{"version":3,"sources":["../../../src/lib/load-custom-routes.ts"],"sourcesContent":["import type { NextConfig } from '../server/config'\nimport type { Token } from 'next/dist/compiled/path-to-regexp'\n\nimport { bold, yellow } from './picocolors'\nimport { escapeStringRegexp } from '../shared/lib/escape-regexp'\nimport { tryToParsePath } from './try-to-parse-path'\nimport { allowedStatusCodes } from './redirect-status'\nimport { isFullStringUrl } from './url'\nimport { NEXT_NAV_DEPLOYMENT_ID_HEADER } from './constants'\n\nexport type RouteHas =\n  | {\n      type: 'header' | 'cookie' | 'query'\n      key: string\n      value?: string\n    }\n  | {\n      type: 'host'\n      key?: undefined\n      value: string\n    }\n\nexport type Rewrite = {\n  source: string\n  destination: string\n  basePath?: false\n  locale?: false\n  has?: RouteHas[]\n  missing?: RouteHas[]\n\n  /**\n   * @internal - used internally for routing\n   */\n  internal?: boolean\n\n  /**\n   * @internal - used internally for routing\n   */\n  regex?: string\n}\n\nexport type Header = {\n  source: string\n  basePath?: false\n  locale?: false\n  headers: Array<{ key: string; value: string }>\n  has?: RouteHas[]\n  missing?: RouteHas[]\n\n  /**\n   * @internal - used internally for routing\n   */\n  internal?: boolean\n}\n\n// internal type used for validation (not user facing)\nexport type Redirect = {\n  source: string\n  destination: string\n  basePath?: false\n  locale?: false\n  has?: RouteHas[]\n  missing?: RouteHas[]\n  priority?: boolean\n\n  /**\n   * @internal - used internally for routing\n   */\n  internal?: boolean\n} & (\n  | {\n      statusCode?: never\n      permanent: boolean\n    }\n  | {\n      statusCode: number\n      permanent?: never\n    }\n)\n\nexport type Middleware = {\n  source: string\n  locale?: false\n  has?: RouteHas[]\n  missing?: RouteHas[]\n}\n\nconst allowedHasTypes = new Set(['header', 'cookie', 'query', 'host'])\nconst namedGroupsRegex = /\\(\\?<([a-zA-Z][a-zA-Z0-9]*)>/g\n\nexport function normalizeRouteRegex(regex: string) {\n  // clean up un-necessary escaping from regex.source which turns / into \\\\/\n  return regex.replace(/\\\\\\//g, '/')\n}\n\nfunction checkRedirect(route: Redirect): {\n  invalidParts: string[]\n  hadInvalidStatus: boolean\n} {\n  const invalidParts: string[] = []\n  let hadInvalidStatus: boolean = false\n\n  if (route.statusCode && !allowedStatusCodes.has(route['statusCode'])) {\n    hadInvalidStatus = true\n    invalidParts.push(`\\`statusCode\\` is not undefined or valid statusCode`)\n  }\n  if (typeof route.permanent !== 'boolean' && !route['statusCode']) {\n    invalidParts.push(`\\`permanent\\` is not set to \\`true\\` or \\`false\\``)\n  }\n\n  return {\n    invalidParts,\n    hadInvalidStatus,\n  }\n}\n\nfunction checkHeader(route: Header): string[] {\n  const invalidParts: string[] = []\n\n  if (!Array.isArray(route.headers)) {\n    invalidParts.push('`headers` field must be an array')\n  } else if (route.headers.length === 0) {\n    invalidParts.push('`headers` field cannot be empty')\n  } else {\n    for (const header of route.headers) {\n      if (!header || typeof header !== 'object') {\n        invalidParts.push(\n          \"`headers` items must be object with { key: '', value: '' }\"\n        )\n        break\n      }\n      if (typeof header.key !== 'string') {\n        invalidParts.push('`key` in header item must be string')\n        break\n      }\n      if (typeof header.value !== 'string') {\n        invalidParts.push('`value` in header item must be string')\n        break\n      }\n    }\n  }\n  return invalidParts\n}\n\nexport type RouteType = 'rewrite' | 'redirect' | 'header'\n\nexport function checkCustomRoutes(\n  routes: Redirect[] | Header[] | Rewrite[] | Middleware[],\n  type: RouteType | 'middleware'\n): void {\n  if (!Array.isArray(routes)) {\n    console.error(\n      `Error: ${type}s must return an array, received ${typeof routes}.\\n` +\n        `See here for more info: https://nextjs.org/docs/messages/routes-must-be-array`\n    )\n    process.exit(1)\n  }\n\n  let numInvalidRoutes = 0\n  let hadInvalidStatus = false\n  let hadInvalidHas = false\n  let hadInvalidMissing = false\n\n  const allowedKeys = new Set<string>(['source', 'locale', 'has', 'missing'])\n\n  if (type === 'rewrite') {\n    allowedKeys.add('basePath')\n    allowedKeys.add('destination')\n  }\n  if (type === 'redirect') {\n    allowedKeys.add('basePath')\n    allowedKeys.add('statusCode')\n    allowedKeys.add('permanent')\n    allowedKeys.add('destination')\n  }\n  if (type === 'header') {\n    allowedKeys.add('basePath')\n    allowedKeys.add('headers')\n  }\n\n  for (const route of routes) {\n    if (!route || typeof route !== 'object') {\n      console.error(\n        `The route ${JSON.stringify(\n          route\n        )} is not a valid object with \\`source\\`${\n          type !== 'middleware'\n            ? ` and \\`${type === 'header' ? 'headers' : 'destination'}\\``\n            : ''\n        }`\n      )\n      numInvalidRoutes++\n      continue\n    }\n\n    if (\n      type === 'rewrite' &&\n      (route as Rewrite).basePath === false &&\n      !(\n        (route as Rewrite).destination.startsWith('http://') ||\n        (route as Rewrite).destination.startsWith('https://')\n      )\n    ) {\n      console.error(\n        `The route ${\n          (route as Rewrite).source\n        } rewrites urls outside of the basePath. Please use a destination that starts with \\`http://\\` or \\`https://\\` https://nextjs.org/docs/messages/invalid-external-rewrite`\n      )\n      numInvalidRoutes++\n      continue\n    }\n\n    const keys = Object.keys(route)\n    const invalidKeys = keys.filter((key) => !allowedKeys.has(key))\n    const invalidParts: string[] = []\n\n    if (\n      'basePath' in route &&\n      typeof route.basePath !== 'undefined' &&\n      route.basePath !== false\n    ) {\n      invalidParts.push('`basePath` must be undefined or false')\n    }\n\n    if (typeof route.locale !== 'undefined' && route.locale !== false) {\n      invalidParts.push('`locale` must be undefined or false')\n    }\n\n    const checkInvalidHasMissing = (\n      items: any,\n      fieldName: 'has' | 'missing'\n    ) => {\n      let hadInvalidItem = false\n\n      if (typeof items !== 'undefined' && !Array.isArray(items)) {\n        invalidParts.push(\n          `\\`${fieldName}\\` must be undefined or valid has object`\n        )\n        hadInvalidItem = true\n      } else if (items) {\n        const invalidHasItems = []\n\n        for (const hasItem of items) {\n          let invalidHasParts = []\n\n          if (!allowedHasTypes.has(hasItem.type)) {\n            invalidHasParts.push(`invalid type \"${hasItem.type}\"`)\n          }\n          if (typeof hasItem.key !== 'string' && hasItem.type !== 'host') {\n            invalidHasParts.push(`invalid key \"${hasItem.key}\"`)\n          }\n          if (\n            typeof hasItem.value !== 'undefined' &&\n            typeof hasItem.value !== 'string'\n          ) {\n            invalidHasParts.push(`invalid value \"${hasItem.value}\"`)\n          }\n          if (typeof hasItem.value === 'undefined' && hasItem.type === 'host') {\n            invalidHasParts.push(`value is required for \"host\" type`)\n          }\n\n          if (invalidHasParts.length > 0) {\n            invalidHasItems.push(\n              `${invalidHasParts.join(', ')} for ${JSON.stringify(hasItem)}`\n            )\n          }\n        }\n\n        if (invalidHasItems.length > 0) {\n          hadInvalidItem = true\n          const itemStr = `item${invalidHasItems.length === 1 ? '' : 's'}`\n\n          console.error(\n            `Invalid \\`${fieldName}\\` ${itemStr}:\\n` +\n              invalidHasItems.join('\\n')\n          )\n          console.error()\n          invalidParts.push(`invalid \\`${fieldName}\\` ${itemStr} found`)\n        }\n      }\n      return hadInvalidItem\n    }\n    if (checkInvalidHasMissing(route.has, 'has')) {\n      hadInvalidHas = true\n    }\n    if (checkInvalidHasMissing(route.missing, 'missing')) {\n      hadInvalidMissing = true\n    }\n\n    if (!route.source) {\n      invalidParts.push('`source` is missing')\n    } else if (typeof route.source !== 'string') {\n      invalidParts.push('`source` is not a string')\n    } else if (!route.source.startsWith('/')) {\n      invalidParts.push('`source` does not start with /')\n    }\n\n    if (type === 'header') {\n      invalidParts.push(...checkHeader(route as Header))\n    } else if (type !== 'middleware') {\n      let _route = route as Rewrite | Redirect\n      if (!_route.destination) {\n        invalidParts.push('`destination` is missing')\n      } else if (typeof _route.destination !== 'string') {\n        invalidParts.push('`destination` is not a string')\n      } else if (\n        type === 'rewrite' &&\n        !_route.destination.match(/^(\\/|https:\\/\\/|http:\\/\\/)/)\n      ) {\n        invalidParts.push(\n          '`destination` does not start with `/`, `http://`, or `https://`'\n        )\n      }\n    }\n\n    if (type === 'redirect') {\n      const result = checkRedirect(route as Redirect)\n      hadInvalidStatus = hadInvalidStatus || result.hadInvalidStatus\n      invalidParts.push(...result.invalidParts)\n    }\n\n    let sourceTokens: Token[] | undefined\n\n    if (typeof route.source === 'string' && route.source.startsWith('/')) {\n      // only show parse error if we didn't already show error\n      // for not being a string\n      const { tokens, error, regexStr } = tryToParsePath(route.source)\n\n      if (error) {\n        invalidParts.push('`source` parse failed')\n      }\n\n      if (regexStr && regexStr.length > 4096) {\n        invalidParts.push('`source` exceeds max built length of 4096')\n      }\n\n      sourceTokens = tokens\n    }\n    const hasSegments = new Set<string>()\n\n    if (route.has) {\n      for (const hasItem of route.has) {\n        if (!hasItem.value && hasItem.key) {\n          hasSegments.add(hasItem.key)\n        }\n\n        if (hasItem.value) {\n          for (const match of hasItem.value.matchAll(namedGroupsRegex)) {\n            if (match[1]) {\n              hasSegments.add(match[1])\n            }\n          }\n\n          if (hasItem.type === 'host') {\n            hasSegments.add('host')\n          }\n        }\n      }\n    }\n\n    // make sure no unnamed patterns are attempted to be used in the\n    // destination as this can cause confusion and is not allowed\n    if (typeof (route as Rewrite).destination === 'string') {\n      if (\n        (route as Rewrite).destination.startsWith('/') &&\n        Array.isArray(sourceTokens)\n      ) {\n        const unnamedInDest = new Set()\n\n        for (const token of sourceTokens) {\n          if (typeof token === 'object' && typeof token.name === 'number') {\n            const unnamedIndex = new RegExp(`:${token.name}(?!\\\\d)`)\n            if ((route as Rewrite).destination.match(unnamedIndex)) {\n              unnamedInDest.add(`:${token.name}`)\n            }\n          }\n        }\n\n        if (unnamedInDest.size > 0) {\n          invalidParts.push(\n            `\\`destination\\` has unnamed params ${[...unnamedInDest].join(\n              ', '\n            )}`\n          )\n        } else {\n          const {\n            tokens: destTokens,\n            regexStr: destRegexStr,\n            error: destinationParseFailed,\n          } = tryToParsePath((route as Rewrite).destination, {\n            handleUrl: true,\n          })\n\n          if (destRegexStr && destRegexStr.length > 4096) {\n            invalidParts.push('`destination` exceeds max built length of 4096')\n          }\n\n          if (destinationParseFailed) {\n            invalidParts.push('`destination` parse failed')\n          } else {\n            const sourceSegments = new Set(\n              sourceTokens\n                .map((item) => typeof item === 'object' && item.name)\n                .filter(Boolean)\n            )\n            const invalidDestSegments = new Set()\n\n            for (const token of destTokens!) {\n              if (\n                typeof token === 'object' &&\n                !sourceSegments.has(token.name) &&\n                !hasSegments.has(token.name as string)\n              ) {\n                invalidDestSegments.add(token.name)\n              }\n            }\n\n            if (invalidDestSegments.size) {\n              invalidParts.push(\n                `\\`destination\\` has segments not in \\`source\\` or \\`has\\` (${[\n                  ...invalidDestSegments,\n                ].join(', ')})`\n              )\n            }\n          }\n        }\n      }\n    }\n\n    const hasInvalidKeys = invalidKeys.length > 0\n    const hasInvalidParts = invalidParts.length > 0\n\n    if (hasInvalidKeys || hasInvalidParts) {\n      console.error(\n        `${invalidParts.join(', ')}${\n          invalidKeys.length\n            ? (hasInvalidParts ? ',' : '') +\n              ` invalid field${invalidKeys.length === 1 ? '' : 's'}: ` +\n              invalidKeys.join(',')\n            : ''\n        } for route ${JSON.stringify(route)}`\n      )\n      console.error()\n      numInvalidRoutes++\n    }\n  }\n\n  if (numInvalidRoutes > 0) {\n    if (hadInvalidStatus) {\n      console.error(\n        `\\nValid redirect statusCode values are ${[...allowedStatusCodes].join(\n          ', '\n        )}`\n      )\n    }\n    if (hadInvalidHas) {\n      console.error(\n        `\\nValid \\`has\\` object shape is ${JSON.stringify(\n          {\n            type: [...allowedHasTypes].join(', '),\n            key: 'the key to check for',\n            value: 'undefined or a value string to match against',\n          },\n          null,\n          2\n        )}`\n      )\n    }\n    if (hadInvalidMissing) {\n      console.error(\n        `\\nValid \\`missing\\` object shape is ${JSON.stringify(\n          {\n            type: [...allowedHasTypes].join(', '),\n            key: 'the key to check for',\n            value: 'undefined or a value string to match against',\n          },\n          null,\n          2\n        )}`\n      )\n    }\n    console.error()\n    console.error(\n      `Error: Invalid ${type}${numInvalidRoutes === 1 ? '' : 's'} found`\n    )\n    process.exit(1)\n  }\n}\n\nexport interface CustomRoutes {\n  headers: Header[]\n  onMatchHeaders: Header[]\n  rewrites: {\n    fallback: Rewrite[]\n    afterFiles: Rewrite[]\n    beforeFiles: Rewrite[]\n  }\n  redirects: Redirect[]\n}\n\nfunction processRoutes<T>(\n  routes: T,\n  config: NextConfig,\n  type: 'redirect' | 'rewrite' | 'header'\n): T {\n  const _routes = routes as any as Array<{\n    source: string\n    locale?: false\n    basePath?: false\n    destination?: string\n  }>\n  const newRoutes: typeof _routes = []\n  const defaultLocales: Array<{\n    locale: string\n    base: string\n  }> = []\n\n  if (config.i18n && type === 'redirect') {\n    for (const item of config.i18n?.domains || []) {\n      defaultLocales.push({\n        locale: item.defaultLocale,\n        base: `http${item.http ? '' : 's'}://${item.domain}`,\n      })\n    }\n\n    defaultLocales.push({\n      locale: config.i18n.defaultLocale,\n      base: '',\n    })\n  }\n\n  for (const r of _routes) {\n    const srcBasePath =\n      config.basePath && r.basePath !== false ? config.basePath : ''\n    const isExternal = !r.destination?.startsWith('/')\n    const destBasePath = srcBasePath && !isExternal ? srcBasePath : ''\n\n    if (config.i18n && r.locale !== false) {\n      if (!isExternal) {\n        defaultLocales.forEach((item) => {\n          let destination\n\n          if (r.destination) {\n            destination = item.base\n              ? `${item.base}${destBasePath}${r.destination}`\n              : `${destBasePath}${r.destination}`\n          }\n\n          newRoutes.push({\n            ...r,\n            destination,\n            source: `${srcBasePath}/${item.locale}${\n              r.source === '/' && !config.trailingSlash ? '' : r.source\n            }`,\n          })\n        })\n      }\n\n      r.source = `/:nextInternalLocale(${config.i18n.locales\n        .map((locale: string) => escapeStringRegexp(locale))\n        .join('|')})${\n        r.source === '/' && !config.trailingSlash ? '' : r.source\n      }`\n\n      if (r.destination && r.destination?.startsWith('/')) {\n        r.destination = `/:nextInternalLocale${\n          r.destination === '/' && !config.trailingSlash ? '' : r.destination\n        }`\n      }\n    }\n    r.source = `${srcBasePath}${\n      r.source === '/' && srcBasePath ? '' : r.source\n    }`\n\n    if (r.destination) {\n      r.destination = `${destBasePath}${\n        r.destination === '/' && destBasePath ? '' : r.destination\n      }`\n    }\n    newRoutes.push(r)\n  }\n  return newRoutes as any as T\n}\n\nasync function loadRedirects(config: NextConfig) {\n  if (typeof config.redirects !== 'function') {\n    return []\n  }\n  let redirects = await config.redirects()\n  // check before we process the routes and after to ensure\n  // they are still valid\n  checkCustomRoutes(redirects, 'redirect')\n\n  // save original redirects before transforms\n  if (Array.isArray(redirects)) {\n    config._originalRedirects = redirects.map((r) => ({ ...r }))\n  }\n  redirects = processRoutes(redirects, config, 'redirect')\n  checkCustomRoutes(redirects, 'redirect')\n  return redirects\n}\n\nasync function loadRewrites(config: NextConfig) {\n  // If assetPrefix is set, add a rewrite for `/${assetPrefix}/_next/*`\n  // requests so that they are handled in any of dev, start, or deploy\n  // automatically without the user having to configure this.\n  // If the assetPrefix is an absolute URL, we still consider the path for automatic rewrite.\n  // but hostname routing must be handled by the user\n  let maybeAssetPrefixRewrite: Rewrite[] = []\n  if (config.assetPrefix) {\n    let prefix = config.assetPrefix\n    if (\n      isFullStringUrl(config.assetPrefix) &&\n      URL.canParse(config.assetPrefix)\n    ) {\n      prefix = new URL(config.assetPrefix).pathname\n    }\n\n    if (prefix && prefix !== '/') {\n      const assetPrefix = prefix.startsWith('/') ? prefix : `/${prefix}`\n      const basePath = config.basePath || ''\n      // If these are the same, then this would result in an infinite rewrite.\n      if (assetPrefix !== basePath) {\n        maybeAssetPrefixRewrite.push({\n          source: `${assetPrefix}/_next/:path+`,\n          destination: `${basePath}/_next/:path+`,\n        })\n      }\n    }\n  }\n\n  if (typeof config.rewrites !== 'function') {\n    return {\n      beforeFiles: [...maybeAssetPrefixRewrite],\n      afterFiles: [],\n      fallback: [],\n    }\n  }\n  const _rewrites = await config.rewrites()\n  let beforeFiles: Rewrite[] = []\n  let afterFiles: Rewrite[] = []\n  let fallback: Rewrite[] = []\n\n  if (\n    !Array.isArray(_rewrites) &&\n    typeof _rewrites === 'object' &&\n    Object.keys(_rewrites).every(\n      (key) =>\n        key === 'beforeFiles' || key === 'afterFiles' || key === 'fallback'\n    )\n  ) {\n    beforeFiles = _rewrites.beforeFiles || []\n    afterFiles = _rewrites.afterFiles || []\n    fallback = _rewrites.fallback || []\n  } else {\n    afterFiles = _rewrites as any\n  }\n  // check before we process the routes and after to ensure\n  // they are still valid\n  checkCustomRoutes(beforeFiles, 'rewrite')\n  checkCustomRoutes(afterFiles, 'rewrite')\n  checkCustomRoutes(fallback, 'rewrite')\n\n  // save original rewrites before transforms\n  config._originalRewrites = {\n    beforeFiles: beforeFiles.map((r) => ({ ...r })),\n    afterFiles: afterFiles.map((r) => ({ ...r })),\n    fallback: fallback.map((r) => ({ ...r })),\n  }\n\n  beforeFiles = [\n    ...maybeAssetPrefixRewrite,\n    ...processRoutes(beforeFiles, config, 'rewrite'),\n  ]\n  afterFiles = processRoutes(afterFiles, config, 'rewrite')\n  fallback = processRoutes(fallback, config, 'rewrite')\n\n  checkCustomRoutes(beforeFiles, 'rewrite')\n  checkCustomRoutes(afterFiles, 'rewrite')\n  checkCustomRoutes(fallback, 'rewrite')\n\n  return {\n    beforeFiles,\n    afterFiles,\n    fallback,\n  }\n}\n\nasync function loadHeaders(config: NextConfig) {\n  if (typeof config.headers !== 'function') {\n    return []\n  }\n  let headers = await config.headers()\n  // check before we process the routes and after to ensure\n  // they are still valid\n  checkCustomRoutes(headers, 'header')\n\n  headers = processRoutes(headers, config, 'header')\n  checkCustomRoutes(headers, 'header')\n  return headers\n}\n\nexport default async function loadCustomRoutes(\n  config: NextConfig\n): Promise<CustomRoutes> {\n  const [headers, rewrites, redirects] = await Promise.all([\n    loadHeaders(config),\n    loadRewrites(config),\n    loadRedirects(config),\n  ])\n\n  const onMatchHeaders: Header[] = []\n\n  const totalRewrites =\n    rewrites.beforeFiles.length +\n    rewrites.afterFiles.length +\n    rewrites.fallback.length\n\n  const totalRoutes = headers.length + redirects.length + totalRewrites\n\n  if (totalRoutes > 1000) {\n    console.warn(\n      bold(yellow(`Warning: `)) +\n        `total number of custom routes exceeds 1000, this can reduce performance. Route counts:\\n` +\n        `headers: ${headers.length}\\n` +\n        `rewrites: ${totalRewrites}\\n` +\n        `redirects: ${redirects.length}\\n` +\n        `See more info: https://nextjs.org/docs/messages/max-custom-routes-reached`\n    )\n  }\n\n  const cacheControlSources: string[] = []\n  for (const headerRoute of headers) {\n    if (!headerRoute.source.startsWith('/_next/')) {\n      continue\n    }\n    for (const header of headerRoute.headers) {\n      if (header.key.toLowerCase() === 'cache-control') {\n        cacheControlSources.push(headerRoute.source)\n        break\n      }\n    }\n  }\n  if (cacheControlSources.length > 0) {\n    console.warn(\n      bold(yellow(`Warning: `)) +\n        `Custom Cache-Control headers detected for the following routes:\\n` +\n        cacheControlSources.map((source) => `  - ${source}`).join('\\n') +\n        `\\n\\nSetting a custom Cache-Control header can break Next.js development behavior.`\n    )\n  }\n\n  if (config.deploymentId) {\n    if (config.experimental?.useSkewCookie) {\n      headers.unshift({\n        source: '/:path*',\n        headers: [\n          {\n            key: 'Set-Cookie',\n            value: `__vdpl=${config.deploymentId}; Path=/; HttpOnly`,\n          },\n        ],\n      })\n    }\n\n    onMatchHeaders.push(\n      {\n        source: '/:path*',\n        has: [\n          {\n            type: 'header',\n            key: 'rsc',\n            value: '1',\n          },\n        ],\n        headers: [\n          {\n            key: NEXT_NAV_DEPLOYMENT_ID_HEADER,\n            value: config.deploymentId,\n          },\n        ],\n      },\n      {\n        source: '/_next/data/(.*)',\n        headers: [\n          {\n            key: NEXT_NAV_DEPLOYMENT_ID_HEADER,\n            value: config.deploymentId,\n          },\n        ],\n      }\n    )\n  }\n\n  if (!config.skipTrailingSlashRedirect) {\n    if (config.trailingSlash) {\n      redirects.unshift(\n        {\n          source: '/:file((?!\\\\.well-known(?:/.*)?)(?:[^/]+/)*[^/]+\\\\.\\\\w+)/',\n          destination: '/:file',\n          permanent: true,\n          locale: config.i18n ? false : undefined,\n          internal: true,\n          priority: true,\n          // don't run this redirect for _next/data requests\n          missing: [\n            {\n              type: 'header',\n              key: 'x-nextjs-data',\n            },\n          ],\n        },\n        {\n          source: '/:notfile((?!\\\\.well-known(?:/.*)?)(?:[^/]+/)*[^/\\\\.]+)',\n          destination: '/:notfile/',\n          permanent: true,\n          locale: config.i18n ? false : undefined,\n          internal: true,\n          priority: true,\n        }\n      )\n      if (config.basePath) {\n        redirects.unshift({\n          source: config.basePath,\n          destination: config.basePath + '/',\n          permanent: true,\n          basePath: false,\n          locale: config.i18n ? false : undefined,\n          internal: true,\n          priority: true,\n        })\n      }\n    } else {\n      redirects.unshift({\n        source: '/:path+/',\n        destination: '/:path+',\n        permanent: true,\n        locale: config.i18n ? false : undefined,\n        internal: true,\n        priority: true,\n      })\n      if (config.basePath) {\n        redirects.unshift({\n          source: config.basePath + '/',\n          destination: config.basePath,\n          permanent: true,\n          basePath: false,\n          locale: config.i18n ? false : undefined,\n          internal: true,\n          priority: true,\n        })\n      }\n    }\n  }\n\n  return {\n    headers,\n    onMatchHeaders,\n    rewrites,\n    redirects,\n  }\n}\n"],"names":["bold","yellow","escapeStringRegexp","tryToParsePath","allowedStatusCodes","isFullStringUrl","NEXT_NAV_DEPLOYMENT_ID_HEADER","allowedHasTypes","Set","namedGroupsRegex","normalizeRouteRegex","regex","replace","checkRedirect","route","invalidParts","hadInvalidStatus","statusCode","has","push","permanent","checkHeader","Array","isArray","headers","length","header","key","value","checkCustomRoutes","routes","type","console","error","process","exit","numInvalidRoutes","hadInvalidHas","hadInvalidMissing","allowedKeys","add","JSON","stringify","basePath","destination","startsWith","source","keys","Object","invalidKeys","filter","locale","checkInvalidHasMissing","items","fieldName","hadInvalidItem","invalidHasItems","hasItem","invalidHasParts","join","itemStr","missing","_route","match","result","sourceTokens","tokens","regexStr","hasSegments","matchAll","unnamedInDest","token","name","unnamedIndex","RegExp","size","destTokens","destRegexStr","destinationParseFailed","handleUrl","sourceSegments","map","item","Boolean","invalidDestSegments","hasInvalidKeys","hasInvalidParts","processRoutes","config","_routes","newRoutes","defaultLocales","i18n","domains","defaultLocale","base","http","domain","r","srcBasePath","isExternal","destBasePath","forEach","trailingSlash","locales","loadRedirects","redirects","_originalRedirects","loadRewrites","maybeAssetPrefixRewrite","assetPrefix","prefix","URL","canParse","pathname","rewrites","beforeFiles","afterFiles","fallback","_rewrites","every","_originalRewrites","loadHeaders","loadCustomRoutes","Promise","all","onMatchHeaders","totalRewrites","totalRoutes","warn","cacheControlSources","headerRoute","toLowerCase","deploymentId","experimental","useSkewCookie","unshift","skipTrailingSlashRedirect","undefined","internal","priority"],"mappings":"AAGA,SAASA,IAAI,EAAEC,MAAM,QAAQ,eAAc;AAC3C,SAASC,kBAAkB,QAAQ,8BAA6B;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,kBAAkB,QAAQ,oBAAmB;AACtD,SAASC,eAAe,QAAQ,QAAO;AACvC,SAASC,6BAA6B,QAAQ,cAAa;AA+E3D,MAAMC,kBAAkB,IAAIC,IAAI;IAAC;IAAU;IAAU;IAAS;CAAO;AACrE,MAAMC,mBAAmB;AAEzB,OAAO,SAASC,oBAAoBC,KAAa;IAC/C,0EAA0E;IAC1E,OAAOA,MAAMC,OAAO,CAAC,SAAS;AAChC;AAEA,SAASC,cAAcC,KAAe;IAIpC,MAAMC,eAAyB,EAAE;IACjC,IAAIC,mBAA4B;IAEhC,IAAIF,MAAMG,UAAU,IAAI,CAACb,mBAAmBc,GAAG,CAACJ,KAAK,CAAC,aAAa,GAAG;QACpEE,mBAAmB;QACnBD,aAAaI,IAAI,CAAC,CAAC,mDAAmD,CAAC;IACzE;IACA,IAAI,OAAOL,MAAMM,SAAS,KAAK,aAAa,CAACN,KAAK,CAAC,aAAa,EAAE;QAChEC,aAAaI,IAAI,CAAC,CAAC,iDAAiD,CAAC;IACvE;IAEA,OAAO;QACLJ;QACAC;IACF;AACF;AAEA,SAASK,YAAYP,KAAa;IAChC,MAAMC,eAAyB,EAAE;IAEjC,IAAI,CAACO,MAAMC,OAAO,CAACT,MAAMU,OAAO,GAAG;QACjCT,aAAaI,IAAI,CAAC;IACpB,OAAO,IAAIL,MAAMU,OAAO,CAACC,MAAM,KAAK,GAAG;QACrCV,aAAaI,IAAI,CAAC;IACpB,OAAO;QACL,KAAK,M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