{"version":3,"file":"Typewriter.DFDoaW8E.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/IqgVN8OFegeAwpgjk6FW/I4zDRPXaQrYKBOXB4iZ8/Typewriter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect,useState,useRef}from\"react\";import{motion,useMotionValue,animate}from\"framer-motion\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function TypewriterComponent(props){const{text,cursor}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const Element=props.tag;const[textIndex,setTextIndex]=useState(0);const[characters,setCharacters]=useState(0);const characterMotionValue=useMotionValue(0);const textIndexRef=useRef(0);useEffect(()=>{function animateCharactersUp(newIndex){animate(characterMotionValue,text[newIndex].length,{duration:props.typeDelay*text[newIndex].length,type:\"tween\",ease:\"linear\",onUpdate:latest=>setCharacters(Math.floor(latest)),onComplete:()=>setTimeout(()=>{if(!props.looping&&newIndex==text.length-1&&props.endState==\"showText\"){var _props_completed;(_props_completed=props.completed)===null||_props_completed===void 0?void 0:_props_completed.call(props);}else{animateCharactersDown();}},props.endPause*1e3)});textIndexRef.current=newIndex;setTextIndex(newIndex);}function animateCharactersDown(){animate(characterMotionValue,0,{duration:props.deleteDelay*text[textIndexRef.current].length,type:\"tween\",ease:\"linear\",onUpdate:latest=>setCharacters(Math.floor(latest)),onComplete:()=>setTimeout(()=>{const newIndex=(textIndexRef.current+1)%text.length;if(newIndex==0){if(props.looping){var _props_looped;(_props_looped=props.looped)===null||_props_looped===void 0?void 0:_props_looped.call(props);animateCharactersUp(newIndex);}else{var _props_completed;(_props_completed=props.completed)===null||_props_completed===void 0?void 0:_props_completed.call(props);}}else{animateCharactersUp(newIndex);}},props.startPause*1e3)});}if(props.playing){animateCharactersUp(textIndex);}},[text.length,props.playing]);return /*#__PURE__*/_jsxs(Element,{style:{color:props.fontColor,margin:0,...props.font,...props.style},id:props.id,children:[isCanvas?text[0]:text[textIndex].slice(0,characters),cursor&&/*#__PURE__*/_jsx(motion.span,{style:{color:cursor.color},animate:{opacity:{blink:[1,1,0,0],pulse:[1,0],none:1}[cursor.animation]},transition:{duration:cursor.time,times:cursor.animation==\"blink\"?[0,cursor.time/2,cursor.time/2,cursor.time]:undefined,repeat:Infinity,repeatType:\"mirror\",ease:\"linear\"},children:cursor.character})]});}TypewriterComponent.displayName=\"Typewriter\";addPropertyControls(TypewriterComponent,{text:{type:ControlType.Array,defaultValue:[\"Framestack\",\"Typewriter\"],control:{type:ControlType.String,placeholder:\"Type here...\"}},playing:{type:ControlType.Boolean,defaultValue:true},looping:{type:ControlType.Boolean},endState:{type:ControlType.Enum,options:[\"showText\",\"clearText\"],optionTitles:[\"Show Text\",\"Clear Text\"],displaySegmentedControl:true,segmentedControlDirection:\"vertical\",hidden:props=>props.looping},typeDelay:{type:ControlType.Number,defaultValue:.1,min:0,step:.01},deleteDelay:{type:ControlType.Number,defaultValue:.05,min:0,step:.01},startPause:{type:ControlType.Number,defaultValue:.2,min:0,step:.01},endPause:{type:ControlType.Number,defaultValue:1,min:0,step:.01},cursor:{type:ControlType.Object,optional:true,defaultValue:{character:\"|\",color:\"rgba(0, 0, 0, 0.5)\",animation:\"blink\",time:.5},controls:{character:{type:ControlType.String,defaultValue:\"|\"},color:{type:ControlType.Color,defaultValue:\"rgba(0, 0, 0, 0.5)\"},animation:{type:ControlType.Enum,defaultValue:\"blink\",options:[\"pulse\",\"blink\",\"none\"],optionTitles:[\"Pulse\",\"Blink\",\"None\"],displaySegmentedControl:true,segmentedControlDirection:\"vertical\"},time:{type:ControlType.Number,defaultValue:.5,min:.1,step:.1,hidden:props=>props.animation===\"none\"}}},font:{type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:1.4}},fontColor:{type:ControlType.Color,defaultValue:\"#000\"},tag:{type:ControlType.Enum,defaultValue:\"p\",options:[\"p\",\"span\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"]},completed:{type:ControlType.EventHandler},looped:{type:ControlType.EventHandler}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TypewriterComponent\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Typewriter.map"],"mappings":"sQAGG,SAAwB,EAAoB,EAAM,CAAC,GAAK,CAAC,OAAK,UAAQ,EAAY,EAAS,EAAa,SAAS,GAAG,EAAa,OAAa,EAAQ,EAAM,IAAS,CAAC,EAAU,GAAcA,EAAS,EAAE,CAAM,CAAC,EAAW,GAAeA,EAAS,EAAE,CAAO,EAAqB,EAAe,EAAE,CAAO,EAAaC,EAAO,EAAE,CAA8xC,OAA7xC,MAAc,CAAC,SAAS,EAAoB,EAAS,CAAC,EAAQ,EAAqB,EAAK,GAAU,OAAO,CAAC,SAAS,EAAM,UAAU,EAAK,GAAU,OAAO,KAAK,QAAQ,KAAK,SAAS,SAAS,GAAQ,EAAc,KAAK,MAAM,EAAO,CAAC,CAAC,eAAe,eAAe,CAAC,GAAG,CAAC,EAAM,SAAS,GAAU,EAAK,OAAO,GAAG,EAAM,UAAU,WAAW,CAAC,IAAI,GAAkB,EAAiB,EAAM,YAAa,MAAuC,EAAiB,KAAK,EAAM,MAAO,GAAuB,EAAI,EAAM,SAAS,IAAI,CAAC,CAAC,CAAC,EAAa,QAAQ,EAAS,EAAa,EAAS,CAAE,SAAS,GAAuB,CAAC,EAAQ,EAAqB,EAAE,CAAC,SAAS,EAAM,YAAY,EAAK,EAAa,SAAS,OAAO,KAAK,QAAQ,KAAK,SAAS,SAAS,GAAQ,EAAc,KAAK,MAAM,EAAO,CAAC,CAAC,eAAe,eAAe,CAAC,IAAM,GAAU,EAAa,QAAQ,GAAG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