{"version":3,"file":"ScrollText.cQLFQFRN.mjs","names":["useRef","useState","useMemo"],"sources":["https:/framerusercontent.com/modules/LH6mis2OQaBqlh3494Ip/PFSP4uqVd7M4ssNzz2ym/ScrollText.js"],"sourcesContent":["// Scroll Text with animation per word, slots for inline components, blur/fade on scroll, full font/text control. No DOMPurify.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion,useScroll,useTransform,useSpring}from\"framer-motion\";import{useEffect,useMemo,useRef,useState,startTransition}from\"react\";const EachWord=({word,starting,ending,startOpacity,endOpacity,progress,children,animationStyle,enableBlur,enableSmooth,isCanvas})=>{const sanitizedWord=word;const progressVal=useTransform(progress,[starting,ending],[startOpacity,endOpacity]);const yVal=useTransform(progress,[starting,ending],animationStyle===\"slide\"?[20,0]:[0,0]);const blurVal=useTransform(progress,[starting,ending],enableBlur?[10,0]:[0,0]);const filterVal=useTransform(blurVal,value=>`blur(${value}px)`);const springConfig={stiffness:100,damping:20,mass:1};const smoothOpacity=useSpring(progressVal,springConfig);const smoothY=useSpring(yVal,springConfig);const smoothBlur=useSpring(blurVal,springConfig);const smoothFilter=useTransform(smoothBlur,value=>`blur(${value}px)`);const finalOpacity=isCanvas?1:enableSmooth?smoothOpacity:progressVal;const finalY=isCanvas?0:enableSmooth?smoothY:yVal;const finalFilter=isCanvas?\"none\":enableSmooth?smoothFilter:filterVal;if(children){return /*#__PURE__*/_jsx(motion.span,{style:{opacity:finalOpacity,y:finalY,filter:enableBlur?finalFilter:undefined,willChange:animationStyle===\"slide\"?\"opacity, transform\":\"opacity\",display:\"inline-flex\",alignItems:\"center\"},children:children});}return /*#__PURE__*/_jsx(motion.span,{style:{opacity:finalOpacity,y:finalY,filter:enableBlur?finalFilter:undefined,willChange:animationStyle===\"slide\"?\"opacity, transform\":\"opacity\",display:\"inline\"},dangerouslySetInnerHTML:{__html:sanitizedWord}});};/**\n *\n * @framerIntrinsicWidth 480\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight auto\n */export default function ScrollText(props){const text=props.text;const ref=useRef(null);const outerContainerRef=useRef(null);const[hasOuterContainer,setHasOuterContainer]=useState(false);useEffect(()=>{if(typeof window===\"undefined\")return;const layerName=(props.outerContainerLayerName||\"\").trim();if(!layerName){outerContainerRef.current=null;startTransition(()=>setHasOuterContainer(false));return;}const escaped=// @ts-ignore\ntypeof CSS!==\"undefined\"&&CSS?.escape?CSS.escape(layerName):layerName.replace(/([\"\\\\])/g,\"\\\\$1\");const el=document.querySelector(`[data-framer-name=\"${escaped}\"]`);outerContainerRef.current=el;startTransition(()=>setHasOuterContainer(!!el));},[props.outerContainerLayerName]);const scrollTarget=hasOuterContainer?outerContainerRef:ref;const{scrollYProgress}=useScroll({target:scrollTarget,offset:[`start ${props.startOffset}`,`end ${props.endOffset}`]});const isCanvas=RenderTarget.current()===RenderTarget.canvas;const segments=useMemo(()=>{const textWithNewlines=text.replace(/<br\\s*\\/?>(\\s*<br\\s*\\/?>(\\s*))?/gi,\"\\n\\n\").replace(/<br\\s*\\/?>(?!\\n)/gi,\"\\n\");const slotEnabled=props.showSlots;return textWithNewlines.split(/(\\[[^\\]]*\\]|\\n+|<[^>]+>[^<]*<\\/[^^>]+>|<[^>]+>|[^\\s\\[\\]<>\\n]+)/g).filter(Boolean).map((segment,index)=>{if(segment.match(/\\n+/)){return{type:\"linebreak\",content:segment};}if(segment.startsWith(\"[\")&&segment.endsWith(\"]\")){const slotIndex=parseInt(segment.slice(1,-1))-1;if(slotEnabled&&!isNaN(slotIndex)&&slotIndex>=0){return{type:\"slot\",index:slotIndex};}else{return{type:\"text\",content:segment};}}if(segment.match(/^\\s+$/)){return null;}return{type:\"text\",content:segment};}).filter(segment=>segment!==null&&segment!==undefined);},[text,props.showSlots]);const totalSegments=segments.length;return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{width:\"100%\",height:\"auto\",// Remove maxWidth: 480,\n...props.font,color:props.textColor,margin:0,padding:0,display:\"flex\",flexWrap:\"wrap\",alignItems:\"baseline\",justifyContent:props.font?.textAlign===\"center\"?\"center\":props.font?.textAlign===\"right\"?\"flex-end\":\"flex-start\",textAlign:props.font?.textAlign||\"left\",gap:\"0.25em\",wordBreak:\"break-word\"},children:segments.map((segment,idx)=>{if(segment.type===\"linebreak\"){return /*#__PURE__*/_jsx(\"span\",{style:{flexBasis:\"100%\",height:0}},`break-${idx}`);}if(segment.type===\"slot\"){if(!props.showSlots)return null;const slotContent=props.slots?.[segment.index];if(!slotContent){// Render purple placeholder box when slot is empty\nconst fontSize=parseFloat(props.font?.fontSize)||36;const lineHeight=props.font?.lineHeight||1.1;const lineHeightValue=typeof lineHeight===\"string\"?parseFloat(lineHeight)*fontSize:lineHeight*fontSize;const boxSize=lineHeightValue;return /*#__PURE__*/_jsx(EachWord,{word:\"\",starting:idx/totalSegments,ending:(idx+1)/totalSegments,startOpacity:props.startOpacity,endOpacity:props.endOpacity,progress:scrollYProgress,animationStyle:props.animationStyle,enableBlur:props.enableBlur,enableSmooth:props.enableSmooth,isCanvas:isCanvas,children:/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",alignSelf:\"baseline\",marginLeft:props.layerGap||0,marginRight:props.layerGap||0,backgroundColor:\"rgba(136, 85, 255, 0.1)\",color:\"#8855FF\",padding:\"4px 12px\",border:\"1px solid #8855FF\",fontSize:\"14px\",fontWeight:\"bold\",width:boxSize,height:boxSize},children:segment.index+1})},`slot-${idx}`);}return /*#__PURE__*/_jsx(EachWord,{word:\"\",starting:idx/totalSegments,ending:(idx+1)/totalSegments,startOpacity:props.startOpacity,endOpacity:props.endOpacity,progress:scrollYProgress,animationStyle:props.animationStyle,enableBlur:props.enableBlur,enableSmooth:props.enableSmooth,isCanvas:isCanvas,children:/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-flex\",alignItems:\"center\",marginLeft:props.layerGap||0,marginRight:props.layerGap||0},children:slotContent})},`slot-${idx}`);}return /*#__PURE__*/_jsx(EachWord,{word:segment.content,starting:idx/totalSegments,ending:(idx+1)/totalSegments,startOpacity:props.startOpacity,endOpacity:props.endOpacity,progress:scrollYProgress,animationStyle:props.animationStyle,enableBlur:props.enableBlur,enableSmooth:props.enableSmooth,isCanvas:isCanvas,children:null},`text-${idx}`);})});}addPropertyControls(ScrollText,{outerContainerLayerName:{title:\"Scroll Container Name\",type:ControlType.String,defaultValue:\"\",placeholder:\"YOUR LAYER NAME\"},text:{title:\"Text\",type:ControlType.String,defaultValue:\"Turn your [1] into something people truly value in less time and with more [2]\",displayTextArea:true},showSlots:{type:ControlType.Boolean,title:\"Show Slots\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},slots:{type:ControlType.Array,title:\"Slots\",description:\"Add components to slots. Use [1], [2], etc. in text above.\",control:{type:ControlType.ComponentInstance},defaultValue:[],maxCount:10,hidden:props=>!props?.showSlots},layerGap:{type:ControlType.Number,title:\"Layer Gap\",defaultValue:2,min:0,max:100,step:1},font:{type:ControlType.Font,controls:\"extended\",defaultValue:{fontSize:36,variant:\"Regular\",lineHeight:1.1},defaultFontType:\"sans-serif\"},textColor:{type:ControlType.Color,defaultValue:\"#FFFFFF\"},animationStyle:{type:ControlType.Enum,title:\"Animation\",options:[\"fade\",\"slide\"],optionTitles:[\"Fade\",\"Slide\"],defaultValue:\"fade\",displaySegmentedControl:true},enableSmooth:{type:ControlType.Boolean,title:\"Smooth\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},enableBlur:{type:ControlType.Boolean,title:\"Blur\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},startOffset:{title:\"Start Offset\",type:ControlType.Number,defaultValue:.5,min:0,max:1,step:.01},endOffset:{title:\"End Offset\",type:ControlType.Number,defaultValue:.5,min:0,max:1,step:.01},startOpacity:{title:\"Start Opacity\",type:ControlType.Number,defaultValue:0,min:0,max:1,step:.01},endOpacity:{title:\"End Opacity\",type:ControlType.Number,defaultValue:1,min:0,max:1,step:.01}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollText\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"480\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollText.map"],"mappings":"6RAOG,SAAwB,EAAW,EAAM,CAAC,IAAM,EAAK,EAAM,KAAW,EAAIA,EAAO,KAAK,CAAO,EAAkBA,EAAO,KAAK,CAAM,CAAC,EAAkB,GAAsBC,EAAS,GAAM,CAAC,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,GAAW,EAAM,yBAAyB,IAAI,MAAM,CAAC,GAAG,CAAC,EAAU,CAAC,EAAkB,QAAQ,KAAK,MAAoB,EAAqB,GAAM,CAAC,CAAC,OAAQ,IAAM,EAC1Z,OAAO,IAAM,KAAa,KAAK,OAAO,IAAI,OAAO,EAAU,CAAC,EAAU,QAAQ,WAAW,OAAO,CAAO,EAAG,SAAS,cAAc,sBAAsB,EAAQ,IAAI,CAAC,EAAkB,QAAQ,EAAG,MAAoB,EAAqB,CAAC,CAAC,EAAG,CAAC,EAAG,CAAC,EAAM,wBAAwB,CAAC,CAA4D,GAAK,CAAC,mBAAiB,EAAU,CAAC,OAA1E,EAAkB,EAAkB,EAA0D,OAAO,CAAC,SAAS,EAAM,cAAc,OAAO,EAAM,YAAY,CAAC,CAAC,CAAO,EAAS,EAAa,SAAS,GAAG,EAAa,OAAa,EAASC,MAAY,CAAC,IAAM,EAAiB,EAAK,QAAQ,oCAAoC;;EAAO,CAAC,QAAQ,qBAAqB;EAAK,CAAO,EAAY,EAAM,UAAU,OAAO,EAAiB,MAAM,kEAAkE,CAAC,OAAO,QAAQ,CAAC,KAAK,EAAQ,IAAQ,CAAC,GAAG,EAAQ,MAAM,MAAM,CAAE,MAAM,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