import { a as _e, i as Vt, r as ze, x as U } from "../chunks/lit-element.jLBm65_O.js";
import { n as y, C as Be } from "../chunks/lib-cortex-element.CVMmyPMC.js";
import { r as Me } from "../chunks/state.CSDxrqLd.js";
import { e as Ct } from "../chunks/query.BBf1UFkC.js";
import { e as He } from "../chunks/base.D76d76ww.js";
import { e as ht } from "../chunks/class-map.BiVq-cVR.js";
import { o as Lt } from "../chunks/if-defined.BRoBj_Rp.js";
import { o as se } from "../chunks/style-map.llVFPd__.js";
import { i as gt, p as ne, f as Ie, a as We } from "../chunks/browser.BHOCIF_A.js";
import { c as ye } from "../chunks/component.styles.CRO4Odto.js";
import { c as qe } from "../chunks/custom-element.L4WJXn1j.js";
import { d as Ve } from "../chunks/debounce.DaHuiSGU.js";
import { L as je } from "../chunks/i18n.BABe9hN4.js";
import { n as Ue } from "../chunks/when.Dr1es41R.js";
/**
 * @license
 * Copyright 2021 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
function Ye(e) {
  return (t, o) => {
    const { slot: i, selector: s } = e ?? {}, r = "slot" + (i ? `[name=${i}]` : ":not([name])");
    return He(t, o, { get() {
      const n = this.renderRoot?.querySelector(r), a = n?.assignedElements(e) ?? [];
      return s === void 0 ? a : a.filter((l) => l.matches(s));
    } });
  };
}
const re = /* @__PURE__ */ new Set(), Ke = (e) => e?.startManagingContentDirection !== void 0 || e?.tagName === "SP-THEME";
function Xe(e) {
  class t extends e {
    /**
     * @private
     */
    get isLTR() {
      return this.dir === "ltr";
    }
    hasVisibleFocusInTree() {
      const s = ((r = document) => {
        let n = r.activeElement;
        for (; n?.shadowRoot && n.shadowRoot.activeElement; )
          n = n.shadowRoot.activeElement;
        const a = n ? [n] : [];
        for (; n; ) {
          const l = n.assignedSlot || n.parentElement || n.getRootNode()?.host;
          l && a.push(l), n = l;
        }
        return a;
      })(this.getRootNode())[0];
      if (!s)
        return !1;
      try {
        return s.matches(":focus-visible") || s.matches(".focus-visible");
      } catch {
        return s.matches(".focus-visible");
      }
    }
    connectedCallback() {
      if (!this.hasAttribute("dir")) {
        let i = this.assignedSlot || this.parentNode;
        for (; i && i !== document.documentElement && !Ke(i); )
          i = i.assignedSlot || // step into the shadow DOM of the parent of a slotted node
          i.parentNode || // DOM Element detected
          i.host;
        if (this.dir = i?.dir === "rtl" ? i.dir : this.dir || "ltr", i === document.documentElement)
          re.add(this);
        else if (i) {
          const { localName: s } = i;
          s.search("-") > -1 && !customElements.get(s) ? customElements.whenDefined(s).then(() => {
            i.startManagingContentDirection(this);
          }) : i.startManagingContentDirection(this);
        }
        this._dirParent = i;
      }
      super.connectedCallback();
    }
    disconnectedCallback() {
      super.disconnectedCallback(), this._dirParent && (this._dirParent === document.documentElement ? re.delete(this) : this._dirParent.stopManagingContentDirection(this), this.removeAttribute("dir"));
    }
  }
  return t;
}
class Ge extends Xe(_e) {
}
function Je(e, t, o) {
  const i = e.getAttribute(t);
  let s = i ? i.split(/\s+/) : [];
  s = s.filter(
    (r) => !o.find((n) => r === n)
  ), s.length ? e.setAttribute(t, s.join(" ")) : e.removeAttribute(t);
}
function Nt(e, t, o) {
  const i = Array.isArray(o) ? o : [o], s = e.getAttribute(t), r = s ? s.split(/\s+/) : [];
  return i.every((a) => r.indexOf(a) > -1) ? () => {
  } : (r.push(...i), e.setAttribute(t, r.join(" ")), () => Je(e, t, i));
}
function Qe(e, t) {
  customElements.get(e) || customElements.define(e, t);
}
function Ze(e, t, o = []) {
  for (let i = 0; i < t.length; ++i) {
    const s = t[i], r = e[i], n = r.parentElement || r.getRootNode();
    o[i] && o[i](s), n && n !== r && n.replaceChild(s, r), delete e[i];
  }
  return t;
}
const ti = (e, t, {
  position: o,
  prepareCallback: i
} = { position: "beforeend" }) => {
  let { length: s } = e;
  if (s === 0)
    return () => e;
  let r = 1, n = 0;
  (o === "afterbegin" || o === "afterend") && (r = -1, n = s - 1);
  const a = new Array(s), l = new Array(s), c = document.createComment(
    "placeholder for reparented element"
  );
  do {
    const h = e[n];
    i && (l[n] = i(h)), a[n] = c.cloneNode();
    const d = h.parentElement || h.getRootNode();
    d && d !== h && d.replaceChild(a[n], h), t.insertAdjacentElement(o, h), n += r;
  } while (--s > 0);
  return function() {
    return Ze(a, e, l);
  };
};
function jt() {
  return Array.from(
    crypto.getRandomValues(new Uint8Array(4)),
    (e) => `0${(e & 255).toString(16)}`.slice(-2)
  ).join("");
}
const ei = [
  "button",
  "[focusable]",
  "[href]",
  "input",
  "label",
  "select",
  "textarea",
  "[tabindex]"
], ae = ':not([tabindex="-1"])', ft = ei.join(`${ae}, `) + ae, Ut = (e) => e.querySelector(
  ft
), Yt = (e) => e.assignedElements().find(
  (o) => o.matches(ft)
);
function ii(e) {
  return typeof window < "u" && window.navigator != null ? e.test(window.navigator.userAgent) : !1;
}
function Kt(e) {
  return typeof window < "u" && window.navigator != null ? e.test(window.navigator.platform) : !1;
}
function oi() {
  return Kt(/^Mac/);
}
function si() {
  return Kt(/^iPhone/);
}
function ni() {
  return Kt(/^iPad/) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
  oi() && navigator.maxTouchPoints > 1;
}
function ri() {
  return si() || ni();
}
function ai() {
  return ii(/Android/);
}
const li = 1e3, ci = 1e3;
class hi {
  constructor(t = {}) {
    this.warmUpDelay = li, this.coolDownDelay = ci, this.isWarm = !1, this.timeout = 0, Object.assign(this, t);
  }
  async openTimer(t) {
    if (this.cancelCooldownTimer(), !this.component || t !== this.component)
      return this.component && (this.close(this.component), this.cancelCooldownTimer()), this.component = t, this.isWarm ? !1 : (this.promise = new Promise((o) => {
        this.resolve = o, this.timeout = window.setTimeout(() => {
          this.resolve && (this.resolve(!1), this.isWarm = !0);
        }, this.warmUpDelay);
      }), this.promise);
    if (this.promise)
      return this.promise;
    throw new Error("Inconsistent state");
  }
  close(t) {
    this.component && this.component === t && (this.resetCooldownTimer(), this.timeout > 0 && (clearTimeout(this.timeout), this.timeout = 0), this.resolve && (this.resolve(!0), delete this.resolve), delete this.promise, delete this.component);
  }
  resetCooldownTimer() {
    this.isWarm && (this.cooldownTimeout && window.clearTimeout(this.cooldownTimeout), this.cooldownTimeout = window.setTimeout(() => {
      this.isWarm = !1, delete this.cooldownTimeout;
    }, this.coolDownDelay));
  }
  cancelCooldownTimer() {
    this.cooldownTimeout && window.clearTimeout(this.cooldownTimeout), delete this.cooldownTimeout;
  }
}
const wt = new hi(), it = () => {
}, Xt = (e, t, o) => {
  const i = new AbortController(), s = /* @__PURE__ */ new Map(), r = () => {
    i.abort(), o();
  };
  let n, a;
  const l = requestAnimationFrame(() => {
    n = requestAnimationFrame(() => {
      a = requestAnimationFrame(() => {
        r();
      });
    });
  }), c = (d) => {
    d.target === e && (s.set(
      d.propertyName,
      s.get(d.propertyName) - 1
    ), s.get(d.propertyName) || s.delete(d.propertyName), s.size === 0 && r());
  }, h = (d) => {
    d.target === e && (s.has(d.propertyName) || s.set(d.propertyName, 0), s.set(
      d.propertyName,
      s.get(d.propertyName) + 1
    ), cancelAnimationFrame(l), cancelAnimationFrame(n), cancelAnimationFrame(a));
  };
  e.addEventListener("transitionrun", h, {
    signal: i.signal
  }), e.addEventListener("transitionend", c, {
    signal: i.signal
  }), e.addEventListener("transitioncancel", c, {
    signal: i.signal
  }), t();
};
function k() {
  return new Promise((e) => requestAnimationFrame(() => e()));
}
class dt extends Ge {
  constructor() {
    super(...arguments), this.dispose = it, this.offset = 0, this.willPreventClose = !1;
  }
  async applyFocus(t, o) {
  }
  /* c8 ignore next 6 */
  get delayed() {
    return !1;
  }
  set delayed(t) {
  }
  /* c8 ignore next 6 */
  get disabled() {
    return !1;
  }
  set disabled(t) {
  }
  get elementResolver() {
    return this._elementResolver;
  }
  set elementResolver(t) {
    this._elementResolver = t;
  }
  /* c8 ignore next 3 */
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  async ensureOnDOM(t) {
  }
  /* c8 ignore next 5 */
  async makeTransition(t) {
    return null;
  }
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  async manageDelay(t) {
  }
  /* c8 ignore next 3 */
  async manageDialogOpen() {
  }
  /* c8 ignore next 3 */
  async managePopoverOpen() {
  }
  /* c8 ignore next 3 */
  managePosition() {
  }
  /* c8 ignore next 6 */
  get open() {
    return !1;
  }
  set open(t) {
  }
  get placementController() {
    return this._placementController;
  }
  set placementController(t) {
    this._placementController = t;
  }
  requestSlottable() {
  }
  returnFocus() {
  }
  /* c8 ignore next 6 */
  get state() {
    return "closed";
  }
  set state(t) {
  }
  /* c8 ignore next 3 */
  manuallyKeepOpen() {
  }
  static update() {
    const t = new CustomEvent("cx-update-overlays", {
      bubbles: !0,
      cancelable: !0,
      composed: !0
    });
    document.dispatchEvent(t);
  }
  static async open(t, o, i, s) {
    await Promise.resolve().then(() => Fe);
    const r = arguments.length === 2, n = i || t, a = new this();
    let l = !1;
    a.dispose = () => {
      a.addEventListener("cx-closed", () => {
        l || (c(), l = !0), requestAnimationFrame(() => {
          a.remove();
        });
      }), a.open = !1, a.dispose = it;
    };
    const c = ti([n], a, {
      position: "beforeend",
      prepareCallback: (u) => {
        const p = u.slot;
        return u.removeAttribute("slot"), () => {
          u.slot = p;
        };
      }
    });
    if (!r && n && s) {
      const u = t, p = o, f = s;
      return dt.applyOptions(a, {
        ...f,
        delayed: f.delayed || n.hasAttribute("delayed"),
        trigger: f.virtualTrigger || u,
        type: p === "modal" ? "modal" : p === "hover" ? "hint" : "auto"
      }), u.insertAdjacentElement("afterend", a), await a.updateComplete, a.open = !0, a.dispose;
    }
    const d = o;
    return a.append(n), dt.applyOptions(a, {
      ...d,
      delayed: d.delayed || n.hasAttribute("delayed")
    }), a.updateComplete.then(() => {
      a.open = !0;
    }), a;
  }
  static applyOptions(t, o) {
    t.delayed = !!o.delayed, t.receivesFocus = o.receivesFocus ?? "auto", t.triggerElement = o.trigger || null, t.type = o.type || "modal", t.offset = o.offset ?? 0, t.placement = o.placement, t.willPreventClose = !!o.notImmediatelyClosable;
  }
}
const ve = Symbol("element resolver updated");
class di {
  constructor(t, { selector: o } = { selector: "" }) {
    this._element = null, this._selector = "", this.mutationCallback = (i) => {
      let s = !1;
      i.forEach((r) => {
        if (!s) {
          if (r.type === "childList") {
            const n = this.element && [...r.removedNodes].includes(this.element), a = !!this.selector && [...r.addedNodes].some(
              this.elementIsSelected
            );
            s = s || n || a;
          }
          if (r.type === "attributes") {
            const n = r.target === this.element, a = !!this.selector && this.elementIsSelected(r.target);
            s = s || n || a;
          }
        }
      }), s && this.resolveElement();
    }, this.elementIsSelected = (i) => this.selectorIsId ? i?.id === this.selectorAsId : i?.matches?.(this.selector), this.host = t, this.selector = o, this.observer = new MutationObserver(this.mutationCallback), this.host.addController(this);
  }
  get element() {
    return this._element;
  }
  set element(t) {
    if (t === this.element)
      return;
    const o = this.element;
    this._element = t, this.host.requestUpdate(ve, o);
  }
  get selector() {
    return this._selector;
  }
  set selector(t) {
    t !== this.selector && (this.releaseElement(), this._selector = t, this.resolveElement());
  }
  get selectorAsId() {
    return this.selector.slice(1);
  }
  get selectorIsId() {
    return !!this.selector && this.selector.startsWith("#");
  }
  hostConnected() {
    this.resolveElement(), this.observer.observe(this.host.getRootNode(), {
      attributes: !0,
      childList: !0,
      subtree: !0
    });
  }
  hostDisconnected() {
    this.releaseElement(), this.observer.disconnect();
  }
  resolveElement() {
    if (!this.selector) {
      this.releaseElement();
      return;
    }
    const t = this.host.getRootNode();
    this.element = this.selectorIsId ? t.getElementById(this.selectorAsId) : t.querySelector(this.selector);
  }
  releaseElement() {
    this.element = null;
  }
}
class Gt extends Event {
  constructor() {
    super("beforetoggle", {
      bubbles: !1,
      composed: !1
    }), this.currentState = "open", this.newState = "closed";
  }
}
class Jt extends Event {
  constructor() {
    super("beforetoggle", {
      bubbles: !1,
      composed: !1
    }), this.currentState = "closed", this.newState = "open";
  }
}
class _ extends Event {
  constructor(t, o, {
    interaction: i,
    publish: s,
    reason: r
  }) {
    super(t, {
      bubbles: s,
      composed: s
    }), this.overlay = o, this.detail = {
      interaction: i,
      reason: r
    };
  }
}
class Ot {
  constructor(t, o) {
    this.x = 0, this.y = 0, this.x = t, this.y = o;
  }
  updateBoundingClientRect(t, o) {
    this.x = t, this.y = o, dt.update();
  }
  getBoundingClientRect() {
    return {
      bottom: this.y,
      height: 0,
      left: this.x,
      right: this.x,
      /* c8 ignore next 3 */
      toJSON() {
      },
      top: this.y,
      width: 0,
      x: this.x,
      y: this.y
    };
  }
}
function pi(e) {
  class t extends e {
    async manageDialogOpen() {
      const i = this.open;
      if (await this.managePosition(), this.open !== i)
        return;
      const s = await this.dialogMakeTransition(i);
      this.open === i && await this.dialogApplyFocus(i, s);
    }
    async dialogMakeTransition(i) {
      let s = null;
      const r = (a, l) => async () => {
        if (a.open = i, !i) {
          const h = () => {
            a.removeEventListener("close", h);
          };
          a.addEventListener("close", h);
        }
        if (l > 0)
          return;
        const c = i ? Jt : Gt;
        this.dispatchEvent(new c()), i && (a.matches(ft) && (s = a), s = s || Ut(a), s || a.querySelectorAll("slot").forEach((d) => {
          s || (s = Yt(d));
        }), !(!this.isConnected || this.dialogEl.open) && this.dialogEl.showModal());
      }, n = (a, l) => () => {
        if (this.open !== i)
          return;
        const c = i ? "cx-opened" : "cx-closed";
        if (l > 0) {
          a.dispatchEvent(
            new _(c, this, {
              interaction: this.type,
              publish: !1
            })
          );
          return;
        }
        if (!this.isConnected || i !== this.open)
          return;
        const h = async () => {
          const d = this.triggerElement instanceof Ot;
          this.dispatchEvent(
            new _(c, this, {
              interaction: this.type,
              publish: d
            })
          ), a.dispatchEvent(
            new _(c, this, {
              interaction: this.type,
              publish: !1
            })
          ), this.triggerElement && !d && this.triggerElement.dispatchEvent(
            new _(c, this, {
              interaction: this.type,
              publish: !0
            })
          ), this.state = i ? "opened" : "closed", this.returnFocus(), await k(), await k(), i === this.open && i === !1 && this.requestSlottable();
        };
        !i && this.dialogEl.open ? (this.dialogEl.addEventListener(
          "close",
          () => {
            h();
          },
          { once: !0 }
        ), this.dialogEl.close()) : h();
      };
      return this.elements.forEach((a, l) => {
        Xt(a, r(a, l), n(a, l));
      }), s;
    }
    async dialogApplyFocus(i, s) {
      this.applyFocus(i, s);
    }
  }
  return t;
}
function ui(e) {
  class t extends e {
    async managePopoverOpen() {
      await this.managePosition();
    }
    async manageDelay(i) {
      if (i === !1 || i !== this.open) {
        wt.close(this);
        return;
      }
      this.delayed && await wt.openTimer(this) && (this.open = !i);
    }
    async ensureOnDOM(i) {
      document.body.offsetHeight;
    }
    async makeTransition(i) {
      if (this.open !== i)
        return null;
      let s = null;
      const r = (a, l) => () => {
        if (i !== this.open)
          return;
        if (a.open = i, l === 0) {
          const h = i ? Jt : Gt;
          this.dispatchEvent(new h());
        }
        if (i !== !0 || (a.matches(ft) && (s = a), s = s || Ut(a), s))
          return;
        a.querySelectorAll("slot").forEach((h) => {
          s || (s = Yt(h));
        });
      }, n = (a, l) => async () => {
        if (this.open !== i)
          return;
        const c = i ? "cx-opened" : "cx-closed";
        if (a.dispatchEvent(
          new _(c, this, {
            interaction: this.type
          })
        ), l > 0)
          return;
        const h = this.triggerElement instanceof Ot;
        this.dispatchEvent(
          new _(c, this, {
            interaction: this.type,
            publish: h
          })
        ), this.triggerElement && !h && this.triggerElement.dispatchEvent(
          new _(c, this, {
            interaction: this.type,
            publish: !0
          })
        ), this.state = i ? "opened" : "closed", this.returnFocus(), await k(), await k(), i === this.open && i === !1 && this.requestSlottable();
      };
      return this.elements.forEach((a, l) => {
        Xt(a, r(a, l), n(a, l));
      }), s;
    }
  }
  return t;
}
const fi = CSS.supports("(overlay: auto)");
function kt(e) {
  let t = !1;
  try {
    t = e.matches(":popover-open");
  } catch {
  }
  let o = !1;
  try {
    o = e.matches(":open");
  } catch {
  }
  return t || o;
}
function mi(e) {
  class t extends e {
    constructor(...i) {
      super(...i), this.handleFullscreenChange = this.handleFullscreenChange.bind(this);
    }
    async manageDelay(i) {
      if (i === !1 || i !== this.open) {
        wt.close(this);
        return;
      }
      this.delayed && await wt.openTimer(this) && (this.open = !i);
    }
    /**
     * A popover should be hidden _after_ it is no longer on top-layer because
     * the position metrics will have changed from when it was originally positioned.
     */
    async shouldHidePopover(i) {
      if (i && this.open !== i)
        return;
      const s = async ({
        newState: r
      } = {}) => {
        r !== "open" && await this.placementController.resetOverlayPosition();
      };
      if (!kt(this.dialogEl)) {
        s();
        return;
      }
      this.dialogEl.addEventListener("toggle", s, {
        once: !0
      });
    }
    async shouldShowPopover(i) {
      let s = !1;
      try {
        s = this.dialogEl.matches(":popover-open");
      } catch {
      }
      let r = !1;
      try {
        r = this.dialogEl.matches(":open");
      } catch {
      }
      i && this.open === i && !s && !r && this.isConnected && (this.dialogEl.showPopover(), await this.managePosition());
    }
    handleFullscreenChange() {
      kt(this.dialogEl) && (this.dialogEl.hidePopover(), this.dialogEl.showPopover());
    }
    firstUpdated(i) {
      super.firstUpdated(i), gt() && k().then(() => {
        this.dialogEl.showPopover();
      });
    }
    runConnectedCallback() {
      gt() && document.addEventListener("fullscreenchange", this.handleFullscreenChange);
    }
    disconnectedCallback() {
      super.disconnectedCallback(), gt() && document.removeEventListener(
        "fullscreenchange",
        this.handleFullscreenChange
      );
    }
    async ensureOnDOM(i) {
      await k(), fi || await this.shouldHidePopover(i), await this.shouldShowPopover(i), await k();
    }
    async makeTransition(i) {
      if (this.open !== i)
        return null;
      let s = null;
      const r = (a, l) => () => {
        if (a.open = i, l === 0) {
          const h = i ? Jt : Gt;
          this.dispatchEvent(new h());
        }
        if (!i || (a.matches(ft) && (s = a), s = s || Ut(a), s))
          return;
        a.querySelectorAll("slot").forEach((h) => {
          s || (s = Yt(h));
        });
      }, n = (a, l) => async () => {
        if (this.open !== i)
          return;
        const c = i ? "cx-opened" : "cx-closed";
        if (l > 0) {
          a.dispatchEvent(
            new _(c, this, {
              interaction: this.type,
              publish: !1
            })
          );
          return;
        }
        const h = async () => {
          if (this.open !== i)
            return;
          await k();
          const u = this.triggerElement instanceof Ot;
          this.dispatchEvent(
            new _(c, this, {
              interaction: this.type,
              publish: u
            })
          ), a.dispatchEvent(
            new _(c, this, {
              interaction: this.type,
              publish: !1
            })
          ), this.triggerElement && !u && this.triggerElement.dispatchEvent(
            new _(c, this, {
              interaction: this.type,
              publish: !0
            })
          ), this.state = i ? "opened" : "closed", this.returnFocus(), await k(), await k(), i === this.open && i === !1 && this.requestSlottable();
        };
        if (this.open !== i)
          return;
        const d = kt(this.dialogEl);
        i !== !0 && d && this.isConnected ? (this.dialogEl.addEventListener(
          "beforetoggle",
          () => {
            h();
          },
          { once: !0 }
        ), gt() || this.dialogEl.hidePopover()) : h();
      };
      return this.elements.forEach((a, l) => {
        Xt(a, r(a, l), n(a, l));
      }), s;
    }
  }
  return t;
}
const gi = "showPopover" in document.createElement("div");
class yi {
  constructor() {
    this.root = document.body, this.stack = [], this.handlePointerdown = (t) => {
      this.pointerdownPath = t.composedPath(), this.lastOverlay = this.stack[this.stack.length - 1];
    }, this.handlePointerup = () => {
      const t = this.pointerdownPath;
      if (this.pointerdownPath = void 0, !this.stack.length || !t?.length)
        return;
      const o = this.stack.length - 1, i = this.stack.filter((s, r) => !t.find(
        (a) => (
          // The Overlay is in the stack
          a === s || // The Overlay trigger is in the stack and the Overlay is a "hint"
          a === s?.triggerElement && s?.type === "hint" || // The last Overlay in the stack is not the last Overlay at `pointerdown` time and has a
          // `triggerInteraction` of "longpress", meaning it was opened by this poitner interaction
          r === o && s !== this.lastOverlay && s.triggerInteraction === "longpress"
        )
      ) && !s.shouldPreventClose() && s.type !== "manual");
      i.reverse(), i.forEach((s) => {
        this.closeOverlay(s);
        let r = s.parentOverlayToForceClose;
        for (; r; )
          this.closeOverlay(r), r = r.parentOverlayToForceClose;
      });
    }, this.handleBeforetoggle = (t) => {
      const { newState: o, target: i } = t;
      o !== "open" && this.closeOverlay(i);
    }, this.handleKeydown = (t) => {
      if (t.code !== "Escape" || !this.stack.length)
        return;
      const o = this.stack[this.stack.length - 1];
      if (o?.type === "page") {
        t.preventDefault();
        return;
      }
      gi || o?.type !== "manual" && o && this.closeOverlay(o);
    }, this.bindEvents();
  }
  get document() {
    return this.root?.ownerDocument || document;
  }
  bindEvents() {
    this.document.addEventListener("pointerdown", this.handlePointerdown), this.document.addEventListener("pointerup", this.handlePointerup), this.document.addEventListener("keydown", this.handleKeydown);
  }
  closeOverlay(t) {
    const o = this.stack.indexOf(t);
    o > -1 && this.stack.splice(o, 1), t.open = !1;
  }
  /**
   * Get an array of Overlays that all share the same trigger element.
   *
   * @param triggerElement {HTMLELement}
   * @returns {Overlay[]}
   */
  overlaysByTriggerElement(t) {
    return this.stack.filter(
      (o) => o.triggerElement === t
    );
  }
  /**
   * When overlays are added manage the open state of exisiting overlays appropriately:
   * - 'modal': should close other overlays
   * - 'page': should close other overlays
   * - 'auto': should close other 'auto' overlays and other 'hint' overlays, but not 'manual' overlays
   * - 'manual': shouldn't close other overlays
   * - 'hint': shouldn't close other overlays and give way to all other overlays on a trigger
   */
  add(t) {
    if (this.stack.includes(t)) {
      const o = this.stack.indexOf(t);
      o > -1 && (this.stack.splice(o, 1), this.stack.push(t));
      return;
    }
    if (t.type === "auto" || t.type === "modal" || t.type === "page") {
      const o = "cx-overlay-query-path", i = new Event(o, {
        bubbles: !0,
        composed: !0
      });
      t.addEventListener(
        o,
        (s) => {
          const r = s.composedPath();
          this.stack.forEach((n) => {
            !r.find((l) => l === n) && n.type !== "manual" && this.closeOverlay(n);
          });
        },
        { once: !0 }
      ), t.dispatchEvent(i);
    } else if (t.type === "hint") {
      if (this.stack.some((i) => i.type !== "manual" && i.triggerElement && i.triggerElement === t.triggerElement)) {
        t.open = !1;
        return;
      }
      this.stack.forEach((i) => {
        i.type === "hint" && this.closeOverlay(i);
      });
    }
    requestAnimationFrame(() => {
      this.stack.push(t), t.addEventListener("beforetoggle", this.handleBeforetoggle, {
        once: !0
      });
    });
  }
  remove(t) {
    this.closeOverlay(t);
  }
}
const le = new yi(), vi = ["top", "right", "bottom", "left"], Q = Math.min, T = Math.max, xt = Math.round, yt = Math.floor, I = (e) => ({
  x: e,
  y: e
}), bi = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
}, wi = {
  start: "end",
  end: "start"
};
function _t(e, t, o) {
  return T(e, Q(t, o));
}
function st(e, t) {
  return typeof e == "function" ? e(t) : e;
}
function Z(e) {
  return e.split("-")[0];
}
function at(e) {
  return e.split("-")[1];
}
function be(e) {
  return e === "x" ? "y" : "x";
}
function Qt(e) {
  return e === "y" ? "height" : "width";
}
const xi = /* @__PURE__ */ new Set(["top", "bottom"]);
function Y(e) {
  return xi.has(Z(e)) ? "y" : "x";
}
function Zt(e) {
  return be(Y(e));
}
function Ei(e, t, o) {
  o === void 0 && (o = !1);
  const i = at(e), s = Zt(e), r = Qt(s);
  let n = s === "x" ? i === (o ? "end" : "start") ? "right" : "left" : i === "start" ? "bottom" : "top";
  return t.reference[r] > t.floating[r] && (n = Et(n)), [n, Et(n)];
}
function Pi(e) {
  const t = Et(e);
  return [zt(e), t, zt(t)];
}
function zt(e) {
  return e.replace(/start|end/g, (t) => wi[t]);
}
const ce = ["left", "right"], he = ["right", "left"], Ci = ["top", "bottom"], Oi = ["bottom", "top"];
function Ai(e, t, o) {
  switch (e) {
    case "top":
    case "bottom":
      return o ? t ? he : ce : t ? ce : he;
    case "left":
    case "right":
      return t ? Ci : Oi;
    default:
      return [];
  }
}
function Si(e, t, o, i) {
  const s = at(e);
  let r = Ai(Z(e), o === "start", i);
  return s && (r = r.map((n) => n + "-" + s), t && (r = r.concat(r.map(zt)))), r;
}
function Et(e) {
  return e.replace(/left|right|bottom|top/g, (t) => bi[t]);
}
function Ri(e) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...e
  };
}
function we(e) {
  return typeof e != "number" ? Ri(e) : {
    top: e,
    right: e,
    bottom: e,
    left: e
  };
}
function Pt(e) {
  const {
    x: t,
    y: o,
    width: i,
    height: s
  } = e;
  return {
    width: i,
    height: s,
    top: o,
    left: t,
    right: t + i,
    bottom: o + s,
    x: t,
    y: o
  };
}
function de(e, t, o) {
  let {
    reference: i,
    floating: s
  } = e;
  const r = Y(t), n = Zt(t), a = Qt(n), l = Z(t), c = r === "y", h = i.x + i.width / 2 - s.width / 2, d = i.y + i.height / 2 - s.height / 2, u = i[a] / 2 - s[a] / 2;
  let p;
  switch (l) {
    case "top":
      p = {
        x: h,
        y: i.y - s.height
      };
      break;
    case "bottom":
      p = {
        x: h,
        y: i.y + i.height
      };
      break;
    case "right":
      p = {
        x: i.x + i.width,
        y: d
      };
      break;
    case "left":
      p = {
        x: i.x - s.width,
        y: d
      };
      break;
    default:
      p = {
        x: i.x,
        y: i.y
      };
  }
  switch (at(t)) {
    case "start":
      p[n] -= u * (o && c ? -1 : 1);
      break;
    case "end":
      p[n] += u * (o && c ? -1 : 1);
      break;
  }
  return p;
}
const Ti = async (e, t, o) => {
  const {
    placement: i = "bottom",
    strategy: s = "absolute",
    middleware: r = [],
    platform: n
  } = o, a = r.filter(Boolean), l = await (n.isRTL == null ? void 0 : n.isRTL(t));
  let c = await n.getElementRects({
    reference: e,
    floating: t,
    strategy: s
  }), {
    x: h,
    y: d
  } = de(c, i, l), u = i, p = {}, f = 0;
  for (let m = 0; m < a.length; m++) {
    const {
      name: g,
      fn: v
    } = a[m], {
      x,
      y: E,
      data: C,
      reset: P
    } = await v({
      x: h,
      y: d,
      initialPlacement: i,
      placement: u,
      strategy: s,
      middlewareData: p,
      rects: c,
      platform: n,
      elements: {
        reference: e,
        floating: t
      }
    });
    h = x ?? h, d = E ?? d, p = {
      ...p,
      [g]: {
        ...p[g],
        ...C
      }
    }, P && f <= 50 && (f++, typeof P == "object" && (P.placement && (u = P.placement), P.rects && (c = P.rects === !0 ? await n.getElementRects({
      reference: e,
      floating: t,
      strategy: s
    }) : P.rects), {
      x: h,
      y: d
    } = de(c, u, l)), m = -1);
  }
  return {
    x: h,
    y: d,
    placement: u,
    strategy: s,
    middlewareData: p
  };
};
async function pt(e, t) {
  var o;
  t === void 0 && (t = {});
  const {
    x: i,
    y: s,
    platform: r,
    rects: n,
    elements: a,
    strategy: l
  } = e, {
    boundary: c = "clippingAncestors",
    rootBoundary: h = "viewport",
    elementContext: d = "floating",
    altBoundary: u = !1,
    padding: p = 0
  } = st(t, e), f = we(p), g = a[u ? d === "floating" ? "reference" : "floating" : d], v = Pt(await r.getClippingRect({
    element: (o = await (r.isElement == null ? void 0 : r.isElement(g))) == null || o ? g : g.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(a.floating)),
    boundary: c,
    rootBoundary: h,
    strategy: l
  })), x = d === "floating" ? {
    x: i,
    y: s,
    width: n.floating.width,
    height: n.floating.height
  } : n.reference, E = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(a.floating)), C = await (r.isElement == null ? void 0 : r.isElement(E)) ? await (r.getScale == null ? void 0 : r.getScale(E)) || {
    x: 1,
    y: 1
  } : {
    x: 1,
    y: 1
  }, P = Pt(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
    elements: a,
    rect: x,
    offsetParent: E,
    strategy: l
  }) : x);
  return {
    top: (v.top - P.top + f.top) / C.y,
    bottom: (P.bottom - v.bottom + f.bottom) / C.y,
    left: (v.left - P.left + f.left) / C.x,
    right: (P.right - v.right + f.right) / C.x
  };
}
const Di = (e) => ({
  name: "arrow",
  options: e,
  async fn(t) {
    const {
      x: o,
      y: i,
      placement: s,
      rects: r,
      platform: n,
      elements: a,
      middlewareData: l
    } = t, {
      element: c,
      padding: h = 0
    } = st(e, t) || {};
    if (c == null)
      return {};
    const d = we(h), u = {
      x: o,
      y: i
    }, p = Zt(s), f = Qt(p), m = await n.getDimensions(c), g = p === "y", v = g ? "top" : "left", x = g ? "bottom" : "right", E = g ? "clientHeight" : "clientWidth", C = r.reference[f] + r.reference[p] - u[p] - r.floating[f], P = u[p] - r.reference[p], $ = await (n.getOffsetParent == null ? void 0 : n.getOffsetParent(c));
    let A = $ ? $[E] : 0;
    (!A || !await (n.isElement == null ? void 0 : n.isElement($))) && (A = a.floating[E] || r.floating[f]);
    const V = C / 2 - P / 2, M = A / 2 - m[f] / 2 - 1, L = Q(d[v], M), X = Q(d[x], M), H = L, G = A - m[f] - X, R = A / 2 - m[f] / 2 + V, et = _t(H, R, G), j = !l.arrow && at(s) != null && R !== et && r.reference[f] / 2 - (R < H ? L : X) - m[f] / 2 < 0, F = j ? R < H ? R - H : R - G : 0;
    return {
      [p]: u[p] + F,
      data: {
        [p]: et,
        centerOffset: R - et - F,
        ...j && {
          alignmentOffset: F
        }
      },
      reset: j
    };
  }
}), Li = function(e) {
  return e === void 0 && (e = {}), {
    name: "flip",
    options: e,
    async fn(t) {
      var o, i;
      const {
        placement: s,
        middlewareData: r,
        rects: n,
        initialPlacement: a,
        platform: l,
        elements: c
      } = t, {
        mainAxis: h = !0,
        crossAxis: d = !0,
        fallbackPlacements: u,
        fallbackStrategy: p = "bestFit",
        fallbackAxisSideDirection: f = "none",
        flipAlignment: m = !0,
        ...g
      } = st(e, t);
      if ((o = r.arrow) != null && o.alignmentOffset)
        return {};
      const v = Z(s), x = Y(a), E = Z(a) === a, C = await (l.isRTL == null ? void 0 : l.isRTL(c.floating)), P = u || (E || !m ? [Et(a)] : Pi(a)), $ = f !== "none";
      !u && $ && P.push(...Si(a, m, f, C));
      const A = [a, ...P], V = await pt(t, g), M = [];
      let L = ((i = r.flip) == null ? void 0 : i.overflows) || [];
      if (h && M.push(V[v]), d) {
        const R = Ei(s, n, C);
        M.push(V[R[0]], V[R[1]]);
      }
      if (L = [...L, {
        placement: s,
        overflows: M
      }], !M.every((R) => R <= 0)) {
        var X, H;
        const R = (((X = r.flip) == null ? void 0 : X.index) || 0) + 1, et = A[R];
        if (et && (!(d === "alignment" ? x !== Y(et) : !1) || // We leave the current main axis only if every placement on that axis
        // overflows the main axis.
        L.every((N) => Y(N.placement) === x ? N.overflows[0] > 0 : !0)))
          return {
            data: {
              index: R,
              overflows: L
            },
            reset: {
              placement: et
            }
          };
        let j = (H = L.filter((F) => F.overflows[0] <= 0).sort((F, N) => F.overflows[1] - N.overflows[1])[0]) == null ? void 0 : H.placement;
        if (!j)
          switch (p) {
            case "bestFit": {
              var G;
              const F = (G = L.filter((N) => {
                if ($) {
                  const J = Y(N.placement);
                  return J === x || // Create a bias to the `y` side axis due to horizontal
                  // reading directions favoring greater width.
                  J === "y";
                }
                return !0;
              }).map((N) => [N.placement, N.overflows.filter((J) => J > 0).reduce((J, Ne) => J + Ne, 0)]).sort((N, J) => N[1] - J[1])[0]) == null ? void 0 : G[0];
              F && (j = F);
              break;
            }
            case "initialPlacement":
              j = a;
              break;
          }
        if (s !== j)
          return {
            reset: {
              placement: j
            }
          };
      }
      return {};
    }
  };
};
function pe(e, t) {
  return {
    top: e.top - t.height,
    right: e.right - t.width,
    bottom: e.bottom - t.height,
    left: e.left - t.width
  };
}
function ue(e) {
  return vi.some((t) => e[t] >= 0);
}
const ki = function(e) {
  return e === void 0 && (e = {}), {
    name: "hide",
    options: e,
    async fn(t) {
      const {
        rects: o
      } = t, {
        strategy: i = "referenceHidden",
        ...s
      } = st(e, t);
      switch (i) {
        case "referenceHidden": {
          const r = await pt(t, {
            ...s,
            elementContext: "reference"
          }), n = pe(r, o.reference);
          return {
            data: {
              referenceHiddenOffsets: n,
              referenceHidden: ue(n)
            }
          };
        }
        case "escaped": {
          const r = await pt(t, {
            ...s,
            altBoundary: !0
          }), n = pe(r, o.floating);
          return {
            data: {
              escapedOffsets: n,
              escaped: ue(n)
            }
          };
        }
        default:
          return {};
      }
    }
  };
}, $i = /* @__PURE__ */ new Set(["left", "top"]);
async function Fi(e, t) {
  const {
    placement: o,
    platform: i,
    elements: s
  } = e, r = await (i.isRTL == null ? void 0 : i.isRTL(s.floating)), n = Z(o), a = at(o), l = Y(o) === "y", c = $i.has(n) ? -1 : 1, h = r && l ? -1 : 1, d = st(t, e);
  let {
    mainAxis: u,
    crossAxis: p,
    alignmentAxis: f
  } = typeof d == "number" ? {
    mainAxis: d,
    crossAxis: 0,
    alignmentAxis: null
  } : {
    mainAxis: d.mainAxis || 0,
    crossAxis: d.crossAxis || 0,
    alignmentAxis: d.alignmentAxis
  };
  return a && typeof f == "number" && (p = a === "end" ? f * -1 : f), l ? {
    x: p * h,
    y: u * c
  } : {
    x: u * c,
    y: p * h
  };
}
const Ni = function(e) {
  return e === void 0 && (e = 0), {
    name: "offset",
    options: e,
    async fn(t) {
      var o, i;
      const {
        x: s,
        y: r,
        placement: n,
        middlewareData: a
      } = t, l = await Fi(t, e);
      return n === ((o = a.offset) == null ? void 0 : o.placement) && (i = a.arrow) != null && i.alignmentOffset ? {} : {
        x: s + l.x,
        y: r + l.y,
        data: {
          ...l,
          placement: n
        }
      };
    }
  };
}, _i = function(e) {
  return e === void 0 && (e = {}), {
    name: "shift",
    options: e,
    async fn(t) {
      const {
        x: o,
        y: i,
        placement: s
      } = t, {
        mainAxis: r = !0,
        crossAxis: n = !1,
        limiter: a = {
          fn: (g) => {
            let {
              x: v,
              y: x
            } = g;
            return {
              x: v,
              y: x
            };
          }
        },
        ...l
      } = st(e, t), c = {
        x: o,
        y: i
      }, h = await pt(t, l), d = Y(Z(s)), u = be(d);
      let p = c[u], f = c[d];
      if (r) {
        const g = u === "y" ? "top" : "left", v = u === "y" ? "bottom" : "right", x = p + h[g], E = p - h[v];
        p = _t(x, p, E);
      }
      if (n) {
        const g = d === "y" ? "top" : "left", v = d === "y" ? "bottom" : "right", x = f + h[g], E = f - h[v];
        f = _t(x, f, E);
      }
      const m = a.fn({
        ...t,
        [u]: p,
        [d]: f
      });
      return {
        ...m,
        data: {
          x: m.x - o,
          y: m.y - i,
          enabled: {
            [u]: r,
            [d]: n
          }
        }
      };
    }
  };
}, zi = function(e) {
  return e === void 0 && (e = {}), {
    name: "size",
    options: e,
    async fn(t) {
      var o, i;
      const {
        placement: s,
        rects: r,
        platform: n,
        elements: a
      } = t, {
        apply: l = () => {
        },
        ...c
      } = st(e, t), h = await pt(t, c), d = Z(s), u = at(s), p = Y(s) === "y", {
        width: f,
        height: m
      } = r.floating;
      let g, v;
      d === "top" || d === "bottom" ? (g = d, v = u === (await (n.isRTL == null ? void 0 : n.isRTL(a.floating)) ? "start" : "end") ? "left" : "right") : (v = d, g = u === "end" ? "top" : "bottom");
      const x = m - h.top - h.bottom, E = f - h.left - h.right, C = Q(m - h[g], x), P = Q(f - h[v], E), $ = !t.middlewareData.shift;
      let A = C, V = P;
      if ((o = t.middlewareData.shift) != null && o.enabled.x && (V = E), (i = t.middlewareData.shift) != null && i.enabled.y && (A = x), $ && !u) {
        const L = T(h.left, 0), X = T(h.right, 0), H = T(h.top, 0), G = T(h.bottom, 0);
        p ? V = f - 2 * (L !== 0 || X !== 0 ? L + X : T(h.left, h.right)) : A = m - 2 * (H !== 0 || G !== 0 ? H + G : T(h.top, h.bottom));
      }
      await l({
        ...t,
        availableWidth: V,
        availableHeight: A
      });
      const M = await n.getDimensions(a.floating);
      return f !== M.width || m !== M.height ? {
        reset: {
          rects: !0
        }
      } : {};
    }
  };
};
function At() {
  return typeof window < "u";
}
function lt(e) {
  return xe(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function D(e) {
  var t;
  return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function q(e) {
  var t;
  return (t = (xe(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function xe(e) {
  return At() ? e instanceof Node || e instanceof D(e).Node : !1;
}
function z(e) {
  return At() ? e instanceof Element || e instanceof D(e).Element : !1;
}
function W(e) {
  return At() ? e instanceof HTMLElement || e instanceof D(e).HTMLElement : !1;
}
function fe(e) {
  return !At() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof D(e).ShadowRoot;
}
const Bi = /* @__PURE__ */ new Set(["inline", "contents"]);
function mt(e) {
  const {
    overflow: t,
    overflowX: o,
    overflowY: i,
    display: s
  } = B(e);
  return /auto|scroll|overlay|hidden|clip/.test(t + i + o) && !Bi.has(s);
}
const Mi = /* @__PURE__ */ new Set(["table", "td", "th"]);
function Hi(e) {
  return Mi.has(lt(e));
}
const Ii = [":popover-open", ":modal"];
function St(e) {
  return Ii.some((t) => {
    try {
      return e.matches(t);
    } catch {
      return !1;
    }
  });
}
const Wi = ["transform", "translate", "scale", "rotate", "perspective"], qi = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Vi = ["paint", "layout", "strict", "content"];
function Rt(e) {
  const t = te(), o = z(e) ? B(e) : e;
  return Wi.some((i) => o[i] ? o[i] !== "none" : !1) || (o.containerType ? o.containerType !== "normal" : !1) || !t && (o.backdropFilter ? o.backdropFilter !== "none" : !1) || !t && (o.filter ? o.filter !== "none" : !1) || qi.some((i) => (o.willChange || "").includes(i)) || Vi.some((i) => (o.contain || "").includes(i));
}
function ji(e) {
  let t = tt(e);
  for (; W(t) && !rt(t); ) {
    if (Rt(t))
      return t;
    if (St(t))
      return null;
    t = tt(t);
  }
  return null;
}
function te() {
  return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const Ui = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function rt(e) {
  return Ui.has(lt(e));
}
function B(e) {
  return D(e).getComputedStyle(e);
}
function Tt(e) {
  return z(e) ? {
    scrollLeft: e.scrollLeft,
    scrollTop: e.scrollTop
  } : {
    scrollLeft: e.scrollX,
    scrollTop: e.scrollY
  };
}
function tt(e) {
  if (lt(e) === "html")
    return e;
  const t = (
    // Step into the shadow DOM of the parent of a slotted node.
    e.assignedSlot || // DOM Element detected.
    e.parentNode || // ShadowRoot detected.
    fe(e) && e.host || // Fallback.
    q(e)
  );
  return fe(t) ? t.host : t;
}
function Ee(e) {
  const t = tt(e);
  return rt(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : W(t) && mt(t) ? t : Ee(t);
}
function ut(e, t, o) {
  var i;
  t === void 0 && (t = []), o === void 0 && (o = !0);
  const s = Ee(e), r = s === ((i = e.ownerDocument) == null ? void 0 : i.body), n = D(s);
  if (r) {
    const a = Bt(n);
    return t.concat(n, n.visualViewport || [], mt(s) ? s : [], a && o ? ut(a) : []);
  }
  return t.concat(s, ut(s, [], o));
}
function Bt(e) {
  return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
function Pe(e) {
  const t = B(e);
  let o = parseFloat(t.width) || 0, i = parseFloat(t.height) || 0;
  const s = W(e), r = s ? e.offsetWidth : o, n = s ? e.offsetHeight : i, a = xt(o) !== r || xt(i) !== n;
  return a && (o = r, i = n), {
    width: o,
    height: i,
    $: a
  };
}
function ee(e) {
  return z(e) ? e : e.contextElement;
}
function nt(e) {
  const t = ee(e);
  if (!W(t))
    return I(1);
  const o = t.getBoundingClientRect(), {
    width: i,
    height: s,
    $: r
  } = Pe(t);
  let n = (r ? xt(o.width) : o.width) / i, a = (r ? xt(o.height) : o.height) / s;
  return (!n || !Number.isFinite(n)) && (n = 1), (!a || !Number.isFinite(a)) && (a = 1), {
    x: n,
    y: a
  };
}
const Yi = /* @__PURE__ */ I(0);
function Ce(e) {
  const t = D(e);
  return !te() || !t.visualViewport ? Yi : {
    x: t.visualViewport.offsetLeft,
    y: t.visualViewport.offsetTop
  };
}
function Ki(e, t, o) {
  return t === void 0 && (t = !1), !o || t && o !== D(e) ? !1 : t;
}
function ot(e, t, o, i) {
  t === void 0 && (t = !1), o === void 0 && (o = !1);
  const s = e.getBoundingClientRect(), r = ee(e);
  let n = I(1);
  t && (i ? z(i) && (n = nt(i)) : n = nt(e));
  const a = Ki(r, o, i) ? Ce(r) : I(0);
  let l = (s.left + a.x) / n.x, c = (s.top + a.y) / n.y, h = s.width / n.x, d = s.height / n.y;
  if (r) {
    const u = D(r), p = i && z(i) ? D(i) : i;
    let f = u, m = Bt(f);
    for (; m && i && p !== f; ) {
      const g = nt(m), v = m.getBoundingClientRect(), x = B(m), E = v.left + (m.clientLeft + parseFloat(x.paddingLeft)) * g.x, C = v.top + (m.clientTop + parseFloat(x.paddingTop)) * g.y;
      l *= g.x, c *= g.y, h *= g.x, d *= g.y, l += E, c += C, f = D(m), m = Bt(f);
    }
  }
  return Pt({
    width: h,
    height: d,
    x: l,
    y: c
  });
}
function ie(e, t) {
  const o = Tt(e).scrollLeft;
  return t ? t.left + o : ot(q(e)).left + o;
}
function Oe(e, t, o) {
  o === void 0 && (o = !1);
  const i = e.getBoundingClientRect(), s = i.left + t.scrollLeft - (o ? 0 : (
    // RTL <body> scrollbar.
    ie(e, i)
  )), r = i.top + t.scrollTop;
  return {
    x: s,
    y: r
  };
}
function Xi(e) {
  let {
    elements: t,
    rect: o,
    offsetParent: i,
    strategy: s
  } = e;
  const r = s === "fixed", n = q(i), a = t ? St(t.floating) : !1;
  if (i === n || a && r)
    return o;
  let l = {
    scrollLeft: 0,
    scrollTop: 0
  }, c = I(1);
  const h = I(0), d = W(i);
  if ((d || !d && !r) && ((lt(i) !== "body" || mt(n)) && (l = Tt(i)), W(i))) {
    const p = ot(i);
    c = nt(i), h.x = p.x + i.clientLeft, h.y = p.y + i.clientTop;
  }
  const u = n && !d && !r ? Oe(n, l, !0) : I(0);
  return {
    width: o.width * c.x,
    height: o.height * c.y,
    x: o.x * c.x - l.scrollLeft * c.x + h.x + u.x,
    y: o.y * c.y - l.scrollTop * c.y + h.y + u.y
  };
}
function Gi(e) {
  return Array.from(e.getClientRects());
}
function Ji(e) {
  const t = q(e), o = Tt(e), i = e.ownerDocument.body, s = T(t.scrollWidth, t.clientWidth, i.scrollWidth, i.clientWidth), r = T(t.scrollHeight, t.clientHeight, i.scrollHeight, i.clientHeight);
  let n = -o.scrollLeft + ie(e);
  const a = -o.scrollTop;
  return B(i).direction === "rtl" && (n += T(t.clientWidth, i.clientWidth) - s), {
    width: s,
    height: r,
    x: n,
    y: a
  };
}
function Qi(e, t) {
  const o = D(e), i = q(e), s = o.visualViewport;
  let r = i.clientWidth, n = i.clientHeight, a = 0, l = 0;
  if (s) {
    r = s.width, n = s.height;
    const c = te();
    (!c || c && t === "fixed") && (a = s.offsetLeft, l = s.offsetTop);
  }
  return {
    width: r,
    height: n,
    x: a,
    y: l
  };
}
const Zi = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function to(e, t) {
  const o = ot(e, !0, t === "fixed"), i = o.top + e.clientTop, s = o.left + e.clientLeft, r = W(e) ? nt(e) : I(1), n = e.clientWidth * r.x, a = e.clientHeight * r.y, l = s * r.x, c = i * r.y;
  return {
    width: n,
    height: a,
    x: l,
    y: c
  };
}
function me(e, t, o) {
  let i;
  if (t === "viewport")
    i = Qi(e, o);
  else if (t === "document")
    i = Ji(q(e));
  else if (z(t))
    i = to(t, o);
  else {
    const s = Ce(e);
    i = {
      x: t.x - s.x,
      y: t.y - s.y,
      width: t.width,
      height: t.height
    };
  }
  return Pt(i);
}
function Ae(e, t) {
  const o = tt(e);
  return o === t || !z(o) || rt(o) ? !1 : B(o).position === "fixed" || Ae(o, t);
}
function eo(e, t) {
  const o = t.get(e);
  if (o)
    return o;
  let i = ut(e, [], !1).filter((a) => z(a) && lt(a) !== "body"), s = null;
  const r = B(e).position === "fixed";
  let n = r ? tt(e) : e;
  for (; z(n) && !rt(n); ) {
    const a = B(n), l = Rt(n);
    !l && a.position === "fixed" && (s = null), (r ? !l && !s : !l && a.position === "static" && !!s && Zi.has(s.position) || mt(n) && !l && Ae(e, n)) ? i = i.filter((h) => h !== n) : s = a, n = tt(n);
  }
  return t.set(e, i), i;
}
function io(e) {
  let {
    element: t,
    boundary: o,
    rootBoundary: i,
    strategy: s
  } = e;
  const n = [...o === "clippingAncestors" ? St(t) ? [] : eo(t, this._c) : [].concat(o), i], a = n[0], l = n.reduce((c, h) => {
    const d = me(t, h, s);
    return c.top = T(d.top, c.top), c.right = Q(d.right, c.right), c.bottom = Q(d.bottom, c.bottom), c.left = T(d.left, c.left), c;
  }, me(t, a, s));
  return {
    width: l.right - l.left,
    height: l.bottom - l.top,
    x: l.left,
    y: l.top
  };
}
function oo(e) {
  const {
    width: t,
    height: o
  } = Pe(e);
  return {
    width: t,
    height: o
  };
}
function so(e, t, o) {
  const i = W(t), s = q(t), r = o === "fixed", n = ot(e, !0, r, t);
  let a = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const l = I(0);
  function c() {
    l.x = ie(s);
  }
  if (i || !i && !r)
    if ((lt(t) !== "body" || mt(s)) && (a = Tt(t)), i) {
      const p = ot(t, !0, r, t);
      l.x = p.x + t.clientLeft, l.y = p.y + t.clientTop;
    } else s && c();
  r && !i && s && c();
  const h = s && !i && !r ? Oe(s, a) : I(0), d = n.left + a.scrollLeft - l.x - h.x, u = n.top + a.scrollTop - l.y - h.y;
  return {
    x: d,
    y: u,
    width: n.width,
    height: n.height
  };
}
function $t(e) {
  return B(e).position === "static";
}
function ge(e, t) {
  if (!W(e) || B(e).position === "fixed")
    return null;
  if (t)
    return t(e);
  let o = e.offsetParent;
  return q(e) === o && (o = o.ownerDocument.body), o;
}
function Se(e, t) {
  const o = D(e);
  if (St(e))
    return o;
  if (!W(e)) {
    let s = tt(e);
    for (; s && !rt(s); ) {
      if (z(s) && !$t(s))
        return s;
      s = tt(s);
    }
    return o;
  }
  let i = ge(e, t);
  for (; i && Hi(i) && $t(i); )
    i = ge(i, t);
  return i && rt(i) && $t(i) && !Rt(i) ? o : i || ji(e) || o;
}
const no = async function(e) {
  const t = this.getOffsetParent || Se, o = this.getDimensions, i = await o(e.floating);
  return {
    reference: so(e.reference, await t(e.floating), e.strategy),
    floating: {
      x: 0,
      y: 0,
      width: i.width,
      height: i.height
    }
  };
};
function ro(e) {
  return B(e).direction === "rtl";
}
const Mt = {
  convertOffsetParentRelativeRectToViewportRelativeRect: Xi,
  getDocumentElement: q,
  getClippingRect: io,
  getOffsetParent: Se,
  getElementRects: no,
  getClientRects: Gi,
  getDimensions: oo,
  getScale: nt,
  isElement: z,
  isRTL: ro
};
function Re(e, t) {
  return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
}
function ao(e, t) {
  let o = null, i;
  const s = q(e);
  function r() {
    var a;
    clearTimeout(i), (a = o) == null || a.disconnect(), o = null;
  }
  function n(a, l) {
    a === void 0 && (a = !1), l === void 0 && (l = 1), r();
    const c = e.getBoundingClientRect(), {
      left: h,
      top: d,
      width: u,
      height: p
    } = c;
    if (a || t(), !u || !p)
      return;
    const f = yt(d), m = yt(s.clientWidth - (h + u)), g = yt(s.clientHeight - (d + p)), v = yt(h), E = {
      rootMargin: -f + "px " + -m + "px " + -g + "px " + -v + "px",
      threshold: T(0, Q(1, l)) || 1
    };
    let C = !0;
    function P($) {
      const A = $[0].intersectionRatio;
      if (A !== l) {
        if (!C)
          return n();
        A ? n(!1, A) : i = setTimeout(() => {
          n(!1, 1e-7);
        }, 1e3);
      }
      A === 1 && !Re(c, e.getBoundingClientRect()) && n(), C = !1;
    }
    try {
      o = new IntersectionObserver(P, {
        ...E,
        // Handle <iframe>s
        root: s.ownerDocument
      });
    } catch {
      o = new IntersectionObserver(P, E);
    }
    o.observe(e);
  }
  return n(!0), r;
}
function Ht(e, t, o, i) {
  i === void 0 && (i = {});
  const {
    ancestorScroll: s = !0,
    ancestorResize: r = !0,
    elementResize: n = typeof ResizeObserver == "function",
    layoutShift: a = typeof IntersectionObserver == "function",
    animationFrame: l = !1
  } = i, c = ee(e), h = s || r ? [...c ? ut(c) : [], ...ut(t)] : [];
  h.forEach((v) => {
    s && v.addEventListener("scroll", o, {
      passive: !0
    }), r && v.addEventListener("resize", o);
  });
  const d = c && a ? ao(c, o) : null;
  let u = -1, p = null;
  n && (p = new ResizeObserver((v) => {
    let [x] = v;
    x && x.target === c && p && (p.unobserve(t), cancelAnimationFrame(u), u = requestAnimationFrame(() => {
      var E;
      (E = p) == null || E.observe(t);
    })), o();
  }), c && !l && p.observe(c), p.observe(t));
  let f, m = l ? ot(e) : null;
  l && g();
  function g() {
    const v = ot(e);
    m && !Re(m, v) && o(), m = v, f = requestAnimationFrame(g);
  }
  return o(), () => {
    var v;
    h.forEach((x) => {
      s && x.removeEventListener("scroll", o), r && x.removeEventListener("resize", o);
    }), d?.(), (v = p) == null || v.disconnect(), p = null, l && cancelAnimationFrame(f);
  };
}
const It = Ni, Te = _i, Wt = Li, qt = zi, lo = ki, De = Di, Le = (e, t, o) => {
  const i = /* @__PURE__ */ new Map(), s = {
    platform: Mt,
    ...o
  }, r = {
    ...s.platform,
    _c: i
  };
  return Ti(e, t, {
    ...s,
    platform: r
  });
};
function vt(e) {
  if (typeof e > "u")
    return 0;
  const t = window.devicePixelRatio || 1;
  return Math.round(e * t) / t || -1e4;
}
const bt = 8, co = 100, ho = (e) => ({
  bottom: ["top", "left", "right"],
  "bottom-end": ["top-end", "left", "right"],
  "bottom-start": ["top-start", "left", "right"],
  left: ["right", "bottom", "top"],
  "left-end": ["right-end", "bottom", "top"],
  "left-start": ["right-start", "bottom", "top"],
  right: ["left", "bottom", "top"],
  "right-end": ["left-end", "bottom", "top"],
  "right-start": ["left-start", "bottom", "top"],
  top: ["bottom", "left", "right"],
  "top-end": ["bottom-end", "left", "right"],
  "top-start": ["bottom-start", "left", "right"]
})[e] ?? [e];
class po {
  constructor(t) {
    this.originalPlacements = /* @__PURE__ */ new WeakMap(), this.allowPlacementUpdate = !1, this.closeForAncestorUpdate = () => {
      !this.allowPlacementUpdate && this.options.type !== "modal" && this.cleanup && this.target.dispatchEvent(new Event("close", { bubbles: !0 })), this.allowPlacementUpdate = !1;
    }, this.updatePlacement = () => {
      this.computePlacement();
    }, this.resetOverlayPosition = () => {
      !this.target || !this.options || (this.clearOverlayPosition(), this.host.offsetHeight, this.computePlacement());
    }, this.host = t, this.host.addController(this);
  }
  async placeOverlay(t = this.target, o = this.options) {
    if (this.target = t, this.options = o, !t || !o)
      return;
    const i = Ht(
      o.trigger,
      t,
      this.closeForAncestorUpdate,
      {
        ancestorResize: !1,
        elementResize: !1,
        layoutShift: !1
      }
    ), s = Ht(
      o.trigger,
      t,
      this.updatePlacement,
      {
        ancestorScroll: !1
      }
    );
    this.cleanup = () => {
      this.host.elements?.forEach((r) => {
        r.addEventListener(
          "cx-closed",
          () => {
            const n = this.originalPlacements.get(r);
            n && r.setAttribute("placement", n), this.originalPlacements.delete(r);
          },
          { once: !0 }
        );
      }), i(), s();
    };
  }
  async computePlacement() {
    const { options: t, target: o } = this;
    await (document.fonts ? document.fonts.ready : Promise.resolve());
    const i = t.trigger instanceof HTMLElement ? Wt() : Wt({
      fallbackPlacements: ho(t.placement),
      padding: bt
    }), [s = 0, r = 0] = Array.isArray(t?.offset) ? t.offset : [t.offset, 0], n = this.host.elements.find(
      (u) => u.tipElement
    )?.tipElement, a = [
      It({
        crossAxis: r,
        mainAxis: s
      }),
      Te({ padding: bt }),
      i,
      qt({
        apply: ({ availableHeight: u, availableWidth: p, rects: { floating: f } }) => {
          const m = Math.max(
            co,
            Math.floor(u)
          ), g = f.height;
          this.initialHeight = this.isConstrained && this.initialHeight || g, this.isConstrained = g < this.initialHeight || m <= g;
          const v = this.isConstrained ? `${m}px` : "";
          Object.assign(o.style, {
            maxHeight: v,
            maxWidth: `${Math.floor(p)}px`
          });
        },
        padding: bt
      }),
      ...n ? [
        De({
          element: n,
          padding: t.tipPadding || bt
        })
      ] : []
    ], { middlewareData: l, placement: c, x: h, y: d } = await Le(
      t.trigger,
      o,
      {
        middleware: a,
        placement: t.placement,
        strategy: "fixed"
      }
    );
    if (Object.assign(o.style, {
      left: "0px",
      top: "0px",
      translate: `${vt(h)}px ${vt(d)}px`
    }), o.setAttribute("actual-placement", c), this.host.elements?.forEach((u) => {
      this.originalPlacements.has(u) || this.originalPlacements.set(
        u,
        u.getAttribute("placement")
      ), u.setAttribute("placement", c);
    }), n && l.arrow) {
      const { x: u, y: p } = l.arrow;
      Object.assign(n.style, {
        left: c.startsWith("bottom") || c.startsWith("top") ? "0px" : "",
        top: c.startsWith("right") || c.startsWith("left") ? "0px" : "",
        translate: `${vt(u)}px ${vt(p)}px`
      });
    }
  }
  clearOverlayPosition() {
    this.target && (this.target.style.removeProperty("max-height"), this.target.style.removeProperty("max-width"), this.initialHeight = void 0, this.isConstrained = !1);
  }
  hostConnected() {
    document.addEventListener("cx-update-overlays", this.resetOverlayPosition);
  }
  hostUpdated() {
    this.host.open || (this.cleanup?.(), this.cleanup = void 0);
  }
  hostDisconnected() {
    this.cleanup?.(), this.cleanup = void 0, document.removeEventListener(
      "cx-update-overlays",
      this.resetOverlayPosition
    );
  }
}
var Dt = /* @__PURE__ */ ((e) => (e.Click = "click", e.Hover = "hover", e.LongPress = "longpress", e))(Dt || {});
class oe {
  constructor(t, { handleOverlayReady: o, isPersistent: i, overlay: s }) {
    this.target = t, this.isLazilyOpen = !1, this.isPersistent = !1, this.isPersistent = !!i, this.handleOverlayReady = o, this.isPersistent && this.init(), this.overlay = s;
  }
  get activelyOpening() {
    return !1;
  }
  get open() {
    return this.overlay?.open ?? this.isLazilyOpen;
  }
  /**
   * Set `open` against the associated Overlay lazily.
   */
  set open(t) {
    if (t !== this.open) {
      if (this.isLazilyOpen = t, this.overlay) {
        this.overlay.open = t;
        return;
      }
      t && (customElements.whenDefined("cx-overlay").then(async () => {
        const { Overlay: o } = await Promise.resolve().then(() => Oo);
        this.overlay = new o(), this.overlay.open = !0;
      }), Promise.resolve().then(() => Fe));
    }
  }
  get overlay() {
    return this._overlay;
  }
  set overlay(t) {
    t && this.overlay !== t && (this.overlay && this.overlay.removeController(this), this._overlay = t, this.overlay.addController(this), this.initOverlay(), this.prepareDescription(this.target), this.handleOverlayReady?.(this.overlay));
  }
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  prepareDescription(t) {
  }
  releaseDescription() {
  }
  shouldCompleteOpen() {
  }
  /* c8 ignore next 3 */
  init() {
  }
  /* c8 ignore next 3 */
  initOverlay() {
  }
  abort() {
    this.releaseDescription(), this.abortController?.abort();
  }
  hostConnected() {
    this.init();
  }
  hostDisconnected() {
    this.isPersistent || this.abort();
  }
}
const uo = 300, ke = {
  keyboard: "Press Space or Alt+Down Arrow for additional options",
  mouse: "Click and hold for additional options",
  touch: "Double tap and long press for additional options"
};
class fo extends oe {
  constructor() {
    super(...arguments), this.type = Dt.LongPress, this.longpressState = null, this.releaseDescription = it, this.handlePointerup = () => {
      clearTimeout(this.timeout), this.target && (this.longpressState = this.overlay?.state === "opening" ? "pressed" : null, document.removeEventListener("pointerup", this.handlePointerup), document.removeEventListener("pointercancel", this.handlePointerup));
    };
  }
  get activelyOpening() {
    return this.longpressState === "opening" || this.longpressState === "pressed";
  }
  handleLongpress() {
    this.open = !0, this.longpressState = this.longpressState === "potential" ? "opening" : "pressed";
  }
  handlePointerdown(t) {
    !this.target || t.button !== 0 || (this.longpressState = "potential", document.addEventListener("pointerup", this.handlePointerup), document.addEventListener("pointercancel", this.handlePointerup), "holdAffordance" in this.target) || (this.timeout = setTimeout(() => {
      this.target && this.target.dispatchEvent(
        new CustomEvent("longpress", {
          bubbles: !0,
          composed: !0,
          detail: {
            source: "pointer"
          }
        })
      );
    }, uo));
  }
  handleKeydown(t) {
    const { altKey: o, code: i } = t;
    o && i === "ArrowDown" && (t.stopPropagation(), t.stopImmediatePropagation());
  }
  handleKeyup(t) {
    const { altKey: o, code: i } = t;
    if (i === "Space" || o && i === "ArrowDown") {
      if (!this.target)
        return;
      t.stopPropagation(), this.target.dispatchEvent(
        new CustomEvent("longpress", {
          bubbles: !0,
          composed: !0,
          detail: {
            source: "keyboard"
          }
        })
      ), setTimeout(() => {
        this.longpressState = null;
      });
    }
  }
  prepareDescription(t) {
    if (
      // do not reapply until target is recycled
      this.releaseDescription !== it || // require "longpress content" to apply relationship
      !this.overlay.elements.length
    )
      return;
    const o = document.createElement("div");
    o.id = `longpress-describedby-descriptor-${jt()}`;
    const i = ri() || ai() ? "touch" : "keyboard";
    o.textContent = ke[i], o.slot = "longpress-describedby-descriptor";
    const s = t.getRootNode(), r = this.overlay.getRootNode();
    s === r ? this.overlay.append(o) : (o.hidden = !("host" in s), t.insertAdjacentElement("afterend", o));
    const n = Nt(
      t,
      "aria-describedby",
      [o.id]
    );
    this.releaseDescription = () => {
      n(), o.remove(), this.releaseDescription = it;
    };
  }
  shouldCompleteOpen() {
    this.longpressState = this.longpressState === "pressed" ? null : this.longpressState;
  }
  init() {
    this.abortController?.abort(), this.abortController = new AbortController();
    const { signal: t } = this.abortController;
    this.target.addEventListener("longpress", () => this.handleLongpress(), {
      signal: t
    }), this.target.addEventListener(
      "pointerdown",
      (o) => this.handlePointerdown(o),
      { signal: t }
    ), this.prepareDescription(this.target), !this.target.holdAffordance && (this.target.addEventListener(
      "keydown",
      (o) => this.handleKeydown(o),
      { signal: t }
    ), this.target.addEventListener(
      "keyup",
      (o) => this.handleKeyup(o),
      { signal: t }
    ));
  }
}
const mo = Vt`:host{pointer-events:none;--swc-overlay-animation-distance:var(--cx-spacing-medium);display:contents}.dialog{box-sizing:border-box;--cx-overlay-open:true;background:0 0;border:0;max-width:calc(100vw - 16px);height:auto;max-height:calc(100dvh - 16px);margin:0;padding:0;display:flex;position:fixed;inset:0 auto auto 0;overflow:visible;opacity:1!important}.dialog:focus{outline:none}:host(:not([open])) .dialog{--cx-overlay-open:false}.dialog::backdrop{display:none}.dialog:before{content:"";position:absolute;inset:-999em;pointer-events:auto!important}.dialog:not(.not-immediately-closable):before{display:none}.dialog>div{width:100%}::slotted(*){pointer-events:auto;visibility:visible!important}.dialog.defer-slotted-visibility>slot::slotted(*){filter:opacity(0);pointer-events:none;translate:-200vw -200vh;visibility:hidden!important}.dialog.defer-slotted-visibility.defer-slotted-opened>slot::slotted(*){filter:none;pointer-events:auto;translate:none;visibility:visible!important}.dialog:not([actual-placement])[placement*=top]{padding-block:var(--swc-overlay-animation-distance);margin-top:var(--swc-overlay-animation-distance)}.dialog:not([actual-placement])[placement*=right]{padding-inline:var(--swc-overlay-animation-distance);margin-left:calc(-1 * var(--swc-overlay-animation-distance))}.dialog:not([actual-placement])[placement*=bottom]{padding-block:var(--swc-overlay-animation-distance);margin-top:calc(-1 * var(--swc-overlay-animation-distance))}.dialog:not([actual-placement])[placement*=left]{padding-inline:var(--swc-overlay-animation-distance);margin-left:var(--swc-overlay-animation-distance)}.dialog[actual-placement*=top]{padding-block:var(--swc-overlay-animation-distance);margin-top:var(--swc-overlay-animation-distance)}.dialog[actual-placement*=right]{padding-inline:var(--swc-overlay-animation-distance);margin-left:calc(-1 * var(--swc-overlay-animation-distance))}.dialog[actual-placement*=bottom]{padding-block:var(--swc-overlay-animation-distance);margin-top:calc(-1 * var(--swc-overlay-animation-distance))}.dialog[actual-placement*=left]{padding-inline:var(--swc-overlay-animation-distance);margin-left:var(--swc-overlay-animation-distance)}slot[name=longpress-describedby-descriptor]{display:none}@supports selector(:open){.dialog{opacity:0}.dialog:open{opacity:1}}@supports selector(:popover-open){.dialog{opacity:0}.dialog:popover-open{opacity:1}}@supports (overlay:auto){.dialog{transition:all var(--cx-transition-fast,.13s), translate 0s, display var(--cx-transition-fast,.13s);transition-behavior:allow-discrete}.dialog:popover-open,.dialog:modal{display:flex}}.dialog[actual-placement]{z-index:calc(var(--swc-overlay-z-index-base,1000) + var(--swc-overlay-open-count))}@supports (not selector(:open)) and (not selector(:popover-open)){:host:not([open]) .dialog{pointer-events:none}}`;
class go extends Event {
  constructor(t, o, i) {
    super("slottable-request", {
      bubbles: !1,
      cancelable: !0,
      composed: !1
    }), this.name = t, this.data = o, this.slotName = i !== void 0 ? `${t}.${i}` : t;
  }
}
const yo = Symbol("remove-slottable-request");
class vo extends oe {
  constructor() {
    super(...arguments), this.type = Dt.Click, this.preventNextToggle = !1;
  }
  handleClick() {
    this.preventNextToggle || (this.open = !this.open), this.preventNextToggle = !1;
  }
  handlePointerdown() {
    this.preventNextToggle = this.open;
  }
  init() {
    this.abortController?.abort(), this.abortController = new AbortController();
    const { signal: t } = this.abortController;
    this.target.addEventListener("click", () => this.handleClick(), {
      signal: t
    }), this.target.addEventListener(
      "pointerdown",
      () => this.handlePointerdown(),
      { signal: t }
    );
  }
}
const bo = 300;
class wo extends oe {
  constructor() {
    super(...arguments), this.type = Dt.Hover, this.elementIds = [], this.focusedin = !1, this.pointerentered = !1;
  }
  handleTargetFocusin() {
    this.target.matches(":focus-visible") && (this.open = !0, this.focusedin = !0);
  }
  handleTargetFocusout() {
    this.focusedin = !1, !this.pointerentered && (this.open = !1);
  }
  handleTargetPointerenter() {
    this.hoverTimeout && (clearTimeout(this.hoverTimeout), this.hoverTimeout = void 0), !this.overlay?.disabled && (this.open = !0, this.pointerentered = !0);
  }
  handleTargetPointerleave() {
    this.doPointerleave();
  }
  // set a timeout once the pointer enters and the overlay is shown
  // give the user time to enter the overlay
  handleHostPointerenter() {
    this.hoverTimeout && (clearTimeout(this.hoverTimeout), this.hoverTimeout = void 0);
  }
  handleHostPointerleave() {
    this.doPointerleave();
  }
  prepareDescription() {
    if (!this.overlay.elements.length)
      return;
    const t = this.target.getRootNode(), o = this.overlay.elements[0].getRootNode(), i = this.overlay.getRootNode();
    t === i ? this.prepareOverlayRelativeDescription() : t === o && this.prepareContentRelativeDescription();
  }
  prepareOverlayRelativeDescription() {
    const t = Nt(
      this.target,
      "aria-describedby",
      [this.overlay.id]
    );
    this.releaseDescription = () => {
      t(), this.releaseDescription = it;
    };
  }
  prepareContentRelativeDescription() {
    const t = [], o = this.overlay.elements.map((s) => (t.push(s.id), s.id || (s.id = `${this.overlay.tagName.toLowerCase()}-helper-${jt()}`), s.id));
    this.elementIds = t;
    const i = Nt(
      this.target,
      "aria-describedby",
      o
    );
    this.releaseDescription = () => {
      i(), this.overlay.elements.map((s, r) => {
        s.id = this.elementIds[r];
      }), this.releaseDescription = it;
    };
  }
  doPointerleave() {
    this.pointerentered = !1;
    const t = this.target;
    this.focusedin && t.matches(":focus-visible") || (this.hoverTimeout = setTimeout(() => {
      this.open = !1;
    }, bo));
  }
  init() {
    this.abortController?.abort(), this.abortController = new AbortController();
    const { signal: t } = this.abortController;
    this.target.addEventListener("focusin", () => this.handleTargetFocusin(), {
      signal: t
    }), this.target.addEventListener(
      "focusout",
      () => this.handleTargetFocusout(),
      { signal: t }
    ), this.target.addEventListener(
      "pointerenter",
      () => this.handleTargetPointerenter(),
      { signal: t }
    ), this.target.addEventListener(
      "pointerleave",
      () => this.handleTargetPointerleave(),
      { signal: t }
    ), this.overlay && this.initOverlay();
  }
  initOverlay() {
    if (!this.abortController)
      return;
    const { signal: t } = this.abortController;
    this.overlay.addEventListener(
      "pointerenter",
      () => this.handleHostPointerenter(),
      { signal: t }
    ), this.overlay.addEventListener(
      "pointerleave",
      () => this.handleHostPointerleave(),
      { signal: t }
    );
  }
}
const xo = {
  click: vo,
  hover: wo,
  longpress: fo
};
var Eo = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, S = (e, t, o, i) => {
  for (var s = i > 1 ? void 0 : i ? Po(t, o) : t, r = e.length - 1, n; r >= 0; r--)
    (n = e[r]) && (s = (i ? n(t, o, s) : n(s)) || s);
  return i && s && Eo(t, o, s), s;
};
const Co = "showPopover" in document.createElement("div");
let ct = pi(dt);
Co ? ct = mi(ct) : ct = ui(ct);
var K;
const O = (K = class extends ct {
  constructor() {
    super(), this._delayed = !1, this.deferSlottedVisibility = !1, this._disabled = !1, this.offset = 0, this._open = !1, this.lastRequestSlottableState = !1, this.receivesFocus = "auto", this._state = "closed", this.triggerElement = null, this.type = "auto", this.wasOpen = !1, this.closeOnFocusOut = (t) => {
      if (!t.relatedTarget)
        return;
      const o = new Event("overlay-relation-query", {
        bubbles: !0,
        composed: !0
      });
      t.relatedTarget.addEventListener(o.type, (i) => {
        i.composedPath().includes(this) || (this.open = !1);
      }), t.relatedTarget.dispatchEvent(o);
    }, this.handleClose = this.handleClose.bind(this);
  }
  get delayed() {
    return this.elements.length ? this.elements[this.elements.length - 1].hasAttribute("delayed") || this._delayed : this._delayed;
  }
  set delayed(t) {
    this._delayed = t;
  }
  get disabled() {
    return this._disabled;
  }
  set disabled(t) {
    this._disabled = t, t ? (this.strategy?.abort(), this.wasOpen = this.open, this.open = !1) : (this.bindEvents(), this.open = this.open || this.wasOpen, this.wasOpen = !1);
  }
  get hasNonVirtualTrigger() {
    return !!this.triggerElement && !(this.triggerElement instanceof Ot);
  }
  get placementController() {
    return this._placementController || (this._placementController = new po(this)), this._placementController;
  }
  get open() {
    return this._open;
  }
  set open(t) {
    t && this.disabled || t !== this.open && (this.strategy?.activelyOpening && !t || (this._open = t, this.open && (K.openCount += 1), this.requestUpdate("open", !this.open), this.open && this.requestSlottable()));
  }
  get state() {
    return this._state;
  }
  set state(t) {
    if (t === this.state)
      return;
    const o = this.state;
    this._state = t, (this.state === "opened" || this.state === "closed") && this.strategy?.shouldCompleteOpen(), this.requestUpdate("state", o);
  }
  get elementResolver() {
    return this._elementResolver || (this._elementResolver = new di(this)), this._elementResolver;
  }
  get usesDialog() {
    return this.type === "modal" || this.type === "page";
  }
  get popoverValue() {
    if ("popover" in this)
      switch (this.type) {
        case "modal":
        case "page":
          return;
        case "hint":
          return "manual";
        default:
          return this.type;
      }
  }
  get requiresPosition() {
    return !(this.type === "page" || !this.open || !this.triggerElement || !this.placement && this.type !== "hint");
  }
  managePosition() {
    if (!this.requiresPosition || !this.open)
      return;
    const t = this.offset || 0, o = this.triggerElement, i = this.placement || "right", s = this.tipPadding;
    this.placementController.placeOverlay(this.dialogEl, {
      offset: t,
      placement: i,
      tipPadding: s,
      trigger: o,
      type: this.type
    });
  }
  async managePopoverOpen() {
    super.managePopoverOpen();
    const t = this.open;
    if (this.open !== t || (await this.manageDelay(t), this.open !== t) || (await this.ensureOnDOM(t), this.open !== t))
      return;
    const o = await this.makeTransition(t);
    this.open === t && await this.applyFocus(t, o);
  }
  async applyFocus(t, o) {
    if (!(this.receivesFocus === "false" || this.type === "hint")) {
      if (await k(), await k(), t === this.open && !this.open) {
        this.hasNonVirtualTrigger && this.contains(this.getRootNode().activeElement) && this.triggerElement.focus();
        return;
      }
      o?.focus();
    }
  }
  returnFocus() {
    if (this.open || this.type === "hint")
      return;
    const t = () => {
      const o = [];
      let i = document.activeElement;
      for (; i?.shadowRoot?.activeElement; )
        i = i.shadowRoot.activeElement;
      for (; i; ) {
        const s = i.assignedSlot || i.parentElement || i.getRootNode()?.host;
        s && o.push(s), i = s;
      }
      return o;
    };
    this.receivesFocus !== "false" && this.triggerElement?.focus && (this.contains(this.getRootNode().activeElement) || t().includes(this) || document.activeElement === document.body) && this.triggerElement.focus();
  }
  async manageOpen(t) {
    if (!(!this.isConnected && this.open) && (this.hasUpdated || await this.updateComplete, this.open ? (le.add(this), this.willPreventClose && (document.addEventListener(
      "pointerup",
      () => {
        this.dialogEl.classList.toggle("not-immediately-closable", !1), this.willPreventClose = !1;
      },
      { once: !0 }
    ), this.dialogEl.classList.toggle("not-immediately-closable", !0))) : (t && this.dispose(), le.remove(this)), this.open && this.state !== "opened" ? this.state = "opening" : !this.open && this.state !== "closed" && (this.state = "closing"), this.usesDialog ? this.manageDialogOpen() : this.managePopoverOpen(), this.type === "auto")) {
      const o = this.getRootNode();
      this.open ? o.addEventListener("focusout", this.closeOnFocusOut, {
        capture: !0
      }) : o.removeEventListener("focusout", this.closeOnFocusOut, {
        capture: !0
      });
    }
  }
  bindEvents() {
    this.strategy?.abort(), this.strategy = void 0, this.hasNonVirtualTrigger && this.triggerInteraction && (this.strategy = new xo[this.triggerInteraction](
      this.triggerElement,
      {
        overlay: this
      }
    ));
  }
  handleBeforetoggle(t) {
    t.newState !== "open" && this.handleBrowserClose();
  }
  handleBrowserClose() {
    if (!this.strategy?.activelyOpening) {
      this.open = !1;
      return;
    }
    this.manuallyKeepOpen();
  }
  manuallyKeepOpen() {
    this.open = !0, this.placementController.allowPlacementUpdate = !0, this.manageOpen(!1);
  }
  handleSlotchange() {
    this.elements.length ? this.hasNonVirtualTrigger && this.strategy?.prepareDescription(this.triggerElement) : this.strategy?.releaseDescription();
  }
  shouldPreventClose() {
    const t = this.willPreventClose;
    return this.willPreventClose = !1, t;
  }
  requestSlottable() {
    this.lastRequestSlottableState !== this.open && (this.open || document.body.offsetHeight, this.dispatchEvent(
      new go(
        "overlay-content",
        this.open ? {} : yo
      )
    ), this.lastRequestSlottableState = this.open);
  }
  willUpdate(t) {
    if (this.hasAttribute("id") || this.setAttribute("id", `${this.tagName.toLowerCase()}-${jt()}`), t.has("open") && (this.hasUpdated || this.open) && this.manageOpen(t.get("open")), t.has("trigger")) {
      const [i, s] = this.trigger?.split("@") || [];
      this.elementResolver.selector = i ? `#${i}` : "", this.triggerInteraction = s;
    }
    let o = !1;
    t.has(ve) && (o = this.triggerElement, this.triggerElement = this.elementResolver.element), t.has("triggerElement") && (o = t.get("triggerElement")), o !== !1 && this.bindEvents();
  }
  updated(t) {
    super.updated(t), t.has("placement") && (this.placement ? this.dialogEl.setAttribute("actual-placement", this.placement) : this.dialogEl.removeAttribute("actual-placement"), this.open && typeof t.get("placement") < "u" && this.placementController.resetOverlayPosition()), t.has("state") && this.state === "closed" && typeof t.get("state") < "u" && this.placementController.clearOverlayPosition();
  }
  renderContent() {
    return U`<slot @slotchange=${this.handleSlotchange}></slot>`;
  }
  get dialogStyleMap() {
    return {
      "--swc-overlay-open-count": K.openCount.toString()
    };
  }
  /** Reveal deferred slotted content only after the overlay reaches the opened state. */
  get deferSlottedOpened() {
    return this.deferSlottedVisibility && this.state === "opened";
  }
  handleClose() {
    this.open = !1;
  }
  renderDialog() {
    return U`<dialog class=${ht({
      "defer-slotted-opened": this.deferSlottedOpened,
      "defer-slotted-visibility": this.deferSlottedVisibility,
      dialog: !0
    })} part="dialog" placement=${Lt(
      this.requiresPosition ? this.placement || "right" : void 0
    )} style=${se(this.dialogStyleMap)} @close=${this.handleBrowserClose} @cancel=${this.handleBrowserClose} @beforetoggle=${this.handleBeforetoggle} ?is-visible=${this.state !== "closed"}>${this.renderContent()}</dialog>`;
  }
  renderPopover() {
    return U`<div class=${ht({
      "defer-slotted-opened": this.deferSlottedOpened,
      "defer-slotted-visibility": this.deferSlottedVisibility,
      dialog: !0
    })} part="dialog" placement=${Lt(
      this.requiresPosition ? this.placement || "right" : void 0
    )} popover=${Lt(this.popoverValue)} style=${se(this.dialogStyleMap)} @beforetoggle=${this.handleBeforetoggle} @close=${this.handleBrowserClose} ?is-visible=${this.state !== "closed"}>${this.renderContent()}</div>`;
  }
  render() {
    const t = this.type === "modal" || this.type === "page";
    return U`
      ${t ? this.renderDialog() : this.renderPopover()}<slot name="longpress-describedby-descriptor"></slot>`;
  }
  connectedCallback() {
    super.connectedCallback(), this.addEventListener("close", this.handleClose), this.hasUpdated && this.bindEvents();
  }
  disconnectedCallback() {
    super.disconnectedCallback(), this.removeEventListener("close", this.handleClose), this.strategy?.releaseDescription(), this.open = !1;
  }
}, K.styles = [
  ye,
  Vt`
      ${ze(mo)}
    `
], K.openCount = 1, K);
S([
  y({ type: Boolean })
], O.prototype, "delayed", 1);
S([
  y({ attribute: "defer-slotted-visibility", type: Boolean })
], O.prototype, "deferSlottedVisibility", 2);
S([
  Ct(".dialog")
], O.prototype, "dialogEl", 2);
S([
  y({ type: Boolean })
], O.prototype, "disabled", 1);
S([
  Ye({
    flatten: !0,
    selector: ':not([slot="longpress-describedby-descriptor"], slot)'
    // gather only elements slotted into the default slot
  })
], O.prototype, "elements", 2);
S([
  y({ type: Number })
], O.prototype, "offset", 2);
S([
  y({ reflect: !0, type: Boolean })
], O.prototype, "open", 1);
S([
  y()
], O.prototype, "placement", 2);
S([
  y({ attribute: "receives-focus" })
], O.prototype, "receivesFocus", 2);
S([
  Ct("slot")
], O.prototype, "slotEl", 2);
S([
  Me()
], O.prototype, "state", 1);
S([
  y({ attribute: "tip-padding", type: Number })
], O.prototype, "tipPadding", 2);
S([
  y()
], O.prototype, "trigger", 2);
S([
  y({ attribute: "trigger-element" })
], O.prototype, "triggerElement", 2);
S([
  y({ attribute: "trigger-interaction" })
], O.prototype, "triggerInteraction", 2);
S([
  y()
], O.prototype, "type", 2);
let $e = O;
const Oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  LONGPRESS_INSTRUCTIONS: ke,
  Overlay: $e
}, Symbol.toStringTag, { value: "Module" }));
Qe("cx-overlay", $e);
const Fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null
}, Symbol.toStringTag, { value: "Module" }));
function Ao(e) {
  return So(e);
}
function Ft(e) {
  return e.assignedSlot ? e.assignedSlot : e.parentNode instanceof ShadowRoot ? e.parentNode.host : e.parentNode;
}
function So(e) {
  for (let t = e; t; t = Ft(t)) if (t instanceof Element && getComputedStyle(t).display === "none") return null;
  for (let t = Ft(e); t; t = Ft(t)) {
    if (!(t instanceof Element)) continue;
    const o = getComputedStyle(t);
    if (o.display !== "contents" && (o.position !== "static" || Rt(o) || t.tagName === "BODY"))
      return t;
  }
  return null;
}
const Ro = Vt`:host{--arrow-color:var(--cx-color-neutral-1000);--arrow-size:6px;--arrow-size-diagonal:calc(var(--arrow-size) * .7071);--arrow-padding-offset:calc(var(--arrow-size-diagonal) - var(--arrow-size));-webkit-overflow-scrolling:auto;display:contents}.popup{isolation:isolate;max-width:var(--auto-size-available-width,none);max-height:var(--auto-size-available-height,none);position:absolute}.popup--use-size-middleware{width:max-content}.popup--fixed,.popup--overlay{z-index:var(--cx-z-index-dialog);position:fixed}.popup:not(.popup--active){display:none}.popup__arrow{width:calc(var(--arrow-size-diagonal) * 2);height:calc(var(--arrow-size-diagonal) * 2);background:var(--arrow-color);z-index:-1;position:absolute;rotate:45deg}.popup-hover-bridge:not(.popup-hover-bridge--visible){display:none}.popup-hover-bridge{z-index:calc(var(--cx-z-index-dropdown) - 1);clip-path:polygon(var(--hover-bridge-top-left-x,0) var(--hover-bridge-top-left-y,0), var(--hover-bridge-top-right-x,0) var(--hover-bridge-top-right-y,0), var(--hover-bridge-bottom-right-x,0) var(--hover-bridge-bottom-right-y,0), var(--hover-bridge-bottom-left-x,0) var(--hover-bridge-bottom-left-y,0));position:fixed;inset:0}`;
var To = Object.defineProperty, Do = Object.getOwnPropertyDescriptor, w = (e, t, o, i) => {
  for (var s = i > 1 ? void 0 : i ? Do(t, o) : t, r = e.length - 1, n; r >= 0; r--)
    (n = e[r]) && (s = (i ? n(t, o, s) : n(s)) || s);
  return i && s && To(t, o, s), s;
};
function Lo(e) {
  if (e == null || typeof e != "object")
    return !1;
  const t = "contextElement" in e ? e.contextElement.ownerDocument.defaultView : null;
  return "getBoundingClientRect" in e && ("contextElement" in e ? e.contextElement instanceof (t?.Element ?? Element) : !0);
}
let b = class extends Be {
  constructor() {
    super(...arguments), this.localize = new je(this), this.active = !1, this.placement = "top", this.strategy = "absolute", this.distance = 0, this.skidding = 0, this.arrow = !1, this.arrowPlacement = "anchor", this.arrowPadding = 10, this.flip = !1, this.hide = !1, this.hideBoundaryStrategy = "escaped", this.flipFallbackPlacements = "", this.flipFallbackStrategy = "best-fit", this.flipPadding = 0, this.shift = !1, this.shiftPadding = 0, this.autoSizePadding = 0, this.hoverBridge = !1, this.autoWidthFactor = 1, this.updateHoverBridge = () => {
      if (this.hoverBridge && this.anchorEl) {
        const e = this.anchorEl.getBoundingClientRect(), t = this.popup.getBoundingClientRect(), o = this.placement.includes("top") || this.placement.includes("bottom") || this.placement === "center";
        let i = 0, s = 0, r = 0, n = 0, a = 0, l = 0, c = 0, h = 0;
        o ? e.top < t.top ? (i = e.left, s = e.bottom, r = e.right, n = e.bottom, a = t.left, l = t.top, c = t.right, h = t.top) : (i = t.left, s = t.bottom, r = t.right, n = t.bottom, a = e.left, l = e.top, c = e.right, h = e.top) : e.left < t.left ? (i = e.right, s = e.top, r = t.left, n = t.top, a = e.right, l = e.bottom, c = t.left, h = t.bottom) : (i = t.right, s = t.top, r = e.left, n = e.top, a = t.right, l = t.bottom, c = e.left, h = e.bottom), this.style.setProperty("--hover-bridge-top-left-x", `${i}px`), this.style.setProperty("--hover-bridge-top-left-y", `${s}px`), this.style.setProperty("--hover-bridge-top-right-x", `${r}px`), this.style.setProperty("--hover-bridge-top-right-y", `${n}px`), this.style.setProperty(
          "--hover-bridge-bottom-left-x",
          `${a}px`
        ), this.style.setProperty(
          "--hover-bridge-bottom-left-y",
          `${l}px`
        ), this.style.setProperty(
          "--hover-bridge-bottom-right-x",
          `${c}px`
        ), this.style.setProperty(
          "--hover-bridge-bottom-right-y",
          `${h}px`
        );
      }
    };
  }
  /*
   * Use to prevent update loops when using the size middleware.
   * https://github.com/floating-ui/floating-ui/issues/1740#issuecomment-1563544849
   */
  get isSizeMiddleWareUsed() {
    return this.sync || this.autoSize;
  }
  disconnectedCallback() {
    super.disconnectedCallback(), this.stop();
  }
  connectedUpdatedCallback() {
    if (this.strategy === "overlay" && (this.start(), !ne)) {
      const e = Ie(this);
      e && (this.autoSizeBoundary = e, this.flipBoundary = e, this.shiftBoundary = e);
    }
  }
  async updated(e) {
    super.updated(e), e.has("active") && (this.active ? (this.start(), this.strategy !== "overlay" && this.emit("cx-opened")) : this.stop()), e.has("anchor") && this.handleAnchorChange(), this.active && (await this.updateComplete, this.reposition());
  }
  async handleOverlayOpened() {
    await this.updateComplete, await new Promise((e) => {
      requestAnimationFrame(() => e());
    }), this.active && this.emit("cx-opened");
  }
  async handleAnchorChange() {
    if (await this.stop(), this.anchor && typeof this.anchor == "string") {
      const e = this.getRootNode();
      this.anchorEl = e.getElementById(this.anchor);
    } else this.anchor instanceof Element || Lo(this.anchor) ? this.anchorEl = this.anchor : this.anchorEl = this.querySelector('[slot="anchor"]');
    this.anchorEl instanceof HTMLSlotElement && (this.anchorEl = this.anchorEl.assignedElements({
      flatten: !0
    })[0]), this.anchorEl instanceof Element && this.anchorEl.tagName.toLowerCase() === "cx-dialog" && (this.anchorEl = this.anchorEl?.shadowRoot?.querySelector(
      '[part="panel"]'
    )), this.anchorEl && this.start();
  }
  start() {
    !this.anchorEl || !this.isConnected || (this.cleanup = Ht(this.anchorEl, this.popup, () => {
      this.reposition();
    }));
  }
  async stop() {
    return new Promise((e) => {
      this.cleanup ? (this.cleanup(), this.cleanup = void 0, this.removeAttribute("data-current-placement"), this.style.removeProperty("--auto-size-available-width"), this.style.removeProperty("--auto-size-available-height"), requestAnimationFrame(() => e())) : e();
    });
  }
  /** Forces the popup to recalculate and reposition itself. */
  reposition() {
    if (!this.active || !this.anchorEl)
      return;
    const e = [
      // The offset middleware goes first
      this.placement === "center" ? It(
        ({ rects: t }) => -t.reference.height / 2 - t.floating.height / 2
      ) : It({ crossAxis: this.skidding, mainAxis: this.distance })
    ];
    this.sync ? e.push(
      qt({
        apply: ({ rects: t }) => {
          const o = this.sync === "width" || this.sync === "both", i = this.sync === "height" || this.sync === "both", s = this.syncElement ? this.syncElement.getBoundingClientRect() : t.reference;
          this.popup.style.width = o ? `${s.width}px` : "", this.popup.style.height = i ? `${s.height}px` : "";
        }
      })
    ) : (this.popup.style.width = "", this.popup.style.height = ""), this.flip && e.push(
      Wt({
        boundary: this.flipBoundary,
        // @ts-expect-error - We're converting a string attribute to an array here
        fallbackPlacements: this.flipFallbackPlacements,
        fallbackStrategy: this.flipFallbackStrategy === "best-fit" ? "bestFit" : "initialPlacement",
        padding: this.flipPadding
      })
    ), this.shift && e.push(
      Te({
        boundary: this.shiftBoundary,
        padding: this.shiftPadding
      })
    ), this.autoSize ? e.push(
      qt({
        apply: ({ availableHeight: t, availableWidth: o }) => {
          this.autoSize === "vertical" || this.autoSize === "both" ? this.style.setProperty(
            "--auto-size-available-height",
            `${t}px`
          ) : this.style.removeProperty("--auto-size-available-height"), this.autoSize === "horizontal" || this.autoSize === "both" ? this.style.setProperty(
            "--auto-size-available-width",
            `${o * this.autoWidthFactor}px`
          ) : this.style.removeProperty("--auto-size-available-width");
        },
        boundary: this.autoSizeBoundary,
        padding: this.autoSizePadding
      })
    ) : (this.style.removeProperty("--auto-size-available-width"), this.style.removeProperty("--auto-size-available-height")), this.arrow && e.push(
      De({
        element: this.arrowEl,
        padding: this.arrowPadding
      })
    ), this.hide && e.push(
      lo({
        boundary: this.hideBoundary,
        strategy: this.hideBoundaryStrategy
      })
    ), Le(this.anchorEl, this.popup, {
      middleware: e,
      placement: this.placement === "center" ? "bottom" : this.placement,
      platform: {
        ...Mt,
        getOffsetParent: (t) => this.strategy === "absolute" ? Mt.getOffsetParent(t, Ao) : this.strategy === "overlay" && ne ? window : We(t) || window
      },
      strategy: ["overlay", "fixed"].includes(this.strategy) ? "fixed" : "absolute"
    }).then(({ middlewareData: t, placement: o, x: i, y: s }) => {
      const r = this.localize.dir() === "rtl", n = {
        bottom: "top",
        left: "right",
        right: "left",
        top: "bottom"
      }[o.split("-")[0]];
      if (this.setAttribute("data-current-placement", o), this.anchorEl === document.body && this.placement === "center") {
        const a = window.innerWidth, l = window.innerHeight, c = this.popup.offsetWidth, h = this.popup.offsetHeight, d = (a - c) / 2, u = (l - h) / 2;
        Object.assign(this.popup.style, { left: `${d}px`, top: `${u}px` });
      } else
        Object.assign(this.popup.style, {
          left: `${i}px`,
          top: `${s}px`
        });
      if (this.arrow) {
        const a = t.arrow.x, l = t.arrow.y;
        let c = "", h = "", d = "", u = "";
        if (this.arrowPlacement === "start") {
          const p = typeof a == "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "";
          c = typeof l == "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "", h = r ? p : "", u = r ? "" : p;
        } else if (this.arrowPlacement === "end") {
          const p = typeof a == "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "";
          h = r ? "" : p, u = r ? p : "", d = typeof l == "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "";
        } else this.arrowPlacement === "center" ? (u = typeof a == "number" ? "calc(50% - var(--arrow-size-diagonal))" : "", c = typeof l == "number" ? "calc(50% - var(--arrow-size-diagonal))" : "") : (u = typeof a == "number" ? `${a}px` : "", c = typeof l == "number" ? `${l}px` : "");
        Object.assign(this.arrowEl.style, {
          bottom: d,
          left: u,
          right: h,
          top: c
        }), this.arrowEl.style.setProperty(
          n,
          "calc(var(--arrow-size-diagonal) * -1)"
        );
      }
      t.hide && Object.assign(this.popup.style, {
        opacity: t.hide.escaped ? 0 : 1,
        visibility: t.hide.escaped ? "hidden" : "visible"
      });
    }).catch(() => {
    }), requestAnimationFrame(() => {
      this.updateHoverBridge(), this.emit("cx-reposition");
    });
  }
  render() {
    const e = U`<cx-overlay ?open=${this.active} defer-slotted-visibility placement="bottom" type="manual" @cx-opened=${this.handleOverlayOpened}><div part="popup" class=${ht({
      popup: !0,
      "popup--active": this.active,
      "popup--has-arrow": this.arrow,
      "popup--overlay": !0,
      "popup--use-size-middleware": this.isSizeMiddleWareUsed
    })}><slot></slot>${this.arrow ? U`<div part="arrow" class="popup__arrow" role="presentation"></div>` : ""}</div></cx-overlay>`;
    return U`<slot name="anchor" @slotchange=${this.handleAnchorChange}></slot><span part="hover-bridge" class=${ht({
      "popup-hover-bridge": !0,
      "popup-hover-bridge--visible": this.hoverBridge && this.active
    })}></span>${Ue(
      this.strategy === "overlay",
      () => e,
      () => U`<div part="popup" class=${ht({
        popup: !0,
        "popup--active": this.active,
        "popup--fixed": this.strategy === "fixed",
        "popup--has-arrow": this.arrow,
        "popup--use-size-middleware": this.isSizeMiddleWareUsed
      })}><slot></slot>${this.arrow ? U`<div part="arrow" class="popup__arrow" role="presentation"></div>` : ""}</div>`
    )}
    `;
  }
};
b.styles = [ye, Ro];
w([
  Ct(".popup")
], b.prototype, "popup", 2);
w([
  Ct(".popup__arrow")
], b.prototype, "arrowEl", 2);
w([
  y()
], b.prototype, "anchor", 2);
w([
  y({ reflect: !0, type: Boolean })
], b.prototype, "active", 2);
w([
  y({ reflect: !0 })
], b.prototype, "placement", 2);
w([
  y({ reflect: !0 })
], b.prototype, "strategy", 2);
w([
  y({ type: Number })
], b.prototype, "distance", 2);
w([
  y({ type: Number })
], b.prototype, "skidding", 2);
w([
  y({ type: Boolean })
], b.prototype, "arrow", 2);
w([
  y({ attribute: "arrow-placement" })
], b.prototype, "arrowPlacement", 2);
w([
  y({ attribute: "arrow-padding", type: Number })
], b.prototype, "arrowPadding", 2);
w([
  y({ type: Boolean })
], b.prototype, "flip", 2);
w([
  y({ type: Boolean })
], b.prototype, "hide", 2);
w([
  y({ attribute: "hide-boundary", type: Object })
], b.prototype, "hideBoundary", 2);
w([
  y({ attribute: "hide-boundary-strategy" })
], b.prototype, "hideBoundaryStrategy", 2);
w([
  y({
    attribute: "flip-fallback-placements",
    converter: {
      fromAttribute: (e) => e.split(" ").map((t) => t.trim()).filter((t) => t !== ""),
      toAttribute: (e) => e.join(" ")
    }
  })
], b.prototype, "flipFallbackPlacements", 2);
w([
  y({ attribute: "flip-fallback-strategy" })
], b.prototype, "flipFallbackStrategy", 2);
w([
  y({ attribute: "flip-boundary", type: Object })
], b.prototype, "flipBoundary", 2);
w([
  y({ attribute: "flip-padding", type: Number })
], b.prototype, "flipPadding", 2);
w([
  y({ type: Boolean })
], b.prototype, "shift", 2);
w([
  y({ attribute: "shift-boundary", type: Object })
], b.prototype, "shiftBoundary", 2);
w([
  y({ attribute: "shift-padding", type: Number })
], b.prototype, "shiftPadding", 2);
w([
  y({ attribute: "auto-size" })
], b.prototype, "autoSize", 2);
w([
  y()
], b.prototype, "sync", 2);
w([
  y({ attribute: "sync-element" })
], b.prototype, "syncElement", 2);
w([
  y({ attribute: "auto-size-boundary", type: Object })
], b.prototype, "autoSizeBoundary", 2);
w([
  y({ attribute: "auto-size-padding", type: Number })
], b.prototype, "autoSizePadding", 2);
w([
  y({ attribute: "hover-bridge", type: Boolean })
], b.prototype, "hoverBridge", 2);
w([
  y({ attribute: "auto-width-factor" })
], b.prototype, "autoWidthFactor", 2);
w([
  Ve(200)
], b.prototype, "start", 1);
b = w([
  qe("cx-popup")
], b);
export {
  b as default
};
