import { o as e } from "../chunks/flex-DYZ0IbU6.js";
import { t } from "../chunks/date-input-DT9E8dhk.js";
import { c as n, l as r, r as i, s as a, t as o, u as s } from "../chunks/date-range-preset-select-BLnY47cv.js";
import { useCallback as c, useMemo as l, useRef as u, useState as d } from "react";
import { jsx as f, jsxs as p } from "react/jsx-runtime";
//#region src/preset-range-date-input/lib/constants.ts
var m = "preset-range-date-input";
//#endregion
//#region src/preset-range-date-input/ui/PresetRangeDateInput.tsx
function h(e) {
	return e ?? "__empty__";
}
function g({ value: m, onChange: g, presetId: _, onPresetIdChange: v, referenceDate: y, presetIds: b, presetOptions: x, presetLabel: S, presetDescription: C, presetPlaceholder: w = "Выберите пресет диапазона", presetDisabled: T, ...E }) {
	let [D] = d(() => /* @__PURE__ */ new Date()), O = y ?? D, k = l(() => x ?? r(a(b, i)), [b, x]), A = m ?? null, j = l(() => n(A, O, k), [
		A,
		k,
		O
	]), M = _ ?? j ?? void 0, N = u(""), P = c((e) => {
		if (!v) return;
		let t = h(e);
		t !== N.current && (N.current = t, v(e));
	}, [v]), F = (e) => {
		let t = s(e, O, k);
		if (!t) {
			P(null);
			return;
		}
		P(t.id), g(t.range);
	}, I = (e) => {
		g(e), P(n(e, O, k));
	};
	return /* @__PURE__ */ p(e, {
		gap: "sm",
		align: "end",
		children: [/* @__PURE__ */ f(o, {
			size: "md",
			label: S,
			description: C,
			placeholder: w,
			disabled: T ?? E.disabled,
			value: M,
			onChange: F,
			options: k,
			referenceDate: O
		}), /* @__PURE__ */ f(t, {
			...E,
			size: "md",
			value: A,
			onChange: I
		})]
	});
}
//#endregion
export { m as PRESET_RANGE_DATE_INPUT_COMPONENT_ID, g as PresetRangeDateInput };

//# sourceMappingURL=index.js.map