import { e as b, F as B, ag as j, ah as v, ai as U, aj as w, ak as D, al as N, am as _, an as z, ao as A, ap as V } from "./Toggle-5mHDjpoq.js";
import { j as n } from "./jsx-runtime-NmMXPjeo.js";
import { C as u, d as k, l as x, e as F } from "./css-M9deYuc0.js";
import { useCallback as M, useState as T } from "react";
import { S } from "./Center-ZEYtK6iF.js";
import "./aggregator-e8E2YGic.js";
import { useController as E, useFormContext as H } from "react-hook-form";
const C = ({
  className: e,
  variant: t = "error",
  ...s
}) => /* @__PURE__ */ n.jsx(
  b,
  {
    className: u(
      u.B("input-help-text"),
      u.BM("input-help-text", t),
      e
    ),
    level: "small",
    ...s
  }
), I = ({ className: e, ...t }) => /* @__PURE__ */ n.jsx("label", { className: u(u.B("input-label"), e), ...t }), P = (e) => e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()), R = (e, t = "x") => e ?? (k.construct(t) === "y" ? "stretch" : "center"), O = ({
  label: e,
  showLabel: t = !0,
  helpText: s,
  direction: m = "y",
  className: a,
  children: f,
  align: r,
  size: g = "small",
  padHelpText: o = !1,
  ...p
}) => {
  let l;
  return m === "x" ? l = /* @__PURE__ */ n.jsxs(S, { direction: "y", size: "small", children: [
    f,
    (o || s != null && s.length > 0) && /* @__PURE__ */ n.jsx(C, { children: s })
  ] }) : l = /* @__PURE__ */ n.jsxs(S, { direction: "y", size: 1 / 3, children: [
    f,
    (o || s != null && s.length > 0) && /* @__PURE__ */ n.jsx(C, { children: s })
  ] }), /* @__PURE__ */ n.jsxs(
    S,
    {
      className: u(u.B("input-item"), a),
      direction: m,
      size: g,
      align: R(r, m),
      ...p,
      children: [
        t && /* @__PURE__ */ n.jsx(I, { children: e }),
        l
      ]
    }
  );
}, $ = B(j), q = ({
  name: e,
  rules: t,
  shouldUnregister: s,
  defaultValue: m,
  label: a,
  children: f = $,
  alsoValidate: r,
  padHelpText: g = !0,
  ref: o,
  ...p
}) => {
  var h;
  const { field: l, fieldState: d } = E({
    rules: t,
    name: e
  }), { trigger: i } = H();
  a == null && (a = P(e));
  const c = M(() => {
    l.onBlur(), r != null && i(r);
  }, [l.onBlur, i, r, e]);
  return /* @__PURE__ */ n.jsx(
    O,
    {
      label: a,
      padHelpText: g,
      helpText: (h = d.error) == null ? void 0 : h.message,
      ...p,
      children: f({
        onChange: l.onChange,
        value: l.value,
        onBlur: c
      })
    }
  );
}, L = ({
  value: e,
  onChange: t,
  onBlur: s,
  ...m
}) => {
  const a = new x(e, "UTC"), [f, r] = T(
    a.fString("ISO", "local").slice(0, -1)
  ), [g, o] = T(!0), p = (d) => {
    let i = d.toString();
    r(i);
    let c = new x(d, "UTC");
    i.length < 23 && (i += ".000"), c = c.add(
      BigInt(
        x.now().date().getTimezoneOffset() - c.date().getTimezoneOffset()
      ) * F.MINUTE.valueOf()
    );
    let h = !1;
    try {
      h = c.fString("ISO", "local").slice(0, -1) === i;
    } catch {
      console.error("e");
    }
    if (!h) {
      o(!1);
      return;
    }
    t(Number(c.valueOf())), o(!0);
  }, l = (d) => {
    o(!0), r(new x(e, "UTC").fString("ISO", "local").slice(0, -1)), s == null || s(d);
  };
  return /* @__PURE__ */ n.jsx(
    j,
    {
      type: "datetime-local",
      onBlur: l,
      required: !1,
      value: g ? new x(e, "UTC").fString("ISO", "local").slice(0, -1) : f,
      onChange: p,
      ...m
    }
  );
}, Y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Date: v,
  DateTime: L,
  DragButton: U,
  HFItem: q,
  HelpText: C,
  Item: O,
  Label: I,
  Numeric: w,
  Switch: D,
  Text: j,
  TextArea: N,
  Time: _,
  combineDateAndTimeValue: z,
  useDate: A,
  useTime: V
}, Symbol.toStringTag, { value: "Module" }));
export {
  O as I,
  Y as e
};
//# sourceMappingURL=external-6Q0ZX0n9.js.map
