{"version":3,"file":"TypewriterEffect.Db4e1ZJx.mjs","names":["useState","useRef","useMemo","__esmMin","init_ssg_sandbox_shims","te","window","_e","pe","p","c","init_jsx_runtime","ce","init_npm_react_18_3_1","de","useInView","init_framer_motion_DhsWWWsN","init_framer_CKT6jEEQ","addPropertyControls","ControlType","TypewriterEffect","props","displayed","setDisplayed","isDeleting","setIsDeleting","wordIndex","setWordIndex","charIndex","setCharIndex","pause","setPause","showCursor","setShowCursor","typingStarted","setTypingStarted","timeoutRef","blinkRef","containerRef","inView","currentWord","words","delay","typingSpeed","v","fontSize","font","style","textColor","cursorColor","cursorWidth","cursorHeight","init_TypewriterEffect"],"sources":["https:/framerusercontent.com/modules/7i80DUhHnAoyoMPOkEsl/oGVJLz0zTPuAO4uOAiJ4/TypewriterEffect.js"],"sourcesContent":["// Dynamic Typing Animation Component with Customizable Cursor and Typography\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useRef,useMemo,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useInView}from\"framer-motion\";/**\n * Dynamic Typing Animation\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function TypewriterEffect(props){const{words=[{word:\"Hello\"},{word:\"World\"},{word:\"Framer\"}],typingSpeed,deletingSpeed,pauseDuration,cursorColor,cursorWidth,cursorHeight,font,textColor,style}=props;const[displayed,setDisplayed]=useState(\"\");const[isDeleting,setIsDeleting]=useState(false);const[wordIndex,setWordIndex]=useState(0);const[charIndex,setCharIndex]=useState(0);const[pause,setPause]=useState(false);const[showCursor,setShowCursor]=useState(true);const[typingStarted,setTypingStarted]=useState(false);const timeoutRef=useRef(null);const blinkRef=useRef(null);const containerRef=useRef(null);const inView=useInView(containerRef,{once:true,amount:.2});const currentWord=words.length>0?words[wordIndex%words.length].word:\"\";// Typing/Deleting Effect\nuseEffect(()=>{if(!inView||typingStarted)return;if(inView&&!typingStarted)startTransition(()=>setTypingStarted(true));},[inView,typingStarted]);useEffect(()=>{if(!typingStarted)return;if(pause)return;if(timeoutRef.current)clearTimeout(timeoutRef.current);let delay=typingSpeed;if(charIndex<currentWord.length){delay=typingSpeed;timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setDisplayed(currentWord.slice(0,charIndex+1));setCharIndex(charIndex+1);});},delay);}else if(charIndex===currentWord.length){// Pause at end of word, show text and do nothing\n}return()=>{if(timeoutRef.current)clearTimeout(timeoutRef.current);};},[charIndex,pause,wordIndex,currentWord,typingSpeed,words.length,typingStarted]);// Reset charIndex when wordIndex changes\nuseEffect(()=>{if(!isDeleting){startTransition(()=>setCharIndex(0));}},[wordIndex,isDeleting]);// Blinking Cursor Effect\nuseEffect(()=>{if(blinkRef.current)clearInterval(blinkRef.current);blinkRef.current=window.setInterval(()=>{startTransition(()=>setShowCursor(v=>!v));},500);return()=>{if(blinkRef.current)clearInterval(blinkRef.current);};},[]);// Font size for cursor height calculation\nconst fontSize=useMemo(()=>{if(font&&font.fontSize){if(typeof font.fontSize===\"string\"&&font.fontSize.endsWith(\"px\")){return parseFloat(font.fontSize);}else if(typeof font.fontSize===\"number\"){return font.fontSize;}}return 32;},[font]);return /*#__PURE__*/_jsxs(\"span\",{ref:containerRef,style:{...style,...font,color:textColor,display:\"inline-flex\",alignItems:\"center\",minWidth:1,minHeight:1,width:\"max-content\",height:\"max-content\",whiteSpace:\"pre\"},\"aria-live\":\"polite\",children:[displayed,/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":\"true\",style:{display:\"inline-block\",background:cursorColor,width:cursorWidth,height:fontSize*(cursorHeight/100),marginLeft:2,marginRight:2,verticalAlign:\"bottom\",opacity:showCursor?1:0,transition:\"opacity 0.1s\",borderRadius:2}})]});}addPropertyControls(TypewriterEffect,{words:{type:ControlType.Array,title:\"Words\",control:{type:ControlType.Object,controls:{word:{type:ControlType.String,defaultValue:\"Hello\"}}},defaultValue:[{word:\"Hello\"},{word:\"World\"},{word:\"Framer\"}],maxCount:10},typingSpeed:{type:ControlType.Number,title:\"Typing Speed\",defaultValue:100,min:20,max:500,unit:\"ms\",step:5},deletingSpeed:{type:ControlType.Number,title:\"Deleting Speed\",defaultValue:60,min:10,max:500,unit:\"ms\",step:5},pauseDuration:{type:ControlType.Number,title:\"Pause Duration\",defaultValue:1e3,min:200,max:3e3,unit:\"ms\",step:50},cursorColor:{type:ControlType.Color,title:\"Cursor Color\",defaultValue:\"#FFFFFF\"},cursorWidth:{type:ControlType.Number,title:\"Cursor Width\",defaultValue:2,min:1,max:8,unit:\"px\",step:1},cursorHeight:{type:ControlType.Number,title:\"Cursor Height\",defaultValue:100,min:50,max:120,unit:\"%\",step:1},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Bold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TypewriterEffect\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TypewriterEffect.map"],"mappings":"A,4QAMG,SAAwBoB,EAAiB,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC,KAAK,QAAQ,CAAC,EAAE,cAAY,gBAAc,gBAAc,cAAY,cAAY,eAAa,OAAK,YAAU,SAAOC,EAAW,CAACC,EAAUC,GAAcvB,EAAS,EAAE,EAAO,CAACwB,EAAWC,GAAezB,EAAS,EAAK,EAAO,CAAC0B,EAAUC,GAAc3B,EAAS,CAAC,EAAO,CAAC4B,EAAUC,GAAc7B,EAAS,CAAC,EAAO,CAAC8B,EAAMC,GAAU/B,EA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