{"version":3,"file":"ShimmerText.CxKnRqYN.mjs","names":["useRef","useState","useMemo"],"sources":["https:/framerusercontent.com/modules/Q8kCep7K45ow0OmfRZrk/vcUyze30EISIPJOhmpA2/ShimmerText.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useMemo,useRef}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * fiadsgn — ShimmerText\n *\n * Drop-in text element with the nirnor-style per-character flicker:\n * each glyph blinks out and snaps back at random for a short burst,\n * then resolves cleanly to fully visible. Use it for any text on\n * the site (project titles, labels, descriptions) to match the\n * homepage slider.\n *\n * Trigger options:\n * - On load (default): shimmers once when it appears.\n * - On view: shimmers when scrolled into view (good for project\n *   pages where text sits lower down).\n * - On hover: re-runs the flicker each hover.\n *\n * The grey-stuck bug is fixed three ways: keyframes resolve to full\n * by 88%, base opacity is 1, and the animation self-removes on end.\n */let fiaKeyId=0;function buildChars(text){const id=++fiaKeyId;let css=\"\";let charIndex=0;// Count non-space chars so we can spread their arrival across the timeline.\nconst totalChars=(text||\"\").replace(/\\s+/g,\"\").length||1;const tokens=(text||\"\").split(/(\\s+)/)// keeps whitespace chunks\n;const words=tokens.map((tok,wi)=>{const isSpace=/^\\s+$/.test(tok);const chars=tok.split(\"\").map(c=>{const i=charIndex++;const name=`fiaST_${id}_${i}`;// Measured from nirnor (60fps, frame-by-frame): once a glyph\n// arrives it doesn't just appear — it FLICKERS a random number\n// of times (some 0–1, some 3–4), oscillating between visible and\n// dim like a tube warming up, THEN settles solid. Some letters\n// (e.g. early ones) barely flicker; others stutter several times.\n// That stutter is the soul of the effect.\n//\n// start: when this glyph's flicker begins (0–60% of timeline),\n// randomized so arrival is scattered, not left-to-right.\nconst start=Math.round(Math.random()*60);// how many on/off flickers before it commits: 1–4, weighted so\n// some settle almost immediately and some stutter a lot.\nconst flickers=1+Math.floor(Math.random()*4);// the flicker burst occupies a short window after start\nconst window=14+Math.round(Math.random()*16)// 14–30%\n;const settleAt=Math.min(start+window,100);const keys=[`0%{opacity:0}`];if(start>1)keys.push(`${start-1}%{opacity:0}`);// build the oscillation: alternate bright/dim across the window\nfor(let f=0;f<=flickers;f++){const pct=Math.min(Math.round(start+window*f/(flickers+1)),settleAt);// bright on even steps, dim on odd — with slight randomness\nconst on=f%2===0;const o=on?(.85+Math.random()*.15).toFixed(2)// near/at full\n:(.1+Math.random()*.3).toFixed(2)// dim, not gone\n;keys.push(`${pct}%{opacity:${o}}`);}keys.push(`${settleAt}%{opacity:1}`);keys.push(`100%{opacity:1}`);css+=`@keyframes ${name}{${keys.join(\"\")}}`;return{c,name,delay:0,key:i};});return{chars,isSpace,key:wi};});return{words,css};}export default function ShimmerText(props){const{text,trigger,duration,font,color,align,lineHeight}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const ref=useRef(null);// a bump counter forces a remount of the spans -> replays animation\nconst[runId,setRunId]=useState(0);const[armed,setArmed]=useState(trigger===\"load\");const{words,css}=useMemo(()=>buildChars(text),[text,runId]);// on-load trigger\nuseEffect(()=>{if(isCanvas)return;if(trigger===\"load\"){const t=setTimeout(()=>setRunId(n=>n+1),60);return()=>clearTimeout(t);}},[isCanvas,trigger]);// on-view trigger\nuseEffect(()=>{if(isCanvas||trigger!==\"view\")return;const el=ref.current;if(!el)return;const io=new IntersectionObserver(entries=>{if(entries[0].isIntersecting){setRunId(n=>n+1);io.disconnect();}},{threshold:.25});io.observe(el);return()=>io.disconnect();},[isCanvas,trigger]);const playing=!isCanvas&&(trigger!==\"view\"?armed:true);const handleEnter=()=>{if(trigger===\"hover\"&&!isCanvas)setRunId(n=>n+1);};// On canvas, or before first run for load/hover, show static text.\nconst showStatic=isCanvas||trigger===\"load\"&&runId===0||trigger===\"hover\"&&runId===0;return /*#__PURE__*/_jsx(\"div\",{ref:ref,onMouseEnter:handleEnter,style:{...font,color,textAlign:align,lineHeight,cursor:trigger===\"hover\"?\"pointer\":\"inherit\",display:\"inline-block\"},children:showStatic?/*#__PURE__*/_jsx(\"span\",{children:text}):/*#__PURE__*/_jsxs(\"span\",{children:[/*#__PURE__*/_jsx(\"style\",{children:css}),words.map(word=>word.isSpace?// a real space that CAN wrap between words\n    /*#__PURE__*/_jsx(\"span\",{children:\" \"},word.key):// whole word: never breaks internally\n    /*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",whiteSpace:\"nowrap\"},children:word.chars.map(({c,name,delay,key})=>/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",opacity:1,animation:`${name} ${duration}s ${delay}s step-end 1 both`},onAnimationEnd:e=>{e.currentTarget.style.animation=\"none\";},children:c},key))},word.key))]},runId)});}ShimmerText.defaultProps={text:\"ZALINAE\",trigger:\"load\",duration:1.3,color:\"#0A0A0A\",align:\"left\",lineHeight:1.4};addPropertyControls(ShimmerText,{text:{type:ControlType.String,title:\"Text\",displayTextArea:true,defaultValue:\"ZALINAE\"},trigger:{type:ControlType.Enum,title:\"Trigger\",options:[\"load\",\"view\",\"hover\"],optionTitles:[\"On load\",\"On scroll into view\",\"On hover\"],defaultValue:\"load\"},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:1.1,min:.4,max:5,step:.1,description:\"How long the reveal takes — higher is slower\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#0A0A0A\"},align:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},lineHeight:{type:ControlType.Number,title:\"Line height\",defaultValue:1.4,min:.8,max:3,step:.1,displayStepper:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ShimmerText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ShimmerText.map"],"mappings":"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