{"version":3,"file":"url.js","names":[],"sources":["esm/head/url.js"],"sourcesContent":["const protocolWarningString = `{ plugins: [[\"router\", { origin: \"...<URL>...\" }]] }`;\nfunction memoize(fn) {\n  const cache = {};\n  return ((...args) => {\n    const key = JSON.stringify(args);\n    if (cache[key]) {\n      return cache[key];\n    }\n    const result = fn(...args);\n    cache[key] = result;\n    return result;\n  });\n}\nfunction sanitizeUrl(url) {\n  const parsed = new URL(url);\n  const validProtocol = !parsed.protocol || parsed.protocol === \"http:\" || parsed.protocol === \"https:\";\n  if (!validProtocol) {\n    throwOrAlert(\n      `One Head: Native origin has invalid protocol \"${parsed.protocol}\" for URL in Config: ${protocolWarningString}.`\n    );\n  }\n  parsed.pathname = \"\";\n  parsed.search = \"\";\n  parsed.hash = \"\";\n  parsed.protocol ??= \"https:\";\n  return parsed.toString().replace(/\\/$/, \"\");\n}\nconst memoSanitizeUrl = memoize(sanitizeUrl);\nfunction getUrlFromConstants() {\n  const origin = process.env.One_ORIGIN;\n  if (!origin) {\n    throwOrAlert(\n      `One Head: Add the handoff origin to the Config (requires rebuild). Add the Config Plugin ${protocolWarningString}, where \\`origin\\` is the hosted URL.`\n    );\n    return \"https://expo.dev\";\n  }\n  if (!origin.match(/^http(s)?:\\/\\//)) {\n    console.warn(\n      `One Head: origin \"${origin}\" is missing a \\`https://\\` protocol. ${protocolWarningString}.`\n    );\n  }\n  return memoSanitizeUrl(origin);\n}\nfunction throwOrAlert(msg) {\n  console.warn(`TODO FIX: ${msg}`);\n}\nfunction getStaticUrlFromOneRouter(pathname) {\n  return getUrlFromConstants() + pathname;\n}\nexport {\n  getStaticUrlFromOneRouter\n};\n//# sourceMappingURL=url.js.map\n"],"mappings":";AAAA,MAAM,wBAAwB;AAC9B,SAAS,QAAQ,IAAI;CACnB,MAAM,QAAQ,CAAC;CACf,SAAS,GAAG,SAAS;EACnB,MAAM,MAAM,KAAK,UAAU,IAAI;EAC/B,IAAI,MAAM,MAAM;GACd,OAAO,MAAM;EACf;EACA,MAAM,SAAS,GAAG,GAAG,IAAI;EACzB,MAAM,OAAO;EACb,OAAO;CACT;AACF;AACA,SAAS,YAAY,KAAK;CACxB,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,MAAM,gBAAgB,CAAC,OAAO,YAAY,OAAO,aAAa,WAAW,OAAO,aAAa;CAC7F,IAAI,CAAC,eAAe;EAClB,aACE,iDAAiD,OAAO,SAAS,uBAAuB,sBAAsB,EAChH;CACF;CACA,OAAO,WAAW;CAClB,OAAO,SAAS;CAChB,OAAO,OAAO;CACd,OAAO,aAAa;CACpB,OAAO,OAAO,SAAS,CAAC,CAAC,QAAQ,OAAO,EAAE;AAC5C;AACA,MAAM,kBAAkB,QAAQ,WAAW;AAC3C,SAAS,sBAAsB;CAC7B,MAAM,SAAS,QAAQ,IAAI;CAC3B,IAAI,CAAC,QAAQ;EACX,aACE,4FAA4F,sBAAsB,sCACpH;EACA,OAAO;CACT;CACA,IAAI,CAAC,OAAO,MAAM,gBAAgB,GAAG;EACnC,QAAQ,KACN,qBAAqB,OAAO,wCAAwC,sBAAsB,EAC5F;CACF;CACA,OAAO,gBAAgB,MAAM;AAC/B;AACA,SAAS,aAAa,KAAK;CACzB,QAAQ,KAAK,aAAa,KAAK;AACjC;AACA,SAAS,0BAA0B,UAAU;CAC3C,OAAO,oBAAoB,IAAI;AACjC"}