{"version":3,"file":"TypewriterEffect.CU8IU6RD.mjs","names":["useState","useRef","useMemo","useCallback"],"sources":["https:/framerusercontent.com/modules/hs8lKFupbhj0hT62K6Tt/Q0660kc2ccvev1LtiQyu/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,useCallback}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\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,respectReducedMotion=true,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[prefersReducedMotion,setPrefersReducedMotion]=useState(false);const[isHovered,setIsHovered]=useState(false);const timeoutRef=useRef(null);const blinkRef=useRef(null);const containerRef=useRef(null);// Check for reduced motion preference\nuseEffect(()=>{if(typeof window===\"undefined\")return;const mediaQuery=window.matchMedia(\"(prefers-reduced-motion: reduce)\");setPrefersReducedMotion(mediaQuery.matches&&respectReducedMotion);const handler=e=>{setPrefersReducedMotion(e.matches&&respectReducedMotion);};mediaQuery.addEventListener(\"change\",handler);return()=>mediaQuery.removeEventListener(\"change\",handler);},[respectReducedMotion]);const currentWord=words.length>0?words[wordIndex%words.length].word:\"\";// Typing/Deleting Effect\nuseEffect(()=>{if(prefersReducedMotion){setDisplayed(currentWord);return;}if(pause||isHovered)return;if(timeoutRef.current)clearTimeout(timeoutRef.current);let delay=typingSpeed;if(!isDeleting&&charIndex<currentWord.length){delay=typingSpeed;timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setDisplayed(currentWord.slice(0,charIndex+1));setCharIndex(charIndex+1);});},delay);}else if(!isDeleting&&charIndex===currentWord.length){// Pause at end of word\ntimeoutRef.current=window.setTimeout(()=>{startTransition(()=>setIsDeleting(true));},pauseDuration);}else if(isDeleting&&charIndex>0){delay=deletingSpeed;timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setDisplayed(currentWord.slice(0,charIndex-1));setCharIndex(charIndex-1);});},delay);}else if(isDeleting&&charIndex===0){// Pause before next word\ntimeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setIsDeleting(false);setWordIndex((wordIndex+1)%words.length);});},pauseDuration);}return()=>{if(timeoutRef.current)clearTimeout(timeoutRef.current);};},[charIndex,isDeleting,pause,isHovered,wordIndex,currentWord,typingSpeed,deletingSpeed,pauseDuration,words.length,prefersReducedMotion]);// Reset charIndex when wordIndex changes\nuseEffect(()=>{if(!isDeleting||prefersReducedMotion){startTransition(()=>setCharIndex(0));}},[wordIndex,isDeleting,prefersReducedMotion]);// Blinking Cursor Effect\nuseEffect(()=>{if(prefersReducedMotion){setShowCursor(true);return;}if(blinkRef.current)clearInterval(blinkRef.current);blinkRef.current=window.setInterval(()=>{startTransition(()=>setShowCursor(v=>!v));},500);return()=>{if(blinkRef.current)clearInterval(blinkRef.current);};},[prefersReducedMotion]);// 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]);// Touch/click handlers for mobile interaction\nconst handleTouchStart=useCallback(()=>{startTransition(()=>setPause(true));},[]);const handleTouchEnd=useCallback(()=>{startTransition(()=>setPause(false));},[]);const handleMouseEnter=useCallback(()=>{setIsHovered(true);},[]);const handleMouseLeave=useCallback(()=>{setIsHovered(false);},[]);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\",userSelect:\"none\",WebkitUserSelect:\"none\",touchAction:\"manipulation\",cursor:\"pointer\",WebkitTapHighlightColor:\"transparent\"},\"aria-live\":\"polite\",\"aria-label\":`Animated text: ${displayed}`,role:\"text\",onTouchStart:handleTouchStart,onTouchEnd:handleTouchEnd,onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,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\"},respectReducedMotion:{type:ControlType.Boolean,title:\"Reduced Motion\",defaultValue:true,enabledTitle:\"Respect\",disabledTitle:\"Ignore\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TypewriterEffect\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TypewriterEffect.map"],"mappings":"kOAMG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,cAAY,gBAAc,gBAAc,cAAY,cAAY,eAAa,OAAK,YAAU,uBAAqB,GAAK,SAAO,EAAW,CAAC,EAAU,GAAcA,EAAS,GAAG,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,EAAE,CAAM,CAAC,EAAU,GAAcA,EAAS,EAAE,CAAM,CAAC,EAAM,GAAUA,EAAS,GAAM,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAK,CAAM,CAAC,EAAqB,GAAyBA,EAAS,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAO,EAAWC,EAAO,KAAK,CAAO,EAASA,EAAO,KAAK,CAAO,EAAaA,EAAO,KAAK,CACjsB,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,EAAW,EAAO,WAAW,mCAAmC,CAAC,EAAwB,EAAW,SAAS,EAAqB,CAAC,IAAM,EAAQ,GAAG,CAAC,EAAwB,EAAE,SAAS,EAAqB,EAAiD,OAA9C,EAAW,iBAAiB,SAAS,EAAQ,KAAW,EAAW,oBAAoB,SAAS,EAAQ,EAAG,CAAC,EAAqB,CAAC,CAAC,IAAM,EAAY,EAAM,OAAO,EAAE,EAAM,EAAU,E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