const j = Math.min, _ = Math.max, nt = Math.round, et = Math.floor, P = (t) => ({
  x: t,
  y: t
}), Bt = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
}, Nt = {
  start: "end",
  end: "start"
};
function at(t, e, n) {
  return _(t, j(e, n));
}
function Q(t, e) {
  return typeof t == "function" ? t(e) : t;
}
function z(t) {
  return t.split("-")[0];
}
function Z(t) {
  return t.split("-")[1];
}
function Ct(t) {
  return t === "x" ? "y" : "x";
}
function mt(t) {
  return t === "y" ? "height" : "width";
}
const Vt = /* @__PURE__ */ new Set(["top", "bottom"]);
function B(t) {
  return Vt.has(z(t)) ? "y" : "x";
}
function gt(t) {
  return Ct(B(t));
}
function Ht(t, e, n) {
  n === void 0 && (n = !1);
  const o = Z(t), i = gt(t), r = mt(i);
  let s = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
  return e.reference[r] > e.floating[r] && (s = ot(s)), [s, ot(s)];
}
function $t(t) {
  const e = ot(t);
  return [ut(t), e, ut(e)];
}
function ut(t) {
  return t.replace(/start|end/g, (e) => Nt[e]);
}
const xt = ["left", "right"], yt = ["right", "left"], _t = ["top", "bottom"], zt = ["bottom", "top"];
function It(t, e, n) {
  switch (t) {
    case "top":
    case "bottom":
      return n ? e ? yt : xt : e ? xt : yt;
    case "left":
    case "right":
      return e ? _t : zt;
    default:
      return [];
  }
}
function Xt(t, e, n, o) {
  const i = Z(t);
  let r = It(z(t), n === "start", o);
  return i && (r = r.map((s) => s + "-" + i), e && (r = r.concat(r.map(ut)))), r;
}
function ot(t) {
  return t.replace(/left|right|bottom|top/g, (e) => Bt[e]);
}
function jt(t) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...t
  };
}
function St(t) {
  return typeof t != "number" ? jt(t) : {
    top: t,
    right: t,
    bottom: t,
    left: t
  };
}
function it(t) {
  const {
    x: e,
    y: n,
    width: o,
    height: i
  } = t;
  return {
    width: o,
    height: i,
    top: n,
    left: e,
    right: e + o,
    bottom: n + i,
    x: e,
    y: n
  };
}
function vt(t, e, n) {
  let {
    reference: o,
    floating: i
  } = t;
  const r = B(e), s = gt(e), c = mt(s), l = z(e), f = r === "y", d = o.x + o.width / 2 - i.width / 2, u = o.y + o.height / 2 - i.height / 2, m = o[c] / 2 - i[c] / 2;
  let a;
  switch (l) {
    case "top":
      a = {
        x: d,
        y: o.y - i.height
      };
      break;
    case "bottom":
      a = {
        x: d,
        y: o.y + o.height
      };
      break;
    case "right":
      a = {
        x: o.x + o.width,
        y: u
      };
      break;
    case "left":
      a = {
        x: o.x - i.width,
        y: u
      };
      break;
    default:
      a = {
        x: o.x,
        y: o.y
      };
  }
  switch (Z(e)) {
    case "start":
      a[s] -= m * (n && f ? -1 : 1);
      break;
    case "end":
      a[s] += m * (n && f ? -1 : 1);
      break;
  }
  return a;
}
async function Yt(t, e) {
  var n;
  e === void 0 && (e = {});
  const {
    x: o,
    y: i,
    platform: r,
    rects: s,
    elements: c,
    strategy: l
  } = t, {
    boundary: f = "clippingAncestors",
    rootBoundary: d = "viewport",
    elementContext: u = "floating",
    altBoundary: m = !1,
    padding: a = 0
  } = Q(e, t), g = St(a), w = c[m ? u === "floating" ? "reference" : "floating" : u], h = it(await r.getClippingRect({
    element: (n = await (r.isElement == null ? void 0 : r.isElement(w))) == null || n ? w : w.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(c.floating)),
    boundary: f,
    rootBoundary: d,
    strategy: l
  })), x = u === "floating" ? {
    x: o,
    y: i,
    width: s.floating.width,
    height: s.floating.height
  } : s.reference, y = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(c.floating)), v = await (r.isElement == null ? void 0 : r.isElement(y)) ? await (r.getScale == null ? void 0 : r.getScale(y)) || {
    x: 1,
    y: 1
  } : {
    x: 1,
    y: 1
  }, O = it(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
    elements: c,
    rect: x,
    offsetParent: y,
    strategy: l
  }) : x);
  return {
    top: (h.top - O.top + g.top) / v.y,
    bottom: (O.bottom - h.bottom + g.bottom) / v.y,
    left: (h.left - O.left + g.left) / v.x,
    right: (O.right - h.right + g.right) / v.x
  };
}
const qt = async (t, e, n) => {
  const {
    placement: o = "bottom",
    strategy: i = "absolute",
    middleware: r = [],
    platform: s
  } = n, c = r.filter(Boolean), l = await (s.isRTL == null ? void 0 : s.isRTL(e));
  let f = await s.getElementRects({
    reference: t,
    floating: e,
    strategy: i
  }), {
    x: d,
    y: u
  } = vt(f, o, l), m = o, a = {}, g = 0;
  for (let w = 0; w < c.length; w++) {
    var p;
    const {
      name: h,
      fn: x
    } = c[w], {
      x: y,
      y: v,
      data: O,
      reset: b
    } = await x({
      x: d,
      y: u,
      initialPlacement: o,
      placement: m,
      strategy: i,
      middlewareData: a,
      rects: f,
      platform: {
        ...s,
        detectOverflow: (p = s.detectOverflow) != null ? p : Yt
      },
      elements: {
        reference: t,
        floating: e
      }
    });
    d = y != null ? y : d, u = v != null ? v : u, a = {
      ...a,
      [h]: {
        ...a[h],
        ...O
      }
    }, b && g <= 50 && (g++, typeof b == "object" && (b.placement && (m = b.placement), b.rects && (f = b.rects === !0 ? await s.getElementRects({
      reference: t,
      floating: e,
      strategy: i
    }) : b.rects), {
      x: d,
      y: u
    } = vt(f, m, l)), w = -1);
  }
  return {
    x: d,
    y: u,
    placement: m,
    strategy: i,
    middlewareData: a
  };
}, Ut = (t) => ({
  name: "arrow",
  options: t,
  async fn(e) {
    const {
      x: n,
      y: o,
      placement: i,
      rects: r,
      platform: s,
      elements: c,
      middlewareData: l
    } = e, {
      element: f,
      padding: d = 0
    } = Q(t, e) || {};
    if (f == null)
      return {};
    const u = St(d), m = {
      x: n,
      y: o
    }, a = gt(i), g = mt(a), p = await s.getDimensions(f), w = a === "y", h = w ? "top" : "left", x = w ? "bottom" : "right", y = w ? "clientHeight" : "clientWidth", v = r.reference[g] + r.reference[a] - m[a] - r.floating[g], O = m[a] - r.reference[a], b = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(f));
    let C = b ? b[y] : 0;
    (!C || !await (s.isElement == null ? void 0 : s.isElement(b))) && (C = c.floating[y] || r.floating[g]);
    const U = v / 2 - O / 2, V = C / 2 - p[g] / 2 - 1, k = j(u[h], V), K = j(u[x], V), H = k, G = C - p[g] - K, A = C / 2 - p[g] / 2 + U, $ = at(H, A, G), M = !l.arrow && Z(i) != null && A !== $ && r.reference[g] / 2 - (A < H ? k : K) - p[g] / 2 < 0, S = M ? A < H ? A - H : A - G : 0;
    return {
      [a]: m[a] + S,
      data: {
        [a]: $,
        centerOffset: A - $ - S,
        ...M && {
          alignmentOffset: S
        }
      },
      reset: M
    };
  }
}), Kt = function(t) {
  return t === void 0 && (t = {}), {
    name: "flip",
    options: t,
    async fn(e) {
      var n, o;
      const {
        placement: i,
        middlewareData: r,
        rects: s,
        initialPlacement: c,
        platform: l,
        elements: f
      } = e, {
        mainAxis: d = !0,
        crossAxis: u = !0,
        fallbackPlacements: m,
        fallbackStrategy: a = "bestFit",
        fallbackAxisSideDirection: g = "none",
        flipAlignment: p = !0,
        ...w
      } = Q(t, e);
      if ((n = r.arrow) != null && n.alignmentOffset)
        return {};
      const h = z(i), x = B(c), y = z(c) === c, v = await (l.isRTL == null ? void 0 : l.isRTL(f.floating)), O = m || (y || !p ? [ot(c)] : $t(c)), b = g !== "none";
      !m && b && O.push(...Xt(c, p, g, v));
      const C = [c, ...O], U = await l.detectOverflow(e, w), V = [];
      let k = ((o = r.flip) == null ? void 0 : o.overflows) || [];
      if (d && V.push(U[h]), u) {
        const A = Ht(i, s, v);
        V.push(U[A[0]], U[A[1]]);
      }
      if (k = [...k, {
        placement: i,
        overflows: V
      }], !V.every((A) => A <= 0)) {
        var K, H;
        const A = (((K = r.flip) == null ? void 0 : K.index) || 0) + 1, $ = C[A];
        if ($ && (!(u === "alignment" ? x !== B($) : !1) || k.every((L) => B(L.placement) === x ? L.overflows[0] > 0 : !0)))
          return {
            data: {
              index: A,
              overflows: k
            },
            reset: {
              placement: $
            }
          };
        let M = (H = k.filter((S) => S.overflows[0] <= 0).sort((S, L) => S.overflows[1] - L.overflows[1])[0]) == null ? void 0 : H.placement;
        if (!M)
          switch (a) {
            case "bestFit": {
              var G;
              const S = (G = k.filter((L) => {
                if (b) {
                  const W = B(L.placement);
                  return W === x || W === "y";
                }
                return !0;
              }).map((L) => [L.placement, L.overflows.filter((W) => W > 0).reduce((W, Wt) => W + Wt, 0)]).sort((L, W) => L[1] - W[1])[0]) == null ? void 0 : G[0];
              S && (M = S);
              break;
            }
            case "initialPlacement":
              M = c;
              break;
          }
        if (i !== M)
          return {
            reset: {
              placement: M
            }
          };
      }
      return {};
    }
  };
}, Gt = /* @__PURE__ */ new Set(["left", "top"]);
async function Jt(t, e) {
  const {
    placement: n,
    platform: o,
    elements: i
  } = t, r = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), s = z(n), c = Z(n), l = B(n) === "y", f = Gt.has(s) ? -1 : 1, d = r && l ? -1 : 1, u = Q(e, t);
  let {
    mainAxis: m,
    crossAxis: a,
    alignmentAxis: g
  } = typeof u == "number" ? {
    mainAxis: u,
    crossAxis: 0,
    alignmentAxis: null
  } : {
    mainAxis: u.mainAxis || 0,
    crossAxis: u.crossAxis || 0,
    alignmentAxis: u.alignmentAxis
  };
  return c && typeof g == "number" && (a = c === "end" ? g * -1 : g), l ? {
    x: a * d,
    y: m * f
  } : {
    x: m * f,
    y: a * d
  };
}
const Qt = function(t) {
  return t === void 0 && (t = 0), {
    name: "offset",
    options: t,
    async fn(e) {
      var n, o;
      const {
        x: i,
        y: r,
        placement: s,
        middlewareData: c
      } = e, l = await Jt(e, t);
      return s === ((n = c.offset) == null ? void 0 : n.placement) && (o = c.arrow) != null && o.alignmentOffset ? {} : {
        x: i + l.x,
        y: r + l.y,
        data: {
          ...l,
          placement: s
        }
      };
    }
  };
}, Zt = function(t) {
  return t === void 0 && (t = {}), {
    name: "shift",
    options: t,
    async fn(e) {
      const {
        x: n,
        y: o,
        placement: i,
        platform: r
      } = e, {
        mainAxis: s = !0,
        crossAxis: c = !1,
        limiter: l = {
          fn: (h) => {
            let {
              x,
              y
            } = h;
            return {
              x,
              y
            };
          }
        },
        ...f
      } = Q(t, e), d = {
        x: n,
        y: o
      }, u = await r.detectOverflow(e, f), m = B(z(i)), a = Ct(m);
      let g = d[a], p = d[m];
      if (s) {
        const h = a === "y" ? "top" : "left", x = a === "y" ? "bottom" : "right", y = g + u[h], v = g - u[x];
        g = at(y, g, v);
      }
      if (c) {
        const h = m === "y" ? "top" : "left", x = m === "y" ? "bottom" : "right", y = p + u[h], v = p - u[x];
        p = at(y, p, v);
      }
      const w = l.fn({
        ...e,
        [a]: g,
        [m]: p
      });
      return {
        ...w,
        data: {
          x: w.x - n,
          y: w.y - o,
          enabled: {
            [a]: s,
            [m]: c
          }
        }
      };
    }
  };
};
function st() {
  return typeof window < "u";
}
function q(t) {
  return Lt(t) ? (t.nodeName || "").toLowerCase() : "#document";
}
function R(t) {
  var e;
  return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
}
function F(t) {
  var e;
  return (e = (Lt(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
}
function Lt(t) {
  return st() ? t instanceof Node || t instanceof R(t).Node : !1;
}
function E(t) {
  return st() ? t instanceof Element || t instanceof R(t).Element : !1;
}
function D(t) {
  return st() ? t instanceof HTMLElement || t instanceof R(t).HTMLElement : !1;
}
function bt(t) {
  return !st() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof R(t).ShadowRoot;
}
const te = /* @__PURE__ */ new Set(["inline", "contents"]);
function tt(t) {
  const {
    overflow: e,
    overflowX: n,
    overflowY: o,
    display: i
  } = T(t);
  return /auto|scroll|overlay|hidden|clip/.test(e + o + n) && !te.has(i);
}
const ee = /* @__PURE__ */ new Set(["table", "td", "th"]);
function ne(t) {
  return ee.has(q(t));
}
const oe = [":popover-open", ":modal"];
function rt(t) {
  return oe.some((e) => {
    try {
      return t.matches(e);
    } catch {
      return !1;
    }
  });
}
const ie = ["transform", "translate", "scale", "rotate", "perspective"], se = ["transform", "translate", "scale", "rotate", "perspective", "filter"], re = ["paint", "layout", "strict", "content"];
function ht(t) {
  const e = pt(), n = E(t) ? T(t) : t;
  return ie.some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !e && (n.filter ? n.filter !== "none" : !1) || se.some((o) => (n.willChange || "").includes(o)) || re.some((o) => (n.contain || "").includes(o));
}
function ce(t) {
  let e = N(t);
  for (; D(e) && !Y(e); ) {
    if (ht(e))
      return e;
    if (rt(e))
      return null;
    e = N(e);
  }
  return null;
}
function pt() {
  return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const le = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function Y(t) {
  return le.has(q(t));
}
function T(t) {
  return R(t).getComputedStyle(t);
}
function ct(t) {
  return E(t) ? {
    scrollLeft: t.scrollLeft,
    scrollTop: t.scrollTop
  } : {
    scrollLeft: t.scrollX,
    scrollTop: t.scrollY
  };
}
function N(t) {
  if (q(t) === "html")
    return t;
  const e = t.assignedSlot || t.parentNode || bt(t) && t.host || F(t);
  return bt(e) ? e.host : e;
}
function Et(t) {
  const e = N(t);
  return Y(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : D(e) && tt(e) ? e : Et(e);
}
function J(t, e, n) {
  var o;
  e === void 0 && (e = []), n === void 0 && (n = !0);
  const i = Et(t), r = i === ((o = t.ownerDocument) == null ? void 0 : o.body), s = R(i);
  if (r) {
    const c = dt(s);
    return e.concat(s, s.visualViewport || [], tt(i) ? i : [], c && n ? J(c) : []);
  }
  return e.concat(i, J(i, [], n));
}
function dt(t) {
  return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
}
function Tt(t) {
  const e = T(t);
  let n = parseFloat(e.width) || 0, o = parseFloat(e.height) || 0;
  const i = D(t), r = i ? t.offsetWidth : n, s = i ? t.offsetHeight : o, c = nt(n) !== r || nt(o) !== s;
  return c && (n = r, o = s), {
    width: n,
    height: o,
    $: c
  };
}
function wt(t) {
  return E(t) ? t : t.contextElement;
}
function X(t) {
  const e = wt(t);
  if (!D(e))
    return P(1);
  const n = e.getBoundingClientRect(), {
    width: o,
    height: i,
    $: r
  } = Tt(e);
  let s = (r ? nt(n.width) : n.width) / o, c = (r ? nt(n.height) : n.height) / i;
  return (!s || !Number.isFinite(s)) && (s = 1), (!c || !Number.isFinite(c)) && (c = 1), {
    x: s,
    y: c
  };
}
const fe = /* @__PURE__ */ P(0);
function Pt(t) {
  const e = R(t);
  return !pt() || !e.visualViewport ? fe : {
    x: e.visualViewport.offsetLeft,
    y: e.visualViewport.offsetTop
  };
}
function ae(t, e, n) {
  return e === void 0 && (e = !1), !n || e && n !== R(t) ? !1 : e;
}
function I(t, e, n, o) {
  e === void 0 && (e = !1), n === void 0 && (n = !1);
  const i = t.getBoundingClientRect(), r = wt(t);
  let s = P(1);
  e && (o ? E(o) && (s = X(o)) : s = X(t));
  const c = ae(r, n, o) ? Pt(r) : P(0);
  let l = (i.left + c.x) / s.x, f = (i.top + c.y) / s.y, d = i.width / s.x, u = i.height / s.y;
  if (r) {
    const m = R(r), a = o && E(o) ? R(o) : o;
    let g = m, p = dt(g);
    for (; p && o && a !== g; ) {
      const w = X(p), h = p.getBoundingClientRect(), x = T(p), y = h.left + (p.clientLeft + parseFloat(x.paddingLeft)) * w.x, v = h.top + (p.clientTop + parseFloat(x.paddingTop)) * w.y;
      l *= w.x, f *= w.y, d *= w.x, u *= w.y, l += y, f += v, g = R(p), p = dt(g);
    }
  }
  return it({
    width: d,
    height: u,
    x: l,
    y: f
  });
}
function lt(t, e) {
  const n = ct(t).scrollLeft;
  return e ? e.left + n : I(F(t)).left + n;
}
function Dt(t, e) {
  const n = t.getBoundingClientRect(), o = n.left + e.scrollLeft - lt(t, n), i = n.top + e.scrollTop;
  return {
    x: o,
    y: i
  };
}
function ue(t) {
  let {
    elements: e,
    rect: n,
    offsetParent: o,
    strategy: i
  } = t;
  const r = i === "fixed", s = F(o), c = e ? rt(e.floating) : !1;
  if (o === s || c && r)
    return n;
  let l = {
    scrollLeft: 0,
    scrollTop: 0
  }, f = P(1);
  const d = P(0), u = D(o);
  if ((u || !u && !r) && ((q(o) !== "body" || tt(s)) && (l = ct(o)), D(o))) {
    const a = I(o);
    f = X(o), d.x = a.x + o.clientLeft, d.y = a.y + o.clientTop;
  }
  const m = s && !u && !r ? Dt(s, l) : P(0);
  return {
    width: n.width * f.x,
    height: n.height * f.y,
    x: n.x * f.x - l.scrollLeft * f.x + d.x + m.x,
    y: n.y * f.y - l.scrollTop * f.y + d.y + m.y
  };
}
function de(t) {
  return Array.from(t.getClientRects());
}
function me(t) {
  const e = F(t), n = ct(t), o = t.ownerDocument.body, i = _(e.scrollWidth, e.clientWidth, o.scrollWidth, o.clientWidth), r = _(e.scrollHeight, e.clientHeight, o.scrollHeight, o.clientHeight);
  let s = -n.scrollLeft + lt(t);
  const c = -n.scrollTop;
  return T(o).direction === "rtl" && (s += _(e.clientWidth, o.clientWidth) - i), {
    width: i,
    height: r,
    x: s,
    y: c
  };
}
const At = 25;
function ge(t, e) {
  const n = R(t), o = F(t), i = n.visualViewport;
  let r = o.clientWidth, s = o.clientHeight, c = 0, l = 0;
  if (i) {
    r = i.width, s = i.height;
    const d = pt();
    (!d || d && e === "fixed") && (c = i.offsetLeft, l = i.offsetTop);
  }
  const f = lt(o);
  if (f <= 0) {
    const d = o.ownerDocument, u = d.body, m = getComputedStyle(u), a = d.compatMode === "CSS1Compat" && parseFloat(m.marginLeft) + parseFloat(m.marginRight) || 0, g = Math.abs(o.clientWidth - u.clientWidth - a);
    g <= At && (r -= g);
  } else
    f <= At && (r += f);
  return {
    width: r,
    height: s,
    x: c,
    y: l
  };
}
const he = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function pe(t, e) {
  const n = I(t, !0, e === "fixed"), o = n.top + t.clientTop, i = n.left + t.clientLeft, r = D(t) ? X(t) : P(1), s = t.clientWidth * r.x, c = t.clientHeight * r.y, l = i * r.x, f = o * r.y;
  return {
    width: s,
    height: c,
    x: l,
    y: f
  };
}
function Ot(t, e, n) {
  let o;
  if (e === "viewport")
    o = ge(t, n);
  else if (e === "document")
    o = me(F(t));
  else if (E(e))
    o = pe(e, n);
  else {
    const i = Pt(t);
    o = {
      x: e.x - i.x,
      y: e.y - i.y,
      width: e.width,
      height: e.height
    };
  }
  return it(o);
}
function Ft(t, e) {
  const n = N(t);
  return n === e || !E(n) || Y(n) ? !1 : T(n).position === "fixed" || Ft(n, e);
}
function we(t, e) {
  const n = e.get(t);
  if (n)
    return n;
  let o = J(t, [], !1).filter((c) => E(c) && q(c) !== "body"), i = null;
  const r = T(t).position === "fixed";
  let s = r ? N(t) : t;
  for (; E(s) && !Y(s); ) {
    const c = T(s), l = ht(s);
    !l && c.position === "fixed" && (i = null), (r ? !l && !i : !l && c.position === "static" && !!i && he.has(i.position) || tt(s) && !l && Ft(t, s)) ? o = o.filter((d) => d !== s) : i = c, s = N(s);
  }
  return e.set(t, o), o;
}
function xe(t) {
  let {
    element: e,
    boundary: n,
    rootBoundary: o,
    strategy: i
  } = t;
  const s = [...n === "clippingAncestors" ? rt(e) ? [] : we(e, this._c) : [].concat(n), o], c = s[0], l = s.reduce((f, d) => {
    const u = Ot(e, d, i);
    return f.top = _(u.top, f.top), f.right = j(u.right, f.right), f.bottom = j(u.bottom, f.bottom), f.left = _(u.left, f.left), f;
  }, Ot(e, c, i));
  return {
    width: l.right - l.left,
    height: l.bottom - l.top,
    x: l.left,
    y: l.top
  };
}
function ye(t) {
  const {
    width: e,
    height: n
  } = Tt(t);
  return {
    width: e,
    height: n
  };
}
function ve(t, e, n) {
  const o = D(e), i = F(e), r = n === "fixed", s = I(t, !0, r, e);
  let c = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const l = P(0);
  function f() {
    l.x = lt(i);
  }
  if (o || !o && !r)
    if ((q(e) !== "body" || tt(i)) && (c = ct(e)), o) {
      const a = I(e, !0, r, e);
      l.x = a.x + e.clientLeft, l.y = a.y + e.clientTop;
    } else
      i && f();
  r && !o && i && f();
  const d = i && !o && !r ? Dt(i, c) : P(0), u = s.left + c.scrollLeft - l.x - d.x, m = s.top + c.scrollTop - l.y - d.y;
  return {
    x: u,
    y: m,
    width: s.width,
    height: s.height
  };
}
function ft(t) {
  return T(t).position === "static";
}
function Rt(t, e) {
  if (!D(t) || T(t).position === "fixed")
    return null;
  if (e)
    return e(t);
  let n = t.offsetParent;
  return F(t) === n && (n = n.ownerDocument.body), n;
}
function kt(t, e) {
  const n = R(t);
  if (rt(t))
    return n;
  if (!D(t)) {
    let i = N(t);
    for (; i && !Y(i); ) {
      if (E(i) && !ft(i))
        return i;
      i = N(i);
    }
    return n;
  }
  let o = Rt(t, e);
  for (; o && ne(o) && ft(o); )
    o = Rt(o, e);
  return o && Y(o) && ft(o) && !ht(o) ? n : o || ce(t) || n;
}
const be = async function(t) {
  const e = this.getOffsetParent || kt, n = this.getDimensions, o = await n(t.floating);
  return {
    reference: ve(t.reference, await e(t.floating), t.strategy),
    floating: {
      x: 0,
      y: 0,
      width: o.width,
      height: o.height
    }
  };
};
function Ae(t) {
  return T(t).direction === "rtl";
}
const Oe = {
  convertOffsetParentRelativeRectToViewportRelativeRect: ue,
  getDocumentElement: F,
  getClippingRect: xe,
  getOffsetParent: kt,
  getElementRects: be,
  getClientRects: de,
  getDimensions: ye,
  getScale: X,
  isElement: E,
  isRTL: Ae
};
function Mt(t, e) {
  return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height;
}
function Re(t, e) {
  let n = null, o;
  const i = F(t);
  function r() {
    var c;
    clearTimeout(o), (c = n) == null || c.disconnect(), n = null;
  }
  function s(c, l) {
    c === void 0 && (c = !1), l === void 0 && (l = 1), r();
    const f = t.getBoundingClientRect(), {
      left: d,
      top: u,
      width: m,
      height: a
    } = f;
    if (c || e(), !m || !a)
      return;
    const g = et(u), p = et(i.clientWidth - (d + m)), w = et(i.clientHeight - (u + a)), h = et(d), y = {
      rootMargin: -g + "px " + -p + "px " + -w + "px " + -h + "px",
      threshold: _(0, j(1, l)) || 1
    };
    let v = !0;
    function O(b) {
      const C = b[0].intersectionRatio;
      if (C !== l) {
        if (!v)
          return s();
        C ? s(!1, C) : o = setTimeout(() => {
          s(!1, 1e-7);
        }, 1e3);
      }
      C === 1 && !Mt(f, t.getBoundingClientRect()) && s(), v = !1;
    }
    try {
      n = new IntersectionObserver(O, {
        ...y,
        root: i.ownerDocument
      });
    } catch {
      n = new IntersectionObserver(O, y);
    }
    n.observe(t);
  }
  return s(!0), r;
}
function Ce(t, e, n, o) {
  o === void 0 && (o = {});
  const {
    ancestorScroll: i = !0,
    ancestorResize: r = !0,
    elementResize: s = typeof ResizeObserver == "function",
    layoutShift: c = typeof IntersectionObserver == "function",
    animationFrame: l = !1
  } = o, f = wt(t), d = i || r ? [...f ? J(f) : [], ...J(e)] : [];
  d.forEach((h) => {
    i && h.addEventListener("scroll", n, {
      passive: !0
    }), r && h.addEventListener("resize", n);
  });
  const u = f && c ? Re(f, n) : null;
  let m = -1, a = null;
  s && (a = new ResizeObserver((h) => {
    let [x] = h;
    x && x.target === f && a && (a.unobserve(e), cancelAnimationFrame(m), m = requestAnimationFrame(() => {
      var y;
      (y = a) == null || y.observe(e);
    })), n();
  }), f && !l && a.observe(f), a.observe(e));
  let g, p = l ? I(t) : null;
  l && w();
  function w() {
    const h = I(t);
    p && !Mt(p, h) && n(), p = h, g = requestAnimationFrame(w);
  }
  return n(), () => {
    var h;
    d.forEach((x) => {
      i && x.removeEventListener("scroll", n), r && x.removeEventListener("resize", n);
    }), u == null || u(), (h = a) == null || h.disconnect(), a = null, l && cancelAnimationFrame(g);
  };
}
const Se = Qt, Le = Zt, Ee = Kt, Te = Ut, Pe = (t, e, n) => {
  const o = /* @__PURE__ */ new Map(), i = {
    platform: Oe,
    ...n
  }, r = {
    ...i.platform,
    _c: o
  };
  return qt(t, e, {
    ...i,
    platform: r
  });
};
export {
  Ce as a,
  Te as b,
  Pe as c,
  Ee as f,
  Se as o,
  Le as s
};
