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