@cossistant/react 0.0.1
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.
- package/_virtual/rolldown_runtime.js +13 -0
- package/conversation.d.ts +312 -0
- package/conversation.d.ts.map +1 -0
- package/hooks/index.d.ts +23 -0
- package/hooks/index.js +24 -0
- package/hooks/private/store/use-conversations-store.d.ts +13 -0
- package/hooks/private/store/use-conversations-store.d.ts.map +1 -0
- package/hooks/private/store/use-conversations-store.js +34 -0
- package/hooks/private/store/use-conversations-store.js.map +1 -0
- package/hooks/private/store/use-store-selector.d.ts +10 -0
- package/hooks/private/store/use-store-selector.d.ts.map +1 -0
- package/hooks/private/store/use-store-selector.js +17 -0
- package/hooks/private/store/use-store-selector.js.map +1 -0
- package/hooks/private/store/use-website-store.d.ts +18 -0
- package/hooks/private/store/use-website-store.d.ts.map +1 -0
- package/hooks/private/store/use-website-store.js +39 -0
- package/hooks/private/store/use-website-store.js.map +1 -0
- package/hooks/private/use-client-query.d.ts +25 -0
- package/hooks/private/use-client-query.d.ts.map +1 -0
- package/hooks/private/use-client-query.js +122 -0
- package/hooks/private/use-client-query.js.map +1 -0
- package/hooks/private/use-default-messages.d.ts +18 -0
- package/hooks/private/use-default-messages.d.ts.map +1 -0
- package/hooks/private/use-default-messages.js +45 -0
- package/hooks/private/use-default-messages.js.map +1 -0
- package/hooks/private/use-grouped-messages.d.ts +54 -0
- package/hooks/private/use-grouped-messages.d.ts.map +1 -0
- package/hooks/private/use-grouped-messages.js +157 -0
- package/hooks/private/use-grouped-messages.js.map +1 -0
- package/hooks/private/use-multimodal-input.d.ts +40 -0
- package/hooks/private/use-multimodal-input.d.ts.map +1 -0
- package/hooks/private/use-multimodal-input.js +129 -0
- package/hooks/private/use-multimodal-input.js.map +1 -0
- package/hooks/private/use-rest-client.d.ts +17 -0
- package/hooks/private/use-rest-client.d.ts.map +1 -0
- package/hooks/private/use-rest-client.js +41 -0
- package/hooks/private/use-rest-client.js.map +1 -0
- package/hooks/private/use-visitor-typing-reporter.d.ts +19 -0
- package/hooks/private/use-visitor-typing-reporter.d.ts.map +1 -0
- package/hooks/private/use-visitor-typing-reporter.js +140 -0
- package/hooks/private/use-visitor-typing-reporter.js.map +1 -0
- package/hooks/use-composer-refocus.d.ts +20 -0
- package/hooks/use-composer-refocus.d.ts.map +1 -0
- package/hooks/use-composer-refocus.js +32 -0
- package/hooks/use-composer-refocus.js.map +1 -0
- package/hooks/use-conversation-auto-seen.d.ts +54 -0
- package/hooks/use-conversation-auto-seen.d.ts.map +1 -0
- package/hooks/use-conversation-auto-seen.js +106 -0
- package/hooks/use-conversation-auto-seen.js.map +1 -0
- package/hooks/use-conversation-history-page.d.ts +86 -0
- package/hooks/use-conversation-history-page.d.ts.map +1 -0
- package/hooks/use-conversation-history-page.js +97 -0
- package/hooks/use-conversation-history-page.js.map +1 -0
- package/hooks/use-conversation-lifecycle.d.ts +80 -0
- package/hooks/use-conversation-lifecycle.d.ts.map +1 -0
- package/hooks/use-conversation-lifecycle.js +54 -0
- package/hooks/use-conversation-lifecycle.js.map +1 -0
- package/hooks/use-conversation-page.d.ts +82 -0
- package/hooks/use-conversation-page.d.ts.map +1 -0
- package/hooks/use-conversation-page.js +138 -0
- package/hooks/use-conversation-page.js.map +1 -0
- package/hooks/use-conversation-seen.d.ts +17 -0
- package/hooks/use-conversation-seen.d.ts.map +1 -0
- package/hooks/use-conversation-seen.js +58 -0
- package/hooks/use-conversation-seen.js.map +1 -0
- package/hooks/use-conversation-timeline-items.d.ts +21 -0
- package/hooks/use-conversation-timeline-items.d.ts.map +1 -0
- package/hooks/use-conversation-timeline-items.js +87 -0
- package/hooks/use-conversation-timeline-items.js.map +1 -0
- package/hooks/use-conversation-typing.d.ts +13 -0
- package/hooks/use-conversation-typing.d.ts.map +1 -0
- package/hooks/use-conversation-typing.js +34 -0
- package/hooks/use-conversation-typing.js.map +1 -0
- package/hooks/use-conversation.d.ts +18 -0
- package/hooks/use-conversation.d.ts.map +1 -0
- package/hooks/use-conversation.js +44 -0
- package/hooks/use-conversation.js.map +1 -0
- package/hooks/use-conversations.d.ts +20 -0
- package/hooks/use-conversations.d.ts.map +1 -0
- package/hooks/use-conversations.js +68 -0
- package/hooks/use-conversations.js.map +1 -0
- package/hooks/use-create-conversation.d.ts +30 -0
- package/hooks/use-create-conversation.d.ts.map +1 -0
- package/hooks/use-create-conversation.js +67 -0
- package/hooks/use-create-conversation.js.map +1 -0
- package/hooks/use-home-page.d.ts +82 -0
- package/hooks/use-home-page.d.ts.map +1 -0
- package/hooks/use-home-page.js +89 -0
- package/hooks/use-home-page.js.map +1 -0
- package/hooks/use-message-composer.d.ts +88 -0
- package/hooks/use-message-composer.d.ts.map +1 -0
- package/hooks/use-message-composer.js +94 -0
- package/hooks/use-message-composer.js.map +1 -0
- package/hooks/use-realtime-support.d.ts +25 -0
- package/hooks/use-realtime-support.d.ts.map +1 -0
- package/hooks/use-realtime-support.js +29 -0
- package/hooks/use-realtime-support.js.map +1 -0
- package/hooks/use-send-message.d.ts +34 -0
- package/hooks/use-send-message.d.ts.map +1 -0
- package/hooks/use-send-message.js +118 -0
- package/hooks/use-send-message.js.map +1 -0
- package/hooks/use-visitor.d.ts +28 -0
- package/hooks/use-visitor.d.ts.map +1 -0
- package/hooks/use-visitor.js +59 -0
- package/hooks/use-visitor.js.map +1 -0
- package/hooks/use-window-visibility-focus.d.ts +9 -0
- package/hooks/use-window-visibility-focus.d.ts.map +1 -0
- package/hooks/use-window-visibility-focus.js +53 -0
- package/hooks/use-window-visibility-focus.js.map +1 -0
- package/identify-visitor.d.ts +18 -0
- package/identify-visitor.d.ts.map +1 -0
- package/identify-visitor.js +26 -0
- package/identify-visitor.js.map +1 -0
- package/index.d.ts +38 -0
- package/index.js +38 -0
- package/package.json +121 -0
- package/primitives/avatar/avatar.d.ts +31 -0
- package/primitives/avatar/avatar.d.ts.map +1 -0
- package/primitives/avatar/avatar.js +49 -0
- package/primitives/avatar/avatar.js.map +1 -0
- package/primitives/avatar/fallback.d.ts +24 -0
- package/primitives/avatar/fallback.d.ts.map +1 -0
- package/primitives/avatar/fallback.js +57 -0
- package/primitives/avatar/fallback.js.map +1 -0
- package/primitives/avatar/image.d.ts +27 -0
- package/primitives/avatar/image.d.ts.map +1 -0
- package/primitives/avatar/image.js +58 -0
- package/primitives/avatar/image.js.map +1 -0
- package/primitives/avatar/index.d.ts +4 -0
- package/primitives/avatar/index.js +5 -0
- package/primitives/avatar/index.parts.d.ts +4 -0
- package/primitives/avatar/index.parts.js +5 -0
- package/primitives/bubble.d.ts +28 -0
- package/primitives/bubble.d.ts.map +1 -0
- package/primitives/bubble.js +43 -0
- package/primitives/bubble.js.map +1 -0
- package/primitives/button.d.ts +19 -0
- package/primitives/button.d.ts.map +1 -0
- package/primitives/button.js +27 -0
- package/primitives/button.js.map +1 -0
- package/primitives/conversation-timeline.d.ts +86 -0
- package/primitives/conversation-timeline.d.ts.map +1 -0
- package/primitives/conversation-timeline.js +119 -0
- package/primitives/conversation-timeline.js.map +1 -0
- package/primitives/index.d.ts +20 -0
- package/primitives/index.d.ts.map +1 -0
- package/primitives/index.js +45 -0
- package/primitives/index.js.map +1 -0
- package/primitives/index.parts.d.ts +13 -0
- package/primitives/index.parts.js +14 -0
- package/primitives/multimodal-input.d.ts +53 -0
- package/primitives/multimodal-input.d.ts.map +1 -0
- package/primitives/multimodal-input.js +106 -0
- package/primitives/multimodal-input.js.map +1 -0
- package/primitives/timeline-item-group.d.ts +166 -0
- package/primitives/timeline-item-group.d.ts.map +1 -0
- package/primitives/timeline-item-group.js +204 -0
- package/primitives/timeline-item-group.js.map +1 -0
- package/primitives/timeline-item.d.ts +75 -0
- package/primitives/timeline-item.d.ts.map +1 -0
- package/primitives/timeline-item.js +145 -0
- package/primitives/timeline-item.js.map +1 -0
- package/primitives/window.d.ts +31 -0
- package/primitives/window.d.ts.map +1 -0
- package/primitives/window.js +58 -0
- package/primitives/window.js.map +1 -0
- package/provider.d.ts +95 -0
- package/provider.d.ts.map +1 -0
- package/provider.js +124 -0
- package/provider.js.map +1 -0
- package/realtime/event-filter.d.ts +8 -0
- package/realtime/event-filter.d.ts.map +1 -0
- package/realtime/event-filter.js +21 -0
- package/realtime/event-filter.js.map +1 -0
- package/realtime/index.d.ts +6 -0
- package/realtime/index.js +7 -0
- package/realtime/provider.d.ts +57 -0
- package/realtime/provider.d.ts.map +1 -0
- package/realtime/provider.js +351 -0
- package/realtime/provider.js.map +1 -0
- package/realtime/seen-store.d.ts +23 -0
- package/realtime/seen-store.d.ts.map +1 -0
- package/realtime/seen-store.js +34 -0
- package/realtime/seen-store.js.map +1 -0
- package/realtime/support-provider.d.ts +17 -0
- package/realtime/support-provider.d.ts.map +1 -0
- package/realtime/support-provider.js +54 -0
- package/realtime/support-provider.js.map +1 -0
- package/realtime/typing-store.d.ts +30 -0
- package/realtime/typing-store.d.ts.map +1 -0
- package/realtime/typing-store.js +34 -0
- package/realtime/typing-store.js.map +1 -0
- package/realtime/use-realtime.d.ts +29 -0
- package/realtime/use-realtime.d.ts.map +1 -0
- package/realtime/use-realtime.js +47 -0
- package/realtime/use-realtime.js.map +1 -0
- package/realtime-events.d.ts +344 -0
- package/realtime-events.d.ts.map +1 -0
- package/schemas.d.ts +90 -0
- package/schemas.d.ts.map +1 -0
- package/support/components/avatar-stack.d.ts +45 -0
- package/support/components/avatar-stack.d.ts.map +1 -0
- package/support/components/avatar-stack.js +72 -0
- package/support/components/avatar-stack.js.map +1 -0
- package/support/components/avatar.d.ts +15 -0
- package/support/components/avatar.d.ts.map +1 -0
- package/support/components/avatar.js +23 -0
- package/support/components/avatar.js.map +1 -0
- package/support/components/bubble.d.ts +10 -0
- package/support/components/bubble.d.ts.map +1 -0
- package/support/components/bubble.js +95 -0
- package/support/components/bubble.js.map +1 -0
- package/support/components/button.d.ts +20 -0
- package/support/components/button.d.ts.map +1 -0
- package/support/components/button.js +41 -0
- package/support/components/button.js.map +1 -0
- package/support/components/container.d.ts +14 -0
- package/support/components/container.d.ts.map +1 -0
- package/support/components/container.js +115 -0
- package/support/components/container.js.map +1 -0
- package/support/components/conversation-button-link.d.ts +34 -0
- package/support/components/conversation-button-link.d.ts.map +1 -0
- package/support/components/conversation-button-link.js +195 -0
- package/support/components/conversation-button-link.js.map +1 -0
- package/support/components/conversation-event.d.ts +14 -0
- package/support/components/conversation-event.d.ts.map +1 -0
- package/support/components/conversation-event.js +76 -0
- package/support/components/conversation-event.js.map +1 -0
- package/support/components/conversation-timeline.d.ts +17 -0
- package/support/components/conversation-timeline.d.ts.map +1 -0
- package/support/components/conversation-timeline.js +95 -0
- package/support/components/conversation-timeline.js.map +1 -0
- package/support/components/cossistant-branding.d.ts +12 -0
- package/support/components/cossistant-branding.d.ts.map +1 -0
- package/support/components/cossistant-branding.js +22 -0
- package/support/components/cossistant-branding.js.map +1 -0
- package/support/components/header.d.ts +11 -0
- package/support/components/header.d.ts.map +1 -0
- package/support/components/header.js +43 -0
- package/support/components/header.js.map +1 -0
- package/support/components/icons.d.ts +21 -0
- package/support/components/icons.d.ts.map +1 -0
- package/support/components/icons.js +131 -0
- package/support/components/icons.js.map +1 -0
- package/support/components/index.d.ts +11 -0
- package/support/components/index.js +12 -0
- package/support/components/multimodal-input.d.ts +28 -0
- package/support/components/multimodal-input.d.ts.map +1 -0
- package/support/components/multimodal-input.js +138 -0
- package/support/components/multimodal-input.js.map +1 -0
- package/support/components/navigation-tab.d.ts +7 -0
- package/support/components/navigation-tab.d.ts.map +1 -0
- package/support/components/navigation-tab.js +40 -0
- package/support/components/navigation-tab.js.map +1 -0
- package/support/components/support-content.d.ts +22 -0
- package/support/components/support-content.d.ts.map +1 -0
- package/support/components/support-content.js +50 -0
- package/support/components/support-content.js.map +1 -0
- package/support/components/text-effect.d.ts +49 -0
- package/support/components/text-effect.d.ts.map +1 -0
- package/support/components/text-effect.js +221 -0
- package/support/components/text-effect.js.map +1 -0
- package/support/components/timeline-message-group.d.ts +16 -0
- package/support/components/timeline-message-group.d.ts.map +1 -0
- package/support/components/timeline-message-group.js +117 -0
- package/support/components/timeline-message-group.js.map +1 -0
- package/support/components/timeline-message-item.d.ts +17 -0
- package/support/components/timeline-message-item.d.ts.map +1 -0
- package/support/components/timeline-message-item.js +42 -0
- package/support/components/timeline-message-item.js.map +1 -0
- package/support/components/typing-indicator.d.ts +26 -0
- package/support/components/typing-indicator.d.ts.map +1 -0
- package/support/components/typing-indicator.js +37 -0
- package/support/components/typing-indicator.js.map +1 -0
- package/support/components/watermark.d.ts +8 -0
- package/support/components/watermark.d.ts.map +1 -0
- package/support/components/watermark.js +34 -0
- package/support/components/watermark.js.map +1 -0
- package/support/context/config.d.ts +32 -0
- package/support/context/config.d.ts.map +1 -0
- package/support/context/config.js +27 -0
- package/support/context/config.js.map +1 -0
- package/support/context/websocket.d.ts +22 -0
- package/support/context/websocket.d.ts.map +1 -0
- package/support/context/websocket.js +113 -0
- package/support/context/websocket.js.map +1 -0
- package/support/index.d.ts +39 -0
- package/support/index.d.ts.map +1 -0
- package/support/index.js +43 -0
- package/support/index.js.map +1 -0
- package/support/pages/articles.d.ts +7 -0
- package/support/pages/articles.d.ts.map +1 -0
- package/support/pages/articles.js +39 -0
- package/support/pages/articles.js.map +1 -0
- package/support/pages/conversation-history.d.ts +18 -0
- package/support/pages/conversation-history.d.ts.map +1 -0
- package/support/pages/conversation-history.js +120 -0
- package/support/pages/conversation-history.js.map +1 -0
- package/support/pages/conversation.d.ts +32 -0
- package/support/pages/conversation.d.ts.map +1 -0
- package/support/pages/conversation.js +92 -0
- package/support/pages/conversation.js.map +1 -0
- package/support/pages/home.d.ts +20 -0
- package/support/pages/home.d.ts.map +1 -0
- package/support/pages/home.js +184 -0
- package/support/pages/home.js.map +1 -0
- package/support/router.d.ts +14 -0
- package/support/router.d.ts.map +1 -0
- package/support/router.js +31 -0
- package/support/router.js.map +1 -0
- package/support/store/index.d.ts +2 -0
- package/support/store/index.js +3 -0
- package/support/store/support-store.d.ts +42 -0
- package/support/store/support-store.d.ts.map +1 -0
- package/support/store/support-store.js +66 -0
- package/support/store/support-store.js.map +1 -0
- package/support/support-CMoDLQoC.css +408 -0
- package/support/support-CMoDLQoC.css.map +1 -0
- package/support/support.js +1 -0
- package/support/text/index.d.ts +35 -0
- package/support/text/index.d.ts.map +1 -0
- package/support/text/index.js +71 -0
- package/support/text/index.js.map +1 -0
- package/support/text/locales/en.d.ts +7 -0
- package/support/text/locales/en.d.ts.map +1 -0
- package/support/text/locales/en.js +65 -0
- package/support/text/locales/en.js.map +1 -0
- package/support/text/locales/es.d.ts +7 -0
- package/support/text/locales/es.d.ts.map +1 -0
- package/support/text/locales/es.js +64 -0
- package/support/text/locales/es.js.map +1 -0
- package/support/text/locales/fr.d.ts +7 -0
- package/support/text/locales/fr.d.ts.map +1 -0
- package/support/text/locales/fr.js +64 -0
- package/support/text/locales/fr.js.map +1 -0
- package/support/text/locales/keys.d.ts +216 -0
- package/support/text/locales/keys.d.ts.map +1 -0
- package/support/text/locales/keys.js +54 -0
- package/support/text/locales/keys.js.map +1 -0
- package/support/text/runtime.d.ts +17 -0
- package/support/text/runtime.d.ts.map +1 -0
- package/support/text/runtime.js +156 -0
- package/support/text/runtime.js.map +1 -0
- package/support/utils/index.d.ts +7 -0
- package/support/utils/index.d.ts.map +1 -0
- package/support/utils/index.js +11 -0
- package/support/utils/index.js.map +1 -0
- package/support/utils/time.d.ts +5 -0
- package/support/utils/time.d.ts.map +1 -0
- package/support/utils/time.js +28 -0
- package/support/utils/time.js.map +1 -0
- package/support-config.d.ts +20 -0
- package/support-config.d.ts.map +1 -0
- package/support-config.js +25 -0
- package/support-config.js.map +1 -0
- package/support.css +2 -0
- package/timeline-item.d.ts +133 -0
- package/timeline-item.d.ts.map +1 -0
- package/utils/id.d.ts +6 -0
- package/utils/id.d.ts.map +1 -0
- package/utils/id.js +13 -0
- package/utils/id.js.map +1 -0
- package/utils/index.d.ts +3 -0
- package/utils/index.js +4 -0
- package/utils/text.d.ts +5 -0
- package/utils/text.d.ts.map +1 -0
- package/utils/text.js +9 -0
- package/utils/text.js.map +1 -0
- package/utils/use-render-element.d.ts +22 -0
- package/utils/use-render-element.d.ts.map +1 -0
- package/utils/use-render-element.js +35 -0
- package/utils/use-render-element.js.map +1 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { initializeSupportStore, useSupportConfig as useSupportConfig$1 } from "../store/support-store.js";
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/support/context/config.tsx
|
|
9
|
+
const useSupportConfig = useSupportConfig$1;
|
|
10
|
+
const SupportConfigProvider = ({ children, mode = "floating", size = "normal", defaultOpen = false }) => {
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
initializeSupportStore({
|
|
13
|
+
mode,
|
|
14
|
+
size,
|
|
15
|
+
defaultOpen
|
|
16
|
+
});
|
|
17
|
+
}, [
|
|
18
|
+
mode,
|
|
19
|
+
size,
|
|
20
|
+
defaultOpen
|
|
21
|
+
]);
|
|
22
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { SupportConfigProvider, useSupportConfig };
|
|
27
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","names":["useSupportConfigStore","SupportConfigProvider: React.FC<{\n\tchildren: React.ReactNode;\n\tmode?: \"floating\" | \"responsive\";\n\tsize?: \"normal\" | \"larger\";\n\tdefaultOpen?: boolean;\n}>"],"sources":["../../../src/support/context/config.tsx"],"sourcesContent":["\"use client\";\n\nimport type React from \"react\";\nimport { useEffect } from \"react\";\nimport {\n\tinitializeSupportStore,\n\tuseSupportConfig as useSupportConfigStore,\n} from \"../store/support-store\";\n\nexport type SupportConfigSetters = {\n\topen: () => void;\n\tclose: () => void;\n\ttoggle: () => void;\n};\n\nexport const useSupportConfig = useSupportConfigStore;\n\nexport const SupportConfigProvider: React.FC<{\n\tchildren: React.ReactNode;\n\tmode?: \"floating\" | \"responsive\";\n\tsize?: \"normal\" | \"larger\";\n\tdefaultOpen?: boolean;\n}> = ({\n\tchildren,\n\tmode = \"floating\",\n\tsize = \"normal\",\n\tdefaultOpen = false,\n}) => {\n\tuseEffect(() => {\n\t\tinitializeSupportStore({ mode, size, defaultOpen });\n\t}, [mode, size, defaultOpen]);\n\n\treturn <>{children}</>;\n};\n"],"mappings":";;;;;;;;AAeA,MAAa,mBAAmBA;AAEhC,MAAaC,yBAKP,EACL,UACA,OAAO,YACP,OAAO,UACP,cAAc,YACT;AACL,iBAAgB;AACf,yBAAuB;GAAE;GAAM;GAAM;GAAa,CAAC;IACjD;EAAC;EAAM;EAAM;EAAY,CAAC;AAE7B,QAAO,gCAAG,WAAY"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RealtimeEvent } from "../../realtime-events.js";
|
|
2
|
+
import { RealtimeContextValue } from "../../realtime/provider.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/support/context/websocket.d.ts
|
|
6
|
+
type WebSocketContextValue = RealtimeContextValue;
|
|
7
|
+
type WebSocketProviderProps = {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
publicKey?: string;
|
|
10
|
+
websiteId?: string;
|
|
11
|
+
visitorId?: string;
|
|
12
|
+
wsUrl?: string;
|
|
13
|
+
autoConnect?: boolean;
|
|
14
|
+
onConnect?: () => void;
|
|
15
|
+
onDisconnect?: () => void;
|
|
16
|
+
onError?: (error: Error) => void;
|
|
17
|
+
};
|
|
18
|
+
declare const WebSocketProvider: React.FC<WebSocketProviderProps>;
|
|
19
|
+
declare const useWebSocket: () => WebSocketContextValue;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { type RealtimeEvent, type WebSocketContextValue, WebSocketProvider, type WebSocketProviderProps, useWebSocket };
|
|
22
|
+
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.d.ts","names":[],"sources":["../../../src/support/context/websocket.tsx"],"sourcesContent":[],"mappings":";;;;;KAYK,qBAAA,GAAwB;KAExB,sBAAA;YACM,KAAA,CAAM;EAHZ,SAAA,CAAA,EAAA,MAAA;EAEA,SAAA,CAAA,EAAA,MAAA;EAAsB,SAAA,CAAA,EAAA,MAAA;OAChB,CAAA,EAAA,MAAM;aAQE,CAAA,EAAA,OAAA;EAAK,SAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EAyIX,YAAA,CAAA,EAAA,GAAA,GAyBZ,IAAA;EAAA,OAAA,CAAA,EAAA,CAAA,KAAA,EAlKkB,KAkKlB,EAAA,GAAA,IAAA;;AAzB+B,cAAnB,iBAAyB,EAAN,KAAA,CAAM,EAAA,CAAG,sBAAH,CAAA;AAAE,cA2B3B,YA3B2B,EAAA,GAAA,GA2BR,qBA3BQ"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { RealtimeProvider, useRealtimeConnection } from "../../realtime/provider.js";
|
|
5
|
+
import { createContext, useContext, useEffect, useMemo } from "react";
|
|
6
|
+
import { PRESENCE_PING_INTERVAL_MS } from "@cossistant/types";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/support/context/websocket.tsx
|
|
10
|
+
const WebSocketContext = createContext(null);
|
|
11
|
+
function createVisitorAuthConfig({ visitorId, websiteId, publicKey }) {
|
|
12
|
+
const normalizedVisitorId = visitorId?.trim();
|
|
13
|
+
if (!normalizedVisitorId) return null;
|
|
14
|
+
return {
|
|
15
|
+
kind: "visitor",
|
|
16
|
+
visitorId: normalizedVisitorId,
|
|
17
|
+
websiteId: websiteId?.trim() || null,
|
|
18
|
+
publicKey: publicKey?.trim() || null
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const WebSocketBridge = ({ children, onError }) => {
|
|
22
|
+
const connection = useRealtimeConnection();
|
|
23
|
+
const { visitorId, sendRaw, isConnected } = connection;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
26
|
+
if (!(visitorId && sendRaw)) return;
|
|
27
|
+
const pingMessage = "presence:ping";
|
|
28
|
+
const sendPresencePing = () => {
|
|
29
|
+
if (!isConnected) return;
|
|
30
|
+
try {
|
|
31
|
+
sendRaw(pingMessage);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (!onError) return;
|
|
34
|
+
const normalizedError = error instanceof Error ? error : new Error(typeof error === "string" ? error : "Unknown presence ping error");
|
|
35
|
+
if (!normalizedError.message.includes("Failed to send presence ping")) normalizedError.message = `Failed to send presence ping: ${normalizedError.message}`;
|
|
36
|
+
onError(normalizedError);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
let intervalId = null;
|
|
40
|
+
const clearPresenceInterval = () => {
|
|
41
|
+
if (intervalId !== null) {
|
|
42
|
+
window.clearInterval(intervalId);
|
|
43
|
+
intervalId = null;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const startPresenceInterval = () => {
|
|
47
|
+
clearPresenceInterval();
|
|
48
|
+
if (!isConnected || document.visibilityState === "hidden") return;
|
|
49
|
+
intervalId = window.setInterval(sendPresencePing, PRESENCE_PING_INTERVAL_MS);
|
|
50
|
+
};
|
|
51
|
+
const handleFocus = () => {
|
|
52
|
+
sendPresencePing();
|
|
53
|
+
startPresenceInterval();
|
|
54
|
+
};
|
|
55
|
+
const handleVisibilityChange = () => {
|
|
56
|
+
if (document.visibilityState === "hidden") {
|
|
57
|
+
clearPresenceInterval();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
sendPresencePing();
|
|
61
|
+
startPresenceInterval();
|
|
62
|
+
};
|
|
63
|
+
window.addEventListener("focus", handleFocus);
|
|
64
|
+
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
65
|
+
if (isConnected && document.visibilityState !== "hidden") {
|
|
66
|
+
sendPresencePing();
|
|
67
|
+
startPresenceInterval();
|
|
68
|
+
}
|
|
69
|
+
return () => {
|
|
70
|
+
window.removeEventListener("focus", handleFocus);
|
|
71
|
+
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
72
|
+
clearPresenceInterval();
|
|
73
|
+
};
|
|
74
|
+
}, [
|
|
75
|
+
isConnected,
|
|
76
|
+
onError,
|
|
77
|
+
sendRaw,
|
|
78
|
+
visitorId
|
|
79
|
+
]);
|
|
80
|
+
const value = useMemo(() => connection, [connection]);
|
|
81
|
+
return /* @__PURE__ */ jsx(WebSocketContext.Provider, {
|
|
82
|
+
value,
|
|
83
|
+
children
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const WebSocketProvider = ({ children, publicKey, websiteId, visitorId, wsUrl, autoConnect = true, onConnect, onDisconnect, onError }) => {
|
|
87
|
+
const auth = createVisitorAuthConfig({
|
|
88
|
+
publicKey,
|
|
89
|
+
websiteId,
|
|
90
|
+
visitorId
|
|
91
|
+
});
|
|
92
|
+
return /* @__PURE__ */ jsx(RealtimeProvider, {
|
|
93
|
+
auth,
|
|
94
|
+
autoConnect,
|
|
95
|
+
onConnect,
|
|
96
|
+
onDisconnect,
|
|
97
|
+
onError,
|
|
98
|
+
wsUrl,
|
|
99
|
+
children: /* @__PURE__ */ jsx(WebSocketBridge, {
|
|
100
|
+
onError,
|
|
101
|
+
children
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const useWebSocket = () => {
|
|
106
|
+
const context = useContext(WebSocketContext);
|
|
107
|
+
if (!context) throw new Error("useWebSocket must be used within WebSocketProvider");
|
|
108
|
+
return context;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
export { WebSocketProvider, useWebSocket };
|
|
113
|
+
//# sourceMappingURL=websocket.js.map
|
|
@@ -0,0 +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\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\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\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;;AAI9B,MAAaC,qBAAuD,EACnE,UACA,WACA,WACA,WACA,OACA,cAAc,MACd,WACA,cACA,cACK;CACL,MAAM,OAAO,wBAAwB;EAAE;EAAW;EAAW;EAAW,CAAC;AAEzE,QACC,oBAAC;EACM;EACO;EACF;EACG;EACL;EACF;YAEP,oBAAC;GAAyB;GAAU;IAA2B;GAC7C;;AAIrB,MAAa,qBAA4C;CACxD,MAAM,UAAU,WAAW,iBAAiB;AAC5C,KAAI,CAAC,QACJ,OAAM,IAAI,MAAM,qDAAqD;AAEtE,QAAO"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SupportLocale, SupportTextContentOverrides } from "./text/locales/keys.js";
|
|
2
|
+
import { Text, useSupportText } from "./text/index.js";
|
|
3
|
+
import { useSupportConfig } from "./context/config.js";
|
|
4
|
+
import { WebSocketContextValue, WebSocketProvider, useWebSocket } from "./context/websocket.js";
|
|
5
|
+
import { useSupportStore } from "./store/support-store.js";
|
|
6
|
+
import { DefaultMessage } from "@cossistant/types";
|
|
7
|
+
import * as react_jsx_runtime12 from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/support/index.d.ts
|
|
10
|
+
type SupportProps<Locale extends string = SupportLocale> = {
|
|
11
|
+
className?: string;
|
|
12
|
+
position?: "top" | "bottom";
|
|
13
|
+
align?: "right" | "left";
|
|
14
|
+
mode?: "floating" | "responsive";
|
|
15
|
+
quickOptions?: string[];
|
|
16
|
+
defaultMessages?: DefaultMessage[];
|
|
17
|
+
defaultOpen?: boolean;
|
|
18
|
+
locale?: Locale;
|
|
19
|
+
content?: SupportTextContentOverrides<Locale>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Orchestrates the end-user support experience by nesting realtime, config and
|
|
23
|
+
* content providers. Renders nothing until website data is available to avoid
|
|
24
|
+
* flashing incomplete UI.
|
|
25
|
+
*/
|
|
26
|
+
declare function Support<Locale extends string = SupportLocale>({
|
|
27
|
+
className,
|
|
28
|
+
position,
|
|
29
|
+
align,
|
|
30
|
+
mode,
|
|
31
|
+
quickOptions,
|
|
32
|
+
defaultMessages,
|
|
33
|
+
defaultOpen,
|
|
34
|
+
locale,
|
|
35
|
+
content
|
|
36
|
+
}: SupportProps<Locale>): react_jsx_runtime12.JSX.Element | null;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Support, Support as default, type SupportLocale, SupportProps, type SupportTextContentOverrides, Text, type WebSocketContextValue, WebSocketProvider, useSupportConfig, useSupportStore, useSupportText, useWebSocket };
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/support/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;KAWY,qCAAqC;;;;;;EAArC,eAAY,CAAA,EAOL,cAPK,EAAA;EAAA,WAAA,CAAA,EAAA,OAAA;QAAyB,CAAA,EASvC,MATuC;SAO9B,CAAA,EAGR,2BAHQ,CAGoB,MAHpB,CAAA;;;;;AAYnB;;AAAgD,iBAAhC,OAAgC,CAAA,eAAA,MAAA,GAAA,aAAA,CAAA,CAAA;EAAA,SAAA;EAAA,QAAA;EAAA,KAAA;EAAA,IAAA;EAAA,YAAA;EAAA,eAAA;EAAA,WAAA;EAAA,MAAA;EAAA;AAAA,CAAA,EAU7C,YAV6C,CAUhC,MAVgC,CAAA,CAAA,EAUzB,mBAAA,CAAA,GAAA,CAAA,OAAA,GAVyB,IAAA"}
|
package/support/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import "./support.js";
|
|
2
|
+
import { SupportRealtimeProvider } from "../realtime/support-provider.js";
|
|
3
|
+
import { SupportConfig } from "../support-config.js";
|
|
4
|
+
import { useSupportStore } from "./store/support-store.js";
|
|
5
|
+
import { SupportConfigProvider, useSupportConfig } from "./context/config.js";
|
|
6
|
+
import { SupportTextProvider, Text, useSupportText } from "./text/index.js";
|
|
7
|
+
import { SupportContent } from "./components/support-content.js";
|
|
8
|
+
import { WebSocketProvider, useWebSocket } from "./context/websocket.js";
|
|
9
|
+
import { useSupport } from "../provider.js";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
|
|
12
|
+
//#region src/support/index.tsx
|
|
13
|
+
/**
|
|
14
|
+
* Orchestrates the end-user support experience by nesting realtime, config and
|
|
15
|
+
* content providers. Renders nothing until website data is available to avoid
|
|
16
|
+
* flashing incomplete UI.
|
|
17
|
+
*/
|
|
18
|
+
function Support({ className, position = "bottom", align = "right", mode = "floating", quickOptions, defaultMessages, defaultOpen, locale, content }) {
|
|
19
|
+
const { website } = useSupport();
|
|
20
|
+
if (!website) return null;
|
|
21
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SupportRealtimeProvider, { children: /* @__PURE__ */ jsx(SupportConfigProvider, {
|
|
22
|
+
defaultOpen,
|
|
23
|
+
mode,
|
|
24
|
+
children: /* @__PURE__ */ jsx(SupportTextProvider, {
|
|
25
|
+
content,
|
|
26
|
+
locale,
|
|
27
|
+
children: /* @__PURE__ */ jsx(SupportContent, {
|
|
28
|
+
align,
|
|
29
|
+
className,
|
|
30
|
+
mode,
|
|
31
|
+
position
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
}) }), /* @__PURE__ */ jsx(SupportConfig, {
|
|
35
|
+
defaultMessages,
|
|
36
|
+
quickOptions
|
|
37
|
+
})] });
|
|
38
|
+
}
|
|
39
|
+
var support_default = Support;
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Support, Text, WebSocketProvider, support_default as default, useSupportConfig, useSupportStore, useSupportText, useWebSocket };
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/support/index.tsx"],"sourcesContent":["import \"./support.css\";\n\nimport type { DefaultMessage } from \"@cossistant/types\";\nimport { useSupport } from \"../provider\";\nimport { SupportRealtimeProvider } from \"../realtime\";\nimport { SupportConfig } from \"../support-config\";\nimport { SupportContent } from \"./components/support-content\";\nimport { SupportConfigProvider } from \"./context/config\";\nimport type { SupportLocale, SupportTextContentOverrides } from \"./text\";\nimport { SupportTextProvider } from \"./text\";\n\nexport type SupportProps<Locale extends string = SupportLocale> = {\n\tclassName?: string;\n\tposition?: \"top\" | \"bottom\";\n\talign?: \"right\" | \"left\";\n\t// Display the support widget in a floating window or in responsive mode (takes the full width / height of the parent)\n\tmode?: \"floating\" | \"responsive\";\n\tquickOptions?: string[];\n\tdefaultMessages?: DefaultMessage[];\n\tdefaultOpen?: boolean;\n\tlocale?: Locale;\n\tcontent?: SupportTextContentOverrides<Locale>;\n};\n\n// Internal component that needs the conversation context\n/**\n * Orchestrates the end-user support experience by nesting realtime, config and\n * content providers. Renders nothing until website data is available to avoid\n * flashing incomplete UI.\n */\nexport function Support<Locale extends string = SupportLocale>({\n\tclassName,\n\tposition = \"bottom\",\n\talign = \"right\",\n\tmode = \"floating\",\n\tquickOptions,\n\tdefaultMessages,\n\tdefaultOpen,\n\tlocale,\n\tcontent,\n}: SupportProps<Locale>) {\n\tconst { website } = useSupport();\n\n\tif (!website) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<SupportRealtimeProvider>\n\t\t\t\t<SupportConfigProvider defaultOpen={defaultOpen} mode={mode}>\n\t\t\t\t\t<SupportTextProvider content={content} locale={locale}>\n\t\t\t\t\t\t<SupportContent\n\t\t\t\t\t\t\talign={align}\n\t\t\t\t\t\t\tclassName={className}\n\t\t\t\t\t\t\tmode={mode}\n\t\t\t\t\t\t\tposition={position}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</SupportTextProvider>\n\t\t\t\t</SupportConfigProvider>\n\t\t\t</SupportRealtimeProvider>\n\t\t\t<SupportConfig\n\t\t\t\tdefaultMessages={defaultMessages}\n\t\t\t\tquickOptions={quickOptions}\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default Support;\n\nexport { useSupportConfig } from \"./context/config\";\nexport type { WebSocketContextValue } from \"./context/websocket\";\nexport { useWebSocket, WebSocketProvider } from \"./context/websocket\";\n// Export the store for direct access if needed\nexport { useSupportStore } from \"./store\";\nexport type { SupportLocale, SupportTextContentOverrides } from \"./text\";\nexport { Text, useSupportText } from \"./text\";\n"],"mappings":";;;;;;;;;;;;;;;;;AA8BA,SAAgB,QAA+C,EAC9D,WACA,WAAW,UACX,QAAQ,SACR,OAAO,YACP,cACA,iBACA,aACA,QACA,WACwB;CACxB,MAAM,EAAE,YAAY,YAAY;AAEhC,KAAI,CAAC,QACJ,QAAO;AAGR,QACC,4CACC,oBAAC,qCACA,oBAAC;EAAmC;EAAmB;YACtD,oBAAC;GAA6B;GAAiB;aAC9C,oBAAC;IACO;IACI;IACL;IACI;KACT;IACmB;GACC,GACC,EAC1B,oBAAC;EACiB;EACH;GACb,IACA;;AAIL,sBAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"articles.d.ts","names":[],"sources":["../../../src/support/pages/articles.tsx"],"sourcesContent":[],"mappings":";;;cAKa,cAAc,KAAA,CAAM"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Container } from "../components/container.js";
|
|
2
|
+
import { Header } from "../components/header.js";
|
|
3
|
+
import { NavigationTab } from "../components/navigation-tab.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/support/pages/articles.tsx
|
|
7
|
+
const ArticlesPage = () => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Header, { children: /* @__PURE__ */ jsx(NavigationTab, {}) }), /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx("div", {
|
|
8
|
+
className: "p-2",
|
|
9
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
10
|
+
className: "flex flex-col gap-5",
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
|
|
13
|
+
className: "mb-2 font-medium text-base text-primary",
|
|
14
|
+
children: "How do I start a conversation?"
|
|
15
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
16
|
+
className: "text-primary/60 text-sm leading-relaxed",
|
|
17
|
+
children: "Click the \"Start New Conversation\" button on the home page to begin chatting with our support team."
|
|
18
|
+
})] }),
|
|
19
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
|
|
20
|
+
className: "mb-2 font-medium text-base text-primary",
|
|
21
|
+
children: "Can I view previous conversations?"
|
|
22
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
23
|
+
className: "text-primary/60 text-sm leading-relaxed",
|
|
24
|
+
children: "Yes! Navigate to the Conversation History page to see all your past conversations."
|
|
25
|
+
})] }),
|
|
26
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
|
|
27
|
+
className: "mb-2 font-medium text-base text-primary",
|
|
28
|
+
children: "How quickly will I get a response?"
|
|
29
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
30
|
+
className: "text-primary/60 text-sm leading-relaxed",
|
|
31
|
+
children: "Our team typically responds within a few minutes during business hours."
|
|
32
|
+
})] })
|
|
33
|
+
]
|
|
34
|
+
})
|
|
35
|
+
}) })] });
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { ArticlesPage };
|
|
39
|
+
//# sourceMappingURL=articles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"articles.js","names":["ArticlesPage: React.FC"],"sources":["../../../src/support/pages/articles.tsx"],"sourcesContent":["import type React from \"react\";\nimport { Container } from \"../components/container\";\nimport { Header } from \"../components/header\";\nimport { NavigationTab } from \"../components/navigation-tab\";\n\nexport const ArticlesPage: React.FC = () => (\n\t<>\n\t\t<Header>\n\t\t\t<NavigationTab />\n\t\t</Header>\n\t\t<Container>\n\t\t\t<div className=\"p-2\">\n\t\t\t\t<div className=\"flex flex-col gap-5\">\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<h3 className=\"mb-2 font-medium text-base text-primary\">\n\t\t\t\t\t\t\tHow do I start a conversation?\n\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t<p className=\"text-primary/60 text-sm leading-relaxed\">\n\t\t\t\t\t\t\tClick the \"Start New Conversation\" button on the home page to\n\t\t\t\t\t\t\tbegin chatting with our support team.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<h3 className=\"mb-2 font-medium text-base text-primary\">\n\t\t\t\t\t\t\tCan I view previous conversations?\n\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t<p className=\"text-primary/60 text-sm leading-relaxed\">\n\t\t\t\t\t\t\tYes! Navigate to the Conversation History page to see all your\n\t\t\t\t\t\t\tpast conversations.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<h3 className=\"mb-2 font-medium text-base text-primary\">\n\t\t\t\t\t\t\tHow quickly will I get a response?\n\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t<p className=\"text-primary/60 text-sm leading-relaxed\">\n\t\t\t\t\t\t\tOur team typically responds within a few minutes during business\n\t\t\t\t\t\t\thours.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</Container>\n\t</>\n);\n"],"mappings":";;;;;;AAKA,MAAaA,qBACZ,4CACC,oBAAC,oBACA,oBAAC,kBAAgB,GACT,EACT,oBAAC,uBACA,oBAAC;CAAI,WAAU;WACd,qBAAC;EAAI,WAAU;;GACd,qBAAC,oBACA,oBAAC;IAAG,WAAU;cAA0C;KAEnD,EACL,oBAAC;IAAE,WAAU;cAA0C;KAGnD,IACC;GACN,qBAAC,oBACA,oBAAC;IAAG,WAAU;cAA0C;KAEnD,EACL,oBAAC;IAAE,WAAU;cAA0C;KAGnD,IACC;GACN,qBAAC,oBACA,oBAAC;IAAG,WAAU;cAA0C;KAEnD,EACL,oBAAC;IAAE,WAAU;cAA0C;KAGnD,IACC;;GACD;EACD,GACK,IACV"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/support/pages/conversation-history.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Conversation history page component.
|
|
7
|
+
*
|
|
8
|
+
* Displays:
|
|
9
|
+
* - List of all conversations
|
|
10
|
+
* - Pagination controls
|
|
11
|
+
* - Button to start new conversation
|
|
12
|
+
*
|
|
13
|
+
* All logic is handled by the useConversationHistoryPage hook.
|
|
14
|
+
*/
|
|
15
|
+
declare const ConversationHistoryPage: React.FC;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ConversationHistoryPage };
|
|
18
|
+
//# sourceMappingURL=conversation-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-history.d.ts","names":[],"sources":["../../../src/support/pages/conversation-history.tsx"],"sourcesContent":[],"mappings":";;;;;;AAwBA;;;;;;;;cAAa,yBAAyB,KAAA,CAAM"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { AvatarStack } from "../components/avatar-stack.js";
|
|
2
|
+
import { useSupportNavigation } from "../store/support-store.js";
|
|
3
|
+
import { Button } from "../components/button.js";
|
|
4
|
+
import icons_default from "../components/icons.js";
|
|
5
|
+
import { Header } from "../components/header.js";
|
|
6
|
+
import { Text, useSupportText } from "../text/index.js";
|
|
7
|
+
import { PENDING_CONVERSATION_ID } from "../../utils/id.js";
|
|
8
|
+
import { Watermark } from "../components/watermark.js";
|
|
9
|
+
import { useConversationHistoryPage } from "../../hooks/use-conversation-history-page.js";
|
|
10
|
+
import { ConversationButtonLink } from "../components/conversation-button-link.js";
|
|
11
|
+
import { TextEffect } from "../components/text-effect.js";
|
|
12
|
+
import { useSupport } from "../../provider.js";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
|
|
15
|
+
//#region src/support/pages/conversation-history.tsx
|
|
16
|
+
/**
|
|
17
|
+
* Conversation history page component.
|
|
18
|
+
*
|
|
19
|
+
* Displays:
|
|
20
|
+
* - List of all conversations
|
|
21
|
+
* - Pagination controls
|
|
22
|
+
* - Button to start new conversation
|
|
23
|
+
*
|
|
24
|
+
* All logic is handled by the useConversationHistoryPage hook.
|
|
25
|
+
*/
|
|
26
|
+
const ConversationHistoryPage = () => {
|
|
27
|
+
const { goBack, canGoBack, navigate } = useSupportNavigation();
|
|
28
|
+
const { availableAIAgents, availableHumanAgents } = useSupport();
|
|
29
|
+
const text = useSupportText();
|
|
30
|
+
const history = useConversationHistoryPage({
|
|
31
|
+
initialVisibleCount: 4,
|
|
32
|
+
onOpenConversation: (conversationId) => {
|
|
33
|
+
navigate({
|
|
34
|
+
page: "CONVERSATION",
|
|
35
|
+
params: { conversationId }
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
onStartConversation: (initialMessage) => {
|
|
39
|
+
navigate({
|
|
40
|
+
page: "CONVERSATION",
|
|
41
|
+
params: {
|
|
42
|
+
conversationId: PENDING_CONVERSATION_ID,
|
|
43
|
+
initialMessage
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const handleGoBack = () => {
|
|
49
|
+
if (canGoBack) goBack();
|
|
50
|
+
else navigate({ page: "HOME" });
|
|
51
|
+
};
|
|
52
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
53
|
+
/* @__PURE__ */ jsx(Header, {
|
|
54
|
+
onGoBack: handleGoBack,
|
|
55
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
56
|
+
className: "flex w-full items-center justify-between gap-2 py-3",
|
|
57
|
+
children: [/* @__PURE__ */ jsx("div", { className: "flex flex-col" }), /* @__PURE__ */ jsx(AvatarStack, {
|
|
58
|
+
aiAgents: availableAIAgents,
|
|
59
|
+
gapWidth: 2,
|
|
60
|
+
humanAgents: availableHumanAgents,
|
|
61
|
+
size: 32,
|
|
62
|
+
spacing: 28
|
|
63
|
+
})]
|
|
64
|
+
})
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: "sticky top-4 flex flex-1 items-center justify-center",
|
|
68
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
69
|
+
className: "flex flex-col items-center gap-2",
|
|
70
|
+
children: /* @__PURE__ */ jsx(TextEffect, {
|
|
71
|
+
as: "h2",
|
|
72
|
+
className: "max-w-xs text-balance text-center font-co-sans text-2xl leading-normal",
|
|
73
|
+
delay: .5,
|
|
74
|
+
preset: "fade-in-blur",
|
|
75
|
+
children: text("page.conversationHistory.title")
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
}),
|
|
79
|
+
/* @__PURE__ */ jsxs("div", {
|
|
80
|
+
className: "flex flex-shrink-0 flex-col items-center justify-center gap-2 px-6 pt-20 pb-4",
|
|
81
|
+
children: [history.conversations.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [history.hasMore && /* @__PURE__ */ jsx(Button, {
|
|
82
|
+
className: "relative mt-6 w-full text-co-primary/40 text-xs hover:text-co-primary",
|
|
83
|
+
onClick: history.showAll,
|
|
84
|
+
variant: "ghost",
|
|
85
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
86
|
+
as: "span",
|
|
87
|
+
textKey: "page.conversationHistory.showMore",
|
|
88
|
+
variables: { count: history.remainingCount }
|
|
89
|
+
})
|
|
90
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
91
|
+
className: "mt-6 flex w-full flex-col overflow-clip rounded-md border border-co-border/80",
|
|
92
|
+
children: history.visibleConversations.map((conversation) => /* @__PURE__ */ jsx(ConversationButtonLink, {
|
|
93
|
+
className: "rounded-none",
|
|
94
|
+
conversation,
|
|
95
|
+
onClick: () => history.openConversation(conversation.id)
|
|
96
|
+
}, conversation.id))
|
|
97
|
+
})] }), /* @__PURE__ */ jsxs("div", {
|
|
98
|
+
className: "sticky bottom-4 z-10 flex w-full flex-col items-center gap-2",
|
|
99
|
+
children: [/* @__PURE__ */ jsxs(Button, {
|
|
100
|
+
className: "relative w-full justify-between",
|
|
101
|
+
onClick: () => history.startConversation(),
|
|
102
|
+
size: "large",
|
|
103
|
+
variant: "secondary",
|
|
104
|
+
children: [/* @__PURE__ */ jsx(icons_default, {
|
|
105
|
+
className: "-translate-y-1/2 absolute top-1/2 right-4 size-3 text-co-primary/60 transition-transform duration-200 group-hover/btn:translate-x-0.5 group-hover/btn:text-co-primary",
|
|
106
|
+
name: "arrow-right",
|
|
107
|
+
variant: "default"
|
|
108
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
109
|
+
as: "span",
|
|
110
|
+
textKey: "common.actions.askQuestion"
|
|
111
|
+
})]
|
|
112
|
+
}), /* @__PURE__ */ jsx(Watermark, { className: "mt-4 mb-2" })]
|
|
113
|
+
})]
|
|
114
|
+
})
|
|
115
|
+
] });
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { ConversationHistoryPage };
|
|
120
|
+
//# sourceMappingURL=conversation-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-history.js","names":["ConversationHistoryPage: React.FC","Icon"],"sources":["../../../src/support/pages/conversation-history.tsx"],"sourcesContent":["import { useSupport } from \"@cossistant/react\";\nimport { PENDING_CONVERSATION_ID } from \"@cossistant/react/utils/id\";\nimport type React from \"react\";\nimport { useConversationHistoryPage } from \"../../hooks/use-conversation-history-page\";\nimport { AvatarStack } from \"../components/avatar-stack\";\nimport { Button } from \"../components/button\";\nimport { ConversationButtonLink } from \"../components/conversation-button-link\";\nimport { Header } from \"../components/header\";\nimport Icon from \"../components/icons\";\nimport { TextEffect } from \"../components/text-effect\";\nimport { Watermark } from \"../components/watermark\";\nimport { useSupportNavigation } from \"../store/support-store\";\nimport { Text, useSupportText } from \"../text\";\n\n/**\n * Conversation history page component.\n *\n * Displays:\n * - List of all conversations\n * - Pagination controls\n * - Button to start new conversation\n *\n * All logic is handled by the useConversationHistoryPage hook.\n */\nexport const ConversationHistoryPage: React.FC = () => {\n\tconst { goBack, canGoBack, navigate } = useSupportNavigation();\n\tconst { availableAIAgents, availableHumanAgents } = useSupport();\n\tconst text = useSupportText();\n\n\tconst history = useConversationHistoryPage({\n\t\tinitialVisibleCount: 4,\n\t\tonOpenConversation: (conversationId) => {\n\t\t\tnavigate({\n\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\tparams: {\n\t\t\t\t\tconversationId,\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t\tonStartConversation: (initialMessage) => {\n\t\t\tnavigate({\n\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\tparams: {\n\t\t\t\t\tconversationId: PENDING_CONVERSATION_ID,\n\t\t\t\t\tinitialMessage,\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t});\n\n\tconst handleGoBack = () => {\n\t\tif (canGoBack) {\n\t\t\tgoBack();\n\t\t} else {\n\t\t\tnavigate({\n\t\t\t\tpage: \"HOME\",\n\t\t\t});\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Header onGoBack={handleGoBack}>\n\t\t\t\t<div className=\"flex w-full items-center justify-between gap-2 py-3\">\n\t\t\t\t\t<div className=\"flex flex-col\" />\n\t\t\t\t\t<AvatarStack\n\t\t\t\t\t\taiAgents={availableAIAgents}\n\t\t\t\t\t\tgapWidth={2}\n\t\t\t\t\t\thumanAgents={availableHumanAgents}\n\t\t\t\t\t\tsize={32}\n\t\t\t\t\t\tspacing={28}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</Header>\n\t\t\t<div className=\"sticky top-4 flex flex-1 items-center justify-center\">\n\t\t\t\t<div className=\"flex flex-col items-center gap-2\">\n\t\t\t\t\t<TextEffect\n\t\t\t\t\t\tas=\"h2\"\n\t\t\t\t\t\tclassName=\"max-w-xs text-balance text-center font-co-sans text-2xl leading-normal\"\n\t\t\t\t\t\tdelay={0.5}\n\t\t\t\t\t\tpreset=\"fade-in-blur\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{text(\"page.conversationHistory.title\")}\n\t\t\t\t\t</TextEffect>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div className=\"flex flex-shrink-0 flex-col items-center justify-center gap-2 px-6 pt-20 pb-4\">\n\t\t\t\t{history.conversations.length > 0 && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{history.hasMore && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"relative mt-6 w-full text-co-primary/40 text-xs hover:text-co-primary\"\n\t\t\t\t\t\t\t\tonClick={history.showAll}\n\t\t\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\t\ttextKey=\"page.conversationHistory.showMore\"\n\t\t\t\t\t\t\t\t\tvariables={{ count: history.remainingCount }}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<div className=\"mt-6 flex w-full flex-col overflow-clip rounded-md border border-co-border/80\">\n\t\t\t\t\t\t\t{history.visibleConversations.map((conversation) => (\n\t\t\t\t\t\t\t\t<ConversationButtonLink\n\t\t\t\t\t\t\t\t\tclassName=\"rounded-none\"\n\t\t\t\t\t\t\t\t\tconversation={conversation}\n\t\t\t\t\t\t\t\t\tkey={conversation.id}\n\t\t\t\t\t\t\t\t\tonClick={() => history.openConversation(conversation.id)}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\n\t\t\t\t<div className=\"sticky bottom-4 z-10 flex w-full flex-col items-center gap-2\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"relative w-full justify-between\"\n\t\t\t\t\t\tonClick={() => history.startConversation()}\n\t\t\t\t\t\tsize=\"large\"\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"-translate-y-1/2 absolute top-1/2 right-4 size-3 text-co-primary/60 transition-transform duration-200 group-hover/btn:translate-x-0.5 group-hover/btn:text-co-primary\"\n\t\t\t\t\t\t\tname=\"arrow-right\"\n\t\t\t\t\t\t\tvariant=\"default\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Text as=\"span\" textKey=\"common.actions.askQuestion\" />\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Watermark className=\"mt-4 mb-2\" />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAaA,gCAA0C;CACtD,MAAM,EAAE,QAAQ,WAAW,aAAa,sBAAsB;CAC9D,MAAM,EAAE,mBAAmB,yBAAyB,YAAY;CAChE,MAAM,OAAO,gBAAgB;CAE7B,MAAM,UAAU,2BAA2B;EAC1C,qBAAqB;EACrB,qBAAqB,mBAAmB;AACvC,YAAS;IACR,MAAM;IACN,QAAQ,EACP,gBACA;IACD,CAAC;;EAEH,sBAAsB,mBAAmB;AACxC,YAAS;IACR,MAAM;IACN,QAAQ;KACP,gBAAgB;KAChB;KACA;IACD,CAAC;;EAEH,CAAC;CAEF,MAAM,qBAAqB;AAC1B,MAAI,UACH,SAAQ;MAER,UAAS,EACR,MAAM,QACN,CAAC;;AAIJ,QACC;EACC,oBAAC;GAAO,UAAU;aACjB,qBAAC;IAAI,WAAU;eACd,oBAAC,SAAI,WAAU,kBAAkB,EACjC,oBAAC;KACA,UAAU;KACV,UAAU;KACV,aAAa;KACb,MAAM;KACN,SAAS;MACR;KACG;IACE;EACT,oBAAC;GAAI,WAAU;aACd,oBAAC;IAAI,WAAU;cACd,oBAAC;KACA,IAAG;KACH,WAAU;KACV,OAAO;KACP,QAAO;eAEN,KAAK,iCAAiC;MAC3B;KACR;IACD;EACN,qBAAC;GAAI,WAAU;cACb,QAAQ,cAAc,SAAS,KAC/B,4CACE,QAAQ,WACR,oBAAC;IACA,WAAU;IACV,SAAS,QAAQ;IACjB,SAAQ;cAER,oBAAC;KACA,IAAG;KACH,SAAQ;KACR,WAAW,EAAE,OAAO,QAAQ,gBAAgB;MAC3C;KACM,EAEV,oBAAC;IAAI,WAAU;cACb,QAAQ,qBAAqB,KAAK,iBAClC,oBAAC;KACA,WAAU;KACI;KAEd,eAAe,QAAQ,iBAAiB,aAAa,GAAG;OADnD,aAAa,GAEjB,CACD;KACG,IACJ,EAGJ,qBAAC;IAAI,WAAU;eACd,qBAAC;KACA,WAAU;KACV,eAAe,QAAQ,mBAAmB;KAC1C,MAAK;KACL,SAAQ;gBAER,oBAACC;MACA,WAAU;MACV,MAAK;MACL,SAAQ;OACP,EACF,oBAAC;MAAK,IAAG;MAAO,SAAQ;OAA+B;MAC/C,EACT,oBAAC,aAAU,WAAU,cAAc;KAC9B;IACD;KACJ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TimelineItem } from "../../timeline-item.js";
|
|
2
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/support/pages/conversation.d.ts
|
|
5
|
+
type ConversationPageProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The conversation ID to display (can be PENDING_CONVERSATION_ID or a real ID).
|
|
8
|
+
*/
|
|
9
|
+
conversationId: string;
|
|
10
|
+
/**
|
|
11
|
+
* Optional initial message to send when opening the conversation.
|
|
12
|
+
*/
|
|
13
|
+
initialMessage?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional timeline items to display (for optimistic updates or initial state).
|
|
16
|
+
*/
|
|
17
|
+
items?: TimelineItem[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Main conversation page component.
|
|
21
|
+
*
|
|
22
|
+
* All conversation logic is handled by the useConversationPage hook,
|
|
23
|
+
* making this component focused purely on rendering and user interaction.
|
|
24
|
+
*/
|
|
25
|
+
declare const ConversationPage: ({
|
|
26
|
+
conversationId: initialConversationId,
|
|
27
|
+
initialMessage,
|
|
28
|
+
items: passedItems
|
|
29
|
+
}: ConversationPageProps) => react_jsx_runtime3.JSX.Element;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { ConversationPage };
|
|
32
|
+
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","names":[],"sources":["../../../src/support/pages/conversation.tsx"],"sourcesContent":[],"mappings":";;;;KAUK,qBAAA;;;AAVmE;EAiC3D,cAAA,EAAA,MA+EZ;EAAA;;;gBA/EgC,CAAA,EAAA,MAAA;;;;UATxB;;;;;;;;cASI;kBAAoB;;SAAA;GAI9B,0BAAqB,kBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { AvatarStack } from "../components/avatar-stack.js";
|
|
2
|
+
import { useSupportNavigation } from "../store/support-store.js";
|
|
3
|
+
import { Header } from "../components/header.js";
|
|
4
|
+
import { Text, useSupportText } from "../text/index.js";
|
|
5
|
+
import { useConversationPage } from "../../hooks/use-conversation-page.js";
|
|
6
|
+
import { ConversationTimelineList } from "../components/conversation-timeline.js";
|
|
7
|
+
import { MultimodalInput } from "../components/multimodal-input.js";
|
|
8
|
+
import { useSupport } from "../../provider.js";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
//#region src/support/pages/conversation.tsx
|
|
12
|
+
/**
|
|
13
|
+
* Main conversation page component.
|
|
14
|
+
*
|
|
15
|
+
* All conversation logic is handled by the useConversationPage hook,
|
|
16
|
+
* making this component focused purely on rendering and user interaction.
|
|
17
|
+
*/
|
|
18
|
+
const ConversationPage = ({ conversationId: initialConversationId, initialMessage, items: passedItems = [] }) => {
|
|
19
|
+
const { website, availableAIAgents, availableHumanAgents, visitor } = useSupport();
|
|
20
|
+
const { navigate, replace, goBack, canGoBack } = useSupportNavigation();
|
|
21
|
+
const text = useSupportText();
|
|
22
|
+
const conversation = useConversationPage({
|
|
23
|
+
conversationId: initialConversationId,
|
|
24
|
+
items: passedItems,
|
|
25
|
+
initialMessage,
|
|
26
|
+
onConversationIdChange: (newConversationId) => {
|
|
27
|
+
replace({
|
|
28
|
+
page: "CONVERSATION",
|
|
29
|
+
params: { conversationId: newConversationId }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const handleGoBack = () => {
|
|
34
|
+
if (canGoBack) goBack();
|
|
35
|
+
else navigate({ page: "HOME" });
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
38
|
+
className: "flex h-full flex-col gap-0 overflow-hidden",
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsx(Header, {
|
|
41
|
+
onGoBack: handleGoBack,
|
|
42
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
43
|
+
className: "flex w-full items-center justify-between gap-2 py-3",
|
|
44
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
45
|
+
className: "flex flex-col",
|
|
46
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
47
|
+
className: "font-medium text-sm",
|
|
48
|
+
children: website?.name
|
|
49
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
50
|
+
as: "p",
|
|
51
|
+
className: "text-muted-foreground text-sm",
|
|
52
|
+
textKey: "common.labels.supportOnline"
|
|
53
|
+
})]
|
|
54
|
+
}), /* @__PURE__ */ jsx(AvatarStack, {
|
|
55
|
+
aiAgents: availableAIAgents,
|
|
56
|
+
gapWidth: 2,
|
|
57
|
+
humanAgents: availableHumanAgents,
|
|
58
|
+
size: 32,
|
|
59
|
+
spacing: 28
|
|
60
|
+
})]
|
|
61
|
+
})
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ jsx(ConversationTimelineList, {
|
|
64
|
+
availableAIAgents,
|
|
65
|
+
availableHumanAgents,
|
|
66
|
+
className: "min-h-0 flex-1 px-4",
|
|
67
|
+
conversationId: conversation.conversationId,
|
|
68
|
+
currentVisitorId: visitor?.id,
|
|
69
|
+
items: conversation.items
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ jsx("div", {
|
|
72
|
+
className: "flex-shrink-0 p-1",
|
|
73
|
+
children: /* @__PURE__ */ jsx(MultimodalInput, {
|
|
74
|
+
disabled: conversation.composer.isSubmitting,
|
|
75
|
+
error: conversation.error,
|
|
76
|
+
files: conversation.composer.files,
|
|
77
|
+
isSubmitting: conversation.composer.isSubmitting,
|
|
78
|
+
onChange: conversation.composer.setMessage,
|
|
79
|
+
onFileSelect: conversation.composer.addFiles,
|
|
80
|
+
onRemoveFile: conversation.composer.removeFile,
|
|
81
|
+
onSubmit: conversation.composer.submit,
|
|
82
|
+
placeholder: text("component.multimodalInput.placeholder"),
|
|
83
|
+
value: conversation.composer.message
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { ConversationPage };
|
|
92
|
+
//# sourceMappingURL=conversation.js.map
|