"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.$clone = $clone;
const _1 = require("../Class/$");
const Unit_1 = require("../Class/Unit");
const cloneUnit_1 = require("../spec/cloneUnit");
function $clone(a) {
    if (typeof a !== 'object' || a === null) {
        return a;
    }
    if (a instanceof Set) {
        return new Set(a);
    }
    if (a.constructor.name === 'Array' || a.constructor.name === 'Object') {
        const _a = (Array.isArray(a) ? [] : {});
        for (const k in a) {
            _a[k] = $clone(a[k]);
        }
        return _a;
    }
    if (a instanceof _1.$) {
        if (a instanceof Unit_1.Unit) {
            return (0, cloneUnit_1.cloneUnit)(a, false)[0];
        }
    }
    return a;
}
//# sourceMappingURL=$clone.js.map