/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { EventDispatcher } from "@vertexvis/utils";
import { KeyBinding } from "../keyBinding";
export var ViewerWalkModeOperation;
(function (ViewerWalkModeOperation) {
    ViewerWalkModeOperation["MOVE_DOWN"] = "MOVE_DOWN";
    ViewerWalkModeOperation["MOVE_UP"] = "MOVE_UP";
    ViewerWalkModeOperation["PIVOT_DOWN"] = "PIVOT_DOWN";
    ViewerWalkModeOperation["PIVOT_LEFT"] = "PIVOT_LEFT";
    ViewerWalkModeOperation["PIVOT_RIGHT"] = "PIVOT_RIGHT";
    ViewerWalkModeOperation["PIVOT_UP"] = "PIVOT_UP";
    ViewerWalkModeOperation["WALK_BACKWARD"] = "WALK_BACKWARD";
    ViewerWalkModeOperation["WALK_FORWARD"] = "WALK_FORWARD";
    ViewerWalkModeOperation["WALK_LEFT"] = "WALK_LEFT";
    ViewerWalkModeOperation["WALK_RIGHT"] = "WALK_RIGHT";
})(ViewerWalkModeOperation || (ViewerWalkModeOperation = {}));
export class WalkModeModel {
    constructor() {
        this.keyBindings = {
            [ViewerWalkModeOperation.MOVE_DOWN]: [
                new KeyBinding('PageDown', '!Shift', '!Alt'),
            ],
            [ViewerWalkModeOperation.MOVE_UP]: [
                new KeyBinding('PageUp', '!Shift', '!Alt'),
            ],
            [ViewerWalkModeOperation.PIVOT_DOWN]: [
                new KeyBinding('ArrowDown', '!Shift', '!Alt'),
            ],
            [ViewerWalkModeOperation.PIVOT_LEFT]: [
                new KeyBinding('ArrowLeft', '!Shift', '!Alt'),
            ],
            [ViewerWalkModeOperation.PIVOT_RIGHT]: [
                new KeyBinding('ArrowRight', '!Shift', '!Alt'),
            ],
            [ViewerWalkModeOperation.PIVOT_UP]: [
                new KeyBinding('ArrowUp', '!Shift', '!Alt'),
            ],
            [ViewerWalkModeOperation.WALK_BACKWARD]: [new KeyBinding('s')],
            [ViewerWalkModeOperation.WALK_FORWARD]: [new KeyBinding('w')],
            [ViewerWalkModeOperation.WALK_LEFT]: [new KeyBinding('a')],
            [ViewerWalkModeOperation.WALK_RIGHT]: [new KeyBinding('d')],
        };
        this.configuration = {
            teleportHeightPercentage: 11.75,
            teleportDistancePercentage: 2,
            teleportCollisionDistance: 1000,
            keyboardWalkSpeed: 5,
            keyboardPivotDegrees: 1,
            keyboardRepeatIntervalMs: 25,
        };
        this.enabled = true;
        this.enabledChanged = new EventDispatcher();
        this.teleportModeChanged = new EventDispatcher();
        this.configurationChanged = new EventDispatcher();
        this.keyBindingsChanged = new EventDispatcher();
    }
    setEnabled(enabled) {
        this.enabled = enabled;
        this.enabledChanged.emit(enabled);
    }
    setTeleportMode(mode) {
        this.teleportMode = mode;
        this.teleportModeChanged.emit(mode);
    }
    setConfiguration(configuration) {
        this.configuration = configuration;
        this.configurationChanged.emit(configuration);
    }
    addKeyBinding(operation, keyBinding) {
        this.keyBindings[operation] = [...this.keyBindings[operation], keyBinding];
        this.keyBindingsChanged.emit(this.keyBindings);
    }
    replaceKeyBinding(operation, keyBinding) {
        this.keyBindings[operation] = [keyBinding];
        this.keyBindingsChanged.emit(this.keyBindings);
    }
    setExcludedPredicate(predicate) {
        this.excludedPredicate = predicate;
    }
    getEnabled() {
        return this.enabled;
    }
    getTeleportMode() {
        return this.teleportMode;
    }
    getTeleportHeightPercentage() {
        return this.configuration.teleportHeightPercentage;
    }
    getKeyboardWalkSpeed() {
        return this.configuration.keyboardWalkSpeed;
    }
    getKeyboardPivotDegrees() {
        return this.configuration.keyboardPivotDegrees;
    }
    getKeyboardRepeatInterval() {
        return this.configuration.keyboardRepeatIntervalMs;
    }
    getConfiguration() {
        return this.configuration;
    }
    getKeyBindings() {
        return this.keyBindings;
    }
    operationMatches(operation, state) {
        return this.keyBindings[operation].some((binding) => binding.matches(state));
    }
    isElementExcluded(el) {
        var _a;
        return !!((_a = this.excludedPredicate) === null || _a === void 0 ? void 0 : _a.call(this, el));
    }
    onEnabledChange(listener) {
        return this.enabledChanged.on(listener);
    }
    onTeleportModeChange(listener) {
        return this.teleportModeChanged.on(listener);
    }
    onConfigurationChange(listener) {
        return this.configurationChanged.on(listener);
    }
    onKeyBindingsChange(listener) {
        return this.keyBindingsChanged.on(listener);
    }
}
//# sourceMappingURL=model.js.map
