UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

58 lines (57 loc) 1.44 kB
import { CDN_ENVIRONMENTS as l, API_ENVIRONMENTS as $ } from "./constants.js"; import { httpGet as i } from "./Http/http.js"; const c = "test", a = "live", d = (r) => r?.replace?.(/([^/])$/, "$1/"), u = (r) => r?.replace(/^([^/])/, "/$1"), v = /* @__PURE__ */ (() => { const r = $, e = l; return (t) => { const n = e[(t === "test" ? "live" : t) ?? a] || e[a]; return { apiUrl: r[t ?? c] || r[c], cdnTranslationsUrl: `${n}/assets/translations`, cdnAssetsUrl: `${n}/assets`, cdnConfigUrl: `${n}/config` }; }; })(), E = ({ url: r }) => async ({ name: e, extension: t = "json", fallback: o, subFolder: n = "" }) => { try { return await i({ loadingContext: `${r}${n ? `/${n}` : ""}`, path: `/${e}.${t}`, versionless: !0, skipContentType: !0, errorLevel: "error" }); } catch (s) { return console.warn(s), o; } }, N = ({ url: r }) => async ({ name: e, extension: t = "json", fallback: o, subFolder: n = "" }) => { try { return await i({ loadingContext: `${r}${n ? `/${n}` : ""}`, path: `/${e}.${t}`, versionless: !0, skipContentType: !0, errorLevel: "error" }); } catch (s) { return console.warn(s), o; } }; export { a as FALLBACK_CDN_ENV, c as FALLBACK_ENV, E as getConfigFromCdn, N as getDatasetFromCdn, d as normalizeLoadingContext, u as normalizeUrl, v as resolveEnvironment };