math-main-components 0.0.196 → 0.0.197

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 (257) hide show
  1. package/dist/components/Accordeon/Accordeon.d.ts +4 -1
  2. package/dist/components/Accordeon/Accordeon.stories.d.ts +13 -0
  3. package/dist/components/Button/Button.d.ts +3 -3
  4. package/dist/components/Button/Button.stories.d.ts +13 -0
  5. package/dist/components/{AuthButton/AuthButton.d.ts → Button2/Button2.d.ts} +2 -2
  6. package/dist/components/Button2/Button2.stories.d.ts +13 -0
  7. package/dist/components/Button2/index.d.ts +1 -0
  8. package/dist/components/CardButton/CardButton.d.ts +3 -3
  9. package/dist/components/CardButton/CardButton.stories.d.ts +13 -0
  10. package/dist/components/Checkbox/Checkbox.stories.d.ts +13 -0
  11. package/dist/components/ChooseRole/ChooseRole.d.ts +3 -4
  12. package/dist/components/ChooseRole/ChooseRole.stories.d.ts +13 -0
  13. package/dist/components/ChooseRole/index.d.ts +1 -1
  14. package/dist/components/CopyCode/CopyCode.d.ts +3 -4
  15. package/dist/components/CopyCode/CopyCode.stories.d.ts +13 -0
  16. package/dist/components/EmptyCard/EmptyCard.stories.d.ts +13 -0
  17. package/dist/components/FormButton/FormButton.d.ts +4 -4
  18. package/dist/components/FormButton/FormButton.stories.d.ts +13 -0
  19. package/dist/components/FormText/FormText.stories.d.ts +13 -0
  20. package/dist/components/ForwardButton/ForwardButton.stories.d.ts +13 -0
  21. package/dist/index.cjs.js +39 -48
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.esm.js +39 -47
  24. package/dist/styles/font.scss +5 -0
  25. package/dist/styles/material-symbols.scss +24 -0
  26. package/dist/styles/theme-colors.scss +164 -0
  27. package/dist/styles/theme-styles.scss +8 -0
  28. package/package.json +18 -3
  29. package/dist/_virtual/_interop_require_default.cjs.js +0 -3
  30. package/dist/_virtual/_interop_require_wildcard.cjs.js +0 -3
  31. package/dist/_virtual/add-base-path.js +0 -3
  32. package/dist/_virtual/add-locale.js +0 -3
  33. package/dist/_virtual/add-locale2.js +0 -3
  34. package/dist/_virtual/add-path-prefix.js +0 -3
  35. package/dist/_virtual/add-path-suffix.js +0 -3
  36. package/dist/_virtual/app-paths.js +0 -3
  37. package/dist/_virtual/app-router-context.shared-runtime.js +0 -3
  38. package/dist/_virtual/app-router-headers.js +0 -3
  39. package/dist/_virtual/bloom-filter.js +0 -3
  40. package/dist/_virtual/compare-states.js +0 -3
  41. package/dist/_virtual/denormalize-page-path.js +0 -3
  42. package/dist/_virtual/detect-domain-locale.js +0 -3
  43. package/dist/_virtual/detect-domain-locale2.js +0 -3
  44. package/dist/_virtual/ensure-leading-slash.js +0 -3
  45. package/dist/_virtual/escape-regexp.js +0 -3
  46. package/dist/_virtual/format-next-pathname-info.js +0 -3
  47. package/dist/_virtual/format-url.js +0 -3
  48. package/dist/_virtual/get-asset-path-from-route.js +0 -3
  49. package/dist/_virtual/get-cookie-parser.js +0 -3
  50. package/dist/_virtual/get-domain-locale.js +0 -3
  51. package/dist/_virtual/get-next-pathname-info.js +0 -3
  52. package/dist/_virtual/handle-smooth-scroll.js +0 -3
  53. package/dist/_virtual/has-base-path.js +0 -3
  54. package/dist/_virtual/head-manager-context.shared-runtime.js +0 -3
  55. package/dist/_virtual/head-manager.js +0 -3
  56. package/dist/_virtual/index.js +0 -3
  57. package/dist/_virtual/index2.js +0 -3
  58. package/dist/_virtual/index3.js +0 -3
  59. package/dist/_virtual/index4.js +0 -3
  60. package/dist/_virtual/index5.js +0 -3
  61. package/dist/_virtual/interception-routes.js +0 -3
  62. package/dist/_virtual/interpolate-as.js +0 -3
  63. package/dist/_virtual/is-api-route.js +0 -3
  64. package/dist/_virtual/is-bot.js +0 -3
  65. package/dist/_virtual/is-dynamic.js +0 -3
  66. package/dist/_virtual/is-error.js +0 -3
  67. package/dist/_virtual/is-local-url.js +0 -3
  68. package/dist/_virtual/is-plain-object.js +0 -3
  69. package/dist/_virtual/link.js +0 -3
  70. package/dist/_virtual/link2.js +0 -3
  71. package/dist/_virtual/mitt.js +0 -3
  72. package/dist/_virtual/normalize-locale-path.js +0 -3
  73. package/dist/_virtual/normalize-locale-path2.js +0 -3
  74. package/dist/_virtual/normalize-path-sep.js +0 -3
  75. package/dist/_virtual/normalize-trailing-slash.js +0 -3
  76. package/dist/_virtual/omit.js +0 -3
  77. package/dist/_virtual/parse-path.js +0 -3
  78. package/dist/_virtual/parse-relative-url.js +0 -3
  79. package/dist/_virtual/parse-url.js +0 -3
  80. package/dist/_virtual/path-has-prefix.js +0 -3
  81. package/dist/_virtual/path-match.js +0 -3
  82. package/dist/_virtual/prepare-destination.js +0 -3
  83. package/dist/_virtual/querystring.js +0 -3
  84. package/dist/_virtual/react-is.development.js +0 -3
  85. package/dist/_virtual/react-is.production.min.js +0 -3
  86. package/dist/_virtual/remove-base-path.js +0 -3
  87. package/dist/_virtual/remove-locale.js +0 -3
  88. package/dist/_virtual/remove-path-prefix.js +0 -3
  89. package/dist/_virtual/remove-trailing-slash.js +0 -3
  90. package/dist/_virtual/request-idle-callback.js +0 -3
  91. package/dist/_virtual/resolve-href.js +0 -3
  92. package/dist/_virtual/resolve-rewrites.js +0 -3
  93. package/dist/_virtual/route-loader.js +0 -3
  94. package/dist/_virtual/route-matcher.js +0 -3
  95. package/dist/_virtual/route-regex.js +0 -3
  96. package/dist/_virtual/router-context.shared-runtime.js +0 -3
  97. package/dist/_virtual/router-reducer-types.js +0 -3
  98. package/dist/_virtual/router.js +0 -3
  99. package/dist/_virtual/router2.js +0 -3
  100. package/dist/_virtual/router3.js +0 -3
  101. package/dist/_virtual/script.js +0 -3
  102. package/dist/_virtual/segment.js +0 -3
  103. package/dist/_virtual/sorted-routes.js +0 -3
  104. package/dist/_virtual/trusted-types.js +0 -3
  105. package/dist/_virtual/use-intersection.js +0 -3
  106. package/dist/_virtual/utils.js +0 -3
  107. package/dist/_virtual/with-router.js +0 -3
  108. package/dist/components/Accordeon/Accordeon.types.d.ts +0 -4
  109. package/dist/components/AuthButton/index.d.ts +0 -1
  110. package/dist/components/Dialog/Dialog.types.d.ts +0 -7
  111. package/dist/components/PrimaryButton/PrimaryButton.d.ts +0 -8
  112. package/dist/components/PrimaryButton/index.d.ts +0 -1
  113. package/dist/components/SvgIcon/SvgIcon.types.d.ts +0 -8
  114. package/dist/components/index.d.ts +0 -31
  115. package/dist/components/useDimensions.d.ts +0 -4
  116. package/dist/components/useOrientation.d.ts +0 -3
  117. package/dist/components/useScroll.d.ts +0 -4
  118. package/dist/node_modules/@swc/helpers/cjs/_interop_require_default.cjs.js +0 -7
  119. package/dist/node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs.js +0 -48
  120. package/dist/node_modules/clsx/dist/clsx.m.js +0 -3
  121. package/dist/node_modules/external-svg-loader/dist/svg-loader.min.js +0 -1
  122. package/dist/node_modules/next/dist/client/add-base-path.js +0 -38
  123. package/dist/node_modules/next/dist/client/add-locale.js +0 -42
  124. package/dist/node_modules/next/dist/client/components/app-router-headers.js +0 -78
  125. package/dist/node_modules/next/dist/client/components/router-reducer/router-reducer-types.js +0 -69
  126. package/dist/node_modules/next/dist/client/detect-domain-locale.js +0 -39
  127. package/dist/node_modules/next/dist/client/get-domain-locale.js +0 -51
  128. package/dist/node_modules/next/dist/client/has-base-path.js +0 -36
  129. package/dist/node_modules/next/dist/client/head-manager.js +0 -212
  130. package/dist/node_modules/next/dist/client/link.js +0 -431
  131. package/dist/node_modules/next/dist/client/normalize-locale-path.js +0 -40
  132. package/dist/node_modules/next/dist/client/normalize-trailing-slash.js +0 -50
  133. package/dist/node_modules/next/dist/client/remove-base-path.js +0 -45
  134. package/dist/node_modules/next/dist/client/remove-locale.js +0 -41
  135. package/dist/node_modules/next/dist/client/request-idle-callback.js +0 -52
  136. package/dist/node_modules/next/dist/client/resolve-href.js +0 -99
  137. package/dist/node_modules/next/dist/client/route-loader.js +0 -327
  138. package/dist/node_modules/next/dist/client/router.js +0 -202
  139. package/dist/node_modules/next/dist/client/script.js +0 -353
  140. package/dist/node_modules/next/dist/client/trusted-types.js +0 -54
  141. package/dist/node_modules/next/dist/client/use-intersection.js +0 -129
  142. package/dist/node_modules/next/dist/client/with-router.js +0 -52
  143. package/dist/node_modules/next/dist/compiled/cookie/index.js +0 -18
  144. package/dist/node_modules/next/dist/compiled/gzip-size/index.js +0 -15
  145. package/dist/node_modules/next/dist/compiled/path-to-regexp/index.js +0 -416
  146. package/dist/node_modules/next/dist/compiled/react-is/cjs/react-is.development.js +0 -230
  147. package/dist/node_modules/next/dist/compiled/react-is/cjs/react-is.production.min.js +0 -26
  148. package/dist/node_modules/next/dist/compiled/react-is/index.js +0 -21
  149. package/dist/node_modules/next/dist/lib/is-api-route.js +0 -27
  150. package/dist/node_modules/next/dist/lib/is-error.js +0 -53
  151. package/dist/node_modules/next/dist/server/api-utils/get-cookie-parser.js +0 -35
  152. package/dist/node_modules/next/dist/server/future/helpers/interception-routes.js +0 -97
  153. package/dist/node_modules/next/dist/shared/lib/app-router-context.shared-runtime.js +0 -63
  154. package/dist/node_modules/next/dist/shared/lib/bloom-filter.js +0 -96
  155. package/dist/node_modules/next/dist/shared/lib/escape-regexp.js +0 -33
  156. package/dist/node_modules/next/dist/shared/lib/head-manager-context.shared-runtime.js +0 -33
  157. package/dist/node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js +0 -38
  158. package/dist/node_modules/next/dist/shared/lib/i18n/normalize-locale-path.js +0 -42
  159. package/dist/node_modules/next/dist/shared/lib/is-plain-object.js +0 -50
  160. package/dist/node_modules/next/dist/shared/lib/mitt.js +0 -57
  161. package/dist/node_modules/next/dist/shared/lib/page-path/denormalize-page-path.js +0 -32
  162. package/dist/node_modules/next/dist/shared/lib/page-path/ensure-leading-slash.js +0 -32
  163. package/dist/node_modules/next/dist/shared/lib/page-path/normalize-path-sep.js +0 -33
  164. package/dist/node_modules/next/dist/shared/lib/router/router.js +0 -1771
  165. package/dist/node_modules/next/dist/shared/lib/router/utils/add-locale.js +0 -42
  166. package/dist/node_modules/next/dist/shared/lib/router/utils/add-path-prefix.js +0 -33
  167. package/dist/node_modules/next/dist/shared/lib/router/utils/add-path-suffix.js +0 -33
  168. package/dist/node_modules/next/dist/shared/lib/router/utils/app-paths.js +0 -61
  169. package/dist/node_modules/next/dist/shared/lib/router/utils/compare-states.js +0 -46
  170. package/dist/node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.js +0 -43
  171. package/dist/node_modules/next/dist/shared/lib/router/utils/format-url.js +0 -99
  172. package/dist/node_modules/next/dist/shared/lib/router/utils/get-asset-path-from-route.js +0 -29
  173. package/dist/node_modules/next/dist/shared/lib/router/utils/get-next-pathname-info.js +0 -69
  174. package/dist/node_modules/next/dist/shared/lib/router/utils/handle-smooth-scroll.js +0 -49
  175. package/dist/node_modules/next/dist/shared/lib/router/utils/index.js +0 -36
  176. package/dist/node_modules/next/dist/shared/lib/router/utils/interpolate-as.js +0 -67
  177. package/dist/node_modules/next/dist/shared/lib/router/utils/is-bot.js +0 -27
  178. package/dist/node_modules/next/dist/shared/lib/router/utils/is-dynamic.js +0 -28
  179. package/dist/node_modules/next/dist/shared/lib/router/utils/is-local-url.js +0 -40
  180. package/dist/node_modules/next/dist/shared/lib/router/utils/omit.js +0 -33
  181. package/dist/node_modules/next/dist/shared/lib/router/utils/parse-path.js +0 -47
  182. package/dist/node_modules/next/dist/shared/lib/router/utils/parse-relative-url.js +0 -43
  183. package/dist/node_modules/next/dist/shared/lib/router/utils/parse-url.js +0 -44
  184. package/dist/node_modules/next/dist/shared/lib/router/utils/path-has-prefix.js +0 -33
  185. package/dist/node_modules/next/dist/shared/lib/router/utils/path-match.js +0 -62
  186. package/dist/node_modules/next/dist/shared/lib/router/utils/prepare-destination.js +0 -245
  187. package/dist/node_modules/next/dist/shared/lib/router/utils/querystring.js +0 -80
  188. package/dist/node_modules/next/dist/shared/lib/router/utils/remove-path-prefix.js +0 -52
  189. package/dist/node_modules/next/dist/shared/lib/router/utils/remove-trailing-slash.js +0 -35
  190. package/dist/node_modules/next/dist/shared/lib/router/utils/resolve-rewrites.js +0 -136
  191. package/dist/node_modules/next/dist/shared/lib/router/utils/route-matcher.js +0 -53
  192. package/dist/node_modules/next/dist/shared/lib/router/utils/route-regex.js +0 -200
  193. package/dist/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js +0 -182
  194. package/dist/node_modules/next/dist/shared/lib/router-context.shared-runtime.js +0 -33
  195. package/dist/node_modules/next/dist/shared/lib/segment.js +0 -28
  196. package/dist/node_modules/next/dist/shared/lib/utils.js +0 -196
  197. package/dist/node_modules/next/link.js +0 -7
  198. package/dist/node_modules/next/router.js +0 -6
  199. package/dist/node_modules/react-toastify/dist/react-toastify.esm.mjs.js +0 -7
  200. package/dist/node_modules/style-inject/dist/style-inject.es.js +0 -28
  201. package/dist/services/prisma.service.d.ts +0 -2
  202. package/dist/src/components/Accordeon/Accordeon.js +0 -14
  203. package/dist/src/components/Accordeon/styles.module.scss.js +0 -7
  204. package/dist/src/components/AuthButton/styles.module.scss.js +0 -4
  205. package/dist/src/components/CardButton/styles.module.scss.js +0 -4
  206. package/dist/src/components/Checkbox/styles.module.scss.js +0 -4
  207. package/dist/src/components/ChooseRole/styles.module.scss.js +0 -4
  208. package/dist/src/components/CopyCode/styles.module.scss.js +0 -4
  209. package/dist/src/components/Dialog/Dialog.js +0 -14
  210. package/dist/src/components/Dialog/styles.module.scss.js +0 -7
  211. package/dist/src/components/FormButton/styles.module.scss.js +0 -4
  212. package/dist/src/components/FormText/styles.module.scss.js +0 -4
  213. package/dist/src/components/ForwardButton/styles.module.scss.js +0 -4
  214. package/dist/src/components/Gap/Gap.js +0 -7
  215. package/dist/src/components/InputMail/styles.module.scss.js +0 -4
  216. package/dist/src/components/InputNames/styles.module.scss.js +0 -4
  217. package/dist/src/components/InputNumber/styles.module.scss.js +0 -4
  218. package/dist/src/components/InputPassword/styles.module.scss.js +0 -4
  219. package/dist/src/components/InputPin/styles.module.scss.js +0 -4
  220. package/dist/src/components/InputText/styles.module.scss.js +0 -4
  221. package/dist/src/components/OptionField/styles.module.scss.js +0 -4
  222. package/dist/src/components/OptionFieldHorizontal/styles.module.scss.js +0 -4
  223. package/dist/src/components/PrimaryButton/styles.module.scss.js +0 -4
  224. package/dist/src/components/ProgressBar/styles.module.scss.js +0 -4
  225. package/dist/src/components/RadioButtons/styles.module.scss.js +0 -4
  226. package/dist/src/components/RedirectButton/styles.module.scss.js +0 -4
  227. package/dist/src/components/SearchChips/styles.module.scss.js +0 -4
  228. package/dist/src/components/Searchbar/styles.module.scss.js +0 -4
  229. package/dist/src/components/Slider/styles.module.scss.js +0 -4
  230. package/dist/src/components/StepBack/styles.module.scss.js +0 -4
  231. package/dist/src/components/SvgIcon/SvgIcon.js +0 -9
  232. package/dist/src/components/Table/Table.js +0 -12
  233. package/dist/src/components/Table/styles.module.scss.js +0 -4
  234. package/dist/src/components/TextWithIcon/styles.module.scss.js +0 -4
  235. package/dist/src/components/UsageCard/styles.module.scss.js +0 -4
  236. package/dist/src/index.js +0 -36
  237. package/dist/types/Concept.d.ts +0 -7
  238. package/dist/types/Content.d.ts +0 -15
  239. package/dist/types/CourseAnnouncement.d.ts +0 -13
  240. package/dist/types/CourseAnnouncementAsset.d.ts +0 -22
  241. package/dist/types/CourseAnnouncementAssset.d.ts +0 -21
  242. package/dist/types/CourseMessage.d.ts +0 -13
  243. package/dist/types/CourseParticipant.d.ts +0 -9
  244. package/dist/types/CoursePin.d.ts +0 -8
  245. package/dist/types/File.d.ts +0 -13
  246. package/dist/types/HelpData.d.ts +0 -8
  247. package/dist/types/News.d.ts +0 -13
  248. package/dist/types/OrganizationMember.d.ts +0 -12
  249. package/dist/types/Page.d.ts +0 -8
  250. package/dist/types/ProductFeature.d.ts +0 -8
  251. package/dist/types/ProductLimit.d.ts +0 -8
  252. package/dist/types/PublicUser.d.ts +0 -7
  253. package/dist/types/index.d.ts +0 -2
  254. package/dist/types/marketing/BenefitForIndividuals.d.ts +0 -9
  255. package/dist/types/marketing/BenefitForSchools.d.ts +0 -9
  256. package/dist/types/marketing/Page.d.ts +0 -8
  257. package/dist/types/marketing/WebsiteData.d.ts +0 -23
@@ -1,1771 +0,0 @@
1
- import { __exports as router } from '../../../../../../_virtual/router3.js';
2
- import '../../../../../@swc/helpers/cjs/_interop_require_default.cjs.js';
3
- import { __require as require_interop_require_wildcard } from '../../../../../@swc/helpers/cjs/_interop_require_wildcard.cjs.js';
4
- import { __require as requireRemoveTrailingSlash } from './utils/remove-trailing-slash.js';
5
- import { __require as requireRouteLoader } from '../../../client/route-loader.js';
6
- import { __require as requireScript } from '../../../client/script.js';
7
- import { __require as requireIsError } from '../../../lib/is-error.js';
8
- import { __require as requireDenormalizePagePath } from '../page-path/denormalize-page-path.js';
9
- import { __require as requireNormalizeLocalePath } from '../i18n/normalize-locale-path.js';
10
- import { __require as requireMitt } from '../mitt.js';
11
- import { __require as requireUtils } from '../utils.js';
12
- import { __require as requireIsDynamic } from './utils/is-dynamic.js';
13
- import { __require as requireParseRelativeUrl } from './utils/parse-relative-url.js';
14
- import { __require as requireResolveRewrites } from './utils/resolve-rewrites.js';
15
- import { __require as requireRouteMatcher } from './utils/route-matcher.js';
16
- import { __require as requireRouteRegex } from './utils/route-regex.js';
17
- import { __require as requireFormatUrl } from './utils/format-url.js';
18
- import { __require as requireDetectDomainLocale } from '../../../client/detect-domain-locale.js';
19
- import { __require as requireParsePath } from './utils/parse-path.js';
20
- import { __require as requireAddLocale } from '../../../client/add-locale.js';
21
- import { __require as requireRemoveLocale } from '../../../client/remove-locale.js';
22
- import { __require as requireRemoveBasePath } from '../../../client/remove-base-path.js';
23
- import { __require as requireAddBasePath } from '../../../client/add-base-path.js';
24
- import { __require as requireHasBasePath } from '../../../client/has-base-path.js';
25
- import { __require as requireResolveHref } from '../../../client/resolve-href.js';
26
- import { __require as requireIsApiRoute } from '../../../lib/is-api-route.js';
27
- import { __require as requireGetNextPathnameInfo } from './utils/get-next-pathname-info.js';
28
- import { __require as requireFormatNextPathnameInfo } from './utils/format-next-pathname-info.js';
29
- import { __require as requireCompareStates } from './utils/compare-states.js';
30
- import { __require as requireIsLocalUrl } from './utils/is-local-url.js';
31
- import { __require as requireIsBot } from './utils/is-bot.js';
32
- import { __require as requireOmit } from './utils/omit.js';
33
- import { __require as requireInterpolateAs } from './utils/interpolate-as.js';
34
- import { __require as requireHandleSmoothScroll } from './utils/handle-smooth-scroll.js';
35
- import { __require as requireReactIs } from '../../../compiled/react-is/index.js';
36
- import { __require as requireBloomFilter } from '../bloom-filter.js';
37
- import { __exports as _interop_require_default } from '../../../../../../_virtual/_interop_require_default.cjs.js';
38
-
39
- var hasRequiredRouter;
40
-
41
- function requireRouter () {
42
- if (hasRequiredRouter) return router;
43
- hasRequiredRouter = 1;
44
- (function (exports) {
45
- Object.defineProperty(exports, "__esModule", {
46
- value: true
47
- });
48
- function _export(target, all) {
49
- for(var name in all)Object.defineProperty(target, name, {
50
- enumerable: true,
51
- get: all[name]
52
- });
53
- }
54
- _export(exports, {
55
- default: function() {
56
- return Router;
57
- },
58
- matchesMiddleware: function() {
59
- return matchesMiddleware;
60
- },
61
- createKey: function() {
62
- return createKey;
63
- }
64
- });
65
- const _interop_require_default$1 = _interop_require_default;
66
- const _interop_require_wildcard = require_interop_require_wildcard();
67
- const _removetrailingslash = requireRemoveTrailingSlash();
68
- const _routeloader = requireRouteLoader();
69
- const _script = requireScript();
70
- const _iserror = /*#__PURE__*/ _interop_require_wildcard._(requireIsError());
71
- const _denormalizepagepath = requireDenormalizePagePath();
72
- const _normalizelocalepath = requireNormalizeLocalePath();
73
- const _mitt = /*#__PURE__*/ _interop_require_default$1._(requireMitt());
74
- const _utils = requireUtils();
75
- const _isdynamic = requireIsDynamic();
76
- const _parserelativeurl = requireParseRelativeUrl();
77
- const _resolverewrites = /*#__PURE__*/ _interop_require_default$1._(requireResolveRewrites());
78
- const _routematcher = requireRouteMatcher();
79
- const _routeregex = requireRouteRegex();
80
- const _formaturl = requireFormatUrl();
81
- const _detectdomainlocale = requireDetectDomainLocale();
82
- const _parsepath = requireParsePath();
83
- const _addlocale = requireAddLocale();
84
- const _removelocale = requireRemoveLocale();
85
- const _removebasepath = requireRemoveBasePath();
86
- const _addbasepath = requireAddBasePath();
87
- const _hasbasepath = requireHasBasePath();
88
- const _resolvehref = requireResolveHref();
89
- const _isapiroute = requireIsApiRoute();
90
- const _getnextpathnameinfo = requireGetNextPathnameInfo();
91
- const _formatnextpathnameinfo = requireFormatNextPathnameInfo();
92
- const _comparestates = requireCompareStates();
93
- const _islocalurl = requireIsLocalUrl();
94
- const _isbot = requireIsBot();
95
- const _omit = requireOmit();
96
- const _interpolateas = requireInterpolateAs();
97
- const _handlesmoothscroll = requireHandleSmoothScroll();
98
- function buildCancellationError() {
99
- return Object.assign(new Error("Route Cancelled"), {
100
- cancelled: true
101
- });
102
- }
103
- async function matchesMiddleware(options) {
104
- const matchers = await Promise.resolve(options.router.pageLoader.getMiddleware());
105
- if (!matchers) return false;
106
- const { pathname: asPathname } = (0, _parsepath.parsePath)(options.asPath);
107
- // remove basePath first since path prefix has to be in the order of `/${basePath}/${locale}`
108
- const cleanedAs = (0, _hasbasepath.hasBasePath)(asPathname) ? (0, _removebasepath.removeBasePath)(asPathname) : asPathname;
109
- const asWithBasePathAndLocale = (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(cleanedAs, options.locale));
110
- // Check only path match on client. Matching "has" should be done on server
111
- // where we can access more info such as headers, HttpOnly cookie, etc.
112
- return matchers.some((m)=>new RegExp(m.regexp).test(asWithBasePathAndLocale));
113
- }
114
- function stripOrigin(url) {
115
- const origin = (0, _utils.getLocationOrigin)();
116
- return url.startsWith(origin) ? url.substring(origin.length) : url;
117
- }
118
- function prepareUrlAs(router, url, as) {
119
- // If url and as provided as an object representation,
120
- // we'll format them into the string version here.
121
- let [resolvedHref, resolvedAs] = (0, _resolvehref.resolveHref)(router, url, true);
122
- const origin = (0, _utils.getLocationOrigin)();
123
- const hrefWasAbsolute = resolvedHref.startsWith(origin);
124
- const asWasAbsolute = resolvedAs && resolvedAs.startsWith(origin);
125
- resolvedHref = stripOrigin(resolvedHref);
126
- resolvedAs = resolvedAs ? stripOrigin(resolvedAs) : resolvedAs;
127
- const preparedUrl = hrefWasAbsolute ? resolvedHref : (0, _addbasepath.addBasePath)(resolvedHref);
128
- const preparedAs = as ? stripOrigin((0, _resolvehref.resolveHref)(router, as)) : resolvedAs || resolvedHref;
129
- return {
130
- url: preparedUrl,
131
- as: asWasAbsolute ? preparedAs : (0, _addbasepath.addBasePath)(preparedAs)
132
- };
133
- }
134
- function resolveDynamicRoute(pathname, pages) {
135
- const cleanPathname = (0, _removetrailingslash.removeTrailingSlash)((0, _denormalizepagepath.denormalizePagePath)(pathname));
136
- if (cleanPathname === "/404" || cleanPathname === "/_error") {
137
- return pathname;
138
- }
139
- // handle resolving href for dynamic routes
140
- if (!pages.includes(cleanPathname)) {
141
- // eslint-disable-next-line array-callback-return
142
- pages.some((page)=>{
143
- if ((0, _isdynamic.isDynamicRoute)(page) && (0, _routeregex.getRouteRegex)(page).re.test(cleanPathname)) {
144
- pathname = page;
145
- return true;
146
- }
147
- });
148
- }
149
- return (0, _removetrailingslash.removeTrailingSlash)(pathname);
150
- }
151
- function getMiddlewareData(source, response, options) {
152
- const nextConfig = {
153
- basePath: options.router.basePath,
154
- i18n: {
155
- locales: options.router.locales
156
- },
157
- trailingSlash: Boolean(process.env.__NEXT_TRAILING_SLASH)
158
- };
159
- const rewriteHeader = response.headers.get("x-nextjs-rewrite");
160
- let rewriteTarget = rewriteHeader || response.headers.get("x-nextjs-matched-path");
161
- const matchedPath = response.headers.get("x-matched-path");
162
- if (matchedPath && !rewriteTarget && !matchedPath.includes("__next_data_catchall") && !matchedPath.includes("/_error") && !matchedPath.includes("/404")) {
163
- // leverage x-matched-path to detect next.config.js rewrites
164
- rewriteTarget = matchedPath;
165
- }
166
- if (rewriteTarget) {
167
- if (rewriteTarget.startsWith("/") || process.env.__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE) {
168
- const parsedRewriteTarget = (0, _parserelativeurl.parseRelativeUrl)(rewriteTarget);
169
- const pathnameInfo = (0, _getnextpathnameinfo.getNextPathnameInfo)(parsedRewriteTarget.pathname, {
170
- nextConfig,
171
- parseData: true
172
- });
173
- let fsPathname = (0, _removetrailingslash.removeTrailingSlash)(pathnameInfo.pathname);
174
- return Promise.all([
175
- options.router.pageLoader.getPageList(),
176
- (0, _routeloader.getClientBuildManifest)()
177
- ]).then((param)=>{
178
- let [pages, { __rewrites: rewrites }] = param;
179
- let as = (0, _addlocale.addLocale)(pathnameInfo.pathname, pathnameInfo.locale);
180
- if ((0, _isdynamic.isDynamicRoute)(as) || !rewriteHeader && pages.includes((0, _normalizelocalepath.normalizeLocalePath)((0, _removebasepath.removeBasePath)(as), options.router.locales).pathname)) {
181
- const parsedSource = (0, _getnextpathnameinfo.getNextPathnameInfo)((0, _parserelativeurl.parseRelativeUrl)(source).pathname, {
182
- nextConfig: process.env.__NEXT_HAS_REWRITES ? undefined : nextConfig,
183
- parseData: true
184
- });
185
- as = (0, _addbasepath.addBasePath)(parsedSource.pathname);
186
- parsedRewriteTarget.pathname = as;
187
- }
188
- if (process.env.__NEXT_HAS_REWRITES) {
189
- const result = (0, _resolverewrites.default)(as, pages, rewrites, parsedRewriteTarget.query, (path)=>resolveDynamicRoute(path, pages), options.router.locales);
190
- if (result.matchedPage) {
191
- parsedRewriteTarget.pathname = result.parsedAs.pathname;
192
- as = parsedRewriteTarget.pathname;
193
- Object.assign(parsedRewriteTarget.query, result.parsedAs.query);
194
- }
195
- } else if (!pages.includes(fsPathname)) {
196
- const resolvedPathname = resolveDynamicRoute(fsPathname, pages);
197
- if (resolvedPathname !== fsPathname) {
198
- fsPathname = resolvedPathname;
199
- }
200
- }
201
- const resolvedHref = !pages.includes(fsPathname) ? resolveDynamicRoute((0, _normalizelocalepath.normalizeLocalePath)((0, _removebasepath.removeBasePath)(parsedRewriteTarget.pathname), options.router.locales).pathname, pages) : fsPathname;
202
- if ((0, _isdynamic.isDynamicRoute)(resolvedHref)) {
203
- const matches = (0, _routematcher.getRouteMatcher)((0, _routeregex.getRouteRegex)(resolvedHref))(as);
204
- Object.assign(parsedRewriteTarget.query, matches || {});
205
- }
206
- return {
207
- type: "rewrite",
208
- parsedAs: parsedRewriteTarget,
209
- resolvedHref
210
- };
211
- });
212
- }
213
- const src = (0, _parsepath.parsePath)(source);
214
- const pathname = (0, _formatnextpathnameinfo.formatNextPathnameInfo)({
215
- ...(0, _getnextpathnameinfo.getNextPathnameInfo)(src.pathname, {
216
- nextConfig,
217
- parseData: true
218
- }),
219
- defaultLocale: options.router.defaultLocale,
220
- buildId: ""
221
- });
222
- return Promise.resolve({
223
- type: "redirect-external",
224
- destination: "" + pathname + src.query + src.hash
225
- });
226
- }
227
- const redirectTarget = response.headers.get("x-nextjs-redirect");
228
- if (redirectTarget) {
229
- if (redirectTarget.startsWith("/")) {
230
- const src = (0, _parsepath.parsePath)(redirectTarget);
231
- const pathname = (0, _formatnextpathnameinfo.formatNextPathnameInfo)({
232
- ...(0, _getnextpathnameinfo.getNextPathnameInfo)(src.pathname, {
233
- nextConfig,
234
- parseData: true
235
- }),
236
- defaultLocale: options.router.defaultLocale,
237
- buildId: ""
238
- });
239
- return Promise.resolve({
240
- type: "redirect-internal",
241
- newAs: "" + pathname + src.query + src.hash,
242
- newUrl: "" + pathname + src.query + src.hash
243
- });
244
- }
245
- return Promise.resolve({
246
- type: "redirect-external",
247
- destination: redirectTarget
248
- });
249
- }
250
- return Promise.resolve({
251
- type: "next"
252
- });
253
- }
254
- async function withMiddlewareEffects(options) {
255
- const matches = await matchesMiddleware(options);
256
- if (!matches || !options.fetchData) {
257
- return null;
258
- }
259
- try {
260
- const data = await options.fetchData();
261
- const effect = await getMiddlewareData(data.dataHref, data.response, options);
262
- return {
263
- dataHref: data.dataHref,
264
- json: data.json,
265
- response: data.response,
266
- text: data.text,
267
- cacheKey: data.cacheKey,
268
- effect
269
- };
270
- } catch (e) {
271
- /**
272
- * TODO: Revisit this in the future.
273
- * For now we will not consider middleware data errors to be fatal.
274
- * maybe we should revisit in the future.
275
- */ return null;
276
- }
277
- }
278
- const manualScrollRestoration = process.env.__NEXT_SCROLL_RESTORATION && typeof window !== "undefined" && "scrollRestoration" in window.history && !!function() {
279
- try {
280
- let v = "__next";
281
- // eslint-disable-next-line no-sequences
282
- return sessionStorage.setItem(v, v), sessionStorage.removeItem(v), true;
283
- } catch (n) {}
284
- }();
285
- const SSG_DATA_NOT_FOUND = Symbol("SSG_DATA_NOT_FOUND");
286
- function fetchRetry(url, attempts, options) {
287
- return fetch(url, {
288
- // Cookies are required to be present for Next.js' SSG "Preview Mode".
289
- // Cookies may also be required for `getServerSideProps`.
290
- //
291
- // > `fetch` won’t send cookies, unless you set the credentials init
292
- // > option.
293
- // https://developer.mozilla.org/docs/Web/API/Fetch_API/Using_Fetch
294
- //
295
- // > For maximum browser compatibility when it comes to sending &
296
- // > receiving cookies, always supply the `credentials: 'same-origin'`
297
- // > option instead of relying on the default.
298
- // https://github.com/github/fetch#caveats
299
- credentials: "same-origin",
300
- method: options.method || "GET",
301
- headers: Object.assign({}, options.headers, {
302
- "x-nextjs-data": "1"
303
- })
304
- }).then((response)=>{
305
- return !response.ok && attempts > 1 && response.status >= 500 ? fetchRetry(url, attempts - 1, options) : response;
306
- });
307
- }
308
- function tryToParseAsJSON(text) {
309
- try {
310
- return JSON.parse(text);
311
- } catch (error) {
312
- return null;
313
- }
314
- }
315
- function fetchNextData(param) {
316
- let { dataHref, inflightCache, isPrefetch, hasMiddleware, isServerRender, parseJSON, persistCache, isBackground, unstable_skipClientCache } = param;
317
- const { href: cacheKey } = new URL(dataHref, window.location.href);
318
- var _params_method;
319
- const getData = (params)=>fetchRetry(dataHref, isServerRender ? 3 : 1, {
320
- headers: Object.assign({}, isPrefetch ? {
321
- purpose: "prefetch"
322
- } : {}, isPrefetch && hasMiddleware ? {
323
- "x-middleware-prefetch": "1"
324
- } : {}),
325
- method: (_params_method = params == null ? void 0 : params.method) != null ? _params_method : "GET"
326
- }).then((response)=>{
327
- if (response.ok && (params == null ? void 0 : params.method) === "HEAD") {
328
- return {
329
- dataHref,
330
- response,
331
- text: "",
332
- json: {},
333
- cacheKey
334
- };
335
- }
336
- return response.text().then((text)=>{
337
- if (!response.ok) {
338
- /**
339
- * When the data response is a redirect because of a middleware
340
- * we do not consider it an error. The headers must bring the
341
- * mapped location.
342
- * TODO: Change the status code in the handler.
343
- */ if (hasMiddleware && [
344
- 301,
345
- 302,
346
- 307,
347
- 308
348
- ].includes(response.status)) {
349
- return {
350
- dataHref,
351
- response,
352
- text,
353
- json: {},
354
- cacheKey
355
- };
356
- }
357
- if (response.status === 404) {
358
- var _tryToParseAsJSON;
359
- if ((_tryToParseAsJSON = tryToParseAsJSON(text)) == null ? void 0 : _tryToParseAsJSON.notFound) {
360
- return {
361
- dataHref,
362
- json: {
363
- notFound: SSG_DATA_NOT_FOUND
364
- },
365
- response,
366
- text,
367
- cacheKey
368
- };
369
- }
370
- }
371
- const error = new Error("Failed to load static props");
372
- /**
373
- * We should only trigger a server-side transition if this was
374
- * caused on a client-side transition. Otherwise, we'd get into
375
- * an infinite loop.
376
- */ if (!isServerRender) {
377
- (0, _routeloader.markAssetError)(error);
378
- }
379
- throw error;
380
- }
381
- return {
382
- dataHref,
383
- json: parseJSON ? tryToParseAsJSON(text) : null,
384
- response,
385
- text,
386
- cacheKey
387
- };
388
- });
389
- }).then((data)=>{
390
- if (!persistCache || process.env.NODE_ENV !== "production" || data.response.headers.get("x-middleware-cache") === "no-cache") {
391
- delete inflightCache[cacheKey];
392
- }
393
- return data;
394
- }).catch((err)=>{
395
- if (!unstable_skipClientCache) {
396
- delete inflightCache[cacheKey];
397
- }
398
- if (// chrome
399
- err.message === "Failed to fetch" || // firefox
400
- err.message === "NetworkError when attempting to fetch resource." || // safari
401
- err.message === "Load failed") {
402
- (0, _routeloader.markAssetError)(err);
403
- }
404
- throw err;
405
- });
406
- // when skipping client cache we wait to update
407
- // inflight cache until successful data response
408
- // this allows racing click event with fetching newer data
409
- // without blocking navigation when stale data is available
410
- if (unstable_skipClientCache && persistCache) {
411
- return getData({}).then((data)=>{
412
- inflightCache[cacheKey] = Promise.resolve(data);
413
- return data;
414
- });
415
- }
416
- if (inflightCache[cacheKey] !== undefined) {
417
- return inflightCache[cacheKey];
418
- }
419
- return inflightCache[cacheKey] = getData(isBackground ? {
420
- method: "HEAD"
421
- } : {});
422
- }
423
- function createKey() {
424
- return Math.random().toString(36).slice(2, 10);
425
- }
426
- function handleHardNavigation(param) {
427
- let { url, router } = param;
428
- // ensure we don't trigger a hard navigation to the same
429
- // URL as this can end up with an infinite refresh
430
- if (url === (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(router.asPath, router.locale))) {
431
- throw new Error("Invariant: attempted to hard navigate to the same URL " + url + " " + location.href);
432
- }
433
- window.location.href = url;
434
- }
435
- const getCancelledHandler = (param)=>{
436
- let { route, router } = param;
437
- let cancelled = false;
438
- const cancel = router.clc = ()=>{
439
- cancelled = true;
440
- };
441
- const handleCancelled = ()=>{
442
- if (cancelled) {
443
- const error = new Error('Abort fetching component for route: "' + route + '"');
444
- error.cancelled = true;
445
- throw error;
446
- }
447
- if (cancel === router.clc) {
448
- router.clc = null;
449
- }
450
- };
451
- return handleCancelled;
452
- };
453
- class Router {
454
- reload() {
455
- window.location.reload();
456
- }
457
- /**
458
- * Go back in history
459
- */ back() {
460
- window.history.back();
461
- }
462
- /**
463
- * Go forward in history
464
- */ forward() {
465
- window.history.forward();
466
- }
467
- /**
468
- * Performs a `pushState` with arguments
469
- * @param url of the route
470
- * @param as masks `url` for the browser
471
- * @param options object you can define `shallow` and other options
472
- */ push(url, as, options) {
473
- if (options === void 0) options = {};
474
- if (process.env.__NEXT_SCROLL_RESTORATION) {
475
- // TODO: remove in the future when we update history before route change
476
- // is complete, as the popstate event should handle this capture.
477
- if (manualScrollRestoration) {
478
- try {
479
- // Snapshot scroll position right before navigating to a new page:
480
- sessionStorage.setItem("__next_scroll_" + this._key, JSON.stringify({
481
- x: self.pageXOffset,
482
- y: self.pageYOffset
483
- }));
484
- } catch (e) {}
485
- }
486
- }
487
- ({ url, as } = prepareUrlAs(this, url, as));
488
- return this.change("pushState", url, as, options);
489
- }
490
- /**
491
- * Performs a `replaceState` with arguments
492
- * @param url of the route
493
- * @param as masks `url` for the browser
494
- * @param options object you can define `shallow` and other options
495
- */ replace(url, as, options) {
496
- if (options === void 0) options = {};
497
- ({ url, as } = prepareUrlAs(this, url, as));
498
- return this.change("replaceState", url, as, options);
499
- }
500
- async _bfl(as, resolvedAs, locale, skipNavigate) {
501
- if (process.env.__NEXT_CLIENT_ROUTER_FILTER_ENABLED) {
502
- let matchesBflStatic = false;
503
- let matchesBflDynamic = false;
504
- for (const curAs of [
505
- as,
506
- resolvedAs
507
- ]){
508
- if (curAs) {
509
- const asNoSlash = (0, _removetrailingslash.removeTrailingSlash)(new URL(curAs, "http://n").pathname);
510
- const asNoSlashLocale = (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(asNoSlash, locale || this.locale));
511
- if (asNoSlash !== (0, _removetrailingslash.removeTrailingSlash)(new URL(this.asPath, "http://n").pathname)) {
512
- var _this__bfl_s, _this__bfl_s1;
513
- matchesBflStatic = matchesBflStatic || !!((_this__bfl_s = this._bfl_s) == null ? void 0 : _this__bfl_s.contains(asNoSlash)) || !!((_this__bfl_s1 = this._bfl_s) == null ? void 0 : _this__bfl_s1.contains(asNoSlashLocale));
514
- for (const normalizedAS of [
515
- asNoSlash,
516
- asNoSlashLocale
517
- ]){
518
- // if any sub-path of as matches a dynamic filter path
519
- // it should be hard navigated
520
- const curAsParts = normalizedAS.split("/");
521
- for(let i = 0; !matchesBflDynamic && i < curAsParts.length + 1; i++){
522
- var _this__bfl_d;
523
- const currentPart = curAsParts.slice(0, i).join("/");
524
- if (currentPart && ((_this__bfl_d = this._bfl_d) == null ? void 0 : _this__bfl_d.contains(currentPart))) {
525
- matchesBflDynamic = true;
526
- break;
527
- }
528
- }
529
- }
530
- // if the client router filter is matched then we trigger
531
- // a hard navigation
532
- if (matchesBflStatic || matchesBflDynamic) {
533
- if (skipNavigate) {
534
- return true;
535
- }
536
- handleHardNavigation({
537
- url: (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(as, locale || this.locale, this.defaultLocale)),
538
- router: this
539
- });
540
- return new Promise(()=>{});
541
- }
542
- }
543
- }
544
- }
545
- }
546
- return false;
547
- }
548
- async change(method, url, as, options, forcedScroll) {
549
- var _this_components_pathname;
550
- if (!(0, _islocalurl.isLocalURL)(url)) {
551
- handleHardNavigation({
552
- url,
553
- router: this
554
- });
555
- return false;
556
- }
557
- // WARNING: `_h` is an internal option for handing Next.js client-side
558
- // hydration. Your app should _never_ use this property. It may change at
559
- // any time without notice.
560
- const isQueryUpdating = options._h === 1;
561
- if (!isQueryUpdating && !options.shallow) {
562
- await this._bfl(as, undefined, options.locale);
563
- }
564
- let shouldResolveHref = isQueryUpdating || options._shouldResolveHref || (0, _parsepath.parsePath)(url).pathname === (0, _parsepath.parsePath)(as).pathname;
565
- const nextState = {
566
- ...this.state
567
- };
568
- // for static pages with query params in the URL we delay
569
- // marking the router ready until after the query is updated
570
- // or a navigation has occurred
571
- const readyStateChange = this.isReady !== true;
572
- this.isReady = true;
573
- const isSsr = this.isSsr;
574
- if (!isQueryUpdating) {
575
- this.isSsr = false;
576
- }
577
- // if a route transition is already in progress before
578
- // the query updating is triggered ignore query updating
579
- if (isQueryUpdating && this.clc) {
580
- return false;
581
- }
582
- const prevLocale = nextState.locale;
583
- if (process.env.__NEXT_I18N_SUPPORT) {
584
- nextState.locale = options.locale === false ? this.defaultLocale : options.locale || nextState.locale;
585
- if (typeof options.locale === "undefined") {
586
- options.locale = nextState.locale;
587
- }
588
- const parsedAs = (0, _parserelativeurl.parseRelativeUrl)((0, _hasbasepath.hasBasePath)(as) ? (0, _removebasepath.removeBasePath)(as) : as);
589
- const localePathResult = (0, _normalizelocalepath.normalizeLocalePath)(parsedAs.pathname, this.locales);
590
- if (localePathResult.detectedLocale) {
591
- nextState.locale = localePathResult.detectedLocale;
592
- parsedAs.pathname = (0, _addbasepath.addBasePath)(parsedAs.pathname);
593
- as = (0, _formaturl.formatWithValidation)(parsedAs);
594
- url = (0, _addbasepath.addBasePath)((0, _normalizelocalepath.normalizeLocalePath)((0, _hasbasepath.hasBasePath)(url) ? (0, _removebasepath.removeBasePath)(url) : url, this.locales).pathname);
595
- }
596
- let didNavigate = false;
597
- // we need to wrap this in the env check again since regenerator runtime
598
- // moves this on its own due to the return
599
- if (process.env.__NEXT_I18N_SUPPORT) {
600
- var _this_locales;
601
- // if the locale isn't configured hard navigate to show 404 page
602
- if (!((_this_locales = this.locales) == null ? void 0 : _this_locales.includes(nextState.locale))) {
603
- parsedAs.pathname = (0, _addlocale.addLocale)(parsedAs.pathname, nextState.locale);
604
- handleHardNavigation({
605
- url: (0, _formaturl.formatWithValidation)(parsedAs),
606
- router: this
607
- });
608
- // this was previously a return but was removed in favor
609
- // of better dead code elimination with regenerator runtime
610
- didNavigate = true;
611
- }
612
- }
613
- const detectedDomain = (0, _detectdomainlocale.detectDomainLocale)(this.domainLocales, undefined, nextState.locale);
614
- // we need to wrap this in the env check again since regenerator runtime
615
- // moves this on its own due to the return
616
- if (process.env.__NEXT_I18N_SUPPORT) {
617
- // if we are navigating to a domain locale ensure we redirect to the
618
- // correct domain
619
- if (!didNavigate && detectedDomain && this.isLocaleDomain && self.location.hostname !== detectedDomain.domain) {
620
- const asNoBasePath = (0, _removebasepath.removeBasePath)(as);
621
- handleHardNavigation({
622
- url: "http" + (detectedDomain.http ? "" : "s") + "://" + detectedDomain.domain + (0, _addbasepath.addBasePath)("" + (nextState.locale === detectedDomain.defaultLocale ? "" : "/" + nextState.locale) + (asNoBasePath === "/" ? "" : asNoBasePath) || "/"),
623
- router: this
624
- });
625
- // this was previously a return but was removed in favor
626
- // of better dead code elimination with regenerator runtime
627
- didNavigate = true;
628
- }
629
- }
630
- if (didNavigate) {
631
- return new Promise(()=>{});
632
- }
633
- }
634
- // marking route changes as a navigation start entry
635
- if (_utils.ST) {
636
- performance.mark("routeChange");
637
- }
638
- const { shallow = false, scroll = true } = options;
639
- const routeProps = {
640
- shallow
641
- };
642
- if (this._inFlightRoute && this.clc) {
643
- if (!isSsr) {
644
- Router.events.emit("routeChangeError", buildCancellationError(), this._inFlightRoute, routeProps);
645
- }
646
- this.clc();
647
- this.clc = null;
648
- }
649
- as = (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)((0, _hasbasepath.hasBasePath)(as) ? (0, _removebasepath.removeBasePath)(as) : as, options.locale, this.defaultLocale));
650
- const cleanedAs = (0, _removelocale.removeLocale)((0, _hasbasepath.hasBasePath)(as) ? (0, _removebasepath.removeBasePath)(as) : as, nextState.locale);
651
- this._inFlightRoute = as;
652
- const localeChange = prevLocale !== nextState.locale;
653
- // If the url change is only related to a hash change
654
- // We should not proceed. We should only change the state.
655
- if (!isQueryUpdating && this.onlyAHashChange(cleanedAs) && !localeChange) {
656
- nextState.asPath = cleanedAs;
657
- Router.events.emit("hashChangeStart", as, routeProps);
658
- // TODO: do we need the resolved href when only a hash change?
659
- this.changeState(method, url, as, {
660
- ...options,
661
- scroll: false
662
- });
663
- if (scroll) {
664
- this.scrollToHash(cleanedAs);
665
- }
666
- try {
667
- await this.set(nextState, this.components[nextState.route], null);
668
- } catch (err) {
669
- if ((0, _iserror.default)(err) && err.cancelled) {
670
- Router.events.emit("routeChangeError", err, cleanedAs, routeProps);
671
- }
672
- throw err;
673
- }
674
- Router.events.emit("hashChangeComplete", as, routeProps);
675
- return true;
676
- }
677
- let parsed = (0, _parserelativeurl.parseRelativeUrl)(url);
678
- let { pathname, query } = parsed;
679
- // if we detected the path as app route during prefetching
680
- // trigger hard navigation
681
- if ((_this_components_pathname = this.components[pathname]) == null ? void 0 : _this_components_pathname.__appRouter) {
682
- handleHardNavigation({
683
- url: as,
684
- router: this
685
- });
686
- return new Promise(()=>{});
687
- }
688
- // The build manifest needs to be loaded before auto-static dynamic pages
689
- // get their query parameters to allow ensuring they can be parsed properly
690
- // when rewritten to
691
- let pages, rewrites;
692
- try {
693
- [pages, { __rewrites: rewrites }] = await Promise.all([
694
- this.pageLoader.getPageList(),
695
- (0, _routeloader.getClientBuildManifest)(),
696
- this.pageLoader.getMiddleware()
697
- ]);
698
- } catch (err) {
699
- // If we fail to resolve the page list or client-build manifest, we must
700
- // do a server-side transition:
701
- handleHardNavigation({
702
- url: as,
703
- router: this
704
- });
705
- return false;
706
- }
707
- // If asked to change the current URL we should reload the current page
708
- // (not location.reload() but reload getInitialProps and other Next.js stuffs)
709
- // We also need to set the method = replaceState always
710
- // as this should not go into the history (That's how browsers work)
711
- // We should compare the new asPath to the current asPath, not the url
712
- if (!this.urlIsNew(cleanedAs) && !localeChange) {
713
- method = "replaceState";
714
- }
715
- // we need to resolve the as value using rewrites for dynamic SSG
716
- // pages to allow building the data URL correctly
717
- let resolvedAs = as;
718
- // url and as should always be prefixed with basePath by this
719
- // point by either next/link or router.push/replace so strip the
720
- // basePath from the pathname to match the pages dir 1-to-1
721
- pathname = pathname ? (0, _removetrailingslash.removeTrailingSlash)((0, _removebasepath.removeBasePath)(pathname)) : pathname;
722
- let route = (0, _removetrailingslash.removeTrailingSlash)(pathname);
723
- const parsedAsPathname = as.startsWith("/") && (0, _parserelativeurl.parseRelativeUrl)(as).pathname;
724
- const isMiddlewareRewrite = !!(parsedAsPathname && route !== parsedAsPathname && (!(0, _isdynamic.isDynamicRoute)(route) || !(0, _routematcher.getRouteMatcher)((0, _routeregex.getRouteRegex)(route))(parsedAsPathname)));
725
- // we don't attempt resolve asPath when we need to execute
726
- // middleware as the resolving will occur server-side
727
- const isMiddlewareMatch = !options.shallow && await matchesMiddleware({
728
- asPath: as,
729
- locale: nextState.locale,
730
- router: this
731
- });
732
- if (isQueryUpdating && isMiddlewareMatch) {
733
- shouldResolveHref = false;
734
- }
735
- if (shouldResolveHref && pathname !== "/_error") {
736
- options._shouldResolveHref = true;
737
- if (process.env.__NEXT_HAS_REWRITES && as.startsWith("/")) {
738
- const rewritesResult = (0, _resolverewrites.default)((0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(cleanedAs, nextState.locale), true), pages, rewrites, query, (p)=>resolveDynamicRoute(p, pages), this.locales);
739
- if (rewritesResult.externalDest) {
740
- handleHardNavigation({
741
- url: as,
742
- router: this
743
- });
744
- return true;
745
- }
746
- if (!isMiddlewareMatch) {
747
- resolvedAs = rewritesResult.asPath;
748
- }
749
- if (rewritesResult.matchedPage && rewritesResult.resolvedHref) {
750
- // if this directly matches a page we need to update the href to
751
- // allow the correct page chunk to be loaded
752
- pathname = rewritesResult.resolvedHref;
753
- parsed.pathname = (0, _addbasepath.addBasePath)(pathname);
754
- if (!isMiddlewareMatch) {
755
- url = (0, _formaturl.formatWithValidation)(parsed);
756
- }
757
- }
758
- } else {
759
- parsed.pathname = resolveDynamicRoute(pathname, pages);
760
- if (parsed.pathname !== pathname) {
761
- pathname = parsed.pathname;
762
- parsed.pathname = (0, _addbasepath.addBasePath)(pathname);
763
- if (!isMiddlewareMatch) {
764
- url = (0, _formaturl.formatWithValidation)(parsed);
765
- }
766
- }
767
- }
768
- }
769
- if (!(0, _islocalurl.isLocalURL)(as)) {
770
- if (process.env.NODE_ENV !== "production") {
771
- throw new Error('Invalid href: "' + url + '" and as: "' + as + '", received relative href and external as' + "\nSee more info: https://nextjs.org/docs/messages/invalid-relative-url-external-as");
772
- }
773
- handleHardNavigation({
774
- url: as,
775
- router: this
776
- });
777
- return false;
778
- }
779
- resolvedAs = (0, _removelocale.removeLocale)((0, _removebasepath.removeBasePath)(resolvedAs), nextState.locale);
780
- route = (0, _removetrailingslash.removeTrailingSlash)(pathname);
781
- let routeMatch = false;
782
- if ((0, _isdynamic.isDynamicRoute)(route)) {
783
- const parsedAs = (0, _parserelativeurl.parseRelativeUrl)(resolvedAs);
784
- const asPathname = parsedAs.pathname;
785
- const routeRegex = (0, _routeregex.getRouteRegex)(route);
786
- routeMatch = (0, _routematcher.getRouteMatcher)(routeRegex)(asPathname);
787
- const shouldInterpolate = route === asPathname;
788
- const interpolatedAs = shouldInterpolate ? (0, _interpolateas.interpolateAs)(route, asPathname, query) : {};
789
- if (!routeMatch || shouldInterpolate && !interpolatedAs.result) {
790
- const missingParams = Object.keys(routeRegex.groups).filter((param)=>!query[param] && !routeRegex.groups[param].optional);
791
- if (missingParams.length > 0 && !isMiddlewareMatch) {
792
- if (process.env.NODE_ENV !== "production") {
793
- console.warn("" + (shouldInterpolate ? "Interpolating href" : "Mismatching `as` and `href`") + " failed to manually provide " + ("the params: " + missingParams.join(", ") + " in the `href`'s `query`"));
794
- }
795
- 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")));
796
- }
797
- } else if (shouldInterpolate) {
798
- as = (0, _formaturl.formatWithValidation)(Object.assign({}, parsedAs, {
799
- pathname: interpolatedAs.result,
800
- query: (0, _omit.omit)(query, interpolatedAs.params)
801
- }));
802
- } else {
803
- // Merge params into `query`, overwriting any specified in search
804
- Object.assign(query, routeMatch);
805
- }
806
- }
807
- if (!isQueryUpdating) {
808
- Router.events.emit("routeChangeStart", as, routeProps);
809
- }
810
- const isErrorRoute = this.pathname === "/404" || this.pathname === "/_error";
811
- try {
812
- var _self___NEXT_DATA___props_pageProps, _self___NEXT_DATA___props, _routeInfo_props;
813
- let routeInfo = await this.getRouteInfo({
814
- route,
815
- pathname,
816
- query,
817
- as,
818
- resolvedAs,
819
- routeProps,
820
- locale: nextState.locale,
821
- isPreview: nextState.isPreview,
822
- hasMiddleware: isMiddlewareMatch,
823
- unstable_skipClientCache: options.unstable_skipClientCache,
824
- isQueryUpdating: isQueryUpdating && !this.isFallback,
825
- isMiddlewareRewrite
826
- });
827
- if (!isQueryUpdating && !options.shallow) {
828
- await this._bfl(as, "resolvedAs" in routeInfo ? routeInfo.resolvedAs : undefined, nextState.locale);
829
- }
830
- if ("route" in routeInfo && isMiddlewareMatch) {
831
- pathname = routeInfo.route || route;
832
- route = pathname;
833
- if (!routeProps.shallow) {
834
- query = Object.assign({}, routeInfo.query || {}, query);
835
- }
836
- const cleanedParsedPathname = (0, _hasbasepath.hasBasePath)(parsed.pathname) ? (0, _removebasepath.removeBasePath)(parsed.pathname) : parsed.pathname;
837
- if (routeMatch && pathname !== cleanedParsedPathname) {
838
- Object.keys(routeMatch).forEach((key)=>{
839
- if (routeMatch && query[key] === routeMatch[key]) {
840
- delete query[key];
841
- }
842
- });
843
- }
844
- if ((0, _isdynamic.isDynamicRoute)(pathname)) {
845
- const prefixedAs = !routeProps.shallow && routeInfo.resolvedAs ? routeInfo.resolvedAs : (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(new URL(as, location.href).pathname, nextState.locale), true);
846
- let rewriteAs = prefixedAs;
847
- if ((0, _hasbasepath.hasBasePath)(rewriteAs)) {
848
- rewriteAs = (0, _removebasepath.removeBasePath)(rewriteAs);
849
- }
850
- if (process.env.__NEXT_I18N_SUPPORT) {
851
- const localeResult = (0, _normalizelocalepath.normalizeLocalePath)(rewriteAs, this.locales);
852
- nextState.locale = localeResult.detectedLocale || nextState.locale;
853
- rewriteAs = localeResult.pathname;
854
- }
855
- const routeRegex = (0, _routeregex.getRouteRegex)(pathname);
856
- const curRouteMatch = (0, _routematcher.getRouteMatcher)(routeRegex)(new URL(rewriteAs, location.href).pathname);
857
- if (curRouteMatch) {
858
- Object.assign(query, curRouteMatch);
859
- }
860
- }
861
- }
862
- // If the routeInfo brings a redirect we simply apply it.
863
- if ("type" in routeInfo) {
864
- if (routeInfo.type === "redirect-internal") {
865
- return this.change(method, routeInfo.newUrl, routeInfo.newAs, options);
866
- } else {
867
- handleHardNavigation({
868
- url: routeInfo.destination,
869
- router: this
870
- });
871
- return new Promise(()=>{});
872
- }
873
- }
874
- const component = routeInfo.Component;
875
- if (component && component.unstable_scriptLoader) {
876
- const scripts = [].concat(component.unstable_scriptLoader());
877
- scripts.forEach((script)=>{
878
- (0, _script.handleClientScriptLoad)(script.props);
879
- });
880
- }
881
- // handle redirect on client-transition
882
- if ((routeInfo.__N_SSG || routeInfo.__N_SSP) && routeInfo.props) {
883
- if (routeInfo.props.pageProps && routeInfo.props.pageProps.__N_REDIRECT) {
884
- // Use the destination from redirect without adding locale
885
- options.locale = false;
886
- const destination = routeInfo.props.pageProps.__N_REDIRECT;
887
- // check if destination is internal (resolves to a page) and attempt
888
- // client-navigation if it is falling back to hard navigation if
889
- // it's not
890
- if (destination.startsWith("/") && routeInfo.props.pageProps.__N_REDIRECT_BASE_PATH !== false) {
891
- const parsedHref = (0, _parserelativeurl.parseRelativeUrl)(destination);
892
- parsedHref.pathname = resolveDynamicRoute(parsedHref.pathname, pages);
893
- const { url: newUrl, as: newAs } = prepareUrlAs(this, destination, destination);
894
- return this.change(method, newUrl, newAs, options);
895
- }
896
- handleHardNavigation({
897
- url: destination,
898
- router: this
899
- });
900
- return new Promise(()=>{});
901
- }
902
- nextState.isPreview = !!routeInfo.props.__N_PREVIEW;
903
- // handle SSG data 404
904
- if (routeInfo.props.notFound === SSG_DATA_NOT_FOUND) {
905
- let notFoundRoute;
906
- try {
907
- await this.fetchComponent("/404");
908
- notFoundRoute = "/404";
909
- } catch (_) {
910
- notFoundRoute = "/_error";
911
- }
912
- routeInfo = await this.getRouteInfo({
913
- route: notFoundRoute,
914
- pathname: notFoundRoute,
915
- query,
916
- as,
917
- resolvedAs,
918
- routeProps: {
919
- shallow: false
920
- },
921
- locale: nextState.locale,
922
- isPreview: nextState.isPreview,
923
- isNotFound: true
924
- });
925
- if ("type" in routeInfo) {
926
- throw new Error("Unexpected middleware effect on /404");
927
- }
928
- }
929
- }
930
- if (isQueryUpdating && this.pathname === "/_error" && ((_self___NEXT_DATA___props = self.__NEXT_DATA__.props) == null ? void 0 : (_self___NEXT_DATA___props_pageProps = _self___NEXT_DATA___props.pageProps) == null ? void 0 : _self___NEXT_DATA___props_pageProps.statusCode) === 500 && ((_routeInfo_props = routeInfo.props) == null ? void 0 : _routeInfo_props.pageProps)) {
931
- // ensure statusCode is still correct for static 500 page
932
- // when updating query information
933
- routeInfo.props.pageProps.statusCode = 500;
934
- }
935
- var _routeInfo_route;
936
- // shallow routing is only allowed for same page URL changes.
937
- const isValidShallowRoute = options.shallow && nextState.route === ((_routeInfo_route = routeInfo.route) != null ? _routeInfo_route : route);
938
- var _options_scroll;
939
- const shouldScroll = (_options_scroll = options.scroll) != null ? _options_scroll : !isQueryUpdating && !isValidShallowRoute;
940
- const resetScroll = shouldScroll ? {
941
- x: 0,
942
- y: 0
943
- } : null;
944
- const upcomingScrollState = forcedScroll != null ? forcedScroll : resetScroll;
945
- // the new state that the router gonna set
946
- const upcomingRouterState = {
947
- ...nextState,
948
- route,
949
- pathname,
950
- query,
951
- asPath: cleanedAs,
952
- isFallback: false
953
- };
954
- // When the page being rendered is the 404 page, we should only update the
955
- // query parameters. Route changes here might add the basePath when it
956
- // wasn't originally present. This is also why this block is before the
957
- // below `changeState` call which updates the browser's history (changing
958
- // the URL).
959
- if (isQueryUpdating && isErrorRoute) {
960
- var _self___NEXT_DATA___props_pageProps1, _self___NEXT_DATA___props1, _routeInfo_props1;
961
- routeInfo = await this.getRouteInfo({
962
- route: this.pathname,
963
- pathname: this.pathname,
964
- query,
965
- as,
966
- resolvedAs,
967
- routeProps: {
968
- shallow: false
969
- },
970
- locale: nextState.locale,
971
- isPreview: nextState.isPreview,
972
- isQueryUpdating: isQueryUpdating && !this.isFallback
973
- });
974
- if ("type" in routeInfo) {
975
- throw new Error("Unexpected middleware effect on " + this.pathname);
976
- }
977
- if (this.pathname === "/_error" && ((_self___NEXT_DATA___props1 = self.__NEXT_DATA__.props) == null ? void 0 : (_self___NEXT_DATA___props_pageProps1 = _self___NEXT_DATA___props1.pageProps) == null ? void 0 : _self___NEXT_DATA___props_pageProps1.statusCode) === 500 && ((_routeInfo_props1 = routeInfo.props) == null ? void 0 : _routeInfo_props1.pageProps)) {
978
- // ensure statusCode is still correct for static 500 page
979
- // when updating query information
980
- routeInfo.props.pageProps.statusCode = 500;
981
- }
982
- try {
983
- await this.set(upcomingRouterState, routeInfo, upcomingScrollState);
984
- } catch (err) {
985
- if ((0, _iserror.default)(err) && err.cancelled) {
986
- Router.events.emit("routeChangeError", err, cleanedAs, routeProps);
987
- }
988
- throw err;
989
- }
990
- return true;
991
- }
992
- Router.events.emit("beforeHistoryChange", as, routeProps);
993
- this.changeState(method, url, as, options);
994
- // for query updates we can skip it if the state is unchanged and we don't
995
- // need to scroll
996
- // https://github.com/vercel/next.js/issues/37139
997
- const canSkipUpdating = isQueryUpdating && !upcomingScrollState && !readyStateChange && !localeChange && (0, _comparestates.compareRouterStates)(upcomingRouterState, this.state);
998
- if (!canSkipUpdating) {
999
- try {
1000
- await this.set(upcomingRouterState, routeInfo, upcomingScrollState);
1001
- } catch (e) {
1002
- if (e.cancelled) routeInfo.error = routeInfo.error || e;
1003
- else throw e;
1004
- }
1005
- if (routeInfo.error) {
1006
- if (!isQueryUpdating) {
1007
- Router.events.emit("routeChangeError", routeInfo.error, cleanedAs, routeProps);
1008
- }
1009
- throw routeInfo.error;
1010
- }
1011
- if (process.env.__NEXT_I18N_SUPPORT) {
1012
- if (nextState.locale) {
1013
- document.documentElement.lang = nextState.locale;
1014
- }
1015
- }
1016
- if (!isQueryUpdating) {
1017
- Router.events.emit("routeChangeComplete", as, routeProps);
1018
- }
1019
- // A hash mark # is the optional last part of a URL
1020
- const hashRegex = /#.+$/;
1021
- if (shouldScroll && hashRegex.test(as)) {
1022
- this.scrollToHash(as);
1023
- }
1024
- }
1025
- return true;
1026
- } catch (err) {
1027
- if ((0, _iserror.default)(err) && err.cancelled) {
1028
- return false;
1029
- }
1030
- throw err;
1031
- }
1032
- }
1033
- changeState(method, url, as, options) {
1034
- if (options === void 0) options = {};
1035
- if (process.env.NODE_ENV !== "production") {
1036
- if (typeof window.history === "undefined") {
1037
- console.error("Warning: window.history is not available.");
1038
- return;
1039
- }
1040
- if (typeof window.history[method] === "undefined") {
1041
- console.error("Warning: window.history." + method + " is not available");
1042
- return;
1043
- }
1044
- }
1045
- if (method !== "pushState" || (0, _utils.getURL)() !== as) {
1046
- this._shallow = options.shallow;
1047
- window.history[method]({
1048
- url,
1049
- as,
1050
- options,
1051
- __N: true,
1052
- key: this._key = method !== "pushState" ? this._key : createKey()
1053
- }, // Most browsers currently ignores this parameter, although they may use it in the future.
1054
- // Passing the empty string here should be safe against future changes to the method.
1055
- // https://developer.mozilla.org/docs/Web/API/History/replaceState
1056
- "", as);
1057
- }
1058
- }
1059
- async handleRouteInfoError(err, pathname, query, as, routeProps, loadErrorFail) {
1060
- console.error(err);
1061
- if (err.cancelled) {
1062
- // bubble up cancellation errors
1063
- throw err;
1064
- }
1065
- if ((0, _routeloader.isAssetError)(err) || loadErrorFail) {
1066
- Router.events.emit("routeChangeError", err, as, routeProps);
1067
- // If we can't load the page it could be one of following reasons
1068
- // 1. Page doesn't exists
1069
- // 2. Page does exist in a different zone
1070
- // 3. Internal error while loading the page
1071
- // So, doing a hard reload is the proper way to deal with this.
1072
- handleHardNavigation({
1073
- url: as,
1074
- router: this
1075
- });
1076
- // Changing the URL doesn't block executing the current code path.
1077
- // So let's throw a cancellation error stop the routing logic.
1078
- throw buildCancellationError();
1079
- }
1080
- try {
1081
- let props;
1082
- const { page: Component, styleSheets } = await this.fetchComponent("/_error");
1083
- const routeInfo = {
1084
- props,
1085
- Component,
1086
- styleSheets,
1087
- err,
1088
- error: err
1089
- };
1090
- if (!routeInfo.props) {
1091
- try {
1092
- routeInfo.props = await this.getInitialProps(Component, {
1093
- err,
1094
- pathname,
1095
- query
1096
- });
1097
- } catch (gipErr) {
1098
- console.error("Error in error page `getInitialProps`: ", gipErr);
1099
- routeInfo.props = {};
1100
- }
1101
- }
1102
- return routeInfo;
1103
- } catch (routeInfoErr) {
1104
- return this.handleRouteInfoError((0, _iserror.default)(routeInfoErr) ? routeInfoErr : new Error(routeInfoErr + ""), pathname, query, as, routeProps, true);
1105
- }
1106
- }
1107
- async getRouteInfo(param) {
1108
- let { route: requestedRoute, pathname, query, as, resolvedAs, routeProps, locale, hasMiddleware, isPreview, unstable_skipClientCache, isQueryUpdating, isMiddlewareRewrite, isNotFound } = param;
1109
- /**
1110
- * This `route` binding can change if there's a rewrite
1111
- * so we keep a reference to the original requested route
1112
- * so we can store the cache for it and avoid re-requesting every time
1113
- * for shallow routing purposes.
1114
- */ let route = requestedRoute;
1115
- try {
1116
- var _data_effect, _data_effect1, _data_effect2, _data_response;
1117
- const handleCancelled = getCancelledHandler({
1118
- route,
1119
- router: this
1120
- });
1121
- let existingInfo = this.components[route];
1122
- if (routeProps.shallow && existingInfo && this.route === route) {
1123
- return existingInfo;
1124
- }
1125
- if (hasMiddleware) {
1126
- existingInfo = undefined;
1127
- }
1128
- let cachedRouteInfo = existingInfo && !("initial" in existingInfo) && process.env.NODE_ENV !== "development" ? existingInfo : undefined;
1129
- const isBackground = isQueryUpdating;
1130
- const fetchNextDataParams = {
1131
- dataHref: this.pageLoader.getDataHref({
1132
- href: (0, _formaturl.formatWithValidation)({
1133
- pathname,
1134
- query
1135
- }),
1136
- skipInterpolation: true,
1137
- asPath: isNotFound ? "/404" : resolvedAs,
1138
- locale
1139
- }),
1140
- hasMiddleware: true,
1141
- isServerRender: this.isSsr,
1142
- parseJSON: true,
1143
- inflightCache: isBackground ? this.sbc : this.sdc,
1144
- persistCache: !isPreview,
1145
- isPrefetch: false,
1146
- unstable_skipClientCache,
1147
- isBackground
1148
- };
1149
- let data = isQueryUpdating && !isMiddlewareRewrite ? null : await withMiddlewareEffects({
1150
- fetchData: ()=>fetchNextData(fetchNextDataParams),
1151
- asPath: isNotFound ? "/404" : resolvedAs,
1152
- locale: locale,
1153
- router: this
1154
- }).catch((err)=>{
1155
- // we don't hard error during query updating
1156
- // as it's un-necessary and doesn't need to be fatal
1157
- // unless it is a fallback route and the props can't
1158
- // be loaded
1159
- if (isQueryUpdating) {
1160
- return null;
1161
- }
1162
- throw err;
1163
- });
1164
- // when rendering error routes we don't apply middleware
1165
- // effects
1166
- if (data && (pathname === "/_error" || pathname === "/404")) {
1167
- data.effect = undefined;
1168
- }
1169
- if (isQueryUpdating) {
1170
- if (!data) {
1171
- data = {
1172
- json: self.__NEXT_DATA__.props
1173
- };
1174
- } else {
1175
- data.json = self.__NEXT_DATA__.props;
1176
- }
1177
- }
1178
- handleCancelled();
1179
- if ((data == null ? void 0 : (_data_effect = data.effect) == null ? void 0 : _data_effect.type) === "redirect-internal" || (data == null ? void 0 : (_data_effect1 = data.effect) == null ? void 0 : _data_effect1.type) === "redirect-external") {
1180
- return data.effect;
1181
- }
1182
- if ((data == null ? void 0 : (_data_effect2 = data.effect) == null ? void 0 : _data_effect2.type) === "rewrite") {
1183
- const resolvedRoute = (0, _removetrailingslash.removeTrailingSlash)(data.effect.resolvedHref);
1184
- const pages = await this.pageLoader.getPageList();
1185
- // during query updating the page must match although during
1186
- // client-transition a redirect that doesn't match a page
1187
- // can be returned and this should trigger a hard navigation
1188
- // which is valid for incremental migration
1189
- if (!isQueryUpdating || pages.includes(resolvedRoute)) {
1190
- route = resolvedRoute;
1191
- pathname = data.effect.resolvedHref;
1192
- query = {
1193
- ...query,
1194
- ...data.effect.parsedAs.query
1195
- };
1196
- resolvedAs = (0, _removebasepath.removeBasePath)((0, _normalizelocalepath.normalizeLocalePath)(data.effect.parsedAs.pathname, this.locales).pathname);
1197
- // Check again the cache with the new destination.
1198
- existingInfo = this.components[route];
1199
- if (routeProps.shallow && existingInfo && this.route === route && !hasMiddleware) {
1200
- // If we have a match with the current route due to rewrite,
1201
- // we can copy the existing information to the rewritten one.
1202
- // Then, we return the information along with the matched route.
1203
- return {
1204
- ...existingInfo,
1205
- route
1206
- };
1207
- }
1208
- }
1209
- }
1210
- if ((0, _isapiroute.isAPIRoute)(route)) {
1211
- handleHardNavigation({
1212
- url: as,
1213
- router: this
1214
- });
1215
- return new Promise(()=>{});
1216
- }
1217
- const routeInfo = cachedRouteInfo || await this.fetchComponent(route).then((res)=>({
1218
- Component: res.page,
1219
- styleSheets: res.styleSheets,
1220
- __N_SSG: res.mod.__N_SSG,
1221
- __N_SSP: res.mod.__N_SSP
1222
- }));
1223
- if (process.env.NODE_ENV !== "production") {
1224
- const { isValidElementType } = requireReactIs();
1225
- if (!isValidElementType(routeInfo.Component)) {
1226
- throw new Error('The default export is not a React Component in page: "' + pathname + '"');
1227
- }
1228
- }
1229
- const wasBailedPrefetch = data == null ? void 0 : (_data_response = data.response) == null ? void 0 : _data_response.headers.get("x-middleware-skip");
1230
- const shouldFetchData = routeInfo.__N_SSG || routeInfo.__N_SSP;
1231
- // For non-SSG prefetches that bailed before sending data
1232
- // we clear the cache to fetch full response
1233
- if (wasBailedPrefetch && (data == null ? void 0 : data.dataHref)) {
1234
- delete this.sdc[data.dataHref];
1235
- }
1236
- const { props, cacheKey } = await this._getData(async ()=>{
1237
- if (shouldFetchData) {
1238
- if ((data == null ? void 0 : data.json) && !wasBailedPrefetch) {
1239
- return {
1240
- cacheKey: data.cacheKey,
1241
- props: data.json
1242
- };
1243
- }
1244
- const dataHref = (data == null ? void 0 : data.dataHref) ? data.dataHref : this.pageLoader.getDataHref({
1245
- href: (0, _formaturl.formatWithValidation)({
1246
- pathname,
1247
- query
1248
- }),
1249
- asPath: resolvedAs,
1250
- locale
1251
- });
1252
- const fetched = await fetchNextData({
1253
- dataHref,
1254
- isServerRender: this.isSsr,
1255
- parseJSON: true,
1256
- inflightCache: wasBailedPrefetch ? {} : this.sdc,
1257
- persistCache: !isPreview,
1258
- isPrefetch: false,
1259
- unstable_skipClientCache
1260
- });
1261
- return {
1262
- cacheKey: fetched.cacheKey,
1263
- props: fetched.json || {}
1264
- };
1265
- }
1266
- return {
1267
- headers: {},
1268
- props: await this.getInitialProps(routeInfo.Component, // we provide AppTree later so this needs to be `any`
1269
- {
1270
- pathname,
1271
- query,
1272
- asPath: as,
1273
- locale,
1274
- locales: this.locales,
1275
- defaultLocale: this.defaultLocale
1276
- })
1277
- };
1278
- });
1279
- // Only bust the data cache for SSP routes although
1280
- // middleware can skip cache per request with
1281
- // x-middleware-cache: no-cache as well
1282
- if (routeInfo.__N_SSP && fetchNextDataParams.dataHref && cacheKey) {
1283
- delete this.sdc[cacheKey];
1284
- }
1285
- // we kick off a HEAD request in the background
1286
- // when a non-prefetch request is made to signal revalidation
1287
- if (!this.isPreview && routeInfo.__N_SSG && process.env.NODE_ENV !== "development" && !isQueryUpdating) {
1288
- fetchNextData(Object.assign({}, fetchNextDataParams, {
1289
- isBackground: true,
1290
- persistCache: false,
1291
- inflightCache: this.sbc
1292
- })).catch(()=>{});
1293
- }
1294
- props.pageProps = Object.assign({}, props.pageProps);
1295
- routeInfo.props = props;
1296
- routeInfo.route = route;
1297
- routeInfo.query = query;
1298
- routeInfo.resolvedAs = resolvedAs;
1299
- this.components[route] = routeInfo;
1300
- return routeInfo;
1301
- } catch (err) {
1302
- return this.handleRouteInfoError((0, _iserror.getProperError)(err), pathname, query, as, routeProps);
1303
- }
1304
- }
1305
- set(state, data, resetScroll) {
1306
- this.state = state;
1307
- return this.sub(data, this.components["/_app"].Component, resetScroll);
1308
- }
1309
- /**
1310
- * Callback to execute before replacing router state
1311
- * @param cb callback to be executed
1312
- */ beforePopState(cb) {
1313
- this._bps = cb;
1314
- }
1315
- onlyAHashChange(as) {
1316
- if (!this.asPath) return false;
1317
- const [oldUrlNoHash, oldHash] = this.asPath.split("#");
1318
- const [newUrlNoHash, newHash] = as.split("#");
1319
- // Makes sure we scroll to the provided hash if the url/hash are the same
1320
- if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {
1321
- return true;
1322
- }
1323
- // If the urls are change, there's more than a hash change
1324
- if (oldUrlNoHash !== newUrlNoHash) {
1325
- return false;
1326
- }
1327
- // If the hash has changed, then it's a hash only change.
1328
- // This check is necessary to handle both the enter and
1329
- // leave hash === '' cases. The identity case falls through
1330
- // and is treated as a next reload.
1331
- return oldHash !== newHash;
1332
- }
1333
- scrollToHash(as) {
1334
- const [, hash = ""] = as.split("#");
1335
- (0, _handlesmoothscroll.handleSmoothScroll)(()=>{
1336
- // Scroll to top if the hash is just `#` with no value or `#top`
1337
- // To mirror browsers
1338
- if (hash === "" || hash === "top") {
1339
- window.scrollTo(0, 0);
1340
- return;
1341
- }
1342
- // Decode hash to make non-latin anchor works.
1343
- const rawHash = decodeURIComponent(hash);
1344
- // First we check if the element by id is found
1345
- const idEl = document.getElementById(rawHash);
1346
- if (idEl) {
1347
- idEl.scrollIntoView();
1348
- return;
1349
- }
1350
- // If there's no element with the id, we check the `name` property
1351
- // To mirror browsers
1352
- const nameEl = document.getElementsByName(rawHash)[0];
1353
- if (nameEl) {
1354
- nameEl.scrollIntoView();
1355
- }
1356
- }, {
1357
- onlyHashChange: this.onlyAHashChange(as)
1358
- });
1359
- }
1360
- urlIsNew(asPath) {
1361
- return this.asPath !== asPath;
1362
- }
1363
- /**
1364
- * Prefetch page code, you may wait for the data during page rendering.
1365
- * This feature only works in production!
1366
- * @param url the href of prefetched page
1367
- * @param asPath the as path of the prefetched page
1368
- */ async prefetch(url, asPath, options) {
1369
- if (asPath === void 0) asPath = url;
1370
- if (options === void 0) options = {};
1371
- // Prefetch is not supported in development mode because it would trigger on-demand-entries
1372
- if (process.env.NODE_ENV !== "production") {
1373
- return;
1374
- }
1375
- if (typeof window !== "undefined" && (0, _isbot.isBot)(window.navigator.userAgent)) {
1376
- // No prefetches for bots that render the link since they are typically navigating
1377
- // links via the equivalent of a hard navigation and hence never utilize these
1378
- // prefetches.
1379
- return;
1380
- }
1381
- let parsed = (0, _parserelativeurl.parseRelativeUrl)(url);
1382
- const urlPathname = parsed.pathname;
1383
- let { pathname, query } = parsed;
1384
- const originalPathname = pathname;
1385
- if (process.env.__NEXT_I18N_SUPPORT) {
1386
- if (options.locale === false) {
1387
- pathname = (0, _normalizelocalepath.normalizeLocalePath)(pathname, this.locales).pathname;
1388
- parsed.pathname = pathname;
1389
- url = (0, _formaturl.formatWithValidation)(parsed);
1390
- let parsedAs = (0, _parserelativeurl.parseRelativeUrl)(asPath);
1391
- const localePathResult = (0, _normalizelocalepath.normalizeLocalePath)(parsedAs.pathname, this.locales);
1392
- parsedAs.pathname = localePathResult.pathname;
1393
- options.locale = localePathResult.detectedLocale || this.defaultLocale;
1394
- asPath = (0, _formaturl.formatWithValidation)(parsedAs);
1395
- }
1396
- }
1397
- const pages = await this.pageLoader.getPageList();
1398
- let resolvedAs = asPath;
1399
- const locale = typeof options.locale !== "undefined" ? options.locale || undefined : this.locale;
1400
- const isMiddlewareMatch = await matchesMiddleware({
1401
- asPath: asPath,
1402
- locale: locale,
1403
- router: this
1404
- });
1405
- if (process.env.__NEXT_HAS_REWRITES && asPath.startsWith("/")) {
1406
- let rewrites;
1407
- ({ __rewrites: rewrites } = await (0, _routeloader.getClientBuildManifest)());
1408
- const rewritesResult = (0, _resolverewrites.default)((0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(asPath, this.locale), true), pages, rewrites, parsed.query, (p)=>resolveDynamicRoute(p, pages), this.locales);
1409
- if (rewritesResult.externalDest) {
1410
- return;
1411
- }
1412
- if (!isMiddlewareMatch) {
1413
- resolvedAs = (0, _removelocale.removeLocale)((0, _removebasepath.removeBasePath)(rewritesResult.asPath), this.locale);
1414
- }
1415
- if (rewritesResult.matchedPage && rewritesResult.resolvedHref) {
1416
- // if this directly matches a page we need to update the href to
1417
- // allow the correct page chunk to be loaded
1418
- pathname = rewritesResult.resolvedHref;
1419
- parsed.pathname = pathname;
1420
- if (!isMiddlewareMatch) {
1421
- url = (0, _formaturl.formatWithValidation)(parsed);
1422
- }
1423
- }
1424
- }
1425
- parsed.pathname = resolveDynamicRoute(parsed.pathname, pages);
1426
- if ((0, _isdynamic.isDynamicRoute)(parsed.pathname)) {
1427
- pathname = parsed.pathname;
1428
- parsed.pathname = pathname;
1429
- Object.assign(query, (0, _routematcher.getRouteMatcher)((0, _routeregex.getRouteRegex)(parsed.pathname))((0, _parsepath.parsePath)(asPath).pathname) || {});
1430
- if (!isMiddlewareMatch) {
1431
- url = (0, _formaturl.formatWithValidation)(parsed);
1432
- }
1433
- }
1434
- const data = process.env.__NEXT_MIDDLEWARE_PREFETCH === "strict" ? null : await withMiddlewareEffects({
1435
- fetchData: ()=>fetchNextData({
1436
- dataHref: this.pageLoader.getDataHref({
1437
- href: (0, _formaturl.formatWithValidation)({
1438
- pathname: originalPathname,
1439
- query
1440
- }),
1441
- skipInterpolation: true,
1442
- asPath: resolvedAs,
1443
- locale
1444
- }),
1445
- hasMiddleware: true,
1446
- isServerRender: this.isSsr,
1447
- parseJSON: true,
1448
- inflightCache: this.sdc,
1449
- persistCache: !this.isPreview,
1450
- isPrefetch: true
1451
- }),
1452
- asPath: asPath,
1453
- locale: locale,
1454
- router: this
1455
- });
1456
- /**
1457
- * If there was a rewrite we apply the effects of the rewrite on the
1458
- * current parameters for the prefetch.
1459
- */ if ((data == null ? void 0 : data.effect.type) === "rewrite") {
1460
- parsed.pathname = data.effect.resolvedHref;
1461
- pathname = data.effect.resolvedHref;
1462
- query = {
1463
- ...query,
1464
- ...data.effect.parsedAs.query
1465
- };
1466
- resolvedAs = data.effect.parsedAs.pathname;
1467
- url = (0, _formaturl.formatWithValidation)(parsed);
1468
- }
1469
- /**
1470
- * If there is a redirect to an external destination then we don't have
1471
- * to prefetch content as it will be unused.
1472
- */ if ((data == null ? void 0 : data.effect.type) === "redirect-external") {
1473
- return;
1474
- }
1475
- const route = (0, _removetrailingslash.removeTrailingSlash)(pathname);
1476
- if (await this._bfl(asPath, resolvedAs, options.locale, true)) {
1477
- this.components[urlPathname] = {
1478
- __appRouter: true
1479
- };
1480
- }
1481
- await Promise.all([
1482
- this.pageLoader._isSsg(route).then((isSsg)=>{
1483
- return isSsg ? fetchNextData({
1484
- dataHref: (data == null ? void 0 : data.json) ? data == null ? void 0 : data.dataHref : this.pageLoader.getDataHref({
1485
- href: url,
1486
- asPath: resolvedAs,
1487
- locale: locale
1488
- }),
1489
- isServerRender: false,
1490
- parseJSON: true,
1491
- inflightCache: this.sdc,
1492
- persistCache: !this.isPreview,
1493
- isPrefetch: true,
1494
- unstable_skipClientCache: options.unstable_skipClientCache || options.priority && !!process.env.__NEXT_OPTIMISTIC_CLIENT_CACHE
1495
- }).then(()=>false).catch(()=>false) : false;
1496
- }),
1497
- this.pageLoader[options.priority ? "loadPage" : "prefetch"](route)
1498
- ]);
1499
- }
1500
- async fetchComponent(route) {
1501
- const handleCancelled = getCancelledHandler({
1502
- route,
1503
- router: this
1504
- });
1505
- try {
1506
- const componentResult = await this.pageLoader.loadPage(route);
1507
- handleCancelled();
1508
- return componentResult;
1509
- } catch (err) {
1510
- handleCancelled();
1511
- throw err;
1512
- }
1513
- }
1514
- _getData(fn) {
1515
- let cancelled = false;
1516
- const cancel = ()=>{
1517
- cancelled = true;
1518
- };
1519
- this.clc = cancel;
1520
- return fn().then((data)=>{
1521
- if (cancel === this.clc) {
1522
- this.clc = null;
1523
- }
1524
- if (cancelled) {
1525
- const err = new Error("Loading initial props cancelled");
1526
- err.cancelled = true;
1527
- throw err;
1528
- }
1529
- return data;
1530
- });
1531
- }
1532
- _getFlightData(dataHref) {
1533
- // Do not cache RSC flight response since it's not a static resource
1534
- return fetchNextData({
1535
- dataHref,
1536
- isServerRender: true,
1537
- parseJSON: false,
1538
- inflightCache: this.sdc,
1539
- persistCache: false,
1540
- isPrefetch: false
1541
- }).then((param)=>{
1542
- let { text } = param;
1543
- return {
1544
- data: text
1545
- };
1546
- });
1547
- }
1548
- getInitialProps(Component, ctx) {
1549
- const { Component: App } = this.components["/_app"];
1550
- const AppTree = this._wrapApp(App);
1551
- ctx.AppTree = AppTree;
1552
- return (0, _utils.loadGetInitialProps)(App, {
1553
- AppTree,
1554
- Component,
1555
- router: this,
1556
- ctx
1557
- });
1558
- }
1559
- get route() {
1560
- return this.state.route;
1561
- }
1562
- get pathname() {
1563
- return this.state.pathname;
1564
- }
1565
- get query() {
1566
- return this.state.query;
1567
- }
1568
- get asPath() {
1569
- return this.state.asPath;
1570
- }
1571
- get locale() {
1572
- return this.state.locale;
1573
- }
1574
- get isFallback() {
1575
- return this.state.isFallback;
1576
- }
1577
- get isPreview() {
1578
- return this.state.isPreview;
1579
- }
1580
- constructor(pathname, query, as, { initialProps, pageLoader, App, wrapApp, Component, err, subscription, isFallback, locale, locales, defaultLocale, domainLocales, isPreview }){
1581
- // Server Data Cache (full data requests)
1582
- this.sdc = {};
1583
- // Server Background Cache (HEAD requests)
1584
- this.sbc = {};
1585
- this.isFirstPopStateEvent = true;
1586
- this._key = createKey();
1587
- this.onPopState = (e)=>{
1588
- const { isFirstPopStateEvent } = this;
1589
- this.isFirstPopStateEvent = false;
1590
- const state = e.state;
1591
- if (!state) {
1592
- // We get state as undefined for two reasons.
1593
- // 1. With older safari (< 8) and older chrome (< 34)
1594
- // 2. When the URL changed with #
1595
- //
1596
- // In the both cases, we don't need to proceed and change the route.
1597
- // (as it's already changed)
1598
- // But we can simply replace the state with the new changes.
1599
- // Actually, for (1) we don't need to nothing. But it's hard to detect that event.
1600
- // So, doing the following for (1) does no harm.
1601
- const { pathname, query } = this;
1602
- this.changeState("replaceState", (0, _formaturl.formatWithValidation)({
1603
- pathname: (0, _addbasepath.addBasePath)(pathname),
1604
- query
1605
- }), (0, _utils.getURL)());
1606
- return;
1607
- }
1608
- // __NA is used to identify if the history entry can be handled by the app-router.
1609
- if (state.__NA) {
1610
- window.location.reload();
1611
- return;
1612
- }
1613
- if (!state.__N) {
1614
- return;
1615
- }
1616
- // Safari fires popstateevent when reopening the browser.
1617
- if (isFirstPopStateEvent && this.locale === state.options.locale && state.as === this.asPath) {
1618
- return;
1619
- }
1620
- let forcedScroll;
1621
- const { url, as, options, key } = state;
1622
- if (process.env.__NEXT_SCROLL_RESTORATION) {
1623
- if (manualScrollRestoration) {
1624
- if (this._key !== key) {
1625
- // Snapshot current scroll position:
1626
- try {
1627
- sessionStorage.setItem("__next_scroll_" + this._key, JSON.stringify({
1628
- x: self.pageXOffset,
1629
- y: self.pageYOffset
1630
- }));
1631
- } catch (e) {}
1632
- // Restore old scroll position:
1633
- try {
1634
- const v = sessionStorage.getItem("__next_scroll_" + key);
1635
- forcedScroll = JSON.parse(v);
1636
- } catch (e) {
1637
- forcedScroll = {
1638
- x: 0,
1639
- y: 0
1640
- };
1641
- }
1642
- }
1643
- }
1644
- }
1645
- this._key = key;
1646
- const { pathname } = (0, _parserelativeurl.parseRelativeUrl)(url);
1647
- // Make sure we don't re-render on initial load,
1648
- // can be caused by navigating back from an external site
1649
- if (this.isSsr && as === (0, _addbasepath.addBasePath)(this.asPath) && pathname === (0, _addbasepath.addBasePath)(this.pathname)) {
1650
- return;
1651
- }
1652
- // If the downstream application returns falsy, return.
1653
- // They will then be responsible for handling the event.
1654
- if (this._bps && !this._bps(state)) {
1655
- return;
1656
- }
1657
- this.change("replaceState", url, as, Object.assign({}, options, {
1658
- shallow: options.shallow && this._shallow,
1659
- locale: options.locale || this.defaultLocale,
1660
- // @ts-ignore internal value not exposed on types
1661
- _h: 0
1662
- }), forcedScroll);
1663
- };
1664
- // represents the current component key
1665
- const route = (0, _removetrailingslash.removeTrailingSlash)(pathname);
1666
- // set up the component cache (by route keys)
1667
- this.components = {};
1668
- // We should not keep the cache, if there's an error
1669
- // Otherwise, this cause issues when when going back and
1670
- // come again to the errored page.
1671
- if (pathname !== "/_error") {
1672
- this.components[route] = {
1673
- Component,
1674
- initial: true,
1675
- props: initialProps,
1676
- err,
1677
- __N_SSG: initialProps && initialProps.__N_SSG,
1678
- __N_SSP: initialProps && initialProps.__N_SSP
1679
- };
1680
- }
1681
- this.components["/_app"] = {
1682
- Component: App,
1683
- styleSheets: []
1684
- };
1685
- if (process.env.__NEXT_CLIENT_ROUTER_FILTER_ENABLED) {
1686
- const { BloomFilter } = requireBloomFilter();
1687
- const staticFilterData = process.env.__NEXT_CLIENT_ROUTER_S_FILTER;
1688
- const dynamicFilterData = process.env.__NEXT_CLIENT_ROUTER_D_FILTER;
1689
- if (staticFilterData == null ? void 0 : staticFilterData.numHashes) {
1690
- this._bfl_s = new BloomFilter(staticFilterData.numItems, staticFilterData.errorRate);
1691
- this._bfl_s.import(staticFilterData);
1692
- }
1693
- if (dynamicFilterData == null ? void 0 : dynamicFilterData.numHashes) {
1694
- this._bfl_d = new BloomFilter(dynamicFilterData.numItems, dynamicFilterData.errorRate);
1695
- this._bfl_d.import(dynamicFilterData);
1696
- }
1697
- }
1698
- // Backwards compat for Router.router.events
1699
- // TODO: Should be remove the following major version as it was never documented
1700
- this.events = Router.events;
1701
- this.pageLoader = pageLoader;
1702
- // if auto prerendered and dynamic route wait to update asPath
1703
- // until after mount to prevent hydration mismatch
1704
- const autoExportDynamic = (0, _isdynamic.isDynamicRoute)(pathname) && self.__NEXT_DATA__.autoExport;
1705
- this.basePath = process.env.__NEXT_ROUTER_BASEPATH || "";
1706
- this.sub = subscription;
1707
- this.clc = null;
1708
- this._wrapApp = wrapApp;
1709
- // make sure to ignore extra popState in safari on navigating
1710
- // back from external site
1711
- this.isSsr = true;
1712
- this.isLocaleDomain = false;
1713
- this.isReady = !!(self.__NEXT_DATA__.gssp || self.__NEXT_DATA__.gip || self.__NEXT_DATA__.appGip && !self.__NEXT_DATA__.gsp || !autoExportDynamic && !self.location.search && !process.env.__NEXT_HAS_REWRITES);
1714
- if (process.env.__NEXT_I18N_SUPPORT) {
1715
- this.locales = locales;
1716
- this.defaultLocale = defaultLocale;
1717
- this.domainLocales = domainLocales;
1718
- this.isLocaleDomain = !!(0, _detectdomainlocale.detectDomainLocale)(domainLocales, self.location.hostname);
1719
- }
1720
- this.state = {
1721
- route,
1722
- pathname,
1723
- query,
1724
- asPath: autoExportDynamic ? pathname : as,
1725
- isPreview: !!isPreview,
1726
- locale: process.env.__NEXT_I18N_SUPPORT ? locale : undefined,
1727
- isFallback
1728
- };
1729
- this._initialMatchesMiddlewarePromise = Promise.resolve(false);
1730
- if (typeof window !== "undefined") {
1731
- // make sure "as" doesn't start with double slashes or else it can
1732
- // throw an error as it's considered invalid
1733
- if (!as.startsWith("//")) {
1734
- // in order for `e.state` to work on the `onpopstate` event
1735
- // we have to register the initial route upon initialization
1736
- const options = {
1737
- locale
1738
- };
1739
- const asPath = (0, _utils.getURL)();
1740
- this._initialMatchesMiddlewarePromise = matchesMiddleware({
1741
- router: this,
1742
- locale,
1743
- asPath
1744
- }).then((matches)=>{
1745
- options._shouldResolveHref = as !== pathname;
1746
- this.changeState("replaceState", matches ? asPath : (0, _formaturl.formatWithValidation)({
1747
- pathname: (0, _addbasepath.addBasePath)(pathname),
1748
- query
1749
- }), asPath, options);
1750
- return matches;
1751
- });
1752
- }
1753
- window.addEventListener("popstate", this.onPopState);
1754
- // enable custom scroll restoration handling when available
1755
- // otherwise fallback to browser's default handling
1756
- if (process.env.__NEXT_SCROLL_RESTORATION) {
1757
- if (manualScrollRestoration) {
1758
- window.history.scrollRestoration = "manual";
1759
- }
1760
- }
1761
- }
1762
- }
1763
- }
1764
- Router.events = (0, _mitt.default)();
1765
-
1766
-
1767
- } (router));
1768
- return router;
1769
- }
1770
-
1771
- export { requireRouter as __require };