@zeke-02/docx-editor-agents 0.1.0

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 (59) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +126 -0
  3. package/dist/agent-types-C8RvQB7n.d.mts +36 -0
  4. package/dist/agent-types-C8RvQB7n.d.ts +36 -0
  5. package/dist/ai-sdk/react.d.mts +57 -0
  6. package/dist/ai-sdk/react.d.ts +57 -0
  7. package/dist/ai-sdk/react.js +1 -0
  8. package/dist/ai-sdk/react.mjs +1 -0
  9. package/dist/ai-sdk/server.d.mts +80 -0
  10. package/dist/ai-sdk/server.d.ts +80 -0
  11. package/dist/ai-sdk/server.js +1 -0
  12. package/dist/ai-sdk/server.mjs +1 -0
  13. package/dist/ai-sdk/vue.d.ts +32 -0
  14. package/dist/ai-sdk/vue.js +1 -0
  15. package/dist/ai-sdk/vue.mjs +28 -0
  16. package/dist/bridge.d.mts +19 -0
  17. package/dist/bridge.d.ts +19 -0
  18. package/dist/bridge.js +1 -0
  19. package/dist/bridge.mjs +1 -0
  20. package/dist/chunk-24MVJKCP.mjs +8 -0
  21. package/dist/chunk-2RGRAPLW.js +5 -0
  22. package/dist/chunk-53PAUP4S.js +2 -0
  23. package/dist/chunk-AU3KR5IN.mjs +5 -0
  24. package/dist/chunk-KMEZXSKR.mjs +2 -0
  25. package/dist/chunk-RI5S75JY.js +8 -0
  26. package/dist/chunk-UNUH3LRU.mjs +1 -0
  27. package/dist/chunk-VXAJD6QK.js +1 -0
  28. package/dist/docx-editor-agents.css +2 -0
  29. package/dist/index.d.mts +178 -0
  30. package/dist/index.d.ts +178 -0
  31. package/dist/index.js +1 -0
  32. package/dist/index.mjs +1 -0
  33. package/dist/mcp.d.mts +200 -0
  34. package/dist/mcp.d.ts +200 -0
  35. package/dist/mcp.js +4 -0
  36. package/dist/mcp.mjs +4 -0
  37. package/dist/react.d.mts +251 -0
  38. package/dist/react.d.ts +251 -0
  39. package/dist/react.js +9 -0
  40. package/dist/react.mjs +9 -0
  41. package/dist/server-uWvnaIh-.d.mts +620 -0
  42. package/dist/server-uWvnaIh-.d.ts +620 -0
  43. package/dist/server.d.mts +35 -0
  44. package/dist/server.d.ts +35 -0
  45. package/dist/server.js +1 -0
  46. package/dist/server.mjs +1 -0
  47. package/dist/vue/components/AIContextMenu.d.ts +33 -0
  48. package/dist/vue/components/AIResponsePreview.d.ts +40 -0
  49. package/dist/vue/components/AgentChatLog.d.ts +37 -0
  50. package/dist/vue/components/AgentComposer.d.ts +30 -0
  51. package/dist/vue/components/AgentPanel.d.ts +49 -0
  52. package/dist/vue/components/AgentSuggestionChip.d.ts +10 -0
  53. package/dist/vue/components/AgentTimeline.d.ts +19 -0
  54. package/dist/vue/composables/useAgentBridge.d.ts +19 -0
  55. package/dist/vue/types.d.ts +5 -0
  56. package/dist/vue.d.ts +72 -0
  57. package/dist/vue.js +20 -0
  58. package/dist/vue.mjs +2026 -0
  59. package/package.json +157 -0
package/dist/vue.mjs ADDED
@@ -0,0 +1,2026 @@
1
+ import { Fragment as e, Teleport as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, defineComponent as c, nextTick as l, normalizeClass as u, normalizeStyle as d, onBeforeUnmount as f, onMounted as p, openBlock as m, ref as h, renderList as g, renderSlot as _, toDisplayString as v, unref as y, vModelText as b, watch as x, withDirectives as S, withKeys as C, withModifiers as w } from "vue";
2
+ var T = {
3
+ _lang: "en",
4
+ agentPanel: {
5
+ defaultTitle: "Assistant",
6
+ close: "Close panel",
7
+ resizeHandle: "Resize agent panel",
8
+ thinking: "Assistant is thinking",
9
+ composerPlaceholder: "Ask the assistant…",
10
+ send: "Send",
11
+ timeline: {
12
+ working: "Working… {count, plural, one {# step} other {# steps}}",
13
+ summary: "{count, plural, one {# step} other {# steps}}",
14
+ earlier: "+ {count, plural, one {# earlier step} other {# earlier steps}}"
15
+ }
16
+ },
17
+ aiActions: {
18
+ header: "AI Actions",
19
+ askAi: "Ask AI",
20
+ rewrite: "Rewrite",
21
+ expand: "Expand",
22
+ summarize: "Summarize",
23
+ translate: "Translate",
24
+ explain: "Explain",
25
+ fixGrammar: "Fix grammar",
26
+ makeFormal: "Make formal",
27
+ makeCasual: "Make casual",
28
+ custom: "Custom",
29
+ customPlaceholder: "Custom prompt…"
30
+ },
31
+ aiPreview: {
32
+ defaultTitle: "AI Response",
33
+ labels: {
34
+ rewrite: "Rewrite",
35
+ expand: "Expand",
36
+ summarize: "Summary",
37
+ translate: "Translation",
38
+ explain: "Explanation",
39
+ fixGrammar: "Grammar Fix",
40
+ makeFormal: "Formal Version",
41
+ makeCasual: "Casual Version",
42
+ custom: "AI Response",
43
+ askAi: "AI Response"
44
+ },
45
+ loading: "Processing…",
46
+ original: "Original:",
47
+ suggested: "Suggested:",
48
+ edit: "Edit",
49
+ discard: "Discard",
50
+ accept: "Accept",
51
+ retry: "Retry",
52
+ close: "Close"
53
+ }
54
+ }, E = [
55
+ "aria-hidden",
56
+ "aria-label",
57
+ "data-state"
58
+ ], ee = [
59
+ "aria-label",
60
+ "aria-valuenow",
61
+ "aria-valuemin",
62
+ "aria-valuemax",
63
+ "aria-valuetext"
64
+ ], D = ["aria-label", "title"], O = "eigenpal:docx-editor:agentPanelWidth", k = /* @__PURE__ */ c({
65
+ __name: "AgentPanel",
66
+ props: {
67
+ title: { default: () => T.agentPanel.defaultTitle },
68
+ closeLabel: { default: () => T.agentPanel.close },
69
+ resizeHandleLabel: { default: () => T.agentPanel.resizeHandle },
70
+ width: { default: void 0 },
71
+ defaultWidth: { default: 360 },
72
+ minWidth: { default: 280 },
73
+ maxWidth: { default: 600 },
74
+ closed: {
75
+ type: Boolean,
76
+ default: !1
77
+ },
78
+ closable: {
79
+ type: Boolean,
80
+ default: !0
81
+ },
82
+ className: { default: "" }
83
+ },
84
+ emits: ["close", "update:width"],
85
+ setup(e, { emit: t }) {
86
+ let r = e, s = t, c = n(() => r.width !== void 0);
87
+ function l() {
88
+ if (typeof window > "u") return r.defaultWidth;
89
+ try {
90
+ let e = window.localStorage.getItem(O);
91
+ if (e) {
92
+ let t = Number(e);
93
+ if (Number.isFinite(t) && t >= r.minWidth && t <= r.maxWidth) return t;
94
+ }
95
+ } catch {}
96
+ return r.defaultWidth;
97
+ }
98
+ let p = h(c.value ? r.width : l()), g = n(() => c.value ? r.width : p.value), y = h(!1), b = null;
99
+ x(() => r.closed, () => {
100
+ b !== null && window.clearTimeout(b), y.value = !0, b = window.setTimeout(() => {
101
+ y.value = !1, b = null;
102
+ }, 260);
103
+ }, { flush: "post" });
104
+ let S = null;
105
+ function w(e) {
106
+ if (!S) return;
107
+ let t = S.startX - e.clientX, n = Math.min(r.maxWidth, Math.max(r.minWidth, S.startWidth + t));
108
+ S.lastWidth = n, c.value || (p.value = n), s("update:width", n);
109
+ }
110
+ function T() {
111
+ if (!S) return;
112
+ let e = S.lastWidth;
113
+ if (S = null, document.removeEventListener("pointermove", w), document.removeEventListener("pointerup", T), !c.value) try {
114
+ window.localStorage.setItem(O, String(e));
115
+ } catch {}
116
+ }
117
+ function k(e) {
118
+ e.preventDefault(), S = {
119
+ startX: e.clientX,
120
+ startWidth: g.value,
121
+ lastWidth: g.value
122
+ }, document.addEventListener("pointermove", w), document.addEventListener("pointerup", T);
123
+ }
124
+ function A(e) {
125
+ r.closable && (e.stopPropagation(), s("close"));
126
+ }
127
+ function j(e) {
128
+ let t = 0, n = null, i = e.shiftKey ? 64 : 16;
129
+ switch (e.key) {
130
+ case "ArrowLeft":
131
+ t = i;
132
+ break;
133
+ case "ArrowRight":
134
+ t = -i;
135
+ break;
136
+ case "Home":
137
+ n = r.maxWidth;
138
+ break;
139
+ case "End":
140
+ n = r.minWidth;
141
+ break;
142
+ default: return;
143
+ }
144
+ e.preventDefault();
145
+ let a = n === null ? Math.min(r.maxWidth, Math.max(r.minWidth, g.value + t)) : n;
146
+ if (c.value || (p.value = a), s("update:width", a), !c.value) try {
147
+ window.localStorage.setItem(O, String(a));
148
+ } catch {}
149
+ }
150
+ f(() => {
151
+ document.removeEventListener("pointermove", w), document.removeEventListener("pointerup", T), b !== null && window.clearTimeout(b);
152
+ });
153
+ let M = n(() => ({
154
+ width: r.closed ? "0px" : `${g.value}px`,
155
+ flex: r.closed ? "0 0 0px" : `0 0 ${g.value}px`,
156
+ height: "calc(100% - 16px)",
157
+ margin: r.closed ? "8px 0 8px 0" : "8px 8px 8px 12px",
158
+ display: "flex",
159
+ flexDirection: "column",
160
+ background: "#ffffff",
161
+ border: r.closed ? "1px solid transparent" : "1px solid #e3e3e3",
162
+ borderRadius: "16px",
163
+ boxShadow: r.closed ? "none" : "0 1px 2px rgba(60,64,67,0.05), 0 4px 12px rgba(60,64,67,0.08)",
164
+ opacity: +!r.closed,
165
+ pointerEvents: r.closed ? "none" : "auto",
166
+ position: "relative",
167
+ boxSizing: "border-box",
168
+ minWidth: r.closed ? 0 : `${r.minWidth}px`,
169
+ overflow: "hidden",
170
+ fontFamily: "'Google Sans', 'Google Sans Text', system-ui, -apple-system, sans-serif",
171
+ transition: y.value ? "flex-basis 220ms cubic-bezier(0.4, 0, 0.2, 1), width 220ms cubic-bezier(0.4, 0, 0.2, 1), margin 220ms cubic-bezier(0.4, 0, 0.2, 1), opacity 180ms ease, box-shadow 220ms ease, border-color 220ms ease" : "opacity 180ms ease, box-shadow 220ms ease, border-color 220ms ease"
172
+ })), N = {
173
+ position: "absolute",
174
+ left: "-3px",
175
+ top: 0,
176
+ bottom: 0,
177
+ width: "6px",
178
+ cursor: "col-resize",
179
+ touchAction: "none",
180
+ zIndex: 1
181
+ }, P = {
182
+ display: "flex",
183
+ alignItems: "center",
184
+ gap: "10px",
185
+ padding: "14px 16px 10px",
186
+ flex: "0 0 auto",
187
+ background: "#ffffff"
188
+ }, F = {
189
+ display: "inline-flex",
190
+ alignItems: "center",
191
+ color: "#0b57d0"
192
+ }, I = {
193
+ flex: 1,
194
+ fontSize: "15px",
195
+ fontWeight: 500,
196
+ color: "#1f1f1f",
197
+ letterSpacing: "0.1px",
198
+ overflow: "hidden",
199
+ textOverflow: "ellipsis",
200
+ whiteSpace: "nowrap"
201
+ }, L = {
202
+ border: "none",
203
+ background: "transparent",
204
+ padding: "6px",
205
+ cursor: "pointer",
206
+ display: "inline-flex",
207
+ alignItems: "center",
208
+ justifyContent: "center",
209
+ color: "#444746",
210
+ borderRadius: "999px",
211
+ transition: "background 0.15s"
212
+ }, R = {
213
+ flex: 1,
214
+ minHeight: 0,
215
+ overflow: "hidden",
216
+ display: "flex",
217
+ flexDirection: "column"
218
+ };
219
+ function z(e, t) {
220
+ let n = t.currentTarget;
221
+ n && (n.style.background = e ? "#f1f3f4" : "transparent");
222
+ }
223
+ return (t, n) => (m(), a("div", {
224
+ class: u(["ep-agent-panel", e.className]),
225
+ style: d(M.value),
226
+ "aria-hidden": e.closed,
227
+ "aria-label": e.title,
228
+ role: "complementary",
229
+ "data-testid": "agent-panel",
230
+ "data-state": e.closed ? "closed" : "open",
231
+ onKeydown: C(A, ["esc"])
232
+ }, [
233
+ o("div", {
234
+ role: "separator",
235
+ "aria-orientation": "vertical",
236
+ "aria-label": e.resizeHandleLabel,
237
+ "aria-valuenow": g.value,
238
+ "aria-valuemin": e.minWidth,
239
+ "aria-valuemax": e.maxWidth,
240
+ "aria-valuetext": `${g.value} pixels wide`,
241
+ tabindex: "0",
242
+ style: N,
243
+ "data-testid": "agent-panel-resize-handle",
244
+ onPointerdown: k,
245
+ onKeydown: j
246
+ }, null, 40, ee),
247
+ o("div", { style: P }, [
248
+ o("span", { style: F }, [_(t.$slots, "icon", {}, () => [n[3] ||= o("svg", {
249
+ viewBox: "0 -960 960 960",
250
+ width: "22",
251
+ height: "22",
252
+ fill: "currentColor",
253
+ "aria-hidden": "true"
254
+ }, [o("path", { d: "m760-600-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110Zm0 560-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110ZM360-160 260-380 40-480l220-100 100-220 100 220 220 100-220 100-100 220Zm0-194 40-86 86-40-86-40-40-86-40 86-86 40 86 40 40 86Zm0-126Z" })], -1)])]),
255
+ o("span", { style: I }, v(e.title), 1),
256
+ e.closable ? (m(), a("button", {
257
+ key: 0,
258
+ type: "button",
259
+ "aria-label": e.closeLabel,
260
+ title: e.closeLabel,
261
+ "data-testid": "agent-panel-close",
262
+ style: L,
263
+ onClick: n[0] ||= (e) => s("close"),
264
+ onMouseenter: n[1] ||= (e) => z(!0, e),
265
+ onMouseleave: n[2] ||= (e) => z(!1, e)
266
+ }, [...n[4] ||= [o("svg", {
267
+ viewBox: "0 -960 960 960",
268
+ width: "18",
269
+ height: "18",
270
+ fill: "currentColor",
271
+ "aria-hidden": "true"
272
+ }, [o("path", { d: "m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z" })], -1)]], 40, D)) : i("", !0)
273
+ ]),
274
+ o("div", { style: R }, [_(t.$slots, "default")])
275
+ ], 46, E));
276
+ }
277
+ });
278
+ //#endregion
279
+ //#region src/i18n/format-message.ts
280
+ function A(e) {
281
+ let t = {}, n = /(=\d+|\w+)\s*\{([^}]*)\}/g, r;
282
+ for (; (r = n.exec(e)) !== null;) t[r[1]] = r[2];
283
+ return t;
284
+ }
285
+ function j(e, t, n = "en") {
286
+ return t ? e.replace(/\{(\w+),\s*plural,\s*((?:[^{}]|\{[^{}]*\})*)\}/g, (e, r, i) => {
287
+ let a = Number(t[r]);
288
+ if (isNaN(a)) return e;
289
+ let o = A(i), s = o[`=${a}`];
290
+ if (s !== void 0) return s.replace(/#/g, String(a));
291
+ let c;
292
+ try {
293
+ c = new Intl.PluralRules(n).select(a);
294
+ } catch {
295
+ c = a === 1 ? "one" : "other";
296
+ }
297
+ return (o[c] ?? o.other ?? "").replace(/#/g, String(a));
298
+ }).replace(/\{(\w+)\}/g, (e, n) => {
299
+ let r = t[n];
300
+ return r === void 0 ? `{${n}}` : String(r);
301
+ }) : e;
302
+ }
303
+ //#endregion
304
+ //#region src/agent-types.ts
305
+ function M(e) {
306
+ let t = e.replace(/_/g, " ");
307
+ return t.charAt(0).toUpperCase() + t.slice(1);
308
+ }
309
+ //#endregion
310
+ //#region src/vue/components/AgentTimeline.vue?vue&type=script&setup=true&lang.ts
311
+ var N = ["aria-expanded"], P = {
312
+ key: 1,
313
+ style: {
314
+ marginRight: "6px",
315
+ display: "inline-flex"
316
+ },
317
+ "aria-hidden": "true"
318
+ }, F = /* @__PURE__ */ c({
319
+ __name: "AgentTimeline",
320
+ props: {
321
+ toolCalls: {},
322
+ streaming: {
323
+ type: Boolean,
324
+ default: !1
325
+ },
326
+ maxVisibleCalls: { default: 3 },
327
+ humanizeName: {
328
+ type: Function,
329
+ default: void 0
330
+ },
331
+ workingLabel: {
332
+ type: Function,
333
+ default: void 0
334
+ },
335
+ summaryLabel: {
336
+ type: Function,
337
+ default: void 0
338
+ },
339
+ earlierLabel: {
340
+ type: Function,
341
+ default: void 0
342
+ }
343
+ },
344
+ setup(t) {
345
+ let r = t, c = h(null), l = n(() => c.value === null ? !!r.streaming : c.value), u = (e) => (r.humanizeName ?? M)(e), f = (e) => (r.earlierLabel ?? ((e) => j(T.agentPanel.timeline.earlier, { count: e })))(e), p = n(() => {
346
+ let e = r.toolCalls.length;
347
+ return r.streaming ? (r.workingLabel ?? ((e) => j(T.agentPanel.timeline.working, { count: e })))(e) : (r.summaryLabel ?? ((e) => j(T.agentPanel.timeline.summary, { count: e })))(e);
348
+ }), _ = n(() => r.toolCalls.slice(-r.maxVisibleCalls)), y = n(() => Math.max(0, r.toolCalls.length - _.value.length)), b = n(() => ({
349
+ fontSize: "12px",
350
+ color: "#5f6368",
351
+ transition: "transform 0.15s ease",
352
+ marginLeft: "8px",
353
+ display: "inline-block",
354
+ transform: l.value ? "rotate(180deg)" : "rotate(0deg)"
355
+ }));
356
+ function x(e = !1) {
357
+ return {
358
+ marginRight: e ? 0 : "6px",
359
+ display: "inline-flex",
360
+ animation: "epAgentSpin 0.8s linear infinite",
361
+ flexShrink: 0
362
+ };
363
+ }
364
+ let S = {
365
+ timelineWrap: {
366
+ alignSelf: "flex-start",
367
+ maxWidth: "92%",
368
+ background: "#fff",
369
+ border: "1px solid #e1e3e6",
370
+ borderRadius: "12px",
371
+ overflow: "hidden",
372
+ fontFamily: "'Google Sans Text', system-ui, sans-serif"
373
+ },
374
+ timelineHeader: {
375
+ display: "flex",
376
+ alignItems: "center",
377
+ justifyContent: "space-between",
378
+ width: "100%",
379
+ padding: "8px 12px",
380
+ background: "transparent",
381
+ border: "none",
382
+ cursor: "pointer",
383
+ fontSize: "12.5px",
384
+ color: "#1f1f1f",
385
+ fontFamily: "inherit"
386
+ },
387
+ timelineSummary: {
388
+ display: "inline-flex",
389
+ alignItems: "center",
390
+ fontWeight: 500
391
+ },
392
+ timelineList: {
393
+ listStyle: "none",
394
+ margin: 0,
395
+ padding: "4px 12px 10px 12px",
396
+ display: "flex",
397
+ flexDirection: "column",
398
+ gap: "6px",
399
+ borderTop: "1px solid #ececf0"
400
+ },
401
+ timelineItem: {
402
+ display: "flex",
403
+ alignItems: "center",
404
+ gap: "8px",
405
+ fontSize: "12px",
406
+ color: "#444746"
407
+ },
408
+ timelineDot: {
409
+ width: "6px",
410
+ height: "6px",
411
+ borderRadius: "50%",
412
+ flexShrink: 0
413
+ },
414
+ timelineCall: {
415
+ display: "inline-flex",
416
+ flexDirection: "column",
417
+ minWidth: 0
418
+ },
419
+ timelineCallName: { color: "#1f1f1f" },
420
+ timelineError: {
421
+ color: "#d93025",
422
+ fontSize: "11px"
423
+ },
424
+ timelineMore: {
425
+ fontSize: "11px",
426
+ color: "#5f6368",
427
+ fontStyle: "italic",
428
+ paddingLeft: "14px"
429
+ }
430
+ };
431
+ return (n, r) => t.toolCalls.length > 0 ? (m(), a("div", {
432
+ key: 0,
433
+ style: d(S.timelineWrap),
434
+ "data-testid": "agent-timeline"
435
+ }, [o("button", {
436
+ type: "button",
437
+ "aria-expanded": l.value,
438
+ style: d(S.timelineHeader),
439
+ "data-testid": "agent-timeline-toggle",
440
+ onClick: r[0] ||= (e) => c.value = !l.value
441
+ }, [o("span", { style: d(S.timelineSummary) }, [t.streaming ? (m(), a("span", {
442
+ key: 0,
443
+ style: d(x()),
444
+ "aria-hidden": "true"
445
+ }, [...r[1] ||= [o("svg", {
446
+ width: "12",
447
+ height: "12",
448
+ viewBox: "0 0 24 24",
449
+ fill: "none"
450
+ }, [o("circle", {
451
+ cx: "12",
452
+ cy: "12",
453
+ r: "9",
454
+ stroke: "#dadce0",
455
+ "stroke-width": "3",
456
+ fill: "none"
457
+ }), o("path", {
458
+ d: "M21 12a9 9 0 0 0-9-9",
459
+ stroke: "#0b57d0",
460
+ "stroke-width": "3",
461
+ "stroke-linecap": "round"
462
+ })], -1)]], 4)) : (m(), a("span", P, [...r[2] ||= [o("svg", {
463
+ width: "12",
464
+ height: "12",
465
+ viewBox: "0 0 24 24",
466
+ fill: "none"
467
+ }, [o("path", {
468
+ d: "M5 13l4 4L19 7",
469
+ stroke: "#1e8e3e",
470
+ "stroke-width": "2.5",
471
+ "stroke-linecap": "round",
472
+ "stroke-linejoin": "round"
473
+ })], -1)]])), s(" " + v(p.value), 1)], 4), o("span", {
474
+ style: d(b.value),
475
+ "aria-hidden": "true"
476
+ }, "▾", 4)], 12, N), l.value ? (m(), a("ol", {
477
+ key: 0,
478
+ style: d(S.timelineList)
479
+ }, [y.value > 0 ? (m(), a("li", {
480
+ key: 0,
481
+ style: d(S.timelineMore),
482
+ "data-testid": "agent-timeline-earlier"
483
+ }, v(f(y.value)), 5)) : i("", !0), (m(!0), a(e, null, g(_.value, (e) => (m(), a("li", {
484
+ key: e.id,
485
+ style: d(S.timelineItem)
486
+ }, [e.status === "running" ? (m(), a("span", {
487
+ key: 0,
488
+ style: d(x(!0)),
489
+ "aria-hidden": "true"
490
+ }, [...r[3] ||= [o("svg", {
491
+ width: "10",
492
+ height: "10",
493
+ viewBox: "0 0 24 24",
494
+ fill: "none"
495
+ }, [o("circle", {
496
+ cx: "12",
497
+ cy: "12",
498
+ r: "9",
499
+ stroke: "#dadce0",
500
+ "stroke-width": "3",
501
+ fill: "none"
502
+ }), o("path", {
503
+ d: "M21 12a9 9 0 0 0-9-9",
504
+ stroke: "#0b57d0",
505
+ "stroke-width": "3",
506
+ "stroke-linecap": "round"
507
+ })], -1)]], 4)) : (m(), a("span", {
508
+ key: 1,
509
+ style: d({
510
+ ...S.timelineDot,
511
+ background: e.status === "error" ? "#d93025" : "#1e8e3e"
512
+ }),
513
+ "aria-hidden": "true"
514
+ }, null, 4)), o("span", { style: d(S.timelineCall) }, [o("span", { style: d(S.timelineCallName) }, v(u(e.name)), 5), e.error ? (m(), a("span", {
515
+ key: 0,
516
+ style: d(S.timelineError)
517
+ }, v(e.error), 5)) : i("", !0)], 4)], 4))), 128))], 4)) : i("", !0)], 4)) : i("", !0);
518
+ }
519
+ }), I = ["data-role"], L = ["aria-label"], R = "ep-agent-chat-keyframes", z = /* @__PURE__ */ c({
520
+ __name: "AgentChatLog",
521
+ props: {
522
+ messages: {},
523
+ loading: {
524
+ type: Boolean,
525
+ default: !1
526
+ },
527
+ error: { default: null },
528
+ thinkingLabel: { default: () => T.agentPanel.thinking },
529
+ workingLabel: {
530
+ type: Function,
531
+ default: void 0
532
+ },
533
+ summaryLabel: {
534
+ type: Function,
535
+ default: void 0
536
+ },
537
+ earlierLabel: {
538
+ type: Function,
539
+ default: void 0
540
+ },
541
+ autoScroll: {
542
+ type: Boolean,
543
+ default: !0
544
+ },
545
+ humanizeToolName: {
546
+ type: Function,
547
+ default: void 0
548
+ },
549
+ maxVisibleCalls: { default: 3 },
550
+ className: { default: "" }
551
+ },
552
+ setup(t) {
553
+ let s = t, c = h(null), f = n(() => s.messages.length === 0 && !s.loading && !s.error);
554
+ function y() {
555
+ if (!s.autoScroll) return;
556
+ let e = s.messages[s.messages.length - 1]?.status === "streaming";
557
+ c.value?.scrollIntoView({
558
+ behavior: e || s.loading ? "auto" : "smooth",
559
+ block: "end"
560
+ });
561
+ }
562
+ p(() => {
563
+ l(y), b();
564
+ }), x([
565
+ () => s.messages.length,
566
+ () => s.messages[s.messages.length - 1]?.toolCalls?.length ?? 0,
567
+ () => s.loading,
568
+ () => s.messages[s.messages.length - 1]?.status === "streaming"
569
+ ], y, { flush: "post" });
570
+ function b() {
571
+ if (typeof document > "u" || document.getElementById(R)) return;
572
+ let e = document.createElement("style");
573
+ e.id = R, e.textContent = "\n@keyframes epAgentDot {\n 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }\n 40% { transform: scale(1); opacity: 1; }\n}\n@keyframes epAgentSpin {\n to { transform: rotate(360deg); }\n}\n", document.head.appendChild(e);
574
+ }
575
+ let S = {
576
+ flex: 1,
577
+ overflow: "auto",
578
+ padding: "16px 14px 8px",
579
+ display: "flex",
580
+ flexDirection: "column",
581
+ gap: "10px"
582
+ }, C = {
583
+ messageGroup: {
584
+ display: "flex",
585
+ flexDirection: "column",
586
+ gap: "6px",
587
+ width: "100%"
588
+ },
589
+ userBubble: {
590
+ background: "#0b57d0",
591
+ color: "#fff",
592
+ padding: "10px 14px",
593
+ borderRadius: "20px 20px 4px 20px",
594
+ fontSize: "13.5px",
595
+ lineHeight: 1.5,
596
+ alignSelf: "flex-end",
597
+ maxWidth: "88%",
598
+ whiteSpace: "pre-wrap",
599
+ wordBreak: "break-word",
600
+ fontFamily: "'Google Sans', 'Google Sans Text', system-ui, -apple-system, sans-serif"
601
+ },
602
+ assistantBubble: {
603
+ background: "#f0f4f9",
604
+ color: "#1f1f1f",
605
+ padding: "12px 16px",
606
+ borderRadius: "20px 20px 20px 4px",
607
+ fontSize: "13.5px",
608
+ lineHeight: 1.55,
609
+ alignSelf: "flex-start",
610
+ maxWidth: "92%",
611
+ whiteSpace: "pre-wrap",
612
+ wordBreak: "break-word",
613
+ fontFamily: "'Google Sans', 'Google Sans Text', system-ui, -apple-system, sans-serif"
614
+ },
615
+ thinkingBubble: {
616
+ background: "#f0f4f9",
617
+ padding: "12px 16px",
618
+ borderRadius: "20px 20px 20px 4px",
619
+ alignSelf: "flex-start",
620
+ display: "flex",
621
+ gap: "4px",
622
+ alignItems: "center"
623
+ },
624
+ dot: {
625
+ width: "6px",
626
+ height: "6px",
627
+ borderRadius: "50%",
628
+ background: "#5f6368",
629
+ display: "inline-block",
630
+ animation: "epAgentDot 1.4s infinite ease-in-out"
631
+ },
632
+ errorBubble: {
633
+ background: "#fce8e6",
634
+ color: "#b3261e",
635
+ padding: "10px 14px",
636
+ borderRadius: "16px",
637
+ fontSize: "12.5px",
638
+ alignSelf: "flex-start",
639
+ maxWidth: "92%",
640
+ whiteSpace: "pre-wrap",
641
+ fontFamily: "'Google Sans Text', system-ui, sans-serif"
642
+ }
643
+ };
644
+ return (n, s) => (m(), a("div", {
645
+ class: u(["ep-agent-chat-log", t.className]),
646
+ style: S,
647
+ role: "log",
648
+ "aria-live": "polite",
649
+ "aria-atomic": "false"
650
+ }, [
651
+ f.value ? _(n.$slots, "empty", { key: 0 }) : i("", !0),
652
+ (m(!0), a(e, null, g(t.messages, (e) => (m(), a("div", {
653
+ key: e.id,
654
+ style: d(C.messageGroup),
655
+ "data-role": e.role
656
+ }, [e.role === "assistant" && e.toolCalls && e.toolCalls.length > 0 ? (m(), r(F, {
657
+ key: 0,
658
+ "tool-calls": e.toolCalls,
659
+ streaming: e.status === "streaming",
660
+ "humanize-name": t.humanizeToolName,
661
+ "max-visible-calls": t.maxVisibleCalls,
662
+ "working-label": t.workingLabel,
663
+ "summary-label": t.summaryLabel,
664
+ "earlier-label": t.earlierLabel
665
+ }, null, 8, [
666
+ "tool-calls",
667
+ "streaming",
668
+ "humanize-name",
669
+ "max-visible-calls",
670
+ "working-label",
671
+ "summary-label",
672
+ "earlier-label"
673
+ ])) : i("", !0), e.text.length > 0 ? (m(), a("div", {
674
+ key: 1,
675
+ style: d(e.role === "user" ? C.userBubble : C.assistantBubble)
676
+ }, v(e.text), 5)) : i("", !0)], 12, I))), 128)),
677
+ t.loading ? (m(), a("div", {
678
+ key: 1,
679
+ style: d(C.thinkingBubble),
680
+ "aria-label": t.thinkingLabel
681
+ }, [
682
+ o("span", { style: d({
683
+ ...C.dot,
684
+ animationDelay: "0s"
685
+ }) }, null, 4),
686
+ o("span", { style: d({
687
+ ...C.dot,
688
+ animationDelay: "0.15s"
689
+ }) }, null, 4),
690
+ o("span", { style: d({
691
+ ...C.dot,
692
+ animationDelay: "0.3s"
693
+ }) }, null, 4)
694
+ ], 12, L)) : i("", !0),
695
+ t.error ? (m(), a("div", {
696
+ key: 2,
697
+ style: d(C.errorBubble),
698
+ role: "alert"
699
+ }, v(t.error), 5)) : i("", !0),
700
+ o("div", {
701
+ ref_key: "endEl",
702
+ ref: c
703
+ }, null, 512)
704
+ ], 2));
705
+ }
706
+ }), te = [
707
+ "value",
708
+ "placeholder",
709
+ "disabled"
710
+ ], ne = ["aria-label", "disabled"], re = /* @__PURE__ */ c({
711
+ __name: "AgentComposer",
712
+ props: {
713
+ modelValue: {},
714
+ disabled: {
715
+ type: Boolean,
716
+ default: !1
717
+ },
718
+ placeholder: { default: () => T.agentPanel.composerPlaceholder },
719
+ sendLabel: { default: () => T.agentPanel.send },
720
+ className: { default: "" }
721
+ },
722
+ emits: ["update:modelValue", "submit"],
723
+ setup(e, { emit: t }) {
724
+ let r = e, s = t, c = n(() => r.modelValue.trim().length > 0 && !r.disabled);
725
+ function l() {
726
+ c.value && s("submit");
727
+ }
728
+ let f = n(() => ({
729
+ width: "36px",
730
+ height: "36px",
731
+ borderRadius: "50%",
732
+ border: "none",
733
+ background: "#0b57d0",
734
+ color: "#fff",
735
+ flexShrink: 0,
736
+ display: "inline-flex",
737
+ alignItems: "center",
738
+ justifyContent: "center",
739
+ transition: "background 0.15s, opacity 0.15s, transform 0.15s",
740
+ opacity: c.value ? 1 : .35,
741
+ cursor: c.value ? "pointer" : "not-allowed"
742
+ })), p = {
743
+ composerWrap: {
744
+ padding: "8px 12px 14px",
745
+ background: "#fff",
746
+ flex: "0 0 auto"
747
+ },
748
+ composerShell: {
749
+ display: "flex",
750
+ alignItems: "center",
751
+ gap: "4px",
752
+ padding: "6px 6px 6px 18px",
753
+ background: "#fff",
754
+ border: "1px solid #c4c7c5",
755
+ borderRadius: "28px",
756
+ boxShadow: "0 1px 2px rgba(60,64,67,0.04)",
757
+ transition: "border-color 0.15s, box-shadow 0.15s",
758
+ fontFamily: "'Google Sans Text', system-ui, sans-serif"
759
+ },
760
+ composerInput: {
761
+ flex: 1,
762
+ padding: "8px 0",
763
+ fontSize: "14px",
764
+ border: "none",
765
+ outline: "none",
766
+ background: "transparent",
767
+ fontFamily: "inherit",
768
+ color: "#1f1f1f"
769
+ },
770
+ footnote: {
771
+ fontSize: "11px",
772
+ color: "#5f6368",
773
+ textAlign: "center",
774
+ marginTop: "10px",
775
+ fontFamily: "'Google Sans Text', system-ui, sans-serif"
776
+ }
777
+ };
778
+ return (t, n) => (m(), a("form", {
779
+ class: u(["ep-agent-composer", e.className]),
780
+ style: d(p.composerWrap),
781
+ onSubmit: w(l, ["prevent"])
782
+ }, [o("div", { style: d(p.composerShell) }, [o("input", {
783
+ style: d(p.composerInput),
784
+ value: e.modelValue,
785
+ placeholder: e.placeholder,
786
+ disabled: e.disabled,
787
+ onInput: n[0] ||= (e) => s("update:modelValue", e.target.value)
788
+ }, null, 44, te), o("button", {
789
+ type: "submit",
790
+ "aria-label": e.sendLabel,
791
+ disabled: !c.value,
792
+ style: d(f.value)
793
+ }, [...n[1] ||= [o("svg", {
794
+ width: "16",
795
+ height: "16",
796
+ viewBox: "0 0 24 24",
797
+ fill: "none",
798
+ "aria-hidden": "true"
799
+ }, [o("path", {
800
+ d: "M12 19V5M5 12l7-7 7 7",
801
+ stroke: "currentColor",
802
+ "stroke-width": "2",
803
+ "stroke-linecap": "round",
804
+ "stroke-linejoin": "round"
805
+ })], -1)]], 12, ne)], 4), t.$slots.footnote ? (m(), a("div", {
806
+ key: 0,
807
+ style: d(p.footnote)
808
+ }, [_(t.$slots, "footnote")], 4)) : i("", !0)], 38));
809
+ }
810
+ }), ie = ["disabled"], ae = /* @__PURE__ */ c({
811
+ __name: "AgentSuggestionChip",
812
+ props: {
813
+ label: {},
814
+ disabled: { type: Boolean }
815
+ },
816
+ emits: ["click"],
817
+ setup(e, { emit: t }) {
818
+ let n = t, r = {
819
+ textAlign: "left",
820
+ background: "#fff",
821
+ border: "1px solid #dadce0",
822
+ borderRadius: "18px",
823
+ padding: "10px 14px",
824
+ fontSize: "13px",
825
+ color: "#1f1f1f",
826
+ cursor: "pointer",
827
+ fontFamily: "'Google Sans Text', system-ui, sans-serif",
828
+ lineHeight: 1.4,
829
+ transition: "background 0.15s, border-color 0.15s, box-shadow 0.15s",
830
+ width: "100%"
831
+ };
832
+ return (t, i) => (m(), a("button", {
833
+ type: "button",
834
+ style: r,
835
+ disabled: e.disabled,
836
+ onClick: i[0] ||= (e) => n("click")
837
+ }, v(e.label), 9, ie));
838
+ }
839
+ }), oe = ["aria-label"], se = {
840
+ class: "ai-ctx-menu__header",
841
+ "aria-hidden": "true"
842
+ }, ce = ["onMousedown"], le = ["innerHTML"], ue = { class: "ai-ctx-menu__label" }, de = {
843
+ key: 0,
844
+ class: "ai-ctx-menu__custom"
845
+ }, fe = ["placeholder"], pe = /* @__PURE__ */ c({
846
+ __name: "AIContextMenu",
847
+ props: {
848
+ isOpen: { type: Boolean },
849
+ position: {},
850
+ selectedText: {},
851
+ showCustomPrompt: {
852
+ type: Boolean,
853
+ default: !0
854
+ },
855
+ labels: { default: () => ({}) }
856
+ },
857
+ emits: ["close", "action"],
858
+ setup(s, { emit: c }) {
859
+ let u = s, f = c, p = h(""), _ = h([]);
860
+ x(() => u.isOpen, (e) => {
861
+ e && l(() => _.value[0]?.focus());
862
+ }, { immediate: !0 });
863
+ let y = [
864
+ {
865
+ id: "rewrite",
866
+ icon: "&#x270D;"
867
+ },
868
+ {
869
+ id: "expand",
870
+ icon: "&#x2194;"
871
+ },
872
+ {
873
+ id: "summarize",
874
+ icon: "&#x1F4DD;"
875
+ },
876
+ {
877
+ id: "fixGrammar",
878
+ icon: "&#x2714;"
879
+ },
880
+ {
881
+ id: "makeFormal",
882
+ icon: "&#x1F454;"
883
+ },
884
+ {
885
+ id: "makeCasual",
886
+ icon: "&#x1F60A;"
887
+ },
888
+ {
889
+ id: "translate",
890
+ icon: "&#x1F310;"
891
+ },
892
+ {
893
+ id: "explain",
894
+ icon: "&#x1F4A1;"
895
+ }
896
+ ], E = n(() => u.labels?.header ?? T.aiActions.header), ee = n(() => u.labels?.customPlaceholder ?? T.aiActions.customPlaceholder);
897
+ function D(e) {
898
+ return u.labels?.[e] || (T.aiActions[e] ?? e);
899
+ }
900
+ let O = n(() => {
901
+ let e = u.position.x, t = u.position.y;
902
+ return typeof window < "u" && (e + 220 + 10 > window.innerWidth && (e = window.innerWidth - 220 - 10), t + 360 + 10 > window.innerHeight && (t = window.innerHeight - 360 - 10)), {
903
+ position: "fixed",
904
+ left: `${e}px`,
905
+ top: `${t}px`,
906
+ zIndex: 500
907
+ };
908
+ });
909
+ function k(e) {
910
+ f("action", e, e === "custom" ? p.value : void 0), p.value = "", f("close");
911
+ }
912
+ return (n, c) => (m(), r(t, { to: "body" }, [s.isOpen ? (m(), a("div", {
913
+ key: 0,
914
+ class: "ai-ctx-backdrop",
915
+ onMousedown: c[0] ||= (e) => f("close"),
916
+ onContextmenu: c[1] ||= w((e) => f("close"), ["prevent"])
917
+ }, null, 32)) : i("", !0), s.isOpen ? (m(), a("div", {
918
+ key: 1,
919
+ class: "ai-ctx-menu",
920
+ "aria-label": E.value,
921
+ style: d(O.value),
922
+ tabindex: "-1",
923
+ onContextmenu: c[4] ||= w(() => {}, ["prevent"]),
924
+ onKeydown: c[5] ||= C(w((e) => f("close"), ["stop"]), ["esc"])
925
+ }, [
926
+ o("div", se, v(E.value), 1),
927
+ (m(), a(e, null, g(y, (e) => o("button", {
928
+ key: e.id,
929
+ ref_for: !0,
930
+ ref_key: "itemRefs",
931
+ ref: _,
932
+ class: "ai-ctx-menu__item",
933
+ onMousedown: w((t) => k(e.id), ["prevent"])
934
+ }, [o("span", {
935
+ class: "ai-ctx-menu__icon",
936
+ innerHTML: e.icon
937
+ }, null, 8, le), o("span", ue, v(D(e.id)), 1)], 40, ce)), 64)),
938
+ c[6] ||= o("div", { class: "ai-ctx-menu__divider" }, null, -1),
939
+ s.showCustomPrompt ? (m(), a("div", de, [S(o("input", {
940
+ "onUpdate:modelValue": c[2] ||= (e) => p.value = e,
941
+ class: "ai-ctx-menu__input",
942
+ placeholder: ee.value,
943
+ onKeydown: c[3] ||= C(w((e) => k("custom"), ["prevent"]), ["enter"])
944
+ }, null, 40, fe), [[b, p.value]])])) : i("", !0)
945
+ ], 44, oe)) : i("", !0)]));
946
+ }
947
+ }), B = (e, t) => {
948
+ let n = e.__vccOpts || e;
949
+ for (let [e, r] of t) n[e] = r;
950
+ return n;
951
+ }, me = /* @__PURE__ */ B(pe, [["__scopeId", "data-v-c30da7a7"]]), he = ["aria-label"], ge = { class: "ai-preview__header" }, _e = { class: "ai-preview__title" }, ve = ["aria-label"], ye = {
952
+ key: 0,
953
+ class: "ai-preview__loading"
954
+ }, be = {
955
+ key: 1,
956
+ class: "ai-preview__error"
957
+ }, xe = {
958
+ key: 2,
959
+ class: "ai-preview__content"
960
+ }, Se = {
961
+ key: 0,
962
+ class: "ai-preview__diff"
963
+ }, Ce = { class: "ai-preview__diff-label" }, we = { class: "ai-preview__diff-text ai-preview__diff-text--old" }, Te = { class: "ai-preview__diff-label" }, Ee = { class: "ai-preview__diff-text ai-preview__diff-text--new" }, De = {
964
+ key: 1,
965
+ class: "ai-preview__result"
966
+ }, Oe = {
967
+ key: 3,
968
+ class: "ai-preview__footer"
969
+ }, ke = /* @__PURE__ */ B(/* @__PURE__ */ c({
970
+ __name: "AIResponsePreview",
971
+ props: {
972
+ isVisible: { type: Boolean },
973
+ originalText: {},
974
+ responseText: {},
975
+ action: {},
976
+ isLoading: { type: Boolean },
977
+ error: { default: void 0 },
978
+ allowEdit: {
979
+ type: Boolean,
980
+ default: !0
981
+ },
982
+ showDiff: {
983
+ type: Boolean,
984
+ default: !0
985
+ },
986
+ showRetry: {
987
+ type: Boolean,
988
+ default: !0
989
+ },
990
+ labels: { default: () => ({}) }
991
+ },
992
+ emits: [
993
+ "accept",
994
+ "reject",
995
+ "retry"
996
+ ],
997
+ setup(e, { emit: t }) {
998
+ let r = e, s = t, c = h(!1), l = h(""), u = n(() => ({
999
+ loading: r.labels?.loading ?? T.aiPreview.loading,
1000
+ original: r.labels?.original ?? T.aiPreview.original,
1001
+ suggested: r.labels?.suggested ?? T.aiPreview.suggested,
1002
+ edit: r.labels?.edit ?? T.aiPreview.edit,
1003
+ discard: r.labels?.discard ?? T.aiPreview.discard,
1004
+ accept: r.labels?.accept ?? T.aiPreview.accept,
1005
+ retry: r.labels?.retry ?? T.aiPreview.retry,
1006
+ close: r.labels?.close ?? T.aiPreview.close
1007
+ })), d = n(() => r.labels?.actionTitles?.[r.action] || (T.aiPreview.labels[r.action] ?? T.aiPreview.defaultTitle));
1008
+ x(() => r.responseText, (e) => {
1009
+ l.value = e, c.value = !1;
1010
+ });
1011
+ function f() {
1012
+ s("accept", c.value ? l.value : r.responseText);
1013
+ }
1014
+ return (t, n) => e.isVisible ? (m(), a("div", {
1015
+ key: 0,
1016
+ class: "ai-preview",
1017
+ role: "region",
1018
+ "aria-label": d.value,
1019
+ tabindex: "-1",
1020
+ onKeydown: n[5] ||= C(w((e) => s("reject"), ["stop"]), ["esc"])
1021
+ }, [
1022
+ o("div", ge, [o("span", _e, v(d.value), 1), o("button", {
1023
+ class: "ai-preview__close",
1024
+ "aria-label": u.value.close,
1025
+ onClick: n[0] ||= (e) => s("reject")
1026
+ }, " ✕ ", 8, ve)]),
1027
+ e.isLoading ? (m(), a("div", ye, [n[6] ||= o("span", { class: "ai-preview__spinner" }, null, -1), o("span", null, v(u.value.loading), 1)])) : e.error ? (m(), a("div", be, [o("span", null, v(e.error), 1), e.showRetry ? (m(), a("button", {
1028
+ key: 0,
1029
+ class: "ai-preview__retry",
1030
+ onMousedown: n[1] ||= w((e) => s("retry"), ["prevent"])
1031
+ }, v(u.value.retry), 33)) : i("", !0)])) : (m(), a("div", xe, [e.showDiff ? (m(), a("div", Se, [
1032
+ o("div", Ce, v(u.value.original), 1),
1033
+ o("div", we, v(e.originalText), 1),
1034
+ o("div", Te, v(u.value.suggested), 1),
1035
+ o("div", Ee, v(e.responseText), 1)
1036
+ ])) : (m(), a("div", De, v(e.responseText), 1)), e.allowEdit && c.value ? S((m(), a("textarea", {
1037
+ key: 2,
1038
+ "onUpdate:modelValue": n[2] ||= (e) => l.value = e,
1039
+ class: "ai-preview__textarea",
1040
+ rows: "4"
1041
+ }, null, 512)), [[b, l.value]]) : i("", !0)])),
1042
+ !e.isLoading && !e.error ? (m(), a("div", Oe, [
1043
+ e.allowEdit && !c.value ? (m(), a("button", {
1044
+ key: 0,
1045
+ class: "ai-preview__btn",
1046
+ onMousedown: n[3] ||= w((e) => c.value = !0, ["prevent"])
1047
+ }, v(u.value.edit), 33)) : i("", !0),
1048
+ o("button", {
1049
+ class: "ai-preview__btn",
1050
+ onMousedown: n[4] ||= w((e) => s("reject"), ["prevent"])
1051
+ }, v(u.value.discard), 33),
1052
+ o("button", {
1053
+ class: "ai-preview__btn ai-preview__btn--primary",
1054
+ onMousedown: w(f, ["prevent"])
1055
+ }, v(u.value.accept), 33)
1056
+ ])) : i("", !0)
1057
+ ], 40, he)) : i("", !0);
1058
+ }
1059
+ }), [["__scopeId", "data-v-1226b741"]]), V = [
1060
+ "single",
1061
+ "words",
1062
+ "double",
1063
+ "thick",
1064
+ "dotted",
1065
+ "dottedHeavy",
1066
+ "dash",
1067
+ "dashedHeavy",
1068
+ "dashLong",
1069
+ "dashLongHeavy",
1070
+ "dotDash",
1071
+ "dashDotHeavy",
1072
+ "dotDotDash",
1073
+ "dashDotDotHeavy",
1074
+ "wave",
1075
+ "wavyHeavy",
1076
+ "wavyDouble",
1077
+ "none"
1078
+ ], H = [
1079
+ "black",
1080
+ "blue",
1081
+ "cyan",
1082
+ "darkBlue",
1083
+ "darkCyan",
1084
+ "darkGray",
1085
+ "darkGreen",
1086
+ "darkMagenta",
1087
+ "darkRed",
1088
+ "darkYellow",
1089
+ "green",
1090
+ "lightGray",
1091
+ "magenta",
1092
+ "red",
1093
+ "white",
1094
+ "yellow",
1095
+ "none"
1096
+ ], U = [
1097
+ {
1098
+ name: "read_document",
1099
+ displayName: "Reading document",
1100
+ description: "Read the document content. Returns lines tagged with a stable paragraph id, e.g. \"[2A1F3B] First paragraph\". Use the bracketed id as `paraId` when commenting or suggesting changes — it survives edits, unlike ordinal indices. Returns the vanilla document (the doc as it exists right now, before any tracked suggestions are accepted): pending insertions are HIDDEN, pending deletions are shown as plain text (still part of the document until accepted), and comment markers are stripped. Use read_changes / read_comments to inspect what is pending.",
1101
+ inputSchema: {
1102
+ type: "object",
1103
+ properties: {
1104
+ fromIndex: {
1105
+ type: "number",
1106
+ description: "Start ordinal index (inclusive). Optional."
1107
+ },
1108
+ toIndex: {
1109
+ type: "number",
1110
+ description: "End ordinal index (inclusive). Optional."
1111
+ }
1112
+ }
1113
+ },
1114
+ handler: (e, t) => ({
1115
+ success: !0,
1116
+ data: t.getContentAsText({
1117
+ fromIndex: e.fromIndex,
1118
+ toIndex: e.toIndex,
1119
+ includeTrackedChanges: !1,
1120
+ includeCommentAnchors: !1
1121
+ })
1122
+ })
1123
+ },
1124
+ {
1125
+ name: "read_selection",
1126
+ displayName: "Reading selection",
1127
+ description: "Read the user's current cursor or selection. Returns the selected text, the paragraph it lives in, and that paragraph's `paraId`. Use this when the user asks \"fix this\" or \"review what I have selected\".",
1128
+ inputSchema: {
1129
+ type: "object",
1130
+ properties: {}
1131
+ },
1132
+ handler: (e, t) => {
1133
+ let n = t.getSelection();
1134
+ return n ? {
1135
+ success: !0,
1136
+ data: n
1137
+ } : {
1138
+ success: !1,
1139
+ error: "No selection (editor not focused)."
1140
+ };
1141
+ }
1142
+ },
1143
+ {
1144
+ name: "read_page",
1145
+ displayName: "Reading page",
1146
+ description: "Read the contents of one rendered page (1-indexed). Returns paragraphs on the page, each tagged with its stable paraId. Use this when the user asks \"summarize page 3\" or \"comment on what's on this page\".",
1147
+ inputSchema: {
1148
+ type: "object",
1149
+ properties: { pageNumber: {
1150
+ type: "number",
1151
+ description: "1-indexed page number."
1152
+ } },
1153
+ required: ["pageNumber"]
1154
+ },
1155
+ handler: (e, t) => {
1156
+ let n = t.getPage(e.pageNumber);
1157
+ if (!n) {
1158
+ let n = t.getTotalPages();
1159
+ return n === 0 ? {
1160
+ success: !1,
1161
+ error: "No pages rendered (headless mode or empty document)."
1162
+ } : {
1163
+ success: !1,
1164
+ error: `Page ${e.pageNumber} does not exist (document has ${n} page${n === 1 ? "" : "s"}).`
1165
+ };
1166
+ }
1167
+ return {
1168
+ success: !0,
1169
+ data: n.text || "(empty page)"
1170
+ };
1171
+ }
1172
+ },
1173
+ {
1174
+ name: "read_pages",
1175
+ displayName: "Reading pages",
1176
+ description: "Read a contiguous range of rendered pages (1-indexed, inclusive). Returns paragraphs across the range, each tagged with paraId. Cheaper than calling read_page repeatedly — single round-trip.",
1177
+ inputSchema: {
1178
+ type: "object",
1179
+ properties: {
1180
+ from: {
1181
+ type: "number",
1182
+ description: "1-indexed start page (inclusive)."
1183
+ },
1184
+ to: {
1185
+ type: "number",
1186
+ description: "1-indexed end page (inclusive)."
1187
+ }
1188
+ },
1189
+ required: ["from", "to"]
1190
+ },
1191
+ handler: (e, t) => {
1192
+ let n = t.getPages({
1193
+ from: e.from,
1194
+ to: e.to
1195
+ });
1196
+ if (n.length === 0) {
1197
+ let n = t.getTotalPages();
1198
+ return n === 0 ? {
1199
+ success: !1,
1200
+ error: "No pages rendered (headless mode or empty document)."
1201
+ } : {
1202
+ success: !1,
1203
+ error: `No pages in range ${e.from}–${e.to} (document has ${n} page${n === 1 ? "" : "s"}).`
1204
+ };
1205
+ }
1206
+ return {
1207
+ success: !0,
1208
+ data: n.map((e) => `--- Page ${e.pageNumber} ---\n${e.text || "(empty page)"}`).join("\n\n")
1209
+ };
1210
+ }
1211
+ },
1212
+ {
1213
+ name: "find_text",
1214
+ displayName: "Finding text",
1215
+ description: "Locate paragraphs containing `query`. Returns up to `limit` handles, each with `paraId`, the matched substring, and surrounding context. Pass any returned `paraId` (and the `match` as `search`) to add_comment / suggest_change.",
1216
+ inputSchema: {
1217
+ type: "object",
1218
+ properties: {
1219
+ query: {
1220
+ type: "string",
1221
+ description: "Text to find (substring match)."
1222
+ },
1223
+ caseSensitive: {
1224
+ type: "boolean",
1225
+ description: "Default: false."
1226
+ },
1227
+ limit: {
1228
+ type: "number",
1229
+ description: "Max paragraphs to return. Default: 20."
1230
+ }
1231
+ },
1232
+ required: ["query"]
1233
+ },
1234
+ handler: (e, t) => {
1235
+ let n = t.findText(e.query, {
1236
+ caseSensitive: e.caseSensitive,
1237
+ limit: e.limit
1238
+ });
1239
+ return n.length === 0 ? {
1240
+ success: !0,
1241
+ data: "No matches."
1242
+ } : {
1243
+ success: !0,
1244
+ data: n
1245
+ };
1246
+ }
1247
+ },
1248
+ {
1249
+ name: "read_comments",
1250
+ displayName: "Reading comments",
1251
+ description: "List all comments in the document with their paragraph anchors.",
1252
+ inputSchema: {
1253
+ type: "object",
1254
+ properties: {}
1255
+ },
1256
+ handler: (e, t) => {
1257
+ let n = t.getComments();
1258
+ return n.length === 0 ? {
1259
+ success: !0,
1260
+ data: "No comments."
1261
+ } : {
1262
+ success: !0,
1263
+ data: n.map((e) => `[Comment #${e.id}] ${e.author}: "${e.text}"` + (e.anchoredText ? ` (anchored to: "${e.anchoredText}")` : "") + (e.replies.length > 0 ? "\n" + e.replies.map((e) => ` Reply by ${e.author}: "${e.text}"`).join("\n") : "")).join("\n")
1264
+ };
1265
+ }
1266
+ },
1267
+ {
1268
+ name: "read_changes",
1269
+ displayName: "Reading changes",
1270
+ description: "List tracked changes (insertions / deletions) currently in the document.",
1271
+ inputSchema: {
1272
+ type: "object",
1273
+ properties: {}
1274
+ },
1275
+ handler: (e, t) => {
1276
+ let n = t.getChanges();
1277
+ return n.length === 0 ? {
1278
+ success: !0,
1279
+ data: "No tracked changes."
1280
+ } : {
1281
+ success: !0,
1282
+ data: n.map((e) => `[Change #${e.id}] ${e.type} by ${e.author}: "${e.text}"`).join("\n")
1283
+ };
1284
+ }
1285
+ },
1286
+ {
1287
+ name: "add_comment",
1288
+ displayName: "Adding comment",
1289
+ description: "Attach a comment to a paragraph, optionally anchored to a unique phrase within it. The user sees it instantly in the comments sidebar.",
1290
+ inputSchema: {
1291
+ type: "object",
1292
+ properties: {
1293
+ paraId: {
1294
+ type: "string",
1295
+ description: "Paragraph id from read_document / find_text."
1296
+ },
1297
+ text: {
1298
+ type: "string",
1299
+ description: "Comment body."
1300
+ },
1301
+ search: {
1302
+ type: "string",
1303
+ description: "Optional: anchor to this exact phrase within the paragraph. Must be unique."
1304
+ }
1305
+ },
1306
+ required: ["paraId", "text"]
1307
+ },
1308
+ handler: (e, t) => {
1309
+ let n = t.addComment({
1310
+ paraId: e.paraId,
1311
+ text: e.text,
1312
+ search: e.search
1313
+ });
1314
+ return n === null ? {
1315
+ success: !1,
1316
+ error: "Could not add comment. The paraId may not exist, or `search` is missing / ambiguous."
1317
+ } : {
1318
+ success: !0,
1319
+ data: `Comment ${n} added on ${e.paraId}.`
1320
+ };
1321
+ }
1322
+ },
1323
+ {
1324
+ name: "suggest_change",
1325
+ displayName: "Suggesting change",
1326
+ description: "Suggest a tracked change. Three modes: (1) replacement — `search` non-empty, `replaceWith` non-empty; (2) deletion — `search` non-empty, `replaceWith` empty; (3) insertion at paragraph end — `search` empty, `replaceWith` non-empty. The user can accept or reject in the editor UI.",
1327
+ inputSchema: {
1328
+ type: "object",
1329
+ properties: {
1330
+ paraId: {
1331
+ type: "string",
1332
+ description: "Paragraph id from read_document / find_text."
1333
+ },
1334
+ search: {
1335
+ type: "string",
1336
+ description: "Phrase to find (must be unique). Empty string = insert at paragraph end."
1337
+ },
1338
+ replaceWith: {
1339
+ type: "string",
1340
+ description: "Replacement text. Empty string = delete the matched phrase."
1341
+ }
1342
+ },
1343
+ required: [
1344
+ "paraId",
1345
+ "search",
1346
+ "replaceWith"
1347
+ ]
1348
+ },
1349
+ handler: (e, t) => t.proposeChange({
1350
+ paraId: e.paraId,
1351
+ search: e.search,
1352
+ replaceWith: e.replaceWith
1353
+ }) ? e.search ? e.replaceWith ? {
1354
+ success: !0,
1355
+ data: `Replacement proposed: "${e.search}" → "${e.replaceWith}" on ${e.paraId}.`
1356
+ } : {
1357
+ success: !0,
1358
+ data: `Deletion proposed: "${e.search}" on ${e.paraId}.`
1359
+ } : {
1360
+ success: !0,
1361
+ data: `Insertion proposed on ${e.paraId}.`
1362
+ } : {
1363
+ success: !1,
1364
+ error: "Could not propose change. Possible causes: paraId not found; search missing or ambiguous; or the target overlaps an existing tracked change."
1365
+ }
1366
+ },
1367
+ {
1368
+ name: "apply_formatting",
1369
+ displayName: "Applying formatting",
1370
+ description: "Apply character formatting (bold, italic, underline, strike, color, highlight, font size, font family) to a paragraph or to a unique phrase within it. Pass `search` to scope the change to part of the paragraph; omit it to format the whole paragraph. Direct edit — does not create a tracked change. Pass `false` to clear a mark; omit a key to leave it untouched. Color uses `{rgb: \"FF0000\"}` (no hash) or `{themeColor: \"accent1\"}`. Font size is in points. Font family takes `{ascii, hAnsi}`.",
1371
+ inputSchema: {
1372
+ type: "object",
1373
+ properties: {
1374
+ paraId: {
1375
+ type: "string",
1376
+ description: "Paragraph id from read_document / find_text."
1377
+ },
1378
+ search: {
1379
+ type: "string",
1380
+ description: "Optional: format only this exact phrase within the paragraph (must be unique)."
1381
+ },
1382
+ marks: {
1383
+ type: "object",
1384
+ description: "Marks to set or clear. Omit a key to leave it untouched.",
1385
+ properties: {
1386
+ bold: { type: "boolean" },
1387
+ italic: { type: "boolean" },
1388
+ underline: { description: "true → single underline; false → clear; or { style: \"single\"|\"double\"|\"thick\"|\"dotted\"|\"dottedHeavy\"|\"dash\"|\"dashedHeavy\"|\"dashLong\"|\"dashLongHeavy\"|\"dotDash\"|\"dashDotHeavy\"|\"dotDotDash\"|\"dashDotDotHeavy\"|\"wave\"|\"wavyHeavy\"|\"wavyDouble\"|\"words\"|\"none\" }. Other values are rejected." },
1389
+ strike: { type: "boolean" },
1390
+ color: {
1391
+ type: "object",
1392
+ description: "Either {rgb: \"RRGGBB\"} (no hash) or {themeColor: \"accent1\"|\"text1\"|...}.",
1393
+ properties: {
1394
+ rgb: { type: "string" },
1395
+ themeColor: { type: "string" }
1396
+ }
1397
+ },
1398
+ highlight: {
1399
+ type: "string",
1400
+ enum: [...H],
1401
+ description: "Highlight color — must be one of the Word-supported names: " + H.join(", ") + ". Pass \"none\" to clear. Hex values are rejected (Word does not accept hex for <w:highlight>)."
1402
+ },
1403
+ fontSize: {
1404
+ type: "number",
1405
+ description: "Size in points (e.g. 12, 14, 24)."
1406
+ },
1407
+ fontFamily: {
1408
+ type: "object",
1409
+ properties: {
1410
+ ascii: { type: "string" },
1411
+ hAnsi: { type: "string" }
1412
+ }
1413
+ }
1414
+ }
1415
+ }
1416
+ },
1417
+ required: ["paraId", "marks"]
1418
+ },
1419
+ handler: (e, t) => {
1420
+ if (!e.marks || Object.keys(e.marks).length === 0) return {
1421
+ success: !1,
1422
+ error: "No marks provided. Specify at least one of bold/italic/etc."
1423
+ };
1424
+ let n = typeof e.marks.underline == "object" && e.marks.underline !== null ? e.marks.underline.style : void 0;
1425
+ if (n && !V.includes(n)) return {
1426
+ success: !1,
1427
+ error: `Invalid underline.style "${n}". Must be one of: ${V.join(", ")}.`
1428
+ };
1429
+ let r = typeof e.marks.highlight == "string" ? e.marks.highlight : void 0;
1430
+ if (r && !H.includes(r)) return {
1431
+ success: !1,
1432
+ error: `Invalid highlight "${r}". Must be one of: ${H.join(", ")}. Hex values are not supported by Word's highlight attribute.`
1433
+ };
1434
+ let i = r === "none" ? {
1435
+ ...e.marks,
1436
+ highlight: ""
1437
+ } : e.marks;
1438
+ return t.applyFormatting({
1439
+ paraId: e.paraId,
1440
+ search: e.search,
1441
+ marks: i
1442
+ }) ? {
1443
+ success: !0,
1444
+ data: `Formatting applied to ${e.search ? `"${e.search}" in ${e.paraId}` : e.paraId}.`
1445
+ } : {
1446
+ success: !1,
1447
+ error: "Could not apply formatting. The paraId may not exist, or `search` is missing / ambiguous."
1448
+ };
1449
+ }
1450
+ },
1451
+ {
1452
+ name: "set_paragraph_style",
1453
+ displayName: "Setting paragraph style",
1454
+ description: "Apply a paragraph style by id (e.g. \"Heading1\", \"Heading2\", \"Title\", \"Quote\", \"Normal\"). The styleId must exist in the document's style definitions — unknown ids are no-ops. Direct edit, not a tracked change.",
1455
+ inputSchema: {
1456
+ type: "object",
1457
+ properties: {
1458
+ paraId: {
1459
+ type: "string",
1460
+ description: "Paragraph id from read_document / find_text."
1461
+ },
1462
+ styleId: {
1463
+ type: "string",
1464
+ description: "Style id (e.g. \"Heading1\", \"Title\", \"Quote\", \"Normal\")."
1465
+ }
1466
+ },
1467
+ required: ["paraId", "styleId"]
1468
+ },
1469
+ handler: (e, t) => t.setParagraphStyle({
1470
+ paraId: e.paraId,
1471
+ styleId: e.styleId
1472
+ }) ? {
1473
+ success: !0,
1474
+ data: `Style "${e.styleId}" applied to ${e.paraId}.`
1475
+ } : {
1476
+ success: !1,
1477
+ error: `Could not set style. paraId "${e.paraId}" not found, or styleId "${e.styleId}" is not defined.`
1478
+ }
1479
+ },
1480
+ {
1481
+ name: "reply_comment",
1482
+ displayName: "Replying to comment",
1483
+ description: "Reply to an existing comment by id. Threaded under the original.",
1484
+ inputSchema: {
1485
+ type: "object",
1486
+ properties: {
1487
+ commentId: {
1488
+ type: "number",
1489
+ description: "Comment id from read_comments."
1490
+ },
1491
+ text: {
1492
+ type: "string",
1493
+ description: "Reply body."
1494
+ }
1495
+ },
1496
+ required: ["commentId", "text"]
1497
+ },
1498
+ handler: (e, t) => {
1499
+ let n = t.replyTo(e.commentId, { text: e.text });
1500
+ return n === null ? {
1501
+ success: !1,
1502
+ error: `Comment #${e.commentId} not found.`
1503
+ } : {
1504
+ success: !0,
1505
+ data: `Reply ${n} added to comment ${e.commentId}.`
1506
+ };
1507
+ }
1508
+ },
1509
+ {
1510
+ name: "resolve_comment",
1511
+ displayName: "Resolving comment",
1512
+ description: "Mark a comment as resolved (done).",
1513
+ inputSchema: {
1514
+ type: "object",
1515
+ properties: { commentId: {
1516
+ type: "number",
1517
+ description: "Comment id from read_comments."
1518
+ } },
1519
+ required: ["commentId"]
1520
+ },
1521
+ handler: (e, t) => (t.resolveComment(e.commentId), {
1522
+ success: !0,
1523
+ data: `Comment ${e.commentId} resolved.`
1524
+ })
1525
+ },
1526
+ {
1527
+ name: "scroll",
1528
+ displayName: "Scrolling",
1529
+ description: "Scroll the editor to a paragraph by paraId. Does not move the user's cursor.",
1530
+ inputSchema: {
1531
+ type: "object",
1532
+ properties: { paraId: {
1533
+ type: "string",
1534
+ description: "Paragraph id from read_document / find_text."
1535
+ } },
1536
+ required: ["paraId"]
1537
+ },
1538
+ handler: (e, t) => t.scrollTo(e.paraId) ? {
1539
+ success: !0,
1540
+ data: `Scrolled to ${e.paraId}.`
1541
+ } : {
1542
+ success: !1,
1543
+ error: `paraId ${e.paraId} not found.`
1544
+ }
1545
+ }
1546
+ ];
1547
+ function Ae(e, t, n) {
1548
+ let r = U.find((t) => t.name === e);
1549
+ if (!r) return {
1550
+ success: !1,
1551
+ error: `Unknown tool: ${e}`
1552
+ };
1553
+ try {
1554
+ return r.handler(t, n);
1555
+ } catch (e) {
1556
+ return {
1557
+ success: !1,
1558
+ error: e instanceof Error ? e.message : String(e)
1559
+ };
1560
+ }
1561
+ }
1562
+ function je(e) {
1563
+ let t = U.find((t) => t.name === e);
1564
+ if (t?.displayName) return t.displayName;
1565
+ let n = e.replace(/_/g, " ");
1566
+ return n.charAt(0).toUpperCase() + n.slice(1);
1567
+ }
1568
+ function Me() {
1569
+ return U.map((e) => ({
1570
+ type: "function",
1571
+ function: {
1572
+ name: e.name,
1573
+ description: e.description,
1574
+ parameters: e.inputSchema
1575
+ }
1576
+ }));
1577
+ }
1578
+ //#endregion
1579
+ //#region ../core/dist/chunk-FWTP7BN7.mjs
1580
+ function W(e) {
1581
+ return e.content.filter((e) => e.type === "text").map((e) => e.text).join("");
1582
+ }
1583
+ function G(e) {
1584
+ let t = [];
1585
+ for (let n of e.children) n.type === "run" && t.push(W(n));
1586
+ return t.join("");
1587
+ }
1588
+ function Ne(e) {
1589
+ return e ? e.toLowerCase().includes("heading") : !1;
1590
+ }
1591
+ function Pe(e) {
1592
+ if (!e) return;
1593
+ let t = e.match(/heading\s*(\d)/i);
1594
+ if (t) return parseInt(t[1], 10);
1595
+ }
1596
+ //#endregion
1597
+ //#region src/utils.ts
1598
+ function K(e) {
1599
+ return e.type === "insertion" || e.type === "deletion" || e.type === "moveFrom" || e.type === "moveTo";
1600
+ }
1601
+ function q(e) {
1602
+ let t = [];
1603
+ for (let n of e) n.type === "run" ? t.push(W(n)) : n.type === "hyperlink" && t.push(G(n));
1604
+ return t.join("");
1605
+ }
1606
+ function J(e, t) {
1607
+ let n = 0;
1608
+ for (let r of e.content) if (r.type === "paragraph") {
1609
+ if (t(r, n) === !1) return;
1610
+ n++;
1611
+ } else if (r.type === "table") {
1612
+ for (let e of r.rows) for (let r of e.cells) for (let e of r.content) if (e.type === "paragraph") {
1613
+ if (t(e, n) === !1) return;
1614
+ n++;
1615
+ }
1616
+ } else n++;
1617
+ }
1618
+ //#endregion
1619
+ //#region src/content.ts
1620
+ function Y(e, t = {}) {
1621
+ let { fromIndex: n, toIndex: r, includeTrackedChanges: i = !0, includeCommentAnchors: a = !0 } = t, o = [], s = 0;
1622
+ for (let t of e.content) if (t.type === "paragraph") X(s, n, r) && o.push(Fe(t, s, i, a)), s++;
1623
+ else if (t.type === "table") {
1624
+ X(s, n, r) && o.push(Ie(t, s, i, a));
1625
+ for (let e of t.rows) for (let t of e.cells) for (let e of t.content) e.type === "paragraph" && s++;
1626
+ } else s++;
1627
+ return o;
1628
+ }
1629
+ function X(e, t, n) {
1630
+ return (t === void 0 || e >= t) && (n === void 0 || e <= n);
1631
+ }
1632
+ function Fe(e, t, n, r) {
1633
+ let i = Z(e, n, r), a = e.formatting?.styleId, o = e.paraId;
1634
+ return Ne(a) ? {
1635
+ type: "heading",
1636
+ index: t,
1637
+ paraId: o,
1638
+ level: Pe(a) ?? 1,
1639
+ text: i
1640
+ } : e.listRendering ? {
1641
+ type: "list-item",
1642
+ index: t,
1643
+ paraId: o,
1644
+ text: i,
1645
+ listLevel: e.listRendering.level ?? 0,
1646
+ listType: e.listRendering.isBullet ? "bullet" : "number"
1647
+ } : {
1648
+ type: "paragraph",
1649
+ index: t,
1650
+ paraId: o,
1651
+ text: i
1652
+ };
1653
+ }
1654
+ function Ie(e, t, n, r) {
1655
+ let i = [], a = [];
1656
+ for (let t of e.rows) {
1657
+ let e = [], o = [];
1658
+ for (let i of t.cells) {
1659
+ let t = [], a;
1660
+ for (let e of i.content) e.type === "paragraph" && (a === void 0 && (a = e.paraId), t.push(Z(e, n, r)));
1661
+ e.push(t.join("\n")), o.push(a);
1662
+ }
1663
+ i.push(e), a.push(o);
1664
+ }
1665
+ return {
1666
+ type: "table",
1667
+ index: t,
1668
+ rows: i,
1669
+ cellParaIds: a
1670
+ };
1671
+ }
1672
+ function Le(e) {
1673
+ let t = [], n = (e) => e.paraId ? e.paraId : String(e.index);
1674
+ for (let r of e) switch (r.type) {
1675
+ case "heading":
1676
+ t.push(`[${n(r)}] (h${r.level}) ${r.text}`);
1677
+ break;
1678
+ case "paragraph":
1679
+ t.push(`[${n(r)}] ${r.text}`);
1680
+ break;
1681
+ case "list-item": {
1682
+ let e = " ".repeat(r.listLevel), i = r.listType === "bullet" ? "•" : "-";
1683
+ t.push(`[${n(r)}] ${e}${i} ${r.text}`);
1684
+ break;
1685
+ }
1686
+ case "table": {
1687
+ let e = r.index;
1688
+ for (let n = 0; n < r.rows.length; n++) for (let i = 0; i < r.rows[n].length; i++) {
1689
+ let a = r.rows[n][i].split("\n"), o = r.cellParaIds?.[n]?.[i];
1690
+ for (let r = 0; r < a.length; r++) {
1691
+ let s = r === 0 && o ? o : String(e);
1692
+ t.push(`[${s}] (table, row ${n + 1}, col ${i + 1}) ${a[r]}`), e++;
1693
+ }
1694
+ }
1695
+ break;
1696
+ }
1697
+ }
1698
+ return t.join("\n");
1699
+ }
1700
+ function Z(e, t, n) {
1701
+ let r = [], i = /* @__PURE__ */ new Set();
1702
+ for (let a of e.content) {
1703
+ if (a.type === "commentRangeStart" && n) {
1704
+ i.add(a.id), r.push(`[comment:${a.id}]`);
1705
+ continue;
1706
+ }
1707
+ if (a.type === "commentRangeEnd" && n) {
1708
+ i.has(a.id) && (i.delete(a.id), r.push("[/comment]"));
1709
+ continue;
1710
+ }
1711
+ if (a.type === "run") r.push(W(a));
1712
+ else if (a.type === "hyperlink") r.push(G(a));
1713
+ else if (K(a)) {
1714
+ let e = q(a.content);
1715
+ a.type === "insertion" || a.type === "moveTo" ? t && r.push(`[+${e}+]{by:${a.info.author}}`) : t ? r.push(`[-${e}-]{by:${a.info.author}}`) : r.push(e);
1716
+ }
1717
+ }
1718
+ return r.join("");
1719
+ }
1720
+ //#endregion
1721
+ //#region src/textSearch.ts
1722
+ function Re(e) {
1723
+ let t = [], n = 0;
1724
+ for (let r = 0; r < e.content.length; r++) {
1725
+ let i = e.content[r];
1726
+ if (i.type === "run") {
1727
+ let e = W(i);
1728
+ t.push({
1729
+ contentIndex: r,
1730
+ run: i,
1731
+ text: e,
1732
+ startPos: n
1733
+ }), n += e.length;
1734
+ } else if (i.type === "hyperlink") for (let e = 0; e < i.children.length; e++) {
1735
+ let a = i.children[e];
1736
+ if (a.type === "run") {
1737
+ let e = W(a);
1738
+ t.push({
1739
+ contentIndex: r,
1740
+ run: a,
1741
+ text: e,
1742
+ startPos: n
1743
+ }), n += e.length;
1744
+ }
1745
+ }
1746
+ else if (K(i)) {
1747
+ if (i.type === "insertion" || i.type === "moveTo") continue;
1748
+ for (let e = 0; e < i.content.length; e++) {
1749
+ let a = i.content[e];
1750
+ if (a.type === "run") {
1751
+ let e = W(a);
1752
+ t.push({
1753
+ contentIndex: r,
1754
+ run: a,
1755
+ text: e,
1756
+ startPos: n
1757
+ }), n += e.length;
1758
+ } else if (a.type === "hyperlink") {
1759
+ for (let e of a.children) if (e.type === "run") {
1760
+ let i = W(e);
1761
+ t.push({
1762
+ contentIndex: r,
1763
+ run: e,
1764
+ text: i,
1765
+ startPos: n
1766
+ }), n += i.length;
1767
+ }
1768
+ }
1769
+ }
1770
+ }
1771
+ }
1772
+ return t;
1773
+ }
1774
+ function Q(e) {
1775
+ return Re(e).map((e) => e.text).join("");
1776
+ }
1777
+ //#endregion
1778
+ //#region src/discovery.ts
1779
+ function ze(e, t) {
1780
+ let n = /* @__PURE__ */ new Map();
1781
+ return J(e, (e, t) => {
1782
+ let r = null;
1783
+ for (let i of e.content) if (K(i)) {
1784
+ r === null && (r = Q(e));
1785
+ let a = q(i.content), o = i.info.id, s = n.get(o);
1786
+ s && s.paragraphIndex === t ? s.text += a : n.set(o, {
1787
+ id: o,
1788
+ type: i.type,
1789
+ author: i.info.author,
1790
+ date: i.info.date ?? null,
1791
+ text: a,
1792
+ context: r,
1793
+ paragraphIndex: t
1794
+ });
1795
+ }
1796
+ }), Array.from(n.values()).filter((e) => !(t?.author && e.author !== t.author || t?.type && e.type !== t.type));
1797
+ }
1798
+ function Be(e, t) {
1799
+ let n = e.comments ?? [];
1800
+ if (n.length === 0) return [];
1801
+ let r = He(e), i = [], a = /* @__PURE__ */ new Map();
1802
+ for (let e of n) if (e.parentId !== void 0) {
1803
+ let t = a.get(e.parentId) ?? [];
1804
+ t.push(e), a.set(e.parentId, t);
1805
+ } else i.push(e);
1806
+ return i.map((e) => {
1807
+ let t = r.get(e.id), n = (a.get(e.id) ?? []).map((e) => ({
1808
+ id: e.id,
1809
+ author: e.author,
1810
+ date: e.date ?? null,
1811
+ text: Ve(e)
1812
+ }));
1813
+ return {
1814
+ id: e.id,
1815
+ author: e.author,
1816
+ date: e.date ?? null,
1817
+ text: Ve(e),
1818
+ anchoredText: t?.text ?? "",
1819
+ paragraphIndex: t?.paragraphIndex ?? -1,
1820
+ replies: n,
1821
+ done: e.done ?? !1
1822
+ };
1823
+ }).filter((e) => !(t?.author && e.author !== t.author || t?.done !== void 0 && e.done !== t.done));
1824
+ }
1825
+ function Ve(e) {
1826
+ return e.content.map((e) => Q(e)).join("\n");
1827
+ }
1828
+ function He(e) {
1829
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
1830
+ return J(e, (e, r) => {
1831
+ for (let i of e.content) if (i.type === "commentRangeStart") n.set(i.id, {
1832
+ paragraphIndex: r,
1833
+ parts: []
1834
+ });
1835
+ else if (i.type === "commentRangeEnd") {
1836
+ let e = n.get(i.id);
1837
+ e && (t.set(i.id, {
1838
+ text: e.parts.join(""),
1839
+ paragraphIndex: e.paragraphIndex
1840
+ }), n.delete(i.id));
1841
+ } else if (i.type === "run") {
1842
+ let e = W(i);
1843
+ for (let t of n.values()) t.parts.push(e);
1844
+ } else if (i.type === "hyperlink") {
1845
+ let e = i.children.filter((e) => e.type === "run").map(W).join("");
1846
+ for (let t of n.values()) t.parts.push(e);
1847
+ } else if (K(i)) {
1848
+ if (i.type === "insertion" || i.type === "moveTo") continue;
1849
+ let e = q(i.content);
1850
+ for (let t of n.values()) t.parts.push(e);
1851
+ }
1852
+ }), t;
1853
+ }
1854
+ //#endregion
1855
+ //#region src/bridge.ts
1856
+ function Ue(e) {
1857
+ return !e || e.length === 0 ? "" : e.map((e) => {
1858
+ let t = e;
1859
+ return t?.content ? t.content.map((e) => e.content?.map((e) => e.text || "").join("") || "").join("") : "";
1860
+ }).join("\n");
1861
+ }
1862
+ function $(e) {
1863
+ let t = e.getEditorRef();
1864
+ if (t) {
1865
+ let e = t.getDocument();
1866
+ if (e?.package?.document) return e.package.document;
1867
+ }
1868
+ return e.getDocument()?.package?.document ?? null;
1869
+ }
1870
+ function We(e, t = "AI") {
1871
+ function n(e) {
1872
+ return e ?? t;
1873
+ }
1874
+ return {
1875
+ getContentAsText(t) {
1876
+ let n = $(e);
1877
+ return n ? Le(Y(n, t)) : "";
1878
+ },
1879
+ getContent(t) {
1880
+ let n = $(e);
1881
+ return n ? Y(n, t) : [];
1882
+ },
1883
+ getComments(t) {
1884
+ let n = $(e);
1885
+ if (!n) return [];
1886
+ let r = Be(n, t);
1887
+ if (r.length > 0) return r;
1888
+ let i = e.getComments();
1889
+ if (i.length === 0) return [];
1890
+ let a = /* @__PURE__ */ new Map(), o = [];
1891
+ for (let e of i) if (e.parentId) {
1892
+ let t = a.get(e.parentId);
1893
+ t ? t.push(e) : a.set(e.parentId, [e]);
1894
+ } else o.push(e);
1895
+ let s = [];
1896
+ for (let e of o) {
1897
+ if (t?.author && e.author !== t.author || t?.done !== void 0 && (e.done ?? !1) !== t.done) continue;
1898
+ let n = a.get(e.id) ?? [];
1899
+ s.push({
1900
+ id: e.id,
1901
+ author: e.author,
1902
+ date: e.date ?? null,
1903
+ text: Ue(e.content),
1904
+ anchoredText: "",
1905
+ paragraphIndex: -1,
1906
+ replies: n.map((e) => ({
1907
+ id: e.id,
1908
+ author: e.author,
1909
+ date: e.date ?? null,
1910
+ text: Ue(e.content)
1911
+ })),
1912
+ done: e.done ?? !1
1913
+ });
1914
+ }
1915
+ return s;
1916
+ },
1917
+ getChanges(t) {
1918
+ let n = $(e);
1919
+ return n ? ze(n, t) : [];
1920
+ },
1921
+ findText(t, n) {
1922
+ return e.findInDocument(t, n);
1923
+ },
1924
+ getSelection() {
1925
+ return e.getSelectionInfo();
1926
+ },
1927
+ addComment(t) {
1928
+ return e.addComment({
1929
+ paraId: t.paraId,
1930
+ text: t.text,
1931
+ author: n(t.author),
1932
+ search: t.search
1933
+ });
1934
+ },
1935
+ replyTo(t, r) {
1936
+ return e.replyToComment(t, r.text, n(r.author));
1937
+ },
1938
+ resolveComment(t) {
1939
+ e.resolveComment(t);
1940
+ },
1941
+ proposeChange(t) {
1942
+ return e.proposeChange({
1943
+ paraId: t.paraId,
1944
+ search: t.search,
1945
+ replaceWith: t.replaceWith,
1946
+ author: n(t.author)
1947
+ });
1948
+ },
1949
+ applyFormatting(t) {
1950
+ return e.applyFormatting({
1951
+ paraId: t.paraId,
1952
+ search: t.search,
1953
+ marks: t.marks
1954
+ });
1955
+ },
1956
+ setParagraphStyle(t) {
1957
+ return e.setParagraphStyle({
1958
+ paraId: t.paraId,
1959
+ styleId: t.styleId
1960
+ });
1961
+ },
1962
+ getPage(t) {
1963
+ return e.getPageContent(t);
1964
+ },
1965
+ getPages(t) {
1966
+ let n = e.getTotalPages(), r = Math.max(1, Math.min(t.from, n)), i = Math.max(r, Math.min(t.to, n)), a = [];
1967
+ for (let t = r; t <= i; t++) {
1968
+ let n = e.getPageContent(t);
1969
+ n && a.push(n);
1970
+ }
1971
+ return a;
1972
+ },
1973
+ getTotalPages() {
1974
+ return e.getTotalPages();
1975
+ },
1976
+ getCurrentPage() {
1977
+ return e.getCurrentPage();
1978
+ },
1979
+ scrollTo(t) {
1980
+ return e.scrollToParaId(t);
1981
+ },
1982
+ onContentChange(t) {
1983
+ return e.onContentChange(() => {
1984
+ let n = $(e), r = n ? Be(n) : [], i = n ? ze(n) : [];
1985
+ try {
1986
+ t({
1987
+ commentCount: r.length,
1988
+ changeCount: i.length,
1989
+ comments: r,
1990
+ changes: i
1991
+ });
1992
+ } catch (e) {
1993
+ console.error("onContentChange listener threw:", e);
1994
+ }
1995
+ });
1996
+ },
1997
+ onSelectionChange(t) {
1998
+ return e.onSelectionChange(() => {
1999
+ try {
2000
+ t(e.getSelectionInfo());
2001
+ } catch (e) {
2002
+ console.error("onSelectionChange listener threw:", e);
2003
+ }
2004
+ });
2005
+ }
2006
+ };
2007
+ }
2008
+ //#endregion
2009
+ //#region src/vue/composables/useAgentBridge.ts
2010
+ var Ge = Me();
2011
+ function Ke(e) {
2012
+ let { editorRef: t, author: r = "AI" } = e, i = n(() => t.value ? We(t.value, y(r)) : null);
2013
+ function a(e, t) {
2014
+ let n = i.value;
2015
+ return n ? Ae(e, t, n) : {
2016
+ success: !1,
2017
+ error: "Editor not ready"
2018
+ };
2019
+ }
2020
+ return {
2021
+ executeToolCall: a,
2022
+ toolSchemas: Ge
2023
+ };
2024
+ }
2025
+ //#endregion
2026
+ export { me as AIContextMenu, ke as AIResponsePreview, z as AgentChatLog, re as AgentComposer, k as AgentPanel, ae as AgentSuggestionChip, F as AgentTimeline, je as getToolDisplayName, Ke as useAgentBridge };