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