"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnhideAllChannelModelObjectsUC = void 0;
exports.makeUnhideAllChannelModelObjectsUC = makeUnhideAllChannelModelObjectsUC;
const core_1 = require("@vived/core");
const DispatchStateChangeUC_1 = require("../../Dispatcher/UC/DispatchStateChangeUC");
const Hideable_1 = require("../../Hideable/Entities/Hideable");
const ChannelModel_1 = require("../Entities/ChannelModel");
const UnhideAllAppObjectsUndoRedo_1 = require("./UnhideAllAppObjectsUndoRedo");
class UnhideAllChannelModelObjectsUC extends core_1.AppObjectUC {
    static get(id, appObjects) {
        return appObjects
            .get(id)
            ?.getComponent(UnhideAllChannelModelObjectsUC.type);
    }
}
exports.UnhideAllChannelModelObjectsUC = UnhideAllChannelModelObjectsUC;
UnhideAllChannelModelObjectsUC.type = "UnhideAllChannelModelObjectsUC";
function makeUnhideAllChannelModelObjectsUC(appObject) {
    return new UnhideAllChannelModelObjectsUCImp(appObject);
}
class UnhideAllChannelModelObjectsUCImp extends UnhideAllChannelModelObjectsUC {
    get model() {
        return this.getCachedLocalComponent(ChannelModel_1.ChannelModelEntity.type);
    }
    get dispatchStateChange() {
        return this.getCachedSingleton(DispatchStateChangeUC_1.DispatchStateChangeUC.type)?.doDispatch;
    }
    constructor(appObject) {
        super(appObject, UnhideAllChannelModelObjectsUC.type);
        this.unhideAll = () => {
            if (!this.model)
                return;
            const hiddenObjectIDs = [];
            this.model.modelObjectIds.forEach((id) => {
                const hideable = Hideable_1.Hideable.get(id, this.appObjects);
                if (hideable && hideable.isHidden) {
                    hiddenObjectIDs.push(id);
                    hideable.isHidden = false;
                }
            });
            if (hiddenObjectIDs.length === 0)
                return;
            if (this.dispatchStateChange) {
                this.dispatchStateChange();
            }
            new UnhideAllAppObjectsUndoRedo_1.UnhideAllAppObjectsUndoRedo(hiddenObjectIDs, this.appObjects);
        };
    }
}
//# sourceMappingURL=UnhideAllChannelModelObjectsUC.js.map