{"version":3,"file":"throttle-debounce-aea961cb.js","sources":["../../node_modules/throttle-debounce/esm/index.js"],"sourcesContent":["/* eslint-disable no-undefined,no-param-reassign,no-shadow */\n\n/**\n * Throttle execution of a function. Especially useful for rate limiting\n * execution of handlers on events like resize and scroll.\n *\n * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.\n * @param {boolean} [noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the\n * throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time\n * after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,\n * the internal counter is reset).\n * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,\n * to `callback` when the throttled-function is executed.\n * @param {boolean} [debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),\n * schedule `callback` to execute after `delay` ms.\n *\n * @returns {Function} A new, throttled, function.\n */\nfunction throttle (delay, noTrailing, callback, debounceMode) {\n /*\n * After wrapper has stopped being called, this timeout ensures that\n * `callback` is executed at the proper times in `throttle` and `end`\n * debounce modes.\n */\n var timeoutID;\n var cancelled = false; // Keep track of the last time `callback` was executed.\n\n var lastExec = 0; // Function to clear existing timeout\n\n function clearExistingTimeout() {\n if (timeoutID) {\n clearTimeout(timeoutID);\n }\n } // Function to cancel next exec\n\n\n function cancel() {\n clearExistingTimeout();\n cancelled = true;\n } // `noTrailing` defaults to falsy.\n\n\n if (typeof noTrailing !== 'boolean') {\n debounceMode = callback;\n callback = noTrailing;\n noTrailing = undefined;\n }\n /*\n * The `wrapper` function encapsulates all of the throttling / debouncing\n * functionality and when executed will limit the rate at which `callback`\n * is executed.\n */\n\n\n function wrapper() {\n for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) {\n arguments_[_key] = arguments[_key];\n }\n\n var self = this;\n var elapsed = Date.now() - lastExec;\n\n if (cancelled) {\n return;\n } // Execute `callback` and update the `lastExec` timestamp.\n\n\n function exec() {\n lastExec = Date.now();\n callback.apply(self, arguments_);\n }\n /*\n * If `debounceMode` is true (at begin) this is used to clear the flag\n * to allow future `callback` executions.\n */\n\n\n function clear() {\n timeoutID = undefined;\n }\n\n if (debounceMode && !timeoutID) {\n /*\n * Since `wrapper` is being called for the first time and\n * `debounceMode` is true (at begin), execute `callback`.\n */\n exec();\n }\n\n clearExistingTimeout();\n\n if (debounceMode === undefined && elapsed > delay) {\n /*\n * In throttle mode, if `delay` time has been exceeded, execute\n * `callback`.\n */\n exec();\n } else if (noTrailing !== true) {\n /*\n * In trailing throttle mode, since `delay` time has not been\n * exceeded, schedule `callback` to execute `delay` ms after most\n * recent execution.\n *\n * If `debounceMode` is true (at begin), schedule `clear` to execute\n * after `delay` ms.\n *\n * If `debounceMode` is false (at end), schedule `callback` to\n * execute after `delay` ms.\n */\n timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);\n }\n }\n\n wrapper.cancel = cancel; // Return the wrapper function.\n\n return wrapper;\n}\n\n/* eslint-disable no-undefined */\n/**\n * Debounce execution of a function. Debouncing, unlike throttling,\n * guarantees that a function is only executed a single time, either at the\n * very beginning of a series of calls, or at the very end.\n *\n * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.\n * @param {boolean} [atBegin] - Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds\n * after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.\n * (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).\n * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,\n * to `callback` when the debounced-function is executed.\n *\n * @returns {Function} A new, debounced function.\n */\n\nfunction debounce (delay, atBegin, callback) {\n return callback === undefined ? throttle(delay, atBegin, false) : throttle(delay, callback, atBegin !== false);\n}\n\nexport { debounce, throttle };\n//# sourceMappingURL=index.js.map\n"],"names":["throttle","delay","noTrailing","callback","debounceMode","timeoutID","cancelled","lastExec","clearExistingTimeout","cancel","wrapper","_len","arguments_","_key","self","elapsed","exec","clear","debounce","atBegin"],"mappings":"AAkBA,SAASA,EAAUC,EAAOC,EAAYC,EAAUC,EAAc,CAM5D,IAAIC,EACAC,EAAY,GAEZC,EAAW,EAEf,SAASC,GAAuB,CAC1BH,GACF,aAAaA,CAAS,CAEzB,CAGD,SAASI,GAAS,CAChBD,IACAF,EAAY,EACb,CAGG,OAAOJ,GAAe,YACxBE,EAAeD,EACfA,EAAWD,EACXA,EAAa,QASf,SAASQ,GAAU,CACjB,QAASC,EAAO,UAAU,OAAQC,EAAa,IAAI,MAAMD,CAAI,EAAGE,EAAO,EAAGA,EAAOF,EAAME,IACrFD,EAAWC,CAAI,EAAI,UAAUA,CAAI,EAGnC,IAAIC,EAAO,KACPC,EAAU,KAAK,IAAG,EAAKR,EAE3B,GAAID,EACF,OAIF,SAASU,GAAO,CACdT,EAAW,KAAK,MAChBJ,EAAS,MAAMW,EAAMF,CAAU,CAChC,CAOD,SAASK,GAAQ,CACfZ,EAAY,MACb,CAEGD,GAAgB,CAACC,GAKnBW,IAGFR,IAEIJ,IAAiB,QAAaW,EAAUd,EAK1Ce,IACSd,IAAe,KAYxBG,EAAY,WAAWD,EAAea,EAAQD,EAAMZ,IAAiB,OAAYH,EAAQc,EAAUd,CAAK,EAE3G,CAED,OAAAS,EAAQ,OAASD,EAEVC,CACT,CAkBA,SAASQ,EAAUjB,EAAOkB,EAAShB,EAAU,CAC3C,OAAOA,IAAa,OAAYH,EAASC,EAAOkB,EAAS,EAAK,EAAInB,EAASC,EAAOE,EAAUgB,IAAY,EAAK,CAC/G","x_google_ignoreList":[0]}