@sheerid/jslib-nightly
Version:
SheerID JavaScript Library
1,421 lines (1,420 loc) • 61.2 kB
JavaScript
/**
* WARNING: This file is intended to be used within MySheerID.
* This file is not intended for use in other contexts and there are no guarantees about its behavior outside of MySheerID.
*/
/**
* VERSION: 2.230.0-alpha.0
* BUILD_TIMESTAMP: 1778694697559
* BUILD_DATE: Wed May 13 2026 17:51:37 GMT+0000 (Coordinated Universal Time)
* BUILD_COMMIT: 7af1c105d5485ac4ed1190c56d492bb4590667a9
*/
import { b as s, j as r, aB as xe, R as ee, aC as ne, aD as Te, aE as De, aF as oe, aG as S, aH as Ze, aI as Ae, aJ as Vt, aK as Ht, aL as ke, aM as Je, aN as Wt, aO as qt, aP as Yt, aQ as Xt, aR as Qt, aS as Zt, aT as Jt, aU as en, aV as et, a4 as ae, ak as tt, C as tn, E as ue, r as le, l as Z, aW as nn, G as on, F as te, aX as rn, aY as He, H as sn, i as nt, aZ as an, N as Q, s as cn, a_ as Oe, d as ye, h as be, e as un } from "../_mysheerid-preview.js";
import { F as ln, g as dn } from "./FormFieldLayout-DDEEmlGC.js";
import { u as Ne } from "./downshift.esm-CtrbqQGL.js";
import { u as ot, M as X } from "./useMetrics-D2fG6cgw.js";
import { i as fn } from "./FormFieldText-CJ-GVpZE.js";
const rt = s.createContext({
showOverlay: !1,
setShowOverlay: () => {
}
}), pn = () => s.useContext(rt), st = s.createContext(null), Le = () => s.useContext(st);
function mn() {
const [e, t] = s.useState(null), [n, o] = s.useState(null), [a, c] = s.useState(!1), i = s.useCallback(() => (c(!0), o(null), new Promise((l, p) => {
navigator.geolocation.getCurrentPosition(
(f) => {
const u = {
latitude: f.coords.latitude,
longitude: f.coords.longitude
};
t(u), c(!1), l(u);
},
(f) => {
const u = { code: f.code, message: f.message };
o(u), c(!1), p(u);
}
);
})), []);
return {
location: e,
error: n,
loading: a,
requestLocation: i
};
}
const hn = ({ children: e }) => {
const [t, n] = s.useState("relevance"), [o, a] = s.useState(null), [c, i] = s.useState(!1), l = mn(), p = s.useCallback(async () => {
try {
const u = await l.requestLocation();
return a(u), i(!1), u;
} catch {
throw i(!0), new Error("Location denied");
}
}, [l]), f = s.useMemo(
() => ({
sortMode: t,
userLocation: o,
locationDenied: c,
setSortMode: n,
requestLocation: p
}),
[t, o, c, p]
);
return /* @__PURE__ */ r.jsx(st.Provider, { value: f, children: e });
}, gn = 'button, a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])', vn = ({
children: e,
enabled: t,
closeSectionLabel: n
}) => {
const [o, a] = s.useState(!1), c = s.useRef(null), i = t && o, l = s.useRef(0), p = (f) => {
if (!t) return;
const u = window !== window.top;
if (f && o === !1) {
if (l.current = window.scrollY, document.body.style.overflow = "hidden", document.body.style.backgroundColor = "rgba(0,0,0,.1)", window.scrollTo({ top: 0 }), u) {
const d = window.screen.availHeight - 80, g = document.body.clientHeight;
document.body.style.height = `${Math.min(g, d)}px`;
}
c.current && setTimeout(() => {
c.current.scrollIntoView();
}, 0);
}
f || (document.body.style.overflow = "unset", document.body.style.backgroundColor = "unset", window.scrollTo({ top: l.current }), u && (document.body.style.height = "unset")), a(f);
};
return s.useEffect(() => {
if (!i) return;
const f = (u) => {
if (u.key !== "Tab") return;
const d = c.current;
if (!d) return;
const g = d.querySelectorAll(gn), R = g[0], w = g[g.length - 1];
u.shiftKey && document.activeElement === R ? (u.preventDefault(), w?.focus()) : !u.shiftKey && document.activeElement === w && (u.preventDefault(), R?.focus());
};
return document.addEventListener("keydown", f, !0), () => document.removeEventListener("keydown", f, !0);
}, [i]), t ? /* @__PURE__ */ r.jsx(rt.Provider, { value: { showOverlay: i, setShowOverlay: p }, children: /* @__PURE__ */ r.jsx(hn, { children: /* @__PURE__ */ r.jsx("div", { className: i && "sid-search-overlay__overlay", children: /* @__PURE__ */ r.jsxs("div", { className: i && "sid-search-overlay__container", ref: c, children: [
i && /* @__PURE__ */ r.jsx("button", { className: "sid-search-overlay__close", onClick: () => p(!1), children: n }),
e
] }) }) }) }) : /* @__PURE__ */ r.jsx(r.Fragment, { children: e });
}, wn = ({ org: e, onClear: t, clearSelectionLabel: n, labelId: o }) => {
const a = s.useRef(null), c = [e.city, e.state].filter(Boolean).join(", "), i = [e.name, c].filter(Boolean).join(", ");
return s.useEffect(() => {
a.current?.focus();
}, []), /* @__PURE__ */ r.jsxs("div", { className: "sid-selected-org__wrapper", children: [
/* @__PURE__ */ r.jsx(
"input",
{
ref: a,
className: "sid-h-screen-reader-only",
type: "text",
readOnly: !0,
"aria-labelledby": o,
"aria-expanded": !1,
value: i
}
),
/* @__PURE__ */ r.jsxs("div", { className: "sid-selected-org__container", children: [
/* @__PURE__ */ r.jsxs("div", { className: "sid-selected-org__name", "aria-hidden": "true", children: [
e.name,
c && /* @__PURE__ */ r.jsx("span", { className: "sid-selected-org__location", children: c })
] }),
/* @__PURE__ */ r.jsx(
"button",
{
className: "sid-selected-org__clear",
"aria-label": n,
onClick: t,
children: "✕"
}
)
] })
] });
}, _n = 6371;
function xn(e, t, n, o) {
const a = (f) => f * Math.PI / 180, c = a(n - e), i = a(o - t), l = Math.sin(c / 2) * Math.sin(c / 2) + Math.cos(a(e)) * Math.cos(a(n)) * Math.sin(i / 2) * Math.sin(i / 2), p = 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l));
return _n * p;
}
const Mn = ["en-us", "en-gb"];
function Cn(e) {
return Mn.includes(e.toLowerCase()) ? "miles" : "kilometers";
}
function Rn(e, t) {
const n = t === "miles" ? "mi" : "km", o = t === "miles" ? e * 0.621371 : e, a = Math.round(o * 10) / 10;
return a >= 10 ? `${Math.round(o)} ${n}` : `${a} ${n}`;
}
function at(e) {
const t = e + "CollectionProvider", [n, o] = xe(t), [a, c] = n(
t,
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
), i = (v) => {
const { scope: m, children: _ } = v, y = ee.useRef(null), x = ee.useRef(/* @__PURE__ */ new Map()).current;
return /* @__PURE__ */ r.jsx(a, { scope: m, itemMap: x, collectionRef: y, children: _ });
};
i.displayName = t;
const l = e + "CollectionSlot", p = Te(l), f = ee.forwardRef(
(v, m) => {
const { scope: _, children: y } = v, x = c(l, _), C = ne(m, x.collectionRef);
return /* @__PURE__ */ r.jsx(p, { ref: C, children: y });
}
);
f.displayName = l;
const u = e + "CollectionItemSlot", d = "data-radix-collection-item", g = Te(u), R = ee.forwardRef(
(v, m) => {
const { scope: _, children: y, ...x } = v, C = ee.useRef(null), T = ne(m, C), j = c(u, _);
return ee.useEffect(() => (j.itemMap.set(C, { ref: C, ...x }), () => {
j.itemMap.delete(C);
})), /* @__PURE__ */ r.jsx(g, { [d]: "", ref: T, children: y });
}
);
R.displayName = u;
function w(v) {
const m = c(e + "CollectionConsumer", v);
return ee.useCallback(() => {
const y = m.collectionRef.current;
if (!y) return [];
const x = Array.from(y.querySelectorAll(`[${d}]`));
return Array.from(m.itemMap.values()).sort(
(j, E) => x.indexOf(j.ref.current) - x.indexOf(E.ref.current)
);
}, [m.collectionRef, m.itemMap]);
}
return [
{ Provider: i, Slot: f, ItemSlot: R },
w,
o
];
}
var Sn = s.createContext(void 0);
function ct(e) {
const t = s.useContext(Sn);
return e || t || "ltr";
}
var Ee = "rovingFocusGroup.onEntryFocus", yn = { bubbles: !1, cancelable: !0 }, pe = "RovingFocusGroup", [je, it, bn] = at(pe), [En, ut] = xe(
pe,
[bn]
), [In, Tn] = En(pe), lt = s.forwardRef(
(e, t) => /* @__PURE__ */ r.jsx(je.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ r.jsx(je.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ r.jsx(Dn, { ...e, ref: t }) }) })
);
lt.displayName = pe;
var Dn = s.forwardRef((e, t) => {
const {
__scopeRovingFocusGroup: n,
orientation: o,
loop: a = !1,
dir: c,
currentTabStopId: i,
defaultCurrentTabStopId: l,
onCurrentTabStopIdChange: p,
onEntryFocus: f,
preventScrollOnEntryFocus: u = !1,
...d
} = e, g = s.useRef(null), R = ne(t, g), w = ct(c), [v, m] = Ze({
prop: i,
defaultProp: l ?? null,
onChange: p,
caller: pe
}), [_, y] = s.useState(!1), x = Ae(f), C = it(n), T = s.useRef(!1), [j, E] = s.useState(0);
return s.useEffect(() => {
const b = g.current;
if (b)
return b.addEventListener(Ee, x), () => b.removeEventListener(Ee, x);
}, [x]), /* @__PURE__ */ r.jsx(
In,
{
scope: n,
orientation: o,
dir: w,
loop: a,
currentTabStopId: v,
onItemFocus: s.useCallback(
(b) => m(b),
[m]
),
onItemShiftTab: s.useCallback(() => y(!0), []),
onFocusableItemAdd: s.useCallback(
() => E((b) => b + 1),
[]
),
onFocusableItemRemove: s.useCallback(
() => E((b) => b - 1),
[]
),
children: /* @__PURE__ */ r.jsx(
oe.div,
{
tabIndex: _ || j === 0 ? -1 : 0,
"data-orientation": o,
...d,
ref: R,
style: { outline: "none", ...e.style },
onMouseDown: S(e.onMouseDown, () => {
T.current = !0;
}),
onFocus: S(e.onFocus, (b) => {
const L = !T.current;
if (b.target === b.currentTarget && L && !_) {
const I = new CustomEvent(Ee, yn);
if (b.currentTarget.dispatchEvent(I), !I.defaultPrevented) {
const V = C().filter((D) => D.focusable), O = V.find((D) => D.active), q = V.find((D) => D.id === v), U = [O, q, ...V].filter(
Boolean
).map((D) => D.ref.current);
pt(U, u);
}
}
T.current = !1;
}),
onBlur: S(e.onBlur, () => y(!1))
}
)
}
);
}), dt = "RovingFocusGroupItem", ft = s.forwardRef(
(e, t) => {
const {
__scopeRovingFocusGroup: n,
focusable: o = !0,
active: a = !1,
tabStopId: c,
children: i,
...l
} = e, p = De(), f = c || p, u = Tn(dt, n), d = u.currentTabStopId === f, g = it(n), { onFocusableItemAdd: R, onFocusableItemRemove: w, currentTabStopId: v } = u;
return s.useEffect(() => {
if (o)
return R(), () => w();
}, [o, R, w]), /* @__PURE__ */ r.jsx(
je.ItemSlot,
{
scope: n,
id: f,
focusable: o,
active: a,
children: /* @__PURE__ */ r.jsx(
oe.span,
{
tabIndex: d ? 0 : -1,
"data-orientation": u.orientation,
...l,
ref: t,
onMouseDown: S(e.onMouseDown, (m) => {
o ? u.onItemFocus(f) : m.preventDefault();
}),
onFocus: S(e.onFocus, () => u.onItemFocus(f)),
onKeyDown: S(e.onKeyDown, (m) => {
if (m.key === "Tab" && m.shiftKey) {
u.onItemShiftTab();
return;
}
if (m.target !== m.currentTarget) return;
const _ = jn(m, u.orientation, u.dir);
if (_ !== void 0) {
if (m.metaKey || m.ctrlKey || m.altKey || m.shiftKey) return;
m.preventDefault();
let x = g().filter((C) => C.focusable).map((C) => C.ref.current);
if (_ === "last") x.reverse();
else if (_ === "prev" || _ === "next") {
_ === "prev" && x.reverse();
const C = x.indexOf(m.currentTarget);
x = u.loop ? Pn(x, C + 1) : x.slice(C + 1);
}
setTimeout(() => pt(x));
}
}),
children: typeof i == "function" ? i({ isCurrentTabStop: d, hasTabStop: v != null }) : i
}
)
}
);
}
);
ft.displayName = dt;
var On = {
ArrowLeft: "prev",
ArrowUp: "prev",
ArrowRight: "next",
ArrowDown: "next",
PageUp: "first",
Home: "first",
PageDown: "last",
End: "last"
};
function Nn(e, t) {
return t !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
}
function jn(e, t, n) {
const o = Nn(e.key, n);
if (!(t === "vertical" && ["ArrowLeft", "ArrowRight"].includes(o)) && !(t === "horizontal" && ["ArrowUp", "ArrowDown"].includes(o)))
return On[o];
}
function pt(e, t = !1) {
const n = document.activeElement;
for (const o of e)
if (o === n || (o.focus({ preventScroll: t }), document.activeElement !== n)) return;
}
function Pn(e, t) {
return e.map((n, o) => e[(t + o) % e.length]);
}
var An = lt, kn = ft, Pe = ["Enter", " "], Ln = ["ArrowDown", "PageUp", "Home"], mt = ["ArrowUp", "PageDown", "End"], Fn = [...Ln, ...mt], Gn = {
ltr: [...Pe, "ArrowRight"],
rtl: [...Pe, "ArrowLeft"]
}, Bn = {
ltr: ["ArrowLeft"],
rtl: ["ArrowRight"]
}, me = "Menu", [de, Un, Kn] = at(me), [se, ht] = xe(me, [
Kn,
Je,
ut
]), Me = Je(), gt = ut(), [$n, ce] = se(me), [zn, he] = se(me), vt = (e) => {
const { __scopeMenu: t, open: n = !1, children: o, dir: a, onOpenChange: c, modal: i = !0 } = e, l = Me(t), [p, f] = s.useState(null), u = s.useRef(!1), d = Ae(c), g = ct(a);
return s.useEffect(() => {
const R = () => {
u.current = !0, document.addEventListener("pointerdown", w, { capture: !0, once: !0 }), document.addEventListener("pointermove", w, { capture: !0, once: !0 });
}, w = () => u.current = !1;
return document.addEventListener("keydown", R, { capture: !0 }), () => {
document.removeEventListener("keydown", R, { capture: !0 }), document.removeEventListener("pointerdown", w, { capture: !0 }), document.removeEventListener("pointermove", w, { capture: !0 });
};
}, []), /* @__PURE__ */ r.jsx(Vt, { ...l, children: /* @__PURE__ */ r.jsx(
$n,
{
scope: t,
open: n,
onOpenChange: d,
content: p,
onContentChange: f,
children: /* @__PURE__ */ r.jsx(
zn,
{
scope: t,
onClose: s.useCallback(() => d(!1), [d]),
isUsingKeyboardRef: u,
dir: g,
modal: i,
children: o
}
)
}
) });
};
vt.displayName = me;
var Vn = "MenuAnchor", Fe = s.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...o } = e, a = Me(n);
return /* @__PURE__ */ r.jsx(Ht, { ...a, ...o, ref: t });
}
);
Fe.displayName = Vn;
var Hn = "MenuPortal", [Rr, wt] = se(Hn, {
forceMount: void 0
}), z = "MenuContent", [Wn, Ge] = se(z), _t = s.forwardRef(
(e, t) => {
const n = wt(z, e.__scopeMenu), { forceMount: o = n.forceMount, ...a } = e, c = ce(z, e.__scopeMenu), i = he(z, e.__scopeMenu);
return /* @__PURE__ */ r.jsx(de.Provider, { scope: e.__scopeMenu, children: /* @__PURE__ */ r.jsx(ke, { present: o || c.open, children: /* @__PURE__ */ r.jsx(de.Slot, { scope: e.__scopeMenu, children: i.modal ? /* @__PURE__ */ r.jsx(qn, { ...a, ref: t }) : /* @__PURE__ */ r.jsx(Yn, { ...a, ref: t }) }) }) });
}
), qn = s.forwardRef(
(e, t) => {
const n = ce(z, e.__scopeMenu), o = s.useRef(null), a = ne(t, o);
return s.useEffect(() => {
const c = o.current;
if (c) return Wt(c);
}, []), /* @__PURE__ */ r.jsx(
Be,
{
...e,
ref: a,
trapFocus: n.open,
disableOutsidePointerEvents: n.open,
disableOutsideScroll: !0,
onFocusOutside: S(
e.onFocusOutside,
(c) => c.preventDefault(),
{ checkForDefaultPrevented: !1 }
),
onDismiss: () => n.onOpenChange(!1)
}
);
}
), Yn = s.forwardRef((e, t) => {
const n = ce(z, e.__scopeMenu);
return /* @__PURE__ */ r.jsx(
Be,
{
...e,
ref: t,
trapFocus: !1,
disableOutsidePointerEvents: !1,
disableOutsideScroll: !1,
onDismiss: () => n.onOpenChange(!1)
}
);
}), Xn = Te("MenuContent.ScrollLock"), Be = s.forwardRef(
(e, t) => {
const {
__scopeMenu: n,
loop: o = !1,
trapFocus: a,
onOpenAutoFocus: c,
onCloseAutoFocus: i,
disableOutsidePointerEvents: l,
onEntryFocus: p,
onEscapeKeyDown: f,
onPointerDownOutside: u,
onFocusOutside: d,
onInteractOutside: g,
onDismiss: R,
disableOutsideScroll: w,
...v
} = e, m = ce(z, n), _ = he(z, n), y = Me(n), x = gt(n), C = Un(n), [T, j] = s.useState(null), E = s.useRef(null), b = ne(t, E, m.onContentChange), L = s.useRef(0), I = s.useRef(""), V = s.useRef(0), O = s.useRef(null), q = s.useRef("right"), F = s.useRef(0), U = w ? Xt : s.Fragment, D = w ? { as: Xn, allowPinchZoom: !0 } : void 0, K = (h) => {
const G = I.current + h, k = C().filter((P) => !P.disabled), A = document.activeElement, H = k.find((P) => P.ref.current === A)?.textValue, $ = k.map((P) => P.textValue), Y = io($, G, H), W = k.find((P) => P.textValue === Y)?.ref.current;
(function P(ge) {
I.current = ge, window.clearTimeout(L.current), ge !== "" && (L.current = window.setTimeout(() => P(""), 1e3));
})(G), W && setTimeout(() => W.focus());
};
s.useEffect(() => () => window.clearTimeout(L.current), []), Yt();
const N = s.useCallback((h) => q.current === O.current?.side && lo(h, O.current?.area), []);
return /* @__PURE__ */ r.jsx(
Wn,
{
scope: n,
searchRef: I,
onItemEnter: s.useCallback(
(h) => {
N(h) && h.preventDefault();
},
[N]
),
onItemLeave: s.useCallback(
(h) => {
N(h) || (E.current?.focus(), j(null));
},
[N]
),
onTriggerLeave: s.useCallback(
(h) => {
N(h) && h.preventDefault();
},
[N]
),
pointerGraceTimerRef: V,
onPointerGraceIntentChange: s.useCallback((h) => {
O.current = h;
}, []),
children: /* @__PURE__ */ r.jsx(U, { ...D, children: /* @__PURE__ */ r.jsx(
Qt,
{
asChild: !0,
trapped: a,
onMountAutoFocus: S(c, (h) => {
h.preventDefault(), E.current?.focus({ preventScroll: !0 });
}),
onUnmountAutoFocus: i,
children: /* @__PURE__ */ r.jsx(
Zt,
{
asChild: !0,
disableOutsidePointerEvents: l,
onEscapeKeyDown: f,
onPointerDownOutside: u,
onFocusOutside: d,
onInteractOutside: g,
onDismiss: R,
children: /* @__PURE__ */ r.jsx(
An,
{
asChild: !0,
...x,
dir: _.dir,
orientation: "vertical",
loop: o,
currentTabStopId: T,
onCurrentTabStopIdChange: j,
onEntryFocus: S(p, (h) => {
_.isUsingKeyboardRef.current || h.preventDefault();
}),
preventScrollOnEntryFocus: !0,
children: /* @__PURE__ */ r.jsx(
Jt,
{
role: "menu",
"aria-orientation": "vertical",
"data-state": At(m.open),
"data-radix-menu-content": "",
dir: _.dir,
...y,
...v,
ref: b,
style: { outline: "none", ...v.style },
onKeyDown: S(v.onKeyDown, (h) => {
const k = h.target.closest("[data-radix-menu-content]") === h.currentTarget, A = h.ctrlKey || h.altKey || h.metaKey, H = h.key.length === 1;
k && (h.key === "Tab" && h.preventDefault(), !A && H && K(h.key));
const $ = E.current;
if (h.target !== $ || !Fn.includes(h.key)) return;
h.preventDefault();
const W = C().filter((P) => !P.disabled).map((P) => P.ref.current);
mt.includes(h.key) && W.reverse(), ao(W);
}),
onBlur: S(e.onBlur, (h) => {
h.currentTarget.contains(h.target) || (window.clearTimeout(L.current), I.current = "");
}),
onPointerMove: S(
e.onPointerMove,
fe((h) => {
const G = h.target, k = F.current !== h.clientX;
if (h.currentTarget.contains(G) && k) {
const A = h.clientX > F.current ? "right" : "left";
q.current = A, F.current = h.clientX;
}
})
)
}
)
}
)
}
)
}
) })
}
);
}
);
_t.displayName = z;
var Qn = "MenuGroup", Ue = s.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...o } = e;
return /* @__PURE__ */ r.jsx(oe.div, { role: "group", ...o, ref: t });
}
);
Ue.displayName = Qn;
var Zn = "MenuLabel", xt = s.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...o } = e;
return /* @__PURE__ */ r.jsx(oe.div, { ...o, ref: t });
}
);
xt.displayName = Zn;
var we = "MenuItem", We = "menu.itemSelect", Ce = s.forwardRef(
(e, t) => {
const { disabled: n = !1, onSelect: o, ...a } = e, c = s.useRef(null), i = he(we, e.__scopeMenu), l = Ge(we, e.__scopeMenu), p = ne(t, c), f = s.useRef(!1), u = () => {
const d = c.current;
if (!n && d) {
const g = new CustomEvent(We, { bubbles: !0, cancelable: !0 });
d.addEventListener(We, (R) => o?.(R), { once: !0 }), qt(d, g), g.defaultPrevented ? f.current = !1 : i.onClose();
}
};
return /* @__PURE__ */ r.jsx(
Mt,
{
...a,
ref: p,
disabled: n,
onClick: S(e.onClick, u),
onPointerDown: (d) => {
e.onPointerDown?.(d), f.current = !0;
},
onPointerUp: S(e.onPointerUp, (d) => {
f.current || d.currentTarget?.click();
}),
onKeyDown: S(e.onKeyDown, (d) => {
const g = l.searchRef.current !== "";
n || g && d.key === " " || Pe.includes(d.key) && (d.currentTarget.click(), d.preventDefault());
})
}
);
}
);
Ce.displayName = we;
var Mt = s.forwardRef(
(e, t) => {
const { __scopeMenu: n, disabled: o = !1, textValue: a, ...c } = e, i = Ge(we, n), l = gt(n), p = s.useRef(null), f = ne(t, p), [u, d] = s.useState(!1), [g, R] = s.useState("");
return s.useEffect(() => {
const w = p.current;
w && R((w.textContent ?? "").trim());
}, [c.children]), /* @__PURE__ */ r.jsx(
de.ItemSlot,
{
scope: n,
disabled: o,
textValue: a ?? g,
children: /* @__PURE__ */ r.jsx(kn, { asChild: !0, ...l, focusable: !o, children: /* @__PURE__ */ r.jsx(
oe.div,
{
role: "menuitem",
"data-highlighted": u ? "" : void 0,
"aria-disabled": o || void 0,
"data-disabled": o ? "" : void 0,
...c,
ref: f,
onPointerMove: S(
e.onPointerMove,
fe((w) => {
o ? i.onItemLeave(w) : (i.onItemEnter(w), w.defaultPrevented || w.currentTarget.focus({ preventScroll: !0 }));
})
),
onPointerLeave: S(
e.onPointerLeave,
fe((w) => i.onItemLeave(w))
),
onFocus: S(e.onFocus, () => d(!0)),
onBlur: S(e.onBlur, () => d(!1))
}
) })
}
);
}
), Jn = "MenuCheckboxItem", Ct = s.forwardRef(
(e, t) => {
const { checked: n = !1, onCheckedChange: o, ...a } = e;
return /* @__PURE__ */ r.jsx(Et, { scope: e.__scopeMenu, checked: n, children: /* @__PURE__ */ r.jsx(
Ce,
{
role: "menuitemcheckbox",
"aria-checked": _e(n) ? "mixed" : n,
...a,
ref: t,
"data-state": $e(n),
onSelect: S(
a.onSelect,
() => o?.(_e(n) ? !0 : !n),
{ checkForDefaultPrevented: !1 }
)
}
) });
}
);
Ct.displayName = Jn;
var Rt = "MenuRadioGroup", [eo, to] = se(
Rt,
{ value: void 0, onValueChange: () => {
} }
), St = s.forwardRef(
(e, t) => {
const { value: n, onValueChange: o, ...a } = e, c = Ae(o);
return /* @__PURE__ */ r.jsx(eo, { scope: e.__scopeMenu, value: n, onValueChange: c, children: /* @__PURE__ */ r.jsx(Ue, { ...a, ref: t }) });
}
);
St.displayName = Rt;
var yt = "MenuRadioItem", bt = s.forwardRef(
(e, t) => {
const { value: n, ...o } = e, a = to(yt, e.__scopeMenu), c = n === a.value;
return /* @__PURE__ */ r.jsx(Et, { scope: e.__scopeMenu, checked: c, children: /* @__PURE__ */ r.jsx(
Ce,
{
role: "menuitemradio",
"aria-checked": c,
...o,
ref: t,
"data-state": $e(c),
onSelect: S(
o.onSelect,
() => a.onValueChange?.(n),
{ checkForDefaultPrevented: !1 }
)
}
) });
}
);
bt.displayName = yt;
var Ke = "MenuItemIndicator", [Et, no] = se(
Ke,
{ checked: !1 }
), It = s.forwardRef(
(e, t) => {
const { __scopeMenu: n, forceMount: o, ...a } = e, c = no(Ke, n);
return /* @__PURE__ */ r.jsx(
ke,
{
present: o || _e(c.checked) || c.checked === !0,
children: /* @__PURE__ */ r.jsx(
oe.span,
{
...a,
ref: t,
"data-state": $e(c.checked)
}
)
}
);
}
);
It.displayName = Ke;
var oo = "MenuSeparator", Tt = s.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...o } = e;
return /* @__PURE__ */ r.jsx(
oe.div,
{
role: "separator",
"aria-orientation": "horizontal",
...o,
ref: t
}
);
}
);
Tt.displayName = oo;
var ro = "MenuArrow", Dt = s.forwardRef(
(e, t) => {
const { __scopeMenu: n, ...o } = e, a = Me(n);
return /* @__PURE__ */ r.jsx(en, { ...a, ...o, ref: t });
}
);
Dt.displayName = ro;
var so = "MenuSub", [Sr, Ot] = se(so), ie = "MenuSubTrigger", Nt = s.forwardRef(
(e, t) => {
const n = ce(ie, e.__scopeMenu), o = he(ie, e.__scopeMenu), a = Ot(ie, e.__scopeMenu), c = Ge(ie, e.__scopeMenu), i = s.useRef(null), { pointerGraceTimerRef: l, onPointerGraceIntentChange: p } = c, f = { __scopeMenu: e.__scopeMenu }, u = s.useCallback(() => {
i.current && window.clearTimeout(i.current), i.current = null;
}, []);
return s.useEffect(() => u, [u]), s.useEffect(() => {
const d = l.current;
return () => {
window.clearTimeout(d), p(null);
};
}, [l, p]), /* @__PURE__ */ r.jsx(Fe, { asChild: !0, ...f, children: /* @__PURE__ */ r.jsx(
Mt,
{
id: a.triggerId,
"aria-haspopup": "menu",
"aria-expanded": n.open,
"aria-controls": a.contentId,
"data-state": At(n.open),
...e,
ref: et(t, a.onTriggerChange),
onClick: (d) => {
e.onClick?.(d), !(e.disabled || d.defaultPrevented) && (d.currentTarget.focus(), n.open || n.onOpenChange(!0));
},
onPointerMove: S(
e.onPointerMove,
fe((d) => {
c.onItemEnter(d), !d.defaultPrevented && !e.disabled && !n.open && !i.current && (c.onPointerGraceIntentChange(null), i.current = window.setTimeout(() => {
n.onOpenChange(!0), u();
}, 100));
})
),
onPointerLeave: S(
e.onPointerLeave,
fe((d) => {
u();
const g = n.content?.getBoundingClientRect();
if (g) {
const R = n.content?.dataset.side, w = R === "right", v = w ? -5 : 5, m = g[w ? "left" : "right"], _ = g[w ? "right" : "left"];
c.onPointerGraceIntentChange({
area: [
// Apply a bleed on clientX to ensure that our exit point is
// consistently within polygon bounds
{ x: d.clientX + v, y: d.clientY },
{ x: m, y: g.top },
{ x: _, y: g.top },
{ x: _, y: g.bottom },
{ x: m, y: g.bottom }
],
side: R
}), window.clearTimeout(l.current), l.current = window.setTimeout(
() => c.onPointerGraceIntentChange(null),
300
);
} else {
if (c.onTriggerLeave(d), d.defaultPrevented) return;
c.onPointerGraceIntentChange(null);
}
})
),
onKeyDown: S(e.onKeyDown, (d) => {
const g = c.searchRef.current !== "";
e.disabled || g && d.key === " " || Gn[o.dir].includes(d.key) && (n.onOpenChange(!0), n.content?.focus(), d.preventDefault());
})
}
) });
}
);
Nt.displayName = ie;
var jt = "MenuSubContent", Pt = s.forwardRef(
(e, t) => {
const n = wt(z, e.__scopeMenu), { forceMount: o = n.forceMount, ...a } = e, c = ce(z, e.__scopeMenu), i = he(z, e.__scopeMenu), l = Ot(jt, e.__scopeMenu), p = s.useRef(null), f = ne(t, p);
return /* @__PURE__ */ r.jsx(de.Provider, { scope: e.__scopeMenu, children: /* @__PURE__ */ r.jsx(ke, { present: o || c.open, children: /* @__PURE__ */ r.jsx(de.Slot, { scope: e.__scopeMenu, children: /* @__PURE__ */ r.jsx(
Be,
{
id: l.contentId,
"aria-labelledby": l.triggerId,
...a,
ref: f,
align: "start",
side: i.dir === "rtl" ? "left" : "right",
disableOutsidePointerEvents: !1,
disableOutsideScroll: !1,
trapFocus: !1,
onOpenAutoFocus: (u) => {
i.isUsingKeyboardRef.current && p.current?.focus(), u.preventDefault();
},
onCloseAutoFocus: (u) => u.preventDefault(),
onFocusOutside: S(e.onFocusOutside, (u) => {
u.target !== l.trigger && c.onOpenChange(!1);
}),
onEscapeKeyDown: S(e.onEscapeKeyDown, (u) => {
i.onClose(), u.preventDefault();
}),
onKeyDown: S(e.onKeyDown, (u) => {
const d = u.currentTarget.contains(u.target), g = Bn[i.dir].includes(u.key);
d && g && (c.onOpenChange(!1), l.trigger?.focus(), u.preventDefault());
})
}
) }) }) });
}
);
Pt.displayName = jt;
function At(e) {
return e ? "open" : "closed";
}
function _e(e) {
return e === "indeterminate";
}
function $e(e) {
return _e(e) ? "indeterminate" : e ? "checked" : "unchecked";
}
function ao(e) {
const t = document.activeElement;
for (const n of e)
if (n === t || (n.focus(), document.activeElement !== t)) return;
}
function co(e, t) {
return e.map((n, o) => e[(t + o) % e.length]);
}
function io(e, t, n) {
const a = t.length > 1 && Array.from(t).every((f) => f === t[0]) ? t[0] : t, c = n ? e.indexOf(n) : -1;
let i = co(e, Math.max(c, 0));
a.length === 1 && (i = i.filter((f) => f !== n));
const p = i.find(
(f) => f.toLowerCase().startsWith(a.toLowerCase())
);
return p !== n ? p : void 0;
}
function uo(e, t) {
const { x: n, y: o } = e;
let a = !1;
for (let c = 0, i = t.length - 1; c < t.length; i = c++) {
const l = t[c], p = t[i], f = l.x, u = l.y, d = p.x, g = p.y;
u > o != g > o && n < (d - f) * (o - u) / (g - u) + f && (a = !a);
}
return a;
}
function lo(e, t) {
if (!t) return !1;
const n = { x: e.clientX, y: e.clientY };
return uo(n, t);
}
function fe(e) {
return (t) => t.pointerType === "mouse" ? e(t) : void 0;
}
var fo = vt, po = Fe, mo = _t, ho = Ue, go = xt, vo = Ce, wo = Ct, _o = St, xo = bt, Mo = It, Co = Tt, Ro = Dt, So = Nt, yo = Pt, Re = "DropdownMenu", [bo] = xe(
Re,
[ht]
), B = ht(), [Eo, kt] = bo(Re), Lt = (e) => {
const {
__scopeDropdownMenu: t,
children: n,
dir: o,
open: a,
defaultOpen: c,
onOpenChange: i,
modal: l = !0
} = e, p = B(t), f = s.useRef(null), [u, d] = Ze({
prop: a,
defaultProp: c ?? !1,
onChange: i,
caller: Re
});
return /* @__PURE__ */ r.jsx(
Eo,
{
scope: t,
triggerId: De(),
triggerRef: f,
contentId: De(),
open: u,
onOpenChange: d,
onOpenToggle: s.useCallback(() => d((g) => !g), [d]),
modal: l,
children: /* @__PURE__ */ r.jsx(fo, { ...p, open: u, onOpenChange: d, dir: o, modal: l, children: n })
}
);
};
Lt.displayName = Re;
var Ft = "DropdownMenuTrigger", Gt = s.forwardRef(
(e, t) => {
const { __scopeDropdownMenu: n, disabled: o = !1, ...a } = e, c = kt(Ft, n), i = B(n);
return /* @__PURE__ */ r.jsx(po, { asChild: !0, ...i, children: /* @__PURE__ */ r.jsx(
oe.button,
{
type: "button",
id: c.triggerId,
"aria-haspopup": "menu",
"aria-expanded": c.open,
"aria-controls": c.open ? c.contentId : void 0,
"data-state": c.open ? "open" : "closed",
"data-disabled": o ? "" : void 0,
disabled: o,
...a,
ref: et(t, c.triggerRef),
onPointerDown: S(e.onPointerDown, (l) => {
!o && l.button === 0 && l.ctrlKey === !1 && (c.onOpenToggle(), c.open || l.preventDefault());
}),
onKeyDown: S(e.onKeyDown, (l) => {
o || (["Enter", " "].includes(l.key) && c.onOpenToggle(), l.key === "ArrowDown" && c.onOpenChange(!0), ["Enter", " ", "ArrowDown"].includes(l.key) && l.preventDefault());
})
}
) });
}
);
Gt.displayName = Ft;
var Bt = "DropdownMenuContent", Ut = s.forwardRef(
(e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = kt(Bt, n), c = B(n), i = s.useRef(!1);
return /* @__PURE__ */ r.jsx(
mo,
{
id: a.contentId,
"aria-labelledby": a.triggerId,
...c,
...o,
ref: t,
onCloseAutoFocus: S(e.onCloseAutoFocus, (l) => {
i.current || a.triggerRef.current?.focus(), i.current = !1, l.preventDefault();
}),
onInteractOutside: S(e.onInteractOutside, (l) => {
const p = l.detail.originalEvent, f = p.button === 0 && p.ctrlKey === !0, u = p.button === 2 || f;
(!a.modal || u) && (i.current = !0);
}),
style: {
...e.style,
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
}
}
);
}
);
Ut.displayName = Bt;
var Io = "DropdownMenuGroup", To = s.forwardRef(
(e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
return /* @__PURE__ */ r.jsx(ho, { ...a, ...o, ref: t });
}
);
To.displayName = Io;
var Do = "DropdownMenuLabel", Oo = s.forwardRef(
(e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
return /* @__PURE__ */ r.jsx(go, { ...a, ...o, ref: t });
}
);
Oo.displayName = Do;
var No = "DropdownMenuItem", Kt = s.forwardRef(
(e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
return /* @__PURE__ */ r.jsx(vo, { ...a, ...o, ref: t });
}
);
Kt.displayName = No;
var jo = "DropdownMenuCheckboxItem", Po = s.forwardRef((e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
return /* @__PURE__ */ r.jsx(wo, { ...a, ...o, ref: t });
});
Po.displayName = jo;
var Ao = "DropdownMenuRadioGroup", ko = s.forwardRef((e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
return /* @__PURE__ */ r.jsx(_o, { ...a, ...o, ref: t });
});
ko.displayName = Ao;
var Lo = "DropdownMenuRadioItem", Fo = s.forwardRef((e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
return /* @__PURE__ */ r.jsx(xo, { ...a, ...o, ref: t });
});
Fo.displayName = Lo;
var Go = "DropdownMenuItemIndicator", Bo = s.forwardRef((e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
return /* @__PURE__ */ r.jsx(Mo, { ...a, ...o, ref: t });
});
Bo.displayName = Go;
var Uo = "DropdownMenuSeparator", Ko = s.forwardRef((e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
return /* @__PURE__ */ r.jsx(Co, { ...a, ...o, ref: t });
});
Ko.displayName = Uo;
var $o = "DropdownMenuArrow", zo = s.forwardRef(
(e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
return /* @__PURE__ */ r.jsx(Ro, { ...a, ...o, ref: t });
}
);
zo.displayName = $o;
var Vo = "DropdownMenuSubTrigger", Ho = s.forwardRef((e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
return /* @__PURE__ */ r.jsx(So, { ...a, ...o, ref: t });
});
Ho.displayName = Vo;
var Wo = "DropdownMenuSubContent", qo = s.forwardRef((e, t) => {
const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
return /* @__PURE__ */ r.jsx(
yo,
{
...a,
...o,
ref: t,
style: {
...e.style,
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
}
}
);
});
qo.displayName = Wo;
var Yo = Lt, Xo = Gt, Qo = Ut, qe = Kt;
function Zo({
title: e,
titleId: t,
...n
}, o) {
return /* @__PURE__ */ s.createElement("svg", Object.assign({
xmlns: "http://www.w3.org/2000/svg",
fill: "none",
viewBox: "0 0 24 24",
strokeWidth: 1.5,
stroke: "currentColor",
"aria-hidden": "true",
"data-slot": "icon",
ref: o,
"aria-labelledby": t
}, n), e ? /* @__PURE__ */ s.createElement("title", {
id: t
}, e) : null, /* @__PURE__ */ s.createElement("path", {
strokeLinecap: "round",
strokeLinejoin: "round",
d: "M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0-3.75-3.75M17.25 21 21 17.25"
}));
}
const Jo = /* @__PURE__ */ s.forwardRef(Zo), er = ({
sortByRelevanceLabel: e,
sortByDistanceLabel: t,
accessibilityLabel: n,
on: o = () => {
}
// default no-op
}) => {
const a = Le();
if (!a)
throw new Error("SortDropdown must be used within a SearchRankingProvider");
const { sortMode: c, setSortMode: i, requestLocation: l, locationDenied: p } = a, f = () => {
i("relevance"), o("sortRelevance");
}, u = async () => {
if (!p)
try {
await l(), i("distance"), o("sortDistance");
} catch {
}
};
return /* @__PURE__ */ r.jsxs(Yo, { onOpenChange: (d) => d && o("openSortMenu"), children: [
/* @__PURE__ */ r.jsx(Xo, { asChild: !0, children: /* @__PURE__ */ r.jsx(
"button",
{
type: "button",
className: "sid-sort-dropdown__trigger",
"aria-label": n,
children: /* @__PURE__ */ r.jsx(Jo, { className: "sid-sort-dropdown__icon" })
}
) }),
/* @__PURE__ */ r.jsxs(
Qo,
{
className: "sid-sort-dropdown__content",
sideOffset: 0,
collisionPadding: 10,
align: "end",
children: [
/* @__PURE__ */ r.jsx(
qe,
{
className: "sid-sort-dropdown__item",
onSelect: f,
"data-active": c === "relevance" ? "" : void 0,
children: e
}
),
/* @__PURE__ */ r.jsx(
qe,
{
className: "sid-sort-dropdown__item",
onSelect: u,
disabled: p,
"data-active": c === "distance" ? "" : void 0,
children: t
}
)
]
}
)
] });
};
var Ie, Ye;
function tr() {
if (Ye) return Ie;
Ye = 1;
function e(t, n, o) {
var a, c, i, l, p;
n == null && (n = 100);
function f() {
var d = Date.now() - l;
d < n && d >= 0 ? a = setTimeout(f, n - d) : (a = null, o || (p = t.apply(i, c), i = c = null));
}
var u = function() {
i = this, c = arguments, l = Date.now();
var d = o && !a;
return a || (a = setTimeout(f, n)), d && (p = t.apply(i, c), i = c = null), p;
};
return u.clear = function() {
a && (clearTimeout(a), a = null);
}, u.flush = function() {
a && (p = t.apply(i, c), i = c = null, clearTimeout(a), a = null);
}, u;
}
return e.debounce = e, Ie = e, Ie;
}
var nr = tr();
const or = 42, rr = 26, sr = ({
getItemProps: e,
highlightedIndex: t,
organizations: n,
itemToString: o,
children: a,
maxItemsToDisplay: c = rr
}) => {
const i = s.Children.count(a), l = (n.length + i) * or, p = {}, f = ae("org-search-overlay") === "overlay", u = Le(), d = tt(), g = s.useMemo(() => Cn(d), [d]), R = (v) => {
if (!u?.userLocation || v.latitude == null || v.longitude == null) return null;
const m = xn(
u.userLocation.latitude,
u.userLocation.longitude,
v.latitude,
v.longitude
);
return Rn(m, g);
};
s.useEffect(() => {
const v = document.getElementsByClassName("sid-organization-list__item--highlighted").item(0);
v && ("scrollIntoViewIfNeeded" in v && typeof v.scrollIntoViewIfNeeded == "function" ? v.scrollIntoViewIfNeeded(!0) : v.scrollIntoView({ behavior: "instant", block: "center" }));
}, [t]);
const w = (v, m) => {
const _ = [v.city, v.state].filter(Boolean).join(", "), y = R(v);
return /* @__PURE__ */ r.jsxs(
"div",
{
className: `sid-organization-list__item ${t === m ? "sid-organization-list__item--highlighted" : ""}`,
role: "option",
"aria-selected": t === m,
...e({
index: m,
item: v
}),
ref: p[t],
children: [
/* @__PURE__ */ r.jsx("span", { className: "sid-organization-list__name", children: o(v) }),
f && _ && /* @__PURE__ */ r.jsx("span", { className: "sid-organization-list__location", children: _ }),
y && /* @__PURE__ */ r.jsx("span", { className: "sid-organization-list__distance", "data-testid": "org-distance", children: y })
]
},
m
);
};
return /* @__PURE__ */ r.jsx(
"div",
{
id: "sid-org-list-menu",
className: "sid-organization-list__menu",
tabIndex: -1,
role: "listbox",
children: /* @__PURE__ */ r.jsxs("div", { style: { height: Math.min(l, 280) }, children: [
n.filter((v, m) => m <= c - 1).map((v, m) => w(v, m)),
a
] })
}
);
}, ar = sr, cr = ({ className: e }) => /* @__PURE__ */ r.jsx(
"svg",
{
xmlns: "http://www.w3.org/2000/svg",
fill: "none",
viewBox: "0 0 24 24",
strokeWidth: 1.5,
stroke: "currentColor",
className: e,
children: /* @__PURE__ */ r.jsx(
"path",
{
strokeLinecap: "round",
strokeLinejoin: "round",
d: "M12 18v-5.25m0 0a6.01 6.01 0 0 0 1.5-.189m-1.5.189a6.01 6.01 0 0 1-1.5-.189m3.75 7.478a12.06 12.06 0 0 1-4.5 0m3.75 2.383a14.406 14.406 0 0 1-3 0M14.25 18v-.192c0-.983.658-1.823 1.508-2.316a7.5 7.5 0 1 0-7.517 0c.85.493 1.509 1.333 1.509 2.316V18"
}
)
}
), Xe = ({
urlAddSchoolForm: e,
programId: t,
locale: n = sn,
onClick: o = () => {
},
onTipsShown: a
}) => {
const [c, i] = ee.useState(!1), { trackEvent: l } = ot({ programId: t }), p = () => {
le({
eventName: ue.ASR_TIPS_SHOWN,
params: { programId: t, locale: n }
}), l(X.AsrTipsShown), a?.(), i(!0);
};
return c ? /* @__PURE__ */ r.jsxs("div", { className: "sid-organization-list__add-school-tips", children: [
/* @__PURE__ */ r.jsxs("div", { className: "sid-organization-list__tips", children: [
/* @__PURE__ */ r.jsx("div", { children: /* @__PURE__ */ r.jsx(cr, { className: "sid-organization-list__tips-icon" }) }),
/* @__PURE__ */ r.jsxs("div", { className: "sid-organization-list__tips-text", children: [
/* @__PURE__ */ r.jsx(
te,
{
id: "multipleLocationsTips",
defaultMessage: "If your academic institution has multiple locations and you didn't see yours, enter the main location."
}
),
/* @__PURE__ */ r.jsx(
te,
{
id: "tryFullNameTips",
defaultMessage: "Try typing the full name of the academic institution rather than using acronyms or abbreviations."
}
)
] })
] }),
/* @__PURE__ */ r.jsx(
He,
{
onClick: o,
className: "sid-organization-list__item sid-organization-list__request-school sid-link",
href: `${e}?pid=${t}&locale=${n}`,
children: /* @__PURE__ */ r.jsx(
te,
{
id: "requestSchool",
defaultMessage: "Don't see your school? Request to have it added"
}
)
}
)
] }) : /* @__PURE__ */ r.jsx(
He,
{
onClick: p,
className: "sid-organization-list__item sid-organization-list__request-school sid-link",
children: /* @__PURE__ */ r.jsx(
te,
{
id: "cantFindYourSchool",
defaultMessage: "Can't find your school? Click to show tips"
}
)
}
);
}, Qe = (e) => rn("name", e) || "", ir = (e) => e && e.find((n) => n.source === "PLACE") ? /* @__PURE__ */ r.jsx(
"img",
{
className: "sid-organization-list__attribution-logo",
src: "https://developers.google.com/static/maps/documentation/images/google_on_white.png",
alt: "Google"
}
) : null, ur = (e, t, n) => {
if (!t && !n)
return e;
if (!e)
return Z.error("Expected orgSearchUrl"), e;
try {
const o = new URL(e), { origin: a, pathname: c, search: i } = o, l = new URLSearchParams(i);
return t && l.set("name", t), n && Object.entries(n).forEach(([p, f]) => {
l.set(p, f);
}), l.sort(), `${a}${c}?${l.toString()}`;
} catch (o) {
Z.error(o);
}
}, lr = ({
getItemProps: e,
getMenuProps: t,
highlightedIndex: n,
itemToString: o,
minimumSearchValueLength: a,
onLoaded: c,
programId: i,
orgSearchUrl: l,
locale: p,
urlAddSchoolForm: f,
openOrgSearchEnabled: u,
onClickAddSchool: d,
onTipsShown: g,
searchUrlParams: R,
searchValue: w
}) => {
const [v, m] = s.useState(!1), [_, y] = s.useState(null), [x, C] = s.useState(null), T = s.useRef(!1), j = s.useRef(null), E = Le(), b = s.useRef({ orgSearchUrl: l, searchValue: w, searchUrlParams: R, onLoaded: c });
b.current = { orgSearchUrl: l, searchValue: w, searchUrlParams: R, onLoaded: c };
const L = s.useRef(E);
L.current = E;
const I = w || Qe(l) || "", V = s.useCallback(async () => {
if (!T.current)
return;
const {
orgSearchUrl: K,
searchValue: N,
searchUrlParams: h,
onLoaded: G
} = b.current;
let k = h;
const A = L.current;
A && A.sortMode === "distance" && A.userLocation && (k = {
...h,
lat: String(A.userLocation.latitude),
long: String(A.userLocation.longitude)
});
const H = Date.now(), $ = await tn(
ur(K, N, k)
);
if (T.current) {
$ && (G($), y($), m(!1));
try {
const Y = N || Qe(K) || "", W = {
eventName: ue.ORGS_DISPLAYED,
params: {
queryLength: Y.length,
eventDuration: Date.now() - H,
numberOfResults: $?.length
}
};
le(W);
} catch (Y) {
Z.error(Y);
}
}
}, []), O = s.useRef(null);
O.current || (O.current = nr.debounce(V, nn)), s.useEffect(() => (T.current = !0, () => {
T.current = !1, O.current && O.current.clear();
}), []), s.useEffect(() => {
const K = j.current;
K !== I && (I.length >= a ? (C(null), m(!0), y(null), O.current && O.current()) : (C(null), m(!1), y(null), K !== null ? Z.info(
`No organizations fetched. Search searchTterm "${I}" is less than ${a} characters.`
) : I.length > 0 && Z.info(
`No organizations fetched. Search searchTerm "${I}" is less than ${a} characters.`
))), j.current = I;
}, [I, a]);
const q = E?.sortMode, F = E?.userLocation?.latitude, U = E?.userLocation?.longitude;
s.useEffect(() => {
I.length >= a && (C(null), m(!0), y(null), O.current?.());
}, [q, F, U, I, a]);
const D = ir(_);
return v ? /* @__PURE__ */ r.jsx("div", { className: "sid-organization-list__menu", children: /* @__PURE__ */ r.jsx("div", { className: "sid-organization-list__message sid-organization-list__spinner-container", children: /* @__PURE__ */ r.jsx("div", { id: "sid-spinner-container", children: /* @__PURE__ */ r.jsx(on, {}) }) }) }) : x ? /* @__PURE__ */ r.jsx("div", { className: "sid-organization-list__menu", children: /* @__PURE__ */ r.jsx("div", { className: "sid-organization-list__message", children: /* @__PURE__ */ r.jsx(
te,
{
id: "errorId.unknownError",
defaultMessage: "An unknown error occurred"
}
) }) }) : _ && _.length > 0 ? /* @__PURE__ */ r.jsxs(r.F