import{r as e,j as t}from"./vendor-react-Dp9pL_Wn.js";const n="undefined"!=typeof Intl&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null;const r=e.memo(({text:r})=>{const[a,u]=e.useState(r),[s,o]=e.useState(0),[m,c]=e.useState(!1),i=e.useRef(null),l=e.useRef(r),f=e.useMemo(()=>function(e){return n?Array.from(n.segment(e),e=>e.segment):Array.from(e)}(a),[a]);return e.useEffect(()=>{l.current=r,r!==a&&c(!0)},[r]),e.useEffect(()=>{const e=f.length,t=m?11:16,n=s;let r=null;const a=s=>{r??=s;const f=Math.floor((s-r)/t),d=m?Math.max(0,n-f):Math.min(e,f);o(d),(m?d>0:d<e)?i.current=requestAnimationFrame(a):m&&(u(l.current),c(!1))};return i.current=requestAnimationFrame(a),()=>{null!==i.current&&cancelAnimationFrame(i.current)}},[a,f.length,m]),t.jsx("span",{"aria-hidden":!0,children:f.slice(0,s).join("")})});r.displayName="TypewriterText";export{r as TypewriterText};
