@rpcbase/client 0.405.0 → 0.407.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,2672 +1,2436 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
1
+ import { i as require_toString, m as __toESM, p as __commonJSMin, t as require_throttle } from "./throttle-Cz-gYuKD.js";
2
+ import { n as setClientExceptionReporter, t as reportClientException } from "./errorReporting-Dfcrn3W1.js";
3
+ import { C as peekHydratedRtsQueryData, S as hydrateRtsFromWindow, T as peekHydratedRtsQueryTotalCount, b as STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY, t as useQuery, w as peekHydratedRtsQueryPageInfo, x as clearHydratedRtsQueryData, y as RtsSsrRuntimeProvider } from "./rts-C9dMrcRZ.js";
2
4
  import { c } from "react/compiler-runtime";
3
- import { useSyncExternalStore, lazy, useEffect, Suspense, StrictMode, useState, useRef, useLayoutEffect, createContext, useContext } from "react";
5
+ import { StrictMode, Suspense, createContext, lazy, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
7
  import env from "@rpcbase/env";
5
- import { getNavigationGuards, createRoutesFromElements, createBrowserRouter, RouterProvider, matchRoutes, useLocation, RoutePrefetchProvider, useRouteError, isRouteErrorResponse } from "@rpcbase/router";
8
+ import { RoutePrefetchProvider, RouterProvider, createBrowserRouter, createRoutesFromElements, getNavigationGuards, isRouteErrorResponse, matchRoutes, useLocation, useRouteError } from "@rpcbase/router";
6
9
  import { hydrateRoot } from "react-dom/client";
7
- import { r as reportClientException } from "./errorReporting-CVoUUKxW.js";
8
- import { s } from "./errorReporting-CVoUUKxW.js";
9
- import { n as hydrateRtsFromWindow, w as useQuery } from "./useQuery-XvXbEwG_.js";
10
- import { R, S, p, q, t, v } from "./useQuery-XvXbEwG_.js";
11
- import { r as requireToString, g as getDefaultExportFromCjs, t as throttle$1 } from "./throttle-CXOc9Dto.js";
12
- const emptyUnsubscribe = () => {
13
- };
14
- const useMediaQuery = (query) => {
15
- const $ = c(4);
16
- const isServer = typeof window === "undefined";
17
- let t0;
18
- if ($[0] !== query) {
19
- t0 = (callback) => {
20
- if (isServer) {
21
- return emptyUnsubscribe;
22
- }
23
- const mql = window.matchMedia(query);
24
- if (mql.addEventListener) {
25
- mql.addEventListener("change", callback);
26
- return () => mql.removeEventListener("change", callback);
27
- }
28
- mql.addListener(callback);
29
- return () => mql.removeListener(callback);
30
- };
31
- $[0] = query;
32
- $[1] = t0;
33
- } else {
34
- t0 = $[1];
35
- }
36
- const subscribe = t0;
37
- let t1;
38
- if ($[2] !== query) {
39
- t1 = () => {
40
- if (isServer) {
41
- return false;
42
- }
43
- return window.matchMedia(query).matches;
44
- };
45
- $[2] = query;
46
- $[3] = t1;
47
- } else {
48
- t1 = $[3];
49
- }
50
- const getSnapshot = t1;
51
- return useSyncExternalStore(subscribe, getSnapshot, _temp$3);
10
+ //#region src/hooks/useMediaQuery.ts
11
+ var emptyUnsubscribe = () => {};
12
+ var useMediaQuery = (query) => {
13
+ const $ = c(4);
14
+ const isServer = typeof window === "undefined";
15
+ let t0;
16
+ if ($[0] !== query) {
17
+ t0 = (callback) => {
18
+ if (isServer) return emptyUnsubscribe;
19
+ const mql = window.matchMedia(query);
20
+ if (mql.addEventListener) {
21
+ mql.addEventListener("change", callback);
22
+ return () => mql.removeEventListener("change", callback);
23
+ }
24
+ mql.addListener(callback);
25
+ return () => mql.removeListener(callback);
26
+ };
27
+ $[0] = query;
28
+ $[1] = t0;
29
+ } else t0 = $[1];
30
+ const subscribe = t0;
31
+ let t1;
32
+ if ($[2] !== query) {
33
+ t1 = () => {
34
+ if (isServer) return false;
35
+ return window.matchMedia(query).matches;
36
+ };
37
+ $[2] = query;
38
+ $[3] = t1;
39
+ } else t1 = $[3];
40
+ return useSyncExternalStore(subscribe, t1, _temp$3);
52
41
  };
53
42
  function _temp$3() {
54
- return false;
43
+ return false;
55
44
  }
56
- let sonner = null;
57
- let sonnerImport = null;
58
- const queued = [];
59
- let toasterRequested = false;
60
- const toasterListeners = /* @__PURE__ */ new Set();
61
- let toasterMounted = false;
62
- let toasterPreloadStarted = false;
63
- let idCounter = 0;
64
- const createToastId = () => `rb-toast-${++idCounter}`;
65
- const resolveId = (id) => {
66
- if (typeof id === "number") return id;
67
- if (typeof id === "string" && id.length > 0) return id;
68
- return void 0;
69
- };
70
- const requestToasterMount = () => {
71
- if (toasterRequested) return;
72
- toasterRequested = true;
73
- for (const listener of toasterListeners) {
74
- listener();
75
- }
76
- };
77
- const subscribeToasterRequested = (listener) => {
78
- toasterListeners.add(listener);
79
- return () => {
80
- toasterListeners.delete(listener);
81
- };
82
- };
83
- const getToasterRequested = () => toasterRequested;
84
- const flushQueue = () => {
85
- if (!sonner) return;
86
- if (typeof document !== "undefined" && !toasterMounted) return;
87
- while (queued.length) {
88
- const fn = queued.shift();
89
- if (fn) fn(sonner);
90
- }
91
- };
92
- const setToasterMounted = (mounted) => {
93
- toasterMounted = mounted;
94
- if (mounted) flushQueue();
95
- };
96
- const loadSonner = () => {
97
- if (sonner) return Promise.resolve(sonner);
98
- if (sonnerImport) return sonnerImport;
99
- sonnerImport = import("sonner").then((mod) => {
100
- sonner = mod;
101
- flushQueue();
102
- return mod;
103
- });
104
- return sonnerImport;
105
- };
106
- const enqueue = (fn) => {
107
- if (sonner && (toasterMounted || typeof document === "undefined")) {
108
- fn(sonner);
109
- return;
110
- }
111
- queued.push(fn);
112
- };
113
- const isPageLoaded = () => {
114
- if (typeof document === "undefined") return false;
115
- return document.readyState === "complete";
116
- };
117
- const startToaster = () => {
118
- if (toasterPreloadStarted) return;
119
- toasterPreloadStarted = true;
120
- requestToasterMount();
121
- void loadSonner();
122
- };
123
- const ensureReady = () => {
124
- if (typeof document === "undefined") startToaster();
125
- };
126
- const buildToastData = (data, id) => data ? {
127
- ...data,
128
- id
129
- } : {
130
- id
131
- };
132
- const toastFn = ((message, data) => {
133
- ensureReady();
134
- const id = resolveId(data?.id) ?? createToastId();
135
- const nextData = buildToastData(data, id);
136
- enqueue((m) => {
137
- m.toast(message, nextData);
138
- });
139
- return id;
45
+ //#endregion
46
+ //#region src/toast.tsx
47
+ var sonner = null;
48
+ var sonnerImport = null;
49
+ var queued = [];
50
+ var toasterRequested = false;
51
+ var toasterListeners = /* @__PURE__ */ new Set();
52
+ var toasterMounted = false;
53
+ var toasterPreloadStarted = false;
54
+ var idCounter = 0;
55
+ var createToastId = () => `rb-toast-${++idCounter}`;
56
+ var resolveId = (id) => {
57
+ if (typeof id === "number") return id;
58
+ if (typeof id === "string" && id.length > 0) return id;
59
+ };
60
+ var requestToasterMount = () => {
61
+ if (toasterRequested) return;
62
+ toasterRequested = true;
63
+ for (const listener of toasterListeners) listener();
64
+ };
65
+ var subscribeToasterRequested = (listener) => {
66
+ toasterListeners.add(listener);
67
+ return () => {
68
+ toasterListeners.delete(listener);
69
+ };
70
+ };
71
+ var getToasterRequested = () => toasterRequested;
72
+ var flushQueue = () => {
73
+ if (!sonner) return;
74
+ if (typeof document !== "undefined" && !toasterMounted) return;
75
+ while (queued.length) {
76
+ const fn = queued.shift();
77
+ if (fn) fn(sonner);
78
+ }
79
+ };
80
+ var setToasterMounted = (mounted) => {
81
+ toasterMounted = mounted;
82
+ if (mounted) flushQueue();
83
+ };
84
+ var loadSonner = () => {
85
+ if (sonner) return Promise.resolve(sonner);
86
+ if (sonnerImport) return sonnerImport;
87
+ sonnerImport = import("sonner").then((mod) => {
88
+ sonner = mod;
89
+ flushQueue();
90
+ return mod;
91
+ });
92
+ return sonnerImport;
93
+ };
94
+ var enqueue = (fn) => {
95
+ if (sonner && (toasterMounted || typeof document === "undefined")) {
96
+ fn(sonner);
97
+ return;
98
+ }
99
+ queued.push(fn);
100
+ };
101
+ var isPageLoaded = () => {
102
+ if (typeof document === "undefined") return false;
103
+ return document.readyState === "complete";
104
+ };
105
+ var startToaster = () => {
106
+ if (toasterPreloadStarted) return;
107
+ toasterPreloadStarted = true;
108
+ requestToasterMount();
109
+ loadSonner();
110
+ };
111
+ var ensureReady = () => {
112
+ if (typeof document === "undefined") startToaster();
113
+ };
114
+ var buildToastData = (data, id) => data ? {
115
+ ...data,
116
+ id
117
+ } : { id };
118
+ var toastFn = ((message, data) => {
119
+ ensureReady();
120
+ const id = resolveId(data?.id) ?? createToastId();
121
+ const nextData = buildToastData(data, id);
122
+ enqueue((m) => {
123
+ m.toast(message, nextData);
124
+ });
125
+ return id;
140
126
  });
141
- const toastSuccess = (message, data) => {
142
- ensureReady();
143
- const id = resolveId(data?.id) ?? createToastId();
144
- const nextData = buildToastData(data, id);
145
- enqueue((m) => {
146
- m.toast.success(message, nextData);
147
- });
148
- return id;
149
- };
150
- const toastInfo = (message, data) => {
151
- ensureReady();
152
- const id = resolveId(data?.id) ?? createToastId();
153
- const nextData = buildToastData(data, id);
154
- enqueue((m) => {
155
- m.toast.info(message, nextData);
156
- });
157
- return id;
158
- };
159
- const toastWarning = (message, data) => {
160
- ensureReady();
161
- const id = resolveId(data?.id) ?? createToastId();
162
- const nextData = buildToastData(data, id);
163
- enqueue((m) => {
164
- m.toast.warning(message, nextData);
165
- });
166
- return id;
167
- };
168
- const toastError = (message, data) => {
169
- ensureReady();
170
- const id = resolveId(data?.id) ?? createToastId();
171
- const nextData = buildToastData(data, id);
172
- enqueue((m) => {
173
- m.toast.error(message, nextData);
174
- });
175
- return id;
176
- };
177
- const toastMessage = (message, data) => {
178
- ensureReady();
179
- const id = resolveId(data?.id) ?? createToastId();
180
- const nextData = buildToastData(data, id);
181
- enqueue((m) => {
182
- m.toast.message(message, nextData);
183
- });
184
- return id;
185
- };
186
- const toastLoading = (message, data) => {
187
- ensureReady();
188
- const id = resolveId(data?.id) ?? createToastId();
189
- const nextData = buildToastData(data, id);
190
- enqueue((m) => {
191
- m.toast.loading(message, nextData);
192
- });
193
- return id;
194
- };
195
- const toastCustom = (jsx2, data) => {
196
- ensureReady();
197
- const id = resolveId(data?.id) ?? createToastId();
198
- const nextData = buildToastData(data, id);
199
- enqueue((m) => {
200
- m.toast.custom(jsx2, nextData);
201
- });
202
- return id;
203
- };
204
- const toastPromise = (promise, data) => {
205
- ensureReady();
206
- if (!data) return void 0;
207
- const startedPromise = promise instanceof Function ? promise() : promise;
208
- const unwrap = () => Promise.resolve(startedPromise);
209
- if (data.loading === void 0) {
210
- enqueue((m) => {
211
- m.toast.promise(startedPromise, data);
212
- });
213
- return {
214
- unwrap
215
- };
216
- }
217
- const id = resolveId(data.id) ?? createToastId();
218
- const nextData = {
219
- ...data,
220
- id
221
- };
222
- enqueue((m) => {
223
- m.toast.promise(startedPromise, nextData);
224
- });
225
- return Object.assign(id, {
226
- unwrap
227
- });
228
- };
229
- const toastDismiss = (id) => {
230
- ensureReady();
231
- enqueue((m) => {
232
- m.toast.dismiss(id);
233
- });
234
- return id;
235
- };
236
- const toastGetHistory = () => sonner ? sonner.toast.getHistory() : [];
237
- const toastGetToasts = () => sonner ? sonner.toast.getToasts() : [];
238
- const toast = Object.assign(toastFn, {
239
- success: toastSuccess,
240
- info: toastInfo,
241
- warning: toastWarning,
242
- error: toastError,
243
- message: toastMessage,
244
- loading: toastLoading,
245
- custom: toastCustom,
246
- promise: toastPromise,
247
- dismiss: toastDismiss,
248
- getHistory: toastGetHistory,
249
- getToasts: toastGetToasts
127
+ var toastSuccess = (message, data) => {
128
+ ensureReady();
129
+ const id = resolveId(data?.id) ?? createToastId();
130
+ const nextData = buildToastData(data, id);
131
+ enqueue((m) => {
132
+ m.toast.success(message, nextData);
133
+ });
134
+ return id;
135
+ };
136
+ var toastInfo = (message, data) => {
137
+ ensureReady();
138
+ const id = resolveId(data?.id) ?? createToastId();
139
+ const nextData = buildToastData(data, id);
140
+ enqueue((m) => {
141
+ m.toast.info(message, nextData);
142
+ });
143
+ return id;
144
+ };
145
+ var toastWarning = (message, data) => {
146
+ ensureReady();
147
+ const id = resolveId(data?.id) ?? createToastId();
148
+ const nextData = buildToastData(data, id);
149
+ enqueue((m) => {
150
+ m.toast.warning(message, nextData);
151
+ });
152
+ return id;
153
+ };
154
+ var toastError = (message, data) => {
155
+ ensureReady();
156
+ const id = resolveId(data?.id) ?? createToastId();
157
+ const nextData = buildToastData(data, id);
158
+ enqueue((m) => {
159
+ m.toast.error(message, nextData);
160
+ });
161
+ return id;
162
+ };
163
+ var toastMessage = (message, data) => {
164
+ ensureReady();
165
+ const id = resolveId(data?.id) ?? createToastId();
166
+ const nextData = buildToastData(data, id);
167
+ enqueue((m) => {
168
+ m.toast.message(message, nextData);
169
+ });
170
+ return id;
171
+ };
172
+ var toastLoading = (message, data) => {
173
+ ensureReady();
174
+ const id = resolveId(data?.id) ?? createToastId();
175
+ const nextData = buildToastData(data, id);
176
+ enqueue((m) => {
177
+ m.toast.loading(message, nextData);
178
+ });
179
+ return id;
180
+ };
181
+ var toastCustom = (jsx, data) => {
182
+ ensureReady();
183
+ const id = resolveId(data?.id) ?? createToastId();
184
+ const nextData = buildToastData(data, id);
185
+ enqueue((m) => {
186
+ m.toast.custom(jsx, nextData);
187
+ });
188
+ return id;
189
+ };
190
+ var toastPromise = (promise, data) => {
191
+ ensureReady();
192
+ if (!data) return void 0;
193
+ const startedPromise = promise instanceof Function ? promise() : promise;
194
+ const unwrap = () => Promise.resolve(startedPromise);
195
+ if (data.loading === void 0) {
196
+ enqueue((m) => {
197
+ m.toast.promise(startedPromise, data);
198
+ });
199
+ return { unwrap };
200
+ }
201
+ const id = resolveId(data.id) ?? createToastId();
202
+ const nextData = {
203
+ ...data,
204
+ id
205
+ };
206
+ enqueue((m) => {
207
+ m.toast.promise(startedPromise, nextData);
208
+ });
209
+ return Object.assign(id, { unwrap });
210
+ };
211
+ var toastDismiss = (id) => {
212
+ ensureReady();
213
+ enqueue((m) => {
214
+ m.toast.dismiss(id);
215
+ });
216
+ return id;
217
+ };
218
+ var toastGetHistory = () => sonner ? sonner.toast.getHistory() : [];
219
+ var toastGetToasts = () => sonner ? sonner.toast.getToasts() : [];
220
+ var toast = Object.assign(toastFn, {
221
+ success: toastSuccess,
222
+ info: toastInfo,
223
+ warning: toastWarning,
224
+ error: toastError,
225
+ message: toastMessage,
226
+ loading: toastLoading,
227
+ custom: toastCustom,
228
+ promise: toastPromise,
229
+ dismiss: toastDismiss,
230
+ getHistory: toastGetHistory,
231
+ getToasts: toastGetToasts
250
232
  });
251
- const LazySonnerToaster = lazy(async () => {
252
- const mod = await import("sonner");
253
- return {
254
- default: mod.Toaster
255
- };
233
+ var LazySonnerToaster = lazy(async () => {
234
+ return { default: (await import("sonner")).Toaster };
256
235
  });
257
- const MountedLazyToaster = (props) => {
258
- const $ = c(3);
259
- let t0;
260
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
261
- t0 = [];
262
- $[0] = t0;
263
- } else {
264
- t0 = $[0];
265
- }
266
- useEffect(_temp2$1, t0);
267
- let t1;
268
- if ($[1] !== props) {
269
- t1 = /* @__PURE__ */ jsx(LazySonnerToaster, { ...props });
270
- $[1] = props;
271
- $[2] = t1;
272
- } else {
273
- t1 = $[2];
274
- }
275
- return t1;
276
- };
277
- const ActiveToaster = () => {
278
- const $ = c(9);
279
- const isMobile = useMediaQuery("(max-width: 767px)");
280
- const isCoarsePointer = useMediaQuery("(hover: none) and (pointer: coarse)");
281
- const position = isMobile ? "top-center" : void 0;
282
- let t0;
283
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
284
- t0 = [];
285
- $[0] = t0;
286
- } else {
287
- t0 = $[0];
288
- }
289
- useEffect(_temp4$1, t0);
290
- const t1 = !isCoarsePointer;
291
- let t2;
292
- if ($[1] !== isCoarsePointer) {
293
- t2 = isCoarsePointer ? void 0 : [];
294
- $[1] = isCoarsePointer;
295
- $[2] = t2;
296
- } else {
297
- t2 = $[2];
298
- }
299
- let t3;
300
- if ($[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
301
- t3 = {
302
- pointerEvents: "auto",
303
- "--toast-close-button-start": "unset",
304
- "--toast-close-button-end": "0",
305
- "--toast-close-button-transform": "translate(35%, -35%)"
306
- };
307
- $[3] = t3;
308
- } else {
309
- t3 = $[3];
310
- }
311
- let t4;
312
- if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
313
- t4 = {
314
- style: {
315
- pointerEvents: "auto",
316
- userSelect: "text"
317
- }
318
- };
319
- $[4] = t4;
320
- } else {
321
- t4 = $[4];
322
- }
323
- let t5;
324
- if ($[5] !== position || $[6] !== t1 || $[7] !== t2) {
325
- t5 = /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(MountedLazyToaster, { closeButton: t1, theme: "dark", position, swipeDirections: t2, style: t3, toastOptions: t4 }) });
326
- $[5] = position;
327
- $[6] = t1;
328
- $[7] = t2;
329
- $[8] = t5;
330
- } else {
331
- t5 = $[8];
332
- }
333
- return t5;
334
- };
335
- const Toaster = () => {
336
- const $ = c(2);
337
- let t0;
338
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
339
- t0 = [];
340
- $[0] = t0;
341
- } else {
342
- t0 = $[0];
343
- }
344
- useEffect(_temp8, t0);
345
- const requested = useSyncExternalStore(subscribeToasterRequested, getToasterRequested, getToasterRequested);
346
- if (!requested) {
347
- return null;
348
- }
349
- let t1;
350
- if ($[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
351
- t1 = /* @__PURE__ */ jsx(ActiveToaster, {});
352
- $[1] = t1;
353
- } else {
354
- t1 = $[1];
355
- }
356
- return t1;
236
+ var MountedLazyToaster = (props) => {
237
+ const $ = c(3);
238
+ let t0;
239
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
240
+ t0 = [];
241
+ $[0] = t0;
242
+ } else t0 = $[0];
243
+ useEffect(_temp2$1, t0);
244
+ let t1;
245
+ if ($[1] !== props) {
246
+ t1 = /* @__PURE__ */ jsx(LazySonnerToaster, { ...props });
247
+ $[1] = props;
248
+ $[2] = t1;
249
+ } else t1 = $[2];
250
+ return t1;
251
+ };
252
+ var ActiveToaster = () => {
253
+ const $ = c(9);
254
+ const isMobile = useMediaQuery("(max-width: 767px)");
255
+ const isCoarsePointer = useMediaQuery("(hover: none) and (pointer: coarse)");
256
+ const position = isMobile ? "top-center" : void 0;
257
+ let t0;
258
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
259
+ t0 = [];
260
+ $[0] = t0;
261
+ } else t0 = $[0];
262
+ useEffect(_temp4$1, t0);
263
+ const t1 = !isCoarsePointer;
264
+ let t2;
265
+ if ($[1] !== isCoarsePointer) {
266
+ t2 = isCoarsePointer ? void 0 : [];
267
+ $[1] = isCoarsePointer;
268
+ $[2] = t2;
269
+ } else t2 = $[2];
270
+ let t3;
271
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
272
+ t3 = {
273
+ pointerEvents: "auto",
274
+ "--toast-close-button-start": "unset",
275
+ "--toast-close-button-end": "0",
276
+ "--toast-close-button-transform": "translate(35%, -35%)"
277
+ };
278
+ $[3] = t3;
279
+ } else t3 = $[3];
280
+ let t4;
281
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
282
+ t4 = { style: {
283
+ pointerEvents: "auto",
284
+ userSelect: "text"
285
+ } };
286
+ $[4] = t4;
287
+ } else t4 = $[4];
288
+ let t5;
289
+ if ($[5] !== position || $[6] !== t1 || $[7] !== t2) {
290
+ t5 = /* @__PURE__ */ jsx(Suspense, {
291
+ fallback: null,
292
+ children: /* @__PURE__ */ jsx(MountedLazyToaster, {
293
+ closeButton: t1,
294
+ theme: "dark",
295
+ position,
296
+ swipeDirections: t2,
297
+ style: t3,
298
+ toastOptions: t4
299
+ })
300
+ });
301
+ $[5] = position;
302
+ $[6] = t1;
303
+ $[7] = t2;
304
+ $[8] = t5;
305
+ } else t5 = $[8];
306
+ return t5;
307
+ };
308
+ var Toaster = () => {
309
+ const $ = c(2);
310
+ let t0;
311
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
312
+ t0 = [];
313
+ $[0] = t0;
314
+ } else t0 = $[0];
315
+ useEffect(_temp8, t0);
316
+ if (!useSyncExternalStore(subscribeToasterRequested, getToasterRequested, getToasterRequested)) return null;
317
+ let t1;
318
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
319
+ t1 = /* @__PURE__ */ jsx(ActiveToaster, {});
320
+ $[1] = t1;
321
+ } else t1 = $[1];
322
+ return t1;
357
323
  };
358
324
  function _temp$2() {
359
- return setToasterMounted(false);
325
+ return setToasterMounted(false);
360
326
  }
361
327
  function _temp2$1() {
362
- setToasterMounted(true);
363
- return _temp$2;
328
+ setToasterMounted(true);
329
+ return _temp$2;
364
330
  }
365
331
  function _temp3$1(event) {
366
- const target = event.target;
367
- if (!(target instanceof Element)) {
368
- return;
369
- }
370
- if (!target.closest("[data-sonner-toaster]")) {
371
- return;
372
- }
373
- event.preventDefault();
332
+ const target = event.target;
333
+ if (!(target instanceof Element)) return;
334
+ if (!target.closest("[data-sonner-toaster]")) return;
335
+ event.preventDefault();
374
336
  }
375
337
  function _temp4$1() {
376
- const handler = _temp3$1;
377
- document.addEventListener("dismissableLayer.pointerDownOutside", handler, true);
378
- document.addEventListener("dismissableLayer.focusOutside", handler, true);
379
- return () => {
380
- document.removeEventListener("dismissableLayer.pointerDownOutside", handler, true);
381
- document.removeEventListener("dismissableLayer.focusOutside", handler, true);
382
- };
338
+ const handler = _temp3$1;
339
+ document.addEventListener("dismissableLayer.pointerDownOutside", handler, true);
340
+ document.addEventListener("dismissableLayer.focusOutside", handler, true);
341
+ return () => {
342
+ document.removeEventListener("dismissableLayer.pointerDownOutside", handler, true);
343
+ document.removeEventListener("dismissableLayer.focusOutside", handler, true);
344
+ };
383
345
  }
384
346
  function _temp5$1() {
385
- return startToaster();
347
+ return startToaster();
386
348
  }
387
349
  function _temp6() {
388
- return startToaster();
350
+ return startToaster();
389
351
  }
390
352
  function _temp7() {
391
- if (typeof window.requestIdleCallback === "function") {
392
- window.requestIdleCallback(_temp5$1, {
393
- timeout: 2e3
394
- });
395
- return;
396
- }
397
- window.setTimeout(_temp6, 150);
353
+ if (typeof window.requestIdleCallback === "function") {
354
+ window.requestIdleCallback(_temp5$1, { timeout: 2e3 });
355
+ return;
356
+ }
357
+ window.setTimeout(_temp6, 150);
398
358
  }
399
359
  function _temp8() {
400
- if (typeof window === "undefined") {
401
- return;
402
- }
403
- const startDeferred = _temp7;
404
- if (isPageLoaded()) {
405
- startDeferred();
406
- return;
407
- }
408
- window.addEventListener("load", startDeferred, {
409
- once: true
410
- });
411
- return () => {
412
- window.removeEventListener("load", startDeferred);
413
- };
360
+ if (typeof window === "undefined") return;
361
+ const startDeferred = _temp7;
362
+ if (isPageLoaded()) {
363
+ startDeferred();
364
+ return;
365
+ }
366
+ window.addEventListener("load", startDeferred, { once: true });
367
+ return () => {
368
+ window.removeEventListener("load", startDeferred);
369
+ };
414
370
  }
415
- let apiClient;
416
- const initApiClient = async (args) => {
417
- if (env.SSR) {
418
- if (!args) {
419
- throw new Error("Server args must be provided in SSR mode");
420
- }
421
- const {
422
- getServerApiClient
423
- } = await import("./getServerApiClient-C1UInaMF.js");
424
- apiClient = await getServerApiClient(args.app);
425
- } else {
426
- const axios = (await import("axios/dist/browser/axios.cjs")).default;
427
- const axiosClient = axios.create({
428
- baseURL: args && "baseURL" in args ? args?.baseURL ?? "/" : "/",
429
- withCredentials: true,
430
- headers: {
431
- "Content-Type": "application/json"
432
- }
433
- });
434
- const createMethod = (method) => {
435
- return async (path, payload, _ctx) => {
436
- const config = {
437
- method,
438
- url: path,
439
- ...method === "get" ? {
440
- params: payload
441
- } : {
442
- data: payload
443
- },
444
- headers: {
445
- // ...(typeof ctxOrPath !== 'string' && {
446
- // // 'X-Custom-Header': ctxOrPath.someHeaderValue,
447
- // // ...ctxOrPath.additionalHeaders,
448
- // }),
449
- }
450
- };
451
- try {
452
- const response = await axiosClient(config);
453
- return response.data;
454
- } catch (error) {
455
- console.log("AXIOS API ERROR", error);
456
- throw error;
457
- }
458
- };
459
- };
460
- apiClient = {
461
- get: createMethod("get"),
462
- put: createMethod("put"),
463
- post: createMethod("post"),
464
- delete: createMethod("delete")
465
- };
466
- }
467
- };
468
- const CLEANUP_WAIT_DELAY = 1e3;
469
- const cleanupURL = () => {
470
- if (env.SSR) {
471
- return;
472
- }
473
- const runCleanup = () => {
474
- setTimeout(() => {
475
- const url = new URL(window.location.href);
476
- const params = new URLSearchParams(url.search);
477
- const paramKeys = Array.from(params.keys());
478
- paramKeys.forEach((key) => {
479
- if (key.startsWith("utm_")) {
480
- params.delete(key);
481
- }
482
- });
483
- const cleanUrl = url.pathname + (params.toString() ? "?" + params.toString() : "") + url.hash;
484
- window.history.replaceState({}, document.title, cleanUrl);
485
- }, CLEANUP_WAIT_DELAY);
486
- };
487
- if (document.readyState === "complete" || document.readyState === "interactive") {
488
- runCleanup();
489
- } else {
490
- document.addEventListener("DOMContentLoaded", runCleanup, {
491
- once: true
492
- });
493
- }
494
- };
495
- const isDesktopDevice = () => {
496
- if (typeof window === "undefined") {
497
- return false;
498
- }
499
- if (typeof window.matchMedia !== "function") {
500
- return false;
501
- }
502
- const hasDesktopPointer = window.matchMedia("(hover: hover) and (pointer: fine)").matches;
503
- const hasTouch = typeof navigator !== "undefined" && navigator.maxTouchPoints > 0;
504
- return hasDesktopPointer && !hasTouch;
505
- };
506
- const isPlaywrightTestEnvironment = () => {
507
- if (typeof navigator === "undefined") {
508
- return false;
509
- }
510
- return navigator.webdriver === true;
511
- };
512
- const DEFAULT_PRIORITY = 0;
513
- const canBlockNavigation = (guard, {
514
- isPathnameChange,
515
- isSearchChange
516
- }) => {
517
- if (!guard.enabled) return false;
518
- if (isPathnameChange) return true;
519
- if (isSearchChange && guard.blockOnSearch) return true;
520
- return false;
521
- };
522
- const pickNavigationGuard = (args) => {
523
- const isPathnameChange = args.currentLocation.pathname !== args.nextLocation.pathname;
524
- const isSearchChange = args.currentLocation.search !== args.nextLocation.search;
525
- if (!isPathnameChange && !isSearchChange) {
526
- return null;
527
- }
528
- const eligibleGuards = getNavigationGuards().filter((guard) => canBlockNavigation(guard, {
529
- isPathnameChange,
530
- isSearchChange
531
- })).filter((guard) => guard.shouldBlockNavigation(args));
532
- if (eligibleGuards.length === 0) {
533
- return null;
534
- }
535
- return eligibleGuards.reduce((best, guard) => {
536
- const bestPriority = best.priority ?? DEFAULT_PRIORITY;
537
- const guardPriority = guard.priority ?? DEFAULT_PRIORITY;
538
- return guardPriority > bestPriority ? guard : best;
539
- }, eligibleGuards[0]);
540
- };
541
- const getLocationDedupKey = (location) => location.key ?? `${location.pathname}${location.search}`;
542
- const hasUnloadBlockers = () => getNavigationGuards().some((guard) => guard.enabled && guard.shouldBlockUnload);
543
- const WINDOW_STATE_KEY = "__rpcbaseNavigationGuardWindowState";
544
- const INSTALLED_ROUTERS_KEY = "__rpcbaseNavigationGuardInstalledRouters";
545
- const BEFORE_UNLOAD_INSTALLED_KEY = "__rpcbaseBeforeUnloadNavigationGuardInstalled";
546
- const getWindowState = () => {
547
- if (typeof window === "undefined") return null;
548
- const globalWindow = window;
549
- const existing = globalWindow[WINDOW_STATE_KEY];
550
- if (existing) {
551
- if (typeof existing.suppressBeforeUnloadFromKey === "undefined") {
552
- existing.suppressBeforeUnloadFromKey = null;
553
- }
554
- return existing;
555
- }
556
- const created = {
557
- suppressBeforeUnloadFromKey: null,
558
- nativePromptActive: false
559
- };
560
- globalWindow[WINDOW_STATE_KEY] = created;
561
- return created;
562
- };
563
- const getGlobalGuardWeakSet = () => {
564
- const globalScope = globalThis;
565
- const existing = globalScope[INSTALLED_ROUTERS_KEY];
566
- if (existing && existing instanceof WeakSet) {
567
- return existing;
568
- }
569
- const created = /* @__PURE__ */ new WeakSet();
570
- globalScope[INSTALLED_ROUTERS_KEY] = created;
571
- return created;
572
- };
573
- const installGlobalNavigationGuard = (router) => {
574
- const installedRouters = getGlobalGuardWeakSet();
575
- if (installedRouters.has(router)) {
576
- return;
577
- }
578
- installedRouters.add(router);
579
- const blockerKey = "rpcbase:navigation-guards";
580
- const windowState = getWindowState();
581
- let lastArgs = null;
582
- let lastPromptedLocationKey = null;
583
- router.getBlocker(blockerKey, (args) => {
584
- lastArgs = args;
585
- if (windowState?.nativePromptActive && args.historyAction !== "POP") {
586
- windowState.nativePromptActive = false;
587
- }
588
- return pickNavigationGuard(args) !== null;
589
- });
590
- router.subscribe((state) => {
591
- if (windowState?.suppressBeforeUnloadFromKey) {
592
- const currentKey = getLocationDedupKey(state.location);
593
- if (currentKey !== windowState.suppressBeforeUnloadFromKey) {
594
- windowState.suppressBeforeUnloadFromKey = null;
595
- }
596
- }
597
- const blocker = state.blockers.get(blockerKey);
598
- if (!blocker || blocker.state !== "blocked") {
599
- lastPromptedLocationKey = null;
600
- return;
601
- }
602
- const blockedLocation = blocker.location;
603
- const dedupKey = getLocationDedupKey(blockedLocation);
604
- if (lastPromptedLocationKey === dedupKey) {
605
- return;
606
- }
607
- lastPromptedLocationKey = dedupKey;
608
- if (windowState?.nativePromptActive && lastArgs?.historyAction === "POP") {
609
- windowState.nativePromptActive = false;
610
- blocker.reset();
611
- return;
612
- }
613
- const args = lastArgs;
614
- if (!args) {
615
- blocker.proceed();
616
- return;
617
- }
618
- const guard = pickNavigationGuard(args);
619
- if (!guard) {
620
- blocker.proceed();
621
- return;
622
- }
623
- const ok = window.confirm(guard.message);
624
- if (ok) {
625
- if (windowState) {
626
- windowState.suppressBeforeUnloadFromKey = getLocationDedupKey(args.currentLocation);
627
- }
628
- blocker.proceed();
629
- } else {
630
- blocker.reset();
631
- }
632
- });
633
- if (typeof window !== "undefined") {
634
- const globalWindow = window;
635
- if (!globalWindow[BEFORE_UNLOAD_INSTALLED_KEY]) {
636
- globalWindow[BEFORE_UNLOAD_INSTALLED_KEY] = true;
637
- window.addEventListener("beforeunload", (event) => {
638
- const state = getWindowState();
639
- if (state && state.suppressBeforeUnloadFromKey) {
640
- state.suppressBeforeUnloadFromKey = null;
641
- return;
642
- }
643
- if (!hasUnloadBlockers()) {
644
- return;
645
- }
646
- if (state) {
647
- state.nativePromptActive = true;
648
- }
649
- event.preventDefault();
650
- event.returnValue = "";
651
- });
652
- }
653
- }
654
- };
655
- const SSR_ERROR_STATE_GLOBAL_KEY = "__RPCBASE_SSR_ERROR__";
656
- const ESCAPED_LT = /</g;
657
- const ESCAPED_U2028 = /\u2028/g;
658
- const ESCAPED_U2029 = /\u2029/g;
659
- const serializeSsrErrorState = (state) => JSON.stringify(state).replace(ESCAPED_LT, "\\u003c").replace(ESCAPED_U2028, "\\u2028").replace(ESCAPED_U2029, "\\u2029");
660
- const peekClientSsrErrorState = () => {
661
- if (typeof window === "undefined") {
662
- return null;
663
- }
664
- const globalScope = window;
665
- const state = globalScope[SSR_ERROR_STATE_GLOBAL_KEY];
666
- if (state && typeof state === "object") {
667
- return state;
668
- }
669
- return null;
670
- };
671
- const consumeClientSsrErrorState = () => {
672
- const state = peekClientSsrErrorState();
673
- if (!state) {
674
- return null;
675
- }
676
- if (typeof window !== "undefined") {
677
- delete window[SSR_ERROR_STATE_GLOBAL_KEY];
678
- }
679
- return state;
680
- };
681
- const DEFAULT_TITLE = "Something went wrong";
682
- const DEFAULT_MESSAGE = "We couldn't render this page. Please try again in a few seconds.";
683
- const SsrErrorFallback = (t0) => {
684
- const $ = c(19);
685
- const {
686
- state,
687
- renderErrorExtra
688
- } = t0;
689
- const {
690
- statusCode: t1,
691
- title: t2,
692
- message: t3,
693
- details
694
- } = state;
695
- const statusCode = t1 === void 0 ? 500 : t1;
696
- const title = t2 === void 0 ? DEFAULT_TITLE : t2;
697
- const message = t3 === void 0 ? DEFAULT_MESSAGE : t3;
698
- let t4;
699
- if ($[0] !== renderErrorExtra || $[1] !== state) {
700
- t4 = renderErrorExtra?.(state);
701
- $[0] = renderErrorExtra;
702
- $[1] = state;
703
- $[2] = t4;
704
- } else {
705
- t4 = $[2];
706
- }
707
- const extra = t4;
708
- let t5;
709
- if ($[3] !== statusCode) {
710
- t5 = /* @__PURE__ */ jsx("p", { className: "text-base font-semibold text-rose-600", children: statusCode });
711
- $[3] = statusCode;
712
- $[4] = t5;
713
- } else {
714
- t5 = $[4];
715
- }
716
- let t6;
717
- if ($[5] !== title) {
718
- t6 = /* @__PURE__ */ jsx("h1", { className: "mt-4 text-pretty text-4xl font-semibold tracking-tight text-gray-900 sm:text-5xl", children: title });
719
- $[5] = title;
720
- $[6] = t6;
721
- } else {
722
- t6 = $[6];
723
- }
724
- let t7;
725
- if ($[7] !== message) {
726
- t7 = /* @__PURE__ */ jsx("p", { className: "mt-6 text-lg text-gray-600 sm:text-xl/relaxed", children: message });
727
- $[7] = message;
728
- $[8] = t7;
729
- } else {
730
- t7 = $[8];
731
- }
732
- let t8;
733
- if ($[9] !== details) {
734
- t8 = details ? /* @__PURE__ */ jsxs("div", { className: "mt-10 w-full rounded-2xl bg-gray-900/95 p-5 text-left shadow-2xl", children: [
735
- /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold uppercase tracking-wide text-gray-400", children: "Debug details" }),
736
- /* @__PURE__ */ jsx("pre", { className: "mt-3 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-gray-100", children: details })
737
- ] }) : null;
738
- $[9] = details;
739
- $[10] = t8;
740
- } else {
741
- t8 = $[10];
742
- }
743
- let t9;
744
- if ($[11] !== extra) {
745
- 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;
746
- $[11] = extra;
747
- $[12] = t9;
748
- } else {
749
- t9 = $[12];
750
- }
751
- let t10;
752
- if ($[13] !== t5 || $[14] !== t6 || $[15] !== t7 || $[16] !== t8 || $[17] !== t9) {
753
- 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: [
754
- t5,
755
- t6,
756
- t7,
757
- t8,
758
- t9
759
- ] }) });
760
- $[13] = t5;
761
- $[14] = t6;
762
- $[15] = t7;
763
- $[16] = t8;
764
- $[17] = t9;
765
- $[18] = t10;
766
- } else {
767
- t10 = $[18];
768
- }
769
- return t10;
770
- };
771
- const isProduction = env.MODE === "production";
772
- const LOADER_TIMEOUT_MS = 8e3;
773
- const HYDRATION_IDENTIFIER_PREFIX = "rb-";
774
- const IMMUTABLE_LAZY_ROUTE_KEYS = /* @__PURE__ */ new Set(["lazy", "caseSensitive", "path", "id", "index", "children"]);
775
- const showErrorOverlay = (err) => {
776
- const ErrorOverlay = customElements.get("vite-error-overlay");
777
- if (!ErrorOverlay) {
778
- return;
779
- }
780
- console.log(err);
781
- const overlay = new ErrorOverlay(err);
782
- document.body.appendChild(overlay);
783
- };
784
- const handleServerErrors = () => {
785
- const hydrationData = window.__staticRouterHydrationData;
786
- if (hydrationData?.errors) {
787
- const {
788
- errors
789
- } = hydrationData;
790
- Object.values(errors).forEach((error) => {
791
- showErrorOverlay({
792
- plugin: "ssr-router",
793
- ...error.reason
794
- });
795
- });
796
- }
797
- };
798
- const clearStaticRouterHydrationData = () => {
799
- delete window.__staticRouterHydrationData;
800
- };
801
- const wrapLoaderWithTimeout = (loader, routeId) => async (...args) => new Promise((resolve, reject) => {
802
- const timer = setTimeout(() => {
803
- console.error("[rpcbase timeout][client loader]", {
804
- routeId,
805
- ms: LOADER_TIMEOUT_MS,
806
- url: window.location.href
807
- });
808
- reject(new Response("Loader timeout", {
809
- status: 504
810
- }));
811
- }, LOADER_TIMEOUT_MS);
812
- Promise.resolve(loader(...args)).then((val) => {
813
- clearTimeout(timer);
814
- resolve(val);
815
- }).catch((err) => {
816
- clearTimeout(timer);
817
- reject(err);
818
- });
371
+ //#endregion
372
+ //#region src/apiClient/index.ts
373
+ var apiClient;
374
+ var initApiClient = async (args) => {
375
+ if (env.SSR) {
376
+ if (!args) throw new Error("Server args must be provided in SSR mode");
377
+ const { getServerApiClient } = await import("./getServerApiClient-udstTQk3.js");
378
+ apiClient = await getServerApiClient(args.app);
379
+ } else {
380
+ const axiosClient = (await import("axios/dist/browser/axios.cjs")).default.create({
381
+ baseURL: args && "baseURL" in args ? args?.baseURL ?? "/" : "/",
382
+ withCredentials: true,
383
+ headers: { "Content-Type": "application/json" }
384
+ });
385
+ const createMethod = (method) => {
386
+ return async (path, payload, _ctx) => {
387
+ const config = {
388
+ method,
389
+ url: path,
390
+ ...method === "get" ? { params: payload } : { data: payload },
391
+ headers: {}
392
+ };
393
+ try {
394
+ return (await axiosClient(config)).data;
395
+ } catch (error) {
396
+ console.log("AXIOS API ERROR", error);
397
+ throw error;
398
+ }
399
+ };
400
+ };
401
+ apiClient = {
402
+ get: createMethod("get"),
403
+ put: createMethod("put"),
404
+ post: createMethod("post"),
405
+ delete: createMethod("delete")
406
+ };
407
+ }
408
+ };
409
+ //#endregion
410
+ //#region src/cleanupURL.ts
411
+ var CLEANUP_WAIT_DELAY = 1e3;
412
+ var cleanupURL = () => {
413
+ if (env.SSR) return;
414
+ const runCleanup = () => {
415
+ setTimeout(() => {
416
+ const url = new URL(window.location.href);
417
+ const params = new URLSearchParams(url.search);
418
+ Array.from(params.keys()).forEach((key) => {
419
+ if (key.startsWith("utm_")) params.delete(key);
420
+ });
421
+ const cleanUrl = url.pathname + (params.toString() ? "?" + params.toString() : "") + url.hash;
422
+ window.history.replaceState({}, document.title, cleanUrl);
423
+ }, CLEANUP_WAIT_DELAY);
424
+ };
425
+ if (document.readyState === "complete" || document.readyState === "interactive") runCleanup();
426
+ else document.addEventListener("DOMContentLoaded", runCleanup, { once: true });
427
+ };
428
+ //#endregion
429
+ //#region src/isDesktopDevice.ts
430
+ var isDesktopDevice = () => {
431
+ if (typeof window === "undefined") return false;
432
+ if (typeof window.matchMedia !== "function") return false;
433
+ const hasDesktopPointer = window.matchMedia("(hover: hover) and (pointer: fine)").matches;
434
+ const hasTouch = typeof navigator !== "undefined" && navigator.maxTouchPoints > 0;
435
+ return hasDesktopPointer && !hasTouch;
436
+ };
437
+ //#endregion
438
+ //#region src/isPlaywrightTestEnvironment.ts
439
+ var isPlaywrightTestEnvironment = () => {
440
+ if (typeof navigator === "undefined") return false;
441
+ return navigator.webdriver === true;
442
+ };
443
+ //#endregion
444
+ //#region src/navigationGuard/installGlobalNavigationGuard.ts
445
+ var DEFAULT_PRIORITY = 0;
446
+ var canBlockNavigation = (guard, { isPathnameChange, isSearchChange }) => {
447
+ if (!guard.enabled) return false;
448
+ if (isPathnameChange) return true;
449
+ if (isSearchChange && guard.blockOnSearch) return true;
450
+ return false;
451
+ };
452
+ var pickNavigationGuard = (args) => {
453
+ const isPathnameChange = args.currentLocation.pathname !== args.nextLocation.pathname;
454
+ const isSearchChange = args.currentLocation.search !== args.nextLocation.search;
455
+ if (!isPathnameChange && !isSearchChange) return null;
456
+ const eligibleGuards = getNavigationGuards().filter((guard) => canBlockNavigation(guard, {
457
+ isPathnameChange,
458
+ isSearchChange
459
+ })).filter((guard) => guard.shouldBlockNavigation(args));
460
+ if (eligibleGuards.length === 0) return null;
461
+ return eligibleGuards.reduce((best, guard) => {
462
+ const bestPriority = best.priority ?? DEFAULT_PRIORITY;
463
+ return (guard.priority ?? DEFAULT_PRIORITY) > bestPriority ? guard : best;
464
+ }, eligibleGuards[0]);
465
+ };
466
+ var getLocationDedupKey = (location) => location.key ?? `${location.pathname}${location.search}`;
467
+ var hasUnloadBlockers = () => getNavigationGuards().some((guard) => guard.enabled && guard.shouldBlockUnload);
468
+ var WINDOW_STATE_KEY = "__rpcbaseNavigationGuardWindowState";
469
+ var INSTALLED_ROUTERS_KEY = "__rpcbaseNavigationGuardInstalledRouters";
470
+ var BEFORE_UNLOAD_INSTALLED_KEY = "__rpcbaseBeforeUnloadNavigationGuardInstalled";
471
+ var getWindowState = () => {
472
+ if (typeof window === "undefined") return null;
473
+ const globalWindow = window;
474
+ const existing = globalWindow[WINDOW_STATE_KEY];
475
+ if (existing) {
476
+ if (typeof existing.suppressBeforeUnloadFromKey === "undefined") existing.suppressBeforeUnloadFromKey = null;
477
+ return existing;
478
+ }
479
+ const created = {
480
+ suppressBeforeUnloadFromKey: null,
481
+ nativePromptActive: false
482
+ };
483
+ globalWindow[WINDOW_STATE_KEY] = created;
484
+ return created;
485
+ };
486
+ var getGlobalGuardWeakSet = () => {
487
+ const globalScope = globalThis;
488
+ const existing = globalScope[INSTALLED_ROUTERS_KEY];
489
+ if (existing && existing instanceof WeakSet) return existing;
490
+ const created = /* @__PURE__ */ new WeakSet();
491
+ globalScope[INSTALLED_ROUTERS_KEY] = created;
492
+ return created;
493
+ };
494
+ var installGlobalNavigationGuard = (router) => {
495
+ const installedRouters = getGlobalGuardWeakSet();
496
+ if (installedRouters.has(router)) return;
497
+ installedRouters.add(router);
498
+ const blockerKey = "rpcbase:navigation-guards";
499
+ const windowState = getWindowState();
500
+ let lastArgs = null;
501
+ let lastPromptedLocationKey = null;
502
+ router.getBlocker(blockerKey, (args) => {
503
+ lastArgs = args;
504
+ if (windowState?.nativePromptActive && args.historyAction !== "POP") windowState.nativePromptActive = false;
505
+ return pickNavigationGuard(args) !== null;
506
+ });
507
+ router.subscribe((state) => {
508
+ if (windowState?.suppressBeforeUnloadFromKey) {
509
+ if (getLocationDedupKey(state.location) !== windowState.suppressBeforeUnloadFromKey) windowState.suppressBeforeUnloadFromKey = null;
510
+ }
511
+ const blocker = state.blockers.get(blockerKey);
512
+ if (!blocker || blocker.state !== "blocked") {
513
+ lastPromptedLocationKey = null;
514
+ return;
515
+ }
516
+ const blockedLocation = blocker.location;
517
+ const dedupKey = getLocationDedupKey(blockedLocation);
518
+ if (lastPromptedLocationKey === dedupKey) return;
519
+ lastPromptedLocationKey = dedupKey;
520
+ if (windowState?.nativePromptActive && lastArgs?.historyAction === "POP") {
521
+ windowState.nativePromptActive = false;
522
+ blocker.reset();
523
+ return;
524
+ }
525
+ const args = lastArgs;
526
+ if (!args) {
527
+ blocker.proceed();
528
+ return;
529
+ }
530
+ const guard = pickNavigationGuard(args);
531
+ if (!guard) {
532
+ blocker.proceed();
533
+ return;
534
+ }
535
+ if (window.confirm(guard.message)) {
536
+ if (windowState) windowState.suppressBeforeUnloadFromKey = getLocationDedupKey(args.currentLocation);
537
+ blocker.proceed();
538
+ } else blocker.reset();
539
+ });
540
+ if (typeof window !== "undefined") {
541
+ const globalWindow = window;
542
+ if (!globalWindow[BEFORE_UNLOAD_INSTALLED_KEY]) {
543
+ globalWindow[BEFORE_UNLOAD_INSTALLED_KEY] = true;
544
+ window.addEventListener("beforeunload", (event) => {
545
+ const state = getWindowState();
546
+ if (state && state.suppressBeforeUnloadFromKey) {
547
+ state.suppressBeforeUnloadFromKey = null;
548
+ return;
549
+ }
550
+ if (!hasUnloadBlockers()) return;
551
+ if (state) state.nativePromptActive = true;
552
+ event.preventDefault();
553
+ event.returnValue = "";
554
+ });
555
+ }
556
+ }
557
+ };
558
+ //#endregion
559
+ //#region src/ssrErrorState.ts
560
+ var SSR_ERROR_STATE_GLOBAL_KEY = "__RPCBASE_SSR_ERROR__";
561
+ var ESCAPED_LT = /</g;
562
+ var ESCAPED_U2028 = /\u2028/g;
563
+ var ESCAPED_U2029 = /\u2029/g;
564
+ var serializeSsrErrorState = (state) => JSON.stringify(state).replace(ESCAPED_LT, "\\u003c").replace(ESCAPED_U2028, "\\u2028").replace(ESCAPED_U2029, "\\u2029");
565
+ var peekClientSsrErrorState = () => {
566
+ if (typeof window === "undefined") return null;
567
+ const state = window[SSR_ERROR_STATE_GLOBAL_KEY];
568
+ if (state && typeof state === "object") return state;
569
+ return null;
570
+ };
571
+ var consumeClientSsrErrorState = () => {
572
+ const state = peekClientSsrErrorState();
573
+ if (!state) return null;
574
+ if (typeof window !== "undefined") delete window[SSR_ERROR_STATE_GLOBAL_KEY];
575
+ return state;
576
+ };
577
+ //#endregion
578
+ //#region src/components/SsrErrorFallback.tsx
579
+ var DEFAULT_TITLE = "Something went wrong";
580
+ var DEFAULT_MESSAGE = "We couldn't render this page. Please try again in a few seconds.";
581
+ var SsrErrorFallback = (t0) => {
582
+ const $ = c(19);
583
+ const { state, renderErrorExtra } = t0;
584
+ const { statusCode: t1, title: t2, message: t3, details } = state;
585
+ const statusCode = t1 === void 0 ? 500 : t1;
586
+ const title = t2 === void 0 ? DEFAULT_TITLE : t2;
587
+ const message = t3 === void 0 ? DEFAULT_MESSAGE : t3;
588
+ let t4;
589
+ if ($[0] !== renderErrorExtra || $[1] !== state) {
590
+ t4 = renderErrorExtra?.(state);
591
+ $[0] = renderErrorExtra;
592
+ $[1] = state;
593
+ $[2] = t4;
594
+ } else t4 = $[2];
595
+ const extra = t4;
596
+ let t5;
597
+ if ($[3] !== statusCode) {
598
+ t5 = /* @__PURE__ */ jsx("p", {
599
+ className: "text-base font-semibold text-rose-600",
600
+ children: statusCode
601
+ });
602
+ $[3] = statusCode;
603
+ $[4] = t5;
604
+ } else t5 = $[4];
605
+ let t6;
606
+ if ($[5] !== title) {
607
+ t6 = /* @__PURE__ */ jsx("h1", {
608
+ className: "mt-4 text-pretty text-4xl font-semibold tracking-tight text-gray-900 sm:text-5xl",
609
+ children: title
610
+ });
611
+ $[5] = title;
612
+ $[6] = t6;
613
+ } else t6 = $[6];
614
+ let t7;
615
+ if ($[7] !== message) {
616
+ t7 = /* @__PURE__ */ jsx("p", {
617
+ className: "mt-6 text-lg text-gray-600 sm:text-xl/relaxed",
618
+ children: message
619
+ });
620
+ $[7] = message;
621
+ $[8] = t7;
622
+ } else t7 = $[8];
623
+ let t8;
624
+ if ($[9] !== details) {
625
+ t8 = details ? /* @__PURE__ */ jsxs("div", {
626
+ className: "mt-10 w-full rounded-2xl bg-gray-900/95 p-5 text-left shadow-2xl",
627
+ children: [/* @__PURE__ */ jsx("p", {
628
+ className: "text-sm font-semibold uppercase tracking-wide text-gray-400",
629
+ children: "Debug details"
630
+ }), /* @__PURE__ */ jsx("pre", {
631
+ className: "mt-3 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-gray-100",
632
+ children: details
633
+ })]
634
+ }) : null;
635
+ $[9] = details;
636
+ $[10] = t8;
637
+ } else t8 = $[10];
638
+ let t9;
639
+ if ($[11] !== extra) {
640
+ t9 = extra ? /* @__PURE__ */ jsx("div", {
641
+ className: "mt-10 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-center",
642
+ children: extra
643
+ }) : null;
644
+ $[11] = extra;
645
+ $[12] = t9;
646
+ } else t9 = $[12];
647
+ let t10;
648
+ if ($[13] !== t5 || $[14] !== t6 || $[15] !== t7 || $[16] !== t8 || $[17] !== t9) {
649
+ t10 = /* @__PURE__ */ jsx("div", {
650
+ className: "bg-white min-h-screen",
651
+ children: /* @__PURE__ */ jsxs("main", {
652
+ 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",
653
+ children: [
654
+ t5,
655
+ t6,
656
+ t7,
657
+ t8,
658
+ t9
659
+ ]
660
+ })
661
+ });
662
+ $[13] = t5;
663
+ $[14] = t6;
664
+ $[15] = t7;
665
+ $[16] = t8;
666
+ $[17] = t9;
667
+ $[18] = t10;
668
+ } else t10 = $[18];
669
+ return t10;
670
+ };
671
+ //#endregion
672
+ //#region src/initWithRoutes.tsx
673
+ var isProduction = env.MODE === "production";
674
+ var LOADER_TIMEOUT_MS = 8e3;
675
+ var HYDRATION_IDENTIFIER_PREFIX = "rb-";
676
+ var IMMUTABLE_LAZY_ROUTE_KEYS = new Set([
677
+ "lazy",
678
+ "caseSensitive",
679
+ "path",
680
+ "id",
681
+ "index",
682
+ "children"
683
+ ]);
684
+ var showErrorOverlay = (err) => {
685
+ const ErrorOverlay = customElements.get("vite-error-overlay");
686
+ if (!ErrorOverlay) return;
687
+ console.log(err);
688
+ const overlay = new ErrorOverlay(err);
689
+ document.body.appendChild(overlay);
690
+ };
691
+ var handleServerErrors = () => {
692
+ const hydrationData = window.__staticRouterHydrationData;
693
+ if (hydrationData?.errors) {
694
+ const { errors } = hydrationData;
695
+ Object.values(errors).forEach((error) => {
696
+ showErrorOverlay({
697
+ plugin: "ssr-router",
698
+ ...error.reason
699
+ });
700
+ });
701
+ }
702
+ };
703
+ var clearStaticRouterHydrationData = () => {
704
+ delete window.__staticRouterHydrationData;
705
+ };
706
+ var wrapLoaderWithTimeout = (loader, routeId) => async (...args) => new Promise((resolve, reject) => {
707
+ const timer = setTimeout(() => {
708
+ console.error("[rpcbase timeout][client loader]", {
709
+ routeId,
710
+ ms: LOADER_TIMEOUT_MS,
711
+ url: window.location.href
712
+ });
713
+ reject(new Response("Loader timeout", { status: 504 }));
714
+ }, LOADER_TIMEOUT_MS);
715
+ Promise.resolve(loader(...args)).then((val) => {
716
+ clearTimeout(timer);
717
+ resolve(val);
718
+ }).catch((err) => {
719
+ clearTimeout(timer);
720
+ reject(err);
721
+ });
819
722
  });
820
- const applyLoaderTimeouts = (routes) => {
821
- routes.forEach((route) => {
822
- if (typeof route.loader === "function") {
823
- route.loader = wrapLoaderWithTimeout(route.loader, route.id);
824
- }
825
- if (typeof route.lazy === "function") {
826
- const origLazy = route.lazy;
827
- route.lazy = async (...lazyArgs) => {
828
- const mod = await origLazy(...lazyArgs);
829
- if (typeof mod.loader === "function") {
830
- const origLoader = mod.loader;
831
- mod.loader = (...loaderArgs) => wrapLoaderWithTimeout(origLoader, route.id)(...loaderArgs);
832
- }
833
- return mod;
834
- };
835
- }
836
- if (route.children) {
837
- applyLoaderTimeouts(route.children);
838
- }
839
- });
840
- };
841
- const resolveLazyRoute = async (route) => {
842
- const lazy2 = route.lazy;
843
- if (typeof lazy2 !== "function") return;
844
- const lazyModule = await lazy2();
845
- if (!lazyModule || typeof lazyModule !== "object") {
846
- route.lazy = void 0;
847
- return;
848
- }
849
- const mutableRoute = route;
850
- for (const [key, value] of Object.entries(lazyModule)) {
851
- if (IMMUTABLE_LAZY_ROUTE_KEYS.has(key)) continue;
852
- if (mutableRoute[key] !== void 0) continue;
853
- mutableRoute[key] = value;
854
- }
855
- route.lazy = void 0;
856
- };
857
- const preloadMatchedLazyRoutes = async (routes) => {
858
- const matches = matchRoutes(routes, {
859
- pathname: window.location.pathname,
860
- search: window.location.search,
861
- hash: window.location.hash
862
- });
863
- if (!matches?.length) return;
864
- await Promise.all(matches.map((match) => resolveLazyRoute(match.route)));
865
- };
866
- const getRootElement = () => {
867
- const el = document.getElementById("root");
868
- if (!el) {
869
- throw new Error("Root element #root not found");
870
- }
871
- return el;
872
- };
873
- const hydrateSsrFallbackIfPresent = (rootElement, renderErrorExtra) => {
874
- const ssrErrorState = peekClientSsrErrorState();
875
- if (!ssrErrorState) {
876
- return false;
877
- }
878
- consumeClientSsrErrorState();
879
- hydrateRoot(rootElement, /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(SsrErrorFallback, { state: ssrErrorState, renderErrorExtra }) }));
880
- return true;
881
- };
882
- const ClientOnly = (t0) => {
883
- const $ = c(4);
884
- const {
885
- children
886
- } = t0;
887
- const [mounted, setMounted] = useState(false);
888
- let t1;
889
- let t2;
890
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
891
- t1 = () => {
892
- setMounted(true);
893
- };
894
- t2 = [];
895
- $[0] = t1;
896
- $[1] = t2;
897
- } else {
898
- t1 = $[0];
899
- t2 = $[1];
900
- }
901
- useEffect(t1, t2);
902
- if (!mounted) {
903
- return null;
904
- }
905
- let t3;
906
- if ($[2] !== children) {
907
- t3 = /* @__PURE__ */ jsx(Fragment, { children });
908
- $[2] = children;
909
- $[3] = t3;
910
- } else {
911
- t3 = $[3];
912
- }
913
- return t3;
914
- };
915
- const initWithRoutes = async (routesElement, opts) => {
916
- const rootElement = getRootElement();
917
- if (hydrateSsrFallbackIfPresent(rootElement, opts?.renderErrorExtra)) {
918
- return;
919
- }
920
- await initApiClient();
921
- cleanupURL();
922
- handleServerErrors();
923
- hydrateRtsFromWindow();
924
- const routes = createRoutesFromElements(routesElement);
925
- applyLoaderTimeouts(routes);
926
- await preloadMatchedLazyRoutes(routes);
927
- const router = createBrowserRouter(routes, {});
928
- clearStaticRouterHydrationData();
929
- installGlobalNavigationGuard(router);
930
- const toError = (error) => error instanceof Error ? error : new Error(String(error));
931
- const mentionsHydration = (value, depth = 0) => {
932
- if (depth > 5) {
933
- return false;
934
- }
935
- if (typeof value === "string") {
936
- return value.toLowerCase().includes("hydrat");
937
- }
938
- if (value instanceof Error) {
939
- const digest = value.digest;
940
- const cause = value.cause;
941
- return mentionsHydration(value.message, depth + 1) || mentionsHydration(digest, depth + 1) || mentionsHydration(cause, depth + 1);
942
- }
943
- return false;
944
- };
945
- const reactErrorHandler = (reactContext) => (error, errorInfo) => {
946
- const err = toError(error);
947
- reportClientException(err, {
948
- reactContext,
949
- componentStack: errorInfo?.componentStack
950
- });
951
- if (reactContext === "uncaught") {
952
- console.warn("Uncaught error", err, errorInfo?.componentStack);
953
- }
954
- };
955
- const baseHydrationOptions = {
956
- identifierPrefix: HYDRATION_IDENTIFIER_PREFIX
957
- };
958
- const hydrationOptions = isProduction ? {
959
- ...baseHydrationOptions,
960
- onUncaughtError: reactErrorHandler("uncaught"),
961
- onCaughtError: reactErrorHandler("caught"),
962
- onRecoverableError: reactErrorHandler("recoverable")
963
- } : opts?.devThrowsOnHydrationErrors ? {
964
- ...baseHydrationOptions,
965
- onRecoverableError(error, errorInfo) {
966
- const err = toError(error);
967
- if (mentionsHydration(err) || mentionsHydration(errorInfo?.componentStack)) {
968
- throw err;
969
- }
970
- console.error(err, errorInfo?.componentStack);
971
- }
972
- } : baseHydrationOptions;
973
- hydrateRoot(rootElement, /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsxs(Fragment, { children: [
974
- /* @__PURE__ */ jsx(RouterProvider, { router }),
975
- /* @__PURE__ */ jsx(ClientOnly, { children: /* @__PURE__ */ jsx(Toaster, {}) })
976
- ] }) }), hydrationOptions);
977
- };
978
- if (!isProduction && !env.SSR && isDesktopDevice() && !isPlaywrightTestEnvironment()) {
979
- import("react-grab/core").then(({
980
- init
981
- }) => {
982
- init({
983
- // theme: { hue: 350 }
984
- });
985
- });
986
- }
987
- var _arrayReduce;
988
- var hasRequired_arrayReduce;
989
- function require_arrayReduce() {
990
- if (hasRequired_arrayReduce) return _arrayReduce;
991
- hasRequired_arrayReduce = 1;
992
- function arrayReduce(array, iteratee, accumulator, initAccum) {
993
- var index = -1, length = array == null ? 0 : array.length;
994
- if (initAccum && length) {
995
- accumulator = array[++index];
996
- }
997
- while (++index < length) {
998
- accumulator = iteratee(accumulator, array[index], index, array);
999
- }
1000
- return accumulator;
1001
- }
1002
- _arrayReduce = arrayReduce;
1003
- return _arrayReduce;
1004
- }
1005
- var _basePropertyOf;
1006
- var hasRequired_basePropertyOf;
1007
- function require_basePropertyOf() {
1008
- if (hasRequired_basePropertyOf) return _basePropertyOf;
1009
- hasRequired_basePropertyOf = 1;
1010
- function basePropertyOf(object) {
1011
- return function(key) {
1012
- return object == null ? void 0 : object[key];
1013
- };
1014
- }
1015
- _basePropertyOf = basePropertyOf;
1016
- return _basePropertyOf;
1017
- }
1018
- var _deburrLetter;
1019
- var hasRequired_deburrLetter;
1020
- function require_deburrLetter() {
1021
- if (hasRequired_deburrLetter) return _deburrLetter;
1022
- hasRequired_deburrLetter = 1;
1023
- var basePropertyOf = require_basePropertyOf();
1024
- var deburredLetters = {
1025
- // Latin-1 Supplement block.
1026
- "À": "A",
1027
- "Á": "A",
1028
- "Â": "A",
1029
- "Ã": "A",
1030
- "Ä": "A",
1031
- "Å": "A",
1032
- "à": "a",
1033
- "á": "a",
1034
- "â": "a",
1035
- "ã": "a",
1036
- "ä": "a",
1037
- "å": "a",
1038
- "Ç": "C",
1039
- "ç": "c",
1040
- "Ð": "D",
1041
- "ð": "d",
1042
- "È": "E",
1043
- "É": "E",
1044
- "Ê": "E",
1045
- "Ë": "E",
1046
- "è": "e",
1047
- "é": "e",
1048
- "ê": "e",
1049
- "ë": "e",
1050
- "Ì": "I",
1051
- "Í": "I",
1052
- "Î": "I",
1053
- "Ï": "I",
1054
- "ì": "i",
1055
- "í": "i",
1056
- "î": "i",
1057
- "ï": "i",
1058
- "Ñ": "N",
1059
- "ñ": "n",
1060
- "Ò": "O",
1061
- "Ó": "O",
1062
- "Ô": "O",
1063
- "Õ": "O",
1064
- "Ö": "O",
1065
- "Ø": "O",
1066
- "ò": "o",
1067
- "ó": "o",
1068
- "ô": "o",
1069
- "õ": "o",
1070
- "ö": "o",
1071
- "ø": "o",
1072
- "Ù": "U",
1073
- "Ú": "U",
1074
- "Û": "U",
1075
- "Ü": "U",
1076
- "ù": "u",
1077
- "ú": "u",
1078
- "û": "u",
1079
- "ü": "u",
1080
- "Ý": "Y",
1081
- "ý": "y",
1082
- "ÿ": "y",
1083
- "Æ": "Ae",
1084
- "æ": "ae",
1085
- "Þ": "Th",
1086
- "þ": "th",
1087
- "ß": "ss",
1088
- // Latin Extended-A block.
1089
- "Ā": "A",
1090
- "Ă": "A",
1091
- "Ą": "A",
1092
- "ā": "a",
1093
- "ă": "a",
1094
- "ą": "a",
1095
- "Ć": "C",
1096
- "Ĉ": "C",
1097
- "Ċ": "C",
1098
- "Č": "C",
1099
- "ć": "c",
1100
- "ĉ": "c",
1101
- "ċ": "c",
1102
- "č": "c",
1103
- "Ď": "D",
1104
- "Đ": "D",
1105
- "ď": "d",
1106
- "đ": "d",
1107
- "Ē": "E",
1108
- "Ĕ": "E",
1109
- "Ė": "E",
1110
- "Ę": "E",
1111
- "Ě": "E",
1112
- "ē": "e",
1113
- "ĕ": "e",
1114
- "ė": "e",
1115
- "ę": "e",
1116
- "ě": "e",
1117
- "Ĝ": "G",
1118
- "Ğ": "G",
1119
- "Ġ": "G",
1120
- "Ģ": "G",
1121
- "ĝ": "g",
1122
- "ğ": "g",
1123
- "ġ": "g",
1124
- "ģ": "g",
1125
- "Ĥ": "H",
1126
- "Ħ": "H",
1127
- "ĥ": "h",
1128
- "ħ": "h",
1129
- "Ĩ": "I",
1130
- "Ī": "I",
1131
- "Ĭ": "I",
1132
- "Į": "I",
1133
- "İ": "I",
1134
- "ĩ": "i",
1135
- "ī": "i",
1136
- "ĭ": "i",
1137
- "į": "i",
1138
- "ı": "i",
1139
- "Ĵ": "J",
1140
- "ĵ": "j",
1141
- "Ķ": "K",
1142
- "ķ": "k",
1143
- "ĸ": "k",
1144
- "Ĺ": "L",
1145
- "Ļ": "L",
1146
- "Ľ": "L",
1147
- "Ŀ": "L",
1148
- "Ł": "L",
1149
- "ĺ": "l",
1150
- "ļ": "l",
1151
- "ľ": "l",
1152
- "ŀ": "l",
1153
- "ł": "l",
1154
- "Ń": "N",
1155
- "Ņ": "N",
1156
- "Ň": "N",
1157
- "Ŋ": "N",
1158
- "ń": "n",
1159
- "ņ": "n",
1160
- "ň": "n",
1161
- "ŋ": "n",
1162
- "Ō": "O",
1163
- "Ŏ": "O",
1164
- "Ő": "O",
1165
- "ō": "o",
1166
- "ŏ": "o",
1167
- "ő": "o",
1168
- "Ŕ": "R",
1169
- "Ŗ": "R",
1170
- "Ř": "R",
1171
- "ŕ": "r",
1172
- "ŗ": "r",
1173
- "ř": "r",
1174
- "Ś": "S",
1175
- "Ŝ": "S",
1176
- "Ş": "S",
1177
- "Š": "S",
1178
- "ś": "s",
1179
- "ŝ": "s",
1180
- "ş": "s",
1181
- "š": "s",
1182
- "Ţ": "T",
1183
- "Ť": "T",
1184
- "Ŧ": "T",
1185
- "ţ": "t",
1186
- "ť": "t",
1187
- "ŧ": "t",
1188
- "Ũ": "U",
1189
- "Ū": "U",
1190
- "Ŭ": "U",
1191
- "Ů": "U",
1192
- "Ű": "U",
1193
- "Ų": "U",
1194
- "ũ": "u",
1195
- "ū": "u",
1196
- "ŭ": "u",
1197
- "ů": "u",
1198
- "ű": "u",
1199
- "ų": "u",
1200
- "Ŵ": "W",
1201
- "ŵ": "w",
1202
- "Ŷ": "Y",
1203
- "ŷ": "y",
1204
- "Ÿ": "Y",
1205
- "Ź": "Z",
1206
- "Ż": "Z",
1207
- "Ž": "Z",
1208
- "ź": "z",
1209
- "ż": "z",
1210
- "ž": "z",
1211
- "IJ": "IJ",
1212
- "ij": "ij",
1213
- "Œ": "Oe",
1214
- "œ": "oe",
1215
- "ʼn": "'n",
1216
- "ſ": "s"
1217
- };
1218
- var deburrLetter = basePropertyOf(deburredLetters);
1219
- _deburrLetter = deburrLetter;
1220
- return _deburrLetter;
1221
- }
1222
- var deburr_1;
1223
- var hasRequiredDeburr;
1224
- function requireDeburr() {
1225
- if (hasRequiredDeburr) return deburr_1;
1226
- hasRequiredDeburr = 1;
1227
- var deburrLetter = require_deburrLetter(), toString2 = requireToString();
1228
- var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
1229
- var rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
1230
- var rsCombo = "[" + rsComboRange + "]";
1231
- var reComboMark = RegExp(rsCombo, "g");
1232
- function deburr(string) {
1233
- string = toString2(string);
1234
- return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
1235
- }
1236
- deburr_1 = deburr;
1237
- return deburr_1;
1238
- }
1239
- var _asciiWords;
1240
- var hasRequired_asciiWords;
1241
- function require_asciiWords() {
1242
- if (hasRequired_asciiWords) return _asciiWords;
1243
- hasRequired_asciiWords = 1;
1244
- var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
1245
- function asciiWords(string) {
1246
- return string.match(reAsciiWord) || [];
1247
- }
1248
- _asciiWords = asciiWords;
1249
- return _asciiWords;
1250
- }
1251
- var _hasUnicodeWord;
1252
- var hasRequired_hasUnicodeWord;
1253
- function require_hasUnicodeWord() {
1254
- if (hasRequired_hasUnicodeWord) return _hasUnicodeWord;
1255
- hasRequired_hasUnicodeWord = 1;
1256
- var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
1257
- function hasUnicodeWord(string) {
1258
- return reHasUnicodeWord.test(string);
1259
- }
1260
- _hasUnicodeWord = hasUnicodeWord;
1261
- return _hasUnicodeWord;
1262
- }
1263
- var _unicodeWords;
1264
- var hasRequired_unicodeWords;
1265
- function require_unicodeWords() {
1266
- if (hasRequired_unicodeWords) return _unicodeWords;
1267
- hasRequired_unicodeWords = 1;
1268
- var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsDingbatRange = "\\u2700-\\u27bf", rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff", rsMathOpRange = "\\xac\\xb1\\xd7\\xf7", rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", rsPunctuationRange = "\\u2000-\\u206f", rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde", rsVarRange = "\\ufe0e\\ufe0f", rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
1269
- var rsApos = "['’]", rsBreak = "[" + rsBreakRange + "]", rsCombo = "[" + rsComboRange + "]", rsDigits = "\\d+", rsDingbat = "[" + rsDingbatRange + "]", rsLower = "[" + rsLowerRange + "]", rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsUpper = "[" + rsUpperRange + "]", rsZWJ = "\\u200d";
1270
- var rsMiscLower = "(?:" + rsLower + "|" + rsMisc + ")", rsMiscUpper = "(?:" + rsUpper + "|" + rsMisc + ")", rsOptContrLower = "(?:" + rsApos + "(?:d|ll|m|re|s|t|ve))?", rsOptContrUpper = "(?:" + rsApos + "(?:D|LL|M|RE|S|T|VE))?", reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*", rsOrdLower = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", rsOrdUpper = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsEmoji = "(?:" + [rsDingbat, rsRegional, rsSurrPair].join("|") + ")" + rsSeq;
1271
- var reUnicodeWord = RegExp([
1272
- rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [rsBreak, rsUpper, "$"].join("|") + ")",
1273
- rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [rsBreak, rsUpper + rsMiscLower, "$"].join("|") + ")",
1274
- rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower,
1275
- rsUpper + "+" + rsOptContrUpper,
1276
- rsOrdUpper,
1277
- rsOrdLower,
1278
- rsDigits,
1279
- rsEmoji
1280
- ].join("|"), "g");
1281
- function unicodeWords(string) {
1282
- return string.match(reUnicodeWord) || [];
1283
- }
1284
- _unicodeWords = unicodeWords;
1285
- return _unicodeWords;
1286
- }
1287
- var words_1;
1288
- var hasRequiredWords;
1289
- function requireWords() {
1290
- if (hasRequiredWords) return words_1;
1291
- hasRequiredWords = 1;
1292
- var asciiWords = require_asciiWords(), hasUnicodeWord = require_hasUnicodeWord(), toString2 = requireToString(), unicodeWords = require_unicodeWords();
1293
- function words(string, pattern, guard) {
1294
- string = toString2(string);
1295
- pattern = guard ? void 0 : pattern;
1296
- if (pattern === void 0) {
1297
- return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
1298
- }
1299
- return string.match(pattern) || [];
1300
- }
1301
- words_1 = words;
1302
- return words_1;
1303
- }
1304
- var _createCompounder;
1305
- var hasRequired_createCompounder;
1306
- function require_createCompounder() {
1307
- if (hasRequired_createCompounder) return _createCompounder;
1308
- hasRequired_createCompounder = 1;
1309
- var arrayReduce = require_arrayReduce(), deburr = requireDeburr(), words = requireWords();
1310
- var rsApos = "['’]";
1311
- var reApos = RegExp(rsApos, "g");
1312
- function createCompounder(callback) {
1313
- return function(string) {
1314
- return arrayReduce(words(deburr(string).replace(reApos, "")), callback, "");
1315
- };
1316
- }
1317
- _createCompounder = createCompounder;
1318
- return _createCompounder;
1319
- }
1320
- var snakeCase_1;
1321
- var hasRequiredSnakeCase;
1322
- function requireSnakeCase() {
1323
- if (hasRequiredSnakeCase) return snakeCase_1;
1324
- hasRequiredSnakeCase = 1;
1325
- var createCompounder = require_createCompounder();
1326
- var snakeCase = createCompounder(function(result, word, index) {
1327
- return result + (index ? "_" : "") + word.toLowerCase();
1328
- });
1329
- snakeCase_1 = snakeCase;
1330
- return snakeCase_1;
1331
- }
1332
- var snakeCaseExports = requireSnakeCase();
1333
- const _snakeCase = /* @__PURE__ */ getDefaultExportFromCjs(snakeCaseExports);
1334
- const getFeatureFlagNYI = async (_flag) => {
1335
- return void 0;
1336
- };
1337
- const getFeatureFlag = async (flag) => {
1338
- const envKey = `RB_PUBLIC_FLAG_${_snakeCase(flag).toUpperCase()}`;
1339
- if (env.SSR) {
1340
- if (process.env[envKey] !== void 0) {
1341
- return process.env[envKey];
1342
- }
1343
- return await getFeatureFlagNYI();
1344
- } else {
1345
- if (globalThis.__rb_env__[envKey] !== void 0) {
1346
- return globalThis.__rb_env__[envKey];
1347
- }
1348
- return await getFeatureFlagNYI();
1349
- }
1350
- };
723
+ var applyLoaderTimeouts = (routes) => {
724
+ routes.forEach((route) => {
725
+ if (typeof route.loader === "function") route.loader = wrapLoaderWithTimeout(route.loader, route.id);
726
+ if (typeof route.lazy === "function") {
727
+ const origLazy = route.lazy;
728
+ route.lazy = async (...lazyArgs) => {
729
+ const mod = await origLazy(...lazyArgs);
730
+ if (typeof mod.loader === "function") {
731
+ const origLoader = mod.loader;
732
+ mod.loader = (...loaderArgs) => wrapLoaderWithTimeout(origLoader, route.id)(...loaderArgs);
733
+ }
734
+ return mod;
735
+ };
736
+ }
737
+ if (route.children) applyLoaderTimeouts(route.children);
738
+ });
739
+ };
740
+ var resolveLazyRoute = async (route) => {
741
+ const lazy = route.lazy;
742
+ if (typeof lazy !== "function") return;
743
+ const lazyModule = await lazy();
744
+ if (!lazyModule || typeof lazyModule !== "object") {
745
+ route.lazy = void 0;
746
+ return;
747
+ }
748
+ const mutableRoute = route;
749
+ for (const [key, value] of Object.entries(lazyModule)) {
750
+ if (IMMUTABLE_LAZY_ROUTE_KEYS.has(key)) continue;
751
+ if (mutableRoute[key] !== void 0) continue;
752
+ mutableRoute[key] = value;
753
+ }
754
+ route.lazy = void 0;
755
+ };
756
+ var preloadMatchedLazyRoutes = async (routes) => {
757
+ const matches = matchRoutes(routes, {
758
+ pathname: window.location.pathname,
759
+ search: window.location.search,
760
+ hash: window.location.hash
761
+ });
762
+ if (!matches?.length) return;
763
+ await Promise.all(matches.map((match) => resolveLazyRoute(match.route)));
764
+ };
765
+ var getRootElement = () => {
766
+ const el = document.getElementById("root");
767
+ if (!el) throw new Error("Root element #root not found");
768
+ return el;
769
+ };
770
+ var hydrateSsrFallbackIfPresent = (rootElement, renderErrorExtra) => {
771
+ const ssrErrorState = peekClientSsrErrorState();
772
+ if (!ssrErrorState) return false;
773
+ consumeClientSsrErrorState();
774
+ hydrateRoot(rootElement, /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(SsrErrorFallback, {
775
+ state: ssrErrorState,
776
+ renderErrorExtra
777
+ }) }));
778
+ return true;
779
+ };
780
+ var ClientOnly = (t0) => {
781
+ const $ = c(4);
782
+ const { children } = t0;
783
+ const [mounted, setMounted] = useState(false);
784
+ let t1;
785
+ let t2;
786
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
787
+ t1 = () => {
788
+ setMounted(true);
789
+ };
790
+ t2 = [];
791
+ $[0] = t1;
792
+ $[1] = t2;
793
+ } else {
794
+ t1 = $[0];
795
+ t2 = $[1];
796
+ }
797
+ useEffect(t1, t2);
798
+ if (!mounted) return null;
799
+ let t3;
800
+ if ($[2] !== children) {
801
+ t3 = /* @__PURE__ */ jsx(Fragment, { children });
802
+ $[2] = children;
803
+ $[3] = t3;
804
+ } else t3 = $[3];
805
+ return t3;
806
+ };
807
+ var initWithRoutes = async (routesElement, opts) => {
808
+ const rootElement = getRootElement();
809
+ if (hydrateSsrFallbackIfPresent(rootElement, opts?.renderErrorExtra)) return;
810
+ await initApiClient();
811
+ cleanupURL();
812
+ handleServerErrors();
813
+ hydrateRtsFromWindow();
814
+ const routes = createRoutesFromElements(routesElement);
815
+ applyLoaderTimeouts(routes);
816
+ await preloadMatchedLazyRoutes(routes);
817
+ const router = createBrowserRouter(routes, {});
818
+ clearStaticRouterHydrationData();
819
+ installGlobalNavigationGuard(router);
820
+ const toError = (error) => error instanceof Error ? error : new Error(String(error));
821
+ const mentionsHydration = (value, depth = 0) => {
822
+ if (depth > 5) return false;
823
+ if (typeof value === "string") return value.toLowerCase().includes("hydrat");
824
+ if (value instanceof Error) {
825
+ const digest = value.digest;
826
+ const cause = value.cause;
827
+ return mentionsHydration(value.message, depth + 1) || mentionsHydration(digest, depth + 1) || mentionsHydration(cause, depth + 1);
828
+ }
829
+ return false;
830
+ };
831
+ const reactErrorHandler = (reactContext) => (error, errorInfo) => {
832
+ const err = toError(error);
833
+ reportClientException(err, {
834
+ reactContext,
835
+ componentStack: errorInfo?.componentStack
836
+ });
837
+ if (reactContext === "uncaught") console.warn("Uncaught error", err, errorInfo?.componentStack);
838
+ };
839
+ const baseHydrationOptions = { identifierPrefix: HYDRATION_IDENTIFIER_PREFIX };
840
+ const hydrationOptions = isProduction ? {
841
+ ...baseHydrationOptions,
842
+ onUncaughtError: reactErrorHandler("uncaught"),
843
+ onCaughtError: reactErrorHandler("caught"),
844
+ onRecoverableError: reactErrorHandler("recoverable")
845
+ } : opts?.devThrowsOnHydrationErrors ? {
846
+ ...baseHydrationOptions,
847
+ onRecoverableError(error, errorInfo) {
848
+ const err = toError(error);
849
+ if (mentionsHydration(err) || mentionsHydration(errorInfo?.componentStack)) throw err;
850
+ console.error(err, errorInfo?.componentStack);
851
+ }
852
+ } : baseHydrationOptions;
853
+ hydrateRoot(rootElement, /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(RouterProvider, { router }), /* @__PURE__ */ jsx(ClientOnly, { children: /* @__PURE__ */ jsx(Toaster, {}) })] }) }), hydrationOptions);
854
+ };
855
+ if (!isProduction && !env.SSR && isDesktopDevice() && !isPlaywrightTestEnvironment()) import("react-grab/core").then(({ init }) => {
856
+ init({});
857
+ });
858
+ //#endregion
859
+ //#region node_modules/lodash/_arrayReduce.js
860
+ var require__arrayReduce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
861
+ /**
862
+ * A specialized version of `_.reduce` for arrays without support for
863
+ * iteratee shorthands.
864
+ *
865
+ * @private
866
+ * @param {Array} [array] The array to iterate over.
867
+ * @param {Function} iteratee The function invoked per iteration.
868
+ * @param {*} [accumulator] The initial value.
869
+ * @param {boolean} [initAccum] Specify using the first element of `array` as
870
+ * the initial value.
871
+ * @returns {*} Returns the accumulated value.
872
+ */
873
+ function arrayReduce(array, iteratee, accumulator, initAccum) {
874
+ var index = -1, length = array == null ? 0 : array.length;
875
+ if (initAccum && length) accumulator = array[++index];
876
+ while (++index < length) accumulator = iteratee(accumulator, array[index], index, array);
877
+ return accumulator;
878
+ }
879
+ module.exports = arrayReduce;
880
+ }));
881
+ //#endregion
882
+ //#region node_modules/lodash/_basePropertyOf.js
883
+ var require__basePropertyOf = /* @__PURE__ */ __commonJSMin(((exports, module) => {
884
+ /**
885
+ * The base implementation of `_.propertyOf` without support for deep paths.
886
+ *
887
+ * @private
888
+ * @param {Object} object The object to query.
889
+ * @returns {Function} Returns the new accessor function.
890
+ */
891
+ function basePropertyOf(object) {
892
+ return function(key) {
893
+ return object == null ? void 0 : object[key];
894
+ };
895
+ }
896
+ module.exports = basePropertyOf;
897
+ }));
898
+ //#endregion
899
+ //#region node_modules/lodash/_deburrLetter.js
900
+ var require__deburrLetter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
901
+ module.exports = require__basePropertyOf()({
902
+ "À": "A",
903
+ "Á": "A",
904
+ "Â": "A",
905
+ "Ã": "A",
906
+ "Ä": "A",
907
+ "Å": "A",
908
+ "à": "a",
909
+ "á": "a",
910
+ "â": "a",
911
+ "ã": "a",
912
+ "ä": "a",
913
+ "å": "a",
914
+ "Ç": "C",
915
+ "ç": "c",
916
+ "Ð": "D",
917
+ "ð": "d",
918
+ "È": "E",
919
+ "É": "E",
920
+ "Ê": "E",
921
+ "Ë": "E",
922
+ "è": "e",
923
+ "é": "e",
924
+ "ê": "e",
925
+ "ë": "e",
926
+ "Ì": "I",
927
+ "Í": "I",
928
+ "Î": "I",
929
+ "Ï": "I",
930
+ "ì": "i",
931
+ "í": "i",
932
+ "î": "i",
933
+ "ï": "i",
934
+ "Ñ": "N",
935
+ "ñ": "n",
936
+ "Ò": "O",
937
+ "Ó": "O",
938
+ "Ô": "O",
939
+ "Õ": "O",
940
+ "Ö": "O",
941
+ "Ø": "O",
942
+ "ò": "o",
943
+ "ó": "o",
944
+ "ô": "o",
945
+ "õ": "o",
946
+ "ö": "o",
947
+ "ø": "o",
948
+ "Ù": "U",
949
+ "Ú": "U",
950
+ "Û": "U",
951
+ "Ü": "U",
952
+ "ù": "u",
953
+ "ú": "u",
954
+ "û": "u",
955
+ "ü": "u",
956
+ "Ý": "Y",
957
+ "ý": "y",
958
+ "ÿ": "y",
959
+ "Æ": "Ae",
960
+ "æ": "ae",
961
+ "Þ": "Th",
962
+ "þ": "th",
963
+ "ß": "ss",
964
+ "Ā": "A",
965
+ "Ă": "A",
966
+ "Ą": "A",
967
+ "ā": "a",
968
+ "ă": "a",
969
+ "ą": "a",
970
+ "Ć": "C",
971
+ "Ĉ": "C",
972
+ "Ċ": "C",
973
+ "Č": "C",
974
+ "ć": "c",
975
+ "ĉ": "c",
976
+ "ċ": "c",
977
+ "č": "c",
978
+ "Ď": "D",
979
+ "Đ": "D",
980
+ "ď": "d",
981
+ "đ": "d",
982
+ "Ē": "E",
983
+ "Ĕ": "E",
984
+ "Ė": "E",
985
+ "Ę": "E",
986
+ "Ě": "E",
987
+ "ē": "e",
988
+ "ĕ": "e",
989
+ "ė": "e",
990
+ "ę": "e",
991
+ "ě": "e",
992
+ "Ĝ": "G",
993
+ "Ğ": "G",
994
+ "Ġ": "G",
995
+ "Ģ": "G",
996
+ "ĝ": "g",
997
+ "ğ": "g",
998
+ "ġ": "g",
999
+ "ģ": "g",
1000
+ "Ĥ": "H",
1001
+ "Ħ": "H",
1002
+ "ĥ": "h",
1003
+ "ħ": "h",
1004
+ "Ĩ": "I",
1005
+ "Ī": "I",
1006
+ "Ĭ": "I",
1007
+ "Į": "I",
1008
+ "İ": "I",
1009
+ "ĩ": "i",
1010
+ "ī": "i",
1011
+ "ĭ": "i",
1012
+ "į": "i",
1013
+ "ı": "i",
1014
+ "Ĵ": "J",
1015
+ "ĵ": "j",
1016
+ "Ķ": "K",
1017
+ "ķ": "k",
1018
+ "ĸ": "k",
1019
+ "Ĺ": "L",
1020
+ "Ļ": "L",
1021
+ "Ľ": "L",
1022
+ "Ŀ": "L",
1023
+ "Ł": "L",
1024
+ "ĺ": "l",
1025
+ "ļ": "l",
1026
+ "ľ": "l",
1027
+ "ŀ": "l",
1028
+ "ł": "l",
1029
+ "Ń": "N",
1030
+ "Ņ": "N",
1031
+ "Ň": "N",
1032
+ "Ŋ": "N",
1033
+ "ń": "n",
1034
+ "ņ": "n",
1035
+ "ň": "n",
1036
+ "ŋ": "n",
1037
+ "Ō": "O",
1038
+ "Ŏ": "O",
1039
+ "Ő": "O",
1040
+ "ō": "o",
1041
+ "ŏ": "o",
1042
+ "ő": "o",
1043
+ "Ŕ": "R",
1044
+ "Ŗ": "R",
1045
+ "Ř": "R",
1046
+ "ŕ": "r",
1047
+ "ŗ": "r",
1048
+ "ř": "r",
1049
+ "Ś": "S",
1050
+ "Ŝ": "S",
1051
+ "Ş": "S",
1052
+ "Š": "S",
1053
+ "ś": "s",
1054
+ "ŝ": "s",
1055
+ "ş": "s",
1056
+ "š": "s",
1057
+ "Ţ": "T",
1058
+ "Ť": "T",
1059
+ "Ŧ": "T",
1060
+ "ţ": "t",
1061
+ "ť": "t",
1062
+ "ŧ": "t",
1063
+ "Ũ": "U",
1064
+ "Ū": "U",
1065
+ "Ŭ": "U",
1066
+ "Ů": "U",
1067
+ "Ű": "U",
1068
+ "Ų": "U",
1069
+ "ũ": "u",
1070
+ "ū": "u",
1071
+ "ŭ": "u",
1072
+ "ů": "u",
1073
+ "ű": "u",
1074
+ "ų": "u",
1075
+ "Ŵ": "W",
1076
+ "ŵ": "w",
1077
+ "Ŷ": "Y",
1078
+ "ŷ": "y",
1079
+ "Ÿ": "Y",
1080
+ "Ź": "Z",
1081
+ "Ż": "Z",
1082
+ "Ž": "Z",
1083
+ "ź": "z",
1084
+ "ż": "z",
1085
+ "ž": "z",
1086
+ "IJ": "IJ",
1087
+ "ij": "ij",
1088
+ "Œ": "Oe",
1089
+ "œ": "oe",
1090
+ "ʼn": "'n",
1091
+ "ſ": "s"
1092
+ });
1093
+ }));
1094
+ //#endregion
1095
+ //#region node_modules/lodash/deburr.js
1096
+ var require_deburr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1097
+ var deburrLetter = require__deburrLetter(), toString = require_toString();
1098
+ /** Used to match Latin Unicode letters (excluding mathematical operators). */
1099
+ var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
1100
+ /**
1101
+ * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
1102
+ * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
1103
+ */
1104
+ var reComboMark = RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]", "g");
1105
+ /**
1106
+ * Deburrs `string` by converting
1107
+ * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
1108
+ * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
1109
+ * letters to basic Latin letters and removing
1110
+ * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
1111
+ *
1112
+ * @static
1113
+ * @memberOf _
1114
+ * @since 3.0.0
1115
+ * @category String
1116
+ * @param {string} [string=''] The string to deburr.
1117
+ * @returns {string} Returns the deburred string.
1118
+ * @example
1119
+ *
1120
+ * _.deburr('déjà vu');
1121
+ * // => 'deja vu'
1122
+ */
1123
+ function deburr(string) {
1124
+ string = toString(string);
1125
+ return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
1126
+ }
1127
+ module.exports = deburr;
1128
+ }));
1129
+ //#endregion
1130
+ //#region node_modules/lodash/_asciiWords.js
1131
+ var require__asciiWords = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1132
+ /** Used to match words composed of alphanumeric characters. */
1133
+ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
1134
+ /**
1135
+ * Splits an ASCII `string` into an array of its words.
1136
+ *
1137
+ * @private
1138
+ * @param {string} The string to inspect.
1139
+ * @returns {Array} Returns the words of `string`.
1140
+ */
1141
+ function asciiWords(string) {
1142
+ return string.match(reAsciiWord) || [];
1143
+ }
1144
+ module.exports = asciiWords;
1145
+ }));
1146
+ //#endregion
1147
+ //#region node_modules/lodash/_hasUnicodeWord.js
1148
+ var require__hasUnicodeWord = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1149
+ /** Used to detect strings that need a more robust regexp to match words. */
1150
+ var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
1151
+ /**
1152
+ * Checks if `string` contains a word composed of Unicode symbols.
1153
+ *
1154
+ * @private
1155
+ * @param {string} string The string to inspect.
1156
+ * @returns {boolean} Returns `true` if a word is found, else `false`.
1157
+ */
1158
+ function hasUnicodeWord(string) {
1159
+ return reHasUnicodeWord.test(string);
1160
+ }
1161
+ module.exports = hasUnicodeWord;
1162
+ }));
1163
+ //#endregion
1164
+ //#region node_modules/lodash/_unicodeWords.js
1165
+ var require__unicodeWords = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1166
+ /** Used to compose unicode character classes. */
1167
+ var rsAstralRange = "\\ud800-\\udfff", rsComboRange = "\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff", rsDingbatRange = "\\u2700-\\u27bf", rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff", rsMathOpRange = "\\xac\\xb1\\xd7\\xf7", rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", rsPunctuationRange = "\\u2000-\\u206f", rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde", rsVarRange = "\\ufe0e\\ufe0f", rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
1168
+ /** Used to compose unicode capture groups. */
1169
+ var rsApos = "['’]", rsBreak = "[" + rsBreakRange + "]", rsCombo = "[" + rsComboRange + "]", rsDigits = "\\d+", rsDingbat = "[" + rsDingbatRange + "]", rsLower = "[" + rsLowerRange + "]", rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]", rsModifier = "(?:" + rsCombo + "|\\ud83c[\\udffb-\\udfff])", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsUpper = "[" + rsUpperRange + "]", rsZWJ = "\\u200d";
1170
+ /** Used to compose unicode regexes. */
1171
+ var rsMiscLower = "(?:" + rsLower + "|" + rsMisc + ")", rsMiscUpper = "(?:" + rsUpper + "|" + rsMisc + ")", rsOptContrLower = "(?:" + rsApos + "(?:d|ll|m|re|s|t|ve))?", rsOptContrUpper = "(?:" + rsApos + "(?:D|LL|M|RE|S|T|VE))?", reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [
1172
+ rsNonAstral,
1173
+ rsRegional,
1174
+ rsSurrPair
1175
+ ].join("|") + ")" + rsOptVar + reOptMod + ")*", rsOrdLower = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", rsOrdUpper = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsEmoji = "(?:" + [
1176
+ rsDingbat,
1177
+ rsRegional,
1178
+ rsSurrPair
1179
+ ].join("|") + ")" + rsSeq;
1180
+ /** Used to match complex or compound words. */
1181
+ var reUnicodeWord = RegExp([
1182
+ rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [
1183
+ rsBreak,
1184
+ rsUpper,
1185
+ "$"
1186
+ ].join("|") + ")",
1187
+ rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [
1188
+ rsBreak,
1189
+ rsUpper + rsMiscLower,
1190
+ "$"
1191
+ ].join("|") + ")",
1192
+ rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower,
1193
+ rsUpper + "+" + rsOptContrUpper,
1194
+ rsOrdUpper,
1195
+ rsOrdLower,
1196
+ rsDigits,
1197
+ rsEmoji
1198
+ ].join("|"), "g");
1199
+ /**
1200
+ * Splits a Unicode `string` into an array of its words.
1201
+ *
1202
+ * @private
1203
+ * @param {string} The string to inspect.
1204
+ * @returns {Array} Returns the words of `string`.
1205
+ */
1206
+ function unicodeWords(string) {
1207
+ return string.match(reUnicodeWord) || [];
1208
+ }
1209
+ module.exports = unicodeWords;
1210
+ }));
1211
+ //#endregion
1212
+ //#region node_modules/lodash/words.js
1213
+ var require_words = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1214
+ var asciiWords = require__asciiWords(), hasUnicodeWord = require__hasUnicodeWord(), toString = require_toString(), unicodeWords = require__unicodeWords();
1215
+ /**
1216
+ * Splits `string` into an array of its words.
1217
+ *
1218
+ * @static
1219
+ * @memberOf _
1220
+ * @since 3.0.0
1221
+ * @category String
1222
+ * @param {string} [string=''] The string to inspect.
1223
+ * @param {RegExp|string} [pattern] The pattern to match words.
1224
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
1225
+ * @returns {Array} Returns the words of `string`.
1226
+ * @example
1227
+ *
1228
+ * _.words('fred, barney, & pebbles');
1229
+ * // => ['fred', 'barney', 'pebbles']
1230
+ *
1231
+ * _.words('fred, barney, & pebbles', /[^, ]+/g);
1232
+ * // => ['fred', 'barney', '&', 'pebbles']
1233
+ */
1234
+ function words(string, pattern, guard) {
1235
+ string = toString(string);
1236
+ pattern = guard ? void 0 : pattern;
1237
+ if (pattern === void 0) return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
1238
+ return string.match(pattern) || [];
1239
+ }
1240
+ module.exports = words;
1241
+ }));
1242
+ //#endregion
1243
+ //#region node_modules/lodash/_createCompounder.js
1244
+ var require__createCompounder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1245
+ var arrayReduce = require__arrayReduce(), deburr = require_deburr(), words = require_words();
1246
+ /** Used to match apostrophes. */
1247
+ var reApos = RegExp("['’]", "g");
1248
+ /**
1249
+ * Creates a function like `_.camelCase`.
1250
+ *
1251
+ * @private
1252
+ * @param {Function} callback The function to combine each word.
1253
+ * @returns {Function} Returns the new compounder function.
1254
+ */
1255
+ function createCompounder(callback) {
1256
+ return function(string) {
1257
+ return arrayReduce(words(deburr(string).replace(reApos, "")), callback, "");
1258
+ };
1259
+ }
1260
+ module.exports = createCompounder;
1261
+ }));
1262
+ //#endregion
1263
+ //#region src/getFeatureFlag.ts
1264
+ var import_snakeCase = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
1265
+ module.exports = require__createCompounder()(function(result, word, index) {
1266
+ return result + (index ? "_" : "") + word.toLowerCase();
1267
+ });
1268
+ })))(), 1);
1269
+ var getFeatureFlagNYI = async (_flag) => {};
1270
+ var getFeatureFlag = async (flag) => {
1271
+ const envKey = `RB_PUBLIC_FLAG_${(0, import_snakeCase.default)(flag).toUpperCase()}`;
1272
+ if (env.SSR) {
1273
+ if (process.env[envKey] !== void 0) return process.env[envKey];
1274
+ return await getFeatureFlagNYI(flag);
1275
+ } else {
1276
+ if (globalThis.__rb_env__[envKey] !== void 0) return globalThis.__rb_env__[envKey];
1277
+ return await getFeatureFlagNYI(flag);
1278
+ }
1279
+ };
1280
+ //#endregion
1281
+ //#region src/utils/useApplyScroll.ts
1351
1282
  function throttle(callback, limit) {
1352
- let wait = false;
1353
- return (...args) => {
1354
- if (!wait) {
1355
- callback(...args);
1356
- wait = true;
1357
- setTimeout(() => {
1358
- wait = false;
1359
- }, limit);
1360
- }
1361
- };
1283
+ let wait = false;
1284
+ return (...args) => {
1285
+ if (!wait) {
1286
+ callback(...args);
1287
+ wait = true;
1288
+ setTimeout(() => {
1289
+ wait = false;
1290
+ }, limit);
1291
+ }
1292
+ };
1362
1293
  }
1363
1294
  function useApplyScroll() {
1364
- const $ = c(17);
1365
- const location = useLocation();
1366
- const previousPathRef = useRef(location.pathname);
1367
- const hasAppliedLocationRef = useRef(false);
1368
- const isScrollingProgrammatically = useRef(false);
1369
- const scrollTimeoutRef = useRef(null);
1370
- const lastAppliedHashRef = useRef("");
1371
- let t0;
1372
- let t1;
1373
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1374
- t0 = () => {
1375
- if (typeof window !== "undefined") {
1376
- lastAppliedHashRef.current = window.location.hash || "";
1377
- }
1378
- };
1379
- t1 = [];
1380
- $[0] = t0;
1381
- $[1] = t1;
1382
- } else {
1383
- t0 = $[0];
1384
- t1 = $[1];
1385
- }
1386
- useEffect(t0, t1);
1387
- let t2;
1388
- let t3;
1389
- if ($[2] !== location.hash) {
1390
- t2 = () => {
1391
- lastAppliedHashRef.current = location.hash || "";
1392
- };
1393
- t3 = [location.hash];
1394
- $[2] = location.hash;
1395
- $[3] = t2;
1396
- $[4] = t3;
1397
- } else {
1398
- t2 = $[3];
1399
- t3 = $[4];
1400
- }
1401
- useEffect(t2, t3);
1402
- let t4;
1403
- if ($[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1404
- t4 = (hash) => {
1405
- if (typeof window === "undefined") {
1406
- return;
1407
- }
1408
- if (lastAppliedHashRef.current === hash) {
1409
- return;
1410
- }
1411
- const base = `${window.location.pathname}${window.location.search}`;
1412
- window.history.replaceState(window.history.state, "", `${base}${hash}`);
1413
- lastAppliedHashRef.current = hash;
1414
- };
1415
- $[5] = t4;
1416
- } else {
1417
- t4 = $[5];
1418
- }
1419
- const replaceHashSilently = t4;
1420
- let t5;
1421
- if ($[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1422
- t5 = () => {
1423
- isScrollingProgrammatically.current = true;
1424
- if (scrollTimeoutRef.current) {
1425
- clearTimeout(scrollTimeoutRef.current);
1426
- }
1427
- scrollTimeoutRef.current = setTimeout(() => {
1428
- isScrollingProgrammatically.current = false;
1429
- }, 1e3);
1430
- };
1431
- $[6] = t5;
1432
- } else {
1433
- t5 = $[6];
1434
- }
1435
- const markProgrammaticScroll = t5;
1436
- let t6;
1437
- let t7;
1438
- if ($[7] !== location.hash || $[8] !== location.pathname) {
1439
- t6 = () => {
1440
- const isInitialLocation = !hasAppliedLocationRef.current;
1441
- hasAppliedLocationRef.current = true;
1442
- const pathChanged = previousPathRef.current !== location.pathname;
1443
- const applyHashScroll = (behavior) => {
1444
- const id = location.hash.substring(1);
1445
- const element = document.getElementById(id);
1446
- if (!element) {
1447
- return;
1448
- }
1449
- markProgrammaticScroll();
1450
- element.scrollIntoView({
1451
- behavior
1452
- });
1453
- };
1454
- if (pathChanged) {
1455
- previousPathRef.current = location.pathname;
1456
- if (!location.hash) {
1457
- window.scrollTo({
1458
- top: 0,
1459
- left: 0,
1460
- behavior: "auto"
1461
- });
1462
- return;
1463
- }
1464
- setTimeout(() => {
1465
- applyHashScroll("auto");
1466
- }, 100);
1467
- return;
1468
- }
1469
- if (!location.hash) {
1470
- return;
1471
- }
1472
- applyHashScroll(isInitialLocation ? "auto" : "smooth");
1473
- };
1474
- t7 = [location.hash, location.pathname, markProgrammaticScroll];
1475
- $[7] = location.hash;
1476
- $[8] = location.pathname;
1477
- $[9] = t6;
1478
- $[10] = t7;
1479
- } else {
1480
- t6 = $[9];
1481
- t7 = $[10];
1482
- }
1483
- useEffect(t6, t7);
1484
- let t8;
1485
- let t9;
1486
- if ($[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1487
- t8 = () => {
1488
- if (typeof window === "undefined") {
1489
- return;
1490
- }
1491
- const handleScroll = throttle(() => {
1492
- if (isScrollingProgrammatically.current) {
1493
- return;
1494
- }
1495
- const sections = Array.from(document.querySelectorAll("section[id]"));
1496
- if (sections.length === 0) {
1497
- replaceHashSilently("");
1498
- return;
1499
- }
1500
- const scrollPosition = window.scrollY;
1501
- const viewportHeight = window.innerHeight;
1502
- const checkPoint = scrollPosition + viewportHeight / 3;
1503
- let activeSectionId = null;
1504
- for (const section of sections) {
1505
- if (section.offsetTop <= checkPoint && section.offsetTop + section.offsetHeight > checkPoint) {
1506
- activeSectionId = section.id;
1507
- break;
1508
- }
1509
- }
1510
- const newHash = activeSectionId ? `#${activeSectionId}` : "";
1511
- replaceHashSilently(newHash);
1512
- }, 150);
1513
- document.addEventListener("scroll", handleScroll);
1514
- return () => {
1515
- document.removeEventListener("scroll", handleScroll);
1516
- if (scrollTimeoutRef.current) {
1517
- clearTimeout(scrollTimeoutRef.current);
1518
- scrollTimeoutRef.current = null;
1519
- }
1520
- };
1521
- };
1522
- t9 = [replaceHashSilently];
1523
- $[11] = t8;
1524
- $[12] = t9;
1525
- } else {
1526
- t8 = $[11];
1527
- t9 = $[12];
1528
- }
1529
- useEffect(t8, t9);
1530
- let t10;
1531
- let t11;
1532
- if ($[13] !== location.hash || $[14] !== location.pathname) {
1533
- t10 = () => {
1534
- const handleClick = (event) => {
1535
- const target = event.target;
1536
- const link = target?.closest("a");
1537
- const currentHash = typeof window !== "undefined" ? window.location.hash : location.hash || "";
1538
- if (!link || !link.hash || link.pathname !== location.pathname || link.hash !== currentHash) {
1539
- return;
1540
- }
1541
- const id_0 = link.hash.substring(1);
1542
- const element_0 = document.getElementById(id_0);
1543
- if (element_0) {
1544
- event.preventDefault();
1545
- event.stopPropagation();
1546
- markProgrammaticScroll();
1547
- element_0.scrollIntoView({
1548
- behavior: "smooth"
1549
- });
1550
- }
1551
- };
1552
- document.addEventListener("click", handleClick, true);
1553
- return () => document.removeEventListener("click", handleClick, true);
1554
- };
1555
- t11 = [location.hash, location.pathname, markProgrammaticScroll];
1556
- $[13] = location.hash;
1557
- $[14] = location.pathname;
1558
- $[15] = t10;
1559
- $[16] = t11;
1560
- } else {
1561
- t10 = $[15];
1562
- t11 = $[16];
1563
- }
1564
- useEffect(t10, t11);
1295
+ const $ = c(17);
1296
+ const location = useLocation();
1297
+ const previousPathRef = useRef(location.pathname);
1298
+ const hasAppliedLocationRef = useRef(false);
1299
+ const isScrollingProgrammatically = useRef(false);
1300
+ const scrollTimeoutRef = useRef(null);
1301
+ const lastAppliedHashRef = useRef("");
1302
+ let t0;
1303
+ let t1;
1304
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1305
+ t0 = () => {
1306
+ if (typeof window !== "undefined") lastAppliedHashRef.current = window.location.hash || "";
1307
+ };
1308
+ t1 = [];
1309
+ $[0] = t0;
1310
+ $[1] = t1;
1311
+ } else {
1312
+ t0 = $[0];
1313
+ t1 = $[1];
1314
+ }
1315
+ useEffect(t0, t1);
1316
+ let t2;
1317
+ let t3;
1318
+ if ($[2] !== location.hash) {
1319
+ t2 = () => {
1320
+ lastAppliedHashRef.current = location.hash || "";
1321
+ };
1322
+ t3 = [location.hash];
1323
+ $[2] = location.hash;
1324
+ $[3] = t2;
1325
+ $[4] = t3;
1326
+ } else {
1327
+ t2 = $[3];
1328
+ t3 = $[4];
1329
+ }
1330
+ useEffect(t2, t3);
1331
+ let t4;
1332
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
1333
+ t4 = (hash) => {
1334
+ if (typeof window === "undefined") return;
1335
+ if (lastAppliedHashRef.current === hash) return;
1336
+ const base = `${window.location.pathname}${window.location.search}`;
1337
+ window.history.replaceState(window.history.state, "", `${base}${hash}`);
1338
+ lastAppliedHashRef.current = hash;
1339
+ };
1340
+ $[5] = t4;
1341
+ } else t4 = $[5];
1342
+ const replaceHashSilently = t4;
1343
+ let t5;
1344
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
1345
+ t5 = () => {
1346
+ isScrollingProgrammatically.current = true;
1347
+ if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);
1348
+ scrollTimeoutRef.current = setTimeout(() => {
1349
+ isScrollingProgrammatically.current = false;
1350
+ }, 1e3);
1351
+ };
1352
+ $[6] = t5;
1353
+ } else t5 = $[6];
1354
+ const markProgrammaticScroll = t5;
1355
+ let t6;
1356
+ let t7;
1357
+ if ($[7] !== location.hash || $[8] !== location.pathname) {
1358
+ t6 = () => {
1359
+ const isInitialLocation = !hasAppliedLocationRef.current;
1360
+ hasAppliedLocationRef.current = true;
1361
+ const pathChanged = previousPathRef.current !== location.pathname;
1362
+ const applyHashScroll = (behavior) => {
1363
+ const id = location.hash.substring(1);
1364
+ const element = document.getElementById(id);
1365
+ if (!element) return;
1366
+ markProgrammaticScroll();
1367
+ element.scrollIntoView({ behavior });
1368
+ };
1369
+ if (pathChanged) {
1370
+ previousPathRef.current = location.pathname;
1371
+ if (!location.hash) {
1372
+ window.scrollTo({
1373
+ top: 0,
1374
+ left: 0,
1375
+ behavior: "auto"
1376
+ });
1377
+ return;
1378
+ }
1379
+ setTimeout(() => {
1380
+ applyHashScroll("auto");
1381
+ }, 100);
1382
+ return;
1383
+ }
1384
+ if (!location.hash) return;
1385
+ applyHashScroll(isInitialLocation ? "auto" : "smooth");
1386
+ };
1387
+ t7 = [
1388
+ location.hash,
1389
+ location.pathname,
1390
+ markProgrammaticScroll
1391
+ ];
1392
+ $[7] = location.hash;
1393
+ $[8] = location.pathname;
1394
+ $[9] = t6;
1395
+ $[10] = t7;
1396
+ } else {
1397
+ t6 = $[9];
1398
+ t7 = $[10];
1399
+ }
1400
+ useEffect(t6, t7);
1401
+ let t8;
1402
+ let t9;
1403
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
1404
+ t8 = () => {
1405
+ if (typeof window === "undefined") return;
1406
+ const handleScroll = throttle(() => {
1407
+ if (isScrollingProgrammatically.current) return;
1408
+ const sections = Array.from(document.querySelectorAll("section[id]"));
1409
+ if (sections.length === 0) {
1410
+ replaceHashSilently("");
1411
+ return;
1412
+ }
1413
+ const checkPoint = window.scrollY + window.innerHeight / 3;
1414
+ let activeSectionId = null;
1415
+ for (const section of sections) if (section.offsetTop <= checkPoint && section.offsetTop + section.offsetHeight > checkPoint) {
1416
+ activeSectionId = section.id;
1417
+ break;
1418
+ }
1419
+ replaceHashSilently(activeSectionId ? `#${activeSectionId}` : "");
1420
+ }, 150);
1421
+ document.addEventListener("scroll", handleScroll);
1422
+ return () => {
1423
+ document.removeEventListener("scroll", handleScroll);
1424
+ if (scrollTimeoutRef.current) {
1425
+ clearTimeout(scrollTimeoutRef.current);
1426
+ scrollTimeoutRef.current = null;
1427
+ }
1428
+ };
1429
+ };
1430
+ t9 = [replaceHashSilently];
1431
+ $[11] = t8;
1432
+ $[12] = t9;
1433
+ } else {
1434
+ t8 = $[11];
1435
+ t9 = $[12];
1436
+ }
1437
+ useEffect(t8, t9);
1438
+ let t10;
1439
+ let t11;
1440
+ if ($[13] !== location.hash || $[14] !== location.pathname) {
1441
+ t10 = () => {
1442
+ const handleClick = (event) => {
1443
+ const link = event.target?.closest("a");
1444
+ const currentHash = typeof window !== "undefined" ? window.location.hash : location.hash || "";
1445
+ if (!link || !link.hash || link.pathname !== location.pathname || link.hash !== currentHash) return;
1446
+ const id_0 = link.hash.substring(1);
1447
+ const element_0 = document.getElementById(id_0);
1448
+ if (element_0) {
1449
+ event.preventDefault();
1450
+ event.stopPropagation();
1451
+ markProgrammaticScroll();
1452
+ element_0.scrollIntoView({ behavior: "smooth" });
1453
+ }
1454
+ };
1455
+ document.addEventListener("click", handleClick, true);
1456
+ return () => document.removeEventListener("click", handleClick, true);
1457
+ };
1458
+ t11 = [
1459
+ location.hash,
1460
+ location.pathname,
1461
+ markProgrammaticScroll
1462
+ ];
1463
+ $[13] = location.hash;
1464
+ $[14] = location.pathname;
1465
+ $[15] = t10;
1466
+ $[16] = t11;
1467
+ } else {
1468
+ t10 = $[15];
1469
+ t11 = $[16];
1470
+ }
1471
+ useEffect(t10, t11);
1565
1472
  }
1566
- const RootProvider = (t0) => {
1567
- const $ = c(4);
1568
- const {
1569
- children,
1570
- routePrefetch
1571
- } = t0;
1572
- useApplyScroll();
1573
- const t1 = routePrefetch?.defaultPrefetch ?? "intent";
1574
- let t2;
1575
- if ($[0] !== children || $[1] !== routePrefetch || $[2] !== t1) {
1576
- t2 = /* @__PURE__ */ jsx(RoutePrefetchProvider, { ...routePrefetch, defaultPrefetch: t1, children });
1577
- $[0] = children;
1578
- $[1] = routePrefetch;
1579
- $[2] = t1;
1580
- $[3] = t2;
1581
- } else {
1582
- t2 = $[3];
1583
- }
1584
- return t2;
1585
- };
1586
- const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
1587
- const { hasOwnProperty } = Object.prototype;
1473
+ //#endregion
1474
+ //#region src/RootProvider/index.tsx
1475
+ var RootProvider = (t0) => {
1476
+ const $ = c(4);
1477
+ const { children, routePrefetch } = t0;
1478
+ useApplyScroll();
1479
+ const t1 = routePrefetch?.defaultPrefetch ?? "intent";
1480
+ let t2;
1481
+ if ($[0] !== children || $[1] !== routePrefetch || $[2] !== t1) {
1482
+ t2 = /* @__PURE__ */ jsx(RoutePrefetchProvider, {
1483
+ ...routePrefetch,
1484
+ defaultPrefetch: t1,
1485
+ children
1486
+ });
1487
+ $[0] = children;
1488
+ $[1] = routePrefetch;
1489
+ $[2] = t1;
1490
+ $[3] = t2;
1491
+ } else t2 = $[3];
1492
+ return t2;
1493
+ };
1494
+ //#endregion
1495
+ //#region ../../node_modules/fast-equals/dist/es/index.mjs
1496
+ var import_throttle = /* @__PURE__ */ __toESM(require_throttle(), 1);
1497
+ var { getOwnPropertyNames, getOwnPropertySymbols } = Object;
1498
+ var { hasOwnProperty } = Object.prototype;
1499
+ /**
1500
+ * Combine two comparators into a single comparators.
1501
+ */
1588
1502
  function combineComparators(comparatorA, comparatorB) {
1589
- return function isEqual(a, b, state) {
1590
- return comparatorA(a, b, state) && comparatorB(a, b, state);
1591
- };
1503
+ return function isEqual(a, b, state) {
1504
+ return comparatorA(a, b, state) && comparatorB(a, b, state);
1505
+ };
1592
1506
  }
1507
+ /**
1508
+ * Wrap the provided `areItemsEqual` method to manage the circular state, allowing
1509
+ * for circular references to be safely included in the comparison without creating
1510
+ * stack overflows.
1511
+ */
1593
1512
  function createIsCircular(areItemsEqual) {
1594
- return function isCircular(a, b, state) {
1595
- if (!a || !b || typeof a !== "object" || typeof b !== "object") {
1596
- return areItemsEqual(a, b, state);
1597
- }
1598
- const { cache } = state;
1599
- const cachedA = cache.get(a);
1600
- const cachedB = cache.get(b);
1601
- if (cachedA && cachedB) {
1602
- return cachedA === b && cachedB === a;
1603
- }
1604
- cache.set(a, b);
1605
- cache.set(b, a);
1606
- const result = areItemsEqual(a, b, state);
1607
- cache.delete(a);
1608
- cache.delete(b);
1609
- return result;
1610
- };
1513
+ return function isCircular(a, b, state) {
1514
+ if (!a || !b || typeof a !== "object" || typeof b !== "object") return areItemsEqual(a, b, state);
1515
+ const { cache } = state;
1516
+ const cachedA = cache.get(a);
1517
+ const cachedB = cache.get(b);
1518
+ if (cachedA && cachedB) return cachedA === b && cachedB === a;
1519
+ cache.set(a, b);
1520
+ cache.set(b, a);
1521
+ const result = areItemsEqual(a, b, state);
1522
+ cache.delete(a);
1523
+ cache.delete(b);
1524
+ return result;
1525
+ };
1611
1526
  }
1527
+ /**
1528
+ * Get the properties to strictly examine, which include both own properties that are
1529
+ * not enumerable and symbol properties.
1530
+ */
1612
1531
  function getStrictProperties(object) {
1613
- return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
1532
+ return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
1614
1533
  }
1615
- const hasOwn = (
1616
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1617
- Object.hasOwn || ((object, property) => hasOwnProperty.call(object, property))
1618
- );
1619
- const PREACT_VNODE = "__v";
1620
- const PREACT_OWNER = "__o";
1621
- const REACT_OWNER = "_owner";
1622
- const { getOwnPropertyDescriptor, keys } = Object;
1623
- const sameValueEqual = (
1624
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1625
- Object.is || function sameValueEqual2(a, b) {
1626
- return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
1627
- }
1628
- );
1534
+ /**
1535
+ * Whether the object contains the property passed as an own property.
1536
+ */
1537
+ var hasOwn = Object.hasOwn || ((object, property) => hasOwnProperty.call(object, property));
1538
+ var PREACT_VNODE = "__v";
1539
+ var PREACT_OWNER = "__o";
1540
+ var REACT_OWNER = "_owner";
1541
+ var { getOwnPropertyDescriptor, keys } = Object;
1542
+ /**
1543
+ * Whether the values passed are equal based on a [SameValue](https://262.ecma-international.org/7.0/#sec-samevalue) basis.
1544
+ * Simplified, this maps to if the two values are referentially equal to one another (`a === b`) or both are `NaN`.
1545
+ *
1546
+ * @note
1547
+ * When available in the environment, this is just a re-export of the global
1548
+ * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) method.
1549
+ */
1550
+ var sameValueEqual = Object.is || function sameValueEqual(a, b) {
1551
+ return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
1552
+ };
1553
+ /**
1554
+ * Whether the values passed are equal based on a
1555
+ * [Strict Equality Comparison](https://262.ecma-international.org/7.0/#sec-strict-equality-comparison) basis.
1556
+ * Simplified, this maps to if the two values are referentially equal to one another (`a === b`).
1557
+ *
1558
+ * @note
1559
+ * This is mainly available as a convenience function, such as being a default when a function to determine equality between
1560
+ * two objects is used.
1561
+ */
1629
1562
  function strictEqual(a, b) {
1630
- return a === b;
1563
+ return a === b;
1631
1564
  }
1565
+ /**
1566
+ * Whether the array buffers are equal in value.
1567
+ */
1632
1568
  function areArrayBuffersEqual(a, b) {
1633
- return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a), new Uint8Array(b));
1569
+ return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a), new Uint8Array(b));
1634
1570
  }
1571
+ /**
1572
+ * Whether the arrays are equal in value.
1573
+ */
1635
1574
  function areArraysEqual(a, b, state) {
1636
- let index = a.length;
1637
- if (b.length !== index) {
1638
- return false;
1639
- }
1640
- while (index-- > 0) {
1641
- if (!state.equals(a[index], b[index], index, index, a, b, state)) {
1642
- return false;
1643
- }
1644
- }
1645
- return true;
1575
+ let index = a.length;
1576
+ if (b.length !== index) return false;
1577
+ while (index-- > 0) if (!state.equals(a[index], b[index], index, index, a, b, state)) return false;
1578
+ return true;
1646
1579
  }
1580
+ /**
1581
+ * Whether the dataviews are equal in value.
1582
+ */
1647
1583
  function areDataViewsEqual(a, b) {
1648
- return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength));
1584
+ return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength));
1649
1585
  }
1586
+ /**
1587
+ * Whether the dates passed are equal in value.
1588
+ */
1650
1589
  function areDatesEqual(a, b) {
1651
- return sameValueEqual(a.getTime(), b.getTime());
1590
+ return sameValueEqual(a.getTime(), b.getTime());
1652
1591
  }
1592
+ /**
1593
+ * Whether the errors passed are equal in value.
1594
+ */
1653
1595
  function areErrorsEqual(a, b) {
1654
- return a.name === b.name && a.message === b.message && a.cause === b.cause && a.stack === b.stack;
1596
+ return a.name === b.name && a.message === b.message && a.cause === b.cause && a.stack === b.stack;
1655
1597
  }
1598
+ /**
1599
+ * Whether the `Map`s are equal in value.
1600
+ */
1656
1601
  function areMapsEqual(a, b, state) {
1657
- const size = a.size;
1658
- if (size !== b.size) {
1659
- return false;
1660
- }
1661
- if (!size) {
1662
- return true;
1663
- }
1664
- const matchedIndices = new Array(size);
1665
- const aIterable = a.entries();
1666
- let aResult;
1667
- let bResult;
1668
- let index = 0;
1669
- while (aResult = aIterable.next()) {
1670
- if (aResult.done) {
1671
- break;
1672
- }
1673
- const bIterable = b.entries();
1674
- let hasMatch = false;
1675
- let matchIndex = 0;
1676
- while (bResult = bIterable.next()) {
1677
- if (bResult.done) {
1678
- break;
1679
- }
1680
- if (matchedIndices[matchIndex]) {
1681
- matchIndex++;
1682
- continue;
1683
- }
1684
- const aEntry = aResult.value;
1685
- const bEntry = bResult.value;
1686
- if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {
1687
- hasMatch = matchedIndices[matchIndex] = true;
1688
- break;
1689
- }
1690
- matchIndex++;
1691
- }
1692
- if (!hasMatch) {
1693
- return false;
1694
- }
1695
- index++;
1696
- }
1697
- return true;
1602
+ const size = a.size;
1603
+ if (size !== b.size) return false;
1604
+ if (!size) return true;
1605
+ const matchedIndices = new Array(size);
1606
+ const aIterable = a.entries();
1607
+ let aResult;
1608
+ let bResult;
1609
+ let index = 0;
1610
+ while (aResult = aIterable.next()) {
1611
+ if (aResult.done) break;
1612
+ const bIterable = b.entries();
1613
+ let hasMatch = false;
1614
+ let matchIndex = 0;
1615
+ while (bResult = bIterable.next()) {
1616
+ if (bResult.done) break;
1617
+ if (matchedIndices[matchIndex]) {
1618
+ matchIndex++;
1619
+ continue;
1620
+ }
1621
+ const aEntry = aResult.value;
1622
+ const bEntry = bResult.value;
1623
+ if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {
1624
+ hasMatch = matchedIndices[matchIndex] = true;
1625
+ break;
1626
+ }
1627
+ matchIndex++;
1628
+ }
1629
+ if (!hasMatch) return false;
1630
+ index++;
1631
+ }
1632
+ return true;
1698
1633
  }
1634
+ /**
1635
+ * Whether the objects are equal in value.
1636
+ */
1699
1637
  function areObjectsEqual(a, b, state) {
1700
- const properties = keys(a);
1701
- let index = properties.length;
1702
- if (keys(b).length !== index) {
1703
- return false;
1704
- }
1705
- while (index-- > 0) {
1706
- if (!isPropertyEqual(a, b, state, properties[index])) {
1707
- return false;
1708
- }
1709
- }
1710
- return true;
1638
+ const properties = keys(a);
1639
+ let index = properties.length;
1640
+ if (keys(b).length !== index) return false;
1641
+ while (index-- > 0) if (!isPropertyEqual(a, b, state, properties[index])) return false;
1642
+ return true;
1711
1643
  }
1644
+ /**
1645
+ * Whether the objects are equal in value with strict property checking.
1646
+ */
1712
1647
  function areObjectsEqualStrict(a, b, state) {
1713
- const properties = getStrictProperties(a);
1714
- let index = properties.length;
1715
- if (getStrictProperties(b).length !== index) {
1716
- return false;
1717
- }
1718
- let property;
1719
- let descriptorA;
1720
- let descriptorB;
1721
- while (index-- > 0) {
1722
- property = properties[index];
1723
- if (!isPropertyEqual(a, b, state, property)) {
1724
- return false;
1725
- }
1726
- descriptorA = getOwnPropertyDescriptor(a, property);
1727
- descriptorB = getOwnPropertyDescriptor(b, property);
1728
- if ((descriptorA || descriptorB) && (!descriptorA || !descriptorB || descriptorA.configurable !== descriptorB.configurable || descriptorA.enumerable !== descriptorB.enumerable || descriptorA.writable !== descriptorB.writable)) {
1729
- return false;
1730
- }
1731
- }
1732
- return true;
1648
+ const properties = getStrictProperties(a);
1649
+ let index = properties.length;
1650
+ if (getStrictProperties(b).length !== index) return false;
1651
+ let property;
1652
+ let descriptorA;
1653
+ let descriptorB;
1654
+ while (index-- > 0) {
1655
+ property = properties[index];
1656
+ if (!isPropertyEqual(a, b, state, property)) return false;
1657
+ descriptorA = getOwnPropertyDescriptor(a, property);
1658
+ descriptorB = getOwnPropertyDescriptor(b, property);
1659
+ if ((descriptorA || descriptorB) && (!descriptorA || !descriptorB || descriptorA.configurable !== descriptorB.configurable || descriptorA.enumerable !== descriptorB.enumerable || descriptorA.writable !== descriptorB.writable)) return false;
1660
+ }
1661
+ return true;
1733
1662
  }
1663
+ /**
1664
+ * Whether the primitive wrappers passed are equal in value.
1665
+ */
1734
1666
  function arePrimitiveWrappersEqual(a, b) {
1735
- return sameValueEqual(a.valueOf(), b.valueOf());
1667
+ return sameValueEqual(a.valueOf(), b.valueOf());
1736
1668
  }
1669
+ /**
1670
+ * Whether the regexps passed are equal in value.
1671
+ */
1737
1672
  function areRegExpsEqual(a, b) {
1738
- return a.source === b.source && a.flags === b.flags;
1673
+ return a.source === b.source && a.flags === b.flags;
1739
1674
  }
1675
+ /**
1676
+ * Whether the `Set`s are equal in value.
1677
+ */
1740
1678
  function areSetsEqual(a, b, state) {
1741
- const size = a.size;
1742
- if (size !== b.size) {
1743
- return false;
1744
- }
1745
- if (!size) {
1746
- return true;
1747
- }
1748
- const matchedIndices = new Array(size);
1749
- const aIterable = a.values();
1750
- let aResult;
1751
- let bResult;
1752
- while (aResult = aIterable.next()) {
1753
- if (aResult.done) {
1754
- break;
1755
- }
1756
- const bIterable = b.values();
1757
- let hasMatch = false;
1758
- let matchIndex = 0;
1759
- while (bResult = bIterable.next()) {
1760
- if (bResult.done) {
1761
- break;
1762
- }
1763
- if (!matchedIndices[matchIndex] && state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {
1764
- hasMatch = matchedIndices[matchIndex] = true;
1765
- break;
1766
- }
1767
- matchIndex++;
1768
- }
1769
- if (!hasMatch) {
1770
- return false;
1771
- }
1772
- }
1773
- return true;
1679
+ const size = a.size;
1680
+ if (size !== b.size) return false;
1681
+ if (!size) return true;
1682
+ const matchedIndices = new Array(size);
1683
+ const aIterable = a.values();
1684
+ let aResult;
1685
+ let bResult;
1686
+ while (aResult = aIterable.next()) {
1687
+ if (aResult.done) break;
1688
+ const bIterable = b.values();
1689
+ let hasMatch = false;
1690
+ let matchIndex = 0;
1691
+ while (bResult = bIterable.next()) {
1692
+ if (bResult.done) break;
1693
+ if (!matchedIndices[matchIndex] && state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {
1694
+ hasMatch = matchedIndices[matchIndex] = true;
1695
+ break;
1696
+ }
1697
+ matchIndex++;
1698
+ }
1699
+ if (!hasMatch) return false;
1700
+ }
1701
+ return true;
1774
1702
  }
1703
+ /**
1704
+ * Whether the TypedArray instances are equal in value.
1705
+ */
1775
1706
  function areTypedArraysEqual(a, b) {
1776
- let index = a.byteLength;
1777
- if (b.byteLength !== index || a.byteOffset !== b.byteOffset) {
1778
- return false;
1779
- }
1780
- while (index-- > 0) {
1781
- if (a[index] !== b[index]) {
1782
- return false;
1783
- }
1784
- }
1785
- return true;
1707
+ let index = a.byteLength;
1708
+ if (b.byteLength !== index || a.byteOffset !== b.byteOffset) return false;
1709
+ while (index-- > 0) if (a[index] !== b[index]) return false;
1710
+ return true;
1786
1711
  }
1712
+ /**
1713
+ * Whether the URL instances are equal in value.
1714
+ */
1787
1715
  function areUrlsEqual(a, b) {
1788
- return a.hostname === b.hostname && a.pathname === b.pathname && a.protocol === b.protocol && a.port === b.port && a.hash === b.hash && a.username === b.username && a.password === b.password;
1716
+ return a.hostname === b.hostname && a.pathname === b.pathname && a.protocol === b.protocol && a.port === b.port && a.hash === b.hash && a.username === b.username && a.password === b.password;
1789
1717
  }
1790
1718
  function isPropertyEqual(a, b, state, property) {
1791
- if ((property === REACT_OWNER || property === PREACT_OWNER || property === PREACT_VNODE) && (a.$$typeof || b.$$typeof)) {
1792
- return true;
1793
- }
1794
- return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
1719
+ if ((property === REACT_OWNER || property === PREACT_OWNER || property === PREACT_VNODE) && (a.$$typeof || b.$$typeof)) return true;
1720
+ return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
1795
1721
  }
1796
- const toString = Object.prototype.toString;
1722
+ var toString = Object.prototype.toString;
1723
+ /**
1724
+ * Create a comparator method based on the type-specific equality comparators passed.
1725
+ */
1797
1726
  function createEqualityComparator(config) {
1798
- const supportedComparatorMap = createSupportedComparatorMap(config);
1799
- const { areArraysEqual: areArraysEqual2, areDatesEqual: areDatesEqual2, areFunctionsEqual, areMapsEqual: areMapsEqual2, areNumbersEqual, areObjectsEqual: areObjectsEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, getUnsupportedCustomComparator } = config;
1800
- return function comparator(a, b, state) {
1801
- if (a === b) {
1802
- return true;
1803
- }
1804
- if (a == null || b == null) {
1805
- return false;
1806
- }
1807
- const type = typeof a;
1808
- if (type !== typeof b) {
1809
- return false;
1810
- }
1811
- if (type !== "object") {
1812
- if (type === "number" || type === "bigint") {
1813
- return areNumbersEqual(a, b, state);
1814
- }
1815
- if (type === "function") {
1816
- return areFunctionsEqual(a, b, state);
1817
- }
1818
- return false;
1819
- }
1820
- const constructor = a.constructor;
1821
- if (constructor !== b.constructor) {
1822
- return false;
1823
- }
1824
- if (constructor === Object) {
1825
- return areObjectsEqual2(a, b, state);
1826
- }
1827
- if (constructor === Array) {
1828
- return areArraysEqual2(a, b, state);
1829
- }
1830
- if (constructor === Date) {
1831
- return areDatesEqual2(a, b, state);
1832
- }
1833
- if (constructor === RegExp) {
1834
- return areRegExpsEqual2(a, b, state);
1835
- }
1836
- if (constructor === Map) {
1837
- return areMapsEqual2(a, b, state);
1838
- }
1839
- if (constructor === Set) {
1840
- return areSetsEqual2(a, b, state);
1841
- }
1842
- if (constructor === Promise) {
1843
- return false;
1844
- }
1845
- if (Array.isArray(a)) {
1846
- return areArraysEqual2(a, b, state);
1847
- }
1848
- const tag = toString.call(a);
1849
- const supportedComparator = supportedComparatorMap[tag];
1850
- if (supportedComparator) {
1851
- return supportedComparator(a, b, state);
1852
- }
1853
- const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a, b, state, tag);
1854
- if (unsupportedCustomComparator) {
1855
- return unsupportedCustomComparator(a, b, state);
1856
- }
1857
- return false;
1858
- };
1727
+ const supportedComparatorMap = createSupportedComparatorMap(config);
1728
+ const { areArraysEqual, areDatesEqual, areFunctionsEqual, areMapsEqual, areNumbersEqual, areObjectsEqual, areRegExpsEqual, areSetsEqual, getUnsupportedCustomComparator } = config;
1729
+ /**
1730
+ * compare the value of the two objects and return true if they are equivalent in values
1731
+ */
1732
+ return function comparator(a, b, state) {
1733
+ if (a === b) return true;
1734
+ if (a == null || b == null) return false;
1735
+ const type = typeof a;
1736
+ if (type !== typeof b) return false;
1737
+ if (type !== "object") {
1738
+ if (type === "number" || type === "bigint") return areNumbersEqual(a, b, state);
1739
+ if (type === "function") return areFunctionsEqual(a, b, state);
1740
+ return false;
1741
+ }
1742
+ const constructor = a.constructor;
1743
+ if (constructor !== b.constructor) return false;
1744
+ if (constructor === Object) return areObjectsEqual(a, b, state);
1745
+ if (constructor === Array) return areArraysEqual(a, b, state);
1746
+ if (constructor === Date) return areDatesEqual(a, b, state);
1747
+ if (constructor === RegExp) return areRegExpsEqual(a, b, state);
1748
+ if (constructor === Map) return areMapsEqual(a, b, state);
1749
+ if (constructor === Set) return areSetsEqual(a, b, state);
1750
+ if (constructor === Promise) return false;
1751
+ if (Array.isArray(a)) return areArraysEqual(a, b, state);
1752
+ const tag = toString.call(a);
1753
+ const supportedComparator = supportedComparatorMap[tag];
1754
+ if (supportedComparator) return supportedComparator(a, b, state);
1755
+ const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a, b, state, tag);
1756
+ if (unsupportedCustomComparator) return unsupportedCustomComparator(a, b, state);
1757
+ return false;
1758
+ };
1859
1759
  }
1760
+ /**
1761
+ * Create the configuration object used for building comparators.
1762
+ */
1860
1763
  function createEqualityComparatorConfig({ circular, createCustomConfig, strict }) {
1861
- let config = {
1862
- areArrayBuffersEqual,
1863
- areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
1864
- areDataViewsEqual,
1865
- areDatesEqual,
1866
- areErrorsEqual,
1867
- areFunctionsEqual: strictEqual,
1868
- areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
1869
- areNumbersEqual: sameValueEqual,
1870
- areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,
1871
- arePrimitiveWrappersEqual,
1872
- areRegExpsEqual,
1873
- areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,
1874
- areTypedArraysEqual: strict ? combineComparators(areTypedArraysEqual, areObjectsEqualStrict) : areTypedArraysEqual,
1875
- areUrlsEqual,
1876
- getUnsupportedCustomComparator: void 0
1877
- };
1878
- if (createCustomConfig) {
1879
- config = Object.assign({}, config, createCustomConfig(config));
1880
- }
1881
- if (circular) {
1882
- const areArraysEqual2 = createIsCircular(config.areArraysEqual);
1883
- const areMapsEqual2 = createIsCircular(config.areMapsEqual);
1884
- const areObjectsEqual2 = createIsCircular(config.areObjectsEqual);
1885
- const areSetsEqual2 = createIsCircular(config.areSetsEqual);
1886
- config = Object.assign({}, config, {
1887
- areArraysEqual: areArraysEqual2,
1888
- areMapsEqual: areMapsEqual2,
1889
- areObjectsEqual: areObjectsEqual2,
1890
- areSetsEqual: areSetsEqual2
1891
- });
1892
- }
1893
- return config;
1764
+ let config = {
1765
+ areArrayBuffersEqual,
1766
+ areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
1767
+ areDataViewsEqual,
1768
+ areDatesEqual,
1769
+ areErrorsEqual,
1770
+ areFunctionsEqual: strictEqual,
1771
+ areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
1772
+ areNumbersEqual: sameValueEqual,
1773
+ areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,
1774
+ arePrimitiveWrappersEqual,
1775
+ areRegExpsEqual,
1776
+ areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,
1777
+ areTypedArraysEqual: strict ? combineComparators(areTypedArraysEqual, areObjectsEqualStrict) : areTypedArraysEqual,
1778
+ areUrlsEqual,
1779
+ getUnsupportedCustomComparator: void 0
1780
+ };
1781
+ if (createCustomConfig) config = Object.assign({}, config, createCustomConfig(config));
1782
+ if (circular) {
1783
+ const areArraysEqual = createIsCircular(config.areArraysEqual);
1784
+ const areMapsEqual = createIsCircular(config.areMapsEqual);
1785
+ const areObjectsEqual = createIsCircular(config.areObjectsEqual);
1786
+ const areSetsEqual = createIsCircular(config.areSetsEqual);
1787
+ config = Object.assign({}, config, {
1788
+ areArraysEqual,
1789
+ areMapsEqual,
1790
+ areObjectsEqual,
1791
+ areSetsEqual
1792
+ });
1793
+ }
1794
+ return config;
1894
1795
  }
1796
+ /**
1797
+ * Default equality comparator pass-through, used as the standard `isEqual` creator for
1798
+ * use inside the built comparator.
1799
+ */
1895
1800
  function createInternalEqualityComparator(compare) {
1896
- return function(a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {
1897
- return compare(a, b, state);
1898
- };
1801
+ return function(a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {
1802
+ return compare(a, b, state);
1803
+ };
1899
1804
  }
1805
+ /**
1806
+ * Create the `isEqual` function used by the consuming application.
1807
+ */
1900
1808
  function createIsEqual({ circular, comparator, createState, equals, strict }) {
1901
- if (createState) {
1902
- return function isEqual(a, b) {
1903
- const { cache = circular ? /* @__PURE__ */ new WeakMap() : void 0, meta } = createState();
1904
- return comparator(a, b, {
1905
- cache,
1906
- equals,
1907
- meta,
1908
- strict
1909
- });
1910
- };
1911
- }
1912
- if (circular) {
1913
- return function isEqual(a, b) {
1914
- return comparator(a, b, {
1915
- cache: /* @__PURE__ */ new WeakMap(),
1916
- equals,
1917
- meta: void 0,
1918
- strict
1919
- });
1920
- };
1921
- }
1922
- const state = {
1923
- cache: void 0,
1924
- equals,
1925
- meta: void 0,
1926
- strict
1927
- };
1928
- return function isEqual(a, b) {
1929
- return comparator(a, b, state);
1930
- };
1809
+ if (createState) return function isEqual(a, b) {
1810
+ const { cache = circular ? /* @__PURE__ */ new WeakMap() : void 0, meta } = createState();
1811
+ return comparator(a, b, {
1812
+ cache,
1813
+ equals,
1814
+ meta,
1815
+ strict
1816
+ });
1817
+ };
1818
+ if (circular) return function isEqual(a, b) {
1819
+ return comparator(a, b, {
1820
+ cache: /* @__PURE__ */ new WeakMap(),
1821
+ equals,
1822
+ meta: void 0,
1823
+ strict
1824
+ });
1825
+ };
1826
+ const state = {
1827
+ cache: void 0,
1828
+ equals,
1829
+ meta: void 0,
1830
+ strict
1831
+ };
1832
+ return function isEqual(a, b) {
1833
+ return comparator(a, b, state);
1834
+ };
1931
1835
  }
1932
- function createSupportedComparatorMap({ areArrayBuffersEqual: areArrayBuffersEqual2, areArraysEqual: areArraysEqual2, areDataViewsEqual: areDataViewsEqual2, areDatesEqual: areDatesEqual2, areErrorsEqual: areErrorsEqual2, areFunctionsEqual, areMapsEqual: areMapsEqual2, areNumbersEqual, areObjectsEqual: areObjectsEqual2, arePrimitiveWrappersEqual: arePrimitiveWrappersEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, areTypedArraysEqual: areTypedArraysEqual2, areUrlsEqual: areUrlsEqual2 }) {
1933
- return {
1934
- "[object Arguments]": areObjectsEqual2,
1935
- "[object Array]": areArraysEqual2,
1936
- "[object ArrayBuffer]": areArrayBuffersEqual2,
1937
- "[object AsyncGeneratorFunction]": areFunctionsEqual,
1938
- "[object BigInt]": areNumbersEqual,
1939
- "[object BigInt64Array]": areTypedArraysEqual2,
1940
- "[object BigUint64Array]": areTypedArraysEqual2,
1941
- "[object Boolean]": arePrimitiveWrappersEqual2,
1942
- "[object DataView]": areDataViewsEqual2,
1943
- "[object Date]": areDatesEqual2,
1944
- // If an error tag, it should be tested explicitly. Like RegExp, the properties are not
1945
- // enumerable, and therefore will give false positives if tested like a standard object.
1946
- "[object Error]": areErrorsEqual2,
1947
- "[object Float16Array]": areTypedArraysEqual2,
1948
- "[object Float32Array]": areTypedArraysEqual2,
1949
- "[object Float64Array]": areTypedArraysEqual2,
1950
- "[object Function]": areFunctionsEqual,
1951
- "[object GeneratorFunction]": areFunctionsEqual,
1952
- "[object Int8Array]": areTypedArraysEqual2,
1953
- "[object Int16Array]": areTypedArraysEqual2,
1954
- "[object Int32Array]": areTypedArraysEqual2,
1955
- "[object Map]": areMapsEqual2,
1956
- "[object Number]": arePrimitiveWrappersEqual2,
1957
- "[object Object]": (a, b, state) => (
1958
- // The exception for value comparison is custom `Promise`-like class instances. These should
1959
- // be treated the same as standard `Promise` objects, which means strict equality, and if
1960
- // it reaches this point then that strict equality comparison has already failed.
1961
- typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a, b, state)
1962
- ),
1963
- // For RegExp, the properties are not enumerable, and therefore will give false positives if
1964
- // tested like a standard object.
1965
- "[object RegExp]": areRegExpsEqual2,
1966
- "[object Set]": areSetsEqual2,
1967
- "[object String]": arePrimitiveWrappersEqual2,
1968
- "[object URL]": areUrlsEqual2,
1969
- "[object Uint8Array]": areTypedArraysEqual2,
1970
- "[object Uint8ClampedArray]": areTypedArraysEqual2,
1971
- "[object Uint16Array]": areTypedArraysEqual2,
1972
- "[object Uint32Array]": areTypedArraysEqual2
1973
- };
1836
+ /**
1837
+ * Create a map of `toString()` values to their respective handlers for `tag`-based lookups.
1838
+ */
1839
+ function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areNumbersEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual }) {
1840
+ return {
1841
+ "[object Arguments]": areObjectsEqual,
1842
+ "[object Array]": areArraysEqual,
1843
+ "[object ArrayBuffer]": areArrayBuffersEqual,
1844
+ "[object AsyncGeneratorFunction]": areFunctionsEqual,
1845
+ "[object BigInt]": areNumbersEqual,
1846
+ "[object BigInt64Array]": areTypedArraysEqual,
1847
+ "[object BigUint64Array]": areTypedArraysEqual,
1848
+ "[object Boolean]": arePrimitiveWrappersEqual,
1849
+ "[object DataView]": areDataViewsEqual,
1850
+ "[object Date]": areDatesEqual,
1851
+ "[object Error]": areErrorsEqual,
1852
+ "[object Float16Array]": areTypedArraysEqual,
1853
+ "[object Float32Array]": areTypedArraysEqual,
1854
+ "[object Float64Array]": areTypedArraysEqual,
1855
+ "[object Function]": areFunctionsEqual,
1856
+ "[object GeneratorFunction]": areFunctionsEqual,
1857
+ "[object Int8Array]": areTypedArraysEqual,
1858
+ "[object Int16Array]": areTypedArraysEqual,
1859
+ "[object Int32Array]": areTypedArraysEqual,
1860
+ "[object Map]": areMapsEqual,
1861
+ "[object Number]": arePrimitiveWrappersEqual,
1862
+ "[object Object]": (a, b, state) => typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual(a, b, state),
1863
+ "[object RegExp]": areRegExpsEqual,
1864
+ "[object Set]": areSetsEqual,
1865
+ "[object String]": arePrimitiveWrappersEqual,
1866
+ "[object URL]": areUrlsEqual,
1867
+ "[object Uint8Array]": areTypedArraysEqual,
1868
+ "[object Uint8ClampedArray]": areTypedArraysEqual,
1869
+ "[object Uint16Array]": areTypedArraysEqual,
1870
+ "[object Uint32Array]": areTypedArraysEqual
1871
+ };
1974
1872
  }
1975
- const deepEqual = createCustomEqual();
1873
+ /**
1874
+ * Whether the items passed are deeply-equal in value.
1875
+ */
1876
+ var deepEqual = createCustomEqual();
1976
1877
  createCustomEqual({ strict: true });
1977
1878
  createCustomEqual({ circular: true });
1978
1879
  createCustomEqual({
1979
- circular: true,
1980
- strict: true
1981
- });
1982
- createCustomEqual({
1983
- createInternalComparator: () => sameValueEqual
1880
+ circular: true,
1881
+ strict: true
1984
1882
  });
1883
+ createCustomEqual({ createInternalComparator: () => sameValueEqual });
1985
1884
  createCustomEqual({
1986
- strict: true,
1987
- createInternalComparator: () => sameValueEqual
1885
+ strict: true,
1886
+ createInternalComparator: () => sameValueEqual
1988
1887
  });
1989
1888
  createCustomEqual({
1990
- circular: true,
1991
- createInternalComparator: () => sameValueEqual
1889
+ circular: true,
1890
+ createInternalComparator: () => sameValueEqual
1992
1891
  });
1993
1892
  createCustomEqual({
1994
- circular: true,
1995
- createInternalComparator: () => sameValueEqual,
1996
- strict: true
1893
+ circular: true,
1894
+ createInternalComparator: () => sameValueEqual,
1895
+ strict: true
1997
1896
  });
1897
+ /**
1898
+ * Create a custom equality comparison method.
1899
+ *
1900
+ * This can be done to create very targeted comparisons in extreme hot-path scenarios
1901
+ * where the standard methods are not performant enough, but can also be used to provide
1902
+ * support for legacy environments that do not support expected features like
1903
+ * `RegExp.prototype.flags` out of the box.
1904
+ */
1998
1905
  function createCustomEqual(options = {}) {
1999
- const { circular = false, createInternalComparator: createCustomInternalComparator, createState, strict = false } = options;
2000
- const config = createEqualityComparatorConfig(options);
2001
- const comparator = createEqualityComparator(config);
2002
- const equals = createCustomInternalComparator ? createCustomInternalComparator(comparator) : createInternalEqualityComparator(comparator);
2003
- return createIsEqual({ circular, comparator, createState, equals, strict });
1906
+ const { circular = false, createInternalComparator: createCustomInternalComparator, createState, strict = false } = options;
1907
+ const comparator = createEqualityComparator(createEqualityComparatorConfig(options));
1908
+ return createIsEqual({
1909
+ circular,
1910
+ comparator,
1911
+ createState,
1912
+ equals: createCustomInternalComparator ? createCustomInternalComparator(comparator) : createInternalEqualityComparator(comparator),
1913
+ strict
1914
+ });
2004
1915
  }
2005
- const defaultRect = {
2006
- x: 0,
2007
- y: 0,
2008
- width: 0,
2009
- height: 0,
2010
- top: 0,
2011
- left: 0,
2012
- bottom: 0,
2013
- right: 0
2014
- };
2015
- const useLocalMeasure = () => {
2016
- const $ = c(6);
2017
- const [node, setNode] = useState(null);
2018
- let t0;
2019
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2020
- t0 = (el) => setNode(el);
2021
- $[0] = t0;
2022
- } else {
2023
- t0 = $[0];
2024
- }
2025
- const ref = t0;
2026
- const [rect, setRect] = useState(defaultRect);
2027
- let t1;
2028
- let t2;
2029
- if ($[1] !== node) {
2030
- t1 = () => {
2031
- if (typeof window === "undefined" || typeof ResizeObserver === "undefined") {
2032
- return;
2033
- }
2034
- if (!node) {
2035
- return;
2036
- }
2037
- const observer = new ResizeObserver((entries) => {
2038
- const entry = entries[0];
2039
- if (!entry?.contentRect) {
2040
- return;
2041
- }
2042
- const {
2043
- x,
2044
- y,
2045
- width,
2046
- height,
2047
- top,
2048
- left,
2049
- bottom,
2050
- right
2051
- } = entry.contentRect;
2052
- setRect({
2053
- x,
2054
- y,
2055
- width,
2056
- height,
2057
- top,
2058
- left,
2059
- bottom,
2060
- right
2061
- });
2062
- });
2063
- observer.observe(node);
2064
- return () => observer.disconnect();
2065
- };
2066
- t2 = [node];
2067
- $[1] = node;
2068
- $[2] = t1;
2069
- $[3] = t2;
2070
- } else {
2071
- t1 = $[2];
2072
- t2 = $[3];
2073
- }
2074
- useLayoutEffect(t1, t2);
2075
- let t3;
2076
- if ($[4] !== rect) {
2077
- t3 = [ref, rect];
2078
- $[4] = rect;
2079
- $[5] = t3;
2080
- } else {
2081
- t3 = $[5];
2082
- }
2083
- return t3;
2084
- };
2085
- const DEFAULT_THROTTLE_TIME = 16;
2086
- const useThrottledMeasure = (t0) => {
2087
- const $ = c(10);
2088
- const throttleDuration = t0 === void 0 ? DEFAULT_THROTTLE_TIME : t0;
2089
- const hasInitialMeasure = useRef(false);
2090
- const [ref, measuredRect] = useLocalMeasure();
2091
- const [rect, setRect] = useState(_temp$1);
2092
- let t1;
2093
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2094
- t1 = (newRect) => {
2095
- setRect((current) => deepEqual(current, newRect) ? current : newRect);
2096
- };
2097
- $[0] = t1;
2098
- } else {
2099
- t1 = $[0];
2100
- }
2101
- let t2;
2102
- if ($[1] !== throttleDuration) {
2103
- t2 = throttle$1(t1, throttleDuration, {
2104
- leading: true,
2105
- trailing: true
2106
- });
2107
- $[1] = throttleDuration;
2108
- $[2] = t2;
2109
- } else {
2110
- t2 = $[2];
2111
- }
2112
- const throttledSetRect = t2;
2113
- let t3;
2114
- let t4;
2115
- if ($[3] !== measuredRect || $[4] !== throttledSetRect) {
2116
- t3 = () => {
2117
- if (measuredRect.width > 0 && !hasInitialMeasure.current) {
2118
- hasInitialMeasure.current = true;
2119
- setRect((current_0) => deepEqual(current_0, measuredRect) ? current_0 : measuredRect);
2120
- return;
2121
- }
2122
- throttledSetRect(measuredRect);
2123
- return () => {
2124
- throttledSetRect.cancel();
2125
- };
2126
- };
2127
- t4 = [measuredRect, throttledSetRect];
2128
- $[3] = measuredRect;
2129
- $[4] = throttledSetRect;
2130
- $[5] = t3;
2131
- $[6] = t4;
2132
- } else {
2133
- t3 = $[5];
2134
- t4 = $[6];
2135
- }
2136
- useEffect(t3, t4);
2137
- let t5;
2138
- if ($[7] !== rect || $[8] !== ref) {
2139
- t5 = [ref, rect];
2140
- $[7] = rect;
2141
- $[8] = ref;
2142
- $[9] = t5;
2143
- } else {
2144
- t5 = $[9];
2145
- }
2146
- return t5;
1916
+ //#endregion
1917
+ //#region src/hooks/useThrottledMeasure.ts
1918
+ var defaultRect = {
1919
+ x: 0,
1920
+ y: 0,
1921
+ width: 0,
1922
+ height: 0,
1923
+ top: 0,
1924
+ left: 0,
1925
+ bottom: 0,
1926
+ right: 0
1927
+ };
1928
+ var useLocalMeasure = () => {
1929
+ const $ = c(6);
1930
+ const [node, setNode] = useState(null);
1931
+ let t0;
1932
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1933
+ t0 = (el) => setNode(el);
1934
+ $[0] = t0;
1935
+ } else t0 = $[0];
1936
+ const ref = t0;
1937
+ const [rect, setRect] = useState(defaultRect);
1938
+ let t1;
1939
+ let t2;
1940
+ if ($[1] !== node) {
1941
+ t1 = () => {
1942
+ if (typeof window === "undefined" || typeof ResizeObserver === "undefined") return;
1943
+ if (!node) return;
1944
+ const observer = new ResizeObserver((entries) => {
1945
+ const entry = entries[0];
1946
+ if (!entry?.contentRect) return;
1947
+ const { x, y, width, height, top, left, bottom, right } = entry.contentRect;
1948
+ setRect({
1949
+ x,
1950
+ y,
1951
+ width,
1952
+ height,
1953
+ top,
1954
+ left,
1955
+ bottom,
1956
+ right
1957
+ });
1958
+ });
1959
+ observer.observe(node);
1960
+ return () => observer.disconnect();
1961
+ };
1962
+ t2 = [node];
1963
+ $[1] = node;
1964
+ $[2] = t1;
1965
+ $[3] = t2;
1966
+ } else {
1967
+ t1 = $[2];
1968
+ t2 = $[3];
1969
+ }
1970
+ useLayoutEffect(t1, t2);
1971
+ let t3;
1972
+ if ($[4] !== rect) {
1973
+ t3 = [ref, rect];
1974
+ $[4] = rect;
1975
+ $[5] = t3;
1976
+ } else t3 = $[5];
1977
+ return t3;
1978
+ };
1979
+ var DEFAULT_THROTTLE_TIME = 16;
1980
+ var useThrottledMeasure = (t0) => {
1981
+ const $ = c(10);
1982
+ const throttleDuration = t0 === void 0 ? DEFAULT_THROTTLE_TIME : t0;
1983
+ const hasInitialMeasure = useRef(false);
1984
+ const [ref, measuredRect] = useLocalMeasure();
1985
+ const [rect, setRect] = useState(_temp$1);
1986
+ let t1;
1987
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1988
+ t1 = (newRect) => {
1989
+ setRect((current) => deepEqual(current, newRect) ? current : newRect);
1990
+ };
1991
+ $[0] = t1;
1992
+ } else t1 = $[0];
1993
+ let t2;
1994
+ if ($[1] !== throttleDuration) {
1995
+ t2 = (0, import_throttle.default)(t1, throttleDuration, {
1996
+ leading: true,
1997
+ trailing: true
1998
+ });
1999
+ $[1] = throttleDuration;
2000
+ $[2] = t2;
2001
+ } else t2 = $[2];
2002
+ const throttledSetRect = t2;
2003
+ let t3;
2004
+ let t4;
2005
+ if ($[3] !== measuredRect || $[4] !== throttledSetRect) {
2006
+ t3 = () => {
2007
+ if (measuredRect.width > 0 && !hasInitialMeasure.current) {
2008
+ hasInitialMeasure.current = true;
2009
+ setRect((current_0) => deepEqual(current_0, measuredRect) ? current_0 : measuredRect);
2010
+ return;
2011
+ }
2012
+ throttledSetRect(measuredRect);
2013
+ return () => {
2014
+ throttledSetRect.cancel();
2015
+ };
2016
+ };
2017
+ t4 = [measuredRect, throttledSetRect];
2018
+ $[3] = measuredRect;
2019
+ $[4] = throttledSetRect;
2020
+ $[5] = t3;
2021
+ $[6] = t4;
2022
+ } else {
2023
+ t3 = $[5];
2024
+ t4 = $[6];
2025
+ }
2026
+ useEffect(t3, t4);
2027
+ let t5;
2028
+ if ($[7] !== rect || $[8] !== ref) {
2029
+ t5 = [ref, rect];
2030
+ $[7] = rect;
2031
+ $[8] = ref;
2032
+ $[9] = t5;
2033
+ } else t5 = $[9];
2034
+ return t5;
2147
2035
  };
2148
2036
  function _temp$1() {
2149
- return defaultRect;
2037
+ return defaultRect;
2150
2038
  }
2151
- const defaultState = {
2152
- statusCode: 500,
2153
- title: "Something went wrong",
2154
- message: "We couldn't render this route. Please try again shortly."
2155
- };
2156
- const toSsrErrorState = (error) => {
2157
- if (isRouteErrorResponse(error)) {
2158
- const data = error.data;
2159
- const message = typeof data === "string" ? data : data?.message || defaultState.message;
2160
- let details;
2161
- if (env.DEV && data && typeof data !== "string") {
2162
- try {
2163
- details = JSON.stringify(data, null, 2);
2164
- } catch {
2165
- details = void 0;
2166
- }
2167
- }
2168
- return {
2169
- statusCode: error.status ?? defaultState.statusCode,
2170
- title: error.statusText || defaultState.title,
2171
- message,
2172
- details
2173
- };
2174
- }
2175
- if (error instanceof Error) {
2176
- return {
2177
- statusCode: defaultState.statusCode,
2178
- title: defaultState.title,
2179
- message: error.message || defaultState.message,
2180
- details: globalThis.__rb_env__.DEV ? error.stack ?? error.message : void 0
2181
- };
2182
- }
2183
- if (typeof error === "string") {
2184
- return {
2185
- statusCode: defaultState.statusCode,
2186
- title: defaultState.title,
2187
- message: error
2188
- };
2189
- }
2190
- return defaultState;
2191
- };
2192
- const RouteErrorBoundary = (t0) => {
2193
- const $ = c(5);
2194
- const {
2195
- renderErrorExtra
2196
- } = t0;
2197
- const routeError = useRouteError();
2198
- let t1;
2199
- if ($[0] !== routeError) {
2200
- t1 = toSsrErrorState(routeError);
2201
- $[0] = routeError;
2202
- $[1] = t1;
2203
- } else {
2204
- t1 = $[1];
2205
- }
2206
- const state = t1;
2207
- let t2;
2208
- if ($[2] !== renderErrorExtra || $[3] !== state) {
2209
- t2 = /* @__PURE__ */ jsx(SsrErrorFallback, { state, renderErrorExtra });
2210
- $[2] = renderErrorExtra;
2211
- $[3] = state;
2212
- $[4] = t2;
2213
- } else {
2214
- t2 = $[4];
2215
- }
2216
- return t2;
2217
- };
2218
- const listNotifications = async (input = {}) => {
2219
- const result = await apiClient.post("/api/rb/notifications", input);
2220
- if (!result?.ok) {
2221
- throw new Error(result?.error || "Failed to load notifications");
2222
- }
2223
- return {
2224
- notifications: Array.isArray(result.notifications) ? result.notifications : [],
2225
- unreadCount: Number.isFinite(result.unreadCount) ? Math.max(0, Math.floor(result.unreadCount ?? 0)) : 0,
2226
- unseenCount: Number.isFinite(result.unseenCount) ? Math.max(0, Math.floor(result.unseenCount ?? 0)) : 0
2227
- };
2228
- };
2229
- const markNotificationRead = async (notificationId) => {
2230
- const id = notificationId.trim();
2231
- if (!id) throw new Error("notificationId is required");
2232
- const result = await apiClient.post(`/api/rb/notifications/${encodeURIComponent(id)}/read`, {});
2233
- if (!result?.ok) {
2234
- throw new Error(result?.error || "Failed to mark notification read");
2235
- }
2236
- };
2237
- const archiveNotification = async (notificationId) => {
2238
- const id = notificationId.trim();
2239
- if (!id) throw new Error("notificationId is required");
2240
- const result = await apiClient.post(`/api/rb/notifications/${encodeURIComponent(id)}/archive`, {});
2241
- if (!result?.ok) {
2242
- throw new Error(result?.error || "Failed to archive notification");
2243
- }
2244
- };
2245
- const markAllNotificationsRead = async () => {
2246
- const result = await apiClient.post("/api/rb/notifications/mark-all-read", {});
2247
- if (!result?.ok) {
2248
- throw new Error(result?.error || "Failed to mark all notifications read");
2249
- }
2250
- };
2251
- const getNotificationSettings = async () => {
2252
- const result = await apiClient.get("/api/rb/notifications/settings", {});
2253
- if (!result?.ok) {
2254
- throw new Error(result?.error || "Failed to load notification settings");
2255
- }
2256
- return result.settings ?? {
2257
- digestFrequency: "weekly",
2258
- topicPreferences: []
2259
- };
2260
- };
2261
- const updateNotificationSettings = async (partial) => {
2262
- const result = await apiClient.put("/api/rb/notifications/settings", partial);
2263
- if (!result?.ok) {
2264
- throw new Error(result?.error || "Failed to update notification settings");
2265
- }
2266
- return result.settings ?? {
2267
- digestFrequency: "weekly",
2268
- topicPreferences: []
2269
- };
2270
- };
2271
- const runNotificationDigest = async ({
2272
- force = false
2273
- } = {}) => {
2274
- const result = await apiClient.post("/api/rb/notifications/digest/run", {
2275
- force
2276
- });
2277
- if (!result?.ok) {
2278
- throw new Error(result?.error || "Failed to run digest");
2279
- }
2280
- return {
2281
- sent: result.sent === true,
2282
- skippedReason: result.skippedReason
2283
- };
2284
- };
2285
- const NotificationsRealtimeContext = createContext(null);
2286
- const toIso = (value) => {
2287
- if (value instanceof Date) return value.toISOString();
2288
- if (typeof value === "string") return value;
2289
- return void 0;
2290
- };
2291
- const toNotificationItem = (doc) => {
2292
- const id = typeof doc._id === "string" ? doc._id : String(doc._id ?? "");
2293
- if (!id) return null;
2294
- return {
2295
- id,
2296
- topic: typeof doc.topic === "string" ? doc.topic : void 0,
2297
- title: typeof doc.title === "string" ? doc.title : "",
2298
- body: typeof doc.body === "string" ? doc.body : void 0,
2299
- url: typeof doc.url === "string" ? doc.url : void 0,
2300
- createdAt: toIso(doc.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
2301
- seenAt: toIso(doc.seenAt),
2302
- readAt: toIso(doc.readAt),
2303
- archivedAt: toIso(doc.archivedAt),
2304
- metadata: typeof doc.metadata === "object" && doc.metadata !== null ? doc.metadata : void 0
2305
- };
2306
- };
2307
- const buildDisabledTopics = (settings) => {
2308
- const raw = settings?.topicPreferences;
2309
- if (!Array.isArray(raw) || raw.length === 0) return [];
2310
- return raw.map((pref) => {
2311
- if (!pref || typeof pref !== "object") return null;
2312
- const topic = typeof pref.topic === "string" ? pref.topic.trim() : "";
2313
- if (!topic) return null;
2314
- return pref.inApp === false ? topic : null;
2315
- }).filter((topic) => Boolean(topic));
2039
+ //#endregion
2040
+ //#region src/components/RouteErrorBoundary.tsx
2041
+ var defaultState = {
2042
+ statusCode: 500,
2043
+ title: "Something went wrong",
2044
+ message: "We couldn't render this route. Please try again shortly."
2045
+ };
2046
+ var toSsrErrorState = (error) => {
2047
+ if (isRouteErrorResponse(error)) {
2048
+ const data = error.data;
2049
+ const message = typeof data === "string" ? data : data?.message || defaultState.message;
2050
+ let details;
2051
+ if (env.DEV && data && typeof data !== "string") try {
2052
+ details = JSON.stringify(data, null, 2);
2053
+ } catch {
2054
+ details = void 0;
2055
+ }
2056
+ return {
2057
+ statusCode: error.status ?? defaultState.statusCode,
2058
+ title: error.statusText || defaultState.title,
2059
+ message,
2060
+ details
2061
+ };
2062
+ }
2063
+ if (error instanceof Error) return {
2064
+ statusCode: defaultState.statusCode,
2065
+ title: defaultState.title,
2066
+ message: error.message || defaultState.message,
2067
+ details: globalThis.__rb_env__.DEV ? error.stack ?? error.message : void 0
2068
+ };
2069
+ if (typeof error === "string") return {
2070
+ statusCode: defaultState.statusCode,
2071
+ title: defaultState.title,
2072
+ message: error
2073
+ };
2074
+ return defaultState;
2075
+ };
2076
+ var RouteErrorBoundary = (t0) => {
2077
+ const $ = c(5);
2078
+ const { renderErrorExtra } = t0;
2079
+ const routeError = useRouteError();
2080
+ let t1;
2081
+ if ($[0] !== routeError) {
2082
+ t1 = toSsrErrorState(routeError);
2083
+ $[0] = routeError;
2084
+ $[1] = t1;
2085
+ } else t1 = $[1];
2086
+ const state = t1;
2087
+ let t2;
2088
+ if ($[2] !== renderErrorExtra || $[3] !== state) {
2089
+ t2 = /* @__PURE__ */ jsx(SsrErrorFallback, {
2090
+ state,
2091
+ renderErrorExtra
2092
+ });
2093
+ $[2] = renderErrorExtra;
2094
+ $[3] = state;
2095
+ $[4] = t2;
2096
+ } else t2 = $[4];
2097
+ return t2;
2098
+ };
2099
+ //#endregion
2100
+ //#region src/notifications.ts
2101
+ var listNotifications = async (input = {}) => {
2102
+ const result = await apiClient.post("/api/rb/notifications", input);
2103
+ if (!result?.ok) throw new Error(result?.error || "Failed to load notifications");
2104
+ return {
2105
+ notifications: Array.isArray(result.notifications) ? result.notifications : [],
2106
+ unreadCount: Number.isFinite(result.unreadCount) ? Math.max(0, Math.floor(result.unreadCount ?? 0)) : 0,
2107
+ unseenCount: Number.isFinite(result.unseenCount) ? Math.max(0, Math.floor(result.unseenCount ?? 0)) : 0
2108
+ };
2109
+ };
2110
+ var markNotificationRead = async (notificationId) => {
2111
+ const id = notificationId.trim();
2112
+ if (!id) throw new Error("notificationId is required");
2113
+ const result = await apiClient.post(`/api/rb/notifications/${encodeURIComponent(id)}/read`, {});
2114
+ if (!result?.ok) throw new Error(result?.error || "Failed to mark notification read");
2115
+ };
2116
+ var archiveNotification = async (notificationId) => {
2117
+ const id = notificationId.trim();
2118
+ if (!id) throw new Error("notificationId is required");
2119
+ const result = await apiClient.post(`/api/rb/notifications/${encodeURIComponent(id)}/archive`, {});
2120
+ if (!result?.ok) throw new Error(result?.error || "Failed to archive notification");
2121
+ };
2122
+ var markAllNotificationsRead = async () => {
2123
+ const result = await apiClient.post("/api/rb/notifications/mark-all-read", {});
2124
+ if (!result?.ok) throw new Error(result?.error || "Failed to mark all notifications read");
2125
+ };
2126
+ var getNotificationSettings = async () => {
2127
+ const result = await apiClient.get("/api/rb/notifications/settings", {});
2128
+ if (!result?.ok) throw new Error(result?.error || "Failed to load notification settings");
2129
+ return result.settings ?? {
2130
+ digestFrequency: "weekly",
2131
+ topicPreferences: []
2132
+ };
2133
+ };
2134
+ var updateNotificationSettings = async (partial) => {
2135
+ const result = await apiClient.put("/api/rb/notifications/settings", partial);
2136
+ if (!result?.ok) throw new Error(result?.error || "Failed to update notification settings");
2137
+ return result.settings ?? {
2138
+ digestFrequency: "weekly",
2139
+ topicPreferences: []
2140
+ };
2141
+ };
2142
+ var runNotificationDigest = async ({ force = false } = {}) => {
2143
+ const result = await apiClient.post("/api/rb/notifications/digest/run", { force });
2144
+ if (!result?.ok) throw new Error(result?.error || "Failed to run digest");
2145
+ return {
2146
+ sent: result.sent === true,
2147
+ skippedReason: result.skippedReason
2148
+ };
2149
+ };
2150
+ //#endregion
2151
+ //#region src/notificationsRealtime.tsx
2152
+ var NotificationsRealtimeContext = createContext(null);
2153
+ var toIso = (value) => {
2154
+ if (value instanceof Date) return value.toISOString();
2155
+ if (typeof value === "string") return value;
2156
+ };
2157
+ var toNotificationItem = (doc) => {
2158
+ const id = typeof doc._id === "string" ? doc._id : String(doc._id ?? "");
2159
+ if (!id) return null;
2160
+ return {
2161
+ id,
2162
+ topic: typeof doc.topic === "string" ? doc.topic : void 0,
2163
+ title: typeof doc.title === "string" ? doc.title : "",
2164
+ body: typeof doc.body === "string" ? doc.body : void 0,
2165
+ url: typeof doc.url === "string" ? doc.url : void 0,
2166
+ createdAt: toIso(doc.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
2167
+ seenAt: toIso(doc.seenAt),
2168
+ readAt: toIso(doc.readAt),
2169
+ archivedAt: toIso(doc.archivedAt),
2170
+ metadata: typeof doc.metadata === "object" && doc.metadata !== null ? doc.metadata : void 0
2171
+ };
2172
+ };
2173
+ var buildDisabledTopics = (settings) => {
2174
+ const raw = settings?.topicPreferences;
2175
+ if (!Array.isArray(raw) || raw.length === 0) return [];
2176
+ return raw.map((pref) => {
2177
+ if (!pref || typeof pref !== "object") return null;
2178
+ const topic = typeof pref.topic === "string" ? pref.topic.trim() : "";
2179
+ if (!topic) return null;
2180
+ return pref.inApp === false ? topic : null;
2181
+ }).filter((topic) => Boolean(topic));
2316
2182
  };
2317
2183
  function NotificationsRealtimeProvider(t0) {
2318
- const $ = c(47);
2319
- const {
2320
- userId,
2321
- limit: t1,
2322
- toastOnNew: t2,
2323
- children
2324
- } = t0;
2325
- const limit = t1 === void 0 ? 200 : t1;
2326
- const toastOnNew = t2 === void 0 ? true : t2;
2327
- let t3;
2328
- if ($[0] !== userId) {
2329
- t3 = typeof userId === "string" ? userId.trim() : "";
2330
- $[0] = userId;
2331
- $[1] = t3;
2332
- } else {
2333
- t3 = $[1];
2334
- }
2335
- const trimmedUserId = t3;
2336
- const canUseRts = Boolean(trimmedUserId);
2337
- let t4;
2338
- if ($[2] !== canUseRts || $[3] !== trimmedUserId) {
2339
- t4 = canUseRts ? {
2340
- userId: trimmedUserId
2341
- } : {};
2342
- $[2] = canUseRts;
2343
- $[3] = trimmedUserId;
2344
- $[4] = t4;
2345
- } else {
2346
- t4 = $[4];
2347
- }
2348
- let t5;
2349
- if ($[5] !== canUseRts) {
2350
- t5 = {
2351
- key: "rb.notifications.settings",
2352
- limit: 1,
2353
- enabled: canUseRts
2354
- };
2355
- $[5] = canUseRts;
2356
- $[6] = t5;
2357
- } else {
2358
- t5 = $[6];
2359
- }
2360
- const settingsQuery = useQuery("RBNotificationSettings", t4, t5);
2361
- const settings = settingsQuery.data?.[0] ?? null;
2362
- let t6;
2363
- if ($[7] !== settings) {
2364
- t6 = buildDisabledTopics(settings);
2365
- $[7] = settings;
2366
- $[8] = t6;
2367
- } else {
2368
- t6 = $[8];
2369
- }
2370
- const disabledTopics = t6;
2371
- let t7;
2372
- bb0: {
2373
- if (!canUseRts) {
2374
- let t83;
2375
- if ($[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2376
- t83 = {};
2377
- $[9] = t83;
2378
- } else {
2379
- t83 = $[9];
2380
- }
2381
- t7 = t83;
2382
- break bb0;
2383
- }
2384
- let t82;
2385
- if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2386
- t82 = {
2387
- $exists: false
2388
- };
2389
- $[10] = t82;
2390
- } else {
2391
- t82 = $[10];
2392
- }
2393
- let base;
2394
- if ($[11] !== disabledTopics || $[12] !== trimmedUserId) {
2395
- base = {
2396
- userId: trimmedUserId,
2397
- archivedAt: t82
2398
- };
2399
- if (disabledTopics.length > 0) {
2400
- let t92;
2401
- if ($[14] !== disabledTopics) {
2402
- t92 = {
2403
- $nin: disabledTopics
2404
- };
2405
- $[14] = disabledTopics;
2406
- $[15] = t92;
2407
- } else {
2408
- t92 = $[15];
2409
- }
2410
- base.topic = t92;
2411
- }
2412
- $[11] = disabledTopics;
2413
- $[12] = trimmedUserId;
2414
- $[13] = base;
2415
- } else {
2416
- base = $[13];
2417
- }
2418
- t7 = base;
2419
- }
2420
- const query = t7;
2421
- let t8;
2422
- if ($[16] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2423
- t8 = {
2424
- createdAt: -1
2425
- };
2426
- $[16] = t8;
2427
- } else {
2428
- t8 = $[16];
2429
- }
2430
- let t9;
2431
- if ($[17] !== canUseRts || $[18] !== limit) {
2432
- t9 = {
2433
- key: "rb.notifications",
2434
- sort: t8,
2435
- limit,
2436
- enabled: canUseRts
2437
- };
2438
- $[17] = canUseRts;
2439
- $[18] = limit;
2440
- $[19] = t9;
2441
- } else {
2442
- t9 = $[19];
2443
- }
2444
- const notificationsQuery = useQuery("RBNotification", query, t9);
2445
- let t10;
2446
- bb1: {
2447
- const raw = notificationsQuery.data;
2448
- if (!Array.isArray(raw)) {
2449
- let t113;
2450
- if ($[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2451
- t113 = [];
2452
- $[20] = t113;
2453
- } else {
2454
- t113 = $[20];
2455
- }
2456
- t10 = t113;
2457
- break bb1;
2458
- }
2459
- let t112;
2460
- if ($[21] !== raw) {
2461
- t112 = raw.map(_temp).filter(_temp2);
2462
- $[21] = raw;
2463
- $[22] = t112;
2464
- } else {
2465
- t112 = $[22];
2466
- }
2467
- t10 = t112;
2468
- }
2469
- const notifications = t10;
2470
- let t11;
2471
- if ($[23] !== notifications) {
2472
- t11 = notifications.reduce(_temp3, 0);
2473
- $[23] = notifications;
2474
- $[24] = t11;
2475
- } else {
2476
- t11 = $[24];
2477
- }
2478
- const unreadCount = t11;
2479
- let t12;
2480
- if ($[25] !== notifications) {
2481
- t12 = notifications.reduce(_temp4, 0);
2482
- $[25] = notifications;
2483
- $[26] = t12;
2484
- } else {
2485
- t12 = $[26];
2486
- }
2487
- const unseenCount = t12;
2488
- let t13;
2489
- if ($[27] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2490
- t13 = /* @__PURE__ */ new Set();
2491
- $[27] = t13;
2492
- } else {
2493
- t13 = $[27];
2494
- }
2495
- const lastToastIds = useRef(t13);
2496
- const hasSeededToastIds = useRef(false);
2497
- let t14;
2498
- if ($[28] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2499
- t14 = Date.now();
2500
- $[28] = t14;
2501
- } else {
2502
- t14 = $[28];
2503
- }
2504
- const toastStartMs = useRef(t14);
2505
- let t15;
2506
- if ($[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2507
- t15 = () => {
2508
- hasSeededToastIds.current = false;
2509
- lastToastIds.current = /* @__PURE__ */ new Set();
2510
- toastStartMs.current = Date.now();
2511
- };
2512
- $[29] = t15;
2513
- } else {
2514
- t15 = $[29];
2515
- }
2516
- let t16;
2517
- if ($[30] !== trimmedUserId) {
2518
- t16 = [trimmedUserId];
2519
- $[30] = trimmedUserId;
2520
- $[31] = t16;
2521
- } else {
2522
- t16 = $[31];
2523
- }
2524
- useEffect(t15, t16);
2525
- let t17;
2526
- let t18;
2527
- if ($[32] !== canUseRts || $[33] !== notifications || $[34] !== notificationsQuery.loading || $[35] !== toastOnNew) {
2528
- t17 = () => {
2529
- if (!toastOnNew) {
2530
- return;
2531
- }
2532
- if (!canUseRts) {
2533
- return;
2534
- }
2535
- if (notificationsQuery.loading) {
2536
- return;
2537
- }
2538
- if (!hasSeededToastIds.current) {
2539
- hasSeededToastIds.current = true;
2540
- lastToastIds.current = new Set(notifications.map(_temp5));
2541
- return;
2542
- }
2543
- const nextNew = notifications.filter((n_3) => !lastToastIds.current.has(n_3.id));
2544
- if (!nextNew.length) {
2545
- return;
2546
- }
2547
- for (const n_4 of nextNew) {
2548
- lastToastIds.current.add(n_4.id);
2549
- }
2550
- const isTabActive = typeof document !== "undefined" && document.visibilityState === "visible";
2551
- if (!isTabActive) {
2552
- return;
2553
- }
2554
- const eligible = nextNew.filter((n_5) => {
2555
- const createdAtMs = Date.parse(n_5.createdAt);
2556
- if (!Number.isFinite(createdAtMs)) {
2557
- return true;
2558
- }
2559
- return createdAtMs >= toastStartMs.current;
2560
- });
2561
- if (!eligible.length) {
2562
- return;
2563
- }
2564
- if (eligible.length > 3) {
2565
- toast(`${eligible.length} new notifications`, {
2566
- description: "Open the notifications drawer to view them."
2567
- });
2568
- return;
2569
- }
2570
- for (const n_6 of eligible) {
2571
- toast(n_6.title || "New notification", {
2572
- description: n_6.body
2573
- });
2574
- }
2575
- };
2576
- t18 = [canUseRts, notifications, notificationsQuery.loading, toastOnNew];
2577
- $[32] = canUseRts;
2578
- $[33] = notifications;
2579
- $[34] = notificationsQuery.loading;
2580
- $[35] = toastOnNew;
2581
- $[36] = t17;
2582
- $[37] = t18;
2583
- } else {
2584
- t17 = $[36];
2585
- t18 = $[37];
2586
- }
2587
- useEffect(t17, t18);
2588
- let t19;
2589
- if ($[38] !== notifications || $[39] !== notificationsQuery.error || $[40] !== notificationsQuery.loading || $[41] !== unreadCount || $[42] !== unseenCount) {
2590
- t19 = {
2591
- notifications,
2592
- unreadCount,
2593
- unseenCount,
2594
- loading: notificationsQuery.loading,
2595
- error: notificationsQuery.error
2596
- };
2597
- $[38] = notifications;
2598
- $[39] = notificationsQuery.error;
2599
- $[40] = notificationsQuery.loading;
2600
- $[41] = unreadCount;
2601
- $[42] = unseenCount;
2602
- $[43] = t19;
2603
- } else {
2604
- t19 = $[43];
2605
- }
2606
- const value = t19;
2607
- const t20 = canUseRts ? value : null;
2608
- let t21;
2609
- if ($[44] !== children || $[45] !== t20) {
2610
- t21 = /* @__PURE__ */ jsx(NotificationsRealtimeContext.Provider, { value: t20, children });
2611
- $[44] = children;
2612
- $[45] = t20;
2613
- $[46] = t21;
2614
- } else {
2615
- t21 = $[46];
2616
- }
2617
- return t21;
2184
+ const $ = c(47);
2185
+ const { userId, limit: t1, toastOnNew: t2, children } = t0;
2186
+ const limit = t1 === void 0 ? 200 : t1;
2187
+ const toastOnNew = t2 === void 0 ? true : t2;
2188
+ let t3;
2189
+ if ($[0] !== userId) {
2190
+ t3 = typeof userId === "string" ? userId.trim() : "";
2191
+ $[0] = userId;
2192
+ $[1] = t3;
2193
+ } else t3 = $[1];
2194
+ const trimmedUserId = t3;
2195
+ const canUseRts = Boolean(trimmedUserId);
2196
+ let t4;
2197
+ if ($[2] !== canUseRts || $[3] !== trimmedUserId) {
2198
+ t4 = canUseRts ? { userId: trimmedUserId } : {};
2199
+ $[2] = canUseRts;
2200
+ $[3] = trimmedUserId;
2201
+ $[4] = t4;
2202
+ } else t4 = $[4];
2203
+ let t5;
2204
+ if ($[5] !== canUseRts) {
2205
+ t5 = {
2206
+ key: "rb.notifications.settings",
2207
+ limit: 1,
2208
+ enabled: canUseRts
2209
+ };
2210
+ $[5] = canUseRts;
2211
+ $[6] = t5;
2212
+ } else t5 = $[6];
2213
+ const settings = useQuery("RBNotificationSettings", t4, t5).data?.[0] ?? null;
2214
+ let t6;
2215
+ if ($[7] !== settings) {
2216
+ t6 = buildDisabledTopics(settings);
2217
+ $[7] = settings;
2218
+ $[8] = t6;
2219
+ } else t6 = $[8];
2220
+ const disabledTopics = t6;
2221
+ let t7;
2222
+ bb0: {
2223
+ if (!canUseRts) {
2224
+ let t8;
2225
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
2226
+ t8 = {};
2227
+ $[9] = t8;
2228
+ } else t8 = $[9];
2229
+ t7 = t8;
2230
+ break bb0;
2231
+ }
2232
+ let t8;
2233
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
2234
+ t8 = { $exists: false };
2235
+ $[10] = t8;
2236
+ } else t8 = $[10];
2237
+ let base;
2238
+ if ($[11] !== disabledTopics || $[12] !== trimmedUserId) {
2239
+ base = {
2240
+ userId: trimmedUserId,
2241
+ archivedAt: t8
2242
+ };
2243
+ if (disabledTopics.length > 0) {
2244
+ let t9;
2245
+ if ($[14] !== disabledTopics) {
2246
+ t9 = { $nin: disabledTopics };
2247
+ $[14] = disabledTopics;
2248
+ $[15] = t9;
2249
+ } else t9 = $[15];
2250
+ base.topic = t9;
2251
+ }
2252
+ $[11] = disabledTopics;
2253
+ $[12] = trimmedUserId;
2254
+ $[13] = base;
2255
+ } else base = $[13];
2256
+ t7 = base;
2257
+ }
2258
+ const query = t7;
2259
+ let t8;
2260
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
2261
+ t8 = { createdAt: -1 };
2262
+ $[16] = t8;
2263
+ } else t8 = $[16];
2264
+ let t9;
2265
+ if ($[17] !== canUseRts || $[18] !== limit) {
2266
+ t9 = {
2267
+ key: "rb.notifications",
2268
+ sort: t8,
2269
+ limit,
2270
+ enabled: canUseRts
2271
+ };
2272
+ $[17] = canUseRts;
2273
+ $[18] = limit;
2274
+ $[19] = t9;
2275
+ } else t9 = $[19];
2276
+ const notificationsQuery = useQuery("RBNotification", query, t9);
2277
+ let t10;
2278
+ bb1: {
2279
+ const raw = notificationsQuery.data;
2280
+ if (!Array.isArray(raw)) {
2281
+ let t11;
2282
+ if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
2283
+ t11 = [];
2284
+ $[20] = t11;
2285
+ } else t11 = $[20];
2286
+ t10 = t11;
2287
+ break bb1;
2288
+ }
2289
+ let t11;
2290
+ if ($[21] !== raw) {
2291
+ t11 = raw.map(_temp).filter(_temp2);
2292
+ $[21] = raw;
2293
+ $[22] = t11;
2294
+ } else t11 = $[22];
2295
+ t10 = t11;
2296
+ }
2297
+ const notifications = t10;
2298
+ let t11;
2299
+ if ($[23] !== notifications) {
2300
+ t11 = notifications.reduce(_temp3, 0);
2301
+ $[23] = notifications;
2302
+ $[24] = t11;
2303
+ } else t11 = $[24];
2304
+ const unreadCount = t11;
2305
+ let t12;
2306
+ if ($[25] !== notifications) {
2307
+ t12 = notifications.reduce(_temp4, 0);
2308
+ $[25] = notifications;
2309
+ $[26] = t12;
2310
+ } else t12 = $[26];
2311
+ const unseenCount = t12;
2312
+ let t13;
2313
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
2314
+ t13 = /* @__PURE__ */ new Set();
2315
+ $[27] = t13;
2316
+ } else t13 = $[27];
2317
+ const lastToastIds = useRef(t13);
2318
+ const hasSeededToastIds = useRef(false);
2319
+ let t14;
2320
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
2321
+ t14 = Date.now();
2322
+ $[28] = t14;
2323
+ } else t14 = $[28];
2324
+ const toastStartMs = useRef(t14);
2325
+ let t15;
2326
+ if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
2327
+ t15 = () => {
2328
+ hasSeededToastIds.current = false;
2329
+ lastToastIds.current = /* @__PURE__ */ new Set();
2330
+ toastStartMs.current = Date.now();
2331
+ };
2332
+ $[29] = t15;
2333
+ } else t15 = $[29];
2334
+ let t16;
2335
+ if ($[30] !== trimmedUserId) {
2336
+ t16 = [trimmedUserId];
2337
+ $[30] = trimmedUserId;
2338
+ $[31] = t16;
2339
+ } else t16 = $[31];
2340
+ useEffect(t15, t16);
2341
+ let t17;
2342
+ let t18;
2343
+ if ($[32] !== canUseRts || $[33] !== notifications || $[34] !== notificationsQuery.loading || $[35] !== toastOnNew) {
2344
+ t17 = () => {
2345
+ if (!toastOnNew) return;
2346
+ if (!canUseRts) return;
2347
+ if (notificationsQuery.loading) return;
2348
+ if (!hasSeededToastIds.current) {
2349
+ hasSeededToastIds.current = true;
2350
+ lastToastIds.current = new Set(notifications.map(_temp5));
2351
+ return;
2352
+ }
2353
+ const nextNew = notifications.filter((n_3) => !lastToastIds.current.has(n_3.id));
2354
+ if (!nextNew.length) return;
2355
+ for (const n_4 of nextNew) lastToastIds.current.add(n_4.id);
2356
+ if (!(typeof document !== "undefined" && document.visibilityState === "visible")) return;
2357
+ const eligible = nextNew.filter((n_5) => {
2358
+ const createdAtMs = Date.parse(n_5.createdAt);
2359
+ if (!Number.isFinite(createdAtMs)) return true;
2360
+ return createdAtMs >= toastStartMs.current;
2361
+ });
2362
+ if (!eligible.length) return;
2363
+ if (eligible.length > 3) {
2364
+ toast(`${eligible.length} new notifications`, { description: "Open the notifications drawer to view them." });
2365
+ return;
2366
+ }
2367
+ for (const n_6 of eligible) toast(n_6.title || "New notification", { description: n_6.body });
2368
+ };
2369
+ t18 = [
2370
+ canUseRts,
2371
+ notifications,
2372
+ notificationsQuery.loading,
2373
+ toastOnNew
2374
+ ];
2375
+ $[32] = canUseRts;
2376
+ $[33] = notifications;
2377
+ $[34] = notificationsQuery.loading;
2378
+ $[35] = toastOnNew;
2379
+ $[36] = t17;
2380
+ $[37] = t18;
2381
+ } else {
2382
+ t17 = $[36];
2383
+ t18 = $[37];
2384
+ }
2385
+ useEffect(t17, t18);
2386
+ let t19;
2387
+ if ($[38] !== notifications || $[39] !== notificationsQuery.error || $[40] !== notificationsQuery.loading || $[41] !== unreadCount || $[42] !== unseenCount) {
2388
+ t19 = {
2389
+ notifications,
2390
+ unreadCount,
2391
+ unseenCount,
2392
+ loading: notificationsQuery.loading,
2393
+ error: notificationsQuery.error
2394
+ };
2395
+ $[38] = notifications;
2396
+ $[39] = notificationsQuery.error;
2397
+ $[40] = notificationsQuery.loading;
2398
+ $[41] = unreadCount;
2399
+ $[42] = unseenCount;
2400
+ $[43] = t19;
2401
+ } else t19 = $[43];
2402
+ const t20 = canUseRts ? t19 : null;
2403
+ let t21;
2404
+ if ($[44] !== children || $[45] !== t20) {
2405
+ t21 = /* @__PURE__ */ jsx(NotificationsRealtimeContext.Provider, {
2406
+ value: t20,
2407
+ children
2408
+ });
2409
+ $[44] = children;
2410
+ $[45] = t20;
2411
+ $[46] = t21;
2412
+ } else t21 = $[46];
2413
+ return t21;
2618
2414
  }
2619
2415
  function _temp5(n_2) {
2620
- return n_2.id;
2416
+ return n_2.id;
2621
2417
  }
2622
2418
  function _temp4(acc_0, n_1) {
2623
- return acc_0 + (n_1.seenAt ? 0 : 1);
2419
+ return acc_0 + (n_1.seenAt ? 0 : 1);
2624
2420
  }
2625
2421
  function _temp3(acc, n_0) {
2626
- return acc + (n_0.readAt ? 0 : 1);
2422
+ return acc + (n_0.readAt ? 0 : 1);
2627
2423
  }
2628
2424
  function _temp2(n) {
2629
- return Boolean(n);
2425
+ return Boolean(n);
2630
2426
  }
2631
2427
  function _temp(doc) {
2632
- return toNotificationItem(doc);
2428
+ return toNotificationItem(doc);
2633
2429
  }
2634
- const useNotificationsRealtime = () => {
2635
- return useContext(NotificationsRealtimeContext);
2636
- };
2637
- export {
2638
- NotificationsRealtimeContext,
2639
- NotificationsRealtimeProvider,
2640
- RootProvider,
2641
- RouteErrorBoundary,
2642
- R as RtsSsrRuntimeProvider,
2643
- SSR_ERROR_STATE_GLOBAL_KEY,
2644
- S as STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY,
2645
- SsrErrorFallback,
2646
- apiClient,
2647
- archiveNotification,
2648
- p as clearHydratedRtsQueryData,
2649
- consumeClientSsrErrorState,
2650
- getFeatureFlag,
2651
- getNotificationSettings,
2652
- hydrateRtsFromWindow,
2653
- initApiClient,
2654
- initWithRoutes,
2655
- listNotifications,
2656
- markAllNotificationsRead,
2657
- markNotificationRead,
2658
- peekClientSsrErrorState,
2659
- q as peekHydratedRtsQueryData,
2660
- t as peekHydratedRtsQueryPageInfo,
2661
- v as peekHydratedRtsQueryTotalCount,
2662
- reportClientException,
2663
- runNotificationDigest,
2664
- serializeSsrErrorState,
2665
- s as setClientExceptionReporter,
2666
- toast,
2667
- updateNotificationSettings,
2668
- useMediaQuery,
2669
- useNotificationsRealtime,
2670
- useThrottledMeasure
2671
- };
2672
- //# sourceMappingURL=index.js.map
2430
+ var useNotificationsRealtime = () => {
2431
+ return useContext(NotificationsRealtimeContext);
2432
+ };
2433
+ //#endregion
2434
+ export { NotificationsRealtimeContext, NotificationsRealtimeProvider, RootProvider, RouteErrorBoundary, RtsSsrRuntimeProvider, SSR_ERROR_STATE_GLOBAL_KEY, STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY, SsrErrorFallback, apiClient, archiveNotification, clearHydratedRtsQueryData, consumeClientSsrErrorState, getFeatureFlag, getNotificationSettings, hydrateRtsFromWindow, initApiClient, initWithRoutes, listNotifications, markAllNotificationsRead, markNotificationRead, peekClientSsrErrorState, peekHydratedRtsQueryData, peekHydratedRtsQueryPageInfo, peekHydratedRtsQueryTotalCount, reportClientException, runNotificationDigest, serializeSsrErrorState, setClientExceptionReporter, toast, updateNotificationSettings, useMediaQuery, useNotificationsRealtime, useThrottledMeasure };
2435
+
2436
+ //# sourceMappingURL=index.js.map