"use client";
import { cn, normalizeOptions } from "./index3.js";
import { SelectItem, SelectPopup, SelectRoot, SelectTrigger, SelectValue } from "./index32.js";
import { useAIInteraction } from "./index407.js";
import * as React from "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region src/components/organisms/ai/AISelect/AISelect.tsx
/**
* AISelect - An interactive select/dropdown for use in AI chat messages.
*
* Renders a select dropdown that emits interaction events when the user makes a selection.
* Supports both string array shorthand and full option object format.
*/
function AISelect({ schema, className }) {
	const { onInteraction } = useAIInteraction();
	const labelId = React.useId();
	const normalizedOptions = React.useMemo(() => normalizeOptions(schema.options), [schema.options]);
	const handleValueChange = React.useCallback((value) => {
		onInteraction?.({
			componentId: schema.id,
			componentType: "select",
			action: "change",
			value,
			timestamp: Date.now()
		});
	}, [onInteraction, schema.id]);
	return /* @__PURE__ */ jsxs("div", {
		"data-slot": "ai-select",
		className: cn("flex flex-col gap-1.5", className),
		children: [schema.label && /* @__PURE__ */ jsxs("span", {
			id: labelId,
			className: "text-sm font-medium text-foreground",
			children: [schema.label, schema.required && /* @__PURE__ */ jsx("span", {
				className: "text-destructive ml-0.5",
				"aria-hidden": "true",
				children: "*"
			})]
		}), /* @__PURE__ */ jsxs(SelectRoot, {
			defaultValue: typeof schema.defaultValue === "string" ? schema.defaultValue : void 0,
			onValueChange: handleValueChange,
			children: [/* @__PURE__ */ jsx(SelectTrigger, {
				"aria-labelledby": schema.label ? labelId : void 0,
				"aria-label": !schema.label ? schema.placeholder ?? "Select an option" : void 0,
				"aria-required": schema.required,
				children: /* @__PURE__ */ jsx(SelectValue, { placeholder: schema.placeholder })
			}), /* @__PURE__ */ jsx(SelectPopup, { children: normalizedOptions.map((option) => /* @__PURE__ */ jsx(SelectItem, {
				value: option.value,
				disabled: option.disabled,
				children: option.label
			}, option.value)) })]
		})]
	});
}
AISelect.displayName = "AISelect";
//#endregion
export { AISelect as default };

//# sourceMappingURL=index434.js.map