{"version":3,"file":"LightShadowText.BDnVTeIv.mjs","names":["useRef","useEffect","_jsx","_jsxs","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","window","p","c","init_jsx_runtime","ce","de","addPropertyControls","init_framer_B3LLf74D","useIsStaticRenderer","ControlType","LightShadowText","props","text","font","fontSize","color","shadowColor","maxOffset","range","singleLine","Tag","rootRef","wordRefs","isStatic","words","frame","x","y","hasPointer","inView","update","schedule","el","rect","dx","dy","distance","reach","length","NEAR_RADIUS","ux","uy","layers","i","LAYERS","step","observer","entries","onMove","event","onLeave","word","index","init_LightShadowText"],"sources":["https:/framerusercontent.com/modules/e6pPAnDXVt1OzYUVJIPj/VpYoaouQENwGW8xiIrOb/LightShadowText.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";const LAYERS=8;// Words closer to the cursor than this cast a shorter shadow, so the\n// direction never flips abruptly under the pointer.\nconst NEAR_RADIUS=80;/**\n * Text where every word casts a shadow away from the cursor,\n * as if the cursor were a light source.\n *\n * @framerIntrinsicWidth 600\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function LightShadowText(props){const{text,font,fontSize,color,shadowColor,maxOffset,range,singleLine}=props;const Tag=props.tag??\"h2\";const rootRef=useRef(null);const wordRefs=useRef([]);const isStatic=useIsStaticRenderer();const words=text.split(/\\s+/).filter(Boolean);useEffect(()=>{if(isStatic||typeof window===\"undefined\")return;let frame=0;let x=0;let y=0;let hasPointer=false;let inView=true;const update=()=>{frame=0;// A single line is meant to sit in a ticker, where words move\n// under a resting cursor, so keep updating while it is lit.\nif(singleLine&&hasPointer&&inView)schedule();for(const el of wordRefs.current){if(!el)continue;if(!hasPointer){el.style.textShadow=\"none\";continue;}const rect=el.getBoundingClientRect();const dx=rect.left+rect.width/2-x;const dy=rect.top+rect.height/2-y;const distance=Math.hypot(dx,dy);const reach=Math.max(0,1-distance/Math.max(range,1));const length=maxOffset*reach*Math.min(1,distance/NEAR_RADIUS);if(length<.5||distance===0){el.style.textShadow=\"none\";continue;}const ux=dx/distance;const uy=dy/distance;const layers=[];for(let i=1;i<=LAYERS;i++){const step=length*i/LAYERS;layers.push(`${(ux*step).toFixed(2)}px ${(uy*step).toFixed(2)}px 0 ${shadowColor}`);}el.style.textShadow=layers.join(\", \");}};function schedule(){if(!frame)frame=requestAnimationFrame(update);}const observer=new IntersectionObserver(entries=>{inView=entries[entries.length-1].isIntersecting;if(inView)schedule();});if(rootRef.current)observer.observe(rootRef.current);const onMove=event=>{if(event.pointerType!==\"mouse\")return;x=event.clientX;y=event.clientY;hasPointer=true;schedule();};const onLeave=()=>{hasPointer=false;schedule();};window.addEventListener(\"pointermove\",onMove,{passive:true});window.addEventListener(\"scroll\",schedule,{passive:true});document.documentElement.addEventListener(\"pointerleave\",onLeave);return()=>{if(frame)cancelAnimationFrame(frame);observer.disconnect();window.removeEventListener(\"pointermove\",onMove);window.removeEventListener(\"scroll\",schedule);document.documentElement.removeEventListener(\"pointerleave\",onLeave);};},[isStatic,range,maxOffset,shadowColor,text,singleLine]);return /*#__PURE__*/_jsx(Tag,{ref:rootRef,style:{...props.style,position:\"relative\",width:singleLine?\"max-content\":\"100%\",whiteSpace:singleLine?\"nowrap\":\"normal\",margin:0,color,...font,fontSize,letterSpacing:\"-0.04em\",lineHeight:`${props.lineHeight??1}em`,textAlign:\"start\"},children:words.map((word,index)=>/*#__PURE__*/_jsxs(\"span\",{children:[/*#__PURE__*/_jsx(\"span\",{ref:el=>{wordRefs.current[index]=el;},style:{display:\"inline-block\"},children:word}),!singleLine&&index<words.length-1?\" \":null]},index))});}addPropertyControls(LightShadowText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Every word casts a shadow away from the cursor.\",displayTextArea:true},font:{type:ControlType.Font,title:\"Font\",controls:\"basic\",defaultFontType:\"sans-serif\",displayFontSize:false,displayTextAlignment:false},fontSize:{type:ControlType.Number,title:\"Size\",defaultValue:93,min:8,max:300,step:1,unit:\"px\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"rgb(15, 15, 15)\"},shadowColor:{type:ControlType.Color,title:\"Shadow\",defaultValue:\"rgb(208, 244, 33)\"},maxOffset:{type:ControlType.Number,title:\"Length\",defaultValue:14,min:0,max:60,step:1,unit:\"px\"},range:{type:ControlType.Number,title:\"Range\",defaultValue:700,min:100,max:2e3,step:10,unit:\"px\"},lineHeight:{type:ControlType.Number,title:\"Line Height\",defaultValue:1,min:.8,max:2,step:.05,unit:\"em\"},tag:{type:ControlType.Enum,title:\"Tag\",options:[\"h1\",\"h2\",\"h3\",\"p\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"P\"],defaultValue:\"h2\"},singleLine:{type:ControlType.Boolean,title:\"Single Line\",description:\"One unbroken line without spaces between words, for use in a ticker.\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LightShadowText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"600\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LightShadowText.map"],"mappings":"A,8MAUG,SAAwBiB,EAAgBC,EAAM,CAAC,GAAK,CAACC,OAAKC,OAAKC,WAASC,QAAMC,cAAYC,YAAUC,QAAMC,cAAYR,EAAYS,EAAIT,EAAM,KAAK,KAAWU,EAAQ5B,EAAO,IAAI,EAAQ6B,EAAS7B,EAAO,CAAC,CAAC,EAAQ8B,EAASf,EAAoB,EAAQgB,EAAMZ,EAAK,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,EAE4xC,OAF1xClB,MAAc,CAAC,GAAG6B,GAAiBvB,IAAS,OAAY,OAAO,IAAIyB,EAAM,EAAMC,EAAE,EAAMC,EAAE,EAAMC,EAAW,GAAUC,EA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