"use client";
import { t as e } from "./useControlled-ZBScq72P.js";
import { t } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { t as n } from "./useRenderElement-CmuWsiNa.js";
import { t as r } from "./useStableCallback-CqEVb76s.js";
import { g as i, t as a } from "./createBaseUIEventDetails-ChcQXp54.js";
import { t as o } from "./shadowDom-C-4Ejp9R.js";
import { t as s } from "./owner-BrzQrszh.js";
import { cn as c } from "./lib/utils.js";
import { i as l, n as u, r as d, t as f } from "./LabelableContext-Q1Z-xUI9.js";
import { t as p } from "./useLabelableId-Dgoo7-Ly.js";
import * as m from "react";
import { jsx as h } from "react/jsx-runtime";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/field/control/FieldControl.js
var g = /*#__PURE__*/ m.forwardRef(function(c, h) {
	let { render: g, className: _, id: v, name: y, value: b, disabled: x = !1, onValueChange: S, defaultValue: C, autoFocus: w = !1, style: T, ...E } = c, { state: D, name: O, disabled: k, setTouched: A, setDirty: j, validityData: M, setFocused: N, setFilled: P, validationMode: F, validation: I } = d(), L = k || x, R = O ?? y, z = {
		...D,
		disabled: L
	}, { labelId: B } = f(), V = p({ id: v });
	t(() => {
		let e = b != null;
		I.inputRef.current?.value || e && b !== "" ? P(!0) : e && b === "" && P(!1);
	}, [
		I.inputRef,
		P,
		b
	]);
	let H = m.useRef(null);
	t(() => {
		w && H.current === o(s(H.current)) && N(!0);
	}, [w, N]);
	let [U] = e({
		controlled: b,
		default: C,
		name: "FieldControl",
		state: "value"
	}), W = b !== void 0, G = W ? U : void 0, K = r(() => I.inputRef.current?.value);
	return u(I.inputRef, V, G, K), n("input", c, {
		ref: [h, H],
		state: z,
		props: [
			{
				id: V,
				disabled: L,
				name: R,
				ref: I.inputRef,
				"aria-labelledby": B,
				autoFocus: w,
				...W ? { value: G } : { defaultValue: C },
				onChange(e) {
					let t = e.currentTarget.value;
					S?.(t, a(i, e.nativeEvent)), j(t !== M.initialValue), P(t !== "");
				},
				onFocus() {
					N(!0);
				},
				onBlur(e) {
					A(!0), N(!1), F === "onBlur" && I.commit(e.currentTarget.value);
				},
				onKeyDown(e) {
					e.currentTarget.tagName === "INPUT" && e.key === "Enter" && (A(!0), I.commit(e.currentTarget.value));
				}
			},
			I.getInputValidationProps(),
			E
		],
		stateAttributesMapping: l
	});
});
process.env.NODE_ENV !== "production" && (g.displayName = "FieldControl");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/input/Input.js
var _ = /*#__PURE__*/ m.forwardRef(function(e, t) {
	return /*#__PURE__*/ h(g, {
		ref: t,
		...e
	});
});
process.env.NODE_ENV !== "production" && (_.displayName = "Input");
//#endregion
//#region lib/components/ui/atoms/input.tsx
function v({ className: e, type: t, ...n }) {
	return /* @__PURE__ */ h(_, {
		className: c("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base shadow-xs outline-none transition-[color,box-shadow] file:inline-flex file:h-7 file:border-0 file:bg-transparent file:font-medium file:text-foreground file:text-sm placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", e),
		"data-slot": "input",
		type: t,
		...n
	});
}
//#endregion
export { v as t };
