{"ast":null,"code":"import _asyncToGenerator from \"@babel/runtime/helpers/asyncToGenerator\";\nimport Constants, { ExecutionEnvironment } from \"expo-constants\";\nimport * as Linking from \"expo-linking\";\nimport Platform from \"react-native-web/dist/exports/Platform\";\nimport { adjustPathname } from \"../fork/extractPathFromURL\";\nimport getPathFromState from \"../fork/getPathFromState\";\nimport getStateFromPath from \"../fork/getStateFromPath\";\nexport function getInitialURL() {\n  if (process.env.NODE_ENV === \"test\") {\n    var _Linking$getInitialUR;\n    return (_Linking$getInitialUR = Linking.getInitialURL()) != null ? _Linking$getInitialUR : getRootURL();\n  }\n  if (Platform.OS === \"web\") {\n    var _window$location;\n    if (typeof window === \"undefined\") {\n      return \"\";\n    } else if (typeof ((_window$location = window.location) == null ? void 0 : _window$location.href) === \"string\") {\n      return window.location.href;\n    }\n  }\n  return Promise.race([_asyncToGenerator(function* () {\n    var url = yield Linking.getInitialURL();\n    if (url && Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n      var parsed = Linking.parse(url);\n      if (parsed.path === null || [\"\", \"/\"].includes(adjustPathname({\n        hostname: parsed.hostname,\n        pathname: parsed.path\n      }))) {\n        return getRootURL();\n      }\n    }\n    return url != null ? url : getRootURL();\n  })(), new Promise(function (resolve) {\n    return setTimeout(function () {\n      return resolve(getRootURL());\n    }, 150);\n  })]);\n}\nvar _rootURL;\nexport function getRootURL() {\n  if (_rootURL === undefined) {\n    _rootURL = Linking.createURL(\"/\");\n  }\n  return _rootURL;\n}\nexport function addEventListener(listener) {\n  var callback = undefined;\n  if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n    callback = function callback(_ref2) {\n      var url = _ref2.url;\n      var parsed = Linking.parse(url);\n      if (parsed.path === null || [\"\", \"/\"].includes(adjustPathname({\n        hostname: parsed.hostname,\n        pathname: parsed.path\n      }))) {\n        listener(getRootURL());\n      } else {\n        listener(url);\n      }\n    };\n  } else {\n    callback = function callback(_ref3) {\n      var url = _ref3.url;\n      return listener(url);\n    };\n  }\n  var subscription = Linking.addEventListener(\"url\", callback);\n  return function () {\n    subscription == null ? void 0 : subscription.remove == null ? void 0 : subscription.remove();\n  };\n}\nexport { getStateFromPath, getPathFromState };","map":{"version":3,"names":["Constants","ExecutionEnvironment","Linking","Platform","adjustPathname","getPathFromState","getStateFromPath","getInitialURL","process","env","NODE_ENV","_Linking$getInitialUR","getRootURL","OS","_window$location","window","location","href","Promise","race","_asyncToGenerator","url","executionEnvironment","StoreClient","parsed","parse","path","includes","hostname","pathname","resolve","setTimeout","_rootURL","undefined","createURL","addEventListener","listener","callback","_ref2","_ref3","subscription","remove"],"sources":["/Users/Daniel.Antelo/Workspaces/expo-template-reactrouter-nativebase/node_modules/expo-router/src/link/linking.ts"],"sourcesContent":["import Constants, { ExecutionEnvironment } from \"expo-constants\";\nimport * as Linking from \"expo-linking\";\nimport { Platform } from \"react-native\";\n\nimport { adjustPathname } from \"../fork/extractPathFromURL\";\nimport getPathFromState from \"../fork/getPathFromState\";\nimport getStateFromPath from \"../fork/getStateFromPath\";\n\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.\nexport function getInitialURL(): Promise<string | null> | string {\n  if (process.env.NODE_ENV === \"test\") {\n    return Linking.getInitialURL() ?? getRootURL();\n  }\n\n  if (Platform.OS === \"web\") {\n    if (typeof window === \"undefined\") {\n      return \"\";\n    } else if (typeof window.location?.href === \"string\") {\n      return window.location.href;\n    }\n  }\n  return Promise.race<string>([\n    (async () => {\n      const url = await Linking.getInitialURL();\n\n      // NOTE(EvanBacon): This could probably be wrapped with the development boundary\n      // since Expo Go is mostly just used in development.\n\n      // Expo Go is weird and requires the root path to be `/--/`\n      if (\n        url &&\n        Constants.executionEnvironment === ExecutionEnvironment.StoreClient\n      ) {\n        const parsed = Linking.parse(url);\n        // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n        // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n        if (\n          parsed.path === null ||\n          [\"\", \"/\"].includes(\n            adjustPathname({\n              hostname: parsed.hostname,\n              pathname: parsed.path,\n            })\n          )\n        ) {\n          return getRootURL();\n        }\n      }\n      // The path will be nullish in bare apps when the app is launched from the home screen.\n      // TODO(EvanBacon): define some policy around notifications.\n      return url ?? getRootURL();\n    })(),\n    new Promise<string>((resolve) =>\n      // Timeout in 150ms if `getInitialState` doesn't resolve\n      // Workaround for https://github.com/facebook/react-native/issues/25675\n      setTimeout(() => resolve(getRootURL()), 150)\n    ),\n  ]);\n}\n\nlet _rootURL: string | undefined;\n\nexport function getRootURL(): string {\n  if (_rootURL === undefined) {\n    _rootURL = Linking.createURL(\"/\");\n  }\n  return _rootURL;\n}\n\nexport function addEventListener(listener: (url: string) => void) {\n  let callback: (({ url }: { url: string }) => void) | undefined = undefined;\n\n  if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n    // This extra work is only done in the Expo Go app.\n    callback = ({ url }: { url: string }) => {\n      const parsed = Linking.parse(url);\n\n      // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n      // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n      if (\n        parsed.path === null ||\n        [\"\", \"/\"].includes(\n          adjustPathname({ hostname: parsed.hostname, pathname: parsed.path })\n        )\n      ) {\n        listener(getRootURL());\n      } else {\n        listener(url);\n      }\n    };\n  } else {\n    callback = ({ url }: { url: string }) => listener(url);\n  }\n  const subscription = Linking.addEventListener(\"url\", callback);\n\n  return () => {\n    // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n    subscription?.remove?.();\n  };\n}\n\nexport { getStateFromPath, getPathFromState };\n"],"mappings":";AAAA,OAAOA,SAAS,IAAIC,oBAAoB,QAAQ,gBAAgB;AAChE,OAAO,KAAKC,OAAO,MAAM,cAAc;AAAC,OAAAC,QAAA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