import { jsxs as b, jsx as s } from "react/jsx-runtime";
import { a as T } from "./index.CfQlFjZU.js";
import { n as x } from "./index.B0wX8xO7.js";
import { c as y } from "./index.CfM2L_w0.js";
import { l as h } from "./lodash.xuulwbEa.js";
import { useMemo as M, useCallback as d } from "react";
import "./ProgressActivity.DYLCzf8q.js";
import "./formInputIcon.module.CU3tuFAI.js";
import { u as H } from "./useIsMobile.56gy4Bq-.js";
import "./isEqual.Bk3xqtBB.js";
import { a as I } from "./ChipFilter.4oJ283mr.js";
import { i as A, c as k } from "./Dropdown.CMeTYQwB.js";
const j = "creator_container_O4IR6", E = "creator_label_NfpOT", K = "creator_helper_-RyNk", O = "creator_fields_HIPzn", R = "creator_dropdown_EKglm", V = "creator_chips_I5nWf", W = "creator_error_iW0BK", n = { container: j, label: E, helper: K, fields: O, dropdown: R, chips: V, error: W }, z = ({
  label: u,
  value: r,
  onChange: a,
  hasHourError: c,
  hasMinuteError: l,
  ...f
}) => {
  const i = H(), _ = M(() => Array.from({ length: 12 }).map((e, o) => ({
    value: (o + 1).toString(),
    label: (o + 1).toString()
  })), []), g = M(() => i ? "Min" : "Minutes", [i]), m = M(() => Array.from({ length: 60 }).map((e, o) => ({
    value: o.toString(),
    label: o.toString().padStart(2, "0")
  })), []), t = d(
    (e) => {
      const o = e.period || "AM";
      a && a({ ...e, period: o });
    },
    [a]
  ), C = d(
    (e) => {
      const o = e.length && parseInt(A(e[0]));
      t({ ...r, hour: o });
    },
    [t, r]
  ), p = d(
    (e) => {
      const o = e.length && parseInt(A(e[0]));
      t({ ...r, minute: o });
    },
    [t, r]
  ), N = d(
    (e) => {
      e !== r?.period && t({ ...r, period: e });
    },
    [t, r]
  );
  return {
    label: u,
    hourItems: _,
    minuteItems: m,
    minuteLabel: g,
    hasHourError: c,
    hasMinuteError: l,
    hour: r?.hour?.toString(),
    minute: r?.minute?.toString(),
    period: r?.period || "AM",
    setHour: C,
    setMinute: p,
    setPeriod: N,
    containerClassName: y(n.container, {
      [n.error]: c || l
    }),
    labelClassName: n.label,
    fieldsClassName: n.fields,
    dropdownClassName: n.dropdown,
    chipsClassName: n.chips,
    helperClassName: n.helper,
    ...f
  };
}, B = ({
  label: u,
  hourItems: r,
  minuteItems: a,
  minuteLabel: c,
  helper: l,
  hasHourError: f,
  hasMinuteError: i,
  hour: _,
  minute: g,
  period: m,
  setHour: t,
  setMinute: C,
  setPeriod: p,
  containerClassName: N,
  labelClassName: e,
  fieldsClassName: o,
  dropdownClassName: S,
  chipsClassName: w,
  helperClassName: P
}) => /* @__PURE__ */ b("div", { className: N, children: [
  /* @__PURE__ */ s("label", { className: e, children: u }),
  /* @__PURE__ */ b("div", { className: o, children: [
    /* @__PURE__ */ s(
      k,
      {
        className: S,
        placeholder: "Hours",
        items: r,
        value: _,
        onSelect: t,
        onClick: h.noop,
        onChange: h.noop,
        hasError: f
      }
    ),
    /* @__PURE__ */ s(
      k,
      {
        className: S,
        placeholder: c,
        items: a,
        value: g,
        onSelect: C,
        onClick: h.noop,
        onChange: h.noop,
        hasError: i
      }
    ),
    /* @__PURE__ */ b("span", { className: w, children: [
      /* @__PURE__ */ s(
        I,
        {
          label: "AM",
          onClick: () => p("AM"),
          selected: m === "AM"
        }
      ),
      /* @__PURE__ */ s(
        I,
        {
          label: "PM",
          onClick: () => p("PM"),
          selected: m === "PM"
        }
      )
    ] })
  ] }),
  /* @__PURE__ */ s(
    x,
    {
      value: l,
      then: /* @__PURE__ */ s("label", { className: P, children: l })
    }
  )
] }), v = T(B, z);
export {
  v as T
};
