{"version":3,"file":"HighlightText.CAd4CsmO.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/BRkNbpuf2zuHniGCWgzk/8haFnyo6hc2h4QVFSXCT/HighlightText.js"],"sourcesContent":["// Highlight Text Effect Component (No Line Breaks, Inline Gradient Animation, Animate on In-View with Delay)\n// Renders text with a customizable highlight background, simulating a highlight pen effect, supporting multiline and inline highlights with animation when the component enters the viewport (with delay), and never causing line breaks.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useInView}from\"framer-motion\";import{useRef,useState,useEffect,startTransition}from\"react\";/**\n * HighlightText\n *\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 60\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function HighlightText(props){const{text,highlightColor,textColor,highlightedTextColor,font,paddingY,paddingX,borderRadius,animate,highlightWords,delay,style}=props;const ref=useRef(null);const inView=useInView(ref,{once:true,margin:\"-10% 0px\"});const[mounted,setMounted]=useState(false);useEffect(()=>{if(animate&&inView){const t=setTimeout(()=>{startTransition(()=>setMounted(true));},delay);return()=>clearTimeout(t);}else if(!animate){setMounted(true);}},[animate,delay,inView]);// Build segments for highlighting by phrases (multi-word supported)\nfunction getPhraseSegments(text,highlightPhrase){if(!highlightPhrase||highlightPhrase.trim()===\"\")return[{text,highlight:false}];const phrase=highlightPhrase.trim();const lowerText=text.toLowerCase();const lowerPhrase=phrase.toLowerCase();let segments=[];let i=0;while(i<text.length){const phraseLen=phrase.length;if(lowerText.substr(i,phraseLen)===lowerPhrase){segments.push({text:text.substr(i,phraseLen),highlight:true});i+=phraseLen;}else{segments.push({text:text[i],highlight:false});i++;}}// Merge adjacent non-highlighted segments\nlet merged=[];for(let seg of segments){if(merged.length&&!seg.highlight&&!merged[merged.length-1].highlight){merged[merged.length-1].text+=seg.text;}else{merged.push(seg);}}return merged;}// Multiline support: split by line breaks, process each line\nconst lines=text.split(/\\r?\\n/);let allSegments=[];for(let idx=0;idx<lines.length;idx++){const line=lines[idx];const segments=getPhraseSegments(line,highlightWords||\"\");allSegments=allSegments.concat(segments);if(idx<lines.length-1)allSegments.push({text:\"\\n\",highlight:false});}// Style for all text\nconst textStyle={color:textColor,...font,padding:`${paddingY}px ${paddingX}px`,boxSizing:\"border-box\",display:\"inline\",verticalAlign:\"baseline\",whiteSpace:\"pre-wrap\",borderRadius};return /*#__PURE__*/_jsx(\"span\",{ref:ref,style:{display:\"inline\",position:\"relative\",...style,width:style?.width===\"100%\"?\"100%\":\"max-content\",minWidth:0,maxWidth:\"100%\",wordBreak:\"break-word\",overflowWrap:\"break-word\",whiteSpace:style?.width===\"100%\"?\"normal\":\"pre-wrap\"},tabIndex:0,\"aria-label\":text,role:\"text\",children:allSegments.map((seg,i)=>{if(!seg.text)return null;if(seg.highlight){return /*#__PURE__*/_jsx(motion.span,{style:{...textStyle,background:`linear-gradient(90deg, ${highlightColor} 100%, transparent 100%)`,backgroundRepeat:\"no-repeat\",backgroundPosition:\"0 100%\",backgroundSize:mounted?\"100% 100%\":\"0% 100%\",transition:animate?\"background-size 0.5s cubic-bezier(0.25,0.46,0.45,0.94), color 0.2s linear\":undefined,zIndex:1,position:\"relative\",borderRadius,whiteSpace:\"pre-wrap\",display:\"inline\",color:mounted?highlightedTextColor:textColor},animate:{backgroundSize:mounted?\"100% 100%\":\"0% 100%\",color:mounted?highlightedTextColor:textColor},transition:{duration:.5,ease:[.25,.46,.45,.94],delay:animate?delay/1e3:0},children:seg.text},\"h-\"+i);}else{return /*#__PURE__*/_jsx(\"span\",{style:{...textStyle,background:\"none\",verticalAlign:\"baseline\",display:\"inline\"},children:seg.text},\"n-\"+i);}})});}addPropertyControls(HighlightText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Highlight me!\",displayTextArea:false},highlightWords:{type:ControlType.String,title:\"Highlight Words\",placeholder:\"word or phrase\",defaultValue:\"Highlight\"},highlightColor:{type:ControlType.Color,title:\"Highlight\",defaultValue:\"#FFF59D\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},highlightedTextColor:{type:ControlType.Color,title:\"Highlighted Text\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},paddingY:{type:ControlType.Number,title:\"Vertical Padding\",defaultValue:4,min:0,max:32,unit:\"px\"},paddingX:{type:ControlType.Number,title:\"Horizontal Padding\",defaultValue:8,min:0,max:32,unit:\"px\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:6,min:0,max:32,unit:\"px\"},animate:{type:ControlType.Boolean,title:\"Animate\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},delay:{type:ControlType.Number,title:\"Delay (ms)\",defaultValue:0,min:0,max:5e3,step:50,unit:\"ms\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HighlightText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"300\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"60\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HighlightText.map"],"mappings":"uPAUG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,OAAK,iBAAe,YAAU,uBAAqB,OAAK,WAAS,WAAS,eAAa,UAAQ,iBAAe,QAAM,SAAO,EAAY,EAAIA,EAAO,IAAI,EAAQ,EAAO,EAAU,EAAI,CAAC,KAAK,GAAK,OAAO,UAAU,CAAC,EAAO,CAAC,EAAQ,GAAYC,EAAS,EAAK,EAAE,MAAc,CAAC,GAAG,GAAS,EAAO,CAAC,IAAM,EAAE,eAAe,CAAC,MAAoB,EAAW,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