{"version":3,"file":"getRoutes.js","names":[],"sources":["esm/router/getRoutes.js"],"sourcesContent":["import { getDefaultRenderMode } from \"../config\";\nimport { getPageExport } from \"../utils/getPageExport\";\nimport {\n  matchArrayGroupName,\n  matchDirectoryRenderMode,\n  matchDynamicName,\n  matchFileRenderMode,\n  matchGroupName,\n  matchInterceptPrefix,\n  matchSlotName,\n  removeSupportedExtensions,\n  stripInterceptPrefix\n} from \"./matchers\";\nconst validPlatforms = /* @__PURE__ */ new Set([\"android\", \"ios\", \"native\", \"web\"]);\nfunction getRoutes(contextModule, options = {}) {\n  const directoryTree = getDirectoryTree(contextModule, options);\n  if (!directoryTree) {\n    return null;\n  }\n  const rootNode = flattenDirectoryTreeToRoutes(directoryTree, options);\n  if (!options.ignoreEntryPoints) {\n    crawlAndAppendInitialRoutesAndEntryFiles(rootNode, options);\n  }\n  return rootNode;\n}\nfunction getDirectoryTree(contextModule, options) {\n  const importMode = options.importMode || process.env.One_ROUTER_IMPORT_MODE;\n  const ignoreList = [\n    /^\\.\\/\\+html\\.[tj]sx?$/,\n    // Ignore the top level ./+html file\n    /\\.d\\.ts$/\n    // Ignore TypeScript declaration files\n  ];\n  if (options.ignore) {\n    ignoreList.push(...options.ignore);\n  }\n  if (!options.preserveApiRoutes) {\n    ignoreList.push(/\\+api\\.[tj]sx?$/);\n  }\n  const rootDirectory = {\n    files: /* @__PURE__ */ new Map(),\n    subdirectories: /* @__PURE__ */ new Map(),\n    slots: /* @__PURE__ */ new Map()\n  };\n  let hasRoutes = false;\n  let isValid = false;\n  for (const filePath of contextModule.keys()) {\n    if (ignoreList.some((regex) => regex.test(filePath))) {\n      continue;\n    }\n    isValid = true;\n    let parentRenderMode;\n    const pathParts = filePath.replace(/^\\.\\//, \"\").split(\"/\");\n    const directoryParts = pathParts.slice(0, -1);\n    for (const part of directoryParts) {\n      const dirRenderMode = matchDirectoryRenderMode(part);\n      if (dirRenderMode) {\n        parentRenderMode = dirRenderMode.renderMode;\n      }\n    }\n    const meta = getFileMeta(filePath, options, parentRenderMode);\n    if (meta.specificity < 0) {\n      continue;\n    }\n    const type = meta.isLayout ? \"layout\" : meta.renderMode || getDefaultRenderMode();\n    const layoutRenderMode = meta.isLayout && meta.renderMode && meta.renderMode !== \"api\" ? meta.renderMode : void 0;\n    let node = {\n      type,\n      // store layout render mode if this is a layout with an explicit mode\n      ...layoutRenderMode && { layoutRenderMode },\n      loadRoute() {\n        if (options.ignoreRequireErrors) {\n          try {\n            return contextModule(filePath);\n          } catch {\n            return {};\n          }\n        } else {\n          return contextModule(filePath);\n        }\n      },\n      contextKey: filePath,\n      route: \"\",\n      // This is overwritten during hoisting based upon the _layout\n      dynamic: null,\n      children: []\n      // While we are building the directory tree, we don't know the node's children just yet. This is added during hoisting\n    };\n    if (process.env.NODE_ENV === \"development\") {\n      if (node.type !== \"api\" && importMode === \"sync\") {\n        if (!getPageExport(node.loadRoute())) {\n          continue;\n        }\n      }\n    }\n    for (const route of extrapolateGroups(meta.route)) {\n      const subdirectoryParts = route.split(\"/\").slice(0, -1);\n      let directory = rootDirectory;\n      for (const part of subdirectoryParts) {\n        const slotName = matchSlotName(part);\n        if (slotName) {\n          let slotDirectory = directory.slots.get(slotName);\n          if (!slotDirectory) {\n            slotDirectory = {\n              files: /* @__PURE__ */ new Map(),\n              subdirectories: /* @__PURE__ */ new Map(),\n              slots: /* @__PURE__ */ new Map()\n            };\n            directory.slots.set(slotName, slotDirectory);\n          }\n          directory = slotDirectory;\n        } else {\n          const dirRenderMode = matchDirectoryRenderMode(part);\n          const dirName = dirRenderMode?.name ?? part;\n          let subDirectory = directory.subdirectories.get(dirName);\n          if (!subDirectory) {\n            subDirectory = {\n              files: /* @__PURE__ */ new Map(),\n              subdirectories: /* @__PURE__ */ new Map(),\n              slots: /* @__PURE__ */ new Map(),\n              renderMode: dirRenderMode?.renderMode\n            };\n            directory.subdirectories.set(dirName, subDirectory);\n          }\n          directory = subDirectory;\n        }\n      }\n      node = {\n        ...node,\n        route,\n        slotName: meta.slotName,\n        intercept: meta.interceptMatch ? {\n          levels: meta.interceptMatch.levels,\n          targetPath: meta.interceptMatch.targetPath\n        } : void 0\n      };\n      if (meta.isLayout) {\n        directory.layout ??= [];\n        const existing = directory.layout[meta.specificity];\n        if (existing) {\n          if (process.env.NODE_ENV !== \"production\") {\n            throw new Error(\n              `The layouts \"${filePath}\" and \"${existing.contextKey}\" conflict on the route \"/${route}\". Please remove or rename one of these files.`\n            );\n          }\n        } else {\n          node = getLayoutNode(node, options);\n          directory.layout[meta.specificity] = node;\n        }\n      } else if (meta.isMiddleware) {\n        directory.middleware = node;\n      } else if (type === \"api\") {\n        const fileKey = `${route}+api`;\n        let nodes = directory.files.get(fileKey);\n        if (!nodes) {\n          nodes = [];\n          directory.files.set(fileKey, nodes);\n        }\n        const existing = nodes[0];\n        if (existing) {\n          if (process.env.NODE_ENV !== \"production\") {\n            throw new Error(\n              `The API route file \"${filePath}\" and \"${existing.contextKey}\" conflict on the route \"/${route}\". Please remove or rename one of these files.`\n            );\n          }\n        } else {\n          nodes[0] = node;\n        }\n      } else {\n        let nodes = directory.files.get(route);\n        if (!nodes) {\n          nodes = [];\n          directory.files.set(route, nodes);\n        }\n        const existing = nodes[meta.specificity];\n        if (existing) {\n          if (process.env.NODE_ENV !== \"production\") {\n            throw new Error(\n              `The route files \"${filePath}\" and \"${existing.contextKey}\" conflict on the route \"/${route}\". Please remove or rename one of these files.`\n            );\n          }\n        } else {\n          hasRoutes ||= true;\n          nodes[meta.specificity] = node;\n        }\n      }\n    }\n  }\n  if (!isValid) {\n    return null;\n  }\n  if (!rootDirectory.layout) {\n    rootDirectory.layout = [\n      {\n        type: \"layout\",\n        loadRoute: () => ({\n          default: (() => {\n            try {\n              return require(\"../views/Navigator\");\n            } catch (e) {\n              return {\n                DefaultNavigator: () => {\n                  throw e;\n                }\n              };\n            }\n          })().DefaultNavigator\n        }),\n        // Generate a fake file name for the directory\n        contextKey: \"router/build/views/Navigator.js\",\n        route: \"\",\n        generated: true,\n        dynamic: null,\n        children: []\n      }\n    ];\n  }\n  if (hasRoutes) {\n    appendSitemapRoute(rootDirectory);\n  }\n  appendNotFoundRoute(rootDirectory);\n  return rootDirectory;\n}\nfunction flattenDirectoryTreeToRoutes(directory, options, layout, pathToRemove = \"\", parentMiddlewares) {\n  if (directory.layout) {\n    const previousLayout = layout;\n    layout = getMostSpecific(directory.layout);\n    if (previousLayout) {\n      previousLayout.children.push(layout);\n    }\n    const newRoute = layout.route.replace(pathToRemove, \"\");\n    pathToRemove = layout.route ? `${layout.route}/` : \"\";\n    layout.route = newRoute;\n    layout.dynamic = generateDynamic(layout.route);\n  }\n  if (!layout) throw new Error(\"One Internal Error: No nearest layout\");\n  const middlewares = directory.middleware ? [...parentMiddlewares || [], directory.middleware] : parentMiddlewares;\n  for (const routes of directory.files.values()) {\n    const routeNode = getMostSpecific(routes);\n    routeNode.route = routeNode.route.replace(pathToRemove, \"\");\n    routeNode.dynamic = generateDynamic(routeNode.route);\n    routeNode.middlewares = middlewares;\n    layout.children.push(routeNode);\n  }\n  for (const child of directory.subdirectories.values()) {\n    flattenDirectoryTreeToRoutes(child, options, layout, pathToRemove, middlewares);\n  }\n  if (directory.slots.size > 0) {\n    layout.slots = /* @__PURE__ */ new Map();\n    for (const [slotName, slotDir] of directory.slots) {\n      const slotConfig = flattenSlotDirectory(slotDir, slotName, options, pathToRemove);\n      layout.slots.set(slotName, slotConfig);\n    }\n  }\n  return layout;\n}\nfunction flattenSlotDirectory(directory, slotName, options, pathToRemove) {\n  const interceptRoutes = [];\n  let defaultRoute;\n  for (const routes of directory.files.values()) {\n    const routeNode = getMostSpecific(routes);\n    let cleanRoute = routeNode.route.replace(pathToRemove, \"\");\n    cleanRoute = cleanRoute.split(\"/\").filter((segment) => !matchSlotName(segment)).map((segment) => stripInterceptPrefix(segment)).join(\"/\");\n    if (cleanRoute.endsWith(\"default\") || cleanRoute === \"default\") {\n      defaultRoute = {\n        ...routeNode,\n        route: cleanRoute,\n        slotName,\n        dynamic: generateDynamic(cleanRoute)\n      };\n    } else {\n      interceptRoutes.push({\n        ...routeNode,\n        route: cleanRoute,\n        slotName,\n        dynamic: generateDynamic(cleanRoute)\n      });\n    }\n  }\n  for (const [subDirName, subDir] of directory.subdirectories) {\n    const subRoutes = flattenSlotSubdirectory(\n      subDir,\n      slotName,\n      options,\n      pathToRemove,\n      subDirName\n    );\n    interceptRoutes.push(...subRoutes);\n  }\n  return {\n    name: slotName,\n    defaultRoute,\n    interceptRoutes\n  };\n}\nfunction flattenSlotSubdirectory(directory, slotName, options, pathToRemove, currentPath) {\n  const routes = [];\n  for (const fileRoutes of directory.files.values()) {\n    const routeNode = getMostSpecific(fileRoutes);\n    let cleanRoute = routeNode.route.replace(pathToRemove, \"\");\n    cleanRoute = cleanRoute.split(\"/\").filter((segment) => !matchSlotName(segment)).map((segment) => stripInterceptPrefix(segment)).join(\"/\");\n    routes.push({\n      ...routeNode,\n      route: cleanRoute,\n      slotName,\n      dynamic: generateDynamic(cleanRoute)\n    });\n  }\n  for (const [subDirName, subDir] of directory.subdirectories) {\n    const subPath = currentPath ? `${currentPath}/${subDirName}` : subDirName;\n    routes.push(\n      ...flattenSlotSubdirectory(subDir, slotName, options, pathToRemove, subPath)\n    );\n  }\n  return routes;\n}\nfunction getFileMeta(key, options, parentRenderMode) {\n  key = key.replace(/^\\.\\//, \"\");\n  const parts = key.split(\"/\");\n  let route = removeSupportedExtensions(key);\n  const filename = parts[parts.length - 1];\n  const filenameWithoutExtensions = removeSupportedExtensions(filename);\n  const isLayout = filenameWithoutExtensions.startsWith(\"_layout\");\n  const isMiddleware = filenameWithoutExtensions.startsWith(\"_middleware\");\n  const fileRenderMode = matchFileRenderMode(filename);\n  const renderMode = fileRenderMode ?? parentRenderMode;\n  route = route.split(\"/\").map((segment) => {\n    const dirRenderMode = matchDirectoryRenderMode(segment);\n    return dirRenderMode ? dirRenderMode.name : segment;\n  }).join(\"/\");\n  if (filenameWithoutExtensions.startsWith(\"(\") && filenameWithoutExtensions.endsWith(\")\")) {\n    throw new Error(`Invalid route ./${key}. Routes cannot end with '(group)' syntax`);\n  }\n  if (renderMode !== \"api\" && filename.startsWith(\"+\") && filenameWithoutExtensions !== \"+not-found\") {\n    const renamedRoute = [...parts.slice(0, -1), filename.slice(1)].join(\"/\");\n    throw new Error(\n      `Invalid route ./${key}. Route nodes cannot start with the '+' character. \"Please rename to ${renamedRoute}\"`\n    );\n  }\n  let slotName;\n  for (const part of parts) {\n    const match = matchSlotName(part);\n    if (match) {\n      slotName = match;\n      break;\n    }\n  }\n  let interceptMatch;\n  for (let i = 0; i < parts.length; i++) {\n    const part = parts[i];\n    const match = matchInterceptPrefix(part);\n    if (match) {\n      const remainingParts = parts.slice(i + 1).map((p) => removeSupportedExtensions(p)).filter((p) => p !== \"index\");\n      const fullTargetPath = [match.targetPath, ...remainingParts].filter(Boolean).join(\"/\");\n      interceptMatch = {\n        ...match,\n        targetPath: fullTargetPath\n      };\n      break;\n    }\n  }\n  let specificity = 0;\n  const platformExtension = filenameWithoutExtensions.split(\".\")[1];\n  const hasPlatformExtension = validPlatforms.has(platformExtension);\n  const usePlatformRoutes = options.platformRoutes ?? true;\n  if (hasPlatformExtension) {\n    if (!usePlatformRoutes) {\n      specificity = -1;\n    } else if (!options.platform) {\n      specificity = -1;\n    } else if (platformExtension === options.platform) {\n      specificity = 2;\n    } else if (platformExtension === \"native\" && options.platform !== \"web\") {\n      specificity = 1;\n    } else if (platformExtension !== options.platform) {\n      specificity = -1;\n    }\n    if (renderMode === \"api\" && specificity !== 0) {\n      throw new Error(\n        `Api routes cannot have platform extensions. Please remove '.${platformExtension}' from './${key}'`\n      );\n    }\n    route = route.replace(new RegExp(`.${platformExtension}$`), \"\");\n  }\n  return {\n    route,\n    specificity,\n    isLayout,\n    isMiddleware,\n    renderMode,\n    slotName,\n    interceptMatch\n  };\n}\nfunction getMostSpecific(routes) {\n  const route = routes[routes.length - 1];\n  if (!routes[0]) {\n    throw new Error(\n      ` [one] The file ${route.contextKey} does not have a fallback sibling file without a platform extension in routes (${routes[0]}, ${routes.length}):\n${routes.map((r) => r.contextKey || \"NONE\").join(\"\\n\")}.`\n    );\n  }\n  return route;\n}\nfunction getIgnoreList(options) {\n  const ignore = [/^\\.\\/\\+html\\.[tj]sx?$/, ...options?.ignore ?? []];\n  if (options?.preserveApiRoutes !== true) {\n    ignore.push(/\\+api\\.[tj]sx?$/);\n  }\n  return ignore;\n}\nfunction extrapolateGroups(key, keys = /* @__PURE__ */ new Set()) {\n  const match = matchArrayGroupName(key);\n  if (!match) {\n    keys.add(key);\n    return keys;\n  }\n  const groups = match.split(\",\");\n  const groupsSet = new Set(groups);\n  if (groupsSet.size !== groups.length) {\n    throw new Error(\n      `Array syntax cannot contain duplicate group name \"${groups}\" in \"${key}\".`\n    );\n  }\n  if (groups.length === 1) {\n    keys.add(key);\n    return keys;\n  }\n  for (const group of groups) {\n    extrapolateGroups(key.replace(match, group.trim()), keys);\n  }\n  return keys;\n}\nfunction generateDynamic(path) {\n  const dynamic = path.split(\"/\").map((part) => {\n    if (part === \"+not-found\") {\n      return {\n        name: \"+not-found\",\n        deep: true,\n        notFound: true\n      };\n    }\n    const dynamicMatch = matchDynamicName(part);\n    if (!dynamicMatch) return null;\n    return { name: dynamicMatch.name, deep: dynamicMatch.deep };\n  }).filter((part) => !!part);\n  return dynamic.length === 0 ? null : dynamic;\n}\nfunction appendSitemapRoute(directory) {\n  if (!directory.files.has(\"_sitemap\")) {\n    directory.files.set(\"_sitemap\", [\n      {\n        loadRoute() {\n          return { default: () => null, getNavOptions: () => {\n          } };\n        },\n        route: \"_sitemap\",\n        type: \"ssg\",\n        contextKey: \"\",\n        generated: true,\n        internal: true,\n        dynamic: null,\n        children: []\n      }\n    ]);\n  }\n}\nfunction hasNotFoundInGroupSubdirs(directory) {\n  for (const [dirName, subDir] of directory.subdirectories) {\n    if (!matchGroupName(dirName)) continue;\n    for (const fileKey of subDir.files.keys()) {\n      if (fileKey.endsWith(\"+not-found\")) {\n        return true;\n      }\n    }\n    if (hasNotFoundInGroupSubdirs(subDir)) {\n      return true;\n    }\n  }\n  return false;\n}\nfunction appendNotFoundRoute(directory) {\n  if (!directory.files.has(\"+not-found\") && !hasNotFoundInGroupSubdirs(directory)) {\n    directory.files.set(\"+not-found\", [\n      {\n        loadRoute() {\n          return { default: () => null };\n        },\n        type: \"spa\",\n        route: \"+not-found\",\n        contextKey: \"\",\n        generated: true,\n        internal: true,\n        dynamic: [{ name: \"+not-found\", deep: true, notFound: true }],\n        children: []\n      }\n    ]);\n  }\n}\nfunction getLayoutNode(node, options) {\n  const groupName = matchGroupName(node.route);\n  const childMatchingGroup = node.children.find((child) => {\n    return child.route.replace(/\\/index$/, \"\") === groupName;\n  });\n  const initialRouteName = childMatchingGroup?.route;\n  return {\n    ...node,\n    route: node.route.replace(/\\/?_layout$/, \"\"),\n    children: [],\n    // Each layout should have its own children\n    initialRouteName\n  };\n}\nfunction crawlAndAppendInitialRoutesAndEntryFiles(node, options, entryPoints = []) {\n  if (node.type === \"spa\" || node.type === \"ssg\" || node.type === \"ssr\") {\n    node.entryPoints = [.../* @__PURE__ */ new Set([...entryPoints, node.contextKey])];\n  } else if (node.type === \"layout\") {\n    if (!node.children) {\n      throw new Error(`Layout \"${node.contextKey}\" does not contain any child routes`);\n    }\n    entryPoints = [...entryPoints, node.contextKey];\n    const groupName = matchGroupName(node.route);\n    const childMatchingGroup = node.children.find((child) => {\n      return child.route.replace(/\\/index$/, \"\") === groupName;\n    });\n    let initialRouteName = childMatchingGroup?.route;\n    const loaded = node.loadRoute();\n    if (loaded?.unstable_settings) {\n      initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;\n      if (groupName) {\n        const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.initialRouteName;\n        initialRouteName = groupSpecificInitialRouteName ?? initialRouteName;\n      }\n    }\n    if (initialRouteName) {\n      const initialRoute = node.children.find((child) => child.route === initialRouteName);\n      if (!initialRoute) {\n        const validInitialRoutes = node.children.filter((child) => !child.generated).map((child) => `'${child.route}'`).join(\", \");\n        if (groupName) {\n          throw new Error(\n            `Layout ${node.contextKey} has invalid initialRouteName '${initialRouteName}' for group '(${groupName})'. Valid options are: ${validInitialRoutes}`\n          );\n        }\n        throw new Error(\n          `Layout ${node.contextKey} has invalid initialRouteName '${initialRouteName}'. Valid options are: ${validInitialRoutes}`\n        );\n      }\n      node.initialRouteName = initialRouteName;\n      entryPoints.push(initialRoute.contextKey);\n    }\n    for (const child of node.children) {\n      crawlAndAppendInitialRoutesAndEntryFiles(child, options, entryPoints);\n    }\n  }\n}\nexport {\n  extrapolateGroups,\n  generateDynamic,\n  getIgnoreList,\n  getRoutes\n};\n//# sourceMappingURL=getRoutes.js.map\n"],"mappings":";;;;;;;;;;;;AAaA,MAAM,iCAAiC,IAAI,IAAI;CAAC;CAAW;CAAO;CAAU;AAAK,CAAC;AAClF,SAAS,UAAU,eAAe,UAAU,CAAC,GAAG;CAC9C,MAAM,gBAAgB,iBAAiB,eAAe,OAAO;CAC7D,IAAI,CAAC,eAAe;EAClB,OAAO;CACT;CACA,MAAM,WAAW,6BAA6B,eAAe,OAAO;CACpE,IAAI,CAAC,QAAQ,mBAAmB;EAC9B,yCAAyC,UAAU,OAAO;CAC5D;CACA,OAAO;AACT;AACA,SAAS,iBAAiB,eAAe,SAAS;CAChD,MAAM,aAAa,QAAQ,cAAc,QAAQ,IAAI;CACrD,MAAM,aAAa,CACjB,yBAEA,UAEF;CACA,IAAI,QAAQ,QAAQ;EAClB,WAAW,KAAK,GAAG,QAAQ,MAAM;CACnC;CACA,IAAI,CAAC,QAAQ,mBAAmB;EAC9B,WAAW,KAAK,iBAAiB;CACnC;CACA,MAAM,gBAAgB;EACpB,uBAAuB,IAAI,IAAI;EAC/B,gCAAgC,IAAI,IAAI;EACxC,uBAAuB,IAAI,IAAI;CACjC;CACA,IAAI,YAAY;CAChB,IAAI,UAAU;CACd,KAAK,MAAM,YAAY,cAAc,KAAK,GAAG;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