const S = ".rte-content, .editora-content", ke = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", ve = "__editoraCommandEditorRoot", $e = "rte-translation-workflow-styles", d = "rte-translation-workflow-panel", y = "translation-workflow", $ = "translationWorkflow", k = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', Ee = [
  "p",
  "h1",
  "h2",
  "h3",
  "h4",
  "h5",
  "h6",
  "li",
  "td",
  "th",
  "blockquote",
  "figcaption"
].join(", "), Ce = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "Home", "End"]), Ae = [
  {
    locale: "en",
    label: "English",
    minLengthRatio: 0.6,
    maxLengthRatio: 1.4,
    requireDifferentFromSource: !1,
    preserveTokens: !0
  },
  {
    locale: "fr",
    label: "French",
    minLengthRatio: 0.75,
    maxLengthRatio: 1.7,
    requireDifferentFromSource: !0,
    preserveTokens: !0
  },
  {
    locale: "de",
    label: "German",
    minLengthRatio: 0.8,
    maxLengthRatio: 1.9,
    requireDifferentFromSource: !0,
    preserveTokens: !0
  },
  {
    locale: "es",
    label: "Spanish",
    minLengthRatio: 0.7,
    maxLengthRatio: 1.7,
    requireDifferentFromSource: !0,
    preserveTokens: !0
  },
  {
    locale: "it",
    label: "Italian",
    minLengthRatio: 0.7,
    maxLengthRatio: 1.7,
    requireDifferentFromSource: !0,
    preserveTokens: !0
  },
  {
    locale: "ja",
    label: "Japanese",
    minLengthRatio: 0.45,
    maxLengthRatio: 1.2,
    requireDifferentFromSource: !0,
    preserveTokens: !0
  },
  {
    locale: "zh",
    label: "Chinese",
    minLengthRatio: 0.4,
    maxLengthRatio: 1.2,
    requireDifferentFromSource: !0,
    preserveTokens: !0
  }
], _e = {
  panelTitle: "Translation Workflow",
  panelAriaLabel: "Translation workflow panel",
  sourceLocaleLabel: "Source Locale",
  targetLocaleLabel: "Target Locale",
  validateText: "Validate Locale",
  captureSourceText: "Capture Source",
  lockSelectedText: "Lock Selected",
  unlockSelectedText: "Unlock Selected",
  lockSegmentAriaLabel: "Lock segment",
  unlockSegmentAriaLabel: "Unlock segment",
  realtimeOnText: "Realtime On",
  realtimeOffText: "Realtime Off",
  closeText: "Close",
  summaryPrefix: "Locale QA",
  noIssuesText: "No locale validation issues.",
  issuesLabel: "Locale issues",
  segmentsLabel: "Segments",
  sourcePreviewLabel: "Source",
  targetPreviewLabel: "Target",
  helperText: "Select segments, lock finalized ones, and run locale validation before handoff.",
  shortcutText: "Shortcuts: Ctrl/Cmd+Alt+Shift+L (panel), Ctrl/Cmd+Alt+Shift+V (validate), Ctrl/Cmd+Alt+Shift+K (lock segment)",
  readonlySegmentMessage: "This segment is locked. Unlock before editing.",
  sourceCapturedMessage: "Source snapshot captured from current content.",
  selectedSegmentPrefix: "Selected Segment",
  missingTargetMessage: "Segment is empty in target locale.",
  tokenMismatchMessage: "Tokens/placeholders do not match source segment.",
  untranslatedMessage: "Segment appears untranslated (same as source).",
  lengthOutOfRangeMessage: "Translation length is outside expected locale range."
}, u = /* @__PURE__ */ new WeakMap(), oe = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new WeakMap(), se = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new Set();
let ee = 0, Fe = 0, Re = 0, We = 0, w = null, x = null, N = null, O = null, _ = null, F = null, I = null, W = null;
function m(e) {
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}
function Ke(e) {
  return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
}
function B(e, n, t) {
  return Number.isFinite(e) ? Math.max(n, Math.min(t, e)) : n;
}
function A(e) {
  return (e || "").trim() || "en-US";
}
function j(e) {
  return e.trim().toLowerCase();
}
function Ve(e) {
  return e.replace(/"/g, "&quot;");
}
function je(e, n = 120) {
  return e.length <= n ? e : `${e.slice(0, Math.max(0, n - 1)).trimEnd()}…`;
}
function Ie(e) {
  const n = e.match(/\{\{[^{}]+\}\}|%[A-Z0-9_]+%|\$\{[^{}]+\}/gi);
  return !n || n.length === 0 ? [] : n.map((t) => t.trim()).filter(Boolean);
}
function Ue(e, n) {
  const t = Ie(e).sort(), r = Ie(n).sort();
  if (t.length !== r.length) return !1;
  for (let a = 0; a < t.length; a += 1)
    if (t[a] !== r[a]) return !1;
  return !0;
}
function Ge(e, n) {
  const t = Array.isArray(n) && n.length > 0 ? n : Ae, r = [], a = /* @__PURE__ */ new Set();
  return t.forEach((o) => {
    var i, c;
    const l = j(o.locale || "");
    if (!l) return;
    const s = l;
    a.has(s) || (a.add(s), r.push({
      locale: s,
      label: (o.label || l).trim() || l,
      minLengthRatio: B(Number((i = o.minLengthRatio) != null ? i : 0.5), 0.1, 3),
      maxLengthRatio: B(Number((c = o.maxLengthRatio) != null ? c : 1.8), 0.2, 4),
      requireDifferentFromSource: o.requireDifferentFromSource !== !1,
      preserveTokens: o.preserveTokens !== !1
    }));
  }), e.forEach((o) => {
    const l = j(o);
    if (a.has(l)) return;
    const s = Ae.find((i) => l.startsWith(i.locale));
    r.push(
      s ? { ...s, locale: l, label: o } : {
        locale: l,
        label: o,
        minLengthRatio: 0.5,
        maxLengthRatio: 1.8,
        requireDifferentFromSource: !0,
        preserveTokens: !0
      }
    );
  }), r;
}
function ae(e = {}) {
  var s, i, c, g;
  const n = e.normalizeText || Ke, t = A(e.sourceLocale || "en-US"), r = A(e.targetLocale || "fr-FR"), a = /* @__PURE__ */ new Set([t, r]);
  (Array.isArray(e.locales) ? e.locales : []).forEach((p) => {
    if (typeof p != "string") return;
    const v = A(p);
    a.add(v);
  });
  const o = Array.from(a), l = Ge(o, e.localeRules);
  return {
    sourceLocale: t,
    targetLocale: r,
    locales: o,
    localeRules: l,
    enableRealtime: e.enableRealtime !== !1,
    debounceMs: B(Number((s = e.debounceMs) != null ? s : 260), 60, 2e3),
    maxIssues: B(Number((i = e.maxIssues) != null ? i : 120), 5, 1e3),
    maxSegments: B(Number((c = e.maxSegments) != null ? c : 600), 20, 3e3),
    minSourceLengthForRatio: B(Number((g = e.minSourceLengthForRatio) != null ? g : 8), 2, 100),
    segmentSelector: (e.segmentSelector || Ee).trim() || Ee,
    labels: {
      ..._e,
      ...e.labels || {}
    },
    normalizeText: n
  };
}
function Ye(e) {
  return {
    sourceLocale: e.sourceLocale,
    targetLocale: e.targetLocale,
    locales: [...e.locales],
    localeRules: e.localeRules.map((n) => ({
      locale: n.locale,
      label: n.label,
      minLengthRatio: n.minLengthRatio,
      maxLengthRatio: n.maxLengthRatio,
      requireDifferentFromSource: n.requireDifferentFromSource,
      preserveTokens: n.preserveTokens
    })),
    enableRealtime: e.enableRealtime,
    debounceMs: e.debounceMs,
    maxIssues: e.maxIssues,
    maxSegments: e.maxSegments,
    minSourceLengthForRatio: e.minSourceLengthForRatio,
    segmentSelector: e.segmentSelector,
    labels: { ...e.labels },
    normalizeText: e.normalizeText
  };
}
function we(e) {
  return e.closest(ke) || e;
}
function U(e) {
  if (!e) return null;
  if (e.matches(S)) return e;
  const n = e.querySelector(S);
  return n instanceof HTMLElement ? n : null;
}
function Ze() {
  if (typeof window == "undefined") return null;
  const e = window[ve];
  if (!(e instanceof HTMLElement)) return null;
  window[ve] = null;
  const n = U(e);
  if (n) return n;
  const t = e.closest(ke);
  if (t) {
    const a = U(t);
    if (a) return a;
  }
  const r = e.closest(S);
  return r instanceof HTMLElement ? r : null;
}
function Je(e) {
  const n = e.closest("[data-editora-editor]");
  if (n && U(n) === e)
    return n;
  let t = e;
  for (; t; ) {
    if (t.matches(ke) && (t === e || U(t) === e))
      return t;
    t = t.parentElement;
  }
  return we(e);
}
function He(e) {
  return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
}
function te(e) {
  return e ? (e.getAttribute("data-theme") || e.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : e.classList.contains("dark") || e.classList.contains("editora-theme-dark") || e.classList.contains("rte-theme-dark") : !1;
}
function Qe(e) {
  const n = we(e);
  if (te(n)) return !0;
  const t = n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
  return te(t) ? !0 : te(document.documentElement) || te(document.body);
}
function ge(e, n) {
  e.classList.remove("rte-translation-workflow-theme-dark"), Qe(n) && e.classList.add("rte-translation-workflow-theme-dark");
}
function Xe(e) {
  var n, t, r, a;
  for (let o = 0; o < e.length; o += 1) {
    const l = e[o];
    if (!(l.type !== "childList" || l.removedNodes.length === 0))
      for (let s = 0; s < l.removedNodes.length; s += 1) {
        const i = l.removedNodes[s];
        if (i.nodeType !== Node.ELEMENT_NODE) continue;
        const c = i;
        if ((n = c.matches) != null && n.call(c, S) || (t = c.matches) != null && t.call(c, `.${d}`) || (r = c.querySelector) != null && r.call(c, S) || (a = c.querySelector) != null && a.call(c, `.${d}`))
          return !0;
      }
  }
  return !1;
}
function le() {
  Array.from(Z).forEach((n) => {
    n.isConnected || Se(n);
  });
}
function T(e, n = !0, t = !0) {
  var s;
  if (le(), (e == null ? void 0 : e.contentElement) instanceof HTMLElement) return e.contentElement;
  if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
    const i = U(e.editorElement);
    if (i) return i;
  }
  const r = Ze();
  if (r) return r;
  const a = window.getSelection();
  if (a && a.rangeCount > 0) {
    const i = (s = He(a.getRangeAt(0).startContainer)) == null ? void 0 : s.closest(
      S
    );
    if (i) return i;
  }
  const o = document.activeElement;
  if (o) {
    if (o.matches(S)) return o;
    const i = o.closest(S);
    if (i) return i;
  }
  if (t && x && x.isConnected)
    return x;
  if (!n) return null;
  const l = document.querySelector(S);
  return l instanceof HTMLElement ? l : null;
}
function et(e) {
  const n = e.target;
  if (n) {
    const r = n.closest(`.${d}`);
    if (r) {
      const o = Array.from(h.entries()).find(([, l]) => l === r);
      if (o) return o[0];
    }
    const a = n.closest(S);
    if (a) return a;
  }
  const t = document.activeElement;
  if (t) {
    const r = t.closest(`.${d}`);
    if (r) {
      const o = Array.from(h.entries()).find(([, l]) => l === r);
      if (o) return o[0];
    }
    const a = t.closest(S);
    if (a) return a;
  }
  return null;
}
function fe(e, n, t) {
  const r = Je(e);
  Array.from(
    r.querySelectorAll(
      `.rte-toolbar-button[data-command="${n}"], .editora-toolbar-button[data-command="${n}"]`
    )
  ).forEach((o) => {
    o.classList.toggle("active", t), o.setAttribute("data-active", t ? "true" : "false"), o.setAttribute("aria-pressed", t ? "true" : "false");
  });
}
function xe(e) {
  const n = se.get(e);
  typeof n == "number" && (window.clearTimeout(n), se.delete(e));
}
function tt(e, n) {
  const t = j(n), r = e.localeRules.find((l) => j(l.locale) === t);
  if (r) return r;
  const a = t.split("-")[0], o = e.localeRules.find((l) => j(l.locale).split("-")[0] === a);
  return o || {
    locale: t,
    label: n,
    minLengthRatio: 0.5,
    maxLengthRatio: 1.8,
    requireDifferentFromSource: !0,
    preserveTokens: !0
  };
}
function ne(e, n, t, r = {}) {
  return Re += 1, {
    id: `translation-workflow-issue-${Re}`,
    type: e,
    severity: n,
    message: t,
    ...r
  };
}
function ce(e, n) {
  if (n) {
    e.hasAttribute("data-translation-prev-contenteditable") || e.setAttribute(
      "data-translation-prev-contenteditable",
      e.hasAttribute("contenteditable") && e.getAttribute("contenteditable") || "inherit"
    ), e.setAttribute("data-translation-locked", "true"), e.setAttribute("contenteditable", "false"), e.setAttribute("aria-readonly", "true"), e.classList.add("rte-translation-segment-locked");
    return;
  }
  if (e.removeAttribute("data-translation-locked"), e.removeAttribute("aria-readonly"), e.classList.remove("rte-translation-segment-locked"), e.hasAttribute("data-translation-prev-contenteditable")) {
    const t = e.getAttribute("data-translation-prev-contenteditable") || "";
    t === "inherit" ? e.setAttribute("contenteditable", "true") : e.setAttribute("contenteditable", t), e.removeAttribute("data-translation-prev-contenteditable");
  } else
    e.setAttribute("contenteditable", "true");
}
function ue(e, n) {
  return e.querySelector(`[data-translation-segment-id="${Ve(n)}"]`);
}
function qe(e) {
  const n = window.getSelection();
  if (!n || n.rangeCount === 0) return null;
  const t = He(n.getRangeAt(0).startContainer);
  return !t || !e.contains(t) ? null : t.closest("[data-translation-segment-id]");
}
function nt(e, n) {
  const t = Array.from(e.querySelectorAll(n));
  if (t.length <= 1) return t;
  const r = new Set(t);
  return t.filter((a) => {
    let o = a.parentElement;
    for (; o && o !== e; ) {
      if (r.has(o))
        return !1;
      o = o.parentElement;
    }
    return !0;
  });
}
function rt(e, n, t) {
  let r = (t || "").trim();
  if (!r || n.has(r)) {
    do
      r = `translation-segment-${Fe++}`;
    while (n.has(r));
    e.setAttribute("data-translation-segment-id", r);
  }
  return r;
}
function me(e, n) {
  if (n.lockedSegmentIds.size === 0) return !1;
  let t = !1;
  return n.lockedSegmentIds.forEach((r) => {
    const a = ue(e, r);
    if (!a) return;
    ce(a, !0);
    const o = n.lockedHtmlBySegmentId.get(r);
    if (typeof o == "string") {
      a.innerHTML !== o && (a.innerHTML = o, t = !0);
      return;
    }
    n.lockedHtmlBySegmentId.set(r, a.innerHTML);
  }), t;
}
function M(e, n, t) {
  var l;
  const r = nt(e, n.segmentSelector), a = [], o = /* @__PURE__ */ new Set();
  for (let s = 0; s < r.length && !(a.length >= n.maxSegments); s += 1) {
    const i = r[s], c = rt(i, o, i.getAttribute("data-translation-segment-id")), g = t.lockedSegmentIds.has(c), p = i.getAttribute("data-translation-locked") === "true", v = g || p;
    if (v)
      if (t.lockedSegmentIds.add(c), ce(i, !0), !t.lockedHtmlBySegmentId.has(c))
        t.lockedHtmlBySegmentId.set(c, i.innerHTML);
      else {
        const H = t.lockedHtmlBySegmentId.get(c) || "";
        i.innerHTML !== H && (i.innerHTML = H);
      }
    else
      t.lockedHtmlBySegmentId.delete(c);
    const C = n.normalizeText(i.textContent || "");
    if (!C) continue;
    t.sourceTextBySegmentId.has(c) || t.sourceTextBySegmentId.set(c, C);
    const K = t.sourceTextBySegmentId.get(c) || C;
    a.push({
      id: c,
      tagName: i.tagName.toLowerCase(),
      index: a.length,
      text: C,
      sourceText: K,
      locked: v
    }), o.add(c);
  }
  return Array.from(t.sourceTextBySegmentId.keys()).forEach((s) => {
    o.has(s) || t.sourceTextBySegmentId.delete(s);
  }), Array.from(t.lockedSegmentIds.keys()).forEach((s) => {
    o.has(s) || t.lockedSegmentIds.delete(s);
  }), Array.from(t.lockedHtmlBySegmentId.keys()).forEach((s) => {
    (!o.has(s) || !t.lockedSegmentIds.has(s)) && t.lockedHtmlBySegmentId.delete(s);
  }), (!t.selectedSegmentId || !a.some((s) => s.id === t.selectedSegmentId)) && (t.selectedSegmentId = ((l = a[0]) == null ? void 0 : l.id) || null), a;
}
function b(e, n) {
  u.has(e) || u.set(e, n);
  let t = D.get(e);
  return t || (t = {
    sourceLocale: n.sourceLocale,
    targetLocale: n.targetLocale,
    selectedSegmentId: null,
    realtimeEnabled: n.enableRealtime,
    segments: [],
    issues: [],
    sourceTextBySegmentId: /* @__PURE__ */ new Map(),
    lockedSegmentIds: /* @__PURE__ */ new Set(),
    lockedHtmlBySegmentId: /* @__PURE__ */ new Map(),
    snapshot: "",
    lastRunAt: null
  }, D.set(e, t)), Z.add(e), t;
}
function Se(e) {
  xe(e);
  const n = h.get(e);
  n && n.remove(), h.delete(e), Y.delete(e);
  const t = D.get(e);
  t && (t.lockedSegmentIds.forEach((r) => {
    const a = ue(e, r);
    a && ce(a, !1);
  }), t.lockedHtmlBySegmentId.clear()), u.delete(e), oe.delete(e), D.delete(e), Z.delete(e), x === e && (x = null);
}
function ye(e) {
  return Y.get(e) === !0;
}
function be(e, n) {
  if (!n.classList.contains("show")) return;
  const t = we(e).getBoundingClientRect(), r = Math.min(window.innerWidth - 20, 520), a = Math.max(10, window.innerWidth - r - 10), o = Math.min(Math.max(10, t.right - r), a), l = Math.max(10, Math.min(window.innerHeight - 10, t.top + 12));
  n.style.width = `${r}px`, n.style.left = `${o}px`, n.style.top = `${l}px`, n.style.maxHeight = `${Math.max(260, window.innerHeight - 20)}px`;
}
function P(e, n) {
  const t = e.querySelector(".rte-translation-live");
  t && (t.textContent = n);
}
function ot(e, n) {
  return `${e.innerHTML}::${n.sourceLocale}::${n.targetLocale}::${Array.from(n.lockedSegmentIds).sort().join("|")}`;
}
function at(e, n, t) {
  const r = [], a = tt(t, n.targetLocale);
  for (let o = 0; o < e.length && !(r.length >= t.maxIssues); o += 1) {
    const l = e[o], s = t.normalizeText(l.sourceText || ""), i = t.normalizeText(l.text || "");
    if (!i) {
      r.push(
        ne("missing-target", "error", t.labels.missingTargetMessage, {
          segmentId: l.id,
          sourceText: s,
          targetText: i,
          suggestion: "Provide translated content for this segment before export."
        })
      );
      continue;
    }
    if (a.preserveTokens && s && !Ue(s, i) && (r.push(
      ne("token-mismatch", "error", t.labels.tokenMismatchMessage, {
        segmentId: l.id,
        sourceText: s,
        targetText: i,
        suggestion: "Preserve placeholders/tokens exactly (for example {{name}}, %ID%, ${value})."
      })
    ), r.length >= t.maxIssues) || a.requireDifferentFromSource && s && t.normalizeText(s) === t.normalizeText(i) && (r.push(
      ne("untranslated", "warning", t.labels.untranslatedMessage, {
        segmentId: l.id,
        sourceText: s,
        targetText: i,
        suggestion: "Translate the segment or mark it intentionally unchanged."
      })
    ), r.length >= t.maxIssues))
      break;
    if (s.length >= t.minSourceLengthForRatio) {
      const c = i.length / Math.max(1, s.length);
      (c < a.minLengthRatio || c > a.maxLengthRatio) && r.push(
        ne("length-out-of-range", "warning", t.labels.lengthOutOfRangeMessage, {
          segmentId: l.id,
          sourceText: s,
          targetText: i,
          suggestion: `Expected ratio for ${a.label}: ${a.minLengthRatio.toFixed(2)} - ${a.maxLengthRatio.toFixed(2)}.`
        })
      );
    }
  }
  return r;
}
function Be(e) {
  const n = u.get(e) || w, t = D.get(e);
  return {
    sourceLocale: (t == null ? void 0 : t.sourceLocale) || (n == null ? void 0 : n.sourceLocale) || "en-US",
    targetLocale: (t == null ? void 0 : t.targetLocale) || (n == null ? void 0 : n.targetLocale) || "fr-FR",
    realtimeEnabled: (t == null ? void 0 : t.realtimeEnabled) === !0,
    selectedSegmentId: (t == null ? void 0 : t.selectedSegmentId) || null,
    segmentCount: (t == null ? void 0 : t.segments.length) || 0,
    lockedSegmentCount: t ? t.segments.filter((r) => r.locked).length : 0,
    issues: t != null && t.issues ? t.issues.map((r) => ({ ...r })) : [],
    segments: (t == null ? void 0 : t.segments.map((r) => ({
      id: r.id,
      tagName: r.tagName,
      index: r.index,
      sourceLength: r.sourceText.length,
      targetLength: r.text.length,
      locked: r.locked
    }))) || [],
    lastRunAt: (t == null ? void 0 : t.lastRunAt) || null
  };
}
function E(e) {
  const n = D.get(e), t = n && n.selectedSegmentId ? n.segments.find((r) => r.id === n.selectedSegmentId) : null;
  fe(e, "toggleTranslationWorkflowPanel", ye(e)), fe(e, "toggleTranslationRealtime", (n == null ? void 0 : n.realtimeEnabled) === !0), fe(e, "toggleTranslationSegmentLock", (t == null ? void 0 : t.locked) === !0);
}
function lt(e, n) {
  const t = ue(e, n);
  if (!t) return;
  try {
    t.scrollIntoView({ block: "nearest", inline: "nearest" });
  } catch (a) {
  }
  const r = window.getSelection();
  if (!(!r || typeof document.createRange != "function"))
    try {
      const a = document.createRange();
      a.selectNodeContents(t), a.collapse(!0), r.removeAllRanges(), r.addRange(a), e.focus({ preventScroll: !0 });
    } catch (a) {
    }
}
function R(e) {
  const n = h.get(e);
  if (!n) return;
  const t = u.get(e) || w;
  if (!t) return;
  const r = b(e, t), a = n.querySelector(".rte-translation-source-label");
  a && (a.textContent = t.labels.sourceLocaleLabel);
  const o = n.querySelector(".rte-translation-target-label");
  o && (o.textContent = t.labels.targetLocaleLabel);
  const l = n.querySelector('[data-field="source-locale"]'), s = n.querySelector('[data-field="target-locale"]'), i = t.locales.map((f) => `<option value="${m(f)}">${m(f)}</option>`).join("");
  l && (l.innerHTML = i, l.value = r.sourceLocale), s && (s.innerHTML = i, s.value = r.targetLocale);
  const c = n.querySelector(".rte-translation-summary");
  if (c) {
    const f = r.issues.length, z = r.selectedSegmentId ? ` • ${t.labels.selectedSegmentPrefix}: ${r.selectedSegmentId}` : "";
    c.textContent = `${t.labels.summaryPrefix}: ${r.sourceLocale} → ${r.targetLocale} • ${f} issue${f === 1 ? "" : "s"}${z}`;
  }
  const g = n.querySelector(".rte-translation-helper");
  g && (g.textContent = t.labels.helperText);
  const p = n.querySelector(".rte-translation-shortcut");
  p && (p.textContent = t.labels.shortcutText);
  const v = n.querySelector('[data-action="run-validation"]');
  v && (v.textContent = t.labels.validateText);
  const C = n.querySelector('[data-action="capture-source"]');
  C && (C.textContent = t.labels.captureSourceText);
  const K = n.querySelector('[data-action="toggle-realtime"]');
  K && (K.textContent = r.realtimeEnabled ? t.labels.realtimeOnText : t.labels.realtimeOffText, K.setAttribute("aria-pressed", r.realtimeEnabled ? "true" : "false"));
  const H = n.querySelector('[data-action="lock-selected"]'), q = r.selectedSegmentId && r.segments.find((f) => f.id === r.selectedSegmentId) || null;
  H && (H.textContent = q != null && q.locked ? t.labels.unlockSelectedText : t.labels.lockSelectedText, H.disabled = !q, H.setAttribute("aria-pressed", q != null && q.locked ? "true" : "false"));
  const Te = n.querySelector('[data-action="close"]');
  Te && Te.setAttribute("aria-label", t.labels.closeText);
  const J = n.querySelector(".rte-translation-issues"), V = n.querySelector(".rte-translation-empty");
  J && (J.setAttribute("aria-label", t.labels.issuesLabel), r.issues.length === 0 ? (J.innerHTML = "", V && (V.hidden = !1, V.textContent = t.labels.noIssuesText)) : (V && (V.hidden = !0), J.innerHTML = r.issues.map((f) => `
            <li class="rte-translation-issue ${f.severity === "error" ? "error" : f.severity === "warning" ? "warning" : "info"}" role="listitem" data-segment-id="${m(
    f.segmentId || ""
  )}">
              <p class="rte-translation-issue-message">${m(f.message)}</p>
              ${f.suggestion ? `<p class="rte-translation-issue-suggestion">${m(f.suggestion)}</p>` : ""}
            </li>
          `).join("")));
  const de = n.querySelector(".rte-translation-segments");
  de && (de.setAttribute("aria-label", t.labels.segmentsLabel), de.innerHTML = r.segments.map((f) => {
    const z = f.id === r.selectedSegmentId ? "selected" : "", Oe = f.locked ? "locked" : "";
    return `
          <li class="rte-translation-segment-item ${z} ${Oe}" role="option" aria-selected="${f.id === r.selectedSegmentId ? "true" : "false"}" data-segment-id="${m(f.id)}">
            <button type="button" class="rte-translation-segment-select" data-action="select-segment" data-segment-id="${m(
      f.id
    )}" title="${m(f.text)}">
              <span class="rte-translation-segment-meta">#${f.index + 1} • ${m(f.tagName)}</span>
              <span class="rte-translation-segment-text">${m(je(f.text, 110))}</span>
            </button>
            <button type="button" class="rte-translation-segment-lock" data-action="toggle-lock" data-segment-id="${m(
      f.id
    )}" aria-label="${f.locked ? t.labels.unlockSegmentAriaLabel : t.labels.lockSegmentAriaLabel}" aria-pressed="${f.locked ? "true" : "false"}"></button>
          </li>
        `;
  }).join(""));
  const Q = n.querySelector(".rte-translation-source-preview"), X = n.querySelector(".rte-translation-target-preview");
  if (Q || X) {
    const f = r.selectedSegmentId && r.segments.find((z) => z.id === r.selectedSegmentId) || null;
    Q && (Q.textContent = (f == null ? void 0 : f.sourceText) || "—", Q.setAttribute("aria-label", t.labels.sourcePreviewLabel)), X && (X.textContent = (f == null ? void 0 : f.text) || "—", X.setAttribute("aria-label", t.labels.targetPreviewLabel));
  }
  n.setAttribute("aria-label", t.labels.panelAriaLabel);
}
function Pe(e) {
  const n = u.get(e) || w;
  if (!n) return;
  xe(e);
  const t = window.setTimeout(() => {
    se.delete(e), L(e, "realtime", !1);
  }, n.debounceMs);
  se.set(e, t);
}
function L(e, n, t) {
  const r = u.get(e) || w;
  if (!r) return [];
  const a = b(e, r), o = me(e, a);
  a.segments = M(e, r, a);
  const l = ot(e, a);
  if (!t && a.snapshot === l)
    return a.issues;
  a.issues = at(a.segments, a, r), a.lastRunAt = (/* @__PURE__ */ new Date()).toISOString(), a.snapshot = l, R(e), E(e), e.dispatchEvent(
    new CustomEvent("editora:translation-workflow-validation", {
      bubbles: !0,
      detail: {
        reason: n,
        state: Be(e)
      }
    })
  );
  const s = h.get(e);
  if (s) {
    if (o)
      return P(s, r.labels.readonlySegmentMessage), a.issues;
    P(
      s,
      a.issues.length === 0 ? r.labels.noIssuesText : `${a.issues.length} issue${a.issues.length === 1 ? "" : "s"} detected.`
    );
  }
  return a.issues;
}
function De(e) {
  const n = u.get(e) || w;
  if (!n) return !1;
  const t = b(e, n), r = M(e, n, t);
  r.forEach((o) => {
    t.sourceTextBySegmentId.set(o.id, o.text);
  }), t.snapshot = "", L(e, "capture-source", !0);
  const a = h.get(e);
  return a && P(a, n.labels.sourceCapturedMessage), e.dispatchEvent(
    new CustomEvent("editora:translation-source-captured", {
      bubbles: !0,
      detail: {
        sourceLocale: t.sourceLocale,
        segmentCount: r.length
      }
    })
  ), !0;
}
function ie(e, n, t) {
  var c, g;
  const r = u.get(e) || w;
  if (!r) return !1;
  const a = b(e, r);
  a.segments = M(e, r, a);
  const o = ((c = qe(e)) == null ? void 0 : c.getAttribute("data-translation-segment-id")) || null, l = n || o || a.selectedSegmentId || ((g = a.segments[0]) == null ? void 0 : g.id) || null;
  if (!l) return !1;
  const s = ue(e, l);
  if (!s) return !1;
  const i = typeof t == "boolean" ? t : !a.lockedSegmentIds.has(l);
  return i ? (a.lockedSegmentIds.add(l), a.lockedHtmlBySegmentId.set(l, s.innerHTML)) : (a.lockedSegmentIds.delete(l), a.lockedHtmlBySegmentId.delete(l)), ce(s, i), a.selectedSegmentId = l, a.snapshot = "", L(e, "lock-segment", !0), e.dispatchEvent(
    new CustomEvent("editora:translation-segment-lock", {
      bubbles: !0,
      detail: {
        segmentId: l,
        locked: i
      }
    })
  ), !0;
}
function ze(e, n) {
  const t = u.get(e) || w;
  if (!t) return !1;
  const r = b(e, t), a = typeof n == "boolean" ? n : !r.realtimeEnabled;
  return r.realtimeEnabled = a, a ? Pe(e) : xe(e), R(e), E(e), !0;
}
function pe(e, n, t = !0) {
  const r = u.get(e) || w;
  if (!r) return !1;
  const a = b(e, r);
  return a.segments = M(e, r, a), a.segments.some((o) => o.id === n) ? (a.selectedSegmentId = n, R(e), E(e), t && lt(e, n), !0) : !1;
}
function re(e, n) {
  const t = u.get(e) || w;
  if (!t) return !1;
  const r = b(e, t);
  if (r.segments = M(e, t, r), r.segments.length === 0) return !1;
  const a = Math.max(
    0,
    r.segments.findIndex((s) => s.id === r.selectedSegmentId)
  );
  let o = a;
  n === "start" ? o = 0 : n === "end" ? o = r.segments.length - 1 : o = B(a + n, 0, r.segments.length - 1);
  const l = r.segments[o];
  return l ? pe(e, l.id, !0) : !1;
}
function G(e, n = !1) {
  const t = h.get(e);
  t && (t.classList.remove("show"), Y.set(e, !1), E(e), n && e.focus({ preventScroll: !0 }));
}
function he(e) {
  const n = dt(e);
  h.forEach((r, a) => {
    a !== e && G(a, !1);
  }), n.classList.add("show"), Y.set(e, !0), L(e, "panel-open", !1), R(e), be(e, n), E(e);
  const t = n.querySelector('[data-field="target-locale"]');
  t == null || t.focus();
}
function Ne(e, n) {
  const t = ye(e);
  return (typeof n == "boolean" ? n : !t) ? he(e) : G(e, !1), !0;
}
function Le(e) {
  return typeof e.key == "string" ? e.key.toLowerCase() : "";
}
function st(e) {
  const n = Le(e);
  return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && n === "l";
}
function it(e) {
  const n = Le(e);
  return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && n === "v";
}
function ct(e) {
  const n = Le(e);
  return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && n === "k";
}
function ut(e) {
  return e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey ? !0 : e.key === "Backspace" || e.key === "Delete" || e.key === "Enter";
}
function Me(e) {
  return e instanceof HTMLElement ? e.closest('[data-translation-locked="true"]') : null;
}
function dt(e) {
  const n = h.get(e);
  if (n) return n;
  const t = u.get(e) || w || ae();
  b(e, t);
  const r = `rte-translation-workflow-panel-${We++}`, a = `${r}-source`, o = `${r}-target`, l = document.createElement("section");
  return l.className = d, l.id = r, l.setAttribute("role", "dialog"), l.setAttribute("aria-modal", "false"), l.setAttribute("aria-label", t.labels.panelAriaLabel), l.innerHTML = `
    <header class="rte-translation-header">
      <h2 class="rte-translation-title">${m(t.labels.panelTitle)}</h2>
      <button type="button" class="rte-translation-icon-btn" data-action="close" aria-label="${m(
    t.labels.closeText
  )}">✕</button>
    </header>
    <div class="rte-translation-body">
      <div class="rte-translation-locales">
        <div class="rte-translation-locale-field">
          <label class="rte-translation-source-label" for="${m(a)}"></label>
          <select id="${m(a)}" class="rte-translation-select" data-field="source-locale"></select>
        </div>
        <div class="rte-translation-locale-field">
          <label class="rte-translation-target-label" for="${m(o)}"></label>
          <select id="${m(o)}" class="rte-translation-select" data-field="target-locale"></select>
        </div>
      </div>
      <p class="rte-translation-summary"></p>
      <div class="rte-translation-actions">
        <button type="button" class="rte-translation-btn rte-translation-btn-primary" data-action="run-validation"></button>
        <button type="button" class="rte-translation-btn" data-action="capture-source"></button>
        <button type="button" class="rte-translation-btn" data-action="lock-selected"></button>
        <button type="button" class="rte-translation-btn" data-action="toggle-realtime" aria-pressed="false"></button>
      </div>
      <p class="rte-translation-helper"></p>
      <p class="rte-translation-shortcut"></p>
      <div class="rte-translation-grid">
        <section class="rte-translation-segments-wrap" aria-label="${m(t.labels.segmentsLabel)}">
          <h3 class="rte-translation-subtitle">${m(t.labels.segmentsLabel)}</h3>
          <ul class="rte-translation-segments" role="listbox" tabindex="0" aria-label="${m(
    t.labels.segmentsLabel
  )}"></ul>
        </section>
        <section class="rte-translation-preview-wrap">
          <h3 class="rte-translation-subtitle">${m(t.labels.sourcePreviewLabel)} / ${m(
    t.labels.targetPreviewLabel
  )}</h3>
          <div class="rte-translation-preview-block">
            <p class="rte-translation-preview-label">${m(t.labels.sourcePreviewLabel)}</p>
            <p class="rte-translation-source-preview"></p>
          </div>
          <div class="rte-translation-preview-block">
            <p class="rte-translation-preview-label">${m(t.labels.targetPreviewLabel)}</p>
            <p class="rte-translation-target-preview"></p>
          </div>
        </section>
      </div>
      <section class="rte-translation-issues-wrap">
        <h3 class="rte-translation-subtitle">${m(t.labels.issuesLabel)}</h3>
        <ul class="rte-translation-issues" role="list" aria-label="${m(t.labels.issuesLabel)}"></ul>
        <p class="rte-translation-empty" hidden></p>
      </section>
    </div>
    <div class="rte-translation-live" aria-live="polite" aria-atomic="true"></div>
  `, l.addEventListener("click", (s) => {
    const i = s.target;
    if (!i) return;
    const c = i.closest("[data-action]");
    if (!c) {
      const p = i.closest(".rte-translation-issue[data-segment-id]"), v = (p == null ? void 0 : p.getAttribute("data-segment-id")) || "";
      v && pe(e, v, !0);
      return;
    }
    const g = c.getAttribute("data-action");
    if (g === "close") {
      G(e, !0);
      return;
    }
    if (g === "run-validation") {
      L(e, "panel-button", !0);
      return;
    }
    if (g === "capture-source") {
      De(e);
      return;
    }
    if (g === "lock-selected") {
      ie(e);
      return;
    }
    if (g === "toggle-realtime") {
      ze(e);
      return;
    }
    if (g === "select-segment") {
      const p = c.getAttribute("data-segment-id") || "";
      p && pe(e, p, !0);
      return;
    }
    if (g === "toggle-lock") {
      const p = c.getAttribute("data-segment-id") || "";
      p && ie(e, p);
    }
  }), l.addEventListener("change", (s) => {
    const i = s.target;
    if (!(i instanceof HTMLSelectElement)) return;
    const c = u.get(e) || w;
    if (!c) return;
    const g = b(e, c);
    if (i.getAttribute("data-field") === "source-locale") {
      g.sourceLocale = A(i.value), g.snapshot = "", L(e, "source-locale-change", !0);
      return;
    }
    i.getAttribute("data-field") === "target-locale" && (g.targetLocale = A(i.value), g.snapshot = "", L(e, "target-locale-change", !0));
  }), l.addEventListener("keydown", (s) => {
    const i = s.target;
    if (s.key === "Escape") {
      s.preventDefault(), G(e, !0);
      return;
    }
    !(i != null && i.closest(".rte-translation-segments")) || !Ce.has(s.key) || (s.preventDefault(), s.key === "ArrowUp" ? re(e, -1) : s.key === "ArrowDown" ? re(e, 1) : s.key === "Home" ? re(e, "start") : s.key === "End" && re(e, "end"));
  }), ge(l, e), document.body.appendChild(l), h.set(e, l), Y.set(e, !1), R(e), l;
}
function ft(e) {
  w = e, N || (N = (n) => {
    var i;
    le();
    const t = n.target, r = t == null ? void 0 : t.closest(S);
    if (!r) return;
    const a = u.get(r) || e, o = b(r, a);
    u.set(r, a), x = r;
    const l = ((i = qe(r)) == null ? void 0 : i.getAttribute("data-translation-segment-id")) || null;
    l && (o.selectedSegmentId = l), E(r);
    const s = h.get(r);
    s && (ge(s, r), be(r, s), R(r));
  }, document.addEventListener("focusin", N, !0)), O || (O = (n) => {
    const t = n.target, r = t == null ? void 0 : t.closest(S);
    if (!r) return;
    const a = u.get(r) || w;
    if (!a) return;
    const o = b(r, a), l = me(r, o);
    if (o.segments = M(r, a, o), !o.realtimeEnabled) {
      if (l) {
        const s = h.get(r);
        s && P(s, a.labels.readonlySegmentMessage);
      }
      R(r), E(r);
      return;
    }
    Pe(r);
  }, document.addEventListener("input", O, !0)), _ || (_ = (n) => {
    const t = n, r = t.target, a = r == null ? void 0 : r.closest(S);
    if (!a) return;
    const o = Me(r);
    if (!o || !a.contains(o)) return;
    t.preventDefault();
    const l = h.get(a), s = u.get(a) || w;
    l && s && P(l, s.labels.readonlySegmentMessage);
  }, document.addEventListener("beforeinput", _, !0)), F || (F = (n) => {
    if (n.defaultPrevented) return;
    const t = n.target;
    if ((t == null ? void 0 : t.closest(`.${d}`)) && n.key !== "Escape" && !Ce.has(n.key)) return;
    const a = n.key === "Escape", o = st(n), l = it(n), s = ct(n), i = Me(t);
    if (!a && !o && !l && !s && !i)
      return;
    const c = et(n);
    if (!c) return;
    const g = u.get(c) || w || e;
    if (b(c, g), u.set(c, g), x = c, a && ye(c)) {
      n.preventDefault(), G(c, !0);
      return;
    }
    if (i && c.contains(i) && ut(n)) {
      n.preventDefault();
      const p = h.get(c);
      p && P(p, g.labels.readonlySegmentMessage);
      return;
    }
    if (o) {
      n.preventDefault(), n.stopPropagation(), Ne(c);
      return;
    }
    if (l) {
      n.preventDefault(), n.stopPropagation(), L(c, "shortcut", !0);
      return;
    }
    s && (n.preventDefault(), n.stopPropagation(), ie(c));
  }, document.addEventListener("keydown", F, !0)), I || (I = () => {
    le(), h.forEach((n, t) => {
      !t.isConnected || !n.isConnected || (ge(n, t), be(t, n));
    });
  }, window.addEventListener("scroll", I, !0), window.addEventListener("resize", I)), !W && typeof MutationObserver != "undefined" && document.body && (W = new MutationObserver((n) => {
    Xe(n) && le(), n.some((r) => r.type === "characterData" ? !0 : r.type === "childList" && (r.addedNodes.length > 0 || r.removedNodes.length > 0)) && Z.forEach((r) => {
      const a = D.get(r);
      if (!a || a.lockedSegmentIds.size === 0 || !me(r, a)) return;
      a.snapshot = "";
      const l = u.get(r) || w, s = h.get(r);
      s && l && P(s, l.labels.readonlySegmentMessage), l && (a.segments = M(r, l, a), R(r), E(r));
    });
  }), W.observe(document.body, {
    childList: !0,
    subtree: !0,
    characterData: !0
  }));
}
function gt() {
  N && (document.removeEventListener("focusin", N, !0), N = null), O && (document.removeEventListener("input", O, !0), O = null), _ && (document.removeEventListener("beforeinput", _, !0), _ = null), F && (document.removeEventListener("keydown", F, !0), F = null), I && (window.removeEventListener("scroll", I, !0), window.removeEventListener("resize", I), I = null), W && (W.disconnect(), W = null), h.forEach((n) => n.remove()), h.clear(), Array.from(Z).forEach((n) => Se(n)), w = null, x = null;
}
function mt() {
  if (typeof document == "undefined" || document.getElementById($e)) return;
  const e = document.createElement("style");
  e.id = $e, e.textContent = `
    .rte-toolbar-group-items.${y},
    .editora-toolbar-group-items.${y},
    .rte-toolbar-group-items.${$},
    .editora-toolbar-group-items.${$} {
      display: flex;
      border: 1px solid #cbd5e1;
      border-radius: 4px;
      background: #ffffff;
    }

    .rte-toolbar-group-items.${y} .rte-toolbar-button,
    .editora-toolbar-group-items.${y} .editora-toolbar-button,
    .rte-toolbar-group-items.${$} .rte-toolbar-button,
    .editora-toolbar-group-items.${$} .editora-toolbar-button {
      border: none;
      border-right: 1px solid #cbd5e1;
      border-radius: 0;
    }

    .rte-toolbar-group-items.${y} .rte-toolbar-item:last-child .rte-toolbar-button,
    .editora-toolbar-group-items.${y} .editora-toolbar-item:last-child .editora-toolbar-button,
    .rte-toolbar-group-items.${$} .rte-toolbar-item:last-child .rte-toolbar-button,
    .editora-toolbar-group-items.${$} .editora-toolbar-item:last-child .editora-toolbar-button {
      border-right: none;
    }

    ${k} .rte-toolbar-group-items.${y},
    ${k} .editora-toolbar-group-items.${y},
    ${k} .rte-toolbar-group-items.${$},
    ${k} .editora-toolbar-group-items.${$} {
      border-color: #566275;
    }
    .rte-toolbar-button[data-command="toggleTranslationWorkflowPanel"].active,
    .editora-toolbar-button[data-command="toggleTranslationWorkflowPanel"].active,
    .rte-toolbar-button[data-command="toggleTranslationSegmentLock"].active,
    .editora-toolbar-button[data-command="toggleTranslationSegmentLock"].active, 
    .rte-toolbar-button[data-command="toggleTranslationRealtime"].active,
    .editora-toolbar-button[data-command="toggleTranslationRealtime"].active {
      background: #ccc;
    }
    ${k} .rte-toolbar-group-items.${y} .rte-toolbar-button svg,
    ${k} .editora-toolbar-group-items.${y} .editora-toolbar-button svg,
    ${k} .rte-toolbar-group-items.${$} .rte-toolbar-button svg,
    ${k} .editora-toolbar-group-items.${$} .editora-toolbar-button svg
    {
      fill: none;
    }
    ${k} .rte-toolbar-group-items.${y} .rte-toolbar-button,
    ${k} .editora-toolbar-group-items.${y} .editora-toolbar-button
    {
      border-color: #566275;
    }

    ${k} .rte-toolbar-button[data-command="toggleTranslationWorkflowPanel"].active,
    ${k} .editora-toolbar-button[data-command="toggleTranslationWorkflowPanel"].active,
    ${k} .rte-toolbar-button[data-command="toggleTranslationSegmentLock"].active,
    ${k} .editora-toolbar-button[data-command="toggleTranslationSegmentLock"].active, 
    ${k} .rte-toolbar-button[data-command="toggleTranslationRealtime"].active,
    ${k} .editora-toolbar-button[data-command="toggleTranslationRealtime"].active {
      background: linear-gradient(180deg, #5eaaf6 0%, #4a95de 100%);
    }

    .${d} {
      position: fixed;
      z-index: 12000;
      display: none;
      width: min(520px, calc(100vw - 20px));
      max-height: calc(100vh - 20px);
      border: 1px solid #d1d5db;
      border-radius: 14px;
      background: #ffffff;
      color: #0f172a;
      box-shadow: 0 24px 48px rgba(15, 23, 42, 0.24);
      overflow: hidden;
    }

    .${d}.show {
      display: flex;
      flex-direction: column;
    }

    .${d}.rte-translation-workflow-theme-dark {
      border-color: #334155;
      background: #0f172a;
      color: #e2e8f0;
      box-shadow: 0 24px 52px rgba(2, 6, 23, 0.68);
    }

    .rte-translation-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 12px 14px;
      border-bottom: 1px solid #e2e8f0;
      background: linear-gradient(180deg, #eff6ff 0%, #e2e8f0 100%);
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-header {
      border-color: #1e293b;
      background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
    }

    .rte-translation-title {
      margin: 0;
      font-size: 15px;
      line-height: 1.2;
      font-weight: 700;
    }

    .rte-translation-icon-btn {
      border: 1px solid #cbd5e1;
      border-radius: 6px;
      min-height: 34px;
      width: 34px;
      background: #ffffff;
      color: #0f172a;
      font-size: 16px;
      line-height: 1;
      font-weight: 600;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
    }

    .rte-translation-icon-btn:hover,
    .rte-translation-icon-btn:focus-visible {
      outline: none;
      border-color: #3b82f6;
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-icon-btn {
      border-color: #475569;
      background: #0f172a;
      color: #e2e8f0;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-icon-btn:hover,
    .${d}.rte-translation-workflow-theme-dark .rte-translation-icon-btn:focus-visible {
      border-color: #60a5fa;
      box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
    }

    .rte-translation-body {
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 12px;
      overflow: auto;
    }

    .rte-translation-locales {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }

    .rte-translation-locale-field {
      display: grid;
      gap: 4px;
    }

    .rte-translation-source-label,
    .rte-translation-target-label {
      font-size: 12px;
      font-weight: 700;
      color: #334155;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-source-label,
    .${d}.rte-translation-workflow-theme-dark .rte-translation-target-label {
      color: #cbd5e1;
    }

    .rte-translation-select {
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      min-height: 34px;
      padding: 0 10px;
      font-size: 13px;
      background: #ffffff;
      color: inherit;
    }

    .rte-translation-select:focus-visible {
      border-color: #0e7490;
      box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.18);
      outline: none;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-select {
      border-color: #334155;
      background: #0b1220;
      color: #e2e8f0;
    }

    .rte-translation-summary,
    .rte-translation-helper,
    .rte-translation-shortcut {
      margin: 0;
      font-size: 12px;
      line-height: 1.35;
      color: #475569;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-summary,
    .${d}.rte-translation-workflow-theme-dark .rte-translation-helper,
    .${d}.rte-translation-workflow-theme-dark .rte-translation-shortcut {
      color: #94a3b8;
    }

    .rte-translation-actions {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 8px;
    }

    .rte-translation-btn {
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      min-height: 34px;
      padding: 0 8px;
      background: #ffffff;
      color: inherit;
      font-size: 12px;
      font-weight: 700;
      cursor: pointer;
    }

    .rte-translation-btn:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    .rte-translation-btn-primary {
      border-color: #0e7490;
      background: #0e7490;
      color: #f8fafc;
    }

    .rte-translation-btn:hover,
    .rte-translation-btn:focus-visible {
      border-color: #94a3b8;
      outline: none;
    }

    .rte-translation-btn-primary:hover,
    .rte-translation-btn-primary:focus-visible {
      border-color: #155e75;
      background: #155e75;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-btn {
      border-color: #334155;
      background: #111827;
      color: #e2e8f0;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-btn-primary {
      border-color: #22d3ee;
      background: #0e7490;
      color: #ecfeff;
    }

    .rte-translation-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }

    .rte-translation-segments-wrap,
    .rte-translation-preview-wrap,
    .rte-translation-issues-wrap {
      border: 1px solid #e2e8f0;
      border-radius: 10px;
      background: #f8fafc;
      padding: 8px;
      min-height: 120px;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-segments-wrap,
    .${d}.rte-translation-workflow-theme-dark .rte-translation-preview-wrap,
    .${d}.rte-translation-workflow-theme-dark .rte-translation-issues-wrap {
      border-color: #334155;
      background: #0b1220;
    }

    .rte-translation-subtitle {
      margin: 0 0 6px;
      font-size: 12px;
      font-weight: 700;
      color: #334155;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-subtitle {
      color: #cbd5e1;
    }

    .rte-translation-segments {
      margin: 0;
      padding: 0;
      list-style: none;
      display: grid;
      gap: 6px;
      max-height: 220px;
      overflow: auto;
      outline: none;
    }

    .rte-translation-segment-item {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 6px;
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      background: #ffffff;
      padding: 6px;
    }

    .rte-translation-segment-item.selected {
      border-color: #0e7490;
      box-shadow: 0 0 0 2px rgba(14, 116, 144, 0.16);
    }

    .rte-translation-segment-item.locked {
      border-color: #f59e0b;
      background: #fffbeb;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-segment-item {
      border-color: #334155;
      background: #111827;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-segment-item.locked {
      border-color: rgba(245, 158, 11, 0.72);
      background: rgba(120, 53, 15, 0.28);
    }

    .rte-translation-segment-select {
      border: none;
      background: transparent;
      color: inherit;
      text-align: left;
      padding: 0;
      cursor: pointer;
      display: grid;
      gap: 2px;
    }

    .rte-translation-segment-meta {
      font-size: 11px;
      color: #64748b;
      font-weight: 700;
    }

    .rte-translation-segment-text {
      font-size: 12px;
      color: #334155;
      line-height: 1.3;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-segment-meta {
      color: #94a3b8;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-segment-text {
      color: #e2e8f0;
    }

    .rte-translation-segment-lock {
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      width: 28px;
      min-height: 28px;
      background: #ffffff;
      cursor: pointer;
      position: relative;
      color: inherit;
      font-size: 0;
    }

    .rte-translation-segment-lock::before {
      content: '🔒';
      font-size: 14px;
      position: absolute;
      inset: 0;
      display: grid;
      place-items: center;
      opacity: 0.35;
    }

    .rte-translation-segment-lock[aria-pressed="true"]::before {
      opacity: 1;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-segment-lock {
      border-color: #334155;
      background: #111827;
    }

    .rte-translation-preview-block {
      display: grid;
      gap: 4px;
      margin-bottom: 8px;
    }

    .rte-translation-preview-label {
      margin: 0;
      font-size: 11px;
      color: #64748b;
      font-weight: 700;
    }

    .rte-translation-source-preview,
    .rte-translation-target-preview {
      margin: 0;
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      background: #ffffff;
      padding: 8px;
      font-size: 12px;
      min-height: 56px;
      white-space: pre-wrap;
      line-height: 1.35;
      color: #1f2937;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-preview-label {
      color: #94a3b8;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-source-preview,
    .${d}.rte-translation-workflow-theme-dark .rte-translation-target-preview {
      border-color: #334155;
      background: #111827;
      color: #e2e8f0;
    }

    .rte-translation-issues {
      margin: 0;
      padding: 0;
      list-style: none;
      display: grid;
      gap: 6px;
      max-height: 200px;
      overflow: auto;
    }

    .rte-translation-issue {
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      background: #ffffff;
      padding: 8px;
      display: grid;
      gap: 4px;
      cursor: pointer;
    }

    .rte-translation-issue.error {
      border-color: #ef4444;
      background: #fef2f2;
    }

    .rte-translation-issue.warning {
      border-color: #f59e0b;
      background: #fffbeb;
    }

    .rte-translation-issue.info {
      border-color: #0ea5e9;
      background: #f0f9ff;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-issue {
      border-color: #334155;
      background: #111827;
      color: #e2e8f0;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-issue.error {
      border-color: rgba(239, 68, 68, 0.7);
      background: rgba(127, 29, 29, 0.28);
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-issue.warning {
      border-color: rgba(245, 158, 11, 0.72);
      background: rgba(120, 53, 15, 0.28);
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-issue.info {
      border-color: rgba(14, 165, 233, 0.7);
      background: rgba(7, 89, 133, 0.28);
    }

    .rte-translation-issue-message,
    .rte-translation-issue-suggestion {
      margin: 0;
      font-size: 12px;
      line-height: 1.35;
      color: #1f2937;
    }

    .rte-translation-issue-suggestion {
      color: #475569;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-issue-message {
      color: #e2e8f0;
    }

    .${d}.rte-translation-workflow-theme-dark .rte-translation-issue-suggestion {
      color: #cbd5e1;
    }

    .rte-translation-empty {
      margin: 8px;
      font-size: 12px;
      color: #64748b;
    }

    .rte-translation-live {
      position: absolute;
      width: 1px;
      height: 1px;
      margin: -1px;
      padding: 0;
      overflow: hidden;
      clip: rect(0 0 0 0);
      border: 0;
    }

    [data-translation-locked="true"].rte-translation-segment-locked {
      outline: 2px dashed rgba(245, 158, 11, 0.65);
      outline-offset: 2px;
      background: rgba(255, 251, 235, 0.8);
      border-radius: 4px;
    }

    ${k} [data-translation-locked="true"].rte-translation-segment-locked {
      outline-color: rgba(245, 158, 11, 0.75);
      background: rgba(120, 53, 15, 0.22);
    }

    @media (max-width: 920px) {
      .${d} {
        left: 10px !important;
        right: 10px;
        top: 10px !important;
        width: auto !important;
        max-height: calc(100vh - 20px);
      }

      .rte-translation-locales,
      .rte-translation-actions,
      .rte-translation-grid {
        grid-template-columns: 1fr;
      }
    }
  `, document.head.appendChild(e);
}
const bt = (e = {}) => {
  const n = ae(e), t = /* @__PURE__ */ new Set();
  return mt(), {
    name: "translationWorkflow",
    toolbar: [
      {
        id: "translationWorkflowGroup",
        label: "Translation Workflow",
        type: "group",
        command: "translationWorkflow",
        items: [
          {
            id: "toggleTranslationWorkflowPanel",
            label: "Translation Workflow",
            command: "toggleTranslationWorkflowPanel",
            shortcut: "Mod-Alt-Shift-l",
            icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6.5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H8l-4 3V6.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M20 17.5a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-1.5" stroke="currentColor" stroke-width="1.6"/><path d="m13 8 2 2m0 0 2-2m-2 2V4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'
          },
          {
            id: "runTranslationLocaleValidation",
            label: "Run Locale Validation",
            command: "runTranslationLocaleValidation",
            shortcut: "Mod-Alt-Shift-v",
            icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="4" width="12" height="16" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8 8h5.5M8 11h4M8 14h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="m15.5 15.5 1.7 1.7 3.3-3.3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'
          },
          {
            id: "toggleTranslationSegmentLock",
            label: "Toggle Segment Lock",
            command: "toggleTranslationSegmentLock",
            shortcut: "Mod-Alt-Shift-k",
            icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="5" y="10" width="14" height="10" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8.5 10V7.5a3.5 3.5 0 1 1 7 0V10" stroke="currentColor" stroke-width="1.6"/><circle cx="12" cy="15" r="1.2" fill="currentColor"/></svg>'
          },
          {
            id: "toggleTranslationRealtime",
            label: "Toggle Translation Realtime",
            command: "toggleTranslationRealtime",
            icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 1 7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M9.5 19.5H5.5v-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 8v4l2.5 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'
          }
        ]
      }
    ],
    commands: {
      translationWorkflow: (r, a) => {
        const o = T(a, !1, !1);
        if (!o) return !1;
        const l = u.get(o) || n;
        return b(o, l), u.set(o, l), x = o, he(o), !0;
      },
      openTranslationWorkflowPanel: (r, a) => {
        const o = T(a, !1, !1);
        if (!o) return !1;
        const l = u.get(o) || n;
        return b(o, l), u.set(o, l), x = o, he(o), !0;
      },
      toggleTranslationWorkflowPanel: (r, a) => {
        const o = T(a, !1, !1);
        if (!o) return !1;
        const l = u.get(o) || n;
        return b(o, l), u.set(o, l), x = o, Ne(o, typeof r == "boolean" ? r : void 0);
      },
      runTranslationLocaleValidation: (r, a) => {
        const o = T(a, !1, !1);
        if (!o) return !1;
        const l = u.get(o) || n;
        return b(o, l), u.set(o, l), x = o, L(o, "command", !0), !0;
      },
      toggleTranslationRealtime: (r, a) => {
        const o = T(a, !1, !1);
        if (!o) return !1;
        const l = u.get(o) || n;
        return b(o, l), u.set(o, l), x = o, ze(o, typeof r == "boolean" ? r : void 0);
      },
      toggleTranslationSegmentLock: (r, a) => {
        const o = T(a, !1, !1);
        if (!o) return !1;
        const l = u.get(o) || n;
        b(o, l), u.set(o, l), x = o;
        const s = typeof r == "boolean" ? r : r == null ? void 0 : r.locked, i = typeof r == "object" ? r == null ? void 0 : r.segmentId : void 0;
        return ie(o, i, s);
      },
      setTranslationLocales: (r, a) => {
        const o = T(a, !1, !1);
        if (!o || !r || typeof r != "object") return !1;
        const l = u.get(o) || n, s = b(o, l);
        return u.set(o, l), typeof r.sourceLocale == "string" && r.sourceLocale.trim() && (s.sourceLocale = A(r.sourceLocale)), typeof r.targetLocale == "string" && r.targetLocale.trim() && (s.targetLocale = A(r.targetLocale)), s.snapshot = "", L(o, "set-locales", !0), !0;
      },
      captureTranslationSourceSnapshot: (r, a) => {
        const o = T(a, !1, !1);
        if (!o) return !1;
        const l = u.get(o) || n;
        return b(o, l), u.set(o, l), x = o, De(o);
      },
      setTranslationWorkflowOptions: (r, a) => {
        const o = T(a, !1, !1);
        if (!o || !r || typeof r != "object") return !1;
        const l = u.get(o) || n, s = oe.get(o) || Ye(l), i = {
          ...s,
          ...r,
          labels: {
            ...s.labels || {},
            ...r.labels || {}
          },
          localeRules: Array.isArray(r.localeRules) ? r.localeRules : s.localeRules,
          locales: Array.isArray(r.locales) ? r.locales : s.locales,
          normalizeText: r.normalizeText || l.normalizeText
        }, c = ae(i);
        u.set(o, c), oe.set(o, i);
        const g = b(o, c);
        return typeof r.enableRealtime == "boolean" && (g.realtimeEnabled = r.enableRealtime), typeof r.sourceLocale == "string" && r.sourceLocale.trim() && (g.sourceLocale = A(r.sourceLocale)), typeof r.targetLocale == "string" && r.targetLocale.trim() && (g.targetLocale = A(r.targetLocale)), g.snapshot = "", L(o, "set-options", !0), R(o), E(o), !0;
      },
      getTranslationWorkflowState: (r, a) => {
        const o = T(a, !1, !1);
        if (!o) return !1;
        const l = u.get(o) || n;
        b(o, l);
        const s = Be(o);
        if (typeof r == "function")
          try {
            r(s);
          } catch (i) {
          }
        return o.__translationWorkflowState = s, o.dispatchEvent(
          new CustomEvent("editora:translation-workflow-state", {
            bubbles: !0,
            detail: s
          })
        ), !0;
      }
    },
    keymap: {
      "Mod-Alt-Shift-l": "toggleTranslationWorkflowPanel",
      "Mod-Alt-Shift-L": "toggleTranslationWorkflowPanel",
      "Mod-Alt-Shift-v": "runTranslationLocaleValidation",
      "Mod-Alt-Shift-V": "runTranslationLocaleValidation",
      "Mod-Alt-Shift-k": "toggleTranslationSegmentLock",
      "Mod-Alt-Shift-K": "toggleTranslationSegmentLock"
    },
    init: function(a) {
      ee += 1;
      const o = this && typeof this.__pluginConfig == "object" ? { ...e, ...this.__pluginConfig } : e, l = ae(o);
      ft(l);
      const s = T(
        a != null && a.editorElement ? { editorElement: a.editorElement } : void 0,
        !1,
        !1
      );
      if (!s) return;
      x = s, t.add(s);
      const i = b(s, l);
      u.set(s, l), oe.set(s, o), i.segments = M(s, l, i), L(s, "init", !0), E(s);
    },
    destroy: () => {
      t.forEach((r) => Se(r)), t.clear(), ee = Math.max(0, ee - 1), !(ee > 0) && gt();
    }
  };
};
export {
  bt as TranslationWorkflowPlugin
};
//# sourceMappingURL=TranslationWorkflowPlugin.native-DdF16tgT.mjs.map
