{"version":3,"file":"TextAnimation.CFzWCQu0.mjs","names":["useState","useRef","__esmMin","init_npm_react_18_3_1","_e","de","p","c","init_jsx_runtime","ce","motion","init_framer_motion_DhsWWWsN","init_framer_BL9pqxmF","addPropertyControls","ControlType","AnimatedText","props","showHighlights","setShowHighlights","isInView","setIsInView","containerRef","observer","entries","entry","timer","delay","text","textParts","parts","regex","match","input","font","part","highlightColor","extendDuration","revealDuration","frameColor","index","normalColor","init_TextAnimation"],"sources":["https:/framerusercontent.com/modules/iV3iM3tBJ9ZS0AyTr4B6/mvhcL2ubF4sBrTvINHnB/TextAnimation.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";import{useState,useEffect,useRef}from\"react\";/**\n * @framerDisableUnlink\n */export default function AnimatedText(props){const{text=\"This is a [test] tile. we can [do] it.\",normalColor=\"#FFFFFF\",highlightColor=\"#60A5FA\",frameColor=\"#FFFFFF\",delay=200,extendDuration=200,revealDuration=200,font,textTransform=\"none\"}=props;const[showHighlights,setShowHighlights]=useState(false);const[isInView,setIsInView]=useState(false);const containerRef=useRef(null);useEffect(()=>{const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting&&!isInView){setIsInView(true);}});},{threshold:.1});if(containerRef.current){observer.observe(containerRef.current);}return()=>{if(containerRef.current){observer.unobserve(containerRef.current);}};},[isInView]);useEffect(()=>{if(!isInView)return;// Start the animation after component is in view + delay\nconst timer=setTimeout(()=>{setShowHighlights(true);},delay);return()=>clearTimeout(timer);},[delay,text,isInView]);// Parse the text to extract normal and highlighted parts\nconst parseText=input=>{const parts=[];const regex=/\\[([^\\]]+)\\]|([^\\[]+)/g;let match;while((match=regex.exec(input))!==null){if(match[1]){// Highlighted text (inside brackets)\nparts.push({text:match[1],isHighlight:true});}else if(match[2]){// Normal text\nparts.push({text:match[2],isHighlight:false});}}return parts;};const textParts=parseText(text);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:/*#__PURE__*/_jsx(\"p\",{style:{fontSize:font?.fontSize,fontFamily:font?.fontFamily,fontWeight:font?.fontWeight,lineHeight:font?.lineHeight,letterSpacing:font?.letterSpacing,margin:0,textAlign:font?.textAlign,textTransform:textTransform,display:\"inline\",whiteSpace:\"pre-wrap\"},children:textParts.map((part,index)=>{if(!part.isHighlight){return /*#__PURE__*/_jsx(\"span\",{style:{color:normalColor},children:part.text},index);}return /*#__PURE__*/_jsxs(\"span\",{style:{position:\"relative\",display:\"inline-block\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{visibility:\"hidden\"},children:part.text}),/*#__PURE__*/_jsxs(\"span\",{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(motion.span,{style:{position:\"absolute\",top:0,left:0,color:highlightColor,whiteSpace:\"nowrap\"},initial:{clipPath:\"inset(0 100% 0 0)\"},animate:showHighlights?{clipPath:[\"inset(0 100% 0 0)\",\"inset(0 0% 0 0)\"]}:{},transition:{duration:(extendDuration+revealDuration)/1e3,ease:\"linear\"},children:part.text}),showHighlights&&/*#__PURE__*/_jsx(motion.span,{style:{position:\"absolute\",top:0,left:0,height:\"100%\",backgroundColor:frameColor,transformOrigin:\"left\"},initial:{width:0},animate:{width:[\"0%\",\"100%\",\"100%\",\"0%\"],left:[\"0%\",\"0%\",\"0%\",\"100%\"]},transition:{duration:(extendDuration+revealDuration)/1e3,times:[0,extendDuration/(extendDuration+revealDuration),extendDuration/(extendDuration+revealDuration),1],ease:\"linear\"}})]})]},index);})})});}AnimatedText.defaultProps={text:\"This is a [test] tile. we can [do] it.\",normalColor:\"#FFFFFF\",highlightColor:\"#60A5FA\",frameColor:\"#FFFFFF\",delay:200,extendDuration:200,revealDuration:200,textTransform:\"none\"};addPropertyControls(AnimatedText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"This is a [test] tile. we can [do] it.\",displayTextArea:true},normalColor:{type:ControlType.Color,title:\"Normal Color\",defaultValue:\"#FFFFFF\"},highlightColor:{type:ControlType.Color,title:\"Highlight Color\",defaultValue:\"#60A5FA\"},frameColor:{type:ControlType.Color,title:\"Frame Color\",defaultValue:\"#FFFFFF\"},delay:{type:ControlType.Number,title:\"Delay (ms)\",defaultValue:200,min:0,max:5e3,step:50},extendDuration:{type:ControlType.Number,title:\"Extend Duration (ms)\",defaultValue:200,min:50,max:2e3,step:50},revealDuration:{type:ControlType.Number,title:\"Reveal Duration (ms)\",defaultValue:200,min:50,max:2e3,step:50},font:{type:ControlType.Font,controls:\"extended\"},textTransform:{type:ControlType.Enum,title:\"Text Transform\",options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],optionTitles:[\"None\",\"Uppercase\",\"Lowercase\",\"Capitalize\"],defaultValue:\"none\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AnimatedText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextAnimation.map"],"mappings":"A,gPAEG,SAAwBe,EAAa,EAAM,CAAC,GAAK,CAAC,OAAK,yCAAyC,cAAY,UAAU,iBAAe,UAAU,aAAW,UAAU,QAAM,IAAI,iBAAe,IAAI,iBAAe,IAAI,OAAK,gBAAc,QAAQC,EAAW,CAACC,EAAeC,GAAmBlB,EAAS,EAAK,EAAO,CAACmB,EAASC,GAAapB,EAAS,EAAK,EAAQqB,EAAapB,EAAO,IAAI,EAAEQ,MAAc,CAAC,IAAMa,EAAS,IAAI,qBAAqB,GAAS,CAACC,EAAQ,QAAQ,GAAO,CAAIC,EAAM,gBAAgB,CAACL,GAAUC,EAAY,EAAI,CAAG,CAAC,CAAE,EAAE,CAAC,UAAU,EAAE,CAAC,EAAmE,OAA9D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