impact-nova 2.5.16 → 2.6.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/README.md +27 -25
  2. package/dist/components/data/ag-grid-react/ag-grid.types.d.ts +28 -1
  3. package/dist/components/data/ag-grid-react/cell-renderers/date-display-renderer.d.ts +0 -3
  4. package/dist/components/data/ag-grid-react/cell-renderers/date-display-renderer.js +31 -38
  5. package/dist/components/data/ag-grid-react/cell-renderers/input-display-renderer.d.ts +1 -1
  6. package/dist/components/data/ag-grid-react/chat/chat-capabilities.d.ts +9 -0
  7. package/dist/components/data/ag-grid-react/chat/chat-capabilities.js +22 -0
  8. package/dist/components/data/ag-grid-react/chat/chat-column.d.ts +20 -0
  9. package/dist/components/data/ag-grid-react/chat/chat-column.js +81 -0
  10. package/dist/components/data/ag-grid-react/chat/chat-composer.d.ts +10 -0
  11. package/dist/components/data/ag-grid-react/chat/chat-composer.js +352 -0
  12. package/dist/components/data/ag-grid-react/chat/chat-constants.d.ts +17 -0
  13. package/dist/components/data/ag-grid-react/chat/chat-constants.js +22 -0
  14. package/dist/components/data/ag-grid-react/chat/chat-format.d.ts +41 -0
  15. package/dist/components/data/ag-grid-react/chat/chat-format.js +94 -0
  16. package/dist/components/data/ag-grid-react/chat/chat-host.d.ts +10 -0
  17. package/dist/components/data/ag-grid-react/chat/chat-host.js +651 -0
  18. package/dist/components/data/ag-grid-react/chat/chat-host.types.d.ts +13 -0
  19. package/dist/components/data/ag-grid-react/chat/chat-html.d.ts +2 -0
  20. package/dist/components/data/ag-grid-react/chat/chat-html.js +40 -0
  21. package/dist/components/data/ag-grid-react/chat/chat-identity.d.ts +13 -0
  22. package/dist/components/data/ag-grid-react/chat/chat-identity.js +24 -0
  23. package/dist/components/data/ag-grid-react/chat/chat-menu.d.ts +13 -0
  24. package/dist/components/data/ag-grid-react/chat/chat-menu.js +15 -0
  25. package/dist/components/data/ag-grid-react/chat/chat-notify.d.ts +17 -0
  26. package/dist/components/data/ag-grid-react/chat/chat-notify.js +124 -0
  27. package/dist/components/data/ag-grid-react/chat/chat-persist.d.ts +13 -0
  28. package/dist/components/data/ag-grid-react/chat/chat-persist.js +34 -0
  29. package/dist/components/data/ag-grid-react/chat/chat-priority.d.ts +13 -0
  30. package/dist/components/data/ag-grid-react/chat/chat-priority.js +79 -0
  31. package/dist/components/data/ag-grid-react/chat/chat-summaries.d.ts +2 -0
  32. package/dist/components/data/ag-grid-react/chat/chat-summaries.js +24 -0
  33. package/dist/components/data/ag-grid-react/chat/chat-thread-ui.d.ts +72 -0
  34. package/dist/components/data/ag-grid-react/chat/chat-thread-ui.js +713 -0
  35. package/dist/components/data/ag-grid-react/chat/chat-toggle.d.ts +6 -0
  36. package/dist/components/data/ag-grid-react/chat/chat-toggle.js +25 -0
  37. package/dist/components/data/ag-grid-react/chat/chat-ui-actions.d.ts +13 -0
  38. package/dist/components/data/ag-grid-react/chat/chat-ui-actions.js +26 -0
  39. package/dist/components/data/ag-grid-react/chat/chat-window.d.ts +14 -0
  40. package/dist/components/data/ag-grid-react/chat/chat-window.js +82 -0
  41. package/dist/components/data/ag-grid-react/chat/chat-workspace.d.ts +91 -0
  42. package/dist/components/data/ag-grid-react/chat/chat-workspace.js +555 -0
  43. package/dist/components/data/ag-grid-react/chat/chat.types.d.ts +319 -0
  44. package/dist/components/data/ag-grid-react/chat/index.d.ts +6 -0
  45. package/dist/components/data/ag-grid-react/chat/index.js +24 -0
  46. package/dist/components/data/ag-grid-react/chat.story-data.d.ts +34 -0
  47. package/dist/components/data/ag-grid-react/chat.story-sources.d.ts +4 -0
  48. package/dist/components/data/ag-grid-react/comments/assets/comments-no-results.png.js +4 -0
  49. package/dist/components/data/ag-grid-react/comments/comment-mode-toggle.d.ts +6 -0
  50. package/dist/components/data/ag-grid-react/comments/comment-mode-toggle.js +29 -0
  51. package/dist/components/data/ag-grid-react/comments/comments-actions-menu.d.ts +8 -0
  52. package/dist/components/data/ag-grid-react/comments/comments-actions-menu.js +18 -0
  53. package/dist/components/data/ag-grid-react/comments/comments-ag-grid-presence.d.ts +18 -0
  54. package/dist/components/data/ag-grid-react/comments/comments-ag-grid-presence.js +16 -0
  55. package/dist/components/data/ag-grid-react/comments/comments-capabilities.d.ts +11 -0
  56. package/dist/components/data/ag-grid-react/comments/comments-capabilities.js +26 -0
  57. package/dist/components/data/ag-grid-react/comments/comments-constants.d.ts +12 -0
  58. package/dist/components/data/ag-grid-react/comments/comments-constants.js +21 -0
  59. package/dist/components/data/ag-grid-react/comments/comments-format.d.ts +20 -0
  60. package/dist/components/data/ag-grid-react/comments/comments-format.js +49 -0
  61. package/dist/components/data/ag-grid-react/comments/comments-generation.d.ts +14 -0
  62. package/dist/components/data/ag-grid-react/comments/comments-generation.js +18 -0
  63. package/dist/components/data/ag-grid-react/comments/comments-host.d.ts +10 -0
  64. package/dist/components/data/ag-grid-react/comments/comments-host.js +343 -0
  65. package/dist/components/data/ag-grid-react/comments/comments-host.types.d.ts +18 -0
  66. package/dist/components/data/ag-grid-react/comments/comments-identity.d.ts +7 -0
  67. package/dist/components/data/ag-grid-react/comments/comments-identity.js +20 -0
  68. package/dist/components/data/ag-grid-react/comments/comments-menu.d.ts +29 -0
  69. package/dist/components/data/ag-grid-react/comments/comments-menu.js +35 -0
  70. package/dist/components/data/ag-grid-react/comments/comments-overlay-anchor.d.ts +22 -0
  71. package/dist/components/data/ag-grid-react/comments/comments-overlay-anchor.js +98 -0
  72. package/dist/components/data/ag-grid-react/comments/comments-overlay.d.ts +21 -0
  73. package/dist/components/data/ag-grid-react/comments/comments-overlay.js +406 -0
  74. package/dist/components/data/ag-grid-react/comments/comments-panel.d.ts +9 -0
  75. package/dist/components/data/ag-grid-react/comments/comments-panel.js +272 -0
  76. package/dist/components/data/ag-grid-react/comments/comments-persist.d.ts +11 -0
  77. package/dist/components/data/ag-grid-react/comments/comments-persist.js +19 -0
  78. package/dist/components/data/ag-grid-react/comments/comments-reveal.d.ts +11 -0
  79. package/dist/components/data/ag-grid-react/comments/comments-reveal.js +31 -0
  80. package/dist/components/data/ag-grid-react/comments/comments-ui-actions.d.ts +18 -0
  81. package/dist/components/data/ag-grid-react/comments/comments-ui-actions.js +22 -0
  82. package/dist/components/data/ag-grid-react/comments/comments-window.d.ts +10 -0
  83. package/dist/components/data/ag-grid-react/comments/comments-window.js +62 -0
  84. package/dist/components/data/ag-grid-react/comments/comments.types.d.ts +178 -0
  85. package/dist/components/data/ag-grid-react/comments/index.d.ts +5 -0
  86. package/dist/components/data/ag-grid-react/comments/index.js +15 -0
  87. package/dist/components/data/ag-grid-react/comments-cell-renderers-showcase.d.ts +25 -0
  88. package/dist/components/data/ag-grid-react/comments.story-data.d.ts +37 -0
  89. package/dist/components/data/ag-grid-react/comments.story-sources.d.ts +11 -0
  90. package/dist/components/data/ag-grid-react/grid-cell-address.d.ts +21 -0
  91. package/dist/components/data/ag-grid-react/grid-cell-address.js +21 -0
  92. package/dist/components/data/ag-grid-react/grid-row-reveal.d.ts +34 -0
  93. package/dist/components/data/ag-grid-react/grid-row-reveal.js +33 -0
  94. package/dist/components/data/ag-grid-react/headers/advanced-filter/advanced-filter-dialog.js +75 -65
  95. package/dist/components/data/ag-grid-react/headers/advanced-filter/column-filter-section.d.ts +1 -1
  96. package/dist/components/data/ag-grid-react/headers/advanced-filter/column-filter-section.js +54 -54
  97. package/dist/components/data/ag-grid-react/headers/components/date-filter-picker.d.ts +1 -1
  98. package/dist/components/data/ag-grid-react/headers/header-search-input.js +122 -119
  99. package/dist/components/data/ag-grid-react/headers/utils/date-utils.d.ts +2 -1
  100. package/dist/components/data/ag-grid-react/headers/utils/date-utils.js +25 -20
  101. package/dist/components/data/ag-grid-react/headers/utils/filter-utils.d.ts +1 -1
  102. package/dist/components/data/ag-grid-react/index.d.ts +1 -1
  103. package/dist/components/data/ag-grid-react/index.js +481 -254
  104. package/dist/components/data/ag-grid-react/notes/index.d.ts +2 -0
  105. package/dist/components/data/ag-grid-react/notes/index.js +1 -0
  106. package/dist/components/data/ag-grid-react/notes/notes-ag-grid-adapter.d.ts +25 -0
  107. package/dist/components/data/ag-grid-react/notes/notes-ag-grid-adapter.js +32 -0
  108. package/dist/components/data/ag-grid-react/notes/notes-constants.d.ts +2 -0
  109. package/dist/components/data/ag-grid-react/notes/notes-constants.js +4 -0
  110. package/dist/components/data/ag-grid-react/notes/notes.types.d.ts +12 -0
  111. package/dist/components/data/ag-grid-react/notes.story-sources.d.ts +7 -0
  112. package/dist/components/data/ag-grid-react/nova-system-column.d.ts +7 -0
  113. package/dist/components/data/ag-grid-react/nova-system-column.js +18 -0
  114. package/dist/components/data/ag-grid-react/theme.js +6 -2
  115. package/dist/components/data/ag-grid-react/value-formatter.types.d.ts +4 -0
  116. package/dist/components/data/ag-grid-react/value-formatters.d.ts +0 -19
  117. package/dist/components/data/ag-grid-react/value-formatters.js +88 -90
  118. package/dist/components/data/data-table/build-column-tree-from-grid.d.ts +0 -1
  119. package/dist/components/data/data-table/build-column-tree-from-grid.js +49 -53
  120. package/dist/components/data/data-table/data-table-column-apply.d.ts +0 -2
  121. package/dist/components/data/data-table/data-table-column-apply.js +73 -84
  122. package/dist/components/data/data-table/data-table-column-def-pin.js +34 -31
  123. package/dist/components/data/data-table/data-table-column-list.js +64 -94
  124. package/dist/components/data/data-table/data-table-column-tree-cache.d.ts +6 -12
  125. package/dist/components/data/data-table/data-table-column-tree-cache.js +131 -250
  126. package/dist/components/data/data-table/data-table-context.js +5 -5
  127. package/dist/components/data/data-table/data-table-sheet-context.js +1 -1
  128. package/dist/components/data/data-table/data-table-sheet.js +2 -1
  129. package/dist/components/data/data-table/patch-column-tree-indicators-from-grid.d.ts +0 -5
  130. package/dist/components/data/data-table/patch-column-tree-indicators-from-grid.js +11 -28
  131. package/dist/components/data/data-table/use-data-table-column-list-sync.d.ts +0 -10
  132. package/dist/components/data/data-table/use-data-table-column-list-sync.js +196 -250
  133. package/dist/components/data/nested-list/components/NestedListContent.d.ts +2 -10
  134. package/dist/components/data/nested-list/components/NestedListContent.js +138 -253
  135. package/dist/components/data/nested-list/components/SortableItem.d.ts +1 -2
  136. package/dist/components/data/nested-list/components/SortableItem.js +60 -62
  137. package/dist/components/data/nested-list/hooks/useNestedListDragDrop.d.ts +20 -10
  138. package/dist/components/data/nested-list/hooks/useNestedListDragDrop.js +233 -44
  139. package/dist/components/data/nested-list/nested-list-constants.d.ts +1 -4
  140. package/dist/components/data/nested-list/nested-list-constants.js +4 -10
  141. package/dist/components/data/nested-list/nested-list.js +336 -322
  142. package/dist/components/data/nested-list/nested-list.types.d.ts +0 -17
  143. package/dist/components/data-display/calendar/calendar-config.js +22 -21
  144. package/dist/components/data-display/calendar/calendar-day-button.js +21 -21
  145. package/dist/components/data-display/calendar/calendar-day-picker-view.js +36 -35
  146. package/dist/components/data-display/calendar/calendar-fiscal-labels.d.ts +3 -3
  147. package/dist/components/data-display/calendar/calendar-fiscal-labels.js +50 -62
  148. package/dist/components/data-display/calendar/calendar.js +138 -137
  149. package/dist/components/data-display/calendar/fiscal-period-caption-select.js +23 -22
  150. package/dist/components/data-display/calendar/use-calendar-i18n.d.ts +1 -0
  151. package/dist/components/data-display/calendar/use-calendar-i18n.js +10 -9
  152. package/dist/components/data-display/chart/chart.js +72 -72
  153. package/dist/components/data-display/chart/chart.utils.d.ts +1 -1
  154. package/dist/components/data-display/chart/chart.utils.js +40 -31
  155. package/dist/components/feedback/sheet/sheet.js +1 -1
  156. package/dist/components/feedback/toast/toast.d.ts +1 -1
  157. package/dist/components/feedback/toast/toast.variants.d.ts +1 -1
  158. package/dist/components/flows/filter-panel/filter-panel.d.ts +1 -1
  159. package/dist/components/flows/filter-panel/filter-panel.js +65 -64
  160. package/dist/components/flows/filter-panel/filter-panel.types.d.ts +1 -0
  161. package/dist/components/forms/date-picker/date-picker.js +125 -126
  162. package/dist/components/forms/date-picker/date-range-picker.js +191 -192
  163. package/dist/components/forms/date-picker/multi-date-picker.js +66 -67
  164. package/dist/components/forms/date-picker/multi-week-picker.js +82 -83
  165. package/dist/components/forms/date-picker/use-picker-i18n.d.ts +6 -0
  166. package/dist/components/forms/date-picker/use-picker-i18n.js +11 -0
  167. package/dist/components/forms/date-picker/week-picker.js +146 -147
  168. package/dist/components/forms/date-picker/week-range-picker.js +158 -159
  169. package/dist/components/ui/local-raster-icons/message3d.webp.js +4 -0
  170. package/dist/components/ui/local-raster-icons/rasterIcons.d.ts +1 -0
  171. package/dist/components/ui/local-raster-icons/rasterIcons.js +27 -25
  172. package/dist/form-react/Fields/WeekRangePicker.js +16 -16
  173. package/dist/i18n/defaultMessages.d.ts +144 -0
  174. package/dist/i18n/defaultMessages.js +161 -19
  175. package/dist/i18n/format/collator.d.ts +1 -0
  176. package/dist/i18n/format/collator.js +7 -0
  177. package/dist/i18n/format/date-pattern.d.ts +5 -0
  178. package/dist/i18n/format/date-pattern.js +20 -0
  179. package/dist/i18n/format/format-date.d.ts +9 -0
  180. package/dist/i18n/format/format-date.js +56 -0
  181. package/dist/i18n/format/format-number.d.ts +20 -0
  182. package/dist/i18n/format/format-number.js +68 -0
  183. package/dist/i18n/format/formatter-cache.d.ts +9 -0
  184. package/dist/i18n/format/formatter-cache.js +66 -0
  185. package/dist/i18n/format/index.d.ts +6 -0
  186. package/dist/i18n/format/parse-number.d.ts +6 -0
  187. package/dist/i18n/format/parse-number.js +53 -0
  188. package/dist/i18n/getDateFnsLocale.d.ts +5 -4
  189. package/dist/i18n/getDateFnsLocale.js +46 -16
  190. package/dist/i18n/i18n.types.d.ts +13 -0
  191. package/dist/i18n/impact-nova-i18n-context.d.ts +1 -1
  192. package/dist/i18n/impact-nova-i18n-context.js +33 -25
  193. package/dist/i18n/impact-nova-i18n-defaults.js +8 -6
  194. package/dist/i18n/index.d.ts +4 -1
  195. package/dist/i18n/index.js +41 -16
  196. package/dist/i18n/locale-config.d.ts +28 -0
  197. package/dist/i18n/locale-config.js +32 -0
  198. package/dist/i18n/locales/de.js +142 -0
  199. package/dist/i18n/locales/es.js +142 -0
  200. package/dist/i18n/locales/hi.js +142 -0
  201. package/dist/i18n/locales/kn.js +142 -0
  202. package/dist/i18n/week-start.d.ts +6 -0
  203. package/dist/i18n/week-start.js +30 -0
  204. package/dist/impact-nova-components.css +249 -0
  205. package/dist/impact-nova-tokens.scss +6 -0
  206. package/dist/impact-nova.css +1 -1
  207. package/dist/index.d.ts +1 -1
  208. package/dist/index.js +624 -601
  209. package/dist/llms/index.js +26 -2
  210. package/dist/llms/rules/ag-grid.js +1 -1
  211. package/dist/llms/rules/best-practices.js +1 -1
  212. package/dist/llms/rules/data-table-chat.js +1 -0
  213. package/dist/llms/rules/data-table-comments.js +1 -0
  214. package/dist/llms/rules/data-table-notes.js +1 -0
  215. package/dist/llms/rules/installation.js +1 -1
  216. package/dist/llms/rules/migration.js +1 -1
  217. package/dist/llms/rules/real-world-patterns.js +1 -1
  218. package/dist/llms/rules/requirements.js +1 -1
  219. package/dist/llms/rules/troubleshooting.js +1 -1
  220. package/dist/providers/app-providers.d.ts +3 -1
  221. package/dist/providers/app-providers.js +22 -11
  222. package/package.json +13 -1
  223. package/dist/components/data/data-table/column-picker-authority.d.ts +0 -34
  224. package/dist/components/data/data-table/column-picker-authority.js +0 -116
  225. package/dist/components/data/data-table/column-picker-drop-validation.d.ts +0 -7
  226. package/dist/components/data/data-table/column-picker-drop-validation.js +0 -37
  227. package/dist/components/data/data-table/data-table-column-list-tree-apply.d.ts +0 -10
  228. package/dist/components/data/data-table/data-table-column-list-tree-apply.js +0 -79
  229. package/dist/components/data/data-table/data-table-flat-column-virtual-rows.d.ts +0 -26
  230. package/dist/components/data/data-table/data-table-flat-column-virtual-rows.js +0 -195
  231. package/dist/components/data/data-table/data-table-picker-column-eligibility.d.ts +0 -1
  232. package/dist/components/data/data-table/data-table-picker-column-eligibility.js +0 -7
  233. package/dist/components/data/data-table/reconcile-column-tree-from-grid.d.ts +0 -12
  234. package/dist/components/data/data-table/reconcile-column-tree-from-grid.js +0 -12
  235. package/dist/components/data/nested-list/hooks/useVirtualNestedListDrag.d.ts +0 -24
  236. package/dist/components/data/nested-list/hooks/useVirtualNestedListDrag.js +0 -128
  237. package/dist/components/data/nested-list/nested-list-display-utils.d.ts +0 -11
  238. package/dist/components/data/nested-list/nested-list-display-utils.js +0 -74
  239. package/dist/components/data/nested-list/nested-list-drop-engine.d.ts +0 -31
  240. package/dist/components/data/nested-list/nested-list-drop-engine.js +0 -209
  241. package/dist/components/data/nested-list/nested-list-flat-virtual-handlers.d.ts +0 -26
  242. package/dist/components/data/nested-list/nested-list-flat-virtual-handlers.js +0 -67
  243. package/dist/components/data/nested-list/nested-list-item-tree-mutations.d.ts +0 -4
  244. package/dist/components/data/nested-list/nested-list-item-tree-mutations.js +0 -43
  245. package/dist/components/data/nested-list/nested-list-lazy-flat-rows.d.ts +0 -3
  246. package/dist/components/data/nested-list/nested-list-lazy-flat-rows.js +0 -34
  247. package/dist/components/data/nested-list/nested-list-row-estimates.d.ts +0 -9
  248. package/dist/components/data/nested-list/nested-list-row-estimates.js +0 -14
  249. package/dist/components/data/nested-list/nested-list-scroll-anchor.d.ts +0 -36
  250. package/dist/components/data/nested-list/nested-list-scroll-anchor.js +0 -47
  251. package/dist/components/data/nested-list/nested-list-virtual-drop.d.ts +0 -59
  252. package/dist/components/data/nested-list/nested-list-virtual-drop.js +0 -341
  253. package/dist/lib/hash/fnv1a128.d.ts +0 -16
  254. package/dist/lib/hash/fnv1a128.js +0 -21
@@ -0,0 +1,651 @@
1
+ import { jsxs as tn, Fragment as on, jsx as M } from "react/jsx-runtime";
2
+ import { forwardRef as sn, useRef as Ie, useState as l, useCallback as u, useEffect as ge, useImperativeHandle as rn } from "react";
3
+ import { Button as an } from "../../../primitives/button/button.js";
4
+ import { toast as H } from "../../../../hooks/use-toast.js";
5
+ import { useImpactNovaI18n as dn } from "../../../../i18n/use-impact-nova-i18n.js";
6
+ import { subscribeGridApiEvents as cn } from "../grid-api-event-subscription.js";
7
+ import { revealGridRow as be } from "../grid-row-reveal.js";
8
+ import { ThreadGenerationMap as ln } from "../comments/comments-generation.js";
9
+ import { CHAT_PANEL_PAGE_SIZE as Me, CHAT_PANEL_WIDE_CLASS as un, CHAT_PANEL_SPLIT_CLASS as fn, CHAT_PANEL_CATALOG_CLASS as mn } from "./chat-constants.js";
10
+ import { resolveChatColumnId as vn } from "./chat-column.js";
11
+ import { chatAllows as V } from "./chat-capabilities.js";
12
+ import { resolveChatMembers as Pe, selectNewChatMembers as pn } from "./chat-format.js";
13
+ import { isValidChatMessageText as se, mintChatMessageId as re, mintConversationId as In, rowIdFromGridEvent as gn } from "./chat-identity.js";
14
+ import { commitChatPersist as G, chatPersistFailureKey as P } from "./chat-persist.js";
15
+ import { uniqueRowSummaries as Cn } from "./chat-summaries.js";
16
+ import { boundLoadedConversation as hn, chatThreadPageRequest as A, chatPinnedPageRequest as wn, chatReplyThreadRequest as yn } from "./chat-window.js";
17
+ import { ChatWorkspaceSheet as Sn, ChatConversationSidebar as Dn, ChatPanelHeader as Rn, ChatRowCatalog as Tn, ChatThreadPane as An } from "./chat-workspace.js";
18
+ const bn = ["modelUpdated", "filterChanged"];
19
+ function Ce(I, r) {
20
+ if (!I || I.isDestroyed()) return "missing";
21
+ const d = I.getRowNode(r);
22
+ return d ? d.rowIndex == null ? "filtered" : "ready" : "unloaded";
23
+ }
24
+ function he(I, r) {
25
+ !I || I.isDestroyed() || !r || I.refreshCells({ columns: [r], force: !0 });
26
+ }
27
+ function we(I, r, d) {
28
+ return {
29
+ conversationId: I.conversationId,
30
+ rowId: I.rowId,
31
+ title: r,
32
+ createdBy: d,
33
+ messages: [],
34
+ hasMoreOlder: !1,
35
+ hiddenCount: 0,
36
+ messageCount: 0,
37
+ notify: "mentions",
38
+ members: d ? [{ id: d, name: d }] : []
39
+ };
40
+ }
41
+ function Mn(I) {
42
+ return I.reduce((r, d) => r ? (d.updatedAt ?? "") > (r.updatedAt ?? "") ? d : r : d, void 0);
43
+ }
44
+ const Un = sn(function({ chat: r, gridApi: d }, Oe) {
45
+ const { t: c } = dn(), y = Ie(new ln()), ae = Ie(0), ie = Ie(!1), [b, de] = l(!1), [O, ce] = l("rows"), [t, le] = l(null), [ke, S] = l("ready"), [n, f] = l(null), [Ee, Le] = l([]), [Ne, x] = l([]), [z, ye] = l(""), [_e, ue] = l(!1), [Se, fe] = l(!1), [U, me] = l(!1), [He, g] = l(!1), [Ge, v] = l(null), [B, W] = l(""), [K, q] = l(void 0), [Z, F] = l([]), [xe, k] = l(!1), [J, E] = l(""), [C, L] = l(null), [De, N] = l([]), [Be, Re] = l(!1), [Q, _] = l(""), [We, X] = l(!1), [qe, Y] = l(""), [Fe, $] = l(null), h = vn(r), j = u(() => {
46
+ de(!1), ce("rows"), le(null), f(null), W(""), q(void 0), F([]), E(""), k(!1), L(null), N([]), _(""), X(!1), Y(""), $(null), v(null), ue(!1), fe(!1), me(!1), g(!1), S("ready");
47
+ }, []);
48
+ ge(() => {
49
+ const e = y.current;
50
+ return () => e.destroy();
51
+ }, []);
52
+ const w = u(
53
+ async (e, s, a = "replace") => {
54
+ const o = y.current.next(e.conversationId);
55
+ a === "replace" ? (f(
56
+ (i) => i?.conversationId === e.conversationId ? i : we(e, r.getRowTitle?.(e.rowId), r.getAuthor())
57
+ ), ue(!0)) : fe(!0), v(null);
58
+ try {
59
+ const i = await r.loadConversation(e, s);
60
+ if (!y.current.isCurrent(e.conversationId, o)) return;
61
+ if (!i) {
62
+ f(we(e, r.getRowTitle?.(e.rowId), r.getAuthor()));
63
+ return;
64
+ }
65
+ const m = hn(i, s);
66
+ f((R) => a === "prepend" && R?.conversationId === e.conversationId ? {
67
+ ...m,
68
+ messages: [...m.messages, ...R.messages],
69
+ hasMoreOlder: m.hasMoreOlder,
70
+ hiddenCount: m.hiddenCount
71
+ } : m);
72
+ } catch {
73
+ if (!y.current.isCurrent(e.conversationId, o)) return;
74
+ v(c("chat.loadError"));
75
+ } finally {
76
+ y.current.isCurrent(e.conversationId, o) && (ue(!1), fe(!1));
77
+ }
78
+ },
79
+ [r, c]
80
+ ), Te = u(
81
+ async (e) => {
82
+ const s = ++ae.current, a = Ce(d, e);
83
+ if (a === "ready") {
84
+ S("ready"), be(d, e, { colId: h });
85
+ return;
86
+ }
87
+ if (a === "filtered") {
88
+ S("filtered");
89
+ return;
90
+ }
91
+ if (!r.locateRow) {
92
+ S(a === "missing" ? "missing" : "unloaded");
93
+ return;
94
+ }
95
+ me(!0), S("locating");
96
+ try {
97
+ const o = await be(d, e, {
98
+ colId: h,
99
+ locateRow: r.locateRow,
100
+ pagination: d?.getGridOption?.("pagination") === !0
101
+ });
102
+ if (s !== ae.current) return;
103
+ if (o === "missing") {
104
+ S("missing");
105
+ return;
106
+ }
107
+ if (o === "filtered") {
108
+ S("filtered");
109
+ return;
110
+ }
111
+ if (o === "unloaded") {
112
+ S("unloaded");
113
+ return;
114
+ }
115
+ S(Ce(d, e));
116
+ } finally {
117
+ s === ae.current && me(!1);
118
+ }
119
+ },
120
+ [r.locateRow, h, d]
121
+ ), D = u(
122
+ async (e, s) => {
123
+ if (!r.getSummaries) {
124
+ x([]);
125
+ return;
126
+ }
127
+ try {
128
+ const o = [...(await r.getSummaries({
129
+ limit: Me,
130
+ query: { rowId: e }
131
+ })).items];
132
+ x(o);
133
+ const i = o.find((m) => m.conversationId === s) ?? Mn(o);
134
+ i ? w({ rowId: e, conversationId: i.conversationId }, A()) : f(null);
135
+ } catch {
136
+ v(c("chat.loadError"));
137
+ }
138
+ },
139
+ [r, w, c]
140
+ ), ee = u(
141
+ (e) => {
142
+ V(r, "view", { rowId: e }) && (de(!0), ce("row-chats"), le(e), W(""), q(void 0), F([]), k(!1), E(""), v(null), f(null), L(null), N([]), _(""), Y(""), X(!1), $(null), D(e), Te(e));
143
+ },
144
+ [r, D, Te]
145
+ ), ne = u(() => {
146
+ de(!0), ce("rows"), le(null), f(null), L(null), N([]), _(""), Y(""), X(!1), $(null), W(""), q(void 0), F([]), k(!1), E(""), v(null);
147
+ }, []), p = u(
148
+ async (e, s, a = { clearDraft: "main" }) => {
149
+ const o = e.rowId;
150
+ g(!0), v(null);
151
+ const i = await G({
152
+ persist: r.persist,
153
+ event: e,
154
+ generations: y.current,
155
+ conversationId: e.conversationId,
156
+ onApplied: () => he(d, h)
157
+ });
158
+ if (i === "stale") return i;
159
+ if (i === "rejected")
160
+ return g(!1), i;
161
+ if (i === "failed" || i === "conflict" || i === "denied") {
162
+ g(!1);
163
+ const m = c(P(i));
164
+ return v(m), s && f(s), H({ title: m }), i === "conflict" && w({ rowId: o, conversationId: e.conversationId }, A()), i;
165
+ }
166
+ return g(!1), a.clearDraft === "main" && (W(""), q(void 0), F([])), a.clearDraft === "thread" && _(""), w({ rowId: o, conversationId: e.conversationId }, A()), D(o, e.conversationId), i;
167
+ },
168
+ [r.persist, h, d, w, D, c]
169
+ ), T = u(
170
+ async (e, s) => {
171
+ Re(!0);
172
+ try {
173
+ const a = s.kind === "pinned" ? wn() : yn(s.parent.id), o = await r.loadConversation(e, a);
174
+ N(o?.messages ?? []);
175
+ } catch {
176
+ v(c("chat.loadError"));
177
+ } finally {
178
+ Re(!1);
179
+ }
180
+ },
181
+ [r, c]
182
+ ), te = u(() => {
183
+ L(null), N([]), _("");
184
+ }, []), je = u(() => {
185
+ const e = Z.length > 0;
186
+ if (!t || !n || !se(B) && !e) return;
187
+ const s = n, a = {
188
+ id: re(),
189
+ text: se(B) ? B.trim() : "",
190
+ author: r.getAuthor(),
191
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
192
+ ...K ? { priority: K } : {},
193
+ ...e ? { attachments: Z } : {}
194
+ };
195
+ f({
196
+ ...n,
197
+ messages: [...n.messages, a],
198
+ messageCount: (n.messageCount ?? n.messages.length) + 1
199
+ }), p(
200
+ { type: "add-message", rowId: t, conversationId: n.conversationId, message: a },
201
+ s
202
+ );
203
+ }, [r, n, B, Z, K, p, t]), Ve = u(() => {
204
+ if (!t || !n || C?.kind !== "thread" || !se(Q)) return;
205
+ const e = C.parent, s = n, a = {
206
+ id: re(),
207
+ text: Q.trim(),
208
+ author: r.getAuthor(),
209
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
210
+ parentId: e.id,
211
+ replyTo: e.deleted ? void 0 : { id: e.id, author: e.author, text: e.text }
212
+ };
213
+ N((o) => [...o, a]), f({
214
+ ...n,
215
+ messages: n.messages.map(
216
+ (o) => o.id === e.id ? { ...o, replyCount: (o.replyCount ?? 0) + 1 } : o
217
+ )
218
+ }), p(
219
+ { type: "add-message", rowId: t, conversationId: n.conversationId, message: a },
220
+ s,
221
+ { clearDraft: "thread" }
222
+ ).then(() => {
223
+ T({ rowId: t, conversationId: n.conversationId }, C);
224
+ });
225
+ }, [r, n, C, T, p, t, Q]), ze = u(() => {
226
+ if (!t || !n) return;
227
+ if (C?.kind === "pinned") {
228
+ te();
229
+ return;
230
+ }
231
+ const e = { kind: "pinned" };
232
+ L(e), T({ rowId: t, conversationId: n.conversationId }, e);
233
+ }, [te, n, C, T, t]), ve = u(
234
+ (e) => {
235
+ if (!t || !n) return;
236
+ const s = { kind: "thread", parent: e };
237
+ L(s), T({ rowId: t, conversationId: n.conversationId }, s);
238
+ },
239
+ [n, T, t]
240
+ ), Ue = u(
241
+ (e, s) => {
242
+ if (!t || !n) return;
243
+ const a = n;
244
+ f({
245
+ ...n,
246
+ messages: n.messages.map((o) => o.id === e.id ? { ...o, pinned: s } : o)
247
+ }), p(
248
+ { type: "pin-message", rowId: t, conversationId: n.conversationId, messageId: e.id, pinned: s },
249
+ a,
250
+ { clearDraft: !1 }
251
+ ).then(() => {
252
+ C?.kind === "pinned" && T({ rowId: t, conversationId: n.conversationId }, C);
253
+ });
254
+ },
255
+ [n, C, T, p, t]
256
+ ), Ke = u(
257
+ (e, s) => {
258
+ if (!t || !n || !se(s)) return;
259
+ const a = n, o = { ...e, text: s.trim(), updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
260
+ f({
261
+ ...n,
262
+ messages: n.messages.map((i) => i.id === e.id ? o : i)
263
+ }), p(
264
+ { type: "edit-message", rowId: t, conversationId: n.conversationId, message: o },
265
+ a,
266
+ { clearDraft: !1 }
267
+ );
268
+ },
269
+ [n, p, t]
270
+ ), Ze = u(
271
+ (e) => {
272
+ if (!t || !n) return;
273
+ const s = n;
274
+ f({
275
+ ...n,
276
+ messages: n.messages.map(
277
+ (a) => a.id === e.id ? { ...a, deleted: !0, text: "", pinned: !1 } : a
278
+ )
279
+ }), p(
280
+ { type: "delete-message", rowId: t, conversationId: n.conversationId, messageId: e.id },
281
+ s,
282
+ { clearDraft: !1 }
283
+ );
284
+ },
285
+ [n, p, t]
286
+ ), Je = u(
287
+ (e, s) => {
288
+ if (!t || !n) return;
289
+ const a = n;
290
+ f({
291
+ ...n,
292
+ messages: n.messages.map((o) => {
293
+ if (o.id !== e.id) return o;
294
+ if (s == null) {
295
+ const i = { ...o };
296
+ return delete i.priority, i;
297
+ }
298
+ return { ...o, priority: s };
299
+ })
300
+ }), p(
301
+ {
302
+ type: "set-priority",
303
+ rowId: t,
304
+ conversationId: n.conversationId,
305
+ priority: s,
306
+ messageId: e.id
307
+ },
308
+ a,
309
+ { clearDraft: !1 }
310
+ );
311
+ },
312
+ [n, p, t]
313
+ ), Qe = u(
314
+ async (e) => {
315
+ if (!t || !n) return;
316
+ const s = n, a = e.notify ?? "mentions";
317
+ f({
318
+ ...n,
319
+ notify: a,
320
+ includeBroadcast: e.includeBroadcast,
321
+ muted: e.muted
322
+ }), x(
323
+ (m) => m.map(
324
+ (R) => R.conversationId === n.conversationId ? { ...R, muted: e.muted } : R
325
+ )
326
+ ), g(!0), v(null);
327
+ const o = await G({
328
+ persist: r.persist,
329
+ event: {
330
+ type: "mute-conversation",
331
+ rowId: t,
332
+ conversationId: n.conversationId,
333
+ muted: e.muted
334
+ },
335
+ generations: y.current,
336
+ conversationId: n.conversationId,
337
+ onApplied: () => he(d, h)
338
+ });
339
+ if (o === "failed" || o === "conflict" || o === "denied") {
340
+ g(!1), f(s), v(c(o === "conflict" ? "chat.conflict" : "chat.saveError")), H({ title: c(P(o)) });
341
+ return;
342
+ }
343
+ const i = await G({
344
+ persist: r.persist,
345
+ event: {
346
+ type: "set-notify",
347
+ rowId: t,
348
+ conversationId: n.conversationId,
349
+ notify: a,
350
+ includeBroadcast: e.includeBroadcast
351
+ },
352
+ generations: y.current,
353
+ conversationId: n.conversationId
354
+ });
355
+ if (g(!1), i === "failed" || i === "conflict" || i === "denied") {
356
+ f(s), v(c(P(i))), H({ title: c(P(i)) });
357
+ return;
358
+ }
359
+ w({ rowId: t, conversationId: n.conversationId }, A()), D(t, n.conversationId);
360
+ },
361
+ [r.persist, h, n, d, w, D, t, c]
362
+ ), oe = u(
363
+ async (e, s) => {
364
+ if (!t || !n || ie.current) return;
365
+ ie.current = !0;
366
+ const a = n;
367
+ f({
368
+ ...n,
369
+ members: e,
370
+ messages: [...n.messages, ...s],
371
+ messageCount: (n.messageCount ?? n.messages.length) + s.length
372
+ }), g(!0), v(null);
373
+ try {
374
+ const o = await G({
375
+ persist: r.persist,
376
+ event: {
377
+ type: "set-members",
378
+ rowId: t,
379
+ conversationId: n.conversationId,
380
+ members: e
381
+ },
382
+ generations: y.current,
383
+ conversationId: n.conversationId
384
+ });
385
+ if (o === "failed" || o === "conflict" || o === "denied") {
386
+ g(!1), f(a);
387
+ const i = c(P(o));
388
+ v(i), H({ title: i });
389
+ return;
390
+ }
391
+ for (const i of s) {
392
+ const m = await G({
393
+ persist: r.persist,
394
+ event: { type: "add-message", rowId: t, conversationId: n.conversationId, message: i },
395
+ generations: y.current,
396
+ conversationId: n.conversationId,
397
+ onApplied: () => he(d, h)
398
+ });
399
+ if (m === "failed" || m === "conflict" || m === "denied") {
400
+ g(!1), f(a);
401
+ const R = c(P(m));
402
+ v(R), H({ title: R });
403
+ return;
404
+ }
405
+ }
406
+ g(!1), w({ rowId: t, conversationId: n.conversationId }, A()), D(t, n.conversationId);
407
+ } finally {
408
+ ie.current = !1;
409
+ }
410
+ },
411
+ [r.persist, h, n, d, w, D, t, c]
412
+ ), Xe = u(
413
+ (e) => {
414
+ if (!n || !t || !V(r, "invite", { rowId: t, conversationId: n.conversationId })) return;
415
+ const s = Pe(n), a = pn(e, s);
416
+ if (a.length === 0) return;
417
+ const o = a.map((i) => ({
418
+ id: re(),
419
+ text: c("chat.memberAdded", { name: i.name }),
420
+ author: r.getAuthor(),
421
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
422
+ system: !0
423
+ }));
424
+ oe([...s, ...a], o);
425
+ },
426
+ [oe, r, n, t, c]
427
+ ), Ye = u(
428
+ (e) => {
429
+ if (!n || !t || !V(r, "remove-member", { rowId: t, conversationId: n.conversationId, member: e })) return;
430
+ const s = Pe(n);
431
+ if (!s.some((i) => i.id === e.id || i.name === e.name)) return;
432
+ const a = s.filter((i) => i.id !== e.id && i.name !== e.name), o = {
433
+ id: re(),
434
+ text: c("chat.memberRemoved", { name: e.name }),
435
+ author: r.getAuthor(),
436
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
437
+ system: !0
438
+ };
439
+ oe(a, [o]);
440
+ },
441
+ [oe, r, n, t, c]
442
+ ), $e = u(
443
+ async (e, s) => {
444
+ if (!t || e.length === 0) return;
445
+ const a = n?.conversationId;
446
+ x(
447
+ (o) => o.map((i) => e.includes(i.conversationId) ? { ...i, muted: s } : i)
448
+ ), f(
449
+ (o) => o && e.includes(o.conversationId) ? { ...o, muted: s } : o
450
+ );
451
+ for (const o of e) {
452
+ const i = await G({
453
+ persist: r.persist,
454
+ event: { type: "mute-conversation", rowId: t, conversationId: o, muted: s },
455
+ generations: y.current,
456
+ conversationId: o
457
+ });
458
+ if (i === "failed" || i === "conflict" || i === "denied") {
459
+ H({ title: c(P(i)) }), D(t, a);
460
+ return;
461
+ }
462
+ }
463
+ },
464
+ [r.persist, n?.conversationId, D, t, c]
465
+ ), en = u(() => {
466
+ if (!t || J.trim().length < 2 || !V(r, "create", { rowId: t })) return;
467
+ const e = In(t), s = J.trim(), a = r.getAuthor(), o = a ? [{ id: a, name: a }] : [], i = we({ rowId: t, conversationId: e }, s, a);
468
+ f(i), x((m) => [
469
+ {
470
+ conversationId: e,
471
+ rowId: t,
472
+ title: s,
473
+ preview: "",
474
+ messageCount: 0,
475
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
476
+ },
477
+ ...m
478
+ ]), k(!1), E(""), p(
479
+ { type: "create-conversation", rowId: t, conversationId: e, title: s, members: o },
480
+ null
481
+ );
482
+ }, [r, J, p, t]);
483
+ rn(
484
+ Oe,
485
+ () => ({
486
+ onCellClicked(e) {
487
+ const s = gn(e), a = e.column?.getColId?.();
488
+ !s || !h || a !== h || ee(s);
489
+ },
490
+ openRow: ee,
491
+ openCatalog: ne,
492
+ close: j
493
+ }),
494
+ [h, j, ne, ee]
495
+ ), ge(() => {
496
+ if (!b || !t || !d) return;
497
+ const e = () => {
498
+ if (U) return;
499
+ const s = Ce(d, t);
500
+ S((a) => a === "missing" && s === "unloaded" ? a : s);
501
+ };
502
+ return e(), cn(d, bn, e);
503
+ }, [d, U, t, b]), ge(() => {
504
+ if (!b || O !== "rows" || !r.getSummaries) return;
505
+ let e = !1;
506
+ return r.getSummaries({ limit: Me, query: z.trim() ? { text: z.trim() } : void 0 }).then((s) => {
507
+ e || Le(Cn(s.items, r.getRowTitle));
508
+ }).catch(() => {
509
+ e || v(c("chat.loadError"));
510
+ }), () => {
511
+ e = !0;
512
+ };
513
+ }, [r, z, c, O, b]);
514
+ const Ae = t ? r.getRowTitle?.(t) ?? n?.title : void 0, nn = t ? V(r, "create", { rowId: t, conversationId: n?.conversationId }) : !1, pe = b ? O === "rows" ? /* @__PURE__ */ M(
515
+ Tn,
516
+ {
517
+ summaries: Ee,
518
+ search: z,
519
+ locating: U,
520
+ onSearchChange: ye,
521
+ onSearchSubmit: () => ye((e) => e.trim()),
522
+ onSelectRow: ee
523
+ }
524
+ ) : /* @__PURE__ */ M(
525
+ An,
526
+ {
527
+ rowId: t,
528
+ rowTitle: Ae,
529
+ rowStatus: ke,
530
+ conversation: n,
531
+ loading: _e,
532
+ loadingOlder: Se,
533
+ error: Ge,
534
+ saving: He,
535
+ draft: B,
536
+ draftPriority: K,
537
+ draftAttachments: Z,
538
+ drawer: C,
539
+ drawerMessages: De,
540
+ drawerLoading: Be,
541
+ threadDraft: Q,
542
+ searchOpen: We,
543
+ messageSearch: qe,
544
+ highlightedMessageId: Fe,
545
+ onDraftChange: W,
546
+ onDraftPriorityChange: (e) => q(e ?? void 0),
547
+ onDraftAttachmentsChange: (e) => F([...e]),
548
+ onSave: je,
549
+ onRetry: () => {
550
+ t && n && w({ rowId: t, conversationId: n.conversationId }, A());
551
+ },
552
+ onLoadOlder: () => {
553
+ const e = n?.messages[0];
554
+ !t || !e || Se || !n?.hasMoreOlder || w(
555
+ { rowId: t, conversationId: n.conversationId },
556
+ A(e.id),
557
+ "prepend"
558
+ );
559
+ },
560
+ onToggleSearch: () => X((e) => !e),
561
+ onMessageSearchChange: Y,
562
+ onOpenPinned: ze,
563
+ onOpenThread: ve,
564
+ onReply: ve,
565
+ onPin: Ue,
566
+ onEdit: Ke,
567
+ onDelete: Ze,
568
+ onSetPriority: Je,
569
+ onSaveNotify: Qe,
570
+ onAddMembers: Xe,
571
+ onRemoveMember: Ye,
572
+ onCloseDrawer: te,
573
+ onCloseWorkspace: j,
574
+ onSelectDrawerMessage: (e) => {
575
+ if ($(e), C?.kind === "pinned") {
576
+ const s = De.find((a) => a.id === e);
577
+ if (s?.parentId) {
578
+ const a = n?.messages.find((o) => o.id === s.parentId);
579
+ a && ve(a);
580
+ }
581
+ }
582
+ },
583
+ onThreadDraftChange: _,
584
+ onThreadSave: Ve,
585
+ config: r
586
+ }
587
+ ) : null;
588
+ return /* @__PURE__ */ tn(on, { children: [
589
+ r.getSummaries ? /* @__PURE__ */ M("div", { className: "pointer-events-none absolute right-3 top-3 z-20", children: /* @__PURE__ */ M(
590
+ an,
591
+ {
592
+ type: "button",
593
+ size: "sm",
594
+ variant: "outline",
595
+ className: "pointer-events-auto",
596
+ "data-iv-chat-panel-trigger": "",
597
+ onClick: ne,
598
+ children: c("chat.panelTitle")
599
+ }
600
+ ) }) : null,
601
+ /* @__PURE__ */ M(
602
+ Sn,
603
+ {
604
+ open: b,
605
+ onOpenChange: (e) => {
606
+ e || j();
607
+ },
608
+ description: c("chat.panelDescription"),
609
+ className: O === "row-chats" ? C ? un : fn : mn,
610
+ header: /* @__PURE__ */ M(
611
+ Rn,
612
+ {
613
+ view: O,
614
+ rowTitle: Ae,
615
+ rowId: t,
616
+ conversationId: n?.conversationId,
617
+ onBack: ne
618
+ }
619
+ ),
620
+ sidebar: O === "row-chats" && b ? /* @__PURE__ */ M(
621
+ Dn,
622
+ {
623
+ summaries: Ne,
624
+ selectedConversationId: n?.conversationId ?? null,
625
+ locating: U,
626
+ canCreate: nn,
627
+ naming: xe,
628
+ nameDraft: J,
629
+ rowId: t,
630
+ listActions: r.listActions,
631
+ onNameDraftChange: E,
632
+ onStartCreate: () => k(!0),
633
+ onCancelCreate: () => {
634
+ k(!1), E("");
635
+ },
636
+ onCreate: en,
637
+ onSelectConversation: (e) => {
638
+ t && (te(), w({ rowId: t, conversationId: e }, A()));
639
+ },
640
+ onMute: $e,
641
+ onCloseWorkspace: j
642
+ }
643
+ ) : void 0,
644
+ children: r.renderPanel && pe ? r.renderPanel({ children: pe }) : pe
645
+ }
646
+ )
647
+ ] });
648
+ });
649
+ export {
650
+ Un as ChatHost
651
+ };
@@ -0,0 +1,13 @@
1
+ export type ChatHostHandle = {
2
+ onCellClicked: (event: {
3
+ node?: {
4
+ id?: string | null;
5
+ } | null;
6
+ column?: {
7
+ getColId?: () => string;
8
+ } | null;
9
+ }) => void;
10
+ openRow: (rowId: string) => void;
11
+ openCatalog: () => void;
12
+ close: () => void;
13
+ };
@@ -0,0 +1,2 @@
1
+ export declare function sanitizeChatHtml(html: string): string;
2
+ export declare function chatLooksLikeHtml(value: string): boolean;
@@ -0,0 +1,40 @@
1
+ import { chatPlainText as a } from "./chat-identity.js";
2
+ const c = /* @__PURE__ */ new Set(["B", "STRONG", "I", "EM", "A", "BR", "P", "SPAN"]);
3
+ function s(t) {
4
+ const o = [...t.childNodes];
5
+ for (const n of o) {
6
+ if (n.nodeType === Node.TEXT_NODE) continue;
7
+ if (n.nodeType !== Node.ELEMENT_NODE) {
8
+ n.parentNode?.removeChild(n);
9
+ continue;
10
+ }
11
+ const e = n, i = e.tagName;
12
+ if (!c.has(i)) {
13
+ const r = e.parentNode;
14
+ for (; e.firstChild; ) r?.insertBefore(e.firstChild, e);
15
+ r?.removeChild(e);
16
+ continue;
17
+ }
18
+ for (const r of [...e.getAttributeNames()]) {
19
+ if (i === "A" && r === "href") {
20
+ const f = e.getAttribute("href") ?? "";
21
+ /^(https?:|mailto:)/i.test(f) ? e.setAttribute("rel", "noopener noreferrer") : e.removeAttribute("href"), e.setAttribute("target", "_blank");
22
+ continue;
23
+ }
24
+ e.removeAttribute(r);
25
+ }
26
+ s(e);
27
+ }
28
+ }
29
+ function h(t) {
30
+ if (typeof DOMParser > "u") return a(t);
31
+ const o = new DOMParser().parseFromString(t, "text/html");
32
+ return s(o.body), o.body.innerHTML;
33
+ }
34
+ function u(t) {
35
+ return /<[a-z][\s\S]*>/i.test(t);
36
+ }
37
+ export {
38
+ u as chatLooksLikeHtml,
39
+ h as sanitizeChatHtml
40
+ };