import { jsx as a, jsxs as R } from "react/jsx-runtime";
import h from "react";
import { a as j } from "./index.CfQlFjZU.js";
import { s as v, a as E, D as I, C as N } from "./Header.CH7cTbOc.js";
import { D as O } from "./DatePickerDropdown.CWuVBLlU.js";
import { F as T } from "./Footer.D9uAPTrM.js";
import { R as Y } from "./rangeSelector.C0cE_3yU.js";
import { f as b } from "./format.CRlSnSc-.js";
const g = "creator_datePickerCard_i-s4Y", F = { datePickerCard: g }, H = ({
  dropdownPlaceholder: r,
  dropdownDisabled: u,
  selectedDate: e,
  disablePastDates: c,
  disableFutureDates: d,
  mode: k = "",
  label: y,
  helper: D,
  hasError: M,
  dropdownIcon: x,
  onDateChange: p
}) => {
  const i = /* @__PURE__ */ new Date(), [o, t] = h.useState(
    e
  ), [C, m] = h.useState(!1), [s, S] = h.useState(k);
  h.useEffect(() => {
    t(e);
  }, [e]);
  const n = (f) => {
    S(f);
  }, w = (f) => {
    t(f);
  }, l = [];
  c && l.push({
    from: /* @__PURE__ */ new Date(0),
    // Start of Unix epoch (past)
    to: v(i, 1)
  }), d && l.push({
    from: E(i, 1),
    to: new Date(i.getFullYear() + 100, 12, 31)
  });
  const P = r || "Choose an option", _ = o ? [b(o, "MMM dd, yyyy")] : [];
  return {
    disablePastDates: c,
    disableFutureDates: d,
    dropdownDisabled: u,
    expanded: C,
    setExpanded: m,
    selectedDay: o,
    setSelectedDay: t,
    mode: s,
    handleModeSelection: n,
    placeholder: P,
    disabledDates: l,
    selectedDate: e,
    label: y,
    helperText: C ? void 0 : D,
    hasError: M,
    selectedDropdownDate: _,
    dropdownIcon: x,
    onDateChange: p,
    handleDayClick: w,
    handleCancelClick: () => {
      t(e), m(!1), n("");
    },
    handleOkClick: () => {
      m(!1), p(o), n("");
    },
    CustomMonthsComponent: s !== "" ? (f) => /* @__PURE__ */ a(
      Y,
      {
        ...f,
        mode: s,
        disablePastDates: c,
        disableFutureDates: d,
        handleModeSelection: n
      }
    ) : void 0
  };
}, V = ({
  selectedDay: r,
  setSelectedDay: u,
  label: e,
  helperText: c,
  hasError: d,
  dropdownIcon: k,
  mode: y,
  selectedDropdownDate: D,
  handleModeSelection: M,
  placeholder: x,
  disabledDates: p,
  dropdownDisabled: i,
  disablePastDates: o,
  disableFutureDates: t,
  handleDayClick: C,
  handleCancelClick: m,
  handleOkClick: s,
  expanded: S,
  setExpanded: n,
  CustomMonthsComponent: w
}) => /* @__PURE__ */ a(
  O,
  {
    customSuffixIcon: k,
    expanded: S,
    setExpanded: n,
    placeholder: x,
    selectedItems: D,
    label: e,
    helper: c,
    hasError: d,
    disabled: i,
    handleOutsideClick: s,
    children: /* @__PURE__ */ a("div", { children: /* @__PURE__ */ R("div", { className: F.datePickerCard, children: [
      /* @__PURE__ */ a(
        I,
        {
          modifiers: { disabledDates: p },
          modifiersClassNames: {
            disabledDates: "rdp-day_disabled"
          },
          components: {
            Caption: (l) => /* @__PURE__ */ a(
              N,
              {
                ...l,
                disablePastDates: o,
                disableFutureDates: t,
                handleModeSelection: M
              }
            ),
            Months: w
          },
          onSelect: u,
          defaultMonth: r,
          selected: r,
          onDayClick: C
        }
      ),
      !y && /* @__PURE__ */ a(
        T,
        {
          handleCancelClick: m,
          handleOkClick: s
        }
      )
    ] }) })
  }
), Z = j(V, H);
export {
  Z as D,
  V as a,
  H as u
};
