import { r as e } from "../chunks/select-kZQRRj2e.js";
import { useMemo as t } from "react";
import { cn as n } from "@ryuzaki13/react-foundation-lib/utils";
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
import { DEFAULT_VALUE_STATES as o, VALUE_STATE_COLOR_TOKENS as s } from "@ryuzaki13/react-foundation-lib/formatters";
var c = {
	button: "p4nQdZ",
	valueContainer: "_94tg5v",
	swatch: "HyK7Zs",
	optionsPalette: "Mm4hrB",
	optionsDetailed: "clxxBQ",
	option: "_5pJ7o-",
	optionPalette: "VV6hKN",
	optionDetailed: "cuQNP0",
	optionMeta: "w7nIOT",
	optionMetaIcon: "ed-Afj",
	optionMetaLabel: "Lbxloe"
};
//#endregion
//#region src/state-select/StateSelect.tsx
function l({ state: e, className: t }) {
	return /* @__PURE__ */ i("span", {
		className: n(c.swatch, t),
		"data-empty": e === "none" ? "" : void 0,
		style: { "--state-color": s[e] }
	});
}
function u(e) {
	return !!(e?.icon || e?.label);
}
function d(e, t) {
	return typeof t?.label == "string" && t.label.trim() ? t.label : e || "empty";
}
function f(e) {
	return u(e) ? /* @__PURE__ */ a("span", {
		className: c.optionMeta,
		children: [e?.icon ? /* @__PURE__ */ i("span", {
			className: c.optionMetaIcon,
			children: e.icon
		}) : null, e?.label ? /* @__PURE__ */ i("span", {
			className: c.optionMetaLabel,
			children: e.label
		}) : null]
	}) : null;
}
function p(e, t) {
	return /* @__PURE__ */ a("div", {
		className: c.valueContainer,
		children: [/* @__PURE__ */ i(l, { state: e }), f(t)]
	});
}
function m({ label: s, description: m, disabled: h, placeholder: g, size: _, value: v, onChange: y, options: b = o, stateMeta: x, className: S, clearable: C }) {
	let w = t(() => Array.from(new Set(b)), [b]), T = w.some((e) => u(x?.[e]));
	return /* @__PURE__ */ i(e, {
		label: s,
		description: m,
		disabled: h,
		placeholder: g,
		size: _,
		value: v,
		onChange: y,
		options: w,
		className: S,
		clearable: C,
		getOptionKey: (e) => e || "__empty_state__",
		getOptionLabel: (e) => x?.[e]?.label ?? e,
		getOptionAriaLabel: (e) => d(e, x?.[e]),
		renderValue: (e) => p(e, x?.[e]),
		renderOption: (e) => /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ i(l, { state: e }), T ? f(x?.[e]) : null] }),
		buttonClassName: c.button,
		optionsContentClassName: n(T ? c.optionsDetailed : c.optionsPalette),
		getOptionClassName: () => n(c.option, T ? c.optionDetailed : c.optionPalette)
	});
}
//#endregion
export { m as StateSelect };

//# sourceMappingURL=index.js.map