import { r as d, c as n, h as e, H as l, g as r } from "./index.e6beb8d9.js";
import { c } from "./index-orsBiyT_.fc4357c3.js";
import { t as g } from "./index.esm-DBTxpXCn.fccbd562.js";
import "react";
import "react-dom";
const h = () => ":host{display:block}:host *{box-sizing:border-box}.dialog{position:fixed;z-index:var(--s-z-40);display:flex;justify-content:center;align-items:center;inset:0;border:none;padding:0;width:auto;background:transparent;max-width:none;max-height:none;overflow:visible}.dialog::backdrop{display:none}.dialog:not([open]){display:none}.dialog:not(.dialog--closing) .dialog__backdrop{animation:0.15s dialog-backdrop-fade-in}@media (prefers-reduced-motion){.dialog:not(.dialog--closing) .dialog__backdrop{animation:none}}.dialog:not(.dialog--closing) .dialog__body{animation:0.15s dialog-scale-in}@media (prefers-reduced-motion){.dialog:not(.dialog--closing) .dialog__body{animation:none}}.dialog--closing{animation:0.15s dialog-fade-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.dialog--closing{animation:none}}.dialog__backdrop{position:fixed;background-color:rgba(0, 0, 0, 0.2);inset:0}.dialog__body{z-index:var(--s-z-40);overflow-x:hidden;overflow-y:auto;width:18.5rem;max-height:90vh;padding-top:var(--s-space-24);padding-right:var(--s-space-16);padding-bottom:var(--s-space-16);padding-left:var(--s-space-16);border-radius:var(--s-border-radius-l);background-color:var(--s-surface-overlay-default);text-align:center;box-shadow:var(--s-shadow-level-3)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.dialog__body{width:25rem;border-radius:var(--s-border-radius-base)}}@media (min-width: 992px){.dialog__body{text-align:start}}.dialog__heading{margin:0;margin-bottom:var(--s-space-8);padding-right:var(--s-space-8);padding-left:var(--s-space-8);font-size:var(--s-font-size-lg);font-weight:var(--s-font-weight-semibold);line-height:var(--s-line-height-lg);min-width:0;max-width:100%;overflow-wrap:break-word}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.dialog__heading{line-height:var(--s-line-height-base)}}.dialog__content{margin-bottom:var(--s-space-20);padding-right:var(--s-space-8);padding-left:var(--s-space-8);line-height:var(--s-line-height-base);overflow-wrap:break-word}.dialog__content ::slotted(*){margin:0}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.dialog__content{font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm)}}@media (min-width: 992px){.dialog__content{margin-bottom:var(--s-space-24)}}.dialog__controls{display:flex;flex-wrap:wrap;align-items:stretch;gap:var(--s-space-8);min-width:0;width:100%}@media (min-width: 992px){.dialog__controls{flex-wrap:nowrap;justify-content:flex-end}}.dialog__actions{display:grid;gap:var(--s-space-8);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;min-width:0;max-width:100%}.dialog__actions:has(>:only-child){width:100%;grid-template-columns:minmax(0, 1fr);justify-items:end}.dialog__actions:has(>:only-child)>swirl-button{min-width:0;max-width:100%}.dialog__actions:has(>:nth-child(2)){grid-template-columns:repeat(2, minmax(0, 1fr));width:100%}@media (min-width: 992px){.dialog__actions:has(>:nth-child(2)){width:auto}}.dialog__left_controls{display:flex;align-items:center;flex-grow:1;padding-left:var(--s-space-8);width:100%;min-width:0}@media (min-width: 992px){.dialog__left_controls{width:auto}}@keyframes dialog-scale-in{from{transform:scale(0)}to{transform:scale(1)}}@keyframes dialog-backdrop-fade-in{from{opacity:0}to{opacity:1}}@keyframes dialog-fade-out{from{opacity:1}to{opacity:0}}", m = class {
  constructor(i) {
    d(this, i), this.dialogClose = n(this, "dialogClose", 7), this.dialogOpen = n(this, "dialogOpen", 7), this.primaryAction = n(this, "primaryAction", 7), this.secondaryAction = n(this, "secondaryAction", 7), this.toggleDialog = n(this, "toggleDialog", 7), this.intent = "primary", this.closing = !1, this.opening = !1, this.onClose = () => {
      this.closing = !1, this.dialogClose.emit();
    }, this.onToggle = (o) => {
      const a = {
        newState: o.newState,
        dialog: this.dialogEl
      };
      this.el.isConnected ? this.toggleDialog.emit(a) : document.dispatchEvent(new CustomEvent("toggleDialog", {
        bubbles: !0,
        composed: !0,
        detail: a
      }));
    }, this.onKeyDown = (o) => {
      o.code === "Escape" && (o.stopImmediatePropagation(), o.preventDefault(), this.close());
    }, this.onBackdropClick = () => {
      this.close();
    }, this.onPrimaryAction = (o) => {
      this.primaryAction.emit(o), this.close();
    }, this.onSecondaryAction = (o) => {
      this.secondaryAction.emit(o), this.close();
    };
  }
  componentDidLoad() {
    this.ensureOpening(), this.setDialogCustomProps();
  }
  disconnectedCallback() {
    var i;
    (i = this.dialogEl) != null && i.open && this.dialogEl.close();
  }
  ensureOpening() {
    var i;
    this.opening && !((i = this.dialogEl) != null && i.open) && this.open();
  }
  setDialogCustomProps() {
    this.dialogEl.setAttribute("closedby", "none");
  }
  async open(i) {
    this.opening = !0, this.temporaryReturnFocusTo = i, this.dialogEl && (this.dialogEl.showModal(), this.dialogOpen.emit());
  }
  async close() {
    this.closing || (this.closing = !0, setTimeout(() => {
      this.dialogEl.close(), this.customFocusReturn();
    }, 150));
  }
  customFocusReturn() {
    var t;
    const i = (t = this.temporaryReturnFocusTo) != null ? t : this.returnFocusTo;
    if (!i)
      return;
    const o = typeof i == "string" ? document.querySelector(i) : i, a = g(o, {
      includeContainer: !0,
      getShadowRoot: !0
    });
    a.length > 0 && a[0].focus(), this.temporaryReturnFocusTo = void 0;
  }
  render() {
    const i = c("dialog", { "dialog--closing": this.closing }), o = Boolean(this.el.querySelector('[slot="left-controls"]')), a = Boolean(this.secondaryActionLabel), t = Boolean(this.primaryActionLabel);
    return e(l, { key: "708ccaa68bef8d5e4dfae280b571bcb3f7faac66" }, e("dialog", { key: "4dd33c539c98ce28cd71e6ac1ddb98d28d3870bb", "aria-describedby": "content", "aria-labelledby": this.hideLabel ? void 0 : "label", "aria-label": this.hideLabel ? this.label : void 0, class: i, onClose: this.onClose, onKeyDown: this.onKeyDown, onToggle: this.onToggle, role: "alertdialog", ref: (s) => this.dialogEl = s }, e("div", { key: "eda118903dd12286cae5be5272b4a8e22e54377a", class: "dialog__backdrop", onClick: this.onBackdropClick }), e("div", { key: "674a21b5fd4412385029de514e80437931e3dd5a", class: "dialog__body", part: "dialog__body", role: "document" }, !this.hideLabel && e("h2", { key: "326f9f9ce7b0ac7cf6a0f45dc6035149b840e31b", class: "dialog__heading", part: "dialog__heading", id: "label" }, this.label), e("div", { key: "94430fd2bb927c8e0214759c9f8a383acace21a0", class: "dialog__content", part: "dialog__content", id: "content" }, e("slot", { key: "7a6309bb02a4a8b806517c58dd5670e88c1b71ef" })), e("div", { key: "64b97d60aaeed063ad7ebecacdcc0a0b65d4e4b2", class: "dialog__controls" }, o && e("div", { key: "b2c4a576b81538ae4ca4deabff165570115640bf", class: "dialog__left_controls" }, e("slot", { key: "9ef9724675aefdc19e0e3c49552df6d6b58f56ab", name: "left-controls" })), (a || t) && e("div", { key: "2325285d62d53c49f9204a6ce0619f1cbea8b2fc", class: "dialog__actions" }, a && e("swirl-button", { key: "824700139c59a3a9c96dc5592a3a3b447189eb0a", label: this.secondaryActionLabel, onClick: this.onSecondaryAction }), t && e("swirl-button", { key: "0de63d58d30b5d8b3a148d9720047429c4343af2", intent: this.intent, label: this.primaryActionLabel, onClick: this.onPrimaryAction, variant: "flat" }))))));
  }
  get el() {
    return r(this);
  }
};
m.style = h();
export {
  m as swirl_dialog
};
