strapi-plugin-hubspot 0.6.0 → 0.7.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 (33) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/_chunks/{Forms-CW1KFO9U.mjs → Forms-CKA6ukB6.mjs} +5 -4
  3. package/dist/_chunks/{Forms-BF4_zA-m.js → Forms-HMZbTk_B.js} +30 -29
  4. package/dist/_chunks/HubspotFormInput-BequMb12.js +79 -0
  5. package/dist/_chunks/HubspotFormInput-CKYRcNNU.mjs +61 -0
  6. package/dist/_chunks/{HubspotObjectInput-hjAYWtaU.js → HubspotObjectInput-D-FGwsyS.js} +8 -7
  7. package/dist/_chunks/{HubspotObjectInput-CpxeM2J0.mjs → HubspotObjectInput-V3uhGK8k.mjs} +4 -3
  8. package/dist/_chunks/{HubspotPropertyInput-OSeIBaRC.js → HubspotPropertyInput-Dn1QvOcu.js} +18 -17
  9. package/dist/_chunks/{HubspotPropertyInput-C-52Lu24.mjs → HubspotPropertyInput-DrBsx9jQ.mjs} +4 -3
  10. package/dist/_chunks/{Settings-2V7TH5CX.mjs → Settings-BjkNbyna.mjs} +4 -3
  11. package/dist/_chunks/{Settings-DcA9M5Tw.js → Settings-Cgp7M1Cv.js} +8 -7
  12. package/dist/_chunks/{en-CJ9wYHgN.mjs → en-Cun5LoUP.mjs} +8 -1
  13. package/dist/_chunks/{en-C_-N8cjv.js → en-D5Ch9YFo.js} +8 -1
  14. package/dist/_chunks/{fr-DttDn-2Y.mjs → fr-ClOWflse.mjs} +8 -1
  15. package/dist/_chunks/{fr-BHObPoUp.js → fr-CqlhHltZ.js} +8 -1
  16. package/dist/_chunks/{objectLabels-D9UEuOGr.mjs → index-CEh8vkxY.mjs} +0 -14
  17. package/dist/_chunks/{index-CMzg-x5i.js → index-D2Q34BuH.js} +21 -5
  18. package/dist/_chunks/{objectLabels-Th7aYW-B.js → index-DkTxsEqL.js} +0 -14
  19. package/dist/_chunks/{index-DkGOTp8p.mjs → index-FKsiOEPB.mjs} +21 -5
  20. package/dist/_chunks/objectLabels-DBKevJle.mjs +16 -0
  21. package/dist/_chunks/objectLabels-LAQ0M6-a.js +15 -0
  22. package/dist/_chunks/{useHubspotSchema-DQkQcA_V.mjs → useHubspotSchema-BC0Od-Wl.mjs} +1 -1
  23. package/dist/_chunks/{useHubspotSchema-Bgrgg8Mt.js → useHubspotSchema-C08qBAyy.js} +1 -1
  24. package/dist/admin/index.js +1 -1
  25. package/dist/admin/index.mjs +1 -1
  26. package/dist/admin/src/components/HubspotFormInput.d.ts +29 -0
  27. package/dist/server/index.js +33 -0
  28. package/dist/server/index.mjs +33 -0
  29. package/dist/server/src/formsAdmin.d.ts +7 -0
  30. package/dist/server/src/index.d.ts +1 -0
  31. package/package.json +3 -2
  32. package/dist/_chunks/index-C1UJXE_o.mjs +0 -1552
  33. package/dist/_chunks/index-Dgbid2LK.js +0 -1569
@@ -1,1552 +0,0 @@
1
- import * as React from "react";
2
- import "react-dom";
3
- /**
4
- * @remix-run/router v1.23.3
5
- *
6
- * Copyright (c) Remix Software Inc.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE.md file in the root directory of this source tree.
10
- *
11
- * @license MIT
12
- */
13
- function _extends$2() {
14
- return _extends$2 = Object.assign ? Object.assign.bind() : function(n) {
15
- for (var e = 1; e < arguments.length; e++) {
16
- var t = arguments[e];
17
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
18
- }
19
- return n;
20
- }, _extends$2.apply(null, arguments);
21
- }
22
- var Action;
23
- (function(Action2) {
24
- Action2["Pop"] = "POP";
25
- Action2["Push"] = "PUSH";
26
- Action2["Replace"] = "REPLACE";
27
- })(Action || (Action = {}));
28
- function invariant(value, message) {
29
- if (value === false || value === null || typeof value === "undefined") {
30
- throw new Error(message);
31
- }
32
- }
33
- function warning(cond, message) {
34
- if (!cond) {
35
- if (typeof console !== "undefined") console.warn(message);
36
- try {
37
- throw new Error(message);
38
- } catch (e) {
39
- }
40
- }
41
- }
42
- function createPath(_ref) {
43
- let {
44
- pathname = "/",
45
- search = "",
46
- hash = ""
47
- } = _ref;
48
- if (search && search !== "?") pathname += search.charAt(0) === "?" ? search : "?" + search;
49
- if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
50
- return pathname;
51
- }
52
- function parsePath(path) {
53
- let parsedPath = {};
54
- if (path) {
55
- let hashIndex = path.indexOf("#");
56
- if (hashIndex >= 0) {
57
- parsedPath.hash = path.substr(hashIndex);
58
- path = path.substr(0, hashIndex);
59
- }
60
- let searchIndex = path.indexOf("?");
61
- if (searchIndex >= 0) {
62
- parsedPath.search = path.substr(searchIndex);
63
- path = path.substr(0, searchIndex);
64
- }
65
- if (path) {
66
- parsedPath.pathname = path;
67
- }
68
- }
69
- return parsedPath;
70
- }
71
- var ResultType;
72
- (function(ResultType2) {
73
- ResultType2["data"] = "data";
74
- ResultType2["deferred"] = "deferred";
75
- ResultType2["redirect"] = "redirect";
76
- ResultType2["error"] = "error";
77
- })(ResultType || (ResultType = {}));
78
- function matchRoutes(routes, locationArg, basename) {
79
- if (basename === void 0) {
80
- basename = "/";
81
- }
82
- return matchRoutesImpl(routes, locationArg, basename);
83
- }
84
- function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
85
- let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
86
- let pathname = stripBasename(location.pathname || "/", basename);
87
- if (pathname == null) {
88
- return null;
89
- }
90
- let branches = flattenRoutes(routes);
91
- rankRouteBranches(branches);
92
- let matches = null;
93
- let decoded = decodePath(pathname);
94
- for (let i = 0; matches == null && i < branches.length; ++i) {
95
- matches = matchRouteBranch(branches[i], decoded);
96
- }
97
- return matches;
98
- }
99
- function flattenRoutes(routes, branches, parentsMeta, parentPath) {
100
- if (branches === void 0) {
101
- branches = [];
102
- }
103
- if (parentsMeta === void 0) {
104
- parentsMeta = [];
105
- }
106
- if (parentPath === void 0) {
107
- parentPath = "";
108
- }
109
- let flattenRoute = (route, index, relativePath) => {
110
- let meta = {
111
- relativePath: relativePath === void 0 ? route.path || "" : relativePath,
112
- caseSensitive: route.caseSensitive === true,
113
- childrenIndex: index,
114
- route
115
- };
116
- if (meta.relativePath.startsWith("/")) {
117
- invariant(meta.relativePath.startsWith(parentPath), '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.");
118
- meta.relativePath = meta.relativePath.slice(parentPath.length);
119
- }
120
- let path = joinPaths([parentPath, meta.relativePath]);
121
- let routesMeta = parentsMeta.concat(meta);
122
- if (route.children && route.children.length > 0) {
123
- invariant(
124
- // Our types know better, but runtime JS may not!
125
- // @ts-expect-error
126
- route.index !== true,
127
- "Index routes must not have child routes. Please remove " + ('all child routes from route path "' + path + '".')
128
- );
129
- flattenRoutes(route.children, branches, routesMeta, path);
130
- }
131
- if (route.path == null && !route.index) {
132
- return;
133
- }
134
- branches.push({
135
- path,
136
- score: computeScore(path, route.index),
137
- routesMeta
138
- });
139
- };
140
- routes.forEach((route, index) => {
141
- var _route$path;
142
- if (route.path === "" || !((_route$path = route.path) != null && _route$path.includes("?"))) {
143
- flattenRoute(route, index);
144
- } else {
145
- for (let exploded of explodeOptionalSegments(route.path)) {
146
- flattenRoute(route, index, exploded);
147
- }
148
- }
149
- });
150
- return branches;
151
- }
152
- function explodeOptionalSegments(path) {
153
- let segments = path.split("/");
154
- if (segments.length === 0) return [];
155
- let [first, ...rest] = segments;
156
- let isOptional = first.endsWith("?");
157
- let required = first.replace(/\?$/, "");
158
- if (rest.length === 0) {
159
- return isOptional ? [required, ""] : [required];
160
- }
161
- let restExploded = explodeOptionalSegments(rest.join("/"));
162
- let result = [];
163
- result.push(...restExploded.map((subpath) => subpath === "" ? required : [required, subpath].join("/")));
164
- if (isOptional) {
165
- result.push(...restExploded);
166
- }
167
- return result.map((exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded);
168
- }
169
- function rankRouteBranches(branches) {
170
- branches.sort((a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(a.routesMeta.map((meta) => meta.childrenIndex), b.routesMeta.map((meta) => meta.childrenIndex)));
171
- }
172
- const paramRe = /^:[\w-]+$/;
173
- const dynamicSegmentValue = 3;
174
- const indexRouteValue = 2;
175
- const emptySegmentValue = 1;
176
- const staticSegmentValue = 10;
177
- const splatPenalty = -2;
178
- const isSplat = (s) => s === "*";
179
- function computeScore(path, index) {
180
- let segments = path.split("/");
181
- let initialScore = segments.length;
182
- if (segments.some(isSplat)) {
183
- initialScore += splatPenalty;
184
- }
185
- if (index) {
186
- initialScore += indexRouteValue;
187
- }
188
- return segments.filter((s) => !isSplat(s)).reduce((score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue), initialScore);
189
- }
190
- function compareIndexes(a, b) {
191
- let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
192
- return siblings ? (
193
- // If two routes are siblings, we should try to match the earlier sibling
194
- // first. This allows people to have fine-grained control over the matching
195
- // behavior by simply putting routes with identical paths in the order they
196
- // want them tried.
197
- a[a.length - 1] - b[b.length - 1]
198
- ) : (
199
- // Otherwise, it doesn't really make sense to rank non-siblings by index,
200
- // so they sort equally.
201
- 0
202
- );
203
- }
204
- function matchRouteBranch(branch, pathname, allowPartial) {
205
- let {
206
- routesMeta
207
- } = branch;
208
- let matchedParams = {};
209
- let matchedPathname = "/";
210
- let matches = [];
211
- for (let i = 0; i < routesMeta.length; ++i) {
212
- let meta = routesMeta[i];
213
- let end = i === routesMeta.length - 1;
214
- let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
215
- let match = matchPath({
216
- path: meta.relativePath,
217
- caseSensitive: meta.caseSensitive,
218
- end
219
- }, remainingPathname);
220
- let route = meta.route;
221
- if (!match) {
222
- return null;
223
- }
224
- Object.assign(matchedParams, match.params);
225
- matches.push({
226
- // TODO: Can this as be avoided?
227
- params: matchedParams,
228
- pathname: joinPaths([matchedPathname, match.pathname]),
229
- pathnameBase: normalizePathname(joinPaths([matchedPathname, match.pathnameBase])),
230
- route
231
- });
232
- if (match.pathnameBase !== "/") {
233
- matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
234
- }
235
- }
236
- return matches;
237
- }
238
- function matchPath(pattern, pathname) {
239
- if (typeof pattern === "string") {
240
- pattern = {
241
- path: pattern,
242
- caseSensitive: false,
243
- end: true
244
- };
245
- }
246
- let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end);
247
- let match = pathname.match(matcher);
248
- if (!match) return null;
249
- let matchedPathname = match[0];
250
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
251
- let captureGroups = match.slice(1);
252
- let params = compiledParams.reduce((memo, _ref, index) => {
253
- let {
254
- paramName,
255
- isOptional
256
- } = _ref;
257
- if (paramName === "*") {
258
- let splatValue = captureGroups[index] || "";
259
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
260
- }
261
- const value = captureGroups[index];
262
- if (isOptional && !value) {
263
- memo[paramName] = void 0;
264
- } else {
265
- memo[paramName] = (value || "").replace(/%2F/g, "/");
266
- }
267
- return memo;
268
- }, {});
269
- return {
270
- params,
271
- pathname: matchedPathname,
272
- pathnameBase,
273
- pattern
274
- };
275
- }
276
- function compilePath(path, caseSensitive, end) {
277
- if (caseSensitive === void 0) {
278
- caseSensitive = false;
279
- }
280
- if (end === void 0) {
281
- end = true;
282
- }
283
- warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), '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(/\*$/, "/*") + '".'));
284
- let params = [];
285
- let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (_, paramName, isOptional) => {
286
- params.push({
287
- paramName,
288
- isOptional: isOptional != null
289
- });
290
- return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
291
- });
292
- if (path.endsWith("*")) {
293
- params.push({
294
- paramName: "*"
295
- });
296
- regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
297
- } else if (end) {
298
- regexpSource += "\\/*$";
299
- } else if (path !== "" && path !== "/") {
300
- regexpSource += "(?:(?=\\/|$))";
301
- } else ;
302
- let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
303
- return [matcher, params];
304
- }
305
- function decodePath(value) {
306
- try {
307
- return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
308
- } catch (error) {
309
- warning(false, 'The URL path "' + value + '" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent ' + ("encoding (" + error + ")."));
310
- return value;
311
- }
312
- }
313
- function stripBasename(pathname, basename) {
314
- if (basename === "/") return pathname;
315
- if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
316
- return null;
317
- }
318
- let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
319
- let nextChar = pathname.charAt(startIndex);
320
- if (nextChar && nextChar !== "/") {
321
- return null;
322
- }
323
- return pathname.slice(startIndex) || "/";
324
- }
325
- const ABSOLUTE_URL_REGEX$1 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
326
- const isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX$1.test(url);
327
- function resolvePath(to, fromPathname) {
328
- if (fromPathname === void 0) {
329
- fromPathname = "/";
330
- }
331
- let {
332
- pathname: toPathname,
333
- search = "",
334
- hash = ""
335
- } = typeof to === "string" ? parsePath(to) : to;
336
- let pathname;
337
- if (toPathname) {
338
- if (isAbsoluteUrl(toPathname)) {
339
- pathname = toPathname;
340
- } else {
341
- if (toPathname.includes("//")) {
342
- let oldPathname = toPathname;
343
- toPathname = removeDoubleSlashes(toPathname);
344
- warning(false, "Pathnames cannot have embedded double slashes - normalizing " + (oldPathname + " -> " + toPathname));
345
- }
346
- if (toPathname.startsWith("/")) {
347
- pathname = resolvePathname(toPathname.substring(1), "/");
348
- } else {
349
- pathname = resolvePathname(toPathname, fromPathname);
350
- }
351
- }
352
- } else {
353
- pathname = fromPathname;
354
- }
355
- return {
356
- pathname,
357
- search: normalizeSearch(search),
358
- hash: normalizeHash(hash)
359
- };
360
- }
361
- function resolvePathname(relativePath, fromPathname) {
362
- let segments = fromPathname.replace(/\/+$/, "").split("/");
363
- let relativeSegments = relativePath.split("/");
364
- relativeSegments.forEach((segment) => {
365
- if (segment === "..") {
366
- if (segments.length > 1) segments.pop();
367
- } else if (segment !== ".") {
368
- segments.push(segment);
369
- }
370
- });
371
- return segments.length > 1 ? segments.join("/") : "/";
372
- }
373
- function getInvalidPathError(char, field, dest, path) {
374
- return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path) + "]. 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.';
375
- }
376
- function getPathContributingMatches(matches) {
377
- return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0);
378
- }
379
- function getResolveToMatches(matches, v7_relativeSplatPath) {
380
- let pathMatches = getPathContributingMatches(matches);
381
- if (v7_relativeSplatPath) {
382
- return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
383
- }
384
- return pathMatches.map((match) => match.pathnameBase);
385
- }
386
- function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) {
387
- if (isPathRelative === void 0) {
388
- isPathRelative = false;
389
- }
390
- let to;
391
- if (typeof toArg === "string") {
392
- to = parsePath(toArg);
393
- } else {
394
- to = _extends$2({}, toArg);
395
- invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
396
- invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
397
- invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
398
- }
399
- let isEmptyPath = toArg === "" || to.pathname === "";
400
- let toPathname = isEmptyPath ? "/" : to.pathname;
401
- let from;
402
- if (toPathname == null) {
403
- from = locationPathname;
404
- } else {
405
- let routePathnameIndex = routePathnames.length - 1;
406
- if (!isPathRelative && toPathname.startsWith("..")) {
407
- let toSegments = toPathname.split("/");
408
- while (toSegments[0] === "..") {
409
- toSegments.shift();
410
- routePathnameIndex -= 1;
411
- }
412
- to.pathname = toSegments.join("/");
413
- }
414
- from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
415
- }
416
- let path = resolvePath(to, from);
417
- let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
418
- let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
419
- if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
420
- path.pathname += "/";
421
- }
422
- return path;
423
- }
424
- const removeDoubleSlashes = (path) => path.replace(/\/\/+/g, "/");
425
- const joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
426
- const normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
427
- const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
428
- const normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
429
- function isRouteErrorResponse(error) {
430
- return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
431
- }
432
- const validMutationMethodsArr = ["post", "put", "patch", "delete"];
433
- new Set(validMutationMethodsArr);
434
- const validRequestMethodsArr = ["get", ...validMutationMethodsArr];
435
- new Set(validRequestMethodsArr);
436
- /**
437
- * React Router v6.30.4
438
- *
439
- * Copyright (c) Remix Software Inc.
440
- *
441
- * This source code is licensed under the MIT license found in the
442
- * LICENSE.md file in the root directory of this source tree.
443
- *
444
- * @license MIT
445
- */
446
- function _extends$1() {
447
- return _extends$1 = Object.assign ? Object.assign.bind() : function(n) {
448
- for (var e = 1; e < arguments.length; e++) {
449
- var t = arguments[e];
450
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
451
- }
452
- return n;
453
- }, _extends$1.apply(null, arguments);
454
- }
455
- const DataRouterContext = /* @__PURE__ */ React.createContext(null);
456
- if (process.env.NODE_ENV !== "production") {
457
- DataRouterContext.displayName = "DataRouter";
458
- }
459
- const DataRouterStateContext = /* @__PURE__ */ React.createContext(null);
460
- if (process.env.NODE_ENV !== "production") {
461
- DataRouterStateContext.displayName = "DataRouterState";
462
- }
463
- const AwaitContext = /* @__PURE__ */ React.createContext(null);
464
- if (process.env.NODE_ENV !== "production") {
465
- AwaitContext.displayName = "Await";
466
- }
467
- const NavigationContext = /* @__PURE__ */ React.createContext(null);
468
- if (process.env.NODE_ENV !== "production") {
469
- NavigationContext.displayName = "Navigation";
470
- }
471
- const LocationContext = /* @__PURE__ */ React.createContext(null);
472
- if (process.env.NODE_ENV !== "production") {
473
- LocationContext.displayName = "Location";
474
- }
475
- const RouteContext = /* @__PURE__ */ React.createContext({
476
- outlet: null,
477
- matches: [],
478
- isDataRoute: false
479
- });
480
- if (process.env.NODE_ENV !== "production") {
481
- RouteContext.displayName = "Route";
482
- }
483
- const RouteErrorContext = /* @__PURE__ */ React.createContext(null);
484
- if (process.env.NODE_ENV !== "production") {
485
- RouteErrorContext.displayName = "RouteError";
486
- }
487
- function useHref(to, _temp) {
488
- let {
489
- relative
490
- } = _temp === void 0 ? {} : _temp;
491
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
492
- false,
493
- // TODO: This error is probably because they somehow have 2 versions of the
494
- // router loaded. We can help them understand how to avoid that.
495
- "useHref() may be used only in the context of a <Router> component."
496
- ) : invariant(false) : void 0;
497
- let {
498
- basename,
499
- navigator
500
- } = React.useContext(NavigationContext);
501
- let {
502
- hash,
503
- pathname,
504
- search
505
- } = useResolvedPath(to, {
506
- relative
507
- });
508
- let joinedPathname = pathname;
509
- if (basename !== "/") {
510
- joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
511
- }
512
- return navigator.createHref({
513
- pathname: joinedPathname,
514
- search,
515
- hash
516
- });
517
- }
518
- function useInRouterContext() {
519
- return React.useContext(LocationContext) != null;
520
- }
521
- function useLocation() {
522
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
523
- false,
524
- // TODO: This error is probably because they somehow have 2 versions of the
525
- // router loaded. We can help them understand how to avoid that.
526
- "useLocation() may be used only in the context of a <Router> component."
527
- ) : invariant(false) : void 0;
528
- return React.useContext(LocationContext).location;
529
- }
530
- const navigateEffectWarning = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
531
- function useIsomorphicLayoutEffect(cb) {
532
- let isStatic = React.useContext(NavigationContext).static;
533
- if (!isStatic) {
534
- React.useLayoutEffect(cb);
535
- }
536
- }
537
- function useNavigate() {
538
- let {
539
- isDataRoute
540
- } = React.useContext(RouteContext);
541
- return isDataRoute ? useNavigateStable() : useNavigateUnstable();
542
- }
543
- function useNavigateUnstable() {
544
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
545
- false,
546
- // TODO: This error is probably because they somehow have 2 versions of the
547
- // router loaded. We can help them understand how to avoid that.
548
- "useNavigate() may be used only in the context of a <Router> component."
549
- ) : invariant(false) : void 0;
550
- let dataRouterContext = React.useContext(DataRouterContext);
551
- let {
552
- basename,
553
- future,
554
- navigator
555
- } = React.useContext(NavigationContext);
556
- let {
557
- matches
558
- } = React.useContext(RouteContext);
559
- let {
560
- pathname: locationPathname
561
- } = useLocation();
562
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
563
- let activeRef = React.useRef(false);
564
- useIsomorphicLayoutEffect(() => {
565
- activeRef.current = true;
566
- });
567
- let navigate = React.useCallback(function(to, options) {
568
- if (options === void 0) {
569
- options = {};
570
- }
571
- process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
572
- if (!activeRef.current) return;
573
- if (typeof to === "number") {
574
- navigator.go(to);
575
- return;
576
- }
577
- let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
578
- if (dataRouterContext == null && basename !== "/") {
579
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
580
- }
581
- (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
582
- }, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
583
- return navigate;
584
- }
585
- function useParams() {
586
- let {
587
- matches
588
- } = React.useContext(RouteContext);
589
- let routeMatch = matches[matches.length - 1];
590
- return routeMatch ? routeMatch.params : {};
591
- }
592
- function useResolvedPath(to, _temp2) {
593
- let {
594
- relative
595
- } = _temp2 === void 0 ? {} : _temp2;
596
- let {
597
- future
598
- } = React.useContext(NavigationContext);
599
- let {
600
- matches
601
- } = React.useContext(RouteContext);
602
- let {
603
- pathname: locationPathname
604
- } = useLocation();
605
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
606
- return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
607
- }
608
- function useRoutes(routes, locationArg) {
609
- return useRoutesImpl(routes, locationArg);
610
- }
611
- function useRoutesImpl(routes, locationArg, dataRouterState, future) {
612
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
613
- false,
614
- // TODO: This error is probably because they somehow have 2 versions of the
615
- // router loaded. We can help them understand how to avoid that.
616
- "useRoutes() may be used only in the context of a <Router> component."
617
- ) : invariant(false) : void 0;
618
- let {
619
- navigator
620
- } = React.useContext(NavigationContext);
621
- let {
622
- matches: parentMatches
623
- } = React.useContext(RouteContext);
624
- let routeMatch = parentMatches[parentMatches.length - 1];
625
- let parentParams = routeMatch ? routeMatch.params : {};
626
- let parentPathname = routeMatch ? routeMatch.pathname : "/";
627
- let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
628
- let parentRoute = routeMatch && routeMatch.route;
629
- if (process.env.NODE_ENV !== "production") {
630
- let parentPath = parentRoute && parentRoute.path || "";
631
- warningOnce(parentPathname, !parentRoute || parentPath.endsWith("*"), "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.
632
-
633
- ` + ('Please change the parent <Route path="' + parentPath + '"> to <Route ') + ('path="' + (parentPath === "/" ? "*" : parentPath + "/*") + '">.'));
634
- }
635
- let locationFromContext = useLocation();
636
- let location;
637
- if (locationArg) {
638
- var _parsedLocationArg$pa;
639
- let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
640
- !(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? process.env.NODE_ENV !== "production" ? invariant(false, "When overriding the location using `<Routes location>` or `useRoutes(routes, location)`, the location pathname must begin with the portion of the URL pathname that was " + ('matched by all parent routes. The current pathname base is "' + parentPathnameBase + '" ') + ('but pathname "' + parsedLocationArg.pathname + '" was given in the `location` prop.')) : invariant(false) : void 0;
641
- location = parsedLocationArg;
642
- } else {
643
- location = locationFromContext;
644
- }
645
- let pathname = location.pathname || "/";
646
- let remainingPathname = pathname;
647
- if (parentPathnameBase !== "/") {
648
- let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
649
- let segments = pathname.replace(/^\//, "").split("/");
650
- remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
651
- }
652
- let matches = matchRoutes(routes, {
653
- pathname: remainingPathname
654
- });
655
- if (process.env.NODE_ENV !== "production") {
656
- process.env.NODE_ENV !== "production" ? warning(parentRoute || matches != null, 'No routes matched location "' + location.pathname + location.search + location.hash + '" ') : void 0;
657
- process.env.NODE_ENV !== "production" ? warning(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, '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.') : void 0;
658
- }
659
- let renderedMatches = _renderMatches(matches && matches.map((match) => Object.assign({}, match, {
660
- params: Object.assign({}, parentParams, match.params),
661
- pathname: joinPaths([
662
- parentPathnameBase,
663
- // Re-encode pathnames that were decoded inside matchRoutes
664
- navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname
665
- ]),
666
- pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
667
- parentPathnameBase,
668
- // Re-encode pathnames that were decoded inside matchRoutes
669
- navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
670
- ])
671
- })), parentMatches, dataRouterState, future);
672
- if (locationArg && renderedMatches) {
673
- return /* @__PURE__ */ React.createElement(LocationContext.Provider, {
674
- value: {
675
- location: _extends$1({
676
- pathname: "/",
677
- search: "",
678
- hash: "",
679
- state: null,
680
- key: "default"
681
- }, location),
682
- navigationType: Action.Pop
683
- }
684
- }, renderedMatches);
685
- }
686
- return renderedMatches;
687
- }
688
- function DefaultErrorComponent() {
689
- let error = useRouteError();
690
- let message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error);
691
- let stack = error instanceof Error ? error.stack : null;
692
- let lightgrey = "rgba(200,200,200, 0.5)";
693
- let preStyles = {
694
- padding: "0.5rem",
695
- backgroundColor: lightgrey
696
- };
697
- let codeStyles = {
698
- padding: "2px 4px",
699
- backgroundColor: lightgrey
700
- };
701
- let devInfo = null;
702
- if (process.env.NODE_ENV !== "production") {
703
- console.error("Error handled by React Router default ErrorBoundary:", error);
704
- devInfo = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React.createElement("code", {
705
- style: codeStyles
706
- }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React.createElement("code", {
707
- style: codeStyles
708
- }, "errorElement"), " prop on your route."));
709
- }
710
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React.createElement("h3", {
711
- style: {
712
- fontStyle: "italic"
713
- }
714
- }, message), stack ? /* @__PURE__ */ React.createElement("pre", {
715
- style: preStyles
716
- }, stack) : null, devInfo);
717
- }
718
- const defaultErrorElement = /* @__PURE__ */ React.createElement(DefaultErrorComponent, null);
719
- class RenderErrorBoundary extends React.Component {
720
- constructor(props) {
721
- super(props);
722
- this.state = {
723
- location: props.location,
724
- revalidation: props.revalidation,
725
- error: props.error
726
- };
727
- }
728
- static getDerivedStateFromError(error) {
729
- return {
730
- error
731
- };
732
- }
733
- static getDerivedStateFromProps(props, state) {
734
- if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
735
- return {
736
- error: props.error,
737
- location: props.location,
738
- revalidation: props.revalidation
739
- };
740
- }
741
- return {
742
- error: props.error !== void 0 ? props.error : state.error,
743
- location: state.location,
744
- revalidation: props.revalidation || state.revalidation
745
- };
746
- }
747
- componentDidCatch(error, errorInfo) {
748
- console.error("React Router caught the following error during render", error, errorInfo);
749
- }
750
- render() {
751
- return this.state.error !== void 0 ? /* @__PURE__ */ React.createElement(RouteContext.Provider, {
752
- value: this.props.routeContext
753
- }, /* @__PURE__ */ React.createElement(RouteErrorContext.Provider, {
754
- value: this.state.error,
755
- children: this.props.component
756
- })) : this.props.children;
757
- }
758
- }
759
- function RenderedRoute(_ref) {
760
- let {
761
- routeContext,
762
- match,
763
- children
764
- } = _ref;
765
- let dataRouterContext = React.useContext(DataRouterContext);
766
- if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
767
- dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
768
- }
769
- return /* @__PURE__ */ React.createElement(RouteContext.Provider, {
770
- value: routeContext
771
- }, children);
772
- }
773
- function _renderMatches(matches, parentMatches, dataRouterState, future) {
774
- var _dataRouterState;
775
- if (parentMatches === void 0) {
776
- parentMatches = [];
777
- }
778
- if (dataRouterState === void 0) {
779
- dataRouterState = null;
780
- }
781
- if (future === void 0) {
782
- future = null;
783
- }
784
- if (matches == null) {
785
- var _future;
786
- if (!dataRouterState) {
787
- return null;
788
- }
789
- if (dataRouterState.errors) {
790
- matches = dataRouterState.matches;
791
- } else if ((_future = future) != null && _future.v7_partialHydration && parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
792
- matches = dataRouterState.matches;
793
- } else {
794
- return null;
795
- }
796
- }
797
- let renderedMatches = matches;
798
- let errors = (_dataRouterState = dataRouterState) == null ? void 0 : _dataRouterState.errors;
799
- if (errors != null) {
800
- let errorIndex = renderedMatches.findIndex((m) => m.route.id && (errors == null ? void 0 : errors[m.route.id]) !== void 0);
801
- !(errorIndex >= 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not find a matching route for errors on route IDs: " + Object.keys(errors).join(",")) : invariant(false) : void 0;
802
- renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
803
- }
804
- let renderFallback = false;
805
- let fallbackIndex = -1;
806
- if (dataRouterState && future && future.v7_partialHydration) {
807
- for (let i = 0; i < renderedMatches.length; i++) {
808
- let match = renderedMatches[i];
809
- if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
810
- fallbackIndex = i;
811
- }
812
- if (match.route.id) {
813
- let {
814
- loaderData,
815
- errors: errors2
816
- } = dataRouterState;
817
- let needsToRunLoader = match.route.loader && loaderData[match.route.id] === void 0 && (!errors2 || errors2[match.route.id] === void 0);
818
- if (match.route.lazy || needsToRunLoader) {
819
- renderFallback = true;
820
- if (fallbackIndex >= 0) {
821
- renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
822
- } else {
823
- renderedMatches = [renderedMatches[0]];
824
- }
825
- break;
826
- }
827
- }
828
- }
829
- }
830
- return renderedMatches.reduceRight((outlet, match, index) => {
831
- let error;
832
- let shouldRenderHydrateFallback = false;
833
- let errorElement = null;
834
- let hydrateFallbackElement = null;
835
- if (dataRouterState) {
836
- error = errors && match.route.id ? errors[match.route.id] : void 0;
837
- errorElement = match.route.errorElement || defaultErrorElement;
838
- if (renderFallback) {
839
- if (fallbackIndex < 0 && index === 0) {
840
- warningOnce("route-fallback", false, "No `HydrateFallback` element provided to render during initial hydration");
841
- shouldRenderHydrateFallback = true;
842
- hydrateFallbackElement = null;
843
- } else if (fallbackIndex === index) {
844
- shouldRenderHydrateFallback = true;
845
- hydrateFallbackElement = match.route.hydrateFallbackElement || null;
846
- }
847
- }
848
- }
849
- let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
850
- let getChildren = () => {
851
- let children;
852
- if (error) {
853
- children = errorElement;
854
- } else if (shouldRenderHydrateFallback) {
855
- children = hydrateFallbackElement;
856
- } else if (match.route.Component) {
857
- children = /* @__PURE__ */ React.createElement(match.route.Component, null);
858
- } else if (match.route.element) {
859
- children = match.route.element;
860
- } else {
861
- children = outlet;
862
- }
863
- return /* @__PURE__ */ React.createElement(RenderedRoute, {
864
- match,
865
- routeContext: {
866
- outlet,
867
- matches: matches2,
868
- isDataRoute: dataRouterState != null
869
- },
870
- children
871
- });
872
- };
873
- return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React.createElement(RenderErrorBoundary, {
874
- location: dataRouterState.location,
875
- revalidation: dataRouterState.revalidation,
876
- component: errorElement,
877
- error,
878
- children: getChildren(),
879
- routeContext: {
880
- outlet: null,
881
- matches: matches2,
882
- isDataRoute: true
883
- }
884
- }) : getChildren();
885
- }, null);
886
- }
887
- var DataRouterHook$1 = /* @__PURE__ */ function(DataRouterHook2) {
888
- DataRouterHook2["UseBlocker"] = "useBlocker";
889
- DataRouterHook2["UseRevalidator"] = "useRevalidator";
890
- DataRouterHook2["UseNavigateStable"] = "useNavigate";
891
- return DataRouterHook2;
892
- }(DataRouterHook$1 || {});
893
- var DataRouterStateHook$1 = /* @__PURE__ */ function(DataRouterStateHook2) {
894
- DataRouterStateHook2["UseBlocker"] = "useBlocker";
895
- DataRouterStateHook2["UseLoaderData"] = "useLoaderData";
896
- DataRouterStateHook2["UseActionData"] = "useActionData";
897
- DataRouterStateHook2["UseRouteError"] = "useRouteError";
898
- DataRouterStateHook2["UseNavigation"] = "useNavigation";
899
- DataRouterStateHook2["UseRouteLoaderData"] = "useRouteLoaderData";
900
- DataRouterStateHook2["UseMatches"] = "useMatches";
901
- DataRouterStateHook2["UseRevalidator"] = "useRevalidator";
902
- DataRouterStateHook2["UseNavigateStable"] = "useNavigate";
903
- DataRouterStateHook2["UseRouteId"] = "useRouteId";
904
- return DataRouterStateHook2;
905
- }(DataRouterStateHook$1 || {});
906
- function getDataRouterConsoleError$1(hookName) {
907
- return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
908
- }
909
- function useDataRouterContext$1(hookName) {
910
- let ctx = React.useContext(DataRouterContext);
911
- !ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
912
- return ctx;
913
- }
914
- function useDataRouterState(hookName) {
915
- let state = React.useContext(DataRouterStateContext);
916
- !state ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
917
- return state;
918
- }
919
- function useRouteContext(hookName) {
920
- let route = React.useContext(RouteContext);
921
- !route ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
922
- return route;
923
- }
924
- function useCurrentRouteId(hookName) {
925
- let route = useRouteContext(hookName);
926
- let thisRoute = route.matches[route.matches.length - 1];
927
- !thisRoute.route.id ? process.env.NODE_ENV !== "production" ? invariant(false, hookName + ' can only be used on routes that contain a unique "id"') : invariant(false) : void 0;
928
- return thisRoute.route.id;
929
- }
930
- function useRouteId() {
931
- return useCurrentRouteId(DataRouterStateHook$1.UseRouteId);
932
- }
933
- function useRouteError() {
934
- var _state$errors;
935
- let error = React.useContext(RouteErrorContext);
936
- let state = useDataRouterState(DataRouterStateHook$1.UseRouteError);
937
- let routeId = useCurrentRouteId(DataRouterStateHook$1.UseRouteError);
938
- if (error !== void 0) {
939
- return error;
940
- }
941
- return (_state$errors = state.errors) == null ? void 0 : _state$errors[routeId];
942
- }
943
- function useNavigateStable() {
944
- let {
945
- router
946
- } = useDataRouterContext$1(DataRouterHook$1.UseNavigateStable);
947
- let id = useCurrentRouteId(DataRouterStateHook$1.UseNavigateStable);
948
- let activeRef = React.useRef(false);
949
- useIsomorphicLayoutEffect(() => {
950
- activeRef.current = true;
951
- });
952
- let navigate = React.useCallback(function(to, options) {
953
- if (options === void 0) {
954
- options = {};
955
- }
956
- process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
957
- if (!activeRef.current) return;
958
- if (typeof to === "number") {
959
- router.navigate(to);
960
- } else {
961
- router.navigate(to, _extends$1({
962
- fromRouteId: id
963
- }, options));
964
- }
965
- }, [router, id]);
966
- return navigate;
967
- }
968
- const alreadyWarned$1 = {};
969
- function warningOnce(key, cond, message) {
970
- if (!cond && !alreadyWarned$1[key]) {
971
- alreadyWarned$1[key] = true;
972
- process.env.NODE_ENV !== "production" ? warning(false, message) : void 0;
973
- }
974
- }
975
- function Route(_props) {
976
- process.env.NODE_ENV !== "production" ? invariant(false, "A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.") : invariant(false);
977
- }
978
- function Routes(_ref6) {
979
- let {
980
- children,
981
- location
982
- } = _ref6;
983
- return useRoutes(createRoutesFromChildren(children), location);
984
- }
985
- new Promise(() => {
986
- });
987
- function createRoutesFromChildren(children, parentPath) {
988
- if (parentPath === void 0) {
989
- parentPath = [];
990
- }
991
- let routes = [];
992
- React.Children.forEach(children, (element, index) => {
993
- if (!/* @__PURE__ */ React.isValidElement(element)) {
994
- return;
995
- }
996
- let treePath = [...parentPath, index];
997
- if (element.type === React.Fragment) {
998
- routes.push.apply(routes, createRoutesFromChildren(element.props.children, treePath));
999
- return;
1000
- }
1001
- !(element.type === Route) ? process.env.NODE_ENV !== "production" ? invariant(false, "[" + (typeof element.type === "string" ? element.type : element.type.name) + "] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>") : invariant(false) : void 0;
1002
- !(!element.props.index || !element.props.children) ? process.env.NODE_ENV !== "production" ? invariant(false, "An index route cannot have child routes.") : invariant(false) : void 0;
1003
- let route = {
1004
- id: element.props.id || treePath.join("-"),
1005
- caseSensitive: element.props.caseSensitive,
1006
- element: element.props.element,
1007
- Component: element.props.Component,
1008
- index: element.props.index,
1009
- path: element.props.path,
1010
- loader: element.props.loader,
1011
- action: element.props.action,
1012
- errorElement: element.props.errorElement,
1013
- ErrorBoundary: element.props.ErrorBoundary,
1014
- hasErrorBoundary: element.props.ErrorBoundary != null || element.props.errorElement != null,
1015
- shouldRevalidate: element.props.shouldRevalidate,
1016
- handle: element.props.handle,
1017
- lazy: element.props.lazy
1018
- };
1019
- if (element.props.children) {
1020
- route.children = createRoutesFromChildren(element.props.children, treePath);
1021
- }
1022
- routes.push(route);
1023
- });
1024
- return routes;
1025
- }
1026
- /**
1027
- * React Router DOM v6.30.4
1028
- *
1029
- * Copyright (c) Remix Software Inc.
1030
- *
1031
- * This source code is licensed under the MIT license found in the
1032
- * LICENSE.md file in the root directory of this source tree.
1033
- *
1034
- * @license MIT
1035
- */
1036
- function _extends() {
1037
- return _extends = Object.assign ? Object.assign.bind() : function(n) {
1038
- for (var e = 1; e < arguments.length; e++) {
1039
- var t = arguments[e];
1040
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
1041
- }
1042
- return n;
1043
- }, _extends.apply(null, arguments);
1044
- }
1045
- function _objectWithoutPropertiesLoose(r, e) {
1046
- if (null == r) return {};
1047
- var t = {};
1048
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
1049
- if (-1 !== e.indexOf(n)) continue;
1050
- t[n] = r[n];
1051
- }
1052
- return t;
1053
- }
1054
- const defaultMethod = "get";
1055
- const defaultEncType = "application/x-www-form-urlencoded";
1056
- function isHtmlElement(object) {
1057
- return object != null && typeof object.tagName === "string";
1058
- }
1059
- function isButtonElement(object) {
1060
- return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
1061
- }
1062
- function isFormElement(object) {
1063
- return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
1064
- }
1065
- function isInputElement(object) {
1066
- return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
1067
- }
1068
- function isModifiedEvent(event) {
1069
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
1070
- }
1071
- function shouldProcessLinkClick(event, target) {
1072
- return event.button === 0 && // Ignore everything but left clicks
1073
- (!target || target === "_self") && // Let browser handle "target=_blank" etc.
1074
- !isModifiedEvent(event);
1075
- }
1076
- function createSearchParams(init) {
1077
- if (init === void 0) {
1078
- init = "";
1079
- }
1080
- return new URLSearchParams(typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
1081
- let value = init[key];
1082
- return memo.concat(Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]);
1083
- }, []));
1084
- }
1085
- function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
1086
- let searchParams = createSearchParams(locationSearch);
1087
- if (defaultSearchParams) {
1088
- defaultSearchParams.forEach((_, key) => {
1089
- if (!searchParams.has(key)) {
1090
- defaultSearchParams.getAll(key).forEach((value) => {
1091
- searchParams.append(key, value);
1092
- });
1093
- }
1094
- });
1095
- }
1096
- return searchParams;
1097
- }
1098
- let _formDataSupportsSubmitter = null;
1099
- function isFormDataSubmitterSupported() {
1100
- if (_formDataSupportsSubmitter === null) {
1101
- try {
1102
- new FormData(
1103
- document.createElement("form"),
1104
- // @ts-expect-error if FormData supports the submitter parameter, this will throw
1105
- 0
1106
- );
1107
- _formDataSupportsSubmitter = false;
1108
- } catch (e) {
1109
- _formDataSupportsSubmitter = true;
1110
- }
1111
- }
1112
- return _formDataSupportsSubmitter;
1113
- }
1114
- const supportedFormEncTypes = /* @__PURE__ */ new Set(["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]);
1115
- function getFormEncType(encType) {
1116
- if (encType != null && !supportedFormEncTypes.has(encType)) {
1117
- process.env.NODE_ENV !== "production" ? warning(false, '"' + encType + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + defaultEncType + '"')) : void 0;
1118
- return null;
1119
- }
1120
- return encType;
1121
- }
1122
- function getFormSubmissionInfo(target, basename) {
1123
- let method;
1124
- let action;
1125
- let encType;
1126
- let formData;
1127
- let body;
1128
- if (isFormElement(target)) {
1129
- let attr = target.getAttribute("action");
1130
- action = attr ? stripBasename(attr, basename) : null;
1131
- method = target.getAttribute("method") || defaultMethod;
1132
- encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
1133
- formData = new FormData(target);
1134
- } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
1135
- let form = target.form;
1136
- if (form == null) {
1137
- throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');
1138
- }
1139
- let attr = target.getAttribute("formaction") || form.getAttribute("action");
1140
- action = attr ? stripBasename(attr, basename) : null;
1141
- method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
1142
- encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
1143
- formData = new FormData(form, target);
1144
- if (!isFormDataSubmitterSupported()) {
1145
- let {
1146
- name,
1147
- type,
1148
- value
1149
- } = target;
1150
- if (type === "image") {
1151
- let prefix = name ? name + "." : "";
1152
- formData.append(prefix + "x", "0");
1153
- formData.append(prefix + "y", "0");
1154
- } else if (name) {
1155
- formData.append(name, value);
1156
- }
1157
- }
1158
- } else if (isHtmlElement(target)) {
1159
- throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');
1160
- } else {
1161
- method = defaultMethod;
1162
- action = null;
1163
- encType = defaultEncType;
1164
- body = target;
1165
- }
1166
- if (formData && encType === "text/plain") {
1167
- body = formData;
1168
- formData = void 0;
1169
- }
1170
- return {
1171
- action,
1172
- method: method.toLowerCase(),
1173
- encType,
1174
- formData,
1175
- body
1176
- };
1177
- }
1178
- const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "viewTransition"], _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "viewTransition", "children"], _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "viewTransition"];
1179
- const REACT_ROUTER_VERSION = "6";
1180
- try {
1181
- window.__reactRouterVersion = REACT_ROUTER_VERSION;
1182
- } catch (e) {
1183
- }
1184
- const ViewTransitionContext = /* @__PURE__ */ React.createContext({
1185
- isTransitioning: false
1186
- });
1187
- if (process.env.NODE_ENV !== "production") {
1188
- ViewTransitionContext.displayName = "ViewTransition";
1189
- }
1190
- const FetchersContext = /* @__PURE__ */ React.createContext(/* @__PURE__ */ new Map());
1191
- if (process.env.NODE_ENV !== "production") {
1192
- FetchersContext.displayName = "Fetchers";
1193
- }
1194
- if (process.env.NODE_ENV !== "production") ;
1195
- const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
1196
- const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1197
- const Link = /* @__PURE__ */ React.forwardRef(function LinkWithRef(_ref7, ref) {
1198
- let {
1199
- onClick,
1200
- relative,
1201
- reloadDocument,
1202
- replace,
1203
- state,
1204
- target,
1205
- to,
1206
- preventScrollReset,
1207
- viewTransition
1208
- } = _ref7, rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
1209
- let {
1210
- basename
1211
- } = React.useContext(NavigationContext);
1212
- let absoluteHref;
1213
- let isExternal = false;
1214
- if (typeof to === "string" && ABSOLUTE_URL_REGEX.test(to)) {
1215
- absoluteHref = to;
1216
- if (isBrowser) {
1217
- try {
1218
- let currentUrl = new URL(window.location.href);
1219
- let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
1220
- let path = stripBasename(targetUrl.pathname, basename);
1221
- if (targetUrl.origin === currentUrl.origin && path != null) {
1222
- to = path + targetUrl.search + targetUrl.hash;
1223
- } else {
1224
- isExternal = true;
1225
- }
1226
- } catch (e) {
1227
- process.env.NODE_ENV !== "production" ? warning(false, '<Link to="' + to + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.') : void 0;
1228
- }
1229
- }
1230
- }
1231
- let href = useHref(to, {
1232
- relative
1233
- });
1234
- let internalOnClick = useLinkClickHandler(to, {
1235
- replace,
1236
- state,
1237
- target,
1238
- preventScrollReset,
1239
- relative,
1240
- viewTransition
1241
- });
1242
- function handleClick(event) {
1243
- if (onClick) onClick(event);
1244
- if (!event.defaultPrevented) {
1245
- internalOnClick(event);
1246
- }
1247
- }
1248
- return (
1249
- // eslint-disable-next-line jsx-a11y/anchor-has-content
1250
- /* @__PURE__ */ React.createElement("a", _extends({}, rest, {
1251
- href: absoluteHref || href,
1252
- onClick: isExternal || reloadDocument ? onClick : handleClick,
1253
- ref,
1254
- target
1255
- }))
1256
- );
1257
- });
1258
- if (process.env.NODE_ENV !== "production") {
1259
- Link.displayName = "Link";
1260
- }
1261
- const NavLink = /* @__PURE__ */ React.forwardRef(function NavLinkWithRef(_ref8, ref) {
1262
- let {
1263
- "aria-current": ariaCurrentProp = "page",
1264
- caseSensitive = false,
1265
- className: classNameProp = "",
1266
- end = false,
1267
- style: styleProp,
1268
- to,
1269
- viewTransition,
1270
- children
1271
- } = _ref8, rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
1272
- let path = useResolvedPath(to, {
1273
- relative: rest.relative
1274
- });
1275
- let location = useLocation();
1276
- let routerState = React.useContext(DataRouterStateContext);
1277
- let {
1278
- navigator,
1279
- basename
1280
- } = React.useContext(NavigationContext);
1281
- let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
1282
- // eslint-disable-next-line react-hooks/rules-of-hooks
1283
- useViewTransitionState(path) && viewTransition === true;
1284
- let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
1285
- let locationPathname = location.pathname;
1286
- let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
1287
- if (!caseSensitive) {
1288
- locationPathname = locationPathname.toLowerCase();
1289
- nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
1290
- toPathname = toPathname.toLowerCase();
1291
- }
1292
- if (nextLocationPathname && basename) {
1293
- nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
1294
- }
1295
- const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
1296
- let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
1297
- let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
1298
- let renderProps = {
1299
- isActive,
1300
- isPending,
1301
- isTransitioning
1302
- };
1303
- let ariaCurrent = isActive ? ariaCurrentProp : void 0;
1304
- let className;
1305
- if (typeof classNameProp === "function") {
1306
- className = classNameProp(renderProps);
1307
- } else {
1308
- className = [classNameProp, isActive ? "active" : null, isPending ? "pending" : null, isTransitioning ? "transitioning" : null].filter(Boolean).join(" ");
1309
- }
1310
- let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
1311
- return /* @__PURE__ */ React.createElement(Link, _extends({}, rest, {
1312
- "aria-current": ariaCurrent,
1313
- className,
1314
- ref,
1315
- style,
1316
- to,
1317
- viewTransition
1318
- }), typeof children === "function" ? children(renderProps) : children);
1319
- });
1320
- if (process.env.NODE_ENV !== "production") {
1321
- NavLink.displayName = "NavLink";
1322
- }
1323
- const Form = /* @__PURE__ */ React.forwardRef((_ref9, forwardedRef) => {
1324
- let {
1325
- fetcherKey,
1326
- navigate,
1327
- reloadDocument,
1328
- replace,
1329
- state,
1330
- method = defaultMethod,
1331
- action,
1332
- onSubmit,
1333
- relative,
1334
- preventScrollReset,
1335
- viewTransition
1336
- } = _ref9, props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
1337
- let submit = useSubmit();
1338
- let formAction = useFormAction(action, {
1339
- relative
1340
- });
1341
- let formMethod = method.toLowerCase() === "get" ? "get" : "post";
1342
- let submitHandler = (event) => {
1343
- onSubmit && onSubmit(event);
1344
- if (event.defaultPrevented) return;
1345
- event.preventDefault();
1346
- let submitter = event.nativeEvent.submitter;
1347
- let submitMethod = (submitter == null ? void 0 : submitter.getAttribute("formmethod")) || method;
1348
- submit(submitter || event.currentTarget, {
1349
- fetcherKey,
1350
- method: submitMethod,
1351
- navigate,
1352
- replace,
1353
- state,
1354
- relative,
1355
- preventScrollReset,
1356
- viewTransition
1357
- });
1358
- };
1359
- return /* @__PURE__ */ React.createElement("form", _extends({
1360
- ref: forwardedRef,
1361
- method: formMethod,
1362
- action: formAction,
1363
- onSubmit: reloadDocument ? onSubmit : submitHandler
1364
- }, props));
1365
- });
1366
- if (process.env.NODE_ENV !== "production") {
1367
- Form.displayName = "Form";
1368
- }
1369
- if (process.env.NODE_ENV !== "production") ;
1370
- var DataRouterHook;
1371
- (function(DataRouterHook2) {
1372
- DataRouterHook2["UseScrollRestoration"] = "useScrollRestoration";
1373
- DataRouterHook2["UseSubmit"] = "useSubmit";
1374
- DataRouterHook2["UseSubmitFetcher"] = "useSubmitFetcher";
1375
- DataRouterHook2["UseFetcher"] = "useFetcher";
1376
- DataRouterHook2["useViewTransitionState"] = "useViewTransitionState";
1377
- })(DataRouterHook || (DataRouterHook = {}));
1378
- var DataRouterStateHook;
1379
- (function(DataRouterStateHook2) {
1380
- DataRouterStateHook2["UseFetcher"] = "useFetcher";
1381
- DataRouterStateHook2["UseFetchers"] = "useFetchers";
1382
- DataRouterStateHook2["UseScrollRestoration"] = "useScrollRestoration";
1383
- })(DataRouterStateHook || (DataRouterStateHook = {}));
1384
- function getDataRouterConsoleError(hookName) {
1385
- return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
1386
- }
1387
- function useDataRouterContext(hookName) {
1388
- let ctx = React.useContext(DataRouterContext);
1389
- !ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
1390
- return ctx;
1391
- }
1392
- function useLinkClickHandler(to, _temp) {
1393
- let {
1394
- target,
1395
- replace: replaceProp,
1396
- state,
1397
- preventScrollReset,
1398
- relative,
1399
- viewTransition
1400
- } = _temp === void 0 ? {} : _temp;
1401
- let navigate = useNavigate();
1402
- let location = useLocation();
1403
- let path = useResolvedPath(to, {
1404
- relative
1405
- });
1406
- return React.useCallback((event) => {
1407
- if (shouldProcessLinkClick(event, target)) {
1408
- event.preventDefault();
1409
- let replace = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
1410
- navigate(to, {
1411
- replace,
1412
- state,
1413
- preventScrollReset,
1414
- relative,
1415
- viewTransition
1416
- });
1417
- }
1418
- }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, viewTransition]);
1419
- }
1420
- function useSearchParams(defaultInit) {
1421
- process.env.NODE_ENV !== "production" ? warning(typeof URLSearchParams !== "undefined", "You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.") : void 0;
1422
- let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
1423
- let hasSetSearchParamsRef = React.useRef(false);
1424
- let location = useLocation();
1425
- let searchParams = React.useMemo(() => (
1426
- // Only merge in the defaults if we haven't yet called setSearchParams.
1427
- // Once we call that we want those to take precedence, otherwise you can't
1428
- // remove a param with setSearchParams({}) if it has an initial value
1429
- getSearchParamsForLocation(location.search, hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current)
1430
- ), [location.search]);
1431
- let navigate = useNavigate();
1432
- let setSearchParams = React.useCallback((nextInit, navigateOptions) => {
1433
- const newSearchParams = createSearchParams(typeof nextInit === "function" ? nextInit(searchParams) : nextInit);
1434
- hasSetSearchParamsRef.current = true;
1435
- navigate("?" + newSearchParams, navigateOptions);
1436
- }, [navigate, searchParams]);
1437
- return [searchParams, setSearchParams];
1438
- }
1439
- function validateClientSideSubmission() {
1440
- if (typeof document === "undefined") {
1441
- throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");
1442
- }
1443
- }
1444
- let fetcherId = 0;
1445
- let getUniqueFetcherId = () => "__" + String(++fetcherId) + "__";
1446
- function useSubmit() {
1447
- let {
1448
- router
1449
- } = useDataRouterContext(DataRouterHook.UseSubmit);
1450
- let {
1451
- basename
1452
- } = React.useContext(NavigationContext);
1453
- let currentRouteId = useRouteId();
1454
- return React.useCallback(function(target, options) {
1455
- if (options === void 0) {
1456
- options = {};
1457
- }
1458
- validateClientSideSubmission();
1459
- let {
1460
- action,
1461
- method,
1462
- encType,
1463
- formData,
1464
- body
1465
- } = getFormSubmissionInfo(target, basename);
1466
- if (options.navigate === false) {
1467
- let key = options.fetcherKey || getUniqueFetcherId();
1468
- router.fetch(key, currentRouteId, options.action || action, {
1469
- preventScrollReset: options.preventScrollReset,
1470
- formData,
1471
- body,
1472
- formMethod: options.method || method,
1473
- formEncType: options.encType || encType,
1474
- flushSync: options.flushSync
1475
- });
1476
- } else {
1477
- router.navigate(options.action || action, {
1478
- preventScrollReset: options.preventScrollReset,
1479
- formData,
1480
- body,
1481
- formMethod: options.method || method,
1482
- formEncType: options.encType || encType,
1483
- replace: options.replace,
1484
- state: options.state,
1485
- fromRouteId: currentRouteId,
1486
- flushSync: options.flushSync,
1487
- viewTransition: options.viewTransition
1488
- });
1489
- }
1490
- }, [router, basename, currentRouteId]);
1491
- }
1492
- function useFormAction(action, _temp2) {
1493
- let {
1494
- relative
1495
- } = _temp2 === void 0 ? {} : _temp2;
1496
- let {
1497
- basename
1498
- } = React.useContext(NavigationContext);
1499
- let routeContext = React.useContext(RouteContext);
1500
- !routeContext ? process.env.NODE_ENV !== "production" ? invariant(false, "useFormAction must be used inside a RouteContext") : invariant(false) : void 0;
1501
- let [match] = routeContext.matches.slice(-1);
1502
- let path = _extends({}, useResolvedPath(action ? action : ".", {
1503
- relative
1504
- }));
1505
- let location = useLocation();
1506
- if (action == null) {
1507
- path.search = location.search;
1508
- let params = new URLSearchParams(path.search);
1509
- let indexValues = params.getAll("index");
1510
- let hasNakedIndexParam = indexValues.some((v) => v === "");
1511
- if (hasNakedIndexParam) {
1512
- params.delete("index");
1513
- indexValues.filter((v) => v).forEach((v) => params.append("index", v));
1514
- let qs = params.toString();
1515
- path.search = qs ? "?" + qs : "";
1516
- }
1517
- }
1518
- if ((!action || action === ".") && match.route.index) {
1519
- path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
1520
- }
1521
- if (basename !== "/") {
1522
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
1523
- }
1524
- return createPath(path);
1525
- }
1526
- function useViewTransitionState(to, opts) {
1527
- if (opts === void 0) {
1528
- opts = {};
1529
- }
1530
- let vtContext = React.useContext(ViewTransitionContext);
1531
- !(vtContext != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?") : invariant(false) : void 0;
1532
- let {
1533
- basename
1534
- } = useDataRouterContext(DataRouterHook.useViewTransitionState);
1535
- let path = useResolvedPath(to, {
1536
- relative: opts.relative
1537
- });
1538
- if (!vtContext.isTransitioning) {
1539
- return false;
1540
- }
1541
- let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
1542
- let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
1543
- return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
1544
- }
1545
- export {
1546
- Link as L,
1547
- Routes as R,
1548
- useSearchParams as a,
1549
- useNavigate as b,
1550
- Route as c,
1551
- useParams as u
1552
- };