import { AppObjectController } from "@vived/core";
import { BaseAppState } from "../../BaseApp/Entity/BaseAppState";
import { KeyboardInputEntity, } from "../../KeyboardInput/Entities/KeyboardInput";
import { InspectorTabEntity } from "../Entities";
export class KeyboardToSetTab extends AppObjectController {
    get inspectorTabEntity() {
        return this.getCachedSingleton(InspectorTabEntity.type);
    }
    get baseApp() {
        return this.getCachedSingleton(BaseAppState.type);
    }
    constructor(appObject) {
        super(appObject, KeyboardToSetTab.type);
        this.codeLookup = new Map([
            ["Digit1", 0],
            ["Digit2", 1],
            ["Digit3", 2],
            ["Digit4", 3],
            ["Digit5", 4],
        ]);
        this.onKeyDown = (e) => {
            if (!this.inspectorTabEntity)
                return;
            if (this.baseApp?.isAuthoring !== true)
                return;
            if (!this.codeLookup.has(e.code))
                return;
            const desiredIndex = this.codeLookup.get(e.code);
            if (desiredIndex === undefined ||
                desiredIndex < 0 ||
                desiredIndex >= this.inspectorTabEntity.inspectorTabs.length) {
                return;
            }
            this.inspectorTabEntity.activeTabIndex = desiredIndex;
        };
        const keyboardInput = KeyboardInputEntity.get(this.appObjects);
        keyboardInput?.registerController(this);
    }
}
KeyboardToSetTab.type = "KeyboardToSetTab";
//# sourceMappingURL=KeyboardToSetTab.js.map