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