{"version":3,"file":"OneShotTypewriter.B5cQLdYX.mjs","names":["useState","useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/DXeSNZMAlDcrgDtL87uW/f6aRPkfysR01viKand7K/OneShotTypewriter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useMemo,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,isStaticRenderer,RenderTarget}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function OneShotTypewriter(props){const{text=\"Work\",font,textColor=\"#000000\",cursorColor=\"#000000\",fontSize,letterSpacing,lineHeight,typingSpeed=80,startDelay=0,showCursor=true,hideCursorOnComplete=false,style}=props;const renderTarget=RenderTarget.current();const isStaticTarget=isStaticRenderer()||renderTarget===RenderTarget.canvas||renderTarget===RenderTarget.export||renderTarget===RenderTarget.thumbnail;const[targetText]=useState(()=>text);const[initialTypingSpeed]=useState(()=>typingSpeed);const[initialStartDelay]=useState(()=>startDelay);const[typedText,setTypedText]=useState(()=>isStaticTarget?text:\"\");const[isComplete,setIsComplete]=useState(()=>isStaticTarget);const[cursorVisible,setCursorVisible]=useState(()=>isStaticTarget?!hideCursorOnComplete:true);const typingTimerRef=useRef(null);const startTimerRef=useRef(null);const blinkTimerRef=useRef(null);useEffect(()=>{if(isStaticTarget){startTransition(()=>{setTypedText(targetText);setIsComplete(true);});return;}const safeTypingSpeed=Math.max(10,initialTypingSpeed);const safeStartDelay=Math.max(0,initialStartDelay)*1e3;let currentIndex=0;startTimerRef.current=setTimeout(()=>{typingTimerRef.current=setInterval(()=>{currentIndex+=1;const nextText=targetText.slice(0,currentIndex);startTransition(()=>{setTypedText(nextText);});if(currentIndex>=targetText.length){if(typingTimerRef.current!==null){clearInterval(typingTimerRef.current);}startTransition(()=>{setIsComplete(true);});}},safeTypingSpeed);},safeStartDelay);return()=>{if(startTimerRef.current!==null)clearTimeout(startTimerRef.current);if(typingTimerRef.current!==null)clearInterval(typingTimerRef.current);};},[initialStartDelay,initialTypingSpeed,isStaticTarget,targetText]);useEffect(()=>{if(!showCursor){startTransition(()=>{setCursorVisible(false);});return;}if(isComplete){startTransition(()=>{setCursorVisible(!hideCursorOnComplete);});return;}blinkTimerRef.current=setInterval(()=>{startTransition(()=>{setCursorVisible(prev=>!prev);});},450);return()=>{if(blinkTimerRef.current!==null)clearInterval(blinkTimerRef.current);};},[hideCursorOnComplete,isComplete,showCursor]);const resolvedFontSize=fontSize??font?.fontSize??15;const resolvedLetterSpacing=letterSpacing??font?.letterSpacing??\"-0.01em\";const resolvedLineHeight=lineHeight??font?.lineHeight??\"1.3em\";const textStyle=useMemo(()=>({color:textColor,fontFamily:font?.fontFamily,fontWeight:font?.fontWeight,fontStyle:font?.fontStyle,textAlign:font?.textAlign,fontSize:typeof resolvedFontSize===\"number\"?`${resolvedFontSize}px`:resolvedFontSize,letterSpacing:typeof resolvedLetterSpacing===\"number\"?`${resolvedLetterSpacing}px`:resolvedLetterSpacing,lineHeight:typeof resolvedLineHeight===\"number\"?`${resolvedLineHeight}em`:resolvedLineHeight,whiteSpace:\"pre-wrap\",width:\"max-content\",minWidth:\"max-content\"}),[font,textColor,resolvedFontSize,resolvedLetterSpacing,resolvedLineHeight]);return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",display:\"flex\",alignItems:\"center\",justifyContent:\"flex-start\",width:style?.width??\"100%\",height:style?.height??\"100%\",background:\"transparent\",...style},children:/*#__PURE__*/_jsxs(\"span\",{style:textStyle,children:[typedText,showCursor&&cursorVisible?/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":true,style:{color:cursorColor},children:\"|\"}):null]})});}addPropertyControls(OneShotTypewriter,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Work\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:15,variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#000000\"},cursorColor:{type:ControlType.Color,title:\"Cursor\",defaultValue:\"#000000\"},fontSize:{type:ControlType.Number,title:\"Size\",defaultValue:15,min:8,max:240,step:1,unit:\"px\"},letterSpacing:{type:ControlType.Number,title:\"Spacing\",defaultValue:-.01,min:-5,max:20,step:.01,unit:\"px\"},lineHeight:{type:ControlType.Number,title:\"Line\",defaultValue:1.3,min:.6,max:3,step:.05,unit:\"em\"},typingSpeed:{type:ControlType.Number,title:\"Speed\",defaultValue:80,min:10,max:1e3,step:10,unit:\"ms\"},startDelay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:10,step:.1,unit:\"s\"},showCursor:{type:ControlType.Boolean,title:\"Cursor\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},hideCursorOnComplete:{type:ControlType.Boolean,title:\"Hide End\",defaultValue:false,enabledTitle:\"Hide\",disabledTitle:\"Keep\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"OneShotTypewriter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./OneShotTypewriter.map"],"mappings":"2NAGG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,OAAK,OAAO,OAAK,YAAU,UAAU,cAAY,UAAU,WAAS,gBAAc,aAAW,cAAY,GAAG,aAAW,EAAE,aAAW,GAAK,uBAAqB,GAAM,SAAO,EAAY,EAAa,EAAa,QAAQ,EAAQ,EAAe,EAAiB,GAAG,IAAe,EAAa,QAAQ,IAAe,EAAa,QAAQ,IAAe,EAAa,UAAe,CAAC,GAAYA,MAAa,CAAI,EAAO,CAAC,GAAoBA,MAAa,CAAW,EAAO,CAAC,GAAmBA,MAAa,C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