"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloneUnitClass = exports.cloneUnit = void 0;
const object_1 = require("../util/object");
const fromUnitBundle_1 = require("./fromUnitBundle");
function cloneUnit(unit, deep = false) {
    const { __system } = unit;
    const [NewBundle, bundle] = cloneUnitClass(unit, deep);
    const newUnit = new NewBundle(__system);
    return [newUnit, bundle];
}
exports.cloneUnit = cloneUnit;
function cloneUnitClass(unit, deep = false) {
    const { __system } = unit;
    const specs = __system.specs;
    const bundle = (0, object_1.clone)(unit.getUnitBundleSpec(deep));
    const NewBundle = (0, fromUnitBundle_1.fromUnitBundle)(bundle, specs, __system.classes);
    return [NewBundle, bundle];
}
exports.cloneUnitClass = cloneUnitClass;
//# sourceMappingURL=cloneUnit.js.map