{"ast":null,"code":"\"use strict\";\n\nvar _interopRequireDefault = require(\"@babel/runtime-corejs2/helpers/interopRequireDefault\");\n\nvar _regenerator = _interopRequireDefault(require(\"@babel/runtime-corejs2/regenerator\"));\n\nvar _asyncToGenerator2 = _interopRequireDefault(require(\"@babel/runtime-corejs2/helpers/asyncToGenerator\"));\n\nvar _slicedToArray2 = _interopRequireDefault(require(\"@babel/runtime-corejs2/helpers/slicedToArray\"));\n\nvar _keys = _interopRequireDefault(require(\"@babel/runtime-corejs2/core-js/object/keys\"));\n\nvar _typeof2 = _interopRequireDefault(require(\"@babel/runtime-corejs2/helpers/typeof\"));\n\nvar _assign = _interopRequireDefault(require(\"@babel/runtime-corejs2/core-js/object/assign\"));\n\nvar _promise = _interopRequireDefault(require(\"@babel/runtime-corejs2/core-js/promise\"));\n\nvar _classCallCheck2 = _interopRequireDefault(require(\"@babel/runtime-corejs2/helpers/classCallCheck\"));\n\nvar _createClass2 = _interopRequireDefault(require(\"@babel/runtime-corejs2/helpers/createClass\"));\n\nvar _defineProperty = _interopRequireDefault(require(\"@babel/runtime-corejs2/core-js/object/define-property\"));\n\nvar __importDefault = void 0 && (void 0).__importDefault || function (mod) {\n  return mod && mod.__esModule ? mod : {\n    \"default\": mod\n  };\n};\n\n(0, _defineProperty[\"default\"])(exports, \"__esModule\", {\n  value: true\n});\n\nvar url_1 = require(\"url\");\n\nvar mitt_1 = __importDefault(require(\"../mitt\"));\n\nvar utils_1 = require(\"../utils\");\n\nvar is_dynamic_1 = require(\"./utils/is-dynamic\");\n\nvar route_matcher_1 = require(\"./utils/route-matcher\");\n\nvar route_regex_1 = require(\"./utils/route-regex\");\n\nvar basePath = process.env.__NEXT_ROUTER_BASEPATH || '';\n\nfunction addBasePath(path) {\n  return path.indexOf(basePath) !== 0 ? basePath + path : path;\n}\n\nexports.addBasePath = addBasePath;\n\nfunction delBasePath(path) {\n  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;\n}\n\nexports.delBasePath = delBasePath;\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(utils_1.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  function Router(pathname, query, as, _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    (0, _classCallCheck2[\"default\"])(this, Router);\n    // Static Data Cache\n    this.sdc = {};\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', utils_1.formatWithValidation({\n          pathname: _pathname,\n          query: _query\n        }), utils_1.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 && url_1.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/zeit/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(url_1.parse(asPath).pathname);\n      return false && _this.sdc[pathname] ? _promise[\"default\"].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 _url_1$parse = url_1.parse(asPath, true),\n          pathname = _url_1$parse.pathname,\n          query = _url_1$parse.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    is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;\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 (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('replaceState', utils_1.formatWithValidation({\n          pathname: pathname,\n          query: query\n        }), as);\n      }\n\n      window.addEventListener('popstate', this.onPopState);\n    }\n  } // @deprecated backwards compatibility even though it's a private method.\n\n\n  (0, _createClass2[\"default\"])(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 = (0, _assign[\"default\"])((0, _assign[\"default\"])({}, 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[\"default\"](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_1.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 = (0, _typeof2[\"default\"])(_url) === 'object' ? utils_1.formatWithValidation(_url) : _url;\n        var as = (0, _typeof2[\"default\"])(_as) === 'object' ? utils_1.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 _url_1$parse2 = url_1.parse(url, true),\n            pathname = _url_1$parse2.pathname,\n            query = _url_1$parse2.query,\n            protocol = _url_1$parse2.protocol;\n\n        if (!pathname || protocol) {\n          if (true) {\n            throw new Error(\"Invalid href passed to router: \".concat(url, \" https://err.sh/zeit/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 (is_dynamic_1.isDynamicRoute(route)) {\n          var _url_1$parse3 = url_1.parse(as),\n              asPathname = _url_1$parse3.pathname;\n\n          var routeRegex = route_regex_1.getRouteRegex(route);\n          var routeMatch = route_matcher_1.getRouteMatcher(routeRegex)(asPathname);\n\n          if (!routeMatch) {\n            var missingParams = (0, _keys[\"default\"])(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/zeit/next.js/incompatible-href-as\"));\n            }\n          } else {\n            // Merge params into `query`, overwriting any specified in search\n            (0, _assign[\"default\"])(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);\n\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        }, 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' || utils_1.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[\"default\"].resolve(cachedRouteInfo);\n      }\n\n      var handleError = function handleError(err, loadErrorFail) {\n        return new _promise[\"default\"](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[\"default\"](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[\"default\"](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      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 = (0, _slicedToArray2[\"default\"])(_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 = (0, _slicedToArray2[\"default\"])(_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 = (0, _slicedToArray2[\"default\"])(_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[\"default\"](function (resolve, reject) {\n        var _url_1$parse4 = url_1.parse(url),\n            pathname = _url_1$parse4.pathname,\n            protocol = _url_1$parse4.protocol;\n\n        if (!pathname || protocol) {\n          if (true) {\n            throw new Error(\"Invalid href passed to router: \".concat(url, \" https://err.sh/zeit/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\n        _promise[\"default\"].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 = (0, _asyncToGenerator2[\"default\"])( /*#__PURE__*/_regenerator[\"default\"].mark(function _callee(route) {\n        var cancelled, cancel, componentResult, error;\n        return _regenerator[\"default\"].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 utils_1.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      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  return Router;\n}();\n\nexports[\"default\"] = Router;\nRouter.events = mitt_1[\"default\"]();","map":{"version":3,"sources":["/Users/captainsafia/github.com/nteract/commuter/node_modules/next/dist/next-server/lib/router/router.js"],"names":["__importDefault","mod","__esModule","exports","value","url_1","require","mitt_1","utils_1","is_dynamic_1","route_matcher_1","route_regex_1","basePath","process","env","__NEXT_ROUTER_BASEPATH","addBasePath","path","indexOf","delBasePath","substr","length","toRoute","replace","prepareRoute","fetchNextData","pathname","query","isServerRender","cb","attempts","getResponse","fetch","formatWithValidation","__NEXT_DATA__","buildId","credentials","then","res","ok","status","Error","json","data","err","code","Router","as","initialProps","pageLoader","App","wrapApp","Component","subscription","isFallback","sdc","onPopState","e","state","changeState","getURL","isSsr","asPath","parse","url","_bps","options","console","warn","_getStaticData","resolve","_getServerData","route","components","props","__N_SSG","__N_SSP","events","isDynamicRoute","autoExport","sub","clc","_wrapApp","window","addEventListener","newData","notify","location","reload","history","back","change","method","_url","_as","reject","_h","ST","performance","mark","__NEXT_EXPORT_TRAILING_SLASH","rewriteUrlForNextExport","nextExport","abortComponentLoad","onlyAHashChange","emit","scrollToHash","protocol","urlIsNew","shallow","asPathname","routeRegex","getRouteRegex","routeMatch","getRouteMatcher","missingParams","groups","filter","param","join","getRouteInfo","routeInfo","error","cancelled","appComp","next","isPrerendered","getInitialProps","origGetInitialProps","set","cachedRouteInfo","handleError","loadErrorFail","href","fetchComponent","page","gipErr","isValidElementType","_getData","split","oldUrlNoHash","oldHash","newUrlNoHash","newHash","hash","scrollTo","idEl","document","getElementById","scrollIntoView","nameEl","getElementsByName","all","prefetchData","priority","cancel","loadPage","componentResult","fn","ctx","AppTree","loadGetInitialProps","router"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,eAAe,GAAI,UAAQ,SAAKA,eAAd,IAAkC,UA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AAAA,SAAS,EAATA,SAFoC;AAGpC8G,QAAAA,MAAM,EAAE,IAH4B;AAIpCH,QAAAA,GAAG,EAAHA;AAJoC,OAAjC,CAAP;AAMH;;;uCACkBhH,E,EAAI;AACnB,UAAI,KAAKkC,GAAT,EAAc;AACV,YAAMxB,CAAC,GAAG,IAAIhB,KAAJ,CAAU,iBAAV,CAAV;AACAgB,QAAAA,CAAC,CAACkE,SAAF,GAAc,IAAd;AACA7E,QAAAA,MAAM,CAAC+B,MAAP,CAAc4B,IAAd,CAAmB,kBAAnB,EAAuChD,CAAvC,EAA0CV,EAA1C;AACA,aAAKkC,GAAL;AACA,aAAKA,GAAL,GAAW,IAAX;AACH;AACJ;;;2BACMtC,I,EAAM;AACT,WAAKqC,GAAL,CAASrC,IAAT,EAAe,KAAK8B,UAAL,CAAgB,OAAhB,EAAyBrB,SAAxC;AACH;;;6CApZ+BY,G,EAAK;AACjC,UAAInD,OAAO,CAACC,GAAR,CAAYsF,4BAAhB,EAA8C;AAC1C,YAAMC,uBAAuB,GAAG/F,OAAO,CAAC,0BAAD,CAAP,CAC3B+F,uBADL;;AAEA,eAAOA,uBAAuB,CAACrC,GAAD,CAA9B;AACH,OAJD,MAKK;AACD,eAAOA,GAAP;AACH;AACJ;;;;;AA6YL7D,OAAO,WAAP,GAAkB2C,MAAlB;AACAA,MAAM,CAAC+B,MAAP,GAAgBtE,MAAM,WAAN,EAAhB","sourcesContent":["\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst url_1 = require(\"url\");\nconst mitt_1 = __importDefault(require(\"../mitt\"));\nconst utils_1 = require(\"../utils\");\nconst is_dynamic_1 = require(\"./utils/is-dynamic\");\nconst route_matcher_1 = require(\"./utils/route-matcher\");\nconst route_regex_1 = require(\"./utils/route-regex\");\nconst basePath = process.env.__NEXT_ROUTER_BASEPATH || '';\nfunction addBasePath(path) {\n    return path.indexOf(basePath) !== 0 ? basePath + path : path;\n}\nexports.addBasePath = addBasePath;\nfunction delBasePath(path) {\n    return path.indexOf(basePath) === 0\n        ? path.substr(basePath.length) || '/'\n        : path;\n}\nexports.delBasePath = delBasePath;\nfunction toRoute(path) {\n    return path.replace(/\\/$/, '') || '/';\n}\nconst prepareRoute = (path) => toRoute(!path || path === '/' ? '/index' : path);\nfunction fetchNextData(pathname, query, isServerRender, cb) {\n    let attempts = isServerRender ? 3 : 1;\n    function getResponse() {\n        return fetch(utils_1.formatWithValidation({\n            pathname: addBasePath(\n            // @ts-ignore __NEXT_DATA__\n            `/_next/data/${__NEXT_DATA__.buildId}${delBasePath(pathname)}.json`),\n            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(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    return getResponse()\n        .then(data => {\n        return cb ? cb(data) : data;\n    })\n        .catch((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        throw err;\n    });\n}\nclass Router {\n    constructor(pathname, query, as, { initialProps, pageLoader, App, wrapApp, Component, err, subscription, isFallback, }) {\n        // Static Data Cache\n        this.sdc = {};\n        this.onPopState = (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                const { pathname, query } = this;\n                this.changeState('replaceState', utils_1.formatWithValidation({ pathname, query }), utils_1.getURL());\n                return;\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 (e.state &&\n                this.isSsr &&\n                e.state.as === this.asPath &&\n                url_1.parse(e.state.url).pathname === this.pathname) {\n                return;\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            const { url, as, options } = e.state;\n            if (process.env.NODE_ENV !== 'production') {\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/zeit/next.js/popstate-state-empty');\n                }\n            }\n            this.replace(url, as, options);\n        };\n        this._getStaticData = (asPath) => {\n            const pathname = prepareRoute(url_1.parse(asPath).pathname);\n            return process.env.NODE_ENV === 'production' && this.sdc[pathname]\n                ? Promise.resolve(this.sdc[pathname])\n                : fetchNextData(pathname, null, this.isSsr, data => (this.sdc[pathname] = data));\n        };\n        this._getServerData = (asPath) => {\n            let { pathname, query } = url_1.parse(asPath, true);\n            pathname = prepareRoute(pathname);\n            return fetchNextData(pathname, query, this.isSsr);\n        };\n        // represents the current component key\n        this.route = toRoute(pathname);\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        this.components['/_app'] = { Component: App };\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        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            is_dynamic_1.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        this.isFallback = isFallback;\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('replaceState', utils_1.formatWithValidation({ pathname, query }), as);\n            }\n            window.addEventListener('popstate', this.onPopState);\n        }\n    }\n    // @deprecated backwards compatibility even though it's a private method.\n    static _rewriteUrlForNextExport(url) {\n        if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n            const rewriteUrlForNextExport = require('./rewrite-url-for-export')\n                .rewriteUrlForNextExport;\n            return rewriteUrlForNextExport(url);\n        }\n        else {\n            return url;\n        }\n    }\n    update(route, mod) {\n        const Component = mod.default || mod;\n        const data = this.components[route];\n        if (!data) {\n            throw new Error(`Cannot update unavailable route: ${route}`);\n        }\n        const newData = Object.assign(Object.assign({}, data), { Component, __N_SSG: mod.__N_SSG, __N_SSP: mod.__N_SSP });\n        this.components[route] = newData;\n        // pages/_app.js updated\n        if (route === '/_app') {\n            this.notify(this.components[this.route]);\n            return;\n        }\n        if (route === this.route) {\n            this.notify(newData);\n        }\n    }\n    reload() {\n        window.location.reload();\n    }\n    /**\n     * Go back in history\n     */\n    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    push(url, as = url, options = {}) {\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    replace(url, as = url, options = {}) {\n        return this.change('replaceState', url, as, options);\n    }\n    change(method, _url, _as, options) {\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 (utils_1.ST) {\n                performance.mark('routeChange');\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' ? utils_1.formatWithValidation(_url) : _url;\n            let as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;\n            url = addBasePath(url);\n            as = addBasePath(as);\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            this.abortComponentLoad(as);\n            // 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            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            const { pathname, query, protocol } = url_1.parse(url, true);\n            if (!pathname || protocol) {\n                if (process.env.NODE_ENV !== 'production') {\n                    throw new Error(`Invalid href passed to router: ${url} https://err.sh/zeit/next.js/invalid-href-passed`);\n                }\n                return resolve(false);\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            const route = toRoute(pathname);\n            const { shallow = false } = options;\n            if (is_dynamic_1.isDynamicRoute(route)) {\n                const { pathname: asPathname } = url_1.parse(as);\n                const routeRegex = route_regex_1.getRouteRegex(route);\n                const routeMatch = route_matcher_1.getRouteMatcher(routeRegex)(asPathname);\n                if (!routeMatch) {\n                    const missingParams = Object.keys(routeRegex.groups).filter(param => !query[param]);\n                    if (missingParams.length > 0) {\n                        if (process.env.NODE_ENV !== 'production') {\n                            console.warn(`Mismatching \\`as\\` and \\`href\\` failed to manually provide ` +\n                                `the params: ${missingParams.join(', ')} in the \\`href\\`'s \\`query\\``);\n                        }\n                        return reject(new Error(`The provided \\`as\\` value (${asPathname}) is incompatible with the \\`href\\` value (${route}). ` +\n                            `Read more: https://err.sh/zeit/next.js/incompatible-href-as`));\n                    }\n                }\n                else {\n                    // Merge params into `query`, overwriting any specified in search\n                    Object.assign(query, routeMatch);\n                }\n            }\n            Router.events.emit('routeChangeStart', as);\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(routeInfo => {\n                const { error } = routeInfo;\n                if (error && error.cancelled) {\n                    return resolve(false);\n                }\n                Router.events.emit('beforeHistoryChange', as);\n                this.changeState(method, url, as, options);\n                if (process.env.NODE_ENV !== 'production') {\n                    const appComp = this.components['/_app'].Component;\n                    window.next.isPrerendered =\n                        appComp.getInitialProps === appComp.origGetInitialProps &&\n                            !routeInfo.Component.getInitialProps;\n                }\n                this.set(route, pathname, query, as, routeInfo);\n                if (error) {\n                    Router.events.emit('routeChangeError', error, as);\n                    throw error;\n                }\n                Router.events.emit('routeChangeComplete', as);\n                return resolve(true);\n            }, reject);\n        });\n    }\n    changeState(method, url, as, options = {}) {\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            if (typeof window.history[method] === 'undefined') {\n                console.error(`Warning: window.history.${method} is not available`);\n                return;\n            }\n        }\n        if (method !== 'pushState' || utils_1.getURL() !== as) {\n            window.history[method]({\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            '', as);\n        }\n    }\n    getRouteInfo(route, pathname, query, as, shallow = false) {\n        const cachedRouteInfo = this.components[route];\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        const handleError = (err, loadErrorFail) => {\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                    // So, doing a hard reload is the proper way to deal with this.\n                    window.location.href = as;\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                if (err.cancelled) {\n                    // @ts-ignore TODO: fix the control flow here\n                    return resolve({ error: err });\n                }\n                resolve(this.fetchComponent('/_error')\n                    .then(res => {\n                    const { page: Component } = res;\n                    const routeInfo = { Component, err };\n                    return new Promise(resolve => {\n                        this.getInitialProps(Component, {\n                            err,\n                            pathname,\n                            query,\n                        }).then(props => {\n                            routeInfo.props = props;\n                            routeInfo.error = err;\n                            resolve(routeInfo);\n                        }, gipErr => {\n                            console.error('Error in error page `getInitialProps`: ', gipErr);\n                            routeInfo.error = err;\n                            routeInfo.props = {};\n                            resolve(routeInfo);\n                        });\n                    });\n                })\n                    .catch(err => handleError(err, true)));\n            });\n        };\n        return new Promise((resolve, reject) => {\n            if (cachedRouteInfo) {\n                return resolve(cachedRouteInfo);\n            }\n            this.fetchComponent(route).then(res => resolve({\n                Component: res.page,\n                __N_SSG: res.mod.__N_SSG,\n                __N_SSP: res.mod.__N_SSP,\n            }), reject);\n        })\n            .then((routeInfo) => {\n            const { Component, __N_SSG, __N_SSP } = routeInfo;\n            if (process.env.NODE_ENV !== 'production') {\n                const { isValidElementType } = require('react-is');\n                if (!isValidElementType(Component)) {\n                    throw new Error(`The default export is not a React Component in page: \"${pathname}\"`);\n                }\n            }\n            return this._getData(() => __N_SSG\n                ? this._getStaticData(as)\n                : __N_SSP\n                    ? this._getServerData(as)\n                    : this.getInitialProps(Component, \n                    // we provide AppTree later so this needs to be `any`\n                    {\n                        pathname,\n                        query,\n                        asPath: as,\n                    })).then(props => {\n                routeInfo.props = props;\n                this.components[route] = routeInfo;\n                return routeInfo;\n            });\n        })\n            .catch(handleError);\n    }\n    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        this.notify(data);\n    }\n    /**\n     * Callback to execute before replacing router state\n     * @param cb callback to be executed\n     */\n    beforePopState(cb) {\n        this._bps = cb;\n    }\n    onlyAHashChange(as) {\n        if (!this.asPath)\n            return false;\n        const [oldUrlNoHash, oldHash] = this.asPath.split('#');\n        const [newUrlNoHash, newHash] = as.split('#');\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        // If the urls are change, there's more than a hash change\n        if (oldUrlNoHash !== newUrlNoHash) {\n            return false;\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    scrollToHash(as) {\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        // 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    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    prefetch(url, asPath = url, options = {}) {\n        return new Promise((resolve, reject) => {\n            const { pathname, protocol } = url_1.parse(url);\n            if (!pathname || protocol) {\n                if (process.env.NODE_ENV !== 'production') {\n                    throw new Error(`Invalid href passed to router: ${url} https://err.sh/zeit/next.js/invalid-href-passed`);\n                }\n                return;\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    async fetchComponent(route) {\n        let cancelled = false;\n        const cancel = (this.clc = () => {\n            cancelled = true;\n        });\n        route = delBasePath(route);\n        const componentResult = await this.pageLoader.loadPage(route);\n        if (cancelled) {\n            const error = new Error(`Abort fetching component for route: \"${route}\"`);\n            error.cancelled = true;\n            throw error;\n        }\n        if (cancel === this.clc) {\n            this.clc = null;\n        }\n        return componentResult;\n    }\n    _getData(fn) {\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            if (cancelled) {\n                const err = new Error('Loading initial props cancelled');\n                err.cancelled = true;\n                throw err;\n            }\n            return data;\n        });\n    }\n    getInitialProps(Component, ctx) {\n        const { Component: App } = this.components['/_app'];\n        const AppTree = this._wrapApp(App);\n        ctx.AppTree = AppTree;\n        return utils_1.loadGetInitialProps(App, {\n            AppTree,\n            Component,\n            router: this,\n            ctx,\n        });\n    }\n    abortComponentLoad(as) {\n        if (this.clc) {\n            const 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    notify(data) {\n        this.sub(data, this.components['/_app'].Component);\n    }\n}\nexports.default = Router;\nRouter.events = mitt_1.default();\n"]},"metadata":{},"sourceType":"script"}