import { AppObjectUC, getSingletonComponent, } from "@vived/core";
import { AppDispatcher } from "../Entities/AppDispatcher";
export class IsZSpaceAvailableUC extends AppObjectUC {
    constructor() {
        super(...arguments);
        this.requestType = "IS_ZSPACE_AVAILABLE";
    }
}
IsZSpaceAvailableUC.type = "IsZSpaceAvailableUC";
IsZSpaceAvailableUC.get = (appObjects) => getSingletonComponent(IsZSpaceAvailableUC.type, appObjects);
export function makeIsZSpaceAvailableUC(appObject) {
    return new DispatchStateChangeUCImp(appObject);
}
class DispatchStateChangeUCImp extends IsZSpaceAvailableUC {
    constructor(appObject) {
        super(appObject, IsZSpaceAvailableUC.type);
        this.requestVersion = 1;
        this.doDispatch = () => {
            return new Promise((resolve, reject) => {
                const callback = (IsZSpaceAvailable) => {
                    resolve(IsZSpaceAvailable);
                };
                const payload = {
                    callback,
                };
                if (!this.appDispatcher)
                    return reject(new Error("No host handler has been registered"));
                else {
                    this.appDispatcher.formRequestAndDispatch(this.requestType, this.requestVersion, payload);
                }
            });
        };
        this.appDispatcher = appObject.getComponent(AppDispatcher.type);
        if (!this.appDispatcher) {
            this.warn("IsZSpaceAvailableUC has been added to an App Object that does not have a AppDispatcher. Add a dispatcher first");
            this.dispose();
        }
    }
}
//# sourceMappingURL=IsZSpaceAvailableUC.js.map