"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupUndoRedo = setupUndoRedo;
const Tools_1 = require("../../Tools");
const Controllers_1 = require("../Controllers");
const Entities_1 = require("../Entities");
const PM_1 = require("../PM");
const UCs_1 = require("../UCs");
function setupUndoRedo(appObjects) {
    const ao = appObjects.getOrCreate("UndoRedo");
    // Entity
    const undoRedo = (0, Entities_1.makeUndoRedoEntity)(ao);
    // UCs
    new UCs_1.UndoRedoToolStatesHook(ao);
    // PMs
    (0, PM_1.makeHasUndoPM)(ao);
    (0, PM_1.makeHasRedoPM)(ao);
    // Setup Tools
    const toolRepo = Tools_1.ToolRepository.get(appObjects);
    if (!toolRepo) {
        appObjects.submitWarning("setupHideable", "Unable to find tool repo");
        return ao;
    }
    let modifierKeyPrefix = "Ctrl";
    if (navigator.platform.indexOf("Mac") === 0 ||
        navigator.platform === "iPhone") {
        modifierKeyPrefix = "⌘";
    }
    const undoTool = toolRepo.makeToolFromData({
        toolType: "UNDO",
        isDefault: false,
        label: "Undo",
        shortcutLabel: `${modifierKeyPrefix} + z`,
        hotkeys: [
            { keyCode: "KeyZ", control: true },
            { keyCode: "KeyZ", meta: true },
        ],
    });
    undoTool.registerAction(() => (0, Controllers_1.doUndo)(appObjects));
    const redoTool = toolRepo.makeToolFromData({
        toolType: "REDO",
        isDefault: false,
        label: "Redo",
        shortcutLabel: `${modifierKeyPrefix} + Shift + z`,
        hotkeys: [
            { keyCode: "KeyY", control: true },
            { keyCode: "KeyY", meta: true },
            { keyCode: "KeyZ", control: true, shift: true },
            { keyCode: "KeyZ", meta: true, shift: true },
        ],
    });
    redoTool.registerAction(() => (0, Controllers_1.doRedo)(appObjects));
    return ao;
}
//# sourceMappingURL=setupUndoRedo.js.map