@editora/plugins 1.0.8 → 1.0.10

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