index-2b1ee5b2-1731319840132.js 1.2 KB

1
  1. import{bT as x,ch as y,bS as F,T as P,b1 as C}from"./index-6198d9d3-1731319840132.js";function g(e){return x()?(y(e),!0):!1}function T(e){return typeof e=="function"?e():C(e)}const R=typeof window<"u",m=()=>{};function D(e,i){function n(...t){return new Promise((o,r)=>{Promise.resolve(e(()=>i.apply(this,t),{fn:i,thisArg:this,args:t})).then(o).catch(r)})}return n}function S(e,i={}){let n,t,o=m;const r=u=>{clearTimeout(u),o(),o=m};return u=>{const a=T(e),s=T(i.maxWait);return n&&r(n),a<=0||s!==void 0&&s<=0?(t&&(r(t),t=null),Promise.resolve(u())):new Promise((l,p)=>{o=i.rejectOnCancel?p:l,s&&!t&&(t=setTimeout(()=>{n&&r(n),t=null,l(u())},s)),n=setTimeout(()=>{t&&r(t),t=null,l(u())},a)})}}function j(e,i=!0,n=!0,t=!1){let o=0,r,c=!0,u=m,a;const s=()=>{r&&(clearTimeout(r),r=void 0,u(),u=m)};return p=>{const f=T(e),w=Date.now()-o,d=()=>a=p();return s(),f<=0?(o=Date.now(),d()):(w>f&&(n||!c)?(o=Date.now(),d()):i&&(a=new Promise((h,b)=>{u=t?b:h,r=setTimeout(()=>{o=Date.now(),c=!0,h(d()),s()},Math.max(0,f-w))})),!n&&!r&&(r=setTimeout(()=>c=!0,f)),c=!1,a)}}function U(e,i=200,n={}){return D(S(i,n),e)}function V(e,i=200,n=!1,t=!0,o=!1){return D(j(i,n,t,o),e)}function W(e){F()&&P(e)}export{V as a,g as b,T as c,R as i,W as t,U as u};