{"version":3,"file":"RichTextComponent.BqdpqXP9.mjs","names":["useRef","useState","useMemo"],"sources":["https:/framerusercontent.com/modules/ptKepjhtHXE0SQsjdga7/640fgJgSXZcAHuWAaPLl/RichTextComponent.js"],"sourcesContent":["// Request: Add an optional Text Flux Unveil / scroll word reveal feature while keeping default rendering/API behavior unchanged.\n// Text component with indentation, text balance, and rich text support\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useScroll,useInView}from\"framer-motion\";import{useMemo,useRef,useEffect,useState,startTransition}from\"react\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function RichTextComponent(props){const{text,font,textColor,highlightText,highlightColor,highlightPosition,textIndent,indentType,useTextBalance,enableTextFluxUnveil,startFromWord,initialOpacity,fadeDelay,fadeDuration,fadeEasing,fullRevealDistance,stickyTop}=props;const containerRef=useRef(null);const isStaticRenderer=useIsStaticRenderer();const isInView=useInView(containerRef,{margin:\"-20% 0px -20% 0px\"});const{scrollY}=useScroll();const[elementTop,setElementTop]=useState(0);const[windowHeight,setWindowHeight]=useState(0);const[scrollProgress,setScrollProgress]=useState(0);const processedText=useMemo(()=>{if(!highlightText||highlightText.trim()===\"\"){return text;}const highlightStyle=`color: ${highlightColor};`;const regex=new RegExp(`(${highlightText.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")})`,\"gi\");// Check if highlight text exists in main text\nif(text.toLowerCase().includes(highlightText.toLowerCase())){return text.replace(regex,`<span style=\"${highlightStyle}\">$1</span>`);}else{// If highlight text doesn't exist in main text, add it based on position\nconst highlightSpan=`<span style=\"${highlightStyle}\">${highlightText}</span>`;if(highlightPosition===\"start\"){return`${highlightSpan} ${text}`;}else{return`${text} ${highlightSpan}`;}}},[text,highlightText,highlightColor,highlightPosition]);const getIndent=useMemo(()=>{switch(indentType){case\"px\":return`${textIndent}px`;case\"percentage\":return`${textIndent}%`;default:return\"0\";}},[textIndent,indentType]);const revealText=useMemo(()=>{if(!highlightText||highlightText.trim()===\"\")return text;if(text.toLowerCase().includes(highlightText.toLowerCase()))return text;if(highlightPosition===\"start\")return`${highlightText} ${text}`;return`${text} ${highlightText}`;},[text,highlightText,highlightPosition]);const revealWords=useMemo(()=>{return revealText.split(\" \").filter(word=>word.length>0);},[revealText]);useEffect(()=>{if(!enableTextFluxUnveil||isStaticRenderer)return;if(typeof window===\"undefined\"||typeof document===\"undefined\"){return;}if(!containerRef.current)return;const updatePosition=()=>{if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();const scrollTop=window.pageYOffset||document.documentElement.scrollTop;startTransition(()=>{setElementTop(rect.top+scrollTop);setWindowHeight(window.innerHeight);});};updatePosition();window.addEventListener(\"resize\",updatePosition);return()=>window.removeEventListener(\"resize\",updatePosition);},[enableTextFluxUnveil,isStaticRenderer]);useEffect(()=>{if(!enableTextFluxUnveil||isStaticRenderer)return;const unsubscribe=scrollY.on(\"change\",latest=>{if(!isInView)return;const triggerPoint=elementTop-windowHeight;const progress=Math.max(0,Math.min(1,(latest-triggerPoint)/fullRevealDistance));startTransition(()=>setScrollProgress(progress));});return unsubscribe;},[enableTextFluxUnveil,isStaticRenderer,scrollY,elementTop,windowHeight,fullRevealDistance,isInView]);const textAlign=(font?.textAlign)||\"left\";const cleanedHighlightText=highlightText.trim().toLowerCase();if(!enableTextFluxUnveil){return /*#__PURE__*/_jsx(\"div\",{style:{display:\"block\",width:\"100%\",minHeight:\"1em\",color:textColor,textIndent:getIndent,...useTextBalance&&{textWrap:\"balance\"},...font},dangerouslySetInnerHTML:{__html:processedText}});}return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{position:\"relative\",width:\"100%\",minHeight:\"1em\"},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"sticky\",top:stickyTop,width:\"100%\",display:\"flex\",justifyContent:textAlign===\"center\"?\"center\":textAlign===\"right\"?\"flex-end\":\"flex-start\"},children:/*#__PURE__*/_jsx(\"p\",{role:\"text\",\"aria-live\":\"polite\",\"aria-atomic\":\"false\",style:{margin:0,width:\"100%\",color:textColor,...useTextBalance&&{textWrap:\"balance\"},...font,whiteSpace:\"pre-wrap\",wordWrap:\"break-word\"},children:revealWords.map((word,index)=>{const wordIndex=index+1;const shouldAnimate=wordIndex>=startFromWord;const lowerWord=word.toLowerCase();const isHighlighted=!!cleanedHighlightText&&lowerWord.includes(cleanedHighlightText);if(!shouldAnimate){return /*#__PURE__*/_jsxs(\"span\",{style:{display:\"inline\",opacity:1,color:isHighlighted?highlightColor:undefined,...index===0&&{paddingLeft:getIndent}},children:[word,\" \"]},`${word}-${index}`);}const wordsToAnimate=Math.max(1,revealWords.length-(startFromWord-1));const animatedWordIndex=index-(startFromWord-1);const wordRevealStart=animatedWordIndex/wordsToAnimate;const wordRevealEnd=(animatedWordIndex+1)/wordsToAnimate;let wordOpacity=initialOpacity;if(isStaticRenderer){wordOpacity=1;}else if(scrollProgress>=wordRevealEnd){wordOpacity=1;}else if(scrollProgress>wordRevealStart){const wordProgress=(scrollProgress-wordRevealStart)/(wordRevealEnd-wordRevealStart);wordOpacity=initialOpacity+(1-initialOpacity)*wordProgress;}return /*#__PURE__*/_jsxs(\"span\",{style:{display:\"inline\",opacity:wordOpacity,color:isHighlighted?highlightColor:undefined,transitionProperty:\"opacity\",transitionDuration:`${fadeDuration}s`,transitionTimingFunction:fadeEasing,transitionDelay:`${fadeDelay*animatedWordIndex}s`,...index===0&&{paddingLeft:getIndent}},children:[word,\" \"]},`${word}-${index}`);})})})});}const hideFluxControls=props=>!props.enableTextFluxUnveil;addPropertyControls(RichTextComponent,{highlightText:{type:ControlType.String,title:\"Key Text\",defaultValue:\"sample\",placeholder:\"Text to highlight...\"},highlightColor:{type:ControlType.Color,title:\"Color\",defaultValue:\"#FF6B35\"},highlightPosition:{type:ControlType.Enum,title:\"Position\",options:[\"start\",\"end\"],optionTitles:[\"Beginning\",\"End\"],defaultValue:\"end\",displaySegmentedControl:true},text:{type:ControlType.String,title:\"Main Text\",defaultValue:\"This is a sample text with rich formatting support. You can style different words with different colors and weights.\",displayTextArea:true},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"16px\",variant:\"Regular\",letterSpacing:\"0em\",lineHeight:\"1.4em\",textAlign:\"left\"},controls:\"extended\",defaultFontType:\"sans-serif\",displayTextAlignment:true,displayFontSize:true},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},textIndent:{type:ControlType.Number,title:\"Indent Value\",defaultValue:100,min:0,max:500,step:1},indentType:{type:ControlType.Enum,title:\"Indent Type\",options:[\"px\",\"percentage\"],optionTitles:[\"Pixels\",\"Percentage\"],defaultValue:\"px\",displaySegmentedControl:true},useTextBalance:{type:ControlType.Boolean,title:\"Text Balance\",defaultValue:false,enabledTitle:\"Balanced\",disabledTitle:\"Normal\"},enableTextFluxUnveil:{type:ControlType.Boolean,title:\"Text Flux Unveil\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},startFromWord:{type:ControlType.Number,title:\"Start From Word\",defaultValue:5,min:1,max:50,step:1,hidden:hideFluxControls},initialOpacity:{type:ControlType.Number,title:\"Initial Opacity\",defaultValue:.2,min:0,max:1,step:.1,hidden:hideFluxControls},fadeDelay:{type:ControlType.Number,title:\"Fade Delay\",defaultValue:0,min:0,max:1,step:.05,unit:\"s\",hidden:hideFluxControls},fadeDuration:{type:ControlType.Number,title:\"Fade Duration\",defaultValue:.1,min:0,max:2,step:.1,unit:\"s\",hidden:hideFluxControls},fadeEasing:{type:ControlType.Enum,title:\"Fade Easing\",options:[\"linear\",\"easeIn\",\"easeOut\",\"easeInOut\"],optionTitles:[\"Linear\",\"Ease In\",\"Ease Out\",\"Ease In Out\"],defaultValue:\"linear\",hidden:hideFluxControls},fullRevealDistance:{type:ControlType.Number,title:\"Full Reveal Distance\",defaultValue:150,min:100,max:1e3,step:50,unit:\"px\",hidden:hideFluxControls},stickyTop:{type:ControlType.String,title:\"Sticky Top\",defaultValue:\"20vh\",hidden:hideFluxControls}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RichTextComponent\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RichTextComponent.map"],"mappings":"2RAKG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,OAAK,OAAK,YAAU,gBAAc,iBAAe,oBAAkB,aAAW,aAAW,iBAAe,uBAAqB,gBAAc,iBAAe,YAAU,eAAa,aAAW,qBAAmB,aAAW,EAAY,EAAaA,EAAO,IAAI,EAAQ,EAAiB,EAAoB,EAAQ,EAAS,EAAU,EAAa,CAAC,OAAO,mBAAmB,CAAC,EAAO,CAAC,WAAS,EAAU,EAAO,CAAC,EAAW,GAAeC,EAAS,CAAC,EAAO,CAAC,EAAa,GAAiBA,EAAS,CAAC,EAAO,CAAC,EAAe,GAAmBA,EAAS,CAAC,EAAQ,EAAcC,MAAY,CAAC,GAAG,CAAC,GAAe,EAAc,KAAK,IAAI,GAAI,OAAO,EAAM,IAAM,EAAe,UAAU,EAAe,GAAS,EAAU,OAAO,IAAI,EAAc,QAAQ,sBAAsB,MAAM,EAAE,GAAG,IAAI,EACzzB,GAAG,EAAK,YAAY,CAAC,CAAC,SAAS,EAAc,YAAY,CAAC,EAAG,OAAO,EAAK,QAAQ,EAAM,gBAAgB,EAAe,YAAY,EAAO,CACzI,IAAM,EAAc,gBAAgB,EAAe,IAAI,EAAc,SAAgF,OAApE,IAAoB,QAAe,GAAG,EAAc,GAAG,IAAmB,GAAG,EAAK,GAAG,GAAiB,CAAC,EAAE,CAAC,EAAK,EAAc,EAAe,CAAiB,CAAC,EAAQ,EAAUA,MAAY,CAAC,OAAO,EAAP,CAAmB,IAAI,KAAK,MAAM,GAAG,EAAW,IA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