import { n as __exportAll } from "./chunk-B-1-B7_t.js";
import { n as Button_default } from "./button-B9CnnuTu.js";
import { t as Input_default } from "./input-CwDp-vE8.js";
import { t as FieldFrame_default } from "./field-frame-DhCOWcMP.js";
import { computed, createBlock, createCommentVNode, createElementVNode, createVNode, defineComponent, mergeModels, normalizeClass, onMounted, openBlock, ref, unref, useModel, useTemplateRef, withCtx } from "vue";
import { Eye, EyeOff } from "@lucide/vue";
//#region src/components/compositions/elements/input/PasswordInput.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "relative" };
var PasswordInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "PasswordInput",
	props: /* @__PURE__ */ mergeModels({
		modelValue: {},
		id: {},
		name: {},
		label: {},
		hideLabel: { type: Boolean },
		placeholder: {},
		required: { type: Boolean },
		readonly: { type: Boolean },
		disabled: { type: Boolean },
		maxlength: {},
		minlength: {},
		helpText: {},
		errors: { default: () => [] },
		autoFocus: { type: Boolean },
		togglePasswordVisibility: { type: Boolean }
	}, {
		"modelValue": {},
		"modelModifiers": {}
	}),
	emits: ["update:modelValue"],
	setup(__props) {
		/**
		* Props-driven password input composition. Composes the shadcn `Input`
		* primitive (with `type="password"`) and `FieldFrame` chrome. When
		* `togglePasswordVisibility` is set, renders an Eye/EyeOff toggle
		* button.
		*
		* Self-contained — usable directly in any Vue app:
		*
		*   <PasswordInput v-model="pw" label="Password" required toggle-password-visibility />
		*/
		const props = __props;
		const model = useModel(__props, "modelValue");
		const inputRef = useTemplateRef("inputRef");
		const visible = ref(false);
		const inputType = computed(() => visible.value ? "text" : "password");
		onMounted(() => {
			if (props.autoFocus) inputRef.value?.focus();
		});
		function toggleVisibility() {
			visible.value = !visible.value;
		}
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(FieldFrame_default), {
				label: __props.label,
				required: __props.required,
				"hide-label": __props.hideLabel,
				for: __props.id,
				"help-text": __props.helpText,
				errors: __props.errors
			}, {
				default: withCtx(() => [createElementVNode("div", _hoisted_1, [createVNode(unref(Input_default), {
					ref_key: "inputRef",
					ref: inputRef,
					"model-value": model.value ?? void 0,
					id: __props.id,
					name: __props.name ?? void 0,
					type: inputType.value,
					placeholder: __props.placeholder ?? "",
					readonly: __props.readonly,
					disabled: __props.disabled,
					required: __props.required,
					maxlength: __props.maxlength,
					minlength: __props.minlength,
					"data-element-name": __props.name ?? void 0,
					class: normalizeClass([__props.errors.length ? "border-destructive ring-destructive" : "", __props.togglePasswordVisibility ? "pr-10" : ""]),
					"onUpdate:modelValue": _cache[0] || (_cache[0] = (v) => model.value = v == null ? "" : String(v))
				}, null, 8, [
					"model-value",
					"id",
					"name",
					"type",
					"placeholder",
					"readonly",
					"disabled",
					"required",
					"maxlength",
					"minlength",
					"data-element-name",
					"class"
				]), __props.togglePasswordVisibility ? (openBlock(), createBlock(unref(Button_default), {
					key: 0,
					type: "button",
					variant: "ghost",
					size: "icon-sm",
					class: "absolute right-1 top-1/2 -translate-y-1/2",
					"aria-label": visible.value ? "Hide password" : "Show password",
					"data-testid": "password-toggle",
					onClick: toggleVisibility
				}, {
					default: withCtx(() => [visible.value ? (openBlock(), createBlock(unref(EyeOff), {
						key: 0,
						class: "h-4 w-4"
					})) : (openBlock(), createBlock(unref(Eye), {
						key: 1,
						class: "h-4 w-4"
					}))]),
					_: 1
				}, 8, ["aria-label"])) : createCommentVNode("", true)])]),
				_: 1
			}, 8, [
				"label",
				"required",
				"hide-label",
				"for",
				"help-text",
				"errors"
			]);
		};
	}
});
//#endregion
//#region src/components/compositions/elements/input/PasswordInput.vue
var PasswordInput_exports = /* @__PURE__ */ __exportAll({ default: () => PasswordInput_default });
var PasswordInput_default = PasswordInput_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { PasswordInput_exports as n, PasswordInput_default as t };

//# sourceMappingURL=PasswordInput-CEJxymes.js.map