{"version":3,"file":"HighlightedHeading.6nS3Q9IY.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/uL4KYgB9kHwTSAdUnYr3/9UmZmpggy3SDOyHR1DE7/HighlightedHeading.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo}from\"react\";/**\n * User request: Extend “Highlighted Heading” so highlighted text can appear anywhere\n * in the sentence (including middle), preserve existing defaults/usages, and keep\n * highlight color/background controls with natural inline wrapping behavior.\n *//**\n * Highlighted Heading\n * A responsive heading component with a highlighted text span\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function HighlightedHeading(props){const{blackText=\"You can't prevent what\\n\",afterText=\"\",fullText=\"You can't prevent what you can't see\",highlightedText=\"retails network\",highlightMode=\"segments\",matchCaseSensitive=false,highlightAllMatches=false,textTag,headingLevel,blackTextColor=\"#000000\",highlightedTextColor=\"#4F46E5\",highlightBackgroundColor=\"#E0E7FF\",highlightPadding=8,highlightBorderRadius=4,textStyle,style}=props;const resolvedTag=textTag??(headingLevel===\"span\"?\"p\":headingLevel)??\"h2\";const Tag=resolvedTag;const normalizedHighlightText=highlightedText??\"\";const contentParts=useMemo(()=>{if(highlightMode===\"segments\"){return[{text:blackText,highlighted:false},{text:normalizedHighlightText,highlighted:true},{text:afterText,highlighted:false}];}if(!normalizedHighlightText){return[{text:fullText,highlighted:false}];}const sourceText=fullText??\"\";const source=matchCaseSensitive?sourceText:sourceText.toLowerCase();const target=matchCaseSensitive?normalizedHighlightText:normalizedHighlightText.toLowerCase();if(!target)return[{text:sourceText,highlighted:false}];const parts=[];let cursor=0;while(cursor<=source.length){const foundIndex=source.indexOf(target,cursor);if(foundIndex===-1){parts.push({text:sourceText.slice(cursor),highlighted:false});break;}if(foundIndex>cursor){parts.push({text:sourceText.slice(cursor,foundIndex),highlighted:false});}parts.push({text:sourceText.slice(foundIndex,foundIndex+target.length),highlighted:true});cursor=foundIndex+target.length;if(!highlightAllMatches){if(cursor<sourceText.length){parts.push({text:sourceText.slice(cursor),highlighted:false});}break;}}return parts.length>0?parts:[{text:sourceText,highlighted:false}];},[highlightMode,blackText,normalizedHighlightText,afterText,fullText,matchCaseSensitive,highlightAllMatches]);return /*#__PURE__*/_jsx(Tag,{style:{...style,...textStyle,width:\"100%\",margin:0,padding:0,position:\"relative\",color:blackTextColor,whiteSpace:\"pre-wrap\"},children:contentParts.map((part,index)=>part.highlighted?/*#__PURE__*/_jsx(\"span\",{style:{color:highlightedTextColor,backgroundColor:highlightBackgroundColor,padding:`${highlightPadding}px`,borderRadius:`${highlightBorderRadius}px`,display:\"inline\",whiteSpace:\"pre-wrap\",boxDecorationBreak:\"clone\",WebkitBoxDecorationBreak:\"clone\"},children:part.text},`highlight-${index}`):/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"pre-wrap\"},children:part.text},`text-${index}`))});}addPropertyControls(HighlightedHeading,{textStyle:{type:ControlType.Font,title:\"Text Style\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Regular\",letterSpacing:\"-0.01em\",lineHeight:\"1.3\"}},textTag:{type:ControlType.Enum,title:\"Text Tag\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"H4\",\"H5\",\"H6\",\"Paragraph\"],defaultValue:\"h2\"},highlightMode:{type:ControlType.Enum,title:\"Mode\",options:[\"segments\",\"match\"],optionTitles:[\"Before/Highlight/After\",\"Find in Full Text\"],defaultValue:\"segments\"},fullText:{type:ControlType.String,title:\"Full Text\",defaultValue:\"You can't prevent what you can't see\",displayTextArea:true,hidden:props=>props.highlightMode!==\"match\"},blackText:{type:ControlType.String,title:\"Before Text\",defaultValue:\"You can't prevent what\\n\",placeholder:\"Enter text before highlight...\",displayTextArea:true,hidden:props=>props.highlightMode!==\"segments\"},highlightedText:{type:ControlType.String,title:\"Highlighted Text\",defaultValue:\"retails network\",placeholder:\"Enter highlighted text...\",displayTextArea:true},afterText:{type:ControlType.String,title:\"After Text\",defaultValue:\"\",placeholder:\"Enter text after highlight...\",displayTextArea:true,hidden:props=>props.highlightMode!==\"segments\"},matchCaseSensitive:{type:ControlType.Boolean,title:\"Case Sensitive\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\",hidden:props=>props.highlightMode!==\"match\"},highlightAllMatches:{type:ControlType.Boolean,title:\"All Matches\",defaultValue:false,enabledTitle:\"All\",disabledTitle:\"First\",hidden:props=>props.highlightMode!==\"match\"},blackTextColor:{type:ControlType.Color,title:\"Black Text Color\",defaultValue:\"#000000\"},highlightedTextColor:{type:ControlType.Color,title:\"Highlighted Text Color\",defaultValue:\"#4F46E5\"},highlightBackgroundColor:{type:ControlType.Color,title:\"Highlight Background\",defaultValue:\"#E0E7FF\"},highlightPadding:{type:ControlType.Number,title:\"Highlight Padding\",defaultValue:8,min:0,max:32,step:1,unit:\"px\"},highlightBorderRadius:{type:ControlType.Number,title:\"Highlight Radius\",defaultValue:4,min:0,max:24,step:1,unit:\"px\"}});HighlightedHeading.displayName=\"Highlighted Heading\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HighlightedHeading\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HighlightedHeading.map"],"mappings":"0KAUG,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,YAAU;EAA2B,YAAU,GAAG,WAAS,uCAAuC,kBAAgB,kBAAkB,gBAAc,WAAW,qBAAmB,GAAM,sBAAoB,GAAM,UAAQ,eAAa,iBAAe,UAAU,uBAAqB,UAAU,2BAAyB,UAAU,mBAAiB,EAAE,wBAAsB,EAAE,YAAU,SAAO,EAAsF,EAA9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