import{b}from"./chunk-p42kdtn4.js";var d=["lines","words","chars"],T={lines:"split-text_line",words:"split-text_word",chars:"split-text_char"},_=(t)=>Boolean(t?.replace(/[\s\u200B-\u200D\uFEFF]/g,"")),m=(t)=>{let e=t.cloneNode(!0);return e.querySelectorAll("br").forEach((n)=>n.replaceWith(" ")),e.textContent?.replace(/\s+/g," ").trim()??""},E=(t,e)=>{if(e===null){t.removeAttribute("aria-hidden");return}t.setAttribute("aria-hidden",e)},w=(t,e,n)=>{if(E(t,n),n==="true"||!e)return;t.querySelectorAll(":scope > [data-split-text-sr]").forEach((p)=>p.remove());let o=document.createElement("span");o.className="u-sr-only",o.dataset.splitTextSr="",o.textContent=e,t.appendChild(o)},v=(t,e="lines")=>{let n=t?.trim().toLowerCase();return d.includes(n)?n:e},h=(t)=>Array.from(t.querySelectorAll("*")).every((e)=>e.tagName==="BR"),y=(t,e)=>{if(e==="lines")return t.lines;if(e==="words")return t.words;return t.chars};function f(t,{type:e="lines",autoSplit:n=e==="lines",onSplit:o}={}){let p=m(t),c=t.getAttribute("aria-hidden"),g=d.map((r)=>({property:`--${r}`,value:t.style.getPropertyValue(`--${r}`),priority:t.style.getPropertyPriority(`--${r}`)})),s=null,u={get instance(){return s},type:e,get items(){return s?y(s,e):[]},get lines(){return s?.lines??[]},get words(){return s?.words??[]},get chars(){return s?.chars??[]},revert(){let r=s;s=null,r?.kill(),r?.revert(),t.querySelectorAll(":scope > [data-split-text-sr]").forEach((l)=>l.remove()),E(t,c),g.forEach(({property:l,value:i,priority:a})=>{if(i)t.style.setProperty(l,i,a);else t.style.removeProperty(l)})}};return s=b.create(t,{type:e==="chars"?"words,chars":e,tag:"span",aria:c==="true"?"none":"hidden",autoSplit:n,deepSlice:!1,linesClass:T.lines,wordsClass:T.words,charsClass:T.chars,onSplit(r){return s=r,d.forEach((l)=>{let i=r[l],a=l.slice(0,-1);t.style.setProperty(`--${l}`,String(i.length)),i.forEach((x,S)=>{x.setAttribute(`data-${a}`,String(S)),x.style.setProperty(`--${a}`,String(S))})}),w(t,p,c),o?.({instance:r,items:y(r,e),lines:r.lines,words:r.words,chars:r.chars,handle:u})}}),u} export{_,v,h,f};