import { assign as q } from "../../../../min-dash/dist/index.esm.mjs";
var d = {
  moveSpeed: 50,
  moveSpeedAccelerated: 200
};
function w(n, t, c) {
  var i = this;
  this._config = q({}, d, n || {}), t.addListener(v);
  function v(s) {
    var r = s.keyEvent, a = i._config;
    if (t.isCmd(r) && t.isKey([
      "ArrowLeft",
      "Left",
      "ArrowUp",
      "Up",
      "ArrowDown",
      "Down",
      "ArrowRight",
      "Right"
    ], r)) {
      var o = t.isShift(r) ? a.moveSpeedAccelerated : a.moveSpeed, e;
      switch (r.key) {
        case "ArrowLeft":
        case "Left":
          e = "left";
          break;
        case "ArrowUp":
        case "Up":
          e = "up";
          break;
        case "ArrowRight":
        case "Right":
          e = "right";
          break;
        case "ArrowDown":
        case "Down":
          e = "down";
          break;
      }
      return i.moveCanvas({
        speed: o,
        direction: e
      }), true;
    }
  }
  this.moveCanvas = function(s) {
    var r = 0, a = 0, o = s.speed, e = o / Math.min(Math.sqrt(c.viewbox().scale), 1);
    switch (s.direction) {
      case "left":
        r = e;
        break;
      case "up":
        a = e;
        break;
      case "right":
        r = -e;
        break;
      case "down":
        a = -e;
        break;
    }
    c.scroll({
      dx: r,
      dy: a
    });
  };
}
w.$inject = [
  "config.keyboardMove",
  "keyboard",
  "canvas"
];
export {
  w as default
};
