{"ast":null,"code":"\"use strict\";\n\nvar _regeneratorRuntime = require(\"@babel/runtime/regenerator\");\n\nvar _asyncToGenerator = require(\"@babel/runtime/helpers/asyncToGenerator\");\n\nvar _slicedToArray = require(\"@babel/runtime/helpers/slicedToArray\");\n\nvar _classCallCheck = require(\"@babel/runtime/helpers/classCallCheck\");\n\nvar _createClass = require(\"@babel/runtime/helpers/createClass\");\n\nexports.__esModule = true;\nexports.addBasePath = addBasePath;\nexports.delBasePath = delBasePath;\nexports[\"default\"] = void 0;\n\nvar _url2 = require(\"url\");\n\nvar _mitt = _interopRequireDefault(require(\"../mitt\"));\n\nvar _utils = require(\"../utils\");\n\nvar _isDynamic = require(\"./utils/is-dynamic\");\n\nvar _routeMatcher = require(\"./utils/route-matcher\");\n\nvar _routeRegex = require(\"./utils/route-regex\");\n\nfunction _interopRequireDefault(obj) {\n  return obj && obj.__esModule ? obj : {\n    \"default\": obj\n  };\n}\n/* global __NEXT_DATA__ */\n// tslint:disable:no-console\n\n\nvar basePath = process.env.__NEXT_ROUTER_BASEPATH || '';\n\nfunction addBasePath(path) {\n  return path.indexOf(basePath) !== 0 ? basePath + path : path;\n}\n\nfunction delBasePath(path) {\n  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;\n}\n\nfunction toRoute(path) {\n  return path.replace(/\\/$/, '') || '/';\n}\n\nvar prepareRoute = function prepareRoute(path) {\n  return toRoute(!path || path === '/' ? '/index' : path);\n};\n\nfunction fetchNextData(pathname, query, isServerRender, cb) {\n  var attempts = isServerRender ? 3 : 1;\n\n  function getResponse() {\n    return fetch((0, _utils.formatWithValidation)({\n      pathname: addBasePath( // @ts-ignore __NEXT_DATA__\n      \"/_next/data/\".concat(__NEXT_DATA__.buildId).concat(delBasePath(pathname), \".json\")),\n      query: query\n    }), {\n      // Cookies are required to be present for Next.js' SSG \"Preview Mode\".\n      // Cookies may also be required for `getServerSideProps`.\n      //\n      // > `fetch` won’t send cookies, unless you set the credentials init\n      // > option.\n      // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch\n      //\n      // > For maximum browser compatibility when it comes to sending &\n      // > receiving cookies, always supply the `credentials: 'same-origin'`\n      // > option instead of relying on the default.\n      // https://github.com/github/fetch#caveats\n      credentials: 'same-origin'\n    }).then(function (res) {\n      if (!res.ok) {\n        if (--attempts > 0 && res.status >= 500) {\n          return getResponse();\n        }\n\n        throw new Error(\"Failed to load static props\");\n      }\n\n      return res.json();\n    });\n  }\n\n  return getResponse().then(function (data) {\n    return cb ? cb(data) : data;\n  })[\"catch\"](function (err) {\n    // We should only trigger a server-side transition if this was caused\n    // on a client-side transition. Otherwise, we'd get into an infinite\n    // loop.\n    if (!isServerRender) {\n      ;\n      err.code = 'PAGE_LOAD_ERROR';\n    }\n\n    throw err;\n  });\n}\n\nvar Router = /*#__PURE__*/function () {\n  /**\n  * Map of all components loaded in `Router`\n  */\n  // Static Data Cache\n  function Router(_pathname, _query, _as2, _ref) {\n    var _this = this;\n\n    var initialProps = _ref.initialProps,\n        pageLoader = _ref.pageLoader,\n        App = _ref.App,\n        wrapApp = _ref.wrapApp,\n        Component = _ref.Component,\n        err = _ref.err,\n        subscription = _ref.subscription,\n        isFallback = _ref.isFallback;\n\n    _classCallCheck(this, Router);\n\n    this.route = void 0;\n    this.pathname = void 0;\n    this.query = void 0;\n    this.asPath = void 0;\n    this.basePath = void 0;\n    this.components = void 0;\n    this.sdc = {};\n    this.sub = void 0;\n    this.clc = void 0;\n    this.pageLoader = void 0;\n    this._bps = void 0;\n    this.events = void 0;\n    this._wrapApp = void 0;\n    this.isSsr = void 0;\n    this.isFallback = void 0;\n\n    this.onPopState = function (e) {\n      if (!e.state) {\n        // We get state as undefined for two reasons.\n        //  1. With older safari (< 8) and older chrome (< 34)\n        //  2. When the URL changed with #\n        //\n        // In the both cases, we don't need to proceed and change the route.\n        // (as it's already changed)\n        // But we can simply replace the state with the new changes.\n        // Actually, for (1) we don't need to nothing. But it's hard to detect that event.\n        // So, doing the following for (1) does no harm.\n        var pathname = _this.pathname,\n            query = _this.query;\n\n        _this.changeState('replaceState', (0, _utils.formatWithValidation)({\n          pathname: pathname,\n          query: query\n        }), (0, _utils.getURL)());\n\n        return;\n      } // Make sure we don't re-render on initial load,\n      // can be caused by navigating back from an external site\n\n\n      if (e.state && _this.isSsr && e.state.as === _this.asPath && (0, _url2.parse)(e.state.url).pathname === _this.pathname) {\n        return;\n      } // If the downstream application returns falsy, return.\n      // They will then be responsible for handling the event.\n\n\n      if (_this._bps && !_this._bps(e.state)) {\n        return;\n      }\n\n      var _e$state = e.state,\n          url = _e$state.url,\n          as = _e$state.as,\n          options = _e$state.options;\n\n      if (true) {\n        if (typeof url === 'undefined' || typeof as === 'undefined') {\n          console.warn('`popstate` event triggered but `event.state` did not have `url` or `as` https://err.sh/vercel/next.js/popstate-state-empty');\n        }\n      }\n\n      _this.replace(url, as, options);\n    };\n\n    this._getStaticData = function (asPath) {\n      var pathname = prepareRoute((0, _url2.parse)(asPath).pathname);\n      return false && _this.sdc[pathname] ? Promise.resolve(_this.sdc[pathname]) : fetchNextData(pathname, null, _this.isSsr, function (data) {\n        return _this.sdc[pathname] = data;\n      });\n    };\n\n    this._getServerData = function (asPath) {\n      var _ref2 = (0, _url2.parse)(asPath, true),\n          pathname = _ref2.pathname,\n          query = _ref2.query;\n\n      pathname = prepareRoute(pathname);\n      return fetchNextData(pathname, query, _this.isSsr);\n    }; // represents the current component key\n\n\n    this.route = toRoute(_pathname); // set up the component cache (by route keys)\n\n    this.components = {}; // We should not keep the cache, if there's an error\n    // Otherwise, this cause issues when when going back and\n    // come again to the errored page.\n\n    if (_pathname !== '/_error') {\n      this.components[this.route] = {\n        Component: Component,\n        props: initialProps,\n        err: err,\n        __N_SSG: initialProps && initialProps.__N_SSG,\n        __N_SSP: initialProps && initialProps.__N_SSP\n      };\n    }\n\n    this.components['/_app'] = {\n      Component: App\n    }; // Backwards compat for Router.router.events\n    // TODO: Should be remove the following major version as it was never documented\n\n    this.events = Router.events;\n    this.pageLoader = pageLoader;\n    this.pathname = _pathname;\n    this.query = _query; // if auto prerendered and dynamic route wait to update asPath\n    // until after mount to prevent hydration mismatch\n\n    this.asPath = // @ts-ignore this is temporarily global (attached to window)\n    (0, _isDynamic.isDynamicRoute)(_pathname) && __NEXT_DATA__.autoExport ? _pathname : _as2;\n    this.basePath = basePath;\n    this.sub = subscription;\n    this.clc = null;\n    this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating\n    // back from external site\n\n    this.isSsr = true;\n    this.isFallback = isFallback;\n\n    if (true) {\n      // make sure \"as\" doesn't start with double slashes or else it can\n      // throw an error as it's considered invalid\n      if (_as2.substr(0, 2) !== '//') {\n        // in order for `e.state` to work on the `onpopstate` event\n        // we have to register the initial route upon initialization\n        this.changeState('replaceState', (0, _utils.formatWithValidation)({\n          pathname: _pathname,\n          query: _query\n        }), _as2);\n      }\n\n      window.addEventListener('popstate', this.onPopState);\n    }\n  } // @deprecated backwards compatibility even though it's a private method.\n\n\n  _createClass(Router, [{\n    key: \"update\",\n    value: function update(route, mod) {\n      var Component = mod[\"default\"] || mod;\n      var data = this.components[route];\n\n      if (!data) {\n        throw new Error(\"Cannot update unavailable route: \".concat(route));\n      }\n\n      var newData = Object.assign({}, data, {\n        Component: Component,\n        __N_SSG: mod.__N_SSG,\n        __N_SSP: mod.__N_SSP\n      });\n      this.components[route] = newData; // pages/_app.js updated\n\n      if (route === '/_app') {\n        this.notify(this.components[this.route]);\n        return;\n      }\n\n      if (route === this.route) {\n        this.notify(newData);\n      }\n    }\n  }, {\n    key: \"reload\",\n    value: function reload() {\n      window.location.reload();\n    }\n    /**\n    * Go back in history\n    */\n\n  }, {\n    key: \"back\",\n    value: function back() {\n      window.history.back();\n    }\n    /**\n    * Performs a `pushState` with arguments\n    * @param url of the route\n    * @param as masks `url` for the browser\n    * @param options object you can define `shallow` and other options\n    */\n\n  }, {\n    key: \"push\",\n    value: function push(url) {\n      var as = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : url;\n      var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n      return this.change('pushState', url, as, options);\n    }\n    /**\n    * Performs a `replaceState` with arguments\n    * @param url of the route\n    * @param as masks `url` for the browser\n    * @param options object you can define `shallow` and other options\n    */\n\n  }, {\n    key: \"replace\",\n    value: function replace(url) {\n      var as = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : url;\n      var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n      return this.change('replaceState', url, as, options);\n    }\n  }, {\n    key: \"change\",\n    value: function change(method, _url, _as, options) {\n      var _this2 = this;\n\n      return new Promise(function (resolve, reject) {\n        if (!options._h) {\n          _this2.isSsr = false;\n        } // marking route changes as a navigation start entry\n\n\n        if (_utils.ST) {\n          performance.mark('routeChange');\n        } // If url and as provided as an object representation,\n        // we'll format them into the string version here.\n\n\n        var url = typeof _url === 'object' ? (0, _utils.formatWithValidation)(_url) : _url;\n        var as = typeof _as === 'object' ? (0, _utils.formatWithValidation)(_as) : _as;\n        url = addBasePath(url);\n        as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the\n        // \"<page>/index.html\" directly for the SSR page.\n\n        if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n          var rewriteUrlForNextExport = require('./rewrite-url-for-export').rewriteUrlForNextExport; // @ts-ignore this is temporarily global (attached to window)\n\n\n          if (__NEXT_DATA__.nextExport) {\n            as = rewriteUrlForNextExport(as);\n          }\n        }\n\n        _this2.abortComponentLoad(as); // If the url change is only related to a hash change\n        // We should not proceed. We should only change the state.\n        // WARNING: `_h` is an internal option for handing Next.js client-side\n        // hydration. Your app should _never_ use this property. It may change at\n        // any time without notice.\n\n\n        if (!options._h && _this2.onlyAHashChange(as)) {\n          _this2.asPath = as;\n          Router.events.emit('hashChangeStart', as);\n\n          _this2.changeState(method, url, as, options);\n\n          _this2.scrollToHash(as);\n\n          Router.events.emit('hashChangeComplete', as);\n          return resolve(true);\n        }\n\n        var _ref3 = (0, _url2.parse)(url, true),\n            pathname = _ref3.pathname,\n            query = _ref3.query,\n            protocol = _ref3.protocol;\n\n        if (!pathname || protocol) {\n          if (true) {\n            throw new Error(\"Invalid href passed to router: \".concat(url, \" https://err.sh/vercel/next.js/invalid-href-passed\"));\n          }\n\n          return resolve(false);\n        } // If asked to change the current URL we should reload the current page\n        // (not location.reload() but reload getInitialProps and other Next.js stuffs)\n        // We also need to set the method = replaceState always\n        // as this should not go into the history (That's how browsers work)\n        // We should compare the new asPath to the current asPath, not the url\n\n\n        if (!_this2.urlIsNew(as)) {\n          method = 'replaceState';\n        }\n\n        var route = toRoute(pathname);\n        var _options$shallow = options.shallow,\n            shallow = _options$shallow === void 0 ? false : _options$shallow;\n\n        if ((0, _isDynamic.isDynamicRoute)(route)) {\n          var _ref4 = (0, _url2.parse)(as),\n              asPathname = _ref4.pathname;\n\n          var routeRegex = (0, _routeRegex.getRouteRegex)(route);\n          var routeMatch = (0, _routeMatcher.getRouteMatcher)(routeRegex)(asPathname);\n\n          if (!routeMatch) {\n            var missingParams = Object.keys(routeRegex.groups).filter(function (param) {\n              return !query[param];\n            });\n\n            if (missingParams.length > 0) {\n              if (true) {\n                console.warn(\"Mismatching `as` and `href` failed to manually provide \" + \"the params: \".concat(missingParams.join(', '), \" in the `href`'s `query`\"));\n              }\n\n              return reject(new Error(\"The provided `as` value (\".concat(asPathname, \") is incompatible with the `href` value (\").concat(route, \"). \") + \"Read more: https://err.sh/vercel/next.js/incompatible-href-as\"));\n            }\n          } else {\n            // Merge params into `query`, overwriting any specified in search\n            Object.assign(query, routeMatch);\n          }\n        }\n\n        Router.events.emit('routeChangeStart', as); // If shallow is true and the route exists in the router cache we reuse the previous result\n\n        _this2.getRouteInfo(route, pathname, query, as, shallow).then(function (routeInfo) {\n          var error = routeInfo.error;\n\n          if (error && error.cancelled) {\n            return resolve(false);\n          }\n\n          Router.events.emit('beforeHistoryChange', as);\n\n          _this2.changeState(method, url, as, options);\n\n          if (true) {\n            var appComp = _this2.components['/_app'].Component;\n            window.next.isPrerendered = appComp.getInitialProps === appComp.origGetInitialProps && !routeInfo.Component.getInitialProps;\n          }\n\n          _this2.set(route, pathname, query, as, routeInfo).then(function () {\n            if (error) {\n              Router.events.emit('routeChangeError', error, as);\n              throw error;\n            }\n\n            Router.events.emit('routeChangeComplete', as);\n            return resolve(true);\n          });\n        }, reject);\n      });\n    }\n  }, {\n    key: \"changeState\",\n    value: function changeState(method, url, as) {\n      var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n\n      if (true) {\n        if (typeof window.history === 'undefined') {\n          console.error(\"Warning: window.history is not available.\");\n          return;\n        }\n\n        if (typeof window.history[method] === 'undefined') {\n          console.error(\"Warning: window.history.\".concat(method, \" is not available\"));\n          return;\n        }\n      }\n\n      if (method !== 'pushState' || (0, _utils.getURL)() !== as) {\n        window.history[method]({\n          url: url,\n          as: as,\n          options: options\n        }, // Most browsers currently ignores this parameter, although they may use it in the future.\n        // Passing the empty string here should be safe against future changes to the method.\n        // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState\n        '', as);\n      }\n    }\n  }, {\n    key: \"getRouteInfo\",\n    value: function getRouteInfo(route, pathname, query, as) {\n      var _this3 = this;\n\n      var shallow = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n      var cachedRouteInfo = this.components[route]; // If there is a shallow route transition possible\n      // If the route is already rendered on the screen.\n\n      if (shallow && cachedRouteInfo && this.route === route) {\n        return Promise.resolve(cachedRouteInfo);\n      }\n\n      var handleError = function handleError(err, loadErrorFail) {\n        return new Promise(function (resolve) {\n          if (err.code === 'PAGE_LOAD_ERROR' || loadErrorFail) {\n            // If we can't load the page it could be one of following reasons\n            //  1. Page doesn't exists\n            //  2. Page does exist in a different zone\n            //  3. Internal error while loading the page\n            // So, doing a hard reload is the proper way to deal with this.\n            window.location.href = as; // Changing the URL doesn't block executing the current code path.\n            // So, we need to mark it as a cancelled error and stop the routing logic.\n\n            err.cancelled = true; // @ts-ignore TODO: fix the control flow here\n\n            return resolve({\n              error: err\n            });\n          }\n\n          if (err.cancelled) {\n            // @ts-ignore TODO: fix the control flow here\n            return resolve({\n              error: err\n            });\n          }\n\n          resolve(_this3.fetchComponent('/_error').then(function (res) {\n            var Component = res.page;\n            var routeInfo = {\n              Component: Component,\n              err: err\n            };\n            return new Promise(function (resolve) {\n              _this3.getInitialProps(Component, {\n                err: err,\n                pathname: pathname,\n                query: query\n              }).then(function (props) {\n                routeInfo.props = props;\n                routeInfo.error = err;\n                resolve(routeInfo);\n              }, function (gipErr) {\n                console.error('Error in error page `getInitialProps`: ', gipErr);\n                routeInfo.error = err;\n                routeInfo.props = {};\n                resolve(routeInfo);\n              });\n            });\n          })[\"catch\"](function (err) {\n            return handleError(err, true);\n          }));\n        });\n      };\n\n      return new Promise(function (resolve, reject) {\n        if (cachedRouteInfo) {\n          return resolve(cachedRouteInfo);\n        }\n\n        _this3.fetchComponent(route).then(function (res) {\n          return resolve({\n            Component: res.page,\n            __N_SSG: res.mod.__N_SSG,\n            __N_SSP: res.mod.__N_SSP\n          });\n        }, reject);\n      }).then(function (routeInfo) {\n        var Component = routeInfo.Component,\n            __N_SSG = routeInfo.__N_SSG,\n            __N_SSP = routeInfo.__N_SSP;\n\n        if (true) {\n          var _require = require('react-is'),\n              isValidElementType = _require.isValidElementType;\n\n          if (!isValidElementType(Component)) {\n            throw new Error(\"The default export is not a React Component in page: \\\"\".concat(pathname, \"\\\"\"));\n          }\n        }\n\n        return _this3._getData(function () {\n          return __N_SSG ? _this3._getStaticData(as) : __N_SSP ? _this3._getServerData(as) : _this3.getInitialProps(Component, // we provide AppTree later so this needs to be `any`\n          {\n            pathname: pathname,\n            query: query,\n            asPath: as\n          });\n        }).then(function (props) {\n          routeInfo.props = props;\n          _this3.components[route] = routeInfo;\n          return routeInfo;\n        });\n      })[\"catch\"](handleError);\n    }\n  }, {\n    key: \"set\",\n    value: function set(route, pathname, query, as, data) {\n      this.isFallback = false;\n      this.route = route;\n      this.pathname = pathname;\n      this.query = query;\n      this.asPath = as;\n      return this.notify(data);\n    }\n    /**\n    * Callback to execute before replacing router state\n    * @param cb callback to be executed\n    */\n\n  }, {\n    key: \"beforePopState\",\n    value: function beforePopState(cb) {\n      this._bps = cb;\n    }\n  }, {\n    key: \"onlyAHashChange\",\n    value: function onlyAHashChange(as) {\n      if (!this.asPath) return false;\n\n      var _this$asPath$split = this.asPath.split('#'),\n          _this$asPath$split2 = _slicedToArray(_this$asPath$split, 2),\n          oldUrlNoHash = _this$asPath$split2[0],\n          oldHash = _this$asPath$split2[1];\n\n      var _as$split = as.split('#'),\n          _as$split2 = _slicedToArray(_as$split, 2),\n          newUrlNoHash = _as$split2[0],\n          newHash = _as$split2[1]; // Makes sure we scroll to the provided hash if the url/hash are the same\n\n\n      if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {\n        return true;\n      } // If the urls are change, there's more than a hash change\n\n\n      if (oldUrlNoHash !== newUrlNoHash) {\n        return false;\n      } // If the hash has changed, then it's a hash only change.\n      // This check is necessary to handle both the enter and\n      // leave hash === '' cases. The identity case falls through\n      // and is treated as a next reload.\n\n\n      return oldHash !== newHash;\n    }\n  }, {\n    key: \"scrollToHash\",\n    value: function scrollToHash(as) {\n      var _as$split3 = as.split('#'),\n          _as$split4 = _slicedToArray(_as$split3, 2),\n          hash = _as$split4[1]; // Scroll to top if the hash is just `#` with no value\n\n\n      if (hash === '') {\n        window.scrollTo(0, 0);\n        return;\n      } // First we check if the element by id is found\n\n\n      var idEl = document.getElementById(hash);\n\n      if (idEl) {\n        idEl.scrollIntoView();\n        return;\n      } // If there's no element with the id, we check the `name` property\n      // To mirror browsers\n\n\n      var nameEl = document.getElementsByName(hash)[0];\n\n      if (nameEl) {\n        nameEl.scrollIntoView();\n      }\n    }\n  }, {\n    key: \"urlIsNew\",\n    value: function urlIsNew(asPath) {\n      return this.asPath !== asPath;\n    }\n    /**\n    * Prefetch page code, you may wait for the data during page rendering.\n    * This feature only works in production!\n    * @param url the href of prefetched page\n    * @param asPath the as path of the prefetched page\n    */\n\n  }, {\n    key: \"prefetch\",\n    value: function prefetch(url) {\n      var _this4 = this;\n\n      var asPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : url;\n      var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n      return new Promise(function (resolve, reject) {\n        var _ref5 = (0, _url2.parse)(url),\n            pathname = _ref5.pathname,\n            protocol = _ref5.protocol;\n\n        if (!pathname || protocol) {\n          if (true) {\n            throw new Error(\"Invalid href passed to router: \".concat(url, \" https://err.sh/vercel/next.js/invalid-href-passed\"));\n          }\n\n          return;\n        } // Prefetch is not supported in development mode because it would trigger on-demand-entries\n\n\n        if (true) {\n          return;\n        }\n\n        var route = delBasePath(toRoute(pathname));\n        Promise.all([_this4.pageLoader.prefetchData(url, delBasePath(asPath)), _this4.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route)]).then(function () {\n          return resolve();\n        }, reject);\n      });\n    }\n  }, {\n    key: \"fetchComponent\",\n    value: function () {\n      var _fetchComponent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(route) {\n        var cancelled, cancel, componentResult, error;\n        return _regeneratorRuntime.wrap(function _callee$(_context) {\n          while (1) {\n            switch (_context.prev = _context.next) {\n              case 0:\n                cancelled = false;\n\n                cancel = this.clc = function () {\n                  cancelled = true;\n                };\n\n                route = delBasePath(route);\n                _context.next = 5;\n                return this.pageLoader.loadPage(route);\n\n              case 5:\n                componentResult = _context.sent;\n\n                if (!cancelled) {\n                  _context.next = 10;\n                  break;\n                }\n\n                error = new Error(\"Abort fetching component for route: \\\"\".concat(route, \"\\\"\"));\n                error.cancelled = true;\n                throw error;\n\n              case 10:\n                if (cancel === this.clc) {\n                  this.clc = null;\n                }\n\n                return _context.abrupt(\"return\", componentResult);\n\n              case 12:\n              case \"end\":\n                return _context.stop();\n            }\n          }\n        }, _callee, this);\n      }));\n\n      function fetchComponent(_x) {\n        return _fetchComponent.apply(this, arguments);\n      }\n\n      return fetchComponent;\n    }()\n  }, {\n    key: \"_getData\",\n    value: function _getData(fn) {\n      var _this5 = this;\n\n      var cancelled = false;\n\n      var cancel = function cancel() {\n        cancelled = true;\n      };\n\n      this.clc = cancel;\n      return fn().then(function (data) {\n        if (cancel === _this5.clc) {\n          _this5.clc = null;\n        }\n\n        if (cancelled) {\n          var err = new Error('Loading initial props cancelled');\n          err.cancelled = true;\n          throw err;\n        }\n\n        return data;\n      });\n    }\n  }, {\n    key: \"getInitialProps\",\n    value: function getInitialProps(Component, ctx) {\n      var App = this.components['/_app'].Component;\n\n      var AppTree = this._wrapApp(App);\n\n      ctx.AppTree = AppTree;\n      return (0, _utils.loadGetInitialProps)(App, {\n        AppTree: AppTree,\n        Component: Component,\n        router: this,\n        ctx: ctx\n      });\n    }\n  }, {\n    key: \"abortComponentLoad\",\n    value: function abortComponentLoad(as) {\n      if (this.clc) {\n        var e = new Error('Route Cancelled');\n        e.cancelled = true;\n        Router.events.emit('routeChangeError', e, as);\n        this.clc();\n        this.clc = null;\n      }\n    }\n  }, {\n    key: \"notify\",\n    value: function notify(data) {\n      return this.sub(data, this.components['/_app'].Component);\n    }\n  }], [{\n    key: \"_rewriteUrlForNextExport\",\n    value: function _rewriteUrlForNextExport(url) {\n      if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n        var rewriteUrlForNextExport = require('./rewrite-url-for-export').rewriteUrlForNextExport;\n\n        return rewriteUrlForNextExport(url);\n      } else {\n        return url;\n      }\n    }\n  }]);\n\n  return Router;\n}();\n\nexports[\"default\"] = Router;\nRouter.events = (0, _mitt[\"default\"])();","map":{"version":3,"sources":["../../../../next-server/lib/router/router.ts"],"names":["basePath","process","path","prepareRoute","toRoute","attempts","isServerRender","pathname","addBasePath","__NEXT_DATA__","buildId","delBasePath","query","credentials","res","getResponse","data","cb","err","Router","route","asPath","components","sdc","sub","clc","pageLoader","_bps","events","_wrapApp","isSsr","isFallback","constructor","Component","props","__N_SSG","initialProps","__N_SSP","as","window","rewriteUrlForNextExport","require","e","console","update","mod","newData","Object","reload","options","change","ST","performance","url","resolve","method","shallow","routeRegex","routeMatch","missingParams","param","reject","asPathname","routeInfo","error","appComp","changeState","getRouteInfo","cachedRouteInfo","Promise","handleError","page","gipErr","isValidElementType","set","onlyAHashChange","newHash","oldUrlNoHash","oldHash","scrollToHash","hash","idEl","document","nameEl","urlIsNew","cancelled","cancel","componentResult","fn","fetchNextData","getInitialProps","AppTree","ctx","router","abortComponentLoad","notify"],"mappings":";;;;;;;;;;;;;;;;;AAIA,IAAA,KAAA,GAAA,OAAA,CAAA,KAAA,CAAA;;AACA,IAAA,KAAA,GAAA,sBAAA,CAAA,OAAA,CAAA,SAAA,CAAA,CAAA;;AACA,IAAA,MAAA,GAAA,OAAA,CAAA,UAAA,CAAA;;AAQA,IAAA,UAAA,GAAA,OAAA,CAAA,oBAAA,CAAA;;AACA,IAAA,aAAA,GAAA,OAAA,CAAA,uBAAA,CAAA;;AACA,IAAA,WAAA,GAAA,OAAA,CAAA,qBAAA,CAAA;;;;;;AAhBA;AAAA;AACA;;;AAiBA,IAAMA,QAAQ,GAAIC,OAAO,CAAPA,GAAAA,CAAD,sBAACA,IAAlB,EAAA;;AAEO,SAAA,WAAA,CAAA,IAAA,EAA2C;AAChD,SAAOC,IAAI,CAAJA,OAAAA,CAAAA,QAAAA,MAAAA,CAAAA,GAA+BF,QAAQ,GAAvCE,IAAAA,GAAP,IAAA;AAGK;;AAAA,SAAA,WAAA,CAAA,IAAA,EAA2C;AAChD,SAAOA,IAAI,CAAJA,OAAAA,CAAAA,QAAAA,MAAAA,CAAAA,GACHA,IAAI,CAAJA,MAAAA,CAAYF,QAAQ,CAApBE,MAAAA,KADGA,GAAAA,GAAP,IAAA;AAKF;;AAAA,SAAA,OAAA,CAAA,IAAA,EAAuC;AACrC,SAAOA,IAAI,CAAJA,OAAAA,CAAAA,KAAAA,EAAAA,EAAAA,KAAP,GAAA;AAGF;;AAAA,IAAMC,YAA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disable:no-console\nimport { ParsedUrlQuery } from 'querystring'\nimport { ComponentType } from 'react'\nimport { parse, UrlObject } from 'url'\nimport mitt, { MittEmitter } from '../mitt'\nimport {\n  AppContextType,\n  formatWithValidation,\n  getURL,\n  loadGetInitialProps,\n  NextPageContext,\n  ST,\n} from '../utils'\nimport { isDynamicRoute } from './utils/is-dynamic'\nimport { getRouteMatcher } from './utils/route-matcher'\nimport { getRouteRegex } from './utils/route-regex'\n\nconst basePath = (process.env.__NEXT_ROUTER_BASEPATH as string) || ''\n\nexport function addBasePath(path: string): string {\n  return path.indexOf(basePath) !== 0 ? basePath + path : path\n}\n\nexport function delBasePath(path: string): string {\n  return path.indexOf(basePath) === 0\n    ? path.substr(basePath.length) || '/'\n    : path\n}\n\nfunction toRoute(path: string): string {\n  return path.replace(/\\/$/, '') || '/'\n}\n\nconst prepareRoute = (path: string) =>\n  toRoute(!path || path === '/' ? '/index' : path)\n\ntype Url = UrlObject | string\n\ntype ComponentRes = { page: ComponentType; mod: any }\n\nexport type BaseRouter = {\n  route: string\n  pathname: string\n  query: ParsedUrlQuery\n  asPath: string\n  basePath: string\n}\n\nexport type NextRouter = BaseRouter &\n  Pick<\n    Router,\n    | 'push'\n    | 'replace'\n    | 'reload'\n    | 'back'\n    | 'prefetch'\n    | 'beforePopState'\n    | 'events'\n    | 'isFallback'\n  >\n\nexport type PrefetchOptions = {\n  priority?: boolean\n}\n\ntype RouteInfo = {\n  Component: ComponentType\n  __N_SSG?: boolean\n  __N_SSP?: boolean\n  props?: any\n  err?: Error\n  error?: any\n}\n\ntype Subscription = (data: RouteInfo, App?: ComponentType) => Promise<void>\n\ntype BeforePopStateCallback = (state: any) => boolean\n\ntype ComponentLoadCancel = (() => void) | null\n\ntype HistoryMethod = 'replaceState' | 'pushState'\n\nfunction fetchNextData(\n  pathname: string,\n  query: ParsedUrlQuery | null,\n  isServerRender: boolean,\n  cb?: (...args: any) => any\n) {\n  let attempts = isServerRender ? 3 : 1\n  function getResponse(): Promise<any> {\n    return fetch(\n      formatWithValidation({\n        pathname: addBasePath(\n          // @ts-ignore __NEXT_DATA__\n          `/_next/data/${__NEXT_DATA__.buildId}${delBasePath(pathname)}.json`\n        ),\n        query,\n      }),\n      {\n        // Cookies are required to be present for Next.js' SSG \"Preview Mode\".\n        // Cookies may also be required for `getServerSideProps`.\n        //\n        // > `fetch` won’t send cookies, unless you set the credentials init\n        // > option.\n        // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch\n        //\n        // > For maximum browser compatibility when it comes to sending &\n        // > receiving cookies, always supply the `credentials: 'same-origin'`\n        // > option instead of relying on the default.\n        // https://github.com/github/fetch#caveats\n        credentials: 'same-origin',\n      }\n    ).then((res) => {\n      if (!res.ok) {\n        if (--attempts > 0 && res.status >= 500) {\n          return getResponse()\n        }\n        throw new Error(`Failed to load static props`)\n      }\n      return res.json()\n    })\n  }\n\n  return getResponse()\n    .then((data) => {\n      return cb ? cb(data) : data\n    })\n    .catch((err: Error) => {\n      // We should only trigger a server-side transition if this was caused\n      // on a client-side transition. Otherwise, we'd get into an infinite\n      // loop.\n      if (!isServerRender) {\n        ;(err as any).code = 'PAGE_LOAD_ERROR'\n      }\n      throw err\n    })\n}\n\nexport default class Router implements BaseRouter {\n  route: string\n  pathname: string\n  query: ParsedUrlQuery\n  asPath: string\n  basePath: string\n\n  /**\n   * Map of all components loaded in `Router`\n   */\n  components: { [pathname: string]: RouteInfo }\n  // Static Data Cache\n  sdc: { [asPath: string]: object } = {}\n  sub: Subscription\n  clc: ComponentLoadCancel\n  pageLoader: any\n  _bps: BeforePopStateCallback | undefined\n  events: MittEmitter\n  _wrapApp: (App: ComponentType) => any\n  isSsr: boolean\n  isFallback: boolean\n\n  static events: MittEmitter = mitt()\n\n  constructor(\n    pathname: string,\n    query: ParsedUrlQuery,\n    as: string,\n    {\n      initialProps,\n      pageLoader,\n      App,\n      wrapApp,\n      Component,\n      err,\n      subscription,\n      isFallback,\n    }: {\n      subscription: Subscription\n      initialProps: any\n      pageLoader: any\n      Component: ComponentType\n      App: ComponentType\n      wrapApp: (App: ComponentType) => any\n      err?: Error\n      isFallback: boolean\n    }\n  ) {\n    // represents the current component key\n    this.route = toRoute(pathname)\n\n    // set up the component cache (by route keys)\n    this.components = {}\n    // We should not keep the cache, if there's an error\n    // Otherwise, this cause issues when when going back and\n    // come again to the errored page.\n    if (pathname !== '/_error') {\n      this.components[this.route] = {\n        Component,\n        props: initialProps,\n        err,\n        __N_SSG: initialProps && initialProps.__N_SSG,\n        __N_SSP: initialProps && initialProps.__N_SSP,\n      }\n    }\n\n    this.components['/_app'] = { Component: App }\n\n    // Backwards compat for Router.router.events\n    // TODO: Should be remove the following major version as it was never documented\n    this.events = Router.events\n\n    this.pageLoader = pageLoader\n    this.pathname = pathname\n    this.query = query\n    // if auto prerendered and dynamic route wait to update asPath\n    // until after mount to prevent hydration mismatch\n    this.asPath =\n      // @ts-ignore this is temporarily global (attached to window)\n      isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as\n    this.basePath = basePath\n    this.sub = subscription\n    this.clc = null\n    this._wrapApp = wrapApp\n    // make sure to ignore extra popState in safari on navigating\n    // back from external site\n    this.isSsr = true\n\n    this.isFallback = isFallback\n\n    if (typeof window !== 'undefined') {\n      // make sure \"as\" doesn't start with double slashes or else it can\n      // throw an error as it's considered invalid\n      if (as.substr(0, 2) !== '//') {\n        // in order for `e.state` to work on the `onpopstate` event\n        // we have to register the initial route upon initialization\n        this.changeState(\n          'replaceState',\n          formatWithValidation({ pathname, query }),\n          as\n        )\n      }\n\n      window.addEventListener('popstate', this.onPopState)\n    }\n  }\n\n  // @deprecated backwards compatibility even though it's a private method.\n  static _rewriteUrlForNextExport(url: string): string {\n    if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n      const rewriteUrlForNextExport = require('./rewrite-url-for-export')\n        .rewriteUrlForNextExport\n      return rewriteUrlForNextExport(url)\n    } else {\n      return url\n    }\n  }\n\n  onPopState = (e: PopStateEvent): void => {\n    if (!e.state) {\n      // We get state as undefined for two reasons.\n      //  1. With older safari (< 8) and older chrome (< 34)\n      //  2. When the URL changed with #\n      //\n      // In the both cases, we don't need to proceed and change the route.\n      // (as it's already changed)\n      // But we can simply replace the state with the new changes.\n      // Actually, for (1) we don't need to nothing. But it's hard to detect that event.\n      // So, doing the following for (1) does no harm.\n      const { pathname, query } = this\n      this.changeState(\n        'replaceState',\n        formatWithValidation({ pathname, query }),\n        getURL()\n      )\n      return\n    }\n\n    // Make sure we don't re-render on initial load,\n    // can be caused by navigating back from an external site\n    if (\n      e.state &&\n      this.isSsr &&\n      e.state.as === this.asPath &&\n      parse(e.state.url).pathname === this.pathname\n    ) {\n      return\n    }\n\n    // If the downstream application returns falsy, return.\n    // They will then be responsible for handling the event.\n    if (this._bps && !this._bps(e.state)) {\n      return\n    }\n\n    const { url, as, options } = e.state\n    if (process.env.NODE_ENV !== 'production') {\n      if (typeof url === 'undefined' || typeof as === 'undefined') {\n        console.warn(\n          '`popstate` event triggered but `event.state` did not have `url` or `as` https://err.sh/vercel/next.js/popstate-state-empty'\n        )\n      }\n    }\n    this.replace(url, as, options)\n  }\n\n  update(route: string, mod: any) {\n    const Component: ComponentType = mod.default || mod\n    const data = this.components[route]\n    if (!data) {\n      throw new Error(`Cannot update unavailable route: ${route}`)\n    }\n\n    const newData = Object.assign({}, data, {\n      Component,\n      __N_SSG: mod.__N_SSG,\n      __N_SSP: mod.__N_SSP,\n    })\n    this.components[route] = newData\n\n    // pages/_app.js updated\n    if (route === '/_app') {\n      this.notify(this.components[this.route])\n      return\n    }\n\n    if (route === this.route) {\n      this.notify(newData)\n    }\n  }\n\n  reload(): void {\n    window.location.reload()\n  }\n\n  /**\n   * Go back in history\n   */\n  back() {\n    window.history.back()\n  }\n\n  /**\n   * Performs a `pushState` with arguments\n   * @param url of the route\n   * @param as masks `url` for the browser\n   * @param options object you can define `shallow` and other options\n   */\n  push(url: Url, as: Url = url, options = {}) {\n    return this.change('pushState', url, as, options)\n  }\n\n  /**\n   * Performs a `replaceState` with arguments\n   * @param url of the route\n   * @param as masks `url` for the browser\n   * @param options object you can define `shallow` and other options\n   */\n  replace(url: Url, as: Url = url, options = {}) {\n    return this.change('replaceState', url, as, options)\n  }\n\n  change(\n    method: HistoryMethod,\n    _url: Url,\n    _as: Url,\n    options: any\n  ): Promise<boolean> {\n    return new Promise((resolve, reject) => {\n      if (!options._h) {\n        this.isSsr = false\n      }\n      // marking route changes as a navigation start entry\n      if (ST) {\n        performance.mark('routeChange')\n      }\n\n      // If url and as provided as an object representation,\n      // we'll format them into the string version here.\n      let url = typeof _url === 'object' ? formatWithValidation(_url) : _url\n      let as = typeof _as === 'object' ? formatWithValidation(_as) : _as\n\n      url = addBasePath(url)\n      as = addBasePath(as)\n\n      // Add the ending slash to the paths. So, we can serve the\n      // \"<page>/index.html\" directly for the SSR page.\n      if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n        const rewriteUrlForNextExport = require('./rewrite-url-for-export')\n          .rewriteUrlForNextExport\n        // @ts-ignore this is temporarily global (attached to window)\n        if (__NEXT_DATA__.nextExport) {\n          as = rewriteUrlForNextExport(as)\n        }\n      }\n\n      this.abortComponentLoad(as)\n\n      // If the url change is only related to a hash change\n      // We should not proceed. We should only change the state.\n\n      // WARNING: `_h` is an internal option for handing Next.js client-side\n      // hydration. Your app should _never_ use this property. It may change at\n      // any time without notice.\n      if (!options._h && this.onlyAHashChange(as)) {\n        this.asPath = as\n        Router.events.emit('hashChangeStart', as)\n        this.changeState(method, url, as, options)\n        this.scrollToHash(as)\n        Router.events.emit('hashChangeComplete', as)\n        return resolve(true)\n      }\n\n      const { pathname, query, protocol } = parse(url, true)\n\n      if (!pathname || protocol) {\n        if (process.env.NODE_ENV !== 'production') {\n          throw new Error(\n            `Invalid href passed to router: ${url} https://err.sh/vercel/next.js/invalid-href-passed`\n          )\n        }\n        return resolve(false)\n      }\n\n      // If asked to change the current URL we should reload the current page\n      // (not location.reload() but reload getInitialProps and other Next.js stuffs)\n      // We also need to set the method = replaceState always\n      // as this should not go into the history (That's how browsers work)\n      // We should compare the new asPath to the current asPath, not the url\n      if (!this.urlIsNew(as)) {\n        method = 'replaceState'\n      }\n\n      const route = toRoute(pathname)\n      const { shallow = false } = options\n\n      if (isDynamicRoute(route)) {\n        const { pathname: asPathname } = parse(as)\n        const routeRegex = getRouteRegex(route)\n        const routeMatch = getRouteMatcher(routeRegex)(asPathname)\n        if (!routeMatch) {\n          const missingParams = Object.keys(routeRegex.groups).filter(\n            (param) => !query[param]\n          )\n\n          if (missingParams.length > 0) {\n            if (process.env.NODE_ENV !== 'production') {\n              console.warn(\n                `Mismatching \\`as\\` and \\`href\\` failed to manually provide ` +\n                  `the params: ${missingParams.join(\n                    ', '\n                  )} in the \\`href\\`'s \\`query\\``\n              )\n            }\n\n            return reject(\n              new Error(\n                `The provided \\`as\\` value (${asPathname}) is incompatible with the \\`href\\` value (${route}). ` +\n                  `Read more: https://err.sh/vercel/next.js/incompatible-href-as`\n              )\n            )\n          }\n        } else {\n          // Merge params into `query`, overwriting any specified in search\n          Object.assign(query, routeMatch)\n        }\n      }\n\n      Router.events.emit('routeChangeStart', as)\n\n      // If shallow is true and the route exists in the router cache we reuse the previous result\n      this.getRouteInfo(route, pathname, query, as, shallow).then(\n        (routeInfo) => {\n          const { error } = routeInfo\n\n          if (error && error.cancelled) {\n            return resolve(false)\n          }\n\n          Router.events.emit('beforeHistoryChange', as)\n          this.changeState(method, url, as, options)\n\n          if (process.env.NODE_ENV !== 'production') {\n            const appComp: any = this.components['/_app'].Component\n            ;(window as any).next.isPrerendered =\n              appComp.getInitialProps === appComp.origGetInitialProps &&\n              !(routeInfo.Component as any).getInitialProps\n          }\n\n          this.set(route, pathname, query, as, routeInfo).then(() => {\n            if (error) {\n              Router.events.emit('routeChangeError', error, as)\n              throw error\n            }\n\n            Router.events.emit('routeChangeComplete', as)\n            return resolve(true)\n          })\n        },\n        reject\n      )\n    })\n  }\n\n  changeState(\n    method: HistoryMethod,\n    url: string,\n    as: string,\n    options = {}\n  ): void {\n    if (process.env.NODE_ENV !== 'production') {\n      if (typeof window.history === 'undefined') {\n        console.error(`Warning: window.history is not available.`)\n        return\n      }\n\n      if (typeof window.history[method] === 'undefined') {\n        console.error(`Warning: window.history.${method} is not available`)\n        return\n      }\n    }\n\n    if (method !== 'pushState' || getURL() !== as) {\n      window.history[method](\n        {\n          url,\n          as,\n          options,\n        },\n        // Most browsers currently ignores this parameter, although they may use it in the future.\n        // Passing the empty string here should be safe against future changes to the method.\n        // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState\n        '',\n        as\n      )\n    }\n  }\n\n  getRouteInfo(\n    route: string,\n    pathname: string,\n    query: any,\n    as: string,\n    shallow: boolean = false\n  ): Promise<RouteInfo> {\n    const cachedRouteInfo = this.components[route]\n\n    // If there is a shallow route transition possible\n    // If the route is already rendered on the screen.\n    if (shallow && cachedRouteInfo && this.route === route) {\n      return Promise.resolve(cachedRouteInfo)\n    }\n\n    const handleError = (\n      err: Error & { code: any; cancelled: boolean },\n      loadErrorFail?: boolean\n    ) => {\n      return new Promise((resolve) => {\n        if (err.code === 'PAGE_LOAD_ERROR' || loadErrorFail) {\n          // If we can't load the page it could be one of following reasons\n          //  1. Page doesn't exists\n          //  2. Page does exist in a different zone\n          //  3. Internal error while loading the page\n\n          // So, doing a hard reload is the proper way to deal with this.\n          window.location.href = as\n\n          // Changing the URL doesn't block executing the current code path.\n          // So, we need to mark it as a cancelled error and stop the routing logic.\n          err.cancelled = true\n          // @ts-ignore TODO: fix the control flow here\n          return resolve({ error: err })\n        }\n\n        if (err.cancelled) {\n          // @ts-ignore TODO: fix the control flow here\n          return resolve({ error: err })\n        }\n\n        resolve(\n          this.fetchComponent('/_error')\n            .then((res) => {\n              const { page: Component } = res\n              const routeInfo: RouteInfo = { Component, err }\n              return new Promise((resolve) => {\n                this.getInitialProps(Component, {\n                  err,\n                  pathname,\n                  query,\n                } as any).then(\n                  (props) => {\n                    routeInfo.props = props\n                    routeInfo.error = err\n                    resolve(routeInfo)\n                  },\n                  (gipErr) => {\n                    console.error(\n                      'Error in error page `getInitialProps`: ',\n                      gipErr\n                    )\n                    routeInfo.error = err\n                    routeInfo.props = {}\n                    resolve(routeInfo)\n                  }\n                )\n              }) as Promise<RouteInfo>\n            })\n            .catch((err) => handleError(err, true))\n        )\n      }) as Promise<RouteInfo>\n    }\n\n    return (new Promise((resolve, reject) => {\n      if (cachedRouteInfo) {\n        return resolve(cachedRouteInfo)\n      }\n\n      this.fetchComponent(route).then(\n        (res) =>\n          resolve({\n            Component: res.page,\n            __N_SSG: res.mod.__N_SSG,\n            __N_SSP: res.mod.__N_SSP,\n          }),\n        reject\n      )\n    }) as Promise<RouteInfo>)\n      .then((routeInfo: RouteInfo) => {\n        const { Component, __N_SSG, __N_SSP } = routeInfo\n\n        if (process.env.NODE_ENV !== 'production') {\n          const { isValidElementType } = require('react-is')\n          if (!isValidElementType(Component)) {\n            throw new Error(\n              `The default export is not a React Component in page: \"${pathname}\"`\n            )\n          }\n        }\n\n        return this._getData<RouteInfo>(() =>\n          __N_SSG\n            ? this._getStaticData(as)\n            : __N_SSP\n            ? this._getServerData(as)\n            : this.getInitialProps(\n                Component,\n                // we provide AppTree later so this needs to be `any`\n                {\n                  pathname,\n                  query,\n                  asPath: as,\n                } as any\n              )\n        ).then((props) => {\n          routeInfo.props = props\n          this.components[route] = routeInfo\n          return routeInfo\n        })\n      })\n      .catch(handleError)\n  }\n\n  set(\n    route: string,\n    pathname: string,\n    query: any,\n    as: string,\n    data: RouteInfo\n  ): Promise<void> {\n    this.isFallback = false\n\n    this.route = route\n    this.pathname = pathname\n    this.query = query\n    this.asPath = as\n    return this.notify(data)\n  }\n\n  /**\n   * Callback to execute before replacing router state\n   * @param cb callback to be executed\n   */\n  beforePopState(cb: BeforePopStateCallback) {\n    this._bps = cb\n  }\n\n  onlyAHashChange(as: string): boolean {\n    if (!this.asPath) return false\n    const [oldUrlNoHash, oldHash] = this.asPath.split('#')\n    const [newUrlNoHash, newHash] = as.split('#')\n\n    // Makes sure we scroll to the provided hash if the url/hash are the same\n    if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {\n      return true\n    }\n\n    // If the urls are change, there's more than a hash change\n    if (oldUrlNoHash !== newUrlNoHash) {\n      return false\n    }\n\n    // If the hash has changed, then it's a hash only change.\n    // This check is necessary to handle both the enter and\n    // leave hash === '' cases. The identity case falls through\n    // and is treated as a next reload.\n    return oldHash !== newHash\n  }\n\n  scrollToHash(as: string): void {\n    const [, hash] = as.split('#')\n    // Scroll to top if the hash is just `#` with no value\n    if (hash === '') {\n      window.scrollTo(0, 0)\n      return\n    }\n\n    // First we check if the element by id is found\n    const idEl = document.getElementById(hash)\n    if (idEl) {\n      idEl.scrollIntoView()\n      return\n    }\n    // If there's no element with the id, we check the `name` property\n    // To mirror browsers\n    const nameEl = document.getElementsByName(hash)[0]\n    if (nameEl) {\n      nameEl.scrollIntoView()\n    }\n  }\n\n  urlIsNew(asPath: string): boolean {\n    return this.asPath !== asPath\n  }\n\n  /**\n   * Prefetch page code, you may wait for the data during page rendering.\n   * This feature only works in production!\n   * @param url the href of prefetched page\n   * @param asPath the as path of the prefetched page\n   */\n  prefetch(\n    url: string,\n    asPath: string = url,\n    options: PrefetchOptions = {}\n  ): Promise<void> {\n    return new Promise((resolve, reject) => {\n      const { pathname, protocol } = parse(url)\n\n      if (!pathname || protocol) {\n        if (process.env.NODE_ENV !== 'production') {\n          throw new Error(\n            `Invalid href passed to router: ${url} https://err.sh/vercel/next.js/invalid-href-passed`\n          )\n        }\n        return\n      }\n\n      // Prefetch is not supported in development mode because it would trigger on-demand-entries\n      if (process.env.NODE_ENV !== 'production') {\n        return\n      }\n      const route = delBasePath(toRoute(pathname))\n      Promise.all([\n        this.pageLoader.prefetchData(url, delBasePath(asPath)),\n        this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route),\n      ]).then(() => resolve(), reject)\n    })\n  }\n\n  async fetchComponent(route: string): Promise<ComponentRes> {\n    let cancelled = false\n    const cancel = (this.clc = () => {\n      cancelled = true\n    })\n    route = delBasePath(route)\n\n    const componentResult = await this.pageLoader.loadPage(route)\n\n    if (cancelled) {\n      const error: any = new Error(\n        `Abort fetching component for route: \"${route}\"`\n      )\n      error.cancelled = true\n      throw error\n    }\n\n    if (cancel === this.clc) {\n      this.clc = null\n    }\n\n    return componentResult\n  }\n\n  _getData<T>(fn: () => Promise<T>): Promise<T> {\n    let cancelled = false\n    const cancel = () => {\n      cancelled = true\n    }\n    this.clc = cancel\n    return fn().then((data) => {\n      if (cancel === this.clc) {\n        this.clc = null\n      }\n\n      if (cancelled) {\n        const err: any = new Error('Loading initial props cancelled')\n        err.cancelled = true\n        throw err\n      }\n\n      return data\n    })\n  }\n\n  _getStaticData = (asPath: string): Promise<object> => {\n    const pathname = prepareRoute(parse(asPath).pathname!)\n\n    return process.env.NODE_ENV === 'production' && this.sdc[pathname]\n      ? Promise.resolve(this.sdc[pathname])\n      : fetchNextData(\n          pathname,\n          null,\n          this.isSsr,\n          (data) => (this.sdc[pathname] = data)\n        )\n  }\n\n  _getServerData = (asPath: string): Promise<object> => {\n    let { pathname, query } = parse(asPath, true)\n    pathname = prepareRoute(pathname!)\n    return fetchNextData(pathname, query, this.isSsr)\n  }\n\n  getInitialProps(\n    Component: ComponentType,\n    ctx: NextPageContext\n  ): Promise<any> {\n    const { Component: App } = this.components['/_app']\n    const AppTree = this._wrapApp(App)\n    ctx.AppTree = AppTree\n    return loadGetInitialProps<AppContextType<Router>>(App, {\n      AppTree,\n      Component,\n      router: this,\n      ctx,\n    })\n  }\n\n  abortComponentLoad(as: string): void {\n    if (this.clc) {\n      const e = new Error('Route Cancelled')\n      ;(e as any).cancelled = true\n      Router.events.emit('routeChangeError', e, as)\n      this.clc()\n      this.clc = null\n    }\n  }\n\n  notify(data: RouteInfo): Promise<void> {\n    return this.sub(data, this.components['/_app'].Component)\n  }\n}\n"]},"metadata":{},"sourceType":"script"}