const p = ".rte-content, .editora-content", g = '.rte-track-insert[data-track-change="insert"]', f = '.rte-track-delete[data-track-change="delete"]', x = `${g}, ${f}`, _ = "__editoraCommandEditorRoot", B = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new Set();
let q = !1, h = null, F = !1, T = {}, j = !1;
const J = typeof InputEvent < "u" && typeof InputEvent.prototype == "object" && "inputType" in InputEvent.prototype, Q = /* @__PURE__ */ new Set([
  "IMG",
  "TABLE",
  "VIDEO",
  "AUDIO",
  "SVG",
  "MATH",
  "HR",
  "IFRAME",
  "INPUT",
  "TEXTAREA",
  "SELECT",
  "BUTTON",
  "CANVAS"
]);
function ee(e) {
  if (!e) return null;
  const t = e.querySelector('[contenteditable="true"]');
  return t instanceof HTMLElement ? t : null;
}
function te() {
  if (typeof window > "u") return null;
  const e = window[_];
  if (!(e instanceof HTMLElement)) return null;
  window[_] = null;
  const t = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
  if (t) {
    const r = ee(t);
    if (r) return r;
    if (t.getAttribute("contenteditable") === "true") return t;
  }
  if (e.getAttribute("contenteditable") === "true")
    return e;
  const n = e.closest('[contenteditable="true"]');
  return n instanceof HTMLElement ? n : null;
}
function ne(e) {
  if (e?.contentElement instanceof HTMLElement) return e.contentElement;
  if (e?.editorElement instanceof HTMLElement) {
    const o = e.editorElement;
    if (o.getAttribute("contenteditable") === "true") return o;
    const a = o.querySelector('[contenteditable="true"]');
    if (a instanceof HTMLElement) return a;
  }
  const t = te();
  if (t && document.contains(t)) return t;
  const n = window.getSelection();
  if (n && n.rangeCount > 0) {
    const o = n.getRangeAt(0).startContainer, c = (o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement)?.closest(p);
    if (c) return c;
  }
  const r = document.activeElement;
  if (r) {
    if (r.matches(p)) return r;
    const o = r.closest(p);
    if (o) return o;
  }
  return h?.isConnected ? h : document.querySelector(p);
}
function w(e, t) {
  k(e), H(e);
  let n = B.get(e);
  return n || (n = {
    enabled: !!t.enabledByDefault,
    author: t.author?.trim() || "system",
    includeTimestamp: t.includeTimestamp !== !1
  }, B.set(e, n), n.enabled && (M(e, n), y(e, n.enabled))), S(e, "toggleTrackChanges", n.enabled), n;
}
function y(e, t) {
  e.classList.toggle("rte-track-changes-enabled", t), t ? e.setAttribute("data-track-changes", "true") : e.removeAttribute("data-track-changes");
}
function re(e) {
  return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || e;
}
function S(e, t, n) {
  const r = re(e);
  Array.from(
    r.querySelectorAll(
      `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
    )
  ).forEach((a) => {
    a.classList.toggle("active", n), a.setAttribute("data-active", n ? "true" : "false"), a.setAttribute("aria-pressed", n ? "true" : "false"), a.setAttribute("title", n ? "Track Changes (On)" : "Track Changes (Off)");
  });
}
function ae(e) {
  e.dispatchEvent(new Event("input", { bubbles: !0 }));
}
function oe(e, t) {
  if (t === e.innerHTML) return;
  const n = window.execEditorCommand || window.executeEditorCommand;
  if (typeof n == "function")
    try {
      n("recordDomTransaction", e, t, e.innerHTML);
    } catch {
    }
}
function m(e, t) {
  ae(e), oe(e, t);
}
function ce(e, t) {
  return e.startContainer === t.startContainer && e.startOffset === t.startOffset && e.endContainer === t.endContainer && e.endOffset === t.endOffset;
}
function G(e) {
  return {
    author: e.author,
    timestamp: e.includeTimestamp ? (/* @__PURE__ */ new Date()).toISOString() : ""
  };
}
function se(e, t) {
  const n = document.createElement("span");
  n.className = "rte-track-insert", n.setAttribute("data-track-change", "insert"), n.setAttribute("contenteditable", "false");
  const r = G(t);
  return n.setAttribute("data-track-author", r.author), r.timestamp && n.setAttribute("data-track-time", r.timestamp), n.appendChild(document.createTextNode(e)), n;
}
function k(e) {
  Array.from(e.querySelectorAll(g)).forEach((n) => {
    n.setAttribute("contenteditable", "false");
  });
}
function E(e) {
  return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
}
function le(e, t) {
  const n = e.startContainer, r = e.startOffset;
  if (n.nodeType === Node.TEXT_NODE) {
    const o = n, a = o.previousSibling || o.nextSibling;
    if (a instanceof HTMLElement && a.matches(g) && t.contains(a))
      return a;
  }
  if (n.nodeType === Node.ELEMENT_NODE) {
    const o = n, a = o.childNodes[r - 1];
    if (a instanceof HTMLElement && a.matches(g) && t.contains(a))
      return a;
    const c = o.childNodes[r];
    if (c instanceof HTMLElement && c.matches(g) && t.contains(c))
      return c;
  }
  return null;
}
function P(e, t, n) {
  const r = t.lastChild;
  r && r.nodeType === Node.TEXT_NODE ? r.data += n : t.appendChild(document.createTextNode(n)), C(e, t);
}
function ie(e, t) {
  const n = document.createElement("span");
  n.className = "rte-track-delete", n.setAttribute("data-track-change", "delete"), n.setAttribute("contenteditable", "false");
  const r = G(t);
  return n.setAttribute("data-track-author", r.author), r.timestamp && n.setAttribute("data-track-time", r.timestamp), n.appendChild(e), n;
}
function b(e) {
  const t = window.getSelection();
  if (!t || t.rangeCount === 0) return null;
  const n = t.getRangeAt(0);
  return e.contains(n.commonAncestorContainer) ? n : null;
}
function ue() {
  j || typeof document > "u" || (j = !0, document.addEventListener(
    "selectionchange",
    () => {
      const e = window.getSelection();
      if (!e || e.rangeCount === 0) return;
      const t = e.getRangeAt(0), r = E(t.startContainer)?.closest(p) || null;
      r && (L.set(r, t.cloneRange()), h = r);
    },
    !0
  ));
}
function C(e, t) {
  if (!t.parentNode) {
    e.focus({ preventScroll: !0 });
    return;
  }
  const n = window.getSelection();
  if (!n) return;
  const r = document.createRange();
  r.setStartAfter(t), r.collapse(!0), n.removeAllRanges(), n.addRange(r), e.focus({ preventScroll: !0 });
}
function O(e, t) {
  if (!t.parentNode) {
    e.focus({ preventScroll: !0 });
    return;
  }
  const n = window.getSelection();
  if (!n) return;
  const r = document.createRange();
  r.setStartBefore(t), r.collapse(!0), n.removeAllRanges(), n.addRange(r), e.focus({ preventScroll: !0 });
}
function de(e, t, n) {
  const r = window.getSelection();
  if (!r) return;
  const o = document.createRange();
  o.setStart(t, Math.max(0, n)), o.collapse(!0), r.removeAllRanges(), r.addRange(o), e.focus({ preventScroll: !0 });
}
function V(e) {
  let t = b(e);
  if (!t) {
    const c = L.get(e);
    c && e.contains(c.commonAncestorContainer) && (t = c.cloneRange());
  }
  if (!t || !t.collapsed) return;
  const n = E(t.startContainer);
  if (!n) return;
  const r = n.closest(g);
  if (!r || !e.contains(r) || !r.parentNode) return;
  const o = window.getSelection();
  if (!o) return;
  const a = document.createRange();
  a.setStartAfter(r), a.collapse(!0), o.removeAllRanges(), o.addRange(a), e.focus({ preventScroll: !0 });
}
function K(e, t) {
  const n = e.innerHTML;
  k(e), V(e), e.focus({ preventScroll: !0 });
  const r = t === "insertLineBreak" ? "insertLineBreak" : "insertParagraph", o = document.execCommand(r, !1);
  return k(e), m(e, n), o !== !1;
}
function fe(e) {
  const t = b(e);
  if (t && t.collapsed) return t;
  const n = L.get(e);
  return n && n.collapsed && e.contains(n.commonAncestorContainer) ? n.cloneRange() : null;
}
function ge(e) {
  return e.matches(g) || e.matches(f) ? (e.textContent || "").replace(/\u200B/g, "").trim().length > 0 : Q.has(e.tagName);
}
function W(e, t) {
  if (t !== "insertParagraph") return !1;
  const n = fe(e);
  if (!n) return !1;
  const r = E(n.startContainer);
  if (!r) return !1;
  const o = r.closest("li");
  return !(o instanceof HTMLElement) || !e.contains(o) || (o.textContent || "").replace(/\u200B/g, "").trim().length > 0 ? !1 : !Array.from(o.querySelectorAll("*")).some(
    (s) => ge(s)
  );
}
function me(e) {
  const t = document.createRange(), n = window.getSelection();
  if (n && n.rangeCount > 0) {
    const r = n.getRangeAt(0);
    if (e.contains(r.commonAncestorContainer))
      return t.setStart(r.endContainer, r.endOffset), t.collapse(!0), t;
  }
  return t.selectNodeContents(e), t.collapse(!1), t;
}
function he(e) {
  return (e.textContent || "").length > 0 ? !0 : Array.from(e.childNodes).some((n) => {
    if (n.nodeType !== Node.ELEMENT_NODE) return !1;
    const r = n;
    return ["BR", "IMG", "TABLE", "VIDEO", "AUDIO", "SVG", "MATH"].includes(r.tagName);
  });
}
function pe(e) {
  return Array.from(e.childNodes).some((t) => {
    if (t.nodeType === Node.TEXT_NODE)
      return (t.textContent || "").length > 0;
    if (t.nodeType !== Node.ELEMENT_NODE) return !1;
    const n = t;
    return ["BR", "IMG", "TABLE", "VIDEO", "AUDIO", "SVG", "MATH"].includes(n.tagName);
  });
}
function Ee(e, t, n) {
  if (!e.collapsed) return null;
  const r = e.startContainer, o = e.startOffset;
  let a = null;
  if (r.nodeType === Node.TEXT_NODE) {
    const c = r;
    t === "backward" && o === 0 ? a = c.previousSibling : t === "forward" && o === c.length && (a = c.nextSibling);
  } else if (r.nodeType === Node.ELEMENT_NODE) {
    const c = r;
    t === "backward" && o > 0 ? a = c.childNodes[o - 1] || null : t === "forward" && o < c.childNodes.length && (a = c.childNodes[o] || null);
  }
  return !(a instanceof HTMLElement) || !a.matches(g) || !n.contains(a) ? null : a;
}
function ke(e, t) {
  const n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = [];
  let o = n.nextNode();
  for (; o; ) {
    const a = o;
    a.data.length > 0 && r.push(a), o = n.nextNode();
  }
  return r.length === 0 ? null : t ? r[r.length - 1] : r[0];
}
function Te(e, t, n) {
  const r = Ee(t, n, e);
  return r ? v(e, r, n) : !1;
}
function v(e, t, n) {
  const r = t.parentNode;
  if (!r) return !1;
  const o = Array.prototype.indexOf.call(r.childNodes, t), a = ke(t, n === "backward");
  return a ? (n === "backward" ? a.data = a.data.slice(0, -1) : a.data = a.data.slice(1), a.data.length === 0 && a.remove(), pe(t) ? (n === "backward" ? C(e, t) : O(e, t), !0) : (t.remove(), de(e, r, o), !0)) : !1;
}
function Z(e) {
  if (e.startContainer !== e.endContainer || e.startContainer.nodeType !== Node.ELEMENT_NODE) return null;
  const t = e.startContainer;
  return e.endOffset - e.startOffset !== 1 ? null : t.childNodes[e.startOffset] || null;
}
function I(e, t) {
  const n = Z(e);
  return !(n instanceof HTMLElement) || !n.matches(f) || !t.contains(n) ? null : n;
}
function be(e, t) {
  const n = Z(e);
  return !(n instanceof HTMLElement) || !n.matches(g) || !t.contains(n) ? null : n;
}
function Ce(e, t) {
  if (t.collapsed) {
    const c = E(t.startContainer)?.closest(f);
    if (c && e.contains(c)) {
      const s = document.createRange();
      return s.setStartAfter(c), s.collapse(!0), s;
    }
    return t;
  }
  const n = I(t, e);
  if (n) {
    const a = document.createRange();
    return a.setStartAfter(n), a.collapse(!0), a;
  }
  const r = E(t.startContainer)?.closest(f), o = E(t.endContainer)?.closest(f);
  if (r && o && r === o && e.contains(r)) {
    const a = document.createRange();
    return a.setStartAfter(r), a.collapse(!0), a;
  }
  return t;
}
function Ae(e, t) {
  const r = Array.from(t.querySelectorAll(g)).filter((s) => {
    try {
      return e.intersectsNode(s);
    } catch {
      return !1;
    }
  });
  if (r.length !== 1) return null;
  const o = r[0], a = (e.toString() || "").replace(/\s+/g, ""), c = (o.textContent || "").replace(/\s+/g, "");
  return !c || a !== c ? null : o;
}
function U(e, t, n) {
  if (t.collapsed) return null;
  const r = t.cloneContents();
  if (!he(r)) return null;
  const o = ie(r, n);
  return t.deleteContents(), t.insertNode(o), C(e, o), o;
}
function Ne(e, t, n) {
  if (!t.collapsed) return t;
  const r = t.startContainer, o = t.startOffset;
  if (r.nodeType === Node.TEXT_NODE) {
    const s = r;
    if (n === "backward" && o > 0) {
      const l = t.cloneRange();
      return l.setStart(s, o - 1), l;
    }
    if (n === "forward" && o < s.length) {
      const l = t.cloneRange();
      return l.setEnd(s, o + 1), l;
    }
  }
  if (r.nodeType === Node.ELEMENT_NODE) {
    const s = r;
    if (n === "backward" && o > 0)
      for (let l = o - 1; l >= 0; l -= 1) {
        const i = s.childNodes[l];
        if (!i || i instanceof HTMLElement && i.matches(f))
          continue;
        const u = t.cloneRange();
        if (i.nodeType === Node.TEXT_NODE) {
          const d = i;
          if (d.length === 0) continue;
          u.setStart(d, d.length - 1), u.setEnd(d, d.length);
        } else
          u.setStartBefore(i), u.setEndAfter(i);
        return u;
      }
    if (n === "forward" && o < s.childNodes.length)
      for (let l = o; l < s.childNodes.length; l += 1) {
        const i = s.childNodes[l];
        if (!i || i instanceof HTMLElement && i.matches(f))
          continue;
        const u = t.cloneRange();
        if (i.nodeType === Node.TEXT_NODE) {
          const d = i;
          if (d.length === 0) continue;
          u.setStart(d, 0), u.setEnd(d, 1);
        } else
          u.setStartBefore(i), u.setEndAfter(i);
        return u;
      }
  }
  const a = window.getSelection();
  if (!a || typeof a.modify != "function")
    return null;
  const c = t.cloneRange();
  a.removeAllRanges(), a.addRange(c);
  try {
    if (a.modify("extend", n, "character"), a.rangeCount === 0)
      return null;
    const s = a.getRangeAt(0).cloneRange();
    if (s.collapsed || !e.contains(s.commonAncestorContainer))
      return null;
    const l = I(s, e);
    return l ? (n === "backward" ? O(e, l) : C(e, l), null) : s;
  } catch {
    return null;
  } finally {
    a.removeAllRanges(), a.addRange(c);
  }
}
function z(e, t, n) {
  let r = b(e);
  if (!r) return !1;
  const o = Ce(e, r.cloneRange());
  if (!ce(o, r)) {
    const d = window.getSelection();
    d && (d.removeAllRanges(), d.addRange(o)), r = o;
  }
  const a = e.innerHTML;
  r.collapsed || U(e, r.cloneRange(), t);
  const s = E(r.startContainer)?.closest(g);
  if (r.collapsed && s && e.contains(s))
    return P(e, s, n), m(e, a), !0;
  const l = r.collapsed ? le(r, e) : null;
  if (l)
    return P(e, l, n), m(e, a), !0;
  const i = me(e), u = se(n, t);
  return i.insertNode(u), C(e, u), m(e, a), !0;
}
function $(e, t, n) {
  const r = b(e);
  if (!r) return !1;
  const o = n.includes("Backward") ? "backward" : "forward", a = e.innerHTML;
  if (r.collapsed && Te(e, r.cloneRange(), o))
    return m(e, a), !0;
  const c = be(r, e);
  if (c && v(e, c, o))
    return m(e, a), !0;
  if (!r.collapsed) {
    const u = Ae(r, e);
    if (u && v(e, u, o))
      return m(e, a), !0;
  }
  const s = r.collapsed ? Ne(e, r.cloneRange(), o) : r.cloneRange();
  if (!s) return !1;
  const l = I(s, e);
  return l ? (o === "backward" ? O(e, l) : C(e, l), !0) : U(e, s, t) ? (H(e), m(e, a), !0) : !1;
}
function R(e) {
  const t = e.parentNode;
  if (t) {
    for (; e.firstChild; )
      t.insertBefore(e.firstChild, e);
    t.removeChild(e);
  }
}
function H(e) {
  Array.from(e.querySelectorAll(f)).forEach((r) => {
    r.setAttribute("contenteditable", "false"), Array.from(r.querySelectorAll(f)).forEach((a) => {
      a !== r && R(a);
    });
  });
  let n = !0;
  for (; n; )
    n = !1, Array.from(e.querySelectorAll(f)).forEach((o) => {
      if (!o.isConnected) return;
      let a = o.nextSibling;
      for (; a && a.nodeType === Node.TEXT_NODE && !(a.textContent || "").trim(); )
        a = a.nextSibling;
      if (a instanceof HTMLElement && a.matches(f)) {
        for (; a.firstChild; )
          o.appendChild(a.firstChild);
        a.remove(), n = !0;
      }
      o.firstChild || (o.remove(), n = !0);
    });
}
function Y(e) {
  return Array.from(e.querySelectorAll(x));
}
function ye(e) {
  const t = b(e);
  if (!t) return [];
  const n = /* @__PURE__ */ new Set(), r = t.startContainer.nodeType === Node.ELEMENT_NODE ? t.startContainer : t.startContainer.parentElement, o = t.endContainer.nodeType === Node.ELEMENT_NODE ? t.endContainer : t.endContainer.parentElement, a = r?.closest(x);
  a && e.contains(a) && n.add(a);
  const c = o?.closest(x);
  return c && e.contains(c) && n.add(c), Y(e).filter((l) => {
    try {
      return t.intersectsNode(l);
    } catch {
      return !1;
    }
  }).forEach((l) => n.add(l)), Array.from(n);
}
function A(e, t, n) {
  const r = n === "all" ? Y(e) : ye(e);
  if (r.length === 0) return !1;
  const o = e.innerHTML;
  return r.forEach((a) => {
    if (!a.isConnected) return;
    const c = a.matches(g), s = a.matches(f);
    if (!(!c && !s)) {
      if (t === "accept") {
        c ? R(a) : a.remove();
        return;
      }
      c ? a.remove() : (a.removeAttribute("contenteditable"), R(a));
    }
  }), H(e), m(e, o), !0;
}
function Se(e) {
  return e instanceof Node && (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest(p) || null;
}
function Me() {
  F || typeof document > "u" || (F = !0, document.addEventListener(
    "focusin",
    (e) => {
      if (!T.enabledByDefault) return;
      const t = Se(e.target);
      if (!t) return;
      h = t;
      const n = w(t, T);
      n.enabled ? (M(t, n), y(t, !0), S(t, "toggleTrackChanges", !0)) : k(t);
    },
    !0
  ));
}
function xe(e, t) {
  return (n) => {
    if (!t.enabled || e.getAttribute("data-track-changes") !== "true") return;
    h = e;
    const r = n.inputType || "";
    if (r === "insertParagraph" || r === "insertLineBreak") {
      if (W(e, r))
        return;
      n.preventDefault(), K(e, r);
      return;
    }
    if (r.startsWith("delete")) {
      n.preventDefault(), $(e, t, r);
      return;
    }
    if (r === "insertText" || r === "insertCompositionText") {
      const o = n.data || "";
      if (!o) return;
      n.preventDefault(), z(e, t, o);
    }
  };
}
function we(e, t) {
  return (n) => {
    if (!t.enabled || e.getAttribute("data-track-changes") !== "true" || n.key !== "Enter" || J) return;
    const r = n.shiftKey ? "insertLineBreak" : "insertParagraph";
    W(e, r) || (h = e, n.preventDefault(), n.stopPropagation(), K(e, r));
  };
}
function ve(e, t) {
  return (n) => {
    if (n.__editoraSmartPasteHandled === !0 || n.defaultPrevented || !t.enabled || e.getAttribute("data-track-changes") !== "true") return;
    const r = n.clipboardData?.getData("text/plain") || "";
    r && (n.preventDefault(), h = e, z(e, t, r));
  };
}
function Re(e, t) {
  return (n) => {
    if (!t.enabled || e.getAttribute("data-track-changes") !== "true") return;
    const r = b(e);
    if (!r || r.collapsed) return;
    const o = r.toString();
    n.clipboardData && (n.clipboardData.setData("text/plain", o), n.preventDefault()), h = e, $(e, t, "deleteByCut");
  };
}
function M(e, t) {
  if (N.has(e)) return;
  k(e);
  const n = {
    beforeInput: xe(e, t),
    keydown: we(e, t),
    paste: ve(e, t),
    cut: Re(e, t)
  };
  e.addEventListener("beforeinput", n.beforeInput), e.addEventListener("keydown", n.keydown), e.addEventListener("paste", n.paste), e.addEventListener("cut", n.cut), N.set(e, n), D.add(e);
}
function X(e) {
  const t = N.get(e);
  t && (e.removeEventListener("beforeinput", t.beforeInput), e.removeEventListener("keydown", t.keydown), e.removeEventListener("paste", t.paste), e.removeEventListener("cut", t.cut), N.delete(e), D.delete(e));
}
function Le() {
  if (q || typeof document > "u") return;
  q = !0;
  const e = document.createElement("style");
  e.id = "rte-track-changes-styles", e.textContent = `
    .rte-track-insert[data-track-change="insert"] {
      background: rgba(22, 163, 74, 0.2);
      color: inherit;
      text-decoration: underline;
      text-decoration-color: #16a34a;
      text-decoration-thickness: 2px;
      border-radius: 2px;
      padding: 0 1px;
      white-space: pre-wrap;
    }

    .rte-track-delete[data-track-change="delete"] {
      background: rgba(220, 38, 38, 0.16);
      color: inherit;
      text-decoration: line-through;
      text-decoration-color: #dc2626;
      text-decoration-thickness: 2px;
      border-radius: 2px;
      padding: 0 1px;
      white-space: pre-wrap;
      cursor: pointer;
    }

    .editora-theme-dark .rte-track-insert[data-track-change="insert"],
    .rte-theme-dark .rte-track-insert[data-track-change="insert"] {
      background: rgba(74, 222, 128, 0.2);
      text-decoration-color: #4ade80;
    }

    .editora-theme-dark .rte-track-delete[data-track-change="delete"],
    .rte-theme-dark .rte-track-delete[data-track-change="delete"] {
      background: rgba(248, 113, 113, 0.18);
      text-decoration-color: #f87171;
    }

    .rte-content[data-track-changes="true"],
    .editora-content[data-track-changes="true"] {
      caret-color: currentColor;
    }

    .rte-toolbar-group-items.track-changes,
    .editora-toolbar-group-items.track-changes {
      display: flex;
      border: 1px solid #ccc;
      border-radius: 3px;
      background: #fff;
    }
    .rte-toolbar-group-items.track-changes .rte-toolbar-button,
    .editora-toolbar-group-items.track-changes .editora-toolbar-button {
      border: none;
      border-radius: 0px; 
    }
    .rte-toolbar-group-items.track-changes .rte-toolbar-button,
    .editora-toolbar-group-items.track-changes .editora-toolbar-button {
      border-right: 1px solid #ccc;
    }
    .rte-toolbar-group-items.track-changes .rte-toolbar-item:last-child .rte-toolbar-button,
    .editora-toolbar-group-items.track-changes .editora-toolbar-item:last-child .editora-toolbar-button {
      border-right: none;
    }

    :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .rte-toolbar-group-items.track-changes,
    :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .editora-toolbar-group-items.track-changes {
      border-color: #566275;
    }

    :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .rte-toolbar-group-items.track-changes .rte-toolbar-button,
    :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .editora-toolbar-group-items.track-changes .editora-toolbar-button {
      border-right-color: #566275;
    }

    .rte-toolbar-button[data-command="toggleTrackChanges"].active,
    .editora-toolbar-button[data-command="toggleTrackChanges"].active {
      background-color: #ccc;
    }
  `, document.head.appendChild(e);
}
const De = (e = {}) => {
  Le(), ue(), T = { ...T, ...e }, Me(), T.enabledByDefault && typeof document < "u" && (typeof requestAnimationFrame == "function" ? requestAnimationFrame : (o) => window.setTimeout(o, 0))(() => {
    Array.from(document.querySelectorAll(p)).forEach((a) => {
      const c = w(a, T);
      c.enabled ? (M(a, c), y(a, !0), S(a, "toggleTrackChanges", !0)) : k(a);
    });
  });
  const t = (r) => {
    const o = ne(r);
    return o ? (h = o, o) : null;
  }, n = (r) => {
    const o = t(r);
    if (!o) return null;
    const a = w(o, e);
    return { editor: o, state: a };
  };
  return {
    name: "trackChanges",
    toolbar: [
      {
        label: "Track Changes",
        command: "toggleTrackChanges",
        type: "group",
        items: [
          {
            label: "Track Changes",
            command: "toggleTrackChanges",
            icon: '<svg width="24" height="24" focusable="false"><path d="M4 6h10a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h7a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h8a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm13.3-3.6 1.3 1.3 2.9-2.9a1 1 0 1 1 1.4 1.4l-3.6 3.6a1 1 0 0 1-1.4 0l-2-2a1 1 0 1 1 1.4-1.4Z"></path></svg>',
            shortcut: "Mod-Shift-t"
          },
          {
            label: "Accept All Changes",
            command: "acceptAllTrackChanges",
            icon: '<svg width="24" height="24" focusable="false"><path d="M9.2 16.2 5.8 12.8a1 1 0 1 1 1.4-1.4l2.1 2.1 7.5-7.5a1 1 0 1 1 1.4 1.4l-8.2 8.2a1 1 0 0 1-1.4 0Z"></path></svg>'
          },
          {
            label: "Reject All Changes",
            command: "rejectAllTrackChanges",
            icon: '<svg width="24" height="24" focusable="false"><path d="M7.8 7.8a1 1 0 0 1 1.4 0L12 10.6l2.8-2.8a1 1 0 1 1 1.4 1.4L13.4 12l2.8 2.8a1 1 0 1 1-1.4 1.4L12 13.4l-2.8 2.8a1 1 0 1 1-1.4-1.4l2.8-2.8-2.8-2.8a1 1 0 0 1 0-1.4Z"></path></svg>'
          }
        ]
      }
    ],
    commands: {
      toggleTrackChanges: (r, o) => {
        const a = n(o);
        if (!a) return !1;
        const { editor: c, state: s } = a;
        return s.enabled = !s.enabled, s.enabled ? M(c, s) : (X(c), k(c), V(c)), y(c, s.enabled), S(c, "toggleTrackChanges", s.enabled), c.dispatchEvent(new CustomEvent("editora:track-changes-toggle", {
          bubbles: !0,
          detail: {
            enabled: s.enabled,
            author: s.author
          }
        })), s.enabled;
      },
      acceptAllTrackChanges: (r, o) => {
        const a = n(o);
        return a ? A(a.editor, "accept", "all") : !1;
      },
      rejectAllTrackChanges: (r, o) => {
        const a = n(o);
        return a ? A(a.editor, "reject", "all") : !1;
      },
      acceptSelectedTrackChanges: (r, o) => {
        const a = n(o);
        return a ? A(a.editor, "accept", "selection") : !1;
      },
      rejectSelectedTrackChanges: (r, o) => {
        const a = n(o);
        return a ? A(a.editor, "reject", "selection") : !1;
      }
    },
    keymap: {
      "Mod-Shift-t": "toggleTrackChanges",
      "Mod-Shift-T": "toggleTrackChanges"
    },
    destroy: () => {
      Array.from(D).forEach((r) => X(r));
    }
  };
};
export {
  De as TrackChangesPlugin
};
