import { jsx as e, jsxs as C } from "react/jsx-runtime";
import { useState as p, useMemo as $, useCallback as N, useEffect as j } from "react";
import { t as u } from "../global.module.js";
import { B as A, a as F } from "../tools/icons.js";
import { g, c as K, s as L, a as R, k as T, b as i } from "../tools/tools.js";
import { f } from "../lite.js";
const k = /* @__PURE__ */ new Date(), _ = function(D) {
  const {
    as: M = "div",
    className: m,
    dropOldClass: v,
    locale: l,
    onDateClick: n,
    selectedDate: d,
    style: h,
    variables: x,
    ...w
  } = D, [s, P] = p(k.getFullYear()), [o, S] = p(k.getMonth()), [W, y] = p(
    g(s, o, [], 6, 1, void 0, d, l, !0)
  ), B = $(() => {
    const a = K(!v && "card card-body border-0 p-0", m), t = L((c, r) => ({ tKey: R(r) }), x, h);
    return {
      className: a,
      style: t
    };
  }, [m, v, h, x]), b = N(
    (a) => {
      const t = new Date(s, o + a);
      P(t.getFullYear()), S(t.getMonth());
    },
    [o, s]
  ), O = N(
    (a) => {
      const t = { ...a, active: !0 };
      y((c) => T(t, c)), n == null || n(t);
    },
    [n]
  );
  return j(() => {
    y(g(s, o, [], 6, 1, void 0, d, l, !0));
  }, [o, s, l, d]), /* @__PURE__ */ e(M, { ...w, ...B, children: /* @__PURE__ */ C("div", { className: "list-group border-0 row-gap-1 px-3", children: [
    /* @__PURE__ */ C("div", { className: "row align-items-center position-relative text-center w-100 mb-2", children: [
      /* @__PURE__ */ e("div", { className: "col px-1", onClick: () => b(-1), children: /* @__PURE__ */ e(
        "div",
        {
          className: i(
            null,
            "user-select-none list-group-item list-group-item-action border-0 px-0 py-1 rounded text-secondary",
            u.brlCursorPointer
          ),
          children: /* @__PURE__ */ e(A, {})
        }
      ) }),
      /* @__PURE__ */ e("div", { className: "col px-1" }),
      /* @__PURE__ */ e("div", { className: "col px-1" }),
      /* @__PURE__ */ e("div", { className: "col px-1" }),
      /* @__PURE__ */ e("div", { className: "col px-1" }),
      /* @__PURE__ */ e("div", { className: "col px-1" }),
      /* @__PURE__ */ e("div", { className: "col px-1", onClick: () => b(1), children: /* @__PURE__ */ e(
        "div",
        {
          className: i(
            null,
            "user-select-none list-group-item list-group-item-action border-0 px-0 py-1 rounded text-secondary",
            u.brlCursorPointer
          ),
          children: /* @__PURE__ */ e(F, {})
        }
      ) }),
      /* @__PURE__ */ e("div", { className: "position-absolute top-50 start-50 translate-middle w-auto text-nowrap", children: f(new Date(s, o), "MMMM yyyy", {
        locale: l
      }) })
    ] }),
    W.rows.map((a, t) => {
      const c = t !== 0 && a.every((r) => r.active);
      return /* @__PURE__ */ e(
        "div",
        {
          className: i(
            null,
            "row text-center d-flex list-group-item rounded p-0 border-0",
            t === 0 ? "w-100" : `list-group-item-action ${u.brlCursorPointer}`,
            c && "active"
          ),
          children: a.map((r, Y) => t === 0 ? /* @__PURE__ */ e("div", { className: "col px-1", children: /* @__PURE__ */ e("div", { className: "px-0 py-1 rounded text-body-secondary", children: r.value }) }, `${r.value}${Y}`) : /* @__PURE__ */ e("div", { className: "col px-1", onClick: () => O(r), children: /* @__PURE__ */ e(
            "div",
            {
              className: i(
                null,
                "px-0 py-1 rounded",
                !r.isCurrentMonth && !r.active && "text-body-tertiary",
                r.isToday ? "border border-secondary-subtle" : "border-0"
              ),
              children: f(r.date, "d", { locale: l })
            }
          ) }, r.date.toISOString()))
        },
        t
      );
    })
  ] }) });
};
_.displayName = "BRL.DatePickerWeek";
export {
  _ as D
};
//# sourceMappingURL=date-picker-week.js.map
