import { AppObjectPM, getSingletonComponent, } from "@vived/core";
import { BaseAppState } from "../Entity";
export class SlideNavigationPM extends AppObjectPM {
}
SlideNavigationPM.type = "SlideNavigationPM";
SlideNavigationPM.get = (appObjects) => getSingletonComponent(SlideNavigationPM.type, appObjects);
export const defaultSlideNavigationVM = {
    hasNextState: true,
    hasPreviousState: false,
    hideNavigation: false,
};
export function makeSlideNavigationPM(appObject) {
    return new SlideNavigationPMImp(appObject);
}
class SlideNavigationPMImp extends SlideNavigationPM {
    get baseAppState() {
        return this.getCachedSingleton(BaseAppState.type);
    }
    vmsAreEqual(a, b) {
        if (a.hasNextState !== b.hasNextState)
            return false;
        if (a.hasPreviousState !== b.hasPreviousState)
            return false;
        if (a.hideNavigation !== b.hideNavigation)
            return false;
        return true;
    }
    constructor(appObject) {
        super(appObject, SlideNavigationPM.type);
        this.onAppStateChange = () => {
            if (!this.baseAppState)
                return;
            const hasNextState = this.baseAppState.hasNextState;
            const hasPreviousState = this.baseAppState.hasPreviousState;
            const hideNavigation = this.baseAppState.hideSlideNavigation;
            const vm = { hasNextState, hasPreviousState, hideNavigation };
            this.doUpdateView(vm);
        };
        this.baseAppState?.addChangeObserver(this.onAppStateChange);
        this.onAppStateChange();
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=SlideNavigationPM.js.map