import { jsx as e, jsxs as c } from "react/jsx-runtime";
import { j as S, d as T, e as A, f as F, g as I, h as z, a as P, c as L, k as N } from "./Heading-C0SIgP_B.es.js";
import { createSlotRecipeContext as j } from "@chakra-ui/react";
import { useSlotRecipe as B } from "@chakra-ui/react/styled-system";
import { e as G } from "./extract-style-props-CMyV-es-.es.js";
import { c as l, d as H } from "./useDateFormatter-C0T2-xr7.es.js";
import { useContext as u } from "react";
import { $ } from "./Button-C9AKe3Kt.es.js";
import { e as _, c as w } from "./utils-CrjF8U_E.es.js";
import { $ as v } from "./Text-DOcU1ycg.es.js";
import { n as f, u as k } from "./normalize-messages-BN9BAFXe.es.js";
import { $ as D } from "./context-BfHy4NgG.es.js";
import { KeyboardArrowLeft as g, KeyboardArrowRight as y } from "@commercetools/nimbus-icons";
import { T as C } from "./text-iTgAZrNO.es.js";
import { F as V } from "./flex-BqxAMF-7.es.js";
import { S as M } from "./stack-CoNreM7B.es.js";
import { V as J } from "./visually-hidden-DVHn3y3w.es.js";
import { I as p } from "./icon-button-DQaOMIAe.es.js";
import { B as R } from "./box-DuBoAZvq.es.js";
const { withProvider: K, withContext: s } = /* @__PURE__ */ j({
  key: "nimbusCalendar"
}), W = /* @__PURE__ */ K("div", "root"), q = /* @__PURE__ */ s("div", "header"), E = /* @__PURE__ */ s("div", "grids"), O = /* @__PURE__ */ s("div", "monthTitle"), Q = /* @__PURE__ */ s("table", "grid"), U = /* @__PURE__ */ s("thead", "gridHeader"), X = /* @__PURE__ */ s("th", "headerCell"), Z = /* @__PURE__ */ s("tbody", "gridBody"), ee = /* @__PURE__ */ s("td", "bodyCell"), te = {
  nextMonth: "Next month",
  nextYear: "Next year",
  previousMonth: "Previous month",
  previousYear: "Previous year"
}, oe = {
  nextMonth: "Nächsten Monat",
  nextYear: "Nächstes Jahr",
  previousMonth: "Letzten Monat",
  previousYear: "Letztes Jahr"
}, re = {
  nextMonth: "Próximo mes",
  nextYear: "Próximo año",
  previousMonth: "Mes anterior",
  previousYear: "Año anterior"
}, ae = {
  nextMonth: "Mois suivant",
  nextYear: "Année suivante",
  previousMonth: "Mois précédent",
  previousYear: "Année précédente"
}, ne = {
  nextMonth: "Próximo mês",
  nextYear: "Próximo ano",
  previousMonth: "Mês anterior",
  previousYear: "Ano anterior"
}, se = {
  en: /* @__PURE__ */ f(te),
  de: /* @__PURE__ */ f(oe),
  es: /* @__PURE__ */ f(re),
  "fr-FR": /* @__PURE__ */ f(ae),
  "pt-BR": /* @__PURE__ */ f(ne)
}, ie = ({
  children: i
}) => {
  const { locale: a } = D(), t = k(se), r = u($), n = u(v), o = u(S), b = {
    "next-month": {
      onPress: () => o.focusNextSection(),
      "aria-label": t.format("nextMonth")
    },
    "previous-month": {
      onPress: () => o.focusPreviousSection(),
      "aria-label": t.format("previousMonth")
    },
    "next-year": {
      onPress: () => o.focusNextSection(!0),
      "aria-label": t.format("nextYear")
    },
    "previous-year": {
      onPress: () => o.focusPreviousSection(!0),
      "aria-label": t.format("previousYear")
    }
  }, m = new Intl.DateTimeFormat(a, {
    month: "long"
  }).format(o.focusedDate.toDate(l())), x = [
    new Intl.DateTimeFormat(a, {
      month: "long"
    }).format(o.visibleRange.start.toDate(l())),
    new Intl.DateTimeFormat(a, {
      month: "long"
    }).format(o.visibleRange.end.toDate(l()))
  ].join(" - "), h = new Intl.DateTimeFormat(a, {
    year: "numeric"
  }).format(o.focusedDate.toDate(l())), d = {
    month: { children: m },
    monthRange: { children: x },
    year: { children: h }
  };
  return /* @__PURE__ */ e(
    _,
    {
      values: [
        [
          $,
          {
            ...r,
            slots: {
              ...r && typeof r == "object" && "slots" in r ? r.slots : {},
              ...b
            }
          }
        ],
        [
          v,
          {
            ...n,
            slots: {
              ...n && typeof n == "object" && "slots" in n ? n.slots : {},
              ...d
            }
          }
        ]
      ],
      children: i
    }
  );
}, de = () => {
  const { locale: i } = D(), a = w(P), t = u(S), r = a?.visibleDuration?.months || 1, n = H(l()), o = r > 1;
  return /* @__PURE__ */ e(E, { children: Array.from({ length: r }, (b, m) => {
    const x = t.visibleRange.start.add({
      months: m
    }), h = new Intl.DateTimeFormat(i, {
      month: "long"
    }).format(x.toDate(l()));
    return /* @__PURE__ */ c(
      R,
      {
        width: r == 1 ? "full" : "auto",
        children: [
          o && /* @__PURE__ */ e(O, { children: h }),
          /* @__PURE__ */ e(Q, { asChild: !0, children: /* @__PURE__ */ c(T, { offset: { months: m }, weekdayStyle: "short", children: [
            /* @__PURE__ */ e(U, { asChild: !0, children: /* @__PURE__ */ e(A, { children: (d) => /* @__PURE__ */ e(X, { asChild: !0, children: /* @__PURE__ */ e(F, { children: d }) }) }) }),
            /* @__PURE__ */ e(Z, { asChild: !0, children: /* @__PURE__ */ e(I, { children: (d) => {
              const Y = d.compare(n) === 0;
              return /* @__PURE__ */ e(ee, { asChild: !0, "data-today": Y, children: /* @__PURE__ */ e(z, { date: d }) });
            } }) })
          ] }) })
        ]
      },
      h
    );
  }) });
}, le = () => {
  const t = (w(P)?.visibleDuration?.months || 1) > 1;
  return /* @__PURE__ */ e(q, { children: /* @__PURE__ */ c(V, { children: [
    /* @__PURE__ */ c(M, { direction: "row", alignItems: "center", children: [
      /* @__PURE__ */ e(J, { children: /* @__PURE__ */ e(L, {}) }),
      /* @__PURE__ */ e(
        p,
        {
          slot: t ? "previous" : "previous-month",
          size: "xs",
          variant: "ghost",
          colorPalette: "primary",
          children: /* @__PURE__ */ e(g, {})
        }
      ),
      /* @__PURE__ */ e(
        C,
        {
          textStyle: "sm",
          fontWeight: "500",
          color: "neutral.11",
          width: t ? "4000" : "2000",
          textAlign: "center",
          "aria-hidden": "true",
          slot: t ? "monthRange" : "month"
        }
      ),
      /* @__PURE__ */ e(
        p,
        {
          slot: t ? "next" : "next-month",
          size: "xs",
          variant: "ghost",
          colorPalette: "primary",
          children: /* @__PURE__ */ e(y, {})
        }
      )
    ] }),
    /* @__PURE__ */ e(R, { flexGrow: "1" }),
    /* @__PURE__ */ c(M, { direction: "row", alignItems: "center", children: [
      /* @__PURE__ */ e(
        p,
        {
          slot: "previous-year",
          size: "xs",
          variant: "ghost",
          colorPalette: "primary",
          children: /* @__PURE__ */ e(g, {})
        }
      ),
      /* @__PURE__ */ e(
        C,
        {
          textStyle: "sm",
          fontWeight: "500",
          color: "neutral.11",
          width: "1400",
          textAlign: "center",
          "aria-hidden": "true",
          slot: "year"
        }
      ),
      /* @__PURE__ */ e(
        p,
        {
          slot: "next-year",
          size: "xs",
          variant: "ghost",
          colorPalette: "primary",
          children: /* @__PURE__ */ e(y, {})
        }
      )
    ] })
  ] }) });
}, Ye = (i) => {
  const a = B({ key: "nimbusCalendar" }), [t, r] = a.splitVariantProps(i), [n, o] = G(r);
  return /* @__PURE__ */ e(W, { ...t, ...n, asChild: !0, children: /* @__PURE__ */ e(N, { ...o, children: /* @__PURE__ */ c(ie, { children: [
    /* @__PURE__ */ e(le, {}),
    /* @__PURE__ */ e(de, {})
  ] }) }) });
};
export {
  Ye as C
};
//# sourceMappingURL=calendar-B3GH1VKH.es.js.map
