import { $n as e, D as t, E as n, Lt as r, On as i, Zn as a, b as o, et as s, g as c, jt as l, mt as u, o as d, qt as f, tr as p, v as m, wn as h, xt as g, y as _, z as v } from "./runtime-core.esm-bundler-Ci9kEgM7.js";
import { I as y, S as b, X as x, b as S, m as C, t as w, x as T } from "./Button-CzGEASGR.js";
import { A as E, r as D } from "./dist-D5YmEqpM.js";
import { f as O, i as ee } from "./Tooltip-CmrGYuQV.js";
import { a as k, c as A, i as j, l as M, n as N, o as P, r as F, s as I } from "./useOverlay-D6IDAxlU.js";
import { t as L } from "./overlay-DR-nxSLa.js";
var R = { slots: { overlay: `fixed inset-0`, content: `bg-default divide-y divide-default flex flex-col focus:outline-none`, header: `flex items-center gap-1.5 p-4 sm:px-6 min-h-(--ui-header-height)`, wrapper: ``, body: `flex-1 p-4 sm:p-6`, footer: `flex items-center gap-1.5 p-4 sm:px-6`, title: `text-highlighted font-semibold`, description: `mt-1 text-muted text-sm`, close: `absolute top-4 end-4` }, variants: { transition: { true: { overlay: `data-[state=open]:animate-[fade-in_200ms_ease-out] data-[state=closed]:animate-[fade-out_200ms_ease-in]`, content: `data-[state=open]:animate-[scale-in_200ms_ease-out] data-[state=closed]:animate-[scale-out_200ms_ease-in]` } }, fullscreen: { true: { content: `inset-0` }, false: { content: `w-[calc(100vw-2rem)] max-w-lg rounded-lg shadow-lg ring ring-default` } }, overlay: { true: { overlay: `bg-elevated/75` } }, scrollable: { true: { overlay: `overflow-y-auto`, content: `relative` }, false: { content: `fixed`, body: `overflow-y-auto` } } }, compoundVariants: [{ scrollable: true, fullscreen: false, class: { overlay: `grid place-items-center p-4 sm:py-8` } }, { scrollable: false, fullscreen: false, class: { content: `top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 max-h-[calc(100dvh-2rem)] sm:max-h-[calc(100dvh-4rem)] overflow-hidden` } }] }, z = { __name: `Modal`, props: { title: { type: String, required: false }, description: { type: String, required: false }, content: { type: Object, required: false }, overlay: { type: Boolean, required: false, default: true }, scrollable: { type: Boolean, required: false }, transition: { type: Boolean, required: false, default: true }, fullscreen: { type: Boolean, required: false }, portal: { type: [Boolean, String], required: false, skipCheck: true, default: true }, close: { type: [Boolean, Object], required: false, default: true }, closeIcon: { type: null, required: false }, dismissible: { type: Boolean, required: false, default: true }, class: { type: null, required: false }, ui: { type: Object, required: false }, open: { type: Boolean, required: false }, defaultOpen: { type: Boolean, required: false }, modal: { type: Boolean, required: false, default: true } }, emits: [`leave`, `after:leave`, `enter`, `after:enter`, `close:prevent`, `update:open`], setup(z2, { emit: B }) {
  let V = z2, H = B, U = r(), W = b(`modal`, V), { t: G } = y(), K = x(), q = T(E(W, `open`, `defaultOpen`, `modal`), H), J = ee(h(() => W.portal)), Y = h(() => W.content), X = c(() => W.dismissible ? { pointerDownOutside: (e2) => L(e2, { scrollable: W.scrollable }) } : [`interactOutside`, `escapeKeyDown`].reduce((e2, t2) => (e2[t2] = (e3) => {
    e3.preventDefault(), H(`close:prevent`);
  }, e2), {})), [Z, Q] = D(), $ = c(() => S({ extend: S(R), ...K.ui?.modal || {} })({ transition: W.transition, fullscreen: W.fullscreen, overlay: W.overlay, scrollable: W.scrollable }));
  return (r2, c2) => (u(), m(i(M), e(v(i(q))), { default: f(({ open: h2, close: y2 }) => [t(i(Z), null, { default: f(() => [t(i(I), s({ "data-slot": `content`, class: $.value.content({ class: [!U.default && i(W).class, i(W).ui?.content] }) }, Y.value, { onEnter: c2[0] || (c2[0] = (e2) => H(`enter`)), onAfterEnter: c2[1] || (c2[1] = (e2) => H(`after:enter`)), onLeave: c2[2] || (c2[2] = (e2) => H(`leave`)), onAfterLeave: c2[3] || (c2[3] = (e2) => H(`after:leave`)) }, l(X.value)), { default: f(() => [!i(W).title && !U.title || !i(W).description && !U.description || U.content ? (u(), m(i(O), { key: 0 }, { default: f(() => [!i(W).title && !U.title ? (u(), m(i(F), { key: 0 })) : U.content ? (u(), m(i(F), { key: 1 }, { default: f(() => [g(r2.$slots, `title`, {}, () => [n(p(i(W).title), 1)])]), _: 3 })) : _(``, true), !i(W).description && !U.description ? (u(), m(i(P), { key: 2 })) : U.content ? (u(), m(i(P), { key: 3 }, { default: f(() => [g(r2.$slots, `description`, {}, () => [n(p(i(W).description), 1)])]), _: 3 })) : _(``, true)]), _: 3 })) : _(``, true), g(r2.$slots, `content`, { close: y2 }, () => [U.header || i(W).title || U.title || i(W).description || U.description || i(W).close || U.close ? (u(), o(`div`, { key: 0, "data-slot": `header`, class: a($.value.header({ class: i(W).ui?.header })) }, [g(r2.$slots, `header`, { close: y2 }, () => [i(W).title || U.title || i(W).description || U.description ? (u(), o(`div`, { key: 0, "data-slot": `wrapper`, class: a($.value.wrapper({ class: i(W).ui?.wrapper })) }, [i(W).title || U.title ? (u(), m(i(F), { key: 0, "data-slot": `title`, class: a($.value.title({ class: i(W).ui?.title })) }, { default: f(() => [g(r2.$slots, `title`, {}, () => [n(p(i(W).title), 1)])]), _: 3 }, 8, [`class`])) : _(``, true), i(W).description || U.description ? (u(), m(i(P), { key: 1, "data-slot": `description`, class: a($.value.description({ class: i(W).ui?.description })) }, { default: f(() => [g(r2.$slots, `description`, {}, () => [n(p(i(W).description), 1)])]), _: 3 }, 8, [`class`])) : _(``, true)], 2)) : _(``, true), g(r2.$slots, `actions`), i(W).close || U.close ? (u(), m(i(A), { key: 1, "as-child": `` }, { default: f(() => [g(r2.$slots, `close`, { ui: $.value }, () => [i(W).close ? (u(), m(w, s({ key: 0, icon: i(W).closeIcon || i(K).ui.icons.close, color: `neutral`, variant: `ghost`, "aria-label": i(G)(`modal.close`) }, typeof i(W).close == `object` ? i(W).close : {}, { "data-slot": `close`, class: $.value.close({ class: i(W).ui?.close }) }), null, 16, [`icon`, `aria-label`, `class`])) : _(``, true)])]), _: 2 }, 1024)) : _(``, true)])], 2)) : _(``, true), U.body ? (u(), o(`div`, { key: 1, "data-slot": `body`, class: a($.value.body({ class: i(W).ui?.body })) }, [g(r2.$slots, `body`, { close: y2 })], 2)) : _(``, true), U.footer ? (u(), o(`div`, { key: 2, "data-slot": `footer`, class: a($.value.footer({ class: i(W).ui?.footer })) }, [g(r2.$slots, `footer`, { close: y2 })], 2)) : _(``, true)])]), _: 2 }, 1040, [`class`])]), _: 2 }, 1024), U.default ? (u(), m(i(N), { key: 0, "as-child": ``, class: a(i(W).class) }, { default: f(() => [g(r2.$slots, `default`, { open: h2 })]), _: 2 }, 1032, [`class`])) : _(``, true), t(i(j), e(v(i(J))), { default: f(() => [t(i(C), null, { default: f(() => [i(W).scrollable ? (u(), m(i(k), { key: 0, "data-slot": `overlay`, class: a($.value.overlay({ class: i(W).ui?.overlay })) }, { default: f(() => [t(i(Q))]), _: 1 }, 8, [`class`])) : (u(), o(d, { key: 1 }, [i(W).overlay ? (u(), m(i(k), { key: 0, "data-slot": `overlay`, class: a($.value.overlay({ class: i(W).ui?.overlay })) }, null, 8, [`class`])) : _(``, true), t(i(Q))], 64))]), _: 1 })]), _: 1 }, 16)]), _: 3 }, 16));
} };
export {
  z as t
};
