import { jsxs as z, jsx as t } from "react/jsx-runtime";
import { forwardRef as E } from "react";
import { TextInput as b } from "../TextInput/TextInput.es.js";
import F from "../../foundation/Icon/Generated/IconCalendar.es.js";
import I from "../../foundation/Icon/Generated/IconCaretDown.es.js";
import O from "../../foundation/Icon/Generated/IconCaretUp.es.js";
import { IconSize as l } from "../../foundation/Icon/IconSize.es.js";
import { merge as f } from "../../utilities/merge.es.js";
import { Validation as a } from "../../utilities/validation.es.js";
const R = E(
  ({
    value: i,
    onClick: r,
    isClearable: s,
    placeHolder: m,
    isCalendarOpen: w,
    validation: e = a.Default,
    onDateChanged: n,
    hugWidth: d = !0,
    "aria-label": g
  }, p) => {
    const u = e === a.Error || e === a.Warning, h = "tw-right-14", S = "tw-right-8", y = "tw-right-4", c = ((o) => {
      switch (o) {
        case 0:
          return y;
        case 1:
          return S;
        case 2:
          return h;
      }
      return "";
    })(
      (i && s ? 1 : 0) + (u ? 1 : 0)
    );
    return /* @__PURE__ */ z("div", { ref: p, className: d ? "tw-w-auto" : "tw-w-full", children: [
      /* @__PURE__ */ t(
        "div",
        {
          className: f([
            "tw-absolute tw-top-2 tw-text-black-60 tw-z-[1]",
            c
          ]),
          children: w ? /* @__PURE__ */ t(O, { size: l.Size20 }) : /* @__PURE__ */ t(I, { size: l.Size20 })
        }
      ),
      /* @__PURE__ */ t(
        "div",
        {
          className: f([
            "tw-absolute tw-top-0 tw-left-0 tw-bottom-0 tw-z-10",
            c
          ]),
          onClick: r,
          role: "button",
          tabIndex: 0,
          onKeyDown: (o) => {
            (o.key === "Enter" || o.key === " ") && (r == null || r());
          },
          "aria-label": g,
          "data-test-id": "open-close-click-zone"
        }
      ),
      /* @__PURE__ */ t(
        b,
        {
          decorator: /* @__PURE__ */ t(F, {}),
          placeholder: m,
          value: i,
          clearable: s,
          onEnterPressed: r,
          onClear: () => {
            n && n(null);
          },
          validation: e
        }
      )
    ] });
  }
);
R.displayName = "FondueDatePickerTrigger";
export {
  R as DatePickerTrigger
};
//# sourceMappingURL=DatePickerTrigger.es.js.map
