mirror of https://github.com/allinssl/allinssl
2 lines
2.2 KiB
JavaScript
2 lines
2.2 KiB
JavaScript
import{bj as t,c4 as e,c5 as n,b$ as i,c6 as a,aQ as o,o as r,V as s,x as u,J as c,r as l,c7 as f,bw as m}from"./main-DxBfl9jt.js";function v(t){return!!a()&&(o(t),!0)}const p="undefined"!=typeof window&&"undefined"!=typeof document;"undefined"!=typeof WorkerGlobalScope&&(globalThis,WorkerGlobalScope);const d=Object.prototype.toString,b=t=>"[object Object]"===d.call(t),w=()=>{};function y(t,e){return function(...n){return new Promise(((i,a)=>{Promise.resolve(t((()=>e.apply(this,n)),{fn:e,thisArg:this,args:n})).then(i).catch(a)}))}}const g=t=>t();function h(t=g,n={}){const{initialState:i="active"}=n,a=function(...t){if(1!==t.length)return c(...t);const n=t[0];return"function"==typeof n?e(f((()=>({get:n,set:w})))):l(n)}("active"===i);return{isActive:e(a),pause:function(){a.value=!1},resume:function(){a.value=!0},eventFilter:(...e)=>{a.value&&t(...e)}}}function j(t){return Array.isArray(t)?t:[t]}function A(t,e=200,a=!1,o=!0,r=!1){return y(function(...t){let e,a,o,r,s,u,c=0,l=!0,f=w;n(t[0])||"object"!=typeof t[0]?[o,r=!0,s=!0,u=!1]=t:({delay:o,trailing:r=!0,leading:s=!0,rejectOnCancel:u=!1}=t[0]);const m=()=>{e&&(clearTimeout(e),e=void 0,f(),f=w)};return t=>{const n=i(o),v=Date.now()-c,p=()=>a=t();return m(),n<=0?(c=Date.now(),p()):(v>n&&(s||!l)?(c=Date.now(),p()):r&&(a=new Promise(((t,i)=>{f=u?i:t,e=setTimeout((()=>{c=Date.now(),l=!0,t(p()),m()}),Math.max(0,n-v))}))),s||e||(e=setTimeout((()=>l=!0),n)),l=!1,a)}}(e,a,o,r),t)}function S(t,e,n={}){const{eventFilter:i,initialState:a="active",...o}=n,{eventFilter:r,pause:s,resume:c,isActive:l}=h(i,{initialState:a}),f=function(t,e,n={}){const{eventFilter:i=g,...a}=n;return u(t,y(i,e),a)}(t,e,{...o,eventFilter:r});return{stop:f,pause:s,resume:c,isActive:l}}function T(t,e=!0,n){m()?r(t,n):e?t():s(t)}function F(n,a,o={}){const{immediate:r=!0,immediateCallback:s=!1}=o,u=t(!1);let c=null;function l(){c&&(clearTimeout(c),c=null)}function f(){u.value=!1,l()}function m(...t){s&&n(),l(),u.value=!0,c=setTimeout((()=>{u.value=!1,c=null,n(...t)}),i(a))}return r&&(u.value=!0,p&&m()),v(f),{isPending:e(u),start:m,stop:f}}function D(t,e,n){return u(t,e,{...n,immediate:!0})}export{A as a,j as b,D as c,v as d,b as e,p as i,T as t,F as u,S as w};
|