"use strict";
/**
 * Creates a throttled function that only invokes func at most once per
 * every wait milliseconds. The throttled function comes with a cancel
 * method to cancel delayed func invocations and a flush method to
 * immediately invoke them.
 *
 * Supports options: { leading, trailing }
 * Drop-in replacement for lodash/throttle.
 *
 * Implemented using debounce with maxWait (same approach as lodash).
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = throttle;
const tslib_1 = require("tslib");
const debounce_1 = tslib_1.__importDefault(require("./debounce"));
function throttle(func, wait = 0, options) {
    return (0, debounce_1.default)(func, wait, {
        leading: options?.leading ?? true,
        trailing: options?.trailing ?? true,
        maxWait: wait,
    });
}
