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