@editora/core 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +5 -0
  2. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-58d12bed.mjs} +23 -12
  3. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-289a112a.mjs} +112 -102
  4. package/dist/ApprovalWorkflowPlugin.native-449ce66c.mjs +1115 -0
  5. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-8aceb5cc.mjs} +16 -9
  6. package/dist/{BlockquotePlugin.native-JFmOLsxN.mjs → BlockquotePlugin.native-3541c714.mjs} +3 -2
  7. package/dist/BlocksLibraryPlugin.native-1cc51e63.mjs +1386 -0
  8. package/dist/{BoldPlugin.native-BAzzoqU5.mjs → BoldPlugin.native-f9d7f8e4.mjs} +1 -1
  9. package/dist/{CapitalizationPlugin.native-DOMsh5R7.mjs → CapitalizationPlugin.native-42c135dc.mjs} +3 -2
  10. package/dist/{ChecklistPlugin.native-nuSSEFNI.mjs → ChecklistPlugin.native-3b397ee9.mjs} +43 -22
  11. package/dist/CitationsPlugin.native-169fb1e8.mjs +1532 -0
  12. package/dist/{ClearFormattingPlugin.native-Bq_XcTh2.mjs → ClearFormattingPlugin.native-77baa514.mjs} +11 -6
  13. package/dist/{CodePlugin.native-DlpTPdkd.mjs → CodePlugin.native-989cf0aa.mjs} +629 -580
  14. package/dist/{CodeSamplePlugin.native-CgGoH-X4.mjs → CodeSamplePlugin.native-6cc0148e.mjs} +19 -10
  15. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-03659874.mjs} +55 -28
  16. package/dist/ConditionalContentPlugin.native-4983143a.mjs +1424 -0
  17. package/dist/ContentRulesPlugin.native-63ed405b.mjs +1149 -0
  18. package/dist/DataBindingPlugin.native-427e9d75.mjs +956 -0
  19. package/dist/{DirectionPlugin.native-CDnbdNyl.mjs → DirectionPlugin.native-4e742f42.mjs} +19 -10
  20. package/dist/DocSchemaPlugin.native-8e41eda0.mjs +1382 -0
  21. package/dist/{DocumentManagerPlugin.native-C2cs_1w4.mjs → DocumentManagerPlugin.native-e69895ad.mjs} +4 -4
  22. package/dist/{EmbedIframePlugin.native-DKJx2OS7.mjs → EmbedIframePlugin.native-55209c87.mjs} +70 -70
  23. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-65c5ac47.mjs} +11 -6
  24. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-f9bc255a.mjs} +7 -4
  25. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-f5647872.mjs} +19 -10
  26. package/dist/{FootnotePlugin.native-D730OGRm.mjs → FootnotePlugin.native-494657b3.mjs} +77 -39
  27. package/dist/{FullscreenPlugin.native-ChXyxeNw.mjs → FullscreenPlugin.native-87ce92e9.mjs} +1 -1
  28. package/dist/{HeadingPlugin.native-DrLYwQnQ.mjs → HeadingPlugin.native-e38c4a16.mjs} +1 -1
  29. package/dist/{HistoryPlugin.native-TDnVMsEO.mjs → HistoryPlugin.native-92ed4be4.mjs} +43 -22
  30. package/dist/{IndentPlugin.native-BHixp8sP.mjs → IndentPlugin.native-e4ee902b.mjs} +23 -12
  31. package/dist/{ItalicPlugin.native-CQjjDyUL.mjs → ItalicPlugin.native-7c95cfbc.mjs} +1 -1
  32. package/dist/{LineHeightPlugin.native-CM7iXdQj.mjs → LineHeightPlugin.native-5668f78c.mjs} +19 -10
  33. package/dist/{LinkPlugin.native-DYCIcdTm.mjs → LinkPlugin.native-6df29111.mjs} +9 -5
  34. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-fe2e115a.mjs} +9 -5
  35. package/dist/{MathPlugin.native-f_mDp8VL.mjs → MathPlugin.native-735bbac2.mjs} +9 -5
  36. package/dist/{MediaManagerPlugin.native-BiXiK8FC.mjs → MediaManagerPlugin.native-3cf48a00.mjs} +219 -207
  37. package/dist/MentionPlugin.native-3b1e8c05.mjs +778 -0
  38. package/dist/{MergeTagPlugin.native-C3eOfEgw.mjs → MergeTagPlugin.native-31cf7d48.mjs} +51 -26
  39. package/dist/PIIRedactionPlugin.native-7ab10b9f.mjs +1449 -0
  40. package/dist/{PageBreakPlugin.native-CXdX5fAv.mjs → PageBreakPlugin.native-1794c5fb.mjs} +67 -52
  41. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-f7b67cc0.mjs} +38 -33
  42. package/dist/{PrintPlugin.native-7qt5v7L5.mjs → PrintPlugin.native-f6a168c2.mjs} +5 -3
  43. package/dist/SlashCommandsPlugin.native-8d45e511.mjs +790 -0
  44. package/dist/SmartPastePlugin.native-a6c5efec.mjs +1447 -0
  45. package/dist/{SpecialCharactersPlugin.native-CZDato89.mjs → SpecialCharactersPlugin.native-7f06d4ba.mjs} +17 -9
  46. package/dist/{SpellCheckPlugin.native-BZB9AewP.mjs → SpellCheckPlugin.native-04e20834.mjs} +41 -21
  47. package/dist/{StrikethroughPlugin.native-0Be7j49s.mjs → StrikethroughPlugin.native-905e9501.mjs} +9 -5
  48. package/dist/{TablePlugin.native-DrHX-efe.mjs → TablePlugin.native-7d5458c1.mjs} +58 -30
  49. package/dist/{TemplatePlugin.native-CrpfKRJ8.mjs → TemplatePlugin.native-580f0f63.mjs} +32 -17
  50. package/dist/{TextAlignmentPlugin.native-sM_1s00t.mjs → TextAlignmentPlugin.native-9357b3ed.mjs} +11 -6
  51. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-d53ed459.mjs} +26 -14
  52. package/dist/TrackChangesPlugin.native-e96da509.mjs +818 -0
  53. package/dist/TranslationWorkflowPlugin.native-4e711b1e.mjs +1797 -0
  54. package/dist/{UnderlinePlugin.native-QpIcK4L2.mjs → UnderlinePlugin.native-8080c998.mjs} +1 -1
  55. package/dist/VersionDiffPlugin.native-5bbeff85.mjs +801 -0
  56. package/dist/_commonjsHelpers-69d58be2.mjs +31 -0
  57. package/dist/{anchoredPopover-Bxds0VoB.mjs → anchoredPopover-5cca53ba.mjs} +1 -1
  58. package/dist/documentManager-8327fb6e.mjs +9166 -0
  59. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +3 -2
  60. package/dist/editora.min.js +14 -13
  61. package/dist/editora.umd.js +14 -13
  62. package/dist/{html2canvas.esm-AYkPY5LS.mjs → html2canvas.esm-c51cb3b9.mjs} +978 -894
  63. package/dist/index-072ef022.js +11 -0
  64. package/dist/index-49d31221.mjs +16860 -0
  65. package/dist/{index-yzU4NdPT.mjs → index-7da30697.mjs} +490 -358
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-b47a189f.mjs +5782 -0
  68. package/dist/index.esm.js +12 -7
  69. package/dist/{jspdf.es.min-BJGtOnRT.mjs → jspdf.es.min-780c82db.mjs} +4808 -3784
  70. package/dist/plugin-loader.js +77 -40
  71. package/dist/{purify.es-CKpwg8Tk.mjs → purify.es-3bdbcfc5.mjs} +20 -10
  72. package/dist/style.css +1 -0
  73. package/dist/webcomponent-core.js +546 -414
  74. package/dist/webcomponent-core.min.css +1 -1
  75. package/dist/webcomponent-core.min.js +40 -39
  76. package/dist/webcomponent.cjs.js +1 -1
  77. package/dist/webcomponent.esm.js +1 -1
  78. package/dist/webcomponent.js +484 -315
  79. package/dist/webcomponent.min.css +1 -1
  80. package/dist/webcomponent.min.js +6035 -558
  81. package/package.json +11 -5
  82. package/dist/_commonjsHelpers-DOllISpa.mjs +0 -32
  83. package/dist/core.css +0 -1
  84. package/dist/documentManager-vQ1VkbUY.mjs +0 -8418
  85. package/dist/index-BpE6GFbz.js +0 -10
  86. package/dist/index-BslAFzmv.mjs +0 -16544
  87. package/dist/index.es-BYD2KEo6.mjs +0 -6666
@@ -0,0 +1,1532 @@
1
+ const $ = ".rte-content, .editora-content", gt = "rte-citations-styles", m = "rte-citations-panel", ot = ".rte-citation-ref[data-citation-id]", W = '.rte-citation-bibliography[data-type="citation-bibliography"]', G = '.rte-citation-footnotes[data-type="citation-footnotes"]', x = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', L = ["apa", "mla", "chicago"], Bt = {
2
+ panelTitle: "Citations",
3
+ panelAriaLabel: "Citations panel",
4
+ styleLabel: "Citation style",
5
+ authorLabel: "Author",
6
+ yearLabel: "Year",
7
+ titleLabel: "Title",
8
+ sourceLabel: "Source",
9
+ urlLabel: "URL",
10
+ noteLabel: "Footnote note",
11
+ insertText: "Insert Citation",
12
+ refreshText: "Refresh Bibliography",
13
+ closeText: "Close",
14
+ bibliographyTitle: "References",
15
+ footnotesTitle: "Citation Notes",
16
+ noCitationsText: "No citations inserted yet.",
17
+ styleButtonPrefix: "Style",
18
+ recentHeading: "Recent citations",
19
+ deleteRecentText: "x",
20
+ summaryPrefix: "Citations",
21
+ invalidMessage: "Author and title are required."
22
+ }, f = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), pt = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new Set();
23
+ let I = null, B = null, O = null, k = null, Y = 0, Ot = 0, at = 0, M = null, p = null;
24
+ function g(t) {
25
+ return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
26
+ }
27
+ function Pt(t) {
28
+ return t.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
29
+ }
30
+ function ht(t, o) {
31
+ const e = o(t);
32
+ if (!e)
33
+ return "";
34
+ const i = e.match(/\d{4}/);
35
+ return i ? i[0] : e;
36
+ }
37
+ function xt(t, o) {
38
+ const e = o(t);
39
+ return e ? /^https?:\/\//i.test(e) ? e : `https://${e}` : "";
40
+ }
41
+ function F(t) {
42
+ return t.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
43
+ }
44
+ function yt(t, o) {
45
+ return {
46
+ id: F(o.normalizeText(t.id || "")),
47
+ author: o.normalizeText(t.author || ""),
48
+ year: ht(t.year || "", o.normalizeText) || void 0,
49
+ title: o.normalizeText(t.title || ""),
50
+ source: o.normalizeText(t.source || "") || void 0,
51
+ url: xt(t.url || "", o.normalizeText) || void 0,
52
+ note: o.normalizeText(t.note || "") || void 0
53
+ };
54
+ }
55
+ function Z(t = {}) {
56
+ var i, n;
57
+ const o = t.defaultStyle && L.includes(t.defaultStyle) ? t.defaultStyle : "apa", e = {
58
+ ...Bt,
59
+ ...t.labels || {}
60
+ };
61
+ return {
62
+ defaultStyle: o,
63
+ enableFootnoteSync: t.enableFootnoteSync !== !1,
64
+ debounceMs: Math.max(80, Number((i = t.debounceMs) != null ? i : 220)),
65
+ maxRecentCitations: Math.max(3, Math.min(30, Number((n = t.maxRecentCitations) != null ? n : 8))),
66
+ labels: e,
67
+ normalizeText: t.normalizeText || Pt,
68
+ generateCitationId: typeof t.generateCitationId == "function" ? t.generateCitationId : void 0
69
+ };
70
+ }
71
+ function Ct(t) {
72
+ return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
73
+ }
74
+ function lt(t) {
75
+ return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || t;
76
+ }
77
+ function X(t) {
78
+ return t ? (t.getAttribute("data-theme") || t.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : t.classList.contains("dark") || t.classList.contains("editora-theme-dark") || t.classList.contains("rte-theme-dark") : !1;
79
+ }
80
+ function Dt(t) {
81
+ const o = lt(t);
82
+ if (X(o))
83
+ return !0;
84
+ const e = o.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
85
+ return X(e) ? !0 : X(document.documentElement) || X(document.body);
86
+ }
87
+ function tt(t, o) {
88
+ t.classList.remove("rte-citations-theme-dark"), Dt(o) && t.classList.add("rte-citations-theme-dark");
89
+ }
90
+ function h(t, o = !0) {
91
+ if ((t == null ? void 0 : t.contentElement) instanceof HTMLElement)
92
+ return t.contentElement;
93
+ if ((t == null ? void 0 : t.editorElement) instanceof HTMLElement) {
94
+ const n = t.editorElement;
95
+ if (n.matches($))
96
+ return n;
97
+ const r = n.querySelector($);
98
+ if (r instanceof HTMLElement)
99
+ return r;
100
+ }
101
+ const e = window.getSelection();
102
+ if (e && e.rangeCount > 0) {
103
+ const n = e.getRangeAt(0).startContainer, r = Ct(n), a = r == null ? void 0 : r.closest($);
104
+ if (a)
105
+ return a;
106
+ }
107
+ const i = document.activeElement;
108
+ if (i) {
109
+ if (i.matches($))
110
+ return i;
111
+ const n = i.closest($);
112
+ if (n)
113
+ return n;
114
+ }
115
+ return p && p.isConnected ? p : (p && !p.isConnected && (p = null), o ? document.querySelector($) : null);
116
+ }
117
+ function S(t) {
118
+ return t.getAttribute("contenteditable") === "false" || t.getAttribute("data-readonly") === "true";
119
+ }
120
+ function j(t) {
121
+ const o = Ct(t);
122
+ return o ? !!(o.closest(W) || o.closest(G)) : !1;
123
+ }
124
+ function Ht(t, o) {
125
+ if (at += 1, o.generateCitationId) {
126
+ const e = o.generateCitationId({ editor: t, index: at }), i = F(o.normalizeText(e || ""));
127
+ if (i)
128
+ return i;
129
+ }
130
+ return `cite-${Date.now().toString(36)}-${at.toString(36)}`;
131
+ }
132
+ function st(t) {
133
+ return t.map((o) => (o || "").trim()).filter(Boolean).join(" ").trim();
134
+ }
135
+ function Ft(t, o) {
136
+ const e = t.author || "Unknown", i = t.year || "n.d.";
137
+ return o === "mla" ? `(${e} ${i})` : o === "chicago" ? `(${e} ${i})` : `(${e}, ${i})`;
138
+ }
139
+ function ut(t, o) {
140
+ const e = t.author || "Unknown", i = t.year || "n.d.", n = t.title || "Untitled", r = t.source || "", a = t.url || "";
141
+ return st(o === "mla" ? [
142
+ `${e}.`,
143
+ `"${n}."`,
144
+ r ? `${r},` : "",
145
+ `${i}.`,
146
+ a
147
+ ] : o === "chicago" ? [
148
+ `${e}.`,
149
+ `${n}.`,
150
+ r ? `${r}.` : "",
151
+ `(${i}).`,
152
+ a
153
+ ] : [
154
+ `${e}.`,
155
+ `(${i}).`,
156
+ `${n}.`,
157
+ r ? `${r}.` : "",
158
+ a
159
+ ]);
160
+ }
161
+ function R(t) {
162
+ return Array.from(t.querySelectorAll(ot)).filter(
163
+ (o) => !o.closest(W) && !o.closest(G)
164
+ );
165
+ }
166
+ function wt(t, o) {
167
+ const e = F(o.normalizeText(t.getAttribute("data-citation-id") || ""));
168
+ if (!e)
169
+ return null;
170
+ const i = o.normalizeText(t.getAttribute("data-citation-author") || ""), n = o.normalizeText(t.getAttribute("data-citation-title") || "");
171
+ return {
172
+ id: e,
173
+ author: i || "Unknown",
174
+ year: ht(t.getAttribute("data-citation-year") || "", o.normalizeText) || void 0,
175
+ title: n || "Untitled",
176
+ source: o.normalizeText(t.getAttribute("data-citation-source") || "") || void 0,
177
+ url: xt(t.getAttribute("data-citation-url") || "", o.normalizeText) || void 0,
178
+ note: o.normalizeText(t.getAttribute("data-citation-note") || "") || void 0
179
+ };
180
+ }
181
+ function vt(t, o, e) {
182
+ t.classList.add("rte-citation-ref"), t.setAttribute("data-citation-id", o.id), t.setAttribute("data-citation-author", o.author || ""), t.setAttribute("data-citation-year", o.year || ""), t.setAttribute("data-citation-title", o.title || ""), t.setAttribute("data-citation-source", o.source || ""), t.setAttribute("data-citation-url", o.url || ""), t.setAttribute("data-citation-note", o.note || ""), t.setAttribute("contenteditable", "false"), t.setAttribute("tabindex", "0"), t.setAttribute("role", "doc-biblioref"), t.setAttribute("data-style", e), t.textContent = Ft(o, e);
183
+ }
184
+ function it(t, o, e) {
185
+ const i = lt(t);
186
+ Array.from(
187
+ i.querySelectorAll(
188
+ `.rte-toolbar-button[data-command="${o}"], .editora-toolbar-button[data-command="${o}"]`
189
+ )
190
+ ).forEach((r) => {
191
+ r.classList.toggle("active", e), r.setAttribute("data-active", e ? "true" : "false"), r.setAttribute("aria-pressed", e ? "true" : "false");
192
+ });
193
+ }
194
+ function N(t, o) {
195
+ const e = T.get(t);
196
+ return e && L.includes(e) ? e : (o == null ? void 0 : o.defaultStyle) || "apa";
197
+ }
198
+ function K(t, o) {
199
+ const e = R(t), i = /* @__PURE__ */ new Map();
200
+ return e.forEach((n) => {
201
+ const r = wt(n, o);
202
+ if (!r)
203
+ return;
204
+ if (!i.has(r.id)) {
205
+ i.set(r.id, r);
206
+ return;
207
+ }
208
+ const a = i.get(r.id);
209
+ i.set(r.id, {
210
+ ...a,
211
+ author: a.author || r.author,
212
+ title: a.title || r.title,
213
+ year: a.year || r.year,
214
+ source: a.source || r.source,
215
+ url: a.url || r.url,
216
+ note: a.note || r.note
217
+ });
218
+ }), Array.from(i.values());
219
+ }
220
+ function _t(t, o, e) {
221
+ const i = yt(o, e);
222
+ if (!i.id || !i.author || !i.title)
223
+ return;
224
+ const r = (D.get(t) || []).filter((a) => a.id !== i.id);
225
+ D.set(t, [i, ...r].slice(0, e.maxRecentCitations));
226
+ }
227
+ function rt(t, o, e) {
228
+ const i = D.get(t) || [], n = /* @__PURE__ */ new Map();
229
+ o.slice(Math.max(0, o.length - e.maxRecentCitations)).reverse().forEach((a) => {
230
+ a.id && n.set(a.id, a);
231
+ }), i.forEach((a) => {
232
+ !a.id || n.has(a.id) || n.set(a.id, a);
233
+ });
234
+ const r = Array.from(n.values()).slice(0, e.maxRecentCitations);
235
+ return D.set(t, r), r;
236
+ }
237
+ function Et(t, o, e, i) {
238
+ const n = F(i.normalizeText(o || ""));
239
+ return n && rt(t, e, i).find((a) => a.id === n) || null;
240
+ }
241
+ function qt(t, o, e) {
242
+ const i = F(e.normalizeText(o || ""));
243
+ if (!i)
244
+ return !1;
245
+ const n = D.get(t) || [], r = n.filter((a) => a.id !== i);
246
+ return r.length === n.length ? !1 : (D.set(t, r), !0);
247
+ }
248
+ function $t(t, o, e) {
249
+ const i = document.createElement("section");
250
+ i.className = t, i.setAttribute("data-type", o), i.setAttribute("contenteditable", "false"), i.setAttribute("aria-label", e), o === "citation-bibliography" ? i.setAttribute("role", "doc-bibliography") : o === "citation-footnotes" && i.setAttribute("role", "doc-endnotes");
251
+ const n = document.createElement("h3");
252
+ n.className = "rte-citation-section-title", n.textContent = e;
253
+ const r = document.createElement("ol");
254
+ return r.className = "rte-citation-list", r.setAttribute("role", "list"), i.appendChild(n), i.appendChild(r), i;
255
+ }
256
+ function jt(t, o) {
257
+ let e = t.querySelector(W);
258
+ e || (e = $t("rte-citation-bibliography", "citation-bibliography", o.labels.bibliographyTitle), t.appendChild(e));
259
+ const i = e.querySelector(".rte-citation-section-title");
260
+ return i && (i.textContent = o.labels.bibliographyTitle), e.setAttribute("aria-label", o.labels.bibliographyTitle), e;
261
+ }
262
+ function Kt(t, o) {
263
+ let e = t.querySelector(G);
264
+ e || (e = $t("rte-citation-footnotes", "citation-footnotes", o.labels.footnotesTitle), t.appendChild(e));
265
+ const i = e.querySelector(".rte-citation-section-title");
266
+ return i && (i.textContent = o.labels.footnotesTitle), e.setAttribute("aria-label", o.labels.footnotesTitle), e;
267
+ }
268
+ function St(t, o) {
269
+ const e = t.querySelector(o);
270
+ e == null || e.remove();
271
+ }
272
+ function Ut(t, o, e, i) {
273
+ if (o.length === 0) {
274
+ St(t, W);
275
+ return;
276
+ }
277
+ const r = jt(t, e).querySelector(".rte-citation-list");
278
+ if (!r)
279
+ return;
280
+ const a = document.createDocumentFragment();
281
+ o.forEach((s, d) => {
282
+ const c = document.createElement("li");
283
+ c.className = "rte-citation-item", c.id = `rte-citation-entry-${s.id}`, c.setAttribute("data-citation-id", s.id), c.setAttribute("data-citation-number", String(d + 1)), c.textContent = ut(s, i), a.appendChild(c);
284
+ }), r.innerHTML = "", r.appendChild(a);
285
+ }
286
+ function Wt(t, o, e, i) {
287
+ if (!e.enableFootnoteSync || o.length === 0) {
288
+ St(t, G), R(t).forEach((l) => {
289
+ l.removeAttribute("data-footnote-number"), l.removeAttribute("data-footnote-target");
290
+ });
291
+ return;
292
+ }
293
+ const r = Kt(t, e).querySelector(".rte-citation-list");
294
+ if (!r)
295
+ return;
296
+ const a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
297
+ o.forEach((l, u) => {
298
+ s.set(l.id, u + 1);
299
+ });
300
+ const d = /* @__PURE__ */ new Map();
301
+ R(t).forEach((l) => {
302
+ const u = l.getAttribute("data-citation-id") || "";
303
+ if (!u || !s.has(u))
304
+ return;
305
+ const b = (d.get(u) || 0) + 1;
306
+ d.set(u, b);
307
+ const w = `rte-citation-ref-${u}-${b}`;
308
+ l.id = w;
309
+ const A = s.get(u);
310
+ l.setAttribute("data-footnote-number", String(A)), l.setAttribute("data-footnote-target", `rte-citation-note-${u}`), a.has(u) || a.set(u, w);
311
+ });
312
+ const c = document.createDocumentFragment();
313
+ o.forEach((l, u) => {
314
+ const b = document.createElement("li");
315
+ b.className = "rte-citation-item rte-citation-footnote-item", b.id = `rte-citation-note-${l.id}`, b.setAttribute("data-citation-id", l.id);
316
+ const w = document.createElement("span");
317
+ w.className = "rte-citation-footnote-number", w.textContent = `${u + 1}. `;
318
+ const A = document.createElement("span");
319
+ A.className = "rte-citation-footnote-text";
320
+ const It = l.note ? `${l.note}. ` : "";
321
+ A.textContent = `${It}${ut(l, i)}`, b.appendChild(w), b.appendChild(A);
322
+ const mt = a.get(l.id);
323
+ if (mt) {
324
+ const _ = document.createElement("a");
325
+ _.className = "rte-citation-backref", _.href = `#${mt}`, _.setAttribute("aria-label", `Back to citation ${u + 1}`), _.textContent = "Back", b.appendChild(_);
326
+ }
327
+ c.appendChild(b);
328
+ }), r.innerHTML = "", r.appendChild(c);
329
+ }
330
+ function Gt(t, o, e, i) {
331
+ const n = ut(o, e);
332
+ t.setAttribute("data-citation-number", String(i)), t.setAttribute("aria-label", `Citation ${i}: ${n}`);
333
+ }
334
+ function Vt(t, o, e) {
335
+ const i = R(t);
336
+ let n = `${o}:${e ? "1" : "0"}:${i.length}`;
337
+ return i.forEach((r) => {
338
+ n += `|${r.getAttribute("data-citation-id") || ""}`, n += `|${r.getAttribute("data-citation-author") || ""}`, n += `|${r.getAttribute("data-citation-year") || ""}`, n += `|${r.getAttribute("data-citation-title") || ""}`, n += `|${r.getAttribute("data-citation-source") || ""}`, n += `|${r.getAttribute("data-citation-url") || ""}`, n += `|${r.getAttribute("data-citation-note") || ""}`;
339
+ }), n;
340
+ }
341
+ function H(t) {
342
+ const o = v.get(t);
343
+ if (!o)
344
+ return;
345
+ const e = f.get(t) || M;
346
+ if (!e)
347
+ return;
348
+ const i = N(t, e), n = K(t, e), r = rt(t, n, e), a = o.querySelector(".rte-citations-status"), s = o.querySelector('[data-action="cycle-style"]'), d = o.querySelector(".rte-citations-recent-list");
349
+ if (a) {
350
+ const c = n.length;
351
+ a.textContent = `${e.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${e.enableFootnoteSync ? "On" : "Off"}`;
352
+ }
353
+ if (s && (s.textContent = `${e.labels.styleButtonPrefix}: ${i.toUpperCase()}`, s.setAttribute("aria-label", `${e.labels.styleButtonPrefix}: ${i.toUpperCase()}`)), d) {
354
+ if (r.length === 0) {
355
+ d.innerHTML = `<li class="rte-citations-empty">${g(e.labels.noCitationsText)}</li>`;
356
+ return;
357
+ }
358
+ d.innerHTML = r.map(
359
+ (c) => `
360
+ <li class="rte-citations-recent-item">
361
+ <div class="rte-citations-recent-row">
362
+ <button
363
+ type="button"
364
+ class="rte-citations-recent-btn"
365
+ data-action="insert-from-recent"
366
+ data-citation-id="${g(c.id)}"
367
+ aria-label="Insert citation: ${g(c.title)}"
368
+ >
369
+ <span class="rte-citations-recent-title">${g(c.title)}</span>
370
+ <span class="rte-citations-recent-meta">${g(c.author)}${c.year ? ` (${g(c.year)})` : ""}</span>
371
+ </button>
372
+ <button
373
+ type="button"
374
+ class="rte-citations-recent-delete"
375
+ data-action="delete-by-id"
376
+ data-citation-id="${g(c.id)}"
377
+ aria-label="Delete citation: ${g(c.title)}"
378
+ >${g(e.labels.deleteRecentText)}</button>
379
+ </div>
380
+ </li>
381
+ `
382
+ ).join("");
383
+ }
384
+ }
385
+ function y(t, o, e = !1) {
386
+ const i = N(t, o), n = Vt(t, i, o.enableFootnoteSync);
387
+ if (!e && pt.get(t) === n)
388
+ return K(t, o);
389
+ const r = R(t), a = /* @__PURE__ */ new Map();
390
+ r.forEach((c) => {
391
+ const l = wt(c, o);
392
+ l && (a.has(l.id) || a.set(l.id, l));
393
+ });
394
+ const s = Array.from(a.values());
395
+ rt(t, s, o);
396
+ const d = /* @__PURE__ */ new Map();
397
+ return s.forEach((c, l) => {
398
+ d.set(c.id, l + 1);
399
+ }), r.forEach((c) => {
400
+ const l = c.getAttribute("data-citation-id") || "", u = a.get(l);
401
+ if (!u)
402
+ return;
403
+ vt(c, u, i);
404
+ const b = d.get(u.id) || 1;
405
+ Gt(c, u, i, Math.max(1, b));
406
+ }), Ut(t, s, o, i), Wt(t, s, o, i), pt.set(t, n), H(t), t.dispatchEvent(
407
+ new CustomEvent("editora:citations-refreshed", {
408
+ bubbles: !0,
409
+ detail: {
410
+ citations: s,
411
+ style: i,
412
+ footnoteSync: o.enableFootnoteSync
413
+ }
414
+ })
415
+ ), s;
416
+ }
417
+ function At(t) {
418
+ const o = Q.get(t);
419
+ typeof o == "number" && (window.clearTimeout(o), q.delete(o), Q.delete(t));
420
+ }
421
+ function kt(t) {
422
+ const o = f.get(t) || M;
423
+ if (!o)
424
+ return;
425
+ At(t);
426
+ const e = window.setTimeout(() => {
427
+ q.delete(e), Q.delete(t), y(t, o, !1);
428
+ }, o.debounceMs);
429
+ q.add(e), Q.set(t, e);
430
+ }
431
+ function Yt(t) {
432
+ const o = window.getSelection();
433
+ if (!o)
434
+ throw new Error("Selection unavailable");
435
+ if (o.rangeCount > 0) {
436
+ const a = o.getRangeAt(0);
437
+ if (t.contains(a.commonAncestorContainer) && !j(a.commonAncestorContainer))
438
+ return a.cloneRange();
439
+ }
440
+ const e = document.createRange(), i = t.querySelector(W), n = t.querySelector(G), r = i || n;
441
+ return r ? (e.setStartBefore(r), e.collapse(!0), e) : (e.selectNodeContents(t), e.collapse(!1), e);
442
+ }
443
+ function dt(t) {
444
+ t.dispatchEvent(new Event("input", { bubbles: !0 }));
445
+ }
446
+ function ft(t, o) {
447
+ if (o === t.innerHTML)
448
+ return;
449
+ const e = window.execEditorCommand || window.executeEditorCommand;
450
+ if (typeof e == "function")
451
+ try {
452
+ e("recordDomTransaction", t, o, t.innerHTML);
453
+ } catch (i) {
454
+ }
455
+ }
456
+ function Tt(t, o) {
457
+ const e = window.getSelection();
458
+ if (!e)
459
+ return;
460
+ const i = document.createRange();
461
+ if (t.nodeType === Node.TEXT_NODE) {
462
+ const n = t, r = Math.max(0, Math.min(o, n.length));
463
+ i.setStart(n, r);
464
+ } else {
465
+ const n = t.childNodes.length, r = Math.max(0, Math.min(o, n));
466
+ i.setStart(t, r);
467
+ }
468
+ i.collapse(!0), e.removeAllRanges(), e.addRange(i);
469
+ }
470
+ function Mt(t) {
471
+ if (t.collapsed || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1 || !(t.startContainer instanceof Element || t.startContainer instanceof DocumentFragment))
472
+ return null;
473
+ const o = t.startContainer.childNodes[t.startOffset];
474
+ return !(o instanceof HTMLElement) || !o.matches(ot) ? null : o;
475
+ }
476
+ function J(t, o, e) {
477
+ const { startContainer: i, startOffset: n } = t;
478
+ if (i.nodeType === Node.ELEMENT_NODE) {
479
+ const a = i;
480
+ if (e === "previous") {
481
+ if (n > 0)
482
+ return a.childNodes[n - 1] || null;
483
+ } else if (n < a.childNodes.length)
484
+ return a.childNodes[n] || null;
485
+ }
486
+ if (i.nodeType === Node.TEXT_NODE && (e === "previous" && n < i.data.length || e === "next" && n > 0))
487
+ return null;
488
+ let r = i;
489
+ for (; r && r !== o; ) {
490
+ const a = e === "previous" ? r.previousSibling : r.nextSibling;
491
+ if (a)
492
+ return a;
493
+ r = r.parentNode;
494
+ }
495
+ return null;
496
+ }
497
+ function Lt(t, o, e) {
498
+ if (!t.collapsed)
499
+ return null;
500
+ const i = (a) => a instanceof HTMLElement && a.matches(ot) ? a : null, { startContainer: n, startOffset: r } = t;
501
+ if (n.nodeType === Node.ELEMENT_NODE) {
502
+ const a = n;
503
+ return e === "Backspace" && r > 0 ? i(a.childNodes[r - 1] || null) : e === "Delete" ? i(a.childNodes[r] || null) : null;
504
+ }
505
+ if (n.nodeType === Node.TEXT_NODE) {
506
+ const a = n;
507
+ if (e === "Backspace" && r === 0) {
508
+ const s = i(a.previousSibling);
509
+ return s || i(J(t, o, "previous"));
510
+ }
511
+ if (e === "Delete" && r === a.data.length) {
512
+ const s = i(a.nextSibling);
513
+ return s || i(J(t, o, "next"));
514
+ }
515
+ }
516
+ return i(e === "Backspace" ? J(t, o, "previous") : J(t, o, "next"));
517
+ }
518
+ function P(t, o, e) {
519
+ const i = t.closest($);
520
+ if (!i || j(t))
521
+ return !1;
522
+ const n = t.parentNode;
523
+ if (!n)
524
+ return !1;
525
+ const r = i.innerHTML, a = Array.from(n.childNodes).indexOf(t);
526
+ if (a < 0)
527
+ return !1;
528
+ const s = t.nextSibling;
529
+ return s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), t.remove(), Tt(n, a), y(i, e, !0), ft(i, r), dt(i), o === "Delete" && i.focus({ preventScroll: !0 }), !0;
530
+ }
531
+ function Xt(t, o, e) {
532
+ if (t.key !== "Backspace" && t.key !== "Delete")
533
+ return !1;
534
+ const i = t.key, n = t.target;
535
+ if (n != null && n.matches(ot) && o.contains(n) && !j(n))
536
+ return t.preventDefault(), t.stopPropagation(), P(n, i, e);
537
+ const r = window.getSelection();
538
+ if (!r || r.rangeCount === 0)
539
+ return !1;
540
+ const a = r.getRangeAt(0);
541
+ if (!o.contains(a.commonAncestorContainer) || j(a.commonAncestorContainer))
542
+ return !1;
543
+ const s = Mt(a);
544
+ if (s)
545
+ return t.preventDefault(), t.stopPropagation(), P(s, i, e);
546
+ const d = Lt(a, o, i);
547
+ return d ? (t.preventDefault(), t.stopPropagation(), P(d, i, e)) : !1;
548
+ }
549
+ function Rt(t, o, e) {
550
+ const i = F(e.normalizeText(o || ""));
551
+ if (!i)
552
+ return !1;
553
+ const n = R(t).filter((a) => a.getAttribute("data-citation-id") === i);
554
+ if (n.length === 0)
555
+ return !1;
556
+ if (n.length === 1)
557
+ return P(n[0], "Delete", e);
558
+ const r = t.innerHTML;
559
+ return n.forEach((a) => {
560
+ const s = a.nextSibling;
561
+ s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), a.remove();
562
+ }), Tt(t, t.childNodes.length), y(t, e, !0), ft(t, r), dt(t), t.focus({ preventScroll: !0 }), !0;
563
+ }
564
+ function Jt(t, o) {
565
+ const e = window.getSelection();
566
+ if (!e || e.rangeCount === 0)
567
+ return !1;
568
+ const i = e.getRangeAt(0);
569
+ if (!t.contains(i.commonAncestorContainer) || j(i.commonAncestorContainer))
570
+ return !1;
571
+ const n = Mt(i);
572
+ if (n)
573
+ return P(n, "Delete", o);
574
+ const r = Lt(i, t, "Backspace");
575
+ return r ? P(r, "Backspace", o) : !1;
576
+ }
577
+ function et(t, o, e) {
578
+ var l, u;
579
+ const i = yt(o, e);
580
+ if (!i.author || !i.title)
581
+ return !1;
582
+ i.id || (i.id = Ht(t, e));
583
+ const n = t.innerHTML;
584
+ let r;
585
+ try {
586
+ r = Yt(t);
587
+ } catch (b) {
588
+ return !1;
589
+ }
590
+ const a = window.getSelection();
591
+ if (!a)
592
+ return !1;
593
+ r.collapsed || r.deleteContents();
594
+ const s = document.createElement("span");
595
+ vt(s, i, N(t, e));
596
+ try {
597
+ r.insertNode(s);
598
+ } catch (b) {
599
+ return !1;
600
+ }
601
+ const d = document.createTextNode(" ");
602
+ s.nextSibling ? (l = s.parentNode) == null || l.insertBefore(d, s.nextSibling) : (u = s.parentNode) == null || u.appendChild(d);
603
+ const c = document.createRange();
604
+ if (d.parentNode) {
605
+ const b = Array.from(d.parentNode.childNodes).indexOf(d) + 1;
606
+ c.setStart(d.parentNode, Math.max(0, b));
607
+ } else
608
+ c.setStartAfter(s);
609
+ return c.collapse(!0), a.removeAllRanges(), a.addRange(c), _t(t, i, e), y(t, e, !0), ft(t, n), dt(t), !0;
610
+ }
611
+ function Zt(t, o) {
612
+ if (!o)
613
+ return !1;
614
+ const e = R(t).find((r) => r.getAttribute("data-citation-id") === o) || null;
615
+ if (!e)
616
+ return !1;
617
+ e.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), e.focus({ preventScroll: !0 });
618
+ const i = window.getSelection();
619
+ if (!i)
620
+ return !0;
621
+ const n = document.createRange();
622
+ return n.selectNode(e), i.removeAllRanges(), i.addRange(n), !0;
623
+ }
624
+ function nt(t) {
625
+ return V.get(t) === !0;
626
+ }
627
+ function U(t, o = !1) {
628
+ const e = v.get(t);
629
+ e && (e.classList.remove("show"), V.set(t, !1), it(t, "toggleCitationsPanel", !1), o && t.focus({ preventScroll: !0 }));
630
+ }
631
+ function Qt(t) {
632
+ v.forEach((o, e) => {
633
+ e !== t && U(e, !1);
634
+ });
635
+ }
636
+ function ct(t, o) {
637
+ if (!o.classList.contains("show"))
638
+ return;
639
+ const i = lt(t).getBoundingClientRect(), n = Math.min(window.innerWidth - 20, 380), r = Math.max(10, window.innerWidth - n - 10), a = Math.min(Math.max(10, i.right - n), r), s = Math.max(10, Math.min(window.innerHeight - 10 - 260, i.top + 10));
640
+ o.style.width = `${n}px`, o.style.left = `${a}px`, o.style.top = `${s}px`, o.style.maxHeight = `${Math.max(260, window.innerHeight - 24)}px`;
641
+ }
642
+ function C(t, o) {
643
+ return t.querySelector(`[data-field="${o}"]`);
644
+ }
645
+ function te(t) {
646
+ var s, d, c, l, u, b;
647
+ const o = ((s = C(t, "author")) == null ? void 0 : s.value) || "", e = ((d = C(t, "year")) == null ? void 0 : d.value) || "", i = ((c = C(t, "title")) == null ? void 0 : c.value) || "", n = ((l = C(t, "source")) == null ? void 0 : l.value) || "", r = ((u = C(t, "url")) == null ? void 0 : u.value) || "", a = ((b = C(t, "note")) == null ? void 0 : b.value) || "";
648
+ return {
649
+ author: o,
650
+ year: e,
651
+ title: i,
652
+ source: n,
653
+ url: r,
654
+ note: a
655
+ };
656
+ }
657
+ function E(t, o) {
658
+ const e = t.querySelector(".rte-citations-live");
659
+ e && (e.textContent = o);
660
+ }
661
+ function ee(t, o, e) {
662
+ const i = C(o, "style");
663
+ i && (i.value = N(t, e));
664
+ }
665
+ function Nt(t, o, e) {
666
+ const i = L.includes(o) ? o : e.defaultStyle;
667
+ return T.set(t, i), y(t, e, !0), i;
668
+ }
669
+ function bt(t, o) {
670
+ const e = N(t, o), i = L.indexOf(e), n = L[(i + 1) % L.length];
671
+ return T.set(t, n), y(t, o, !0), n;
672
+ }
673
+ function ne(t) {
674
+ const o = v.get(t);
675
+ if (o)
676
+ return o;
677
+ const e = f.get(t) || M || Z(), i = `rte-citations-panel-${Ot++}`, n = document.createElement("section");
678
+ n.className = m, n.id = i, n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "false"), n.setAttribute("aria-label", e.labels.panelAriaLabel), n.setAttribute("tabindex", "-1"), n.innerHTML = `
679
+ <header class="rte-citations-header">
680
+ <h2 class="rte-citations-title">${g(e.labels.panelTitle)}</h2>
681
+ <button type="button" class="rte-citations-icon-btn" data-action="close" aria-label="${g(e.labels.closeText)}">✕</button>
682
+ </header>
683
+ <div class="rte-citations-body">
684
+ <p class="rte-citations-status" aria-live="polite"></p>
685
+
686
+ <div class="rte-citations-grid">
687
+ <label class="rte-citations-label">
688
+ ${g(e.labels.styleLabel)}
689
+ <select data-field="style" class="rte-citations-field">
690
+ <option value="apa">APA</option>
691
+ <option value="mla">MLA</option>
692
+ <option value="chicago">Chicago</option>
693
+ </select>
694
+ </label>
695
+ <label class="rte-citations-label">
696
+ ${g(e.labels.authorLabel)}
697
+ <input type="text" data-field="author" class="rte-citations-field" autocomplete="off" />
698
+ </label>
699
+ <label class="rte-citations-label">
700
+ ${g(e.labels.yearLabel)}
701
+ <input type="text" data-field="year" class="rte-citations-field" inputmode="numeric" autocomplete="off" />
702
+ </label>
703
+ <label class="rte-citations-label">
704
+ ${g(e.labels.titleLabel)}
705
+ <input type="text" data-field="title" class="rte-citations-field" autocomplete="off" />
706
+ </label>
707
+ <label class="rte-citations-label">
708
+ ${g(e.labels.sourceLabel)}
709
+ <input type="text" data-field="source" class="rte-citations-field" autocomplete="off" />
710
+ </label>
711
+ <label class="rte-citations-label">
712
+ ${g(e.labels.urlLabel)}
713
+ <input type="url" data-field="url" class="rte-citations-field" autocomplete="off" />
714
+ </label>
715
+ <label class="rte-citations-label rte-citations-label-note">
716
+ ${g(e.labels.noteLabel)}
717
+ <textarea data-field="note" class="rte-citations-field" rows="2"></textarea>
718
+ </label>
719
+ </div>
720
+
721
+ <div class="rte-citations-controls" role="toolbar" aria-label="Citation actions">
722
+ <button type="button" class="rte-citations-btn rte-citations-btn-primary" data-action="insert">${g(e.labels.insertText)}</button>
723
+ <button type="button" class="rte-citations-btn" data-action="refresh">${g(e.labels.refreshText)}</button>
724
+ <button type="button" class="rte-citations-btn" data-action="cycle-style"></button>
725
+ </div>
726
+
727
+ <section class="rte-citations-recent" aria-label="${g(e.labels.recentHeading)}">
728
+ <h3 class="rte-citations-recent-heading">${g(e.labels.recentHeading)}</h3>
729
+ <ul class="rte-citations-recent-list" role="list"></ul>
730
+ </section>
731
+
732
+ <p class="rte-citations-shortcut">Shortcut: Ctrl/Cmd + Alt + Shift + C</p>
733
+ <span class="rte-citations-live" aria-live="polite"></span>
734
+ </div>
735
+ `, n.addEventListener("click", (a) => {
736
+ const s = a.target;
737
+ if (!s)
738
+ return;
739
+ const d = s.closest("[data-action]");
740
+ if (!d)
741
+ return;
742
+ const c = d.getAttribute("data-action") || "", l = f.get(t) || M || e;
743
+ if (f.set(t, l), c === "close") {
744
+ U(t, !0);
745
+ return;
746
+ }
747
+ if (c === "insert") {
748
+ if (S(t))
749
+ return;
750
+ const u = te(n);
751
+ if (!l.normalizeText(u.author) || !l.normalizeText(u.title)) {
752
+ E(n, l.labels.invalidMessage);
753
+ return;
754
+ }
755
+ if (!et(t, u, l)) {
756
+ E(n, l.labels.invalidMessage);
757
+ return;
758
+ }
759
+ E(n, "Citation inserted.");
760
+ const w = C(n, "title"), A = C(n, "note");
761
+ w && (w.value = ""), A && (A.value = "");
762
+ return;
763
+ }
764
+ if (c === "refresh") {
765
+ const u = y(t, l, !0);
766
+ E(n, `Refreshed ${u.length} citation${u.length === 1 ? "" : "s"}.`);
767
+ return;
768
+ }
769
+ if (c === "cycle-style") {
770
+ const u = bt(t, l);
771
+ ee(t, n, l), E(n, `Style changed to ${u.toUpperCase()}.`);
772
+ return;
773
+ }
774
+ if (c === "insert-from-recent") {
775
+ if (S(t))
776
+ return;
777
+ const u = d.getAttribute("data-citation-id") || "", b = Et(t, u, K(t, l), l);
778
+ if (!b)
779
+ return;
780
+ et(t, b, l), E(n, `Inserted citation: ${b.title}.`);
781
+ return;
782
+ }
783
+ if (c === "delete-by-id") {
784
+ if (S(t))
785
+ return;
786
+ const u = d.getAttribute("data-citation-id") || "";
787
+ if (Rt(t, u, l)) {
788
+ E(n, "Citation deleted.");
789
+ return;
790
+ }
791
+ qt(t, u, l) && (H(t), E(n, "Removed from recent citations."));
792
+ }
793
+ }), n.addEventListener("keydown", (a) => {
794
+ if (a.key === "Escape") {
795
+ a.preventDefault(), U(t, !0);
796
+ return;
797
+ }
798
+ const s = a.target;
799
+ if (!s || !s.matches(".rte-citations-recent-btn") || a.key !== "ArrowDown" && a.key !== "ArrowUp")
800
+ return;
801
+ const d = Array.from(n.querySelectorAll(".rte-citations-recent-btn"));
802
+ if (d.length === 0)
803
+ return;
804
+ const c = d.indexOf(s);
805
+ if (c < 0)
806
+ return;
807
+ a.preventDefault();
808
+ const l = a.key === "ArrowDown" ? 1 : -1, u = (c + l + d.length) % d.length;
809
+ d[u].focus();
810
+ });
811
+ const r = C(n, "style");
812
+ return r == null || r.addEventListener("change", () => {
813
+ const a = f.get(t) || M || e, s = r.value;
814
+ Nt(t, s, a), E(n, `Style changed to ${s.toUpperCase()}.`);
815
+ }), tt(n, t), document.body.appendChild(n), v.set(t, n), V.set(t, !1), H(t), n;
816
+ }
817
+ function z(t) {
818
+ const o = ne(t);
819
+ Qt(t), o.classList.add("show"), V.set(t, !0), it(t, "toggleCitationsPanel", !0), tt(o, t), ct(t, o), H(t);
820
+ const e = C(o, "author");
821
+ e == null || e.focus();
822
+ }
823
+ function zt(t, o) {
824
+ const e = nt(t);
825
+ return (typeof o == "boolean" ? o : !e) ? z(t) : U(t, !1), !0;
826
+ }
827
+ function oe(t) {
828
+ const o = t.key.toLowerCase();
829
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && o === "c";
830
+ }
831
+ function ie(t) {
832
+ const o = t.key.toLowerCase();
833
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && o === "b";
834
+ }
835
+ function re(t) {
836
+ const o = t.key.toLowerCase();
837
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && o === "j";
838
+ }
839
+ function ae(t) {
840
+ M = t, I || (I = (o) => {
841
+ const e = o.target, i = e == null ? void 0 : e.closest($);
842
+ if (!i)
843
+ return;
844
+ p = i, f.has(i) || f.set(i, t), T.has(i) || T.set(i, t.defaultStyle);
845
+ const n = v.get(i);
846
+ n && (tt(n, i), ct(i, n)), it(i, "toggleCitationsPanel", nt(i));
847
+ }, document.addEventListener("focusin", I, !0)), B || (B = (o) => {
848
+ const e = o.target, i = e == null ? void 0 : e.closest($);
849
+ i && (p = i, kt(i));
850
+ }, document.addEventListener("input", B, !0)), O || (O = (o) => {
851
+ if (o.defaultPrevented)
852
+ return;
853
+ const e = o.target, i = !!(e != null && e.closest(`.${m} input, .${m} textarea, .${m} select`)), n = h(void 0, !1);
854
+ if (!n || S(n))
855
+ return;
856
+ const r = f.get(n) || M || t;
857
+ if (f.set(n, r), p = n, o.key === "Escape" && nt(n)) {
858
+ o.preventDefault(), U(n, !0);
859
+ return;
860
+ }
861
+ if (!i && !Xt(o, n, r)) {
862
+ if (oe(o)) {
863
+ o.preventDefault(), o.stopPropagation(), zt(n);
864
+ return;
865
+ }
866
+ if (ie(o)) {
867
+ o.preventDefault(), o.stopPropagation(), y(n, r, !0), z(n);
868
+ return;
869
+ }
870
+ re(o) && (o.preventDefault(), o.stopPropagation(), bt(n, r));
871
+ }
872
+ }, document.addEventListener("keydown", O, !0)), k || (k = () => {
873
+ v.forEach((o, e) => {
874
+ if (!e.isConnected || !o.isConnected) {
875
+ At(e), o.remove(), v.delete(e), V.delete(e);
876
+ return;
877
+ }
878
+ tt(o, e), ct(e, o);
879
+ });
880
+ }, window.addEventListener("scroll", k, !0), window.addEventListener("resize", k));
881
+ }
882
+ function se() {
883
+ I && (document.removeEventListener("focusin", I, !0), I = null), B && (document.removeEventListener("input", B, !0), B = null), O && (document.removeEventListener("keydown", O, !0), O = null), k && (window.removeEventListener("scroll", k, !0), window.removeEventListener("resize", k), k = null), v.forEach((t) => t.remove()), v.clear(), M = null, p = null;
884
+ }
885
+ function ce() {
886
+ if (typeof document == "undefined" || document.getElementById(gt))
887
+ return;
888
+ const t = document.createElement("style");
889
+ t.id = gt, t.textContent = `
890
+ .rte-toolbar-group-items.citations,
891
+ .editora-toolbar-group-items.citations {
892
+ display: flex;
893
+ border: 1px solid #ccc;
894
+ border-radius: 3px;
895
+ background: #fff;
896
+ }
897
+
898
+ .rte-toolbar-group-items.citations .rte-toolbar-button,
899
+ .editora-toolbar-group-items.citations .editora-toolbar-button {
900
+ border: none;
901
+ border-radius: 0;
902
+ border-right: 1px solid #ccc;
903
+ }
904
+
905
+ .rte-toolbar-group-items.citations .rte-toolbar-item:last-child .rte-toolbar-button,
906
+ .editora-toolbar-group-items.citations .editora-toolbar-item:last-child .editora-toolbar-button {
907
+ border-right: none;
908
+ }
909
+
910
+ .rte-toolbar-button[data-command="toggleCitationsPanel"].active,
911
+ .editora-toolbar-button[data-command="toggleCitationsPanel"].active {
912
+ background: #ccc;
913
+ }
914
+
915
+ ${x} .rte-toolbar-group-items.citations,
916
+ ${x} .editora-toolbar-group-items.citations,
917
+ .${m}.rte-citations-theme-dark {
918
+ border-color: #566275;
919
+ }
920
+
921
+ ${x} .rte-toolbar-group-items.citations .rte-toolbar-button[data-command="refreshCitations"] svg,
922
+ ${x} .editora-toolbar-group-items.citations .editora-toolbar-button[data-command="refreshCitations"] svg
923
+ {
924
+ fill: none;
925
+ }
926
+ ${x} .rte-toolbar-group-items.citations .rte-toolbar-button,
927
+ ${x} .editora-toolbar-group-items.citations .editora-toolbar-button
928
+ {
929
+ border-color: #566275;
930
+ }
931
+ ${x} .rte-toolbar-button[data-command="toggleCitationsPanel"].active,
932
+ ${x} .editora-toolbar-button[data-command="toggleCitationsPanel"].active {
933
+ background: linear-gradient(180deg, #5eaaf6 0%, #4a95de 100%);
934
+ }
935
+ .${m} {
936
+ position: fixed;
937
+ z-index: 1500;
938
+ right: 16px;
939
+ top: 16px;
940
+ width: min(380px, calc(100vw - 20px));
941
+ max-height: calc(100vh - 24px);
942
+ display: none;
943
+ flex-direction: column;
944
+ border-radius: 12px;
945
+ border: 1px solid #d1d5db;
946
+ background: #ffffff;
947
+ color: #0f172a;
948
+ box-shadow: 0 18px 38px rgba(15, 23, 42, 0.16);
949
+ overflow: hidden;
950
+ }
951
+
952
+ .${m}.show {
953
+ display: flex;
954
+ }
955
+
956
+ .${m}.rte-citations-theme-dark {
957
+ background: #0f172a;
958
+ color: #e2e8f0;
959
+ border-color: #334155;
960
+ box-shadow: 0 20px 40px rgba(2, 6, 23, 0.5);
961
+ }
962
+
963
+ .rte-citations-header {
964
+ display: flex;
965
+ align-items: center;
966
+ justify-content: space-between;
967
+ padding: 10px 12px;
968
+ border-bottom: 1px solid #e2e8f0;
969
+ background: #f8fafc;
970
+ }
971
+
972
+ .${m}.rte-citations-theme-dark .rte-citations-header {
973
+ border-bottom-color: #334155;
974
+ background: #111827;
975
+ }
976
+
977
+ .rte-citations-title {
978
+ margin: 0;
979
+ font-size: 14px;
980
+ font-weight: 700;
981
+ }
982
+
983
+ .rte-citations-icon-btn {
984
+ border: 1px solid #cbd5e1;
985
+ background: #ffffff;
986
+ color: #0f172a;
987
+ border-radius: 6px;
988
+ cursor: pointer;
989
+ min-width: 34px;
990
+ min-height: 34px;
991
+ width: 34px;
992
+ height: 34px;
993
+ padding: 0;
994
+ display: inline-flex;
995
+ align-items: center;
996
+ justify-content: center;
997
+ font-size: 16px;
998
+ line-height: 1;
999
+ font-weight: 600;
1000
+ }
1001
+
1002
+ .rte-citations-icon-btn:hover,
1003
+ .rte-citations-icon-btn:focus-visible {
1004
+ outline: none;
1005
+ border-color: #3b82f6;
1006
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
1007
+ }
1008
+
1009
+ .${m}.rte-citations-theme-dark .rte-citations-icon-btn {
1010
+ background: #0f172a;
1011
+ border-color: #475569;
1012
+ color: #e2e8f0;
1013
+ }
1014
+
1015
+ .${m}.rte-citations-theme-dark .rte-citations-icon-btn:hover,
1016
+ .${m}.rte-citations-theme-dark .rte-citations-icon-btn:focus-visible {
1017
+ border-color: #60a5fa;
1018
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
1019
+ }
1020
+
1021
+ .rte-citations-body {
1022
+ display: flex;
1023
+ flex-direction: column;
1024
+ gap: 10px;
1025
+ padding: 12px;
1026
+ overflow: auto;
1027
+ }
1028
+
1029
+ .rte-citations-status {
1030
+ margin: 0;
1031
+ font-size: 12px;
1032
+ color: #475569;
1033
+ }
1034
+
1035
+ .${m}.rte-citations-theme-dark .rte-citations-status {
1036
+ color: #94a3b8;
1037
+ }
1038
+
1039
+ .rte-citations-grid {
1040
+ display: grid;
1041
+ grid-template-columns: 1fr 1fr;
1042
+ gap: 8px;
1043
+ }
1044
+
1045
+ .rte-citations-label {
1046
+ display: flex;
1047
+ flex-direction: column;
1048
+ gap: 4px;
1049
+ font-size: 12px;
1050
+ font-weight: 600;
1051
+ color: inherit;
1052
+ }
1053
+
1054
+ .rte-citations-label-note {
1055
+ grid-column: 1 / -1;
1056
+ }
1057
+
1058
+ .rte-citations-field {
1059
+ width: 100%;
1060
+ box-sizing: border-box;
1061
+ min-height: 30px;
1062
+ border-radius: 8px;
1063
+ border: 1px solid #cbd5e1;
1064
+ background: #ffffff;
1065
+ color: inherit;
1066
+ font-size: 13px;
1067
+ padding: 6px 8px;
1068
+ }
1069
+
1070
+ .rte-citations-field:focus-visible {
1071
+ outline: none;
1072
+ border-color: #1d4ed8;
1073
+ box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.2);
1074
+ }
1075
+
1076
+ .${m}.rte-citations-theme-dark .rte-citations-field {
1077
+ border-color: #334155;
1078
+ background: #0b1220;
1079
+ color: #e2e8f0;
1080
+ }
1081
+
1082
+ .rte-citations-controls {
1083
+ display: flex;
1084
+ flex-wrap: wrap;
1085
+ gap: 8px;
1086
+ }
1087
+
1088
+ .rte-citations-btn {
1089
+ border: 1px solid #cbd5e1;
1090
+ background: #f8fafc;
1091
+ color: inherit;
1092
+ border-radius: 8px;
1093
+ padding: 6px 10px;
1094
+ font-size: 12px;
1095
+ font-weight: 600;
1096
+ cursor: pointer;
1097
+ }
1098
+
1099
+ .rte-citations-btn:hover,
1100
+ .rte-citations-btn:focus-visible {
1101
+ outline: none;
1102
+ border-color: #1d4ed8;
1103
+ box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.2);
1104
+ }
1105
+
1106
+ .rte-citations-btn-primary {
1107
+ background: #1d4ed8;
1108
+ border-color: #1d4ed8;
1109
+ color: #ffffff;
1110
+ }
1111
+
1112
+ .rte-citations-btn-primary:hover,
1113
+ .rte-citations-btn-primary:focus-visible {
1114
+ background: #1e40af;
1115
+ border-color: #1e40af;
1116
+ }
1117
+
1118
+ .${m}.rte-citations-theme-dark .rte-citations-btn {
1119
+ border-color: #334155;
1120
+ background: #0b1220;
1121
+ color: #e2e8f0;
1122
+ }
1123
+
1124
+ .${m}.rte-citations-theme-dark .rte-citations-btn-primary {
1125
+ border-color: #2563eb;
1126
+ background: #2563eb;
1127
+ color: #ffffff;
1128
+ }
1129
+
1130
+ .rte-citations-recent {
1131
+ border: 1px solid #e2e8f0;
1132
+ border-radius: 10px;
1133
+ padding: 8px;
1134
+ }
1135
+
1136
+ .${m}.rte-citations-theme-dark .rte-citations-recent {
1137
+ border-color: #334155;
1138
+ }
1139
+
1140
+ .rte-citations-recent-heading {
1141
+ margin: 0 0 8px;
1142
+ font-size: 12px;
1143
+ font-weight: 700;
1144
+ }
1145
+
1146
+ .rte-citations-recent-list {
1147
+ margin: 0;
1148
+ padding: 0;
1149
+ list-style: none;
1150
+ display: flex;
1151
+ flex-direction: column;
1152
+ gap: 6px;
1153
+ max-height: 170px;
1154
+ overflow: auto;
1155
+ }
1156
+
1157
+ .rte-citations-recent-btn {
1158
+ width: 100%;
1159
+ text-align: left;
1160
+ border: 1px solid #cbd5e1;
1161
+ background: #ffffff;
1162
+ color: inherit;
1163
+ border-radius: 8px;
1164
+ padding: 7px;
1165
+ cursor: pointer;
1166
+ display: flex;
1167
+ flex-direction: column;
1168
+ gap: 2px;
1169
+ }
1170
+
1171
+ .rte-citations-recent-row {
1172
+ display: flex;
1173
+ gap: 6px;
1174
+ align-items: stretch;
1175
+ }
1176
+
1177
+ .rte-citations-recent-delete {
1178
+ flex: 0 0 auto;
1179
+ border: 1px solid #fecaca;
1180
+ background: #fff1f2;
1181
+ color: #b91c1c;
1182
+ border-radius: 8px;
1183
+ padding: 0 8px;
1184
+ font-size: 11px;
1185
+ font-weight: 700;
1186
+ cursor: pointer;
1187
+ min-height: 34px;
1188
+ }
1189
+
1190
+ .rte-citations-recent-delete:hover,
1191
+ .rte-citations-recent-delete:focus-visible {
1192
+ outline: none;
1193
+ border-color: #f87171;
1194
+ box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.2);
1195
+ }
1196
+
1197
+ .rte-citations-recent-btn:focus-visible,
1198
+ .rte-citations-recent-btn:hover {
1199
+ outline: none;
1200
+ border-color: #1d4ed8;
1201
+ box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.18);
1202
+ }
1203
+
1204
+ .${m}.rte-citations-theme-dark .rte-citations-recent-btn {
1205
+ border-color: #334155;
1206
+ background: #0b1220;
1207
+ color: #e2e8f0;
1208
+ }
1209
+
1210
+ .${m}.rte-citations-theme-dark .rte-citations-recent-delete {
1211
+ border-color: #7f1d1d;
1212
+ background: #2b1218;
1213
+ color: #fca5a5;
1214
+ }
1215
+
1216
+ .rte-citations-recent-title {
1217
+ font-size: 12px;
1218
+ font-weight: 700;
1219
+ line-height: 1.3;
1220
+ }
1221
+
1222
+ .rte-citations-recent-meta {
1223
+ font-size: 11px;
1224
+ color: #64748b;
1225
+ line-height: 1.3;
1226
+ }
1227
+
1228
+ .${m}.rte-citations-theme-dark .rte-citations-recent-meta {
1229
+ color: #94a3b8;
1230
+ }
1231
+
1232
+ .rte-citations-empty {
1233
+ border: 1px dashed #cbd5e1;
1234
+ border-radius: 8px;
1235
+ padding: 8px;
1236
+ font-size: 12px;
1237
+ color: #64748b;
1238
+ }
1239
+
1240
+ .${m}.rte-citations-theme-dark .rte-citations-empty {
1241
+ border-color: #334155;
1242
+ color: #94a3b8;
1243
+ }
1244
+
1245
+ .rte-citations-shortcut {
1246
+ margin: 0;
1247
+ font-size: 11px;
1248
+ color: #64748b;
1249
+ }
1250
+
1251
+ .${m}.rte-citations-theme-dark .rte-citations-shortcut {
1252
+ color: #94a3b8;
1253
+ }
1254
+
1255
+ .rte-citations-live {
1256
+ position: absolute;
1257
+ width: 1px;
1258
+ height: 1px;
1259
+ margin: -1px;
1260
+ padding: 0;
1261
+ overflow: hidden;
1262
+ clip: rect(0 0 0 0);
1263
+ border: 0;
1264
+ }
1265
+
1266
+ .rte-citation-ref {
1267
+ display: inline-flex;
1268
+ align-items: center;
1269
+ border-radius: 6px;
1270
+ border: 1px solid rgba(29, 78, 216, 0.24);
1271
+ background: rgba(29, 78, 216, 0.08);
1272
+ color: #1e3a8a;
1273
+ padding: 0 4px;
1274
+ margin: 0 1px;
1275
+ font-size: 0.92em;
1276
+ line-height: 1.35;
1277
+ white-space: nowrap;
1278
+ cursor: pointer;
1279
+ user-select: all;
1280
+ }
1281
+
1282
+ .rte-citation-ref:focus,
1283
+ .rte-citation-ref:focus-visible {
1284
+ outline: none;
1285
+ border-color: #1d4ed8;
1286
+ box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.22);
1287
+ }
1288
+
1289
+ .${x} .rte-citation-ref {
1290
+ border-color: rgba(96, 165, 250, 0.45);
1291
+ background: rgba(37, 99, 235, 0.22);
1292
+ color: #bfdbfe;
1293
+ }
1294
+
1295
+ .rte-citation-bibliography,
1296
+ .rte-citation-footnotes {
1297
+ margin-top: 16px;
1298
+ border-top: 1px solid #d1d5db;
1299
+ padding-top: 10px;
1300
+ }
1301
+
1302
+ .${x} .rte-citation-bibliography,
1303
+ .${x} .rte-citation-footnotes {
1304
+ border-top-color: #475569;
1305
+ }
1306
+
1307
+ .rte-citation-section-title {
1308
+ margin: 0 0 8px;
1309
+ font-size: 1em;
1310
+ font-weight: 700;
1311
+ }
1312
+
1313
+ .rte-citation-list {
1314
+ margin: 0;
1315
+ padding-left: 22px;
1316
+ }
1317
+
1318
+ .rte-citation-item {
1319
+ margin: 0 0 8px;
1320
+ line-height: 1.45;
1321
+ }
1322
+
1323
+ .rte-citation-backref {
1324
+ margin-left: 8px;
1325
+ color: #1d4ed8;
1326
+ text-decoration: none;
1327
+ font-size: 0.9em;
1328
+ }
1329
+
1330
+ .rte-citation-backref:hover,
1331
+ .rte-citation-backref:focus-visible {
1332
+ text-decoration: underline;
1333
+ outline: none;
1334
+ }
1335
+
1336
+ .${x} .rte-citation-backref {
1337
+ color: #93c5fd;
1338
+ }
1339
+
1340
+ @media (max-width: 768px) {
1341
+ .${m} {
1342
+ left: 10px !important;
1343
+ right: 10px;
1344
+ top: 10px !important;
1345
+ width: auto !important;
1346
+ max-height: calc(100vh - 20px);
1347
+ }
1348
+
1349
+ .rte-citations-grid {
1350
+ grid-template-columns: 1fr;
1351
+ }
1352
+
1353
+ .rte-citations-recent-list {
1354
+ max-height: 34vh;
1355
+ }
1356
+ }
1357
+ `, document.head.appendChild(t);
1358
+ }
1359
+ const le = (t = {}) => {
1360
+ const o = Z(t);
1361
+ return ce(), {
1362
+ name: "citations",
1363
+ toolbar: [
1364
+ {
1365
+ id: "citationsGroup",
1366
+ label: "Citations",
1367
+ type: "group",
1368
+ command: "citations",
1369
+ items: [
1370
+ {
1371
+ id: "citations",
1372
+ label: "Citations",
1373
+ command: "toggleCitationsPanel",
1374
+ shortcut: "Mod-Alt-Shift-c",
1375
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12M6 9h12M6 13h8M6 17h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17 14.5a2.5 2.5 0 0 1 2.5 2.5v2H15v-2a2 2 0 0 1 2-2Z" stroke="currentColor" stroke-width="1.5"/></svg>'
1376
+ },
1377
+ {
1378
+ id: "citationsRefresh",
1379
+ label: "Refresh Citations",
1380
+ command: "refreshCitations",
1381
+ shortcut: "Mod-Alt-Shift-b",
1382
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.34-5.66" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M20 4v6h-6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'
1383
+ },
1384
+ {
1385
+ id: "citationsStyle",
1386
+ label: "Cycle Citation Style",
1387
+ command: "cycleCitationStyle",
1388
+ shortcut: "Mod-Alt-Shift-j",
1389
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 6h14M5 10h8M5 14h14M5 18h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="18" cy="10" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'
1390
+ }
1391
+ ]
1392
+ }
1393
+ ],
1394
+ commands: {
1395
+ citations: (e, i) => {
1396
+ const n = h(i);
1397
+ if (!n || S(n))
1398
+ return !1;
1399
+ const r = f.get(n) || o;
1400
+ return f.set(n, r), T.set(n, N(n, r)), p = n, z(n), y(n, r, !1), !0;
1401
+ },
1402
+ toggleCitationsPanel: (e, i) => {
1403
+ const n = h(i);
1404
+ if (!n || S(n))
1405
+ return !1;
1406
+ const r = f.get(n) || o;
1407
+ f.set(n, r), p = n;
1408
+ const a = zt(n, typeof e == "boolean" ? e : void 0);
1409
+ return nt(n) && y(n, r, !1), a;
1410
+ },
1411
+ insertCitation: (e, i) => {
1412
+ const n = h(i);
1413
+ if (!n || S(n) || !e || typeof e != "object")
1414
+ return !1;
1415
+ const r = f.get(n) || o;
1416
+ f.set(n, r), p = n;
1417
+ const a = et(n, e, r);
1418
+ return a && z(n), a;
1419
+ },
1420
+ refreshCitations: (e, i) => {
1421
+ const n = h(i);
1422
+ if (!n)
1423
+ return !1;
1424
+ const r = f.get(n) || o;
1425
+ return f.set(n, r), p = n, y(n, r, !0), z(n), !0;
1426
+ },
1427
+ setCitationStyle: (e, i) => {
1428
+ const n = h(i);
1429
+ if (!n || !e)
1430
+ return !1;
1431
+ const r = f.get(n) || o;
1432
+ return f.set(n, r), p = n, Nt(n, e, r), !0;
1433
+ },
1434
+ cycleCitationStyle: (e, i) => {
1435
+ const n = h(i);
1436
+ if (!n)
1437
+ return !1;
1438
+ const r = f.get(n) || o;
1439
+ return f.set(n, r), p = n, bt(n, r), H(n), !0;
1440
+ },
1441
+ getCitationRecords: (e, i) => {
1442
+ const n = h(i);
1443
+ if (!n)
1444
+ return !1;
1445
+ const r = f.get(n) || o, a = K(n, r);
1446
+ if (typeof e == "function")
1447
+ try {
1448
+ e(a);
1449
+ } catch (s) {
1450
+ }
1451
+ return n.__citationRecords = a, n.dispatchEvent(
1452
+ new CustomEvent("editora:citations-data", {
1453
+ bubbles: !0,
1454
+ detail: {
1455
+ records: a,
1456
+ style: N(n, r)
1457
+ }
1458
+ })
1459
+ ), !0;
1460
+ },
1461
+ setCitationsOptions: (e, i) => {
1462
+ const n = h(i);
1463
+ if (!n || !e || typeof e != "object")
1464
+ return !1;
1465
+ const r = f.get(n) || o, a = Z({
1466
+ ...r,
1467
+ ...e,
1468
+ labels: {
1469
+ ...r.labels,
1470
+ ...e.labels || {}
1471
+ },
1472
+ normalizeText: e.normalizeText || r.normalizeText,
1473
+ generateCitationId: e.generateCitationId || r.generateCitationId
1474
+ });
1475
+ return f.set(n, a), e.defaultStyle && L.includes(e.defaultStyle) && T.set(n, e.defaultStyle), y(n, a, !0), H(n), !0;
1476
+ },
1477
+ locateCitation: (e, i) => {
1478
+ const n = h(i);
1479
+ return !n || typeof e != "string" ? !1 : Zt(n, e);
1480
+ },
1481
+ deleteCitation: (e, i) => {
1482
+ const n = h(i);
1483
+ if (!n || S(n))
1484
+ return !1;
1485
+ const r = f.get(n) || o;
1486
+ return f.set(n, r), typeof e == "string" && e.trim() ? Rt(n, e, r) : Jt(n, r);
1487
+ },
1488
+ insertRecentCitation: (e, i) => {
1489
+ const n = h(i);
1490
+ if (!n || S(n))
1491
+ return !1;
1492
+ const r = f.get(n) || o;
1493
+ f.set(n, r);
1494
+ const a = K(n, r), s = rt(n, a, r);
1495
+ if (s.length === 0)
1496
+ return !1;
1497
+ const d = typeof e == "string" && e.trim() ? Et(n, e, a, r) : s[0];
1498
+ if (!d)
1499
+ return !1;
1500
+ const c = et(n, d, r);
1501
+ return c && z(n), c;
1502
+ }
1503
+ },
1504
+ keymap: {
1505
+ "Mod-Alt-Shift-c": "toggleCitationsPanel",
1506
+ "Mod-Alt-Shift-C": "toggleCitationsPanel",
1507
+ "Mod-Alt-Shift-b": "refreshCitations",
1508
+ "Mod-Alt-Shift-B": "refreshCitations",
1509
+ "Mod-Alt-Shift-j": "cycleCitationStyle",
1510
+ "Mod-Alt-Shift-J": "cycleCitationStyle"
1511
+ },
1512
+ init: function(i) {
1513
+ Y += 1;
1514
+ const n = this && typeof this.__pluginConfig == "object" ? Z({ ...o, ...this.__pluginConfig }) : o;
1515
+ ae(n);
1516
+ const r = h(
1517
+ i && i.editorElement ? { editorElement: i.editorElement } : void 0,
1518
+ !1
1519
+ );
1520
+ r && (p = r, f.set(r, n), T.set(r, n.defaultStyle), it(r, "toggleCitationsPanel", !1), kt(r));
1521
+ },
1522
+ destroy: () => {
1523
+ Y = Math.max(0, Y - 1), !(Y > 0) && (q.forEach((e) => {
1524
+ window.clearTimeout(e);
1525
+ }), q.clear(), se());
1526
+ }
1527
+ };
1528
+ };
1529
+ export {
1530
+ le as CitationsPlugin
1531
+ };
1532
+ //# sourceMappingURL=CitationsPlugin.native-169fb1e8.mjs.map