quoin-editor 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/ai.cjs +168 -249
  3. package/dist/ai.cjs.map +1 -1
  4. package/dist/ai.js +37 -121
  5. package/dist/ai.js.map +1 -1
  6. package/dist/catalogue.cjs +28 -43
  7. package/dist/catalogue.cjs.map +1 -1
  8. package/dist/catalogue.js +20 -37
  9. package/dist/catalogue.js.map +1 -1
  10. package/dist/{chunk-26Q4LSIU.js → chunk-2EQ6FKSK.js} +19 -28
  11. package/dist/chunk-2EQ6FKSK.js.map +1 -0
  12. package/dist/{chunk-6LMS5J3Y.js → chunk-3BXUGX5F.js} +4 -18
  13. package/dist/chunk-3BXUGX5F.js.map +1 -0
  14. package/dist/chunk-3QRVAI53.cjs +27 -0
  15. package/dist/chunk-3QRVAI53.cjs.map +1 -0
  16. package/dist/{chunk-LMAEPFTX.js → chunk-7FAVFJAS.js} +4 -10
  17. package/dist/chunk-7FAVFJAS.js.map +1 -0
  18. package/dist/{chunk-XX5FTPJR.cjs → chunk-7SVKLWDT.cjs} +24 -31
  19. package/dist/chunk-7SVKLWDT.cjs.map +1 -0
  20. package/dist/{chunk-EH5KXQXY.cjs → chunk-A6PGQVTR.cjs} +36 -20
  21. package/dist/chunk-A6PGQVTR.cjs.map +1 -0
  22. package/dist/{chunk-5M4QG3ZC.cjs → chunk-ACSEYJJF.cjs} +427 -534
  23. package/dist/chunk-ACSEYJJF.cjs.map +1 -0
  24. package/dist/{chunk-BTBHHBVR.cjs → chunk-AIS37SL2.cjs} +205 -198
  25. package/dist/chunk-AIS37SL2.cjs.map +1 -0
  26. package/dist/{chunk-F5V3IEEE.cjs → chunk-DTQFYHDJ.cjs} +56 -105
  27. package/dist/chunk-DTQFYHDJ.cjs.map +1 -0
  28. package/dist/{chunk-O4Z2WMFF.js → chunk-HDJ653LM.js} +25 -18
  29. package/dist/chunk-HDJ653LM.js.map +1 -0
  30. package/dist/chunk-HQ43EIYO.cjs +94 -0
  31. package/dist/chunk-HQ43EIYO.cjs.map +1 -0
  32. package/dist/{chunk-6YSGUAVW.js → chunk-HTLWPSMU.js} +11 -66
  33. package/dist/chunk-HTLWPSMU.js.map +1 -0
  34. package/dist/{chunk-UBNG5YCG.js → chunk-HWEK7EX5.js} +17 -69
  35. package/dist/chunk-HWEK7EX5.js.map +1 -0
  36. package/dist/{chunk-QXG3HWDS.js → chunk-ITXCE6KL.js} +7 -25
  37. package/dist/chunk-ITXCE6KL.js.map +1 -0
  38. package/dist/{chunk-PX6LZMH4.cjs → chunk-IXVGHH7F.cjs} +102 -155
  39. package/dist/chunk-IXVGHH7F.cjs.map +1 -0
  40. package/dist/{chunk-LV6EYPJO.js → chunk-JZJIWRF3.js} +4 -8
  41. package/dist/chunk-JZJIWRF3.js.map +1 -0
  42. package/dist/{chunk-UCXLRRWY.js → chunk-KSF2HILJ.js} +66 -216
  43. package/dist/chunk-KSF2HILJ.js.map +1 -0
  44. package/dist/{chunk-UPSLDTLT.js → chunk-L4D23LM2.js} +5 -184
  45. package/dist/chunk-L4D23LM2.js.map +1 -0
  46. package/dist/{chunk-62WKUAQY.js → chunk-L6OW2FL3.js} +12 -91
  47. package/dist/chunk-L6OW2FL3.js.map +1 -0
  48. package/dist/chunk-LE5XMIFJ.cjs +4 -3
  49. package/dist/chunk-LE5XMIFJ.cjs.map +1 -1
  50. package/dist/{chunk-56C7GCKO.cjs → chunk-LY2D45F2.cjs} +233 -363
  51. package/dist/chunk-LY2D45F2.cjs.map +1 -0
  52. package/dist/{chunk-GPIDU3GN.js → chunk-MGMA5PEL.js} +14 -57
  53. package/dist/chunk-MGMA5PEL.js.map +1 -0
  54. package/dist/chunk-MQUCCSWG.js +2 -3
  55. package/dist/chunk-MQUCCSWG.js.map +1 -1
  56. package/dist/chunk-NO3KTZDY.cjs +33 -0
  57. package/dist/chunk-NO3KTZDY.cjs.map +1 -0
  58. package/dist/{chunk-MLRAVUFG.cjs → chunk-OM7E43ZN.cjs} +92 -91
  59. package/dist/chunk-OM7E43ZN.cjs.map +1 -0
  60. package/dist/{chunk-PIWRSX7U.js → chunk-PJCHSHM3.js} +38 -120
  61. package/dist/chunk-PJCHSHM3.js.map +1 -0
  62. package/dist/{chunk-SSIRYUCK.js → chunk-QC35D2AU.js} +109 -263
  63. package/dist/chunk-QC35D2AU.js.map +1 -0
  64. package/dist/{chunk-5R3ISX4A.cjs → chunk-QEMGOL5L.cjs} +1302 -1780
  65. package/dist/chunk-QEMGOL5L.cjs.map +1 -0
  66. package/dist/chunk-QWS7KH3K.cjs +483 -0
  67. package/dist/chunk-QWS7KH3K.cjs.map +1 -0
  68. package/dist/{chunk-A4IJSJKL.js → chunk-RHQPAW4W.js} +34 -92
  69. package/dist/chunk-RHQPAW4W.js.map +1 -0
  70. package/dist/chunk-RIIXJWBR.cjs +24 -0
  71. package/dist/chunk-RIIXJWBR.cjs.map +1 -0
  72. package/dist/{chunk-PGSS4IOS.js → chunk-SAEQMDAU.js} +71 -168
  73. package/dist/chunk-SAEQMDAU.js.map +1 -0
  74. package/dist/chunk-SKZC4K5S.cjs +612 -0
  75. package/dist/chunk-SKZC4K5S.cjs.map +1 -0
  76. package/dist/{chunk-RQW3P3GH.js → chunk-TBCHYHNU.js} +38 -105
  77. package/dist/chunk-TBCHYHNU.js.map +1 -0
  78. package/dist/{chunk-WMN6566P.js → chunk-TNN6Z52D.js} +13 -45
  79. package/dist/chunk-TNN6Z52D.js.map +1 -0
  80. package/dist/{chunk-OCCKQHCY.js → chunk-TYZSB7JT.js} +4 -8
  81. package/dist/chunk-TYZSB7JT.js.map +1 -0
  82. package/dist/{chunk-HOIDJEVI.cjs → chunk-VFSVN5IQ.cjs} +495 -551
  83. package/dist/chunk-VFSVN5IQ.cjs.map +1 -0
  84. package/dist/{chunk-V3KLMSRO.cjs → chunk-WDO6DBYU.cjs} +90 -153
  85. package/dist/chunk-WDO6DBYU.cjs.map +1 -0
  86. package/dist/{chunk-VACTAZWS.cjs → chunk-WHV5ZSIO.cjs} +36 -64
  87. package/dist/chunk-WHV5ZSIO.cjs.map +1 -0
  88. package/dist/{chunk-LE3F7WIP.js → chunk-XJDPQFPU.js} +693 -1254
  89. package/dist/chunk-XJDPQFPU.js.map +1 -0
  90. package/dist/{chunk-ESMAW4NK.cjs → chunk-ZTLYHRZT.cjs} +34 -44
  91. package/dist/chunk-ZTLYHRZT.cjs.map +1 -0
  92. package/dist/chunk-ZWB7SZVI.cjs +200 -0
  93. package/dist/chunk-ZWB7SZVI.cjs.map +1 -0
  94. package/dist/comments.cjs +209 -290
  95. package/dist/comments.cjs.map +1 -1
  96. package/dist/comments.js +81 -186
  97. package/dist/comments.js.map +1 -1
  98. package/dist/diff.cjs +48 -64
  99. package/dist/diff.cjs.map +1 -1
  100. package/dist/diff.d.cts +2 -2
  101. package/dist/diff.d.ts +2 -2
  102. package/dist/diff.js +9 -32
  103. package/dist/diff.js.map +1 -1
  104. package/dist/docx.cjs +50 -63
  105. package/dist/docx.cjs.map +1 -1
  106. package/dist/docx.js +7 -22
  107. package/dist/docx.js.map +1 -1
  108. package/dist/embed.cjs +18 -12
  109. package/dist/embed.cjs.map +1 -1
  110. package/dist/embed.js +9 -16
  111. package/dist/embed.js.map +1 -1
  112. package/dist/emoji-data.cjs +7 -5
  113. package/dist/emoji-data.cjs.map +1 -1
  114. package/dist/emoji-data.js +3 -5
  115. package/dist/emoji-data.js.map +1 -1
  116. package/dist/emoji.cjs +25 -17
  117. package/dist/emoji.cjs.map +1 -1
  118. package/dist/emoji.js +8 -17
  119. package/dist/emoji.js.map +1 -1
  120. package/dist/engine.cjs +229 -118
  121. package/dist/engine.cjs.map +1 -1
  122. package/dist/engine.js +4 -118
  123. package/dist/engine.js.map +1 -1
  124. package/dist/find.cjs +29 -19
  125. package/dist/find.cjs.map +1 -1
  126. package/dist/find.js +8 -19
  127. package/dist/find.js.map +1 -1
  128. package/dist/headless.cjs +290 -151
  129. package/dist/headless.cjs.map +1 -1
  130. package/dist/headless.d.cts +5 -1
  131. package/dist/headless.d.ts +5 -1
  132. package/dist/headless.js +5 -151
  133. package/dist/headless.js.map +1 -1
  134. package/dist/index.cjs +348 -183
  135. package/dist/index.cjs.map +1 -1
  136. package/dist/index.d.cts +14 -4
  137. package/dist/index.d.ts +14 -4
  138. package/dist/index.js +7 -183
  139. package/dist/index.js.map +1 -1
  140. package/dist/math.cjs +19 -13
  141. package/dist/math.cjs.map +1 -1
  142. package/dist/math.js +10 -17
  143. package/dist/math.js.map +1 -1
  144. package/dist/mention.cjs +19 -13
  145. package/dist/mention.cjs.map +1 -1
  146. package/dist/mention.js +10 -17
  147. package/dist/mention.js.map +1 -1
  148. package/dist/presence.cjs +99 -136
  149. package/dist/presence.cjs.map +1 -1
  150. package/dist/presence.js +23 -83
  151. package/dist/presence.js.map +1 -1
  152. package/dist/{registry-CWBOSAHm.d.cts → registry-CXegaw5k.d.cts} +25 -2
  153. package/dist/{registry-CWBOSAHm.d.ts → registry-CXegaw5k.d.ts} +25 -2
  154. package/dist/stats.cjs +26 -18
  155. package/dist/stats.cjs.map +1 -1
  156. package/dist/stats.js +9 -18
  157. package/dist/stats.js.map +1 -1
  158. package/dist/styles.css +1 -1
  159. package/dist/table.cjs +89 -49
  160. package/dist/table.cjs.map +1 -1
  161. package/dist/table.js +8 -49
  162. package/dist/table.js.map +1 -1
  163. package/dist/toc.cjs +25 -17
  164. package/dist/toc.cjs.map +1 -1
  165. package/dist/toc.js +8 -17
  166. package/dist/toc.js.map +1 -1
  167. package/dist/view.cjs +13 -16
  168. package/dist/view.cjs.map +1 -1
  169. package/dist/view.d.cts +2 -2
  170. package/dist/view.d.ts +2 -2
  171. package/dist/view.js +7 -16
  172. package/dist/view.js.map +1 -1
  173. package/dist/yjs.cjs +258 -248
  174. package/dist/yjs.cjs.map +1 -1
  175. package/dist/yjs.js +104 -120
  176. package/dist/yjs.js.map +1 -1
  177. package/package.json +1 -1
  178. package/dist/chunk-26Q4LSIU.js.map +0 -1
  179. package/dist/chunk-56C7GCKO.cjs.map +0 -1
  180. package/dist/chunk-5M4QG3ZC.cjs.map +0 -1
  181. package/dist/chunk-5R3ISX4A.cjs.map +0 -1
  182. package/dist/chunk-62WKUAQY.js.map +0 -1
  183. package/dist/chunk-6LMS5J3Y.js.map +0 -1
  184. package/dist/chunk-6PKVJZQV.cjs +0 -100
  185. package/dist/chunk-6PKVJZQV.cjs.map +0 -1
  186. package/dist/chunk-6YSGUAVW.js.map +0 -1
  187. package/dist/chunk-75C6PX2L.cjs +0 -239
  188. package/dist/chunk-75C6PX2L.cjs.map +0 -1
  189. package/dist/chunk-A4IJSJKL.js.map +0 -1
  190. package/dist/chunk-BTBHHBVR.cjs.map +0 -1
  191. package/dist/chunk-CLTHD5GO.cjs +0 -34
  192. package/dist/chunk-CLTHD5GO.cjs.map +0 -1
  193. package/dist/chunk-EH5KXQXY.cjs.map +0 -1
  194. package/dist/chunk-ESMAW4NK.cjs.map +0 -1
  195. package/dist/chunk-EYFCOV3T.cjs +0 -30
  196. package/dist/chunk-EYFCOV3T.cjs.map +0 -1
  197. package/dist/chunk-F5V3IEEE.cjs.map +0 -1
  198. package/dist/chunk-GPIDU3GN.js.map +0 -1
  199. package/dist/chunk-HOIDJEVI.cjs.map +0 -1
  200. package/dist/chunk-JJ3RASQS.cjs +0 -706
  201. package/dist/chunk-JJ3RASQS.cjs.map +0 -1
  202. package/dist/chunk-LE3F7WIP.js.map +0 -1
  203. package/dist/chunk-LMAEPFTX.js.map +0 -1
  204. package/dist/chunk-LV6EYPJO.js.map +0 -1
  205. package/dist/chunk-MLRAVUFG.cjs.map +0 -1
  206. package/dist/chunk-O4Z2WMFF.js.map +0 -1
  207. package/dist/chunk-OCCKQHCY.js.map +0 -1
  208. package/dist/chunk-PGSS4IOS.js.map +0 -1
  209. package/dist/chunk-PIWRSX7U.js.map +0 -1
  210. package/dist/chunk-PX6LZMH4.cjs.map +0 -1
  211. package/dist/chunk-QXG3HWDS.js.map +0 -1
  212. package/dist/chunk-RQW3P3GH.js.map +0 -1
  213. package/dist/chunk-SSIRYUCK.js.map +0 -1
  214. package/dist/chunk-UBNG5YCG.js.map +0 -1
  215. package/dist/chunk-UCXLRRWY.js.map +0 -1
  216. package/dist/chunk-UDAVVEFC.cjs +0 -562
  217. package/dist/chunk-UDAVVEFC.cjs.map +0 -1
  218. package/dist/chunk-UPSLDTLT.js.map +0 -1
  219. package/dist/chunk-UWNZG2SD.cjs +0 -25
  220. package/dist/chunk-UWNZG2SD.cjs.map +0 -1
  221. package/dist/chunk-V3KLMSRO.cjs.map +0 -1
  222. package/dist/chunk-VACTAZWS.cjs.map +0 -1
  223. package/dist/chunk-WMN6566P.js.map +0 -1
  224. package/dist/chunk-XX5FTPJR.cjs.map +0 -1
package/dist/ai.cjs CHANGED
@@ -1,61 +1,16 @@
1
- 'use client';"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
-
3
-
4
- var _chunkLE5XMIFJcjs = require('./chunk-LE5XMIFJ.cjs');
5
-
6
-
7
- var _chunkCLTHD5GOcjs = require('./chunk-CLTHD5GO.cjs');
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
- var _chunk5R3ISX4Acjs = require('./chunk-5R3ISX4A.cjs');
21
-
22
-
23
-
24
-
25
-
26
- var _chunk5M4QG3ZCcjs = require('./chunk-5M4QG3ZC.cjs');
27
- require('./chunk-EH5KXQXY.cjs');
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
- var _chunkHOIDJEVIcjs = require('./chunk-HOIDJEVI.cjs');
51
- require('./chunk-XX5FTPJR.cjs');
52
-
53
-
54
-
55
-
56
-
57
-
58
- var _chunkBTBHHBVRcjs = require('./chunk-BTBHHBVR.cjs');
1
+ 'use client';'use strict';
2
+
3
+ var chunkLE5XMIFJ_cjs = require('./chunk-LE5XMIFJ.cjs');
4
+ var chunkNO3KTZDY_cjs = require('./chunk-NO3KTZDY.cjs');
5
+ var chunkQEMGOL5L_cjs = require('./chunk-QEMGOL5L.cjs');
6
+ var chunkACSEYJJF_cjs = require('./chunk-ACSEYJJF.cjs');
7
+ require('./chunk-A6PGQVTR.cjs');
8
+ var chunkVFSVN5IQ_cjs = require('./chunk-VFSVN5IQ.cjs');
9
+ require('./chunk-7SVKLWDT.cjs');
10
+ var chunkAIS37SL2_cjs = require('./chunk-AIS37SL2.cjs');
11
+ var lucideReact = require('lucide-react');
12
+ var react = require('react');
13
+ var jsxRuntime = require('react/jsx-runtime');
59
14
 
60
15
  // src/extensions/ai/streaming-markdown.ts
61
16
  var FENCE = /^ {0,3}(`{3,}|~{3,})/;
@@ -70,8 +25,8 @@ var isSpace = (char) => char === void 0 || /\s/.test(char);
70
25
  function openFence(lines) {
71
26
  let open = null;
72
27
  for (const line of lines) {
73
- const fence = _optionalChain([FENCE, 'access', _2 => _2.exec, 'call', _3 => _3(line), 'optionalAccess', _4 => _4[1]]);
74
- if (open === null) open = _nullishCoalesce(fence, () => ( null));
28
+ const fence = FENCE.exec(line)?.[1];
29
+ if (open === null) open = fence ?? null;
75
30
  else if (fence !== void 0 && fence[0] === open[0] && fence.length >= open.length && line.trim() === fence) {
76
31
  open = null;
77
32
  }
@@ -91,7 +46,7 @@ function tokenAt(body, at) {
91
46
  if (DOUBLE.includes(two)) return two;
92
47
  const one = body[at];
93
48
  if (one === "*") return one;
94
- if (one === "_" && !(WORD.test(_nullishCoalesce(body[at - 1], () => ( ""))) && WORD.test(_nullishCoalesce(body[at + 1], () => ( ""))))) return one;
49
+ if (one === "_" && !(WORD.test(body[at - 1] ?? "") && WORD.test(body[at + 1] ?? ""))) return one;
95
50
  return null;
96
51
  }
97
52
  function codeEnd(body, at) {
@@ -124,7 +79,7 @@ function closeInline(source) {
124
79
  }
125
80
  const before = body[at - 1];
126
81
  const after = body[at + token.length];
127
- if (_optionalChain([opened, 'access', _5 => _5.at, 'call', _6 => _6(-1), 'optionalAccess', _7 => _7.token]) === token && !isSpace(before)) opened.pop();
82
+ if (opened.at(-1)?.token === token && !isSpace(before)) opened.pop();
128
83
  else if (after === void 0 || !isSpace(after)) opened.push({ token, at });
129
84
  at += token.length;
130
85
  }
@@ -147,49 +102,49 @@ function closeStreaming(markdown) {
147
102
  }
148
103
  const block = lines.slice(first).join("\n");
149
104
  const head = markdown.slice(0, markdown.length - block.length);
150
- const prefix = _nullishCoalesce(_optionalChain([LINE_PREFIX, 'access', _8 => _8.exec, 'call', _9 => _9(block), 'optionalAccess', _10 => _10[0]]), () => ( ""));
105
+ const prefix = LINE_PREFIX.exec(block)?.[0] ?? "";
151
106
  return head + prefix + closeInline(block.slice(prefix.length));
152
107
  }
153
108
 
154
109
  // src/extensions/ai/ai-target.ts
155
110
  function targetOfBlocks(state, ids) {
156
111
  const { doc, schema } = state;
157
- const first = _chunkBTBHHBVRcjs.blockById.call(void 0, doc, ids[0]);
158
- const last = _chunkBTBHHBVRcjs.blockById.call(void 0, doc, ids[ids.length - 1]);
112
+ const first = chunkAIS37SL2_cjs.blockById(doc, ids[0]);
113
+ const last = chunkAIS37SL2_cjs.blockById(doc, ids[ids.length - 1]);
159
114
  if (first === void 0 || last === void 0) return null;
160
- const start = _chunkHOIDJEVIcjs.primaryRegion.call(void 0, schema, first);
161
- const end = _chunkHOIDJEVIcjs.primaryRegion.call(void 0, schema, last);
115
+ const start = chunkVFSVN5IQ_cjs.primaryRegion(schema, first);
116
+ const end = chunkVFSVN5IQ_cjs.primaryRegion(schema, last);
162
117
  if (start === null || end === null) return null;
163
118
  const from = { block: first.id, region: start, offset: 0 };
164
- return { from, to: { block: last.id, region: end, offset: _chunkHOIDJEVIcjs.regionLength.call(void 0, last, end) }, selected: ids.length > 1 };
119
+ return { from, to: { block: last.id, region: end, offset: chunkVFSVN5IQ_cjs.regionLength(last, end) }, selected: ids.length > 1 };
165
120
  }
166
121
  function targetOfSelection(state) {
167
122
  const { doc, selection } = state;
168
123
  if (selection === null) return null;
169
- if (selection.kind !== "text") return targetOfBlocks(state, _chunkHOIDJEVIcjs.selectedBlockIds.call(void 0, doc, selection));
170
- const { from, to } = _chunkHOIDJEVIcjs.orderedRange.call(void 0, doc, selection.anchor, selection.head);
171
- if (_chunkHOIDJEVIcjs.comparePos.call(void 0, doc, from, to) !== 0) return { from, to, selected: true };
124
+ if (selection.kind !== "text") return targetOfBlocks(state, chunkVFSVN5IQ_cjs.selectedBlockIds(doc, selection));
125
+ const { from, to } = chunkVFSVN5IQ_cjs.orderedRange(doc, selection.anchor, selection.head);
126
+ if (chunkVFSVN5IQ_cjs.comparePos(doc, from, to) !== 0) return { from, to, selected: true };
172
127
  const block = doc.blocks[doc.index.get(from.block)];
173
128
  const whole = { block: from.block, region: from.region };
174
- return { from: { ...whole, offset: 0 }, to: { ...whole, offset: _chunkHOIDJEVIcjs.regionLength.call(void 0, block, from.region) }, selected: false };
129
+ return { from: { ...whole, offset: 0 }, to: { ...whole, offset: chunkVFSVN5IQ_cjs.regionLength(block, from.region) }, selected: false };
175
130
  }
176
131
  function nearestKept(tr, target) {
177
132
  const { doc } = tr.before;
178
- const first = _nullishCoalesce(doc.index.get(target.from.block), () => ( 0));
179
- const last = _nullishCoalesce(doc.index.get(target.to.block), () => ( first));
180
- const kept = (block) => block && _chunkBTBHHBVRcjs.blockById.call(void 0, tr.doc, block.id);
133
+ const first = doc.index.get(target.from.block) ?? 0;
134
+ const last = doc.index.get(target.to.block) ?? first;
135
+ const kept = (block) => block && chunkAIS37SL2_cjs.blockById(tr.doc, block.id);
181
136
  for (let step = 1; first - step >= 0 || last + step < doc.blocks.length; step++) {
182
- const found = _nullishCoalesce(kept(doc.blocks[first - step]), () => ( kept(doc.blocks[last + step])));
137
+ const found = kept(doc.blocks[first - step]) ?? kept(doc.blocks[last + step]);
183
138
  if (found) return found;
184
139
  }
185
140
  return tr.doc.blocks[0];
186
141
  }
187
142
  function edgeOf(tr, target) {
188
143
  const point = tr.mapPos(target.from, -1);
189
- const block = _nullishCoalesce(_chunkBTBHHBVRcjs.blockById.call(void 0, tr.doc, point.block), () => ( nearestKept(tr, target)));
144
+ const block = chunkAIS37SL2_cjs.blockById(tr.doc, point.block) ?? nearestKept(tr, target);
190
145
  if (block === void 0) return null;
191
- const region = _nullishCoalesce(_chunkHOIDJEVIcjs.primaryRegion.call(void 0, tr.before.schema, block), () => ( ""));
192
- const length = region === "" ? 0 : _chunkHOIDJEVIcjs.regionLength.call(void 0, block, region);
146
+ const region = chunkVFSVN5IQ_cjs.primaryRegion(tr.before.schema, block) ?? "";
147
+ const length = region === "" ? 0 : chunkVFSVN5IQ_cjs.regionLength(block, region);
193
148
  const offset = block.id === point.block ? Math.min(point.offset, length) : length;
194
149
  const after = offset > 0 || length === 0;
195
150
  const at = { block: block.id, region, offset: after ? length : 0 };
@@ -201,29 +156,29 @@ function mapTarget(tr, target) {
201
156
  const from = tr.mapPos(target.from, inside);
202
157
  const mapped2 = tr.mapPos(target.to, -inside);
203
158
  if (!tr.doc.index.has(from.block) || !tr.doc.index.has(mapped2.block)) return edgeOf(tr, target);
204
- const to = _chunkHOIDJEVIcjs.comparePos.call(void 0, tr.doc, from, mapped2) > 0 ? from : mapped2;
159
+ const to = chunkVFSVN5IQ_cjs.comparePos(tr.doc, from, mapped2) > 0 ? from : mapped2;
205
160
  return from === target.from && to === target.to ? target : { ...target, from, to };
206
161
  }
207
- var targetGone = (doc, target) => target.lost !== void 0 || target.selected && _chunkHOIDJEVIcjs.comparePos.call(void 0, doc, target.from, target.to) === 0;
162
+ var targetGone = (doc, target) => target.lost !== void 0 || target.selected && chunkVFSVN5IQ_cjs.comparePos(doc, target.from, target.to) === 0;
208
163
  function targetRanges(state, { from, to }) {
209
164
  const { doc, schema } = state;
210
165
  const start = doc.index.get(from.block);
211
166
  const end = doc.index.get(to.block);
212
167
  return doc.blocks.slice(start, end + 1).flatMap((block, i) => {
213
- const region = i === 0 ? from.region : block.id === to.block ? to.region : _chunkHOIDJEVIcjs.primaryRegion.call(void 0, schema, block);
168
+ const region = i === 0 ? from.region : block.id === to.block ? to.region : chunkVFSVN5IQ_cjs.primaryRegion(schema, block);
214
169
  if (region === null || !Object.hasOwn(block.regions, region)) return [];
215
170
  const left = i === 0 ? from.offset : 0;
216
- const right = block.id === to.block ? to.offset : _chunkHOIDJEVIcjs.regionLength.call(void 0, block, region);
171
+ const right = block.id === to.block ? to.offset : chunkVFSVN5IQ_cjs.regionLength(block, region);
217
172
  return right > left ? [{ block: block.id, region, from: left, to: right }] : [];
218
173
  });
219
174
  }
220
175
 
221
176
  // src/extensions/ai/ai-plugin.ts
222
- var aiKey = _chunkHOIDJEVIcjs.createPluginKey.call(void 0, "ai");
177
+ var aiKey = chunkVFSVN5IQ_cjs.createPluginKey("ai");
223
178
  var AI = "ai";
224
179
  var IDLE = { target: null, menu: null, ghost: null, held: [] };
225
- var aiState = (state) => _chunkHOIDJEVIcjs.getPluginState.call(void 0, state, aiKey);
226
- var aiTransaction = (state, act2) => new (0, _chunkHOIDJEVIcjs.Transaction)(state).setMeta(AI, act2).setMeta("addToHistory", false);
180
+ var aiState = (state) => chunkVFSVN5IQ_cjs.getPluginState(state, aiKey);
181
+ var aiTransaction = (state, act2) => new chunkVFSVN5IQ_cjs.Transaction(state).setMeta(AI, act2).setMeta("addToHistory", false);
227
182
  function written(ghost, key, phase, output) {
228
183
  return ghost.key !== key ? ghost : { ...ghost, phase, output, shown: closeStreaming(output) };
229
184
  }
@@ -252,11 +207,11 @@ function act(value, action) {
252
207
  }
253
208
  function caretBlock(state) {
254
209
  const { selection } = state;
255
- return _optionalChain([selection, 'optionalAccess', _11 => _11.kind]) === "text" ? selection.head.block : null;
210
+ return selection?.kind === "text" ? selection.head.block : null;
256
211
  }
257
212
  function hasText(state, id) {
258
- const block = _chunkBTBHHBVRcjs.blockById.call(void 0, state.doc, id);
259
- return block !== void 0 && Object.keys(block.regions).some((region) => _chunkHOIDJEVIcjs.regionLength.call(void 0, block, region) > 0);
213
+ const block = chunkAIS37SL2_cjs.blockById(state.doc, id);
214
+ return block !== void 0 && Object.keys(block.regions).some((region) => chunkVFSVN5IQ_cjs.regionLength(block, region) > 0);
260
215
  }
261
216
  function heldText(tr, value, before, after) {
262
217
  if (!tr.docChanged) return value.held;
@@ -295,15 +250,12 @@ function decorate(state, { target, ghost }) {
295
250
  function aiDecorations(state) {
296
251
  const value = aiState(state);
297
252
  const last = drawn.get(value);
298
- if (_optionalChain([last, 'optionalAccess', _12 => _12.doc]) === state.doc) return last.decorations;
253
+ if (last?.doc === state.doc) return last.decorations;
299
254
  const decorations = decorate(state, value);
300
255
  drawn.set(value, { doc: state.doc, decorations });
301
256
  return decorations;
302
257
  }
303
258
 
304
- // src/extensions/ai/ai-items.ts
305
- var _lucidereact = require('lucide-react');
306
-
307
259
  // src/extensions/ai/ai-actions.ts
308
260
  var MENU_ACTIONS = [
309
261
  "continue",
@@ -357,16 +309,16 @@ function aroundSelection(text, start, end, limit = CONTEXT_LIMIT) {
357
309
  }
358
310
  var WHITESPACE_ENTITY = /(?<!\\)&#(32|9);/g;
359
311
  var plain = (markdown) => markdown.replace(WHITESPACE_ENTITY, (_, code) => code === "32" ? " " : " ");
360
- var markdownOf = (state, blocks) => _chunkHOIDJEVIcjs.toMarkdown.call(void 0, blocks, { schema: state.schema, comments: false });
312
+ var markdownOf = (state, blocks) => chunkVFSVN5IQ_cjs.toMarkdown(blocks, { schema: state.schema, comments: false });
361
313
  function rangeMarkdown(state, from, to) {
362
- const slice = _chunkHOIDJEVIcjs.sliceFromSelection.call(void 0, { ...state, selection: _chunkHOIDJEVIcjs.textSelection.call(void 0, from, to) }, _chunkBTBHHBVRcjs.createBlockCodec.call(void 0, state.schema));
314
+ const slice = chunkVFSVN5IQ_cjs.sliceFromSelection({ ...state, selection: chunkVFSVN5IQ_cjs.textSelection(from, to) }, chunkAIS37SL2_cjs.createBlockCodec(state.schema));
363
315
  return slice === null ? "" : markdownOf(state, slice.blocks).replace(/\n$/, "");
364
316
  }
365
317
  function documentContext(state, target, selection) {
366
- const blocks = _chunkBTBHHBVRcjs.createBlockCodec.call(void 0, state.schema).blocksFromDoc(state.doc);
318
+ const blocks = chunkAIS37SL2_cjs.createBlockCodec(state.schema).blocksFromDoc(state.doc);
367
319
  const full = plain(markdownOf(state, blocks));
368
320
  if (full.length <= CONTEXT_LIMIT) return full;
369
- const index = _nullishCoalesce(state.doc.index.get(target.from.block), () => ( 0));
321
+ const index = state.doc.index.get(target.from.block) ?? 0;
370
322
  const blockStart = index === 0 ? 0 : plain(markdownOf(state, blocks.slice(0, index))).length + 1;
371
323
  const lead = { ...target.from, offset: 0 };
372
324
  const start = blockStart + plain(rangeMarkdown(state, lead, target.from)).length;
@@ -394,7 +346,7 @@ function endRun(link, ended = false) {
394
346
  const { run } = link;
395
347
  if (run === null) return null;
396
348
  link.run = null;
397
- _optionalChain([run, 'access', _13 => _13.cancelFrame, 'optionalCall', _14 => _14()]);
349
+ run.cancelFrame?.();
398
350
  run.cancelFrame = null;
399
351
  if (!ended) run.abort.abort();
400
352
  return run;
@@ -424,7 +376,7 @@ async function read(editor, link, run, stream, request) {
424
376
  } catch (error) {
425
377
  if (!live()) return;
426
378
  end("error");
427
- link.report(_chunk5R3ISX4Acjs.toError.call(void 0, error));
379
+ link.report(chunkQEMGOL5L_cjs.toError(error));
428
380
  }
429
381
  }
430
382
  function startStream(editor, link, stream, request, replace) {
@@ -438,7 +390,7 @@ function startStream(editor, link, stream, request, replace) {
438
390
  }
439
391
  function stopped(editor, link, key, output) {
440
392
  const { ghost } = aiState(editor.state);
441
- if (link.mounts === 0 || _optionalChain([ghost, 'optionalAccess', _15 => _15.key]) !== key || ghost.phase !== "streaming") return;
393
+ if (link.mounts === 0 || ghost?.key !== key || ghost.phase !== "streaming") return;
442
394
  send(editor, { type: "end", key, phase: "stopped", output });
443
395
  link.ended("stopped", output);
444
396
  }
@@ -453,8 +405,8 @@ function watchGhost(editor, link) {
453
405
  const { run } = link;
454
406
  const { ghost, target } = aiState(state);
455
407
  if (run === null) return;
456
- if (_optionalChain([ghost, 'optionalAccess', _16 => _16.key]) !== run.key || ghost.phase !== "streaming") endRun(link);
457
- else if (_optionalChain([target, 'optionalAccess', _17 => _17.lost]) !== void 0 && tr !== null && _optionalChain([aiState, 'call', _18 => _18(tr.before), 'access', _19 => _19.target, 'optionalAccess', _20 => _20.lost]) === void 0) {
408
+ if (ghost?.key !== run.key || ghost.phase !== "streaming") endRun(link);
409
+ else if (target?.lost !== void 0 && tr !== null && aiState(tr.before).target?.lost === void 0) {
458
410
  endRun(link);
459
411
  queueMicrotask(() => stopped(editor, link, run.key, run.output));
460
412
  }
@@ -499,7 +451,7 @@ function discard(editor) {
499
451
 
500
452
  // src/extensions/ai/ai-env.ts
501
453
  function languageOf(controller) {
502
- return _optionalChain([controller, 'access', _21 => _21.root, 'optionalAccess', _22 => _22.closest, 'call', _23 => _23("[lang]"), 'optionalAccess', _24 => _24.getAttribute, 'call', _25 => _25("lang")]) || void 0;
454
+ return controller.root?.closest("[lang]")?.getAttribute("lang") || void 0;
503
455
  }
504
456
  function askFrom(env, action, prompt) {
505
457
  const { controller, stream } = env;
@@ -521,7 +473,7 @@ function aiSlashItems(labels, stream) {
521
473
  title: labels.askAi,
522
474
  description: labels.askAiDescription,
523
475
  group: "ai",
524
- icon: _lucidereact.Sparkles,
476
+ icon: lucideReact.Sparkles,
525
477
  keywords: KEYWORDS,
526
478
  run: ({ controller }) => void openFor(controller)
527
479
  },
@@ -529,10 +481,10 @@ function aiSlashItems(labels, stream) {
529
481
  id: "ai-continue",
530
482
  title: labels.actions.continue,
531
483
  group: "ai",
532
- icon: _lucidereact.PenLine,
484
+ icon: lucideReact.PenLine,
533
485
  keywords: [...KEYWORDS, "continue"],
534
486
  run: ({ controller }) => {
535
- if (openFor(controller)) askFrom({ controller, stream, labels }, "continue");
487
+ if (openFor(controller)) askFrom({ controller, stream}, "continue");
536
488
  }
537
489
  }
538
490
  ];
@@ -540,14 +492,14 @@ function aiSlashItems(labels, stream) {
540
492
  var aiBubbleItem = (labels) => ({
541
493
  id: "ai",
542
494
  title: labels.askAi,
543
- icon: _lucidereact.Sparkles,
495
+ icon: lucideReact.Sparkles,
544
496
  available: (state) => aiState(state).ghost === null,
545
497
  run: (controller) => void openFor(controller)
546
498
  });
547
499
  var aiBlockMenuItem = (labels) => ({
548
500
  id: "ai",
549
501
  label: labels.askAi,
550
- icon: _lucidereact.Sparkles,
502
+ icon: lucideReact.Sparkles,
551
503
  available: (state, blockIds) => targetOfBlocks(state, blockIds) !== null,
552
504
  run: (controller, blockIds) => {
553
505
  const target = targetOfBlocks(controller.editor.state, blockIds);
@@ -591,7 +543,7 @@ var englishAiLabels = {
591
543
  targetGone: "The text this was for was removed, so Accept inserts it where that text was"
592
544
  };
593
545
  function resolveAiLabels(overrides) {
594
- const given = Object.entries(_nullishCoalesce(overrides, () => ( {}))).filter(([, value]) => value !== void 0);
546
+ const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
595
547
  return given.length === 0 ? englishAiLabels : { ...englishAiLabels, ...Object.fromEntries(given) };
596
548
  }
597
549
 
@@ -599,31 +551,25 @@ function resolveAiLabels(overrides) {
599
551
  var openOnSpace = (state, dispatch) => {
600
552
  const { selection, doc } = state;
601
553
  const ai = aiState(state);
602
- if (_optionalChain([selection, 'optionalAccess', _26 => _26.kind]) !== "text" || !_chunkHOIDJEVIcjs.isCollapsed.call(void 0, selection) || ai.menu !== null || ai.ghost !== null) return false;
554
+ if (selection?.kind !== "text" || !chunkVFSVN5IQ_cjs.isCollapsed(selection) || ai.menu !== null || ai.ghost !== null) return false;
603
555
  const { head } = selection;
604
556
  const block = doc.blocks[doc.index.get(head.block)];
605
557
  const paragraph = block.type === "MARKDOWN" && block.attrs.kind === "paragraph";
606
- if (!paragraph || _chunkHOIDJEVIcjs.regionLength.call(void 0, block, head.region) > 0 || ai.held.includes(block.id)) return false;
607
- _optionalChain([dispatch, 'optionalCall', _27 => _27(aiTransaction(state, { type: "open", target: { from: head, to: head, selected: false }, fromSpace: true }))]);
558
+ if (!paragraph || chunkVFSVN5IQ_cjs.regionLength(block, head.region) > 0 || ai.held.includes(block.id)) return false;
559
+ dispatch?.(aiTransaction(state, { type: "open", target: { from: head, to: head, selected: false }, fromSpace: true }));
608
560
  return true;
609
561
  };
610
562
 
611
- // src/extensions/ai/AiOverlay.tsx
612
- var _react = require('react');
613
-
614
- // src/extensions/ai/AiBar.tsx
615
-
616
-
617
563
  // src/extensions/ai/ai-accept.ts
618
- var isParagraph = (block) => _optionalChain([block, 'optionalAccess', _28 => _28.type]) === "MARKDOWN" && _chunkBTBHHBVRcjs.parseLine.call(void 0, String(_nullishCoalesce(block.data.markdown, () => ( "")))).kind === "paragraph";
564
+ var isParagraph = (block) => block?.type === "MARKDOWN" && chunkAIS37SL2_cjs.parseLine(String(block.data.markdown ?? "")).kind === "paragraph";
619
565
  var DISCARD = { type: "discard" };
620
566
  function insertBeside(tr, schema, target, pieces, makeId) {
621
567
  const index = tr.doc.index.get(target.to.block);
622
- const at = _optionalChain([target, 'access', _29 => _29.lost, 'optionalAccess', _30 => _30.after]) ? _chunkHOIDJEVIcjs.descendantsEnd.call(void 0, tr.doc, index) : index;
623
- const fresh = _chunkHOIDJEVIcjs.freshBlocks.call(void 0, pieces, tr.doc.blocks[index].indent, makeId);
624
- tr.step(_chunkHOIDJEVIcjs.insertBlocksStep.call(void 0, at, fresh));
625
- _chunkHOIDJEVIcjs.capIndents.call(void 0, tr, at, at + fresh.length);
626
- tr.setSelection(_chunkHOIDJEVIcjs.endOf.call(void 0, tr.doc, schema, fresh[fresh.length - 1].id));
568
+ const at = target.lost?.after ? chunkVFSVN5IQ_cjs.descendantsEnd(tr.doc, index) : index;
569
+ const fresh = chunkVFSVN5IQ_cjs.freshBlocks(pieces, tr.doc.blocks[index].indent, makeId);
570
+ tr.step(chunkVFSVN5IQ_cjs.insertBlocksStep(at, fresh));
571
+ chunkVFSVN5IQ_cjs.capIndents(tr, at, at + fresh.length);
572
+ tr.setSelection(chunkVFSVN5IQ_cjs.endOf(tr.doc, schema, fresh[fresh.length - 1].id));
627
573
  }
628
574
  function acceptAnswer(editor) {
629
575
  const { state } = editor;
@@ -631,7 +577,7 @@ function acceptAnswer(editor) {
631
577
  if (target === null || ghost === null || ghost.phase === "streaming" || ghost.phase === "error") return null;
632
578
  const { codec } = editor;
633
579
  const makeId = codec.context.newId;
634
- const blocks = _chunkBTBHHBVRcjs.fromMarkdown.call(void 0, ghost.output, { newId: makeId });
580
+ const blocks = chunkAIS37SL2_cjs.fromMarkdown(ghost.output, { newId: makeId });
635
581
  const pieces = blocks.flatMap((block) => codec.toEngineBlocks(block));
636
582
  const tr = editor.createTransaction().setOrigin("ai").setMeta(AI, DISCARD);
637
583
  const gone = targetGone(state.doc, target);
@@ -641,37 +587,34 @@ function acceptAnswer(editor) {
641
587
  const { schema } = state;
642
588
  const open = { openStart: isParagraph(blocks[0]), openEnd: isParagraph(blocks[blocks.length - 1]) };
643
589
  if (ghost.replace || gone) {
644
- const caret = ghost.replace && !gone ? _chunkHOIDJEVIcjs.deleteRange.call(void 0, tr, schema, target.from, target.to, makeId) : target.to;
645
- _chunkHOIDJEVIcjs.pasteAtCaret.call(void 0, tr, schema, caret, open, pieces, makeId);
590
+ const caret = ghost.replace && !gone ? chunkVFSVN5IQ_cjs.deleteRange(tr, schema, target.from, target.to, makeId) : target.to;
591
+ chunkVFSVN5IQ_cjs.pasteAtCaret(tr, schema, caret, open, pieces, makeId);
646
592
  } else {
647
593
  const block = tr.doc.blocks[tr.doc.index.get(target.to.block)];
648
- const end = { ...target.to, offset: _chunkHOIDJEVIcjs.regionLength.call(void 0, block, target.to.region) };
649
- _chunkHOIDJEVIcjs.pasteAtCaret.call(void 0, tr, schema, end, { openStart: false, openEnd: false }, pieces, makeId);
594
+ const end = { ...target.to, offset: chunkVFSVN5IQ_cjs.regionLength(block, target.to.region) };
595
+ chunkVFSVN5IQ_cjs.pasteAtCaret(tr, schema, end, { openStart: false, openEnd: false }, pieces, makeId);
650
596
  }
651
597
  }
652
598
  editor.dispatch(tr);
653
599
  return { gone };
654
600
  }
655
-
656
- // src/extensions/ai/AiBar.tsx
657
- var _jsxruntime = require('react/jsx-runtime');
658
601
  var PRIMARY = "data-ai-primary";
659
602
  function AiBar({ env, ghost, gone, barId }) {
660
603
  const { controller, stream, labels } = env;
661
604
  const { editor } = controller;
662
- const content = _react.useRef.call(void 0, null);
663
- const inside = _react.useRef.call(void 0, false);
664
- const [next, setNext] = _react.useState.call(void 0, "");
605
+ const content = react.useRef(null);
606
+ const inside = react.useRef(false);
607
+ const [next, setNext] = react.useState("");
665
608
  const { phase } = ghost;
666
- const focusPrimary = () => _optionalChain([content, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.querySelector, 'call', _33 => _33(`[${PRIMARY}]`), 'optionalAccess', _34 => _34.focus, 'call', _35 => _35()]);
667
- _chunk5M4QG3ZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
668
- const active = _optionalChain([content, 'access', _36 => _36.current, 'optionalAccess', _37 => _37.ownerDocument, 'access', _38 => _38.activeElement]);
609
+ const focusPrimary = () => content.current?.querySelector(`[${PRIMARY}]`)?.focus();
610
+ chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
611
+ const active = content.current?.ownerDocument.activeElement;
669
612
  inside.current = active == null || active === active.ownerDocument.body;
670
613
  if (inside.current) focusPrimary();
671
614
  }, []);
672
- _chunk5M4QG3ZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
673
- const active = _optionalChain([content, 'access', _39 => _39.current, 'optionalAccess', _40 => _40.ownerDocument, 'access', _41 => _41.activeElement]);
674
- if (inside.current && !_optionalChain([content, 'access', _42 => _42.current, 'optionalAccess', _43 => _43.contains, 'call', _44 => _44(_nullishCoalesce(active, () => ( null)))])) focusPrimary();
615
+ chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
616
+ const active = content.current?.ownerDocument.activeElement;
617
+ if (inside.current && !content.current?.contains(active ?? null)) focusPrimary();
675
618
  }, [phase, ghost.key]);
676
619
  const backToText = () => {
677
620
  if (inside.current) controller.focus();
@@ -681,7 +624,7 @@ function AiBar({ env, ghost, gone, barId }) {
681
624
  let gone2 = false;
682
625
  controller.edit(() => {
683
626
  const result = acceptAnswer(editor);
684
- gone2 = _nullishCoalesce(_optionalChain([result, 'optionalAccess', _45 => _45.gone]), () => ( false));
627
+ gone2 = result?.gone ?? false;
685
628
  return result !== null;
686
629
  });
687
630
  controller.focus();
@@ -698,7 +641,7 @@ function AiBar({ env, ghost, gone, barId }) {
698
641
  setNext("");
699
642
  };
700
643
  const primary = { [PRIMARY]: "" };
701
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
644
+ return /* @__PURE__ */ jsxRuntime.jsxs(
702
645
  "div",
703
646
  {
704
647
  ref: content,
@@ -707,7 +650,7 @@ function AiBar({ env, ghost, gone, barId }) {
707
650
  "aria-label": labels.response,
708
651
  className: "quoin-ai-bar flex flex-wrap items-center gap-2 rounded-md border bg-popover p-2 text-popover-foreground shadow-md",
709
652
  onFocus: () => inside.current = true,
710
- onBlur: (event) => inside.current = _nullishCoalesce(_optionalChain([content, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.contains, 'call', _48 => _48(event.relatedTarget)]), () => ( false)),
653
+ onBlur: (event) => inside.current = content.current?.contains(event.relatedTarget) ?? false,
711
654
  onKeyDown: (event) => {
712
655
  if (event.key !== "Escape" || event.nativeEvent.isComposing) return;
713
656
  event.preventDefault();
@@ -715,23 +658,23 @@ function AiBar({ env, ghost, gone, barId }) {
715
658
  else onDiscard();
716
659
  },
717
660
  children: [
718
- phase === "streaming" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
719
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-muted-foreground", children: labels.writing }),
720
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5R3ISX4Acjs.Button, { ...primary, size: "sm", variant: "outline", onClick: () => stop(editor), children: labels.stop })
661
+ phase === "streaming" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
662
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: labels.writing }),
663
+ /* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.Button, { ...primary, size: "sm", variant: "outline", onClick: () => stop(editor), children: labels.stop })
721
664
  ] }),
722
- phase === "error" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
723
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { role: "alert", className: "text-sm text-destructive", children: labels.failed }),
724
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5R3ISX4Acjs.Button, { ...primary, size: "sm", onClick: () => retry(editor, stream), children: labels.retry }),
725
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5R3ISX4Acjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard })
665
+ phase === "error" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
666
+ /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "text-sm text-destructive", children: labels.failed }),
667
+ /* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.Button, { ...primary, size: "sm", onClick: () => retry(editor, stream), children: labels.retry }),
668
+ /* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard })
726
669
  ] }),
727
- (phase === "done" || phase === "stopped") && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
728
- phase === "stopped" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-muted-foreground", children: labels.stopped }),
729
- gone && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "w-full text-xs text-muted-foreground", children: labels.targetGone }),
730
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5R3ISX4Acjs.Button, { ...primary, size: "sm", onClick: onAccept, children: labels.accept }),
731
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5R3ISX4Acjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard }),
732
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5R3ISX4Acjs.Button, { size: "sm", variant: "ghost", onClick: () => retry(editor, stream), children: labels.retry }),
733
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "form", { className: "w-full", onSubmit: onFollowUp, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
734
- _chunk5R3ISX4Acjs.Input,
670
+ (phase === "done" || phase === "stopped") && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
671
+ phase === "stopped" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: labels.stopped }),
672
+ gone && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "w-full text-xs text-muted-foreground", children: labels.targetGone }),
673
+ /* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.Button, { ...primary, size: "sm", onClick: onAccept, children: labels.accept }),
674
+ /* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard }),
675
+ /* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.Button, { size: "sm", variant: "ghost", onClick: () => retry(editor, stream), children: labels.retry }),
676
+ /* @__PURE__ */ jsxRuntime.jsx("form", { className: "w-full", onSubmit: onFollowUp, children: /* @__PURE__ */ jsxRuntime.jsx(
677
+ chunkQEMGOL5L_cjs.Input,
735
678
  {
736
679
  "aria-label": labels.followUp,
737
680
  placeholder: labels.followUp,
@@ -748,15 +691,12 @@ function AiBar({ env, ghost, gone, barId }) {
748
691
  );
749
692
  }
750
693
 
751
- // src/extensions/ai/AiGhost.tsx
752
-
753
-
754
694
  // src/extensions/ai/ai-ghost-render.ts
755
695
  var reader = null;
756
696
  function readerOf() {
757
697
  if (reader === null) {
758
- const schema = _chunkBTBHHBVRcjs.createSchema.call(void 0, );
759
- reader = { schema, codec: _chunkBTBHHBVRcjs.createBlockCodec.call(void 0, schema) };
698
+ const schema = chunkAIS37SL2_cjs.createSchema();
699
+ reader = { schema, codec: chunkAIS37SL2_cjs.createBlockCodec(schema) };
760
700
  }
761
701
  return reader;
762
702
  }
@@ -764,25 +704,22 @@ function fillGhost(ghost, markdown) {
764
704
  const doc = ghost.ownerDocument;
765
705
  const { schema, codec } = readerOf();
766
706
  const drawn2 = [];
767
- for (const block of _chunkBTBHHBVRcjs.fromMarkdown.call(void 0, markdown)) {
707
+ for (const block of chunkAIS37SL2_cjs.fromMarkdown(markdown)) {
768
708
  for (const piece of codec.toEngineBlocks(block)) {
769
709
  const element = doc.createElement("div");
770
710
  element.className = "quoin-ai-ghost-block";
771
- element.dataset.kind = String(_nullishCoalesce(piece.attrs.kind, () => ( piece.type.toLowerCase())));
711
+ element.dataset.kind = String(piece.attrs.kind ?? piece.type.toLowerCase());
772
712
  if (piece.attrs.level !== void 0) element.dataset.level = String(piece.attrs.level);
773
713
  if (piece.indent > 0) element.style.setProperty("--quoin-ai-indent", String(piece.indent));
774
- const region = _chunkHOIDJEVIcjs.primaryRegion.call(void 0, schema, piece);
775
- if (region === null) element.textContent = _chunkHOIDJEVIcjs.toPlainText.call(void 0, [codec.toQuoin(piece)], { schema });
776
- else _chunk5M4QG3ZCcjs.renderInline.call(void 0, element, piece.regions[region], []);
714
+ const region = chunkVFSVN5IQ_cjs.primaryRegion(schema, piece);
715
+ if (region === null) element.textContent = chunkVFSVN5IQ_cjs.toPlainText([codec.toQuoin(piece)], { schema });
716
+ else chunkACSEYJJF_cjs.renderInline(element, piece.regions[region], []);
777
717
  drawn2.push(element);
778
718
  }
779
719
  }
780
720
  ghost.replaceChildren(...drawn2);
781
721
  }
782
722
 
783
- // src/extensions/ai/use-ghost-place.ts
784
-
785
-
786
723
  // src/extensions/ai/keep-reader-still.ts
787
724
  function scrollerOf(root) {
788
725
  for (let element = root; element !== null; element = element.parentElement) {
@@ -790,7 +727,7 @@ function scrollerOf(root) {
790
727
  return element;
791
728
  }
792
729
  }
793
- return _nullishCoalesce(root.ownerDocument.scrollingElement, () => ( null));
730
+ return root.ownerDocument.scrollingElement ?? null;
794
731
  }
795
732
  function keepReaderStill(root, shell, change) {
796
733
  const scroller = scrollerOf(root);
@@ -808,7 +745,7 @@ function keepReaderStill(root, shell, change) {
808
745
  // src/extensions/ai/space-below.ts
809
746
  function rowGap(shell) {
810
747
  const parent = shell.parentElement;
811
- if (parent === null || !_optionalChain([shell, 'access', _49 => _49.nextElementSibling, 'optionalAccess', _50 => _50.hasAttribute, 'call', _51 => _51("data-block-id")])) return 0;
748
+ if (parent === null || !shell.nextElementSibling?.hasAttribute("data-block-id")) return 0;
812
749
  const { display, flexDirection, rowGap: gap } = getComputedStyle(parent);
813
750
  const column = display.includes("grid") || display.includes("flex") && flexDirection.startsWith("column");
814
751
  return column ? parseFloat(gap) || 0 : 0;
@@ -830,7 +767,7 @@ function place(controller, root, layer, block, region) {
830
767
  return;
831
768
  }
832
769
  layer.style.visibility = "";
833
- const host = _nullishCoalesce(controller.registry.get(block, region), () => ( shell));
770
+ const host = controller.registry.get(block, region) ?? shell;
834
771
  const origin = root.getBoundingClientRect();
835
772
  const scale = origin.width / root.offsetWidth || 1;
836
773
  const below = shell.getBoundingClientRect();
@@ -840,7 +777,7 @@ function place(controller, root, layer, block, region) {
840
777
  const top = (below.bottom - origin.top) / scale - padding - root.clientTop + root.scrollTop + GAP;
841
778
  layer.style.transform = `translate(${left}px, ${top}px)`;
842
779
  layer.style.width = `${text.width / scale}px`;
843
- clipAside(layer, text, _chunkLE5XMIFJcjs.clipBoxes.call(void 0, host, root), scale);
780
+ clipAside(layer, text, chunkLE5XMIFJ_cjs.clipBoxes(host, root), scale);
844
781
  const room = Math.max(0, layer.offsetHeight + 2 * GAP - padding - gap);
845
782
  keepReaderStill(root, shell, () => root.style.setProperty(ROOM2, `${room}px`));
846
783
  }
@@ -851,12 +788,12 @@ function clipAside(layer, text, areas, scale) {
851
788
  if (start + end >= text.width / scale && text.width > 0) layer.style.visibility = "hidden";
852
789
  }
853
790
  function useGhostPlace(controller, layer, block, region) {
854
- const placeNow = _react.useRef.call(void 0, () => {
791
+ const placeNow = react.useRef(() => {
855
792
  });
856
- _chunk5M4QG3ZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
793
+ chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
857
794
  const root = controller.root;
858
795
  const element = layer.current;
859
- const view = _optionalChain([root, 'optionalAccess', _52 => _52.ownerDocument, 'access', _53 => _53.defaultView]);
796
+ const view = root?.ownerDocument.defaultView;
860
797
  if (!root || !element || !view) return void 0;
861
798
  const update = () => place(controller, root, element, block, region);
862
799
  let frame = 0;
@@ -874,7 +811,7 @@ function useGhostPlace(controller, layer, block, region) {
874
811
  const unsubscribe = controller.editor.subscribe(later);
875
812
  const fonts = root.ownerDocument.fonts;
876
813
  root.addEventListener("scroll", later, { capture: true, passive: true });
877
- _optionalChain([fonts, 'optionalAccess', _54 => _54.addEventListener, 'call', _55 => _55("loadingdone", later)]);
814
+ fonts?.addEventListener("loadingdone", later);
878
815
  return () => {
879
816
  placeNow.current = () => {
880
817
  };
@@ -882,58 +819,46 @@ function useGhostPlace(controller, layer, block, region) {
882
819
  observer.disconnect();
883
820
  unsubscribe();
884
821
  root.removeEventListener("scroll", later, { capture: true });
885
- _optionalChain([fonts, 'optionalAccess', _56 => _56.removeEventListener, 'call', _57 => _57("loadingdone", later)]);
822
+ fonts?.removeEventListener("loadingdone", later);
886
823
  root.style.removeProperty(ROOM2);
887
824
  };
888
825
  }, [controller, layer, block, region]);
889
- return _react.useCallback.call(void 0, () => placeNow.current(), []);
826
+ return react.useCallback(() => placeNow.current(), []);
890
827
  }
891
-
892
- // src/extensions/ai/AiGhost.tsx
893
-
894
828
  function AiGhost({ env, ghost, target, gone, barId }) {
895
- const layer = _react.useRef.call(void 0, null);
896
- const drawn2 = _react.useRef.call(void 0, null);
829
+ const layer = react.useRef(null);
830
+ const drawn2 = react.useRef(null);
897
831
  const place2 = useGhostPlace(env.controller, layer, target.to.block, target.to.region);
898
- _chunk5M4QG3ZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
832
+ chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
899
833
  const element = drawn2.current;
900
834
  if (element === null) return;
901
835
  element.setAttribute("inert", "");
902
836
  fillGhost(element, ghost.shown);
903
837
  place2();
904
838
  }, [ghost.shown, ghost.phase, gone, place2]);
905
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref: layer, className: "quoin-ai-layer", children: [
906
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: drawn2, className: "quoin-ai-ghost", "aria-hidden": "true", "data-phase": ghost.phase }),
907
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AiBar, { env, ghost, gone, barId })
839
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: layer, className: "quoin-ai-layer", children: [
840
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: drawn2, className: "quoin-ai-ghost", "aria-hidden": "true", "data-phase": ghost.phase }),
841
+ /* @__PURE__ */ jsxRuntime.jsx(AiBar, { env, ghost, gone, barId })
908
842
  ] });
909
843
  }
910
-
911
- // src/extensions/ai/AiMenu.tsx
912
-
913
-
914
- // src/extensions/ai/use-target-anchor.ts
915
-
916
844
  function useTargetAnchor(controller, target) {
917
- const latest = _react.useRef.call(void 0, target);
918
- _chunk5M4QG3ZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
845
+ const latest = react.useRef(target);
846
+ chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
919
847
  latest.current = target;
920
848
  });
921
- return _react.useMemo.call(void 0, () => {
849
+ return react.useMemo(() => {
922
850
  const end = () => {
923
851
  const { to } = latest.current;
924
852
  return { block: to.block, region: to.region, from: to.offset, to: to.offset };
925
853
  };
926
854
  return {
927
- current: _chunk5R3ISX4Acjs.virtualAnchor.call(void 0,
928
- () => _chunk5R3ISX4Acjs.rangeRect.call(void 0, controller, end()),
855
+ current: chunkQEMGOL5L_cjs.virtualAnchor(
856
+ () => chunkQEMGOL5L_cjs.rangeRect(controller, end()),
929
857
  () => controller.registry.get(end().block, end().region)
930
858
  )
931
859
  };
932
860
  }, [controller]);
933
861
  }
934
-
935
- // src/extensions/ai/AiMenu.tsx
936
-
937
862
  function choicesFor(env, target, query) {
938
863
  const { labels } = env;
939
864
  const emptyLine = !target.selected && target.to.offset === 0;
@@ -946,12 +871,12 @@ function choicesFor(env, target, query) {
946
871
  }
947
872
  function AiMenu({ env, target, fromSpace }) {
948
873
  const { controller, labels } = env;
949
- const [query, setQuery] = _react.useState.call(void 0, "");
950
- const [asking, setAsking] = _react.useState.call(void 0, null);
951
- const [active, setActive] = _react.useState.call(void 0, 0);
952
- const field = _react.useRef.call(void 0, null);
874
+ const [query, setQuery] = react.useState("");
875
+ const [asking, setAsking] = react.useState(null);
876
+ const [active, setActive] = react.useState(0);
877
+ const field = react.useRef(null);
953
878
  const anchor = useTargetAnchor(controller, target);
954
- const id = _react.useId.call(void 0, );
879
+ const id = react.useId();
955
880
  const choices = asking === null ? choicesFor(env, target, query) : [];
956
881
  const current = Math.min(active, choices.length - 1);
957
882
  const optionId = (index) => `${id}-${index}`;
@@ -981,8 +906,8 @@ function AiMenu({ env, target, fromSpace }) {
981
906
  }
982
907
  };
983
908
  const fieldLabel = asking === "tone" ? labels.tonePrompt : asking === "translate" ? labels.translatePrompt : labels.prompt;
984
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
985
- _chunk5R3ISX4Acjs.Popover,
909
+ return /* @__PURE__ */ jsxRuntime.jsxs(
910
+ chunkQEMGOL5L_cjs.Popover,
986
911
  {
987
912
  open: true,
988
913
  modal: false,
@@ -990,9 +915,9 @@ function AiMenu({ env, target, fromSpace }) {
990
915
  if (!next) closeMenu(controller.editor);
991
916
  },
992
917
  children: [
993
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5R3ISX4Acjs.PopoverAnchor, { virtualRef: anchor }),
994
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
995
- _chunk5R3ISX4Acjs.PopoverContent,
918
+ /* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.PopoverAnchor, { virtualRef: anchor }),
919
+ /* @__PURE__ */ jsxRuntime.jsxs(
920
+ chunkQEMGOL5L_cjs.PopoverContent,
996
921
  {
997
922
  "aria-label": labels.askAi,
998
923
  side: "bottom",
@@ -1000,7 +925,7 @@ function AiMenu({ env, target, fromSpace }) {
1000
925
  className: "w-80 p-1",
1001
926
  onOpenAutoFocus: (event) => {
1002
927
  event.preventDefault();
1003
- _optionalChain([field, 'access', _58 => _58.current, 'optionalAccess', _59 => _59.focus, 'call', _60 => _60()]);
928
+ field.current?.focus();
1004
929
  },
1005
930
  onCloseAutoFocus: (event) => event.preventDefault(),
1006
931
  onEscapeKeyDown: (event) => {
@@ -1008,8 +933,8 @@ function AiMenu({ env, target, fromSpace }) {
1008
933
  close(fromSpace);
1009
934
  },
1010
935
  children: [
1011
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1012
- _chunk5R3ISX4Acjs.Input,
936
+ /* @__PURE__ */ jsxRuntime.jsx(
937
+ chunkQEMGOL5L_cjs.Input,
1013
938
  {
1014
939
  ref: field,
1015
940
  role: "combobox",
@@ -1027,13 +952,13 @@ function AiMenu({ env, target, fromSpace }) {
1027
952
  onKeyDown
1028
953
  }
1029
954
  ),
1030
- choices.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { id: `${id}-list`, role: "listbox", "aria-label": labels.menu, className: "mt-1 max-h-72 overflow-y-auto", children: choices.map((choice, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
955
+ choices.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { id: `${id}-list`, role: "listbox", "aria-label": labels.menu, className: "mt-1 max-h-72 overflow-y-auto", children: choices.map((choice, index) => /* @__PURE__ */ jsxRuntime.jsx(
1031
956
  "li",
1032
957
  {
1033
958
  id: optionId(index),
1034
959
  role: "option",
1035
960
  "aria-selected": index === current,
1036
- className: _chunk5R3ISX4Acjs.cn.call(void 0, _chunk5R3ISX4Acjs.MENU_ITEM, index === current && "bg-accent text-accent-foreground"),
961
+ className: chunkQEMGOL5L_cjs.cn(chunkQEMGOL5L_cjs.MENU_ITEM, index === current && "bg-accent text-accent-foreground"),
1037
962
  onMouseDown: (event) => event.preventDefault(),
1038
963
  onClick: () => choose(choice),
1039
964
  children: choice.label
@@ -1047,43 +972,40 @@ function AiMenu({ env, target, fromSpace }) {
1047
972
  }
1048
973
  );
1049
974
  }
1050
-
1051
- // src/extensions/ai/AiOverlay.tsx
1052
-
1053
975
  var goneOf = (state) => {
1054
976
  const { target, ghost } = aiState(state);
1055
977
  return target !== null && ghost !== null && targetGone(state.doc, target);
1056
978
  };
1057
- var plainText = (markdown) => _chunkHOIDJEVIcjs.toPlainText.call(void 0, _chunkBTBHHBVRcjs.fromMarkdown.call(void 0, markdown));
979
+ var plainText = (markdown) => chunkVFSVN5IQ_cjs.toPlainText(chunkAIS37SL2_cjs.fromMarkdown(markdown));
1058
980
  function AiOverlay({ controller, stream, labels }) {
1059
- const { onError } = _chunk5R3ISX4Acjs.useQuoin.call(void 0, );
981
+ const { onError } = chunkQEMGOL5L_cjs.useQuoin();
1060
982
  const link = linkOf(controller.editor);
1061
- _chunk5M4QG3ZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
983
+ chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
1062
984
  link.report = onError;
1063
985
  link.ended = (phase, output) => controller.announce((phase === "done" ? labels.written : labels.halted)(plainText(output)));
1064
986
  }, [link, onError, controller, labels]);
1065
- const value = _chunk5M4QG3ZCcjs.useEditorState.call(void 0, controller, aiState);
1066
- const gone = _chunk5M4QG3ZCcjs.useEditorState.call(void 0, controller, goneOf);
1067
- const readOnly = _chunk5M4QG3ZCcjs.useReadOnly.call(void 0, controller);
1068
- const env = _react.useMemo.call(void 0, () => ({ controller, stream, labels }), [controller, stream, labels]);
1069
- const barId = _react.useId.call(void 0, );
987
+ const value = chunkACSEYJJF_cjs.useEditorState(controller, aiState);
988
+ const gone = chunkACSEYJJF_cjs.useEditorState(controller, goneOf);
989
+ const readOnly = chunkACSEYJJF_cjs.useReadOnly(controller);
990
+ const env = react.useMemo(() => ({ controller, stream, labels }), [controller, stream, labels]);
991
+ const barId = react.useId();
1070
992
  const showing = value.ghost !== null;
1071
- _react.useEffect.call(void 0, () => {
993
+ react.useEffect(() => {
1072
994
  if (!showing) return;
1073
995
  const toBar = (event) => {
1074
996
  if (event.key !== "Escape" || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return false;
1075
- const bar = _optionalChain([controller, 'access', _61 => _61.root, 'optionalAccess', _62 => _62.ownerDocument, 'access', _63 => _63.getElementById, 'call', _64 => _64(barId)]);
1076
- _optionalChain([bar, 'optionalAccess', _65 => _65.querySelector, 'call', _66 => _66(`[${PRIMARY}]`), 'optionalAccess', _67 => _67.focus, 'call', _68 => _68()]);
997
+ const bar = controller.root?.ownerDocument.getElementById(barId);
998
+ bar?.querySelector(`[${PRIMARY}]`)?.focus();
1077
999
  return bar != null;
1078
1000
  };
1079
1001
  controller.keyInterceptors.add(toBar);
1080
1002
  return () => void controller.keyInterceptors.delete(toBar);
1081
1003
  }, [controller, showing, barId]);
1082
- _react.useEffect.call(void 0, () => {
1004
+ react.useEffect(() => {
1083
1005
  const root = controller.root;
1084
1006
  if (!root) return;
1085
1007
  let away = true;
1086
- return _chunkCLTHD5GOcjs.watchCanvasFocus.call(void 0, controller, root.ownerDocument, (inside, node) => {
1008
+ return chunkNO3KTZDY_cjs.watchCanvasFocus(controller, root.ownerDocument, (inside, node) => {
1087
1009
  if (!inside) away = true;
1088
1010
  else if (root.contains(node)) {
1089
1011
  if (away) noteFocus(controller.editor);
@@ -1091,7 +1013,7 @@ function AiOverlay({ controller, stream, labels }) {
1091
1013
  }
1092
1014
  });
1093
1015
  }, [controller]);
1094
- _react.useEffect.call(void 0,
1016
+ react.useEffect(
1095
1017
  () => controller.subscribeReadOnly(() => {
1096
1018
  if (!controller.readOnly) return;
1097
1019
  endRun(link);
@@ -1102,19 +1024,16 @@ function AiOverlay({ controller, stream, labels }) {
1102
1024
  [controller, link]
1103
1025
  );
1104
1026
  if (readOnly || value.target === null) return null;
1105
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1106
- value.menu !== null && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AiMenu, { env, target: value.target, fromSpace: value.menu.fromSpace }),
1107
- value.ghost !== null && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AiGhost, { env, ghost: value.ghost, target: value.target, gone, barId })
1027
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1028
+ value.menu !== null && /* @__PURE__ */ jsxRuntime.jsx(AiMenu, { env, target: value.target, fromSpace: value.menu.fromSpace }),
1029
+ value.ghost !== null && /* @__PURE__ */ jsxRuntime.jsx(AiGhost, { env, ghost: value.ghost, target: value.target, gone, barId })
1108
1030
  ] });
1109
1031
  }
1110
-
1111
- // src/extensions/ai/ai-extension.tsx
1112
-
1113
1032
  function aiExtension(options) {
1114
1033
  const { stream } = options;
1115
1034
  const labels = resolveAiLabels(options.labels);
1116
1035
  function Overlay({ controller }) {
1117
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AiOverlay, { controller, stream, labels });
1036
+ return /* @__PURE__ */ jsxRuntime.jsx(AiOverlay, { controller, stream, labels });
1118
1037
  }
1119
1038
  const ui = {
1120
1039
  slashItems: aiSlashItems(labels, stream),
@@ -1122,7 +1041,7 @@ function aiExtension(options) {
1122
1041
  blockMenuItems: [aiBlockMenuItem(labels)],
1123
1042
  overlays: [Overlay]
1124
1043
  };
1125
- return _chunkHOIDJEVIcjs.defineExtension.call(void 0, {
1044
+ return chunkVFSVN5IQ_cjs.defineExtension({
1126
1045
  name: "ai",
1127
1046
  plugins: [aiPlugin],
1128
1047
  decorations: aiDecorations,
@@ -1133,7 +1052,7 @@ function aiExtension(options) {
1133
1052
  if (link.mounts++ === 0) link.stopWatching = watchGhost(editor, link);
1134
1053
  return () => {
1135
1054
  if (--link.mounts > 0) return;
1136
- _optionalChain([link, 'access', _69 => _69.stopWatching, 'optionalCall', _70 => _70()]);
1055
+ link.stopWatching?.();
1137
1056
  link.stopWatching = null;
1138
1057
  endRun(link);
1139
1058
  };
@@ -1142,7 +1061,7 @@ function aiExtension(options) {
1142
1061
  });
1143
1062
  }
1144
1063
 
1145
-
1146
-
1147
- exports.aiExtension = aiExtension; exports.englishAiLabels = englishAiLabels;
1064
+ exports.aiExtension = aiExtension;
1065
+ exports.englishAiLabels = englishAiLabels;
1066
+ //# sourceMappingURL=ai.cjs.map
1148
1067
  //# sourceMappingURL=ai.cjs.map