{"version":3,"file":"TextHighlightReveal.CWCmWNgW.mjs","names":["useMemo","useRef"],"sources":["https:/framerusercontent.com/modules/umRiyHnh8Skyl0AKqCr2/R2NGTr39C7SWQD10RTxh/TextHighlightReveal.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion,useScroll,useTransform}from\"framer-motion\";import{useMemo,useRef}from\"react\";function AnimatedCharacter(props){const{char,color,progress,start,end,startOpacity,endOpacity,transition,isCanvas}=props;const opacity=useTransform(progress,[start,end],[startOpacity,endOpacity]);return /*#__PURE__*/_jsx(motion.span,{style:{opacity:isCanvas?endOpacity:opacity,color},transition:transition,children:char});}/**\n * Text Highlight Reveal\n *\n * Highlight words using:\n * [highlight text]\n *\n * Links using:\n * {text|url}\n *\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function TextHighlightReveal(props){const{text,textColor,highlightColor,linkColor,startOpacity,endOpacity,font,textTransform,paragraphAlign,offsetReference,offsetStart,offsetEnd,transition,tag}=props;const parsedContent=useMemo(()=>{const regex=/\\[([^\\]]+)\\]|\\{([^}|]+)\\|([^}]+)\\}/g;const parts=[];let lastIndex=0;let match;while((match=regex.exec(text))!==null){// Normal text before match\nif(match.index>lastIndex){parts.push({text:text.slice(lastIndex,match.index),type:\"normal\"});}// Highlight\nif(match[1]){parts.push({text:match[1],type:\"highlight\"});}else if(match[2]&&match[3]){parts.push({text:match[2],type:\"link\",url:match[3]});}lastIndex=regex.lastIndex;}// Remaining text\nif(lastIndex<text.length){parts.push({text:text.slice(lastIndex),type:\"normal\"});}return parts;},[text]);const totalCharacters=parsedContent.reduce((acc,part)=>{return acc+part.text.length;},0);const ref=useRef(null);const{scrollYProgress}=useScroll({target:ref,offset:[`${offsetReference} ${offsetStart}`,`${offsetReference} ${offsetEnd}`]});const Tag=tag;const isCanvas=RenderTarget.current()===RenderTarget.canvas;return /*#__PURE__*/_jsx(Tag,{ref:ref,style:{...props.style,...font,margin:0,whiteSpace:\"pre-wrap\",wordBreak:\"break-word\",textTransform,color:textColor,textAlign:paragraphAlign===\"flex-start\"?\"left\":paragraphAlign===\"center\"?\"center\":\"right\"},children:(()=>{let globalCharacterIndex=0;return parsedContent.map((part,partIndex)=>{let color=textColor;if(part.type===\"highlight\"){color=highlightColor;}if(part.type===\"link\"){color=linkColor;}const characters=part.text.split(\"\");const renderedCharacters=characters.map((char,charIndex)=>{const currentIndex=globalCharacterIndex;globalCharacterIndex++;const{spread}=props;const start=currentIndex/totalCharacters;const end=Math.min(start+spread,1);return /*#__PURE__*/_jsx(AnimatedCharacter,{char:char,color:color,progress:scrollYProgress,start:start,end:end,startOpacity:startOpacity,endOpacity:endOpacity,transition:transition,isCanvas:isCanvas},charIndex);});// Link wrapper\nif(part.type===\"link\"){return /*#__PURE__*/_jsx(\"a\",{href:part.url,style:{color,textDecoration:\"underline\"},children:renderedCharacters},partIndex);}return /*#__PURE__*/_jsx(\"span\",{children:renderedCharacters},partIndex);});})()});}addPropertyControls(TextHighlightReveal,{text:{title:\"Text\",type:ControlType.String,displayTextArea:true,defaultValue:\"Build better [sites], faster.\\n\\nVisit {Framer|https://framer.com}\",description:\"Use [text] for highlights and {text|url} for links.\"},font:{title:\"Font\",type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Medium\",lineHeight:\"1.2em\",letterSpacing:\"0px\"}},textTransform:{title:\"Text Transform\",type:ControlType.Enum,options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],optionTitles:[\"None\",\"Uppercase\",\"Lowercase\",\"Capitalize\"],defaultValue:\"none\"},textColor:{title:\"Text Color\",type:ControlType.Color,defaultValue:\"#666666\"},highlightColor:{title:\"Highlight Color\",type:ControlType.Color,defaultValue:\"#FFFFFF\"},linkColor:{title:\"Link Color\",type:ControlType.Color,defaultValue:\"#FFFFFF\"},paragraphAlign:{title:\"Align\",type:ControlType.Enum,options:[\"flex-start\",\"center\",\"flex-end\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"flex-start\",displaySegmentedControl:true},startOpacity:{title:\"Start Opacity\",type:ControlType.Number,defaultValue:.15,min:0,max:1,step:.05},endOpacity:{title:\"End Opacity\",type:ControlType.Number,defaultValue:1,min:0,max:1,step:.05},spread:{title:\"Fade Spread\",type:ControlType.Number,defaultValue:.12,min:.01,max:.3,step:.01,description:\"Lower values create sharper reveals. Higher values create smoother fade trails. Recommended: 0.08-0.14\"},offsetReference:{title:\"Offset Ref\",type:ControlType.Enum,options:[\"start\",\"center\",\"end\"],optionTitles:[\"Top\",\"Middle\",\"Bottom\"],defaultValue:\"start\"},offsetStart:{title:\"Offset Start\",type:ControlType.Number,defaultValue:.9,min:0,max:1,step:.05},offsetEnd:{title:\"Offset End\",type:ControlType.Number,defaultValue:.2,min:0,max:1,step:.05},transition:{title:\"Transition\",type:ControlType.Transition,defaultValue:{type:\"tween\",duration:.3,ease:\"easeInOut\"}},tag:{title:\"Tag\",type:ControlType.Enum,options:[\"p\",\"span\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"],defaultValue:\"p\",description:\"More components at [Framerize](https://dub.sh/frmze-cc).\"}});TextHighlightReveal.displayName=\"Text Highlight Reveal\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextHighlightReveal\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"*\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextHighlightReveal.map"],"mappings":"uPAAuM,SAAS,EAAkB,EAAM,CAAC,GAAK,CAAC,OAAK,QAAM,WAAS,QAAM,MAAI,eAAa,aAAW,aAAW,YAAU,EAAY,EAAQ,EAAa,EAAS,CAAC,EAAM,EAAI,CAAC,CAAC,EAA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