{"ast":null,"code":"\"use strict\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\");\n\nvar _interopRequireWildcard = require(\"@babel/runtime/helpers/interopRequireWildcard\");\n\nexports.__esModule = true;\nexports.default = void 0;\n\nvar _react = _interopRequireWildcard(require(\"react\"));\n\nvar _url = require(\"url\");\n\nvar _utils = require(\"../next-server/lib/utils\");\n\nvar _router = _interopRequireDefault(require(\"./router\"));\n\nvar _router2 = require(\"../next-server/lib/router/router\");\n\nfunction isLocal(href) {\n  const url = (0, _url.parse)(href, false, true);\n  const origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);\n  return !url.host || url.protocol === origin.protocol && url.host === origin.host;\n}\n\nfunction memoizedFormatUrl(formatFunc) {\n  let lastHref = null;\n  let lastAs = null;\n  let lastResult = null;\n  return (href, as) => {\n    if (lastResult && href === lastHref && as === lastAs) {\n      return lastResult;\n    }\n\n    const result = formatFunc(href, as);\n    lastHref = href;\n    lastAs = as;\n    lastResult = result;\n    return result;\n  };\n}\n\nfunction formatUrl(url) {\n  return url && typeof url === 'object' ? (0, _utils.formatWithValidation)(url) : url;\n}\n\nlet observer;\nconst listeners = new Map();\nconst IntersectionObserver = false ? window.IntersectionObserver : null;\nconst prefetched = {};\n\nfunction getObserver() {\n  // Return shared instance of IntersectionObserver if already created\n  if (observer) {\n    return observer;\n  } // Only create shared IntersectionObserver if supported in browser\n\n\n  if (!IntersectionObserver) {\n    return undefined;\n  }\n\n  return observer = new IntersectionObserver(entries => {\n    entries.forEach(entry => {\n      if (!listeners.has(entry.target)) {\n        return;\n      }\n\n      const cb = listeners.get(entry.target);\n\n      if (entry.isIntersecting || entry.intersectionRatio > 0) {\n        observer.unobserve(entry.target);\n        listeners.delete(entry.target);\n        cb();\n      }\n    });\n  }, {\n    rootMargin: '200px'\n  });\n}\n\nconst listenToIntersections = (el, cb) => {\n  const observer = getObserver();\n\n  if (!observer) {\n    return () => {};\n  }\n\n  observer.observe(el);\n  listeners.set(el, cb);\n  return () => {\n    try {\n      observer.unobserve(el);\n    } catch (err) {\n      console.error(err);\n    }\n\n    listeners.delete(el);\n  };\n};\n\nclass Link extends _react.Component {\n  constructor(props) {\n    super(props);\n    this.p = void 0;\n\n    this.cleanUpListeners = () => {};\n\n    this.formatUrls = memoizedFormatUrl((href, asHref) => {\n      return {\n        href: (0, _router2.addBasePath)(formatUrl(href)),\n        as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref\n      };\n    });\n\n    this.linkClicked = e => {\n      const {\n        nodeName,\n        target\n      } = e.currentTarget;\n\n      if (nodeName === 'A' && (target && target !== '_self' || e.metaKey || e.ctrlKey || e.shiftKey || e.nativeEvent && e.nativeEvent.which === 2)) {\n        // ignore click for new tab / new window behavior\n        return;\n      }\n\n      let {\n        href,\n        as\n      } = this.formatUrls(this.props.href, this.props.as);\n\n      if (!isLocal(href)) {\n        // ignore click if it's outside our scope (e.g. https://google.com)\n        return;\n      }\n\n      const {\n        pathname\n      } = window.location;\n      href = (0, _url.resolve)(pathname, href);\n      as = as ? (0, _url.resolve)(pathname, as) : href;\n      e.preventDefault(); //  avoid scroll for urls with anchor refs\n\n      let {\n        scroll\n      } = this.props;\n\n      if (scroll == null) {\n        scroll = as.indexOf('#') < 0;\n      } // replace state instead of push if prop is present\n\n\n      _router.default[this.props.replace ? 'replace' : 'push'](href, as, {\n        shallow: this.props.shallow\n      }).then(success => {\n        if (!success) return;\n\n        if (scroll) {\n          window.scrollTo(0, 0);\n          document.body.focus();\n        }\n      });\n    };\n\n    if (true) {\n      if (props.prefetch) {\n        console.warn('Next.js auto-prefetches automatically based on viewport. The prefetch attribute is no longer needed. More: https://err.sh/vercel/next.js/prefetch-true-deprecated');\n      }\n    }\n\n    this.p = props.prefetch !== false;\n  }\n\n  componentWillUnmount() {\n    this.cleanUpListeners();\n  }\n\n  getPaths() {\n    const {\n      pathname\n    } = window.location;\n    const {\n      href: parsedHref,\n      as: parsedAs\n    } = this.formatUrls(this.props.href, this.props.as);\n    const resolvedHref = (0, _url.resolve)(pathname, parsedHref);\n    return [resolvedHref, parsedAs ? (0, _url.resolve)(pathname, parsedAs) : resolvedHref];\n  }\n\n  handleRef(ref) {\n    if (this.p && IntersectionObserver && ref && ref.tagName) {\n      this.cleanUpListeners();\n      const isPrefetched = prefetched[this.getPaths().join( // Join on an invalid URI character\n      '%')];\n\n      if (!isPrefetched) {\n        this.cleanUpListeners = listenToIntersections(ref, () => {\n          this.prefetch();\n        });\n      }\n    }\n  } // The function is memoized so that no extra lifecycles are needed\n  // as per https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html\n\n\n  prefetch(options) {\n    if (!this.p || true) return; // Prefetch the JSON page if asked (only in the client)\n\n    const paths = this.getPaths(); // We need to handle a prefetch error here since we may be\n    // loading with priority which can reject but we don't\n    // want to force navigation since this is only a prefetch\n\n    _router.default.prefetch(paths[\n    /* href */\n    0], paths[\n    /* asPath */\n    1], options).catch(err => {\n      if (true) {\n        // rethrow to show invalid URL errors\n        throw err;\n      }\n    });\n\n    prefetched[paths.join( // Join on an invalid URI character\n    '%')] = true;\n  }\n\n  render() {\n    let {\n      children\n    } = this.props;\n    const {\n      href,\n      as\n    } = this.formatUrls(this.props.href, this.props.as); // Deprecated. Warning shown by propType check. If the children provided is a string (<Link>example</Link>) we wrap it in an <a> tag\n\n    if (typeof children === 'string') {\n      children = /*#__PURE__*/_react.default.createElement(\"a\", null, children);\n    } // This will return the first child, if multiple are provided it will throw an error\n\n\n    const child = _react.Children.only(children);\n\n    const props = {\n      ref: el => {\n        this.handleRef(el);\n\n        if (child && typeof child === 'object' && child.ref) {\n          if (typeof child.ref === 'function') child.ref(el);else if (typeof child.ref === 'object') {\n            child.ref.current = el;\n          }\n        }\n      },\n      onMouseEnter: e => {\n        if (child.props && typeof child.props.onMouseEnter === 'function') {\n          child.props.onMouseEnter(e);\n        }\n\n        this.prefetch({\n          priority: true\n        });\n      },\n      onClick: e => {\n        if (child.props && typeof child.props.onClick === 'function') {\n          child.props.onClick(e);\n        }\n\n        if (!e.defaultPrevented) {\n          this.linkClicked(e);\n        }\n      }\n    }; // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is\n    // defined, we specify the current 'href', so that repetition is not needed by the user\n\n    if (this.props.passHref || child.type === 'a' && !('href' in child.props)) {\n      props.href = as || href;\n    } // Add the ending slash to the paths. So, we can serve the\n    // \"<page>/index.html\" directly.\n\n\n    if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n      const rewriteUrlForNextExport = require('../next-server/lib/router/rewrite-url-for-export').rewriteUrlForNextExport;\n\n      if (props.href && typeof __NEXT_DATA__ !== 'undefined' && __NEXT_DATA__.nextExport) {\n        props.href = rewriteUrlForNextExport(props.href);\n      }\n    }\n\n    return _react.default.cloneElement(child, props);\n  }\n\n}\n\nif (true) {\n  const warn = (0, _utils.execOnce)(console.error); // This module gets removed by webpack.IgnorePlugin\n\n  const PropTypes = require('prop-types');\n\n  const exact = require('prop-types-exact'); // @ts-ignore the property is supported, when declaring it on the class it outputs an extra bit of code which is not needed.\n\n\n  Link.propTypes = exact({\n    href: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,\n    as: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),\n    prefetch: PropTypes.bool,\n    replace: PropTypes.bool,\n    shallow: PropTypes.bool,\n    passHref: PropTypes.bool,\n    scroll: PropTypes.bool,\n    children: PropTypes.oneOfType([PropTypes.element, (props, propName) => {\n      const value = props[propName];\n\n      if (typeof value === 'string') {\n        warn(`Warning: You're using a string directly inside <Link>. This usage has been deprecated. Please add an <a> tag as child of <Link>`);\n      }\n\n      return null;\n    }]).isRequired\n  });\n}\n\nvar _default = Link;\nexports.default = _default;","map":{"version":3,"sources":["../../client/link.tsx"],"names":["url","origin","lastHref","lastAs","lastResult","href","as","result","formatFunc","listeners","IntersectionObserver","window","prefetched","observer","entries","entry","cb","rootMargin","listenToIntersections","getObserver","console","Component","p","constructor","props","componentWillUnmount","getPaths","resolvedHref","parsedAs","handleRef","ref","isPrefetched","memoizedFormatUrl","formatUrl","asHref","e","nodeName","target","isLocal","scroll","Router","shallow","success","document","prefetch","paths","err","render","children","child","Children","el","onMouseEnter","priority","onClick","process","rewriteUrlForNextExport","require","__NEXT_DATA__","React","warn","PropTypes","exact","Link","replace","passHref","value"],"mappings":";;;;;;;;;AAEA,IAAA,MAAA,GAAA,uBAAA,CAAA,OAAA,CAAA,OAAA,CAAA,CAAA;;AACA,IAAA,IAAA,GAAA,OAAA,CAAA,KAAA,CAAA;;AAEA,IAAA,MAAA,GAAA,OAAA,CAAA,0BAAA,CAAA;;AAKA,IAAA,OAAA,GAAA,sBAAA,CAAA,OAAA,CAAA,UAAA,CAAA,CAAA;;AACA,IAAA,QAAA,GAAA,OAAA,CAAA,kCAAA,CAAA;;AAEA,SAAA,OAAA,CAAA,IAAA,EAAwC;AACtC,QAAMA,GAAG,GAAG,CAAA,GAAA,IAAA,CAAA,KAAA,EAAA,IAAA,EAAA,KAAA,EAAZ,IAAY,CAAZ;AACA,QAAMC,MAAM,GAAG,CAAA,GAAA,IAAA,CAAA,KAAA,EAAM,CAAA,GAAA,MAAA,CAAN,iBAAM,GAAN,EAAA,KAAA,EAAf,IAAe,CAAf;AAEA,SACE,CAACD,GAAG,CAAJ,IAAA,IAAcA,GAAG,CAAHA,QAAAA,KAAiBC,MAAM,CAAvBD,QAAAA,IAAoCA,GAAG,CAAHA,IAAAA,KAAaC,MAAM,CADvE,IAAA;AAQF;;AAAA,SAAA,iBAAA,CAAA,UAAA,EAA8E;AAC5E,MAAIC,QAAoB,GAAxB,IAAA;AACA,MAAIC,MAA8B,GAAlC,IAAA;AACA,MAAIC,UAA+B,GAAnC,IAAA;AACA,SAAO,CAAA,IAAA,EAAA,EAAA,KAAyB;AAC9B,QAAIA,UAAU,IAAIC,IAAI,KAAlBD,QAAAA,IAAmCE,EAAE,KAAzC,MAAA,EAAsD;AACpD,aAAA,UAAA;AAGF;;AAAA,UAAMC,MAA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A,EAA+B;AAC7BoC,QAAAA,IAAI,CAAJA,iIAAI,CAAJA;AAKF;;AAAA,aAAA,IAAA;AAXMC,KAAoB,CAApBA,EARZE;AAAuB,GAAD,CAAtBA;;;eAyBaA,I","sourcesContent":["declare const __NEXT_DATA__: any\n\nimport React, { Children, Component } from 'react'\nimport { parse, resolve, UrlObject } from 'url'\nimport { PrefetchOptions } from '../next-server/lib/router/router'\nimport {\n  execOnce,\n  formatWithValidation,\n  getLocationOrigin,\n} from '../next-server/lib/utils'\nimport Router from './router'\nimport { addBasePath } from '../next-server/lib/router/router'\n\nfunction isLocal(href: string): boolean {\n  const url = parse(href, false, true)\n  const origin = parse(getLocationOrigin(), false, true)\n\n  return (\n    !url.host || (url.protocol === origin.protocol && url.host === origin.host)\n  )\n}\n\ntype Url = string | UrlObject\ntype FormatResult = { href: string; as?: string }\n\nfunction memoizedFormatUrl(formatFunc: (href: Url, as?: Url) => FormatResult) {\n  let lastHref: null | Url = null\n  let lastAs: undefined | null | Url = null\n  let lastResult: null | FormatResult = null\n  return (href: Url, as?: Url) => {\n    if (lastResult && href === lastHref && as === lastAs) {\n      return lastResult\n    }\n\n    const result = formatFunc(href, as)\n    lastHref = href\n    lastAs = as\n    lastResult = result\n    return result\n  }\n}\n\nfunction formatUrl(url: Url): string {\n  return url && typeof url === 'object' ? formatWithValidation(url) : url\n}\n\nexport type LinkProps = {\n  href: Url\n  as?: Url\n  replace?: boolean\n  scroll?: boolean\n  shallow?: boolean\n  passHref?: boolean\n  prefetch?: boolean\n}\n\nlet observer: IntersectionObserver\nconst listeners = new Map<Element, () => void>()\nconst IntersectionObserver =\n  typeof window !== 'undefined' ? window.IntersectionObserver : null\nconst prefetched: { [cacheKey: string]: boolean } = {}\n\nfunction getObserver(): IntersectionObserver | undefined {\n  // Return shared instance of IntersectionObserver if already created\n  if (observer) {\n    return observer\n  }\n\n  // Only create shared IntersectionObserver if supported in browser\n  if (!IntersectionObserver) {\n    return undefined\n  }\n\n  return (observer = new IntersectionObserver(\n    (entries) => {\n      entries.forEach((entry) => {\n        if (!listeners.has(entry.target)) {\n          return\n        }\n\n        const cb = listeners.get(entry.target)!\n        if (entry.isIntersecting || entry.intersectionRatio > 0) {\n          observer.unobserve(entry.target)\n          listeners.delete(entry.target)\n          cb()\n        }\n      })\n    },\n    { rootMargin: '200px' }\n  ))\n}\n\nconst listenToIntersections = (el: Element, cb: () => void) => {\n  const observer = getObserver()\n  if (!observer) {\n    return () => {}\n  }\n\n  observer.observe(el)\n  listeners.set(el, cb)\n  return () => {\n    try {\n      observer.unobserve(el)\n    } catch (err) {\n      console.error(err)\n    }\n    listeners.delete(el)\n  }\n}\n\nclass Link extends Component<LinkProps> {\n  p: boolean\n\n  constructor(props: LinkProps) {\n    super(props)\n    if (process.env.NODE_ENV !== 'production') {\n      if (props.prefetch) {\n        console.warn(\n          'Next.js auto-prefetches automatically based on viewport. The prefetch attribute is no longer needed. More: https://err.sh/vercel/next.js/prefetch-true-deprecated'\n        )\n      }\n    }\n    this.p = props.prefetch !== false\n  }\n\n  cleanUpListeners = () => {}\n\n  componentWillUnmount(): void {\n    this.cleanUpListeners()\n  }\n\n  getPaths(): string[] {\n    const { pathname } = window.location\n    const { href: parsedHref, as: parsedAs } = this.formatUrls(\n      this.props.href,\n      this.props.as\n    )\n    const resolvedHref = resolve(pathname, parsedHref)\n    return [resolvedHref, parsedAs ? resolve(pathname, parsedAs) : resolvedHref]\n  }\n\n  handleRef(ref: Element): void {\n    if (this.p && IntersectionObserver && ref && ref.tagName) {\n      this.cleanUpListeners()\n\n      const isPrefetched =\n        prefetched[\n          this.getPaths().join(\n            // Join on an invalid URI character\n            '%'\n          )\n        ]\n      if (!isPrefetched) {\n        this.cleanUpListeners = listenToIntersections(ref, () => {\n          this.prefetch()\n        })\n      }\n    }\n  }\n\n  // The function is memoized so that no extra lifecycles are needed\n  // as per https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html\n  formatUrls = memoizedFormatUrl((href, asHref) => {\n    return {\n      href: addBasePath(formatUrl(href)),\n      as: asHref ? addBasePath(formatUrl(asHref)) : asHref,\n    }\n  })\n\n  linkClicked = (e: React.MouseEvent): void => {\n    const { nodeName, target } = e.currentTarget as HTMLAnchorElement\n    if (\n      nodeName === 'A' &&\n      ((target && target !== '_self') ||\n        e.metaKey ||\n        e.ctrlKey ||\n        e.shiftKey ||\n        (e.nativeEvent && e.nativeEvent.which === 2))\n    ) {\n      // ignore click for new tab / new window behavior\n      return\n    }\n\n    let { href, as } = this.formatUrls(this.props.href, this.props.as)\n\n    if (!isLocal(href)) {\n      // ignore click if it's outside our scope (e.g. https://google.com)\n      return\n    }\n\n    const { pathname } = window.location\n    href = resolve(pathname, href)\n    as = as ? resolve(pathname, as) : href\n\n    e.preventDefault()\n\n    //  avoid scroll for urls with anchor refs\n    let { scroll } = this.props\n    if (scroll == null) {\n      scroll = as.indexOf('#') < 0\n    }\n\n    // replace state instead of push if prop is present\n    Router[this.props.replace ? 'replace' : 'push'](href, as, {\n      shallow: this.props.shallow,\n    }).then((success: boolean) => {\n      if (!success) return\n      if (scroll) {\n        window.scrollTo(0, 0)\n        document.body.focus()\n      }\n    })\n  }\n\n  prefetch(options?: PrefetchOptions): void {\n    if (!this.p || typeof window === 'undefined') return\n    // Prefetch the JSON page if asked (only in the client)\n    const paths = this.getPaths()\n    // We need to handle a prefetch error here since we may be\n    // loading with priority which can reject but we don't\n    // want to force navigation since this is only a prefetch\n    Router.prefetch(paths[/* href */ 0], paths[/* asPath */ 1], options).catch(\n      (err) => {\n        if (process.env.NODE_ENV !== 'production') {\n          // rethrow to show invalid URL errors\n          throw err\n        }\n      }\n    )\n    prefetched[\n      paths.join(\n        // Join on an invalid URI character\n        '%'\n      )\n    ] = true\n  }\n\n  render() {\n    let { children } = this.props\n    const { href, as } = this.formatUrls(this.props.href, this.props.as)\n    // Deprecated. Warning shown by propType check. If the children provided is a string (<Link>example</Link>) we wrap it in an <a> tag\n    if (typeof children === 'string') {\n      children = <a>{children}</a>\n    }\n\n    // This will return the first child, if multiple are provided it will throw an error\n    const child: any = Children.only(children)\n    const props: {\n      onMouseEnter: React.MouseEventHandler\n      onClick: React.MouseEventHandler\n      href?: string\n      ref?: any\n    } = {\n      ref: (el: any) => {\n        this.handleRef(el)\n\n        if (child && typeof child === 'object' && child.ref) {\n          if (typeof child.ref === 'function') child.ref(el)\n          else if (typeof child.ref === 'object') {\n            child.ref.current = el\n          }\n        }\n      },\n      onMouseEnter: (e: React.MouseEvent) => {\n        if (child.props && typeof child.props.onMouseEnter === 'function') {\n          child.props.onMouseEnter(e)\n        }\n        this.prefetch({ priority: true })\n      },\n      onClick: (e: React.MouseEvent) => {\n        if (child.props && typeof child.props.onClick === 'function') {\n          child.props.onClick(e)\n        }\n        if (!e.defaultPrevented) {\n          this.linkClicked(e)\n        }\n      },\n    }\n\n    // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is\n    // defined, we specify the current 'href', so that repetition is not needed by the user\n    if (\n      this.props.passHref ||\n      (child.type === 'a' && !('href' in child.props))\n    ) {\n      props.href = as || href\n    }\n\n    // Add the ending slash to the paths. So, we can serve the\n    // \"<page>/index.html\" directly.\n    if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n      const rewriteUrlForNextExport = require('../next-server/lib/router/rewrite-url-for-export')\n        .rewriteUrlForNextExport\n      if (\n        props.href &&\n        typeof __NEXT_DATA__ !== 'undefined' &&\n        __NEXT_DATA__.nextExport\n      ) {\n        props.href = rewriteUrlForNextExport(props.href)\n      }\n    }\n\n    return React.cloneElement(child, props)\n  }\n}\n\nif (process.env.NODE_ENV === 'development') {\n  const warn = execOnce(console.error)\n\n  // This module gets removed by webpack.IgnorePlugin\n  const PropTypes = require('prop-types')\n  const exact = require('prop-types-exact')\n  // @ts-ignore the property is supported, when declaring it on the class it outputs an extra bit of code which is not needed.\n  Link.propTypes = exact({\n    href: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,\n    as: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),\n    prefetch: PropTypes.bool,\n    replace: PropTypes.bool,\n    shallow: PropTypes.bool,\n    passHref: PropTypes.bool,\n    scroll: PropTypes.bool,\n    children: PropTypes.oneOfType([\n      PropTypes.element,\n      (props: any, propName: string) => {\n        const value = props[propName]\n\n        if (typeof value === 'string') {\n          warn(\n            `Warning: You're using a string directly inside <Link>. This usage has been deprecated. Please add an <a> tag as child of <Link>`\n          )\n        }\n\n        return null\n      },\n    ]).isRequired,\n  })\n}\n\nexport default Link\n"]},"metadata":{},"sourceType":"script"}