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