{"version":3,"file":"AnimatedUnderlineText.DFDLSkG2.mjs","names":["React.useMemo"],"sources":["https:/framerusercontent.com/modules/JLtgeHHraUisf8tuVwcO/zjJFR4ck6hTDfeEpUwVZ/AnimatedUnderlineText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{motion}from\"framer-motion\";function escapeRegExp(value){return value.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");}function splitLineByPhrases(line,phrases){if(!line)return[{text:\"\",underlined:false}];if(phrases.length===0)return[{text:line,underlined:false}];const pattern=phrases.map(escapeRegExp).join(\"|\");const regex=new RegExp(`(${pattern})`,\"gi\");const out=[];let lastIndex=0;let match=regex.exec(line);while(match){const start=match.index;const matched=match[0];if(start>lastIndex){out.push({text:line.slice(lastIndex,start),underlined:false});}out.push({text:matched,underlined:true});lastIndex=start+matched.length;match=regex.exec(line);}if(lastIndex<line.length){out.push({text:line.slice(lastIndex),underlined:false});}return out.length>0?out:[{text:line,underlined:false}];}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function AnimatedUnderlineText(props){const{text,underlinedWords,underlineThickness,underlineColor,delay,duration,font,textColor,textAlign,maxWidth}=props;const isStatic=useIsStaticRenderer();const lines=React.useMemo(()=>(text??\"\").split(\"\\n\"),[text]);const phrases=React.useMemo(()=>{return(underlinedWords??\"\").split(\",\").map(v=>v.trim()).filter(Boolean).sort((a,b)=>b.length-a.length);},[underlinedWords]);const fontStyle=React.useMemo(()=>{return{fontSize:font?.fontSize,fontWeight:font?.fontWeight,fontFamily:font?.fontFamily,lineHeight:font?.lineHeight,letterSpacing:font?.letterSpacing,fontStyle:font?.fontStyle};},[font]);return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",width:\"100%\",maxWidth:`${maxWidth}px`,margin:\"0 auto\",color:textColor,background:\"transparent\",textAlign,...fontStyle},children:lines.map((line,lineIndex)=>{const segments=splitLineByPhrases(line,phrases);return /*#__PURE__*/_jsx(\"div\",{style:{display:\"block\",width:\"100%\",minHeight:\"1em\",whiteSpace:\"pre-wrap\"},children:segments.map((segment,i)=>{if(!segment.underlined){return /*#__PURE__*/_jsx(\"span\",{children:segment.text||(line.length===0?\"\\xa0\":\"\")},`s-${lineIndex}-${i}`);}return /*#__PURE__*/_jsx(motion.span,{initial:isStatic?{backgroundSize:`100% ${underlineThickness}px`}:{backgroundSize:`0% ${underlineThickness}px`},animate:{backgroundSize:`100% ${underlineThickness}px`},transition:{delay,duration,ease:\"easeOut\"},style:{display:\"inline\",paddingBottom:`${Math.max(2,underlineThickness)}px`,backgroundImage:`linear-gradient(${underlineColor}, ${underlineColor})`,backgroundRepeat:\"no-repeat\",backgroundPosition:\"0 100%\",boxDecorationBreak:\"clone\",WebkitBoxDecorationBreak:\"clone\"},children:segment.text},`u-${lineIndex}-${i}`);})},`line-${lineIndex}`);})});}AnimatedUnderlineText.displayName=\"Animated Underline Text\";addPropertyControls(AnimatedUnderlineText,{text:{type:ControlType.String,title:\"Text\",displayTextArea:true,defaultValue:\"Learn to move\\nsafely and\\nguide others.\"},underlinedWords:{type:ControlType.String,title:\"Underlined Words\",defaultValue:\"safely, guide others\",placeholder:\"word, phrase, another phrase\"},underlineThickness:{type:ControlType.Number,title:\"Underline Thickness\",defaultValue:4,min:1,max:16,step:1,unit:\"px\"},underlineColor:{type:ControlType.Color,title:\"Underline Color\",defaultValue:\"#123A2F\"},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:.3,min:0,max:5,step:.1,unit:\"s\"},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:.9,min:.1,max:5,step:.1,unit:\"s\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"68px\",variant:\"Semibold\",lineHeight:\"1.2em\",letterSpacing:\"-0.01em\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#1C4A3A\"},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\",displaySegmentedControl:true},maxWidth:{type:ControlType.Number,title:\"Max Width\",defaultValue:980,min:240,max:1600,step:10,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AnimatedUnderlineText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AnimatedUnderlineText.map"],"mappings":"mOAAiL,SAAS,EAAa,EAAM,CAAC,OAAO,EAAM,QAAQ,sBAAsB,MAAM,CAAE,CAAC,SAAS,EAAmB,EAAK,EAAQ,CAAC,GAAG,CAAC,EAAK,MAAM,CAAC,CAAC,KAAK,GAAG,WAAW,EAAK,CAAC,EAAE,GAAG,EAAQ,SAAS,EAAE,MAAM,CAAC,CAAC,KAAK,EAAK,WAAW,EAAK,CAAC,EAAE,IAAM,EAAQ,EAAQ,IAAI,CAAY,CAAC,CAAC,KAAK,GAAG,EAAQ,EAAU,OAAO,IAAI,EAAQ,GAAG,IAAI,EAAQ,EAAI,CAAC,EAAM,EAAU,EAAM,EAAM,EAAM,KAAK,CAAI,EAAE,KAAM,GAAM,CAAC,IAAM,EAAM,EAAM,MAAY,EAAQ,EAAM,GAAM,EAAM,GAAW,EAAI,KAAK,CAAC,KAAK,EAAK,MAAM,EAAU,CAAK,EAAE,WAAW,EAAK,CAAC,EAAG,EAAI,KAAK,CAAC,KAAK,EAAQ,WAAW,EAAI,CAAC,EAAE,EAAU,EAAM,EAAQ,OAAO,EAAM,EAAM,KAAK,CAAI,CAAE,CAAoF,OAAhF,EAAU,EAAK,QAAQ,EAAI,KAAK,CAAC,KAAK,EAAK,MAAM,CAAS,EAAE,W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