import { AppObjectUC } from "@vived/core";
import { DispatchStateChangeUC } from "../../Dispatcher/UC/DispatchStateChangeUC";
import { Hideable } from "../../Hideable/Entities/Hideable";
import { ChannelModelEntity } from "../Entities/ChannelModel";
import { UnhideAllAppObjectsUndoRedo } from "./UnhideAllAppObjectsUndoRedo";
export class UnhideAllChannelModelObjectsUC extends AppObjectUC {
    static get(id, appObjects) {
        return appObjects
            .get(id)
            ?.getComponent(UnhideAllChannelModelObjectsUC.type);
    }
}
UnhideAllChannelModelObjectsUC.type = "UnhideAllChannelModelObjectsUC";
export function makeUnhideAllChannelModelObjectsUC(appObject) {
    return new UnhideAllChannelModelObjectsUCImp(appObject);
}
class UnhideAllChannelModelObjectsUCImp extends UnhideAllChannelModelObjectsUC {
    get model() {
        return this.getCachedLocalComponent(ChannelModelEntity.type);
    }
    get dispatchStateChange() {
        return this.getCachedSingleton(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.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(hiddenObjectIDs, this.appObjects);
        };
    }
}
//# sourceMappingURL=UnhideAllChannelModelObjectsUC.js.map