import { jsx as x, jsxs as qe } from "react/jsx-runtime";
import { useCallback as E, useEffect as y, useState as I, useRef as g, useMemo as Xe, createContext as Ye, useContext as Qe, Children as Je, isValidElement as et, cloneElement as Y, useSyncExternalStore as tt } from "react";
import { s as Q } from "../index-VL0YEmOW.mjs";
import { createPortal as nt } from "react-dom";
import { $ as it, a as ot, b as J, c as at, d as rt, e as st, f as ut, g as ee, h as lt, i as F, j as w, k as ct, l as dt } from "../useFocusWithin-CoL4390f.mjs";
import { c as j, a as z } from "../index-BmAFn37q.mjs";
import { B as mt } from "../Button-D32Avk2j.mjs";
import { Close as ft } from "@spark-ui/icons/Close";
import { I as te } from "../Icon-D1RueiPY.mjs";
import { I as bt } from "../IconButton-BY3gYXtU.mjs";
function pt(t) {
  let e = E((o) => t.subscribe(o), [
    t
  ]), n = E(() => t.visibleToasts, [
    t
  ]);
  return {
    visibleToasts: Q.useSyncExternalStore(e, n, n),
    add: (o, r) => t.add(o, r),
    close: (o) => t.close(o),
    remove: (o) => t.remove(o),
    pauseAll: () => t.pauseAll(),
    resumeAll: () => t.resumeAll()
  };
}
class ht {
  /** Subscribes to updates to the visible toasts. */
  subscribe(e) {
    return this.subscriptions.add(e), () => this.subscriptions.delete(e);
  }
  /** Adds a new toast to the queue. */
  add(e, n = {}) {
    let i = Math.random().toString(36), o = {
      ...n,
      content: e,
      key: i,
      timer: n.timeout ? new vt(() => this.close(i), n.timeout) : void 0
    }, r = 0, s = this.queue.length;
    for (; r < s; ) {
      let c = Math.floor((r + s) / 2);
      (o.priority || 0) > (this.queue[c].priority || 0) ? s = c : r = c + 1;
    }
    this.queue.splice(r, 0, o), o.animation = r < this.maxVisibleToasts ? "entering" : "queued";
    let a = this.maxVisibleToasts;
    for (; a < this.queue.length; ) this.queue[a++].animation = "queued";
    return this.updateVisibleToasts({
      action: "add"
    }), i;
  }
  /**
  * Closes a toast. If `hasExitAnimation` is true, the toast
  * transitions to an "exiting" state instead of being removed immediately.
  */
  close(e) {
    let n = this.queue.findIndex((r) => r.key === e);
    if (n >= 0) {
      var i, o;
      (i = (o = this.queue[n]).onClose) === null || i === void 0 || i.call(o), this.queue.splice(n, 1);
    }
    this.updateVisibleToasts({
      action: "close",
      key: e
    });
  }
  /** Removes a toast from the visible toasts after an exiting animation. */
  remove(e) {
    this.updateVisibleToasts({
      action: "remove",
      key: e
    });
  }
  updateVisibleToasts(e) {
    let { action: n, key: i } = e, o = this.queue.slice(0, this.maxVisibleToasts);
    if (n === "add" && this.hasExitAnimation) {
      let r = this.visibleToasts.filter((s) => !o.some((a) => s.key === a.key)).map((s) => ({
        ...s,
        animation: "exiting"
      }));
      this.visibleToasts = r.concat(o).sort((s, a) => {
        var c, u;
        return ((c = a.priority) !== null && c !== void 0 ? c : 0) - ((u = s.priority) !== null && u !== void 0 ? u : 0);
      });
    } else n === "close" && this.hasExitAnimation ? this.visibleToasts = this.visibleToasts.map((r) => r.key !== i ? r : {
      ...r,
      animation: "exiting"
    }) : this.visibleToasts = o;
    for (let r of this.subscriptions) r();
  }
  /** Pauses the timers for all visible toasts. */
  pauseAll() {
    for (let e of this.visibleToasts) e.timer && e.timer.pause();
  }
  /** Resumes the timers for all visible toasts. */
  resumeAll() {
    for (let e of this.visibleToasts) e.timer && e.timer.resume();
  }
  constructor(e) {
    this.queue = [], this.subscriptions = /* @__PURE__ */ new Set(), this.visibleToasts = [];
    var n;
    this.maxVisibleToasts = (n = e?.maxVisibleToasts) !== null && n !== void 0 ? n : 1;
    var i;
    this.hasExitAnimation = (i = e?.hasExitAnimation) !== null && i !== void 0 ? i : !1;
  }
}
class vt {
  reset(e) {
    this.remaining = e, this.resume();
  }
  pause() {
    this.timerId != null && (clearTimeout(this.timerId), this.timerId = null, this.remaining -= Date.now() - this.startTime);
  }
  resume() {
    this.remaining <= 0 || (this.startTime = Date.now(), this.timerId = setTimeout(() => {
      this.timerId = null, this.remaining = 0, this.callback();
    }, this.remaining));
  }
  constructor(e, n) {
    this.startTime = null, this.remaining = n, this.callback = e;
  }
}
var ne = {};
ne = {
  close: "إغلاق",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} إشعار`,
    other: () => `${e.number(t.count)} إشعارات`
  })}.`
};
var ie = {};
ie = {
  close: "Затвори",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} известие`,
    other: () => `${e.number(t.count)} известия`
  })}.`
};
var oe = {};
oe = {
  close: "Zavřít",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} oznámení`,
    other: () => `${e.number(t.count)} oznámení`
  })}.`
};
var ae = {};
ae = {
  close: "Luk",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} besked`,
    other: () => `${e.number(t.count)} beskeder`
  })}.`
};
var re = {};
re = {
  close: "Schließen",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} Benachrichtigung`,
    other: () => `${e.number(t.count)} Benachrichtigungen`
  })}.`
};
var se = {};
se = {
  close: "Κλείσιμο",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} ειδοποίηση`,
    other: () => `${e.number(t.count)} ειδοποιήσεις`
  })}.`
};
var ue = {};
ue = {
  close: "Close",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} notification`,
    other: () => `${e.number(t.count)} notifications`
  })}.`
};
var le = {};
le = {
  close: "Cerrar",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} notificación`,
    other: () => `${e.number(t.count)} notificaciones`
  })}.`
};
var ce = {};
ce = {
  close: "Sule",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} teatis`,
    other: () => `${e.number(t.count)} teatist`
  })}.`
};
var de = {};
de = {
  close: "Sulje",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} ilmoitus`,
    other: () => `${e.number(t.count)} ilmoitusta`
  })}.`
};
var me = {};
me = {
  close: "Fermer",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} notification`,
    other: () => `${e.number(t.count)} notifications`
  })}.`
};
var fe = {};
fe = {
  close: "סגור",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} התראה`,
    other: () => `${e.number(t.count)} התראות`
  })}.`
};
var be = {};
be = {
  close: "Zatvori",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} obavijest`,
    other: () => `${e.number(t.count)} obavijesti`
  })}.`
};
var pe = {};
pe = {
  close: "Bezárás",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} értesítés`,
    other: () => `${e.number(t.count)} értesítés`
  })}.`
};
var he = {};
he = {
  close: "Chiudi",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} notifica`,
    other: () => `${e.number(t.count)} notifiche`
  })}.`
};
var ve = {};
ve = {
  close: "閉じる",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} 個の通知`,
    other: () => `${e.number(t.count)} 個の通知`
  })}。`
};
var $e = {};
$e = {
  close: "닫기",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)}개 알림`,
    other: () => `${e.number(t.count)}개 알림`
  })}.`
};
var ge = {};
ge = {
  close: "Uždaryti",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} pranešimas`,
    other: () => `${e.number(t.count)} pranešimai`
  })}.`
};
var xe = {};
xe = {
  close: "Aizvērt",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} paziņojums`,
    other: () => `${e.number(t.count)} paziņojumi`
  })}.`
};
var ke = {};
ke = {
  close: "Lukk",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} varsling`,
    other: () => `${e.number(t.count)} varsler`
  })}.`
};
var Ee = {};
Ee = {
  close: "Sluiten",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} melding`,
    other: () => `${e.number(t.count)} meldingen`
  })}.`
};
var ye = {};
ye = {
  close: "Zamknij",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} powiadomienie`,
    few: () => `${e.number(t.count)} powiadomienia`,
    many: () => `${e.number(t.count)} powiadomień`,
    other: () => `${e.number(t.count)} powiadomienia`
  })}.`
};
var we = {};
we = {
  close: "Fechar",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} notificação`,
    other: () => `${e.number(t.count)} notificações`
  })}.`
};
var Le = {};
Le = {
  close: "Fechar",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} notificação`,
    other: () => `${e.number(t.count)} notificações`
  })}.`
};
var Te = {};
Te = {
  close: "Închideţi",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} notificare`,
    other: () => `${e.number(t.count)} notificări`
  })}.`
};
var Se = {};
Se = {
  close: "Закрыть",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} уведомление`,
    other: () => `${e.number(t.count)} уведомления`
  })}.`
};
var Ie = {};
Ie = {
  close: "Zatvoriť",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} oznámenie`,
    few: () => `${e.number(t.count)} oznámenia`,
    other: () => `${e.number(t.count)} oznámení`
  })}.`
};
var Ae = {};
Ae = {
  close: "Zapri",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} obvestilo`,
    two: () => `${e.number(t.count)} obvestili`,
    few: () => `${e.number(t.count)} obvestila`,
    other: () => `${e.number(t.count)} obvestil`
  })}.`
};
var Ce = {};
Ce = {
  close: "Zatvori",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} obaveštenje`,
    other: () => `${e.number(t.count)} obaveštenja`
  })}.`
};
var Ne = {};
Ne = {
  close: "Stäng",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} meddelande`,
    other: () => `${e.number(t.count)} meddelanden`
  })}.`
};
var Pe = {};
Pe = {
  close: "Kapat",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} bildirim`,
    other: () => `${e.number(t.count)} bildirim`
  })}.`
};
var Be = {};
Be = {
  close: "Закрити",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} сповіщення`,
    other: () => `${e.number(t.count)} сповіщення`
  })}.`
};
var _e = {};
_e = {
  close: "关闭",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} 个通知`,
    other: () => `${e.number(t.count)} 个通知`
  })}。`
};
var He = {};
He = {
  close: "關閉",
  notifications: (t, e) => `${e.plural(t.count, {
    one: () => `${e.number(t.count)} 個通知`,
    other: () => `${e.number(t.count)} 個通知`
  })}。`
};
var G = {};
G = {
  "ar-AE": ne,
  "bg-BG": ie,
  "cs-CZ": oe,
  "da-DK": ae,
  "de-DE": re,
  "el-GR": se,
  "en-US": ue,
  "es-ES": le,
  "et-EE": ce,
  "fi-FI": de,
  "fr-FR": me,
  "he-IL": fe,
  "hr-HR": be,
  "hu-HU": pe,
  "it-IT": he,
  "ja-JP": ve,
  "ko-KR": $e,
  "lt-LT": ge,
  "lv-LV": xe,
  "nb-NO": ke,
  "nl-NL": Ee,
  "pl-PL": ye,
  "pt-BR": we,
  "pt-PT": Le,
  "ro-RO": Te,
  "ru-RU": Se,
  "sk-SK": Ie,
  "sl-SI": Ae,
  "sr-SP": Ce,
  "sv-SE": Ne,
  "tr-TR": Pe,
  "uk-UA": Be,
  "zh-CN": _e,
  "zh-TW": He
};
function $t(t) {
  return t && t.__esModule ? t.default : t;
}
function gt(t, e, n) {
  let { key: i, timer: o, timeout: r } = t.toast;
  y(() => {
    if (!(o == null || r == null))
      return o.reset(r), () => {
        o.pause();
      };
  }, [
    o,
    r
  ]);
  let s = it(), a = ot(), c = J($t(G), "@react-aria/toast"), [u, f] = I(!1);
  return y(() => {
    f(!0);
  }, []), {
    toastProps: {
      ...at(t, {
        labelable: !0
      }),
      role: "alertdialog",
      "aria-modal": "false",
      "aria-labelledby": t["aria-labelledby"] || s,
      "aria-describedby": t["aria-describedby"] || a,
      tabIndex: 0
    },
    contentProps: {
      role: "alert",
      "aria-atomic": "true",
      "aria-hidden": u ? void 0 : "true"
    },
    titleProps: {
      id: s
    },
    descriptionProps: {
      id: a
    },
    closeButtonProps: {
      "aria-label": c.format("close"),
      onPress: () => e.close(i)
    }
  };
}
let S = !1, L = 0;
function O() {
  S = !0, setTimeout(() => {
    S = !1;
  }, 50);
}
function Z(t) {
  t.pointerType === "touch" && O();
}
function xt() {
  if (!(typeof document > "u"))
    return L === 0 && (typeof PointerEvent < "u" ? document.addEventListener("pointerup", Z) : process.env.NODE_ENV === "test" && document.addEventListener("touchend", O)), L++, () => {
      L--, !(L > 0) && (typeof PointerEvent < "u" ? document.removeEventListener("pointerup", Z) : process.env.NODE_ENV === "test" && document.removeEventListener("touchend", O));
    };
}
function kt(t) {
  let { onHoverStart: e, onHoverChange: n, onHoverEnd: i, isDisabled: o } = t, [r, s] = I(!1), a = g({
    isHovered: !1,
    ignoreEmulatedMouseEvents: !1,
    pointerType: "",
    target: null
  }).current;
  y(xt, []);
  let { addGlobalListener: c, removeAllGlobalListeners: u } = rt(), { hoverProps: f, triggerHoverEnd: h } = Xe(() => {
    let b = (d, p) => {
      if (a.pointerType = p, o || p === "touch" || a.isHovered || !d.currentTarget.contains(d.target)) return;
      a.isHovered = !0;
      let m = d.currentTarget;
      a.target = m, c(st(d.target), "pointerover", ($) => {
        a.isHovered && a.target && !ut(a.target, $.target) && v($, $.pointerType);
      }, {
        capture: !0
      }), e && e({
        type: "hoverstart",
        target: m,
        pointerType: p
      }), n && n(!0), s(!0);
    }, v = (d, p) => {
      let m = a.target;
      a.pointerType = "", a.target = null, !(p === "touch" || !a.isHovered || !m) && (a.isHovered = !1, u(), i && i({
        type: "hoverend",
        target: m,
        pointerType: p
      }), n && n(!1), s(!1));
    }, l = {};
    return typeof PointerEvent < "u" ? (l.onPointerEnter = (d) => {
      S && d.pointerType === "mouse" || b(d, d.pointerType);
    }, l.onPointerLeave = (d) => {
      !o && d.currentTarget.contains(d.target) && v(d, d.pointerType);
    }) : process.env.NODE_ENV === "test" && (l.onTouchStart = () => {
      a.ignoreEmulatedMouseEvents = !0;
    }, l.onMouseEnter = (d) => {
      !a.ignoreEmulatedMouseEvents && !S && b(d, "mouse"), a.ignoreEmulatedMouseEvents = !1;
    }, l.onMouseLeave = (d) => {
      !o && d.currentTarget.contains(d.target) && v(d, "mouse");
    }), {
      hoverProps: l,
      triggerHoverEnd: v
    };
  }, [
    e,
    n,
    i,
    o,
    a,
    c,
    u
  ]);
  return y(() => {
    o && h({
      currentTarget: a.target
    }, a.pointerType);
  }, [
    o
  ]), {
    hoverProps: f,
    isHovered: r
  };
}
const De = 1, V = Symbol.for("react-aria-landmark-manager");
function Et(t) {
  return document.addEventListener("react-aria-landmark-manager-change", t), () => document.removeEventListener("react-aria-landmark-manager-change", t);
}
function q() {
  if (typeof document > "u") return null;
  let t = document[V];
  return t && t.version >= De ? t : (document[V] = new wt(), document.dispatchEvent(new CustomEvent("react-aria-landmark-manager-change")), document[V]);
}
function yt() {
  return Q.useSyncExternalStore(Et, q, q);
}
class wt {
  setupIfNeeded() {
    this.isListening || (document.addEventListener("keydown", this.f6Handler, {
      capture: !0
    }), document.addEventListener("focusin", this.focusinHandler, {
      capture: !0
    }), document.addEventListener("focusout", this.focusoutHandler, {
      capture: !0
    }), this.isListening = !0);
  }
  teardownIfNeeded() {
    !this.isListening || this.landmarks.length > 0 || this.refCount > 0 || (document.removeEventListener("keydown", this.f6Handler, {
      capture: !0
    }), document.removeEventListener("focusin", this.focusinHandler, {
      capture: !0
    }), document.removeEventListener("focusout", this.focusoutHandler, {
      capture: !0
    }), this.isListening = !1);
  }
  focusLandmark(e, n) {
    var i, o;
    (o = this.landmarks.find((r) => r.ref.current === e)) === null || o === void 0 || (i = o.focus) === null || i === void 0 || i.call(o, n);
  }
  /**
  * Return set of landmarks with a specific role.
  */
  getLandmarksByRole(e) {
    return new Set(this.landmarks.filter((n) => n.role === e));
  }
  /**
  * Return first landmark with a specific role.
  */
  getLandmarkByRole(e) {
    return this.landmarks.find((n) => n.role === e);
  }
  addLandmark(e) {
    if (this.setupIfNeeded(), this.landmarks.find((o) => o.ref === e.ref) || !e.ref.current) return;
    if (this.landmarks.filter((o) => o.role === "main").length > 1 && process.env.NODE_ENV !== "production" && console.error('Page can contain no more than one landmark with the role "main".'), this.landmarks.length === 0) {
      this.landmarks = [
        e
      ], this.checkLabels(e.role);
      return;
    }
    let n = 0, i = this.landmarks.length - 1;
    for (; n <= i; ) {
      let o = Math.floor((n + i) / 2), r = e.ref.current.compareDocumentPosition(this.landmarks[o].ref.current);
      !!(r & Node.DOCUMENT_POSITION_PRECEDING || r & Node.DOCUMENT_POSITION_CONTAINS) ? n = o + 1 : i = o - 1;
    }
    this.landmarks.splice(n, 0, e), this.checkLabels(e.role);
  }
  updateLandmark(e) {
    let n = this.landmarks.findIndex((i) => i.ref === e.ref);
    n >= 0 && (this.landmarks[n] = {
      ...this.landmarks[n],
      ...e
    }, this.checkLabels(this.landmarks[n].role));
  }
  removeLandmark(e) {
    this.landmarks = this.landmarks.filter((n) => n.ref !== e), this.teardownIfNeeded();
  }
  /**
  * Warn if there are 2+ landmarks with the same role but no label.
  * Labels for landmarks with the same role must also be unique.
  *
  * See https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/.
  */
  checkLabels(e) {
    let n = this.getLandmarksByRole(e);
    if (n.size > 1) {
      let i = [
        ...n
      ].filter((o) => !o.label);
      if (i.length > 0 && process.env.NODE_ENV !== "production") console.warn(`Page contains more than one landmark with the '${e}' role. If two or more landmarks on a page share the same role, all must be labeled with an aria-label or aria-labelledby attribute: `, i.map((o) => o.ref.current));
      else if (process.env.NODE_ENV !== "production") {
        let o = [
          ...n
        ].map((s) => s.label);
        o.filter((s, a) => o.indexOf(s) !== a).forEach((s) => {
          console.warn(`Page contains more than one landmark with the '${e}' role and '${s}' label. If two or more landmarks on a page share the same role, they must have unique labels: `, [
            ...n
          ].filter((a) => a.label === s).map((a) => a.ref.current));
        });
      }
    }
  }
  /**
  * Get the landmark that is the closest parent in the DOM.
  * Returns undefined if no parent is a landmark.
  */
  closestLandmark(e) {
    let n = new Map(this.landmarks.map((o) => [
      o.ref.current,
      o
    ])), i = e;
    for (; i && !n.has(i) && i !== document.body && i.parentElement; ) i = i.parentElement;
    return n.get(i);
  }
  /**
  * Gets the next landmark, in DOM focus order, or previous if backwards is specified.
  * If last landmark, next should be the first landmark.
  * If not inside a landmark, will return first landmark.
  * Returns undefined if there are no landmarks.
  */
  getNextLandmark(e, { backward: n }) {
    var i;
    let o = this.closestLandmark(e), r = n ? this.landmarks.length - 1 : 0;
    o && (r = this.landmarks.indexOf(o) + (n ? -1 : 1));
    let s = () => {
      if (r < 0) {
        if (!e.dispatchEvent(new CustomEvent("react-aria-landmark-navigation", {
          detail: {
            direction: "backward"
          },
          bubbles: !0,
          cancelable: !0
        }))) return !0;
        r = this.landmarks.length - 1;
      } else if (r >= this.landmarks.length) {
        if (!e.dispatchEvent(new CustomEvent("react-aria-landmark-navigation", {
          detail: {
            direction: "forward"
          },
          bubbles: !0,
          cancelable: !0
        }))) return !0;
        r = 0;
      }
      return r < 0 || r >= this.landmarks.length;
    };
    if (s()) return;
    let a = r;
    for (; !((i = this.landmarks[r].ref.current) === null || i === void 0) && i.closest("[aria-hidden=true]"); ) {
      if (r += n ? -1 : 1, s()) return;
      if (r === a) break;
    }
    return this.landmarks[r];
  }
  /**
  * Look at next landmark. If an element was previously focused inside, restore focus there.
  * If not, focus the landmark itself.
  * If no landmarks at all, or none with focusable elements, don't move focus.
  */
  f6Handler(e) {
    e.key === "F6" && (e.altKey ? this.focusMain() : this.navigate(e.target, e.shiftKey)) && (e.preventDefault(), e.stopPropagation());
  }
  focusMain() {
    let e = this.getLandmarkByRole("main");
    return e && e.ref.current && document.contains(e.ref.current) ? (this.focusLandmark(e.ref.current, "forward"), !0) : !1;
  }
  navigate(e, n) {
    let i = this.getNextLandmark(e, {
      backward: n
    });
    if (!i) return !1;
    if (i.lastFocused) {
      let o = i.lastFocused;
      if (document.body.contains(o))
        return o.focus(), !0;
    }
    return i.ref.current && document.contains(i.ref.current) ? (this.focusLandmark(i.ref.current, n ? "backward" : "forward"), !0) : !1;
  }
  /**
  * Sets lastFocused for a landmark, if focus is moved within that landmark.
  * Lets the last focused landmark know it was blurred if something else is focused.
  */
  focusinHandler(e) {
    let n = this.closestLandmark(e.target);
    n && n.ref.current !== e.target && this.updateLandmark({
      ref: n.ref,
      lastFocused: e.target
    });
    let i = e.relatedTarget;
    if (i) {
      let o = this.closestLandmark(i);
      o && o.ref.current === i && o.blur();
    }
  }
  /**
  * Track if the focus is lost to the body. If it is, do cleanup on the landmark that last had focus.
  */
  focusoutHandler(e) {
    let n = e.target, i = e.relatedTarget;
    if (!i || i === document) {
      let o = this.closestLandmark(n);
      o && o.ref.current === n && o.blur();
    }
  }
  createLandmarkController() {
    let e = this;
    return e.refCount++, e.setupIfNeeded(), {
      navigate(n, i) {
        let o = i?.from || document.activeElement;
        return e.navigate(o, n === "backward");
      },
      focusNext(n) {
        let i = n?.from || document.activeElement;
        return e.navigate(i, !1);
      },
      focusPrevious(n) {
        let i = n?.from || document.activeElement;
        return e.navigate(i, !0);
      },
      focusMain() {
        return e.focusMain();
      },
      dispose() {
        e && (e.refCount--, e.teardownIfNeeded(), e = null);
      }
    };
  }
  registerLandmark(e) {
    return this.landmarks.find((n) => n.ref === e.ref) ? this.updateLandmark(e) : this.addLandmark(e), () => this.removeLandmark(e.ref);
  }
  constructor() {
    this.landmarks = [], this.isListening = !1, this.refCount = 0, this.version = De, this.f6Handler = this.f6Handler.bind(this), this.focusinHandler = this.focusinHandler.bind(this), this.focusoutHandler = this.focusoutHandler.bind(this);
  }
}
function Lt(t, e) {
  const { role: n, "aria-label": i, "aria-labelledby": o, focus: r } = t;
  let s = yt(), a = i || o, [c, u] = I(!1), f = E(() => {
    u(!0);
  }, [
    u
  ]), h = E(() => {
    u(!1);
  }, [
    u
  ]);
  return ee(() => {
    if (s) return s.registerLandmark({
      ref: e,
      label: a,
      role: n,
      focus: r || f,
      blur: h
    });
  }, [
    s,
    a,
    e,
    n,
    r,
    f,
    h
  ]), y(() => {
    var b;
    c && ((b = e.current) === null || b === void 0 || b.focus());
  }, [
    c,
    e
  ]), {
    landmarkProps: {
      role: n,
      tabIndex: c ? -1 : void 0,
      "aria-label": i,
      "aria-labelledby": o
    }
  };
}
function Tt(t) {
  return t && t.__esModule ? t.default : t;
}
function St(t, e, n) {
  let i = J(Tt(G), "@react-aria/toast"), { landmarkProps: o } = Lt({
    role: "region",
    "aria-label": t["aria-label"] || i.format("notifications", {
      count: e.visibleToasts.length
    })
  }, n), r = g(!1), s = g(!1), a = lt(() => {
    r.current || s.current ? e.pauseAll() : e.resumeAll();
  }), { hoverProps: c } = kt({
    onHoverStart: () => {
      r.current = !0, a();
    },
    onHoverEnd: () => {
      r.current = !1, a();
    }
  }), u = g([]), f = g(e.visibleToasts), h = g(null);
  ee(() => {
    if (h.current === -1 || e.visibleToasts.length === 0 || !n.current) {
      u.current = [], f.current = e.visibleToasts;
      return;
    }
    if (u.current = [
      ...n.current.querySelectorAll('[role="alertdialog"]')
    ], f.current.length === e.visibleToasts.length && e.visibleToasts.every((m, $) => m.key === f.current[$].key)) {
      f.current = e.visibleToasts;
      return;
    }
    let l = f.current.map((m, $) => ({
      ...m,
      i: $,
      isRemoved: !e.visibleToasts.some((k) => m.key === k.key)
    })), d = l.findIndex((m) => m.i === h.current && m.isRemoved);
    if (d > -1) {
      var p;
      if (F() === "pointer" && (!((p = b.current) === null || p === void 0) && p.isConnected)) w(b.current);
      else {
        let m = 0, $, k;
        for (; m <= d; )
          l[m].isRemoved || (k = Math.max(0, m - 1)), m++;
        for (; m < l.length; ) {
          if (!l[m].isRemoved) {
            $ = m - 1;
            break;
          }
          m++;
        }
        k === void 0 && $ === void 0 && (k = 0), k >= 0 && k < u.current.length ? w(u.current[k]) : $ >= 0 && $ < u.current.length && w(u.current[$]);
      }
    }
    f.current = e.visibleToasts;
  }, [
    e.visibleToasts,
    n,
    a
  ]);
  let b = g(null), { focusWithinProps: v } = ct({
    onFocusWithin: (l) => {
      s.current = !0, b.current = l.relatedTarget, a();
    },
    onBlurWithin: () => {
      s.current = !1, b.current = null, a();
    }
  });
  return y(() => {
    var l;
    e.visibleToasts.length === 0 && (!((l = b.current) === null || l === void 0) && l.isConnected) && (F() === "pointer" ? w(b.current) : b.current.focus(), b.current = null);
  }, [
    n,
    e.visibleToasts.length
  ]), y(() => () => {
    var l;
    !((l = b.current) === null || l === void 0) && l.isConnected && (F() === "pointer" ? w(b.current) : b.current.focus(), b.current = null);
  }, [
    n
  ]), {
    regionProps: dt(o, c, v, {
      tabIndex: -1,
      // Mark the toast region as a "top layer", so that it:
      //   - is not aria-hidden when opening an overlay
      //   - allows focus even outside a containing focus scope
      //   - doesn’t dismiss overlays when clicking on it, even though it is outside
      // @ts-ignore
      "data-react-aria-top-layer": !0,
      // listen to focus events separate from focuswithin because that will only fire once
      // and we need to follow all focus changes
      onFocus: (l) => {
        let d = l.target.closest('[role="alertdialog"]');
        h.current = u.current.findIndex((p) => p === d);
      },
      onBlur: () => {
        h.current = -1;
      }
    })
  };
}
const It = [
  {
    design: "filled",
    intent: "success",
    class: ["bg-success text-on-success"]
  },
  {
    design: "filled",
    intent: "alert",
    class: ["bg-alert text-on-alert"]
  },
  {
    design: "filled",
    intent: "error",
    class: ["bg-error text-on-error"]
  },
  {
    design: "filled",
    intent: "info",
    class: ["bg-info text-on-info"]
  },
  {
    design: "filled",
    intent: "neutral",
    class: ["bg-neutral text-on-neutral"]
  },
  {
    design: "filled",
    intent: "main",
    class: ["bg-main text-on-main"]
  },
  {
    design: "filled",
    intent: "basic",
    class: ["bg-basic text-on-basic"]
  },
  {
    design: "filled",
    intent: "support",
    class: ["bg-support text-on-support"]
  },
  {
    design: "filled",
    intent: "accent",
    class: ["bg-accent text-on-accent"]
  },
  {
    design: "filled",
    intent: "inverse",
    class: ["bg-surface-inverse text-on-surface-inverse"]
  }
], At = [
  {
    design: "tinted",
    intent: "success",
    class: ["bg-success-container text-on-success-container"]
  },
  {
    design: "tinted",
    intent: "alert",
    class: ["bg-alert-container text-on-alert-container"]
  },
  {
    design: "tinted",
    intent: "error",
    class: ["bg-error-container text-on-error-container"]
  },
  {
    design: "tinted",
    intent: "info",
    class: ["bg-info-container text-on-info-container"]
  },
  {
    design: "tinted",
    intent: "neutral",
    class: ["bg-neutral-container text-on-neutral-container"]
  },
  {
    design: "tinted",
    intent: "main",
    class: ["bg-main-container text-on-main-container"]
  },
  {
    design: "tinted",
    intent: "basic",
    class: ["bg-basic-container text-on-basic-container"]
  },
  {
    design: "tinted",
    intent: "support",
    class: ["bg-support-container text-on-support-container"]
  },
  {
    design: "tinted",
    intent: "accent",
    class: ["bg-accent-container text-on-accent-container"]
  },
  {
    design: "tinted",
    intent: "inverse",
    class: ["bg-surface-inverse text-on-surface-inverse"]
  }
], Ct = j(
  [
    "rounded-md shadow-sm",
    "max-w-[600px]",
    "cursor-default pointer-events-auto touch-none select-none",
    "absolute",
    /**
     * Focus
     */
    "group-focus-visible:outline-hidden group-focus-visible:u-outline group-not-focus-visible:ring-inset",
    /**
     * Positionning
     */
    "group-data-[position=bottom]:bottom-0 group-data-[position=bottom-left]:bottom-0 group-data-[position=bottom-right]:bottom-0",
    "group-data-[position=top]:top-0 group-data-[position=top-left]:top-0 group-data-[position=top-right]:top-0",
    /**
     * Animation and opacity
     */
    "animation-duration-400",
    "[animation-fill-mode: forwards]!",
    "data-[animation=queued]:animate-fade-in",
    "data-[animation=entering]:animation-ease-decelerate-back",
    "data-[animation=exiting]:animation-ease-accelerate",
    // Parent position bottom|bottom-left|bottom-right
    "data-[animation=entering]:group-data-[position=bottom]:[&:not([data-swipe])]:animate-slide-in-bottom",
    "data-[animation=exiting]:opacity-0 data-[animation=exiting]:transition-opacity",
    "data-[animation=exiting]:group-data-[position=bottom]:[&:not([data-swipe])]:animate-slide-out-bottom",
    "data-[animation=entering]:group-data-[position=bottom-left]:[&:not([data-swipe])]:animate-slide-in-bottom",
    "data-[animation=exiting]:group-data-[position=bottom-left]:[&:not([data-swipe])]:animate-slide-out-bottom",
    "data-[animation=entering]:group-data-[position=bottom-right]:[&:not([data-swipe])]:animate-slide-in-bottom",
    "data-[animation=exiting]:group-data-[position=bottom-right]:[&:not([data-swipe])]:animate-slide-out-bottom",
    // Parent position top|top-left|top-right
    "data-[animation=entering]:group-data-[position=top]:[&:not([data-swipe])]:animate-slide-in-top",
    "data-[animation=exiting]:group-data-[position=top]:[&:not([data-swipe])]:animate-slide-out-top",
    "data-[animation=entering]:group-data-[position=top-left]:[&:not([data-swipe])]:animate-slide-in-top",
    "data-[animation=exiting]:group-data-[position=top-left]:[&:not([data-swipe])]:animate-slide-out-top",
    "data-[animation=entering]:group-data-[position=top-right]:[&:not([data-swipe])]:animate-slide-in-top",
    "data-[animation=exiting]:group-data-[position=top-right]:[&:not([data-swipe])]:animate-slide-out-top",
    /**
     * Swipe
     */
    "data-[swipe=move]:data-[swipe-direction=right]:translate-x-(--swipe-position-x)",
    "data-[swipe=move]:data-[swipe-direction=left]:translate-x-(--swipe-position-x)",
    "data-[swipe=cancel]:translate-x-0",
    "data-[swipe=end]:data-[swipe-direction=right]:animate-standalone-swipe-out-right",
    "data-[swipe=end]:data-[swipe-direction=left]:animate-standalone-swipe-out-left"
  ],
  {
    variants: {
      /**
       * Set different look and feel
       * @default 'filled'
       */
      design: {
        filled: "",
        tinted: ""
      },
      /**
       * Set color intent
       * @default 'neutral'
       */
      intent: {
        success: "",
        alert: "",
        error: "",
        info: "",
        neutral: "",
        main: "",
        basic: "",
        support: "",
        accent: "",
        inverse: ""
      }
    },
    compoundVariants: [...It, ...At],
    defaultVariants: {
      design: "filled",
      intent: "neutral"
    }
  }
), Nt = j(
  [
    "inline-grid items-center",
    "col-start-1 row-start-1",
    "pl-md pr-lg"
    // applying padding on the parent prevents VoiceOver on Safari from reading snackbar content 🤷
  ],
  {
    variants: {
      /**
       * Force action button displaying on a new line
       * @default false
       */
      actionOnNewline: {
        true: [
          "grid-rows-[52px_1fr_52px]",
          "grid-cols-[min-content_1fr_min-content]",
          "[grid-template-areas:'icon_message_close'_'._message_.'_'action_action_action']"
        ],
        false: [
          "grid-cols-[min-content_1fr_min-content_min-content]",
          "[grid-template-areas:'icon_message_action_close']"
        ]
      }
    },
    defaultVariants: {
      actionOnNewline: !1
    }
  }
), Fe = Ye({}), K = () => Qe(Fe), A = ({
  design: t = "filled",
  intent: e = "neutral",
  onClick: n,
  children: i,
  className: o,
  ref: r,
  ...s
}) => {
  const { toast: a, state: c } = K(), u = e ?? a.content.intent, f = t ?? a.content.design;
  return /* @__PURE__ */ x(
    mt,
    {
      "data-spark-component": "snackbar-item-action",
      ref: r,
      size: "md",
      shape: "rounded",
      ...u === "inverse" ? {
        design: "ghost",
        intent: "surface"
      } : {
        design: f,
        intent: u === "error" ? "danger" : u
      },
      onClick: (h) => {
        n?.(h), c.close(a.key);
      },
      style: { gridArea: "action", ...s.style },
      className: z("ml-md justify-self-end", o),
      ...s,
      children: i
    }
  );
};
A.displayName = "Snackbar.ItemAction";
const C = ({
  design: t = "filled",
  intent: e = "neutral",
  "aria-label": n,
  onClick: i,
  className: o,
  ref: r,
  ...s
}) => {
  const { toast: a, state: c } = K(), u = e ?? a.content.intent, f = t ?? a.content.design;
  return /* @__PURE__ */ x(
    bt,
    {
      "data-spark-component": "snackbar-item-close",
      ref: r,
      size: "md",
      shape: "rounded",
      ...u === "inverse" ? {
        design: "ghost",
        intent: "surface"
      } : {
        design: f,
        intent: u === "error" ? "danger" : u
      },
      "aria-label": n,
      onClick: (h) => {
        i?.(h), c.close(a.key);
      },
      style: { gridArea: "close", ...s.style },
      className: z("ml-md justify-self-end", o),
      ...s,
      children: /* @__PURE__ */ x(te, { size: "sm", children: /* @__PURE__ */ x(ft, {}) })
    }
  );
};
C.displayName = "Snackbar.ItemClose";
const N = ({
  children: t,
  className: e,
  ...n
}) => /* @__PURE__ */ x(
  te,
  {
    size: "md",
    className: z("mx-md", e),
    style: { gridArea: "icon", ...n.style },
    ...n,
    children: t
  }
);
N.displayName = "Snackbar.ItemIcon";
const X = 75, Pt = ({
  swipeRef: t,
  onSwipeStart: e,
  onSwipeMove: n,
  onSwipeCancel: i,
  onSwipeEnd: o,
  threshold: r = 10
}) => {
  const [s, a] = I(), c = g(null), u = g(null), f = g(null), h = (l) => {
    u.current = { x: l.clientX, y: l.clientY }, document.addEventListener("selectstart", (d) => d.preventDefault());
  }, b = (l) => {
    if (!u.current) return;
    const d = Math.abs(l.clientX - u.current.x), p = Math.abs(l.clientY - u.current.y);
    let m;
    d > p && d > r ? c.current = l.clientX > u.current.x ? "right" : "left" : p > r && (c.current = l.clientY > u.current.y ? "down" : "up"), c.current && (f.current ? (m = "move", f.current = { x: d, y: p }, t.current.style.setProperty(
      "--swipe-position-x",
      `${d > p ? l.clientX - u.current.x : 0}px`
    ), t.current.style.setProperty(
      "--swipe-position-y",
      `${d > p ? 0 : l.clientY - u.current.y}px`
    ), n?.({ state: m, direction: c.current })) : (m = "start", f.current = { x: d, y: p }, e?.({ state: m, direction: c.current })), a(m));
  }, v = () => {
    const l = f.current;
    if (u.current = null, f.current = null, l) {
      const { x: d, y: p } = l;
      let m;
      d > p ? d > X ? (m = "end", o?.({ state: m, direction: c.current })) : (m = "cancel", i?.({ state: m, direction: c.current })) : p > X ? (m = "end", o?.({ state: m, direction: c.current })) : (m = "cancel", i?.({ state: m, direction: c.current })), a(m), document.removeEventListener("selectstart", ($) => $.preventDefault());
    }
  };
  return y(() => {
    if (!t.current) return;
    const l = t.current;
    return l.addEventListener("pointerdown", h), document.addEventListener("pointermove", b), document.addEventListener("pointerup", v), () => {
      l.removeEventListener("pointerdown", h), document.removeEventListener("pointermove", b), document.removeEventListener("pointerup", v);
    };
  }, []), {
    state: s,
    direction: c.current
  };
}, P = ({
  "aria-label": t,
  "aria-labelledby": e,
  "aria-describedby": n,
  "aria-details": i,
  design: o,
  intent: r,
  actionOnNewline: s,
  className: a,
  children: c,
  ref: u,
  ...f
}) => {
  const h = g(null), b = typeof u != "function" && u || h, { toast: v, state: l } = K(), { state: d, direction: p } = Pt({
    swipeRef: b,
    onSwipeStart: l.pauseAll,
    onSwipeCancel: l.resumeAll,
    onSwipeEnd: ({ direction: D }) => {
      ["left", "right"].includes(`${D}`) && l.close(v.key);
    }
  }), { message: m, icon: $, isClosable: k, onAction: U, actionLabel: W } = v.content, B = r ?? v.content.intent, _ = o ?? v.content.design, Me = s ?? v.content.actionOnNewline, Oe = {
    ariaLabel: t,
    ariaLabelledby: e,
    ariaDescribedby: n,
    ariaDetails: i
  }, { toastProps: Re, titleProps: je, closeButtonProps: ze, contentProps: Ge } = gt(
    { toast: v, ...Oe },
    l
  ), H = E(
    (D) => Je.toArray(c).filter(et).find(
      (Ze) => !!Ze.type.displayName?.includes(
        D
      )
    ),
    [c]
  ), Ke = H("Snackbar.ItemIcon"), Ue = H("Snackbar.ItemAction"), We = H("Snackbar.ItemClose");
  return /* @__PURE__ */ x(
    "div",
    {
      "data-spark-component": "snackbar-item",
      className: Ct({ design: _, intent: B, className: a }),
      "data-animation": v.animation,
      ...!(d === "cancel" && v.animation === "exiting") && {
        "data-swipe": d,
        "data-swipe-direction": p
      },
      ...v.animation === "exiting" && {
        // Remove snackbar when the exiting animation completes
        onAnimationEnd: () => l.remove(v.key)
      },
      ref: b,
      ...Re,
      ...f,
      children: /* @__PURE__ */ qe("div", { className: Nt({ actionOnNewline: Me }), ...Ge, children: [
        M(Ke, $ ? N : null, {
          children: $
        }),
        /* @__PURE__ */ x(
          "p",
          {
            className: "px-md py-lg text-body-2 row-span-3",
            style: { gridArea: "message" },
            ...je,
            children: m
          }
        ),
        M(
          Ue,
          W && U ? A : null,
          { intent: B, design: _, onClick: U, children: W }
        ),
        M(We, k ? C : null, {
          intent: B,
          design: _,
          /**
           * React Spectrum typing of aria-label is inaccurate, and aria-label value should never be undefined.
           * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/i18n/src/useLocalizedStringFormatter.ts#L40
           */
          "aria-label": ze["aria-label"]
        })
      ] })
    }
  );
};
P.displayName = "Snackbar.Item";
const M = (t, e, n) => t ? Y(t, { ...n, ...t.props }) : e ? /* @__PURE__ */ x(e, { ...n }) : null, Bt = j(
  [
    "fixed inset-x-lg z-toast group",
    "outline-hidden pointer-events-none",
    "grid grid-rows-1 grid-cols-1 gap-lg"
  ],
  {
    variants: {
      /**
       * Set snackbar item position
       * @default 'bottom'
       */
      position: {
        top: "top-lg justify-items-center",
        "top-right": "top-lg justify-items-end",
        "top-left": "top-lg justify-items-start",
        bottom: "bottom-lg justify-items-center",
        "bottom-right": "bottom-lg justify-items-end",
        "bottom-left": "bottom-lg justify-items-start"
      }
    },
    defaultVariants: {
      position: "bottom"
    }
  }
), _t = ({
  children: t = /* @__PURE__ */ x(P, {}),
  state: e,
  position: n = "bottom",
  className: i,
  ref: o,
  ...r
}) => {
  const s = g(null), a = o && typeof o != "function" ? o : s, { regionProps: c } = St(r, e, a);
  return /* @__PURE__ */ x(
    "div",
    {
      ...c,
      ref: a,
      "data-position": n,
      className: Bt({ position: n, className: i }),
      children: e.visibleToasts.map((u) => /* @__PURE__ */ x(Fe.Provider, { value: { toast: u, state: e }, children: Y(t, { key: u.key }) }, u.key))
    }
  );
}, Ht = ({
  providers: t,
  subscriptions: e
}) => {
  const n = E(
    (a) => (e.add(a), () => e.delete(a)),
    [e]
  ), i = E(() => [...t].reverse()[0], [t]), o = E(
    (a) => {
      t.add(a);
      for (const c of e)
        c();
    },
    [t, e]
  ), r = E(
    (a) => {
      t.delete(a);
      for (const c of e)
        c();
    },
    [t, e]
  );
  return {
    provider: tt(n, i, i),
    addProvider: o,
    deleteProvider: r
  };
};
let T = null;
const R = () => (T || (T = new ht({
  maxVisibleToasts: 1,
  hasExitAnimation: !0
})), T), Xt = () => {
  T = null;
}, Dt = {
  providers: /* @__PURE__ */ new Set(),
  subscriptions: /* @__PURE__ */ new Set()
}, Ve = ({ ref: t, ...e }) => {
  const n = g(null), i = pt(R()), { provider: o, addProvider: r, deleteProvider: s } = Ht(Dt);
  return y(() => (r(n), () => {
    for (const a of R().visibleToasts)
      a.animation = void 0;
    s(n);
  }), []), n === o && i.visibleToasts.length > 0 ? nt(/* @__PURE__ */ x(_t, { ref: t, state: i, ...e }), document.body) : null;
};
Ve.displayName = "Snackbar";
const Yt = ({ onClose: t, timeout: e = 5e3, priority: n, ...i }) => {
  R().add(i, {
    onClose: t,
    timeout: e && !i.onAction ? Math.max(e, 5e3) : void 0,
    priority: n
  });
}, Ft = Object.assign(Ve, {
  Item: P,
  ItemAction: A,
  ItemClose: C,
  ItemIcon: N
});
Ft.displayName = "Snackbar";
P.displayName = "Snackbar.Item";
A.displayName = "Snackbar.ItemAction";
C.displayName = "Snackbar.ItemClose";
N.displayName = "Snackbar.ItemIcon";
export {
  Ft as Snackbar,
  Yt as addSnackbar,
  Xt as clearSnackbarQueue
};
//# sourceMappingURL=index.mjs.map
