eddyter 1.4.16 → 1.4.18

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 (45) hide show
  1. package/dist/AIChatPlugin-DsUPycjT.js +872 -0
  2. package/dist/CombinedAutocompletGrammarPlugin-BXOz6IRb.js +1778 -0
  3. package/dist/{CommentBubblePlugin-DZQW1ibY.js → CommentBubblePlugin-kiMehQkL.js} +5 -5
  4. package/dist/CommentPlugin-DIuM-Jao.js +154 -0
  5. package/dist/LazyCodeMirror-DdCIk-83.js +21374 -0
  6. package/dist/{LazySignatureCanvas-FKl1mD-T.js → LazySignatureCanvas-BtcxlSTW.js} +1 -1
  7. package/dist/NotePanelPlugin-FirMseLu.js +31 -0
  8. package/dist/TextEnhancePlugin-oXbL_F1i.js +199 -0
  9. package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
  10. package/dist/assets/style.css +1 -1
  11. package/dist/components/AiPlugin/commands.d.ts +4 -0
  12. package/dist/components/AiPlugin/index.d.ts +0 -4
  13. package/dist/components/CommentToggle/CommentToggle.d.ts +1 -0
  14. package/dist/components/ConfigurableEditorWithAuth.d.ts +2 -0
  15. package/dist/editor/components/FloatingToolbarManager.d.ts +2 -1
  16. package/dist/editor/components/ToolbarMount.d.ts +2 -1
  17. package/dist/{generateDocxThumbnail-DJlPLsdY.js → generateDocxThumbnail-RE7yNAXP.js} +7 -6
  18. package/dist/{generatePdfThumbnail-CfDAh39b.js → generatePdfThumbnail-CnldK2yE.js} +4 -4
  19. package/dist/{generateXlsxThumbnail-cRIT4Jyf.js → generateXlsxThumbnail-BpBB4ePK.js} +1 -1
  20. package/dist/{html2pdf.bundle.min-BW3dolOS.js → html2pdf.bundle.min-u-o_L5zA.js} +1 -1
  21. package/dist/{index-BEepnYCf.js → index-B4W_mfNI.js} +15 -15
  22. package/dist/{index-gjz4wieB.js → index-C8ZUqYRj.js} +56 -56
  23. package/dist/{index-W6_ogglw.js → index-CKRp6axU.js} +28 -28
  24. package/dist/{index-BydXFu_2.js → index-CL0adQ5R.js} +1 -1
  25. package/dist/{index-BDDjWwK4.js → index-CXyZgoBl.js} +16862 -21806
  26. package/dist/{index-BmfQcIrc.js → index-DZAvLKar.js} +118 -116
  27. package/dist/index-F2-F96Nx.js +720 -0
  28. package/dist/index.js +3 -3
  29. package/dist/marked.esm-Tjr8Gfse.js +1114 -0
  30. package/dist/pages/ConfigurableEditor/ConfigurableEditor.d.ts +1 -0
  31. package/dist/plugins/AIChatPlugin.commands.d.ts +7 -0
  32. package/dist/plugins/AIChatPlugin.d.ts +0 -7
  33. package/dist/plugins/CommentPlugin.commands.d.ts +5 -0
  34. package/dist/plugins/CommentPlugin.d.ts +0 -5
  35. package/dist/plugins/NotePanelPlugin.commands.d.ts +6 -0
  36. package/dist/plugins/NotePanelPlugin.d.ts +0 -6
  37. package/dist/plugins/TextEnhancePlugin.commands.d.ts +1 -0
  38. package/dist/plugins/TextEnhancePlugin.d.ts +0 -1
  39. package/dist/plugins/WordCountPlugin.d.ts +1 -0
  40. package/dist/sparkles-CTAYmQOE.js +17 -0
  41. package/dist/square-CupR-YWR.js +7 -0
  42. package/dist/types.d.ts +1 -0
  43. package/dist/useVoiceToText-U0yKgS5Q.js +153 -0
  44. package/package.json +5 -2
  45. package/dist/LazyCodeMirror-C1bW4mVF.js +0 -44822
@@ -0,0 +1,1778 @@
1
+ import { jsxs as L, Fragment as we, jsx as k } from "react/jsx-runtime";
2
+ import { c as Ce, O as Ee, Q as ve, R as ye, U as Ft, V as $t, W as be, Y as ke, X as Se, Z as Kt, _ as Me, a0 as Ie } from "./index-CXyZgoBl.js";
3
+ import { $isCodeNode as Ne } from "@lexical/code";
4
+ import { useLexicalComposerContext as Re } from "@lexical/react/LexicalComposerContext";
5
+ import { $getRoot as It, $getSelection as Ut, $isRangeSelection as Vt, $isTextNode as lt, $getNodeByKey as zt, $createRangeSelection as Oe, $setSelection as Le, KEY_ARROW_DOWN_COMMAND as Ae, COMMAND_PRIORITY_LOW as st, KEY_ARROW_UP_COMMAND as Be, KEY_ESCAPE_COMMAND as Pe, KEY_TAB_COMMAND as De, KEY_ENTER_COMMAND as _e, createCommand as Te, $isElementNode as He } from "lexical";
6
+ import { g as We } from "./_commonjsHelpers-DaMA6jEr.js";
7
+ import { useRef as B, useState as q, useEffect as T, useCallback as G } from "react";
8
+ import { createPortal as qt } from "react-dom";
9
+ import { S as Fe } from "./sparkles-CTAYmQOE.js";
10
+ const Gt = Ce("BookOpen", [
11
+ ["path", { d: "M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z", key: "vv98re" }],
12
+ ["path", { d: "M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z", key: "1cyq3y" }]
13
+ ]);
14
+ var Et = { exports: {} }, vt = { exports: {} }, Yt;
15
+ function $e() {
16
+ return Yt || (Yt = 1, (function() {
17
+ var o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", t = {
18
+ // Bit-wise rotation left
19
+ rotl: function(e, n) {
20
+ return e << n | e >>> 32 - n;
21
+ },
22
+ // Bit-wise rotation right
23
+ rotr: function(e, n) {
24
+ return e << 32 - n | e >>> n;
25
+ },
26
+ // Swap big-endian to little-endian and vice versa
27
+ endian: function(e) {
28
+ if (e.constructor == Number)
29
+ return t.rotl(e, 8) & 16711935 | t.rotl(e, 24) & 4278255360;
30
+ for (var n = 0; n < e.length; n++)
31
+ e[n] = t.endian(e[n]);
32
+ return e;
33
+ },
34
+ // Generate an array of any length of random bytes
35
+ randomBytes: function(e) {
36
+ for (var n = []; e > 0; e--)
37
+ n.push(Math.floor(Math.random() * 256));
38
+ return n;
39
+ },
40
+ // Convert a byte array to big-endian 32-bit words
41
+ bytesToWords: function(e) {
42
+ for (var n = [], c = 0, d = 0; c < e.length; c++, d += 8)
43
+ n[d >>> 5] |= e[c] << 24 - d % 32;
44
+ return n;
45
+ },
46
+ // Convert big-endian 32-bit words to a byte array
47
+ wordsToBytes: function(e) {
48
+ for (var n = [], c = 0; c < e.length * 32; c += 8)
49
+ n.push(e[c >>> 5] >>> 24 - c % 32 & 255);
50
+ return n;
51
+ },
52
+ // Convert a byte array to a hex string
53
+ bytesToHex: function(e) {
54
+ for (var n = [], c = 0; c < e.length; c++)
55
+ n.push((e[c] >>> 4).toString(16)), n.push((e[c] & 15).toString(16));
56
+ return n.join("");
57
+ },
58
+ // Convert a hex string to a byte array
59
+ hexToBytes: function(e) {
60
+ for (var n = [], c = 0; c < e.length; c += 2)
61
+ n.push(parseInt(e.substr(c, 2), 16));
62
+ return n;
63
+ },
64
+ // Convert a byte array to a base-64 string
65
+ bytesToBase64: function(e) {
66
+ for (var n = [], c = 0; c < e.length; c += 3)
67
+ for (var d = e[c] << 16 | e[c + 1] << 8 | e[c + 2], h = 0; h < 4; h++)
68
+ c * 8 + h * 6 <= e.length * 8 ? n.push(o.charAt(d >>> 6 * (3 - h) & 63)) : n.push("=");
69
+ return n.join("");
70
+ },
71
+ // Convert a base-64 string to a byte array
72
+ base64ToBytes: function(e) {
73
+ e = e.replace(/[^A-Z0-9+\/]/ig, "");
74
+ for (var n = [], c = 0, d = 0; c < e.length; d = ++c % 4)
75
+ d != 0 && n.push((o.indexOf(e.charAt(c - 1)) & Math.pow(2, -2 * d + 8) - 1) << d * 2 | o.indexOf(e.charAt(c)) >>> 6 - d * 2);
76
+ return n;
77
+ }
78
+ };
79
+ vt.exports = t;
80
+ })()), vt.exports;
81
+ }
82
+ var yt, Xt;
83
+ function jt() {
84
+ if (Xt) return yt;
85
+ Xt = 1;
86
+ var o = {
87
+ // UTF-8 encoding
88
+ utf8: {
89
+ // Convert a string to a byte array
90
+ stringToBytes: function(t) {
91
+ return o.bin.stringToBytes(unescape(encodeURIComponent(t)));
92
+ },
93
+ // Convert a byte array to a string
94
+ bytesToString: function(t) {
95
+ return decodeURIComponent(escape(o.bin.bytesToString(t)));
96
+ }
97
+ },
98
+ // Binary encoding
99
+ bin: {
100
+ // Convert a string to a byte array
101
+ stringToBytes: function(t) {
102
+ for (var e = [], n = 0; n < t.length; n++)
103
+ e.push(t.charCodeAt(n) & 255);
104
+ return e;
105
+ },
106
+ // Convert a byte array to a string
107
+ bytesToString: function(t) {
108
+ for (var e = [], n = 0; n < t.length; n++)
109
+ e.push(String.fromCharCode(t[n]));
110
+ return e.join("");
111
+ }
112
+ }
113
+ };
114
+ return yt = o, yt;
115
+ }
116
+ var bt, Jt;
117
+ function Ke() {
118
+ if (Jt) return bt;
119
+ Jt = 1, bt = function(e) {
120
+ return e != null && (o(e) || t(e) || !!e._isBuffer);
121
+ };
122
+ function o(e) {
123
+ return !!e.constructor && typeof e.constructor.isBuffer == "function" && e.constructor.isBuffer(e);
124
+ }
125
+ function t(e) {
126
+ return typeof e.readFloatLE == "function" && typeof e.slice == "function" && o(e.slice(0, 0));
127
+ }
128
+ return bt;
129
+ }
130
+ var Zt;
131
+ function Ue() {
132
+ return Zt || (Zt = 1, (function() {
133
+ var o = $e(), t = jt().utf8, e = Ke(), n = jt().bin, c = function(d, h) {
134
+ d.constructor == String ? h && h.encoding === "binary" ? d = n.stringToBytes(d) : d = t.stringToBytes(d) : e(d) ? d = Array.prototype.slice.call(d, 0) : !Array.isArray(d) && d.constructor !== Uint8Array && (d = d.toString());
135
+ for (var r = o.bytesToWords(d), w = d.length * 8, i = 1732584193, s = -271733879, l = -1732584194, a = 271733878, f = 0; f < r.length; f++)
136
+ r[f] = (r[f] << 8 | r[f] >>> 24) & 16711935 | (r[f] << 24 | r[f] >>> 8) & 4278255360;
137
+ r[w >>> 5] |= 128 << w % 32, r[(w + 64 >>> 9 << 4) + 14] = w;
138
+ for (var M = c._ff, b = c._gg, S = c._hh, I = c._ii, f = 0; f < r.length; f += 16) {
139
+ var J = i, P = s, H = l, Y = a;
140
+ i = M(i, s, l, a, r[f + 0], 7, -680876936), a = M(a, i, s, l, r[f + 1], 12, -389564586), l = M(l, a, i, s, r[f + 2], 17, 606105819), s = M(s, l, a, i, r[f + 3], 22, -1044525330), i = M(i, s, l, a, r[f + 4], 7, -176418897), a = M(a, i, s, l, r[f + 5], 12, 1200080426), l = M(l, a, i, s, r[f + 6], 17, -1473231341), s = M(s, l, a, i, r[f + 7], 22, -45705983), i = M(i, s, l, a, r[f + 8], 7, 1770035416), a = M(a, i, s, l, r[f + 9], 12, -1958414417), l = M(l, a, i, s, r[f + 10], 17, -42063), s = M(s, l, a, i, r[f + 11], 22, -1990404162), i = M(i, s, l, a, r[f + 12], 7, 1804603682), a = M(a, i, s, l, r[f + 13], 12, -40341101), l = M(l, a, i, s, r[f + 14], 17, -1502002290), s = M(s, l, a, i, r[f + 15], 22, 1236535329), i = b(i, s, l, a, r[f + 1], 5, -165796510), a = b(a, i, s, l, r[f + 6], 9, -1069501632), l = b(l, a, i, s, r[f + 11], 14, 643717713), s = b(s, l, a, i, r[f + 0], 20, -373897302), i = b(i, s, l, a, r[f + 5], 5, -701558691), a = b(a, i, s, l, r[f + 10], 9, 38016083), l = b(l, a, i, s, r[f + 15], 14, -660478335), s = b(s, l, a, i, r[f + 4], 20, -405537848), i = b(i, s, l, a, r[f + 9], 5, 568446438), a = b(a, i, s, l, r[f + 14], 9, -1019803690), l = b(l, a, i, s, r[f + 3], 14, -187363961), s = b(s, l, a, i, r[f + 8], 20, 1163531501), i = b(i, s, l, a, r[f + 13], 5, -1444681467), a = b(a, i, s, l, r[f + 2], 9, -51403784), l = b(l, a, i, s, r[f + 7], 14, 1735328473), s = b(s, l, a, i, r[f + 12], 20, -1926607734), i = S(i, s, l, a, r[f + 5], 4, -378558), a = S(a, i, s, l, r[f + 8], 11, -2022574463), l = S(l, a, i, s, r[f + 11], 16, 1839030562), s = S(s, l, a, i, r[f + 14], 23, -35309556), i = S(i, s, l, a, r[f + 1], 4, -1530992060), a = S(a, i, s, l, r[f + 4], 11, 1272893353), l = S(l, a, i, s, r[f + 7], 16, -155497632), s = S(s, l, a, i, r[f + 10], 23, -1094730640), i = S(i, s, l, a, r[f + 13], 4, 681279174), a = S(a, i, s, l, r[f + 0], 11, -358537222), l = S(l, a, i, s, r[f + 3], 16, -722521979), s = S(s, l, a, i, r[f + 6], 23, 76029189), i = S(i, s, l, a, r[f + 9], 4, -640364487), a = S(a, i, s, l, r[f + 12], 11, -421815835), l = S(l, a, i, s, r[f + 15], 16, 530742520), s = S(s, l, a, i, r[f + 2], 23, -995338651), i = I(i, s, l, a, r[f + 0], 6, -198630844), a = I(a, i, s, l, r[f + 7], 10, 1126891415), l = I(l, a, i, s, r[f + 14], 15, -1416354905), s = I(s, l, a, i, r[f + 5], 21, -57434055), i = I(i, s, l, a, r[f + 12], 6, 1700485571), a = I(a, i, s, l, r[f + 3], 10, -1894986606), l = I(l, a, i, s, r[f + 10], 15, -1051523), s = I(s, l, a, i, r[f + 1], 21, -2054922799), i = I(i, s, l, a, r[f + 8], 6, 1873313359), a = I(a, i, s, l, r[f + 15], 10, -30611744), l = I(l, a, i, s, r[f + 6], 15, -1560198380), s = I(s, l, a, i, r[f + 13], 21, 1309151649), i = I(i, s, l, a, r[f + 4], 6, -145523070), a = I(a, i, s, l, r[f + 11], 10, -1120210379), l = I(l, a, i, s, r[f + 2], 15, 718787259), s = I(s, l, a, i, r[f + 9], 21, -343485551), i = i + J >>> 0, s = s + P >>> 0, l = l + H >>> 0, a = a + Y >>> 0;
141
+ }
142
+ return o.endian([i, s, l, a]);
143
+ };
144
+ c._ff = function(d, h, r, w, i, s, l) {
145
+ var a = d + (h & r | ~h & w) + (i >>> 0) + l;
146
+ return (a << s | a >>> 32 - s) + h;
147
+ }, c._gg = function(d, h, r, w, i, s, l) {
148
+ var a = d + (h & w | r & ~w) + (i >>> 0) + l;
149
+ return (a << s | a >>> 32 - s) + h;
150
+ }, c._hh = function(d, h, r, w, i, s, l) {
151
+ var a = d + (h ^ r ^ w) + (i >>> 0) + l;
152
+ return (a << s | a >>> 32 - s) + h;
153
+ }, c._ii = function(d, h, r, w, i, s, l) {
154
+ var a = d + (r ^ (h | ~w)) + (i >>> 0) + l;
155
+ return (a << s | a >>> 32 - s) + h;
156
+ }, c._blocksize = 16, c._digestsize = 16, Et.exports = function(d, h) {
157
+ if (d == null)
158
+ throw new Error("Illegal argument " + d);
159
+ var r = o.wordsToBytes(c(d, h));
160
+ return h && h.asBytes ? r : h && h.asString ? n.bytesToString(r) : o.bytesToHex(r);
161
+ };
162
+ })()), Et.exports;
163
+ }
164
+ var Ve = Ue();
165
+ const ze = /* @__PURE__ */ We(Ve);
166
+ var Qt;
167
+ (function(o) {
168
+ o.Document = "Document", o.DocumentExit = "Document:exit", o.Paragraph = "Paragraph", o.ParagraphExit = "Paragraph:exit", o.BlockQuote = "BlockQuote", o.BlockQuoteExit = "BlockQuote:exit", o.ListItem = "ListItem", o.ListItemExit = "ListItem:exit", o.List = "List", o.ListExit = "List:exit", o.Header = "Header", o.HeaderExit = "Header:exit", o.CodeBlock = "CodeBlock", o.CodeBlockExit = "CodeBlock:exit", o.HtmlBlock = "HtmlBlock", o.HtmlBlockExit = "HtmlBlock:exit", o.HorizontalRule = "HorizontalRule", o.HorizontalRuleExit = "HorizontalRule:exit", o.Comment = "Comment", o.CommentExit = "Comment:exit", o.ReferenceDef = "ReferenceDef", o.ReferenceDefExit = "ReferenceDef:exit", o.Str = "Str", o.StrExit = "Str:exit", o.Break = "Break", o.BreakExit = "Break:exit", o.Emphasis = "Emphasis", o.EmphasisExit = "Emphasis:exit", o.Strong = "Strong", o.StrongExit = "Strong:exit", o.Html = "Html", o.HtmlExit = "Html:exit", o.Link = "Link", o.LinkExit = "Link:exit", o.Image = "Image", o.ImageExit = "Image:exit", o.Code = "Code", o.CodeExit = "Code:exit", o.Delete = "Delete", o.DeleteExit = "Delete:exit", o.Table = "Table", o.TableExit = "Table:exit", o.TableRow = "TableRow", o.TableRowExit = "TableRow:exit", o.TableCell = "TableCell", o.TableCellExit = "TableCell:exit";
169
+ })(Qt || (Qt = {}));
170
+ var ct = {}, U = {}, te;
171
+ function qe() {
172
+ if (te) return U;
173
+ te = 1, Object.defineProperty(U, "__esModule", { value: !0 }), U.binarySearch = U.upperBound = U.lowerBound = U.compare = void 0;
174
+ function o(c, d) {
175
+ return c < d;
176
+ }
177
+ U.compare = o;
178
+ function t(c, d, h = o) {
179
+ let r = c.length, w = 0;
180
+ for (; r; ) {
181
+ let i = r >>> 1, s = w + i;
182
+ h(d, c[s]) ? r = i : (w = s + 1, r -= i + 1);
183
+ }
184
+ return w;
185
+ }
186
+ U.upperBound = t;
187
+ function e(c, d, h = o) {
188
+ let r = c.length, w = 0;
189
+ for (; r; ) {
190
+ let i = r >>> 1, s = w + i;
191
+ h(c[s], d) ? (w = s + 1, r -= i + 1) : r = i;
192
+ }
193
+ return w;
194
+ }
195
+ U.lowerBound = e;
196
+ function n(c, d, h = o) {
197
+ let r = e(c, d, h);
198
+ return r !== c.length && !h(d, c[r]);
199
+ }
200
+ return U.binarySearch = n, U;
201
+ }
202
+ var ee;
203
+ function Ge() {
204
+ if (ee) return ct;
205
+ ee = 1, Object.defineProperty(ct, "__esModule", { value: !0 }), ct.StructuredSource = void 0;
206
+ const o = qe();
207
+ class t {
208
+ /**
209
+ * @constructs StructuredSource
210
+ * @param {string} source - source code text.
211
+ */
212
+ constructor(n) {
213
+ this.indice = [0];
214
+ let c = /[\r\n\u2028\u2029]/g;
215
+ const d = n.length;
216
+ for (c.lastIndex = 0; ; ) {
217
+ let h = c.exec(n);
218
+ if (!h)
219
+ break;
220
+ let r = h.index;
221
+ n.charCodeAt(r) === 13 && n.charCodeAt(r + 1) === 10 && (r += 1);
222
+ let w = r + 1;
223
+ if (d < w)
224
+ break;
225
+ this.indice.push(w), c.lastIndex = w;
226
+ }
227
+ }
228
+ get line() {
229
+ return this.indice.length;
230
+ }
231
+ /**
232
+ * @param {SourceLocation} loc - location indicator.
233
+ * @return {[ number, number ]} range.
234
+ */
235
+ locationToRange(n) {
236
+ return [this.positionToIndex(n.start), this.positionToIndex(n.end)];
237
+ }
238
+ /**
239
+ * @param {[ number, number ]} range - pair of indice.
240
+ * @return {SourceLocation} location.
241
+ */
242
+ rangeToLocation(n) {
243
+ return {
244
+ start: this.indexToPosition(n[0]),
245
+ end: this.indexToPosition(n[1])
246
+ };
247
+ }
248
+ /**
249
+ * @param {SourcePosition} pos - position indicator.
250
+ * @return {number} index.
251
+ */
252
+ positionToIndex(n) {
253
+ return this.indice[n.line - 1] + n.column;
254
+ }
255
+ /**
256
+ * @param {number} index - index to the source code.
257
+ * @return {SourcePosition} position.
258
+ */
259
+ indexToPosition(n) {
260
+ const c = (0, o.upperBound)(this.indice, n);
261
+ return {
262
+ line: c,
263
+ column: n - this.indice[c - 1]
264
+ };
265
+ }
266
+ }
267
+ return ct.StructuredSource = t, ct;
268
+ }
269
+ var re = Ge();
270
+ const Ye = (o, t) => {
271
+ for (let e = o.length - 1; e >= 0; e--)
272
+ if (t(o[e], e, o))
273
+ return e;
274
+ return -1;
275
+ };
276
+ class Xe {
277
+ index = 0;
278
+ source;
279
+ textCharacters;
280
+ sourceNode;
281
+ // active context
282
+ contexts = [];
283
+ // These context is consumed
284
+ // It is used for attaching context to AST
285
+ consumedContexts = [];
286
+ contextRanges = [];
287
+ firstChildPadding;
288
+ startOffset;
289
+ constructor(t) {
290
+ if (typeof t == "string")
291
+ this.textCharacters = t.split(""), this.source = new re.StructuredSource(t), this.startOffset = 0, this.firstChildPadding = 0;
292
+ else {
293
+ this.sourceNode = t, this.startOffset = this.sourceNode.range[0], this.index = this.startOffset;
294
+ const e = Array.from(new Array(this.sourceNode.loc.start.line - 1)).fill(`
295
+ `), n = Array.from(new Array(this.startOffset - e.length)).fill("∯"), c = t.raw.split("");
296
+ this.textCharacters = [...e, ...n, ...c], this.source = new re.StructuredSource(this.textCharacters.join("")), this.sourceNode.children[0] ? this.firstChildPadding = this.sourceNode.children[0].range[0] - this.startOffset : this.firstChildPadding = 0;
297
+ }
298
+ }
299
+ get length() {
300
+ return this.textCharacters.length;
301
+ }
302
+ // range mark is for abbreviation
303
+ markContextRange(t) {
304
+ this.contextRanges.push(t);
305
+ }
306
+ isInContextRange() {
307
+ const t = this.offset;
308
+ return this.contextRanges.some((e) => e[0] <= t && t < e[1]);
309
+ }
310
+ // context is for pair mark
311
+ enterContext(t) {
312
+ this.contexts.push([t, this.index]);
313
+ }
314
+ isInContext(t) {
315
+ return t ? this.contexts.some((e) => e[0].key === t.key) : this.contexts.length > 0;
316
+ }
317
+ leaveContext(t) {
318
+ const e = Ye(this.contexts, (n) => n[0].key === t.key);
319
+ if (e !== -1) {
320
+ const n = this.contexts[e];
321
+ this.contexts.splice(e, 1);
322
+ const c = [n[1], this.index];
323
+ this.consumedContexts.push({
324
+ pairMark: n[0],
325
+ range: [n[1], this.index],
326
+ loc: this.source.rangeToLocation(c)
327
+ });
328
+ }
329
+ }
330
+ /**
331
+ * Return current offset value
332
+ * @returns {number}
333
+ */
334
+ get offset() {
335
+ return this.index + this.firstChildPadding;
336
+ }
337
+ /**
338
+ * Return current position object.
339
+ * It includes line, column, offset.
340
+ */
341
+ now() {
342
+ const t = this.offset, e = this.source.indexToPosition(t);
343
+ return {
344
+ line: e.line,
345
+ column: e.column,
346
+ offset: t
347
+ };
348
+ }
349
+ /**
350
+ * Return true, no more read char
351
+ */
352
+ get hasEnd() {
353
+ return this.read() === !1;
354
+ }
355
+ /**
356
+ * read char
357
+ * if can not read, return empty string
358
+ * @returns {string}
359
+ */
360
+ read(t = 0) {
361
+ const e = this.offset + t;
362
+ return e < this.startOffset ? !1 : 0 <= e && e < this.textCharacters.length ? this.textCharacters[e] : !1;
363
+ }
364
+ /**
365
+ * read node
366
+ * if can not read, return empty string
367
+ * @returns {node}
368
+ */
369
+ readNode(t = 0) {
370
+ if (!this.sourceNode)
371
+ return !1;
372
+ const e = this.offset + t;
373
+ if (e < this.startOffset)
374
+ return !1;
375
+ const n = this.sourceNode.children.filter((c) => c.range[0] <= e && e < c.range[1]);
376
+ return n.length > 0 ? n[n.length - 1] : !1;
377
+ }
378
+ /**
379
+ * Increment current index
380
+ */
381
+ peek() {
382
+ this.index += 1;
383
+ }
384
+ /**
385
+ * Increment node range
386
+ */
387
+ peekNode(t) {
388
+ this.index += t.range[1] - t.range[0];
389
+ }
390
+ /**
391
+ * Seek and Peek
392
+ */
393
+ seekNext(t) {
394
+ const e = this.now();
395
+ t.seek(this);
396
+ const n = this.now();
397
+ return {
398
+ value: this.sliceRange(e.offset, n.offset),
399
+ startPosition: e,
400
+ endPosition: n
401
+ };
402
+ }
403
+ /**
404
+ * Slice text form the range.
405
+ * @param {number} start
406
+ * @param {number} end
407
+ * @returns {string}
408
+ */
409
+ sliceRange(t, e) {
410
+ return this.textCharacters.slice(t, e).join("");
411
+ }
412
+ }
413
+ class je {
414
+ test(t) {
415
+ const e = t.read();
416
+ return e ? /[\r\n]/.test(e) : !1;
417
+ }
418
+ seek(t) {
419
+ for (; this.test(t); )
420
+ t.peek();
421
+ }
422
+ }
423
+ class Je {
424
+ test(t) {
425
+ const e = t.read();
426
+ return e ? /[^\S\n\r]/.test(e) : !1;
427
+ }
428
+ seek(t) {
429
+ for (; this.test(t); )
430
+ t.peek();
431
+ }
432
+ }
433
+ const Ze = {
434
+ separatorCharacters: [
435
+ ".",
436
+ // period
437
+ ".",
438
+ // (ja) zenkaku-period
439
+ "。",
440
+ // (ja) 句点
441
+ "?",
442
+ // question mark
443
+ "!",
444
+ // exclamation mark
445
+ "?",
446
+ // (ja) zenkaku question mark
447
+ "!"
448
+ // (ja) zenkaku exclamation mark
449
+ ]
450
+ };
451
+ class Qe {
452
+ options;
453
+ separatorCharacters;
454
+ constructor(t) {
455
+ this.options = t, this.separatorCharacters = t && t.separatorCharacters ? t.separatorCharacters : Ze.separatorCharacters;
456
+ }
457
+ test(t) {
458
+ if (t.isInContext() || t.isInContextRange())
459
+ return !1;
460
+ const e = t.read(), n = t.read(1);
461
+ return !e || !this.separatorCharacters.includes(e) ? !1 : e === "." && n ? /[\s\t\r\n]/.test(n) : !0;
462
+ }
463
+ seek(t) {
464
+ for (; this.test(t); )
465
+ t.peek();
466
+ }
467
+ }
468
+ const se = typeof process == "object" && process?.env?.DEBUG === "sentence-splitter";
469
+ function tr(o, t) {
470
+ se && console.log("sentence-splitter: " + o, t);
471
+ }
472
+ function ne(...o) {
473
+ se && console.log("sentence-splitter: ", ...o.map((t) => typeof t == "string" ? t.replace(/\n/g, "\\n") : t));
474
+ }
475
+ class er {
476
+ parsers;
477
+ markers;
478
+ /**
479
+ * Eat any value without `parsers.test`
480
+ */
481
+ constructor(t) {
482
+ this.parsers = t.parsers, this.markers = t.markers;
483
+ }
484
+ test(t) {
485
+ return t.hasEnd ? !1 : this.parsers.every((e) => !e.test(t));
486
+ }
487
+ seek(t) {
488
+ const e = t.readNode();
489
+ if (!e) {
490
+ for (; this.test(t); )
491
+ this.markers.forEach((c) => c.mark(t)), t.peek();
492
+ return;
493
+ }
494
+ const n = () => {
495
+ const c = t.offset;
496
+ return e.range[0] <= c && c < e.range[1];
497
+ };
498
+ for (; n() && this.test(t); )
499
+ tr(t.offset, t.read()), this.markers.forEach((c) => c.mark(t)), t.peek();
500
+ }
501
+ }
502
+ const rr = {
503
+ ABBREVIATIONS: [
504
+ "Adj.",
505
+ "Adm.",
506
+ "Adv.",
507
+ "Al.",
508
+ "Ala.",
509
+ "Alta.",
510
+ "Apr.",
511
+ "Arc.",
512
+ "Ariz.",
513
+ "Ark.",
514
+ "Art.",
515
+ "Assn.",
516
+ "Asst.",
517
+ "Attys.",
518
+ "Aug.",
519
+ "Ave.",
520
+ "Bart.",
521
+ "Bld.",
522
+ "Bldg.",
523
+ "Blvd.",
524
+ "Brig.",
525
+ "Bros.",
526
+ "Btw.",
527
+ "Cal.",
528
+ "Calif.",
529
+ "Capt.",
530
+ "Cl.",
531
+ "Cmdr.",
532
+ "Co.",
533
+ "Col.",
534
+ "Colo.",
535
+ "Comdr.",
536
+ "Con.",
537
+ "Conn.",
538
+ "Corp.",
539
+ "Cpl.",
540
+ "Cres.",
541
+ "Ct.",
542
+ "D.phil.",
543
+ "Dak.",
544
+ "Dec.",
545
+ "Del.",
546
+ "Dept.",
547
+ "Det.",
548
+ "Dist.",
549
+ "Dr.",
550
+ "Dr.phil.",
551
+ "Dr.philos.",
552
+ "Drs.",
553
+ "E.g.",
554
+ "Ens.",
555
+ "Esp.",
556
+ "Esq.",
557
+ "Etc.",
558
+ "Exp.",
559
+ "Expy.",
560
+ "Ext.",
561
+ "Feb.",
562
+ "Fed.",
563
+ "Fla.",
564
+ "Ft.",
565
+ "Fwy.",
566
+ "Fy.",
567
+ "Ga.",
568
+ "Gen.",
569
+ "Gov.",
570
+ "Hon.",
571
+ "Hosp.",
572
+ "Hr.",
573
+ "Hway.",
574
+ "Hwy.",
575
+ "I.e.",
576
+ "Ia.",
577
+ "Id.",
578
+ "Ida.",
579
+ "Ill.",
580
+ "Inc.",
581
+ "Ind.",
582
+ "Ing.",
583
+ "Insp.",
584
+ "Is.",
585
+ "Jan.",
586
+ "Jr.",
587
+ "Jul.",
588
+ "Jun.",
589
+ "Kan.",
590
+ "Kans.",
591
+ "Ken.",
592
+ "Ky.",
593
+ "La.",
594
+ "Lt.",
595
+ "Ltd.",
596
+ "Maj.",
597
+ "Man.",
598
+ "Mar.",
599
+ "Mass.",
600
+ "May.",
601
+ "Md.",
602
+ "Me.",
603
+ "Med.",
604
+ "Messrs.",
605
+ "Mex.",
606
+ "Mfg.",
607
+ "Mich.",
608
+ "Min.",
609
+ "Minn.",
610
+ "Miss.",
611
+ "Mlle.",
612
+ "Mm.",
613
+ "Mme.",
614
+ "Mo.",
615
+ "Mont.",
616
+ "Mr.",
617
+ "Mrs.",
618
+ "Ms.",
619
+ "Msgr.",
620
+ "Mssrs.",
621
+ "Mt.",
622
+ "Mtn.",
623
+ "Neb.",
624
+ "Nebr.",
625
+ "Nev.",
626
+ "No.",
627
+ "Nos.",
628
+ "Nov.",
629
+ "Nr.",
630
+ "Oct.",
631
+ "Ok.",
632
+ "Okla.",
633
+ "Ont.",
634
+ "Op.",
635
+ "Ord.",
636
+ "Ore.",
637
+ "P.",
638
+ "Pa.",
639
+ "Pd.",
640
+ "Pde.",
641
+ "Penn.",
642
+ "Penna.",
643
+ "Pfc.",
644
+ "Ph.",
645
+ "Ph.d.",
646
+ "Pl.",
647
+ "Plz.",
648
+ "Pp.",
649
+ "Prof.",
650
+ "Pvt.",
651
+ "Que.",
652
+ "Rd.",
653
+ "Rs.",
654
+ "Ref.",
655
+ "Rep.",
656
+ "Reps.",
657
+ "Res.",
658
+ "Rev.",
659
+ "Rt.",
660
+ "Sask.",
661
+ "Sec.",
662
+ "Sen.",
663
+ "Sens.",
664
+ "Sep.",
665
+ "Sept.",
666
+ "Sfc.",
667
+ "Sgt.",
668
+ "Sr.",
669
+ "St.",
670
+ "Supt.",
671
+ "Surg.",
672
+ "Tce.",
673
+ "Tenn.",
674
+ "Tex.",
675
+ "Univ.",
676
+ "Usafa.",
677
+ "U.S.",
678
+ "Ut.",
679
+ "Va.",
680
+ "V.",
681
+ "Ver.",
682
+ "Vs.",
683
+ "Vt.",
684
+ "Wash.",
685
+ "Wis.",
686
+ "Wisc.",
687
+ "Wy.",
688
+ "Wyo.",
689
+ "Yuk."
690
+ ],
691
+ PREPOSITIVE_ABBREVIATIONS: [
692
+ "Adm.",
693
+ "Attys.",
694
+ "Brig.",
695
+ "Capt.",
696
+ "Cmdr.",
697
+ "Col.",
698
+ "Cpl.",
699
+ "Det.",
700
+ "Dr.",
701
+ "Gen.",
702
+ "Gov.",
703
+ "Ing.",
704
+ "Lt.",
705
+ "Maj.",
706
+ "Mr.",
707
+ "Mrs.",
708
+ "Ms.",
709
+ "Mt.",
710
+ "Messrs.",
711
+ "Mssrs.",
712
+ "Prof.",
713
+ "Ph.",
714
+ "Rep.",
715
+ "Reps.",
716
+ "Rev.",
717
+ "Sen.",
718
+ "Sens.",
719
+ "Sgt.",
720
+ "St.",
721
+ "Supt.",
722
+ "V.",
723
+ "Vs."
724
+ ],
725
+ EXCLAMATION_WORDS: [
726
+ "!Xũ",
727
+ "!Kung",
728
+ "ǃʼOǃKung",
729
+ "!Xuun",
730
+ "!Kung-Ekoka",
731
+ "ǃHu",
732
+ "ǃKhung",
733
+ "ǃKu",
734
+ "ǃung",
735
+ "ǃXo",
736
+ "ǃXû",
737
+ "ǃXung",
738
+ "ǃXũ",
739
+ "!Xun",
740
+ "Yahoo!",
741
+ "Y!J",
742
+ "Yum!"
743
+ ]
744
+ }, kt = (o) => !o || o.length === 0 ? !1 : new RegExp("^\\p{Uppercase_Letter}", "u").test(o), St = (o, t) => o.toLowerCase() === t.toLowerCase(), nr = {
745
+ language: rr
746
+ };
747
+ class or {
748
+ options;
749
+ lang;
750
+ constructor(t) {
751
+ this.options = t, this.lang = t && t.language ? t.language : nr.language;
752
+ }
753
+ /**
754
+ * Get Word
755
+ * word should have left space and right space,
756
+ * @param {SourceCode} sourceCode
757
+ * @param {number} startIndex
758
+ * @returns {string}
759
+ */
760
+ getWord(t, e = 0) {
761
+ const n = /\s/, c = t.read(-1);
762
+ if (c && !n.test(c))
763
+ return "";
764
+ let d = "", h = e, r = "";
765
+ for (; (r = t.read(h)) && !n.test(r); )
766
+ d += r, h++;
767
+ return d;
768
+ }
769
+ getPrevWord(t) {
770
+ const e = /\s/;
771
+ let n = -1, c = "";
772
+ for (; (c = t.read(n)) && e.test(c); )
773
+ n--;
774
+ for (; (c = t.read(n)) && !e.test(c); )
775
+ n--;
776
+ return this.getWord(t, n + 1);
777
+ }
778
+ mark(t) {
779
+ if (t.isInContextRange())
780
+ return;
781
+ const e = this.getWord(t);
782
+ if (e.length === 0)
783
+ return;
784
+ if (/^([a-zA-Z]\.){3,}$/.test(e))
785
+ return t.markContextRange([t.offset, t.offset + e.length]);
786
+ if (this.lang.EXCLAMATION_WORDS.some((i) => St(i, e)))
787
+ return t.markContextRange([t.offset, t.offset + e.length]);
788
+ const c = this.lang.PREPOSITIVE_ABBREVIATIONS.some((i) => St(i, e)), d = /^\d+\.$/.test(e);
789
+ if (c || d)
790
+ return t.markContextRange([t.offset, t.offset + e.length]);
791
+ const h = this.lang.ABBREVIATIONS.some((i) => St(i, e)), r = this.getPrevWord(t), w = this.getWord(t, e.length + 1);
792
+ kt(r) && new RegExp("^\\p{Uppercase_Letter}\\.", "u").test(e) && kt(w) ? t.markContextRange([t.offset, t.offset + e.length]) : h && !kt(w) && t.markContextRange([t.offset, t.offset + e.length]);
793
+ }
794
+ }
795
+ const ir = [
796
+ {
797
+ key: "double quote",
798
+ start: '"',
799
+ end: '"'
800
+ },
801
+ {
802
+ key: "angled bracket",
803
+ start: "[",
804
+ end: "]"
805
+ },
806
+ {
807
+ key: "round bracket",
808
+ start: "(",
809
+ end: ")"
810
+ },
811
+ {
812
+ key: "curly brace",
813
+ start: "{",
814
+ end: "}"
815
+ },
816
+ {
817
+ key: "かぎ括弧",
818
+ start: "「",
819
+ end: "」"
820
+ },
821
+ {
822
+ key: "丸括弧",
823
+ start: "(",
824
+ end: ")"
825
+ },
826
+ {
827
+ key: "二重かぎ括弧",
828
+ start: "『",
829
+ end: "』"
830
+ },
831
+ {
832
+ key: "波括弧",
833
+ start: "{",
834
+ end: "}"
835
+ },
836
+ {
837
+ key: "角括弧",
838
+ start: "[",
839
+ end: "]"
840
+ },
841
+ {
842
+ key: "重角括弧",
843
+ start: "〚",
844
+ end: "〛"
845
+ },
846
+ {
847
+ key: "隅付き括弧",
848
+ start: "【",
849
+ end: "】"
850
+ },
851
+ {
852
+ key: "二重隅付き括弧",
853
+ start: "《",
854
+ end: "》"
855
+ }
856
+ ];
857
+ class sr {
858
+ PAIR_MARKS_KEY_Map = new Map(ir.flatMap((t) => [
859
+ [t.start, t],
860
+ [t.end, t]
861
+ ]));
862
+ mark(t) {
863
+ const e = t.read();
864
+ if (!e)
865
+ return;
866
+ const n = this.PAIR_MARKS_KEY_Map.get(e);
867
+ n && (t.isInContext(n) ? n.end === e && (ne(`PairMaker -> leaveContext: ${e} `), t.leaveContext(n)) : n.start === e && (ne(`PairMaker -> enterContext: ${e} `), t.enterContext(n)));
868
+ }
869
+ }
870
+ const gt = {
871
+ WhiteSpace: "WhiteSpace",
872
+ Punctuation: "Punctuation",
873
+ Sentence: "Sentence",
874
+ Str: "Str"
875
+ };
876
+ class cr {
877
+ sentenceNodeList = [];
878
+ results = [];
879
+ source;
880
+ constructor(t) {
881
+ this.source = new Xe(t);
882
+ }
883
+ get current() {
884
+ return this.sentenceNodeList[this.sentenceNodeList.length - 1];
885
+ }
886
+ pushNodeToCurrent(t) {
887
+ const e = this.current;
888
+ e ? e.children.push(t) : this.results.push(t);
889
+ }
890
+ // open with ParentNode
891
+ open(t) {
892
+ this.sentenceNodeList.push(t);
893
+ }
894
+ isOpened() {
895
+ return this.sentenceNodeList.length > 0;
896
+ }
897
+ nextLine(t) {
898
+ const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
899
+ return this.pushNodeToCurrent(oe(e, n, c)), c;
900
+ }
901
+ nextSpace(t) {
902
+ const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
903
+ this.pushNodeToCurrent(oe(e, n, c));
904
+ }
905
+ nextValue(t) {
906
+ const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
907
+ this.pushNodeToCurrent(ur(e, n, c));
908
+ }
909
+ // close current Node and remove it from list
910
+ close(t) {
911
+ const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
912
+ n.offset !== c.offset && !/^\s+$/.test(e) && this.pushNodeToCurrent(dr(e, n, c));
913
+ const d = this.sentenceNodeList.pop();
914
+ if (!d || d.children.length === 0)
915
+ return;
916
+ const h = d.children[0], r = this.source.now(), w = this.source.sliceRange(h.range[0], r.offset), i = this.source.consumedContexts.sort((s, l) => s.range[0] - l.range[0]).map((s) => ({
917
+ type: "PairMark",
918
+ pairMark: s.pairMark,
919
+ range: s.range,
920
+ loc: s.loc
921
+ }));
922
+ this.results.push({
923
+ ...d,
924
+ loc: {
925
+ start: h.loc.start,
926
+ end: {
927
+ line: r.line,
928
+ column: r.column
929
+ }
930
+ },
931
+ range: [h.range[0], r.offset],
932
+ raw: w,
933
+ contexts: i
934
+ });
935
+ }
936
+ toList() {
937
+ return this.results;
938
+ }
939
+ }
940
+ const ar = (o = {}) => {
941
+ const t = new je(), e = new Je(), n = new Qe(o.SeparatorParser), c = new or(o.AbbrMarker), d = new sr(), h = new er({
942
+ parsers: [t, n],
943
+ markers: [c, d]
944
+ });
945
+ return {
946
+ newLine: t,
947
+ space: e,
948
+ separator: n,
949
+ abbrMarker: c,
950
+ anyValueParser: h
951
+ };
952
+ };
953
+ function lr(o, t) {
954
+ const { newLine: e, space: n, separator: c, anyValueParser: d } = ar(t), h = new cr(o), r = h.source;
955
+ for (; !r.hasEnd; )
956
+ e.test(r) ? h.nextLine(e) : n.test(r) ? h.nextSpace(n) : c.test(r) ? h.close(c) : (h.isOpened() || h.open(fr()), h.nextValue(d));
957
+ return h.close(n), h.toList();
958
+ }
959
+ function oe(o, t, e) {
960
+ return {
961
+ type: gt.WhiteSpace,
962
+ raw: o,
963
+ value: o,
964
+ loc: {
965
+ start: {
966
+ line: t.line,
967
+ column: t.column
968
+ },
969
+ end: {
970
+ line: e.line,
971
+ column: e.column
972
+ }
973
+ },
974
+ range: [t.offset, e.offset]
975
+ };
976
+ }
977
+ function dr(o, t, e) {
978
+ return {
979
+ type: gt.Punctuation,
980
+ raw: o,
981
+ value: o,
982
+ loc: {
983
+ start: {
984
+ line: t.line,
985
+ column: t.column
986
+ },
987
+ end: {
988
+ line: e.line,
989
+ column: e.column
990
+ }
991
+ },
992
+ range: [t.offset, e.offset]
993
+ };
994
+ }
995
+ function ur(o, t, e) {
996
+ return {
997
+ type: gt.Str,
998
+ raw: o,
999
+ value: o,
1000
+ loc: {
1001
+ start: {
1002
+ line: t.line,
1003
+ column: t.column
1004
+ },
1005
+ end: {
1006
+ line: e.line,
1007
+ column: e.column
1008
+ }
1009
+ },
1010
+ range: [t.offset, e.offset]
1011
+ };
1012
+ }
1013
+ function fr() {
1014
+ return {
1015
+ type: gt.Sentence,
1016
+ raw: "",
1017
+ loc: {
1018
+ start: { column: NaN, line: NaN },
1019
+ end: { column: NaN, line: NaN }
1020
+ },
1021
+ range: [NaN, NaN],
1022
+ children: [],
1023
+ contexts: []
1024
+ };
1025
+ }
1026
+ const Dr = Te(
1027
+ "AUTOCOMPLETE_COMMAND"
1028
+ ), ce = "grammarDictionary", hr = [
1029
+ "javascript",
1030
+ "typescript",
1031
+ "lexical",
1032
+ "editor",
1033
+ "autocomplete",
1034
+ "suggestions",
1035
+ "keyboard",
1036
+ "navigation",
1037
+ "development",
1038
+ "programming"
1039
+ ], gr = 300 * 1e3, pr = 200, mr = 3e4, xr = { padding: 8 }, at = {
1040
+ width: 340,
1041
+ maxHeight: 280,
1042
+ padding: 16,
1043
+ offsetX: 10,
1044
+ offsetY: 20
1045
+ }, wr = 400, ae = () => {
1046
+ try {
1047
+ const o = localStorage.getItem(ce);
1048
+ return o ? new Set(JSON.parse(o)) : /* @__PURE__ */ new Set();
1049
+ } catch (o) {
1050
+ return console.error("Error reading dictionary from localStorage", o), /* @__PURE__ */ new Set();
1051
+ }
1052
+ }, Cr = (o) => {
1053
+ try {
1054
+ const t = ae();
1055
+ return t.add(o.toLowerCase()), localStorage.setItem(
1056
+ ce,
1057
+ JSON.stringify(Array.from(t))
1058
+ ), t;
1059
+ } catch (t) {
1060
+ return console.error("Error saving to dictionary", t), /* @__PURE__ */ new Set();
1061
+ }
1062
+ }, Mt = (o) => ze(o.trim().toLowerCase());
1063
+ function Er(o) {
1064
+ return lr(o).filter((e) => e.type === "Sentence").map((e, n) => ({
1065
+ id: `${n}`,
1066
+ text: e.raw,
1067
+ index: n
1068
+ })).filter((e) => e.text.trim().length > 0);
1069
+ }
1070
+ const vr = (o, t, e, n, c, d, h) => {
1071
+ const r = window.innerWidth, w = window.innerHeight;
1072
+ let i = o + c, s = t + d;
1073
+ return i + e > r - h && (i = o - e - c), i < h && (i = h), s + n > w - h && (s = t - n - d), s < h && (s = h), { left: i, top: s };
1074
+ }, ie = (o) => {
1075
+ let t = "";
1076
+ const e = [];
1077
+ try {
1078
+ o.read(() => {
1079
+ const n = It(), c = (d) => {
1080
+ if (!Ne(d)) {
1081
+ if (lt(d)) {
1082
+ const h = d.getTextContent(), r = t.length;
1083
+ t += h, e.push({
1084
+ start: r,
1085
+ end: r + h.length,
1086
+ key: d.getKey(),
1087
+ text: h
1088
+ });
1089
+ } else if (He(d)) {
1090
+ const h = d.getChildren();
1091
+ for (const r of h)
1092
+ c(r);
1093
+ typeof d.isInline == "function" && !d.isInline() && (t += `
1094
+ `);
1095
+ }
1096
+ }
1097
+ };
1098
+ c(n);
1099
+ });
1100
+ } catch (n) {
1101
+ console.error("Critical: Text extraction failed", n);
1102
+ }
1103
+ return { fullText: t, nodeMap: e };
1104
+ };
1105
+ class yr {
1106
+ apiEndpoint;
1107
+ requestTimeout = mr;
1108
+ sentenceCache = /* @__PURE__ */ new Map();
1109
+ constructor(t = "/api/ai/process") {
1110
+ this.apiEndpoint = Ie + t;
1111
+ }
1112
+ isSentenceCached(t) {
1113
+ const e = Mt(t), n = this.sentenceCache.get(e);
1114
+ return n && Date.now() - n.checkedAt < gr ? n : (n && this.sentenceCache.delete(e), null);
1115
+ }
1116
+ cacheSentence(t, e, n) {
1117
+ const c = Mt(t.text);
1118
+ if (this.sentenceCache.set(c, {
1119
+ id: t.id,
1120
+ text: t.text,
1121
+ hash: c,
1122
+ isClean: n,
1123
+ errors: e,
1124
+ checkedAt: Date.now()
1125
+ }), this.sentenceCache.size > pr) {
1126
+ const d = this.sentenceCache.keys().next().value;
1127
+ d && this.sentenceCache.delete(d);
1128
+ }
1129
+ }
1130
+ async processInChunks(t, e, n, c) {
1131
+ const d = [];
1132
+ let h = 0;
1133
+ const r = [];
1134
+ for (const w of t) {
1135
+ const i = this.isSentenceCached(w.text);
1136
+ i ? (d.push(i), h++, n?.(i)) : r.push(w);
1137
+ }
1138
+ if (r.length === 0)
1139
+ return {
1140
+ results: d,
1141
+ stats: {
1142
+ totalSentences: t.length,
1143
+ cachedSentences: h,
1144
+ apiCalls: 0
1145
+ }
1146
+ };
1147
+ try {
1148
+ const w = new AbortController(), i = setTimeout(
1149
+ () => w.abort(),
1150
+ this.requestTimeout
1151
+ ), s = await fetch(this.apiEndpoint, {
1152
+ method: "POST",
1153
+ headers: { "Content-Type": "application/json" },
1154
+ body: JSON.stringify({
1155
+ mode: "incremental",
1156
+ sentences: r,
1157
+ maxSuggestions: e
1158
+ }),
1159
+ signal: w.signal
1160
+ });
1161
+ if (clearTimeout(i), !s.ok) throw new Error(`Status ${s.status}`);
1162
+ const a = (await s.json()).data;
1163
+ a?.results && a.results.forEach((f, M) => {
1164
+ const b = r[M];
1165
+ if (!b) return;
1166
+ const S = [], I = f.correctedSentence || b.text, J = (H, Y) => {
1167
+ Array.isArray(H) && H.forEach((A, it) => {
1168
+ const Z = Number(A.startOffset ?? -1), W = Number(A.endOffset ?? Z);
1169
+ Y === "spelling" && W <= Z || A.original && S.push({
1170
+ type: Y,
1171
+ original: A.original,
1172
+ suggestions: A.suggestions || (A.suggestion ? [A.suggestion] : []),
1173
+ index: Y === "grammar" ? 1e3 + it : it,
1174
+ issue: A.issue,
1175
+ severity: A.severity,
1176
+ sentenceId: b.id,
1177
+ sentenceIndex: b.index,
1178
+ originalSentence: b.text,
1179
+ correctedSentence: I,
1180
+ wordPosition: A.wordPosition ?? 0
1181
+ });
1182
+ });
1183
+ };
1184
+ J(f.errors?.spelling, "spelling"), J(f.errors?.grammar, "grammar");
1185
+ const P = {
1186
+ id: b.id,
1187
+ text: b.text,
1188
+ hash: Mt(b.text),
1189
+ isClean: S.length === 0,
1190
+ errors: S,
1191
+ checkedAt: Date.now()
1192
+ };
1193
+ this.cacheSentence(b, S, S.length === 0), n?.(P), d.push(P), c?.(h + M + 1, t.length);
1194
+ });
1195
+ } catch {
1196
+ }
1197
+ return {
1198
+ results: d,
1199
+ stats: {
1200
+ totalSentences: t.length,
1201
+ cachedSentences: h,
1202
+ apiCalls: 1
1203
+ }
1204
+ };
1205
+ }
1206
+ }
1207
+ function _r({
1208
+ onQueryChange: o,
1209
+ onSelectOption: t,
1210
+ minMatchLength: e = 2,
1211
+ maxSuggestions: n = 10,
1212
+ apiEndpoint: c = "/api/grammar/process",
1213
+ enableAI: d = !0,
1214
+ debounceDelay: h = 800
1215
+ }) {
1216
+ const [r] = Re(), { toolbarState: w, updateToolbarState: i } = Ee(), { isHtmlView: s } = ve(), l = B([]), a = B(new yr(c)), f = B(), M = B(""), b = B(null), S = B(null), I = B(null), J = B(!1), P = B(null), H = B(null), Y = B(() => {
1217
+ }), A = B(0), it = B(async () => {
1218
+ }), Z = B(/* @__PURE__ */ new Set()), [W, Q] = q(null), [F, tt] = q([]), [dt, et] = q(0), [Nt, le] = q(
1219
+ null
1220
+ ), [pt, V] = q([]), [br, z] = q(/* @__PURE__ */ new Map()), [kr, rt] = q(
1221
+ /* @__PURE__ */ new Set()
1222
+ ), [Rt, de] = q(/* @__PURE__ */ new Set()), [Sr, ue] = q(
1223
+ /* @__PURE__ */ new Set()
1224
+ ), [mt, $] = q(null), nt = ye() ?? null;
1225
+ T(() => {
1226
+ Z.current = ae();
1227
+ }, []);
1228
+ const Ot = G(() => {
1229
+ const u = new Set(hr);
1230
+ return r.getEditorState().read(() => {
1231
+ const E = It().getTextContent().match(/\b[a-zA-Z][a-zA-Z0-9_]*\b/g);
1232
+ E && E.forEach((x) => {
1233
+ x.length >= e && u.add(x);
1234
+ });
1235
+ }), Array.from(u);
1236
+ }, [r, e]), Lt = G(
1237
+ (u) => !u || u.length < e ? [] : Ot().filter(
1238
+ (m) => m.toLowerCase().startsWith(u.toLowerCase()) && m.toLowerCase() !== u.toLowerCase()
1239
+ ).slice(0, n).map((m) => ({
1240
+ displayText: m,
1241
+ key: `traditional-${m}`,
1242
+ queryWordStart: 0,
1243
+ queryWordEnd: u.length,
1244
+ type: "suggestion",
1245
+ confidence: "low"
1246
+ })),
1247
+ [Ot, e, n]
1248
+ ), At = G(() => {
1249
+ Q(null);
1250
+ }, []), ut = G(async () => {
1251
+ if (!w.isAutocompleteEnabled || !d) {
1252
+ V([]), z(/* @__PURE__ */ new Map()), rt(/* @__PURE__ */ new Set());
1253
+ return;
1254
+ }
1255
+ const { fullText: u, nodeMap: m } = ie(r.getEditorState());
1256
+ if (!u) return;
1257
+ if (l.current = m, u.trim().length < 3) {
1258
+ V([]), z(/* @__PURE__ */ new Map()), rt(/* @__PURE__ */ new Set());
1259
+ return;
1260
+ }
1261
+ M.current = u;
1262
+ const E = Er(u);
1263
+ if (E.length === 0) return;
1264
+ const x = ++A.current, p = new Set(E.map((g) => g.id));
1265
+ rt(new Set(E.map((g) => g.id))), z((g) => {
1266
+ const C = /* @__PURE__ */ new Map();
1267
+ return g.forEach((v, y) => {
1268
+ p.has(y) && C.set(y, v);
1269
+ }), C;
1270
+ });
1271
+ try {
1272
+ await a.current.processInChunks(
1273
+ E.map((g) => ({ id: g.id, text: g.text, index: g.index })),
1274
+ n,
1275
+ (g) => {
1276
+ if (A.current !== x) return;
1277
+ rt((v) => {
1278
+ const y = new Set(v);
1279
+ return y.delete(g.id), y;
1280
+ });
1281
+ const C = g.errors.filter((v) => {
1282
+ const y = `${v.sentenceId}-${v.original.toLowerCase()}`, R = Rt.has(y), K = Z.current.has(
1283
+ v.original.toLowerCase()
1284
+ );
1285
+ return !R && !K;
1286
+ });
1287
+ z((v) => {
1288
+ const y = new Map(v);
1289
+ return C.length > 0 ? y.set(g.id, C) : y.delete(g.id), y;
1290
+ }), V((v) => [...v.filter(
1291
+ (R) => R.sentenceId !== g.id
1292
+ ), ...C]);
1293
+ }
1294
+ );
1295
+ } catch {
1296
+ A.current === x && (V([]), z(/* @__PURE__ */ new Map()), rt(/* @__PURE__ */ new Set()));
1297
+ }
1298
+ }, [r, w, d, n, Rt]);
1299
+ T(() => {
1300
+ it.current = ut;
1301
+ });
1302
+ const ft = G(
1303
+ (u) => {
1304
+ tt((m) => m.filter((E) => E.key !== u.key)), et(0), J.current = !0, r.update(() => {
1305
+ const m = Ut();
1306
+ if (!Vt(m)) return;
1307
+ const E = m.anchor, x = E.getNode(), p = x.getTextContent(), g = E.offset;
1308
+ let C = g;
1309
+ for (; C > 0 && /[a-zA-Z0-9_']/.test(p[C - 1]); )
1310
+ C--;
1311
+ if (lt(x)) {
1312
+ const v = p.slice(0, C) + u.displayText + p.slice(g);
1313
+ x.setTextContent(v);
1314
+ const y = C + u.displayText.length;
1315
+ m.anchor.set(x.getKey(), y, "text"), m.focus.set(x.getKey(), y, "text");
1316
+ }
1317
+ }), M.current = "", Q(null), tt([]), t?.(u, null, () => Q(null)), setTimeout(ut, 500);
1318
+ },
1319
+ [r, t, ut]
1320
+ ), fe = G(
1321
+ (u, m) => {
1322
+ const E = m.sentenceId || "";
1323
+ z((x) => {
1324
+ const p = new Map(x), C = (p.get(E) || []).filter((v) => v !== m);
1325
+ return C.length > 0 ? p.set(E, C) : p.delete(E), p;
1326
+ }), V((x) => x.filter((p) => p !== m)), $(null), r.update(() => {
1327
+ const { fullText: x, nodeMap: p } = ie(
1328
+ r.getEditorState()
1329
+ );
1330
+ let g = x.indexOf(m.originalSentence || "");
1331
+ if (g === -1 && (g = x.indexOf(m.original)), g === -1) return;
1332
+ const C = x.substring(g).indexOf(m.original);
1333
+ if (C === -1) return;
1334
+ const v = g + C, y = v + m.original.length, R = p.find(
1335
+ (O) => v >= O.start && v < O.end
1336
+ ), K = p.find(
1337
+ (O) => y > O.start && y <= O.end
1338
+ );
1339
+ if (R && K) {
1340
+ const O = zt(R.key), X = zt(K.key);
1341
+ if (lt(O) && lt(X)) {
1342
+ const D = Oe(), ot = v - R.start, _t = y - K.start;
1343
+ D.anchor.set(O.getKey(), ot, "text"), D.focus.set(X.getKey(), _t, "text"), Le(D), D.insertText(u);
1344
+ }
1345
+ }
1346
+ }), V(
1347
+ (x) => x.map((p) => p.sentenceId === E && p !== m ? {
1348
+ ...p,
1349
+ originalSentence: p.originalSentence?.replace(
1350
+ m.original,
1351
+ u
1352
+ )
1353
+ } : p)
1354
+ ), window.dispatchEvent(new Event("customUpdateHighlights"));
1355
+ },
1356
+ [r]
1357
+ ), he = G(
1358
+ (u, m, E) => {
1359
+ ue((x) => new Set(x).add(E)), z((x) => {
1360
+ const p = new Map(x);
1361
+ return p.delete(E), p;
1362
+ }), V((x) => x.filter((p) => p.sentenceId !== E)), $(null), r.update(() => {
1363
+ const x = It();
1364
+ let p = !1;
1365
+ const g = (C) => {
1366
+ if (p) return !0;
1367
+ if (lt(C)) {
1368
+ const y = C.getTextContent(), R = y.toLowerCase().indexOf(m.toLowerCase());
1369
+ if (R !== -1) {
1370
+ const K = y.substring(0, R) + u + y.substring(R + m.length);
1371
+ return C.setTextContent(K), p = !0, !0;
1372
+ }
1373
+ }
1374
+ const v = C.getChildren ? C.getChildren() : [];
1375
+ for (const y of v)
1376
+ if (g(y)) return !0;
1377
+ return !1;
1378
+ };
1379
+ g(x);
1380
+ });
1381
+ },
1382
+ [r]
1383
+ ), Bt = G((u) => {
1384
+ const m = `${u.sentenceId}-${u.original.toLowerCase()}`, E = u.sentenceId || "";
1385
+ de((x) => new Set(x).add(m)), z((x) => {
1386
+ const p = new Map(x), C = (p.get(E) || []).filter(
1387
+ (v) => v.original !== u.original
1388
+ );
1389
+ return C.length > 0 ? p.set(E, C) : p.delete(E), p;
1390
+ }), V((x) => x.filter((p) => p.original !== u.original)), $(null);
1391
+ }, []), Pt = G((u) => {
1392
+ const m = Cr(u.original);
1393
+ Z.current = m;
1394
+ const E = u.sentenceId || "";
1395
+ z((x) => {
1396
+ const p = new Map(x), C = (p.get(E) || []).filter(
1397
+ (v) => v.original.toLowerCase() !== u.original.toLowerCase()
1398
+ );
1399
+ return C.length > 0 ? p.set(E, C) : p.delete(E), p;
1400
+ }), V(
1401
+ (x) => x.filter(
1402
+ (p) => p.original.toLowerCase() !== u.original.toLowerCase()
1403
+ )
1404
+ ), $(null), window.dispatchEvent(new Event("customUpdateHighlights"));
1405
+ }, []), Dt = G(() => {
1406
+ S.current && r.getEditorState().read(() => {
1407
+ const u = Ut();
1408
+ if (!Vt(u)) return;
1409
+ const m = window.getSelection()?.getRangeAt(0);
1410
+ if (!m) return;
1411
+ const E = m.getBoundingClientRect(), x = S.current;
1412
+ if (!x) return;
1413
+ const p = E.bottom + window.scrollY + xr.padding, g = E.left + window.scrollX;
1414
+ x.style.top = `${p}px`, x.style.left = `${g}px`;
1415
+ });
1416
+ }, [r]);
1417
+ T(() => {
1418
+ M.current = "";
1419
+ }, []), T(() => {
1420
+ w.isAutocompleteEnabled ? ut() : (Q(null), tt([]), V([]), z(/* @__PURE__ */ new Map()), rt(/* @__PURE__ */ new Set()));
1421
+ }, [w.isAutocompleteEnabled]), T(() => (I.current && clearTimeout(I.current), W && !J.current ? I.current = window.setTimeout(() => {
1422
+ tt(Lt(W)), et(0), o?.(W);
1423
+ }, h) : (tt([]), et(0), o?.(null)), () => {
1424
+ I.current && clearTimeout(I.current);
1425
+ }), [W, Lt, o, h]), T(() => {
1426
+ if (!W || F.length === 0) return;
1427
+ const u = r.registerCommand(
1428
+ Ae,
1429
+ (g) => (g?.preventDefault(), et((C) => (C + 1) % F.length), !0),
1430
+ st
1431
+ ), m = r.registerCommand(
1432
+ Be,
1433
+ (g) => (g?.preventDefault(), et(
1434
+ (C) => (C - 1 + F.length) % F.length
1435
+ ), !0),
1436
+ st
1437
+ ), E = r.registerCommand(
1438
+ Pe,
1439
+ (g) => (g?.preventDefault(), Q(null), !0),
1440
+ st
1441
+ ), x = r.registerCommand(
1442
+ De,
1443
+ (g) => (g?.preventDefault(), ft(F[dt]), !0),
1444
+ st
1445
+ ), p = r.registerCommand(
1446
+ _e,
1447
+ (g) => (g?.preventDefault(), ft(F[dt]), !0),
1448
+ st
1449
+ );
1450
+ return () => {
1451
+ u(), m(), E(), x(), p();
1452
+ };
1453
+ }, [r, W, F, dt, ft]), T(() => r.registerUpdateListener(({ editorState: u }) => {
1454
+ u.read(() => setTimeout(At, 0));
1455
+ }), [r, At]), T(() => {
1456
+ W && F.length > 0 && Dt();
1457
+ }, [W, F, Dt]), T(() => {
1458
+ const u = document.createElement("div");
1459
+ return u.style.position = "absolute", u.style.zIndex = "1000", document.body.appendChild(u), S.current = u, le(u), () => {
1460
+ S.current && document.body.removeChild(S.current);
1461
+ };
1462
+ }, []), T(() => {
1463
+ if (!w.isAutocompleteEnabled) return;
1464
+ const u = r.registerUpdateListener(() => {
1465
+ clearTimeout(f.current), f.current = window.setTimeout(() => it.current(), 1e3);
1466
+ });
1467
+ return () => {
1468
+ u(), clearTimeout(f.current);
1469
+ };
1470
+ }, [r, w.isAutocompleteEnabled]), T(() => {
1471
+ const u = () => {
1472
+ const m = r.getRootElement();
1473
+ if (!m) return;
1474
+ if (s) {
1475
+ document.querySelectorAll(".grammar-error-highlight").forEach((g) => g.remove());
1476
+ return;
1477
+ }
1478
+ const E = m.getBoundingClientRect();
1479
+ if (E.width === 0 || E.height === 0) {
1480
+ document.querySelectorAll(".grammar-error-highlight").forEach((g) => g.remove());
1481
+ return;
1482
+ }
1483
+ if (document.querySelectorAll(".grammar-error-highlight").forEach((g) => g.remove()), pt.length === 0) return;
1484
+ const x = l.current, p = M.current;
1485
+ pt.forEach((g) => {
1486
+ if (Z.current.has(g.original.toLowerCase()))
1487
+ return;
1488
+ let C = p.indexOf(g.originalSentence || "");
1489
+ if (C === -1 && (C = p.indexOf(g.original)), C === -1) return;
1490
+ const v = p.substring(C), y = g.original.replace(
1491
+ /[.*+?^${}()|[\]\\]/g,
1492
+ "\\$&"
1493
+ ), R = new RegExp(`\\b${y}\\b`, "g");
1494
+ if (!R.test(p))
1495
+ return;
1496
+ R.lastIndex = 0;
1497
+ const K = new RegExp(`\\b${y}\\b`), O = v.match(K), X = O ? O.index : -1;
1498
+ if (X === void 0 || X === -1) return;
1499
+ const D = C + X, ot = D + g.original.length;
1500
+ x.filter(
1501
+ (_) => _.start <= D && _.end > D || _.start < ot && _.end >= ot || _.start >= D && _.end <= ot
1502
+ ).forEach((_) => {
1503
+ const me = Math.max(_.start, D), xe = Math.min(_.end, ot), Tt = me - _.start, Ht = xe - _.start;
1504
+ if (Ht <= Tt) return;
1505
+ const Wt = r.getElementByKey(_.key);
1506
+ if (!Wt) return;
1507
+ const ht = Wt.firstChild;
1508
+ if (!ht || ht.nodeType !== Node.TEXT_NODE) return;
1509
+ const xt = document.createRange();
1510
+ try {
1511
+ xt.setStart(ht, Tt), xt.setEnd(ht, Ht);
1512
+ const wt = xt.getClientRects();
1513
+ for (let Ct = 0; Ct < wt.length; Ct++) {
1514
+ const j = wt[Ct];
1515
+ if (j.width === 0 || j.height === 0) continue;
1516
+ const N = document.createElement("div");
1517
+ N.className = "grammar-error-highlight", N.style.position = "absolute", N.style.left = `${j.left + window.scrollX}px`, N.style.top = `${j.bottom + window.scrollY - 8}px`, N.style.width = `${j.width}px`, N.style.height = "2px", N.style.paddingTop = "3px", N.style.paddingBottom = "3px", N.style.zIndex = "10", N.style.cursor = "pointer", N.style.pointerEvents = "auto", N.style.boxSizing = "content-box", g.type === "grammar" ? (N.style.backgroundColor = "rgba(59, 130, 246, 0.1)", N.style.borderBottom = "2.5px solid #3b82f6") : (N.style.backgroundColor = "rgba(239, 68, 68, 0.1)", N.style.borderBottom = "2.5px solid #ef4444"), N.onmouseenter = () => {
1518
+ P.current && (clearTimeout(P.current), P.current = null), H.current && clearTimeout(H.current), H.current = window.setTimeout(() => {
1519
+ $({
1520
+ error: g,
1521
+ x: j.left + j.width / 2,
1522
+ y: j.bottom + 5,
1523
+ isVisible: !0,
1524
+ isLocked: !1
1525
+ });
1526
+ }, 200);
1527
+ }, N.onmouseleave = () => {
1528
+ H.current && (clearTimeout(H.current), H.current = null), P.current = window.setTimeout(() => {
1529
+ $(null);
1530
+ }, 400);
1531
+ }, document.body.appendChild(N);
1532
+ }
1533
+ } catch {
1534
+ }
1535
+ });
1536
+ });
1537
+ };
1538
+ return Y.current = u, window.addEventListener("scroll", u, !0), window.addEventListener("resize", u), window.addEventListener("customUpdateHighlights", u), requestAnimationFrame(u), () => {
1539
+ window.removeEventListener("scroll", u, !0), window.removeEventListener("resize", u), window.removeEventListener("customUpdateHighlights", u), document.querySelectorAll(".grammar-error-highlight").forEach((m) => m.remove()), Y.current = () => {
1540
+ };
1541
+ };
1542
+ }, [pt, r, s]), T(() => {
1543
+ const u = (m) => {
1544
+ const E = m.target;
1545
+ b.current?.contains(E) || document.querySelector(".grammar-tooltip-card")?.contains(E) || (Q(null), tt([]), $(null));
1546
+ };
1547
+ return document.addEventListener("mousedown", u), () => document.removeEventListener("mousedown", u);
1548
+ }, []);
1549
+ const ge = () => {
1550
+ if (!mt || !mt.isVisible) return null;
1551
+ const { error: u, x: m, y: E } = mt, x = !!nt, p = nt?.getBoundingClientRect(), { left: g, top: C } = vr(
1552
+ m,
1553
+ E,
1554
+ at.width,
1555
+ at.maxHeight,
1556
+ at.offsetX,
1557
+ at.offsetY,
1558
+ at.padding
1559
+ );
1560
+ let v, y, R;
1561
+ x && p && nt ? (R = "absolute", v = g - p.left + nt.scrollLeft, y = C - p.top + nt.scrollTop) : (R = "fixed", v = g, y = C);
1562
+ const K = /* @__PURE__ */ k(
1563
+ "div",
1564
+ {
1565
+ className: R === "fixed" ? "cteditor-fixed cteditor-z-[10001]" : "cteditor-absolute cteditor-z-[10001]",
1566
+ style: {
1567
+ top: `${y}px`,
1568
+ left: `${v}px`,
1569
+ animation: "fadeIn 0.2s ease-out",
1570
+ pointerEvents: "auto",
1571
+ paddingTop: "10px"
1572
+ },
1573
+ onMouseEnter: () => {
1574
+ P.current && (clearTimeout(P.current), P.current = null);
1575
+ },
1576
+ onMouseLeave: () => {
1577
+ P.current = window.setTimeout(() => {
1578
+ $(null);
1579
+ }, wr);
1580
+ },
1581
+ children: /* @__PURE__ */ k(Ft, { className: "cteditor-w-[340px] cteditor-max-w-[calc(100vw-32px)] cteditor-shadow-2xl cteditor-border cteditor-border-foreground/15 cteditor-bg-grammar-tooltip-bg grammar-tooltip-card cteditor-overflow-hidden cteditor-relative", children: /* @__PURE__ */ L($t, { className: "!cteditor-p-4 sm:!cteditor-p-5 cteditor-space-y-3 cteditor-font-geist", children: [
1582
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-items-start cteditor-justify-between cteditor-gap-2 ", children: [
1583
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-min-w-0 cteditor-flex-1", children: [
1584
+ /* @__PURE__ */ k(
1585
+ "div",
1586
+ {
1587
+ className: `cteditor-w-6 cteditor-h-6 cteditor-rounded-full cteditor-flex cteditor-items-center cteditor-justify-center cteditor-flex-shrink-0 ${u.type === "spelling" ? "cteditor-bg-red-100 dark:cteditor-bg-red-900/30" : "cteditor-bg-blue-100 dark:cteditor-bg-blue-900/30"}`,
1588
+ children: /* @__PURE__ */ k(
1589
+ be,
1590
+ {
1591
+ className: `cteditor-w-4 cteditor-h-4 ${u.type === "spelling" ? "cteditor-text-red-600 dark:cteditor-text-red-400" : "cteditor-text-blue-600 dark:cteditor-text-blue-400"}`
1592
+ }
1593
+ )
1594
+ }
1595
+ ),
1596
+ /* @__PURE__ */ L("div", { className: "cteditor-min-w-0 cteditor-flex-1", children: [
1597
+ /* @__PURE__ */ k(
1598
+ ke,
1599
+ {
1600
+ variant: u.type === "spelling" ? "destructive" : "default",
1601
+ className: "cteditor-text-xs cteditor-font-bold",
1602
+ children: u.type === "spelling" ? "Spelling" : "Grammar"
1603
+ }
1604
+ ),
1605
+ u.issue && /* @__PURE__ */ k("p", { className: "cteditor-text-xs cteditor-text-foreground/50 cteditor-mt-1 cteditor-break-words", children: u.issue })
1606
+ ] })
1607
+ ] }),
1608
+ /* @__PURE__ */ k(
1609
+ "button",
1610
+ {
1611
+ type: "button",
1612
+ onClick: () => $(null),
1613
+ className: "cteditor-text-gray-400 hover:cteditor-text-gray-600 cteditor-flex-shrink-0 cteditor-p-1 cteditor-absolute cteditor-top-1 cteditor-right-1",
1614
+ children: /* @__PURE__ */ k(Se, { className: "cteditor-w-4 cteditor-h-4" })
1615
+ }
1616
+ )
1617
+ ] }),
1618
+ /* @__PURE__ */ k("div", { className: "cteditor-p-3 cteditor-bg-incorrect-word-bg cteditor-rounded-lg cteditor-border cteditor-border-incorrect-word-border cteditor-overflow-hidden", children: /* @__PURE__ */ k("p", { className: "cteditor-text-sm cteditor-line-through cteditor-text-incorrect-word-text cteditor-font-semibold cteditor-break-all", children: u.original }) }),
1619
+ u.suggestions.length > 0 ? /* @__PURE__ */ L("div", { className: "cteditor-space-y-3", children: [
1620
+ /* @__PURE__ */ k("p", { className: "cteditor-text-xs cteditor-font-bold cteditor-text-main-foreground cteditor-uppercase cteditor-tracking-wider", children: "Suggestions:" }),
1621
+ /* @__PURE__ */ k("div", { className: "cteditor-space-y-2 cteditor-max-h-[120px] cteditor-overflow-y-auto cteditor-pr-1", children: u.suggestions.map((O, X) => /* @__PURE__ */ L(
1622
+ "button",
1623
+ {
1624
+ type: "button",
1625
+ onClick: (D) => {
1626
+ D.preventDefault(), D.stopPropagation(), fe(O, u);
1627
+ },
1628
+ className: "cteditor-w-full cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-px-3 cteditor-py-2 cteditor-bg-suggestion-bg cteditor-border cteditor-border-suggestion-border cteditor-rounded-lg cteditor-transition-all",
1629
+ children: [
1630
+ /* @__PURE__ */ k(Kt, { className: "cteditor-w-4 cteditor-h-4 cteditor-flex-shrink-0 cteditor-text-suggestion-text " }),
1631
+ /* @__PURE__ */ k("span", { className: "cteditor-text-sm cteditor-font-semibold cteditor-text-suggestion-text cteditor-break-all cteditor-text-left", children: O })
1632
+ ]
1633
+ },
1634
+ X
1635
+ )) }),
1636
+ u.type === "grammar" && u.correctedSentence && /* @__PURE__ */ k(
1637
+ "button",
1638
+ {
1639
+ type: "button",
1640
+ onClick: (O) => {
1641
+ O.preventDefault(), he(
1642
+ u.correctedSentence,
1643
+ u.originalSentence,
1644
+ u.sentenceId
1645
+ );
1646
+ },
1647
+ className: "cteditor-w-full cteditor-px-3 cteditor-py-2 cteditor-bg-explanation-bg cteditor-border-2 cteditor-border-explanation-border cteditor-rounded-lg cteditor-text-left",
1648
+ children: /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-items-start cteditor-gap-2", children: [
1649
+ /* @__PURE__ */ k(Kt, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-blue-600 cteditor-mt-0.5 cteditor-flex-shrink-0" }),
1650
+ /* @__PURE__ */ L("div", { className: "cteditor-min-w-0 cteditor-flex-1", children: [
1651
+ /* @__PURE__ */ k("p", { className: "cteditor-text-xs cteditor-font-semibold cteditor-text-blue-700", children: "Fix entire sentence" }),
1652
+ /* @__PURE__ */ k("p", { className: "cteditor-text-xs cteditor-text-blue-600 cteditor-break-words cteditor-line-clamp-2", children: u.correctedSentence })
1653
+ ] })
1654
+ ] })
1655
+ }
1656
+ ),
1657
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-3 cteditor-mt-3 cteditor-pt-3 ", children: [
1658
+ /* @__PURE__ */ k(
1659
+ "button",
1660
+ {
1661
+ type: "button",
1662
+ onClick: () => Bt(u),
1663
+ className: "cteditor-w-full cteditor-px-4 cteditor-py-2.5 cteditor-text-sm cteditor-font-medium cteditor-rounded-lg cteditor-border cteditor-border-foreground/20 hover:cteditor-bg-foreground/10 cteditor-transition-colors",
1664
+ title: "Ignore this suggestion",
1665
+ children: "Dismiss"
1666
+ }
1667
+ ),
1668
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-gap-2 cteditor-justify-between", children: [
1669
+ /* @__PURE__ */ L(
1670
+ "button",
1671
+ {
1672
+ type: "button",
1673
+ onClick: () => Pt(u),
1674
+ className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1.5 cteditor-text-xs cteditor-transition-colors cteditor-font-medium hover:cteditor-opacity-90",
1675
+ title: "Add word to your personal dictionary ",
1676
+ children: [
1677
+ /* @__PURE__ */ k(Gt, { className: "cteditor-w-3.5 cteditor-h-3.5" }),
1678
+ "Add to Dictionary"
1679
+ ]
1680
+ }
1681
+ ),
1682
+ /* @__PURE__ */ k(
1683
+ "button",
1684
+ {
1685
+ type: "button",
1686
+ onClick: () => {
1687
+ i("isAutocompleteEnabled", !1), $(null);
1688
+ },
1689
+ className: "cteditor-px-3 cteditor-py-2 hover:cteditor-bg-foreground/10 cteditor-text-xs cteditor-rounded-md cteditor-transition-colors cteditor-font-medium",
1690
+ title: "Turn off grammar checking",
1691
+ children: "Disable"
1692
+ }
1693
+ )
1694
+ ] })
1695
+ ] })
1696
+ ] }) : (
1697
+ /* No suggestions - action buttons only */
1698
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-3 cteditor-mt-3 cteditor-pt-3 ", children: [
1699
+ /* @__PURE__ */ k(
1700
+ "button",
1701
+ {
1702
+ type: "button",
1703
+ onClick: () => Bt(u),
1704
+ className: "cteditor-flex-1 cteditor-px-3 cteditor-py-2 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1.5 cteditor-text-xs cteditor-rounded-md cteditor-border cteditor-border-foreground/50 hover:cteditor-bg-foreground/10 cteditor-transition-colors",
1705
+ title: "Ignore this suggestion",
1706
+ children: "Dismiss"
1707
+ }
1708
+ ),
1709
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-gap-2 cteditor-justify-between", children: [
1710
+ /* @__PURE__ */ L(
1711
+ "button",
1712
+ {
1713
+ type: "button",
1714
+ onClick: () => Pt(u),
1715
+ className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1.5 cteditor-text-xs cteditor-rounded-md cteditor-transition-colors cteditor-font-medium hover:cteditor-opacity-90 ",
1716
+ title: "Add word to your personal dictionary",
1717
+ children: [
1718
+ /* @__PURE__ */ k(Gt, { className: "cteditor-w-3.5 cteditor-h-3.5" }),
1719
+ "Add to Dictionary"
1720
+ ]
1721
+ }
1722
+ ),
1723
+ /* @__PURE__ */ k(
1724
+ "button",
1725
+ {
1726
+ type: "button",
1727
+ onClick: () => {
1728
+ i("isAutocompleteEnabled", !1), $(null);
1729
+ },
1730
+ className: "cteditor-px-3 cteditor-py-2 hover:cteditor-bg-foreground/10 cteditor-text-xs cteditor-rounded-md cteditor-transition-colors cteditor-font-medium",
1731
+ title: "Turn off grammar checking",
1732
+ children: "Disable"
1733
+ }
1734
+ )
1735
+ ] })
1736
+ ] })
1737
+ )
1738
+ ] }) })
1739
+ }
1740
+ );
1741
+ return qt(K, nt || document.body);
1742
+ }, pe = () => !Nt || !W || F.length === 0 ? null : qt(
1743
+ /* @__PURE__ */ k(
1744
+ Ft,
1745
+ {
1746
+ ref: b,
1747
+ className: "cteditor-w-80 cteditor-max-h-64 cteditor-overflow-hidden cteditor-shadow-xl cteditor-border-2 cteditor-bg-white dark:cteditor-bg-gray-900 autocomplete-menu",
1748
+ children: /* @__PURE__ */ k($t, { className: "!cteditor-p-2", children: /* @__PURE__ */ k("div", { className: "cteditor-max-h-56 cteditor-overflow-y-auto cteditor-space-y-1", children: F.map((u, m) => /* @__PURE__ */ L(
1749
+ "button",
1750
+ {
1751
+ type: "button",
1752
+ className: Me(
1753
+ "cteditor-w-full cteditor-flex cteditor-items-center cteditor-gap-3 cteditor-px-3 cteditor-py-2.5 cteditor-rounded-md cteditor-text-left",
1754
+ m === dt ? "cteditor-bg-blue-100" : "hover:cteditor-bg-gray-100"
1755
+ ),
1756
+ onClick: () => ft(u),
1757
+ onMouseEnter: () => et(m),
1758
+ children: [
1759
+ /* @__PURE__ */ k(Fe, { className: "cteditor-w-4 cteditor-h-4" }),
1760
+ /* @__PURE__ */ k("span", { className: "cteditor-text-sm cteditor-font-medium", children: u.displayText })
1761
+ ]
1762
+ },
1763
+ u.key
1764
+ )) }) })
1765
+ }
1766
+ ),
1767
+ Nt
1768
+ );
1769
+ return /* @__PURE__ */ L(we, { children: [
1770
+ ge(),
1771
+ pe()
1772
+ ] });
1773
+ }
1774
+ export {
1775
+ Dr as AUTOCOMPLETE_COMMAND,
1776
+ _r as default,
1777
+ Er as splitIntoSentences
1778
+ };