import { j as jsxRuntimeExports } from "../../../../../../../_virtual/jsx-runtime.js";
import "react";
import "../../../../../../../node_modules/.pnpm/@formkit_auto-animate@0.8.2/node_modules/@formkit/auto-animate/index.js";
import "../../../../../../../node_modules/.pnpm/react-hot-toast@2.5.2_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/react-hot-toast/dist/index.js";
import { FieldTitle } from "../field-factory.js";
import { tx as D } from "../../../../../../style-system/dist/twind.js";
import { a as c } from "../../../../../../sdk/dist/shared/chunk-QGYZ7CG5.js";
import "../../../../../../sdk/dist/shared/chunk-AFVJZPLS.js";
import "@sinclair/typebox";
import "../../../../../../sdk/dist/shared/chunk-A3GF4PYW.js";
import "../../../../../../sdk/dist/shared/chunk-W33JMRRN.js";
import { Icon } from "../../../../../../../node_modules/.pnpm/@iconify_react@6.0.0_react@19.1.1/node_modules/@iconify/react/dist/iconify.js";
import { Root as C, Trigger as u, Content as g, Group as y, Item as v } from "../../../../../../../node_modules/.pnpm/@radix-ui_themes@3.2.1_@types_react-dom@19.1.9_@types_react@19.1.13__@types_react@19.1._832fa1fef691e6e9510ada03948dc85c/node_modules/@radix-ui/themes/dist/esm/components/select.js";
import { Root as p, Item as l } from "../../../../../../../node_modules/.pnpm/@radix-ui_themes@3.2.1_@types_react-dom@19.1.9_@types_react@19.1.13__@types_react@19.1._832fa1fef691e6e9510ada03948dc85c/node_modules/@radix-ui/themes/dist/esm/components/segmented-control.js";
import { Tooltip as e } from "../../../../../../../node_modules/.pnpm/@radix-ui_themes@3.2.1_@types_react-dom@19.1.9_@types_react@19.1.13__@types_react@19.1._832fa1fef691e6e9510ada03948dc85c/node_modules/@radix-ui/themes/dist/esm/components/tooltip.js";
const EnumField = (props) => {
  const { schema, currentValue, formData, onChange, title, description, noFieldGrow } = props;
  const options = c(schema) ?? [];
  const displayAs = schema["ui:display"] ?? (options.length > 3 ? "select" : "button-group");
  switch (displayAs) {
    case "radio":
      return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "radio-field", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(FieldTitle, { title, description }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-2", children: options.filter((o) => !o["ui:hidden-option"]).map((option) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-1", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx(
              "input",
              {
                type: "radio",
                value: option.const,
                checked: currentValue === option.const,
                onChange: () => onChange(option.const),
                className: "form-radio mr-1 text-upstart-600 ring-upstart-600 focus:ring-transparent"
              }
            ),
            /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: option.title })
          ] }),
          option.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 leading-tight select-none", children: option.description })
        ] }, option.const)) })
      ] });
    case "button-group": {
      return /* @__PURE__ */ jsxRuntimeExports.jsxs(
        "div",
        {
          className: D("button-group-field flex-1 flex justify-between gap-2", !noFieldGrow && "flex-grow"),
          children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx(FieldTitle, { title, description }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(
              p,
              {
                onValueChange: onChange,
                defaultValue: currentValue,
                size: "1",
                radius: "medium",
                className: "!h-[26px]",
                children: options.filter((o) => !o["ui:hidden-option"]).map((option) => /* @__PURE__ */ jsxRuntimeExports.jsx(
                  l,
                  {
                    value: option.const,
                    className: D("[&_.rt-SegmentedControlItemLabel]:(px-[7px])"),
                    children: option.title
                  },
                  option.const
                ))
              }
            )
          ]
        }
      );
    }
    case "icon-group":
      return /* @__PURE__ */ jsxRuntimeExports.jsxs(
        "div",
        {
          className: D(
            "icon-group-field flex flex-grow shrink-0 justify-between gap-2",
            !noFieldGrow && "flex-grow"
          ),
          children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx(FieldTitle, { title, description }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(
              p,
              {
                onValueChange: onChange,
                defaultValue: currentValue,
                size: "1",
                radius: "medium",
                className: "!h-[26px]",
                children: options.filter((o) => !o["ui:hidden-option"]).map((option) => /* @__PURE__ */ jsxRuntimeExports.jsx(
                  l,
                  {
                    value: option.const,
                    className: D("[&_.rt-SegmentedControlItemLabel]:px-[6px]"),
                    children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                      e,
                      {
                        content: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "block text-xs p-0.5", children: option.title }),
                        className: "!z-[99999]",
                        children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: option["ui:icon"] ? /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { icon: option["ui:icon"], className: "w-5 h-5 pointer-events-none" }) : option.title })
                      },
                      option.const
                    )
                  },
                  option.const
                ))
              }
            )
          ]
        }
      );
    default:
      return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: D("flex justify-between pr-1 gap-4", !noFieldGrow && "flex-grow"), children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(FieldTitle, { title, description }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs(C, { defaultValue: currentValue, size: "2", onValueChange: (value) => onChange(value), children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(
            u,
            {
              radius: "large",
              variant: "ghost",
              placeholder: schema["ui:placeholder"] ?? "Not specified"
            }
          ),
          /* @__PURE__ */ jsxRuntimeExports.jsx(g, { position: "popper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(y, { children: options.filter((o) => !o["ui:hidden-option"]).map((option) => /* @__PURE__ */ jsxRuntimeExports.jsx(v, { value: option.const, children: option.title }, option.const)) }) })
        ] })
      ] });
  }
};
export {
  EnumField as default
};
//# sourceMappingURL=enum.js.map
