{"version":3,"file":"getStateFromPath.js","names":[],"sources":["esm/fork/getStateFromPath.js"],"sourcesContent":["import escape from \"escape-string-regexp\";\nimport { getParamValue, isDynamicPart, replacePart } from \"./_shared\";\nimport { findFocusedRoute } from \"./findFocusedRoute\";\nimport {\n  appendIsInitial,\n  createConfigItemAdditionalProperties,\n  decodeURIComponentSafe,\n  formatRegexPattern,\n  getRouteConfigSorter,\n  getUrlWithReactNavigationConcessions,\n  matchForEmptyPath,\n  parseQueryParamsExtended,\n  populateParams\n} from \"./getStateFromPath-mods\";\nimport { validatePathConfig } from \"./validatePathConfig\";\nfunction getStateFromPath(path, options) {\n  resetRouteKeyCounter();\n  if (process.env.ONE_DEBUG_ROUTER) {\n    console.info(\n      `[one] getStateFromPath called with path=${path}, isServer=${typeof window === \"undefined\"}`\n    );\n  }\n  const { initialRoutes, configs, configWithRegexes } = getConfigResources(options);\n  const screens = options?.screens;\n  const pathData = getUrlWithReactNavigationConcessions(path);\n  let remaining = pathData.nonstandardPathname.replace(/\\/+/g, \"/\").replace(/^\\//, \"\").replace(/\\?.*$/, \"\");\n  remaining = remaining.endsWith(\"/\") ? remaining : `${remaining}/`;\n  const prefix = options?.path?.replace(/^\\//, \"\");\n  if (prefix) {\n    const normalizedPrefix = prefix.endsWith(\"/\") ? prefix : `${prefix}/`;\n    if (!remaining.startsWith(normalizedPrefix)) {\n      return void 0;\n    }\n    remaining = remaining.replace(normalizedPrefix, \"\");\n  }\n  if (screens === void 0) {\n    const routes2 = remaining.split(\"/\").filter(Boolean).map((segment) => {\n      const name = decodeURIComponent(segment);\n      return { name };\n    });\n    if (routes2.length) {\n      return createNestedStateObject(pathData, routes2, initialRoutes, []);\n    }\n    return void 0;\n  }\n  if (remaining === \"/\") {\n    const match = matchForEmptyPath(configWithRegexes);\n    if (match) {\n      return createNestedStateObject(\n        pathData,\n        // @modified: pass pathData instead of path\n        match.routeNames.map((name) => ({ name })),\n        initialRoutes,\n        configs\n      );\n    }\n    return void 0;\n  }\n  let result;\n  let current;\n  const { routes, remainingPath } = matchAgainstConfigs(remaining, configWithRegexes);\n  if (routes !== void 0) {\n    current = createNestedStateObject(pathData, routes, initialRoutes, configs);\n    remaining = remainingPath;\n    result = current;\n  }\n  if (current == null || result == null) {\n    return void 0;\n  }\n  return result;\n}\nconst cachedConfigResources = /* @__PURE__ */ new WeakMap();\nfunction getConfigResources(options) {\n  if (!options) return prepareConfigResources();\n  const cached = cachedConfigResources.get(options);\n  if (cached) return cached;\n  const resources = prepareConfigResources(options);\n  cachedConfigResources.set(options, resources);\n  return resources;\n}\nfunction prepareConfigResources(options, previousSegments) {\n  if (options) {\n    validatePathConfig(options);\n  }\n  const initialRoutes = getInitialRoutes(options);\n  const configs = getNormalizedConfigs(initialRoutes, options?.screens, previousSegments);\n  checkForDuplicatedConfigs(configs);\n  const configWithRegexes = getConfigsWithRegexes(configs);\n  return {\n    initialRoutes,\n    configs,\n    configWithRegexes\n  };\n}\nfunction getInitialRoutes(options) {\n  const initialRoutes = [];\n  if (options?.initialRouteName) {\n    initialRoutes.push({\n      initialRouteName: options.initialRouteName,\n      parentScreens: []\n    });\n  }\n  return initialRoutes;\n}\nfunction getNormalizedConfigs(initialRoutes, screens = {}, previousSegments) {\n  return [].concat(\n    ...Object.keys(screens).map(\n      (key) => createNormalizedConfigs(\n        key,\n        screens,\n        [],\n        initialRoutes,\n        []\n      )\n    )\n  ).map(appendIsInitial(initialRoutes)).sort(getRouteConfigSorter(previousSegments));\n}\nfunction checkForDuplicatedConfigs(configs) {\n  configs.reduce((acc, config) => {\n    if (acc[config.pattern]) {\n      const a = acc[config.pattern].routeNames;\n      const b = config.routeNames;\n      const intersects = a.length > b.length ? b.every((it, i) => a[i] === it) : a.every((it, i) => b[i] === it);\n      if (!intersects) {\n        throw new Error(\n          `Found conflicting screens with the same pattern. The pattern '${config.pattern}' resolves to both '${a.join(\" > \")}' and '${b.join(\n            \" > \"\n          )}'. Patterns must be unique and cannot resolve to more than one screen.`\n        );\n      }\n    }\n    return Object.assign(acc, {\n      [config.pattern]: config\n    });\n  }, {});\n}\nfunction getConfigsWithRegexes(configs) {\n  return configs.map((c) => ({\n    ...c,\n    // Add `$` to the regex to make sure it matches till end of the path and not just beginning\n    // @modified - start\n    // regex: c.regex ? new RegExp(c.regex.source + '$') : undefined,\n    regex: c.pattern ? new RegExp(`^(${c.pattern.split(\"/\").map(formatRegexPattern).join(\"\")})$`) : void 0\n    // @modified - end\n  }));\n}\nconst joinPaths = (...paths) => [].concat(...paths.map((p) => p.split(\"/\"))).filter(Boolean).join(\"/\");\nconst matchAgainstConfigs = (remaining, configs) => {\n  let routes;\n  let remainingPath = remaining;\n  const allParams = /* @__PURE__ */ Object.create(null);\n  for (const config of configs) {\n    if (!config.regex) {\n      continue;\n    }\n    const match = remainingPath.match(config.regex);\n    if (match) {\n      const matchResult = config.pattern?.split(\"/\").reduce(\n        (acc, p, index) => {\n          if (!isDynamicPart(p)) {\n            return acc;\n          }\n          acc.pos += 1;\n          const decodedParamSegment = decodeURIComponentSafe(\n            // @modified: use decodeURIComponent**Safe**\n            // The param segments appear every second item starting from 2 in the regex match result\n            match[(acc.pos + 1) * 2].replace(/\\/$/, \"\")\n          );\n          Object.assign(acc.matchedParams, {\n            [p]: Object.assign(acc.matchedParams[p] || {}, {\n              [index]: decodedParamSegment\n            })\n          });\n          return acc;\n        },\n        { pos: -1, matchedParams: {} }\n      );\n      const matchedParams = matchResult.matchedParams || {};\n      routes = config.routeNames.map((name) => {\n        const routeConfig = configs.find((c) => {\n          return c.screen === name && config.pattern.startsWith(c.pattern);\n        });\n        const normalizedPath = routeConfig?.path.split(\"/\").filter(Boolean).join(\"/\");\n        const numInitialSegments = routeConfig?.pattern.replace(new RegExp(`${escape(normalizedPath)}$`), \"\")?.split(\"/\").length;\n        const params = normalizedPath?.split(\"/\").reduce((acc, p, index) => {\n          if (!isDynamicPart(p)) {\n            return acc;\n          }\n          const offset = numInitialSegments ? numInitialSegments - 1 : 0;\n          const value = getParamValue(p, matchedParams[p]?.[index + offset]);\n          if (value) {\n            const key = replacePart(p);\n            acc[key] = routeConfig?.parse?.[key] ? routeConfig.parse[key](value) : value;\n          }\n          return acc;\n        }, {});\n        if (params && Object.keys(params).length) {\n          Object.assign(allParams, params);\n          return { name, params };\n        }\n        return { name };\n      });\n      remainingPath = remainingPath.replace(match[1], \"\");\n      break;\n    }\n  }\n  populateParams(routes, allParams);\n  return { routes, remainingPath };\n};\nconst createNormalizedConfigs = (screen, routeConfig, routeNames = [], initials, parentScreens, parentPattern) => {\n  const configs = [];\n  routeNames.push(screen);\n  parentScreens.push(screen);\n  const config = routeConfig[screen];\n  if (typeof config === \"string\") {\n    const pattern = parentPattern ? joinPaths(parentPattern, config) : config;\n    configs.push(createConfigItem(screen, routeNames, pattern, config));\n  } else if (typeof config === \"object\") {\n    let pattern;\n    if (typeof config.path === \"string\") {\n      if (config.exact && config.path === void 0) {\n        throw new Error(\n          \"A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.\"\n        );\n      }\n      pattern = config.exact !== true ? joinPaths(parentPattern || \"\", config.path || \"\") : config.path || \"\";\n      configs.push(\n        createConfigItem(screen, routeNames, pattern, config.path, config.parse, config)\n      );\n    }\n    if (config.screens) {\n      if (config.initialRouteName) {\n        initials.push({\n          initialRouteName: config.initialRouteName,\n          parentScreens\n        });\n      }\n      Object.keys(config.screens).forEach((nestedConfig) => {\n        const result = createNormalizedConfigs(\n          nestedConfig,\n          config.screens,\n          routeNames,\n          initials,\n          [...parentScreens],\n          pattern ?? parentPattern\n        );\n        configs.push(...result);\n      });\n    }\n  }\n  routeNames.pop();\n  return configs;\n};\nconst createConfigItem = (screen, routeNames, pattern, path, parse = void 0, config = {}) => {\n  pattern = pattern.split(\"/\").filter(Boolean).join(\"/\");\n  const regex = pattern ? new RegExp(\n    `^(${pattern.split(\"/\").map((it) => {\n      if (it.startsWith(\":\")) {\n        return `(([^/]+\\\\/)${it.endsWith(\"?\") ? \"?\" : \"\"})`;\n      }\n      return `${it === \"*\" ? \".*\" : escape(it)}\\\\/`;\n    }).join(\"\")})`\n  ) : void 0;\n  return {\n    screen,\n    regex,\n    pattern,\n    path,\n    // The routeNames array is mutated, so copy it to keep the current state\n    routeNames: [...routeNames],\n    parse,\n    // @modified - start\n    ...createConfigItemAdditionalProperties(screen, pattern, routeNames, config)\n    // @modified - end\n  };\n};\nconst findParseConfigForRoute = (routeName, flatConfig) => {\n  for (const config of flatConfig) {\n    if (routeName === config.routeNames[config.routeNames.length - 1]) {\n      return config.parse;\n    }\n  }\n  return void 0;\n};\nconst findInitialRoute = (routeName, parentScreens, initialRoutes) => {\n  for (const config of initialRoutes) {\n    if (parentScreens.length === config.parentScreens.length) {\n      let sameParents = true;\n      for (let i = 0; i < parentScreens.length; i++) {\n        if (parentScreens[i].localeCompare(config.parentScreens[i]) !== 0) {\n          sameParents = false;\n          break;\n        }\n      }\n      if (sameParents) {\n        return routeName !== config.initialRouteName ? config.initialRouteName : void 0;\n      }\n    }\n  }\n  return void 0;\n};\nlet routeKeyCounter = 0;\nfunction resetRouteKeyCounter() {\n  routeKeyCounter = 0;\n}\nfunction getRouteWithKey(route) {\n  const key = `${route.name}-${routeKeyCounter++}`;\n  if (process.env.ONE_DEBUG_ROUTER) {\n    console.info(`[one] getRouteWithKey: ${route.name} -> key=${key}`);\n  }\n  return { ...route, key };\n}\nconst createStateObject = (initialRoute, route, isEmpty) => {\n  if (isEmpty) {\n    if (initialRoute) {\n      return {\n        index: 1,\n        // @modified: add deterministic keys\n        routes: [getRouteWithKey({ name: initialRoute }), getRouteWithKey(route)]\n      };\n    } else {\n      return {\n        // @modified: add deterministic keys\n        routes: [getRouteWithKey(route)]\n      };\n    }\n  } else {\n    if (initialRoute) {\n      return {\n        index: 1,\n        // @modified: add deterministic keys\n        routes: [\n          getRouteWithKey({ name: initialRoute }),\n          getRouteWithKey({ ...route, state: { routes: [] } })\n        ]\n      };\n    } else {\n      return {\n        // @modified: add deterministic keys\n        routes: [getRouteWithKey({ ...route, state: { routes: [] } })]\n      };\n    }\n  }\n};\nconst createNestedStateObject = ({ path, ...restPathData }, routes, initialRoutes, flatConfig) => {\n  let route = routes.shift();\n  const parentScreens = [];\n  let initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);\n  parentScreens.push(route.name);\n  const state = createStateObject(initialRoute, route, routes.length === 0);\n  if (routes.length > 0) {\n    let nestedState = state;\n    while (route = routes.shift()) {\n      initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);\n      const nestedStateIndex = nestedState.index || nestedState.routes.length - 1;\n      nestedState.routes[nestedStateIndex].state = createStateObject(\n        initialRoute,\n        route,\n        routes.length === 0\n      );\n      if (routes.length > 0) {\n        nestedState = nestedState.routes[nestedStateIndex].state;\n      }\n      parentScreens.push(route.name);\n    }\n  }\n  route = findFocusedRoute(state);\n  route.path = restPathData.pathWithoutGroups;\n  const params = parseQueryParamsExtended(\n    path,\n    route,\n    flatConfig ? findParseConfigForRoute(route.name, flatConfig) : void 0,\n    restPathData.hash\n  );\n  if (params) {\n    route.params = { ...route.params, ...params };\n  }\n  return state;\n};\nexport {\n  getStateFromPath\n};\n//# sourceMappingURL=getStateFromPath.js.map\n"],"mappings":";;;;;;;AAeA,SAAS,iBAAiB,MAAM,SAAS;CACvC,qBAAqB;CACrB,IAAI,QAAQ,IAAI,kBAAkB;EAChC,QAAQ,KACN,2CAA2C,KAAK,aAAa,OAAO,WAAW,aACjF;CACF;CACA,MAAM,EAAE,eAAe,SAAS,sBAAsB,mBAAmB,OAAO;CAChF,MAAM,UAAU,SAAS;CACzB,MAAM,WAAW,qCAAqC,IAAI;CAC1D,IAAI,YAAY,SAAS,oBAAoB,QAAQ,QAAQ,GAAG,CAAC,CAAC,QAAQ,OAAO,EAAE,CAAC,CAAC,QAAQ,SAAS,EAAE;CACxG,YAAY,UAAU,SAAS,GAAG,IAAI,YAAY,GAAG,UAAU;CAC/D,MAAM,SAAS,SAAS,MAAM,QAAQ,OA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