{"version":3,"file":"GradientHighlight.CcA33edG.mjs","names":["useMemo","output","elements"],"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":"0LAOG,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,GAAqB,CACrR,EAAeA,MAAY,CAAC,GAAG,CAAC,EAAU,OAAO,KAAK,IAAM,EA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