require("./chunk-9hOWP6kD.cjs");
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
//#region ../../../node_modules/.pnpm/frimousse@0.2.0_react@19.2.4/node_modules/frimousse/dist/index.js
var ct = Object.defineProperty;
var ut = (e, t) => {
	for (var o in t) ct(e, o, {
		get: t[o],
		enumerable: !0
	});
};
var at = {};
ut(at, {
	ActiveEmoji: () => it,
	Empty: () => nt,
	List: () => tt,
	Loading: () => rt,
	Root: () => Je,
	Search: () => qe,
	SkinTone: () => st,
	SkinToneSelector: () => ot,
	Viewport: () => Ge
});
var q = "'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif", O = [
	"none",
	"light",
	"medium-light",
	"medium",
	"medium-dark",
	"dark"
];
function G(e) {
	return e.charAt(0).toUpperCase() + e.slice(1);
}
var $ = 2, x = null;
function ie(e) {
	try {
		x ??= document.createElement("canvas").getContext("2d", { willReadFrequently: !0 });
	} catch {}
	if (!x || (queueMicrotask(() => {
		x && (x = null);
	}), x.canvas.width = $, x.canvas.height = $, x.font = `2px ${q}`, x.textBaseline = "middle", x.measureText(e).width >= $ * 2)) return !1;
	x.fillStyle = "#00f", x.fillText(e, 0, 0);
	let t = x.getImageData(0, 0, $, $).data;
	x.clearRect(0, 0, $, $), x.fillStyle = "#f00", x.fillText(e, 0, 0);
	let o = x.getImageData(0, 0, $, $).data;
	for (let r = 0; r < $ * $ * 4; r += 4) if (t[r] !== o[r] || t[r + 1] !== o[r + 1] || t[r + 2] !== o[r + 2]) return !1;
	return !0;
}
function se(e, t, o) {
	try {
		let r = e.getItem(t);
		if (!r) throw new Error(`No value found for "${t}".`);
		return o(JSON.parse(r));
	} catch {
		return null;
	}
}
function ae(e, t, o) {
	e.setItem(t, JSON.stringify(o));
}
function ce(e) {
	return (t) => t === void 0 ? void 0 : e(t);
}
function ue(e) {
	return (t) => t === null ? null : e(t);
}
function v(e) {
	if (typeof e != "string") throw new Error();
	return e;
}
function _(e) {
	if (typeof e != "number") throw new Error();
	return e;
}
function le(e) {
	if (typeof e != "boolean") throw new Error();
	return e;
}
function F(e) {
	return (t) => {
		if (typeof t != "object" || t === null) throw new Error();
		let o = {};
		for (let r in e) {
			let n = t[r];
			n === void 0 && e[r](void 0), o[r] = e[r](n);
		}
		return o;
	};
}
function Z(e) {
	return (t) => {
		if (!Array.isArray(t)) throw new Error();
		return t.length > 0 && e(t[0]), t;
	};
}
var ke = (e, t) => `${e}/${t}/data.json`, we = (e, t) => `${e}/${t}/messages.json`, mt = [
	"bn",
	"da",
	"de",
	"en-gb",
	"en",
	"es-mx",
	"es",
	"et",
	"fi",
	"fr",
	"hi",
	"hu",
	"it",
	"ja",
	"ko",
	"lt",
	"ms",
	"nb",
	"nl",
	"pl",
	"pt",
	"ru",
	"sv",
	"th",
	"uk",
	"vi",
	"zh-hant",
	"zh"
], pe = "en", ye = (e) => `frimousse/data/${e}`, Ee = "frimousse/metadata";
async function he(e, t) {
	try {
		return (await fetch(e, {
			method: "HEAD",
			signal: t
		})).headers.get("etag");
	} catch {
		return null;
	}
}
async function dt(e, t, o) {
	let [{ emojis: r, emojisEtag: n }, { messages: s, messagesEtag: a }] = await Promise.all([fetch(ke(e, t), { signal: o }).then(async (i) => ({
		emojis: await i.json(),
		emojisEtag: i.headers.get("etag")
	})), fetch(we(e, t), { signal: o }).then(async (i) => ({
		messages: await i.json(),
		messagesEtag: i.headers.get("etag")
	}))]);
	return {
		emojis: r,
		messages: s,
		emojisEtag: n,
		messagesEtag: a
	};
}
async function ft(e, t, o) {
	let [r, n] = await Promise.all([he(ke(e, t), o), he(we(e, t), o)]);
	return {
		emojisEtag: r,
		messagesEtag: n
	};
}
function gt(e) {
	return e.skins ? e.skins.filter((o) => typeof o.tone == "number").reduce((o, r) => {
		let n = O[r.tone];
		return o[n] = r.emoji, o;
	}, {}) : void 0;
}
async function je(e, t, o) {
	let { emojis: r, emojisEtag: n, messages: s, messagesEtag: a } = await dt(e, t, o), i = s.subgroups.find((l) => l.key === "country-flag" || l.key === "subdivision-flag"), m = s.groups.filter((l) => l.key !== "component"), c = r.filter((l) => "group" in l), f = m.map((l) => ({
		index: l.order,
		label: G(l.message)
	})), u = s.skinTones.reduce((l, j) => (l[j.key] = G(j.message), l), {}), d = {
		locale: t,
		emojis: c.map((l) => ({
			emoji: l.emoji,
			category: l.group,
			version: l.version,
			label: G(l.label),
			tags: l.tags ?? [],
			countryFlag: i && l.subgroup === i.order || void 0,
			skins: gt(l)
		})),
		categories: f,
		skinTones: u
	};
	return ae(localStorage, ye(t), {
		data: d,
		metadata: {
			emojisEtag: n,
			messagesEtag: a
		}
	}), d;
}
function pt(e, t) {
	let o = /* @__PURE__ */ new Map();
	for (let a of e) o.has(a.version) || o.set(a.version, a.emoji);
	let r = [...o.keys()].sort((a, i) => i - a), n = r[0] ?? 0, s = ie("🇪🇺");
	if (typeof t == "number") return {
		emojiVersion: t,
		countryFlags: s
	};
	for (let a of r) if (ie(o.get(a))) return {
		emojiVersion: a,
		countryFlags: s
	};
	return {
		emojiVersion: n,
		countryFlags: s
	};
}
var Et = F({
	emojiVersion: _,
	countryFlags: le
}), ht = F({
	data: F({
		locale: v,
		emojis: Z(F({
			emoji: v,
			category: _,
			label: v,
			version: _,
			tags: Z(v),
			countryFlag: ce(le),
			skins: ce(F({
				light: v,
				"medium-light": v,
				medium: v,
				"medium-dark": v,
				dark: v
			}))
		})),
		categories: Z(F({
			index: _,
			label: v
		})),
		skinTones: F({
			light: v,
			"medium-light": v,
			medium: v,
			"medium-dark": v,
			dark: v
		})
	}),
	metadata: F({
		emojisEtag: ue(v),
		messagesEtag: ue(v)
	})
});
async function Se({ locale: e, emojiVersion: t, emojibaseUrl: o, signal: r }) {
	let n = typeof o == "string" ? o : `https://cdn.jsdelivr.net/npm/emojibase-data@${typeof t == "number" ? Math.floor(t) : "latest"}`, s = se(sessionStorage, Ee, Et), a = se(localStorage, ye(e), ht), i;
	if (!a) i = await je(n, e, r);
	else if (s) i = a.data;
	else try {
		let { emojisEtag: c, messagesEtag: f } = await ft(n, e, r);
		i = !c || !f || c !== a.metadata.emojisEtag || f !== a.metadata.messagesEtag ? await je(n, e, r) : a.data;
	} catch {
		i = a.data;
	}
	s ??= pt(i.emojis, t), ae(sessionStorage, Ee, s);
	return {
		locale: e,
		emojis: i.emojis.filter((c) => {
			let f = c.version <= s.emojiVersion;
			return c.countryFlag ? f && s.countryFlags : f;
		}),
		categories: i.categories,
		skinTones: i.skinTones
	};
}
function me(e) {
	return mt.includes(e) ? e : (console.warn(`Locale "${e}" is not supported, using "${pe}" instead.`), pe);
}
function de(e) {
	return O.includes(e) ? e : (console.warn(`Skin tone "${e}" is not valid, using "none" instead.`), "none");
}
function ve(e, t) {
	let o = [];
	if (t <= 0) return o;
	for (let r = 0, n = e.length; r < n; r += t) o.push(e.slice(r, r + t));
	return o;
}
function jt(e, t) {
	if (!t) return e;
	let o = t.toLowerCase().trim(), r = /* @__PURE__ */ new WeakMap();
	return e.filter((n) => {
		let s = 0;
		n.label.toLowerCase().includes(o) && (s += 10);
		for (let a of n.tags) a.toLowerCase().includes(o) && (s += 1);
		return s > 0 ? (r.set(n, s), !0) : !1;
	}).sort((n, s) => (r.get(s) ?? 0) - (r.get(n) ?? 0));
}
function Pe(e, t, o, r) {
	let n = jt(e.emojis, r), s = [], a = [], i = [], m = {}, c = 0, f = 0;
	for (let u of n) m[u.category] || (m[u.category] = []), m[u.category].push({
		emoji: o && o !== "none" && u.skins ? u.skins[o] : u.emoji,
		label: u.label
	});
	for (let u of e.categories) {
		let h = m[u.index];
		if (!h || h.length === 0) continue;
		let d = ve(Array.from(h), t).map((l) => ({
			categoryIndex: c,
			emojis: l
		}));
		s.push(...d), a.push({
			label: u.label,
			rowsCount: d.length,
			startRowIndex: f
		}), i.push(f), c++, f += d.length;
	}
	return {
		count: n.length,
		categories: a,
		categoriesStartRowIndices: i,
		rows: s,
		skinTones: e.skinTones
	};
}
function Te(e) {
	let t = {}, o = null, r = null, n = /* @__PURE__ */ new Set(), s = () => {
		if (o) {
			t = o, o = null;
			for (let c of n) c(t);
		}
		r = null;
	}, a = () => o ?? t, i = (c) => {
		o ??= t, Object.assign(o, typeof c == "function" ? c(a()) : c), r || (r = requestAnimationFrame(s));
	}, m = (c) => (n.add(c), () => n.delete(c));
	return t = e(i, a), {
		get: a,
		set: i,
		subscribe: m
	};
}
function xe(e) {
	let [t] = (0, react.useState)(e);
	return t;
}
function Ce(e) {
	let t = (0, react.createContext)(null);
	return {
		useStore: () => {
			let n = (0, react.useContext)(t);
			if (!n) throw new Error(e);
			return n;
		},
		Provider: ({ store: n, children: s }) => (0, react_jsx_runtime.jsx)(t.Provider, {
			value: n,
			children: s
		})
	};
}
function L(e, t, o = Object.is) {
	let [r, n] = (0, react.useState)(() => t(e.get()));
	return (0, react.useEffect)(() => e.subscribe(() => {
		let s = t(e.get());
		n((a) => o(a, s) ? a : s);
	}), [
		e,
		t,
		o
	]), (0, react.useDebugValue)(r), r;
}
function M(e, t, o) {
	return L(e, (0, react.useCallback)((n) => n[t], [t]), o);
}
var Re = 2;
function Le(e, t, o, r) {
	let n = 0;
	return Te((s, a) => ({
		locale: t,
		columns: o,
		skinTone: r,
		onEmojiSelect: e,
		data: null,
		search: "",
		interaction: "none",
		activeColumnIndex: 0,
		activeRowIndex: 0,
		rowHeight: null,
		categoryHeaderHeight: null,
		viewportWidth: null,
		viewportHeight: null,
		viewportCurrentCategoryIndex: null,
		viewportStartCategoryIndex: 0,
		viewportStartRowIndex: 0,
		viewportEndRowIndex: 0,
		rootRef: null,
		searchRef: null,
		viewportRef: null,
		listRef: null,
		updateViewportState: (i) => {
			let m = a(), c = i?.data ?? m.data, f = i?.categoryHeaderHeight ?? m.categoryHeaderHeight, u = i?.rowHeight ?? m.rowHeight, h = i?.viewportHeight ?? m.viewportHeight;
			if (!c || c.rows.length === 0 || !f || !u || !h) return s({
				...i,
				viewportStartCategoryIndex: 0,
				viewportStartRowIndex: 0,
				viewportEndRowIndex: 0
			});
			let d = 0, l = 0;
			for (let R of c.categories) if (l++ * f + R.startRowIndex * u < n) d += f;
			else break;
			let j = c.categories.length * f + c.rows.length * u, g = Math.floor(Re * u / 2), w = Math.ceil(Re * u / 2), P = Math.min(n - d - g, j - h), T = P + h + w, p = Math.max(0, Math.floor(P / u)), y = Math.min(c.rows.length - 1, Math.ceil(T / u)), S = c.rows[p]?.categoryIndex;
			return s(S === void 0 && i ? i : {
				...i,
				viewportStartCategoryIndex: S,
				viewportStartRowIndex: p,
				viewportEndRowIndex: y
			});
		},
		onDataChange: (i) => {
			a().updateViewportState({
				data: i,
				activeColumnIndex: 0,
				activeRowIndex: 0
			});
		},
		onSearchChange: (i) => {
			s({
				search: i,
				interaction: i ? "keyboard" : "none"
			});
		},
		onActiveEmojiChange: (i, m, c) => {
			if (s({
				interaction: i,
				activeColumnIndex: m,
				activeRowIndex: c
			}), i !== "keyboard") return;
			let { listRef: f, viewportRef: u, rowHeight: h, viewportHeight: d, categoryHeaderHeight: l } = a(), j = f?.current, g = u?.current;
			if (!j || !g || !h || !l || !d) return;
			let w = c;
			w === 0 && g.scrollTo({
				top: 0,
				behavior: "instant"
			});
			let P = j.querySelector(`[aria-rowindex="${w}"]`);
			if (!(P instanceof HTMLElement)) return;
			let T = P.offsetTop, p = getComputedStyle(P), y = Number.parseFloat(p.scrollMarginTop), S = Number.parseFloat(p.scrollMarginBottom), R = n + y;
			T < n + d / 2 && (R += l);
			let A = R + d - S;
			(T < R || T + h > A) && g.scrollTo({
				top: Math.max(T < R + l ? T - Math.max(l, y) : T - d + h + S, 0),
				behavior: "instant"
			});
		},
		onActiveEmojiReset: () => {
			s({
				interaction: "none",
				activeColumnIndex: 0,
				activeRowIndex: 0
			});
		},
		onRowHeightChange: (i) => {
			a().updateViewportState({ rowHeight: i });
		},
		onCategoryHeaderHeightChange: (i) => {
			a().updateViewportState({ categoryHeaderHeight: i });
		},
		onViewportSizeChange: (i, m) => {
			a().updateViewportState({
				viewportWidth: i,
				viewportHeight: m
			});
		},
		onViewportScroll: (i) => {
			n = i, a().updateViewportState();
		}
	}));
}
var { useStore: C, Provider: He } = Ce("EmojiPicker.Root is missing.");
function Ie(e) {
	return e.search;
}
function N(e) {
	return e.interaction === "none" ? void 0 : e.data?.rows[e.activeRowIndex]?.emojis[e.activeColumnIndex];
}
function De(e) {
	return e.data === void 0 || typeof e.data?.count == "number" && e.data.count === 0;
}
function Ae(e) {
	return e.data === null || e.viewportHeight === null || e.rowHeight === null || e.categoryHeaderHeight === null;
}
function fe(e) {
	return e.data?.rows.length;
}
function $e(e) {
	return e.data?.categories.length;
}
function Me(e) {
	return e.data?.categoriesStartRowIndices;
}
function Fe(e) {
	return e.data?.skinTones;
}
function ge(e, t) {
	return e?.emoji === t?.emoji;
}
function Ve(e, t) {
	return e?.categoryIndex !== t?.categoryIndex || e?.emojis.length !== t?.emojis.length ? !1 : !!e?.emojis.every((o, r) => ge(o, t?.emojis[r]));
}
var W = "‍", Oe = /\p{Emoji_Modifier_Base}/u, bt = /\uFE0F$/, Tt = /\u{1F3FB}|\u{1F3FC}|\u{1F3FD}|\u{1F3FE}|\u{1F3FF}/gu, xt = {
	light: "🏻",
	"medium-light": "🏼",
	medium: "🏽",
	"medium-dark": "🏾",
	dark: "🏿"
};
function Ct(e, t) {
	if (!e.split(W).some((r) => Oe.test(r))) return e;
	let o = e.split(W).map((r) => r.replace(Tt, "")).join(W);
	return t === "none" ? o : o.split(W).map((r, n, s) => {
		let a = s.length > 1;
		return !Oe.test(r) || a && r === "🤝" ? r : r.replace(bt, "") + xt[t];
	}).join(W);
}
function _e(e) {
	return O.map((t) => ({
		skinTone: t,
		emoji: Ct(e, t)
	}));
}
function X() {
	return (0, react.useDeferredValue)(L(C(), N, ge));
}
function Q(e = "✋") {
	let t = C(), o = M(t, "skinTone"), r = (0, react.useMemo)(() => _e(e), [e]);
	return [
		o,
		(0, react.useCallback)((s) => {
			t.set({ skinTone: s });
		}, []),
		r
	];
}
function ee(e, t) {
	if (Object.is(e, t)) return !0;
	if (typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
	let o = Object.keys(e), r = Object.keys(t);
	return o.length !== r.length ? !1 : o.every((n) => n in t && e[n] === t[n]);
}
function Ne(...e) {}
function We(e, t) {
	let o = null;
	if (typeof window.requestIdleCallback == "function") o = window.requestIdleCallback(e, t);
	else {
		let r = Date.now();
		o = window.setTimeout(() => {
			e({
				didTimeout: !1,
				timeRemaining: () => Math.max(0, (t?.timeout ?? 50) - (Date.now() - r))
			});
		}, 10);
	}
	return () => {
		typeof window.cancelIdleCallback == "function" ? window.cancelIdleCallback(o) : window.clearTimeout(o);
	};
}
var I = typeof window < "u" ? react.useLayoutEffect : react.useEffect;
function Be(e) {
	let t = (0, react.useRef)(e);
	return I(() => {
		t.current = e;
	}), (0, react.useCallback)((...o) => t.current(...o), []);
}
function Ft({ emojiVersion: e, emojibaseUrl: t }) {
	let [o, r] = (0, react.useState)(void 0), n = C(), s = M(n, "locale"), a = M(n, "columns"), i = M(n, "skinTone"), m = M(n, "search");
	return (0, react.useEffect)(() => {
		let c = new AbortController(), f = c.signal;
		return Se({
			locale: s,
			emojiVersion: e,
			emojibaseUrl: t,
			signal: f
		}).then((u) => {
			r(u);
		}).catch((u) => {
			f.aborted || console.error(u);
		}), () => {
			c.abort();
		};
	}, [
		e,
		t,
		s
	]), (0, react.useEffect)(() => {
		if (o) return We(() => {
			n.get().onDataChange(Pe(o, a, i, m));
		}, { timeout: 100 });
	}, [
		o,
		a,
		i,
		m
	]), null;
}
var Je = (0, react.forwardRef)(({ locale: e = "en", columns: t = 9, skinTone: o = "none", onEmojiSelect: r = Ne, emojiVersion: n, emojibaseUrl: s, onFocusCapture: a, onBlurCapture: i, children: m, style: c, ...f }, u) => {
	let h = Be(r), d = xe(() => Le(h, me(e), t, de(o))), [l, j] = (0, react.useState)(!1), g = (0, react.useRef)(null), w = (0, react.useCallback)((p) => {
		p && (g.current = p, d.set({ rootRef: g }));
	}, []);
	I(() => {
		d.set({ locale: me(e) });
	}, [e]), I(() => {
		d.set({ columns: t });
	}, [t]), I(() => {
		d.set({ skinTone: de(o) });
	}, [o]);
	let P = (0, react.useCallback)((p) => {
		a?.(p);
		let { searchRef: y, viewportRef: S } = d.get(), R = p.target === y?.current || p.target.hasAttribute("frimousse-search"), A = p.target === S?.current || p.target.hasAttribute("frimousse-viewport");
		p.isDefaultPrevented() || (j(R || A), p.isDefaultPrevented() || (j(R || A), A ? d.get().onActiveEmojiChange("keyboard", 0, 0) : R && d.get().search === "" && d.set({ interaction: "none" })));
	}, [a]), T = (0, react.useCallback)((p) => {
		i?.(p), !p.isDefaultPrevented() && !p.currentTarget.contains(p.relatedTarget) && j(!1);
	}, [i]);
	return I(() => {
		l || d.get().onActiveEmojiReset();
	}, [l]), (0, react.useImperativeHandle)(u, () => g.current), (0, react.useEffect)(() => {
		if (!l) return;
		function p(y) {
			if (y.defaultPrevented || !y.key.startsWith("Arrow") && y.key !== "Enter") return;
			let { data: S, onEmojiSelect: R, onActiveEmojiChange: A, interaction: U, activeColumnIndex: Y, activeRowIndex: J } = d.get();
			if (y.key === "Enter") {
				let b = N(d.get());
				b && (y.preventDefault(), R(b));
			}
			if (y.key.startsWith("Arrow")) {
				let b = Y, k = J;
				if (y.preventDefault(), U !== "none") {
					if (S?.rows && S.rows.length > 0) switch (y.key) {
						case "ArrowLeft":
							if (b === 0) {
								let H = k - 1, ne = S.rows[H];
								ne && (k = H, b = ne.emojis.length - 1);
							} else b -= 1;
							break;
						case "ArrowRight":
							if (b === S.rows[k].emojis.length - 1) {
								let H = k + 1;
								S.rows[H] && (k = H, b = 0);
							} else b += 1;
							break;
						case "ArrowUp": {
							let H = S.rows[k - 1];
							H && (k -= 1, H.emojis[b] || (b = H.emojis.length - 1));
							break;
						}
						case "ArrowDown": {
							let H = S.rows[k + 1];
							H && (k += 1, H.emojis[b] || (b = H.emojis.length - 1));
							break;
						}
					}
					A("keyboard", b, k);
				} else A("keyboard", 0, 0);
			}
		}
		return document.addEventListener("keydown", p), () => {
			document.removeEventListener("keydown", p);
		};
	}, [l]), I(() => {
		let p = null, y = null, S = null, R = null, A = d.subscribe((k) => {
			g.current && (p !== k.viewportWidth && (p = k.viewportWidth, g.current.style.setProperty("--frimousse-viewport-width", `${k.viewportWidth}px`)), y !== k.viewportHeight && (y = k.viewportHeight, g.current.style.setProperty("--frimousse-viewport-height", `${k.viewportHeight}px`)), S !== k.rowHeight && (S = k.rowHeight, g.current.style.setProperty("--frimousse-row-height", `${k.rowHeight}px`)), R !== k.categoryHeaderHeight && (R = k.categoryHeaderHeight, g.current.style.setProperty("--frimousse-category-header-height", `${k.categoryHeaderHeight}px`)));
		}), { viewportWidth: U, viewportHeight: Y, rowHeight: J, categoryHeaderHeight: b } = d.get();
		return U && g.current.style.setProperty("--frimousse-viewport-width", `${U}px`), Y && g.current.style.setProperty("--frimousse-viewport-height", `${Y}px`), J && g.current.style.setProperty("--frimousse-row-height", `${J}px`), b && g.current.style.setProperty("--frimousse-category-header-height", `${b}px`), A;
	}, []), (0, react_jsx_runtime.jsx)("div", {
		"data-focused": l ? "" : void 0,
		"frimousse-root": "",
		onBlurCapture: T,
		onFocusCapture: P,
		...f,
		ref: w,
		style: {
			"--frimousse-emoji-font": q,
			...c
		},
		children: (0, react_jsx_runtime.jsxs)(He, {
			store: d,
			children: [(0, react_jsx_runtime.jsx)(Ft, {
				emojiVersion: n,
				emojibaseUrl: s
			}), m]
		})
	});
}), qe = (0, react.forwardRef)(({ value: e, defaultValue: t, onChange: o, ...r }, n) => {
	let s = C(), a = (0, react.useRef)(null), i = (0, react.useCallback)((u) => {
		u && (a.current = u, s.set({ searchRef: a }));
	}, []), m = typeof e == "string", c = (0, react.useRef)(m);
	(0, react.useEffect)(() => {
		process.env.NODE_ENV !== "production" && c.current !== m && console.warn(`EmojiPicker.Search is changing from ${c ? "controlled" : "uncontrolled"} to ${m ? "controlled" : "uncontrolled"}.`), c.current = m;
	}, [m]), I(() => {
		s.set({ search: typeof e == "string" ? e : typeof t == "string" ? t : "" });
	}, []), I(() => {
		typeof e == "string" && s.get().onSearchChange(e);
	}, [e]);
	let f = (0, react.useCallback)((u) => {
		o?.(u), u.isDefaultPrevented() || s.get().onSearchChange(u.target.value);
	}, [o]);
	return (0, react.useImperativeHandle)(n, () => a.current), (0, react_jsx_runtime.jsx)("input", {
		autoCapitalize: "off",
		autoComplete: "off",
		autoCorrect: "off",
		enterKeyHint: "done",
		"frimousse-search": "",
		placeholder: "Search…",
		spellCheck: !1,
		type: "search",
		...r,
		defaultValue: t,
		onChange: f,
		ref: i,
		value: e
	});
}), Vt = (0, react.memo)(() => {
	let e = X();
	return e ? (0, react_jsx_runtime.jsx)("div", {
		"aria-live": "polite",
		style: {
			border: 0,
			clip: "rect(0, 0, 0, 0)",
			height: 1,
			margin: -1,
			overflow: "hidden",
			padding: 0,
			position: "absolute",
			whiteSpace: "nowrap",
			width: 1,
			wordWrap: "normal"
		},
		children: e.label
	}) : null;
}), Ge = (0, react.forwardRef)(({ children: e, onScroll: t, onKeyDown: o, style: r, ...n }, s) => {
	let a = C(), i = (0, react.useRef)(null), m = (0, react.useCallback)((h) => {
		h && (i.current = h, a.set({ viewportRef: i }));
	}, []), c = L(a, fe), f = L(a, $e), u = (0, react.useCallback)((h) => {
		t?.(h), a.get().onViewportScroll(h.currentTarget.scrollTop);
	}, [t]);
	return I(() => {
		if (!i.current) return;
		let h = new ResizeObserver(([d]) => {
			let l = d?.borderBoxSize[0]?.inlineSize ?? 0, j = d?.borderBoxSize[0]?.blockSize ?? 0, { onViewportSizeChange: g, viewportHeight: w, viewportWidth: P } = a.get();
			(w !== j || P !== l) && g(l, j);
		});
		return h.observe(i.current), a.get().onViewportSizeChange(i.current.offsetWidth, i.current.clientHeight), () => {
			h.disconnect();
		};
	}, []), (0, react.useImperativeHandle)(s, () => i.current), (0, react_jsx_runtime.jsxs)("div", {
		"frimousse-viewport": "",
		...n,
		onScroll: u,
		ref: m,
		style: {
			position: "relative",
			boxSizing: "border-box",
			contain: "layout paint",
			containIntrinsicSize: typeof c == "number" && typeof f == "number" ? `var(--frimousse-viewport-width, auto) calc(${c} * var(--frimousse-row-height) + ${f} * var(--frimousse-category-header-height))` : void 0,
			overflowY: "auto",
			overscrollBehavior: "contain",
			scrollbarGutter: "stable",
			willChange: "scroll-position",
			...r
		},
		children: [(0, react_jsx_runtime.jsx)(Vt, {}), e]
	});
});
function Ze(e, t, o) {
	return {
		emoji: {
			...e,
			isActive: o
		},
		role: "gridcell",
		"aria-colindex": t,
		"aria-selected": o || void 0,
		"aria-label": e.label,
		"data-active": o ? "" : void 0,
		"frimousse-emoji": "",
		style: { fontFamily: "var(--frimousse-emoji-font)" },
		tabIndex: -1
	};
}
function Xe(e, t = !1) {
	return {
		role: t ? void 0 : "row",
		"aria-rowindex": t ? void 0 : e,
		"frimousse-row": "",
		style: {
			contain: t ? void 0 : "content",
			height: t ? void 0 : "var(--frimousse-row-height)",
			display: "flex"
		}
	};
}
function Qe(e, t) {
	return {
		"frimousse-category": "",
		style: {
			contain: "content",
			top: t ? `calc(${e} * var(--frimousse-category-header-height) + ${t.startRowIndex} * var(--frimousse-row-height))` : void 0,
			height: t ? `calc(var(--frimousse-category-header-height) + ${t.rowsCount} * var(--frimousse-row-height))` : void 0,
			width: "100%",
			pointerEvents: "none",
			position: "absolute"
		}
	};
}
function et(e, t = !1) {
	return {
		category: e,
		"frimousse-category-header": "",
		style: {
			contain: t ? void 0 : "layout paint",
			height: t ? void 0 : "var(--frimousse-category-header-height)",
			pointerEvents: "auto",
			position: "sticky",
			top: 0
		}
	};
}
function ze(e, t, o, r) {
	return {
		"frimousse-list-sizer": "",
		style: {
			position: "relative",
			boxSizing: "border-box",
			height: `calc(${e} * var(--frimousse-row-height) + ${t} * var(--frimousse-category-header-height))`,
			paddingTop: `calc(${o} * var(--frimousse-row-height) + ${r} * var(--frimousse-category-header-height))`
		}
	};
}
function Ke(e, t, o) {
	return {
		"aria-colcount": e,
		"aria-rowcount": t,
		"frimousse-list": "",
		style: {
			"--frimousse-list-columns": e,
			...o
		},
		role: "grid"
	};
}
function Ot(e) {
	e.preventDefault();
}
var _t = (0, react.memo)(({ Emoji: e, emoji: t, columnIndex: o, rowIndex: r }) => {
	let n = C(), s = L(n, (c) => N(c)?.emoji === t.emoji), a = (0, react.useCallback)(() => {
		n.get().onEmojiSelect(t);
	}, [t]), i = (0, react.useCallback)(() => {
		n.get().onActiveEmojiChange("pointer", o, r);
	}, [o, r]), m = (0, react.useCallback)(() => {
		n.get().onActiveEmojiReset();
	}, []);
	return (0, react_jsx_runtime.jsx)(e, {
		...Ze(t, o, s),
		onClick: a,
		onPointerDown: Ot,
		onPointerEnter: i,
		onPointerLeave: m
	});
}), Nt = (0, react.memo)(({ Row: e, Emoji: t, rowIndex: o }) => {
	let n = L(C(), (s) => s.data?.rows[o], Ve);
	return n ? (0, react_jsx_runtime.jsx)(e, {
		...Xe(o),
		children: n.emojis.map((s, a) => (0, react_jsx_runtime.jsx)(_t, {
			Emoji: t,
			columnIndex: a,
			emoji: s,
			rowIndex: o
		}, s.label))
	}) : null;
}), Wt = (0, react.memo)(({ CategoryHeader: e, categoryIndex: t }) => {
	let r = L(C(), (n) => n.data?.categories[t], ee);
	return r ? (0, react_jsx_runtime.jsx)("div", {
		...Qe(t, r),
		children: (0, react_jsx_runtime.jsx)(e, { ...et({ label: r.label }) })
	}) : null;
}), Ue = (0, react.memo)(({ CategoryHeader: e, Row: t, Emoji: o }) => {
	let r = (0, react.useRef)(null), n = C(), s = M(n, "columns"), a = (0, react.useMemo)(() => Array(s).fill({
		emoji: "🙂",
		label: ""
	}), [s]), i = (0, react.useMemo)(() => ({ label: "Category" }), []), m = (0, react.useRef)(null), c = (0, react.useRef)(null);
	return I(() => {
		let f = r.current?.parentElement?.parentElement;
		if (!f || !m.current || !c.current) return;
		let u = new ResizeObserver((l) => {
			for (let j of l) {
				let g = j.contentRect.height, { onRowHeightChange: w, onCategoryHeaderHeightChange: P, rowHeight: T, categoryHeaderHeight: p } = n.get();
				j.target === m.current && T !== g && w(g), j.target === c.current && p !== g && P(g);
			}
		});
		u.observe(f), u.observe(m.current), u.observe(c.current);
		let { onRowHeightChange: h, onCategoryHeaderHeightChange: d } = n.get();
		return h(m.current.clientHeight), d(c.current.clientHeight), () => {
			u.disconnect();
		};
	}, []), (0, react_jsx_runtime.jsxs)("div", {
		"aria-hidden": !0,
		ref: r,
		style: {
			height: 0,
			visibility: "hidden"
		},
		children: [(0, react_jsx_runtime.jsx)("div", {
			"frimousse-row-sizer": "",
			ref: m,
			children: (0, react_jsx_runtime.jsx)(t, {
				...Xe(-1, !0),
				children: a.map((f, u) => (0, react_jsx_runtime.jsx)(o, { ...Ze(f, u, !1) }, u))
			})
		}), (0, react_jsx_runtime.jsx)("div", {
			...Qe(-1),
			children: (0, react_jsx_runtime.jsx)("div", {
				"frimousse-category-header-sizer": "",
				ref: c,
				children: (0, react_jsx_runtime.jsx)(e, { ...et(i, !0) })
			})
		})]
	});
});
function Bt({ category: e, ...t }) {
	return (0, react_jsx_runtime.jsx)("div", {
		...t,
		children: e.label
	});
}
function zt({ emoji: e, ...t }) {
	return (0, react_jsx_runtime.jsx)("button", {
		type: "button",
		...t,
		children: e.emoji
	});
}
function Kt({ ...e }) {
	return (0, react_jsx_runtime.jsx)("div", { ...e });
}
var tt = (0, react.forwardRef)(({ style: e, components: t, ...o }, r) => {
	let n = C(), s = (0, react.useRef)(null), a = (0, react.useCallback)((w) => {
		w && (s.current = w, n.set({ listRef: s }));
	}, []), i = t?.CategoryHeader ?? Bt, m = t?.Emoji ?? zt, c = t?.Row ?? Kt, f = M(n, "columns"), u = M(n, "viewportStartRowIndex"), h = M(n, "viewportEndRowIndex"), d = L(n, fe), l = L(n, Me, ee), j = (0, react.useMemo)(() => l?.filter((w) => w < u).length ?? 0, [l, u]), g = l?.length ?? 0;
	return (0, react.useImperativeHandle)(r, () => s.current), !d || !l || g === 0 ? (0, react_jsx_runtime.jsx)("div", {
		...Ke(f, 0, e),
		...o,
		children: (0, react_jsx_runtime.jsx)("div", {
			...ze(0, 0, 0, 0),
			children: (0, react_jsx_runtime.jsx)(Ue, {
				CategoryHeader: i,
				Emoji: m,
				Row: c
			})
		})
	}) : (0, react_jsx_runtime.jsx)("div", {
		...Ke(f, d, e),
		...o,
		ref: a,
		children: (0, react_jsx_runtime.jsxs)("div", {
			...ze(d, g, u, j),
			children: [
				(0, react_jsx_runtime.jsx)(Ue, {
					CategoryHeader: i,
					Emoji: m,
					Row: c
				}),
				Array.from({ length: h - u + 1 }, (w, P) => {
					let T = u + P;
					return (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [l.indexOf(T) >= 0 && (0, react_jsx_runtime.jsx)("div", { style: { height: "var(--frimousse-category-header-height)" } }), (0, react_jsx_runtime.jsx)(Nt, {
						Emoji: m,
						Row: c,
						rowIndex: T
					})] }, T);
				}),
				Array.from({ length: g }, (w, P) => (0, react_jsx_runtime.jsx)(Wt, {
					CategoryHeader: i,
					categoryIndex: P
				}, P))
			]
		})
	});
}), ot = (0, react.forwardRef)(({ emoji: e, onClick: t, "aria-label": o = "Change skin tone", ...r }, n) => {
	let a = L(C(), Fe, ee), [i, m, c] = Q(e), f = (0, react.useMemo)(() => Math.max(0, c.findIndex((w) => w.skinTone === i)), [i, c]), u = c[f], d = c[(f + 1) % c.length].skinTone, l = i === "none" ? void 0 : a?.[i], j = d === "none" ? void 0 : a?.[d], g = (0, react.useCallback)((w) => {
		t?.(w), w.isDefaultPrevented() || m(d);
	}, [
		t,
		m,
		d
	]);
	return (0, react_jsx_runtime.jsx)("button", {
		type: "button",
		...r,
		"aria-label": o + (j ? ` (${j})` : ""),
		"aria-live": "polite",
		"aria-valuetext": l,
		"frimousse-skin-tone-selector": "",
		onClick: g,
		ref: n,
		children: u.emoji
	});
});
function rt({ children: e, ...t }) {
	return L(C(), Ae) ? (0, react_jsx_runtime.jsx)("span", {
		"frimousse-loading": "",
		...t,
		children: e
	}) : null;
}
function Ut({ children: e }) {
	return e({ search: L(C(), Ie) });
}
function nt({ children: e, ...t }) {
	return L(C(), De) ? (0, react_jsx_runtime.jsx)("span", {
		"frimousse-empty": "",
		...t,
		children: typeof e == "function" ? (0, react_jsx_runtime.jsx)(Ut, { children: e }) : e
	}) : null;
}
function it({ children: e }) {
	return e({ emoji: X() });
}
function st({ children: e, emoji: t }) {
	let [o, r, n] = Q(t);
	return e({
		skinTone: o,
		setSkinTone: r,
		skinToneVariations: n
	});
}
Je.displayName = "EmojiPicker.Root";
qe.displayName = "EmojiPicker.Search";
Ge.displayName = "EmojiPicker.Viewport";
tt.displayName = "EmojiPicker.List";
rt.displayName = "EmojiPicker.Loading";
nt.displayName = "EmojiPicker.Empty";
ot.displayName = "EmojiPicker.SkinToneSelector";
it.displayName = "EmojiPicker.ActiveEmoji";
st.displayName = "EmojiPicker.SkinTone";
//#endregion
Object.defineProperty(exports, "Q", {
	enumerable: true,
	get: function() {
		return Q;
	}
});
Object.defineProperty(exports, "at", {
	enumerable: true,
	get: function() {
		return at;
	}
});

//# sourceMappingURL=dist-jBuvSzmR.cjs.map