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