import { AppObjectEntity, getSingletonComponent, } from "@vived/core";
export class FeatureFlagsEntity extends AppObjectEntity {
    static get(appObjects) {
        return getSingletonComponent(FeatureFlagsEntity.type, appObjects);
    }
}
FeatureFlagsEntity.type = "FeatureFlagsEntity";
export 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