import Model from "../Data/Model.js";
export default class EditorModel extends Model {
    constructor(options) {
        super(options.data);
        this.m_feature = options.feature;
        this.state.unset("feature", { silent: true });
    }
    get feature() {
        return this.m_feature;
    }
    get group() {
        return this.feature.parent;
    }
    get set() {
        return this.group.parent;
    }
    get root() {
        return this.set.root;
    }
    get controller() {
        return this.set.controller;
    }
    get attributes() {
        return this.state.get("attributes");
    }
    get script() {
        return this.state.get("script");
    }
    get uid() {
        return this.state.get("uid");
    }
    getFeatureValue(name, defaultValue) {
        return this.feature.getValue(name, defaultValue);
    }
    setFeatureValue(name, value, options = {}) {
        this.setSilence(options);
        this.setChangeSource(options);
        this.feature.setValue(name, value, options);
    }
    getRemoteFeatureValue(name, defaultValue) {
        return this.feature.getRemoteValue(name, defaultValue);
    }
    setRemoteFeatureValue(name, value, options = {}) {
        this.setSilence(options);
        this.setChangeSource(options);
        this.feature.setRemoteValue(name, value, options);
    }
    setSilence(options) {
        let valueChangesSilenced = this.root.context.featureSet.valueChangesAreSilent;
        options.silent = options.silent || valueChangesSilenced;
    }
    setChangeSource(options) {
        if (options.silent !== true && options.postback === true) {
            this.root.context.storage.global.postbackInputId = this.uid;
        }
    }
}
