import { jsxs as p, jsx as e } from "react/jsx-runtime";
import { useState as c, useMemo as z, useCallback as B, useEffect as G } from "react";
import { t as x } from "../global.module.js";
import { B as J, a as Q, c as U } from "../tools/icons.js";
import { g as $, c as X, s as Z, a as ee, u as te, b as y } from "../tools/tools.js";
import { s as se, a as ae, b as re, f as O } from "../lite.js";
const N = /* @__PURE__ */ new Date(), l = (C) => C.toString().padStart(2, "0"), ne = function(T) {
  const {
    as: Y = "div",
    className: b,
    dropOldClass: f,
    locale: i,
    onDateClick: u,
    selectedDate: m,
    style: M,
    variables: D,
    ...j
  } = T, r = m ?? N, [n, F] = c(N.getFullYear()), [o, K] = c(N.getMonth()), [L, S] = c(
    $(n, o, [], 6, 1, void 0, m, i)
  ), [h, k] = c(l(r.getHours())), [v, w] = c(l(r.getMinutes())), [g, H] = c(l(r.getSeconds())), R = z(() => {
    const t = X(!f && "card card-body border-0 p-0", b), a = Z((s, d) => ({ tKey: ee(d) }), D, M);
    return {
      className: t,
      style: a
    };
  }, [b, f, M, D]), I = B(
    (t) => {
      const a = new Date(n, o + t);
      F(a.getFullYear()), K(a.getMonth());
    },
    [o, n]
  ), _ = B(
    (t) => {
      const a = parseInt(h, 10) || 0, s = parseInt(v, 10) || 0, d = parseInt(g, 10) || 0, W = se(ae(re(t.date, a), s), d), P = { ...t, active: !0, date: W };
      S((q) => te(P, q)), u == null || u(P);
    },
    [h, v, u, g]
  ), A = (t) => {
    k(t.target.value.trim());
  }, E = (t) => {
    w(t.target.value.trim());
  }, V = (t) => {
    H(t.target.value.trim());
  };
  return G(() => {
    S($(n, o, [], 6, 1, void 0, m, i)), k(l(r.getHours())), w(l(r.getMinutes())), H(l(r.getSeconds()));
  }, [o, n, r, i, m]), /* @__PURE__ */ p(Y, { ...j, ...R, children: [
    /* @__PURE__ */ p("div", { className: "list-group border-0 row-gap-1 px-3", children: [
      /* @__PURE__ */ p("div", { className: "row align-items-center position-relative text-center mb-2", children: [
        /* @__PURE__ */ e("div", { className: "col px-1", onClick: () => I(-1), children: /* @__PURE__ */ e(
          "div",
          {
            className: y(
              null,
              "user-select-none list-group-item list-group-item-action border-0 px-0 py-1 rounded text-secondary",
              x.brlCursorPointer
            ),
            children: /* @__PURE__ */ e(J, {})
          }
        ) }),
        /* @__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: () => I(1), children: /* @__PURE__ */ e(
          "div",
          {
            className: y(
              null,
              "user-select-none list-group-item list-group-item-action border-0 px-0 py-1 rounded text-secondary",
              x.brlCursorPointer
            ),
            children: /* @__PURE__ */ e(Q, {})
          }
        ) }),
        /* @__PURE__ */ e("div", { className: "position-absolute top-50 start-50 translate-middle w-auto text-nowrap", children: O(new Date(n, o), "MMMM yyyy", {
          locale: i
        }) })
      ] }),
      L.rows.map((t, a) => /* @__PURE__ */ e("div", { className: "row text-center", children: t.map((s, d) => a === 0 ? /* @__PURE__ */ e("div", { className: "col px-1", children: /* @__PURE__ */ e("div", { className: "list-group-item border-0 px-0 py-1 rounded text-body-secondary", children: s.value }) }, `${s.value}${d}`) : /* @__PURE__ */ e("div", { className: "col px-1", onClick: () => _(s), children: /* @__PURE__ */ e(
        "div",
        {
          className: y(
            null,
            "list-group-item list-group-item-action px-0 py-1 rounded",
            x.brlCursorPointer,
            !s.isCurrentMonth && !s.active && "text-body-tertiary",
            s.active && "active",
            s.isToday ? "border-secondary-subtle" : "border-0"
          ),
          children: O(s.date, "d", { locale: i })
        }
      ) }, s.date.toISOString())) }, a))
    ] }),
    /* @__PURE__ */ p("div", { className: "input-group mt-4 mb-1", children: [
      /* @__PURE__ */ p("span", { className: "input-group-text text-primary-emphasis", children: [
        /* @__PURE__ */ e(U, {}),
        /* @__PURE__ */ e("span", { className: "ps-1", children: "Time" })
      ] }),
      /* @__PURE__ */ e("input", { className: "form-control", onChange: A, placeholder: "HH", type: "text", value: h }),
      /* @__PURE__ */ e("span", { className: "input-group-text text-secondary", children: ":" }),
      /* @__PURE__ */ e("input", { className: "form-control", onChange: E, placeholder: "MM", type: "text", value: v }),
      /* @__PURE__ */ e("span", { className: "input-group-text text-secondary", children: ":" }),
      /* @__PURE__ */ e("input", { className: "form-control", onChange: V, placeholder: "SS", type: "text", value: g })
    ] })
  ] });
};
ne.displayName = "BRL.DatePickerDatetime";
export {
  ne as D
};
//# sourceMappingURL=date-picker-datetime.js.map
