@solexllc/usx-react 0.11.0 → 1.0.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 (240) hide show
  1. package/README.md +31 -0
  2. package/dist/Popover-Bg4-2-cU.cjs +987 -0
  3. package/dist/Popover-CqHczzNE.js +988 -0
  4. package/dist/chat.cjs +1396 -0
  5. package/dist/chat.js +1396 -0
  6. package/dist/index.cjs +4412 -5247
  7. package/dist/index.js +140 -972
  8. package/package.json +9 -5
  9. package/src/chat.js +15 -0
  10. package/src/components/accordion/Accordion.tsx +9 -57
  11. package/src/components/accordion/accordion.django.html +10 -20
  12. package/src/components/accordion/config.json +8 -2
  13. package/src/components/accordion-item/AccordionItem.tsx +54 -0
  14. package/src/components/accordion-item/accordion-item.django.html +19 -0
  15. package/src/components/accordion-item/accordion-item.html +8 -0
  16. package/src/components/accordion-item/config.json +55 -0
  17. package/src/components/alert/alert.django-snapshot.html +4 -4
  18. package/src/components/avatar/Avatar.tsx +54 -16
  19. package/src/components/avatar/avatar.django-snapshot.html +118 -2
  20. package/src/components/avatar/avatar.django.html +2 -2
  21. package/src/components/avatar/avatar.html +25 -0
  22. package/src/components/avatar/avatar.react-snapshot.html +110 -3
  23. package/src/components/avatar/config.json +17 -17
  24. package/src/components/avatar-group/AvatarGroup.tsx +17 -15
  25. package/src/components/avatar-group/avatar-group.django-snapshot.html +196 -174
  26. package/src/components/avatar-group/avatar-group.django.html +1 -1
  27. package/src/components/avatar-group/avatar-group.react-snapshot.html +216 -165
  28. package/src/components/avatar-group/config.json +14 -8
  29. package/src/components/back-to-top/BackToTop.tsx +21 -57
  30. package/src/components/back-to-top/back-to-top.django-snapshot.html +101 -202
  31. package/src/components/back-to-top/back-to-top.django.html +11 -38
  32. package/src/components/back-to-top/back-to-top.html +22 -106
  33. package/src/components/back-to-top/back-to-top.react-snapshot.html +94 -148
  34. package/src/components/back-to-top/config.json +41 -10
  35. package/src/components/banner/banner.django-snapshot.html +2 -2
  36. package/src/components/button/Button.tsx +15 -3
  37. package/src/components/button/button.django-snapshot.html +82 -0
  38. package/src/components/button/button.django.html +5 -2
  39. package/src/components/button/button.react-snapshot.html +80 -0
  40. package/src/components/button/config.json +17 -3
  41. package/src/components/callout/callout.django.html +1 -1
  42. package/src/components/callout/config.json +7 -16
  43. package/src/components/card/card.django-snapshot.html +43 -0
  44. package/src/components/card/card.react-snapshot.html +36 -0
  45. package/src/components/character-count/CharacterCount.tsx +2 -0
  46. package/src/components/character-count/character-count.react-snapshot.html +7 -0
  47. package/src/components/chat/Chat.tsx +575 -0
  48. package/src/components/chat/README.md +174 -0
  49. package/src/components/chat/avatarProps.ts +32 -0
  50. package/src/components/chat/chat.django-snapshot.html +23579 -0
  51. package/src/components/chat/chat.django.html +75 -0
  52. package/src/components/chat/chat.html +116 -0
  53. package/src/components/chat/chat.react-snapshot.html +16895 -0
  54. package/src/components/chat/config.json +1241 -0
  55. package/src/components/chat-attachment/ChatAttachment.tsx +39 -0
  56. package/src/components/chat-attachment/chat-attachment.django.html +24 -0
  57. package/src/components/chat-attachment/chat-attachment.html +10 -0
  58. package/src/components/chat-attachment/config.json +27 -0
  59. package/src/components/chat-attachments/ChatAttachments.tsx +17 -0
  60. package/src/components/chat-attachments/chat-attachments.django-snapshot.html +58 -0
  61. package/src/components/chat-attachments/chat-attachments.django.html +10 -0
  62. package/src/components/chat-attachments/chat-attachments.html +14 -0
  63. package/src/components/chat-attachments/chat-attachments.react-snapshot.html +46 -0
  64. package/src/components/chat-attachments/config.json +25 -0
  65. package/src/components/chat-bubble/ChatBubble.tsx +39 -0
  66. package/src/components/chat-bubble/ChatFormattedText.tsx +138 -0
  67. package/src/components/chat-bubble/chat-bubble.django-snapshot.html +128 -0
  68. package/src/components/chat-bubble/chat-bubble.django.html +19 -0
  69. package/src/components/chat-bubble/chat-bubble.html +1 -0
  70. package/src/components/chat-bubble/chat-bubble.react-snapshot.html +118 -0
  71. package/src/components/chat-bubble/config.json +70 -0
  72. package/src/components/chat-composer/ChatComposer.tsx +213 -0
  73. package/src/components/chat-composer/README.md +15 -0
  74. package/src/components/chat-composer/chat-composer.django-snapshot.html +575 -0
  75. package/src/components/chat-composer/chat-composer.django.html +77 -0
  76. package/src/components/chat-composer/chat-composer.html +44 -0
  77. package/src/components/chat-composer/chat-composer.react-snapshot.html +519 -0
  78. package/src/components/chat-composer/chat-formatting.django.html +59 -0
  79. package/src/components/chat-composer/config.json +137 -0
  80. package/src/components/chat-context/ChatContext.tsx +46 -0
  81. package/src/components/chat-context/chat-context.django-snapshot.html +35 -0
  82. package/src/components/chat-context/chat-context.django.html +20 -0
  83. package/src/components/chat-context/chat-context.html +9 -0
  84. package/src/components/chat-context/chat-context.react-snapshot.html +30 -0
  85. package/src/components/chat-context/config.json +36 -0
  86. package/src/components/chat-controls/ChatControls.tsx +67 -0
  87. package/src/components/chat-controls/chat-controls.django-snapshot.html +114 -0
  88. package/src/components/chat-controls/chat-controls.django.html +36 -0
  89. package/src/components/chat-controls/chat-controls.html +11 -0
  90. package/src/components/chat-controls/chat-controls.react-snapshot.html +107 -0
  91. package/src/components/chat-controls/config.json +67 -0
  92. package/src/components/chat-directory/ChatDirectory.tsx +168 -0
  93. package/src/components/chat-directory/chat-directory.django-snapshot.html +546 -0
  94. package/src/components/chat-directory/chat-directory.django.html +14 -0
  95. package/src/components/chat-directory/chat-directory.html +4 -0
  96. package/src/components/chat-directory/chat-directory.react-snapshot.html +471 -0
  97. package/src/components/chat-directory/config.json +242 -0
  98. package/src/components/chat-directory-item/ChatDirectoryItem.tsx +150 -0
  99. package/src/components/chat-directory-item/chat-directory-item.django-snapshot.html +281 -0
  100. package/src/components/chat-directory-item/chat-directory-item.django.html +38 -0
  101. package/src/components/chat-directory-item/chat-directory-item.html +9 -0
  102. package/src/components/chat-directory-item/chat-directory-item.react-snapshot.html +249 -0
  103. package/src/components/chat-directory-item/config.json +103 -0
  104. package/src/components/chat-history/ChatHistory.tsx +30 -0
  105. package/src/components/chat-history/chat-history.django-snapshot.html +113 -0
  106. package/src/components/chat-history/chat-history.django.html +20 -0
  107. package/src/components/chat-history/chat-history.html +9 -0
  108. package/src/components/chat-history/chat-history.react-snapshot.html +111 -0
  109. package/src/components/chat-history/config.json +24 -0
  110. package/src/components/chat-message/ChatMessage.tsx +148 -0
  111. package/src/components/chat-message/chat-message.django-snapshot.html +758 -0
  112. package/src/components/chat-message/chat-message.django.html +56 -0
  113. package/src/components/chat-message/chat-message.html +12 -0
  114. package/src/components/chat-message/chat-message.react-snapshot.html +627 -0
  115. package/src/components/chat-message/config.json +278 -0
  116. package/src/components/chat-message-actions/ChatMessageActions.tsx +133 -0
  117. package/src/components/chat-message-actions/chat-message-actions.django-snapshot.html +345 -0
  118. package/src/components/chat-message-actions/chat-message-actions.django.html +29 -0
  119. package/src/components/chat-message-actions/chat-message-actions.html +53 -0
  120. package/src/components/chat-message-actions/chat-message-actions.react-snapshot.html +295 -0
  121. package/src/components/chat-message-actions/config.json +121 -0
  122. package/src/components/chat-window/ChatWindow.tsx +135 -0
  123. package/src/components/chat-window/chat-window.django-snapshot.html +450 -0
  124. package/src/components/chat-window/chat-window.django.html +39 -0
  125. package/src/components/chat-window/chat-window.html +26 -0
  126. package/src/components/chat-window/chat-window.react-snapshot.html +286 -0
  127. package/src/components/chat-window/config.json +123 -0
  128. package/src/components/checkbox/checkbox.django-snapshot.html +2 -2
  129. package/src/components/clickable/Clickable.tsx +19 -5
  130. package/src/components/clickable/clickable.django-snapshot.html +11 -2
  131. package/src/components/clickable/clickable.django.html +2 -0
  132. package/src/components/clickable/clickable.react-snapshot.html +10 -2
  133. package/src/components/clickable/config.json +4 -0
  134. package/src/components/code/code.django-snapshot.html +25 -18
  135. package/src/components/code/code.react-snapshot.html +41 -4
  136. package/src/components/copy-to-clipboard/CopyToClipboard.tsx +2 -7
  137. package/src/components/copy-to-clipboard/copy-to-clipboard.django-snapshot.html +6 -4
  138. package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +3 -2
  139. package/src/components/copy-to-clipboard/copy-to-clipboard.react-snapshot.html +14 -2
  140. package/src/components/data-table/data-table.django-snapshot.html +4 -5
  141. package/src/components/data-table/data-table.react-snapshot.html +4 -4
  142. package/src/components/drawer/drawer.django-snapshot.html +53 -30
  143. package/src/components/error-page/error-page.django-snapshot.html +20 -7
  144. package/src/components/fieldset/fieldset.django-snapshot.html +1 -6
  145. package/src/components/file-list/FileList.tsx +3 -2
  146. package/src/components/file-list/config.json +5 -0
  147. package/src/components/file-list/file-list.django-snapshot.html +63 -0
  148. package/src/components/file-list/file-list.django.html +1 -1
  149. package/src/components/file-list/file-list.react-snapshot.html +53 -0
  150. package/src/components/footer/footer.django-snapshot.html +0 -3
  151. package/src/components/form-group/form-group.django-snapshot.html +0 -2
  152. package/src/components/header/header.django-snapshot.html +3 -163
  153. package/src/components/header/header.django.html +2 -2
  154. package/src/components/header/header.html +1 -1
  155. package/src/components/header/header.react-snapshot.html +3 -3
  156. package/src/components/hero/hero.django-snapshot.html +0 -20
  157. package/src/components/hero/hero.django.html +3 -3
  158. package/src/components/identifier/config.json +4 -2
  159. package/src/components/identifier/identifier.django-snapshot.html +13 -16
  160. package/src/components/identifier/identifier.react-snapshot.html +13 -15
  161. package/src/components/image/image.django-snapshot.html +6 -6
  162. package/src/components/image/image.django.html +4 -4
  163. package/src/components/input/Input.tsx +1 -1
  164. package/src/components/input/config.json +2 -3
  165. package/src/components/input/input.django-snapshot.html +4 -21
  166. package/src/components/input/input.django.html +2 -2
  167. package/src/components/layout/layout.django-snapshot.html +2 -0
  168. package/src/components/link/Link.tsx +7 -4
  169. package/src/components/link/config.json +2 -3
  170. package/src/components/link/link.django-snapshot.html +8 -0
  171. package/src/components/link/link.django.html +2 -2
  172. package/src/components/link/link.html +4 -1
  173. package/src/components/link/link.react-snapshot.html +8 -0
  174. package/src/components/memorable-date/memorable-date.django-snapshot.html +0 -8
  175. package/src/components/memorable-date/memorable-date.django.html +2 -2
  176. package/src/components/misc-banner/misc-banner.django-snapshot.html +12 -12
  177. package/src/components/misc-banner/misc-banner.django.html +4 -2
  178. package/src/components/modal/Modal.tsx +4 -3
  179. package/src/components/modal/config.json +3 -2
  180. package/src/components/modal/modal.django-snapshot.html +70 -14
  181. package/src/components/modal/modal.django.html +7 -9
  182. package/src/components/modal/modal.html +4 -4
  183. package/src/components/modal/modal.react-snapshot.html +64 -4
  184. package/src/components/page/Page.tsx +10 -7
  185. package/src/components/page/page.django-snapshot.html +5 -8
  186. package/src/components/page/page.django.html +2 -2
  187. package/src/components/page/page.html +1 -2
  188. package/src/components/page/page.react-snapshot.html +5 -8
  189. package/src/components/pagination/navigation/PaginationNavigation.tsx +2 -0
  190. package/src/components/pagination/navigation/pagination-navigation.django.html +2 -0
  191. package/src/components/pagination/pagination.django-snapshot.html +62 -0
  192. package/src/components/pagination/pagination.django.html +3 -1
  193. package/src/components/pagination/pagination.html +46 -0
  194. package/src/components/pagination/pagination.react-snapshot.html +48 -0
  195. package/src/components/pagination/summary/PaginationSummary.tsx +1 -1
  196. package/src/components/pagination/summary/pagination-summary.django.html +1 -1
  197. package/src/components/popover/Popover.tsx +61 -9
  198. package/src/components/popover/PopoverMenu.tsx +33 -15
  199. package/src/components/popover/config.json +88 -14
  200. package/src/components/popover/popover-menu.django.html +13 -2
  201. package/src/components/popover/popover.django-snapshot.html +265 -7
  202. package/src/components/popover/popover.django.html +3 -2
  203. package/src/components/popover/popover.react-snapshot.html +154 -4
  204. package/src/components/process-list/config.json +41 -3
  205. package/src/components/quote/Quote.tsx +9 -2
  206. package/src/components/search/Search.tsx +1 -1
  207. package/src/components/search/config.json +3 -4
  208. package/src/components/search/search.django-snapshot.html +262 -1684
  209. package/src/components/search/search.django.html +1 -20
  210. package/src/components/section/Section.tsx +3 -1
  211. package/src/components/select/select.django-snapshot.html +7 -7
  212. package/src/components/select/select.react-snapshot.html +7 -7
  213. package/src/components/site-alert/site-alert.django-snapshot.html +8 -8
  214. package/src/components/summary/Summary.tsx +4 -2
  215. package/src/components/summary/config.json +4 -0
  216. package/src/components/summary/summary.django.html +4 -4
  217. package/src/components/swap/Swap.tsx +35 -3
  218. package/src/components/swap/config.json +28 -1
  219. package/src/components/swap/swap.django-snapshot.html +29 -7
  220. package/src/components/swap/swap.django.html +15 -1
  221. package/src/components/swap/swap.react-snapshot.html +34 -4
  222. package/src/components/table/Table.tsx +58 -25
  223. package/src/components/table/config.json +61 -13
  224. package/src/components/tag/Tag.tsx +40 -7
  225. package/src/components/tag/config.json +18 -2
  226. package/src/components/tag/tag.django-snapshot.html +16 -1
  227. package/src/components/tag/tag.django.html +12 -6
  228. package/src/components/tag/tag.html +4 -0
  229. package/src/components/tag/tag.react-snapshot.html +16 -1
  230. package/src/components/tag-group/TagGroup.tsx +6 -9
  231. package/src/components/tag-group/config.json +4 -0
  232. package/src/components/tag-group/tag-group.django.html +1 -1
  233. package/src/components/theme-picker/ThemePicker.tsx +48 -42
  234. package/src/components/theme-picker/config.json +27 -29
  235. package/src/components/theme-picker/theme-picker-select.django.html +1 -1
  236. package/src/components/theme-picker/theme-picker.django-snapshot.html +283 -78
  237. package/src/components/theme-picker/theme-picker.django.html +24 -11
  238. package/src/components/theme-picker/theme-picker.html +155 -54
  239. package/src/components/theme-picker/theme-picker.react-snapshot.html +265 -67
  240. package/src/index.js +1 -0
package/dist/chat.js ADDED
@@ -0,0 +1,1396 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { P as Popover, B as Button, I as Icon, C as ClassNames$1, a as Image, e as TagGroup, A as Avatar, i as Alert, m as getDefaultExportFromCjs, k as AvatarGroup, T as Tag, j as Clickable, h as Callout, f as Link, b as ButtonGroup, c as TextArea } from "./Popover-CqHczzNE.js";
3
+ import React from "react";
4
+ function ChatWindow({
5
+ id,
6
+ title = "Chat",
7
+ view = "conversation",
8
+ status,
9
+ showBack = false,
10
+ showNewMessage = false,
11
+ showCopyAction = false,
12
+ conversationId,
13
+ conversationActions = [],
14
+ actions,
15
+ children,
16
+ summaryProps,
17
+ side = "bottom",
18
+ align = "start",
19
+ defaultOpen = false,
20
+ className
21
+ }) {
22
+ return /* @__PURE__ */ jsx(
23
+ Popover,
24
+ {
25
+ id,
26
+ side,
27
+ align,
28
+ panelShape: "square",
29
+ defaultOpen,
30
+ dismissOnOutside: false,
31
+ className: ClassNames$1("usx-chat", className),
32
+ panelClassName: "usx-chat__panel",
33
+ contentClassName: "usx-chat__popover-content",
34
+ headerClassName: "usx-chat__header",
35
+ panelHeading: title,
36
+ headingAs: "h2",
37
+ panelHeadingId: `${id}-title`,
38
+ headerLeftActions: showBack && /* @__PURE__ */ jsx(
39
+ Button,
40
+ {
41
+ variant: "unstyled",
42
+ tighten: true,
43
+ className: "usx-popover__header-action",
44
+ "aria-label": view === "thread" ? "Back to conversation" : "Back",
45
+ iconProps: [{ name: "arrow_back" }],
46
+ extraAttributes: { "data-usx-chat-back": "" }
47
+ }
48
+ ),
49
+ headerRightActions: /* @__PURE__ */ jsxs(Fragment, { children: [
50
+ showNewMessage && /* @__PURE__ */ jsx(
51
+ Button,
52
+ {
53
+ variant: "unstyled",
54
+ tighten: true,
55
+ className: "usx-popover__header-action",
56
+ "aria-label": "New message",
57
+ iconProps: [{ name: "add" }],
58
+ extraAttributes: { "data-usx-chat-new": "" }
59
+ }
60
+ ),
61
+ (showCopyAction || conversationActions.length > 0 || Boolean(actions)) && /* @__PURE__ */ jsx(
62
+ Popover,
63
+ {
64
+ id: `${id}-conversation-actions`,
65
+ className: "usx-chat__actions",
66
+ side: "bottom",
67
+ align: "end",
68
+ panelShape: "square",
69
+ panelClassName: "usx-chat__actions-menu",
70
+ menuItems: [
71
+ ...showCopyAction ? [
72
+ {
73
+ text: "Copy conversation",
74
+ type: "button",
75
+ icon: { name: "content_copy" },
76
+ extraAttributes: { "data-usx-chat-copy": "" }
77
+ }
78
+ ] : [],
79
+ ...conversationActions.map((action) => ({
80
+ id: action.id,
81
+ type: "button",
82
+ text: action.label,
83
+ disabled: action.disabled,
84
+ extraAttributes: {
85
+ "data-usx-chat-directory-action": action.id,
86
+ ...conversationId ? { "data-usx-chat-conversation-id": conversationId } : {}
87
+ }
88
+ }))
89
+ ],
90
+ summaryProps: {
91
+ ariaLabel: "Conversation actions",
92
+ className: "usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action",
93
+ children: /* @__PURE__ */ jsx(Icon, { name: "more_vert" })
94
+ },
95
+ children: actions
96
+ }
97
+ )
98
+ ] }),
99
+ showCloseIcon: true,
100
+ closeIconLabel: "Close chat",
101
+ summaryProps: { label: "Open chat", ...summaryProps },
102
+ children: /* @__PURE__ */ jsxs("section", { className: "usx-chat__window", "aria-labelledby": `${id}-title`, "data-chat-view": view, children: [
103
+ /* @__PURE__ */ jsx("span", { className: "usx-chat__copy-status usa-sr-only", role: "status", "aria-live": "polite" }),
104
+ status && /* @__PURE__ */ jsx("p", { className: "usx-chat__status", children: status }),
105
+ children
106
+ ] })
107
+ }
108
+ );
109
+ }
110
+ function chatAvatarProps(participant, name, statusRingColor, statusLabel, tooltipProps) {
111
+ var _a, _b, _c, _d;
112
+ const initials = name.trim().split(/\s+/).slice(0, 2).map((part) => Array.from(part)[0] || "").join("").toUpperCase();
113
+ return {
114
+ variant: "initials",
115
+ value: initials,
116
+ alt: name,
117
+ shape: "circle",
118
+ contentClassName: "bg-primary-light text-inverse",
119
+ ...participant == null ? void 0 : participant.avatarProps,
120
+ statusRingColor: statusRingColor ?? ((_a = participant == null ? void 0 : participant.avatarProps) == null ? void 0 : _a.statusRingColor),
121
+ statusLabel: statusLabel ?? ((_b = participant == null ? void 0 : participant.avatarProps) == null ? void 0 : _b.statusLabel),
122
+ tooltipProps: tooltipProps ?? ((_c = participant == null ? void 0 : participant.avatarProps) == null ? void 0 : _c.tooltipProps),
123
+ className: ClassNames$1("usx-chat__avatar", (_d = participant == null ? void 0 : participant.avatarProps) == null ? void 0 : _d.className)
124
+ };
125
+ }
126
+ function ChatAttachment({ name, url, imageUrl, alt }) {
127
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
128
+ imageUrl ? /* @__PURE__ */ jsx(
129
+ Image,
130
+ {
131
+ src: imageUrl,
132
+ alt: alt ?? name,
133
+ className: "usx-chat__attachment-image maxw-card",
134
+ objectFit: "cover",
135
+ rounded: true
136
+ }
137
+ ) : /* @__PURE__ */ jsx(Icon, { name: "attach_file" }),
138
+ /* @__PURE__ */ jsx("span", { children: name })
139
+ ] });
140
+ return /* @__PURE__ */ jsx("li", { children: url ? /* @__PURE__ */ jsx(Button, { href: url, download: name, variant: "unstyled", children: content }) : /* @__PURE__ */ jsx("div", { children: content }) });
141
+ }
142
+ function ChatAttachments({ items = [] }) {
143
+ if (!items.length) return null;
144
+ return /* @__PURE__ */ jsx("ul", { className: "usx-chat__attachments", children: items.map((item, index) => /* @__PURE__ */ jsx(ChatAttachment, { ...item }, index)) });
145
+ }
146
+ function inline(value) {
147
+ const pattern = /(\*\*([^*\n]+)\*\*|\*([^*\n]+)\*|<u>([^<\n]+)<\/u>|~~([^~\n]+)~~|`([^`\n]+)`)/g;
148
+ const parts = [];
149
+ let cursor = 0;
150
+ for (const match of value.matchAll(pattern)) {
151
+ const at = match.index ?? 0;
152
+ if (at > cursor) parts.push(value.slice(cursor, at));
153
+ const key = parts.length;
154
+ if (match[2]) parts.push(/* @__PURE__ */ jsx("strong", { children: match[2] }, key));
155
+ else if (match[3]) parts.push(/* @__PURE__ */ jsx("em", { children: match[3] }, key));
156
+ else if (match[4]) parts.push(/* @__PURE__ */ jsx("u", { children: match[4] }, key));
157
+ else if (match[5]) parts.push(/* @__PURE__ */ jsx("s", { children: match[5] }, key));
158
+ else parts.push(/* @__PURE__ */ jsx("code", { children: match[6] }, key));
159
+ cursor = at + match[0].length;
160
+ }
161
+ if (cursor < value.length) parts.push(value.slice(cursor));
162
+ return parts;
163
+ }
164
+ function quotePrefix(line) {
165
+ let offset = 0;
166
+ let depth = 0;
167
+ while (line[offset] === ">") {
168
+ depth += 1;
169
+ offset += 1;
170
+ while (line[offset] === " " || line[offset] === " ") offset += 1;
171
+ }
172
+ return { depth, content: line.slice(offset) };
173
+ }
174
+ function quotedBlock(lines) {
175
+ const root = { children: [] };
176
+ const stack = [root];
177
+ for (const line of lines) {
178
+ const { depth, content } = quotePrefix(line);
179
+ while (stack.length - 1 > depth) stack.pop();
180
+ while (stack.length - 1 < depth) {
181
+ const child = { children: [] };
182
+ stack[stack.length - 1].children.push(child);
183
+ stack.push(child);
184
+ }
185
+ stack[stack.length - 1].children.push(content);
186
+ }
187
+ const rendered = /* @__PURE__ */ new WeakMap();
188
+ const pending = [{ node: root, ready: false }];
189
+ while (pending.length) {
190
+ const item = pending.pop();
191
+ if (!item.ready) {
192
+ pending.push({ node: item.node, ready: true });
193
+ for (let index = item.node.children.length - 1; index >= 0; index -= 1) {
194
+ const child = item.node.children[index];
195
+ if (typeof child !== "string") pending.push({ node: child, ready: false });
196
+ }
197
+ continue;
198
+ }
199
+ rendered.set(
200
+ item.node,
201
+ /* @__PURE__ */ jsx("blockquote", { children: item.node.children.map(
202
+ (child, index) => typeof child === "string" ? /* @__PURE__ */ jsx("p", { children: inline(child) }, index) : /* @__PURE__ */ jsx(React.Fragment, { children: rendered.get(child) }, index)
203
+ ) })
204
+ );
205
+ }
206
+ return root.children.map((child, index) => /* @__PURE__ */ jsx(React.Fragment, { children: rendered.get(child) }, index));
207
+ }
208
+ function ChatFormattedText({ text }) {
209
+ const lines = text.split("\n");
210
+ const blocks = [];
211
+ let index = 0;
212
+ while (index < lines.length) {
213
+ const line = lines[index];
214
+ if (!line.trim()) {
215
+ index += 1;
216
+ continue;
217
+ }
218
+ const key = blocks.length;
219
+ if (/^```/.test(line)) {
220
+ const code = [];
221
+ index += 1;
222
+ while (index < lines.length && !/^```\s*$/.test(lines[index])) code.push(lines[index++]);
223
+ if (index < lines.length) index += 1;
224
+ blocks.push(
225
+ /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: code.join("\n") }) }, key)
226
+ );
227
+ continue;
228
+ }
229
+ if (quotePrefix(line).depth) {
230
+ const quoted = [];
231
+ while (index < lines.length && quotePrefix(lines[index]).depth) quoted.push(lines[index++]);
232
+ blocks.push(/* @__PURE__ */ jsx(React.Fragment, { children: quotedBlock(quoted) }, key));
233
+ continue;
234
+ }
235
+ const ordered = /^\d+\. /.test(line);
236
+ const unordered = /^[-*] /.test(line);
237
+ if (ordered || unordered) {
238
+ const items = [];
239
+ const itemPattern = ordered ? /^\d+\. / : /^[-*] /;
240
+ while (index < lines.length && itemPattern.test(lines[index])) {
241
+ items.push(/* @__PURE__ */ jsx("li", { children: inline(lines[index++].replace(itemPattern, "")) }, items.length));
242
+ }
243
+ blocks.push(ordered ? /* @__PURE__ */ jsx("ol", { children: items }, key) : /* @__PURE__ */ jsx("ul", { children: items }, key));
244
+ continue;
245
+ }
246
+ const paragraph = [];
247
+ while (index < lines.length && lines[index].trim() && !/^(?:```|> ?|\d+\. |[-*] )/.test(lines[index]))
248
+ paragraph.push(lines[index++]);
249
+ blocks.push(
250
+ /* @__PURE__ */ jsx("p", { children: paragraph.map((part, partIndex) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
251
+ partIndex > 0 && /* @__PURE__ */ jsx("br", {}),
252
+ inline(part)
253
+ ] }, partIndex)) }, key)
254
+ );
255
+ }
256
+ return /* @__PURE__ */ jsx(Fragment, { children: blocks });
257
+ }
258
+ function ChatBubble({ text, content, attachments, reactions }) {
259
+ return /* @__PURE__ */ jsxs("div", { className: "usx-chat__bubble", children: [
260
+ content ?? (text && /* @__PURE__ */ jsx(ChatFormattedText, { text })),
261
+ /* @__PURE__ */ jsx(ChatAttachments, { items: attachments }),
262
+ (reactions == null ? void 0 : reactions.length) ? /* @__PURE__ */ jsx(
263
+ TagGroup,
264
+ {
265
+ className: "usx-chat__reactions",
266
+ extraAttributes: { role: "group", "aria-label": "Reactions" },
267
+ children: reactions.map((reaction) => /* @__PURE__ */ jsxs(
268
+ Button,
269
+ {
270
+ variant: "unstyled",
271
+ className: "usa-tag usx-tag usx-tag--outline usx-tag--interactive usa-link usx-link usx-no-visited usx-chat__reaction",
272
+ extraAttributes: { "data-usx-chat-reaction": reaction.label },
273
+ "aria-pressed": Boolean(reaction.selected),
274
+ "aria-label": `${reaction.label}, ${reaction.count}`,
275
+ children: [
276
+ reaction.emoji,
277
+ " ",
278
+ reaction.count
279
+ ]
280
+ },
281
+ reaction.label
282
+ ))
283
+ }
284
+ ) : null
285
+ ] });
286
+ }
287
+ function ChatMessageActions({
288
+ id,
289
+ messageId,
290
+ senderName,
291
+ reactions,
292
+ reactionOptions = [],
293
+ actions = [],
294
+ canCopy = false,
295
+ canReply = false,
296
+ canForward = false
297
+ }) {
298
+ const hasOverflow = canCopy || actions.length > 0;
299
+ const hasMessageTools = reactionOptions.length > 0 || canReply || canForward || hasOverflow;
300
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
301
+ " ",
302
+ hasMessageTools && /* @__PURE__ */ jsxs(
303
+ "div",
304
+ {
305
+ className: "usx-chat__message-tools",
306
+ role: "group",
307
+ "aria-label": `Actions for message from ${senderName}`,
308
+ children: [
309
+ reactionOptions.length > 0 && /* @__PURE__ */ jsx(
310
+ Popover,
311
+ {
312
+ id: `${id}-reactions-${messageId}`,
313
+ side: "top",
314
+ align: "end",
315
+ panelShape: "square",
316
+ className: "usx-chat__message-actions usx-chat__reaction-actions",
317
+ menuItems: reactionOptions.map((option) => {
318
+ const current = reactions == null ? void 0 : reactions.find((reaction) => reaction.label === option.label);
319
+ return {
320
+ id: option.label,
321
+ type: "button",
322
+ text: option.emoji,
323
+ extraAttributes: {
324
+ "aria-label": option.label,
325
+ title: "name" in option && option.name ? `:${option.name}:` : option.label,
326
+ "aria-pressed": Boolean(current == null ? void 0 : current.selected),
327
+ "data-usx-chat-reaction": option.label
328
+ }
329
+ };
330
+ }),
331
+ summaryProps: {
332
+ ariaLabel: `React to message from ${senderName}`,
333
+ title: "Add reaction",
334
+ className: "usa-button usx-button usa-button--unstyled",
335
+ children: /* @__PURE__ */ jsx(Icon, { name: "sentiment_satisfied" })
336
+ }
337
+ }
338
+ ),
339
+ canReply && /* @__PURE__ */ jsx(
340
+ Button,
341
+ {
342
+ variant: "unstyled",
343
+ className: "usx-chat__tool-button",
344
+ title: "Reply in thread",
345
+ "aria-label": `Reply in thread to message from ${senderName}`,
346
+ "data-usx-chat-thread": messageId,
347
+ children: /* @__PURE__ */ jsx(Icon, { name: "comment" })
348
+ }
349
+ ),
350
+ canForward && /* @__PURE__ */ jsx(
351
+ Button,
352
+ {
353
+ variant: "unstyled",
354
+ className: "usx-chat__tool-button",
355
+ title: "Forward message",
356
+ "aria-label": `Forward message from ${senderName}`,
357
+ "data-usx-chat-forward": messageId,
358
+ children: /* @__PURE__ */ jsx(Icon, { name: "arrow_forward" })
359
+ }
360
+ ),
361
+ hasOverflow && /* @__PURE__ */ jsx(
362
+ Popover,
363
+ {
364
+ id: `${id}-actions-${messageId}`,
365
+ side: "top",
366
+ align: "end",
367
+ panelShape: "square",
368
+ className: "usx-chat__message-actions usx-chat__overflow-actions",
369
+ menuItems: [
370
+ ...canCopy ? [
371
+ {
372
+ text: "Copy message",
373
+ type: "button",
374
+ icon: { name: "content_copy" },
375
+ extraAttributes: { "data-usx-chat-copy-message": "" }
376
+ }
377
+ ] : [],
378
+ ...(actions ?? []).map(
379
+ (action) => ({
380
+ id: action.id,
381
+ type: "button",
382
+ text: action.label,
383
+ disabled: action.disabled,
384
+ extraAttributes: {
385
+ "data-usx-chat-message-action": action.id
386
+ }
387
+ })
388
+ )
389
+ ],
390
+ summaryProps: {
391
+ ariaLabel: `More actions for message from ${senderName}`,
392
+ title: "More actions",
393
+ className: "usa-button usx-button usa-button--unstyled",
394
+ children: /* @__PURE__ */ jsx(Icon, { name: "more_horiz" })
395
+ }
396
+ }
397
+ )
398
+ ]
399
+ }
400
+ )
401
+ ] });
402
+ }
403
+ function ChatMessage({
404
+ id,
405
+ message,
406
+ participant,
407
+ own = false,
408
+ isThread = false,
409
+ allowForward = false,
410
+ allowThreads = false,
411
+ showCopyMessageAction = true,
412
+ reactionOptions = [],
413
+ disabled = false
414
+ }) {
415
+ var _a, _b;
416
+ const name = (participant == null ? void 0 : participant.name) || message.senderId;
417
+ const unconfirmed = Boolean(message.deliveryState);
418
+ const position = unconfirmed ? "single" : message.groupPosition ?? "single";
419
+ const showIdentity = position === "single" || position === "first";
420
+ const showTime = position === "single" || position === "last";
421
+ const isPanel = message.layout === "panel";
422
+ const deliveryStatus = message.deliveryStatus ?? (message.deliveryState === "sending" ? "Sending…" : void 0);
423
+ const availableReactions = isPanel || unconfirmed ? [] : (message.reactionOptions ?? reactionOptions ?? []).slice(0, 100);
424
+ const canCopyMessage = !isPanel && !unconfirmed && showCopyMessageAction && Boolean(
425
+ (message.exportText ?? message.text ?? (typeof message.content === "string" ? message.content : "")) || ((_a = message.attachments) == null ? void 0 : _a.length)
426
+ );
427
+ const visibleReplyCount = message.replyCount ?? ((_b = message.replies) == null ? void 0 : _b.length) ?? 0;
428
+ const canOpenThread = !isPanel && !unconfirmed && !isThread && allowThreads;
429
+ const canForward = !isPanel && !unconfirmed && allowForward;
430
+ return /* @__PURE__ */ jsxs(
431
+ "li",
432
+ {
433
+ className: ClassNames$1("usx-chat__message", `usx-chat__message--${position}`, {
434
+ "usx-chat__message--own": own,
435
+ "usx-chat__message--panel": message.layout === "panel",
436
+ "usx-chat__message--failed": message.deliveryState === "failed"
437
+ }),
438
+ "data-message-id": message.id,
439
+ "data-usx-chat-client-message-id": message.clientMessageId,
440
+ "data-usx-chat-delivery-state": message.deliveryState,
441
+ "data-sender-name": name,
442
+ "data-export-text": message.exportText ?? message.text ?? void 0,
443
+ children: [
444
+ showIdentity ? /* @__PURE__ */ jsx(Avatar, { ...chatAvatarProps(participant, name) }) : /* @__PURE__ */ jsx("span", { className: "usx-chat__avatar-space", "aria-hidden": "true" }),
445
+ /* @__PURE__ */ jsxs("div", { className: "usx-chat__message-body", children: [
446
+ showIdentity && /* @__PURE__ */ jsx("span", { className: "usx-chat__sender", children: name }),
447
+ /* @__PURE__ */ jsx(
448
+ ChatBubble,
449
+ {
450
+ text: message.text,
451
+ content: message.content,
452
+ attachments: message.attachments,
453
+ reactions: !isPanel && !unconfirmed ? message.reactions : void 0
454
+ }
455
+ ),
456
+ message.deliveryState === "failed" && /* @__PURE__ */ jsxs(Alert, { variant: "error", noIcon: true, slim: true, className: "usx-chat__delivery-error", children: [
457
+ /* @__PURE__ */ jsx("span", { children: "Message not sent." }),
458
+ /* @__PURE__ */ jsx(
459
+ Button,
460
+ {
461
+ variant: "unstyled",
462
+ className: "usx-chat__retry",
463
+ "aria-label": "Retry sending message",
464
+ "data-usx-chat-retry": message.id,
465
+ disabled,
466
+ children: "Retry"
467
+ }
468
+ )
469
+ ] }),
470
+ !isPanel && message.timeLabel && !showTime && /* @__PURE__ */ jsx("time", { className: "usx-chat__time usa-sr-only", dateTime: message.sentAt, children: message.timeLabel }),
471
+ !isPanel && (Boolean(message.timeLabel && showTime) || message.edited || deliveryStatus || canOpenThread && visibleReplyCount > 0) && /* @__PURE__ */ jsxs("div", { className: "usx-chat__message-footer", children: [
472
+ message.timeLabel && showTime && /* @__PURE__ */ jsx("time", { className: "usx-chat__time", dateTime: message.sentAt, children: message.timeLabel }),
473
+ (message.edited || deliveryStatus) && /* @__PURE__ */ jsxs("span", { className: "usx-chat__message-meta", children: [
474
+ message.edited && "Edited",
475
+ message.edited && deliveryStatus && " · ",
476
+ deliveryStatus
477
+ ] }),
478
+ canOpenThread && visibleReplyCount > 0 && /* @__PURE__ */ jsxs(
479
+ Button,
480
+ {
481
+ variant: "unstyled",
482
+ className: "usx-chat__thread-link",
483
+ "data-usx-chat-thread": message.id,
484
+ children: [
485
+ visibleReplyCount,
486
+ " ",
487
+ visibleReplyCount === 1 ? "reply" : "replies"
488
+ ]
489
+ }
490
+ )
491
+ ] }),
492
+ /* @__PURE__ */ jsx(
493
+ ChatMessageActions,
494
+ {
495
+ id,
496
+ messageId: message.id,
497
+ senderName: name,
498
+ reactions: message.reactions,
499
+ reactionOptions: availableReactions,
500
+ actions: !isPanel && !unconfirmed ? message.actions : void 0,
501
+ canCopy: canCopyMessage,
502
+ canReply: canOpenThread,
503
+ canForward
504
+ }
505
+ )
506
+ ] })
507
+ ]
508
+ }
509
+ );
510
+ }
511
+ function ChatControls({
512
+ suggestedQuestions = [],
513
+ choices = [],
514
+ choicePrompt = "Choose an answer",
515
+ disabled = false,
516
+ children
517
+ }) {
518
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
519
+ " ",
520
+ (suggestedQuestions.length > 0 || choices.length > 0 || Boolean(children)) && /* @__PURE__ */ jsxs("li", { className: "usx-chat__controls", role: "presentation", children: [
521
+ suggestedQuestions.length > 0 && /* @__PURE__ */ jsxs(
522
+ TagGroup,
523
+ {
524
+ className: "usx-chat__quick-replies",
525
+ extraAttributes: { role: "group", "aria-label": "Suggested questions" },
526
+ children: [
527
+ /* @__PURE__ */ jsx("p", { children: "Suggested questions" }),
528
+ suggestedQuestions.map((option) => /* @__PURE__ */ jsx(
529
+ Button,
530
+ {
531
+ variant: "unstyled",
532
+ className: "usa-tag usx-tag usx-tag--outline usx-tag--interactive usa-link usx-link usx-no-visited",
533
+ extraAttributes: { "data-usx-chat-suggestion": option.value },
534
+ disabled,
535
+ children: option.label
536
+ },
537
+ option.value
538
+ ))
539
+ ]
540
+ }
541
+ ),
542
+ choices.length > 0 && /* @__PURE__ */ jsxs(
543
+ TagGroup,
544
+ {
545
+ className: "usx-chat__choices",
546
+ extraAttributes: { role: "group", "aria-label": choicePrompt },
547
+ children: [
548
+ /* @__PURE__ */ jsx("p", { children: choicePrompt }),
549
+ choices.map((option) => /* @__PURE__ */ jsx(
550
+ Button,
551
+ {
552
+ variant: "unstyled",
553
+ className: "usa-tag usx-tag usx-tag--outline usx-tag--interactive usa-link usx-link usx-no-visited",
554
+ extraAttributes: { "data-usx-chat-choice": option.value },
555
+ disabled,
556
+ children: option.label
557
+ },
558
+ option.value
559
+ ))
560
+ ]
561
+ }
562
+ ),
563
+ children
564
+ ] })
565
+ ] });
566
+ }
567
+ var dedupe = { exports: {} };
568
+ /*!
569
+ Copyright (c) 2018 Jed Watson.
570
+ Licensed under the MIT License (MIT), see
571
+ http://jedwatson.github.io/classnames
572
+ */
573
+ var hasRequiredDedupe;
574
+ function requireDedupe() {
575
+ if (hasRequiredDedupe) return dedupe.exports;
576
+ hasRequiredDedupe = 1;
577
+ (function(module) {
578
+ (function() {
579
+ var classNames = (function() {
580
+ function StorageObject() {
581
+ }
582
+ StorageObject.prototype = /* @__PURE__ */ Object.create(null);
583
+ function _parseArray(resultSet, array) {
584
+ var length = array.length;
585
+ for (var i = 0; i < length; ++i) {
586
+ _parse(resultSet, array[i]);
587
+ }
588
+ }
589
+ var hasOwn = {}.hasOwnProperty;
590
+ function _parseNumber(resultSet, num) {
591
+ resultSet[num] = true;
592
+ }
593
+ function _parseObject(resultSet, object) {
594
+ if (object.toString !== Object.prototype.toString && !object.toString.toString().includes("[native code]")) {
595
+ resultSet[object.toString()] = true;
596
+ return;
597
+ }
598
+ for (var k in object) {
599
+ if (hasOwn.call(object, k)) {
600
+ resultSet[k] = !!object[k];
601
+ }
602
+ }
603
+ }
604
+ var SPACE = /\s+/;
605
+ function _parseString(resultSet, str) {
606
+ var array = str.split(SPACE);
607
+ var length = array.length;
608
+ for (var i = 0; i < length; ++i) {
609
+ resultSet[array[i]] = true;
610
+ }
611
+ }
612
+ function _parse(resultSet, arg) {
613
+ if (!arg) return;
614
+ var argType = typeof arg;
615
+ if (argType === "string") {
616
+ _parseString(resultSet, arg);
617
+ } else if (Array.isArray(arg)) {
618
+ _parseArray(resultSet, arg);
619
+ } else if (argType === "object") {
620
+ _parseObject(resultSet, arg);
621
+ } else if (argType === "number") {
622
+ _parseNumber(resultSet, arg);
623
+ }
624
+ }
625
+ function _classNames() {
626
+ var len = arguments.length;
627
+ var args = Array(len);
628
+ for (var i = 0; i < len; i++) {
629
+ args[i] = arguments[i];
630
+ }
631
+ var classSet = new StorageObject();
632
+ _parseArray(classSet, args);
633
+ var list = [];
634
+ for (var k in classSet) {
635
+ if (classSet[k]) {
636
+ list.push(k);
637
+ }
638
+ }
639
+ return list.join(" ");
640
+ }
641
+ return _classNames;
642
+ })();
643
+ if (module.exports) {
644
+ classNames.default = classNames;
645
+ module.exports = classNames;
646
+ } else {
647
+ window.classNames = classNames;
648
+ }
649
+ })();
650
+ })(dedupe);
651
+ return dedupe.exports;
652
+ }
653
+ var dedupeExports = requireDedupe();
654
+ const ClassNames = /* @__PURE__ */ getDefaultExportFromCjs(dedupeExports);
655
+ function ChatDirectoryItem({
656
+ id,
657
+ title,
658
+ subtitle,
659
+ preview,
660
+ avatarProps = [],
661
+ timeLabel,
662
+ unreadCount = 0,
663
+ href,
664
+ conversationId,
665
+ participantId,
666
+ actions = [],
667
+ selectable = false,
668
+ selected = false,
669
+ formId,
670
+ disabled = false
671
+ }) {
672
+ const avatars = avatarProps.map((avatar) => ({
673
+ ...avatar,
674
+ className: ClassNames("usx-chat__avatar", avatar.className)
675
+ }));
676
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
677
+ avatars.length > 1 ? /* @__PURE__ */ jsx(AvatarGroup, { overlap: true, className: "usx-chat__directory-avatars", avatarProps: avatars }) : avatars.length === 1 ? /* @__PURE__ */ jsx(Avatar, { ...avatars[0] }) : null,
678
+ /* @__PURE__ */ jsxs("span", { className: "usx-chat__directory-copy", children: [
679
+ /* @__PURE__ */ jsx("span", { className: "usx-chat__directory-title", children: title }),
680
+ subtitle && /* @__PURE__ */ jsx(
681
+ "span",
682
+ {
683
+ className: "usx-chat__directory-subtitle",
684
+ id: selectable ? `${id}-description` : void 0,
685
+ children: subtitle
686
+ }
687
+ ),
688
+ preview && /* @__PURE__ */ jsx("span", { className: "usx-chat__directory-preview", children: preview })
689
+ ] }),
690
+ (timeLabel || Boolean(unreadCount)) && /* @__PURE__ */ jsxs("span", { className: "usx-chat__directory-meta", children: [
691
+ timeLabel && /* @__PURE__ */ jsx("small", { children: timeLabel }),
692
+ Boolean(unreadCount) && /* @__PURE__ */ jsxs(Fragment, { children: [
693
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: /* @__PURE__ */ jsx(Tag, { color: "info", className: "usx-rounded-md", value: String(unreadCount) }) }),
694
+ /* @__PURE__ */ jsxs("span", { className: "usa-sr-only", children: [
695
+ unreadCount,
696
+ " unread messages"
697
+ ] })
698
+ ] })
699
+ ] })
700
+ ] });
701
+ return /* @__PURE__ */ jsxs("li", { className: actions.length ? "usx-chat__directory-row" : void 0, children: [
702
+ selectable ? /* @__PURE__ */ jsxs("div", { className: "usa-checkbox usx-checkbox usx-chat__directory-item usx-chat__recipient", children: [
703
+ /* @__PURE__ */ jsx(
704
+ "input",
705
+ {
706
+ id,
707
+ className: "usa-checkbox__input",
708
+ type: "checkbox",
709
+ name: "recipientIds",
710
+ value: participantId ?? "",
711
+ form: formId,
712
+ defaultChecked: selected,
713
+ disabled,
714
+ "aria-label": title,
715
+ "aria-describedby": subtitle ? `${id}-description` : void 0,
716
+ "data-usx-chat-recipient": ""
717
+ }
718
+ ),
719
+ /* @__PURE__ */ jsx("label", { className: "usa-checkbox__label usx-chat__recipient-label", htmlFor: id, children: content })
720
+ ] }) : /* @__PURE__ */ jsx(
721
+ Clickable,
722
+ {
723
+ href: href || void 0,
724
+ className: "usx-chat__directory-item",
725
+ extraAttributes: href ? void 0 : participantId !== void 0 ? { "data-usx-chat-contact": participantId } : conversationId !== void 0 ? { "data-usx-chat-conversation": conversationId } : void 0,
726
+ children: content
727
+ }
728
+ ),
729
+ actions.length > 0 && /* @__PURE__ */ jsx(
730
+ Popover,
731
+ {
732
+ id: `${id}-actions`,
733
+ side: "bottom",
734
+ align: "end",
735
+ panelShape: "square",
736
+ className: "usx-chat__directory-actions",
737
+ summaryProps: {
738
+ ariaLabel: `Actions for ${title}`,
739
+ className: "usa-button usx-button usa-button--unstyled",
740
+ children: /* @__PURE__ */ jsx(Icon, { name: "more_vert" })
741
+ },
742
+ menuItems: actions.map((action) => ({
743
+ id: action.id,
744
+ type: "button",
745
+ text: action.label,
746
+ disabled: action.disabled,
747
+ extraAttributes: {
748
+ "data-usx-chat-directory-action": action.id,
749
+ ...conversationId ? { "data-usx-chat-conversation-id": conversationId } : {},
750
+ ...participantId ? { "data-usx-chat-participant-id": participantId } : {}
751
+ }
752
+ }))
753
+ }
754
+ )
755
+ ] });
756
+ }
757
+ function contactAvatar(person, name) {
758
+ var _a, _b, _c;
759
+ const statusRingColor = (person == null ? void 0 : person.presence) === "online" ? "success" : (person == null ? void 0 : person.presence) === "away" ? "warning" : (_a = person == null ? void 0 : person.avatarProps) == null ? void 0 : _a.statusRingColor;
760
+ const statusLabel = (person == null ? void 0 : person.presence) === "online" ? "Online" : (person == null ? void 0 : person.presence) === "away" ? "Away" : (_b = person == null ? void 0 : person.avatarProps) == null ? void 0 : _b.statusLabel;
761
+ return chatAvatarProps(
762
+ person,
763
+ name,
764
+ statusRingColor,
765
+ statusLabel,
766
+ statusLabel ? { label: statusLabel, position: "right" } : (_c = person == null ? void 0 : person.avatarProps) == null ? void 0 : _c.tooltipProps
767
+ );
768
+ }
769
+ function conversationItem(conversation, participants, currentUserId, directoryId) {
770
+ var _a, _b, _c;
771
+ const people = [...new Set(conversation.participantIds ?? [])].filter((id) => id !== currentUserId).map((id) => participants.find((person) => person.id === id) ?? { id, name: id });
772
+ const isGroup = Boolean(conversation.isGroup || people.length > 1);
773
+ let avatars;
774
+ if (isGroup && conversation.avatarProps) {
775
+ avatars = [
776
+ chatAvatarProps(
777
+ { id: conversation.id, name: conversation.title, avatarProps: conversation.avatarProps },
778
+ conversation.title
779
+ )
780
+ ];
781
+ } else if (isGroup && people.length > 1) {
782
+ avatars = people.slice(0, people.length > 3 ? 2 : 3).map((person) => chatAvatarProps(person, person.name));
783
+ if (people.length > 3)
784
+ avatars.push({
785
+ variant: "initials",
786
+ value: `+${people.length - 2}`,
787
+ alt: `${people.length - 2} more participants`,
788
+ shape: "circle",
789
+ contentClassName: "bg-base-darker text-white"
790
+ });
791
+ } else if (isGroup) {
792
+ avatars = [
793
+ chatAvatarProps(
794
+ {
795
+ id: conversation.id,
796
+ name: conversation.title,
797
+ avatarProps: { variant: "icon", value: "groups", alt: `${conversation.title} group` }
798
+ },
799
+ conversation.title
800
+ )
801
+ ];
802
+ } else {
803
+ avatars = [contactAvatar(people[0], ((_a = people[0]) == null ? void 0 : _a.name) ?? conversation.title)];
804
+ }
805
+ const sender = conversation.previewSenderId ? ((_b = participants.find((person) => person.id === conversation.previewSenderId)) == null ? void 0 : _b.name) || conversation.previewSenderId : "";
806
+ return {
807
+ id: `${directoryId}-conversation-${conversation.id}`,
808
+ title: conversation.title,
809
+ subtitle: (_c = conversation.context) == null ? void 0 : _c.title,
810
+ preview: conversation.preview && isGroup && sender ? `${sender}: ${conversation.preview}` : conversation.preview,
811
+ avatarProps: avatars,
812
+ href: conversation.href,
813
+ conversationId: conversation.id,
814
+ timeLabel: conversation.timeLabel,
815
+ unreadCount: conversation.unreadCount,
816
+ actions: conversation.actions
817
+ };
818
+ }
819
+ function ChatDirectory({
820
+ id = "chat-directory",
821
+ selectable = false,
822
+ recipientIds = [],
823
+ formId,
824
+ disabled = false,
825
+ view = "inbox",
826
+ conversations = [],
827
+ contacts = [],
828
+ participants = [],
829
+ currentUserId = "user"
830
+ }) {
831
+ if (view !== "inbox" && view !== "contacts") return null;
832
+ const selecting = view === "contacts" && selectable;
833
+ const Container = selecting ? "div" : "nav";
834
+ const items = view === "inbox" ? conversations.map(
835
+ (conversation) => conversationItem(conversation, participants, currentUserId, id)
836
+ ) : contacts.map((contact) => {
837
+ const person = participants.find((person2) => person2.id === contact.participantId);
838
+ const title = (person == null ? void 0 : person.name) ?? contact.participantId;
839
+ return {
840
+ id: `${id}-recipient-${contact.participantId}`,
841
+ title,
842
+ subtitle: contact.description,
843
+ avatarProps: [contactAvatar(person, title)],
844
+ href: contact.href,
845
+ conversationId: contact.conversationId,
846
+ participantId: contact.participantId,
847
+ actions: contact.actions,
848
+ selectable,
849
+ selected: recipientIds.includes(contact.participantId),
850
+ formId,
851
+ disabled
852
+ };
853
+ });
854
+ return /* @__PURE__ */ jsxs(
855
+ Container,
856
+ {
857
+ className: "usx-chat__directory",
858
+ role: selecting ? "group" : void 0,
859
+ "aria-label": view === "inbox" ? "Conversations" : selecting ? "Recipients" : "People",
860
+ children: [
861
+ selecting && /* @__PURE__ */ jsx("p", { className: "usx-chat__recipient-hint", children: "To: Choose one or more people." }),
862
+ /* @__PURE__ */ jsx("ul", { className: "usx-chat__directory-list", children: items.map((item) => /* @__PURE__ */ jsx(ChatDirectoryItem, { ...item }, item.id)) }),
863
+ view === "inbox" && items.length === 0 && /* @__PURE__ */ jsx("p", { className: "usx-chat__empty", children: "No conversations yet." })
864
+ ]
865
+ }
866
+ );
867
+ }
868
+ function ChatContext({
869
+ label,
870
+ title,
871
+ description,
872
+ imageUrl,
873
+ imageAlt,
874
+ href
875
+ }) {
876
+ return /* @__PURE__ */ jsxs(
877
+ Callout,
878
+ {
879
+ as: "aside",
880
+ big: false,
881
+ strokeColor: "primary",
882
+ backgroundColor: "surface-2",
883
+ textColor: "ink",
884
+ className: "usx-chat__context",
885
+ "aria-label": label,
886
+ children: [
887
+ imageUrl && /* @__PURE__ */ jsx(
888
+ Image,
889
+ {
890
+ className: "usx-chat__context-image",
891
+ objectFit: "cover",
892
+ src: imageUrl,
893
+ alt: imageAlt ?? ""
894
+ }
895
+ ),
896
+ /* @__PURE__ */ jsxs("div", { className: "usx-chat__context-copy", children: [
897
+ /* @__PURE__ */ jsx("span", { className: "usx-chat__context-label", children: label }),
898
+ href ? /* @__PURE__ */ jsx(Link, { href, children: title }) : /* @__PURE__ */ jsx("strong", { children: title }),
899
+ description && /* @__PURE__ */ jsx("span", { children: description })
900
+ ] })
901
+ ]
902
+ }
903
+ );
904
+ }
905
+ function ChatHistory({ hasMore = false, loading = false, error }) {
906
+ return /* @__PURE__ */ jsxs("li", { className: "usx-chat__older-history", children: [
907
+ hasMore ? /* @__PURE__ */ jsx(
908
+ Button,
909
+ {
910
+ variant: "unstyled",
911
+ className: "usx-chat__load-older",
912
+ disabled: loading,
913
+ extraAttributes: { "data-usx-chat-load-older": "" },
914
+ children: loading ? "Loading earlier messages…" : error ? "Try again" : "Load earlier messages"
915
+ }
916
+ ) : /* @__PURE__ */ jsx("span", { className: "usx-chat__history-start", children: "Beginning of conversation" }),
917
+ error && !loading && /* @__PURE__ */ jsx("span", { className: "usx-chat__history-error", role: "alert", children: error })
918
+ ] });
919
+ }
920
+ const props$1 = /* @__PURE__ */ JSON.parse(`{"id":{"type":"string","description":"Unique Popover panel ID and prefix for chat controls."},"title":{"type":"string","description":"Conversation heading inside the chat panel.","default":"Chat"},"status":{"type":"string","description":"Optional status line below the heading."},"context":{"type":"object","description":"Optional subject of a standalone conversation; a selected conversation context overrides it. Keep sensitive record details host-controlled.","properties":{"label":{"type":"string","description":"Short subject category, such as Marketplace listing or Access request."},"title":{"type":"string","description":"Name of the item or record being discussed."},"description":{"type":"string","description":"Optional price, status, or other concise detail."},"imageUrl":{"type":"string","description":"Optional subject thumbnail rendered through Image."},"imageAlt":{"type":"string","description":"Thumbnail description; empty when decorative."},"href":{"type":"string","description":"Optional link to the underlying item or record."}}},"participants":{"type":"array","description":"Participants, including the current user, agents, and bots. Message sender IDs should match participant IDs.","items":{"type":"object","description":"One chat participant.","properties":{"id":{"type":"string","description":"Stable participant ID."},"name":{"type":"string","description":"Visible sender name and transcript label."},"avatarProps":{"type":"object","component":"avatar","description":"Avatar props. Chat renders avatars without links."},"presence":{"type":"select","options":["online","away"],"description":"Optional current presence in inbox and contact lists. The host must keep it current; it is not a response-time promise."},"messageActions":{"type":"array","description":"Host-defined message actions. An explicit empty array disables inherited host actions.","items":{"type":"object","description":"One message action.","properties":{"id":{"type":"string","description":"Action identifier."},"label":{"type":"string","description":"Visible action label."},"disabled":{"type":"boolean","description":"Disable this action."}}}}}},"default":[]},"currentUserId":{"type":"string","description":"Participant ID whose messages align to the outgoing side.","default":"user"},"messages":{"type":"array","description":"Conversation messages in display order. Chat does not fetch or append messages.","items":{"type":"object","description":"One message in the transcript.","properties":{"id":{"type":"string","description":"Stable message ID."},"senderId":{"type":"string","description":"ID of the sender in participants."},"text":{"type":"string","description":"Message text. Chat safely renders **bold**, *italic*, <u>underline</u>, ~~strike~~, numbered and bulleted lines, > quotes, and fenced code blocks. Use content for other rich content."},"content":{"type":"slot","description":"Optional rich message content. Sanitize HTML before passing it to Django; supply exportText for copied transcripts."},"exportText":{"type":"string","description":"Plain text or Markdown used by Copy conversation for rich messages."},"sentAt":{"type":"string","description":"ISO calendar timestamp (YYYY-MM-DDTHH:mm[:ss[.fraction]], optionally followed by Z or ±HH:mm). Grouping treats a missing timezone as UTC and truncates fractions to milliseconds; invalid dates remain ungrouped. Rendered datetime attributes and timeLabel strings are unchanged."},"timeLabel":{"type":"string","description":"Localized timestamp label. Visible on the last message in a close group; retained for screen readers on earlier messages."},"groupPosition":{"type":"select","options":["single","first","middle","last"],"description":"Optional explicit grouping position. Both renderers derive it from adjacent sender IDs and sentAt values when omitted."},"attachments":{"type":"array","description":"Files and images included with the message.","items":{"type":"object","description":"One file or image attachment.","properties":{"name":{"type":"string","description":"Accessible file name."},"url":{"type":"string","description":"Download URL, if available."},"imageUrl":{"type":"string","description":"Optional image preview URL rendered through Image."},"alt":{"type":"string","description":"Description of the preview image. Defaults to the file name."}}}},"replies":{"type":"array","description":"Messages displayed in this message's thread.","items":{"type":"object","description":"One thread reply."}},"olderReplies":{"type":"object","description":"Optional older-page state for this message's thread, using the same fields as olderHistory."},"replyCount":{"type":"number","description":"Visible count of replies to this message; a positive count adds a persistent thread link beside message metadata."},"edited":{"type":"boolean","description":"Show an Edited marker."},"layout":{"type":"select","options":["bubble","panel"],"description":"Use panel for host-supplied editing or confirmation content. It expands to the available row width and uses a neutral surface instead of the sender's bubble color."},"deliveryStatus":{"type":"string","description":"Delivery or read status supplied by the application."},"actions":{"type":"array","description":"Overflow menu items, such as Edit or Delete. The application handles the action.","items":{"type":"object","description":"One message action.","properties":{"id":{"type":"string","description":"Action identifier."},"label":{"type":"string","description":"Visible action label."},"disabled":{"type":"boolean","description":"Disable this action."}}}},"reactions":{"type":"array","description":"Current reactions, rendered as toggle buttons in supplied order. Keep an entry in place while its count remains positive.","items":{"type":"object","description":"One reaction.","properties":{"emoji":{"type":"string","description":"Visible emoji."},"label":{"type":"string","description":"Accessible reaction name and event value."},"count":{"type":"number","description":"Number of reactions."},"selected":{"type":"boolean","description":"Whether the current user selected this reaction."}}}},"reactionOptions":{"type":"array","description":"Emoji choices for adding a reaction to this message; overrides the Chat-level list. An empty array disables new reactions.","items":{"type":"object","description":"A reaction choice.","properties":{"emoji":{"type":"string","description":"Visible emoji."},"label":{"type":"string","description":"Accessible choice name and event value."}}}},"clientMessageId":{"type":"string","description":"Host-supplied correlation ID for a submitted message."},"deliveryState":{"type":"select","options":["sending","failed"],"description":"Host-supplied sending or failed state. Failed messages expose a Retry control that emits usx:chat-retry."}}},"default":[]},"firstUnreadMessageId":{"type":"string","description":"First unread message ID for a standalone conversation. Show the unread divider before this message. A selected conversation overrides it."},"olderHistory":{"type":"object","description":"Optional older-page state for a standalone conversation. Supplying it enables a top load control; selected conversations use their own state.","properties":{"hasMore":{"type":"boolean","description":"Whether earlier messages can be requested."},"cursor":{"type":"string","description":"Opaque host-owned cursor for the next earlier page. Advance it even if a page is empty."},"loading":{"type":"boolean","description":"Show a loading state and suppress duplicate requests."},"error":{"type":"string","description":"Optional load failure text; the control becomes Try again."}}},"conversations":{"type":"array","description":"Optional inbox rows. A row may supply messages for client-side selection or href for server navigation.","items":{"type":"object","description":"One conversation.","properties":{"id":{"type":"string","description":"Stable conversation ID."},"title":{"type":"string","description":"Conversation title."},"participantIds":{"type":"array","description":"Member IDs for this conversation. The current user is omitted from the inbox avatar cluster when present.","items":{"type":"string","description":"Participant ID."}},"isGroup":{"type":"boolean","description":"Keep group inbox treatment even when only one other member remains. Multiple other members also imply a group."},"avatarProps":{"type":"object","component":"avatar","description":"Optional group Avatar, such as an icon or image, in place of member avatars."},"preview":{"type":"string","description":"Last message preview."},"previewSenderId":{"type":"string","description":"Optional sender ID prefixed to a group conversation preview. Useful when only inbox summaries are loaded."},"timeLabel":{"type":"string","description":"Last activity label."},"unreadCount":{"type":"number","description":"Unread message count shown with Tag."},"firstUnreadMessageId":{"type":"string","description":"Stable ID of the first unread message in this conversation's supplied history. Required for an accurate unread divider."},"href":{"type":"string","description":"Optional server-rendered conversation URL."},"context":{"type":"object","description":"Optional subject of this conversation, using the same fields as Chat.context. Its title appears in the inbox and its details above the transcript."},"messages":{"type":"array","description":"History to show when this conversation is selected.","items":{"type":"object","description":"One message."}},"olderHistory":{"type":"object","description":"Optional older-page state for this conversation, using the same fields as Chat.olderHistory."},"allowAttachments":{"type":"boolean","description":"Override whether this conversation accepts new file uploads."},"actions":{"type":"array","description":"Host-defined conversation actions shared by the directory row and the open conversation or thread header. Both dispatch usx:chat-directory-action with the same actionId and conversationId. Omit or pass [] for no host actions.","items":{"type":"object","description":"One conversation action.","properties":{"id":{"type":"string","description":"Action identifier."},"label":{"type":"string","description":"Visible action label."},"disabled":{"type":"boolean","description":"Disable this action."}}}},"messageActions":{"type":"object","description":"Default host actions for sent and received messages. Precedence: message.actions, sender.messageActions, conversation.messageActions side, Chat.messageActions side. Missing sides inherit; [] disables that side. Copy, reply, and reaction controls remain separately configured.","properties":{"sent":{"type":"array","description":"Actions on the active user’s messages.","items":{"type":"object","description":"One message action.","properties":{"id":{"type":"string","description":"Action identifier."},"label":{"type":"string","description":"Visible action label."},"disabled":{"type":"boolean","description":"Disable this action."}}}},"received":{"type":"array","description":"Actions on other users’ messages.","items":{"type":"object","description":"One message action.","properties":{"id":{"type":"string","description":"Action identifier."},"label":{"type":"string","description":"Visible action label."},"disabled":{"type":"boolean","description":"Disable this action."}}}}}},"allowThreads":{"type":"boolean","description":"Override the Chat-level thread setting for every message in this conversation."}}},"default":[]},"contacts":{"type":"array","description":"Optional people available for a new conversation.","items":{"type":"object","description":"One contact.","properties":{"participantId":{"type":"string","description":"ID from participants."},"description":{"type":"string","description":"Supporting text."},"conversationId":{"type":"string","description":"Existing conversation ID, if any."},"href":{"type":"string","description":"Optional server-rendered contact URL in a non-selectable ChatDirectory. The new-message picker selects recipients instead of following contact links."},"allowAttachments":{"type":"boolean","description":"Override whether a new conversation with this contact accepts uploads."},"actions":{"type":"array","description":"Optional host-defined directory actions. Omit or pass [] to hide the menu. Actions dispatch usx:chat-directory-action; the host controls availability and effects.","items":{"type":"object","description":"One message action.","properties":{"id":{"type":"string","description":"Action identifier."},"label":{"type":"string","description":"Visible action label."},"disabled":{"type":"boolean","description":"Disable this action."}}}}}},"default":[]},"view":{"type":"select","options":["inbox","contacts","conversation","thread"],"description":"View to render. Defaults to defaultView, then inbox when conversations exist, otherwise conversation."},"defaultView":{"type":"select","options":["inbox","contacts","conversation","thread"],"description":"Initial view. Defaults to inbox when conversations are supplied, otherwise conversation."},"activeConversationId":{"type":"string","description":"Controlled selected conversation ID."},"defaultConversationId":{"type":"string","description":"Initially selected conversation ID."},"activeThreadId":{"type":"string","description":"Thread root message ID when rendering the thread view."},"recipientId":{"type":"string","description":"Participant ID for a new conversation that has no conversation ID yet."},"emptyText":{"type":"string","description":"Text displayed when there are no messages.","default":"No messages yet. Start the conversation."},"typingIds":{"type":"array","description":"Participant IDs currently typing.","items":{"type":"string","description":"ID of a participant who is typing."},"default":[]},"suggestedQuestions":{"type":"array","description":"Suggested questions shown above the composer.","items":{"type":"object","description":"A suggested question button.","properties":{"label":{"type":"string","description":"Visible question."},"value":{"type":"string","description":"Value sent to the selection callback."}}},"default":[]},"choices":{"type":"array","description":"Answer choices offered by a bot.","items":{"type":"object","description":"A bot answer choice button.","properties":{"label":{"type":"string","description":"Visible answer."},"value":{"type":"string","description":"Value sent to the selection callback."}}},"default":[]},"choicePrompt":{"type":"string","description":"Accessible heading for answer choices.","default":"Choose an answer"},"actions":{"type":"slot","description":"Additional controls inside the optional actions menu."},"showCopyAction":{"type":"boolean","default":false,"description":"Show Copy conversation in the actions menu. Rich messages should provide exportText."},"showCopyMessageAction":{"type":"boolean","default":true,"description":"Show Copy message in each message's More menu when the message has exportable content."},"reactionOptions":{"type":"array","description":"Emoji choices in each message’s Add reaction Popover. Defaults to emojiPack. Pass an empty array to disable adding reactions.","items":{"type":"object","description":"A reaction choice.","properties":{"emoji":{"type":"string","description":"Visible emoji."},"label":{"type":"string","description":"Accessible choice name and event value."},"name":{"type":"string","description":"Optional shortcode name; used for the reaction menu tooltip."},"aliases":{"type":"array","description":"Optional additional shortcodes.","items":{"type":"string","description":"Shortcode alias."}}}},"default":null},"children":{"type":"slot","description":"Optional custom controls above the composer."},"side":{"type":"select","options":["top","right","bottom","left"],"description":"Popover panel side relative to the host launcher.","default":"bottom"},"align":{"type":"select","options":["start","center","end"],"description":"Popover panel alignment relative to the host launcher.","default":"start"},"defaultOpen":{"type":"boolean","default":false,"description":"Show the panel on initial render."},"groupWindowMinutes":{"type":"number","default":5,"description":"Maximum gap between adjacent messages from the same sender for automatic bubble grouping."},"allowAttachments":{"type":"boolean","default":false,"description":"Enable file uploads in the composer. Conversations and contacts may override this setting."},"allowFormatting":{"type":"boolean","default":false,"description":"Show the composer formatting controls and enable formatting shortcuts."},"accept":{"type":"string","description":"File input accept attribute when uploads are enabled. Omit to allow files and images."},"formAction":{"type":"string","description":"Optional native form endpoint. The host may cancel the shared usx:chat-send event to handle submission."},"disabled":{"type":"boolean","default":false,"description":"Disable composing and response controls."},"className":{"type":"string","default":"","description":"Additional classes for the Popover root."},"emojiPack":{"type":"array","default":[{"emoji":"😂","name":"joy","label":"Face with tears of joy"},{"emoji":"❤️","name":"heart","label":"Red heart"},{"emoji":"😍","name":"heart_eyes","label":"Smiling face with heart eyes"},{"emoji":"🤣","name":"rofl","label":"Rolling on the floor laughing"},{"emoji":"😊","name":"blush","label":"Smiling face"},{"emoji":"🙏","name":"pray","label":"Folded hands"},{"emoji":"😭","name":"sob","label":"Loudly crying face"},{"emoji":"👍","name":"thumbsup","label":"Thumbs up","aliases":["thumbs_up","+1"]},{"emoji":"👎","name":"thumbsdown","label":"Thumbs down","aliases":["thumbs_down","-1"]},{"emoji":"😅","name":"sweat_smile","label":"Grinning face with sweat"},{"emoji":"👏","name":"clap","label":"Clapping hands"},{"emoji":"😁","name":"grin","label":"Beaming face"},{"emoji":"🔥","name":"fire","label":"Fire"},{"emoji":"💔","name":"broken_heart","label":"Broken heart"},{"emoji":"😢","name":"cry","label":"Crying face"},{"emoji":"🤔","name":"thinking","label":"Thinking face","aliases":["thinking_face"]},{"emoji":"😆","name":"laughing","label":"Laughing face","aliases":["laugh"]},{"emoji":"🙄","name":"rolling_eyes","label":"Face with rolling eyes"},{"emoji":"💪","name":"muscle","label":"Flexed biceps"},{"emoji":"😉","name":"wink","label":"Winking face"},{"emoji":"👌","name":"ok_hand","label":"OK hand"},{"emoji":"🤗","name":"hug","label":"Hugging face"},{"emoji":"😎","name":"sunglasses","label":"Smiling face with sunglasses"},{"emoji":"😇","name":"innocent","label":"Smiling face with halo"},{"emoji":"🎉","name":"tada","label":"Party popper","aliases":["party"]},{"emoji":"✌️","name":"v","label":"Victory hand"},{"emoji":"✨","name":"sparkles","label":"Sparkles"},{"emoji":"😱","name":"scream","label":"Face screaming in fear"},{"emoji":"😌","name":"relieved","label":"Relieved face"},{"emoji":"🙌","name":"raised_hands","label":"Raising hands"},{"emoji":"😋","name":"yum","label":"Face savoring food"},{"emoji":"🙂","name":"slightly_smiling_face","label":"Slightly smiling face"},{"emoji":"🤩","name":"star_struck","label":"Star-struck"},{"emoji":"😀","name":"grinning","label":"Grinning face"},{"emoji":"💯","name":"100","label":"Hundred points"},{"emoji":"👀","name":"eyes","label":"Eyes"},{"emoji":"🤭","name":"hand_over_mouth","label":"Face with hand over mouth"},{"emoji":"😮","name":"open_mouth","label":"Face with open mouth"},{"emoji":"😐","name":"neutral_face","label":"Neutral face"},{"emoji":"😡","name":"rage","label":"Enraged face"},{"emoji":"😴","name":"sleeping","label":"Sleeping face"},{"emoji":"🤷","name":"shrug","label":"Person shrugging"},{"emoji":"🤦","name":"facepalm","label":"Person facepalming"},{"emoji":"👋","name":"wave","label":"Waving hand"},{"emoji":"🤝","name":"handshake","label":"Handshake"},{"emoji":"✅","name":"check","label":"Check mark","aliases":["white_check_mark"]},{"emoji":"❌","name":"x","label":"Cross mark"},{"emoji":"⭐","name":"star","label":"Star"},{"emoji":"⚠️","name":"warning","label":"Warning"},{"emoji":"💡","name":"bulb","label":"Light bulb"},{"emoji":"📌","name":"pushpin","label":"Pushpin"},{"emoji":"📝","name":"memo","label":"Memo"},{"emoji":"📅","name":"calendar","label":"Calendar"},{"emoji":"⏰","name":"alarm_clock","label":"Alarm clock"},{"emoji":"📎","name":"paperclip","label":"Paperclip"},{"emoji":"📁","name":"file_folder","label":"File folder"},{"emoji":"🔗","name":"link","label":"Link"},{"emoji":"🔒","name":"lock","label":"Lock"},{"emoji":"🔑","name":"key","label":"Key"},{"emoji":"🚀","name":"rocket","label":"Rocket"},{"emoji":"💬","name":"speech_balloon","label":"Speech balloon"},{"emoji":"❓","name":"question","label":"Question mark"},{"emoji":"❗","name":"exclamation","label":"Exclamation mark"},{"emoji":"😄","name":"smile","label":"Smiling face with open mouth"},{"emoji":"💙","name":"blue_heart","label":"Blue heart"},{"emoji":"💚","name":"green_heart","label":"Green heart"},{"emoji":"💛","name":"yellow_heart","label":"Yellow heart"},{"emoji":"🥳","name":"partying_face","label":"Partying face"},{"emoji":"🤖","name":"robot","label":"Robot"},{"emoji":"🐱","name":"cat","label":"Cat"},{"emoji":"🐶","name":"dog","label":"Dog"},{"emoji":"🌈","name":"rainbow","label":"Rainbow"},{"emoji":"☀️","name":"sunny","label":"Sun"},{"emoji":"🌙","name":"crescent_moon","label":"Crescent moon"},{"emoji":"☕","name":"coffee","label":"Hot beverage"},{"emoji":"🍕","name":"pizza","label":"Pizza"},{"emoji":"🍰","name":"cake","label":"Cake"},{"emoji":"🎂","name":"birthday","label":"Birthday cake"},{"emoji":"🎵","name":"musical_note","label":"Musical note"},{"emoji":"🏆","name":"trophy","label":"Trophy"}],"description":"Emoji choices in the composer Popover beside attachment and formatting controls, and in :name: shortcodes. Defaults to the included 80-emoji pack. Supply up to 100 entries, or [] to disable emoji input. Reaction choices use this pack unless reactionOptions overrides them.","items":{"type":"object","description":"One emoji choice.","properties":{"emoji":{"type":"string","description":"Unicode emoji glyph."},"name":{"type":"string","description":"Lowercase shortcode without colons."},"label":{"type":"string","description":"Accessible emoji name."},"aliases":{"type":"array","description":"Optional additional shortcodes.","items":{"type":"string","description":"Shortcode alias."}}}}},"recipientIds":{"type":"array","description":"Initially selected participant IDs in the new-message recipient picker.","default":[],"items":{"type":"string","description":"Recipient participant ID."}},"messageActions":{"type":"object","description":"Default host actions for sent and received messages. Precedence: message.actions, sender.messageActions, conversation.messageActions side, Chat.messageActions side. Missing sides inherit; [] disables that side. Copy, reply, and reaction controls remain separately configured.","properties":{"sent":{"type":"array","description":"Actions on the active user’s messages.","items":{"type":"object","description":"One message action.","properties":{"id":{"type":"string","description":"Action identifier."},"label":{"type":"string","description":"Visible action label."},"disabled":{"type":"boolean","description":"Disable this action."}}}},"received":{"type":"array","description":"Actions on other users’ messages.","items":{"type":"object","description":"One message action.","properties":{"id":{"type":"string","description":"Action identifier."},"label":{"type":"string","description":"Visible action label."},"disabled":{"type":"boolean","description":"Disable this action."}}}}}},"summaryProps":{"type":"object","component":"summary","description":"Host-supplied launcher content, classes, accessible label, and title. Chat adds no launcher styling or positioning. The default label is Open chat."},"allowThreads":{"type":"boolean","default":false,"description":"Enable thread entry points for every message in the conversation."}}`);
921
+ const chatConfig = {
922
+ props: props$1
923
+ };
924
+ const props = { "emojiPack": { "default": [{ "emoji": "👍", "name": "thumbs_up", "label": "Thumbs up" }, { "emoji": "😊", "name": "smile", "label": "Smile" }, { "emoji": "🎉", "name": "celebrate", "label": "Celebrate" }] } };
925
+ const config = {
926
+ props
927
+ };
928
+ function ChatComposer({
929
+ id,
930
+ value = "",
931
+ formAction,
932
+ disabled = false,
933
+ allowAttachments = false,
934
+ allowFormatting = false,
935
+ accept,
936
+ emojiPack = config.props.emojiPack.default,
937
+ isThread = false,
938
+ conversationId,
939
+ recipientId,
940
+ recipientIds = [],
941
+ requireRecipients = false,
942
+ threadRootId
943
+ }) {
944
+ return /* @__PURE__ */ jsxs(
945
+ "form",
946
+ {
947
+ id: `${id}-composer`,
948
+ "data-usx-chat-require-recipients": requireRecipients ? "true" : void 0,
949
+ className: "usx-chat-composer usx-chat__composer",
950
+ action: formAction,
951
+ method: "post",
952
+ encType: allowAttachments ? "multipart/form-data" : void 0,
953
+ children: [
954
+ conversationId && /* @__PURE__ */ jsx("input", { type: "hidden", name: "conversationId", value: conversationId }),
955
+ recipientId && !conversationId && /* @__PURE__ */ jsx("input", { type: "hidden", name: "recipientId", value: recipientId }),
956
+ !conversationId && recipientIds.map((recipient, index) => /* @__PURE__ */ jsx("input", { type: "hidden", name: "recipientIds", value: recipient }, index)),
957
+ isThread && threadRootId && /* @__PURE__ */ jsx("input", { type: "hidden", name: "threadRootId", value: threadRootId }),
958
+ allowFormatting && /* @__PURE__ */ jsx(
959
+ "div",
960
+ {
961
+ id: `${id}-formatting`,
962
+ className: "usx-chat__formatting",
963
+ "aria-label": "Message formatting",
964
+ hidden: true,
965
+ children: /* @__PURE__ */ jsx(
966
+ ButtonGroup,
967
+ {
968
+ segmented: true,
969
+ className: "usx-chat__format-buttons",
970
+ buttonProps: [
971
+ ["bold", "Bold", "Ctrl/⌘+B", /* @__PURE__ */ jsx("strong", { children: "B" }, "bold")],
972
+ ["italic", "Italic", "Ctrl/⌘+I", /* @__PURE__ */ jsx("em", { children: "I" }, "italic")],
973
+ ["underline", "Underline", "Ctrl/⌘+U", /* @__PURE__ */ jsx("u", { children: "U" }, "underline")],
974
+ ["strike", "Strikethrough", "Ctrl/⌘+Shift+X", /* @__PURE__ */ jsx("s", { children: "S" }, "strike")],
975
+ ["ordered", "Numbered list", "Ctrl/⌘+Shift+7", "1."],
976
+ ["unordered", "Bulleted list", "Ctrl/⌘+Shift+8", /* @__PURE__ */ jsx(Icon, { name: "list" }, "list")],
977
+ [
978
+ "quote",
979
+ "Block quote",
980
+ "Ctrl/⌘+Shift+9",
981
+ /* @__PURE__ */ jsx(Icon, { name: "format_quote" }, "quote")
982
+ ],
983
+ ["code", "Code block", "Ctrl/⌘+Alt+Shift+C", /* @__PURE__ */ jsx(Icon, { name: "code" }, "code")]
984
+ ].map(([format, label, shortcut, icon]) => ({
985
+ type: "button",
986
+ variant: "outline",
987
+ tighten: true,
988
+ className: "usx-chat__format-button",
989
+ disabled,
990
+ "aria-label": label,
991
+ title: `${label} (${shortcut})`,
992
+ extraAttributes: { "data-usx-chat-format": format },
993
+ children: icon
994
+ }))
995
+ }
996
+ )
997
+ }
998
+ ),
999
+ /* @__PURE__ */ jsx(
1000
+ TextArea,
1001
+ {
1002
+ id: `${id}-message`,
1003
+ label: isThread ? "Reply in thread" : "Message",
1004
+ screenReaderOnlyLabel: true,
1005
+ formGroup: false,
1006
+ name: "message",
1007
+ defaultValue: value,
1008
+ disabled,
1009
+ placeholder: isThread ? "Reply in thread" : "Write a message",
1010
+ rows: 2
1011
+ }
1012
+ ),
1013
+ /* @__PURE__ */ jsxs("div", { className: "usx-chat__composer-actions", children: [
1014
+ /* @__PURE__ */ jsxs("div", { className: "usx-chat__attach", children: [
1015
+ (allowAttachments || allowFormatting) && /* @__PURE__ */ jsx(
1016
+ ButtonGroup,
1017
+ {
1018
+ className: "usx-chat__composer-tools",
1019
+ buttonProps: [
1020
+ ...allowAttachments ? [
1021
+ {
1022
+ type: "button",
1023
+ variant: "outline",
1024
+ tighten: true,
1025
+ "aria-label": "Attach files",
1026
+ title: "Attach files",
1027
+ extraAttributes: { "data-usx-chat-attach": "" },
1028
+ disabled,
1029
+ children: /* @__PURE__ */ jsx(Icon, { name: "attach_file" })
1030
+ }
1031
+ ] : [],
1032
+ ...allowFormatting ? [
1033
+ {
1034
+ type: "button",
1035
+ variant: "outline",
1036
+ tighten: true,
1037
+ "aria-label": "Show formatting",
1038
+ title: "Show formatting",
1039
+ "aria-expanded": false,
1040
+ "aria-controls": `${id}-formatting`,
1041
+ extraAttributes: { "data-usx-chat-toggle-formatting": "" },
1042
+ disabled,
1043
+ children: /* @__PURE__ */ jsx(Icon, { name: "text_fields" })
1044
+ }
1045
+ ] : []
1046
+ ]
1047
+ }
1048
+ ),
1049
+ emojiPack.length > 0 && !disabled && /* @__PURE__ */ jsx(
1050
+ Popover,
1051
+ {
1052
+ id: `${id}-emoji-picker`,
1053
+ side: "top",
1054
+ align: "start",
1055
+ panelShape: "square",
1056
+ className: "usx-chat__emoji-picker",
1057
+ menuItems: emojiPack.slice(0, 100).map(
1058
+ (option) => ({
1059
+ type: "button",
1060
+ id: option.name,
1061
+ text: option.emoji,
1062
+ extraAttributes: {
1063
+ "aria-label": option.label,
1064
+ title: `:${option.name}:`,
1065
+ "data-usx-chat-emoji": option.emoji,
1066
+ "data-usx-chat-emoji-name": option.name,
1067
+ "data-usx-chat-emoji-aliases": (option.aliases ?? []).join(",")
1068
+ }
1069
+ })
1070
+ ),
1071
+ summaryProps: {
1072
+ ariaLabel: "Choose emoji",
1073
+ title: "Choose emoji",
1074
+ className: "usa-button usx-button usa-button--outline",
1075
+ children: /* @__PURE__ */ jsx(Icon, { name: "sentiment_satisfied" })
1076
+ }
1077
+ }
1078
+ ),
1079
+ allowAttachments && /* @__PURE__ */ jsx(
1080
+ "input",
1081
+ {
1082
+ type: "file",
1083
+ hidden: true,
1084
+ name: "attachments",
1085
+ multiple: true,
1086
+ accept,
1087
+ disabled,
1088
+ "aria-label": "Attach files"
1089
+ }
1090
+ )
1091
+ ] }),
1092
+ /* @__PURE__ */ jsx(
1093
+ Button,
1094
+ {
1095
+ type: "submit",
1096
+ variant: "primary",
1097
+ className: "usx-chat__send",
1098
+ label: isThread ? "Send reply" : "Send",
1099
+ iconProps: [{ name: "send" }],
1100
+ disabled: disabled || !value.trim() || requireRecipients && !recipientId && !recipientIds.length
1101
+ }
1102
+ )
1103
+ ] })
1104
+ ]
1105
+ }
1106
+ );
1107
+ }
1108
+ const MAX_EMOJI = 100;
1109
+ function resolveChatMessageActions(message, currentUserId, participant, conversation, defaults) {
1110
+ var _a;
1111
+ const side = message.senderId === currentUserId ? "sent" : "received";
1112
+ return message.actions ?? (participant == null ? void 0 : participant.messageActions) ?? ((_a = conversation == null ? void 0 : conversation.messageActions) == null ? void 0 : _a[side]) ?? (defaults == null ? void 0 : defaults[side]) ?? [];
1113
+ }
1114
+ const nameOf = (id, participants) => {
1115
+ var _a;
1116
+ return ((_a = participants.find((participant) => participant.id === id)) == null ? void 0 : _a.name) || id;
1117
+ };
1118
+ function groupingTime(value) {
1119
+ const match = value == null ? void 0 : value.match(
1120
+ /^(\d{4}-\d{2}-\d{2})T((?:[01]\d|2[0-3]):[0-5]\d)(?::([0-5]\d)(?:\.(\d+))?)?(Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)?$/
1121
+ );
1122
+ if (!match || match[0] !== value) return NaN;
1123
+ const [, date, time, seconds = "00", fraction = "", zone = "Z"] = match;
1124
+ const calendar = /* @__PURE__ */ new Date(`${date}T00:00:00Z`);
1125
+ if (date.startsWith("0000") || !Number.isFinite(calendar.getTime()) || calendar.toISOString().slice(0, 10) !== date)
1126
+ return NaN;
1127
+ return Date.parse(`${date}T${time}:${seconds}.${fraction.slice(0, 3).padEnd(3, "0")}${zone}`);
1128
+ }
1129
+ const sameGroup = (a, b, minutes) => {
1130
+ if (!(a == null ? void 0 : a.sentAt) || !(b == null ? void 0 : b.sentAt) || a.senderId !== b.senderId) return false;
1131
+ const gap = groupingTime(b.sentAt) - groupingTime(a.sentAt);
1132
+ return Number.isFinite(gap) && gap >= 0 && gap <= minutes * 6e4;
1133
+ };
1134
+ function Chat({
1135
+ id,
1136
+ title = "Chat",
1137
+ status,
1138
+ context,
1139
+ participants = [],
1140
+ currentUserId = "user",
1141
+ messages = [],
1142
+ messageActions,
1143
+ olderHistory,
1144
+ firstUnreadMessageId,
1145
+ conversations = [],
1146
+ contacts = [],
1147
+ view,
1148
+ defaultView,
1149
+ activeConversationId,
1150
+ defaultConversationId,
1151
+ activeThreadId,
1152
+ recipientId,
1153
+ recipientIds = [],
1154
+ emptyText = "No messages yet. Start the conversation.",
1155
+ typingIds = [],
1156
+ suggestedQuestions = [],
1157
+ choices = [],
1158
+ choicePrompt = "Choose an answer",
1159
+ actions,
1160
+ showCopyAction = false,
1161
+ showCopyMessageAction = true,
1162
+ reactionOptions,
1163
+ emojiPack = chatConfig.props.emojiPack.default,
1164
+ children,
1165
+ summaryProps,
1166
+ side,
1167
+ align,
1168
+ defaultOpen = false,
1169
+ groupWindowMinutes = 5,
1170
+ allowAttachments = false,
1171
+ allowThreads = false,
1172
+ allowFormatting = false,
1173
+ accept,
1174
+ formAction,
1175
+ disabled = false,
1176
+ className
1177
+ }) {
1178
+ var _a, _b, _c;
1179
+ const currentView = view ?? defaultView ?? (conversations.length ? "inbox" : "conversation");
1180
+ const conversationId = activeConversationId ?? defaultConversationId;
1181
+ const conversation = conversations.find((item) => item.id === conversationId);
1182
+ const conversationContext = (conversation == null ? void 0 : conversation.context) ?? context;
1183
+ const selectedRecipientId = recipientId;
1184
+ const contactPerson = participants.find((item) => item.id === recipientId);
1185
+ const selectedContact = !conversation ? contacts.find((item) => item.participantId === recipientId) : void 0;
1186
+ const canAttach = (conversation == null ? void 0 : conversation.allowAttachments) ?? (selectedContact == null ? void 0 : selectedContact.allowAttachments) ?? allowAttachments;
1187
+ const activeEmojiPack = emojiPack.slice(0, MAX_EMOJI);
1188
+ const conversationMessages = recipientId && !conversation ? [] : (conversation == null ? void 0 : conversation.messages) ?? messages;
1189
+ const unreadBoundaryId = conversation ? conversation.firstUnreadMessageId : firstUnreadMessageId;
1190
+ const threadRootId = activeThreadId;
1191
+ const threadRoot = conversationMessages.find((item) => item.id === threadRootId);
1192
+ const threadReplyCount = (threadRoot == null ? void 0 : threadRoot.replyCount) ?? (((_a = threadRoot == null ? void 0 : threadRoot.olderReplies) == null ? void 0 : _a.hasMore) ? null : ((_b = threadRoot == null ? void 0 : threadRoot.replies) == null ? void 0 : _b.length) ?? 0);
1193
+ const threadRootPreview = (threadRoot == null ? void 0 : threadRoot.text) ?? (threadRoot == null ? void 0 : threadRoot.exportText) ?? (((_c = threadRoot == null ? void 0 : threadRoot.attachments) == null ? void 0 : _c[0]) ? "Attachment: " + threadRoot.attachments[0].name : "");
1194
+ const visibleMessages = currentView === "thread" ? threadRoot ? [threadRoot, ...threadRoot.replies ?? []] : [] : conversationMessages;
1195
+ const activeOlderHistory = currentView === "thread" ? threadRoot == null ? void 0 : threadRoot.olderReplies : recipientId && !conversation ? void 0 : conversation ? conversation.olderHistory : olderHistory;
1196
+ const olderLoading = Boolean(activeOlderHistory == null ? void 0 : activeOlderHistory.loading);
1197
+ const canCopy = showCopyAction && (currentView === "conversation" || currentView === "thread");
1198
+ const historyControl = activeOlderHistory ? /* @__PURE__ */ jsx(ChatHistory, { ...activeOlderHistory }) : null;
1199
+ return /* @__PURE__ */ jsxs(
1200
+ ChatWindow,
1201
+ {
1202
+ id,
1203
+ title: currentView === "thread" ? "Thread" : currentView === "contacts" ? "New message" : (conversation == null ? void 0 : conversation.title) ?? (contactPerson == null ? void 0 : contactPerson.name) ?? title,
1204
+ view: currentView,
1205
+ status: currentView === "thread" ? `In ${(conversation == null ? void 0 : conversation.title) ?? title}` : currentView === "conversation" ? status : void 0,
1206
+ showBack: currentView === "thread" || currentView === "contacts" || currentView === "conversation" && conversations.length > 0,
1207
+ showNewMessage: contacts.length > 0 && currentView === "inbox",
1208
+ showCopyAction: canCopy,
1209
+ conversationId: conversation == null ? void 0 : conversation.id,
1210
+ conversationActions: currentView === "conversation" || currentView === "thread" ? conversation == null ? void 0 : conversation.actions : void 0,
1211
+ actions,
1212
+ summaryProps,
1213
+ side,
1214
+ align,
1215
+ defaultOpen,
1216
+ className,
1217
+ children: [
1218
+ (currentView === "conversation" || currentView === "thread") && conversationContext && /* @__PURE__ */ jsx(ChatContext, { ...conversationContext }),
1219
+ currentView === "thread" && threadRoot && /* @__PURE__ */ jsx(
1220
+ Callout,
1221
+ {
1222
+ as: "aside",
1223
+ big: false,
1224
+ strokeColor: "primary",
1225
+ backgroundColor: "surface-2",
1226
+ textColor: "ink",
1227
+ className: "usx-chat__context",
1228
+ "aria-label": "Thread context",
1229
+ children: /* @__PURE__ */ jsxs("div", { className: "usx-chat__context-copy", children: [
1230
+ /* @__PURE__ */ jsxs("strong", { children: [
1231
+ "Replying to ",
1232
+ nameOf(threadRoot.senderId, participants)
1233
+ ] }),
1234
+ threadRootPreview && /* @__PURE__ */ jsx("span", { children: threadRootPreview })
1235
+ ] })
1236
+ }
1237
+ ),
1238
+ /* @__PURE__ */ jsx(
1239
+ ChatDirectory,
1240
+ {
1241
+ id: `${id}-directory`,
1242
+ view: currentView,
1243
+ conversations,
1244
+ contacts,
1245
+ participants,
1246
+ currentUserId,
1247
+ selectable: currentView === "contacts",
1248
+ recipientIds,
1249
+ formId: `${id}-composer`,
1250
+ disabled
1251
+ }
1252
+ ),
1253
+ currentView === "contacts" && /* @__PURE__ */ jsx(
1254
+ ChatComposer,
1255
+ {
1256
+ id,
1257
+ formAction,
1258
+ requireRecipients: true,
1259
+ disabled,
1260
+ allowAttachments,
1261
+ allowFormatting,
1262
+ accept,
1263
+ emojiPack: activeEmojiPack
1264
+ }
1265
+ ),
1266
+ (currentView === "conversation" || currentView === "thread") && /* @__PURE__ */ jsxs(Fragment, { children: [
1267
+ /* @__PURE__ */ jsxs(
1268
+ "ol",
1269
+ {
1270
+ className: "usx-chat__messages",
1271
+ role: "log",
1272
+ "aria-label": currentView === "thread" ? "Thread messages" : "Conversation",
1273
+ "aria-live": "polite",
1274
+ "aria-relevant": "additions text",
1275
+ "aria-busy": olderLoading,
1276
+ tabIndex: 0,
1277
+ "data-usx-chat-older-cursor": activeOlderHistory == null ? void 0 : activeOlderHistory.cursor,
1278
+ "data-usx-chat-conversation-id": conversationId,
1279
+ "data-usx-chat-thread-id": currentView === "thread" ? threadRootId : void 0,
1280
+ children: [
1281
+ currentView !== "thread" && historyControl,
1282
+ visibleMessages.length === 0 && /* @__PURE__ */ jsx("li", { className: "usx-chat__empty", children: currentView === "thread" ? "Thread unavailable." : emptyText }),
1283
+ currentView === "thread" && threadRoot && /* @__PURE__ */ jsx("li", { className: "usx-chat__thread-label", role: "separator", children: "Original message" }),
1284
+ visibleMessages.map((message, index) => {
1285
+ const participant = participants.find((item) => item.id === message.senderId);
1286
+ const unconfirmed = Boolean(message.deliveryState);
1287
+ const previous = visibleMessages[index - 1];
1288
+ const next = visibleMessages[index + 1];
1289
+ const starts = currentView === "thread" && index === 1 || unconfirmed || Boolean(previous == null ? void 0 : previous.deliveryState) || !sameGroup(previous, message, groupWindowMinutes);
1290
+ const ends = currentView === "thread" && index === 0 || unconfirmed || Boolean(next == null ? void 0 : next.deliveryState) || !sameGroup(message, next, groupWindowMinutes);
1291
+ const position = unconfirmed ? "single" : currentView === "thread" && index < 2 ? starts ? ends ? "single" : "first" : ends ? "last" : "middle" : message.groupPosition ?? (starts ? ends ? "single" : "first" : ends ? "last" : "middle");
1292
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
1293
+ currentView === "conversation" && message.id === unreadBoundaryId && /* @__PURE__ */ jsx("li", { className: "usx-chat__unread-divider", role: "separator", children: /* @__PURE__ */ jsx("span", { children: "Unread messages" }) }),
1294
+ /* @__PURE__ */ jsx(
1295
+ ChatMessage,
1296
+ {
1297
+ id,
1298
+ message: {
1299
+ ...message,
1300
+ groupPosition: position,
1301
+ actions: resolveChatMessageActions(
1302
+ message,
1303
+ currentUserId,
1304
+ participant,
1305
+ conversation,
1306
+ messageActions
1307
+ )
1308
+ },
1309
+ participant,
1310
+ own: message.senderId === currentUserId,
1311
+ isThread: currentView === "thread",
1312
+ allowThreads: (conversation == null ? void 0 : conversation.allowThreads) ?? allowThreads,
1313
+ allowForward: contacts.length > 0,
1314
+ showCopyMessageAction,
1315
+ reactionOptions: reactionOptions ?? activeEmojiPack,
1316
+ disabled
1317
+ }
1318
+ ),
1319
+ currentView === "thread" && index === 0 && historyControl,
1320
+ currentView === "thread" && index === 0 && /* @__PURE__ */ jsx("li", { className: "usx-chat__thread-divider", role: "separator", children: /* @__PURE__ */ jsx("span", { children: threadReplyCount === null ? "Replies" : threadReplyCount === 1 ? "1 reply" : `${threadReplyCount} replies` }) })
1321
+ ] }, message.id);
1322
+ }),
1323
+ typingIds.length > 0 && /* @__PURE__ */ jsxs("li", { className: "usx-chat__typing", role: "status", "aria-live": "polite", children: [
1324
+ /* @__PURE__ */ jsx(
1325
+ AvatarGroup,
1326
+ {
1327
+ overlap: true,
1328
+ avatarProps: typingIds.map(
1329
+ (personId) => chatAvatarProps(
1330
+ participants.find((item) => item.id === personId),
1331
+ nameOf(personId, participants)
1332
+ )
1333
+ )
1334
+ }
1335
+ ),
1336
+ /* @__PURE__ */ jsxs("span", { children: [
1337
+ typingIds.map((personId) => nameOf(personId, participants)).join(", "),
1338
+ " ",
1339
+ typingIds.length === 1 ? "is" : "are",
1340
+ " typing"
1341
+ ] }),
1342
+ /* @__PURE__ */ jsxs("span", { className: "usx-chat__typing-dots", "aria-hidden": "true", children: [
1343
+ /* @__PURE__ */ jsx("i", {}),
1344
+ /* @__PURE__ */ jsx("i", {}),
1345
+ /* @__PURE__ */ jsx("i", {})
1346
+ ] })
1347
+ ] }),
1348
+ /* @__PURE__ */ jsx(
1349
+ ChatControls,
1350
+ {
1351
+ suggestedQuestions,
1352
+ choices,
1353
+ choicePrompt,
1354
+ disabled,
1355
+ children
1356
+ }
1357
+ )
1358
+ ]
1359
+ }
1360
+ ),
1361
+ (currentView !== "thread" || threadRoot) && /* @__PURE__ */ jsx(
1362
+ ChatComposer,
1363
+ {
1364
+ id,
1365
+ formAction,
1366
+ disabled,
1367
+ allowAttachments: canAttach,
1368
+ allowFormatting,
1369
+ accept,
1370
+ emojiPack: activeEmojiPack,
1371
+ isThread: currentView === "thread",
1372
+ conversationId,
1373
+ recipientId: selectedRecipientId,
1374
+ threadRootId
1375
+ }
1376
+ )
1377
+ ] })
1378
+ ]
1379
+ }
1380
+ );
1381
+ }
1382
+ export {
1383
+ Chat,
1384
+ ChatAttachment,
1385
+ ChatAttachments,
1386
+ ChatBubble,
1387
+ ChatComposer,
1388
+ ChatContext,
1389
+ ChatControls,
1390
+ ChatDirectory,
1391
+ ChatDirectoryItem,
1392
+ ChatHistory,
1393
+ ChatMessage,
1394
+ ChatMessageActions,
1395
+ ChatWindow
1396
+ };