@blade-hq/agent-react 2612.0.0-beta.86 → 2612.0.0-beta.88

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 (55) hide show
  1. package/README.md +1 -1
  2. package/dist/SessionPluginConfigForm-Y657MKRX.js +9 -0
  3. package/dist/chat/AssistantTurnBlock.d.ts +2 -1
  4. package/dist/chat/ChatLoadingIndicator.d.ts +9 -1
  5. package/dist/chat/ChatPanel.d.ts +3 -1
  6. package/dist/chat/FileDeliveryCards.d.ts +12 -6
  7. package/dist/chat/ai-elements/shimmer.d.ts +4 -0
  8. package/dist/chat/chat-column-width.d.ts +21 -0
  9. package/dist/chat/index.d.ts +3 -1
  10. package/dist/chat/runtime/actions.d.ts +5 -1
  11. package/dist/chat/runtime/environment.d.ts +2 -0
  12. package/dist/chat/runtime/use-chat-actions.d.ts +1 -1
  13. package/dist/chat.css +18 -0
  14. package/dist/{chunk-SK43YNRX.js → chunk-5ESAKOUV.js} +2 -2
  15. package/dist/{chunk-6RQGCCG7.js → chunk-5UGLGKFI.js} +205 -7
  16. package/dist/chunk-5UGLGKFI.js.map +1 -0
  17. package/dist/{chunk-LYDXKR3Q.js → chunk-7LVZQ4LS.js} +95 -70
  18. package/dist/chunk-7LVZQ4LS.js.map +1 -0
  19. package/dist/{chunk-MWILWSPG.js → chunk-GXHHSZSS.js} +2 -2
  20. package/dist/{chunk-C3LBNHVM.js → chunk-LOXIHCL2.js} +13 -7
  21. package/dist/{chunk-C3LBNHVM.js.map → chunk-LOXIHCL2.js.map} +1 -1
  22. package/dist/{chunk-FDB3J5QF.js → chunk-NADWKQYZ.js} +76 -11
  23. package/dist/{chunk-FDB3J5QF.js.map → chunk-NADWKQYZ.js.map} +1 -1
  24. package/dist/{chunk-FH5HA3GW.js → chunk-PWUFWSMN.js} +6 -6
  25. package/dist/chunk-PWUFWSMN.js.map +1 -0
  26. package/dist/{chunk-RGL2XUQR.js → chunk-QKI7OC5D.js} +1803 -1183
  27. package/dist/chunk-QKI7OC5D.js.map +1 -0
  28. package/dist/{chunk-KHJEIHMJ.js → chunk-SEJUZPT5.js} +37 -60
  29. package/dist/chunk-SEJUZPT5.js.map +1 -0
  30. package/dist/{chunk-NRYLAO3X.js → chunk-VTEKA5HD.js} +281 -102
  31. package/dist/{chunk-NRYLAO3X.js.map → chunk-VTEKA5HD.js.map} +1 -1
  32. package/dist/connectors.js +3 -3
  33. package/dist/index.js +9 -9
  34. package/dist/internal.d.ts +2 -2
  35. package/dist/internal.js +620 -46
  36. package/dist/internal.js.map +1 -1
  37. package/dist/questions.js +4 -4
  38. package/dist/rich-input/ChatInput.d.ts +1 -1
  39. package/dist/rich-input/ModelSelector.d.ts +3 -1
  40. package/dist/rich-input/model/resolve-model.d.ts +1 -1
  41. package/dist/rich-input.js +1051 -1185
  42. package/dist/rich-input.js.map +1 -1
  43. package/dist/style.full.css +19 -1
  44. package/dist/tool-details.js +5 -5
  45. package/package.json +2 -2
  46. package/dist/SessionPluginConfigForm-7LJ5SUNY.js +0 -9
  47. package/dist/chat-IHPRU35X.css +0 -162
  48. package/dist/chunk-6RQGCCG7.js.map +0 -1
  49. package/dist/chunk-FH5HA3GW.js.map +0 -1
  50. package/dist/chunk-KHJEIHMJ.js.map +0 -1
  51. package/dist/chunk-LYDXKR3Q.js.map +0 -1
  52. package/dist/chunk-RGL2XUQR.js.map +0 -1
  53. /package/dist/{SessionPluginConfigForm-7LJ5SUNY.js.map → SessionPluginConfigForm-Y657MKRX.js.map} +0 -0
  54. /package/dist/{chunk-SK43YNRX.js.map → chunk-5ESAKOUV.js.map} +0 -0
  55. /package/dist/{chunk-MWILWSPG.js.map → chunk-GXHHSZSS.js.map} +0 -0
@@ -1,9 +1,15 @@
1
1
  import {
2
2
  ConnectorPanel,
3
3
  PluginTriggerStack,
4
+ backgroundTaskDismissals,
5
+ composerChannels,
4
6
  selectionFromItem,
5
- triggerSummary
6
- } from "./chunk-6RQGCCG7.js";
7
+ skillDisplayName,
8
+ triggerSummary,
9
+ useComposerChannels,
10
+ useDismissedBackgroundTasks,
11
+ visibleSkills
12
+ } from "./chunk-5UGLGKFI.js";
7
13
  import {
8
14
  MODEL_REASONING_LEVELS_KEY,
9
15
  PREFERRED_MODEL_KEY,
@@ -40,8 +46,8 @@ import {
40
46
  useSessionDataInvalidation,
41
47
  useSessionSkills,
42
48
  useSkillStats
43
- } from "./chunk-LYDXKR3Q.js";
44
- import "./chunk-FH5HA3GW.js";
49
+ } from "./chunk-7LVZQ4LS.js";
50
+ import "./chunk-PWUFWSMN.js";
45
51
  import {
46
52
  cn,
47
53
  notifyChat,
@@ -51,8 +57,9 @@ import {
51
57
  useChatSessionDetail,
52
58
  useCurrentChatSessionId,
53
59
  useSessionHandle,
54
- useSessionSource
55
- } from "./chunk-NRYLAO3X.js";
60
+ useSessionSource,
61
+ useSessionState
62
+ } from "./chunk-VTEKA5HD.js";
56
63
  import {
57
64
  Dialog,
58
65
  DialogClose,
@@ -61,28 +68,26 @@ import {
61
68
  cn as cn2,
62
69
  dist_exports4 as dist_exports,
63
70
  usePortalContainer
64
- } from "./chunk-MWILWSPG.js";
65
- import "./chunk-SK43YNRX.js";
71
+ } from "./chunk-GXHHSZSS.js";
72
+ import "./chunk-5ESAKOUV.js";
66
73
  import {
67
74
  Archive,
75
+ ArrowUp,
68
76
  BookOpen,
69
77
  Brain,
70
78
  Check,
71
79
  ChevronDown,
72
80
  ChevronRight,
73
- Download,
74
81
  EyeOff,
75
82
  File,
76
83
  FileCode2,
77
84
  FileText,
78
85
  Film,
79
- FlaskConical,
80
86
  Folder,
81
87
  FolderUp,
82
88
  Import,
83
89
  Lightbulb,
84
90
  ListPlus,
85
- ListTree,
86
91
  LoaderCircle,
87
92
  Mic,
88
93
  Music,
@@ -90,17 +95,14 @@ import {
90
95
  Play,
91
96
  Plug,
92
97
  Plus,
93
- Rocket,
94
- RotateCcw,
95
- Scissors,
98
+ RotateCw,
96
99
  Search,
97
- Send,
98
- Share2,
100
+ SlidersHorizontal,
99
101
  Sparkles,
100
102
  Square,
101
103
  Terminal,
102
104
  X
103
- } from "./chunk-KHJEIHMJ.js";
105
+ } from "./chunk-SEJUZPT5.js";
104
106
  import {
105
107
  __commonJS,
106
108
  __require,
@@ -138,7 +140,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
138
140
  },
139
141
  [subscribe, value, getSnapshot]
140
142
  );
141
- useEffect10(
143
+ useEffect11(
142
144
  function() {
143
145
  checkIfSnapshotChanged(inst) && forceUpdate({ inst });
144
146
  return subscribe(function() {
@@ -164,7 +166,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
164
166
  return getSnapshot();
165
167
  }
166
168
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
167
- var React2 = __require("react"), objectIs = "function" === typeof Object.is ? Object.is : is, useState13 = React2.useState, useEffect10 = React2.useEffect, useLayoutEffect3 = React2.useLayoutEffect, useDebugValue3 = React2.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
169
+ var React2 = __require("react"), objectIs = "function" === typeof Object.is ? Object.is : is, useState13 = React2.useState, useEffect11 = React2.useEffect, useLayoutEffect3 = React2.useLayoutEffect, useDebugValue3 = React2.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
168
170
  exports.useSyncExternalStore = void 0 !== React2.useSyncExternalStore ? React2.useSyncExternalStore : shim;
169
171
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
170
172
  })();
@@ -192,7 +194,7 @@ var require_with_selector_development = __commonJS({
192
194
  return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
193
195
  }
194
196
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
195
- var React2 = __require("react"), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore5 = shim.useSyncExternalStore, useRef8 = React2.useRef, useEffect10 = React2.useEffect, useMemo8 = React2.useMemo, useDebugValue3 = React2.useDebugValue;
197
+ var React2 = __require("react"), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore4 = shim.useSyncExternalStore, useRef8 = React2.useRef, useEffect11 = React2.useEffect, useMemo8 = React2.useMemo, useDebugValue3 = React2.useDebugValue;
196
198
  exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
197
199
  var instRef = useRef8(null);
198
200
  if (null === instRef.current) {
@@ -234,8 +236,8 @@ var require_with_selector_development = __commonJS({
234
236
  },
235
237
  [getSnapshot, getServerSnapshot, selector, isEqual]
236
238
  );
237
- var value = useSyncExternalStore5(subscribe, instRef[0], instRef[1]);
238
- useEffect10(
239
+ var value = useSyncExternalStore4(subscribe, instRef[0], instRef[1]);
240
+ useEffect11(
239
241
  function() {
240
242
  inst.hasValue = true;
241
243
  inst.value = value;
@@ -265,41 +267,6 @@ var require_with_selector = __commonJS({
265
267
  // src/rich-input/BackgroundTasksPill.tsx
266
268
  import { useMemo, useState } from "react";
267
269
 
268
- // src/chat/runtime/background-task-dismissals.ts
269
- import { useSyncExternalStore } from "react";
270
- var state = {};
271
- var listeners = /* @__PURE__ */ new Set();
272
- var NO_IDS = [];
273
- function emit() {
274
- for (const listener of [...listeners]) listener();
275
- }
276
- var backgroundTaskDismissals = {
277
- getState: () => state,
278
- subscribe(listener) {
279
- listeners.add(listener);
280
- return () => {
281
- listeners.delete(listener);
282
- };
283
- },
284
- dismiss(sessionId, taskId) {
285
- const existing = state[sessionId] ?? [];
286
- if (existing.includes(taskId)) return;
287
- state = { ...state, [sessionId]: [...existing, taskId] };
288
- emit();
289
- },
290
- reset() {
291
- state = {};
292
- emit();
293
- }
294
- };
295
- function useDismissedBackgroundTasks(sessionId) {
296
- return useSyncExternalStore(
297
- backgroundTaskDismissals.subscribe,
298
- () => state[sessionId] ?? NO_IDS,
299
- () => state[sessionId] ?? NO_IDS
300
- );
301
- }
302
-
303
270
  // src/rich-input/lib/background-tasks-view.ts
304
271
  var LIVE_STATUSES = /* @__PURE__ */ new Set(["starting", "running", "cancelling"]);
305
272
  var ATTENTION_STATUSES = /* @__PURE__ */ new Set(["failed", "lost"]);
@@ -2584,19 +2551,19 @@ function dfa(nfa2) {
2584
2551
  });
2585
2552
  });
2586
2553
  });
2587
- let state3 = labeled[states.join(",")] = new ContentMatch(states.indexOf(nfa2.length - 1) > -1);
2554
+ let state = labeled[states.join(",")] = new ContentMatch(states.indexOf(nfa2.length - 1) > -1);
2588
2555
  for (let i = 0; i < out.length; i++) {
2589
2556
  let states2 = out[i][1].sort(cmp);
2590
- state3.next.push({ type: out[i][0], next: labeled[states2.join(",")] || explore(states2) });
2557
+ state.next.push({ type: out[i][0], next: labeled[states2.join(",")] || explore(states2) });
2591
2558
  }
2592
- return state3;
2559
+ return state;
2593
2560
  }
2594
2561
  }
2595
2562
  function checkForDeadEnds(match, stream) {
2596
2563
  for (let i = 0, work = [match]; i < work.length; i++) {
2597
- let state3 = work[i], dead = !state3.validEnd, nodes = [];
2598
- for (let j = 0; j < state3.next.length; j++) {
2599
- let { type, next } = state3.next[j];
2564
+ let state = work[i], dead = !state.validEnd, nodes = [];
2565
+ for (let j = 0; j < state.next.length; j++) {
2566
+ let { type, next } = state.next[j];
2600
2567
  nodes.push(type.name);
2601
2568
  if (dead && !(type.isText || type.hasRequiredAttrs()))
2602
2569
  dead = false;
@@ -6204,14 +6171,14 @@ var Transaction = class extends Transform {
6204
6171
  /**
6205
6172
  @internal
6206
6173
  */
6207
- constructor(state3) {
6208
- super(state3.doc);
6174
+ constructor(state) {
6175
+ super(state.doc);
6209
6176
  this.curSelectionFor = 0;
6210
6177
  this.updated = 0;
6211
6178
  this.meta = /* @__PURE__ */ Object.create(null);
6212
6179
  this.time = Date.now();
6213
- this.curSelection = state3.selection;
6214
- this.storedMarks = state3.storedMarks;
6180
+ this.curSelection = state.selection;
6181
+ this.storedMarks = state.storedMarks;
6215
6182
  }
6216
6183
  /**
6217
6184
  The transaction's current selection. This defaults to the editor
@@ -6417,8 +6384,8 @@ var baseFields = [
6417
6384
  init(config) {
6418
6385
  return config.storedMarks || null;
6419
6386
  },
6420
- apply(tr2, _marks, _old, state3) {
6421
- return state3.selection.$cursor ? tr2.storedMarks : null;
6387
+ apply(tr2, _marks, _old, state) {
6388
+ return state.selection.$cursor ? tr2.storedMarks : null;
6422
6389
  }
6423
6390
  }),
6424
6391
  new FieldDesc("scrollToSelection", {
@@ -6582,9 +6549,9 @@ var EditorState = class _EditorState {
6582
6549
  for (let prop in pluginFields) {
6583
6550
  if (prop == "doc" || prop == "selection")
6584
6551
  throw new RangeError("The JSON fields `doc` and `selection` are reserved");
6585
- let plugin = pluginFields[prop], state3 = plugin.spec.state;
6586
- if (state3 && state3.toJSON)
6587
- result[prop] = state3.toJSON.call(plugin, this[plugin.key]);
6552
+ let plugin = pluginFields[prop], state = plugin.spec.state;
6553
+ if (state && state.toJSON)
6554
+ result[prop] = state.toJSON.call(plugin, this[plugin.key]);
6588
6555
  }
6589
6556
  return result;
6590
6557
  }
@@ -6613,9 +6580,9 @@ var EditorState = class _EditorState {
6613
6580
  } else {
6614
6581
  if (pluginFields)
6615
6582
  for (let prop in pluginFields) {
6616
- let plugin = pluginFields[prop], state3 = plugin.spec.state;
6617
- if (plugin.key == field.name && state3 && state3.fromJSON && Object.prototype.hasOwnProperty.call(json, prop)) {
6618
- instance[field.name] = state3.fromJSON.call(plugin, config, json[prop], instance);
6583
+ let plugin = pluginFields[prop], state = plugin.spec.state;
6584
+ if (plugin.key == field.name && state && state.fromJSON && Object.prototype.hasOwnProperty.call(json, prop)) {
6585
+ instance[field.name] = state.fromJSON.call(plugin, config, json[prop], instance);
6619
6586
  return;
6620
6587
  }
6621
6588
  }
@@ -6650,8 +6617,8 @@ var Plugin = class {
6650
6617
  /**
6651
6618
  Extract the plugin's state field from an editor state.
6652
6619
  */
6653
- getState(state3) {
6654
- return state3[this.key];
6620
+ getState(state) {
6621
+ return state[this.key];
6655
6622
  }
6656
6623
  };
6657
6624
  var keys = /* @__PURE__ */ Object.create(null);
@@ -6672,33 +6639,33 @@ var PluginKey = class {
6672
6639
  Get the active plugin with this key, if any, from an editor
6673
6640
  state.
6674
6641
  */
6675
- get(state3) {
6676
- return state3.config.pluginsByKey[this.key];
6642
+ get(state) {
6643
+ return state.config.pluginsByKey[this.key];
6677
6644
  }
6678
6645
  /**
6679
6646
  Get the plugin's state from an editor state.
6680
6647
  */
6681
- getState(state3) {
6682
- return state3[this.key];
6648
+ getState(state) {
6649
+ return state[this.key];
6683
6650
  }
6684
6651
  };
6685
6652
 
6686
6653
  // ../../node_modules/.pnpm/prosemirror-commands@1.7.1/node_modules/prosemirror-commands/dist/index.js
6687
- var deleteSelection = (state3, dispatch) => {
6688
- if (state3.selection.empty)
6654
+ var deleteSelection = (state, dispatch) => {
6655
+ if (state.selection.empty)
6689
6656
  return false;
6690
6657
  if (dispatch)
6691
- dispatch(state3.tr.deleteSelection().scrollIntoView());
6658
+ dispatch(state.tr.deleteSelection().scrollIntoView());
6692
6659
  return true;
6693
6660
  };
6694
- function atBlockStart(state3, view) {
6695
- let { $cursor } = state3.selection;
6696
- if (!$cursor || (view ? !view.endOfTextblock("backward", state3) : $cursor.parentOffset > 0))
6661
+ function atBlockStart(state, view) {
6662
+ let { $cursor } = state.selection;
6663
+ if (!$cursor || (view ? !view.endOfTextblock("backward", state) : $cursor.parentOffset > 0))
6697
6664
  return null;
6698
6665
  return $cursor;
6699
6666
  }
6700
- var joinBackward = (state3, dispatch, view) => {
6701
- let $cursor = atBlockStart(state3, view);
6667
+ var joinBackward = (state, dispatch, view) => {
6668
+ let $cursor = atBlockStart(state, view);
6702
6669
  if (!$cursor)
6703
6670
  return false;
6704
6671
  let $cut = findCutBefore($cursor);
@@ -6707,18 +6674,18 @@ var joinBackward = (state3, dispatch, view) => {
6707
6674
  if (target == null)
6708
6675
  return false;
6709
6676
  if (dispatch)
6710
- dispatch(state3.tr.lift(range, target).scrollIntoView());
6677
+ dispatch(state.tr.lift(range, target).scrollIntoView());
6711
6678
  return true;
6712
6679
  }
6713
6680
  let before = $cut.nodeBefore;
6714
- if (deleteBarrier(state3, $cut, dispatch, -1))
6681
+ if (deleteBarrier(state, $cut, dispatch, -1))
6715
6682
  return true;
6716
6683
  if ($cursor.parent.content.size == 0 && (textblockAt(before, "end") || NodeSelection.isSelectable(before))) {
6717
6684
  for (let depth = $cursor.depth; ; depth--) {
6718
- let delStep = replaceStep(state3.doc, $cursor.before(depth), $cursor.after(depth), Slice.empty);
6685
+ let delStep = replaceStep(state.doc, $cursor.before(depth), $cursor.after(depth), Slice.empty);
6719
6686
  if (delStep && delStep.slice.size < delStep.to - delStep.from) {
6720
6687
  if (dispatch) {
6721
- let tr2 = state3.tr.step(delStep);
6688
+ let tr2 = state.tr.step(delStep);
6722
6689
  tr2.setSelection(textblockAt(before, "end") ? Selection.findFrom(tr2.doc.resolve(tr2.mapping.map($cut.pos, -1)), -1) : NodeSelection.create(tr2.doc, $cut.pos - before.nodeSize));
6723
6690
  dispatch(tr2.scrollIntoView());
6724
6691
  }
@@ -6730,26 +6697,26 @@ var joinBackward = (state3, dispatch, view) => {
6730
6697
  }
6731
6698
  if (before.isAtom && $cut.depth == $cursor.depth - 1) {
6732
6699
  if (dispatch)
6733
- dispatch(state3.tr.delete($cut.pos - before.nodeSize, $cut.pos).scrollIntoView());
6700
+ dispatch(state.tr.delete($cut.pos - before.nodeSize, $cut.pos).scrollIntoView());
6734
6701
  return true;
6735
6702
  }
6736
6703
  return false;
6737
6704
  };
6738
- var joinTextblockBackward = (state3, dispatch, view) => {
6739
- let $cursor = atBlockStart(state3, view);
6705
+ var joinTextblockBackward = (state, dispatch, view) => {
6706
+ let $cursor = atBlockStart(state, view);
6740
6707
  if (!$cursor)
6741
6708
  return false;
6742
6709
  let $cut = findCutBefore($cursor);
6743
- return $cut ? joinTextblocksAround(state3, $cut, dispatch) : false;
6710
+ return $cut ? joinTextblocksAround(state, $cut, dispatch) : false;
6744
6711
  };
6745
- var joinTextblockForward = (state3, dispatch, view) => {
6746
- let $cursor = atBlockEnd(state3, view);
6712
+ var joinTextblockForward = (state, dispatch, view) => {
6713
+ let $cursor = atBlockEnd(state, view);
6747
6714
  if (!$cursor)
6748
6715
  return false;
6749
6716
  let $cut = findCutAfter($cursor);
6750
- return $cut ? joinTextblocksAround(state3, $cut, dispatch) : false;
6717
+ return $cut ? joinTextblocksAround(state, $cut, dispatch) : false;
6751
6718
  };
6752
- function joinTextblocksAround(state3, $cut, dispatch) {
6719
+ function joinTextblocksAround(state, $cut, dispatch) {
6753
6720
  let before = $cut.nodeBefore, beforeText = before, beforePos = $cut.pos - 1;
6754
6721
  for (; !beforeText.isTextblock; beforePos--) {
6755
6722
  if (beforeText.type.spec.isolating)
@@ -6768,11 +6735,11 @@ function joinTextblocksAround(state3, $cut, dispatch) {
6768
6735
  return false;
6769
6736
  afterText = child;
6770
6737
  }
6771
- let step = replaceStep(state3.doc, beforePos, afterPos, Slice.empty);
6738
+ let step = replaceStep(state.doc, beforePos, afterPos, Slice.empty);
6772
6739
  if (!step || step.from != beforePos || step instanceof ReplaceStep && step.slice.size >= afterPos - beforePos)
6773
6740
  return false;
6774
6741
  if (dispatch) {
6775
- let tr2 = state3.tr.step(step);
6742
+ let tr2 = state.tr.step(step);
6776
6743
  tr2.setSelection(TextSelection.create(tr2.doc, beforePos));
6777
6744
  dispatch(tr2.scrollIntoView());
6778
6745
  }
@@ -6787,12 +6754,12 @@ function textblockAt(node, side, only = false) {
6787
6754
  }
6788
6755
  return false;
6789
6756
  }
6790
- var selectNodeBackward = (state3, dispatch, view) => {
6791
- let { $head, empty: empty2 } = state3.selection, $cut = $head;
6757
+ var selectNodeBackward = (state, dispatch, view) => {
6758
+ let { $head, empty: empty2 } = state.selection, $cut = $head;
6792
6759
  if (!empty2)
6793
6760
  return false;
6794
6761
  if ($head.parent.isTextblock) {
6795
- if (view ? !view.endOfTextblock("backward", state3) : $head.parentOffset > 0)
6762
+ if (view ? !view.endOfTextblock("backward", state) : $head.parentOffset > 0)
6796
6763
  return false;
6797
6764
  $cut = findCutBefore($head);
6798
6765
  }
@@ -6800,7 +6767,7 @@ var selectNodeBackward = (state3, dispatch, view) => {
6800
6767
  if (!node || !NodeSelection.isSelectable(node))
6801
6768
  return false;
6802
6769
  if (dispatch)
6803
- dispatch(state3.tr.setSelection(NodeSelection.create(state3.doc, $cut.pos - node.nodeSize)).scrollIntoView());
6770
+ dispatch(state.tr.setSelection(NodeSelection.create(state.doc, $cut.pos - node.nodeSize)).scrollIntoView());
6804
6771
  return true;
6805
6772
  };
6806
6773
  function findCutBefore($pos) {
@@ -6813,27 +6780,27 @@ function findCutBefore($pos) {
6813
6780
  }
6814
6781
  return null;
6815
6782
  }
6816
- function atBlockEnd(state3, view) {
6817
- let { $cursor } = state3.selection;
6818
- if (!$cursor || (view ? !view.endOfTextblock("forward", state3) : $cursor.parentOffset < $cursor.parent.content.size))
6783
+ function atBlockEnd(state, view) {
6784
+ let { $cursor } = state.selection;
6785
+ if (!$cursor || (view ? !view.endOfTextblock("forward", state) : $cursor.parentOffset < $cursor.parent.content.size))
6819
6786
  return null;
6820
6787
  return $cursor;
6821
6788
  }
6822
- var joinForward = (state3, dispatch, view) => {
6823
- let $cursor = atBlockEnd(state3, view);
6789
+ var joinForward = (state, dispatch, view) => {
6790
+ let $cursor = atBlockEnd(state, view);
6824
6791
  if (!$cursor)
6825
6792
  return false;
6826
6793
  let $cut = findCutAfter($cursor);
6827
6794
  if (!$cut)
6828
6795
  return false;
6829
6796
  let after = $cut.nodeAfter;
6830
- if (deleteBarrier(state3, $cut, dispatch, 1))
6797
+ if (deleteBarrier(state, $cut, dispatch, 1))
6831
6798
  return true;
6832
6799
  if ($cursor.parent.content.size == 0 && (textblockAt(after, "start") || NodeSelection.isSelectable(after))) {
6833
- let delStep = replaceStep(state3.doc, $cursor.before(), $cursor.after(), Slice.empty);
6800
+ let delStep = replaceStep(state.doc, $cursor.before(), $cursor.after(), Slice.empty);
6834
6801
  if (delStep && delStep.slice.size < delStep.to - delStep.from) {
6835
6802
  if (dispatch) {
6836
- let tr2 = state3.tr.step(delStep);
6803
+ let tr2 = state.tr.step(delStep);
6837
6804
  tr2.setSelection(textblockAt(after, "start") ? Selection.findFrom(tr2.doc.resolve(tr2.mapping.map($cut.pos)), 1) : NodeSelection.create(tr2.doc, tr2.mapping.map($cut.pos)));
6838
6805
  dispatch(tr2.scrollIntoView());
6839
6806
  }
@@ -6842,17 +6809,17 @@ var joinForward = (state3, dispatch, view) => {
6842
6809
  }
6843
6810
  if (after.isAtom && $cut.depth == $cursor.depth - 1) {
6844
6811
  if (dispatch)
6845
- dispatch(state3.tr.delete($cut.pos, $cut.pos + after.nodeSize).scrollIntoView());
6812
+ dispatch(state.tr.delete($cut.pos, $cut.pos + after.nodeSize).scrollIntoView());
6846
6813
  return true;
6847
6814
  }
6848
6815
  return false;
6849
6816
  };
6850
- var selectNodeForward = (state3, dispatch, view) => {
6851
- let { $head, empty: empty2 } = state3.selection, $cut = $head;
6817
+ var selectNodeForward = (state, dispatch, view) => {
6818
+ let { $head, empty: empty2 } = state.selection, $cut = $head;
6852
6819
  if (!empty2)
6853
6820
  return false;
6854
6821
  if ($head.parent.isTextblock) {
6855
- if (view ? !view.endOfTextblock("forward", state3) : $head.parentOffset < $head.parent.content.size)
6822
+ if (view ? !view.endOfTextblock("forward", state) : $head.parentOffset < $head.parent.content.size)
6856
6823
  return false;
6857
6824
  $cut = findCutAfter($head);
6858
6825
  }
@@ -6860,7 +6827,7 @@ var selectNodeForward = (state3, dispatch, view) => {
6860
6827
  if (!node || !NodeSelection.isSelectable(node))
6861
6828
  return false;
6862
6829
  if (dispatch)
6863
- dispatch(state3.tr.setSelection(NodeSelection.create(state3.doc, $cut.pos)).scrollIntoView());
6830
+ dispatch(state.tr.setSelection(NodeSelection.create(state.doc, $cut.pos)).scrollIntoView());
6864
6831
  return true;
6865
6832
  };
6866
6833
  function findCutAfter($pos) {
@@ -6874,55 +6841,55 @@ function findCutAfter($pos) {
6874
6841
  }
6875
6842
  return null;
6876
6843
  }
6877
- var joinUp = (state3, dispatch) => {
6878
- let sel = state3.selection, nodeSel = sel instanceof NodeSelection, point;
6844
+ var joinUp = (state, dispatch) => {
6845
+ let sel = state.selection, nodeSel = sel instanceof NodeSelection, point;
6879
6846
  if (nodeSel) {
6880
- if (sel.node.isTextblock || !canJoin(state3.doc, sel.from))
6847
+ if (sel.node.isTextblock || !canJoin(state.doc, sel.from))
6881
6848
  return false;
6882
6849
  point = sel.from;
6883
6850
  } else {
6884
- point = joinPoint(state3.doc, sel.from, -1);
6851
+ point = joinPoint(state.doc, sel.from, -1);
6885
6852
  if (point == null)
6886
6853
  return false;
6887
6854
  }
6888
6855
  if (dispatch) {
6889
- let tr2 = state3.tr.join(point);
6856
+ let tr2 = state.tr.join(point);
6890
6857
  if (nodeSel)
6891
- tr2.setSelection(NodeSelection.create(tr2.doc, point - state3.doc.resolve(point).nodeBefore.nodeSize));
6858
+ tr2.setSelection(NodeSelection.create(tr2.doc, point - state.doc.resolve(point).nodeBefore.nodeSize));
6892
6859
  dispatch(tr2.scrollIntoView());
6893
6860
  }
6894
6861
  return true;
6895
6862
  };
6896
- var joinDown = (state3, dispatch) => {
6897
- let sel = state3.selection, point;
6863
+ var joinDown = (state, dispatch) => {
6864
+ let sel = state.selection, point;
6898
6865
  if (sel instanceof NodeSelection) {
6899
- if (sel.node.isTextblock || !canJoin(state3.doc, sel.to))
6866
+ if (sel.node.isTextblock || !canJoin(state.doc, sel.to))
6900
6867
  return false;
6901
6868
  point = sel.to;
6902
6869
  } else {
6903
- point = joinPoint(state3.doc, sel.to, 1);
6870
+ point = joinPoint(state.doc, sel.to, 1);
6904
6871
  if (point == null)
6905
6872
  return false;
6906
6873
  }
6907
6874
  if (dispatch)
6908
- dispatch(state3.tr.join(point).scrollIntoView());
6875
+ dispatch(state.tr.join(point).scrollIntoView());
6909
6876
  return true;
6910
6877
  };
6911
- var lift2 = (state3, dispatch) => {
6912
- let { $from, $to } = state3.selection;
6878
+ var lift2 = (state, dispatch) => {
6879
+ let { $from, $to } = state.selection;
6913
6880
  let range = $from.blockRange($to), target = range && liftTarget(range);
6914
6881
  if (target == null)
6915
6882
  return false;
6916
6883
  if (dispatch)
6917
- dispatch(state3.tr.lift(range, target).scrollIntoView());
6884
+ dispatch(state.tr.lift(range, target).scrollIntoView());
6918
6885
  return true;
6919
6886
  };
6920
- var newlineInCode = (state3, dispatch) => {
6921
- let { $head, $anchor } = state3.selection;
6887
+ var newlineInCode = (state, dispatch) => {
6888
+ let { $head, $anchor } = state.selection;
6922
6889
  if (!$head.parent.type.spec.code || !$head.sameParent($anchor))
6923
6890
  return false;
6924
6891
  if (dispatch)
6925
- dispatch(state3.tr.insertText("\n").scrollIntoView());
6892
+ dispatch(state.tr.insertText("\n").scrollIntoView());
6926
6893
  return true;
6927
6894
  };
6928
6895
  function defaultBlockAt(match) {
@@ -6933,22 +6900,22 @@ function defaultBlockAt(match) {
6933
6900
  }
6934
6901
  return null;
6935
6902
  }
6936
- var exitCode = (state3, dispatch) => {
6937
- let { $head, $anchor } = state3.selection;
6903
+ var exitCode = (state, dispatch) => {
6904
+ let { $head, $anchor } = state.selection;
6938
6905
  if (!$head.parent.type.spec.code || !$head.sameParent($anchor))
6939
6906
  return false;
6940
6907
  let above = $head.node(-1), after = $head.indexAfter(-1), type = defaultBlockAt(above.contentMatchAt(after));
6941
6908
  if (!type || !above.canReplaceWith(after, after, type))
6942
6909
  return false;
6943
6910
  if (dispatch) {
6944
- let pos = $head.after(), tr2 = state3.tr.replaceWith(pos, pos, type.createAndFill());
6911
+ let pos = $head.after(), tr2 = state.tr.replaceWith(pos, pos, type.createAndFill());
6945
6912
  tr2.setSelection(Selection.near(tr2.doc.resolve(pos), 1));
6946
6913
  dispatch(tr2.scrollIntoView());
6947
6914
  }
6948
6915
  return true;
6949
6916
  };
6950
- var createParagraphNear = (state3, dispatch) => {
6951
- let sel = state3.selection, { $from, $to } = sel;
6917
+ var createParagraphNear = (state, dispatch) => {
6918
+ let sel = state.selection, { $from, $to } = sel;
6952
6919
  if (sel instanceof AllSelection || $from.parent.inlineContent || $to.parent.inlineContent)
6953
6920
  return false;
6954
6921
  let type = defaultBlockAt($to.parent.contentMatchAt($to.indexAfter()));
@@ -6956,21 +6923,21 @@ var createParagraphNear = (state3, dispatch) => {
6956
6923
  return false;
6957
6924
  if (dispatch) {
6958
6925
  let side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to).pos;
6959
- let tr2 = state3.tr.insert(side, type.createAndFill());
6926
+ let tr2 = state.tr.insert(side, type.createAndFill());
6960
6927
  tr2.setSelection(TextSelection.create(tr2.doc, side + 1));
6961
6928
  dispatch(tr2.scrollIntoView());
6962
6929
  }
6963
6930
  return true;
6964
6931
  };
6965
- var liftEmptyBlock = (state3, dispatch) => {
6966
- let { $cursor } = state3.selection;
6932
+ var liftEmptyBlock = (state, dispatch) => {
6933
+ let { $cursor } = state.selection;
6967
6934
  if (!$cursor || $cursor.parent.content.size)
6968
6935
  return false;
6969
6936
  if ($cursor.depth > 1 && $cursor.after() != $cursor.end(-1)) {
6970
6937
  let before = $cursor.before();
6971
- if (canSplit(state3.doc, before)) {
6938
+ if (canSplit(state.doc, before)) {
6972
6939
  if (dispatch)
6973
- dispatch(state3.tr.split(before).scrollIntoView());
6940
+ dispatch(state.tr.split(before).scrollIntoView());
6974
6941
  return true;
6975
6942
  }
6976
6943
  }
@@ -6978,17 +6945,17 @@ var liftEmptyBlock = (state3, dispatch) => {
6978
6945
  if (target == null)
6979
6946
  return false;
6980
6947
  if (dispatch)
6981
- dispatch(state3.tr.lift(range, target).scrollIntoView());
6948
+ dispatch(state.tr.lift(range, target).scrollIntoView());
6982
6949
  return true;
6983
6950
  };
6984
6951
  function splitBlockAs(splitNode) {
6985
- return (state3, dispatch) => {
6986
- let { $from, $to } = state3.selection;
6987
- if (state3.selection instanceof NodeSelection && state3.selection.node.isBlock) {
6988
- if (!$from.parentOffset || !canSplit(state3.doc, $from.pos))
6952
+ return (state, dispatch) => {
6953
+ let { $from, $to } = state.selection;
6954
+ if (state.selection instanceof NodeSelection && state.selection.node.isBlock) {
6955
+ if (!$from.parentOffset || !canSplit(state.doc, $from.pos))
6989
6956
  return false;
6990
6957
  if (dispatch)
6991
- dispatch(state3.tr.split($from.pos).scrollIntoView());
6958
+ dispatch(state.tr.split($from.pos).scrollIntoView());
6992
6959
  return true;
6993
6960
  }
6994
6961
  if (!$from.depth)
@@ -7011,8 +6978,8 @@ function splitBlockAs(splitNode) {
7011
6978
  types.unshift(null);
7012
6979
  }
7013
6980
  }
7014
- let tr2 = state3.tr;
7015
- if (state3.selection instanceof TextSelection || state3.selection instanceof AllSelection)
6981
+ let tr2 = state.tr;
6982
+ if (state.selection instanceof TextSelection || state.selection instanceof AllSelection)
7016
6983
  tr2.deleteSelection();
7017
6984
  let splitPos = tr2.mapping.map($from.pos);
7018
6985
  let can = canSplit(tr2.doc, splitPos, types.length, types);
@@ -7034,40 +7001,40 @@ function splitBlockAs(splitNode) {
7034
7001
  };
7035
7002
  }
7036
7003
  var splitBlock = splitBlockAs();
7037
- var selectParentNode = (state3, dispatch) => {
7038
- let { $from, to } = state3.selection, pos;
7004
+ var selectParentNode = (state, dispatch) => {
7005
+ let { $from, to } = state.selection, pos;
7039
7006
  let same = $from.sharedDepth(to);
7040
7007
  if (same == 0)
7041
7008
  return false;
7042
7009
  pos = $from.before(same);
7043
7010
  if (dispatch)
7044
- dispatch(state3.tr.setSelection(NodeSelection.create(state3.doc, pos)));
7011
+ dispatch(state.tr.setSelection(NodeSelection.create(state.doc, pos)));
7045
7012
  return true;
7046
7013
  };
7047
- var selectAll = (state3, dispatch) => {
7014
+ var selectAll = (state, dispatch) => {
7048
7015
  if (dispatch)
7049
- dispatch(state3.tr.setSelection(new AllSelection(state3.doc)));
7016
+ dispatch(state.tr.setSelection(new AllSelection(state.doc)));
7050
7017
  return true;
7051
7018
  };
7052
- function joinMaybeClear(state3, $pos, dispatch) {
7019
+ function joinMaybeClear(state, $pos, dispatch) {
7053
7020
  let before = $pos.nodeBefore, after = $pos.nodeAfter, index = $pos.index();
7054
7021
  if (!before || !after || !before.type.compatibleContent(after.type))
7055
7022
  return false;
7056
7023
  if (!before.content.size && $pos.parent.canReplace(index - 1, index)) {
7057
7024
  if (dispatch)
7058
- dispatch(state3.tr.delete($pos.pos - before.nodeSize, $pos.pos).scrollIntoView());
7025
+ dispatch(state.tr.delete($pos.pos - before.nodeSize, $pos.pos).scrollIntoView());
7059
7026
  return true;
7060
7027
  }
7061
- if (!$pos.parent.canReplace(index, index + 1) || !(after.isTextblock || canJoin(state3.doc, $pos.pos)))
7028
+ if (!$pos.parent.canReplace(index, index + 1) || !(after.isTextblock || canJoin(state.doc, $pos.pos)))
7062
7029
  return false;
7063
7030
  if (dispatch)
7064
- dispatch(state3.tr.join($pos.pos).scrollIntoView());
7031
+ dispatch(state.tr.join($pos.pos).scrollIntoView());
7065
7032
  return true;
7066
7033
  }
7067
- function deleteBarrier(state3, $cut, dispatch, dir) {
7034
+ function deleteBarrier(state, $cut, dispatch, dir) {
7068
7035
  let before = $cut.nodeBefore, after = $cut.nodeAfter, conn, match;
7069
7036
  let isolated = before.type.spec.isolating || after.type.spec.isolating;
7070
- if (!isolated && joinMaybeClear(state3, $cut, dispatch))
7037
+ if (!isolated && joinMaybeClear(state, $cut, dispatch))
7071
7038
  return true;
7072
7039
  let canDelAfter = !isolated && $cut.parent.canReplace($cut.index(), $cut.index() + 1);
7073
7040
  if (canDelAfter && (conn = (match = before.contentMatchAt(before.childCount)).findWrapping(after.type)) && match.matchType(conn[0] || after.type).validEnd) {
@@ -7076,7 +7043,7 @@ function deleteBarrier(state3, $cut, dispatch, dir) {
7076
7043
  for (let i = conn.length - 1; i >= 0; i--)
7077
7044
  wrap2 = Fragment2.from(conn[i].create(null, wrap2));
7078
7045
  wrap2 = Fragment2.from(before.copy(wrap2));
7079
- let tr2 = state3.tr.step(new ReplaceAroundStep($cut.pos - 1, end, $cut.pos, end, new Slice(wrap2, 1, 0), conn.length, true));
7046
+ let tr2 = state.tr.step(new ReplaceAroundStep($cut.pos - 1, end, $cut.pos, end, new Slice(wrap2, 1, 0), conn.length, true));
7080
7047
  let $joinAt = tr2.doc.resolve(end + 2 * conn.length);
7081
7048
  if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type && canJoin(tr2.doc, $joinAt.pos))
7082
7049
  tr2.join($joinAt.pos);
@@ -7088,7 +7055,7 @@ function deleteBarrier(state3, $cut, dispatch, dir) {
7088
7055
  let range = selAfter && selAfter.$from.blockRange(selAfter.$to), target = range && liftTarget(range);
7089
7056
  if (target != null && target >= $cut.depth) {
7090
7057
  if (dispatch)
7091
- dispatch(state3.tr.lift(range, target).scrollIntoView());
7058
+ dispatch(state.tr.lift(range, target).scrollIntoView());
7092
7059
  return true;
7093
7060
  }
7094
7061
  if (canDelAfter && textblockAt(after, "start", true) && textblockAt(before, "end")) {
@@ -7107,7 +7074,7 @@ function deleteBarrier(state3, $cut, dispatch, dir) {
7107
7074
  let end = Fragment2.empty;
7108
7075
  for (let i = wrap2.length - 1; i >= 0; i--)
7109
7076
  end = Fragment2.from(wrap2[i].copy(end));
7110
- let tr2 = state3.tr.step(new ReplaceAroundStep($cut.pos - wrap2.length, $cut.pos + after.nodeSize, $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth, new Slice(end, wrap2.length, 0), 0, true));
7077
+ let tr2 = state.tr.step(new ReplaceAroundStep($cut.pos - wrap2.length, $cut.pos + after.nodeSize, $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth, new Slice(end, wrap2.length, 0), 0, true));
7111
7078
  dispatch(tr2.scrollIntoView());
7112
7079
  }
7113
7080
  return true;
@@ -7116,8 +7083,8 @@ function deleteBarrier(state3, $cut, dispatch, dir) {
7116
7083
  return false;
7117
7084
  }
7118
7085
  function selectTextblockSide(side) {
7119
- return function(state3, dispatch) {
7120
- let sel = state3.selection, $pos = side < 0 ? sel.$from : sel.$to;
7086
+ return function(state, dispatch) {
7087
+ let sel = state.selection, $pos = side < 0 ? sel.$from : sel.$to;
7121
7088
  let depth = $pos.depth;
7122
7089
  while ($pos.node(depth).isInline) {
7123
7090
  if (!depth)
@@ -7127,29 +7094,29 @@ function selectTextblockSide(side) {
7127
7094
  if (!$pos.node(depth).isTextblock)
7128
7095
  return false;
7129
7096
  if (dispatch)
7130
- dispatch(state3.tr.setSelection(TextSelection.create(state3.doc, side < 0 ? $pos.start(depth) : $pos.end(depth))));
7097
+ dispatch(state.tr.setSelection(TextSelection.create(state.doc, side < 0 ? $pos.start(depth) : $pos.end(depth))));
7131
7098
  return true;
7132
7099
  };
7133
7100
  }
7134
7101
  var selectTextblockStart = selectTextblockSide(-1);
7135
7102
  var selectTextblockEnd = selectTextblockSide(1);
7136
7103
  function wrapIn(nodeType, attrs = null) {
7137
- return function(state3, dispatch) {
7138
- let { $from, $to } = state3.selection;
7104
+ return function(state, dispatch) {
7105
+ let { $from, $to } = state.selection;
7139
7106
  let range = $from.blockRange($to), wrapping = range && findWrapping(range, nodeType, attrs);
7140
7107
  if (!wrapping)
7141
7108
  return false;
7142
7109
  if (dispatch)
7143
- dispatch(state3.tr.wrap(range, wrapping).scrollIntoView());
7110
+ dispatch(state.tr.wrap(range, wrapping).scrollIntoView());
7144
7111
  return true;
7145
7112
  };
7146
7113
  }
7147
7114
  function setBlockType2(nodeType, attrs = null) {
7148
- return function(state3, dispatch) {
7115
+ return function(state, dispatch) {
7149
7116
  let applicable = false;
7150
- for (let i = 0; i < state3.selection.ranges.length && !applicable; i++) {
7151
- let { $from: { pos: from2 }, $to: { pos: to } } = state3.selection.ranges[i];
7152
- state3.doc.nodesBetween(from2, to, (node, pos) => {
7117
+ for (let i = 0; i < state.selection.ranges.length && !applicable; i++) {
7118
+ let { $from: { pos: from2 }, $to: { pos: to } } = state.selection.ranges[i];
7119
+ state.doc.nodesBetween(from2, to, (node, pos) => {
7153
7120
  if (applicable)
7154
7121
  return false;
7155
7122
  if (!node.isTextblock || node.hasMarkup(nodeType, attrs))
@@ -7157,7 +7124,7 @@ function setBlockType2(nodeType, attrs = null) {
7157
7124
  if (node.type == nodeType) {
7158
7125
  applicable = true;
7159
7126
  } else {
7160
- let $pos = state3.doc.resolve(pos), index = $pos.index();
7127
+ let $pos = state.doc.resolve(pos), index = $pos.index();
7161
7128
  applicable = $pos.parent.canReplaceWith(index, index + 1, nodeType);
7162
7129
  }
7163
7130
  });
@@ -7165,9 +7132,9 @@ function setBlockType2(nodeType, attrs = null) {
7165
7132
  if (!applicable)
7166
7133
  return false;
7167
7134
  if (dispatch) {
7168
- let tr2 = state3.tr;
7169
- for (let i = 0; i < state3.selection.ranges.length; i++) {
7170
- let { $from: { pos: from2 }, $to: { pos: to } } = state3.selection.ranges[i];
7135
+ let tr2 = state.tr;
7136
+ for (let i = 0; i < state.selection.ranges.length; i++) {
7137
+ let { $from: { pos: from2 }, $to: { pos: to } } = state.selection.ranges[i];
7171
7138
  tr2.setBlockType(from2, to, nodeType, attrs);
7172
7139
  }
7173
7140
  dispatch(tr2.scrollIntoView());
@@ -7176,9 +7143,9 @@ function setBlockType2(nodeType, attrs = null) {
7176
7143
  };
7177
7144
  }
7178
7145
  function chainCommands(...commands) {
7179
- return function(state3, dispatch, view) {
7146
+ return function(state, dispatch, view) {
7180
7147
  for (let i = 0; i < commands.length; i++)
7181
- if (commands[i](state3, dispatch, view))
7148
+ if (commands[i](state, dispatch, view))
7182
7149
  return true;
7183
7150
  return false;
7184
7151
  };
@@ -7211,12 +7178,12 @@ var mac = typeof navigator != "undefined" ? /Mac|iP(hone|[oa]d)/.test(navigator.
7211
7178
 
7212
7179
  // ../../node_modules/.pnpm/prosemirror-schema-list@1.5.1/node_modules/prosemirror-schema-list/dist/index.js
7213
7180
  function wrapInList(listType, attrs = null) {
7214
- return function(state3, dispatch) {
7215
- let { $from, $to } = state3.selection;
7181
+ return function(state, dispatch) {
7182
+ let { $from, $to } = state.selection;
7216
7183
  let range = $from.blockRange($to);
7217
7184
  if (!range)
7218
7185
  return false;
7219
- let tr2 = dispatch ? state3.tr : null;
7186
+ let tr2 = dispatch ? state.tr : null;
7220
7187
  if (!wrapRangeInList(tr2, range, listType, attrs))
7221
7188
  return false;
7222
7189
  if (dispatch)
@@ -7263,21 +7230,21 @@ function doWrapInList(tr2, range, wrappers, joinBefore, listType) {
7263
7230
  return tr2;
7264
7231
  }
7265
7232
  function liftListItem(itemType) {
7266
- return function(state3, dispatch) {
7267
- let { $from, $to } = state3.selection;
7233
+ return function(state, dispatch) {
7234
+ let { $from, $to } = state.selection;
7268
7235
  let range = $from.blockRange($to, (node) => node.childCount > 0 && node.firstChild.type == itemType);
7269
7236
  if (!range)
7270
7237
  return false;
7271
7238
  if (!dispatch)
7272
7239
  return true;
7273
7240
  if ($from.node(range.depth - 1).type == itemType)
7274
- return liftToOuterList(state3, dispatch, itemType, range);
7241
+ return liftToOuterList(state, dispatch, itemType, range);
7275
7242
  else
7276
- return liftOutOfList(state3, dispatch, range);
7243
+ return liftOutOfList(state, dispatch, range);
7277
7244
  };
7278
7245
  }
7279
- function liftToOuterList(state3, dispatch, itemType, range) {
7280
- let tr2 = state3.tr, end = range.end, endOfList = range.$to.end(range.depth);
7246
+ function liftToOuterList(state, dispatch, itemType, range) {
7247
+ let tr2 = state.tr, end = range.end, endOfList = range.$to.end(range.depth);
7281
7248
  if (end < endOfList) {
7282
7249
  tr2.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment2.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));
7283
7250
  range = new NodeRange(tr2.doc.resolve(range.$from.pos), tr2.doc.resolve(endOfList), range.depth);
@@ -7292,8 +7259,8 @@ function liftToOuterList(state3, dispatch, itemType, range) {
7292
7259
  dispatch(tr2.scrollIntoView());
7293
7260
  return true;
7294
7261
  }
7295
- function liftOutOfList(state3, dispatch, range) {
7296
- let tr2 = state3.tr, list = range.parent;
7262
+ function liftOutOfList(state, dispatch, range) {
7263
+ let tr2 = state.tr, list = range.parent;
7297
7264
  for (let pos = range.end, i = range.endIndex - 1, e = range.startIndex; i > e; i--) {
7298
7265
  pos -= list.child(i).nodeSize;
7299
7266
  tr2.delete(pos - 1, pos + 1);
@@ -7311,8 +7278,8 @@ function liftOutOfList(state3, dispatch, range) {
7311
7278
  return true;
7312
7279
  }
7313
7280
  function sinkListItem(itemType) {
7314
- return function(state3, dispatch) {
7315
- let { $from, $to } = state3.selection;
7281
+ return function(state, dispatch) {
7282
+ let { $from, $to } = state.selection;
7316
7283
  let range = $from.blockRange($to, (node) => node.childCount > 0 && node.firstChild.type == itemType);
7317
7284
  if (!range)
7318
7285
  return false;
@@ -7327,7 +7294,7 @@ function sinkListItem(itemType) {
7327
7294
  let inner = Fragment2.from(nestedBefore ? itemType.create() : null);
7328
7295
  let slice2 = new Slice(Fragment2.from(itemType.create(null, Fragment2.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
7329
7296
  let before = range.start, after = range.end;
7330
- dispatch(state3.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
7297
+ dispatch(state.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
7331
7298
  }
7332
7299
  return true;
7333
7300
  };
@@ -7876,25 +7843,25 @@ function flattenH(rect, top) {
7876
7843
  let y = top ? rect.top : rect.bottom;
7877
7844
  return { top: y, bottom: y, left: rect.left, right: rect.right };
7878
7845
  }
7879
- function withFlushedState(view, state3, f) {
7846
+ function withFlushedState(view, state, f) {
7880
7847
  let viewState = view.state, active = view.root.activeElement;
7881
- if (viewState != state3)
7882
- view.updateState(state3);
7848
+ if (viewState != state)
7849
+ view.updateState(state);
7883
7850
  if (active != view.dom)
7884
7851
  view.focus();
7885
7852
  try {
7886
7853
  return f();
7887
7854
  } finally {
7888
- if (viewState != state3)
7855
+ if (viewState != state)
7889
7856
  view.updateState(viewState);
7890
7857
  if (active != view.dom && active)
7891
7858
  active.focus();
7892
7859
  }
7893
7860
  }
7894
- function endOfTextblockVertical(view, state3, dir) {
7895
- let sel = state3.selection;
7861
+ function endOfTextblockVertical(view, state, dir) {
7862
+ let sel = state.selection;
7896
7863
  let $pos = dir == "up" ? sel.$from : sel.$to;
7897
- return withFlushedState(view, state3, () => {
7864
+ return withFlushedState(view, state, () => {
7898
7865
  let { node: dom } = view.docView.domFromPos($pos.pos, dir == "up" ? -1 : 1);
7899
7866
  for (; ; ) {
7900
7867
  let nearest = view.docView.nearestDesc(dom, true);
@@ -7925,8 +7892,8 @@ function endOfTextblockVertical(view, state3, dir) {
7925
7892
  });
7926
7893
  }
7927
7894
  var maybeRTL = /[\u0590-\u08ac]/;
7928
- function endOfTextblockHorizontal(view, state3, dir) {
7929
- let { $head } = state3.selection;
7895
+ function endOfTextblockHorizontal(view, state, dir) {
7896
+ let { $head } = state.selection;
7930
7897
  if (!$head.parent.isTextblock)
7931
7898
  return false;
7932
7899
  let offset = $head.parentOffset, atStart = !offset, atEnd = offset == $head.parent.content.size;
@@ -7935,7 +7902,7 @@ function endOfTextblockHorizontal(view, state3, dir) {
7935
7902
  return $head.pos == $head.start() || $head.pos == $head.end();
7936
7903
  if (!maybeRTL.test($head.parent.textContent) || !sel.modify)
7937
7904
  return dir == "left" || dir == "backward" ? atStart : atEnd;
7938
- return withFlushedState(view, state3, () => {
7905
+ return withFlushedState(view, state, () => {
7939
7906
  let { focusNode: oldNode, focusOffset: oldOff, anchorNode, anchorOffset } = view.domSelectionRange();
7940
7907
  let oldBidiLevel = sel.caretBidiLevel;
7941
7908
  sel.modify("move", dir, "character");
@@ -7956,12 +7923,12 @@ function endOfTextblockHorizontal(view, state3, dir) {
7956
7923
  var cachedState = null;
7957
7924
  var cachedDir = null;
7958
7925
  var cachedResult = false;
7959
- function endOfTextblock(view, state3, dir) {
7960
- if (cachedState == state3 && cachedDir == dir)
7926
+ function endOfTextblock(view, state, dir) {
7927
+ if (cachedState == state && cachedDir == dir)
7961
7928
  return cachedResult;
7962
- cachedState = state3;
7929
+ cachedState = state;
7963
7930
  cachedDir = dir;
7964
- return cachedResult = dir == "up" || dir == "down" ? endOfTextblockVertical(view, state3, dir) : endOfTextblockHorizontal(view, state3, dir);
7931
+ return cachedResult = dir == "up" || dir == "down" ? endOfTextblockVertical(view, state, dir) : endOfTextblockHorizontal(view, state, dir);
7965
7932
  }
7966
7933
  var NOT_DIRTY = 0;
7967
7934
  var CHILD_DIRTY = 1;
@@ -9494,10 +9461,10 @@ function anchorInRightPlace(view) {
9494
9461
  let domSel = view.domSelectionRange();
9495
9462
  return isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset);
9496
9463
  }
9497
- function moveSelectionBlock(state3, dir) {
9498
- let { $anchor, $head } = state3.selection;
9464
+ function moveSelectionBlock(state, dir) {
9465
+ let { $anchor, $head } = state.selection;
9499
9466
  let $side = dir > 0 ? $anchor.max($head) : $anchor.min($head);
9500
- let $start = !$side.parent.inlineContent ? $side : $side.depth ? state3.doc.resolve(dir > 0 ? $side.after() : $side.before()) : null;
9467
+ let $start = !$side.parent.inlineContent ? $side : $side.depth ? state.doc.resolve(dir > 0 ? $side.after() : $side.before()) : null;
9501
9468
  return $start && Selection.findFrom($start, dir);
9502
9469
  }
9503
9470
  function apply(view, sel) {
@@ -9701,9 +9668,9 @@ function setSelFocus(view, node, offset) {
9701
9668
  sel.extend(node, offset);
9702
9669
  }
9703
9670
  view.domObserver.setCurSelection();
9704
- let { state: state3 } = view;
9671
+ let { state } = view;
9705
9672
  setTimeout(() => {
9706
- if (view.state == state3)
9673
+ if (view.state == state)
9707
9674
  selectionToDOM(view);
9708
9675
  }, 50);
9709
9676
  }
@@ -9768,9 +9735,9 @@ function stopNativeHorizontalDelete(view, dir) {
9768
9735
  }
9769
9736
  return false;
9770
9737
  }
9771
- function switchEditable(view, node, state3) {
9738
+ function switchEditable(view, node, state) {
9772
9739
  view.domObserver.stop();
9773
- node.contentEditable = state3;
9740
+ node.contentEditable = state;
9774
9741
  view.domObserver.start();
9775
9742
  }
9776
9743
  function safariDownArrowBug(view) {
@@ -10436,14 +10403,14 @@ var timeoutComposition = android ? 5e3 : -1;
10436
10403
  editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
10437
10404
  if (!view.composing) {
10438
10405
  view.domObserver.flush();
10439
- let { state: state3 } = view, $pos = state3.selection.$to;
10440
- if (state3.selection instanceof TextSelection && (state3.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows && selectionBeforeUneditable(view))) {
10406
+ let { state } = view, $pos = state.selection.$to;
10407
+ if (state.selection instanceof TextSelection && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows && selectionBeforeUneditable(view))) {
10441
10408
  view.markCursor = view.state.storedMarks || $pos.marks();
10442
10409
  endComposition(view, true);
10443
10410
  view.markCursor = null;
10444
10411
  } else {
10445
- endComposition(view, !state3.selection.empty);
10446
- if (gecko && state3.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {
10412
+ endComposition(view, !state.selection.empty);
10413
+ if (gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {
10447
10414
  let sel = view.domSelectionRange();
10448
10415
  for (let node = sel.focusNode, offset = sel.focusOffset; node && node.nodeType == 1 && offset != 0; ) {
10449
10416
  let before = offset < 0 ? node.lastChild : node.childNodes[offset - 1];
@@ -12146,18 +12113,18 @@ var EditorView = class {
12146
12113
  Update the editor's `state` prop, without touching any of the
12147
12114
  other props.
12148
12115
  */
12149
- updateState(state3) {
12150
- this.updateStateInner(state3, this._props);
12116
+ updateState(state) {
12117
+ this.updateStateInner(state, this._props);
12151
12118
  }
12152
- updateStateInner(state3, prevProps) {
12119
+ updateStateInner(state, prevProps) {
12153
12120
  var _a;
12154
12121
  let prev = this.state, redraw = false, updateSel = false;
12155
- if (state3.storedMarks && this.composing) {
12122
+ if (state.storedMarks && this.composing) {
12156
12123
  clearComposition(this);
12157
12124
  updateSel = true;
12158
12125
  }
12159
- this.state = state3;
12160
- let pluginsChanged = prev.plugins != state3.plugins || this._props.plugins != prevProps.plugins;
12126
+ this.state = state;
12127
+ let pluginsChanged = prev.plugins != state.plugins || this._props.plugins != prevProps.plugins;
12161
12128
  if (pluginsChanged || this._props.plugins != prevProps.plugins || this._props.nodeViews != prevProps.nodeViews) {
12162
12129
  let nodeViews = buildNodeViews(this);
12163
12130
  if (changedNodeViews(nodeViews, this.nodeViews)) {
@@ -12171,22 +12138,22 @@ var EditorView = class {
12171
12138
  this.editable = getEditable(this);
12172
12139
  updateCursorWrapper(this);
12173
12140
  let innerDeco = viewDecorations(this), outerDeco = computeDocDeco(this);
12174
- let scroll = prev.plugins != state3.plugins && !prev.doc.eq(state3.doc) ? "reset" : state3.scrollToSelection > prev.scrollToSelection ? "to selection" : "preserve";
12175
- let updateDoc = redraw || !this.docView.matchesNode(state3.doc, outerDeco, innerDeco);
12176
- if (updateDoc || !state3.selection.eq(prev.selection))
12141
+ let scroll = prev.plugins != state.plugins && !prev.doc.eq(state.doc) ? "reset" : state.scrollToSelection > prev.scrollToSelection ? "to selection" : "preserve";
12142
+ let updateDoc = redraw || !this.docView.matchesNode(state.doc, outerDeco, innerDeco);
12143
+ if (updateDoc || !state.selection.eq(prev.selection))
12177
12144
  updateSel = true;
12178
12145
  let oldScrollPos = scroll == "preserve" && updateSel && this.dom.style.overflowAnchor == null && storeScrollPos(this);
12179
12146
  if (updateSel) {
12180
12147
  this.domObserver.stop();
12181
- let forceSelUpdate = updateDoc && (ie || chrome) && !this.composing && !prev.selection.empty && !state3.selection.empty && selectionContextChanged(prev.selection, state3.selection);
12148
+ let forceSelUpdate = updateDoc && (ie || chrome) && !this.composing && !prev.selection.empty && !state.selection.empty && selectionContextChanged(prev.selection, state.selection);
12182
12149
  if (updateDoc) {
12183
12150
  let chromeKludge = chrome ? this.trackWrites = this.domSelectionRange().focusNode : null;
12184
12151
  if (this.composing)
12185
12152
  this.input.compositionNode = findCompositionNode(this);
12186
- if (redraw || !this.docView.update(state3.doc, outerDeco, innerDeco, this)) {
12153
+ if (redraw || !this.docView.update(state.doc, outerDeco, innerDeco, this)) {
12187
12154
  this.docView.updateOuterDeco(outerDeco);
12188
12155
  this.docView.destroy();
12189
- this.docView = docViewDesc(state3.doc, outerDeco, innerDeco, this.dom, this);
12156
+ this.docView = docViewDesc(state.doc, outerDeco, innerDeco, this.dom, this);
12190
12157
  }
12191
12158
  if (chromeKludge && (!this.trackWrites || !this.dom.contains(this.trackWrites)))
12192
12159
  forceSelUpdate = true;
@@ -12194,13 +12161,13 @@ var EditorView = class {
12194
12161
  if (forceSelUpdate || !(this.input.mouseDown && this.domObserver.currentSelection.eq(this.domSelectionRange()) && anchorInRightPlace(this))) {
12195
12162
  selectionToDOM(this, forceSelUpdate);
12196
12163
  } else {
12197
- syncNodeSelection(this, state3.selection);
12164
+ syncNodeSelection(this, state.selection);
12198
12165
  this.domObserver.setCurSelection();
12199
12166
  }
12200
12167
  this.domObserver.start();
12201
12168
  }
12202
12169
  this.updatePluginViews(prev);
12203
- if (((_a = this.dragging) === null || _a === void 0 ? void 0 : _a.node) && !prev.doc.eq(state3.doc))
12170
+ if (((_a = this.dragging) === null || _a === void 0 ? void 0 : _a.node) && !prev.doc.eq(state.doc))
12204
12171
  this.updateDraggedNode(this.dragging, prev);
12205
12172
  if (scroll == "reset") {
12206
12173
  this.dom.scrollTop = 0;
@@ -12410,8 +12377,8 @@ var EditorView = class {
12410
12377
  to the view's current state by default, but it is possible to
12411
12378
  pass a different state.
12412
12379
  */
12413
- endOfTextblock(dir, state3) {
12414
- return endOfTextblock(this, state3 || this.state, dir);
12380
+ endOfTextblock(dir, state) {
12381
+ return endOfTextblock(this, state || this.state, dir);
12415
12382
  }
12416
12383
  /**
12417
12384
  Run the editor's paste logic with the given HTML string. The
@@ -12752,18 +12719,18 @@ var __export = (target, all) => {
12752
12719
  __defProp(target, name, { get: all[name], enumerable: true });
12753
12720
  };
12754
12721
  function createChainableState(config) {
12755
- const { state: state3, transaction } = config;
12722
+ const { state, transaction } = config;
12756
12723
  let { selection } = transaction;
12757
12724
  let { doc: doc3 } = transaction;
12758
12725
  let { storedMarks } = transaction;
12759
12726
  return {
12760
- ...state3,
12761
- apply: state3.apply.bind(state3),
12762
- applyTransaction: state3.applyTransaction.bind(state3),
12763
- plugins: state3.plugins,
12764
- schema: state3.schema,
12765
- reconfigure: state3.reconfigure.bind(state3),
12766
- toJSON: state3.toJSON.bind(state3),
12727
+ ...state,
12728
+ apply: state.apply.bind(state),
12729
+ applyTransaction: state.applyTransaction.bind(state),
12730
+ plugins: state.plugins,
12731
+ schema: state.schema,
12732
+ reconfigure: state.reconfigure.bind(state),
12733
+ toJSON: state.toJSON.bind(state),
12767
12734
  get storedMarks() {
12768
12735
  return storedMarks;
12769
12736
  },
@@ -12794,9 +12761,9 @@ var CommandManager = class {
12794
12761
  return this.customState || this.editor.state;
12795
12762
  }
12796
12763
  get commands() {
12797
- const { rawCommands, editor, state: state3 } = this;
12764
+ const { rawCommands, editor, state } = this;
12798
12765
  const { view } = editor;
12799
- const { tr: tr2 } = state3;
12766
+ const { tr: tr2 } = state;
12800
12767
  const props = this.buildProps(tr2);
12801
12768
  return Object.fromEntries(
12802
12769
  Object.entries(rawCommands).map(([name, command2]) => {
@@ -12818,11 +12785,11 @@ var CommandManager = class {
12818
12785
  return () => this.createCan();
12819
12786
  }
12820
12787
  createChain(startTr, shouldDispatch = true) {
12821
- const { rawCommands, editor, state: state3 } = this;
12788
+ const { rawCommands, editor, state } = this;
12822
12789
  const { view } = editor;
12823
12790
  const callbacks = [];
12824
12791
  const hasStartTransaction = !!startTr;
12825
- const tr2 = startTr || state3.tr;
12792
+ const tr2 = startTr || state.tr;
12826
12793
  const run32 = () => {
12827
12794
  if (!hasStartTransaction && shouldDispatch && !tr2.getMeta("preventDispatch") && !this.hasCustomState) {
12828
12795
  view.dispatch(tr2);
@@ -12846,9 +12813,9 @@ var CommandManager = class {
12846
12813
  return chain;
12847
12814
  }
12848
12815
  createCan(startTr) {
12849
- const { rawCommands, state: state3 } = this;
12816
+ const { rawCommands, state } = this;
12850
12817
  const dispatch = false;
12851
- const tr2 = startTr || state3.tr;
12818
+ const tr2 = startTr || state.tr;
12852
12819
  const props = this.buildProps(tr2, dispatch);
12853
12820
  const formattedCommands = Object.fromEntries(
12854
12821
  Object.entries(rawCommands).map(([name, command2]) => {
@@ -12861,14 +12828,14 @@ var CommandManager = class {
12861
12828
  };
12862
12829
  }
12863
12830
  buildProps(tr2, shouldDispatch = true) {
12864
- const { rawCommands, editor, state: state3 } = this;
12831
+ const { rawCommands, editor, state } = this;
12865
12832
  const { view } = editor;
12866
12833
  const props = {
12867
12834
  tr: tr2,
12868
12835
  editor,
12869
12836
  view,
12870
12837
  state: createChainableState({
12871
- state: state3,
12838
+ state,
12872
12839
  transaction: tr2
12873
12840
  }),
12874
12841
  dispatch: shouldDispatch ? () => void 0 : void 0,
@@ -12962,14 +12929,14 @@ var blur = () => ({ editor, view }) => {
12962
12929
  var clearContent = (emitUpdate = true) => ({ commands }) => {
12963
12930
  return commands.setContent("", { emitUpdate });
12964
12931
  };
12965
- var clearNodes = () => ({ state: state3, tr: tr2, dispatch }) => {
12932
+ var clearNodes = () => ({ state, tr: tr2, dispatch }) => {
12966
12933
  const { selection } = tr2;
12967
12934
  const { ranges } = selection;
12968
12935
  if (!dispatch) {
12969
12936
  return true;
12970
12937
  }
12971
12938
  ranges.forEach(({ $from, $to }) => {
12972
- state3.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
12939
+ state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
12973
12940
  if (node.type.isText) {
12974
12941
  return;
12975
12942
  }
@@ -12995,12 +12962,12 @@ var clearNodes = () => ({ state: state3, tr: tr2, dispatch }) => {
12995
12962
  var command = (fn) => (props) => {
12996
12963
  return fn(props);
12997
12964
  };
12998
- var createParagraphNear2 = () => ({ state: state3, dispatch }) => {
12999
- return createParagraphNear(state3, dispatch);
12965
+ var createParagraphNear2 = () => ({ state, dispatch }) => {
12966
+ return createParagraphNear(state, dispatch);
13000
12967
  };
13001
12968
  var cut = (originRange, targetPos) => ({ editor, tr: tr2 }) => {
13002
- const { state: state3 } = editor;
13003
- const contentSlice = state3.doc.slice(originRange.from, originRange.to);
12969
+ const { state } = editor;
12970
+ const contentSlice = state.doc.slice(originRange.from, originRange.to);
13004
12971
  tr2.deleteRange(originRange.from, originRange.to);
13005
12972
  const newPos = tr2.mapping.map(targetPos);
13006
12973
  tr2.insert(newPos, contentSlice.content);
@@ -13036,8 +13003,8 @@ function getNodeType(nameOrType, schema) {
13036
13003
  }
13037
13004
  return nameOrType;
13038
13005
  }
13039
- var deleteNode = (typeOrName) => ({ tr: tr2, state: state3, dispatch }) => {
13040
- const type = getNodeType(typeOrName, state3.schema);
13006
+ var deleteNode = (typeOrName) => ({ tr: tr2, state, dispatch }) => {
13007
+ const type = getNodeType(typeOrName, state.schema);
13041
13008
  const $pos = tr2.selection.$anchor;
13042
13009
  for (let depth = $pos.depth; depth > 0; depth -= 1) {
13043
13010
  const node = $pos.node(depth);
@@ -13059,14 +13026,14 @@ var deleteRange2 = (range) => ({ tr: tr2, dispatch }) => {
13059
13026
  }
13060
13027
  return true;
13061
13028
  };
13062
- var deleteSelection2 = () => ({ state: state3, dispatch }) => {
13063
- return deleteSelection(state3, dispatch);
13029
+ var deleteSelection2 = () => ({ state, dispatch }) => {
13030
+ return deleteSelection(state, dispatch);
13064
13031
  };
13065
13032
  var enter = () => ({ commands }) => {
13066
13033
  return commands.keyboardShortcut("Enter");
13067
13034
  };
13068
- var exitCode2 = () => ({ state: state3, dispatch }) => {
13069
- return exitCode(state3, dispatch);
13035
+ var exitCode2 = () => ({ state, dispatch }) => {
13036
+ return exitCode(state, dispatch);
13070
13037
  };
13071
13038
  function isRegExp(value) {
13072
13039
  return Object.prototype.toString.call(value) === "[object RegExp]";
@@ -13141,8 +13108,8 @@ function getMarkType(nameOrType, schema) {
13141
13108
  }
13142
13109
  return nameOrType;
13143
13110
  }
13144
- var extendMarkRange = (typeOrName, attributes = {}) => ({ tr: tr2, state: state3, dispatch }) => {
13145
- const type = getMarkType(typeOrName, state3.schema);
13111
+ var extendMarkRange = (typeOrName, attributes = {}) => ({ tr: tr2, state, dispatch }) => {
13112
+ const type = getMarkType(typeOrName, state.schema);
13146
13113
  const { doc: doc3, selection } = tr2;
13147
13114
  const { $from, from: from2, to } = selection;
13148
13115
  if (dispatch) {
@@ -13472,21 +13439,21 @@ var insertContentAt = (position, value, options) => ({ tr: tr2, dispatch, editor
13472
13439
  }
13473
13440
  return true;
13474
13441
  };
13475
- var joinUp2 = () => ({ state: state3, dispatch }) => {
13476
- return joinUp(state3, dispatch);
13442
+ var joinUp2 = () => ({ state, dispatch }) => {
13443
+ return joinUp(state, dispatch);
13477
13444
  };
13478
- var joinDown2 = () => ({ state: state3, dispatch }) => {
13479
- return joinDown(state3, dispatch);
13445
+ var joinDown2 = () => ({ state, dispatch }) => {
13446
+ return joinDown(state, dispatch);
13480
13447
  };
13481
- var joinBackward2 = () => ({ state: state3, dispatch }) => {
13482
- return joinBackward(state3, dispatch);
13448
+ var joinBackward2 = () => ({ state, dispatch }) => {
13449
+ return joinBackward(state, dispatch);
13483
13450
  };
13484
- var joinForward2 = () => ({ state: state3, dispatch }) => {
13485
- return joinForward(state3, dispatch);
13451
+ var joinForward2 = () => ({ state, dispatch }) => {
13452
+ return joinForward(state, dispatch);
13486
13453
  };
13487
- var joinItemBackward = () => ({ state: state3, dispatch, tr: tr2 }) => {
13454
+ var joinItemBackward = () => ({ state, dispatch, tr: tr2 }) => {
13488
13455
  try {
13489
- const point = joinPoint(state3.doc, state3.selection.$from.pos, -1);
13456
+ const point = joinPoint(state.doc, state.selection.$from.pos, -1);
13490
13457
  if (point === null || point === void 0) {
13491
13458
  return false;
13492
13459
  }
@@ -13499,9 +13466,9 @@ var joinItemBackward = () => ({ state: state3, dispatch, tr: tr2 }) => {
13499
13466
  return false;
13500
13467
  }
13501
13468
  };
13502
- var joinItemForward = () => ({ state: state3, dispatch, tr: tr2 }) => {
13469
+ var joinItemForward = () => ({ state, dispatch, tr: tr2 }) => {
13503
13470
  try {
13504
- const point = joinPoint(state3.doc, state3.selection.$from.pos, 1);
13471
+ const point = joinPoint(state.doc, state.selection.$from.pos, 1);
13505
13472
  if (point === null || point === void 0) {
13506
13473
  return false;
13507
13474
  }
@@ -13514,11 +13481,11 @@ var joinItemForward = () => ({ state: state3, dispatch, tr: tr2 }) => {
13514
13481
  return false;
13515
13482
  }
13516
13483
  };
13517
- var joinTextblockBackward2 = () => ({ state: state3, dispatch }) => {
13518
- return joinTextblockBackward(state3, dispatch);
13484
+ var joinTextblockBackward2 = () => ({ state, dispatch }) => {
13485
+ return joinTextblockBackward(state, dispatch);
13519
13486
  };
13520
- var joinTextblockForward2 = () => ({ state: state3, dispatch }) => {
13521
- return joinTextblockForward(state3, dispatch);
13487
+ var joinTextblockForward2 = () => ({ state, dispatch }) => {
13488
+ return joinTextblockForward(state, dispatch);
13522
13489
  };
13523
13490
  function isMacOS() {
13524
13491
  return typeof navigator !== "undefined" ? /Mac/.test(navigator.platform) : false;
@@ -13590,11 +13557,11 @@ var keyboardShortcut = (name) => ({ editor, view, tr: tr2, dispatch }) => {
13590
13557
  });
13591
13558
  return true;
13592
13559
  };
13593
- function isNodeActive(state3, typeOrName, attributes = {}) {
13594
- const { from: from2, to, empty: empty2 } = state3.selection;
13595
- const type = typeOrName ? getNodeType(typeOrName, state3.schema) : null;
13560
+ function isNodeActive(state, typeOrName, attributes = {}) {
13561
+ const { from: from2, to, empty: empty2 } = state.selection;
13562
+ const type = typeOrName ? getNodeType(typeOrName, state.schema) : null;
13596
13563
  const nodeRanges = [];
13597
- state3.doc.nodesBetween(from2, to, (node, pos) => {
13564
+ state.doc.nodesBetween(from2, to, (node, pos) => {
13598
13565
  if (node.isText) {
13599
13566
  return;
13600
13567
  }
@@ -13619,23 +13586,23 @@ function isNodeActive(state3, typeOrName, attributes = {}) {
13619
13586
  const range = matchedNodeRanges.reduce((sum, nodeRange) => sum + nodeRange.to - nodeRange.from, 0);
13620
13587
  return range >= selectionRange;
13621
13588
  }
13622
- var lift3 = (typeOrName, attributes = {}) => ({ state: state3, dispatch }) => {
13623
- const type = getNodeType(typeOrName, state3.schema);
13624
- const isActive2 = isNodeActive(state3, type, attributes);
13589
+ var lift3 = (typeOrName, attributes = {}) => ({ state, dispatch }) => {
13590
+ const type = getNodeType(typeOrName, state.schema);
13591
+ const isActive2 = isNodeActive(state, type, attributes);
13625
13592
  if (!isActive2) {
13626
13593
  return false;
13627
13594
  }
13628
- return lift2(state3, dispatch);
13595
+ return lift2(state, dispatch);
13629
13596
  };
13630
- var liftEmptyBlock2 = () => ({ state: state3, dispatch }) => {
13631
- return liftEmptyBlock(state3, dispatch);
13597
+ var liftEmptyBlock2 = () => ({ state, dispatch }) => {
13598
+ return liftEmptyBlock(state, dispatch);
13632
13599
  };
13633
- var liftListItem2 = (typeOrName) => ({ state: state3, dispatch }) => {
13634
- const type = getNodeType(typeOrName, state3.schema);
13635
- return liftListItem(type)(state3, dispatch);
13600
+ var liftListItem2 = (typeOrName) => ({ state, dispatch }) => {
13601
+ const type = getNodeType(typeOrName, state.schema);
13602
+ return liftListItem(type)(state, dispatch);
13636
13603
  };
13637
- var newlineInCode2 = () => ({ state: state3, dispatch }) => {
13638
- return newlineInCode(state3, dispatch);
13604
+ var newlineInCode2 = () => ({ state, dispatch }) => {
13605
+ return newlineInCode(state, dispatch);
13639
13606
  };
13640
13607
  function getSchemaTypeNameByName(name, schema) {
13641
13608
  if (schema.nodes[name]) {
@@ -13655,25 +13622,25 @@ function deleteProps(obj, propOrProps) {
13655
13622
  return newObj;
13656
13623
  }, {});
13657
13624
  }
13658
- var resetAttributes = (typeOrName, attributes) => ({ tr: tr2, state: state3, dispatch }) => {
13625
+ var resetAttributes = (typeOrName, attributes) => ({ tr: tr2, state, dispatch }) => {
13659
13626
  let nodeType = null;
13660
13627
  let markType = null;
13661
13628
  const schemaType = getSchemaTypeNameByName(
13662
13629
  typeof typeOrName === "string" ? typeOrName : typeOrName.name,
13663
- state3.schema
13630
+ state.schema
13664
13631
  );
13665
13632
  if (!schemaType) {
13666
13633
  return false;
13667
13634
  }
13668
13635
  if (schemaType === "node") {
13669
- nodeType = getNodeType(typeOrName, state3.schema);
13636
+ nodeType = getNodeType(typeOrName, state.schema);
13670
13637
  }
13671
13638
  if (schemaType === "mark") {
13672
- markType = getMarkType(typeOrName, state3.schema);
13639
+ markType = getMarkType(typeOrName, state.schema);
13673
13640
  }
13674
13641
  let canReset = false;
13675
13642
  tr2.selection.ranges.forEach((range) => {
13676
- state3.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {
13643
+ state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {
13677
13644
  if (nodeType && nodeType === node.type) {
13678
13645
  canReset = true;
13679
13646
  if (dispatch) {
@@ -13707,20 +13674,20 @@ var selectAll2 = () => ({ tr: tr2, dispatch }) => {
13707
13674
  }
13708
13675
  return true;
13709
13676
  };
13710
- var selectNodeBackward2 = () => ({ state: state3, dispatch }) => {
13711
- return selectNodeBackward(state3, dispatch);
13677
+ var selectNodeBackward2 = () => ({ state, dispatch }) => {
13678
+ return selectNodeBackward(state, dispatch);
13712
13679
  };
13713
- var selectNodeForward2 = () => ({ state: state3, dispatch }) => {
13714
- return selectNodeForward(state3, dispatch);
13680
+ var selectNodeForward2 = () => ({ state, dispatch }) => {
13681
+ return selectNodeForward(state, dispatch);
13715
13682
  };
13716
- var selectParentNode2 = () => ({ state: state3, dispatch }) => {
13717
- return selectParentNode(state3, dispatch);
13683
+ var selectParentNode2 = () => ({ state, dispatch }) => {
13684
+ return selectParentNode(state, dispatch);
13718
13685
  };
13719
- var selectTextblockEnd2 = () => ({ state: state3, dispatch }) => {
13720
- return selectTextblockEnd(state3, dispatch);
13686
+ var selectTextblockEnd2 = () => ({ state, dispatch }) => {
13687
+ return selectTextblockEnd(state, dispatch);
13721
13688
  };
13722
- var selectTextblockStart2 = () => ({ state: state3, dispatch }) => {
13723
- return selectTextblockStart(state3, dispatch);
13689
+ var selectTextblockStart2 = () => ({ state, dispatch }) => {
13690
+ return selectTextblockStart(state, dispatch);
13724
13691
  };
13725
13692
  function createDocument(content, schema, parseOptions = {}, options = {}) {
13726
13693
  return createNodeFromContent(content, schema, {
@@ -13748,17 +13715,17 @@ var setContent = (content, { errorOnInvalidContent, emitUpdate = true, parseOpti
13748
13715
  errorOnInvalidContent: errorOnInvalidContent != null ? errorOnInvalidContent : editor.options.enableContentCheck
13749
13716
  });
13750
13717
  };
13751
- function getMarkAttributes(state3, typeOrName) {
13752
- const type = getMarkType(typeOrName, state3.schema);
13753
- const { from: from2, to, empty: empty2 } = state3.selection;
13718
+ function getMarkAttributes(state, typeOrName) {
13719
+ const type = getMarkType(typeOrName, state.schema);
13720
+ const { from: from2, to, empty: empty2 } = state.selection;
13754
13721
  const marks = [];
13755
13722
  if (empty2) {
13756
- if (state3.storedMarks) {
13757
- marks.push(...state3.storedMarks);
13723
+ if (state.storedMarks) {
13724
+ marks.push(...state.storedMarks);
13758
13725
  }
13759
- marks.push(...state3.selection.$head.marks());
13726
+ marks.push(...state.selection.$head.marks());
13760
13727
  } else {
13761
- state3.doc.nodesBetween(from2, to, (node) => {
13728
+ state.doc.nodesBetween(from2, to, (node) => {
13762
13729
  marks.push(...node.marks);
13763
13730
  });
13764
13731
  }
@@ -14298,11 +14265,11 @@ function getTextSerializersFromSchema(schema) {
14298
14265
  Object.entries(schema.nodes).filter(([, node]) => node.spec.toText).map(([name, node]) => [name, node.spec.toText])
14299
14266
  );
14300
14267
  }
14301
- function getNodeAttributes(state3, typeOrName) {
14302
- const type = getNodeType(typeOrName, state3.schema);
14303
- const { from: from2, to } = state3.selection;
14268
+ function getNodeAttributes(state, typeOrName) {
14269
+ const type = getNodeType(typeOrName, state.schema);
14270
+ const { from: from2, to } = state.selection;
14304
14271
  const nodes = [];
14305
- state3.doc.nodesBetween(from2, to, (node2) => {
14272
+ state.doc.nodesBetween(from2, to, (node2) => {
14306
14273
  nodes.push(node2);
14307
14274
  });
14308
14275
  const node = nodes.reverse().find((nodeItem) => nodeItem.type.name === type.name);
@@ -14311,16 +14278,16 @@ function getNodeAttributes(state3, typeOrName) {
14311
14278
  }
14312
14279
  return { ...node.attrs };
14313
14280
  }
14314
- function getAttributes(state3, typeOrName) {
14281
+ function getAttributes(state, typeOrName) {
14315
14282
  const schemaType = getSchemaTypeNameByName(
14316
14283
  typeof typeOrName === "string" ? typeOrName : typeOrName.name,
14317
- state3.schema
14284
+ state.schema
14318
14285
  );
14319
14286
  if (schemaType === "node") {
14320
- return getNodeAttributes(state3, typeOrName);
14287
+ return getNodeAttributes(state, typeOrName);
14321
14288
  }
14322
14289
  if (schemaType === "mark") {
14323
- return getMarkAttributes(state3, typeOrName);
14290
+ return getMarkAttributes(state, typeOrName);
14324
14291
  }
14325
14292
  return {};
14326
14293
  }
@@ -14405,8 +14372,8 @@ function getMarksBetween(from2, to, doc3) {
14405
14372
  }
14406
14373
  return marks;
14407
14374
  }
14408
- var getNodeAtPosition = (state3, typeOrName, pos, maxDepth = 20) => {
14409
- const $pos = state3.doc.resolve(pos);
14375
+ var getNodeAtPosition = (state, typeOrName, pos, maxDepth = 20) => {
14376
+ const $pos = state.doc.resolve(pos);
14410
14377
  let currentDepth = maxDepth;
14411
14378
  let node = null;
14412
14379
  while (currentDepth > 0 && node === null) {
@@ -14450,11 +14417,11 @@ var getTextContentFromNodes = ($from, maxMatch = 500) => {
14450
14417
  });
14451
14418
  return textBefore;
14452
14419
  };
14453
- function isMarkActive(state3, typeOrName, attributes = {}) {
14454
- const { empty: empty2, ranges } = state3.selection;
14455
- const type = typeOrName ? getMarkType(typeOrName, state3.schema) : null;
14420
+ function isMarkActive(state, typeOrName, attributes = {}) {
14421
+ const { empty: empty2, ranges } = state.selection;
14422
+ const type = typeOrName ? getMarkType(typeOrName, state.schema) : null;
14456
14423
  if (empty2) {
14457
- return !!(state3.storedMarks || state3.selection.$from.marks()).filter((mark) => {
14424
+ return !!(state.storedMarks || state.selection.$from.marks()).filter((mark) => {
14458
14425
  if (!type) {
14459
14426
  return true;
14460
14427
  }
@@ -14466,7 +14433,7 @@ function isMarkActive(state3, typeOrName, attributes = {}) {
14466
14433
  ranges.forEach(({ $from, $to }) => {
14467
14434
  const from2 = $from.pos;
14468
14435
  const to = $to.pos;
14469
- state3.doc.nodesBetween(from2, to, (node, pos) => {
14436
+ state.doc.nodesBetween(from2, to, (node, pos) => {
14470
14437
  if (type && node.inlineContent && !node.type.allowsMarkType(type)) {
14471
14438
  return false;
14472
14439
  }
@@ -14504,27 +14471,27 @@ function isMarkActive(state3, typeOrName, attributes = {}) {
14504
14471
  const range = matchedRange > 0 ? matchedRange + excludedRange : matchedRange;
14505
14472
  return range >= selectionRange;
14506
14473
  }
14507
- function isActive(state3, name, attributes = {}) {
14474
+ function isActive(state, name, attributes = {}) {
14508
14475
  if (!name) {
14509
- return isNodeActive(state3, null, attributes) || isMarkActive(state3, null, attributes);
14476
+ return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes);
14510
14477
  }
14511
- const schemaType = getSchemaTypeNameByName(name, state3.schema);
14478
+ const schemaType = getSchemaTypeNameByName(name, state.schema);
14512
14479
  if (schemaType === "node") {
14513
- return isNodeActive(state3, name, attributes);
14480
+ return isNodeActive(state, name, attributes);
14514
14481
  }
14515
14482
  if (schemaType === "mark") {
14516
- return isMarkActive(state3, name, attributes);
14483
+ return isMarkActive(state, name, attributes);
14517
14484
  }
14518
14485
  return false;
14519
14486
  }
14520
- var isAtEndOfNode = (state3, nodeType) => {
14521
- const { $from, $to, $anchor } = state3.selection;
14487
+ var isAtEndOfNode = (state, nodeType) => {
14488
+ const { $from, $to, $anchor } = state.selection;
14522
14489
  if (nodeType) {
14523
- const parentNode2 = findParentNode((node) => node.type.name === nodeType)(state3.selection);
14490
+ const parentNode2 = findParentNode((node) => node.type.name === nodeType)(state.selection);
14524
14491
  if (!parentNode2) {
14525
14492
  return false;
14526
14493
  }
14527
- const $parentPos = state3.doc.resolve(parentNode2.pos + 1);
14494
+ const $parentPos = state.doc.resolve(parentNode2.pos + 1);
14528
14495
  if ($anchor.pos + 1 === $parentPos.end()) {
14529
14496
  return true;
14530
14497
  }
@@ -14535,8 +14502,8 @@ var isAtEndOfNode = (state3, nodeType) => {
14535
14502
  }
14536
14503
  return true;
14537
14504
  };
14538
- var isAtStartOfNode = (state3) => {
14539
- const { $from, $to } = state3.selection;
14505
+ var isAtStartOfNode = (state) => {
14506
+ const { $from, $to } = state.selection;
14540
14507
  if ($from.parentOffset > 0 || $from.pos !== $to.pos) {
14541
14508
  return false;
14542
14509
  }
@@ -14636,7 +14603,7 @@ function getUpdatedPosition(position, transaction) {
14636
14603
  function createMappablePosition(position) {
14637
14604
  return new MappablePosition(position);
14638
14605
  }
14639
- function canSetMark(state3, tr2, newMarkType) {
14606
+ function canSetMark(state, tr2, newMarkType) {
14640
14607
  var _a;
14641
14608
  const { selection } = tr2;
14642
14609
  let cursor = null;
@@ -14644,14 +14611,14 @@ function canSetMark(state3, tr2, newMarkType) {
14644
14611
  cursor = selection.$cursor;
14645
14612
  }
14646
14613
  if (cursor) {
14647
- const currentMarks = (_a = state3.storedMarks) != null ? _a : cursor.marks();
14614
+ const currentMarks = (_a = state.storedMarks) != null ? _a : cursor.marks();
14648
14615
  const parentAllowsMarkType = cursor.parent.type.allowsMarkType(newMarkType);
14649
14616
  return parentAllowsMarkType && (!!newMarkType.isInSet(currentMarks) || !currentMarks.some((mark) => mark.type.excludes(newMarkType)));
14650
14617
  }
14651
14618
  const { ranges } = selection;
14652
14619
  return ranges.some(({ $from, $to }) => {
14653
- let someNodeSupportsMark = $from.depth === 0 ? state3.doc.inlineContent && state3.doc.type.allowsMarkType(newMarkType) : false;
14654
- state3.doc.nodesBetween($from.pos, $to.pos, (node, _pos, parent) => {
14620
+ let someNodeSupportsMark = $from.depth === 0 ? state.doc.inlineContent && state.doc.type.allowsMarkType(newMarkType) : false;
14621
+ state.doc.nodesBetween($from.pos, $to.pos, (node, _pos, parent) => {
14655
14622
  if (someNodeSupportsMark) {
14656
14623
  return false;
14657
14624
  }
@@ -14665,13 +14632,13 @@ function canSetMark(state3, tr2, newMarkType) {
14665
14632
  return someNodeSupportsMark;
14666
14633
  });
14667
14634
  }
14668
- var setMark = (typeOrName, attributes = {}) => ({ tr: tr2, state: state3, dispatch }) => {
14635
+ var setMark = (typeOrName, attributes = {}) => ({ tr: tr2, state, dispatch }) => {
14669
14636
  const { selection } = tr2;
14670
14637
  const { empty: empty2, ranges } = selection;
14671
- const type = getMarkType(typeOrName, state3.schema);
14638
+ const type = getMarkType(typeOrName, state.schema);
14672
14639
  if (dispatch) {
14673
14640
  if (empty2) {
14674
- const oldAttributes = getMarkAttributes(state3, type);
14641
+ const oldAttributes = getMarkAttributes(state, type);
14675
14642
  tr2.addStoredMark(
14676
14643
  type.create({
14677
14644
  ...oldAttributes,
@@ -14682,7 +14649,7 @@ var setMark = (typeOrName, attributes = {}) => ({ tr: tr2, state: state3, dispat
14682
14649
  ranges.forEach((range) => {
14683
14650
  const from2 = range.$from.pos;
14684
14651
  const to = range.$to.pos;
14685
- state3.doc.nodesBetween(from2, to, (node, pos) => {
14652
+ state.doc.nodesBetween(from2, to, (node, pos) => {
14686
14653
  const trimmedFrom = Math.max(pos, from2);
14687
14654
  const trimmedTo = Math.min(pos + node.nodeSize, to);
14688
14655
  const someHasMark = node.marks.find((mark) => mark.type === type);
@@ -14706,24 +14673,24 @@ var setMark = (typeOrName, attributes = {}) => ({ tr: tr2, state: state3, dispat
14706
14673
  });
14707
14674
  }
14708
14675
  }
14709
- return canSetMark(state3, tr2, type);
14676
+ return canSetMark(state, tr2, type);
14710
14677
  };
14711
14678
  var setMeta = (key, value) => ({ tr: tr2 }) => {
14712
14679
  tr2.setMeta(key, value);
14713
14680
  return true;
14714
14681
  };
14715
- var setNode = (typeOrName, attributes = {}) => ({ state: state3, dispatch, chain }) => {
14716
- const type = getNodeType(typeOrName, state3.schema);
14682
+ var setNode = (typeOrName, attributes = {}) => ({ state, dispatch, chain }) => {
14683
+ const type = getNodeType(typeOrName, state.schema);
14717
14684
  let attributesToCopy;
14718
- if (state3.selection.$anchor.sameParent(state3.selection.$head)) {
14719
- attributesToCopy = state3.selection.$anchor.parent.attrs;
14685
+ if (state.selection.$anchor.sameParent(state.selection.$head)) {
14686
+ attributesToCopy = state.selection.$anchor.parent.attrs;
14720
14687
  }
14721
14688
  if (!type.isTextblock) {
14722
14689
  console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.');
14723
14690
  return false;
14724
14691
  }
14725
14692
  return chain().command(({ commands }) => {
14726
- const canSetBlock = setBlockType2(type, { ...attributesToCopy, ...attributes })(state3);
14693
+ const canSetBlock = setBlockType2(type, { ...attributesToCopy, ...attributes })(state);
14727
14694
  if (canSetBlock) {
14728
14695
  return true;
14729
14696
  }
@@ -14741,8 +14708,8 @@ var setNodeSelection = (position) => ({ tr: tr2, dispatch }) => {
14741
14708
  }
14742
14709
  return true;
14743
14710
  };
14744
- var setTextDirection = (direction, position) => ({ tr: tr2, state: state3, dispatch }) => {
14745
- const { selection } = state3;
14711
+ var setTextDirection = (direction, position) => ({ tr: tr2, state, dispatch }) => {
14712
+ const { selection } = state;
14746
14713
  let from2;
14747
14714
  let to;
14748
14715
  if (typeof position === "number") {
@@ -14781,18 +14748,18 @@ var setTextSelection = (position) => ({ tr: tr2, dispatch }) => {
14781
14748
  }
14782
14749
  return true;
14783
14750
  };
14784
- var sinkListItem2 = (typeOrName) => ({ state: state3, dispatch }) => {
14785
- const type = getNodeType(typeOrName, state3.schema);
14786
- return sinkListItem(type)(state3, dispatch);
14751
+ var sinkListItem2 = (typeOrName) => ({ state, dispatch }) => {
14752
+ const type = getNodeType(typeOrName, state.schema);
14753
+ return sinkListItem(type)(state, dispatch);
14787
14754
  };
14788
- function ensureMarks(state3, splittableMarks) {
14789
- const marks = state3.storedMarks || state3.selection.$to.parentOffset && state3.selection.$from.marks();
14755
+ function ensureMarks(state, splittableMarks) {
14756
+ const marks = state.storedMarks || state.selection.$to.parentOffset && state.selection.$from.marks();
14790
14757
  if (marks) {
14791
14758
  const filteredMarks = marks.filter((mark) => splittableMarks == null ? void 0 : splittableMarks.includes(mark.type.name));
14792
- state3.tr.ensureMarks(filteredMarks);
14759
+ state.tr.ensureMarks(filteredMarks);
14793
14760
  }
14794
14761
  }
14795
- var splitBlock2 = ({ keepMarks = true } = {}) => ({ tr: tr2, state: state3, dispatch, editor }) => {
14762
+ var splitBlock2 = ({ keepMarks = true } = {}) => ({ tr: tr2, state, dispatch, editor }) => {
14796
14763
  const { selection, doc: doc3 } = tr2;
14797
14764
  const { $from, $to } = selection;
14798
14765
  const extensionAttributes = editor.extensionManager.attributes;
@@ -14803,7 +14770,7 @@ var splitBlock2 = ({ keepMarks = true } = {}) => ({ tr: tr2, state: state3, disp
14803
14770
  }
14804
14771
  if (dispatch) {
14805
14772
  if (keepMarks) {
14806
- ensureMarks(state3, editor.extensionManager.splittableMarks);
14773
+ ensureMarks(state, editor.extensionManager.splittableMarks);
14807
14774
  }
14808
14775
  tr2.split($from.pos).scrollIntoView();
14809
14776
  }
@@ -14845,17 +14812,17 @@ var splitBlock2 = ({ keepMarks = true } = {}) => ({ tr: tr2, state: state3, disp
14845
14812
  }
14846
14813
  }
14847
14814
  if (keepMarks) {
14848
- ensureMarks(state3, editor.extensionManager.splittableMarks);
14815
+ ensureMarks(state, editor.extensionManager.splittableMarks);
14849
14816
  }
14850
14817
  tr2.scrollIntoView();
14851
14818
  }
14852
14819
  return can;
14853
14820
  };
14854
- var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr: tr2, state: state3, dispatch, editor }) => {
14821
+ var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr: tr2, state, dispatch, editor }) => {
14855
14822
  var _a;
14856
- const type = getNodeType(typeOrName, state3.schema);
14857
- const { $from, $to } = state3.selection;
14858
- const node = state3.selection.node;
14823
+ const type = getNodeType(typeOrName, state.schema);
14824
+ const { $from, $to } = state.selection;
14825
+ const node = state.selection.node;
14859
14826
  if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
14860
14827
  return false;
14861
14828
  }
@@ -14920,7 +14887,7 @@ var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr: tr2, state: state
14920
14887
  return false;
14921
14888
  }
14922
14889
  if (dispatch) {
14923
- const { selection, storedMarks } = state3;
14890
+ const { selection, storedMarks } = state;
14924
14891
  const { splittableMarks } = editor.extensionManager;
14925
14892
  const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
14926
14893
  tr2.split($from.pos, 2, types).scrollIntoView();
@@ -14966,11 +14933,11 @@ var joinListForwards = (tr2, listType) => {
14966
14933
  tr2.join(after);
14967
14934
  return true;
14968
14935
  };
14969
- var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) => ({ editor, tr: tr2, state: state3, dispatch, chain, commands, can }) => {
14936
+ var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) => ({ editor, tr: tr2, state, dispatch, chain, commands, can }) => {
14970
14937
  const { extensions, splittableMarks } = editor.extensionManager;
14971
- const listType = getNodeType(listTypeOrName, state3.schema);
14972
- const itemType = getNodeType(itemTypeOrName, state3.schema);
14973
- const { selection, storedMarks } = state3;
14938
+ const listType = getNodeType(listTypeOrName, state.schema);
14939
+ const itemType = getNodeType(itemTypeOrName, state.schema);
14940
+ const { selection, storedMarks } = state;
14974
14941
  const { $from, $to } = selection;
14975
14942
  const range = $from.blockRange($to);
14976
14943
  const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
@@ -15008,51 +14975,51 @@ var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) =>
15008
14975
  return commands.clearNodes();
15009
14976
  }).wrapInList(listType, attributes).command(() => joinListBackwards(tr2, listType)).command(() => joinListForwards(tr2, listType)).run();
15010
14977
  };
15011
- var toggleMark = (typeOrName, attributes = {}, options = {}) => ({ state: state3, commands }) => {
14978
+ var toggleMark = (typeOrName, attributes = {}, options = {}) => ({ state, commands }) => {
15012
14979
  const { extendEmptyMarkRange = false } = options;
15013
- const type = getMarkType(typeOrName, state3.schema);
15014
- const isActive2 = isMarkActive(state3, type, attributes);
14980
+ const type = getMarkType(typeOrName, state.schema);
14981
+ const isActive2 = isMarkActive(state, type, attributes);
15015
14982
  if (isActive2) {
15016
14983
  return commands.unsetMark(type, { extendEmptyMarkRange });
15017
14984
  }
15018
14985
  return commands.setMark(type, attributes);
15019
14986
  };
15020
- var toggleNode = (typeOrName, toggleTypeOrName, attributes = {}) => ({ state: state3, commands }) => {
15021
- const type = getNodeType(typeOrName, state3.schema);
15022
- const toggleType = getNodeType(toggleTypeOrName, state3.schema);
15023
- const isActive2 = isNodeActive(state3, type, attributes);
14987
+ var toggleNode = (typeOrName, toggleTypeOrName, attributes = {}) => ({ state, commands }) => {
14988
+ const type = getNodeType(typeOrName, state.schema);
14989
+ const toggleType = getNodeType(toggleTypeOrName, state.schema);
14990
+ const isActive2 = isNodeActive(state, type, attributes);
15024
14991
  let attributesToCopy;
15025
- if (state3.selection.$anchor.sameParent(state3.selection.$head)) {
15026
- attributesToCopy = state3.selection.$anchor.parent.attrs;
14992
+ if (state.selection.$anchor.sameParent(state.selection.$head)) {
14993
+ attributesToCopy = state.selection.$anchor.parent.attrs;
15027
14994
  }
15028
14995
  if (isActive2) {
15029
14996
  return commands.setNode(toggleType, attributesToCopy);
15030
14997
  }
15031
14998
  return commands.setNode(type, { ...attributesToCopy, ...attributes });
15032
14999
  };
15033
- var toggleWrap = (typeOrName, attributes = {}) => ({ state: state3, commands }) => {
15034
- const type = getNodeType(typeOrName, state3.schema);
15035
- const isActive2 = isNodeActive(state3, type, attributes);
15000
+ var toggleWrap = (typeOrName, attributes = {}) => ({ state, commands }) => {
15001
+ const type = getNodeType(typeOrName, state.schema);
15002
+ const isActive2 = isNodeActive(state, type, attributes);
15036
15003
  if (isActive2) {
15037
15004
  return commands.lift(type);
15038
15005
  }
15039
15006
  return commands.wrapIn(type, attributes);
15040
15007
  };
15041
- var undoInputRule = () => ({ state: state3, dispatch }) => {
15042
- const plugins = state3.plugins;
15008
+ var undoInputRule = () => ({ state, dispatch }) => {
15009
+ const plugins = state.plugins;
15043
15010
  for (let i = 0; i < plugins.length; i += 1) {
15044
15011
  const plugin = plugins[i];
15045
15012
  let undoable;
15046
- if (plugin.spec.isInputRules && (undoable = plugin.getState(state3))) {
15013
+ if (plugin.spec.isInputRules && (undoable = plugin.getState(state))) {
15047
15014
  if (dispatch) {
15048
- const tr2 = state3.tr;
15015
+ const tr2 = state.tr;
15049
15016
  const toUndo = undoable.transform;
15050
15017
  for (let j = toUndo.steps.length - 1; j >= 0; j -= 1) {
15051
15018
  tr2.step(toUndo.steps[j].invert(toUndo.docs[j]));
15052
15019
  }
15053
15020
  if (undoable.text) {
15054
15021
  const marks = tr2.doc.resolve(undoable.from).marks();
15055
- tr2.replaceWith(undoable.from, undoable.to, state3.schema.text(undoable.text, marks));
15022
+ tr2.replaceWith(undoable.from, undoable.to, state.schema.text(undoable.text, marks));
15056
15023
  } else {
15057
15024
  tr2.delete(undoable.from, undoable.to);
15058
15025
  }
@@ -15075,11 +15042,11 @@ var unsetAllMarks = () => ({ tr: tr2, dispatch }) => {
15075
15042
  }
15076
15043
  return true;
15077
15044
  };
15078
- var unsetMark = (typeOrName, options = {}) => ({ tr: tr2, state: state3, dispatch }) => {
15045
+ var unsetMark = (typeOrName, options = {}) => ({ tr: tr2, state, dispatch }) => {
15079
15046
  var _a;
15080
15047
  const { extendEmptyMarkRange = false } = options;
15081
15048
  const { selection } = tr2;
15082
- const type = getMarkType(typeOrName, state3.schema);
15049
+ const type = getMarkType(typeOrName, state.schema);
15083
15050
  const { $from, empty: empty2, ranges } = selection;
15084
15051
  if (!dispatch) {
15085
15052
  return true;
@@ -15101,8 +15068,8 @@ var unsetMark = (typeOrName, options = {}) => ({ tr: tr2, state: state3, dispatc
15101
15068
  tr2.removeStoredMark(type);
15102
15069
  return true;
15103
15070
  };
15104
- var unsetTextDirection = (position) => ({ tr: tr2, state: state3, dispatch }) => {
15105
- const { selection } = state3;
15071
+ var unsetTextDirection = (position) => ({ tr: tr2, state, dispatch }) => {
15072
+ const { selection } = state;
15106
15073
  let from2;
15107
15074
  let to;
15108
15075
  if (typeof position === "number") {
@@ -15127,21 +15094,21 @@ var unsetTextDirection = (position) => ({ tr: tr2, state: state3, dispatch }) =>
15127
15094
  }
15128
15095
  return true;
15129
15096
  };
15130
- var updateAttributes = (typeOrName, attributes = {}) => ({ tr: tr2, state: state3, dispatch }) => {
15097
+ var updateAttributes = (typeOrName, attributes = {}) => ({ tr: tr2, state, dispatch }) => {
15131
15098
  let nodeType = null;
15132
15099
  let markType = null;
15133
15100
  const schemaType = getSchemaTypeNameByName(
15134
15101
  typeof typeOrName === "string" ? typeOrName : typeOrName.name,
15135
- state3.schema
15102
+ state.schema
15136
15103
  );
15137
15104
  if (!schemaType) {
15138
15105
  return false;
15139
15106
  }
15140
15107
  if (schemaType === "node") {
15141
- nodeType = getNodeType(typeOrName, state3.schema);
15108
+ nodeType = getNodeType(typeOrName, state.schema);
15142
15109
  }
15143
15110
  if (schemaType === "mark") {
15144
- markType = getMarkType(typeOrName, state3.schema);
15111
+ markType = getMarkType(typeOrName, state.schema);
15145
15112
  }
15146
15113
  let canUpdate = false;
15147
15114
  tr2.selection.ranges.forEach((range) => {
@@ -15152,7 +15119,7 @@ var updateAttributes = (typeOrName, attributes = {}) => ({ tr: tr2, state: state
15152
15119
  let trimmedFrom;
15153
15120
  let trimmedTo;
15154
15121
  if (tr2.selection.empty) {
15155
- state3.doc.nodesBetween(from2, to, (node, pos) => {
15122
+ state.doc.nodesBetween(from2, to, (node, pos) => {
15156
15123
  if (nodeType && nodeType === node.type) {
15157
15124
  canUpdate = true;
15158
15125
  trimmedFrom = Math.max(pos, from2);
@@ -15162,7 +15129,7 @@ var updateAttributes = (typeOrName, attributes = {}) => ({ tr: tr2, state: state
15162
15129
  }
15163
15130
  });
15164
15131
  } else {
15165
- state3.doc.nodesBetween(from2, to, (node, pos) => {
15132
+ state.doc.nodesBetween(from2, to, (node, pos) => {
15166
15133
  if (pos < from2 && nodeType && nodeType === node.type) {
15167
15134
  canUpdate = true;
15168
15135
  trimmedFrom = Math.max(pos, from2);
@@ -15227,13 +15194,13 @@ var updateAttributes = (typeOrName, attributes = {}) => ({ tr: tr2, state: state
15227
15194
  });
15228
15195
  return canUpdate;
15229
15196
  };
15230
- var wrapIn2 = (typeOrName, attributes = {}) => ({ state: state3, dispatch }) => {
15231
- const type = getNodeType(typeOrName, state3.schema);
15232
- return wrapIn(type, attributes)(state3, dispatch);
15197
+ var wrapIn2 = (typeOrName, attributes = {}) => ({ state, dispatch }) => {
15198
+ const type = getNodeType(typeOrName, state.schema);
15199
+ return wrapIn(type, attributes)(state, dispatch);
15233
15200
  };
15234
- var wrapInList2 = (typeOrName, attributes = {}) => ({ state: state3, dispatch }) => {
15235
- const type = getNodeType(typeOrName, state3.schema);
15236
- return wrapInList(type, attributes)(state3, dispatch);
15201
+ var wrapInList2 = (typeOrName, attributes = {}) => ({ state, dispatch }) => {
15202
+ const type = getNodeType(typeOrName, state.schema);
15203
+ return wrapInList(type, attributes)(state, dispatch);
15237
15204
  };
15238
15205
  var EventEmitter = class {
15239
15206
  constructor() {
@@ -15329,7 +15296,7 @@ function run(config) {
15329
15296
  return;
15330
15297
  }
15331
15298
  const tr2 = view.state.tr;
15332
- const state3 = createChainableState({
15299
+ const state = createChainableState({
15333
15300
  state: view.state,
15334
15301
  transaction: tr2
15335
15302
  });
@@ -15339,10 +15306,10 @@ function run(config) {
15339
15306
  };
15340
15307
  const { commands, chain, can } = new CommandManager({
15341
15308
  editor,
15342
- state: state3
15309
+ state
15343
15310
  });
15344
15311
  const handler = rule.handler({
15345
- state: state3,
15312
+ state,
15346
15313
  range,
15347
15314
  match,
15348
15315
  commands,
@@ -15372,7 +15339,7 @@ function inputRulesPlugin(props) {
15372
15339
  init() {
15373
15340
  return null;
15374
15341
  },
15375
- apply(tr2, prev, state3) {
15342
+ apply(tr2, prev, state) {
15376
15343
  const stored = tr2.getMeta(plugin);
15377
15344
  if (stored) {
15378
15345
  return stored;
@@ -15385,7 +15352,7 @@ function inputRulesPlugin(props) {
15385
15352
  if (typeof text === "string") {
15386
15353
  text = text;
15387
15354
  } else {
15388
- text = getHTMLFromFragment(Fragment2.from(text), state3.schema);
15355
+ text = getHTMLFromFragment(Fragment2.from(text), state.schema);
15389
15356
  }
15390
15357
  const { from: from2 } = simulatedInputMeta;
15391
15358
  const to = from2 + text.length;
@@ -15604,13 +15571,13 @@ var pasteRuleMatcherHandler = (text, find2, event) => {
15604
15571
  });
15605
15572
  };
15606
15573
  function run2(config) {
15607
- const { editor, state: state3, from: from2, to, rule, pasteEvent, dropEvent } = config;
15574
+ const { editor, state, from: from2, to, rule, pasteEvent, dropEvent } = config;
15608
15575
  const { commands, chain, can } = new CommandManager({
15609
15576
  editor,
15610
- state: state3
15577
+ state
15611
15578
  });
15612
15579
  const handlers2 = [];
15613
- state3.doc.nodesBetween(from2, to, (node, pos) => {
15580
+ state.doc.nodesBetween(from2, to, (node, pos) => {
15614
15581
  var _a, _b, _c, _d, _e;
15615
15582
  if (((_b = (_a = node.type) == null ? void 0 : _a.spec) == null ? void 0 : _b.code) || !(node.isText || node.isTextblock || node.isInline)) {
15616
15583
  return;
@@ -15630,11 +15597,11 @@ function run2(config) {
15630
15597
  const start = resolvedFrom + match.index + 1;
15631
15598
  const end = start + match[0].length;
15632
15599
  const range = {
15633
- from: state3.tr.mapping.map(start),
15634
- to: state3.tr.mapping.map(end)
15600
+ from: state.tr.mapping.map(start),
15601
+ to: state.tr.mapping.map(end)
15635
15602
  };
15636
15603
  const handler = rule.handler({
15637
- state: state3,
15604
+ state,
15638
15605
  range,
15639
15606
  match,
15640
15607
  commands,
@@ -15671,15 +15638,15 @@ function pasteRulesPlugin(props) {
15671
15638
  dropEvent = null;
15672
15639
  }
15673
15640
  const processEvent = ({
15674
- state: state3,
15641
+ state,
15675
15642
  from: from2,
15676
15643
  to,
15677
15644
  rule,
15678
15645
  pasteEvt
15679
15646
  }) => {
15680
- const tr2 = state3.tr;
15647
+ const tr2 = state.tr;
15681
15648
  const chainableState = createChainableState({
15682
- state: state3,
15649
+ state,
15683
15650
  transaction: tr2
15684
15651
  });
15685
15652
  const handler = run2({
@@ -15754,7 +15721,7 @@ function pasteRulesPlugin(props) {
15754
15721
  }
15755
15722
  }
15756
15723
  },
15757
- appendTransaction: (transactions, oldState, state3) => {
15724
+ appendTransaction: (transactions, oldState, state) => {
15758
15725
  const transaction = transactions[0];
15759
15726
  const isPaste = transaction.getMeta("uiEvent") === "paste" && !isPastedFromProseMirror;
15760
15727
  const isDrop = transaction.getMeta("uiEvent") === "drop" && !isDroppedFromProseMirror;
@@ -15768,27 +15735,27 @@ function pasteRulesPlugin(props) {
15768
15735
  if (typeof text === "string") {
15769
15736
  text = text;
15770
15737
  } else {
15771
- text = getHTMLFromFragment(Fragment2.from(text), state3.schema);
15738
+ text = getHTMLFromFragment(Fragment2.from(text), state.schema);
15772
15739
  }
15773
15740
  const { from: from22 } = simulatedPasteMeta;
15774
15741
  const to2 = from22 + text.length;
15775
15742
  const pasteEvt = createClipboardPasteEvent(text);
15776
15743
  return processEvent({
15777
15744
  rule,
15778
- state: state3,
15745
+ state,
15779
15746
  from: from22,
15780
15747
  to: { b: to2 },
15781
15748
  pasteEvt
15782
15749
  });
15783
15750
  }
15784
- const from2 = oldState.doc.content.findDiffStart(state3.doc.content);
15785
- const to = oldState.doc.content.findDiffEnd(state3.doc.content);
15751
+ const from2 = oldState.doc.content.findDiffStart(state.doc.content);
15752
+ const to = oldState.doc.content.findDiffEnd(state.doc.content);
15786
15753
  if (!isNumber(from2) || !to || from2 === to.b) {
15787
15754
  return;
15788
15755
  }
15789
15756
  return processEvent({
15790
15757
  rule,
15791
- state: state3,
15758
+ state,
15792
15759
  from: from2,
15793
15760
  to,
15794
15761
  pasteEvt: pasteEvent
@@ -16163,8 +16130,8 @@ var ClipboardTextSerializer = Extension.create({
16163
16130
  props: {
16164
16131
  clipboardTextSerializer: () => {
16165
16132
  const { editor } = this;
16166
- const { state: state3, schema } = editor;
16167
- const { doc: doc3, selection } = state3;
16133
+ const { state, schema } = editor;
16134
+ const { doc: doc3, selection } = state;
16168
16135
  const { ranges } = selection;
16169
16136
  const from2 = Math.min(...ranges.map((range2) => range2.$from.pos));
16170
16137
  const to = Math.max(...ranges.map((range2) => range2.$to.pos));
@@ -16414,13 +16381,13 @@ var Keymap = Extension.create({
16414
16381
  return;
16415
16382
  }
16416
16383
  const tr2 = newState.tr;
16417
- const state3 = createChainableState({
16384
+ const state = createChainableState({
16418
16385
  state: newState,
16419
16386
  transaction: tr2
16420
16387
  });
16421
16388
  const { commands } = new CommandManager({
16422
16389
  editor: this.editor,
16423
- state: state3
16390
+ state
16424
16391
  });
16425
16392
  commands.clearNodes();
16426
16393
  if (!tr2.steps.length) {
@@ -16990,8 +16957,8 @@ var Editor = class extends EventEmitter {
16990
16957
  return new Proxy(
16991
16958
  {
16992
16959
  state: this.editorState,
16993
- updateState: (state3) => {
16994
- this.editorState = state3;
16960
+ updateState: (state) => {
16961
+ this.editorState = state;
16995
16962
  },
16996
16963
  dispatch: (tr2) => {
16997
16964
  this.dispatchTransaction(tr2);
@@ -17038,9 +17005,9 @@ var Editor = class extends EventEmitter {
17038
17005
  */
17039
17006
  registerPlugin(plugin, handlePlugins) {
17040
17007
  const plugins = isFunction(handlePlugins) ? handlePlugins(plugin, [...this.state.plugins]) : [...this.state.plugins, plugin];
17041
- const state3 = this.state.reconfigure({ plugins });
17042
- this.view.updateState(state3);
17043
- return state3;
17008
+ const state = this.state.reconfigure({ plugins });
17009
+ this.view.updateState(state);
17010
+ return state;
17044
17011
  }
17045
17012
  /**
17046
17013
  * Unregister a ProseMirror plugin.
@@ -17061,11 +17028,11 @@ var Editor = class extends EventEmitter {
17061
17028
  if (prevPlugins.length === plugins.length) {
17062
17029
  return void 0;
17063
17030
  }
17064
- const state3 = this.state.reconfigure({
17031
+ const state = this.state.reconfigure({
17065
17032
  plugins
17066
17033
  });
17067
- this.view.updateState(state3);
17068
- return state3;
17034
+ this.view.updateState(state);
17035
+ return state;
17069
17036
  }
17070
17037
  /**
17071
17038
  * Creates an extension manager.
@@ -17220,19 +17187,19 @@ var Editor = class extends EventEmitter {
17220
17187
  });
17221
17188
  return;
17222
17189
  }
17223
- const { state: state3, transactions } = this.state.applyTransaction(transaction);
17224
- const selectionHasChanged = !this.state.selection.eq(state3.selection);
17190
+ const { state, transactions } = this.state.applyTransaction(transaction);
17191
+ const selectionHasChanged = !this.state.selection.eq(state.selection);
17225
17192
  const rootTrWasApplied = transactions.includes(transaction);
17226
17193
  const prevState = this.state;
17227
17194
  this.emit("beforeTransaction", {
17228
17195
  editor: this,
17229
17196
  transaction,
17230
- nextState: state3
17197
+ nextState: state
17231
17198
  });
17232
17199
  if (!rootTrWasApplied) {
17233
17200
  return;
17234
17201
  }
17235
- this.view.updateState(state3);
17202
+ this.view.updateState(state);
17236
17203
  this.emit("transaction", {
17237
17204
  editor: this,
17238
17205
  transaction,
@@ -17263,7 +17230,7 @@ var Editor = class extends EventEmitter {
17263
17230
  transaction: mostRecentFocusTr
17264
17231
  });
17265
17232
  }
17266
- if (transaction.getMeta("preventUpdate") || !transactions.some((tr2) => tr2.docChanged) || prevState.doc.eq(state3.doc)) {
17233
+ if (transaction.getMeta("preventUpdate") || !transactions.some((tr2) => tr2.docChanged) || prevState.doc.eq(state.doc)) {
17267
17234
  return;
17268
17235
  }
17269
17236
  this.emit("update", {
@@ -17348,19 +17315,19 @@ var Editor = class extends EventEmitter {
17348
17315
  function markInputRule(config) {
17349
17316
  return new InputRule({
17350
17317
  find: config.find,
17351
- handler: ({ state: state3, range, match }) => {
17318
+ handler: ({ state, range, match }) => {
17352
17319
  const attributes = callOrReturn(config.getAttributes, void 0, match);
17353
17320
  if (attributes === false || attributes === null) {
17354
17321
  return null;
17355
17322
  }
17356
- const { tr: tr2 } = state3;
17323
+ const { tr: tr2 } = state;
17357
17324
  const captureGroup = match[match.length - 1];
17358
17325
  const fullMatch = match[0];
17359
17326
  if (captureGroup) {
17360
17327
  const startSpaces = fullMatch.search(/\S/);
17361
17328
  const textStart = range.from + fullMatch.indexOf(captureGroup);
17362
17329
  const textEnd = textStart + captureGroup.length;
17363
- const excludedMarks = getMarksBetween(range.from, range.to, state3.doc).filter((item) => {
17330
+ const excludedMarks = getMarksBetween(range.from, range.to, state.doc).filter((item) => {
17364
17331
  const excluded = item.mark.type.excluded;
17365
17332
  return excluded.find((type) => type === config.type && type !== item.mark.type);
17366
17333
  }).filter((item) => item.to > textStart);
@@ -17384,9 +17351,9 @@ function markInputRule(config) {
17384
17351
  function nodeInputRule(config) {
17385
17352
  return new InputRule({
17386
17353
  find: config.find,
17387
- handler: ({ state: state3, range, match }) => {
17354
+ handler: ({ state, range, match }) => {
17388
17355
  const attributes = callOrReturn(config.getAttributes, void 0, match) || {};
17389
- const { tr: tr2 } = state3;
17356
+ const { tr: tr2 } = state;
17390
17357
  const start = range.from;
17391
17358
  let end = range.to;
17392
17359
  const newNode = config.type.create(attributes);
@@ -17413,13 +17380,13 @@ function nodeInputRule(config) {
17413
17380
  function textblockTypeInputRule(config) {
17414
17381
  return new InputRule({
17415
17382
  find: config.find,
17416
- handler: ({ state: state3, range, match }) => {
17417
- const $start = state3.doc.resolve(range.from);
17383
+ handler: ({ state, range, match }) => {
17384
+ const $start = state.doc.resolve(range.from);
17418
17385
  const attributes = callOrReturn(config.getAttributes, void 0, match) || {};
17419
17386
  if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), config.type)) {
17420
17387
  return null;
17421
17388
  }
17422
- state3.tr.delete(range.from, range.to).setBlockType(range.from, range.from, config.type, attributes);
17389
+ state.tr.delete(range.from, range.to).setBlockType(range.from, range.from, config.type, attributes);
17423
17390
  },
17424
17391
  undoable: config.undoable
17425
17392
  });
@@ -17427,9 +17394,9 @@ function textblockTypeInputRule(config) {
17427
17394
  function wrappingInputRule(config) {
17428
17395
  return new InputRule({
17429
17396
  find: config.find,
17430
- handler: ({ state: state3, range, match, chain }) => {
17397
+ handler: ({ state, range, match, chain }) => {
17431
17398
  const attributes = callOrReturn(config.getAttributes, void 0, match) || {};
17432
- const tr2 = state3.tr.delete(range.from, range.to);
17399
+ const tr2 = state.tr.delete(range.from, range.to);
17433
17400
  const $start = tr2.doc.resolve(range.from);
17434
17401
  const blockRange = $start.blockRange();
17435
17402
  const wrapping = blockRange && findWrapping(blockRange, config.type, attributes);
@@ -17438,7 +17405,7 @@ function wrappingInputRule(config) {
17438
17405
  }
17439
17406
  tr2.wrap(blockRange, wrapping);
17440
17407
  if (config.keepMarks && config.editor) {
17441
- const { selection, storedMarks } = state3;
17408
+ const { selection, storedMarks } = state;
17442
17409
  const { splittableMarks } = config.editor.extensionManager;
17443
17410
  const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
17444
17411
  if (marks) {
@@ -17458,8 +17425,8 @@ function wrappingInputRule(config) {
17458
17425
  undoable: config.undoable
17459
17426
  });
17460
17427
  }
17461
- function canInsertNode(state3, nodeType) {
17462
- const { selection } = state3;
17428
+ function canInsertNode(state, nodeType) {
17429
+ const { selection } = state;
17463
17430
  const { $from } = selection;
17464
17431
  if (selection instanceof NodeSelection) {
17465
17432
  const index = $from.index();
@@ -17961,8 +17928,8 @@ ${indentedChild}`;
17961
17928
  return output;
17962
17929
  }
17963
17930
  function updateMarkViewAttributes(checkMark, editor, attrs = {}) {
17964
- const { state: state3 } = editor;
17965
- const { doc: doc3, tr: tr2 } = state3;
17931
+ const { state } = editor;
17932
+ const { doc: doc3, tr: tr2 } = state;
17966
17933
  const thisMark = checkMark;
17967
17934
  doc3.descendants((node, pos) => {
17968
17935
  const from2 = tr2.mapping.map(pos);
@@ -18020,12 +17987,12 @@ var Node3 = class _Node extends Extendable {
18020
17987
  function markPasteRule(config) {
18021
17988
  return new PasteRule({
18022
17989
  find: config.find,
18023
- handler: ({ state: state3, range, match, pasteEvent }) => {
17990
+ handler: ({ state, range, match, pasteEvent }) => {
18024
17991
  const attributes = callOrReturn(config.getAttributes, void 0, match, pasteEvent);
18025
17992
  if (attributes === false || attributes === null) {
18026
17993
  return null;
18027
17994
  }
18028
- const { tr: tr2 } = state3;
17995
+ const { tr: tr2 } = state;
18029
17996
  const captureGroup = match[match.length - 1];
18030
17997
  const fullMatch = match[0];
18031
17998
  let markEnd = range.to;
@@ -18033,7 +18000,7 @@ function markPasteRule(config) {
18033
18000
  const startSpaces = fullMatch.search(/\S/);
18034
18001
  const textStart = range.from + fullMatch.indexOf(captureGroup);
18035
18002
  const textEnd = textStart + captureGroup.length;
18036
- const excludedMarks = getMarksBetween(range.from, range.to, state3.doc).filter((item) => {
18003
+ const excludedMarks = getMarksBetween(range.from, range.to, state.doc).filter((item) => {
18037
18004
  const excluded = item.mark.type.excluded;
18038
18005
  return excluded.find((type) => type === config.type && type !== item.mark.type);
18039
18006
  }).filter((item) => item.to > textStart);
@@ -18133,8 +18100,8 @@ function Suggestion({
18133
18100
  return getAnchorClientRect;
18134
18101
  }
18135
18102
  return () => {
18136
- const state3 = pluginKey.getState(editor.state);
18137
- const decorationId = state3 == null ? void 0 : state3.decorationId;
18103
+ const state = pluginKey.getState(editor.state);
18104
+ const decorationId = state == null ? void 0 : state.decorationId;
18138
18105
  const currentDecorationNode = view.dom.querySelector(`[data-decoration-id="${decorationId}"]`);
18139
18106
  return (currentDecorationNode == null ? void 0 : currentDecorationNode.getBoundingClientRect()) || null;
18140
18107
  };
@@ -18142,17 +18109,17 @@ function Suggestion({
18142
18109
  function dispatchExit(view, pluginKeyRef) {
18143
18110
  var _a;
18144
18111
  try {
18145
- const state3 = pluginKey.getState(view.state);
18146
- const decorationNode = (state3 == null ? void 0 : state3.decorationId) ? view.dom.querySelector(`[data-decoration-id="${state3.decorationId}"]`) : null;
18112
+ const state = pluginKey.getState(view.state);
18113
+ const decorationNode = (state == null ? void 0 : state.decorationId) ? view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`) : null;
18147
18114
  const exitProps = {
18148
18115
  // @ts-ignore editor is available in closure
18149
18116
  editor,
18150
- range: (state3 == null ? void 0 : state3.range) || { from: 0, to: 0 },
18151
- query: (state3 == null ? void 0 : state3.query) || null,
18152
- text: (state3 == null ? void 0 : state3.text) || null,
18117
+ range: (state == null ? void 0 : state.range) || { from: 0, to: 0 },
18118
+ query: (state == null ? void 0 : state.query) || null,
18119
+ text: (state == null ? void 0 : state.text) || null,
18153
18120
  items: [],
18154
18121
  command: (commandProps) => {
18155
- return command2({ editor, range: (state3 == null ? void 0 : state3.range) || { from: 0, to: 0 }, props: commandProps });
18122
+ return command2({ editor, range: (state == null ? void 0 : state.range) || { from: 0, to: 0 }, props: commandProps });
18156
18123
  },
18157
18124
  decorationNode,
18158
18125
  clientRect: clientRectFor(view, decorationNode)
@@ -18181,18 +18148,18 @@ function Suggestion({
18181
18148
  if (!handleStart && !handleChange && !handleExit) {
18182
18149
  return;
18183
18150
  }
18184
- const state3 = handleExit && !handleStart ? prev : next;
18185
- const decorationNode = view.dom.querySelector(`[data-decoration-id="${state3.decorationId}"]`);
18151
+ const state = handleExit && !handleStart ? prev : next;
18152
+ const decorationNode = view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`);
18186
18153
  props = {
18187
18154
  editor,
18188
- range: state3.range,
18189
- query: state3.query,
18190
- text: state3.text,
18155
+ range: state.range,
18156
+ query: state.query,
18157
+ text: state.text,
18191
18158
  items: [],
18192
18159
  command: (commandProps) => {
18193
18160
  return command2({
18194
18161
  editor,
18195
- range: state3.range,
18162
+ range: state.range,
18196
18163
  props: commandProps
18197
18164
  });
18198
18165
  },
@@ -18208,7 +18175,7 @@ function Suggestion({
18208
18175
  if (handleChange || handleStart) {
18209
18176
  props.items = await items({
18210
18177
  editor,
18211
- query: state3.query
18178
+ query: state.query
18212
18179
  });
18213
18180
  }
18214
18181
  if (handleExit) {
@@ -18233,7 +18200,7 @@ function Suggestion({
18233
18200
  state: {
18234
18201
  // Initialize the plugin's internal state.
18235
18202
  init() {
18236
- const state3 = {
18203
+ const state = {
18237
18204
  active: false,
18238
18205
  range: {
18239
18206
  from: 0,
@@ -18243,10 +18210,10 @@ function Suggestion({
18243
18210
  text: null,
18244
18211
  composing: false
18245
18212
  };
18246
- return state3;
18213
+ return state;
18247
18214
  },
18248
18215
  // Apply changes to the plugin state from a view transaction.
18249
- apply(transaction, prev, _oldState, state3) {
18216
+ apply(transaction, prev, _oldState, state) {
18250
18217
  const { isEditable } = editor;
18251
18218
  const { composing } = editor.view;
18252
18219
  const { selection } = transaction;
@@ -18277,7 +18244,7 @@ function Suggestion({
18277
18244
  const decorationId = `id_${Math.floor(Math.random() * 4294967295)}`;
18278
18245
  if (match && allow({
18279
18246
  editor,
18280
- state: state3,
18247
+ state,
18281
18248
  range: match.range,
18282
18249
  isActive: prev.active
18283
18250
  }) && (!shouldShow || shouldShow({
@@ -18316,21 +18283,21 @@ function Suggestion({
18316
18283
  return false;
18317
18284
  }
18318
18285
  if (event.key === "Escape" || event.key === "Esc") {
18319
- const state3 = plugin.getState(view.state);
18286
+ const state = plugin.getState(view.state);
18320
18287
  const cachedNode = (_a = props == null ? void 0 : props.decorationNode) != null ? _a : null;
18321
- const decorationNode = cachedNode != null ? cachedNode : (state3 == null ? void 0 : state3.decorationId) ? view.dom.querySelector(`[data-decoration-id="${state3.decorationId}"]`) : null;
18322
- const handledByKeyDown = ((_b = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _b.call(renderer, { view, event, range: state3.range })) || false;
18288
+ const decorationNode = cachedNode != null ? cachedNode : (state == null ? void 0 : state.decorationId) ? view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`) : null;
18289
+ const handledByKeyDown = ((_b = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _b.call(renderer, { view, event, range: state.range })) || false;
18323
18290
  if (handledByKeyDown) {
18324
18291
  return true;
18325
18292
  }
18326
18293
  const exitProps = {
18327
18294
  editor,
18328
- range: state3.range,
18329
- query: state3.query,
18330
- text: state3.text,
18295
+ range: state.range,
18296
+ query: state.query,
18297
+ text: state.text,
18331
18298
  items: [],
18332
18299
  command: (commandProps) => {
18333
- return command2({ editor, range: state3.range, props: commandProps });
18300
+ return command2({ editor, range: state.range, props: commandProps });
18334
18301
  },
18335
18302
  decorationNode,
18336
18303
  // If we have a cached decoration node, use it for the clientRect
@@ -18348,8 +18315,8 @@ function Suggestion({
18348
18315
  return handled;
18349
18316
  },
18350
18317
  // Setup decorator on the currently active suggestion.
18351
- decorations(state3) {
18352
- const { active, range, decorationId, query } = plugin.getState(state3);
18318
+ decorations(state) {
18319
+ const { active, range, decorationId, query } = plugin.getState(state);
18353
18320
  if (!active) {
18354
18321
  return null;
18355
18322
  }
@@ -18358,7 +18325,7 @@ function Suggestion({
18358
18325
  if (isEmpty) {
18359
18326
  classNames.push(decorationEmptyClass);
18360
18327
  }
18361
- return DecorationSet.create(state3.doc, [
18328
+ return DecorationSet.create(state.doc, [
18362
18329
  Decoration.inline(range.from, range.to, {
18363
18330
  nodeName: decorationTag,
18364
18331
  class: classNames.join(" "),
@@ -18407,9 +18374,9 @@ function getSuggestionOptions({
18407
18374
  ]).run();
18408
18375
  (_c = (_b = editor.view.dom.ownerDocument.defaultView) == null ? void 0 : _b.getSelection()) == null ? void 0 : _c.collapseToEnd();
18409
18376
  },
18410
- allow: ({ state: state3, range }) => {
18411
- const $from = state3.doc.resolve(range.from);
18412
- const type = state3.schema.nodes[extensionName];
18377
+ allow: ({ state, range }) => {
18378
+ const $from = state.doc.resolve(range.from);
18379
+ const type = state.schema.nodes[extensionName];
18413
18380
  const allow = !!$from.parent.type.contentMatch.matchType(type);
18414
18381
  return allow;
18415
18382
  },
@@ -18578,16 +18545,16 @@ var Mention = Node3.create({
18578
18545
  },
18579
18546
  addKeyboardShortcuts() {
18580
18547
  return {
18581
- Backspace: () => this.editor.commands.command(({ tr: tr2, state: state3 }) => {
18548
+ Backspace: () => this.editor.commands.command(({ tr: tr2, state }) => {
18582
18549
  let isMention = false;
18583
- const { selection } = state3;
18550
+ const { selection } = state;
18584
18551
  const { empty: empty2, anchor } = selection;
18585
18552
  if (!empty2) {
18586
18553
  return false;
18587
18554
  }
18588
18555
  let mentionNode = new Node2();
18589
18556
  let mentionPos = 0;
18590
- state3.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
18557
+ state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
18591
18558
  if (node.type.name === this.name) {
18592
18559
  isMention = true;
18593
18560
  mentionNode = node;
@@ -18829,142 +18796,6 @@ var TopicAssetMention = index_default.extend({
18829
18796
  }
18830
18797
  });
18831
18798
 
18832
- // src/chat/runtime/composer-channels.ts
18833
- import { normalizeTopicAssetRefs as normalizeTopicAssetRefs2 } from "@blade-hq/agent-client";
18834
- import { useSyncExternalStore as useSyncExternalStore2 } from "react";
18835
- function buildSignalId() {
18836
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
18837
- return crypto.randomUUID();
18838
- }
18839
- return `bridge-${Date.now()}-${Math.random().toString(36).slice(2)}`;
18840
- }
18841
- function withoutKey(record, key) {
18842
- if (!(key in record)) return record;
18843
- const next = { ...record };
18844
- delete next[key];
18845
- return next;
18846
- }
18847
- var state2 = {
18848
- topicAssetReferences: {},
18849
- pendingContexts: {},
18850
- draftAppends: {},
18851
- sendRequests: {},
18852
- modelDrafts: {},
18853
- rewindDrafts: {}
18854
- };
18855
- var listeners2 = /* @__PURE__ */ new Set();
18856
- function setState(update) {
18857
- const next = update(state2);
18858
- if (next === state2) return;
18859
- state2 = next;
18860
- for (const listener of [...listeners2]) listener();
18861
- }
18862
- function consume(key, sessionId) {
18863
- const signals = state2[key][sessionId] ?? [];
18864
- if (signals.length === 0) return [];
18865
- setState((current) => ({ ...current, [key]: withoutKey(current[key], sessionId) }));
18866
- return signals;
18867
- }
18868
- var composerChannels = {
18869
- getState: () => state2,
18870
- addTopicAssetReference(sessionId, ref) {
18871
- setState((current) => ({ ...current, topicAssetReferences: { ...current.topicAssetReferences, [sessionId]: normalizeTopicAssetRefs2([...current.topicAssetReferences[sessionId] ?? [], ref]) } }));
18872
- },
18873
- consumeTopicAssetReferences: (sessionId) => consume("topicAssetReferences", sessionId),
18874
- subscribe(listener) {
18875
- listeners2.add(listener);
18876
- return () => {
18877
- listeners2.delete(listener);
18878
- };
18879
- },
18880
- addPendingContext(sessionId, context) {
18881
- setState((current) => ({
18882
- ...current,
18883
- pendingContexts: {
18884
- ...current.pendingContexts,
18885
- [sessionId]: [
18886
- ...current.pendingContexts[sessionId] ?? [],
18887
- { id: buildSignalId(), label: context.label, content: context.content, imageUrl: context.imageUrl }
18888
- ]
18889
- }
18890
- }));
18891
- },
18892
- removePendingContext(sessionId, contextId) {
18893
- setState((current) => {
18894
- const contexts = current.pendingContexts[sessionId];
18895
- if (!contexts?.length) return current;
18896
- const next = contexts.filter((context) => context.id !== contextId);
18897
- if (next.length === contexts.length) return current;
18898
- return {
18899
- ...current,
18900
- pendingContexts: next.length > 0 ? { ...current.pendingContexts, [sessionId]: next } : withoutKey(current.pendingContexts, sessionId)
18901
- };
18902
- });
18903
- },
18904
- consumePendingContexts: (sessionId) => consume("pendingContexts", sessionId),
18905
- clearPendingContexts(sessionId) {
18906
- setState((current) => ({ ...current, pendingContexts: withoutKey(current.pendingContexts, sessionId) }));
18907
- },
18908
- addDraftAppend(sessionId, text, separate) {
18909
- setState((current) => ({
18910
- ...current,
18911
- draftAppends: {
18912
- ...current.draftAppends,
18913
- [sessionId]: [...current.draftAppends[sessionId] ?? [], { id: buildSignalId(), text, separate }]
18914
- }
18915
- }));
18916
- },
18917
- consumeDraftAppends: (sessionId) => consume("draftAppends", sessionId),
18918
- clearDraftAppends(sessionId) {
18919
- setState((current) => ({ ...current, draftAppends: withoutKey(current.draftAppends, sessionId) }));
18920
- },
18921
- addSendRequest(sessionId) {
18922
- setState((current) => ({
18923
- ...current,
18924
- sendRequests: {
18925
- ...current.sendRequests,
18926
- [sessionId]: [...current.sendRequests[sessionId] ?? [], { id: buildSignalId() }]
18927
- }
18928
- }));
18929
- },
18930
- consumeSendRequests: (sessionId) => consume("sendRequests", sessionId),
18931
- clearSendRequests(sessionId) {
18932
- setState((current) => ({ ...current, sendRequests: withoutKey(current.sendRequests, sessionId) }));
18933
- },
18934
- setModelDraft(sessionId, model) {
18935
- setState(
18936
- (current) => current.modelDrafts[sessionId] === model ? current : { ...current, modelDrafts: { ...current.modelDrafts, [sessionId]: model } }
18937
- );
18938
- },
18939
- clearModelDraft(sessionId) {
18940
- setState((current) => ({ ...current, modelDrafts: withoutKey(current.modelDrafts, sessionId) }));
18941
- },
18942
- setRewindDraft(sessionId, text) {
18943
- setState(
18944
- (current) => text === null ? { ...current, rewindDrafts: withoutKey(current.rewindDrafts, sessionId) } : { ...current, rewindDrafts: { ...current.rewindDrafts, [sessionId]: text } }
18945
- );
18946
- },
18947
- clearSession(sessionId) {
18948
- setState((current) => ({
18949
- ...current,
18950
- topicAssetReferences: withoutKey(current.topicAssetReferences, sessionId),
18951
- pendingContexts: withoutKey(current.pendingContexts, sessionId),
18952
- draftAppends: withoutKey(current.draftAppends, sessionId),
18953
- sendRequests: withoutKey(current.sendRequests, sessionId)
18954
- }));
18955
- },
18956
- reset() {
18957
- setState(() => ({ topicAssetReferences: {}, pendingContexts: {}, draftAppends: {}, sendRequests: {}, modelDrafts: {}, rewindDrafts: {} }));
18958
- }
18959
- };
18960
- function useComposerChannels(selector) {
18961
- return useSyncExternalStore2(
18962
- composerChannels.subscribe,
18963
- () => selector(state2),
18964
- () => selector(state2)
18965
- );
18966
- }
18967
-
18968
18799
  // src/rich-input/lib/topic-asset-suggestions.ts
18969
18800
  async function getTopicAssetSuggestionItems(client, topicId, query) {
18970
18801
  if (!topicId) return [];
@@ -19087,16 +18918,16 @@ import { useDebugValue as useDebugValue2, useEffect as useEffect2, useRef as use
19087
18918
  var { getOwnPropertyNames, getOwnPropertySymbols } = Object;
19088
18919
  var { hasOwnProperty } = Object.prototype;
19089
18920
  function combineComparators(comparatorA, comparatorB) {
19090
- return function isEqual(a, b, state3) {
19091
- return comparatorA(a, b, state3) && comparatorB(a, b, state3);
18921
+ return function isEqual(a, b, state) {
18922
+ return comparatorA(a, b, state) && comparatorB(a, b, state);
19092
18923
  };
19093
18924
  }
19094
18925
  function createIsCircular(areItemsEqual) {
19095
- return function isCircular(a, b, state3) {
18926
+ return function isCircular(a, b, state) {
19096
18927
  if (!a || !b || typeof a !== "object" || typeof b !== "object") {
19097
- return areItemsEqual(a, b, state3);
18928
+ return areItemsEqual(a, b, state);
19098
18929
  }
19099
- const { cache } = state3;
18930
+ const { cache } = state;
19100
18931
  const cachedA = cache.get(a);
19101
18932
  const cachedB = cache.get(b);
19102
18933
  if (cachedA && cachedB) {
@@ -19104,7 +18935,7 @@ function createIsCircular(areItemsEqual) {
19104
18935
  }
19105
18936
  cache.set(a, b);
19106
18937
  cache.set(b, a);
19107
- const result = areItemsEqual(a, b, state3);
18938
+ const result = areItemsEqual(a, b, state);
19108
18939
  cache.delete(a);
19109
18940
  cache.delete(b);
19110
18941
  return result;
@@ -19130,13 +18961,13 @@ var { getOwnPropertyDescriptor, keys: keys2 } = Object;
19130
18961
  function areArrayBuffersEqual(a, b) {
19131
18962
  return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a), new Uint8Array(b));
19132
18963
  }
19133
- function areArraysEqual(a, b, state3) {
18964
+ function areArraysEqual(a, b, state) {
19134
18965
  let index = a.length;
19135
18966
  if (b.length !== index) {
19136
18967
  return false;
19137
18968
  }
19138
18969
  while (index-- > 0) {
19139
- if (!state3.equals(a[index], b[index], index, index, a, b, state3)) {
18970
+ if (!state.equals(a[index], b[index], index, index, a, b, state)) {
19140
18971
  return false;
19141
18972
  }
19142
18973
  }
@@ -19154,7 +18985,7 @@ function areErrorsEqual(a, b) {
19154
18985
  function areFunctionsEqual(a, b) {
19155
18986
  return a === b;
19156
18987
  }
19157
- function areMapsEqual(a, b, state3) {
18988
+ function areMapsEqual(a, b, state) {
19158
18989
  const size = a.size;
19159
18990
  if (size !== b.size) {
19160
18991
  return false;
@@ -19184,7 +19015,7 @@ function areMapsEqual(a, b, state3) {
19184
19015
  }
19185
19016
  const aEntry = aResult.value;
19186
19017
  const bEntry = bResult.value;
19187
- if (state3.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state3) && state3.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state3)) {
19018
+ if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {
19188
19019
  hasMatch = matchedIndices[matchIndex] = true;
19189
19020
  break;
19190
19021
  }
@@ -19198,20 +19029,20 @@ function areMapsEqual(a, b, state3) {
19198
19029
  return true;
19199
19030
  }
19200
19031
  var areNumbersEqual = sameValueZeroEqual;
19201
- function areObjectsEqual(a, b, state3) {
19032
+ function areObjectsEqual(a, b, state) {
19202
19033
  const properties = keys2(a);
19203
19034
  let index = properties.length;
19204
19035
  if (keys2(b).length !== index) {
19205
19036
  return false;
19206
19037
  }
19207
19038
  while (index-- > 0) {
19208
- if (!isPropertyEqual(a, b, state3, properties[index])) {
19039
+ if (!isPropertyEqual(a, b, state, properties[index])) {
19209
19040
  return false;
19210
19041
  }
19211
19042
  }
19212
19043
  return true;
19213
19044
  }
19214
- function areObjectsEqualStrict(a, b, state3) {
19045
+ function areObjectsEqualStrict(a, b, state) {
19215
19046
  const properties = getStrictProperties(a);
19216
19047
  let index = properties.length;
19217
19048
  if (getStrictProperties(b).length !== index) {
@@ -19222,7 +19053,7 @@ function areObjectsEqualStrict(a, b, state3) {
19222
19053
  let descriptorB;
19223
19054
  while (index-- > 0) {
19224
19055
  property = properties[index];
19225
- if (!isPropertyEqual(a, b, state3, property)) {
19056
+ if (!isPropertyEqual(a, b, state, property)) {
19226
19057
  return false;
19227
19058
  }
19228
19059
  descriptorA = getOwnPropertyDescriptor(a, property);
@@ -19239,7 +19070,7 @@ function arePrimitiveWrappersEqual(a, b) {
19239
19070
  function areRegExpsEqual(a, b) {
19240
19071
  return a.source === b.source && a.flags === b.flags;
19241
19072
  }
19242
- function areSetsEqual(a, b, state3) {
19073
+ function areSetsEqual(a, b, state) {
19243
19074
  const size = a.size;
19244
19075
  if (size !== b.size) {
19245
19076
  return false;
@@ -19262,7 +19093,7 @@ function areSetsEqual(a, b, state3) {
19262
19093
  if (bResult.done) {
19263
19094
  break;
19264
19095
  }
19265
- if (!matchedIndices[matchIndex] && state3.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state3)) {
19096
+ if (!matchedIndices[matchIndex] && state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {
19266
19097
  hasMatch = matchedIndices[matchIndex] = true;
19267
19098
  break;
19268
19099
  }
@@ -19289,11 +19120,11 @@ function areTypedArraysEqual(a, b) {
19289
19120
  function areUrlsEqual(a, b) {
19290
19121
  return a.hostname === b.hostname && a.pathname === b.pathname && a.protocol === b.protocol && a.port === b.port && a.hash === b.hash && a.username === b.username && a.password === b.password;
19291
19122
  }
19292
- function isPropertyEqual(a, b, state3, property) {
19123
+ function isPropertyEqual(a, b, state, property) {
19293
19124
  if ((property === REACT_OWNER || property === PREACT_OWNER || property === PREACT_VNODE) && (a.$$typeof || b.$$typeof)) {
19294
19125
  return true;
19295
19126
  }
19296
- return hasOwn(b, property) && state3.equals(a[property], b[property], property, property, a, b, state3);
19127
+ return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
19297
19128
  }
19298
19129
  var ARRAY_BUFFER_TAG = "[object ArrayBuffer]";
19299
19130
  var ARGUMENTS_TAG = "[object Arguments]";
@@ -19324,7 +19155,7 @@ var TYPED_ARRAY_TAGS = {
19324
19155
  var URL_TAG = "[object URL]";
19325
19156
  var toString = Object.prototype.toString;
19326
19157
  function createEqualityComparator({ areArrayBuffersEqual: areArrayBuffersEqual2, areArraysEqual: areArraysEqual2, areDataViewsEqual: areDataViewsEqual2, areDatesEqual: areDatesEqual2, areErrorsEqual: areErrorsEqual2, areFunctionsEqual: areFunctionsEqual2, areMapsEqual: areMapsEqual2, areNumbersEqual: areNumbersEqual2, areObjectsEqual: areObjectsEqual2, arePrimitiveWrappersEqual: arePrimitiveWrappersEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, areTypedArraysEqual: areTypedArraysEqual2, areUrlsEqual: areUrlsEqual2, unknownTagComparators }) {
19327
- return function comparator(a, b, state3) {
19158
+ return function comparator(a, b, state) {
19328
19159
  if (a === b) {
19329
19160
  return true;
19330
19161
  }
@@ -19337,10 +19168,10 @@ function createEqualityComparator({ areArrayBuffersEqual: areArrayBuffersEqual2,
19337
19168
  }
19338
19169
  if (type !== "object") {
19339
19170
  if (type === "number") {
19340
- return areNumbersEqual2(a, b, state3);
19171
+ return areNumbersEqual2(a, b, state);
19341
19172
  }
19342
19173
  if (type === "function") {
19343
- return areFunctionsEqual2(a, b, state3);
19174
+ return areFunctionsEqual2(a, b, state);
19344
19175
  }
19345
19176
  return false;
19346
19177
  }
@@ -19349,59 +19180,59 @@ function createEqualityComparator({ areArrayBuffersEqual: areArrayBuffersEqual2,
19349
19180
  return false;
19350
19181
  }
19351
19182
  if (constructor === Object) {
19352
- return areObjectsEqual2(a, b, state3);
19183
+ return areObjectsEqual2(a, b, state);
19353
19184
  }
19354
19185
  if (Array.isArray(a)) {
19355
- return areArraysEqual2(a, b, state3);
19186
+ return areArraysEqual2(a, b, state);
19356
19187
  }
19357
19188
  if (constructor === Date) {
19358
- return areDatesEqual2(a, b, state3);
19189
+ return areDatesEqual2(a, b, state);
19359
19190
  }
19360
19191
  if (constructor === RegExp) {
19361
- return areRegExpsEqual2(a, b, state3);
19192
+ return areRegExpsEqual2(a, b, state);
19362
19193
  }
19363
19194
  if (constructor === Map) {
19364
- return areMapsEqual2(a, b, state3);
19195
+ return areMapsEqual2(a, b, state);
19365
19196
  }
19366
19197
  if (constructor === Set) {
19367
- return areSetsEqual2(a, b, state3);
19198
+ return areSetsEqual2(a, b, state);
19368
19199
  }
19369
19200
  const tag = toString.call(a);
19370
19201
  if (tag === DATE_TAG) {
19371
- return areDatesEqual2(a, b, state3);
19202
+ return areDatesEqual2(a, b, state);
19372
19203
  }
19373
19204
  if (tag === REG_EXP_TAG) {
19374
- return areRegExpsEqual2(a, b, state3);
19205
+ return areRegExpsEqual2(a, b, state);
19375
19206
  }
19376
19207
  if (tag === MAP_TAG) {
19377
- return areMapsEqual2(a, b, state3);
19208
+ return areMapsEqual2(a, b, state);
19378
19209
  }
19379
19210
  if (tag === SET_TAG) {
19380
- return areSetsEqual2(a, b, state3);
19211
+ return areSetsEqual2(a, b, state);
19381
19212
  }
19382
19213
  if (tag === OBJECT_TAG) {
19383
- return typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a, b, state3);
19214
+ return typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a, b, state);
19384
19215
  }
19385
19216
  if (tag === URL_TAG) {
19386
- return areUrlsEqual2(a, b, state3);
19217
+ return areUrlsEqual2(a, b, state);
19387
19218
  }
19388
19219
  if (tag === ERROR_TAG) {
19389
- return areErrorsEqual2(a, b, state3);
19220
+ return areErrorsEqual2(a, b, state);
19390
19221
  }
19391
19222
  if (tag === ARGUMENTS_TAG) {
19392
- return areObjectsEqual2(a, b, state3);
19223
+ return areObjectsEqual2(a, b, state);
19393
19224
  }
19394
19225
  if (TYPED_ARRAY_TAGS[tag]) {
19395
- return areTypedArraysEqual2(a, b, state3);
19226
+ return areTypedArraysEqual2(a, b, state);
19396
19227
  }
19397
19228
  if (tag === ARRAY_BUFFER_TAG) {
19398
- return areArrayBuffersEqual2(a, b, state3);
19229
+ return areArrayBuffersEqual2(a, b, state);
19399
19230
  }
19400
19231
  if (tag === DATA_VIEW_TAG) {
19401
- return areDataViewsEqual2(a, b, state3);
19232
+ return areDataViewsEqual2(a, b, state);
19402
19233
  }
19403
19234
  if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {
19404
- return arePrimitiveWrappersEqual2(a, b, state3);
19235
+ return arePrimitiveWrappersEqual2(a, b, state);
19405
19236
  }
19406
19237
  if (unknownTagComparators) {
19407
19238
  let unknownTagComparator = unknownTagComparators[tag];
@@ -19412,7 +19243,7 @@ function createEqualityComparator({ areArrayBuffersEqual: areArrayBuffersEqual2,
19412
19243
  }
19413
19244
  }
19414
19245
  if (unknownTagComparator) {
19415
- return unknownTagComparator(a, b, state3);
19246
+ return unknownTagComparator(a, b, state);
19416
19247
  }
19417
19248
  }
19418
19249
  return false;
@@ -19454,8 +19285,8 @@ function createEqualityComparatorConfig({ circular, createCustomConfig, strict }
19454
19285
  return config;
19455
19286
  }
19456
19287
  function createInternalEqualityComparator(compare) {
19457
- return function(a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state3) {
19458
- return compare(a, b, state3);
19288
+ return function(a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {
19289
+ return compare(a, b, state);
19459
19290
  };
19460
19291
  }
19461
19292
  function createIsEqual({ circular, comparator, createState, equals, strict }) {
@@ -19480,14 +19311,14 @@ function createIsEqual({ circular, comparator, createState, equals, strict }) {
19480
19311
  });
19481
19312
  };
19482
19313
  }
19483
- const state3 = {
19314
+ const state = {
19484
19315
  cache: void 0,
19485
19316
  equals,
19486
19317
  meta: void 0,
19487
19318
  strict
19488
19319
  };
19489
19320
  return function isEqual(a, b) {
19490
- return comparator(a, b, state3);
19321
+ return comparator(a, b, state);
19491
19322
  };
19492
19323
  }
19493
19324
  var deepEqual = createCustomEqual();
@@ -20461,8 +20292,8 @@ var CodeBlock = Node3.create({
20461
20292
  return false;
20462
20293
  }
20463
20294
  const tabSize = (_a = this.options.tabSize) != null ? _a : DEFAULT_TAB_SIZE;
20464
- const { state: state3 } = editor;
20465
- const { selection } = state3;
20295
+ const { state } = editor;
20296
+ const { selection } = state;
20466
20297
  const { $from, empty: empty2 } = selection;
20467
20298
  if ($from.parent.type !== this.type) {
20468
20299
  return false;
@@ -20473,10 +20304,10 @@ var CodeBlock = Node3.create({
20473
20304
  }
20474
20305
  return editor.commands.command(({ tr: tr2 }) => {
20475
20306
  const { from: from2, to } = selection;
20476
- const text = state3.doc.textBetween(from2, to, "\n", "\n");
20307
+ const text = state.doc.textBetween(from2, to, "\n", "\n");
20477
20308
  const lines = text.split("\n");
20478
20309
  const indentedText = lines.map((line) => indent + line).join("\n");
20479
- tr2.replaceWith(from2, to, state3.schema.text(indentedText));
20310
+ tr2.replaceWith(from2, to, state.schema.text(indentedText));
20480
20311
  return true;
20481
20312
  });
20482
20313
  },
@@ -20487,8 +20318,8 @@ var CodeBlock = Node3.create({
20487
20318
  return false;
20488
20319
  }
20489
20320
  const tabSize = (_a = this.options.tabSize) != null ? _a : DEFAULT_TAB_SIZE;
20490
- const { state: state3 } = editor;
20491
- const { selection } = state3;
20321
+ const { state } = editor;
20322
+ const { selection } = state;
20492
20323
  const { $from, empty: empty2 } = selection;
20493
20324
  if ($from.parent.type !== this.type) {
20494
20325
  return false;
@@ -20499,7 +20330,7 @@ var CodeBlock = Node3.create({
20499
20330
  const { pos } = $from;
20500
20331
  const codeBlockStart = $from.start();
20501
20332
  const codeBlockEnd = $from.end();
20502
- const allText = state3.doc.textBetween(codeBlockStart, codeBlockEnd, "\n", "\n");
20333
+ const allText = state.doc.textBetween(codeBlockStart, codeBlockEnd, "\n", "\n");
20503
20334
  const lines = allText.split("\n");
20504
20335
  let currentLineIndex = 0;
20505
20336
  let charCount = 0;
@@ -20531,7 +20362,7 @@ var CodeBlock = Node3.create({
20531
20362
  }
20532
20363
  return editor.commands.command(({ tr: tr2 }) => {
20533
20364
  const { from: from2, to } = selection;
20534
- const text = state3.doc.textBetween(from2, to, "\n", "\n");
20365
+ const text = state.doc.textBetween(from2, to, "\n", "\n");
20535
20366
  const lines = text.split("\n");
20536
20367
  const reverseIndentText = lines.map((line) => {
20537
20368
  var _a2;
@@ -20539,7 +20370,7 @@ var CodeBlock = Node3.create({
20539
20370
  const spacesToRemove = Math.min(leadingSpaces.length, tabSize);
20540
20371
  return line.slice(spacesToRemove);
20541
20372
  }).join("\n");
20542
- tr2.replaceWith(from2, to, state3.schema.text(reverseIndentText));
20373
+ tr2.replaceWith(from2, to, state.schema.text(reverseIndentText));
20543
20374
  return true;
20544
20375
  });
20545
20376
  },
@@ -20548,8 +20379,8 @@ var CodeBlock = Node3.create({
20548
20379
  if (!this.options.exitOnTripleEnter) {
20549
20380
  return false;
20550
20381
  }
20551
- const { state: state3 } = editor;
20552
- const { selection } = state3;
20382
+ const { state } = editor;
20383
+ const { selection } = state;
20553
20384
  const { $from, empty: empty2 } = selection;
20554
20385
  if (!empty2 || $from.parent.type !== this.type) {
20555
20386
  return false;
@@ -20569,8 +20400,8 @@ var CodeBlock = Node3.create({
20569
20400
  if (!this.options.exitOnArrowDown) {
20570
20401
  return false;
20571
20402
  }
20572
- const { state: state3 } = editor;
20573
- const { selection, doc: doc3 } = state3;
20403
+ const { state } = editor;
20404
+ const { selection, doc: doc3 } = state;
20574
20405
  const { $from, empty: empty2 } = selection;
20575
20406
  if (!empty2 || $from.parent.type !== this.type) {
20576
20407
  return false;
@@ -20694,11 +20525,11 @@ var HardBreak = Node3.create({
20694
20525
  },
20695
20526
  addCommands() {
20696
20527
  return {
20697
- setHardBreak: () => ({ commands, chain, state: state3, editor }) => {
20528
+ setHardBreak: () => ({ commands, chain, state, editor }) => {
20698
20529
  return commands.first([
20699
20530
  () => commands.exitCode(),
20700
20531
  () => commands.command(() => {
20701
- const { selection, storedMarks } = state3;
20532
+ const { selection, storedMarks } = state;
20702
20533
  if (selection.$from.parent.type.spec.isolating) {
20703
20534
  return false;
20704
20535
  }
@@ -20833,11 +20664,11 @@ var HorizontalRule = Node3.create({
20833
20664
  },
20834
20665
  addCommands() {
20835
20666
  return {
20836
- setHorizontalRule: () => ({ chain, state: state3 }) => {
20837
- if (!canInsertNode(state3, state3.schema.nodes[this.name])) {
20667
+ setHorizontalRule: () => ({ chain, state }) => {
20668
+ if (!canInsertNode(state, state.schema.nodes[this.name])) {
20838
20669
  return false;
20839
20670
  }
20840
- const { selection } = state3;
20671
+ const { selection } = state;
20841
20672
  const { $to: $originTo } = selection;
20842
20673
  const currentChain = chain();
20843
20674
  if (isNodeSelection(selection)) {
@@ -21049,19 +20880,19 @@ State.prototype = {
21049
20880
  * @returns {?State<T>} the next state, if any
21050
20881
  */
21051
20882
  go(input) {
21052
- const state3 = this;
21053
- const nextState = state3.j[input];
20883
+ const state = this;
20884
+ const nextState = state.j[input];
21054
20885
  if (nextState) {
21055
20886
  return nextState;
21056
20887
  }
21057
- for (let i = 0; i < state3.jr.length; i++) {
21058
- const regex = state3.jr[i][0];
21059
- const nextState2 = state3.jr[i][1];
20888
+ for (let i = 0; i < state.jr.length; i++) {
20889
+ const regex = state.jr[i][0];
20890
+ const nextState2 = state.jr[i][1];
21060
20891
  if (nextState2 && regex.test(input)) {
21061
20892
  return nextState2;
21062
20893
  }
21063
20894
  }
21064
- return state3.jd;
20895
+ return state.jd;
21065
20896
  },
21066
20897
  /**
21067
20898
  * Whether the state has a transition for the given input. Set the second
@@ -21120,15 +20951,15 @@ State.prototype = {
21120
20951
  * @returns {State<T>} taken after the given input
21121
20952
  */
21122
20953
  ts(input, next, flags, groups) {
21123
- let state3 = this;
20954
+ let state = this;
21124
20955
  const len = input.length;
21125
20956
  if (!len) {
21126
- return state3;
20957
+ return state;
21127
20958
  }
21128
20959
  for (let i = 0; i < len - 1; i++) {
21129
- state3 = state3.tt(input[i]);
20960
+ state = state.tt(input[i]);
21130
20961
  }
21131
- return state3.tt(input[len - 1], next, flags, groups);
20962
+ return state.tt(input[len - 1], next, flags, groups);
21132
20963
  },
21133
20964
  /**
21134
20965
  * Short for "take transition", this is a method for building/working with
@@ -21158,13 +20989,13 @@ State.prototype = {
21158
20989
  */
21159
20990
  tt(input, next, flags, groups) {
21160
20991
  groups = groups || State.groups;
21161
- const state3 = this;
20992
+ const state = this;
21162
20993
  if (next && next.j) {
21163
- state3.j[input] = next;
20994
+ state.j[input] = next;
21164
20995
  return next;
21165
20996
  }
21166
20997
  const t = next;
21167
- let nextState, templateState = state3.go(input);
20998
+ let nextState, templateState = state.go(input);
21168
20999
  if (templateState) {
21169
21000
  nextState = new State();
21170
21001
  Object.assign(nextState.j, templateState.j);
@@ -21185,14 +21016,14 @@ State.prototype = {
21185
21016
  }
21186
21017
  nextState.t = t;
21187
21018
  }
21188
- state3.j[input] = nextState;
21019
+ state.j[input] = nextState;
21189
21020
  return nextState;
21190
21021
  }
21191
21022
  };
21192
- var ta = (state3, input, next, flags, groups) => state3.ta(input, next, flags, groups);
21193
- var tr = (state3, regexp, next, flags, groups) => state3.tr(regexp, next, flags, groups);
21194
- var ts = (state3, input, next, flags, groups) => state3.ts(input, next, flags, groups);
21195
- var tt = (state3, input, next, flags, groups) => state3.tt(input, next, flags, groups);
21023
+ var ta = (state, input, next, flags, groups) => state.ta(input, next, flags, groups);
21024
+ var tr = (state, regexp, next, flags, groups) => state.tr(regexp, next, flags, groups);
21025
+ var ts = (state, input, next, flags, groups) => state.ts(input, next, flags, groups);
21026
+ var tt = (state, input, next, flags, groups) => state.tt(input, next, flags, groups);
21196
21027
  var WORD = "WORD";
21197
21028
  var UWORD = "UWORD";
21198
21029
  var ASCIINUMERICAL = "ASCIINUMERICAL";
@@ -21489,18 +21320,18 @@ function run$1(start, str) {
21489
21320
  let cursor = 0;
21490
21321
  let charCursor = 0;
21491
21322
  while (charCursor < charCount) {
21492
- let state3 = start;
21323
+ let state = start;
21493
21324
  let nextState = null;
21494
21325
  let tokenLength = 0;
21495
21326
  let latestAccepting = null;
21496
21327
  let sinceAccepts = -1;
21497
21328
  let charsSinceAccepts = -1;
21498
- while (charCursor < charCount && (nextState = state3.go(iterable[charCursor]))) {
21499
- state3 = nextState;
21500
- if (state3.accepts()) {
21329
+ while (charCursor < charCount && (nextState = state.go(iterable[charCursor]))) {
21330
+ state = nextState;
21331
+ if (state.accepts()) {
21501
21332
  sinceAccepts = 0;
21502
21333
  charsSinceAccepts = 0;
21503
- latestAccepting = state3;
21334
+ latestAccepting = state;
21504
21335
  } else if (sinceAccepts >= 0) {
21505
21336
  sinceAccepts += iterable[charCursor].length;
21506
21337
  charsSinceAccepts++;
@@ -21538,23 +21369,23 @@ function stringToArray(str) {
21538
21369
  }
21539
21370
  return result;
21540
21371
  }
21541
- function fastts(state3, input, t, defaultt, jr) {
21372
+ function fastts(state, input, t, defaultt, jr) {
21542
21373
  let next;
21543
21374
  const len = input.length;
21544
21375
  for (let i = 0; i < len - 1; i++) {
21545
21376
  const char = input[i];
21546
- if (state3.j[char]) {
21547
- next = state3.j[char];
21377
+ if (state.j[char]) {
21378
+ next = state.j[char];
21548
21379
  } else {
21549
21380
  next = new State(defaultt);
21550
21381
  next.jr = jr.slice();
21551
- state3.j[char] = next;
21382
+ state.j[char] = next;
21552
21383
  }
21553
- state3 = next;
21384
+ state = next;
21554
21385
  }
21555
21386
  next = new State(t);
21556
21387
  next.jr = jr.slice();
21557
- state3.j[input[len - 1]] = next;
21388
+ state.j[input[len - 1]] = next;
21558
21389
  return next;
21559
21390
  }
21560
21391
  function decodeTlds(encoded) {
@@ -21997,21 +21828,21 @@ function run3(start, input, tokens) {
21997
21828
  let multis = [];
21998
21829
  let textTokens = [];
21999
21830
  while (cursor < len) {
22000
- let state3 = start;
21831
+ let state = start;
22001
21832
  let secondState = null;
22002
21833
  let nextState = null;
22003
21834
  let multiLength = 0;
22004
21835
  let latestAccepting = null;
22005
21836
  let sinceAccepts = -1;
22006
- while (cursor < len && !(secondState = state3.go(tokens[cursor].t))) {
21837
+ while (cursor < len && !(secondState = state.go(tokens[cursor].t))) {
22007
21838
  textTokens.push(tokens[cursor++]);
22008
21839
  }
22009
- while (cursor < len && (nextState = secondState || state3.go(tokens[cursor].t))) {
21840
+ while (cursor < len && (nextState = secondState || state.go(tokens[cursor].t))) {
22010
21841
  secondState = null;
22011
- state3 = nextState;
22012
- if (state3.accepts()) {
21842
+ state = nextState;
21843
+ if (state.accepts()) {
22013
21844
  sinceAccepts = 0;
22014
- latestAccepting = state3;
21845
+ latestAccepting = state;
22015
21846
  } else if (sinceAccepts >= 0) {
22016
21847
  sinceAccepts++;
22017
21848
  }
@@ -22268,8 +22099,8 @@ function pasteHandler(options) {
22268
22099
  props: {
22269
22100
  handlePaste: (view, _event, slice2) => {
22270
22101
  const { shouldAutoLink } = options;
22271
- const { state: state3 } = view;
22272
- const { selection } = state3;
22102
+ const { state } = view;
22103
+ const { selection } = state;
22273
22104
  const { empty: empty2 } = selection;
22274
22105
  if (empty2) {
22275
22106
  return false;
@@ -22727,9 +22558,9 @@ __export2(listHelpers_exports, {
22727
22558
  nextListIsDeeper: () => nextListIsDeeper,
22728
22559
  nextListIsHigher: () => nextListIsHigher
22729
22560
  });
22730
- var findListItemPos = (typeOrName, state3) => {
22731
- const { $from } = state3.selection;
22732
- const nodeType = getNodeType(typeOrName, state3.schema);
22561
+ var findListItemPos = (typeOrName, state) => {
22562
+ const { $from } = state.selection;
22563
+ const nodeType = getNodeType(typeOrName, state.schema);
22733
22564
  let currentNode = null;
22734
22565
  let currentDepth = $from.depth;
22735
22566
  let currentPos = $from.pos;
@@ -22746,14 +22577,14 @@ var findListItemPos = (typeOrName, state3) => {
22746
22577
  if (targetDepth === null) {
22747
22578
  return null;
22748
22579
  }
22749
- return { $pos: state3.doc.resolve(currentPos), depth: targetDepth };
22580
+ return { $pos: state.doc.resolve(currentPos), depth: targetDepth };
22750
22581
  };
22751
- var getNextListDepth = (typeOrName, state3) => {
22752
- const listItemPos = findListItemPos(typeOrName, state3);
22582
+ var getNextListDepth = (typeOrName, state) => {
22583
+ const listItemPos = findListItemPos(typeOrName, state);
22753
22584
  if (!listItemPos) {
22754
22585
  return false;
22755
22586
  }
22756
- const [, depth] = getNodeAtPosition(state3, typeOrName, listItemPos.$pos.pos + 4);
22587
+ const [, depth] = getNodeAtPosition(state, typeOrName, listItemPos.$pos.pos + 4);
22757
22588
  return depth;
22758
22589
  };
22759
22590
  var hasListBefore = (editorState, name, parentListTypes) => {
@@ -22765,10 +22596,10 @@ var hasListBefore = (editorState, name, parentListTypes) => {
22765
22596
  }
22766
22597
  return true;
22767
22598
  };
22768
- var hasListItemBefore = (typeOrName, state3) => {
22599
+ var hasListItemBefore = (typeOrName, state) => {
22769
22600
  var _a;
22770
- const { $anchor } = state3.selection;
22771
- const $targetPos = state3.doc.resolve($anchor.pos - 2);
22601
+ const { $anchor } = state.selection;
22602
+ const $targetPos = state.doc.resolve($anchor.pos - 2);
22772
22603
  if ($targetPos.index() === 0) {
22773
22604
  return false;
22774
22605
  }
@@ -22777,11 +22608,11 @@ var hasListItemBefore = (typeOrName, state3) => {
22777
22608
  }
22778
22609
  return true;
22779
22610
  };
22780
- var listItemHasSubList = (typeOrName, state3, node) => {
22611
+ var listItemHasSubList = (typeOrName, state, node) => {
22781
22612
  if (!node) {
22782
22613
  return false;
22783
22614
  }
22784
- const nodeType = getNodeType(typeOrName, state3.schema);
22615
+ const nodeType = getNodeType(typeOrName, state.schema);
22785
22616
  let hasSubList = false;
22786
22617
  node.descendants((child) => {
22787
22618
  if (child.type === nodeType) {
@@ -22831,9 +22662,9 @@ var handleBackspace = (editor, name, parentListTypes) => {
22831
22662
  }
22832
22663
  return editor.chain().liftListItem(name).run();
22833
22664
  };
22834
- var nextListIsDeeper = (typeOrName, state3) => {
22835
- const listDepth = getNextListDepth(typeOrName, state3);
22836
- const listItemPos = findListItemPos(typeOrName, state3);
22665
+ var nextListIsDeeper = (typeOrName, state) => {
22666
+ const listDepth = getNextListDepth(typeOrName, state);
22667
+ const listItemPos = findListItemPos(typeOrName, state);
22837
22668
  if (!listItemPos || !listDepth) {
22838
22669
  return false;
22839
22670
  }
@@ -22842,9 +22673,9 @@ var nextListIsDeeper = (typeOrName, state3) => {
22842
22673
  }
22843
22674
  return false;
22844
22675
  };
22845
- var nextListIsHigher = (typeOrName, state3) => {
22846
- const listDepth = getNextListDepth(typeOrName, state3);
22847
- const listItemPos = findListItemPos(typeOrName, state3);
22676
+ var nextListIsHigher = (typeOrName, state) => {
22677
+ const listDepth = getNextListDepth(typeOrName, state);
22678
+ const listItemPos = findListItemPos(typeOrName, state);
22848
22679
  if (!listItemPos || !listDepth) {
22849
22680
  return false;
22850
22681
  }
@@ -22873,10 +22704,10 @@ var handleDelete = (editor, name) => {
22873
22704
  }
22874
22705
  return editor.commands.joinItemForward();
22875
22706
  };
22876
- var hasListItemAfter = (typeOrName, state3) => {
22707
+ var hasListItemAfter = (typeOrName, state) => {
22877
22708
  var _a;
22878
- const { $anchor } = state3.selection;
22879
- const $targetPos = state3.doc.resolve($anchor.pos - $anchor.parentOffset - 2);
22709
+ const { $anchor } = state.selection;
22710
+ const $targetPos = state.doc.resolve($anchor.pos - $anchor.parentOffset - 2);
22880
22711
  if ($targetPos.index() === $targetPos.parent.childCount - 1) {
22881
22712
  return false;
22882
22713
  }
@@ -24076,20 +23907,20 @@ var handleKeyDown = keydownHandler({
24076
23907
  });
24077
23908
  function arrow(axis, dir) {
24078
23909
  const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
24079
- return function(state3, dispatch, view) {
24080
- let sel = state3.selection;
23910
+ return function(state, dispatch, view) {
23911
+ let sel = state.selection;
24081
23912
  let $start = dir > 0 ? sel.$to : sel.$from, mustMove = sel.empty;
24082
23913
  if (sel instanceof TextSelection) {
24083
23914
  if (!view.endOfTextblock(dirStr) || $start.depth == 0)
24084
23915
  return false;
24085
23916
  mustMove = false;
24086
- $start = state3.doc.resolve(dir > 0 ? $start.after() : $start.before());
23917
+ $start = state.doc.resolve(dir > 0 ? $start.after() : $start.before());
24087
23918
  }
24088
23919
  let $found = GapCursor.findGapCursorFrom($start, dir, mustMove);
24089
23920
  if (!$found)
24090
23921
  return false;
24091
23922
  if (dispatch)
24092
- dispatch(state3.tr.setSelection(new GapCursor($found)));
23923
+ dispatch(state.tr.setSelection(new GapCursor($found)));
24093
23924
  return true;
24094
23925
  };
24095
23926
  }
@@ -24120,12 +23951,12 @@ function beforeinput(view, event) {
24120
23951
  view.dispatch(tr2);
24121
23952
  return false;
24122
23953
  }
24123
- function drawGapCursor(state3) {
24124
- if (!(state3.selection instanceof GapCursor))
23954
+ function drawGapCursor(state) {
23955
+ if (!(state.selection instanceof GapCursor))
24125
23956
  return null;
24126
23957
  let node = document.createElement("div");
24127
23958
  node.className = "ProseMirror-gapcursor";
24128
- return DecorationSet.create(state3.doc, [Decoration.widget(state3.selection.head, node, { key: "gapcursor" })]);
23959
+ return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, { key: "gapcursor" })]);
24129
23960
  }
24130
23961
 
24131
23962
  // ../../node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.js
@@ -24320,7 +24151,7 @@ var Branch = class _Branch {
24320
24151
  }
24321
24152
  // Pop the latest event off the branch's history and apply it
24322
24153
  // to a document transform.
24323
- popEvent(state3, preserveItems) {
24154
+ popEvent(state, preserveItems) {
24324
24155
  if (this.eventCount == 0)
24325
24156
  return null;
24326
24157
  let end = this.items.length;
@@ -24336,7 +24167,7 @@ var Branch = class _Branch {
24336
24167
  remap = this.remapping(end, this.items.length);
24337
24168
  mapFrom = remap.maps.length;
24338
24169
  }
24339
- let transform = state3.tr;
24170
+ let transform = state.tr;
24340
24171
  let selection, remaining;
24341
24172
  let addAfter = [], addBefore = [];
24342
24173
  this.items.forEach((item, i) => {
@@ -24533,7 +24364,7 @@ var HistoryState = class {
24533
24364
  }
24534
24365
  };
24535
24366
  var DEPTH_OVERFLOW = 20;
24536
- function applyTransaction(history2, state3, tr2, options) {
24367
+ function applyTransaction(history2, state, tr2, options) {
24537
24368
  let historyTr = tr2.getMeta(historyKey), rebased;
24538
24369
  if (historyTr)
24539
24370
  return historyTr.historyState;
@@ -24544,14 +24375,14 @@ function applyTransaction(history2, state3, tr2, options) {
24544
24375
  return history2;
24545
24376
  } else if (appended && appended.getMeta(historyKey)) {
24546
24377
  if (appended.getMeta(historyKey).redo)
24547
- return new HistoryState(history2.done.addTransform(tr2, void 0, options, mustPreserveItems(state3)), history2.undone, rangesFor(tr2.mapping.maps), history2.prevTime, history2.prevComposition);
24378
+ return new HistoryState(history2.done.addTransform(tr2, void 0, options, mustPreserveItems(state)), history2.undone, rangesFor(tr2.mapping.maps), history2.prevTime, history2.prevComposition);
24548
24379
  else
24549
- return new HistoryState(history2.done, history2.undone.addTransform(tr2, void 0, options, mustPreserveItems(state3)), null, history2.prevTime, history2.prevComposition);
24380
+ return new HistoryState(history2.done, history2.undone.addTransform(tr2, void 0, options, mustPreserveItems(state)), null, history2.prevTime, history2.prevComposition);
24550
24381
  } else if (tr2.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
24551
24382
  let composition = tr2.getMeta("composition");
24552
24383
  let newGroup = history2.prevTime == 0 || !appended && history2.prevComposition != composition && (history2.prevTime < (tr2.time || 0) - options.newGroupDelay || !isAdjacentTo(tr2, history2.prevRanges));
24553
24384
  let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps);
24554
- return new HistoryState(history2.done.addTransform(tr2, newGroup ? state3.selection.getBookmark() : void 0, options, mustPreserveItems(state3)), Branch.empty, prevRanges, tr2.time, composition == null ? history2.prevComposition : composition);
24385
+ return new HistoryState(history2.done.addTransform(tr2, newGroup ? state.selection.getBookmark() : void 0, options, mustPreserveItems(state)), Branch.empty, prevRanges, tr2.time, composition == null ? history2.prevComposition : composition);
24555
24386
  } else if (rebased = tr2.getMeta("rebased")) {
24556
24387
  return new HistoryState(history2.done.rebased(tr2, rebased), history2.undone.rebased(tr2, rebased), mapRanges(history2.prevRanges, tr2.mapping), history2.prevTime, history2.prevComposition);
24557
24388
  } else {
@@ -24588,21 +24419,21 @@ function mapRanges(ranges, mapping) {
24588
24419
  }
24589
24420
  return result;
24590
24421
  }
24591
- function histTransaction(history2, state3, redo2) {
24592
- let preserveItems = mustPreserveItems(state3);
24593
- let histOptions = historyKey.get(state3).spec.config;
24594
- let pop = (redo2 ? history2.undone : history2.done).popEvent(state3, preserveItems);
24422
+ function histTransaction(history2, state, redo2) {
24423
+ let preserveItems = mustPreserveItems(state);
24424
+ let histOptions = historyKey.get(state).spec.config;
24425
+ let pop = (redo2 ? history2.undone : history2.done).popEvent(state, preserveItems);
24595
24426
  if (!pop)
24596
24427
  return null;
24597
24428
  let selection = pop.selection.resolve(pop.transform.doc);
24598
- let added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform, state3.selection.getBookmark(), histOptions, preserveItems);
24429
+ let added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
24599
24430
  let newHist = new HistoryState(redo2 ? added : pop.remaining, redo2 ? pop.remaining : added, null, 0, -1);
24600
24431
  return pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist });
24601
24432
  }
24602
24433
  var cachedPreserveItems = false;
24603
24434
  var cachedPreserveItemsPlugins = null;
24604
- function mustPreserveItems(state3) {
24605
- let plugins = state3.plugins;
24435
+ function mustPreserveItems(state) {
24436
+ let plugins = state.plugins;
24606
24437
  if (cachedPreserveItemsPlugins != plugins) {
24607
24438
  cachedPreserveItems = false;
24608
24439
  cachedPreserveItemsPlugins = plugins;
@@ -24627,8 +24458,8 @@ function history(config = {}) {
24627
24458
  init() {
24628
24459
  return new HistoryState(Branch.empty, Branch.empty, null, 0, -1);
24629
24460
  },
24630
- apply(tr2, hist, state3) {
24631
- return applyTransaction(hist, state3, tr2, config);
24461
+ apply(tr2, hist, state) {
24462
+ return applyTransaction(hist, state, tr2, config);
24632
24463
  }
24633
24464
  },
24634
24465
  config,
@@ -24647,12 +24478,12 @@ function history(config = {}) {
24647
24478
  });
24648
24479
  }
24649
24480
  function buildCommand(redo2, scroll) {
24650
- return (state3, dispatch) => {
24651
- let hist = historyKey.getState(state3);
24481
+ return (state, dispatch) => {
24482
+ let hist = historyKey.getState(state);
24652
24483
  if (!hist || (redo2 ? hist.undone : hist.done).eventCount == 0)
24653
24484
  return false;
24654
24485
  if (dispatch) {
24655
- let tr2 = histTransaction(hist, state3, redo2);
24486
+ let tr2 = histTransaction(hist, state, redo2);
24656
24487
  if (tr2)
24657
24488
  dispatch(scroll ? tr2.scrollIntoView() : tr2);
24658
24489
  }
@@ -24725,12 +24556,12 @@ var CharacterCount = Extension.create({
24725
24556
  }
24726
24557
  initialEvaluationDone = true;
24727
24558
  },
24728
- filterTransaction: (transaction, state3) => {
24559
+ filterTransaction: (transaction, state) => {
24729
24560
  const limit = this.options.limit;
24730
24561
  if (!transaction.docChanged || limit === 0 || limit === null || limit === void 0) {
24731
24562
  return true;
24732
24563
  }
24733
- const oldSize = this.storage.characters({ node: state3.doc });
24564
+ const oldSize = this.storage.characters({ node: state.doc });
24734
24565
  const newSize = this.storage.characters({ node: transaction.doc });
24735
24566
  if (newSize <= limit) {
24736
24567
  return true;
@@ -24925,12 +24756,12 @@ var Selection2 = Extension.create({
24925
24756
  new Plugin({
24926
24757
  key: new PluginKey("selection"),
24927
24758
  props: {
24928
- decorations(state3) {
24929
- if (state3.selection.empty || editor.isFocused || !editor.isEditable || isNodeSelection(state3.selection) || editor.view.dragging) {
24759
+ decorations(state) {
24760
+ if (state.selection.empty || editor.isFocused || !editor.isEditable || isNodeSelection(state.selection) || editor.view.dragging) {
24930
24761
  return null;
24931
24762
  }
24932
- return DecorationSet.create(state3.doc, [
24933
- Decoration.inline(state3.selection.from, state3.selection.to, {
24763
+ return DecorationSet.create(state.doc, [
24764
+ Decoration.inline(state.selection.from, state.selection.to, {
24934
24765
  class: options.className
24935
24766
  })
24936
24767
  ]);
@@ -24959,9 +24790,9 @@ var TrailingNode = Extension.create({
24959
24790
  return [
24960
24791
  new Plugin({
24961
24792
  key: plugin,
24962
- appendTransaction: (_, __, state3) => {
24963
- const { doc: doc3, tr: tr2, schema } = state3;
24964
- const shouldInsertNodeAtEnd = plugin.getState(state3);
24793
+ appendTransaction: (_, __, state) => {
24794
+ const { doc: doc3, tr: tr2, schema } = state;
24795
+ const shouldInsertNodeAtEnd = plugin.getState(state);
24965
24796
  const endPosition = doc3.content.size;
24966
24797
  const type = schema.nodes[defaultNode];
24967
24798
  if (!shouldInsertNodeAtEnd) {
@@ -24970,8 +24801,8 @@ var TrailingNode = Extension.create({
24970
24801
  return tr2.insert(endPosition, type.create());
24971
24802
  },
24972
24803
  state: {
24973
- init: (_, state3) => {
24974
- const lastNode = state3.tr.doc.lastChild;
24804
+ init: (_, state) => {
24805
+ const lastNode = state.tr.doc.lastChild;
24975
24806
  return !nodeEqualsType({ node: lastNode, types: disabledNodes });
24976
24807
  },
24977
24808
  apply: (tr2, value) => {
@@ -24999,11 +24830,11 @@ var UndoRedo = Extension.create({
24999
24830
  },
25000
24831
  addCommands() {
25001
24832
  return {
25002
- undo: () => ({ state: state3, dispatch }) => {
25003
- return undo(state3, dispatch);
24833
+ undo: () => ({ state, dispatch }) => {
24834
+ return undo(state, dispatch);
25004
24835
  },
25005
- redo: () => ({ state: state3, dispatch }) => {
25006
- return redo(state3, dispatch);
24836
+ redo: () => ({ state, dispatch }) => {
24837
+ return redo(state, dispatch);
25007
24838
  }
25008
24839
  };
25009
24840
  },
@@ -25101,21 +24932,12 @@ var index_default2 = StarterKit;
25101
24932
 
25102
24933
  // src/rich-input/ChatInput.tsx
25103
24934
  import {
25104
- useEffect as useEffect8,
24935
+ useEffect as useEffect9,
25105
24936
  useRef as useRef7,
25106
24937
  useState as useState11
25107
24938
  } from "react";
25108
24939
  import { createRoot } from "react-dom/client";
25109
24940
 
25110
- // src/chat/lib/skill-name.ts
25111
- function skillDisplayName(skill) {
25112
- const displayName = (skill.display_name ?? skill.displayName ?? "").trim();
25113
- if (displayName) {
25114
- return displayName;
25115
- }
25116
- return (skill.skill_id ?? skill.skillId ?? "").trim();
25117
- }
25118
-
25119
24941
  // src/rich-input/voice/use-tiptap-voice-input.ts
25120
24942
  import { useCallback, useEffect as useEffect4, useRef as useRef3 } from "react";
25121
24943
  var IDLE_VOICE = {
@@ -25351,7 +25173,7 @@ function useComposerModel(activeSessionId) {
25351
25173
  const [selectingSession, setSelectingSession] = useState4(null);
25352
25174
  const selectingRef = useRef4(null);
25353
25175
  const sharedModelDraft = useComposerChannels(
25354
- (state3) => activeSessionId ? state3.modelDrafts[activeSessionId] : void 0
25176
+ (state) => activeSessionId ? state.modelDrafts[activeSessionId] : void 0
25355
25177
  );
25356
25178
  const explicitModelSelection = activeSessionId ? sharedModelDraft ? { sessionId: activeSessionId, model: sharedModelDraft } : null : newSessionModelSelection;
25357
25179
  const {
@@ -25470,8 +25292,8 @@ function PopoverContent({
25470
25292
  }
25471
25293
 
25472
25294
  // src/rich-input/ModelSelector.tsx
25473
- import { useMemo as useMemo4, useState as useState5 } from "react";
25474
- import { jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
25295
+ import { useEffect as useEffect6, useMemo as useMemo4, useState as useState5 } from "react";
25296
+ import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
25475
25297
  var inputModalityLabels = {
25476
25298
  text: "\u6587\u672C",
25477
25299
  image: "\u56FE\u7247",
@@ -25489,19 +25311,100 @@ function formatInputModalities(model) {
25489
25311
  if (modalities.length === 0) return "\u65E0\u8F93\u5165\u80FD\u529B";
25490
25312
  return modalities.map((value) => inputModalityLabels[value] ?? value).join("\u3001");
25491
25313
  }
25492
- function ModelSelector({
25314
+ function ModelCatalogPopoverBody({
25315
+ value,
25316
+ onSelectModel,
25317
+ refreshOnMount = false
25318
+ }) {
25319
+ const { models, isFetching, refresh } = useModelCatalog();
25320
+ const [query, setQuery] = useState5("");
25321
+ const selectedModel = models.find((model) => model.id === value);
25322
+ const selectedUnavailable = !!value.trim() && !selectedModel;
25323
+ useEffect6(() => {
25324
+ if (refreshOnMount) {
25325
+ void refresh();
25326
+ }
25327
+ }, []);
25328
+ const filteredModels = useMemo4(() => {
25329
+ const normalized = query.trim().toLowerCase();
25330
+ if (!normalized) return models;
25331
+ return models.filter((model) => {
25332
+ const inputLabel = formatInputModalities(model).toLowerCase();
25333
+ return model.id.toLowerCase().includes(normalized) || model.label.toLowerCase().includes(normalized) || inputLabel.includes(normalized);
25334
+ });
25335
+ }, [models, query]);
25336
+ return /* @__PURE__ */ jsxs3(Fragment4, { children: [
25337
+ /* @__PURE__ */ jsxs3("div", { className: "border-b border-border p-2", children: [
25338
+ /* @__PURE__ */ jsx12(
25339
+ "input",
25340
+ {
25341
+ value: query,
25342
+ onChange: (event) => setQuery(event.target.value),
25343
+ placeholder: "\u7B5B\u9009\u6A21\u578B...",
25344
+ className: "h-8 w-full rounded-lg border border-border bg-background px-2.5 text-xs text-foreground outline-none placeholder:text-muted-foreground focus:border-ring"
25345
+ }
25346
+ ),
25347
+ selectedUnavailable ? /* @__PURE__ */ jsx12("p", { className: "px-1 pt-2 text-[11px] leading-4 text-destructive", children: "\u5F53\u524D\u4F1A\u8BDD\u6A21\u578B\u4E0D\u53EF\u7528\u3002\u8BF7\u5728\u4E0B\u65B9\u9009\u62E9\u4E00\u4E2A\u6A21\u578B\uFF0C\u9009\u4E2D\u540E\u4F1A\u5728\u4E0B\u6B21\u53D1\u9001\u65F6\u5207\u6362\u3002" }) : null
25348
+ ] }),
25349
+ /* @__PURE__ */ jsx12(
25350
+ "div",
25351
+ {
25352
+ className: "overflow-y-auto p-1",
25353
+ style: { maxHeight: "min(220px, max(0px, calc(var(--radix-popover-content-available-height) - 49px)))" },
25354
+ children: isFetching ? /* @__PURE__ */ jsxs3("output", { className: "flex items-center justify-center gap-2 px-3 py-6 text-xs text-muted-foreground", children: [
25355
+ /* @__PURE__ */ jsx12(LoaderCircle, { size: 14, className: "animate-spin", "aria-hidden": "true" }),
25356
+ "\u6B63\u5728\u52A0\u8F7D\u5019\u9009\u6A21\u578B..."
25357
+ ] }) : models.length === 0 ? /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between gap-2 px-3 py-3 text-xs text-muted-foreground", children: [
25358
+ /* @__PURE__ */ jsx12("span", { children: "\u5F53\u524D\u6682\u65E0\u53EF\u7528\u6A21\u578B" }),
25359
+ /* @__PURE__ */ jsxs3(
25360
+ "button",
25361
+ {
25362
+ type: "button",
25363
+ onClick: () => void refresh(),
25364
+ className: "inline-flex shrink-0 items-center gap-1 rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground transition-colors hover:bg-accent",
25365
+ children: [
25366
+ /* @__PURE__ */ jsx12(RotateCw, { size: 12, "aria-hidden": "true" }),
25367
+ "\u91CD\u65B0\u52A0\u8F7D"
25368
+ ]
25369
+ }
25370
+ )
25371
+ ] }) : filteredModels.length === 0 ? /* @__PURE__ */ jsx12("div", { className: "px-3 py-2 text-xs text-muted-foreground", children: "\u6CA1\u6709\u5339\u914D\u7684\u6A21\u578B" }) : filteredModels.map((model) => {
25372
+ const inputLabel = formatInputModalities(model);
25373
+ const title = model.id === model.label ? `${model.id}\uFF0C\u652F\u6301\u8F93\u5165\uFF1A${inputLabel}` : `${model.label} (${model.id})\uFF0C\u652F\u6301\u8F93\u5165\uFF1A${inputLabel}`;
25374
+ return /* @__PURE__ */ jsxs3(
25375
+ "button",
25376
+ {
25377
+ type: "button",
25378
+ onClick: () => onSelectModel(model.id),
25379
+ className: `flex w-full items-center justify-between gap-3 rounded-lg px-3 py-2 text-left text-xs transition-colors ${model.id === value ? "bg-accent text-foreground" : "text-muted-foreground hover:bg-accent hover:text-foreground"}`,
25380
+ title,
25381
+ children: [
25382
+ /* @__PURE__ */ jsx12("span", { className: "min-w-0 truncate", children: model.label }),
25383
+ /* @__PURE__ */ jsxs3("span", { className: "flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground", children: [
25384
+ inputLabel,
25385
+ model.id === value ? /* @__PURE__ */ jsx12(Check, { size: 13, "aria-label": "\u5DF2\u9009\u62E9" }) : null
25386
+ ] })
25387
+ ]
25388
+ },
25389
+ model.id
25390
+ );
25391
+ })
25392
+ }
25393
+ )
25394
+ ] });
25395
+ }
25396
+ function BannerModelSelector({
25493
25397
  value,
25494
25398
  onValueChange,
25495
25399
  disabled = false,
25496
- compact = false,
25497
- placement = "bottom"
25400
+ placement = "top",
25401
+ onOpenChange
25498
25402
  }) {
25499
- const { models, defaultModel, isLoading, isFetching, refresh } = useModelCatalog();
25500
25403
  const [isOpen, setIsOpen] = useState5(false);
25501
- const [query, setQuery] = useState5("");
25502
25404
  const [mobileAnchor, setMobileAnchor] = useState5(null);
25503
25405
  function handleOpenChange(open) {
25504
25406
  setIsOpen(open);
25407
+ onOpenChange?.(open);
25505
25408
  if (!open) return;
25506
25409
  const isNarrow = window.matchMedia?.("(max-width: 767px)").matches ?? false;
25507
25410
  if (isNarrow) {
@@ -25510,18 +25413,87 @@ function ModelSelector({
25510
25413
  } else {
25511
25414
  setMobileAnchor(null);
25512
25415
  }
25513
- void refresh();
25514
25416
  }
25515
- const filteredModels = useMemo4(() => {
25516
- const normalized = query.trim().toLowerCase();
25517
- if (!normalized) return models;
25518
- return models.filter(
25519
- (model) => {
25520
- const inputLabel = formatInputModalities(model).toLowerCase();
25521
- return model.id.toLowerCase().includes(normalized) || model.label.toLowerCase().includes(normalized) || inputLabel.includes(normalized);
25417
+ return /* @__PURE__ */ jsx12("div", { className: "relative shrink-0", children: /* @__PURE__ */ jsxs3(Popover, { open: isOpen, onOpenChange: handleOpenChange, children: [
25418
+ mobileAnchor ? /* @__PURE__ */ jsx12(PopoverAnchor, { virtualRef: mobileAnchor }) : null,
25419
+ /* @__PURE__ */ jsx12(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs3(
25420
+ "button",
25421
+ {
25422
+ type: "button",
25423
+ disabled,
25424
+ "aria-label": "\u9009\u62E9\u6A21\u578B",
25425
+ title: "\u9009\u62E9\u6216\u5207\u6362\u53EF\u7528\u6A21\u578B",
25426
+ className: "inline-flex shrink-0 items-center gap-1 rounded-lg border border-[hsl(var(--destructive))]/25 bg-[hsl(var(--background))] px-2.5 py-1 text-xs font-medium text-[hsl(var(--foreground))] shadow-2xs transition-colors hover:border-[hsl(var(--destructive))]/45 hover:bg-[hsl(var(--accent))] disabled:cursor-not-allowed disabled:opacity-50",
25427
+ children: [
25428
+ /* @__PURE__ */ jsx12(Sparkles, { size: 13, className: "shrink-0 text-[hsl(var(--destructive))]", "aria-hidden": "true" }),
25429
+ /* @__PURE__ */ jsx12("span", { className: "whitespace-nowrap", children: "\u9009\u62E9\u6A21\u578B" }),
25430
+ /* @__PURE__ */ jsx12(ChevronDown, { size: 13, className: "shrink-0 text-[hsl(var(--muted-foreground))]", "aria-hidden": "true" })
25431
+ ]
25432
+ }
25433
+ ) }),
25434
+ isOpen ? /* @__PURE__ */ jsx12(
25435
+ PopoverContent,
25436
+ {
25437
+ side: mobileAnchor ? "top" : placement,
25438
+ align: mobileAnchor ? "start" : "end",
25439
+ sideOffset: mobileAnchor ? 0 : 8,
25440
+ collisionPadding: 8,
25441
+ onOpenAutoFocus: (event) => event.preventDefault(),
25442
+ className: `block gap-0 overflow-hidden rounded-xl border border-border bg-popover p-0 text-base text-foreground shadow-[var(--swf-shadow-overlay)] ring-0 ${mobileAnchor ? "w-(--radix-popover-trigger-width)" : "w-[380px]"}`,
25443
+ children: /* @__PURE__ */ jsx12(
25444
+ ModelCatalogPopoverBody,
25445
+ {
25446
+ value,
25447
+ refreshOnMount: true,
25448
+ onSelectModel: (modelId) => {
25449
+ onValueChange(modelId);
25450
+ handleOpenChange(false);
25451
+ }
25452
+ }
25453
+ )
25454
+ }
25455
+ ) : null
25456
+ ] }) });
25457
+ }
25458
+ function ModelSelector(props) {
25459
+ if (props.variant === "banner") {
25460
+ return /* @__PURE__ */ jsx12(
25461
+ BannerModelSelector,
25462
+ {
25463
+ value: props.value,
25464
+ onValueChange: props.onValueChange,
25465
+ disabled: props.disabled,
25466
+ placement: props.placement,
25467
+ onOpenChange: props.onOpenChange
25522
25468
  }
25523
25469
  );
25524
- }, [models, query]);
25470
+ }
25471
+ return /* @__PURE__ */ jsx12(StandardModelSelector, { ...props });
25472
+ }
25473
+ function StandardModelSelector({
25474
+ value,
25475
+ onValueChange,
25476
+ disabled = false,
25477
+ compact = false,
25478
+ placement = "bottom",
25479
+ onOpenChange
25480
+ }) {
25481
+ const { models, defaultModel, isLoading, refresh } = useModelCatalog();
25482
+ const [isOpen, setIsOpen] = useState5(false);
25483
+ const [mobileAnchor, setMobileAnchor] = useState5(null);
25484
+ function handleOpenChange(open) {
25485
+ setIsOpen(open);
25486
+ onOpenChange?.(open);
25487
+ if (!open) return;
25488
+ const isNarrow = window.matchMedia?.("(max-width: 767px)").matches ?? false;
25489
+ if (isNarrow) {
25490
+ const rect = new DOMRect(8, window.innerHeight - 8, window.innerWidth - 16, 0);
25491
+ setMobileAnchor({ current: { getBoundingClientRect: () => rect } });
25492
+ } else {
25493
+ setMobileAnchor(null);
25494
+ }
25495
+ void refresh();
25496
+ }
25525
25497
  const canSelect = models.length > 0;
25526
25498
  const selectedModel = models.find((model) => model.id === value);
25527
25499
  const defaultModelOption = models.find((model) => model.id === defaultModel);
@@ -25575,7 +25547,7 @@ function ModelSelector({
25575
25547
  ]
25576
25548
  }
25577
25549
  ) }),
25578
- /* @__PURE__ */ jsxs3(
25550
+ /* @__PURE__ */ jsx12(
25579
25551
  PopoverContent,
25580
25552
  {
25581
25553
  side: mobileAnchor ? "top" : placement,
@@ -25584,61 +25556,16 @@ function ModelSelector({
25584
25556
  collisionPadding: 8,
25585
25557
  onOpenAutoFocus: (event) => event.preventDefault(),
25586
25558
  className: `block gap-0 overflow-hidden rounded-xl border border-border bg-popover p-0 text-base text-foreground shadow-[var(--swf-shadow-overlay)] ring-0 ${mobileAnchor ? "w-(--radix-popover-trigger-width)" : "w-[380px]"}`,
25587
- children: [
25588
- /* @__PURE__ */ jsxs3("div", { className: "border-b border-border p-2", children: [
25589
- /* @__PURE__ */ jsx12(
25590
- "input",
25591
- {
25592
- value: query,
25593
- onChange: (event) => setQuery(event.target.value),
25594
- placeholder: "\u7B5B\u9009\u6A21\u578B...",
25595
- className: "h-8 w-full rounded-lg border border-border bg-background px-2.5 text-xs text-foreground outline-none placeholder:text-muted-foreground focus:border-ring"
25596
- }
25597
- ),
25598
- selectedUnavailable ? /* @__PURE__ */ jsx12("p", { className: "px-1 pt-2 text-[11px] leading-4 text-destructive", children: "\u5F53\u524D\u4F1A\u8BDD\u6A21\u578B\u4E0D\u53EF\u7528\u3002\u8BF7\u5728\u4E0B\u65B9\u9009\u62E9\u4E00\u4E2A\u6A21\u578B\uFF0C\u9009\u4E2D\u540E\u4F1A\u5728\u4E0B\u6B21\u53D1\u9001\u65F6\u5207\u6362\u3002" }) : null
25599
- ] }),
25600
- /* @__PURE__ */ jsx12(
25601
- "div",
25602
- {
25603
- className: "overflow-y-auto p-1",
25604
- style: { maxHeight: "min(220px, max(0px, calc(var(--radix-popover-content-available-height) - 49px)))" },
25605
- children: isFetching ? /* @__PURE__ */ jsxs3(
25606
- "output",
25607
- {
25608
- className: "flex items-center justify-center gap-2 px-3 py-6 text-xs text-muted-foreground",
25609
- children: [
25610
- /* @__PURE__ */ jsx12(LoaderCircle, { size: 14, className: "animate-spin", "aria-hidden": "true" }),
25611
- "\u6B63\u5728\u52A0\u8F7D\u5019\u9009\u6A21\u578B..."
25612
- ]
25613
- }
25614
- ) : filteredModels.length === 0 ? /* @__PURE__ */ jsx12("div", { className: "px-3 py-2 text-xs text-muted-foreground", children: "\u6CA1\u6709\u5339\u914D\u7684\u6A21\u578B" }) : filteredModels.map((model) => {
25615
- const inputLabel = formatInputModalities(model);
25616
- const title = model.id === model.label ? `${model.id}\uFF0C\u652F\u6301\u8F93\u5165\uFF1A${inputLabel}` : `${model.label} (${model.id})\uFF0C\u652F\u6301\u8F93\u5165\uFF1A${inputLabel}`;
25617
- return /* @__PURE__ */ jsxs3(
25618
- "button",
25619
- {
25620
- type: "button",
25621
- onClick: () => {
25622
- onValueChange(model.id);
25623
- setIsOpen(false);
25624
- setQuery("");
25625
- },
25626
- className: `flex w-full items-center justify-between gap-3 rounded-lg px-3 py-2 text-left text-xs transition-colors ${model.id === value ? "bg-accent text-foreground" : "text-muted-foreground hover:bg-accent hover:text-foreground"}`,
25627
- title,
25628
- children: [
25629
- /* @__PURE__ */ jsx12("span", { className: "min-w-0 truncate", children: model.label }),
25630
- /* @__PURE__ */ jsxs3("span", { className: "flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground", children: [
25631
- inputLabel,
25632
- model.id === value ? /* @__PURE__ */ jsx12(Check, { size: 13, "aria-label": "\u5DF2\u9009\u62E9" }) : null
25633
- ] })
25634
- ]
25635
- },
25636
- model.id
25637
- );
25638
- })
25559
+ children: /* @__PURE__ */ jsx12(
25560
+ ModelCatalogPopoverBody,
25561
+ {
25562
+ value,
25563
+ onSelectModel: (modelId) => {
25564
+ onValueChange(modelId);
25565
+ handleOpenChange(false);
25639
25566
  }
25640
- )
25641
- ]
25567
+ }
25568
+ )
25642
25569
  }
25643
25570
  )
25644
25571
  ] }) });
@@ -25647,11 +25574,6 @@ function ModelSelector({
25647
25574
  // src/rich-input/SkillStatusBar.tsx
25648
25575
  import { useMemo as useMemo5 } from "react";
25649
25576
 
25650
- // src/chat/lib/skill-visibility.ts
25651
- function visibleSkills(skills, mode) {
25652
- return mode === "developer" ? skills : skills.filter((skill) => !skill.builtin);
25653
- }
25654
-
25655
25577
  // src/rich-input/lib/token-pressure.ts
25656
25578
  var NO_PRESSURE = { ratio: 0, level: "normal" };
25657
25579
  function clampRatio(value) {
@@ -25809,7 +25731,9 @@ function SkillStatusBar({
25809
25731
  }) {
25810
25732
  const { data: skillStatsData, error, loading } = useSkillStats(sessionId);
25811
25733
  const skillStats = skillStatsData ?? EMPTY_SKILL_STATS;
25812
- const mode = useChatRenderMode();
25734
+ const chatEnvironment = useChatEnvironment();
25735
+ const renderMode = useChatRenderMode();
25736
+ const mode = chatEnvironment.includeBuiltinSkills ? "developer" : renderMode;
25813
25737
  const { data: allSessionSkills = NO_SKILLS, loading: skillsLoading, error: skillsFailure } = useSessionSkills(sessionId);
25814
25738
  const skillsError = Boolean(skillsFailure);
25815
25739
  const sessionSkills = visibleSkills(allSessionSkills, mode);
@@ -25931,7 +25855,7 @@ function SkillStatusBar({
25931
25855
  }
25932
25856
 
25933
25857
  // src/rich-input/InputActionSubmenu.tsx
25934
- import { useSyncExternalStore as useSyncExternalStore4 } from "react";
25858
+ import { useSyncExternalStore as useSyncExternalStore3 } from "react";
25935
25859
  import { jsx as jsx15, jsxs as jsxs6 } from "react/jsx-runtime";
25936
25860
  var narrowQuery = "(max-width: 639px)";
25937
25861
  function subscribeToViewport(onChange) {
@@ -25941,7 +25865,7 @@ function subscribeToViewport(onChange) {
25941
25865
  }
25942
25866
  var isNarrowViewport = () => window.matchMedia(narrowQuery).matches;
25943
25867
  function InputActionSubmenu({ label, icon, open, onOpenChange, children, disabled = false }) {
25944
- const narrow = useSyncExternalStore4(subscribeToViewport, isNarrowViewport, () => false);
25868
+ const narrow = useSyncExternalStore3(subscribeToViewport, isNarrowViewport, () => false);
25945
25869
  return /* @__PURE__ */ jsxs6(dist_exports.Root, { open, onOpenChange, children: [
25946
25870
  /* @__PURE__ */ jsx15(dist_exports.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs6(
25947
25871
  "button",
@@ -26219,7 +26143,7 @@ function ConnectButton({
26219
26143
  }
26220
26144
 
26221
26145
  // src/rich-input/voice/use-voice-input.ts
26222
- import { useCallback as useCallback2, useEffect as useEffect6, useRef as useRef5, useState as useState7 } from "react";
26146
+ import { useCallback as useCallback2, useEffect as useEffect7, useRef as useRef5, useState as useState7 } from "react";
26223
26147
 
26224
26148
  // src/rich-input/voice/voice-input-support.ts
26225
26149
  function isIpHost(hostname) {
@@ -26531,7 +26455,7 @@ function useVoiceInput(options) {
26531
26455
  if (startAbortRef.current === abort) startAbortRef.current = null;
26532
26456
  }
26533
26457
  }, [reportError, disposeSession, getSocket]);
26534
- useEffect6(() => {
26458
+ useEffect7(() => {
26535
26459
  return () => {
26536
26460
  startAbortRef.current?.abort();
26537
26461
  const s = sessionRef.current;
@@ -26657,10 +26581,10 @@ function useReferenceCandidates(getScope, sources) {
26657
26581
  }
26658
26582
 
26659
26583
  // src/rich-input/use-input-history.ts
26660
- import { useCallback as useCallback3, useEffect as useEffect7, useMemo as useMemo6, useState as useState8 } from "react";
26584
+ import { useCallback as useCallback3, useEffect as useEffect8, useMemo as useMemo6, useState as useState8 } from "react";
26661
26585
 
26662
26586
  // src/rich-input/lib/input-history-document.ts
26663
- import { normalizeTopicAssetRefs as normalizeTopicAssetRefs3 } from "@blade-hq/agent-client";
26587
+ import { normalizeTopicAssetRefs as normalizeTopicAssetRefs2 } from "@blade-hq/agent-client";
26664
26588
  function copyEditorDocument(value) {
26665
26589
  const attributes = {
26666
26590
  pluginMention: { provider: "string", plugin: "string", server: "string", id: "string", label: "string" },
@@ -26698,7 +26622,7 @@ function copyEditorDocument(value) {
26698
26622
  if (expected === "string" && typeof attr !== "string" || expected === "number" && typeof attr !== "number" || expected === "boolean" && typeof attr !== "boolean") return null;
26699
26623
  attrs[key] = attr;
26700
26624
  }
26701
- if (type === "topicAssetMention" && normalizeTopicAssetRefs3([attrs]).length !== 1) return null;
26625
+ if (type === "topicAssetMention" && normalizeTopicAssetRefs2([attrs]).length !== 1) return null;
26702
26626
  return { type, attrs };
26703
26627
  };
26704
26628
  try {
@@ -26751,13 +26675,13 @@ function useInputHistory(sessionId, client) {
26751
26675
  const [entries, setEntries] = useState8([]);
26752
26676
  const [cursor, setCursor] = useState8(null);
26753
26677
  const [draft, setDraft] = useState8(emptyEntry);
26754
- useEffect7(() => {
26678
+ useEffect8(() => {
26755
26679
  setGeneration(getInputHistoryGeneration());
26756
26680
  setEntries(readEntries(storageKey));
26757
26681
  setCursor(null);
26758
26682
  setDraft(emptyEntry());
26759
26683
  }, [storageKey, client]);
26760
- useEffect7(() => {
26684
+ useEffect8(() => {
26761
26685
  if (!client) return;
26762
26686
  return onInputCachesReset(client, () => {
26763
26687
  setGeneration(getInputHistoryGeneration());
@@ -26921,7 +26845,7 @@ function listUserHomeDir(client, dirPath) {
26921
26845
  }
26922
26846
 
26923
26847
  // src/rich-input/FileCompletionMenu.tsx
26924
- import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
26848
+ import { Fragment as Fragment5, jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
26925
26849
  var ROOT_DIR = ".";
26926
26850
  function installSuggestionOutsideDismiss(container, onDismiss) {
26927
26851
  const onPointerDown = (event) => {
@@ -27182,7 +27106,7 @@ var FileCompletionMenuContent = forwardRef2(function FileCompletionMenuContent2(
27182
27106
  },
27183
27107
  `${item.plugin}:${item.server}:${item.id}`
27184
27108
  )),
27185
- topicItems.length > 0 || topicError ? /* @__PURE__ */ jsxs8(Fragment4, { children: [
27109
+ topicItems.length > 0 || topicError ? /* @__PURE__ */ jsxs8(Fragment5, { children: [
27186
27110
  /* @__PURE__ */ jsx17("div", { className: "px-3 pt-1 pb-0.5 text-xs font-medium text-muted-foreground", children: "\u5DE5\u4F5C\u7A7A\u95F4\u8D44\u4EA7" }),
27187
27111
  topicError ? /* @__PURE__ */ jsx17("output", { className: "block px-3 py-2 text-xs text-muted-foreground", children: topicError }) : null,
27188
27112
  topicItems.map((item, topicIndex) => {
@@ -27551,7 +27475,7 @@ function ComposerAttachmentViewport({
27551
27475
  }
27552
27476
 
27553
27477
  // src/rich-input/ChatInput.tsx
27554
- import { Fragment as Fragment5, jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
27478
+ import { Fragment as Fragment6, jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
27555
27479
  var RECENT_SESSION_LIMIT = 50;
27556
27480
  var DOUBLE_ESCAPE_MS = 450;
27557
27481
  function getEditorText(editor) {
@@ -28010,7 +27934,7 @@ function ComposerContextPill({
28010
27934
  }) {
28011
27935
  const [showDetail, setShowDetail] = useState11(false);
28012
27936
  const tokenK = formatTokenK(content);
28013
- return /* @__PURE__ */ jsxs13(Fragment5, { children: [
27937
+ return /* @__PURE__ */ jsxs13(Fragment6, { children: [
28014
27938
  /* @__PURE__ */ jsxs13("div", { className: "flex shrink-0 items-center gap-1.5 rounded-full border border-[hsl(var(--border))] bg-[hsl(var(--accent))] px-2.5 py-1 text-[11px] text-[hsl(var(--foreground))]", children: [
28015
27939
  imageUrl ? /* @__PURE__ */ jsx24(
28016
27940
  "button",
@@ -28131,13 +28055,13 @@ function ChatInput({
28131
28055
  onBeforeSend,
28132
28056
  ensureSession,
28133
28057
  onCommand,
28134
- canShareSession = false,
28058
+ canShareSession: _canShareSession = false,
28135
28059
  slotAboveTextarea,
28136
28060
  slotBeforeSend,
28137
28061
  planPanel,
28138
28062
  externalDraft,
28139
28063
  externalAttachments,
28140
- maxWidthClassName = "max-w-3xl",
28064
+ maxWidthClassName = "max-w-[var(--blade-chat-width,780px)]",
28141
28065
  mergesWithPanelAbove = false,
28142
28066
  className,
28143
28067
  innerClassName,
@@ -28171,7 +28095,7 @@ function ChatInput({
28171
28095
  inputRef.current = input;
28172
28096
  const appliedInitialDraftKeyRef = useRef7(null);
28173
28097
  const appliedInitialDraftRef = useRef7(null);
28174
- useEffect8(() => {
28098
+ useEffect9(() => {
28175
28099
  if (externalDraftValue == null) return;
28176
28100
  if (inputRef.current === externalDraftValue) return;
28177
28101
  if (editorRef.current) {
@@ -28179,7 +28103,7 @@ function ChatInput({
28179
28103
  }
28180
28104
  setInputInternal(externalDraftValue);
28181
28105
  }, [externalDraftValue]);
28182
- useEffect8(() => {
28106
+ useEffect9(() => {
28183
28107
  const key = initialDraftKey ?? initialDraft ?? "";
28184
28108
  if (!initialDraft || !key || appliedInitialDraftKeyRef.current === key) return;
28185
28109
  if (inputRef.current === initialDraft) appliedInitialDraftRef.current = initialDraft;
@@ -28207,7 +28131,7 @@ function ChatInput({
28207
28131
  const externalAttachmentsValue = externalAttachments?.value;
28208
28132
  const composerAttachmentsRef = useRef7(composerAttachments);
28209
28133
  composerAttachmentsRef.current = composerAttachments;
28210
- useEffect8(() => {
28134
+ useEffect9(() => {
28211
28135
  if (externalAttachmentsValue == null) return;
28212
28136
  if (composerAttachmentsRef.current === externalAttachmentsValue) return;
28213
28137
  setComposerAttachmentsInternal(externalAttachmentsValue);
@@ -28221,11 +28145,13 @@ function ChatInput({
28221
28145
  const invalidation = useSessionDataInvalidation();
28222
28146
  const SkillStatusBarComponent = SkillStatusBarOverride ?? SkillStatusBar;
28223
28147
  const [actionMenuOpen, setActionMenuOpen] = useState11(false);
28148
+ const [bannerModelPickerOpen, setBannerModelPickerOpen] = useState11(false);
28224
28149
  const actionMenuOpenRef = useRef7(false);
28225
- useEffect8(() => {
28150
+ useEffect9(() => {
28226
28151
  actionMenuOpenRef.current = actionMenuOpen;
28227
28152
  }, [actionMenuOpen]);
28228
28153
  const [connectMenuOpen, setConnectMenuOpen] = useState11(false);
28154
+ const [moreOptionsOpen, setMoreOptionsOpen] = useState11(false);
28229
28155
  const fileInputRef = useRef7(null);
28230
28156
  const folderInputRef = useRef7(null);
28231
28157
  const editorRef = useRef7(null);
@@ -28245,20 +28171,20 @@ function ChatInput({
28245
28171
  isLoading: isModelLoading
28246
28172
  } = model;
28247
28173
  const rewindDraft = useComposerChannels(
28248
- (state3) => activeSessionId ? state3.rewindDrafts[activeSessionId] : void 0
28174
+ (state) => activeSessionId ? state.rewindDrafts[activeSessionId] : void 0
28249
28175
  );
28250
28176
  const pendingContexts = useComposerChannels(
28251
- (state3) => activeSessionId ? state3.pendingContexts[activeSessionId] : void 0
28177
+ (state) => activeSessionId ? state.pendingContexts[activeSessionId] : void 0
28252
28178
  );
28253
28179
  const draftAppends = useComposerChannels(
28254
- (state3) => activeSessionId ? state3.draftAppends[activeSessionId] : void 0
28180
+ (state) => activeSessionId ? state.draftAppends[activeSessionId] : void 0
28255
28181
  );
28256
28182
  const sendRequests = useComposerChannels(
28257
- (state3) => activeSessionId ? state3.sendRequests[activeSessionId] : void 0
28183
+ (state) => activeSessionId ? state.sendRequests[activeSessionId] : void 0
28258
28184
  );
28259
28185
  const connectionStatus = useComposerConnection(activeSessionId);
28260
28186
  const inputHistory = useInputHistory(activeSessionId, client);
28261
- const queuedTopicRefs = useComposerChannels((state3) => activeSessionId ? state3.topicAssetReferences[activeSessionId] : void 0);
28187
+ const queuedTopicRefs = useComposerChannels((state) => activeSessionId ? state.topicAssetReferences[activeSessionId] : void 0);
28262
28188
  const getTopicSuggestions = useEffectEvent(async (query) => {
28263
28189
  if (!activeSessionId) return [];
28264
28190
  try {
@@ -28284,7 +28210,7 @@ function ChatInput({
28284
28210
  const skillItems = await getSlashSuggestions(query, {
28285
28211
  client,
28286
28212
  sessionId: getSessionId(),
28287
- renderMode: environment.renderMode ?? "normal"
28213
+ renderMode: environment.includeBuiltinSkills ? "developer" : environment.renderMode ?? "normal"
28288
28214
  }).catch(() => []);
28289
28215
  return skillItems;
28290
28216
  }
@@ -28534,7 +28460,7 @@ function ChatInput({
28534
28460
  "aria-label": resolvedInputLabel,
28535
28461
  "data-testid": "chat-message-input",
28536
28462
  "data-blade-input-label": resolvedInputLabel,
28537
- class: "min-h-[34px] max-h-[240px] overflow-y-auto px-5 py-3 text-sm leading-relaxed text-[hsl(var(--foreground))] focus:outline-none [&_.file-mention-pill]:inline-flex [&_.file-mention-pill]:items-center [&_.file-mention-pill]:rounded-full [&_.file-mention-pill]:bg-[hsl(var(--accent))] [&_.file-mention-pill]:px-2 [&_.file-mention-pill]:py-0.5 [&_.file-mention-pill]:font-medium [&_.file-mention-pill]:text-[hsl(var(--primary))] [&_.file-mention-pill]:select-none [&_.file-mention-pill]:whitespace-nowrap [&_.skill-mention-pill]:inline-flex [&_.skill-mention-pill]:items-center [&_.skill-mention-pill]:rounded-full [&_.skill-mention-pill]:bg-[hsl(var(--primary)/0.15)] [&_.skill-mention-pill]:px-2 [&_.skill-mention-pill]:py-0.5 [&_.skill-mention-pill]:font-medium [&_.skill-mention-pill]:text-[hsl(var(--primary))] [&_.skill-mention-pill]:select-none [&_.skill-mention-pill]:whitespace-nowrap [&_p:first-child]:mt-0 [&_p:last-child]:mb-0"
28463
+ class: "min-h-[36px] max-h-[220px] overflow-y-auto px-2 py-1.5 text-[15px] leading-6 text-[hsl(var(--foreground))] focus:outline-none [&_.file-mention-pill]:inline-flex [&_.file-mention-pill]:items-center [&_.file-mention-pill]:rounded-full [&_.file-mention-pill]:bg-[hsl(var(--accent))] [&_.file-mention-pill]:px-2 [&_.file-mention-pill]:py-0.5 [&_.file-mention-pill]:font-medium [&_.file-mention-pill]:text-[hsl(var(--primary))] [&_.file-mention-pill]:select-none [&_.file-mention-pill]:whitespace-nowrap [&_.skill-mention-pill]:inline-flex [&_.skill-mention-pill]:items-center [&_.skill-mention-pill]:rounded-full [&_.skill-mention-pill]:bg-[hsl(var(--primary)/0.15)] [&_.skill-mention-pill]:px-2 [&_.skill-mention-pill]:py-0.5 [&_.skill-mention-pill]:font-medium [&_.skill-mention-pill]:text-[hsl(var(--primary))] [&_.skill-mention-pill]:select-none [&_.skill-mention-pill]:whitespace-nowrap [&_p:first-child]:mt-0 [&_p:last-child]:mb-0"
28538
28464
  },
28539
28465
  handleDOMEvents: {
28540
28466
  focus: () => {
@@ -28546,7 +28472,7 @@ function ChatInput({
28546
28472
  return false;
28547
28473
  },
28548
28474
  keydown: (_view, event) => {
28549
- const state3 = getEditorState();
28475
+ const state = getEditorState();
28550
28476
  const fileMentionState = editorRef.current ? fileMentionSuggestionKey.getState(editorRef.current.view.state) : void 0;
28551
28477
  if (fileMentionState?.active) {
28552
28478
  return false;
@@ -28556,33 +28482,33 @@ function ChatInput({
28556
28482
  return false;
28557
28483
  }
28558
28484
  const actionMenuOpen2 = actionMenuOpenRef.current;
28559
- if (shouldHandleHistoryKey(event, actionMenuOpen2) && event.key === "ArrowUp" && (state3.input.trim().length === 0 || state3.isNavigatingHistory)) {
28560
- const previousEntry = state3.navigateUp(editorRef.current?.getJSON());
28485
+ if (shouldHandleHistoryKey(event, actionMenuOpen2) && event.key === "ArrowUp" && (state.input.trim().length === 0 || state.isNavigatingHistory)) {
28486
+ const previousEntry = state.navigateUp(editorRef.current?.getJSON());
28561
28487
  if (!previousEntry) {
28562
28488
  return false;
28563
28489
  }
28564
28490
  event.preventDefault();
28565
- editorRef.current?.commands.setContent(retainTopicAssetMentions(previousEntry.document, state3.topicId));
28491
+ editorRef.current?.commands.setContent(retainTopicAssetMentions(previousEntry.document, state.topicId));
28566
28492
  editorRef.current?.commands.focus("end");
28567
28493
  return true;
28568
28494
  }
28569
28495
  if (shouldHandleHistoryKey(event, actionMenuOpen2) && event.key === "ArrowDown") {
28570
- const nextEntry = state3.navigateDown();
28496
+ const nextEntry = state.navigateDown();
28571
28497
  if (nextEntry == null) {
28572
28498
  return false;
28573
28499
  }
28574
28500
  event.preventDefault();
28575
- editorRef.current?.commands.setContent(retainTopicAssetMentions(nextEntry.document, state3.topicId));
28501
+ editorRef.current?.commands.setContent(retainTopicAssetMentions(nextEntry.document, state.topicId));
28576
28502
  editorRef.current?.commands.focus("end");
28577
28503
  return true;
28578
28504
  }
28579
- if (state3.onDoubleEscape && event.key === "Escape" && !isImeCompositionKey(event) && !event.repeat) {
28505
+ if (state.onDoubleEscape && event.key === "Escape" && !isImeCompositionKey(event) && !event.repeat) {
28580
28506
  const now = Date.now();
28581
28507
  if (now - lastEscapeAtRef.current <= DOUBLE_ESCAPE_MS) {
28582
28508
  lastEscapeAtRef.current = 0;
28583
28509
  event.preventDefault();
28584
28510
  const rect = editorRef.current?.view.dom.getBoundingClientRect() ?? null;
28585
- state3.onDoubleEscape(rect);
28511
+ state.onDoubleEscape(rect);
28586
28512
  return true;
28587
28513
  }
28588
28514
  lastEscapeAtRef.current = now;
@@ -28590,10 +28516,10 @@ function ChatInput({
28590
28516
  }
28591
28517
  if (shouldSubmitChatInput(event, actionMenuOpen2)) {
28592
28518
  event.preventDefault();
28593
- if (state3.connectionStatus !== "connected") {
28519
+ if (state.connectionStatus !== "connected") {
28594
28520
  return true;
28595
28521
  }
28596
- void state3.handleSubmit(isQueueShortcut(event));
28522
+ void state.handleSubmit(isQueueShortcut(event));
28597
28523
  return true;
28598
28524
  }
28599
28525
  return false;
@@ -28610,13 +28536,13 @@ function ChatInput({
28610
28536
  }
28611
28537
  });
28612
28538
  useDismissSkillSuggestionsOnModeChange(editor);
28613
- useEffect8(() => {
28539
+ useEffect9(() => {
28614
28540
  const dom = editor?.view.dom;
28615
28541
  if (!dom) return;
28616
28542
  dom.setAttribute("aria-label", resolvedInputLabel);
28617
28543
  dom.setAttribute("data-blade-input-label", resolvedInputLabel);
28618
28544
  }, [editor, resolvedInputLabel]);
28619
- useEffect8(() => {
28545
+ useEffect9(() => {
28620
28546
  if (!editor || !activeSessionId || rewindDraft == null) {
28621
28547
  return;
28622
28548
  }
@@ -28629,7 +28555,7 @@ function ChatInput({
28629
28555
  }, [activeSessionId, editor, rewindDraft]);
28630
28556
  const submittingRef = useRef7(false);
28631
28557
  const [isSubmitting, setIsSubmitting] = useState11(false);
28632
- useEffect8(() => {
28558
+ useEffect9(() => {
28633
28559
  let changed = false;
28634
28560
  const nextLocalIds = /* @__PURE__ */ new Set();
28635
28561
  for (const attachment of composerAttachments) {
@@ -28654,7 +28580,7 @@ function ChatInput({
28654
28580
  setLocalImageUrls(Object.fromEntries(localImageUrlsRef.current));
28655
28581
  }
28656
28582
  }, [composerAttachments]);
28657
- useEffect8(() => {
28583
+ useEffect9(() => {
28658
28584
  return () => {
28659
28585
  for (const url of localImageUrlsRef.current.values()) {
28660
28586
  URL.revokeObjectURL(url);
@@ -28664,7 +28590,7 @@ function ChatInput({
28664
28590
  }, []);
28665
28591
  const sessionHandle = useSessionHandle(activeSessionId);
28666
28592
  const restoredPluginSelection = useRef7(null);
28667
- useEffect8(() => {
28593
+ useEffect9(() => {
28668
28594
  if (!sessionHandle || !activeSessionId || !editor) return;
28669
28595
  const restore = () => {
28670
28596
  if (restoredPluginSelection.current === activeSessionId) return;
@@ -28679,7 +28605,7 @@ function ChatInput({
28679
28605
  restore();
28680
28606
  return sessionHandle.subscribe(restore);
28681
28607
  }, [sessionHandle, activeSessionId, editor]);
28682
- useEffect8(() => {
28608
+ useEffect9(() => {
28683
28609
  if (!sessionHandle || !activeSessionId) return;
28684
28610
  const offInsert = sessionHandle.on("insertTextRequested", ({ text }) => {
28685
28611
  const separate = /^\n/.test(text);
@@ -28714,7 +28640,7 @@ ${append2.text}` : append2.text;
28714
28640
  editor.chain().focus("end").insertContent(text).run();
28715
28641
  });
28716
28642
  const editorReady = editor != null;
28717
- useEffect8(() => {
28643
+ useEffect9(() => {
28718
28644
  if (!editorReady || !draftAppends?.length) {
28719
28645
  return;
28720
28646
  }
@@ -28730,7 +28656,7 @@ ${append2.text}` : append2.text;
28730
28656
  }
28731
28657
  void stableHandleSubmit();
28732
28658
  });
28733
- useEffect8(() => {
28659
+ useEffect9(() => {
28734
28660
  if (!sendRequests?.length) {
28735
28661
  return;
28736
28662
  }
@@ -28748,7 +28674,7 @@ ${append2.text}` : append2.text;
28748
28674
  const voiceStopRef = useRef7(voice.stop);
28749
28675
  voiceStopRef.current = voice.stop;
28750
28676
  const prevSessionIdRef = useRef7(activeSessionId);
28751
- useEffect8(() => {
28677
+ useEffect9(() => {
28752
28678
  if (prevSessionIdRef.current !== activeSessionId) {
28753
28679
  prevSessionIdRef.current = activeSessionId;
28754
28680
  if (isRecording) {
@@ -28760,7 +28686,7 @@ ${append2.text}` : append2.text;
28760
28686
  const json = editor?.getJSON();
28761
28687
  return composerAttachments.length > 0 || collectMessageMentions(json).length > 0 || collectTopicAssetMentions(json).length > 0;
28762
28688
  };
28763
- const handleSubmit = async (queueWhenRunning = false) => {
28689
+ const handleSubmit = async (queueWhenRunning = false, overrideText) => {
28764
28690
  if (connectionStatus !== "connected") {
28765
28691
  return;
28766
28692
  }
@@ -28780,7 +28706,8 @@ ${append2.text}` : append2.text;
28780
28706
  return;
28781
28707
  }
28782
28708
  if (!isStreaming) {
28783
- const modelGate = gateSendWhileModelLoading(isModelLoading, hasComposerContent);
28709
+ const hasEffectiveContent = hasComposerContent || Boolean(overrideText?.trim());
28710
+ const modelGate = gateSendWhileModelLoading(isModelLoading, hasEffectiveContent);
28784
28711
  if (modelGate.blocked) {
28785
28712
  if (modelGate.hint) notifyChat(environment, "info", modelGate.hint);
28786
28713
  return;
@@ -28816,7 +28743,7 @@ ${append2.text}` : append2.text;
28816
28743
  notifyChat(environment, "error", "\u6BCF\u6761\u6D88\u606F\u6700\u591A\u5F15\u7528 20 \u4E2A\u5DE5\u4F5C\u7A7A\u95F4\u8D44\u4EA7");
28817
28744
  return;
28818
28745
  }
28819
- const text = rawText;
28746
+ const text = overrideText ?? rawText;
28820
28747
  const pendingFiles = composerAttachments.filter(
28821
28748
  (a) => a.kind === "file" && a.status === "pending" && !!a.file
28822
28749
  );
@@ -28915,12 +28842,18 @@ ${append2.text}` : append2.text;
28915
28842
  }
28916
28843
  }
28917
28844
  const activePendingContexts = pendingContexts ?? [];
28918
- const nextPayload = await buildSubmitPayload(
28919
- text,
28920
- updatedAttachments,
28921
- activePendingContexts,
28922
- onBeforeSend
28923
- );
28845
+ let nextPayload;
28846
+ try {
28847
+ nextPayload = await buildSubmitPayload(
28848
+ text,
28849
+ updatedAttachments,
28850
+ activePendingContexts,
28851
+ onBeforeSend
28852
+ );
28853
+ } catch (error) {
28854
+ notifyChat(environment, "error", error instanceof Error ? error.message : "\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
28855
+ return;
28856
+ }
28924
28857
  if (isMessageContentEmpty(nextPayload)) {
28925
28858
  return;
28926
28859
  }
@@ -28943,7 +28876,7 @@ ${append2.text}` : append2.text;
28943
28876
  resetComposer();
28944
28877
  return true;
28945
28878
  };
28946
- const composerWasReset = resetSubmittedComposer();
28879
+ const composerWasReset = overrideText ? false : resetSubmittedComposer();
28947
28880
  let accepted;
28948
28881
  try {
28949
28882
  accepted = await onSend(nextPayload, {
@@ -28974,7 +28907,7 @@ ${append2.text}` : append2.text;
28974
28907
  if (activeSessionId && activePendingContexts.length > 0) {
28975
28908
  composerChannels.consumePendingContexts(activeSessionId);
28976
28909
  }
28977
- if (text.trim()) {
28910
+ if (!overrideText && text.trim()) {
28978
28911
  inputHistory.addEntry(json);
28979
28912
  }
28980
28913
  } finally {
@@ -28982,7 +28915,7 @@ ${append2.text}` : append2.text;
28982
28915
  setIsSubmitting(false);
28983
28916
  }
28984
28917
  };
28985
- useEffect8(() => {
28918
+ useEffect9(() => {
28986
28919
  if (!editor || !activeSessionId || !queuedTopicRefs?.length) return;
28987
28920
  const existing = collectTopicAssetMentions(editor.getJSON());
28988
28921
  const refs = composerChannels.consumeTopicAssetReferences(activeSessionId).filter((ref) => !existing.some((item) => item.topic_id === ref.topic_id && item.path === ref.path));
@@ -28996,7 +28929,7 @@ ${append2.text}` : append2.text;
28996
28929
  };
28997
28930
  const [showAddContext, setShowAddContext] = useState11(false);
28998
28931
  const isPlanning = mode === "planning";
28999
- const fullPlaceholder = isPlanning ? "\u89C4\u5212\u8FDB\u884C\u4E2D\u2026 \u53EF\u8F93\u5165\u8865\u5145\u9700\u6C42\u6216\u7B49\u5F85\u5B8C\u6210" : placeholderText ?? "\u8F93\u5165 / \u8C03\u7528\u6280\u80FD\uFF0C\u8F93\u5165 @ \u5F15\u7528\u6587\u4EF6\u2026";
28932
+ const fullPlaceholder = isPlanning ? "\u89C4\u5212\u8FDB\u884C\u4E2D\u2026 \u53EF\u8F93\u5165\u8865\u5145\u9700\u6C42\u6216\u7B49\u5F85\u5B8C\u6210" : placeholderText ?? "\u6D88\u606F";
29000
28933
  const [typedPlaceholder, setTypedPlaceholder] = useState11(() => {
29001
28934
  if (!typewriterPlaceholder) return fullPlaceholder;
29002
28935
  const reduceMotion = typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
@@ -29004,7 +28937,7 @@ ${append2.text}` : append2.text;
29004
28937
  });
29005
28938
  const typewriterPlayedRef = useRef7(false);
29006
28939
  const isTypingRef = useRef7(false);
29007
- useEffect8(() => {
28940
+ useEffect9(() => {
29008
28941
  if (!typewriterPlaceholder || typewriterPlayedRef.current) return;
29009
28942
  typewriterPlayedRef.current = true;
29010
28943
  const reduceMotion = typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
@@ -29025,7 +28958,7 @@ ${append2.text}` : append2.text;
29025
28958
  isTypingRef.current = false;
29026
28959
  };
29027
28960
  }, [typewriterPlaceholder]);
29028
- useEffect8(() => {
28961
+ useEffect9(() => {
29029
28962
  if (isTypingRef.current) return;
29030
28963
  setTypedPlaceholder(fullPlaceholder);
29031
28964
  }, [fullPlaceholder]);
@@ -29045,11 +28978,35 @@ ${append2.text}` : append2.text;
29045
28978
  const submitWhileRunning = isStreaming && !isStopping && queueWhileRunning;
29046
28979
  const hasComposerContent = Boolean(input.trim()) || hasValidAttachments || hasRenderedAttachments || hasPendingContexts;
29047
28980
  const isSendDisabled = connectionStatus !== "connected" || isCompacting || !submitWhileRunning && isModelLoading || !submitWhileRunning && !hasAvailableModel || isSubmitting || hasUploadingFiles || !input.trim() && !hasValidAttachments && !hasRenderedAttachments && !hasPendingContexts;
28981
+ const hasRecoverableLastTurn = useSessionState(activeSessionId ?? "", (state) => {
28982
+ const last = state.messages.at(-1);
28983
+ return Boolean(
28984
+ last && last.role === "assistant" && (last.status === "interrupted" || last.status === "failed")
28985
+ );
28986
+ });
28987
+ const canContinueGeneration = Boolean(activeSessionId) && hasRecoverableLastTurn && !isStreaming && !isCompacting && !hasComposerContent && !isRecording && !isSubmitting && connectionStatus === "connected" && !isModelLoading && hasAvailableModel;
28988
+ const hasMoreOptions = !lite;
29048
28989
  const showQueueShortcut = Boolean(input.trim()) && !isSendDisabled && !isStopping && !isRecording && (!isStreaming || queueWhileRunning && !hasRunningSendBlockers());
29049
- return /* @__PURE__ */ jsxs13(Fragment5, { children: [
28990
+ return /* @__PURE__ */ jsxs13(Fragment6, { children: [
29050
28991
  /* @__PURE__ */ jsx24("div", { className: `px-5 pb-3 pt-0 ${className ?? ""}`, children: /* @__PURE__ */ jsxs13("div", { className: `mx-auto ${maxWidthClassName} ${innerClassName ?? ""}`, children: [
29051
- statusBarAddon ? /* @__PURE__ */ jsx24("div", { className: "mb-2 flex flex-wrap items-center gap-2", children: statusBarAddon }) : null,
29052
- !isModelLoading && !hasAvailableModel ? /* @__PURE__ */ jsx24("div", { className: "mb-2 rounded-lg border border-[hsl(var(--destructive))]/30 bg-[hsl(var(--destructive))]/8 px-3 py-2 text-xs text-[hsl(var(--destructive))]", children: modelAvailabilityMessage }) : null,
28992
+ statusBarAddon || !lite && activeSessionId ? /* @__PURE__ */ jsxs13("div", { className: "mb-2 flex flex-wrap items-center gap-2 empty:mb-0", children: [
28993
+ statusBarAddon,
28994
+ !lite && activeSessionId ? /* @__PURE__ */ jsx24(BackgroundTasksPill, { sessionId: activeSessionId }) : null
28995
+ ] }) : null,
28996
+ (!isModelLoading || bannerModelPickerOpen) && !hasAvailableModel ? /* @__PURE__ */ jsxs13("div", { className: "mb-2 flex items-center justify-between gap-3 rounded-xl border border-[hsl(var(--destructive))]/30 bg-[hsl(var(--destructive))]/8 px-3 py-1.5 text-xs text-[hsl(var(--destructive))]", children: [
28997
+ /* @__PURE__ */ jsx24("span", { className: "min-w-0 flex-1 leading-5", children: modelAvailabilityMessage || "\u6A21\u578B\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u6216\u91CD\u65B0\u9009\u62E9\u6A21\u578B" }),
28998
+ /* @__PURE__ */ jsx24(
28999
+ ModelSelector,
29000
+ {
29001
+ variant: "banner",
29002
+ disabled: isModelLoading && !bannerModelPickerOpen,
29003
+ value: selectedModel,
29004
+ onValueChange: model.selectModel,
29005
+ onOpenChange: setBannerModelPickerOpen,
29006
+ placement: "top"
29007
+ }
29008
+ )
29009
+ ] }) : null,
29053
29010
  /* @__PURE__ */ jsx24(
29054
29011
  "div",
29055
29012
  {
@@ -29087,9 +29044,9 @@ ${append2.text}` : append2.text;
29087
29044
  children: /* @__PURE__ */ jsxs13(
29088
29045
  "div",
29089
29046
  {
29090
- className: `overflow-visible border bg-[hsl(var(--card))] transition-[box-shadow,border-color] duration-300 ${mergesWithPanelAbove ? "rounded-b-[22px]" : "rounded-[22px]"} ${isRecording ? "border-[hsl(var(--swf-success))]!" : isPlanning ? dragging || isEditorFocused ? "border-[hsl(var(--swf-warning)/0.6)]" : "border-[hsl(var(--swf-warning)/0.3)]" : dragging || isEditorFocused ? "border-[hsl(213_94%_60%/0.55)] shadow-[0_0_0_3px_hsl(213_94%_60%/0.16),0_8px_24px_-6px_hsl(213_94%_60%/0.3)]" : "border-[hsl(213_94%_60%/0.28)] shadow-[0_0_0_2px_hsl(213_94%_60%/0.08),0_4px_14px_-6px_hsl(213_94%_60%/0.16)]"}`,
29047
+ className: `overflow-visible border bg-[hsl(var(--card))] transition-[box-shadow,border-color] duration-200 ${mergesWithPanelAbove ? "rounded-b-[28px]" : "rounded-[28px]"} ${isRecording ? "border-[hsl(var(--swf-success))]!" : isPlanning ? dragging || isEditorFocused ? "border-[hsl(var(--swf-warning)/0.6)]" : "border-[hsl(var(--swf-warning)/0.3)]" : dragging || isEditorFocused ? "border-[hsl(var(--primary)/0.45)] shadow-[0_2px_16px_-4px_hsl(var(--foreground)/0.1)]" : "border-[hsl(var(--border)/0.85)] shadow-xs"}`,
29091
29048
  children: [
29092
- dragging && /* @__PURE__ */ jsx24("div", { className: `pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-[hsl(var(--primary)/0.06)] ${mergesWithPanelAbove ? "rounded-b-[22px]" : "rounded-2xl"}`, children: /* @__PURE__ */ jsx24("span", { className: "rounded-full bg-[hsl(var(--primary)/0.12)] px-4 py-2 text-sm font-medium text-[hsl(var(--primary))]", children: "\u677E\u624B\u5F15\u7528\u6587\u4EF6" }) }),
29049
+ dragging && /* @__PURE__ */ jsx24("div", { className: `pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-[hsl(var(--primary)/0.06)] ${mergesWithPanelAbove ? "rounded-b-[28px]" : "rounded-[28px]"}`, children: /* @__PURE__ */ jsx24("span", { className: "rounded-full bg-[hsl(var(--primary)/0.12)] px-4 py-2 text-sm font-medium text-[hsl(var(--primary))]", children: "\u677E\u624B\u5F15\u7528\u6587\u4EF6" }) }),
29093
29050
  planPanel,
29094
29051
  composerAttachments.length > 0 && /* @__PURE__ */ jsxs13(ComposerAttachmentViewport, { className: "flex flex-col gap-2 border-b border-[hsl(var(--border))] px-4 py-2", children: [
29095
29052
  imageAttachments.length > 0 && /* @__PURE__ */ jsx24("div", { className: "grid grid-cols-3 gap-2", children: imageAttachments.map((attachment) => /* @__PURE__ */ jsxs13(
@@ -29171,12 +29128,8 @@ ${append2.text}` : append2.text;
29171
29128
  ),
29172
29129
  attachments ? /* @__PURE__ */ jsx24("div", { className: "border-b border-[hsl(var(--border))] px-4 py-3", children: attachments }) : null,
29173
29130
  slotAboveTextarea ? /* @__PURE__ */ jsx24("div", { className: "border-b border-[hsl(var(--border))] px-4 py-2", children: slotAboveTextarea }) : null,
29174
- /* @__PURE__ */ jsxs13("div", { className: "relative", children: [
29175
- input.length === 0 && /* @__PURE__ */ jsx24("div", { className: "pointer-events-none absolute left-5 top-3 text-sm leading-relaxed text-[hsl(var(--muted-foreground)/0.6)]", children: placeholder }),
29176
- /* @__PURE__ */ jsx24(EditorContent, { editor })
29177
- ] }),
29178
- /* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-between px-4 pb-3 pt-1", children: [
29179
- /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
29131
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-end gap-1.5 px-2.5 py-2", children: [
29132
+ /* @__PURE__ */ jsxs13("div", { className: "flex shrink-0 items-center self-end", children: [
29180
29133
  /* @__PURE__ */ jsx24(
29181
29134
  "input",
29182
29135
  {
@@ -29215,7 +29168,10 @@ ${append2.text}` : append2.text;
29215
29168
  open: actionMenuOpen,
29216
29169
  onOpenChange: (open) => {
29217
29170
  setActionMenuOpen(open);
29218
- if (open) setConnectMenuOpen(false);
29171
+ if (!open) {
29172
+ setConnectMenuOpen(false);
29173
+ setMoreOptionsOpen(false);
29174
+ }
29219
29175
  },
29220
29176
  children: [
29221
29177
  /* @__PURE__ */ jsx24(dist_exports.Trigger, { asChild: true, children: /* @__PURE__ */ jsx24(
@@ -29224,8 +29180,8 @@ ${append2.text}` : append2.text;
29224
29180
  type: "button",
29225
29181
  "aria-label": "\u6DFB\u52A0\u5185\u5BB9",
29226
29182
  title: "\u6DFB\u52A0\u5185\u5BB9",
29227
- className: "flex h-9 w-9 shrink-0 cursor-pointer items-center justify-center rounded-full border border-[hsl(var(--border))] text-[hsl(var(--muted-foreground))] transition-colors hover:border-[hsl(var(--ring))] hover:text-[hsl(var(--foreground))]",
29228
- children: /* @__PURE__ */ jsx24(Plus, { size: 14 })
29183
+ className: "flex h-9 w-9 shrink-0 cursor-pointer items-center justify-center rounded-full text-[hsl(var(--muted-foreground))] transition-colors hover:bg-[hsl(var(--accent))] hover:text-[hsl(var(--foreground))] data-[state=open]:bg-[hsl(var(--accent))] data-[state=open]:text-[hsl(var(--foreground))]",
29184
+ children: /* @__PURE__ */ jsx24(Plus, { size: 20, strokeWidth: 1.85 })
29229
29185
  }
29230
29186
  ) }),
29231
29187
  /* @__PURE__ */ jsx24(dist_exports.Portal, { children: /* @__PURE__ */ jsxs13(
@@ -29234,7 +29190,7 @@ ${append2.text}` : append2.text;
29234
29190
  side: "top",
29235
29191
  align: "start",
29236
29192
  sideOffset: 8,
29237
- className: "z-30 w-[min(380px,calc(100vw-2rem))] origin-(--radix-popover-content-transform-origin) overflow-visible rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--popover))] py-1 text-[11px] text-[hsl(var(--popover-foreground))] shadow-[var(--swf-shadow-overlay)] outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
29193
+ className: "z-30 w-[min(240px,calc(100vw-2rem))] origin-(--radix-popover-content-transform-origin) overflow-visible rounded-2xl border border-[hsl(var(--border))] bg-[hsl(var(--popover))] p-1.5 text-sm text-[hsl(var(--popover-foreground))] shadow-[var(--swf-shadow-overlay)] outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
29238
29194
  children: [
29239
29195
  /* @__PURE__ */ jsxs13(
29240
29196
  "button",
@@ -29244,9 +29200,9 @@ ${append2.text}` : append2.text;
29244
29200
  setActionMenuOpen(false);
29245
29201
  fileInputRef.current?.click();
29246
29202
  },
29247
- className: "flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[hsl(var(--accent))]",
29203
+ className: "flex w-full items-center gap-2 rounded-lg px-3 py-2.5 text-left text-sm transition-colors hover:bg-[hsl(var(--accent))]",
29248
29204
  children: [
29249
- /* @__PURE__ */ jsx24(Paperclip, { size: 14 }),
29205
+ /* @__PURE__ */ jsx24(Paperclip, { size: 16 }),
29250
29206
  "\u4E0A\u4F20\u6587\u4EF6"
29251
29207
  ]
29252
29208
  }
@@ -29259,224 +29215,120 @@ ${append2.text}` : append2.text;
29259
29215
  setActionMenuOpen(false);
29260
29216
  folderInputRef.current?.click();
29261
29217
  },
29262
- className: "flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[hsl(var(--accent))]",
29218
+ className: "flex w-full items-center gap-2 rounded-lg px-3 py-2.5 text-left text-sm transition-colors hover:bg-[hsl(var(--accent))]",
29263
29219
  children: [
29264
- /* @__PURE__ */ jsx24(FolderUp, { size: 14 }),
29220
+ /* @__PURE__ */ jsx24(FolderUp, { size: 16 }),
29265
29221
  "\u4E0A\u4F20\u6587\u4EF6\u5939"
29266
29222
  ]
29267
29223
  }
29268
29224
  ),
29269
- onCommand && canCreateBoardTask && !lite ? /* @__PURE__ */ jsxs13(
29270
- "button",
29225
+ /* @__PURE__ */ jsx24(
29226
+ ConnectButton,
29271
29227
  {
29272
- type: "button",
29273
- onClick: () => {
29274
- setActionMenuOpen(false);
29275
- void onCommand("create_board_task");
29276
- },
29277
- className: "flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[hsl(var(--accent))]",
29278
- children: [
29279
- /* @__PURE__ */ jsx24(ListPlus, { size: 14 }),
29280
- "\u521B\u5EFA\u540E\u53F0\u4EFB\u52A1"
29281
- ]
29282
- }
29283
- ) : null,
29284
- onCommand && !lite ? /* @__PURE__ */ jsxs13(
29285
- "button",
29286
- {
29287
- type: "button",
29288
- onClick: () => {
29289
- setActionMenuOpen(false);
29290
- void onCommand("open_message_outline");
29291
- },
29292
- className: "flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[hsl(var(--accent))]",
29293
- children: [
29294
- /* @__PURE__ */ jsx24(ListTree, { size: 14 }),
29295
- "\u6D88\u606F\u8109\u7EDC"
29296
- ]
29297
- }
29298
- ) : null,
29299
- onDoubleEscape ? /* @__PURE__ */ jsxs13(
29300
- "button",
29301
- {
29302
- type: "button",
29303
- onClick: () => {
29304
- setActionMenuOpen(false);
29305
- onDoubleEscape(
29306
- editorRef.current?.view.dom.getBoundingClientRect() ?? null
29307
- );
29308
- },
29309
- className: "flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[hsl(var(--accent))]",
29310
- children: [
29311
- /* @__PURE__ */ jsx24(RotateCcw, { size: 14 }),
29312
- "\u56DE\u5230\u4E4B\u524D\u7684\u67D0\u4E00\u6B65"
29313
- ]
29314
- }
29315
- ) : null,
29316
- onCommand && !lite ? /* @__PURE__ */ jsxs13(Fragment5, { children: [
29317
- developer ? /* @__PURE__ */ jsxs13(
29318
- "button",
29319
- {
29320
- type: "button",
29321
- onClick: () => {
29322
- setActionMenuOpen(false);
29323
- void onCommand("compact");
29324
- },
29325
- disabled: isBusy,
29326
- className: "flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[hsl(var(--accent))] disabled:cursor-not-allowed disabled:opacity-50",
29327
- children: [
29328
- isCompacting ? /* @__PURE__ */ jsx24(LoaderCircle, { size: 14, className: "animate-spin" }) : /* @__PURE__ */ jsx24(Scissors, { size: 14 }),
29329
- "\u6574\u7406\u5BF9\u8BDD"
29330
- ]
29331
- }
29332
- ) : null,
29333
- /* @__PURE__ */ jsxs13(
29334
- "button",
29335
- {
29336
- type: "button",
29337
- onClick: () => {
29338
- setActionMenuOpen(false);
29339
- void onCommand("download_session");
29340
- },
29341
- className: "flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[hsl(var(--accent))]",
29342
- children: [
29343
- /* @__PURE__ */ jsx24(Download, { size: 14 }),
29344
- "\u5BFC\u51FA\u4F1A\u8BDD"
29345
- ]
29346
- }
29347
- ),
29348
- /* @__PURE__ */ jsxs13(
29349
- "button",
29350
- {
29351
- type: "button",
29352
- onClick: () => {
29353
- setActionMenuOpen(false);
29354
- void onCommand("replay_session");
29355
- },
29356
- className: "flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[hsl(var(--accent))]",
29357
- children: [
29358
- /* @__PURE__ */ jsx24(Play, { size: 14 }),
29359
- "\u56DE\u653E\u8FD9\u4E2A\u5BF9\u8BDD"
29360
- ]
29228
+ variant: "submenu",
29229
+ sessionId: activeSessionId,
29230
+ open: connectMenuOpen,
29231
+ onOpenChange: (open) => {
29232
+ setConnectMenuOpen(open);
29233
+ if (open) setMoreOptionsOpen(false);
29361
29234
  }
29362
- ),
29363
- canShareSession ? /* @__PURE__ */ jsxs13(
29364
- "button",
29365
- {
29366
- type: "button",
29367
- onClick: () => {
29368
- setActionMenuOpen(false);
29369
- void onCommand("share_session");
29370
- },
29371
- className: "flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[hsl(var(--accent))]",
29372
- children: [
29373
- /* @__PURE__ */ jsx24(Share2, { size: 14 }),
29374
- "\u5206\u4EAB\u4F1A\u8BDD"
29375
- ]
29376
- }
29377
- ) : null,
29378
- /* @__PURE__ */ jsxs13(
29379
- "button",
29380
- {
29381
- type: "button",
29382
- onClick: () => {
29383
- setActionMenuOpen(false);
29384
- void onCommand("extract_skill");
29385
- },
29386
- className: "flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[hsl(var(--accent))]",
29387
- children: [
29388
- /* @__PURE__ */ jsx24(FlaskConical, { size: 14 }),
29389
- "\u63D0\u53D6\u6280\u80FD"
29390
- ]
29391
- }
29392
- ),
29393
- /* @__PURE__ */ jsxs13(
29394
- "button",
29395
- {
29396
- type: "button",
29397
- onClick: () => {
29398
- setActionMenuOpen(false);
29399
- void onCommand("generate_app");
29400
- },
29401
- className: "flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[hsl(var(--accent))]",
29402
- children: [
29403
- /* @__PURE__ */ jsx24(Rocket, { size: 14 }),
29404
- "\u751F\u6210\u5E94\u7528"
29405
- ]
29406
- }
29407
- )
29408
- ] }) : null,
29409
- onToggleMode && !lite ? /* @__PURE__ */ jsx24(
29410
- PlanningToggle,
29411
- {
29412
- enabled: isPlanning,
29413
- onChange: () => {
29414
- setActionMenuOpen(false);
29415
- onToggleMode();
29416
- },
29417
- disabled: isBusy
29418
29235
  }
29419
- ) : null,
29420
- !lite && thinkingAvailable && reasoningLevels.length > 0 ? /* @__PURE__ */ jsx24(
29421
- ReasoningModeSelect,
29422
- {
29423
- level: selectedReasoningLevel,
29424
- levels: reasoningLevels,
29425
- disabled: isCompacting,
29426
- disabledReason: developer ? "\u5BF9\u8BDD\u6574\u7406\u5B8C\u6210\u540E\u53EF\u8C03\u6574" : "\u5904\u7406\u5B8C\u6210\u540E\u53EF\u8C03\u6574",
29427
- onChange: model.setReasoningLevel
29428
- }
29429
- ) : null,
29430
- !lite ? /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2 px-3 py-2", children: [
29431
- /* @__PURE__ */ jsx24(Sparkles, { size: 14, className: "shrink-0", "aria-hidden": "true" }),
29432
- /* @__PURE__ */ jsx24("span", { className: "shrink-0", children: "\u6A21\u578B" }),
29236
+ ),
29237
+ hasMoreOptions ? /* @__PURE__ */ jsxs13(Fragment6, { children: [
29238
+ /* @__PURE__ */ jsx24("div", { className: "my-1 h-px bg-[hsl(var(--border)/0.75)]" }),
29433
29239
  /* @__PURE__ */ jsx24(
29434
- ModelSelector,
29240
+ InputActionSubmenu,
29435
29241
  {
29436
- disabled: isModelLoading,
29437
- value: selectedModel,
29438
- onValueChange: model.selectModel,
29439
- compact: true,
29440
- placement: "top"
29242
+ label: "\u66F4\u591A\u9009\u9879",
29243
+ icon: /* @__PURE__ */ jsx24(SlidersHorizontal, { size: 16, "aria-hidden": "true" }),
29244
+ open: moreOptionsOpen,
29245
+ onOpenChange: (open) => {
29246
+ setMoreOptionsOpen(open);
29247
+ if (open) setConnectMenuOpen(false);
29248
+ },
29249
+ children: /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-0.5 py-0.5 text-xs", children: [
29250
+ onCommand && canCreateBoardTask && !lite ? /* @__PURE__ */ jsxs13(
29251
+ "button",
29252
+ {
29253
+ type: "button",
29254
+ onClick: () => {
29255
+ setMoreOptionsOpen(false);
29256
+ setActionMenuOpen(false);
29257
+ void onCommand("create_board_task");
29258
+ },
29259
+ className: "flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-xs transition-colors hover:bg-[hsl(var(--accent))]",
29260
+ children: [
29261
+ /* @__PURE__ */ jsx24(ListPlus, { size: 14, className: "shrink-0" }),
29262
+ /* @__PURE__ */ jsx24("span", { children: "\u521B\u5EFA\u540E\u53F0\u4EFB\u52A1" })
29263
+ ]
29264
+ }
29265
+ ) : null,
29266
+ onToggleMode ? /* @__PURE__ */ jsx24(
29267
+ PlanningToggle,
29268
+ {
29269
+ enabled: isPlanning,
29270
+ onChange: () => {
29271
+ setMoreOptionsOpen(false);
29272
+ setActionMenuOpen(false);
29273
+ onToggleMode();
29274
+ },
29275
+ disabled: isBusy
29276
+ }
29277
+ ) : null,
29278
+ thinkingAvailable && reasoningLevels.length > 0 ? /* @__PURE__ */ jsx24(
29279
+ ReasoningModeSelect,
29280
+ {
29281
+ level: selectedReasoningLevel,
29282
+ levels: reasoningLevels,
29283
+ disabled: isCompacting,
29284
+ disabledReason: developer ? "\u5BF9\u8BDD\u6574\u7406\u5B8C\u6210\u540E\u53EF\u8C03\u6574" : "\u5904\u7406\u5B8C\u6210\u540E\u53EF\u8C03\u6574",
29285
+ onChange: model.setReasoningLevel
29286
+ }
29287
+ ) : null,
29288
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2 rounded-lg px-3 py-2", children: [
29289
+ /* @__PURE__ */ jsx24(Sparkles, { size: 14, className: "shrink-0", "aria-hidden": "true" }),
29290
+ /* @__PURE__ */ jsx24("span", { className: "shrink-0", children: "\u6A21\u578B" }),
29291
+ /* @__PURE__ */ jsx24(
29292
+ ModelSelector,
29293
+ {
29294
+ disabled: isModelLoading,
29295
+ value: selectedModel,
29296
+ onValueChange: model.selectModel,
29297
+ compact: true,
29298
+ placement: "top"
29299
+ }
29300
+ )
29301
+ ] }),
29302
+ activeSessionId && moreOptionsOpen ? /* @__PURE__ */ jsxs13("div", { className: "border-t border-[hsl(var(--border))] px-3 py-2.5", children: [
29303
+ /* @__PURE__ */ jsx24(
29304
+ SkillStatusBarComponent,
29305
+ {
29306
+ sessionId: activeSessionId,
29307
+ onOpenSkills,
29308
+ vertical: true,
29309
+ className: skillStatusBarClassName,
29310
+ innerClassName: skillStatusBarInnerClassName
29311
+ }
29312
+ ),
29313
+ composerHint ? /* @__PURE__ */ jsx24("div", { className: "mt-2 border-t border-[hsl(var(--border))] pt-2 text-[hsl(var(--muted-foreground))]", children: composerHint }) : null
29314
+ ] }) : null
29315
+ ] })
29441
29316
  }
29442
29317
  )
29443
- ] }) : null,
29444
- !lite && activeSessionId && actionMenuOpen ? /* @__PURE__ */ jsxs13("div", { className: "border-t border-[hsl(var(--border))] px-3 py-2.5", children: [
29445
- /* @__PURE__ */ jsx24(
29446
- SkillStatusBarComponent,
29447
- {
29448
- sessionId: activeSessionId,
29449
- onOpenSkills,
29450
- vertical: true,
29451
- className: skillStatusBarClassName,
29452
- innerClassName: skillStatusBarInnerClassName
29453
- }
29454
- ),
29455
- composerHint ? /* @__PURE__ */ jsx24("div", { className: "mt-2 border-t border-[hsl(var(--border))] pt-2 text-[hsl(var(--muted-foreground))]", children: composerHint }) : null
29456
29318
  ] }) : null
29457
29319
  ]
29458
29320
  }
29459
29321
  ) })
29460
29322
  ]
29461
29323
  }
29462
- ),
29463
- /* @__PURE__ */ jsx24(
29464
- ConnectButton,
29465
- {
29466
- sessionId: activeSessionId,
29467
- open: connectMenuOpen,
29468
- onOpenChange: (open) => {
29469
- setConnectMenuOpen(open);
29470
- if (open) {
29471
- setActionMenuOpen(false);
29472
- }
29473
- }
29474
- }
29475
- ),
29476
- !lite && activeSessionId ? /* @__PURE__ */ jsx24(BackgroundTasksPill, { sessionId: activeSessionId }) : null
29324
+ )
29325
+ ] }),
29326
+ /* @__PURE__ */ jsxs13("div", { className: "relative min-w-0 flex-1 self-center", children: [
29327
+ input.length === 0 && /* @__PURE__ */ jsx24("div", { className: "pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 select-none truncate text-[15px] leading-6 text-[hsl(var(--muted-foreground)/0.65)]", children: placeholder }),
29328
+ /* @__PURE__ */ jsx24(EditorContent, { editor })
29477
29329
  ] }),
29478
- /* @__PURE__ */ jsxs13("div", { className: "flex min-h-10 items-center gap-1.5", children: [
29479
- showQueueShortcut && /* @__PURE__ */ jsxs13("span", { className: "mr-1 text-[11px] text-[hsl(var(--muted-foreground))]", children: [
29330
+ /* @__PURE__ */ jsxs13("div", { className: "flex shrink-0 items-center gap-1.5 self-end", children: [
29331
+ showQueueShortcut && /* @__PURE__ */ jsxs13("span", { className: "mr-1 hidden text-[11px] text-[hsl(var(--muted-foreground))] sm:inline", children: [
29480
29332
  queueShortcutLabel(),
29481
29333
  " \xB7 \u6392\u961F\u6D88\u606F"
29482
29334
  ] }),
@@ -29488,12 +29340,12 @@ ${append2.text}` : append2.text;
29488
29340
  onClick: voice.toggle,
29489
29341
  "aria-label": isRecording || isVoiceStarting ? "\u505C\u6B62\u8BED\u97F3\u8F93\u5165" : "\u5F00\u59CB\u8BED\u97F3\u8F93\u5165",
29490
29342
  title: isVoiceStarting ? "\u6B63\u5728\u8FDE\u63A5\u8BED\u97F3\u8F93\u5165\uFF0C\u70B9\u51FB\u53D6\u6D88" : isRecording ? "\u505C\u6B62\u8BED\u97F3\u8F93\u5165" : "\u8BED\u97F3\u8F93\u5165",
29491
- className: `flex items-center justify-center rounded-full transition-[width,height,background-color,color,box-shadow] duration-300 disabled:opacity-40 ${isRecording ? "h-10 w-10 bg-[hsl(var(--swf-success-soft))] text-[hsl(var(--swf-success))]" : "h-10 w-10 bg-[hsl(213_94%_60%/0.10)] text-[hsl(213_94%_45%)] hover:bg-[hsl(213_94%_60%/0.18)]"}`,
29492
- children: isVoiceStarting ? /* @__PURE__ */ jsx24(LoaderCircle, { size: 20, className: "animate-spin" }) : isRecording ? /* @__PURE__ */ jsx24(VoiceWaveform, { level: voiceLevel, size: 20 }) : /* @__PURE__ */ jsx24(Mic, { size: 20 })
29343
+ className: `flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-colors duration-150 disabled:opacity-40 ${isRecording ? "bg-[hsl(var(--swf-success-soft))] text-[hsl(var(--swf-success))]" : "text-[hsl(var(--muted-foreground))] hover:bg-[hsl(var(--accent))] hover:text-[hsl(var(--foreground))]"}`,
29344
+ children: isVoiceStarting ? /* @__PURE__ */ jsx24(LoaderCircle, { size: 18, className: "animate-spin" }) : isRecording ? /* @__PURE__ */ jsx24(VoiceWaveform, { level: voiceLevel, size: 18 }) : /* @__PURE__ */ jsx24(Mic, { size: 19, strokeWidth: 1.85 })
29493
29345
  }
29494
29346
  ) : null,
29495
- isStreaming ? /* @__PURE__ */ jsxs13(Fragment5, { children: [
29496
- submitWhileRunning ? /* @__PURE__ */ jsx24(
29347
+ isStreaming ? /* @__PURE__ */ jsxs13(Fragment6, { children: [
29348
+ submitWhileRunning && hasComposerContent && !isSendDisabled && !isRecording ? /* @__PURE__ */ jsx24(
29497
29349
  "button",
29498
29350
  {
29499
29351
  type: "button",
@@ -29501,8 +29353,8 @@ ${append2.text}` : append2.text;
29501
29353
  disabled: isSendDisabled || isRecording,
29502
29354
  "aria-label": "\u53D1\u9001\u5F15\u5BFC\u6D88\u606F",
29503
29355
  title: "\u53D1\u9001\u5F15\u5BFC\u6D88\u606F",
29504
- className: "flex h-10 w-10 items-center justify-center rounded-full bg-[hsl(213_94%_55%)] text-white disabled:opacity-25",
29505
- children: isSubmitting ? /* @__PURE__ */ jsx24(LoaderCircle, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ jsx24(Send, { size: 16 })
29356
+ className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] transition-opacity hover:opacity-90 disabled:opacity-30",
29357
+ children: isSubmitting ? /* @__PURE__ */ jsx24(LoaderCircle, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ jsx24(ArrowUp, { size: 18, strokeWidth: 2.25 })
29506
29358
  }
29507
29359
  ) : null,
29508
29360
  /* @__PURE__ */ jsx24(
@@ -29512,9 +29364,9 @@ ${append2.text}` : append2.text;
29512
29364
  onClick: () => void onStop(),
29513
29365
  disabled: isStopping,
29514
29366
  "aria-label": isStopping ? "\u6B63\u5728\u505C\u6B62" : "\u505C\u6B62\u751F\u6210",
29515
- title: isStopping ? "\u6B63\u5728\u505C\u6B62" : "\u505C\u6B62\u751F\u6210",
29516
- className: "flex h-10 w-10 items-center justify-center rounded-full bg-[hsl(var(--destructive))] text-[hsl(var(--destructive-foreground))] transition-opacity hover:opacity-80 disabled:cursor-wait disabled:opacity-70",
29517
- children: isStopping ? /* @__PURE__ */ jsx24(LoaderCircle, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ jsx24(Square, { size: 16 })
29367
+ title: isStopping ? "\u6B63\u5728\u505C\u6B62" : "\u505C\u6B62\u751F\u6210\uFF08\u6216\u53CC\u51FB Esc\uFF09",
29368
+ className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[hsl(var(--destructive)/0.14)] text-[hsl(var(--destructive))] transition-colors hover:bg-[hsl(var(--destructive))] hover:text-[hsl(var(--destructive-foreground))] disabled:cursor-wait disabled:opacity-70",
29369
+ children: isStopping ? /* @__PURE__ */ jsx24(LoaderCircle, { size: 15, className: "animate-spin" }) : /* @__PURE__ */ jsx24(Square, { size: 13, fill: "currentColor" })
29518
29370
  }
29519
29371
  )
29520
29372
  ] }) : isCompacting ? /* @__PURE__ */ jsx24(
@@ -29524,21 +29376,35 @@ ${append2.text}` : append2.text;
29524
29376
  disabled: true,
29525
29377
  "aria-label": developer ? "\u6B63\u5728\u6574\u7406\u5BF9\u8BDD" : "\u6B63\u5728\u5904\u7406",
29526
29378
  title: developer ? "\u6B63\u5728\u6574\u7406\u5BF9\u8BDD" : "\u6B63\u5728\u5904\u7406",
29527
- className: "flex h-10 w-10 items-center justify-center rounded-full bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] opacity-50",
29379
+ className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[hsl(var(--primary)/0.22)] text-[hsl(var(--primary))] opacity-70",
29528
29380
  children: /* @__PURE__ */ jsx24(LoaderCircle, { size: 16, className: "animate-spin" })
29529
29381
  }
29530
- ) : !isRecording && hasComposerContent ? /* @__PURE__ */ jsx24(
29382
+ ) : canContinueGeneration ? /* @__PURE__ */ jsxs13(
29383
+ "button",
29384
+ {
29385
+ type: "button",
29386
+ "data-testid": "composer-continue-button",
29387
+ onClick: () => void handleSubmit(false, "\u8BF7\u7EE7\u7EED\u5B8C\u6210\u521A\u624D\u672A\u5B8C\u6210\u7684\u56DE\u590D"),
29388
+ "aria-label": "\u7EE7\u7EED\u751F\u6210",
29389
+ title: "\u7EE7\u7EED\u5B8C\u6210\u4E0A\u4E00\u8F6E\u4E2D\u65AD\u6216\u5931\u8D25\u7684\u56DE\u590D",
29390
+ className: "inline-flex h-9 shrink-0 items-center gap-1 rounded-full bg-[hsl(var(--primary)/0.14)] px-3 text-xs font-medium text-[hsl(var(--primary))] transition-colors hover:bg-[hsl(var(--primary))] hover:text-[hsl(var(--primary-foreground))]",
29391
+ children: [
29392
+ /* @__PURE__ */ jsx24(Play, { size: 12, fill: "currentColor", "aria-hidden": "true" }),
29393
+ /* @__PURE__ */ jsx24("span", { children: "\u7EE7\u7EED" })
29394
+ ]
29395
+ }
29396
+ ) : /* @__PURE__ */ jsx24(
29531
29397
  "button",
29532
29398
  {
29533
29399
  type: "button",
29534
29400
  onClick: () => void handleSubmit(),
29535
- disabled: isSendDisabled,
29401
+ disabled: isSendDisabled || isRecording,
29536
29402
  "aria-label": "\u53D1\u9001\u5F15\u5BFC\u6D88\u606F",
29537
29403
  title: isModelLoading ? "\u6B63\u5728\u52A0\u8F7D\u6A21\u578B\u914D\u7F6E" : !hasAvailableModel ? modelAvailabilityMessage : "\u53D1\u9001\u5F15\u5BFC\u6D88\u606F",
29538
- className: "flex h-10 w-10 items-center justify-center rounded-full bg-[hsl(213_94%_55%)] text-white transition-colors duration-[120ms] ease-out hover:bg-[hsl(213_94%_48%)] disabled:opacity-25",
29539
- children: isSubmitting ? /* @__PURE__ */ jsx24(LoaderCircle, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ jsx24(Send, { size: 16 })
29404
+ className: `flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-colors duration-150 ${isSendDisabled || isRecording ? "cursor-not-allowed bg-[hsl(var(--primary)/0.2)] text-[hsl(var(--primary)/0.65)]" : "bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90"}`,
29405
+ children: isSubmitting ? /* @__PURE__ */ jsx24(LoaderCircle, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ jsx24(ArrowUp, { size: 18, strokeWidth: 2.25 })
29540
29406
  }
29541
- ) : null
29407
+ )
29542
29408
  ] })
29543
29409
  ] }),
29544
29410
  slotBelowActions ? /* @__PURE__ */ jsx24("div", { className: "border-t border-[hsl(var(--border))] px-4 py-1.5", children: slotBelowActions }) : null
@@ -29565,8 +29431,8 @@ ${append2.text}` : append2.text;
29565
29431
  }
29566
29432
 
29567
29433
  // src/rich-input/SkillActionMenu.tsx
29568
- import { useEffect as useEffect9, useState as useState12 } from "react";
29569
- import { Fragment as Fragment6, jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
29434
+ import { useEffect as useEffect10, useState as useState12 } from "react";
29435
+ import { Fragment as Fragment7, jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
29570
29436
  function SkillActionMenu({ open, onOpenChange, renderMode, onSelect, onManage, disabled }) {
29571
29437
  return /* @__PURE__ */ jsx25(InputActionSubmenu, { label: "\u6280\u80FD", icon: /* @__PURE__ */ jsx25(Sparkles, { size: 16, "aria-hidden": "true" }), open, onOpenChange, disabled, children: /* @__PURE__ */ jsx25(SkillPicker, { renderMode, onSelect, onManage }) });
29572
29438
  }
@@ -29574,7 +29440,7 @@ function SkillPicker({ renderMode, onSelect, onManage }) {
29574
29440
  const client = useBladeClient();
29575
29441
  const [query, setQuery] = useState12("");
29576
29442
  const [skills, setSkills] = useState12(null);
29577
- useEffect9(() => {
29443
+ useEffect10(() => {
29578
29444
  let active = true;
29579
29445
  setSkills(null);
29580
29446
  getSlashSuggestions(query, { client, sessionId: null, renderMode }).then((items) => {
@@ -29586,7 +29452,7 @@ function SkillPicker({ renderMode, onSelect, onManage }) {
29586
29452
  active = false;
29587
29453
  };
29588
29454
  }, [client, renderMode, query]);
29589
- return /* @__PURE__ */ jsxs14(Fragment6, { children: [
29455
+ return /* @__PURE__ */ jsxs14(Fragment7, { children: [
29590
29456
  /* @__PURE__ */ jsxs14("label", { className: "m-1 flex items-center gap-2 rounded-lg bg-[hsl(var(--muted))] px-3 py-2", children: [
29591
29457
  /* @__PURE__ */ jsx25(Search, { size: 14, "aria-hidden": "true" }),
29592
29458
  /* @__PURE__ */ jsx25("input", { "aria-label": "\u641C\u7D22\u6280\u80FD", placeholder: "\u641C\u7D22\u6280\u80FD", value: query, onChange: (event) => setQuery(event.target.value), className: "min-w-0 flex-1 bg-transparent outline-none" })