lkd-web-kit 0.0.2 → 0.0.4

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.
@@ -1,3402 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const require$$1 = require('react/jsx-runtime');
6
- const core = require('@mantine/core');
7
- const require$$0 = require('react');
8
- const useFetchNextPageOnScroll = require('./useFetchNextPageOnScroll-Fqj7Vp-O.cjs');
9
- const navigation = require('./navigation-DnFkn_t2.cjs');
10
-
11
- function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
12
-
13
- const Icon = ({
14
- i: I,
15
- size = "md",
16
- style,
17
- rotate,
18
- className,
19
- ...rest
20
- }) => {
21
- return /* @__PURE__ */ require$$1.jsx(
22
- I,
23
- {
24
- ...typeof size === "number" ? {
25
- height: size,
26
- width: size
27
- } : stylesBySize[size],
28
- viewBox: "0 0 24 24",
29
- style: {
30
- ...style,
31
- transform: `rotate(${rotate}deg)`
32
- },
33
- className: clsx("shrink-0", className),
34
- ...rest
35
- }
36
- );
37
- };
38
- const stylesBySize = {
39
- xs: {
40
- height: 16,
41
- width: 16
42
- },
43
- sm: {
44
- height: 20,
45
- width: 20
46
- },
47
- md: {
48
- height: 24,
49
- width: 24
50
- },
51
- lg: {
52
- height: 28,
53
- width: 28
54
- },
55
- xl: {
56
- height: 32,
57
- width: 32
58
- },
59
- ["2xl"]: {
60
- height: 40,
61
- width: 40
62
- }
63
- };
64
-
65
- const pxBySize = {
66
- sm: 48,
67
- md: 60,
68
- lg: 84
69
- };
70
- const EmptyState = ({
71
- label,
72
- action,
73
- icon,
74
- className,
75
- size = "md",
76
- ...props
77
- }) => {
78
- return /* @__PURE__ */ require$$1.jsxs(
79
- "div",
80
- {
81
- className: clsx("justfiy-center flex flex-col items-center gap-1", className),
82
- ...props,
83
- children: [
84
- /* @__PURE__ */ require$$1.jsx(
85
- Icon,
86
- {
87
- i: icon,
88
- size: pxBySize[size],
89
- className: "text-gray-2"
90
- }
91
- ),
92
- /* @__PURE__ */ require$$1.jsx("p", { className: "text-gray-6 text-sm font-semibold", children: label }),
93
- /* @__PURE__ */ require$$1.jsx("div", { children: action })
94
- ]
95
- }
96
- );
97
- };
98
-
99
- const InfinityLoader = ({ infinity, loaderProps, ...props }) => {
100
- return /* @__PURE__ */ require$$1.jsx(core.Center, { ...props, children: infinity.isFetching ? /* @__PURE__ */ require$$1.jsx(core.Loader, { ...loaderProps }) : !infinity.hasNextPage && (infinity.data?.pages.length ?? 0) > 1 && /* @__PURE__ */ require$$1.jsx("p", { children: "No hay más resultados" }) });
101
- };
102
-
103
- function SelectInfinity({
104
- value,
105
- onChange,
106
- data = [],
107
- searchValue,
108
- onSearchChange,
109
- renderOption,
110
- onOptionSubmit,
111
- nothingFoundMessage,
112
- infinity,
113
- placeholder,
114
- ...props
115
- }) {
116
- const combobox = core.useCombobox({
117
- onDropdownClose: () => {
118
- combobox.resetSelectedOption();
119
- combobox.focusTarget();
120
- onSearchChange?.("");
121
- },
122
- onDropdownOpen: () => {
123
- combobox.focusSearchInput();
124
- }
125
- });
126
- const options = data.map((i) => /* @__PURE__ */ require$$1.jsx(
127
- core.Combobox.Option,
128
- {
129
- value: i.value,
130
- children: renderOption ? renderOption({ option: i }) : i.label
131
- },
132
- i.value
133
- ));
134
- const selectedOption = data.find((i) => i.value === value);
135
- const scrollAreaRef = require$$0.useRef(null);
136
- useFetchNextPageOnScroll.useFetchNextPageOnScroll(infinity, scrollAreaRef);
137
- return /* @__PURE__ */ require$$1.jsxs(
138
- core.Combobox,
139
- {
140
- store: combobox,
141
- middlewares: {
142
- shift: {
143
- crossAxis: true
144
- }
145
- },
146
- onOptionSubmit: (val) => {
147
- onChange?.(val);
148
- onOptionSubmit?.(val);
149
- combobox.closeDropdown();
150
- },
151
- children: [
152
- /* @__PURE__ */ require$$1.jsx(core.Combobox.Target, { children: /* @__PURE__ */ require$$1.jsx(
153
- core.InputBase,
154
- {
155
- component: "button",
156
- type: "button",
157
- pointer: true,
158
- rightSection: /* @__PURE__ */ require$$1.jsx(core.Combobox.Chevron, {}),
159
- onClick: () => combobox.toggleDropdown(),
160
- rightSectionPointerEvents: "none",
161
- ...props,
162
- children: selectedOption?.label || /* @__PURE__ */ require$$1.jsx(core.Input.Placeholder, { children: placeholder })
163
- }
164
- ) }),
165
- /* @__PURE__ */ require$$1.jsxs(core.Combobox.Dropdown, { children: [
166
- /* @__PURE__ */ require$$1.jsx(
167
- core.Combobox.Search,
168
- {
169
- value: searchValue,
170
- onChange: (event) => onSearchChange?.(event.currentTarget.value),
171
- placeholder: "Escribe para buscar"
172
- }
173
- ),
174
- /* @__PURE__ */ require$$1.jsx(core.Combobox.Options, { children: /* @__PURE__ */ require$$1.jsxs(
175
- core.ScrollArea.Autosize,
176
- {
177
- mah: 200,
178
- type: "scroll",
179
- viewportRef: scrollAreaRef,
180
- children: [
181
- options.length > 0 ? options : !infinity.isFetching ? /* @__PURE__ */ require$$1.jsx(
182
- core.Combobox.Empty,
183
- {
184
- onClick: () => combobox.closeDropdown(),
185
- className: "min-h-6",
186
- children: nothingFoundMessage ?? "Sin resultados"
187
- }
188
- ) : null,
189
- /* @__PURE__ */ require$$1.jsx(
190
- InfinityLoader,
191
- {
192
- className: "text-sm",
193
- infinity,
194
- loaderProps: {
195
- size: "sm",
196
- className: "mt-1 mb-2"
197
- }
198
- }
199
- )
200
- ]
201
- }
202
- ) })
203
- ] })
204
- ]
205
- }
206
- );
207
- }
208
-
209
- function getDefaultExportFromCjs (x) {
210
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
211
- }
212
-
213
- var link$1 = {exports: {}};
214
-
215
- var resolveHref = {exports: {}};
216
-
217
- var querystring = {};
218
-
219
- var hasRequiredQuerystring;
220
-
221
- function requireQuerystring () {
222
- if (hasRequiredQuerystring) return querystring;
223
- hasRequiredQuerystring = 1;
224
- (function (exports) {
225
- Object.defineProperty(exports, "__esModule", {
226
- value: true
227
- });
228
- function _export(target, all) {
229
- for(var name in all)Object.defineProperty(target, name, {
230
- enumerable: true,
231
- get: all[name]
232
- });
233
- }
234
- _export(exports, {
235
- assign: function() {
236
- return assign;
237
- },
238
- searchParamsToUrlQuery: function() {
239
- return searchParamsToUrlQuery;
240
- },
241
- urlQueryToSearchParams: function() {
242
- return urlQueryToSearchParams;
243
- }
244
- });
245
- function searchParamsToUrlQuery(searchParams) {
246
- const query = {};
247
- for (const [key, value] of searchParams.entries()){
248
- const existing = query[key];
249
- if (typeof existing === 'undefined') {
250
- query[key] = value;
251
- } else if (Array.isArray(existing)) {
252
- existing.push(value);
253
- } else {
254
- query[key] = [
255
- existing,
256
- value
257
- ];
258
- }
259
- }
260
- return query;
261
- }
262
- function stringifyUrlQueryParam(param) {
263
- if (typeof param === 'string') {
264
- return param;
265
- }
266
- if (typeof param === 'number' && !isNaN(param) || typeof param === 'boolean') {
267
- return String(param);
268
- } else {
269
- return '';
270
- }
271
- }
272
- function urlQueryToSearchParams(query) {
273
- const searchParams = new URLSearchParams();
274
- for (const [key, value] of Object.entries(query)){
275
- if (Array.isArray(value)) {
276
- for (const item of value){
277
- searchParams.append(key, stringifyUrlQueryParam(item));
278
- }
279
- } else {
280
- searchParams.set(key, stringifyUrlQueryParam(value));
281
- }
282
- }
283
- return searchParams;
284
- }
285
- function assign(target) {
286
- for(var _len = arguments.length, searchParamsList = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
287
- searchParamsList[_key - 1] = arguments[_key];
288
- }
289
- for (const searchParams of searchParamsList){
290
- for (const key of searchParams.keys()){
291
- target.delete(key);
292
- }
293
- for (const [key, value] of searchParams.entries()){
294
- target.append(key, value);
295
- }
296
- }
297
- return target;
298
- }
299
-
300
-
301
- } (querystring));
302
- return querystring;
303
- }
304
-
305
- var formatUrl = {};
306
-
307
- var hasRequiredFormatUrl;
308
-
309
- function requireFormatUrl () {
310
- if (hasRequiredFormatUrl) return formatUrl;
311
- hasRequiredFormatUrl = 1;
312
- (function (exports) {
313
- Object.defineProperty(exports, "__esModule", {
314
- value: true
315
- });
316
- function _export(target, all) {
317
- for(var name in all)Object.defineProperty(target, name, {
318
- enumerable: true,
319
- get: all[name]
320
- });
321
- }
322
- _export(exports, {
323
- formatUrl: function() {
324
- return formatUrl;
325
- },
326
- formatWithValidation: function() {
327
- return formatWithValidation;
328
- },
329
- urlObjectKeys: function() {
330
- return urlObjectKeys;
331
- }
332
- });
333
- const _interop_require_wildcard = /*@__PURE__*/ navigation.require_interop_require_wildcard();
334
- const _querystring = /*#__PURE__*/ _interop_require_wildcard._(requireQuerystring());
335
- const slashedProtocols = /https?|ftp|gopher|file/;
336
- function formatUrl(urlObj) {
337
- let { auth, hostname } = urlObj;
338
- let protocol = urlObj.protocol || '';
339
- let pathname = urlObj.pathname || '';
340
- let hash = urlObj.hash || '';
341
- let query = urlObj.query || '';
342
- let host = false;
343
- auth = auth ? encodeURIComponent(auth).replace(/%3A/i, ':') + '@' : '';
344
- if (urlObj.host) {
345
- host = auth + urlObj.host;
346
- } else if (hostname) {
347
- host = auth + (~hostname.indexOf(':') ? "[" + hostname + "]" : hostname);
348
- if (urlObj.port) {
349
- host += ':' + urlObj.port;
350
- }
351
- }
352
- if (query && typeof query === 'object') {
353
- query = String(_querystring.urlQueryToSearchParams(query));
354
- }
355
- let search = urlObj.search || query && "?" + query || '';
356
- if (protocol && !protocol.endsWith(':')) protocol += ':';
357
- if (urlObj.slashes || (!protocol || slashedProtocols.test(protocol)) && host !== false) {
358
- host = '//' + (host || '');
359
- if (pathname && pathname[0] !== '/') pathname = '/' + pathname;
360
- } else if (!host) {
361
- host = '';
362
- }
363
- if (hash && hash[0] !== '#') hash = '#' + hash;
364
- if (search && search[0] !== '?') search = '?' + search;
365
- pathname = pathname.replace(/[?#]/g, encodeURIComponent);
366
- search = search.replace('#', '%23');
367
- return "" + protocol + host + pathname + search + hash;
368
- }
369
- const urlObjectKeys = [
370
- 'auth',
371
- 'hash',
372
- 'host',
373
- 'hostname',
374
- 'href',
375
- 'path',
376
- 'pathname',
377
- 'port',
378
- 'protocol',
379
- 'query',
380
- 'search',
381
- 'slashes'
382
- ];
383
- function formatWithValidation(url) {
384
- if (process.env.NODE_ENV === 'development') {
385
- if (url !== null && typeof url === 'object') {
386
- Object.keys(url).forEach((key)=>{
387
- if (!urlObjectKeys.includes(key)) {
388
- console.warn("Unknown key passed via urlObject into url.format: " + key);
389
- }
390
- });
391
- }
392
- }
393
- return formatUrl(url);
394
- }
395
-
396
-
397
- } (formatUrl));
398
- return formatUrl;
399
- }
400
-
401
- var omit = {};
402
-
403
- var hasRequiredOmit;
404
-
405
- function requireOmit () {
406
- if (hasRequiredOmit) return omit;
407
- hasRequiredOmit = 1;
408
- (function (exports) {
409
- Object.defineProperty(exports, "__esModule", {
410
- value: true
411
- });
412
- Object.defineProperty(exports, "omit", {
413
- enumerable: true,
414
- get: function() {
415
- return omit;
416
- }
417
- });
418
- function omit(object, keys) {
419
- const omitted = {};
420
- Object.keys(object).forEach((key)=>{
421
- if (!keys.includes(key)) {
422
- omitted[key] = object[key];
423
- }
424
- });
425
- return omitted;
426
- }
427
-
428
-
429
- } (omit));
430
- return omit;
431
- }
432
-
433
- var utils$1 = {};
434
-
435
- var hasRequiredUtils$1;
436
-
437
- function requireUtils$1 () {
438
- if (hasRequiredUtils$1) return utils$1;
439
- hasRequiredUtils$1 = 1;
440
- (function (exports) {
441
- Object.defineProperty(exports, "__esModule", {
442
- value: true
443
- });
444
- function _export(target, all) {
445
- for(var name in all)Object.defineProperty(target, name, {
446
- enumerable: true,
447
- get: all[name]
448
- });
449
- }
450
- _export(exports, {
451
- DecodeError: function() {
452
- return DecodeError;
453
- },
454
- MiddlewareNotFoundError: function() {
455
- return MiddlewareNotFoundError;
456
- },
457
- MissingStaticPage: function() {
458
- return MissingStaticPage;
459
- },
460
- NormalizeError: function() {
461
- return NormalizeError;
462
- },
463
- PageNotFoundError: function() {
464
- return PageNotFoundError;
465
- },
466
- SP: function() {
467
- return SP;
468
- },
469
- ST: function() {
470
- return ST;
471
- },
472
- WEB_VITALS: function() {
473
- return WEB_VITALS;
474
- },
475
- execOnce: function() {
476
- return execOnce;
477
- },
478
- getDisplayName: function() {
479
- return getDisplayName;
480
- },
481
- getLocationOrigin: function() {
482
- return getLocationOrigin;
483
- },
484
- getURL: function() {
485
- return getURL;
486
- },
487
- isAbsoluteUrl: function() {
488
- return isAbsoluteUrl;
489
- },
490
- isResSent: function() {
491
- return isResSent;
492
- },
493
- loadGetInitialProps: function() {
494
- return loadGetInitialProps;
495
- },
496
- normalizeRepeatedSlashes: function() {
497
- return normalizeRepeatedSlashes;
498
- },
499
- stringifyError: function() {
500
- return stringifyError;
501
- }
502
- });
503
- const WEB_VITALS = [
504
- 'CLS',
505
- 'FCP',
506
- 'FID',
507
- 'INP',
508
- 'LCP',
509
- 'TTFB'
510
- ];
511
- function execOnce(fn) {
512
- let used = false;
513
- let result;
514
- return function() {
515
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
516
- args[_key] = arguments[_key];
517
- }
518
- if (!used) {
519
- used = true;
520
- result = fn(...args);
521
- }
522
- return result;
523
- };
524
- }
525
- // Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
526
- // Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
527
- const ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
528
- const isAbsoluteUrl = (url)=>ABSOLUTE_URL_REGEX.test(url);
529
- function getLocationOrigin() {
530
- const { protocol, hostname, port } = window.location;
531
- return protocol + "//" + hostname + (port ? ':' + port : '');
532
- }
533
- function getURL() {
534
- const { href } = window.location;
535
- const origin = getLocationOrigin();
536
- return href.substring(origin.length);
537
- }
538
- function getDisplayName(Component) {
539
- return typeof Component === 'string' ? Component : Component.displayName || Component.name || 'Unknown';
540
- }
541
- function isResSent(res) {
542
- return res.finished || res.headersSent;
543
- }
544
- function normalizeRepeatedSlashes(url) {
545
- const urlParts = url.split('?');
546
- const urlNoQuery = urlParts[0];
547
- return urlNoQuery// first we replace any non-encoded backslashes with forward
548
- // then normalize repeated forward slashes
549
- .replace(/\\/g, '/').replace(/\/\/+/g, '/') + (urlParts[1] ? "?" + urlParts.slice(1).join('?') : '');
550
- }
551
- async function loadGetInitialProps(App, ctx) {
552
- if (process.env.NODE_ENV !== 'production') {
553
- var _App_prototype;
554
- if ((_App_prototype = App.prototype) == null ? void 0 : _App_prototype.getInitialProps) {
555
- const message = '"' + getDisplayName(App) + '.getInitialProps()" is defined as an instance method - visit https://nextjs.org/docs/messages/get-initial-props-as-an-instance-method for more information.';
556
- throw Object.defineProperty(new Error(message), "__NEXT_ERROR_CODE", {
557
- value: "E394",
558
- enumerable: false,
559
- configurable: true
560
- });
561
- }
562
- }
563
- // when called from _app `ctx` is nested in `ctx`
564
- const res = ctx.res || ctx.ctx && ctx.ctx.res;
565
- if (!App.getInitialProps) {
566
- if (ctx.ctx && ctx.Component) {
567
- // @ts-ignore pageProps default
568
- return {
569
- pageProps: await loadGetInitialProps(ctx.Component, ctx.ctx)
570
- };
571
- }
572
- return {};
573
- }
574
- const props = await App.getInitialProps(ctx);
575
- if (res && isResSent(res)) {
576
- return props;
577
- }
578
- if (!props) {
579
- const message = '"' + getDisplayName(App) + '.getInitialProps()" should resolve to an object. But found "' + props + '" instead.';
580
- throw Object.defineProperty(new Error(message), "__NEXT_ERROR_CODE", {
581
- value: "E394",
582
- enumerable: false,
583
- configurable: true
584
- });
585
- }
586
- if (process.env.NODE_ENV !== 'production') {
587
- if (Object.keys(props).length === 0 && !ctx.ctx) {
588
- console.warn("" + getDisplayName(App) + " returned an empty object from `getInitialProps`. This de-optimizes and prevents automatic static optimization. https://nextjs.org/docs/messages/empty-object-getInitialProps");
589
- }
590
- }
591
- return props;
592
- }
593
- const SP = typeof performance !== 'undefined';
594
- const ST = SP && [
595
- 'mark',
596
- 'measure',
597
- 'getEntriesByName'
598
- ].every((method)=>typeof performance[method] === 'function');
599
- class DecodeError extends Error {
600
- }
601
- class NormalizeError extends Error {
602
- }
603
- class PageNotFoundError extends Error {
604
- constructor(page){
605
- super();
606
- this.code = 'ENOENT';
607
- this.name = 'PageNotFoundError';
608
- this.message = "Cannot find module for page: " + page;
609
- }
610
- }
611
- class MissingStaticPage extends Error {
612
- constructor(page, message){
613
- super();
614
- this.message = "Failed to load static file for page: " + page + " " + message;
615
- }
616
- }
617
- class MiddlewareNotFoundError extends Error {
618
- constructor(){
619
- super();
620
- this.code = 'ENOENT';
621
- this.message = "Cannot find the middleware module";
622
- }
623
- }
624
- function stringifyError(error) {
625
- return JSON.stringify({
626
- message: error.message,
627
- stack: error.stack
628
- });
629
- }
630
-
631
-
632
- } (utils$1));
633
- return utils$1;
634
- }
635
-
636
- var normalizeTrailingSlash = {exports: {}};
637
-
638
- var removeTrailingSlash = {};
639
-
640
- /**
641
- * Removes the trailing slash for a given route or page path. Preserves the
642
- * root page. Examples:
643
- * - `/foo/bar/` -> `/foo/bar`
644
- * - `/foo/bar` -> `/foo/bar`
645
- * - `/` -> `/`
646
- */
647
-
648
- var hasRequiredRemoveTrailingSlash;
649
-
650
- function requireRemoveTrailingSlash () {
651
- if (hasRequiredRemoveTrailingSlash) return removeTrailingSlash;
652
- hasRequiredRemoveTrailingSlash = 1;
653
- (function (exports) {
654
- Object.defineProperty(exports, "__esModule", {
655
- value: true
656
- });
657
- Object.defineProperty(exports, "removeTrailingSlash", {
658
- enumerable: true,
659
- get: function() {
660
- return removeTrailingSlash;
661
- }
662
- });
663
- function removeTrailingSlash(route) {
664
- return route.replace(/\/$/, '') || '/';
665
- }
666
-
667
-
668
- } (removeTrailingSlash));
669
- return removeTrailingSlash;
670
- }
671
-
672
- var parsePath = {};
673
-
674
- /**
675
- * Given a path this function will find the pathname, query and hash and return
676
- * them. This is useful to parse full paths on the client side.
677
- * @param path A path to parse e.g. /foo/bar?id=1#hash
678
- */
679
-
680
- var hasRequiredParsePath;
681
-
682
- function requireParsePath () {
683
- if (hasRequiredParsePath) return parsePath;
684
- hasRequiredParsePath = 1;
685
- (function (exports) {
686
- Object.defineProperty(exports, "__esModule", {
687
- value: true
688
- });
689
- Object.defineProperty(exports, "parsePath", {
690
- enumerable: true,
691
- get: function() {
692
- return parsePath;
693
- }
694
- });
695
- function parsePath(path) {
696
- const hashIndex = path.indexOf('#');
697
- const queryIndex = path.indexOf('?');
698
- const hasQuery = queryIndex > -1 && (hashIndex < 0 || queryIndex < hashIndex);
699
- if (hasQuery || hashIndex > -1) {
700
- return {
701
- pathname: path.substring(0, hasQuery ? queryIndex : hashIndex),
702
- query: hasQuery ? path.substring(queryIndex, hashIndex > -1 ? hashIndex : undefined) : '',
703
- hash: hashIndex > -1 ? path.slice(hashIndex) : ''
704
- };
705
- }
706
- return {
707
- pathname: path,
708
- query: '',
709
- hash: ''
710
- };
711
- }
712
-
713
-
714
- } (parsePath));
715
- return parsePath;
716
- }
717
-
718
- var hasRequiredNormalizeTrailingSlash;
719
-
720
- function requireNormalizeTrailingSlash () {
721
- if (hasRequiredNormalizeTrailingSlash) return normalizeTrailingSlash.exports;
722
- hasRequiredNormalizeTrailingSlash = 1;
723
- (function (module, exports) {
724
- Object.defineProperty(exports, "__esModule", {
725
- value: true
726
- });
727
- Object.defineProperty(exports, "normalizePathTrailingSlash", {
728
- enumerable: true,
729
- get: function() {
730
- return normalizePathTrailingSlash;
731
- }
732
- });
733
- const _removetrailingslash = requireRemoveTrailingSlash();
734
- const _parsepath = requireParsePath();
735
- const normalizePathTrailingSlash = (path)=>{
736
- if (!path.startsWith('/') || process.env.__NEXT_MANUAL_TRAILING_SLASH) {
737
- return path;
738
- }
739
- const { pathname, query, hash } = (0, _parsepath.parsePath)(path);
740
- if (process.env.__NEXT_TRAILING_SLASH) {
741
- if (/\.[^/]+\/?$/.test(pathname)) {
742
- return "" + (0, _removetrailingslash.removeTrailingSlash)(pathname) + query + hash;
743
- } else if (pathname.endsWith('/')) {
744
- return "" + pathname + query + hash;
745
- } else {
746
- return pathname + "/" + query + hash;
747
- }
748
- }
749
- return "" + (0, _removetrailingslash.removeTrailingSlash)(pathname) + query + hash;
750
- };
751
-
752
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
753
- Object.defineProperty(exports.default, '__esModule', { value: true });
754
- Object.assign(exports.default, exports);
755
- module.exports = exports.default;
756
- }
757
-
758
-
759
- } (normalizeTrailingSlash, normalizeTrailingSlash.exports));
760
- return normalizeTrailingSlash.exports;
761
- }
762
-
763
- var isLocalUrl = {};
764
-
765
- var hasBasePath = {exports: {}};
766
-
767
- var pathHasPrefix = {};
768
-
769
- var hasRequiredPathHasPrefix;
770
-
771
- function requirePathHasPrefix () {
772
- if (hasRequiredPathHasPrefix) return pathHasPrefix;
773
- hasRequiredPathHasPrefix = 1;
774
- (function (exports) {
775
- Object.defineProperty(exports, "__esModule", {
776
- value: true
777
- });
778
- Object.defineProperty(exports, "pathHasPrefix", {
779
- enumerable: true,
780
- get: function() {
781
- return pathHasPrefix;
782
- }
783
- });
784
- const _parsepath = requireParsePath();
785
- function pathHasPrefix(path, prefix) {
786
- if (typeof path !== 'string') {
787
- return false;
788
- }
789
- const { pathname } = (0, _parsepath.parsePath)(path);
790
- return pathname === prefix || pathname.startsWith(prefix + '/');
791
- }
792
-
793
-
794
- } (pathHasPrefix));
795
- return pathHasPrefix;
796
- }
797
-
798
- var hasRequiredHasBasePath;
799
-
800
- function requireHasBasePath () {
801
- if (hasRequiredHasBasePath) return hasBasePath.exports;
802
- hasRequiredHasBasePath = 1;
803
- (function (module, exports) {
804
- Object.defineProperty(exports, "__esModule", {
805
- value: true
806
- });
807
- Object.defineProperty(exports, "hasBasePath", {
808
- enumerable: true,
809
- get: function() {
810
- return hasBasePath;
811
- }
812
- });
813
- const _pathhasprefix = requirePathHasPrefix();
814
- const basePath = process.env.__NEXT_ROUTER_BASEPATH || '';
815
- function hasBasePath(path) {
816
- return (0, _pathhasprefix.pathHasPrefix)(path, basePath);
817
- }
818
-
819
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
820
- Object.defineProperty(exports.default, '__esModule', { value: true });
821
- Object.assign(exports.default, exports);
822
- module.exports = exports.default;
823
- }
824
-
825
-
826
- } (hasBasePath, hasBasePath.exports));
827
- return hasBasePath.exports;
828
- }
829
-
830
- var hasRequiredIsLocalUrl;
831
-
832
- function requireIsLocalUrl () {
833
- if (hasRequiredIsLocalUrl) return isLocalUrl;
834
- hasRequiredIsLocalUrl = 1;
835
- (function (exports) {
836
- Object.defineProperty(exports, "__esModule", {
837
- value: true
838
- });
839
- Object.defineProperty(exports, "isLocalURL", {
840
- enumerable: true,
841
- get: function() {
842
- return isLocalURL;
843
- }
844
- });
845
- const _utils = requireUtils$1();
846
- const _hasbasepath = requireHasBasePath();
847
- function isLocalURL(url) {
848
- // prevent a hydration mismatch on href for url with anchor refs
849
- if (!(0, _utils.isAbsoluteUrl)(url)) return true;
850
- try {
851
- // absolute urls can be local if they are on the same origin
852
- const locationOrigin = (0, _utils.getLocationOrigin)();
853
- const resolved = new URL(url, locationOrigin);
854
- return resolved.origin === locationOrigin && (0, _hasbasepath.hasBasePath)(resolved.pathname);
855
- } catch (_) {
856
- return false;
857
- }
858
- }
859
-
860
-
861
- } (isLocalUrl));
862
- return isLocalUrl;
863
- }
864
-
865
- var utils = {};
866
-
867
- var sortedRoutes = {};
868
-
869
- var hasRequiredSortedRoutes;
870
-
871
- function requireSortedRoutes () {
872
- if (hasRequiredSortedRoutes) return sortedRoutes;
873
- hasRequiredSortedRoutes = 1;
874
- (function (exports) {
875
- Object.defineProperty(exports, "__esModule", {
876
- value: true
877
- });
878
- function _export(target, all) {
879
- for(var name in all)Object.defineProperty(target, name, {
880
- enumerable: true,
881
- get: all[name]
882
- });
883
- }
884
- _export(exports, {
885
- getSortedRouteObjects: function() {
886
- return getSortedRouteObjects;
887
- },
888
- getSortedRoutes: function() {
889
- return getSortedRoutes;
890
- }
891
- });
892
- class UrlNode {
893
- insert(urlPath) {
894
- this._insert(urlPath.split('/').filter(Boolean), [], false);
895
- }
896
- smoosh() {
897
- return this._smoosh();
898
- }
899
- _smoosh(prefix) {
900
- if (prefix === void 0) prefix = '/';
901
- const childrenPaths = [
902
- ...this.children.keys()
903
- ].sort();
904
- if (this.slugName !== null) {
905
- childrenPaths.splice(childrenPaths.indexOf('[]'), 1);
906
- }
907
- if (this.restSlugName !== null) {
908
- childrenPaths.splice(childrenPaths.indexOf('[...]'), 1);
909
- }
910
- if (this.optionalRestSlugName !== null) {
911
- childrenPaths.splice(childrenPaths.indexOf('[[...]]'), 1);
912
- }
913
- const routes = childrenPaths.map((c)=>this.children.get(c)._smoosh("" + prefix + c + "/")).reduce((prev, curr)=>[
914
- ...prev,
915
- ...curr
916
- ], []);
917
- if (this.slugName !== null) {
918
- routes.push(...this.children.get('[]')._smoosh(prefix + "[" + this.slugName + "]/"));
919
- }
920
- if (!this.placeholder) {
921
- const r = prefix === '/' ? '/' : prefix.slice(0, -1);
922
- if (this.optionalRestSlugName != null) {
923
- throw Object.defineProperty(new Error('You cannot define a route with the same specificity as a optional catch-all route ("' + r + '" and "' + r + "[[..." + this.optionalRestSlugName + ']]").'), "__NEXT_ERROR_CODE", {
924
- value: "E458",
925
- enumerable: false,
926
- configurable: true
927
- });
928
- }
929
- routes.unshift(r);
930
- }
931
- if (this.restSlugName !== null) {
932
- routes.push(...this.children.get('[...]')._smoosh(prefix + "[..." + this.restSlugName + "]/"));
933
- }
934
- if (this.optionalRestSlugName !== null) {
935
- routes.push(...this.children.get('[[...]]')._smoosh(prefix + "[[..." + this.optionalRestSlugName + "]]/"));
936
- }
937
- return routes;
938
- }
939
- _insert(urlPaths, slugNames, isCatchAll) {
940
- if (urlPaths.length === 0) {
941
- this.placeholder = false;
942
- return;
943
- }
944
- if (isCatchAll) {
945
- throw Object.defineProperty(new Error("Catch-all must be the last part of the URL."), "__NEXT_ERROR_CODE", {
946
- value: "E392",
947
- enumerable: false,
948
- configurable: true
949
- });
950
- }
951
- // The next segment in the urlPaths list
952
- let nextSegment = urlPaths[0];
953
- // Check if the segment matches `[something]`
954
- if (nextSegment.startsWith('[') && nextSegment.endsWith(']')) {
955
- // Strip `[` and `]`, leaving only `something`
956
- let segmentName = nextSegment.slice(1, -1);
957
- let isOptional = false;
958
- if (segmentName.startsWith('[') && segmentName.endsWith(']')) {
959
- // Strip optional `[` and `]`, leaving only `something`
960
- segmentName = segmentName.slice(1, -1);
961
- isOptional = true;
962
- }
963
- if (segmentName.startsWith('…')) {
964
- throw Object.defineProperty(new Error("Detected a three-dot character ('…') at ('" + segmentName + "'). Did you mean ('...')?"), "__NEXT_ERROR_CODE", {
965
- value: "E147",
966
- enumerable: false,
967
- configurable: true
968
- });
969
- }
970
- if (segmentName.startsWith('...')) {
971
- // Strip `...`, leaving only `something`
972
- segmentName = segmentName.substring(3);
973
- isCatchAll = true;
974
- }
975
- if (segmentName.startsWith('[') || segmentName.endsWith(']')) {
976
- throw Object.defineProperty(new Error("Segment names may not start or end with extra brackets ('" + segmentName + "')."), "__NEXT_ERROR_CODE", {
977
- value: "E421",
978
- enumerable: false,
979
- configurable: true
980
- });
981
- }
982
- if (segmentName.startsWith('.')) {
983
- throw Object.defineProperty(new Error("Segment names may not start with erroneous periods ('" + segmentName + "')."), "__NEXT_ERROR_CODE", {
984
- value: "E288",
985
- enumerable: false,
986
- configurable: true
987
- });
988
- }
989
- function handleSlug(previousSlug, nextSlug) {
990
- if (previousSlug !== null) {
991
- // If the specific segment already has a slug but the slug is not `something`
992
- // This prevents collisions like:
993
- // pages/[post]/index.js
994
- // pages/[id]/index.js
995
- // Because currently multiple dynamic params on the same segment level are not supported
996
- if (previousSlug !== nextSlug) {
997
- // TODO: This error seems to be confusing for users, needs an error link, the description can be based on above comment.
998
- throw Object.defineProperty(new Error("You cannot use different slug names for the same dynamic path ('" + previousSlug + "' !== '" + nextSlug + "')."), "__NEXT_ERROR_CODE", {
999
- value: "E337",
1000
- enumerable: false,
1001
- configurable: true
1002
- });
1003
- }
1004
- }
1005
- slugNames.forEach((slug)=>{
1006
- if (slug === nextSlug) {
1007
- throw Object.defineProperty(new Error('You cannot have the same slug name "' + nextSlug + '" repeat within a single dynamic path'), "__NEXT_ERROR_CODE", {
1008
- value: "E247",
1009
- enumerable: false,
1010
- configurable: true
1011
- });
1012
- }
1013
- if (slug.replace(/\W/g, '') === nextSegment.replace(/\W/g, '')) {
1014
- throw Object.defineProperty(new Error('You cannot have the slug names "' + slug + '" and "' + nextSlug + '" differ only by non-word symbols within a single dynamic path'), "__NEXT_ERROR_CODE", {
1015
- value: "E499",
1016
- enumerable: false,
1017
- configurable: true
1018
- });
1019
- }
1020
- });
1021
- slugNames.push(nextSlug);
1022
- }
1023
- if (isCatchAll) {
1024
- if (isOptional) {
1025
- if (this.restSlugName != null) {
1026
- throw Object.defineProperty(new Error('You cannot use both an required and optional catch-all route at the same level ("[...' + this.restSlugName + ']" and "' + urlPaths[0] + '" ).'), "__NEXT_ERROR_CODE", {
1027
- value: "E299",
1028
- enumerable: false,
1029
- configurable: true
1030
- });
1031
- }
1032
- handleSlug(this.optionalRestSlugName, segmentName);
1033
- // slugName is kept as it can only be one particular slugName
1034
- this.optionalRestSlugName = segmentName;
1035
- // nextSegment is overwritten to [[...]] so that it can later be sorted specifically
1036
- nextSegment = '[[...]]';
1037
- } else {
1038
- if (this.optionalRestSlugName != null) {
1039
- throw Object.defineProperty(new Error('You cannot use both an optional and required catch-all route at the same level ("[[...' + this.optionalRestSlugName + ']]" and "' + urlPaths[0] + '").'), "__NEXT_ERROR_CODE", {
1040
- value: "E300",
1041
- enumerable: false,
1042
- configurable: true
1043
- });
1044
- }
1045
- handleSlug(this.restSlugName, segmentName);
1046
- // slugName is kept as it can only be one particular slugName
1047
- this.restSlugName = segmentName;
1048
- // nextSegment is overwritten to [...] so that it can later be sorted specifically
1049
- nextSegment = '[...]';
1050
- }
1051
- } else {
1052
- if (isOptional) {
1053
- throw Object.defineProperty(new Error('Optional route parameters are not yet supported ("' + urlPaths[0] + '").'), "__NEXT_ERROR_CODE", {
1054
- value: "E435",
1055
- enumerable: false,
1056
- configurable: true
1057
- });
1058
- }
1059
- handleSlug(this.slugName, segmentName);
1060
- // slugName is kept as it can only be one particular slugName
1061
- this.slugName = segmentName;
1062
- // nextSegment is overwritten to [] so that it can later be sorted specifically
1063
- nextSegment = '[]';
1064
- }
1065
- }
1066
- // If this UrlNode doesn't have the nextSegment yet we create a new child UrlNode
1067
- if (!this.children.has(nextSegment)) {
1068
- this.children.set(nextSegment, new UrlNode());
1069
- }
1070
- this.children.get(nextSegment)._insert(urlPaths.slice(1), slugNames, isCatchAll);
1071
- }
1072
- constructor(){
1073
- this.placeholder = true;
1074
- this.children = new Map();
1075
- this.slugName = null;
1076
- this.restSlugName = null;
1077
- this.optionalRestSlugName = null;
1078
- }
1079
- }
1080
- function getSortedRoutes(normalizedPages) {
1081
- // First the UrlNode is created, and every UrlNode can have only 1 dynamic segment
1082
- // Eg you can't have pages/[post]/abc.js and pages/[hello]/something-else.js
1083
- // Only 1 dynamic segment per nesting level
1084
- // So in the case that is test/integration/dynamic-routing it'll be this:
1085
- // pages/[post]/comments.js
1086
- // pages/blog/[post]/comment/[id].js
1087
- // Both are fine because `pages/[post]` and `pages/blog` are on the same level
1088
- // So in this case `UrlNode` created here has `this.slugName === 'post'`
1089
- // And since your PR passed through `slugName` as an array basically it'd including it in too many possibilities
1090
- // Instead what has to be passed through is the upwards path's dynamic names
1091
- const root = new UrlNode();
1092
- // Here the `root` gets injected multiple paths, and insert will break them up into sublevels
1093
- normalizedPages.forEach((pagePath)=>root.insert(pagePath));
1094
- // Smoosh will then sort those sublevels up to the point where you get the correct route definition priority
1095
- return root.smoosh();
1096
- }
1097
- function getSortedRouteObjects(objects, getter) {
1098
- // We're assuming here that all the pathnames are unique, that way we can
1099
- // sort the list and use the index as the key.
1100
- const indexes = {};
1101
- const pathnames = [];
1102
- for(let i = 0; i < objects.length; i++){
1103
- const pathname = getter(objects[i]);
1104
- indexes[pathname] = i;
1105
- pathnames[i] = pathname;
1106
- }
1107
- // Sort the pathnames.
1108
- const sorted = getSortedRoutes(pathnames);
1109
- // Map the sorted pathnames back to the original objects using the new sorted
1110
- // index.
1111
- return sorted.map((pathname)=>objects[indexes[pathname]]);
1112
- }
1113
-
1114
-
1115
- } (sortedRoutes));
1116
- return sortedRoutes;
1117
- }
1118
-
1119
- var isDynamic = {};
1120
-
1121
- var interceptionRoutes = {};
1122
-
1123
- var appPaths = {};
1124
-
1125
- var ensureLeadingSlash = {};
1126
-
1127
- /**
1128
- * For a given page path, this function ensures that there is a leading slash.
1129
- * If there is not a leading slash, one is added, otherwise it is noop.
1130
- */
1131
-
1132
- var hasRequiredEnsureLeadingSlash;
1133
-
1134
- function requireEnsureLeadingSlash () {
1135
- if (hasRequiredEnsureLeadingSlash) return ensureLeadingSlash;
1136
- hasRequiredEnsureLeadingSlash = 1;
1137
- (function (exports) {
1138
- Object.defineProperty(exports, "__esModule", {
1139
- value: true
1140
- });
1141
- Object.defineProperty(exports, "ensureLeadingSlash", {
1142
- enumerable: true,
1143
- get: function() {
1144
- return ensureLeadingSlash;
1145
- }
1146
- });
1147
- function ensureLeadingSlash(path) {
1148
- return path.startsWith('/') ? path : "/" + path;
1149
- }
1150
-
1151
-
1152
- } (ensureLeadingSlash));
1153
- return ensureLeadingSlash;
1154
- }
1155
-
1156
- var hasRequiredAppPaths;
1157
-
1158
- function requireAppPaths () {
1159
- if (hasRequiredAppPaths) return appPaths;
1160
- hasRequiredAppPaths = 1;
1161
- (function (exports) {
1162
- Object.defineProperty(exports, "__esModule", {
1163
- value: true
1164
- });
1165
- function _export(target, all) {
1166
- for(var name in all)Object.defineProperty(target, name, {
1167
- enumerable: true,
1168
- get: all[name]
1169
- });
1170
- }
1171
- _export(exports, {
1172
- normalizeAppPath: function() {
1173
- return normalizeAppPath;
1174
- },
1175
- normalizeRscURL: function() {
1176
- return normalizeRscURL;
1177
- }
1178
- });
1179
- const _ensureleadingslash = requireEnsureLeadingSlash();
1180
- const _segment = navigation.requireSegment();
1181
- function normalizeAppPath(route) {
1182
- return (0, _ensureleadingslash.ensureLeadingSlash)(route.split('/').reduce((pathname, segment, index, segments)=>{
1183
- // Empty segments are ignored.
1184
- if (!segment) {
1185
- return pathname;
1186
- }
1187
- // Groups are ignored.
1188
- if ((0, _segment.isGroupSegment)(segment)) {
1189
- return pathname;
1190
- }
1191
- // Parallel segments are ignored.
1192
- if (segment[0] === '@') {
1193
- return pathname;
1194
- }
1195
- // The last segment (if it's a leaf) should be ignored.
1196
- if ((segment === 'page' || segment === 'route') && index === segments.length - 1) {
1197
- return pathname;
1198
- }
1199
- return pathname + "/" + segment;
1200
- }, ''));
1201
- }
1202
- function normalizeRscURL(url) {
1203
- return url.replace(/\.rsc($|\?)/, // $1 ensures `?` is preserved
1204
- '$1');
1205
- }
1206
-
1207
-
1208
- } (appPaths));
1209
- return appPaths;
1210
- }
1211
-
1212
- var hasRequiredInterceptionRoutes;
1213
-
1214
- function requireInterceptionRoutes () {
1215
- if (hasRequiredInterceptionRoutes) return interceptionRoutes;
1216
- hasRequiredInterceptionRoutes = 1;
1217
- (function (exports) {
1218
- Object.defineProperty(exports, "__esModule", {
1219
- value: true
1220
- });
1221
- function _export(target, all) {
1222
- for(var name in all)Object.defineProperty(target, name, {
1223
- enumerable: true,
1224
- get: all[name]
1225
- });
1226
- }
1227
- _export(exports, {
1228
- INTERCEPTION_ROUTE_MARKERS: function() {
1229
- return INTERCEPTION_ROUTE_MARKERS;
1230
- },
1231
- extractInterceptionRouteInformation: function() {
1232
- return extractInterceptionRouteInformation;
1233
- },
1234
- isInterceptionRouteAppPath: function() {
1235
- return isInterceptionRouteAppPath;
1236
- }
1237
- });
1238
- const _apppaths = requireAppPaths();
1239
- const INTERCEPTION_ROUTE_MARKERS = [
1240
- '(..)(..)',
1241
- '(.)',
1242
- '(..)',
1243
- '(...)'
1244
- ];
1245
- function isInterceptionRouteAppPath(path) {
1246
- // TODO-APP: add more serious validation
1247
- return path.split('/').find((segment)=>INTERCEPTION_ROUTE_MARKERS.find((m)=>segment.startsWith(m))) !== undefined;
1248
- }
1249
- function extractInterceptionRouteInformation(path) {
1250
- let interceptingRoute, marker, interceptedRoute;
1251
- for (const segment of path.split('/')){
1252
- marker = INTERCEPTION_ROUTE_MARKERS.find((m)=>segment.startsWith(m));
1253
- if (marker) {
1254
- [interceptingRoute, interceptedRoute] = path.split(marker, 2);
1255
- break;
1256
- }
1257
- }
1258
- if (!interceptingRoute || !marker || !interceptedRoute) {
1259
- throw Object.defineProperty(new Error("Invalid interception route: " + path + ". Must be in the format /<intercepting route>/(..|...|..)(..)/<intercepted route>"), "__NEXT_ERROR_CODE", {
1260
- value: "E269",
1261
- enumerable: false,
1262
- configurable: true
1263
- });
1264
- }
1265
- interceptingRoute = (0, _apppaths.normalizeAppPath)(interceptingRoute) // normalize the path, e.g. /(blog)/feed -> /feed
1266
- ;
1267
- switch(marker){
1268
- case '(.)':
1269
- // (.) indicates that we should match with sibling routes, so we just need to append the intercepted route to the intercepting route
1270
- if (interceptingRoute === '/') {
1271
- interceptedRoute = "/" + interceptedRoute;
1272
- } else {
1273
- interceptedRoute = interceptingRoute + '/' + interceptedRoute;
1274
- }
1275
- break;
1276
- case '(..)':
1277
- // (..) indicates that we should match at one level up, so we need to remove the last segment of the intercepting route
1278
- if (interceptingRoute === '/') {
1279
- throw Object.defineProperty(new Error("Invalid interception route: " + path + ". Cannot use (..) marker at the root level, use (.) instead."), "__NEXT_ERROR_CODE", {
1280
- value: "E207",
1281
- enumerable: false,
1282
- configurable: true
1283
- });
1284
- }
1285
- interceptedRoute = interceptingRoute.split('/').slice(0, -1).concat(interceptedRoute).join('/');
1286
- break;
1287
- case '(...)':
1288
- // (...) will match the route segment in the root directory, so we need to use the root directory to prepend the intercepted route
1289
- interceptedRoute = '/' + interceptedRoute;
1290
- break;
1291
- case '(..)(..)':
1292
- // (..)(..) indicates that we should match at two levels up, so we need to remove the last two segments of the intercepting route
1293
- const splitInterceptingRoute = interceptingRoute.split('/');
1294
- if (splitInterceptingRoute.length <= 2) {
1295
- throw Object.defineProperty(new Error("Invalid interception route: " + path + ". Cannot use (..)(..) marker at the root level or one level up."), "__NEXT_ERROR_CODE", {
1296
- value: "E486",
1297
- enumerable: false,
1298
- configurable: true
1299
- });
1300
- }
1301
- interceptedRoute = splitInterceptingRoute.slice(0, -2).concat(interceptedRoute).join('/');
1302
- break;
1303
- default:
1304
- throw Object.defineProperty(new Error('Invariant: unexpected marker'), "__NEXT_ERROR_CODE", {
1305
- value: "E112",
1306
- enumerable: false,
1307
- configurable: true
1308
- });
1309
- }
1310
- return {
1311
- interceptingRoute,
1312
- interceptedRoute
1313
- };
1314
- }
1315
-
1316
-
1317
- } (interceptionRoutes));
1318
- return interceptionRoutes;
1319
- }
1320
-
1321
- var hasRequiredIsDynamic;
1322
-
1323
- function requireIsDynamic () {
1324
- if (hasRequiredIsDynamic) return isDynamic;
1325
- hasRequiredIsDynamic = 1;
1326
- (function (exports) {
1327
- Object.defineProperty(exports, "__esModule", {
1328
- value: true
1329
- });
1330
- Object.defineProperty(exports, "isDynamicRoute", {
1331
- enumerable: true,
1332
- get: function() {
1333
- return isDynamicRoute;
1334
- }
1335
- });
1336
- const _interceptionroutes = requireInterceptionRoutes();
1337
- // Identify /.*[param].*/ in route string
1338
- const TEST_ROUTE = /\/[^/]*\[[^/]+\][^/]*(?=\/|$)/;
1339
- // Identify /[param]/ in route string
1340
- const TEST_STRICT_ROUTE = /\/\[[^/]+\](?=\/|$)/;
1341
- function isDynamicRoute(route, strict) {
1342
- if (strict === void 0) strict = true;
1343
- if ((0, _interceptionroutes.isInterceptionRouteAppPath)(route)) {
1344
- route = (0, _interceptionroutes.extractInterceptionRouteInformation)(route).interceptedRoute;
1345
- }
1346
- if (strict) {
1347
- return TEST_STRICT_ROUTE.test(route);
1348
- }
1349
- return TEST_ROUTE.test(route);
1350
- }
1351
-
1352
-
1353
- } (isDynamic));
1354
- return isDynamic;
1355
- }
1356
-
1357
- var hasRequiredUtils;
1358
-
1359
- function requireUtils () {
1360
- if (hasRequiredUtils) return utils;
1361
- hasRequiredUtils = 1;
1362
- (function (exports) {
1363
- Object.defineProperty(exports, "__esModule", {
1364
- value: true
1365
- });
1366
- function _export(target, all) {
1367
- for(var name in all)Object.defineProperty(target, name, {
1368
- enumerable: true,
1369
- get: all[name]
1370
- });
1371
- }
1372
- _export(exports, {
1373
- getSortedRouteObjects: function() {
1374
- return _sortedroutes.getSortedRouteObjects;
1375
- },
1376
- getSortedRoutes: function() {
1377
- return _sortedroutes.getSortedRoutes;
1378
- },
1379
- isDynamicRoute: function() {
1380
- return _isdynamic.isDynamicRoute;
1381
- }
1382
- });
1383
- const _sortedroutes = requireSortedRoutes();
1384
- const _isdynamic = requireIsDynamic();
1385
-
1386
-
1387
- } (utils));
1388
- return utils;
1389
- }
1390
-
1391
- var interpolateAs = {};
1392
-
1393
- var routeMatcher = {};
1394
-
1395
- var hasRequiredRouteMatcher;
1396
-
1397
- function requireRouteMatcher () {
1398
- if (hasRequiredRouteMatcher) return routeMatcher;
1399
- hasRequiredRouteMatcher = 1;
1400
- (function (exports) {
1401
- Object.defineProperty(exports, "__esModule", {
1402
- value: true
1403
- });
1404
- Object.defineProperty(exports, "getRouteMatcher", {
1405
- enumerable: true,
1406
- get: function() {
1407
- return getRouteMatcher;
1408
- }
1409
- });
1410
- const _utils = requireUtils$1();
1411
- function getRouteMatcher(param) {
1412
- let { re, groups } = param;
1413
- return (pathname)=>{
1414
- const routeMatch = re.exec(pathname);
1415
- if (!routeMatch) return false;
1416
- const decode = (param)=>{
1417
- try {
1418
- return decodeURIComponent(param);
1419
- } catch (e) {
1420
- throw Object.defineProperty(new _utils.DecodeError('failed to decode param'), "__NEXT_ERROR_CODE", {
1421
- value: "E528",
1422
- enumerable: false,
1423
- configurable: true
1424
- });
1425
- }
1426
- };
1427
- const params = {};
1428
- for (const [key, group] of Object.entries(groups)){
1429
- const match = routeMatch[group.pos];
1430
- if (match !== undefined) {
1431
- if (group.repeat) {
1432
- params[key] = match.split('/').map((entry)=>decode(entry));
1433
- } else {
1434
- params[key] = decode(match);
1435
- }
1436
- }
1437
- }
1438
- return params;
1439
- };
1440
- }
1441
-
1442
-
1443
- } (routeMatcher));
1444
- return routeMatcher;
1445
- }
1446
-
1447
- var routeRegex = {};
1448
-
1449
- var constants = {};
1450
-
1451
- var hasRequiredConstants;
1452
-
1453
- function requireConstants () {
1454
- if (hasRequiredConstants) return constants;
1455
- hasRequiredConstants = 1;
1456
- (function (exports) {
1457
- Object.defineProperty(exports, "__esModule", {
1458
- value: true
1459
- });
1460
- function _export(target, all) {
1461
- for(var name in all)Object.defineProperty(target, name, {
1462
- enumerable: true,
1463
- get: all[name]
1464
- });
1465
- }
1466
- _export(exports, {
1467
- ACTION_SUFFIX: function() {
1468
- return ACTION_SUFFIX;
1469
- },
1470
- APP_DIR_ALIAS: function() {
1471
- return APP_DIR_ALIAS;
1472
- },
1473
- CACHE_ONE_YEAR: function() {
1474
- return CACHE_ONE_YEAR;
1475
- },
1476
- DOT_NEXT_ALIAS: function() {
1477
- return DOT_NEXT_ALIAS;
1478
- },
1479
- ESLINT_DEFAULT_DIRS: function() {
1480
- return ESLINT_DEFAULT_DIRS;
1481
- },
1482
- GSP_NO_RETURNED_VALUE: function() {
1483
- return GSP_NO_RETURNED_VALUE;
1484
- },
1485
- GSSP_COMPONENT_MEMBER_ERROR: function() {
1486
- return GSSP_COMPONENT_MEMBER_ERROR;
1487
- },
1488
- GSSP_NO_RETURNED_VALUE: function() {
1489
- return GSSP_NO_RETURNED_VALUE;
1490
- },
1491
- INFINITE_CACHE: function() {
1492
- return INFINITE_CACHE;
1493
- },
1494
- INSTRUMENTATION_HOOK_FILENAME: function() {
1495
- return INSTRUMENTATION_HOOK_FILENAME;
1496
- },
1497
- MATCHED_PATH_HEADER: function() {
1498
- return MATCHED_PATH_HEADER;
1499
- },
1500
- MIDDLEWARE_FILENAME: function() {
1501
- return MIDDLEWARE_FILENAME;
1502
- },
1503
- MIDDLEWARE_LOCATION_REGEXP: function() {
1504
- return MIDDLEWARE_LOCATION_REGEXP;
1505
- },
1506
- NEXT_BODY_SUFFIX: function() {
1507
- return NEXT_BODY_SUFFIX;
1508
- },
1509
- NEXT_CACHE_IMPLICIT_TAG_ID: function() {
1510
- return NEXT_CACHE_IMPLICIT_TAG_ID;
1511
- },
1512
- NEXT_CACHE_REVALIDATED_TAGS_HEADER: function() {
1513
- return NEXT_CACHE_REVALIDATED_TAGS_HEADER;
1514
- },
1515
- NEXT_CACHE_REVALIDATE_TAG_TOKEN_HEADER: function() {
1516
- return NEXT_CACHE_REVALIDATE_TAG_TOKEN_HEADER;
1517
- },
1518
- NEXT_CACHE_SOFT_TAG_MAX_LENGTH: function() {
1519
- return NEXT_CACHE_SOFT_TAG_MAX_LENGTH;
1520
- },
1521
- NEXT_CACHE_TAGS_HEADER: function() {
1522
- return NEXT_CACHE_TAGS_HEADER;
1523
- },
1524
- NEXT_CACHE_TAG_MAX_ITEMS: function() {
1525
- return NEXT_CACHE_TAG_MAX_ITEMS;
1526
- },
1527
- NEXT_CACHE_TAG_MAX_LENGTH: function() {
1528
- return NEXT_CACHE_TAG_MAX_LENGTH;
1529
- },
1530
- NEXT_DATA_SUFFIX: function() {
1531
- return NEXT_DATA_SUFFIX;
1532
- },
1533
- NEXT_INTERCEPTION_MARKER_PREFIX: function() {
1534
- return NEXT_INTERCEPTION_MARKER_PREFIX;
1535
- },
1536
- NEXT_META_SUFFIX: function() {
1537
- return NEXT_META_SUFFIX;
1538
- },
1539
- NEXT_QUERY_PARAM_PREFIX: function() {
1540
- return NEXT_QUERY_PARAM_PREFIX;
1541
- },
1542
- NEXT_RESUME_HEADER: function() {
1543
- return NEXT_RESUME_HEADER;
1544
- },
1545
- NON_STANDARD_NODE_ENV: function() {
1546
- return NON_STANDARD_NODE_ENV;
1547
- },
1548
- PAGES_DIR_ALIAS: function() {
1549
- return PAGES_DIR_ALIAS;
1550
- },
1551
- PRERENDER_REVALIDATE_HEADER: function() {
1552
- return PRERENDER_REVALIDATE_HEADER;
1553
- },
1554
- PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER: function() {
1555
- return PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER;
1556
- },
1557
- PUBLIC_DIR_MIDDLEWARE_CONFLICT: function() {
1558
- return PUBLIC_DIR_MIDDLEWARE_CONFLICT;
1559
- },
1560
- ROOT_DIR_ALIAS: function() {
1561
- return ROOT_DIR_ALIAS;
1562
- },
1563
- RSC_ACTION_CLIENT_WRAPPER_ALIAS: function() {
1564
- return RSC_ACTION_CLIENT_WRAPPER_ALIAS;
1565
- },
1566
- RSC_ACTION_ENCRYPTION_ALIAS: function() {
1567
- return RSC_ACTION_ENCRYPTION_ALIAS;
1568
- },
1569
- RSC_ACTION_PROXY_ALIAS: function() {
1570
- return RSC_ACTION_PROXY_ALIAS;
1571
- },
1572
- RSC_ACTION_VALIDATE_ALIAS: function() {
1573
- return RSC_ACTION_VALIDATE_ALIAS;
1574
- },
1575
- RSC_CACHE_WRAPPER_ALIAS: function() {
1576
- return RSC_CACHE_WRAPPER_ALIAS;
1577
- },
1578
- RSC_MOD_REF_PROXY_ALIAS: function() {
1579
- return RSC_MOD_REF_PROXY_ALIAS;
1580
- },
1581
- RSC_PREFETCH_SUFFIX: function() {
1582
- return RSC_PREFETCH_SUFFIX;
1583
- },
1584
- RSC_SEGMENTS_DIR_SUFFIX: function() {
1585
- return RSC_SEGMENTS_DIR_SUFFIX;
1586
- },
1587
- RSC_SEGMENT_SUFFIX: function() {
1588
- return RSC_SEGMENT_SUFFIX;
1589
- },
1590
- RSC_SUFFIX: function() {
1591
- return RSC_SUFFIX;
1592
- },
1593
- SERVER_PROPS_EXPORT_ERROR: function() {
1594
- return SERVER_PROPS_EXPORT_ERROR;
1595
- },
1596
- SERVER_PROPS_GET_INIT_PROPS_CONFLICT: function() {
1597
- return SERVER_PROPS_GET_INIT_PROPS_CONFLICT;
1598
- },
1599
- SERVER_PROPS_SSG_CONFLICT: function() {
1600
- return SERVER_PROPS_SSG_CONFLICT;
1601
- },
1602
- SERVER_RUNTIME: function() {
1603
- return SERVER_RUNTIME;
1604
- },
1605
- SSG_FALLBACK_EXPORT_ERROR: function() {
1606
- return SSG_FALLBACK_EXPORT_ERROR;
1607
- },
1608
- SSG_GET_INITIAL_PROPS_CONFLICT: function() {
1609
- return SSG_GET_INITIAL_PROPS_CONFLICT;
1610
- },
1611
- STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR: function() {
1612
- return STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR;
1613
- },
1614
- UNSTABLE_REVALIDATE_RENAME_ERROR: function() {
1615
- return UNSTABLE_REVALIDATE_RENAME_ERROR;
1616
- },
1617
- WEBPACK_LAYERS: function() {
1618
- return WEBPACK_LAYERS;
1619
- },
1620
- WEBPACK_RESOURCE_QUERIES: function() {
1621
- return WEBPACK_RESOURCE_QUERIES;
1622
- }
1623
- });
1624
- const NEXT_QUERY_PARAM_PREFIX = 'nxtP';
1625
- const NEXT_INTERCEPTION_MARKER_PREFIX = 'nxtI';
1626
- const MATCHED_PATH_HEADER = 'x-matched-path';
1627
- const PRERENDER_REVALIDATE_HEADER = 'x-prerender-revalidate';
1628
- const PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER = 'x-prerender-revalidate-if-generated';
1629
- const RSC_PREFETCH_SUFFIX = '.prefetch.rsc';
1630
- const RSC_SEGMENTS_DIR_SUFFIX = '.segments';
1631
- const RSC_SEGMENT_SUFFIX = '.segment.rsc';
1632
- const RSC_SUFFIX = '.rsc';
1633
- const ACTION_SUFFIX = '.action';
1634
- const NEXT_DATA_SUFFIX = '.json';
1635
- const NEXT_META_SUFFIX = '.meta';
1636
- const NEXT_BODY_SUFFIX = '.body';
1637
- const NEXT_CACHE_TAGS_HEADER = 'x-next-cache-tags';
1638
- const NEXT_CACHE_REVALIDATED_TAGS_HEADER = 'x-next-revalidated-tags';
1639
- const NEXT_CACHE_REVALIDATE_TAG_TOKEN_HEADER = 'x-next-revalidate-tag-token';
1640
- const NEXT_RESUME_HEADER = 'next-resume';
1641
- const NEXT_CACHE_TAG_MAX_ITEMS = 128;
1642
- const NEXT_CACHE_TAG_MAX_LENGTH = 256;
1643
- const NEXT_CACHE_SOFT_TAG_MAX_LENGTH = 1024;
1644
- const NEXT_CACHE_IMPLICIT_TAG_ID = '_N_T_';
1645
- const CACHE_ONE_YEAR = 31536000;
1646
- const INFINITE_CACHE = 0xfffffffe;
1647
- const MIDDLEWARE_FILENAME = 'middleware';
1648
- const MIDDLEWARE_LOCATION_REGEXP = `(?:src/)?${MIDDLEWARE_FILENAME}`;
1649
- const INSTRUMENTATION_HOOK_FILENAME = 'instrumentation';
1650
- const PAGES_DIR_ALIAS = 'private-next-pages';
1651
- const DOT_NEXT_ALIAS = 'private-dot-next';
1652
- const ROOT_DIR_ALIAS = 'private-next-root-dir';
1653
- const APP_DIR_ALIAS = 'private-next-app-dir';
1654
- const RSC_MOD_REF_PROXY_ALIAS = 'private-next-rsc-mod-ref-proxy';
1655
- const RSC_ACTION_VALIDATE_ALIAS = 'private-next-rsc-action-validate';
1656
- const RSC_ACTION_PROXY_ALIAS = 'private-next-rsc-server-reference';
1657
- const RSC_CACHE_WRAPPER_ALIAS = 'private-next-rsc-cache-wrapper';
1658
- const RSC_ACTION_ENCRYPTION_ALIAS = 'private-next-rsc-action-encryption';
1659
- const RSC_ACTION_CLIENT_WRAPPER_ALIAS = 'private-next-rsc-action-client-wrapper';
1660
- const PUBLIC_DIR_MIDDLEWARE_CONFLICT = `You can not have a '_next' folder inside of your public folder. This conflicts with the internal '/_next' route. https://nextjs.org/docs/messages/public-next-folder-conflict`;
1661
- const SSG_GET_INITIAL_PROPS_CONFLICT = `You can not use getInitialProps with getStaticProps. To use SSG, please remove your getInitialProps`;
1662
- const SERVER_PROPS_GET_INIT_PROPS_CONFLICT = `You can not use getInitialProps with getServerSideProps. Please remove getInitialProps.`;
1663
- const SERVER_PROPS_SSG_CONFLICT = `You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps`;
1664
- const STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR = `can not have getInitialProps/getServerSideProps, https://nextjs.org/docs/messages/404-get-initial-props`;
1665
- const SERVER_PROPS_EXPORT_ERROR = `pages with \`getServerSideProps\` can not be exported. See more info here: https://nextjs.org/docs/messages/gssp-export`;
1666
- const GSP_NO_RETURNED_VALUE = 'Your `getStaticProps` function did not return an object. Did you forget to add a `return`?';
1667
- const GSSP_NO_RETURNED_VALUE = 'Your `getServerSideProps` function did not return an object. Did you forget to add a `return`?';
1668
- const UNSTABLE_REVALIDATE_RENAME_ERROR = 'The `unstable_revalidate` property is available for general use.\n' + 'Please use `revalidate` instead.';
1669
- const GSSP_COMPONENT_MEMBER_ERROR = `can not be attached to a page's component and must be exported from the page. See more info here: https://nextjs.org/docs/messages/gssp-component-member`;
1670
- const NON_STANDARD_NODE_ENV = `You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env`;
1671
- const SSG_FALLBACK_EXPORT_ERROR = `Pages with \`fallback\` enabled in \`getStaticPaths\` can not be exported. See more info here: https://nextjs.org/docs/messages/ssg-fallback-true-export`;
1672
- const ESLINT_DEFAULT_DIRS = [
1673
- 'app',
1674
- 'pages',
1675
- 'components',
1676
- 'lib',
1677
- 'src'
1678
- ];
1679
- const SERVER_RUNTIME = {
1680
- edge: 'edge',
1681
- experimentalEdge: 'experimental-edge',
1682
- nodejs: 'nodejs'
1683
- };
1684
- /**
1685
- * The names of the webpack layers. These layers are the primitives for the
1686
- * webpack chunks.
1687
- */ const WEBPACK_LAYERS_NAMES = {
1688
- /**
1689
- * The layer for the shared code between the client and server bundles.
1690
- */ shared: 'shared',
1691
- /**
1692
- * The layer for server-only runtime and picking up `react-server` export conditions.
1693
- * Including app router RSC pages and app router custom routes and metadata routes.
1694
- */ reactServerComponents: 'rsc',
1695
- /**
1696
- * Server Side Rendering layer for app (ssr).
1697
- */ serverSideRendering: 'ssr',
1698
- /**
1699
- * The browser client bundle layer for actions.
1700
- */ actionBrowser: 'action-browser',
1701
- /**
1702
- * The Node.js bundle layer for the API routes.
1703
- */ apiNode: 'api-node',
1704
- /**
1705
- * The Edge Lite bundle layer for the API routes.
1706
- */ apiEdge: 'api-edge',
1707
- /**
1708
- * The layer for the middleware code.
1709
- */ middleware: 'middleware',
1710
- /**
1711
- * The layer for the instrumentation hooks.
1712
- */ instrument: 'instrument',
1713
- /**
1714
- * The layer for assets on the edge.
1715
- */ edgeAsset: 'edge-asset',
1716
- /**
1717
- * The browser client bundle layer for App directory.
1718
- */ appPagesBrowser: 'app-pages-browser',
1719
- /**
1720
- * The browser client bundle layer for Pages directory.
1721
- */ pagesDirBrowser: 'pages-dir-browser',
1722
- /**
1723
- * The Edge Lite bundle layer for Pages directory.
1724
- */ pagesDirEdge: 'pages-dir-edge',
1725
- /**
1726
- * The Node.js bundle layer for Pages directory.
1727
- */ pagesDirNode: 'pages-dir-node'
1728
- };
1729
- const WEBPACK_LAYERS = {
1730
- ...WEBPACK_LAYERS_NAMES,
1731
- GROUP: {
1732
- builtinReact: [
1733
- WEBPACK_LAYERS_NAMES.reactServerComponents,
1734
- WEBPACK_LAYERS_NAMES.actionBrowser
1735
- ],
1736
- serverOnly: [
1737
- WEBPACK_LAYERS_NAMES.reactServerComponents,
1738
- WEBPACK_LAYERS_NAMES.actionBrowser,
1739
- WEBPACK_LAYERS_NAMES.instrument,
1740
- WEBPACK_LAYERS_NAMES.middleware
1741
- ],
1742
- neutralTarget: [
1743
- // pages api
1744
- WEBPACK_LAYERS_NAMES.apiNode,
1745
- WEBPACK_LAYERS_NAMES.apiEdge
1746
- ],
1747
- clientOnly: [
1748
- WEBPACK_LAYERS_NAMES.serverSideRendering,
1749
- WEBPACK_LAYERS_NAMES.appPagesBrowser
1750
- ],
1751
- bundled: [
1752
- WEBPACK_LAYERS_NAMES.reactServerComponents,
1753
- WEBPACK_LAYERS_NAMES.actionBrowser,
1754
- WEBPACK_LAYERS_NAMES.serverSideRendering,
1755
- WEBPACK_LAYERS_NAMES.appPagesBrowser,
1756
- WEBPACK_LAYERS_NAMES.shared,
1757
- WEBPACK_LAYERS_NAMES.instrument,
1758
- WEBPACK_LAYERS_NAMES.middleware
1759
- ],
1760
- appPages: [
1761
- // app router pages and layouts
1762
- WEBPACK_LAYERS_NAMES.reactServerComponents,
1763
- WEBPACK_LAYERS_NAMES.serverSideRendering,
1764
- WEBPACK_LAYERS_NAMES.appPagesBrowser,
1765
- WEBPACK_LAYERS_NAMES.actionBrowser
1766
- ]
1767
- }
1768
- };
1769
- const WEBPACK_RESOURCE_QUERIES = {
1770
- edgeSSREntry: '__next_edge_ssr_entry__',
1771
- metadata: '__next_metadata__',
1772
- metadataRoute: '__next_metadata_route__',
1773
- metadataImageMeta: '__next_metadata_image_meta__'
1774
- };
1775
-
1776
-
1777
- } (constants));
1778
- return constants;
1779
- }
1780
-
1781
- var escapeRegexp = {};
1782
-
1783
- var hasRequiredEscapeRegexp;
1784
-
1785
- function requireEscapeRegexp () {
1786
- if (hasRequiredEscapeRegexp) return escapeRegexp;
1787
- hasRequiredEscapeRegexp = 1;
1788
- (function (exports) {
1789
- Object.defineProperty(exports, "__esModule", {
1790
- value: true
1791
- });
1792
- Object.defineProperty(exports, "escapeStringRegexp", {
1793
- enumerable: true,
1794
- get: function() {
1795
- return escapeStringRegexp;
1796
- }
1797
- });
1798
- const reHasRegExp = /[|\\{}()[\]^$+*?.-]/;
1799
- const reReplaceRegExp = /[|\\{}()[\]^$+*?.-]/g;
1800
- function escapeStringRegexp(str) {
1801
- // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23
1802
- if (reHasRegExp.test(str)) {
1803
- return str.replace(reReplaceRegExp, '\\$&');
1804
- }
1805
- return str;
1806
- }
1807
-
1808
-
1809
- } (escapeRegexp));
1810
- return escapeRegexp;
1811
- }
1812
-
1813
- var hasRequiredRouteRegex;
1814
-
1815
- function requireRouteRegex () {
1816
- if (hasRequiredRouteRegex) return routeRegex;
1817
- hasRequiredRouteRegex = 1;
1818
- (function (exports) {
1819
- Object.defineProperty(exports, "__esModule", {
1820
- value: true
1821
- });
1822
- function _export(target, all) {
1823
- for(var name in all)Object.defineProperty(target, name, {
1824
- enumerable: true,
1825
- get: all[name]
1826
- });
1827
- }
1828
- _export(exports, {
1829
- getNamedMiddlewareRegex: function() {
1830
- return getNamedMiddlewareRegex;
1831
- },
1832
- getNamedRouteRegex: function() {
1833
- return getNamedRouteRegex;
1834
- },
1835
- getRouteRegex: function() {
1836
- return getRouteRegex;
1837
- },
1838
- parseParameter: function() {
1839
- return parseParameter;
1840
- }
1841
- });
1842
- const _constants = requireConstants();
1843
- const _interceptionroutes = requireInterceptionRoutes();
1844
- const _escaperegexp = requireEscapeRegexp();
1845
- const _removetrailingslash = requireRemoveTrailingSlash();
1846
- /**
1847
- * Regular expression pattern used to match route parameters.
1848
- * Matches both single parameters and parameter groups.
1849
- * Examples:
1850
- * - `[[...slug]]` matches parameter group with key 'slug', repeat: true, optional: true
1851
- * - `[...slug]` matches parameter group with key 'slug', repeat: true, optional: false
1852
- * - `[[foo]]` matches parameter with key 'foo', repeat: false, optional: true
1853
- * - `[bar]` matches parameter with key 'bar', repeat: false, optional: false
1854
- */ const PARAMETER_PATTERN = /^([^[]*)\[((?:\[[^\]]*\])|[^\]]+)\](.*)$/;
1855
- function parseParameter(param) {
1856
- const match = param.match(PARAMETER_PATTERN);
1857
- if (!match) {
1858
- return parseMatchedParameter(param);
1859
- }
1860
- return parseMatchedParameter(match[2]);
1861
- }
1862
- /**
1863
- * Parses a matched parameter from the PARAMETER_PATTERN regex to a data structure that can be used
1864
- * to generate the parametrized route.
1865
- * Examples:
1866
- * - `[...slug]` -> `{ key: 'slug', repeat: true, optional: true }`
1867
- * - `...slug` -> `{ key: 'slug', repeat: true, optional: false }`
1868
- * - `[foo]` -> `{ key: 'foo', repeat: false, optional: true }`
1869
- * - `bar` -> `{ key: 'bar', repeat: false, optional: false }`
1870
- * @param param - The matched parameter to parse.
1871
- * @returns The parsed parameter as a data structure.
1872
- */ function parseMatchedParameter(param) {
1873
- const optional = param.startsWith('[') && param.endsWith(']');
1874
- if (optional) {
1875
- param = param.slice(1, -1);
1876
- }
1877
- const repeat = param.startsWith('...');
1878
- if (repeat) {
1879
- param = param.slice(3);
1880
- }
1881
- return {
1882
- key: param,
1883
- repeat,
1884
- optional
1885
- };
1886
- }
1887
- function getParametrizedRoute(route, includeSuffix, includePrefix) {
1888
- const groups = {};
1889
- let groupIndex = 1;
1890
- const segments = [];
1891
- for (const segment of (0, _removetrailingslash.removeTrailingSlash)(route).slice(1).split('/')){
1892
- const markerMatch = _interceptionroutes.INTERCEPTION_ROUTE_MARKERS.find((m)=>segment.startsWith(m));
1893
- const paramMatches = segment.match(PARAMETER_PATTERN) // Check for parameters
1894
- ;
1895
- if (markerMatch && paramMatches && paramMatches[2]) {
1896
- const { key, optional, repeat } = parseMatchedParameter(paramMatches[2]);
1897
- groups[key] = {
1898
- pos: groupIndex++,
1899
- repeat,
1900
- optional
1901
- };
1902
- segments.push("/" + (0, _escaperegexp.escapeStringRegexp)(markerMatch) + "([^/]+?)");
1903
- } else if (paramMatches && paramMatches[2]) {
1904
- const { key, repeat, optional } = parseMatchedParameter(paramMatches[2]);
1905
- groups[key] = {
1906
- pos: groupIndex++,
1907
- repeat,
1908
- optional
1909
- };
1910
- if (includePrefix && paramMatches[1]) {
1911
- segments.push("/" + (0, _escaperegexp.escapeStringRegexp)(paramMatches[1]));
1912
- }
1913
- let s = repeat ? optional ? '(?:/(.+?))?' : '/(.+?)' : '/([^/]+?)';
1914
- // Remove the leading slash if includePrefix already added it.
1915
- if (includePrefix && paramMatches[1]) {
1916
- s = s.substring(1);
1917
- }
1918
- segments.push(s);
1919
- } else {
1920
- segments.push("/" + (0, _escaperegexp.escapeStringRegexp)(segment));
1921
- }
1922
- // If there's a suffix, add it to the segments if it's enabled.
1923
- if (includeSuffix && paramMatches && paramMatches[3]) {
1924
- segments.push((0, _escaperegexp.escapeStringRegexp)(paramMatches[3]));
1925
- }
1926
- }
1927
- return {
1928
- parameterizedRoute: segments.join(''),
1929
- groups
1930
- };
1931
- }
1932
- function getRouteRegex(normalizedRoute, param) {
1933
- let { includeSuffix = false, includePrefix = false, excludeOptionalTrailingSlash = false } = param === void 0 ? {} : param;
1934
- const { parameterizedRoute, groups } = getParametrizedRoute(normalizedRoute, includeSuffix, includePrefix);
1935
- let re = parameterizedRoute;
1936
- if (!excludeOptionalTrailingSlash) {
1937
- re += '(?:/)?';
1938
- }
1939
- return {
1940
- re: new RegExp("^" + re + "$"),
1941
- groups: groups
1942
- };
1943
- }
1944
- /**
1945
- * Builds a function to generate a minimal routeKey using only a-z and minimal
1946
- * number of characters.
1947
- */ function buildGetSafeRouteKey() {
1948
- let i = 0;
1949
- return ()=>{
1950
- let routeKey = '';
1951
- let j = ++i;
1952
- while(j > 0){
1953
- routeKey += String.fromCharCode(97 + (j - 1) % 26);
1954
- j = Math.floor((j - 1) / 26);
1955
- }
1956
- return routeKey;
1957
- };
1958
- }
1959
- function getSafeKeyFromSegment(param) {
1960
- let { interceptionMarker, getSafeRouteKey, segment, routeKeys, keyPrefix, backreferenceDuplicateKeys } = param;
1961
- const { key, optional, repeat } = parseMatchedParameter(segment);
1962
- // replace any non-word characters since they can break
1963
- // the named regex
1964
- let cleanedKey = key.replace(/\W/g, '');
1965
- if (keyPrefix) {
1966
- cleanedKey = "" + keyPrefix + cleanedKey;
1967
- }
1968
- let invalidKey = false;
1969
- // check if the key is still invalid and fallback to using a known
1970
- // safe key
1971
- if (cleanedKey.length === 0 || cleanedKey.length > 30) {
1972
- invalidKey = true;
1973
- }
1974
- if (!isNaN(parseInt(cleanedKey.slice(0, 1)))) {
1975
- invalidKey = true;
1976
- }
1977
- if (invalidKey) {
1978
- cleanedKey = getSafeRouteKey();
1979
- }
1980
- const duplicateKey = cleanedKey in routeKeys;
1981
- if (keyPrefix) {
1982
- routeKeys[cleanedKey] = "" + keyPrefix + key;
1983
- } else {
1984
- routeKeys[cleanedKey] = key;
1985
- }
1986
- // if the segment has an interception marker, make sure that's part of the regex pattern
1987
- // this is to ensure that the route with the interception marker doesn't incorrectly match
1988
- // the non-intercepted route (ie /app/(.)[username] should not match /app/[username])
1989
- const interceptionPrefix = interceptionMarker ? (0, _escaperegexp.escapeStringRegexp)(interceptionMarker) : '';
1990
- let pattern;
1991
- if (duplicateKey && backreferenceDuplicateKeys) {
1992
- // Use a backreference to the key to ensure that the key is the same value
1993
- // in each of the placeholders.
1994
- pattern = "\\k<" + cleanedKey + ">";
1995
- } else if (repeat) {
1996
- pattern = "(?<" + cleanedKey + ">.+?)";
1997
- } else {
1998
- pattern = "(?<" + cleanedKey + ">[^/]+?)";
1999
- }
2000
- return optional ? "(?:/" + interceptionPrefix + pattern + ")?" : "/" + interceptionPrefix + pattern;
2001
- }
2002
- function getNamedParametrizedRoute(route, prefixRouteKeys, includeSuffix, includePrefix, backreferenceDuplicateKeys) {
2003
- const getSafeRouteKey = buildGetSafeRouteKey();
2004
- const routeKeys = {};
2005
- const segments = [];
2006
- for (const segment of (0, _removetrailingslash.removeTrailingSlash)(route).slice(1).split('/')){
2007
- const hasInterceptionMarker = _interceptionroutes.INTERCEPTION_ROUTE_MARKERS.some((m)=>segment.startsWith(m));
2008
- const paramMatches = segment.match(PARAMETER_PATTERN) // Check for parameters
2009
- ;
2010
- if (hasInterceptionMarker && paramMatches && paramMatches[2]) {
2011
- // If there's an interception marker, add it to the segments.
2012
- segments.push(getSafeKeyFromSegment({
2013
- getSafeRouteKey,
2014
- interceptionMarker: paramMatches[1],
2015
- segment: paramMatches[2],
2016
- routeKeys,
2017
- keyPrefix: prefixRouteKeys ? _constants.NEXT_INTERCEPTION_MARKER_PREFIX : undefined,
2018
- backreferenceDuplicateKeys
2019
- }));
2020
- } else if (paramMatches && paramMatches[2]) {
2021
- // If there's a prefix, add it to the segments if it's enabled.
2022
- if (includePrefix && paramMatches[1]) {
2023
- segments.push("/" + (0, _escaperegexp.escapeStringRegexp)(paramMatches[1]));
2024
- }
2025
- let s = getSafeKeyFromSegment({
2026
- getSafeRouteKey,
2027
- segment: paramMatches[2],
2028
- routeKeys,
2029
- keyPrefix: prefixRouteKeys ? _constants.NEXT_QUERY_PARAM_PREFIX : undefined,
2030
- backreferenceDuplicateKeys
2031
- });
2032
- // Remove the leading slash if includePrefix already added it.
2033
- if (includePrefix && paramMatches[1]) {
2034
- s = s.substring(1);
2035
- }
2036
- segments.push(s);
2037
- } else {
2038
- segments.push("/" + (0, _escaperegexp.escapeStringRegexp)(segment));
2039
- }
2040
- // If there's a suffix, add it to the segments if it's enabled.
2041
- if (includeSuffix && paramMatches && paramMatches[3]) {
2042
- segments.push((0, _escaperegexp.escapeStringRegexp)(paramMatches[3]));
2043
- }
2044
- }
2045
- return {
2046
- namedParameterizedRoute: segments.join(''),
2047
- routeKeys
2048
- };
2049
- }
2050
- function getNamedRouteRegex(normalizedRoute, options) {
2051
- var _options_includeSuffix, _options_includePrefix, _options_backreferenceDuplicateKeys;
2052
- const result = getNamedParametrizedRoute(normalizedRoute, options.prefixRouteKeys, (_options_includeSuffix = options.includeSuffix) != null ? _options_includeSuffix : false, (_options_includePrefix = options.includePrefix) != null ? _options_includePrefix : false, (_options_backreferenceDuplicateKeys = options.backreferenceDuplicateKeys) != null ? _options_backreferenceDuplicateKeys : false);
2053
- let namedRegex = result.namedParameterizedRoute;
2054
- if (!options.excludeOptionalTrailingSlash) {
2055
- namedRegex += '(?:/)?';
2056
- }
2057
- return {
2058
- ...getRouteRegex(normalizedRoute, options),
2059
- namedRegex: "^" + namedRegex + "$",
2060
- routeKeys: result.routeKeys
2061
- };
2062
- }
2063
- function getNamedMiddlewareRegex(normalizedRoute, options) {
2064
- const { parameterizedRoute } = getParametrizedRoute(normalizedRoute, false, false);
2065
- const { catchAll = true } = options;
2066
- if (parameterizedRoute === '/') {
2067
- let catchAllRegex = catchAll ? '.*' : '';
2068
- return {
2069
- namedRegex: "^/" + catchAllRegex + "$"
2070
- };
2071
- }
2072
- const { namedParameterizedRoute } = getNamedParametrizedRoute(normalizedRoute, false, false, false, false);
2073
- let catchAllGroupedRegex = catchAll ? '(?:(/.*)?)' : '';
2074
- return {
2075
- namedRegex: "^" + namedParameterizedRoute + catchAllGroupedRegex + "$"
2076
- };
2077
- }
2078
-
2079
-
2080
- } (routeRegex));
2081
- return routeRegex;
2082
- }
2083
-
2084
- var hasRequiredInterpolateAs;
2085
-
2086
- function requireInterpolateAs () {
2087
- if (hasRequiredInterpolateAs) return interpolateAs;
2088
- hasRequiredInterpolateAs = 1;
2089
- (function (exports) {
2090
- Object.defineProperty(exports, "__esModule", {
2091
- value: true
2092
- });
2093
- Object.defineProperty(exports, "interpolateAs", {
2094
- enumerable: true,
2095
- get: function() {
2096
- return interpolateAs;
2097
- }
2098
- });
2099
- const _routematcher = requireRouteMatcher();
2100
- const _routeregex = requireRouteRegex();
2101
- function interpolateAs(route, asPathname, query) {
2102
- let interpolatedRoute = '';
2103
- const dynamicRegex = (0, _routeregex.getRouteRegex)(route);
2104
- const dynamicGroups = dynamicRegex.groups;
2105
- const dynamicMatches = // Try to match the dynamic route against the asPath
2106
- (asPathname !== route ? (0, _routematcher.getRouteMatcher)(dynamicRegex)(asPathname) : '') || // Fall back to reading the values from the href
2107
- // TODO: should this take priority; also need to change in the router.
2108
- query;
2109
- interpolatedRoute = route;
2110
- const params = Object.keys(dynamicGroups);
2111
- if (!params.every((param)=>{
2112
- let value = dynamicMatches[param] || '';
2113
- const { repeat, optional } = dynamicGroups[param];
2114
- // support single-level catch-all
2115
- // TODO: more robust handling for user-error (passing `/`)
2116
- let replaced = "[" + (repeat ? '...' : '') + param + "]";
2117
- if (optional) {
2118
- replaced = (!value ? '/' : '') + "[" + replaced + "]";
2119
- }
2120
- if (repeat && !Array.isArray(value)) value = [
2121
- value
2122
- ];
2123
- return (optional || param in dynamicMatches) && // Interpolate group into data URL if present
2124
- (interpolatedRoute = interpolatedRoute.replace(replaced, repeat ? value.map(// these values should be fully encoded instead of just
2125
- // path delimiter escaped since they are being inserted
2126
- // into the URL and we expect URL encoded segments
2127
- // when parsing dynamic route params
2128
- (segment)=>encodeURIComponent(segment)).join('/') : encodeURIComponent(value)) || '/');
2129
- })) {
2130
- interpolatedRoute = '' // did not satisfy all requirements
2131
- ;
2132
- // n.b. We ignore this error because we handle warning for this case in
2133
- // development in the `<Link>` component directly.
2134
- }
2135
- return {
2136
- params,
2137
- result: interpolatedRoute
2138
- };
2139
- }
2140
-
2141
-
2142
- } (interpolateAs));
2143
- return interpolateAs;
2144
- }
2145
-
2146
- var hasRequiredResolveHref;
2147
-
2148
- function requireResolveHref () {
2149
- if (hasRequiredResolveHref) return resolveHref.exports;
2150
- hasRequiredResolveHref = 1;
2151
- (function (module, exports) {
2152
- Object.defineProperty(exports, "__esModule", {
2153
- value: true
2154
- });
2155
- Object.defineProperty(exports, "resolveHref", {
2156
- enumerable: true,
2157
- get: function() {
2158
- return resolveHref;
2159
- }
2160
- });
2161
- const _querystring = requireQuerystring();
2162
- const _formaturl = requireFormatUrl();
2163
- const _omit = requireOmit();
2164
- const _utils = requireUtils$1();
2165
- const _normalizetrailingslash = requireNormalizeTrailingSlash();
2166
- const _islocalurl = requireIsLocalUrl();
2167
- const _utils1 = requireUtils();
2168
- const _interpolateas = requireInterpolateAs();
2169
- function resolveHref(router, href, resolveAs) {
2170
- // we use a dummy base url for relative urls
2171
- let base;
2172
- let urlAsString = typeof href === 'string' ? href : (0, _formaturl.formatWithValidation)(href);
2173
- // repeated slashes and backslashes in the URL are considered
2174
- // invalid and will never match a Next.js page/file
2175
- const urlProtoMatch = urlAsString.match(/^[a-zA-Z]{1,}:\/\//);
2176
- const urlAsStringNoProto = urlProtoMatch ? urlAsString.slice(urlProtoMatch[0].length) : urlAsString;
2177
- const urlParts = urlAsStringNoProto.split('?', 1);
2178
- if ((urlParts[0] || '').match(/(\/\/|\\)/)) {
2179
- console.error("Invalid href '" + urlAsString + "' passed to next/router in page: '" + router.pathname + "'. Repeated forward-slashes (//) or backslashes \\ are not valid in the href.");
2180
- const normalizedUrl = (0, _utils.normalizeRepeatedSlashes)(urlAsStringNoProto);
2181
- urlAsString = (urlProtoMatch ? urlProtoMatch[0] : '') + normalizedUrl;
2182
- }
2183
- // Return because it cannot be routed by the Next.js router
2184
- if (!(0, _islocalurl.isLocalURL)(urlAsString)) {
2185
- return resolveAs ? [
2186
- urlAsString
2187
- ] : urlAsString;
2188
- }
2189
- try {
2190
- base = new URL(urlAsString.startsWith('#') ? router.asPath : router.pathname, 'http://n');
2191
- } catch (_) {
2192
- // fallback to / for invalid asPath values e.g. //
2193
- base = new URL('/', 'http://n');
2194
- }
2195
- try {
2196
- const finalUrl = new URL(urlAsString, base);
2197
- finalUrl.pathname = (0, _normalizetrailingslash.normalizePathTrailingSlash)(finalUrl.pathname);
2198
- let interpolatedAs = '';
2199
- if ((0, _utils1.isDynamicRoute)(finalUrl.pathname) && finalUrl.searchParams && resolveAs) {
2200
- const query = (0, _querystring.searchParamsToUrlQuery)(finalUrl.searchParams);
2201
- const { result, params } = (0, _interpolateas.interpolateAs)(finalUrl.pathname, finalUrl.pathname, query);
2202
- if (result) {
2203
- interpolatedAs = (0, _formaturl.formatWithValidation)({
2204
- pathname: result,
2205
- hash: finalUrl.hash,
2206
- query: (0, _omit.omit)(query, params)
2207
- });
2208
- }
2209
- }
2210
- // if the origin didn't change, it means we received a relative href
2211
- const resolvedHref = finalUrl.origin === base.origin ? finalUrl.href.slice(finalUrl.origin.length) : finalUrl.href;
2212
- return resolveAs ? [
2213
- resolvedHref,
2214
- interpolatedAs || resolvedHref
2215
- ] : resolvedHref;
2216
- } catch (_) {
2217
- return resolveAs ? [
2218
- urlAsString
2219
- ] : urlAsString;
2220
- }
2221
- }
2222
-
2223
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
2224
- Object.defineProperty(exports.default, '__esModule', { value: true });
2225
- Object.assign(exports.default, exports);
2226
- module.exports = exports.default;
2227
- }
2228
-
2229
-
2230
- } (resolveHref, resolveHref.exports));
2231
- return resolveHref.exports;
2232
- }
2233
-
2234
- var addLocale$1 = {exports: {}};
2235
-
2236
- var addLocale = {};
2237
-
2238
- var addPathPrefix = {};
2239
-
2240
- var hasRequiredAddPathPrefix;
2241
-
2242
- function requireAddPathPrefix () {
2243
- if (hasRequiredAddPathPrefix) return addPathPrefix;
2244
- hasRequiredAddPathPrefix = 1;
2245
- (function (exports) {
2246
- Object.defineProperty(exports, "__esModule", {
2247
- value: true
2248
- });
2249
- Object.defineProperty(exports, "addPathPrefix", {
2250
- enumerable: true,
2251
- get: function() {
2252
- return addPathPrefix;
2253
- }
2254
- });
2255
- const _parsepath = requireParsePath();
2256
- function addPathPrefix(path, prefix) {
2257
- if (!path.startsWith('/') || !prefix) {
2258
- return path;
2259
- }
2260
- const { pathname, query, hash } = (0, _parsepath.parsePath)(path);
2261
- return "" + prefix + pathname + query + hash;
2262
- }
2263
-
2264
-
2265
- } (addPathPrefix));
2266
- return addPathPrefix;
2267
- }
2268
-
2269
- var hasRequiredAddLocale$1;
2270
-
2271
- function requireAddLocale$1 () {
2272
- if (hasRequiredAddLocale$1) return addLocale;
2273
- hasRequiredAddLocale$1 = 1;
2274
- (function (exports) {
2275
- Object.defineProperty(exports, "__esModule", {
2276
- value: true
2277
- });
2278
- Object.defineProperty(exports, "addLocale", {
2279
- enumerable: true,
2280
- get: function() {
2281
- return addLocale;
2282
- }
2283
- });
2284
- const _addpathprefix = requireAddPathPrefix();
2285
- const _pathhasprefix = requirePathHasPrefix();
2286
- function addLocale(path, locale, defaultLocale, ignorePrefix) {
2287
- // If no locale was given or the locale is the default locale, we don't need
2288
- // to prefix the path.
2289
- if (!locale || locale === defaultLocale) return path;
2290
- const lower = path.toLowerCase();
2291
- // If the path is an API path or the path already has the locale prefix, we
2292
- // don't need to prefix the path.
2293
- if (!ignorePrefix) {
2294
- if ((0, _pathhasprefix.pathHasPrefix)(lower, '/api')) return path;
2295
- if ((0, _pathhasprefix.pathHasPrefix)(lower, "/" + locale.toLowerCase())) return path;
2296
- }
2297
- // Add the locale prefix to the path.
2298
- return (0, _addpathprefix.addPathPrefix)(path, "/" + locale);
2299
- }
2300
-
2301
-
2302
- } (addLocale));
2303
- return addLocale;
2304
- }
2305
-
2306
- var hasRequiredAddLocale;
2307
-
2308
- function requireAddLocale () {
2309
- if (hasRequiredAddLocale) return addLocale$1.exports;
2310
- hasRequiredAddLocale = 1;
2311
- (function (module, exports) {
2312
- Object.defineProperty(exports, "__esModule", {
2313
- value: true
2314
- });
2315
- Object.defineProperty(exports, "addLocale", {
2316
- enumerable: true,
2317
- get: function() {
2318
- return addLocale;
2319
- }
2320
- });
2321
- const _normalizetrailingslash = requireNormalizeTrailingSlash();
2322
- const addLocale = function(path) {
2323
- for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
2324
- args[_key - 1] = arguments[_key];
2325
- }
2326
- if (process.env.__NEXT_I18N_SUPPORT) {
2327
- return (0, _normalizetrailingslash.normalizePathTrailingSlash)(requireAddLocale$1().addLocale(path, ...args));
2328
- }
2329
- return path;
2330
- };
2331
-
2332
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
2333
- Object.defineProperty(exports.default, '__esModule', { value: true });
2334
- Object.assign(exports.default, exports);
2335
- module.exports = exports.default;
2336
- }
2337
-
2338
-
2339
- } (addLocale$1, addLocale$1.exports));
2340
- return addLocale$1.exports;
2341
- }
2342
-
2343
- var routerContext_sharedRuntime = {};
2344
-
2345
- var hasRequiredRouterContext_sharedRuntime;
2346
-
2347
- function requireRouterContext_sharedRuntime () {
2348
- if (hasRequiredRouterContext_sharedRuntime) return routerContext_sharedRuntime;
2349
- hasRequiredRouterContext_sharedRuntime = 1;
2350
- (function (exports) {
2351
- Object.defineProperty(exports, "__esModule", {
2352
- value: true
2353
- });
2354
- Object.defineProperty(exports, "RouterContext", {
2355
- enumerable: true,
2356
- get: function() {
2357
- return RouterContext;
2358
- }
2359
- });
2360
- const _interop_require_default = /*@__PURE__*/ navigation.require_interop_require_default();
2361
- const _react = /*#__PURE__*/ _interop_require_default._(require$$0);
2362
- const RouterContext = _react.default.createContext(null);
2363
- if (process.env.NODE_ENV !== 'production') {
2364
- RouterContext.displayName = 'RouterContext';
2365
- }
2366
-
2367
-
2368
- } (routerContext_sharedRuntime));
2369
- return routerContext_sharedRuntime;
2370
- }
2371
-
2372
- var useIntersection = {exports: {}};
2373
-
2374
- var requestIdleCallback = {exports: {}};
2375
-
2376
- var hasRequiredRequestIdleCallback;
2377
-
2378
- function requireRequestIdleCallback () {
2379
- if (hasRequiredRequestIdleCallback) return requestIdleCallback.exports;
2380
- hasRequiredRequestIdleCallback = 1;
2381
- (function (module, exports) {
2382
- Object.defineProperty(exports, "__esModule", {
2383
- value: true
2384
- });
2385
- function _export(target, all) {
2386
- for(var name in all)Object.defineProperty(target, name, {
2387
- enumerable: true,
2388
- get: all[name]
2389
- });
2390
- }
2391
- _export(exports, {
2392
- cancelIdleCallback: function() {
2393
- return cancelIdleCallback;
2394
- },
2395
- requestIdleCallback: function() {
2396
- return requestIdleCallback;
2397
- }
2398
- });
2399
- const requestIdleCallback = typeof self !== 'undefined' && self.requestIdleCallback && self.requestIdleCallback.bind(window) || function(cb) {
2400
- let start = Date.now();
2401
- return self.setTimeout(function() {
2402
- cb({
2403
- didTimeout: false,
2404
- timeRemaining: function() {
2405
- return Math.max(0, 50 - (Date.now() - start));
2406
- }
2407
- });
2408
- }, 1);
2409
- };
2410
- const cancelIdleCallback = typeof self !== 'undefined' && self.cancelIdleCallback && self.cancelIdleCallback.bind(window) || function(id) {
2411
- return clearTimeout(id);
2412
- };
2413
-
2414
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
2415
- Object.defineProperty(exports.default, '__esModule', { value: true });
2416
- Object.assign(exports.default, exports);
2417
- module.exports = exports.default;
2418
- }
2419
-
2420
-
2421
- } (requestIdleCallback, requestIdleCallback.exports));
2422
- return requestIdleCallback.exports;
2423
- }
2424
-
2425
- var hasRequiredUseIntersection;
2426
-
2427
- function requireUseIntersection () {
2428
- if (hasRequiredUseIntersection) return useIntersection.exports;
2429
- hasRequiredUseIntersection = 1;
2430
- (function (module, exports) {
2431
- Object.defineProperty(exports, "__esModule", {
2432
- value: true
2433
- });
2434
- Object.defineProperty(exports, "useIntersection", {
2435
- enumerable: true,
2436
- get: function() {
2437
- return useIntersection;
2438
- }
2439
- });
2440
- const _react = require$$0;
2441
- const _requestidlecallback = requireRequestIdleCallback();
2442
- const hasIntersectionObserver = typeof IntersectionObserver === 'function';
2443
- const observers = new Map();
2444
- const idList = [];
2445
- function createObserver(options) {
2446
- const id = {
2447
- root: options.root || null,
2448
- margin: options.rootMargin || ''
2449
- };
2450
- const existing = idList.find((obj)=>obj.root === id.root && obj.margin === id.margin);
2451
- let instance;
2452
- if (existing) {
2453
- instance = observers.get(existing);
2454
- if (instance) {
2455
- return instance;
2456
- }
2457
- }
2458
- const elements = new Map();
2459
- const observer = new IntersectionObserver((entries)=>{
2460
- entries.forEach((entry)=>{
2461
- const callback = elements.get(entry.target);
2462
- const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
2463
- if (callback && isVisible) {
2464
- callback(isVisible);
2465
- }
2466
- });
2467
- }, options);
2468
- instance = {
2469
- id,
2470
- observer,
2471
- elements
2472
- };
2473
- idList.push(id);
2474
- observers.set(id, instance);
2475
- return instance;
2476
- }
2477
- function observe(element, callback, options) {
2478
- const { id, observer, elements } = createObserver(options);
2479
- elements.set(element, callback);
2480
- observer.observe(element);
2481
- return function unobserve() {
2482
- elements.delete(element);
2483
- observer.unobserve(element);
2484
- // Destroy observer when there's nothing left to watch:
2485
- if (elements.size === 0) {
2486
- observer.disconnect();
2487
- observers.delete(id);
2488
- const index = idList.findIndex((obj)=>obj.root === id.root && obj.margin === id.margin);
2489
- if (index > -1) {
2490
- idList.splice(index, 1);
2491
- }
2492
- }
2493
- };
2494
- }
2495
- function useIntersection(param) {
2496
- let { rootRef, rootMargin, disabled } = param;
2497
- const isDisabled = disabled || !hasIntersectionObserver;
2498
- const [visible, setVisible] = (0, _react.useState)(false);
2499
- const elementRef = (0, _react.useRef)(null);
2500
- const setElement = (0, _react.useCallback)((element)=>{
2501
- elementRef.current = element;
2502
- }, []);
2503
- (0, _react.useEffect)(()=>{
2504
- if (hasIntersectionObserver) {
2505
- if (isDisabled || visible) return;
2506
- const element = elementRef.current;
2507
- if (element && element.tagName) {
2508
- const unobserve = observe(element, (isVisible)=>isVisible && setVisible(isVisible), {
2509
- root: rootRef == null ? void 0 : rootRef.current,
2510
- rootMargin
2511
- });
2512
- return unobserve;
2513
- }
2514
- } else {
2515
- if (!visible) {
2516
- const idleCallback = (0, _requestidlecallback.requestIdleCallback)(()=>setVisible(true));
2517
- return ()=>(0, _requestidlecallback.cancelIdleCallback)(idleCallback);
2518
- }
2519
- }
2520
- // eslint-disable-next-line react-hooks/exhaustive-deps
2521
- }, [
2522
- isDisabled,
2523
- rootMargin,
2524
- rootRef,
2525
- visible,
2526
- elementRef.current
2527
- ]);
2528
- const resetVisible = (0, _react.useCallback)(()=>{
2529
- setVisible(false);
2530
- }, []);
2531
- return [
2532
- setElement,
2533
- visible,
2534
- resetVisible
2535
- ];
2536
- }
2537
-
2538
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
2539
- Object.defineProperty(exports.default, '__esModule', { value: true });
2540
- Object.assign(exports.default, exports);
2541
- module.exports = exports.default;
2542
- }
2543
-
2544
-
2545
- } (useIntersection, useIntersection.exports));
2546
- return useIntersection.exports;
2547
- }
2548
-
2549
- var getDomainLocale = {exports: {}};
2550
-
2551
- var normalizeLocalePath$1 = {exports: {}};
2552
-
2553
- var normalizeLocalePath = {};
2554
-
2555
- var hasRequiredNormalizeLocalePath$1;
2556
-
2557
- function requireNormalizeLocalePath$1 () {
2558
- if (hasRequiredNormalizeLocalePath$1) return normalizeLocalePath;
2559
- hasRequiredNormalizeLocalePath$1 = 1;
2560
- (function (exports) {
2561
- Object.defineProperty(exports, "__esModule", {
2562
- value: true
2563
- });
2564
- Object.defineProperty(exports, "normalizeLocalePath", {
2565
- enumerable: true,
2566
- get: function() {
2567
- return normalizeLocalePath;
2568
- }
2569
- });
2570
- /**
2571
- * A cache of lowercased locales for each list of locales. This is stored as a
2572
- * WeakMap so if the locales are garbage collected, the cache entry will be
2573
- * removed as well.
2574
- */ const cache = new WeakMap();
2575
- function normalizeLocalePath(pathname, locales) {
2576
- // If locales is undefined, return the pathname as is.
2577
- if (!locales) return {
2578
- pathname
2579
- };
2580
- // Get the cached lowercased locales or create a new cache entry.
2581
- let lowercasedLocales = cache.get(locales);
2582
- if (!lowercasedLocales) {
2583
- lowercasedLocales = locales.map((locale)=>locale.toLowerCase());
2584
- cache.set(locales, lowercasedLocales);
2585
- }
2586
- let detectedLocale;
2587
- // The first segment will be empty, because it has a leading `/`. If
2588
- // there is no further segment, there is no locale (or it's the default).
2589
- const segments = pathname.split('/', 2);
2590
- // If there's no second segment (ie, the pathname is just `/`), there's no
2591
- // locale.
2592
- if (!segments[1]) return {
2593
- pathname
2594
- };
2595
- // The second segment will contain the locale part if any.
2596
- const segment = segments[1].toLowerCase();
2597
- // See if the segment matches one of the locales. If it doesn't, there is
2598
- // no locale (or it's the default).
2599
- const index = lowercasedLocales.indexOf(segment);
2600
- if (index < 0) return {
2601
- pathname
2602
- };
2603
- // Return the case-sensitive locale.
2604
- detectedLocale = locales[index];
2605
- // Remove the `/${locale}` part of the pathname.
2606
- pathname = pathname.slice(detectedLocale.length + 1) || '/';
2607
- return {
2608
- pathname,
2609
- detectedLocale
2610
- };
2611
- }
2612
-
2613
-
2614
- } (normalizeLocalePath));
2615
- return normalizeLocalePath;
2616
- }
2617
-
2618
- var hasRequiredNormalizeLocalePath;
2619
-
2620
- function requireNormalizeLocalePath () {
2621
- if (hasRequiredNormalizeLocalePath) return normalizeLocalePath$1.exports;
2622
- hasRequiredNormalizeLocalePath = 1;
2623
- (function (module, exports) {
2624
- Object.defineProperty(exports, "__esModule", {
2625
- value: true
2626
- });
2627
- Object.defineProperty(exports, "normalizeLocalePath", {
2628
- enumerable: true,
2629
- get: function() {
2630
- return normalizeLocalePath;
2631
- }
2632
- });
2633
- const normalizeLocalePath = (pathname, locales)=>{
2634
- if (process.env.__NEXT_I18N_SUPPORT) {
2635
- return requireNormalizeLocalePath$1().normalizeLocalePath(pathname, locales);
2636
- }
2637
- return {
2638
- pathname,
2639
- detectedLocale: undefined
2640
- };
2641
- };
2642
-
2643
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
2644
- Object.defineProperty(exports.default, '__esModule', { value: true });
2645
- Object.assign(exports.default, exports);
2646
- module.exports = exports.default;
2647
- }
2648
-
2649
-
2650
- } (normalizeLocalePath$1, normalizeLocalePath$1.exports));
2651
- return normalizeLocalePath$1.exports;
2652
- }
2653
-
2654
- var detectDomainLocale$1 = {exports: {}};
2655
-
2656
- var detectDomainLocale = {};
2657
-
2658
- var hasRequiredDetectDomainLocale$1;
2659
-
2660
- function requireDetectDomainLocale$1 () {
2661
- if (hasRequiredDetectDomainLocale$1) return detectDomainLocale;
2662
- hasRequiredDetectDomainLocale$1 = 1;
2663
- (function (exports) {
2664
- Object.defineProperty(exports, "__esModule", {
2665
- value: true
2666
- });
2667
- Object.defineProperty(exports, "detectDomainLocale", {
2668
- enumerable: true,
2669
- get: function() {
2670
- return detectDomainLocale;
2671
- }
2672
- });
2673
- function detectDomainLocale(domainItems, hostname, detectedLocale) {
2674
- if (!domainItems) return;
2675
- if (detectedLocale) {
2676
- detectedLocale = detectedLocale.toLowerCase();
2677
- }
2678
- for (const item of domainItems){
2679
- var _item_domain, _item_locales;
2680
- // remove port if present
2681
- const domainHostname = (_item_domain = item.domain) == null ? void 0 : _item_domain.split(':', 1)[0].toLowerCase();
2682
- if (hostname === domainHostname || detectedLocale === item.defaultLocale.toLowerCase() || ((_item_locales = item.locales) == null ? void 0 : _item_locales.some((locale)=>locale.toLowerCase() === detectedLocale))) {
2683
- return item;
2684
- }
2685
- }
2686
- }
2687
-
2688
-
2689
- } (detectDomainLocale));
2690
- return detectDomainLocale;
2691
- }
2692
-
2693
- var hasRequiredDetectDomainLocale;
2694
-
2695
- function requireDetectDomainLocale () {
2696
- if (hasRequiredDetectDomainLocale) return detectDomainLocale$1.exports;
2697
- hasRequiredDetectDomainLocale = 1;
2698
- (function (module, exports) {
2699
- Object.defineProperty(exports, "__esModule", {
2700
- value: true
2701
- });
2702
- Object.defineProperty(exports, "detectDomainLocale", {
2703
- enumerable: true,
2704
- get: function() {
2705
- return detectDomainLocale;
2706
- }
2707
- });
2708
- const detectDomainLocale = function() {
2709
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
2710
- args[_key] = arguments[_key];
2711
- }
2712
- if (process.env.__NEXT_I18N_SUPPORT) {
2713
- return requireDetectDomainLocale$1().detectDomainLocale(...args);
2714
- }
2715
- };
2716
-
2717
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
2718
- Object.defineProperty(exports.default, '__esModule', { value: true });
2719
- Object.assign(exports.default, exports);
2720
- module.exports = exports.default;
2721
- }
2722
-
2723
-
2724
- } (detectDomainLocale$1, detectDomainLocale$1.exports));
2725
- return detectDomainLocale$1.exports;
2726
- }
2727
-
2728
- var hasRequiredGetDomainLocale;
2729
-
2730
- function requireGetDomainLocale () {
2731
- if (hasRequiredGetDomainLocale) return getDomainLocale.exports;
2732
- hasRequiredGetDomainLocale = 1;
2733
- (function (module, exports) {
2734
- Object.defineProperty(exports, "__esModule", {
2735
- value: true
2736
- });
2737
- Object.defineProperty(exports, "getDomainLocale", {
2738
- enumerable: true,
2739
- get: function() {
2740
- return getDomainLocale;
2741
- }
2742
- });
2743
- const _normalizetrailingslash = requireNormalizeTrailingSlash();
2744
- const basePath = process.env.__NEXT_ROUTER_BASEPATH || '';
2745
- function getDomainLocale(path, locale, locales, domainLocales) {
2746
- if (process.env.__NEXT_I18N_SUPPORT) {
2747
- const normalizeLocalePath = requireNormalizeLocalePath().normalizeLocalePath;
2748
- const detectDomainLocale = requireDetectDomainLocale().detectDomainLocale;
2749
- const target = locale || normalizeLocalePath(path, locales).detectedLocale;
2750
- const domain = detectDomainLocale(domainLocales, undefined, target);
2751
- if (domain) {
2752
- const proto = "http" + (domain.http ? '' : 's') + "://";
2753
- const finalLocale = target === domain.defaultLocale ? '' : "/" + target;
2754
- return "" + proto + domain.domain + (0, _normalizetrailingslash.normalizePathTrailingSlash)("" + basePath + finalLocale + path);
2755
- }
2756
- return false;
2757
- } else {
2758
- return false;
2759
- }
2760
- }
2761
-
2762
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
2763
- Object.defineProperty(exports.default, '__esModule', { value: true });
2764
- Object.assign(exports.default, exports);
2765
- module.exports = exports.default;
2766
- }
2767
-
2768
-
2769
- } (getDomainLocale, getDomainLocale.exports));
2770
- return getDomainLocale.exports;
2771
- }
2772
-
2773
- var addBasePath = {exports: {}};
2774
-
2775
- var hasRequiredAddBasePath;
2776
-
2777
- function requireAddBasePath () {
2778
- if (hasRequiredAddBasePath) return addBasePath.exports;
2779
- hasRequiredAddBasePath = 1;
2780
- (function (module, exports) {
2781
- Object.defineProperty(exports, "__esModule", {
2782
- value: true
2783
- });
2784
- Object.defineProperty(exports, "addBasePath", {
2785
- enumerable: true,
2786
- get: function() {
2787
- return addBasePath;
2788
- }
2789
- });
2790
- const _addpathprefix = requireAddPathPrefix();
2791
- const _normalizetrailingslash = requireNormalizeTrailingSlash();
2792
- const basePath = process.env.__NEXT_ROUTER_BASEPATH || '';
2793
- function addBasePath(path, required) {
2794
- return (0, _normalizetrailingslash.normalizePathTrailingSlash)(process.env.__NEXT_MANUAL_CLIENT_BASE_PATH && !required ? path : (0, _addpathprefix.addPathPrefix)(path, basePath));
2795
- }
2796
-
2797
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
2798
- Object.defineProperty(exports.default, '__esModule', { value: true });
2799
- Object.assign(exports.default, exports);
2800
- module.exports = exports.default;
2801
- }
2802
-
2803
-
2804
- } (addBasePath, addBasePath.exports));
2805
- return addBasePath.exports;
2806
- }
2807
-
2808
- var useMergedRef = {exports: {}};
2809
-
2810
- var hasRequiredUseMergedRef;
2811
-
2812
- function requireUseMergedRef () {
2813
- if (hasRequiredUseMergedRef) return useMergedRef.exports;
2814
- hasRequiredUseMergedRef = 1;
2815
- (function (module, exports) {
2816
- Object.defineProperty(exports, "__esModule", {
2817
- value: true
2818
- });
2819
- Object.defineProperty(exports, "useMergedRef", {
2820
- enumerable: true,
2821
- get: function() {
2822
- return useMergedRef;
2823
- }
2824
- });
2825
- const _react = require$$0;
2826
- function useMergedRef(refA, refB) {
2827
- const cleanupA = (0, _react.useRef)(null);
2828
- const cleanupB = (0, _react.useRef)(null);
2829
- // NOTE: In theory, we could skip the wrapping if only one of the refs is non-null.
2830
- // (this happens often if the user doesn't pass a ref to Link/Form/Image)
2831
- // But this can cause us to leak a cleanup-ref into user code (e.g. via `<Link legacyBehavior>`),
2832
- // and the user might pass that ref into ref-merging library that doesn't support cleanup refs
2833
- // (because it hasn't been updated for React 19)
2834
- // which can then cause things to blow up, because a cleanup-returning ref gets called with `null`.
2835
- // So in practice, it's safer to be defensive and always wrap the ref, even on React 19.
2836
- return (0, _react.useCallback)((current)=>{
2837
- if (current === null) {
2838
- const cleanupFnA = cleanupA.current;
2839
- if (cleanupFnA) {
2840
- cleanupA.current = null;
2841
- cleanupFnA();
2842
- }
2843
- const cleanupFnB = cleanupB.current;
2844
- if (cleanupFnB) {
2845
- cleanupB.current = null;
2846
- cleanupFnB();
2847
- }
2848
- } else {
2849
- if (refA) {
2850
- cleanupA.current = applyRef(refA, current);
2851
- }
2852
- if (refB) {
2853
- cleanupB.current = applyRef(refB, current);
2854
- }
2855
- }
2856
- }, [
2857
- refA,
2858
- refB
2859
- ]);
2860
- }
2861
- function applyRef(refA, current) {
2862
- if (typeof refA === 'function') {
2863
- const cleanup = refA(current);
2864
- if (typeof cleanup === 'function') {
2865
- return cleanup;
2866
- } else {
2867
- return ()=>refA(null);
2868
- }
2869
- } else {
2870
- refA.current = current;
2871
- return ()=>{
2872
- refA.current = null;
2873
- };
2874
- }
2875
- }
2876
-
2877
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
2878
- Object.defineProperty(exports.default, '__esModule', { value: true });
2879
- Object.assign(exports.default, exports);
2880
- module.exports = exports.default;
2881
- }
2882
-
2883
-
2884
- } (useMergedRef, useMergedRef.exports));
2885
- return useMergedRef.exports;
2886
- }
2887
-
2888
- var errorOnce = {};
2889
-
2890
- var hasRequiredErrorOnce;
2891
-
2892
- function requireErrorOnce () {
2893
- if (hasRequiredErrorOnce) return errorOnce;
2894
- hasRequiredErrorOnce = 1;
2895
- (function (exports) {
2896
- Object.defineProperty(exports, "__esModule", {
2897
- value: true
2898
- });
2899
- Object.defineProperty(exports, "errorOnce", {
2900
- enumerable: true,
2901
- get: function() {
2902
- return errorOnce;
2903
- }
2904
- });
2905
- let errorOnce = (_)=>{};
2906
- if (process.env.NODE_ENV !== 'production') {
2907
- const errors = new Set();
2908
- errorOnce = (msg)=>{
2909
- if (!errors.has(msg)) {
2910
- console.error(msg);
2911
- }
2912
- errors.add(msg);
2913
- };
2914
- }
2915
-
2916
-
2917
- } (errorOnce));
2918
- return errorOnce;
2919
- }
2920
-
2921
- var hasRequiredLink$1;
2922
-
2923
- function requireLink$1 () {
2924
- if (hasRequiredLink$1) return link$1.exports;
2925
- hasRequiredLink$1 = 1;
2926
- (function (module, exports) {
2927
- 'use client';
2928
- Object.defineProperty(exports, "__esModule", {
2929
- value: true
2930
- });
2931
- function _export(target, all) {
2932
- for(var name in all)Object.defineProperty(target, name, {
2933
- enumerable: true,
2934
- get: all[name]
2935
- });
2936
- }
2937
- _export(exports, {
2938
- default: function() {
2939
- return _default;
2940
- },
2941
- useLinkStatus: function() {
2942
- return useLinkStatus;
2943
- }
2944
- });
2945
- const _interop_require_wildcard = /*@__PURE__*/ navigation.require_interop_require_wildcard();
2946
- const _jsxruntime = require$$1;
2947
- const _react = /*#__PURE__*/ _interop_require_wildcard._(require$$0);
2948
- const _resolvehref = requireResolveHref();
2949
- const _islocalurl = requireIsLocalUrl();
2950
- const _formaturl = requireFormatUrl();
2951
- const _utils = requireUtils$1();
2952
- const _addlocale = requireAddLocale();
2953
- const _routercontextsharedruntime = requireRouterContext_sharedRuntime();
2954
- const _useintersection = requireUseIntersection();
2955
- const _getdomainlocale = requireGetDomainLocale();
2956
- const _addbasepath = requireAddBasePath();
2957
- const _usemergedref = requireUseMergedRef();
2958
- const _erroronce = requireErrorOnce();
2959
- const prefetched = new Set();
2960
- function prefetch(router, href, as, options) {
2961
- if (typeof window === 'undefined') {
2962
- return;
2963
- }
2964
- if (!(0, _islocalurl.isLocalURL)(href)) {
2965
- return;
2966
- }
2967
- // We should only dedupe requests when experimental.optimisticClientCache is
2968
- // disabled.
2969
- if (!options.bypassPrefetchedCheck) {
2970
- const locale = // Let the link's locale prop override the default router locale.
2971
- typeof options.locale !== 'undefined' ? options.locale : 'locale' in router ? router.locale : undefined;
2972
- const prefetchedKey = href + '%' + as + '%' + locale;
2973
- // If we've already fetched the key, then don't prefetch it again!
2974
- if (prefetched.has(prefetchedKey)) {
2975
- return;
2976
- }
2977
- // Mark this URL as prefetched.
2978
- prefetched.add(prefetchedKey);
2979
- }
2980
- // Prefetch the JSON page if asked (only in the client)
2981
- // We need to handle a prefetch error here since we may be
2982
- // loading with priority which can reject but we don't
2983
- // want to force navigation since this is only a prefetch
2984
- router.prefetch(href, as, options).catch((err)=>{
2985
- if (process.env.NODE_ENV !== 'production') {
2986
- // rethrow to show invalid URL errors
2987
- throw err;
2988
- }
2989
- });
2990
- }
2991
- function isModifiedEvent(event) {
2992
- const eventTarget = event.currentTarget;
2993
- const target = eventTarget.getAttribute('target');
2994
- return target && target !== '_self' || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || // triggers resource download
2995
- event.nativeEvent && event.nativeEvent.which === 2;
2996
- }
2997
- function linkClicked(e, router, href, as, replace, shallow, scroll, locale, onNavigate) {
2998
- const { nodeName } = e.currentTarget;
2999
- // anchors inside an svg have a lowercase nodeName
3000
- const isAnchorNodeName = nodeName.toUpperCase() === 'A';
3001
- if (isAnchorNodeName && isModifiedEvent(e) || e.currentTarget.hasAttribute('download')) {
3002
- // ignore click for browser’s default behavior
3003
- return;
3004
- }
3005
- if (!(0, _islocalurl.isLocalURL)(href)) {
3006
- if (replace) {
3007
- // browser default behavior does not replace the history state
3008
- // so we need to do it manually
3009
- e.preventDefault();
3010
- location.replace(href);
3011
- }
3012
- // ignore click for browser’s default behavior
3013
- return;
3014
- }
3015
- e.preventDefault();
3016
- const navigate = ()=>{
3017
- if (onNavigate) {
3018
- let isDefaultPrevented = false;
3019
- onNavigate({
3020
- preventDefault: ()=>{
3021
- isDefaultPrevented = true;
3022
- }
3023
- });
3024
- if (isDefaultPrevented) {
3025
- return;
3026
- }
3027
- }
3028
- // If the router is an NextRouter instance it will have `beforePopState`
3029
- const routerScroll = scroll != null ? scroll : true;
3030
- if ('beforePopState' in router) {
3031
- router[replace ? 'replace' : 'push'](href, as, {
3032
- shallow,
3033
- locale,
3034
- scroll: routerScroll
3035
- });
3036
- } else {
3037
- router[replace ? 'replace' : 'push'](as || href, {
3038
- scroll: routerScroll
3039
- });
3040
- }
3041
- };
3042
- navigate();
3043
- }
3044
- function formatStringOrUrl(urlObjOrString) {
3045
- if (typeof urlObjOrString === 'string') {
3046
- return urlObjOrString;
3047
- }
3048
- return (0, _formaturl.formatUrl)(urlObjOrString);
3049
- }
3050
- /**
3051
- * A React component that extends the HTML `<a>` element to provide [prefetching](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#2-prefetching)
3052
- * and client-side navigation between routes.
3053
- *
3054
- * It is the primary way to navigate between routes in Next.js.
3055
- *
3056
- * Read more: [Next.js docs: `<Link>`](https://nextjs.org/docs/app/api-reference/components/link)
3057
- */ const Link = /*#__PURE__*/ _react.default.forwardRef(function LinkComponent(props, forwardedRef) {
3058
- let children;
3059
- const { href: hrefProp, as: asProp, children: childrenProp, prefetch: prefetchProp = null, passHref, replace, shallow, scroll, locale, onClick, onNavigate, onMouseEnter: onMouseEnterProp, onTouchStart: onTouchStartProp, legacyBehavior = false, ...restProps } = props;
3060
- children = childrenProp;
3061
- if (legacyBehavior && (typeof children === 'string' || typeof children === 'number')) {
3062
- children = /*#__PURE__*/ (0, _jsxruntime.jsx)("a", {
3063
- children: children
3064
- });
3065
- }
3066
- const router = _react.default.useContext(_routercontextsharedruntime.RouterContext);
3067
- const prefetchEnabled = prefetchProp !== false;
3068
- if (process.env.NODE_ENV !== 'production') {
3069
- function createPropError(args) {
3070
- return Object.defineProperty(new Error("Failed prop type: The prop `" + args.key + "` expects a " + args.expected + " in `<Link>`, but got `" + args.actual + "` instead." + (typeof window !== 'undefined' ? "\nOpen your browser's console to view the Component stack trace." : '')), "__NEXT_ERROR_CODE", {
3071
- value: "E319",
3072
- enumerable: false,
3073
- configurable: true
3074
- });
3075
- }
3076
- // TypeScript trick for type-guarding:
3077
- const requiredPropsGuard = {
3078
- href: true
3079
- };
3080
- const requiredProps = Object.keys(requiredPropsGuard);
3081
- requiredProps.forEach((key)=>{
3082
- if (key === 'href') {
3083
- if (props[key] == null || typeof props[key] !== 'string' && typeof props[key] !== 'object') {
3084
- throw createPropError({
3085
- key,
3086
- expected: '`string` or `object`',
3087
- actual: props[key] === null ? 'null' : typeof props[key]
3088
- });
3089
- }
3090
- }
3091
- });
3092
- // TypeScript trick for type-guarding:
3093
- const optionalPropsGuard = {
3094
- as: true,
3095
- replace: true,
3096
- scroll: true,
3097
- shallow: true,
3098
- passHref: true,
3099
- prefetch: true,
3100
- locale: true,
3101
- onClick: true,
3102
- onMouseEnter: true,
3103
- onTouchStart: true,
3104
- legacyBehavior: true,
3105
- onNavigate: true
3106
- };
3107
- const optionalProps = Object.keys(optionalPropsGuard);
3108
- optionalProps.forEach((key)=>{
3109
- const valType = typeof props[key];
3110
- if (key === 'as') {
3111
- if (props[key] && valType !== 'string' && valType !== 'object') {
3112
- throw createPropError({
3113
- key,
3114
- expected: '`string` or `object`',
3115
- actual: valType
3116
- });
3117
- }
3118
- } else if (key === 'locale') {
3119
- if (props[key] && valType !== 'string') {
3120
- throw createPropError({
3121
- key,
3122
- expected: '`string`',
3123
- actual: valType
3124
- });
3125
- }
3126
- } else if (key === 'onClick' || key === 'onMouseEnter' || key === 'onTouchStart' || key === 'onNavigate') {
3127
- if (props[key] && valType !== 'function') {
3128
- throw createPropError({
3129
- key,
3130
- expected: '`function`',
3131
- actual: valType
3132
- });
3133
- }
3134
- } else if (key === 'replace' || key === 'scroll' || key === 'shallow' || key === 'passHref' || key === 'prefetch' || key === 'legacyBehavior') {
3135
- if (props[key] != null && valType !== 'boolean') {
3136
- throw createPropError({
3137
- key,
3138
- expected: '`boolean`',
3139
- actual: valType
3140
- });
3141
- }
3142
- } else ;
3143
- });
3144
- }
3145
- const { href, as } = _react.default.useMemo(()=>{
3146
- if (!router) {
3147
- const resolvedHref = formatStringOrUrl(hrefProp);
3148
- return {
3149
- href: resolvedHref,
3150
- as: asProp ? formatStringOrUrl(asProp) : resolvedHref
3151
- };
3152
- }
3153
- const [resolvedHref, resolvedAs] = (0, _resolvehref.resolveHref)(router, hrefProp, true);
3154
- return {
3155
- href: resolvedHref,
3156
- as: asProp ? (0, _resolvehref.resolveHref)(router, asProp) : resolvedAs || resolvedHref
3157
- };
3158
- }, [
3159
- router,
3160
- hrefProp,
3161
- asProp
3162
- ]);
3163
- const previousHref = _react.default.useRef(href);
3164
- const previousAs = _react.default.useRef(as);
3165
- // This will return the first child, if multiple are provided it will throw an error
3166
- let child;
3167
- if (legacyBehavior) {
3168
- if (process.env.NODE_ENV === 'development') {
3169
- if (onClick) {
3170
- console.warn('"onClick" was passed to <Link> with `href` of `' + hrefProp + '` but "legacyBehavior" was set. The legacy behavior requires onClick be set on the child of next/link');
3171
- }
3172
- if (onMouseEnterProp) {
3173
- console.warn('"onMouseEnter" was passed to <Link> with `href` of `' + hrefProp + '` but "legacyBehavior" was set. The legacy behavior requires onMouseEnter be set on the child of next/link');
3174
- }
3175
- try {
3176
- child = _react.default.Children.only(children);
3177
- } catch (err) {
3178
- if (!children) {
3179
- throw Object.defineProperty(new Error("No children were passed to <Link> with `href` of `" + hrefProp + "` but one child is required https://nextjs.org/docs/messages/link-no-children"), "__NEXT_ERROR_CODE", {
3180
- value: "E320",
3181
- enumerable: false,
3182
- configurable: true
3183
- });
3184
- }
3185
- throw Object.defineProperty(new Error("Multiple children were passed to <Link> with `href` of `" + hrefProp + "` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children" + (typeof window !== 'undefined' ? " \nOpen your browser's console to view the Component stack trace." : '')), "__NEXT_ERROR_CODE", {
3186
- value: "E266",
3187
- enumerable: false,
3188
- configurable: true
3189
- });
3190
- }
3191
- } else {
3192
- child = _react.default.Children.only(children);
3193
- }
3194
- } else {
3195
- if (process.env.NODE_ENV === 'development') {
3196
- if ((children == null ? void 0 : children.type) === 'a') {
3197
- throw Object.defineProperty(new Error('Invalid <Link> with <a> child. Please remove <a> or use <Link legacyBehavior>.\nLearn more: https://nextjs.org/docs/messages/invalid-new-link-with-extra-anchor'), "__NEXT_ERROR_CODE", {
3198
- value: "E209",
3199
- enumerable: false,
3200
- configurable: true
3201
- });
3202
- }
3203
- }
3204
- }
3205
- const childRef = legacyBehavior ? child && typeof child === 'object' && child.ref : forwardedRef;
3206
- const [setIntersectionRef, isVisible, resetVisible] = (0, _useintersection.useIntersection)({
3207
- rootMargin: '200px'
3208
- });
3209
- const setIntersectionWithResetRef = _react.default.useCallback((el)=>{
3210
- // Before the link getting observed, check if visible state need to be reset
3211
- if (previousAs.current !== as || previousHref.current !== href) {
3212
- resetVisible();
3213
- previousAs.current = as;
3214
- previousHref.current = href;
3215
- }
3216
- setIntersectionRef(el);
3217
- }, [
3218
- as,
3219
- href,
3220
- resetVisible,
3221
- setIntersectionRef
3222
- ]);
3223
- const setRef = (0, _usemergedref.useMergedRef)(setIntersectionWithResetRef, childRef);
3224
- // Prefetch the URL if we haven't already and it's visible.
3225
- _react.default.useEffect(()=>{
3226
- // in dev, we only prefetch on hover to avoid wasting resources as the prefetch will trigger compiling the page.
3227
- if (process.env.NODE_ENV !== 'production') {
3228
- return;
3229
- }
3230
- if (!router) {
3231
- return;
3232
- }
3233
- // If we don't need to prefetch the URL, don't do prefetch.
3234
- if (!isVisible || !prefetchEnabled) {
3235
- return;
3236
- }
3237
- // Prefetch the URL.
3238
- prefetch(router, href, as, {
3239
- locale
3240
- });
3241
- }, [
3242
- as,
3243
- href,
3244
- isVisible,
3245
- locale,
3246
- prefetchEnabled,
3247
- router == null ? void 0 : router.locale,
3248
- router
3249
- ]);
3250
- const childProps = {
3251
- ref: setRef,
3252
- onClick (e) {
3253
- if (process.env.NODE_ENV !== 'production') {
3254
- if (!e) {
3255
- throw Object.defineProperty(new Error('Component rendered inside next/link has to pass click event to "onClick" prop.'), "__NEXT_ERROR_CODE", {
3256
- value: "E312",
3257
- enumerable: false,
3258
- configurable: true
3259
- });
3260
- }
3261
- }
3262
- if (!legacyBehavior && typeof onClick === 'function') {
3263
- onClick(e);
3264
- }
3265
- if (legacyBehavior && child.props && typeof child.props.onClick === 'function') {
3266
- child.props.onClick(e);
3267
- }
3268
- if (!router) {
3269
- return;
3270
- }
3271
- if (e.defaultPrevented) {
3272
- return;
3273
- }
3274
- linkClicked(e, router, href, as, replace, shallow, scroll, locale, onNavigate);
3275
- },
3276
- onMouseEnter (e) {
3277
- if (!legacyBehavior && typeof onMouseEnterProp === 'function') {
3278
- onMouseEnterProp(e);
3279
- }
3280
- if (legacyBehavior && child.props && typeof child.props.onMouseEnter === 'function') {
3281
- child.props.onMouseEnter(e);
3282
- }
3283
- if (!router) {
3284
- return;
3285
- }
3286
- prefetch(router, href, as, {
3287
- locale,
3288
- priority: true,
3289
- // @see {https://github.com/vercel/next.js/discussions/40268?sort=top#discussioncomment-3572642}
3290
- bypassPrefetchedCheck: true
3291
- });
3292
- },
3293
- onTouchStart: process.env.__NEXT_LINK_NO_TOUCH_START ? undefined : function onTouchStart(e) {
3294
- if (!legacyBehavior && typeof onTouchStartProp === 'function') {
3295
- onTouchStartProp(e);
3296
- }
3297
- if (legacyBehavior && child.props && typeof child.props.onTouchStart === 'function') {
3298
- child.props.onTouchStart(e);
3299
- }
3300
- if (!router) {
3301
- return;
3302
- }
3303
- prefetch(router, href, as, {
3304
- locale,
3305
- priority: true,
3306
- // @see {https://github.com/vercel/next.js/discussions/40268?sort=top#discussioncomment-3572642}
3307
- bypassPrefetchedCheck: true
3308
- });
3309
- }
3310
- };
3311
- // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is
3312
- // defined, we specify the current 'href', so that repetition is not needed by the user.
3313
- // If the url is absolute, we can bypass the logic to prepend the domain and locale.
3314
- if ((0, _utils.isAbsoluteUrl)(as)) {
3315
- childProps.href = as;
3316
- } else if (!legacyBehavior || passHref || child.type === 'a' && !('href' in child.props)) {
3317
- const curLocale = typeof locale !== 'undefined' ? locale : router == null ? void 0 : router.locale;
3318
- // we only render domain locales if we are currently on a domain locale
3319
- // so that locale links are still visitable in development/preview envs
3320
- const localeDomain = (router == null ? void 0 : router.isLocaleDomain) && (0, _getdomainlocale.getDomainLocale)(as, curLocale, router == null ? void 0 : router.locales, router == null ? void 0 : router.domainLocales);
3321
- childProps.href = localeDomain || (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(as, curLocale, router == null ? void 0 : router.defaultLocale));
3322
- }
3323
- if (legacyBehavior) {
3324
- if (process.env.NODE_ENV === 'development') {
3325
- (0, _erroronce.errorOnce)('`legacyBehavior` is deprecated and will be removed in a future ' + 'release. A codemod is available to upgrade your components:\n\n' + 'npx @next/codemod@latest new-link .\n\n' + 'Learn more: https://nextjs.org/docs/app/building-your-application/upgrading/codemods#remove-a-tags-from-link-components');
3326
- }
3327
- return /*#__PURE__*/ _react.default.cloneElement(child, childProps);
3328
- }
3329
- return /*#__PURE__*/ (0, _jsxruntime.jsx)("a", {
3330
- ...restProps,
3331
- ...childProps,
3332
- children: children
3333
- });
3334
- });
3335
- const LinkStatusContext = /*#__PURE__*/ (0, _react.createContext)({
3336
- // We do not support link status in the Pages Router, so we always return false
3337
- pending: false
3338
- });
3339
- const useLinkStatus = ()=>{
3340
- // This behaviour is like React's useFormStatus. When the component is not under
3341
- // a <form> tag, it will get the default value, instead of throwing an error.
3342
- return (0, _react.useContext)(LinkStatusContext);
3343
- };
3344
- const _default = Link;
3345
-
3346
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
3347
- Object.defineProperty(exports.default, '__esModule', { value: true });
3348
- Object.assign(exports.default, exports);
3349
- module.exports = exports.default;
3350
- }
3351
-
3352
-
3353
- } (link$1, link$1.exports));
3354
- return link$1.exports;
3355
- }
3356
-
3357
- var link;
3358
- var hasRequiredLink;
3359
-
3360
- function requireLink () {
3361
- if (hasRequiredLink) return link;
3362
- hasRequiredLink = 1;
3363
- link = requireLink$1();
3364
- return link;
3365
- }
3366
-
3367
- var linkExports = requireLink();
3368
- const Link = /*@__PURE__*/getDefaultExportFromCjs(linkExports);
3369
-
3370
- const NavItems = ({ items }) => {
3371
- const pathname = navigation.navigationExports.usePathname();
3372
- return /* @__PURE__ */ require$$1.jsx(core.Stack, { gap: 0, children: items.map(({ href, isActive, ...navLinkProps }) => {
3373
- if (href) {
3374
- const active = isActive ?? href.includes(pathname);
3375
- return /* @__PURE__ */ require$$1.jsx(
3376
- core.NavLink,
3377
- {
3378
- active,
3379
- component: Link,
3380
- prefetch: false,
3381
- href,
3382
- ...navLinkProps
3383
- },
3384
- navLinkProps.label
3385
- );
3386
- }
3387
- return /* @__PURE__ */ require$$1.jsx(
3388
- core.NavLink,
3389
- {
3390
- active: isActive,
3391
- component: "button",
3392
- ...navLinkProps
3393
- },
3394
- navLinkProps.label
3395
- );
3396
- }) });
3397
- };
3398
-
3399
- exports.EmptyState = EmptyState;
3400
- exports.InfinityLoader = InfinityLoader;
3401
- exports.NavItems = NavItems;
3402
- exports.SelectInfinity = SelectInfinity;