import { getCurrentScope as y, onScopeDispose as j, unref as O, isRef as S, onMounted as x, nextTick as D, getCurrentInstance as P } from "vue";
function _(e) {
  return y() ? (j(e), !0) : !1;
}
function p(e) {
  return typeof e == "function" ? e() : O(e);
}
const C = typeof window < "u" && typeof document < "u";
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
const R = (e) => e != null, F = Object.prototype.toString, k = (e) => F.call(e) === "[object Object]", d = () => {
}, G = /* @__PURE__ */ N();
function N() {
  var e, o;
  return C && ((e = window == null ? void 0 : window.navigator) == null ? void 0 : e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((o = window == null ? void 0 : window.navigator) == null ? void 0 : o.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? void 0 : window.navigator.userAgent));
}
function v(e, o) {
  function t(...n) {
    return new Promise((i, r) => {
      Promise.resolve(e(() => o.apply(this, n), { fn: o, thisArg: this, args: n })).then(i).catch(r);
    });
  }
  return t;
}
function W(e, o = {}) {
  let t, n, i = d;
  const r = (u) => {
    clearTimeout(u), i(), i = d;
  };
  return (u) => {
    const c = p(e), l = p(o.maxWait);
    return t && r(t), c <= 0 || l !== void 0 && l <= 0 ? (n && (r(n), n = null), Promise.resolve(u())) : new Promise((s, w) => {
      i = o.rejectOnCancel ? w : s, l && !n && (n = setTimeout(() => {
        t && r(t), n = null, s(u());
      }, l)), t = setTimeout(() => {
        n && r(n), n = null, s(u());
      }, c);
    });
  };
}
function A(...e) {
  let o = 0, t, n = !0, i = d, r, a, u, c, l;
  !S(e[0]) && typeof e[0] == "object" ? { delay: a, trailing: u = !0, leading: c = !0, rejectOnCancel: l = !1 } = e[0] : [a, u = !0, c = !0, l = !1] = e;
  const s = () => {
    t && (clearTimeout(t), t = void 0, i(), i = d);
  };
  return (T) => {
    const f = p(a), h = Date.now() - o, m = () => r = T();
    return s(), f <= 0 ? (o = Date.now(), m()) : (h > f && (c || !n) ? (o = Date.now(), m()) : u && (r = new Promise((b, g) => {
      i = l ? g : b, t = setTimeout(() => {
        o = Date.now(), n = !0, b(m()), s();
      }, Math.max(0, f - h));
    })), !c && !t && (t = setTimeout(() => n = !0, f)), n = !1, r);
  };
}
function L(e, o) {
  var t;
  if (typeof e == "number")
    return e + o;
  const n = ((t = e.match(/^-?\d+\.?\d*/)) == null ? void 0 : t[0]) || "", i = e.slice(n.length), r = Number.parseFloat(n) + o;
  return Number.isNaN(r) ? e : r + i;
}
function I(e) {
  return e || P();
}
function V(e, o = 200, t = {}) {
  return v(
    W(o, t),
    e
  );
}
function E(e, o = 200, t = !1, n = !0, i = !1) {
  return v(
    A(o, t, n, i),
    e
  );
}
function U(e, o = !0, t) {
  I() ? x(e, t) : o ? e() : D(e);
}
export {
  v as createFilterWrapper,
  W as debounceFilter,
  I as getLifeCycleTarget,
  L as increaseWithUnit,
  C as isClient,
  G as isIOS,
  k as isObject,
  d as noop,
  R as notNullish,
  A as throttleFilter,
  p as toValue,
  U as tryOnMounted,
  _ as tryOnScopeDispose,
  V as useDebounceFn,
  E as useThrottleFn
};
