Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

2785 righe
79 KiB

  1. exports.id = 1664;
  2. exports.ids = [1664];
  3. exports.modules = {
  4. /***/ 6071:
  5. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  6. "use strict";
  7. var __webpack_unused_export__;
  8. var _interopRequireWildcard = __webpack_require__(9448);
  9. __webpack_unused_export__ = true;
  10. exports.default = void 0;
  11. var _react = _interopRequireWildcard(__webpack_require__(9297));
  12. var _router = __webpack_require__(1689);
  13. var _router2 = __webpack_require__(2441);
  14. var _useIntersection = __webpack_require__(5749);
  15. const prefetched = {};
  16. function prefetch(router, href, as, options) {
  17. if (true) return;
  18. if (!(0, _router.isLocalURL)(href)) return; // Prefetch the JSON page if asked (only in the client)
  19. // We need to handle a prefetch error here since we may be
  20. // loading with priority which can reject but we don't
  21. // want to force navigation since this is only a prefetch
  22. router.prefetch(href, as, options).catch(err => {
  23. if (false) {}
  24. });
  25. const curLocale = options && typeof options.locale !== 'undefined' ? options.locale : router && router.locale; // Join on an invalid URI character
  26. prefetched[href + '%' + as + (curLocale ? '%' + curLocale : '')] = true;
  27. }
  28. function isModifiedEvent(event) {
  29. const {
  30. target
  31. } = event.currentTarget;
  32. return target && target !== '_self' || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || // triggers resource download
  33. event.nativeEvent && event.nativeEvent.which === 2;
  34. }
  35. function linkClicked(e, router, href, as, replace, shallow, scroll, locale) {
  36. const {
  37. nodeName
  38. } = e.currentTarget;
  39. if (nodeName === 'A' && (isModifiedEvent(e) || !(0, _router.isLocalURL)(href))) {
  40. // ignore click for browser’s default behavior
  41. return;
  42. }
  43. e.preventDefault(); // avoid scroll for urls with anchor refs
  44. if (scroll == null) {
  45. scroll = as.indexOf('#') < 0;
  46. } // replace state instead of push if prop is present
  47. router[replace ? 'replace' : 'push'](href, as, {
  48. shallow,
  49. locale,
  50. scroll
  51. });
  52. }
  53. function Link(props) {
  54. if (false) {}
  55. const p = props.prefetch !== false;
  56. const router = (0, _router2.useRouter)();
  57. const pathname = router && router.asPath || '/';
  58. const {
  59. href,
  60. as
  61. } = _react.default.useMemo(() => {
  62. const [resolvedHref, resolvedAs] = (0, _router.resolveHref)(pathname, props.href, true);
  63. return {
  64. href: resolvedHref,
  65. as: props.as ? (0, _router.resolveHref)(pathname, props.as) : resolvedAs || resolvedHref
  66. };
  67. }, [pathname, props.href, props.as]);
  68. let {
  69. children,
  70. replace,
  71. shallow,
  72. scroll,
  73. locale
  74. } = props; // Deprecated. Warning shown by propType check. If the children provided is a string (<Link>example</Link>) we wrap it in an <a> tag
  75. if (typeof children === 'string') {
  76. children = /*#__PURE__*/_react.default.createElement("a", null, children);
  77. } // This will return the first child, if multiple are provided it will throw an error
  78. const child = _react.Children.only(children);
  79. const childRef = child && typeof child === 'object' && child.ref;
  80. const [setIntersectionRef, isVisible] = (0, _useIntersection.useIntersection)({
  81. rootMargin: '200px'
  82. });
  83. const setRef = _react.default.useCallback(el => {
  84. setIntersectionRef(el);
  85. if (childRef) {
  86. if (typeof childRef === 'function') childRef(el);else if (typeof childRef === 'object') {
  87. childRef.current = el;
  88. }
  89. }
  90. }, [childRef, setIntersectionRef]);
  91. (0, _react.useEffect)(() => {
  92. const shouldPrefetch = isVisible && p && (0, _router.isLocalURL)(href);
  93. const curLocale = typeof locale !== 'undefined' ? locale : router && router.locale;
  94. const isPrefetched = prefetched[href + '%' + as + (curLocale ? '%' + curLocale : '')];
  95. if (shouldPrefetch && !isPrefetched) {
  96. prefetch(router, href, as, {
  97. locale: curLocale
  98. });
  99. }
  100. }, [as, href, isVisible, locale, p, router]);
  101. const childProps = {
  102. ref: setRef,
  103. onClick: e => {
  104. if (child.props && typeof child.props.onClick === 'function') {
  105. child.props.onClick(e);
  106. }
  107. if (!e.defaultPrevented) {
  108. linkClicked(e, router, href, as, replace, shallow, scroll, locale);
  109. }
  110. }
  111. };
  112. childProps.onMouseEnter = e => {
  113. if (!(0, _router.isLocalURL)(href)) return;
  114. if (child.props && typeof child.props.onMouseEnter === 'function') {
  115. child.props.onMouseEnter(e);
  116. }
  117. prefetch(router, href, as, {
  118. priority: true
  119. });
  120. }; // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is
  121. // defined, we specify the current 'href', so that repetition is not needed by the user
  122. if (props.passHref || child.type === 'a' && !('href' in child.props)) {
  123. const curLocale = typeof locale !== 'undefined' ? locale : router && router.locale; // we only render domain locales if we are currently on a domain locale
  124. // so that locale links are still visitable in development/preview envs
  125. const localeDomain = router && router.isLocaleDomain && (0, _router.getDomainLocale)(as, curLocale, router && router.locales, router && router.domainLocales);
  126. childProps.href = localeDomain || (0, _router.addBasePath)((0, _router.addLocale)(as, curLocale, router && router.defaultLocale));
  127. }
  128. return /*#__PURE__*/_react.default.cloneElement(child, childProps);
  129. }
  130. var _default = Link;
  131. exports.default = _default;
  132. /***/ }),
  133. /***/ 6528:
  134. /***/ (function(__unused_webpack_module, exports) {
  135. "use strict";
  136. exports.__esModule = true;
  137. exports.removePathTrailingSlash = removePathTrailingSlash;
  138. exports.normalizePathTrailingSlash = void 0;
  139. /**
  140. * Removes the trailing slash of a path if there is one. Preserves the root path `/`.
  141. */
  142. function removePathTrailingSlash(path) {
  143. return path.endsWith('/') && path !== '/' ? path.slice(0, -1) : path;
  144. }
  145. /**
  146. * Normalizes the trailing slash of a path according to the `trailingSlash` option
  147. * in `next.config.js`.
  148. */
  149. const normalizePathTrailingSlash = true ? path => {
  150. if (/\.[^/]+\/?$/.test(path)) {
  151. return removePathTrailingSlash(path);
  152. } else if (path.endsWith('/')) {
  153. return path;
  154. } else {
  155. return path + '/';
  156. }
  157. } : 0;
  158. exports.normalizePathTrailingSlash = normalizePathTrailingSlash;
  159. /***/ }),
  160. /***/ 8391:
  161. /***/ (function(__unused_webpack_module, exports) {
  162. "use strict";
  163. exports.__esModule = true;
  164. exports.cancelIdleCallback = exports.requestIdleCallback = void 0;
  165. const requestIdleCallback = typeof self !== 'undefined' && self.requestIdleCallback || function (cb) {
  166. let start = Date.now();
  167. return setTimeout(function () {
  168. cb({
  169. didTimeout: false,
  170. timeRemaining: function () {
  171. return Math.max(0, 50 - (Date.now() - start));
  172. }
  173. });
  174. }, 1);
  175. };
  176. exports.requestIdleCallback = requestIdleCallback;
  177. const cancelIdleCallback = typeof self !== 'undefined' && self.cancelIdleCallback || function (id) {
  178. return clearTimeout(id);
  179. };
  180. exports.cancelIdleCallback = cancelIdleCallback;
  181. /***/ }),
  182. /***/ 7599:
  183. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  184. "use strict";
  185. var _interopRequireDefault = __webpack_require__(2426);
  186. exports.__esModule = true;
  187. exports.markAssetError = markAssetError;
  188. exports.isAssetError = isAssetError;
  189. exports.getClientBuildManifest = getClientBuildManifest;
  190. exports.default = void 0;
  191. var _getAssetPathFromRoute = _interopRequireDefault(__webpack_require__(2238));
  192. var _requestIdleCallback = __webpack_require__(8391); // 3.8s was arbitrarily chosen as it's what https://web.dev/interactive
  193. // considers as "Good" time-to-interactive. We must assume something went
  194. // wrong beyond this point, and then fall-back to a full page transition to
  195. // show the user something of value.
  196. const MS_MAX_IDLE_DELAY = 3800;
  197. function withFuture(key, map, generator) {
  198. let entry = map.get(key);
  199. if (entry) {
  200. if ('future' in entry) {
  201. return entry.future;
  202. }
  203. return Promise.resolve(entry);
  204. }
  205. let resolver;
  206. const prom = new Promise(resolve => {
  207. resolver = resolve;
  208. });
  209. map.set(key, entry = {
  210. resolve: resolver,
  211. future: prom
  212. });
  213. return generator ? // eslint-disable-next-line no-sequences
  214. generator().then(value => (resolver(value), value)) : prom;
  215. }
  216. function hasPrefetch(link) {
  217. try {
  218. link = document.createElement('link');
  219. return (// detect IE11 since it supports prefetch but isn't detected
  220. // with relList.support
  221. !!window.MSInputMethodContext && !!document.documentMode || link.relList.supports('prefetch')
  222. );
  223. } catch (_unused) {
  224. return false;
  225. }
  226. }
  227. const canPrefetch = hasPrefetch();
  228. function prefetchViaDom(href, as, link) {
  229. return new Promise((res, rej) => {
  230. if (document.querySelector(`link[rel="prefetch"][href^="${href}"]`)) {
  231. return res();
  232. }
  233. link = document.createElement('link'); // The order of property assignment here is intentional:
  234. if (as) link.as = as;
  235. link.rel = `prefetch`;
  236. link.crossOrigin = undefined;
  237. link.onload = res;
  238. link.onerror = rej; // `href` should always be last:
  239. link.href = href;
  240. document.head.appendChild(link);
  241. });
  242. }
  243. const ASSET_LOAD_ERROR = Symbol('ASSET_LOAD_ERROR'); // TODO: unexport
  244. function markAssetError(err) {
  245. return Object.defineProperty(err, ASSET_LOAD_ERROR, {});
  246. }
  247. function isAssetError(err) {
  248. return err && ASSET_LOAD_ERROR in err;
  249. }
  250. function appendScript(src, script) {
  251. return new Promise((resolve, reject) => {
  252. script = document.createElement('script'); // The order of property assignment here is intentional.
  253. // 1. Setup success/failure hooks in case the browser synchronously
  254. // executes when `src` is set.
  255. script.onload = resolve;
  256. script.onerror = () => reject(markAssetError(new Error(`Failed to load script: ${src}`))); // 2. Configure the cross-origin attribute before setting `src` in case the
  257. // browser begins to fetch.
  258. script.crossOrigin = undefined; // 3. Finally, set the source and inject into the DOM in case the child
  259. // must be appended for fetching to start.
  260. script.src = src;
  261. document.body.appendChild(script);
  262. });
  263. } // Resolve a promise that times out after given amount of milliseconds.
  264. function resolvePromiseWithTimeout(p, ms, err) {
  265. return new Promise((resolve, reject) => {
  266. let cancelled = false;
  267. p.then(r => {
  268. // Resolved, cancel the timeout
  269. cancelled = true;
  270. resolve(r);
  271. }).catch(reject);
  272. (0, _requestIdleCallback.requestIdleCallback)(() => setTimeout(() => {
  273. if (!cancelled) {
  274. reject(err);
  275. }
  276. }, ms));
  277. });
  278. } // TODO: stop exporting or cache the failure
  279. // It'd be best to stop exporting this. It's an implementation detail. We're
  280. // only exporting it for backwards compatibilty with the `page-loader`.
  281. // Only cache this response as a last resort if we cannot eliminate all other
  282. // code branches that use the Build Manifest Callback and push them through
  283. // the Route Loader interface.
  284. function getClientBuildManifest() {
  285. if (self.__BUILD_MANIFEST) {
  286. return Promise.resolve(self.__BUILD_MANIFEST);
  287. }
  288. const onBuildManifest = new Promise(resolve => {
  289. // Mandatory because this is not concurrent safe:
  290. const cb = self.__BUILD_MANIFEST_CB;
  291. self.__BUILD_MANIFEST_CB = () => {
  292. resolve(self.__BUILD_MANIFEST);
  293. cb && cb();
  294. };
  295. });
  296. return resolvePromiseWithTimeout(onBuildManifest, MS_MAX_IDLE_DELAY, markAssetError(new Error('Failed to load client build manifest')));
  297. }
  298. function getFilesForRoute(assetPrefix, route) {
  299. if (false) {}
  300. return getClientBuildManifest().then(manifest => {
  301. if (!(route in manifest)) {
  302. throw markAssetError(new Error(`Failed to lookup route: ${route}`));
  303. }
  304. const allFiles = manifest[route].map(entry => assetPrefix + '/_next/' + encodeURI(entry));
  305. return {
  306. scripts: allFiles.filter(v => v.endsWith('.js')),
  307. css: allFiles.filter(v => v.endsWith('.css'))
  308. };
  309. });
  310. }
  311. function createRouteLoader(assetPrefix) {
  312. const entrypoints = new Map();
  313. const loadedScripts = new Map();
  314. const styleSheets = new Map();
  315. const routes = new Map();
  316. function maybeExecuteScript(src) {
  317. let prom = loadedScripts.get(src);
  318. if (prom) {
  319. return prom;
  320. } // Skip executing script if it's already in the DOM:
  321. if (document.querySelector(`script[src^="${src}"]`)) {
  322. return Promise.resolve();
  323. }
  324. loadedScripts.set(src, prom = appendScript(src));
  325. return prom;
  326. }
  327. function fetchStyleSheet(href) {
  328. let prom = styleSheets.get(href);
  329. if (prom) {
  330. return prom;
  331. }
  332. styleSheets.set(href, prom = fetch(href).then(res => {
  333. if (!res.ok) {
  334. throw new Error(`Failed to load stylesheet: ${href}`);
  335. }
  336. return res.text().then(text => ({
  337. href: href,
  338. content: text
  339. }));
  340. }).catch(err => {
  341. throw markAssetError(err);
  342. }));
  343. return prom;
  344. }
  345. return {
  346. whenEntrypoint(route) {
  347. return withFuture(route, entrypoints);
  348. },
  349. onEntrypoint(route, execute) {
  350. Promise.resolve(execute).then(fn => fn()).then(exports => ({
  351. component: exports && exports.default || exports,
  352. exports: exports
  353. }), err => ({
  354. error: err
  355. })).then(input => {
  356. const old = entrypoints.get(route);
  357. entrypoints.set(route, input);
  358. if (old && 'resolve' in old) old.resolve(input);
  359. });
  360. },
  361. loadRoute(route, prefetch) {
  362. return withFuture(route, routes, () => {
  363. return resolvePromiseWithTimeout(getFilesForRoute(assetPrefix, route).then(({
  364. scripts,
  365. css
  366. }) => {
  367. return Promise.all([entrypoints.has(route) ? [] : Promise.all(scripts.map(maybeExecuteScript)), Promise.all(css.map(fetchStyleSheet))]);
  368. }).then(res => {
  369. return this.whenEntrypoint(route).then(entrypoint => ({
  370. entrypoint,
  371. styles: res[1]
  372. }));
  373. }), MS_MAX_IDLE_DELAY, markAssetError(new Error(`Route did not complete loading: ${route}`))).then(({
  374. entrypoint,
  375. styles
  376. }) => {
  377. const res = Object.assign({
  378. styles: styles
  379. }, entrypoint);
  380. return 'error' in entrypoint ? entrypoint : res;
  381. }).catch(err => {
  382. if (prefetch) {
  383. // we don't want to cache errors during prefetch
  384. throw err;
  385. }
  386. return {
  387. error: err
  388. };
  389. });
  390. });
  391. },
  392. prefetch(route) {
  393. // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
  394. // License: Apache 2.0
  395. let cn;
  396. if (cn = navigator.connection) {
  397. // Don't prefetch if using 2G or if Save-Data is enabled.
  398. if (cn.saveData || /2g/.test(cn.effectiveType)) return Promise.resolve();
  399. }
  400. return getFilesForRoute(assetPrefix, route).then(output => Promise.all(canPrefetch ? output.scripts.map(script => prefetchViaDom(script, 'script')) : [])).then(() => {
  401. (0, _requestIdleCallback.requestIdleCallback)(() => this.loadRoute(route, true).catch(() => {}));
  402. }).catch( // swallow prefetch errors
  403. () => {});
  404. }
  405. };
  406. }
  407. var _default = createRouteLoader;
  408. exports.default = _default;
  409. /***/ }),
  410. /***/ 2441:
  411. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  412. "use strict";
  413. var _interopRequireWildcard = __webpack_require__(9448);
  414. var _interopRequireDefault = __webpack_require__(2426);
  415. exports.__esModule = true;
  416. exports.useRouter = useRouter;
  417. exports.makePublicRouterInstance = makePublicRouterInstance;
  418. exports.createRouter = exports.withRouter = exports.default = void 0;
  419. var _react = _interopRequireDefault(__webpack_require__(9297));
  420. var _router2 = _interopRequireWildcard(__webpack_require__(1689));
  421. exports.Router = _router2.default;
  422. exports.NextRouter = _router2.NextRouter;
  423. var _routerContext = __webpack_require__(8417);
  424. var _withRouter = _interopRequireDefault(__webpack_require__(3168));
  425. exports.withRouter = _withRouter.default;
  426. /* global window */
  427. const singletonRouter = {
  428. router: null,
  429. // holds the actual router instance
  430. readyCallbacks: [],
  431. ready(cb) {
  432. if (this.router) return cb();
  433. if (false) {}
  434. }
  435. }; // Create public properties and methods of the router in the singletonRouter
  436. const urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'isFallback', 'basePath', 'locale', 'locales', 'defaultLocale', 'isReady', 'isPreview', 'isLocaleDomain'];
  437. const routerEvents = ['routeChangeStart', 'beforeHistoryChange', 'routeChangeComplete', 'routeChangeError', 'hashChangeStart', 'hashChangeComplete'];
  438. const coreMethodFields = ['push', 'replace', 'reload', 'back', 'prefetch', 'beforePopState']; // Events is a static property on the router, the router doesn't have to be initialized to use it
  439. Object.defineProperty(singletonRouter, 'events', {
  440. get() {
  441. return _router2.default.events;
  442. }
  443. });
  444. urlPropertyFields.forEach(field => {
  445. // Here we need to use Object.defineProperty because, we need to return
  446. // the property assigned to the actual router
  447. // The value might get changed as we change routes and this is the
  448. // proper way to access it
  449. Object.defineProperty(singletonRouter, field, {
  450. get() {
  451. const router = getRouter();
  452. return router[field];
  453. }
  454. });
  455. });
  456. coreMethodFields.forEach(field => {
  457. // We don't really know the types here, so we add them later instead
  458. ;
  459. singletonRouter[field] = (...args) => {
  460. const router = getRouter();
  461. return router[field](...args);
  462. };
  463. });
  464. routerEvents.forEach(event => {
  465. singletonRouter.ready(() => {
  466. _router2.default.events.on(event, (...args) => {
  467. const eventField = `on${event.charAt(0).toUpperCase()}${event.substring(1)}`;
  468. const _singletonRouter = singletonRouter;
  469. if (_singletonRouter[eventField]) {
  470. try {
  471. _singletonRouter[eventField](...args);
  472. } catch (err) {
  473. console.error(`Error when running the Router event: ${eventField}`);
  474. console.error(`${err.message}\n${err.stack}`);
  475. }
  476. }
  477. });
  478. });
  479. });
  480. function getRouter() {
  481. if (!singletonRouter.router) {
  482. const message = 'No router instance found.\n' + 'You should only use "next/router" inside the client side of your app.\n';
  483. throw new Error(message);
  484. }
  485. return singletonRouter.router;
  486. } // Export the singletonRouter and this is the public API.
  487. var _default = singletonRouter; // Reexport the withRoute HOC
  488. exports.default = _default;
  489. function useRouter() {
  490. return _react.default.useContext(_routerContext.RouterContext);
  491. } // INTERNAL APIS
  492. // -------------
  493. // (do not use following exports inside the app)
  494. // Create a router and assign it as the singleton instance.
  495. // This is used in client side when we are initilizing the app.
  496. // This should **not** use inside the server.
  497. const createRouter = (...args) => {
  498. singletonRouter.router = new _router2.default(...args);
  499. singletonRouter.readyCallbacks.forEach(cb => cb());
  500. singletonRouter.readyCallbacks = [];
  501. return singletonRouter.router;
  502. }; // This function is used to create the `withRouter` router instance
  503. exports.createRouter = createRouter;
  504. function makePublicRouterInstance(router) {
  505. const _router = router;
  506. const instance = {};
  507. for (const property of urlPropertyFields) {
  508. if (typeof _router[property] === 'object') {
  509. instance[property] = Object.assign(Array.isArray(_router[property]) ? [] : {}, _router[property]); // makes sure query is not stateful
  510. continue;
  511. }
  512. instance[property] = _router[property];
  513. } // Events is a static property on the router, the router doesn't have to be initialized to use it
  514. instance.events = _router2.default.events;
  515. coreMethodFields.forEach(field => {
  516. instance[field] = (...args) => {
  517. return _router[field](...args);
  518. };
  519. });
  520. return instance;
  521. }
  522. /***/ }),
  523. /***/ 5749:
  524. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  525. "use strict";
  526. exports.__esModule = true;
  527. exports.useIntersection = useIntersection;
  528. var _react = __webpack_require__(9297);
  529. var _requestIdleCallback = __webpack_require__(8391);
  530. const hasIntersectionObserver = typeof IntersectionObserver !== 'undefined';
  531. function useIntersection({
  532. rootMargin,
  533. disabled
  534. }) {
  535. const isDisabled = disabled || !hasIntersectionObserver;
  536. const unobserve = (0, _react.useRef)();
  537. const [visible, setVisible] = (0, _react.useState)(false);
  538. const setRef = (0, _react.useCallback)(el => {
  539. if (unobserve.current) {
  540. unobserve.current();
  541. unobserve.current = undefined;
  542. }
  543. if (isDisabled || visible) return;
  544. if (el && el.tagName) {
  545. unobserve.current = observe(el, isVisible => isVisible && setVisible(isVisible), {
  546. rootMargin
  547. });
  548. }
  549. }, [isDisabled, rootMargin, visible]);
  550. (0, _react.useEffect)(() => {
  551. if (!hasIntersectionObserver) {
  552. if (!visible) {
  553. const idleCallback = (0, _requestIdleCallback.requestIdleCallback)(() => setVisible(true));
  554. return () => (0, _requestIdleCallback.cancelIdleCallback)(idleCallback);
  555. }
  556. }
  557. }, [visible]);
  558. return [setRef, visible];
  559. }
  560. function observe(element, callback, options) {
  561. const {
  562. id,
  563. observer,
  564. elements
  565. } = createObserver(options);
  566. elements.set(element, callback);
  567. observer.observe(element);
  568. return function unobserve() {
  569. elements.delete(element);
  570. observer.unobserve(element); // Destroy observer when there's nothing left to watch:
  571. if (elements.size === 0) {
  572. observer.disconnect();
  573. observers.delete(id);
  574. }
  575. };
  576. }
  577. const observers = new Map();
  578. function createObserver(options) {
  579. const id = options.rootMargin || '';
  580. let instance = observers.get(id);
  581. if (instance) {
  582. return instance;
  583. }
  584. const elements = new Map();
  585. const observer = new IntersectionObserver(entries => {
  586. entries.forEach(entry => {
  587. const callback = elements.get(entry.target);
  588. const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
  589. if (callback && isVisible) {
  590. callback(isVisible);
  591. }
  592. });
  593. }, options);
  594. observers.set(id, instance = {
  595. id,
  596. observer,
  597. elements
  598. });
  599. return instance;
  600. }
  601. /***/ }),
  602. /***/ 3168:
  603. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  604. "use strict";
  605. var _interopRequireDefault = __webpack_require__(2426);
  606. exports.__esModule = true;
  607. exports.default = withRouter;
  608. var _react = _interopRequireDefault(__webpack_require__(9297));
  609. var _router = __webpack_require__(2441);
  610. function withRouter(ComposedComponent) {
  611. function WithRouterWrapper(props) {
  612. return /*#__PURE__*/_react.default.createElement(ComposedComponent, Object.assign({
  613. router: (0, _router.useRouter)()
  614. }, props));
  615. }
  616. WithRouterWrapper.getInitialProps = ComposedComponent.getInitialProps // This is needed to allow checking for custom getInitialProps in _app
  617. ;
  618. WithRouterWrapper.origGetInitialProps = ComposedComponent.origGetInitialProps;
  619. if (false) {}
  620. return WithRouterWrapper;
  621. }
  622. /***/ }),
  623. /***/ 5557:
  624. /***/ (function(__unused_webpack_module, exports) {
  625. "use strict";
  626. var __webpack_unused_export__;
  627. __webpack_unused_export__ = true;
  628. exports.D = detectDomainLocale;
  629. function detectDomainLocale(domainItems, hostname, detectedLocale) {
  630. let domainItem;
  631. if (domainItems) {
  632. if (detectedLocale) {
  633. detectedLocale = detectedLocale.toLowerCase();
  634. }
  635. for (const item of domainItems) {
  636. var _item$domain, _item$locales; // remove port if present
  637. const domainHostname = (_item$domain = item.domain) == null ? void 0 : _item$domain.split(':')[0].toLowerCase();
  638. if (hostname === domainHostname || detectedLocale === item.defaultLocale.toLowerCase() || (_item$locales = item.locales) != null && _item$locales.some(locale => locale.toLowerCase() === detectedLocale)) {
  639. domainItem = item;
  640. break;
  641. }
  642. }
  643. }
  644. return domainItem;
  645. }
  646. /***/ }),
  647. /***/ 1253:
  648. /***/ (function(__unused_webpack_module, exports) {
  649. "use strict";
  650. exports.__esModule = true;
  651. exports.normalizeLocalePath = normalizeLocalePath;
  652. function normalizeLocalePath(pathname, locales) {
  653. let detectedLocale; // first item will be empty string from splitting at first char
  654. const pathnameParts = pathname.split('/');
  655. (locales || []).some(locale => {
  656. if (pathnameParts[1].toLowerCase() === locale.toLowerCase()) {
  657. detectedLocale = locale;
  658. pathnameParts.splice(1, 1);
  659. pathname = pathnameParts.join('/') || '/';
  660. return true;
  661. }
  662. return false;
  663. });
  664. return {
  665. pathname,
  666. detectedLocale
  667. };
  668. }
  669. /***/ }),
  670. /***/ 7332:
  671. /***/ (function(__unused_webpack_module, exports) {
  672. "use strict";
  673. exports.__esModule = true;
  674. exports.default = mitt;
  675. /*
  676. MIT License
  677. Copyright (c) Jason Miller (https://jasonformat.com/)
  678. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  679. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  680. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  681. */
  682. // This file is based on https://github.com/developit/mitt/blob/v1.1.3/src/index.js
  683. // It's been edited for the needs of this script
  684. // See the LICENSE at the top of the file
  685. function mitt() {
  686. const all = Object.create(null);
  687. return {
  688. on(type, handler) {
  689. ;
  690. (all[type] || (all[type] = [])).push(handler);
  691. },
  692. off(type, handler) {
  693. if (all[type]) {
  694. all[type].splice(all[type].indexOf(handler) >>> 0, 1);
  695. }
  696. },
  697. emit(type, ...evts) {
  698. // eslint-disable-next-line array-callback-return
  699. ;
  700. (all[type] || []).slice().map(handler => {
  701. handler(...evts);
  702. });
  703. }
  704. };
  705. }
  706. /***/ }),
  707. /***/ 1689:
  708. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  709. "use strict";
  710. exports.__esModule = true;
  711. exports.getDomainLocale = getDomainLocale;
  712. exports.addLocale = addLocale;
  713. exports.delLocale = delLocale;
  714. exports.hasBasePath = hasBasePath;
  715. exports.addBasePath = addBasePath;
  716. exports.delBasePath = delBasePath;
  717. exports.isLocalURL = isLocalURL;
  718. exports.interpolateAs = interpolateAs;
  719. exports.resolveHref = resolveHref;
  720. exports.default = void 0;
  721. var _normalizeTrailingSlash = __webpack_require__(6528);
  722. var _routeLoader = __webpack_require__(7599);
  723. var _denormalizePagePath = __webpack_require__(9320);
  724. var _normalizeLocalePath = __webpack_require__(1253);
  725. var _mitt = _interopRequireDefault(__webpack_require__(7332));
  726. var _utils = __webpack_require__(3937);
  727. var _isDynamic = __webpack_require__(3288);
  728. var _parseRelativeUrl = __webpack_require__(4436);
  729. var _querystring = __webpack_require__(4915);
  730. var _resolveRewrites = _interopRequireDefault(__webpack_require__(4453));
  731. var _routeMatcher = __webpack_require__(7451);
  732. var _routeRegex = __webpack_require__(8193);
  733. function _interopRequireDefault(obj) {
  734. return obj && obj.__esModule ? obj : {
  735. default: obj
  736. };
  737. } // tslint:disable:no-console
  738. let detectDomainLocale;
  739. if (true) {
  740. detectDomainLocale = __webpack_require__(5557)/* .detectDomainLocale */ .D;
  741. }
  742. const basePath = false || '';
  743. function buildCancellationError() {
  744. return Object.assign(new Error('Route Cancelled'), {
  745. cancelled: true
  746. });
  747. }
  748. function addPathPrefix(path, prefix) {
  749. return prefix && path.startsWith('/') ? path === '/' ? (0, _normalizeTrailingSlash.normalizePathTrailingSlash)(prefix) : `${prefix}${pathNoQueryHash(path) === '/' ? path.substring(1) : path}` : path;
  750. }
  751. function getDomainLocale(path, locale, locales, domainLocales) {
  752. if (true) {
  753. locale = locale || (0, _normalizeLocalePath.normalizeLocalePath)(path, locales).detectedLocale;
  754. const detectedDomain = detectDomainLocale(domainLocales, undefined, locale);
  755. if (detectedDomain) {
  756. return `http${detectedDomain.http ? '' : 's'}://${detectedDomain.domain}${basePath || ''}${locale === detectedDomain.defaultLocale ? '' : `/${locale}`}${path}`;
  757. }
  758. return false;
  759. }
  760. return false;
  761. }
  762. function addLocale(path, locale, defaultLocale) {
  763. if (true) {
  764. const pathname = pathNoQueryHash(path);
  765. const pathLower = pathname.toLowerCase();
  766. const localeLower = locale && locale.toLowerCase();
  767. return locale && locale !== defaultLocale && !pathLower.startsWith('/' + localeLower + '/') && pathLower !== '/' + localeLower ? addPathPrefix(path, '/' + locale) : path;
  768. }
  769. return path;
  770. }
  771. function delLocale(path, locale) {
  772. if (true) {
  773. const pathname = pathNoQueryHash(path);
  774. const pathLower = pathname.toLowerCase();
  775. const localeLower = locale && locale.toLowerCase();
  776. return locale && (pathLower.startsWith('/' + localeLower + '/') || pathLower === '/' + localeLower) ? (pathname.length === locale.length + 1 ? '/' : '') + path.substr(locale.length + 1) : path;
  777. }
  778. return path;
  779. }
  780. function pathNoQueryHash(path) {
  781. const queryIndex = path.indexOf('?');
  782. const hashIndex = path.indexOf('#');
  783. if (queryIndex > -1 || hashIndex > -1) {
  784. path = path.substring(0, queryIndex > -1 ? queryIndex : hashIndex);
  785. }
  786. return path;
  787. }
  788. function hasBasePath(path) {
  789. path = pathNoQueryHash(path);
  790. return path === basePath || path.startsWith(basePath + '/');
  791. }
  792. function addBasePath(path) {
  793. // we only add the basepath on relative urls
  794. return addPathPrefix(path, basePath);
  795. }
  796. function delBasePath(path) {
  797. path = path.slice(basePath.length);
  798. if (!path.startsWith('/')) path = `/${path}`;
  799. return path;
  800. }
  801. /**
  802. * Detects whether a given url is routable by the Next.js router (browser only).
  803. */
  804. function isLocalURL(url) {
  805. // prevent a hydration mismatch on href for url with anchor refs
  806. if (url.startsWith('/') || url.startsWith('#')) return true;
  807. try {
  808. // absolute urls can be local if they are on the same origin
  809. const locationOrigin = (0, _utils.getLocationOrigin)();
  810. const resolved = new URL(url, locationOrigin);
  811. return resolved.origin === locationOrigin && hasBasePath(resolved.pathname);
  812. } catch (_) {
  813. return false;
  814. }
  815. }
  816. function interpolateAs(route, asPathname, query) {
  817. let interpolatedRoute = '';
  818. const dynamicRegex = (0, _routeRegex.getRouteRegex)(route);
  819. const dynamicGroups = dynamicRegex.groups;
  820. const dynamicMatches = // Try to match the dynamic route against the asPath
  821. (asPathname !== route ? (0, _routeMatcher.getRouteMatcher)(dynamicRegex)(asPathname) : '') || // Fall back to reading the values from the href
  822. // TODO: should this take priority; also need to change in the router.
  823. query;
  824. interpolatedRoute = route;
  825. const params = Object.keys(dynamicGroups);
  826. if (!params.every(param => {
  827. let value = dynamicMatches[param] || '';
  828. const {
  829. repeat,
  830. optional
  831. } = dynamicGroups[param]; // support single-level catch-all
  832. // TODO: more robust handling for user-error (passing `/`)
  833. let replaced = `[${repeat ? '...' : ''}${param}]`;
  834. if (optional) {
  835. replaced = `${!value ? '/' : ''}[${replaced}]`;
  836. }
  837. if (repeat && !Array.isArray(value)) value = [value];
  838. return (optional || param in dynamicMatches) && ( // Interpolate group into data URL if present
  839. interpolatedRoute = interpolatedRoute.replace(replaced, repeat ? value.map( // these values should be fully encoded instead of just
  840. // path delimiter escaped since they are being inserted
  841. // into the URL and we expect URL encoded segments
  842. // when parsing dynamic route params
  843. segment => encodeURIComponent(segment)).join('/') : encodeURIComponent(value)) || '/');
  844. })) {
  845. interpolatedRoute = ''; // did not satisfy all requirements
  846. // n.b. We ignore this error because we handle warning for this case in
  847. // development in the `<Link>` component directly.
  848. }
  849. return {
  850. params,
  851. result: interpolatedRoute
  852. };
  853. }
  854. function omitParmsFromQuery(query, params) {
  855. const filteredQuery = {};
  856. Object.keys(query).forEach(key => {
  857. if (!params.includes(key)) {
  858. filteredQuery[key] = query[key];
  859. }
  860. });
  861. return filteredQuery;
  862. }
  863. /**
  864. * Resolves a given hyperlink with a certain router state (basePath not included).
  865. * Preserves absolute urls.
  866. */
  867. function resolveHref(currentPath, href, resolveAs) {
  868. // we use a dummy base url for relative urls
  869. let base;
  870. try {
  871. base = new URL(currentPath, 'http://n');
  872. } catch (_) {
  873. // fallback to / for invalid asPath values e.g. //
  874. base = new URL('/', 'http://n');
  875. }
  876. const urlAsString = typeof href === 'string' ? href : (0, _utils.formatWithValidation)(href); // Return because it cannot be routed by the Next.js router
  877. if (!isLocalURL(urlAsString)) {
  878. return resolveAs ? [urlAsString] : urlAsString;
  879. }
  880. try {
  881. const finalUrl = new URL(urlAsString, base);
  882. finalUrl.pathname = (0, _normalizeTrailingSlash.normalizePathTrailingSlash)(finalUrl.pathname);
  883. let interpolatedAs = '';
  884. if ((0, _isDynamic.isDynamicRoute)(finalUrl.pathname) && finalUrl.searchParams && resolveAs) {
  885. const query = (0, _querystring.searchParamsToUrlQuery)(finalUrl.searchParams);
  886. const {
  887. result,
  888. params
  889. } = interpolateAs(finalUrl.pathname, finalUrl.pathname, query);
  890. if (result) {
  891. interpolatedAs = (0, _utils.formatWithValidation)({
  892. pathname: result,
  893. hash: finalUrl.hash,
  894. query: omitParmsFromQuery(query, params)
  895. });
  896. }
  897. } // if the origin didn't change, it means we received a relative href
  898. const resolvedHref = finalUrl.origin === base.origin ? finalUrl.href.slice(finalUrl.origin.length) : finalUrl.href;
  899. return resolveAs ? [resolvedHref, interpolatedAs || resolvedHref] : resolvedHref;
  900. } catch (_) {
  901. return resolveAs ? [urlAsString] : urlAsString;
  902. }
  903. }
  904. function stripOrigin(url) {
  905. const origin = (0, _utils.getLocationOrigin)();
  906. return url.startsWith(origin) ? url.substring(origin.length) : url;
  907. }
  908. function prepareUrlAs(router, url, as) {
  909. // If url and as provided as an object representation,
  910. // we'll format them into the string version here.
  911. let [resolvedHref, resolvedAs] = resolveHref(router.asPath, url, true);
  912. const origin = (0, _utils.getLocationOrigin)();
  913. const hrefHadOrigin = resolvedHref.startsWith(origin);
  914. const asHadOrigin = resolvedAs && resolvedAs.startsWith(origin);
  915. resolvedHref = stripOrigin(resolvedHref);
  916. resolvedAs = resolvedAs ? stripOrigin(resolvedAs) : resolvedAs;
  917. const preparedUrl = hrefHadOrigin ? resolvedHref : addBasePath(resolvedHref);
  918. const preparedAs = as ? stripOrigin(resolveHref(router.asPath, as)) : resolvedAs || resolvedHref;
  919. return {
  920. url: preparedUrl,
  921. as: asHadOrigin ? preparedAs : addBasePath(preparedAs)
  922. };
  923. }
  924. function resolveDynamicRoute(pathname, pages) {
  925. const cleanPathname = (0, _normalizeTrailingSlash.removePathTrailingSlash)((0, _denormalizePagePath.denormalizePagePath)(pathname));
  926. if (cleanPathname === '/404' || cleanPathname === '/_error') {
  927. return pathname;
  928. } // handle resolving href for dynamic routes
  929. if (!pages.includes(cleanPathname)) {
  930. // eslint-disable-next-line array-callback-return
  931. pages.some(page => {
  932. if ((0, _isDynamic.isDynamicRoute)(page) && (0, _routeRegex.getRouteRegex)(page).re.test(cleanPathname)) {
  933. pathname = page;
  934. return true;
  935. }
  936. });
  937. }
  938. return (0, _normalizeTrailingSlash.removePathTrailingSlash)(pathname);
  939. }
  940. const manualScrollRestoration = (/* unused pure expression or super */ null && ( false && 0));
  941. const SSG_DATA_NOT_FOUND = Symbol('SSG_DATA_NOT_FOUND');
  942. function fetchRetry(url, attempts) {
  943. return fetch(url, {
  944. // Cookies are required to be present for Next.js' SSG "Preview Mode".
  945. // Cookies may also be required for `getServerSideProps`.
  946. //
  947. // > `fetch` won’t send cookies, unless you set the credentials init
  948. // > option.
  949. // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
  950. //
  951. // > For maximum browser compatibility when it comes to sending &
  952. // > receiving cookies, always supply the `credentials: 'same-origin'`
  953. // > option instead of relying on the default.
  954. // https://github.com/github/fetch#caveats
  955. credentials: 'same-origin'
  956. }).then(res => {
  957. if (!res.ok) {
  958. if (attempts > 1 && res.status >= 500) {
  959. return fetchRetry(url, attempts - 1);
  960. }
  961. if (res.status === 404) {
  962. return res.json().then(data => {
  963. if (data.notFound) {
  964. return {
  965. notFound: SSG_DATA_NOT_FOUND
  966. };
  967. }
  968. throw new Error(`Failed to load static props`);
  969. });
  970. }
  971. throw new Error(`Failed to load static props`);
  972. }
  973. return res.json();
  974. });
  975. }
  976. function fetchNextData(dataHref, isServerRender) {
  977. return fetchRetry(dataHref, isServerRender ? 3 : 1).catch(err => {
  978. // We should only trigger a server-side transition if this was caused
  979. // on a client-side transition. Otherwise, we'd get into an infinite
  980. // loop.
  981. if (!isServerRender) {
  982. (0, _routeLoader.markAssetError)(err);
  983. }
  984. throw err;
  985. });
  986. }
  987. class Router {
  988. /**
  989. * Map of all components loaded in `Router`
  990. */
  991. // Static Data Cache
  992. // In-flight Server Data Requests, for deduping
  993. constructor(_pathname, _query, _as, {
  994. initialProps,
  995. pageLoader,
  996. App,
  997. wrapApp,
  998. Component,
  999. err,
  1000. subscription,
  1001. isFallback,
  1002. locale,
  1003. locales,
  1004. defaultLocale,
  1005. domainLocales,
  1006. isPreview
  1007. }) {
  1008. this.route = void 0;
  1009. this.pathname = void 0;
  1010. this.query = void 0;
  1011. this.asPath = void 0;
  1012. this.basePath = void 0;
  1013. this.components = void 0;
  1014. this.sdc = {};
  1015. this.sdr = {};
  1016. this.sub = void 0;
  1017. this.clc = void 0;
  1018. this.pageLoader = void 0;
  1019. this._bps = void 0;
  1020. this.events = void 0;
  1021. this._wrapApp = void 0;
  1022. this.isSsr = void 0;
  1023. this.isFallback = void 0;
  1024. this._inFlightRoute = void 0;
  1025. this._shallow = void 0;
  1026. this.locale = void 0;
  1027. this.locales = void 0;
  1028. this.defaultLocale = void 0;
  1029. this.domainLocales = void 0;
  1030. this.isReady = void 0;
  1031. this.isPreview = void 0;
  1032. this.isLocaleDomain = void 0;
  1033. this._idx = 0;
  1034. this.onPopState = e => {
  1035. const state = e.state;
  1036. if (!state) {
  1037. // We get state as undefined for two reasons.
  1038. // 1. With older safari (< 8) and older chrome (< 34)
  1039. // 2. When the URL changed with #
  1040. //
  1041. // In the both cases, we don't need to proceed and change the route.
  1042. // (as it's already changed)
  1043. // But we can simply replace the state with the new changes.
  1044. // Actually, for (1) we don't need to nothing. But it's hard to detect that event.
  1045. // So, doing the following for (1) does no harm.
  1046. const {
  1047. pathname,
  1048. query
  1049. } = this;
  1050. this.changeState('replaceState', (0, _utils.formatWithValidation)({
  1051. pathname: addBasePath(pathname),
  1052. query
  1053. }), (0, _utils.getURL)());
  1054. return;
  1055. }
  1056. if (!state.__N) {
  1057. return;
  1058. }
  1059. let forcedScroll;
  1060. const {
  1061. url,
  1062. as,
  1063. options,
  1064. idx
  1065. } = state;
  1066. if (false) {}
  1067. this._idx = idx;
  1068. const {
  1069. pathname
  1070. } = (0, _parseRelativeUrl.parseRelativeUrl)(url); // Make sure we don't re-render on initial load,
  1071. // can be caused by navigating back from an external site
  1072. if (this.isSsr && as === this.asPath && pathname === this.pathname) {
  1073. return;
  1074. } // If the downstream application returns falsy, return.
  1075. // They will then be responsible for handling the event.
  1076. if (this._bps && !this._bps(state)) {
  1077. return;
  1078. }
  1079. this.change('replaceState', url, as, Object.assign({}, options, {
  1080. shallow: options.shallow && this._shallow,
  1081. locale: options.locale || this.defaultLocale
  1082. }), forcedScroll);
  1083. }; // represents the current component key
  1084. this.route = (0, _normalizeTrailingSlash.removePathTrailingSlash)(_pathname); // set up the component cache (by route keys)
  1085. this.components = {}; // We should not keep the cache, if there's an error
  1086. // Otherwise, this cause issues when when going back and
  1087. // come again to the errored page.
  1088. if (_pathname !== '/_error') {
  1089. this.components[this.route] = {
  1090. Component,
  1091. initial: true,
  1092. props: initialProps,
  1093. err,
  1094. __N_SSG: initialProps && initialProps.__N_SSG,
  1095. __N_SSP: initialProps && initialProps.__N_SSP
  1096. };
  1097. }
  1098. this.components['/_app'] = {
  1099. Component: App,
  1100. styleSheets: [
  1101. /* /_app does not need its stylesheets managed */
  1102. ]
  1103. }; // Backwards compat for Router.router.events
  1104. // TODO: Should be remove the following major version as it was never documented
  1105. this.events = Router.events;
  1106. this.pageLoader = pageLoader;
  1107. this.pathname = _pathname;
  1108. this.query = _query; // if auto prerendered and dynamic route wait to update asPath
  1109. // until after mount to prevent hydration mismatch
  1110. const autoExportDynamic = (0, _isDynamic.isDynamicRoute)(_pathname) && self.__NEXT_DATA__.autoExport;
  1111. this.asPath = autoExportDynamic ? _pathname : _as;
  1112. this.basePath = basePath;
  1113. this.sub = subscription;
  1114. this.clc = null;
  1115. this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
  1116. // back from external site
  1117. this.isSsr = true;
  1118. this.isFallback = isFallback;
  1119. this.isReady = !!(self.__NEXT_DATA__.gssp || self.__NEXT_DATA__.gip || !autoExportDynamic && !self.location.search && !false);
  1120. this.isPreview = !!isPreview;
  1121. this.isLocaleDomain = false;
  1122. if (true) {
  1123. this.locale = locale;
  1124. this.locales = locales;
  1125. this.defaultLocale = defaultLocale;
  1126. this.domainLocales = domainLocales;
  1127. this.isLocaleDomain = !!detectDomainLocale(domainLocales, self.location.hostname);
  1128. }
  1129. if (false) {}
  1130. }
  1131. reload() {
  1132. window.location.reload();
  1133. }
  1134. /**
  1135. * Go back in history
  1136. */
  1137. back() {
  1138. window.history.back();
  1139. }
  1140. /**
  1141. * Performs a `pushState` with arguments
  1142. * @param url of the route
  1143. * @param as masks `url` for the browser
  1144. * @param options object you can define `shallow` and other options
  1145. */
  1146. push(url, as, options = {}) {
  1147. if (false) {}
  1148. ;
  1149. ({
  1150. url,
  1151. as
  1152. } = prepareUrlAs(this, url, as));
  1153. return this.change('pushState', url, as, options);
  1154. }
  1155. /**
  1156. * Performs a `replaceState` with arguments
  1157. * @param url of the route
  1158. * @param as masks `url` for the browser
  1159. * @param options object you can define `shallow` and other options
  1160. */
  1161. replace(url, as, options = {}) {
  1162. ;
  1163. ({
  1164. url,
  1165. as
  1166. } = prepareUrlAs(this, url, as));
  1167. return this.change('replaceState', url, as, options);
  1168. }
  1169. async change(method, url, as, options, forcedScroll) {
  1170. var _options$scroll;
  1171. if (!isLocalURL(url)) {
  1172. window.location.href = url;
  1173. return false;
  1174. }
  1175. const shouldResolveHref = url === as || options._h; // for static pages with query params in the URL we delay
  1176. // marking the router ready until after the query is updated
  1177. if (options._h) {
  1178. this.isReady = true;
  1179. } // Default to scroll reset behavior unless explicitly specified to be
  1180. // `false`! This makes the behavior between using `Router#push` and a
  1181. // `<Link />` consistent.
  1182. options.scroll = !!((_options$scroll = options.scroll) != null ? _options$scroll : true);
  1183. let localeChange = options.locale !== this.locale;
  1184. if (true) {
  1185. this.locale = options.locale === false ? this.defaultLocale : options.locale || this.locale;
  1186. if (typeof options.locale === 'undefined') {
  1187. options.locale = this.locale;
  1188. }
  1189. const parsedAs = (0, _parseRelativeUrl.parseRelativeUrl)(hasBasePath(as) ? delBasePath(as) : as);
  1190. const localePathResult = (0, _normalizeLocalePath.normalizeLocalePath)(parsedAs.pathname, this.locales);
  1191. if (localePathResult.detectedLocale) {
  1192. this.locale = localePathResult.detectedLocale;
  1193. parsedAs.pathname = addBasePath(parsedAs.pathname);
  1194. as = (0, _utils.formatWithValidation)(parsedAs);
  1195. url = addBasePath((0, _normalizeLocalePath.normalizeLocalePath)(hasBasePath(url) ? delBasePath(url) : url, this.locales).pathname);
  1196. }
  1197. let didNavigate = false; // we need to wrap this in the env check again since regenerator runtime
  1198. // moves this on its own due to the return
  1199. if (true) {
  1200. var _this$locales; // if the locale isn't configured hard navigate to show 404 page
  1201. if (!((_this$locales = this.locales) != null && _this$locales.includes(this.locale))) {
  1202. parsedAs.pathname = addLocale(parsedAs.pathname, this.locale);
  1203. window.location.href = (0, _utils.formatWithValidation)(parsedAs); // this was previously a return but was removed in favor
  1204. // of better dead code elimination with regenerator runtime
  1205. didNavigate = true;
  1206. }
  1207. }
  1208. const detectedDomain = detectDomainLocale(this.domainLocales, undefined, this.locale); // we need to wrap this in the env check again since regenerator runtime
  1209. // moves this on its own due to the return
  1210. if (true) {
  1211. // if we are navigating to a domain locale ensure we redirect to the
  1212. // correct domain
  1213. if (!didNavigate && detectedDomain && this.isLocaleDomain && self.location.hostname !== detectedDomain.domain) {
  1214. const asNoBasePath = delBasePath(as);
  1215. window.location.href = `http${detectedDomain.http ? '' : 's'}://${detectedDomain.domain}${addBasePath(`${this.locale === detectedDomain.defaultLocale ? '' : `/${this.locale}`}${asNoBasePath === '/' ? '' : asNoBasePath}` || '/')}`; // this was previously a return but was removed in favor
  1216. // of better dead code elimination with regenerator runtime
  1217. didNavigate = true;
  1218. }
  1219. }
  1220. if (didNavigate) {
  1221. return new Promise(() => {});
  1222. }
  1223. }
  1224. if (!options._h) {
  1225. this.isSsr = false;
  1226. } // marking route changes as a navigation start entry
  1227. if (_utils.ST) {
  1228. performance.mark('routeChange');
  1229. }
  1230. const {
  1231. shallow = false
  1232. } = options;
  1233. const routeProps = {
  1234. shallow
  1235. };
  1236. if (this._inFlightRoute) {
  1237. this.abortComponentLoad(this._inFlightRoute, routeProps);
  1238. }
  1239. as = addBasePath(addLocale(hasBasePath(as) ? delBasePath(as) : as, options.locale, this.defaultLocale));
  1240. const cleanedAs = delLocale(hasBasePath(as) ? delBasePath(as) : as, this.locale);
  1241. this._inFlightRoute = as; // If the url change is only related to a hash change
  1242. // We should not proceed. We should only change the state.
  1243. // WARNING: `_h` is an internal option for handing Next.js client-side
  1244. // hydration. Your app should _never_ use this property. It may change at
  1245. // any time without notice.
  1246. if (!options._h && this.onlyAHashChange(cleanedAs)) {
  1247. this.asPath = cleanedAs;
  1248. Router.events.emit('hashChangeStart', as, routeProps); // TODO: do we need the resolved href when only a hash change?
  1249. this.changeState(method, url, as, options);
  1250. this.scrollToHash(cleanedAs);
  1251. this.notify(this.components[this.route], null);
  1252. Router.events.emit('hashChangeComplete', as, routeProps);
  1253. return true;
  1254. }
  1255. let parsed = (0, _parseRelativeUrl.parseRelativeUrl)(url);
  1256. let {
  1257. pathname,
  1258. query
  1259. } = parsed; // The build manifest needs to be loaded before auto-static dynamic pages
  1260. // get their query parameters to allow ensuring they can be parsed properly
  1261. // when rewritten to
  1262. let pages, rewrites;
  1263. try {
  1264. pages = await this.pageLoader.getPageList();
  1265. ({
  1266. __rewrites: rewrites
  1267. } = await (0, _routeLoader.getClientBuildManifest)());
  1268. } catch (err) {
  1269. // If we fail to resolve the page list or client-build manifest, we must
  1270. // do a server-side transition:
  1271. window.location.href = as;
  1272. return false;
  1273. } // If asked to change the current URL we should reload the current page
  1274. // (not location.reload() but reload getInitialProps and other Next.js stuffs)
  1275. // We also need to set the method = replaceState always
  1276. // as this should not go into the history (That's how browsers work)
  1277. // We should compare the new asPath to the current asPath, not the url
  1278. if (!this.urlIsNew(cleanedAs) && !localeChange) {
  1279. method = 'replaceState';
  1280. } // we need to resolve the as value using rewrites for dynamic SSG
  1281. // pages to allow building the data URL correctly
  1282. let resolvedAs = as; // url and as should always be prefixed with basePath by this
  1283. // point by either next/link or router.push/replace so strip the
  1284. // basePath from the pathname to match the pages dir 1-to-1
  1285. pathname = pathname ? (0, _normalizeTrailingSlash.removePathTrailingSlash)(delBasePath(pathname)) : pathname;
  1286. if (shouldResolveHref && pathname !== '/_error') {
  1287. if (false) {} else {
  1288. parsed.pathname = resolveDynamicRoute(pathname, pages);
  1289. if (parsed.pathname !== pathname) {
  1290. pathname = parsed.pathname;
  1291. url = (0, _utils.formatWithValidation)(parsed);
  1292. }
  1293. }
  1294. }
  1295. const route = (0, _normalizeTrailingSlash.removePathTrailingSlash)(pathname);
  1296. if (!isLocalURL(as)) {
  1297. if (false) {}
  1298. window.location.href = as;
  1299. return false;
  1300. }
  1301. resolvedAs = delLocale(delBasePath(resolvedAs), this.locale);
  1302. if ((0, _isDynamic.isDynamicRoute)(route)) {
  1303. const parsedAs = (0, _parseRelativeUrl.parseRelativeUrl)(resolvedAs);
  1304. const asPathname = parsedAs.pathname;
  1305. const routeRegex = (0, _routeRegex.getRouteRegex)(route);
  1306. const routeMatch = (0, _routeMatcher.getRouteMatcher)(routeRegex)(asPathname);
  1307. const shouldInterpolate = route === asPathname;
  1308. const interpolatedAs = shouldInterpolate ? interpolateAs(route, asPathname, query) : {};
  1309. if (!routeMatch || shouldInterpolate && !interpolatedAs.result) {
  1310. const missingParams = Object.keys(routeRegex.groups).filter(param => !query[param]);
  1311. if (missingParams.length > 0) {
  1312. if (false) {}
  1313. 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'}`);
  1314. }
  1315. } else if (shouldInterpolate) {
  1316. as = (0, _utils.formatWithValidation)(Object.assign({}, parsedAs, {
  1317. pathname: interpolatedAs.result,
  1318. query: omitParmsFromQuery(query, interpolatedAs.params)
  1319. }));
  1320. } else {
  1321. // Merge params into `query`, overwriting any specified in search
  1322. Object.assign(query, routeMatch);
  1323. }
  1324. }
  1325. Router.events.emit('routeChangeStart', as, routeProps);
  1326. try {
  1327. var _self$__NEXT_DATA__$p, _self$__NEXT_DATA__$p2;
  1328. let routeInfo = await this.getRouteInfo(route, pathname, query, as, resolvedAs, routeProps);
  1329. let {
  1330. error,
  1331. props,
  1332. __N_SSG,
  1333. __N_SSP
  1334. } = routeInfo; // handle redirect on client-transition
  1335. if ((__N_SSG || __N_SSP) && props) {
  1336. if (props.pageProps && props.pageProps.__N_REDIRECT) {
  1337. const destination = props.pageProps.__N_REDIRECT; // check if destination is internal (resolves to a page) and attempt
  1338. // client-navigation if it is falling back to hard navigation if
  1339. // it's not
  1340. if (destination.startsWith('/')) {
  1341. const parsedHref = (0, _parseRelativeUrl.parseRelativeUrl)(destination);
  1342. parsedHref.pathname = resolveDynamicRoute(parsedHref.pathname, pages);
  1343. if (pages.includes(parsedHref.pathname)) {
  1344. const {
  1345. url: newUrl,
  1346. as: newAs
  1347. } = prepareUrlAs(this, destination, destination);
  1348. return this.change(method, newUrl, newAs, options);
  1349. }
  1350. }
  1351. window.location.href = destination;
  1352. return new Promise(() => {});
  1353. }
  1354. this.isPreview = !!props.__N_PREVIEW; // handle SSG data 404
  1355. if (props.notFound === SSG_DATA_NOT_FOUND) {
  1356. let notFoundRoute;
  1357. try {
  1358. await this.fetchComponent('/404');
  1359. notFoundRoute = '/404';
  1360. } catch (_) {
  1361. notFoundRoute = '/_error';
  1362. }
  1363. routeInfo = await this.getRouteInfo(notFoundRoute, notFoundRoute, query, as, resolvedAs, {
  1364. shallow: false
  1365. });
  1366. }
  1367. }
  1368. Router.events.emit('beforeHistoryChange', as, routeProps);
  1369. this.changeState(method, url, as, options);
  1370. if (false) {} // shallow routing is only allowed for same page URL changes.
  1371. const isValidShallowRoute = options.shallow && this.route === route;
  1372. if (options._h && pathname === '/_error' && ((_self$__NEXT_DATA__$p = self.__NEXT_DATA__.props) == null ? void 0 : (_self$__NEXT_DATA__$p2 = _self$__NEXT_DATA__$p.pageProps) == null ? void 0 : _self$__NEXT_DATA__$p2.statusCode) === 500 && props != null && props.pageProps) {
  1373. // ensure statusCode is still correct for static 500 page
  1374. // when updating query information
  1375. props.pageProps.statusCode = 500;
  1376. }
  1377. await this.set(route, pathname, query, cleanedAs, routeInfo, forcedScroll || (isValidShallowRoute || !options.scroll ? null : {
  1378. x: 0,
  1379. y: 0
  1380. })).catch(e => {
  1381. if (e.cancelled) error = error || e;else throw e;
  1382. });
  1383. if (error) {
  1384. Router.events.emit('routeChangeError', error, cleanedAs, routeProps);
  1385. throw error;
  1386. }
  1387. if (true) {
  1388. if (this.locale) {
  1389. document.documentElement.lang = this.locale;
  1390. }
  1391. }
  1392. Router.events.emit('routeChangeComplete', as, routeProps);
  1393. return true;
  1394. } catch (err) {
  1395. if (err.cancelled) {
  1396. return false;
  1397. }
  1398. throw err;
  1399. }
  1400. }
  1401. changeState(method, url, as, options = {}) {
  1402. if (false) {}
  1403. if (method !== 'pushState' || (0, _utils.getURL)() !== as) {
  1404. this._shallow = options.shallow;
  1405. window.history[method]({
  1406. url,
  1407. as,
  1408. options,
  1409. __N: true,
  1410. idx: this._idx = method !== 'pushState' ? this._idx : this._idx + 1
  1411. }, // Most browsers currently ignores this parameter, although they may use it in the future.
  1412. // Passing the empty string here should be safe against future changes to the method.
  1413. // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
  1414. '', as);
  1415. }
  1416. }
  1417. async handleRouteInfoError(err, pathname, query, as, routeProps, loadErrorFail) {
  1418. if (err.cancelled) {
  1419. // bubble up cancellation errors
  1420. throw err;
  1421. }
  1422. if ((0, _routeLoader.isAssetError)(err) || loadErrorFail) {
  1423. Router.events.emit('routeChangeError', err, as, routeProps); // If we can't load the page it could be one of following reasons
  1424. // 1. Page doesn't exists
  1425. // 2. Page does exist in a different zone
  1426. // 3. Internal error while loading the page
  1427. // So, doing a hard reload is the proper way to deal with this.
  1428. window.location.href = as; // Changing the URL doesn't block executing the current code path.
  1429. // So let's throw a cancellation error stop the routing logic.
  1430. throw buildCancellationError();
  1431. }
  1432. try {
  1433. let Component;
  1434. let styleSheets;
  1435. let props;
  1436. if (typeof Component === 'undefined' || typeof styleSheets === 'undefined') {
  1437. ;
  1438. ({
  1439. page: Component,
  1440. styleSheets
  1441. } = await this.fetchComponent('/_error'));
  1442. }
  1443. const routeInfo = {
  1444. props,
  1445. Component,
  1446. styleSheets,
  1447. err,
  1448. error: err
  1449. };
  1450. if (!routeInfo.props) {
  1451. try {
  1452. routeInfo.props = await this.getInitialProps(Component, {
  1453. err,
  1454. pathname,
  1455. query
  1456. });
  1457. } catch (gipErr) {
  1458. console.error('Error in error page `getInitialProps`: ', gipErr);
  1459. routeInfo.props = {};
  1460. }
  1461. }
  1462. return routeInfo;
  1463. } catch (routeInfoErr) {
  1464. return this.handleRouteInfoError(routeInfoErr, pathname, query, as, routeProps, true);
  1465. }
  1466. }
  1467. async getRouteInfo(route, pathname, query, as, resolvedAs, routeProps) {
  1468. try {
  1469. const existingRouteInfo = this.components[route];
  1470. if (routeProps.shallow && existingRouteInfo && this.route === route) {
  1471. return existingRouteInfo;
  1472. }
  1473. const cachedRouteInfo = existingRouteInfo && 'initial' in existingRouteInfo ? undefined : existingRouteInfo;
  1474. const routeInfo = cachedRouteInfo ? cachedRouteInfo : await this.fetchComponent(route).then(res => ({
  1475. Component: res.page,
  1476. styleSheets: res.styleSheets,
  1477. __N_SSG: res.mod.__N_SSG,
  1478. __N_SSP: res.mod.__N_SSP
  1479. }));
  1480. const {
  1481. Component,
  1482. __N_SSG,
  1483. __N_SSP
  1484. } = routeInfo;
  1485. if (false) {}
  1486. let dataHref;
  1487. if (__N_SSG || __N_SSP) {
  1488. dataHref = this.pageLoader.getDataHref((0, _utils.formatWithValidation)({
  1489. pathname,
  1490. query
  1491. }), resolvedAs, __N_SSG, this.locale);
  1492. }
  1493. const props = await this._getData(() => __N_SSG ? this._getStaticData(dataHref) : __N_SSP ? this._getServerData(dataHref) : this.getInitialProps(Component, // we provide AppTree later so this needs to be `any`
  1494. {
  1495. pathname,
  1496. query,
  1497. asPath: as,
  1498. locale: this.locale,
  1499. locales: this.locales,
  1500. defaultLocale: this.defaultLocale
  1501. }));
  1502. routeInfo.props = props;
  1503. this.components[route] = routeInfo;
  1504. return routeInfo;
  1505. } catch (err) {
  1506. return this.handleRouteInfoError(err, pathname, query, as, routeProps);
  1507. }
  1508. }
  1509. set(route, pathname, query, as, data, resetScroll) {
  1510. this.isFallback = false;
  1511. this.route = route;
  1512. this.pathname = pathname;
  1513. this.query = query;
  1514. this.asPath = as;
  1515. return this.notify(data, resetScroll);
  1516. }
  1517. /**
  1518. * Callback to execute before replacing router state
  1519. * @param cb callback to be executed
  1520. */
  1521. beforePopState(cb) {
  1522. this._bps = cb;
  1523. }
  1524. onlyAHashChange(as) {
  1525. if (!this.asPath) return false;
  1526. const [oldUrlNoHash, oldHash] = this.asPath.split('#');
  1527. const [newUrlNoHash, newHash] = as.split('#'); // Makes sure we scroll to the provided hash if the url/hash are the same
  1528. if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {
  1529. return true;
  1530. } // If the urls are change, there's more than a hash change
  1531. if (oldUrlNoHash !== newUrlNoHash) {
  1532. return false;
  1533. } // If the hash has changed, then it's a hash only change.
  1534. // This check is necessary to handle both the enter and
  1535. // leave hash === '' cases. The identity case falls through
  1536. // and is treated as a next reload.
  1537. return oldHash !== newHash;
  1538. }
  1539. scrollToHash(as) {
  1540. const [, hash] = as.split('#'); // Scroll to top if the hash is just `#` with no value or `#top`
  1541. // To mirror browsers
  1542. if (hash === '' || hash === 'top') {
  1543. window.scrollTo(0, 0);
  1544. return;
  1545. } // First we check if the element by id is found
  1546. const idEl = document.getElementById(hash);
  1547. if (idEl) {
  1548. idEl.scrollIntoView();
  1549. return;
  1550. } // If there's no element with the id, we check the `name` property
  1551. // To mirror browsers
  1552. const nameEl = document.getElementsByName(hash)[0];
  1553. if (nameEl) {
  1554. nameEl.scrollIntoView();
  1555. }
  1556. }
  1557. urlIsNew(asPath) {
  1558. return this.asPath !== asPath;
  1559. }
  1560. /**
  1561. * Prefetch page code, you may wait for the data during page rendering.
  1562. * This feature only works in production!
  1563. * @param url the href of prefetched page
  1564. * @param asPath the as path of the prefetched page
  1565. */
  1566. async prefetch(url, asPath = url, options = {}) {
  1567. let parsed = (0, _parseRelativeUrl.parseRelativeUrl)(url);
  1568. let {
  1569. pathname
  1570. } = parsed;
  1571. if (true) {
  1572. if (options.locale === false) {
  1573. pathname = (0, _normalizeLocalePath.normalizeLocalePath)(pathname, this.locales).pathname;
  1574. parsed.pathname = pathname;
  1575. url = (0, _utils.formatWithValidation)(parsed);
  1576. let parsedAs = (0, _parseRelativeUrl.parseRelativeUrl)(asPath);
  1577. const localePathResult = (0, _normalizeLocalePath.normalizeLocalePath)(parsedAs.pathname, this.locales);
  1578. parsedAs.pathname = localePathResult.pathname;
  1579. options.locale = localePathResult.detectedLocale || this.defaultLocale;
  1580. asPath = (0, _utils.formatWithValidation)(parsedAs);
  1581. }
  1582. }
  1583. const pages = await this.pageLoader.getPageList();
  1584. let resolvedAs = asPath;
  1585. if (false) {} else {
  1586. parsed.pathname = resolveDynamicRoute(parsed.pathname, pages);
  1587. if (parsed.pathname !== pathname) {
  1588. pathname = parsed.pathname;
  1589. url = (0, _utils.formatWithValidation)(parsed);
  1590. }
  1591. }
  1592. const route = (0, _normalizeTrailingSlash.removePathTrailingSlash)(pathname); // Prefetch is not supported in development mode because it would trigger on-demand-entries
  1593. if (false) {}
  1594. await Promise.all([this.pageLoader._isSsg(route).then(isSsg => {
  1595. return isSsg ? this._getStaticData(this.pageLoader.getDataHref(url, resolvedAs, true, typeof options.locale !== 'undefined' ? options.locale : this.locale)) : false;
  1596. }), this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route)]);
  1597. }
  1598. async fetchComponent(route) {
  1599. let cancelled = false;
  1600. const cancel = this.clc = () => {
  1601. cancelled = true;
  1602. };
  1603. const componentResult = await this.pageLoader.loadPage(route);
  1604. if (cancelled) {
  1605. const error = new Error(`Abort fetching component for route: "${route}"`);
  1606. error.cancelled = true;
  1607. throw error;
  1608. }
  1609. if (cancel === this.clc) {
  1610. this.clc = null;
  1611. }
  1612. return componentResult;
  1613. }
  1614. _getData(fn) {
  1615. let cancelled = false;
  1616. const cancel = () => {
  1617. cancelled = true;
  1618. };
  1619. this.clc = cancel;
  1620. return fn().then(data => {
  1621. if (cancel === this.clc) {
  1622. this.clc = null;
  1623. }
  1624. if (cancelled) {
  1625. const err = new Error('Loading initial props cancelled');
  1626. err.cancelled = true;
  1627. throw err;
  1628. }
  1629. return data;
  1630. });
  1631. }
  1632. _getStaticData(dataHref) {
  1633. const {
  1634. href: cacheKey
  1635. } = new URL(dataHref, window.location.href);
  1636. if ( true && !this.isPreview && this.sdc[cacheKey]) {
  1637. return Promise.resolve(this.sdc[cacheKey]);
  1638. }
  1639. return fetchNextData(dataHref, this.isSsr).then(data => {
  1640. this.sdc[cacheKey] = data;
  1641. return data;
  1642. });
  1643. }
  1644. _getServerData(dataHref) {
  1645. const {
  1646. href: resourceKey
  1647. } = new URL(dataHref, window.location.href);
  1648. if (this.sdr[resourceKey]) {
  1649. return this.sdr[resourceKey];
  1650. }
  1651. return this.sdr[resourceKey] = fetchNextData(dataHref, this.isSsr).then(data => {
  1652. delete this.sdr[resourceKey];
  1653. return data;
  1654. }).catch(err => {
  1655. delete this.sdr[resourceKey];
  1656. throw err;
  1657. });
  1658. }
  1659. getInitialProps(Component, ctx) {
  1660. const {
  1661. Component: App
  1662. } = this.components['/_app'];
  1663. const AppTree = this._wrapApp(App);
  1664. ctx.AppTree = AppTree;
  1665. return (0, _utils.loadGetInitialProps)(App, {
  1666. AppTree,
  1667. Component,
  1668. router: this,
  1669. ctx
  1670. });
  1671. }
  1672. abortComponentLoad(as, routeProps) {
  1673. if (this.clc) {
  1674. Router.events.emit('routeChangeError', buildCancellationError(), as, routeProps);
  1675. this.clc();
  1676. this.clc = null;
  1677. }
  1678. }
  1679. notify(data, resetScroll) {
  1680. return this.sub(data, this.components['/_app'].Component, resetScroll);
  1681. }
  1682. }
  1683. exports.default = Router;
  1684. Router.events = (0, _mitt.default)();
  1685. /***/ }),
  1686. /***/ 7687:
  1687. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1688. "use strict";
  1689. exports.__esModule = true;
  1690. exports.formatUrl = formatUrl;
  1691. var querystring = _interopRequireWildcard(__webpack_require__(4915));
  1692. function _getRequireWildcardCache() {
  1693. if (typeof WeakMap !== "function") return null;
  1694. var cache = new WeakMap();
  1695. _getRequireWildcardCache = function () {
  1696. return cache;
  1697. };
  1698. return cache;
  1699. }
  1700. function _interopRequireWildcard(obj) {
  1701. if (obj && obj.__esModule) {
  1702. return obj;
  1703. }
  1704. if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
  1705. return {
  1706. default: obj
  1707. };
  1708. }
  1709. var cache = _getRequireWildcardCache();
  1710. if (cache && cache.has(obj)) {
  1711. return cache.get(obj);
  1712. }
  1713. var newObj = {};
  1714. var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
  1715. for (var key in obj) {
  1716. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1717. var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
  1718. if (desc && (desc.get || desc.set)) {
  1719. Object.defineProperty(newObj, key, desc);
  1720. } else {
  1721. newObj[key] = obj[key];
  1722. }
  1723. }
  1724. }
  1725. newObj.default = obj;
  1726. if (cache) {
  1727. cache.set(obj, newObj);
  1728. }
  1729. return newObj;
  1730. } // Format function modified from nodejs
  1731. // Copyright Joyent, Inc. and other Node contributors.
  1732. //
  1733. // Permission is hereby granted, free of charge, to any person obtaining a
  1734. // copy of this software and associated documentation files (the
  1735. // "Software"), to deal in the Software without restriction, including
  1736. // without limitation the rights to use, copy, modify, merge, publish,
  1737. // distribute, sublicense, and/or sell copies of the Software, and to permit
  1738. // persons to whom the Software is furnished to do so, subject to the
  1739. // following conditions:
  1740. //
  1741. // The above copyright notice and this permission notice shall be included
  1742. // in all copies or substantial portions of the Software.
  1743. //
  1744. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  1745. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  1746. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  1747. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  1748. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  1749. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  1750. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  1751. const slashedProtocols = /https?|ftp|gopher|file/;
  1752. function formatUrl(urlObj) {
  1753. let {
  1754. auth,
  1755. hostname
  1756. } = urlObj;
  1757. let protocol = urlObj.protocol || '';
  1758. let pathname = urlObj.pathname || '';
  1759. let hash = urlObj.hash || '';
  1760. let query = urlObj.query || '';
  1761. let host = false;
  1762. auth = auth ? encodeURIComponent(auth).replace(/%3A/i, ':') + '@' : '';
  1763. if (urlObj.host) {
  1764. host = auth + urlObj.host;
  1765. } else if (hostname) {
  1766. host = auth + (~hostname.indexOf(':') ? `[${hostname}]` : hostname);
  1767. if (urlObj.port) {
  1768. host += ':' + urlObj.port;
  1769. }
  1770. }
  1771. if (query && typeof query === 'object') {
  1772. query = String(querystring.urlQueryToSearchParams(query));
  1773. }
  1774. let search = urlObj.search || query && `?${query}` || '';
  1775. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  1776. if (urlObj.slashes || (!protocol || slashedProtocols.test(protocol)) && host !== false) {
  1777. host = '//' + (host || '');
  1778. if (pathname && pathname[0] !== '/') pathname = '/' + pathname;
  1779. } else if (!host) {
  1780. host = '';
  1781. }
  1782. if (hash && hash[0] !== '#') hash = '#' + hash;
  1783. if (search && search[0] !== '?') search = '?' + search;
  1784. pathname = pathname.replace(/[?#]/g, encodeURIComponent);
  1785. search = search.replace('#', '%23');
  1786. return `${protocol}${host}${pathname}${search}${hash}`;
  1787. }
  1788. /***/ }),
  1789. /***/ 3288:
  1790. /***/ (function(__unused_webpack_module, exports) {
  1791. "use strict";
  1792. exports.__esModule = true;
  1793. exports.isDynamicRoute = isDynamicRoute; // Identify /[param]/ in route string
  1794. const TEST_ROUTE = /\/\[[^/]+?\](?=\/|$)/;
  1795. function isDynamicRoute(route) {
  1796. return TEST_ROUTE.test(route);
  1797. }
  1798. /***/ }),
  1799. /***/ 4436:
  1800. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1801. "use strict";
  1802. exports.__esModule = true;
  1803. exports.parseRelativeUrl = parseRelativeUrl;
  1804. var _utils = __webpack_require__(3937);
  1805. var _querystring = __webpack_require__(4915);
  1806. /**
  1807. * Parses path-relative urls (e.g. `/hello/world?foo=bar`). If url isn't path-relative
  1808. * (e.g. `./hello`) then at least base must be.
  1809. * Absolute urls are rejected with one exception, in the browser, absolute urls that are on
  1810. * the current origin will be parsed as relative
  1811. */
  1812. function parseRelativeUrl(url, base) {
  1813. const globalBase = new URL( true ? 'http://n' : 0);
  1814. const resolvedBase = base ? new URL(base, globalBase) : globalBase;
  1815. const {
  1816. pathname,
  1817. searchParams,
  1818. search,
  1819. hash,
  1820. href,
  1821. origin
  1822. } = new URL(url, resolvedBase);
  1823. if (origin !== globalBase.origin) {
  1824. throw new Error(`invariant: invalid relative URL, router received ${url}`);
  1825. }
  1826. return {
  1827. pathname,
  1828. query: (0, _querystring.searchParamsToUrlQuery)(searchParams),
  1829. search,
  1830. hash,
  1831. href: href.slice(globalBase.origin.length)
  1832. };
  1833. }
  1834. /***/ }),
  1835. /***/ 4915:
  1836. /***/ (function(__unused_webpack_module, exports) {
  1837. "use strict";
  1838. exports.__esModule = true;
  1839. exports.searchParamsToUrlQuery = searchParamsToUrlQuery;
  1840. exports.urlQueryToSearchParams = urlQueryToSearchParams;
  1841. exports.assign = assign;
  1842. function searchParamsToUrlQuery(searchParams) {
  1843. const query = {};
  1844. searchParams.forEach((value, key) => {
  1845. if (typeof query[key] === 'undefined') {
  1846. query[key] = value;
  1847. } else if (Array.isArray(query[key])) {
  1848. ;
  1849. query[key].push(value);
  1850. } else {
  1851. query[key] = [query[key], value];
  1852. }
  1853. });
  1854. return query;
  1855. }
  1856. function stringifyUrlQueryParam(param) {
  1857. if (typeof param === 'string' || typeof param === 'number' && !isNaN(param) || typeof param === 'boolean') {
  1858. return String(param);
  1859. } else {
  1860. return '';
  1861. }
  1862. }
  1863. function urlQueryToSearchParams(urlQuery) {
  1864. const result = new URLSearchParams();
  1865. Object.entries(urlQuery).forEach(([key, value]) => {
  1866. if (Array.isArray(value)) {
  1867. value.forEach(item => result.append(key, stringifyUrlQueryParam(item)));
  1868. } else {
  1869. result.set(key, stringifyUrlQueryParam(value));
  1870. }
  1871. });
  1872. return result;
  1873. }
  1874. function assign(target, ...searchParamsList) {
  1875. searchParamsList.forEach(searchParams => {
  1876. Array.from(searchParams.keys()).forEach(key => target.delete(key));
  1877. searchParams.forEach((value, key) => target.append(key, value));
  1878. });
  1879. return target;
  1880. }
  1881. /***/ }),
  1882. /***/ 7451:
  1883. /***/ (function(__unused_webpack_module, exports) {
  1884. "use strict";
  1885. exports.__esModule = true;
  1886. exports.getRouteMatcher = getRouteMatcher;
  1887. function getRouteMatcher(routeRegex) {
  1888. const {
  1889. re,
  1890. groups
  1891. } = routeRegex;
  1892. return pathname => {
  1893. const routeMatch = re.exec(pathname);
  1894. if (!routeMatch) {
  1895. return false;
  1896. }
  1897. const decode = param => {
  1898. try {
  1899. return decodeURIComponent(param);
  1900. } catch (_) {
  1901. const err = new Error('failed to decode param');
  1902. err.code = 'DECODE_FAILED';
  1903. throw err;
  1904. }
  1905. };
  1906. const params = {};
  1907. Object.keys(groups).forEach(slugName => {
  1908. const g = groups[slugName];
  1909. const m = routeMatch[g.pos];
  1910. if (m !== undefined) {
  1911. params[slugName] = ~m.indexOf('/') ? m.split('/').map(entry => decode(entry)) : g.repeat ? [decode(m)] : decode(m);
  1912. }
  1913. });
  1914. return params;
  1915. };
  1916. }
  1917. /***/ }),
  1918. /***/ 8193:
  1919. /***/ (function(__unused_webpack_module, exports) {
  1920. "use strict";
  1921. exports.__esModule = true;
  1922. exports.getRouteRegex = getRouteRegex; // this isn't importing the escape-string-regex module
  1923. // to reduce bytes
  1924. function escapeRegex(str) {
  1925. return str.replace(/[|\\{}()[\]^$+*?.-]/g, '\\$&');
  1926. }
  1927. function parseParameter(param) {
  1928. const optional = param.startsWith('[') && param.endsWith(']');
  1929. if (optional) {
  1930. param = param.slice(1, -1);
  1931. }
  1932. const repeat = param.startsWith('...');
  1933. if (repeat) {
  1934. param = param.slice(3);
  1935. }
  1936. return {
  1937. key: param,
  1938. repeat,
  1939. optional
  1940. };
  1941. }
  1942. function getRouteRegex(normalizedRoute) {
  1943. const segments = (normalizedRoute.replace(/\/$/, '') || '/').slice(1).split('/');
  1944. const groups = {};
  1945. let groupIndex = 1;
  1946. const parameterizedRoute = segments.map(segment => {
  1947. if (segment.startsWith('[') && segment.endsWith(']')) {
  1948. const {
  1949. key,
  1950. optional,
  1951. repeat
  1952. } = parseParameter(segment.slice(1, -1));
  1953. groups[key] = {
  1954. pos: groupIndex++,
  1955. repeat,
  1956. optional
  1957. };
  1958. return repeat ? optional ? '(?:/(.+?))?' : '/(.+?)' : '/([^/]+?)';
  1959. } else {
  1960. return `/${escapeRegex(segment)}`;
  1961. }
  1962. }).join(''); // dead code eliminate for browser since it's only needed
  1963. // while generating routes-manifest
  1964. if (true) {
  1965. let routeKeyCharCode = 97;
  1966. let routeKeyCharLength = 1; // builds a minimal routeKey using only a-z and minimal number of characters
  1967. const getSafeRouteKey = () => {
  1968. let routeKey = '';
  1969. for (let i = 0; i < routeKeyCharLength; i++) {
  1970. routeKey += String.fromCharCode(routeKeyCharCode);
  1971. routeKeyCharCode++;
  1972. if (routeKeyCharCode > 122) {
  1973. routeKeyCharLength++;
  1974. routeKeyCharCode = 97;
  1975. }
  1976. }
  1977. return routeKey;
  1978. };
  1979. const routeKeys = {};
  1980. let namedParameterizedRoute = segments.map(segment => {
  1981. if (segment.startsWith('[') && segment.endsWith(']')) {
  1982. const {
  1983. key,
  1984. optional,
  1985. repeat
  1986. } = parseParameter(segment.slice(1, -1)); // replace any non-word characters since they can break
  1987. // the named regex
  1988. let cleanedKey = key.replace(/\W/g, '');
  1989. let invalidKey = false; // check if the key is still invalid and fallback to using a known
  1990. // safe key
  1991. if (cleanedKey.length === 0 || cleanedKey.length > 30) {
  1992. invalidKey = true;
  1993. }
  1994. if (!isNaN(parseInt(cleanedKey.substr(0, 1)))) {
  1995. invalidKey = true;
  1996. }
  1997. if (invalidKey) {
  1998. cleanedKey = getSafeRouteKey();
  1999. }
  2000. routeKeys[cleanedKey] = key;
  2001. return repeat ? optional ? `(?:/(?<${cleanedKey}>.+?))?` : `/(?<${cleanedKey}>.+?)` : `/(?<${cleanedKey}>[^/]+?)`;
  2002. } else {
  2003. return `/${escapeRegex(segment)}`;
  2004. }
  2005. }).join('');
  2006. return {
  2007. re: new RegExp(`^${parameterizedRoute}(?:/)?$`),
  2008. groups,
  2009. routeKeys,
  2010. namedRegex: `^${namedParameterizedRoute}(?:/)?$`
  2011. };
  2012. }
  2013. return {
  2014. re: new RegExp(`^${parameterizedRoute}(?:/)?$`),
  2015. groups
  2016. };
  2017. }
  2018. /***/ }),
  2019. /***/ 3937:
  2020. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  2021. "use strict";
  2022. exports.__esModule = true;
  2023. exports.execOnce = execOnce;
  2024. exports.getLocationOrigin = getLocationOrigin;
  2025. exports.getURL = getURL;
  2026. exports.getDisplayName = getDisplayName;
  2027. exports.isResSent = isResSent;
  2028. exports.loadGetInitialProps = loadGetInitialProps;
  2029. exports.formatWithValidation = formatWithValidation;
  2030. exports.ST = exports.SP = exports.urlObjectKeys = void 0;
  2031. var _formatUrl = __webpack_require__(7687);
  2032. /**
  2033. * Utils
  2034. */
  2035. function execOnce(fn) {
  2036. let used = false;
  2037. let result;
  2038. return (...args) => {
  2039. if (!used) {
  2040. used = true;
  2041. result = fn(...args);
  2042. }
  2043. return result;
  2044. };
  2045. }
  2046. function getLocationOrigin() {
  2047. const {
  2048. protocol,
  2049. hostname,
  2050. port
  2051. } = window.location;
  2052. return `${protocol}//${hostname}${port ? ':' + port : ''}`;
  2053. }
  2054. function getURL() {
  2055. const {
  2056. href
  2057. } = window.location;
  2058. const origin = getLocationOrigin();
  2059. return href.substring(origin.length);
  2060. }
  2061. function getDisplayName(Component) {
  2062. return typeof Component === 'string' ? Component : Component.displayName || Component.name || 'Unknown';
  2063. }
  2064. function isResSent(res) {
  2065. return res.finished || res.headersSent;
  2066. }
  2067. async function loadGetInitialProps(App, ctx) {
  2068. if (false) { var _App$prototype; } // when called from _app `ctx` is nested in `ctx`
  2069. const res = ctx.res || ctx.ctx && ctx.ctx.res;
  2070. if (!App.getInitialProps) {
  2071. if (ctx.ctx && ctx.Component) {
  2072. // @ts-ignore pageProps default
  2073. return {
  2074. pageProps: await loadGetInitialProps(ctx.Component, ctx.ctx)
  2075. };
  2076. }
  2077. return {};
  2078. }
  2079. const props = await App.getInitialProps(ctx);
  2080. if (res && isResSent(res)) {
  2081. return props;
  2082. }
  2083. if (!props) {
  2084. const message = `"${getDisplayName(App)}.getInitialProps()" should resolve to an object. But found "${props}" instead.`;
  2085. throw new Error(message);
  2086. }
  2087. if (false) {}
  2088. return props;
  2089. }
  2090. const urlObjectKeys = ['auth', 'hash', 'host', 'hostname', 'href', 'path', 'pathname', 'port', 'protocol', 'query', 'search', 'slashes'];
  2091. exports.urlObjectKeys = urlObjectKeys;
  2092. function formatWithValidation(url) {
  2093. if (false) {}
  2094. return (0, _formatUrl.formatUrl)(url);
  2095. }
  2096. const SP = typeof performance !== 'undefined';
  2097. exports.SP = SP;
  2098. const ST = SP && typeof performance.mark === 'function' && typeof performance.measure === 'function';
  2099. exports.ST = ST;
  2100. /***/ }),
  2101. /***/ 9320:
  2102. /***/ (function(__unused_webpack_module, exports) {
  2103. "use strict";
  2104. exports.__esModule=true;exports.normalizePathSep=normalizePathSep;exports.denormalizePagePath=denormalizePagePath;function normalizePathSep(path){return path.replace(/\\/g,'/');}function denormalizePagePath(page){page=normalizePathSep(page);if(page.startsWith('/index/')){page=page.slice(6);}else if(page==='/index'){page='/';}return page;}
  2105. //# sourceMappingURL=denormalize-page-path.js.map
  2106. /***/ }),
  2107. /***/ 1664:
  2108. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  2109. module.exports = __webpack_require__(6071)
  2110. /***/ }),
  2111. /***/ 2426:
  2112. /***/ (function(module) {
  2113. function _interopRequireDefault(obj) {
  2114. return obj && obj.__esModule ? obj : {
  2115. "default": obj
  2116. };
  2117. }
  2118. module.exports = _interopRequireDefault;
  2119. /***/ }),
  2120. /***/ 9448:
  2121. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  2122. var _typeof = __webpack_require__(7917);
  2123. function _getRequireWildcardCache() {
  2124. if (typeof WeakMap !== "function") return null;
  2125. var cache = new WeakMap();
  2126. _getRequireWildcardCache = function _getRequireWildcardCache() {
  2127. return cache;
  2128. };
  2129. return cache;
  2130. }
  2131. function _interopRequireWildcard(obj) {
  2132. if (obj && obj.__esModule) {
  2133. return obj;
  2134. }
  2135. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  2136. return {
  2137. "default": obj
  2138. };
  2139. }
  2140. var cache = _getRequireWildcardCache();
  2141. if (cache && cache.has(obj)) {
  2142. return cache.get(obj);
  2143. }
  2144. var newObj = {};
  2145. var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
  2146. for (var key in obj) {
  2147. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  2148. var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
  2149. if (desc && (desc.get || desc.set)) {
  2150. Object.defineProperty(newObj, key, desc);
  2151. } else {
  2152. newObj[key] = obj[key];
  2153. }
  2154. }
  2155. }
  2156. newObj["default"] = obj;
  2157. if (cache) {
  2158. cache.set(obj, newObj);
  2159. }
  2160. return newObj;
  2161. }
  2162. module.exports = _interopRequireWildcard;
  2163. /***/ }),
  2164. /***/ 7917:
  2165. /***/ (function(module) {
  2166. function _typeof(obj) {
  2167. "@babel/helpers - typeof";
  2168. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  2169. module.exports = _typeof = function _typeof(obj) {
  2170. return typeof obj;
  2171. };
  2172. } else {
  2173. module.exports = _typeof = function _typeof(obj) {
  2174. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  2175. };
  2176. }
  2177. return _typeof(obj);
  2178. }
  2179. module.exports = _typeof;
  2180. /***/ })
  2181. };
  2182. ;