@editora/plugins 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -4
  3. package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
  4. package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
  5. package/dist/anchor.cjs.js +11 -11
  6. package/dist/anchor.esm.js +130 -107
  7. package/dist/anchoredPopover-BzqGPOAE.js +1 -0
  8. package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
  9. package/dist/approval-workflow.cjs.js +447 -0
  10. package/dist/approval-workflow.esm.js +1070 -0
  11. package/dist/background-color.cjs.js +3 -3
  12. package/dist/background-color.esm.js +116 -119
  13. package/dist/blocks-library.cjs.js +442 -0
  14. package/dist/blocks-library.esm.js +1317 -0
  15. package/dist/citations.cjs.js +548 -0
  16. package/dist/citations.esm.js +1457 -0
  17. package/dist/code.cjs.js +82 -102
  18. package/dist/code.esm.js +1172 -662
  19. package/dist/comments.cjs.js +10 -10
  20. package/dist/comments.esm.js +195 -177
  21. package/dist/conditional-content.cjs.js +626 -0
  22. package/dist/conditional-content.esm.js +1360 -0
  23. package/dist/content-rules.cjs.js +408 -0
  24. package/dist/content-rules.esm.js +1093 -0
  25. package/dist/data-binding.cjs.js +321 -0
  26. package/dist/data-binding.esm.js +913 -0
  27. package/dist/doc-schema.cjs.js +398 -0
  28. package/dist/doc-schema.esm.js +1310 -0
  29. package/dist/document-manager.cjs.js +1 -1
  30. package/dist/document-manager.esm.js +1 -1
  31. package/dist/documentManager-CTqRftU8.mjs +8369 -0
  32. package/dist/documentManager-Jf0RbSks.js +17 -0
  33. package/dist/embed-iframe.cjs.js +2 -2
  34. package/dist/embed-iframe.esm.js +8 -5
  35. package/dist/emojis.cjs.js +64 -39
  36. package/dist/emojis.esm.js +133 -104
  37. package/dist/enterprise.cjs.js +1 -0
  38. package/dist/enterprise.esm.js +56 -0
  39. package/dist/html2canvas.esm-B5qzocYs.js +5 -0
  40. package/dist/html2canvas.esm-BWVIUcAF.mjs +4802 -0
  41. package/dist/{index-Bskk414V.mjs → index-BFsKNTTj.mjs} +50 -50
  42. package/dist/index-CvJk4DKa.js +221 -0
  43. package/dist/index-D3CycEFU.mjs +16543 -0
  44. package/dist/index-tqLTHcO6.js +1 -0
  45. package/dist/index.cjs.js +1 -1
  46. package/dist/{index.es-Cz1qItab.js → index.es-CE_A4QSm.js} +5 -5
  47. package/dist/{index.es-DEcRmSTY.mjs → index.es-DQ78mYYo.mjs} +4 -3
  48. package/dist/index.esm.js +111 -75
  49. package/dist/jspdf.es.min-BoS80556.js +77 -0
  50. package/dist/jspdf.es.min-DQCoX5yh.mjs +7889 -0
  51. package/dist/link.cjs.js +6 -6
  52. package/dist/link.esm.js +41 -39
  53. package/dist/math.cjs.js +21 -21
  54. package/dist/math.esm.js +151 -112
  55. package/dist/media-manager.cjs.js +15 -15
  56. package/dist/media-manager.esm.js +227 -206
  57. package/dist/mentions.cjs.js +105 -0
  58. package/dist/mentions.esm.js +726 -0
  59. package/dist/merge-tag.cjs.js +44 -12
  60. package/dist/merge-tag.esm.js +368 -241
  61. package/dist/page-break.cjs.js +2 -2
  62. package/dist/page-break.esm.js +85 -77
  63. package/dist/pii-redaction.cjs.js +436 -0
  64. package/dist/pii-redaction.esm.js +1377 -0
  65. package/dist/preview.cjs.js +3 -3
  66. package/dist/preview.esm.js +29 -29
  67. package/dist/slash-commands.cjs.js +90 -0
  68. package/dist/slash-commands.esm.js +752 -0
  69. package/dist/smart-paste.cjs.js +398 -0
  70. package/dist/smart-paste.esm.js +1388 -0
  71. package/dist/special-characters.cjs.js +83 -45
  72. package/dist/special-characters.esm.js +149 -100
  73. package/dist/spell-check.cjs.js +9 -9
  74. package/dist/spell-check.esm.js +235 -216
  75. package/dist/template.cjs.js +14 -14
  76. package/dist/template.esm.js +157 -131
  77. package/dist/text-color.cjs.js +9 -9
  78. package/dist/text-color.esm.js +131 -115
  79. package/dist/track-changes.cjs.js +77 -0
  80. package/dist/track-changes.esm.js +755 -0
  81. package/dist/translation-workflow.cjs.js +626 -0
  82. package/dist/translation-workflow.esm.js +1718 -0
  83. package/dist/version-diff.cjs.js +362 -0
  84. package/dist/version-diff.esm.js +768 -0
  85. package/index.d.ts +849 -1
  86. package/package.json +105 -6
  87. package/dist/colorSelectionApply-C0iOfMWb.js +0 -1
  88. package/dist/colorSelectionApply-D8r_gV32.mjs +0 -63
  89. package/dist/documentManager-DRUc1-Cs.mjs +0 -37581
  90. package/dist/documentManager-_tQQfQi9.js +0 -317
  91. package/dist/index-D3pJyAsj.js +0 -1
@@ -0,0 +1,1718 @@
1
+ const S = ".rte-content, .editora-content", ke = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", Te = "__editoraCommandEditorRoot", ve = "rte-translation-workflow-styles", u = "rte-translation-workflow-panel", y = "translation-workflow", $ = "translationWorkflow", h = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', $e = [
2
+ "p",
3
+ "h1",
4
+ "h2",
5
+ "h3",
6
+ "h4",
7
+ "h5",
8
+ "h6",
9
+ "li",
10
+ "td",
11
+ "th",
12
+ "blockquote",
13
+ "figcaption"
14
+ ].join(", "), Me = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "Home", "End"]), Ee = [
15
+ {
16
+ locale: "en",
17
+ label: "English",
18
+ minLengthRatio: 0.6,
19
+ maxLengthRatio: 1.4,
20
+ requireDifferentFromSource: !1,
21
+ preserveTokens: !0
22
+ },
23
+ {
24
+ locale: "fr",
25
+ label: "French",
26
+ minLengthRatio: 0.75,
27
+ maxLengthRatio: 1.7,
28
+ requireDifferentFromSource: !0,
29
+ preserveTokens: !0
30
+ },
31
+ {
32
+ locale: "de",
33
+ label: "German",
34
+ minLengthRatio: 0.8,
35
+ maxLengthRatio: 1.9,
36
+ requireDifferentFromSource: !0,
37
+ preserveTokens: !0
38
+ },
39
+ {
40
+ locale: "es",
41
+ label: "Spanish",
42
+ minLengthRatio: 0.7,
43
+ maxLengthRatio: 1.7,
44
+ requireDifferentFromSource: !0,
45
+ preserveTokens: !0
46
+ },
47
+ {
48
+ locale: "it",
49
+ label: "Italian",
50
+ minLengthRatio: 0.7,
51
+ maxLengthRatio: 1.7,
52
+ requireDifferentFromSource: !0,
53
+ preserveTokens: !0
54
+ },
55
+ {
56
+ locale: "ja",
57
+ label: "Japanese",
58
+ minLengthRatio: 0.45,
59
+ maxLengthRatio: 1.2,
60
+ requireDifferentFromSource: !0,
61
+ preserveTokens: !0
62
+ },
63
+ {
64
+ locale: "zh",
65
+ label: "Chinese",
66
+ minLengthRatio: 0.4,
67
+ maxLengthRatio: 1.2,
68
+ requireDifferentFromSource: !0,
69
+ preserveTokens: !0
70
+ }
71
+ ], Oe = {
72
+ panelTitle: "Translation Workflow",
73
+ panelAriaLabel: "Translation workflow panel",
74
+ sourceLocaleLabel: "Source Locale",
75
+ targetLocaleLabel: "Target Locale",
76
+ validateText: "Validate Locale",
77
+ captureSourceText: "Capture Source",
78
+ lockSelectedText: "Lock Selected",
79
+ unlockSelectedText: "Unlock Selected",
80
+ lockSegmentAriaLabel: "Lock segment",
81
+ unlockSegmentAriaLabel: "Unlock segment",
82
+ realtimeOnText: "Realtime On",
83
+ realtimeOffText: "Realtime Off",
84
+ closeText: "Close",
85
+ summaryPrefix: "Locale QA",
86
+ noIssuesText: "No locale validation issues.",
87
+ issuesLabel: "Locale issues",
88
+ segmentsLabel: "Segments",
89
+ sourcePreviewLabel: "Source",
90
+ targetPreviewLabel: "Target",
91
+ helperText: "Select segments, lock finalized ones, and run locale validation before handoff.",
92
+ shortcutText: "Shortcuts: Ctrl/Cmd+Alt+Shift+L (panel), Ctrl/Cmd+Alt+Shift+V (validate), Ctrl/Cmd+Alt+Shift+K (lock segment)",
93
+ readonlySegmentMessage: "This segment is locked. Unlock before editing.",
94
+ sourceCapturedMessage: "Source snapshot captured from current content.",
95
+ selectedSegmentPrefix: "Selected Segment",
96
+ missingTargetMessage: "Segment is empty in target locale.",
97
+ tokenMismatchMessage: "Tokens/placeholders do not match source segment.",
98
+ untranslatedMessage: "Segment appears untranslated (same as source).",
99
+ lengthOutOfRangeMessage: "Translation length is outside expected locale range."
100
+ }, c = /* @__PURE__ */ new WeakMap(), re = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new WeakMap(), le = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new Set();
101
+ let X = 0, _e = 0, Ae = 0, Fe = 0, k = null, x = null, D = null, z = null, N = null, O = null, I = null, _ = null;
102
+ function m(e) {
103
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
104
+ }
105
+ function We(e) {
106
+ return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
107
+ }
108
+ function C(e, t, r) {
109
+ return Number.isFinite(e) ? Math.max(t, Math.min(r, e)) : t;
110
+ }
111
+ function A(e) {
112
+ return (e || "").trim() || "en-US";
113
+ }
114
+ function W(e) {
115
+ return e.trim().toLowerCase();
116
+ }
117
+ function Ke(e) {
118
+ return e.replace(/"/g, "&quot;");
119
+ }
120
+ function Ve(e, t = 120) {
121
+ return e.length <= t ? e : `${e.slice(0, Math.max(0, t - 1)).trimEnd()}…`;
122
+ }
123
+ function Re(e) {
124
+ const t = e.match(/\{\{[^{}]+\}\}|%[A-Z0-9_]+%|\$\{[^{}]+\}/gi);
125
+ return !t || t.length === 0 ? [] : t.map((r) => r.trim()).filter(Boolean);
126
+ }
127
+ function je(e, t) {
128
+ const r = Re(e).sort(), n = Re(t).sort();
129
+ if (r.length !== n.length) return !1;
130
+ for (let a = 0; a < r.length; a += 1)
131
+ if (r[a] !== n[a]) return !1;
132
+ return !0;
133
+ }
134
+ function Ue(e, t) {
135
+ const r = Array.isArray(t) && t.length > 0 ? t : Ee, n = [], a = /* @__PURE__ */ new Set();
136
+ return r.forEach((o) => {
137
+ const l = W(o.locale || "");
138
+ if (!l) return;
139
+ const s = l;
140
+ a.has(s) || (a.add(s), n.push({
141
+ locale: s,
142
+ label: (o.label || l).trim() || l,
143
+ minLengthRatio: C(Number(o.minLengthRatio ?? 0.5), 0.1, 3),
144
+ maxLengthRatio: C(Number(o.maxLengthRatio ?? 1.8), 0.2, 4),
145
+ requireDifferentFromSource: o.requireDifferentFromSource !== !1,
146
+ preserveTokens: o.preserveTokens !== !1
147
+ }));
148
+ }), e.forEach((o) => {
149
+ const l = W(o);
150
+ if (a.has(l)) return;
151
+ const s = Ee.find((i) => l.startsWith(i.locale));
152
+ n.push(
153
+ s ? { ...s, locale: l, label: o } : {
154
+ locale: l,
155
+ label: o,
156
+ minLengthRatio: 0.5,
157
+ maxLengthRatio: 1.8,
158
+ requireDifferentFromSource: !0,
159
+ preserveTokens: !0
160
+ }
161
+ );
162
+ }), n;
163
+ }
164
+ function oe(e = {}) {
165
+ const t = e.normalizeText || We, r = A(e.sourceLocale || "en-US"), n = A(e.targetLocale || "fr-FR"), a = /* @__PURE__ */ new Set([r, n]);
166
+ (Array.isArray(e.locales) ? e.locales : []).forEach((s) => {
167
+ if (typeof s != "string") return;
168
+ const i = A(s);
169
+ a.add(i);
170
+ });
171
+ const o = Array.from(a), l = Ue(o, e.localeRules);
172
+ return {
173
+ sourceLocale: r,
174
+ targetLocale: n,
175
+ locales: o,
176
+ localeRules: l,
177
+ enableRealtime: e.enableRealtime !== !1,
178
+ debounceMs: C(Number(e.debounceMs ?? 260), 60, 2e3),
179
+ maxIssues: C(Number(e.maxIssues ?? 120), 5, 1e3),
180
+ maxSegments: C(Number(e.maxSegments ?? 600), 20, 3e3),
181
+ minSourceLengthForRatio: C(Number(e.minSourceLengthForRatio ?? 8), 2, 100),
182
+ segmentSelector: (e.segmentSelector || $e).trim() || $e,
183
+ labels: {
184
+ ...Oe,
185
+ ...e.labels || {}
186
+ },
187
+ normalizeText: t
188
+ };
189
+ }
190
+ function Ge(e) {
191
+ return {
192
+ sourceLocale: e.sourceLocale,
193
+ targetLocale: e.targetLocale,
194
+ locales: [...e.locales],
195
+ localeRules: e.localeRules.map((t) => ({
196
+ locale: t.locale,
197
+ label: t.label,
198
+ minLengthRatio: t.minLengthRatio,
199
+ maxLengthRatio: t.maxLengthRatio,
200
+ requireDifferentFromSource: t.requireDifferentFromSource,
201
+ preserveTokens: t.preserveTokens
202
+ })),
203
+ enableRealtime: e.enableRealtime,
204
+ debounceMs: e.debounceMs,
205
+ maxIssues: e.maxIssues,
206
+ maxSegments: e.maxSegments,
207
+ minSourceLengthForRatio: e.minSourceLengthForRatio,
208
+ segmentSelector: e.segmentSelector,
209
+ labels: { ...e.labels },
210
+ normalizeText: e.normalizeText
211
+ };
212
+ }
213
+ function xe(e) {
214
+ return e.closest(ke) || e;
215
+ }
216
+ function K(e) {
217
+ if (!e) return null;
218
+ if (e.matches(S)) return e;
219
+ const t = e.querySelector(S);
220
+ return t instanceof HTMLElement ? t : null;
221
+ }
222
+ function Ye() {
223
+ if (typeof window > "u") return null;
224
+ const e = window[Te];
225
+ if (!(e instanceof HTMLElement)) return null;
226
+ window[Te] = null;
227
+ const t = K(e);
228
+ if (t) return t;
229
+ const r = e.closest(ke);
230
+ if (r) {
231
+ const a = K(r);
232
+ if (a) return a;
233
+ }
234
+ const n = e.closest(S);
235
+ return n instanceof HTMLElement ? n : null;
236
+ }
237
+ function Ze(e) {
238
+ const t = e.closest("[data-editora-editor]");
239
+ if (t && K(t) === e)
240
+ return t;
241
+ let r = e;
242
+ for (; r; ) {
243
+ if (r.matches(ke) && (r === e || K(r) === e))
244
+ return r;
245
+ r = r.parentElement;
246
+ }
247
+ return xe(e);
248
+ }
249
+ function Ce(e) {
250
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
251
+ }
252
+ function ee(e) {
253
+ 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;
254
+ }
255
+ function Je(e) {
256
+ const t = xe(e);
257
+ if (ee(t)) return !0;
258
+ const r = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
259
+ return ee(r) ? !0 : ee(document.documentElement) || ee(document.body);
260
+ }
261
+ function ge(e, t) {
262
+ e.classList.remove("rte-translation-workflow-theme-dark"), Je(t) && e.classList.add("rte-translation-workflow-theme-dark");
263
+ }
264
+ function Qe(e) {
265
+ for (let t = 0; t < e.length; t += 1) {
266
+ const r = e[t];
267
+ if (!(r.type !== "childList" || r.removedNodes.length === 0))
268
+ for (let n = 0; n < r.removedNodes.length; n += 1) {
269
+ const a = r.removedNodes[n];
270
+ if (a.nodeType !== Node.ELEMENT_NODE) continue;
271
+ const o = a;
272
+ if (o.matches?.(S) || o.matches?.(`.${u}`) || o.querySelector?.(S) || o.querySelector?.(`.${u}`))
273
+ return !0;
274
+ }
275
+ }
276
+ return !1;
277
+ }
278
+ function ae() {
279
+ Array.from(U).forEach((t) => {
280
+ t.isConnected || Se(t);
281
+ });
282
+ }
283
+ function T(e, t = !0, r = !0) {
284
+ if (ae(), e?.contentElement instanceof HTMLElement) return e.contentElement;
285
+ if (e?.editorElement instanceof HTMLElement) {
286
+ const s = K(e.editorElement);
287
+ if (s) return s;
288
+ }
289
+ const n = Ye();
290
+ if (n) return n;
291
+ const a = window.getSelection();
292
+ if (a && a.rangeCount > 0) {
293
+ const s = Ce(a.getRangeAt(0).startContainer)?.closest(
294
+ S
295
+ );
296
+ if (s) return s;
297
+ }
298
+ const o = document.activeElement;
299
+ if (o) {
300
+ if (o.matches(S)) return o;
301
+ const s = o.closest(S);
302
+ if (s) return s;
303
+ }
304
+ if (r && x && x.isConnected)
305
+ return x;
306
+ if (!t) return null;
307
+ const l = document.querySelector(S);
308
+ return l instanceof HTMLElement ? l : null;
309
+ }
310
+ function Xe(e) {
311
+ const t = e.target;
312
+ if (t) {
313
+ const n = t.closest(`.${u}`);
314
+ if (n) {
315
+ const o = Array.from(p.entries()).find(([, l]) => l === n);
316
+ if (o) return o[0];
317
+ }
318
+ const a = t.closest(S);
319
+ if (a) return a;
320
+ }
321
+ const r = document.activeElement;
322
+ if (r) {
323
+ const n = r.closest(`.${u}`);
324
+ if (n) {
325
+ const o = Array.from(p.entries()).find(([, l]) => l === n);
326
+ if (o) return o[0];
327
+ }
328
+ const a = r.closest(S);
329
+ if (a) return a;
330
+ }
331
+ return null;
332
+ }
333
+ function fe(e, t, r) {
334
+ const n = Ze(e);
335
+ Array.from(
336
+ n.querySelectorAll(
337
+ `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
338
+ )
339
+ ).forEach((o) => {
340
+ o.classList.toggle("active", r), o.setAttribute("data-active", r ? "true" : "false"), o.setAttribute("aria-pressed", r ? "true" : "false");
341
+ });
342
+ }
343
+ function we(e) {
344
+ const t = le.get(e);
345
+ typeof t == "number" && (window.clearTimeout(t), le.delete(e));
346
+ }
347
+ function et(e, t) {
348
+ const r = W(t), n = e.localeRules.find((l) => W(l.locale) === r);
349
+ if (n) return n;
350
+ const a = r.split("-")[0], o = e.localeRules.find((l) => W(l.locale).split("-")[0] === a);
351
+ return o || {
352
+ locale: r,
353
+ label: t,
354
+ minLengthRatio: 0.5,
355
+ maxLengthRatio: 1.8,
356
+ requireDifferentFromSource: !0,
357
+ preserveTokens: !0
358
+ };
359
+ }
360
+ function te(e, t, r, n = {}) {
361
+ return Ae += 1, {
362
+ id: `translation-workflow-issue-${Ae}`,
363
+ type: e,
364
+ severity: t,
365
+ message: r,
366
+ ...n
367
+ };
368
+ }
369
+ function ie(e, t) {
370
+ if (t) {
371
+ e.hasAttribute("data-translation-prev-contenteditable") || e.setAttribute(
372
+ "data-translation-prev-contenteditable",
373
+ e.hasAttribute("contenteditable") && e.getAttribute("contenteditable") || "inherit"
374
+ ), e.setAttribute("data-translation-locked", "true"), e.setAttribute("contenteditable", "false"), e.setAttribute("aria-readonly", "true"), e.classList.add("rte-translation-segment-locked");
375
+ return;
376
+ }
377
+ if (e.removeAttribute("data-translation-locked"), e.removeAttribute("aria-readonly"), e.classList.remove("rte-translation-segment-locked"), e.hasAttribute("data-translation-prev-contenteditable")) {
378
+ const r = e.getAttribute("data-translation-prev-contenteditable") || "";
379
+ r === "inherit" ? e.setAttribute("contenteditable", "true") : e.setAttribute("contenteditable", r), e.removeAttribute("data-translation-prev-contenteditable");
380
+ } else
381
+ e.setAttribute("contenteditable", "true");
382
+ }
383
+ function ce(e, t) {
384
+ return e.querySelector(`[data-translation-segment-id="${Ke(t)}"]`);
385
+ }
386
+ function He(e) {
387
+ const t = window.getSelection();
388
+ if (!t || t.rangeCount === 0) return null;
389
+ const r = Ce(t.getRangeAt(0).startContainer);
390
+ return !r || !e.contains(r) ? null : r.closest("[data-translation-segment-id]");
391
+ }
392
+ function tt(e, t) {
393
+ const r = Array.from(e.querySelectorAll(t));
394
+ if (r.length <= 1) return r;
395
+ const n = new Set(r);
396
+ return r.filter((a) => {
397
+ let o = a.parentElement;
398
+ for (; o && o !== e; ) {
399
+ if (n.has(o))
400
+ return !1;
401
+ o = o.parentElement;
402
+ }
403
+ return !0;
404
+ });
405
+ }
406
+ function nt(e, t, r) {
407
+ let n = (r || "").trim();
408
+ if (!n || t.has(n)) {
409
+ do
410
+ n = `translation-segment-${_e++}`;
411
+ while (t.has(n));
412
+ e.setAttribute("data-translation-segment-id", n);
413
+ }
414
+ return n;
415
+ }
416
+ function me(e, t) {
417
+ if (t.lockedSegmentIds.size === 0) return !1;
418
+ let r = !1;
419
+ return t.lockedSegmentIds.forEach((n) => {
420
+ const a = ce(e, n);
421
+ if (!a) return;
422
+ ie(a, !0);
423
+ const o = t.lockedHtmlBySegmentId.get(n);
424
+ if (typeof o == "string") {
425
+ a.innerHTML !== o && (a.innerHTML = o, r = !0);
426
+ return;
427
+ }
428
+ t.lockedHtmlBySegmentId.set(n, a.innerHTML);
429
+ }), r;
430
+ }
431
+ function M(e, t, r) {
432
+ const n = tt(e, t.segmentSelector), a = [], o = /* @__PURE__ */ new Set();
433
+ for (let l = 0; l < n.length && !(a.length >= t.maxSegments); l += 1) {
434
+ const s = n[l], i = nt(s, o, s.getAttribute("data-translation-segment-id")), d = r.lockedSegmentIds.has(i), g = s.getAttribute("data-translation-locked") === "true", w = d || g;
435
+ if (w)
436
+ if (r.lockedSegmentIds.add(i), ie(s, !0), !r.lockedHtmlBySegmentId.has(i))
437
+ r.lockedHtmlBySegmentId.set(i, s.innerHTML);
438
+ else {
439
+ const B = r.lockedHtmlBySegmentId.get(i) || "";
440
+ s.innerHTML !== B && (s.innerHTML = B);
441
+ }
442
+ else
443
+ r.lockedHtmlBySegmentId.delete(i);
444
+ const v = t.normalizeText(s.textContent || "");
445
+ if (!v) continue;
446
+ r.sourceTextBySegmentId.has(i) || r.sourceTextBySegmentId.set(i, v);
447
+ const G = r.sourceTextBySegmentId.get(i) || v;
448
+ a.push({
449
+ id: i,
450
+ tagName: s.tagName.toLowerCase(),
451
+ index: a.length,
452
+ text: v,
453
+ sourceText: G,
454
+ locked: w
455
+ }), o.add(i);
456
+ }
457
+ return Array.from(r.sourceTextBySegmentId.keys()).forEach((l) => {
458
+ o.has(l) || r.sourceTextBySegmentId.delete(l);
459
+ }), Array.from(r.lockedSegmentIds.keys()).forEach((l) => {
460
+ o.has(l) || r.lockedSegmentIds.delete(l);
461
+ }), Array.from(r.lockedHtmlBySegmentId.keys()).forEach((l) => {
462
+ (!o.has(l) || !r.lockedSegmentIds.has(l)) && r.lockedHtmlBySegmentId.delete(l);
463
+ }), (!r.selectedSegmentId || !a.some((l) => l.id === r.selectedSegmentId)) && (r.selectedSegmentId = a[0]?.id || null), a;
464
+ }
465
+ function b(e, t) {
466
+ c.has(e) || c.set(e, t);
467
+ let r = q.get(e);
468
+ return r || (r = {
469
+ sourceLocale: t.sourceLocale,
470
+ targetLocale: t.targetLocale,
471
+ selectedSegmentId: null,
472
+ realtimeEnabled: t.enableRealtime,
473
+ segments: [],
474
+ issues: [],
475
+ sourceTextBySegmentId: /* @__PURE__ */ new Map(),
476
+ lockedSegmentIds: /* @__PURE__ */ new Set(),
477
+ lockedHtmlBySegmentId: /* @__PURE__ */ new Map(),
478
+ snapshot: "",
479
+ lastRunAt: null
480
+ }, q.set(e, r)), U.add(e), r;
481
+ }
482
+ function Se(e) {
483
+ we(e);
484
+ const t = p.get(e);
485
+ t && t.remove(), p.delete(e), j.delete(e);
486
+ const r = q.get(e);
487
+ r && (r.lockedSegmentIds.forEach((n) => {
488
+ const a = ce(e, n);
489
+ a && ie(a, !1);
490
+ }), r.lockedHtmlBySegmentId.clear()), c.delete(e), re.delete(e), q.delete(e), U.delete(e), x === e && (x = null);
491
+ }
492
+ function ye(e) {
493
+ return j.get(e) === !0;
494
+ }
495
+ function be(e, t) {
496
+ if (!t.classList.contains("show")) return;
497
+ const r = xe(e).getBoundingClientRect(), n = Math.min(window.innerWidth - 20, 520), a = Math.max(10, window.innerWidth - n - 10), o = Math.min(Math.max(10, r.right - n), a), l = Math.max(10, Math.min(window.innerHeight - 10, r.top + 12));
498
+ t.style.width = `${n}px`, t.style.left = `${o}px`, t.style.top = `${l}px`, t.style.maxHeight = `${Math.max(260, window.innerHeight - 20)}px`;
499
+ }
500
+ function H(e, t) {
501
+ const r = e.querySelector(".rte-translation-live");
502
+ r && (r.textContent = t);
503
+ }
504
+ function rt(e, t) {
505
+ return `${e.innerHTML}::${t.sourceLocale}::${t.targetLocale}::${Array.from(t.lockedSegmentIds).sort().join("|")}`;
506
+ }
507
+ function ot(e, t, r) {
508
+ const n = [], a = et(r, t.targetLocale);
509
+ for (let o = 0; o < e.length && !(n.length >= r.maxIssues); o += 1) {
510
+ const l = e[o], s = r.normalizeText(l.sourceText || ""), i = r.normalizeText(l.text || "");
511
+ if (!i) {
512
+ n.push(
513
+ te("missing-target", "error", r.labels.missingTargetMessage, {
514
+ segmentId: l.id,
515
+ sourceText: s,
516
+ targetText: i,
517
+ suggestion: "Provide translated content for this segment before export."
518
+ })
519
+ );
520
+ continue;
521
+ }
522
+ if (a.preserveTokens && s && !je(s, i) && (n.push(
523
+ te("token-mismatch", "error", r.labels.tokenMismatchMessage, {
524
+ segmentId: l.id,
525
+ sourceText: s,
526
+ targetText: i,
527
+ suggestion: "Preserve placeholders/tokens exactly (for example {{name}}, %ID%, ${value})."
528
+ })
529
+ ), n.length >= r.maxIssues) || a.requireDifferentFromSource && s && r.normalizeText(s) === r.normalizeText(i) && (n.push(
530
+ te("untranslated", "warning", r.labels.untranslatedMessage, {
531
+ segmentId: l.id,
532
+ sourceText: s,
533
+ targetText: i,
534
+ suggestion: "Translate the segment or mark it intentionally unchanged."
535
+ })
536
+ ), n.length >= r.maxIssues))
537
+ break;
538
+ if (s.length >= r.minSourceLengthForRatio) {
539
+ const d = i.length / Math.max(1, s.length);
540
+ (d < a.minLengthRatio || d > a.maxLengthRatio) && n.push(
541
+ te("length-out-of-range", "warning", r.labels.lengthOutOfRangeMessage, {
542
+ segmentId: l.id,
543
+ sourceText: s,
544
+ targetText: i,
545
+ suggestion: `Expected ratio for ${a.label}: ${a.minLengthRatio.toFixed(2)} - ${a.maxLengthRatio.toFixed(2)}.`
546
+ })
547
+ );
548
+ }
549
+ }
550
+ return n;
551
+ }
552
+ function qe(e) {
553
+ const t = c.get(e) || k, r = q.get(e);
554
+ return {
555
+ sourceLocale: r?.sourceLocale || t?.sourceLocale || "en-US",
556
+ targetLocale: r?.targetLocale || t?.targetLocale || "fr-FR",
557
+ realtimeEnabled: r?.realtimeEnabled === !0,
558
+ selectedSegmentId: r?.selectedSegmentId || null,
559
+ segmentCount: r?.segments.length || 0,
560
+ lockedSegmentCount: r ? r.segments.filter((n) => n.locked).length : 0,
561
+ issues: r?.issues ? r.issues.map((n) => ({ ...n })) : [],
562
+ segments: r?.segments.map((n) => ({
563
+ id: n.id,
564
+ tagName: n.tagName,
565
+ index: n.index,
566
+ sourceLength: n.sourceText.length,
567
+ targetLength: n.text.length,
568
+ locked: n.locked
569
+ })) || [],
570
+ lastRunAt: r?.lastRunAt || null
571
+ };
572
+ }
573
+ function E(e) {
574
+ const t = q.get(e), r = t && t.selectedSegmentId ? t.segments.find((n) => n.id === t.selectedSegmentId) : null;
575
+ fe(e, "toggleTranslationWorkflowPanel", ye(e)), fe(e, "toggleTranslationRealtime", t?.realtimeEnabled === !0), fe(e, "toggleTranslationSegmentLock", r?.locked === !0);
576
+ }
577
+ function at(e, t) {
578
+ const r = ce(e, t);
579
+ if (!r) return;
580
+ try {
581
+ r.scrollIntoView({ block: "nearest", inline: "nearest" });
582
+ } catch {
583
+ }
584
+ const n = window.getSelection();
585
+ if (!(!n || typeof document.createRange != "function"))
586
+ try {
587
+ const a = document.createRange();
588
+ a.selectNodeContents(r), a.collapse(!0), n.removeAllRanges(), n.addRange(a), e.focus({ preventScroll: !0 });
589
+ } catch {
590
+ }
591
+ }
592
+ function R(e) {
593
+ const t = p.get(e);
594
+ if (!t) return;
595
+ const r = c.get(e) || k;
596
+ if (!r) return;
597
+ const n = b(e, r), a = t.querySelector(".rte-translation-source-label");
598
+ a && (a.textContent = r.labels.sourceLocaleLabel);
599
+ const o = t.querySelector(".rte-translation-target-label");
600
+ o && (o.textContent = r.labels.targetLocaleLabel);
601
+ const l = t.querySelector('[data-field="source-locale"]'), s = t.querySelector('[data-field="target-locale"]'), i = r.locales.map((f) => `<option value="${m(f)}">${m(f)}</option>`).join("");
602
+ l && (l.innerHTML = i, l.value = n.sourceLocale), s && (s.innerHTML = i, s.value = n.targetLocale);
603
+ const d = t.querySelector(".rte-translation-summary");
604
+ if (d) {
605
+ const f = n.issues.length, P = n.selectedSegmentId ? ` • ${r.labels.selectedSegmentPrefix}: ${n.selectedSegmentId}` : "";
606
+ d.textContent = `${r.labels.summaryPrefix}: ${n.sourceLocale} → ${n.targetLocale} • ${f} issue${f === 1 ? "" : "s"}${P}`;
607
+ }
608
+ const g = t.querySelector(".rte-translation-helper");
609
+ g && (g.textContent = r.labels.helperText);
610
+ const w = t.querySelector(".rte-translation-shortcut");
611
+ w && (w.textContent = r.labels.shortcutText);
612
+ const v = t.querySelector('[data-action="run-validation"]');
613
+ v && (v.textContent = r.labels.validateText);
614
+ const G = t.querySelector('[data-action="capture-source"]');
615
+ G && (G.textContent = r.labels.captureSourceText);
616
+ const B = t.querySelector('[data-action="toggle-realtime"]');
617
+ B && (B.textContent = n.realtimeEnabled ? r.labels.realtimeOnText : r.labels.realtimeOffText, B.setAttribute("aria-pressed", n.realtimeEnabled ? "true" : "false"));
618
+ const Y = t.querySelector('[data-action="lock-selected"]'), ue = n.selectedSegmentId && n.segments.find((f) => f.id === n.selectedSegmentId) || null;
619
+ Y && (Y.textContent = ue?.locked ? r.labels.unlockSelectedText : r.labels.lockSelectedText, Y.disabled = !ue, Y.setAttribute("aria-pressed", ue?.locked ? "true" : "false"));
620
+ const Le = t.querySelector('[data-action="close"]');
621
+ Le && Le.setAttribute("aria-label", r.labels.closeText);
622
+ const Z = t.querySelector(".rte-translation-issues"), F = t.querySelector(".rte-translation-empty");
623
+ Z && (Z.setAttribute("aria-label", r.labels.issuesLabel), n.issues.length === 0 ? (Z.innerHTML = "", F && (F.hidden = !1, F.textContent = r.labels.noIssuesText)) : (F && (F.hidden = !0), Z.innerHTML = n.issues.map((f) => `
624
+ <li class="rte-translation-issue ${f.severity === "error" ? "error" : f.severity === "warning" ? "warning" : "info"}" role="listitem" data-segment-id="${m(
625
+ f.segmentId || ""
626
+ )}">
627
+ <p class="rte-translation-issue-message">${m(f.message)}</p>
628
+ ${f.suggestion ? `<p class="rte-translation-issue-suggestion">${m(f.suggestion)}</p>` : ""}
629
+ </li>
630
+ `).join("")));
631
+ const de = t.querySelector(".rte-translation-segments");
632
+ de && (de.setAttribute("aria-label", r.labels.segmentsLabel), de.innerHTML = n.segments.map((f) => {
633
+ const P = f.id === n.selectedSegmentId ? "selected" : "", Ne = f.locked ? "locked" : "";
634
+ return `
635
+ <li class="rte-translation-segment-item ${P} ${Ne}" role="option" aria-selected="${f.id === n.selectedSegmentId ? "true" : "false"}" data-segment-id="${m(f.id)}">
636
+ <button type="button" class="rte-translation-segment-select" data-action="select-segment" data-segment-id="${m(
637
+ f.id
638
+ )}" title="${m(f.text)}">
639
+ <span class="rte-translation-segment-meta">#${f.index + 1} • ${m(f.tagName)}</span>
640
+ <span class="rte-translation-segment-text">${m(Ve(f.text, 110))}</span>
641
+ </button>
642
+ <button type="button" class="rte-translation-segment-lock" data-action="toggle-lock" data-segment-id="${m(
643
+ f.id
644
+ )}" aria-label="${f.locked ? r.labels.unlockSegmentAriaLabel : r.labels.lockSegmentAriaLabel}" aria-pressed="${f.locked ? "true" : "false"}"></button>
645
+ </li>
646
+ `;
647
+ }).join(""));
648
+ const J = t.querySelector(".rte-translation-source-preview"), Q = t.querySelector(".rte-translation-target-preview");
649
+ if (J || Q) {
650
+ const f = n.selectedSegmentId && n.segments.find((P) => P.id === n.selectedSegmentId) || null;
651
+ J && (J.textContent = f?.sourceText || "—", J.setAttribute("aria-label", r.labels.sourcePreviewLabel)), Q && (Q.textContent = f?.text || "—", Q.setAttribute("aria-label", r.labels.targetPreviewLabel));
652
+ }
653
+ t.setAttribute("aria-label", r.labels.panelAriaLabel);
654
+ }
655
+ function Be(e) {
656
+ const t = c.get(e) || k;
657
+ if (!t) return;
658
+ we(e);
659
+ const r = window.setTimeout(() => {
660
+ le.delete(e), L(e, "realtime", !1);
661
+ }, t.debounceMs);
662
+ le.set(e, r);
663
+ }
664
+ function L(e, t, r) {
665
+ const n = c.get(e) || k;
666
+ if (!n) return [];
667
+ const a = b(e, n), o = me(e, a);
668
+ a.segments = M(e, n, a);
669
+ const l = rt(e, a);
670
+ if (!r && a.snapshot === l)
671
+ return a.issues;
672
+ a.issues = ot(a.segments, a, n), a.lastRunAt = (/* @__PURE__ */ new Date()).toISOString(), a.snapshot = l, R(e), E(e), e.dispatchEvent(
673
+ new CustomEvent("editora:translation-workflow-validation", {
674
+ bubbles: !0,
675
+ detail: {
676
+ reason: t,
677
+ state: qe(e)
678
+ }
679
+ })
680
+ );
681
+ const s = p.get(e);
682
+ if (s) {
683
+ if (o)
684
+ return H(s, n.labels.readonlySegmentMessage), a.issues;
685
+ H(
686
+ s,
687
+ a.issues.length === 0 ? n.labels.noIssuesText : `${a.issues.length} issue${a.issues.length === 1 ? "" : "s"} detected.`
688
+ );
689
+ }
690
+ return a.issues;
691
+ }
692
+ function Pe(e) {
693
+ const t = c.get(e) || k;
694
+ if (!t) return !1;
695
+ const r = b(e, t), n = M(e, t, r);
696
+ n.forEach((o) => {
697
+ r.sourceTextBySegmentId.set(o.id, o.text);
698
+ }), r.snapshot = "", L(e, "capture-source", !0);
699
+ const a = p.get(e);
700
+ return a && H(a, t.labels.sourceCapturedMessage), e.dispatchEvent(
701
+ new CustomEvent("editora:translation-source-captured", {
702
+ bubbles: !0,
703
+ detail: {
704
+ sourceLocale: r.sourceLocale,
705
+ segmentCount: n.length
706
+ }
707
+ })
708
+ ), !0;
709
+ }
710
+ function se(e, t, r) {
711
+ const n = c.get(e) || k;
712
+ if (!n) return !1;
713
+ const a = b(e, n);
714
+ a.segments = M(e, n, a);
715
+ const o = He(e)?.getAttribute("data-translation-segment-id") || null, l = t || o || a.selectedSegmentId || a.segments[0]?.id || null;
716
+ if (!l) return !1;
717
+ const s = ce(e, l);
718
+ if (!s) return !1;
719
+ const i = typeof r == "boolean" ? r : !a.lockedSegmentIds.has(l);
720
+ return i ? (a.lockedSegmentIds.add(l), a.lockedHtmlBySegmentId.set(l, s.innerHTML)) : (a.lockedSegmentIds.delete(l), a.lockedHtmlBySegmentId.delete(l)), ie(s, i), a.selectedSegmentId = l, a.snapshot = "", L(e, "lock-segment", !0), e.dispatchEvent(
721
+ new CustomEvent("editora:translation-segment-lock", {
722
+ bubbles: !0,
723
+ detail: {
724
+ segmentId: l,
725
+ locked: i
726
+ }
727
+ })
728
+ ), !0;
729
+ }
730
+ function De(e, t) {
731
+ const r = c.get(e) || k;
732
+ if (!r) return !1;
733
+ const n = b(e, r), a = typeof t == "boolean" ? t : !n.realtimeEnabled;
734
+ return n.realtimeEnabled = a, a ? Be(e) : we(e), R(e), E(e), !0;
735
+ }
736
+ function pe(e, t, r = !0) {
737
+ const n = c.get(e) || k;
738
+ if (!n) return !1;
739
+ const a = b(e, n);
740
+ return a.segments = M(e, n, a), a.segments.some((o) => o.id === t) ? (a.selectedSegmentId = t, R(e), E(e), r && at(e, t), !0) : !1;
741
+ }
742
+ function ne(e, t) {
743
+ const r = c.get(e) || k;
744
+ if (!r) return !1;
745
+ const n = b(e, r);
746
+ if (n.segments = M(e, r, n), n.segments.length === 0) return !1;
747
+ const a = Math.max(
748
+ 0,
749
+ n.segments.findIndex((s) => s.id === n.selectedSegmentId)
750
+ );
751
+ let o = a;
752
+ t === "start" ? o = 0 : t === "end" ? o = n.segments.length - 1 : o = C(a + t, 0, n.segments.length - 1);
753
+ const l = n.segments[o];
754
+ return l ? pe(e, l.id, !0) : !1;
755
+ }
756
+ function V(e, t = !1) {
757
+ const r = p.get(e);
758
+ r && (r.classList.remove("show"), j.set(e, !1), E(e), t && e.focus({ preventScroll: !0 }));
759
+ }
760
+ function he(e) {
761
+ const t = ut(e);
762
+ p.forEach((n, a) => {
763
+ a !== e && V(a, !1);
764
+ }), t.classList.add("show"), j.set(e, !0), L(e, "panel-open", !1), R(e), be(e, t), E(e), t.querySelector('[data-field="target-locale"]')?.focus();
765
+ }
766
+ function ze(e, t) {
767
+ const r = ye(e);
768
+ return (typeof t == "boolean" ? t : !r) ? he(e) : V(e, !1), !0;
769
+ }
770
+ function lt(e) {
771
+ const t = e.key.toLowerCase();
772
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "l";
773
+ }
774
+ function st(e) {
775
+ const t = e.key.toLowerCase();
776
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "v";
777
+ }
778
+ function it(e) {
779
+ const t = e.key.toLowerCase();
780
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "k";
781
+ }
782
+ function ct(e) {
783
+ return e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey ? !0 : e.key === "Backspace" || e.key === "Delete" || e.key === "Enter";
784
+ }
785
+ function Ie(e) {
786
+ return e instanceof HTMLElement ? e.closest('[data-translation-locked="true"]') : null;
787
+ }
788
+ function ut(e) {
789
+ const t = p.get(e);
790
+ if (t) return t;
791
+ const r = c.get(e) || k || oe();
792
+ b(e, r);
793
+ const n = `rte-translation-workflow-panel-${Fe++}`, a = `${n}-source`, o = `${n}-target`, l = document.createElement("section");
794
+ return l.className = u, l.id = n, l.setAttribute("role", "dialog"), l.setAttribute("aria-modal", "false"), l.setAttribute("aria-label", r.labels.panelAriaLabel), l.innerHTML = `
795
+ <header class="rte-translation-header">
796
+ <h2 class="rte-translation-title">${m(r.labels.panelTitle)}</h2>
797
+ <button type="button" class="rte-translation-icon-btn" data-action="close" aria-label="${m(
798
+ r.labels.closeText
799
+ )}">✕</button>
800
+ </header>
801
+ <div class="rte-translation-body">
802
+ <div class="rte-translation-locales">
803
+ <div class="rte-translation-locale-field">
804
+ <label class="rte-translation-source-label" for="${m(a)}"></label>
805
+ <select id="${m(a)}" class="rte-translation-select" data-field="source-locale"></select>
806
+ </div>
807
+ <div class="rte-translation-locale-field">
808
+ <label class="rte-translation-target-label" for="${m(o)}"></label>
809
+ <select id="${m(o)}" class="rte-translation-select" data-field="target-locale"></select>
810
+ </div>
811
+ </div>
812
+ <p class="rte-translation-summary"></p>
813
+ <div class="rte-translation-actions">
814
+ <button type="button" class="rte-translation-btn rte-translation-btn-primary" data-action="run-validation"></button>
815
+ <button type="button" class="rte-translation-btn" data-action="capture-source"></button>
816
+ <button type="button" class="rte-translation-btn" data-action="lock-selected"></button>
817
+ <button type="button" class="rte-translation-btn" data-action="toggle-realtime" aria-pressed="false"></button>
818
+ </div>
819
+ <p class="rte-translation-helper"></p>
820
+ <p class="rte-translation-shortcut"></p>
821
+ <div class="rte-translation-grid">
822
+ <section class="rte-translation-segments-wrap" aria-label="${m(r.labels.segmentsLabel)}">
823
+ <h3 class="rte-translation-subtitle">${m(r.labels.segmentsLabel)}</h3>
824
+ <ul class="rte-translation-segments" role="listbox" tabindex="0" aria-label="${m(
825
+ r.labels.segmentsLabel
826
+ )}"></ul>
827
+ </section>
828
+ <section class="rte-translation-preview-wrap">
829
+ <h3 class="rte-translation-subtitle">${m(r.labels.sourcePreviewLabel)} / ${m(
830
+ r.labels.targetPreviewLabel
831
+ )}</h3>
832
+ <div class="rte-translation-preview-block">
833
+ <p class="rte-translation-preview-label">${m(r.labels.sourcePreviewLabel)}</p>
834
+ <p class="rte-translation-source-preview"></p>
835
+ </div>
836
+ <div class="rte-translation-preview-block">
837
+ <p class="rte-translation-preview-label">${m(r.labels.targetPreviewLabel)}</p>
838
+ <p class="rte-translation-target-preview"></p>
839
+ </div>
840
+ </section>
841
+ </div>
842
+ <section class="rte-translation-issues-wrap">
843
+ <h3 class="rte-translation-subtitle">${m(r.labels.issuesLabel)}</h3>
844
+ <ul class="rte-translation-issues" role="list" aria-label="${m(r.labels.issuesLabel)}"></ul>
845
+ <p class="rte-translation-empty" hidden></p>
846
+ </section>
847
+ </div>
848
+ <div class="rte-translation-live" aria-live="polite" aria-atomic="true"></div>
849
+ `, l.addEventListener("click", (s) => {
850
+ const i = s.target;
851
+ if (!i) return;
852
+ const d = i.closest("[data-action]");
853
+ if (!d) {
854
+ const v = i.closest(".rte-translation-issue[data-segment-id]")?.getAttribute("data-segment-id") || "";
855
+ v && pe(e, v, !0);
856
+ return;
857
+ }
858
+ const g = d.getAttribute("data-action");
859
+ if (g === "close") {
860
+ V(e, !0);
861
+ return;
862
+ }
863
+ if (g === "run-validation") {
864
+ L(e, "panel-button", !0);
865
+ return;
866
+ }
867
+ if (g === "capture-source") {
868
+ Pe(e);
869
+ return;
870
+ }
871
+ if (g === "lock-selected") {
872
+ se(e);
873
+ return;
874
+ }
875
+ if (g === "toggle-realtime") {
876
+ De(e);
877
+ return;
878
+ }
879
+ if (g === "select-segment") {
880
+ const w = d.getAttribute("data-segment-id") || "";
881
+ w && pe(e, w, !0);
882
+ return;
883
+ }
884
+ if (g === "toggle-lock") {
885
+ const w = d.getAttribute("data-segment-id") || "";
886
+ w && se(e, w);
887
+ }
888
+ }), l.addEventListener("change", (s) => {
889
+ const i = s.target;
890
+ if (!(i instanceof HTMLSelectElement)) return;
891
+ const d = c.get(e) || k;
892
+ if (!d) return;
893
+ const g = b(e, d);
894
+ if (i.getAttribute("data-field") === "source-locale") {
895
+ g.sourceLocale = A(i.value), g.snapshot = "", L(e, "source-locale-change", !0);
896
+ return;
897
+ }
898
+ i.getAttribute("data-field") === "target-locale" && (g.targetLocale = A(i.value), g.snapshot = "", L(e, "target-locale-change", !0));
899
+ }), l.addEventListener("keydown", (s) => {
900
+ const i = s.target;
901
+ if (s.key === "Escape") {
902
+ s.preventDefault(), V(e, !0);
903
+ return;
904
+ }
905
+ !i?.closest(".rte-translation-segments") || !Me.has(s.key) || (s.preventDefault(), s.key === "ArrowUp" ? ne(e, -1) : s.key === "ArrowDown" ? ne(e, 1) : s.key === "Home" ? ne(e, "start") : s.key === "End" && ne(e, "end"));
906
+ }), ge(l, e), document.body.appendChild(l), p.set(e, l), j.set(e, !1), R(e), l;
907
+ }
908
+ function dt(e) {
909
+ k = e, D || (D = (t) => {
910
+ ae();
911
+ const n = t.target?.closest(S);
912
+ if (!n) return;
913
+ const a = c.get(n) || e, o = b(n, a);
914
+ c.set(n, a), x = n;
915
+ const l = He(n)?.getAttribute("data-translation-segment-id") || null;
916
+ l && (o.selectedSegmentId = l), E(n);
917
+ const s = p.get(n);
918
+ s && (ge(s, n), be(n, s), R(n));
919
+ }, document.addEventListener("focusin", D, !0)), z || (z = (t) => {
920
+ const n = t.target?.closest(S);
921
+ if (!n) return;
922
+ const a = c.get(n) || k;
923
+ if (!a) return;
924
+ const o = b(n, a), l = me(n, o);
925
+ if (o.segments = M(n, a, o), !o.realtimeEnabled) {
926
+ if (l) {
927
+ const s = p.get(n);
928
+ s && H(s, a.labels.readonlySegmentMessage);
929
+ }
930
+ R(n), E(n);
931
+ return;
932
+ }
933
+ Be(n);
934
+ }, document.addEventListener("input", z, !0)), N || (N = (t) => {
935
+ const r = t, n = r.target, a = n?.closest(S);
936
+ if (!a) return;
937
+ const o = Ie(n);
938
+ if (!o || !a.contains(o)) return;
939
+ r.preventDefault();
940
+ const l = p.get(a), s = c.get(a) || k;
941
+ l && s && H(l, s.labels.readonlySegmentMessage);
942
+ }, document.addEventListener("beforeinput", N, !0)), O || (O = (t) => {
943
+ if (t.defaultPrevented) return;
944
+ const r = t.target;
945
+ if (r?.closest(`.${u}`) && t.key !== "Escape" && !Me.has(t.key)) return;
946
+ const a = t.key === "Escape", o = lt(t), l = st(t), s = it(t), i = Ie(r);
947
+ if (!a && !o && !l && !s && !i)
948
+ return;
949
+ const d = Xe(t);
950
+ if (!d) return;
951
+ const g = c.get(d) || k || e;
952
+ if (b(d, g), c.set(d, g), x = d, a && ye(d)) {
953
+ t.preventDefault(), V(d, !0);
954
+ return;
955
+ }
956
+ if (i && d.contains(i) && ct(t)) {
957
+ t.preventDefault();
958
+ const w = p.get(d);
959
+ w && H(w, g.labels.readonlySegmentMessage);
960
+ return;
961
+ }
962
+ if (o) {
963
+ t.preventDefault(), t.stopPropagation(), ze(d);
964
+ return;
965
+ }
966
+ if (l) {
967
+ t.preventDefault(), t.stopPropagation(), L(d, "shortcut", !0);
968
+ return;
969
+ }
970
+ s && (t.preventDefault(), t.stopPropagation(), se(d));
971
+ }, document.addEventListener("keydown", O, !0)), I || (I = () => {
972
+ ae(), p.forEach((t, r) => {
973
+ !r.isConnected || !t.isConnected || (ge(t, r), be(r, t));
974
+ });
975
+ }, window.addEventListener("scroll", I, !0), window.addEventListener("resize", I)), !_ && typeof MutationObserver < "u" && document.body && (_ = new MutationObserver((t) => {
976
+ Qe(t) && ae(), t.some((n) => n.type === "characterData" ? !0 : n.type === "childList" && (n.addedNodes.length > 0 || n.removedNodes.length > 0)) && U.forEach((n) => {
977
+ const a = q.get(n);
978
+ if (!a || a.lockedSegmentIds.size === 0 || !me(n, a)) return;
979
+ a.snapshot = "";
980
+ const l = c.get(n) || k, s = p.get(n);
981
+ s && l && H(s, l.labels.readonlySegmentMessage), l && (a.segments = M(n, l, a), R(n), E(n));
982
+ });
983
+ }), _.observe(document.body, {
984
+ childList: !0,
985
+ subtree: !0,
986
+ characterData: !0
987
+ }));
988
+ }
989
+ function ft() {
990
+ D && (document.removeEventListener("focusin", D, !0), D = null), z && (document.removeEventListener("input", z, !0), z = null), N && (document.removeEventListener("beforeinput", N, !0), N = null), O && (document.removeEventListener("keydown", O, !0), O = null), I && (window.removeEventListener("scroll", I, !0), window.removeEventListener("resize", I), I = null), _ && (_.disconnect(), _ = null), p.forEach((t) => t.remove()), p.clear(), Array.from(U).forEach((t) => Se(t)), k = null, x = null;
991
+ }
992
+ function gt() {
993
+ if (typeof document > "u" || document.getElementById(ve)) return;
994
+ const e = document.createElement("style");
995
+ e.id = ve, e.textContent = `
996
+ .rte-toolbar-group-items.${y},
997
+ .editora-toolbar-group-items.${y},
998
+ .rte-toolbar-group-items.${$},
999
+ .editora-toolbar-group-items.${$} {
1000
+ display: flex;
1001
+ border: 1px solid #cbd5e1;
1002
+ border-radius: 4px;
1003
+ background: #ffffff;
1004
+ }
1005
+
1006
+ .rte-toolbar-group-items.${y} .rte-toolbar-button,
1007
+ .editora-toolbar-group-items.${y} .editora-toolbar-button,
1008
+ .rte-toolbar-group-items.${$} .rte-toolbar-button,
1009
+ .editora-toolbar-group-items.${$} .editora-toolbar-button {
1010
+ border: none;
1011
+ border-right: 1px solid #cbd5e1;
1012
+ border-radius: 0;
1013
+ }
1014
+
1015
+ .rte-toolbar-group-items.${y} .rte-toolbar-item:last-child .rte-toolbar-button,
1016
+ .editora-toolbar-group-items.${y} .editora-toolbar-item:last-child .editora-toolbar-button,
1017
+ .rte-toolbar-group-items.${$} .rte-toolbar-item:last-child .rte-toolbar-button,
1018
+ .editora-toolbar-group-items.${$} .editora-toolbar-item:last-child .editora-toolbar-button {
1019
+ border-right: none;
1020
+ }
1021
+
1022
+ ${h} .rte-toolbar-group-items.${y},
1023
+ ${h} .editora-toolbar-group-items.${y},
1024
+ ${h} .rte-toolbar-group-items.${$},
1025
+ ${h} .editora-toolbar-group-items.${$} {
1026
+ border-color: #566275;
1027
+ }
1028
+ .rte-toolbar-button[data-command="toggleTranslationWorkflowPanel"].active,
1029
+ .editora-toolbar-button[data-command="toggleTranslationWorkflowPanel"].active,
1030
+ .rte-toolbar-button[data-command="toggleTranslationSegmentLock"].active,
1031
+ .editora-toolbar-button[data-command="toggleTranslationSegmentLock"].active,
1032
+ .rte-toolbar-button[data-command="toggleTranslationRealtime"].active,
1033
+ .editora-toolbar-button[data-command="toggleTranslationRealtime"].active {
1034
+ background: #ccc;
1035
+ }
1036
+ ${h} .rte-toolbar-group-items.${y} .rte-toolbar-button svg,
1037
+ ${h} .editora-toolbar-group-items.${y} .editora-toolbar-button svg,
1038
+ ${h} .rte-toolbar-group-items.${$} .rte-toolbar-button svg,
1039
+ ${h} .editora-toolbar-group-items.${$} .editora-toolbar-button svg
1040
+ {
1041
+ fill: none;
1042
+ }
1043
+ ${h} .rte-toolbar-group-items.${y} .rte-toolbar-button,
1044
+ ${h} .editora-toolbar-group-items.${y} .editora-toolbar-button
1045
+ {
1046
+ border-color: #566275;
1047
+ }
1048
+
1049
+ ${h} .rte-toolbar-button[data-command="toggleTranslationWorkflowPanel"].active,
1050
+ ${h} .editora-toolbar-button[data-command="toggleTranslationWorkflowPanel"].active,
1051
+ ${h} .rte-toolbar-button[data-command="toggleTranslationSegmentLock"].active,
1052
+ ${h} .editora-toolbar-button[data-command="toggleTranslationSegmentLock"].active,
1053
+ ${h} .rte-toolbar-button[data-command="toggleTranslationRealtime"].active,
1054
+ ${h} .editora-toolbar-button[data-command="toggleTranslationRealtime"].active {
1055
+ background: linear-gradient(180deg, #5eaaf6 0%, #4a95de 100%);
1056
+ }
1057
+
1058
+ .${u} {
1059
+ position: fixed;
1060
+ z-index: 12000;
1061
+ display: none;
1062
+ width: min(520px, calc(100vw - 20px));
1063
+ max-height: calc(100vh - 20px);
1064
+ border: 1px solid #d1d5db;
1065
+ border-radius: 14px;
1066
+ background: #ffffff;
1067
+ color: #0f172a;
1068
+ box-shadow: 0 24px 48px rgba(15, 23, 42, 0.24);
1069
+ overflow: hidden;
1070
+ }
1071
+
1072
+ .${u}.show {
1073
+ display: flex;
1074
+ flex-direction: column;
1075
+ }
1076
+
1077
+ .${u}.rte-translation-workflow-theme-dark {
1078
+ border-color: #334155;
1079
+ background: #0f172a;
1080
+ color: #e2e8f0;
1081
+ box-shadow: 0 24px 52px rgba(2, 6, 23, 0.68);
1082
+ }
1083
+
1084
+ .rte-translation-header {
1085
+ display: flex;
1086
+ align-items: center;
1087
+ justify-content: space-between;
1088
+ gap: 8px;
1089
+ padding: 12px 14px;
1090
+ border-bottom: 1px solid #e2e8f0;
1091
+ background: linear-gradient(180deg, #eff6ff 0%, #e2e8f0 100%);
1092
+ }
1093
+
1094
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-header {
1095
+ border-color: #1e293b;
1096
+ background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
1097
+ }
1098
+
1099
+ .rte-translation-title {
1100
+ margin: 0;
1101
+ font-size: 15px;
1102
+ line-height: 1.2;
1103
+ font-weight: 700;
1104
+ }
1105
+
1106
+ .rte-translation-icon-btn {
1107
+ border: 1px solid #cbd5e1;
1108
+ border-radius: 6px;
1109
+ min-height: 34px;
1110
+ width: 34px;
1111
+ background: #ffffff;
1112
+ color: #0f172a;
1113
+ font-size: 16px;
1114
+ line-height: 1;
1115
+ font-weight: 600;
1116
+ padding: 0;
1117
+ display: inline-flex;
1118
+ align-items: center;
1119
+ justify-content: center;
1120
+ cursor: pointer;
1121
+ }
1122
+
1123
+ .rte-translation-icon-btn:hover,
1124
+ .rte-translation-icon-btn:focus-visible {
1125
+ outline: none;
1126
+ border-color: #3b82f6;
1127
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
1128
+ }
1129
+
1130
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-icon-btn {
1131
+ border-color: #475569;
1132
+ background: #0f172a;
1133
+ color: #e2e8f0;
1134
+ }
1135
+
1136
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-icon-btn:hover,
1137
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-icon-btn:focus-visible {
1138
+ border-color: #60a5fa;
1139
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
1140
+ }
1141
+
1142
+ .rte-translation-body {
1143
+ display: flex;
1144
+ flex-direction: column;
1145
+ gap: 8px;
1146
+ padding: 12px;
1147
+ overflow: auto;
1148
+ }
1149
+
1150
+ .rte-translation-locales {
1151
+ display: grid;
1152
+ grid-template-columns: repeat(2, minmax(0, 1fr));
1153
+ gap: 8px;
1154
+ }
1155
+
1156
+ .rte-translation-locale-field {
1157
+ display: grid;
1158
+ gap: 4px;
1159
+ }
1160
+
1161
+ .rte-translation-source-label,
1162
+ .rte-translation-target-label {
1163
+ font-size: 12px;
1164
+ font-weight: 700;
1165
+ color: #334155;
1166
+ }
1167
+
1168
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-source-label,
1169
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-target-label {
1170
+ color: #cbd5e1;
1171
+ }
1172
+
1173
+ .rte-translation-select {
1174
+ border: 1px solid #cbd5e1;
1175
+ border-radius: 8px;
1176
+ min-height: 34px;
1177
+ padding: 0 10px;
1178
+ font-size: 13px;
1179
+ background: #ffffff;
1180
+ color: inherit;
1181
+ }
1182
+
1183
+ .rte-translation-select:focus-visible {
1184
+ border-color: #0e7490;
1185
+ box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.18);
1186
+ outline: none;
1187
+ }
1188
+
1189
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-select {
1190
+ border-color: #334155;
1191
+ background: #0b1220;
1192
+ color: #e2e8f0;
1193
+ }
1194
+
1195
+ .rte-translation-summary,
1196
+ .rte-translation-helper,
1197
+ .rte-translation-shortcut {
1198
+ margin: 0;
1199
+ font-size: 12px;
1200
+ line-height: 1.35;
1201
+ color: #475569;
1202
+ }
1203
+
1204
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-summary,
1205
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-helper,
1206
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-shortcut {
1207
+ color: #94a3b8;
1208
+ }
1209
+
1210
+ .rte-translation-actions {
1211
+ display: grid;
1212
+ grid-template-columns: repeat(4, minmax(0, 1fr));
1213
+ gap: 8px;
1214
+ }
1215
+
1216
+ .rte-translation-btn {
1217
+ border: 1px solid #cbd5e1;
1218
+ border-radius: 8px;
1219
+ min-height: 34px;
1220
+ padding: 0 8px;
1221
+ background: #ffffff;
1222
+ color: inherit;
1223
+ font-size: 12px;
1224
+ font-weight: 700;
1225
+ cursor: pointer;
1226
+ }
1227
+
1228
+ .rte-translation-btn:disabled {
1229
+ opacity: 0.6;
1230
+ cursor: not-allowed;
1231
+ }
1232
+
1233
+ .rte-translation-btn-primary {
1234
+ border-color: #0e7490;
1235
+ background: #0e7490;
1236
+ color: #f8fafc;
1237
+ }
1238
+
1239
+ .rte-translation-btn:hover,
1240
+ .rte-translation-btn:focus-visible {
1241
+ border-color: #94a3b8;
1242
+ outline: none;
1243
+ }
1244
+
1245
+ .rte-translation-btn-primary:hover,
1246
+ .rte-translation-btn-primary:focus-visible {
1247
+ border-color: #155e75;
1248
+ background: #155e75;
1249
+ }
1250
+
1251
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-btn {
1252
+ border-color: #334155;
1253
+ background: #111827;
1254
+ color: #e2e8f0;
1255
+ }
1256
+
1257
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-btn-primary {
1258
+ border-color: #22d3ee;
1259
+ background: #0e7490;
1260
+ color: #ecfeff;
1261
+ }
1262
+
1263
+ .rte-translation-grid {
1264
+ display: grid;
1265
+ grid-template-columns: 1fr 1fr;
1266
+ gap: 8px;
1267
+ }
1268
+
1269
+ .rte-translation-segments-wrap,
1270
+ .rte-translation-preview-wrap,
1271
+ .rte-translation-issues-wrap {
1272
+ border: 1px solid #e2e8f0;
1273
+ border-radius: 10px;
1274
+ background: #f8fafc;
1275
+ padding: 8px;
1276
+ min-height: 120px;
1277
+ }
1278
+
1279
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-segments-wrap,
1280
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-preview-wrap,
1281
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-issues-wrap {
1282
+ border-color: #334155;
1283
+ background: #0b1220;
1284
+ }
1285
+
1286
+ .rte-translation-subtitle {
1287
+ margin: 0 0 6px;
1288
+ font-size: 12px;
1289
+ font-weight: 700;
1290
+ color: #334155;
1291
+ }
1292
+
1293
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-subtitle {
1294
+ color: #cbd5e1;
1295
+ }
1296
+
1297
+ .rte-translation-segments {
1298
+ margin: 0;
1299
+ padding: 0;
1300
+ list-style: none;
1301
+ display: grid;
1302
+ gap: 6px;
1303
+ max-height: 220px;
1304
+ overflow: auto;
1305
+ outline: none;
1306
+ }
1307
+
1308
+ .rte-translation-segment-item {
1309
+ display: grid;
1310
+ grid-template-columns: 1fr auto;
1311
+ gap: 6px;
1312
+ border: 1px solid #cbd5e1;
1313
+ border-radius: 8px;
1314
+ background: #ffffff;
1315
+ padding: 6px;
1316
+ }
1317
+
1318
+ .rte-translation-segment-item.selected {
1319
+ border-color: #0e7490;
1320
+ box-shadow: 0 0 0 2px rgba(14, 116, 144, 0.16);
1321
+ }
1322
+
1323
+ .rte-translation-segment-item.locked {
1324
+ border-color: #f59e0b;
1325
+ background: #fffbeb;
1326
+ }
1327
+
1328
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-segment-item {
1329
+ border-color: #334155;
1330
+ background: #111827;
1331
+ }
1332
+
1333
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-segment-item.locked {
1334
+ border-color: rgba(245, 158, 11, 0.72);
1335
+ background: rgba(120, 53, 15, 0.28);
1336
+ }
1337
+
1338
+ .rte-translation-segment-select {
1339
+ border: none;
1340
+ background: transparent;
1341
+ color: inherit;
1342
+ text-align: left;
1343
+ padding: 0;
1344
+ cursor: pointer;
1345
+ display: grid;
1346
+ gap: 2px;
1347
+ }
1348
+
1349
+ .rte-translation-segment-meta {
1350
+ font-size: 11px;
1351
+ color: #64748b;
1352
+ font-weight: 700;
1353
+ }
1354
+
1355
+ .rte-translation-segment-text {
1356
+ font-size: 12px;
1357
+ color: #334155;
1358
+ line-height: 1.3;
1359
+ }
1360
+
1361
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-segment-meta {
1362
+ color: #94a3b8;
1363
+ }
1364
+
1365
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-segment-text {
1366
+ color: #e2e8f0;
1367
+ }
1368
+
1369
+ .rte-translation-segment-lock {
1370
+ border: 1px solid #cbd5e1;
1371
+ border-radius: 8px;
1372
+ width: 28px;
1373
+ min-height: 28px;
1374
+ background: #ffffff;
1375
+ cursor: pointer;
1376
+ position: relative;
1377
+ color: inherit;
1378
+ font-size: 0;
1379
+ }
1380
+
1381
+ .rte-translation-segment-lock::before {
1382
+ content: '🔒';
1383
+ font-size: 14px;
1384
+ position: absolute;
1385
+ inset: 0;
1386
+ display: grid;
1387
+ place-items: center;
1388
+ opacity: 0.35;
1389
+ }
1390
+
1391
+ .rte-translation-segment-lock[aria-pressed="true"]::before {
1392
+ opacity: 1;
1393
+ }
1394
+
1395
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-segment-lock {
1396
+ border-color: #334155;
1397
+ background: #111827;
1398
+ }
1399
+
1400
+ .rte-translation-preview-block {
1401
+ display: grid;
1402
+ gap: 4px;
1403
+ margin-bottom: 8px;
1404
+ }
1405
+
1406
+ .rte-translation-preview-label {
1407
+ margin: 0;
1408
+ font-size: 11px;
1409
+ color: #64748b;
1410
+ font-weight: 700;
1411
+ }
1412
+
1413
+ .rte-translation-source-preview,
1414
+ .rte-translation-target-preview {
1415
+ margin: 0;
1416
+ border: 1px solid #cbd5e1;
1417
+ border-radius: 8px;
1418
+ background: #ffffff;
1419
+ padding: 8px;
1420
+ font-size: 12px;
1421
+ min-height: 56px;
1422
+ white-space: pre-wrap;
1423
+ line-height: 1.35;
1424
+ color: #1f2937;
1425
+ }
1426
+
1427
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-preview-label {
1428
+ color: #94a3b8;
1429
+ }
1430
+
1431
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-source-preview,
1432
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-target-preview {
1433
+ border-color: #334155;
1434
+ background: #111827;
1435
+ color: #e2e8f0;
1436
+ }
1437
+
1438
+ .rte-translation-issues {
1439
+ margin: 0;
1440
+ padding: 0;
1441
+ list-style: none;
1442
+ display: grid;
1443
+ gap: 6px;
1444
+ max-height: 200px;
1445
+ overflow: auto;
1446
+ }
1447
+
1448
+ .rte-translation-issue {
1449
+ border: 1px solid #cbd5e1;
1450
+ border-radius: 8px;
1451
+ background: #ffffff;
1452
+ padding: 8px;
1453
+ display: grid;
1454
+ gap: 4px;
1455
+ cursor: pointer;
1456
+ }
1457
+
1458
+ .rte-translation-issue.error {
1459
+ border-color: #ef4444;
1460
+ background: #fef2f2;
1461
+ }
1462
+
1463
+ .rte-translation-issue.warning {
1464
+ border-color: #f59e0b;
1465
+ background: #fffbeb;
1466
+ }
1467
+
1468
+ .rte-translation-issue.info {
1469
+ border-color: #0ea5e9;
1470
+ background: #f0f9ff;
1471
+ }
1472
+
1473
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-issue {
1474
+ border-color: #334155;
1475
+ background: #111827;
1476
+ color: #e2e8f0;
1477
+ }
1478
+
1479
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-issue.error {
1480
+ border-color: rgba(239, 68, 68, 0.7);
1481
+ background: rgba(127, 29, 29, 0.28);
1482
+ }
1483
+
1484
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-issue.warning {
1485
+ border-color: rgba(245, 158, 11, 0.72);
1486
+ background: rgba(120, 53, 15, 0.28);
1487
+ }
1488
+
1489
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-issue.info {
1490
+ border-color: rgba(14, 165, 233, 0.7);
1491
+ background: rgba(7, 89, 133, 0.28);
1492
+ }
1493
+
1494
+ .rte-translation-issue-message,
1495
+ .rte-translation-issue-suggestion {
1496
+ margin: 0;
1497
+ font-size: 12px;
1498
+ line-height: 1.35;
1499
+ color: #1f2937;
1500
+ }
1501
+
1502
+ .rte-translation-issue-suggestion {
1503
+ color: #475569;
1504
+ }
1505
+
1506
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-issue-message {
1507
+ color: #e2e8f0;
1508
+ }
1509
+
1510
+ .${u}.rte-translation-workflow-theme-dark .rte-translation-issue-suggestion {
1511
+ color: #cbd5e1;
1512
+ }
1513
+
1514
+ .rte-translation-empty {
1515
+ margin: 8px;
1516
+ font-size: 12px;
1517
+ color: #64748b;
1518
+ }
1519
+
1520
+ .rte-translation-live {
1521
+ position: absolute;
1522
+ width: 1px;
1523
+ height: 1px;
1524
+ margin: -1px;
1525
+ padding: 0;
1526
+ overflow: hidden;
1527
+ clip: rect(0 0 0 0);
1528
+ border: 0;
1529
+ }
1530
+
1531
+ [data-translation-locked="true"].rte-translation-segment-locked {
1532
+ outline: 2px dashed rgba(245, 158, 11, 0.65);
1533
+ outline-offset: 2px;
1534
+ background: rgba(255, 251, 235, 0.8);
1535
+ border-radius: 4px;
1536
+ }
1537
+
1538
+ ${h} [data-translation-locked="true"].rte-translation-segment-locked {
1539
+ outline-color: rgba(245, 158, 11, 0.75);
1540
+ background: rgba(120, 53, 15, 0.22);
1541
+ }
1542
+
1543
+ @media (max-width: 920px) {
1544
+ .${u} {
1545
+ left: 10px !important;
1546
+ right: 10px;
1547
+ top: 10px !important;
1548
+ width: auto !important;
1549
+ max-height: calc(100vh - 20px);
1550
+ }
1551
+
1552
+ .rte-translation-locales,
1553
+ .rte-translation-actions,
1554
+ .rte-translation-grid {
1555
+ grid-template-columns: 1fr;
1556
+ }
1557
+ }
1558
+ `, document.head.appendChild(e);
1559
+ }
1560
+ const mt = (e = {}) => {
1561
+ const t = oe(e), r = /* @__PURE__ */ new Set();
1562
+ return gt(), {
1563
+ name: "translationWorkflow",
1564
+ toolbar: [
1565
+ {
1566
+ id: "translationWorkflowGroup",
1567
+ label: "Translation Workflow",
1568
+ type: "group",
1569
+ command: "translationWorkflow",
1570
+ items: [
1571
+ {
1572
+ id: "toggleTranslationWorkflowPanel",
1573
+ label: "Translation Workflow",
1574
+ command: "toggleTranslationWorkflowPanel",
1575
+ shortcut: "Mod-Alt-Shift-l",
1576
+ 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>'
1577
+ },
1578
+ {
1579
+ id: "runTranslationLocaleValidation",
1580
+ label: "Run Locale Validation",
1581
+ command: "runTranslationLocaleValidation",
1582
+ shortcut: "Mod-Alt-Shift-v",
1583
+ 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>'
1584
+ },
1585
+ {
1586
+ id: "toggleTranslationSegmentLock",
1587
+ label: "Toggle Segment Lock",
1588
+ command: "toggleTranslationSegmentLock",
1589
+ shortcut: "Mod-Alt-Shift-k",
1590
+ 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>'
1591
+ },
1592
+ {
1593
+ id: "toggleTranslationRealtime",
1594
+ label: "Toggle Translation Realtime",
1595
+ command: "toggleTranslationRealtime",
1596
+ 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>'
1597
+ }
1598
+ ]
1599
+ }
1600
+ ],
1601
+ commands: {
1602
+ translationWorkflow: (n, a) => {
1603
+ const o = T(a, !1, !1);
1604
+ if (!o) return !1;
1605
+ const l = c.get(o) || t;
1606
+ return b(o, l), c.set(o, l), x = o, he(o), !0;
1607
+ },
1608
+ openTranslationWorkflowPanel: (n, a) => {
1609
+ const o = T(a, !1, !1);
1610
+ if (!o) return !1;
1611
+ const l = c.get(o) || t;
1612
+ return b(o, l), c.set(o, l), x = o, he(o), !0;
1613
+ },
1614
+ toggleTranslationWorkflowPanel: (n, a) => {
1615
+ const o = T(a, !1, !1);
1616
+ if (!o) return !1;
1617
+ const l = c.get(o) || t;
1618
+ return b(o, l), c.set(o, l), x = o, ze(o, typeof n == "boolean" ? n : void 0);
1619
+ },
1620
+ runTranslationLocaleValidation: (n, a) => {
1621
+ const o = T(a, !1, !1);
1622
+ if (!o) return !1;
1623
+ const l = c.get(o) || t;
1624
+ return b(o, l), c.set(o, l), x = o, L(o, "command", !0), !0;
1625
+ },
1626
+ toggleTranslationRealtime: (n, a) => {
1627
+ const o = T(a, !1, !1);
1628
+ if (!o) return !1;
1629
+ const l = c.get(o) || t;
1630
+ return b(o, l), c.set(o, l), x = o, De(o, typeof n == "boolean" ? n : void 0);
1631
+ },
1632
+ toggleTranslationSegmentLock: (n, a) => {
1633
+ const o = T(a, !1, !1);
1634
+ if (!o) return !1;
1635
+ const l = c.get(o) || t;
1636
+ b(o, l), c.set(o, l), x = o;
1637
+ const s = typeof n == "boolean" ? n : n?.locked, i = typeof n == "object" ? n?.segmentId : void 0;
1638
+ return se(o, i, s);
1639
+ },
1640
+ setTranslationLocales: (n, a) => {
1641
+ const o = T(a, !1, !1);
1642
+ if (!o || !n || typeof n != "object") return !1;
1643
+ const l = c.get(o) || t, s = b(o, l);
1644
+ return c.set(o, l), typeof n.sourceLocale == "string" && n.sourceLocale.trim() && (s.sourceLocale = A(n.sourceLocale)), typeof n.targetLocale == "string" && n.targetLocale.trim() && (s.targetLocale = A(n.targetLocale)), s.snapshot = "", L(o, "set-locales", !0), !0;
1645
+ },
1646
+ captureTranslationSourceSnapshot: (n, a) => {
1647
+ const o = T(a, !1, !1);
1648
+ if (!o) return !1;
1649
+ const l = c.get(o) || t;
1650
+ return b(o, l), c.set(o, l), x = o, Pe(o);
1651
+ },
1652
+ setTranslationWorkflowOptions: (n, a) => {
1653
+ const o = T(a, !1, !1);
1654
+ if (!o || !n || typeof n != "object") return !1;
1655
+ const l = c.get(o) || t, s = re.get(o) || Ge(l), i = {
1656
+ ...s,
1657
+ ...n,
1658
+ labels: {
1659
+ ...s.labels || {},
1660
+ ...n.labels || {}
1661
+ },
1662
+ localeRules: Array.isArray(n.localeRules) ? n.localeRules : s.localeRules,
1663
+ locales: Array.isArray(n.locales) ? n.locales : s.locales,
1664
+ normalizeText: n.normalizeText || l.normalizeText
1665
+ }, d = oe(i);
1666
+ c.set(o, d), re.set(o, i);
1667
+ const g = b(o, d);
1668
+ return typeof n.enableRealtime == "boolean" && (g.realtimeEnabled = n.enableRealtime), typeof n.sourceLocale == "string" && n.sourceLocale.trim() && (g.sourceLocale = A(n.sourceLocale)), typeof n.targetLocale == "string" && n.targetLocale.trim() && (g.targetLocale = A(n.targetLocale)), g.snapshot = "", L(o, "set-options", !0), R(o), E(o), !0;
1669
+ },
1670
+ getTranslationWorkflowState: (n, a) => {
1671
+ const o = T(a, !1, !1);
1672
+ if (!o) return !1;
1673
+ const l = c.get(o) || t;
1674
+ b(o, l);
1675
+ const s = qe(o);
1676
+ if (typeof n == "function")
1677
+ try {
1678
+ n(s);
1679
+ } catch {
1680
+ }
1681
+ return o.__translationWorkflowState = s, o.dispatchEvent(
1682
+ new CustomEvent("editora:translation-workflow-state", {
1683
+ bubbles: !0,
1684
+ detail: s
1685
+ })
1686
+ ), !0;
1687
+ }
1688
+ },
1689
+ keymap: {
1690
+ "Mod-Alt-Shift-l": "toggleTranslationWorkflowPanel",
1691
+ "Mod-Alt-Shift-L": "toggleTranslationWorkflowPanel",
1692
+ "Mod-Alt-Shift-v": "runTranslationLocaleValidation",
1693
+ "Mod-Alt-Shift-V": "runTranslationLocaleValidation",
1694
+ "Mod-Alt-Shift-k": "toggleTranslationSegmentLock",
1695
+ "Mod-Alt-Shift-K": "toggleTranslationSegmentLock"
1696
+ },
1697
+ init: function(a) {
1698
+ X += 1;
1699
+ const o = this && typeof this.__pluginConfig == "object" ? { ...e, ...this.__pluginConfig } : e, l = oe(o);
1700
+ dt(l);
1701
+ const s = T(
1702
+ a?.editorElement ? { editorElement: a.editorElement } : void 0,
1703
+ !1,
1704
+ !1
1705
+ );
1706
+ if (!s) return;
1707
+ x = s, r.add(s);
1708
+ const i = b(s, l);
1709
+ c.set(s, l), re.set(s, o), i.segments = M(s, l, i), L(s, "init", !0), E(s);
1710
+ },
1711
+ destroy: () => {
1712
+ r.forEach((n) => Se(n)), r.clear(), X = Math.max(0, X - 1), !(X > 0) && ft();
1713
+ }
1714
+ };
1715
+ };
1716
+ export {
1717
+ mt as TranslationWorkflowPlugin
1718
+ };