@commentkit/comment-kit 0.6.8 → 0.6.9

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 (330) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +73 -45
  3. package/dist/angular.es.js +47 -3411
  4. package/dist/comment-kit.es.js +13 -3184
  5. package/dist/demo.es.js +395 -0
  6. package/dist/headless.es.js +4 -0
  7. package/dist/preact.es.js +79 -3443
  8. package/dist/qwik.es.js +79 -3443
  9. package/dist/react.es.js +80 -28447
  10. package/dist/shared/ShadowRootContext-Bv-4aElu.js +13 -0
  11. package/dist/shared/annotation-toolbar-pX17NLmJ.js +1104 -0
  12. package/dist/shared/bridge-DRE03N9X.js +174 -0
  13. package/dist/shared/button-By0hGrJK.js +505 -0
  14. package/dist/shared/button-group-CHfMRXyA.js +93 -0
  15. package/dist/shared/clamp-CcFVX0vC.js +55 -0
  16. package/dist/shared/comment-drawing-canvas-CYu5SwRf.js +126 -0
  17. package/dist/shared/comment-image-lightbox-0VdAs2iT.js +178 -0
  18. package/dist/shared/comment-kit-core-D0kY00St.js +3083 -0
  19. package/dist/shared/comment-kit-ui-D2j2gvnm.js +16685 -0
  20. package/dist/shared/comment-screenshot-annotator-BuojwviY.js +137 -0
  21. package/dist/shared/comment-screenshot-overlay-BZX0Vcb8.js +144 -0
  22. package/dist/shared/createReactComponent-BZHeRbD0.js +45 -0
  23. package/dist/shared/dev-export-panel-BLngcr5q.js +208 -0
  24. package/dist/shared/dev-grab-pDAfH2lr.js +203 -0
  25. package/dist/{core/dom-x9svfpMk.js → shared/dom-Bhf4WFtY.js} +2 -2
  26. package/dist/shared/element-selector-CtFzgHvq.js +852 -0
  27. package/dist/shared/errors-Bu5ajEmB.js +22 -0
  28. package/dist/shared/icons-BSHCWYO1.js +267 -0
  29. package/dist/shared/local-demo-context-BohlYbHt.js +6 -0
  30. package/dist/shared/mount-ui-CVivB_eQ.js +193 -0
  31. package/dist/{angular/pusher-Vs-W-c8I.js → shared/pusher-BEl7Qn-8.js} +93 -127
  32. package/dist/{core/realtime-C3_O7gi2.js → shared/realtime-BG_t_ze7.js} +75 -72
  33. package/dist/shared/resolveAriaLabelledBy-CIKpnjNJ.js +669 -0
  34. package/dist/shared/separator-DusFNTs-.js +3915 -0
  35. package/dist/shared/shadow-root-CmYXiSRR.js +135 -0
  36. package/dist/shared/styles-D_FEJZ9G.js +2 -0
  37. package/dist/shared/useLabelableId-DGbfdMi_.js +155 -0
  38. package/dist/shared/useValueChanged-DQXLia-2.js +92 -0
  39. package/dist/{angular/limits-AEqOBweE.js → shared/validation-C7QG8j7Z.js} +2 -28
  40. package/dist/{core/websocket-manager-D1_TEuy_.js → shared/websocket-manager-BTRqNTB7.js} +90 -148
  41. package/dist/solid.es.js +63 -3427
  42. package/dist/svelte.es.js +78 -3442
  43. package/dist/types/adapters/bridge.d.ts +1 -1
  44. package/dist/types/angular/index.d.ts +2 -2
  45. package/dist/types/core/comment-kit-core.d.ts +10 -1
  46. package/dist/types/core/local-demo.d.ts +59 -0
  47. package/dist/types/demo.d.ts +17 -0
  48. package/dist/types/headless.d.ts +8 -0
  49. package/dist/types/index.d.ts +14 -16
  50. package/dist/vue.es.js +80 -3443
  51. package/package.json +55 -37
  52. package/dist/angular/chunk-Cyg4N8Ue.js +0 -11
  53. package/dist/angular/comment-kit-ui-D-LUFD6n.js +0 -24898
  54. package/dist/angular/dom-Cx1nMbdI.js +0 -104
  55. package/dist/angular/mount-ui-C9PJ5aK_.js +0 -72
  56. package/dist/angular/realtime-VrKV0lPI.js +0 -567
  57. package/dist/angular/shadow-root-yMOaW9pk.js +0 -93
  58. package/dist/angular/styles-CMz7-p8x.js +0 -2
  59. package/dist/angular/widget-theme-CYPYAwhR.js +0 -24
  60. package/dist/comment-kit.css +0 -2
  61. package/dist/core/chunk-t7YoJN_i.js +0 -11
  62. package/dist/core/comment-kit-ui-Ct4E18do.js +0 -24898
  63. package/dist/core/error-boundary-CN_BGsYl.js +0 -21
  64. package/dist/core/mount-ui-Bfnuuesk.js +0 -72
  65. package/dist/core/pusher-CizoY5NA.js +0 -2504
  66. package/dist/core/shadow-root-DAtdjHG2.js +0 -93
  67. package/dist/core/styles-ClRoB6ro.js +0 -2
  68. package/dist/core/widget-theme-BWDYr7VR.js +0 -24
  69. package/dist/preact/chunk-CZ0PdaaN.js +0 -11
  70. package/dist/preact/comment-kit-ui-DEzn7J_P.js +0 -24898
  71. package/dist/preact/dom-_ULpq7rg.js +0 -104
  72. package/dist/preact/error-boundary-B4-Bfy3g.js +0 -21
  73. package/dist/preact/limits-C3ZEKcL_.js +0 -71
  74. package/dist/preact/mount-ui-Dx8en--W.js +0 -72
  75. package/dist/preact/pusher-BP4kCufH.js +0 -2504
  76. package/dist/preact/realtime-COin_nJF.js +0 -567
  77. package/dist/preact/shadow-root-D-NcwruG.js +0 -93
  78. package/dist/preact/styles-D6i7be5-.js +0 -2
  79. package/dist/preact/widget-theme-B7Z2pbaA.js +0 -24
  80. package/dist/qwik/chunk-CKKKzG2Q.js +0 -11
  81. package/dist/qwik/comment-kit-ui-Dvwee2tw.js +0 -24898
  82. package/dist/qwik/dom-Dm3gzBBJ.js +0 -104
  83. package/dist/qwik/error-boundary-C4hlYQwS.js +0 -21
  84. package/dist/qwik/limits-DK35yjGY.js +0 -71
  85. package/dist/qwik/mount-ui-DSAwNk_d.js +0 -72
  86. package/dist/qwik/pusher-B1KgC4iB.js +0 -2504
  87. package/dist/qwik/realtime-DhfcBrwF.js +0 -567
  88. package/dist/qwik/shadow-root-PkjcnvPe.js +0 -93
  89. package/dist/qwik/styles-DmEmq5Lh.js +0 -2
  90. package/dist/qwik/widget-theme-lbPF3I0A.js +0 -24
  91. package/dist/react/chunk--MHYZ-zp.js +0 -12
  92. package/dist/react/limits-CpprSem3.js +0 -175
  93. package/dist/react/pusher-3dki8s2l.js +0 -2505
  94. package/dist/react/realtime-DGqScuox.js +0 -567
  95. package/dist/solid/chunk-B2NCWFvW.js +0 -11
  96. package/dist/solid/comment-kit-ui-ACW8BpEm.js +0 -24898
  97. package/dist/solid/dom-DqDH-Gml.js +0 -104
  98. package/dist/solid/error-boundary-9mimpbZA.js +0 -21
  99. package/dist/solid/limits-B_69IbLl.js +0 -71
  100. package/dist/solid/mount-ui-Dq1wj_tx.js +0 -72
  101. package/dist/solid/pusher-_RVNpj1f.js +0 -2504
  102. package/dist/solid/realtime-DbUJK4gU.js +0 -567
  103. package/dist/solid/shadow-root-CssU3bQb.js +0 -93
  104. package/dist/solid/styles-DbueS9xx.js +0 -2
  105. package/dist/solid/widget-theme-B4DJ14fI.js +0 -24
  106. package/dist/svelte/chunk-Pi70BKld.js +0 -11
  107. package/dist/svelte/comment-kit-ui-Cx4u1g77.js +0 -24898
  108. package/dist/svelte/dom-MyTrWzy_.js +0 -104
  109. package/dist/svelte/error-boundary-C3GWI_IX.js +0 -21
  110. package/dist/svelte/limits-CURF22v3.js +0 -71
  111. package/dist/svelte/mount-ui-CBoNGLNS.js +0 -72
  112. package/dist/svelte/pusher-DN1BiUDw.js +0 -2504
  113. package/dist/svelte/realtime-M1CJbCBA.js +0 -567
  114. package/dist/svelte/shadow-root-DG8inbf6.js +0 -93
  115. package/dist/svelte/styles-BK_MaUpD.js +0 -2
  116. package/dist/svelte/widget-theme-CkfJNysI.js +0 -24
  117. package/dist/types/adapters/errors.d.ts +0 -3
  118. package/dist/types/core/auth.d.ts +0 -18
  119. package/dist/types/core/comments.d.ts +0 -43
  120. package/dist/types/core/dev-grab.d.ts +0 -14
  121. package/dist/types/core/keyboard.d.ts +0 -12
  122. package/dist/types/core/limits.d.ts +0 -52
  123. package/dist/types/core/offline-queue.d.ts +0 -23
  124. package/dist/types/core/realtime.d.ts +0 -9
  125. package/dist/types/core/screenshot.d.ts +0 -12
  126. package/dist/types/core/session.d.ts +0 -9
  127. package/dist/types/core/source-resolver.d.ts +0 -19
  128. package/dist/types/core/state.d.ts +0 -24
  129. package/dist/types/react/comment-kit-ui.d.ts +0 -9
  130. package/dist/types/react/comments/comment-flow.d.ts +0 -8
  131. package/dist/types/react/comments/outcomes.d.ts +0 -28
  132. package/dist/types/react/comments/pin-geometry.d.ts +0 -12
  133. package/dist/types/react/comments/view-model.d.ts +0 -66
  134. package/dist/types/react/components/annotation-toolbar.d.ts +0 -36
  135. package/dist/types/react/components/build-panel-shared-props.d.ts +0 -25
  136. package/dist/types/react/components/comment-actions.d.ts +0 -19
  137. package/dist/types/react/components/comment-body.d.ts +0 -8
  138. package/dist/types/react/components/comment-branch-filter.d.ts +0 -15
  139. package/dist/types/react/components/comment-composer-actions.d.ts +0 -26
  140. package/dist/types/react/components/comment-composer-extras-fields.d.ts +0 -32
  141. package/dist/types/react/components/comment-composer-extras-toolbar.d.ts +0 -9
  142. package/dist/types/react/components/comment-composer-extras.d.ts +0 -10
  143. package/dist/types/react/components/comment-composer-extras.state.d.ts +0 -24
  144. package/dist/types/react/components/comment-composer-hook.d.ts +0 -1
  145. package/dist/types/react/components/comment-composer-media.d.ts +0 -17
  146. package/dist/types/react/components/comment-composer.d.ts +0 -4
  147. package/dist/types/react/components/comment-composer.types.d.ts +0 -41
  148. package/dist/types/react/components/comment-composer.utils.d.ts +0 -3
  149. package/dist/types/react/components/comment-connection-alert.d.ts +0 -7
  150. package/dist/types/react/components/comment-cursor-layer.d.ts +0 -14
  151. package/dist/types/react/components/comment-custom-cursor.d.ts +0 -14
  152. package/dist/types/react/components/comment-drawing-canvas.d.ts +0 -10
  153. package/dist/types/react/components/comment-emoji-picker.d.ts +0 -12
  154. package/dist/types/react/components/comment-error-banner.d.ts +0 -8
  155. package/dist/types/react/components/comment-extension-banner.d.ts +0 -8
  156. package/dist/types/react/components/comment-fab-tools.d.ts +0 -37
  157. package/dist/types/react/components/comment-fab.d.ts +0 -34
  158. package/dist/types/react/components/comment-filter-assignee.d.ts +0 -9
  159. package/dist/types/react/components/comment-filter-bar.d.ts +0 -27
  160. package/dist/types/react/components/comment-filter-popover.d.ts +0 -20
  161. package/dist/types/react/components/comment-format-toolbar.constants.d.ts +0 -34
  162. package/dist/types/react/components/comment-format-toolbar.d.ts +0 -6
  163. package/dist/types/react/components/comment-header.d.ts +0 -34
  164. package/dist/types/react/components/comment-highlight-layer.d.ts +0 -11
  165. package/dist/types/react/components/comment-highlight-marker.d.ts +0 -9
  166. package/dist/types/react/components/comment-image-lightbox.d.ts +0 -10
  167. package/dist/types/react/components/comment-images.d.ts +0 -7
  168. package/dist/types/react/components/comment-item.d.ts +0 -26
  169. package/dist/types/react/components/comment-keyboard-shortcuts.d.ts +0 -7
  170. package/dist/types/react/components/comment-kit-overlays.d.ts +0 -15
  171. package/dist/types/react/components/comment-kit.d.ts +0 -12
  172. package/dist/types/react/components/comment-list-filters.d.ts +0 -14
  173. package/dist/types/react/components/comment-login-modal.d.ts +0 -20
  174. package/dist/types/react/components/comment-marker-layer-composer.d.ts +0 -21
  175. package/dist/types/react/components/comment-marker-layer.d.ts +0 -27
  176. package/dist/types/react/components/comment-marker-popover.d.ts +0 -12
  177. package/dist/types/react/components/comment-marker.d.ts +0 -15
  178. package/dist/types/react/components/comment-member-list.d.ts +0 -10
  179. package/dist/types/react/components/comment-mode-bar.d.ts +0 -15
  180. package/dist/types/react/components/comment-online-users.d.ts +0 -8
  181. package/dist/types/react/components/comment-page-ref.d.ts +0 -9
  182. package/dist/types/react/components/comment-panel-header.d.ts +0 -22
  183. package/dist/types/react/components/comment-panel-mobile.d.ts +0 -9
  184. package/dist/types/react/components/comment-panel-utils.d.ts +0 -6
  185. package/dist/types/react/components/comment-panel-view-body.d.ts +0 -23
  186. package/dist/types/react/components/comment-panel.d.ts +0 -37
  187. package/dist/types/react/components/comment-quoted-text.d.ts +0 -9
  188. package/dist/types/react/components/comment-reactions.d.ts +0 -11
  189. package/dist/types/react/components/comment-remote-cursor.d.ts +0 -11
  190. package/dist/types/react/components/comment-screenshot-annotator.d.ts +0 -11
  191. package/dist/types/react/components/comment-screenshot-overlay.d.ts +0 -10
  192. package/dist/types/react/components/comment-search-bar.d.ts +0 -7
  193. package/dist/types/react/components/comment-settings-view.d.ts +0 -20
  194. package/dist/types/react/components/comment-skeletons.d.ts +0 -9
  195. package/dist/types/react/components/comment-thread-detail-badges.d.ts +0 -16
  196. package/dist/types/react/components/comment-thread-detail-meta.d.ts +0 -9
  197. package/dist/types/react/components/comment-thread-detail-replies.d.ts +0 -13
  198. package/dist/types/react/components/comment-thread-detail.d.ts +0 -13
  199. package/dist/types/react/components/comment-thread-footer.d.ts +0 -12
  200. package/dist/types/react/components/comment-thread-list-item.d.ts +0 -15
  201. package/dist/types/react/components/comment-thread-list.d.ts +0 -16
  202. package/dist/types/react/components/comment-user-avatar-tooltip.d.ts +0 -12
  203. package/dist/types/react/components/comment-users-context.d.ts +0 -15
  204. package/dist/types/react/components/comment-utils.d.ts +0 -20
  205. package/dist/types/react/components/comment.d.ts +0 -26
  206. package/dist/types/react/components/constants.d.ts +0 -50
  207. package/dist/types/react/components/dev-export-panel.d.ts +0 -10
  208. package/dist/types/react/components/drawing-path-renderer.d.ts +0 -10
  209. package/dist/types/react/components/element-selector.d.ts +0 -11
  210. package/dist/types/react/components/live-region.d.ts +0 -16
  211. package/dist/types/react/components/screenshot-capture.d.ts +0 -17
  212. package/dist/types/react/components/status-indicator.d.ts +0 -43
  213. package/dist/types/react/components/ui.d.ts +0 -44
  214. package/dist/types/react/components/use-comment-composer.d.ts +0 -28
  215. package/dist/types/react/error-boundary.d.ts +0 -25
  216. package/dist/types/react/hooks/use-comment-fab-drag.d.ts +0 -21
  217. package/dist/types/react/hooks/use-comment-hash-link.d.ts +0 -20
  218. package/dist/types/react/hooks/use-comment-kit-filters.d.ts +0 -19
  219. package/dist/types/react/hooks/use-comment-kit-keyboard.d.ts +0 -11
  220. package/dist/types/react/hooks/use-comment-kit-prop-sync.d.ts +0 -12
  221. package/dist/types/react/hooks/use-comment-marker-drag.d.ts +0 -23
  222. package/dist/types/react/hooks/use-comment-panel-navigation.d.ts +0 -21
  223. package/dist/types/react/hooks/use-comment-realtime.d.ts +0 -6
  224. package/dist/types/react/hooks/use-comment-thread-actions.d.ts +0 -15
  225. package/dist/types/react/hooks/use-connection-retry.d.ts +0 -9
  226. package/dist/types/react/hooks/use-drawing.d.ts +0 -32
  227. package/dist/types/react/hooks/use-extension-conflicts.d.ts +0 -13
  228. package/dist/types/react/hooks/use-filtered-threads.d.ts +0 -7
  229. package/dist/types/react/hooks/use-marker-layer.d.ts +0 -19
  230. package/dist/types/react/hooks/use-screenshot.d.ts +0 -18
  231. package/dist/types/react/hooks/use-text-selection.d.ts +0 -17
  232. package/dist/types/react/hooks/use-websocket.d.ts +0 -9
  233. package/dist/types/react/is-local-host.d.ts +0 -2
  234. package/dist/types/react/mount-ui.d.ts +0 -19
  235. package/dist/types/react/shadow-root.d.ts +0 -23
  236. package/dist/types/react/shims/use-sync-external-store-with-selector.d.ts +0 -4
  237. package/dist/types/react/shims/use-sync-external-store.d.ts +0 -1
  238. package/dist/types/react/ui/lib/ShadowRootContext.d.ts +0 -10
  239. package/dist/types/react/ui/lib/cn.d.ts +0 -12
  240. package/dist/types/react/ui/lib/widget-theme.d.ts +0 -7
  241. package/dist/types/react/ui/primitives/alert/alert.d.ts +0 -8
  242. package/dist/types/react/ui/primitives/alert/index.d.ts +0 -1
  243. package/dist/types/react/ui/primitives/alert-dialog/alert-dialog.d.ts +0 -23
  244. package/dist/types/react/ui/primitives/alert-dialog/index.d.ts +0 -1
  245. package/dist/types/react/ui/primitives/avatar/avatar.d.ts +0 -10
  246. package/dist/types/react/ui/primitives/avatar/index.d.ts +0 -1
  247. package/dist/types/react/ui/primitives/badge/badge.d.ts +0 -5
  248. package/dist/types/react/ui/primitives/badge/index.d.ts +0 -1
  249. package/dist/types/react/ui/primitives/breadcrumb/breadcrumb.d.ts +0 -10
  250. package/dist/types/react/ui/primitives/breadcrumb/index.d.ts +0 -1
  251. package/dist/types/react/ui/primitives/button/button.d.ts +0 -6
  252. package/dist/types/react/ui/primitives/button/index.d.ts +0 -1
  253. package/dist/types/react/ui/primitives/button-group/button-group.d.ts +0 -9
  254. package/dist/types/react/ui/primitives/button-group/index.d.ts +0 -1
  255. package/dist/types/react/ui/primitives/card/card.d.ts +0 -11
  256. package/dist/types/react/ui/primitives/card/index.d.ts +0 -1
  257. package/dist/types/react/ui/primitives/checkbox/checkbox.d.ts +0 -3
  258. package/dist/types/react/ui/primitives/checkbox/index.d.ts +0 -1
  259. package/dist/types/react/ui/primitives/dialog/dialog.d.ts +0 -17
  260. package/dist/types/react/ui/primitives/dialog/index.d.ts +0 -1
  261. package/dist/types/react/ui/primitives/dropdown-menu/dropdown-menu.d.ts +0 -29
  262. package/dist/types/react/ui/primitives/dropdown-menu/index.d.ts +0 -1
  263. package/dist/types/react/ui/primitives/empty/empty.d.ts +0 -10
  264. package/dist/types/react/ui/primitives/empty/index.d.ts +0 -1
  265. package/dist/types/react/ui/primitives/field/field.d.ts +0 -22
  266. package/dist/types/react/ui/primitives/field/index.d.ts +0 -1
  267. package/dist/types/react/ui/primitives/hover-card/hover-card.d.ts +0 -6
  268. package/dist/types/react/ui/primitives/hover-card/index.d.ts +0 -1
  269. package/dist/types/react/ui/primitives/input/index.d.ts +0 -1
  270. package/dist/types/react/ui/primitives/input/input.d.ts +0 -3
  271. package/dist/types/react/ui/primitives/input-group/index.d.ts +0 -1
  272. package/dist/types/react/ui/primitives/input-group/input-group.d.ts +0 -16
  273. package/dist/types/react/ui/primitives/input-otp/index.d.ts +0 -1
  274. package/dist/types/react/ui/primitives/input-otp/input-otp.d.ts +0 -11
  275. package/dist/types/react/ui/primitives/kbd/index.d.ts +0 -1
  276. package/dist/types/react/ui/primitives/kbd/kbd.d.ts +0 -4
  277. package/dist/types/react/ui/primitives/label/index.d.ts +0 -1
  278. package/dist/types/react/ui/primitives/label/label.d.ts +0 -3
  279. package/dist/types/react/ui/primitives/native-select/index.d.ts +0 -1
  280. package/dist/types/react/ui/primitives/native-select/native-select.d.ts +0 -7
  281. package/dist/types/react/ui/primitives/popover/index.d.ts +0 -1
  282. package/dist/types/react/ui/primitives/popover/popover.d.ts +0 -9
  283. package/dist/types/react/ui/primitives/preview/component-preview.d.ts +0 -8
  284. package/dist/types/react/ui/primitives/progress/index.d.ts +0 -1
  285. package/dist/types/react/ui/primitives/progress/progress.d.ts +0 -7
  286. package/dist/types/react/ui/primitives/radio-group/index.d.ts +0 -1
  287. package/dist/types/react/ui/primitives/radio-group/radio-group.d.ts +0 -6
  288. package/dist/types/react/ui/primitives/scroll-area/index.d.ts +0 -1
  289. package/dist/types/react/ui/primitives/scroll-area/scroll-area.d.ts +0 -6
  290. package/dist/types/react/ui/primitives/select/index.d.ts +0 -1
  291. package/dist/types/react/ui/primitives/select/select.d.ts +0 -15
  292. package/dist/types/react/ui/primitives/separator/index.d.ts +0 -1
  293. package/dist/types/react/ui/primitives/separator/separator.d.ts +0 -3
  294. package/dist/types/react/ui/primitives/sheet/index.d.ts +0 -1
  295. package/dist/types/react/ui/primitives/sheet/sheet.d.ts +0 -14
  296. package/dist/types/react/ui/primitives/skeleton/index.d.ts +0 -1
  297. package/dist/types/react/ui/primitives/skeleton/skeleton.d.ts +0 -3
  298. package/dist/types/react/ui/primitives/slider/index.d.ts +0 -1
  299. package/dist/types/react/ui/primitives/slider/slider.d.ts +0 -7
  300. package/dist/types/react/ui/primitives/sonner/index.d.ts +0 -1
  301. package/dist/types/react/ui/primitives/sonner/sonner.d.ts +0 -4
  302. package/dist/types/react/ui/primitives/spinner/index.d.ts +0 -1
  303. package/dist/types/react/ui/primitives/spinner/spinner.d.ts +0 -3
  304. package/dist/types/react/ui/primitives/switch/index.d.ts +0 -1
  305. package/dist/types/react/ui/primitives/switch/switch.d.ts +0 -5
  306. package/dist/types/react/ui/primitives/tabs/index.d.ts +0 -1
  307. package/dist/types/react/ui/primitives/tabs/tabs.d.ts +0 -8
  308. package/dist/types/react/ui/primitives/textarea/index.d.ts +0 -1
  309. package/dist/types/react/ui/primitives/textarea/textarea.d.ts +0 -3
  310. package/dist/types/react/ui/primitives/toggle/index.d.ts +0 -1
  311. package/dist/types/react/ui/primitives/toggle/toggle.d.ts +0 -7
  312. package/dist/types/react/ui/primitives/toggle-group/index.d.ts +0 -1
  313. package/dist/types/react/ui/primitives/toggle-group/toggle-group.d.ts +0 -14
  314. package/dist/types/react/ui/primitives/tooltip/index.d.ts +0 -1
  315. package/dist/types/react/ui/primitives/tooltip/tooltip.d.ts +0 -7
  316. package/dist/types/utils/freeze-animations.d.ts +0 -8
  317. package/dist/types/utils/text.d.ts +0 -9
  318. package/dist/types/utils/validation.d.ts +0 -10
  319. package/dist/vue/chunk-DHrubWSL.js +0 -11
  320. package/dist/vue/comment-kit-ui-C3zijClM.js +0 -24898
  321. package/dist/vue/dom-C7krZAR8.js +0 -104
  322. package/dist/vue/error-boundary-DW6uGR8U.js +0 -21
  323. package/dist/vue/limits-B6csdQeI.js +0 -71
  324. package/dist/vue/mount-ui-18BnLwCO.js +0 -72
  325. package/dist/vue/pusher-cmjNbW6a.js +0 -2504
  326. package/dist/vue/realtime-B0B5cE-E.js +0 -567
  327. package/dist/vue/shadow-root-zwd_wUIP.js +0 -93
  328. package/dist/vue/styles-B0NAkbKu.js +0 -2
  329. package/dist/vue/widget-theme-D7Vkagk7.js +0 -24
  330. /package/dist/{angular/error-boundary-CxhCm8iF.js → shared/error-boundary-D3PD74vI.js} +0 -0
@@ -0,0 +1,3083 @@
1
+ import { a as e, c as t, l as n, n as r, o as i, r as a, s as o, t as s, u as c } from "./validation-C7QG8j7Z.js";
2
+ import { n as l, o as u } from "./dom-Bhf4WFtY.js";
3
+ var d = "https://api.commentkit.dev/api", f = 3e4, p = 10485760, m = 10, h = 1e4, g = 5e3, _ = 254, v = 6, y = 4096, b = [
4
+ ".png",
5
+ ".jpg",
6
+ ".jpeg",
7
+ ".gif",
8
+ ".webp"
9
+ ], x = [
10
+ "image/png",
11
+ "image/jpeg",
12
+ "image/gif",
13
+ "image/webp"
14
+ ], S = /@\[([^\]]+)\]\(([^)]+)\)/g, ee = {
15
+ invalid_api_key: "Authentication failed. Please check your API key.",
16
+ missing_api_key: "Authentication failed. Please check your API key.",
17
+ origin_not_allowed: "This domain is not allowed to use this project's API key.",
18
+ invalid_email: "A valid email address is required.",
19
+ invalid_otp: "A valid OTP code is required.",
20
+ invalid_token: "A valid invite token is required.",
21
+ network_error: "Unable to connect to servers. Please check your connection.",
22
+ timeout: "Request timed out. Please try again.",
23
+ rate_limit: "Too many requests. Please wait before trying again.",
24
+ unauthorized: "You are not authorized to perform this action.",
25
+ not_found: "The requested resource was not found.",
26
+ validation_error: "Invalid input. Please check your data.",
27
+ invalid_response: "Invalid server response.",
28
+ auth_failed: "Sign-in failed. Please check your email and try again.",
29
+ otp_cooldown: "A code was sent recently — please wait a minute before requesting another.",
30
+ otp_not_found: "No verification code found. Request a new one.",
31
+ otp_expired: "That verification code has expired. Request a new one.",
32
+ otp_max_attempts: "Too many incorrect attempts. Request a new code.",
33
+ otp_invalid: "Incorrect verification code. Please try again.",
34
+ invalid_invite: "This invite link is invalid or has expired.",
35
+ email_mismatch: "This invite was issued for a different email address.",
36
+ quota_exceeded: "This project has reached its plan limit."
37
+ };
38
+ function te(e, t) {
39
+ let n = {};
40
+ return e.content !== void 0 && (n.content = e.content), e.status !== void 0 && (n.status = e.status), e.priority !== void 0 && (n.priority = e.priority), e.description !== void 0 && (n.description = e.description), e.assignees !== void 0 && (n.assignees = e.assignees.map((e) => e.id)), e.checklist !== void 0 && (n.checklist = e.checklist.map((e) => ({
41
+ ...e,
42
+ id: /^\d+$/.test(e.id) ? Number(e.id) : null
43
+ }))), e.textSelection !== void 0 && (n.text_selection = e.textSelection), e.drawingData !== void 0 && (n.drawing_data = e.drawingData), e.attachmentIds !== void 0 && (n.attachment_ids = e.attachmentIds.map((e) => typeof e == "number" ? e : Number(e)).filter((e) => Number.isInteger(e) && e > 0).slice(0, 20)), t && t.length > 0 && (n.mentions = t), n;
44
+ }
45
+ function ne(e) {
46
+ return e === "localhost" || e === "127.0.0.1" || e === "[::1]" || e.endsWith(".localhost");
47
+ }
48
+ function re(e) {
49
+ let t = (e || d).trim().replace(/\/+$/, "");
50
+ try {
51
+ let e = new URL(t);
52
+ if (e.protocol !== "https:" && e.protocol !== "http:") throw Error("unsupported protocol");
53
+ if (e.protocol === "http:" && !ne(e.hostname)) throw Error("insecure protocol");
54
+ } catch {
55
+ throw new D("invalid_base_url", "Invalid API base URL", 400);
56
+ }
57
+ return t;
58
+ }
59
+ function C(e) {
60
+ let t = String(e).trim();
61
+ if (!t || r(t)) throw new D("invalid_id", "Invalid identifier", 400);
62
+ return encodeURIComponent(t);
63
+ }
64
+ function w(e) {
65
+ if (typeof e != "string" || r(e)) throw new D("invalid_email", "A valid email address is required", 400);
66
+ let t = e.trim();
67
+ if (!c(t, _)) throw new D("invalid_email", "A valid email address is required", 400);
68
+ return t;
69
+ }
70
+ function ie(e) {
71
+ if (r(e)) throw new D("invalid_otp", "A valid OTP code is required", 400);
72
+ let t = e.trim();
73
+ if (t.length !== v || /\s/.test(t)) throw new D("invalid_otp", "A valid OTP code is required", 400);
74
+ return t;
75
+ }
76
+ function ae(e) {
77
+ if (r(e)) throw new D("invalid_token", "A valid invite token is required", 400);
78
+ let t = e.trim();
79
+ if (t.length !== 64 || !/^[\w-]+$/.test(t)) throw new D("invalid_token", "A valid invite token is required", 400);
80
+ return t;
81
+ }
82
+ function T(e, t, n = h) {
83
+ let r = e.trim();
84
+ if (!r) throw new D("invalid_content", `${t} cannot be empty`, 400);
85
+ if (r.length > n) throw new D("content_too_long", `${t} exceeds maximum length of ${n} characters`, 400);
86
+ return r;
87
+ }
88
+ function oe(e) {
89
+ if (!i(e)) return;
90
+ let t = {};
91
+ for (let [n, r] of Object.entries(e).slice(0, 20)) /^[\w.-]{1,64}$/.test(n) && n !== "__proto__" && n !== "constructor" && n !== "prototype" && (typeof r == "string" ? t[n] = r.slice(0, 200) : typeof r == "number" || typeof r == "boolean" || r === null ? t[n] = r : Array.isArray(r) && (t[n] = r.filter((e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null).slice(0, 10).map((e) => typeof e == "string" ? e.slice(0, 200) : e)));
92
+ return Object.keys(t).length > 0 ? t : void 0;
93
+ }
94
+ var se = class {
95
+ constructor(e) {
96
+ this.projectId = null, this.userEmail = null, this.authToken = null, this.environment = null, this.onAuthExpired = null, this.baseUrl = re(e.baseUrl), this.apiKey = e.apiKey, this.projectId = e.projectId || null, this.environment = e.environment || null;
97
+ }
98
+ setProject(e) {
99
+ this.projectId = String(e).trim();
100
+ }
101
+ setUserEmail(e) {
102
+ this.userEmail = e ? w(e) : null;
103
+ }
104
+ setAuthToken(e) {
105
+ if (e && (r(e) || e.length > y)) throw new D("invalid_token", "A valid auth token is required", 400);
106
+ let t = e?.trim() || null;
107
+ this.authToken = t;
108
+ }
109
+ setEnvironment(e) {
110
+ this.environment = e;
111
+ }
112
+ setOnAuthExpired(e) {
113
+ this.onAuthExpired = e;
114
+ }
115
+ buildHeaders(e) {
116
+ if (typeof this.apiKey != "string" || r(this.apiKey)) throw new D("invalid_api_key", "Authentication failed. Please check your API key.", 401);
117
+ return {
118
+ "X-API-Key": this.apiKey,
119
+ ...this.userEmail ? { "X-User-Email": this.userEmail } : {},
120
+ ...this.authToken ? { Authorization: `Bearer ${this.authToken}` } : {},
121
+ ...e
122
+ };
123
+ }
124
+ async executeRequest(e, t, n, r) {
125
+ let a = new AbortController(), o = setTimeout(() => a.abort(), f);
126
+ try {
127
+ let o = await fetch(e, {
128
+ ...t,
129
+ signal: a.signal
130
+ }), s = await this.parseResponseBody(o);
131
+ if (!o.ok) {
132
+ o.status === 401 && this.authToken && (this.authToken = null, this.onAuthExpired?.());
133
+ let e = i(s) ? s : {}, t = typeof e.error == "string" ? e.error : n;
134
+ throw new D(t, ee[t] ?? r, o.status, oe(e.details));
135
+ }
136
+ return s;
137
+ } catch (e) {
138
+ if (e instanceof D) throw e;
139
+ if (e instanceof DOMException && e.name === "AbortError") throw new D("timeout", "Request timed out. Please try again.", 408);
140
+ if (e instanceof TypeError) throw new D("network_error", "Unable to connect to servers. Please check your connection.", 0);
141
+ let t = new D("unknown_error", "An unexpected error occurred", 500);
142
+ throw t.cause = e, t;
143
+ } finally {
144
+ clearTimeout(o);
145
+ }
146
+ }
147
+ async parseResponseBody(e) {
148
+ if (e.status === 204 || e.status === 205) return {};
149
+ let t = e.headers?.get?.("content-type") ?? "";
150
+ if (typeof e.text == "function") {
151
+ let n = await e.text();
152
+ if (!n) return {};
153
+ if (t && !t.toLowerCase().includes("application/json")) {
154
+ if (e.ok) throw new D("invalid_response", "Invalid server response", 502);
155
+ return {};
156
+ }
157
+ try {
158
+ return JSON.parse(n);
159
+ } catch {
160
+ if (e.ok) throw new D("invalid_response", "Invalid server response", 502);
161
+ return {};
162
+ }
163
+ }
164
+ if (typeof e.json == "function") try {
165
+ return await e.json();
166
+ } catch {
167
+ if (e.ok) throw new D("invalid_response", "Invalid server response", 502);
168
+ }
169
+ return {};
170
+ }
171
+ async request(e, t = {}) {
172
+ let n = `${this.baseUrl}${e}`, r = this.buildHeaders({
173
+ "Content-Type": "application/json",
174
+ ...t.headers
175
+ });
176
+ return this.executeRequest(n, {
177
+ ...t,
178
+ headers: r
179
+ }, "request_failed", "An error occurred");
180
+ }
181
+ async requestFormData(e, t) {
182
+ let n = `${this.baseUrl}${e}`, r = this.buildHeaders();
183
+ return this.executeRequest(n, {
184
+ method: "POST",
185
+ headers: r,
186
+ body: t
187
+ }, "upload_failed", "Upload failed");
188
+ }
189
+ requireProjectId() {
190
+ if (!this.projectId) throw new D("missing_project_id", "Project ID is required", 400);
191
+ return this.projectId;
192
+ }
193
+ async validateApiKey() {
194
+ return this.request("/auth/validate-key", {
195
+ method: "POST",
196
+ body: JSON.stringify({})
197
+ });
198
+ }
199
+ async requestOtp(e) {
200
+ let t = w(e);
201
+ return this.request("/auth/otp/request", {
202
+ method: "POST",
203
+ body: JSON.stringify({ email: t })
204
+ });
205
+ }
206
+ async verifyOtp(e, t) {
207
+ let n = w(e), r = ie(t);
208
+ return this.request("/auth/otp/verify", {
209
+ method: "POST",
210
+ body: JSON.stringify({
211
+ email: n,
212
+ otp: r
213
+ })
214
+ });
215
+ }
216
+ async validateInvite(e, t) {
217
+ let n = ae(e), r = w(t);
218
+ return this.request("/auth/validate-invite", {
219
+ method: "POST",
220
+ body: JSON.stringify({
221
+ token: n,
222
+ email: r
223
+ })
224
+ });
225
+ }
226
+ async getComments(e, t = "all", n = 1, r = 50, i) {
227
+ let a = this.requireProjectId(), o = new URLSearchParams();
228
+ e && o.append("page_path", e), t !== "all" && o.append("status", t), i && o.append("environment", i);
229
+ let s = Number.isFinite(n) ? Math.max(1, Math.floor(n)) : 1, c = Number.isFinite(r) ? Math.min(100, Math.max(1, Math.floor(r))) : 50;
230
+ o.append("page", String(s)), o.append("limit", String(c));
231
+ let l = o.toString(), u = `/projects/${C(a)}/comments${l ? `?${l}` : ""}`, d = await this.request(u), f = d.comments ?? [];
232
+ return {
233
+ comments: f,
234
+ pagination: d.pagination ?? {
235
+ total: f.length,
236
+ hasMore: f.length >= c,
237
+ page: s,
238
+ limit: c
239
+ }
240
+ };
241
+ }
242
+ idempotencyHeaders(e) {
243
+ return typeof e == "string" && e.length > 0 && e.length <= 256 && !r(e) ? { "Idempotency-Key": e } : {};
244
+ }
245
+ async createComment(e, t, n, r, i = "medium", a, o, s, c) {
246
+ let l = T(t, "Comment content"), u = this.requireProjectId(), d = s?.mentions ?? E(l);
247
+ return (await this.request(`/projects/${C(u)}/comments`, {
248
+ method: "POST",
249
+ headers: this.idempotencyHeaders(c),
250
+ body: JSON.stringify({
251
+ type: e,
252
+ position: n,
253
+ page_url: r.url,
254
+ page_path: r.path,
255
+ page_title: r.title,
256
+ environment: this.environment || void 0,
257
+ ...te({
258
+ content: l,
259
+ priority: i,
260
+ description: s?.description,
261
+ assignees: s?.assignees,
262
+ checklist: s?.checklist,
263
+ textSelection: a,
264
+ drawingData: o,
265
+ attachmentIds: s?.attachmentIds
266
+ }, d)
267
+ })
268
+ })).comment;
269
+ }
270
+ async updateComment(e, t) {
271
+ let n = this.requireProjectId(), r = t.content === void 0 ? void 0 : T(t.content, "Comment content"), i = r ? E(r) : void 0, a = te({
272
+ ...t,
273
+ ...r === void 0 ? {} : { content: r }
274
+ }, i);
275
+ return (await this.request(`/projects/${C(n)}/comments/${C(e)}`, {
276
+ method: "PUT",
277
+ body: JSON.stringify(a)
278
+ })).comment;
279
+ }
280
+ async deleteComment(e) {
281
+ let t = this.requireProjectId();
282
+ await this.request(`/projects/${C(t)}/comments/${C(e)}`, { method: "DELETE" });
283
+ }
284
+ async addReply(e, t, n) {
285
+ let r = this.requireProjectId(), i = T(t, "Reply content", g), a = E(i);
286
+ return (await this.request(`/projects/${C(r)}/comments/${C(e)}/replies`, {
287
+ method: "POST",
288
+ headers: this.idempotencyHeaders(n),
289
+ body: JSON.stringify({
290
+ content: i,
291
+ ...a.length > 0 ? { mentions: a } : {}
292
+ })
293
+ })).reply;
294
+ }
295
+ async updateReply(e, t, n) {
296
+ let r = this.requireProjectId(), i = T(n, "Reply content", g);
297
+ return (await this.request(`/projects/${C(r)}/comments/${C(e)}/replies/${C(t)}`, {
298
+ method: "PUT",
299
+ body: JSON.stringify({ content: i })
300
+ })).reply;
301
+ }
302
+ async deleteReply(e, t) {
303
+ let n = this.requireProjectId();
304
+ await this.request(`/projects/${C(n)}/comments/${C(e)}/replies/${C(t)}`, { method: "DELETE" });
305
+ }
306
+ async resolveComment(e) {
307
+ let t = this.requireProjectId();
308
+ return (await this.request(`/projects/${C(t)}/comments/${C(e)}/resolve`, { method: "POST" })).comment;
309
+ }
310
+ async unresolveComment(e) {
311
+ let t = this.requireProjectId();
312
+ return (await this.request(`/projects/${C(t)}/comments/${C(e)}/unresolve`, { method: "POST" })).comment;
313
+ }
314
+ async markComplete(e) {
315
+ let t = this.requireProjectId();
316
+ return (await this.request(`/projects/${C(t)}/comments/${C(e)}/complete`, { method: "POST" })).comment;
317
+ }
318
+ async addReaction(e, t) {
319
+ let n = this.requireProjectId();
320
+ await this.request(`/projects/${C(n)}/comments/${C(e)}/reactions`, {
321
+ method: "POST",
322
+ body: JSON.stringify({ emoji: t })
323
+ });
324
+ }
325
+ async removeReaction(e, t) {
326
+ let n = this.requireProjectId();
327
+ await this.request(`/projects/${C(n)}/comments/${C(e)}/reactions`, {
328
+ method: "DELETE",
329
+ body: JSON.stringify({ emoji: t })
330
+ });
331
+ }
332
+ async updatePosition(e, t) {
333
+ let n = this.requireProjectId();
334
+ return (await this.request(`/projects/${C(n)}/comments/${C(e)}/position`, {
335
+ method: "PUT",
336
+ body: JSON.stringify({ position: t })
337
+ })).comment;
338
+ }
339
+ async createHighlight(e, t, n, r = "medium", i) {
340
+ return this.createComment("highlight", e, {
341
+ x: 0,
342
+ y: 0
343
+ }, n, r, t, void 0, void 0, i);
344
+ }
345
+ async createDrawing(e, t, n, r, i) {
346
+ return this.createComment("drawing", e, n, r, "medium", void 0, t, void 0, i);
347
+ }
348
+ validateFile(e, t = !1) {
349
+ if (e.size > p) throw new D("file_too_large", `File size (${Math.round(e.size / 1024 / 1024)}MB) exceeds maximum of ${p / 1024 / 1024}MB`, 400);
350
+ if (r(e.name) || e.name.includes("/") || e.name.includes("\\")) throw new D("invalid_filename", "Filename contains invalid characters", 400);
351
+ if (t) {
352
+ /* v8 ignore next -- pop() always returns a value since file has a name */
353
+ let t = "." + (e.name.split(".").pop()?.toLowerCase() ?? "");
354
+ if ((e.name.match(/\./g) || []).length > 1) throw new D("invalid_filename", "Filenames with multiple extensions are not allowed", 400);
355
+ if (!x.includes(e.type) || !b.includes(t)) throw new D("invalid_file_type", `Only image files are allowed (${b.join(", ")})`, 400);
356
+ }
357
+ if (s(e.name)) throw new D("invalid_file_type", "This file type is not allowed", 400);
358
+ }
359
+ async uploadFile(e, t, n) {
360
+ this.validateFile(e, t === "screenshot" || t === "drawing");
361
+ let r = this.requireProjectId(), i = new FormData();
362
+ i.append("file", e), i.append("type", t === "attachment" ? "file" : t), n?.commentId && i.append("comment_id", n.commentId), n?.replyId && i.append("reply_id", n.replyId);
363
+ let a = await this.requestFormData(`/projects/${C(r)}/files`, i);
364
+ return {
365
+ id: String(a.attachment.id),
366
+ type: a.attachment.type,
367
+ url: a.attachment.url,
368
+ thumbnail: a.attachment.thumbnail,
369
+ filename: a.attachment.filename,
370
+ size: a.attachment.size
371
+ };
372
+ }
373
+ async uploadScreenshot(e, t) {
374
+ this.validateFile(e, !0);
375
+ let n = T(t.content, "Screenshot comment"), r = this.requireProjectId(), i = new FormData();
376
+ return i.append("file", e), i.append("content", n), i.append("position_x", String(t.position.x)), i.append("position_y", String(t.position.y)), i.append("page_url", t.page.url), i.append("page_path", t.page.path), i.append("page_title", t.page.title), (await this.requestFormData(`/projects/${C(r)}/screenshots`, i)).comment;
377
+ }
378
+ async uploadFiles(e, t) {
379
+ if (e.length > m) throw new D("too_many_files", `Cannot upload more than ${m} files at once`, 400);
380
+ let n = await Promise.allSettled(e.map((e) => {
381
+ /* v8 ignore next -- pop() always returns a value since file has a name */
382
+ let n = "." + (e.name.split(".").pop()?.toLowerCase() ?? ""), r = x.includes(e.type) && b.includes(n);
383
+ return this.uploadFile(e, r ? "screenshot" : "attachment", t);
384
+ })), r = n.filter((e) => e.status === "fulfilled").map((e) => e.value.id), i = n.find((e) => e.status === "rejected");
385
+ if (i) {
386
+ let e = i.reason;
387
+ throw e instanceof D ? new D(e.error, e.message, e.code, {
388
+ ...e.details,
389
+ uploadedIds: r
390
+ }) : new D("upload_failed", "Upload failed", 0, { uploadedIds: r });
391
+ }
392
+ return r;
393
+ }
394
+ async getProjectMembers() {
395
+ let e = this.requireProjectId();
396
+ return (await this.request(`/projects/${C(e)}/members`)).members ?? [];
397
+ }
398
+ };
399
+ function E(e) {
400
+ let t = [], n;
401
+ for (S.lastIndex = 0; (n = S.exec(e)) !== null;) {
402
+ let e = n[1]?.trim(), r = n[2]?.trim();
403
+ e && r && /^[\w-]+$/.test(r) && t.push({
404
+ name: e,
405
+ userId: r,
406
+ index: n.index
407
+ });
408
+ }
409
+ return t;
410
+ }
411
+ function ce(e) {
412
+ return `@[${e.name.replace(/\]/g, "")}](${e.id.replace(/\)/g, "")})`;
413
+ }
414
+ function le(e) {
415
+ return e.replace(S, "@$1");
416
+ }
417
+ var D = class extends Error {
418
+ constructor(e, t, n, r) {
419
+ super(t), this.name = "ApiClientError", this.error = e, this.code = n, this.details = r;
420
+ }
421
+ isAuthError() {
422
+ return this.code === 401 || this.error === "invalid_api_key";
423
+ }
424
+ isNetworkError() {
425
+ return this.code === 0 || this.error === "network_error";
426
+ }
427
+ isRateLimitError() {
428
+ return this.code === 429;
429
+ }
430
+ isPremiumFeatureError() {
431
+ return this.code === 402;
432
+ }
433
+ };
434
+ function ue(e, t) {
435
+ return (e ?? "").replace(/\s+/g, " ").trim().slice(0, t);
436
+ }
437
+ function O(e, t) {
438
+ return (e ?? "").replace(/\s+/g, " ").replace(/`/g, "'").trim().slice(0, t);
439
+ }
440
+ var k = null, de = 0, fe = 3;
441
+ function pe() {
442
+ return k || (k = (async () => {
443
+ try {
444
+ let e = await import("element-source");
445
+ return typeof e?.resolveElementInfo == "function" ? e : null;
446
+ } catch {
447
+ return de += 1, de < fe && (k = null), null;
448
+ }
449
+ })(), k);
450
+ }
451
+ async function me(e) {
452
+ let t = await pe();
453
+ if (!t) return null;
454
+ try {
455
+ return await t.resolveElementInfo(e);
456
+ } catch {
457
+ return null;
458
+ }
459
+ }
460
+ var he = 200, ge = 500, _e = 500, ve = 2e3, ye = "application/x-commentkit-agent-context", be = "Use this CommentKit context to understand unresolved UI feedback. Each comment includes page, selector/XPath, viewport position, resolved DOM metadata when available, and thread replies.";
461
+ function xe(e) {
462
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
463
+ }
464
+ function Se(e) {
465
+ return e === void 0 ? he : !Number.isFinite(e) || e <= 0 ? 0 : Math.min(ge, Math.floor(e));
466
+ }
467
+ function Ce(e) {
468
+ return {
469
+ id: e.id,
470
+ name: e.name,
471
+ email: e.email
472
+ };
473
+ }
474
+ function we(e, t) {
475
+ return e.page.path === t.path || e.page.url === t.url;
476
+ }
477
+ function Te(e, t, n, r) {
478
+ return !(!n.includeResolved && e.status !== "open" || n.currentPageOnly && !we(e, t) || r && !r.has(e.id));
479
+ }
480
+ function Ee(e) {
481
+ let t = e.getBoundingClientRect();
482
+ return {
483
+ top: t.top,
484
+ left: t.left,
485
+ width: t.width,
486
+ height: t.height
487
+ };
488
+ }
489
+ function De(e, t) {
490
+ let n = l(e.element ?? "", e.xpath), r = {
491
+ ...e.element ? { selector: e.element } : {},
492
+ ...e.xpath ? { xpath: e.xpath } : {}
493
+ };
494
+ if (!n) return {
495
+ ...r,
496
+ found: !1
497
+ };
498
+ let i = ue(n.textContent, _e), a = t ? ue(n.outerHTML, ve) : "", o = n.getAttribute("class"), s = n.getAttribute("role"), c = n.getAttribute("aria-label");
499
+ return {
500
+ ...r,
501
+ found: !0,
502
+ tagName: n.tagName.toLowerCase(),
503
+ ...n.id ? { id: n.id } : {},
504
+ ...o ? { className: o } : {},
505
+ ...s ? { role: s } : {},
506
+ ...c ? { ariaLabel: c } : {},
507
+ ...i ? { text: i } : {},
508
+ rect: Ee(n),
509
+ ...a ? { htmlPreview: a } : {}
510
+ };
511
+ }
512
+ function Oe(e) {
513
+ return {
514
+ id: e.id,
515
+ content: e.content,
516
+ author: Ce(e.author),
517
+ createdAt: e.createdAt
518
+ };
519
+ }
520
+ function ke(e) {
521
+ return e.attachments?.find((e) => e.url && e.type === "screenshot")?.url;
522
+ }
523
+ function Ae(e, t) {
524
+ let n = ke(e);
525
+ return {
526
+ id: e.id,
527
+ type: e.type,
528
+ status: e.status,
529
+ priority: e.priority,
530
+ content: e.content,
531
+ author: Ce(e.author),
532
+ createdAt: e.createdAt,
533
+ updatedAt: e.updatedAt,
534
+ page: e.page,
535
+ position: e.position,
536
+ element: De(e.position, t.includeHtml === !0),
537
+ ...n ? { screenshotUrl: n } : {},
538
+ replies: e.replies.map(Oe)
539
+ };
540
+ }
541
+ function je(e) {
542
+ return {
543
+ filePath: e.filePath,
544
+ lineNumber: e.lineNumber,
545
+ columnNumber: e.columnNumber,
546
+ componentName: e.componentName
547
+ };
548
+ }
549
+ function A(e, t = {}) {
550
+ let n = u(), r = {
551
+ url: n.url,
552
+ path: n.path,
553
+ title: n.title
554
+ }, i = t.commentIds?.length ? new Set(t.commentIds) : null, a = Se(t.maxComments), o = e.comments.filter((e) => Te(e, r, t, i)).slice(0, a).map((e) => Ae(e, t));
555
+ return {
556
+ version: 1,
557
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
558
+ instructions: O(t.instructions, 2e3) || be,
559
+ page: r,
560
+ comments: o,
561
+ sourceResolved: !1
562
+ };
563
+ }
564
+ async function Me(e) {
565
+ let t = !1, n = await Promise.all(e.comments.map(async (e) => {
566
+ if (!e.element.found) return e;
567
+ let n = l(e.element.selector ?? "", e.element.xpath);
568
+ if (!n) return e;
569
+ let r = await me(n);
570
+ if (!r || !r.source) return e;
571
+ t = !0;
572
+ let i = je(r.source), a = r.stack.map(je), o = r.componentName ?? void 0;
573
+ return {
574
+ ...e,
575
+ element: {
576
+ ...e.element,
577
+ source: i,
578
+ stack: a,
579
+ ...o ? { componentName: o } : {}
580
+ }
581
+ };
582
+ }));
583
+ return {
584
+ ...e,
585
+ comments: n,
586
+ sourceResolved: t
587
+ };
588
+ }
589
+ function Ne(e) {
590
+ let t = `${e.filePath}${e.lineNumber === null ? "" : `:${e.lineNumber}`}${e.columnNumber === null ? "" : `:${e.columnNumber}`}`;
591
+ return e.componentName ? `${e.componentName} (${t})` : t;
592
+ }
593
+ function j(e) {
594
+ return [
595
+ "# CommentKit Agent Context",
596
+ "",
597
+ e.instructions,
598
+ "",
599
+ `Current page: ${O(e.page.title, 300) || "Untitled"} (${e.page.url || e.page.path || "unknown"})`,
600
+ `Comments: ${e.comments.length}${e.sourceResolved ? " (source-resolved)" : ""}`,
601
+ "",
602
+ ...e.comments.map((e, t) => {
603
+ let n = e.element.found ? `${e.element.tagName}${e.element.id ? `#${e.element.id}` : ""}` : "not found", r = [
604
+ `## ${t + 1}. ${O(e.content, 300)}`,
605
+ `- Status: ${e.status}`,
606
+ `- Priority: ${e.priority}`,
607
+ `- Author: ${e.author.name} <${e.author.email}>`,
608
+ `- Page: ${e.page.url}`,
609
+ `- Element: ${n}`
610
+ ];
611
+ return e.element.source && r.push(`- Source: ${Ne(e.element.source)}`), e.element.stack && e.element.stack.length > 0 && r.push("- Stack:", ...e.element.stack.map((e) => ` - ${Ne(e)}`)), e.element.source || r.push(`- Selector: ${e.element.selector ?? "none"}`, `- XPath: ${e.element.xpath ?? "none"}`), e.screenshotUrl && r.push(`- Screenshot: ${e.screenshotUrl}`), r.push(e.replies.length > 0 ? `- Replies: ${e.replies.length}` : "- Replies: 0", ""), r.join("\n");
612
+ }),
613
+ "```json",
614
+ JSON.stringify(e, null, 2),
615
+ "```"
616
+ ].join("\n");
617
+ }
618
+ function Pe(e) {
619
+ return {
620
+ version: e?.version ?? 1,
621
+ generatedAt: e?.generatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
622
+ commentCount: e?.comments.length ?? 0,
623
+ context: e
624
+ };
625
+ }
626
+ function Fe(e, t) {
627
+ if (typeof document > "u" || !document.body || typeof document.execCommand != "function") return !1;
628
+ let n = JSON.stringify(t), r = (t) => {
629
+ t.preventDefault(), t.clipboardData?.setData("text/plain", e), t.clipboardData?.setData("text/html", `<meta charset="utf-8"><pre><code>${xe(e)}</code></pre>`), t.clipboardData?.setData(ye, n);
630
+ }, i = document.createElement("textarea");
631
+ i.value = e, i.setAttribute("readonly", ""), i.setAttribute("aria-hidden", "true"), i.style.position = "fixed", i.style.left = "-9999px", document.addEventListener("copy", r), document.body.appendChild(i), i.select();
632
+ try {
633
+ return document.execCommand("copy");
634
+ } finally {
635
+ document.removeEventListener("copy", r), i.remove();
636
+ }
637
+ }
638
+ async function Ie(e, t) {
639
+ if (typeof navigator > "u" || typeof navigator.clipboard?.write != "function" || typeof ClipboardItem > "u") return !1;
640
+ try {
641
+ let n = new Blob([`<meta charset="utf-8"><pre><code>${xe(e)}</code></pre>`], { type: "text/html" }), r = new Blob([e], { type: "text/plain" }), i = t.type && t.type.startsWith("image/") ? t.type : "image/png";
642
+ return await navigator.clipboard.write([new ClipboardItem({
643
+ "text/plain": r,
644
+ "text/html": n,
645
+ [i]: t
646
+ })]), !0;
647
+ } catch {
648
+ return !1;
649
+ }
650
+ }
651
+ async function Le(e, t) {
652
+ return t && await Ie(e, t) ? !0 : (await Re(e), !1);
653
+ }
654
+ async function Re(e, t = null) {
655
+ if (!Fe(e, Pe(t))) {
656
+ if (typeof navigator < "u" && typeof navigator.clipboard?.writeText == "function") await navigator.clipboard.writeText(e);
657
+ else throw Error("Clipboard is unavailable");
658
+ }
659
+ }
660
+ var ze = 100, Be = () => {};
661
+ function Ve(e) {
662
+ return typeof e == "function";
663
+ }
664
+ var He = class {
665
+ constructor() {
666
+ this.listeners = /* @__PURE__ */ new Map(), this.onceWrappers = /* @__PURE__ */ new Map();
667
+ }
668
+ on(e, t) {
669
+ if (!Ve(t)) return console.warn(`[CommentKit] Ignoring non-function listener for '${String(e)}'`), Be;
670
+ let n = this.listeners.get(e);
671
+ return n || (n = /* @__PURE__ */ new Set(), this.listeners.set(e, n)), !n.has(t) && n.size >= ze && console.warn(`[CommentKit] Max listeners (${ze}) reached for '${String(e)}' - possible memory leak`), n.add(t), () => this.off(e, t);
672
+ }
673
+ off(e, t) {
674
+ if (!Ve(t)) return;
675
+ let n = this.listeners.get(e);
676
+ if (n) {
677
+ n.delete(t);
678
+ let r = this.onceWrappers.get(e), i = r?.get(t);
679
+ r && i && (n.delete(i), r.delete(t), r.size === 0 && this.onceWrappers.delete(e)), n.size === 0 && this.listeners.delete(e);
680
+ }
681
+ }
682
+ emit(e, t) {
683
+ let n = this.listeners.get(e);
684
+ if (n) for (let r of Array.from(n)) try {
685
+ r(t);
686
+ } catch (t) {
687
+ console.error(`[CommentKit] Error in '${e}' listener:`, t);
688
+ }
689
+ }
690
+ once(e, t) {
691
+ if (!Ve(t)) return console.warn(`[CommentKit] Ignoring non-function listener for '${String(e)}'`), Be;
692
+ let n = (n) => {
693
+ this.off(e, t), t(n);
694
+ }, r = this.onceWrappers.get(e);
695
+ return r || (r = /* @__PURE__ */ new Map(), this.onceWrappers.set(e, r)), r.set(t, n), this.on(e, n);
696
+ }
697
+ removeAllListeners(e) {
698
+ e ? (this.listeners.delete(e), this.onceWrappers.delete(e)) : (this.listeners.clear(), this.onceWrappers.clear());
699
+ }
700
+ listenerCount(e) {
701
+ return this.listeners.get(e)?.size ?? 0;
702
+ }
703
+ }, M = Object.freeze({
704
+ ID: 256,
705
+ CONTENT: 1e4,
706
+ REPLY_CONTENT: 5e3,
707
+ NAME: 500,
708
+ EMAIL: 254,
709
+ PAGE: 2e3,
710
+ SELECTOR: 2048,
711
+ EMOJI: 32,
712
+ COLOR: 128,
713
+ DRAWING_PATH_DATA: 5e4,
714
+ DRAWING_TEXT: 5e3,
715
+ DRAWING_TYPE: 20,
716
+ DRAWING_PATHS: 1e3,
717
+ TEXT_SELECTION: 2e4,
718
+ DESCRIPTION: 1e4,
719
+ ASSIGNEES: 100,
720
+ CHECKLIST_ITEMS: 100,
721
+ CHECKLIST_LABEL: 500,
722
+ ONLINE_USERS: 500,
723
+ RENDERED_CURSORS: 24,
724
+ CURSOR_EMITS_PER_SEC: 240,
725
+ REACTION_COUNT: 1e6,
726
+ PENDING_MUTATIONS: 1e3,
727
+ RETRY_DELAY: 3e4
728
+ }), Ue = "commentkit:session:", We = 4096;
729
+ function Ge() {
730
+ try {
731
+ return typeof sessionStorage > "u" ? null : sessionStorage;
732
+ } catch {
733
+ return null;
734
+ }
735
+ }
736
+ function N(e) {
737
+ return `${Ue}${e}`;
738
+ }
739
+ function Ke(e) {
740
+ return i(e) && n(e.id, M.ID) && n(e.name, M.NAME) && typeof e.email == "string" && c(e.email, M.EMAIL);
741
+ }
742
+ function qe(e) {
743
+ return i(e) && n(e.token, We) && typeof e.email == "string" && c(e.email, M.EMAIL) && Ke(e.user);
744
+ }
745
+ function Je(e, t) {
746
+ if (!e) return;
747
+ let n = Ge();
748
+ if (n) try {
749
+ n.setItem(N(e), JSON.stringify(t));
750
+ } catch {}
751
+ }
752
+ function Ye(e) {
753
+ if (!e) return null;
754
+ let t = Ge();
755
+ if (!t) return null;
756
+ try {
757
+ let n = t.getItem(N(e));
758
+ if (!n) return null;
759
+ let r = JSON.parse(n);
760
+ return qe(r) ? {
761
+ token: r.token.trim(),
762
+ email: r.email.trim(),
763
+ user: {
764
+ id: r.user.id.trim(),
765
+ name: r.user.name.trim(),
766
+ email: r.user.email.trim(),
767
+ ...r.user.avatar ? { avatar: r.user.avatar } : {}
768
+ }
769
+ } : (t.removeItem(N(e)), null);
770
+ } catch {
771
+ return null;
772
+ }
773
+ }
774
+ function Xe(e) {
775
+ if (!e) return;
776
+ let t = Ge();
777
+ if (t) try {
778
+ t.removeItem(N(e));
779
+ } catch {}
780
+ }
781
+ function Ze(e, t) {
782
+ for (let n of e.getState().pendingMutations) e.emit("offline:failed", {
783
+ id: n.id,
784
+ error: {
785
+ error: "auth_cleared",
786
+ message: t,
787
+ code: 401
788
+ }
789
+ });
790
+ }
791
+ var Qe = M.EMAIL, $e = M.NAME, et = M.ID, tt = 4096, nt = 6;
792
+ function rt(e) {
793
+ if (typeof e != "string") return null;
794
+ let t = e.trim();
795
+ return c(t, Qe) ? t : null;
796
+ }
797
+ function it(e) {
798
+ return !r(e) && e.trim().length === nt;
799
+ }
800
+ function at(e) {
801
+ return i(e) && n(e.id, et) && n(e.name, $e) && typeof e.email == "string" && rt(e.email) !== null;
802
+ }
803
+ function ot(e) {
804
+ return i(e) && n(e.id, et);
805
+ }
806
+ function P(e, t, n) {
807
+ return {
808
+ error: e,
809
+ message: t,
810
+ code: n
811
+ };
812
+ }
813
+ async function st(e, t) {
814
+ let n = rt(t);
815
+ if (!n) e.setState({
816
+ isLoading: !1,
817
+ otpStep: "idle",
818
+ otpEmail: null
819
+ }), e.handleError(P("invalid_email", "A valid email address is required", 400));
820
+ else try {
821
+ e.setState({
822
+ isLoading: !0,
823
+ error: null,
824
+ otpStep: "requesting",
825
+ otpEmail: n
826
+ });
827
+ let t = await e.apiClient.requestOtp(n);
828
+ t.success ? (e.setState({
829
+ otpStep: "verifying",
830
+ isLoading: !1
831
+ }), e.emit("auth:otp-requested", {
832
+ email: n,
833
+ expiresIn: t.expiresIn
834
+ })) : (e.setState({
835
+ isLoading: !1,
836
+ otpStep: "idle",
837
+ otpEmail: null
838
+ }), e.handleError(P("otp_failed", "Failed to send OTP. Please try again.", 500)));
839
+ } catch (t) {
840
+ e.setState({
841
+ isLoading: !1,
842
+ otpStep: "idle",
843
+ otpEmail: null
844
+ }), e.handleError(t);
845
+ }
846
+ }
847
+ async function ct(e, t, r) {
848
+ let { onAuthenticated: i, onWrongOtp: a, onSuccess: o } = typeof r == "function" ? { onAuthenticated: r } : r, s = e.getState().otpEmail;
849
+ if (!s) e.handleError(P("no_email", "No OTP request in progress", 400));
850
+ else if (!it(t)) e.setState({ isLoading: !1 }), e.handleError(P("invalid_otp", "Invalid or expired OTP code", 401));
851
+ else try {
852
+ e.setState({
853
+ isLoading: !0,
854
+ error: null
855
+ });
856
+ let r = await e.apiClient.verifyOtp(s, t);
857
+ r.verified && n(r.token, tt) && at(r.user) && ot(r.project) ? (e.apiClient.setAuthToken(r.token), e.apiClient.setUserEmail(r.user.email), Je(e.config.projectId, {
858
+ token: r.token,
859
+ email: r.user.email,
860
+ user: r.user
861
+ }), e.setState({
862
+ currentUser: r.user,
863
+ project: r.project,
864
+ isAuthenticated: !0,
865
+ isLoginModalVisible: !1,
866
+ isOverlayVisible: !0,
867
+ isLoading: !1,
868
+ otpStep: "idle",
869
+ otpEmail: null
870
+ }), o?.(), e.emit("auth:otp-verified", r.user), e.emit("auth:login", r.user), await i()) : (e.setState({ isLoading: !1 }), a?.(), e.handleError(P("invalid_otp", "Invalid or expired OTP code", 401)));
871
+ } catch (t) {
872
+ e.setState({ isLoading: !1 }), e.handleError(t);
873
+ }
874
+ }
875
+ function lt(e) {
876
+ e.setState({
877
+ otpStep: "idle",
878
+ otpEmail: null,
879
+ error: null,
880
+ isLoading: !1
881
+ });
882
+ }
883
+ async function ut(e) {
884
+ let t = e.getState().otpEmail;
885
+ t && await st(e, t);
886
+ }
887
+ function dt(e, t) {
888
+ Ze(e, "Pending offline changes were discarded on logout"), Xe(e.config.projectId), e.apiClient.setUserEmail(null), e.apiClient.setAuthToken(null), t(), e.setState({
889
+ isAuthenticated: !1,
890
+ currentUser: null,
891
+ comments: [],
892
+ activeTool: null,
893
+ selectedComment: null,
894
+ activeComment: null,
895
+ activeDrawing: null,
896
+ activeScreenshot: null,
897
+ onlineUsers: [],
898
+ isOverlayVisible: !1,
899
+ isCommentModeActive: !1,
900
+ isDrawingModeActive: !1,
901
+ isHighlightModeActive: !1,
902
+ isScreenshotModeActive: !1,
903
+ isSidebarVisible: !1,
904
+ otpStep: "idle",
905
+ otpEmail: null,
906
+ pagination: null,
907
+ pendingMutations: [],
908
+ activities: [],
909
+ seenThreadIds: /* @__PURE__ */ new Set(),
910
+ panelView: "list",
911
+ connectionStatus: "disconnected",
912
+ error: null,
913
+ isLoading: !1
914
+ }), e.emit("auth:logout", void 0);
915
+ }
916
+ function ft(e) {
917
+ Ze(e, "Pending offline changes were discarded because the session expired"), Xe(e.config.projectId), e.apiClient.setUserEmail(null), e.apiClient.setAuthToken(null), e.setState({
918
+ isAuthenticated: !1,
919
+ currentUser: null,
920
+ comments: [],
921
+ selectedComment: null,
922
+ activeComment: null,
923
+ activeDrawing: null,
924
+ activeScreenshot: null,
925
+ onlineUsers: [],
926
+ pendingMutations: [],
927
+ activities: [],
928
+ seenThreadIds: /* @__PURE__ */ new Set(),
929
+ panelView: "list",
930
+ connectionStatus: "disconnected",
931
+ isLoginModalVisible: !0,
932
+ error: "Your session has expired. Please sign in again.",
933
+ isLoading: !1
934
+ }), e.emit("error", {
935
+ error: "auth_expired",
936
+ message: "Session expired",
937
+ code: 401
938
+ });
939
+ }
940
+ function pt(e) {
941
+ e.setState({ isLoginModalVisible: !e.getState().isLoginModalVisible });
942
+ }
943
+ async function mt(e, t, n) {
944
+ let r = e.config.inviteToken;
945
+ if (!r) {
946
+ e.handleError(P("no_invite", "No invite token found", 400));
947
+ return;
948
+ }
949
+ let i = rt(t);
950
+ if (!i) e.setState({ isLoading: !1 }), e.handleError(P("invalid_email", "A valid email address is required", 400));
951
+ else try {
952
+ e.setState({
953
+ isLoading: !0,
954
+ error: null
955
+ }), (await e.apiClient.validateInvite(r, i)).success ? await n(i) : (e.setState({ isLoading: !1 }), e.handleError(P("invite_invalid", "Invite validation failed", 400)));
956
+ } catch (t) {
957
+ e.setState({ isLoading: !1 }), e.handleError(t);
958
+ }
959
+ }
960
+ var F = M.ID, ht = M.CONTENT, gt = M.REPLY_CONTENT, _t = M.SELECTOR, vt = M.TEXT_SELECTION, yt = M.DESCRIPTION, bt = M.ASSIGNEES, xt = M.CHECKLIST_ITEMS, St = M.CHECKLIST_LABEL, Ct = M.DRAWING_PATHS, wt = M.DRAWING_PATH_DATA, Tt = M.DRAWING_TEXT, Et = M.REACTION_COUNT, Dt = M.EMOJI, Ot = /* @__PURE__ */ new Set([
961
+ "pin",
962
+ "highlight",
963
+ "drawing"
964
+ ]), kt = /* @__PURE__ */ new Set([
965
+ "low",
966
+ "medium",
967
+ "high",
968
+ "urgent"
969
+ ]), At = /* @__PURE__ */ new Set([
970
+ "open",
971
+ "resolved",
972
+ "complete"
973
+ ]), jt = /* @__PURE__ */ new Set([
974
+ "path",
975
+ "line",
976
+ "rectangle",
977
+ "circle",
978
+ "text"
979
+ ]);
980
+ function I(e, t, n) {
981
+ e.handleError(new D(t, n, 400));
982
+ }
983
+ function L(e) {
984
+ return n(e, F);
985
+ }
986
+ function R(e, t = ht) {
987
+ if (typeof e != "string") return null;
988
+ let n = e.trim();
989
+ return !n || n.length > t || a(n) ? null : n;
990
+ }
991
+ function z(e, t) {
992
+ if (e === void 0) return;
993
+ if (typeof e != "string") return null;
994
+ let n = e.trim();
995
+ return n.length > t || a(n) ? null : n;
996
+ }
997
+ function B(e) {
998
+ if (e === void 0) return;
999
+ if (typeof e != "string") return null;
1000
+ let t = e.trim();
1001
+ return !t || t.length > _t || a(t) ? null : t;
1002
+ }
1003
+ function Mt(t) {
1004
+ if (!i(t) || !e(t.x) || !e(t.y)) return null;
1005
+ let n = B(t.element), r = B(t.xpath);
1006
+ return n === null || r === null ? null : {
1007
+ x: t.x,
1008
+ y: t.y,
1009
+ ...n === void 0 ? {} : { element: n },
1010
+ ...r === void 0 ? {} : { xpath: r }
1011
+ };
1012
+ }
1013
+ function Nt(e) {
1014
+ if (!i(e)) return null;
1015
+ let t = z(e.avatar, _t), n = z(e.organizationId, F);
1016
+ return !L(e.id) || typeof e.name != "string" || !e.name.trim() || e.name.length > M.NAME || a(e.name) || typeof e.email != "string" || !e.email.trim() || e.email.length > M.EMAIL || /\s/.test(e.email.trim()) || a(e.email) || t === null || n === null ? null : {
1017
+ id: e.id.trim(),
1018
+ name: e.name.trim(),
1019
+ email: e.email.trim(),
1020
+ ...t === void 0 ? {} : { avatar: t },
1021
+ ...n === void 0 ? {} : { organizationId: n }
1022
+ };
1023
+ }
1024
+ function Pt(e) {
1025
+ if (e === void 0) return;
1026
+ if (!Array.isArray(e) || e.length > bt) return null;
1027
+ let t = [];
1028
+ for (let n of e) {
1029
+ let e = Nt(n);
1030
+ if (!e) return null;
1031
+ t.push(e);
1032
+ }
1033
+ return t;
1034
+ }
1035
+ function Ft(e) {
1036
+ if (e === void 0) return;
1037
+ if (!Array.isArray(e) || e.length > xt) return null;
1038
+ let t = [];
1039
+ for (let n of e) {
1040
+ if (!i(n)) return null;
1041
+ let e = R(n.label);
1042
+ if (!L(n.id) || !e || typeof n.done != "boolean" || n.sortOrder !== void 0 && (typeof n.sortOrder != "number" || !Number.isFinite(n.sortOrder)) || e.length > St) return null;
1043
+ t.push({
1044
+ id: n.id.trim(),
1045
+ label: e,
1046
+ done: n.done,
1047
+ ...n.sortOrder === void 0 ? {} : { sortOrder: n.sortOrder }
1048
+ });
1049
+ }
1050
+ return t;
1051
+ }
1052
+ function It(e) {
1053
+ if (e === void 0) return;
1054
+ if (!i(e) || typeof e.text != "string") return null;
1055
+ let t = e.text.trim(), n = B(e.element), r = B(e.xpath);
1056
+ return !t || t.length > vt || a(t) || typeof e.startOffset != "number" || typeof e.endOffset != "number" || !Number.isInteger(e.startOffset) || !Number.isInteger(e.endOffset) || e.startOffset < 0 || e.endOffset < e.startOffset || n === null || r === null || n === void 0 || r === void 0 ? null : {
1057
+ text: t,
1058
+ startOffset: e.startOffset,
1059
+ endOffset: e.endOffset,
1060
+ element: n,
1061
+ xpath: r
1062
+ };
1063
+ }
1064
+ function Lt(e) {
1065
+ return typeof e == "string" && e.length > 0 && e.length <= M.COLOR && !a(e);
1066
+ }
1067
+ function V(e) {
1068
+ return e === void 0 || typeof e == "number" && Number.isFinite(e);
1069
+ }
1070
+ function Rt(e) {
1071
+ if (e === void 0) return;
1072
+ if (!i(e) || e.type !== "svg" || !Array.isArray(e.paths) || e.paths.length > Ct || !i(e.viewport) || typeof e.viewport.width != "number" || typeof e.viewport.height != "number" || !Number.isFinite(e.viewport.width) || !Number.isFinite(e.viewport.height) || e.viewport.width <= 0 || e.viewport.height <= 0) return null;
1073
+ let t = [];
1074
+ for (let n of e.paths) {
1075
+ if (!i(n) || !jt.has(String(n.type))) return null;
1076
+ let e = z(n.text, Tt);
1077
+ if (!Lt(n.stroke) || !Lt(n.fill) || typeof n.strokeWidth != "number" || !Number.isFinite(n.strokeWidth) || n.strokeWidth < 0 || n.d !== void 0 && (typeof n.d != "string" || n.d.length > wt || a(n.d)) || !V(n.x) || !V(n.y) || !V(n.width) || !V(n.height) || e === null) return null;
1078
+ t.push({
1079
+ type: n.type,
1080
+ stroke: n.stroke,
1081
+ strokeWidth: n.strokeWidth,
1082
+ fill: n.fill,
1083
+ ...n.d === void 0 ? {} : { d: n.d },
1084
+ ...n.x === void 0 ? {} : { x: n.x },
1085
+ ...n.y === void 0 ? {} : { y: n.y },
1086
+ ...n.width === void 0 ? {} : { width: n.width },
1087
+ ...n.height === void 0 ? {} : { height: n.height },
1088
+ ...e === void 0 ? {} : { text: e }
1089
+ });
1090
+ }
1091
+ return {
1092
+ type: "svg",
1093
+ paths: t,
1094
+ viewport: {
1095
+ width: e.viewport.width,
1096
+ height: e.viewport.height
1097
+ }
1098
+ };
1099
+ }
1100
+ function zt(e) {
1101
+ if (e === void 0) return;
1102
+ if (!i(e)) return null;
1103
+ let t = z(e.description, yt), n = Pt(e.assignees), r = Ft(e.checklist);
1104
+ if (t === null || n === null || r === null) return null;
1105
+ let a = Array.isArray(e.files) ? e.files.filter((e) => typeof File < "u" && e instanceof File) : void 0, o = Array.isArray(e.attachmentIds) ? e.attachmentIds.map((e) => String(e).trim()).filter((e) => e.length > 0 && e.length <= F).slice(0, 20) : void 0;
1106
+ return {
1107
+ ...t === void 0 ? {} : { description: t },
1108
+ ...n === void 0 ? {} : { assignees: n },
1109
+ ...r === void 0 ? {} : { checklist: r },
1110
+ ...a && a.length > 0 ? { files: a } : {},
1111
+ ...o && o.length > 0 ? { attachmentIds: o } : {}
1112
+ };
1113
+ }
1114
+ function Bt(e) {
1115
+ if (!i(e)) return null;
1116
+ let t = {};
1117
+ if ("content" in e) {
1118
+ let n = R(e.content);
1119
+ if (!n) return null;
1120
+ t.content = n;
1121
+ }
1122
+ if ("status" in e) {
1123
+ if (!At.has(e.status)) return null;
1124
+ t.status = e.status;
1125
+ }
1126
+ if ("priority" in e) {
1127
+ if (!kt.has(e.priority)) return null;
1128
+ t.priority = e.priority;
1129
+ }
1130
+ if ("description" in e) {
1131
+ let n = z(e.description, yt);
1132
+ if (n === null) return null;
1133
+ t.description = n;
1134
+ }
1135
+ if ("assignees" in e) {
1136
+ let n = Pt(e.assignees);
1137
+ if (n === null) return null;
1138
+ t.assignees = n;
1139
+ }
1140
+ if ("checklist" in e) {
1141
+ let n = Ft(e.checklist);
1142
+ if (n === null) return null;
1143
+ t.checklist = n;
1144
+ }
1145
+ if ("textSelection" in e) {
1146
+ let n = It(e.textSelection);
1147
+ if (n === null) return null;
1148
+ t.textSelection = n;
1149
+ }
1150
+ if ("drawingData" in e) {
1151
+ let n = Rt(e.drawingData);
1152
+ if (n === null) return null;
1153
+ t.drawingData = n;
1154
+ }
1155
+ if ("attachmentIds" in e) {
1156
+ let n = e.attachmentIds;
1157
+ if (!Array.isArray(n)) return null;
1158
+ t.attachmentIds = n.map((e) => String(e).trim()).filter((e) => e.length > 0 && e.length <= F).slice(0, 20);
1159
+ }
1160
+ return Object.keys(t).length > 0 ? t : void 0;
1161
+ }
1162
+ function H(e) {
1163
+ return `${e}_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
1164
+ }
1165
+ function U(e, t) {
1166
+ return e.getState().comments.some((e) => e.id === t);
1167
+ }
1168
+ function W(e, t, n) {
1169
+ let r = e.getState().comments.filter((e) => e.id !== n.id), i = r.some((e) => e.id === t);
1170
+ e.setState({ comments: i ? r.map((e) => e.id === t ? n : e) : [...r, n] });
1171
+ }
1172
+ function Vt(e, t, n, r) {
1173
+ e.setState({ comments: e.getState().comments.map((e) => {
1174
+ if (e.id !== t) return e;
1175
+ let i = e.replies.filter((e) => e.id !== r.id), a = i.some((e) => e.id === n);
1176
+ return {
1177
+ ...e,
1178
+ replies: a ? i.map((e) => e.id === n ? r : e) : [...i, r]
1179
+ };
1180
+ }) });
1181
+ }
1182
+ function Ht(e, t, n) {
1183
+ return e.getState().comments.some((e) => e.id === t && e.replies.some((e) => e.id === n));
1184
+ }
1185
+ async function G(e) {
1186
+ try {
1187
+ let t = u(), n = await e.apiClient.getComments(t.path);
1188
+ e.setState({
1189
+ comments: n.comments,
1190
+ pagination: n.pagination
1191
+ });
1192
+ } catch (t) {
1193
+ e.handleError(t);
1194
+ }
1195
+ }
1196
+ async function Ut(e, t) {
1197
+ let n = e.getState().pagination;
1198
+ if (n && n.hasMore && !t.current) {
1199
+ t.current = !0;
1200
+ try {
1201
+ e.setState({ isLoading: !0 });
1202
+ let t = u(), r = await e.apiClient.getComments(t.path, "all", n.page + 1, n.limit), i = new Set(e.getState().comments.map((e) => e.id)), a = r.comments.filter((e) => !i.has(e.id));
1203
+ e.setState({
1204
+ comments: [...e.getState().comments, ...a],
1205
+ pagination: r.pagination,
1206
+ isLoading: !1
1207
+ });
1208
+ } catch (t) {
1209
+ e.setState({ isLoading: !1 }), e.handleError(t);
1210
+ } finally {
1211
+ t.current = !1;
1212
+ }
1213
+ }
1214
+ }
1215
+ async function Wt(e, t, n, r, i, a, o = "medium", s, c, l) {
1216
+ let d = e.getState().currentUser;
1217
+ if (!d) return;
1218
+ let f = R(i), p = Mt(a), m = It(s), h = Rt(c), g = zt(l);
1219
+ if (!Ot.has(r) || !f || !p || !kt.has(o) || m === null || h === null || g === null) {
1220
+ I(e, "invalid_comment", "Comment data is invalid");
1221
+ return;
1222
+ }
1223
+ let _ = `create:${r}:${f.slice(0, 50)}:${p.x}:${p.y}`;
1224
+ if (n.has(_)) return;
1225
+ n.add(_);
1226
+ let v = u(), y = g?.files ?? [], b = y.map((e, t) => ({
1227
+ id: H(`pending-att-${t}`),
1228
+ type: e.type.startsWith("image/") ? "screenshot" : "file",
1229
+ url: "",
1230
+ filename: e.name,
1231
+ size: e.size
1232
+ })), x = H("temp"), S = {
1233
+ id: x,
1234
+ type: r,
1235
+ content: f,
1236
+ position: p,
1237
+ status: "open",
1238
+ priority: o,
1239
+ author: d,
1240
+ userId: d.id,
1241
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1242
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1243
+ page: {
1244
+ url: v.url,
1245
+ path: v.path,
1246
+ title: v.title
1247
+ },
1248
+ description: g?.description,
1249
+ assignees: g?.assignees,
1250
+ checklist: g?.checklist,
1251
+ replies: [],
1252
+ attachments: b,
1253
+ textSelection: m,
1254
+ drawingData: h
1255
+ };
1256
+ e.setState({
1257
+ comments: [...e.getState().comments, S],
1258
+ activeComment: null,
1259
+ activeTool: null,
1260
+ isCommentModeActive: !1,
1261
+ isDrawingModeActive: !1,
1262
+ isHighlightModeActive: !1
1263
+ });
1264
+ try {
1265
+ let { files: n, ...i } = g ?? {}, a = await e.apiClient.createComment(r, f, p, v, o, m, h, i, x), s = a;
1266
+ if (y.length > 0) try {
1267
+ let t = (await Promise.all(y.map(async (t) => {
1268
+ let n = "." + (t.name.split(".").pop()?.toLowerCase() ?? ""), r = t.type.startsWith("image/") && [
1269
+ ".jpg",
1270
+ ".jpeg",
1271
+ ".png",
1272
+ ".gif",
1273
+ ".webp"
1274
+ ].includes(n);
1275
+ return e.apiClient.uploadFile(t, r ? "screenshot" : "attachment", { commentId: a.id });
1276
+ }))).map((e) => ({
1277
+ id: e.id,
1278
+ type: e.type === "screenshot" || e.type === "drawing" ? e.type : "file",
1279
+ url: e.url,
1280
+ thumbnail: e.thumbnail,
1281
+ filename: e.filename,
1282
+ size: e.size
1283
+ }));
1284
+ s = {
1285
+ ...a,
1286
+ attachments: t
1287
+ };
1288
+ } catch (t) {
1289
+ e.handleError(t), s = {
1290
+ ...a,
1291
+ attachments: a.attachments ?? []
1292
+ };
1293
+ }
1294
+ W(e, x, s), e.emit("comment:created", s), t.addActivity({
1295
+ type: "comment_created",
1296
+ threadId: s.id,
1297
+ message: "created a new comment"
1298
+ });
1299
+ } catch (n) {
1300
+ t.shouldQueueMutation(n) && t.queueMutation("createComment", [
1301
+ r,
1302
+ f,
1303
+ p,
1304
+ o,
1305
+ m,
1306
+ h,
1307
+ g ? {
1308
+ description: g.description,
1309
+ assignees: g.assignees,
1310
+ checklist: g.checklist,
1311
+ attachmentIds: g.attachmentIds
1312
+ } : void 0,
1313
+ {
1314
+ url: v.url,
1315
+ path: v.path,
1316
+ title: v.title
1317
+ }
1318
+ ], x) || (e.setState({ comments: e.getState().comments.filter((e) => e.id !== x) }), e.handleError(n));
1319
+ } finally {
1320
+ n.delete(_);
1321
+ }
1322
+ }
1323
+ async function Gt(e, t, n, r) {
1324
+ if (!L(n)) return;
1325
+ let i = Bt(r);
1326
+ if (i === null) {
1327
+ I(e, "invalid_comment_update", "Comment update data is invalid");
1328
+ return;
1329
+ }
1330
+ if (i === void 0) return;
1331
+ let a = e.getState().comments, o = a.find((e) => e.id === n);
1332
+ if (o) {
1333
+ e.setState({ comments: a.map((e) => e.id === n ? {
1334
+ ...e,
1335
+ ...i
1336
+ } : e) });
1337
+ try {
1338
+ let t = await e.apiClient.updateComment(n, i);
1339
+ e.setState({ comments: e.getState().comments.map((e) => e.id === n ? t : e) }), e.emit("comment:updated", t);
1340
+ } catch (r) {
1341
+ t.shouldQueueMutation(r) && t.queueMutation("updateComment", [n, i]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n ? o : e) }), e.handleError(r));
1342
+ }
1343
+ }
1344
+ }
1345
+ async function Kt(e, t, n) {
1346
+ if (!L(n)) return;
1347
+ let r = e.getState().comments, i = r.find((e) => e.id === n);
1348
+ if (!i) return;
1349
+ let a = e.getState().selectedComment;
1350
+ e.setState({
1351
+ comments: r.filter((e) => e.id !== n),
1352
+ selectedComment: a?.id === n ? null : a
1353
+ });
1354
+ try {
1355
+ await e.apiClient.deleteComment(n), e.emit("comment:deleted", { id: n });
1356
+ } catch (r) {
1357
+ if (!(t.shouldQueueMutation(r) && t.queueMutation("deleteComment", [n]))) {
1358
+ let t = e.getState().comments;
1359
+ e.setState({
1360
+ comments: t.some((e) => e.id === n) ? t : [...t, i],
1361
+ selectedComment: a
1362
+ }), e.handleError(r);
1363
+ }
1364
+ }
1365
+ }
1366
+ async function qt(e, t, n, r) {
1367
+ let i = e.getState().currentUser;
1368
+ if (!i || !L(n) || !U(e, n)) return;
1369
+ let a = R(r, gt);
1370
+ if (!a) {
1371
+ I(e, "invalid_reply", "Reply content is invalid");
1372
+ return;
1373
+ }
1374
+ let o = H("temp_reply"), s = {
1375
+ id: o,
1376
+ content: a,
1377
+ author: i,
1378
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
1379
+ };
1380
+ e.setState({ comments: e.getState().comments.map((e) => e.id === n ? {
1381
+ ...e,
1382
+ replies: [...e.replies, s]
1383
+ } : e) });
1384
+ try {
1385
+ Vt(e, n, o, await e.apiClient.addReply(n, a, o));
1386
+ let t = e.getState().comments.find((e) => e.id === n);
1387
+ t && e.emit("comment:updated", t);
1388
+ } catch (r) {
1389
+ t.shouldQueueMutation(r) && t.queueMutation("addReply", [n, a], o) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n ? {
1390
+ ...e,
1391
+ replies: e.replies.filter((e) => e.id !== o)
1392
+ } : e) }), e.handleError(r));
1393
+ }
1394
+ }
1395
+ async function Jt(e, t, n, r) {
1396
+ if (!L(t) || !L(n) || !Ht(e, t, n)) return;
1397
+ let i = R(r, gt);
1398
+ if (!i) {
1399
+ I(e, "invalid_reply", "Reply content is invalid");
1400
+ return;
1401
+ }
1402
+ let a = e.getState().comments, o = a.find((e) => e.id === t)?.replies.find((e) => e.id === n);
1403
+ e.setState({ comments: a.map((e) => e.id === t ? {
1404
+ ...e,
1405
+ replies: e.replies.map((e) => e.id === n ? {
1406
+ ...e,
1407
+ content: i,
1408
+ isEdited: !0
1409
+ } : e)
1410
+ } : e) });
1411
+ try {
1412
+ let r = await e.apiClient.updateReply(t, n, i);
1413
+ e.setState({ comments: e.getState().comments.map((e) => e.id === t ? {
1414
+ ...e,
1415
+ replies: e.replies.map((e) => e.id === n ? r : e)
1416
+ } : e) });
1417
+ let a = e.getState().comments.find((e) => e.id === t);
1418
+ a && e.emit("comment:updated", a);
1419
+ } catch (r) {
1420
+ e.setState({ comments: e.getState().comments.map((e) => e.id === t && o ? {
1421
+ ...e,
1422
+ replies: e.replies.map((e) => e.id === n ? o : e)
1423
+ } : e) }), e.handleError(r);
1424
+ }
1425
+ }
1426
+ async function Yt(e, t, n) {
1427
+ if (!L(t) || !L(n) || !Ht(e, t, n)) return;
1428
+ let r = e.getState().comments, i = r.find((e) => e.id === t)?.replies.find((e) => e.id === n);
1429
+ e.setState({ comments: r.map((e) => e.id === t ? {
1430
+ ...e,
1431
+ replies: e.replies.filter((e) => e.id !== n)
1432
+ } : e) });
1433
+ try {
1434
+ await e.apiClient.deleteReply(t, n);
1435
+ let r = e.getState().comments.find((e) => e.id === t);
1436
+ r && e.emit("comment:updated", r);
1437
+ } catch (r) {
1438
+ e.setState({ comments: e.getState().comments.map((e) => e.id === t && i && !e.replies.some((e) => e.id === n) ? {
1439
+ ...e,
1440
+ replies: [...e.replies, i]
1441
+ } : e) }), e.handleError(r);
1442
+ }
1443
+ }
1444
+ async function Xt(e, t, n) {
1445
+ if (!L(n) || !U(e, n)) return;
1446
+ let r = e.getState().comments, i = r.find((e) => e.id === n);
1447
+ e.setState({ comments: r.map((e) => e.id === n ? {
1448
+ ...e,
1449
+ status: "resolved"
1450
+ } : e) });
1451
+ try {
1452
+ let r = await e.apiClient.resolveComment(n);
1453
+ e.setState({ comments: e.getState().comments.map((e) => e.id === n ? r : e) }), e.emit("comment:resolved", r), e.emit("comment:updated", r), t.addActivity({
1454
+ type: "comment_resolved",
1455
+ threadId: n,
1456
+ message: "resolved a comment"
1457
+ });
1458
+ } catch (r) {
1459
+ t.shouldQueueMutation(r) && t.queueMutation("resolveComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
1460
+ }
1461
+ }
1462
+ async function Zt(e, t, n) {
1463
+ if (!L(n) || !U(e, n)) return;
1464
+ let r = e.getState().comments, i = r.find((e) => e.id === n);
1465
+ e.setState({ comments: r.map((e) => e.id === n ? {
1466
+ ...e,
1467
+ status: "open"
1468
+ } : e) });
1469
+ try {
1470
+ let t = await e.apiClient.unresolveComment(n);
1471
+ e.setState({ comments: e.getState().comments.map((e) => e.id === n ? t : e) }), e.emit("comment:updated", t);
1472
+ } catch (r) {
1473
+ t.shouldQueueMutation(r) && t.queueMutation("unresolveComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
1474
+ }
1475
+ }
1476
+ async function Qt(e, t, n) {
1477
+ if (!L(n) || !U(e, n)) return;
1478
+ let r = e.getState().comments, i = r.find((e) => e.id === n);
1479
+ e.setState({ comments: r.map((e) => e.id === n ? {
1480
+ ...e,
1481
+ status: "complete"
1482
+ } : e) });
1483
+ try {
1484
+ let r = await e.apiClient.markComplete(n);
1485
+ e.setState({ comments: e.getState().comments.map((e) => e.id === n ? r : e) }), e.emit("comment:completed", r), t.addActivity({
1486
+ type: "comment_completed",
1487
+ threadId: n,
1488
+ message: "marked a comment as complete"
1489
+ });
1490
+ } catch (r) {
1491
+ t.shouldQueueMutation(r) && t.queueMutation("completeComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
1492
+ }
1493
+ }
1494
+ async function $t(e, t, n, r) {
1495
+ if (!L(n) || typeof r != "string") return;
1496
+ let i = r.trim();
1497
+ if (!i || i.length > Dt || a(i)) return;
1498
+ let o = e.getState().comments.find((e) => e.id === n);
1499
+ if (!o) return;
1500
+ let s = (o.reactions ?? []).filter((e) => typeof e.emoji == "string" && e.emoji.length > 0 && e.emoji.length <= Dt && !a(e.emoji) && typeof e.count == "number" && Number.isInteger(e.count) && e.count >= 0 && e.count <= Et), c = s.find((e) => e.emoji === i)?.reacted, l = [...s];
1501
+ if (c) {
1502
+ let e = l.findIndex((e) => e.emoji === i), t = l[e];
1503
+ t.count <= 1 ? l.splice(e, 1) : l[e] = {
1504
+ ...t,
1505
+ count: t.count - 1,
1506
+ reacted: !1
1507
+ };
1508
+ } else {
1509
+ let e = l.findIndex((e) => e.emoji === i), t = e === -1 ? void 0 : l[e];
1510
+ t ? l[e] = {
1511
+ ...t,
1512
+ count: Math.min(t.count + 1, Et),
1513
+ reacted: !0
1514
+ } : l.push({
1515
+ emoji: i,
1516
+ count: 1,
1517
+ reacted: !0
1518
+ });
1519
+ }
1520
+ let u = e.getState().comments;
1521
+ e.setState({ comments: u.map((e) => e.id === n ? {
1522
+ ...e,
1523
+ reactions: l
1524
+ } : e) });
1525
+ try {
1526
+ c ? await e.apiClient.removeReaction(n, i) : await e.apiClient.addReaction(n, i);
1527
+ let t = e.getState().comments.find((e) => e.id === n);
1528
+ t && e.emit("comment:reaction", {
1529
+ commentId: n,
1530
+ emoji: i,
1531
+ comment: t
1532
+ });
1533
+ } catch (r) {
1534
+ t.shouldQueueMutation(r) && t.queueMutation("reactToComment", [
1535
+ n,
1536
+ i,
1537
+ c ? "remove" : "add"
1538
+ ]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n ? {
1539
+ ...e,
1540
+ reactions: s
1541
+ } : e) }), e.handleError(r));
1542
+ }
1543
+ }
1544
+ async function en(e, t, n, r, i) {
1545
+ if (!L(n) || !U(e, n)) return;
1546
+ let a = Mt({
1547
+ x: r,
1548
+ y: i
1549
+ });
1550
+ if (!a) {
1551
+ I(e, "invalid_position", "Comment position is invalid");
1552
+ return;
1553
+ }
1554
+ let o = e.getState().comments, s = o.find((e) => e.id === n);
1555
+ e.setState({ comments: o.map((e) => e.id === n ? {
1556
+ ...e,
1557
+ position: a
1558
+ } : e) });
1559
+ try {
1560
+ let t = await e.apiClient.updatePosition(n, a);
1561
+ e.setState({ comments: e.getState().comments.map((e) => e.id === n ? t : e) }), e.emit("comment:position", {
1562
+ commentId: n,
1563
+ position: a
1564
+ });
1565
+ } catch (r) {
1566
+ t.shouldQueueMutation(r) && t.queueMutation("updatePosition", [n, a]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && s ? {
1567
+ ...e,
1568
+ position: s.position
1569
+ } : e) }), e.handleError(r));
1570
+ }
1571
+ }
1572
+ function tn(e, t) {
1573
+ e.setState({ selectedComment: t });
1574
+ }
1575
+ async function nn(e, t, n, r, i) {
1576
+ let a = e.getState().currentUser;
1577
+ if (!a) return;
1578
+ let o = R(i), s = It(r);
1579
+ if (!o || s == null) {
1580
+ I(e, "invalid_highlight", "Highlight data is invalid");
1581
+ return;
1582
+ }
1583
+ let c = `highlight:${s.xpath}:${s.startOffset}:${o.slice(0, 50)}`;
1584
+ if (n.has(c)) return;
1585
+ n.add(c);
1586
+ let l = u(), d = H("temp"), f = {
1587
+ id: d,
1588
+ type: "highlight",
1589
+ content: o,
1590
+ position: {
1591
+ x: 0,
1592
+ y: 0
1593
+ },
1594
+ status: "open",
1595
+ priority: "medium",
1596
+ author: a,
1597
+ userId: a.id,
1598
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1599
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1600
+ page: {
1601
+ url: l.url,
1602
+ path: l.path,
1603
+ title: l.title
1604
+ },
1605
+ replies: [],
1606
+ attachments: [],
1607
+ textSelection: s
1608
+ };
1609
+ e.setState({ comments: [...e.getState().comments, f] });
1610
+ try {
1611
+ let t = await e.apiClient.createHighlight(o, s, l, "medium", d);
1612
+ W(e, d, t), e.emit("comment:created", t);
1613
+ } catch (n) {
1614
+ t.shouldQueueMutation(n) && t.queueMutation("createHighlight", [
1615
+ o,
1616
+ s,
1617
+ {
1618
+ url: l.url,
1619
+ path: l.path,
1620
+ title: l.title
1621
+ }
1622
+ ], d) || (e.setState({ comments: e.getState().comments.filter((e) => e.id !== d) }), e.handleError(n));
1623
+ } finally {
1624
+ n.delete(c);
1625
+ }
1626
+ }
1627
+ async function rn(e, t, n, r, i, a) {
1628
+ let o = e.getState().currentUser;
1629
+ if (!o) return;
1630
+ let s = R(a), c = Mt(i), l = Rt(r);
1631
+ if (!s || !c || l == null) {
1632
+ I(e, "invalid_drawing", "Drawing comment data is invalid");
1633
+ return;
1634
+ }
1635
+ let d = `drawing:${c.x}:${c.y}:${s.slice(0, 50)}`;
1636
+ if (n.has(d)) return;
1637
+ n.add(d);
1638
+ let f = u(), p = H("temp"), m = {
1639
+ id: p,
1640
+ type: "drawing",
1641
+ content: s,
1642
+ position: c,
1643
+ status: "open",
1644
+ priority: "medium",
1645
+ author: o,
1646
+ userId: o.id,
1647
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1648
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1649
+ page: {
1650
+ url: f.url,
1651
+ path: f.path,
1652
+ title: f.title
1653
+ },
1654
+ replies: [],
1655
+ attachments: [],
1656
+ drawingData: l
1657
+ };
1658
+ e.setState({ comments: [...e.getState().comments, m] });
1659
+ try {
1660
+ let t = await e.apiClient.createDrawing(s, l, c, f, p);
1661
+ W(e, p, t), e.emit("comment:created", t);
1662
+ } catch (n) {
1663
+ t.shouldQueueMutation(n) && t.queueMutation("createDrawing", [
1664
+ s,
1665
+ l,
1666
+ c,
1667
+ {
1668
+ url: f.url,
1669
+ path: f.path,
1670
+ title: f.title
1671
+ }
1672
+ ], p) || (e.setState({ comments: e.getState().comments.filter((e) => e.id !== p) }), e.handleError(n));
1673
+ } finally {
1674
+ n.delete(d);
1675
+ }
1676
+ }
1677
+ var an = {
1678
+ c: "comment",
1679
+ e: "select",
1680
+ d: "draw",
1681
+ h: "highlight",
1682
+ s: "screenshot"
1683
+ };
1684
+ function on(e) {
1685
+ return typeof e.composedPath == "function" ? e.composedPath() : e.target ? [e.target] : [];
1686
+ }
1687
+ function sn(e) {
1688
+ return typeof Element < "u" && e instanceof Element;
1689
+ }
1690
+ function cn(e) {
1691
+ if (!sn(e)) return !1;
1692
+ let t = e.tagName.toLowerCase();
1693
+ return t === "input" || t === "textarea" || t === "select" || e.isContentEditable || e.getAttribute("role") === "textbox";
1694
+ }
1695
+ function ln(e) {
1696
+ let t = e.activeElement;
1697
+ for (; t?.shadowRoot?.activeElement;) t = t.shadowRoot.activeElement;
1698
+ return t;
1699
+ }
1700
+ function un(e) {
1701
+ return on(e).some(cn) ? !0 : typeof document > "u" ? !1 : cn(ln(document));
1702
+ }
1703
+ function dn(e) {
1704
+ return on(e).some((e) => sn(e) && (e.hasAttribute("data-commentkit") || e.hasAttribute("data-commentkit-ui") || e.hasAttribute("data-commentkit-host")));
1705
+ }
1706
+ function fn(e) {
1707
+ return (e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === "K" || e.key === "k" || e.code === "KeyK");
1708
+ }
1709
+ function pn(e) {
1710
+ let t = e.key.toLowerCase(), n = e.code.startsWith("Key") ? e.code.slice(3).toLowerCase() : "";
1711
+ return an[t] ?? an[n] ?? null;
1712
+ }
1713
+ function K(e) {
1714
+ e.preventDefault(), e.stopPropagation();
1715
+ }
1716
+ function mn(e, t) {
1717
+ if (e.isLoginModalVisible) t.toggleLoginModal();
1718
+ else if (e.isShortcutsOverlayVisible) t.toggleShortcutsOverlay();
1719
+ else if (e.activeComment) t.setState({ activeComment: null });
1720
+ else if (e.selectedComment) t.selectComment(null);
1721
+ else if (e.activeTool) t.setTool(null);
1722
+ else if (e.isSidebarVisible) t.toggleSidebar();
1723
+ else if (e.isOverlayVisible) t.toggleOverlay();
1724
+ else return !1;
1725
+ return !0;
1726
+ }
1727
+ function hn(e, t) {
1728
+ e.isAuthenticated ? t.toggleOverlay() : t.toggleLoginModal();
1729
+ }
1730
+ function gn(e, t, n) {
1731
+ if (e.defaultPrevented || e.repeat || e.isComposing) return;
1732
+ let r = un(e), i = dn(e);
1733
+ if (fn(e)) {
1734
+ if (r) return;
1735
+ K(e), hn(t, n);
1736
+ } else if (e.key === "Escape") {
1737
+ if (r && !i) return;
1738
+ mn(t, n) && K(e);
1739
+ } else if (t.isAuthenticated && (t.isOverlayVisible || t.activeTool !== null) && !r && !e.ctrlKey && !e.metaKey && !e.altKey) {
1740
+ if (e.key === "?") {
1741
+ K(e), n.toggleShortcutsOverlay();
1742
+ return;
1743
+ }
1744
+ let r = pn(e);
1745
+ r && (K(e), n.setTool(t.activeTool === r ? null : r));
1746
+ }
1747
+ }
1748
+ function q(e) {
1749
+ return Object.freeze(e);
1750
+ }
1751
+ var _n = Object.freeze({
1752
+ auth: q([
1753
+ "isAuthenticated",
1754
+ "currentUser",
1755
+ "project",
1756
+ "isLoginModalVisible",
1757
+ "otpStep",
1758
+ "otpEmail"
1759
+ ]),
1760
+ ui: q([
1761
+ "isOverlayVisible",
1762
+ "isSidebarVisible",
1763
+ "isShortcutsOverlayVisible",
1764
+ "activeTool",
1765
+ "isCommentModeActive",
1766
+ "isDrawingModeActive",
1767
+ "isHighlightModeActive",
1768
+ "isScreenshotModeActive",
1769
+ "selectedComment",
1770
+ "activeComment",
1771
+ "activeDrawing",
1772
+ "activeScreenshot",
1773
+ "panelView",
1774
+ "activities",
1775
+ "isLoading",
1776
+ "error"
1777
+ ]),
1778
+ comments: q([
1779
+ "comments",
1780
+ "pagination",
1781
+ "seenThreadIds"
1782
+ ]),
1783
+ realtime: q([
1784
+ "onlineUsers",
1785
+ "connectionStatus",
1786
+ "pendingMutations",
1787
+ "isOnline"
1788
+ ])
1789
+ });
1790
+ function vn() {
1791
+ return typeof navigator < "u" && typeof navigator.onLine == "boolean" ? navigator.onLine : !0;
1792
+ }
1793
+ var yn = 2e3;
1794
+ function bn() {
1795
+ return {
1796
+ isAuthenticated: !1,
1797
+ isOverlayVisible: !0,
1798
+ isCommentModeActive: !1,
1799
+ isDrawingModeActive: !1,
1800
+ isHighlightModeActive: !1,
1801
+ isScreenshotModeActive: !1,
1802
+ isSidebarVisible: !1,
1803
+ isLoginModalVisible: !1,
1804
+ isShortcutsOverlayVisible: !1,
1805
+ currentUser: null,
1806
+ project: null,
1807
+ comments: [],
1808
+ activeTool: null,
1809
+ selectedComment: null,
1810
+ activeComment: null,
1811
+ activeDrawing: null,
1812
+ activeScreenshot: null,
1813
+ onlineUsers: [],
1814
+ connectionStatus: "disconnected",
1815
+ activities: [],
1816
+ seenThreadIds: /* @__PURE__ */ new Set(),
1817
+ panelView: "list",
1818
+ isLoading: !1,
1819
+ error: null,
1820
+ otpStep: "idle",
1821
+ otpEmail: null,
1822
+ pagination: null,
1823
+ pendingMutations: [],
1824
+ isOnline: vn()
1825
+ };
1826
+ }
1827
+ var xn = M.PENDING_MUTATIONS, Sn = M.RETRY_DELAY, J = M.ID, Cn = M.CONTENT, wn = M.REPLY_CONTENT, Tn = M.SELECTOR, En = M.EMOJI, Dn = /* @__PURE__ */ new Set([
1828
+ "createComment",
1829
+ "createHighlight",
1830
+ "createDrawing",
1831
+ "updateComment",
1832
+ "deleteComment",
1833
+ "resolveComment",
1834
+ "unresolveComment",
1835
+ "completeComment",
1836
+ "addReply",
1837
+ "reactToComment",
1838
+ "updatePosition"
1839
+ ]), On = /* @__PURE__ */ new Set([
1840
+ "pin",
1841
+ "highlight",
1842
+ "drawing"
1843
+ ]), kn = /* @__PURE__ */ new Set([
1844
+ "low",
1845
+ "medium",
1846
+ "high",
1847
+ "urgent"
1848
+ ]), An = /* @__PURE__ */ new Set(["add", "remove"]);
1849
+ function jn(n) {
1850
+ return i(n) && e(n.x) && e(n.y) && t(n.element, Tn) && t(n.xpath, Tn);
1851
+ }
1852
+ function Mn(e) {
1853
+ return typeof e == "string" && e.length <= M.PAGE && !r(e);
1854
+ }
1855
+ function Nn(e) {
1856
+ return e === void 0 || i(e) && Mn(e.url) && Mn(e.path) && Mn(e.title);
1857
+ }
1858
+ function Pn(e) {
1859
+ return typeof e == "string" && Dn.has(e);
1860
+ }
1861
+ function Fn(e) {
1862
+ return Number.isInteger(e) && Number(e) >= 0;
1863
+ }
1864
+ function In(e) {
1865
+ return Fn(e) ? Math.min(e, 5) : 0;
1866
+ }
1867
+ function Ln(e) {
1868
+ return e.isNetworkError() || e.code === 408 || e.isRateLimitError();
1869
+ }
1870
+ function Rn(e) {
1871
+ return e instanceof D ? Ln(e) : !0;
1872
+ }
1873
+ function zn(e) {
1874
+ return e instanceof D ? {
1875
+ error: e.error,
1876
+ message: e.message,
1877
+ code: e.code,
1878
+ ...e.details ? { details: e.details } : {}
1879
+ } : {
1880
+ error: "retry_failed",
1881
+ message: "Operation failed after maximum retries",
1882
+ code: 0
1883
+ };
1884
+ }
1885
+ function Bn(e = Date.now()) {
1886
+ return `mutation_${e}_${typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : Math.random().toString(36).slice(2, 12)}`;
1887
+ }
1888
+ function Vn(e) {
1889
+ return Array.isArray(e) ? e.map((e) => Vn(e)) : i(e) ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Vn(t)])) : e;
1890
+ }
1891
+ function Hn(e) {
1892
+ try {
1893
+ if (typeof structuredClone == "function") return structuredClone(e);
1894
+ } catch {}
1895
+ return Vn(e);
1896
+ }
1897
+ function Un(e, t) {
1898
+ switch (e) {
1899
+ case "createComment": {
1900
+ let [e, n, r, a, s, c, l, u] = t;
1901
+ return t.length >= 3 && t.length <= 8 && On.has(String(e)) && o(n, Cn) && jn(r) && (a === void 0 || kn.has(String(a))) && (s === void 0 || i(s)) && (c === void 0 || i(c)) && (l === void 0 || i(l)) && Nn(u);
1902
+ }
1903
+ case "createHighlight": {
1904
+ let [e, n, r] = t;
1905
+ return t.length >= 2 && t.length <= 3 && o(e, Cn) && i(n) && Nn(r);
1906
+ }
1907
+ case "createDrawing": {
1908
+ let [e, n, r, a] = t;
1909
+ return t.length >= 3 && t.length <= 4 && o(e, Cn) && i(n) && jn(r) && Nn(a);
1910
+ }
1911
+ case "updateComment": return t.length === 2 && n(t[0], J) && i(t[1]);
1912
+ case "deleteComment":
1913
+ case "resolveComment":
1914
+ case "unresolveComment":
1915
+ case "completeComment": return t.length === 1 && n(t[0], J);
1916
+ case "addReply": return t.length === 2 && n(t[0], J) && o(t[1], wn);
1917
+ case "reactToComment": return t.length >= 2 && t.length <= 3 && n(t[0], J) && n(t[1], En) && (t[2] === void 0 || An.has(String(t[2])));
1918
+ case "updatePosition": return t.length === 2 && n(t[0], J) && jn(t[1]);
1919
+ }
1920
+ }
1921
+ function Wn(e) {
1922
+ return i(e) ? n(e.id, J) ? Pn(e.type) ? Array.isArray(e.args) ? Number.isFinite(e.timestamp) ? Fn(e.retries) ? t(e.tempId, J) ? Un(e.type, e.args) ? null : "Queued mutation args are invalid" : "Queued mutation has an invalid temp id" : "Queued mutation has an invalid retry count" : "Queued mutation has an invalid timestamp" : "Queued mutation args must be an array" : "Queued mutation has an unsupported type" : "Queued mutation has an invalid id" : "Queued mutation must be an object";
1923
+ }
1924
+ function Gn(e) {
1925
+ let t = Wn(e);
1926
+ if (t) throw new D("invalid_mutation", t, 400);
1927
+ }
1928
+ var Kn = "commentkit:offline-queue:";
1929
+ function qn() {
1930
+ try {
1931
+ return typeof localStorage > "u" ? null : localStorage;
1932
+ } catch {
1933
+ return null;
1934
+ }
1935
+ }
1936
+ function Jn(e) {
1937
+ return `${Kn}${e}`;
1938
+ }
1939
+ function Yn(e, t) {
1940
+ if (!e) return;
1941
+ let n = qn();
1942
+ if (n) try {
1943
+ t.length === 0 ? n.removeItem(Jn(e)) : n.setItem(Jn(e), JSON.stringify(t));
1944
+ } catch {}
1945
+ }
1946
+ function Xn(e) {
1947
+ if (!e) return [];
1948
+ let t = qn();
1949
+ if (!t) return [];
1950
+ try {
1951
+ let n = t.getItem(Jn(e));
1952
+ if (!n) return [];
1953
+ let r = JSON.parse(n);
1954
+ if (!Array.isArray(r)) return [];
1955
+ let i = [];
1956
+ for (let e of r) {
1957
+ if (i.length >= xn) break;
1958
+ Wn(e) === null && i.push(e);
1959
+ }
1960
+ return i;
1961
+ } catch {
1962
+ return [];
1963
+ }
1964
+ }
1965
+ function Y(e) {
1966
+ Promise.resolve().then(e);
1967
+ }
1968
+ function Zn(e, t) {
1969
+ return e.type === t.type && (t.type === "updatePosition" || t.type === "updateComment") && e.args[0] === t.args[0];
1970
+ }
1971
+ function Qn(e, t) {
1972
+ return t.type === "updateComment" && i(e.args[1]) ? {
1973
+ ...t,
1974
+ args: [t.args[0], {
1975
+ ...e.args[1],
1976
+ ...t.args[1]
1977
+ }]
1978
+ } : t;
1979
+ }
1980
+ function $n(e, t) {
1981
+ let n = e.findIndex((e) => Zn(e, t));
1982
+ if (n !== -1) {
1983
+ let r = [...e];
1984
+ return r[n] = Qn(r[n], t), r;
1985
+ }
1986
+ return e.length >= xn ? null : [...e, t];
1987
+ }
1988
+ function X(e, t, n) {
1989
+ e.emit("offline:failed", {
1990
+ id: t,
1991
+ error: n
1992
+ });
1993
+ }
1994
+ function er(e, t) {
1995
+ return !e.isOnline || t instanceof D && Ln(t);
1996
+ }
1997
+ function tr(e, n, r, i, a) {
1998
+ let o = Bn();
1999
+ if (!Pn(r) || !Array.isArray(i) || !Un(r, i) || !t(a, J)) return X(e, o, {
2000
+ error: "invalid_mutation",
2001
+ message: "Queued mutation args are invalid",
2002
+ code: 400
2003
+ }), !1;
2004
+ let s = {
2005
+ id: o,
2006
+ type: r,
2007
+ args: Hn(i),
2008
+ timestamp: Date.now(),
2009
+ retries: 0,
2010
+ ...a === void 0 ? {} : { tempId: a }
2011
+ }, c = $n(e.getState().pendingMutations, s);
2012
+ return c ? (e.setState({ pendingMutations: c }), e.emit("offline:queued", s), e.getState().isOnline && Y(n), !0) : (X(e, o, {
2013
+ error: "queue_full",
2014
+ message: "Offline mutation queue is full",
2015
+ code: 0
2016
+ }), !1);
2017
+ }
2018
+ function nr(e, t, n) {
2019
+ if (t.current || e.getState().pendingMutations.length === 0) return;
2020
+ let r = e.getState().pendingMutations[0];
2021
+ if (!r) return;
2022
+ let i = In(r.retries), a = Math.min(Sn, yn * 2 ** i);
2023
+ t.current = setTimeout(() => {
2024
+ t.current = null, n();
2025
+ }, a);
2026
+ }
2027
+ async function rr(e, t, r, i) {
2028
+ let a = e.getState();
2029
+ if (!a.isOnline || a.pendingMutations.length === 0 || !a.isAuthenticated || t.current) return;
2030
+ t.current = !0;
2031
+ let o = e.getState().pendingMutations[0];
2032
+ if (!o) {
2033
+ t.current = !1;
2034
+ return;
2035
+ }
2036
+ let s = Wn(o);
2037
+ if (s) {
2038
+ let i = e.getState().pendingMutations.filter((e) => e !== o);
2039
+ e.setState({ pendingMutations: i }), X(e, n(o.id, J) ? o.id : "invalid", {
2040
+ error: "invalid_mutation",
2041
+ message: s,
2042
+ code: 400
2043
+ }), i.length > 0 && Y(r), t.current = !1;
2044
+ return;
2045
+ }
2046
+ e.emit("offline:retrying", {
2047
+ id: o.id,
2048
+ attempt: o.retries + 1
2049
+ });
2050
+ let c = i ?? ((t) => ar(e, t));
2051
+ try {
2052
+ await c(o);
2053
+ let n = e.getState().pendingMutations.filter((e) => e.id !== o.id);
2054
+ e.setState({ pendingMutations: n }), e.emit("offline:completed", { id: o.id }), n.length > 0 ? Y(r) : t.reconcileAfterDrain && (t.reconcileAfterDrain = !1, G(e));
2055
+ } catch (n) {
2056
+ let i = {
2057
+ ...o,
2058
+ retries: In(o.retries) + 1
2059
+ };
2060
+ if (Rn(n) && i.retries < 5) {
2061
+ let t = e.getState().pendingMutations.map((e) => e.id === o.id ? i : e);
2062
+ e.setState({ pendingMutations: t }), Y(r);
2063
+ } else {
2064
+ let i = e.getState().pendingMutations.filter((e) => e.id !== o.id);
2065
+ e.setState({ pendingMutations: i }), X(e, o.id, zn(n)), i.length > 0 ? (t.reconcileAfterDrain = !0, Y(r)) : (t.reconcileAfterDrain = !1, G(e));
2066
+ }
2067
+ } finally {
2068
+ t.current = !1;
2069
+ }
2070
+ }
2071
+ function ir(e, t, n) {
2072
+ let r = !1, i = e.getState().pendingMutations.map((e) => e.type !== "createComment" && e.args[0] === t ? (r = !0, {
2073
+ ...e,
2074
+ args: [n, ...e.args.slice(1)]
2075
+ }) : e);
2076
+ r && e.setState({ pendingMutations: i });
2077
+ }
2078
+ async function ar(e, t) {
2079
+ switch (Gn(t), t.type) {
2080
+ case "createComment": {
2081
+ let [n, r, i, a, o, s, c, l] = t.args, d = await e.apiClient.createComment(n, r, i, l ?? u(), a, o, s, c, t.tempId);
2082
+ d && t.tempId && (W(e, t.tempId, d), ir(e, t.tempId, d.id));
2083
+ break;
2084
+ }
2085
+ case "createHighlight": {
2086
+ let [n, r, i] = t.args, a = await e.apiClient.createHighlight(n, r, i ?? u(), "medium", t.tempId);
2087
+ a && t.tempId && (W(e, t.tempId, a), ir(e, t.tempId, a.id));
2088
+ break;
2089
+ }
2090
+ case "createDrawing": {
2091
+ let [n, r, i, a] = t.args, o = await e.apiClient.createDrawing(n, r, i, a ?? u(), t.tempId);
2092
+ o && t.tempId && (W(e, t.tempId, o), ir(e, t.tempId, o.id));
2093
+ break;
2094
+ }
2095
+ case "updateComment": {
2096
+ let [n, r] = t.args;
2097
+ await e.apiClient.updateComment(n, r);
2098
+ break;
2099
+ }
2100
+ case "deleteComment": {
2101
+ let [n] = t.args;
2102
+ await e.apiClient.deleteComment(n);
2103
+ break;
2104
+ }
2105
+ case "resolveComment": {
2106
+ let [n] = t.args;
2107
+ await e.apiClient.resolveComment(n);
2108
+ break;
2109
+ }
2110
+ case "unresolveComment": {
2111
+ let [n] = t.args;
2112
+ await e.apiClient.unresolveComment(n);
2113
+ break;
2114
+ }
2115
+ case "completeComment": {
2116
+ let [n] = t.args;
2117
+ await e.apiClient.markComplete(n);
2118
+ break;
2119
+ }
2120
+ case "addReply": {
2121
+ let [n, r] = t.args, i = await e.apiClient.addReply(n, r, t.tempId);
2122
+ i && t.tempId && Vt(e, n, t.tempId, i);
2123
+ break;
2124
+ }
2125
+ case "reactToComment": {
2126
+ let [n, r, i] = t.args, a;
2127
+ a = i === "add" || i === "remove" ? i === "remove" : e.getState().comments.find((e) => e.id === n)?.reactions?.find((e) => e.emoji === r)?.reacted === !0, a ? await e.apiClient.removeReaction(n, r) : await e.apiClient.addReaction(n, r);
2128
+ break;
2129
+ }
2130
+ case "updatePosition": {
2131
+ let [n, r] = t.args;
2132
+ await e.apiClient.updatePosition(n, r);
2133
+ break;
2134
+ }
2135
+ }
2136
+ }
2137
+ var or = 1e4, sr = 2048, cr = 10485760, lr = 20971520, Z = 16384, ur = 32e6, dr = 10, fr = 10485760, pr = 26214400, mr = /* @__PURE__ */ new Set([
2138
+ "jpg",
2139
+ "jpeg",
2140
+ "png",
2141
+ "gif",
2142
+ "webp",
2143
+ "pdf",
2144
+ "doc",
2145
+ "docx",
2146
+ "txt",
2147
+ "csv"
2148
+ ]), hr = 15e3, gr = 1e4, _r = {
2149
+ "image/gif": "gif",
2150
+ "image/jpeg": "jpg",
2151
+ "image/png": "png",
2152
+ "image/webp": "webp"
2153
+ };
2154
+ function Q(e, t) {
2155
+ let n = Error(t);
2156
+ return n.error = e, n.code = 400, n;
2157
+ }
2158
+ function vr(e) {
2159
+ if (typeof e != "string") throw Q("invalid_position", "Invalid position");
2160
+ let t = e.trim();
2161
+ if (!t || t.length > sr || r(t)) throw Q("invalid_position", "Invalid position");
2162
+ return t;
2163
+ }
2164
+ function yr(t) {
2165
+ if (!i(t) || !e(t.x) || !e(t.y)) throw Q("invalid_position", "Invalid position");
2166
+ return {
2167
+ x: t.x,
2168
+ y: t.y,
2169
+ ...t.element === void 0 ? {} : { element: vr(t.element) },
2170
+ ...t.xpath === void 0 ? {} : { xpath: vr(t.xpath) }
2171
+ };
2172
+ }
2173
+ function br(e) {
2174
+ if (typeof e != "string") throw Q("invalid_content", "Screenshot comment is required");
2175
+ let t = e.trim();
2176
+ if (!t || t.length > or || r(t)) throw Q("invalid_content", "Screenshot comment is required");
2177
+ return t;
2178
+ }
2179
+ function xr(e) {
2180
+ return typeof Blob < "u" && e instanceof Blob;
2181
+ }
2182
+ function Sr(e) {
2183
+ return typeof File < "u" && e instanceof File;
2184
+ }
2185
+ function Cr(e) {
2186
+ return typeof HTMLElement < "u" && e instanceof HTMLElement;
2187
+ }
2188
+ function wr(e) {
2189
+ if (e !== void 0) {
2190
+ if (!Cr(e)) throw Q("invalid_element", "Invalid screenshot target");
2191
+ return e;
2192
+ }
2193
+ if (typeof document > "u" || !document.body) throw Q("invalid_element", "A browser document is required to capture screenshots");
2194
+ return document.body;
2195
+ }
2196
+ function Tr(e) {
2197
+ let t = /^data:(image\/(?:png|jpeg|gif|webp));base64,/i.exec(e)?.[1];
2198
+ return t ? t.toLowerCase() : null;
2199
+ }
2200
+ function Er(e) {
2201
+ if (!i(e)) throw Q("invalid_screenshot", "Invalid screenshot result");
2202
+ let t = typeof e.dataUrl == "string" ? e.dataUrl.trim() : "", n = e.blob, r = e.dimensions;
2203
+ if (!Tr(t) || t.length > lr || !xr(n) || n.size <= 0 || n.size > cr || n.type && !Object.prototype.hasOwnProperty.call(_r, n.type)) throw Q("invalid_screenshot", "Invalid screenshot result");
2204
+ if (!i(r)) throw Q("invalid_screenshot", "Invalid screenshot dimensions");
2205
+ let { width: a, height: o } = r;
2206
+ if (typeof a != "number" || typeof o != "number" || !Number.isFinite(a) || !Number.isFinite(o) || a <= 0 || o <= 0 || a > Z || o > Z) throw Q("invalid_screenshot", "Invalid screenshot dimensions");
2207
+ return {
2208
+ dataUrl: t,
2209
+ blob: n,
2210
+ dimensions: {
2211
+ width: a,
2212
+ height: o
2213
+ }
2214
+ };
2215
+ }
2216
+ function Dr(e) {
2217
+ let t = Tr(e.dataUrl);
2218
+ return e.blob.type || t;
2219
+ }
2220
+ function Or(e) {
2221
+ return `screenshot.${_r[Dr(e)]}`;
2222
+ }
2223
+ function kr(e, t, n) {
2224
+ let r = null;
2225
+ return new Promise((i, a) => {
2226
+ r = setTimeout(() => {
2227
+ r = null, a(Error(n));
2228
+ }, t), e.then((e) => {
2229
+ r && clearTimeout(r), r = null, i(e);
2230
+ }, (e) => {
2231
+ r && clearTimeout(r), r = null, a(e);
2232
+ });
2233
+ });
2234
+ }
2235
+ function Ar(e) {
2236
+ return new Promise((t, n) => {
2237
+ let r = !1, i = setTimeout(() => {
2238
+ r = !0, n(/* @__PURE__ */ Error("toBlob timed out"));
2239
+ }, gr);
2240
+ e.toBlob((e) => {
2241
+ r || (r = !0, clearTimeout(i), e ? t(e) : n(/* @__PURE__ */ Error("toBlob returned null")));
2242
+ }, "image/png");
2243
+ });
2244
+ }
2245
+ function jr(e) {
2246
+ let t = e.lastIndexOf(".");
2247
+ return t >= 0 ? e.slice(t + 1).toLowerCase() : "";
2248
+ }
2249
+ function Mr(e) {
2250
+ if (!Array.isArray(e)) throw Q("invalid_files", "Files must be an array");
2251
+ if (e.length > dr) throw Q("too_many_files", `Cannot upload more than ${dr} files at once`);
2252
+ let t = 0;
2253
+ for (let n of e) {
2254
+ if (!Sr(n)) throw Q("invalid_files", "Invalid file upload");
2255
+ if (n.size > fr) throw Q("file_too_large", `File "${n.name}" exceeds the ${fr / 1024 / 1024}MB limit`);
2256
+ if (t += n.size, t > pr) throw Q("upload_too_large", `Total upload size exceeds the ${pr / 1024 / 1024}MB limit`);
2257
+ if (r(n.name) || n.name.includes("/") || n.name.includes("\\")) throw Q("invalid_filename", "Filename contains invalid characters");
2258
+ if (s(n.name)) throw Q("invalid_file_type", `File type ".${jr(n.name)}" is not allowed`);
2259
+ if (!mr.has(jr(n.name))) throw Q("invalid_file_type", `File type ".${jr(n.name)}" is not supported. Allowed: ${[...mr].map((e) => `.${e}`).join(", ")}`);
2260
+ }
2261
+ return e;
2262
+ }
2263
+ function Nr(e) {
2264
+ try {
2265
+ return e.matches?.("input[type=\"password\"],[data-commentkit-redact],[data-html2canvas-ignore],[autocomplete*=\"cc-\"],[autocomplete=\"current-password\"],[autocomplete=\"new-password\"]") ?? !1;
2266
+ } catch {
2267
+ return !1;
2268
+ }
2269
+ }
2270
+ async function Pr(e, t, n, r = {}) {
2271
+ if (e.isLocalDemo) return null;
2272
+ try {
2273
+ let e = wr(n);
2274
+ if (t) return Er(await t(e));
2275
+ let r;
2276
+ try {
2277
+ r = (await import("html2canvas")).default;
2278
+ } catch {
2279
+ /* v8 ignore next 3 -- dynamic import() can't be intercepted by vi.mock */
2280
+ throw Error("Screenshot requires either a custom screenshotProvider in config or html2canvas installed. Install html2canvas: npm install html2canvas — or provide config.screenshotProvider.");
2281
+ }
2282
+ let i = await kr(r(e, {
2283
+ useCORS: !0,
2284
+ allowTaint: !1,
2285
+ scale: 2,
2286
+ logging: !1,
2287
+ ignoreElements: Nr
2288
+ }), hr, "html2canvas timed out after 15s");
2289
+ if (i.width > Z || i.height > Z || i.width * i.height > ur) throw Q("screenshot_too_large", "Captured area is too large to screenshot");
2290
+ return Er({
2291
+ dataUrl: i.toDataURL("image/png"),
2292
+ blob: await Ar(i),
2293
+ dimensions: {
2294
+ width: i.width,
2295
+ height: i.height
2296
+ }
2297
+ });
2298
+ } catch (t) {
2299
+ return r.reportErrors !== !1 && (console.error("[CommentKit] Screenshot failed:", t), e.handleError({
2300
+ error: "screenshot_failed",
2301
+ message: "Failed to capture screenshot",
2302
+ code: 500
2303
+ })), null;
2304
+ }
2305
+ }
2306
+ async function Fr(e, t, n, r) {
2307
+ try {
2308
+ let i = Er(t), a = br(n), o = yr(r);
2309
+ e.setState({ isLoading: !0 });
2310
+ let s = new File([i.blob], Or(i), { type: Dr(i) }), c = u(), l = await e.apiClient.uploadScreenshot(s, {
2311
+ content: a,
2312
+ position: o,
2313
+ page: c
2314
+ });
2315
+ return e.setState({
2316
+ comments: [...e.getState().comments, l],
2317
+ isLoading: !1,
2318
+ activeScreenshot: null
2319
+ }), e.emit("comment:created", l), l;
2320
+ } catch (t) {
2321
+ return e.setState({ isLoading: !1 }), e.handleError(t), null;
2322
+ }
2323
+ }
2324
+ async function Ir(e, t, n) {
2325
+ try {
2326
+ let r = Mr(t);
2327
+ return r.length === 0 ? [] : await e.apiClient.uploadFiles(r, n);
2328
+ } catch (t) {
2329
+ return e.handleError(t), [];
2330
+ }
2331
+ }
2332
+ var $ = null;
2333
+ async function Lr() {
2334
+ return $ || ($ = await import("./realtime-BG_t_ze7.js"), $);
2335
+ }
2336
+ var Rr = typeof window < "u", zr = /* @__PURE__ */ new Set([
2337
+ "list",
2338
+ "detail",
2339
+ "settings",
2340
+ "activity",
2341
+ "dev-export"
2342
+ ]), Br = /* @__PURE__ */ new Set([
2343
+ "comment",
2344
+ "draw",
2345
+ "highlight",
2346
+ "screenshot",
2347
+ "select",
2348
+ null
2349
+ ]), Vr = 256, Hr = "0.6.9";
2350
+ function Ur(e) {
2351
+ let t = e.trim().match(/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/);
2352
+ return t ? [
2353
+ Number(t[1]),
2354
+ Number(t[2] ?? 0),
2355
+ Number(t[3] ?? 0)
2356
+ ] : null;
2357
+ }
2358
+ function Wr(e) {
2359
+ return /^v?\d+(?:\.\d+)?(?:\.\d+)?-/.test(e.trim());
2360
+ }
2361
+ function Gr(e, t) {
2362
+ if (Wr(e)) return !1;
2363
+ let n = Ur(e), r = Ur(t);
2364
+ if (!n || !r) return !1;
2365
+ for (let e = 0; e < 3; e++) {
2366
+ let t = n[e] ?? 0, i = r[e] ?? 0;
2367
+ if (t > i) return !0;
2368
+ if (t < i) return !1;
2369
+ }
2370
+ return !1;
2371
+ }
2372
+ var Kr = class extends He {
2373
+ get isProcessingQueue() {
2374
+ return this.queueGuard.current;
2375
+ }
2376
+ set isProcessingQueue(e) {
2377
+ this.queueGuard.current = e;
2378
+ }
2379
+ get isLoadingMore() {
2380
+ return this.loadMoreGuard.current;
2381
+ }
2382
+ set isLoadingMore(e) {
2383
+ this.loadMoreGuard.current = e;
2384
+ }
2385
+ get retryTimer() {
2386
+ return this.retryTimerRef.current;
2387
+ }
2388
+ set retryTimer(e) {
2389
+ this.retryTimerRef.current = e;
2390
+ }
2391
+ constructor(e, t) {
2392
+ super(), this.wsManager = null, this.wsUnsubscribers = [], this.keyboardHandler = null, this.holdActivationHandler = null, this.holdBlurHandler = null, this.toggleHandler = null, this.mouseMoveHandler = null, this.hashChangeHandler = null, this.onlineHandler = null, this.offlineHandler = null, this.initialized = !1, this.destroyed = !1, this.screenshotProvider = null, this.bootRetryTimer = null, this.bootAttempts = 0, this.pendingStateUpdates = null, this.flushScheduled = !1, this.isFlushing = !1, this.queueGuard = { current: !1 }, this.activeMutations = /* @__PURE__ */ new Set(), this.sliceSubscribers = /* @__PURE__ */ new Map(), this.retryTimerRef = { current: null }, this.otpFailedAttempts = 0, this.otpCooldownUntil = 0, this.overlayBeforeTool = null, this.loadMoreGuard = { current: !1 }, this.offlinePersistUnsub = null, this.escapeBlockers = /* @__PURE__ */ new Set(), this.config = { ...e }, this.localDemo = t ?? null, this.localDemo && (this.config.features = {
2393
+ comments: !0,
2394
+ drawing: !1,
2395
+ highlighting: !1,
2396
+ screenshots: !1,
2397
+ realtime: !1
2398
+ }, this.config.ui = {
2399
+ ...this.config.ui,
2400
+ loadRemoteFonts: !1
2401
+ }), Rr && !this.config.environment && (this.config.environment = this.detectEnvironment()), this.apiClient = this.localDemo?.client ?? new se(this.config), this.apiClient.setOnAuthExpired(() => this.handleAuthExpired()), this.state = bn(), this.requiresShortcut() && (this.state.isOverlayVisible = !1), this.screenshotProvider = e.screenshotProvider || null, this.ctx = {
2402
+ getState: () => this.getInternalState(),
2403
+ setState: (e) => this.setState(e),
2404
+ apiClient: this.apiClient,
2405
+ emit: (e, t) => {
2406
+ this.destroyed || this.emit(e, t);
2407
+ },
2408
+ handleError: (e) => this.handleError(e),
2409
+ config: this.config,
2410
+ isLocalDemo: !!this.localDemo
2411
+ }, this.kbdCallbacks = {
2412
+ toggleLoginModal: () => this.toggleLoginModal(),
2413
+ toggleOverlay: () => this.toggleOverlay(),
2414
+ toggleSidebar: () => this.toggleSidebar(),
2415
+ toggleShortcutsOverlay: () => this.toggleShortcutsOverlay(),
2416
+ setTool: (e) => this.setTool(e),
2417
+ selectComment: (e) => this.selectComment(e),
2418
+ setState: (e) => this.setState(e)
2419
+ }, this.commentCb = {
2420
+ shouldQueueMutation: (e) => this.shouldQueueMutation(e),
2421
+ queueMutation: (e, t, n) => this.queueMutation(e, t, n),
2422
+ addActivity: (e) => this.addActivity(e)
2423
+ }, this.realtimeRefs = {
2424
+ wsManager: this.wsManager,
2425
+ wsUnsubscribers: this.wsUnsubscribers,
2426
+ mouseMoveHandler: this.mouseMoveHandler
2427
+ }, this.localDemo && (this.restoreDemoState(), this.localDemo.subscribe((e) => {
2428
+ e !== "persist" && this.restoreDemoState();
2429
+ })), e.enabled !== !1 && Rr && Promise.resolve().then(() => this.boot()).catch((e) => this.handleError(e));
2430
+ /* v8 ignore stop */
2431
+ }
2432
+ isLocalDemo() {
2433
+ return this.localDemo !== null;
2434
+ }
2435
+ restoreDemoState() {
2436
+ if (!this.localDemo || this.destroyed) return;
2437
+ let e = this.localDemo.getSession().expired;
2438
+ this.overlayBeforeTool = null, this.setState({
2439
+ ...bn(),
2440
+ currentUser: e ? null : { ...this.localDemo.user },
2441
+ isAuthenticated: !e,
2442
+ isOverlayVisible: !e,
2443
+ isOnline: !0,
2444
+ comments: this.localDemo.getComments(),
2445
+ project: {
2446
+ id: "local-demo",
2447
+ slug: "local-demo",
2448
+ name: "Private browser demo",
2449
+ url: window.location.origin,
2450
+ features: {
2451
+ comments: !0,
2452
+ drawing: !1,
2453
+ highlighting: !1,
2454
+ screenshots: !1,
2455
+ realtime: !1
2456
+ },
2457
+ limits: {
2458
+ maxMembers: 1,
2459
+ retentionDays: 1
2460
+ }
2461
+ }
2462
+ });
2463
+ }
2464
+ startLocalDemo() {
2465
+ this.localDemo && !this.destroyed && (this.localDemo.activate(), this.setState({
2466
+ isOverlayVisible: !0,
2467
+ isSidebarVisible: !1,
2468
+ isLoginModalVisible: !1,
2469
+ error: null
2470
+ }), this.setTool("comment"));
2471
+ }
2472
+ detectEnvironment() {
2473
+ let e = window.location.hostname;
2474
+ return e === "localhost" || e === "127.0.0.1" || e === "[::1]" || e.endsWith(".localhost") ? "development" : e.endsWith(".vercel.app") || e.endsWith(".netlify.app") || e.endsWith(".pages.dev") || e.includes("-preview.") || e.endsWith("-preview") || /-preview-\d/.test(e) ? "preview" : e.startsWith("staging.") || e.startsWith("stage.") || e.includes(".staging.") || e.endsWith(".staging") ? "staging" : "production";
2475
+ }
2476
+ async boot() {
2477
+ if (this.destroyed) return;
2478
+ this.keyboardHandler = this.handleKeyboardShortcuts.bind(this), window.addEventListener("keydown", this.keyboardHandler, !0);
2479
+ let e = this.config.ui?.activation;
2480
+ e?.mode === "hold" && e.key && (this.holdActivationHandler = (e) => {
2481
+ if (this.destroyed || !this.matchesHoldKey(e)) return;
2482
+ let t = this.getInternalState().activeTool;
2483
+ e.type === "keydown" && !t ? this.setTool("select") : e.type === "keyup" && t === "select" && this.setTool(null);
2484
+ }, window.addEventListener("keydown", this.holdActivationHandler), window.addEventListener("keyup", this.holdActivationHandler), this.holdBlurHandler = () => {
2485
+ this.destroyed || this.getInternalState().activeTool === "select" && this.setTool(null);
2486
+ }, window.addEventListener("blur", this.holdBlurHandler)), this.toggleHandler = () => this.handleToggleRequest(), window.addEventListener("commentkit:toggle-overlay", this.toggleHandler), this.hashChangeHandler = () => this.handleDeepLink(), window.addEventListener("hashchange", this.hashChangeHandler), this.handleDeepLink(), !this.localDemo && (this.onlineHandler = () => {
2487
+ this.destroyed || (this.setState({ isOnline: !0 }), this.processOfflineQueue());
2488
+ }, this.offlineHandler = () => {
2489
+ this.destroyed || this.setState({ isOnline: !1 });
2490
+ }, window.addEventListener("online", this.onlineHandler), window.addEventListener("offline", this.offlineHandler), this.autoDetectInviteToken(), this.config.apiKey && await this.initialize());
2491
+ }
2492
+ autoDetectInviteToken() {
2493
+ try {
2494
+ let e = new URLSearchParams(window.location.search), t = e.get("ck_invite");
2495
+ if (!t) return;
2496
+ /^[\w-]{64}$/.test(t) && (this.config.inviteToken = t), e.delete("ck_invite");
2497
+ let n = e.toString(), r = window.location.pathname + (n ? `?${n}` : "") + window.location.hash;
2498
+ window.history.replaceState(window.history.state, "", r);
2499
+ } catch {}
2500
+ }
2501
+ async initialize() {
2502
+ if (!(this.initialized || this.destroyed)) {
2503
+ this.initialized = !0, this.bootAttempts += 1;
2504
+ try {
2505
+ this.setState({
2506
+ isLoading: !0,
2507
+ error: null
2508
+ });
2509
+ let e = await this.apiClient.validateApiKey();
2510
+ if (this.destroyed) return;
2511
+ if (!e.valid) {
2512
+ this.handleError({
2513
+ error: "invalid_api_key",
2514
+ message: "Invalid API key",
2515
+ code: 401
2516
+ });
2517
+ return;
2518
+ }
2519
+ e.project?.id && (this.config.projectId = String(e.project.id), this.hydrateOfflineQueue());
2520
+ let t = e.project?.slug ?? e.project?.id;
2521
+ if (t && this.apiClient.setProject(String(t)), e.project?.features && (this.config.features = e.project.features), e.project?.reverb && e.project.features?.realtime) {
2522
+ let t = e.project.reverb;
2523
+ this.config.reverb = {
2524
+ key: t.key,
2525
+ host: t.host,
2526
+ port: t.port ?? 443,
2527
+ scheme: t.scheme ?? "wss"
2528
+ };
2529
+ }
2530
+ let n = e.project?.sdkLatestVersion;
2531
+ n && Gr(n, "0.6.9") && (console.warn(`[CommentKit] You are using v${Hr}. Update to v${n}: npm update @commentkit/comment-kit`), this.emit("sdk:outdated", {
2532
+ current: Hr,
2533
+ latest: n
2534
+ })), this.setState({
2535
+ project: e.project,
2536
+ isLoading: !1
2537
+ }), await this.restorePersistedSession();
2538
+ } catch (e) {
2539
+ if (this.initialized = !1, this.handleError(e), this.bootAttempts < 3 && !this.destroyed) {
2540
+ let e = 2e3 * 2 ** (this.bootAttempts - 1);
2541
+ this.bootRetryTimer = setTimeout(() => {
2542
+ this.bootRetryTimer = null, this.initialize();
2543
+ }, e);
2544
+ }
2545
+ }
2546
+ }
2547
+ }
2548
+ setState(e) {
2549
+ this.destroyed || (this.localDemo && e.activeTool === null && e.isOverlayVisible === void 0 && this.overlayBeforeTool !== null && (e = {
2550
+ ...e,
2551
+ isOverlayVisible: this.overlayBeforeTool
2552
+ }, this.overlayBeforeTool = null), this.pendingStateUpdates ? Object.assign(this.pendingStateUpdates, e) : this.pendingStateUpdates = { ...e }, this.flushScheduled || (this.flushScheduled = !0, Promise.resolve().then(() => this.flushState())));
2553
+ }
2554
+ getInternalState() {
2555
+ return this.localDemo?.checkExpiry(), this.pendingStateUpdates ? {
2556
+ ...this.state,
2557
+ ...this.pendingStateUpdates
2558
+ } : this.state;
2559
+ }
2560
+ cloneStateSnapshot(e) {
2561
+ return {
2562
+ ...e,
2563
+ currentUser: e.currentUser ? structuredClone(e.currentUser) : null,
2564
+ project: e.project ? structuredClone(e.project) : null,
2565
+ comments: structuredClone(e.comments),
2566
+ selectedComment: e.selectedComment ? structuredClone(e.selectedComment) : null,
2567
+ activeComment: e.activeComment ? structuredClone(e.activeComment) : null,
2568
+ activeDrawing: e.activeDrawing ? structuredClone(e.activeDrawing) : null,
2569
+ activeScreenshot: e.activeScreenshot ? {
2570
+ ...e.activeScreenshot,
2571
+ dimensions: { ...e.activeScreenshot.dimensions }
2572
+ } : null,
2573
+ onlineUsers: structuredClone(e.onlineUsers),
2574
+ pendingMutations: structuredClone(e.pendingMutations),
2575
+ activities: structuredClone(e.activities),
2576
+ seenThreadIds: new Set(e.seenThreadIds),
2577
+ pagination: e.pagination ? { ...e.pagination } : null
2578
+ };
2579
+ }
2580
+ flushState() {
2581
+ if (this.destroyed) {
2582
+ this.pendingStateUpdates = null, this.flushScheduled = !1;
2583
+ return;
2584
+ }
2585
+ if (this.isFlushing) return;
2586
+ this.flushScheduled = !1;
2587
+ let e = this.pendingStateUpdates;
2588
+ if (!e) return;
2589
+ this.pendingStateUpdates = null;
2590
+ let t = this.state;
2591
+ this.state = {
2592
+ ...t,
2593
+ ...e
2594
+ }, this.isFlushing = !0;
2595
+ try {
2596
+ this.notifySubscribers(e, t);
2597
+ } finally {
2598
+ this.isFlushing = !1;
2599
+ }
2600
+ this.pendingStateUpdates && !this.flushScheduled && (this.flushScheduled = !0, Promise.resolve().then(() => this.flushState()));
2601
+ }
2602
+ notifySubscribers(e, t) {
2603
+ e.activeTool !== void 0 && e.activeTool !== t.activeTool && this.emit("tool:changed", e.activeTool), e.isOverlayVisible !== void 0 && e.isOverlayVisible !== t.isOverlayVisible && this.emit("overlay:toggled", e.isOverlayVisible), e.isSidebarVisible !== void 0 && e.isSidebarVisible !== t.isSidebarVisible && this.emit("sidebar:toggled", e.isSidebarVisible), e.isLoginModalVisible !== void 0 && e.isLoginModalVisible !== t.isLoginModalVisible && this.emit("loginmodal:toggled", e.isLoginModalVisible), e.isShortcutsOverlayVisible !== void 0 && e.isShortcutsOverlayVisible !== t.isShortcutsOverlayVisible && this.emit("shortcuts:toggled", e.isShortcutsOverlayVisible), e.connectionStatus !== void 0 && e.connectionStatus !== t.connectionStatus && this.emit("connection:changed", e.connectionStatus);
2604
+ let n = Object.keys(e);
2605
+ for (let [e, t] of this.sliceSubscribers) {
2606
+ let r = _n[e];
2607
+ if (n.some((e) => r.includes(e))) for (let n of t) try {
2608
+ n(this.state);
2609
+ } catch (t) {
2610
+ console.error(`[CommentKit] Error in ${e} slice subscriber:`, t);
2611
+ }
2612
+ }
2613
+ this.emit("state:changed", this.state);
2614
+ }
2615
+ flushStateSync() {
2616
+ this.pendingStateUpdates && !this.isFlushing && this.flushState();
2617
+ }
2618
+ getState() {
2619
+ return this.localDemo?.checkExpiry(), this.flushStateSync(), this.cloneStateSnapshot(this.state);
2620
+ }
2621
+ getFeatures() {
2622
+ return {
2623
+ comments: this.config.features?.comments ?? !0,
2624
+ drawing: this.config.features?.drawing ?? !0,
2625
+ highlighting: this.config.features?.highlighting ?? !0,
2626
+ screenshots: this.config.features?.screenshots ?? !0,
2627
+ realtime: this.config.features?.realtime ?? !0
2628
+ };
2629
+ }
2630
+ getConfig() {
2631
+ return {
2632
+ apiKey: this.config.apiKey,
2633
+ ...this.config.baseUrl !== void 0 && { baseUrl: this.config.baseUrl },
2634
+ ...this.config.enabled !== void 0 && { enabled: this.config.enabled },
2635
+ screenshotProvider: this.config.screenshotProvider,
2636
+ ui: this.config.ui ? { ...this.config.ui } : void 0
2637
+ };
2638
+ }
2639
+ async validateInvite(e) {
2640
+ if (!(this.destroyed || this.localDemo)) return mt(this.ctx, e, (e) => this.login(e));
2641
+ }
2642
+ onSlice(e, t) {
2643
+ if (!_n[e] || typeof t != "function" || this.destroyed) return () => {};
2644
+ let n = this.sliceSubscribers.get(e);
2645
+ return n || (n = /* @__PURE__ */ new Set(), this.sliceSubscribers.set(e, n)), n.add(t), () => n.delete(t);
2646
+ }
2647
+ select(e, t) {
2648
+ if (typeof e != "function" || typeof t != "function" || this.destroyed) return () => {};
2649
+ let n;
2650
+ try {
2651
+ n = e(this.getInternalState());
2652
+ } catch (e) {
2653
+ return this.handleError(e), () => {};
2654
+ }
2655
+ return this.on("state:changed", (r) => {
2656
+ try {
2657
+ let i = e(r);
2658
+ i !== n && (n = i, t(i));
2659
+ } catch (e) {
2660
+ this.handleError(e);
2661
+ }
2662
+ });
2663
+ }
2664
+ handleError(e) {
2665
+ if (this.destroyed) return;
2666
+ let t = e && typeof e == "object" ? e : null, n = typeof t?.message == "string" && t.message ? t.message : String(e ?? "Unknown error"), r = {
2667
+ error: typeof t?.error == "string" && t.error ? t.error : "unknown",
2668
+ message: n,
2669
+ code: typeof t?.code == "number" && Number.isFinite(t.code) ? t.code : 0,
2670
+ ...t?.details && typeof t.details == "object" ? { details: t.details } : {}
2671
+ };
2672
+ console.error("[CommentKit]", r.message), this.setState({
2673
+ error: r.message,
2674
+ isLoading: !1
2675
+ }), this.emit("error", r);
2676
+ }
2677
+ async restorePersistedSession() {
2678
+ if (this.destroyed) return;
2679
+ let e = Ye(this.config.projectId);
2680
+ if (e) try {
2681
+ this.apiClient.setAuthToken(e.token), this.apiClient.setUserEmail(e.email), this.setState({
2682
+ currentUser: e.user,
2683
+ isAuthenticated: !0,
2684
+ isLoginModalVisible: !1,
2685
+ otpStep: "idle",
2686
+ otpEmail: null,
2687
+ error: null
2688
+ }), this.emit("auth:login", e.user), await this.afterAuthenticated();
2689
+ } catch {
2690
+ this.handleAuthExpired();
2691
+ }
2692
+ }
2693
+ async afterAuthenticated() {
2694
+ this.destroyed || (this.getFeatures().realtime && this.initializeWebSocket(), await this.loadComments(), this.handleDeepLink(), this.getInternalState().pendingMutations.length > 0 && this.scheduleRetry());
2695
+ }
2696
+ async login(e) {
2697
+ if (!(this.destroyed || this.localDemo)) return st(this.ctx, e);
2698
+ }
2699
+ async verifyOtp(e) {
2700
+ if (this.destroyed || this.localDemo) return;
2701
+ let t = Date.now();
2702
+ if (t < this.otpCooldownUntil) {
2703
+ let e = Math.ceil((this.otpCooldownUntil - t) / 1e3);
2704
+ this.handleError({
2705
+ error: "otp_throttled",
2706
+ message: `Too many attempts. Please wait ${e}s and try again.`,
2707
+ code: 429
2708
+ });
2709
+ } else return ct(this.ctx, e, {
2710
+ onAuthenticated: async () => {
2711
+ await this.afterAuthenticated();
2712
+ },
2713
+ onSuccess: () => {
2714
+ this.otpFailedAttempts = 0, this.otpCooldownUntil = 0;
2715
+ },
2716
+ onWrongOtp: () => {
2717
+ if (this.otpFailedAttempts += 1, this.otpFailedAttempts >= 3) {
2718
+ let e = Math.min(3e4, 2e3 * 2 ** (this.otpFailedAttempts - 3));
2719
+ this.otpCooldownUntil = Date.now() + e;
2720
+ }
2721
+ }
2722
+ });
2723
+ }
2724
+ cancelOtp() {
2725
+ this.destroyed || lt(this.ctx);
2726
+ }
2727
+ async resendOtp() {
2728
+ if (!(this.destroyed || this.localDemo)) return ut(this.ctx);
2729
+ }
2730
+ logout() {
2731
+ this.destroyed || (this.localDemo ? (this.setTool(null), this.setState({
2732
+ isOverlayVisible: !1,
2733
+ isSidebarVisible: !1
2734
+ })) : (this.overlayBeforeTool = null, dt(this.ctx, () => {
2735
+ this.disconnectRealtime(!0);
2736
+ })));
2737
+ }
2738
+ handleAuthExpired() {
2739
+ this.overlayBeforeTool = null, this.disconnectRealtime(!0), ft(this.ctx);
2740
+ }
2741
+ toggleLoginModal() {
2742
+ this.destroyed || this.localDemo || pt(this.ctx);
2743
+ }
2744
+ requiresShortcut() {
2745
+ return this.localDemo ? !0 : this.config.environment !== "development";
2746
+ }
2747
+ toggleOverlay() {
2748
+ if (this.destroyed) return;
2749
+ let e = !this.getInternalState().isOverlayVisible;
2750
+ this.overlayBeforeTool = null, this.setState({
2751
+ isOverlayVisible: e,
2752
+ ...!e && {
2753
+ selectedComment: null,
2754
+ activeComment: null
2755
+ }
2756
+ });
2757
+ }
2758
+ toggleSidebar() {
2759
+ this.destroyed || this.setState({ isSidebarVisible: !this.getInternalState().isSidebarVisible });
2760
+ }
2761
+ setTool(e) {
2762
+ if (this.destroyed || !Br.has(e) || this.localDemo && e !== null && e !== "comment" && e !== "select") return;
2763
+ let t = this.getInternalState();
2764
+ if (!t.isAuthenticated && e !== "select" && e !== null) {
2765
+ this.toggleLoginModal();
2766
+ return;
2767
+ }
2768
+ let n;
2769
+ e === null ? (n = this.overlayBeforeTool ?? t.isOverlayVisible, this.overlayBeforeTool = null) : (this.overlayBeforeTool === null && (this.overlayBeforeTool = t.isOverlayVisible), n = !1), this.setState({
2770
+ activeTool: e,
2771
+ isCommentModeActive: e === "comment",
2772
+ isDrawingModeActive: e === "draw",
2773
+ isHighlightModeActive: e === "highlight",
2774
+ isScreenshotModeActive: e === "screenshot",
2775
+ isOverlayVisible: n,
2776
+ selectedComment: null,
2777
+ activeComment: null,
2778
+ activeDrawing: null,
2779
+ activeScreenshot: null
2780
+ });
2781
+ }
2782
+ operationContext() {
2783
+ if (!this.localDemo) return this.ctx;
2784
+ this.localDemo.refresh();
2785
+ let e = this.localDemo.getRevision(), t = () => !this.destroyed && e === this.localDemo?.getRevision();
2786
+ return {
2787
+ ...this.ctx,
2788
+ setState: (e) => {
2789
+ t() && this.ctx.setState(e);
2790
+ },
2791
+ emit: (e, n) => {
2792
+ t() && this.ctx.emit(e, n);
2793
+ },
2794
+ handleError: (e) => {
2795
+ t() && this.ctx.handleError(e);
2796
+ }
2797
+ };
2798
+ }
2799
+ operationCallbacks() {
2800
+ if (!this.localDemo) return this.commentCb;
2801
+ let e = this.localDemo.getRevision();
2802
+ return {
2803
+ ...this.commentCb,
2804
+ addActivity: (t) => {
2805
+ e === this.localDemo?.getRevision() && this.commentCb.addActivity(t);
2806
+ }
2807
+ };
2808
+ }
2809
+ async loadComments() {
2810
+ return G(this.operationContext());
2811
+ }
2812
+ async loadMoreComments() {
2813
+ this.destroyed || await Ut(this.operationContext(), this.loadMoreGuard);
2814
+ }
2815
+ async reloadComments() {
2816
+ if (!this.destroyed) return G(this.operationContext());
2817
+ }
2818
+ async createComment(e, t, n, r = "medium", i, a, o) {
2819
+ if (!this.destroyed) {
2820
+ if (this.localDemo && (e !== "pin" || o?.files?.length || o?.attachmentIds?.length)) this.handleError({
2821
+ error: "demo_unavailable",
2822
+ message: "Files and drawings are unavailable in the private browser demo.",
2823
+ code: 400
2824
+ });
2825
+ else return Wt(this.operationContext(), this.operationCallbacks(), this.activeMutations, e, t, n, r, i, a, o);
2826
+ }
2827
+ }
2828
+ async updateComment(e, t) {
2829
+ if (!this.destroyed) return Gt(this.operationContext(), this.operationCallbacks(), e, t);
2830
+ }
2831
+ async deleteComment(e) {
2832
+ if (!this.destroyed) return Kt(this.operationContext(), this.operationCallbacks(), e);
2833
+ }
2834
+ async addReply(e, t) {
2835
+ if (!this.destroyed) return qt(this.operationContext(), this.operationCallbacks(), e, t);
2836
+ }
2837
+ async updateReply(e, t, n) {
2838
+ if (!this.destroyed) return Jt(this.operationContext(), e, t, n);
2839
+ }
2840
+ async deleteReply(e, t) {
2841
+ if (!this.destroyed) return Yt(this.operationContext(), e, t);
2842
+ }
2843
+ async resolveComment(e) {
2844
+ if (!this.destroyed) return Xt(this.operationContext(), this.operationCallbacks(), e);
2845
+ }
2846
+ async unresolveComment(e) {
2847
+ if (!this.destroyed) return Zt(this.operationContext(), this.operationCallbacks(), e);
2848
+ }
2849
+ selectComment(e) {
2850
+ this.destroyed || tn(this.operationContext(), e);
2851
+ }
2852
+ async completeComment(e) {
2853
+ if (!this.destroyed) return Qt(this.operationContext(), this.operationCallbacks(), e);
2854
+ }
2855
+ async reactToComment(e, t) {
2856
+ if (!this.destroyed) return $t(this.operationContext(), this.operationCallbacks(), e, t);
2857
+ }
2858
+ async updateCommentPosition(e, t, n) {
2859
+ if (!this.destroyed) return en(this.operationContext(), this.operationCallbacks(), e, t, n);
2860
+ }
2861
+ hydrateOfflineQueue() {
2862
+ let e = Xn(this.config.projectId);
2863
+ if (e.length > 0) {
2864
+ let t = this.getInternalState().pendingMutations, n = new Set(t.map((e) => e.id)), r = [...t, ...e.filter((e) => !n.has(e.id))];
2865
+ this.setState({ pendingMutations: r }), this.getInternalState().isOnline && this.scheduleRetry();
2866
+ }
2867
+ this.offlinePersistUnsub?.(), this.offlinePersistUnsub = this.select((e) => e.pendingMutations, (e) => Yn(this.config.projectId, e));
2868
+ }
2869
+ shouldQueueMutation(e) {
2870
+ return !this.localDemo && er(this.getInternalState(), e);
2871
+ }
2872
+ queueMutation(e, t, n) {
2873
+ return tr(this.ctx, () => this.scheduleRetry(), e, t, n);
2874
+ }
2875
+ scheduleRetry() {
2876
+ nr(this.ctx, this.retryTimerRef, () => this.processOfflineQueue());
2877
+ }
2878
+ async processOfflineQueue() {
2879
+ await rr(this.ctx, this.queueGuard, () => this.scheduleRetry(), (e) => this.executeMutation(e));
2880
+ }
2881
+ async executeMutation(e) {
2882
+ return ar(this.ctx, e);
2883
+ }
2884
+ getPendingMutationCount() {
2885
+ return this.getInternalState().pendingMutations.length;
2886
+ }
2887
+ clearError() {
2888
+ this.destroyed || this.getInternalState().error == null || this.setState({ error: null });
2889
+ }
2890
+ retryConnection() {
2891
+ !this.destroyed && this.getInternalState().isAuthenticated && (this.wsManager ? this.wsManager.reconnect() : this.initializeWebSocket());
2892
+ }
2893
+ markThreadSeen(e) {
2894
+ if (this.destroyed || typeof e != "string" || !e.trim() || e.length > Vr) return;
2895
+ let t = new Set(this.getInternalState().seenThreadIds);
2896
+ if (t.add(e), t.size > 1e3) {
2897
+ let e = Array.from(t);
2898
+ t.clear();
2899
+ for (let n of e.slice(-1e3)) t.add(n);
2900
+ }
2901
+ this.setState({ seenThreadIds: t });
2902
+ }
2903
+ isThreadNew(e) {
2904
+ return typeof e != "string" || !e.trim() ? !1 : !this.getInternalState().seenThreadIds.has(e);
2905
+ }
2906
+ setPanelView(e) {
2907
+ !this.destroyed && zr.has(e) && this.setState({ panelView: e });
2908
+ }
2909
+ toggleShortcutsOverlay() {
2910
+ this.destroyed || this.setState({ isShortcutsOverlayVisible: !this.getInternalState().isShortcutsOverlayVisible });
2911
+ }
2912
+ addActivity(e) {
2913
+ if (this.destroyed) return;
2914
+ let t = this.getInternalState(), n = t.currentUser;
2915
+ if (!n) return;
2916
+ let r = {
2917
+ id: `activity-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
2918
+ user: {
2919
+ id: n.id,
2920
+ name: n.name,
2921
+ avatarUrl: n.avatar
2922
+ },
2923
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2924
+ read: !1,
2925
+ ...e
2926
+ }, i = [r, ...t.activities].slice(0, 500);
2927
+ this.setState({ activities: i }), this.emit("activity:new", r);
2928
+ }
2929
+ markAllActivitiesRead() {
2930
+ if (this.destroyed) return;
2931
+ let e = this.getInternalState();
2932
+ this.setState({ activities: e.activities.map((e) => ({
2933
+ ...e,
2934
+ read: !0
2935
+ })) });
2936
+ }
2937
+ getUnreadActivityCount() {
2938
+ return this.getInternalState().activities.filter((e) => !e.read).length;
2939
+ }
2940
+ handleDeepLink() {
2941
+ if (this.destroyed) return;
2942
+ let e = window.location.hash.match(/^#comment-(.+)$/);
2943
+ if (!e?.[1]) return;
2944
+ let t = e[1];
2945
+ this.emit("deeplink:navigate", { commentId: t });
2946
+ let n = this.getInternalState().comments.find((e) => e.id === t);
2947
+ n && (this.selectComment(n), this.setState({
2948
+ isSidebarVisible: !0,
2949
+ panelView: "detail"
2950
+ }));
2951
+ }
2952
+ async createHighlight(e, t) {
2953
+ if (!this.destroyed) return nn(this.ctx, this.commentCb, this.activeMutations, e, t);
2954
+ }
2955
+ async createDrawing(e, t, n) {
2956
+ if (!this.destroyed) return rn(this.ctx, this.commentCb, this.activeMutations, e, t, n);
2957
+ }
2958
+ setActiveDrawing(e) {
2959
+ this.destroyed || this.setState({ activeDrawing: e });
2960
+ }
2961
+ sendDrawingStroke(e) {
2962
+ this.destroyed || this.wsManager?.sendDrawingStroke(e);
2963
+ }
2964
+ async captureScreenshot(e) {
2965
+ return this.destroyed ? null : Pr(this.ctx, this.screenshotProvider, e);
2966
+ }
2967
+ async uploadScreenshot(e, t, n) {
2968
+ return this.destroyed ? null : Fr(this.ctx, e, t, n);
2969
+ }
2970
+ setActiveScreenshot(e) {
2971
+ this.destroyed || this.setState({ activeScreenshot: e });
2972
+ }
2973
+ async uploadFiles(e, t) {
2974
+ return this.destroyed ? [] : Ir(this.ctx, e, t);
2975
+ }
2976
+ getAgentContext(e) {
2977
+ return A(this.getInternalState(), e);
2978
+ }
2979
+ async getAgentContextAsync(e) {
2980
+ let t = A(this.getInternalState(), e), n = this.localDemo?.getRevision(), r = await Me(t);
2981
+ return this.localDemo?.checkExpiry(), this.localDemo && n !== this.localDemo.getRevision() ? A(this.getInternalState(), e) : r;
2982
+ }
2983
+ formatAgentContext(e) {
2984
+ return j(this.getAgentContext(e));
2985
+ }
2986
+ async formatAgentContextAsync(e) {
2987
+ return j(await this.getAgentContextAsync(e));
2988
+ }
2989
+ async copyAgentContext(e) {
2990
+ if (this.destroyed) return "";
2991
+ let t = await this.getAgentContextAsync(e), n = j(t);
2992
+ return await Re(n, t), this.emit("agent:context-copied", {
2993
+ commentCount: t.comments.length,
2994
+ sourceResolved: t.sourceResolved
2995
+ }), n;
2996
+ }
2997
+ async grabElement(e, t) {
2998
+ if (this.destroyed) return null;
2999
+ let { grabElement: n } = await import("./dev-grab-pDAfH2lr.js");
3000
+ if (this.destroyed) return null;
3001
+ let r = await n(e, this.ctx, this.screenshotProvider, t);
3002
+ return this.destroyed ? null : (r && this.emit("agent:element-grabbed", {
3003
+ source: r.element.source?.filePath ?? null,
3004
+ componentName: r.element.componentName ?? null
3005
+ }), r);
3006
+ }
3007
+ async grabElements(e, t) {
3008
+ if (this.destroyed) return null;
3009
+ let { grabElements: n } = await import("./dev-grab-pDAfH2lr.js");
3010
+ if (this.destroyed) return null;
3011
+ let r = await n(e, this.ctx, this.screenshotProvider, t);
3012
+ return this.destroyed ? null : (r && this.emit("agent:elements-grabbed", { count: r.results.length }), r);
3013
+ }
3014
+ async getProjectMembers() {
3015
+ if (this.destroyed) return [];
3016
+ try {
3017
+ return await this.apiClient.getProjectMembers();
3018
+ } catch (e) {
3019
+ return this.handleError(e), [];
3020
+ }
3021
+ }
3022
+ handleToggleRequest() {
3023
+ this.destroyed || hn(this.getInternalState(), this.kbdCallbacks);
3024
+ }
3025
+ handleKeyboardShortcuts(e) {
3026
+ if (!this.destroyed) {
3027
+ if (e.key === "Escape") {
3028
+ if (this.escapeBlockers.size > 0 || document.querySelector("dialog[open]")) return;
3029
+ let t = e.composedPath()[0];
3030
+ if (t instanceof Element && t.getRootNode() === document && t.closest("[data-commentkit-ui], [data-commentkit-ignore]")) return;
3031
+ }
3032
+ gn(e, this.getInternalState(), this.kbdCallbacks);
3033
+ }
3034
+ }
3035
+ matchesHoldKey(e) {
3036
+ let t = this.config.ui?.activation?.key;
3037
+ return t ? t === "Alt" ? e.key === "Alt" || e.code === "AltLeft" || e.code === "AltRight" : t === "Meta" ? e.key === "Meta" || e.code === "MetaLeft" || e.code === "MetaRight" : t === "Control" ? e.key === "Control" || e.code === "ControlLeft" || e.code === "ControlRight" : t === "Shift" ? e.key === "Shift" || e.code === "ShiftLeft" || e.code === "ShiftRight" : !1 : !1;
3038
+ }
3039
+ blockEscape() {
3040
+ let e = Symbol();
3041
+ return this.escapeBlockers.add(e), () => {
3042
+ this.escapeBlockers.delete(e);
3043
+ };
3044
+ }
3045
+ initializeWebSocket() {
3046
+ this.destroyed || this.localDemo || Lr().then((e) => {
3047
+ this.destroyed || this.getInternalState().isAuthenticated && (this.syncRealtimeRefs(), e.initializeWebSocket(this.ctx, this.realtimeRefs), this.syncFromRealtimeRefs());
3048
+ }).catch((e) => {
3049
+ this.ctx.handleError(e);
3050
+ });
3051
+ }
3052
+ getOnlineUsers() {
3053
+ /* v8 ignore next -- onlineUsers is always initialized as array */
3054
+ return structuredClone(this.getInternalState().onlineUsers || []);
3055
+ }
3056
+ syncRealtimeRefs() {
3057
+ this.realtimeRefs.wsManager = this.wsManager, this.realtimeRefs.wsUnsubscribers = this.wsUnsubscribers, this.realtimeRefs.mouseMoveHandler = this.mouseMoveHandler;
3058
+ }
3059
+ syncFromRealtimeRefs() {
3060
+ this.wsManager = this.realtimeRefs.wsManager, this.wsUnsubscribers = this.realtimeRefs.wsUnsubscribers, this.mouseMoveHandler = this.realtimeRefs.mouseMoveHandler;
3061
+ }
3062
+ removeMouseMoveListener() {
3063
+ $ && (this.syncRealtimeRefs(), $.removeMouseMoveListener(this.realtimeRefs), this.syncFromRealtimeRefs());
3064
+ }
3065
+ disconnectRealtime(e) {
3066
+ for (let e of this.wsUnsubscribers) try {
3067
+ e();
3068
+ } catch (e) {
3069
+ console.error("[CommentKit] Error during realtime cleanup:", e);
3070
+ }
3071
+ if (this.wsUnsubscribers = [], this.wsManager) {
3072
+ try {
3073
+ e && this.wsManager.sendCursorLeave();
3074
+ } catch {}
3075
+ this.wsManager.destroy(), this.wsManager = null;
3076
+ }
3077
+ this.removeMouseMoveListener(), this.syncRealtimeRefs();
3078
+ }
3079
+ destroy() {
3080
+ this.destroyed || (this.destroyed = !0, Rr && (this.keyboardHandler && window.removeEventListener("keydown", this.keyboardHandler, !0), this.holdActivationHandler && (window.removeEventListener("keydown", this.holdActivationHandler), window.removeEventListener("keyup", this.holdActivationHandler)), this.holdBlurHandler && window.removeEventListener("blur", this.holdBlurHandler), this.toggleHandler && window.removeEventListener("commentkit:toggle-overlay", this.toggleHandler), this.hashChangeHandler && window.removeEventListener("hashchange", this.hashChangeHandler), this.onlineHandler && window.removeEventListener("online", this.onlineHandler), this.offlineHandler && window.removeEventListener("offline", this.offlineHandler)), this.pendingStateUpdates = null, this.flushScheduled = !1, this.activeMutations.clear(), this.offlinePersistUnsub?.(), this.offlinePersistUnsub = null, this.retryTimer &&= (clearTimeout(this.retryTimer), null), this.bootRetryTimer &&= (clearTimeout(this.bootRetryTimer), null), this.disconnectRealtime(!0), this.localDemo?.destroy(), this.sliceSubscribers.clear(), this.removeAllListeners());
3081
+ }
3082
+ };
3083
+ export { He as a, A as c, O as d, se as f, le as g, E as h, M as i, j as l, ce as m, Hr as n, Le as o, D as p, Pr as r, Re as s, Kr as t, me as u };