import { default as BaseModel } from "./BaseModel.js";
import SetModel from "./SetModel.js";
import ArbiterModel from "./ArbiterModel.js";
import ContextAttributes from "./ContextAttributes.js";
import { GlobalEnvironment } from "../Environment/GlobalEnvironment.js";
import StorageManager from "./Storage/StorageManager.js";
export default class ContextModel extends BaseModel {
    constructor(options) {
        super(options);
        this.m_data = options.data;
        this.m_attributes = new ContextAttributes(options.data.attributes);
        this.m_storage = new StorageManager({
            parent: this
        });
        this.m_environment = new GlobalEnvironment({
            parent: this
        });
        this.m_parent = options.parent;
        this.state.unset("parent");
        this.m_arbiter = new ArbiterModel({
            data: options.data.arbiter,
            parent: this,
            root: options.root
        });
        this.m_set = new SetModel({
            data: options.data.featureSet,
            parent: this,
            root: options.root
        });
    }
    get attributes() {
        return this.m_attributes;
    }
    get arbiter() {
        return this.m_arbiter;
    }
    get featureSet() {
        return this.m_set;
    }
    get parent() {
        return this.m_parent;
    }
    get globals() {
        return this.m_environment;
    }
    get storage() {
        return this.m_storage;
    }
    get data() {
        return this.m_data;
    }
    toJSON() {
        this.storage.serialize();
        return {
            arbiter: this.arbiter.toJSON(),
            featureSet: this.featureSet.toJSON(),
            attributes: this.attributes.toJSON()
        };
    }
}
