import { keyName as u, base as c } from "../../../../w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js";
import { Plugin as d } from "../../../../prosemirror-state@1.4.3/node_modules/prosemirror-state/dist/index.js";
const p = typeof navigator < "u" && /Mac|iP(hone|[oa]d)/.test(navigator.platform), y = typeof navigator < "u" && /Win/.test(navigator.platform);
function m(e) {
  let r = e.split(/-(?!$)/), t = r[r.length - 1];
  t == "Space" && (t = " ");
  let i, f, o, a;
  for (let l = 0; l < r.length - 1; l++) {
    let s = r[l];
    if (/^(cmd|meta|m)$/i.test(s))
      a = !0;
    else if (/^a(lt)?$/i.test(s))
      i = !0;
    else if (/^(c|ctrl|control)$/i.test(s))
      f = !0;
    else if (/^s(hift)?$/i.test(s))
      o = !0;
    else if (/^mod$/i.test(s))
      p ? a = !0 : f = !0;
    else
      throw new Error("Unrecognized modifier name: " + s);
  }
  return i && (t = "Alt-" + t), f && (t = "Ctrl-" + t), a && (t = "Meta-" + t), o && (t = "Shift-" + t), t;
}
function h(e) {
  let r = /* @__PURE__ */ Object.create(null);
  for (let t in e)
    r[m(t)] = e[t];
  return r;
}
function n(e, r, t = !0) {
  return r.altKey && (e = "Alt-" + e), r.ctrlKey && (e = "Ctrl-" + e), r.metaKey && (e = "Meta-" + e), t && r.shiftKey && (e = "Shift-" + e), e;
}
function k(e) {
  return new d({ props: { handleKeyDown: K(e) } });
}
function K(e) {
  let r = h(e);
  return function(t, i) {
    let f = u(i), o, a = r[n(f, i)];
    if (a && a(t.state, t.dispatch, t))
      return !0;
    if (f.length == 1 && f != " ") {
      if (i.shiftKey) {
        let l = r[n(f, i, !1)];
        if (l && l(t.state, t.dispatch, t))
          return !0;
      }
      if ((i.altKey || i.metaKey || i.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
      !(y && i.ctrlKey && i.altKey) && (o = c[i.keyCode]) && o != f) {
        let l = r[n(o, i)];
        if (l && l(t.state, t.dispatch, t))
          return !0;
      }
    }
    return !1;
  };
}
export {
  K as keydownHandler,
  k as keymap
};
//# sourceMappingURL=index.js.map
