vue-pure-admin/dist/static/js/index-150817d0.js
2022-12-09 20:23:54 +08:00

2 lines
10 KiB
JavaScript

const le=e=>Array.isArray(e),ae=e=>le(e)?e:[e];let be=function(e){let t=function(c){return ae(c).forEach(w=>{var L;return b.set(Symbol((L=w.char)==null?void 0:L.innerText),s({...w}))}),this},n=()=>m().filter(c=>c.typeable),a=function(c,w){let L=[...b.keys()];b.set(L[c],s(w))},s=c=>(c.shouldPauseCursor=function(){return Boolean(this.typeable||this.cursorable||this.deletable)},c),i=function(){b.forEach(c=>delete c.done)},f=function(){b=new Map,t(e)},d=()=>b,m=()=>Array.from(b.values()),p=c=>b.delete(c),_=(c=!1)=>c?m():m().filter(w=>!w.done),S=(c,w=!1)=>w?b.delete(c):b.get(c).done=!0,b=new Map;return t(e),{add:t,set:a,wipe:f,reset:i,destroy:p,done:S,getItems:_,getQueue:d,getTypeable:n}};const se=e=>Array.from(e),j=e=>document.createTextNode(e);let J=e=>([...e.childNodes].forEach(t=>{if(t.nodeValue){[...t.nodeValue].forEach(n=>{t.parentNode.insertBefore(j(n),t)}),t.remove();return}J(t)}),e);const ie=e=>{let t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,J(t.body)},oe="data-typeit-id",A="ti-cursor",ge="END",Te={started:!1,completed:!1,frozen:!1,destroyed:!1},x={breakLines:!0,cursor:{autoPause:!0,autoPauseDelay:500,animation:{frames:[0,0,1].map(e=>({opacity:e})),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:()=>{}},Se=`[${oe}]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}`;function ue(e,t=!1,n=!1){let a=e.querySelector(`.${A}`),s=document.createTreeWalker(e,NodeFilter.SHOW_ALL,{acceptNode:d=>{var m,p;if(a&&n){if((m=d.classList)!=null&&m.contains(A))return NodeFilter.FILTER_ACCEPT;if(a.contains(d))return NodeFilter.FILTER_REJECT}return(p=d.classList)!=null&&p.contains(A)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),i,f=[];for(;i=s.nextNode();)i.originalParent||(i.originalParent=i.parentNode),f.push(i);return t?f.reverse():f}function we(e){return ue(ie(e))}function Ee(e,t=!0){return t?we(e):se(e).map(j)}const Q=e=>document.createElement(e),de=(e,t="")=>{let n=Q("style");n.id=t,n.appendChild(j(e)),document.head.appendChild(n)},Z=e=>(le(e)||(e=[e/2,e/2]),e),ee=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));let te=e=>e/2;function Ce(e){let{speed:t,deleteSpeed:n,lifeLike:a}=e;return n=n!==null?n:t/3,a?[ee(t,te(t)),ee(n,te(n))]:[t,n]}const _e=e=>(e.forEach(clearTimeout),[]),Ie=()=>Math.random().toString().substring(2,9),X=e=>"value"in e;let Pe=e=>X(e)?se(e.value):ue(e,!0).filter(t=>!(t.childNodes.length>0));const Ne=(e,t)=>{new IntersectionObserver((a,s)=>{a.forEach(i=>{i.isIntersecting&&(t(),s.unobserve(e))})},{threshold:1}).observe(e)};let v=e=>typeof e=="function"?e():e;const fe=e=>Number.isInteger(e);let G=(e,t=document,n=!1)=>t[`querySelector${n?"All":""}`](e),Ae=e=>/body/i.test(e==null?void 0:e.tagName),Le=(e,t)=>{if(X(e)){e.value=`${e.value}${t.textContent}`;return}t.innerHTML="";let n=Ae(t.originalParent)?e:t.originalParent||e;n.insertBefore(t,G("."+A,n)||null)},De=(e,t,n)=>Math.min(Math.max(t+e,0),n.length);const k=(e,t)=>Object.assign({},e,t),ve=(e,t)=>{if(!e)return;let n=e.parentNode;(n.childNodes.length>1||n.isSameNode(t)?e:n).remove()},xe=(e,t,n)=>{let a=t[n-1],s=G(`.${A}`,e);e=(a==null?void 0:a.parentNode)||e,e.insertBefore(s,a||null)};function ke(e){return typeof e=="string"?G(e):e}const Me=e=>/<(.+)>(.*?)<\/(.+)>/.test(e.outerHTML);let Re=(e,t,n)=>new Promise(a=>{let s=async()=>{await e(),a()};n.push(setTimeout(s,t||0))}),$e={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"",transform:"translateX(-.125em)"},Fe=(e,t)=>{let a=`${`[${oe}='${e}']`} .${A}`,s=getComputedStyle(t),i=Object.entries($e).reduce((f,[d,m])=>`${f} ${d}: var(--ti-cursor-${d}, ${m||s[d]});`,"");de(`${a} { display: inline-block; width: 0; ${i} }`,e)};const H=(e,t)=>new Array(t).fill(e),re=({queueItems:e,selector:t,cursorPosition:n,to:a})=>{if(fe(t))return t*-1;let s=new RegExp(ge,"i").test(a),i=t?[...e].reverse().findIndex(({char:d})=>{let m=d.parentElement,p=m.matches(t);return s&&p?!0:p&&m.firstChild.isSameNode(d)}):-1;i<0&&(i=s?0:e.length-1);let f=s?0:1;return i-n+f};let B=e=>new Promise(t=>{requestAnimationFrame(async()=>{t(await e())})}),ce=e=>e==null?void 0:e.getAnimations().find(t=>t.id===e.dataset.tiAnimationId),ye=({cursor:e,frames:t,options:n})=>{let a=e.animate(t,n);return a.pause(),a.id=e.dataset.tiAnimationId,B(()=>{B(()=>{a.play()})}),a},He=({cursor:e,options:t,cursorOptions:n})=>{if(!e||!n)return;let a=ce(e),s;a&&(t.delay=a.effect.getComputedTiming().delay,s=a.currentTime,a.cancel());let i=ye({cursor:e,frames:n.animation.frames,options:t});return s&&(i.currentTime=s),i},ne=e=>{var t;return(t=e.func)==null?void 0:t.call(null)},Qe=async({index:e,queueItems:t,wait:n,cursor:a,cursorOptions:s})=>{let i=t[e][1],f=[],d=e,m=i,p=()=>m&&!m.delay,_=i.shouldPauseCursor()&&s.autoPause;for(;p();)f.push(m),p()&&d++,m=t[d]?t[d][1]:null;if(f.length)return await B(async()=>{for(let c of f)await ne(c)}),d-1;let S=ce(a),b;return S&&(b={...S.effect.getComputedTiming(),delay:_?s.autoPauseDelay:0}),await n(async()=>{S&&_&&S.cancel(),await B(()=>{ne(i)})},i.delay),await He({cursor:a,options:b,cursorOptions:s}),e},Be=e=>{var t,n,a;if(typeof e=="object"){let s={},{frames:i,options:f}=x.cursor.animation;return s.animation=e.animation||{},s.animation.frames=((t=e.animation)==null?void 0:t.frames)||i,s.animation.options=k(f,((n=e.animation)==null?void 0:n.options)||{}),s.autoPause=(a=e.autoPause)!=null?a:x.cursor.autoPause,s.autoPauseDelay=e.autoPauseDelay||x.cursor.autoPauseDelay,s}return e===!0?x.cursor:e};const qe=function(e,t={}){var Y;let n=async(r,l,u=!1)=>{E.frozen&&await new Promise(y=>{this.unfreeze=()=>{E.frozen=!1,y()}}),u||await o.beforeStep(this),await Re(r,l,U),u||await o.afterStep(this)},a=(r,l)=>Qe({index:r,queueItems:l,wait:n,cursor:N,cursorOptions:o.cursor}),s=r=>ve(r,h),i=()=>X(h),f=(r=0)=>Ce(o)[r],d=()=>Pe(h),m=(r={})=>{let l=r.delay;l&&g.add({delay:l})},p=(r,l)=>(g.add(r),m(l),this),_=()=>F!=null?F:D,S=(r={})=>[{func:()=>R(r)},{func:()=>R(o)}],b=r=>{let l=o.nextStringDelay;g.add([{delay:l[0]},...r,{delay:l[1]}])},c=()=>{if(i())return;let r=Q("span");return r.className=A,O?(r.innerHTML=ie(o.cursorChar).innerHTML,r):(r.style.visibility="hidden",r)},w=async()=>{if(!i()&&N&&h.appendChild(N),O){Fe(V,h),N.dataset.tiAnimationId=V;let{animation:r}=o.cursor,{frames:l,options:u}=r;ye({frames:l,cursor:N,options:{duration:o.cursorSpeed,...u}})}},L=()=>{let r=o.strings.filter(l=>!!l);r.forEach((l,u)=>{if(this.type(l),u+1===r.length)return;let y=o.breakLines?[{func:()=>q(Q("BR")),typeable:!0}]:H({func:$,delay:f(1)},g.getTypeable().length);b(y)})},pe=async r=>{let l=_();l&&await K({value:l});let u=d().map(y=>[Symbol(),{func:$,delay:f(1),deletable:!0,shouldPauseCursor:()=>!0}]);for(let y=0;y<u.length;y++)await a(y,u);g.reset(),g.set(0,{delay:r})},me=r=>{let l=h.innerHTML;return l?(h.innerHTML="",o.startDelete?(h.innerHTML=l,J(h),b(H({func:$,delay:f(1),deletable:!0},d().length)),r):l.replace(/<!--(.+?)-->/g,"").trim().split(/<br(?:\s*?)(?:\/)?>/).concat(r)):r},M=async(r=!0)=>{E.started=!0;let l=u=>{g.done(u,!r)};try{let u=[...g.getQueue()];for(let T=0;T<u.length;T++){let[I,C]=u[T];if(!C.done){if(!C.deletable||C.deletable&&d().length){let P=await a(T,u);Array(P-T).fill(T+1).map((z,W)=>z+W).forEach(z=>{let[W]=u[z];l(W)}),T=P}l(I)}}if(!r)return this;if(E.completed=!0,await o.afterComplete(this),!o.loop)throw"";let y=o.loopDelay;n(async()=>{await pe(y[0]),M()},y[1])}catch{}return this},K=async r=>{D=De(r,D,d()),xe(h,d(),D)},q=r=>Le(h,r),R=async r=>o=k(o,r),he=async()=>{if(i()){h.value="";return}d().forEach(s)},$=()=>{let r=d();!r.length||(i()?h.value=h.value.slice(0,-1):s(r[D]))};this.break=function(r){return p({func:()=>q(Q("BR")),typeable:!0},r)},this.delete=function(r=null,l={}){r=v(r);let u=S(l),y=r,{instant:T,to:I}=l,C=g.getTypeable(),P=(()=>y===null?C.length:fe(y)?y:re({queueItems:C,selector:y,cursorPosition:_(),to:I}))();return p([u[0],...H({func:$,delay:T?0:f(1),deletable:!0},P),u[1]],l)},this.empty=function(r={}){return p({func:he},r)},this.exec=function(r,l={}){let u=S(l);return p([u[0],{func:()=>r(this)},u[1]],l)},this.move=function(r,l={}){r=v(r);let u=S(l),{instant:y,to:T}=l,I=re({queueItems:g.getTypeable(),selector:r===null?"":r,to:T,cursorPosition:_()}),C=I<0?-1:1;return F=_()+I,p([u[0],...H({func:()=>K(C),delay:y?0:f(),cursorable:!0},Math.abs(I)),u[1]],l)},this.options=function(r,l={}){return r=v(r),R(r),p({},l)},this.pause=function(r,l={}){return p({delay:v(r)},l)},this.type=function(r,l={}){r=v(r);let{instant:u}=l,y=S(l),I=Ee(r,o.html).map(P=>({func:()=>q(P),char:P,delay:u||Me(P)?0:f(),typeable:P.nodeType===Node.TEXT_NODE})),C=[y[0],{func:async()=>await o.beforeString(r,this)},...I,{func:async()=>await o.afterString(r,this)},y[1]];return p(C,l)},this.is=function(r){return E[r]},this.destroy=function(r=!0){U=_e(U),v(r)&&N&&s(N),E.destroyed=!0},this.freeze=function(){E.frozen=!0},this.unfreeze=()=>{},this.reset=function(r){!this.is("destroyed")&&this.destroy(),r?(g.wipe(),r(this)):g.reset(),D=0;for(let l in E)E[l]=!1;return h[i()?"value":"innerHTML"]="",this},this.go=function(){return E.started?this:(w(),o.waitUntilVisible?(Ne(h,M.bind(this)),this):(M(),this))},this.flush=function(r=()=>{}){return w(),M(!1).then(r),this},this.getQueue=()=>g,this.getOptions=()=>o,this.updateOptions=r=>R(r),this.getElement=()=>h;let h=ke(e),U=[],D=0,F=null,E=k({},Te);t.cursor=Be((Y=t.cursor)!=null?Y:x.cursor);let o=k(x,t);o=k(o,{html:!i()&&o.html,nextStringDelay:Z(o.nextStringDelay),loopDelay:Z(o.loopDelay)});let V=Ie(),g=be([{delay:o.startDelay}]);h.dataset.typeitId=V,de(Se);let O=!!o.cursor&&!i(),N=c();o.strings=me(ae(o.strings)),o.strings.length&&L()},Ue=Vue.defineComponent({name:"TypeIt",props:{speed:{type:Number,default:200},values:{type:Array,defalut:[]},className:{type:String,default:"type-it"},cursor:{type:Boolean,default:!0}},render(){return Vue.h("span",{class:this.className},{default:()=>[]})},mounted(){new qe(`.${this.className}`,{strings:this.values,speed:this.speed,cursor:this.cursor}).go()}});export{Ue as T};