{"version":3,"file":"TextAnimation.BPRtOnIW.mjs","names":["useState","useRef","useEffect","_jsx","_jsxs","__esmMin","init_npm_react_18_3_1","_e","de","p","c","init_jsx_runtime","ce","init_framer_ChujFWHC","addPropertyControls","ControlType","motion","init_framer_motion_1EwlFBEG","AnimatedText","props","text","normalColor","highlightColor","frameColor","delay","extendDuration","revealDuration","font","textTransform","showHighlights","setShowHighlights","isInView","setIsInView","containerRef","observer","entries","entry","timer","textParts","input","parts","regex","match","part","index","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,SAAwBkB,EAAaC,EAAM,CAAC,GAAK,CAACC,OAAK,yCAAyCC,cAAY,UAAUC,iBAAe,UAAUC,aAAW,UAAUC,QAAM,IAAIC,iBAAe,IAAIC,iBAAe,IAAIC,OAAKC,gBAAc,QAAQT,EAAW,CAACU,EAAeC,GAAmB9B,EAAS,EAAK,EAAO,CAAC+B,EAASC,GAAahC,EAAS,EAAK,EAAQiC,EAAahC,EAAO,IAAI,EAAEC,MAAc,CAAC,IAAMgC,EAAS,IAAI,qBAAqBC,GAAS,CAACA,EAAQ,QAAQC,GAAO,CAAIA,EAAM,gBAAgB,CAACL,GAAUC,EAAY,EAAI,CAAG,CAAC,CAAE,EAAE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