@blocknote/xl-ai 0.44.1 → 0.45.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 (62) hide show
  1. package/dist/blocknote-xl-ai.cjs +1 -1
  2. package/dist/blocknote-xl-ai.cjs.map +1 -1
  3. package/dist/blocknote-xl-ai.js +370 -369
  4. package/dist/blocknote-xl-ai.js.map +1 -1
  5. package/dist/{client-C4uaJa77.js → client-B0lU3j7B.js} +60 -29
  6. package/dist/client-B0lU3j7B.js.map +1 -0
  7. package/dist/client-CUJscXD0.cjs +36 -0
  8. package/dist/client-CUJscXD0.cjs.map +1 -0
  9. package/dist/server.cjs +1 -1
  10. package/dist/server.js +1 -1
  11. package/dist/webpack-stats.json +1 -1
  12. package/package.json +9 -9
  13. package/src/AIExtension.ts +6 -2
  14. package/src/api/aiRequest/builder.ts +1 -1
  15. package/src/api/formats/base-tools/createUpdateBlockTool.ts +5 -3
  16. package/src/api/formats/base-tools/delete.ts +5 -1
  17. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/add paragraph and update selection_1_ed2eea810db5ab73a8478e981735f2a6.json +15 -0
  18. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/add paragraph and update selection_1_9d907341d7a5b18529ccaf20cacbbe6f.json +15 -0
  19. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/add paragraph and update selection_1_a7100ba9aeac25c6dbfc977b2325ae74.json +15 -0
  20. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/add paragraph and update selection_1_b6c3311e72a434273d25e4a6dc74731a.json +15 -0
  21. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/fix spelling mid-word selection_1_ce6692c22eda2a757e123681118a333d.json +15 -0
  22. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/translate selection_1_1ad7d1a857e525e2d0f5a8c85b645a0e.json +15 -0
  23. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/fix spelling mid-word selection_1_8c47595610a6a2d15e1c5c751528e97a.json +15 -0
  24. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/translate selection_1_59b3c2f2328276dc62dad98af951d63c.json +15 -0
  25. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/fix spelling mid-word selection_1_a6c5e74c3098077445378d6645e2672e.json +15 -0
  26. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/translate selection_1_d51b8ed2dc61e8f8e333a3221be46316.json +15 -0
  27. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/fix spelling mid-word selection_1_d4b4abc5fa45932eec4efcc43bb337bd.json +15 -0
  28. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/translate selection_1_e4b712a415f8af6f2b49382cac85ae77.json +15 -0
  29. package/src/api/formats/html-blocks/htmlBlocks.ts +1 -1
  30. package/src/api/formats/html-blocks/tools/rebaseTool.ts +6 -2
  31. package/src/api/formats/json/json.ts +1 -1
  32. package/src/api/formats/json/tools/jsontools.test.ts +12 -2
  33. package/src/api/formats/markdown-blocks/markdownBlocks.ts +1 -1
  34. package/src/api/formats/tests/validateTestEnvironment.test.ts +1 -0
  35. package/src/prosemirror/__snapshots__/agent.test.ts.snap +7 -0
  36. package/src/prosemirror/__snapshots__/changeset.test.ts.snap +28 -0
  37. package/src/prosemirror/agent.test.ts +14 -2
  38. package/src/prosemirror/changeset.test.ts +8 -2
  39. package/src/prosemirror/rebaseTool.ts +1 -1
  40. package/src/streamTool/filterValidOperations.ts +1 -0
  41. package/src/streamTool/preprocess.test.ts +32 -66
  42. package/src/streamTool/preprocess.ts +8 -38
  43. package/src/streamTool/toValidatedOperations.ts +12 -0
  44. package/src/streamTool/vercelAiSdk/util/chatHandlers.ts +2 -0
  45. package/src/testUtil/cases/combinedOperationsTestCases.ts +1 -1
  46. package/src/testUtil/cases/editors/simpleEditor.ts +15 -0
  47. package/src/testUtil/cases/index.ts +6 -1
  48. package/src/testUtil/cases/updateOperationTestCases.ts +30 -1
  49. package/src/testUtil/suggestChangesTestUtil.ts +1 -1
  50. package/types/src/streamTool/preprocess.d.ts +0 -13
  51. package/types/src/testUtil/cases/editors/simpleEditor.d.ts +268 -0
  52. package/dist/client-C4uaJa77.js.map +0 -1
  53. package/dist/client-DrruPiJu.cjs +0 -36
  54. package/dist/client-DrruPiJu.cjs.map +0 -1
  55. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/add paragraph and update selection_1_039451748eb07d71d3d7f96c97950d62.json +0 -15
  56. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/add paragraph and update selection_1_a7597ddda3f5117e1572545c53c19414.json +0 -15
  57. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/add paragraph and update selection_1_bb81e06e77589983badfe53e3839ab83.json +0 -15
  58. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/add paragraph and update selection_1_8b11b2a66564f9985f33774d3862cd8c.json +0 -15
  59. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/translate selection_1_885e9088214dbb6d50dcda19d0056f3c.json +0 -15
  60. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/translate selection_1_1e9c30fa14f61508e6d90cbfa4d9b891.json +0 -15
  61. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/translate selection_1_f82bcc59263074bf367562f7380b9cef.json +0 -15
  62. package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/translate selection_1_94c4e51be42ba73c81d7edc503e92b40.json +0 -15
@@ -1,28 +1,28 @@
1
- import { Chat as te } from "@ai-sdk/react";
2
- import { createExtension as oe, createStore as V, getNodeById as ne, UnreachableCaseError as re, mergeCSSClasses as ie } from "@blocknote/core";
3
- import { ForkYDocExtension as L, ShowSelectionExtension as T, filterSuggestionItems as ae, FormattingToolbarExtension as se } from "@blocknote/core/extensions";
4
- import { suggestChanges as le, revertSuggestions as H, applySuggestions as ce } from "@blocknote/prosemirror-suggest-changes";
5
- import { Slice as j, Fragment as R } from "prosemirror-model";
6
- import { Plugin as K, PluginKey as W } from "prosemirror-state";
7
- import { fixTablesKey as ue } from "prosemirror-tables";
8
- import { DecorationSet as q, Decoration as Z } from "prosemirror-view";
9
- import { defaultSelectionBuilder as me } from "y-prosemirror";
10
- import { b as de, s as fe, c as w, a as y } from "./client-C4uaJa77.js";
11
- import { C as ft, P as gt, S as pt, g as ht, d as Ct, f as bt, h as vt, j as St, m as yt, o as wt, n as kt, k as It, p as _t, i as xt, e as Mt, l as Lt, t as Tt } from "./client-C4uaJa77.js";
12
- import { jsxs as ge, jsx as l } from "react/jsx-runtime";
13
- import { useBlockNoteContext as pe, useComponentsContext as P, useSuggestionMenuKeyboardHandler as he, useBlockNoteEditor as A, useExtension as _, useExtensionState as G, BlockPopover as Ce } from "@blocknote/react";
14
- import S, { useState as $, useCallback as I, useMemo as k, useEffect as Y } from "react";
15
- import { offset as be, size as ve, autoUpdate as Se } from "@floating-ui/react";
16
- const D = new W("blocknote-agent-cursor");
17
- function ye(e) {
18
- return new K({
19
- key: D,
1
+ import { Chat as oe } from "@ai-sdk/react";
2
+ import { createExtension as ne, createStore as H, getNodeById as re, UnreachableCaseError as ie, mergeCSSClasses as ae } from "@blocknote/core";
3
+ import { ForkYDocExtension as L, ShowSelectionExtension as T, filterSuggestionItems as se, FormattingToolbarExtension as le } from "@blocknote/core/extensions";
4
+ import { suggestChanges as ce, revertSuggestions as j, applySuggestions as ue } from "@handlewithcare/prosemirror-suggest-changes";
5
+ import { Slice as R, Fragment as q } from "prosemirror-model";
6
+ import { Plugin as W, PluginKey as G } from "prosemirror-state";
7
+ import { fixTablesKey as me } from "prosemirror-tables";
8
+ import { DecorationSet as Z, Decoration as D } from "prosemirror-view";
9
+ import { defaultSelectionBuilder as de } from "y-prosemirror";
10
+ import { b as fe, s as ge, c as y, a as S } from "./client-B0lU3j7B.js";
11
+ import { C as gt, P as pt, S as ht, g as Ct, d as bt, f as vt, h as St, j as yt, m as wt, o as kt, n as It, k as _t, p as xt, i as Mt, e as Lt, l as Tt, t as Pt } from "./client-B0lU3j7B.js";
12
+ import { jsxs as pe, jsx as l } from "react/jsx-runtime";
13
+ import { useBlockNoteContext as he, useComponentsContext as P, useSuggestionMenuKeyboardHandler as Ce, useBlockNoteEditor as A, useExtension as _, useExtensionState as $, BlockPopover as be } from "@blocknote/react";
14
+ import v, { useState as Y, useCallback as I, useMemo as k, useEffect as J } from "react";
15
+ import { offset as ve, size as Se, autoUpdate as ye } from "@floating-ui/react";
16
+ const N = new G("blocknote-agent-cursor");
17
+ function we(e) {
18
+ return new W({
19
+ key: N,
20
20
  view: (t) => ({}),
21
21
  state: {
22
22
  init: () => ({
23
23
  selection: void 0
24
24
  }),
25
- apply: (t, n) => {
25
+ apply: (t, r) => {
26
26
  const o = t.getMeta("aiAgent");
27
27
  return o ? {
28
28
  selection: o.selection
@@ -33,142 +33,143 @@ function ye(e) {
33
33
  },
34
34
  props: {
35
35
  decorations: (t) => {
36
- const { doc: n } = t, { selection: o } = D.getState(t), a = [];
36
+ const { doc: r } = t, { selection: o } = N.getState(t), i = [];
37
37
  if (!o)
38
- return q.create(n, []);
39
- a.push(
40
- Z.widget(o.head, () => we(e), {
38
+ return Z.create(r, []);
39
+ i.push(
40
+ D.widget(o.head, () => ke(e), {
41
41
  key: "agent-cursor",
42
42
  side: 10
43
43
  })
44
44
  );
45
- const u = Math.min(o.anchor, o.head), i = Math.max(o.anchor, o.head);
46
- return a.push(
47
- Z.inline(u, i, me(e), {
45
+ const m = Math.min(o.anchor, o.head), f = Math.max(o.anchor, o.head);
46
+ return i.push(
47
+ D.inline(m, f, de(e), {
48
48
  inclusiveEnd: !0,
49
49
  inclusiveStart: !1
50
50
  })
51
- ), q.create(n, a);
51
+ ), Z.create(r, i);
52
52
  }
53
53
  }
54
54
  });
55
55
  }
56
- const we = (e) => {
56
+ const ke = (e) => {
57
57
  const t = document.createElement("span");
58
58
  t.classList.add("bn-collaboration-cursor__base"), t.setAttribute("data-active", "true");
59
- const n = document.createElement("span");
60
- n.setAttribute("contentedEditable", "false"), n.classList.add("bn-collaboration-cursor__caret"), n.setAttribute("style", `background-color: ${e.color}`);
59
+ const r = document.createElement("span");
60
+ r.setAttribute("contentedEditable", "false"), r.classList.add("bn-collaboration-cursor__caret"), r.setAttribute("style", `background-color: ${e.color}`);
61
61
  const o = document.createElement("span");
62
- return o.classList.add("bn-collaboration-cursor__label"), o.setAttribute("style", `background-color: ${e.color}`), o.insertBefore(document.createTextNode(e.name), null), n.insertBefore(o, null), t.insertBefore(document.createTextNode("⁠"), null), t.insertBefore(n, null), t.insertBefore(document.createTextNode("⁠"), null), t;
63
- }, ke = new W("blocknote-ai-plugin"), b = oe(
62
+ return o.classList.add("bn-collaboration-cursor__label"), o.setAttribute("style", `background-color: ${e.color}`), o.insertBefore(document.createTextNode(e.name), null), r.insertBefore(o, null), t.insertBefore(document.createTextNode("⁠"), null), t.insertBefore(r, null), t.insertBefore(document.createTextNode("⁠"), null), t;
63
+ }, Ie = new G("blocknote-ai-plugin"), b = ne(
64
64
  ({
65
65
  editor: e,
66
66
  options: t
67
67
  }) => {
68
- const n = V(t ?? {}), o = V({
68
+ const r = H(t ?? {}), o = H({
69
69
  aiMenuState: "closed"
70
70
  });
71
- let a, u = !1;
72
- return {
71
+ let i, m = !1;
72
+ const f = ce();
73
+ return f.props.decorations = void 0, {
73
74
  key: "ai",
74
- options: n,
75
+ options: r,
75
76
  store: o,
76
- mount({ signal: i }) {
77
- let r = !1;
77
+ mount({ signal: n }) {
78
+ let a = !1;
78
79
  document.addEventListener(
79
80
  "scroll",
80
81
  () => {
81
- r && (u = !1), r = !0;
82
+ a && (m = !1), a = !0;
82
83
  },
83
84
  {
84
85
  capture: !0,
85
- signal: i
86
+ signal: n
86
87
  }
87
88
  ), document.addEventListener(
88
89
  "scrollend",
89
90
  () => {
90
- r = !1;
91
+ a = !1;
91
92
  },
92
93
  {
93
94
  capture: !0,
94
- signal: i
95
+ signal: n
95
96
  }
96
97
  );
97
98
  },
98
99
  prosemirrorPlugins: [
99
- new K({
100
- key: ke,
101
- filterTransaction: (i) => {
100
+ new W({
101
+ key: Ie,
102
+ filterTransaction: (n) => {
102
103
  var s;
103
- const r = o.state.aiMenuState;
104
- return !(r !== "closed" && r.status === "ai-writing" && (s = i.getMeta(ue)) != null && s.fixTables);
104
+ const a = o.state.aiMenuState;
105
+ return !(a !== "closed" && a.status === "ai-writing" && (s = n.getMeta(me)) != null && s.fixTables);
105
106
  }
106
107
  }),
107
- le(),
108
- ye(
108
+ f,
109
+ we(
109
110
  (t == null ? void 0 : t.agentCursor) || { name: "AI", color: "#8bc6ff" }
110
111
  )
111
112
  ],
112
113
  /**
113
114
  * Open the AI menu at a specific block
114
115
  */
115
- openAIMenuAtBlock(i) {
116
+ openAIMenuAtBlock(n) {
116
117
  var s, c;
117
118
  (s = e.getExtension(T)) == null || s.showSelection(!0), e.isEditable = !1, o.setState({
118
119
  aiMenuState: {
119
- blockId: i,
120
+ blockId: n,
120
121
  status: "user-input"
121
122
  }
122
123
  });
123
- const r = (c = e.domElement) == null ? void 0 : c.querySelector(
124
- `[data-node-type="blockContainer"][data-id="${i}"]`
124
+ const a = (c = e.domElement) == null ? void 0 : c.querySelector(
125
+ `[data-node-type="blockContainer"][data-id="${n}"]`
125
126
  );
126
- r == null || r.scrollIntoView({ block: "center" });
127
+ a == null || a.scrollIntoView({ block: "center" });
127
128
  },
128
129
  /**
129
130
  * Close the AI menu
130
131
  */
131
132
  closeAIMenu() {
132
- var i;
133
+ var n;
133
134
  o.setState({
134
135
  aiMenuState: "closed"
135
- }), a = void 0, (i = e.getExtension(T)) == null || i.showSelection(!1), e.isEditable = !0, e.focus();
136
+ }), i = void 0, (n = e.getExtension(T)) == null || n.showSelection(!1), e.isEditable = !0, e.focus();
136
137
  },
137
138
  /**
138
139
  * Accept the changes made by the LLM
139
140
  */
140
141
  acceptChanges() {
141
- var r;
142
- const i = e.prosemirrorState.doc;
143
- e.exec((s, c) => H(s, (d) => {
144
- c == null || c(d.setMeta("addToHistory", !1));
142
+ var a;
143
+ const n = e.prosemirrorState.doc;
144
+ e.exec((s, c) => j(s, (g) => {
145
+ c == null || c(g.setMeta("addToHistory", !1));
145
146
  })), e.exec((s, c) => {
146
- const d = s.tr;
147
- d.replace(
147
+ const g = s.tr;
148
+ g.replace(
148
149
  0,
149
- d.doc.content.size,
150
- new j(R.from(i), 0, 0)
150
+ g.doc.content.size,
151
+ new R(q.from(n), 0, 0)
151
152
  );
152
- const g = s.apply(d);
153
- return ce(g, (p) => {
153
+ const p = s.apply(g);
154
+ return ue(p, (d) => {
154
155
  c == null || c(
155
- d.replace(
156
+ g.replace(
156
157
  0,
157
- d.doc.content.size,
158
- new j(R.from(p.doc), 0, 0)
158
+ g.doc.content.size,
159
+ new R(q.from(d.doc), 0, 0)
159
160
  )
160
161
  );
161
162
  });
162
- }), (r = e.getExtension(L)) == null || r.merge({ keepChanges: !0 }), this.closeAIMenu();
163
+ }), (a = e.getExtension(L)) == null || a.merge({ keepChanges: !0 }), this.closeAIMenu();
163
164
  },
164
165
  /**
165
166
  * Reject the changes made by the LLM
166
167
  */
167
168
  rejectChanges() {
168
- var i;
169
- e.exec((r, s) => H(r, (c) => {
169
+ var n;
170
+ e.exec((a, s) => j(a, (c) => {
170
171
  s == null || s(c.setMeta("addToHistory", !1));
171
- })), (i = e.getExtension(L)) == null || i.merge({ keepChanges: !1 }), this.closeAIMenu();
172
+ })), (n = e.getExtension(L)) == null || n.merge({ keepChanges: !1 }), this.closeAIMenu();
172
173
  },
173
174
  /**
174
175
  * Abort the current LLM request.
@@ -176,12 +177,12 @@ const we = (e) => {
176
177
  * This will stop the ongoing request and revert any changes made by the AI.
177
178
  * Only valid when there is an active AI request in progress.
178
179
  */
179
- async abort(i) {
180
- const { aiMenuState: r } = o.state;
181
- if (r === "closed" || !a || r.status !== "thinking" && r.status !== "ai-writing")
180
+ async abort(n) {
181
+ const { aiMenuState: a } = o.state;
182
+ if (a === "closed" || !i || a.status !== "thinking" && a.status !== "ai-writing")
182
183
  return;
183
- const s = a.chat;
184
- a.abortController.abort(i), await s.stop();
184
+ const s = i.chat;
185
+ i.abortController.abort(n), await s.stop();
185
186
  },
186
187
  /**
187
188
  * Retry the previous LLM call.
@@ -189,16 +190,16 @@ const we = (e) => {
189
190
  * Only valid if the current status is "error"
190
191
  */
191
192
  async retry() {
192
- const { aiMenuState: i } = o.state;
193
- if (i === "closed" || i.status !== "error" || !a)
193
+ const { aiMenuState: n } = o.state;
194
+ if (n === "closed" || n.status !== "error" || !i)
194
195
  throw new Error(
195
196
  "retry() is only valid when a previous response failed"
196
197
  );
197
- return (a == null ? void 0 : a.chat.status) === "error" ? this.invokeAI({
198
- ...a.previousRequestOptions,
198
+ return (i == null ? void 0 : i.chat.status) === "error" ? this.invokeAI({
199
+ ...i.previousRequestOptions,
199
200
  userPrompt: "An error occured in the previous request. Please retry to accomplish the last user prompt."
200
201
  }) : this.invokeAI({
201
- ...a.previousRequestOptions,
202
+ ...i.previousRequestOptions,
202
203
  userPrompt: "An error occured while executing the previous tool call. Please retry to accomplish the last user prompt."
203
204
  });
204
205
  },
@@ -209,288 +210,288 @@ const we = (e) => {
209
210
  * if you want to implement how an LLM call is executed. Usually, you should
210
211
  * use {@link executeLLMRequest} instead which will handle the status updates for you.
211
212
  */
212
- setAIResponseStatus(i) {
213
+ setAIResponseStatus(n) {
213
214
  var s;
214
- const r = o.state.aiMenuState;
215
- if (r !== "closed")
216
- if (i === "ai-writing" && ((s = e.getExtension(T)) == null || s.showSelection(!1)), typeof i == "object") {
217
- if (i.status !== "error")
218
- throw new re(i.status);
215
+ const a = o.state.aiMenuState;
216
+ if (a !== "closed")
217
+ if (n === "ai-writing" && ((s = e.getExtension(T)) == null || s.showSelection(!1)), typeof n == "object") {
218
+ if (n.status !== "error")
219
+ throw new ie(n.status);
219
220
  this.store.setState({
220
221
  aiMenuState: {
221
- status: i.status,
222
- error: i.error,
223
- blockId: r.blockId
222
+ status: n.status,
223
+ error: n.error,
224
+ blockId: a.blockId
224
225
  }
225
226
  });
226
227
  } else
227
228
  this.store.setState({
228
229
  aiMenuState: {
229
- status: i,
230
- blockId: r.blockId
230
+ status: n,
231
+ blockId: a.blockId
231
232
  }
232
233
  });
233
234
  },
234
235
  /**
235
236
  * @deprecated Use {@link invokeAI} instead
236
237
  */
237
- async callLLM(i) {
238
- return this.invokeAI(i);
238
+ async callLLM(n) {
239
+ return this.invokeAI(n);
239
240
  },
240
241
  /**
241
242
  * Execute a call to an LLM and apply the result to the editor
242
243
  */
243
- async invokeAI(i) {
244
- var r, s, c, d;
245
- this.setAIResponseStatus("thinking"), (r = e.getExtension(L)) == null || r.fork();
244
+ async invokeAI(n) {
245
+ var a, s, c, g;
246
+ this.setAIResponseStatus("thinking"), (a = e.getExtension(L)) == null || a.fork();
246
247
  try {
247
- const g = new AbortController();
248
- a ? (a.previousRequestOptions = i, a.abortController = g) : a = {
249
- previousRequestOptions: i,
250
- chat: ((s = i.chatProvider) == null ? void 0 : s.call(i)) || ((d = (c = this.options.state).chatProvider) == null ? void 0 : d.call(c)) || new te({
248
+ const p = new AbortController();
249
+ i ? (i.previousRequestOptions = n, i.abortController = p) : i = {
250
+ previousRequestOptions: n,
251
+ chat: ((s = n.chatProvider) == null ? void 0 : s.call(n)) || ((g = (c = this.options.state).chatProvider) == null ? void 0 : g.call(c)) || new oe({
251
252
  sendAutomaticallyWhen: () => !1,
252
- transport: i.transport || this.options.state.transport
253
+ transport: n.transport || this.options.state.transport
253
254
  }),
254
- abortController: g
255
+ abortController: p
255
256
  };
256
- const p = a.chat;
257
- i = {
258
- ...n.state,
259
- ...i
257
+ const d = i.chat;
258
+ n = {
259
+ ...r.state,
260
+ ...n
260
261
  };
261
- const h = await de({
262
+ const u = await fe({
262
263
  editor: e,
263
- useSelection: i.useSelection,
264
- deleteEmptyCursorBlock: i.deleteEmptyCursorBlock,
265
- streamToolsProvider: i.streamToolsProvider ?? this.options.state.streamToolsProvider,
266
- documentStateBuilder: i.documentStateBuilder ?? this.options.state.documentStateBuilder,
267
- onBlockUpdated: (v) => {
268
- const B = o.state.aiMenuState, O = B === "closed" ? void 0 : B;
269
- if (!O || O.status !== "ai-writing")
264
+ useSelection: n.useSelection,
265
+ deleteEmptyCursorBlock: n.deleteEmptyCursorBlock,
266
+ streamToolsProvider: n.streamToolsProvider ?? this.options.state.streamToolsProvider,
267
+ documentStateBuilder: n.documentStateBuilder ?? this.options.state.documentStateBuilder,
268
+ onBlockUpdated: (B) => {
269
+ const O = o.state.aiMenuState, z = O === "closed" ? void 0 : O;
270
+ if (!z || z.status !== "ai-writing")
270
271
  return;
271
- const z = ne(
272
- v,
272
+ const V = re(
273
+ B,
273
274
  e.prosemirrorState.doc
274
275
  );
275
- z && (o.setState({
276
+ V && (o.setState({
276
277
  aiMenuState: {
277
- blockId: v,
278
+ blockId: B,
278
279
  status: "ai-writing"
279
280
  }
280
- }), u && e.prosemirrorView.domAtPos(
281
- z.posBeforeNode + 1
281
+ }), m && e.prosemirrorView.domAtPos(
282
+ V.posBeforeNode + 1
282
283
  ).node.scrollIntoView({
283
284
  block: "center"
284
285
  }));
285
286
  },
286
287
  onStart: () => {
287
- u = !0, this.setAIResponseStatus("ai-writing"), h.emptyCursorBlockToDelete && h.editor.getBlock(h.emptyCursorBlockToDelete) && h.editor.removeBlocks([
288
- h.emptyCursorBlockToDelete
288
+ m = !0, this.setAIResponseStatus("ai-writing"), u.emptyCursorBlockToDelete && u.editor.getBlock(u.emptyCursorBlockToDelete) && u.editor.removeBlocks([
289
+ u.emptyCursorBlockToDelete
289
290
  ]);
290
291
  }
291
- }), m = await fe(
292
- p,
293
- h,
292
+ }), C = await ge(
293
+ d,
294
+ u,
294
295
  {
295
296
  role: "user",
296
297
  parts: [
297
298
  {
298
299
  type: "text",
299
- text: i.userPrompt
300
+ text: n.userPrompt
300
301
  }
301
302
  ]
302
303
  },
303
- i.chatRequestOptions || this.options.state.chatRequestOptions,
304
- a.abortController.signal
304
+ n.chatRequestOptions || this.options.state.chatRequestOptions,
305
+ i.abortController.signal
305
306
  );
306
- m.ok && p.status !== "error" || g.signal.aborted ? this.setAIResponseStatus("user-reviewing") : (console.warn("Error calling LLM", {
307
- result: m,
308
- chatStatus: p.status,
309
- chatError: p.error
307
+ C.ok && d.status !== "error" || p.signal.aborted ? this.setAIResponseStatus("user-reviewing") : (console.warn("Error calling LLM", {
308
+ result: C,
309
+ chatStatus: d.status,
310
+ chatError: d.error
310
311
  }), this.setAIResponseStatus({
311
312
  status: "error",
312
- error: m.ok ? p.error : m.error
313
+ error: C.ok ? d.error : C.error
313
314
  }));
314
- } catch (g) {
315
+ } catch (p) {
315
316
  this.setAIResponseStatus({
316
317
  status: "error",
317
- error: g
318
+ error: p
318
319
  }), console.error(
319
320
  "Unexpected error calling LLM",
320
- g,
321
- a == null ? void 0 : a.chat.messages
321
+ p,
322
+ i == null ? void 0 : i.chat.messages
322
323
  );
323
324
  }
324
325
  }
325
326
  };
326
327
  }
327
328
  );
328
- var J = {
329
+ var Q = {
329
330
  color: void 0,
330
331
  size: void 0,
331
332
  className: void 0,
332
333
  style: void 0,
333
334
  attr: void 0
334
- }, N = S.createContext && /* @__PURE__ */ S.createContext(J), Ie = ["attr", "size", "title"];
335
- function _e(e, t) {
335
+ }, F = v.createContext && /* @__PURE__ */ v.createContext(Q), _e = ["attr", "size", "title"];
336
+ function xe(e, t) {
336
337
  if (e == null) return {};
337
- var n = xe(e, t), o, a;
338
+ var r = Me(e, t), o, i;
338
339
  if (Object.getOwnPropertySymbols) {
339
- var u = Object.getOwnPropertySymbols(e);
340
- for (a = 0; a < u.length; a++)
341
- o = u[a], !(t.indexOf(o) >= 0) && Object.prototype.propertyIsEnumerable.call(e, o) && (n[o] = e[o]);
340
+ var m = Object.getOwnPropertySymbols(e);
341
+ for (i = 0; i < m.length; i++)
342
+ o = m[i], !(t.indexOf(o) >= 0) && Object.prototype.propertyIsEnumerable.call(e, o) && (r[o] = e[o]);
342
343
  }
343
- return n;
344
+ return r;
344
345
  }
345
- function xe(e, t) {
346
+ function Me(e, t) {
346
347
  if (e == null) return {};
347
- var n = {};
348
+ var r = {};
348
349
  for (var o in e)
349
350
  if (Object.prototype.hasOwnProperty.call(e, o)) {
350
351
  if (t.indexOf(o) >= 0) continue;
351
- n[o] = e[o];
352
+ r[o] = e[o];
352
353
  }
353
- return n;
354
+ return r;
354
355
  }
355
356
  function x() {
356
357
  return x = Object.assign ? Object.assign.bind() : function(e) {
357
358
  for (var t = 1; t < arguments.length; t++) {
358
- var n = arguments[t];
359
- for (var o in n)
360
- Object.prototype.hasOwnProperty.call(n, o) && (e[o] = n[o]);
359
+ var r = arguments[t];
360
+ for (var o in r)
361
+ Object.prototype.hasOwnProperty.call(r, o) && (e[o] = r[o]);
361
362
  }
362
363
  return e;
363
364
  }, x.apply(this, arguments);
364
365
  }
365
- function F(e, t) {
366
- var n = Object.keys(e);
366
+ function U(e, t) {
367
+ var r = Object.keys(e);
367
368
  if (Object.getOwnPropertySymbols) {
368
369
  var o = Object.getOwnPropertySymbols(e);
369
- t && (o = o.filter(function(a) {
370
- return Object.getOwnPropertyDescriptor(e, a).enumerable;
371
- })), n.push.apply(n, o);
370
+ t && (o = o.filter(function(i) {
371
+ return Object.getOwnPropertyDescriptor(e, i).enumerable;
372
+ })), r.push.apply(r, o);
372
373
  }
373
- return n;
374
+ return r;
374
375
  }
375
376
  function M(e) {
376
377
  for (var t = 1; t < arguments.length; t++) {
377
- var n = arguments[t] != null ? arguments[t] : {};
378
- t % 2 ? F(Object(n), !0).forEach(function(o) {
379
- Me(e, o, n[o]);
380
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : F(Object(n)).forEach(function(o) {
381
- Object.defineProperty(e, o, Object.getOwnPropertyDescriptor(n, o));
378
+ var r = arguments[t] != null ? arguments[t] : {};
379
+ t % 2 ? U(Object(r), !0).forEach(function(o) {
380
+ Le(e, o, r[o]);
381
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : U(Object(r)).forEach(function(o) {
382
+ Object.defineProperty(e, o, Object.getOwnPropertyDescriptor(r, o));
382
383
  });
383
384
  }
384
385
  return e;
385
386
  }
386
- function Me(e, t, n) {
387
- return t = Le(t), t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e;
387
+ function Le(e, t, r) {
388
+ return t = Te(t), t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e;
388
389
  }
389
- function Le(e) {
390
- var t = Te(e, "string");
390
+ function Te(e) {
391
+ var t = Pe(e, "string");
391
392
  return typeof t == "symbol" ? t : t + "";
392
393
  }
393
- function Te(e, t) {
394
+ function Pe(e, t) {
394
395
  if (typeof e != "object" || !e) return e;
395
- var n = e[Symbol.toPrimitive];
396
- if (n !== void 0) {
397
- var o = n.call(e, t);
396
+ var r = e[Symbol.toPrimitive];
397
+ if (r !== void 0) {
398
+ var o = r.call(e, t);
398
399
  if (typeof o != "object") return o;
399
400
  throw new TypeError("@@toPrimitive must return a primitive value.");
400
401
  }
401
402
  return (t === "string" ? String : Number)(e);
402
403
  }
403
- function Q(e) {
404
- return e && e.map((t, n) => /* @__PURE__ */ S.createElement(t.tag, M({
405
- key: n
406
- }, t.attr), Q(t.child)));
404
+ function X(e) {
405
+ return e && e.map((t, r) => /* @__PURE__ */ v.createElement(t.tag, M({
406
+ key: r
407
+ }, t.attr), X(t.child)));
407
408
  }
408
- function C(e) {
409
- return (t) => /* @__PURE__ */ S.createElement(Pe, x({
409
+ function h(e) {
410
+ return (t) => /* @__PURE__ */ v.createElement(Ae, x({
410
411
  attr: M({}, e.attr)
411
- }, t), Q(e.child));
412
+ }, t), X(e.child));
412
413
  }
413
- function Pe(e) {
414
- var t = (n) => {
414
+ function Ae(e) {
415
+ var t = (r) => {
415
416
  var {
416
417
  attr: o,
417
- size: a,
418
- title: u
419
- } = e, i = _e(e, Ie), r = a || n.size || "1em", s;
420
- return n.className && (s = n.className), e.className && (s = (s ? s + " " : "") + e.className), /* @__PURE__ */ S.createElement("svg", x({
418
+ size: i,
419
+ title: m
420
+ } = e, f = xe(e, _e), n = i || r.size || "1em", a;
421
+ return r.className && (a = r.className), e.className && (a = (a ? a + " " : "") + e.className), /* @__PURE__ */ v.createElement("svg", x({
421
422
  stroke: "currentColor",
422
423
  fill: "currentColor",
423
424
  strokeWidth: "0"
424
- }, n.attr, o, i, {
425
- className: s,
425
+ }, r.attr, o, f, {
426
+ className: a,
426
427
  style: M(M({
427
- color: e.color || n.color
428
- }, n.style), e.style),
429
- height: r,
430
- width: r,
428
+ color: e.color || r.color
429
+ }, r.style), e.style),
430
+ height: n,
431
+ width: n,
431
432
  xmlns: "http://www.w3.org/2000/svg"
432
- }), u && /* @__PURE__ */ S.createElement("title", null, u), e.children);
433
+ }), m && /* @__PURE__ */ v.createElement("title", null, m), e.children);
433
434
  };
434
- return N !== void 0 ? /* @__PURE__ */ S.createElement(N.Consumer, null, (n) => t(n)) : t(J);
435
+ return F !== void 0 ? /* @__PURE__ */ v.createElement(F.Consumer, null, (r) => t(r)) : t(Q);
435
436
  }
436
- function X(e) {
437
- return C({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M8 7V11L2 6L8 1V5H13C17.4183 5 21 8.58172 21 13C21 17.4183 17.4183 21 13 21H4V19H13C16.3137 19 19 16.3137 19 13C19 9.68629 16.3137 7 13 7H8Z" }, child: [] }] })(e);
437
+ function ee(e) {
438
+ return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M8 7V11L2 6L8 1V5H13C17.4183 5 21 8.58172 21 13C21 17.4183 17.4183 21 13 21H4V19H13C16.3137 19 19 16.3137 19 13C19 9.68629 16.3137 7 13 7H8Z" }, child: [] }] })(e);
438
439
  }
439
- function U(e) {
440
- return C({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M17.8492 11.6983L17.1421 10.9912L7.24264 20.8907H3V16.648L14.3137 5.33432L19.9706 10.9912C20.3611 11.3817 20.3611 12.0149 19.9706 12.4054L12.8995 19.4765L11.4853 18.0622L17.8492 11.6983ZM15.7279 9.57696L14.3137 8.16274L5 17.4765V18.8907H6.41421L15.7279 9.57696ZM18.5563 2.50589L21.3848 5.33432C21.7753 5.72484 21.7753 6.35801 21.3848 6.74853L19.9706 8.16274L15.7279 3.9201L17.1421 2.50589C17.5327 2.11537 18.1658 2.11537 18.5563 2.50589Z" }, child: [] }] })(e);
441
- }
442
- function Ae(e) {
443
- return C({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M15.1986 9.94447C14.7649 9.5337 14.4859 8.98613 14.4085 8.39384L14.0056 5.31138L11.275 6.79724C10.7503 7.08274 10.1433 7.17888 9.55608 7.06948L6.49998 6.50015L7.06931 9.55625C7.17871 10.1435 7.08257 10.7505 6.79707 11.2751L5.31121 14.0057L8.39367 14.4086C8.98596 14.4861 9.53353 14.7651 9.94431 15.1987L12.0821 17.4557L13.4178 14.6486C13.6745 14.1092 14.109 13.6747 14.6484 13.418L17.4555 12.0823L15.1986 9.94447ZM15.2238 15.5079L13.0111 20.1581C12.8687 20.4573 12.5107 20.5844 12.2115 20.442C12.1448 20.4103 12.0845 20.3665 12.0337 20.3129L8.49229 16.5741C8.39749 16.474 8.27113 16.4096 8.13445 16.3918L3.02816 15.7243C2.69958 15.6814 2.46804 15.3802 2.51099 15.0516C2.52056 14.9784 2.54359 14.9075 2.5789 14.8426L5.04031 10.3192C5.1062 10.1981 5.12839 10.058 5.10314 9.92253L4.16 4.85991C4.09931 4.53414 4.3142 4.22086 4.63997 4.16017C4.7126 4.14664 4.78711 4.14664 4.85974 4.16017L9.92237 5.10331C10.0579 5.12855 10.198 5.10637 10.319 5.04048L14.8424 2.57907C15.1335 2.42068 15.4979 2.52825 15.6562 2.81931C15.6916 2.88421 15.7146 2.95507 15.7241 3.02833L16.3916 8.13462C16.4095 8.2713 16.4739 8.39766 16.5739 8.49245L20.3127 12.0338C20.5533 12.2617 20.5636 12.6415 20.3357 12.8821C20.2849 12.9357 20.2246 12.9795 20.1579 13.0112L15.5078 15.224C15.3833 15.2832 15.283 15.3835 15.2238 15.5079ZM16.0206 17.435L17.4348 16.0208L21.6775 20.2634L20.2633 21.6776L16.0206 17.435Z" }, child: [] }] })(e);
440
+ function K(e) {
441
+ return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M17.8492 11.6983L17.1421 10.9912L7.24264 20.8907H3V16.648L14.3137 5.33432L19.9706 10.9912C20.3611 11.3817 20.3611 12.0149 19.9706 12.4054L12.8995 19.4765L11.4853 18.0622L17.8492 11.6983ZM15.7279 9.57696L14.3137 8.16274L5 17.4765V18.8907H6.41421L15.7279 9.57696ZM18.5563 2.50589L21.3848 5.33432C21.7753 5.72484 21.7753 6.35801 21.3848 6.74853L19.9706 8.16274L15.7279 3.9201L17.1421 2.50589C17.5327 2.11537 18.1658 2.11537 18.5563 2.50589Z" }, child: [] }] })(e);
444
442
  }
445
443
  function Ee(e) {
446
- return C({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z" }, child: [] }] })(e);
444
+ return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M15.1986 9.94447C14.7649 9.5337 14.4859 8.98613 14.4085 8.39384L14.0056 5.31138L11.275 6.79724C10.7503 7.08274 10.1433 7.17888 9.55608 7.06948L6.49998 6.50015L7.06931 9.55625C7.17871 10.1435 7.08257 10.7505 6.79707 11.2751L5.31121 14.0057L8.39367 14.4086C8.98596 14.4861 9.53353 14.7651 9.94431 15.1987L12.0821 17.4557L13.4178 14.6486C13.6745 14.1092 14.109 13.6747 14.6484 13.418L17.4555 12.0823L15.1986 9.94447ZM15.2238 15.5079L13.0111 20.1581C12.8687 20.4573 12.5107 20.5844 12.2115 20.442C12.1448 20.4103 12.0845 20.3665 12.0337 20.3129L8.49229 16.5741C8.39749 16.474 8.27113 16.4096 8.13445 16.3918L3.02816 15.7243C2.69958 15.6814 2.46804 15.3802 2.51099 15.0516C2.52056 14.9784 2.54359 14.9075 2.5789 14.8426L5.04031 10.3192C5.1062 10.1981 5.12839 10.058 5.10314 9.92253L4.16 4.85991C4.09931 4.53414 4.3142 4.22086 4.63997 4.16017C4.7126 4.14664 4.78711 4.14664 4.85974 4.16017L9.92237 5.10331C10.0579 5.12855 10.198 5.10637 10.319 5.04048L14.8424 2.57907C15.1335 2.42068 15.4979 2.52825 15.6562 2.81931C15.6916 2.88421 15.7146 2.95507 15.7241 3.02833L16.3916 8.13462C16.4095 8.2713 16.4739 8.39766 16.5739 8.49245L20.3127 12.0338C20.5533 12.2617 20.5636 12.6415 20.3357 12.8821C20.2849 12.9357 20.2246 12.9795 20.1579 13.0112L15.5078 15.224C15.3833 15.2832 15.283 15.3835 15.2238 15.5079ZM16.0206 17.435L17.4348 16.0208L21.6775 20.2634L20.2633 21.6776L16.0206 17.435Z" }, child: [] }] })(e);
447
445
  }
448
446
  function Be(e) {
449
- return C({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M15 18H16.5C17.8807 18 19 16.8807 19 15.5C19 14.1193 17.8807 13 16.5 13H3V11H16.5C18.9853 11 21 13.0147 21 15.5C21 17.9853 18.9853 20 16.5 20H15V22L11 19L15 16V18ZM3 4H21V6H3V4ZM9 18V20H3V18H9Z" }, child: [] }] })(e);
447
+ return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z" }, child: [] }] })(e);
450
448
  }
451
449
  function Oe(e) {
452
- return C({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M13 6V21H11V6H5V4H19V6H13Z" }, child: [] }] })(e);
450
+ return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M15 18H16.5C17.8807 18 19 16.8807 19 15.5C19 14.1193 17.8807 13 16.5 13H3V11H16.5C18.9853 11 21 13.0147 21 15.5C21 17.9853 18.9853 20 16.5 20H15V22L11 19L15 16V18ZM3 4H21V6H3V4ZM9 18V20H3V18H9Z" }, child: [] }] })(e);
453
451
  }
454
452
  function ze(e) {
455
- return C({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M6.23509 6.45329C4.85101 7.89148 4 9.84636 4 12C4 16.4183 7.58172 20 12 20C13.0808 20 14.1116 19.7857 15.0521 19.3972C15.1671 18.6467 14.9148 17.9266 14.8116 17.6746C14.582 17.115 13.8241 16.1582 12.5589 14.8308C12.2212 14.4758 12.2429 14.2035 12.3636 13.3943L12.3775 13.3029C12.4595 12.7486 12.5971 12.4209 14.4622 12.1248C15.4097 11.9746 15.6589 12.3533 16.0043 12.8777C16.0425 12.9358 16.0807 12.9928 16.1198 13.0499C16.4479 13.5297 16.691 13.6394 17.0582 13.8064C17.2227 13.881 17.428 13.9751 17.7031 14.1314C18.3551 14.504 18.3551 14.9247 18.3551 15.8472V15.9518C18.3551 16.3434 18.3168 16.6872 18.2566 16.9859C19.3478 15.6185 20 13.8854 20 12C20 8.70089 18.003 5.8682 15.1519 4.64482C14.5987 5.01813 13.8398 5.54726 13.575 5.91C13.4396 6.09538 13.2482 7.04166 12.6257 7.11976C12.4626 7.14023 12.2438 7.12589 12.012 7.11097C11.3905 7.07058 10.5402 7.01606 10.268 7.75495C10.0952 8.2232 10.0648 9.49445 10.6239 10.1543C10.7134 10.2597 10.7307 10.4547 10.6699 10.6735C10.59 10.9608 10.4286 11.1356 10.3783 11.1717C10.2819 11.1163 10.0896 10.8931 9.95938 10.7412C9.64554 10.3765 9.25405 9.92233 8.74797 9.78176C8.56395 9.73083 8.36166 9.68867 8.16548 9.64736C7.6164 9.53227 6.99443 9.40134 6.84992 9.09302C6.74442 8.8672 6.74488 8.55621 6.74529 8.22764C6.74529 7.8112 6.74529 7.34029 6.54129 6.88256C6.46246 6.70541 6.35689 6.56446 6.23509 6.45329ZM12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22Z" }, child: [] }] })(e);
453
+ return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M13 6V21H11V6H5V4H19V6H13Z" }, child: [] }] })(e);
456
454
  }
457
455
  function Ve(e) {
458
- return C({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z" }, child: [] }] })(e);
456
+ return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M6.23509 6.45329C4.85101 7.89148 4 9.84636 4 12C4 16.4183 7.58172 20 12 20C13.0808 20 14.1116 19.7857 15.0521 19.3972C15.1671 18.6467 14.9148 17.9266 14.8116 17.6746C14.582 17.115 13.8241 16.1582 12.5589 14.8308C12.2212 14.4758 12.2429 14.2035 12.3636 13.3943L12.3775 13.3029C12.4595 12.7486 12.5971 12.4209 14.4622 12.1248C15.4097 11.9746 15.6589 12.3533 16.0043 12.8777C16.0425 12.9358 16.0807 12.9928 16.1198 13.0499C16.4479 13.5297 16.691 13.6394 17.0582 13.8064C17.2227 13.881 17.428 13.9751 17.7031 14.1314C18.3551 14.504 18.3551 14.9247 18.3551 15.8472V15.9518C18.3551 16.3434 18.3168 16.6872 18.2566 16.9859C19.3478 15.6185 20 13.8854 20 12C20 8.70089 18.003 5.8682 15.1519 4.64482C14.5987 5.01813 13.8398 5.54726 13.575 5.91C13.4396 6.09538 13.2482 7.04166 12.6257 7.11976C12.4626 7.14023 12.2438 7.12589 12.012 7.11097C11.3905 7.07058 10.5402 7.01606 10.268 7.75495C10.0952 8.2232 10.0648 9.49445 10.6239 10.1543C10.7134 10.2597 10.7307 10.4547 10.6699 10.6735C10.59 10.9608 10.4286 11.1356 10.3783 11.1717C10.2819 11.1163 10.0896 10.8931 9.95938 10.7412C9.64554 10.3765 9.25405 9.92233 8.74797 9.78176C8.56395 9.73083 8.36166 9.68867 8.16548 9.64736C7.6164 9.53227 6.99443 9.40134 6.84992 9.09302C6.74442 8.8672 6.74488 8.55621 6.74529 8.22764C6.74529 7.8112 6.74529 7.34029 6.54129 6.88256C6.46246 6.70541 6.35689 6.56446 6.23509 6.45329ZM12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22Z" }, child: [] }] })(e);
459
457
  }
460
458
  function He(e) {
461
- return C({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z" }, child: [] }] })(e);
459
+ return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z" }, child: [] }] })(e);
462
460
  }
463
461
  function je(e) {
464
- return C({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M12 4C9.4095 4 7.10606 5.23053 5.64274 7.14274L8 9.5H2V3.5L4.21863 5.71863C6.05061 3.452 8.85558 2 12 2 17.5228 2 22 6.47715 22 12H20C20 7.58172 16.4183 4 12 4ZM4 12C4 16.4183 7.58172 20 12 20 14.5905 20 16.894 18.7695 18.3573 16.8573L16 14.5 22 14.5V20.5L19.7814 18.2814C17.9494 20.548 15.1444 22 12 22 6.47715 22 2 17.5228 2 12H4Z" }, child: [] }] })(e);
462
+ return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z" }, child: [] }] })(e);
463
+ }
464
+ function Re(e) {
465
+ return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M12 4C9.4095 4 7.10606 5.23053 5.64274 7.14274L8 9.5H2V3.5L4.21863 5.71863C6.05061 3.452 8.85558 2 12 2 17.5228 2 22 6.47715 22 12H20C20 7.58172 16.4183 4 12 4ZM4 12C4 16.4183 7.58172 20 12 20 14.5905 20 16.894 18.7695 18.3573 16.8573L16 14.5 22 14.5V20.5L19.7814 18.2814C17.9494 20.548 15.1444 22 12 22 6.47715 22 2 17.5228 2 12H4Z" }, child: [] }] })(e);
465
466
  }
466
467
  function E(e) {
467
- return C({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M17.0007 1.20825 18.3195 3.68108 20.7923 4.99992 18.3195 6.31876 17.0007 8.79159 15.6818 6.31876 13.209 4.99992 15.6818 3.68108 17.0007 1.20825ZM8.00065 4.33325 10.6673 9.33325 15.6673 11.9999 10.6673 14.6666 8.00065 19.6666 5.33398 14.6666.333984 11.9999 5.33398 9.33325 8.00065 4.33325ZM19.6673 16.3333 18.0007 13.2083 16.334 16.3333 13.209 17.9999 16.334 19.6666 18.0007 22.7916 19.6673 19.6666 22.7923 17.9999 19.6673 16.3333Z" }, child: [] }] })(e);
468
+ return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M17.0007 1.20825 18.3195 3.68108 20.7923 4.99992 18.3195 6.31876 17.0007 8.79159 15.6818 6.31876 13.209 4.99992 15.6818 3.68108 17.0007 1.20825ZM8.00065 4.33325 10.6673 9.33325 15.6673 11.9999 10.6673 14.6666 8.00065 19.6666 5.33398 14.6666.333984 11.9999 5.33398 9.33325 8.00065 4.33325ZM19.6673 16.3333 18.0007 13.2083 16.334 16.3333 13.209 17.9999 16.334 19.6666 18.0007 22.7916 19.6673 19.6666 22.7923 17.9999 19.6673 16.3333Z" }, child: [] }] })(e);
468
469
  }
469
- function ee() {
470
- const e = pe();
471
- return w(e.editor);
470
+ function te() {
471
+ const e = he();
472
+ return y(e.editor);
472
473
  }
473
- const Re = (e) => {
474
- const t = P(), { onManualPromptSubmit: n, promptText: o, onPromptTextChange: a } = e, [u, i] = $(""), r = o || u, s = I(
475
- async (m) => {
476
- m.key === "Enter" && n(r);
474
+ const qe = (e) => {
475
+ const t = P(), { onManualPromptSubmit: r, promptText: o, onPromptTextChange: i } = e, [m, f] = Y(""), n = o || m, a = I(
476
+ async (u) => {
477
+ u.key === "Enter" && r(n);
477
478
  },
478
- [r, n]
479
- ), c = I(
480
- (m) => {
481
- const v = m.currentTarget.value;
482
- a && a(v), o === void 0 && i(v);
479
+ [n, r]
480
+ ), s = I(
481
+ (u) => {
482
+ const C = u.currentTarget.value;
483
+ i && i(C), o === void 0 && f(C);
483
484
  },
484
- [a, i, o]
485
- ), d = k(() => ae(e.items, r), [r, e.items]), { selectedIndex: g, setSelectedIndex: p, handler: f } = he(d, (m) => m.onItemClick()), h = I(
486
- (m) => {
487
- m.key === "Enter" ? d.length > 0 ? f(m) : s(m) : f(m);
485
+ [i, f, o]
486
+ ), c = k(() => se(e.items, n), [n, e.items]), { selectedIndex: g, setSelectedIndex: p, handler: d } = Ce(c, (u) => u.onItemClick()), w = I(
487
+ (u) => {
488
+ u.key === "Enter" ? c.length > 0 ? d(u) : a(u) : d(u);
488
489
  },
489
- [s, f, d.length]
490
+ [a, d, c.length]
490
491
  );
491
- return Y(() => {
492
+ return J(() => {
492
493
  p(0);
493
- }, [r, p]), /* @__PURE__ */ ge("div", { className: "bn-combobox", children: [
494
+ }, [n, p]), /* @__PURE__ */ pe("div", { className: "bn-combobox", children: [
494
495
  /* @__PURE__ */ l(t.Generic.Form.Root, { children: /* @__PURE__ */ l(
495
496
  t.Generic.Form.TextInput,
496
497
  {
@@ -498,12 +499,12 @@ const Re = (e) => {
498
499
  name: "ai-prompt",
499
500
  variant: "large",
500
501
  icon: e.icon,
501
- value: r || "",
502
+ value: n || "",
502
503
  autoFocus: !0,
503
504
  placeholder: e.placeholder,
504
505
  disabled: e.disabled,
505
- onKeyDown: h,
506
- onChange: c,
506
+ onKeyDown: w,
507
+ onChange: s,
507
508
  autoComplete: "off",
508
509
  rightSection: e.rightSection
509
510
  },
@@ -514,37 +515,37 @@ const Re = (e) => {
514
515
  {
515
516
  className: "bn-combobox-items",
516
517
  id: "ai-suggestion-menu",
517
- children: d.map((m, v) => /* @__PURE__ */ l(
518
+ children: c.map((u, C) => /* @__PURE__ */ l(
518
519
  t.SuggestionMenu.Item,
519
520
  {
520
- className: ie(
521
+ className: ae(
521
522
  "bn-suggestion-menu-item",
522
- m.size === "small" ? "bn-suggestion-menu-item-small" : ""
523
+ u.size === "small" ? "bn-suggestion-menu-item-small" : ""
523
524
  ),
524
- id: `bn-suggestion-menu-item-${v}`,
525
- isSelected: v === g,
526
- onClick: m.onItemClick,
527
- item: m
525
+ id: `bn-suggestion-menu-item-${C}`,
526
+ isSelected: C === g,
527
+ onClick: u.onItemClick,
528
+ item: u
528
529
  },
529
- m.title
530
+ u.title
530
531
  ))
531
532
  }
532
533
  )
533
534
  ] });
534
535
  };
535
- function qe(e) {
536
- const t = w(e), n = e.getExtension(b);
537
- return n ? [
536
+ function Ze(e) {
537
+ const t = y(e), r = e.getExtension(b);
538
+ return r ? [
538
539
  {
539
540
  key: "continue_writing",
540
541
  title: t.ai_default_commands.continue_writing.title,
541
542
  aliases: t.ai_default_commands.continue_writing.aliases,
542
- icon: /* @__PURE__ */ l(U, { size: 18 }),
543
+ icon: /* @__PURE__ */ l(K, { size: 18 }),
543
544
  onItemClick: async () => {
544
- await n.invokeAI({
545
+ await r.invokeAI({
545
546
  userPrompt: "Continue writing at the current cursor position related to the previous text. Add multiple blocks if needed. If the document looks like a template / draft, follow the template. Be extensive if needed.",
546
547
  // By default, LLM will be able to add / update / delete blocks. For "continue writing", we only want to allow adding new blocks.
547
- streamToolsProvider: y.html.getStreamToolsProvider({
548
+ streamToolsProvider: S.html.getStreamToolsProvider({
548
549
  defaultStreamTools: {
549
550
  add: !0,
550
551
  delete: !1,
@@ -559,12 +560,12 @@ function qe(e) {
559
560
  key: "summarize",
560
561
  title: t.ai_default_commands.summarize.title,
561
562
  aliases: t.ai_default_commands.summarize.aliases,
562
- icon: /* @__PURE__ */ l(Be, { size: 18 }),
563
+ icon: /* @__PURE__ */ l(Oe, { size: 18 }),
563
564
  onItemClick: async () => {
564
- await n.invokeAI({
565
+ await r.invokeAI({
565
566
  userPrompt: "Summarize",
566
567
  // By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
567
- streamToolsProvider: y.html.getStreamToolsProvider({
568
+ streamToolsProvider: S.html.getStreamToolsProvider({
568
569
  defaultStreamTools: {
569
570
  add: !0,
570
571
  delete: !1,
@@ -579,12 +580,12 @@ function qe(e) {
579
580
  key: "action_items",
580
581
  title: t.ai_default_commands.add_action_items.title,
581
582
  aliases: t.ai_default_commands.add_action_items.aliases,
582
- icon: /* @__PURE__ */ l(Ee, { size: 18 }),
583
+ icon: /* @__PURE__ */ l(Be, { size: 18 }),
583
584
  onItemClick: async () => {
584
- await n.invokeAI({
585
+ await r.invokeAI({
585
586
  userPrompt: "Add action items",
586
587
  // By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
587
- streamToolsProvider: y.html.getStreamToolsProvider({
588
+ streamToolsProvider: S.html.getStreamToolsProvider({
588
589
  defaultStreamTools: {
589
590
  add: !0,
590
591
  delete: !1,
@@ -599,7 +600,7 @@ function qe(e) {
599
600
  key: "write_anything",
600
601
  title: t.ai_default_commands.write_anything.title,
601
602
  aliases: t.ai_default_commands.write_anything.aliases,
602
- icon: /* @__PURE__ */ l(U, { size: 18 }),
603
+ icon: /* @__PURE__ */ l(K, { size: 18 }),
603
604
  onItemClick: (o) => {
604
605
  o(t.ai_default_commands.write_anything.prompt_placeholder);
605
606
  },
@@ -607,20 +608,20 @@ function qe(e) {
607
608
  }
608
609
  ] : [];
609
610
  }
610
- function Ze(e) {
611
- const t = w(e), n = e.getExtension(b);
612
- return n ? [
611
+ function De(e) {
612
+ const t = y(e), r = e.getExtension(b);
613
+ return r ? [
613
614
  {
614
615
  key: "improve_writing",
615
616
  title: t.ai_default_commands.improve_writing.title,
616
617
  aliases: t.ai_default_commands.improve_writing.aliases,
617
- icon: /* @__PURE__ */ l(Oe, { size: 18 }),
618
+ icon: /* @__PURE__ */ l(ze, { size: 18 }),
618
619
  onItemClick: async () => {
619
- await n.invokeAI({
620
+ await r.invokeAI({
620
621
  useSelection: !0,
621
622
  userPrompt: "Improve writing",
622
623
  // By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
623
- streamToolsProvider: y.html.getStreamToolsProvider({
624
+ streamToolsProvider: S.html.getStreamToolsProvider({
624
625
  defaultStreamTools: {
625
626
  add: !1,
626
627
  delete: !1,
@@ -635,13 +636,13 @@ function Ze(e) {
635
636
  key: "fix_spelling",
636
637
  title: t.ai_default_commands.fix_spelling.title,
637
638
  aliases: t.ai_default_commands.fix_spelling.aliases,
638
- icon: /* @__PURE__ */ l(He, { size: 18 }),
639
+ icon: /* @__PURE__ */ l(je, { size: 18 }),
639
640
  onItemClick: async () => {
640
- await n.invokeAI({
641
+ await r.invokeAI({
641
642
  useSelection: !0,
642
643
  userPrompt: "Fix spelling",
643
644
  // By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
644
- streamToolsProvider: y.html.getStreamToolsProvider({
645
+ streamToolsProvider: S.html.getStreamToolsProvider({
645
646
  defaultStreamTools: {
646
647
  add: !1,
647
648
  delete: !1,
@@ -656,7 +657,7 @@ function Ze(e) {
656
657
  key: "translate",
657
658
  title: t.ai_default_commands.translate.title,
658
659
  aliases: t.ai_default_commands.translate.aliases,
659
- icon: /* @__PURE__ */ l(ze, { size: 18 }),
660
+ icon: /* @__PURE__ */ l(Ve, { size: 18 }),
660
661
  onItemClick: (o) => {
661
662
  o(t.ai_default_commands.translate.prompt_placeholder);
662
663
  },
@@ -666,13 +667,13 @@ function Ze(e) {
666
667
  key: "simplify",
667
668
  title: t.ai_default_commands.simplify.title,
668
669
  aliases: t.ai_default_commands.simplify.aliases,
669
- icon: /* @__PURE__ */ l(Ae, { size: 18 }),
670
+ icon: /* @__PURE__ */ l(Ee, { size: 18 }),
670
671
  onItemClick: async () => {
671
- await n.invokeAI({
672
+ await r.invokeAI({
672
673
  useSelection: !0,
673
674
  userPrompt: "Simplify",
674
675
  // By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
675
- streamToolsProvider: y.html.getStreamToolsProvider({
676
+ streamToolsProvider: S.html.getStreamToolsProvider({
676
677
  defaultStreamTools: {
677
678
  add: !1,
678
679
  delete: !1,
@@ -685,16 +686,16 @@ function Ze(e) {
685
686
  }
686
687
  ] : [];
687
688
  }
688
- function De(e) {
689
- const t = w(e), n = e.getExtension(b);
690
- return n ? [
689
+ function Ne(e) {
690
+ const t = y(e), r = e.getExtension(b);
691
+ return r ? [
691
692
  {
692
693
  key: "accept",
693
694
  title: t.ai_menu.actions.accept.title,
694
695
  aliases: t.ai_menu.actions.accept.aliases,
695
- icon: /* @__PURE__ */ l(Ve, { size: 18 }),
696
+ icon: /* @__PURE__ */ l(He, { size: 18 }),
696
697
  onItemClick: () => {
697
- n.acceptChanges();
698
+ r.acceptChanges();
698
699
  },
699
700
  size: "small"
700
701
  },
@@ -702,24 +703,24 @@ function De(e) {
702
703
  key: "revert",
703
704
  title: t.ai_menu.actions.revert.title,
704
705
  aliases: t.ai_menu.actions.revert.aliases,
705
- icon: /* @__PURE__ */ l(X, { size: 18 }),
706
+ icon: /* @__PURE__ */ l(ee, { size: 18 }),
706
707
  onItemClick: () => {
707
- n.rejectChanges();
708
+ r.rejectChanges();
708
709
  },
709
710
  size: "small"
710
711
  }
711
712
  ] : [];
712
713
  }
713
- function Ne(e) {
714
- const t = w(e), n = e.getExtension(b);
715
- return n ? [
714
+ function Fe(e) {
715
+ const t = y(e), r = e.getExtension(b);
716
+ return r ? [
716
717
  {
717
718
  key: "retry",
718
719
  title: t.ai_menu.actions.retry.title,
719
720
  aliases: t.ai_menu.actions.retry.aliases,
720
- icon: /* @__PURE__ */ l(je, { size: 18 }),
721
+ icon: /* @__PURE__ */ l(Re, { size: 18 }),
721
722
  onItemClick: async () => {
722
- await n.retry();
723
+ await r.retry();
723
724
  },
724
725
  size: "small"
725
726
  },
@@ -727,49 +728,49 @@ function Ne(e) {
727
728
  key: "cancel",
728
729
  title: t.ai_menu.actions.cancel.title,
729
730
  aliases: t.ai_menu.actions.cancel.aliases,
730
- icon: /* @__PURE__ */ l(X, { size: 18 }),
731
+ icon: /* @__PURE__ */ l(ee, { size: 18 }),
731
732
  onItemClick: () => {
732
- n.rejectChanges();
733
+ r.rejectChanges();
733
734
  },
734
735
  size: "small"
735
736
  }
736
737
  ] : [];
737
738
  }
738
- function Fe(e, t) {
739
- return t === "user-input" ? e.getSelection() ? Ze(e) : qe(e) : t === "user-reviewing" ? De(e) : t === "error" ? Ne(e) : [];
739
+ function Ue(e, t) {
740
+ return t === "user-input" ? e.getSelection() ? De(e) : Ze(e) : t === "user-reviewing" ? Ne(e) : t === "error" ? Fe(e) : [];
740
741
  }
741
- const Ue = (e) => {
742
- const t = A(), [n, o] = $(""), a = ee(), u = P(), i = _(b), r = G(b, {
743
- selector: (f) => f.aiMenuState !== "closed" ? f.aiMenuState.status : "closed"
744
- }), { items: s } = e, c = k(() => {
745
- let f = [];
746
- return s ? f = s(t, r) : f = Fe(t, r), f.map((h) => ({
747
- ...h,
742
+ const Ke = (e) => {
743
+ const t = A(), [r, o] = Y(""), i = te(), m = P(), f = _(b), n = $(b, {
744
+ selector: (d) => d.aiMenuState !== "closed" ? d.aiMenuState.status : "closed"
745
+ }), { items: a } = e, s = k(() => {
746
+ let d = [];
747
+ return a ? d = a(t, n) : d = Ue(t, n), d.map((w) => ({
748
+ ...w,
748
749
  onItemClick: () => {
749
- h.onItemClick(o);
750
+ w.onItemClick(o);
750
751
  }
751
752
  }));
752
- }, [s, r, t]), d = I(
753
- async (f) => {
754
- await i.invokeAI({
755
- userPrompt: f,
753
+ }, [a, n, t]), c = I(
754
+ async (d) => {
755
+ await f.invokeAI({
756
+ userPrompt: d,
756
757
  useSelection: t.getSelection() !== void 0
757
758
  });
758
759
  },
759
- [i, t]
760
+ [f, t]
760
761
  );
761
- Y(() => {
762
- (r === "ai-writing" || r === "user-reviewing" || r === "error") && o("");
763
- }, [r]);
764
- const g = k(() => r === "thinking" ? a.ai_menu.status.thinking : r === "ai-writing" ? a.ai_menu.status.editing : r === "error" ? a.ai_menu.status.error : a.ai_menu.input_placeholder, [r, a]), p = k(() => {
765
- if (r === "thinking" || r === "ai-writing")
762
+ J(() => {
763
+ (n === "ai-writing" || n === "user-reviewing" || n === "error") && o("");
764
+ }, [n]);
765
+ const g = k(() => n === "thinking" ? i.ai_menu.status.thinking : n === "ai-writing" ? i.ai_menu.status.editing : n === "error" ? i.ai_menu.status.error : i.ai_menu.input_placeholder, [n, i]), p = k(() => {
766
+ if (n === "thinking" || n === "ai-writing")
766
767
  return /* @__PURE__ */ l(
767
- u.SuggestionMenu.Loader,
768
+ m.SuggestionMenu.Loader,
768
769
  {
769
770
  className: "bn-suggestion-menu-loader bn-combobox-right-section"
770
771
  }
771
772
  );
772
- if (r === "error")
773
+ if (n === "error")
773
774
  return /* @__PURE__ */ l("div", { className: "bn-combobox-right-section bn-combobox-error", children: /* @__PURE__ */ l(
774
775
  "svg",
775
776
  {
@@ -781,45 +782,45 @@ const Ue = (e) => {
781
782
  children: /* @__PURE__ */ l("path", { d: "M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm0-160q17 0 28.5-11.5T520-480v-160q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640v160q0 17 11.5 28.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" })
782
783
  }
783
784
  ) });
784
- }, [u, r]);
785
+ }, [m, n]);
785
786
  return /* @__PURE__ */ l(
786
- Re,
787
+ qe,
787
788
  {
788
- onManualPromptSubmit: e.onManualPromptSubmit || d,
789
- items: c,
790
- promptText: n,
789
+ onManualPromptSubmit: e.onManualPromptSubmit || c,
790
+ items: s,
791
+ promptText: r,
791
792
  onPromptTextChange: o,
792
793
  placeholder: g,
793
- disabled: r === "thinking" || r === "ai-writing",
794
+ disabled: n === "thinking" || n === "ai-writing",
794
795
  icon: /* @__PURE__ */ l("div", { className: "bn-combobox-icon", children: /* @__PURE__ */ l(E, {}) }),
795
796
  rightSection: p
796
797
  }
797
798
  );
798
- }, lt = (e) => {
799
- const t = A(), n = _(b), o = G(b, {
799
+ }, ct = (e) => {
800
+ const t = A(), r = _(b), o = $(b, {
800
801
  editor: t,
801
- selector: (r) => r.aiMenuState
802
- }), a = o === "closed" ? void 0 : o.blockId, u = k(
802
+ selector: (n) => n.aiMenuState
803
+ }), i = o === "closed" ? void 0 : o.blockId, m = k(
803
804
  () => ({
804
805
  useFloatingOptions: {
805
806
  open: o !== "closed",
806
807
  placement: "bottom",
807
808
  middleware: [
808
- be(10),
809
+ ve(10),
809
810
  // flip(),
810
- ve({
811
- apply({ rects: r, elements: s }) {
812
- Object.assign(s.floating.style, {
813
- width: `${r.reference.width}px`
811
+ Se({
812
+ apply({ rects: n, elements: a }) {
813
+ Object.assign(a.floating.style, {
814
+ width: `${n.reference.width}px`
814
815
  });
815
816
  }
816
817
  })
817
818
  ],
818
- onOpenChange: (r) => {
819
- r || o === "closed" || (o.status === "user-input" ? n.closeAIMenu() : (o.status === "user-reviewing" || o.status === "error") && n.rejectChanges());
819
+ onOpenChange: (n) => {
820
+ n || o === "closed" || (o.status === "user-input" ? r.closeAIMenu() : (o.status === "user-reviewing" || o.status === "error") && r.rejectChanges());
820
821
  },
821
- whileElementsMounted(r, s, c) {
822
- return Se(r, s, c, {
822
+ whileElementsMounted(n, a, s) {
823
+ return ye(n, a, s, {
823
824
  animationFrame: !0
824
825
  });
825
826
  }
@@ -829,10 +830,10 @@ const Ue = (e) => {
829
830
  // We should just be able to set `referencePress: true` instead of
830
831
  // using this listener, but this doesn't seem to trigger.
831
832
  // (probably because we don't assign the referenceProps to the reference element)
832
- outsidePress: (r) => {
833
- if (r.target instanceof Element) {
834
- const s = r.target.closest(".bn-block");
835
- s && s.getAttribute("data-id") === a && n.closeAIMenu();
833
+ outsidePress: (n) => {
834
+ if (n.target instanceof Element) {
835
+ const a = n.target.closest(".bn-block");
836
+ a && a.getAttribute("data-id") === i && r.closeAIMenu();
836
837
  }
837
838
  return !0;
838
839
  }
@@ -844,31 +845,31 @@ const Ue = (e) => {
844
845
  },
845
846
  ...e.floatingUIOptions
846
847
  }),
847
- [n, o, a, e.floatingUIOptions]
848
- ), i = e.aiMenu || Ue;
849
- return /* @__PURE__ */ l(Ce, { blockId: a, ...u, children: o !== "closed" && /* @__PURE__ */ l(i, {}) });
850
- }, ct = () => {
851
- const e = ee(), t = P(), n = A(), o = _(b), a = _(se), u = () => {
852
- const i = n.getSelection();
853
- if (!i)
848
+ [r, o, i, e.floatingUIOptions]
849
+ ), f = e.aiMenu || Ke;
850
+ return /* @__PURE__ */ l(be, { blockId: i, ...m, children: o !== "closed" && /* @__PURE__ */ l(f, {}) });
851
+ }, ut = () => {
852
+ const e = te(), t = P(), r = A(), o = _(b), i = _(le), m = () => {
853
+ const f = r.getSelection();
854
+ if (!f)
854
855
  throw new Error("No selection");
855
- const r = i.blocks[i.blocks.length - 1].id;
856
- o.openAIMenuAtBlock(r), a.store.setState(!1);
856
+ const n = f.blocks[f.blocks.length - 1].id;
857
+ o.openAIMenuAtBlock(n), i.store.setState(!1);
857
858
  };
858
- return n.isEditable ? /* @__PURE__ */ l(
859
+ return r.isEditable ? /* @__PURE__ */ l(
859
860
  t.Generic.Toolbar.Button,
860
861
  {
861
862
  className: "bn-button",
862
863
  label: e.formatting_toolbar.ai.tooltip,
863
864
  mainTooltip: e.formatting_toolbar.ai.tooltip,
864
865
  icon: /* @__PURE__ */ l(E, {}),
865
- onClick: u
866
+ onClick: m
866
867
  }
867
868
  ) : null;
868
- }, Ke = {
869
+ }, We = {
869
870
  AI: E
870
871
  };
871
- function ut(e) {
872
+ function mt(e) {
872
873
  const t = e.getExtension(b);
873
874
  return t ? [
874
875
  {
@@ -878,40 +879,40 @@ function ut(e) {
878
879
  o.block.content && Array.isArray(o.block.content) && // isarray check not ideal
879
880
  o.block.content.length === 0 && o.prevBlock ? t.openAIMenuAtBlock(o.prevBlock.id) : t.openAIMenuAtBlock(o.block.id);
880
881
  },
881
- ...w(e).slash_menu.ai,
882
- icon: /* @__PURE__ */ l(Ke.AI, {})
882
+ ...y(e).slash_menu.ai,
883
+ icon: /* @__PURE__ */ l(We.AI, {})
883
884
  }
884
885
  ] : [];
885
886
  }
886
887
  export {
887
888
  b as AIExtension,
888
- Ue as AIMenu,
889
- lt as AIMenuController,
890
- ct as AIToolbarButton,
891
- ft as ClientSideTransport,
892
- gt as PROVIDER_OVERRIDES,
893
- Re as PromptSuggestionMenu,
894
- pt as StreamToolExecutor,
895
- ht as _getApplySuggestionsTr,
896
- y as aiDocumentFormats,
897
- de as buildAIRequest,
898
- Ct as createStreamToolsArraySchema,
899
- bt as fetchViaProxy,
900
- w as getAIDictionary,
901
- ut as getAISlashMenuItems,
902
- Fe as getDefaultAIMenuItems,
903
- vt as getProviderOverrides,
904
- St as injectDocumentStateMessages,
905
- yt as makeDocumentStateBuilder,
906
- wt as objectAsToolCallInUIMessageStream,
907
- kt as objectStreamToOperationsResult,
908
- It as partialObjectStreamAsToolCallInUIMessageStream,
909
- _t as promptHelpers,
910
- fe as sendMessageWithAIRequest,
911
- xt as setupToolCallStreaming,
912
- Mt as streamToolsToToolSet,
913
- Lt as toolDefinitionsToToolSet,
914
- Tt as toolSetToToolDefinitions,
915
- ee as useAIDictionary
889
+ Ke as AIMenu,
890
+ ct as AIMenuController,
891
+ ut as AIToolbarButton,
892
+ gt as ClientSideTransport,
893
+ pt as PROVIDER_OVERRIDES,
894
+ qe as PromptSuggestionMenu,
895
+ ht as StreamToolExecutor,
896
+ Ct as _getApplySuggestionsTr,
897
+ S as aiDocumentFormats,
898
+ fe as buildAIRequest,
899
+ bt as createStreamToolsArraySchema,
900
+ vt as fetchViaProxy,
901
+ y as getAIDictionary,
902
+ mt as getAISlashMenuItems,
903
+ Ue as getDefaultAIMenuItems,
904
+ St as getProviderOverrides,
905
+ yt as injectDocumentStateMessages,
906
+ wt as makeDocumentStateBuilder,
907
+ kt as objectAsToolCallInUIMessageStream,
908
+ It as objectStreamToOperationsResult,
909
+ _t as partialObjectStreamAsToolCallInUIMessageStream,
910
+ xt as promptHelpers,
911
+ ge as sendMessageWithAIRequest,
912
+ Mt as setupToolCallStreaming,
913
+ Lt as streamToolsToToolSet,
914
+ Tt as toolDefinitionsToToolSet,
915
+ Pt as toolSetToToolDefinitions,
916
+ te as useAIDictionary
916
917
  };
917
918
  //# sourceMappingURL=blocknote-xl-ai.js.map