@faststore/core 2.0.163-alpha.0 → 2.0.164-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/.next/BUILD_ID +1 -0
  2. package/.next/build-manifest.json +132 -0
  3. package/.next/cache/.tsbuildinfo +1 -0
  4. package/.next/cache/config.json +7 -0
  5. package/.next/cache/eslint/.cache_1gneedd +1 -0
  6. package/.next/cache/next-server.js.nft.json +1 -0
  7. package/.next/cache/webpack/client-production/0.pack +0 -0
  8. package/.next/cache/webpack/client-production/index.pack +0 -0
  9. package/.next/cache/webpack/server-production/0.pack +0 -0
  10. package/.next/cache/webpack/server-production/index.pack +0 -0
  11. package/.next/export-marker.json +1 -0
  12. package/.next/images-manifest.json +1 -0
  13. package/.next/next-server.js.nft.json +1 -0
  14. package/.next/package.json +1 -0
  15. package/.next/prerender-manifest.json +1 -0
  16. package/.next/react-loadable-manifest.json +48 -0
  17. package/.next/required-server-files.json +1 -0
  18. package/.next/routes-manifest.json +1 -0
  19. package/.next/server/chunks/123.js +58 -0
  20. package/.next/server/chunks/143.js +106 -0
  21. package/.next/server/chunks/183.js +90 -0
  22. package/.next/server/chunks/205.js +692 -0
  23. package/.next/server/chunks/247.js +61 -0
  24. package/.next/server/chunks/280.js +324 -0
  25. package/.next/server/chunks/287.js +58 -0
  26. package/.next/server/chunks/289.js +229 -0
  27. package/.next/server/chunks/312.js +697 -0
  28. package/.next/server/chunks/336.js +821 -0
  29. package/.next/server/chunks/350.js +143 -0
  30. package/.next/server/chunks/368.js +253 -0
  31. package/.next/server/chunks/401.js +7241 -0
  32. package/.next/server/chunks/431.js +7241 -0
  33. package/.next/server/chunks/502.js +600 -0
  34. package/.next/server/chunks/576.js +90 -0
  35. package/.next/server/chunks/597.js +169 -0
  36. package/.next/server/chunks/608.js +644 -0
  37. package/.next/server/chunks/644.js +235 -0
  38. package/.next/server/chunks/664.js +3401 -0
  39. package/.next/server/chunks/676.js +32 -0
  40. package/.next/server/chunks/701.js +87 -0
  41. package/.next/server/chunks/74.js +2710 -0
  42. package/.next/server/chunks/82.js +371 -0
  43. package/.next/server/chunks/854.js +72 -0
  44. package/.next/server/chunks/859.js +959 -0
  45. package/.next/server/chunks/874.js +487 -0
  46. package/.next/server/chunks/886.js +120 -0
  47. package/.next/server/chunks/907.js +1803 -0
  48. package/.next/server/chunks/970.js +200 -0
  49. package/.next/server/chunks/98.js +124 -0
  50. package/.next/server/chunks/font-manifest.json +1 -0
  51. package/.next/server/font-manifest.json +1 -0
  52. package/.next/server/middleware-build-manifest.js +1 -0
  53. package/.next/server/middleware-manifest.json +6 -0
  54. package/.next/server/middleware-react-loadable-manifest.js +1 -0
  55. package/.next/server/pages/404.js +393 -0
  56. package/.next/server/pages/404.js.nft.json +1 -0
  57. package/.next/server/pages/500.js +395 -0
  58. package/.next/server/pages/500.js.nft.json +1 -0
  59. package/.next/server/pages/[...slug].js +730 -0
  60. package/.next/server/pages/[...slug].js.nft.json +1 -0
  61. package/.next/server/pages/[slug]/p.js +2476 -0
  62. package/.next/server/pages/[slug]/p.js.nft.json +1 -0
  63. package/.next/server/pages/_app.js +368 -0
  64. package/.next/server/pages/_app.js.nft.json +1 -0
  65. package/.next/server/pages/_document.js +304 -0
  66. package/.next/server/pages/_document.js.nft.json +1 -0
  67. package/.next/server/pages/_error.js +164 -0
  68. package/.next/server/pages/_error.js.nft.json +1 -0
  69. package/.next/server/pages/account.js +370 -0
  70. package/.next/server/pages/account.js.nft.json +1 -0
  71. package/.next/server/pages/api/graphql.js +316 -0
  72. package/.next/server/pages/api/graphql.js.nft.json +1 -0
  73. package/.next/server/pages/api/preview.js +119 -0
  74. package/.next/server/pages/api/preview.js.nft.json +1 -0
  75. package/.next/server/pages/checkout.js +370 -0
  76. package/.next/server/pages/checkout.js.nft.json +1 -0
  77. package/.next/server/pages/en-US/404.html +81 -0
  78. package/.next/server/pages/en-US/404.json +1 -0
  79. package/.next/server/pages/en-US/500.html +81 -0
  80. package/.next/server/pages/en-US/500.json +1 -0
  81. package/.next/server/pages/en-US/account.html +81 -0
  82. package/.next/server/pages/en-US/account.json +1 -0
  83. package/.next/server/pages/en-US/checkout.html +81 -0
  84. package/.next/server/pages/en-US/checkout.json +1 -0
  85. package/.next/server/pages/en-US/login.html +81 -0
  86. package/.next/server/pages/en-US/login.json +1 -0
  87. package/.next/server/pages/en-US/s.html +81 -0
  88. package/.next/server/pages/en-US/s.json +1 -0
  89. package/.next/server/pages/en-US.html +81 -0
  90. package/.next/server/pages/en-US.json +1 -0
  91. package/.next/server/pages/index.js +966 -0
  92. package/.next/server/pages/index.js.nft.json +1 -0
  93. package/.next/server/pages/login.js +375 -0
  94. package/.next/server/pages/login.js.nft.json +1 -0
  95. package/.next/server/pages/s.js +473 -0
  96. package/.next/server/pages/s.js.nft.json +1 -0
  97. package/.next/server/pages-manifest.json +16 -0
  98. package/.next/server/webpack-api-runtime.js +229 -0
  99. package/.next/server/webpack-runtime.js +229 -0
  100. package/.next/static/chunks/0-82274e07cb857231.js +1 -0
  101. package/.next/static/chunks/143.dd8a556e6957baa1.js +1 -0
  102. package/.next/static/chunks/226.b57e10ad9932f88c.js +1 -0
  103. package/.next/static/chunks/240-8e66b2892f9d8c40.js +1 -0
  104. package/.next/static/chunks/336.0846f48eccce57e4.js +1 -0
  105. package/.next/static/chunks/377-891ff95d759cb061.js +1 -0
  106. package/.next/static/chunks/391-47b923ef44945418.js +1 -0
  107. package/.next/static/chunks/495.0ecd099878b2a36d.js +1 -0
  108. package/.next/static/chunks/502.eeca300cb9a355fb.js +1 -0
  109. package/.next/static/chunks/545-1d3d08edfd2ee4c6.js +1 -0
  110. package/.next/static/chunks/597.57a8984b6a1071ae.js +1 -0
  111. package/.next/static/chunks/64.ebbe1d2b40f980c7.js +1 -0
  112. package/.next/static/chunks/651.7142f31ce1e052b3.js +1 -0
  113. package/.next/static/chunks/741.52f7fb873418346f.js +1 -0
  114. package/.next/static/chunks/98.97381d2021f86cd9.js +1 -0
  115. package/.next/static/chunks/framework-dfd14d7ce6600b03.js +1 -0
  116. package/.next/static/chunks/main-fd466221927468fd.js +1 -0
  117. package/.next/static/chunks/pages/404-459452495a0df278.js +1 -0
  118. package/.next/static/chunks/pages/500-008e30c48eceebed.js +1 -0
  119. package/.next/static/chunks/pages/[...slug]-e9d8386ff5e56d85.js +1 -0
  120. package/.next/static/chunks/pages/[slug]/p-8346514a688bf869.js +1 -0
  121. package/.next/static/chunks/pages/_app-78846ca9151cf266.js +1 -0
  122. package/.next/static/chunks/pages/_error-a7a0c1d9bfbb4f38.js +1 -0
  123. package/.next/static/chunks/pages/account-46263f0c100c3eae.js +1 -0
  124. package/.next/static/chunks/pages/checkout-20bb3710b24df3b6.js +1 -0
  125. package/.next/static/chunks/pages/index-2006be8f08ad057f.js +1 -0
  126. package/.next/static/chunks/pages/login-f9d316d261fcc062.js +1 -0
  127. package/.next/static/chunks/pages/s-1cbe740b5b781d28.js +1 -0
  128. package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +1 -0
  129. package/.next/static/chunks/webpack-e9bf82a67cc08d0f.js +1 -0
  130. package/.next/static/css/13a4da555ff5e3be.css +1 -0
  131. package/.next/static/css/287f5ba239375052.css +1 -0
  132. package/.next/static/css/28d7d73e13e2bc1d.css +1 -0
  133. package/.next/static/css/2e00f7ba49c754b3.css +1 -0
  134. package/.next/static/css/47d82dcec9a7dbc2.css +1 -0
  135. package/.next/static/css/6e41f1b6078c14c1.css +1 -0
  136. package/.next/static/css/7d822a137c54a781.css +1 -0
  137. package/.next/static/css/c6f97f692b2efad9.css +1 -0
  138. package/.next/static/css/d4a0d9df8c6df555.css +1 -0
  139. package/.next/static/css/e02cdad8fc000339.css +1 -0
  140. package/.next/static/gIr9FWN1njlGkoTr4tYi8/_buildManifest.js +1 -0
  141. package/.next/static/gIr9FWN1njlGkoTr4tYi8/_ssgManifest.js +1 -0
  142. package/.next/trace +69 -0
  143. package/.turbo/turbo-build.log +5 -4
  144. package/CHANGELOG.md +6 -0
  145. package/cms/faststore/content-types.json +49 -0
  146. package/faststore.config.js +8 -0
  147. package/package.json +2 -2
  148. package/public/~partytown/debug/partytown-atomics.js +556 -0
  149. package/public/~partytown/debug/partytown-media.js +374 -0
  150. package/public/~partytown/debug/partytown-sandbox-sw.js +543 -0
  151. package/public/~partytown/debug/partytown-sw.js +59 -0
  152. package/public/~partytown/debug/partytown-ww-atomics.js +1789 -0
  153. package/public/~partytown/debug/partytown-ww-sw.js +1781 -0
  154. package/public/~partytown/debug/partytown.js +72 -0
  155. package/public/~partytown/partytown-atomics.js +2 -0
  156. package/public/~partytown/partytown-media.js +2 -0
  157. package/public/~partytown/partytown-sw.js +2 -0
  158. package/public/~partytown/partytown.js +2 -0
  159. package/src/pages/api/preview.ts +2 -1
  160. package/src/pages/index.tsx +2 -2
@@ -0,0 +1,3401 @@
1
+ exports.id = 664;
2
+ exports.ids = [664];
3
+ exports.modules = {
4
+
5
+ /***/ 932:
6
+ /***/ ((__unused_webpack_module, exports) => {
7
+
8
+ "use strict";
9
+ var __webpack_unused_export__;
10
+
11
+ __webpack_unused_export__ = ({
12
+ value: true
13
+ });
14
+ exports.Z = _asyncToGenerator;
15
+ function _asyncToGenerator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
31
+ try {
32
+ var info = gen[key](arg);
33
+ var value = info.value;
34
+ } catch (error) {
35
+ reject(error);
36
+ return;
37
+ }
38
+ if (info.done) {
39
+ resolve(value);
40
+ } else {
41
+ Promise.resolve(value).then(_next, _throw);
42
+ }
43
+ }
44
+
45
+
46
+ /***/ }),
47
+
48
+ /***/ 227:
49
+ /***/ ((module, exports, __webpack_require__) => {
50
+
51
+ "use strict";
52
+
53
+
54
+ Object.defineProperty(exports, "__esModule", ({
55
+ value: true
56
+ }));
57
+ exports.addBasePath = addBasePath;
58
+
59
+ var _addPathPrefix = __webpack_require__(1751);
60
+
61
+ var _normalizeTrailingSlash = __webpack_require__(4969);
62
+
63
+ const basePath = false || '';
64
+
65
+ function addBasePath(path, required) {
66
+ if (false) {}
67
+
68
+ return (0, _normalizeTrailingSlash).normalizePathTrailingSlash((0, _addPathPrefix).addPathPrefix(path, basePath));
69
+ }
70
+
71
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
72
+ Object.defineProperty(exports.default, '__esModule', {
73
+ value: true
74
+ });
75
+ Object.assign(exports.default, exports);
76
+ module.exports = exports.default;
77
+ }
78
+
79
+ /***/ }),
80
+
81
+ /***/ 7995:
82
+ /***/ ((module, exports, __webpack_require__) => {
83
+
84
+ "use strict";
85
+
86
+
87
+ Object.defineProperty(exports, "__esModule", ({
88
+ value: true
89
+ }));
90
+ exports.addLocale = void 0;
91
+
92
+ var _normalizeTrailingSlash = __webpack_require__(4969);
93
+
94
+ const addLocale = (path, ...args) => {
95
+ if (true) {
96
+ return (0, _normalizeTrailingSlash).normalizePathTrailingSlash((__webpack_require__(3431).addLocale)(path, ...args));
97
+ }
98
+
99
+ return path;
100
+ };
101
+
102
+ exports.addLocale = addLocale;
103
+
104
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
105
+ Object.defineProperty(exports.default, '__esModule', {
106
+ value: true
107
+ });
108
+ Object.assign(exports.default, exports);
109
+ module.exports = exports.default;
110
+ }
111
+
112
+ /***/ }),
113
+
114
+ /***/ 7565:
115
+ /***/ ((module, exports, __webpack_require__) => {
116
+
117
+ "use strict";
118
+
119
+
120
+ Object.defineProperty(exports, "__esModule", ({
121
+ value: true
122
+ }));
123
+ exports.detectDomainLocale = void 0;
124
+
125
+ const detectDomainLocale = (...args) => {
126
+ if (true) {
127
+ return (__webpack_require__(3539).detectDomainLocale)(...args);
128
+ }
129
+ };
130
+
131
+ exports.detectDomainLocale = detectDomainLocale;
132
+
133
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
134
+ Object.defineProperty(exports.default, '__esModule', {
135
+ value: true
136
+ });
137
+ Object.assign(exports.default, exports);
138
+ module.exports = exports.default;
139
+ }
140
+
141
+ /***/ }),
142
+
143
+ /***/ 4019:
144
+ /***/ ((module, exports, __webpack_require__) => {
145
+
146
+ "use strict";
147
+
148
+
149
+ Object.defineProperty(exports, "__esModule", ({
150
+ value: true
151
+ }));
152
+ exports.getDomainLocale = getDomainLocale;
153
+ const basePath = false || '';
154
+
155
+ function getDomainLocale(path, locale, locales, domainLocales) {
156
+ if (true) {
157
+ const normalizeLocalePath = (__webpack_require__(6340).normalizeLocalePath);
158
+
159
+ const detectDomainLocale = (__webpack_require__(7565).detectDomainLocale);
160
+
161
+ const target = locale || normalizeLocalePath(path, locales).detectedLocale;
162
+ const domain = detectDomainLocale(domainLocales, undefined, target);
163
+
164
+ if (domain) {
165
+ const proto = `http${domain.http ? '' : 's'}://`;
166
+ const finalLocale = target === domain.defaultLocale ? '' : `/${target}`;
167
+ return `${proto}${domain.domain}${basePath}${finalLocale}${path}`;
168
+ }
169
+
170
+ return false;
171
+ } else {}
172
+ }
173
+
174
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
175
+ Object.defineProperty(exports.default, '__esModule', {
176
+ value: true
177
+ });
178
+ Object.assign(exports.default, exports);
179
+ module.exports = exports.default;
180
+ }
181
+
182
+ /***/ }),
183
+
184
+ /***/ 8771:
185
+ /***/ ((module, exports, __webpack_require__) => {
186
+
187
+ "use strict";
188
+
189
+
190
+ Object.defineProperty(exports, "__esModule", ({
191
+ value: true
192
+ }));
193
+ exports.hasBasePath = hasBasePath;
194
+
195
+ var _pathHasPrefix = __webpack_require__(4567);
196
+
197
+ const basePath = false || '';
198
+
199
+ function hasBasePath(path) {
200
+ return (0, _pathHasPrefix).pathHasPrefix(path, basePath);
201
+ }
202
+
203
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
204
+ Object.defineProperty(exports.default, '__esModule', {
205
+ value: true
206
+ });
207
+ Object.assign(exports.default, exports);
208
+ module.exports = exports.default;
209
+ }
210
+
211
+ /***/ }),
212
+
213
+ /***/ 877:
214
+ /***/ ((module, exports) => {
215
+
216
+ "use strict";
217
+
218
+
219
+ Object.defineProperty(exports, "__esModule", ({
220
+ value: true
221
+ }));
222
+ exports["default"] = initHeadManager;
223
+ exports.isEqualNode = isEqualNode;
224
+ exports.DOMAttributeNames = void 0;
225
+
226
+ function initHeadManager() {
227
+ return {
228
+ mountedInstances: new Set(),
229
+ updateHead: head => {
230
+ const tags = {};
231
+ head.forEach(h => {
232
+ if ( // If the font tag is loaded only on client navigation
233
+ // it won't be inlined. In this case revert to the original behavior
234
+ h.type === 'link' && h.props['data-optimized-fonts']) {
235
+ if (document.querySelector(`style[data-href="${h.props['data-href']}"]`)) {
236
+ return;
237
+ } else {
238
+ h.props.href = h.props['data-href'];
239
+ h.props['data-href'] = undefined;
240
+ }
241
+ }
242
+
243
+ const components = tags[h.type] || [];
244
+ components.push(h);
245
+ tags[h.type] = components;
246
+ });
247
+ const titleComponent = tags.title ? tags.title[0] : null;
248
+ let title = '';
249
+
250
+ if (titleComponent) {
251
+ const {
252
+ children
253
+ } = titleComponent.props;
254
+ title = typeof children === 'string' ? children : Array.isArray(children) ? children.join('') : '';
255
+ }
256
+
257
+ if (title !== document.title) document.title = title;
258
+ ['meta', 'base', 'link', 'style', 'script'].forEach(type => {
259
+ updateElements(type, tags[type] || []);
260
+ });
261
+ }
262
+ };
263
+ }
264
+
265
+ const DOMAttributeNames = {
266
+ acceptCharset: 'accept-charset',
267
+ className: 'class',
268
+ htmlFor: 'for',
269
+ httpEquiv: 'http-equiv',
270
+ noModule: 'noModule'
271
+ };
272
+ exports.DOMAttributeNames = DOMAttributeNames;
273
+
274
+ function reactElementToDOM({
275
+ type,
276
+ props
277
+ }) {
278
+ const el = document.createElement(type);
279
+
280
+ for (const p in props) {
281
+ if (!props.hasOwnProperty(p)) continue;
282
+ if (p === 'children' || p === 'dangerouslySetInnerHTML') continue; // we don't render undefined props to the DOM
283
+
284
+ if (props[p] === undefined) continue;
285
+ const attr = DOMAttributeNames[p] || p.toLowerCase();
286
+
287
+ if (type === 'script' && (attr === 'async' || attr === 'defer' || attr === 'noModule')) {
288
+ el[attr] = !!props[p];
289
+ } else {
290
+ el.setAttribute(attr, props[p]);
291
+ }
292
+ }
293
+
294
+ const {
295
+ children,
296
+ dangerouslySetInnerHTML
297
+ } = props;
298
+
299
+ if (dangerouslySetInnerHTML) {
300
+ el.innerHTML = dangerouslySetInnerHTML.__html || '';
301
+ } else if (children) {
302
+ el.textContent = typeof children === 'string' ? children : Array.isArray(children) ? children.join('') : '';
303
+ }
304
+
305
+ return el;
306
+ }
307
+
308
+ function isEqualNode(oldTag, newTag) {
309
+ if (oldTag instanceof HTMLElement && newTag instanceof HTMLElement) {
310
+ const nonce = newTag.getAttribute('nonce'); // Only strip the nonce if `oldTag` has had it stripped. An element's nonce attribute will not
311
+ // be stripped if there is no content security policy response header that includes a nonce.
312
+
313
+ if (nonce && !oldTag.getAttribute('nonce')) {
314
+ const cloneTag = newTag.cloneNode(true);
315
+ cloneTag.setAttribute('nonce', '');
316
+ cloneTag.nonce = nonce;
317
+ return nonce === oldTag.nonce && oldTag.isEqualNode(cloneTag);
318
+ }
319
+ }
320
+
321
+ return oldTag.isEqualNode(newTag);
322
+ }
323
+
324
+ function updateElements(type, components) {
325
+ const headEl = document.getElementsByTagName('head')[0];
326
+ const headCountEl = headEl.querySelector('meta[name=next-head-count]');
327
+
328
+ if (false) {}
329
+
330
+ const headCount = Number(headCountEl.content);
331
+ const oldTags = [];
332
+
333
+ for (let i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = (j == null ? void 0 : j.previousElementSibling) || null) {
334
+ var ref;
335
+
336
+ if ((j == null ? void 0 : (ref = j.tagName) == null ? void 0 : ref.toLowerCase()) === type) {
337
+ oldTags.push(j);
338
+ }
339
+ }
340
+
341
+ const newTags = components.map(reactElementToDOM).filter(newTag => {
342
+ for (let k = 0, len = oldTags.length; k < len; k++) {
343
+ const oldTag = oldTags[k];
344
+
345
+ if (isEqualNode(oldTag, newTag)) {
346
+ oldTags.splice(k, 1);
347
+ return false;
348
+ }
349
+ }
350
+
351
+ return true;
352
+ });
353
+ oldTags.forEach(t => {
354
+ var ref;
355
+ return (ref = t.parentNode) == null ? void 0 : ref.removeChild(t);
356
+ });
357
+ newTags.forEach(t => headEl.insertBefore(t, headCountEl));
358
+ headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
359
+ }
360
+
361
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
362
+ Object.defineProperty(exports.default, '__esModule', {
363
+ value: true
364
+ });
365
+ Object.assign(exports.default, exports);
366
+ module.exports = exports.default;
367
+ }
368
+
369
+ /***/ }),
370
+
371
+ /***/ 7942:
372
+ /***/ ((module, exports, __webpack_require__) => {
373
+
374
+ "client";
375
+ "use strict";
376
+
377
+ Object.defineProperty(exports, "__esModule", ({
378
+ value: true
379
+ }));
380
+ exports["default"] = void 0;
381
+
382
+ var _interop_require_default = (__webpack_require__(2648)/* ["default"] */ .Z);
383
+
384
+ var _object_without_properties_loose = (__webpack_require__(7273)/* ["default"] */ .Z);
385
+
386
+ var _react = _interop_require_default(__webpack_require__(6689));
387
+
388
+ var _router = __webpack_require__(5781);
389
+
390
+ var _addLocale = __webpack_require__(7995);
391
+
392
+ var _routerContext = __webpack_require__(4964);
393
+
394
+ var _appRouterContext = __webpack_require__(3280);
395
+
396
+ var _useIntersection = __webpack_require__(639);
397
+
398
+ var _getDomainLocale = __webpack_require__(4019);
399
+
400
+ var _addBasePath = __webpack_require__(227);
401
+
402
+ 'client';
403
+ const prefetched = {};
404
+
405
+ function prefetch(router, href, as, options) {
406
+ if (true) return;
407
+ if (!(0, _router).isLocalURL(href)) return; // Prefetch the JSON page if asked (only in the client)
408
+ // We need to handle a prefetch error here since we may be
409
+ // loading with priority which can reject but we don't
410
+ // want to force navigation since this is only a prefetch
411
+
412
+ Promise.resolve(router.prefetch(href, as, options)).catch(err => {
413
+ if (false) {}
414
+ });
415
+ const curLocale = options && typeof options.locale !== 'undefined' ? options.locale : router && router.locale; // Join on an invalid URI character
416
+
417
+ prefetched[href + '%' + as + (curLocale ? '%' + curLocale : '')] = true;
418
+ }
419
+
420
+ function isModifiedEvent(event) {
421
+ const {
422
+ target
423
+ } = event.currentTarget;
424
+ return target && target !== '_self' || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.nativeEvent && event.nativeEvent.which === 2;
425
+ }
426
+
427
+ function linkClicked(e, router, href, as, replace, shallow, scroll, locale, isAppRouter, prefetchEnabled) {
428
+ const {
429
+ nodeName
430
+ } = e.currentTarget; // anchors inside an svg have a lowercase nodeName
431
+
432
+ const isAnchorNodeName = nodeName.toUpperCase() === 'A';
433
+
434
+ if (isAnchorNodeName && (isModifiedEvent(e) || !(0, _router).isLocalURL(href))) {
435
+ // ignore click for browser’s default behavior
436
+ return;
437
+ }
438
+
439
+ e.preventDefault();
440
+
441
+ const navigate = () => {
442
+ // If the router is an NextRouter instance it will have `beforePopState`
443
+ if ('beforePopState' in router) {
444
+ router[replace ? 'replace' : 'push'](href, as, {
445
+ shallow,
446
+ locale,
447
+ scroll
448
+ });
449
+ } else {
450
+ // If `beforePopState` doesn't exist on the router it's the AppRouter.
451
+ const method = replace ? 'replace' : 'push';
452
+ router[method](href, {
453
+ forceOptimisticNavigation: !prefetchEnabled
454
+ });
455
+ }
456
+ };
457
+
458
+ if (isAppRouter) {
459
+ // @ts-expect-error startTransition exists.
460
+ _react.default.startTransition(navigate);
461
+ } else {
462
+ navigate();
463
+ }
464
+ }
465
+
466
+ const Link = /*#__PURE__*/_react.default.forwardRef(function LinkComponent(props, forwardedRef) {
467
+ if (false) { var createPropError; }
468
+
469
+ let children;
470
+
471
+ const {
472
+ href: hrefProp,
473
+ as: asProp,
474
+ children: childrenProp,
475
+ prefetch: prefetchProp,
476
+ passHref,
477
+ replace,
478
+ shallow,
479
+ scroll,
480
+ locale,
481
+ onClick,
482
+ onMouseEnter,
483
+ onTouchStart,
484
+ legacyBehavior = Boolean(false) !== true
485
+ } = props,
486
+ restProps = _object_without_properties_loose(props, ["href", "as", "children", "prefetch", "passHref", "replace", "shallow", "scroll", "locale", "onClick", "onMouseEnter", "onTouchStart", "legacyBehavior"]);
487
+
488
+ children = childrenProp;
489
+
490
+ if (legacyBehavior && (typeof children === 'string' || typeof children === 'number')) {
491
+ children = /*#__PURE__*/_react.default.createElement("a", null, children);
492
+ }
493
+
494
+ const p = prefetchProp !== false;
495
+
496
+ let router = _react.default.useContext(_routerContext.RouterContext); // TODO-APP: type error. Remove `as any`
497
+
498
+
499
+ const appRouter = _react.default.useContext(_appRouterContext.AppRouterContext);
500
+
501
+ if (appRouter) {
502
+ router = appRouter;
503
+ }
504
+
505
+ const {
506
+ href,
507
+ as
508
+ } = _react.default.useMemo(() => {
509
+ const [resolvedHref, resolvedAs] = (0, _router).resolveHref(router, hrefProp, true);
510
+ return {
511
+ href: resolvedHref,
512
+ as: asProp ? (0, _router).resolveHref(router, asProp) : resolvedAs || resolvedHref
513
+ };
514
+ }, [router, hrefProp, asProp]);
515
+
516
+ const previousHref = _react.default.useRef(href);
517
+
518
+ const previousAs = _react.default.useRef(as); // This will return the first child, if multiple are provided it will throw an error
519
+
520
+
521
+ let child;
522
+
523
+ if (legacyBehavior) {
524
+ if (false) {} else {
525
+ child = _react.default.Children.only(children);
526
+ }
527
+ }
528
+
529
+ const childRef = legacyBehavior ? child && typeof child === 'object' && child.ref : forwardedRef;
530
+ const [setIntersectionRef, isVisible, resetVisible] = (0, _useIntersection).useIntersection({
531
+ rootMargin: '200px'
532
+ });
533
+
534
+ const setRef = _react.default.useCallback(el => {
535
+ // Before the link getting observed, check if visible state need to be reset
536
+ if (previousAs.current !== as || previousHref.current !== href) {
537
+ resetVisible();
538
+ previousAs.current = as;
539
+ previousHref.current = href;
540
+ }
541
+
542
+ setIntersectionRef(el);
543
+
544
+ if (childRef) {
545
+ if (typeof childRef === 'function') childRef(el);else if (typeof childRef === 'object') {
546
+ childRef.current = el;
547
+ }
548
+ }
549
+ }, [as, childRef, href, resetVisible, setIntersectionRef]);
550
+
551
+ _react.default.useEffect(() => {
552
+ const shouldPrefetch = isVisible && p && (0, _router).isLocalURL(href);
553
+ const curLocale = typeof locale !== 'undefined' ? locale : router && router.locale;
554
+ const isPrefetched = prefetched[href + '%' + as + (curLocale ? '%' + curLocale : '')];
555
+
556
+ if (shouldPrefetch && !isPrefetched) {
557
+ prefetch(router, href, as, {
558
+ locale: curLocale
559
+ });
560
+ }
561
+ }, [as, href, isVisible, locale, p, router]);
562
+
563
+ const childProps = {
564
+ ref: setRef,
565
+ onClick: e => {
566
+ if (false) {}
567
+
568
+ if (!legacyBehavior && typeof onClick === 'function') {
569
+ onClick(e);
570
+ }
571
+
572
+ if (legacyBehavior && child.props && typeof child.props.onClick === 'function') {
573
+ child.props.onClick(e);
574
+ }
575
+
576
+ if (!e.defaultPrevented) {
577
+ linkClicked(e, router, href, as, replace, shallow, scroll, locale, Boolean(appRouter), p);
578
+ }
579
+ },
580
+ onMouseEnter: e => {
581
+ if (!legacyBehavior && typeof onMouseEnter === 'function') {
582
+ onMouseEnter(e);
583
+ }
584
+
585
+ if (legacyBehavior && child.props && typeof child.props.onMouseEnter === 'function') {
586
+ child.props.onMouseEnter(e);
587
+ } // Check for not prefetch disabled in page using appRouter
588
+
589
+
590
+ if (!(!p && appRouter)) {
591
+ if ((0, _router).isLocalURL(href)) {
592
+ prefetch(router, href, as, {
593
+ priority: true
594
+ });
595
+ }
596
+ }
597
+ },
598
+ onTouchStart: e => {
599
+ if (!legacyBehavior && typeof onTouchStart === 'function') {
600
+ onTouchStart(e);
601
+ }
602
+
603
+ if (legacyBehavior && child.props && typeof child.props.onTouchStart === 'function') {
604
+ child.props.onTouchStart(e);
605
+ } // Check for not prefetch disabled in page using appRouter
606
+
607
+
608
+ if (!(!p && appRouter)) {
609
+ if ((0, _router).isLocalURL(href)) {
610
+ prefetch(router, href, as, {
611
+ priority: true
612
+ });
613
+ }
614
+ }
615
+ }
616
+ }; // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is
617
+ // defined, we specify the current 'href', so that repetition is not needed by the user
618
+
619
+ if (!legacyBehavior || passHref || child.type === 'a' && !('href' in child.props)) {
620
+ const curLocale = typeof locale !== 'undefined' ? locale : router && router.locale; // we only render domain locales if we are currently on a domain locale
621
+ // so that locale links are still visitable in development/preview envs
622
+
623
+ const localeDomain = router && router.isLocaleDomain && (0, _getDomainLocale).getDomainLocale(as, curLocale, router.locales, router.domainLocales);
624
+ childProps.href = localeDomain || (0, _addBasePath).addBasePath((0, _addLocale).addLocale(as, curLocale, router && router.defaultLocale));
625
+ }
626
+
627
+ return legacyBehavior ? /*#__PURE__*/_react.default.cloneElement(child, childProps) : /*#__PURE__*/_react.default.createElement("a", Object.assign({}, restProps, childProps), children);
628
+ });
629
+
630
+ var _default = Link;
631
+ exports["default"] = _default;
632
+
633
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
634
+ Object.defineProperty(exports.default, '__esModule', {
635
+ value: true
636
+ });
637
+ Object.assign(exports.default, exports);
638
+ module.exports = exports.default;
639
+ }
640
+
641
+ /***/ }),
642
+
643
+ /***/ 6340:
644
+ /***/ ((module, exports, __webpack_require__) => {
645
+
646
+ "use strict";
647
+
648
+
649
+ Object.defineProperty(exports, "__esModule", ({
650
+ value: true
651
+ }));
652
+ exports.normalizeLocalePath = void 0;
653
+
654
+ const normalizeLocalePath = (pathname, locales) => {
655
+ if (true) {
656
+ return (__webpack_require__(4014).normalizeLocalePath)(pathname, locales);
657
+ }
658
+
659
+ return {
660
+ pathname,
661
+ detectedLocale: undefined
662
+ };
663
+ };
664
+
665
+ exports.normalizeLocalePath = normalizeLocalePath;
666
+
667
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
668
+ Object.defineProperty(exports.default, '__esModule', {
669
+ value: true
670
+ });
671
+ Object.assign(exports.default, exports);
672
+ module.exports = exports.default;
673
+ }
674
+
675
+ /***/ }),
676
+
677
+ /***/ 4969:
678
+ /***/ ((module, exports, __webpack_require__) => {
679
+
680
+ "use strict";
681
+
682
+
683
+ Object.defineProperty(exports, "__esModule", ({
684
+ value: true
685
+ }));
686
+ exports.normalizePathTrailingSlash = void 0;
687
+
688
+ var _removeTrailingSlash = __webpack_require__(3297);
689
+
690
+ var _parsePath = __webpack_require__(8854);
691
+
692
+ const normalizePathTrailingSlash = path => {
693
+ if (!path.startsWith('/') || undefined) {
694
+ return path;
695
+ }
696
+
697
+ const {
698
+ pathname,
699
+ query,
700
+ hash
701
+ } = (0, _parsePath).parsePath(path);
702
+
703
+ if (false) {}
704
+
705
+ return `${(0, _removeTrailingSlash).removeTrailingSlash(pathname)}${query}${hash}`;
706
+ };
707
+
708
+ exports.normalizePathTrailingSlash = normalizePathTrailingSlash;
709
+
710
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
711
+ Object.defineProperty(exports.default, '__esModule', {
712
+ value: true
713
+ });
714
+ Object.assign(exports.default, exports);
715
+ module.exports = exports.default;
716
+ }
717
+
718
+ /***/ }),
719
+
720
+ /***/ 5678:
721
+ /***/ ((module, exports, __webpack_require__) => {
722
+
723
+ "use strict";
724
+
725
+
726
+ Object.defineProperty(exports, "__esModule", ({
727
+ value: true
728
+ }));
729
+ exports.removeBasePath = removeBasePath;
730
+
731
+ var _hasBasePath = __webpack_require__(8771);
732
+
733
+ const basePath = false || '';
734
+
735
+ function removeBasePath(path) {
736
+ if (false) {}
737
+
738
+ path = path.slice(basePath.length);
739
+ if (!path.startsWith('/')) path = `/${path}`;
740
+ return path;
741
+ }
742
+
743
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
744
+ Object.defineProperty(exports.default, '__esModule', {
745
+ value: true
746
+ });
747
+ Object.assign(exports.default, exports);
748
+ module.exports = exports.default;
749
+ }
750
+
751
+ /***/ }),
752
+
753
+ /***/ 9781:
754
+ /***/ ((module, exports, __webpack_require__) => {
755
+
756
+ "use strict";
757
+
758
+
759
+ Object.defineProperty(exports, "__esModule", ({
760
+ value: true
761
+ }));
762
+ exports.removeLocale = removeLocale;
763
+
764
+ var _parsePath = __webpack_require__(8854);
765
+
766
+ function removeLocale(path, locale) {
767
+ if (true) {
768
+ const {
769
+ pathname
770
+ } = (0, _parsePath).parsePath(path);
771
+ const pathLower = pathname.toLowerCase();
772
+ const localeLower = locale == null ? void 0 : locale.toLowerCase();
773
+ return locale && (pathLower.startsWith(`/${localeLower}/`) || pathLower === `/${localeLower}`) ? `${pathname.length === locale.length + 1 ? `/` : ``}${path.slice(locale.length + 1)}` : path;
774
+ }
775
+
776
+ return path;
777
+ }
778
+
779
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
780
+ Object.defineProperty(exports.default, '__esModule', {
781
+ value: true
782
+ });
783
+ Object.assign(exports.default, exports);
784
+ module.exports = exports.default;
785
+ }
786
+
787
+ /***/ }),
788
+
789
+ /***/ 6286:
790
+ /***/ ((module, exports) => {
791
+
792
+ "use strict";
793
+
794
+
795
+ Object.defineProperty(exports, "__esModule", ({
796
+ value: true
797
+ }));
798
+ exports.cancelIdleCallback = exports.requestIdleCallback = void 0;
799
+
800
+ const requestIdleCallback = typeof self !== 'undefined' && self.requestIdleCallback && self.requestIdleCallback.bind(window) || function (cb) {
801
+ let start = Date.now();
802
+ return setTimeout(function () {
803
+ cb({
804
+ didTimeout: false,
805
+ timeRemaining: function () {
806
+ return Math.max(0, 50 - (Date.now() - start));
807
+ }
808
+ });
809
+ }, 1);
810
+ };
811
+
812
+ exports.requestIdleCallback = requestIdleCallback;
813
+
814
+ const cancelIdleCallback = typeof self !== 'undefined' && self.cancelIdleCallback && self.cancelIdleCallback.bind(window) || function (id) {
815
+ return clearTimeout(id);
816
+ };
817
+
818
+ exports.cancelIdleCallback = cancelIdleCallback;
819
+
820
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
821
+ Object.defineProperty(exports.default, '__esModule', {
822
+ value: true
823
+ });
824
+ Object.assign(exports.default, exports);
825
+ module.exports = exports.default;
826
+ }
827
+
828
+ /***/ }),
829
+
830
+ /***/ 4989:
831
+ /***/ ((module, exports, __webpack_require__) => {
832
+
833
+ "use strict";
834
+
835
+
836
+ Object.defineProperty(exports, "__esModule", ({
837
+ value: true
838
+ }));
839
+ exports.markAssetError = markAssetError;
840
+ exports.isAssetError = isAssetError;
841
+ exports.getClientBuildManifest = getClientBuildManifest;
842
+ exports.createRouteLoader = createRouteLoader;
843
+
844
+ var _interop_require_default = (__webpack_require__(2648)/* ["default"] */ .Z);
845
+
846
+ var _getAssetPathFromRoute = _interop_require_default(__webpack_require__(9565));
847
+
848
+ var _trustedTypes = __webpack_require__(5740);
849
+
850
+ var _requestIdleCallback = __webpack_require__(6286); // 3.8s was arbitrarily chosen as it's what https://web.dev/interactive
851
+ // considers as "Good" time-to-interactive. We must assume something went
852
+ // wrong beyond this point, and then fall-back to a full page transition to
853
+ // show the user something of value.
854
+
855
+
856
+ const MS_MAX_IDLE_DELAY = 3800;
857
+
858
+ function withFuture(key, map, generator) {
859
+ let entry = map.get(key);
860
+
861
+ if (entry) {
862
+ if ('future' in entry) {
863
+ return entry.future;
864
+ }
865
+
866
+ return Promise.resolve(entry);
867
+ }
868
+
869
+ let resolver;
870
+ const prom = new Promise(resolve => {
871
+ resolver = resolve;
872
+ });
873
+ map.set(key, entry = {
874
+ resolve: resolver,
875
+ future: prom
876
+ });
877
+ return generator ? generator() // eslint-disable-next-line no-sequences
878
+ .then(value => (resolver(value), value)).catch(err => {
879
+ map.delete(key);
880
+ throw err;
881
+ }) : prom;
882
+ }
883
+
884
+ function hasPrefetch(link) {
885
+ try {
886
+ link = document.createElement('link');
887
+ return (// detect IE11 since it supports prefetch but isn't detected
888
+ // with relList.support
889
+ !!window.MSInputMethodContext && !!document.documentMode || link.relList.supports('prefetch')
890
+ );
891
+ } catch (e) {
892
+ return false;
893
+ }
894
+ }
895
+
896
+ const canPrefetch = hasPrefetch();
897
+
898
+ function prefetchViaDom(href, as, link) {
899
+ return new Promise((res, rej) => {
900
+ const selector = `
901
+ link[rel="prefetch"][href^="${href}"],
902
+ link[rel="preload"][href^="${href}"],
903
+ script[src^="${href}"]`;
904
+
905
+ if (document.querySelector(selector)) {
906
+ return res();
907
+ }
908
+
909
+ link = document.createElement('link'); // The order of property assignment here is intentional:
910
+
911
+ if (as) link.as = as;
912
+ link.rel = `prefetch`;
913
+ link.crossOrigin = undefined;
914
+ link.onload = res;
915
+ link.onerror = rej; // `href` should always be last:
916
+
917
+ link.href = href;
918
+ document.head.appendChild(link);
919
+ });
920
+ }
921
+
922
+ const ASSET_LOAD_ERROR = Symbol('ASSET_LOAD_ERROR');
923
+
924
+ function markAssetError(err) {
925
+ return Object.defineProperty(err, ASSET_LOAD_ERROR, {});
926
+ }
927
+
928
+ function isAssetError(err) {
929
+ return err && ASSET_LOAD_ERROR in err;
930
+ }
931
+
932
+ function appendScript(src, script) {
933
+ return new Promise((resolve, reject) => {
934
+ script = document.createElement('script'); // The order of property assignment here is intentional.
935
+ // 1. Setup success/failure hooks in case the browser synchronously
936
+ // executes when `src` is set.
937
+
938
+ script.onload = resolve;
939
+
940
+ script.onerror = () => reject(markAssetError(new Error(`Failed to load script: ${src}`))); // 2. Configure the cross-origin attribute before setting `src` in case the
941
+ // browser begins to fetch.
942
+
943
+
944
+ script.crossOrigin = undefined; // 3. Finally, set the source and inject into the DOM in case the child
945
+ // must be appended for fetching to start.
946
+
947
+ script.src = src;
948
+ document.body.appendChild(script);
949
+ });
950
+ } // We wait for pages to be built in dev before we start the route transition
951
+ // timeout to prevent an un-necessary hard navigation in development.
952
+
953
+
954
+ let devBuildPromise; // Resolve a promise that times out after given amount of milliseconds.
955
+
956
+ function resolvePromiseWithTimeout(p, ms, err) {
957
+ return new Promise((resolve, reject) => {
958
+ let cancelled = false;
959
+ p.then(r => {
960
+ // Resolved, cancel the timeout
961
+ cancelled = true;
962
+ resolve(r);
963
+ }).catch(reject); // We wrap these checks separately for better dead-code elimination in
964
+ // production bundles.
965
+
966
+ if (false) {}
967
+
968
+ if (true) {
969
+ (0, _requestIdleCallback).requestIdleCallback(() => setTimeout(() => {
970
+ if (!cancelled) {
971
+ reject(err);
972
+ }
973
+ }, ms));
974
+ }
975
+ });
976
+ }
977
+
978
+ function getClientBuildManifest() {
979
+ if (self.__BUILD_MANIFEST) {
980
+ return Promise.resolve(self.__BUILD_MANIFEST);
981
+ }
982
+
983
+ const onBuildManifest = new Promise(resolve => {
984
+ // Mandatory because this is not concurrent safe:
985
+ const cb = self.__BUILD_MANIFEST_CB;
986
+
987
+ self.__BUILD_MANIFEST_CB = () => {
988
+ resolve(self.__BUILD_MANIFEST);
989
+ cb && cb();
990
+ };
991
+ });
992
+ return resolvePromiseWithTimeout(onBuildManifest, MS_MAX_IDLE_DELAY, markAssetError(new Error('Failed to load client build manifest')));
993
+ }
994
+
995
+ function getFilesForRoute(assetPrefix, route) {
996
+ if (false) {}
997
+
998
+ return getClientBuildManifest().then(manifest => {
999
+ if (!(route in manifest)) {
1000
+ throw markAssetError(new Error(`Failed to lookup route: ${route}`));
1001
+ }
1002
+
1003
+ const allFiles = manifest[route].map(entry => assetPrefix + '/_next/' + encodeURI(entry));
1004
+ return {
1005
+ scripts: allFiles.filter(v => v.endsWith('.js')).map(v => (0, _trustedTypes).__unsafeCreateTrustedScriptURL(v)),
1006
+ css: allFiles.filter(v => v.endsWith('.css'))
1007
+ };
1008
+ });
1009
+ }
1010
+
1011
+ function createRouteLoader(assetPrefix) {
1012
+ const entrypoints = new Map();
1013
+ const loadedScripts = new Map();
1014
+ const styleSheets = new Map();
1015
+ const routes = new Map();
1016
+
1017
+ function maybeExecuteScript(src) {
1018
+ // With HMR we might need to "reload" scripts when they are
1019
+ // disposed and readded. Executing scripts twice has no functional
1020
+ // differences
1021
+ if (true) {
1022
+ let prom = loadedScripts.get(src.toString());
1023
+
1024
+ if (prom) {
1025
+ return prom;
1026
+ } // Skip executing script if it's already in the DOM:
1027
+
1028
+
1029
+ if (document.querySelector(`script[src^="${src}"]`)) {
1030
+ return Promise.resolve();
1031
+ }
1032
+
1033
+ loadedScripts.set(src.toString(), prom = appendScript(src));
1034
+ return prom;
1035
+ } else {}
1036
+ }
1037
+
1038
+ function fetchStyleSheet(href) {
1039
+ let prom = styleSheets.get(href);
1040
+
1041
+ if (prom) {
1042
+ return prom;
1043
+ }
1044
+
1045
+ styleSheets.set(href, prom = fetch(href).then(res => {
1046
+ if (!res.ok) {
1047
+ throw new Error(`Failed to load stylesheet: ${href}`);
1048
+ }
1049
+
1050
+ return res.text().then(text => ({
1051
+ href: href,
1052
+ content: text
1053
+ }));
1054
+ }).catch(err => {
1055
+ throw markAssetError(err);
1056
+ }));
1057
+ return prom;
1058
+ }
1059
+
1060
+ return {
1061
+ whenEntrypoint(route) {
1062
+ return withFuture(route, entrypoints);
1063
+ },
1064
+
1065
+ onEntrypoint(route, execute) {
1066
+ (execute ? Promise.resolve().then(() => execute()).then(exports => ({
1067
+ component: exports && exports.default || exports,
1068
+ exports: exports
1069
+ }), err => ({
1070
+ error: err
1071
+ })) : Promise.resolve(undefined)).then(input => {
1072
+ const old = entrypoints.get(route);
1073
+
1074
+ if (old && 'resolve' in old) {
1075
+ if (input) {
1076
+ entrypoints.set(route, input);
1077
+ old.resolve(input);
1078
+ }
1079
+ } else {
1080
+ if (input) {
1081
+ entrypoints.set(route, input);
1082
+ } else {
1083
+ entrypoints.delete(route);
1084
+ } // when this entrypoint has been resolved before
1085
+ // the route is outdated and we want to invalidate
1086
+ // this cache entry
1087
+
1088
+
1089
+ routes.delete(route);
1090
+ }
1091
+ });
1092
+ },
1093
+
1094
+ loadRoute(route, prefetch) {
1095
+ return withFuture(route, routes, () => {
1096
+ let devBuildPromiseResolve;
1097
+
1098
+ if (false) {}
1099
+
1100
+ return resolvePromiseWithTimeout(getFilesForRoute(assetPrefix, route).then(({
1101
+ scripts,
1102
+ css
1103
+ }) => {
1104
+ return Promise.all([entrypoints.has(route) ? [] : Promise.all(scripts.map(maybeExecuteScript)), Promise.all(css.map(fetchStyleSheet))]);
1105
+ }).then(res => {
1106
+ return this.whenEntrypoint(route).then(entrypoint => ({
1107
+ entrypoint,
1108
+ styles: res[1]
1109
+ }));
1110
+ }), MS_MAX_IDLE_DELAY, markAssetError(new Error(`Route did not complete loading: ${route}`))).then(({
1111
+ entrypoint,
1112
+ styles
1113
+ }) => {
1114
+ const res = Object.assign({
1115
+ styles: styles
1116
+ }, entrypoint);
1117
+ return 'error' in entrypoint ? entrypoint : res;
1118
+ }).catch(err => {
1119
+ if (prefetch) {
1120
+ // we don't want to cache errors during prefetch
1121
+ throw err;
1122
+ }
1123
+
1124
+ return {
1125
+ error: err
1126
+ };
1127
+ }).finally(() => {
1128
+ return devBuildPromiseResolve == null ? void 0 : devBuildPromiseResolve();
1129
+ });
1130
+ });
1131
+ },
1132
+
1133
+ prefetch(route) {
1134
+ // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
1135
+ // License: Apache 2.0
1136
+ let cn;
1137
+
1138
+ if (cn = navigator.connection) {
1139
+ // Don't prefetch if using 2G or if Save-Data is enabled.
1140
+ if (cn.saveData || /2g/.test(cn.effectiveType)) return Promise.resolve();
1141
+ }
1142
+
1143
+ return getFilesForRoute(assetPrefix, route).then(output => Promise.all(canPrefetch ? output.scripts.map(script => prefetchViaDom(script.toString(), 'script')) : [])).then(() => {
1144
+ (0, _requestIdleCallback).requestIdleCallback(() => this.loadRoute(route, true).catch(() => {}));
1145
+ }).catch( // swallow prefetch errors
1146
+ () => {});
1147
+ }
1148
+
1149
+ };
1150
+ }
1151
+
1152
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
1153
+ Object.defineProperty(exports.default, '__esModule', {
1154
+ value: true
1155
+ });
1156
+ Object.assign(exports.default, exports);
1157
+ module.exports = exports.default;
1158
+ }
1159
+
1160
+ /***/ }),
1161
+
1162
+ /***/ 2189:
1163
+ /***/ ((module, exports, __webpack_require__) => {
1164
+
1165
+ "client";
1166
+ "use strict";
1167
+
1168
+ Object.defineProperty(exports, "__esModule", ({
1169
+ value: true
1170
+ }));
1171
+ exports.handleClientScriptLoad = handleClientScriptLoad;
1172
+ exports.initScriptLoader = initScriptLoader;
1173
+ exports["default"] = void 0;
1174
+
1175
+ var _extends = (__webpack_require__(6495)/* ["default"] */ .Z);
1176
+
1177
+ var _interop_require_wildcard = (__webpack_require__(1598)/* ["default"] */ .Z);
1178
+
1179
+ var _object_without_properties_loose = (__webpack_require__(7273)/* ["default"] */ .Z);
1180
+
1181
+ var _react = _interop_require_wildcard(__webpack_require__(6689));
1182
+
1183
+ var _headManagerContext = __webpack_require__(2796);
1184
+
1185
+ var _headManager = __webpack_require__(877);
1186
+
1187
+ var _requestIdleCallback = __webpack_require__(6286);
1188
+
1189
+ 'client';
1190
+ const ScriptCache = new Map();
1191
+ const LoadCache = new Set();
1192
+ const ignoreProps = ['onLoad', 'onReady', 'dangerouslySetInnerHTML', 'children', 'onError', 'strategy'];
1193
+
1194
+ const loadScript = props => {
1195
+ const {
1196
+ src,
1197
+ id,
1198
+ onLoad = () => {},
1199
+ onReady = null,
1200
+ dangerouslySetInnerHTML,
1201
+ children = '',
1202
+ strategy = 'afterInteractive',
1203
+ onError
1204
+ } = props;
1205
+ const cacheKey = id || src; // Script has already loaded
1206
+
1207
+ if (cacheKey && LoadCache.has(cacheKey)) {
1208
+ return;
1209
+ } // Contents of this script are already loading/loaded
1210
+
1211
+
1212
+ if (ScriptCache.has(src)) {
1213
+ LoadCache.add(cacheKey); // It is possible that multiple `next/script` components all have same "src", but has different "onLoad"
1214
+ // This is to make sure the same remote script will only load once, but "onLoad" are executed in order
1215
+
1216
+ ScriptCache.get(src).then(onLoad, onError);
1217
+ return;
1218
+ }
1219
+ /** Execute after the script first loaded */
1220
+
1221
+
1222
+ const afterLoad = () => {
1223
+ // Run onReady for the first time after load event
1224
+ if (onReady) {
1225
+ onReady();
1226
+ } // add cacheKey to LoadCache when load successfully
1227
+
1228
+
1229
+ LoadCache.add(cacheKey);
1230
+ };
1231
+
1232
+ const el = document.createElement('script');
1233
+ const loadPromise = new Promise((resolve, reject) => {
1234
+ el.addEventListener('load', function (e) {
1235
+ resolve();
1236
+
1237
+ if (onLoad) {
1238
+ onLoad.call(this, e);
1239
+ }
1240
+
1241
+ afterLoad();
1242
+ });
1243
+ el.addEventListener('error', function (e) {
1244
+ reject(e);
1245
+ });
1246
+ }).catch(function (e) {
1247
+ if (onError) {
1248
+ onError(e);
1249
+ }
1250
+ });
1251
+
1252
+ if (dangerouslySetInnerHTML) {
1253
+ el.innerHTML = dangerouslySetInnerHTML.__html || '';
1254
+ afterLoad();
1255
+ } else if (children) {
1256
+ el.textContent = typeof children === 'string' ? children : Array.isArray(children) ? children.join('') : '';
1257
+ afterLoad();
1258
+ } else if (src) {
1259
+ el.src = src; // do not add cacheKey into LoadCache for remote script here
1260
+ // cacheKey will be added to LoadCache when it is actually loaded (see loadPromise above)
1261
+
1262
+ ScriptCache.set(src, loadPromise);
1263
+ }
1264
+
1265
+ for (const [k, value] of Object.entries(props)) {
1266
+ if (value === undefined || ignoreProps.includes(k)) {
1267
+ continue;
1268
+ }
1269
+
1270
+ const attr = _headManager.DOMAttributeNames[k] || k.toLowerCase();
1271
+ el.setAttribute(attr, value);
1272
+ }
1273
+
1274
+ if (strategy === 'worker') {
1275
+ el.setAttribute('type', 'text/partytown');
1276
+ }
1277
+
1278
+ el.setAttribute('data-nscript', strategy);
1279
+ document.body.appendChild(el);
1280
+ };
1281
+
1282
+ function handleClientScriptLoad(props) {
1283
+ const {
1284
+ strategy = 'afterInteractive'
1285
+ } = props;
1286
+
1287
+ if (strategy === 'lazyOnload') {
1288
+ window.addEventListener('load', () => {
1289
+ (0, _requestIdleCallback).requestIdleCallback(() => loadScript(props));
1290
+ });
1291
+ } else {
1292
+ loadScript(props);
1293
+ }
1294
+ }
1295
+
1296
+ function loadLazyScript(props) {
1297
+ if (document.readyState === 'complete') {
1298
+ (0, _requestIdleCallback).requestIdleCallback(() => loadScript(props));
1299
+ } else {
1300
+ window.addEventListener('load', () => {
1301
+ (0, _requestIdleCallback).requestIdleCallback(() => loadScript(props));
1302
+ });
1303
+ }
1304
+ }
1305
+
1306
+ function addBeforeInteractiveToCache() {
1307
+ const scripts = [...document.querySelectorAll('[data-nscript="beforeInteractive"]'), ...document.querySelectorAll('[data-nscript="beforePageRender"]')];
1308
+ scripts.forEach(script => {
1309
+ const cacheKey = script.id || script.getAttribute('src');
1310
+ LoadCache.add(cacheKey);
1311
+ });
1312
+ }
1313
+
1314
+ function initScriptLoader(scriptLoaderItems) {
1315
+ scriptLoaderItems.forEach(handleClientScriptLoad);
1316
+ addBeforeInteractiveToCache();
1317
+ }
1318
+
1319
+ function Script(props) {
1320
+ const {
1321
+ id,
1322
+ src = '',
1323
+ onLoad = () => {},
1324
+ onReady = null,
1325
+ strategy = 'afterInteractive',
1326
+ onError
1327
+ } = props,
1328
+ restProps = _object_without_properties_loose(props, ["id", "src", "onLoad", "onReady", "strategy", "onError"]); // Context is available only during SSR
1329
+
1330
+
1331
+ const {
1332
+ updateScripts,
1333
+ scripts,
1334
+ getIsSsr
1335
+ } = (0, _react).useContext(_headManagerContext.HeadManagerContext);
1336
+ /**
1337
+ * - First mount:
1338
+ * 1. The useEffect for onReady executes
1339
+ * 2. hasOnReadyEffectCalled.current is false, but the script hasn't loaded yet (not in LoadCache)
1340
+ * onReady is skipped, set hasOnReadyEffectCalled.current to true
1341
+ * 3. The useEffect for loadScript executes
1342
+ * 4. hasLoadScriptEffectCalled.current is false, loadScript executes
1343
+ * Once the script is loaded, the onLoad and onReady will be called by then
1344
+ * [If strict mode is enabled / is wrapped in <OffScreen /> component]
1345
+ * 5. The useEffect for onReady executes again
1346
+ * 6. hasOnReadyEffectCalled.current is true, so entire effect is skipped
1347
+ * 7. The useEffect for loadScript executes again
1348
+ * 8. hasLoadScriptEffectCalled.current is true, so entire effect is skipped
1349
+ *
1350
+ * - Second mount:
1351
+ * 1. The useEffect for onReady executes
1352
+ * 2. hasOnReadyEffectCalled.current is false, but the script has already loaded (found in LoadCache)
1353
+ * onReady is called, set hasOnReadyEffectCalled.current to true
1354
+ * 3. The useEffect for loadScript executes
1355
+ * 4. The script is already loaded, loadScript bails out
1356
+ * [If strict mode is enabled / is wrapped in <OffScreen /> component]
1357
+ * 5. The useEffect for onReady executes again
1358
+ * 6. hasOnReadyEffectCalled.current is true, so entire effect is skipped
1359
+ * 7. The useEffect for loadScript executes again
1360
+ * 8. hasLoadScriptEffectCalled.current is true, so entire effect is skipped
1361
+ */
1362
+
1363
+ const hasOnReadyEffectCalled = (0, _react).useRef(false);
1364
+ (0, _react).useEffect(() => {
1365
+ const cacheKey = id || src;
1366
+
1367
+ if (!hasOnReadyEffectCalled.current) {
1368
+ // Run onReady if script has loaded before but component is re-mounted
1369
+ if (onReady && cacheKey && LoadCache.has(cacheKey)) {
1370
+ onReady();
1371
+ }
1372
+
1373
+ hasOnReadyEffectCalled.current = true;
1374
+ }
1375
+ }, [onReady, id, src]);
1376
+ const hasLoadScriptEffectCalled = (0, _react).useRef(false);
1377
+ (0, _react).useEffect(() => {
1378
+ if (!hasLoadScriptEffectCalled.current) {
1379
+ if (strategy === 'afterInteractive') {
1380
+ loadScript(props);
1381
+ } else if (strategy === 'lazyOnload') {
1382
+ loadLazyScript(props);
1383
+ }
1384
+
1385
+ hasLoadScriptEffectCalled.current = true;
1386
+ }
1387
+ }, [props, strategy]);
1388
+
1389
+ if (strategy === 'beforeInteractive' || strategy === 'worker') {
1390
+ if (updateScripts) {
1391
+ scripts[strategy] = (scripts[strategy] || []).concat([_extends({
1392
+ id,
1393
+ src,
1394
+ onLoad,
1395
+ onReady,
1396
+ onError
1397
+ }, restProps)]);
1398
+ updateScripts(scripts);
1399
+ } else if (getIsSsr && getIsSsr()) {
1400
+ // Script has already loaded during SSR
1401
+ LoadCache.add(id || src);
1402
+ } else if (getIsSsr && !getIsSsr()) {
1403
+ loadScript(props);
1404
+ }
1405
+ }
1406
+
1407
+ return null;
1408
+ }
1409
+
1410
+ Object.defineProperty(Script, '__nextScript', {
1411
+ value: true
1412
+ });
1413
+ var _default = Script;
1414
+ exports["default"] = _default;
1415
+
1416
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
1417
+ Object.defineProperty(exports.default, '__esModule', {
1418
+ value: true
1419
+ });
1420
+ Object.assign(exports.default, exports);
1421
+ module.exports = exports.default;
1422
+ }
1423
+
1424
+ /***/ }),
1425
+
1426
+ /***/ 5740:
1427
+ /***/ ((module, exports) => {
1428
+
1429
+ "use strict";
1430
+
1431
+
1432
+ Object.defineProperty(exports, "__esModule", ({
1433
+ value: true
1434
+ }));
1435
+ exports.__unsafeCreateTrustedScriptURL = __unsafeCreateTrustedScriptURL;
1436
+ /**
1437
+ * Stores the Trusted Types Policy. Starts as undefined and can be set to null
1438
+ * if Trusted Types is not supported in the browser.
1439
+ */
1440
+
1441
+ let policy;
1442
+ /**
1443
+ * Getter for the Trusted Types Policy. If it is undefined, it is instantiated
1444
+ * here or set to null if Trusted Types is not supported in the browser.
1445
+ */
1446
+
1447
+ function getPolicy() {
1448
+ if (typeof policy === 'undefined' && false) { var ref; }
1449
+
1450
+ return policy;
1451
+ }
1452
+
1453
+ function __unsafeCreateTrustedScriptURL(url) {
1454
+ var ref;
1455
+ return ((ref = getPolicy()) == null ? void 0 : ref.createScriptURL(url)) || url;
1456
+ }
1457
+
1458
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
1459
+ Object.defineProperty(exports.default, '__esModule', {
1460
+ value: true
1461
+ });
1462
+ Object.assign(exports.default, exports);
1463
+ module.exports = exports.default;
1464
+ }
1465
+
1466
+ /***/ }),
1467
+
1468
+ /***/ 639:
1469
+ /***/ ((module, exports, __webpack_require__) => {
1470
+
1471
+ "use strict";
1472
+
1473
+
1474
+ Object.defineProperty(exports, "__esModule", ({
1475
+ value: true
1476
+ }));
1477
+ exports.useIntersection = useIntersection;
1478
+
1479
+ var _react = __webpack_require__(6689);
1480
+
1481
+ var _requestIdleCallback = __webpack_require__(6286);
1482
+
1483
+ const hasIntersectionObserver = typeof IntersectionObserver === 'function';
1484
+ const observers = new Map();
1485
+ const idList = [];
1486
+
1487
+ function createObserver(options) {
1488
+ const id = {
1489
+ root: options.root || null,
1490
+ margin: options.rootMargin || ''
1491
+ };
1492
+ const existing = idList.find(obj => obj.root === id.root && obj.margin === id.margin);
1493
+ let instance;
1494
+
1495
+ if (existing) {
1496
+ instance = observers.get(existing);
1497
+
1498
+ if (instance) {
1499
+ return instance;
1500
+ }
1501
+ }
1502
+
1503
+ const elements = new Map();
1504
+ const observer = new IntersectionObserver(entries => {
1505
+ entries.forEach(entry => {
1506
+ const callback = elements.get(entry.target);
1507
+ const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
1508
+
1509
+ if (callback && isVisible) {
1510
+ callback(isVisible);
1511
+ }
1512
+ });
1513
+ }, options);
1514
+ instance = {
1515
+ id,
1516
+ observer,
1517
+ elements
1518
+ };
1519
+ idList.push(id);
1520
+ observers.set(id, instance);
1521
+ return instance;
1522
+ }
1523
+
1524
+ function observe(element, callback, options) {
1525
+ const {
1526
+ id,
1527
+ observer,
1528
+ elements
1529
+ } = createObserver(options);
1530
+ elements.set(element, callback);
1531
+ observer.observe(element);
1532
+ return function unobserve() {
1533
+ elements.delete(element);
1534
+ observer.unobserve(element); // Destroy observer when there's nothing left to watch:
1535
+
1536
+ if (elements.size === 0) {
1537
+ observer.disconnect();
1538
+ observers.delete(id);
1539
+ const index = idList.findIndex(obj => obj.root === id.root && obj.margin === id.margin);
1540
+
1541
+ if (index > -1) {
1542
+ idList.splice(index, 1);
1543
+ }
1544
+ }
1545
+ };
1546
+ }
1547
+
1548
+ function useIntersection({
1549
+ rootRef,
1550
+ rootMargin,
1551
+ disabled
1552
+ }) {
1553
+ const isDisabled = disabled || !hasIntersectionObserver;
1554
+ const [visible, setVisible] = (0, _react).useState(false);
1555
+ const [element, setElement] = (0, _react).useState(null);
1556
+ (0, _react).useEffect(() => {
1557
+ if (hasIntersectionObserver) {
1558
+ if (isDisabled || visible) return;
1559
+
1560
+ if (element && element.tagName) {
1561
+ const unobserve = observe(element, isVisible => isVisible && setVisible(isVisible), {
1562
+ root: rootRef == null ? void 0 : rootRef.current,
1563
+ rootMargin
1564
+ });
1565
+ return unobserve;
1566
+ }
1567
+ } else {
1568
+ if (!visible) {
1569
+ const idleCallback = (0, _requestIdleCallback).requestIdleCallback(() => setVisible(true));
1570
+ return () => (0, _requestIdleCallback).cancelIdleCallback(idleCallback);
1571
+ }
1572
+ }
1573
+ }, [element, isDisabled, rootMargin, rootRef, visible]);
1574
+ const resetVisible = (0, _react).useCallback(() => {
1575
+ setVisible(false);
1576
+ }, []);
1577
+ return [setElement, visible, resetVisible];
1578
+ }
1579
+
1580
+ if ((typeof exports.default === 'function' || typeof exports.default === 'object' && exports.default !== null) && typeof exports.default.__esModule === 'undefined') {
1581
+ Object.defineProperty(exports.default, '__esModule', {
1582
+ value: true
1583
+ });
1584
+ Object.assign(exports.default, exports);
1585
+ module.exports = exports.default;
1586
+ }
1587
+
1588
+ /***/ }),
1589
+
1590
+ /***/ 5781:
1591
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1592
+
1593
+ "use strict";
1594
+
1595
+
1596
+ Object.defineProperty(exports, "__esModule", ({
1597
+ value: true
1598
+ }));
1599
+ exports.matchesMiddleware = matchesMiddleware;
1600
+ exports.isLocalURL = isLocalURL;
1601
+ exports.interpolateAs = interpolateAs;
1602
+ exports.resolveHref = resolveHref;
1603
+ exports.createKey = createKey;
1604
+ exports["default"] = void 0;
1605
+
1606
+ var _async_to_generator = (__webpack_require__(932)/* ["default"] */ .Z);
1607
+
1608
+ var _extends = (__webpack_require__(6495)/* ["default"] */ .Z);
1609
+
1610
+ var _interop_require_default = (__webpack_require__(2648)/* ["default"] */ .Z);
1611
+
1612
+ var _interop_require_wildcard = (__webpack_require__(1598)/* ["default"] */ .Z);
1613
+
1614
+ var _normalizeTrailingSlash = __webpack_require__(4969);
1615
+
1616
+ var _removeTrailingSlash = __webpack_require__(3297);
1617
+
1618
+ var _routeLoader = __webpack_require__(4989);
1619
+
1620
+ var _script = __webpack_require__(2189);
1621
+
1622
+ var _isError = _interop_require_wildcard(__webpack_require__(676));
1623
+
1624
+ var _denormalizePagePath = __webpack_require__(4406);
1625
+
1626
+ var _normalizeLocalePath = __webpack_require__(4014);
1627
+
1628
+ var _mitt = _interop_require_default(__webpack_require__(8020));
1629
+
1630
+ var _utils = __webpack_require__(9232);
1631
+
1632
+ var _isDynamic = __webpack_require__(1428);
1633
+
1634
+ var _parseRelativeUrl = __webpack_require__(1292);
1635
+
1636
+ var _querystring = __webpack_require__(979);
1637
+
1638
+ var _resolveRewrites = _interop_require_default(__webpack_require__(6052));
1639
+
1640
+ var _routeMatcher = __webpack_require__(4226);
1641
+
1642
+ var _routeRegex = __webpack_require__(5052);
1643
+
1644
+ var _formatUrl = __webpack_require__(3938);
1645
+
1646
+ var _detectDomainLocale = __webpack_require__(7565);
1647
+
1648
+ var _parsePath = __webpack_require__(8854);
1649
+
1650
+ var _addLocale = __webpack_require__(7995);
1651
+
1652
+ var _removeLocale = __webpack_require__(9781);
1653
+
1654
+ var _removeBasePath = __webpack_require__(5678);
1655
+
1656
+ var _addBasePath = __webpack_require__(227);
1657
+
1658
+ var _hasBasePath = __webpack_require__(8771);
1659
+
1660
+ var _getNextPathnameInfo = __webpack_require__(5789);
1661
+
1662
+ var _formatNextPathnameInfo = __webpack_require__(299);
1663
+
1664
+ var _compareStates = __webpack_require__(6220);
1665
+
1666
+ var _isBot = __webpack_require__(1897);
1667
+
1668
+ function buildCancellationError() {
1669
+ return Object.assign(new Error('Route Cancelled'), {
1670
+ cancelled: true
1671
+ });
1672
+ }
1673
+
1674
+ function matchesMiddleware(options) {
1675
+ return _matchesMiddleware.apply(this, arguments);
1676
+ }
1677
+
1678
+ function _matchesMiddleware() {
1679
+ _matchesMiddleware = _async_to_generator(function* (options) {
1680
+ const matchers = yield Promise.resolve(options.router.pageLoader.getMiddleware());
1681
+ if (!matchers) return false;
1682
+ const {
1683
+ pathname: asPathname
1684
+ } = (0, _parsePath).parsePath(options.asPath); // remove basePath first since path prefix has to be in the order of `/${basePath}/${locale}`
1685
+
1686
+ const cleanedAs = (0, _hasBasePath).hasBasePath(asPathname) ? (0, _removeBasePath).removeBasePath(asPathname) : asPathname;
1687
+ const asWithBasePathAndLocale = (0, _addBasePath).addBasePath((0, _addLocale).addLocale(cleanedAs, options.locale)); // Check only path match on client. Matching "has" should be done on server
1688
+ // where we can access more info such as headers, HttpOnly cookie, etc.
1689
+
1690
+ return matchers.some(m => new RegExp(m.regexp).test(asWithBasePathAndLocale));
1691
+ });
1692
+ return _matchesMiddleware.apply(this, arguments);
1693
+ }
1694
+
1695
+ function stripOrigin(url) {
1696
+ const origin = (0, _utils).getLocationOrigin();
1697
+ return url.startsWith(origin) ? url.substring(origin.length) : url;
1698
+ }
1699
+
1700
+ function omit(object, keys) {
1701
+ const omitted = {};
1702
+ Object.keys(object).forEach(key => {
1703
+ if (!keys.includes(key)) {
1704
+ omitted[key] = object[key];
1705
+ }
1706
+ });
1707
+ return omitted;
1708
+ }
1709
+
1710
+ function isLocalURL(url) {
1711
+ // prevent a hydration mismatch on href for url with anchor refs
1712
+ if (!(0, _utils).isAbsoluteUrl(url)) return true;
1713
+
1714
+ try {
1715
+ // absolute urls can be local if they are on the same origin
1716
+ const locationOrigin = (0, _utils).getLocationOrigin();
1717
+ const resolved = new URL(url, locationOrigin);
1718
+ return resolved.origin === locationOrigin && (0, _hasBasePath).hasBasePath(resolved.pathname);
1719
+ } catch (_) {
1720
+ return false;
1721
+ }
1722
+ }
1723
+
1724
+ function interpolateAs(route, asPathname, query) {
1725
+ let interpolatedRoute = '';
1726
+ const dynamicRegex = (0, _routeRegex).getRouteRegex(route);
1727
+ const dynamicGroups = dynamicRegex.groups;
1728
+ const dynamicMatches = // Try to match the dynamic route against the asPath
1729
+ (asPathname !== route ? (0, _routeMatcher).getRouteMatcher(dynamicRegex)(asPathname) : '') || // Fall back to reading the values from the href
1730
+ // TODO: should this take priority; also need to change in the router.
1731
+ query;
1732
+ interpolatedRoute = route;
1733
+ const params = Object.keys(dynamicGroups);
1734
+
1735
+ if (!params.every(param => {
1736
+ let value = dynamicMatches[param] || '';
1737
+ const {
1738
+ repeat,
1739
+ optional
1740
+ } = dynamicGroups[param]; // support single-level catch-all
1741
+ // TODO: more robust handling for user-error (passing `/`)
1742
+
1743
+ let replaced = `[${repeat ? '...' : ''}${param}]`;
1744
+
1745
+ if (optional) {
1746
+ replaced = `${!value ? '/' : ''}[${replaced}]`;
1747
+ }
1748
+
1749
+ if (repeat && !Array.isArray(value)) value = [value];
1750
+ return (optional || param in dynamicMatches) && ( // Interpolate group into data URL if present
1751
+ interpolatedRoute = interpolatedRoute.replace(replaced, repeat ? value.map( // these values should be fully encoded instead of just
1752
+ // path delimiter escaped since they are being inserted
1753
+ // into the URL and we expect URL encoded segments
1754
+ // when parsing dynamic route params
1755
+ segment => encodeURIComponent(segment)).join('/') : encodeURIComponent(value)) || '/');
1756
+ })) {
1757
+ interpolatedRoute = '' // did not satisfy all requirements
1758
+ ; // n.b. We ignore this error because we handle warning for this case in
1759
+ // development in the `<Link>` component directly.
1760
+ }
1761
+
1762
+ return {
1763
+ params,
1764
+ result: interpolatedRoute
1765
+ };
1766
+ }
1767
+
1768
+ function resolveHref(router, href, resolveAs) {
1769
+ // we use a dummy base url for relative urls
1770
+ let base;
1771
+ let urlAsString = typeof href === 'string' ? href : (0, _formatUrl).formatWithValidation(href); // repeated slashes and backslashes in the URL are considered
1772
+ // invalid and will never match a Next.js page/file
1773
+
1774
+ const urlProtoMatch = urlAsString.match(/^[a-zA-Z]{1,}:\/\//);
1775
+ const urlAsStringNoProto = urlProtoMatch ? urlAsString.slice(urlProtoMatch[0].length) : urlAsString;
1776
+ const urlParts = urlAsStringNoProto.split('?');
1777
+
1778
+ if ((urlParts[0] || '').match(/(\/\/|\\)/)) {
1779
+ console.error(`Invalid href passed to next/router: ${urlAsString}, repeated forward-slashes (//) or backslashes \\ are not valid in the href`);
1780
+ const normalizedUrl = (0, _utils).normalizeRepeatedSlashes(urlAsStringNoProto);
1781
+ urlAsString = (urlProtoMatch ? urlProtoMatch[0] : '') + normalizedUrl;
1782
+ } // Return because it cannot be routed by the Next.js router
1783
+
1784
+
1785
+ if (!isLocalURL(urlAsString)) {
1786
+ return resolveAs ? [urlAsString] : urlAsString;
1787
+ }
1788
+
1789
+ try {
1790
+ base = new URL(urlAsString.startsWith('#') ? router.asPath : router.pathname, 'http://n');
1791
+ } catch (_) {
1792
+ // fallback to / for invalid asPath values e.g. //
1793
+ base = new URL('/', 'http://n');
1794
+ }
1795
+
1796
+ try {
1797
+ const finalUrl = new URL(urlAsString, base);
1798
+ finalUrl.pathname = (0, _normalizeTrailingSlash).normalizePathTrailingSlash(finalUrl.pathname);
1799
+ let interpolatedAs = '';
1800
+
1801
+ if ((0, _isDynamic).isDynamicRoute(finalUrl.pathname) && finalUrl.searchParams && resolveAs) {
1802
+ const query = (0, _querystring).searchParamsToUrlQuery(finalUrl.searchParams);
1803
+ const {
1804
+ result,
1805
+ params
1806
+ } = interpolateAs(finalUrl.pathname, finalUrl.pathname, query);
1807
+
1808
+ if (result) {
1809
+ interpolatedAs = (0, _formatUrl).formatWithValidation({
1810
+ pathname: result,
1811
+ hash: finalUrl.hash,
1812
+ query: omit(query, params)
1813
+ });
1814
+ }
1815
+ } // if the origin didn't change, it means we received a relative href
1816
+
1817
+
1818
+ const resolvedHref = finalUrl.origin === base.origin ? finalUrl.href.slice(finalUrl.origin.length) : finalUrl.href;
1819
+ return resolveAs ? [resolvedHref, interpolatedAs || resolvedHref] : resolvedHref;
1820
+ } catch (_1) {
1821
+ return resolveAs ? [urlAsString] : urlAsString;
1822
+ }
1823
+ }
1824
+
1825
+ function prepareUrlAs(router, url, as) {
1826
+ // If url and as provided as an object representation,
1827
+ // we'll format them into the string version here.
1828
+ let [resolvedHref, resolvedAs] = resolveHref(router, url, true);
1829
+ const origin = (0, _utils).getLocationOrigin();
1830
+ const hrefHadOrigin = resolvedHref.startsWith(origin);
1831
+ const asHadOrigin = resolvedAs && resolvedAs.startsWith(origin);
1832
+ resolvedHref = stripOrigin(resolvedHref);
1833
+ resolvedAs = resolvedAs ? stripOrigin(resolvedAs) : resolvedAs;
1834
+ const preparedUrl = hrefHadOrigin ? resolvedHref : (0, _addBasePath).addBasePath(resolvedHref);
1835
+ const preparedAs = as ? stripOrigin(resolveHref(router, as)) : resolvedAs || resolvedHref;
1836
+ return {
1837
+ url: preparedUrl,
1838
+ as: asHadOrigin ? preparedAs : (0, _addBasePath).addBasePath(preparedAs)
1839
+ };
1840
+ }
1841
+
1842
+ function resolveDynamicRoute(pathname, pages) {
1843
+ const cleanPathname = (0, _removeTrailingSlash).removeTrailingSlash((0, _denormalizePagePath).denormalizePagePath(pathname));
1844
+
1845
+ if (cleanPathname === '/404' || cleanPathname === '/_error') {
1846
+ return pathname;
1847
+ } // handle resolving href for dynamic routes
1848
+
1849
+
1850
+ if (!pages.includes(cleanPathname)) {
1851
+ // eslint-disable-next-line array-callback-return
1852
+ pages.some(page => {
1853
+ if ((0, _isDynamic).isDynamicRoute(page) && (0, _routeRegex).getRouteRegex(page).re.test(cleanPathname)) {
1854
+ pathname = page;
1855
+ return true;
1856
+ }
1857
+ });
1858
+ }
1859
+
1860
+ return (0, _removeTrailingSlash).removeTrailingSlash(pathname);
1861
+ }
1862
+
1863
+ function getMiddlewareData(source, response, options) {
1864
+ const nextConfig = {
1865
+ basePath: options.router.basePath,
1866
+ i18n: {
1867
+ locales: options.router.locales
1868
+ },
1869
+ trailingSlash: Boolean(false)
1870
+ };
1871
+ const rewriteHeader = response.headers.get('x-nextjs-rewrite');
1872
+ let rewriteTarget = rewriteHeader || response.headers.get('x-nextjs-matched-path');
1873
+ const matchedPath = response.headers.get('x-matched-path');
1874
+
1875
+ if (matchedPath && !rewriteTarget && !matchedPath.includes('__next_data_catchall') && !matchedPath.includes('/_error') && !matchedPath.includes('/404')) {
1876
+ // leverage x-matched-path to detect next.config.js rewrites
1877
+ rewriteTarget = matchedPath;
1878
+ }
1879
+
1880
+ if (rewriteTarget) {
1881
+ if (rewriteTarget.startsWith('/')) {
1882
+ const parsedRewriteTarget = (0, _parseRelativeUrl).parseRelativeUrl(rewriteTarget);
1883
+ const pathnameInfo = (0, _getNextPathnameInfo).getNextPathnameInfo(parsedRewriteTarget.pathname, {
1884
+ nextConfig,
1885
+ parseData: true
1886
+ });
1887
+ let fsPathname = (0, _removeTrailingSlash).removeTrailingSlash(pathnameInfo.pathname);
1888
+ return Promise.all([options.router.pageLoader.getPageList(), (0, _routeLoader).getClientBuildManifest()]).then(([pages, {
1889
+ __rewrites: rewrites
1890
+ }]) => {
1891
+ let as = (0, _addLocale).addLocale(pathnameInfo.pathname, pathnameInfo.locale);
1892
+
1893
+ if ((0, _isDynamic).isDynamicRoute(as) || !rewriteHeader && pages.includes((0, _normalizeLocalePath).normalizeLocalePath((0, _removeBasePath).removeBasePath(as), options.router.locales).pathname)) {
1894
+ const parsedSource = (0, _getNextPathnameInfo).getNextPathnameInfo((0, _parseRelativeUrl).parseRelativeUrl(source).pathname, {
1895
+ parseData: true
1896
+ });
1897
+ as = (0, _addBasePath).addBasePath(parsedSource.pathname);
1898
+ parsedRewriteTarget.pathname = as;
1899
+ }
1900
+
1901
+ if (false) {} else if (!pages.includes(fsPathname)) {
1902
+ const resolvedPathname = resolveDynamicRoute(fsPathname, pages);
1903
+
1904
+ if (resolvedPathname !== fsPathname) {
1905
+ fsPathname = resolvedPathname;
1906
+ }
1907
+ }
1908
+
1909
+ const resolvedHref = !pages.includes(fsPathname) ? resolveDynamicRoute((0, _normalizeLocalePath).normalizeLocalePath((0, _removeBasePath).removeBasePath(parsedRewriteTarget.pathname), options.router.locales).pathname, pages) : fsPathname;
1910
+
1911
+ if ((0, _isDynamic).isDynamicRoute(resolvedHref)) {
1912
+ const matches = (0, _routeMatcher).getRouteMatcher((0, _routeRegex).getRouteRegex(resolvedHref))(as);
1913
+ Object.assign(parsedRewriteTarget.query, matches || {});
1914
+ }
1915
+
1916
+ return {
1917
+ type: 'rewrite',
1918
+ parsedAs: parsedRewriteTarget,
1919
+ resolvedHref
1920
+ };
1921
+ });
1922
+ }
1923
+
1924
+ const src = (0, _parsePath).parsePath(source);
1925
+ const pathname = (0, _formatNextPathnameInfo).formatNextPathnameInfo(_extends({}, (0, _getNextPathnameInfo).getNextPathnameInfo(src.pathname, {
1926
+ nextConfig,
1927
+ parseData: true
1928
+ }), {
1929
+ defaultLocale: options.router.defaultLocale,
1930
+ buildId: ''
1931
+ }));
1932
+ return Promise.resolve({
1933
+ type: 'redirect-external',
1934
+ destination: `${pathname}${src.query}${src.hash}`
1935
+ });
1936
+ }
1937
+
1938
+ const redirectTarget = response.headers.get('x-nextjs-redirect');
1939
+
1940
+ if (redirectTarget) {
1941
+ if (redirectTarget.startsWith('/')) {
1942
+ const src = (0, _parsePath).parsePath(redirectTarget);
1943
+ const pathname = (0, _formatNextPathnameInfo).formatNextPathnameInfo(_extends({}, (0, _getNextPathnameInfo).getNextPathnameInfo(src.pathname, {
1944
+ nextConfig,
1945
+ parseData: true
1946
+ }), {
1947
+ defaultLocale: options.router.defaultLocale,
1948
+ buildId: ''
1949
+ }));
1950
+ return Promise.resolve({
1951
+ type: 'redirect-internal',
1952
+ newAs: `${pathname}${src.query}${src.hash}`,
1953
+ newUrl: `${pathname}${src.query}${src.hash}`
1954
+ });
1955
+ }
1956
+
1957
+ return Promise.resolve({
1958
+ type: 'redirect-external',
1959
+ destination: redirectTarget
1960
+ });
1961
+ }
1962
+
1963
+ return Promise.resolve({
1964
+ type: 'next'
1965
+ });
1966
+ }
1967
+
1968
+ function withMiddlewareEffects(options) {
1969
+ return matchesMiddleware(options).then(matches => {
1970
+ if (matches && options.fetchData) {
1971
+ return options.fetchData().then(data => getMiddlewareData(data.dataHref, data.response, options).then(effect => ({
1972
+ dataHref: data.dataHref,
1973
+ cacheKey: data.cacheKey,
1974
+ json: data.json,
1975
+ response: data.response,
1976
+ text: data.text,
1977
+ effect
1978
+ }))).catch(_err => {
1979
+ /**
1980
+ * TODO: Revisit this in the future.
1981
+ * For now we will not consider middleware data errors to be fatal.
1982
+ * maybe we should revisit in the future.
1983
+ */
1984
+ return null;
1985
+ });
1986
+ }
1987
+
1988
+ return null;
1989
+ });
1990
+ }
1991
+
1992
+ const manualScrollRestoration = (/* unused pure expression or super */ null && ( false && 0));
1993
+ const SSG_DATA_NOT_FOUND = Symbol('SSG_DATA_NOT_FOUND');
1994
+
1995
+ function fetchRetry(url, attempts, options) {
1996
+ return fetch(url, {
1997
+ // Cookies are required to be present for Next.js' SSG "Preview Mode".
1998
+ // Cookies may also be required for `getServerSideProps`.
1999
+ //
2000
+ // > `fetch` won’t send cookies, unless you set the credentials init
2001
+ // > option.
2002
+ // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
2003
+ //
2004
+ // > For maximum browser compatibility when it comes to sending &
2005
+ // > receiving cookies, always supply the `credentials: 'same-origin'`
2006
+ // > option instead of relying on the default.
2007
+ // https://github.com/github/fetch#caveats
2008
+ credentials: 'same-origin',
2009
+ method: options.method || 'GET',
2010
+ headers: Object.assign({}, options.headers, {
2011
+ 'x-nextjs-data': '1'
2012
+ })
2013
+ }).then(response => {
2014
+ return !response.ok && attempts > 1 && response.status >= 500 ? fetchRetry(url, attempts - 1, options) : response;
2015
+ });
2016
+ }
2017
+
2018
+ const backgroundCache = {};
2019
+
2020
+ function handleSmoothScroll(fn) {
2021
+ const htmlElement = document.documentElement;
2022
+ const existing = htmlElement.style.scrollBehavior;
2023
+ htmlElement.style.scrollBehavior = 'auto';
2024
+ fn();
2025
+ htmlElement.style.scrollBehavior = existing;
2026
+ }
2027
+
2028
+ function tryToParseAsJSON(text) {
2029
+ try {
2030
+ return JSON.parse(text);
2031
+ } catch (error) {
2032
+ return null;
2033
+ }
2034
+ }
2035
+
2036
+ function fetchNextData({
2037
+ dataHref,
2038
+ inflightCache,
2039
+ isPrefetch,
2040
+ hasMiddleware,
2041
+ isServerRender,
2042
+ parseJSON,
2043
+ persistCache,
2044
+ isBackground,
2045
+ unstable_skipClientCache
2046
+ }) {
2047
+ const {
2048
+ href: cacheKey
2049
+ } = new URL(dataHref, window.location.href);
2050
+ var ref1;
2051
+
2052
+ const getData = params => {
2053
+ return fetchRetry(dataHref, isServerRender ? 3 : 1, {
2054
+ headers: isPrefetch ? {
2055
+ purpose: 'prefetch'
2056
+ } : {},
2057
+ method: (ref1 = params == null ? void 0 : params.method) != null ? ref1 : 'GET'
2058
+ }).then(response => {
2059
+ if (response.ok && (params == null ? void 0 : params.method) === 'HEAD') {
2060
+ return {
2061
+ dataHref,
2062
+ response,
2063
+ text: '',
2064
+ json: {},
2065
+ cacheKey
2066
+ };
2067
+ }
2068
+
2069
+ return response.text().then(text => {
2070
+ if (!response.ok) {
2071
+ /**
2072
+ * When the data response is a redirect because of a middleware
2073
+ * we do not consider it an error. The headers must bring the
2074
+ * mapped location.
2075
+ * TODO: Change the status code in the handler.
2076
+ */
2077
+ if (hasMiddleware && [301, 302, 307, 308].includes(response.status)) {
2078
+ return {
2079
+ dataHref,
2080
+ response,
2081
+ text,
2082
+ json: {},
2083
+ cacheKey
2084
+ };
2085
+ }
2086
+
2087
+ if (!hasMiddleware && response.status === 404) {
2088
+ var ref;
2089
+
2090
+ if ((ref = tryToParseAsJSON(text)) == null ? void 0 : ref.notFound) {
2091
+ return {
2092
+ dataHref,
2093
+ json: {
2094
+ notFound: SSG_DATA_NOT_FOUND
2095
+ },
2096
+ response,
2097
+ text,
2098
+ cacheKey
2099
+ };
2100
+ }
2101
+ }
2102
+
2103
+ const error = new Error(`Failed to load static props`);
2104
+ /**
2105
+ * We should only trigger a server-side transition if this was
2106
+ * caused on a client-side transition. Otherwise, we'd get into
2107
+ * an infinite loop.
2108
+ */
2109
+
2110
+ if (!isServerRender) {
2111
+ (0, _routeLoader).markAssetError(error);
2112
+ }
2113
+
2114
+ throw error;
2115
+ }
2116
+
2117
+ return {
2118
+ dataHref,
2119
+ json: parseJSON ? tryToParseAsJSON(text) : null,
2120
+ response,
2121
+ text,
2122
+ cacheKey
2123
+ };
2124
+ });
2125
+ }).then(data => {
2126
+ if (!persistCache || false || data.response.headers.get('x-middleware-cache') === 'no-cache') {
2127
+ delete inflightCache[cacheKey];
2128
+ }
2129
+
2130
+ return data;
2131
+ }).catch(err => {
2132
+ delete inflightCache[cacheKey];
2133
+ throw err;
2134
+ });
2135
+ }; // when skipping client cache we wait to update
2136
+ // inflight cache until successful data response
2137
+ // this allows racing click event with fetching newer data
2138
+ // without blocking navigation when stale data is available
2139
+
2140
+
2141
+ if (unstable_skipClientCache && persistCache) {
2142
+ return getData({}).then(data => {
2143
+ inflightCache[cacheKey] = Promise.resolve(data);
2144
+ return data;
2145
+ });
2146
+ }
2147
+
2148
+ if (inflightCache[cacheKey] !== undefined) {
2149
+ return inflightCache[cacheKey];
2150
+ }
2151
+
2152
+ return inflightCache[cacheKey] = getData(isBackground ? {
2153
+ method: 'HEAD'
2154
+ } : {});
2155
+ }
2156
+
2157
+ function createKey() {
2158
+ return Math.random().toString(36).slice(2, 10);
2159
+ }
2160
+
2161
+ function handleHardNavigation({
2162
+ url,
2163
+ router
2164
+ }) {
2165
+ // ensure we don't trigger a hard navigation to the same
2166
+ // URL as this can end up with an infinite refresh
2167
+ if (url === (0, _addBasePath).addBasePath((0, _addLocale).addLocale(router.asPath, router.locale))) {
2168
+ throw new Error(`Invariant: attempted to hard navigate to the same URL ${url} ${location.href}`);
2169
+ }
2170
+
2171
+ window.location.href = url;
2172
+ }
2173
+
2174
+ const getCancelledHandler = ({
2175
+ route,
2176
+ router
2177
+ }) => {
2178
+ let cancelled = false;
2179
+
2180
+ const cancel = router.clc = () => {
2181
+ cancelled = true;
2182
+ };
2183
+
2184
+ const handleCancelled = () => {
2185
+ if (cancelled) {
2186
+ const error = new Error(`Abort fetching component for route: "${route}"`);
2187
+ error.cancelled = true;
2188
+ throw error;
2189
+ }
2190
+
2191
+ if (cancel === router.clc) {
2192
+ router.clc = null;
2193
+ }
2194
+ };
2195
+
2196
+ return handleCancelled;
2197
+ };
2198
+
2199
+ class Router {
2200
+ reload() {
2201
+ window.location.reload();
2202
+ }
2203
+ /**
2204
+ * Go back in history
2205
+ */
2206
+
2207
+
2208
+ back() {
2209
+ window.history.back();
2210
+ }
2211
+ /**
2212
+ * Performs a `pushState` with arguments
2213
+ * @param url of the route
2214
+ * @param as masks `url` for the browser
2215
+ * @param options object you can define `shallow` and other options
2216
+ */
2217
+
2218
+
2219
+ push(url, as, options = {}) {
2220
+ if (false) {}
2221
+
2222
+ ({
2223
+ url,
2224
+ as
2225
+ } = prepareUrlAs(this, url, as));
2226
+ return this.change('pushState', url, as, options);
2227
+ }
2228
+ /**
2229
+ * Performs a `replaceState` with arguments
2230
+ * @param url of the route
2231
+ * @param as masks `url` for the browser
2232
+ * @param options object you can define `shallow` and other options
2233
+ */
2234
+
2235
+
2236
+ replace(url, as, options = {}) {
2237
+ ({
2238
+ url,
2239
+ as
2240
+ } = prepareUrlAs(this, url, as));
2241
+ return this.change('replaceState', url, as, options);
2242
+ }
2243
+
2244
+ change(method, url, as, options, forcedScroll) {
2245
+ var _this = this;
2246
+
2247
+ return _async_to_generator(function* () {
2248
+ if (!isLocalURL(url)) {
2249
+ handleHardNavigation({
2250
+ url,
2251
+ router: _this
2252
+ });
2253
+ return false;
2254
+ } // WARNING: `_h` is an internal option for handing Next.js client-side
2255
+ // hydration. Your app should _never_ use this property. It may change at
2256
+ // any time without notice.
2257
+
2258
+
2259
+ const isQueryUpdating = options._h;
2260
+ const shouldResolveHref = isQueryUpdating || options._shouldResolveHref || (0, _parsePath).parsePath(url).pathname === (0, _parsePath).parsePath(as).pathname;
2261
+
2262
+ const nextState = _extends({}, _this.state); // for static pages with query params in the URL we delay
2263
+ // marking the router ready until after the query is updated
2264
+ // or a navigation has occurred
2265
+
2266
+
2267
+ const readyStateChange = _this.isReady !== true;
2268
+ _this.isReady = true;
2269
+ const isSsr = _this.isSsr;
2270
+
2271
+ if (!isQueryUpdating) {
2272
+ _this.isSsr = false;
2273
+ } // if a route transition is already in progress before
2274
+ // the query updating is triggered ignore query updating
2275
+
2276
+
2277
+ if (isQueryUpdating && _this.clc) {
2278
+ return false;
2279
+ }
2280
+
2281
+ const prevLocale = nextState.locale;
2282
+
2283
+ if (true) {
2284
+ nextState.locale = options.locale === false ? _this.defaultLocale : options.locale || nextState.locale;
2285
+
2286
+ if (typeof options.locale === 'undefined') {
2287
+ options.locale = nextState.locale;
2288
+ }
2289
+
2290
+ const parsedAs = (0, _parseRelativeUrl).parseRelativeUrl((0, _hasBasePath).hasBasePath(as) ? (0, _removeBasePath).removeBasePath(as) : as);
2291
+ const localePathResult = (0, _normalizeLocalePath).normalizeLocalePath(parsedAs.pathname, _this.locales);
2292
+
2293
+ if (localePathResult.detectedLocale) {
2294
+ nextState.locale = localePathResult.detectedLocale;
2295
+ parsedAs.pathname = (0, _addBasePath).addBasePath(parsedAs.pathname);
2296
+ as = (0, _formatUrl).formatWithValidation(parsedAs);
2297
+ url = (0, _addBasePath).addBasePath((0, _normalizeLocalePath).normalizeLocalePath((0, _hasBasePath).hasBasePath(url) ? (0, _removeBasePath).removeBasePath(url) : url, _this.locales).pathname);
2298
+ }
2299
+
2300
+ let didNavigate = false; // we need to wrap this in the env check again since regenerator runtime
2301
+ // moves this on its own due to the return
2302
+
2303
+ if (true) {
2304
+ var ref; // if the locale isn't configured hard navigate to show 404 page
2305
+
2306
+ if (!((ref = _this.locales) == null ? void 0 : ref.includes(nextState.locale))) {
2307
+ parsedAs.pathname = (0, _addLocale).addLocale(parsedAs.pathname, nextState.locale);
2308
+ handleHardNavigation({
2309
+ url: (0, _formatUrl).formatWithValidation(parsedAs),
2310
+ router: _this
2311
+ }); // this was previously a return but was removed in favor
2312
+ // of better dead code elimination with regenerator runtime
2313
+
2314
+ didNavigate = true;
2315
+ }
2316
+ }
2317
+
2318
+ const detectedDomain = (0, _detectDomainLocale).detectDomainLocale(_this.domainLocales, undefined, nextState.locale); // we need to wrap this in the env check again since regenerator runtime
2319
+ // moves this on its own due to the return
2320
+
2321
+ if (true) {
2322
+ // if we are navigating to a domain locale ensure we redirect to the
2323
+ // correct domain
2324
+ if (!didNavigate && detectedDomain && _this.isLocaleDomain && self.location.hostname !== detectedDomain.domain) {
2325
+ const asNoBasePath = (0, _removeBasePath).removeBasePath(as);
2326
+ handleHardNavigation({
2327
+ url: `http${detectedDomain.http ? '' : 's'}://${detectedDomain.domain}${(0, _addBasePath).addBasePath(`${nextState.locale === detectedDomain.defaultLocale ? '' : `/${nextState.locale}`}${asNoBasePath === '/' ? '' : asNoBasePath}` || '/')}`,
2328
+ router: _this
2329
+ }); // this was previously a return but was removed in favor
2330
+ // of better dead code elimination with regenerator runtime
2331
+
2332
+ didNavigate = true;
2333
+ }
2334
+ }
2335
+
2336
+ if (didNavigate) {
2337
+ return new Promise(() => {});
2338
+ }
2339
+ } // marking route changes as a navigation start entry
2340
+
2341
+
2342
+ if (_utils.ST) {
2343
+ performance.mark('routeChange');
2344
+ }
2345
+
2346
+ const {
2347
+ shallow = false,
2348
+ scroll = true
2349
+ } = options;
2350
+ const routeProps = {
2351
+ shallow
2352
+ };
2353
+
2354
+ if (_this._inFlightRoute && _this.clc) {
2355
+ if (!isSsr) {
2356
+ Router.events.emit('routeChangeError', buildCancellationError(), _this._inFlightRoute, routeProps);
2357
+ }
2358
+
2359
+ _this.clc();
2360
+
2361
+ _this.clc = null;
2362
+ }
2363
+
2364
+ as = (0, _addBasePath).addBasePath((0, _addLocale).addLocale((0, _hasBasePath).hasBasePath(as) ? (0, _removeBasePath).removeBasePath(as) : as, options.locale, _this.defaultLocale));
2365
+ const cleanedAs = (0, _removeLocale).removeLocale((0, _hasBasePath).hasBasePath(as) ? (0, _removeBasePath).removeBasePath(as) : as, nextState.locale);
2366
+ _this._inFlightRoute = as;
2367
+ const localeChange = prevLocale !== nextState.locale; // If the url change is only related to a hash change
2368
+ // We should not proceed. We should only change the state.
2369
+
2370
+ if (!isQueryUpdating && _this.onlyAHashChange(cleanedAs) && !localeChange) {
2371
+ nextState.asPath = cleanedAs;
2372
+ Router.events.emit('hashChangeStart', as, routeProps); // TODO: do we need the resolved href when only a hash change?
2373
+
2374
+ _this.changeState(method, url, as, _extends({}, options, {
2375
+ scroll: false
2376
+ }));
2377
+
2378
+ if (scroll) {
2379
+ _this.scrollToHash(cleanedAs);
2380
+ }
2381
+
2382
+ try {
2383
+ yield _this.set(nextState, _this.components[nextState.route], null);
2384
+ } catch (err) {
2385
+ if ((0, _isError).default(err) && err.cancelled) {
2386
+ Router.events.emit('routeChangeError', err, cleanedAs, routeProps);
2387
+ }
2388
+
2389
+ throw err;
2390
+ }
2391
+
2392
+ Router.events.emit('hashChangeComplete', as, routeProps);
2393
+ return true;
2394
+ }
2395
+
2396
+ let parsed = (0, _parseRelativeUrl).parseRelativeUrl(url);
2397
+ let {
2398
+ pathname,
2399
+ query
2400
+ } = parsed; // The build manifest needs to be loaded before auto-static dynamic pages
2401
+ // get their query parameters to allow ensuring they can be parsed properly
2402
+ // when rewritten to
2403
+
2404
+ let pages, rewrites;
2405
+
2406
+ try {
2407
+ [pages, {
2408
+ __rewrites: rewrites
2409
+ }] = yield Promise.all([_this.pageLoader.getPageList(), (0, _routeLoader).getClientBuildManifest(), _this.pageLoader.getMiddleware()]);
2410
+ } catch (err) {
2411
+ // If we fail to resolve the page list or client-build manifest, we must
2412
+ // do a server-side transition:
2413
+ handleHardNavigation({
2414
+ url: as,
2415
+ router: _this
2416
+ });
2417
+ return false;
2418
+ } // If asked to change the current URL we should reload the current page
2419
+ // (not location.reload() but reload getInitialProps and other Next.js stuffs)
2420
+ // We also need to set the method = replaceState always
2421
+ // as this should not go into the history (That's how browsers work)
2422
+ // We should compare the new asPath to the current asPath, not the url
2423
+
2424
+
2425
+ if (!_this.urlIsNew(cleanedAs) && !localeChange) {
2426
+ method = 'replaceState';
2427
+ } // we need to resolve the as value using rewrites for dynamic SSG
2428
+ // pages to allow building the data URL correctly
2429
+
2430
+
2431
+ let resolvedAs = as; // url and as should always be prefixed with basePath by this
2432
+ // point by either next/link or router.push/replace so strip the
2433
+ // basePath from the pathname to match the pages dir 1-to-1
2434
+
2435
+ pathname = pathname ? (0, _removeTrailingSlash).removeTrailingSlash((0, _removeBasePath).removeBasePath(pathname)) : pathname; // we don't attempt resolve asPath when we need to execute
2436
+ // middleware as the resolving will occur server-side
2437
+
2438
+ const isMiddlewareMatch = yield matchesMiddleware({
2439
+ asPath: as,
2440
+ locale: nextState.locale,
2441
+ router: _this
2442
+ });
2443
+
2444
+ if (options.shallow && isMiddlewareMatch) {
2445
+ pathname = _this.pathname;
2446
+ }
2447
+
2448
+ if (shouldResolveHref && pathname !== '/_error') {
2449
+ options._shouldResolveHref = true;
2450
+
2451
+ if (false) {} else {
2452
+ parsed.pathname = resolveDynamicRoute(pathname, pages);
2453
+
2454
+ if (parsed.pathname !== pathname) {
2455
+ pathname = parsed.pathname;
2456
+ parsed.pathname = (0, _addBasePath).addBasePath(pathname);
2457
+
2458
+ if (!isMiddlewareMatch) {
2459
+ url = (0, _formatUrl).formatWithValidation(parsed);
2460
+ }
2461
+ }
2462
+ }
2463
+ }
2464
+
2465
+ if (!isLocalURL(as)) {
2466
+ if (false) {}
2467
+
2468
+ handleHardNavigation({
2469
+ url: as,
2470
+ router: _this
2471
+ });
2472
+ return false;
2473
+ }
2474
+
2475
+ resolvedAs = (0, _removeLocale).removeLocale((0, _removeBasePath).removeBasePath(resolvedAs), nextState.locale);
2476
+ let route = (0, _removeTrailingSlash).removeTrailingSlash(pathname);
2477
+ let routeMatch = false;
2478
+
2479
+ if ((0, _isDynamic).isDynamicRoute(route)) {
2480
+ const parsedAs = (0, _parseRelativeUrl).parseRelativeUrl(resolvedAs);
2481
+ const asPathname = parsedAs.pathname;
2482
+ const routeRegex = (0, _routeRegex).getRouteRegex(route);
2483
+ routeMatch = (0, _routeMatcher).getRouteMatcher(routeRegex)(asPathname);
2484
+ const shouldInterpolate = route === asPathname;
2485
+ const interpolatedAs = shouldInterpolate ? interpolateAs(route, asPathname, query) : {};
2486
+
2487
+ if (!routeMatch || shouldInterpolate && !interpolatedAs.result) {
2488
+ const missingParams = Object.keys(routeRegex.groups).filter(param => !query[param]);
2489
+
2490
+ if (missingParams.length > 0 && !isMiddlewareMatch) {
2491
+ if (false) {}
2492
+
2493
+ throw new Error((shouldInterpolate ? `The provided \`href\` (${url}) value is missing query values (${missingParams.join(', ')}) to be interpolated properly. ` : `The provided \`as\` value (${asPathname}) is incompatible with the \`href\` value (${route}). `) + `Read more: https://nextjs.org/docs/messages/${shouldInterpolate ? 'href-interpolation-failed' : 'incompatible-href-as'}`);
2494
+ }
2495
+ } else if (shouldInterpolate) {
2496
+ as = (0, _formatUrl).formatWithValidation(Object.assign({}, parsedAs, {
2497
+ pathname: interpolatedAs.result,
2498
+ query: omit(query, interpolatedAs.params)
2499
+ }));
2500
+ } else {
2501
+ // Merge params into `query`, overwriting any specified in search
2502
+ Object.assign(query, routeMatch);
2503
+ }
2504
+ }
2505
+
2506
+ if (!isQueryUpdating) {
2507
+ Router.events.emit('routeChangeStart', as, routeProps);
2508
+ }
2509
+
2510
+ try {
2511
+ var ref2, ref3;
2512
+ let routeInfo = yield _this.getRouteInfo({
2513
+ route,
2514
+ pathname,
2515
+ query,
2516
+ as,
2517
+ resolvedAs,
2518
+ routeProps,
2519
+ locale: nextState.locale,
2520
+ isPreview: nextState.isPreview,
2521
+ hasMiddleware: isMiddlewareMatch
2522
+ });
2523
+
2524
+ if ('route' in routeInfo && isMiddlewareMatch) {
2525
+ pathname = routeInfo.route || route;
2526
+ route = pathname;
2527
+
2528
+ if (!routeProps.shallow) {
2529
+ query = Object.assign({}, routeInfo.query || {}, query);
2530
+ }
2531
+
2532
+ const cleanedParsedPathname = (0, _hasBasePath).hasBasePath(parsed.pathname) ? (0, _removeBasePath).removeBasePath(parsed.pathname) : parsed.pathname;
2533
+
2534
+ if (routeMatch && pathname !== cleanedParsedPathname) {
2535
+ Object.keys(routeMatch).forEach(key => {
2536
+ if (routeMatch && query[key] === routeMatch[key]) {
2537
+ delete query[key];
2538
+ }
2539
+ });
2540
+ }
2541
+
2542
+ if ((0, _isDynamic).isDynamicRoute(pathname)) {
2543
+ const prefixedAs = !routeProps.shallow && routeInfo.resolvedAs ? routeInfo.resolvedAs : (0, _addBasePath).addBasePath((0, _addLocale).addLocale(new URL(as, location.href).pathname, nextState.locale), true);
2544
+ let rewriteAs = prefixedAs;
2545
+
2546
+ if ((0, _hasBasePath).hasBasePath(rewriteAs)) {
2547
+ rewriteAs = (0, _removeBasePath).removeBasePath(rewriteAs);
2548
+ }
2549
+
2550
+ if (true) {
2551
+ const localeResult = (0, _normalizeLocalePath).normalizeLocalePath(rewriteAs, _this.locales);
2552
+ nextState.locale = localeResult.detectedLocale || nextState.locale;
2553
+ rewriteAs = localeResult.pathname;
2554
+ }
2555
+
2556
+ const routeRegex = (0, _routeRegex).getRouteRegex(pathname);
2557
+ const curRouteMatch = (0, _routeMatcher).getRouteMatcher(routeRegex)(rewriteAs);
2558
+
2559
+ if (curRouteMatch) {
2560
+ Object.assign(query, curRouteMatch);
2561
+ }
2562
+ }
2563
+ } // If the routeInfo brings a redirect we simply apply it.
2564
+
2565
+
2566
+ if ('type' in routeInfo) {
2567
+ if (routeInfo.type === 'redirect-internal') {
2568
+ return _this.change(method, routeInfo.newUrl, routeInfo.newAs, options);
2569
+ } else {
2570
+ handleHardNavigation({
2571
+ url: routeInfo.destination,
2572
+ router: _this
2573
+ });
2574
+ return new Promise(() => {});
2575
+ }
2576
+ }
2577
+
2578
+ let {
2579
+ error,
2580
+ props,
2581
+ __N_SSG,
2582
+ __N_SSP
2583
+ } = routeInfo;
2584
+ const component = routeInfo.Component;
2585
+
2586
+ if (component && component.unstable_scriptLoader) {
2587
+ const scripts = [].concat(component.unstable_scriptLoader());
2588
+ scripts.forEach(script => {
2589
+ (0, _script).handleClientScriptLoad(script.props);
2590
+ });
2591
+ } // handle redirect on client-transition
2592
+
2593
+
2594
+ if ((__N_SSG || __N_SSP) && props) {
2595
+ if (props.pageProps && props.pageProps.__N_REDIRECT) {
2596
+ // Use the destination from redirect without adding locale
2597
+ options.locale = false;
2598
+ const destination = props.pageProps.__N_REDIRECT; // check if destination is internal (resolves to a page) and attempt
2599
+ // client-navigation if it is falling back to hard navigation if
2600
+ // it's not
2601
+
2602
+ if (destination.startsWith('/') && props.pageProps.__N_REDIRECT_BASE_PATH !== false) {
2603
+ const parsedHref = (0, _parseRelativeUrl).parseRelativeUrl(destination);
2604
+ parsedHref.pathname = resolveDynamicRoute(parsedHref.pathname, pages);
2605
+ const {
2606
+ url: newUrl,
2607
+ as: newAs
2608
+ } = prepareUrlAs(_this, destination, destination);
2609
+ return _this.change(method, newUrl, newAs, options);
2610
+ }
2611
+
2612
+ handleHardNavigation({
2613
+ url: destination,
2614
+ router: _this
2615
+ });
2616
+ return new Promise(() => {});
2617
+ }
2618
+
2619
+ nextState.isPreview = !!props.__N_PREVIEW; // handle SSG data 404
2620
+
2621
+ if (props.notFound === SSG_DATA_NOT_FOUND) {
2622
+ let notFoundRoute;
2623
+
2624
+ try {
2625
+ yield _this.fetchComponent('/404');
2626
+ notFoundRoute = '/404';
2627
+ } catch (_) {
2628
+ notFoundRoute = '/_error';
2629
+ }
2630
+
2631
+ routeInfo = yield _this.getRouteInfo({
2632
+ route: notFoundRoute,
2633
+ pathname: notFoundRoute,
2634
+ query,
2635
+ as,
2636
+ resolvedAs,
2637
+ routeProps: {
2638
+ shallow: false
2639
+ },
2640
+ locale: nextState.locale,
2641
+ isPreview: nextState.isPreview
2642
+ });
2643
+
2644
+ if ('type' in routeInfo) {
2645
+ throw new Error(`Unexpected middleware effect on /404`);
2646
+ }
2647
+ }
2648
+ }
2649
+
2650
+ Router.events.emit('beforeHistoryChange', as, routeProps);
2651
+
2652
+ _this.changeState(method, url, as, options);
2653
+
2654
+ if (isQueryUpdating && pathname === '/_error' && ((ref2 = self.__NEXT_DATA__.props) == null ? void 0 : (ref3 = ref2.pageProps) == null ? void 0 : ref3.statusCode) === 500 && (props == null ? void 0 : props.pageProps)) {
2655
+ // ensure statusCode is still correct for static 500 page
2656
+ // when updating query information
2657
+ props.pageProps.statusCode = 500;
2658
+ }
2659
+
2660
+ var _route; // shallow routing is only allowed for same page URL changes.
2661
+
2662
+
2663
+ const isValidShallowRoute = options.shallow && nextState.route === ((_route = routeInfo.route) != null ? _route : route);
2664
+
2665
+ var _scroll;
2666
+
2667
+ const shouldScroll = (_scroll = options.scroll) != null ? _scroll : !options._h && !isValidShallowRoute;
2668
+ const resetScroll = shouldScroll ? {
2669
+ x: 0,
2670
+ y: 0
2671
+ } : null; // the new state that the router gonna set
2672
+
2673
+ const upcomingRouterState = _extends({}, nextState, {
2674
+ route,
2675
+ pathname,
2676
+ query,
2677
+ asPath: cleanedAs,
2678
+ isFallback: false
2679
+ });
2680
+
2681
+ const upcomingScrollState = forcedScroll != null ? forcedScroll : resetScroll; // for query updates we can skip it if the state is unchanged and we don't
2682
+ // need to scroll
2683
+ // https://github.com/vercel/next.js/issues/37139
2684
+
2685
+ const canSkipUpdating = options._h && !upcomingScrollState && !readyStateChange && !localeChange && (0, _compareStates).compareRouterStates(upcomingRouterState, _this.state);
2686
+
2687
+ if (!canSkipUpdating) {
2688
+ yield _this.set(upcomingRouterState, routeInfo, upcomingScrollState).catch(e => {
2689
+ if (e.cancelled) error = error || e;else throw e;
2690
+ });
2691
+
2692
+ if (error) {
2693
+ if (!isQueryUpdating) {
2694
+ Router.events.emit('routeChangeError', error, cleanedAs, routeProps);
2695
+ }
2696
+
2697
+ throw error;
2698
+ }
2699
+
2700
+ if (true) {
2701
+ if (nextState.locale) {
2702
+ document.documentElement.lang = nextState.locale;
2703
+ }
2704
+ }
2705
+
2706
+ if (!isQueryUpdating) {
2707
+ Router.events.emit('routeChangeComplete', as, routeProps);
2708
+ } // A hash mark # is the optional last part of a URL
2709
+
2710
+
2711
+ const hashRegex = /#.+$/;
2712
+
2713
+ if (shouldScroll && hashRegex.test(as)) {
2714
+ _this.scrollToHash(as);
2715
+ }
2716
+ }
2717
+
2718
+ return true;
2719
+ } catch (err1) {
2720
+ if ((0, _isError).default(err1) && err1.cancelled) {
2721
+ return false;
2722
+ }
2723
+
2724
+ throw err1;
2725
+ }
2726
+ })();
2727
+ }
2728
+
2729
+ changeState(method, url, as, options = {}) {
2730
+ if (false) {}
2731
+
2732
+ if (method !== 'pushState' || (0, _utils).getURL() !== as) {
2733
+ this._shallow = options.shallow;
2734
+ window.history[method]({
2735
+ url,
2736
+ as,
2737
+ options,
2738
+ __N: true,
2739
+ key: this._key = method !== 'pushState' ? this._key : createKey()
2740
+ }, // Most browsers currently ignores this parameter, although they may use it in the future.
2741
+ // Passing the empty string here should be safe against future changes to the method.
2742
+ // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
2743
+ '', as);
2744
+ }
2745
+ }
2746
+
2747
+ handleRouteInfoError(err, pathname, query, as, routeProps, loadErrorFail) {
2748
+ var _this = this;
2749
+
2750
+ return _async_to_generator(function* () {
2751
+ console.error(err);
2752
+
2753
+ if (err.cancelled) {
2754
+ // bubble up cancellation errors
2755
+ throw err;
2756
+ }
2757
+
2758
+ if ((0, _routeLoader).isAssetError(err) || loadErrorFail) {
2759
+ Router.events.emit('routeChangeError', err, as, routeProps); // If we can't load the page it could be one of following reasons
2760
+ // 1. Page doesn't exists
2761
+ // 2. Page does exist in a different zone
2762
+ // 3. Internal error while loading the page
2763
+ // So, doing a hard reload is the proper way to deal with this.
2764
+
2765
+ handleHardNavigation({
2766
+ url: as,
2767
+ router: _this
2768
+ }); // Changing the URL doesn't block executing the current code path.
2769
+ // So let's throw a cancellation error stop the routing logic.
2770
+
2771
+ throw buildCancellationError();
2772
+ }
2773
+
2774
+ try {
2775
+ let props;
2776
+ const {
2777
+ page: Component,
2778
+ styleSheets
2779
+ } = yield _this.fetchComponent('/_error');
2780
+ const routeInfo = {
2781
+ props,
2782
+ Component,
2783
+ styleSheets,
2784
+ err,
2785
+ error: err
2786
+ };
2787
+
2788
+ if (!routeInfo.props) {
2789
+ try {
2790
+ routeInfo.props = yield _this.getInitialProps(Component, {
2791
+ err,
2792
+ pathname,
2793
+ query
2794
+ });
2795
+ } catch (gipErr) {
2796
+ console.error('Error in error page `getInitialProps`: ', gipErr);
2797
+ routeInfo.props = {};
2798
+ }
2799
+ }
2800
+
2801
+ return routeInfo;
2802
+ } catch (routeInfoErr) {
2803
+ return _this.handleRouteInfoError((0, _isError).default(routeInfoErr) ? routeInfoErr : new Error(routeInfoErr + ''), pathname, query, as, routeProps, true);
2804
+ }
2805
+ })();
2806
+ }
2807
+
2808
+ getRouteInfo({
2809
+ route: requestedRoute,
2810
+ pathname,
2811
+ query,
2812
+ as,
2813
+ resolvedAs,
2814
+ routeProps,
2815
+ locale,
2816
+ hasMiddleware,
2817
+ isPreview,
2818
+ unstable_skipClientCache
2819
+ }) {
2820
+ var _this = this;
2821
+
2822
+ return _async_to_generator(function* () {
2823
+ /**
2824
+ * This `route` binding can change if there's a rewrite
2825
+ * so we keep a reference to the original requested route
2826
+ * so we can store the cache for it and avoid re-requesting every time
2827
+ * for shallow routing purposes.
2828
+ */
2829
+ let route = requestedRoute;
2830
+
2831
+ try {
2832
+ var ref, ref4, ref5;
2833
+ const handleCancelled = getCancelledHandler({
2834
+ route,
2835
+ router: _this
2836
+ });
2837
+ let existingInfo = _this.components[route];
2838
+
2839
+ if (routeProps.shallow && existingInfo && _this.route === route) {
2840
+ return existingInfo;
2841
+ }
2842
+
2843
+ if (hasMiddleware) {
2844
+ existingInfo = undefined;
2845
+ }
2846
+
2847
+ let cachedRouteInfo = existingInfo && !('initial' in existingInfo) && true ? existingInfo : undefined;
2848
+ const fetchNextDataParams = {
2849
+ dataHref: _this.pageLoader.getDataHref({
2850
+ href: (0, _formatUrl).formatWithValidation({
2851
+ pathname,
2852
+ query
2853
+ }),
2854
+ skipInterpolation: true,
2855
+ asPath: resolvedAs,
2856
+ locale
2857
+ }),
2858
+ hasMiddleware: true,
2859
+ isServerRender: _this.isSsr,
2860
+ parseJSON: true,
2861
+ inflightCache: _this.sdc,
2862
+ persistCache: !isPreview,
2863
+ isPrefetch: false,
2864
+ unstable_skipClientCache
2865
+ };
2866
+ const data = yield withMiddlewareEffects({
2867
+ fetchData: () => fetchNextData(fetchNextDataParams),
2868
+ asPath: resolvedAs,
2869
+ locale: locale,
2870
+ router: _this
2871
+ });
2872
+ handleCancelled();
2873
+
2874
+ if ((data == null ? void 0 : (ref = data.effect) == null ? void 0 : ref.type) === 'redirect-internal' || (data == null ? void 0 : (ref4 = data.effect) == null ? void 0 : ref4.type) === 'redirect-external') {
2875
+ return data.effect;
2876
+ }
2877
+
2878
+ if ((data == null ? void 0 : (ref5 = data.effect) == null ? void 0 : ref5.type) === 'rewrite') {
2879
+ route = (0, _removeTrailingSlash).removeTrailingSlash(data.effect.resolvedHref);
2880
+ pathname = data.effect.resolvedHref;
2881
+ query = _extends({}, query, data.effect.parsedAs.query);
2882
+ resolvedAs = (0, _removeBasePath).removeBasePath((0, _normalizeLocalePath).normalizeLocalePath(data.effect.parsedAs.pathname, _this.locales).pathname); // Check again the cache with the new destination.
2883
+
2884
+ existingInfo = _this.components[route];
2885
+
2886
+ if (routeProps.shallow && existingInfo && _this.route === route && !hasMiddleware) {
2887
+ // If we have a match with the current route due to rewrite,
2888
+ // we can copy the existing information to the rewritten one.
2889
+ // Then, we return the information along with the matched route.
2890
+ return _extends({}, existingInfo, {
2891
+ route
2892
+ });
2893
+ }
2894
+ }
2895
+
2896
+ if (route === '/api' || route.startsWith('/api/')) {
2897
+ handleHardNavigation({
2898
+ url: as,
2899
+ router: _this
2900
+ });
2901
+ return new Promise(() => {});
2902
+ }
2903
+
2904
+ const routeInfo = cachedRouteInfo || (yield _this.fetchComponent(route).then(res => ({
2905
+ Component: res.page,
2906
+ styleSheets: res.styleSheets,
2907
+ __N_SSG: res.mod.__N_SSG,
2908
+ __N_SSP: res.mod.__N_SSP
2909
+ })));
2910
+
2911
+ if (false) {}
2912
+
2913
+ const shouldFetchData = routeInfo.__N_SSG || routeInfo.__N_SSP;
2914
+ const {
2915
+ props,
2916
+ cacheKey
2917
+ } = yield _this._getData(_async_to_generator(function* () {
2918
+ if (shouldFetchData) {
2919
+ const {
2920
+ json,
2921
+ cacheKey: _cacheKey
2922
+ } = (data == null ? void 0 : data.json) ? data : yield fetchNextData({
2923
+ dataHref: _this.pageLoader.getDataHref({
2924
+ href: (0, _formatUrl).formatWithValidation({
2925
+ pathname,
2926
+ query
2927
+ }),
2928
+ asPath: resolvedAs,
2929
+ locale
2930
+ }),
2931
+ isServerRender: _this.isSsr,
2932
+ parseJSON: true,
2933
+ inflightCache: _this.sdc,
2934
+ persistCache: !isPreview,
2935
+ isPrefetch: false,
2936
+ unstable_skipClientCache
2937
+ });
2938
+ return {
2939
+ cacheKey: _cacheKey,
2940
+ props: json || {}
2941
+ };
2942
+ }
2943
+
2944
+ return {
2945
+ headers: {},
2946
+ cacheKey: '',
2947
+ props: yield _this.getInitialProps(routeInfo.Component, // we provide AppTree later so this needs to be `any`
2948
+ {
2949
+ pathname,
2950
+ query,
2951
+ asPath: as,
2952
+ locale,
2953
+ locales: _this.locales,
2954
+ defaultLocale: _this.defaultLocale
2955
+ })
2956
+ };
2957
+ })); // Only bust the data cache for SSP routes although
2958
+ // middleware can skip cache per request with
2959
+ // x-middleware-cache: no-cache as well
2960
+
2961
+ if (routeInfo.__N_SSP && fetchNextDataParams.dataHref) {
2962
+ delete _this.sdc[cacheKey];
2963
+ } // we kick off a HEAD request in the background
2964
+ // when a non-prefetch request is made to signal revalidation
2965
+
2966
+
2967
+ if (!_this.isPreview && routeInfo.__N_SSG && true) {
2968
+ fetchNextData(Object.assign({}, fetchNextDataParams, {
2969
+ isBackground: true,
2970
+ persistCache: false,
2971
+ inflightCache: backgroundCache
2972
+ })).catch(() => {});
2973
+ }
2974
+
2975
+ props.pageProps = Object.assign({}, props.pageProps);
2976
+ routeInfo.props = props;
2977
+ routeInfo.route = route;
2978
+ routeInfo.query = query;
2979
+ routeInfo.resolvedAs = resolvedAs;
2980
+ _this.components[route] = routeInfo;
2981
+ return routeInfo;
2982
+ } catch (err) {
2983
+ return _this.handleRouteInfoError((0, _isError).getProperError(err), pathname, query, as, routeProps);
2984
+ }
2985
+ })();
2986
+ }
2987
+
2988
+ set(state, data, resetScroll) {
2989
+ this.state = state;
2990
+ return this.sub(data, this.components['/_app'].Component, resetScroll);
2991
+ }
2992
+ /**
2993
+ * Callback to execute before replacing router state
2994
+ * @param cb callback to be executed
2995
+ */
2996
+
2997
+
2998
+ beforePopState(cb) {
2999
+ this._bps = cb;
3000
+ }
3001
+
3002
+ onlyAHashChange(as) {
3003
+ if (!this.asPath) return false;
3004
+ const [oldUrlNoHash, oldHash] = this.asPath.split('#');
3005
+ const [newUrlNoHash, newHash] = as.split('#'); // Makes sure we scroll to the provided hash if the url/hash are the same
3006
+
3007
+ if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {
3008
+ return true;
3009
+ } // If the urls are change, there's more than a hash change
3010
+
3011
+
3012
+ if (oldUrlNoHash !== newUrlNoHash) {
3013
+ return false;
3014
+ } // If the hash has changed, then it's a hash only change.
3015
+ // This check is necessary to handle both the enter and
3016
+ // leave hash === '' cases. The identity case falls through
3017
+ // and is treated as a next reload.
3018
+
3019
+
3020
+ return oldHash !== newHash;
3021
+ }
3022
+
3023
+ scrollToHash(as) {
3024
+ const [, hash = ''] = as.split('#'); // Scroll to top if the hash is just `#` with no value or `#top`
3025
+ // To mirror browsers
3026
+
3027
+ if (hash === '' || hash === 'top') {
3028
+ handleSmoothScroll(() => window.scrollTo(0, 0));
3029
+ return;
3030
+ } // Decode hash to make non-latin anchor works.
3031
+
3032
+
3033
+ const rawHash = decodeURIComponent(hash); // First we check if the element by id is found
3034
+
3035
+ const idEl = document.getElementById(rawHash);
3036
+
3037
+ if (idEl) {
3038
+ handleSmoothScroll(() => idEl.scrollIntoView());
3039
+ return;
3040
+ } // If there's no element with the id, we check the `name` property
3041
+ // To mirror browsers
3042
+
3043
+
3044
+ const nameEl = document.getElementsByName(rawHash)[0];
3045
+
3046
+ if (nameEl) {
3047
+ handleSmoothScroll(() => nameEl.scrollIntoView());
3048
+ }
3049
+ }
3050
+
3051
+ urlIsNew(asPath) {
3052
+ return this.asPath !== asPath;
3053
+ }
3054
+ /**
3055
+ * Prefetch page code, you may wait for the data during page rendering.
3056
+ * This feature only works in production!
3057
+ * @param url the href of prefetched page
3058
+ * @param asPath the as path of the prefetched page
3059
+ */
3060
+
3061
+
3062
+ prefetch(url, asPath = url, options = {}) {
3063
+ var _this = this;
3064
+
3065
+ return _async_to_generator(function* () {
3066
+ if (false) {}
3067
+
3068
+ let parsed = (0, _parseRelativeUrl).parseRelativeUrl(url);
3069
+ let {
3070
+ pathname,
3071
+ query
3072
+ } = parsed;
3073
+
3074
+ if (true) {
3075
+ if (options.locale === false) {
3076
+ pathname = (0, _normalizeLocalePath).normalizeLocalePath(pathname, _this.locales).pathname;
3077
+ parsed.pathname = pathname;
3078
+ url = (0, _formatUrl).formatWithValidation(parsed);
3079
+ let parsedAs = (0, _parseRelativeUrl).parseRelativeUrl(asPath);
3080
+ const localePathResult = (0, _normalizeLocalePath).normalizeLocalePath(parsedAs.pathname, _this.locales);
3081
+ parsedAs.pathname = localePathResult.pathname;
3082
+ options.locale = localePathResult.detectedLocale || _this.defaultLocale;
3083
+ asPath = (0, _formatUrl).formatWithValidation(parsedAs);
3084
+ }
3085
+ }
3086
+
3087
+ const pages = yield _this.pageLoader.getPageList();
3088
+ let resolvedAs = asPath;
3089
+ const locale = typeof options.locale !== 'undefined' ? options.locale || undefined : _this.locale;
3090
+
3091
+ if (false) {}
3092
+
3093
+ parsed.pathname = resolveDynamicRoute(parsed.pathname, pages);
3094
+
3095
+ if ((0, _isDynamic).isDynamicRoute(parsed.pathname)) {
3096
+ pathname = parsed.pathname;
3097
+ parsed.pathname = pathname;
3098
+ Object.assign(query, (0, _routeMatcher).getRouteMatcher((0, _routeRegex).getRouteRegex(parsed.pathname))((0, _parsePath).parsePath(asPath).pathname) || {});
3099
+ url = (0, _formatUrl).formatWithValidation(parsed);
3100
+ } // Prefetch is not supported in development mode because it would trigger on-demand-entries
3101
+
3102
+
3103
+ if (false) {}
3104
+
3105
+ const route = (0, _removeTrailingSlash).removeTrailingSlash(pathname);
3106
+ yield Promise.all([_this.pageLoader._isSsg(route).then(isSsg => {
3107
+ return isSsg ? fetchNextData({
3108
+ dataHref: _this.pageLoader.getDataHref({
3109
+ href: url,
3110
+ asPath: resolvedAs,
3111
+ locale: locale
3112
+ }),
3113
+ isServerRender: false,
3114
+ parseJSON: true,
3115
+ inflightCache: _this.sdc,
3116
+ persistCache: !_this.isPreview,
3117
+ isPrefetch: true,
3118
+ unstable_skipClientCache: options.unstable_skipClientCache || options.priority && !!true
3119
+ }).then(() => false) : false;
3120
+ }), _this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route)]);
3121
+ })();
3122
+ }
3123
+
3124
+ fetchComponent(route) {
3125
+ var _this = this;
3126
+
3127
+ return _async_to_generator(function* () {
3128
+ const handleCancelled = getCancelledHandler({
3129
+ route,
3130
+ router: _this
3131
+ });
3132
+
3133
+ try {
3134
+ const componentResult = yield _this.pageLoader.loadPage(route);
3135
+ handleCancelled();
3136
+ return componentResult;
3137
+ } catch (err) {
3138
+ handleCancelled();
3139
+ throw err;
3140
+ }
3141
+ })();
3142
+ }
3143
+
3144
+ _getData(fn) {
3145
+ let cancelled = false;
3146
+
3147
+ const cancel = () => {
3148
+ cancelled = true;
3149
+ };
3150
+
3151
+ this.clc = cancel;
3152
+ return fn().then(data => {
3153
+ if (cancel === this.clc) {
3154
+ this.clc = null;
3155
+ }
3156
+
3157
+ if (cancelled) {
3158
+ const err = new Error('Loading initial props cancelled');
3159
+ err.cancelled = true;
3160
+ throw err;
3161
+ }
3162
+
3163
+ return data;
3164
+ });
3165
+ }
3166
+
3167
+ _getFlightData(dataHref) {
3168
+ // Do not cache RSC flight response since it's not a static resource
3169
+ return fetchNextData({
3170
+ dataHref,
3171
+ isServerRender: true,
3172
+ parseJSON: false,
3173
+ inflightCache: this.sdc,
3174
+ persistCache: false,
3175
+ isPrefetch: false
3176
+ }).then(({
3177
+ text
3178
+ }) => ({
3179
+ data: text
3180
+ }));
3181
+ }
3182
+
3183
+ getInitialProps(Component, ctx) {
3184
+ const {
3185
+ Component: App
3186
+ } = this.components['/_app'];
3187
+
3188
+ const AppTree = this._wrapApp(App);
3189
+
3190
+ ctx.AppTree = AppTree;
3191
+ return (0, _utils).loadGetInitialProps(App, {
3192
+ AppTree,
3193
+ Component,
3194
+ router: this,
3195
+ ctx
3196
+ });
3197
+ }
3198
+
3199
+ get route() {
3200
+ return this.state.route;
3201
+ }
3202
+
3203
+ get pathname() {
3204
+ return this.state.pathname;
3205
+ }
3206
+
3207
+ get query() {
3208
+ return this.state.query;
3209
+ }
3210
+
3211
+ get asPath() {
3212
+ return this.state.asPath;
3213
+ }
3214
+
3215
+ get locale() {
3216
+ return this.state.locale;
3217
+ }
3218
+
3219
+ get isFallback() {
3220
+ return this.state.isFallback;
3221
+ }
3222
+
3223
+ get isPreview() {
3224
+ return this.state.isPreview;
3225
+ }
3226
+
3227
+ constructor(pathname1, query1, as1, {
3228
+ initialProps,
3229
+ pageLoader,
3230
+ App,
3231
+ wrapApp,
3232
+ Component,
3233
+ err,
3234
+ subscription,
3235
+ isFallback,
3236
+ locale,
3237
+ locales,
3238
+ defaultLocale,
3239
+ domainLocales,
3240
+ isPreview
3241
+ }) {
3242
+ // Server Data Cache
3243
+ this.sdc = {};
3244
+ this.isFirstPopStateEvent = true;
3245
+ this._key = createKey();
3246
+
3247
+ this.onPopState = e => {
3248
+ const {
3249
+ isFirstPopStateEvent
3250
+ } = this;
3251
+ this.isFirstPopStateEvent = false;
3252
+ const state = e.state;
3253
+
3254
+ if (!state) {
3255
+ // We get state as undefined for two reasons.
3256
+ // 1. With older safari (< 8) and older chrome (< 34)
3257
+ // 2. When the URL changed with #
3258
+ //
3259
+ // In the both cases, we don't need to proceed and change the route.
3260
+ // (as it's already changed)
3261
+ // But we can simply replace the state with the new changes.
3262
+ // Actually, for (1) we don't need to nothing. But it's hard to detect that event.
3263
+ // So, doing the following for (1) does no harm.
3264
+ const {
3265
+ pathname,
3266
+ query
3267
+ } = this;
3268
+ this.changeState('replaceState', (0, _formatUrl).formatWithValidation({
3269
+ pathname: (0, _addBasePath).addBasePath(pathname),
3270
+ query
3271
+ }), (0, _utils).getURL());
3272
+ return;
3273
+ } // __NA is used to identify if the history entry can be handled by the app-router.
3274
+
3275
+
3276
+ if (state.__NA) {
3277
+ window.location.reload();
3278
+ return;
3279
+ }
3280
+
3281
+ if (!state.__N) {
3282
+ return;
3283
+ } // Safari fires popstateevent when reopening the browser.
3284
+
3285
+
3286
+ if (isFirstPopStateEvent && this.locale === state.options.locale && state.as === this.asPath) {
3287
+ return;
3288
+ }
3289
+
3290
+ let forcedScroll;
3291
+ const {
3292
+ url,
3293
+ as,
3294
+ options,
3295
+ key
3296
+ } = state;
3297
+
3298
+ if (false) {}
3299
+
3300
+ this._key = key;
3301
+ const {
3302
+ pathname
3303
+ } = (0, _parseRelativeUrl).parseRelativeUrl(url); // Make sure we don't re-render on initial load,
3304
+ // can be caused by navigating back from an external site
3305
+
3306
+ if (this.isSsr && as === (0, _addBasePath).addBasePath(this.asPath) && pathname === (0, _addBasePath).addBasePath(this.pathname)) {
3307
+ return;
3308
+ } // If the downstream application returns falsy, return.
3309
+ // They will then be responsible for handling the event.
3310
+
3311
+
3312
+ if (this._bps && !this._bps(state)) {
3313
+ return;
3314
+ }
3315
+
3316
+ this.change('replaceState', url, as, Object.assign({}, options, {
3317
+ shallow: options.shallow && this._shallow,
3318
+ locale: options.locale || this.defaultLocale,
3319
+ // @ts-ignore internal value not exposed on types
3320
+ _h: 0
3321
+ }), forcedScroll);
3322
+ }; // represents the current component key
3323
+
3324
+
3325
+ const route = (0, _removeTrailingSlash).removeTrailingSlash(pathname1); // set up the component cache (by route keys)
3326
+
3327
+ this.components = {}; // We should not keep the cache, if there's an error
3328
+ // Otherwise, this cause issues when when going back and
3329
+ // come again to the errored page.
3330
+
3331
+ if (pathname1 !== '/_error') {
3332
+ this.components[route] = {
3333
+ Component,
3334
+ initial: true,
3335
+ props: initialProps,
3336
+ err,
3337
+ __N_SSG: initialProps && initialProps.__N_SSG,
3338
+ __N_SSP: initialProps && initialProps.__N_SSP
3339
+ };
3340
+ }
3341
+
3342
+ this.components['/_app'] = {
3343
+ Component: App,
3344
+ styleSheets: []
3345
+ }; // Backwards compat for Router.router.events
3346
+ // TODO: Should be remove the following major version as it was never documented
3347
+
3348
+ this.events = Router.events;
3349
+ this.pageLoader = pageLoader; // if auto prerendered and dynamic route wait to update asPath
3350
+ // until after mount to prevent hydration mismatch
3351
+
3352
+ const autoExportDynamic = (0, _isDynamic).isDynamicRoute(pathname1) && self.__NEXT_DATA__.autoExport;
3353
+
3354
+ this.basePath = false || '';
3355
+ this.sub = subscription;
3356
+ this.clc = null;
3357
+ this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
3358
+ // back from external site
3359
+
3360
+ this.isSsr = true;
3361
+ this.isLocaleDomain = false;
3362
+ this.isReady = !!(self.__NEXT_DATA__.gssp || self.__NEXT_DATA__.gip || self.__NEXT_DATA__.appGip && !self.__NEXT_DATA__.gsp || !autoExportDynamic && !self.location.search && !false);
3363
+
3364
+ if (true) {
3365
+ this.locales = locales;
3366
+ this.defaultLocale = defaultLocale;
3367
+ this.domainLocales = domainLocales;
3368
+ this.isLocaleDomain = !!(0, _detectDomainLocale).detectDomainLocale(domainLocales, self.location.hostname);
3369
+ }
3370
+
3371
+ this.state = {
3372
+ route,
3373
+ pathname: pathname1,
3374
+ query: query1,
3375
+ asPath: autoExportDynamic ? pathname1 : as1,
3376
+ isPreview: !!isPreview,
3377
+ locale: true ? locale : 0,
3378
+ isFallback
3379
+ };
3380
+ this._initialMatchesMiddlewarePromise = Promise.resolve(false);
3381
+
3382
+ if (false) {}
3383
+ }
3384
+
3385
+ }
3386
+
3387
+ Router.events = (0, _mitt).default();
3388
+ exports["default"] = Router;
3389
+
3390
+ /***/ }),
3391
+
3392
+ /***/ 1664:
3393
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3394
+
3395
+ module.exports = __webpack_require__(7942)
3396
+
3397
+
3398
+ /***/ })
3399
+
3400
+ };
3401
+ ;