"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.debounce=debounce;var _isObject=require("./isObject");function debounce(i,o,n){var u,a,t,c,f,d,v=0,s=!1,l=!1,e=!0;if("function"!=typeof i)throw new TypeError("Expected a function");function p(n){var e=u,t=a;return u=a=void 0,v=n,c=i.apply(t,e)}function b(n,e){return setTimeout(n,e)}function h(n){var e=n-d;return void 0===d||o<=e||e<0||l&&t<=n-v}function m(){var n,e=Date.now();if(h(e))return r(e);f=b(m,(n=(e=e)-v,e=o-(e-d),l?Math.min(e,t-n):e))}function r(n){return f=void 0,e&&u?p(n):(u=a=void 0,c)}function w(){for(var n=Date.now(),e=h(n),t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];if(u=i,a=this,d=n,e){if(void 0===f)return v=n=d,f=b(m,o),s?p(n):c;if(l)return f=b(m,o),p(d)}return void 0===f&&(f=b(m,o)),c}return o=+o||0,(0,_isObject.isObject)(n)&&(s=!!n.leading,l="maxWait"in n,t=l?Math.max(+n.maxWait||0,o):t,e="trailing"in n?!!n.trailing:e),w.cancel=function(){void 0!==f&&clearTimeout(f),u=d=a=f=void(v=0)},w.flush=function(){return void 0===f?c:r(Date.now())},w.pending=function(){return void 0!==f},w}