{"version":3,"file":"GradientHighlight.DFwuTSWQ.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/KznaG0zDovlQrzYZnztA/sPNdxsPgLLpmowC2X5d1/GradientHighlight.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useMemo,createElement}from\"react\";/**\n * GradientHighlight\n *\n * Highlights a continuous phrase or multiple words with a gradient, not per word. Allows inserting a component at the start, end, or between words by word index. Supports full-width, tag selection, text balance, and overflow control.\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function GradientHighlight(props){const{text,highlight,gradientStart,gradientEnd,textColor,font,tag:Tag,style,textBalance,gradientType,gradientAngle,showInserted,insertedComponent,insertionPosition,insertionIndex,overflow}=props;const isStatic=useIsStaticRenderer();// Find highlight range (continuous, not per word, only first match)\nconst highlightRange=useMemo(()=>{if(!highlight)return null;const lowerText=text.toLowerCase();const lowerHighlight=highlight.toLowerCase();const foundIdx=lowerText.indexOf(lowerHighlight);if(foundIdx===-1)return null;return{start:foundIdx,end:foundIdx+highlight.length};},[text,highlight]);// Helper: split into words and spaces, preserving spaces as text nodes\nfunction splitWordsAndSpaces(str){const regex=/\\S+|\\s+/g;return Array.from(str.matchAll(regex),m=>m[0]);}// Insert the component at the correct word boundary\nfunction renderWithInsertion(childrenArr){if(!showInserted||!insertedComponent)return childrenArr;// Find word boundaries (words only, not spaces)\n// For insertion, we want to insert between words, not after a space\n// We'll build a new array, inserting at the correct index\nconst words=[];for(let i=0;i<childrenArr.length;i++){const token=childrenArr[i];const isWord=typeof token===\"string\"?!/^\\s+$/.test(token):true;words.push({value:token,isWord});}// Build a list of just the word indices\nconst wordIndices=words.map((w,i)=>w.isWord?i:-1).filter(i=>i!==-1);// For insertion, we want to insert at a position between words\n// e.g. insertionIndex = 0 => before first word\n// insertionIndex = 1 => between word 1 and 2\n// insertionIndex = words.length => after last word\nlet output=[];let wordCount=0;for(let i=0;i<=words.length;i++){// Insert at start\nif(insertionPosition===\"start\"&&i===0){output.push(/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-flex\",verticalAlign:\"middle\",alignItems:\"center\",margin:\"0 0.25em 0 0.25em\"},children:insertedComponent},\"inserted-start\"));}// Insert at custom index\nif(insertionPosition===\"custom\"&&i===insertionIndex){output.push(/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-flex\",verticalAlign:\"middle\",alignItems:\"center\",margin:\"0 0.25em 0 0.25em\"},children:insertedComponent},`inserted-custom-${insertionIndex}`));}if(i<words.length){output.push(words[i].value);}}// For end: insert after last word (i === words.length)\nif(insertionPosition===\"end\"){output.push(/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-flex\",verticalAlign:\"middle\",alignItems:\"center\",margin:\"0 0.25em 0 0.25em\"},children:insertedComponent},\"inserted-end\"));}return output;}// Build the output: split text into before, highlight, after, and insert component at the correct word boundary\nconst output=useMemo(()=>{if(!highlightRange){// No highlight, just render with insertion\nconst tokens=splitWordsAndSpaces(text);let elements=[];for(let i=0;i<tokens.length;i++){if(/^\\s+$/.test(tokens[i])){elements.push(tokens[i]);}else{elements.push(/*#__PURE__*/_jsx(\"span\",{style:{padding:\"0 0 0.1em 0\",margin:0,whiteSpace:\"pre-wrap\"},children:tokens[i]},`word-${i}`));}}return renderWithInsertion(elements);}// Highlight exists: split into before, highlight, after\nconst{start,end}=highlightRange;const before=text.slice(0,start);const highlighted=text.slice(start,end);const after=text.slice(end);// Before highlight\nconst beforeArr=splitWordsAndSpaces(before);let elements=[];for(let i=0;i<beforeArr.length;i++){if(/^\\s+$/.test(beforeArr[i])){elements.push(beforeArr[i]);}else{elements.push(/*#__PURE__*/_jsx(\"span\",{style:{padding:\"0 0 0.1em 0\",margin:0,whiteSpace:\"pre-wrap\"},children:beforeArr[i]},`before-${i}`));}}// Highlighted phrase (single span)\nif(highlighted){elements.push(/*#__PURE__*/_jsx(\"span\",{style:{backgroundImage:gradientType===\"linear\"?`linear-gradient(${gradientAngle}deg, ${gradientStart}, ${gradientEnd})`:`radial-gradient(circle at center, ${gradientStart}, ${gradientEnd})`,backgroundColor:\"transparent\",WebkitBackgroundClip:!isStatic?\"text\":\"none\",WebkitTextFillColor:!isStatic?\"transparent\":\"inherit\",color:isStatic?gradientEnd:\"inherit\",padding:\"0 0 0.1em 0\",margin:0,whiteSpace:\"pre-wrap\"},children:highlighted},\"highlight\"));}// After highlight\nconst afterArr=splitWordsAndSpaces(after);for(let i=0;i<afterArr.length;i++){if(/^\\s+$/.test(afterArr[i])){elements.push(afterArr[i]);}else{elements.push(/*#__PURE__*/_jsx(\"span\",{style:{padding:\"0 0 0.1em 0\",margin:0,whiteSpace:\"pre-wrap\"},children:afterArr[i]},`after-${i}`));}}return renderWithInsertion(elements);},[text,highlightRange,gradientType,gradientAngle,gradientStart,gradientEnd,isStatic,showInserted,insertedComponent,insertionPosition,insertionIndex]);return /*#__PURE__*/createElement(Tag,{style:{position:\"relative\",width:\"100%\",overflow:overflow?\"visible\":\"hidden\",backgroundColor:\"transparent\",display:\"block\",margin:0,padding:0,fontWeight:\"inherit\",textWrap:textBalance?\"balance\":\"wrap\",color:textColor,...font,...style},children:output});}addPropertyControls(GradientHighlight,{showInserted:{type:ControlType.Boolean,title:\"Show Inserted\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},insertedComponent:{type:ControlType.ComponentInstance,title:\"Component\",hidden:({showInserted})=>!showInserted},insertionPosition:{type:ControlType.Enum,title:\"Insert Position\",options:[\"start\",\"end\",\"custom\"],optionTitles:[\"Start\",\"End\",\"Custom\"],defaultValue:\"start\",hidden:({showInserted})=>!showInserted,displaySegmentedControl:true},insertionIndex:{type:ControlType.Number,title:\"Insert Index\",defaultValue:1,min:0,max:50,step:1,hidden:({showInserted,insertionPosition})=>!showInserted||insertionPosition!==\"custom\"},gradientType:{type:ControlType.Enum,title:\"Gradient\",options:[\"linear\",\"radial\"],defaultValue:\"linear\",displaySegmentedControl:true},gradientAngle:{type:ControlType.Number,title:\"Angle\",defaultValue:135,min:0,max:360,unit:\"\\xb0\",step:1,hidden:({gradientType})=>gradientType===\"radial\"},textBalance:{type:ControlType.Boolean,title:\"Text Balance\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},text:{type:ControlType.String,title:\"Text\",defaultValue:\"The quick brown fox jumps over the lazy dog\",displayTextArea:true},highlight:{type:ControlType.String,title:\"Highlight\",defaultValue:\"fox\"},gradientStart:{type:ControlType.Color,title:\"Gradient Start\",defaultValue:\"#FF5588\"},gradientEnd:{type:ControlType.Color,title:\"Gradient End\",defaultValue:\"#8855FF\"},font:{type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:32,lineHeight:\"1.2em\",letterSpacing:0,textAlign:\"left\",variant:\"Bold\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},overflow:{type:ControlType.Boolean,title:\"Overflow\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},tag:{type:ControlType.Enum,title:\"Tag\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\"],defaultValue:\"p\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GradientHighlight\",\"slots\":[\"insertedComponent\"],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GradientHighlight.map"],"mappings":"yLAOG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,OAAK,YAAU,gBAAc,cAAY,YAAU,OAAK,IAAI,EAAI,QAAM,cAAY,eAAa,gBAAc,eAAa,oBAAkB,oBAAkB,iBAAe,YAAU,EAAY,EAAS,EAAoB,EACpR,EAAeA,MAAY,CAAC,GAAG,CAAC,EAAU,OAAO,KAAK,IAAM,EAAU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