import { jsx as I } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import O from "./DateFilterCore.js";
import { FilterParam as e } from "../../../../types.js";
import { useMemo as i, useState as _, useCallback as d } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { DateRangeFilterParam as T } from "./types.js";
import A from "../../../../../core/Context/preact/useCoreContext.js";
import { EMPTY_OBJECT as S } from "../../../../../utils/value/constants.js";
const U = ({
  timezone: u,
  canResetFilters: s,
  defaultParams: t,
  filters: m,
  nowTimestamp: c,
  refreshNowTimestamp: E,
  sinceDate: R,
  untilDate: D,
  updateFilters: n
}) => {
  const { i18n: o } = A(), l = i(() => o.get("common.filters.types.date.label"), [o]), r = i(() => o.get(t.current.defaultTimeRange), [o, t]), [f, C] = _(r), g = d(
    (p = S) => {
      for (const [b, a] of Object.entries(p)) {
        switch (b) {
          case "selectedPresetOption":
            C(a || r);
            break;
          case T.FROM:
            n({
              [e.CREATED_SINCE]: a || t.current.defaultFilterParams[e.CREATED_SINCE]
            });
            break;
          case T.TO:
            n({
              [e.CREATED_UNTIL]: a || t.current.defaultFilterParams[e.CREATED_UNTIL]
            });
            break;
          default:
            return;
        }
        E();
      }
    },
    [r, E, n, t]
  );
  return i(() => !s && C(r), [s, r]), /* @__PURE__ */ I(
    O,
    {
      label: l,
      "aria-label": l,
      name: e.CREATED_SINCE,
      sinceDate: R,
      untilDate: D ?? new Date(c).toString(),
      from: m[e.CREATED_SINCE],
      to: m[e.CREATED_UNTIL],
      selectedPresetOption: f,
      timeRangePresetOptions: t.current.timeRangeOptions,
      timezone: u,
      onChange: g,
      showTimezoneInfo: !0,
      now: c
    }
  );
};
export {
  U as default
};
