import { jsx as o, jsxs as p } from "react/jsx-runtime";
import * as a from "@radix-ui/react-dialog";
import { X as y, ChevronLeft as b } from "lucide-react";
import { c as i } from "../../index-BtlgVD4m.js";
import c from "../box/Box.js";
import x from "./hooks/useOptionalDialogNavigationContext.js";
import h from "../button/Button.js";
const H = a.Root, P = a.Trigger, N = a.Portal, L = a.Close, m = ({ ref: e, className: t, ...s }) => /* @__PURE__ */ o(
  a.Overlay,
  {
    ref: e,
    className: i(
      "fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
      t
    ),
    ...s
  }
);
m.displayName = a.Overlay.displayName;
const D = ({
  ref: e,
  className: t,
  children: s,
  hasCloseButton: l = !0,
  onPointerDownOutside: n,
  onInteractOutside: d,
  ...f
}) => {
  const g = (r) => r instanceof Element && !!r.closest("[data-radix-popper-content-wrapper]"), u = (r) => {
    if (g(r.detail.originalEvent.target)) {
      r.preventDefault();
      return;
    }
    n == null || n(r);
  }, v = (r) => {
    if (g(r.detail.originalEvent.target)) {
      r.preventDefault();
      return;
    }
    d == null || d(r);
  };
  return /* @__PURE__ */ o(N, { children: /* @__PURE__ */ o(m, { children: /* @__PURE__ */ p(
    a.Content,
    {
      ref: e,
      className: i(
        "fixed",
        "left-[50%]",
        "top-[50%]",
        "z-50",
        "grid",
        "w-full",
        "max-w-lg",
        "translate-x-[-50%]",
        "translate-y-[-50%]",
        "gap-[var(--spacing-4)]",
        "border",
        "border-[var(--base-border)]",
        "bg-[var(--base-background)]",
        "p-[var(--spacing-6)]",
        "shadow-lg",
        "duration-200",
        "data-[state=open]:animate-in",
        "data-[state=closed]:animate-out",
        "data-[state=closed]:fade-out-0",
        "data-[state=open]:fade-in-0",
        "data-[state=closed]:zoom-out-95",
        "data-[state=open]:zoom-in-95",
        "data-[state=closed]:slide-out-to-left-1/2",
        "data-[state=closed]:slide-out-to-top-[48%]",
        "data-[state=open]:slide-in-from-left-1/2",
        "data-[state=open]:slide-in-from-top-[48%]",
        "sm:rounded-[var(--border-radius-lg)]",
        t
      ),
      onPointerDownOutside: u,
      onInteractOutside: v,
      ...f,
      children: [
        s,
        l && /* @__PURE__ */ p(a.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-[var(--base-background)] transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground cursor-pointer", children: [
          /* @__PURE__ */ o(y, { className: "h-4 w-4" }),
          /* @__PURE__ */ o("span", { className: "sr-only", children: "Close" })
        ] })
      ]
    }
  ) }) });
};
D.displayName = a.Content.displayName;
const k = ({ className: e, children: t, ...s }) => {
  const l = x();
  return (l == null ? void 0 : l.canGoBack) ?? !1 ? /* @__PURE__ */ p(c, { className: i("flex", "items-start", "gap-[var(--spacing-3)]", e), ...s, children: [
    /* @__PURE__ */ o(h, { type: "button", variant: "outline", icon: /* @__PURE__ */ o(b, {}), onClick: l == null ? void 0 : l.navigateBack, "aria-label": "Go back" }),
    /* @__PURE__ */ o(c, { className: "flex flex-1 flex-col gap-[var(--spacing-1-5)] text-left", children: t })
  ] }) : /* @__PURE__ */ o(c, { className: i("flex", "flex-col", "gap-[var(--spacing-1-5)]", "text-center", "sm:text-left", e), ...s, children: t });
};
k.displayName = "DialogHeader";
const z = ({ className: e, ...t }) => /* @__PURE__ */ o(c, { className: i("flex flex-col-reverse gap-[var(--spacing-4)] sm:flex-row sm:justify-end", e), ...t });
z.displayName = "DialogFooter";
const C = ({ ref: e, className: t, ...s }) => /* @__PURE__ */ o(
  a.Title,
  {
    ref: e,
    className: i(
      "text-[length:var(--typography-base-sizes-large-font-size)]",
      "font-[var(--font-weight-semibold)]",
      "leading-none",
      "tracking-tight",
      t
    ),
    ...s
  }
);
C.displayName = a.Title.displayName;
const w = ({ ref: e, className: t, ...s }) => /* @__PURE__ */ o(
  a.Description,
  {
    ref: e,
    className: i(
      "text-[length:var(--typography-base-sizes-small-font-size)]",
      "text-[var(--base-muted-foreground)]",
      "font-[var(--font-weight-normal)]",
      "leading-[var(--typography-base-sizes-small-line-height)]",
      t
    ),
    ...s
  }
);
w.displayName = a.Description.displayName;
export {
  H as Dialog,
  L as DialogClose,
  D as DialogContent,
  w as DialogDescription,
  z as DialogFooter,
  k as DialogHeader,
  m as DialogOverlay,
  N as DialogPortal,
  C as DialogTitle,
  P as DialogTrigger
};
//# sourceMappingURL=DialogPrimitive.js.map
