{"version":3,"file":"Typewriter_Code.Fr-m68Bn.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/yNbtCc6LcwWeoSBSFgLp/HoNGNcgGK3x2gvd7qgwk/Typewriter_Code.js"],"sourcesContent":["// Typewriter effect component with customizable settings for font, colors, speed, delays, multiple lines, and loop option\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * Typewriter Effect Component\n * \n * Creates a realistic typing animation with customizable speed, delays, and styling options.\n * Supports multiple lines, looping, and cursor customization.\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function Typewriter(props){const{text=\"Hello World!\",headingLevel=\"h1\",font,textColor,cursorColor,showCursor,cursorThickness,typingSpeed,delayStart,enableLoop,hideCursorWhenDone}=props;const[currentText,setCurrentText]=useState(\"\");const[isTyping,setIsTyping]=useState(false);const[showCursorBlink,setShowCursorBlink]=useState(true);const[isComplete,setIsComplete]=useState(false);const[hasStarted,setHasStarted]=useState(false);const timeoutRef=useRef(null);const isStatic=useIsStaticRenderer();// Cleanup function to clear timeout\nconst clearCurrentTimeout=()=>{if(timeoutRef.current){clearTimeout(timeoutRef.current);timeoutRef.current=null;}};useEffect(()=>{if(isStatic){setCurrentText(text||\"\");return;}// Initial delay before starting\nif(!hasStarted){clearCurrentTimeout();timeoutRef.current=window.setTimeout(()=>{startTransition(()=>setHasStarted(true));},delayStart*1e3);return;}if(currentText.length<text.length){startTransition(()=>setIsTyping(true));startTransition(()=>setIsComplete(false));clearCurrentTimeout();timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setCurrentText(prev=>text.slice(0,prev.length+1));});},typingSpeed*1e3);}else{startTransition(()=>setIsTyping(false));startTransition(()=>setIsComplete(true));if(enableLoop){clearCurrentTimeout();timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setCurrentText(\"\");setHasStarted(false);});},2e3);}}return()=>clearCurrentTimeout();},[currentText,isTyping,text,typingSpeed,delayStart,hasStarted,enableLoop,isStatic]);// Cursor blinking effect\nuseEffect(()=>{if(isStatic||!showCursor)return;const blinkInterval=setInterval(()=>{startTransition(()=>setShowCursorBlink(prev=>!prev));},530);return()=>clearInterval(blinkInterval);},[showCursor,isStatic]);// Cleanup on unmount\nuseEffect(()=>{return()=>clearCurrentTimeout();},[]);const isFixedWidth=props?.style&&props.style.width===\"100%\";const shouldShowCursor=showCursor&&(!hideCursorWhenDone||!isComplete||enableLoop);const HeadingTag=headingLevel;return /*#__PURE__*/_jsx(\"div\",{style:{...props.style,position:\"relative\",...isFixedWidth?{...props?.style}:{width:\"max-content\"},display:\"inline-block\"},children:/*#__PURE__*/_jsxs(HeadingTag,{style:{fontSize:font.fontSize,fontStyle:font.fontStyle,fontWeight:font.fontWeight,fontFamily:font.fontFamily,letterSpacing:font.letterSpacing,lineHeight:font.lineHeight,color:textColor,whiteSpace:\"pre-wrap\",margin:0},children:[currentText,shouldShowCursor&&/*#__PURE__*/_jsx(\"span\",{style:{color:cursorColor,opacity:showCursorBlink?1:0,transition:\"opacity 0.1s ease-in-out\",display:\"inline-block\",width:`${cursorThickness}px`,backgroundColor:cursorColor,height:\"0.9em\",marginLeft:\"2px\",verticalAlign:\"middle\"}})]})});}addPropertyControls(Typewriter,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Hello World!\",placeholder:\"Enter text...\"},headingLevel:{type:ControlType.Enum,title:\"Heading Level\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"H4\",\"H5\",\"H6\"],defaultValue:\"h1\",displaySegmentedControl:false},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"24px\",variant:\"Regular\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},showCursor:{type:ControlType.Boolean,title:\"Show Cursor\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},cursorColor:{type:ControlType.Color,title:\"Cursor Color\",defaultValue:\"#000000\",hidden:({showCursor})=>!showCursor},cursorThickness:{type:ControlType.Number,title:\"Cursor Thickness\",defaultValue:2,min:1,max:10,step:1,unit:\"px\",hidden:({showCursor})=>!showCursor},typingSpeed:{type:ControlType.Number,title:\"Typing Speed\",defaultValue:.1,min:.01,max:5,step:.01,unit:\"s\"},delayStart:{type:ControlType.Number,title:\"Delay Start\",defaultValue:0,min:0,max:50,step:.1,unit:\"s\"},enableLoop:{type:ControlType.Boolean,title:\"Enable Loop\",defaultValue:true,enabledTitle:\"Loop\",disabledTitle:\"Once\"},hideCursorWhenDone:{type:ControlType.Boolean,title:\"Hide Cursor When Done\",defaultValue:false,enabledTitle:\"Hide\",disabledTitle:\"Keep\",hidden:({showCursor})=>!showCursor}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Typewriter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Typewriter_Code.map"],"mappings":"uNASG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,eAAe,eAAa,KAAK,OAAK,YAAU,cAAY,aAAW,kBAAgB,cAAY,aAAW,aAAW,sBAAoB,EAAW,CAAC,EAAY,GAAgBA,EAAS,GAAG,CAAM,CAAC,EAAS,GAAaA,EAAS,GAAM,CAAM,CAAC,EAAgB,GAAoBA,EAAS,GAAK,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAO,EAAWC,EAAO,KAAK,CAAO,EAAS,GAAqB,CAC3f,MAAwB,CAAC,AAAwD,EAAW,WAA5C,aA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