"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bundleClass = void 0;
const parseMemorySpec_1 = require("./evaluate/parseMemorySpec");
const _temp_cache = {};
function bundleClass(Class, bundle) {
    const { unit: { id, memory }, } = bundle;
    const cacheKey = `${id}/${JSON.stringify(memory)}`;
    if (_temp_cache[cacheKey]) {
        return _temp_cache[cacheKey];
    }
    // @ts-ignore
    class Bundle extends Class {
        constructor(system) {
            bundle.specs && system.injectSpecs(bundle.specs);
            super(system, id);
            if (memory) {
                const _memory = (0, parseMemorySpec_1.parseMemorySpec)(memory, system.specs, system.classes);
                this.restore(_memory);
            }
        }
    }
    Bundle.__bundle = bundle;
    _temp_cache[cacheKey] = Bundle;
    // @ts-ignore
    return Bundle;
}
exports.bundleClass = bundleClass;
//# sourceMappingURL=bundleClass.js.map