@editora/core 1.0.7 → 1.0.8

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