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