import { getPortalUrl } from "./get-portal-url";
import { HUB_CDN_URLMAP } from "./hub-cdn-urlmap";
import { ENTERPRISE_SITES_PATH } from "../ArcGISContext";
// TODO: should this take IHubRequestOptions as well as a portal?
// if so, address when we tackle https://github.com/Esri/hub.js/issues/321
/**
 * Given a Portal object, return the full Hub locale asset url
 * Used for fetching translations
 * @param {Object} portal Portal Self
 */
export function getHubLocaleAssetUrl(portal) {
    if (portal.isPortal) {
        // Enterprise - use Site app as source for assets
        const baseUrl = getPortalUrl(portal);
        return `${baseUrl}${ENTERPRISE_SITES_PATH}`;
    }
    else {
        // AGO - Convert portalHostname into CDN url
        const index = portal.portalHostname.split(".")[0];
        const base = HUB_CDN_URLMAP[index] || HUB_CDN_URLMAP.www;
        return `${base}/opendata-ui/assets`;
    }
}
//# sourceMappingURL=get-hub-locale-asset-url.js.map