@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,29 @@
|
|
|
1
|
+
import { RealtimeEvent, RealtimeEventData, RealtimeEventType } from "../realtime-events.js";
|
|
2
|
+
import { RealtimeContextValue } from "./provider.js";
|
|
3
|
+
|
|
4
|
+
//#region src/realtime/use-realtime.d.ts
|
|
5
|
+
type RealtimeHandlerContext<TContext> = TContext;
|
|
6
|
+
type RealtimeEventMeta<TType extends RealtimeEventType, TContext> = {
|
|
7
|
+
event: RealtimeEvent<TType>;
|
|
8
|
+
context: RealtimeHandlerContext<TContext>;
|
|
9
|
+
};
|
|
10
|
+
type RealtimeEventHandler<TType extends RealtimeEventType, TContext> = (data: RealtimeEventData<TType>, meta: RealtimeEventMeta<TType, TContext>) => void | Promise<void>;
|
|
11
|
+
type RealtimeEventHandlerEntry<TType extends RealtimeEventType, TContext> = RealtimeEventHandler<TType, TContext> | RealtimeEventHandler<TType, TContext>[];
|
|
12
|
+
type RealtimeEventHandlersMap<TContext> = Partial<{ [TType in RealtimeEventType]: RealtimeEventHandlerEntry<TType, TContext> }>;
|
|
13
|
+
type UseRealtimeOptions<TContext, THandlers extends RealtimeEventHandlersMap<TContext>> = {
|
|
14
|
+
events: THandlers;
|
|
15
|
+
websiteId?: string | null;
|
|
16
|
+
visitorId?: string | null;
|
|
17
|
+
context?: TContext;
|
|
18
|
+
onEventError?: (error: unknown, event: RealtimeEvent<RealtimeEventType>) => void;
|
|
19
|
+
};
|
|
20
|
+
declare function useRealtime<TContext = void, THandlers extends RealtimeEventHandlersMap<TContext> = RealtimeEventHandlersMap<TContext>>({
|
|
21
|
+
events,
|
|
22
|
+
websiteId,
|
|
23
|
+
visitorId,
|
|
24
|
+
context,
|
|
25
|
+
onEventError
|
|
26
|
+
}: UseRealtimeOptions<TContext, THandlers>): RealtimeContextValue;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { RealtimeEventHandler, RealtimeEventHandlerEntry, RealtimeEventHandlersMap, RealtimeEventMeta, RealtimeHandlerContext, useRealtime };
|
|
29
|
+
//# sourceMappingURL=use-realtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-realtime.d.ts","names":[],"sources":["../../src/realtime/use-realtime.ts"],"sourcesContent":[],"mappings":";;;;KAUY,mCAAmC;KAEnC,gCAAgC;SACpC,cAAc;EAHV,OAAA,EAIF,sBAJwB,CAID,QAJc,CAAA;AAE/C,CAAA;AAA6B,KAKjB,oBALiB,CAAA,cAKkB,iBALlB,EAAA,QAAA,CAAA,GAAA,CAAA,IAAA,EAMtB,iBANsB,CAMJ,KANI,CAAA,EAAA,IAAA,EAOtB,iBAPsB,CAOJ,KAPI,EAOG,QAPH,CAAA,EAAA,GAAA,IAAA,GAQjB,OARiB,CAAA,IAAA,CAAA;AAAe,KAUhC,yBAVgC,CAAA,cAW7B,iBAX6B,EAAA,QAAA,CAAA,GAczC,oBAdyC,CAcpB,KAdoB,EAcb,QAda,CAAA,GAezC,oBAfyC,CAepB,KAfoB,EAeb,QAfa,CAAA,EAAA;AACtB,KAgBV,wBAhBU,CAAA,QAAA,CAAA,GAgB2B,OAhB3B,CAAA,YAiBX,iBAjBH,GAiBuB,yBAjBvB,CAiBiD,KAjBjD,EAiBwD,QAjBxD,CAAA;KAoBH,kBAnBK,CAAA,QAAA,EAAA,kBAqBS,wBArBT,CAqBkC,QArBlC,CAAA,CAAA,GAAA;EAAsB,MAAA,EAuBvB,SAvBuB;EAGpB,SAAA,CAAA,EAAA,MAAA,GAAA,IAAoB;EAAA,SAAA,CAAA,EAAA,MAAA,GAAA,IAAA;SAAe,CAAA,EAuBpC,QAvBoC;cACtB,CAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,KAAA,EAyBhB,aAzBgB,CAyBF,iBAzBE,CAAA,EAAA,GAAA,IAAA;;AACA,iBA4BT,WA5BS,CAAA,WAAA,IAAA,EAAA,kBA+BvB,wBA/BuB,CA+BE,QA/BF,CAAA,GA+Bc,wBA/Bd,CA+BuC,QA/BvC,CAAA,CAAA,CAAA;EAAA,MAAA;EAAA,SAAA;EAAA,SAAA;EAAA,OAAA;EAAA;AAAA,CAAA,EAsCtB,kBAtCsB,CAsCH,QAtCG,EAsCO,SAtCP,CAAA,CAAA,EAsCJ,oBAtCI"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useRealtimeConnection } from "./provider.js";
|
|
2
|
+
import { shouldDeliverEvent } from "./event-filter.js";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/realtime/use-realtime.ts
|
|
6
|
+
function useRealtime({ events, websiteId, visitorId, context, onEventError }) {
|
|
7
|
+
const connection = useRealtimeConnection();
|
|
8
|
+
const handlersRef = useRef(events);
|
|
9
|
+
const contextRef = useRef(context);
|
|
10
|
+
const websiteIdRef = useRef(websiteId ?? null);
|
|
11
|
+
const visitorIdRef = useRef(visitorId ?? null);
|
|
12
|
+
const errorHandlerRef = useRef(onEventError);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
handlersRef.current = events;
|
|
15
|
+
}, [events]);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
contextRef.current = context;
|
|
18
|
+
}, [context]);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
websiteIdRef.current = websiteId ?? null;
|
|
21
|
+
}, [websiteId]);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
visitorIdRef.current = visitorId ?? null;
|
|
24
|
+
}, [visitorId]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
errorHandlerRef.current = onEventError;
|
|
27
|
+
}, [onEventError]);
|
|
28
|
+
useEffect(() => connection.subscribe((event) => {
|
|
29
|
+
const handlers = handlersRef.current[event.type];
|
|
30
|
+
if (!handlers) return;
|
|
31
|
+
if (!shouldDeliverEvent(event, websiteIdRef.current, visitorIdRef.current)) return;
|
|
32
|
+
const payload = Array.isArray(handlers) ? handlers : [handlers];
|
|
33
|
+
for (const handler of payload) Promise.resolve(handler(event.payload, {
|
|
34
|
+
event,
|
|
35
|
+
context: contextRef.current
|
|
36
|
+
})).catch((error) => {
|
|
37
|
+
const errorHandler = errorHandlerRef.current;
|
|
38
|
+
if (errorHandler) errorHandler(error, event);
|
|
39
|
+
else console.error("[Realtime] Event handler threw an error", error);
|
|
40
|
+
});
|
|
41
|
+
}), [connection]);
|
|
42
|
+
return connection;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { useRealtime };
|
|
47
|
+
//# sourceMappingURL=use-realtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-realtime.js","names":[],"sources":["../../src/realtime/use-realtime.ts"],"sourcesContent":["import type {\n\tAnyRealtimeEvent,\n\tRealtimeEvent,\n\tRealtimeEventData,\n\tRealtimeEventType,\n} from \"@cossistant/types/realtime-events\";\nimport { useEffect, useRef } from \"react\";\nimport { shouldDeliverEvent } from \"./event-filter\";\nimport { useRealtimeConnection } from \"./provider\";\n\nexport type RealtimeHandlerContext<TContext> = TContext;\n\nexport type RealtimeEventMeta<TType extends RealtimeEventType, TContext> = {\n\tevent: RealtimeEvent<TType>;\n\tcontext: RealtimeHandlerContext<TContext>;\n};\n\nexport type RealtimeEventHandler<TType extends RealtimeEventType, TContext> = (\n\tdata: RealtimeEventData<TType>,\n\tmeta: RealtimeEventMeta<TType, TContext>\n) => void | Promise<void>;\n\nexport type RealtimeEventHandlerEntry<\n\tTType extends RealtimeEventType,\n\tTContext,\n> =\n\t| RealtimeEventHandler<TType, TContext>\n\t| RealtimeEventHandler<TType, TContext>[];\n\nexport type RealtimeEventHandlersMap<TContext> = Partial<{\n\t[TType in RealtimeEventType]: RealtimeEventHandlerEntry<TType, TContext>;\n}>;\n\ntype UseRealtimeOptions<\n\tTContext,\n\tTHandlers extends RealtimeEventHandlersMap<TContext>,\n> = {\n\tevents: THandlers;\n\twebsiteId?: string | null;\n\tvisitorId?: string | null;\n\tcontext?: TContext;\n\tonEventError?: (\n\t\terror: unknown,\n\t\tevent: RealtimeEvent<RealtimeEventType>\n\t) => void;\n};\n\nexport function useRealtime<\n\tTContext = void,\n\tTHandlers extends\n\t\tRealtimeEventHandlersMap<TContext> = RealtimeEventHandlersMap<TContext>,\n>({\n\tevents,\n\twebsiteId,\n\tvisitorId,\n\tcontext,\n\tonEventError,\n}: UseRealtimeOptions<TContext, THandlers>) {\n\tconst connection = useRealtimeConnection();\n\tconst handlersRef = useRef<RealtimeEventHandlersMap<TContext>>(events);\n\tconst contextRef = useRef<TContext | undefined>(context);\n\tconst websiteIdRef = useRef<string | null>(websiteId ?? null);\n\tconst visitorIdRef = useRef<string | null>(visitorId ?? null);\n\tconst errorHandlerRef = useRef<\n\t\t| ((error: unknown, event: RealtimeEvent<RealtimeEventType>) => void)\n\t\t| undefined\n\t>(onEventError);\n\n\tuseEffect(() => {\n\t\thandlersRef.current = events;\n\t}, [events]);\n\n\tuseEffect(() => {\n\t\tcontextRef.current = context;\n\t}, [context]);\n\n\tuseEffect(() => {\n\t\twebsiteIdRef.current = websiteId ?? null;\n\t}, [websiteId]);\n\n\tuseEffect(() => {\n\t\tvisitorIdRef.current = visitorId ?? null;\n\t}, [visitorId]);\n\n\tuseEffect(() => {\n\t\terrorHandlerRef.current = onEventError;\n\t}, [onEventError]);\n\n\tuseEffect(\n\t\t() =>\n\t\t\tconnection.subscribe((event) => {\n\t\t\t\tconst handlers = handlersRef.current[event.type];\n\n\t\t\t\tif (!handlers) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t!shouldDeliverEvent(event, websiteIdRef.current, visitorIdRef.current)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst payload = Array.isArray(handlers) ? handlers : [handlers];\n\n\t\t\t\tfor (const handler of payload) {\n\t\t\t\t\tPromise.resolve(\n\t\t\t\t\t\thandler(event.payload as never, {\n\t\t\t\t\t\t\tevent: event as never,\n\t\t\t\t\t\t\tcontext: contextRef.current as TContext,\n\t\t\t\t\t\t})\n\t\t\t\t\t).catch((error) => {\n\t\t\t\t\t\tconst errorHandler = errorHandlerRef.current;\n\t\t\t\t\t\tif (errorHandler) {\n\t\t\t\t\t\t\terrorHandler(error, event);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.error(\"[Realtime] Event handler threw an error\", error);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}),\n\t\t[connection]\n\t);\n\n\treturn connection;\n}\n"],"mappings":";;;;;AA+CA,SAAgB,YAId,EACD,QACA,WACA,WACA,SACA,gBAC2C;CAC3C,MAAM,aAAa,uBAAuB;CAC1C,MAAM,cAAc,OAA2C,OAAO;CACtE,MAAM,aAAa,OAA6B,QAAQ;CACxD,MAAM,eAAe,OAAsB,aAAa,KAAK;CAC7D,MAAM,eAAe,OAAsB,aAAa,KAAK;CAC7D,MAAM,kBAAkB,OAGtB,aAAa;AAEf,iBAAgB;AACf,cAAY,UAAU;IACpB,CAAC,OAAO,CAAC;AAEZ,iBAAgB;AACf,aAAW,UAAU;IACnB,CAAC,QAAQ,CAAC;AAEb,iBAAgB;AACf,eAAa,UAAU,aAAa;IAClC,CAAC,UAAU,CAAC;AAEf,iBAAgB;AACf,eAAa,UAAU,aAAa;IAClC,CAAC,UAAU,CAAC;AAEf,iBAAgB;AACf,kBAAgB,UAAU;IACxB,CAAC,aAAa,CAAC;AAElB,iBAEE,WAAW,WAAW,UAAU;EAC/B,MAAM,WAAW,YAAY,QAAQ,MAAM;AAE3C,MAAI,CAAC,SACJ;AAGD,MACC,CAAC,mBAAmB,OAAO,aAAa,SAAS,aAAa,QAAQ,CAEtE;EAGD,MAAM,UAAU,MAAM,QAAQ,SAAS,GAAG,WAAW,CAAC,SAAS;AAE/D,OAAK,MAAM,WAAW,QACrB,SAAQ,QACP,QAAQ,MAAM,SAAkB;GACxB;GACP,SAAS,WAAW;GACpB,CAAC,CACF,CAAC,OAAO,UAAU;GAClB,MAAM,eAAe,gBAAgB;AACrC,OAAI,aACH,cAAa,OAAO,MAAM;OAE1B,SAAQ,MAAM,2CAA2C,MAAM;IAE/D;GAEF,EACH,CAAC,WAAW,CACZ;AAED,QAAO"}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region ../types/src/realtime-events.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Central event system for real-time communication
|
|
7
|
+
* All WebSocket and Redis Pub/Sub events are defined here
|
|
8
|
+
*/
|
|
9
|
+
declare const realtimeSchema: {
|
|
10
|
+
readonly userConnected: z.ZodObject<{
|
|
11
|
+
websiteId: z.ZodString;
|
|
12
|
+
organizationId: z.ZodString;
|
|
13
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
14
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
15
|
+
connectionId: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
readonly userDisconnected: z.ZodObject<{
|
|
18
|
+
websiteId: z.ZodString;
|
|
19
|
+
organizationId: z.ZodString;
|
|
20
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
21
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
22
|
+
connectionId: z.ZodString;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
readonly visitorConnected: z.ZodObject<{
|
|
25
|
+
websiteId: z.ZodString;
|
|
26
|
+
organizationId: z.ZodString;
|
|
27
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
28
|
+
visitorId: z.ZodString;
|
|
29
|
+
connectionId: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
readonly visitorDisconnected: z.ZodObject<{
|
|
32
|
+
websiteId: z.ZodString;
|
|
33
|
+
organizationId: z.ZodString;
|
|
34
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
35
|
+
visitorId: z.ZodString;
|
|
36
|
+
connectionId: z.ZodString;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
readonly userPresenceUpdate: z.ZodObject<{
|
|
39
|
+
websiteId: z.ZodString;
|
|
40
|
+
organizationId: z.ZodString;
|
|
41
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
42
|
+
userId: z.ZodString;
|
|
43
|
+
status: z.ZodEnum<{
|
|
44
|
+
online: "online";
|
|
45
|
+
away: "away";
|
|
46
|
+
offline: "offline";
|
|
47
|
+
}>;
|
|
48
|
+
lastSeen: z.ZodString;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
readonly conversationSeen: z.ZodObject<{
|
|
51
|
+
websiteId: z.ZodString;
|
|
52
|
+
organizationId: z.ZodString;
|
|
53
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
54
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
55
|
+
conversationId: z.ZodString;
|
|
56
|
+
aiAgentId: z.ZodNullable<z.ZodString>;
|
|
57
|
+
lastSeenAt: z.ZodString;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
readonly conversationTyping: z.ZodObject<{
|
|
60
|
+
websiteId: z.ZodString;
|
|
61
|
+
organizationId: z.ZodString;
|
|
62
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
63
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
64
|
+
conversationId: z.ZodString;
|
|
65
|
+
aiAgentId: z.ZodNullable<z.ZodString>;
|
|
66
|
+
isTyping: z.ZodBoolean;
|
|
67
|
+
visitorPreview: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
readonly timelineItemCreated: z.ZodObject<{
|
|
70
|
+
websiteId: z.ZodString;
|
|
71
|
+
organizationId: z.ZodString;
|
|
72
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
73
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
74
|
+
conversationId: z.ZodString;
|
|
75
|
+
item: z.ZodObject<{
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
conversationId: z.ZodString;
|
|
78
|
+
organizationId: z.ZodString;
|
|
79
|
+
visibility: z.ZodEnum<{
|
|
80
|
+
public: "public";
|
|
81
|
+
private: "private";
|
|
82
|
+
}>;
|
|
83
|
+
type: z.ZodEnum<{
|
|
84
|
+
message: "message";
|
|
85
|
+
event: "event";
|
|
86
|
+
}>;
|
|
87
|
+
text: z.ZodNullable<z.ZodString>;
|
|
88
|
+
parts: z.ZodArray<z.ZodUnknown>;
|
|
89
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
90
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
91
|
+
aiAgentId: z.ZodNullable<z.ZodString>;
|
|
92
|
+
createdAt: z.ZodString;
|
|
93
|
+
deletedAt: z.ZodNullable<z.ZodString>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
readonly conversationCreated: z.ZodObject<{
|
|
97
|
+
websiteId: z.ZodString;
|
|
98
|
+
organizationId: z.ZodString;
|
|
99
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
100
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
101
|
+
conversationId: z.ZodString;
|
|
102
|
+
conversation: z.ZodObject<{
|
|
103
|
+
id: z.ZodString;
|
|
104
|
+
title: z.ZodOptional<z.ZodString>;
|
|
105
|
+
createdAt: z.ZodString;
|
|
106
|
+
updatedAt: z.ZodString;
|
|
107
|
+
visitorId: z.ZodString;
|
|
108
|
+
websiteId: z.ZodString;
|
|
109
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
110
|
+
resolved: "resolved";
|
|
111
|
+
open: "open";
|
|
112
|
+
spam: "spam";
|
|
113
|
+
}>>;
|
|
114
|
+
lastTimelineItem: z.ZodOptional<z.ZodObject<{
|
|
115
|
+
id: z.ZodOptional<z.ZodString>;
|
|
116
|
+
conversationId: z.ZodString;
|
|
117
|
+
organizationId: z.ZodString;
|
|
118
|
+
visibility: z.ZodEnum<{
|
|
119
|
+
public: "public";
|
|
120
|
+
private: "private";
|
|
121
|
+
}>;
|
|
122
|
+
type: z.ZodEnum<{
|
|
123
|
+
message: "message";
|
|
124
|
+
event: "event";
|
|
125
|
+
}>;
|
|
126
|
+
text: z.ZodNullable<z.ZodString>;
|
|
127
|
+
parts: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
128
|
+
type: z.ZodLiteral<"text">;
|
|
129
|
+
text: z.ZodString;
|
|
130
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
131
|
+
type: z.ZodLiteral<"event">;
|
|
132
|
+
eventType: z.ZodEnum<{
|
|
133
|
+
assigned: "assigned";
|
|
134
|
+
unassigned: "unassigned";
|
|
135
|
+
participant_requested: "participant_requested";
|
|
136
|
+
participant_joined: "participant_joined";
|
|
137
|
+
participant_left: "participant_left";
|
|
138
|
+
status_changed: "status_changed";
|
|
139
|
+
priority_changed: "priority_changed";
|
|
140
|
+
tag_added: "tag_added";
|
|
141
|
+
tag_removed: "tag_removed";
|
|
142
|
+
resolved: "resolved";
|
|
143
|
+
reopened: "reopened";
|
|
144
|
+
}>;
|
|
145
|
+
actorUserId: z.ZodNullable<z.ZodString>;
|
|
146
|
+
actorAiAgentId: z.ZodNullable<z.ZodString>;
|
|
147
|
+
targetUserId: z.ZodNullable<z.ZodString>;
|
|
148
|
+
targetAiAgentId: z.ZodNullable<z.ZodString>;
|
|
149
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
150
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
151
|
+
type: z.ZodLiteral<"image">;
|
|
152
|
+
url: z.ZodString;
|
|
153
|
+
mediaType: z.ZodString;
|
|
154
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
155
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
157
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
158
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
159
|
+
type: z.ZodLiteral<"file">;
|
|
160
|
+
url: z.ZodString;
|
|
161
|
+
mediaType: z.ZodString;
|
|
162
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
163
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
164
|
+
}, z.core.$strip>]>>;
|
|
165
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
166
|
+
aiAgentId: z.ZodNullable<z.ZodString>;
|
|
167
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
168
|
+
createdAt: z.ZodString;
|
|
169
|
+
deletedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
170
|
+
}, z.core.$strip>>;
|
|
171
|
+
}, z.core.$strip>;
|
|
172
|
+
header: z.ZodObject<{
|
|
173
|
+
id: z.ZodString;
|
|
174
|
+
status: z.ZodEnum<{
|
|
175
|
+
resolved: "resolved";
|
|
176
|
+
open: "open";
|
|
177
|
+
spam: "spam";
|
|
178
|
+
}>;
|
|
179
|
+
priority: z.ZodEnum<{
|
|
180
|
+
normal: "normal";
|
|
181
|
+
high: "high";
|
|
182
|
+
low: "low";
|
|
183
|
+
urgent: "urgent";
|
|
184
|
+
}>;
|
|
185
|
+
organizationId: z.ZodString;
|
|
186
|
+
visitorId: z.ZodString;
|
|
187
|
+
visitor: z.ZodObject<{
|
|
188
|
+
id: z.ZodULID;
|
|
189
|
+
lastSeenAt: z.ZodNullable<z.ZodString>;
|
|
190
|
+
blockedAt: z.ZodNullable<z.ZodString>;
|
|
191
|
+
blockedByUserId: z.ZodNullable<z.ZodString>;
|
|
192
|
+
isBlocked: z.ZodBoolean;
|
|
193
|
+
contact: z.ZodNullable<z.ZodObject<{
|
|
194
|
+
id: z.ZodULID;
|
|
195
|
+
name: z.ZodNullable<z.ZodString>;
|
|
196
|
+
email: z.ZodNullable<z.ZodString>;
|
|
197
|
+
image: z.ZodNullable<z.ZodString>;
|
|
198
|
+
}, z.core.$strip>>;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
websiteId: z.ZodString;
|
|
201
|
+
channel: z.ZodString;
|
|
202
|
+
title: z.ZodNullable<z.ZodString>;
|
|
203
|
+
resolutionTime: z.ZodNullable<z.ZodNumber>;
|
|
204
|
+
startedAt: z.ZodNullable<z.ZodString>;
|
|
205
|
+
firstResponseAt: z.ZodNullable<z.ZodString>;
|
|
206
|
+
resolvedAt: z.ZodNullable<z.ZodString>;
|
|
207
|
+
resolvedByUserId: z.ZodNullable<z.ZodString>;
|
|
208
|
+
resolvedByAiAgentId: z.ZodNullable<z.ZodString>;
|
|
209
|
+
createdAt: z.ZodString;
|
|
210
|
+
updatedAt: z.ZodString;
|
|
211
|
+
deletedAt: z.ZodNullable<z.ZodString>;
|
|
212
|
+
lastMessageAt: z.ZodNullable<z.ZodString>;
|
|
213
|
+
lastSeenAt: z.ZodNullable<z.ZodString>;
|
|
214
|
+
lastTimelineItem: z.ZodNullable<z.ZodObject<{
|
|
215
|
+
id: z.ZodOptional<z.ZodString>;
|
|
216
|
+
conversationId: z.ZodString;
|
|
217
|
+
organizationId: z.ZodString;
|
|
218
|
+
visibility: z.ZodEnum<{
|
|
219
|
+
public: "public";
|
|
220
|
+
private: "private";
|
|
221
|
+
}>;
|
|
222
|
+
type: z.ZodEnum<{
|
|
223
|
+
message: "message";
|
|
224
|
+
event: "event";
|
|
225
|
+
}>;
|
|
226
|
+
text: z.ZodNullable<z.ZodString>;
|
|
227
|
+
parts: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
228
|
+
type: z.ZodLiteral<"text">;
|
|
229
|
+
text: z.ZodString;
|
|
230
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
231
|
+
type: z.ZodLiteral<"event">;
|
|
232
|
+
eventType: z.ZodEnum<{
|
|
233
|
+
assigned: "assigned";
|
|
234
|
+
unassigned: "unassigned";
|
|
235
|
+
participant_requested: "participant_requested";
|
|
236
|
+
participant_joined: "participant_joined";
|
|
237
|
+
participant_left: "participant_left";
|
|
238
|
+
status_changed: "status_changed";
|
|
239
|
+
priority_changed: "priority_changed";
|
|
240
|
+
tag_added: "tag_added";
|
|
241
|
+
tag_removed: "tag_removed";
|
|
242
|
+
resolved: "resolved";
|
|
243
|
+
reopened: "reopened";
|
|
244
|
+
}>;
|
|
245
|
+
actorUserId: z.ZodNullable<z.ZodString>;
|
|
246
|
+
actorAiAgentId: z.ZodNullable<z.ZodString>;
|
|
247
|
+
targetUserId: z.ZodNullable<z.ZodString>;
|
|
248
|
+
targetAiAgentId: z.ZodNullable<z.ZodString>;
|
|
249
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
250
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
251
|
+
type: z.ZodLiteral<"image">;
|
|
252
|
+
url: z.ZodString;
|
|
253
|
+
mediaType: z.ZodString;
|
|
254
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
255
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
256
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
257
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
258
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
259
|
+
type: z.ZodLiteral<"file">;
|
|
260
|
+
url: z.ZodString;
|
|
261
|
+
mediaType: z.ZodString;
|
|
262
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
263
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
264
|
+
}, z.core.$strip>]>>;
|
|
265
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
266
|
+
aiAgentId: z.ZodNullable<z.ZodString>;
|
|
267
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
268
|
+
createdAt: z.ZodString;
|
|
269
|
+
deletedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
270
|
+
}, z.core.$strip>>;
|
|
271
|
+
viewIds: z.ZodArray<z.ZodString>;
|
|
272
|
+
seenData: z.ZodArray<z.ZodObject<{
|
|
273
|
+
id: z.ZodString;
|
|
274
|
+
conversationId: z.ZodString;
|
|
275
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
276
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
277
|
+
aiAgentId: z.ZodNullable<z.ZodString>;
|
|
278
|
+
lastSeenAt: z.ZodString;
|
|
279
|
+
createdAt: z.ZodString;
|
|
280
|
+
updatedAt: z.ZodString;
|
|
281
|
+
deletedAt: z.ZodNullable<z.ZodString>;
|
|
282
|
+
}, z.core.$strip>>;
|
|
283
|
+
}, z.core.$strip>;
|
|
284
|
+
}, z.core.$strip>;
|
|
285
|
+
readonly visitorIdentified: z.ZodObject<{
|
|
286
|
+
websiteId: z.ZodString;
|
|
287
|
+
organizationId: z.ZodString;
|
|
288
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
289
|
+
visitorId: z.ZodString;
|
|
290
|
+
visitor: z.ZodObject<{
|
|
291
|
+
id: z.ZodULID;
|
|
292
|
+
browser: z.ZodNullable<z.ZodString>;
|
|
293
|
+
browserVersion: z.ZodNullable<z.ZodString>;
|
|
294
|
+
os: z.ZodNullable<z.ZodString>;
|
|
295
|
+
osVersion: z.ZodNullable<z.ZodString>;
|
|
296
|
+
device: z.ZodNullable<z.ZodString>;
|
|
297
|
+
deviceType: z.ZodNullable<z.ZodString>;
|
|
298
|
+
ip: z.ZodNullable<z.ZodString>;
|
|
299
|
+
city: z.ZodNullable<z.ZodString>;
|
|
300
|
+
region: z.ZodNullable<z.ZodString>;
|
|
301
|
+
country: z.ZodNullable<z.ZodString>;
|
|
302
|
+
countryCode: z.ZodNullable<z.ZodString>;
|
|
303
|
+
latitude: z.ZodNullable<z.ZodNumber>;
|
|
304
|
+
longitude: z.ZodNullable<z.ZodNumber>;
|
|
305
|
+
language: z.ZodNullable<z.ZodString>;
|
|
306
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
307
|
+
screenResolution: z.ZodNullable<z.ZodString>;
|
|
308
|
+
viewport: z.ZodNullable<z.ZodString>;
|
|
309
|
+
createdAt: z.ZodString;
|
|
310
|
+
updatedAt: z.ZodString;
|
|
311
|
+
lastSeenAt: z.ZodNullable<z.ZodString>;
|
|
312
|
+
websiteId: z.ZodULID;
|
|
313
|
+
organizationId: z.ZodULID;
|
|
314
|
+
blockedAt: z.ZodNullable<z.ZodString>;
|
|
315
|
+
blockedByUserId: z.ZodNullable<z.ZodString>;
|
|
316
|
+
isBlocked: z.ZodBoolean;
|
|
317
|
+
contact: z.ZodNullable<z.ZodObject<{
|
|
318
|
+
id: z.ZodULID;
|
|
319
|
+
externalId: z.ZodNullable<z.ZodString>;
|
|
320
|
+
name: z.ZodNullable<z.ZodString>;
|
|
321
|
+
email: z.ZodNullable<z.ZodEmail>;
|
|
322
|
+
image: z.ZodNullable<z.ZodURL>;
|
|
323
|
+
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber]>, z.ZodBoolean]>, z.ZodNull]>>>;
|
|
324
|
+
contactOrganizationId: z.ZodNullable<z.ZodULID>;
|
|
325
|
+
websiteId: z.ZodULID;
|
|
326
|
+
organizationId: z.ZodULID;
|
|
327
|
+
userId: z.ZodNullable<z.ZodULID>;
|
|
328
|
+
createdAt: z.ZodString;
|
|
329
|
+
updatedAt: z.ZodString;
|
|
330
|
+
}, z.core.$strip>>;
|
|
331
|
+
}, z.core.$strip>;
|
|
332
|
+
}, z.core.$strip>;
|
|
333
|
+
};
|
|
334
|
+
type RealtimeEventType = keyof typeof realtimeSchema;
|
|
335
|
+
type RealtimeEventPayload<T extends RealtimeEventType> = z.infer<(typeof realtimeSchema)[T]>;
|
|
336
|
+
type RealtimeEvent<T extends RealtimeEventType> = {
|
|
337
|
+
type: T;
|
|
338
|
+
payload: RealtimeEventPayload<T>;
|
|
339
|
+
};
|
|
340
|
+
type AnyRealtimeEvent = { [K in RealtimeEventType]: RealtimeEvent<K> }[RealtimeEventType];
|
|
341
|
+
type RealtimeEventData<T extends RealtimeEventType> = RealtimeEventPayload<T>;
|
|
342
|
+
//#endregion
|
|
343
|
+
export { AnyRealtimeEvent, RealtimeEvent, RealtimeEventData, RealtimeEventType };
|
|
344
|
+
//# sourceMappingURL=realtime-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime-events.d.ts","names":[],"sources":["../../types/src/realtime-events.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAiBa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiED,iBAAA,gBAAiC;KAEjC,+BAA+B,qBAAqB,CAAA,CAAE,cACzD,gBAAgB;KAGb,wBAAwB;QAC7B;WACG,qBAAqB;;KAGnB,gBAAA,WACL,oBAAoB,cAAc,KACvC;KAEU,4BAA4B,qBACvC,qBAAqB"}
|
package/schemas.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region ../types/src/schemas.d.ts
|
|
4
|
+
|
|
5
|
+
declare const conversationSchema: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
title: z.ZodOptional<z.ZodString>;
|
|
8
|
+
createdAt: z.ZodString;
|
|
9
|
+
updatedAt: z.ZodString;
|
|
10
|
+
visitorId: z.ZodString;
|
|
11
|
+
websiteId: z.ZodString;
|
|
12
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
13
|
+
resolved: "resolved";
|
|
14
|
+
open: "open";
|
|
15
|
+
spam: "spam";
|
|
16
|
+
}>>;
|
|
17
|
+
lastTimelineItem: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
id: z.ZodOptional<z.ZodString>;
|
|
19
|
+
conversationId: z.ZodString;
|
|
20
|
+
organizationId: z.ZodString;
|
|
21
|
+
visibility: z.ZodEnum<{
|
|
22
|
+
public: "public";
|
|
23
|
+
private: "private";
|
|
24
|
+
}>;
|
|
25
|
+
type: z.ZodEnum<{
|
|
26
|
+
message: "message";
|
|
27
|
+
event: "event";
|
|
28
|
+
}>;
|
|
29
|
+
text: z.ZodNullable<z.ZodString>;
|
|
30
|
+
parts: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<"text">;
|
|
32
|
+
text: z.ZodString;
|
|
33
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
34
|
+
type: z.ZodLiteral<"event">;
|
|
35
|
+
eventType: z.ZodEnum<{
|
|
36
|
+
assigned: "assigned";
|
|
37
|
+
unassigned: "unassigned";
|
|
38
|
+
participant_requested: "participant_requested";
|
|
39
|
+
participant_joined: "participant_joined";
|
|
40
|
+
participant_left: "participant_left";
|
|
41
|
+
status_changed: "status_changed";
|
|
42
|
+
priority_changed: "priority_changed";
|
|
43
|
+
tag_added: "tag_added";
|
|
44
|
+
tag_removed: "tag_removed";
|
|
45
|
+
resolved: "resolved";
|
|
46
|
+
reopened: "reopened";
|
|
47
|
+
}>;
|
|
48
|
+
actorUserId: z.ZodNullable<z.ZodString>;
|
|
49
|
+
actorAiAgentId: z.ZodNullable<z.ZodString>;
|
|
50
|
+
targetUserId: z.ZodNullable<z.ZodString>;
|
|
51
|
+
targetAiAgentId: z.ZodNullable<z.ZodString>;
|
|
52
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
54
|
+
type: z.ZodLiteral<"image">;
|
|
55
|
+
url: z.ZodString;
|
|
56
|
+
mediaType: z.ZodString;
|
|
57
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
58
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
62
|
+
type: z.ZodLiteral<"file">;
|
|
63
|
+
url: z.ZodString;
|
|
64
|
+
mediaType: z.ZodString;
|
|
65
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
66
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
}, z.core.$strip>]>>;
|
|
68
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
69
|
+
aiAgentId: z.ZodNullable<z.ZodString>;
|
|
70
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
71
|
+
createdAt: z.ZodString;
|
|
72
|
+
deletedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
type Conversation = z.infer<typeof conversationSchema>;
|
|
76
|
+
declare const conversationSeenSchema: z.ZodObject<{
|
|
77
|
+
id: z.ZodString;
|
|
78
|
+
conversationId: z.ZodString;
|
|
79
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
80
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
81
|
+
aiAgentId: z.ZodNullable<z.ZodString>;
|
|
82
|
+
lastSeenAt: z.ZodString;
|
|
83
|
+
createdAt: z.ZodString;
|
|
84
|
+
updatedAt: z.ZodString;
|
|
85
|
+
deletedAt: z.ZodNullable<z.ZodString>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
type ConversationSeen = z.infer<typeof conversationSeenSchema>;
|
|
88
|
+
//#endregion
|
|
89
|
+
export { Conversation, ConversationSeen };
|
|
90
|
+
//# sourceMappingURL=schemas.d.ts.map
|
package/schemas.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","names":[],"sources":["../../types/src/schemas.ts"],"sourcesContent":[],"mappings":";;;;cAkBa,oBAAkB,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA,SAAA,aAAA;IAAA,SAAA,eAAA,cAAA,YAAA,CAAA,CAAA;EAiBnB,CAAA,eAAY,CAAA,CAAA;CAAA,eAAA,CAAA;AAAkB,KAA9B,YAAA,GAAe,CAAA,CAAE,KAAa,CAAA,OAAA,kBAAA,CAAA;AAAf,cAEd,sBAFgB,EAEM,CAAA,CAAA,SAFN,CAAA;EAAK,EAAA,aAAA;EAErB,cAAA,aAUX;EAAA,MAAA,eAAA,YAAA,CAAA;;;;;;;;KAEU,gBAAA,GAAmB,CAAA,CAAE,aAAa"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as react0 from "react";
|
|
2
|
+
import { AvailableAIAgent, AvailableHumanAgent } from "@cossistant/types";
|
|
3
|
+
|
|
4
|
+
//#region src/support/components/avatar-stack.d.ts
|
|
5
|
+
type AvatarStackProps = {
|
|
6
|
+
humanAgents: AvailableHumanAgent[];
|
|
7
|
+
aiAgents: AvailableAIAgent[];
|
|
8
|
+
hideBranding?: boolean;
|
|
9
|
+
hideDefaultAIAgent?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
/** Size of avatars (default: 44px) */
|
|
12
|
+
size?: number;
|
|
13
|
+
/** Space between avatars (default: 28px) */
|
|
14
|
+
spacing?: number;
|
|
15
|
+
/** Gap width between avatars (default: 2px) */
|
|
16
|
+
gapWidth?: number;
|
|
17
|
+
};
|
|
18
|
+
declare const AvatarStackItem: ({
|
|
19
|
+
children,
|
|
20
|
+
index,
|
|
21
|
+
size,
|
|
22
|
+
spacing,
|
|
23
|
+
gapWidth,
|
|
24
|
+
className
|
|
25
|
+
}: {
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
index: number;
|
|
28
|
+
size?: number;
|
|
29
|
+
spacing?: number;
|
|
30
|
+
gapWidth?: number;
|
|
31
|
+
className?: string;
|
|
32
|
+
}) => react0.ReactElement<unknown, string | react0.JSXElementConstructor<any>> | null;
|
|
33
|
+
declare function AvatarStack({
|
|
34
|
+
humanAgents,
|
|
35
|
+
aiAgents,
|
|
36
|
+
hideBranding,
|
|
37
|
+
hideDefaultAIAgent,
|
|
38
|
+
className,
|
|
39
|
+
size,
|
|
40
|
+
spacing,
|
|
41
|
+
gapWidth
|
|
42
|
+
}: AvatarStackProps): react0.ReactElement<unknown, string | react0.JSXElementConstructor<any>> | null;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { AvatarStack, AvatarStackItem };
|
|
45
|
+
//# sourceMappingURL=avatar-stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar-stack.d.ts","names":[],"sources":["../../../src/support/components/avatar-stack.tsx"],"sourcesContent":[],"mappings":";;;;KAMK,gBAAA;eACS;YACH;EAFN,YAAA,CAAA,EAAA,OAAgB;EAAA,kBAAA,CAAA,EAAA,OAAA;WACP,CAAA,EAAA,MAAA;;EACa,IAAA,CAAA,EAAA,MAAA;EAYd;EA8CZ,OAAA,CAAA,EAAA,MAAA;;UA9C+B,CAAA,EAAA,MAAA;;AAAA,cAAnB,eAAmB,EAAA,CAAA;EAAA,QAAA;EAAA,KAAA;EAAA,IAAA;EAAA,OAAA;EAAA,QAAA;EAAA;AAgDhC,CAhDgC,EAAA;UAAA,EAQrB,KAAA,CAAM,SARe;OAAA,EAAA,MAAA;MAQrB,CAAA,EAAA,MAAM;SAAS,CAAA,EAMzB,MAAA;UAAA,CAAA,EAAA,MAAA;EAAA,SAAA,CAAA,EAAA,MAAA;AAkCD,CAAA,EAAA,GAlCC,MAAA,CAAA,YAkC0B,CAAA,OAAA,EAAA,MAAA,GAxCD,MAAA,CAMzB,qBAkC0B,CAAA,GAAA,CAAA,CAAA,GAAA,IAAA;AAAA,iBAAX,WAAA,CAAW;EAAA,WAAA;EAAA,QAAA;EAAA,YAAA;EAAA,kBAAA;EAAA,SAAA;EAAA,IAAA;EAAA,OAAA;EAAA;AAAA,CAAA,EASxB,gBATwB,CAAA,EASR,MAAA,CAAA,YATQ,CAAA,OAAA,EAAA,MAAA,GASR,MAAA,CAAA,qBATQ,CAAA,GAAA,CAAA,CAAA,GAAA,IAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { cn } from "../utils/index.js";
|
|
2
|
+
import { useRenderElement } from "../../utils/use-render-element.js";
|
|
3
|
+
import { Avatar } from "./avatar.js";
|
|
4
|
+
import { CossistantLogo } from "./cossistant-branding.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/support/components/avatar-stack.tsx
|
|
8
|
+
const AvatarStackItem = ({ children, index, size = 44, spacing = 28, gapWidth = 2, className }) => {
|
|
9
|
+
const isFirst = index === 0;
|
|
10
|
+
const circleRadius = size * .5;
|
|
11
|
+
const cutoutRadius = circleRadius + gapWidth;
|
|
12
|
+
const cutoutPosition = `${circleRadius - spacing}px`;
|
|
13
|
+
return useRenderElement("div", { className }, { props: {
|
|
14
|
+
className: cn("relative grid place-items-center", !isFirst && "[mask-repeat:no-repeat] [mask-size:100%_100%]"),
|
|
15
|
+
style: {
|
|
16
|
+
width: `${size}px`,
|
|
17
|
+
height: `${size}px`,
|
|
18
|
+
...isFirst ? {} : {
|
|
19
|
+
mask: `radial-gradient(${cutoutRadius}px ${cutoutRadius}px at ${cutoutPosition} 50%, transparent ${cutoutRadius}px, white ${cutoutRadius}px)`,
|
|
20
|
+
WebkitMask: `radial-gradient(${cutoutRadius}px ${cutoutRadius}px at ${cutoutPosition} 50%, transparent ${cutoutRadius}px, white ${cutoutRadius}px)`
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
children
|
|
24
|
+
} });
|
|
25
|
+
};
|
|
26
|
+
function AvatarStack({ humanAgents, aiAgents, hideBranding = false, hideDefaultAIAgent = true, className, size = 44, spacing = 28, gapWidth = 3 }) {
|
|
27
|
+
const displayedHumanAgents = humanAgents.slice(0, 2);
|
|
28
|
+
const remainingHumanAgentsCount = Math.max(0, humanAgents.length - 2);
|
|
29
|
+
const items = [
|
|
30
|
+
...displayedHumanAgents.map((agent) => ({
|
|
31
|
+
type: "human",
|
|
32
|
+
agent
|
|
33
|
+
})),
|
|
34
|
+
...remainingHumanAgentsCount > 0 ? [{
|
|
35
|
+
type: "count",
|
|
36
|
+
count: remainingHumanAgentsCount
|
|
37
|
+
}] : [],
|
|
38
|
+
...hideDefaultAIAgent ? [] : [{
|
|
39
|
+
type: "ai",
|
|
40
|
+
agent: aiAgents[0]
|
|
41
|
+
}]
|
|
42
|
+
];
|
|
43
|
+
return useRenderElement("div", { className }, { props: {
|
|
44
|
+
className: "inline-grid items-center",
|
|
45
|
+
style: { gridTemplateColumns: `repeat(${items.length}, ${spacing}px)` },
|
|
46
|
+
children: items.map((item, index) => /* @__PURE__ */ jsxs(AvatarStackItem, {
|
|
47
|
+
gapWidth,
|
|
48
|
+
index,
|
|
49
|
+
size,
|
|
50
|
+
spacing,
|
|
51
|
+
children: [
|
|
52
|
+
item.type === "human" && /* @__PURE__ */ jsx(Avatar, {
|
|
53
|
+
className: cn("size-full"),
|
|
54
|
+
image: item.agent.image,
|
|
55
|
+
name: item.agent.name
|
|
56
|
+
}),
|
|
57
|
+
item.type === "count" && /* @__PURE__ */ jsxs("div", {
|
|
58
|
+
className: "flex size-full items-center justify-center rounded-full bg-co-background-200 font-medium text-co-text-900 text-sm dark:bg-co-background-500",
|
|
59
|
+
children: ["+", item.count]
|
|
60
|
+
}),
|
|
61
|
+
item.type === "ai" && /* @__PURE__ */ jsx("div", {
|
|
62
|
+
className: "flex size-full items-center justify-center rounded-full bg-co-background-200 dark:bg-co-background-600",
|
|
63
|
+
children: /* @__PURE__ */ jsx(CossistantLogo, { className: "h-[50%] min-h-4 w-[50%] min-w-4" })
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
}, `avatar-${index}`))
|
|
67
|
+
} });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { AvatarStack, AvatarStackItem };
|
|
72
|
+
//# sourceMappingURL=avatar-stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar-stack.js","names":[],"sources":["../../../src/support/components/avatar-stack.tsx"],"sourcesContent":["import type { AvailableAIAgent, AvailableHumanAgent } from \"@cossistant/types\";\nimport { useRenderElement } from \"../../utils/use-render-element\";\nimport { cn } from \"../utils\";\nimport { Avatar } from \"./avatar\";\nimport { CossistantLogo } from \"./cossistant-branding\";\n\ntype AvatarStackProps = {\n\thumanAgents: AvailableHumanAgent[];\n\taiAgents: AvailableAIAgent[];\n\thideBranding?: boolean;\n\thideDefaultAIAgent?: boolean;\n\tclassName?: string;\n\t/** Size of avatars (default: 44px) */\n\tsize?: number;\n\t/** Space between avatars (default: 28px) */\n\tspacing?: number;\n\t/** Gap width between avatars (default: 2px) */\n\tgapWidth?: number;\n};\n\nexport const AvatarStackItem = ({\n\tchildren,\n\tindex,\n\tsize = 44,\n\tspacing = 28,\n\tgapWidth = 2,\n\tclassName,\n}: {\n\tchildren: React.ReactNode;\n\tindex: number;\n\tsize?: number;\n\tspacing?: number;\n\tgapWidth?: number;\n\tclassName?: string;\n}) => {\n\tconst isFirst = index === 0;\n\n\t// Calculate the circle radius for the mask cutout\n\tconst circleRadius = size * 0.5;\n\tconst cutoutRadius = circleRadius + gapWidth; // Add gap width to create visible border\n\tconst cutoutPosition = `${circleRadius - spacing}px`;\n\n\treturn useRenderElement(\n\t\t\"div\",\n\t\t{ className },\n\t\t{\n\t\t\tprops: {\n\t\t\t\tclassName: cn(\n\t\t\t\t\t\"relative grid place-items-center\",\n\t\t\t\t\t!isFirst && \"[mask-repeat:no-repeat] [mask-size:100%_100%]\"\n\t\t\t\t),\n\t\t\t\tstyle: {\n\t\t\t\t\twidth: `${size}px`,\n\t\t\t\t\theight: `${size}px`,\n\t\t\t\t\t// Apply mask only to non-first items\n\t\t\t\t\t...(isFirst\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tmask: `radial-gradient(${cutoutRadius}px ${cutoutRadius}px at ${cutoutPosition} 50%, transparent ${cutoutRadius}px, white ${cutoutRadius}px)`,\n\t\t\t\t\t\t\t\tWebkitMask: `radial-gradient(${cutoutRadius}px ${cutoutRadius}px at ${cutoutPosition} 50%, transparent ${cutoutRadius}px, white ${cutoutRadius}px)`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\tchildren,\n\t\t\t},\n\t\t}\n\t);\n};\n\nexport function AvatarStack({\n\thumanAgents,\n\taiAgents,\n\thideBranding = false,\n\thideDefaultAIAgent = true,\n\tclassName,\n\tsize = 44,\n\tspacing = 28,\n\tgapWidth = 3,\n}: AvatarStackProps) {\n\tconst displayedHumanAgents = humanAgents.slice(0, 2);\n\tconst remainingHumanAgentsCount = Math.max(0, humanAgents.length - 2);\n\n\t// Create array of all items to display\n\tconst items = [\n\t\t...displayedHumanAgents.map((agent) => ({\n\t\t\ttype: \"human\" as const,\n\t\t\tagent,\n\t\t})),\n\t\t...(remainingHumanAgentsCount > 0\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"count\" as const,\n\t\t\t\t\t\tcount: remainingHumanAgentsCount,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: []),\n\t\t...(hideDefaultAIAgent\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"ai\" as const,\n\t\t\t\t\t\tagent: aiAgents[0],\n\t\t\t\t\t},\n\t\t\t\t]),\n\t];\n\n\treturn useRenderElement(\n\t\t\"div\",\n\t\t{ className },\n\t\t{\n\t\t\tprops: {\n\t\t\t\tclassName: \"inline-grid items-center\",\n\t\t\t\tstyle: {\n\t\t\t\t\tgridTemplateColumns: `repeat(${items.length}, ${spacing}px)`,\n\t\t\t\t},\n\t\t\t\tchildren: items.map((item, index) => (\n\t\t\t\t\t<AvatarStackItem\n\t\t\t\t\t\tgapWidth={gapWidth}\n\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\tkey={`avatar-${index}`}\n\t\t\t\t\t\tsize={size}\n\t\t\t\t\t\tspacing={spacing}\n\t\t\t\t\t>\n\t\t\t\t\t\t{item.type === \"human\" && (\n\t\t\t\t\t\t\t<Avatar\n\t\t\t\t\t\t\t\tclassName={cn(\"size-full\")}\n\t\t\t\t\t\t\t\timage={item.agent.image}\n\t\t\t\t\t\t\t\tname={item.agent.name}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{item.type === \"count\" && (\n\t\t\t\t\t\t\t<div className=\"flex size-full items-center justify-center rounded-full bg-co-background-200 font-medium text-co-text-900 text-sm dark:bg-co-background-500\">\n\t\t\t\t\t\t\t\t+{item.count}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{item.type === \"ai\" && (\n\t\t\t\t\t\t\t<div className=\"flex size-full items-center justify-center rounded-full bg-co-background-200 dark:bg-co-background-600\">\n\t\t\t\t\t\t\t\t<CossistantLogo className=\"h-[50%] min-h-4 w-[50%] min-w-4\" />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</AvatarStackItem>\n\t\t\t\t)),\n\t\t\t},\n\t\t}\n\t);\n}\n"],"mappings":";;;;;;;AAoBA,MAAa,mBAAmB,EAC/B,UACA,OACA,OAAO,IACP,UAAU,IACV,WAAW,GACX,gBAQK;CACL,MAAM,UAAU,UAAU;CAG1B,MAAM,eAAe,OAAO;CAC5B,MAAM,eAAe,eAAe;CACpC,MAAM,iBAAiB,GAAG,eAAe,QAAQ;AAEjD,QAAO,iBACN,OACA,EAAE,WAAW,EACb,EACC,OAAO;EACN,WAAW,GACV,oCACA,CAAC,WAAW,gDACZ;EACD,OAAO;GACN,OAAO,GAAG,KAAK;GACf,QAAQ,GAAG,KAAK;GAEhB,GAAI,UACD,EAAE,GACF;IACA,MAAM,mBAAmB,aAAa,KAAK,aAAa,QAAQ,eAAe,oBAAoB,aAAa,YAAY,aAAa;IACzI,YAAY,mBAAmB,aAAa,KAAK,aAAa,QAAQ,eAAe,oBAAoB,aAAa,YAAY,aAAa;IAC/I;GACH;EACD;EACA,EACD,CACD;;AAGF,SAAgB,YAAY,EAC3B,aACA,UACA,eAAe,OACf,qBAAqB,MACrB,WACA,OAAO,IACP,UAAU,IACV,WAAW,KACS;CACpB,MAAM,uBAAuB,YAAY,MAAM,GAAG,EAAE;CACpD,MAAM,4BAA4B,KAAK,IAAI,GAAG,YAAY,SAAS,EAAE;CAGrE,MAAM,QAAQ;EACb,GAAG,qBAAqB,KAAK,WAAW;GACvC,MAAM;GACN;GACA,EAAE;EACH,GAAI,4BAA4B,IAC7B,CACA;GACC,MAAM;GACN,OAAO;GACP,CACD,GACA,EAAE;EACL,GAAI,qBACD,EAAE,GACF,CACA;GACC,MAAM;GACN,OAAO,SAAS;GAChB,CACD;EACH;AAED,QAAO,iBACN,OACA,EAAE,WAAW,EACb,EACC,OAAO;EACN,WAAW;EACX,OAAO,EACN,qBAAqB,UAAU,MAAM,OAAO,IAAI,QAAQ,MACxD;EACD,UAAU,MAAM,KAAK,MAAM,UAC1B,qBAAC;GACU;GACH;GAED;GACG;;IAER,KAAK,SAAS,WACd,oBAAC;KACA,WAAW,GAAG,YAAY;KAC1B,OAAO,KAAK,MAAM;KAClB,MAAM,KAAK,MAAM;MAChB;IAEF,KAAK,SAAS,WACd,qBAAC;KAAI,WAAU;gBAA8I,KAC1J,KAAK;MACF;IAEN,KAAK,SAAS,QACd,oBAAC;KAAI,WAAU;eACd,oBAAC,kBAAe,WAAU,oCAAoC;MACzD;;KAnBF,UAAU,QAqBE,CACjB;EACF,EACD,CACD"}
|