@editora/plugins 1.0.8 → 1.0.10

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