{"version":3,"file":"HighlightedText.Cpd600bC.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/qBay99RtuKjbpVzyxFT1/G9ZnFBp7hQNaddyVN5Hm/HighlightedText.js"],"sourcesContent":["// Highlighting effect that animates highlighted sentences from left to right\n// Mark text with underline for positive (green) highlights\n// Mark text with strikethrough for negative (red) highlights\n// Only the highlighted portions animate, not the rest of the text\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useMemo}from\"react\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function HighlightedText(props){const{text,positiveBackground,positiveText,negativeBackground,negativeText,animationDuration,animationDelay,font,normalTextColor,borderRadius,animate}=props;const isStatic=useIsStaticRenderer();const processedText=useMemo(()=>{// Parse text for underline (positive) and strikethrough (negative) markers\n// Support both HTML-like tags and markdown-style markers\nconst segments=[];// Replace common rich text patterns with markers\nlet processedString=text// Underline patterns (positive)\n.replace(/<u>(.*?)<\\/u>/gi,\"{{POSITIVE}}$1{{/POSITIVE}}\").replace(/__(.*?)__/g,\"{{POSITIVE}}$1{{/POSITIVE}}\")// Strikethrough patterns (negative)\n.replace(/<s>(.*?)<\\/s>/gi,\"{{NEGATIVE}}$1{{/NEGATIVE}}\").replace(/~~(.*?)~~/g,\"{{NEGATIVE}}$1{{/NEGATIVE}}\").replace(/<strike>(.*?)<\\/strike>/gi,\"{{NEGATIVE}}$1{{/NEGATIVE}}\");// Parse the marked string\nconst regex=/{{(POSITIVE|NEGATIVE)}}(.*?){{\\/\\1}}/g;let lastIndex=0;let match;while((match=regex.exec(processedString))!==null){// Add normal text before the match\nif(match.index>lastIndex){const normalText=processedString.substring(lastIndex,match.index);if(normalText){segments.push({text:normalText,type:\"normal\"});}}// Add the highlighted segment\nsegments.push({text:match[2],type:match[1].toLowerCase()});lastIndex=regex.lastIndex;}// Add remaining normal text\nif(lastIndex<processedString.length){const remainingText=processedString.substring(lastIndex);if(remainingText){segments.push({text:remainingText,type:\"normal\"});}}// If no segments were found, treat entire text as normal\nif(segments.length===0){segments.push({text,type:\"normal\"});}// If animation is off, show highlights in final state without animation\nif(!animate){return segments.map((segment,index)=>{if(segment.type===\"normal\"){return /*#__PURE__*/_jsx(\"span\",{style:{color:normalTextColor},children:segment.text},index);}return /*#__PURE__*/_jsx(\"span\",{style:{position:\"relative\",display:\"inline-block\",color:normalTextColor},children:segment.text},index);});}// Render segments\nlet highlightIndex=0;return segments.map((segment,index)=>{if(segment.type===\"normal\"){return /*#__PURE__*/_jsx(\"span\",{style:{color:normalTextColor},children:segment.text},index);}const currentIndex=highlightIndex;highlightIndex++;const isPositive=segment.type===\"positive\";return /*#__PURE__*/_jsxs(\"span\",{style:{position:\"relative\",display:\"inline-block\"},children:[/*#__PURE__*/_jsx(motion.span,{initial:isStatic?{width:\"100%\"}:{width:0},animate:{width:\"100%\"},transition:{duration:animationDuration,delay:animationDelay+animationDelay*currentIndex,ease:\"easeInOut\"},style:{position:\"absolute\",top:0,left:0,height:\"100%\",backgroundColor:isPositive?positiveBackground:negativeBackground,borderRadius:`${borderRadius}px`,zIndex:0}}),/*#__PURE__*/_jsx(motion.span,{initial:isStatic?{color:isPositive?positiveText:negativeText}:{color:normalTextColor},animate:{color:isPositive?positiveText:negativeText},transition:{duration:animationDuration,delay:animationDelay+animationDelay*currentIndex,ease:\"easeInOut\"},style:{position:\"relative\",zIndex:1},children:segment.text})]},index);});},[text,positiveBackground,positiveText,negativeBackground,negativeText,animationDuration,animationDelay,normalTextColor,borderRadius,animate,isStatic]);return /*#__PURE__*/_jsx(\"div\",{style:{...props.style,position:\"relative\"},children:/*#__PURE__*/_jsx(\"p\",{style:{margin:0,...font},children:processedText})});}addPropertyControls(HighlightedText,{font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.03em\",lineHeight:\"1.2em\"}},normalTextColor:{type:ControlType.Color,title:\"Default Text\",defaultValue:\"#000000\"},text:{type:ControlType.String,title:\"Text\",defaultValue:\"This is <u>a great sentence</u> but <s>this one is terrible</s> and this is normal.\",displayTextArea:true},animate:{type:ControlType.Boolean,title:\"Animate\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},animationDuration:{type:ControlType.Number,title:\"Duration\",defaultValue:.6,min:.1,max:3,step:.1,unit:\"s\"},animationDelay:{type:ControlType.Number,title:\"Delay\",defaultValue:.2,min:0,max:2,step:.1,unit:\"s\"},positiveText:{type:ControlType.Color,title:\"Highlight #1 Text\",defaultValue:\"#FFFFFF\"},positiveBackground:{type:ControlType.Color,title:\"Highlight #1 BG\",defaultValue:\"#22CC66\"},negativeText:{type:ControlType.Color,title:\"Highlight #2 Text\",defaultValue:\"#FFFFFF\"},negativeBackground:{type:ControlType.Color,title:\"Highlight #2 BG\",defaultValue:\"#FF5588\"},borderRadius:{type:ControlType.Number,title:\"BG Radius\",defaultValue:4,min:0,max:20,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HighlightedText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HighlightedText.map"],"mappings":"2OAOG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,OAAK,qBAAmB,eAAa,qBAAmB,eAAa,oBAAkB,iBAAe,OAAK,kBAAgB,eAAa,WAAS,EAAY,EAAS,EAAoB,EAAQ,EAAcA,MAAY,CAEpR,IAAM,EAAS,CAAC,EACZ,EAAgB,EACnB,QAAQ,kBAAkB,6BAA6B,CAAC,CAAC,QAAQ,aAAa,6BAA6B,CAAC,CAC5G,QAAQ,kBAAkB,6BAA6B,CAAC,CAAC,QAAQ,aA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