import { AppObjectPM, getSingletonComponent, } from "@vived/core";
import { StylusEntity } from "../Entity/StylusEntity";
export class StylusIsInUsePM extends AppObjectPM {
}
StylusIsInUsePM.type = "StylusIsInUsePM";
StylusIsInUsePM.get = (appObjects) => getSingletonComponent(StylusIsInUsePM.type, appObjects);
export function makeStylusIsInUsePM(appObject) {
    return new StylusIsInUsePMImp(appObject);
}
class StylusIsInUsePMImp extends StylusIsInUsePM {
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, StylusIsInUsePM.type);
        this.onStylusChange = () => {
            if (!this.stylus)
                return;
            this.doUpdateView(this.stylus.isInUse);
        };
        this.stylus = appObject.getComponent(StylusEntity.type);
        if (this.stylus) {
            this.stylus.addChangeObserver(this.onStylusChange);
            this.onStylusChange();
        }
        else {
            this.warn("App Object does not have a Stylus Entity");
        }
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=StylusIsInUsePM.js.map