import { t as e } from "../chunks/ui.module-DHVTOqZ0.js";
import { c as t, f as n, i as r, l as i, p as a, t as o } from "../chunks/picker-CrRdwdA5.js";
import { useRef as s, useState as c } from "react";
import { cn as l } from "@ryuzaki13/react-foundation-lib/utils";
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
//#region src/layout-picker/lib/layout.ts
function p(e, t) {
	return {
		gridTemplateColumns: `repeat(${e.columns}, minmax(0, 1fr))`,
		gridTemplateRows: `repeat(${e.rows}, minmax(${t ?? 0}em, 1fr))`
	};
}
function m(e) {
	return {
		gridColumn: `${e.column} / span ${e.columnSpan ?? 1}`,
		gridRow: `${e.row} / span ${e.rowSpan ?? 1}`
	};
}
//#endregion
//#region src/layout-picker/lib/presets.ts
var h = [
	{
		id: "1x1",
		label: "1x1",
		columns: 1,
		rows: 1,
		cells: [{
			id: "c11",
			row: 1,
			column: 1
		}]
	},
	{
		id: "1x2",
		label: "1x2",
		columns: 2,
		rows: 1,
		cells: [{
			id: "c11",
			row: 1,
			column: 1
		}, {
			id: "c12",
			row: 1,
			column: 2
		}]
	},
	{
		id: "1x3",
		label: "1x3",
		columns: 3,
		rows: 1,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c13",
				row: 1,
				column: 3
			}
		]
	},
	{
		id: "2x1",
		label: "2x1",
		columns: 1,
		rows: 2,
		cells: [{
			id: "c11",
			row: 1,
			column: 1
		}, {
			id: "c21",
			row: 2,
			column: 1
		}]
	},
	{
		id: "2x2",
		label: "2x2",
		columns: 2,
		rows: 2,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			}
		]
	},
	{
		id: "2x3",
		label: "2x3",
		columns: 3,
		rows: 2,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c13",
				row: 1,
				column: 3
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c23",
				row: 2,
				column: 3
			}
		]
	},
	{
		id: "3x1",
		label: "3x1",
		columns: 1,
		rows: 3,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c31",
				row: 3,
				column: 1
			}
		]
	},
	{
		id: "3x2",
		label: "3x2",
		columns: 2,
		rows: 3,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c32",
				row: 3,
				column: 2
			}
		]
	},
	{
		id: "3x3",
		label: "3x3",
		columns: 3,
		rows: 3,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c13",
				row: 1,
				column: 3
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c23",
				row: 2,
				column: 3
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c32",
				row: 3,
				column: 2
			},
			{
				id: "c33",
				row: 3,
				column: 3
			}
		]
	},
	{
		id: "4x1",
		label: "4x1",
		columns: 1,
		rows: 4,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c41",
				row: 4,
				column: 1
			}
		]
	},
	{
		id: "4x2",
		label: "4x2",
		columns: 2,
		rows: 4,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c32",
				row: 3,
				column: 2
			},
			{
				id: "c41",
				row: 4,
				column: 1
			},
			{
				id: "c42",
				row: 4,
				column: 2
			}
		]
	},
	{
		id: "4x3",
		label: "4x3",
		columns: 3,
		rows: 4,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c13",
				row: 1,
				column: 3
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c23",
				row: 2,
				column: 3
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c32",
				row: 3,
				column: 2
			},
			{
				id: "c33",
				row: 3,
				column: 3
			},
			{
				id: "c41",
				row: 4,
				column: 1
			},
			{
				id: "c42",
				row: 4,
				column: 2
			},
			{
				id: "c43",
				row: 4,
				column: 3
			}
		]
	},
	{
		id: "2x2-l",
		label: "Большая слева + две справа",
		columns: 2,
		rows: 2,
		cells: [
			{
				id: "left",
				row: 1,
				column: 1,
				rowSpan: 2
			},
			{
				id: "rt",
				row: 1,
				column: 2
			},
			{
				id: "rb",
				row: 2,
				column: 2
			}
		]
	},
	{
		id: "2x2-r",
		label: "Две слева + большая справа",
		columns: 2,
		rows: 2,
		cells: [
			{
				id: "lt",
				row: 1,
				column: 1
			},
			{
				id: "lb",
				row: 2,
				column: 1
			},
			{
				id: "right",
				row: 1,
				column: 2,
				rowSpan: 2
			}
		]
	},
	{
		id: "2x2-t",
		label: "Широкая сверху + две снизу",
		columns: 2,
		rows: 2,
		cells: [
			{
				id: "top",
				row: 1,
				column: 1,
				columnSpan: 2
			},
			{
				id: "bl",
				row: 2,
				column: 1
			},
			{
				id: "br",
				row: 2,
				column: 2
			}
		]
	},
	{
		id: "2x2-b",
		label: "Две сверху + широкая снизу",
		columns: 2,
		rows: 2,
		cells: [
			{
				id: "tl",
				row: 1,
				column: 1
			},
			{
				id: "tr",
				row: 1,
				column: 2
			},
			{
				id: "bottom",
				row: 2,
				column: 1,
				columnSpan: 2
			}
		]
	},
	{
		id: "3x2-t",
		label: "Широкая сверху + 2x2",
		columns: 2,
		rows: 3,
		cells: [
			{
				id: "top",
				row: 1,
				column: 1,
				columnSpan: 2
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c32",
				row: 3,
				column: 2
			}
		]
	},
	{
		id: "3x2-b",
		label: "2x2 + широкая снизу",
		columns: 2,
		rows: 3,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "bottom",
				row: 3,
				column: 1,
				columnSpan: 2
			}
		]
	},
	{
		id: "3x2-m",
		label: "Широкая по центру",
		columns: 2,
		rows: 3,
		cells: [
			{
				id: "tl",
				row: 1,
				column: 1
			},
			{
				id: "tr",
				row: 1,
				column: 2
			},
			{
				id: "middle",
				row: 2,
				column: 1,
				columnSpan: 2
			},
			{
				id: "bl",
				row: 3,
				column: 1
			},
			{
				id: "br",
				row: 3,
				column: 2
			}
		]
	},
	{
		id: "3x3-l",
		label: "Большая слева + 2x3 справа",
		columns: 3,
		rows: 3,
		cells: [
			{
				id: "left",
				row: 1,
				column: 1,
				rowSpan: 3
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c13",
				row: 1,
				column: 3
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c23",
				row: 2,
				column: 3
			},
			{
				id: "c32",
				row: 3,
				column: 2
			},
			{
				id: "c33",
				row: 3,
				column: 3
			}
		]
	},
	{
		id: "3x3-r",
		label: "2x3 слева + большая справа",
		columns: 3,
		rows: 3,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "right",
				row: 1,
				column: 3,
				rowSpan: 3
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c32",
				row: 3,
				column: 2
			}
		]
	},
	{
		id: "3x3-t",
		label: "Широкая сверху + 2x3",
		columns: 3,
		rows: 3,
		cells: [
			{
				id: "top",
				row: 1,
				column: 1,
				columnSpan: 3
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c23",
				row: 2,
				column: 3
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c32",
				row: 3,
				column: 2
			},
			{
				id: "c33",
				row: 3,
				column: 3
			}
		]
	},
	{
		id: "3x3-b",
		label: "2x3 + широкая снизу",
		columns: 3,
		rows: 3,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c13",
				row: 1,
				column: 3
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c23",
				row: 2,
				column: 3
			},
			{
				id: "bottom",
				row: 3,
				column: 1,
				columnSpan: 3
			}
		]
	},
	{
		id: "4x2-t",
		label: "Широкая сверху + 3x2",
		columns: 2,
		rows: 4,
		cells: [
			{
				id: "top",
				row: 1,
				column: 1,
				columnSpan: 2
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c32",
				row: 3,
				column: 2
			},
			{
				id: "c41",
				row: 4,
				column: 1
			},
			{
				id: "c42",
				row: 4,
				column: 2
			}
		]
	},
	{
		id: "4x2-b",
		label: "3x2 + широкая снизу",
		columns: 2,
		rows: 4,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c32",
				row: 3,
				column: 2
			},
			{
				id: "bottom",
				row: 4,
				column: 1,
				columnSpan: 2
			}
		]
	},
	{
		id: "4x3-t",
		label: "Широкая сверху + 3x3",
		columns: 3,
		rows: 4,
		cells: [
			{
				id: "top",
				row: 1,
				column: 1,
				columnSpan: 3
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c23",
				row: 2,
				column: 3
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c32",
				row: 3,
				column: 2
			},
			{
				id: "c33",
				row: 3,
				column: 3
			},
			{
				id: "c41",
				row: 4,
				column: 1
			},
			{
				id: "c42",
				row: 4,
				column: 2
			},
			{
				id: "c43",
				row: 4,
				column: 3
			}
		]
	},
	{
		id: "4x3-b",
		label: "3x3 + широкая снизу",
		columns: 3,
		rows: 4,
		cells: [
			{
				id: "c11",
				row: 1,
				column: 1
			},
			{
				id: "c12",
				row: 1,
				column: 2
			},
			{
				id: "c13",
				row: 1,
				column: 3
			},
			{
				id: "c21",
				row: 2,
				column: 1
			},
			{
				id: "c22",
				row: 2,
				column: 2
			},
			{
				id: "c23",
				row: 2,
				column: 3
			},
			{
				id: "c31",
				row: 3,
				column: 1
			},
			{
				id: "c32",
				row: 3,
				column: 2
			},
			{
				id: "c33",
				row: 3,
				column: 3
			},
			{
				id: "bottom",
				row: 4,
				column: 1,
				columnSpan: 3
			}
		]
	}
];
function g() {
	return h[0].id;
}
function _(e) {
	return h.find((t) => t.id === e) ?? h[0];
}
function v(e) {
	return h.find((t) => t.id === e)?.cells.length ?? 1;
}
var y = {
	valueOverlay: "_959ulH",
	triggerInput: "Ch-SZL",
	triggerText: "SmdPit",
	popup: "giOtGs",
	popupLayout: "_57Tr0T",
	popupBody: "Tkhulr",
	options: "VQlniu",
	option: "wb39Kf",
	optionActive: "HGvQdT",
	optionSelected: "rZuYyb",
	previewCell: "VrHnjN",
	optionPreviewWrap: "vNV6Q2",
	preview: "koxYU-",
	previewPlaceholder: "k8xLa2",
	previewCompact: "_5pd3Bb"
}, b = "Выберите раскладку";
function x({ preset: e, compact: t = !1 }) {
	return /* @__PURE__ */ d("span", {
		className: l(y.preview, t && y.previewCompact),
		style: p(e),
		"aria-hidden": "true",
		"data-ui": "layout-picker-preview",
		children: e.cells.map((t) => /* @__PURE__ */ d("span", {
			className: y.previewCell,
			style: m(t)
		}, `${e.id}:${t.id}`))
	});
}
function S({ id: p, label: m, description: g, value: _, onChange: v, presets: S = h, disabled: C, getPresetDisabled: w, placeholder: T = b, showPlaceholder: E = !1, size: D, ariaLabel: O, className: k, triggerClassName: ee, popupClassName: te, placement: A = "bottom-start" }) {
	let j = s(null), [M, N] = c(!1), P = S.findIndex((e) => e.id === _), F = P >= 0 ? S[P] : void 0, I = F ?? S[0], L = F?.label ?? T, { activeIndex: R, context: z, floatingStyles: B, getFloatingProps: V, setReference: H, setFloating: U, setOptionRef: W, close: G, openList: K, toggleOpen: q, selectOption: J, selectActiveOption: Y, handleReferenceKeyDown: X, handleFloatingKeyDown: Z, getOptionId: ne, getActiveOptionId: Q } = r({
		options: S,
		selectedIndex: P,
		open: M,
		onOpenChange: N,
		getOptionDisabled: w,
		onSelect: (e) => v(e.id),
		disabled: C,
		placement: A,
		triggerMode: "display"
	}), $ = o({
		mode: "display",
		open: M,
		currentQuery: "",
		hasDisplayValue: F !== void 0,
		inputRef: j,
		openList: K,
		close: G,
		toggleOpen: q
	}), re = (e) => {
		j.current = e;
	};
	return /* @__PURE__ */ d(a, {
		id: p,
		label: m,
		description: g,
		disabled: C,
		size: D,
		className: k,
		children: ({ controlId: r, labelId: a, describedBy: o }) => {
			let s = `${r}-listbox`;
			return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(t, {
				ref: re,
				rootRef: H,
				id: r,
				type: "button",
				disabled: C,
				readOnly: !0,
				autoComplete: "off",
				role: "combobox",
				value: L,
				"aria-haspopup": "listbox",
				"aria-expanded": M,
				"aria-controls": M ? s : void 0,
				"aria-labelledby": a,
				"aria-describedby": o,
				"aria-autocomplete": "none",
				"aria-activedescendant": M ? Q(s) : void 0,
				"aria-label": a ? void 0 : O ?? `Выбрать layout. Текущее значение: ${L}`,
				"data-ui": "layout-picker-trigger",
				rootClassName: ee,
				inputClassName: y.triggerInput,
				overlay: /* @__PURE__ */ f("div", {
					className: y.valueOverlay,
					children: [I ? /* @__PURE__ */ d(x, {
						preset: I,
						compact: !0
					}) : /* @__PURE__ */ d("span", { className: y.previewPlaceholder }), E ? /* @__PURE__ */ d("span", {
						className: l(y.triggerText, e.uiPlaceholder),
						"data-ui": "layout-picker-placeholder",
						children: T
					}) : null]
				}),
				endAdornment: /* @__PURE__ */ d(i, {
					open: M,
					disabled: C,
					onToggleMouseDown: $.handleToggleMouseDown,
					onToggleClick: $.handleToggleClick,
					openAriaLabel: "Открыть список layout",
					closeAriaLabel: "Закрыть список layout"
				}),
				onClick: $.handleTriggerClick,
				onFocus: (e) => {
					$.handleTriggerFocus(e.currentTarget);
				},
				onKeyDown: (e) => {
					X(e), !e.defaultPrevented && $.handleTriggerKeyDown({
						event: e,
						onActivateWhenOpen: Y,
						enableSpaceActivation: !0
					});
				}
			}), /* @__PURE__ */ d(n, {
				open: M,
				context: z,
				floatingStyles: B,
				listId: s,
				labelId: a,
				descriptionId: o,
				activeOptionId: Q(s),
				setFloating: U,
				getFloatingProps: V,
				onKeyDown: Z,
				className: l(e.uiPopupOptions, y.popup, te),
				layoutClassName: y.popupLayout,
				bodyClassName: y.popupBody,
				children: /* @__PURE__ */ d("div", {
					className: y.options,
					children: S.map((e, t) => {
						let n = t === P, r = t === R, i = w?.(e) ?? !1, a = ne(s, t);
						return /* @__PURE__ */ d("button", {
							id: a,
							ref: (e) => W(t, e),
							type: "button",
							role: "option",
							tabIndex: -1,
							disabled: i,
							"aria-selected": n,
							"aria-disabled": i || void 0,
							"aria-label": e.description ? `${e.label}. ${e.description}` : e.label,
							className: l(y.option, n && y.optionSelected, r && y.optionActive),
							"data-ui": "layout-picker-option",
							"data-selected": n || void 0,
							onMouseDown: (e) => e.preventDefault(),
							onClick: () => J(e),
							children: /* @__PURE__ */ d("span", {
								className: y.optionPreviewWrap,
								children: /* @__PURE__ */ d(x, { preset: e })
							})
						}, e.id);
					})
				})
			})] });
		}
	});
}
//#endregion
export { h as DEFAULT_LAYOUT_PICKER_PRESETS, S as LayoutPicker, g as getDefaultLayoutPickerPresetId, m as getLayoutCellStyle, p as getLayoutStyle, v as resolveLayoutCellCount, _ as resolveLayoutPreset };

//# sourceMappingURL=index.js.map