{"version":3,"file":"TextHighlighter.B9-P4Ecd.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/My8LfYggTppvuOAzTkRH/iKbElkRzyRvkI56fRNrM/TextHighlighter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";import{useEffect,useState}from\"react\";/**\n * @copyright ©framersnippets.com\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 221\n * @framerDisableUnlink\n **/export default function TextHighlighter(props){const{text,font,color,highlights,textWrap,tag}=props;const[imagesLoaded,setImagesLoaded]=useState({});useEffect(()=>{let loadedImages={};highlights.forEach((highlight,index)=>{if(highlight.useImage&&highlight.customImage){const img=new Image;img.onload=()=>setImagesLoaded(prev=>({...prev,[index]:true}));img.src=highlight.customImage;loadedImages[index]=false;}});setImagesLoaded(loadedImages);},[highlights]);const renderTextWithHighlight=()=>{const regex=new RegExp(`(${highlights.map(h=>h.highlightText).join(\"|\")})`,\"gi\");const parts=text.split(regex);return parts.map((part,index)=>{const highlight=highlights.find(h=>h.highlightText.toLowerCase()===part.toLowerCase());if(highlight){const image=highlight.useImage&&imagesLoaded[highlights.indexOf(highlight)]&&/*#__PURE__*/_jsx(\"img\",{src:highlight.customImage,alt:\"\",style:{width:`${highlight.size}px`,height:\"auto\",verticalAlign:\"middle\",display:\"inline-block\",marginRight:highlight.imagePlacement===\"left\"?`${highlight.gap}px`:0,marginLeft:highlight.imagePlacement===\"right\"?`${highlight.gap}px`:0}});return /*#__PURE__*/_jsxs(\"span\",{style:{position:\"relative\",zIndex:highlight.imagePlacement===\"center\"?highlight.Zindex+1:\"auto\",display:\"inline\"},children:[highlight.imagePlacement===\"left\"&&image,/*#__PURE__*/_jsx(\"span\",{style:{color:highlight.useColor?highlight.color:\"inherit\",position:\"relative\"},children:part}),highlight.imagePlacement===\"right\"&&image,highlight.imagePlacement===\"center\"&&highlight.useImage&&/*#__PURE__*/_jsx(\"img\",{src:highlight.customImage,alt:\"\",style:{position:\"absolute\",width:`${highlight.size}px`,height:\"auto\",top:`${highlight.top}px`,left:`${highlight.left}px`,zIndex:highlight.Zindex,display:\"block\"}})]},index);}return part;});};const Tag=tag||\"p\";return /*#__PURE__*/_jsx(motion.div,{style:{...font,display:\"block\",overflow:\"visible\",color:color,alignItems:\"baseline\",whiteSpace:\"normal\",wordWrap:\"break-word\",textWrap:textWrap?\"balance\":\"normal\"},children:/*#__PURE__*/_jsx(Tag,{style:{all:\"unset\",fontSize:font.fontSize},children:renderTextWithHighlight()})},textWrap);}TextHighlighter.defaultProps={text:\"Create magical headlines that captivate your audience.\",font:{fontSize:16},color:\"#000\",highlights:[{highlightText:\"magical\",useColor:false,color:\"\",useImage:false,customImage:\"\",imagePlacement:\"right\",size:15,gap:5,top:-5,left:0,Zindex:-1}],textWrap:true,tag:\"h1\"};addPropertyControls(TextHighlighter,{text:{type:ControlType.String,title:\"Content\",placeholder:\"Your content..\",displayTextArea:true},font:{type:ControlType.Font,controls:\"extended\",displayFontSize:true,defaultFontType:\"sans-serif\",defaultValue:{fontSize:15,lineHeight:1.4,letterSpacing:0}},color:{type:ControlType.Color,title:\"Color\"},highlights:{type:ControlType.Array,title:\"Highlights\",propertyControl:{type:ControlType.Object,controls:{highlightText:{type:ControlType.String,title:\"Text\",placeholder:\"Your words..\",description:\"Text or word to highlight\"},useColor:{type:ControlType.Boolean,title:\"Color\",defaultValue:false},color:{type:ControlType.Color,title:\"‎\",defaultValue:\"#0599ff\",hidden:props=>!props.useColor},useImage:{type:ControlType.Boolean,title:\"Image\",defaultValue:false},customImage:{type:ControlType.Image,title:\"‎\",hidden:props=>!props.useImage},imagePlacement:{type:ControlType.Enum,title:\"‎\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],displaySegmentedControl:true,defaultValue:\"right\",hidden:props=>!props.useImage},size:{type:ControlType.Number,title:\"Size\",min:1,max:2e3,step:1,defaultValue:15,displayStepper:true,hidden:props=>!props.useImage},gap:{type:ControlType.Number,title:\"Gap\",min:0,max:100,step:1,defaultValue:5,displayStepper:true,hidden:props=>!props.useImage||props.imagePlacement===\"center\"},top:{type:ControlType.Number,title:\"Top\",min:-100,max:100,step:1,defaultValue:-5,displayStepper:true,hidden:props=>!props.useImage||props.imagePlacement!==\"center\"},left:{type:ControlType.Number,title:\"Left\",min:-100,max:100,step:1,defaultValue:0,displayStepper:true,hidden:props=>!props.useImage||props.imagePlacement!==\"center\"},Zindex:{type:ControlType.Number,title:\"Z Index\",min:-1,max:50,step:1,defaultValue:0,displayStepper:true,hidden:props=>!props.useImage||props.imagePlacement!==\"center\"}}}},textWrap:{type:ControlType.Boolean,title:\"Balance\",defaultValue:true},tag:{type:ControlType.Enum,title:\"Tag\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\"],optionTitles:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\"],defaultValue:\"h1\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextHighlighter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any\",\"framerIntrinsicWidth\":\"221\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextHighlighter.map"],"mappings":"iWAMI,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,OAAK,OAAK,QAAM,aAAW,WAAS,OAAK,EAAW,CAAC,EAAa,GAAiBA,EAAS,EAAE,CAAC,CAAC,MAAc,CAAC,IAAI,EAAa,EAAE,CAAC,EAAW,SAAS,EAAU,IAAQ,CAAC,GAAG,EAAU,UAAU,EAAU,YAAY,CAAC,IAAM,EAAI,IAAI,MAAM,EAAI,WAAW,EAA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