{"version":3,"file":"HighlightText.CGcI9AUd.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/OIKfZYMO5foduhegbv4w/9X4MbbexlKiXM757GlFW/HighlightText.js"],"sourcesContent":["// Highlighting Text Component - Allows users to emphasize specific words or phrases within a sentence using customizable background highlights\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo}from\"react\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function HighlightText(props){const{text,highlightWords,highlightColor,textColor,highlightTextColor,font,padding,backgroundColor,borderRadius,highlightBorderRadius,enableAnimation,animationType,style}=props;const wordsToHighlight=useMemo(()=>{if(!highlightWords.trim())return[];return highlightWords.split(\",\").map(word=>word.trim().toLowerCase()).filter(word=>word.length>0);},[highlightWords]);const processedText=useMemo(()=>{if(wordsToHighlight.length===0){return[{text,isHighlighted:false}];}const parts=[];let currentIndex=0;while(currentIndex<text.length){let foundMatch=false;let earliestMatch={index:text.length,word:\"\",length:0};// Find the earliest match from current position\nfor(const word of wordsToHighlight){const index=text.toLowerCase().indexOf(word,currentIndex);if(index!==-1&&index<earliestMatch.index){earliestMatch={index,word:text.substring(index,index+word.length),length:word.length};foundMatch=true;}}if(foundMatch){// Add non-highlighted text before the match\nif(earliestMatch.index>currentIndex){parts.push({text:text.substring(currentIndex,earliestMatch.index),isHighlighted:false});}// Add highlighted text\nparts.push({text:earliestMatch.word,isHighlighted:true});currentIndex=earliestMatch.index+earliestMatch.length;}else{// No more matches, add remaining text\nparts.push({text:text.substring(currentIndex),isHighlighted:false});break;}}return parts;},[text,wordsToHighlight]);const animationVariants={fade:{initial:{opacity:0},animate:{opacity:1},transition:{duration:.5}},slide:{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5}}};const selectedAnimation=animationVariants[animationType];return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",width:\"100%\",padding,backgroundColor,borderRadius,boxSizing:\"border-box\",...font,color:textColor},children:/*#__PURE__*/_jsx(\"p\",{style:{margin:0,whiteSpace:\"pre-wrap\",wordBreak:\"break-word\",overflowWrap:\"break-word\",width:\"100%\"},children:processedText.map((part,index)=>{if(part.isHighlighted){if(enableAnimation){return /*#__PURE__*/_jsx(motion.span,{initial:selectedAnimation.initial,whileInView:selectedAnimation.animate,viewport:{once:true,amount:.5},transition:selectedAnimation.transition,style:{backgroundColor:highlightColor,color:highlightTextColor,borderRadius:highlightBorderRadius,padding:\"2px 4px\",display:\"inline\",boxDecorationBreak:\"clone\",WebkitBoxDecorationBreak:\"clone\"},children:part.text},index);}return /*#__PURE__*/_jsx(\"span\",{style:{backgroundColor:highlightColor,color:highlightTextColor,borderRadius:highlightBorderRadius,padding:\"2px 4px\",boxDecorationBreak:\"clone\",WebkitBoxDecorationBreak:\"clone\"},children:part.text},index);}return /*#__PURE__*/_jsx(\"span\",{children:part.text},index);})})});}addPropertyControls(HighlightText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"The simplicity of this tool has given me real confidence in managing SEO for my clients, and it's an absolute steal vs other platforms on the market.\",displayTextArea:true},highlightWords:{type:ControlType.String,title:\"Highlight Words\",defaultValue:\"simplicity, real confidence, absolute steal\",placeholder:\"word1, word2, phrase\"},highlightColor:{type:ControlType.Color,title:\"Highlight Color\",defaultValue:\"#FFBB00\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},highlightTextColor:{type:ControlType.Color,title:\"Highlight Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.5em\"}},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"20px\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"rgba(255, 255, 255, 0)\"},borderRadius:{type:ControlType.Number,title:\"Container Radius\",defaultValue:0,min:0,max:100,step:1,unit:\"px\"},highlightBorderRadius:{type:ControlType.Number,title:\"Highlight Radius\",defaultValue:4,min:0,max:100,step:1,unit:\"px\"},enableAnimation:{type:ControlType.Boolean,title:\"Animation\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},animationType:{type:ControlType.Enum,title:\"Animation Type\",options:[\"fade\",\"slide\"],optionTitles:[\"Fade In\",\"Slide Up\"],defaultValue:\"fade\",displaySegmentedControl:true,hidden:({enableAnimation})=>!enableAnimation}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HighlightText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HighlightText.map"],"mappings":"2NAIG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,OAAK,iBAAe,iBAAe,YAAU,qBAAmB,OAAK,UAAQ,kBAAgB,eAAa,wBAAsB,kBAAgB,gBAAc,SAAO,EAAY,EAAiBA,MAAiB,EAAe,KAAK,EAAkB,EAAe,MAAM,GAAG,CAAC,CAAC,IAAI,GAAM,EAAK,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,GAAM,EAAK,OAAO,CAAC,EAAnG,CAAC,EAAsG,CAAC,CAAc,CAAC,EAAQ,EAAcA,MAAY,CAAC,GAAG,EAAiB,SAAS,EAAG,MAAM,CAAC,CAAC,OAAK,cAAc,EAAK,CAAC,EAAG,IAAM,EAAM,CAAC,EAAM,EAAa,EAAE,KAAM,EAAa,EAAK,QAAO,CAAC,IAAI,EAAW,GAAU,EAAc,CAAC,MAAM,EAAK,OAAO,KAAK,GAAG,OAAO,CAAC,EAC/oB,IAAI,IAAM,KAAQ,EAAiB,CAAC,IAAM,EAAM,EAAK,YAAY,CAAC,CAAC,QAAQ,EAAK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