import { AppObjectPM, getSingletonComponent, } from "@vived/core";
import { Selection } from "../Entities/Selection";
export class SelectedObjectPM extends AppObjectPM {
    static get(appObjects) {
        return getSingletonComponent(SelectedObjectPM.type, appObjects);
    }
}
SelectedObjectPM.type = "SelectedObjectPM";
export function makeSelectedObjectPM(appObj) {
    return new SelectedObjectPMImp(appObj);
}
class SelectedObjectPMImp extends SelectedObjectPM {
    get selection() {
        return this.getCachedSingleton(Selection.type);
    }
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, SelectedObjectPM.type);
        this.onSelectionChange = () => {
            if (!this.selection)
                return;
            this.doUpdateView(this.selection.selectedObjectId);
        };
        this.selection?.addChangeObserver(this.onSelectionChange);
        this.onSelectionChange();
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=SelectedObjectPM.js.map