sera-components 1.0.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.
Files changed (40) hide show
  1. package/dist/components/src/basic/CountryFlag.d.ts +75 -0
  2. package/dist/components/src/basic/Language.d.ts +48 -0
  3. package/dist/components/src/basic/Menu.d.ts +62 -0
  4. package/dist/components/src/basic/Transition.d.ts +18 -0
  5. package/dist/components/src/basic/index.d.ts +4 -0
  6. package/dist/components/src/data/display/ForeignKeyDisplay.d.ts +7 -0
  7. package/dist/components/src/data/display/TextDisplay.d.ts +2 -0
  8. package/dist/components/src/data/display/index.d.ts +13 -0
  9. package/dist/components/src/data/index.d.ts +2 -0
  10. package/dist/components/src/data/inputs/BooleanInput.d.ts +2 -0
  11. package/dist/components/src/data/inputs/ForeignKeyInput.d.ts +22 -0
  12. package/dist/components/src/data/inputs/NumberInput.d.ts +2 -0
  13. package/dist/components/src/data/inputs/PhoneNumberInput.d.ts +13 -0
  14. package/dist/components/src/data/inputs/TextInput.d.ts +2 -0
  15. package/dist/components/src/data/inputs/index.d.ts +21 -0
  16. package/dist/components/src/form/Form.d.ts +61 -0
  17. package/dist/components/src/form/FormItem.d.ts +31 -0
  18. package/dist/components/src/form/FormItemLabel.d.ts +9 -0
  19. package/dist/components/src/form/index.d.ts +3 -0
  20. package/dist/components/src/index.d.ts +5 -0
  21. package/dist/components/src/misc/index.d.ts +2 -0
  22. package/dist/components/src/misc/trie.d.ts +36 -0
  23. package/dist/components/src/misc/utils.d.ts +9 -0
  24. package/dist/components/src/table/EmbeddedTable.d.ts +13 -0
  25. package/dist/components/src/table/Table.d.ts +16 -0
  26. package/dist/components/src/table/TableAction.d.ts +16 -0
  27. package/dist/components/src/table/TableContent.d.ts +9 -0
  28. package/dist/components/src/table/TablePagination.d.ts +14 -0
  29. package/dist/components/src/table/index.d.ts +4 -0
  30. package/dist/components/src/table/makeColumns.d.ts +28 -0
  31. package/dist/components/src/view/MultiTabView.d.ts +1 -0
  32. package/dist/components/src/view/View.d.ts +25 -0
  33. package/dist/components/src/view/ViewItem.d.ts +15 -0
  34. package/dist/components/src/view/ViewNestedPropertyItem.d.ts +46 -0
  35. package/dist/components/src/view/ViewTab.d.ts +18 -0
  36. package/dist/components/src/view/index.d.ts +2 -0
  37. package/dist/index.css +1 -0
  38. package/dist/index.js +3344 -0
  39. package/dist/index.umd.cjs +33 -0
  40. package/package.json +45 -0
package/dist/index.js ADDED
@@ -0,0 +1,3344 @@
1
+ var nn = Object.defineProperty;
2
+ var rn = (e, n, t) => n in e ? nn(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
+ var oe = (e, n, t) => rn(e, typeof n != "symbol" ? n + "" : n, t);
4
+ import * as d from "react";
5
+ import an, { createContext as on, useContext as ln, useMemo as k, useState as _, useEffect as Re } from "react";
6
+ import { Paper as te, Image as sn, Text as T, Menu as le, Button as U, Alert as Be, Flex as B, Loader as je, NavLink as rt, Group as $, Input as q, useCombobox as bt, Combobox as F, Grid as A, InputBase as un, PasswordInput as cn, Stack as Ee, CloseButton as dn, Divider as fn, Tooltip as wt, Fieldset as hn, Table as jt, rem as ce, Pagination as mn, MenuTarget as gn, MenuDropdown as pn, MenuItem as vn, Checkbox as Ce, Tabs as pe } from "@mantine/core";
7
+ import { IconCheck as xn, IconInfoCircle as Ke, IconChevronRight as yn, IconSearch as Ct, IconHelpOctagonFilled as St, IconPlus as bn, IconPencil as wn, IconReload as jn, IconDatabaseImport as Cn, IconDownload as Sn, IconSelector as Rn } from "@tabler/icons-react";
8
+ import { observer as ne } from "mobx-react-lite";
9
+ import { InternalLink as Rt } from "sera-route";
10
+ import { IMaskInput as En } from "react-imask";
11
+ import { isDraftRecord as Et, isObjectProperty as me } from "sera-db";
12
+ import { flexRender as at, useReactTable as kt, getCoreRowModel as Tt, getPaginationRowModel as kn } from "@tanstack/react-table";
13
+ var ve = { exports: {} }, de = {};
14
+ /**
15
+ * @license React
16
+ * react-jsx-runtime.production.js
17
+ *
18
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
19
+ *
20
+ * This source code is licensed under the MIT license found in the
21
+ * LICENSE file in the root directory of this source tree.
22
+ */
23
+ var ot;
24
+ function Tn() {
25
+ if (ot) return de;
26
+ ot = 1;
27
+ var e = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
28
+ function t(a, r, o) {
29
+ var l = null;
30
+ if (o !== void 0 && (l = "" + o), r.key !== void 0 && (l = "" + r.key), "key" in r) {
31
+ o = {};
32
+ for (var s in r)
33
+ s !== "key" && (o[s] = r[s]);
34
+ } else o = r;
35
+ return r = o.ref, {
36
+ $$typeof: e,
37
+ type: a,
38
+ key: l,
39
+ ref: r !== void 0 ? r : null,
40
+ props: o
41
+ };
42
+ }
43
+ return de.Fragment = n, de.jsx = t, de.jsxs = t, de;
44
+ }
45
+ var fe = {};
46
+ /**
47
+ * @license React
48
+ * react-jsx-runtime.development.js
49
+ *
50
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
51
+ *
52
+ * This source code is licensed under the MIT license found in the
53
+ * LICENSE file in the root directory of this source tree.
54
+ */
55
+ var it;
56
+ function Nn() {
57
+ return it || (it = 1, process.env.NODE_ENV !== "production" && function() {
58
+ function e(m) {
59
+ if (m == null) return null;
60
+ if (typeof m == "function")
61
+ return m.$$typeof === Y ? null : m.displayName || m.name || null;
62
+ if (typeof m == "string") return m;
63
+ switch (m) {
64
+ case h:
65
+ return "Fragment";
66
+ case y:
67
+ return "Profiler";
68
+ case j:
69
+ return "StrictMode";
70
+ case R:
71
+ return "Suspense";
72
+ case K:
73
+ return "SuspenseList";
74
+ case O:
75
+ return "Activity";
76
+ }
77
+ if (typeof m == "object")
78
+ switch (typeof m.tag == "number" && console.error(
79
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
80
+ ), m.$$typeof) {
81
+ case x:
82
+ return "Portal";
83
+ case b:
84
+ return (m.displayName || "Context") + ".Provider";
85
+ case S:
86
+ return (m._context.displayName || "Context") + ".Consumer";
87
+ case w:
88
+ var C = m.render;
89
+ return m = m.displayName, m || (m = C.displayName || C.name || "", m = m !== "" ? "ForwardRef(" + m + ")" : "ForwardRef"), m;
90
+ case D:
91
+ return C = m.displayName || null, C !== null ? C : e(m.type) || "Memo";
92
+ case ee:
93
+ C = m._payload, m = m._init;
94
+ try {
95
+ return e(m(C));
96
+ } catch {
97
+ }
98
+ }
99
+ return null;
100
+ }
101
+ function n(m) {
102
+ return "" + m;
103
+ }
104
+ function t(m) {
105
+ try {
106
+ n(m);
107
+ var C = !1;
108
+ } catch {
109
+ C = !0;
110
+ }
111
+ if (C) {
112
+ C = console;
113
+ var E = C.error, L = typeof Symbol == "function" && Symbol.toStringTag && m[Symbol.toStringTag] || m.constructor.name || "Object";
114
+ return E.call(
115
+ C,
116
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
117
+ L
118
+ ), n(m);
119
+ }
120
+ }
121
+ function a(m) {
122
+ if (m === h) return "<>";
123
+ if (typeof m == "object" && m !== null && m.$$typeof === ee)
124
+ return "<...>";
125
+ try {
126
+ var C = e(m);
127
+ return C ? "<" + C + ">" : "<...>";
128
+ } catch {
129
+ return "<...>";
130
+ }
131
+ }
132
+ function r() {
133
+ var m = re.A;
134
+ return m === null ? null : m.getOwner();
135
+ }
136
+ function o() {
137
+ return Error("react-stack-top-frame");
138
+ }
139
+ function l(m) {
140
+ if (Xe.call(m, "key")) {
141
+ var C = Object.getOwnPropertyDescriptor(m, "key").get;
142
+ if (C && C.isReactWarning) return !1;
143
+ }
144
+ return m.key !== void 0;
145
+ }
146
+ function s(m, C) {
147
+ function E() {
148
+ Ze || (Ze = !0, console.error(
149
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
150
+ C
151
+ ));
152
+ }
153
+ E.isReactWarning = !0, Object.defineProperty(m, "key", {
154
+ get: E,
155
+ configurable: !0
156
+ });
157
+ }
158
+ function u() {
159
+ var m = e(this.type);
160
+ return Qe[m] || (Qe[m] = !0, console.error(
161
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
162
+ )), m = this.props.ref, m !== void 0 ? m : null;
163
+ }
164
+ function c(m, C, E, L, J, z, Fe, Ae) {
165
+ return E = z.ref, m = {
166
+ $$typeof: p,
167
+ type: m,
168
+ key: C,
169
+ props: z,
170
+ _owner: J
171
+ }, (E !== void 0 ? E : null) !== null ? Object.defineProperty(m, "ref", {
172
+ enumerable: !1,
173
+ get: u
174
+ }) : Object.defineProperty(m, "ref", { enumerable: !1, value: null }), m._store = {}, Object.defineProperty(m._store, "validated", {
175
+ configurable: !1,
176
+ enumerable: !1,
177
+ writable: !0,
178
+ value: 0
179
+ }), Object.defineProperty(m, "_debugInfo", {
180
+ configurable: !1,
181
+ enumerable: !1,
182
+ writable: !0,
183
+ value: null
184
+ }), Object.defineProperty(m, "_debugStack", {
185
+ configurable: !1,
186
+ enumerable: !1,
187
+ writable: !0,
188
+ value: Fe
189
+ }), Object.defineProperty(m, "_debugTask", {
190
+ configurable: !1,
191
+ enumerable: !1,
192
+ writable: !0,
193
+ value: Ae
194
+ }), Object.freeze && (Object.freeze(m.props), Object.freeze(m)), m;
195
+ }
196
+ function f(m, C, E, L, J, z, Fe, Ae) {
197
+ var I = C.children;
198
+ if (I !== void 0)
199
+ if (L)
200
+ if (en(I)) {
201
+ for (L = 0; L < I.length; L++)
202
+ v(I[L]);
203
+ Object.freeze && Object.freeze(I);
204
+ } else
205
+ console.error(
206
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
207
+ );
208
+ else v(I);
209
+ if (Xe.call(C, "key")) {
210
+ I = e(m);
211
+ var ae = Object.keys(C).filter(function(tn) {
212
+ return tn !== "key";
213
+ });
214
+ L = 0 < ae.length ? "{key: someKey, " + ae.join(": ..., ") + ": ...}" : "{key: someKey}", nt[I + L] || (ae = 0 < ae.length ? "{" + ae.join(": ..., ") + ": ...}" : "{}", console.error(
215
+ `A props object containing a "key" prop is being spread into JSX:
216
+ let props = %s;
217
+ <%s {...props} />
218
+ React keys must be passed directly to JSX without using spread:
219
+ let props = %s;
220
+ <%s key={someKey} {...props} />`,
221
+ L,
222
+ I,
223
+ ae,
224
+ I
225
+ ), nt[I + L] = !0);
226
+ }
227
+ if (I = null, E !== void 0 && (t(E), I = "" + E), l(C) && (t(C.key), I = "" + C.key), "key" in C) {
228
+ E = {};
229
+ for (var _e in C)
230
+ _e !== "key" && (E[_e] = C[_e]);
231
+ } else E = C;
232
+ return I && s(
233
+ E,
234
+ typeof m == "function" ? m.displayName || m.name || "Unknown" : m
235
+ ), c(
236
+ m,
237
+ I,
238
+ z,
239
+ J,
240
+ r(),
241
+ E,
242
+ Fe,
243
+ Ae
244
+ );
245
+ }
246
+ function v(m) {
247
+ typeof m == "object" && m !== null && m.$$typeof === p && m._store && (m._store.validated = 1);
248
+ }
249
+ var g = an, p = Symbol.for("react.transitional.element"), x = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), j = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), S = Symbol.for("react.consumer"), b = Symbol.for("react.context"), w = Symbol.for("react.forward_ref"), R = Symbol.for("react.suspense"), K = Symbol.for("react.suspense_list"), D = Symbol.for("react.memo"), ee = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), Y = Symbol.for("react.client.reference"), re = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Xe = Object.prototype.hasOwnProperty, en = Array.isArray, Ie = console.createTask ? console.createTask : function() {
250
+ return null;
251
+ };
252
+ g = {
253
+ react_stack_bottom_frame: function(m) {
254
+ return m();
255
+ }
256
+ };
257
+ var Ze, Qe = {}, et = g.react_stack_bottom_frame.bind(
258
+ g,
259
+ o
260
+ )(), tt = Ie(a(o)), nt = {};
261
+ fe.Fragment = h, fe.jsx = function(m, C, E, L, J) {
262
+ var z = 1e4 > re.recentlyCreatedOwnerStacks++;
263
+ return f(
264
+ m,
265
+ C,
266
+ E,
267
+ !1,
268
+ L,
269
+ J,
270
+ z ? Error("react-stack-top-frame") : et,
271
+ z ? Ie(a(m)) : tt
272
+ );
273
+ }, fe.jsxs = function(m, C, E, L, J) {
274
+ var z = 1e4 > re.recentlyCreatedOwnerStacks++;
275
+ return f(
276
+ m,
277
+ C,
278
+ E,
279
+ !0,
280
+ L,
281
+ J,
282
+ z ? Error("react-stack-top-frame") : et,
283
+ z ? Ie(a(m)) : tt
284
+ );
285
+ };
286
+ }()), fe;
287
+ }
288
+ var lt;
289
+ function Pn() {
290
+ return lt || (lt = 1, process.env.NODE_ENV === "production" ? ve.exports = Tn() : ve.exports = Nn()), ve.exports;
291
+ }
292
+ var i = Pn();
293
+ const N = {
294
+ UK: {
295
+ svgFlag: "https://flagcdn.com/gb.svg",
296
+ emojiFlag: "🇬🇧"
297
+ },
298
+ VN: {
299
+ svgFlag: "https://flagcdn.com/vn.svg",
300
+ emojiFlag: "🇻🇳"
301
+ },
302
+ US: {
303
+ svgFlag: "https://flagcdn.com/us.svg",
304
+ emojiFlag: "🇺🇸"
305
+ },
306
+ CA: {
307
+ svgFlag: "https://flagcdn.com/ca.svg",
308
+ emojiFlag: "🇨🇦"
309
+ },
310
+ BR: {
311
+ svgFlag: "https://flagcdn.com/br.svg",
312
+ emojiFlag: "🇧🇷"
313
+ },
314
+ ES: {
315
+ svgFlag: "https://flagcdn.com/es.svg",
316
+ emojiFlag: "🇪🇸"
317
+ },
318
+ IT: {
319
+ svgFlag: "https://flagcdn.com/it.svg",
320
+ emojiFlag: "🇮🇹"
321
+ },
322
+ NZ: {
323
+ svgFlag: "https://flagcdn.com/nz.svg",
324
+ emojiFlag: "🇳🇿"
325
+ },
326
+ MX: {
327
+ svgFlag: "https://flagcdn.com/mx.svg",
328
+ emojiFlag: "🇲🇽"
329
+ },
330
+ CN: {
331
+ svgFlag: "https://flagcdn.com/cn.svg",
332
+ emojiFlag: "🇨🇳"
333
+ },
334
+ AU: {
335
+ svgFlag: "https://flagcdn.com/au.svg",
336
+ emojiFlag: "🇦🇺"
337
+ },
338
+ JP: {
339
+ svgFlag: "https://flagcdn.com/jp.svg",
340
+ emojiFlag: "🇯🇵"
341
+ },
342
+ FR: {
343
+ svgFlag: "https://flagcdn.com/fr.svg",
344
+ emojiFlag: "🇫🇷"
345
+ },
346
+ DE: {
347
+ svgFlag: "https://flagcdn.com/de.svg",
348
+ emojiFlag: "🇩🇪"
349
+ },
350
+ IN: {
351
+ svgFlag: "https://flagcdn.com/in.svg",
352
+ emojiFlag: "🇮🇳"
353
+ }
354
+ }, Ln = ({ flag: e }) => /* @__PURE__ */ i.jsx(te, { shadow: "xs", w: 20, h: 14, children: /* @__PURE__ */ i.jsx(sn, { src: e.svgFlag, w: 20, h: 14, fit: "cover" }) }), In = ({ flag: e }) => /* @__PURE__ */ i.jsx(
355
+ T,
356
+ {
357
+ component: "span",
358
+ style: (n) => ({ textShadow: n.shadows.xs }),
359
+ children: e.emojiFlag
360
+ }
361
+ ), Me = navigator.userAgent.includes("Windows") ? Ln : In, Fn = {
362
+ lang2value: {
363
+ en: "Choose Language",
364
+ vi: "Chọn ngôn ngữ"
365
+ }
366
+ }, xe = {
367
+ en: {
368
+ name: "English",
369
+ flag: N.US,
370
+ locale: new Intl.Locale("en-US")
371
+ },
372
+ vi: {
373
+ name: "Tiếng Việt",
374
+ flag: N.VN,
375
+ locale: new Intl.Locale("vi-VN")
376
+ }
377
+ }, qa = ({
378
+ locale: e,
379
+ setLocale: n
380
+ }) => {
381
+ const t = k(() => Object.entries(xe).map(
382
+ ([a, { flag: r, name: o, locale: l }]) => /* @__PURE__ */ i.jsx(
383
+ le.Item,
384
+ {
385
+ onClick: () => n(l),
386
+ leftSection: /* @__PURE__ */ i.jsx(Me, { flag: r }),
387
+ rightSection: e.language === a && /* @__PURE__ */ i.jsx(xn, { size: "15", color: "#2986cc", stroke: 2 }),
388
+ children: /* @__PURE__ */ i.jsx(T, { size: "sm", children: o })
389
+ },
390
+ a
391
+ )
392
+ ), [xe, e]);
393
+ return /* @__PURE__ */ i.jsxs(le, { width: 170, children: [
394
+ /* @__PURE__ */ i.jsx(le.Target, { children: /* @__PURE__ */ i.jsx(
395
+ U,
396
+ {
397
+ variant: "subtle",
398
+ size: "sm",
399
+ leftSection: /* @__PURE__ */ i.jsx(Me, { flag: xe[e.language].flag }),
400
+ children: /* @__PURE__ */ i.jsx(T, { size: "sm", children: xe[e.language].name })
401
+ }
402
+ ) }),
403
+ /* @__PURE__ */ i.jsxs(le.Dropdown, { children: [
404
+ /* @__PURE__ */ i.jsx(le.Label, { children: /* @__PURE__ */ i.jsx(T, { size: "sm", children: Fn.lang2value[e.language] }) }),
405
+ t
406
+ ] })
407
+ ] });
408
+ }, An = on(new Intl.Locale("en-US")), M = ({ value: e }) => {
409
+ const n = ln(An);
410
+ return e.lang2value[n.language] || e.lang2value[e.lang];
411
+ };
412
+ /**
413
+ * react-router v7.7.1
414
+ *
415
+ * Copyright (c) Remix Software Inc.
416
+ *
417
+ * This source code is licensed under the MIT license found in the
418
+ * LICENSE.md file in the root directory of this source tree.
419
+ *
420
+ * @license MIT
421
+ */
422
+ function P(e, n) {
423
+ if (e === !1 || e === null || typeof e > "u")
424
+ throw new Error(n);
425
+ }
426
+ function V(e, n) {
427
+ if (!e) {
428
+ typeof console < "u" && console.warn(n);
429
+ try {
430
+ throw new Error(n);
431
+ } catch {
432
+ }
433
+ }
434
+ }
435
+ function ze({
436
+ pathname: e = "/",
437
+ search: n = "",
438
+ hash: t = ""
439
+ }) {
440
+ return n && n !== "?" && (e += n.charAt(0) === "?" ? n : "?" + n), t && t !== "#" && (e += t.charAt(0) === "#" ? t : "#" + t), e;
441
+ }
442
+ function Ue(e) {
443
+ let n = {};
444
+ if (e) {
445
+ let t = e.indexOf("#");
446
+ t >= 0 && (n.hash = e.substring(t), e = e.substring(0, t));
447
+ let a = e.indexOf("?");
448
+ a >= 0 && (n.search = e.substring(a), e = e.substring(0, a)), e && (n.pathname = e);
449
+ }
450
+ return n;
451
+ }
452
+ function Nt(e, n, t = "/") {
453
+ return _n(e, n, t, !1);
454
+ }
455
+ function _n(e, n, t, a) {
456
+ let r = typeof n == "string" ? Ue(n) : n, o = X(r.pathname || "/", t);
457
+ if (o == null)
458
+ return null;
459
+ let l = Pt(e);
460
+ On(l);
461
+ let s = null;
462
+ for (let u = 0; s == null && u < l.length; ++u) {
463
+ let c = Hn(o);
464
+ s = Wn(
465
+ l[u],
466
+ c,
467
+ a
468
+ );
469
+ }
470
+ return s;
471
+ }
472
+ function Pt(e, n = [], t = [], a = "") {
473
+ let r = (o, l, s) => {
474
+ let u = {
475
+ relativePath: s === void 0 ? o.path || "" : s,
476
+ caseSensitive: o.caseSensitive === !0,
477
+ childrenIndex: l,
478
+ route: o
479
+ };
480
+ u.relativePath.startsWith("/") && (P(
481
+ u.relativePath.startsWith(a),
482
+ `Absolute route path "${u.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
483
+ ), u.relativePath = u.relativePath.slice(a.length));
484
+ let c = W([a, u.relativePath]), f = t.concat(u);
485
+ o.children && o.children.length > 0 && (P(
486
+ // Our types know better, but runtime JS may not!
487
+ // @ts-expect-error
488
+ o.index !== !0,
489
+ `Index routes must not have child routes. Please remove all child routes from route path "${c}".`
490
+ ), Pt(o.children, n, f, c)), !(o.path == null && !o.index) && n.push({
491
+ path: c,
492
+ score: Un(c, o.index),
493
+ routesMeta: f
494
+ });
495
+ };
496
+ return e.forEach((o, l) => {
497
+ var s;
498
+ if (o.path === "" || !((s = o.path) != null && s.includes("?")))
499
+ r(o, l);
500
+ else
501
+ for (let u of Lt(o.path))
502
+ r(o, l, u);
503
+ }), n;
504
+ }
505
+ function Lt(e) {
506
+ let n = e.split("/");
507
+ if (n.length === 0) return [];
508
+ let [t, ...a] = n, r = t.endsWith("?"), o = t.replace(/\?$/, "");
509
+ if (a.length === 0)
510
+ return r ? [o, ""] : [o];
511
+ let l = Lt(a.join("/")), s = [];
512
+ return s.push(
513
+ ...l.map(
514
+ (u) => u === "" ? o : [o, u].join("/")
515
+ )
516
+ ), r && s.push(...l), s.map(
517
+ (u) => e.startsWith("/") && u === "" ? "/" : u
518
+ );
519
+ }
520
+ function On(e) {
521
+ e.sort(
522
+ (n, t) => n.score !== t.score ? t.score - n.score : qn(
523
+ n.routesMeta.map((a) => a.childrenIndex),
524
+ t.routesMeta.map((a) => a.childrenIndex)
525
+ )
526
+ );
527
+ }
528
+ var $n = /^:[\w-]+$/, Dn = 3, Mn = 2, zn = 1, Bn = 10, Kn = -2, st = (e) => e === "*";
529
+ function Un(e, n) {
530
+ let t = e.split("/"), a = t.length;
531
+ return t.some(st) && (a += Kn), n && (a += Mn), t.filter((r) => !st(r)).reduce(
532
+ (r, o) => r + ($n.test(o) ? Dn : o === "" ? zn : Bn),
533
+ a
534
+ );
535
+ }
536
+ function qn(e, n) {
537
+ return e.length === n.length && e.slice(0, -1).every((a, r) => a === n[r]) ? (
538
+ // If two routes are siblings, we should try to match the earlier sibling
539
+ // first. This allows people to have fine-grained control over the matching
540
+ // behavior by simply putting routes with identical paths in the order they
541
+ // want them tried.
542
+ e[e.length - 1] - n[n.length - 1]
543
+ ) : (
544
+ // Otherwise, it doesn't really make sense to rank non-siblings by index,
545
+ // so they sort equally.
546
+ 0
547
+ );
548
+ }
549
+ function Wn(e, n, t = !1) {
550
+ let { routesMeta: a } = e, r = {}, o = "/", l = [];
551
+ for (let s = 0; s < a.length; ++s) {
552
+ let u = a[s], c = s === a.length - 1, f = o === "/" ? n : n.slice(o.length) || "/", v = Se(
553
+ { path: u.relativePath, caseSensitive: u.caseSensitive, end: c },
554
+ f
555
+ ), g = u.route;
556
+ if (!v && c && t && !a[a.length - 1].route.index && (v = Se(
557
+ {
558
+ path: u.relativePath,
559
+ caseSensitive: u.caseSensitive,
560
+ end: !1
561
+ },
562
+ f
563
+ )), !v)
564
+ return null;
565
+ Object.assign(r, v.params), l.push({
566
+ // TODO: Can this as be avoided?
567
+ params: r,
568
+ pathname: W([o, v.pathname]),
569
+ pathnameBase: Xn(
570
+ W([o, v.pathnameBase])
571
+ ),
572
+ route: g
573
+ }), v.pathnameBase !== "/" && (o = W([o, v.pathnameBase]));
574
+ }
575
+ return l;
576
+ }
577
+ function Se(e, n) {
578
+ typeof e == "string" && (e = { path: e, caseSensitive: !1, end: !0 });
579
+ let [t, a] = Vn(
580
+ e.path,
581
+ e.caseSensitive,
582
+ e.end
583
+ ), r = n.match(t);
584
+ if (!r) return null;
585
+ let o = r[0], l = o.replace(/(.)\/+$/, "$1"), s = r.slice(1);
586
+ return {
587
+ params: a.reduce(
588
+ (c, { paramName: f, isOptional: v }, g) => {
589
+ if (f === "*") {
590
+ let x = s[g] || "";
591
+ l = o.slice(0, o.length - x.length).replace(/(.)\/+$/, "$1");
592
+ }
593
+ const p = s[g];
594
+ return v && !p ? c[f] = void 0 : c[f] = (p || "").replace(/%2F/g, "/"), c;
595
+ },
596
+ {}
597
+ ),
598
+ pathname: o,
599
+ pathnameBase: l,
600
+ pattern: e
601
+ };
602
+ }
603
+ function Vn(e, n = !1, t = !0) {
604
+ V(
605
+ e === "*" || !e.endsWith("*") || e.endsWith("/*"),
606
+ `Route path "${e}" will be treated as if it were "${e.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/, "/*")}".`
607
+ );
608
+ let a = [], r = "^" + e.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(
609
+ /\/:([\w-]+)(\?)?/g,
610
+ (l, s, u) => (a.push({ paramName: s, isOptional: u != null }), u ? "/?([^\\/]+)?" : "/([^\\/]+)")
611
+ );
612
+ return e.endsWith("*") ? (a.push({ paramName: "*" }), r += e === "*" || e === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$") : t ? r += "\\/*$" : e !== "" && e !== "/" && (r += "(?:(?=\\/|$))"), [new RegExp(r, n ? void 0 : "i"), a];
613
+ }
614
+ function Hn(e) {
615
+ try {
616
+ return e.split("/").map((n) => decodeURIComponent(n).replace(/\//g, "%2F")).join("/");
617
+ } catch (n) {
618
+ return V(
619
+ !1,
620
+ `The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${n}).`
621
+ ), e;
622
+ }
623
+ }
624
+ function X(e, n) {
625
+ if (n === "/") return e;
626
+ if (!e.toLowerCase().startsWith(n.toLowerCase()))
627
+ return null;
628
+ let t = n.endsWith("/") ? n.length - 1 : n.length, a = e.charAt(t);
629
+ return a && a !== "/" ? null : e.slice(t) || "/";
630
+ }
631
+ function Gn(e, n = "/") {
632
+ let {
633
+ pathname: t,
634
+ search: a = "",
635
+ hash: r = ""
636
+ } = typeof e == "string" ? Ue(e) : e;
637
+ return {
638
+ pathname: t ? t.startsWith("/") ? t : Yn(t, n) : n,
639
+ search: Zn(a),
640
+ hash: Qn(r)
641
+ };
642
+ }
643
+ function Yn(e, n) {
644
+ let t = n.replace(/\/+$/, "").split("/");
645
+ return e.split("/").forEach((r) => {
646
+ r === ".." ? t.length > 1 && t.pop() : r !== "." && t.push(r);
647
+ }), t.length > 1 ? t.join("/") : "/";
648
+ }
649
+ function Oe(e, n, t, a) {
650
+ return `Cannot include a '${e}' character in a manually specified \`to.${n}\` field [${JSON.stringify(
651
+ a
652
+ )}]. Please separate it out to the \`to.${t}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
653
+ }
654
+ function Jn(e) {
655
+ return e.filter(
656
+ (n, t) => t === 0 || n.route.path && n.route.path.length > 0
657
+ );
658
+ }
659
+ function It(e) {
660
+ let n = Jn(e);
661
+ return n.map(
662
+ (t, a) => a === n.length - 1 ? t.pathname : t.pathnameBase
663
+ );
664
+ }
665
+ function Ft(e, n, t, a = !1) {
666
+ let r;
667
+ typeof e == "string" ? r = Ue(e) : (r = { ...e }, P(
668
+ !r.pathname || !r.pathname.includes("?"),
669
+ Oe("?", "pathname", "search", r)
670
+ ), P(
671
+ !r.pathname || !r.pathname.includes("#"),
672
+ Oe("#", "pathname", "hash", r)
673
+ ), P(
674
+ !r.search || !r.search.includes("#"),
675
+ Oe("#", "search", "hash", r)
676
+ ));
677
+ let o = e === "" || r.pathname === "", l = o ? "/" : r.pathname, s;
678
+ if (l == null)
679
+ s = t;
680
+ else {
681
+ let v = n.length - 1;
682
+ if (!a && l.startsWith("..")) {
683
+ let g = l.split("/");
684
+ for (; g[0] === ".."; )
685
+ g.shift(), v -= 1;
686
+ r.pathname = g.join("/");
687
+ }
688
+ s = v >= 0 ? n[v] : "/";
689
+ }
690
+ let u = Gn(r, s), c = l && l !== "/" && l.endsWith("/"), f = (o || l === ".") && t.endsWith("/");
691
+ return !u.pathname.endsWith("/") && (c || f) && (u.pathname += "/"), u;
692
+ }
693
+ var W = (e) => e.join("/").replace(/\/\/+/g, "/"), Xn = (e) => e.replace(/\/+$/, "").replace(/^\/*/, "/"), Zn = (e) => !e || e === "?" ? "" : e.startsWith("?") ? e : "?" + e, Qn = (e) => !e || e === "#" ? "" : e.startsWith("#") ? e : "#" + e;
694
+ function er(e) {
695
+ return e != null && typeof e.status == "number" && typeof e.statusText == "string" && typeof e.internal == "boolean" && "data" in e;
696
+ }
697
+ var At = [
698
+ "POST",
699
+ "PUT",
700
+ "PATCH",
701
+ "DELETE"
702
+ ];
703
+ new Set(
704
+ At
705
+ );
706
+ var tr = [
707
+ "GET",
708
+ ...At
709
+ ];
710
+ new Set(tr);
711
+ var ue = d.createContext(null);
712
+ ue.displayName = "DataRouter";
713
+ var ke = d.createContext(null);
714
+ ke.displayName = "DataRouterState";
715
+ d.createContext(!1);
716
+ var _t = d.createContext({
717
+ isTransitioning: !1
718
+ });
719
+ _t.displayName = "ViewTransition";
720
+ var nr = d.createContext(
721
+ /* @__PURE__ */ new Map()
722
+ );
723
+ nr.displayName = "Fetchers";
724
+ var rr = d.createContext(null);
725
+ rr.displayName = "Await";
726
+ var H = d.createContext(
727
+ null
728
+ );
729
+ H.displayName = "Navigation";
730
+ var qe = d.createContext(
731
+ null
732
+ );
733
+ qe.displayName = "Location";
734
+ var G = d.createContext({
735
+ outlet: null,
736
+ matches: [],
737
+ isDataRoute: !1
738
+ });
739
+ G.displayName = "Route";
740
+ var We = d.createContext(null);
741
+ We.displayName = "RouteError";
742
+ function ar(e, { relative: n } = {}) {
743
+ P(
744
+ Te(),
745
+ // TODO: This error is probably because they somehow have 2 versions of the
746
+ // router loaded. We can help them understand how to avoid that.
747
+ "useHref() may be used only in the context of a <Router> component."
748
+ );
749
+ let { basename: t, navigator: a } = d.useContext(H), { hash: r, pathname: o, search: l } = ge(e, { relative: n }), s = o;
750
+ return t !== "/" && (s = o === "/" ? t : W([t, o])), a.createHref({ pathname: s, search: l, hash: r });
751
+ }
752
+ function Te() {
753
+ return d.useContext(qe) != null;
754
+ }
755
+ function Q() {
756
+ return P(
757
+ Te(),
758
+ // TODO: This error is probably because they somehow have 2 versions of the
759
+ // router loaded. We can help them understand how to avoid that.
760
+ "useLocation() may be used only in the context of a <Router> component."
761
+ ), d.useContext(qe).location;
762
+ }
763
+ var Ot = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
764
+ function $t(e) {
765
+ d.useContext(H).static || d.useLayoutEffect(e);
766
+ }
767
+ function Ve() {
768
+ let { isDataRoute: e } = d.useContext(G);
769
+ return e ? vr() : or();
770
+ }
771
+ function or() {
772
+ P(
773
+ Te(),
774
+ // TODO: This error is probably because they somehow have 2 versions of the
775
+ // router loaded. We can help them understand how to avoid that.
776
+ "useNavigate() may be used only in the context of a <Router> component."
777
+ );
778
+ let e = d.useContext(ue), { basename: n, navigator: t } = d.useContext(H), { matches: a } = d.useContext(G), { pathname: r } = Q(), o = JSON.stringify(It(a)), l = d.useRef(!1);
779
+ return $t(() => {
780
+ l.current = !0;
781
+ }), d.useCallback(
782
+ (u, c = {}) => {
783
+ if (V(l.current, Ot), !l.current) return;
784
+ if (typeof u == "number") {
785
+ t.go(u);
786
+ return;
787
+ }
788
+ let f = Ft(
789
+ u,
790
+ JSON.parse(o),
791
+ r,
792
+ c.relative === "path"
793
+ );
794
+ e == null && n !== "/" && (f.pathname = f.pathname === "/" ? n : W([n, f.pathname])), (c.replace ? t.replace : t.push)(
795
+ f,
796
+ c.state,
797
+ c
798
+ );
799
+ },
800
+ [
801
+ n,
802
+ t,
803
+ o,
804
+ r,
805
+ e
806
+ ]
807
+ );
808
+ }
809
+ d.createContext(null);
810
+ function ge(e, { relative: n } = {}) {
811
+ let { matches: t } = d.useContext(G), { pathname: a } = Q(), r = JSON.stringify(It(t));
812
+ return d.useMemo(
813
+ () => Ft(
814
+ e,
815
+ JSON.parse(r),
816
+ a,
817
+ n === "path"
818
+ ),
819
+ [e, r, a, n]
820
+ );
821
+ }
822
+ function ir(e, n, t, a) {
823
+ P(
824
+ Te(),
825
+ // TODO: This error is probably because they somehow have 2 versions of the
826
+ // router loaded. We can help them understand how to avoid that.
827
+ "useRoutes() may be used only in the context of a <Router> component."
828
+ );
829
+ let { navigator: r } = d.useContext(H), { matches: o } = d.useContext(G), l = o[o.length - 1], s = l ? l.params : {}, u = l ? l.pathname : "/", c = l ? l.pathnameBase : "/", f = l && l.route;
830
+ {
831
+ let y = f && f.path || "";
832
+ Dt(
833
+ u,
834
+ !f || y.endsWith("*") || y.endsWith("*?"),
835
+ `You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${y}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
836
+
837
+ Please change the parent <Route path="${y}"> to <Route path="${y === "/" ? "*" : `${y}/*`}">.`
838
+ );
839
+ }
840
+ let v = Q(), g;
841
+ g = v;
842
+ let p = g.pathname || "/", x = p;
843
+ if (c !== "/") {
844
+ let y = c.replace(/^\//, "").split("/");
845
+ x = "/" + p.replace(/^\//, "").split("/").slice(y.length).join("/");
846
+ }
847
+ let h = Nt(e, { pathname: x });
848
+ return V(
849
+ f || h != null,
850
+ `No routes matched location "${g.pathname}${g.search}${g.hash}" `
851
+ ), V(
852
+ h == null || h[h.length - 1].route.element !== void 0 || h[h.length - 1].route.Component !== void 0 || h[h.length - 1].route.lazy !== void 0,
853
+ `Matched leaf route at location "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`
854
+ ), dr(
855
+ h && h.map(
856
+ (y) => Object.assign({}, y, {
857
+ params: Object.assign({}, s, y.params),
858
+ pathname: W([
859
+ c,
860
+ // Re-encode pathnames that were decoded inside matchRoutes
861
+ r.encodeLocation ? r.encodeLocation(y.pathname).pathname : y.pathname
862
+ ]),
863
+ pathnameBase: y.pathnameBase === "/" ? c : W([
864
+ c,
865
+ // Re-encode pathnames that were decoded inside matchRoutes
866
+ r.encodeLocation ? r.encodeLocation(y.pathnameBase).pathname : y.pathnameBase
867
+ ])
868
+ })
869
+ ),
870
+ o,
871
+ t,
872
+ a
873
+ );
874
+ }
875
+ function lr() {
876
+ let e = pr(), n = er(e) ? `${e.status} ${e.statusText}` : e instanceof Error ? e.message : JSON.stringify(e), t = e instanceof Error ? e.stack : null, a = "rgba(200,200,200, 0.5)", r = { padding: "0.5rem", backgroundColor: a }, o = { padding: "2px 4px", backgroundColor: a }, l = null;
877
+ return console.error(
878
+ "Error handled by React Router default ErrorBoundary:",
879
+ e
880
+ ), l = /* @__PURE__ */ d.createElement(d.Fragment, null, /* @__PURE__ */ d.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ d.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ d.createElement("code", { style: o }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ d.createElement("code", { style: o }, "errorElement"), " prop on your route.")), /* @__PURE__ */ d.createElement(d.Fragment, null, /* @__PURE__ */ d.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ d.createElement("h3", { style: { fontStyle: "italic" } }, n), t ? /* @__PURE__ */ d.createElement("pre", { style: r }, t) : null, l);
881
+ }
882
+ var sr = /* @__PURE__ */ d.createElement(lr, null), ur = class extends d.Component {
883
+ constructor(e) {
884
+ super(e), this.state = {
885
+ location: e.location,
886
+ revalidation: e.revalidation,
887
+ error: e.error
888
+ };
889
+ }
890
+ static getDerivedStateFromError(e) {
891
+ return { error: e };
892
+ }
893
+ static getDerivedStateFromProps(e, n) {
894
+ return n.location !== e.location || n.revalidation !== "idle" && e.revalidation === "idle" ? {
895
+ error: e.error,
896
+ location: e.location,
897
+ revalidation: e.revalidation
898
+ } : {
899
+ error: e.error !== void 0 ? e.error : n.error,
900
+ location: n.location,
901
+ revalidation: e.revalidation || n.revalidation
902
+ };
903
+ }
904
+ componentDidCatch(e, n) {
905
+ console.error(
906
+ "React Router caught the following error during render",
907
+ e,
908
+ n
909
+ );
910
+ }
911
+ render() {
912
+ return this.state.error !== void 0 ? /* @__PURE__ */ d.createElement(G.Provider, { value: this.props.routeContext }, /* @__PURE__ */ d.createElement(
913
+ We.Provider,
914
+ {
915
+ value: this.state.error,
916
+ children: this.props.component
917
+ }
918
+ )) : this.props.children;
919
+ }
920
+ };
921
+ function cr({ routeContext: e, match: n, children: t }) {
922
+ let a = d.useContext(ue);
923
+ return a && a.static && a.staticContext && (n.route.errorElement || n.route.ErrorBoundary) && (a.staticContext._deepestRenderedBoundaryId = n.route.id), /* @__PURE__ */ d.createElement(G.Provider, { value: e }, t);
924
+ }
925
+ function dr(e, n = [], t = null, a = null) {
926
+ if (e == null) {
927
+ if (!t)
928
+ return null;
929
+ if (t.errors)
930
+ e = t.matches;
931
+ else if (n.length === 0 && !t.initialized && t.matches.length > 0)
932
+ e = t.matches;
933
+ else
934
+ return null;
935
+ }
936
+ let r = e, o = t == null ? void 0 : t.errors;
937
+ if (o != null) {
938
+ let u = r.findIndex(
939
+ (c) => c.route.id && (o == null ? void 0 : o[c.route.id]) !== void 0
940
+ );
941
+ P(
942
+ u >= 0,
943
+ `Could not find a matching route for errors on route IDs: ${Object.keys(
944
+ o
945
+ ).join(",")}`
946
+ ), r = r.slice(
947
+ 0,
948
+ Math.min(r.length, u + 1)
949
+ );
950
+ }
951
+ let l = !1, s = -1;
952
+ if (t)
953
+ for (let u = 0; u < r.length; u++) {
954
+ let c = r[u];
955
+ if ((c.route.HydrateFallback || c.route.hydrateFallbackElement) && (s = u), c.route.id) {
956
+ let { loaderData: f, errors: v } = t, g = c.route.loader && !f.hasOwnProperty(c.route.id) && (!v || v[c.route.id] === void 0);
957
+ if (c.route.lazy || g) {
958
+ l = !0, s >= 0 ? r = r.slice(0, s + 1) : r = [r[0]];
959
+ break;
960
+ }
961
+ }
962
+ }
963
+ return r.reduceRight(
964
+ (u, c, f) => {
965
+ let v, g = !1, p = null, x = null;
966
+ t && (v = o && c.route.id ? o[c.route.id] : void 0, p = c.route.errorElement || sr, l && (s < 0 && f === 0 ? (Dt(
967
+ "route-fallback",
968
+ !1,
969
+ "No `HydrateFallback` element provided to render during initial hydration"
970
+ ), g = !0, x = null) : s === f && (g = !0, x = c.route.hydrateFallbackElement || null)));
971
+ let h = n.concat(r.slice(0, f + 1)), j = () => {
972
+ let y;
973
+ return v ? y = p : g ? y = x : c.route.Component ? y = /* @__PURE__ */ d.createElement(c.route.Component, null) : c.route.element ? y = c.route.element : y = u, /* @__PURE__ */ d.createElement(
974
+ cr,
975
+ {
976
+ match: c,
977
+ routeContext: {
978
+ outlet: u,
979
+ matches: h,
980
+ isDataRoute: t != null
981
+ },
982
+ children: y
983
+ }
984
+ );
985
+ };
986
+ return t && (c.route.ErrorBoundary || c.route.errorElement || f === 0) ? /* @__PURE__ */ d.createElement(
987
+ ur,
988
+ {
989
+ location: t.location,
990
+ revalidation: t.revalidation,
991
+ component: p,
992
+ error: v,
993
+ children: j(),
994
+ routeContext: { outlet: null, matches: h, isDataRoute: !0 }
995
+ }
996
+ ) : j();
997
+ },
998
+ null
999
+ );
1000
+ }
1001
+ function He(e) {
1002
+ return `${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
1003
+ }
1004
+ function fr(e) {
1005
+ let n = d.useContext(ue);
1006
+ return P(n, He(e)), n;
1007
+ }
1008
+ function hr(e) {
1009
+ let n = d.useContext(ke);
1010
+ return P(n, He(e)), n;
1011
+ }
1012
+ function mr(e) {
1013
+ let n = d.useContext(G);
1014
+ return P(n, He(e)), n;
1015
+ }
1016
+ function Ge(e) {
1017
+ let n = mr(e), t = n.matches[n.matches.length - 1];
1018
+ return P(
1019
+ t.route.id,
1020
+ `${e} can only be used on routes that contain a unique "id"`
1021
+ ), t.route.id;
1022
+ }
1023
+ function gr() {
1024
+ return Ge(
1025
+ "useRouteId"
1026
+ /* UseRouteId */
1027
+ );
1028
+ }
1029
+ function pr() {
1030
+ var a;
1031
+ let e = d.useContext(We), n = hr(
1032
+ "useRouteError"
1033
+ /* UseRouteError */
1034
+ ), t = Ge(
1035
+ "useRouteError"
1036
+ /* UseRouteError */
1037
+ );
1038
+ return e !== void 0 ? e : (a = n.errors) == null ? void 0 : a[t];
1039
+ }
1040
+ function vr() {
1041
+ let { router: e } = fr(
1042
+ "useNavigate"
1043
+ /* UseNavigateStable */
1044
+ ), n = Ge(
1045
+ "useNavigate"
1046
+ /* UseNavigateStable */
1047
+ ), t = d.useRef(!1);
1048
+ return $t(() => {
1049
+ t.current = !0;
1050
+ }), d.useCallback(
1051
+ async (r, o = {}) => {
1052
+ V(t.current, Ot), t.current && (typeof r == "number" ? e.navigate(r) : await e.navigate(r, { fromRouteId: n, ...o }));
1053
+ },
1054
+ [e, n]
1055
+ );
1056
+ }
1057
+ var ut = {};
1058
+ function Dt(e, n, t) {
1059
+ !n && !ut[e] && (ut[e] = !0, V(!1, t));
1060
+ }
1061
+ d.memo(xr);
1062
+ function xr({
1063
+ routes: e,
1064
+ future: n,
1065
+ state: t
1066
+ }) {
1067
+ return ir(e, void 0, t, n);
1068
+ }
1069
+ var be = "get", we = "application/x-www-form-urlencoded";
1070
+ function Ne(e) {
1071
+ return e != null && typeof e.tagName == "string";
1072
+ }
1073
+ function yr(e) {
1074
+ return Ne(e) && e.tagName.toLowerCase() === "button";
1075
+ }
1076
+ function br(e) {
1077
+ return Ne(e) && e.tagName.toLowerCase() === "form";
1078
+ }
1079
+ function wr(e) {
1080
+ return Ne(e) && e.tagName.toLowerCase() === "input";
1081
+ }
1082
+ function jr(e) {
1083
+ return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
1084
+ }
1085
+ function Cr(e, n) {
1086
+ return e.button === 0 && // Ignore everything but left clicks
1087
+ (!n || n === "_self") && // Let browser handle "target=_blank" etc.
1088
+ !jr(e);
1089
+ }
1090
+ var ye = null;
1091
+ function Sr() {
1092
+ if (ye === null)
1093
+ try {
1094
+ new FormData(
1095
+ document.createElement("form"),
1096
+ // @ts-expect-error if FormData supports the submitter parameter, this will throw
1097
+ 0
1098
+ ), ye = !1;
1099
+ } catch {
1100
+ ye = !0;
1101
+ }
1102
+ return ye;
1103
+ }
1104
+ var Rr = /* @__PURE__ */ new Set([
1105
+ "application/x-www-form-urlencoded",
1106
+ "multipart/form-data",
1107
+ "text/plain"
1108
+ ]);
1109
+ function $e(e) {
1110
+ return e != null && !Rr.has(e) ? (V(
1111
+ !1,
1112
+ `"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${we}"`
1113
+ ), null) : e;
1114
+ }
1115
+ function Er(e, n) {
1116
+ let t, a, r, o, l;
1117
+ if (br(e)) {
1118
+ let s = e.getAttribute("action");
1119
+ a = s ? X(s, n) : null, t = e.getAttribute("method") || be, r = $e(e.getAttribute("enctype")) || we, o = new FormData(e);
1120
+ } else if (yr(e) || wr(e) && (e.type === "submit" || e.type === "image")) {
1121
+ let s = e.form;
1122
+ if (s == null)
1123
+ throw new Error(
1124
+ 'Cannot submit a <button> or <input type="submit"> without a <form>'
1125
+ );
1126
+ let u = e.getAttribute("formaction") || s.getAttribute("action");
1127
+ if (a = u ? X(u, n) : null, t = e.getAttribute("formmethod") || s.getAttribute("method") || be, r = $e(e.getAttribute("formenctype")) || $e(s.getAttribute("enctype")) || we, o = new FormData(s, e), !Sr()) {
1128
+ let { name: c, type: f, value: v } = e;
1129
+ if (f === "image") {
1130
+ let g = c ? `${c}.` : "";
1131
+ o.append(`${g}x`, "0"), o.append(`${g}y`, "0");
1132
+ } else c && o.append(c, v);
1133
+ }
1134
+ } else {
1135
+ if (Ne(e))
1136
+ throw new Error(
1137
+ 'Cannot submit element that is not <form>, <button>, or <input type="submit|image">'
1138
+ );
1139
+ t = be, a = null, r = we, l = e;
1140
+ }
1141
+ return o && r === "text/plain" && (l = o, o = void 0), { action: a, method: t.toLowerCase(), encType: r, formData: o, body: l };
1142
+ }
1143
+ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
1144
+ function Ye(e, n) {
1145
+ if (e === !1 || e === null || typeof e > "u")
1146
+ throw new Error(n);
1147
+ }
1148
+ function kr(e, n, t) {
1149
+ let a = typeof e == "string" ? new URL(
1150
+ e,
1151
+ // This can be called during the SSR flow via PrefetchPageLinksImpl so
1152
+ // don't assume window is available
1153
+ typeof window > "u" ? "server://singlefetch/" : window.location.origin
1154
+ ) : e;
1155
+ return a.pathname === "/" ? a.pathname = `_root.${t}` : n && X(a.pathname, n) === "/" ? a.pathname = `${n.replace(/\/$/, "")}/_root.${t}` : a.pathname = `${a.pathname.replace(/\/$/, "")}.${t}`, a;
1156
+ }
1157
+ async function Tr(e, n) {
1158
+ if (e.id in n)
1159
+ return n[e.id];
1160
+ try {
1161
+ let t = await import(
1162
+ /* @vite-ignore */
1163
+ /* webpackIgnore: true */
1164
+ e.module
1165
+ );
1166
+ return n[e.id] = t, t;
1167
+ } catch (t) {
1168
+ return console.error(
1169
+ `Error loading route module \`${e.module}\`, reloading page...`
1170
+ ), console.error(t), window.__reactRouterContext && window.__reactRouterContext.isSpaMode, window.location.reload(), new Promise(() => {
1171
+ });
1172
+ }
1173
+ }
1174
+ function Nr(e) {
1175
+ return e == null ? !1 : e.href == null ? e.rel === "preload" && typeof e.imageSrcSet == "string" && typeof e.imageSizes == "string" : typeof e.rel == "string" && typeof e.href == "string";
1176
+ }
1177
+ async function Pr(e, n, t) {
1178
+ let a = await Promise.all(
1179
+ e.map(async (r) => {
1180
+ let o = n.routes[r.route.id];
1181
+ if (o) {
1182
+ let l = await Tr(o, t);
1183
+ return l.links ? l.links() : [];
1184
+ }
1185
+ return [];
1186
+ })
1187
+ );
1188
+ return Ar(
1189
+ a.flat(1).filter(Nr).filter((r) => r.rel === "stylesheet" || r.rel === "preload").map(
1190
+ (r) => r.rel === "stylesheet" ? { ...r, rel: "prefetch", as: "style" } : { ...r, rel: "prefetch" }
1191
+ )
1192
+ );
1193
+ }
1194
+ function ct(e, n, t, a, r, o) {
1195
+ let l = (u, c) => t[c] ? u.route.id !== t[c].route.id : !0, s = (u, c) => {
1196
+ var f;
1197
+ return (
1198
+ // param change, /users/123 -> /users/456
1199
+ t[c].pathname !== u.pathname || // splat param changed, which is not present in match.path
1200
+ // e.g. /files/images/avatar.jpg -> files/finances.xls
1201
+ ((f = t[c].route.path) == null ? void 0 : f.endsWith("*")) && t[c].params["*"] !== u.params["*"]
1202
+ );
1203
+ };
1204
+ return o === "assets" ? n.filter(
1205
+ (u, c) => l(u, c) || s(u, c)
1206
+ ) : o === "data" ? n.filter((u, c) => {
1207
+ var v;
1208
+ let f = a.routes[u.route.id];
1209
+ if (!f || !f.hasLoader)
1210
+ return !1;
1211
+ if (l(u, c) || s(u, c))
1212
+ return !0;
1213
+ if (u.route.shouldRevalidate) {
1214
+ let g = u.route.shouldRevalidate({
1215
+ currentUrl: new URL(
1216
+ r.pathname + r.search + r.hash,
1217
+ window.origin
1218
+ ),
1219
+ currentParams: ((v = t[0]) == null ? void 0 : v.params) || {},
1220
+ nextUrl: new URL(e, window.origin),
1221
+ nextParams: u.params,
1222
+ defaultShouldRevalidate: !0
1223
+ });
1224
+ if (typeof g == "boolean")
1225
+ return g;
1226
+ }
1227
+ return !0;
1228
+ }) : [];
1229
+ }
1230
+ function Lr(e, n, { includeHydrateFallback: t } = {}) {
1231
+ return Ir(
1232
+ e.map((a) => {
1233
+ let r = n.routes[a.route.id];
1234
+ if (!r) return [];
1235
+ let o = [r.module];
1236
+ return r.clientActionModule && (o = o.concat(r.clientActionModule)), r.clientLoaderModule && (o = o.concat(r.clientLoaderModule)), t && r.hydrateFallbackModule && (o = o.concat(r.hydrateFallbackModule)), r.imports && (o = o.concat(r.imports)), o;
1237
+ }).flat(1)
1238
+ );
1239
+ }
1240
+ function Ir(e) {
1241
+ return [...new Set(e)];
1242
+ }
1243
+ function Fr(e) {
1244
+ let n = {}, t = Object.keys(e).sort();
1245
+ for (let a of t)
1246
+ n[a] = e[a];
1247
+ return n;
1248
+ }
1249
+ function Ar(e, n) {
1250
+ let t = /* @__PURE__ */ new Set();
1251
+ return new Set(n), e.reduce((a, r) => {
1252
+ let o = JSON.stringify(Fr(r));
1253
+ return t.has(o) || (t.add(o), a.push({ key: o, link: r })), a;
1254
+ }, []);
1255
+ }
1256
+ function Mt() {
1257
+ let e = d.useContext(ue);
1258
+ return Ye(
1259
+ e,
1260
+ "You must render this element inside a <DataRouterContext.Provider> element"
1261
+ ), e;
1262
+ }
1263
+ function _r() {
1264
+ let e = d.useContext(ke);
1265
+ return Ye(
1266
+ e,
1267
+ "You must render this element inside a <DataRouterStateContext.Provider> element"
1268
+ ), e;
1269
+ }
1270
+ var Je = d.createContext(void 0);
1271
+ Je.displayName = "FrameworkContext";
1272
+ function zt() {
1273
+ let e = d.useContext(Je);
1274
+ return Ye(
1275
+ e,
1276
+ "You must render this element inside a <HydratedRouter> element"
1277
+ ), e;
1278
+ }
1279
+ function Or(e, n) {
1280
+ let t = d.useContext(Je), [a, r] = d.useState(!1), [o, l] = d.useState(!1), { onFocus: s, onBlur: u, onMouseEnter: c, onMouseLeave: f, onTouchStart: v } = n, g = d.useRef(null);
1281
+ d.useEffect(() => {
1282
+ if (e === "render" && l(!0), e === "viewport") {
1283
+ let h = (y) => {
1284
+ y.forEach((S) => {
1285
+ l(S.isIntersecting);
1286
+ });
1287
+ }, j = new IntersectionObserver(h, { threshold: 0.5 });
1288
+ return g.current && j.observe(g.current), () => {
1289
+ j.disconnect();
1290
+ };
1291
+ }
1292
+ }, [e]), d.useEffect(() => {
1293
+ if (a) {
1294
+ let h = setTimeout(() => {
1295
+ l(!0);
1296
+ }, 100);
1297
+ return () => {
1298
+ clearTimeout(h);
1299
+ };
1300
+ }
1301
+ }, [a]);
1302
+ let p = () => {
1303
+ r(!0);
1304
+ }, x = () => {
1305
+ r(!1), l(!1);
1306
+ };
1307
+ return t ? e !== "intent" ? [o, g, {}] : [
1308
+ o,
1309
+ g,
1310
+ {
1311
+ onFocus: he(s, p),
1312
+ onBlur: he(u, x),
1313
+ onMouseEnter: he(c, p),
1314
+ onMouseLeave: he(f, x),
1315
+ onTouchStart: he(v, p)
1316
+ }
1317
+ ] : [!1, g, {}];
1318
+ }
1319
+ function he(e, n) {
1320
+ return (t) => {
1321
+ e && e(t), t.defaultPrevented || n(t);
1322
+ };
1323
+ }
1324
+ function $r({ page: e, ...n }) {
1325
+ let { router: t } = Mt(), a = d.useMemo(
1326
+ () => Nt(t.routes, e, t.basename),
1327
+ [t.routes, e, t.basename]
1328
+ );
1329
+ return a ? /* @__PURE__ */ d.createElement(Mr, { page: e, matches: a, ...n }) : null;
1330
+ }
1331
+ function Dr(e) {
1332
+ let { manifest: n, routeModules: t } = zt(), [a, r] = d.useState([]);
1333
+ return d.useEffect(() => {
1334
+ let o = !1;
1335
+ return Pr(e, n, t).then(
1336
+ (l) => {
1337
+ o || r(l);
1338
+ }
1339
+ ), () => {
1340
+ o = !0;
1341
+ };
1342
+ }, [e, n, t]), a;
1343
+ }
1344
+ function Mr({
1345
+ page: e,
1346
+ matches: n,
1347
+ ...t
1348
+ }) {
1349
+ let a = Q(), { manifest: r, routeModules: o } = zt(), { basename: l } = Mt(), { loaderData: s, matches: u } = _r(), c = d.useMemo(
1350
+ () => ct(
1351
+ e,
1352
+ n,
1353
+ u,
1354
+ r,
1355
+ a,
1356
+ "data"
1357
+ ),
1358
+ [e, n, u, r, a]
1359
+ ), f = d.useMemo(
1360
+ () => ct(
1361
+ e,
1362
+ n,
1363
+ u,
1364
+ r,
1365
+ a,
1366
+ "assets"
1367
+ ),
1368
+ [e, n, u, r, a]
1369
+ ), v = d.useMemo(() => {
1370
+ if (e === a.pathname + a.search + a.hash)
1371
+ return [];
1372
+ let x = /* @__PURE__ */ new Set(), h = !1;
1373
+ if (n.forEach((y) => {
1374
+ var b;
1375
+ let S = r.routes[y.route.id];
1376
+ !S || !S.hasLoader || (!c.some((w) => w.route.id === y.route.id) && y.route.id in s && ((b = o[y.route.id]) != null && b.shouldRevalidate) || S.hasClientLoader ? h = !0 : x.add(y.route.id));
1377
+ }), x.size === 0)
1378
+ return [];
1379
+ let j = kr(e, l, "data");
1380
+ return h && x.size > 0 && j.searchParams.set(
1381
+ "_routes",
1382
+ n.filter((y) => x.has(y.route.id)).map((y) => y.route.id).join(",")
1383
+ ), [j.pathname + j.search];
1384
+ }, [
1385
+ l,
1386
+ s,
1387
+ a,
1388
+ r,
1389
+ c,
1390
+ n,
1391
+ e,
1392
+ o
1393
+ ]), g = d.useMemo(
1394
+ () => Lr(f, r),
1395
+ [f, r]
1396
+ ), p = Dr(f);
1397
+ return /* @__PURE__ */ d.createElement(d.Fragment, null, v.map((x) => /* @__PURE__ */ d.createElement("link", { key: x, rel: "prefetch", as: "fetch", href: x, ...t })), g.map((x) => /* @__PURE__ */ d.createElement("link", { key: x, rel: "modulepreload", href: x, ...t })), p.map(({ key: x, link: h }) => (
1398
+ // these don't spread `linkProps` because they are full link descriptors
1399
+ // already with their own props
1400
+ /* @__PURE__ */ d.createElement("link", { key: x, ...h })
1401
+ )));
1402
+ }
1403
+ function zr(...e) {
1404
+ return (n) => {
1405
+ e.forEach((t) => {
1406
+ typeof t == "function" ? t(n) : t != null && (t.current = n);
1407
+ });
1408
+ };
1409
+ }
1410
+ var Bt = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u";
1411
+ try {
1412
+ Bt && (window.__reactRouterVersion = // @ts-expect-error
1413
+ "7.7.1");
1414
+ } catch {
1415
+ }
1416
+ var Kt = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, Ut = d.forwardRef(
1417
+ function({
1418
+ onClick: n,
1419
+ discover: t = "render",
1420
+ prefetch: a = "none",
1421
+ relative: r,
1422
+ reloadDocument: o,
1423
+ replace: l,
1424
+ state: s,
1425
+ target: u,
1426
+ to: c,
1427
+ preventScrollReset: f,
1428
+ viewTransition: v,
1429
+ ...g
1430
+ }, p) {
1431
+ let { basename: x } = d.useContext(H), h = typeof c == "string" && Kt.test(c), j, y = !1;
1432
+ if (typeof c == "string" && h && (j = c, Bt))
1433
+ try {
1434
+ let O = new URL(window.location.href), Y = c.startsWith("//") ? new URL(O.protocol + c) : new URL(c), re = X(Y.pathname, x);
1435
+ Y.origin === O.origin && re != null ? c = re + Y.search + Y.hash : y = !0;
1436
+ } catch {
1437
+ V(
1438
+ !1,
1439
+ `<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
1440
+ );
1441
+ }
1442
+ let S = ar(c, { relative: r }), [b, w, R] = Or(
1443
+ a,
1444
+ g
1445
+ ), K = qr(c, {
1446
+ replace: l,
1447
+ state: s,
1448
+ target: u,
1449
+ preventScrollReset: f,
1450
+ relative: r,
1451
+ viewTransition: v
1452
+ });
1453
+ function D(O) {
1454
+ n && n(O), O.defaultPrevented || K(O);
1455
+ }
1456
+ let ee = (
1457
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
1458
+ /* @__PURE__ */ d.createElement(
1459
+ "a",
1460
+ {
1461
+ ...g,
1462
+ ...R,
1463
+ href: j || S,
1464
+ onClick: y || o ? n : D,
1465
+ ref: zr(p, w),
1466
+ target: u,
1467
+ "data-discover": !h && t === "render" ? "true" : void 0
1468
+ }
1469
+ )
1470
+ );
1471
+ return b && !h ? /* @__PURE__ */ d.createElement(d.Fragment, null, ee, /* @__PURE__ */ d.createElement($r, { page: S })) : ee;
1472
+ }
1473
+ );
1474
+ Ut.displayName = "Link";
1475
+ var Br = d.forwardRef(
1476
+ function({
1477
+ "aria-current": n = "page",
1478
+ caseSensitive: t = !1,
1479
+ className: a = "",
1480
+ end: r = !1,
1481
+ style: o,
1482
+ to: l,
1483
+ viewTransition: s,
1484
+ children: u,
1485
+ ...c
1486
+ }, f) {
1487
+ let v = ge(l, { relative: c.relative }), g = Q(), p = d.useContext(ke), { navigator: x, basename: h } = d.useContext(H), j = p != null && // Conditional usage is OK here because the usage of a data router is static
1488
+ // eslint-disable-next-line react-hooks/rules-of-hooks
1489
+ Yr(v) && s === !0, y = x.encodeLocation ? x.encodeLocation(v).pathname : v.pathname, S = g.pathname, b = p && p.navigation && p.navigation.location ? p.navigation.location.pathname : null;
1490
+ t || (S = S.toLowerCase(), b = b ? b.toLowerCase() : null, y = y.toLowerCase()), b && h && (b = X(b, h) || b);
1491
+ const w = y !== "/" && y.endsWith("/") ? y.length - 1 : y.length;
1492
+ let R = S === y || !r && S.startsWith(y) && S.charAt(w) === "/", K = b != null && (b === y || !r && b.startsWith(y) && b.charAt(y.length) === "/"), D = {
1493
+ isActive: R,
1494
+ isPending: K,
1495
+ isTransitioning: j
1496
+ }, ee = R ? n : void 0, O;
1497
+ typeof a == "function" ? O = a(D) : O = [
1498
+ a,
1499
+ R ? "active" : null,
1500
+ K ? "pending" : null,
1501
+ j ? "transitioning" : null
1502
+ ].filter(Boolean).join(" ");
1503
+ let Y = typeof o == "function" ? o(D) : o;
1504
+ return /* @__PURE__ */ d.createElement(
1505
+ Ut,
1506
+ {
1507
+ ...c,
1508
+ "aria-current": ee,
1509
+ className: O,
1510
+ ref: f,
1511
+ style: Y,
1512
+ to: l,
1513
+ viewTransition: s
1514
+ },
1515
+ typeof u == "function" ? u(D) : u
1516
+ );
1517
+ }
1518
+ );
1519
+ Br.displayName = "NavLink";
1520
+ var Kr = d.forwardRef(
1521
+ ({
1522
+ discover: e = "render",
1523
+ fetcherKey: n,
1524
+ navigate: t,
1525
+ reloadDocument: a,
1526
+ replace: r,
1527
+ state: o,
1528
+ method: l = be,
1529
+ action: s,
1530
+ onSubmit: u,
1531
+ relative: c,
1532
+ preventScrollReset: f,
1533
+ viewTransition: v,
1534
+ ...g
1535
+ }, p) => {
1536
+ let x = Hr(), h = Gr(s, { relative: c }), j = l.toLowerCase() === "get" ? "get" : "post", y = typeof s == "string" && Kt.test(s), S = (b) => {
1537
+ if (u && u(b), b.defaultPrevented) return;
1538
+ b.preventDefault();
1539
+ let w = b.nativeEvent.submitter, R = (w == null ? void 0 : w.getAttribute("formmethod")) || l;
1540
+ x(w || b.currentTarget, {
1541
+ fetcherKey: n,
1542
+ method: R,
1543
+ navigate: t,
1544
+ replace: r,
1545
+ state: o,
1546
+ relative: c,
1547
+ preventScrollReset: f,
1548
+ viewTransition: v
1549
+ });
1550
+ };
1551
+ return /* @__PURE__ */ d.createElement(
1552
+ "form",
1553
+ {
1554
+ ref: p,
1555
+ method: j,
1556
+ action: h,
1557
+ onSubmit: a ? u : S,
1558
+ ...g,
1559
+ "data-discover": !y && e === "render" ? "true" : void 0
1560
+ }
1561
+ );
1562
+ }
1563
+ );
1564
+ Kr.displayName = "Form";
1565
+ function Ur(e) {
1566
+ return `${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
1567
+ }
1568
+ function qt(e) {
1569
+ let n = d.useContext(ue);
1570
+ return P(n, Ur(e)), n;
1571
+ }
1572
+ function qr(e, {
1573
+ target: n,
1574
+ replace: t,
1575
+ state: a,
1576
+ preventScrollReset: r,
1577
+ relative: o,
1578
+ viewTransition: l
1579
+ } = {}) {
1580
+ let s = Ve(), u = Q(), c = ge(e, { relative: o });
1581
+ return d.useCallback(
1582
+ (f) => {
1583
+ if (Cr(f, n)) {
1584
+ f.preventDefault();
1585
+ let v = t !== void 0 ? t : ze(u) === ze(c);
1586
+ s(e, {
1587
+ replace: v,
1588
+ state: a,
1589
+ preventScrollReset: r,
1590
+ relative: o,
1591
+ viewTransition: l
1592
+ });
1593
+ }
1594
+ },
1595
+ [
1596
+ u,
1597
+ s,
1598
+ c,
1599
+ t,
1600
+ a,
1601
+ n,
1602
+ e,
1603
+ r,
1604
+ o,
1605
+ l
1606
+ ]
1607
+ );
1608
+ }
1609
+ var Wr = 0, Vr = () => `__${String(++Wr)}__`;
1610
+ function Hr() {
1611
+ let { router: e } = qt(
1612
+ "useSubmit"
1613
+ /* UseSubmit */
1614
+ ), { basename: n } = d.useContext(H), t = gr();
1615
+ return d.useCallback(
1616
+ async (a, r = {}) => {
1617
+ let { action: o, method: l, encType: s, formData: u, body: c } = Er(
1618
+ a,
1619
+ n
1620
+ );
1621
+ if (r.navigate === !1) {
1622
+ let f = r.fetcherKey || Vr();
1623
+ await e.fetch(f, t, r.action || o, {
1624
+ preventScrollReset: r.preventScrollReset,
1625
+ formData: u,
1626
+ body: c,
1627
+ formMethod: r.method || l,
1628
+ formEncType: r.encType || s,
1629
+ flushSync: r.flushSync
1630
+ });
1631
+ } else
1632
+ await e.navigate(r.action || o, {
1633
+ preventScrollReset: r.preventScrollReset,
1634
+ formData: u,
1635
+ body: c,
1636
+ formMethod: r.method || l,
1637
+ formEncType: r.encType || s,
1638
+ replace: r.replace,
1639
+ state: r.state,
1640
+ fromRouteId: t,
1641
+ flushSync: r.flushSync,
1642
+ viewTransition: r.viewTransition
1643
+ });
1644
+ },
1645
+ [e, n, t]
1646
+ );
1647
+ }
1648
+ function Gr(e, { relative: n } = {}) {
1649
+ let { basename: t } = d.useContext(H), a = d.useContext(G);
1650
+ P(a, "useFormAction must be used inside a RouteContext");
1651
+ let [r] = a.matches.slice(-1), o = { ...ge(e || ".", { relative: n }) }, l = Q();
1652
+ if (e == null) {
1653
+ o.search = l.search;
1654
+ let s = new URLSearchParams(o.search), u = s.getAll("index");
1655
+ if (u.some((f) => f === "")) {
1656
+ s.delete("index"), u.filter((v) => v).forEach((v) => s.append("index", v));
1657
+ let f = s.toString();
1658
+ o.search = f ? `?${f}` : "";
1659
+ }
1660
+ }
1661
+ return (!e || e === ".") && r.route.index && (o.search = o.search ? o.search.replace(/^\?/, "?index&") : "?index"), t !== "/" && (o.pathname = o.pathname === "/" ? t : W([t, o.pathname])), ze(o);
1662
+ }
1663
+ function Yr(e, { relative: n } = {}) {
1664
+ let t = d.useContext(_t);
1665
+ P(
1666
+ t != null,
1667
+ "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
1668
+ );
1669
+ let { basename: a } = qt(
1670
+ "useViewTransitionState"
1671
+ /* useViewTransitionState */
1672
+ ), r = ge(e, { relative: n });
1673
+ if (!t.isTransitioning)
1674
+ return !1;
1675
+ let o = X(t.currentLocation.pathname, a) || t.currentLocation.pathname, l = X(t.nextLocation.pathname, a) || t.nextLocation.pathname;
1676
+ return Se(r.pathname, l) != null || Se(r.pathname, o) != null;
1677
+ }
1678
+ const Wa = ({ message: e }) => {
1679
+ const n = Ve();
1680
+ return /* @__PURE__ */ i.jsxs(
1681
+ Be,
1682
+ {
1683
+ color: "red",
1684
+ title: "Not Found",
1685
+ variant: "404 - Not Found",
1686
+ icon: /* @__PURE__ */ i.jsx(Ke, { size: 12, stroke: 1.5 }),
1687
+ children: [
1688
+ e || "Sorry, the page you are looking for does not exist.",
1689
+ /* @__PURE__ */ i.jsx(U, { variant: "filled", onClick: () => n("/"), children: "Back Home" })
1690
+ ]
1691
+ }
1692
+ );
1693
+ }, Va = ({ message: e }) => /* @__PURE__ */ i.jsx(
1694
+ Be,
1695
+ {
1696
+ color: "red",
1697
+ title: "Not Found",
1698
+ variant: "404 - Not Found",
1699
+ icon: /* @__PURE__ */ i.jsx(Ke, { size: 12, stroke: 1.5 }),
1700
+ children: e || "Sorry, the page you are looking for does not exist."
1701
+ }
1702
+ ), Wt = ({ message: e }) => /* @__PURE__ */ i.jsx(T, { c: "red", size: "sm", children: e || "Not Found" }), Ha = ({ tip: e }) => e === void 0 ? /* @__PURE__ */ i.jsx(B, { justify: "center", align: "center", children: /* @__PURE__ */ i.jsx(je, { color: "blue", size: "md" }) }) : /* @__PURE__ */ i.jsxs(
1703
+ B,
1704
+ {
1705
+ gap: "md",
1706
+ direction: "column",
1707
+ justify: "center",
1708
+ align: "center",
1709
+ style: { height: "100%" },
1710
+ children: [
1711
+ /* @__PURE__ */ i.jsx(je, { color: "blue", size: "md" }),
1712
+ e
1713
+ ]
1714
+ }
1715
+ ), Ga = ({ tip: e }) => e === void 0 ? /* @__PURE__ */ i.jsx(je, { color: "blue", size: "xs" }) : /* @__PURE__ */ i.jsxs(B, { gap: "md", direction: "column", justify: "center", align: "center", children: [
1716
+ /* @__PURE__ */ i.jsx(je, { color: "blue", size: "xs" }),
1717
+ e
1718
+ ] }), Ya = ({ message: e }) => /* @__PURE__ */ i.jsx(
1719
+ Be,
1720
+ {
1721
+ color: "red",
1722
+ title: "Not Found",
1723
+ variant: "403 - Not Authorized",
1724
+ icon: /* @__PURE__ */ i.jsx(Ke, { size: 12, stroke: 1.5 }),
1725
+ children: e || "Sorry, you are not authorized to access this page."
1726
+ }
1727
+ );
1728
+ class dt {
1729
+ constructor() {
1730
+ oe(this, "children", /* @__PURE__ */ new Map());
1731
+ oe(this, "isEndOfWord", !1);
1732
+ oe(this, "value", "");
1733
+ }
1734
+ }
1735
+ class Vt {
1736
+ constructor() {
1737
+ oe(this, "root", new dt());
1738
+ }
1739
+ /**
1740
+ * Inserts a word into the trie structure.
1741
+ * Creates new nodes as needed along the path of characters.
1742
+ *
1743
+ * @param word - The string to insert into the trie
1744
+ */
1745
+ insert(n) {
1746
+ let t = this.root;
1747
+ for (const a of n) {
1748
+ let r = t.children.get(a);
1749
+ r === void 0 && (r = new dt(), t.children.set(a, r)), t = r;
1750
+ }
1751
+ t.isEndOfWord = !0, t.value = n;
1752
+ }
1753
+ /**
1754
+ * Finds the longest prefix match for the given text.
1755
+ * Returns the longest stored word that is a prefix of the input text.
1756
+ *
1757
+ * @param text - The input string to find prefix matches for
1758
+ * @returns Object containing the longest matching prefix and remaining text
1759
+ */
1760
+ findLongestPrefix(n) {
1761
+ let t = this.root, a = { match: "", remaining: n };
1762
+ for (let r = 0; r < n.length; r++) {
1763
+ const o = n[r];
1764
+ if (!t.children.has(o))
1765
+ break;
1766
+ t = t.children.get(o), t.isEndOfWord && (a = {
1767
+ match: t.value,
1768
+ remaining: n.slice(r + 1)
1769
+ });
1770
+ }
1771
+ return a;
1772
+ }
1773
+ }
1774
+ var Jr = /* @__PURE__ */ ((e) => (e[e.Allow = 0] = "Allow", e[e.Denied = 1] = "Denied", e[e.Pending = 2] = "Pending", e))(Jr || {});
1775
+ class Xr extends Vt {
1776
+ constructor() {
1777
+ super(...arguments);
1778
+ oe(this, "pathToKey", /* @__PURE__ */ new Map());
1779
+ }
1780
+ /**
1781
+ * Normalizes a URL path by removing trailing slashes
1782
+ *
1783
+ * @param path - The path which is an URL string to normalize
1784
+ * @returns The normalized path without trailing slash, except for root "/"
1785
+ */
1786
+ normalizePath(t) {
1787
+ return t === "/" ? "/" : t.replace(/\/$/, "");
1788
+ }
1789
+ /**
1790
+ * Inserts an url path into the trie and associates it with a menu key.
1791
+ *
1792
+ * @param path - The URL path to store (e.g., "/admin/users")
1793
+ * @param menuKey - The menu key to associate with this path
1794
+ */
1795
+ insertRoute(t, a) {
1796
+ const r = this.normalizePath(t);
1797
+ this.insert(r), this.pathToKey.set(r, a);
1798
+ }
1799
+ /**
1800
+ * Finds the menu key associated with the longest matching route prefix
1801
+ *
1802
+ * @param route - The URL to match against stored menu url paths
1803
+ * @returns The menu key if a valid prefix match is found, undefined otherwise
1804
+ */
1805
+ findMatchingKey(t) {
1806
+ const a = this.normalizePath(t), r = this.findLongestPrefix(a);
1807
+ if (r.match && this.pathToKey.has(r.match) && (a === r.match || r.remaining.startsWith("/") || r.remaining === ""))
1808
+ return this.pathToKey.get(r.match);
1809
+ }
1810
+ }
1811
+ function Zr(e) {
1812
+ const n = {}, t = {}, a = {}, r = (o, l = []) => {
1813
+ o.forEach((s) => {
1814
+ const u = [...l, s.key];
1815
+ n[s.key] = s, t[s.key] = u, s.route !== void 0 && (a[s.key] = s.route), s.children !== void 0 && s.children.length > 0 && r(s.children, u);
1816
+ });
1817
+ };
1818
+ return r(e), { key2item: n, key2fullpath: t, key2route: a };
1819
+ }
1820
+ function Qr(e) {
1821
+ const n = new Xr(), t = (a) => {
1822
+ a.forEach((r) => {
1823
+ if (r.route !== void 0) {
1824
+ const o = r.route.path.getURL();
1825
+ n.insertRoute(o, r.key);
1826
+ }
1827
+ r.children !== void 0 && r.children.length > 0 && t(r.children);
1828
+ });
1829
+ };
1830
+ return t(e), n;
1831
+ }
1832
+ function ea(e, n) {
1833
+ return e.map((t) => {
1834
+ if (t.route !== void 0)
1835
+ return n(t.route.role) === 0 ? t : null;
1836
+ if (t.children !== void 0) {
1837
+ const a = t.children.filter((r) => r.route !== void 0 ? n(r.route.role) === 0 : !0);
1838
+ return a.length > 0 ? { ...t, children: a } : null;
1839
+ }
1840
+ return t;
1841
+ }).filter((t) => t !== null);
1842
+ }
1843
+ const Ja = (e) => {
1844
+ const n = Ve(), t = Q(), [a, r] = _(/* @__PURE__ */ new Set()), [o, l] = _(/* @__PURE__ */ new Set()), [s, u] = _(), c = k(() => ea(e.items, e.checkPermission), [e.items, e.checkPermission]), f = k(() => Qr(e.items), [e.items]), { key2fullpath: v, key2route: g } = k(
1845
+ () => Zr(c),
1846
+ [c]
1847
+ );
1848
+ Re(() => {
1849
+ const x = t.pathname, h = f.findMatchingKey(x);
1850
+ h !== void 0 && (l(new Set(v[h])), u(h));
1851
+ }, [t, g]);
1852
+ const p = k(() => {
1853
+ function x(h, j) {
1854
+ var S, b;
1855
+ const y = h.children !== void 0 && h.children.length > 0;
1856
+ return y ? /* @__PURE__ */ i.jsxs(
1857
+ "div",
1858
+ {
1859
+ onMouseEnter: () => {
1860
+ o.has(h.key) || r((w) => {
1861
+ const R = new Set(w);
1862
+ return R.add(h.key), R;
1863
+ });
1864
+ },
1865
+ onMouseLeave: () => {
1866
+ o.has(h.key) || r((w) => {
1867
+ const R = new Set(w);
1868
+ return R.delete(h.key), R;
1869
+ });
1870
+ },
1871
+ children: [
1872
+ /* @__PURE__ */ i.jsx(
1873
+ rt,
1874
+ {
1875
+ active: s === h.key,
1876
+ href: (S = h.route) == null ? void 0 : S.path.getURL(),
1877
+ label: h.label,
1878
+ leftSection: h.icon,
1879
+ styles: {
1880
+ label: { fontSize: "md" },
1881
+ root: {
1882
+ borderRadius: "var(--mantine-radius-sm)"
1883
+ }
1884
+ },
1885
+ ml: j === 0 ? void 0 : j === 1 ? "md" : `calc(var(--mantine-spacing-md) * ${j})`,
1886
+ w: "unset",
1887
+ rightSection: y ? /* @__PURE__ */ i.jsx(
1888
+ yn,
1889
+ {
1890
+ size: 12,
1891
+ stroke: 1.5,
1892
+ className: "mantine-rotate-rtl"
1893
+ }
1894
+ ) : void 0,
1895
+ opened: a.has(h.key) || o.has(h.key),
1896
+ onClick: (w) => {
1897
+ w.ctrlKey || w.metaKey || (w.preventDefault(), l((K) => {
1898
+ const D = new Set(K);
1899
+ return K.has(h.key) ? D.delete(h.key) : D.add(h.key), D;
1900
+ }));
1901
+ }
1902
+ },
1903
+ h.key
1904
+ ),
1905
+ (o.has(h.key) || a.has(h.key)) && h.children.map((w) => x(w, j + 1))
1906
+ ]
1907
+ },
1908
+ `container-${h.key}`
1909
+ ) : /* @__PURE__ */ i.jsx(
1910
+ rt,
1911
+ {
1912
+ active: s === h.key,
1913
+ href: (b = h.route) == null ? void 0 : b.path.getURL(),
1914
+ label: h.label,
1915
+ leftSection: h.icon,
1916
+ styles: {
1917
+ label: { fontSize: "md" },
1918
+ root: {
1919
+ borderRadius: "var(--mantine-radius-sm)"
1920
+ }
1921
+ },
1922
+ ml: j === 0 ? void 0 : j === 1 ? "md" : `calc(var(--mantine-spacing-md) * ${j})`,
1923
+ w: "unset",
1924
+ onClick: (w) => {
1925
+ w.ctrlKey || w.metaKey || (w.preventDefault(), h.route != null && h.route.path.path().open(n));
1926
+ }
1927
+ },
1928
+ h.key
1929
+ );
1930
+ }
1931
+ return c.map((h) => x(h, 0));
1932
+ }, [c, s, o, a, n]);
1933
+ return /* @__PURE__ */ i.jsx(i.Fragment, { children: p });
1934
+ }, ie = ({ value: e }) => /* @__PURE__ */ i.jsx(T, { size: "sm", children: e });
1935
+ function Ht(e, n, t, a) {
1936
+ const r = e.getByName(n.targetClass), o = a[n.targetClass];
1937
+ Re(() => {
1938
+ r.fetchByIds(t);
1939
+ }, [t]);
1940
+ const l = {};
1941
+ for (const s of t)
1942
+ l[s] = r.get(s);
1943
+ return [l, o];
1944
+ }
1945
+ const Pe = ne(
1946
+ ({
1947
+ db: e,
1948
+ property: n,
1949
+ value: t,
1950
+ entityRoutes: a
1951
+ }) => {
1952
+ const r = k(() => [t], [t]), [o, l] = Ht(
1953
+ e,
1954
+ n,
1955
+ r,
1956
+ a
1957
+ ), s = o[t];
1958
+ return s === void 0 ? /* @__PURE__ */ i.jsx(T, { size: "sm", children: t }) : s === null ? /* @__PURE__ */ i.jsx(Wt, {}) : l === void 0 ? /* @__PURE__ */ i.jsx(T, { size: "sm", children: s.name }) : /* @__PURE__ */ i.jsx(
1959
+ Rt,
1960
+ {
1961
+ path: l,
1962
+ openInNewPage: !1,
1963
+ urlArgs: { id: s.id },
1964
+ queryArgs: {},
1965
+ children: s.name
1966
+ }
1967
+ );
1968
+ }
1969
+ ), Le = ne(
1970
+ ({
1971
+ db: e,
1972
+ property: n,
1973
+ value: t,
1974
+ entityRoutes: a
1975
+ }) => {
1976
+ const [r, o] = Ht(
1977
+ e,
1978
+ n,
1979
+ t,
1980
+ a
1981
+ );
1982
+ return /* @__PURE__ */ i.jsx($, { gap: "xs", children: t.map((l, s) => {
1983
+ const u = r[l];
1984
+ return u === void 0 ? /* @__PURE__ */ i.jsx(T, { size: "sm", children: t }, l) : u === null ? /* @__PURE__ */ i.jsx(Wt, {}, l) : o === void 0 ? /* @__PURE__ */ i.jsx(T, { size: "sm", children: u.name }, s) : /* @__PURE__ */ i.jsx(
1985
+ Rt,
1986
+ {
1987
+ path: o,
1988
+ openInNewPage: !1,
1989
+ urlArgs: { id: u.id },
1990
+ queryArgs: {},
1991
+ children: u.name
1992
+ },
1993
+ s
1994
+ );
1995
+ }) });
1996
+ }
1997
+ ), Z = {
1998
+ string: ie,
1999
+ integer: ie,
2000
+ float: ie,
2001
+ boolean: ie,
2002
+ "string[]": ie,
2003
+ enum: ie
2004
+ }, ta = ({ property: e, value: n, onChange: t }) => /* @__PURE__ */ i.jsx(
2005
+ q,
2006
+ {
2007
+ id: e.name,
2008
+ type: "checkbox",
2009
+ checked: n,
2010
+ onChange: (a) => {
2011
+ const r = a.target.checked;
2012
+ t(r);
2013
+ }
2014
+ }
2015
+ ), ft = ({
2016
+ property: e,
2017
+ value: n,
2018
+ onChange: t
2019
+ }) => /* @__PURE__ */ i.jsx(
2020
+ q,
2021
+ {
2022
+ id: e.name,
2023
+ type: "number",
2024
+ value: n,
2025
+ onChange: (a) => {
2026
+ const r = a.target.value;
2027
+ t(r === "" ? void 0 : Number(r));
2028
+ }
2029
+ }
2030
+ ), na = {
2031
+ lang2value: {
2032
+ en: "The leading zero is not necessary in international phone number format. For example, if your phone number is 0123456789, you should enter it as 123-456-789.",
2033
+ vi: "Số 0 đầu tiên không cần thiết trong định dạng điện thoại quốc tế. Ví dụ, nếu số điện thoại của bạn là 0123456789, bạn nên nhập nó là 123-456-789."
2034
+ },
2035
+ lang: "en"
2036
+ }, ra = {
2037
+ lang2value: {
2038
+ en: "No valid country code found.",
2039
+ vi: "Không tìm thấy mã quốc gia hợp lệ. "
2040
+ },
2041
+ lang: "en"
2042
+ }, se = {
2043
+ 84: {
2044
+ name: "Vietnam",
2045
+ flags: [N.VN]
2046
+ },
2047
+ 1: {
2048
+ name: "US, Canada",
2049
+ flags: [N.US, N.CA]
2050
+ },
2051
+ 61: {
2052
+ name: "Australia",
2053
+ flags: [N.AU]
2054
+ },
2055
+ 81: {
2056
+ name: "Japan",
2057
+ flags: [N.JP]
2058
+ },
2059
+ 44: {
2060
+ name: "UK",
2061
+ flags: [N.UK]
2062
+ },
2063
+ 33: {
2064
+ name: "France",
2065
+ flags: [N.FR]
2066
+ },
2067
+ 49: {
2068
+ name: "Germany",
2069
+ flags: [N.DE]
2070
+ },
2071
+ 91: {
2072
+ name: "India",
2073
+ flags: [N.IN]
2074
+ },
2075
+ 55: {
2076
+ name: "Brazil",
2077
+ flags: [N.BR]
2078
+ },
2079
+ 34: {
2080
+ name: "Spain",
2081
+ flags: [N.ES]
2082
+ },
2083
+ 39: {
2084
+ name: "Italy",
2085
+ flags: [N.IT]
2086
+ },
2087
+ 64: {
2088
+ name: "New Zealand",
2089
+ flags: [N.NZ]
2090
+ },
2091
+ 52: {
2092
+ name: "Mexico",
2093
+ flags: [N.MX]
2094
+ },
2095
+ 86: {
2096
+ name: "China",
2097
+ flags: [N.CN]
2098
+ }
2099
+ }, aa = (e, n) => {
2100
+ if (e === "")
2101
+ return { match: "84", remaining: "" };
2102
+ const t = e.replace(/[^\d]/g, ""), a = n.findLongestPrefix(t);
2103
+ if (a.match === "")
2104
+ throw new Error(`No valid country code found for phone number: ${e}`);
2105
+ return a;
2106
+ }, ht = ({ value: e }) => {
2107
+ const n = se[e];
2108
+ if (n !== void 0)
2109
+ return /* @__PURE__ */ i.jsxs($, { gap: "sm", wrap: "nowrap", align: "center", children: [
2110
+ /* @__PURE__ */ i.jsxs(T, { size: "sm", children: [
2111
+ "+",
2112
+ e
2113
+ ] }),
2114
+ /* @__PURE__ */ i.jsx($, { gap: 4, wrap: "nowrap", children: n.flags.map((t, a) => /* @__PURE__ */ i.jsx(Me, { flag: t }, a)) })
2115
+ ] });
2116
+ }, oa = ({
2117
+ value: e,
2118
+ onChange: n,
2119
+ error: t,
2120
+ id: a
2121
+ }) => {
2122
+ const [r, o] = _(""), [l, s] = _(!1), [u, c] = _(""), [f, v] = _(!1), g = k(() => {
2123
+ const b = new Vt();
2124
+ return Object.keys(se).forEach((w) => {
2125
+ b.insert(w);
2126
+ }), b;
2127
+ }, [se]), { rawInput: p } = k(() => {
2128
+ try {
2129
+ const { match: b, remaining: w } = aa(
2130
+ e,
2131
+ g
2132
+ );
2133
+ return c(b), v(!1), {
2134
+ rawInput: w
2135
+ };
2136
+ } catch {
2137
+ return v(!0), c(""), {
2138
+ rawInput: e
2139
+ };
2140
+ }
2141
+ }, [e]), x = bt({
2142
+ onDropdownClose: () => {
2143
+ x.resetSelectedOption(), o("");
2144
+ },
2145
+ onDropdownOpen: () => {
2146
+ x.updateSelectedOptionIndex("active");
2147
+ }
2148
+ }), h = k(() => Object.keys(se), [se]), j = (b, w) => {
2149
+ const R = b.replace(/[^\d]/g, "");
2150
+ return R.length === 0 ? `+${w}` : R.startsWith("0") ? (s(!0), `+${w}${R}`) : (s(!1), `+${w}${R}`);
2151
+ }, y = k(() => h.filter((b) => se[b].name.toLowerCase().includes(r.toLowerCase()) || b.includes(r)), [r, h]), S = k(() => y.map((b, w) => /* @__PURE__ */ i.jsx(F.Option, { value: b, children: /* @__PURE__ */ i.jsx(ht, { value: b }) }, w)), [y]);
2152
+ return /* @__PURE__ */ i.jsxs("div", { children: [
2153
+ /* @__PURE__ */ i.jsx(A, { gutter: "xs", children: /* @__PURE__ */ i.jsx(A.Col, { children: /* @__PURE__ */ i.jsxs($, { gap: 5, children: [
2154
+ /* @__PURE__ */ i.jsxs(
2155
+ F,
2156
+ {
2157
+ store: x,
2158
+ position: "top-start",
2159
+ onOptionSubmit: (b) => {
2160
+ o(""), x.closeDropdown(), n({
2161
+ target: { value: j(p, b) }
2162
+ });
2163
+ },
2164
+ children: [
2165
+ /* @__PURE__ */ i.jsx(F.Target, { children: /* @__PURE__ */ i.jsx(
2166
+ un,
2167
+ {
2168
+ component: "button",
2169
+ type: "button",
2170
+ pointer: !0,
2171
+ rightSection: /* @__PURE__ */ i.jsx(F.Chevron, {}),
2172
+ onClick: () => x.toggleDropdown(),
2173
+ rightSectionPointerEvents: "none",
2174
+ w: 110,
2175
+ children: /* @__PURE__ */ i.jsx(ht, { value: u })
2176
+ }
2177
+ ) }),
2178
+ /* @__PURE__ */ i.jsxs(F.Dropdown, { children: [
2179
+ /* @__PURE__ */ i.jsx(
2180
+ F.Search,
2181
+ {
2182
+ leftSection: /* @__PURE__ */ i.jsx(Ct, { size: 14, stroke: 1.5 }),
2183
+ placeholder: ".....",
2184
+ value: r,
2185
+ onChange: (b) => o(b.currentTarget.value)
2186
+ }
2187
+ ),
2188
+ /* @__PURE__ */ i.jsx(F.Options, { children: S.length > 0 ? S : /* @__PURE__ */ i.jsx(F.Empty, { children: /* @__PURE__ */ i.jsx(T, { size: "sm", children: "Nothing found" }) }) })
2189
+ ] })
2190
+ ]
2191
+ }
2192
+ ),
2193
+ u === "" ? /* @__PURE__ */ i.jsx(
2194
+ q,
2195
+ {
2196
+ id: a,
2197
+ value: p,
2198
+ type: "phone_number",
2199
+ onChange: (b) => {
2200
+ n({ target: { value: b.target.value } });
2201
+ },
2202
+ error: t,
2203
+ flex: 1
2204
+ }
2205
+ ) : /* @__PURE__ */ i.jsx(
2206
+ q,
2207
+ {
2208
+ id: a,
2209
+ value: p,
2210
+ type: "phone_number",
2211
+ onAccept: (b) => {
2212
+ const w = b.replace(/[^\d]/g, "");
2213
+ n({
2214
+ target: { value: j(w, u) }
2215
+ });
2216
+ },
2217
+ component: En,
2218
+ mask: "000-000-0000",
2219
+ error: t,
2220
+ flex: 1
2221
+ }
2222
+ )
2223
+ ] }) }) }),
2224
+ (l || f || t && typeof t == "string") && /* @__PURE__ */ i.jsx(A, { gutter: "xs", children: /* @__PURE__ */ i.jsx(A.Col, { children: /* @__PURE__ */ i.jsx(q.Error, { children: l ? /* @__PURE__ */ i.jsx(M, { value: na }) : f ? /* @__PURE__ */ i.jsx(M, { value: ra }) : t }) }) })
2225
+ ] });
2226
+ }, De = ({
2227
+ property: e,
2228
+ error: n,
2229
+ value: t,
2230
+ onChange: a
2231
+ }) => {
2232
+ const [r, o] = k(() => e.constraints.includes("password") ? ["password", cn] : e.constraints.includes("phone_number") ? ["phone_number", oa] : [e.constraints.includes("email") ? "email" : e.constraints.includes("url") ? "url" : "text", q], [e.constraints]);
2233
+ return /* @__PURE__ */ i.jsx(
2234
+ o,
2235
+ {
2236
+ id: e.name,
2237
+ value: t,
2238
+ type: r,
2239
+ onChange: (l) => a(l.target.value),
2240
+ error: n
2241
+ }
2242
+ );
2243
+ }, mt = {
2244
+ integer: ft,
2245
+ float: ft,
2246
+ string: De,
2247
+ boolean: ta,
2248
+ "string[]": De,
2249
+ enum: De
2250
+ };
2251
+ function ia(e, n) {
2252
+ const [t, a] = _(""), [r, o] = _([]);
2253
+ return Re(() => {
2254
+ e.getByName(n.targetClass).fetch({ limit: 100, offset: 0 }).then((s) => o(s.records));
2255
+ }, [n.name]), {
2256
+ data: r,
2257
+ query: t,
2258
+ setQuery: (s) => {
2259
+ a(s);
2260
+ const u = e.getByName(n.targetClass);
2261
+ o(
2262
+ u.filter(
2263
+ (c) => c.name.toLowerCase().includes(s.toLowerCase())
2264
+ )
2265
+ );
2266
+ },
2267
+ table: e.getByName(n.targetClass)
2268
+ };
2269
+ }
2270
+ const la = (e) => e.name, sa = (e) => /* @__PURE__ */ i.jsx(T, { size: "sm", children: e.name }), ua = ne(
2271
+ (e) => /* @__PURE__ */ i.jsx("h1", { children: "SingleForeignKey" })
2272
+ ), ca = ne(
2273
+ ({
2274
+ db: e,
2275
+ property: n,
2276
+ value: t,
2277
+ onChange: a
2278
+ }) => {
2279
+ const { table: r, data: o, query: l, setQuery: s } = ia(
2280
+ e,
2281
+ n
2282
+ );
2283
+ return /* @__PURE__ */ i.jsxs(Ee, { gap: "sm", children: [
2284
+ /* @__PURE__ */ i.jsx(
2285
+ da,
2286
+ {
2287
+ name: n.name,
2288
+ query: l,
2289
+ setQuery: s,
2290
+ data: o,
2291
+ onSelect: (u) => {
2292
+ t.includes(u) || a([...t, u]);
2293
+ },
2294
+ renderOption: la,
2295
+ isIdInteger: n.datatype === "integer"
2296
+ }
2297
+ ),
2298
+ /* @__PURE__ */ i.jsx(
2299
+ fa,
2300
+ {
2301
+ items: t.map((u) => r.get(u)),
2302
+ onDelete: (u) => {
2303
+ a(t.filter((c) => c !== u.id));
2304
+ },
2305
+ render: sa
2306
+ }
2307
+ )
2308
+ ] });
2309
+ }
2310
+ ), da = ({
2311
+ name: e,
2312
+ data: n,
2313
+ onSelect: t,
2314
+ renderOption: a,
2315
+ isIdInteger: r,
2316
+ query: o,
2317
+ setQuery: l
2318
+ }) => {
2319
+ const s = bt({
2320
+ onDropdownClose: () => s.resetSelectedOption()
2321
+ }), u = k(() => n.map((c) => (
2322
+ // value has to be a string
2323
+ /* @__PURE__ */ i.jsx(F.Option, { value: c.id.toString(), children: a(c) }, c.id)
2324
+ )), [n]);
2325
+ return /* @__PURE__ */ i.jsxs(
2326
+ F,
2327
+ {
2328
+ store: s,
2329
+ onOptionSubmit: (c) => {
2330
+ t(r ? parseInt(c) : c), l(""), s.closeDropdown();
2331
+ },
2332
+ offset: 0,
2333
+ shadow: "sm",
2334
+ children: [
2335
+ /* @__PURE__ */ i.jsx(F.Target, { children: /* @__PURE__ */ i.jsx(
2336
+ q,
2337
+ {
2338
+ id: e,
2339
+ pointer: !0,
2340
+ rightSection: /* @__PURE__ */ i.jsx(Ct, { size: 16, stroke: 1.5 }),
2341
+ rightSectionPointerEvents: "none",
2342
+ onClick: () => s.toggleDropdown(),
2343
+ placeholder: "Type to search...",
2344
+ value: o,
2345
+ onChange: (c) => {
2346
+ l(c.currentTarget.value);
2347
+ }
2348
+ }
2349
+ ) }),
2350
+ /* @__PURE__ */ i.jsx(F.Dropdown, { children: /* @__PURE__ */ i.jsx(F.Options, { children: u.length === 0 ? /* @__PURE__ */ i.jsx(F.Empty, { children: "Nothing found" }) : u }) })
2351
+ ]
2352
+ }
2353
+ );
2354
+ }, fa = ({
2355
+ items: e,
2356
+ onDelete: n,
2357
+ render: t
2358
+ }) => {
2359
+ const a = k(() => {
2360
+ const r = [];
2361
+ for (let o = 0; o < e.length; o++) {
2362
+ const l = e[o];
2363
+ r.push(
2364
+ /* @__PURE__ */ i.jsxs($, { justify: "space-between", p: "sm", children: [
2365
+ t(l),
2366
+ /* @__PURE__ */ i.jsx(dn, { size: "sm", onClick: () => n(l) })
2367
+ ] }, o)
2368
+ ), o < e.length - 1 && r.push(/* @__PURE__ */ i.jsx(fn, {}, `divider-${o}`));
2369
+ }
2370
+ return r;
2371
+ }, [e]);
2372
+ if (a.length !== 0)
2373
+ return /* @__PURE__ */ i.jsx(te, { bd: "1px solid #ddd", children: a });
2374
+ }, ha = "_requiredLabelLeft_l5p83_1", ma = "_requiredLabelRight_l5p83_11", gt = {
2375
+ requiredLabelLeft: ha,
2376
+ requiredLabelRight: ma
2377
+ }, ga = ({
2378
+ label: e,
2379
+ name: n,
2380
+ required: t = !1,
2381
+ tooltip: a,
2382
+ style: r,
2383
+ align: o = "left"
2384
+ }) => {
2385
+ const l = t ? o === "left" ? gt.requiredLabelRight : gt.requiredLabelLeft : "";
2386
+ return /* @__PURE__ */ i.jsx(B, { align: "center", h: 36, children: /* @__PURE__ */ i.jsx("label", { htmlFor: n, style: r, children: /* @__PURE__ */ i.jsxs($, { gap: 4, children: [
2387
+ /* @__PURE__ */ i.jsx(T, { size: "sm", className: l, children: e }),
2388
+ a !== void 0 && /* @__PURE__ */ i.jsx(wt, { label: a, withArrow: !0, children: /* @__PURE__ */ i.jsx(
2389
+ St,
2390
+ {
2391
+ size: 16,
2392
+ stroke: 1.5,
2393
+ style: { color: "var(--mantine-color-dimmed)" }
2394
+ }
2395
+ ) })
2396
+ ] }) }) });
2397
+ }, pa = {
2398
+ type: "vertical",
2399
+ helpAlwaysVisible: !1
2400
+ }, va = ne(
2401
+ ({
2402
+ store: e,
2403
+ record: n,
2404
+ property: t,
2405
+ layout: a = pa,
2406
+ InputComponent: r,
2407
+ validator: o
2408
+ }) => {
2409
+ const [l, s] = _(void 0), u = n[t.tsName], c = (v) => {
2410
+ var p;
2411
+ if (Et(n))
2412
+ n[t.updateFuncName](v);
2413
+ else {
2414
+ const x = n.toDraft();
2415
+ x[t.updateFuncName](v), e.setDraft(x);
2416
+ }
2417
+ const g = o(v);
2418
+ g.isValid ? s(void 0) : s(
2419
+ (p = g.errorMessage) == null ? void 0 : p.t({ args: { name: t.label } })
2420
+ );
2421
+ };
2422
+ if (xa(a))
2423
+ return /* @__PURE__ */ i.jsxs(Ee, { gap: 5, children: [
2424
+ /* @__PURE__ */ i.jsxs(A, { gutter: "sm", children: [
2425
+ /* @__PURE__ */ i.jsx(
2426
+ A.Col,
2427
+ {
2428
+ span: a.labelCol,
2429
+ style: {
2430
+ display: "flex",
2431
+ justifyContent: a.align || "left"
2432
+ },
2433
+ children: /* @__PURE__ */ i.jsx(
2434
+ ga,
2435
+ {
2436
+ label: /* @__PURE__ */ i.jsx(M, { value: t.label }),
2437
+ name: t.name,
2438
+ required: t.isRequired,
2439
+ tooltip: t.description !== void 0 ? /* @__PURE__ */ i.jsx(M, { value: t.description }) : void 0,
2440
+ align: a.align
2441
+ }
2442
+ )
2443
+ }
2444
+ ),
2445
+ /* @__PURE__ */ i.jsx(A.Col, { span: a.itemCol, children: /* @__PURE__ */ i.jsx(
2446
+ r,
2447
+ {
2448
+ db: e.db,
2449
+ property: t,
2450
+ value: u,
2451
+ error: l !== void 0,
2452
+ onChange: c
2453
+ }
2454
+ ) })
2455
+ ] }),
2456
+ l !== void 0 && /* @__PURE__ */ i.jsxs(A, { gutter: "sm", children: [
2457
+ /* @__PURE__ */ i.jsx(A.Col, { span: a.labelCol }),
2458
+ /* @__PURE__ */ i.jsx(A.Col, { span: a.itemCol, children: /* @__PURE__ */ i.jsx(q.Error, { children: l }) })
2459
+ ] })
2460
+ ] });
2461
+ let f = /* @__PURE__ */ i.jsx(M, { value: t.label });
2462
+ return !a.helpAlwaysVisible && t.description !== void 0 && (f = /* @__PURE__ */ i.jsxs($, { gap: 4, style: { display: "inline-flex" }, children: [
2463
+ f,
2464
+ /* @__PURE__ */ i.jsx(
2465
+ wt,
2466
+ {
2467
+ label: /* @__PURE__ */ i.jsx(M, { value: t.description }),
2468
+ withArrow: !0,
2469
+ children: /* @__PURE__ */ i.jsx(
2470
+ St,
2471
+ {
2472
+ size: 16,
2473
+ stroke: 1.5,
2474
+ style: { color: "var(--mantine-color-dimmed)" }
2475
+ }
2476
+ )
2477
+ }
2478
+ )
2479
+ ] })), /* @__PURE__ */ i.jsx(
2480
+ q.Wrapper,
2481
+ {
2482
+ label: f,
2483
+ description: a.helpAlwaysVisible && t.description !== void 0 ? /* @__PURE__ */ i.jsx(M, { value: t.description }) : void 0,
2484
+ required: t.isRequired,
2485
+ children: /* @__PURE__ */ i.jsx(
2486
+ r,
2487
+ {
2488
+ db: e.db,
2489
+ property: t,
2490
+ value: u,
2491
+ error: l,
2492
+ onChange: c
2493
+ }
2494
+ )
2495
+ }
2496
+ );
2497
+ }
2498
+ );
2499
+ function xa(e) {
2500
+ return e.type === "horizontal";
2501
+ }
2502
+ const pt = 12, Xa = (e) => {
2503
+ const n = e.schema, t = k(() => {
2504
+ const a = Math.max(
2505
+ ...e.fieldGroups.map((r) => Math.max(...r.fields.map((o) => o.length)))
2506
+ );
2507
+ return e.fieldGroups.map((r, o) => ya(
2508
+ n,
2509
+ e.store,
2510
+ e.record,
2511
+ o,
2512
+ r,
2513
+ a,
2514
+ e.layout
2515
+ ));
2516
+ }, [n, e.store, e.record, e.fieldGroups, e.layout]);
2517
+ return /* @__PURE__ */ i.jsx(
2518
+ "form",
2519
+ {
2520
+ onSubmit: e.onSubmit === void 0 ? void 0 : (a) => {
2521
+ a.preventDefault(), e.onSubmit !== void 0 && Et(e.record) && e.onSubmit(e.record);
2522
+ },
2523
+ children: /* @__PURE__ */ i.jsxs(Ee, { gap: "sm", className: e.className, style: e.styles, children: [
2524
+ t,
2525
+ /* @__PURE__ */ i.jsx($, { gap: "sm", children: e.actions.map((a, r) => /* @__PURE__ */ i.jsx(
2526
+ U,
2527
+ {
2528
+ variant: a.variant,
2529
+ onClick: () => {
2530
+ a.onClick !== void 0 && a.onClick();
2531
+ },
2532
+ disabled: a.disabled,
2533
+ children: a.label
2534
+ },
2535
+ r
2536
+ )) })
2537
+ ] })
2538
+ }
2539
+ );
2540
+ };
2541
+ function ya(e, n, t, a, r, o, l) {
2542
+ const s = r.fields, u = [];
2543
+ for (let f = 0; f < s.length; f++) {
2544
+ const v = pt / s[f].length;
2545
+ if (!Number.isInteger(v))
2546
+ throw new Error(`Span must be an integer, but got ${v} for row ${f}`);
2547
+ let g;
2548
+ l !== void 0 && typeof l == "object" && l.type === "horizontal" ? g = {
2549
+ ...l,
2550
+ // the size of labelCol must match the minimum size of labelCol across different groups
2551
+ // and rows -- if the result isn't a whole number, we may see unaligned labels
2552
+ // but this is okay as users will need to adjust the layout anyway.
2553
+ labelCol: Math.floor(
2554
+ l.labelCol * s[f].length / o
2555
+ ),
2556
+ itemCol: pt - Math.floor(l.labelCol * s[f].length / o)
2557
+ } : g = l;
2558
+ for (let p = 0; p < s[f].length; p++) {
2559
+ const x = s[f][p], h = e.allProperties[x];
2560
+ let j;
2561
+ if (me(h))
2562
+ j = h.cardinality === "N:N" || h.cardinality === "1:N" ? ca : ua;
2563
+ else {
2564
+ if (mt[h.datatype] === void 0)
2565
+ throw new Error(
2566
+ `No input component found for datatype ${h.datatype}`
2567
+ );
2568
+ j = mt[h.datatype];
2569
+ }
2570
+ u.push(
2571
+ /* @__PURE__ */ i.jsx(A.Col, { span: v, children: /* @__PURE__ */ i.jsx(
2572
+ va,
2573
+ {
2574
+ store: n,
2575
+ record: t,
2576
+ property: h,
2577
+ layout: g,
2578
+ InputComponent: j,
2579
+ validator: e.validators[x]
2580
+ }
2581
+ ) }, `${f}-${p}`)
2582
+ );
2583
+ }
2584
+ }
2585
+ const c = /* @__PURE__ */ i.jsx(A, { gutter: "sm", children: u }, a);
2586
+ return r.name !== void 0 ? /* @__PURE__ */ i.jsx(hn, { legend: r.name, children: c }, a) : c;
2587
+ }
2588
+ const Gt = ({
2589
+ actions: e,
2590
+ reloadData: n,
2591
+ selectedRowKeys: t,
2592
+ size: a = "xs"
2593
+ }) => /* @__PURE__ */ i.jsxs($, { gap: a, children: [
2594
+ (e == null ? void 0 : e.add) && /* @__PURE__ */ i.jsx(
2595
+ U,
2596
+ {
2597
+ variant: "light",
2598
+ leftSection: /* @__PURE__ */ i.jsx(bn, { size: 16, stroke: 1.5 }),
2599
+ size: a,
2600
+ onClick: e.add,
2601
+ children: "Add"
2602
+ }
2603
+ ),
2604
+ (e == null ? void 0 : e.edit) && /* @__PURE__ */ i.jsx(
2605
+ U,
2606
+ {
2607
+ leftSection: /* @__PURE__ */ i.jsx(wn, { size: 16, stroke: 1.5 }),
2608
+ size: a,
2609
+ variant: "light",
2610
+ onClick: () => e.edit !== void 0 && e.edit(t[0]),
2611
+ disabled: t.length !== 1,
2612
+ children: "Edit"
2613
+ }
2614
+ ),
2615
+ (e == null ? void 0 : e.reload) && /* @__PURE__ */ i.jsx(
2616
+ U,
2617
+ {
2618
+ leftSection: /* @__PURE__ */ i.jsx(jn, { size: 16, stroke: 1.5 }),
2619
+ size: a,
2620
+ onClick: n,
2621
+ variant: "light",
2622
+ children: "Reload"
2623
+ }
2624
+ ),
2625
+ (e == null ? void 0 : e.import) && /* @__PURE__ */ i.jsx(
2626
+ U,
2627
+ {
2628
+ leftSection: /* @__PURE__ */ i.jsx(Cn, { size: 16, stroke: 1.5 }),
2629
+ size: a,
2630
+ variant: "light",
2631
+ onClick: e.import,
2632
+ children: "Import"
2633
+ }
2634
+ ),
2635
+ (e == null ? void 0 : e.export) && /* @__PURE__ */ i.jsx(
2636
+ U,
2637
+ {
2638
+ leftSection: /* @__PURE__ */ i.jsx(Sn, { size: 16, stroke: 1.5 }),
2639
+ size: a,
2640
+ variant: "light",
2641
+ onClick: e.export,
2642
+ children: "Export"
2643
+ }
2644
+ )
2645
+ ] }), Yt = (e) => e !== void 0 && (e.add !== void 0 || e.edit !== void 0 || e.delete !== void 0 || e.export !== void 0 || e.reload === !0 || e.import !== void 0), ba = "__selectcol__", { Thead: wa, Tr: vt, Th: ja, Tbody: Ca, Td: Sa } = jt, Jt = (e) => {
2646
+ const n = /* @__PURE__ */ i.jsxs(jt, { striped: !0, highlightOnHover: !0, verticalSpacing: "xs", children: [
2647
+ /* @__PURE__ */ i.jsx(wa, { children: e.table.getHeaderGroups().map((a) => /* @__PURE__ */ i.jsx(vt, { children: a.headers.map((r) => /* @__PURE__ */ i.jsx(
2648
+ ja,
2649
+ {
2650
+ w: r.id === ba ? "1%" : void 0,
2651
+ children: r.isPlaceholder ? null : at(
2652
+ r.column.columnDef.header,
2653
+ r.getContext()
2654
+ )
2655
+ },
2656
+ r.id
2657
+ )) }, a.id)) }),
2658
+ /* @__PURE__ */ i.jsx(Ca, { pos: "relative", children: e.table.getRowModel().rows.map((a) => /* @__PURE__ */ i.jsx(
2659
+ vt,
2660
+ {
2661
+ bg: e.selectedRowKeys[a.id] ? "var(--mantine-color-blue-light)" : void 0,
2662
+ children: a.getVisibleCells().map((r) => /* @__PURE__ */ i.jsx(Sa, { children: at(r.column.columnDef.cell, r.getContext()) }, r.id))
2663
+ },
2664
+ a.id
2665
+ )) })
2666
+ ] });
2667
+ if (!e.bordered) return n;
2668
+ const t = {};
2669
+ return e.hasTopSection && (t.borderTopLeftRadius = 0, t.borderTopRightRadius = 0), e.hasBottomSection && (t.borderBottomLeftRadius = 0, t.borderBottomRightRadius = 0), /* @__PURE__ */ i.jsx(te, { withBorder: !0, p: 0, style: t, children: n });
2670
+ }, Ra = "_pageSizeSelectorActive_1wv6j_1", Ea = {
2671
+ pageSizeSelectorActive: Ra
2672
+ }, Xt = ({
2673
+ total: e,
2674
+ pageIndex: n,
2675
+ pageSize: t,
2676
+ allowPageSizeChange: a = !0,
2677
+ onUpdatePagination: r
2678
+ }) => {
2679
+ const o = /* @__PURE__ */ i.jsx(
2680
+ mn,
2681
+ {
2682
+ size: "sm",
2683
+ total: e,
2684
+ value: n + 1,
2685
+ onChange: (l) => r(l - 1, t)
2686
+ }
2687
+ );
2688
+ return a ? /* @__PURE__ */ i.jsxs($, { gap: "sm", children: [
2689
+ /* @__PURE__ */ i.jsxs("div", { children: [
2690
+ /* @__PURE__ */ i.jsx(T, { size: "sm", component: "span", pr: "xs", c: "dimmed", children: "Records per page" }),
2691
+ /* @__PURE__ */ i.jsx(
2692
+ ka,
2693
+ {
2694
+ size: "sm",
2695
+ values: ["10", "20", "50", "100"],
2696
+ value: t.toString(),
2697
+ onChange: (l) => {
2698
+ r(0, parseInt(l, 10));
2699
+ }
2700
+ }
2701
+ )
2702
+ ] }),
2703
+ o
2704
+ ] }) : o;
2705
+ }, xt = {
2706
+ xs: ce(22),
2707
+ sm: ce(26),
2708
+ md: ce(32),
2709
+ lg: ce(38),
2710
+ xl: ce(44)
2711
+ };
2712
+ function ka({
2713
+ size: e,
2714
+ values: n,
2715
+ value: t,
2716
+ onChange: a
2717
+ }) {
2718
+ return /* @__PURE__ */ i.jsxs(le, { withinPortal: !0, withArrow: !0, offset: 2, children: [
2719
+ /* @__PURE__ */ i.jsx(gn, { children: /* @__PURE__ */ i.jsx(
2720
+ U,
2721
+ {
2722
+ size: e,
2723
+ variant: "default",
2724
+ rightSection: /* @__PURE__ */ i.jsx(Rn, { size: 16, stroke: 1.5 }),
2725
+ style: [
2726
+ { fontWeight: "normal" },
2727
+ (r) => ({
2728
+ height: xt[e],
2729
+ paddingLeft: r.spacing[e],
2730
+ paddingRight: r.spacing[e]
2731
+ })
2732
+ ],
2733
+ styles: {
2734
+ section: {
2735
+ marginInlineStart: 2
2736
+ }
2737
+ },
2738
+ children: t
2739
+ }
2740
+ ) }),
2741
+ /* @__PURE__ */ i.jsx(pn, { children: n.map((r) => {
2742
+ const o = r === t;
2743
+ return /* @__PURE__ */ i.jsx(
2744
+ vn,
2745
+ {
2746
+ className: o ? Ea.pageSizeSelectorActive : void 0,
2747
+ style: [
2748
+ { height: xt[e] }
2749
+ // isCurrent
2750
+ // ? {
2751
+ // color: "var(--mantine-color-text)",
2752
+ // // backgroundColor: "var(--mantine-primary-color-filled)",
2753
+ // opacity: 1,
2754
+ // }
2755
+ // : undefined,
2756
+ ],
2757
+ disabled: o,
2758
+ onClick: () => a(r),
2759
+ children: /* @__PURE__ */ i.jsx(T, { component: "div", size: e, children: r })
2760
+ },
2761
+ r
2762
+ );
2763
+ }) })
2764
+ ] });
2765
+ }
2766
+ const Ta = /* @__PURE__ */ new Set(["topRight", "bottomRight"]), Za = (e) => {
2767
+ var y, S;
2768
+ const [n, t] = _({
2769
+ records: [],
2770
+ total: 0
2771
+ }), [a, r] = _(!1), [o, l] = _(
2772
+ {}
2773
+ ), s = (b) => {
2774
+ r(!0), e.getData(b).then((w) => {
2775
+ t(w), r(!1);
2776
+ });
2777
+ }, u = (b, w) => {
2778
+ const R = {
2779
+ ...e.query.query,
2780
+ limit: w,
2781
+ offset: b * w
2782
+ };
2783
+ e.query.update(R);
2784
+ }, [c, f, v] = k(() => {
2785
+ const b = e.query.query.limit, w = Math.floor(
2786
+ (e.query.query.offset || 0) / e.query.query.limit
2787
+ ), R = Math.ceil(n.total / e.query.query.limit);
2788
+ return [b, w, R];
2789
+ }, [e.query.query.limit, e.query.query.offset, n.total]);
2790
+ Re(() => (n.total == 0 && s(e.query.query), e.query.subscribe(s)), [e.query]);
2791
+ const g = k(() => {
2792
+ const b = e.schema.normalizers[e.schema.primaryKey];
2793
+ return Object.keys(o).filter((w) => o[w]).map((w) => b(w));
2794
+ }, [o]);
2795
+ let p, x;
2796
+ Yt(e.actions) && (p = /* @__PURE__ */ i.jsx(
2797
+ Gt,
2798
+ {
2799
+ actions: e.actions,
2800
+ reloadData: () => s(e.query.query),
2801
+ selectedRowKeys: g
2802
+ }
2803
+ ));
2804
+ const h = ((y = e.pagination) == null ? void 0 : y.positions) || Ta;
2805
+ if (h.size > 0) {
2806
+ const b = /* @__PURE__ */ i.jsx(
2807
+ Xt,
2808
+ {
2809
+ total: v,
2810
+ pageIndex: f,
2811
+ pageSize: c,
2812
+ onUpdatePagination: u,
2813
+ allowPageSizeChange: (S = e.pagination) == null ? void 0 : S.showSizeChanger
2814
+ }
2815
+ );
2816
+ h.has("topRight") && (p !== void 0 ? p = /* @__PURE__ */ i.jsxs($, { justify: "space-between", gap: "sm", children: [
2817
+ p,
2818
+ b
2819
+ ] }) : p = /* @__PURE__ */ i.jsx(B, { justify: "flex-end", children: b })), (h.has("bottomRight") || h.has("bottomLeft") || h.has("bottomCenter")) && (h.has("bottomLeft") ? x = /* @__PURE__ */ i.jsxs(B, { justify: "space-between", align: "center", children: [
2820
+ b,
2821
+ /* @__PURE__ */ i.jsxs(T, { size: "sm", c: "dimmed", children: [
2822
+ "Showing ",
2823
+ f * c + 1,
2824
+ " to",
2825
+ " ",
2826
+ Math.min((f + 1) * c, n.total),
2827
+ " of ",
2828
+ n.total,
2829
+ " ",
2830
+ "records"
2831
+ ] })
2832
+ ] }) : x = /* @__PURE__ */ i.jsxs(B, { justify: "space-between", align: "center", children: [
2833
+ /* @__PURE__ */ i.jsxs(T, { size: "sm", c: "dimmed", children: [
2834
+ "Showing ",
2835
+ f * c + 1,
2836
+ " to",
2837
+ " ",
2838
+ Math.min((f + 1) * c, n.total),
2839
+ " of ",
2840
+ n.total,
2841
+ " ",
2842
+ "records"
2843
+ ] }),
2844
+ b
2845
+ ] }));
2846
+ }
2847
+ const j = k(() => /* @__PURE__ */ i.jsx(
2848
+ Na,
2849
+ {
2850
+ data: n,
2851
+ loading: a,
2852
+ columns: e.columns,
2853
+ primaryKey: e.schema.primaryKey,
2854
+ selectedRowKeys: o,
2855
+ setSelectedRowKeys: l,
2856
+ hasTopSection: p !== void 0,
2857
+ hasBottomSection: x !== void 0
2858
+ }
2859
+ ), [
2860
+ n,
2861
+ a,
2862
+ e.columns,
2863
+ e.schema.primaryKey,
2864
+ o,
2865
+ l,
2866
+ p !== void 0,
2867
+ x !== void 0
2868
+ ]);
2869
+ return p === void 0 || x === void 0 ? j : /* @__PURE__ */ i.jsxs("div", { children: [
2870
+ p !== void 0 && /* @__PURE__ */ i.jsx(
2871
+ te,
2872
+ {
2873
+ withBorder: !0,
2874
+ p: "xs",
2875
+ style: {
2876
+ borderBottomLeftRadius: 0,
2877
+ borderBottomRightRadius: 0,
2878
+ borderBottom: "none"
2879
+ },
2880
+ children: p
2881
+ }
2882
+ ),
2883
+ j,
2884
+ x !== void 0 && /* @__PURE__ */ i.jsx(
2885
+ te,
2886
+ {
2887
+ withBorder: !0,
2888
+ p: "xs",
2889
+ style: {
2890
+ borderTopLeftRadius: 0,
2891
+ borderTopRightRadius: 0,
2892
+ borderTop: "none"
2893
+ },
2894
+ children: x
2895
+ }
2896
+ )
2897
+ ] });
2898
+ }, Na = (e) => {
2899
+ const n = k(() => {
2900
+ const a = [
2901
+ {
2902
+ id: "selection",
2903
+ header: ({ table: r }) => /* @__PURE__ */ i.jsx(
2904
+ Ce,
2905
+ {
2906
+ checked: r.getIsAllRowsSelected(),
2907
+ indeterminate: r.getIsSomeRowsSelected(),
2908
+ onChange: r.getToggleAllRowsSelectedHandler()
2909
+ }
2910
+ ),
2911
+ cell: ({ row: r }) => /* @__PURE__ */ i.jsx(
2912
+ Ce,
2913
+ {
2914
+ checked: r.getIsSelected(),
2915
+ disabled: !r.getCanSelect(),
2916
+ onChange: r.getToggleSelectedHandler()
2917
+ }
2918
+ )
2919
+ }
2920
+ ];
2921
+ return e.columns.forEach((r) => {
2922
+ a.push({
2923
+ id: r.key,
2924
+ header: r.title,
2925
+ accessorFn: r.render,
2926
+ cell: ({ row: o }) => r.render(o.original)
2927
+ });
2928
+ }), a;
2929
+ }, [e.columns]), t = kt({
2930
+ data: e.data.records,
2931
+ columns: n,
2932
+ getCoreRowModel: Tt(),
2933
+ // convert to string, but we actually can get away with number
2934
+ getRowId: (a) => a[e.primaryKey].toString(),
2935
+ state: {
2936
+ rowSelection: e.selectedRowKeys
2937
+ },
2938
+ onRowSelectionChange: e.setSelectedRowKeys,
2939
+ manualPagination: !0
2940
+ });
2941
+ return /* @__PURE__ */ i.jsx(
2942
+ Jt,
2943
+ {
2944
+ table: t,
2945
+ selectedRowKeys: e.selectedRowKeys,
2946
+ bordered: !0,
2947
+ hasTopSection: e.hasTopSection,
2948
+ hasBottomSection: e.hasBottomSection
2949
+ }
2950
+ );
2951
+ };
2952
+ function Zt(e, n, t) {
2953
+ let a;
2954
+ if (me(n))
2955
+ n.cardinality === "1:N" || n.cardinality === "N:N" ? a = Le : a = Pe;
2956
+ else {
2957
+ if (Z[n.datatype] === void 0)
2958
+ throw new Error(
2959
+ `No display component found for datatype ${n.datatype}`
2960
+ );
2961
+ a = Z[n.datatype];
2962
+ }
2963
+ return {
2964
+ key: n.name,
2965
+ title: /* @__PURE__ */ i.jsx(M, { value: n.label }),
2966
+ accessorFn: (r) => r[n.tsName],
2967
+ render: (r) => {
2968
+ const o = r[n.tsName];
2969
+ return /* @__PURE__ */ i.jsx(
2970
+ a,
2971
+ {
2972
+ db: e,
2973
+ property: n,
2974
+ value: o,
2975
+ entityRoutes: t
2976
+ }
2977
+ );
2978
+ }
2979
+ };
2980
+ }
2981
+ function Qa(e, n, t, a, { title: r } = {}) {
2982
+ let o;
2983
+ if (me(t))
2984
+ t.cardinality === "1:N" || t.cardinality === "N:N" ? o = Le : o = Pe;
2985
+ else {
2986
+ if (Z[t.datatype] === void 0)
2987
+ throw new Error(
2988
+ `No display component found for datatype ${t.datatype}`
2989
+ );
2990
+ o = Z[t.datatype];
2991
+ }
2992
+ return {
2993
+ key: n + "." + t.name,
2994
+ title: r || /* @__PURE__ */ i.jsx(M, { value: t.label }),
2995
+ accessorFn: (l) => l[n.tsName][t.tsName],
2996
+ render: (l) => {
2997
+ const s = l[n.tsName][t.tsName];
2998
+ return /* @__PURE__ */ i.jsx(
2999
+ o,
3000
+ {
3001
+ db: e,
3002
+ property: t,
3003
+ value: s,
3004
+ entityRoutes: a
3005
+ }
3006
+ );
3007
+ }
3008
+ };
3009
+ }
3010
+ function eo(e, n, t, a) {
3011
+ return t.map((r) => Qt(r) ? r : Zt(
3012
+ e,
3013
+ n.publicProperties[r],
3014
+ a
3015
+ ));
3016
+ }
3017
+ function to(e, n, t, a) {
3018
+ return t.map((r) => Qt(r) ? r : Zt(
3019
+ e,
3020
+ n.publicProperties[r],
3021
+ a
3022
+ ));
3023
+ }
3024
+ function Qt(e) {
3025
+ return typeof e == "object" && "key" in e && "title" in e;
3026
+ }
3027
+ const Pa = /* @__PURE__ */ new Set([
3028
+ "topRight",
3029
+ "bottomRight"
3030
+ ]), no = (e) => {
3031
+ var f, v;
3032
+ const [n, t] = _({}), a = k(() => {
3033
+ const g = [
3034
+ {
3035
+ id: "selection",
3036
+ header: ({ table: p }) => /* @__PURE__ */ i.jsx(
3037
+ Ce,
3038
+ {
3039
+ checked: p.getIsAllRowsSelected(),
3040
+ indeterminate: p.getIsSomeRowsSelected(),
3041
+ onChange: p.getToggleAllRowsSelectedHandler()
3042
+ }
3043
+ ),
3044
+ cell: ({ row: p }) => /* @__PURE__ */ i.jsx(
3045
+ Ce,
3046
+ {
3047
+ checked: p.getIsSelected(),
3048
+ disabled: !p.getCanSelect(),
3049
+ onChange: p.getToggleSelectedHandler()
3050
+ }
3051
+ )
3052
+ }
3053
+ ];
3054
+ return e.columns.forEach((p) => {
3055
+ g.push({
3056
+ id: p.key,
3057
+ header: p.title,
3058
+ accessorFn: p.render,
3059
+ cell: ({ row: x }) => p.render(x.original)
3060
+ });
3061
+ }), g;
3062
+ }, [e.columns]), r = kt({
3063
+ data: e.data,
3064
+ columns: a,
3065
+ getCoreRowModel: Tt(),
3066
+ getPaginationRowModel: kn(),
3067
+ state: {
3068
+ rowSelection: n
3069
+ },
3070
+ onRowSelectionChange: t
3071
+ }), o = k(() => Object.keys(n).filter((g) => n[g]).map(Number), [n]);
3072
+ let l, s;
3073
+ Yt(e.actions) && (l = /* @__PURE__ */ i.jsx(Gt, { actions: e.actions, selectedRowKeys: o }));
3074
+ const u = ((f = e.pagination) == null ? void 0 : f.positions) || Pa;
3075
+ if (u.size > 0) {
3076
+ const g = r.getState().pagination, p = /* @__PURE__ */ i.jsx(
3077
+ Xt,
3078
+ {
3079
+ total: r.getPageCount(),
3080
+ pageIndex: g.pageIndex,
3081
+ pageSize: g.pageSize,
3082
+ onUpdatePagination: (x, h) => r.setPagination({ pageIndex: x, pageSize: h }),
3083
+ allowPageSizeChange: (v = e.pagination) == null ? void 0 : v.showSizeChanger
3084
+ }
3085
+ );
3086
+ u.has("topRight") && (l !== void 0 ? l = /* @__PURE__ */ i.jsxs($, { justify: "space-between", gap: "sm", children: [
3087
+ l,
3088
+ p
3089
+ ] }) : l = /* @__PURE__ */ i.jsx(B, { justify: "flex-end", children: p })), (u.has("bottomRight") || u.has("bottomLeft") || u.has("bottomCenter")) && (u.has("bottomLeft") ? s = /* @__PURE__ */ i.jsxs(B, { justify: "space-between", align: "center", children: [
3090
+ p,
3091
+ /* @__PURE__ */ i.jsxs(T, { size: "sm", c: "dimmed", children: [
3092
+ "Showing ",
3093
+ g.pageIndex * g.pageSize + 1,
3094
+ " to",
3095
+ " ",
3096
+ Math.min((g.pageIndex + 1) * g.pageSize, e.data.length),
3097
+ " of",
3098
+ " ",
3099
+ e.data.length,
3100
+ " records"
3101
+ ] })
3102
+ ] }) : s = /* @__PURE__ */ i.jsxs(B, { justify: "space-between", align: "center", children: [
3103
+ /* @__PURE__ */ i.jsxs(T, { size: "sm", c: "dimmed", children: [
3104
+ "Showing ",
3105
+ g.pageIndex * g.pageSize + 1,
3106
+ " to",
3107
+ " ",
3108
+ Math.min((g.pageIndex + 1) * g.pageSize, e.data.length),
3109
+ " of",
3110
+ " ",
3111
+ e.data.length,
3112
+ " records"
3113
+ ] }),
3114
+ p
3115
+ ] }));
3116
+ }
3117
+ const c = /* @__PURE__ */ i.jsx(
3118
+ Jt,
3119
+ {
3120
+ selectedRowKeys: n,
3121
+ table: r,
3122
+ bordered: !0,
3123
+ hasTopSection: l !== void 0,
3124
+ hasBottomSection: s !== void 0
3125
+ }
3126
+ );
3127
+ return l === void 0 && s === void 0 ? c : /* @__PURE__ */ i.jsxs("div", { children: [
3128
+ l !== void 0 && /* @__PURE__ */ i.jsx(
3129
+ te,
3130
+ {
3131
+ withBorder: !0,
3132
+ p: "xs",
3133
+ style: {
3134
+ borderBottomLeftRadius: 0,
3135
+ borderBottomRightRadius: 0,
3136
+ borderBottom: "none"
3137
+ },
3138
+ children: l
3139
+ }
3140
+ ),
3141
+ c,
3142
+ s !== void 0 && /* @__PURE__ */ i.jsx(
3143
+ te,
3144
+ {
3145
+ withBorder: !0,
3146
+ p: "xs",
3147
+ style: {
3148
+ borderTopLeftRadius: 0,
3149
+ borderTopRightRadius: 0,
3150
+ borderTop: "none"
3151
+ },
3152
+ children: s
3153
+ }
3154
+ )
3155
+ ] });
3156
+ }, yt = ne(
3157
+ ({
3158
+ store: e,
3159
+ record: n,
3160
+ property: t,
3161
+ DisplayComponent: a,
3162
+ entityRoutes: r
3163
+ }) => {
3164
+ const o = n[t.tsName];
3165
+ return /* @__PURE__ */ i.jsxs("div", { children: [
3166
+ /* @__PURE__ */ i.jsx(T, { size: "sm", fw: 500, children: /* @__PURE__ */ i.jsx(M, { value: t.label }) }),
3167
+ /* @__PURE__ */ i.jsx(
3168
+ a,
3169
+ {
3170
+ db: e.db,
3171
+ entityRoutes: r,
3172
+ property: t,
3173
+ value: o
3174
+ }
3175
+ )
3176
+ ] });
3177
+ }
3178
+ ), La = ne(
3179
+ ({
3180
+ store: e,
3181
+ record: n,
3182
+ properties: t,
3183
+ DisplayComponent: a,
3184
+ entityRoutes: r
3185
+ }) => {
3186
+ const o = t[t.length - 1], l = t.reduce((s, u) => {
3187
+ if (s != null)
3188
+ return s[u.tsName];
3189
+ }, n);
3190
+ return /* @__PURE__ */ i.jsxs("div", { children: [
3191
+ /* @__PURE__ */ i.jsx(T, { size: "sm", fw: 500, children: /* @__PURE__ */ i.jsx(M, { value: o.label }) }),
3192
+ l !== void 0 && /* @__PURE__ */ i.jsx(
3193
+ a,
3194
+ {
3195
+ db: e.db,
3196
+ property: o,
3197
+ value: l,
3198
+ entityRoutes: r
3199
+ }
3200
+ )
3201
+ ] });
3202
+ }
3203
+ ), Ia = 12, Fa = (e) => {
3204
+ const n = e.schema, t = k(() => e.fieldGroups.map((a, r) => Aa(
3205
+ n,
3206
+ e.store,
3207
+ e.record,
3208
+ r,
3209
+ a,
3210
+ e.entityRoutes
3211
+ )), [n, e.store, e.record, e.fieldGroups]);
3212
+ return /* @__PURE__ */ i.jsx(Ee, { gap: "sm", className: e.className, style: e.styles, children: t });
3213
+ };
3214
+ function Aa(e, n, t, a, r, o) {
3215
+ const l = r.fields, s = [];
3216
+ for (let u = 0; u < l.length; u++) {
3217
+ const c = Ia / l[u].length;
3218
+ if (!Number.isInteger(c))
3219
+ throw new Error(`Span must be an integer, but got ${c} for row ${u}`);
3220
+ for (let f = 0; f < l[u].length; f++) {
3221
+ const v = l[u][f];
3222
+ let g;
3223
+ if (typeof v == "function")
3224
+ g = v(n, t);
3225
+ else if (typeof v == "object" && "prop" in v) {
3226
+ const p = e.allProperties[v.prop], x = v.display;
3227
+ g = /* @__PURE__ */ i.jsx(
3228
+ yt,
3229
+ {
3230
+ store: n,
3231
+ record: t,
3232
+ property: p,
3233
+ DisplayComponent: x,
3234
+ entityRoutes: o
3235
+ }
3236
+ );
3237
+ } else {
3238
+ const p = e.allProperties[v];
3239
+ let x;
3240
+ if (me(p))
3241
+ x = p.cardinality === "N:N" || p.cardinality === "1:N" ? Le : Pe;
3242
+ else {
3243
+ if (Z[p.datatype] === void 0)
3244
+ throw new Error(
3245
+ `No display component found for datatype ${p.datatype}`
3246
+ );
3247
+ x = Z[p.datatype];
3248
+ }
3249
+ g = /* @__PURE__ */ i.jsx(
3250
+ yt,
3251
+ {
3252
+ store: n,
3253
+ record: t,
3254
+ property: p,
3255
+ DisplayComponent: x,
3256
+ entityRoutes: o
3257
+ }
3258
+ );
3259
+ }
3260
+ s.push(
3261
+ /* @__PURE__ */ i.jsx(A.Col, { span: c, children: g }, `${u}-${f}`)
3262
+ );
3263
+ }
3264
+ }
3265
+ return /* @__PURE__ */ i.jsx(A, { gutter: "sm", children: s }, a);
3266
+ }
3267
+ function ro(e, n, t) {
3268
+ const a = e[e.length - 1];
3269
+ let r;
3270
+ if (t !== void 0)
3271
+ r = t;
3272
+ else if (me(a))
3273
+ r = a.cardinality === "N:N" || a.cardinality === "1:N" ? Le : Pe;
3274
+ else {
3275
+ if (Z[a.datatype] === void 0)
3276
+ throw new Error(
3277
+ `No display component found for datatype ${a.datatype}`
3278
+ );
3279
+ r = Z[a.datatype];
3280
+ }
3281
+ return (o, l) => /* @__PURE__ */ i.jsx(
3282
+ La,
3283
+ {
3284
+ store: o,
3285
+ record: l,
3286
+ properties: e,
3287
+ DisplayComponent: r,
3288
+ entityRoutes: n
3289
+ }
3290
+ );
3291
+ }
3292
+ const ao = (e) => /* @__PURE__ */ i.jsxs(pe, { defaultValue: e.fieldTabs[0].tabName, children: [
3293
+ /* @__PURE__ */ i.jsx(pe.List, { children: e.fieldTabs.map((n, t) => /* @__PURE__ */ i.jsx(pe.Tab, { value: n.tabName, children: n.tabName }, t)) }),
3294
+ e.fieldTabs.map((n, t) => /* @__PURE__ */ i.jsx(pe.Panel, { value: n.tabName, pt: "sm", children: /* @__PURE__ */ i.jsx(
3295
+ Fa,
3296
+ {
3297
+ schema: e.schema,
3298
+ store: e.store,
3299
+ record: e.record,
3300
+ fieldGroups: n.fieldGroups,
3301
+ styles: e.tabStyles,
3302
+ className: e.tabClassName,
3303
+ entityRoutes: e.entityRoutes
3304
+ }
3305
+ ) }, t))
3306
+ ] });
3307
+ export {
3308
+ Me as CountryFlagComponent,
3309
+ Ta as DEFAULT_PAGINATION_POSITIONS,
3310
+ mt as DataType2Component,
3311
+ Z as DataType2DisplayComponent,
3312
+ In as EmojiCountryFlag,
3313
+ va as FormItem,
3314
+ ga as FormItemLabel,
3315
+ qa as LanguageSelector,
3316
+ Ha as Loading,
3317
+ Ga as LoadingInline,
3318
+ An as LocaleContext,
3319
+ Xr as MenuTrie,
3320
+ Le as MultiForeignKeyDisplay,
3321
+ M as MultiLingualString,
3322
+ Ya as NotAuthorized,
3323
+ Wa as NotFound,
3324
+ Wt as NotFoundInline,
3325
+ Va as NotFoundSubPage,
3326
+ Jr as Permission,
3327
+ Ln as SVGCountryFlag,
3328
+ no as SeraEmbeddedTable,
3329
+ Xa as SeraForm,
3330
+ Za as SeraTable,
3331
+ Ja as SeraVerticalMenu,
3332
+ Fa as SeraView,
3333
+ ao as SeraViewTab,
3334
+ Pe as SingleForeignKeyDisplay,
3335
+ Zr as buildMenuItemIndex,
3336
+ N as countryFlags,
3337
+ ea as filterAllowedItems,
3338
+ Qt as isSeraColumn,
3339
+ to as makeEmbeddedTableColumns,
3340
+ ro as makeFieldDisplay,
3341
+ Zt as makeTableColumn,
3342
+ Qa as makeTableColumnFromNestedProperty,
3343
+ eo as makeTableColumns
3344
+ };