{"version":3,"file":"GradientHighlight.DHSdBy69.mjs","names":["useMemo","__esmMin","init_npm_react_18_3_1","pe","init_jsx_runtime","H","c","addPropertyControls","init_framer_DDfsYcI0","ControlType","useIsStaticRenderer","GradientHighlight","Tag","props","isStatic","highlightRange","highlight","lowerText","text","lowerHighlight","foundIdx","splitWordsAndSpaces","str","m","renderWithInsertion","showInserted","insertedComponent","childrenArr","words","i","token","isWord","w","output","insertionPosition","insertionIndex","tokens","elements","before","start","highlighted","end","after","beforeArr","gradientType","gradientAngle","gradientStart","gradientEnd","afterArr","overflow","textBalance","textColor","font","style","init_GradientHighlight"],"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\",\"framerSupported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