import { n as __exportAll } from "./chunk-B-1-B7_t.js";
import { n as Label_default } from "./label-C5K3zowH.js";
import { n as RadioGroup_default, t as RadioGroupItem_default } from "./radio-group-CGiUFEWB.js";
import { t as FieldFrame_default } from "./field-frame-DhCOWcMP.js";
import { Fragment, computed, createBlock, createElementBlock, createTextVNode, createVNode, defineComponent, mergeModels, normalizeClass, openBlock, renderList, toDisplayString, unref, useModel, withCtx } from "vue";
//#region src/components/compositions/elements/option-select/RadioOption.vue?vue&type=script&setup=true&lang.ts
var RadioOption_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "RadioOption",
	props: /* @__PURE__ */ mergeModels({
		modelValue: {},
		options: { default: () => [] },
		id: {},
		name: {},
		label: {},
		hideLabel: { type: Boolean },
		inline: { type: Boolean },
		required: { type: Boolean },
		readonly: { type: Boolean },
		disabled: { type: Boolean },
		helpText: {},
		errors: { default: () => [] }
	}, {
		"modelValue": {},
		"modelModifiers": {}
	}),
	emits: ["update:modelValue"],
	setup(__props) {
		/**
		* Props-driven radio-group composition. Composes the shadcn-vue
		* `RadioGroup` primitive with `FieldFrame` chrome.
		*
		*   <RadioOption v-model="size" :options="[...]" label="Size" />
		*/
		const props = __props;
		const model = useModel(__props, "modelValue");
		function normaliseOption(opt) {
			if (typeof opt === "string") return {
				label: opt,
				value: opt,
				disabled: false
			};
			return {
				label: opt.label,
				value: String(opt.value),
				disabled: Boolean(opt.disabled)
			};
		}
		const normalised = computed(() => (props.options ?? []).map(normaliseOption));
		const groupValue = computed(() => {
			if (model.value === void 0 || model.value === null) return;
			return String(model.value);
		});
		function onUpdate(next) {
			if (next === void 0 || next === null) {
				model.value = null;
				return;
			}
			if (typeof next === "string" || typeof next === "number") {
				model.value = next;
				return;
			}
			model.value = String(next);
		}
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(FieldFrame_default), {
				label: __props.label,
				required: __props.required,
				"hide-label": __props.hideLabel,
				"help-text": __props.helpText,
				errors: __props.errors
			}, {
				default: withCtx(() => [createVNode(unref(RadioGroup_default), {
					"model-value": groupValue.value,
					name: __props.name,
					disabled: __props.disabled || __props.readonly,
					required: __props.required,
					"data-element-name": __props.name ?? void 0,
					class: normalizeClass(__props.inline ? "flex flex-row flex-wrap gap-4" : "grid gap-2"),
					"onUpdate:modelValue": onUpdate
				}, {
					default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(normalised.value, (opt) => {
						return openBlock(), createElementBlock("div", {
							key: opt.value,
							class: "flex items-center gap-2"
						}, [createVNode(unref(RadioGroupItem_default), {
							id: `${__props.id ?? "radio"}-${opt.value}`,
							value: opt.value,
							disabled: opt.disabled
						}, null, 8, [
							"id",
							"value",
							"disabled"
						]), createVNode(unref(Label_default), {
							for: `${__props.id ?? "radio"}-${opt.value}`,
							class: "cursor-pointer"
						}, {
							default: withCtx(() => [createTextVNode(toDisplayString(opt.label), 1)]),
							_: 2
						}, 1032, ["for"])]);
					}), 128))]),
					_: 1
				}, 8, [
					"model-value",
					"name",
					"disabled",
					"required",
					"data-element-name",
					"class"
				])]),
				_: 1
			}, 8, [
				"label",
				"required",
				"hide-label",
				"help-text",
				"errors"
			]);
		};
	}
});
//#endregion
//#region src/components/compositions/elements/option-select/RadioOption.vue
var RadioOption_exports = /* @__PURE__ */ __exportAll({ default: () => RadioOption_default });
var RadioOption_default = RadioOption_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { RadioOption_exports as n, RadioOption_default as t };

//# sourceMappingURL=RadioOption-DJx4s6U7.js.map