import{aj as d,ak as b,al as h,m as y}from"./CxCfq515.js";function p(e){return b()?(h(e),!0):!1}function P(){const e=new Set,t=r=>{e.delete(r)};return{on:r=>{e.add(r);const i=()=>t(r);return p(i),{off:i}},off:t,trigger:(...r)=>Promise.all(Array.from(e).map(i=>i(...r)))}}function T(e){let t=0,o,n;const r=()=>{t-=1,n&&t<=0&&(n.stop(),o=void 0,n=void 0)};return(...i)=>(t+=1,o||(n=d(!0),o=n.run(()=>e(...i))),p(r),o)}function l(e){return typeof e=="function"?e():y(e)}const v=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const x=e=>e!=null,S=Object.prototype.toString,C=e=>S.call(e)==="[object Object]",f=()=>{},D=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function w(e,t){function o(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return o}function g(e,t={}){let o,n,r=f;const i=s=>{clearTimeout(s),r(),r=f};return s=>{const u=l(e),c=l(t.maxWait);return o&&i(o),u<=0||c!==void 0&&c<=0?(n&&(i(n),n=null),Promise.resolve(s())):new Promise((a,m)=>{r=t.rejectOnCancel?m:a,c&&!n&&(n=setTimeout(()=>{o&&i(o),n=null,a(s())},c)),o=setTimeout(()=>{n&&i(n),n=null,a(s())},u)})}}function F(e){let t;function o(){return t||(t=e()),t}return o.reset=async()=>{const n=t;t=void 0,n&&await n},o}function W(e,t=200,o={}){return w(g(t,o),e)}export{C as a,p as b,T as c,x as d,P as e,F as f,D as h,v as i,f as n,l as t,W as u};
