quoin-editor 1.0.2 → 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 +18 -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-DUE3HCZD.js → chunk-2EQ6FKSK.js} +19 -28
  11. package/dist/chunk-2EQ6FKSK.js.map +1 -0
  12. package/dist/{chunk-RJRX34BZ.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-U3LOLYAU.js → chunk-7FAVFJAS.js} +4 -10
  17. package/dist/chunk-7FAVFJAS.js.map +1 -0
  18. package/dist/{chunk-6V6GGBDK.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-P6KYXFZC.cjs → chunk-ACSEYJJF.cjs} +426 -534
  23. package/dist/chunk-ACSEYJJF.cjs.map +1 -0
  24. package/dist/{chunk-4SLJNZSM.cjs → chunk-AIS37SL2.cjs} +201 -198
  25. package/dist/chunk-AIS37SL2.cjs.map +1 -0
  26. package/dist/{chunk-X4HDKFW5.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-6NULZPVC.js → chunk-HTLWPSMU.js} +8 -61
  33. package/dist/chunk-HTLWPSMU.js.map +1 -0
  34. package/dist/{chunk-ADSJ42DO.js → chunk-HWEK7EX5.js} +17 -69
  35. package/dist/chunk-HWEK7EX5.js.map +1 -0
  36. package/dist/{chunk-623AOJM2.js → chunk-ITXCE6KL.js} +7 -25
  37. package/dist/chunk-ITXCE6KL.js.map +1 -0
  38. package/dist/{chunk-AUOEM3SF.cjs → chunk-IXVGHH7F.cjs} +102 -155
  39. package/dist/chunk-IXVGHH7F.cjs.map +1 -0
  40. package/dist/{chunk-NEZJ7ZP5.js → chunk-JZJIWRF3.js} +4 -8
  41. package/dist/chunk-JZJIWRF3.js.map +1 -0
  42. package/dist/{chunk-C23RQVRK.js → chunk-KSF2HILJ.js} +66 -216
  43. package/dist/chunk-KSF2HILJ.js.map +1 -0
  44. package/dist/{chunk-OBMBSU2S.js → chunk-L4D23LM2.js} +5 -184
  45. package/dist/chunk-L4D23LM2.js.map +1 -0
  46. package/dist/{chunk-4XFXB37X.js → chunk-L6OW2FL3.js} +7 -90
  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-5MAYUGTE.cjs → chunk-LY2D45F2.cjs} +233 -363
  51. package/dist/chunk-LY2D45F2.cjs.map +1 -0
  52. package/dist/{chunk-VCLL5C7J.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-TLGX43P6.cjs → chunk-OM7E43ZN.cjs} +89 -86
  59. package/dist/chunk-OM7E43ZN.cjs.map +1 -0
  60. package/dist/{chunk-JHQUHFLX.js → chunk-PJCHSHM3.js} +38 -120
  61. package/dist/chunk-PJCHSHM3.js.map +1 -0
  62. package/dist/{chunk-EPARJI4V.js → chunk-QC35D2AU.js} +107 -262
  63. package/dist/chunk-QC35D2AU.js.map +1 -0
  64. package/dist/{chunk-CW3AFJBR.cjs → chunk-QEMGOL5L.cjs} +1302 -1773
  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-IQBMAE3F.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-VRS6WCEK.js → chunk-SAEQMDAU.js} +60 -167
  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-N4FGA3H4.js → chunk-TBCHYHNU.js} +38 -105
  77. package/dist/chunk-TBCHYHNU.js.map +1 -0
  78. package/dist/{chunk-OSHZQR3W.js → chunk-TNN6Z52D.js} +13 -45
  79. package/dist/chunk-TNN6Z52D.js.map +1 -0
  80. package/dist/{chunk-YBMUEEM5.js → chunk-TYZSB7JT.js} +4 -8
  81. package/dist/chunk-TYZSB7JT.js.map +1 -0
  82. package/dist/{chunk-ZKVOS57Q.cjs → chunk-VFSVN5IQ.cjs} +495 -551
  83. package/dist/chunk-VFSVN5IQ.cjs.map +1 -0
  84. package/dist/{chunk-FDRUAL3Z.cjs → chunk-WDO6DBYU.cjs} +90 -153
  85. package/dist/chunk-WDO6DBYU.cjs.map +1 -0
  86. package/dist/{chunk-WEYDDIBQ.cjs → chunk-WHV5ZSIO.cjs} +36 -64
  87. package/dist/chunk-WHV5ZSIO.cjs.map +1 -0
  88. package/dist/{chunk-T43RZTUT.js → chunk-XJDPQFPU.js} +693 -1247
  89. package/dist/chunk-XJDPQFPU.js.map +1 -0
  90. package/dist/{chunk-BQANU5BH.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 -65
  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 +8 -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 +98 -132
  149. package/dist/presence.cjs.map +1 -1
  150. package/dist/presence.js +21 -78
  151. package/dist/presence.js.map +1 -1
  152. package/dist/{registry-CWBOSAHm.d.ts → registry-CXegaw5k.d.cts} +25 -2
  153. package/dist/{registry-CWBOSAHm.d.cts → 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 +186 -228
  174. package/dist/yjs.cjs.map +1 -1
  175. package/dist/yjs.js +12 -80
  176. package/dist/yjs.js.map +1 -1
  177. package/package.json +1 -1
  178. package/dist/chunk-4SLJNZSM.cjs.map +0 -1
  179. package/dist/chunk-4XFXB37X.js.map +0 -1
  180. package/dist/chunk-5MAYUGTE.cjs.map +0 -1
  181. package/dist/chunk-623AOJM2.js.map +0 -1
  182. package/dist/chunk-6NULZPVC.js.map +0 -1
  183. package/dist/chunk-6V6GGBDK.cjs.map +0 -1
  184. package/dist/chunk-73653CJ4.cjs +0 -34
  185. package/dist/chunk-73653CJ4.cjs.map +0 -1
  186. package/dist/chunk-ADSJ42DO.js.map +0 -1
  187. package/dist/chunk-AUOEM3SF.cjs.map +0 -1
  188. package/dist/chunk-BQANU5BH.cjs.map +0 -1
  189. package/dist/chunk-C23RQVRK.js.map +0 -1
  190. package/dist/chunk-CW3AFJBR.cjs.map +0 -1
  191. package/dist/chunk-DUE3HCZD.js.map +0 -1
  192. package/dist/chunk-EH5KXQXY.cjs.map +0 -1
  193. package/dist/chunk-EPARJI4V.js.map +0 -1
  194. package/dist/chunk-FDRUAL3Z.cjs.map +0 -1
  195. package/dist/chunk-IQBMAE3F.js.map +0 -1
  196. package/dist/chunk-JHQUHFLX.js.map +0 -1
  197. package/dist/chunk-KUYZMSMF.cjs +0 -100
  198. package/dist/chunk-KUYZMSMF.cjs.map +0 -1
  199. package/dist/chunk-LLTEGXWZ.cjs +0 -562
  200. package/dist/chunk-LLTEGXWZ.cjs.map +0 -1
  201. package/dist/chunk-N4FGA3H4.js.map +0 -1
  202. package/dist/chunk-NEZJ7ZP5.js.map +0 -1
  203. package/dist/chunk-O4Z2WMFF.js.map +0 -1
  204. package/dist/chunk-OBMBSU2S.js.map +0 -1
  205. package/dist/chunk-OSHZQR3W.js.map +0 -1
  206. package/dist/chunk-P6KYXFZC.cjs.map +0 -1
  207. package/dist/chunk-R2BLBV43.cjs +0 -239
  208. package/dist/chunk-R2BLBV43.cjs.map +0 -1
  209. package/dist/chunk-RJRX34BZ.js.map +0 -1
  210. package/dist/chunk-T43RZTUT.js.map +0 -1
  211. package/dist/chunk-TLGX43P6.cjs.map +0 -1
  212. package/dist/chunk-U3LOLYAU.js.map +0 -1
  213. package/dist/chunk-UEKXVCKC.cjs +0 -716
  214. package/dist/chunk-UEKXVCKC.cjs.map +0 -1
  215. package/dist/chunk-VCLL5C7J.js.map +0 -1
  216. package/dist/chunk-VRS6WCEK.js.map +0 -1
  217. package/dist/chunk-WEYDDIBQ.cjs.map +0 -1
  218. package/dist/chunk-X4HDKFW5.cjs.map +0 -1
  219. package/dist/chunk-X4P4TQXH.cjs +0 -30
  220. package/dist/chunk-X4P4TQXH.cjs.map +0 -1
  221. package/dist/chunk-XA3UEJIW.cjs +0 -25
  222. package/dist/chunk-XA3UEJIW.cjs.map +0 -1
  223. package/dist/chunk-YBMUEEM5.js.map +0 -1
  224. package/dist/chunk-ZKVOS57Q.cjs.map +0 -1
package/dist/comments.cjs CHANGED
@@ -1,64 +1,49 @@
1
- 'use client';"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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 _chunkXA3UEJIWcjs = require('./chunk-XA3UEJIW.cjs');
5
-
6
-
7
- var _chunk73653CJ4cjs = require('./chunk-73653CJ4.cjs');
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
- var _chunkCW3AFJBRcjs = require('./chunk-CW3AFJBR.cjs');
20
-
21
-
22
-
23
-
24
- var _chunkP6KYXFZCcjs = require('./chunk-P6KYXFZC.cjs');
25
- require('./chunk-EH5KXQXY.cjs');
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
- var _chunkZKVOS57Qcjs = require('./chunk-ZKVOS57Q.cjs');
39
- require('./chunk-6V6GGBDK.cjs');
40
-
41
-
42
-
43
-
44
-
45
-
46
- var _chunk4SLJNZSMcjs = require('./chunk-4SLJNZSM.cjs');
1
+ 'use client';'use strict';
2
+
3
+ var chunkRIIXJWBR_cjs = require('./chunk-RIIXJWBR.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');
14
+ var DialogPrimitive = require('@radix-ui/react-dialog');
15
+
16
+ function _interopNamespace(e) {
17
+ if (e && e.__esModule) return e;
18
+ var n = Object.create(null);
19
+ if (e) {
20
+ Object.keys(e).forEach(function (k) {
21
+ if (k !== 'default') {
22
+ var d = Object.getOwnPropertyDescriptor(e, k);
23
+ Object.defineProperty(n, k, d.get ? d : {
24
+ enumerable: true,
25
+ get: function () { return e[k]; }
26
+ });
27
+ }
28
+ });
29
+ }
30
+ n.default = e;
31
+ return Object.freeze(n);
32
+ }
47
33
 
48
- // src/extensions/comments/comments-extension.tsx
49
- var _lucidereact = require('lucide-react');
34
+ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
50
35
 
51
36
  // src/extensions/comments/comment-anchors.ts
52
- var idsOf = (node) => _nullishCoalesce(_optionalChain([node, 'optionalAccess', _2 => _2.marks, 'access', _3 => _3.flatMap, 'call', _4 => _4((mark) => mark.type === "comment" && _optionalChain([mark, 'access', _5 => _5.attrs, 'optionalAccess', _6 => _6.id]) ? [mark.attrs.id] : [])]), () => ( []));
37
+ var idsOf = (node) => node?.marks.flatMap((mark) => mark.type === "comment" && mark.attrs?.id ? [mark.attrs.id] : []) ?? [];
53
38
  function addRegion(anchors, block, region, inline2) {
54
39
  let position = 0;
55
40
  for (const node of inline2) {
56
41
  const from = position;
57
- position += _chunk4SLJNZSMcjs.nodeLength.call(void 0, node);
42
+ position += chunkAIS37SL2_cjs.nodeLength(node);
58
43
  for (const id of idsOf(node)) {
59
- const ranges = _nullishCoalesce(anchors.get(id), () => ( []));
44
+ const ranges = anchors.get(id) ?? [];
60
45
  const last = ranges[ranges.length - 1];
61
- const continues = _optionalChain([last, 'optionalAccess', _7 => _7.block]) === block && last.region === region && last.to === from;
46
+ const continues = last?.block === block && last.region === region && last.to === from;
62
47
  if (continues) ranges[ranges.length - 1] = { ...last, to: position };
63
48
  else ranges.push({ block, region, from, to: position });
64
49
  anchors.set(id, ranges);
@@ -78,28 +63,28 @@ function commentAnchors(doc) {
78
63
  }
79
64
  return anchors;
80
65
  }
81
- var atomLabel = (node) => node.kind === "atom" ? _nullishCoalesce(node.attrs.label, () => ( "")) : "";
66
+ var atomLabel = (node) => node.kind === "atom" ? node.attrs.label ?? "" : "";
82
67
  function anchorText(doc, ranges) {
83
68
  return ranges.map(({ block, region, from, to }) => {
84
- const inline2 = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, doc, block), 'optionalAccess', _8 => _8.regions, 'access', _9 => _9[region]]), () => ( []));
85
- return _chunk4SLJNZSMcjs.inlineText.call(void 0, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline2, from, to), atomLabel);
69
+ const inline2 = chunkAIS37SL2_cjs.blockById(doc, block)?.regions[region] ?? [];
70
+ return chunkAIS37SL2_cjs.inlineText(chunkAIS37SL2_cjs.sliceInline(inline2, from, to), atomLabel);
86
71
  }).join(" ");
87
72
  }
88
73
  function commentIdsAt(doc, { block, region, offset }) {
89
- const inline2 = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, doc, block), 'optionalAccess', _10 => _10.regions, 'access', _11 => _11[region]]), () => ( []));
74
+ const inline2 = chunkAIS37SL2_cjs.blockById(doc, block)?.regions[region] ?? [];
90
75
  const ids = /* @__PURE__ */ new Set();
91
76
  let position = 0;
92
77
  for (const node of inline2) {
93
- const end = position + _chunk4SLJNZSMcjs.nodeLength.call(void 0, node);
78
+ const end = position + chunkAIS37SL2_cjs.nodeLength(node);
94
79
  if (position <= offset && offset <= end && end > position) idsOf(node).forEach((id) => ids.add(id));
95
80
  position = end;
96
81
  }
97
82
  return [...ids].sort();
98
83
  }
99
84
  function threadRemoval(state, id) {
100
- const tr = new (0, _chunkZKVOS57Qcjs.Transaction)(state).setOrigin("command");
101
- for (const { block, region, from, to } of _nullishCoalesce(commentAnchors(state.doc).get(id), () => ( []))) {
102
- tr.step(_chunkZKVOS57Qcjs.removeMarkStep.call(void 0, block, region, from, to, { type: "comment", attrs: { id } }));
85
+ const tr = new chunkVFSVN5IQ_cjs.Transaction(state).setOrigin("command");
86
+ for (const { block, region, from, to } of commentAnchors(state.doc).get(id) ?? []) {
87
+ tr.step(chunkVFSVN5IQ_cjs.removeMarkStep(block, region, from, to, { type: "comment", attrs: { id } }));
103
88
  }
104
89
  return tr;
105
90
  }
@@ -110,14 +95,14 @@ function mapPendingRanges(tr, ranges, state) {
110
95
  const from = tr.mapPos({ block: range.block, region: range.region, offset: range.from }, 1);
111
96
  const to = tr.mapPos({ block: range.block, region: range.region, offset: range.to }, -1);
112
97
  const { index } = state.doc;
113
- if (!index.has(from.block) || !index.has(to.block) || _chunkZKVOS57Qcjs.comparePos.call(void 0, state.doc, from, to) >= 0) return [];
114
- return _chunkZKVOS57Qcjs.markRanges.call(void 0, { ...state, selection: _chunkZKVOS57Qcjs.textSelection.call(void 0, from, to) });
98
+ if (!index.has(from.block) || !index.has(to.block) || chunkVFSVN5IQ_cjs.comparePos(state.doc, from, to) >= 0) return [];
99
+ return chunkVFSVN5IQ_cjs.markRanges({ ...state, selection: chunkVFSVN5IQ_cjs.textSelection(from, to) });
115
100
  });
116
101
  }
117
102
 
118
103
  // src/extensions/comments/comments-plugin.ts
119
- var isEnded = (ended, id, current) => ended.some((thread) => thread.id === id && _optionalChain([thread, 'access', _12 => _12.seen, 'optionalAccess', _13 => _13.resolved]) === _optionalChain([current, 'optionalAccess', _14 => _14.resolved]));
120
- var commentsKey = _chunkZKVOS57Qcjs.createPluginKey.call(void 0, "comments");
104
+ var isEnded = (ended, id, current) => ended.some((thread) => thread.id === id && thread.seen?.resolved === current?.resolved);
105
+ var commentsKey = chunkVFSVN5IQ_cjs.createPluginKey("comments");
121
106
  var COMMENTS = "comments";
122
107
  var IDLE = { pending: [], active: null, open: null, ended: [] };
123
108
  function act(value, action) {
@@ -127,7 +112,7 @@ function act(value, action) {
127
112
  case "settled": {
128
113
  const pending = value.pending.filter(({ key }) => key !== action.key);
129
114
  if (action.open === void 0) return { ...value, pending };
130
- return { ...value, pending, active: _nullishCoalesce(action.open.ids[0], () => ( null)), open: action.open };
115
+ return { ...value, pending, active: action.open.ids[0] ?? null, open: action.open };
131
116
  }
132
117
  case "activate":
133
118
  return value.active === action.id ? value : { ...value, active: action.id };
@@ -137,7 +122,7 @@ function act(value, action) {
137
122
  return value.open === null ? value : { ...value, active: null, open: null };
138
123
  case "forget": {
139
124
  const active = value.active === action.id ? null : value.active;
140
- const open = _optionalChain([value, 'access', _15 => _15.open, 'optionalAccess', _16 => _16.ids, 'access', _17 => _17.includes, 'call', _18 => _18(action.id)]) ? null : value.open;
125
+ const open = value.open?.ids.includes(action.id) ? null : value.open;
141
126
  const ended = [...value.ended.filter(({ id }) => id !== action.id), { id: action.id, seen: action.seen }];
142
127
  return { ...value, active, open, ended };
143
128
  }
@@ -155,7 +140,7 @@ function afterMove(tr, value, state) {
155
140
  const { open } = value;
156
141
  if (open === null || open.focus || !tr.selectionSet || !WRITER_MOVES.includes(tr.origin)) return value;
157
142
  const { selection } = state;
158
- const here = _optionalChain([selection, 'optionalAccess', _19 => _19.kind]) === "text" ? commentIdsAt(state.doc, selection.head) : [];
143
+ const here = selection?.kind === "text" ? commentIdsAt(state.doc, selection.head) : [];
159
144
  return open.ids.some((id) => here.includes(id)) ? value : { ...value, active: null, open: null };
160
145
  }
161
146
  var commentsPlugin = {
@@ -170,26 +155,26 @@ var commentsPlugin = {
170
155
 
171
156
  // src/extensions/comments/comment-create.ts
172
157
  var nextKey = 0;
173
- var hasCommentableText = (state) => _optionalChain([state, 'access', _20 => _20.selection, 'optionalAccess', _21 => _21.kind]) === "text" && _chunkZKVOS57Qcjs.markRanges.call(void 0, state).length > 0;
158
+ var hasCommentableText = (state) => state.selection?.kind === "text" && chunkVFSVN5IQ_cjs.markRanges(state).length > 0;
174
159
  var requestComment = (state, dispatch) => {
175
160
  const { selection } = state;
176
- if (_optionalChain([selection, 'optionalAccess', _22 => _22.kind]) !== "text" || _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey).pending.length > 0) return false;
177
- const ranges = _chunkZKVOS57Qcjs.markRanges.call(void 0, state);
161
+ if (selection?.kind !== "text" || chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey).pending.length > 0) return false;
162
+ const ranges = chunkVFSVN5IQ_cjs.markRanges(state);
178
163
  if (ranges.length === 0) return false;
179
164
  if (dispatch === void 0) return true;
180
165
  const pending = { key: ++nextKey, ranges, selection };
181
166
  const action = { type: "pending", pending };
182
- dispatch(new (0, _chunkZKVOS57Qcjs.Transaction)(state).setMeta(COMMENTS, action).setMeta("addToHistory", false));
167
+ dispatch(new chunkVFSVN5IQ_cjs.Transaction(state).setMeta(COMMENTS, action).setMeta("addToHistory", false));
183
168
  return true;
184
169
  };
185
170
  function settledTransaction(editor, key, id) {
186
- const pending = _chunkZKVOS57Qcjs.getPluginState.call(void 0, editor.state, commentsKey).pending.find((anchor) => anchor.key === key);
171
+ const pending = chunkVFSVN5IQ_cjs.getPluginState(editor.state, commentsKey).pending.find((anchor) => anchor.key === key);
187
172
  const tr = editor.createTransaction().setOrigin("command");
188
- const ranges = id === null ? [] : _nullishCoalesce(_optionalChain([pending, 'optionalAccess', _23 => _23.ranges]), () => ( []));
173
+ const ranges = id === null ? [] : pending?.ranges ?? [];
189
174
  for (const { block, region, from, to } of ranges) {
190
- tr.step(_chunkZKVOS57Qcjs.addMarkStep.call(void 0, block, region, from, to, { type: "comment", attrs: { id } }));
175
+ tr.step(chunkVFSVN5IQ_cjs.addMarkStep(block, region, from, to, { type: "comment", attrs: { id } }));
191
176
  }
192
- const untouched = pending !== void 0 && _chunkZKVOS57Qcjs.sameSelection.call(void 0, editor.state.selection, pending.selection);
177
+ const untouched = pending !== void 0 && chunkVFSVN5IQ_cjs.sameSelection(editor.state.selection, pending.selection);
193
178
  const open = id !== null && ranges.length > 0 && untouched ? { ids: [id], focus: true } : void 0;
194
179
  const action = { type: "settled", key, open };
195
180
  return tr.setMeta(COMMENTS, action);
@@ -200,7 +185,7 @@ function create(editor, pending, onCreate, link) {
200
185
  if (link.mounts === 0) return;
201
186
  const tr = settledTransaction(editor, pending.key, id);
202
187
  editor.dispatch(tr);
203
- if (id === null) link.report(_chunkCW3AFJBRcjs.toError.call(void 0, error));
188
+ if (id === null) link.report(chunkQEMGOL5L_cjs.toError(error));
204
189
  else if (!tr.docChanged) link.report(new Error(`Comment thread ${id} has no text: it was deleted meanwhile`));
205
190
  };
206
191
  new Promise((resolve) => resolve(onCreate(input))).then(
@@ -210,30 +195,30 @@ function create(editor, pending, onCreate, link) {
210
195
  }
211
196
  function watchCreates(editor, onCreate, link) {
212
197
  return editor.subscribe((_, tr) => {
213
- const action = _optionalChain([tr, 'optionalAccess', _24 => _24.getMeta, 'call', _25 => _25(COMMENTS)]);
214
- if (_optionalChain([action, 'optionalAccess', _26 => _26.type]) === "pending") create(editor, action.pending, onCreate, link);
198
+ const action = tr?.getMeta(COMMENTS);
199
+ if (action?.type === "pending") create(editor, action.pending, onCreate, link);
215
200
  });
216
201
  }
217
202
 
218
203
  // src/extensions/comments/comment-open.ts
219
204
  function openIds(state, threads, ids) {
220
- const { ended } = _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey);
205
+ const { ended } = chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey);
221
206
  return ids.filter((id) => {
222
207
  const thread = threads.find(id);
223
- return _optionalChain([thread, 'optionalAccess', _27 => _27.resolved]) === false && !isEnded(ended, id, thread);
208
+ return thread?.resolved === false && !isEnded(ended, id, thread);
224
209
  });
225
210
  }
226
211
  function commentsTransaction(state, action) {
227
- return new (0, _chunkZKVOS57Qcjs.Transaction)(state).setMeta(COMMENTS, action).setMeta("addToHistory", false);
212
+ return new chunkVFSVN5IQ_cjs.Transaction(state).setMeta(COMMENTS, action).setMeta("addToHistory", false);
228
213
  }
229
214
  function commentCommand(threads) {
230
215
  return (state, dispatch) => {
231
216
  if (requestComment(state, dispatch)) return true;
232
217
  const { selection } = state;
233
- if (_optionalChain([selection, 'optionalAccess', _28 => _28.kind]) !== "text" || !_chunkZKVOS57Qcjs.isCollapsed.call(void 0, selection)) return false;
218
+ if (selection?.kind !== "text" || !chunkVFSVN5IQ_cjs.isCollapsed(selection)) return false;
234
219
  const ids = openIds(state, threads, commentIdsAt(state.doc, selection.head));
235
220
  if (ids.length === 0) return false;
236
- _optionalChain([dispatch, 'optionalCall', _29 => _29(commentsTransaction(state, { type: "open", open: { ids, focus: true } }))]);
221
+ dispatch?.(commentsTransaction(state, { type: "open", open: { ids, focus: true } }));
237
222
  return true;
238
223
  };
239
224
  }
@@ -261,7 +246,7 @@ var englishCommentsLabels = {
261
246
  postedAt: englishDate
262
247
  };
263
248
  function resolveCommentsLabels(overrides) {
264
- const given = Object.entries(_nullishCoalesce(overrides, () => ( {}))).filter(([, value]) => value !== void 0);
249
+ const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
265
250
  return given.length === 0 ? englishCommentsLabels : { ...englishCommentsLabels, ...Object.fromEntries(given) };
266
251
  }
267
252
 
@@ -276,17 +261,11 @@ function linkOf(editor) {
276
261
  return link;
277
262
  }
278
263
 
279
- // src/extensions/comments/CommentsOverlay.tsx
280
- var _react = require('react');
281
-
282
- // src/extensions/comments/CommentMarkers.tsx
283
-
284
-
285
264
  // src/extensions/comments/rail-layout.ts
286
265
  function stackTops(items, gap) {
287
266
  let next = 0;
288
267
  return items.map(({ top, height }) => {
289
- const placed = Math.max(_nullishCoalesce(top, () => ( next)), next);
268
+ const placed = Math.max(top ?? next, next);
290
269
  next = placed + height + gap;
291
270
  return placed;
292
271
  });
@@ -304,7 +283,7 @@ function place(controller, box, gap) {
304
283
  if (root === null) return;
305
284
  const items = Array.from(box.querySelectorAll("[data-rail-item]"));
306
285
  const tops = stackTops(
307
- items.map((item) => ({ top: topOf(controller, root, _nullishCoalesce(item.dataset.block, () => ( ""))), height: item.offsetHeight })),
286
+ items.map((item) => ({ top: topOf(controller, root, item.dataset.block ?? ""), height: item.offsetHeight })),
308
287
  gap
309
288
  );
310
289
  items.forEach((item, i) => item.style.transform = `translateY(${tops[i]}px)`);
@@ -312,9 +291,9 @@ function place(controller, box, gap) {
312
291
  root.style.setProperty(HEIGHT, `${bottom}px`);
313
292
  }
314
293
  function useBlockAligned(controller, box, gap, key) {
315
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
294
+ chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
316
295
  const element = box.current;
317
- const view = _optionalChain([element, 'optionalAccess', _30 => _30.ownerDocument, 'access', _31 => _31.defaultView]);
296
+ const view = element?.ownerDocument.defaultView;
318
297
  if (!element || !view) return void 0;
319
298
  const update = () => place(controller, element, gap);
320
299
  update();
@@ -331,19 +310,16 @@ function useBlockAligned(controller, box, gap, key) {
331
310
  view.cancelAnimationFrame(frame);
332
311
  unsubscribe();
333
312
  observer.disconnect();
334
- _optionalChain([element, 'access', _32 => _32.parentElement, 'optionalAccess', _33 => _33.style, 'access', _34 => _34.removeProperty, 'call', _35 => _35(HEIGHT)]);
313
+ element.parentElement?.style.removeProperty(HEIGHT);
335
314
  };
336
315
  }, [controller, box, gap, key]);
337
316
  }
338
-
339
- // src/extensions/comments/CommentMarkers.tsx
340
- var _jsxruntime = require('react/jsx-runtime');
341
317
  var GAP = 4;
342
318
  function groupsOf(entries) {
343
319
  const groups = /* @__PURE__ */ new Map();
344
320
  for (const { thread, ranges } of entries) {
345
- const block = _nullishCoalesce(_optionalChain([ranges, 'access', _36 => _36[0], 'optionalAccess', _37 => _37.block]), () => ( ""));
346
- groups.set(block, [..._nullishCoalesce(groups.get(block), () => ( [])), thread.id]);
321
+ const block = ranges[0]?.block ?? "";
322
+ groups.set(block, [...groups.get(block) ?? [], thread.id]);
347
323
  }
348
324
  const removed = groups.get("");
349
325
  groups.delete("");
@@ -352,17 +328,17 @@ function groupsOf(entries) {
352
328
  function CommentMarkers({ env, box, entries, onOpen }) {
353
329
  const groups = groupsOf(entries);
354
330
  useBlockAligned(env.controller, box, GAP, groups.map(({ block, ids }) => `${block}:${ids}`).join(" "));
355
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: box, className: "quoin-comments-markers", children: groups.map(({ block, ids }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
331
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: box, className: "quoin-comments-markers", children: groups.map(({ block, ids }) => /* @__PURE__ */ jsxRuntime.jsxs(
356
332
  "button",
357
333
  {
358
334
  type: "button",
359
335
  "data-rail-item": "",
360
336
  "data-block": block,
361
337
  "aria-label": env.labels.showComments(ids.length),
362
- className: _chunkCW3AFJBRcjs.cn.call(void 0, "quoin-comments-marker", _chunkCW3AFJBRcjs.FOCUS_RING),
338
+ className: chunkQEMGOL5L_cjs.cn("quoin-comments-marker", chunkQEMGOL5L_cjs.FOCUS_RING),
363
339
  onClick: (event) => onOpen(ids[0], event.currentTarget),
364
340
  children: [
365
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.MessageSquare, { "aria-hidden": "true" }),
341
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { "aria-hidden": "true" }),
366
342
  ids.length
367
343
  ]
368
344
  },
@@ -370,41 +346,31 @@ function CommentMarkers({ env, box, entries, onOpen }) {
370
346
  )) });
371
347
  }
372
348
 
373
- // src/extensions/comments/ThreadCard.tsx
374
-
375
-
376
- // src/extensions/comments/ThreadView.tsx
377
-
378
-
379
349
  // src/extensions/comments/comment-actions.ts
380
350
  async function called(link, call) {
381
351
  try {
382
352
  await call();
383
353
  return true;
384
354
  } catch (error) {
385
- link.report(_chunkCW3AFJBRcjs.toError.call(void 0, error));
355
+ link.report(chunkQEMGOL5L_cjs.toError(error));
386
356
  return false;
387
357
  }
388
358
  }
389
359
  async function endThread(editor, link, call, id, threads) {
390
360
  if (!await called(link, () => call(id)) || link.mounts === 0) return false;
391
- const action = { type: "forget", id, seen: _optionalChain([threads, 'optionalAccess', _38 => _38.find, 'call', _39 => _39(id)]) };
361
+ const action = { type: "forget", id, seen: threads?.find(id) };
392
362
  editor.dispatch(threadRemoval(editor.state, id).setMeta(COMMENTS, action));
393
363
  return true;
394
364
  }
395
365
  function sendReply(link, call, id, body) {
396
366
  return called(link, () => call(id, body));
397
367
  }
398
-
399
- // src/extensions/comments/CommentAvatar.tsx
400
-
401
-
402
- var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((word) => _nullishCoalesce(_optionalChain([Array, 'access', _40 => _40.from, 'call', _41 => _41(word), 'access', _42 => _42[0], 'optionalAccess', _43 => _43.toUpperCase, 'call', _44 => _44()]), () => ( ""))).join("");
368
+ var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((word) => Array.from(word)[0]?.toUpperCase() ?? "").join("");
403
369
  function CommentAvatar({ author }) {
404
- const picture = _chunkXA3UEJIWcjs.webAddress.call(void 0, author.avatarUrl);
405
- const [failed, setFailed] = _react.useState.call(void 0, null);
370
+ const picture = chunkRIIXJWBR_cjs.webAddress(author.avatarUrl);
371
+ const [failed, setFailed] = react.useState(null);
406
372
  if (picture !== null && picture !== failed) {
407
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
373
+ return /* @__PURE__ */ jsxRuntime.jsx(
408
374
  "img",
409
375
  {
410
376
  src: picture,
@@ -417,35 +383,27 @@ function CommentAvatar({ author }) {
417
383
  }
418
384
  );
419
385
  }
420
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "aria-hidden": "true", className: "quoin-comments-initials", children: initials(author.name) });
386
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "quoin-comments-initials", children: initials(author.name) });
421
387
  }
422
-
423
- // src/extensions/comments/CommentItem.tsx
424
-
425
388
  function CommentItem({ comment, labels }) {
426
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { className: "flex gap-2", children: [
427
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentAvatar, { author: comment.author }),
428
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "min-w-0 flex-1", children: [
429
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "flex flex-wrap items-baseline gap-x-2 text-sm", children: [
430
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-medium", children: comment.author.name }),
431
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "time", { dateTime: comment.createdAt, className: "text-xs text-muted-foreground", children: labels.postedAt(comment.createdAt) })
389
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex gap-2", children: [
390
+ /* @__PURE__ */ jsxRuntime.jsx(CommentAvatar, { author: comment.author }),
391
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
392
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "flex flex-wrap items-baseline gap-x-2 text-sm", children: [
393
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: comment.author.name }),
394
+ /* @__PURE__ */ jsxRuntime.jsx("time", { dateTime: comment.createdAt, className: "text-xs text-muted-foreground", children: labels.postedAt(comment.createdAt) })
432
395
  ] }),
433
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "quoin-comments-body text-sm", children: comment.body })
396
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "quoin-comments-body text-sm", children: comment.body })
434
397
  ] })
435
398
  ] });
436
399
  }
437
-
438
- // src/extensions/comments/ReplyBox.tsx
439
-
440
-
441
-
442
400
  var REPLY_FIELD = "data-comments-field";
443
401
  function ReplyBox({ env, threadId, first }) {
444
402
  const { controller, host, labels, link } = env;
445
- const [body, setBody] = _react.useState.call(void 0, "");
446
- const [sending, setSending] = _react.useState.call(void 0, false);
447
- const alive = _react.useRef.call(void 0, true);
448
- _react.useEffect.call(void 0, () => {
403
+ const [body, setBody] = react.useState("");
404
+ const [sending, setSending] = react.useState(false);
405
+ const alive = react.useRef(true);
406
+ react.useEffect(() => {
449
407
  alive.current = true;
450
408
  return () => {
451
409
  alive.current = false;
@@ -471,9 +429,9 @@ function ReplyBox({ env, threadId, first }) {
471
429
  event.preventDefault();
472
430
  void send();
473
431
  };
474
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { className: "flex items-start gap-2", onSubmit, children: [
475
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentAvatar, { author: host.currentUser }),
476
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
432
+ return /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "flex items-start gap-2", onSubmit, children: [
433
+ /* @__PURE__ */ jsxRuntime.jsx(CommentAvatar, { author: host.currentUser }),
434
+ /* @__PURE__ */ jsxRuntime.jsx(
477
435
  "textarea",
478
436
  {
479
437
  ...{ [REPLY_FIELD]: "" },
@@ -486,50 +444,47 @@ function ReplyBox({ env, threadId, first }) {
486
444
  className: "quoin-comments-field"
487
445
  }
488
446
  ),
489
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
490
- _chunkCW3AFJBRcjs.Button,
447
+ /* @__PURE__ */ jsxRuntime.jsx(
448
+ chunkQEMGOL5L_cjs.Button,
491
449
  {
492
450
  type: "submit",
493
451
  variant: "ghost",
494
452
  size: "icon-sm",
495
453
  "aria-label": labels.send,
496
454
  "aria-disabled": text === "" || sending || void 0,
497
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.SendHorizontal, {})
455
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SendHorizontal, {})
498
456
  }
499
457
  )
500
458
  ] });
501
459
  }
502
-
503
- // src/extensions/comments/ThreadView.tsx
504
-
505
460
  function ThreadView({ env, id, thread, onEnded }) {
506
461
  const { controller, host, labels, link } = env;
507
- const readOnly = _chunkP6KYXFZCcjs.useReadOnly.call(void 0, controller);
508
- const [busy, setBusy] = _react.useState.call(void 0, false);
509
- const alive = _react.useRef.call(void 0, true);
510
- const root = _react.useRef.call(void 0, null);
511
- _react.useEffect.call(void 0, () => {
462
+ const readOnly = chunkACSEYJJF_cjs.useReadOnly(controller);
463
+ const [busy, setBusy] = react.useState(false);
464
+ const alive = react.useRef(true);
465
+ const root = react.useRef(null);
466
+ react.useEffect(() => {
512
467
  alive.current = true;
513
468
  return () => {
514
469
  alive.current = false;
515
470
  };
516
471
  }, []);
517
- const comments = _nullishCoalesce(_optionalChain([thread, 'optionalAccess', _45 => _45.comments]), () => ( []));
472
+ const comments = thread?.comments ?? [];
518
473
  const end = async (call) => {
519
474
  if (busy) return;
520
475
  setBusy(true);
521
476
  const ended = await endThread(controller.editor, link, call, id, host.threads);
522
477
  if (alive.current) setBusy(false);
523
478
  const active = document.activeElement;
524
- const stayed = active === null || active === document.body || _optionalChain([root, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.contains, 'call', _48 => _48(active)]) === true;
479
+ const stayed = active === null || active === document.body || root.current?.contains(active) === true;
525
480
  if (ended && stayed) onEnded();
526
481
  };
527
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref: root, className: "flex flex-col gap-3", children: [
528
- comments.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { className: "flex flex-col gap-3", children: comments.map((comment) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentItem, { comment, labels }, comment.id)) }),
529
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ReplyBox, { env, threadId: id, first: comments.length === 0 }),
530
- !readOnly && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-1", children: [
531
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
532
- _chunkCW3AFJBRcjs.Button,
482
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: root, className: "flex flex-col gap-3", children: [
483
+ comments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "flex flex-col gap-3", children: comments.map((comment) => /* @__PURE__ */ jsxRuntime.jsx(CommentItem, { comment, labels }, comment.id)) }),
484
+ /* @__PURE__ */ jsxRuntime.jsx(ReplyBox, { env, threadId: id, first: comments.length === 0 }),
485
+ !readOnly && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-1", children: [
486
+ /* @__PURE__ */ jsxRuntime.jsx(
487
+ chunkQEMGOL5L_cjs.Button,
533
488
  {
534
489
  type: "button",
535
490
  variant: "ghost",
@@ -539,8 +494,8 @@ function ThreadView({ env, id, thread, onEnded }) {
539
494
  children: labels.resolve
540
495
  }
541
496
  ),
542
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
543
- _chunkCW3AFJBRcjs.Button,
497
+ /* @__PURE__ */ jsxRuntime.jsx(
498
+ chunkQEMGOL5L_cjs.Button,
544
499
  {
545
500
  type: "button",
546
501
  variant: "ghost",
@@ -553,17 +508,14 @@ function ThreadView({ env, id, thread, onEnded }) {
553
508
  ] })
554
509
  ] });
555
510
  }
556
-
557
- // src/extensions/comments/ThreadCard.tsx
558
-
559
511
  function ThreadCard({ env, entry, active, expanded, onToggle }) {
560
512
  const { labels, controller } = env;
561
513
  const { thread, anchorText: anchorText2, ranges } = entry;
562
- const header = _react.useRef.call(void 0, null);
514
+ const header = react.useRef(null);
563
515
  const [first] = thread.comments;
564
516
  const removed = ranges.length === 0;
565
517
  const backToHeader = () => {
566
- if (_optionalChain([header, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.isConnected])) header.current.focus();
518
+ if (header.current?.isConnected) header.current.focus();
567
519
  else controller.focus();
568
520
  };
569
521
  const onKeyDown = (event) => {
@@ -571,39 +523,36 @@ function ThreadCard({ env, entry, active, expanded, onToggle }) {
571
523
  event.preventDefault();
572
524
  event.stopPropagation();
573
525
  onToggle(null);
574
- _optionalChain([header, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.focus, 'call', _53 => _53()]);
526
+ header.current?.focus();
575
527
  };
576
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "quoin-comments-card", "data-active": active || void 0, onKeyDown, children: [
577
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
528
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-comments-card", "data-active": active || void 0, onKeyDown, children: [
529
+ /* @__PURE__ */ jsxRuntime.jsxs(
578
530
  "button",
579
531
  {
580
532
  ref: header,
581
533
  type: "button",
582
534
  "aria-expanded": expanded,
583
- className: _chunkCW3AFJBRcjs.cn.call(void 0, "flex w-full flex-col items-start gap-1 rounded-sm text-start", _chunkCW3AFJBRcjs.FOCUS_RING),
535
+ className: chunkQEMGOL5L_cjs.cn("flex w-full flex-col items-start gap-1 rounded-sm text-start", chunkQEMGOL5L_cjs.FOCUS_RING),
584
536
  onClick: () => onToggle(expanded ? null : thread.id),
585
537
  children: [
586
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: removed ? "text-xs text-muted-foreground italic" : "quoin-comments-quote", children: removed ? labels.textRemoved : anchorText2 }),
587
- first !== void 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "line-clamp-2 text-sm", children: [
588
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-medium", children: first.author.name }),
538
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: removed ? "text-xs text-muted-foreground italic" : "quoin-comments-quote", children: removed ? labels.textRemoved : anchorText2 }),
539
+ first !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "line-clamp-2 text-sm", children: [
540
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: first.author.name }),
589
541
  " ",
590
542
  first.body
591
543
  ] }),
592
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs text-muted-foreground", children: labels.commentCount(thread.comments.length) })
544
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: labels.commentCount(thread.comments.length) })
593
545
  ]
594
546
  }
595
547
  ),
596
- expanded && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-3", role: "group", "aria-label": removed ? labels.textRemoved : labels.thread(anchorText2), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadView, { env, id: thread.id, thread, onEnded: backToHeader }) })
548
+ expanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3", role: "group", "aria-label": removed ? labels.textRemoved : labels.thread(anchorText2), children: /* @__PURE__ */ jsxRuntime.jsx(ThreadView, { env, id: thread.id, thread, onEnded: backToHeader }) })
597
549
  ] });
598
550
  }
599
-
600
- // src/extensions/comments/CommentsRail.tsx
601
-
602
551
  var GAP2 = 8;
603
- var layoutKey = (entries, value) => `${value.active} ${value.open !== null} ${entries.map(({ thread, ranges }) => `${thread.id}:${_optionalChain([ranges, 'access', _54 => _54[0], 'optionalAccess', _55 => _55.block])}`)}`;
552
+ var layoutKey = (entries, value) => `${value.active} ${value.open !== null} ${entries.map(({ thread, ranges }) => `${thread.id}:${ranges[0]?.block}`)}`;
604
553
  function CommentsRail({ env, box, entries, value, onToggle }) {
605
554
  useBlockAligned(env.controller, box, GAP2, layoutKey(entries, value));
606
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: box, className: "quoin-comments-rail", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { "aria-label": env.labels.comments, children: entries.map((entry) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { "data-rail-item": "", "data-block": _nullishCoalesce(_optionalChain([entry, 'access', _56 => _56.ranges, 'access', _57 => _57[0], 'optionalAccess', _58 => _58.block]), () => ( "")), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
555
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: box, className: "quoin-comments-rail", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": env.labels.comments, children: entries.map((entry) => /* @__PURE__ */ jsxRuntime.jsx("li", { "data-rail-item": "", "data-block": entry.ranges[0]?.block ?? "", children: /* @__PURE__ */ jsxRuntime.jsx(
607
556
  ThreadCard,
608
557
  {
609
558
  env,
@@ -614,32 +563,26 @@ function CommentsRail({ env, box, entries, value, onToggle }) {
614
563
  }
615
564
  ) }, entry.thread.id)) }) });
616
565
  }
617
-
618
- // src/extensions/comments/CommentsSheet.tsx
619
- var _reactdialog = require('@radix-ui/react-dialog'); var DialogPrimitive = _interopRequireWildcard(_reactdialog);
620
-
621
-
622
-
623
566
  function CommentsSheet({ env, entries, value, onToggle, onClose, returnFocus }) {
624
567
  const { labels } = env;
625
- const content = _react.useRef.call(void 0, null);
626
- const outside = _react.useRef.call(void 0, false);
568
+ const content = react.useRef(null);
569
+ const outside = react.useRef(false);
627
570
  const focusOpened = (event) => {
628
- const opened = _optionalChain([content, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.querySelector, 'call', _61 => _61('[aria-expanded="true"]')]);
571
+ const opened = content.current?.querySelector('[aria-expanded="true"]');
629
572
  if (!opened) return;
630
573
  event.preventDefault();
631
574
  opened.focus();
632
575
  };
633
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
634
- DialogPrimitive.Root,
576
+ return /* @__PURE__ */ jsxRuntime.jsx(
577
+ DialogPrimitive__namespace.Root,
635
578
  {
636
579
  open: true,
637
580
  modal: false,
638
581
  onOpenChange: (open) => {
639
582
  if (!open) onClose();
640
583
  },
641
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogPrimitive.Portal, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
642
- DialogPrimitive.Content,
584
+ children: /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
585
+ DialogPrimitive__namespace.Content,
643
586
  {
644
587
  ref: content,
645
588
  "aria-describedby": void 0,
@@ -653,11 +596,11 @@ function CommentsSheet({ env, entries, value, onToggle, onClose, returnFocus })
653
596
  if (!outside.current) returnFocus();
654
597
  },
655
598
  children: [
656
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between gap-2", children: [
657
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogPrimitive.Title, { className: "text-sm font-semibold", children: labels.comments }),
658
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogPrimitive.Close, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": labels.close, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.XIcon, {}) }) })
599
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
600
+ /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Title, { className: "text-sm font-semibold", children: labels.comments }),
601
+ /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": labels.close, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, {}) }) })
659
602
  ] }),
660
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { "aria-label": labels.comments, className: "flex flex-col gap-2", children: entries.map((entry) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
603
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": labels.comments, className: "flex flex-col gap-2", children: entries.map((entry) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(
661
604
  ThreadCard,
662
605
  {
663
606
  env,
@@ -679,71 +622,62 @@ var NONE = [];
679
622
  function railEntries(doc, threads, ended = []) {
680
623
  const anchors = commentAnchors(doc);
681
624
  const entries = threads.filter((thread) => !thread.resolved && !isEnded(ended, thread.id, thread)).map((thread) => {
682
- const ranges = _nullishCoalesce(anchors.get(thread.id), () => ( NONE));
625
+ const ranges = anchors.get(thread.id) ?? NONE;
683
626
  return { thread, ranges, anchorText: anchorText(doc, ranges) };
684
627
  });
685
- const place2 = ({ ranges: [first] }) => first === void 0 ? [Infinity, 0] : [_chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, first.block), first.from];
628
+ const place2 = ({ ranges: [first] }) => first === void 0 ? [Infinity, 0] : [chunkAIS37SL2_cjs.indexOfBlock(doc, first.block), first.from];
686
629
  return entries.map((entry, order) => ({ entry, order, at: place2(entry) })).sort((a, b) => a.at[0] - b.at[0] || a.at[1] - b.at[1] || a.order - b.order).map(({ entry }) => entry);
687
630
  }
688
-
689
- // src/extensions/comments/ThreadPopover.tsx
690
-
691
-
692
- // src/extensions/comments/ThreadChooser.tsx
693
-
694
631
  function ThreadChooser({ env, choices, onChoose }) {
695
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { "aria-label": env.labels.threadsHere, className: "flex flex-col gap-1", children: choices.map(({ id, anchorText: anchorText2, preview }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
632
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": env.labels.threadsHere, className: "flex flex-col gap-1", children: choices.map(({ id, anchorText: anchorText2, preview }) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
696
633
  "button",
697
634
  {
698
635
  type: "button",
699
636
  className: "quoin-comments-choice",
700
637
  onClick: () => onChoose(id),
701
638
  children: [
702
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "quoin-comments-quote", children: anchorText2 }),
703
- preview && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "line-clamp-1 text-sm", children: preview })
639
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "quoin-comments-quote", children: anchorText2 }),
640
+ preview && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "line-clamp-1 text-sm", children: preview })
704
641
  ]
705
642
  }
706
643
  ) }, id)) });
707
644
  }
708
-
709
- // src/extensions/comments/ThreadPopover.tsx
710
-
711
645
  var docOf = (state) => state.doc;
712
646
  function focusIsOurs(controller, content) {
713
- const active = _nullishCoalesce(_optionalChain([content, 'optionalAccess', _62 => _62.ownerDocument, 'access', _63 => _63.activeElement]), () => ( null));
714
- return active === null || active === active.ownerDocument.body || _chunk73653CJ4cjs.ownsNode.call(void 0, controller, active);
647
+ const active = content?.ownerDocument.activeElement ?? null;
648
+ return active === null || active === active.ownerDocument.body || chunkNO3KTZDY_cjs.ownsNode(controller, active);
715
649
  }
716
650
  function ThreadPopover({ env, open, threads, onChoose, onClose }) {
717
651
  const { controller, labels } = env;
718
- const doc = _chunkP6KYXFZCcjs.useEditorState.call(void 0, controller, docOf);
652
+ const doc = chunkACSEYJJF_cjs.useEditorState(controller, docOf);
719
653
  const anchors = commentAnchors(doc);
720
654
  const { ids } = open;
721
- const first = ids.map((id) => _optionalChain([anchors, 'access', _64 => _64.get, 'call', _65 => _65(id), 'optionalAccess', _66 => _66[0]])).find(Boolean);
722
- const latest = _react.useRef.call(void 0, first);
723
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
655
+ const first = ids.map((id) => anchors.get(id)?.[0]).find(Boolean);
656
+ const latest = react.useRef(first);
657
+ chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
724
658
  if (first) latest.current = first;
725
659
  });
726
- const anchor = _react.useMemo.call(void 0,
660
+ const anchor = react.useMemo(
727
661
  () => ({
728
- current: _chunkCW3AFJBRcjs.virtualAnchor.call(void 0,
729
- () => latest.current ? _chunkCW3AFJBRcjs.rangeRect.call(void 0, controller, latest.current) : null,
662
+ current: chunkQEMGOL5L_cjs.virtualAnchor(
663
+ () => latest.current ? chunkQEMGOL5L_cjs.rangeRect(controller, latest.current) : null,
730
664
  () => latest.current && controller.registry.get(latest.current.block, latest.current.region)
731
665
  )
732
666
  }),
733
667
  [controller]
734
668
  );
735
- const content = _react.useRef.call(void 0, null);
669
+ const content = react.useRef(null);
736
670
  const focusField = () => {
737
- const target = _optionalChain([content, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.querySelector, 'call', _69 => _69(`[${REPLY_FIELD}], button`)]);
738
- if (focusIsOurs(controller, content.current) && !_optionalChain([content, 'access', _70 => _70.current, 'optionalAccess', _71 => _71.contains, 'call', _72 => _72(content.current.ownerDocument.activeElement)])) {
739
- _optionalChain([target, 'optionalAccess', _73 => _73.focus, 'call', _74 => _74()]);
671
+ const target = content.current?.querySelector(`[${REPLY_FIELD}], button`);
672
+ if (focusIsOurs(controller, content.current) && !content.current?.contains(content.current.ownerDocument.activeElement)) {
673
+ target?.focus();
740
674
  }
741
675
  };
742
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
676
+ chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
743
677
  if (open.focus) focusField();
744
678
  }, [open]);
745
679
  if (first === void 0 && latest.current === void 0) return null;
746
- const textOf = (id) => anchorText(doc, _nullishCoalesce(anchors.get(id), () => ( []))) || labels.textRemoved;
680
+ const textOf = (id) => anchorText(doc, anchors.get(id) ?? []) || labels.textRemoved;
747
681
  const single = ids.length === 1;
748
682
  const gone = single && !anchors.has(ids[0]);
749
683
  const backToText = () => controller.focus();
@@ -754,13 +688,13 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
754
688
  const onEscape = (event) => {
755
689
  event.preventDefault();
756
690
  event.stopPropagation();
757
- const inside = _nullishCoalesce(_optionalChain([content, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.contains, 'call', _77 => _77(content.current.ownerDocument.activeElement)]), () => ( false));
691
+ const inside = content.current?.contains(content.current.ownerDocument.activeElement) ?? false;
758
692
  onClose();
759
693
  if (inside) backToText();
760
694
  };
761
- const choices = ids.map((id) => ({ id, anchorText: textOf(id), preview: _nullishCoalesce(_optionalChain([threads, 'access', _78 => _78.find, 'call', _79 => _79(id), 'optionalAccess', _80 => _80.comments, 'access', _81 => _81[0], 'optionalAccess', _82 => _82.body]), () => ( "")) }));
762
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
763
- _chunkCW3AFJBRcjs.Popover,
695
+ const choices = ids.map((id) => ({ id, anchorText: textOf(id), preview: threads.find(id)?.comments[0]?.body ?? "" }));
696
+ return /* @__PURE__ */ jsxRuntime.jsxs(
697
+ chunkQEMGOL5L_cjs.Popover,
764
698
  {
765
699
  open: true,
766
700
  modal: false,
@@ -768,9 +702,9 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
768
702
  if (!next) onClose();
769
703
  },
770
704
  children: [
771
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.PopoverAnchor, { virtualRef: anchor }),
772
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
773
- _chunkCW3AFJBRcjs.PopoverContent,
705
+ /* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.PopoverAnchor, { virtualRef: anchor }),
706
+ /* @__PURE__ */ jsxRuntime.jsxs(
707
+ chunkQEMGOL5L_cjs.PopoverContent,
774
708
  {
775
709
  ref: content,
776
710
  "aria-label": gone ? labels.textRemoved : single ? labels.thread(textOf(ids[0])) : labels.threadsHere,
@@ -781,8 +715,8 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
781
715
  onCloseAutoFocus: (event) => event.preventDefault(),
782
716
  onEscapeKeyDown: onEscape,
783
717
  children: [
784
- gone && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-2 text-xs text-muted-foreground italic", children: labels.textRemoved }),
785
- single ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadView, { env, id: ids[0], thread: threads.find(ids[0]), onEnded: backToText }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadChooser, { env, choices, onChoose })
718
+ gone && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-2 text-xs text-muted-foreground italic", children: labels.textRemoved }),
719
+ single ? /* @__PURE__ */ jsxRuntime.jsx(ThreadView, { env, id: ids[0], thread: threads.find(ids[0]), onEnded: backToText }) : /* @__PURE__ */ jsxRuntime.jsx(ThreadChooser, { env, choices, onChoose })
786
720
  ]
787
721
  },
788
722
  ids.join(" ")
@@ -791,24 +725,21 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
791
725
  }
792
726
  );
793
727
  }
794
-
795
- // src/extensions/comments/use-anchor-clicks.ts
796
-
797
728
  function idsUnder(root, target) {
798
729
  const ids = [];
799
730
  let element = target instanceof Element ? target.closest("[data-comment]") : null;
800
731
  while (element !== null && root.contains(element)) {
801
732
  const id = element.getAttribute("data-comment");
802
733
  if (id) ids.push(id);
803
- element = _nullishCoalesce(_optionalChain([element, 'access', _83 => _83.parentElement, 'optionalAccess', _84 => _84.closest, 'call', _85 => _85("[data-comment]")]), () => ( null));
734
+ element = element.parentElement?.closest("[data-comment]") ?? null;
804
735
  }
805
736
  return ids;
806
737
  }
807
738
  function useAnchorClicks(controller, threads) {
808
- _react.useEffect.call(void 0, () => {
739
+ react.useEffect(() => {
809
740
  const onClick = (event) => {
810
741
  const root = controller.root;
811
- if (root === null || event.defaultPrevented || !_optionalChain([root, 'access', _86 => _86.ownerDocument, 'access', _87 => _87.getSelection, 'call', _88 => _88(), 'optionalAccess', _89 => _89.isCollapsed])) return;
742
+ if (root === null || event.defaultPrevented || !root.ownerDocument.getSelection()?.isCollapsed) return;
812
743
  const { editor } = controller;
813
744
  const ids = openIds(editor.state, threads, idsUnder(root, event.target));
814
745
  if (ids.length === 0) return;
@@ -818,14 +749,11 @@ function useAnchorClicks(controller, threads) {
818
749
  return () => document.removeEventListener("click", onClick);
819
750
  }, [controller, threads]);
820
751
  }
821
-
822
- // src/extensions/comments/use-canvas-wide.ts
823
-
824
752
  var WIDE_CANVAS = 800;
825
753
  function useCanvasWide(box, initial) {
826
- const [wide, setWide] = _react.useState.call(void 0, initial);
827
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
828
- const canvas = _optionalChain([box, 'access', _90 => _90.current, 'optionalAccess', _91 => _91.parentElement]);
754
+ const [wide, setWide] = react.useState(initial);
755
+ chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
756
+ const canvas = box.current?.parentElement;
829
757
  if (!canvas) return void 0;
830
758
  const measure = () => setWide(canvas.offsetWidth >= WIDE_CANVAS);
831
759
  measure();
@@ -835,57 +763,51 @@ function useCanvasWide(box, initial) {
835
763
  }, [box]);
836
764
  return wide;
837
765
  }
838
-
839
- // src/extensions/comments/use-threads.ts
840
-
841
766
  function useThreads(threads) {
842
- return _react.useSyncExternalStore.call(void 0, threads.subscribe, threads.get, threads.get);
767
+ return react.useSyncExternalStore(threads.subscribe, threads.get, threads.get);
843
768
  }
844
-
845
- // src/extensions/comments/CommentsOverlay.tsx
846
-
847
- var commentsOf = (state) => _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey);
769
+ var commentsOf = (state) => chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey);
848
770
  var docOf2 = (state) => state.doc;
849
771
  function CommentsOverlay({ controller, host, labels }) {
850
- const { onError } = _chunkCW3AFJBRcjs.useQuoin.call(void 0, );
772
+ const { onError } = chunkQEMGOL5L_cjs.useQuoin();
851
773
  const link = linkOf(controller.editor);
852
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
774
+ chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
853
775
  link.report = onError;
854
776
  }, [link, onError]);
855
777
  useAnchorClicks(controller, host.threads);
856
778
  const threads = useThreads(host.threads);
857
- const value = _chunkP6KYXFZCcjs.useEditorState.call(void 0, controller, commentsOf);
858
- const doc = _chunkP6KYXFZCcjs.useEditorState.call(void 0, controller, docOf2);
859
- const entries = _react.useMemo.call(void 0, () => railEntries(doc, threads, value.ended), [doc, threads, value.ended]);
860
- const box = _react.useRef.call(void 0, null);
779
+ const value = chunkACSEYJJF_cjs.useEditorState(controller, commentsOf);
780
+ const doc = chunkACSEYJJF_cjs.useEditorState(controller, docOf2);
781
+ const entries = react.useMemo(() => railEntries(doc, threads, value.ended), [doc, threads, value.ended]);
782
+ const box = react.useRef(null);
861
783
  const wide = useCanvasWide(box, host.initialLayout === "wide");
862
- const [sheet, setSheet] = _react.useState.call(void 0, false);
863
- const opener = _react.useRef.call(void 0, null);
864
- _react.useEffect.call(void 0, () => {
784
+ const [sheet, setSheet] = react.useState(false);
785
+ const opener = react.useRef(null);
786
+ react.useEffect(() => {
865
787
  if (wide) setSheet(false);
866
788
  }, [wide]);
867
- const env = _react.useMemo.call(void 0, () => ({ controller, host, labels, link }), [controller, host, labels, link]);
868
- const act2 = _react.useCallback.call(void 0,
789
+ const env = react.useMemo(() => ({ controller, host, labels, link }), [controller, host, labels, link]);
790
+ const act2 = react.useCallback(
869
791
  (action) => controller.editor.dispatch(commentsTransaction(controller.editor.state, action)),
870
792
  [controller]
871
793
  );
872
- const toggle = _react.useCallback.call(void 0, (id) => act2({ type: "activate", id }), [act2]);
794
+ const toggle = react.useCallback((id) => act2({ type: "activate", id }), [act2]);
873
795
  const openSheet = (id, marker) => {
874
796
  opener.current = marker;
875
797
  toggle(id);
876
798
  setSheet(true);
877
799
  };
878
800
  const returnFocus = () => {
879
- if (_optionalChain([opener, 'access', _92 => _92.current, 'optionalAccess', _93 => _93.isConnected])) opener.current.focus();
801
+ if (opener.current?.isConnected) opener.current.focus();
880
802
  else controller.focus();
881
803
  };
882
804
  const closeSheet = () => {
883
805
  setSheet(false);
884
806
  toggle(null);
885
807
  };
886
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
887
- wide ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentsRail, { env, box, entries, value, onToggle: toggle }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentMarkers, { env, box, entries, onOpen: openSheet }),
888
- !wide && sheet && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
808
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
809
+ wide ? /* @__PURE__ */ jsxRuntime.jsx(CommentsRail, { env, box, entries, value, onToggle: toggle }) : /* @__PURE__ */ jsxRuntime.jsx(CommentMarkers, { env, box, entries, onOpen: openSheet }),
810
+ !wide && sheet && /* @__PURE__ */ jsxRuntime.jsx(
889
811
  CommentsSheet,
890
812
  {
891
813
  env,
@@ -896,7 +818,7 @@ function CommentsOverlay({ controller, host, labels }) {
896
818
  returnFocus
897
819
  }
898
820
  ),
899
- value.open && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
821
+ value.open && /* @__PURE__ */ jsxRuntime.jsx(
900
822
  ThreadPopover,
901
823
  {
902
824
  env,
@@ -915,10 +837,10 @@ var ACTIVE = { class: "quoin-comment-active" };
915
837
  var inline = (ranges, attrs) => ranges.map((range) => ({ kind: "inline", ...range, attrs }));
916
838
  var drawn = /* @__PURE__ */ new WeakMap();
917
839
  function commentsDecorations(state) {
918
- const value = _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey);
840
+ const value = chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey);
919
841
  const last = drawn.get(value);
920
- if (_optionalChain([last, 'optionalAccess', _94 => _94.doc]) === state.doc) return last.decorations;
921
- const active = value.active === null ? [] : _nullishCoalesce(commentAnchors(state.doc).get(value.active), () => ( []));
842
+ if (last?.doc === state.doc) return last.decorations;
843
+ const active = value.active === null ? [] : commentAnchors(state.doc).get(value.active) ?? [];
922
844
  const decorations = [...value.pending.flatMap(({ ranges }) => inline(ranges, PENDING)), ...inline(active, ACTIVE)];
923
845
  drawn.set(value, { doc: state.doc, decorations });
924
846
  return decorations;
@@ -927,20 +849,17 @@ function commentsDecorations(state) {
927
849
  // src/extensions/comments/watch-ended.ts
928
850
  function watchEnded(editor, threads) {
929
851
  return threads.subscribe(() => {
930
- const { ended } = _chunkZKVOS57Qcjs.getPluginState.call(void 0, editor.state, commentsKey);
852
+ const { ended } = chunkVFSVN5IQ_cjs.getPluginState(editor.state, commentsKey);
931
853
  const kept = ended.filter(({ id }) => isEnded(ended, id, threads.find(id)));
932
854
  if (kept.length < ended.length) editor.dispatch(commentsTransaction(editor.state, { type: "caught", kept }));
933
855
  });
934
856
  }
935
-
936
- // src/extensions/comments/comments-extension.tsx
937
-
938
857
  var commentItem = (labels) => ({
939
858
  id: "comment",
940
859
  title: labels.comment,
941
- icon: _lucidereact.MessageSquarePlus,
860
+ icon: lucideReact.MessageSquarePlus,
942
861
  shortcut: "Mod-Alt-m",
943
- available: (state) => hasCommentableText(state) && _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey).pending.length === 0,
862
+ available: (state) => hasCommentableText(state) && chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey).pending.length === 0,
944
863
  // Focus goes back to the text first: the button leaves the toolbar while the thread is being asked for.
945
864
  run: (controller) => {
946
865
  controller.focus();
@@ -951,10 +870,10 @@ function commentsExtension(options) {
951
870
  const { labels: overrides, ...host } = options;
952
871
  const labels = resolveCommentsLabels(overrides);
953
872
  function Overlay({ controller }) {
954
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentsOverlay, { controller, host, labels });
873
+ return /* @__PURE__ */ jsxRuntime.jsx(CommentsOverlay, { controller, host, labels });
955
874
  }
956
875
  const ui = { bubbleItems: [commentItem(labels)], overlays: [Overlay] };
957
- return _chunkZKVOS57Qcjs.defineExtension.call(void 0, {
876
+ return chunkVFSVN5IQ_cjs.defineExtension({
958
877
  name: "comments",
959
878
  plugins: [commentsPlugin],
960
879
  decorations: commentsDecorations,
@@ -968,7 +887,7 @@ function commentsExtension(options) {
968
887
  }
969
888
  return () => {
970
889
  if (--link.mounts > 0) return;
971
- _optionalChain([link, 'access', _95 => _95.stopWatching, 'optionalCall', _96 => _96()]);
890
+ link.stopWatching?.();
972
891
  link.stopWatching = null;
973
892
  };
974
893
  },
@@ -1001,8 +920,8 @@ function createCommentThreads(initial = NO_THREADS) {
1001
920
  };
1002
921
  }
1003
922
 
1004
-
1005
-
1006
-
1007
- exports.commentsExtension = commentsExtension; exports.createCommentThreads = createCommentThreads; exports.englishCommentsLabels = englishCommentsLabels;
923
+ exports.commentsExtension = commentsExtension;
924
+ exports.createCommentThreads = createCommentThreads;
925
+ exports.englishCommentsLabels = englishCommentsLabels;
926
+ //# sourceMappingURL=comments.cjs.map
1008
927
  //# sourceMappingURL=comments.cjs.map