UNPKG

@undp/design-system-react

Version:

React based design system for UNDP

682 lines (681 loc) 26.4 kB
import { t as e } from "./utils-ca9as9Ye.js"; import { t } from "./check-DQP1Akuz.js"; import { t as n } from "./chevron-down-DPjLJaqj.js"; import { i as r, n as i } from "./dist-DxuGUd9a.js"; import { t as a } from "./dist-jqIPNHDe.js"; import { n as o } from "./dist-X_NWu4il.js"; import { n as s, t as c } from "./dist-BKfyhBSH.js"; import { t as l } from "./dist-J8GU8wyT.js"; import { n as u, t as d } from "./dist-CwCVtfik.js"; import { t as f } from "./dist-CnnnGPaT.js"; import { t as p } from "./dist-DfB3OR9K.js"; import { t as m } from "./dist-pXPIaj85.js"; import { t as h } from "./dist-C8FJXTu6.js"; import { n as g } from "./dist-CMH_aW5P.js"; import { i as _, n as v, r as y, t as b } from "./es2015-PKoodAxS.js"; import { t as x } from "./dist-vWm-kLzq.js"; import { i as S, n as C, r as w, t as T } from "./dist-D8TIRAGv.js"; import { t as E } from "./icons-LAhELNgN.js"; import * as D from "react"; import O from "react"; import { Fragment as k, jsx as A, jsxs as j } from "react/jsx-runtime"; import * as M from "react-dom"; //#region node_modules/@radix-ui/react-use-previous/dist/index.mjs function N(e) { let t = D.useRef({ value: e, previous: e }); return D.useMemo(() => (t.current.value !== e && (t.current.previous = t.current.value, t.current.value = e), t.current.previous), [e]); } //#endregion //#region node_modules/@radix-ui/number/dist/index.mjs function P(e, [t, n]) { return Math.min(n, Math.max(t, e)); } //#endregion //#region node_modules/@radix-ui/react-select/dist/index.mjs var F = Object.defineProperty, I = (e, t) => F(e, "name", { value: t, configurable: !0 }), ee = [ " ", "Enter", "ArrowUp", "ArrowDown" ], L = [" ", "Enter"], R = "Select", [z, B, V] = l(R), [H, U] = s(R, [V, S]), W = S(), [G, K] = H(R), [te, q] = H(R); function ne(e) { let { __scopeSelect: t, children: n, open: r, defaultOpen: i, onOpenChange: a, value: o, defaultValue: s, onValueChange: c, dir: l, name: u, autoComplete: f, disabled: h, required: g, form: _, internal_do_not_use_render: v } = e, y = W(t), [b, x] = D.useState(null), [S, C] = D.useState(null), [T, E] = D.useState(!1), O = m(l), [k, j] = d({ prop: r, defaultProp: i ?? !1, onChange: a, caller: R }), [M, N] = d({ prop: o, defaultProp: s, onChange: c, caller: R }), P = D.useRef(null), F = D.useRef(M); D.useEffect(() => { let e = _ ? b?.ownerDocument.getElementById(_) : b?.form; if (e instanceof HTMLFormElement) { let t = /* @__PURE__ */ I(() => N(F.current), "reset"); return e.addEventListener("reset", t), () => e.removeEventListener("reset", t); } }, [ _, b, N ]); let ee = !b || !!_ || !!b.closest("form"), [L, B] = D.useState(/* @__PURE__ */ new Set()), V = p(), H = Array.from(L).map((e) => e.props.value).join(";"), U = D.useCallback((e) => { B((t) => new Set(t).add(e)); }, []), K = D.useCallback((e) => { B((t) => { let n = new Set(t); return n.delete(e), n; }); }, []), q = { required: g, trigger: b, onTriggerChange: x, valueNode: S, onValueNodeChange: C, valueNodeHasChildren: T, onValueNodeHasChildrenChange: E, contentId: V, value: M, onValueChange: N, open: k, onOpenChange: j, dir: O, triggerPointerDownPosRef: P, disabled: h, name: u, autoComplete: f, form: _, nativeOptions: L, nativeSelectKey: H, isFormControl: ee }; return /* @__PURE__ */ A(w, { ...y, children: /* @__PURE__ */ A(G, { scope: t, ...q, children: /* @__PURE__ */ A(z.Provider, { scope: t, children: /* @__PURE__ */ A(te, { scope: t, onNativeOptionAdd: U, onNativeOptionRemove: K, children: Ne(v) ? v(q) : n }) }) }) }); } I(ne, "SelectProvider"); var re = /* @__PURE__ */ I((e) => { let { __scopeSelect: t, children: n, ...r } = e; return /* @__PURE__ */ A(ne, { __scopeSelect: t, ...r, internal_do_not_use_render: ({ isFormControl: e }) => /* @__PURE__ */ j(k, { children: [n, e ? /* @__PURE__ */ A(Me, { __scopeSelect: t }) : null] }) }); }, "Select"), ie = "SelectTrigger", J = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let { __scopeSelect: n, disabled: i = !1, ...o } = e, s = W(n), c = K(ie, n), l = c.disabled || i, d = r(t, c.onTriggerChange), f = B(n), p = D.useRef("touch"), [m, h, g] = Pe((e) => { let t = f().filter((e) => !e.disabled), n = Fe(t, e, t.find((e) => e.value === c.value)); n !== void 0 && c.onValueChange(n.value); }), _ = /* @__PURE__ */ I((e) => { l || (c.onOpenChange(!0), g()), e && (c.triggerPointerDownPosRef.current = { x: Math.round(e.pageX), y: Math.round(e.pageY) }); }, "handleOpen"); return /* @__PURE__ */ A(T, { asChild: !0, ...s, children: /* @__PURE__ */ A(a.button, { type: "button", role: "combobox", "aria-controls": c.open ? c.contentId : void 0, "aria-expanded": c.open, "aria-required": c.required, "aria-autocomplete": "none", dir: c.dir, "data-state": c.open ? "open" : "closed", disabled: l, "data-disabled": l ? "" : void 0, "data-placeholder": $(c.value) ? "" : void 0, ...o, ref: d, onClick: u(o.onClick, (e) => { e.currentTarget.focus(), p.current !== "mouse" && _(e); }), onPointerDown: u(o.onPointerDown, (e) => { p.current = e.pointerType; let t = e.target; t.hasPointerCapture(e.pointerId) && t.releasePointerCapture(e.pointerId), e.button === 0 && e.ctrlKey === !1 && e.pointerType === "mouse" && (_(e), e.preventDefault()); }), onKeyDown: u(o.onKeyDown, (e) => { let t = m.current !== ""; !(e.ctrlKey || e.altKey || e.metaKey) && e.key.length === 1 && h(e.key), !(t && e.key === " ") && ee.includes(e.key) && (_(), e.preventDefault()); }) }) }); }, "SelectTrigger")), ae = "SelectValue", oe = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let { __scopeSelect: n, className: i, style: o, children: s, placeholder: l = "", ...u } = e, d = K(ae, n), { onValueNodeHasChildrenChange: f } = d, p = s !== void 0, m = r(t, d.onValueNodeChange); c(() => { f(p); }, [f, p]); let h = $(d.value); return /* @__PURE__ */ A(a.span, { ...u, asChild: !h && u.asChild, ref: m, style: { pointerEvents: "none" }, children: /* @__PURE__ */ A(D.Fragment, { children: h ? l : s }, h ? "placeholder" : "value") }); }, "SelectValue")), se = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let { __scopeSelect: n, children: r, ...i } = e; return /* @__PURE__ */ A(a.span, { "aria-hidden": !0, ...i, ref: t, children: r || "▼" }); }, "SelectIcon")), [ce, le] = H("SelectPortal", { forceMount: void 0 }), ue = /* @__PURE__ */ I((e) => { let { __scopeSelect: t, forceMount: n, ...r } = e; return /* @__PURE__ */ A(ce, { scope: e.__scopeSelect, forceMount: n, children: /* @__PURE__ */ A(x, { asChild: !0, ...r }) }); }, "SelectPortal"), Y = "SelectContent", de = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let n = le(Y, e.__scopeSelect), { forceMount: r = n.forceMount, ...i } = e, a = K(Y, e.__scopeSelect), [o, s] = D.useState(); return c(() => { s(new DocumentFragment()); }, []), /* @__PURE__ */ A(f, { present: r || a.open, children: ({ present: e }) => e ? /* @__PURE__ */ A(he, { ...i, ref: t }) : /* @__PURE__ */ A(fe, { ...i, fragment: o }) }); }, "SelectContent")), fe = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let { __scopeSelect: n, children: r, fragment: i } = e; return i ? M.createPortal(/* @__PURE__ */ A(pe, { scope: n, children: /* @__PURE__ */ A(z.Slot, { scope: n, children: /* @__PURE__ */ A("div", { ref: t, children: r }) }) }), i) : null; }, "SelectContentFragment")), X = 10, [pe, Z] = H(Y), me = i("SelectContent.RemoveScroll"), he = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let { __scopeSelect: n } = e, { position: i = "item-aligned", onCloseAutoFocus: a, onEscapeKeyDown: o, onPointerDownOutside: s, side: c, sideOffset: l, align: d, alignOffset: f, arrowPadding: p, collisionBoundary: m, collisionPadding: h, sticky: x, hideWhenDetached: S, avoidCollisions: C, ...w } = e, T = K(Y, n), [E, O] = D.useState(null), [k, j] = D.useState(null), M = r(t, O), [N, P] = D.useState(null), [F, ee] = D.useState(null), L = B(n), [R, z] = D.useState(!1), V = D.useRef(!1); D.useEffect(() => { if (E) return b(E); }, [E]), y(); let H = D.useCallback((e) => { let [t, ...n] = L().map((e) => e.ref.current), [r] = n.slice(-1), i = document.activeElement; for (let n of e) if (n === i || (n?.scrollIntoView({ block: "nearest" }), n === t && k && (k.scrollTop = 0), n === r && k && (k.scrollTop = k.scrollHeight), n?.focus(), document.activeElement !== i)) return; }, [L, k]), U = D.useCallback(() => H([N, E]), [ H, N, E ]); D.useEffect(() => { R && U(); }, [R, U]); let { onOpenChange: W, triggerPointerDownPosRef: G } = T; D.useEffect(() => { if (E) { let e = { x: 0, y: 0 }, t = /* @__PURE__ */ I((t) => { e = { x: Math.abs(Math.round(t.pageX) - (G.current?.x ?? 0)), y: Math.abs(Math.round(t.pageY) - (G.current?.y ?? 0)) }; }, "handlePointerMove"), n = /* @__PURE__ */ I((n) => { e.x <= 10 && e.y <= 10 ? n.preventDefault() : n.composedPath().includes(E) || W(!1), document.removeEventListener("pointermove", t), G.current = null; }, "handlePointerUp"); return G.current !== null && (document.addEventListener("pointermove", t), document.addEventListener("pointerup", n, { capture: !0, once: !0 })), () => { document.removeEventListener("pointermove", t), document.removeEventListener("pointerup", n, { capture: !0 }); }; } }, [ E, W, G ]), D.useEffect(() => { let e = /* @__PURE__ */ I(() => W(!1), "close"); return window.addEventListener("blur", e), window.addEventListener("resize", e), () => { window.removeEventListener("blur", e), window.removeEventListener("resize", e); }; }, [W]); let [te, q] = Pe((e) => { let t = L().filter((e) => !e.disabled), n = Fe(t, e, t.find((e) => e.ref.current === document.activeElement)); n && setTimeout(() => n.ref.current?.focus()); }), ne = D.useCallback((e, t, n) => { let r = !V.current && !n; (T.value !== void 0 && T.value === t || r) && (P(e), r && (V.current = !0)); }, [T.value]), re = D.useCallback(() => E?.focus(), [E]), ie = D.useCallback((e, t, n) => { let r = !V.current && !n; (T.value !== void 0 && T.value === t || r) && ee(e); }, [T.value]), J = i === "popper" ? _e : ge, ae = J === _e ? { side: c, sideOffset: l, align: d, alignOffset: f, arrowPadding: p, collisionBoundary: m, collisionPadding: h, sticky: x, hideWhenDetached: S, avoidCollisions: C } : {}; return /* @__PURE__ */ A(pe, { scope: n, content: E, viewport: k, onViewportChange: j, itemRefCallback: ne, selectedItem: N, onItemLeave: re, itemTextRefCallback: ie, focusSelectedItem: U, selectedItemText: F, position: i, isPositioned: R, searchRef: te, children: /* @__PURE__ */ A(v, { as: me, allowPinchZoom: !0, children: /* @__PURE__ */ A(_, { asChild: !0, trapped: T.open, onMountAutoFocus: (e) => { e.preventDefault(); }, onUnmountAutoFocus: u(a, (e) => { T.trigger?.focus({ preventScroll: !0 }), e.preventDefault(); }), children: /* @__PURE__ */ A(g, { asChild: !0, disableOutsidePointerEvents: !0, onEscapeKeyDown: o, onPointerDownOutside: s, onFocusOutside: (e) => e.preventDefault(), onDismiss: () => T.onOpenChange(!1), children: /* @__PURE__ */ A(J, { role: "listbox", id: T.contentId, "data-state": T.open ? "open" : "closed", dir: T.dir, onContextMenu: (e) => e.preventDefault(), ...w, ...ae, onPlaced: () => z(!0), ref: M, style: { display: "flex", flexDirection: "column", outline: "none", ...w.style }, onKeyDown: u(w.onKeyDown, (e) => { let t = e.ctrlKey || e.altKey || e.metaKey; if (e.key === "Tab" && e.preventDefault(), !t && e.key.length === 1 && q(e.key), [ "ArrowUp", "ArrowDown", "Home", "End" ].includes(e.key)) { let t = L().filter((e) => !e.disabled).map((e) => e.ref.current); if (["ArrowUp", "End"].includes(e.key) && (t = t.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(e.key)) { let n = e.target, r = t.indexOf(n); t = t.slice(r + 1); } setTimeout(() => H(t)), e.preventDefault(); } }) }) }) }) }) }); }, "SelectContentImpl")), ge = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let { __scopeSelect: n, onPlaced: i, ...o } = e, s = K(Y, n), l = Z(Y, n), [u, d] = D.useState(null), [f, p] = D.useState(null), m = r(t, p), h = B(n), g = D.useRef(!1), _ = D.useRef(!0), { viewport: v, selectedItem: y, selectedItemText: b, focusSelectedItem: x } = l, S = D.useCallback(() => { if (s.trigger && s.valueNode && u && f && v && y && b) { let e = s.trigger.getBoundingClientRect(), t = f.getBoundingClientRect(), n = s.valueNode.getBoundingClientRect(), r = b.getBoundingClientRect(); if (s.dir !== "rtl") { let i = r.left - t.left, a = n.left - i, o = e.left - a, s = e.width + o, c = Math.max(s, t.width), l = window.innerWidth - X, d = P(a, [X, Math.max(X, l - c)]); u.style.minWidth = s + "px", u.style.left = d + "px"; } else { let i = t.right - r.right, a = window.innerWidth - n.right - i, o = window.innerWidth - e.right - a, s = e.width + o, c = Math.max(s, t.width), l = window.innerWidth - X, d = P(a, [X, Math.max(X, l - c)]); u.style.minWidth = s + "px", u.style.right = d + "px"; } let a = h(), o = window.innerHeight - X * 2, c = v.scrollHeight, l = window.getComputedStyle(f), d = parseInt(l.borderTopWidth, 10), p = parseInt(l.paddingTop, 10), m = parseInt(l.borderBottomWidth, 10), _ = parseInt(l.paddingBottom, 10), x = d + p + c + _ + m, S = Math.min(y.offsetHeight * 5, x), C = window.getComputedStyle(v), w = parseInt(C.paddingTop, 10), T = parseInt(C.paddingBottom, 10), E = e.top + e.height / 2 - X, D = o - E, O = y.offsetHeight / 2, k = y.offsetTop + O, A = d + p + k, j = x - A; if (A <= E) { let e = a.length > 0 && y === a[a.length - 1].ref.current; u.style.bottom = "0px"; let t = f.clientHeight - v.offsetTop - v.offsetHeight, n = A + Math.max(D, O + (e ? T : 0) + t + m); u.style.height = n + "px"; } else { let e = a.length > 0 && y === a[0].ref.current; u.style.top = "0px"; let t = Math.max(E, d + v.offsetTop + (e ? w : 0) + O) + j; u.style.height = t + "px", v.scrollTop = A - E + v.offsetTop; } u.style.margin = `${X}px 0`, u.style.minHeight = S + "px", u.style.maxHeight = o + "px", i?.(), requestAnimationFrame(() => g.current = !0); } }, [ h, s.trigger, s.valueNode, u, f, v, y, b, s.dir, i ]); c(() => S(), [S]); let [C, w] = D.useState(); return c(() => { f && w(window.getComputedStyle(f).zIndex); }, [f]), /* @__PURE__ */ A(ve, { scope: n, contentWrapper: u, shouldExpandOnScrollRef: g, onScrollButtonChange: D.useCallback((e) => { e && _.current === !0 && (S(), x?.(), _.current = !1); }, [S, x]), children: /* @__PURE__ */ A("div", { ref: d, style: { display: "flex", flexDirection: "column", position: "fixed", zIndex: C }, children: /* @__PURE__ */ A(a.div, { ...o, ref: m, style: { boxSizing: "border-box", maxHeight: "100%", ...o.style } }) }) }); }, "SelectItemAlignedPosition")), _e = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let { __scopeSelect: n, align: r = "start", collisionPadding: i = X, ...a } = e; return /* @__PURE__ */ A(C, { ...W(n), ...a, ref: t, align: r, collisionPadding: i, style: { boxSizing: "border-box", ...a.style, "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)", "--radix-select-content-available-width": "var(--radix-popper-available-width)", "--radix-select-content-available-height": "var(--radix-popper-available-height)", "--radix-select-trigger-width": "var(--radix-popper-anchor-width)", "--radix-select-trigger-height": "var(--radix-popper-anchor-height)" } }); }, "SelectPopperPosition")), [ve, ye] = H(Y, {}), be = "SelectViewport", xe = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let { __scopeSelect: n, nonce: i, ...o } = e, s = Z(be, n), c = ye(be, n), l = r(t, s.onViewportChange), d = D.useRef(0); return /* @__PURE__ */ j(k, { children: [/* @__PURE__ */ A("style", { dangerouslySetInnerHTML: { __html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}" }, nonce: i }), /* @__PURE__ */ A(z.Slot, { scope: n, children: /* @__PURE__ */ A(a.div, { "data-radix-select-viewport": "", role: "presentation", ...o, ref: l, style: { position: "relative", flex: 1, overflow: "hidden auto", ...o.style }, onScroll: u(o.onScroll, (e) => { let t = e.currentTarget, { contentWrapper: n, shouldExpandOnScrollRef: r } = c; if (r?.current && n) { let e = Math.abs(d.current - t.scrollTop); if (e > 0) { let r = window.innerHeight - X * 2, i = parseFloat(n.style.minHeight), a = parseFloat(n.style.height), o = Math.max(i, a); if (o < r) { let i = o + e, a = Math.min(r, i), s = i - a; n.style.height = a + "px", n.style.bottom === "0px" && (t.scrollTop = s > 0 ? s : 0, n.style.justifyContent = "flex-end"); } } } d.current = t.scrollTop; }) }) })] }); }, "SelectViewport")), [Se, Ce] = H("SelectGroup"), we = "SelectItem", [Te, Ee] = H(we), De = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let { __scopeSelect: n, value: i, disabled: o = !1, textValue: s, ...c } = e, l = K(we, n), d = Z(we, n), f = l.value === i, [m, g] = D.useState(s ?? ""), [_, v] = D.useState(!1), y = r(t, h((e) => d.itemRefCallback?.(e, i, o))), b = p(), x = D.useRef("touch"), S = /* @__PURE__ */ I(() => { o || (l.onValueChange(i), l.onOpenChange(!1)); }, "handleSelect"); return /* @__PURE__ */ A(Te, { scope: n, value: i, disabled: o, textId: b, isSelected: f, onItemTextChange: D.useCallback((e) => { g((t) => t || (e?.textContent ?? "").trim()); }, []), children: /* @__PURE__ */ A(z.ItemSlot, { scope: n, value: i, disabled: o, textValue: m, children: /* @__PURE__ */ A(a.div, { role: "option", "aria-labelledby": b, "data-highlighted": _ ? "" : void 0, "aria-selected": f && _, "data-state": f ? "checked" : "unchecked", "aria-disabled": o || void 0, "data-disabled": o ? "" : void 0, tabIndex: o ? void 0 : -1, ...c, ref: y, onFocus: u(c.onFocus, () => v(!0)), onBlur: u(c.onBlur, () => v(!1)), onClick: u(c.onClick, () => { x.current !== "mouse" && S(); }), onPointerUp: u(c.onPointerUp, () => { x.current === "mouse" && S(); }), onPointerDown: u(c.onPointerDown, (e) => { x.current = e.pointerType; }), onPointerMove: u(c.onPointerMove, (e) => { x.current = e.pointerType, o ? d.onItemLeave?.() : x.current === "mouse" && e.currentTarget.focus({ preventScroll: !0 }); }), onPointerLeave: u(c.onPointerLeave, (e) => { e.currentTarget === document.activeElement && d.onItemLeave?.(); }), onKeyDown: u(c.onKeyDown, (e) => { o || e.target !== e.currentTarget || d.searchRef?.current !== "" && e.key === " " || (L.includes(e.key) && S(), e.key === " " && e.preventDefault()); }) }) }) }); }, "SelectItem")), Q = "SelectItemText", Oe = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let { __scopeSelect: n, className: i, style: o, ...s } = e, l = K(Q, n), u = Z(Q, n), d = Ee(Q, n), f = q(Q, n), [p, m] = D.useState(null), g = h((e) => u.itemTextRefCallback?.(e, d.value, d.disabled)), _ = r(t, m, d.onItemTextChange, g), v = p?.textContent, y = D.useMemo(() => /* @__PURE__ */ A("option", { value: d.value, disabled: d.disabled, children: v }, d.value), [ d.disabled, d.value, v ]), { onNativeOptionAdd: b, onNativeOptionRemove: x } = f; return c(() => (b(y), () => x(y)), [ b, x, y ]), /* @__PURE__ */ j(k, { children: [/* @__PURE__ */ A(a.span, { id: d.textId, ...s, ref: _ }), d.isSelected && l.valueNode && !l.valueNodeHasChildren && !$(l.value) ? M.createPortal(s.children, l.valueNode) : null] }); }, "SelectItemText")), ke = "SelectItemIndicator", Ae = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function(e, t) { let { __scopeSelect: n, ...r } = e; return Ee(ke, n).isSelected ? /* @__PURE__ */ A(a.span, { "aria-hidden": !0, ...r, ref: t }) : null; }, "SelectItemIndicator")), je = "SelectBubbleInput", Me = /* @__PURE__ */ D.forwardRef(/* @__PURE__ */ I(function({ __scopeSelect: e, ...t }, n) { let i = K(je, e), { value: s, onValueChange: c, required: l, disabled: u, name: d, autoComplete: f, form: p } = i, { nativeOptions: m, nativeSelectKey: h } = i, g = D.useRef(null), _ = r(n, g), v = s ?? "", y = N(v), b = Array.from(m).some((e) => (e.props.value ?? "") === ""); return D.useEffect(() => { let e = g.current; if (!e) return; let t = window.HTMLSelectElement.prototype, n = Object.getOwnPropertyDescriptor(t, "value").set; if (y !== v && n) { let t = new Event("change", { bubbles: !0 }); n.call(e, v), e.dispatchEvent(t); } }, [y, v]), /* @__PURE__ */ j(a.select, { "aria-hidden": !0, required: l, tabIndex: -1, name: d, autoComplete: f, disabled: u, form: p, onChange: (e) => c(e.target.value), ...t, style: { ...o, ...t.style }, ref: _, defaultValue: v, children: [$(s) && !b ? /* @__PURE__ */ A("option", { value: "" }) : null, Array.from(m)] }, h); }, "SelectBubbleInput")); function Ne(e) { return typeof e == "function"; } I(Ne, "isFunction"); function $(e) { return e === "" || e === void 0; } I($, "shouldShowPlaceholder"); function Pe(e) { let t = h(e), n = D.useRef(""), r = D.useRef(0), i = D.useCallback((e) => { let i = n.current + e; t(i), (/* @__PURE__ */ I((function e(t) { n.current = t, window.clearTimeout(r.current), t !== "" && (r.current = window.setTimeout(() => e(""), 1e3)); }), "updateSearch"))(i); }, [t]), a = D.useCallback(() => { n.current = "", window.clearTimeout(r.current); }, []); return D.useEffect(() => () => window.clearTimeout(r.current), []), [ n, i, a ]; } I(Pe, "useTypeaheadSearch"); function Fe(e, t, n) { let r = t.length > 1 && Array.from(t).every((e) => e === t[0]) ? t[0] : t, i = n ? e.indexOf(n) : -1, a = Ie(e, Math.max(i, 0)); r.length === 1 && (a = a.filter((e) => e !== n)); let o = a.find((e) => e.textValue.toLowerCase().startsWith(r.toLowerCase())); return o === n ? void 0 : o; } I(Fe, "findNextItem"); function Ie(e, t) { return e.map((n, r) => e[(t + r) % e.length]); } I(Ie, "wrapArray"); //#endregion //#region src/components/ui/language-switcher/languageSelect.tsx var Le = re, Re = oe, ze = O.forwardRef(({ className: t, children: r, ...i }, a) => /* @__PURE__ */ j(J, { ref: a, className: e("flex flex h-9 cursor-pointer items-center justify-between gap-2 whitespace-nowrap bg-transparent p-0 font-semibold text-secondary text-sm uppercase hover:text-secondary disabled:cursor-not-allowed disabled:opacity-disabled data-[placeholder]:text-content-placeholder rtl:[direction:rtl] [&>span]:line-clamp-1", "[&[data-state=open]>.lucide-chevron-down]:rotate-180", t), ...i, children: [ /* @__PURE__ */ A(E, {}), r, /* @__PURE__ */ A(se, { asChild: !0, children: /* @__PURE__ */ A(n, { className: "h-6 w-6 transition-transform duration-200" }) }) ] })); ze.displayName = J.displayName; var Be = O.forwardRef(({ className: t, children: n, position: r = "popper", inPortal: i = !1, ...a }, o) => { let s = /* @__PURE__ */ A(de, { ref: o, className: e("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] origin-[--radix-select-content-transform-origin] overflow-y-auto overflow-x-hidden rounded-md border bg-background text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in", r === "popper" && "data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1", t), position: r, ...a, children: /* @__PURE__ */ A(xe, { className: e(r === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"), children: n }) }); return i ? /* @__PURE__ */ A(ue, { children: s }) : s; }); Be.displayName = de.displayName; var Ve = O.forwardRef(({ className: n, children: r, ...i }, a) => /* @__PURE__ */ j(De, { ref: a, className: e("relative flex w-full cursor-default select-none items-center border-stroke border-b px-4 py-3 font-semibold text-sm uppercase outline-none focus:bg-surface-md data-[disabled]:pointer-events-none data-[disabled]:opacity-disabled [&:last-of-type]:border-b-0", n), ...i, children: [/* @__PURE__ */ A("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ A(Ae, { children: /* @__PURE__ */ A(t, { className: "h-4 w-4" }) }) }), /* @__PURE__ */ A(Oe, { children: r })] })); Ve.displayName = De.displayName; //#endregion //#region src/components/ui/language-switcher/index.tsx function He(e) { let { options: t, value: n, onValueChange: r, defaultValue: i, inPortal: a = !1 } = e; return /* @__PURE__ */ j(Le, { onValueChange: r, value: n, defaultValue: i, children: [/* @__PURE__ */ A(ze, { children: /* @__PURE__ */ A(Re, {}) }), /* @__PURE__ */ A(Be, { inPortal: a, children: t.map((e) => /* @__PURE__ */ A(Ve, { value: e.id, children: e.label }, e.id)) })] }); } //#endregion export { He as t }; //# sourceMappingURL=language-switcher-B0wAVQeQ.js.map