quix-ui 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,13 +1,2041 @@
1
- import { jsx } from 'react/jsx-runtime';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import * as React3 from 'react';
3
+ import { useState } from 'react';
2
4
 
3
- function ViewContainer(props) {
4
- const { display, isScrollable, direction, alignItems, justifyContent, width, height, backgroundColor, paddingX, paddingY, textColor, className, rounded } = props;
5
- return jsx("div", { className: className, style: {
6
- display: display || 'block',
5
+ function styleInject(css, ref) {
6
+ if ( ref === void 0 ) ref = {};
7
+ var insertAt = ref.insertAt;
8
+
9
+ if (!css || typeof document === 'undefined') { return; }
10
+
11
+ var head = document.head || document.getElementsByTagName('head')[0];
12
+ var style = document.createElement('style');
13
+ style.type = 'text/css';
14
+
15
+ if (insertAt === 'top') {
16
+ if (head.firstChild) {
17
+ head.insertBefore(style, head.firstChild);
18
+ } else {
19
+ head.appendChild(style);
20
+ }
21
+ } else {
22
+ head.appendChild(style);
23
+ }
24
+
25
+ if (style.styleSheet) {
26
+ style.styleSheet.cssText = css;
27
+ } else {
28
+ style.appendChild(document.createTextNode(css));
29
+ }
30
+ }
31
+
32
+ var css_248z$1 = ":root{border-style:solid}.flex-center{align-items:center;display:flex;justify-content:center}.flex-start{align-items:start;display:flex;justify-content:start}.flex-end{align-items:end;display:flex;justify-content:end}.flex-between{align-items:center;display:flex;justify-content:space-between}";
33
+ styleInject(css_248z$1);
34
+
35
+ /**
36
+ * react-router v7.12.0
37
+ *
38
+ * Copyright (c) Remix Software Inc.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE.md file in the root directory of this source tree.
42
+ *
43
+ * @license MIT
44
+ */
45
+ function invariant(value, message) {
46
+ if (value === false || value === null || typeof value === "undefined") {
47
+ throw new Error(message);
48
+ }
49
+ }
50
+ function warning(cond, message) {
51
+ if (!cond) {
52
+ if (typeof console !== "undefined") console.warn(message);
53
+ try {
54
+ throw new Error(message);
55
+ } catch (e) {
56
+ }
57
+ }
58
+ }
59
+ function createPath({
60
+ pathname = "/",
61
+ search = "",
62
+ hash = ""
63
+ }) {
64
+ if (search && search !== "?")
65
+ pathname += search.charAt(0) === "?" ? search : "?" + search;
66
+ if (hash && hash !== "#")
67
+ pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
68
+ return pathname;
69
+ }
70
+ function parsePath(path) {
71
+ let parsedPath = {};
72
+ if (path) {
73
+ let hashIndex = path.indexOf("#");
74
+ if (hashIndex >= 0) {
75
+ parsedPath.hash = path.substring(hashIndex);
76
+ path = path.substring(0, hashIndex);
77
+ }
78
+ let searchIndex = path.indexOf("?");
79
+ if (searchIndex >= 0) {
80
+ parsedPath.search = path.substring(searchIndex);
81
+ path = path.substring(0, searchIndex);
82
+ }
83
+ if (path) {
84
+ parsedPath.pathname = path;
85
+ }
86
+ }
87
+ return parsedPath;
88
+ }
89
+ function matchRoutes(routes, locationArg, basename = "/") {
90
+ return matchRoutesImpl(routes, locationArg, basename, false);
91
+ }
92
+ function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
93
+ let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
94
+ let pathname = stripBasename(location.pathname || "/", basename);
95
+ if (pathname == null) {
96
+ return null;
97
+ }
98
+ let branches = flattenRoutes(routes);
99
+ rankRouteBranches(branches);
100
+ let matches = null;
101
+ for (let i = 0; matches == null && i < branches.length; ++i) {
102
+ let decoded = decodePath(pathname);
103
+ matches = matchRouteBranch(
104
+ branches[i],
105
+ decoded,
106
+ allowPartial
107
+ );
108
+ }
109
+ return matches;
110
+ }
111
+ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
112
+ let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
113
+ let meta = {
114
+ relativePath: relativePath === void 0 ? route.path || "" : relativePath,
115
+ caseSensitive: route.caseSensitive === true,
116
+ childrenIndex: index,
117
+ route
118
+ };
119
+ if (meta.relativePath.startsWith("/")) {
120
+ if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
121
+ return;
122
+ }
123
+ invariant(
124
+ meta.relativePath.startsWith(parentPath),
125
+ `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
126
+ );
127
+ meta.relativePath = meta.relativePath.slice(parentPath.length);
128
+ }
129
+ let path = joinPaths([parentPath, meta.relativePath]);
130
+ let routesMeta = parentsMeta.concat(meta);
131
+ if (route.children && route.children.length > 0) {
132
+ invariant(
133
+ // Our types know better, but runtime JS may not!
134
+ // @ts-expect-error
135
+ route.index !== true,
136
+ `Index routes must not have child routes. Please remove all child routes from route path "${path}".`
137
+ );
138
+ flattenRoutes(
139
+ route.children,
140
+ branches,
141
+ routesMeta,
142
+ path,
143
+ hasParentOptionalSegments
144
+ );
145
+ }
146
+ if (route.path == null && !route.index) {
147
+ return;
148
+ }
149
+ branches.push({
150
+ path,
151
+ score: computeScore(path, route.index),
152
+ routesMeta
153
+ });
154
+ };
155
+ routes.forEach((route, index) => {
156
+ if (route.path === "" || !route.path?.includes("?")) {
157
+ flattenRoute(route, index);
158
+ } else {
159
+ for (let exploded of explodeOptionalSegments(route.path)) {
160
+ flattenRoute(route, index, true, exploded);
161
+ }
162
+ }
163
+ });
164
+ return branches;
165
+ }
166
+ function explodeOptionalSegments(path) {
167
+ let segments = path.split("/");
168
+ if (segments.length === 0) return [];
169
+ let [first, ...rest] = segments;
170
+ let isOptional = first.endsWith("?");
171
+ let required = first.replace(/\?$/, "");
172
+ if (rest.length === 0) {
173
+ return isOptional ? [required, ""] : [required];
174
+ }
175
+ let restExploded = explodeOptionalSegments(rest.join("/"));
176
+ let result = [];
177
+ result.push(
178
+ ...restExploded.map(
179
+ (subpath) => subpath === "" ? required : [required, subpath].join("/")
180
+ )
181
+ );
182
+ if (isOptional) {
183
+ result.push(...restExploded);
184
+ }
185
+ return result.map(
186
+ (exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded
187
+ );
188
+ }
189
+ function rankRouteBranches(branches) {
190
+ branches.sort(
191
+ (a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(
192
+ a.routesMeta.map((meta) => meta.childrenIndex),
193
+ b.routesMeta.map((meta) => meta.childrenIndex)
194
+ )
195
+ );
196
+ }
197
+ var paramRe = /^:[\w-]+$/;
198
+ var dynamicSegmentValue = 3;
199
+ var indexRouteValue = 2;
200
+ var emptySegmentValue = 1;
201
+ var staticSegmentValue = 10;
202
+ var splatPenalty = -2;
203
+ var isSplat = (s) => s === "*";
204
+ function computeScore(path, index) {
205
+ let segments = path.split("/");
206
+ let initialScore = segments.length;
207
+ if (segments.some(isSplat)) {
208
+ initialScore += splatPenalty;
209
+ }
210
+ if (index) {
211
+ initialScore += indexRouteValue;
212
+ }
213
+ return segments.filter((s) => !isSplat(s)).reduce(
214
+ (score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
215
+ initialScore
216
+ );
217
+ }
218
+ function compareIndexes(a, b) {
219
+ let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
220
+ return siblings ? (
221
+ // If two routes are siblings, we should try to match the earlier sibling
222
+ // first. This allows people to have fine-grained control over the matching
223
+ // behavior by simply putting routes with identical paths in the order they
224
+ // want them tried.
225
+ a[a.length - 1] - b[b.length - 1]
226
+ ) : (
227
+ // Otherwise, it doesn't really make sense to rank non-siblings by index,
228
+ // so they sort equally.
229
+ 0
230
+ );
231
+ }
232
+ function matchRouteBranch(branch, pathname, allowPartial = false) {
233
+ let { routesMeta } = branch;
234
+ let matchedParams = {};
235
+ let matchedPathname = "/";
236
+ let matches = [];
237
+ for (let i = 0; i < routesMeta.length; ++i) {
238
+ let meta = routesMeta[i];
239
+ let end = i === routesMeta.length - 1;
240
+ let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
241
+ let match = matchPath(
242
+ { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
243
+ remainingPathname
244
+ );
245
+ let route = meta.route;
246
+ if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
247
+ match = matchPath(
248
+ {
249
+ path: meta.relativePath,
250
+ caseSensitive: meta.caseSensitive,
251
+ end: false
252
+ },
253
+ remainingPathname
254
+ );
255
+ }
256
+ if (!match) {
257
+ return null;
258
+ }
259
+ Object.assign(matchedParams, match.params);
260
+ matches.push({
261
+ // TODO: Can this as be avoided?
262
+ params: matchedParams,
263
+ pathname: joinPaths([matchedPathname, match.pathname]),
264
+ pathnameBase: normalizePathname(
265
+ joinPaths([matchedPathname, match.pathnameBase])
266
+ ),
267
+ route
268
+ });
269
+ if (match.pathnameBase !== "/") {
270
+ matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
271
+ }
272
+ }
273
+ return matches;
274
+ }
275
+ function matchPath(pattern, pathname) {
276
+ if (typeof pattern === "string") {
277
+ pattern = { path: pattern, caseSensitive: false, end: true };
278
+ }
279
+ let [matcher, compiledParams] = compilePath(
280
+ pattern.path,
281
+ pattern.caseSensitive,
282
+ pattern.end
283
+ );
284
+ let match = pathname.match(matcher);
285
+ if (!match) return null;
286
+ let matchedPathname = match[0];
287
+ let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
288
+ let captureGroups = match.slice(1);
289
+ let params = compiledParams.reduce(
290
+ (memo2, { paramName, isOptional }, index) => {
291
+ if (paramName === "*") {
292
+ let splatValue = captureGroups[index] || "";
293
+ pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
294
+ }
295
+ const value = captureGroups[index];
296
+ if (isOptional && !value) {
297
+ memo2[paramName] = void 0;
298
+ } else {
299
+ memo2[paramName] = (value || "").replace(/%2F/g, "/");
300
+ }
301
+ return memo2;
302
+ },
303
+ {}
304
+ );
305
+ return {
306
+ params,
307
+ pathname: matchedPathname,
308
+ pathnameBase,
309
+ pattern
310
+ };
311
+ }
312
+ function compilePath(path, caseSensitive = false, end = true) {
313
+ warning(
314
+ path === "*" || !path.endsWith("*") || path.endsWith("/*"),
315
+ `Route path "${path}" will be treated as if it were "${path.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${path.replace(/\*$/, "/*")}".`
316
+ );
317
+ let params = [];
318
+ let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(
319
+ /\/:([\w-]+)(\?)?/g,
320
+ (_, paramName, isOptional) => {
321
+ params.push({ paramName, isOptional: isOptional != null });
322
+ return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
323
+ }
324
+ ).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
325
+ if (path.endsWith("*")) {
326
+ params.push({ paramName: "*" });
327
+ regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
328
+ } else if (end) {
329
+ regexpSource += "\\/*$";
330
+ } else if (path !== "" && path !== "/") {
331
+ regexpSource += "(?:(?=\\/|$))";
332
+ } else ;
333
+ let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
334
+ return [matcher, params];
335
+ }
336
+ function decodePath(value) {
337
+ try {
338
+ return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
339
+ } catch (error) {
340
+ warning(
341
+ false,
342
+ `The URL path "${value}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`
343
+ );
344
+ return value;
345
+ }
346
+ }
347
+ function stripBasename(pathname, basename) {
348
+ if (basename === "/") return pathname;
349
+ if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
350
+ return null;
351
+ }
352
+ let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
353
+ let nextChar = pathname.charAt(startIndex);
354
+ if (nextChar && nextChar !== "/") {
355
+ return null;
356
+ }
357
+ return pathname.slice(startIndex) || "/";
358
+ }
359
+ var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
360
+ var isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url);
361
+ function resolvePath(to, fromPathname = "/") {
362
+ let {
363
+ pathname: toPathname,
364
+ search = "",
365
+ hash = ""
366
+ } = typeof to === "string" ? parsePath(to) : to;
367
+ let pathname;
368
+ if (toPathname) {
369
+ if (isAbsoluteUrl(toPathname)) {
370
+ pathname = toPathname;
371
+ } else {
372
+ if (toPathname.includes("//")) {
373
+ let oldPathname = toPathname;
374
+ toPathname = toPathname.replace(/\/\/+/g, "/");
375
+ warning(
376
+ false,
377
+ `Pathnames cannot have embedded double slashes - normalizing ${oldPathname} -> ${toPathname}`
378
+ );
379
+ }
380
+ if (toPathname.startsWith("/")) {
381
+ pathname = resolvePathname(toPathname.substring(1), "/");
382
+ } else {
383
+ pathname = resolvePathname(toPathname, fromPathname);
384
+ }
385
+ }
386
+ } else {
387
+ pathname = fromPathname;
388
+ }
389
+ return {
390
+ pathname,
391
+ search: normalizeSearch(search),
392
+ hash: normalizeHash(hash)
393
+ };
394
+ }
395
+ function resolvePathname(relativePath, fromPathname) {
396
+ let segments = fromPathname.replace(/\/+$/, "").split("/");
397
+ let relativeSegments = relativePath.split("/");
398
+ relativeSegments.forEach((segment) => {
399
+ if (segment === "..") {
400
+ if (segments.length > 1) segments.pop();
401
+ } else if (segment !== ".") {
402
+ segments.push(segment);
403
+ }
404
+ });
405
+ return segments.length > 1 ? segments.join("/") : "/";
406
+ }
407
+ function getInvalidPathError(char, field, dest, path) {
408
+ return `Cannot include a '${char}' character in a manually specified \`to.${field}\` field [${JSON.stringify(
409
+ path
410
+ )}]. Please separate it out to the \`to.${dest}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
411
+ }
412
+ function getPathContributingMatches(matches) {
413
+ return matches.filter(
414
+ (match, index) => index === 0 || match.route.path && match.route.path.length > 0
415
+ );
416
+ }
417
+ function getResolveToMatches(matches) {
418
+ let pathMatches = getPathContributingMatches(matches);
419
+ return pathMatches.map(
420
+ (match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase
421
+ );
422
+ }
423
+ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = false) {
424
+ let to;
425
+ if (typeof toArg === "string") {
426
+ to = parsePath(toArg);
427
+ } else {
428
+ to = { ...toArg };
429
+ invariant(
430
+ !to.pathname || !to.pathname.includes("?"),
431
+ getInvalidPathError("?", "pathname", "search", to)
432
+ );
433
+ invariant(
434
+ !to.pathname || !to.pathname.includes("#"),
435
+ getInvalidPathError("#", "pathname", "hash", to)
436
+ );
437
+ invariant(
438
+ !to.search || !to.search.includes("#"),
439
+ getInvalidPathError("#", "search", "hash", to)
440
+ );
441
+ }
442
+ let isEmptyPath = toArg === "" || to.pathname === "";
443
+ let toPathname = isEmptyPath ? "/" : to.pathname;
444
+ let from;
445
+ if (toPathname == null) {
446
+ from = locationPathname;
447
+ } else {
448
+ let routePathnameIndex = routePathnames.length - 1;
449
+ if (!isPathRelative && toPathname.startsWith("..")) {
450
+ let toSegments = toPathname.split("/");
451
+ while (toSegments[0] === "..") {
452
+ toSegments.shift();
453
+ routePathnameIndex -= 1;
454
+ }
455
+ to.pathname = toSegments.join("/");
456
+ }
457
+ from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
458
+ }
459
+ let path = resolvePath(to, from);
460
+ let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
461
+ let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
462
+ if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
463
+ path.pathname += "/";
464
+ }
465
+ return path;
466
+ }
467
+ var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
468
+ var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
469
+ var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
470
+ var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
471
+ var ErrorResponseImpl = class {
472
+ constructor(status, statusText, data2, internal = false) {
473
+ this.status = status;
474
+ this.statusText = statusText || "";
475
+ this.internal = internal;
476
+ if (data2 instanceof Error) {
477
+ this.data = data2.toString();
478
+ this.error = data2;
479
+ } else {
480
+ this.data = data2;
481
+ }
482
+ }
483
+ };
484
+ function isRouteErrorResponse(error) {
485
+ return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
486
+ }
487
+ function getRoutePattern(matches) {
488
+ return matches.map((m) => m.route.path).filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
489
+ }
490
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
491
+ function parseToInfo(_to, basename) {
492
+ let to = _to;
493
+ if (typeof to !== "string" || !ABSOLUTE_URL_REGEX.test(to)) {
494
+ return {
495
+ absoluteURL: void 0,
496
+ isExternal: false,
497
+ to
498
+ };
499
+ }
500
+ let absoluteURL = to;
501
+ let isExternal = false;
502
+ if (isBrowser) {
503
+ try {
504
+ let currentUrl = new URL(window.location.href);
505
+ let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
506
+ let path = stripBasename(targetUrl.pathname, basename);
507
+ if (targetUrl.origin === currentUrl.origin && path != null) {
508
+ to = path + targetUrl.search + targetUrl.hash;
509
+ } else {
510
+ isExternal = true;
511
+ }
512
+ } catch (e) {
513
+ warning(
514
+ false,
515
+ `<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
516
+ );
517
+ }
518
+ }
519
+ return {
520
+ absoluteURL,
521
+ isExternal,
522
+ to
523
+ };
524
+ }
525
+ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
526
+
527
+ // lib/router/router.ts
528
+ var validMutationMethodsArr = [
529
+ "POST",
530
+ "PUT",
531
+ "PATCH",
532
+ "DELETE"
533
+ ];
534
+ new Set(
535
+ validMutationMethodsArr
536
+ );
537
+ var validRequestMethodsArr = [
538
+ "GET",
539
+ ...validMutationMethodsArr
540
+ ];
541
+ new Set(validRequestMethodsArr);
542
+ var DataRouterContext = React3.createContext(null);
543
+ DataRouterContext.displayName = "DataRouter";
544
+ var DataRouterStateContext = React3.createContext(null);
545
+ DataRouterStateContext.displayName = "DataRouterState";
546
+ var RSCRouterContext = React3.createContext(false);
547
+ var ViewTransitionContext = React3.createContext({
548
+ isTransitioning: false
549
+ });
550
+ ViewTransitionContext.displayName = "ViewTransition";
551
+ var FetchersContext = React3.createContext(
552
+ /* @__PURE__ */ new Map()
553
+ );
554
+ FetchersContext.displayName = "Fetchers";
555
+ var AwaitContext = React3.createContext(null);
556
+ AwaitContext.displayName = "Await";
557
+ var NavigationContext = React3.createContext(
558
+ null
559
+ );
560
+ NavigationContext.displayName = "Navigation";
561
+ var LocationContext = React3.createContext(
562
+ null
563
+ );
564
+ LocationContext.displayName = "Location";
565
+ var RouteContext = React3.createContext({
566
+ outlet: null,
567
+ matches: [],
568
+ isDataRoute: false
569
+ });
570
+ RouteContext.displayName = "Route";
571
+ var RouteErrorContext = React3.createContext(null);
572
+ RouteErrorContext.displayName = "RouteError";
573
+
574
+ // lib/errors.ts
575
+ var ERROR_DIGEST_BASE = "REACT_ROUTER_ERROR";
576
+ var ERROR_DIGEST_REDIRECT = "REDIRECT";
577
+ var ERROR_DIGEST_ROUTE_ERROR_RESPONSE = "ROUTE_ERROR_RESPONSE";
578
+ function decodeRedirectErrorDigest(digest) {
579
+ if (digest.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:{`)) {
580
+ try {
581
+ let parsed = JSON.parse(digest.slice(28));
582
+ if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string" && typeof parsed.location === "string" && typeof parsed.reloadDocument === "boolean" && typeof parsed.replace === "boolean") {
583
+ return parsed;
584
+ }
585
+ } catch {
586
+ }
587
+ }
588
+ }
589
+ function decodeRouteErrorResponseDigest(digest) {
590
+ if (digest.startsWith(
591
+ `${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:{`
592
+ )) {
593
+ try {
594
+ let parsed = JSON.parse(digest.slice(40));
595
+ if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string") {
596
+ return new ErrorResponseImpl(
597
+ parsed.status,
598
+ parsed.statusText,
599
+ parsed.data
600
+ );
601
+ }
602
+ } catch {
603
+ }
604
+ }
605
+ }
606
+
607
+ // lib/hooks.tsx
608
+ function useHref(to, { relative } = {}) {
609
+ invariant(
610
+ useInRouterContext(),
611
+ // TODO: This error is probably because they somehow have 2 versions of the
612
+ // router loaded. We can help them understand how to avoid that.
613
+ `useHref() may be used only in the context of a <Router> component.`
614
+ );
615
+ let { basename, navigator } = React3.useContext(NavigationContext);
616
+ let { hash, pathname, search } = useResolvedPath(to, { relative });
617
+ let joinedPathname = pathname;
618
+ if (basename !== "/") {
619
+ joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
620
+ }
621
+ return navigator.createHref({ pathname: joinedPathname, search, hash });
622
+ }
623
+ function useInRouterContext() {
624
+ return React3.useContext(LocationContext) != null;
625
+ }
626
+ function useLocation() {
627
+ invariant(
628
+ useInRouterContext(),
629
+ // TODO: This error is probably because they somehow have 2 versions of the
630
+ // router loaded. We can help them understand how to avoid that.
631
+ `useLocation() may be used only in the context of a <Router> component.`
632
+ );
633
+ return React3.useContext(LocationContext).location;
634
+ }
635
+ var navigateEffectWarning = `You should call navigate() in a React.useEffect(), not when your component is first rendered.`;
636
+ function useIsomorphicLayoutEffect(cb) {
637
+ let isStatic = React3.useContext(NavigationContext).static;
638
+ if (!isStatic) {
639
+ React3.useLayoutEffect(cb);
640
+ }
641
+ }
642
+ function useNavigate() {
643
+ let { isDataRoute } = React3.useContext(RouteContext);
644
+ return isDataRoute ? useNavigateStable() : useNavigateUnstable();
645
+ }
646
+ function useNavigateUnstable() {
647
+ invariant(
648
+ useInRouterContext(),
649
+ // TODO: This error is probably because they somehow have 2 versions of the
650
+ // router loaded. We can help them understand how to avoid that.
651
+ `useNavigate() may be used only in the context of a <Router> component.`
652
+ );
653
+ let dataRouterContext = React3.useContext(DataRouterContext);
654
+ let { basename, navigator } = React3.useContext(NavigationContext);
655
+ let { matches } = React3.useContext(RouteContext);
656
+ let { pathname: locationPathname } = useLocation();
657
+ let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
658
+ let activeRef = React3.useRef(false);
659
+ useIsomorphicLayoutEffect(() => {
660
+ activeRef.current = true;
661
+ });
662
+ let navigate = React3.useCallback(
663
+ (to, options = {}) => {
664
+ warning(activeRef.current, navigateEffectWarning);
665
+ if (!activeRef.current) return;
666
+ if (typeof to === "number") {
667
+ navigator.go(to);
668
+ return;
669
+ }
670
+ let path = resolveTo(
671
+ to,
672
+ JSON.parse(routePathnamesJson),
673
+ locationPathname,
674
+ options.relative === "path"
675
+ );
676
+ if (dataRouterContext == null && basename !== "/") {
677
+ path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
678
+ }
679
+ (!!options.replace ? navigator.replace : navigator.push)(
680
+ path,
681
+ options.state,
682
+ options
683
+ );
684
+ },
685
+ [
686
+ basename,
687
+ navigator,
688
+ routePathnamesJson,
689
+ locationPathname,
690
+ dataRouterContext
691
+ ]
692
+ );
693
+ return navigate;
694
+ }
695
+ React3.createContext(null);
696
+ function useResolvedPath(to, { relative } = {}) {
697
+ let { matches } = React3.useContext(RouteContext);
698
+ let { pathname: locationPathname } = useLocation();
699
+ let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
700
+ return React3.useMemo(
701
+ () => resolveTo(
702
+ to,
703
+ JSON.parse(routePathnamesJson),
704
+ locationPathname,
705
+ relative === "path"
706
+ ),
707
+ [to, routePathnamesJson, locationPathname, relative]
708
+ );
709
+ }
710
+ function useRoutesImpl(routes, locationArg, dataRouterState, onError, future) {
711
+ invariant(
712
+ useInRouterContext(),
713
+ // TODO: This error is probably because they somehow have 2 versions of the
714
+ // router loaded. We can help them understand how to avoid that.
715
+ `useRoutes() may be used only in the context of a <Router> component.`
716
+ );
717
+ let { navigator } = React3.useContext(NavigationContext);
718
+ let { matches: parentMatches } = React3.useContext(RouteContext);
719
+ let routeMatch = parentMatches[parentMatches.length - 1];
720
+ let parentParams = routeMatch ? routeMatch.params : {};
721
+ let parentPathname = routeMatch ? routeMatch.pathname : "/";
722
+ let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
723
+ let parentRoute = routeMatch && routeMatch.route;
724
+ {
725
+ let parentPath = parentRoute && parentRoute.path || "";
726
+ warningOnce(
727
+ parentPathname,
728
+ !parentRoute || parentPath.endsWith("*") || parentPath.endsWith("*?"),
729
+ `You rendered descendant <Routes> (or called \`useRoutes()\`) at "${parentPathname}" (under <Route path="${parentPath}">) 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.
730
+
731
+ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPath === "/" ? "*" : `${parentPath}/*`}">.`
732
+ );
733
+ }
734
+ let locationFromContext = useLocation();
735
+ let location;
736
+ {
737
+ location = locationFromContext;
738
+ }
739
+ let pathname = location.pathname || "/";
740
+ let remainingPathname = pathname;
741
+ if (parentPathnameBase !== "/") {
742
+ let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
743
+ let segments = pathname.replace(/^\//, "").split("/");
744
+ remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
745
+ }
746
+ let matches = matchRoutes(routes, { pathname: remainingPathname });
747
+ {
748
+ warning(
749
+ parentRoute || matches != null,
750
+ `No routes matched location "${location.pathname}${location.search}${location.hash}" `
751
+ );
752
+ warning(
753
+ matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0,
754
+ `Matched leaf route at location "${location.pathname}${location.search}${location.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.`
755
+ );
756
+ }
757
+ let renderedMatches = _renderMatches(
758
+ matches && matches.map(
759
+ (match) => Object.assign({}, match, {
760
+ params: Object.assign({}, parentParams, match.params),
761
+ pathname: joinPaths([
762
+ parentPathnameBase,
763
+ // Re-encode pathnames that were decoded inside matchRoutes.
764
+ // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
765
+ // `new URL()` internally and we need to prevent it from treating
766
+ // them as separators
767
+ navigator.encodeLocation ? navigator.encodeLocation(
768
+ match.pathname.replace(/\?/g, "%3F").replace(/#/g, "%23")
769
+ ).pathname : match.pathname
770
+ ]),
771
+ pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
772
+ parentPathnameBase,
773
+ // Re-encode pathnames that were decoded inside matchRoutes
774
+ // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
775
+ // `new URL()` internally and we need to prevent it from treating
776
+ // them as separators
777
+ navigator.encodeLocation ? navigator.encodeLocation(
778
+ match.pathnameBase.replace(/\?/g, "%3F").replace(/#/g, "%23")
779
+ ).pathname : match.pathnameBase
780
+ ])
781
+ })
782
+ ),
783
+ parentMatches,
784
+ dataRouterState,
785
+ onError,
786
+ future
787
+ );
788
+ return renderedMatches;
789
+ }
790
+ function DefaultErrorComponent() {
791
+ let error = useRouteError();
792
+ let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
793
+ let stack = error instanceof Error ? error.stack : null;
794
+ let lightgrey = "rgba(200,200,200, 0.5)";
795
+ let preStyles = { padding: "0.5rem", backgroundColor: lightgrey };
796
+ let codeStyles = { padding: "2px 4px", backgroundColor: lightgrey };
797
+ let devInfo = null;
798
+ {
799
+ console.error(
800
+ "Error handled by React Router default ErrorBoundary:",
801
+ error
802
+ );
803
+ devInfo = /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("p", null, "\u{1F4BF} Hey developer \u{1F44B}"), /* @__PURE__ */ React3.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React3.createElement("code", { style: codeStyles }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React3.createElement("code", { style: codeStyles }, "errorElement"), " prop on your route."));
804
+ }
805
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React3.createElement("h3", { style: { fontStyle: "italic" } }, message), stack ? /* @__PURE__ */ React3.createElement("pre", { style: preStyles }, stack) : null, devInfo);
806
+ }
807
+ var defaultErrorElement = /* @__PURE__ */ React3.createElement(DefaultErrorComponent, null);
808
+ var RenderErrorBoundary = class extends React3.Component {
809
+ constructor(props) {
810
+ super(props);
811
+ this.state = {
812
+ location: props.location,
813
+ revalidation: props.revalidation,
814
+ error: props.error
815
+ };
816
+ }
817
+ static getDerivedStateFromError(error) {
818
+ return { error };
819
+ }
820
+ static getDerivedStateFromProps(props, state) {
821
+ if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
822
+ return {
823
+ error: props.error,
824
+ location: props.location,
825
+ revalidation: props.revalidation
826
+ };
827
+ }
828
+ return {
829
+ error: props.error !== void 0 ? props.error : state.error,
830
+ location: state.location,
831
+ revalidation: props.revalidation || state.revalidation
832
+ };
833
+ }
834
+ componentDidCatch(error, errorInfo) {
835
+ if (this.props.onError) {
836
+ this.props.onError(error, errorInfo);
837
+ } else {
838
+ console.error(
839
+ "React Router caught the following error during render",
840
+ error
841
+ );
842
+ }
843
+ }
844
+ render() {
845
+ let error = this.state.error;
846
+ if (this.context && typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
847
+ const decoded = decodeRouteErrorResponseDigest(error.digest);
848
+ if (decoded) error = decoded;
849
+ }
850
+ let result = error !== void 0 ? /* @__PURE__ */ React3.createElement(RouteContext.Provider, { value: this.props.routeContext }, /* @__PURE__ */ React3.createElement(
851
+ RouteErrorContext.Provider,
852
+ {
853
+ value: error,
854
+ children: this.props.component
855
+ }
856
+ )) : this.props.children;
857
+ if (this.context) {
858
+ return /* @__PURE__ */ React3.createElement(RSCErrorHandler, { error }, result);
859
+ }
860
+ return result;
861
+ }
862
+ };
863
+ RenderErrorBoundary.contextType = RSCRouterContext;
864
+ var errorRedirectHandledMap = /* @__PURE__ */ new WeakMap();
865
+ function RSCErrorHandler({
866
+ children,
867
+ error
868
+ }) {
869
+ let { basename } = React3.useContext(NavigationContext);
870
+ if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
871
+ let redirect2 = decodeRedirectErrorDigest(error.digest);
872
+ if (redirect2) {
873
+ let existingRedirect = errorRedirectHandledMap.get(error);
874
+ if (existingRedirect) throw existingRedirect;
875
+ let parsed = parseToInfo(redirect2.location, basename);
876
+ if (isBrowser && !errorRedirectHandledMap.get(error)) {
877
+ if (parsed.isExternal || redirect2.reloadDocument) {
878
+ window.location.href = parsed.absoluteURL || parsed.to;
879
+ } else {
880
+ const redirectPromise = Promise.resolve().then(
881
+ () => window.__reactRouterDataRouter.navigate(parsed.to, {
882
+ replace: redirect2.replace
883
+ })
884
+ );
885
+ errorRedirectHandledMap.set(error, redirectPromise);
886
+ throw redirectPromise;
887
+ }
888
+ }
889
+ return /* @__PURE__ */ React3.createElement(
890
+ "meta",
891
+ {
892
+ httpEquiv: "refresh",
893
+ content: `0;url=${parsed.absoluteURL || parsed.to}`
894
+ }
895
+ );
896
+ }
897
+ }
898
+ return children;
899
+ }
900
+ function RenderedRoute({ routeContext, match, children }) {
901
+ let dataRouterContext = React3.useContext(DataRouterContext);
902
+ if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
903
+ dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
904
+ }
905
+ return /* @__PURE__ */ React3.createElement(RouteContext.Provider, { value: routeContext }, children);
906
+ }
907
+ function _renderMatches(matches, parentMatches = [], dataRouterState = null, onErrorHandler = null, future = null) {
908
+ if (matches == null) {
909
+ if (!dataRouterState) {
910
+ return null;
911
+ }
912
+ if (dataRouterState.errors) {
913
+ matches = dataRouterState.matches;
914
+ } else if (parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
915
+ matches = dataRouterState.matches;
916
+ } else {
917
+ return null;
918
+ }
919
+ }
920
+ let renderedMatches = matches;
921
+ let errors = dataRouterState?.errors;
922
+ if (errors != null) {
923
+ let errorIndex = renderedMatches.findIndex(
924
+ (m) => m.route.id && errors?.[m.route.id] !== void 0
925
+ );
926
+ invariant(
927
+ errorIndex >= 0,
928
+ `Could not find a matching route for errors on route IDs: ${Object.keys(
929
+ errors
930
+ ).join(",")}`
931
+ );
932
+ renderedMatches = renderedMatches.slice(
933
+ 0,
934
+ Math.min(renderedMatches.length, errorIndex + 1)
935
+ );
936
+ }
937
+ let renderFallback = false;
938
+ let fallbackIndex = -1;
939
+ if (dataRouterState) {
940
+ for (let i = 0; i < renderedMatches.length; i++) {
941
+ let match = renderedMatches[i];
942
+ if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
943
+ fallbackIndex = i;
944
+ }
945
+ if (match.route.id) {
946
+ let { loaderData, errors: errors2 } = dataRouterState;
947
+ let needsToRunLoader = match.route.loader && !loaderData.hasOwnProperty(match.route.id) && (!errors2 || errors2[match.route.id] === void 0);
948
+ if (match.route.lazy || needsToRunLoader) {
949
+ renderFallback = true;
950
+ if (fallbackIndex >= 0) {
951
+ renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
952
+ } else {
953
+ renderedMatches = [renderedMatches[0]];
954
+ }
955
+ break;
956
+ }
957
+ }
958
+ }
959
+ }
960
+ let onError = dataRouterState && onErrorHandler ? (error, errorInfo) => {
961
+ onErrorHandler(error, {
962
+ location: dataRouterState.location,
963
+ params: dataRouterState.matches?.[0]?.params ?? {},
964
+ unstable_pattern: getRoutePattern(dataRouterState.matches),
965
+ errorInfo
966
+ });
967
+ } : void 0;
968
+ return renderedMatches.reduceRight(
969
+ (outlet, match, index) => {
970
+ let error;
971
+ let shouldRenderHydrateFallback = false;
972
+ let errorElement = null;
973
+ let hydrateFallbackElement = null;
974
+ if (dataRouterState) {
975
+ error = errors && match.route.id ? errors[match.route.id] : void 0;
976
+ errorElement = match.route.errorElement || defaultErrorElement;
977
+ if (renderFallback) {
978
+ if (fallbackIndex < 0 && index === 0) {
979
+ warningOnce(
980
+ "route-fallback",
981
+ false,
982
+ "No `HydrateFallback` element provided to render during initial hydration"
983
+ );
984
+ shouldRenderHydrateFallback = true;
985
+ hydrateFallbackElement = null;
986
+ } else if (fallbackIndex === index) {
987
+ shouldRenderHydrateFallback = true;
988
+ hydrateFallbackElement = match.route.hydrateFallbackElement || null;
989
+ }
990
+ }
991
+ }
992
+ let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
993
+ let getChildren = () => {
994
+ let children;
995
+ if (error) {
996
+ children = errorElement;
997
+ } else if (shouldRenderHydrateFallback) {
998
+ children = hydrateFallbackElement;
999
+ } else if (match.route.Component) {
1000
+ children = /* @__PURE__ */ React3.createElement(match.route.Component, null);
1001
+ } else if (match.route.element) {
1002
+ children = match.route.element;
1003
+ } else {
1004
+ children = outlet;
1005
+ }
1006
+ return /* @__PURE__ */ React3.createElement(
1007
+ RenderedRoute,
1008
+ {
1009
+ match,
1010
+ routeContext: {
1011
+ outlet,
1012
+ matches: matches2,
1013
+ isDataRoute: dataRouterState != null
1014
+ },
1015
+ children
1016
+ }
1017
+ );
1018
+ };
1019
+ return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React3.createElement(
1020
+ RenderErrorBoundary,
1021
+ {
1022
+ location: dataRouterState.location,
1023
+ revalidation: dataRouterState.revalidation,
1024
+ component: errorElement,
1025
+ error,
1026
+ children: getChildren(),
1027
+ routeContext: { outlet: null, matches: matches2, isDataRoute: true },
1028
+ onError
1029
+ }
1030
+ ) : getChildren();
1031
+ },
1032
+ null
1033
+ );
1034
+ }
1035
+ function getDataRouterConsoleError(hookName) {
1036
+ return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
1037
+ }
1038
+ function useDataRouterContext(hookName) {
1039
+ let ctx = React3.useContext(DataRouterContext);
1040
+ invariant(ctx, getDataRouterConsoleError(hookName));
1041
+ return ctx;
1042
+ }
1043
+ function useDataRouterState(hookName) {
1044
+ let state = React3.useContext(DataRouterStateContext);
1045
+ invariant(state, getDataRouterConsoleError(hookName));
1046
+ return state;
1047
+ }
1048
+ function useRouteContext(hookName) {
1049
+ let route = React3.useContext(RouteContext);
1050
+ invariant(route, getDataRouterConsoleError(hookName));
1051
+ return route;
1052
+ }
1053
+ function useCurrentRouteId(hookName) {
1054
+ let route = useRouteContext(hookName);
1055
+ let thisRoute = route.matches[route.matches.length - 1];
1056
+ invariant(
1057
+ thisRoute.route.id,
1058
+ `${hookName} can only be used on routes that contain a unique "id"`
1059
+ );
1060
+ return thisRoute.route.id;
1061
+ }
1062
+ function useRouteId() {
1063
+ return useCurrentRouteId("useRouteId" /* UseRouteId */);
1064
+ }
1065
+ function useRouteError() {
1066
+ let error = React3.useContext(RouteErrorContext);
1067
+ let state = useDataRouterState("useRouteError" /* UseRouteError */);
1068
+ let routeId = useCurrentRouteId("useRouteError" /* UseRouteError */);
1069
+ if (error !== void 0) {
1070
+ return error;
1071
+ }
1072
+ return state.errors?.[routeId];
1073
+ }
1074
+ function useNavigateStable() {
1075
+ let { router } = useDataRouterContext("useNavigate" /* UseNavigateStable */);
1076
+ let id = useCurrentRouteId("useNavigate" /* UseNavigateStable */);
1077
+ let activeRef = React3.useRef(false);
1078
+ useIsomorphicLayoutEffect(() => {
1079
+ activeRef.current = true;
1080
+ });
1081
+ let navigate = React3.useCallback(
1082
+ async (to, options = {}) => {
1083
+ warning(activeRef.current, navigateEffectWarning);
1084
+ if (!activeRef.current) return;
1085
+ if (typeof to === "number") {
1086
+ await router.navigate(to);
1087
+ } else {
1088
+ await router.navigate(to, { fromRouteId: id, ...options });
1089
+ }
1090
+ },
1091
+ [router, id]
1092
+ );
1093
+ return navigate;
1094
+ }
1095
+ var alreadyWarned = {};
1096
+ function warningOnce(key, cond, message) {
1097
+ if (!cond && !alreadyWarned[key]) {
1098
+ alreadyWarned[key] = true;
1099
+ warning(false, message);
1100
+ }
1101
+ }
1102
+ React3.memo(DataRoutes);
1103
+ function DataRoutes({
1104
+ routes,
1105
+ future,
1106
+ state,
1107
+ onError
1108
+ }) {
1109
+ return useRoutesImpl(routes, void 0, state, onError, future);
1110
+ }
1111
+
1112
+ // lib/dom/dom.ts
1113
+ var defaultMethod = "get";
1114
+ var defaultEncType = "application/x-www-form-urlencoded";
1115
+ function isHtmlElement(object) {
1116
+ return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
1117
+ }
1118
+ function isButtonElement(object) {
1119
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
1120
+ }
1121
+ function isFormElement(object) {
1122
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
1123
+ }
1124
+ function isInputElement(object) {
1125
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
1126
+ }
1127
+ function isModifiedEvent(event) {
1128
+ return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
1129
+ }
1130
+ function shouldProcessLinkClick(event, target) {
1131
+ return event.button === 0 && // Ignore everything but left clicks
1132
+ (!target || target === "_self") && // Let browser handle "target=_blank" etc.
1133
+ !isModifiedEvent(event);
1134
+ }
1135
+ var _formDataSupportsSubmitter = null;
1136
+ function isFormDataSubmitterSupported() {
1137
+ if (_formDataSupportsSubmitter === null) {
1138
+ try {
1139
+ new FormData(
1140
+ document.createElement("form"),
1141
+ // @ts-expect-error if FormData supports the submitter parameter, this will throw
1142
+ 0
1143
+ );
1144
+ _formDataSupportsSubmitter = false;
1145
+ } catch (e) {
1146
+ _formDataSupportsSubmitter = true;
1147
+ }
1148
+ }
1149
+ return _formDataSupportsSubmitter;
1150
+ }
1151
+ var supportedFormEncTypes = /* @__PURE__ */ new Set([
1152
+ "application/x-www-form-urlencoded",
1153
+ "multipart/form-data",
1154
+ "text/plain"
1155
+ ]);
1156
+ function getFormEncType(encType) {
1157
+ if (encType != null && !supportedFormEncTypes.has(encType)) {
1158
+ warning(
1159
+ false,
1160
+ `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
1161
+ );
1162
+ return null;
1163
+ }
1164
+ return encType;
1165
+ }
1166
+ function getFormSubmissionInfo(target, basename) {
1167
+ let method;
1168
+ let action;
1169
+ let encType;
1170
+ let formData;
1171
+ let body;
1172
+ if (isFormElement(target)) {
1173
+ let attr = target.getAttribute("action");
1174
+ action = attr ? stripBasename(attr, basename) : null;
1175
+ method = target.getAttribute("method") || defaultMethod;
1176
+ encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
1177
+ formData = new FormData(target);
1178
+ } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
1179
+ let form = target.form;
1180
+ if (form == null) {
1181
+ throw new Error(
1182
+ `Cannot submit a <button> or <input type="submit"> without a <form>`
1183
+ );
1184
+ }
1185
+ let attr = target.getAttribute("formaction") || form.getAttribute("action");
1186
+ action = attr ? stripBasename(attr, basename) : null;
1187
+ method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
1188
+ encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
1189
+ formData = new FormData(form, target);
1190
+ if (!isFormDataSubmitterSupported()) {
1191
+ let { name, type, value } = target;
1192
+ if (type === "image") {
1193
+ let prefix = name ? `${name}.` : "";
1194
+ formData.append(`${prefix}x`, "0");
1195
+ formData.append(`${prefix}y`, "0");
1196
+ } else if (name) {
1197
+ formData.append(name, value);
1198
+ }
1199
+ }
1200
+ } else if (isHtmlElement(target)) {
1201
+ throw new Error(
1202
+ `Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
1203
+ );
1204
+ } else {
1205
+ method = defaultMethod;
1206
+ action = null;
1207
+ encType = defaultEncType;
1208
+ body = target;
1209
+ }
1210
+ if (formData && encType === "text/plain") {
1211
+ body = formData;
1212
+ formData = void 0;
1213
+ }
1214
+ return { action, method: method.toLowerCase(), encType, formData, body };
1215
+ }
1216
+ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
1217
+
1218
+ // lib/dom/ssr/invariant.ts
1219
+ function invariant2(value, message) {
1220
+ if (value === false || value === null || typeof value === "undefined") {
1221
+ throw new Error(message);
1222
+ }
1223
+ }
1224
+ function singleFetchUrl(reqUrl, basename, trailingSlashAware, extension) {
1225
+ let url = typeof reqUrl === "string" ? new URL(
1226
+ reqUrl,
1227
+ // This can be called during the SSR flow via PrefetchPageLinksImpl so
1228
+ // don't assume window is available
1229
+ typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
1230
+ ) : reqUrl;
1231
+ if (trailingSlashAware) {
1232
+ if (url.pathname.endsWith("/")) {
1233
+ url.pathname = `${url.pathname}_.${extension}`;
1234
+ } else {
1235
+ url.pathname = `${url.pathname}.${extension}`;
1236
+ }
1237
+ } else {
1238
+ if (url.pathname === "/") {
1239
+ url.pathname = `_root.${extension}`;
1240
+ } else if (basename && stripBasename(url.pathname, basename) === "/") {
1241
+ url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
1242
+ } else {
1243
+ url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
1244
+ }
1245
+ }
1246
+ return url;
1247
+ }
1248
+
1249
+ // lib/dom/ssr/routeModules.ts
1250
+ async function loadRouteModule(route, routeModulesCache) {
1251
+ if (route.id in routeModulesCache) {
1252
+ return routeModulesCache[route.id];
1253
+ }
1254
+ try {
1255
+ let routeModule = await import(
1256
+ /* @vite-ignore */
1257
+ /* webpackIgnore: true */
1258
+ route.module
1259
+ );
1260
+ routeModulesCache[route.id] = routeModule;
1261
+ return routeModule;
1262
+ } catch (error) {
1263
+ console.error(
1264
+ `Error loading route module \`${route.module}\`, reloading page...`
1265
+ );
1266
+ console.error(error);
1267
+ if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
1268
+ import.meta.hot) {
1269
+ throw error;
1270
+ }
1271
+ window.location.reload();
1272
+ return new Promise(() => {
1273
+ });
1274
+ }
1275
+ }
1276
+ function isHtmlLinkDescriptor(object) {
1277
+ if (object == null) {
1278
+ return false;
1279
+ }
1280
+ if (object.href == null) {
1281
+ return object.rel === "preload" && typeof object.imageSrcSet === "string" && typeof object.imageSizes === "string";
1282
+ }
1283
+ return typeof object.rel === "string" && typeof object.href === "string";
1284
+ }
1285
+ async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
1286
+ let links = await Promise.all(
1287
+ matches.map(async (match) => {
1288
+ let route = manifest.routes[match.route.id];
1289
+ if (route) {
1290
+ let mod = await loadRouteModule(route, routeModules);
1291
+ return mod.links ? mod.links() : [];
1292
+ }
1293
+ return [];
1294
+ })
1295
+ );
1296
+ return dedupeLinkDescriptors(
1297
+ links.flat(1).filter(isHtmlLinkDescriptor).filter((link) => link.rel === "stylesheet" || link.rel === "preload").map(
1298
+ (link) => link.rel === "stylesheet" ? { ...link, rel: "prefetch", as: "style" } : { ...link, rel: "prefetch" }
1299
+ )
1300
+ );
1301
+ }
1302
+ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
1303
+ let isNew = (match, index) => {
1304
+ if (!currentMatches[index]) return true;
1305
+ return match.route.id !== currentMatches[index].route.id;
1306
+ };
1307
+ let matchPathChanged = (match, index) => {
1308
+ return (
1309
+ // param change, /users/123 -> /users/456
1310
+ currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
1311
+ // e.g. /files/images/avatar.jpg -> files/finances.xls
1312
+ currentMatches[index].route.path?.endsWith("*") && currentMatches[index].params["*"] !== match.params["*"]
1313
+ );
1314
+ };
1315
+ if (mode === "assets") {
1316
+ return nextMatches.filter(
1317
+ (match, index) => isNew(match, index) || matchPathChanged(match, index)
1318
+ );
1319
+ }
1320
+ if (mode === "data") {
1321
+ return nextMatches.filter((match, index) => {
1322
+ let manifestRoute = manifest.routes[match.route.id];
1323
+ if (!manifestRoute || !manifestRoute.hasLoader) {
1324
+ return false;
1325
+ }
1326
+ if (isNew(match, index) || matchPathChanged(match, index)) {
1327
+ return true;
1328
+ }
1329
+ if (match.route.shouldRevalidate) {
1330
+ let routeChoice = match.route.shouldRevalidate({
1331
+ currentUrl: new URL(
1332
+ location.pathname + location.search + location.hash,
1333
+ window.origin
1334
+ ),
1335
+ currentParams: currentMatches[0]?.params || {},
1336
+ nextUrl: new URL(page, window.origin),
1337
+ nextParams: match.params,
1338
+ defaultShouldRevalidate: true
1339
+ });
1340
+ if (typeof routeChoice === "boolean") {
1341
+ return routeChoice;
1342
+ }
1343
+ }
1344
+ return true;
1345
+ });
1346
+ }
1347
+ return [];
1348
+ }
1349
+ function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
1350
+ return dedupeHrefs(
1351
+ matches.map((match) => {
1352
+ let route = manifest.routes[match.route.id];
1353
+ if (!route) return [];
1354
+ let hrefs = [route.module];
1355
+ if (route.clientActionModule) {
1356
+ hrefs = hrefs.concat(route.clientActionModule);
1357
+ }
1358
+ if (route.clientLoaderModule) {
1359
+ hrefs = hrefs.concat(route.clientLoaderModule);
1360
+ }
1361
+ if (includeHydrateFallback && route.hydrateFallbackModule) {
1362
+ hrefs = hrefs.concat(route.hydrateFallbackModule);
1363
+ }
1364
+ if (route.imports) {
1365
+ hrefs = hrefs.concat(route.imports);
1366
+ }
1367
+ return hrefs;
1368
+ }).flat(1)
1369
+ );
1370
+ }
1371
+ function dedupeHrefs(hrefs) {
1372
+ return [...new Set(hrefs)];
1373
+ }
1374
+ function sortKeys(obj) {
1375
+ let sorted = {};
1376
+ let keys = Object.keys(obj).sort();
1377
+ for (let key of keys) {
1378
+ sorted[key] = obj[key];
1379
+ }
1380
+ return sorted;
1381
+ }
1382
+ function dedupeLinkDescriptors(descriptors, preloads) {
1383
+ let set = /* @__PURE__ */ new Set();
1384
+ new Set(preloads);
1385
+ return descriptors.reduce((deduped, descriptor) => {
1386
+ let key = JSON.stringify(sortKeys(descriptor));
1387
+ if (!set.has(key)) {
1388
+ set.add(key);
1389
+ deduped.push({ key, link: descriptor });
1390
+ }
1391
+ return deduped;
1392
+ }, []);
1393
+ }
1394
+
1395
+ // lib/dom/ssr/components.tsx
1396
+ function useDataRouterContext2() {
1397
+ let context = React3.useContext(DataRouterContext);
1398
+ invariant2(
1399
+ context,
1400
+ "You must render this element inside a <DataRouterContext.Provider> element"
1401
+ );
1402
+ return context;
1403
+ }
1404
+ function useDataRouterStateContext() {
1405
+ let context = React3.useContext(DataRouterStateContext);
1406
+ invariant2(
1407
+ context,
1408
+ "You must render this element inside a <DataRouterStateContext.Provider> element"
1409
+ );
1410
+ return context;
1411
+ }
1412
+ var FrameworkContext = React3.createContext(void 0);
1413
+ FrameworkContext.displayName = "FrameworkContext";
1414
+ function useFrameworkContext() {
1415
+ let context = React3.useContext(FrameworkContext);
1416
+ invariant2(
1417
+ context,
1418
+ "You must render this element inside a <HydratedRouter> element"
1419
+ );
1420
+ return context;
1421
+ }
1422
+ function usePrefetchBehavior(prefetch, theirElementProps) {
1423
+ let frameworkContext = React3.useContext(FrameworkContext);
1424
+ let [maybePrefetch, setMaybePrefetch] = React3.useState(false);
1425
+ let [shouldPrefetch, setShouldPrefetch] = React3.useState(false);
1426
+ let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
1427
+ let ref = React3.useRef(null);
1428
+ React3.useEffect(() => {
1429
+ if (prefetch === "render") {
1430
+ setShouldPrefetch(true);
1431
+ }
1432
+ if (prefetch === "viewport") {
1433
+ let callback = (entries) => {
1434
+ entries.forEach((entry) => {
1435
+ setShouldPrefetch(entry.isIntersecting);
1436
+ });
1437
+ };
1438
+ let observer = new IntersectionObserver(callback, { threshold: 0.5 });
1439
+ if (ref.current) observer.observe(ref.current);
1440
+ return () => {
1441
+ observer.disconnect();
1442
+ };
1443
+ }
1444
+ }, [prefetch]);
1445
+ React3.useEffect(() => {
1446
+ if (maybePrefetch) {
1447
+ let id = setTimeout(() => {
1448
+ setShouldPrefetch(true);
1449
+ }, 100);
1450
+ return () => {
1451
+ clearTimeout(id);
1452
+ };
1453
+ }
1454
+ }, [maybePrefetch]);
1455
+ let setIntent = () => {
1456
+ setMaybePrefetch(true);
1457
+ };
1458
+ let cancelIntent = () => {
1459
+ setMaybePrefetch(false);
1460
+ setShouldPrefetch(false);
1461
+ };
1462
+ if (!frameworkContext) {
1463
+ return [false, ref, {}];
1464
+ }
1465
+ if (prefetch !== "intent") {
1466
+ return [shouldPrefetch, ref, {}];
1467
+ }
1468
+ return [
1469
+ shouldPrefetch,
1470
+ ref,
1471
+ {
1472
+ onFocus: composeEventHandlers(onFocus, setIntent),
1473
+ onBlur: composeEventHandlers(onBlur, cancelIntent),
1474
+ onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
1475
+ onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
1476
+ onTouchStart: composeEventHandlers(onTouchStart, setIntent)
1477
+ }
1478
+ ];
1479
+ }
1480
+ function composeEventHandlers(theirHandler, ourHandler) {
1481
+ return (event) => {
1482
+ theirHandler && theirHandler(event);
1483
+ if (!event.defaultPrevented) {
1484
+ ourHandler(event);
1485
+ }
1486
+ };
1487
+ }
1488
+ function PrefetchPageLinks({ page, ...linkProps }) {
1489
+ let { router } = useDataRouterContext2();
1490
+ let matches = React3.useMemo(
1491
+ () => matchRoutes(router.routes, page, router.basename),
1492
+ [router.routes, page, router.basename]
1493
+ );
1494
+ if (!matches) {
1495
+ return null;
1496
+ }
1497
+ return /* @__PURE__ */ React3.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
1498
+ }
1499
+ function useKeyedPrefetchLinks(matches) {
1500
+ let { manifest, routeModules } = useFrameworkContext();
1501
+ let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React3.useState([]);
1502
+ React3.useEffect(() => {
1503
+ let interrupted = false;
1504
+ void getKeyedPrefetchLinks(matches, manifest, routeModules).then(
1505
+ (links) => {
1506
+ if (!interrupted) {
1507
+ setKeyedPrefetchLinks(links);
1508
+ }
1509
+ }
1510
+ );
1511
+ return () => {
1512
+ interrupted = true;
1513
+ };
1514
+ }, [matches, manifest, routeModules]);
1515
+ return keyedPrefetchLinks;
1516
+ }
1517
+ function PrefetchPageLinksImpl({
1518
+ page,
1519
+ matches: nextMatches,
1520
+ ...linkProps
1521
+ }) {
1522
+ let location = useLocation();
1523
+ let { future, manifest, routeModules } = useFrameworkContext();
1524
+ let { basename } = useDataRouterContext2();
1525
+ let { loaderData, matches } = useDataRouterStateContext();
1526
+ let newMatchesForData = React3.useMemo(
1527
+ () => getNewMatchesForLinks(
1528
+ page,
1529
+ nextMatches,
1530
+ matches,
1531
+ manifest,
1532
+ location,
1533
+ "data"
1534
+ ),
1535
+ [page, nextMatches, matches, manifest, location]
1536
+ );
1537
+ let newMatchesForAssets = React3.useMemo(
1538
+ () => getNewMatchesForLinks(
1539
+ page,
1540
+ nextMatches,
1541
+ matches,
1542
+ manifest,
1543
+ location,
1544
+ "assets"
1545
+ ),
1546
+ [page, nextMatches, matches, manifest, location]
1547
+ );
1548
+ let dataHrefs = React3.useMemo(() => {
1549
+ if (page === location.pathname + location.search + location.hash) {
1550
+ return [];
1551
+ }
1552
+ let routesParams = /* @__PURE__ */ new Set();
1553
+ let foundOptOutRoute = false;
1554
+ nextMatches.forEach((m) => {
1555
+ let manifestRoute = manifest.routes[m.route.id];
1556
+ if (!manifestRoute || !manifestRoute.hasLoader) {
1557
+ return;
1558
+ }
1559
+ if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && routeModules[m.route.id]?.shouldRevalidate) {
1560
+ foundOptOutRoute = true;
1561
+ } else if (manifestRoute.hasClientLoader) {
1562
+ foundOptOutRoute = true;
1563
+ } else {
1564
+ routesParams.add(m.route.id);
1565
+ }
1566
+ });
1567
+ if (routesParams.size === 0) {
1568
+ return [];
1569
+ }
1570
+ let url = singleFetchUrl(
1571
+ page,
1572
+ basename,
1573
+ future.unstable_trailingSlashAwareDataRequests,
1574
+ "data"
1575
+ );
1576
+ if (foundOptOutRoute && routesParams.size > 0) {
1577
+ url.searchParams.set(
1578
+ "_routes",
1579
+ nextMatches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
1580
+ );
1581
+ }
1582
+ return [url.pathname + url.search];
1583
+ }, [
1584
+ basename,
1585
+ future.unstable_trailingSlashAwareDataRequests,
1586
+ loaderData,
1587
+ location,
1588
+ manifest,
1589
+ newMatchesForData,
1590
+ nextMatches,
1591
+ page,
1592
+ routeModules
1593
+ ]);
1594
+ let moduleHrefs = React3.useMemo(
1595
+ () => getModuleLinkHrefs(newMatchesForAssets, manifest),
1596
+ [newMatchesForAssets, manifest]
1597
+ );
1598
+ let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
1599
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React3.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })), moduleHrefs.map((href) => /* @__PURE__ */ React3.createElement("link", { key: href, rel: "modulepreload", href, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
1600
+ // these don't spread `linkProps` because they are full link descriptors
1601
+ // already with their own props
1602
+ /* @__PURE__ */ React3.createElement("link", { key, nonce: linkProps.nonce, ...link })
1603
+ )));
1604
+ }
1605
+ function mergeRefs(...refs) {
1606
+ return (value) => {
1607
+ refs.forEach((ref) => {
1608
+ if (typeof ref === "function") {
1609
+ ref(value);
1610
+ } else if (ref != null) {
1611
+ ref.current = value;
1612
+ }
1613
+ });
1614
+ };
1615
+ }
1616
+ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
1617
+ try {
1618
+ if (isBrowser2) {
1619
+ window.__reactRouterVersion = // @ts-expect-error
1620
+ "7.12.0";
1621
+ }
1622
+ } catch (e) {
1623
+ }
1624
+ var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1625
+ var Link = React3.forwardRef(
1626
+ function LinkWithRef({
1627
+ onClick,
1628
+ discover = "render",
1629
+ prefetch = "none",
1630
+ relative,
1631
+ reloadDocument,
1632
+ replace: replace2,
1633
+ state,
1634
+ target,
1635
+ to,
1636
+ preventScrollReset,
1637
+ viewTransition,
1638
+ unstable_defaultShouldRevalidate,
1639
+ ...rest
1640
+ }, forwardedRef) {
1641
+ let { basename, unstable_useTransitions } = React3.useContext(NavigationContext);
1642
+ let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
1643
+ let parsed = parseToInfo(to, basename);
1644
+ to = parsed.to;
1645
+ let href = useHref(to, { relative });
1646
+ let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(
1647
+ prefetch,
1648
+ rest
1649
+ );
1650
+ let internalOnClick = useLinkClickHandler(to, {
1651
+ replace: replace2,
1652
+ state,
1653
+ target,
1654
+ preventScrollReset,
1655
+ relative,
1656
+ viewTransition,
1657
+ unstable_defaultShouldRevalidate,
1658
+ unstable_useTransitions
1659
+ });
1660
+ function handleClick(event) {
1661
+ if (onClick) onClick(event);
1662
+ if (!event.defaultPrevented) {
1663
+ internalOnClick(event);
1664
+ }
1665
+ }
1666
+ let link = (
1667
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
1668
+ /* @__PURE__ */ React3.createElement(
1669
+ "a",
1670
+ {
1671
+ ...rest,
1672
+ ...prefetchHandlers,
1673
+ href: parsed.absoluteURL || href,
1674
+ onClick: parsed.isExternal || reloadDocument ? onClick : handleClick,
1675
+ ref: mergeRefs(forwardedRef, prefetchRef),
1676
+ target,
1677
+ "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
1678
+ }
1679
+ )
1680
+ );
1681
+ return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, link, /* @__PURE__ */ React3.createElement(PrefetchPageLinks, { page: href })) : link;
1682
+ }
1683
+ );
1684
+ Link.displayName = "Link";
1685
+ var NavLink = React3.forwardRef(
1686
+ function NavLinkWithRef({
1687
+ "aria-current": ariaCurrentProp = "page",
1688
+ caseSensitive = false,
1689
+ className: classNameProp = "",
1690
+ end = false,
1691
+ style: styleProp,
1692
+ to,
1693
+ viewTransition,
1694
+ children,
1695
+ ...rest
1696
+ }, ref) {
1697
+ let path = useResolvedPath(to, { relative: rest.relative });
1698
+ let location = useLocation();
1699
+ let routerState = React3.useContext(DataRouterStateContext);
1700
+ let { navigator, basename } = React3.useContext(NavigationContext);
1701
+ let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
1702
+ // eslint-disable-next-line react-hooks/rules-of-hooks
1703
+ useViewTransitionState(path) && viewTransition === true;
1704
+ let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
1705
+ let locationPathname = location.pathname;
1706
+ let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
1707
+ if (!caseSensitive) {
1708
+ locationPathname = locationPathname.toLowerCase();
1709
+ nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
1710
+ toPathname = toPathname.toLowerCase();
1711
+ }
1712
+ if (nextLocationPathname && basename) {
1713
+ nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
1714
+ }
1715
+ const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
1716
+ let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
1717
+ let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
1718
+ let renderProps = {
1719
+ isActive,
1720
+ isPending,
1721
+ isTransitioning
1722
+ };
1723
+ let ariaCurrent = isActive ? ariaCurrentProp : void 0;
1724
+ let className;
1725
+ if (typeof classNameProp === "function") {
1726
+ className = classNameProp(renderProps);
1727
+ } else {
1728
+ className = [
1729
+ classNameProp,
1730
+ isActive ? "active" : null,
1731
+ isPending ? "pending" : null,
1732
+ isTransitioning ? "transitioning" : null
1733
+ ].filter(Boolean).join(" ");
1734
+ }
1735
+ let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
1736
+ return /* @__PURE__ */ React3.createElement(
1737
+ Link,
1738
+ {
1739
+ ...rest,
1740
+ "aria-current": ariaCurrent,
1741
+ className,
1742
+ ref,
1743
+ style,
1744
+ to,
1745
+ viewTransition
1746
+ },
1747
+ typeof children === "function" ? children(renderProps) : children
1748
+ );
1749
+ }
1750
+ );
1751
+ NavLink.displayName = "NavLink";
1752
+ var Form = React3.forwardRef(
1753
+ ({
1754
+ discover = "render",
1755
+ fetcherKey,
1756
+ navigate,
1757
+ reloadDocument,
1758
+ replace: replace2,
1759
+ state,
1760
+ method = defaultMethod,
1761
+ action,
1762
+ onSubmit,
1763
+ relative,
1764
+ preventScrollReset,
1765
+ viewTransition,
1766
+ unstable_defaultShouldRevalidate,
1767
+ ...props
1768
+ }, forwardedRef) => {
1769
+ let { unstable_useTransitions } = React3.useContext(NavigationContext);
1770
+ let submit = useSubmit();
1771
+ let formAction = useFormAction(action, { relative });
1772
+ let formMethod = method.toLowerCase() === "get" ? "get" : "post";
1773
+ let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
1774
+ let submitHandler = (event) => {
1775
+ onSubmit && onSubmit(event);
1776
+ if (event.defaultPrevented) return;
1777
+ event.preventDefault();
1778
+ let submitter = event.nativeEvent.submitter;
1779
+ let submitMethod = submitter?.getAttribute("formmethod") || method;
1780
+ let doSubmit = () => submit(submitter || event.currentTarget, {
1781
+ fetcherKey,
1782
+ method: submitMethod,
1783
+ navigate,
1784
+ replace: replace2,
1785
+ state,
1786
+ relative,
1787
+ preventScrollReset,
1788
+ viewTransition,
1789
+ unstable_defaultShouldRevalidate
1790
+ });
1791
+ if (unstable_useTransitions && navigate !== false) {
1792
+ React3.startTransition(() => doSubmit());
1793
+ } else {
1794
+ doSubmit();
1795
+ }
1796
+ };
1797
+ return /* @__PURE__ */ React3.createElement(
1798
+ "form",
1799
+ {
1800
+ ref: forwardedRef,
1801
+ method: formMethod,
1802
+ action: formAction,
1803
+ onSubmit: reloadDocument ? onSubmit : submitHandler,
1804
+ ...props,
1805
+ "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
1806
+ }
1807
+ );
1808
+ }
1809
+ );
1810
+ Form.displayName = "Form";
1811
+ function getDataRouterConsoleError2(hookName) {
1812
+ return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
1813
+ }
1814
+ function useDataRouterContext3(hookName) {
1815
+ let ctx = React3.useContext(DataRouterContext);
1816
+ invariant(ctx, getDataRouterConsoleError2(hookName));
1817
+ return ctx;
1818
+ }
1819
+ function useLinkClickHandler(to, {
1820
+ target,
1821
+ replace: replaceProp,
1822
+ state,
1823
+ preventScrollReset,
1824
+ relative,
1825
+ viewTransition,
1826
+ unstable_defaultShouldRevalidate,
1827
+ unstable_useTransitions
1828
+ } = {}) {
1829
+ let navigate = useNavigate();
1830
+ let location = useLocation();
1831
+ let path = useResolvedPath(to, { relative });
1832
+ return React3.useCallback(
1833
+ (event) => {
1834
+ if (shouldProcessLinkClick(event, target)) {
1835
+ event.preventDefault();
1836
+ let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
1837
+ let doNavigate = () => navigate(to, {
1838
+ replace: replace2,
1839
+ state,
1840
+ preventScrollReset,
1841
+ relative,
1842
+ viewTransition,
1843
+ unstable_defaultShouldRevalidate
1844
+ });
1845
+ if (unstable_useTransitions) {
1846
+ React3.startTransition(() => doNavigate());
1847
+ } else {
1848
+ doNavigate();
1849
+ }
1850
+ }
1851
+ },
1852
+ [
1853
+ location,
1854
+ navigate,
1855
+ path,
1856
+ replaceProp,
1857
+ state,
1858
+ target,
1859
+ to,
1860
+ preventScrollReset,
1861
+ relative,
1862
+ viewTransition,
1863
+ unstable_defaultShouldRevalidate,
1864
+ unstable_useTransitions
1865
+ ]
1866
+ );
1867
+ }
1868
+ var fetcherId = 0;
1869
+ var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
1870
+ function useSubmit() {
1871
+ let { router } = useDataRouterContext3("useSubmit" /* UseSubmit */);
1872
+ let { basename } = React3.useContext(NavigationContext);
1873
+ let currentRouteId = useRouteId();
1874
+ let routerFetch = router.fetch;
1875
+ let routerNavigate = router.navigate;
1876
+ return React3.useCallback(
1877
+ async (target, options = {}) => {
1878
+ let { action, method, encType, formData, body } = getFormSubmissionInfo(
1879
+ target,
1880
+ basename
1881
+ );
1882
+ if (options.navigate === false) {
1883
+ let key = options.fetcherKey || getUniqueFetcherId();
1884
+ await routerFetch(key, currentRouteId, options.action || action, {
1885
+ unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
1886
+ preventScrollReset: options.preventScrollReset,
1887
+ formData,
1888
+ body,
1889
+ formMethod: options.method || method,
1890
+ formEncType: options.encType || encType,
1891
+ flushSync: options.flushSync
1892
+ });
1893
+ } else {
1894
+ await routerNavigate(options.action || action, {
1895
+ unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
1896
+ preventScrollReset: options.preventScrollReset,
1897
+ formData,
1898
+ body,
1899
+ formMethod: options.method || method,
1900
+ formEncType: options.encType || encType,
1901
+ replace: options.replace,
1902
+ state: options.state,
1903
+ fromRouteId: currentRouteId,
1904
+ flushSync: options.flushSync,
1905
+ viewTransition: options.viewTransition
1906
+ });
1907
+ }
1908
+ },
1909
+ [routerFetch, routerNavigate, basename, currentRouteId]
1910
+ );
1911
+ }
1912
+ function useFormAction(action, { relative } = {}) {
1913
+ let { basename } = React3.useContext(NavigationContext);
1914
+ let routeContext = React3.useContext(RouteContext);
1915
+ invariant(routeContext, "useFormAction must be used inside a RouteContext");
1916
+ let [match] = routeContext.matches.slice(-1);
1917
+ let path = { ...useResolvedPath(action ? action : ".", { relative }) };
1918
+ let location = useLocation();
1919
+ if (action == null) {
1920
+ path.search = location.search;
1921
+ let params = new URLSearchParams(path.search);
1922
+ let indexValues = params.getAll("index");
1923
+ let hasNakedIndexParam = indexValues.some((v) => v === "");
1924
+ if (hasNakedIndexParam) {
1925
+ params.delete("index");
1926
+ indexValues.filter((v) => v).forEach((v) => params.append("index", v));
1927
+ let qs = params.toString();
1928
+ path.search = qs ? `?${qs}` : "";
1929
+ }
1930
+ }
1931
+ if ((!action || action === ".") && match.route.index) {
1932
+ path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
1933
+ }
1934
+ if (basename !== "/") {
1935
+ path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
1936
+ }
1937
+ return createPath(path);
1938
+ }
1939
+ function useViewTransitionState(to, { relative } = {}) {
1940
+ let vtContext = React3.useContext(ViewTransitionContext);
1941
+ invariant(
1942
+ vtContext != null,
1943
+ "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
1944
+ );
1945
+ let { basename } = useDataRouterContext3(
1946
+ "useViewTransitionState" /* useViewTransitionState */
1947
+ );
1948
+ let path = useResolvedPath(to, { relative });
1949
+ if (!vtContext.isTransitioning) {
1950
+ return false;
1951
+ }
1952
+ let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
1953
+ let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
1954
+ return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
1955
+ }
1956
+
1957
+ var css_248z = ".quix_side_menu{border-right:1px solid #333}.quix_menu_item{align-items:center;border-radius:4px;display:flex;height:48px;justify-content:space-between;opacity:100%;width:90%}";
1958
+ styleInject(css_248z);
1959
+
1960
+ function Layout(props) {
1961
+ const { backgroundColor, style, className, sideMenu } = props;
1962
+ return (jsx("section", { className: `${className}`, style: {
1963
+ width: '100vw',
1964
+ height: '100vh',
1965
+ position: 'relative',
1966
+ backgroundColor,
1967
+ ...style
1968
+ }, children: sideMenu && SideMenu(sideMenu) }));
1969
+ }
1970
+ function SideMenu(props) {
1971
+ const { width, height, style, menuItems, ElementType, menuItemsDynamicStyle } = props;
1972
+ return (jsx("aside", { className: " quix_side_menu ", style: {
1973
+ position: 'absolute',
1974
+ left: style?.left ?? 0,
1975
+ bottom: style?.bottom ?? 0,
1976
+ width,
1977
+ height,
1978
+ top: style?.top ?? 80,
1979
+ // ...style
1980
+ }, children: menuItems && menuItems.map((item) => {
1981
+ return MenuItem(item, ElementType, menuItemsDynamicStyle);
1982
+ }) }));
1983
+ }
1984
+ function MenuItem(item, ElementType, menuItemsDynamicStyle) {
1985
+ const [isHover, setIsHover] = useState(false);
1986
+ const color = {
1987
+ bg: isHover ? menuItemsDynamicStyle?.activeColor?.background : 'transparent',
1988
+ text: isHover ? menuItemsDynamicStyle?.activeColor?.text : menuItemsDynamicStyle?.textColor
1989
+ };
1990
+ function onHover() {
1991
+ if (!isHover)
1992
+ setIsHover((prev) => !prev);
1993
+ }
1994
+ function onLeave() {
1995
+ if (isHover)
1996
+ setIsHover((prev) => !prev);
1997
+ }
1998
+ const navigate = (route) => {
1999
+ // window.location.replace(route)
2000
+ };
2001
+ const Element = ({ children }) => ElementType === 'NavLink' ?
2002
+ jsx(NavLink, { style: {
2003
+ width: "100%"
2004
+ }, to: item.route, children: children }, item.label) :
2005
+ ElementType === 'Link' ?
2006
+ jsx(Link, { style: {
2007
+ width: "100%"
2008
+ }, to: item.route, children: children }, item.label) :
2009
+ ElementType === 'a' ?
2010
+ jsx("a", { style: {
2011
+ width: "100%",
2012
+ textDecoration: 'none'
2013
+ }, href: item.route, children: children }, item.label) :
2014
+ jsx("div", { style: {
2015
+ width: "100%"
2016
+ }, onClick: () => {
2017
+ navigate(item.route);
2018
+ }, children: children }, item.label);
2019
+ return (jsx(Element, { children: jsx("div", { style: {
2020
+ padding: 10,
2021
+ width: '100%'
2022
+ }, children: jsxs("div", { onMouseEnter: onHover, onMouseLeave: onLeave, className: 'quix_menu_item ', style: {
2023
+ transition: '0.2s all',
2024
+ backgroundColor: color.bg,
2025
+ color: color.text,
2026
+ border: isHover ? '' : '1px solid #121212 '
2027
+ }, children: [item.icon && item.icon.position === 'left' && item.icon.component, jsx("p", { className: " quix_menuItem_label ", style: {
2028
+ paddingInline: 10,
2029
+ paddingBlock: 8,
2030
+ color: color.text
2031
+ }, children: item?.label }), item.icon && item.icon.position === 'right' && item.icon.component] }) }, item.label) }));
2032
+ }
2033
+
2034
+ function FlexView(props) {
2035
+ const { isScrollable, direction, width, height, backgroundColor, paddingX, paddingY, textColor, className, rounded, gap, style, layout, onClick, onRightClick, tooltip } = props;
2036
+ return jsxs("div", { onContextMenu: onRightClick, onClick: onClick, className: `${className} ${layout} quix_view `, style: {
7
2037
  overflowY: isScrollable ? 'scroll' : 'hidden',
8
2038
  flexDirection: direction || 'row',
9
- alignItems: alignItems || 'stretch',
10
- justifyContent: justifyContent || 'flex-start',
11
2039
  width: width ? `${width}px` : 'auto',
12
2040
  height: height ? `${height}px` : 'auto',
13
2041
  backgroundColor: backgroundColor || 'transparent',
@@ -18,11 +2046,103 @@ function ViewContainer(props) {
18
2046
  borderTopRightRadius: typeof rounded === 'number' ? rounded : rounded?.topRight ?? 4,
19
2047
  borderBottomLeftRadius: typeof rounded === 'number' ? rounded : rounded?.bottomLeft ?? 4,
20
2048
  borderBottomRightRadius: typeof rounded === 'number' ? rounded : rounded?.bottomRight ?? 4,
21
- }, children: props.children });
2049
+ gap,
2050
+ transition: '0.3s all',
2051
+ position: tooltip ? 'relative' : 'unset',
2052
+ ...style
2053
+ }, children: [tooltip && jsx("div", { style: {
2054
+ position: 'absolute',
2055
+ width: '100px',
2056
+ height: '200px',
2057
+ padding: 2,
2058
+ top: tooltip.position === 'top' ? (-(height ?? 100) + 10) : 0,
2059
+ bottom: tooltip.position === 'bottom' ? (-(height ?? 100) + 10) : 0,
2060
+ left: tooltip.position === 'left' ? (-(width ?? 100) - 10) : 0,
2061
+ right: tooltip.position === 'right' ? (-(width ?? 100) + 10) : 0,
2062
+ backgroundColor: '#d4d4',
2063
+ zIndex: 10
2064
+ }, className: "quix_tooltip", children: tooltip.component }), jsx(Layout, { style: {
2065
+ display: 'flex',
2066
+ justifyContent: 'flex-start',
2067
+ alignItems: 'flex-start',
2068
+ flexDirection: 'column',
2069
+ borderRadius: 10,
2070
+ }, backgroundColor: "#748873", sideMenu: {
2071
+ menuItems: [
2072
+ {
2073
+ label: 'Home',
2074
+ route: '/',
2075
+ backgroundColor: '#E5E0D880',
2076
+ textColor: '#121212',
2077
+ activeColor: {
2078
+ background: '#E5E0D8',
2079
+ text: '#121212'
2080
+ },
2081
+ icon: {
2082
+ position: 'right',
2083
+ component: jsx("div", { style: {
2084
+ width: 24,
2085
+ height: 24,
2086
+ border: '1px solid #333333',
2087
+ marginInline: 10,
2088
+ borderRadius: 4
2089
+ } })
2090
+ }
2091
+ },
2092
+ {
2093
+ label: 'Setting',
2094
+ route: '/setting',
2095
+ backgroundColor: '#E5E0D880',
2096
+ textColor: '#121212',
2097
+ activeColor: {
2098
+ background: '#E5E0D8',
2099
+ text: '#121212'
2100
+ },
2101
+ icon: {
2102
+ position: 'right',
2103
+ component: jsx("div", { style: {
2104
+ width: 24,
2105
+ height: 24,
2106
+ border: '1px solid #333333',
2107
+ marginInline: 10,
2108
+ borderRadius: 4
2109
+ } })
2110
+ }
2111
+ }
2112
+ ],
2113
+ width: '20%',
2114
+ height: '100%',
2115
+ style: {
2116
+ display: 'flex',
2117
+ justifyContent: 'flex-start',
2118
+ alignItems: 'flex-start',
2119
+ borderRight: '1px solid #121212'
2120
+ },
2121
+ top: 80,
2122
+ ElementStyle: {
2123
+ height: 48,
2124
+ width: '90%',
2125
+ borderRadius: 8,
2126
+ display: 'flex',
2127
+ justifyContent: 'start',
2128
+ alignItems: 'center',
2129
+ gap: 8,
2130
+ cursor: 'pointer'
2131
+ },
2132
+ ElementType: 'a',
2133
+ menuItemsDynamicStyle: {
2134
+ backgroundColor: '#E5E0D880',
2135
+ textColor: '#121212',
2136
+ activeColor: {
2137
+ background: '#E5E0D8',
2138
+ text: '#121212'
2139
+ },
2140
+ }
2141
+ } })] });
22
2142
  }
23
2143
 
24
2144
  function Buttons(props) {
25
- const { onClick, width, height, label, paddingX, paddingY, backgroundColor, textColor, rounded, className } = props;
2145
+ const { onClick, width, height, label, paddingX, paddingY, backgroundColor, textColor, rounded, className, style } = props;
26
2146
  return jsx("button", { className: className, style: {
27
2147
  width: width ? `${width}px` : 'auto',
28
2148
  height: height ? `${height}px` : 'auto',
@@ -35,7 +2155,8 @@ function Buttons(props) {
35
2155
  borderBottomLeftRadius: typeof rounded === 'number' ? rounded : rounded?.bottomLeft ?? 4,
36
2156
  borderBottomRightRadius: typeof rounded === 'number' ? rounded : rounded?.bottomRight ?? 4,
37
2157
  cursor: 'pointer',
2158
+ ...style
38
2159
  }, onClick: onClick, children: label });
39
2160
  }
40
2161
 
41
- export { Buttons, ViewContainer };
2162
+ export { Buttons, FlexView };