"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    clearIconCache: ()=>clearIconCache,
    fetchIcon: ()=>fetchIcon
});
const memoize_cjs_namespaceObject = require("../../../utils/memoize.cjs");
class IconFetchError extends Error {
    static fromStatusCode(url, statusCode, statusText) {
        return new IconFetchError(url, `status code ${statusCode} (${statusText})`);
    }
    static fromError(url, error) {
        return new IconFetchError(url, 'an error', error);
    }
    constructor(url, errorMessage, errorObject){
        super(`Could not fetch icon from ${url}, got ${errorMessage}.`), this.url = url, this.errorObject = errorObject;
    }
}
const fetchIconUnmemoized = async (url)=>fetch(url).catch((e)=>{
        throw IconFetchError.fromError(url, e);
    }).then((response)=>{
        if (200 !== response.status && 304 !== response.status) throw IconFetchError.fromStatusCode(url, response.status, response.statusText);
        return response.text();
    });
const memoizedFetchIcon = (0, memoize_cjs_namespaceObject.memoize)(fetchIconUnmemoized, (url)=>url, {
    maxEntries: 20
});
const fetchIcon = memoizedFetchIcon.fn;
function clearIconCache() {
    memoizedFetchIcon.clearCache();
}
exports.clearIconCache = __webpack_exports__.clearIconCache;
exports.fetchIcon = __webpack_exports__.fetchIcon;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "clearIconCache",
    "fetchIcon"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
