import { o as u, r as c } from "./rolldown-runtime.js";
import { i as p, t as m } from "./vendor/react.js";
import { r as x, t as f } from "./utils.js";
import { a as b, i as v, n as I, o as S, r as _ } from "./Select.js";
import { n as j } from "./interaction-context.js";
var t = /* @__PURE__ */ u(p(), 1), l = m();
function r({ schema: e, className: n }) {
  const { onInteraction: o } = j(), i = t.useId(), s = t.useMemo(() => x(e.options), [e.options]), d = t.useCallback((a) => {
    o?.({
      componentId: e.id,
      componentType: "select",
      action: "change",
      value: a,
      timestamp: Date.now()
    });
  }, [o, e.id]);
  return /* @__PURE__ */ (0, l.jsxs)("div", {
    "data-slot": "ai-select",
    className: f("flex flex-col gap-1.5", n),
    children: [e.label && /* @__PURE__ */ (0, l.jsxs)("span", {
      id: i,
      className: "text-sm font-medium text-foreground",
      children: [e.label, e.required && /* @__PURE__ */ (0, l.jsx)("span", {
        className: "text-destructive ml-0.5",
        "aria-hidden": "true",
        children: "*"
      })]
    }), /* @__PURE__ */ (0, l.jsxs)(v, {
      defaultValue: typeof e.defaultValue == "string" ? e.defaultValue : void 0,
      onValueChange: d,
      children: [/* @__PURE__ */ (0, l.jsx)(b, {
        "aria-labelledby": e.label ? i : void 0,
        "aria-label": e.label ? void 0 : e.placeholder ?? "Select an option",
        "aria-required": e.required,
        children: /* @__PURE__ */ (0, l.jsx)(S, { placeholder: e.placeholder })
      }), /* @__PURE__ */ (0, l.jsx)(_, { children: s.map((a) => /* @__PURE__ */ (0, l.jsx)(I, {
        value: a.value,
        disabled: a.disabled,
        children: a.label
      }, a.value)) })]
    })]
  });
}
r.displayName = "AISelect";
var N = /* @__PURE__ */ c({
  AISelect: () => r,
  default: () => r
});
export {
  r as n,
  N as t
};

//# sourceMappingURL=AISelect.js.map