"use strict";
// Copyright 2018-2024 the Deno authors. MIT license.
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _FetchCacher_fileFetcher;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FetchCacher = void 0;
/** Provides an interface to Deno's CLI cache.
 *
 * It is better to use the {@linkcode createCache} function directly. */
class FetchCacher {
    constructor(fileFetcher) {
        _FetchCacher_fileFetcher.set(this, void 0);
        // this should have the same interface as deno_graph's loader
        Object.defineProperty(this, "load", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: (specifier, _isDynamic, cacheSetting, checksum) => {
                const url = new URL(specifier);
                return __classPrivateFieldGet(this, _FetchCacher_fileFetcher, "f").fetch(url, { cacheSetting, checksum });
            }
        });
        __classPrivateFieldSet(this, _FetchCacher_fileFetcher, fileFetcher, "f");
    }
}
exports.FetchCacher = FetchCacher;
_FetchCacher_fileFetcher = new WeakMap();
