"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var JsonRefs = require("json-refs");
exports.RS_PROTOCOL = 'rs://';
var ResourceSetImpl = /** @class */ (function () {
    function ResourceSetImpl() {
        this.resourceMap = {};
    }
    ResourceSetImpl.prototype.getResource = function (name) {
        return this.resourceMap[name];
    };
    ResourceSetImpl.prototype.hasResource = function (name) {
        return this.resourceMap[name] !== undefined;
    };
    ResourceSetImpl.prototype.registerResource = function (name, resource, resolveReferences) {
        var _this = this;
        if (resolveReferences === void 0) { resolveReferences = false; }
        var oldResource = this.resourceMap[name];
        if (resolveReferences) {
            var resourcePromise = JsonRefs.resolveRefs(resource, { includeInvalid: true });
            resourcePromise.then(function (result) {
                _this.resourceMap[name] = result.resolved;
            });
        }
        else {
            this.resourceMap[name] = resource;
        }
        return oldResource;
    };
    ResourceSetImpl.prototype.clear = function () {
        this.resourceMap = {};
    };
    return ResourceSetImpl;
}());
exports.ResourceSetImpl = ResourceSetImpl;
//# sourceMappingURL=resource-set.js.map