import { jsx as o } from "react/jsx-runtime";
import m, { useContext as v, createContext as w } from "react";
import { j as N, k as O } from "./Dialog-7Yf08giu.es.js";
import { useSlotRecipe as M, chakra as F } from "@chakra-ui/react/styled-system";
import { createSlotRecipeContext as B } from "@chakra-ui/react";
import { a as _ } from "./Button-C9AKe3Kt.es.js";
import { e as u } from "./extract-style-props-CMyV-es-.es.js";
import { $ as H, a as k } from "./Modal-DCxn1MEV.es.js";
import { H as I } from "./heading-XNj70e-u.es.js";
import { Close as z } from "@commercetools/nimbus-icons";
import { n as d, u as j } from "./normalize-messages-BN9BAFXe.es.js";
import { I as E } from "./icon-button-DQaOMIAe.es.js";
const { withProvider: L, withContext: a } = /* @__PURE__ */ B({
  key: "nimbusDialog"
}), V = /* @__PURE__ */ L(
  "div",
  "root"
), A = /* @__PURE__ */ a("button", "trigger"), K = /* @__PURE__ */ a("div", "modalOverlay"), q = /* @__PURE__ */ a("div", "modal"), G = /* @__PURE__ */ a("div", "content"), J = /* @__PURE__ */ a(
  "header",
  "header"
), Q = /* @__PURE__ */ a(
  "div",
  "body"
), U = /* @__PURE__ */ a(
  "footer",
  "footer"
), W = /* @__PURE__ */ a("h2", "title"), X = /* @__PURE__ */ a("div", "closeTrigger"), D = /* @__PURE__ */ w(
  void 0
), h = () => {
  const e = v(D);
  if (!e)
    throw new Error("useDialogContext must be used within Dialog.Root");
  return e;
}, Y = ({
  children: e,
  value: r
}) => /* @__PURE__ */ o(D, { value: r, children: e }), y = (e) => {
  const r = M({ key: "nimbusDialog" }), [s] = r.splitVariantProps(e), { children: t, isOpen: i, onOpenChange: l, defaultOpen: f = !1 } = e, g = /* @__PURE__ */ o(V, { ...s, children: t }), p = m.Children.toArray(t).some((n) => {
    if (m.isValidElement(n) && typeof n.type == "function") {
      const c = n.type?.displayName;
      return c === "DialogTrigger" || c === "Dialog.Trigger";
    }
    return !1;
  });
  return /* @__PURE__ */ o(Y, { value: e, children: p ? (
    // When there's a Dialog.Trigger, use DialogTrigger for React Aria integration
    /* @__PURE__ */ o(
      N,
      {
        isOpen: i,
        onOpenChange: l,
        defaultOpen: f,
        children: g
      }
    )
  ) : (
    // When no Dialog.Trigger, skip using RaDialogTrigger to avoid console.warning's
    g
  ) });
};
y.displayName = "Dialog.Root";
const C = ({
  ref: e,
  children: r,
  asChild: s,
  ...t
}) => {
  if (s)
    return /* @__PURE__ */ o(F.button, { ref: e, asChild: !0, ...t, children: r });
  const [i, l] = u(t);
  return /* @__PURE__ */ o(A, { ...i, asChild: !0, children: /* @__PURE__ */ o(_, { ref: e, ...l, children: r }) });
};
C.displayName = "Dialog.Trigger";
const b = (e) => {
  const { ref: r, children: s, ...t } = e, {
    defaultOpen: i,
    isDismissable: l,
    isKeyboardDismissDisabled: f,
    shouldCloseOnInteractOutside: g,
    isOpen: p,
    onOpenChange: n
  } = h(), c = {
    defaultOpen: i,
    isDismissable: l,
    isKeyboardDismissDisabled: f,
    shouldCloseOnInteractOutside: g,
    isOpen: p,
    onOpenChange: n
  }, [R] = u(t);
  return /* @__PURE__ */ o(K, { asChild: !0, children: /* @__PURE__ */ o(H, { ...c, children: /* @__PURE__ */ o(q, { asChild: !0, children: /* @__PURE__ */ o(k, { children: /* @__PURE__ */ o(G, { asChild: !0, ...R, children: /* @__PURE__ */ o(O, { ref: r, children: s }) }) }) }) }) });
};
b.displayName = "Dialog.Content";
const T = (e) => {
  const { ref: r, children: s, ...t } = e;
  return /* @__PURE__ */ o(J, { ref: r, ...t, children: s });
};
T.displayName = "Dialog.Header";
const x = (e) => {
  const { ref: r, children: s, ...t } = e, { scrollBehavior: i } = h();
  return /* @__PURE__ */ o(Q, { ref: r, ...{
    /**
     * if scrollBehavior is set to "inside", set tabIndex to 0 to allow the body to
     * receive focus, effectively enabling scrolling via keyboard
     * arrow keys.
     */
    tabIndex: i === "inside" ? 0 : void 0
  }, ...t, children: s });
};
x.displayName = "Dialog.Body";
const $ = (e) => {
  const { ref: r, children: s, ...t } = e;
  return /* @__PURE__ */ o(U, { ref: r, ...t, children: s });
};
$.displayName = "Dialog.Footer";
const P = (e) => {
  const { ref: r, children: s, ...t } = e;
  return /* @__PURE__ */ o(W, { asChild: !0, ...t, children: /* @__PURE__ */ o(I, { ref: r, slot: "title", as: "h2", textStyle: "lg", children: s }) });
};
P.displayName = "Dialog.Title";
const Z = { closeTrigger: "Close dialog" }, ee = { closeTrigger: "Dialog schließen" }, oe = { closeTrigger: "Cerrar diálogo" }, re = { closeTrigger: "Fermer la boîte de dialogue" }, te = { closeTrigger: "Fechar caixa de diálogo" }, se = {
  en: /* @__PURE__ */ d(Z),
  de: /* @__PURE__ */ d(ee),
  es: /* @__PURE__ */ d(oe),
  "fr-FR": /* @__PURE__ */ d(re),
  "pt-BR": /* @__PURE__ */ d(te)
}, S = (e) => {
  const r = j(se), { ref: s, "aria-label": t, ...i } = e;
  return /* @__PURE__ */ o(X, { children: /* @__PURE__ */ o(
    E,
    {
      ref: s,
      slot: "close",
      size: "xs",
      variant: "ghost",
      "aria-label": t || r.format("closeTrigger"),
      ...i,
      children: /* @__PURE__ */ o(z, {})
    }
  ) });
};
S.displayName = "Dialog.CloseTrigger";
const he = {
  /**
   * # Dialog.Root
   *
   * The root component that provides context and state management for the dialog.
   * Uses React Aria's DialogTrigger for accessibility and keyboard interaction.
   *
   * This component must wrap all dialog parts (Trigger, Content, etc.) and provides
   * the dialog open/close state and variant styling context.
   *
   * @example
   * ```tsx
   * <Dialog.Root>
   *   <Dialog.Trigger>Open Dialog</Dialog.Trigger>
   *   <Dialog.Content>
   *     <Dialog.Header>
   *       <Dialog.Title>Dialog Title</Dialog.Title>
   *     </Dialog.Header>
   *     <Dialog.Body>Dialog content</Dialog.Body>
   *   </Dialog.Content>
   * </Dialog.Root>
   * ```
   */
  Root: y,
  /**
   * # Dialog.Trigger
   *
   * The trigger element that opens the dialog when activated.
   * Uses React Aria's Button for accessibility and keyboard support.
   *
   * @example
   * ```tsx
   * <Dialog.Root>
   *   <Dialog.Trigger>Open Dialog</Dialog.Trigger>
   *   <Dialog.Content>...</Dialog.Content>
   * </Dialog.Root>
   * ```
   */
  Trigger: C,
  /**
   * # Dialog.Content
   *
   * The main dialog content container that wraps React Aria's Modal and Dialog.
   * Handles portalling, backdrop, positioning, and content styling.
   *
   * This component creates the dialog overlay, positions the content, and provides
   * accessibility features like focus management and keyboard dismissal.
   *
   * @example
   * ```tsx
   * <Dialog.Root>
   *   <Dialog.Trigger>Open Dialog</Dialog.Trigger>
   *   <Dialog.Content size="md" placement="center">
   *     <Dialog.Header>
   *       <Dialog.Title>Title</Dialog.Title>
   *     </Dialog.Header>
   *     <Dialog.Body>Content</Dialog.Body>
   *     <Dialog.Footer>Actions</Dialog.Footer>
   *   </Dialog.Content>
   * </Dialog.Root>
   * ```
   */
  Content: b,
  /**
   * # Dialog.Header
   *
   * The header section of the dialog content.
   * Typically contains the title and close button.
   *
   * @example
   * ```tsx
   * <Dialog.Content>
   *   <Dialog.Header>
   *     <Dialog.Title>Dialog Title</Dialog.Title>
   *     <Dialog.CloseTrigger />
   *   </Dialog.Header>
   *   <Dialog.Body>...</Dialog.Body>
   * </Dialog.Content>
   * ```
   */
  Header: T,
  /**
   * # Dialog.Body
   *
   * The main body content section of the dialog.
   * Contains the primary dialog content and handles overflow/scrolling.
   *
   * @example
   * ```tsx
   * <Dialog.Content>
   *   <Dialog.Header>...</Dialog.Header>
   *   <Dialog.Body>
   *     <p>This is the main content of the dialog.</p>
   *   </Dialog.Body>
   *   <Dialog.Footer>...</Dialog.Footer>
   * </Dialog.Content>
   * ```
   */
  Body: x,
  /**
   * # Dialog.Footer
   *
   * The footer section of the dialog, typically containing action buttons.
   * Provides consistent spacing and alignment for dialog actions.
   *
   * @example
   * ```tsx
   * <Dialog.Content>
   *   <Dialog.Header>...</Dialog.Header>
   *   <Dialog.Body>...</Dialog.Body>
   *   <Dialog.Footer>
   *     <Button variant="outline">Cancel</Button>
   *     <Button>Confirm</Button>
   *   </Dialog.Footer>
   * </Dialog.Content>
   * ```
   */
  Footer: $,
  /**
   * # Dialog.Title
   *
   * The accessible title element for the dialog.
   * Uses React Aria's Heading for proper accessibility and screen reader support.
   *
   * @example
   * ```tsx
   * <Dialog.Content>
   *   <Dialog.Header>
   *     <Dialog.Title>Confirm Action</Dialog.Title>
   *   </Dialog.Header>
   *   <Dialog.Body>...</Dialog.Body>
   * </Dialog.Content>
   * ```
   */
  Title: P,
  /**
   * # Dialog.CloseTrigger
   *
   * A button that closes the dialog when activated.
   * Displays an IconButton with a close (X) icon by default.
   *
   * The component automatically handles the close behavior through React Aria's
   * context, so no additional onPress handler is needed.
   *
   * @example
   * ```tsx
   * <Dialog.Root>
   *   <Dialog.Trigger>Open Dialog</Dialog.Trigger>
   *   <Dialog.Content>
   *     <Dialog.Header>
   *       <Dialog.Title>Title</Dialog.Title>
   *       <Dialog.CloseTrigger aria-label="Close dialog" />
   *     </Dialog.Header>
   *     <Dialog.Body>Content</Dialog.Body>
   *   </Dialog.Content>
   * </Dialog.Root>
   * ```
   */
  CloseTrigger: S
};
export {
  he as D
};
//# sourceMappingURL=dialog-Cx2LGEGu.es.js.map
