"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStorageBackend = getStorageBackend;
exports.resetStorageBackend = resetStorageBackend;
const local_1 = require("./local");
let _backend = null;
/**
 * Returns the singleton storage backend.
 *
 * Backend selection (via LT_STORAGE_BACKEND env var):
 *   "local" (default) — filesystem storage under LT_FILE_STORAGE_DIR
 *   "s3"              — S3-compatible (MinIO, AWS S3, GCP Cloud Storage)
 */
function getStorageBackend() {
    if (!_backend) {
        const type = process.env.LT_STORAGE_BACKEND || 'local';
        if (type === 's3') {
            // Lazy require to avoid loading @aws-sdk when not needed
            const { S3StorageBackend } = require('./s3');
            _backend = new S3StorageBackend();
        }
        else {
            _backend = new local_1.LocalStorageBackend();
        }
    }
    return _backend;
}
/** Reset the singleton (for testing). */
function resetStorageBackend() {
    _backend = null;
}
