import{x as S}from"./_Uint8Array-BGESiCQL.js";import{t as M}from"./toNumber-GB_lFVaq.js";import{t as h}from"./now-DIo_1hTm.js";var _="Expected a function",j=Math.max,k=Math.min;function q(g,i,u){var e,f,d,a,r,o,m=0,s=!1,v=!1,l=!0;if(typeof g!="function")throw TypeError(_);i=M(i)||0,S(u)&&(s=!!u.leading,v="maxWait"in u,d=v?j(M(u.maxWait)||0,i):d,l="trailing"in u?!!u.trailing:l);function T(t){var n=e,c=f;return e=f=void 0,m=t,a=g.apply(c,n),a}function W(t){return m=t,r=setTimeout(p,i),s?T(t):a}function b(t){var n=t-o,c=t-m,w=i-n;return v?k(w,d-c):w}function y(t){var n=t-o,c=t-m;return o===void 0||n>=i||n<0||v&&c>=d}function p(){var t=h();if(y(t))return E(t);r=setTimeout(p,b(t))}function E(t){return r=void 0,l&&e?T(t):(e=f=void 0,a)}function C(){r!==void 0&&clearTimeout(r),m=0,e=o=f=r=void 0}function D(){return r===void 0?a:E(h())}function x(){var t=h(),n=y(t);if(e=arguments,f=this,o=t,n){if(r===void 0)return W(o);if(v)return clearTimeout(r),r=setTimeout(p,i),T(o)}return r===void 0&&(r=setTimeout(p,i)),a}return x.cancel=C,x.flush=D,x}var z=q;export{z as t};
