"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.StorageServiceWithAttachBlobs = void 0;
/**
 * IRuntimeStorageService proxy which intercepts requests if they can be satisfied by the blobs received in the
 * attach message. We use this to avoid an unnecessary request to the storage service.
 */
class StorageServiceWithAttachBlobs {
    constructor(internalStorageService, attachBlobs) {
        this.internalStorageService = internalStorageService;
        this.attachBlobs = attachBlobs;
    }
    async readBlob(id) {
        const blob = this.attachBlobs.get(id);
        if (blob !== undefined) {
            return blob;
        }
        // Note that it is intentional not to cache the result of this readBlob - we'll trust the real
        // IRuntimeStorageService to cache appropriately, no need to double-cache.
        return this.internalStorageService.readBlob(id);
    }
}
exports.StorageServiceWithAttachBlobs = StorageServiceWithAttachBlobs;
//# sourceMappingURL=storageServiceWithAttachBlobs.js.map