@rpcbase/client 0.384.0 → 0.386.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,32 +1,57 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useSyncExternalStore, lazy, useEffect, Suspense, StrictMode, useState, useRef, useCallback, useMemo, useLayoutEffect, createContext, useContext } from "react";
2
+ import { c } from "react/compiler-runtime";
3
+ import { useSyncExternalStore, lazy, useEffect, Suspense, StrictMode, useState, useRef, useLayoutEffect, createContext, useContext } from "react";
3
4
  import env from "@rpcbase/env";
4
5
  import { getNavigationGuards, createRoutesFromElements, createBrowserRouter, RouterProvider, useLocation, useRouteError, isRouteErrorResponse } from "@rpcbase/router";
5
6
  import { hydrateRoot } from "react-dom/client";
6
7
  import { r as reportClientException } from "./errorReporting-CVoUUKxW.js";
7
8
  import { s } from "./errorReporting-CVoUUKxW.js";
8
- import { n as hydrateRtsFromWindow, v as useQuery } from "./useQuery-Ce_EmI2F.js";
9
- import { R, S, p, q, t } from "./useQuery-Ce_EmI2F.js";
9
+ import { n as hydrateRtsFromWindow, v as useQuery } from "./useQuery-DImVXkBa.js";
10
+ import { R, S, p, q, t } from "./useQuery-DImVXkBa.js";
10
11
  const emptyUnsubscribe = () => {
11
12
  };
12
13
  const useMediaQuery = (query) => {
14
+ const $ = c(4);
13
15
  const isServer = typeof window === "undefined";
14
- const subscribe = (callback) => {
15
- if (isServer) return emptyUnsubscribe;
16
- const mql = window.matchMedia(query);
17
- if (mql.addEventListener) {
18
- mql.addEventListener("change", callback);
19
- return () => mql.removeEventListener("change", callback);
20
- }
21
- mql.addListener(callback);
22
- return () => mql.removeListener(callback);
23
- };
24
- const getSnapshot = () => {
25
- if (isServer) return false;
26
- return window.matchMedia(query).matches;
27
- };
28
- return useSyncExternalStore(subscribe, getSnapshot, () => false);
16
+ let t0;
17
+ if ($[0] !== query) {
18
+ t0 = (callback) => {
19
+ if (isServer) {
20
+ return emptyUnsubscribe;
21
+ }
22
+ const mql = window.matchMedia(query);
23
+ if (mql.addEventListener) {
24
+ mql.addEventListener("change", callback);
25
+ return () => mql.removeEventListener("change", callback);
26
+ }
27
+ mql.addListener(callback);
28
+ return () => mql.removeListener(callback);
29
+ };
30
+ $[0] = query;
31
+ $[1] = t0;
32
+ } else {
33
+ t0 = $[1];
34
+ }
35
+ const subscribe = t0;
36
+ let t1;
37
+ if ($[2] !== query) {
38
+ t1 = () => {
39
+ if (isServer) {
40
+ return false;
41
+ }
42
+ return window.matchMedia(query).matches;
43
+ };
44
+ $[2] = query;
45
+ $[3] = t1;
46
+ } else {
47
+ t1 = $[3];
48
+ }
49
+ const getSnapshot = t1;
50
+ return useSyncExternalStore(subscribe, getSnapshot, _temp$3);
29
51
  };
52
+ function _temp$3() {
53
+ return false;
54
+ }
30
55
  let sonner = null;
31
56
  let sonnerImport = null;
32
57
  const queued = [];
@@ -97,7 +122,12 @@ const startToaster = () => {
97
122
  const ensureReady = () => {
98
123
  if (typeof document === "undefined") startToaster();
99
124
  };
100
- const buildToastData = (data, id) => data ? { ...data, id } : { id };
125
+ const buildToastData = (data, id) => data ? {
126
+ ...data,
127
+ id
128
+ } : {
129
+ id
130
+ };
101
131
  const toastFn = ((message, data) => {
102
132
  ensureReady();
103
133
  const id = resolveId(data?.id) ?? createToastId();
@@ -179,14 +209,21 @@ const toastPromise = (promise, data) => {
179
209
  enqueue((m) => {
180
210
  m.toast.promise(startedPromise, data);
181
211
  });
182
- return { unwrap };
212
+ return {
213
+ unwrap
214
+ };
183
215
  }
184
216
  const id = resolveId(data.id) ?? createToastId();
185
- const nextData = { ...data, id };
217
+ const nextData = {
218
+ ...data,
219
+ id
220
+ };
186
221
  enqueue((m) => {
187
222
  m.toast.promise(startedPromise, nextData);
188
223
  });
189
- return Object.assign(id, { unwrap });
224
+ return Object.assign(id, {
225
+ unwrap
226
+ });
190
227
  };
191
228
  const toastDismiss = (id) => {
192
229
  ensureReady();
@@ -212,89 +249,177 @@ const toast = Object.assign(toastFn, {
212
249
  });
213
250
  const LazySonnerToaster = lazy(async () => {
214
251
  const mod = await import("sonner");
215
- return { default: mod.Toaster };
252
+ return {
253
+ default: mod.Toaster
254
+ };
216
255
  });
217
256
  const MountedLazyToaster = (props) => {
218
- useEffect(() => {
219
- setToasterMounted(true);
220
- return () => setToasterMounted(false);
221
- }, []);
222
- return /* @__PURE__ */ jsx(LazySonnerToaster, { ...props });
257
+ const $ = c(3);
258
+ let t0;
259
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
260
+ t0 = [];
261
+ $[0] = t0;
262
+ } else {
263
+ t0 = $[0];
264
+ }
265
+ useEffect(_temp2$1, t0);
266
+ let t1;
267
+ if ($[1] !== props) {
268
+ t1 = /* @__PURE__ */ jsx(LazySonnerToaster, { ...props });
269
+ $[1] = props;
270
+ $[2] = t1;
271
+ } else {
272
+ t1 = $[2];
273
+ }
274
+ return t1;
223
275
  };
224
276
  const ActiveToaster = () => {
277
+ const $ = c(9);
225
278
  const isMobile = useMediaQuery("(max-width: 767px)");
226
279
  const isCoarsePointer = useMediaQuery("(hover: none) and (pointer: coarse)");
227
280
  const position = isMobile ? "top-center" : void 0;
228
- useEffect(() => {
229
- const handler = (event) => {
230
- const target = event.target;
231
- if (!(target instanceof Element)) return;
232
- if (!target.closest("[data-sonner-toaster]")) return;
233
- event.preventDefault();
234
- };
235
- document.addEventListener("dismissableLayer.pointerDownOutside", handler, true);
236
- document.addEventListener("dismissableLayer.focusOutside", handler, true);
237
- return () => {
238
- document.removeEventListener("dismissableLayer.pointerDownOutside", handler, true);
239
- document.removeEventListener("dismissableLayer.focusOutside", handler, true);
281
+ let t0;
282
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
283
+ t0 = [];
284
+ $[0] = t0;
285
+ } else {
286
+ t0 = $[0];
287
+ }
288
+ useEffect(_temp4$1, t0);
289
+ const t1 = !isCoarsePointer;
290
+ let t2;
291
+ if ($[1] !== isCoarsePointer) {
292
+ t2 = isCoarsePointer ? void 0 : [];
293
+ $[1] = isCoarsePointer;
294
+ $[2] = t2;
295
+ } else {
296
+ t2 = $[2];
297
+ }
298
+ let t3;
299
+ if ($[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
300
+ t3 = {
301
+ pointerEvents: "auto",
302
+ "--toast-close-button-start": "unset",
303
+ "--toast-close-button-end": "0",
304
+ "--toast-close-button-transform": "translate(35%, -35%)"
240
305
  };
241
- }, []);
242
- return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
243
- MountedLazyToaster,
244
- {
245
- closeButton: !isCoarsePointer,
246
- theme: "dark",
247
- position,
248
- swipeDirections: isCoarsePointer ? void 0 : [],
306
+ $[3] = t3;
307
+ } else {
308
+ t3 = $[3];
309
+ }
310
+ let t4;
311
+ if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
312
+ t4 = {
249
313
  style: {
250
314
  pointerEvents: "auto",
251
- "--toast-close-button-start": "unset",
252
- "--toast-close-button-end": "0",
253
- "--toast-close-button-transform": "translate(35%, -35%)"
254
- },
255
- toastOptions: {
256
- style: {
257
- pointerEvents: "auto",
258
- userSelect: "text"
259
- }
315
+ userSelect: "text"
260
316
  }
261
- }
262
- ) });
317
+ };
318
+ $[4] = t4;
319
+ } else {
320
+ t4 = $[4];
321
+ }
322
+ let t5;
323
+ if ($[5] !== position || $[6] !== t1 || $[7] !== t2) {
324
+ t5 = /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(MountedLazyToaster, { closeButton: t1, theme: "dark", position, swipeDirections: t2, style: t3, toastOptions: t4 }) });
325
+ $[5] = position;
326
+ $[6] = t1;
327
+ $[7] = t2;
328
+ $[8] = t5;
329
+ } else {
330
+ t5 = $[8];
331
+ }
332
+ return t5;
263
333
  };
264
334
  const Toaster = () => {
265
- useEffect(() => {
266
- if (typeof window === "undefined") return;
267
- const startDeferred = () => {
268
- if (typeof window.requestIdleCallback === "function") {
269
- window.requestIdleCallback(() => startToaster(), { timeout: 2e3 });
270
- return;
271
- }
272
- window.setTimeout(() => startToaster(), 150);
273
- };
274
- if (isPageLoaded()) {
275
- startDeferred();
276
- return;
277
- }
278
- window.addEventListener("load", startDeferred, { once: true });
279
- return () => {
280
- window.removeEventListener("load", startDeferred);
281
- };
282
- }, []);
283
- const requested = useSyncExternalStore(
284
- subscribeToasterRequested,
285
- getToasterRequested,
286
- getToasterRequested
287
- );
288
- if (!requested) return null;
289
- return /* @__PURE__ */ jsx(ActiveToaster, {});
335
+ const $ = c(2);
336
+ let t0;
337
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
338
+ t0 = [];
339
+ $[0] = t0;
340
+ } else {
341
+ t0 = $[0];
342
+ }
343
+ useEffect(_temp8, t0);
344
+ const requested = useSyncExternalStore(subscribeToasterRequested, getToasterRequested, getToasterRequested);
345
+ if (!requested) {
346
+ return null;
347
+ }
348
+ let t1;
349
+ if ($[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
350
+ t1 = /* @__PURE__ */ jsx(ActiveToaster, {});
351
+ $[1] = t1;
352
+ } else {
353
+ t1 = $[1];
354
+ }
355
+ return t1;
290
356
  };
357
+ function _temp$2() {
358
+ return setToasterMounted(false);
359
+ }
360
+ function _temp2$1() {
361
+ setToasterMounted(true);
362
+ return _temp$2;
363
+ }
364
+ function _temp3$1(event) {
365
+ const target = event.target;
366
+ if (!(target instanceof Element)) {
367
+ return;
368
+ }
369
+ if (!target.closest("[data-sonner-toaster]")) {
370
+ return;
371
+ }
372
+ event.preventDefault();
373
+ }
374
+ function _temp4$1() {
375
+ const handler = _temp3$1;
376
+ document.addEventListener("dismissableLayer.pointerDownOutside", handler, true);
377
+ document.addEventListener("dismissableLayer.focusOutside", handler, true);
378
+ return () => {
379
+ document.removeEventListener("dismissableLayer.pointerDownOutside", handler, true);
380
+ document.removeEventListener("dismissableLayer.focusOutside", handler, true);
381
+ };
382
+ }
383
+ function _temp5$1() {
384
+ return startToaster();
385
+ }
386
+ function _temp6() {
387
+ return startToaster();
388
+ }
389
+ function _temp7() {
390
+ if (typeof window.requestIdleCallback === "function") {
391
+ window.requestIdleCallback(_temp5$1, {
392
+ timeout: 2e3
393
+ });
394
+ return;
395
+ }
396
+ window.setTimeout(_temp6, 150);
397
+ }
398
+ function _temp8() {
399
+ if (typeof window === "undefined") {
400
+ return;
401
+ }
402
+ const startDeferred = _temp7;
403
+ if (isPageLoaded()) {
404
+ startDeferred();
405
+ return;
406
+ }
407
+ window.addEventListener("load", startDeferred, {
408
+ once: true
409
+ });
410
+ return () => {
411
+ window.removeEventListener("load", startDeferred);
412
+ };
413
+ }
291
414
  let apiClient;
292
415
  const initApiClient = async (args) => {
293
416
  if (env.SSR) {
294
417
  if (!args) {
295
418
  throw new Error("Server args must be provided in SSR mode");
296
419
  }
297
- const { getServerApiClient } = await import("./getServerApiClient-BYu8h5Zd.js");
420
+ const {
421
+ getServerApiClient
422
+ } = await import("./getServerApiClient-C1UInaMF.js");
298
423
  apiClient = await getServerApiClient(args.app);
299
424
  } else {
300
425
  const axios = (await import("axios/dist/browser/axios.cjs")).default;
@@ -310,7 +435,11 @@ const initApiClient = async (args) => {
310
435
  const config = {
311
436
  method,
312
437
  url: path,
313
- ...method === "get" ? { params: payload } : { data: payload },
438
+ ...method === "get" ? {
439
+ params: payload
440
+ } : {
441
+ data: payload
442
+ },
314
443
  headers: {
315
444
  // ...(typeof ctxOrPath !== 'string' && {
316
445
  // // 'X-Custom-Header': ctxOrPath.someHeaderValue,
@@ -357,7 +486,9 @@ const cleanupURL = () => {
357
486
  if (document.readyState === "complete" || document.readyState === "interactive") {
358
487
  runCleanup();
359
488
  } else {
360
- document.addEventListener("DOMContentLoaded", runCleanup, { once: true });
489
+ document.addEventListener("DOMContentLoaded", runCleanup, {
490
+ once: true
491
+ });
361
492
  }
362
493
  };
363
494
  const DEFAULT_PRIORITY = 0;
@@ -376,7 +507,10 @@ const pickNavigationGuard = (args) => {
376
507
  if (!isPathnameChange && !isSearchChange) {
377
508
  return null;
378
509
  }
379
- const eligibleGuards = getNavigationGuards().filter((guard) => canBlockNavigation(guard, { isPathnameChange, isSearchChange })).filter((guard) => guard.shouldBlockNavigation(args));
510
+ const eligibleGuards = getNavigationGuards().filter((guard) => canBlockNavigation(guard, {
511
+ isPathnameChange,
512
+ isSearchChange
513
+ })).filter((guard) => guard.shouldBlockNavigation(args));
380
514
  if (eligibleGuards.length === 0) {
381
515
  return null;
382
516
  }
@@ -528,24 +662,93 @@ const consumeClientSsrErrorState = () => {
528
662
  };
529
663
  const DEFAULT_TITLE = "Something went wrong";
530
664
  const DEFAULT_MESSAGE = "We couldn't render this page. Please try again in a few seconds.";
531
- const SsrErrorFallback = ({ state, renderErrorExtra }) => {
665
+ const SsrErrorFallback = (t0) => {
666
+ const $ = c(19);
667
+ const {
668
+ state,
669
+ renderErrorExtra
670
+ } = t0;
532
671
  const {
533
- statusCode = 500,
534
- title = DEFAULT_TITLE,
535
- message = DEFAULT_MESSAGE,
672
+ statusCode: t1,
673
+ title: t2,
674
+ message: t3,
536
675
  details
537
676
  } = state;
538
- const extra = renderErrorExtra?.(state);
539
- return /* @__PURE__ */ jsx("div", { className: "bg-white min-h-screen", children: /* @__PURE__ */ jsxs("main", { className: "mx-auto flex min-h-screen max-w-2xl flex-col items-center justify-center px-6 py-12 text-center sm:py-24", children: [
540
- /* @__PURE__ */ jsx("p", { className: "text-base font-semibold text-rose-600", children: statusCode }),
541
- /* @__PURE__ */ jsx("h1", { className: "mt-4 text-pretty text-4xl font-semibold tracking-tight text-gray-900 sm:text-5xl", children: title }),
542
- /* @__PURE__ */ jsx("p", { className: "mt-6 text-lg text-gray-600 sm:text-xl/relaxed", children: message }),
543
- details ? /* @__PURE__ */ jsxs("div", { className: "mt-10 w-full rounded-2xl bg-gray-900/95 p-5 text-left shadow-2xl", children: [
677
+ const statusCode = t1 === void 0 ? 500 : t1;
678
+ const title = t2 === void 0 ? DEFAULT_TITLE : t2;
679
+ const message = t3 === void 0 ? DEFAULT_MESSAGE : t3;
680
+ let t4;
681
+ if ($[0] !== renderErrorExtra || $[1] !== state) {
682
+ t4 = renderErrorExtra?.(state);
683
+ $[0] = renderErrorExtra;
684
+ $[1] = state;
685
+ $[2] = t4;
686
+ } else {
687
+ t4 = $[2];
688
+ }
689
+ const extra = t4;
690
+ let t5;
691
+ if ($[3] !== statusCode) {
692
+ t5 = /* @__PURE__ */ jsx("p", { className: "text-base font-semibold text-rose-600", children: statusCode });
693
+ $[3] = statusCode;
694
+ $[4] = t5;
695
+ } else {
696
+ t5 = $[4];
697
+ }
698
+ let t6;
699
+ if ($[5] !== title) {
700
+ t6 = /* @__PURE__ */ jsx("h1", { className: "mt-4 text-pretty text-4xl font-semibold tracking-tight text-gray-900 sm:text-5xl", children: title });
701
+ $[5] = title;
702
+ $[6] = t6;
703
+ } else {
704
+ t6 = $[6];
705
+ }
706
+ let t7;
707
+ if ($[7] !== message) {
708
+ t7 = /* @__PURE__ */ jsx("p", { className: "mt-6 text-lg text-gray-600 sm:text-xl/relaxed", children: message });
709
+ $[7] = message;
710
+ $[8] = t7;
711
+ } else {
712
+ t7 = $[8];
713
+ }
714
+ let t8;
715
+ if ($[9] !== details) {
716
+ t8 = details ? /* @__PURE__ */ jsxs("div", { className: "mt-10 w-full rounded-2xl bg-gray-900/95 p-5 text-left shadow-2xl", children: [
544
717
  /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold uppercase tracking-wide text-gray-400", children: "Debug details" }),
545
718
  /* @__PURE__ */ jsx("pre", { className: "mt-3 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-gray-100", children: details })
546
- ] }) : null,
547
- extra ? /* @__PURE__ */ jsx("div", { className: "mt-10 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-center", children: extra }) : null
548
- ] }) });
719
+ ] }) : null;
720
+ $[9] = details;
721
+ $[10] = t8;
722
+ } else {
723
+ t8 = $[10];
724
+ }
725
+ let t9;
726
+ if ($[11] !== extra) {
727
+ t9 = extra ? /* @__PURE__ */ jsx("div", { className: "mt-10 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-center", children: extra }) : null;
728
+ $[11] = extra;
729
+ $[12] = t9;
730
+ } else {
731
+ t9 = $[12];
732
+ }
733
+ let t10;
734
+ if ($[13] !== t5 || $[14] !== t6 || $[15] !== t7 || $[16] !== t8 || $[17] !== t9) {
735
+ t10 = /* @__PURE__ */ jsx("div", { className: "bg-white min-h-screen", children: /* @__PURE__ */ jsxs("main", { className: "mx-auto flex min-h-screen max-w-2xl flex-col items-center justify-center px-6 py-12 text-center sm:py-24", children: [
736
+ t5,
737
+ t6,
738
+ t7,
739
+ t8,
740
+ t9
741
+ ] }) });
742
+ $[13] = t5;
743
+ $[14] = t6;
744
+ $[15] = t7;
745
+ $[16] = t8;
746
+ $[17] = t9;
747
+ $[18] = t10;
748
+ } else {
749
+ t10 = $[18];
750
+ }
751
+ return t10;
549
752
  };
550
753
  const isProduction = env.MODE === "production";
551
754
  const LOADER_TIMEOUT_MS = 8e3;
@@ -561,7 +764,9 @@ const showErrorOverlay = (err) => {
561
764
  const handleServerErrors = () => {
562
765
  const hydrationData = window.__staticRouterHydrationData;
563
766
  if (hydrationData?.errors) {
564
- const { errors } = hydrationData;
767
+ const {
768
+ errors
769
+ } = hydrationData;
565
770
  Object.values(errors).forEach((error) => {
566
771
  showErrorOverlay({
567
772
  plugin: "ssr-router",
@@ -575,8 +780,14 @@ const clearStaticRouterHydrationData = () => {
575
780
  };
576
781
  const wrapLoaderWithTimeout = (loader, routeId) => async (...args) => new Promise((resolve, reject) => {
577
782
  const timer = setTimeout(() => {
578
- console.error("[rpcbase timeout][client loader]", { routeId, ms: LOADER_TIMEOUT_MS, url: window.location.href });
579
- reject(new Response("Loader timeout", { status: 504 }));
783
+ console.error("[rpcbase timeout][client loader]", {
784
+ routeId,
785
+ ms: LOADER_TIMEOUT_MS,
786
+ url: window.location.href
787
+ });
788
+ reject(new Response("Loader timeout", {
789
+ status: 504
790
+ }));
580
791
  }, LOADER_TIMEOUT_MS);
581
792
  Promise.resolve(loader(...args)).then((val) => {
582
793
  clearTimeout(timer);
@@ -620,19 +831,41 @@ const hydrateSsrFallbackIfPresent = (rootElement, renderErrorExtra) => {
620
831
  return false;
621
832
  }
622
833
  consumeClientSsrErrorState();
623
- hydrateRoot(
624
- rootElement,
625
- /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(SsrErrorFallback, { state: ssrErrorState, renderErrorExtra }) })
626
- );
834
+ hydrateRoot(rootElement, /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(SsrErrorFallback, { state: ssrErrorState, renderErrorExtra }) }));
627
835
  return true;
628
836
  };
629
- const ClientOnly = ({ children }) => {
837
+ const ClientOnly = (t0) => {
838
+ const $ = c(4);
839
+ const {
840
+ children
841
+ } = t0;
630
842
  const [mounted, setMounted] = useState(false);
631
- useEffect(() => {
632
- setMounted(true);
633
- }, []);
634
- if (!mounted) return null;
635
- return /* @__PURE__ */ jsx(Fragment, { children });
843
+ let t1;
844
+ let t2;
845
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
846
+ t1 = () => {
847
+ setMounted(true);
848
+ };
849
+ t2 = [];
850
+ $[0] = t1;
851
+ $[1] = t2;
852
+ } else {
853
+ t1 = $[0];
854
+ t2 = $[1];
855
+ }
856
+ useEffect(t1, t2);
857
+ if (!mounted) {
858
+ return null;
859
+ }
860
+ let t3;
861
+ if ($[2] !== children) {
862
+ t3 = /* @__PURE__ */ jsx(Fragment, { children });
863
+ $[2] = children;
864
+ $[3] = t3;
865
+ } else {
866
+ t3 = $[3];
867
+ }
868
+ return t3;
636
869
  };
637
870
  const initWithRoutes = async (routesElement, opts) => {
638
871
  const rootElement = getRootElement();
@@ -686,17 +919,15 @@ const initWithRoutes = async (routesElement, opts) => {
686
919
  console.error(err, errorInfo?.componentStack);
687
920
  }
688
921
  } : void 0;
689
- hydrateRoot(
690
- rootElement,
691
- /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsxs(Fragment, { children: [
692
- /* @__PURE__ */ jsx(RouterProvider, { router }),
693
- /* @__PURE__ */ jsx(ClientOnly, { children: /* @__PURE__ */ jsx(Toaster, {}) })
694
- ] }) }),
695
- hydrationOptions
696
- );
922
+ hydrateRoot(rootElement, /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsxs(Fragment, { children: [
923
+ /* @__PURE__ */ jsx(RouterProvider, { router }),
924
+ /* @__PURE__ */ jsx(ClientOnly, { children: /* @__PURE__ */ jsx(Toaster, {}) })
925
+ ] }) }), hydrationOptions);
697
926
  };
698
927
  if (!isProduction && !env.SSR) {
699
- import("react-grab/core").then(({ init }) => {
928
+ import("react-grab/core").then(({
929
+ init
930
+ }) => {
700
931
  init({
701
932
  // theme: { hue: 350 }
702
933
  });
@@ -967,8 +1198,8 @@ function require_Symbol() {
967
1198
  if (hasRequired_Symbol) return _Symbol;
968
1199
  hasRequired_Symbol = 1;
969
1200
  var root = require_root();
970
- var Symbol = root.Symbol;
971
- _Symbol = Symbol;
1201
+ var Symbol2 = root.Symbol;
1202
+ _Symbol = Symbol2;
972
1203
  return _Symbol;
973
1204
  }
974
1205
  var _arrayMap;
@@ -1000,11 +1231,11 @@ var hasRequired_getRawTag;
1000
1231
  function require_getRawTag() {
1001
1232
  if (hasRequired_getRawTag) return _getRawTag;
1002
1233
  hasRequired_getRawTag = 1;
1003
- var Symbol = require_Symbol();
1234
+ var Symbol2 = require_Symbol();
1004
1235
  var objectProto = Object.prototype;
1005
1236
  var hasOwnProperty2 = objectProto.hasOwnProperty;
1006
1237
  var nativeObjectToString = objectProto.toString;
1007
- var symToStringTag = Symbol ? Symbol.toStringTag : void 0;
1238
+ var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
1008
1239
  function getRawTag(value) {
1009
1240
  var isOwn = hasOwnProperty2.call(value, symToStringTag), tag = value[symToStringTag];
1010
1241
  try {
@@ -1043,9 +1274,9 @@ var hasRequired_baseGetTag;
1043
1274
  function require_baseGetTag() {
1044
1275
  if (hasRequired_baseGetTag) return _baseGetTag;
1045
1276
  hasRequired_baseGetTag = 1;
1046
- var Symbol = require_Symbol(), getRawTag = require_getRawTag(), objectToString = require_objectToString();
1277
+ var Symbol2 = require_Symbol(), getRawTag = require_getRawTag(), objectToString = require_objectToString();
1047
1278
  var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
1048
- var symToStringTag = Symbol ? Symbol.toStringTag : void 0;
1279
+ var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
1049
1280
  function baseGetTag(value) {
1050
1281
  if (value == null) {
1051
1282
  return value === void 0 ? undefinedTag : nullTag;
@@ -1084,8 +1315,8 @@ var hasRequired_baseToString;
1084
1315
  function require_baseToString() {
1085
1316
  if (hasRequired_baseToString) return _baseToString;
1086
1317
  hasRequired_baseToString = 1;
1087
- var Symbol = require_Symbol(), arrayMap = require_arrayMap(), isArray = requireIsArray(), isSymbol = requireIsSymbol();
1088
- var symbolProto = Symbol ? Symbol.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
1318
+ var Symbol2 = require_Symbol(), arrayMap = require_arrayMap(), isArray = requireIsArray(), isSymbol = requireIsSymbol();
1319
+ var symbolProto = Symbol2 ? Symbol2.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
1089
1320
  function baseToString(value) {
1090
1321
  if (typeof value == "string") {
1091
1322
  return value;
@@ -1233,11 +1464,12 @@ const getFeatureFlag = async (flag) => {
1233
1464
  return process.env[envKey];
1234
1465
  }
1235
1466
  const startTime = performance.now();
1236
- const { PostHog } = await Function("return import('posthog-node')")();
1237
- const client = new PostHog(
1238
- process.env.RB_PUBLIC_POSTHOG_KEY,
1239
- { host: "https://eu.i.posthog.com" }
1240
- );
1467
+ const {
1468
+ PostHog
1469
+ } = await Function("return import('posthog-node')")();
1470
+ const client = new PostHog(process.env.RB_PUBLIC_POSTHOG_KEY, {
1471
+ host: "https://eu.i.posthog.com"
1472
+ });
1241
1473
  const distinctId = "server";
1242
1474
  console.log("TODO: NYI server side feature flags client distinctId");
1243
1475
  const value = await client.getFeatureFlag(flag, distinctId);
@@ -1265,7 +1497,9 @@ const getFeatureFlag = async (flag) => {
1265
1497
  return globalThis.__rb_env__[envKey];
1266
1498
  }
1267
1499
  const startTime = performance.now();
1268
- const { posthog } = await import("posthog-js");
1500
+ const {
1501
+ posthog
1502
+ } = await import("posthog-js");
1269
1503
  let hasLoadedFeatureFlags = false;
1270
1504
  const TIMEOUT_MS = 8e3;
1271
1505
  await waitForFeatureFlags();
@@ -1287,126 +1521,223 @@ function throttle(callback, limit) {
1287
1521
  };
1288
1522
  }
1289
1523
  function useApplyScroll() {
1524
+ const $ = c(17);
1290
1525
  const location = useLocation();
1291
1526
  const previousPathRef = useRef(location.pathname);
1292
1527
  const isScrollingProgrammatically = useRef(false);
1293
1528
  const scrollTimeoutRef = useRef(null);
1294
1529
  const lastAppliedHashRef = useRef("");
1295
- useEffect(() => {
1296
- if (typeof window !== "undefined") {
1297
- lastAppliedHashRef.current = window.location.hash || "";
1298
- }
1299
- }, []);
1300
- useEffect(() => {
1301
- lastAppliedHashRef.current = location.hash || "";
1302
- }, [location.hash]);
1303
- const replaceHashSilently = useCallback((hash) => {
1304
- if (typeof window === "undefined") {
1305
- return;
1306
- }
1307
- if (lastAppliedHashRef.current === hash) {
1308
- return;
1309
- }
1310
- const base = `${window.location.pathname}${window.location.search}`;
1311
- window.history.replaceState(window.history.state, "", `${base}${hash}`);
1312
- lastAppliedHashRef.current = hash;
1313
- }, []);
1314
- const markProgrammaticScroll = useCallback(() => {
1315
- isScrollingProgrammatically.current = true;
1316
- if (scrollTimeoutRef.current) {
1317
- clearTimeout(scrollTimeoutRef.current);
1318
- }
1319
- scrollTimeoutRef.current = setTimeout(() => {
1320
- isScrollingProgrammatically.current = false;
1321
- }, 1e3);
1322
- }, []);
1323
- useEffect(() => {
1324
- const pathChanged = previousPathRef.current !== location.pathname;
1325
- if (pathChanged) {
1326
- previousPathRef.current = location.pathname;
1327
- if (!location.hash) {
1328
- window.scrollTo({ top: 0, left: 0, behavior: "auto" });
1329
- return;
1530
+ let t0;
1531
+ let t1;
1532
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1533
+ t0 = () => {
1534
+ if (typeof window !== "undefined") {
1535
+ lastAppliedHashRef.current = window.location.hash || "";
1330
1536
  }
1331
- setTimeout(() => {
1332
- const id2 = location.hash.substring(1);
1333
- const element2 = document.getElementById(id2);
1334
- if (element2) {
1335
- markProgrammaticScroll();
1336
- element2.scrollIntoView({ behavior: "smooth" });
1337
- }
1338
- }, 100);
1339
- return;
1340
- }
1341
- if (!location.hash) {
1342
- return;
1343
- }
1344
- const id = location.hash.substring(1);
1345
- const element = document.getElementById(id);
1346
- if (element) {
1347
- markProgrammaticScroll();
1348
- element.scrollIntoView({ behavior: "smooth" });
1349
- }
1350
- }, [location.hash, location.pathname, markProgrammaticScroll]);
1351
- useEffect(() => {
1352
- if (typeof window === "undefined") {
1353
- return;
1354
- }
1355
- const handleScroll = throttle(() => {
1356
- if (isScrollingProgrammatically.current) {
1537
+ };
1538
+ t1 = [];
1539
+ $[0] = t0;
1540
+ $[1] = t1;
1541
+ } else {
1542
+ t0 = $[0];
1543
+ t1 = $[1];
1544
+ }
1545
+ useEffect(t0, t1);
1546
+ let t2;
1547
+ let t3;
1548
+ if ($[2] !== location.hash) {
1549
+ t2 = () => {
1550
+ lastAppliedHashRef.current = location.hash || "";
1551
+ };
1552
+ t3 = [location.hash];
1553
+ $[2] = location.hash;
1554
+ $[3] = t2;
1555
+ $[4] = t3;
1556
+ } else {
1557
+ t2 = $[3];
1558
+ t3 = $[4];
1559
+ }
1560
+ useEffect(t2, t3);
1561
+ let t4;
1562
+ if ($[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1563
+ t4 = (hash) => {
1564
+ if (typeof window === "undefined") {
1357
1565
  return;
1358
1566
  }
1359
- const sections = Array.from(document.querySelectorAll("section[id]"));
1360
- if (sections.length === 0) {
1361
- replaceHashSilently("");
1567
+ if (lastAppliedHashRef.current === hash) {
1362
1568
  return;
1363
1569
  }
1364
- const scrollPosition = window.scrollY;
1365
- const viewportHeight = window.innerHeight;
1366
- const checkPoint = scrollPosition + viewportHeight / 3;
1367
- let activeSectionId = null;
1368
- for (const section of sections) {
1369
- if (section.offsetTop <= checkPoint && section.offsetTop + section.offsetHeight > checkPoint) {
1370
- activeSectionId = section.id;
1371
- break;
1372
- }
1373
- }
1374
- const newHash = activeSectionId ? `#${activeSectionId}` : "";
1375
- replaceHashSilently(newHash);
1376
- }, 150);
1377
- document.addEventListener("scroll", handleScroll);
1378
- return () => {
1379
- document.removeEventListener("scroll", handleScroll);
1570
+ const base = `${window.location.pathname}${window.location.search}`;
1571
+ window.history.replaceState(window.history.state, "", `${base}${hash}`);
1572
+ lastAppliedHashRef.current = hash;
1573
+ };
1574
+ $[5] = t4;
1575
+ } else {
1576
+ t4 = $[5];
1577
+ }
1578
+ const replaceHashSilently = t4;
1579
+ let t5;
1580
+ if ($[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1581
+ t5 = () => {
1582
+ isScrollingProgrammatically.current = true;
1380
1583
  if (scrollTimeoutRef.current) {
1381
1584
  clearTimeout(scrollTimeoutRef.current);
1382
- scrollTimeoutRef.current = null;
1383
1585
  }
1586
+ scrollTimeoutRef.current = setTimeout(() => {
1587
+ isScrollingProgrammatically.current = false;
1588
+ }, 1e3);
1384
1589
  };
1385
- }, [replaceHashSilently]);
1386
- useEffect(() => {
1387
- const handleClick = (event) => {
1388
- const target = event.target;
1389
- const link = target?.closest("a");
1390
- const currentHash = typeof window !== "undefined" ? window.location.hash : location.hash || "";
1391
- if (!link || !link.hash || link.pathname !== location.pathname || link.hash !== currentHash) {
1590
+ $[6] = t5;
1591
+ } else {
1592
+ t5 = $[6];
1593
+ }
1594
+ const markProgrammaticScroll = t5;
1595
+ let t6;
1596
+ let t7;
1597
+ if ($[7] !== location.hash || $[8] !== location.pathname) {
1598
+ t6 = () => {
1599
+ const pathChanged = previousPathRef.current !== location.pathname;
1600
+ if (pathChanged) {
1601
+ previousPathRef.current = location.pathname;
1602
+ if (!location.hash) {
1603
+ window.scrollTo({
1604
+ top: 0,
1605
+ left: 0,
1606
+ behavior: "auto"
1607
+ });
1608
+ return;
1609
+ }
1610
+ setTimeout(() => {
1611
+ const id = location.hash.substring(1);
1612
+ const element = document.getElementById(id);
1613
+ if (element) {
1614
+ markProgrammaticScroll();
1615
+ element.scrollIntoView({
1616
+ behavior: "smooth"
1617
+ });
1618
+ }
1619
+ }, 100);
1392
1620
  return;
1393
1621
  }
1394
- const id = link.hash.substring(1);
1395
- const element = document.getElementById(id);
1396
- if (element) {
1397
- event.preventDefault();
1398
- event.stopPropagation();
1622
+ if (!location.hash) {
1623
+ return;
1624
+ }
1625
+ const id_0 = location.hash.substring(1);
1626
+ const element_0 = document.getElementById(id_0);
1627
+ if (element_0) {
1399
1628
  markProgrammaticScroll();
1400
- element.scrollIntoView({ behavior: "smooth" });
1629
+ element_0.scrollIntoView({
1630
+ behavior: "smooth"
1631
+ });
1401
1632
  }
1402
1633
  };
1403
- document.addEventListener("click", handleClick, true);
1404
- return () => document.removeEventListener("click", handleClick, true);
1405
- }, [location.hash, location.pathname, markProgrammaticScroll]);
1634
+ t7 = [location.hash, location.pathname, markProgrammaticScroll];
1635
+ $[7] = location.hash;
1636
+ $[8] = location.pathname;
1637
+ $[9] = t6;
1638
+ $[10] = t7;
1639
+ } else {
1640
+ t6 = $[9];
1641
+ t7 = $[10];
1642
+ }
1643
+ useEffect(t6, t7);
1644
+ let t8;
1645
+ let t9;
1646
+ if ($[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1647
+ t8 = () => {
1648
+ if (typeof window === "undefined") {
1649
+ return;
1650
+ }
1651
+ const handleScroll = throttle(() => {
1652
+ if (isScrollingProgrammatically.current) {
1653
+ return;
1654
+ }
1655
+ const sections = Array.from(document.querySelectorAll("section[id]"));
1656
+ if (sections.length === 0) {
1657
+ replaceHashSilently("");
1658
+ return;
1659
+ }
1660
+ const scrollPosition = window.scrollY;
1661
+ const viewportHeight = window.innerHeight;
1662
+ const checkPoint = scrollPosition + viewportHeight / 3;
1663
+ let activeSectionId = null;
1664
+ for (const section of sections) {
1665
+ if (section.offsetTop <= checkPoint && section.offsetTop + section.offsetHeight > checkPoint) {
1666
+ activeSectionId = section.id;
1667
+ break;
1668
+ }
1669
+ }
1670
+ const newHash = activeSectionId ? `#${activeSectionId}` : "";
1671
+ replaceHashSilently(newHash);
1672
+ }, 150);
1673
+ document.addEventListener("scroll", handleScroll);
1674
+ return () => {
1675
+ document.removeEventListener("scroll", handleScroll);
1676
+ if (scrollTimeoutRef.current) {
1677
+ clearTimeout(scrollTimeoutRef.current);
1678
+ scrollTimeoutRef.current = null;
1679
+ }
1680
+ };
1681
+ };
1682
+ t9 = [replaceHashSilently];
1683
+ $[11] = t8;
1684
+ $[12] = t9;
1685
+ } else {
1686
+ t8 = $[11];
1687
+ t9 = $[12];
1688
+ }
1689
+ useEffect(t8, t9);
1690
+ let t10;
1691
+ let t11;
1692
+ if ($[13] !== location.hash || $[14] !== location.pathname) {
1693
+ t10 = () => {
1694
+ const handleClick = (event) => {
1695
+ const target = event.target;
1696
+ const link = target?.closest("a");
1697
+ const currentHash = typeof window !== "undefined" ? window.location.hash : location.hash || "";
1698
+ if (!link || !link.hash || link.pathname !== location.pathname || link.hash !== currentHash) {
1699
+ return;
1700
+ }
1701
+ const id_1 = link.hash.substring(1);
1702
+ const element_1 = document.getElementById(id_1);
1703
+ if (element_1) {
1704
+ event.preventDefault();
1705
+ event.stopPropagation();
1706
+ markProgrammaticScroll();
1707
+ element_1.scrollIntoView({
1708
+ behavior: "smooth"
1709
+ });
1710
+ }
1711
+ };
1712
+ document.addEventListener("click", handleClick, true);
1713
+ return () => document.removeEventListener("click", handleClick, true);
1714
+ };
1715
+ t11 = [location.hash, location.pathname, markProgrammaticScroll];
1716
+ $[13] = location.hash;
1717
+ $[14] = location.pathname;
1718
+ $[15] = t10;
1719
+ $[16] = t11;
1720
+ } else {
1721
+ t10 = $[15];
1722
+ t11 = $[16];
1723
+ }
1724
+ useEffect(t10, t11);
1406
1725
  }
1407
- const RootProvider = ({ children }) => {
1726
+ const RootProvider = (t0) => {
1727
+ const $ = c(2);
1728
+ const {
1729
+ children
1730
+ } = t0;
1408
1731
  useApplyScroll();
1409
- return /* @__PURE__ */ jsx(Fragment, { children });
1732
+ let t1;
1733
+ if ($[0] !== children) {
1734
+ t1 = /* @__PURE__ */ jsx(Fragment, { children });
1735
+ $[0] = children;
1736
+ $[1] = t1;
1737
+ } else {
1738
+ t1 = $[1];
1739
+ }
1740
+ return t1;
1410
1741
  };
1411
1742
  var isObject_1;
1412
1743
  var hasRequiredIsObject;
@@ -2030,57 +2361,152 @@ function createCustomEqual(options = {}) {
2030
2361
  const equals = createCustomInternalComparator ? createCustomInternalComparator(comparator) : createInternalEqualityComparator(comparator);
2031
2362
  return createIsEqual({ circular, comparator, createState, equals, strict });
2032
2363
  }
2033
- const defaultRect = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
2364
+ const defaultRect = {
2365
+ x: 0,
2366
+ y: 0,
2367
+ width: 0,
2368
+ height: 0,
2369
+ top: 0,
2370
+ left: 0,
2371
+ bottom: 0,
2372
+ right: 0
2373
+ };
2034
2374
  const useLocalMeasure = () => {
2375
+ const $ = c(6);
2035
2376
  const [node, setNode] = useState(null);
2036
- const ref = useCallback((el) => setNode(el), []);
2377
+ let t0;
2378
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2379
+ t0 = (el) => setNode(el);
2380
+ $[0] = t0;
2381
+ } else {
2382
+ t0 = $[0];
2383
+ }
2384
+ const ref = t0;
2037
2385
  const [rect, setRect] = useState(defaultRect);
2038
- useLayoutEffect(() => {
2039
- if (typeof window === "undefined" || typeof ResizeObserver === "undefined") return;
2040
- if (!node) return;
2041
- const observer = new ResizeObserver((entries) => {
2042
- const entry = entries[0];
2043
- if (!entry?.contentRect) return;
2044
- const { x, y, width, height, top, left, bottom, right } = entry.contentRect;
2045
- setRect({ x, y, width, height, top, left, bottom, right });
2046
- });
2047
- observer.observe(node);
2048
- return () => observer.disconnect();
2049
- }, [node]);
2050
- return [ref, rect];
2386
+ let t1;
2387
+ let t2;
2388
+ if ($[1] !== node) {
2389
+ t1 = () => {
2390
+ if (typeof window === "undefined" || typeof ResizeObserver === "undefined") {
2391
+ return;
2392
+ }
2393
+ if (!node) {
2394
+ return;
2395
+ }
2396
+ const observer = new ResizeObserver((entries) => {
2397
+ const entry = entries[0];
2398
+ if (!entry?.contentRect) {
2399
+ return;
2400
+ }
2401
+ const {
2402
+ x,
2403
+ y,
2404
+ width,
2405
+ height,
2406
+ top,
2407
+ left,
2408
+ bottom,
2409
+ right
2410
+ } = entry.contentRect;
2411
+ setRect({
2412
+ x,
2413
+ y,
2414
+ width,
2415
+ height,
2416
+ top,
2417
+ left,
2418
+ bottom,
2419
+ right
2420
+ });
2421
+ });
2422
+ observer.observe(node);
2423
+ return () => observer.disconnect();
2424
+ };
2425
+ t2 = [node];
2426
+ $[1] = node;
2427
+ $[2] = t1;
2428
+ $[3] = t2;
2429
+ } else {
2430
+ t1 = $[2];
2431
+ t2 = $[3];
2432
+ }
2433
+ useLayoutEffect(t1, t2);
2434
+ let t3;
2435
+ if ($[4] !== rect) {
2436
+ t3 = [ref, rect];
2437
+ $[4] = rect;
2438
+ $[5] = t3;
2439
+ } else {
2440
+ t3 = $[5];
2441
+ }
2442
+ return t3;
2051
2443
  };
2052
2444
  const DEFAULT_THROTTLE_TIME = 16;
2053
- const useThrottledMeasure = (throttleDuration = DEFAULT_THROTTLE_TIME) => {
2445
+ const useThrottledMeasure = (t0) => {
2446
+ const $ = c(10);
2447
+ const throttleDuration = t0 === void 0 ? DEFAULT_THROTTLE_TIME : t0;
2054
2448
  const hasInitialMeasure = useRef(false);
2055
2449
  const [ref, measuredRect] = useLocalMeasure();
2056
- const [rect, setRect] = useState(() => defaultRect);
2057
- const throttledSetRect = useMemo(
2058
- () => _throttle(
2059
- (newRect) => {
2060
- setRect((current) => {
2061
- return deepEqual(current, newRect) ? current : newRect;
2062
- });
2063
- },
2064
- throttleDuration,
2065
- { leading: true, trailing: true }
2066
- ),
2067
- [throttleDuration]
2068
- );
2069
- useEffect(() => {
2070
- if (measuredRect.width > 0 && !hasInitialMeasure.current) {
2071
- hasInitialMeasure.current = true;
2072
- setRect((current) => {
2073
- return deepEqual(current, measuredRect) ? current : measuredRect;
2074
- });
2075
- return;
2076
- }
2077
- throttledSetRect(measuredRect);
2078
- return () => {
2079
- throttledSetRect.cancel();
2450
+ const [rect, setRect] = useState(_temp$1);
2451
+ let t1;
2452
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2453
+ t1 = (newRect) => {
2454
+ setRect((current) => deepEqual(current, newRect) ? current : newRect);
2455
+ };
2456
+ $[0] = t1;
2457
+ } else {
2458
+ t1 = $[0];
2459
+ }
2460
+ let t2;
2461
+ if ($[1] !== throttleDuration) {
2462
+ t2 = _throttle(t1, throttleDuration, {
2463
+ leading: true,
2464
+ trailing: true
2465
+ });
2466
+ $[1] = throttleDuration;
2467
+ $[2] = t2;
2468
+ } else {
2469
+ t2 = $[2];
2470
+ }
2471
+ const throttledSetRect = t2;
2472
+ let t3;
2473
+ let t4;
2474
+ if ($[3] !== measuredRect || $[4] !== throttledSetRect) {
2475
+ t3 = () => {
2476
+ if (measuredRect.width > 0 && !hasInitialMeasure.current) {
2477
+ hasInitialMeasure.current = true;
2478
+ setRect((current_0) => deepEqual(current_0, measuredRect) ? current_0 : measuredRect);
2479
+ return;
2480
+ }
2481
+ throttledSetRect(measuredRect);
2482
+ return () => {
2483
+ throttledSetRect.cancel();
2484
+ };
2080
2485
  };
2081
- }, [measuredRect, throttledSetRect]);
2082
- return [ref, rect];
2486
+ t4 = [measuredRect, throttledSetRect];
2487
+ $[3] = measuredRect;
2488
+ $[4] = throttledSetRect;
2489
+ $[5] = t3;
2490
+ $[6] = t4;
2491
+ } else {
2492
+ t3 = $[5];
2493
+ t4 = $[6];
2494
+ }
2495
+ useEffect(t3, t4);
2496
+ let t5;
2497
+ if ($[7] !== rect || $[8] !== ref) {
2498
+ t5 = [ref, rect];
2499
+ $[7] = rect;
2500
+ $[8] = ref;
2501
+ $[9] = t5;
2502
+ } else {
2503
+ t5 = $[9];
2504
+ }
2505
+ return t5;
2083
2506
  };
2507
+ function _temp$1() {
2508
+ return defaultRect;
2509
+ }
2084
2510
  const defaultState = {
2085
2511
  statusCode: 500,
2086
2512
  title: "Something went wrong",
@@ -2122,16 +2548,31 @@ const toSsrErrorState = (error) => {
2122
2548
  }
2123
2549
  return defaultState;
2124
2550
  };
2125
- const RouteErrorBoundary = ({ renderErrorExtra }) => {
2551
+ const RouteErrorBoundary = (t0) => {
2552
+ const $ = c(5);
2553
+ const {
2554
+ renderErrorExtra
2555
+ } = t0;
2126
2556
  const routeError = useRouteError();
2127
- const state = toSsrErrorState(routeError);
2128
- return /* @__PURE__ */ jsx(
2129
- SsrErrorFallback,
2130
- {
2131
- state,
2132
- renderErrorExtra
2133
- }
2134
- );
2557
+ let t1;
2558
+ if ($[0] !== routeError) {
2559
+ t1 = toSsrErrorState(routeError);
2560
+ $[0] = routeError;
2561
+ $[1] = t1;
2562
+ } else {
2563
+ t1 = $[1];
2564
+ }
2565
+ const state = t1;
2566
+ let t2;
2567
+ if ($[2] !== renderErrorExtra || $[3] !== state) {
2568
+ t2 = /* @__PURE__ */ jsx(SsrErrorFallback, { state, renderErrorExtra });
2569
+ $[2] = renderErrorExtra;
2570
+ $[3] = state;
2571
+ $[4] = t2;
2572
+ } else {
2573
+ t2 = $[4];
2574
+ }
2575
+ return t2;
2135
2576
  };
2136
2577
  const listNotifications = async (input = {}) => {
2137
2578
  const result = await apiClient.post("/api/rb/notifications", input);
@@ -2147,10 +2588,7 @@ const listNotifications = async (input = {}) => {
2147
2588
  const markNotificationRead = async (notificationId) => {
2148
2589
  const id = notificationId.trim();
2149
2590
  if (!id) throw new Error("notificationId is required");
2150
- const result = await apiClient.post(
2151
- `/api/rb/notifications/${encodeURIComponent(id)}/read`,
2152
- {}
2153
- );
2591
+ const result = await apiClient.post(`/api/rb/notifications/${encodeURIComponent(id)}/read`, {});
2154
2592
  if (!result?.ok) {
2155
2593
  throw new Error(result?.error || "Failed to mark notification read");
2156
2594
  }
@@ -2158,10 +2596,7 @@ const markNotificationRead = async (notificationId) => {
2158
2596
  const archiveNotification = async (notificationId) => {
2159
2597
  const id = notificationId.trim();
2160
2598
  if (!id) throw new Error("notificationId is required");
2161
- const result = await apiClient.post(
2162
- `/api/rb/notifications/${encodeURIComponent(id)}/archive`,
2163
- {}
2164
- );
2599
+ const result = await apiClient.post(`/api/rb/notifications/${encodeURIComponent(id)}/archive`, {});
2165
2600
  if (!result?.ok) {
2166
2601
  throw new Error(result?.error || "Failed to archive notification");
2167
2602
  }
@@ -2177,24 +2612,34 @@ const getNotificationSettings = async () => {
2177
2612
  if (!result?.ok) {
2178
2613
  throw new Error(result?.error || "Failed to load notification settings");
2179
2614
  }
2180
- return result.settings ?? { digestFrequency: "weekly", topicPreferences: [] };
2615
+ return result.settings ?? {
2616
+ digestFrequency: "weekly",
2617
+ topicPreferences: []
2618
+ };
2181
2619
  };
2182
2620
  const updateNotificationSettings = async (partial) => {
2183
2621
  const result = await apiClient.put("/api/rb/notifications/settings", partial);
2184
2622
  if (!result?.ok) {
2185
2623
  throw new Error(result?.error || "Failed to update notification settings");
2186
2624
  }
2187
- return result.settings ?? { digestFrequency: "weekly", topicPreferences: [] };
2625
+ return result.settings ?? {
2626
+ digestFrequency: "weekly",
2627
+ topicPreferences: []
2628
+ };
2188
2629
  };
2189
- const runNotificationDigest = async ({ force = false } = {}) => {
2190
- const result = await apiClient.post(
2191
- "/api/rb/notifications/digest/run",
2192
- { force }
2193
- );
2630
+ const runNotificationDigest = async ({
2631
+ force = false
2632
+ } = {}) => {
2633
+ const result = await apiClient.post("/api/rb/notifications/digest/run", {
2634
+ force
2635
+ });
2194
2636
  if (!result?.ok) {
2195
2637
  throw new Error(result?.error || "Failed to run digest");
2196
2638
  }
2197
- return { sent: result.sent === true, skippedReason: result.skippedReason };
2639
+ return {
2640
+ sent: result.sent === true,
2641
+ skippedReason: result.skippedReason
2642
+ };
2198
2643
  };
2199
2644
  const NotificationsRealtimeContext = createContext(null);
2200
2645
  const toIso = (value) => {
@@ -2228,95 +2673,322 @@ const buildDisabledTopics = (settings) => {
2228
2673
  return pref.inApp === false ? topic : null;
2229
2674
  }).filter((topic) => Boolean(topic));
2230
2675
  };
2231
- function NotificationsRealtimeProvider({
2232
- userId,
2233
- limit = 200,
2234
- toastOnNew = true,
2235
- children
2236
- }) {
2237
- const trimmedUserId = typeof userId === "string" ? userId.trim() : "";
2676
+ function NotificationsRealtimeProvider(t0) {
2677
+ const $ = c(47);
2678
+ const {
2679
+ userId,
2680
+ limit: t1,
2681
+ toastOnNew: t2,
2682
+ children
2683
+ } = t0;
2684
+ const limit = t1 === void 0 ? 200 : t1;
2685
+ const toastOnNew = t2 === void 0 ? true : t2;
2686
+ let t3;
2687
+ if ($[0] !== userId) {
2688
+ t3 = typeof userId === "string" ? userId.trim() : "";
2689
+ $[0] = userId;
2690
+ $[1] = t3;
2691
+ } else {
2692
+ t3 = $[1];
2693
+ }
2694
+ const trimmedUserId = t3;
2238
2695
  const canUseRts = Boolean(trimmedUserId);
2239
- const settingsQuery = useQuery(
2240
- "RBNotificationSettings",
2241
- useMemo(() => canUseRts ? { userId: trimmedUserId } : {}, [canUseRts, trimmedUserId]),
2242
- useMemo(() => ({ key: "rb.notifications.settings", limit: 1, enabled: canUseRts }), [canUseRts])
2243
- );
2696
+ let t4;
2697
+ if ($[2] !== canUseRts || $[3] !== trimmedUserId) {
2698
+ t4 = canUseRts ? {
2699
+ userId: trimmedUserId
2700
+ } : {};
2701
+ $[2] = canUseRts;
2702
+ $[3] = trimmedUserId;
2703
+ $[4] = t4;
2704
+ } else {
2705
+ t4 = $[4];
2706
+ }
2707
+ let t5;
2708
+ if ($[5] !== canUseRts) {
2709
+ t5 = {
2710
+ key: "rb.notifications.settings",
2711
+ limit: 1,
2712
+ enabled: canUseRts
2713
+ };
2714
+ $[5] = canUseRts;
2715
+ $[6] = t5;
2716
+ } else {
2717
+ t5 = $[6];
2718
+ }
2719
+ const settingsQuery = useQuery("RBNotificationSettings", t4, t5);
2244
2720
  const settings = settingsQuery.data?.[0] ?? null;
2245
- const disabledTopics = useMemo(() => buildDisabledTopics(settings), [settings]);
2246
- const query = useMemo(() => {
2247
- if (!canUseRts) return {};
2248
- const base = {
2249
- userId: trimmedUserId,
2250
- archivedAt: { $exists: false }
2721
+ let t6;
2722
+ if ($[7] !== settings) {
2723
+ t6 = buildDisabledTopics(settings);
2724
+ $[7] = settings;
2725
+ $[8] = t6;
2726
+ } else {
2727
+ t6 = $[8];
2728
+ }
2729
+ const disabledTopics = t6;
2730
+ let t7;
2731
+ bb0: {
2732
+ if (!canUseRts) {
2733
+ let t83;
2734
+ if ($[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2735
+ t83 = {};
2736
+ $[9] = t83;
2737
+ } else {
2738
+ t83 = $[9];
2739
+ }
2740
+ t7 = t83;
2741
+ break bb0;
2742
+ }
2743
+ let t82;
2744
+ if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2745
+ t82 = {
2746
+ $exists: false
2747
+ };
2748
+ $[10] = t82;
2749
+ } else {
2750
+ t82 = $[10];
2751
+ }
2752
+ let base;
2753
+ if ($[11] !== disabledTopics || $[12] !== trimmedUserId) {
2754
+ base = {
2755
+ userId: trimmedUserId,
2756
+ archivedAt: t82
2757
+ };
2758
+ if (disabledTopics.length > 0) {
2759
+ let t92;
2760
+ if ($[14] !== disabledTopics) {
2761
+ t92 = {
2762
+ $nin: disabledTopics
2763
+ };
2764
+ $[14] = disabledTopics;
2765
+ $[15] = t92;
2766
+ } else {
2767
+ t92 = $[15];
2768
+ }
2769
+ base.topic = t92;
2770
+ }
2771
+ $[11] = disabledTopics;
2772
+ $[12] = trimmedUserId;
2773
+ $[13] = base;
2774
+ } else {
2775
+ base = $[13];
2776
+ }
2777
+ t7 = base;
2778
+ }
2779
+ const query = t7;
2780
+ let t8;
2781
+ if ($[16] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2782
+ t8 = {
2783
+ createdAt: -1
2251
2784
  };
2252
- if (disabledTopics.length > 0) {
2253
- base.topic = { $nin: disabledTopics };
2254
- }
2255
- return base;
2256
- }, [canUseRts, disabledTopics, trimmedUserId]);
2257
- const notificationsQuery = useQuery(
2258
- "RBNotification",
2259
- query,
2260
- useMemo(() => ({
2785
+ $[16] = t8;
2786
+ } else {
2787
+ t8 = $[16];
2788
+ }
2789
+ let t9;
2790
+ if ($[17] !== canUseRts || $[18] !== limit) {
2791
+ t9 = {
2261
2792
  key: "rb.notifications",
2262
- sort: { createdAt: -1 },
2793
+ sort: t8,
2263
2794
  limit,
2264
2795
  enabled: canUseRts
2265
- }), [canUseRts, limit])
2266
- );
2267
- const notifications = useMemo(() => {
2796
+ };
2797
+ $[17] = canUseRts;
2798
+ $[18] = limit;
2799
+ $[19] = t9;
2800
+ } else {
2801
+ t9 = $[19];
2802
+ }
2803
+ const notificationsQuery = useQuery("RBNotification", query, t9);
2804
+ let t10;
2805
+ bb1: {
2268
2806
  const raw = notificationsQuery.data;
2269
- if (!Array.isArray(raw)) return [];
2270
- return raw.map((doc) => toNotificationItem(doc)).filter((n) => Boolean(n));
2271
- }, [notificationsQuery.data]);
2272
- const unreadCount = useMemo(() => notifications.reduce((acc, n) => acc + (n.readAt ? 0 : 1), 0), [notifications]);
2273
- const unseenCount = useMemo(() => notifications.reduce((acc, n) => acc + (n.seenAt ? 0 : 1), 0), [notifications]);
2274
- const lastToastIds = useRef(/* @__PURE__ */ new Set());
2275
- const hasSeededToastIds = useRef(false);
2276
- const toastStartMs = useRef(Date.now());
2277
- useEffect(() => {
2278
- hasSeededToastIds.current = false;
2279
- lastToastIds.current = /* @__PURE__ */ new Set();
2280
- toastStartMs.current = Date.now();
2281
- }, [trimmedUserId]);
2282
- useEffect(() => {
2283
- if (!toastOnNew) return;
2284
- if (!canUseRts) return;
2285
- if (notificationsQuery.loading) return;
2286
- if (!hasSeededToastIds.current) {
2287
- hasSeededToastIds.current = true;
2288
- lastToastIds.current = new Set(notifications.map((n) => n.id));
2289
- return;
2290
- }
2291
- const nextNew = notifications.filter((n) => !lastToastIds.current.has(n.id));
2292
- if (!nextNew.length) return;
2293
- for (const n of nextNew) {
2294
- lastToastIds.current.add(n.id);
2295
- }
2296
- const isTabActive = typeof document !== "undefined" && document.visibilityState === "visible";
2297
- if (!isTabActive) return;
2298
- const eligible = nextNew.filter((n) => {
2299
- const createdAtMs = Date.parse(n.createdAt);
2300
- if (!Number.isFinite(createdAtMs)) return true;
2301
- return createdAtMs >= toastStartMs.current;
2302
- });
2303
- if (!eligible.length) return;
2304
- if (eligible.length > 3) {
2305
- toast(`${eligible.length} new notifications`, { description: "Open the notifications drawer to view them." });
2306
- return;
2807
+ if (!Array.isArray(raw)) {
2808
+ let t113;
2809
+ if ($[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2810
+ t113 = [];
2811
+ $[20] = t113;
2812
+ } else {
2813
+ t113 = $[20];
2814
+ }
2815
+ t10 = t113;
2816
+ break bb1;
2817
+ }
2818
+ let t112;
2819
+ if ($[21] !== raw) {
2820
+ t112 = raw.map(_temp).filter(_temp2);
2821
+ $[21] = raw;
2822
+ $[22] = t112;
2823
+ } else {
2824
+ t112 = $[22];
2307
2825
  }
2308
- for (const n of eligible) {
2309
- toast(n.title || "New notification", { description: n.body });
2310
- }
2311
- }, [canUseRts, notifications, notificationsQuery.loading, toastOnNew]);
2312
- const value = useMemo(() => ({
2313
- notifications,
2314
- unreadCount,
2315
- unseenCount,
2316
- loading: notificationsQuery.loading,
2317
- error: notificationsQuery.error
2318
- }), [notifications, notificationsQuery.error, notificationsQuery.loading, unreadCount, unseenCount]);
2319
- return /* @__PURE__ */ jsx(NotificationsRealtimeContext.Provider, { value: canUseRts ? value : null, children });
2826
+ t10 = t112;
2827
+ }
2828
+ const notifications = t10;
2829
+ let t11;
2830
+ if ($[23] !== notifications) {
2831
+ t11 = notifications.reduce(_temp3, 0);
2832
+ $[23] = notifications;
2833
+ $[24] = t11;
2834
+ } else {
2835
+ t11 = $[24];
2836
+ }
2837
+ const unreadCount = t11;
2838
+ let t12;
2839
+ if ($[25] !== notifications) {
2840
+ t12 = notifications.reduce(_temp4, 0);
2841
+ $[25] = notifications;
2842
+ $[26] = t12;
2843
+ } else {
2844
+ t12 = $[26];
2845
+ }
2846
+ const unseenCount = t12;
2847
+ let t13;
2848
+ if ($[27] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2849
+ t13 = /* @__PURE__ */ new Set();
2850
+ $[27] = t13;
2851
+ } else {
2852
+ t13 = $[27];
2853
+ }
2854
+ const lastToastIds = useRef(t13);
2855
+ const hasSeededToastIds = useRef(false);
2856
+ let t14;
2857
+ if ($[28] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2858
+ t14 = Date.now();
2859
+ $[28] = t14;
2860
+ } else {
2861
+ t14 = $[28];
2862
+ }
2863
+ const toastStartMs = useRef(t14);
2864
+ let t15;
2865
+ if ($[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2866
+ t15 = () => {
2867
+ hasSeededToastIds.current = false;
2868
+ lastToastIds.current = /* @__PURE__ */ new Set();
2869
+ toastStartMs.current = Date.now();
2870
+ };
2871
+ $[29] = t15;
2872
+ } else {
2873
+ t15 = $[29];
2874
+ }
2875
+ let t16;
2876
+ if ($[30] !== trimmedUserId) {
2877
+ t16 = [trimmedUserId];
2878
+ $[30] = trimmedUserId;
2879
+ $[31] = t16;
2880
+ } else {
2881
+ t16 = $[31];
2882
+ }
2883
+ useEffect(t15, t16);
2884
+ let t17;
2885
+ let t18;
2886
+ if ($[32] !== canUseRts || $[33] !== notifications || $[34] !== notificationsQuery.loading || $[35] !== toastOnNew) {
2887
+ t17 = () => {
2888
+ if (!toastOnNew) {
2889
+ return;
2890
+ }
2891
+ if (!canUseRts) {
2892
+ return;
2893
+ }
2894
+ if (notificationsQuery.loading) {
2895
+ return;
2896
+ }
2897
+ if (!hasSeededToastIds.current) {
2898
+ hasSeededToastIds.current = true;
2899
+ lastToastIds.current = new Set(notifications.map(_temp5));
2900
+ return;
2901
+ }
2902
+ const nextNew = notifications.filter((n_3) => !lastToastIds.current.has(n_3.id));
2903
+ if (!nextNew.length) {
2904
+ return;
2905
+ }
2906
+ for (const n_4 of nextNew) {
2907
+ lastToastIds.current.add(n_4.id);
2908
+ }
2909
+ const isTabActive = typeof document !== "undefined" && document.visibilityState === "visible";
2910
+ if (!isTabActive) {
2911
+ return;
2912
+ }
2913
+ const eligible = nextNew.filter((n_5) => {
2914
+ const createdAtMs = Date.parse(n_5.createdAt);
2915
+ if (!Number.isFinite(createdAtMs)) {
2916
+ return true;
2917
+ }
2918
+ return createdAtMs >= toastStartMs.current;
2919
+ });
2920
+ if (!eligible.length) {
2921
+ return;
2922
+ }
2923
+ if (eligible.length > 3) {
2924
+ toast(`${eligible.length} new notifications`, {
2925
+ description: "Open the notifications drawer to view them."
2926
+ });
2927
+ return;
2928
+ }
2929
+ for (const n_6 of eligible) {
2930
+ toast(n_6.title || "New notification", {
2931
+ description: n_6.body
2932
+ });
2933
+ }
2934
+ };
2935
+ t18 = [canUseRts, notifications, notificationsQuery.loading, toastOnNew];
2936
+ $[32] = canUseRts;
2937
+ $[33] = notifications;
2938
+ $[34] = notificationsQuery.loading;
2939
+ $[35] = toastOnNew;
2940
+ $[36] = t17;
2941
+ $[37] = t18;
2942
+ } else {
2943
+ t17 = $[36];
2944
+ t18 = $[37];
2945
+ }
2946
+ useEffect(t17, t18);
2947
+ let t19;
2948
+ if ($[38] !== notifications || $[39] !== notificationsQuery.error || $[40] !== notificationsQuery.loading || $[41] !== unreadCount || $[42] !== unseenCount) {
2949
+ t19 = {
2950
+ notifications,
2951
+ unreadCount,
2952
+ unseenCount,
2953
+ loading: notificationsQuery.loading,
2954
+ error: notificationsQuery.error
2955
+ };
2956
+ $[38] = notifications;
2957
+ $[39] = notificationsQuery.error;
2958
+ $[40] = notificationsQuery.loading;
2959
+ $[41] = unreadCount;
2960
+ $[42] = unseenCount;
2961
+ $[43] = t19;
2962
+ } else {
2963
+ t19 = $[43];
2964
+ }
2965
+ const value = t19;
2966
+ const t20 = canUseRts ? value : null;
2967
+ let t21;
2968
+ if ($[44] !== children || $[45] !== t20) {
2969
+ t21 = /* @__PURE__ */ jsx(NotificationsRealtimeContext.Provider, { value: t20, children });
2970
+ $[44] = children;
2971
+ $[45] = t20;
2972
+ $[46] = t21;
2973
+ } else {
2974
+ t21 = $[46];
2975
+ }
2976
+ return t21;
2977
+ }
2978
+ function _temp5(n_2) {
2979
+ return n_2.id;
2980
+ }
2981
+ function _temp4(acc_0, n_1) {
2982
+ return acc_0 + (n_1.seenAt ? 0 : 1);
2983
+ }
2984
+ function _temp3(acc, n_0) {
2985
+ return acc + (n_0.readAt ? 0 : 1);
2986
+ }
2987
+ function _temp2(n) {
2988
+ return Boolean(n);
2989
+ }
2990
+ function _temp(doc) {
2991
+ return toNotificationItem(doc);
2320
2992
  }
2321
2993
  const useNotificationsRealtime = () => {
2322
2994
  return useContext(NotificationsRealtimeContext);