const s = [], u = [], a = {}, i = (t, o) => {
  a[t] = o, typeof window != "undefined" && (window.registerEditorCommand || (window.registerEditorCommand = (e, n) => {
    a[e] = n;
  }), window.registerEditorCommand(t, o));
}, y = (t, ...o) => {
  a[t] && a[t](...o);
}, l = () => (document.execCommand("undo", !1), !0), f = () => (document.execCommand("redo", !1), !0), h = (t, o, e) => {
  const n = t.getAttribute(o);
  t.setAttribute(o, e), s.push(() => {
    n == null ? t.removeAttribute(o) : t.setAttribute(o, n);
  }), u.length = 0;
}, p = (t, o) => {
  const e = t.textContent;
  t.textContent = o, s.push(() => {
    t.textContent = e != null ? e : "";
  }), u.length = 0;
}, w = (t) => {
  var c;
  const o = t.element;
  if (!o) return;
  const e = (c = window.a11yRuleRegistry) == null ? void 0 : c.find((r) => r.id === t.rule);
  let n = null;
  if (e && e.fix) {
    const r = {};
    for (const d of o.getAttributeNames())
      r[d] = o.getAttribute(d);
    e.fix(t), n = () => {
      for (const d of Object.keys(r))
        r[d] == null ? o.removeAttribute(d) : o.setAttribute(d, r[d]);
    };
  }
  n && s.push(n), u.length = 0;
}, g = () => {
  const t = s.pop();
  t && (t(), u.push(t));
}, b = () => {
  const t = u.pop();
  t && (t(), s.push(t));
}, m = () => {
  typeof window != "undefined" && (window.execEditorCommand || (window.execEditorCommand = y), i("undo", l), i("redo", f), i("setAttribute", h), i("setText", p), i("autoFixA11y", w), i("undoDom", g), i("redoDom", b));
};
typeof window != "undefined" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", m) : m());
const x = () => ({
  name: "history",
  toolbar: [
    {
      label: "Undo",
      command: "undo",
      type: "button",
      icon: '<svg width="24" height="24" focusable="false"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"></path></svg>',
      shortcut: "Mod-z"
    },
    {
      label: "Redo",
      command: "redo",
      type: "button",
      icon: '<svg width="24" height="24" focusable="false"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"></path></svg>',
      shortcut: "Mod-y"
    }
  ],
  commands: {
    undo: l,
    redo: f,
    setAttribute: h,
    setText: p,
    autoFixA11y: w,
    undoDom: g,
    redoDom: b
  },
  keymap: {
    "Mod-z": "undo",
    "Mod-Z": "undo",
    "Mod-y": "redo",
    "Mod-Y": "redo",
    "Mod-Shift-z": "redo",
    "Mod-Shift-Z": "redo"
  }
});
export {
  x as HistoryPlugin,
  w as autoFixA11y,
  f as redo,
  b as redoDom,
  h as setAttribute,
  p as setText,
  l as undo,
  g as undoDom
};
//# sourceMappingURL=HistoryPlugin.native-DoDRifCf.mjs.map
