import { getResourceUrl } from "./resource-url-utils.js";
function getAssetPath(path) {
    const resourceUrl = getResourceUrl();
    const baseUrl = void 0 !== resourceUrl ? new URL('./', resourceUrl).href : new URL('./', window.document.baseURI).href;
    const assetUrl = new URL(path, baseUrl);
    return assetUrl.origin !== window.location.origin ? assetUrl.href : assetUrl.pathname;
}
function parseAssetURL(url, assetPath = './assets') {
    const [, protocol, remainder] = url.match(/^([a-z]+):\/\/(.*?)(\.svg)?$/) || [];
    if (!protocol) {
        if (url.startsWith('./') || url.startsWith('../')) return url;
        return null;
    }
    if ('http' === protocol || 'https' === protocol) return url;
    if ('assets' === protocol) return getAssetPath(`${assetPath}/${remainder}.svg`);
    return null;
}
export { getAssetPath, parseAssetURL };
