{"version":3,"file":"getLinkingConfig.js","names":[],"sources":["esm/router/getLinkingConfig.js"],"sourcesContent":["import { getActionFromState } from \"@react-navigation/native\";\nimport { getReactNavigationConfig } from \"../getReactNavigationConfig\";\nimport {\n  addEventListener,\n  getDefaultLinkingPrefixes,\n  getInitialURL,\n  getPathFromState,\n  getStateFromPath\n} from \"../link/linking\";\nimport { normalizeLinkingConfig } from \"../link/getLinking\";\nimport { evictOldest } from \"../utils/evictOldest\";\nfunction getNavigationConfig(routes, metaOnly = true) {\n  return getReactNavigationConfig(routes, metaOnly);\n}\nfunction getLinkingConfig(routes, metaOnly = true, linking) {\n  const config = getNavigationConfig(routes, metaOnly);\n  const resolvedLinking = normalizeLinkingConfig(linking, getDefaultLinkingPrefixes());\n  return {\n    prefixes: resolvedLinking.prefixes,\n    filter: resolvedLinking.filter,\n    // @ts-expect-error\n    config,\n    // A custom getInitialURL is used on native to ensure the app always starts at\n    // the root path if it's launched from something other than a deep link.\n    // This helps keep the native functionality working like the web functionality.\n    // For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`\n    // then `/index` would be used on web and `/settings` would be used on native.\n    getInitialURL,\n    subscribe: addEventListener,\n    getStateFromPath: getStateFromPathMemoized,\n    getPathFromState(state, options) {\n      return getPathFromState(state, {\n        ...config,\n        ...options\n      }) ?? \"/\";\n    },\n    // Add all functions to ensure the types never need to fallback.\n    // This is a convenience for usage in the package.\n    getActionFromState\n  };\n}\nconst stateCache = /* @__PURE__ */ new Map();\nconst STATE_CACHE_THRESHOLD = 5e3;\nconst STATE_CACHE_EVICTION = 1e3;\nfunction clearStateCache() {\n  stateCache.clear();\n}\nfunction getStateFromPathMemoized(path, options) {\n  const cached = stateCache.get(path);\n  if (cached) {\n    return cached;\n  }\n  const result = getStateFromPath(path, options);\n  evictOldest(stateCache, STATE_CACHE_THRESHOLD, STATE_CACHE_EVICTION);\n  stateCache.set(path, result);\n  return result;\n}\nexport {\n  clearStateCache,\n  getLinkingConfig,\n  getNavigationConfig,\n  stateCache\n};\n//# sourceMappingURL=getLinkingConfig.js.map\n"],"mappings":";;;;;;;AAWA,SAAS,oBAAoB,QAAQ,WAAW,MAAM;CACpD,OAAO,yBAAyB,QAAQ,QAAQ;AAClD;AACA,SAAS,iBAAiB,QAAQ,WAAW,MAAM,SAAS;CAC1D,MAAM,SAAS,oBAAoB,QAAQ,QAAQ;CACnD,MAAM,kBAAkB,uBAAuB,SAAS,0BAA0B,CAAC;CACnF,OAAO;EACL,UAAU,gBAAgB;EAC1B,QAAQ,gBAAgB;EAExB;EAMA;EACA,WAAW;EACX,kBAAkB;EAClB,iBAAiB,OAAO,SAAS;GAC/B,OAAO,iBAAiB,OAAO;IAC7B,GAAG;IACH,GAAG;GACL,CAAC,KAAK;EACR;EAGA;CACF;AACF;AACA,MAAM,6BAA6B,IAAI,IAAI;AAC3C,MAAM,wBAAwB;AAC9B,MAAM,uBAAuB;AAC7B,SAAS,kBAAkB;CACzB,WAAW,MAAM;AACnB;AACA,SAAS,yBAAyB,MAAM,SAAS;CAC/C,MAAM,SAAS,WAAW,IAAI,IAAI;CAClC,IAAI,QAAQ;EACV,OAAO;CACT;CACA,MAAM,SAAS,iBAAiB,MAAM,OAAO;CAC7C,YAAY,YAAY,uBAAuB,oBAAoB;CACnE,WAAW,IAAI,MAAM,MAAM;CAC3B,OAAO;AACT"}