{"version":3,"file":"Typewriter.DJfF6BV_.mjs","names":["useState","useRef","useMemo","_Fragment","__esmMin","init_ssg_sandbox_shims","_e","de","init_jsx_runtime","pe","p","init_npm_react_18_3_1","ce","window","init_framer_D1IzEvwH","addPropertyControls","ControlType","Typewriter","props","displayedChars","setDisplayedChars","isComplete","setIsComplete","showCursor","setShowCursor","indexRef","timeoutRef","containerRef","hiddenRef","mountedRef","textComponent","textElement","computed","containerStyles","textNodes","extractedHTML","nodes","renderedElement","styleCache","getElementStyles","element","styles","traverse","domElement","textContent","inheritedStyles","isBlockElement","currentStyles","child","units","result","mode","node","unit","idx","char","autoStart","animate","speed","loop","cursor","interval","prev","isFixedWidth","style","l","fadeEffect","fadeDuration","cursorColor","init_Typewriter"],"sources":["https:/framerusercontent.com/modules/BImBBepmbIjs4G88iLD0/jYbRnr5IB3mPZGWQkTuc/Typewriter.js"],"sourcesContent":["// Typewriter effect component that works with formatted text blocks\n// Supports letter-by-letter or word-by-word animation\n// Preserves HTML formatting and styling including multiple colors\n// Use a ComponentInstance control to link to a Framer text component and extract its content\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useState,useRef,useMemo}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Typewriter Effect\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 100\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function Typewriter(props){const{textComponent,speed=50,mode=\"letter\",autoStart=true,loop=false,cursor=true,cursorColor=\"#000000\",fadeEffect=false,fadeDuration=300,style}=props;const[displayedChars,setDisplayedChars]=useState(0);const[isComplete,setIsComplete]=useState(false);const[showCursor,setShowCursor]=useState(true);const indexRef=useRef(0);const timeoutRef=useRef(null);const containerRef=useRef(null);const hiddenRef=useRef(null);const mountedRef=useRef(false);// Force re-extraction after hidden component renders\nuseEffect(()=>{if(textComponent){mountedRef.current=true;}},[textComponent]);// Extract HTML content and styles from the linked component\nconst{extractedHTML,containerStyles}=useMemo(()=>{if(typeof window===\"undefined\"||!hiddenRef.current||!mountedRef.current){return{extractedHTML:\"\",containerStyles:{}};}// Get the first child element (the actual text component)\nconst textElement=hiddenRef.current.firstElementChild;if(!textElement)return{extractedHTML:\"\",containerStyles:{}};// Get computed styles from the original component\nconst computed=window.getComputedStyle(textElement);const containerStyles={color:computed.color,fontSize:computed.fontSize,fontFamily:computed.fontFamily,fontWeight:computed.fontWeight,fontStyle:computed.fontStyle,letterSpacing:computed.letterSpacing,lineHeight:computed.lineHeight,textAlign:computed.textAlign,textDecoration:computed.textDecoration,textTransform:computed.textTransform,fontVariant:computed.fontVariant};const content=textElement.innerHTML;return{extractedHTML:content,containerStyles};},[textComponent,mountedRef.current]);// Parse HTML and extract text nodes with their formatting\nconst textNodes=useMemo(()=>{if(typeof window===\"undefined\"||!extractedHTML||!hiddenRef.current)return[];const nodes=[];// Get the actual rendered element to extract computed styles\nconst renderedElement=hiddenRef.current.firstElementChild;if(!renderedElement)return[];// Cache computed styles to avoid repeated getComputedStyle calls\nconst styleCache=new Map;const getElementStyles=element=>{if(styleCache.has(element)){return styleCache.get(element);}const computed=window.getComputedStyle(element);const styles={color:computed.color,fontSize:computed.fontSize,fontFamily:computed.fontFamily,fontWeight:computed.fontWeight,fontStyle:computed.fontStyle,letterSpacing:computed.letterSpacing,lineHeight:computed.lineHeight,textDecoration:computed.textDecoration,textTransform:computed.textTransform};styleCache.set(element,styles);return styles;};const traverse=(domElement,inheritedStyles={})=>{if(domElement.nodeType===Node.TEXT_NODE){const textContent=domElement.textContent||\"\";if(textContent){nodes.push({text:textContent,styles:{...inheritedStyles}});}}else if(domElement.nodeType===Node.ELEMENT_NODE){const element=domElement;// Handle BR elements as line breaks\nif(element.tagName===\"BR\"){nodes.push({text:\"\\n\",styles:{...inheritedStyles}});return;}// Handle block-level elements that should create line breaks\nconst isBlockElement=[\"DIV\",\"P\",\"H1\",\"H2\",\"H3\",\"H4\",\"H5\",\"H6\"].includes(element.tagName);const currentStyles={...inheritedStyles,...getElementStyles(element)};// Add line break before block element (except for the first one)\nif(isBlockElement&&nodes.length>0){nodes.push({text:\"\\n\",styles:currentStyles});}Array.from(domElement.childNodes).forEach(child=>{traverse(child,currentStyles);});}};traverse(renderedElement,{});return nodes;},[extractedHTML,textComponent]);// Build character/word array with formatting info\nconst units=useMemo(()=>{const result=[];textNodes.forEach(node=>{const chars=mode===\"letter\"?node.text.split(\"\"):node.text.split(\" \");chars.forEach((char,idx)=>{const unit=mode===\"word\"&&idx>0?\" \"+char:char;result.push({char:unit,styles:node.styles});});});return result;},[textNodes,mode]);useEffect(()=>{if(!autoStart)return;const animate=()=>{if(indexRef.current<units.length){setDisplayedChars(indexRef.current+1);indexRef.current++;timeoutRef.current=window.setTimeout(animate,speed);}else{setIsComplete(true);if(loop){timeoutRef.current=window.setTimeout(()=>{indexRef.current=0;setDisplayedChars(0);setIsComplete(false);// Restart animation after reset\ntimeoutRef.current=window.setTimeout(animate,speed);},1e3);}}};indexRef.current=0;setDisplayedChars(0);setIsComplete(false);timeoutRef.current=window.setTimeout(animate,speed);return()=>{if(timeoutRef.current!==null){clearTimeout(timeoutRef.current);}};},[speed,autoStart,loop,units,textComponent]);// Cursor blink effect\nuseEffect(()=>{if(!cursor)return;const interval=setInterval(()=>{setShowCursor(prev=>!prev);},530);return()=>clearInterval(interval);},[cursor]);const isFixedWidth=style?.width===\"100%\";return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{ref:hiddenRef,style:{position:\"fixed\",visibility:\"hidden\",opacity:0,pointerEvents:\"none\",top:-9999,left:-9999},children:textComponent}),/*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{...style,...containerStyles,position:\"relative\",overflow:\"visible\",minHeight:\"1em\",display:\"flex\",alignItems:\"flex-start\",...isFixedWidth?{}:{width:\"max-content\"}},children:[fadeEffect&&/*#__PURE__*/_jsx(\"style\",{children:`\n                            @keyframes fadeIn {\n                                from {\n                                    opacity: 0;\n                                }\n                                to {\n                                    opacity: 1;\n                                }\n                            }\n                        `}),/*#__PURE__*/_jsxs(\"span\",{style:{whiteSpace:\"pre-wrap\",wordBreak:\"break-word\"},children:[units.slice(0,displayedChars).map((unit,idx)=>/*#__PURE__*/_jsx(\"span\",{style:{...unit.styles,...fadeEffect&&{animation:`fadeIn ${fadeDuration}ms ease-in`}},children:unit.char},idx)),cursor&&!isComplete&&/*#__PURE__*/_jsx(\"span\",{style:{color:cursorColor,opacity:showCursor?1:0,transition:\"opacity 0.1s\"},children:\"|\"})]})]})]});}addPropertyControls(Typewriter,{textComponent:{type:ControlType.ComponentInstance,title:\"Text Component\"},mode:{type:ControlType.Enum,title:\"Mode\",options:[\"letter\",\"word\"],optionTitles:[\"Letter\",\"Word\"],defaultValue:\"letter\",displaySegmentedControl:true},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:50,min:10,max:500,step:10,unit:\"ms\"},autoStart:{type:ControlType.Boolean,title:\"Auto Start\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},cursor:{type:ControlType.Boolean,title:\"Show Cursor\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},cursorColor:{type:ControlType.Color,title:\"Cursor Color\",defaultValue:\"#000000\",hidden:({cursor})=>!cursor},fadeEffect:{type:ControlType.Boolean,title:\"Fade Effect\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},fadeDuration:{type:ControlType.Number,title:\"Fade Duration\",defaultValue:300,min:50,max:1e3,step:50,unit:\"ms\",hidden:({fadeEffect})=>!fadeEffect}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Typewriter\",\"slots\":[\"textComponent\"],\"annotations\":{\"framerIntrinsicWidth\":\"400\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"100\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Typewriter.map"],"mappings":"A,sNAYG,SAAwBiB,EAAW,EAAM,CAAC,GAAK,CAAC,gBAAc,QAAM,GAAG,OAAK,SAAS,YAAU,GAAK,OAAK,GAAM,SAAO,GAAK,cAAY,UAAU,aAAW,GAAM,eAAa,IAAI,SAAOC,EAAW,CAACC,EAAeC,GAAmBpB,EAAS,CAAC,EAAO,CAACqB,EAAWC,GAAetB,EAAS,EAAK,EAAO,CAACuB,EAAWC,GAAexB,EAAS,EAAI,EAAQyB,EAASxB,EAAO,CAAC,EAAQyB,EAAWzB,EAAO,IAAI,EAAQ0B,EAAa1B,EAAO,IAAI,EAAQ2B,EAAU3B,EAAO,IAAI,EAAQ4B,EAAW5B,EAAO,EAAK,EACveW,MAAc,CAAIkB,IAAe,EAAW,QAAQ,GAAM,EAAE,CAACA,CAAa,CAAC,EAC3E,GAAK,CAAC,gBAAc,mBAAiB5B,MAAY,CAAC,GAAUW,IAAS,QAAa,CAACe,EAAU,SAAS,CAACC,EAAW,QAAS,MAAM,CAAC,cAAc,GAAG,gBAAgB,CAAC,CAAC,EACrK,IAAME,EAAYH,EAAU,QAAQ,kBAAkB,GAAG,CAACG,EAAY,MAAM,CAAC,cAAc,GAAG,gBAAgB,CAAC,CAAC,EAChH,IAAMC,EAASnB,EAAO,iBAAiBkB,CAAW,EAAQE,EAAgB,CAAC,MAAMD,EAAS,MAAM,SAASA,EAAS,SAAS,WAAWA,EAAS,WAAW,WAAWA,EAAS,WAAW,UAAUA,EAAS,UAAU,cAAcA,EAAS,cAAc,WAAWA,EAAS,WAAW,UAAUA,EAAS,UAAU,eAAeA,EAAS,eAAe,cAAcA,EAAS,cAAc,YAAYA,EAAS,WAAW,EAAsC,MAAM,CAAC,cAA7BD,EAAY,UAAuC,iBAAe,C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