{"version":3,"file":"TypewriterEffect.CybasaJD.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/ecKsL6EQDZ9m4L5fXr5r/X93xc2qGvTNcw1rJoSPq/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\";/**\n * Dynamic Typing Animation\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function TypewriterEffect(props){const{words=[{word:\"Hello\"},{word:\"World\"},{word:\"Framer\"}],typingSpeed,deletingSpeed,pauseDuration,blankPause,cursorWeight,cursorColor,font,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 timeoutRef=useRef(null);const blinkRef=useRef(null);const currentWord=words.length>0?words[wordIndex%words.length].word:\"\";// Typing/Deleting Effect\nuseEffect(()=>{if(pause)return;if(timeoutRef.current)clearTimeout(timeoutRef.current);// Add noise for natural speed\nfunction getNoise(base,range=24){return base+(Math.random()-.5)*range;}let delay=typingSpeed;// If we're about to type or delete a blank/space, pause longer\nconst isAtBlankNext=!isDeleting&&currentWord[charIndex]===\" \"||isDeleting&&currentWord[charIndex-1]===\" \";if(!isDeleting&&charIndex<currentWord.length){// If next char is blank, always pause much longer randomly, no matter what\nif(isAtBlankNext){delay=pause?typingSpeed:Math.random()*blankPause+blankPause;}else{// Otherwise, erratic but not huge pauses at most blanks\nif(currentWord[charIndex]===\" \"){delay=getNoise(getNoise(typingSpeed,typingSpeed*1.1),typingSpeed*.45);}else{delay=getNoise(getNoise(typingSpeed,typingSpeed*.5),typingSpeed*.35);}}timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setDisplayed(currentWord.slice(0,charIndex+1));setCharIndex(charIndex+1);});},delay);}else if(!isDeleting&&charIndex===currentWord.length){timeoutRef.current=window.setTimeout(()=>{startTransition(()=>setIsDeleting(true));},pauseDuration);}else if(isDeleting&&charIndex>0){// When deleting blanks, never pause long\nif(isAtBlankNext){delay=getNoise(deletingSpeed,deletingSpeed*.3);}else{delay=getNoise(getNoise(deletingSpeed,deletingSpeed*.6),deletingSpeed*.45);}timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setDisplayed(currentWord.slice(0,charIndex-1));setCharIndex(charIndex-1);});},delay);}else if(isDeleting&&charIndex===0){timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setIsDeleting(false);setWordIndex((wordIndex+1)%words.length);});},pauseDuration);}return()=>{if(timeoutRef.current)clearTimeout(timeoutRef.current);};},[charIndex,isDeleting,pause,wordIndex,currentWord,typingSpeed,deletingSpeed,pauseDuration,words.length]);// 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\",{style:{...style,...font,display:\"inline\",minWidth:1,minHeight:1,width:style?.width===\"100%\"?\"100%\":\"max-content\",height:\"max-content\",whiteSpace:\"pre-wrap\",wordBreak:\"break-word\",overflowWrap:\"break-word\",position:\"relative\"},\"aria-live\":\"polite\",children:[displayed,/*#__PURE__*/_jsx(\"span\",{style:{fontWeight:cursorWeight,color:cursorColor,display:\"inline\",opacity:showCursor?1:0},children:\"|\"})]});}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},blankPause:{type:ControlType.Number,title:\"Blank Pause\",defaultValue:400,min:100,max:1200,unit:\"ms\",step:20},cursorWeight:{type:ControlType.Enum,title:\"Cursor Weight\",options:[\"100\",\"200\",\"300\",\"400\",\"500\",\"600\",\"700\",\"800\",\"900\"],optionTitles:[\"Thin\",\"Extra Light\",\"Light\",\"Regular\",\"Medium\",\"Semibold\",\"Bold\",\"Extra Bold\",\"Black\"],defaultValue:\"700\"},cursorColor:{type:ControlType.Color,title:\"Cursor Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Bold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TypewriterEffect\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TypewriterEffect.map"],"mappings":"sNAMG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,cAAY,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