import { tryOnMounted as j, toValue as W, noop as I, isObject as K, tryOnScopeDispose as F, pausableWatch as P, notNullish as $, isClient as q } from "../../../../@vueuse_shared@10.9.0_vue@3.4.21/node_modules/@vueuse/shared/index.mjs";
import { bypassFilter as de, createFilterWrapper as pe, debounceFilter as ve, getLifeCycleTarget as me, pausableFilter as we, useDebounceFn as ye, watchWithFilter as he } from "../../../../@vueuse_shared@10.9.0_vue@3.4.21/node_modules/@vueuse/shared/index.mjs";
import { ref as b, watch as _, shallowRef as G, nextTick as Q, computed as R, getCurrentInstance as U, onMounted as X } from "vue";
function S(e) {
  var n;
  const t = W(e);
  return (n = t == null ? void 0 : t.$el) != null ? n : t;
}
const O = q ? window : void 0;
function z(...e) {
  let n, t, i, m;
  if (typeof e[0] == "string" || Array.isArray(e[0]) ? ([t, i, m] = e, n = O) : [n, t, i, m] = e, !n)
    return I;
  Array.isArray(t) || (t = [t]), Array.isArray(i) || (i = [i]);
  const s = [], d = () => {
    s.forEach((a) => a()), s.length = 0;
  }, v = (a, o, u, l) => (a.addEventListener(o, u, l), () => a.removeEventListener(o, u, l)), h = _(
    () => [S(n), W(m)],
    ([a, o]) => {
      if (d(), !a)
        return;
      const u = K(o) ? { ...o } : o;
      s.push(
        ...t.flatMap((l) => i.map((w) => v(a, l, w, u)))
      );
    },
    { immediate: !0, flush: "post" }
  ), p = () => {
    h(), d();
  };
  return F(p), p;
}
function Y() {
  const e = b(!1), n = U();
  return n && X(() => {
    e.value = !0;
  }, n), e;
}
function x(e) {
  const n = Y();
  return R(() => (n.value, !!e()));
}
const M = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, N = "__vueuse_ssr_handlers__", Z = /* @__PURE__ */ k();
function k() {
  return N in M || (M[N] = M[N] || {}), M[N];
}
function ee(e, n) {
  return Z[e] || n;
}
function te(e) {
  return e == null ? "any" : e instanceof Set ? "set" : e instanceof Map ? "map" : e instanceof Date ? "date" : typeof e == "boolean" ? "boolean" : typeof e == "string" ? "string" : typeof e == "object" ? "object" : Number.isNaN(e) ? "any" : "number";
}
const re = {
  boolean: {
    read: (e) => e === "true",
    write: (e) => String(e)
  },
  object: {
    read: (e) => JSON.parse(e),
    write: (e) => JSON.stringify(e)
  },
  number: {
    read: (e) => Number.parseFloat(e),
    write: (e) => String(e)
  },
  any: {
    read: (e) => e,
    write: (e) => String(e)
  },
  string: {
    read: (e) => e,
    write: (e) => String(e)
  },
  map: {
    read: (e) => new Map(JSON.parse(e)),
    write: (e) => JSON.stringify(Array.from(e.entries()))
  },
  set: {
    read: (e) => new Set(JSON.parse(e)),
    write: (e) => JSON.stringify(Array.from(e))
  },
  date: {
    read: (e) => new Date(e),
    write: (e) => e.toISOString()
  }
}, T = "vueuse-storage";
function ne(e, n, t, i = {}) {
  var m;
  const {
    flush: s = "pre",
    deep: d = !0,
    listenToStorageChanges: v = !0,
    writeDefaults: h = !0,
    mergeDefaults: p = !1,
    shallow: a,
    window: o = O,
    eventFilter: u,
    onError: l = (r) => {
      console.error(r);
    },
    initOnMounted: w
  } = i, y = (a ? G : b)(typeof n == "function" ? n() : n);
  if (!t)
    try {
      t = ee("getDefaultStorage", () => {
        var r;
        return (r = O) == null ? void 0 : r.localStorage;
      })();
    } catch (r) {
      l(r);
    }
  if (!t)
    return y;
  const c = W(n), C = te(c), A = (m = i.serializer) != null ? m : re[C], { pause: L, resume: D } = P(
    y,
    () => V(y.value),
    { flush: s, deep: d, eventFilter: u }
  );
  o && v && j(() => {
    z(o, "storage", E), z(o, T, H), w && E();
  }), w || E();
  function J(r, f) {
    o && o.dispatchEvent(new CustomEvent(T, {
      detail: {
        key: e,
        oldValue: r,
        newValue: f,
        storageArea: t
      }
    }));
  }
  function V(r) {
    try {
      const f = t.getItem(e);
      if (r == null)
        J(f, null), t.removeItem(e);
      else {
        const g = A.write(r);
        f !== g && (t.setItem(e, g), J(f, g));
      }
    } catch (f) {
      l(f);
    }
  }
  function B(r) {
    const f = r ? r.newValue : t.getItem(e);
    if (f == null)
      return h && c != null && t.setItem(e, A.write(c)), c;
    if (!r && p) {
      const g = A.read(f);
      return typeof p == "function" ? p(g, c) : C === "object" && !Array.isArray(g) ? { ...c, ...g } : g;
    } else
      return typeof f != "string" ? f : A.read(f);
  }
  function E(r) {
    if (!(r && r.storageArea !== t)) {
      if (r && r.key == null) {
        y.value = c;
        return;
      }
      if (!(r && r.key !== e)) {
        L();
        try {
          (r == null ? void 0 : r.newValue) !== A.write(y.value) && (y.value = B(r));
        } catch (f) {
          l(f);
        } finally {
          r ? Q(D) : D();
        }
      }
    }
  }
  function H(r) {
    E(r.detail);
  }
  return y;
}
function oe(e, n, t = {}) {
  const { window: i = O, ...m } = t;
  let s;
  const d = x(() => i && "MutationObserver" in i), v = () => {
    s && (s.disconnect(), s = void 0);
  }, h = R(() => {
    const u = W(e), l = (Array.isArray(u) ? u : [u]).map(S).filter($);
    return new Set(l);
  }), p = _(
    () => h.value,
    (u) => {
      v(), d.value && i && u.size && (s = new MutationObserver(n), u.forEach((l) => s.observe(l, m)));
    },
    { immediate: !0, flush: "post" }
  ), a = () => s == null ? void 0 : s.takeRecords(), o = () => {
    v(), p();
  };
  return F(o), {
    isSupported: d,
    stop: o,
    takeRecords: a
  };
}
function ie(e, n, t = {}) {
  const { window: i = O, ...m } = t;
  let s;
  const d = x(() => i && "ResizeObserver" in i), v = () => {
    s && (s.disconnect(), s = void 0);
  }, h = R(() => Array.isArray(e) ? e.map((o) => S(o)) : [S(e)]), p = _(
    h,
    (o) => {
      if (v(), d.value && i) {
        s = new ResizeObserver(n);
        for (const u of o)
          u && s.observe(u, m);
      }
    },
    { immediate: !0, flush: "post" }
  ), a = () => {
    v(), p();
  };
  return F(a), {
    isSupported: d,
    stop: a
  };
}
function ae(e, n = {}) {
  const {
    reset: t = !0,
    windowResize: i = !0,
    windowScroll: m = !0,
    immediate: s = !0
  } = n, d = b(0), v = b(0), h = b(0), p = b(0), a = b(0), o = b(0), u = b(0), l = b(0);
  function w() {
    const y = S(e);
    if (!y) {
      t && (d.value = 0, v.value = 0, h.value = 0, p.value = 0, a.value = 0, o.value = 0, u.value = 0, l.value = 0);
      return;
    }
    const c = y.getBoundingClientRect();
    d.value = c.height, v.value = c.bottom, h.value = c.left, p.value = c.right, a.value = c.top, o.value = c.width, u.value = c.x, l.value = c.y;
  }
  return ie(e, w), _(() => S(e), (y) => !y && w()), oe(e, w, {
    attributeFilter: ["style", "class"]
  }), m && z("scroll", w, { capture: !0, passive: !0 }), i && z("resize", w, { passive: !0 }), j(() => {
    s && w();
  }), {
    height: d,
    bottom: v,
    left: h,
    right: p,
    top: a,
    width: o,
    x: u,
    y: l,
    update: w
  };
}
function le(e, n, t = {}) {
  const { window: i = O } = t;
  return ne(e, n, i == null ? void 0 : i.localStorage, t);
}
export {
  re as StorageSerializers,
  de as bypassFilter,
  pe as createFilterWrapper,
  T as customStorageEventName,
  ve as debounceFilter,
  O as defaultWindow,
  me as getLifeCycleTarget,
  ee as getSSRHandler,
  q as isClient,
  K as isObject,
  I as noop,
  $ as notNullish,
  we as pausableFilter,
  P as pausableWatch,
  W as toValue,
  j as tryOnMounted,
  F as tryOnScopeDispose,
  S as unrefElement,
  ye as useDebounceFn,
  ae as useElementBounding,
  z as useEventListener,
  le as useLocalStorage,
  Y as useMounted,
  oe as useMutationObserver,
  ie as useResizeObserver,
  ne as useStorage,
  x as useSupported,
  P as watchPausable,
  he as watchWithFilter
};
