var Xe=Object.defineProperty,Ge=Object.defineProperties;var Ke=Object.getOwnPropertyDescriptors;var Ee=Object.getOwnPropertySymbols;var Ye=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var fe=(t,e,s)=>e in t?Xe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Y=(t,e)=>{for(var s in e||(e={}))Ye.call(e,s)&&fe(t,s,e[s]);if(Ee)for(var s of Ee(e))Ze.call(e,s)&&fe(t,s,e[s]);return t},Ce=(t,e)=>Ge(t,Ke(e));var y=(t,e,s)=>(fe(t,typeof e!="symbol"?e+"":e,s),s),Ie=(t,e,s)=>{if(!e.has(t))throw TypeError("Cannot "+s)};var f=(t,e,s)=>(Ie(t,e,"read from private field"),s?s.call(t):e.get(t)),h=(t,e,s)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,s)};var n=(t,e,s)=>(Ie(t,e,"access private method"),s);var p=(t,e,s)=>new Promise((i,r)=>{var o=l=>{try{a(s.next(l))}catch(d){r(d)}},u=l=>{try{a(s.throw(l))}catch(d){r(d)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,u);a((s=s.apply(t,e)).next())});import{d as et,a as tt,m as st,i as Ne}from"./index-BfJLwqhi.js";const xe=t=>Array.isArray(t),Me=t=>xe(t)?t:[t];let it=function(t){let e=function(c){return Me(c).forEach(T=>{var K;return m.set(Symbol((K=T.char)==null?void 0:K.innerText),r(Y({},T)))}),this},s=()=>l().filter(c=>c.typeable),i=function(c,T){let K=[...m.keys()];m.set(K[c],r(T))},r=c=>(c.shouldPauseCursor=function(){return!!(this.typeable||this.cursorable||this.deletable)},c),o=function(){m.forEach(c=>delete c.done)},u=function(){m=new Map,e(t)},a=()=>m,l=()=>Array.from(m.values()),d=c=>m.delete(c),E=(c=!1)=>c?l():l().filter(T=>!T.done),G=(c,T=!1)=>T?m.delete(c):m.get(c).done=!0,m=new Map;return e(t),{add:e,set:i,wipe:u,done:G,reset:o,destroy:d,getItems:E,getQueue:a,getTypeable:s}};const Re="data-typeit-id",q="ti-cursor",rt="END",nt={started:!1,completed:!1,frozen:!1,destroyed:!1},x={breakLines:!0,cursor:{autoPause:!0,autoPauseDelay:500,animation:{frames:[0,0,1].map(t=>({opacity:t})),options:{iterations:1/0,easing:"steps(2, start)",fill:"forwards"}}},cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}},ot=`[${Re}]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}`,ee=t=>document.createElement(t),we=t=>document.createTextNode(t),$e=(t,e="")=>{let s=ee("style");s.id=e,s.appendChild(we(t)),document.head.appendChild(s)},Ae=t=>(xe(t)||(t=[t/2,t/2]),t),Le=(t,e)=>Math.abs(Math.random()*(t+e-(t-e))+(t-e));let ve=t=>t/2;function ut(t){let{speed:e,deleteSpeed:s,lifeLike:i}=t;return s=s!==null?s:e/3,i?[Le(e,ve(e)),Le(s,ve(s))]:[e,s]}const Fe=t=>Array.from(t);let Pe=t=>([...t.childNodes].forEach(e=>{if(e.nodeValue){[...e.nodeValue].forEach(s=>{e.parentNode.insertBefore(we(s),e)}),e.remove();return}Pe(e)}),t);const He=t=>{let e=document.implementation.createHTMLDocument();return e.body.innerHTML=t,Pe(e.body)};function Qe(t,e=!1,s=!1){let i=t.querySelector(`.${q}`),r=document.createTreeWalker(t,NodeFilter.SHOW_ALL,{acceptNode:a=>{var l,d;if(i&&s){if((l=a.classList)!=null&&l.contains(q))return NodeFilter.FILTER_ACCEPT;if(i.contains(a))return NodeFilter.FILTER_REJECT}return(d=a.classList)!=null&&d.contains(q)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),o,u=[];for(;o=r.nextNode();)o.originalParent||(o.originalParent=o.parentNode),u.push(o);return e?u.reverse():u}function at(t){return Qe(He(t))}function lt(t,e=!0){return e?at(t):Fe(t).map(we)}const Be=t=>Number.isInteger(t),De=({queueItems:t,selector:e,cursorPosition:s,to:i})=>{if(Be(e))return e*-1;let r=new RegExp(rt,"i").test(i),o=e?[...t].reverse().findIndex(({char:a})=>{let l=a.parentElement,d=l.matches(e);return r&&d?!0:d&&l.firstChild.isSameNode(a)}):-1;o<0&&(o=r?0:t.length-1);let u=r?0:1;return o-s+u},ht=t=>(t.forEach(clearTimeout),[]),Z=(t,e)=>new Array(e).fill(t);let re=t=>new Promise(e=>{requestAnimationFrame(()=>p(void 0,null,function*(){e(yield t())}))}),_e=t=>t==null?void 0:t.getAnimations().find(e=>e.id===t.dataset.tiAnimationId),ze=({cursor:t,frames:e,options:s})=>{let i=t.animate(e,s);return i.pause(),i.id=t.dataset.tiAnimationId,re(()=>{re(()=>{i.play()})}),i},dt=({cursor:t,options:e,cursorOptions:s})=>{if(!t||!s)return;let i=_e(t),r;i&&(e.delay=i.effect.getComputedTiming().delay,r=i.currentTime,i.cancel());let o=ze({cursor:t,frames:s.animation.frames,options:e});return r&&(o.currentTime=r),o},qe=t=>{var e;return(e=t.func)==null?void 0:e.call(null)},ct=o=>p(void 0,[o],function*({index:t,queueItems:e,wait:s,cursor:i,cursorOptions:r}){let u=e[t][1],a=[],l=t,d=u,E=()=>d&&!d.delay,G=u.shouldPauseCursor()&&r.autoPause;for(;E();)a.push(d),E()&&l++,d=e[l]?e[l][1]:null;if(a.length)return yield re(()=>p(void 0,null,function*(){for(let T of a)yield qe(T)})),l-1;let m=_e(i),c;return m&&(c=Ce(Y({},m.effect.getComputedTiming()),{delay:G?r.autoPauseDelay:0})),yield s(()=>p(void 0,null,function*(){m&&G&&m.cancel(),yield re(()=>{qe(u)})}),u.delay),yield dt({cursor:i,options:c,cursorOptions:r}),t});const ft=(t,e)=>{new IntersectionObserver((i,r)=>{i.forEach(o=>{o.isIntersecting&&(e(),r.unobserve(t))})},{threshold:1}).observe(t)},pt=()=>Math.random().toString().substring(2,9),ne=t=>"value"in t;let mt=t=>ne(t)?Fe(t.value):Qe(t,!0).filter(e=>!(e.childNodes.length>0)),k=t=>typeof t=="function"?t():t,Se=(t,e=document,s=!1)=>e[`querySelector${s?"All":""}`](t),yt=t=>/body/i.test(t==null?void 0:t.tagName),bt=(t,e)=>{if(ne(t)){t.value=`${t.value}${e.textContent}`;return}e.innerHTML="";let s=yt(e.originalParent)?t:e.originalParent||t;s.insertBefore(e,Se("."+q,s)||null)};const gt=t=>/<(.+)>(.*?)<\/(.+)>/.test(t.outerHTML),F=(t,e)=>Object.assign({},t,e);let Tt=t=>{var e,s,i;if(typeof t=="object"){let r={},{frames:o,options:u}=x.cursor.animation;return r.animation=t.animation||{},r.animation.frames=((e=t.animation)==null?void 0:e.frames)||o,r.animation.options=F(u,((s=t.animation)==null?void 0:s.options)||{}),r.autoPause=(i=t.autoPause)!=null?i:x.cursor.autoPause,r.autoPauseDelay=t.autoPauseDelay||x.cursor.autoPauseDelay,r}return t===!0?x.cursor:t};const wt=(t,e)=>{if(!t)return;let s=t.parentNode;(s.childNodes.length>1||s.isSameNode(e)?t:s).remove()},Pt=(t,e,s)=>{let i=e[s-1],r=Se(`.${q}`,t);t=(i==null?void 0:i.parentNode)||t,t.insertBefore(r,i||null)};function St(t){return typeof t=="string"?Se(t):t}let Et={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"",transform:"translateX(-.125em)"},Ct=(t,e)=>{let i=`${`[${Re}='${t}']`} .${q}`,r=getComputedStyle(e),o=Object.entries(Et).reduce((u,[a,l])=>`${u} ${a}: var(--ti-cursor-${a}, ${l||r[a]});`,"");$e(`${i} { display: inline-block; width: 0; ${o} }`,t)};function It(t){return t.replace(//g,"").trim().split(/
/)}let Nt=(t,e,s)=>Math.min(Math.max(e+t,0),s.length),At=(t,e,s)=>new Promise(i=>{let r=()=>p(void 0,null,function*(){yield t(),i()});s.push(setTimeout(r,e||0))});var oe,Ue,I,H,V,pe,ue,Ve,j,me,O,ye,W,be,M,te,b,w,ae,je,N,Q,A,B,le,Oe,he,de,We,ce,Je,J,ge,R,se,L,_,$,ie,S,C,v,z,D,U,X,Te,g,P,ke;let Lt=(ke=class{constructor(e,s={}){h(this,oe);h(this,I);h(this,V);h(this,ue);h(this,j);h(this,O);h(this,W);h(this,M);h(this,b);h(this,ae);h(this,N);h(this,A);h(this,le);h(this,de);h(this,ce);h(this,J);h(this,R);h(this,L);h(this,$);h(this,S);h(this,v);h(this,D);h(this,X);h(this,g);y(this,"element");y(this,"timeouts");y(this,"cursorPosition");y(this,"predictedCursorPosition");y(this,"statuses",{started:!1,completed:!1,frozen:!1,destroyed:!1});y(this,"opts");y(this,"id");y(this,"queue");y(this,"cursor");y(this,"unfreeze",()=>{});y(this,"is",function(e){return this.statuses[e]});h(this,he,e=>{var s;e.cursor=Tt((s=e.cursor)!=null?s:x.cursor),this.opts.strings=n(this,de,We).call(this,Me(this.opts.strings)),this.opts=F(this.opts,{html:!f(this,D,U)&&this.opts.html,nextStringDelay:Ae(this.opts.nextStringDelay),loopDelay:Ae(this.opts.loopDelay)})});this.opts=F(x,s),this.element=St(e),this.timeouts=[],this.cursorPosition=0,this.unfreeze=()=>{},this.predictedCursorPosition=null,this.statuses=F({},nt),this.id=pt(),this.queue=it([{delay:this.opts.startDelay}]),f(this,he).call(this,s),this.cursor=n(this,ce,Je).call(this),this.element.dataset.typeitId=this.id,$e(ot),this.opts.strings.length&&n(this,le,Oe).call(this)}go(){return this.statuses.started?this:(n(this,W,be).call(this),this.opts.waitUntilVisible?(ft(this.element,n(this,I,H).bind(this)),this):(n(this,I,H).call(this),this))}destroy(e=!0){this.timeouts=ht(this.timeouts),k(e)&&this.cursor&&n(this,$,ie).call(this,this.cursor),this.statuses.destroyed=!0}reset(e){!this.is("destroyed")&&this.destroy(),e?(this.queue.wipe(),e(this)):this.queue.reset(),this.cursorPosition=0;for(let s in this.statuses)this.statuses[s]=!1;return this.element[n(this,M,te).call(this)?"value":"innerHTML"]="",this}type(e,s={}){e=k(e);let{instant:i}=s,r=n(this,N,Q).call(this,s),u=lt(e,this.opts.html).map(l=>({func:()=>n(this,R,se).call(this,l),char:l,delay:i||gt(l)?0:n(this,S,C).call(this),typeable:l.nodeType===Node.TEXT_NODE})),a=[r[0],{func:()=>p(this,null,function*(){return yield this.opts.beforeString(e,this)})},...u,{func:()=>p(this,null,function*(){return yield this.opts.afterString(e,this)})},r[1]];return n(this,b,w).call(this,a,s)}break(e={}){return n(this,b,w).call(this,{func:()=>n(this,R,se).call(this,ee("BR")),typeable:!0},e)}move(e,s={}){e=k(e);let i=n(this,N,Q).call(this,s),{instant:r,to:o}=s,u=De({queueItems:this.queue.getTypeable(),selector:e===null?"":e,to:o,cursorPosition:f(this,v,z)}),a=u<0?-1:1;return this.predictedCursorPosition=f(this,v,z)+u,n(this,b,w).call(this,[i[0],...Z({func:()=>n(this,V,pe).call(this,a),delay:r?0:n(this,S,C).call(this),cursorable:!0},Math.abs(u)),i[1]],s)}exec(e,s={}){let i=n(this,N,Q).call(this,s);return n(this,b,w).call(this,[i[0],{func:()=>e(this)},i[1]],s)}options(e,s={}){return e=k(e),n(this,A,B).call(this,e),n(this,b,w).call(this,{},s)}pause(e,s={}){return n(this,b,w).call(this,{delay:k(e)},s)}delete(e=null,s={}){e=k(e);let i=n(this,N,Q).call(this,s),r=e,{instant:o,to:u}=s,a=this.queue.getTypeable(),l=r===null?a.length:Be(r)?r:De({queueItems:a,selector:r,cursorPosition:f(this,v,z),to:u});return n(this,b,w).call(this,[i[0],...Z({func:n(this,L,_).bind(this),delay:o?0:n(this,S,C).call(this,1),deletable:!0},l),i[1]],s)}freeze(){this.statuses.frozen=!0}flush(e=()=>{}){return n(this,W,be).call(this),n(this,I,H).call(this,!1).then(e),this}getQueue(){return this.queue}getOptions(){return this.opts}updateOptions(e){return n(this,A,B).call(this,e)}getElement(){return this.element}empty(e={}){return n(this,b,w).call(this,{func:n(this,oe,Ue).bind(this)},e)}},oe=new WeakSet,Ue=function(){return p(this,null,function*(){if(n(this,M,te).call(this)){this.element.value="";return}f(this,g,P).forEach(n(this,$,ie).bind(this))})},I=new WeakSet,H=function(e=!0){return p(this,null,function*(){this.statuses.started=!0;let s=i=>{this.queue.done(i,!e)};try{let i=[...this.queue.getQueue()];for(let o=0;od+E).forEach(d=>{let[E]=i[d];s(E)}),o=l}s(u)}}if(!e)return this;if(this.statuses.completed=!0,yield this.opts.afterComplete(this),!this.opts.loop)throw"";let r=this.opts.loopDelay;n(this,O,ye).call(this,()=>p(this,null,function*(){yield n(this,ue,Ve).call(this,r[0]),n(this,I,H).call(this)}),r[1])}catch(i){}return this})},V=new WeakSet,pe=function(e){return p(this,null,function*(){this.cursorPosition=Nt(e,this.cursorPosition,f(this,g,P)),Pt(this.element,f(this,g,P),this.cursorPosition)})},ue=new WeakSet,Ve=function(e){return p(this,null,function*(){let s=f(this,v,z);s&&(yield n(this,V,pe).call(this,{value:s}));let i=f(this,g,P).map(r=>[Symbol(),{func:n(this,L,_).bind(this),delay:n(this,S,C).call(this,1),deletable:!0,shouldPauseCursor:()=>!0}]);for(let r=0;r{this.unfreeze=()=>{this.statuses.frozen=!1,r()}})),i||(yield this.opts.beforeStep(this)),yield At(e,s,this.timeouts),i||(yield this.opts.afterStep(this))})},W=new WeakSet,be=function(){return p(this,null,function*(){if(!n(this,M,te).call(this)&&this.cursor&&this.element.appendChild(this.cursor),f(this,X,Te)){Ct(this.id,this.element),this.cursor.dataset.tiAnimationId=this.id;let{animation:e}=this.opts.cursor,{frames:s,options:i}=e;ze({frames:s,cursor:this.cursor,options:Y({duration:this.opts.cursorSpeed},i)})}})},M=new WeakSet,te=function(){return ne(this.element)},b=new WeakSet,w=function(e,s){return this.queue.add(e),n(this,ae,je).call(this,s),this},ae=new WeakSet,je=function(e={}){let s=e.delay;s&&this.queue.add({delay:s})},N=new WeakSet,Q=function(e={}){return[{func:()=>n(this,A,B).call(this,e)},{func:()=>n(this,A,B).call(this,this.opts)}]},A=new WeakSet,B=function(e){return p(this,null,function*(){this.opts=F(this.opts,e)})},le=new WeakSet,Oe=function(){let e=this.opts.strings.filter(s=>!!s);e.forEach((s,i)=>{if(this.type(s),i+1===e.length)return;let r=this.opts.breakLines?[{func:()=>n(this,R,se).call(this,ee("BR")),typeable:!0}]:Z({func:n(this,L,_).bind(this),delay:n(this,S,C).call(this,1)},this.queue.getTypeable().length);n(this,J,ge).call(this,r)})},he=new WeakMap,de=new WeakSet,We=function(e){let s=this.element.innerHTML;return s?(this.element.innerHTML="",this.opts.startDelete?(this.element.innerHTML=s,Pe(this.element),n(this,J,ge).call(this,Z({func:n(this,L,_).bind(this),delay:n(this,S,C).call(this,1),deletable:!0},f(this,g,P).length)),e):It(s).concat(e)):e},ce=new WeakSet,Je=function(){if(f(this,D,U))return null;let e=ee("span");return e.className=q,f(this,X,Te)?(e.innerHTML=He(this.opts.cursorChar).innerHTML,e):(e.style.visibility="hidden",e)},J=new WeakSet,ge=function(e){let s=this.opts.nextStringDelay;this.queue.add([{delay:s[0]},...e,{delay:s[1]}])},R=new WeakSet,se=function(e){bt(this.element,e)},L=new WeakSet,_=function(){f(this,g,P).length&&(f(this,D,U)?this.element.value=this.element.value.slice(0,-1):n(this,$,ie).call(this,f(this,g,P)[this.cursorPosition]))},$=new WeakSet,ie=function(e){wt(e,this.element)},S=new WeakSet,C=function(e=0){return ut(this.opts)[e]},v=new WeakSet,z=function(){var e;return(e=this.predictedCursorPosition)!=null?e:this.cursorPosition},D=new WeakSet,U=function(){return ne(this.element)},X=new WeakSet,Te=function(){return!!this.opts.cursor&&!f(this,D,U)},g=new WeakSet,P=function(){return mt(this.element)},ke);const vt=et({name:"TypeIt",props:{options:{type:Object,default:()=>({})}},setup(t,{slots:e,expose:s}){function i(u){throw new TypeError(u)}function r(){return navigator.language}const o=tt(null);return st(()=>{const u=o.value.querySelector(".type-it");if(!u){const l=r()==="zh-CN"?"请确保有且只有一个具有class属性为 'type-it' 的元素":"Please make sure that there is only one element with a Class attribute with 'type-it'";i(l)}const a=new Lt(u,t.options).go();s({typeIt:a})}),()=>{var u,a;return Ne("div",{ref:o},[(a=(u=e.default)==null?void 0:u.call(e))!=null?a:Ne("span",{class:"type-it"},null)])}}}),xt=vt;export{xt as T};