"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeatureFlagsEntity = void 0;
exports.makeFeatureFlagsEntity = makeFeatureFlagsEntity;
const core_1 = require("@vived/core");
class FeatureFlagsEntity extends core_1.AppObjectEntity {
    static get(appObjects) {
        return (0, core_1.getSingletonComponent)(FeatureFlagsEntity.type, appObjects);
    }
}
exports.FeatureFlagsEntity = FeatureFlagsEntity;
FeatureFlagsEntity.type = "FeatureFlagsEntity";
function makeFeatureFlagsEntity(appObject) {
    return new FeatureFlagsEntityImp(appObject);
}
class FeatureFlagsEntityImp extends FeatureFlagsEntity {
    get flags() {
        return [...this._flags];
    }
    addFlag(feature) {
        if (this.hasFlag(feature))
            return;
        this._flags.push(feature);
        this.notifyOnChange();
    }
    removeFlag(feature) {
        if (!this.hasFlag(feature))
            return;
        this._flags = this._flags.filter((flag) => flag !== feature);
        this.notifyOnChange();
    }
    hasFlag(feature) {
        return this._flags.includes(feature);
    }
    constructor(appObject) {
        super(appObject, FeatureFlagsEntity.type);
        this._flags = [];
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=FeatureFlagEntity.js.map