@cossistant/react 0.0.28 → 0.0.30

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 (301) hide show
  1. package/README.md +1 -1
  2. package/_virtual/rolldown_runtime.js +9 -23
  3. package/hooks/index.d.ts +3 -3
  4. package/hooks/private/store/use-conversations-store.d.ts +2 -0
  5. package/hooks/private/store/use-conversations-store.d.ts.map +1 -1
  6. package/hooks/private/store/use-conversations-store.js +15 -8
  7. package/hooks/private/store/use-conversations-store.js.map +1 -1
  8. package/hooks/private/store/use-store-selector.d.ts +3 -0
  9. package/hooks/private/store/use-store-selector.d.ts.map +1 -1
  10. package/hooks/private/store/use-store-selector.js +4 -8
  11. package/hooks/private/store/use-store-selector.js.map +1 -1
  12. package/hooks/private/store/use-website-store.d.ts +3 -1
  13. package/hooks/private/store/use-website-store.d.ts.map +1 -1
  14. package/hooks/private/store/use-website-store.js +14 -6
  15. package/hooks/private/store/use-website-store.js.map +1 -1
  16. package/hooks/private/use-client-query.d.ts +1 -1
  17. package/hooks/private/use-client-query.d.ts.map +1 -1
  18. package/hooks/private/use-client-query.js +1 -0
  19. package/hooks/private/use-client-query.js.map +1 -1
  20. package/hooks/private/use-default-messages.d.ts +1 -1
  21. package/hooks/private/use-grouped-messages.d.ts +10 -7
  22. package/hooks/private/use-grouped-messages.d.ts.map +1 -1
  23. package/hooks/private/use-grouped-messages.js +44 -11
  24. package/hooks/private/use-grouped-messages.js.map +1 -1
  25. package/hooks/private/use-rest-client.d.ts +13 -3
  26. package/hooks/private/use-rest-client.d.ts.map +1 -1
  27. package/hooks/private/use-rest-client.js +49 -22
  28. package/hooks/private/use-rest-client.js.map +1 -1
  29. package/hooks/private/use-visitor-typing-reporter.d.ts +1 -1
  30. package/hooks/use-conversation-auto-seen.d.ts +1 -1
  31. package/hooks/use-conversation-page.d.ts +1 -1
  32. package/hooks/use-conversation-page.d.ts.map +1 -1
  33. package/hooks/use-conversation-page.js +10 -3
  34. package/hooks/use-conversation-page.js.map +1 -1
  35. package/hooks/use-conversation-preview.d.ts +3 -1
  36. package/hooks/use-conversation-preview.d.ts.map +1 -1
  37. package/hooks/use-conversation-preview.js +6 -3
  38. package/hooks/use-conversation-preview.js.map +1 -1
  39. package/hooks/use-conversation-seen.d.ts +1 -1
  40. package/hooks/use-conversation-seen.js +1 -1
  41. package/hooks/use-conversation-seen.js.map +1 -1
  42. package/hooks/use-conversation-timeline-items.d.ts +1 -1
  43. package/hooks/use-conversation-timeline-items.js +2 -3
  44. package/hooks/use-conversation-timeline-items.js.map +1 -1
  45. package/hooks/use-conversation-timeline.d.ts +1 -1
  46. package/hooks/use-conversation-timeline.d.ts.map +1 -1
  47. package/hooks/use-conversation-timeline.js +1 -3
  48. package/hooks/use-conversation-timeline.js.map +1 -1
  49. package/hooks/use-conversation.d.ts +1 -1
  50. package/hooks/use-conversation.js +2 -3
  51. package/hooks/use-conversation.js.map +1 -1
  52. package/hooks/use-conversations.d.ts +1 -1
  53. package/hooks/use-conversations.js +5 -3
  54. package/hooks/use-conversations.js.map +1 -1
  55. package/hooks/use-create-conversation.d.ts +3 -3
  56. package/hooks/use-create-conversation.js +1 -0
  57. package/hooks/use-create-conversation.js.map +1 -1
  58. package/hooks/use-file-upload.d.ts +1 -1
  59. package/hooks/use-file-upload.js +3 -3
  60. package/hooks/use-file-upload.js.map +1 -1
  61. package/hooks/use-home-page.js +3 -3
  62. package/hooks/use-home-page.js.map +1 -1
  63. package/hooks/use-message-composer.d.ts +10 -3
  64. package/hooks/use-message-composer.d.ts.map +1 -1
  65. package/hooks/use-message-composer.js +5 -2
  66. package/hooks/use-message-composer.js.map +1 -1
  67. package/hooks/use-realtime-support.d.ts +1 -1
  68. package/hooks/use-send-message.d.ts +8 -2
  69. package/hooks/use-send-message.d.ts.map +1 -1
  70. package/hooks/use-send-message.js +5 -3
  71. package/hooks/use-send-message.js.map +1 -1
  72. package/hooks/use-visitor.js +2 -2
  73. package/hooks/use-visitor.js.map +1 -1
  74. package/identify-visitor.d.ts.map +1 -1
  75. package/identify-visitor.js +15 -1
  76. package/identify-visitor.js.map +1 -1
  77. package/index.d.ts +3 -3
  78. package/index.js +1 -1
  79. package/package.json +5 -3
  80. package/{conversation.d.ts → packages/types/src/api/conversation.d.ts} +368 -64
  81. package/packages/types/src/api/conversation.d.ts.map +1 -0
  82. package/packages/types/src/api/timeline-item.d.ts +460 -0
  83. package/packages/types/src/api/timeline-item.d.ts.map +1 -0
  84. package/packages/types/src/realtime-events.d.ts +1004 -0
  85. package/packages/types/src/realtime-events.d.ts.map +1 -0
  86. package/{schemas3.d.ts → packages/types/src/schemas.d.ts} +95 -19
  87. package/packages/types/src/schemas.d.ts.map +1 -0
  88. package/primitives/avatar/avatar.js +1 -1
  89. package/primitives/avatar/avatar.js.map +1 -1
  90. package/primitives/avatar/fallback.d.ts.map +1 -1
  91. package/primitives/avatar/fallback.js +2 -2
  92. package/primitives/avatar/fallback.js.map +1 -1
  93. package/primitives/avatar/image.d.ts +1 -1
  94. package/primitives/avatar/image.js +1 -1
  95. package/primitives/avatar/image.js.map +1 -1
  96. package/primitives/button.js +1 -1
  97. package/primitives/button.js.map +1 -1
  98. package/primitives/conversation-timeline.d.ts +1 -1
  99. package/primitives/conversation-timeline.js +4 -4
  100. package/primitives/conversation-timeline.js.map +1 -1
  101. package/primitives/day-separator.d.ts +76 -0
  102. package/primitives/day-separator.d.ts.map +1 -0
  103. package/primitives/day-separator.js +111 -0
  104. package/primitives/day-separator.js.map +1 -0
  105. package/primitives/index.d.ts +3 -2
  106. package/primitives/index.js +6 -1
  107. package/primitives/index.parts.d.ts +2 -1
  108. package/primitives/index.parts.js +2 -1
  109. package/primitives/multimodal-input.d.ts +2 -2
  110. package/primitives/multimodal-input.d.ts.map +1 -1
  111. package/primitives/multimodal-input.js +2 -2
  112. package/primitives/multimodal-input.js.map +1 -1
  113. package/primitives/timeline-item-attachments.d.ts +1 -1
  114. package/primitives/timeline-item-attachments.js +6 -7
  115. package/primitives/timeline-item-attachments.js.map +1 -1
  116. package/primitives/timeline-item-group.d.ts +1 -1
  117. package/primitives/timeline-item-group.d.ts.map +1 -1
  118. package/primitives/timeline-item-group.js +8 -8
  119. package/primitives/timeline-item-group.js.map +1 -1
  120. package/primitives/timeline-item.d.ts +1 -1
  121. package/primitives/timeline-item.d.ts.map +1 -1
  122. package/primitives/timeline-item.js +33 -8
  123. package/primitives/timeline-item.js.map +1 -1
  124. package/primitives/trigger.js +1 -1
  125. package/primitives/trigger.js.map +1 -1
  126. package/primitives/window.js +1 -1
  127. package/primitives/window.js.map +1 -1
  128. package/provider.d.ts +4 -2
  129. package/provider.d.ts.map +1 -1
  130. package/provider.js +56 -8
  131. package/provider.js.map +1 -1
  132. package/realtime/event-filter.d.ts +4 -1
  133. package/realtime/event-filter.d.ts.map +1 -1
  134. package/realtime/event-filter.js +14 -0
  135. package/realtime/event-filter.js.map +1 -1
  136. package/realtime/provider.d.ts +1 -1
  137. package/realtime/provider.d.ts.map +1 -1
  138. package/realtime/provider.js +1 -2
  139. package/realtime/provider.js.map +1 -1
  140. package/realtime/seen-store.d.ts +2 -2
  141. package/realtime/support-provider.js +6 -1
  142. package/realtime/support-provider.js.map +1 -1
  143. package/realtime/typing-store.d.ts +1 -1
  144. package/realtime/use-realtime.d.ts +1 -1
  145. package/support/components/avatar-stack.d.ts.map +1 -1
  146. package/support/components/avatar-stack.js +32 -12
  147. package/support/components/avatar-stack.js.map +1 -1
  148. package/support/components/avatar.d.ts +34 -3
  149. package/support/components/avatar.d.ts.map +1 -1
  150. package/support/components/avatar.js +61 -8
  151. package/support/components/avatar.js.map +1 -1
  152. package/support/components/button.d.ts +4 -2
  153. package/support/components/button.d.ts.map +1 -1
  154. package/support/components/button.js +3 -3
  155. package/support/components/button.js.map +1 -1
  156. package/support/components/configuration-error.d.ts +16 -0
  157. package/support/components/configuration-error.d.ts.map +1 -0
  158. package/support/components/configuration-error.js +162 -0
  159. package/support/components/configuration-error.js.map +1 -0
  160. package/support/components/content.js +1 -2
  161. package/support/components/content.js.map +1 -1
  162. package/support/components/conversation-button-link.js +18 -23
  163. package/support/components/conversation-button-link.js.map +1 -1
  164. package/support/components/conversation-event.d.ts.map +1 -1
  165. package/support/components/conversation-event.js +7 -5
  166. package/support/components/conversation-event.js.map +1 -1
  167. package/support/components/conversation-timeline.d.ts +6 -1
  168. package/support/components/conversation-timeline.d.ts.map +1 -1
  169. package/support/components/conversation-timeline.js +22 -2
  170. package/support/components/conversation-timeline.js.map +1 -1
  171. package/support/components/header.js +1 -1
  172. package/support/components/image-lightbox.d.ts +1 -1
  173. package/support/components/image-lightbox.js +1 -2
  174. package/support/components/image-lightbox.js.map +1 -1
  175. package/support/components/index.js +1 -1
  176. package/support/components/multimodal-input.js +0 -1
  177. package/support/components/multimodal-input.js.map +1 -1
  178. package/support/components/navigation-tab.js +1 -1
  179. package/support/components/online-indicator.d.ts +50 -0
  180. package/support/components/online-indicator.d.ts.map +1 -0
  181. package/support/components/online-indicator.js +65 -0
  182. package/support/components/online-indicator.js.map +1 -0
  183. package/support/components/root.js +0 -1
  184. package/support/components/root.js.map +1 -1
  185. package/support/components/timeline-identification-tool.js +4 -4
  186. package/support/components/timeline-identification-tool.js.map +1 -1
  187. package/support/components/timeline-message-group.d.ts +1 -1
  188. package/support/components/timeline-message-group.d.ts.map +1 -1
  189. package/support/components/timeline-message-group.js +6 -4
  190. package/support/components/timeline-message-group.js.map +1 -1
  191. package/support/components/timeline-message-item.d.ts +1 -1
  192. package/support/components/timeline-message-item.js +4 -4
  193. package/support/components/timeline-message-item.js.map +1 -1
  194. package/support/components/trigger.js +1 -2
  195. package/support/components/trigger.js.map +1 -1
  196. package/support/components/typing-indicator.js +1 -1
  197. package/support/components/typing-indicator.js.map +1 -1
  198. package/support/context/controlled-state.js +0 -1
  199. package/support/context/controlled-state.js.map +1 -1
  200. package/support/context/events.d.ts +1 -1
  201. package/support/context/events.js +0 -1
  202. package/support/context/events.js.map +1 -1
  203. package/support/context/handle.js +0 -1
  204. package/support/context/handle.js.map +1 -1
  205. package/support/context/identification.d.ts +33 -0
  206. package/support/context/identification.d.ts.map +1 -0
  207. package/support/context/identification.js +34 -0
  208. package/support/context/identification.js.map +1 -0
  209. package/support/context/positioning.js +0 -1
  210. package/support/context/positioning.js.map +1 -1
  211. package/support/context/slots.js +0 -1
  212. package/support/context/slots.js.map +1 -1
  213. package/support/context/websocket.d.ts +1 -1
  214. package/support/context/websocket.js +0 -1
  215. package/support/context/websocket.js.map +1 -1
  216. package/support/index.d.ts.map +1 -1
  217. package/support/index.js +51 -18
  218. package/support/index.js.map +1 -1
  219. package/support/pages/conversation-history.js +2 -1
  220. package/support/pages/conversation-history.js.map +1 -1
  221. package/support/pages/conversation.d.ts +1 -1
  222. package/support/pages/conversation.js +1 -1
  223. package/support/pages/conversation.js.map +1 -1
  224. package/support/pages/home.js +5 -3
  225. package/support/pages/home.js.map +1 -1
  226. package/support/router.d.ts.map +1 -1
  227. package/support/router.js +4 -0
  228. package/support/router.js.map +1 -1
  229. package/support/store/support-store.js +0 -1
  230. package/support/store/support-store.js.map +1 -1
  231. package/support/{support-C7Xaw-N6.css → support-DmViRaga.css} +2 -2
  232. package/support/{support-C7Xaw-N6.css.map → support-DmViRaga.css.map} +1 -1
  233. package/support/text/index.d.ts +1 -1
  234. package/support/text/index.d.ts.map +1 -1
  235. package/support/text/index.js +1 -1
  236. package/support/text/index.js.map +1 -1
  237. package/support/text/locales/en.js +1 -1
  238. package/support/text/locales/en.js.map +1 -1
  239. package/support/text/locales/es.js +1 -1
  240. package/support/text/locales/es.js.map +1 -1
  241. package/support/text/locales/fr.js +1 -1
  242. package/support/text/locales/fr.js.map +1 -1
  243. package/support/utils/index.d.ts +1 -1
  244. package/support-config.js +0 -1
  245. package/support-config.js.map +1 -1
  246. package/support.css +1 -1
  247. package/tailwind.css +1 -1
  248. package/utils/conversation.d.ts.map +1 -1
  249. package/utils/conversation.js +1 -3
  250. package/utils/conversation.js.map +1 -1
  251. package/utils/use-render-element.d.ts.map +1 -1
  252. package/utils/use-render-element.js +20 -5
  253. package/utils/use-render-element.js.map +1 -1
  254. package/api.d.ts +0 -71
  255. package/api.d.ts.map +0 -1
  256. package/checks.d.ts +0 -189
  257. package/checks.d.ts.map +0 -1
  258. package/clsx.d.ts +0 -7
  259. package/clsx.d.ts.map +0 -1
  260. package/coerce.d.ts +0 -9
  261. package/coerce.d.ts.map +0 -1
  262. package/conversation.d.ts.map +0 -1
  263. package/core.d.ts +0 -35
  264. package/core.d.ts.map +0 -1
  265. package/errors.d.ts +0 -121
  266. package/errors.d.ts.map +0 -1
  267. package/errors2.d.ts +0 -24
  268. package/errors2.d.ts.map +0 -1
  269. package/index2.d.ts +0 -4
  270. package/index3.d.ts +0 -1
  271. package/metadata.d.ts +0 -1
  272. package/openapi-generator.d.ts +0 -1
  273. package/openapi-generator2.d.ts +0 -1
  274. package/openapi-generator3.d.ts +0 -1
  275. package/openapi30.d.ts +0 -125
  276. package/openapi30.d.ts.map +0 -1
  277. package/openapi31.d.ts +0 -131
  278. package/openapi31.d.ts.map +0 -1
  279. package/parse.d.ts +0 -17
  280. package/parse.d.ts.map +0 -1
  281. package/realtime-events.d.ts +0 -482
  282. package/realtime-events.d.ts.map +0 -1
  283. package/registries.d.ts +0 -32
  284. package/registries.d.ts.map +0 -1
  285. package/schemas.d.ts +0 -673
  286. package/schemas.d.ts.map +0 -1
  287. package/schemas2.d.ts +0 -320
  288. package/schemas2.d.ts.map +0 -1
  289. package/schemas3.d.ts.map +0 -1
  290. package/specification-extension.d.ts +0 -9
  291. package/specification-extension.d.ts.map +0 -1
  292. package/standard-schema.d.ts +0 -59
  293. package/standard-schema.d.ts.map +0 -1
  294. package/timeline-item.d.ts +0 -227
  295. package/timeline-item.d.ts.map +0 -1
  296. package/util.d.ts +0 -41
  297. package/util.d.ts.map +0 -1
  298. package/versions.d.ts +0 -9
  299. package/versions.d.ts.map +0 -1
  300. package/zod-extensions.d.ts +0 -39
  301. package/zod-extensions.d.ts.map +0 -1
@@ -12,7 +12,7 @@ const BouncingDots = ({ className }) => /* @__PURE__ */ jsxs("div", {
12
12
  /* @__PURE__ */ jsx("span", { className: cn("dot-bounce-3 size-1 rounded-full bg-co-primary", className) })
13
13
  ]
14
14
  });
15
- const TypingIndicator = React$1.forwardRef(({ participants, availableAIAgents = [], availableHumanAgents = [], withAvatars = true, className,...props }, ref) => {
15
+ const TypingIndicator = React$1.forwardRef(({ participants, availableAIAgents = [], availableHumanAgents = [], withAvatars = true, className, ...props }, ref) => {
16
16
  if (!participants || participants.length === 0) return null;
17
17
  const humanParticipantIds = participants.filter((p) => p.type === "team_member").map((p) => p.id);
18
18
  const aiParticipantIds = participants.filter((p) => p.type === "ai").map((p) => p.id);
@@ -1 +1 @@
1
- {"version":3,"file":"typing-indicator.js","names":["React"],"sources":["../../../src/support/components/typing-indicator.tsx"],"sourcesContent":["import type { AvailableAIAgent, AvailableHumanAgent } from \"@cossistant/types\";\nimport * as React from \"react\";\nimport { cn } from \"../utils\";\nimport { AvatarStack } from \"./avatar-stack\";\n\nexport type TypingParticipantType = \"visitor\" | \"team_member\" | \"ai\";\n\nexport type TypingParticipant = {\n\tid: string;\n\ttype: TypingParticipantType;\n};\n\nexport type TypingIndicatorProps = React.HTMLAttributes<HTMLDivElement> & {\n\tparticipants: TypingParticipant[];\n\tavailableAIAgents?: AvailableAIAgent[];\n\tavailableHumanAgents?: AvailableHumanAgent[];\n\twithAvatars?: boolean;\n};\n\nexport const BouncingDots = ({\n\tclassName,\n}: {\n\tclassName?: string;\n}): React.ReactElement => (\n\t<div className=\"flex gap-1\">\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-1 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-2 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-3 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t</div>\n);\n\nexport const TypingIndicator = React.forwardRef<\n\tHTMLDivElement,\n\tTypingIndicatorProps\n>(\n\t(\n\t\t{\n\t\t\tparticipants,\n\t\t\tavailableAIAgents = [],\n\t\t\tavailableHumanAgents = [],\n\t\t\twithAvatars = true,\n\t\t\tclassName,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tif (!participants || participants.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Separate AI and human participants\n\t\tconst humanParticipantIds = participants\n\t\t\t.filter((p) => p.type === \"team_member\")\n\t\t\t.map((p) => p.id);\n\n\t\tconst aiParticipantIds = participants\n\t\t\t.filter((p) => p.type === \"ai\")\n\t\t\t.map((p) => p.id);\n\n\t\t// Get matching agents\n\t\tconst typingHumanAgents = availableHumanAgents.filter((agent) =>\n\t\t\thumanParticipantIds.includes(agent.id)\n\t\t);\n\n\t\tconst typingAIAgents = availableAIAgents.filter((agent) =>\n\t\t\taiParticipantIds.includes(agent.id)\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={cn(\"flex items-center gap-6\", className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{withAvatars && (\n\t\t\t\t\t<AvatarStack\n\t\t\t\t\t\taiAgents={typingAIAgents}\n\t\t\t\t\t\thideDefaultAIAgent={typingAIAgents.length === 0}\n\t\t\t\t\t\thumanAgents={typingHumanAgents}\n\t\t\t\t\t\tsize={24}\n\t\t\t\t\t\tspacing={16}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<BouncingDots />\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nTypingIndicator.displayName = \"TypingIndicator\";\n"],"mappings":";;;;;;AAmBA,MAAa,gBAAgB,EAC5B,gBAIA,qBAAC;CAAI,WAAU;;EACd,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;EACF,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;EACF,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;;EACG;AAGP,MAAa,kBAAkBA,QAAM,YAKnC,EACC,cACA,oBAAoB,EAAE,EACtB,uBAAuB,EAAE,EACzB,cAAc,MACd,UACA,GAAG,SAEJ,QACI;AACJ,KAAI,CAAC,gBAAgB,aAAa,WAAW,EAC5C,QAAO;CAIR,MAAM,sBAAsB,aAC1B,QAAQ,MAAM,EAAE,SAAS,cAAc,CACvC,KAAK,MAAM,EAAE,GAAG;CAElB,MAAM,mBAAmB,aACvB,QAAQ,MAAM,EAAE,SAAS,KAAK,CAC9B,KAAK,MAAM,EAAE,GAAG;CAGlB,MAAM,oBAAoB,qBAAqB,QAAQ,UACtD,oBAAoB,SAAS,MAAM,GAAG,CACtC;CAED,MAAM,iBAAiB,kBAAkB,QAAQ,UAChD,iBAAiB,SAAS,MAAM,GAAG,CACnC;AAED,QACC,qBAAC;EACA,WAAW,GAAG,2BAA2B,UAAU;EAC9C;EACL,GAAI;aAEH,eACA,oBAAC;GACA,UAAU;GACV,oBAAoB,eAAe,WAAW;GAC9C,aAAa;GACb,MAAM;GACN,SAAS;IACR,EAEH,oBAAC,iBAAe;GACX;EAGR;AAED,gBAAgB,cAAc"}
1
+ {"version":3,"file":"typing-indicator.js","names":["React"],"sources":["../../../src/support/components/typing-indicator.tsx"],"sourcesContent":["import type { AvailableAIAgent, AvailableHumanAgent } from \"@cossistant/types\";\nimport * as React from \"react\";\nimport { cn } from \"../utils\";\nimport { AvatarStack } from \"./avatar-stack\";\n\nexport type TypingParticipantType = \"visitor\" | \"team_member\" | \"ai\";\n\nexport type TypingParticipant = {\n\tid: string;\n\ttype: TypingParticipantType;\n};\n\nexport type TypingIndicatorProps = React.HTMLAttributes<HTMLDivElement> & {\n\tparticipants: TypingParticipant[];\n\tavailableAIAgents?: AvailableAIAgent[];\n\tavailableHumanAgents?: AvailableHumanAgent[];\n\twithAvatars?: boolean;\n};\n\nexport const BouncingDots = ({\n\tclassName,\n}: {\n\tclassName?: string;\n}): React.ReactElement => (\n\t<div className=\"flex gap-1\">\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-1 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-2 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-3 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t</div>\n);\n\nexport const TypingIndicator = React.forwardRef<\n\tHTMLDivElement,\n\tTypingIndicatorProps\n>(\n\t(\n\t\t{\n\t\t\tparticipants,\n\t\t\tavailableAIAgents = [],\n\t\t\tavailableHumanAgents = [],\n\t\t\twithAvatars = true,\n\t\t\tclassName,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tif (!participants || participants.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Separate AI and human participants\n\t\tconst humanParticipantIds = participants\n\t\t\t.filter((p) => p.type === \"team_member\")\n\t\t\t.map((p) => p.id);\n\n\t\tconst aiParticipantIds = participants\n\t\t\t.filter((p) => p.type === \"ai\")\n\t\t\t.map((p) => p.id);\n\n\t\t// Get matching agents\n\t\tconst typingHumanAgents = availableHumanAgents.filter((agent) =>\n\t\t\thumanParticipantIds.includes(agent.id)\n\t\t);\n\n\t\tconst typingAIAgents = availableAIAgents.filter((agent) =>\n\t\t\taiParticipantIds.includes(agent.id)\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={cn(\"flex items-center gap-6\", className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{withAvatars && (\n\t\t\t\t\t<AvatarStack\n\t\t\t\t\t\taiAgents={typingAIAgents}\n\t\t\t\t\t\thideDefaultAIAgent={typingAIAgents.length === 0}\n\t\t\t\t\t\thumanAgents={typingHumanAgents}\n\t\t\t\t\t\tsize={24}\n\t\t\t\t\t\tspacing={16}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<BouncingDots />\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nTypingIndicator.displayName = \"TypingIndicator\";\n"],"mappings":";;;;;;AAmBA,MAAa,gBAAgB,EAC5B,gBAIA,qBAAC;CAAI,WAAU;;EACd,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;EACF,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;EACF,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;;EACG;AAGP,MAAa,kBAAkBA,QAAM,YAKnC,EACC,cACA,oBAAoB,EAAE,EACtB,uBAAuB,EAAE,EACzB,cAAc,MACd,WACA,GAAG,SAEJ,QACI;AACJ,KAAI,CAAC,gBAAgB,aAAa,WAAW,EAC5C,QAAO;CAIR,MAAM,sBAAsB,aAC1B,QAAQ,MAAM,EAAE,SAAS,cAAc,CACvC,KAAK,MAAM,EAAE,GAAG;CAElB,MAAM,mBAAmB,aACvB,QAAQ,MAAM,EAAE,SAAS,KAAK,CAC9B,KAAK,MAAM,EAAE,GAAG;CAGlB,MAAM,oBAAoB,qBAAqB,QAAQ,UACtD,oBAAoB,SAAS,MAAM,GAAG,CACtC;CAED,MAAM,iBAAiB,kBAAkB,QAAQ,UAChD,iBAAiB,SAAS,MAAM,GAAG,CACnC;AAED,QACC,qBAAC;EACA,WAAW,GAAG,2BAA2B,UAAU;EAC9C;EACL,GAAI;aAEH,eACA,oBAAC;GACA,UAAU;GACV,oBAAoB,eAAe,WAAW;GAC9C,aAAa;GACb,MAAM;GACN,SAAS;IACR,EAEH,oBAAC,iBAAe;GACX;EAGR;AAED,gBAAgB,cAAc"}
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
 
3
-
4
3
  import * as React$1 from "react";
5
4
  import { jsx } from "react/jsx-runtime";
6
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"controlled-state.js","names":["React","ControlledStateProvider: React.FC<\n\tControlledStateProviderProps\n>"],"sources":["../../../src/support/context/controlled-state.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * Controlled state context for the Support widget.\n * Allows external control of widget open/close state.\n */\nexport type ControlledStateContextValue = {\n\t/**\n\t * Controlled open state (undefined = uncontrolled)\n\t */\n\topen: boolean | undefined;\n\t/**\n\t * Callback when open state should change\n\t */\n\tonOpenChange: ((open: boolean) => void) | undefined;\n\t/**\n\t * Whether the component is in controlled mode\n\t */\n\tisControlled: boolean;\n};\n\nconst ControlledStateContext =\n\tReact.createContext<ControlledStateContextValue | null>(null);\n\nexport type ControlledStateProviderProps = {\n\t/**\n\t * Controlled open state\n\t */\n\topen?: boolean;\n\t/**\n\t * Callback when open state changes\n\t */\n\tonOpenChange?: (open: boolean) => void;\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider for controlled widget state.\n * Wraps the Support component to enable controlled mode.\n */\nexport const ControlledStateProvider: React.FC<\n\tControlledStateProviderProps\n> = ({ open, onOpenChange, children }) => {\n\tconst value = React.useMemo<ControlledStateContextValue>(\n\t\t() => ({\n\t\t\topen,\n\t\t\tonOpenChange,\n\t\t\tisControlled: open !== undefined,\n\t\t}),\n\t\t[open, onOpenChange]\n\t);\n\n\treturn (\n\t\t<ControlledStateContext.Provider value={value}>\n\t\t\t{children}\n\t\t</ControlledStateContext.Provider>\n\t);\n};\n\n/**\n * Access controlled state context.\n * Returns null if not inside a ControlledStateProvider.\n */\nexport function useControlledState(): ControlledStateContextValue | null {\n\treturn React.useContext(ControlledStateContext);\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,yBACLA,QAAM,cAAkD,KAAK;;;;;AAkB9D,MAAaC,2BAER,EAAE,MAAM,cAAc,eAAe;CACzC,MAAM,QAAQD,QAAM,eACZ;EACN;EACA;EACA,cAAc,SAAS;EACvB,GACD,CAAC,MAAM,aAAa,CACpB;AAED,QACC,oBAAC,uBAAuB;EAAgB;EACtC;GACgC;;;;;;AAQpC,SAAgB,qBAAyD;AACxE,QAAOA,QAAM,WAAW,uBAAuB"}
1
+ {"version":3,"file":"controlled-state.js","names":["React","ControlledStateProvider: React.FC<\n\tControlledStateProviderProps\n>"],"sources":["../../../src/support/context/controlled-state.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * Controlled state context for the Support widget.\n * Allows external control of widget open/close state.\n */\nexport type ControlledStateContextValue = {\n\t/**\n\t * Controlled open state (undefined = uncontrolled)\n\t */\n\topen: boolean | undefined;\n\t/**\n\t * Callback when open state should change\n\t */\n\tonOpenChange: ((open: boolean) => void) | undefined;\n\t/**\n\t * Whether the component is in controlled mode\n\t */\n\tisControlled: boolean;\n};\n\nconst ControlledStateContext =\n\tReact.createContext<ControlledStateContextValue | null>(null);\n\nexport type ControlledStateProviderProps = {\n\t/**\n\t * Controlled open state\n\t */\n\topen?: boolean;\n\t/**\n\t * Callback when open state changes\n\t */\n\tonOpenChange?: (open: boolean) => void;\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider for controlled widget state.\n * Wraps the Support component to enable controlled mode.\n */\nexport const ControlledStateProvider: React.FC<\n\tControlledStateProviderProps\n> = ({ open, onOpenChange, children }) => {\n\tconst value = React.useMemo<ControlledStateContextValue>(\n\t\t() => ({\n\t\t\topen,\n\t\t\tonOpenChange,\n\t\t\tisControlled: open !== undefined,\n\t\t}),\n\t\t[open, onOpenChange]\n\t);\n\n\treturn (\n\t\t<ControlledStateContext.Provider value={value}>\n\t\t\t{children}\n\t\t</ControlledStateContext.Provider>\n\t);\n};\n\n/**\n * Access controlled state context.\n * Returns null if not inside a ControlledStateProvider.\n */\nexport function useControlledState(): ControlledStateContextValue | null {\n\treturn React.useContext(ControlledStateContext);\n}\n"],"mappings":";;;;;;AAuBA,MAAM,yBACLA,QAAM,cAAkD,KAAK;;;;;AAkB9D,MAAaC,2BAER,EAAE,MAAM,cAAc,eAAe;CACzC,MAAM,QAAQD,QAAM,eACZ;EACN;EACA;EACA,cAAc,SAAS;EACvB,GACD,CAAC,MAAM,aAAa,CACpB;AAED,QACC,oBAAC,uBAAuB;EAAgB;EACtC;GACgC;;;;;;AAQpC,SAAgB,qBAAyD;AACxE,QAAOA,QAAM,WAAW,uBAAuB"}
@@ -1,4 +1,4 @@
1
- import { TimelineItem } from "../../timeline-item.js";
1
+ import { TimelineItem } from "../../packages/types/src/api/timeline-item.js";
2
2
  import * as React$1 from "react";
3
3
  import { Conversation } from "@cossistant/types";
4
4
 
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
 
3
-
4
3
  import * as React$1 from "react";
5
4
  import { jsx } from "react/jsx-runtime";
6
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","names":["React","SupportEventsProvider: React.FC<SupportEventsProviderProps>"],"sources":["../../../src/support/context/events.tsx"],"sourcesContent":["\"use client\";\n\nimport type { Conversation } from \"@cossistant/types\";\nimport type { TimelineItem } from \"@cossistant/types/api/timeline-item\";\nimport * as React from \"react\";\n\n// =============================================================================\n// Event Types\n// =============================================================================\n\nexport type SupportEventType =\n\t| \"conversationStart\"\n\t| \"conversationEnd\"\n\t| \"messageSent\"\n\t| \"messageReceived\"\n\t| \"error\";\n\nexport type ConversationStartEvent = {\n\ttype: \"conversationStart\";\n\tconversationId: string;\n\tconversation?: Conversation;\n};\n\nexport type ConversationEndEvent = {\n\ttype: \"conversationEnd\";\n\tconversationId: string;\n\tconversation?: Conversation;\n};\n\nexport type MessageSentEvent = {\n\ttype: \"messageSent\";\n\tconversationId: string;\n\tmessage: TimelineItem;\n};\n\nexport type MessageReceivedEvent = {\n\ttype: \"messageReceived\";\n\tconversationId: string;\n\tmessage: TimelineItem;\n};\n\nexport type ErrorEvent = {\n\ttype: \"error\";\n\terror: Error;\n\tcontext?: string;\n};\n\nexport type SupportEvent =\n\t| ConversationStartEvent\n\t| ConversationEndEvent\n\t| MessageSentEvent\n\t| MessageReceivedEvent\n\t| ErrorEvent;\n\n// =============================================================================\n// Event Callbacks\n// =============================================================================\n\nexport type SupportEventCallbacks = {\n\t/**\n\t * Called when a new conversation is started.\n\t */\n\tonConversationStart?: (event: ConversationStartEvent) => void;\n\t/**\n\t * Called when a conversation ends (resolved, closed, etc.).\n\t */\n\tonConversationEnd?: (event: ConversationEndEvent) => void;\n\t/**\n\t * Called when the visitor sends a message.\n\t */\n\tonMessageSent?: (event: MessageSentEvent) => void;\n\t/**\n\t * Called when a message is received from an agent (human or AI).\n\t */\n\tonMessageReceived?: (event: MessageReceivedEvent) => void;\n\t/**\n\t * Called when an error occurs.\n\t */\n\tonError?: (event: ErrorEvent) => void;\n};\n\n// =============================================================================\n// Context\n// =============================================================================\n\nexport type SupportEventsContextValue = {\n\t/**\n\t * Emit an event to all registered callbacks.\n\t */\n\temit: <T extends SupportEvent>(event: T) => void;\n\t/**\n\t * Subscribe to a specific event type.\n\t * Returns an unsubscribe function.\n\t */\n\tsubscribe: <T extends SupportEventType>(\n\t\ttype: T,\n\t\tcallback: (event: Extract<SupportEvent, { type: T }>) => void\n\t) => () => void;\n};\n\nconst SupportEventsContext =\n\tReact.createContext<SupportEventsContextValue | null>(null);\n\nexport type SupportEventsProviderProps = SupportEventCallbacks & {\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider for support widget events.\n * Allows listening to lifecycle events like message sent/received,\n * conversation start/end, and errors.\n *\n * @example\n * <Support\n * onMessageSent={({ message }) => console.log(\"Sent:\", message)}\n * onMessageReceived={({ message }) => console.log(\"Received:\", message)}\n * onConversationStart={({ conversationId }) => console.log(\"Started:\", conversationId)}\n * onError={({ error }) => console.error(\"Error:\", error)}\n * />\n */\nexport const SupportEventsProvider: React.FC<SupportEventsProviderProps> = ({\n\tonConversationStart,\n\tonConversationEnd,\n\tonMessageSent,\n\tonMessageReceived,\n\tonError,\n\tchildren,\n}) => {\n\t// Store callbacks in refs to avoid stale closures\n\tconst callbacksRef = React.useRef<SupportEventCallbacks>({\n\t\tonConversationStart,\n\t\tonConversationEnd,\n\t\tonMessageSent,\n\t\tonMessageReceived,\n\t\tonError,\n\t});\n\n\t// Update refs when callbacks change\n\tReact.useEffect(() => {\n\t\tcallbacksRef.current = {\n\t\t\tonConversationStart,\n\t\t\tonConversationEnd,\n\t\t\tonMessageSent,\n\t\t\tonMessageReceived,\n\t\t\tonError,\n\t\t};\n\t}, [\n\t\tonConversationStart,\n\t\tonConversationEnd,\n\t\tonMessageSent,\n\t\tonMessageReceived,\n\t\tonError,\n\t]);\n\n\t// Additional subscribers (for internal use)\n\tconst subscribersRef = React.useRef<\n\t\tMap<SupportEventType, Set<(event: SupportEvent) => void>>\n\t>(new Map());\n\n\tconst emit = React.useCallback(<T extends SupportEvent>(event: T) => {\n\t\t// Call the prop callback\n\t\tswitch (event.type) {\n\t\t\tcase \"conversationStart\":\n\t\t\t\tcallbacksRef.current.onConversationStart?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"conversationEnd\":\n\t\t\t\tcallbacksRef.current.onConversationEnd?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"messageSent\":\n\t\t\t\tcallbacksRef.current.onMessageSent?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"messageReceived\":\n\t\t\t\tcallbacksRef.current.onMessageReceived?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"error\":\n\t\t\t\tcallbacksRef.current.onError?.(event);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t// Unknown event type - no callback to call\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// Call any additional subscribers\n\t\tconst subscribers = subscribersRef.current.get(event.type);\n\t\tif (subscribers) {\n\t\t\tfor (const callback of subscribers) {\n\t\t\t\tcallback(event);\n\t\t\t}\n\t\t}\n\t}, []);\n\n\tconst subscribe = React.useCallback(\n\t\t<T extends SupportEventType>(\n\t\t\ttype: T,\n\t\t\tcallback: (event: Extract<SupportEvent, { type: T }>) => void\n\t\t) => {\n\t\t\tif (!subscribersRef.current.has(type)) {\n\t\t\t\tsubscribersRef.current.set(type, new Set());\n\t\t\t}\n\t\t\tconst subscribers = subscribersRef.current.get(type);\n\t\t\tsubscribers?.add(callback as (event: SupportEvent) => void);\n\n\t\t\t// Return unsubscribe function\n\t\t\treturn () => {\n\t\t\t\tsubscribers?.delete(callback as (event: SupportEvent) => void);\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst value = React.useMemo<SupportEventsContextValue>(\n\t\t() => ({ emit, subscribe }),\n\t\t[emit, subscribe]\n\t);\n\n\treturn (\n\t\t<SupportEventsContext.Provider value={value}>\n\t\t\t{children}\n\t\t</SupportEventsContext.Provider>\n\t);\n};\n\n/**\n * Access the events context.\n * Returns null if not inside a SupportEventsProvider.\n */\nexport function useSupportEvents(): SupportEventsContextValue | null {\n\treturn React.useContext(SupportEventsContext);\n}\n\n/**\n * Hook to emit events from within the widget.\n * Safe to use outside of provider (will no-op).\n */\nexport function useSupportEventEmitter() {\n\tconst events = useSupportEvents();\n\n\treturn React.useMemo(\n\t\t() => ({\n\t\t\temitConversationStart: (\n\t\t\t\tconversationId: string,\n\t\t\t\tconversation?: Conversation\n\t\t\t) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"conversationStart\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tconversation,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitConversationEnd: (\n\t\t\t\tconversationId: string,\n\t\t\t\tconversation?: Conversation\n\t\t\t) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"conversationEnd\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tconversation,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitMessageSent: (conversationId: string, message: TimelineItem) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"messageSent\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitMessageReceived: (conversationId: string, message: TimelineItem) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"messageReceived\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitError: (error: Error, context?: string) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\terror,\n\t\t\t\t\tcontext,\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t\t[events]\n\t);\n}\n"],"mappings":";;;;;;;AAoGA,MAAM,uBACLA,QAAM,cAAgD,KAAK;;;;;;;;;;;;;;AAmB5D,MAAaC,yBAA+D,EAC3E,qBACA,mBACA,eACA,mBACA,SACA,eACK;CAEL,MAAM,eAAeD,QAAM,OAA8B;EACxD;EACA;EACA;EACA;EACA;EACA,CAAC;AAGF,SAAM,gBAAgB;AACrB,eAAa,UAAU;GACtB;GACA;GACA;GACA;GACA;GACA;IACC;EACF;EACA;EACA;EACA;EACA;EACA,CAAC;CAGF,MAAM,iBAAiBA,QAAM,uBAE3B,IAAI,KAAK,CAAC;CAEZ,MAAM,OAAOA,QAAM,aAAqC,UAAa;AAEpE,UAAQ,MAAM,MAAd;GACC,KAAK;AACJ,iBAAa,QAAQ,sBAAsB,MAAM;AACjD;GACD,KAAK;AACJ,iBAAa,QAAQ,oBAAoB,MAAM;AAC/C;GACD,KAAK;AACJ,iBAAa,QAAQ,gBAAgB,MAAM;AAC3C;GACD,KAAK;AACJ,iBAAa,QAAQ,oBAAoB,MAAM;AAC/C;GACD,KAAK;AACJ,iBAAa,QAAQ,UAAU,MAAM;AACrC;GACD,QAEC;;EAIF,MAAM,cAAc,eAAe,QAAQ,IAAI,MAAM,KAAK;AAC1D,MAAI,YACH,MAAK,MAAM,YAAY,YACtB,UAAS,MAAM;IAGf,EAAE,CAAC;CAEN,MAAM,YAAYA,QAAM,aAEtB,MACA,aACI;AACJ,MAAI,CAAC,eAAe,QAAQ,IAAI,KAAK,CACpC,gBAAe,QAAQ,IAAI,sBAAM,IAAI,KAAK,CAAC;EAE5C,MAAM,cAAc,eAAe,QAAQ,IAAI,KAAK;AACpD,eAAa,IAAI,SAA0C;AAG3D,eAAa;AACZ,gBAAa,OAAO,SAA0C;;IAGhE,EAAE,CACF;CAED,MAAM,QAAQA,QAAM,eACZ;EAAE;EAAM;EAAW,GAC1B,CAAC,MAAM,UAAU,CACjB;AAED,QACC,oBAAC,qBAAqB;EAAgB;EACpC;GAC8B;;;;;;AAQlC,SAAgB,mBAAqD;AACpE,QAAOA,QAAM,WAAW,qBAAqB;;;;;;AAO9C,SAAgB,yBAAyB;CACxC,MAAM,SAAS,kBAAkB;AAEjC,QAAOA,QAAM,eACL;EACN,wBACC,gBACA,iBACI;AACJ,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,sBACC,gBACA,iBACI;AACJ,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,kBAAkB,gBAAwB,YAA0B;AACnE,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,sBAAsB,gBAAwB,YAA0B;AACvE,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,YAAY,OAAc,YAAqB;AAC9C,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,GACD,CAAC,OAAO,CACR"}
1
+ {"version":3,"file":"events.js","names":["React","SupportEventsProvider: React.FC<SupportEventsProviderProps>"],"sources":["../../../src/support/context/events.tsx"],"sourcesContent":["\"use client\";\n\nimport type { Conversation } from \"@cossistant/types\";\nimport type { TimelineItem } from \"@cossistant/types/api/timeline-item\";\nimport * as React from \"react\";\n\n// =============================================================================\n// Event Types\n// =============================================================================\n\nexport type SupportEventType =\n\t| \"conversationStart\"\n\t| \"conversationEnd\"\n\t| \"messageSent\"\n\t| \"messageReceived\"\n\t| \"error\";\n\nexport type ConversationStartEvent = {\n\ttype: \"conversationStart\";\n\tconversationId: string;\n\tconversation?: Conversation;\n};\n\nexport type ConversationEndEvent = {\n\ttype: \"conversationEnd\";\n\tconversationId: string;\n\tconversation?: Conversation;\n};\n\nexport type MessageSentEvent = {\n\ttype: \"messageSent\";\n\tconversationId: string;\n\tmessage: TimelineItem;\n};\n\nexport type MessageReceivedEvent = {\n\ttype: \"messageReceived\";\n\tconversationId: string;\n\tmessage: TimelineItem;\n};\n\nexport type ErrorEvent = {\n\ttype: \"error\";\n\terror: Error;\n\tcontext?: string;\n};\n\nexport type SupportEvent =\n\t| ConversationStartEvent\n\t| ConversationEndEvent\n\t| MessageSentEvent\n\t| MessageReceivedEvent\n\t| ErrorEvent;\n\n// =============================================================================\n// Event Callbacks\n// =============================================================================\n\nexport type SupportEventCallbacks = {\n\t/**\n\t * Called when a new conversation is started.\n\t */\n\tonConversationStart?: (event: ConversationStartEvent) => void;\n\t/**\n\t * Called when a conversation ends (resolved, closed, etc.).\n\t */\n\tonConversationEnd?: (event: ConversationEndEvent) => void;\n\t/**\n\t * Called when the visitor sends a message.\n\t */\n\tonMessageSent?: (event: MessageSentEvent) => void;\n\t/**\n\t * Called when a message is received from an agent (human or AI).\n\t */\n\tonMessageReceived?: (event: MessageReceivedEvent) => void;\n\t/**\n\t * Called when an error occurs.\n\t */\n\tonError?: (event: ErrorEvent) => void;\n};\n\n// =============================================================================\n// Context\n// =============================================================================\n\nexport type SupportEventsContextValue = {\n\t/**\n\t * Emit an event to all registered callbacks.\n\t */\n\temit: <T extends SupportEvent>(event: T) => void;\n\t/**\n\t * Subscribe to a specific event type.\n\t * Returns an unsubscribe function.\n\t */\n\tsubscribe: <T extends SupportEventType>(\n\t\ttype: T,\n\t\tcallback: (event: Extract<SupportEvent, { type: T }>) => void\n\t) => () => void;\n};\n\nconst SupportEventsContext =\n\tReact.createContext<SupportEventsContextValue | null>(null);\n\nexport type SupportEventsProviderProps = SupportEventCallbacks & {\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider for support widget events.\n * Allows listening to lifecycle events like message sent/received,\n * conversation start/end, and errors.\n *\n * @example\n * <Support\n * onMessageSent={({ message }) => console.log(\"Sent:\", message)}\n * onMessageReceived={({ message }) => console.log(\"Received:\", message)}\n * onConversationStart={({ conversationId }) => console.log(\"Started:\", conversationId)}\n * onError={({ error }) => console.error(\"Error:\", error)}\n * />\n */\nexport const SupportEventsProvider: React.FC<SupportEventsProviderProps> = ({\n\tonConversationStart,\n\tonConversationEnd,\n\tonMessageSent,\n\tonMessageReceived,\n\tonError,\n\tchildren,\n}) => {\n\t// Store callbacks in refs to avoid stale closures\n\tconst callbacksRef = React.useRef<SupportEventCallbacks>({\n\t\tonConversationStart,\n\t\tonConversationEnd,\n\t\tonMessageSent,\n\t\tonMessageReceived,\n\t\tonError,\n\t});\n\n\t// Update refs when callbacks change\n\tReact.useEffect(() => {\n\t\tcallbacksRef.current = {\n\t\t\tonConversationStart,\n\t\t\tonConversationEnd,\n\t\t\tonMessageSent,\n\t\t\tonMessageReceived,\n\t\t\tonError,\n\t\t};\n\t}, [\n\t\tonConversationStart,\n\t\tonConversationEnd,\n\t\tonMessageSent,\n\t\tonMessageReceived,\n\t\tonError,\n\t]);\n\n\t// Additional subscribers (for internal use)\n\tconst subscribersRef = React.useRef<\n\t\tMap<SupportEventType, Set<(event: SupportEvent) => void>>\n\t>(new Map());\n\n\tconst emit = React.useCallback(<T extends SupportEvent>(event: T) => {\n\t\t// Call the prop callback\n\t\tswitch (event.type) {\n\t\t\tcase \"conversationStart\":\n\t\t\t\tcallbacksRef.current.onConversationStart?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"conversationEnd\":\n\t\t\t\tcallbacksRef.current.onConversationEnd?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"messageSent\":\n\t\t\t\tcallbacksRef.current.onMessageSent?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"messageReceived\":\n\t\t\t\tcallbacksRef.current.onMessageReceived?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"error\":\n\t\t\t\tcallbacksRef.current.onError?.(event);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t// Unknown event type - no callback to call\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// Call any additional subscribers\n\t\tconst subscribers = subscribersRef.current.get(event.type);\n\t\tif (subscribers) {\n\t\t\tfor (const callback of subscribers) {\n\t\t\t\tcallback(event);\n\t\t\t}\n\t\t}\n\t}, []);\n\n\tconst subscribe = React.useCallback(\n\t\t<T extends SupportEventType>(\n\t\t\ttype: T,\n\t\t\tcallback: (event: Extract<SupportEvent, { type: T }>) => void\n\t\t) => {\n\t\t\tif (!subscribersRef.current.has(type)) {\n\t\t\t\tsubscribersRef.current.set(type, new Set());\n\t\t\t}\n\t\t\tconst subscribers = subscribersRef.current.get(type);\n\t\t\tsubscribers?.add(callback as (event: SupportEvent) => void);\n\n\t\t\t// Return unsubscribe function\n\t\t\treturn () => {\n\t\t\t\tsubscribers?.delete(callback as (event: SupportEvent) => void);\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst value = React.useMemo<SupportEventsContextValue>(\n\t\t() => ({ emit, subscribe }),\n\t\t[emit, subscribe]\n\t);\n\n\treturn (\n\t\t<SupportEventsContext.Provider value={value}>\n\t\t\t{children}\n\t\t</SupportEventsContext.Provider>\n\t);\n};\n\n/**\n * Access the events context.\n * Returns null if not inside a SupportEventsProvider.\n */\nexport function useSupportEvents(): SupportEventsContextValue | null {\n\treturn React.useContext(SupportEventsContext);\n}\n\n/**\n * Hook to emit events from within the widget.\n * Safe to use outside of provider (will no-op).\n */\nexport function useSupportEventEmitter() {\n\tconst events = useSupportEvents();\n\n\treturn React.useMemo(\n\t\t() => ({\n\t\t\temitConversationStart: (\n\t\t\t\tconversationId: string,\n\t\t\t\tconversation?: Conversation\n\t\t\t) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"conversationStart\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tconversation,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitConversationEnd: (\n\t\t\t\tconversationId: string,\n\t\t\t\tconversation?: Conversation\n\t\t\t) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"conversationEnd\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tconversation,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitMessageSent: (conversationId: string, message: TimelineItem) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"messageSent\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitMessageReceived: (conversationId: string, message: TimelineItem) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"messageReceived\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitError: (error: Error, context?: string) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\terror,\n\t\t\t\t\tcontext,\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t\t[events]\n\t);\n}\n"],"mappings":";;;;;;AAoGA,MAAM,uBACLA,QAAM,cAAgD,KAAK;;;;;;;;;;;;;;AAmB5D,MAAaC,yBAA+D,EAC3E,qBACA,mBACA,eACA,mBACA,SACA,eACK;CAEL,MAAM,eAAeD,QAAM,OAA8B;EACxD;EACA;EACA;EACA;EACA;EACA,CAAC;AAGF,SAAM,gBAAgB;AACrB,eAAa,UAAU;GACtB;GACA;GACA;GACA;GACA;GACA;IACC;EACF;EACA;EACA;EACA;EACA;EACA,CAAC;CAGF,MAAM,iBAAiBA,QAAM,uBAE3B,IAAI,KAAK,CAAC;CAEZ,MAAM,OAAOA,QAAM,aAAqC,UAAa;AAEpE,UAAQ,MAAM,MAAd;GACC,KAAK;AACJ,iBAAa,QAAQ,sBAAsB,MAAM;AACjD;GACD,KAAK;AACJ,iBAAa,QAAQ,oBAAoB,MAAM;AAC/C;GACD,KAAK;AACJ,iBAAa,QAAQ,gBAAgB,MAAM;AAC3C;GACD,KAAK;AACJ,iBAAa,QAAQ,oBAAoB,MAAM;AAC/C;GACD,KAAK;AACJ,iBAAa,QAAQ,UAAU,MAAM;AACrC;GACD,QAEC;;EAIF,MAAM,cAAc,eAAe,QAAQ,IAAI,MAAM,KAAK;AAC1D,MAAI,YACH,MAAK,MAAM,YAAY,YACtB,UAAS,MAAM;IAGf,EAAE,CAAC;CAEN,MAAM,YAAYA,QAAM,aAEtB,MACA,aACI;AACJ,MAAI,CAAC,eAAe,QAAQ,IAAI,KAAK,CACpC,gBAAe,QAAQ,IAAI,sBAAM,IAAI,KAAK,CAAC;EAE5C,MAAM,cAAc,eAAe,QAAQ,IAAI,KAAK;AACpD,eAAa,IAAI,SAA0C;AAG3D,eAAa;AACZ,gBAAa,OAAO,SAA0C;;IAGhE,EAAE,CACF;CAED,MAAM,QAAQA,QAAM,eACZ;EAAE;EAAM;EAAW,GAC1B,CAAC,MAAM,UAAU,CACjB;AAED,QACC,oBAAC,qBAAqB;EAAgB;EACpC;GAC8B;;;;;;AAQlC,SAAgB,mBAAqD;AACpE,QAAOA,QAAM,WAAW,qBAAqB;;;;;;AAO9C,SAAgB,yBAAyB;CACxC,MAAM,SAAS,kBAAkB;AAEjC,QAAOA,QAAM,eACL;EACN,wBACC,gBACA,iBACI;AACJ,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,sBACC,gBACA,iBACI;AACJ,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,kBAAkB,gBAAwB,YAA0B;AACnE,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,sBAAsB,gBAAwB,YAA0B;AACvE,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,YAAY,OAAc,YAAqB;AAC9C,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,GACD,CAAC,OAAO,CACR"}
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
 
3
-
4
3
  import { useSupportConfig, useSupportNavigation } from "../store/support-store.js";
5
4
  import { PENDING_CONVERSATION_ID } from "../../utils/id.js";
6
5
  import * as React$1 from "react";
@@ -1 +1 @@
1
- {"version":3,"file":"handle.js","names":["React","SupportHandleProvider: React.FC<SupportHandleProviderProps>"],"sources":["../../../src/support/context/handle.tsx"],"sourcesContent":["\"use client\";\n\nimport type { RouteRegistry } from \"@cossistant/core\";\nimport * as React from \"react\";\nimport { PENDING_CONVERSATION_ID } from \"../../utils/id\";\nimport { useSupportConfig, useSupportNavigation } from \"../store/support-store\";\n\n// =============================================================================\n// Handle Type\n// =============================================================================\n\n/**\n * Imperative handle for programmatic control of the Support widget.\n * Access via ref on the Support component or via useSupportHandle hook.\n *\n * @example\n * const supportRef = useRef<SupportHandle>(null);\n *\n * // Open the widget\n * supportRef.current?.open();\n *\n * // Navigate to a conversation\n * supportRef.current?.openConversation(\"conv_123\");\n *\n * // Start a new conversation with a message\n * supportRef.current?.startConversation(\"I need help with...\");\n *\n * <Support ref={supportRef} />\n */\nexport type SupportHandle = {\n\t/**\n\t * Open the support widget.\n\t */\n\topen: () => void;\n\t/**\n\t * Close the support widget.\n\t */\n\tclose: () => void;\n\t/**\n\t * Toggle the support widget open/closed.\n\t */\n\ttoggle: () => void;\n\t/**\n\t * Navigate to a specific page with optional params.\n\t */\n\tnavigate: <K extends keyof RouteRegistry>(options: {\n\t\tpage: K;\n\t\tparams?: RouteRegistry[K];\n\t}) => void;\n\t/**\n\t * Go back to the previous page.\n\t */\n\tgoBack: () => void;\n\t/**\n\t * Open a specific conversation.\n\t */\n\topenConversation: (conversationId: string) => void;\n\t/**\n\t * Start a new conversation, optionally with an initial message.\n\t */\n\tstartConversation: (initialMessage?: string) => void;\n\t/**\n\t * Navigate to the home page.\n\t */\n\tgoHome: () => void;\n};\n\n// =============================================================================\n// Context\n// =============================================================================\n\nconst SupportHandleContext = React.createContext<SupportHandle | null>(null);\n\nexport type SupportHandleProviderProps = {\n\t/**\n\t * Ref to expose the handle to parent components.\n\t */\n\tforwardedRef?: React.Ref<SupportHandle>;\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider that creates and exposes the imperative handle.\n */\nexport const SupportHandleProvider: React.FC<SupportHandleProviderProps> = ({\n\tforwardedRef,\n\tchildren,\n}) => {\n\tconst { open, close, toggle } = useSupportConfig();\n\tconst { navigate, goBack } = useSupportNavigation();\n\n\tconst handle = React.useMemo<SupportHandle>(\n\t\t() => ({\n\t\t\topen,\n\t\t\tclose,\n\t\t\ttoggle,\n\t\t\tnavigate: <K extends keyof RouteRegistry>(options: {\n\t\t\t\tpage: K;\n\t\t\t\tparams?: RouteRegistry[K];\n\t\t\t}) => {\n\t\t\t\t// Use type assertion since we know the navigate function accepts these types\n\t\t\t\tnavigate(options as Parameters<typeof navigate>[0]);\n\t\t\t},\n\t\t\tgoBack,\n\t\t\topenConversation: (conversationId: string) => {\n\t\t\t\tnavigate({\n\t\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\t\tparams: { conversationId },\n\t\t\t\t});\n\t\t\t\t// Also open the widget if closed\n\t\t\t\topen();\n\t\t\t},\n\t\t\tstartConversation: (initialMessage?: string) => {\n\t\t\t\tnavigate({\n\t\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tconversationId: PENDING_CONVERSATION_ID,\n\t\t\t\t\t\tinitialMessage,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\t// Also open the widget if closed\n\t\t\t\topen();\n\t\t\t},\n\t\t\tgoHome: () => {\n\t\t\t\tnavigate({ page: \"HOME\" });\n\t\t\t},\n\t\t}),\n\t\t[open, close, toggle, navigate, goBack]\n\t);\n\n\t// Expose handle via ref\n\tReact.useImperativeHandle(forwardedRef, () => handle, [handle]);\n\n\treturn (\n\t\t<SupportHandleContext.Provider value={handle}>\n\t\t\t{children}\n\t\t</SupportHandleContext.Provider>\n\t);\n};\n\n// =============================================================================\n// Hook\n// =============================================================================\n\n/**\n * Hook to access the imperative handle from within the widget.\n * Returns null if not inside Support component.\n *\n * @example\n * function MyComponent() {\n * const support = useSupportHandle();\n *\n * return (\n * <button onClick={() => support?.startConversation(\"Hello!\")}>\n * Get Help\n * </button>\n * );\n * }\n */\nexport function useSupportHandle(): SupportHandle | null {\n\treturn React.useContext(SupportHandleContext);\n}\n"],"mappings":";;;;;;;;;AAuEA,MAAM,uBAAuBA,QAAM,cAAoC,KAAK;;;;AAa5E,MAAaC,yBAA+D,EAC3E,cACA,eACK;CACL,MAAM,EAAE,MAAM,OAAO,WAAW,kBAAkB;CAClD,MAAM,EAAE,UAAU,WAAW,sBAAsB;CAEnD,MAAM,SAASD,QAAM,eACb;EACN;EACA;EACA;EACA,WAA0C,YAGpC;AAEL,YAAS,QAA0C;;EAEpD;EACA,mBAAmB,mBAA2B;AAC7C,YAAS;IACR,MAAM;IACN,QAAQ,EAAE,gBAAgB;IAC1B,CAAC;AAEF,SAAM;;EAEP,oBAAoB,mBAA4B;AAC/C,YAAS;IACR,MAAM;IACN,QAAQ;KACP,gBAAgB;KAChB;KACA;IACD,CAAC;AAEF,SAAM;;EAEP,cAAc;AACb,YAAS,EAAE,MAAM,QAAQ,CAAC;;EAE3B,GACD;EAAC;EAAM;EAAO;EAAQ;EAAU;EAAO,CACvC;AAGD,SAAM,oBAAoB,oBAAoB,QAAQ,CAAC,OAAO,CAAC;AAE/D,QACC,oBAAC,qBAAqB;EAAS,OAAO;EACpC;GAC8B;;;;;;;;;;;;;;;;;AAuBlC,SAAgB,mBAAyC;AACxD,QAAOA,QAAM,WAAW,qBAAqB"}
1
+ {"version":3,"file":"handle.js","names":["React","SupportHandleProvider: React.FC<SupportHandleProviderProps>"],"sources":["../../../src/support/context/handle.tsx"],"sourcesContent":["\"use client\";\n\nimport type { RouteRegistry } from \"@cossistant/core\";\nimport * as React from \"react\";\nimport { PENDING_CONVERSATION_ID } from \"../../utils/id\";\nimport { useSupportConfig, useSupportNavigation } from \"../store/support-store\";\n\n// =============================================================================\n// Handle Type\n// =============================================================================\n\n/**\n * Imperative handle for programmatic control of the Support widget.\n * Access via ref on the Support component or via useSupportHandle hook.\n *\n * @example\n * const supportRef = useRef<SupportHandle>(null);\n *\n * // Open the widget\n * supportRef.current?.open();\n *\n * // Navigate to a conversation\n * supportRef.current?.openConversation(\"conv_123\");\n *\n * // Start a new conversation with a message\n * supportRef.current?.startConversation(\"I need help with...\");\n *\n * <Support ref={supportRef} />\n */\nexport type SupportHandle = {\n\t/**\n\t * Open the support widget.\n\t */\n\topen: () => void;\n\t/**\n\t * Close the support widget.\n\t */\n\tclose: () => void;\n\t/**\n\t * Toggle the support widget open/closed.\n\t */\n\ttoggle: () => void;\n\t/**\n\t * Navigate to a specific page with optional params.\n\t */\n\tnavigate: <K extends keyof RouteRegistry>(options: {\n\t\tpage: K;\n\t\tparams?: RouteRegistry[K];\n\t}) => void;\n\t/**\n\t * Go back to the previous page.\n\t */\n\tgoBack: () => void;\n\t/**\n\t * Open a specific conversation.\n\t */\n\topenConversation: (conversationId: string) => void;\n\t/**\n\t * Start a new conversation, optionally with an initial message.\n\t */\n\tstartConversation: (initialMessage?: string) => void;\n\t/**\n\t * Navigate to the home page.\n\t */\n\tgoHome: () => void;\n};\n\n// =============================================================================\n// Context\n// =============================================================================\n\nconst SupportHandleContext = React.createContext<SupportHandle | null>(null);\n\nexport type SupportHandleProviderProps = {\n\t/**\n\t * Ref to expose the handle to parent components.\n\t */\n\tforwardedRef?: React.Ref<SupportHandle>;\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider that creates and exposes the imperative handle.\n */\nexport const SupportHandleProvider: React.FC<SupportHandleProviderProps> = ({\n\tforwardedRef,\n\tchildren,\n}) => {\n\tconst { open, close, toggle } = useSupportConfig();\n\tconst { navigate, goBack } = useSupportNavigation();\n\n\tconst handle = React.useMemo<SupportHandle>(\n\t\t() => ({\n\t\t\topen,\n\t\t\tclose,\n\t\t\ttoggle,\n\t\t\tnavigate: <K extends keyof RouteRegistry>(options: {\n\t\t\t\tpage: K;\n\t\t\t\tparams?: RouteRegistry[K];\n\t\t\t}) => {\n\t\t\t\t// Use type assertion since we know the navigate function accepts these types\n\t\t\t\tnavigate(options as Parameters<typeof navigate>[0]);\n\t\t\t},\n\t\t\tgoBack,\n\t\t\topenConversation: (conversationId: string) => {\n\t\t\t\tnavigate({\n\t\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\t\tparams: { conversationId },\n\t\t\t\t});\n\t\t\t\t// Also open the widget if closed\n\t\t\t\topen();\n\t\t\t},\n\t\t\tstartConversation: (initialMessage?: string) => {\n\t\t\t\tnavigate({\n\t\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tconversationId: PENDING_CONVERSATION_ID,\n\t\t\t\t\t\tinitialMessage,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\t// Also open the widget if closed\n\t\t\t\topen();\n\t\t\t},\n\t\t\tgoHome: () => {\n\t\t\t\tnavigate({ page: \"HOME\" });\n\t\t\t},\n\t\t}),\n\t\t[open, close, toggle, navigate, goBack]\n\t);\n\n\t// Expose handle via ref\n\tReact.useImperativeHandle(forwardedRef, () => handle, [handle]);\n\n\treturn (\n\t\t<SupportHandleContext.Provider value={handle}>\n\t\t\t{children}\n\t\t</SupportHandleContext.Provider>\n\t);\n};\n\n// =============================================================================\n// Hook\n// =============================================================================\n\n/**\n * Hook to access the imperative handle from within the widget.\n * Returns null if not inside Support component.\n *\n * @example\n * function MyComponent() {\n * const support = useSupportHandle();\n *\n * return (\n * <button onClick={() => support?.startConversation(\"Hello!\")}>\n * Get Help\n * </button>\n * );\n * }\n */\nexport function useSupportHandle(): SupportHandle | null {\n\treturn React.useContext(SupportHandleContext);\n}\n"],"mappings":";;;;;;;;AAuEA,MAAM,uBAAuBA,QAAM,cAAoC,KAAK;;;;AAa5E,MAAaC,yBAA+D,EAC3E,cACA,eACK;CACL,MAAM,EAAE,MAAM,OAAO,WAAW,kBAAkB;CAClD,MAAM,EAAE,UAAU,WAAW,sBAAsB;CAEnD,MAAM,SAASD,QAAM,eACb;EACN;EACA;EACA;EACA,WAA0C,YAGpC;AAEL,YAAS,QAA0C;;EAEpD;EACA,mBAAmB,mBAA2B;AAC7C,YAAS;IACR,MAAM;IACN,QAAQ,EAAE,gBAAgB;IAC1B,CAAC;AAEF,SAAM;;EAEP,oBAAoB,mBAA4B;AAC/C,YAAS;IACR,MAAM;IACN,QAAQ;KACP,gBAAgB;KAChB;KACA;IACD,CAAC;AAEF,SAAM;;EAEP,cAAc;AACb,YAAS,EAAE,MAAM,QAAQ,CAAC;;EAE3B,GACD;EAAC;EAAM;EAAO;EAAQ;EAAU;EAAO,CACvC;AAGD,SAAM,oBAAoB,oBAAoB,QAAQ,CAAC,OAAO,CAAC;AAE/D,QACC,oBAAC,qBAAqB;EAAS,OAAO;EACpC;GAC8B;;;;;;;;;;;;;;;;;AAuBlC,SAAgB,mBAAyC;AACxD,QAAOA,QAAM,WAAW,qBAAqB"}
@@ -0,0 +1,33 @@
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+
3
+ //#region src/support/context/identification.d.ts
4
+ type IdentificationState = {
5
+ /**
6
+ * Whether an identification request is currently in progress.
7
+ * When true, the identification form should not be shown.
8
+ */
9
+ isIdentifying: boolean;
10
+ /**
11
+ * Set the identifying state (used internally by IdentifySupportVisitor).
12
+ */
13
+ setIsIdentifying: (value: boolean) => void;
14
+ };
15
+ type IdentificationProviderProps = {
16
+ children: React.ReactNode;
17
+ };
18
+ /**
19
+ * Provider for tracking visitor identification state.
20
+ * This is used internally to prevent showing the identification form
21
+ * while an identification request is in progress.
22
+ */
23
+ declare function IdentificationProvider({
24
+ children
25
+ }: IdentificationProviderProps): react_jsx_runtime0.JSX.Element;
26
+ /**
27
+ * Hook to access the identification state.
28
+ * Returns null if used outside of IdentificationProvider.
29
+ */
30
+ declare function useIdentificationState(): IdentificationState | null;
31
+ //#endregion
32
+ export { IdentificationProvider, useIdentificationState };
33
+ //# sourceMappingURL=identification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identification.d.ts","names":[],"sources":["../../../src/support/context/identification.tsx"],"sourcesContent":[],"mappings":";;;KAIK,mBAAA;;;AAyByB;AAzBN;EAuBR,aAAA,EAAA,OAAA;EACf;;;EAC6B,gBAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,GAAA,IAAA;AAsB9B,CAAA;KAjCK,2BAAA;YACM,KAAA,CAAM;;;;;;;iBAQD,sBAAA;;GAEb,8BAA2B,kBAAA,CAAA,GAAA,CAAA;;;;;iBAsBd,sBAAA,CAAA,GAA0B"}
@@ -0,0 +1,34 @@
1
+ "use client";
2
+
3
+ import { createContext, useContext, useMemo, useState } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+
6
+ //#region src/support/context/identification.tsx
7
+ const IdentificationContext = createContext(null);
8
+ /**
9
+ * Provider for tracking visitor identification state.
10
+ * This is used internally to prevent showing the identification form
11
+ * while an identification request is in progress.
12
+ */
13
+ function IdentificationProvider({ children }) {
14
+ const [isIdentifying, setIsIdentifying] = useState(false);
15
+ const value = useMemo(() => ({
16
+ isIdentifying,
17
+ setIsIdentifying
18
+ }), [isIdentifying]);
19
+ return /* @__PURE__ */ jsx(IdentificationContext.Provider, {
20
+ value,
21
+ children
22
+ });
23
+ }
24
+ /**
25
+ * Hook to access the identification state.
26
+ * Returns null if used outside of IdentificationProvider.
27
+ */
28
+ function useIdentificationState() {
29
+ return useContext(IdentificationContext);
30
+ }
31
+
32
+ //#endregion
33
+ export { IdentificationProvider, useIdentificationState };
34
+ //# sourceMappingURL=identification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identification.js","names":[],"sources":["../../../src/support/context/identification.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, useMemo, useState } from \"react\";\n\ntype IdentificationState = {\n\t/**\n\t * Whether an identification request is currently in progress.\n\t * When true, the identification form should not be shown.\n\t */\n\tisIdentifying: boolean;\n\t/**\n\t * Set the identifying state (used internally by IdentifySupportVisitor).\n\t */\n\tsetIsIdentifying: (value: boolean) => void;\n};\n\nconst IdentificationContext = createContext<IdentificationState | null>(null);\n\ntype IdentificationProviderProps = {\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider for tracking visitor identification state.\n * This is used internally to prevent showing the identification form\n * while an identification request is in progress.\n */\nexport function IdentificationProvider({\n\tchildren,\n}: IdentificationProviderProps) {\n\tconst [isIdentifying, setIsIdentifying] = useState(false);\n\n\tconst value = useMemo(\n\t\t() => ({\n\t\t\tisIdentifying,\n\t\t\tsetIsIdentifying,\n\t\t}),\n\t\t[isIdentifying]\n\t);\n\n\treturn (\n\t\t<IdentificationContext.Provider value={value}>\n\t\t\t{children}\n\t\t</IdentificationContext.Provider>\n\t);\n}\n\n/**\n * Hook to access the identification state.\n * Returns null if used outside of IdentificationProvider.\n */\nexport function useIdentificationState(): IdentificationState | null {\n\treturn useContext(IdentificationContext);\n}\n"],"mappings":";;;;;;AAgBA,MAAM,wBAAwB,cAA0C,KAAK;;;;;;AAW7E,SAAgB,uBAAuB,EACtC,YAC+B;CAC/B,MAAM,CAAC,eAAe,oBAAoB,SAAS,MAAM;CAEzD,MAAM,QAAQ,eACN;EACN;EACA;EACA,GACD,CAAC,cAAc,CACf;AAED,QACC,oBAAC,sBAAsB;EAAgB;EACrC;GAC+B;;;;;;AAQnC,SAAgB,yBAAqD;AACpE,QAAO,WAAW,sBAAsB"}
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
 
3
-
4
3
  import * as React$1 from "react";
5
4
  import { jsx } from "react/jsx-runtime";
6
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"positioning.js","names":["React","TriggerRefProvider: React.FC<TriggerRefProviderProps>"],"sources":["../../../src/support/context/positioning.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport type TriggerRefContextValue = {\n\t/** The trigger element (state-based for reactivity) */\n\ttriggerElement: HTMLElement | null;\n\t/** Set the trigger element - triggers re-render when called */\n\tsetTriggerElement: (element: HTMLElement | null) => void;\n};\n\n// =============================================================================\n// Context\n// =============================================================================\n\nconst TriggerRefContext = React.createContext<TriggerRefContextValue | null>(\n\tnull\n);\n\n// =============================================================================\n// Provider\n// =============================================================================\n\nexport type TriggerRefProviderProps = {\n\tchildren: React.ReactNode;\n};\n\nexport const TriggerRefProvider: React.FC<TriggerRefProviderProps> = ({\n\tchildren,\n}) => {\n\t// Using state instead of ref to trigger re-renders when trigger mounts\n\t// This ensures Floating UI receives the reference element\n\tconst [triggerElement, setTriggerElement] =\n\t\tReact.useState<HTMLElement | null>(null);\n\n\tconst value = React.useMemo<TriggerRefContextValue>(\n\t\t() => ({\n\t\t\ttriggerElement,\n\t\t\tsetTriggerElement,\n\t\t}),\n\t\t[triggerElement]\n\t);\n\n\treturn (\n\t\t<TriggerRefContext.Provider value={value}>\n\t\t\t{children}\n\t\t</TriggerRefContext.Provider>\n\t);\n};\n\n// =============================================================================\n// Hook\n// =============================================================================\n\nexport function useTriggerRef(): TriggerRefContextValue | null {\n\treturn React.useContext(TriggerRefContext);\n}\n"],"mappings":";;;;;;;AAmBA,MAAM,oBAAoBA,QAAM,cAC/B,KACA;AAUD,MAAaC,sBAAyD,EACrE,eACK;CAGL,MAAM,CAAC,gBAAgB,qBACtBD,QAAM,SAA6B,KAAK;CAEzC,MAAM,QAAQA,QAAM,eACZ;EACN;EACA;EACA,GACD,CAAC,eAAe,CAChB;AAED,QACC,oBAAC,kBAAkB;EAAgB;EACjC;GAC2B;;AAQ/B,SAAgB,gBAA+C;AAC9D,QAAOA,QAAM,WAAW,kBAAkB"}
1
+ {"version":3,"file":"positioning.js","names":["React","TriggerRefProvider: React.FC<TriggerRefProviderProps>"],"sources":["../../../src/support/context/positioning.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport type TriggerRefContextValue = {\n\t/** The trigger element (state-based for reactivity) */\n\ttriggerElement: HTMLElement | null;\n\t/** Set the trigger element - triggers re-render when called */\n\tsetTriggerElement: (element: HTMLElement | null) => void;\n};\n\n// =============================================================================\n// Context\n// =============================================================================\n\nconst TriggerRefContext = React.createContext<TriggerRefContextValue | null>(\n\tnull\n);\n\n// =============================================================================\n// Provider\n// =============================================================================\n\nexport type TriggerRefProviderProps = {\n\tchildren: React.ReactNode;\n};\n\nexport const TriggerRefProvider: React.FC<TriggerRefProviderProps> = ({\n\tchildren,\n}) => {\n\t// Using state instead of ref to trigger re-renders when trigger mounts\n\t// This ensures Floating UI receives the reference element\n\tconst [triggerElement, setTriggerElement] =\n\t\tReact.useState<HTMLElement | null>(null);\n\n\tconst value = React.useMemo<TriggerRefContextValue>(\n\t\t() => ({\n\t\t\ttriggerElement,\n\t\t\tsetTriggerElement,\n\t\t}),\n\t\t[triggerElement]\n\t);\n\n\treturn (\n\t\t<TriggerRefContext.Provider value={value}>\n\t\t\t{children}\n\t\t</TriggerRefContext.Provider>\n\t);\n};\n\n// =============================================================================\n// Hook\n// =============================================================================\n\nexport function useTriggerRef(): TriggerRefContextValue | null {\n\treturn React.useContext(TriggerRefContext);\n}\n"],"mappings":";;;;;;AAmBA,MAAM,oBAAoBA,QAAM,cAC/B,KACA;AAUD,MAAaC,sBAAyD,EACrE,eACK;CAGL,MAAM,CAAC,gBAAgB,qBACtBD,QAAM,SAA6B,KAAK;CAEzC,MAAM,QAAQA,QAAM,eACZ;EACN;EACA;EACA,GACD,CAAC,eAAe,CAChB;AAED,QACC,oBAAC,kBAAkB;EAAgB;EACjC;GAC2B;;AAQ/B,SAAgB,gBAA+C;AAC9D,QAAOA,QAAM,WAAW,kBAAkB"}
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
 
3
-
4
3
  import * as React$1 from "react";
5
4
  import { jsx } from "react/jsx-runtime";
6
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"slots.js","names":["React","SlotProvider: React.FC<SlotProviderProps>","HeaderSlot: React.FC<SlotProps>","FooterSlot: React.FC<SlotProps>"],"sources":["../../../src/support/context/slots.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// =============================================================================\n// Slot Types\n// =============================================================================\n\nexport type SlotContextValue = {\n\t/**\n\t * Custom header slot content\n\t */\n\theader: React.ReactNode | null;\n\t/**\n\t * Custom footer slot content\n\t */\n\tfooter: React.ReactNode | null;\n\t/**\n\t * Whether to use the custom header\n\t */\n\thasCustomHeader: boolean;\n\t/**\n\t * Whether to use the custom footer\n\t */\n\thasCustomFooter: boolean;\n};\n\ntype SlotRegistration = {\n\tregisterHeader: (content: React.ReactNode) => void;\n\tregisterFooter: (content: React.ReactNode) => void;\n\tunregisterHeader: () => void;\n\tunregisterFooter: () => void;\n};\n\nconst SlotContext = React.createContext<SlotContextValue>({\n\theader: null,\n\tfooter: null,\n\thasCustomHeader: false,\n\thasCustomFooter: false,\n});\n\nconst SlotRegistrationContext = React.createContext<SlotRegistration | null>(\n\tnull\n);\n\n// =============================================================================\n// Provider\n// =============================================================================\n\nexport type SlotProviderProps = {\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider for slot-based customization.\n * Allows children to register custom header/footer content.\n */\nexport const SlotProvider: React.FC<SlotProviderProps> = ({ children }) => {\n\tconst [header, setHeader] = React.useState<React.ReactNode | null>(null);\n\tconst [footer, setFooter] = React.useState<React.ReactNode | null>(null);\n\n\tconst registration = React.useMemo<SlotRegistration>(\n\t\t() => ({\n\t\t\tregisterHeader: (content) => setHeader(content),\n\t\t\tregisterFooter: (content) => setFooter(content),\n\t\t\tunregisterHeader: () => setHeader(null),\n\t\t\tunregisterFooter: () => setFooter(null),\n\t\t}),\n\t\t[]\n\t);\n\n\tconst value = React.useMemo<SlotContextValue>(\n\t\t() => ({\n\t\t\theader,\n\t\t\tfooter,\n\t\t\thasCustomHeader: header !== null,\n\t\t\thasCustomFooter: footer !== null,\n\t\t}),\n\t\t[header, footer]\n\t);\n\n\treturn (\n\t\t<SlotRegistrationContext.Provider value={registration}>\n\t\t\t<SlotContext.Provider value={value}>{children}</SlotContext.Provider>\n\t\t</SlotRegistrationContext.Provider>\n\t);\n};\n\n// =============================================================================\n// Hooks\n// =============================================================================\n\n/**\n * Access slot values (for content component)\n */\nexport function useSlots(): SlotContextValue {\n\treturn React.useContext(SlotContext);\n}\n\n/**\n * Access slot registration (for slot components)\n */\nfunction useSlotRegistration(): SlotRegistration | null {\n\treturn React.useContext(SlotRegistrationContext);\n}\n\n// =============================================================================\n// Slot Components\n// =============================================================================\n\nexport type SlotProps = {\n\t/**\n\t * Content to render in the slot.\n\t */\n\tchildren: React.ReactNode;\n\t/**\n\t * When true, renders children directly without a wrapper.\n\t * Useful when you want your component to receive all props.\n\t */\n\tasChild?: boolean;\n};\n\n/**\n * Header slot component.\n * Use inside Support.Content to replace the default header.\n *\n * @example\n * <Support.Content>\n * <Support.Header>\n * <MyCustomHeader />\n * </Support.Header>\n * <Support.Router />\n * </Support.Content>\n *\n * @example\n * // With asChild pattern\n * <Support.Header asChild>\n * <MyCustomHeader showBackButton />\n * </Support.Header>\n */\nexport const HeaderSlot: React.FC<SlotProps> = ({ children, asChild }) => {\n\tconst registration = useSlotRegistration();\n\n\tReact.useEffect(() => {\n\t\tif (registration) {\n\t\t\tregistration.registerHeader(children);\n\t\t\treturn () => registration.unregisterHeader();\n\t\t}\n\t}, [registration, children]);\n\n\t// This component doesn't render anything directly\n\t// It registers its children as the header slot\n\treturn null;\n};\n\n(HeaderSlot as React.FC & { displayName?: string }).displayName =\n\t\"Support.Header\";\n\n/**\n * Footer slot component.\n * Use inside Support.Content to replace the default footer.\n *\n * @example\n * <Support.Content>\n * <Support.Router />\n * <Support.Footer>\n * <MyCustomFooter />\n * </Support.Footer>\n * </Support.Content>\n *\n * @example\n * // With asChild pattern\n * <Support.Footer asChild>\n * <MyCustomFooter showBranding={false} />\n * </Support.Footer>\n */\nexport const FooterSlot: React.FC<SlotProps> = ({ children, asChild }) => {\n\tconst registration = useSlotRegistration();\n\n\tReact.useEffect(() => {\n\t\tif (registration) {\n\t\t\tregistration.registerFooter(children);\n\t\t\treturn () => registration.unregisterFooter();\n\t\t}\n\t}, [registration, children]);\n\n\t// This component doesn't render anything directly\n\t// It registers its children as the footer slot\n\treturn null;\n};\n\n(FooterSlot as React.FC & { displayName?: string }).displayName =\n\t\"Support.Footer\";\n"],"mappings":";;;;;;;AAkCA,MAAM,cAAcA,QAAM,cAAgC;CACzD,QAAQ;CACR,QAAQ;CACR,iBAAiB;CACjB,iBAAiB;CACjB,CAAC;AAEF,MAAM,0BAA0BA,QAAM,cACrC,KACA;;;;;AAcD,MAAaC,gBAA6C,EAAE,eAAe;CAC1E,MAAM,CAAC,QAAQ,aAAaD,QAAM,SAAiC,KAAK;CACxE,MAAM,CAAC,QAAQ,aAAaA,QAAM,SAAiC,KAAK;CAExE,MAAM,eAAeA,QAAM,eACnB;EACN,iBAAiB,YAAY,UAAU,QAAQ;EAC/C,iBAAiB,YAAY,UAAU,QAAQ;EAC/C,wBAAwB,UAAU,KAAK;EACvC,wBAAwB,UAAU,KAAK;EACvC,GACD,EAAE,CACF;CAED,MAAM,QAAQA,QAAM,eACZ;EACN;EACA;EACA,iBAAiB,WAAW;EAC5B,iBAAiB,WAAW;EAC5B,GACD,CAAC,QAAQ,OAAO,CAChB;AAED,QACC,oBAAC,wBAAwB;EAAS,OAAO;YACxC,oBAAC,YAAY;GAAgB;GAAQ;IAAgC;GACnC;;;;;AAWrC,SAAgB,WAA6B;AAC5C,QAAOA,QAAM,WAAW,YAAY;;;;;AAMrC,SAAS,sBAA+C;AACvD,QAAOA,QAAM,WAAW,wBAAwB;;;;;;;;;;;;;;;;;;;;AAqCjD,MAAaE,cAAmC,EAAE,UAAU,cAAc;CACzE,MAAM,eAAe,qBAAqB;AAE1C,SAAM,gBAAgB;AACrB,MAAI,cAAc;AACjB,gBAAa,eAAe,SAAS;AACrC,gBAAa,aAAa,kBAAkB;;IAE3C,CAAC,cAAc,SAAS,CAAC;AAI5B,QAAO;;AAGR,AAAC,WAAmD,cACnD;;;;;;;;;;;;;;;;;;;AAoBD,MAAaC,cAAmC,EAAE,UAAU,cAAc;CACzE,MAAM,eAAe,qBAAqB;AAE1C,SAAM,gBAAgB;AACrB,MAAI,cAAc;AACjB,gBAAa,eAAe,SAAS;AACrC,gBAAa,aAAa,kBAAkB;;IAE3C,CAAC,cAAc,SAAS,CAAC;AAI5B,QAAO;;AAGR,AAAC,WAAmD,cACnD"}
1
+ {"version":3,"file":"slots.js","names":["React","SlotProvider: React.FC<SlotProviderProps>","HeaderSlot: React.FC<SlotProps>","FooterSlot: React.FC<SlotProps>"],"sources":["../../../src/support/context/slots.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// =============================================================================\n// Slot Types\n// =============================================================================\n\nexport type SlotContextValue = {\n\t/**\n\t * Custom header slot content\n\t */\n\theader: React.ReactNode | null;\n\t/**\n\t * Custom footer slot content\n\t */\n\tfooter: React.ReactNode | null;\n\t/**\n\t * Whether to use the custom header\n\t */\n\thasCustomHeader: boolean;\n\t/**\n\t * Whether to use the custom footer\n\t */\n\thasCustomFooter: boolean;\n};\n\ntype SlotRegistration = {\n\tregisterHeader: (content: React.ReactNode) => void;\n\tregisterFooter: (content: React.ReactNode) => void;\n\tunregisterHeader: () => void;\n\tunregisterFooter: () => void;\n};\n\nconst SlotContext = React.createContext<SlotContextValue>({\n\theader: null,\n\tfooter: null,\n\thasCustomHeader: false,\n\thasCustomFooter: false,\n});\n\nconst SlotRegistrationContext = React.createContext<SlotRegistration | null>(\n\tnull\n);\n\n// =============================================================================\n// Provider\n// =============================================================================\n\nexport type SlotProviderProps = {\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider for slot-based customization.\n * Allows children to register custom header/footer content.\n */\nexport const SlotProvider: React.FC<SlotProviderProps> = ({ children }) => {\n\tconst [header, setHeader] = React.useState<React.ReactNode | null>(null);\n\tconst [footer, setFooter] = React.useState<React.ReactNode | null>(null);\n\n\tconst registration = React.useMemo<SlotRegistration>(\n\t\t() => ({\n\t\t\tregisterHeader: (content) => setHeader(content),\n\t\t\tregisterFooter: (content) => setFooter(content),\n\t\t\tunregisterHeader: () => setHeader(null),\n\t\t\tunregisterFooter: () => setFooter(null),\n\t\t}),\n\t\t[]\n\t);\n\n\tconst value = React.useMemo<SlotContextValue>(\n\t\t() => ({\n\t\t\theader,\n\t\t\tfooter,\n\t\t\thasCustomHeader: header !== null,\n\t\t\thasCustomFooter: footer !== null,\n\t\t}),\n\t\t[header, footer]\n\t);\n\n\treturn (\n\t\t<SlotRegistrationContext.Provider value={registration}>\n\t\t\t<SlotContext.Provider value={value}>{children}</SlotContext.Provider>\n\t\t</SlotRegistrationContext.Provider>\n\t);\n};\n\n// =============================================================================\n// Hooks\n// =============================================================================\n\n/**\n * Access slot values (for content component)\n */\nexport function useSlots(): SlotContextValue {\n\treturn React.useContext(SlotContext);\n}\n\n/**\n * Access slot registration (for slot components)\n */\nfunction useSlotRegistration(): SlotRegistration | null {\n\treturn React.useContext(SlotRegistrationContext);\n}\n\n// =============================================================================\n// Slot Components\n// =============================================================================\n\nexport type SlotProps = {\n\t/**\n\t * Content to render in the slot.\n\t */\n\tchildren: React.ReactNode;\n\t/**\n\t * When true, renders children directly without a wrapper.\n\t * Useful when you want your component to receive all props.\n\t */\n\tasChild?: boolean;\n};\n\n/**\n * Header slot component.\n * Use inside Support.Content to replace the default header.\n *\n * @example\n * <Support.Content>\n * <Support.Header>\n * <MyCustomHeader />\n * </Support.Header>\n * <Support.Router />\n * </Support.Content>\n *\n * @example\n * // With asChild pattern\n * <Support.Header asChild>\n * <MyCustomHeader showBackButton />\n * </Support.Header>\n */\nexport const HeaderSlot: React.FC<SlotProps> = ({ children, asChild }) => {\n\tconst registration = useSlotRegistration();\n\n\tReact.useEffect(() => {\n\t\tif (registration) {\n\t\t\tregistration.registerHeader(children);\n\t\t\treturn () => registration.unregisterHeader();\n\t\t}\n\t}, [registration, children]);\n\n\t// This component doesn't render anything directly\n\t// It registers its children as the header slot\n\treturn null;\n};\n\n(HeaderSlot as React.FC & { displayName?: string }).displayName =\n\t\"Support.Header\";\n\n/**\n * Footer slot component.\n * Use inside Support.Content to replace the default footer.\n *\n * @example\n * <Support.Content>\n * <Support.Router />\n * <Support.Footer>\n * <MyCustomFooter />\n * </Support.Footer>\n * </Support.Content>\n *\n * @example\n * // With asChild pattern\n * <Support.Footer asChild>\n * <MyCustomFooter showBranding={false} />\n * </Support.Footer>\n */\nexport const FooterSlot: React.FC<SlotProps> = ({ children, asChild }) => {\n\tconst registration = useSlotRegistration();\n\n\tReact.useEffect(() => {\n\t\tif (registration) {\n\t\t\tregistration.registerFooter(children);\n\t\t\treturn () => registration.unregisterFooter();\n\t\t}\n\t}, [registration, children]);\n\n\t// This component doesn't render anything directly\n\t// It registers its children as the footer slot\n\treturn null;\n};\n\n(FooterSlot as React.FC & { displayName?: string }).displayName =\n\t\"Support.Footer\";\n"],"mappings":";;;;;;AAkCA,MAAM,cAAcA,QAAM,cAAgC;CACzD,QAAQ;CACR,QAAQ;CACR,iBAAiB;CACjB,iBAAiB;CACjB,CAAC;AAEF,MAAM,0BAA0BA,QAAM,cACrC,KACA;;;;;AAcD,MAAaC,gBAA6C,EAAE,eAAe;CAC1E,MAAM,CAAC,QAAQ,aAAaD,QAAM,SAAiC,KAAK;CACxE,MAAM,CAAC,QAAQ,aAAaA,QAAM,SAAiC,KAAK;CAExE,MAAM,eAAeA,QAAM,eACnB;EACN,iBAAiB,YAAY,UAAU,QAAQ;EAC/C,iBAAiB,YAAY,UAAU,QAAQ;EAC/C,wBAAwB,UAAU,KAAK;EACvC,wBAAwB,UAAU,KAAK;EACvC,GACD,EAAE,CACF;CAED,MAAM,QAAQA,QAAM,eACZ;EACN;EACA;EACA,iBAAiB,WAAW;EAC5B,iBAAiB,WAAW;EAC5B,GACD,CAAC,QAAQ,OAAO,CAChB;AAED,QACC,oBAAC,wBAAwB;EAAS,OAAO;YACxC,oBAAC,YAAY;GAAgB;GAAQ;IAAgC;GACnC;;;;;AAWrC,SAAgB,WAA6B;AAC5C,QAAOA,QAAM,WAAW,YAAY;;;;;AAMrC,SAAS,sBAA+C;AACvD,QAAOA,QAAM,WAAW,wBAAwB;;;;;;;;;;;;;;;;;;;;AAqCjD,MAAaE,cAAmC,EAAE,UAAU,cAAc;CACzE,MAAM,eAAe,qBAAqB;AAE1C,SAAM,gBAAgB;AACrB,MAAI,cAAc;AACjB,gBAAa,eAAe,SAAS;AACrC,gBAAa,aAAa,kBAAkB;;IAE3C,CAAC,cAAc,SAAS,CAAC;AAI5B,QAAO;;AAGR,AAAC,WAAmD,cACnD;;;;;;;;;;;;;;;;;;;AAoBD,MAAaC,cAAmC,EAAE,UAAU,cAAc;CACzE,MAAM,eAAe,qBAAqB;AAE1C,SAAM,gBAAgB;AACrB,MAAI,cAAc;AACjB,gBAAa,eAAe,SAAS;AACrC,gBAAa,aAAa,kBAAkB;;IAE3C,CAAC,cAAc,SAAS,CAAC;AAI5B,QAAO;;AAGR,AAAC,WAAmD,cACnD"}
@@ -1,4 +1,4 @@
1
- import { RealtimeEvent } from "../../realtime-events.js";
1
+ import { RealtimeEvent } from "../../packages/types/src/realtime-events.js";
2
2
  import { RealtimeContextValue } from "../../realtime/provider.js";
3
3
  import "../../realtime/index.js";
4
4
  import React from "react";
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
 
3
-
4
3
  import { RealtimeProvider, useRealtimeConnection } from "../../realtime/provider.js";
5
4
  import { createContext, useContext, useEffect, useMemo } from "react";
6
5
  import { PRESENCE_PING_INTERVAL_MS } from "@cossistant/types";
@@ -1 +1 @@
1
- {"version":3,"file":"websocket.js","names":["WebSocketBridge: React.FC<WebSocketBridgeProps>","intervalId: number | null","WebSocketProvider: React.FC<WebSocketProviderProps>"],"sources":["../../../src/support/context/websocket.tsx"],"sourcesContent":["\"use client\";\n\nimport { PRESENCE_PING_INTERVAL_MS } from \"@cossistant/types\";\nimport type React from \"react\";\nimport { createContext, useContext, useEffect, useMemo } from \"react\";\nimport {\n\ttype RealtimeAuthConfig,\n\ttype RealtimeContextValue,\n\tRealtimeProvider,\n\tuseRealtimeConnection,\n} from \"../../realtime\";\n\ntype WebSocketContextValue = RealtimeContextValue;\n\ntype WebSocketProviderProps = {\n\tchildren: React.ReactNode;\n\tpublicKey?: string;\n\twebsiteId?: string;\n\tvisitorId?: string;\n\twsUrl?: string;\n\tautoConnect?: boolean;\n\tonConnect?: () => void;\n\tonDisconnect?: () => void;\n\tonError?: (error: Error) => void;\n};\n\nconst WebSocketContext = createContext<WebSocketContextValue | null>(null);\n\nfunction createVisitorAuthConfig({\n\tvisitorId,\n\twebsiteId,\n\tpublicKey,\n}: Pick<\n\tWebSocketProviderProps,\n\t\"visitorId\" | \"websiteId\" | \"publicKey\"\n>): RealtimeAuthConfig | null {\n\tconst normalizedVisitorId = visitorId?.trim();\n\tif (!normalizedVisitorId) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tkind: \"visitor\",\n\t\tvisitorId: normalizedVisitorId,\n\t\twebsiteId: websiteId?.trim() || null,\n\t\tpublicKey: publicKey?.trim() || null,\n\t} satisfies RealtimeAuthConfig;\n}\n\ntype WebSocketBridgeProps = {\n\tchildren: React.ReactNode;\n\tonError?: (error: Error) => void;\n};\n\nconst WebSocketBridge: React.FC<WebSocketBridgeProps> = ({\n\tchildren,\n\tonError,\n}) => {\n\tconst connection = useRealtimeConnection();\n\tconst { visitorId, sendRaw, isConnected } = connection;\n\n\tuseEffect(() => {\n\t\tif (typeof window === \"undefined\" || typeof document === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!(visitorId && sendRaw)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst pingMessage = \"presence:ping\";\n\n\t\tconst sendPresencePing = () => {\n\t\t\tif (!isConnected) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tsendRaw(pingMessage);\n\t\t\t} catch (error) {\n\t\t\t\tif (!onError) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst normalizedError =\n\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t? error\n\t\t\t\t\t\t: new Error(\n\t\t\t\t\t\t\t\ttypeof error === \"string\"\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: \"Unknown presence ping error\"\n\t\t\t\t\t\t\t);\n\n\t\t\t\tif (!normalizedError.message.includes(\"Failed to send presence ping\")) {\n\t\t\t\t\tnormalizedError.message = `Failed to send presence ping: ${normalizedError.message}`;\n\t\t\t\t}\n\n\t\t\t\tonError(normalizedError);\n\t\t\t}\n\t\t};\n\n\t\tlet intervalId: number | null = null;\n\n\t\tconst clearPresenceInterval = () => {\n\t\t\tif (intervalId !== null) {\n\t\t\t\twindow.clearInterval(intervalId);\n\t\t\t\tintervalId = null;\n\t\t\t}\n\t\t};\n\n\t\tconst startPresenceInterval = () => {\n\t\t\tclearPresenceInterval();\n\n\t\t\tif (!isConnected || document.visibilityState === \"hidden\") {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tintervalId = window.setInterval(\n\t\t\t\tsendPresencePing,\n\t\t\t\tPRESENCE_PING_INTERVAL_MS\n\t\t\t);\n\t\t};\n\n\t\tconst handleFocus = () => {\n\t\t\tsendPresencePing();\n\t\t\tstartPresenceInterval();\n\t\t};\n\n\t\tconst handleVisibilityChange = () => {\n\t\t\tif (document.visibilityState === \"hidden\") {\n\t\t\t\tclearPresenceInterval();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsendPresencePing();\n\t\t\tstartPresenceInterval();\n\t\t};\n\n\t\twindow.addEventListener(\"focus\", handleFocus);\n\t\tdocument.addEventListener(\"visibilitychange\", handleVisibilityChange);\n\n\t\tif (isConnected && document.visibilityState !== \"hidden\") {\n\t\t\tsendPresencePing();\n\t\t\tstartPresenceInterval();\n\t\t}\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"focus\", handleFocus);\n\t\t\tdocument.removeEventListener(\"visibilitychange\", handleVisibilityChange);\n\t\t\tclearPresenceInterval();\n\t\t};\n\t}, [isConnected, onError, sendRaw, visitorId]);\n\tconst value = useMemo(() => connection, [connection]);\n\treturn (\n\t\t<WebSocketContext.Provider value={value}>\n\t\t\t{children}\n\t\t</WebSocketContext.Provider>\n\t);\n};\n\n/**\n * Support-specific realtime provider that authenticates visitors and keeps the\n * connection alive with presence pings.\n */\nexport const WebSocketProvider: React.FC<WebSocketProviderProps> = ({\n\tchildren,\n\tpublicKey,\n\twebsiteId,\n\tvisitorId,\n\twsUrl,\n\tautoConnect = true,\n\tonConnect,\n\tonDisconnect,\n\tonError,\n}) => {\n\tconst auth = createVisitorAuthConfig({ publicKey, websiteId, visitorId });\n\n\treturn (\n\t\t<RealtimeProvider\n\t\t\tauth={auth}\n\t\t\tautoConnect={autoConnect}\n\t\t\tonConnect={onConnect}\n\t\t\tonDisconnect={onDisconnect}\n\t\t\tonError={onError}\n\t\t\twsUrl={wsUrl}\n\t\t>\n\t\t\t<WebSocketBridge onError={onError}>{children}</WebSocketBridge>\n\t\t</RealtimeProvider>\n\t);\n};\n\n/**\n * Accessor for the support websocket context.\n * Throws if used outside WebSocketProvider.\n */\nexport const useWebSocket = (): WebSocketContextValue => {\n\tconst context = useContext(WebSocketContext);\n\tif (!context) {\n\t\tthrow new Error(\"useWebSocket must be used within WebSocketProvider\");\n\t}\n\treturn context;\n};\n\n/**\n * Safe accessor for the support websocket context.\n * Returns null if used outside WebSocketProvider instead of throwing.\n * Useful for optional WebSocket usage in hooks that may or may not have the provider.\n */\nexport const useWebSocketSafe = (): WebSocketContextValue | null =>\n\tuseContext(WebSocketContext);\n\nexport type { WebSocketContextValue, WebSocketProviderProps };\nexport type { RealtimeEvent } from \"@cossistant/types/realtime-events\";\n"],"mappings":";;;;;;;;;AA0BA,MAAM,mBAAmB,cAA4C,KAAK;AAE1E,SAAS,wBAAwB,EAChC,WACA,WACA,aAI6B;CAC7B,MAAM,sBAAsB,WAAW,MAAM;AAC7C,KAAI,CAAC,oBACJ,QAAO;AAGR,QAAO;EACN,MAAM;EACN,WAAW;EACX,WAAW,WAAW,MAAM,IAAI;EAChC,WAAW,WAAW,MAAM,IAAI;EAChC;;AAQF,MAAMA,mBAAmD,EACxD,UACA,cACK;CACL,MAAM,aAAa,uBAAuB;CAC1C,MAAM,EAAE,WAAW,SAAS,gBAAgB;AAE5C,iBAAgB;AACf,MAAI,OAAO,WAAW,eAAe,OAAO,aAAa,YACxD;AAGD,MAAI,EAAE,aAAa,SAClB;EAGD,MAAM,cAAc;EAEpB,MAAM,yBAAyB;AAC9B,OAAI,CAAC,YACJ;AAGD,OAAI;AACH,YAAQ,YAAY;YACZ,OAAO;AACf,QAAI,CAAC,QACJ;IAGD,MAAM,kBACL,iBAAiB,QACd,QACA,IAAI,MACJ,OAAO,UAAU,WACd,QACA,8BACH;AAEJ,QAAI,CAAC,gBAAgB,QAAQ,SAAS,+BAA+B,CACpE,iBAAgB,UAAU,iCAAiC,gBAAgB;AAG5E,YAAQ,gBAAgB;;;EAI1B,IAAIC,aAA4B;EAEhC,MAAM,8BAA8B;AACnC,OAAI,eAAe,MAAM;AACxB,WAAO,cAAc,WAAW;AAChC,iBAAa;;;EAIf,MAAM,8BAA8B;AACnC,0BAAuB;AAEvB,OAAI,CAAC,eAAe,SAAS,oBAAoB,SAChD;AAGD,gBAAa,OAAO,YACnB,kBACA,0BACA;;EAGF,MAAM,oBAAoB;AACzB,qBAAkB;AAClB,0BAAuB;;EAGxB,MAAM,+BAA+B;AACpC,OAAI,SAAS,oBAAoB,UAAU;AAC1C,2BAAuB;AACvB;;AAGD,qBAAkB;AAClB,0BAAuB;;AAGxB,SAAO,iBAAiB,SAAS,YAAY;AAC7C,WAAS,iBAAiB,oBAAoB,uBAAuB;AAErE,MAAI,eAAe,SAAS,oBAAoB,UAAU;AACzD,qBAAkB;AAClB,0BAAuB;;AAGxB,eAAa;AACZ,UAAO,oBAAoB,SAAS,YAAY;AAChD,YAAS,oBAAoB,oBAAoB,uBAAuB;AACxE,0BAAuB;;IAEtB;EAAC;EAAa;EAAS;EAAS;EAAU,CAAC;CAC9C,MAAM,QAAQ,cAAc,YAAY,CAAC,WAAW,CAAC;AACrD,QACC,oBAAC,iBAAiB;EAAgB;EAChC;GAC0B;;;;;;AAQ9B,MAAaC,qBAAuD,EACnE,UACA,WACA,WACA,WACA,OACA,cAAc,MACd,WACA,cACA,cACK;AAGL,QACC,oBAAC;EACA,MAJW,wBAAwB;GAAE;GAAW;GAAW;GAAW,CAAC;EAK1D;EACF;EACG;EACL;EACF;YAEP,oBAAC;GAAyB;GAAU;IAA2B;GAC7C;;;;;;AAQrB,MAAa,qBAA4C;CACxD,MAAM,UAAU,WAAW,iBAAiB;AAC5C,KAAI,CAAC,QACJ,OAAM,IAAI,MAAM,qDAAqD;AAEtE,QAAO;;;;;;;AAQR,MAAa,yBACZ,WAAW,iBAAiB"}
1
+ {"version":3,"file":"websocket.js","names":["WebSocketBridge: React.FC<WebSocketBridgeProps>","intervalId: number | null","WebSocketProvider: React.FC<WebSocketProviderProps>"],"sources":["../../../src/support/context/websocket.tsx"],"sourcesContent":["\"use client\";\n\nimport { PRESENCE_PING_INTERVAL_MS } from \"@cossistant/types\";\nimport type React from \"react\";\nimport { createContext, useContext, useEffect, useMemo } from \"react\";\nimport {\n\ttype RealtimeAuthConfig,\n\ttype RealtimeContextValue,\n\tRealtimeProvider,\n\tuseRealtimeConnection,\n} from \"../../realtime\";\n\ntype WebSocketContextValue = RealtimeContextValue;\n\ntype WebSocketProviderProps = {\n\tchildren: React.ReactNode;\n\tpublicKey?: string;\n\twebsiteId?: string;\n\tvisitorId?: string;\n\twsUrl?: string;\n\tautoConnect?: boolean;\n\tonConnect?: () => void;\n\tonDisconnect?: () => void;\n\tonError?: (error: Error) => void;\n};\n\nconst WebSocketContext = createContext<WebSocketContextValue | null>(null);\n\nfunction createVisitorAuthConfig({\n\tvisitorId,\n\twebsiteId,\n\tpublicKey,\n}: Pick<\n\tWebSocketProviderProps,\n\t\"visitorId\" | \"websiteId\" | \"publicKey\"\n>): RealtimeAuthConfig | null {\n\tconst normalizedVisitorId = visitorId?.trim();\n\tif (!normalizedVisitorId) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tkind: \"visitor\",\n\t\tvisitorId: normalizedVisitorId,\n\t\twebsiteId: websiteId?.trim() || null,\n\t\tpublicKey: publicKey?.trim() || null,\n\t} satisfies RealtimeAuthConfig;\n}\n\ntype WebSocketBridgeProps = {\n\tchildren: React.ReactNode;\n\tonError?: (error: Error) => void;\n};\n\nconst WebSocketBridge: React.FC<WebSocketBridgeProps> = ({\n\tchildren,\n\tonError,\n}) => {\n\tconst connection = useRealtimeConnection();\n\tconst { visitorId, sendRaw, isConnected } = connection;\n\n\tuseEffect(() => {\n\t\tif (typeof window === \"undefined\" || typeof document === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!(visitorId && sendRaw)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst pingMessage = \"presence:ping\";\n\n\t\tconst sendPresencePing = () => {\n\t\t\tif (!isConnected) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tsendRaw(pingMessage);\n\t\t\t} catch (error) {\n\t\t\t\tif (!onError) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst normalizedError =\n\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t? error\n\t\t\t\t\t\t: new Error(\n\t\t\t\t\t\t\t\ttypeof error === \"string\"\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: \"Unknown presence ping error\"\n\t\t\t\t\t\t\t);\n\n\t\t\t\tif (!normalizedError.message.includes(\"Failed to send presence ping\")) {\n\t\t\t\t\tnormalizedError.message = `Failed to send presence ping: ${normalizedError.message}`;\n\t\t\t\t}\n\n\t\t\t\tonError(normalizedError);\n\t\t\t}\n\t\t};\n\n\t\tlet intervalId: number | null = null;\n\n\t\tconst clearPresenceInterval = () => {\n\t\t\tif (intervalId !== null) {\n\t\t\t\twindow.clearInterval(intervalId);\n\t\t\t\tintervalId = null;\n\t\t\t}\n\t\t};\n\n\t\tconst startPresenceInterval = () => {\n\t\t\tclearPresenceInterval();\n\n\t\t\tif (!isConnected || document.visibilityState === \"hidden\") {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tintervalId = window.setInterval(\n\t\t\t\tsendPresencePing,\n\t\t\t\tPRESENCE_PING_INTERVAL_MS\n\t\t\t);\n\t\t};\n\n\t\tconst handleFocus = () => {\n\t\t\tsendPresencePing();\n\t\t\tstartPresenceInterval();\n\t\t};\n\n\t\tconst handleVisibilityChange = () => {\n\t\t\tif (document.visibilityState === \"hidden\") {\n\t\t\t\tclearPresenceInterval();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsendPresencePing();\n\t\t\tstartPresenceInterval();\n\t\t};\n\n\t\twindow.addEventListener(\"focus\", handleFocus);\n\t\tdocument.addEventListener(\"visibilitychange\", handleVisibilityChange);\n\n\t\tif (isConnected && document.visibilityState !== \"hidden\") {\n\t\t\tsendPresencePing();\n\t\t\tstartPresenceInterval();\n\t\t}\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"focus\", handleFocus);\n\t\t\tdocument.removeEventListener(\"visibilitychange\", handleVisibilityChange);\n\t\t\tclearPresenceInterval();\n\t\t};\n\t}, [isConnected, onError, sendRaw, visitorId]);\n\tconst value = useMemo(() => connection, [connection]);\n\treturn (\n\t\t<WebSocketContext.Provider value={value}>\n\t\t\t{children}\n\t\t</WebSocketContext.Provider>\n\t);\n};\n\n/**\n * Support-specific realtime provider that authenticates visitors and keeps the\n * connection alive with presence pings.\n */\nexport const WebSocketProvider: React.FC<WebSocketProviderProps> = ({\n\tchildren,\n\tpublicKey,\n\twebsiteId,\n\tvisitorId,\n\twsUrl,\n\tautoConnect = true,\n\tonConnect,\n\tonDisconnect,\n\tonError,\n}) => {\n\tconst auth = createVisitorAuthConfig({ publicKey, websiteId, visitorId });\n\n\treturn (\n\t\t<RealtimeProvider\n\t\t\tauth={auth}\n\t\t\tautoConnect={autoConnect}\n\t\t\tonConnect={onConnect}\n\t\t\tonDisconnect={onDisconnect}\n\t\t\tonError={onError}\n\t\t\twsUrl={wsUrl}\n\t\t>\n\t\t\t<WebSocketBridge onError={onError}>{children}</WebSocketBridge>\n\t\t</RealtimeProvider>\n\t);\n};\n\n/**\n * Accessor for the support websocket context.\n * Throws if used outside WebSocketProvider.\n */\nexport const useWebSocket = (): WebSocketContextValue => {\n\tconst context = useContext(WebSocketContext);\n\tif (!context) {\n\t\tthrow new Error(\"useWebSocket must be used within WebSocketProvider\");\n\t}\n\treturn context;\n};\n\n/**\n * Safe accessor for the support websocket context.\n * Returns null if used outside WebSocketProvider instead of throwing.\n * Useful for optional WebSocket usage in hooks that may or may not have the provider.\n */\nexport const useWebSocketSafe = (): WebSocketContextValue | null =>\n\tuseContext(WebSocketContext);\n\nexport type { WebSocketContextValue, WebSocketProviderProps };\nexport type { RealtimeEvent } from \"@cossistant/types/realtime-events\";\n"],"mappings":";;;;;;;;AA0BA,MAAM,mBAAmB,cAA4C,KAAK;AAE1E,SAAS,wBAAwB,EAChC,WACA,WACA,aAI6B;CAC7B,MAAM,sBAAsB,WAAW,MAAM;AAC7C,KAAI,CAAC,oBACJ,QAAO;AAGR,QAAO;EACN,MAAM;EACN,WAAW;EACX,WAAW,WAAW,MAAM,IAAI;EAChC,WAAW,WAAW,MAAM,IAAI;EAChC;;AAQF,MAAMA,mBAAmD,EACxD,UACA,cACK;CACL,MAAM,aAAa,uBAAuB;CAC1C,MAAM,EAAE,WAAW,SAAS,gBAAgB;AAE5C,iBAAgB;AACf,MAAI,OAAO,WAAW,eAAe,OAAO,aAAa,YACxD;AAGD,MAAI,EAAE,aAAa,SAClB;EAGD,MAAM,cAAc;EAEpB,MAAM,yBAAyB;AAC9B,OAAI,CAAC,YACJ;AAGD,OAAI;AACH,YAAQ,YAAY;YACZ,OAAO;AACf,QAAI,CAAC,QACJ;IAGD,MAAM,kBACL,iBAAiB,QACd,QACA,IAAI,MACJ,OAAO,UAAU,WACd,QACA,8BACH;AAEJ,QAAI,CAAC,gBAAgB,QAAQ,SAAS,+BAA+B,CACpE,iBAAgB,UAAU,iCAAiC,gBAAgB;AAG5E,YAAQ,gBAAgB;;;EAI1B,IAAIC,aAA4B;EAEhC,MAAM,8BAA8B;AACnC,OAAI,eAAe,MAAM;AACxB,WAAO,cAAc,WAAW;AAChC,iBAAa;;;EAIf,MAAM,8BAA8B;AACnC,0BAAuB;AAEvB,OAAI,CAAC,eAAe,SAAS,oBAAoB,SAChD;AAGD,gBAAa,OAAO,YACnB,kBACA,0BACA;;EAGF,MAAM,oBAAoB;AACzB,qBAAkB;AAClB,0BAAuB;;EAGxB,MAAM,+BAA+B;AACpC,OAAI,SAAS,oBAAoB,UAAU;AAC1C,2BAAuB;AACvB;;AAGD,qBAAkB;AAClB,0BAAuB;;AAGxB,SAAO,iBAAiB,SAAS,YAAY;AAC7C,WAAS,iBAAiB,oBAAoB,uBAAuB;AAErE,MAAI,eAAe,SAAS,oBAAoB,UAAU;AACzD,qBAAkB;AAClB,0BAAuB;;AAGxB,eAAa;AACZ,UAAO,oBAAoB,SAAS,YAAY;AAChD,YAAS,oBAAoB,oBAAoB,uBAAuB;AACxE,0BAAuB;;IAEtB;EAAC;EAAa;EAAS;EAAS;EAAU,CAAC;CAC9C,MAAM,QAAQ,cAAc,YAAY,CAAC,WAAW,CAAC;AACrD,QACC,oBAAC,iBAAiB;EAAgB;EAChC;GAC0B;;;;;;AAQ9B,MAAaC,qBAAuD,EACnE,UACA,WACA,WACA,WACA,OACA,cAAc,MACd,WACA,cACA,cACK;AAGL,QACC,oBAAC;EACA,MAJW,wBAAwB;GAAE;GAAW;GAAW;GAAW,CAAC;EAK1D;EACF;EACG;EACL;EACF;YAEP,oBAAC;GAAyB;GAAU;IAA2B;GAC7C;;;;;;AAQrB,MAAa,qBAA4C;CACxD,MAAM,UAAU,WAAW,iBAAiB;AAC5C,KAAI,CAAC,QACJ,OAAM,IAAI,MAAM,qDAAqD;AAEtE,QAAO;;;;;;;AAQR,MAAa,yBACZ,WAAW,iBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/support/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;KAsCY,qCAAqC;;;;;;;;;SAUzC;EAVI;;;;EAmCQ,KAAA,CAAA,EAnBX,KAmBW;EA+CD;;;;EAeJ,UAAA,CAAA,EAAA,MAAA;EASgB;;;;;EA4BnB,eAAM,CAAA,EAAA,OAAA;EAAS;AA6M3B;;;EAAkC,gBAAA,CAAA,EAhTd,gBAgTc;EAQtB;;;EAAiE,UAAA,CAAA,EAAA;IAsCjE,OAAA,CAAA,EAAA,MAAA;IAMJ,OAAA,CAAA,EAAA,MAAA;EAKC,CAAA;EAgBW;;;EA4CR,KAAA,CAAA,EAAA,OAAA,GAAA,MAAkB;EAsClB;;;;;EAMwC,IAAA,CAAA,EAAA,OAAA;EADxC;;AAuBZ;;;;;;EA6CW,YAAM,CAAA,EAAA,CAAA,IAAA,EAAA,OAAA,EAAA,GAAA,IAAA;EAAS;AA2F1B;;;;EAtUiD,WAAA,CAAA,EAAA,OAAA;EAAV;;;;;;;oBA1PpB;;;;EAyQ2C,MAAM,CAAA,EApQ1D,MAoQ0D;;;;YA/PzD,4BAA4B;;;;gBAKxB;;;;gCASgB;;;;8BAKF;;;;0BAKJ;;;;8BAKI;;;;oBAKV;;;;;;;aAQP,OAAA,CAAM;;KA6MN,mBAAA,GAAsB,KACjC,OAAA,CAAM,qBAAqB;;;;;aAOhB,OAAA,CAAM,qBAAqB,uBAAuB,OAAA,CAAM;;;;;;;KAsCxD,mBAAA;;;;;;SAMJ;;;;;UAKC;;;;;;;;;;;;;;;;qBAgBW;aACR,OAAA,CAAM;;KA2CN,kBAAA;;;;gBAIG;;;;aAIH,OAAA,CAAM;;KA8BN,iCAAgB,iBAAA,CAEO,sBAAa,iBAAA,CAAoC;QAE7E;aACK,OAAA,CAAM;aADV,iBAAA,CAE8B,aAAA,CAAc;;;KAsBxC,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA4BmB;;;;8BAIF;;;;0BAIJ;;;;8BAII;;;;oBAIV;YACR,OAAA,CAAM;;cA2FJ,mCAxUS,sBAEd,aAAa;QAAkB,OAAA,CAAM,IAAI;MAC5C,OAAA,CAAM;;;;;;;eAcC,OAAA,CAAM,qBAAqB,uBAAuB,OAAA,CAAM"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/support/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;KAuCY,qCAAqC;;;;;;;;;SAUzC;EAVI;;;;EAmCQ,KAAA,CAAA,EAnBX,KAmBW;EA+CD;;;;EAeJ,UAAA,CAAA,EAAA,MAAA;EASgB;;;;;EA4BnB,eAAM,CAAA,EAAA,OAAA;EAAS;AAwO3B;;;EAAkC,gBAAA,CAAA,EA3Ud,gBA2Uc;EAQtB;;;EAAiE,UAAA,CAAA,EAAA;IAsCjE,OAAA,CAAA,EAAA,MAAA;IAMJ,OAAA,CAAA,EAAA,MAAA;EAKC,CAAA;EAgBW;;;EA4CR,KAAA,CAAA,EAAA,OAAA,GAAA,MAAkB;EAsClB;;;;;EAMwC,IAAA,CAAA,EAAA,OAAA;EADxC;;AAuBZ;;;;;;EA6CW,YAAM,CAAA,EAAA,CAAA,IAAA,EAAA,OAAA,EAAA,GAAA,IAAA;EAAS;AA+G1B;;;;EA1ViD,WAAA,CAAA,EAAA,OAAA;EAAV;;;;;;;oBArRpB;;;;EAoS2C,MAAM,CAAA,EA/R1D,MA+R0D;;;;YA1RzD,4BAA4B;;;;gBAKxB;;;;gCASgB;;;;8BAKF;;;;0BAKJ;;;;8BAKI;;;;oBAKV;;;;;;;aAQP,OAAA,CAAM;;KAwON,mBAAA,GAAsB,KACjC,OAAA,CAAM,qBAAqB;;;;;aAOhB,OAAA,CAAM,qBAAqB,uBAAuB,OAAA,CAAM;;;;;;;KAsCxD,mBAAA;;;;;;SAMJ;;;;;UAKC;;;;;;;;;;;;;;;;qBAgBW;aACR,OAAA,CAAM;;KA2CN,kBAAA;;;;gBAIG;;;;aAIH,OAAA,CAAM;;KA8BN,iCAAgB,iBAAA,CAEO,sBAAa,iBAAA,CAAoC;QAE7E;aACK,OAAA,CAAM;aADV,iBAAA,CAE8B,aAAA,CAAc;;;KAsBxC,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA4BmB;;;;8BAIF;;;;0BAIJ;;;;8BAII;;;;oBAIV;YACR,OAAA,CAAM;;cA+GJ,mCA5VS,sBAEd,aAAa;QAAkB,OAAA,CAAM,IAAI;MAC5C,OAAA,CAAM;;;;;;;eAcC,OAAA,CAAM,qBAAqB,uBAAuB,OAAA,CAAM"}
package/support/index.js CHANGED
@@ -4,6 +4,8 @@ import { SupportTrigger as SupportTrigger$1 } from "../primitives/trigger.js";
4
4
  import { ControlledStateProvider } from "./context/controlled-state.js";
5
5
  import { initializeSupportStore, useSupportConfig, useSupportNavigation, useSupportStore } from "./store/support-store.js";
6
6
  import { SupportRealtimeProvider } from "../realtime/support-provider.js";
7
+ import { CoButton } from "./components/button.js";
8
+ import { ConfigurationErrorDisplay } from "./components/configuration-error.js";
7
9
  import { FooterSlot, HeaderSlot } from "./context/slots.js";
8
10
  import { Content } from "./components/content.js";
9
11
  import { Root } from "./components/root.js";
@@ -11,7 +13,6 @@ import { ThemeWrapper } from "./components/theme-wrapper.js";
11
13
  import { DefaultTrigger } from "./components/trigger.js";
12
14
  import { SupportEventsProvider, useSupportEventEmitter, useSupportEvents } from "./context/events.js";
13
15
  import { SupportHandleProvider, useSupportHandle } from "./context/handle.js";
14
- import { CoButton } from "./components/button.js";
15
16
  import { Header } from "./components/header.js";
16
17
  import { SupportTextProvider, Text, useSupportText } from "./text/index.js";
17
18
  import { WebSocketProvider, useWebSocket } from "./context/websocket.js";
@@ -91,13 +92,41 @@ function parseChildren(children) {
91
92
  * </Support>
92
93
  */
93
94
  function SupportComponentInner({ className, side = "top", align = "end", sideOffset = 16, avoidCollisions = true, collisionPadding = 8, classNames = {}, theme, open, onOpenChange, defaultOpen, quickOptions, defaultMessages, locale, content, customPages, onConversationStart, onConversationEnd, onMessageSent, onMessageReceived, onError, children }, ref) {
94
- const { website } = useSupport();
95
+ const { website, configurationError } = useSupport();
95
96
  const isVisitorBlocked = website?.visitor?.isBlocked ?? false;
96
97
  React$1.useEffect(() => {
97
98
  if (open === void 0 && defaultOpen !== void 0) initializeSupportStore({ defaultOpen });
98
99
  }, [open, defaultOpen]);
99
- if (!website || isVisitorBlocked) return null;
100
+ if (website && isVisitorBlocked) return null;
100
101
  const parsed = parseChildren(children);
102
+ const triggerElement = parsed.trigger ?? /* @__PURE__ */ jsx(DefaultTrigger, { className: classNames.trigger });
103
+ const contentElement = parsed.content ?? /* @__PURE__ */ jsx(Content, {
104
+ align,
105
+ avoidCollisions,
106
+ className: classNames.content,
107
+ collisionPadding,
108
+ side,
109
+ sideOffset,
110
+ children: configurationError ? /* @__PURE__ */ jsx(ConfigurationErrorDisplay, { error: configurationError }) : website ? /* @__PURE__ */ jsx(Router, {
111
+ customPages,
112
+ children: parsed.pages
113
+ }) : null
114
+ });
115
+ if (configurationError) return /* @__PURE__ */ jsx(ControlledStateProvider, {
116
+ onOpenChange,
117
+ open,
118
+ children: /* @__PURE__ */ jsx(SupportHandleProvider, {
119
+ forwardedRef: ref,
120
+ children: /* @__PURE__ */ jsx(ThemeWrapper, {
121
+ theme,
122
+ children: /* @__PURE__ */ jsxs(Root, {
123
+ className,
124
+ children: [triggerElement, contentElement]
125
+ })
126
+ })
127
+ })
128
+ });
129
+ if (!website) return null;
101
130
  return /* @__PURE__ */ jsx(ControlledStateProvider, {
102
131
  onOpenChange,
103
132
  open,
@@ -116,18 +145,7 @@ function SupportComponentInner({ className, side = "top", align = "end", sideOff
116
145
  locale,
117
146
  children: /* @__PURE__ */ jsxs(Root, {
118
147
  className,
119
- children: [parsed.trigger ?? /* @__PURE__ */ jsx(DefaultTrigger, { className: classNames.trigger }), parsed.content ?? /* @__PURE__ */ jsx(Content, {
120
- align,
121
- avoidCollisions,
122
- className: classNames.content,
123
- collisionPadding,
124
- side,
125
- sideOffset,
126
- children: /* @__PURE__ */ jsx(Router, {
127
- customPages,
128
- children: parsed.pages
129
- })
130
- })]
148
+ children: [triggerElement, contentElement]
131
149
  })
132
150
  }) }), /* @__PURE__ */ jsx(SupportConfig, {
133
151
  defaultMessages,
@@ -150,7 +168,7 @@ const SupportComponent = React$1.forwardRef(SupportComponentInner);
150
168
  * )}
151
169
  * </Support.Trigger>
152
170
  */
153
- const SupportTrigger = React$1.forwardRef(({ children, className, asChild = false,...props }, ref) => /* @__PURE__ */ jsx(SupportTrigger$1, {
171
+ const SupportTrigger = React$1.forwardRef(({ children, className, asChild = false, ...props }, ref) => /* @__PURE__ */ jsx(SupportTrigger$1, {
154
172
  asChild,
155
173
  className,
156
174
  ref,
@@ -241,12 +259,27 @@ SupportPage.displayName = "Support.Page";
241
259
  * </Support.Root>
242
260
  */
243
261
  const SupportRoot = React$1.forwardRef(({ open, onOpenChange, defaultOpen, theme, className, onConversationStart, onConversationEnd, onMessageSent, onMessageReceived, onError, children }, ref) => {
244
- const { website } = useSupport();
262
+ const { website, configurationError } = useSupport();
245
263
  const isVisitorBlocked = website?.visitor?.isBlocked ?? false;
246
264
  React$1.useEffect(() => {
247
265
  if (open === void 0 && defaultOpen !== void 0) initializeSupportStore({ defaultOpen });
248
266
  }, [open, defaultOpen]);
249
- if (!website || isVisitorBlocked) return null;
267
+ if (website && isVisitorBlocked) return null;
268
+ if (configurationError) return /* @__PURE__ */ jsx(ControlledStateProvider, {
269
+ onOpenChange,
270
+ open,
271
+ children: /* @__PURE__ */ jsx(SupportHandleProvider, {
272
+ forwardedRef: ref,
273
+ children: /* @__PURE__ */ jsx(ThemeWrapper, {
274
+ theme,
275
+ children: /* @__PURE__ */ jsx(Root, {
276
+ className,
277
+ children
278
+ })
279
+ })
280
+ })
281
+ });
282
+ if (!website) return null;
250
283
  return /* @__PURE__ */ jsx(ControlledStateProvider, {
251
284
  onOpenChange,
252
285
  open,