@ensembleapp/client-sdk 0.0.13 → 0.0.15
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/dist/index.d.ts +50 -45
- package/dist/index.js +116 -73
- package/dist/index.js.map +1 -1
- package/dist/widget/widget.global.js +32 -32
- package/dist/widget/widget.global.js.map +1 -1
- package/lib/components/ChatWidget.css +5 -0
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,42 +5,43 @@ import React$1, { ReactNode } from 'react';
|
|
|
5
5
|
import z, { AnyZodObject } from 'zod';
|
|
6
6
|
import { ClassValue } from 'clsx';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Version selector for tools. This should mirror VersionSelector on server-side
|
|
10
|
-
* - 'latest': prefer draft (v0), fallback to last published
|
|
11
|
-
* - 'published': prefer last published, fallback to draft
|
|
12
|
-
* - number: specific version (1+)
|
|
13
|
-
*/
|
|
8
|
+
/** @minimum 1 */
|
|
14
9
|
type VersionSelector = 'latest' | 'published' | number;
|
|
15
10
|
/**
|
|
16
|
-
*
|
|
17
|
-
* Uses JEXL expressions to build tool inputs from the widget payload.
|
|
11
|
+
* fetch data via tool call.
|
|
18
12
|
*/
|
|
19
|
-
type
|
|
20
|
-
/** Tool ID to call for enrichment */
|
|
13
|
+
type ToolCallConfig = {
|
|
21
14
|
toolId: string;
|
|
22
15
|
/**
|
|
23
|
-
*
|
|
24
|
-
* - 'latest':
|
|
25
|
-
* - 'published':
|
|
26
|
-
* - number: specific version (1+)
|
|
16
|
+
* Select the tool version (default to 'latest' if not provided).
|
|
17
|
+
* - 'latest': pick draft if exists, fallback to latest published version
|
|
18
|
+
* - 'published': pick latest published version, fallback to draft version
|
|
19
|
+
* - number: specific tool version (1+)
|
|
27
20
|
*/
|
|
28
21
|
version?: VersionSelector;
|
|
29
22
|
/**
|
|
30
|
-
*
|
|
31
|
-
* Expressions are evaluated with $ as the payload root (auto-normalized).
|
|
32
|
-
* Use ${...} syntax for JEXL expressions, or literal values.
|
|
33
|
-
*
|
|
34
|
-
* Examples:
|
|
35
|
-
* - "${vendors|map('id')|join(',')}" → "v1,v2,v3"
|
|
36
|
-
* - "${limit}" → 10
|
|
37
|
-
* - "static value" → "static value"
|
|
38
|
-
*
|
|
39
|
-
* If omitted, the entire payload is passed as tool input.
|
|
23
|
+
* Tool input can be literal or templated string with expressions
|
|
40
24
|
*/
|
|
41
25
|
inputs?: Record<string, unknown>;
|
|
42
26
|
};
|
|
43
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Widget enrichment configuration.
|
|
29
|
+
* Keys are used to access the enrichment results in the render function.
|
|
30
|
+
*
|
|
31
|
+
* Example:
|
|
32
|
+
* ```typescript
|
|
33
|
+
* enrich: {
|
|
34
|
+
* vendorDetails: { toolId: 'vendor-tool', inputs: { ids: "${vendors}" } },
|
|
35
|
+
* pricing: { toolId: 'pricing-tool', inputs: { ids: "${vendors}" } },
|
|
36
|
+
* },
|
|
37
|
+
* render: (payload, enriched) => {
|
|
38
|
+
* const vendors = enriched?.vendorDetails?.data;
|
|
39
|
+
* const pricing = enriched?.pricing?.data;
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
type WidgetEnrichConfig = Record<string, ToolCallConfig>;
|
|
44
|
+
/** Enrichment result containing the full tool response. This should mirror ToolResult on server-side. */
|
|
44
45
|
type EnrichmentResult$1 = {
|
|
45
46
|
success: boolean;
|
|
46
47
|
error?: {
|
|
@@ -55,8 +56,8 @@ type UIWidget = {
|
|
|
55
56
|
widgetType: string;
|
|
56
57
|
/** LLM-generated data based on the widget schema specified by the client */
|
|
57
58
|
payload: unknown;
|
|
58
|
-
/** Server-injected enrichment
|
|
59
|
-
|
|
59
|
+
/** Server-injected enrichment results from tool calls, keyed by enrichment name */
|
|
60
|
+
enriched?: Record<string, EnrichmentResult$1>;
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
type DeprecatedChatConfig = {
|
|
@@ -175,8 +176,7 @@ declare function useFeedback({ api, threadId, agentId, agentExecutionId, }: UseF
|
|
|
175
176
|
error: Error | null;
|
|
176
177
|
};
|
|
177
178
|
|
|
178
|
-
/** Enrichment result containing the full tool response - this should mirror ToolResult
|
|
179
|
-
* OR maybe we should declare ToolResult here? */
|
|
179
|
+
/** Enrichment result containing the full tool response - this should mirror ToolResult */
|
|
180
180
|
interface EnrichmentResult<TData = unknown> {
|
|
181
181
|
success: boolean;
|
|
182
182
|
error?: {
|
|
@@ -186,27 +186,32 @@ interface EnrichmentResult<TData = unknown> {
|
|
|
186
186
|
data?: TData;
|
|
187
187
|
metadata?: Record<string, unknown>;
|
|
188
188
|
}
|
|
189
|
-
/**
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
*/
|
|
193
|
-
interface WidgetRenderProps<TPayload, TEnrichedData = unknown> {
|
|
194
|
-
/** The validated widget payload matching the schema */
|
|
195
|
-
payload: TPayload;
|
|
196
|
-
/** Server-injected enrichment result (only present if widget has enrich config) */
|
|
197
|
-
enrichedResult?: EnrichmentResult<TEnrichedData>;
|
|
198
|
-
}
|
|
199
|
-
interface UIWidgetDefinition<TSchema extends AnyZodObject = AnyZodObject, TEnrichedData = unknown> {
|
|
189
|
+
/** Enriched results keyed by enrichment name */
|
|
190
|
+
type EnrichedResults<T = unknown> = Record<string, EnrichmentResult<T>>;
|
|
191
|
+
interface UIWidgetDefinition<TSchema extends AnyZodObject = AnyZodObject, TEnriched extends EnrichedResults = EnrichedResults> {
|
|
200
192
|
widgetType: string;
|
|
201
193
|
schema: TSchema;
|
|
202
194
|
/**
|
|
203
|
-
* Optional enrichment config - if provided, server will call
|
|
204
|
-
*
|
|
195
|
+
* Optional enrichment config - if provided, server will call the tools to enrich the data.
|
|
196
|
+
* Keys are used to access results in the render function.
|
|
197
|
+
*
|
|
198
|
+
* Example:
|
|
199
|
+
* ```typescript
|
|
200
|
+
* enrich: {
|
|
201
|
+
* vendorDetails: { toolId: 'vendor-tool', inputs: { ids: "${vendors}" } },
|
|
202
|
+
* pricing: { toolId: 'pricing-tool', inputs: { ids: "${vendors}" } },
|
|
203
|
+
* }
|
|
204
|
+
* ```
|
|
205
205
|
*/
|
|
206
206
|
enrich?: WidgetEnrichConfig;
|
|
207
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Render function that receives the payload and enriched results.
|
|
209
|
+
* @param payload - The LLM-generated data matching the schema
|
|
210
|
+
* @param enriched - Enrichment results keyed by name (empty object if no enrich config)
|
|
211
|
+
*/
|
|
212
|
+
render(payload: z.infer<TSchema>, enriched: TEnriched): ReactNode;
|
|
208
213
|
}
|
|
209
|
-
declare const createWidget: <TSchema extends AnyZodObject,
|
|
214
|
+
declare const createWidget: <TSchema extends AnyZodObject, TEnriched extends EnrichedResults = EnrichedResults>({ widgetType, schema, enrich, render, }: UIWidgetDefinition<TSchema, TEnriched>) => UIWidgetDefinition<TSchema, TEnriched>;
|
|
210
215
|
|
|
211
216
|
interface ChatWidgetStyles {
|
|
212
217
|
primaryColor?: string;
|
|
@@ -353,4 +358,4 @@ declare const defaultChatWidgets: UIWidgetDefinition[];
|
|
|
353
358
|
|
|
354
359
|
declare function cn(...inputs: ClassValue[]): string;
|
|
355
360
|
|
|
356
|
-
export { type ApiConfig, type ChatContentItem, type ChatMessage, ChatWidget, type ChatWidgetFeedbackOptions, type ChatWidgetInstance, type ChatWidgetConfig as ChatWidgetProps, type ChatWidgetSpeechToTextOptions, type ChatWidgetStyles, type ChatWidgetVoiceOptions, type EmbeddableChatWidgetConfig, type EnrichmentResult, type FeedbackRating, type FeedbackState, type MessageFeedback, type MessageSection, type PopupAnchorConfig, PopupChatWidget, type PopupChatWidgetProps, type SubmitFeedbackParams, type TagGroup, TagGroupDisplay, type TagGroupDisplayProps, type ToolCallContent, ToolCallDisplay, type ToolCallDisplayProps, type UIWidgetDefinition, type UseChatConfig, type UseFeedbackConfig, type WidgetEnrichConfig,
|
|
361
|
+
export { type ApiConfig, type ChatContentItem, type ChatMessage, ChatWidget, type ChatWidgetFeedbackOptions, type ChatWidgetInstance, type ChatWidgetConfig as ChatWidgetProps, type ChatWidgetSpeechToTextOptions, type ChatWidgetStyles, type ChatWidgetVoiceOptions, type EmbeddableChatWidgetConfig, type EnrichedResults, type EnrichmentResult, type FeedbackRating, type FeedbackState, type MessageFeedback, type MessageSection, type PopupAnchorConfig, PopupChatWidget, type PopupChatWidgetProps, type SubmitFeedbackParams, type TagGroup, TagGroupDisplay, type TagGroupDisplayProps, type ToolCallContent, ToolCallDisplay, type ToolCallDisplayProps, type UIWidgetDefinition, type UseChatConfig, type UseFeedbackConfig, type WidgetEnrichConfig, cn, createChatWidget, createWidget, defaultChatWidgets, registerChatWidgets, useChat, useFeedback };
|
package/dist/index.js
CHANGED
|
@@ -18627,7 +18627,7 @@ var DefaultChatTransport = class extends HttpChatTransport {
|
|
|
18627
18627
|
};
|
|
18628
18628
|
|
|
18629
18629
|
// lib/hooks/useChat.ts
|
|
18630
|
-
import { useEffect, useState } from "react";
|
|
18630
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
18631
18631
|
function useChat({
|
|
18632
18632
|
api,
|
|
18633
18633
|
threadId,
|
|
@@ -18641,6 +18641,29 @@ function useChat({
|
|
|
18641
18641
|
onMessage
|
|
18642
18642
|
}) {
|
|
18643
18643
|
const { baseUrl, token, headers: customHeaders = {} } = api;
|
|
18644
|
+
const dataContextRef = useRef(dataContext);
|
|
18645
|
+
dataContextRef.current = dataContext;
|
|
18646
|
+
const transport = useMemo(() => new DefaultChatTransport({
|
|
18647
|
+
api: `${baseUrl}/chat`,
|
|
18648
|
+
headers: {
|
|
18649
|
+
"Content-Type": "application/json",
|
|
18650
|
+
Authorization: `Bearer ${token}`,
|
|
18651
|
+
"thread-id": threadId,
|
|
18652
|
+
...agentId ? { "agent-id": agentId } : {},
|
|
18653
|
+
...agentExecutionId ? { "agent-execution-id": agentExecutionId } : {},
|
|
18654
|
+
...customHeaders
|
|
18655
|
+
},
|
|
18656
|
+
// only send last message to server
|
|
18657
|
+
prepareSendMessagesRequest({ messages: messages2, id }) {
|
|
18658
|
+
return {
|
|
18659
|
+
body: {
|
|
18660
|
+
id,
|
|
18661
|
+
message: messages2[messages2.length - 1],
|
|
18662
|
+
dataContext: dataContextRef.current
|
|
18663
|
+
}
|
|
18664
|
+
};
|
|
18665
|
+
}
|
|
18666
|
+
}), [baseUrl, token, threadId, agentId, agentExecutionId, customHeaders]);
|
|
18644
18667
|
const {
|
|
18645
18668
|
messages,
|
|
18646
18669
|
status,
|
|
@@ -18649,27 +18672,7 @@ function useChat({
|
|
|
18649
18672
|
setMessages
|
|
18650
18673
|
} = useAIChat({
|
|
18651
18674
|
id: threadId,
|
|
18652
|
-
transport
|
|
18653
|
-
api: `${baseUrl}/chat`,
|
|
18654
|
-
headers: {
|
|
18655
|
-
"Content-Type": "application/json",
|
|
18656
|
-
Authorization: `Bearer ${token}`,
|
|
18657
|
-
"thread-id": threadId,
|
|
18658
|
-
...agentId ? { "agent-id": agentId } : {},
|
|
18659
|
-
...agentExecutionId ? { "agent-execution-id": agentExecutionId } : {},
|
|
18660
|
-
...customHeaders
|
|
18661
|
-
},
|
|
18662
|
-
// only send last message to server
|
|
18663
|
-
prepareSendMessagesRequest({ messages: messages2, id }) {
|
|
18664
|
-
return {
|
|
18665
|
-
body: {
|
|
18666
|
-
id,
|
|
18667
|
-
message: messages2[messages2.length - 1],
|
|
18668
|
-
dataContext
|
|
18669
|
-
}
|
|
18670
|
-
};
|
|
18671
|
-
}
|
|
18672
|
-
}),
|
|
18675
|
+
transport,
|
|
18673
18676
|
onError: (error40) => {
|
|
18674
18677
|
console.error("Chat error:", error40);
|
|
18675
18678
|
onError?.(error40);
|
|
@@ -18909,11 +18912,11 @@ function styleInject(css, { insertAt } = {}) {
|
|
|
18909
18912
|
}
|
|
18910
18913
|
|
|
18911
18914
|
// lib/components/ChatWidget.css
|
|
18912
|
-
styleInject(':root[data-chat-widget],\n[data-chat-widget] {\n --chat-primary: #3b82f6;\n --chat-primary-text: #ffffff;\n --chat-primary-hover: #2563eb;\n --chat-background: #ffffff;\n --chat-border: #e5e7eb;\n --chat-header-text: #ffffff;\n --chat-user-text: #ffffff;\n --chat-assistant-bg: transparent;\n --chat-assistant-text: #111827;\n --chat-font-family:\n "Inter",\n system-ui,\n -apple-system,\n BlinkMacSystemFont,\n sans-serif;\n --chat-radius: 0.75rem;\n --chat-input-bg: #ffffff;\n --chat-input-text: #111827;\n --chat-input-placeholder: #6b7280;\n --chat-thought-border: #d1d5db;\n --chat-font-size: 0.925rem;\n --chat-thought-font-size: 0.75rem;\n}\n.chat-widget {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n min-height: 24rem;\n background: var(--chat-background);\n border: 1px solid var(--chat-border);\n border-radius: var(--chat-radius);\n box-shadow: 0 20px 45px rgba(15, 23, 42, 0.12);\n overflow: hidden;\n font-family: var(--chat-font-family);\n color: var(--chat-assistant-text);\n}\n.chat-widget__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 40px;\n padding: 0.75rem 1rem;\n background: var(--chat-primary);\n color: var(--chat-header-text);\n}\n.chat-widget__title {\n margin: 0;\n font-size: 0.875rem;\n font-weight: 600;\n}\n.chat-widget__messages {\n flex: 1;\n overflow-y: auto;\n padding: 1rem;\n display: flex;\n flex-direction: column;\n gap: 1rem;\n}\n.chat-widget__message {\n display: flex;\n flex-direction: column;\n gap: 0;\n}\n.chat-widget__message-row {\n display: flex;\n}\n.chat-widget__message-row--user {\n justify-content: flex-end;\n}\n.chat-widget__message-row--assistant {\n justify-content: flex-start;\n}\n.chat-widget__bubble {\n max-width: 90%;\n padding: 0.5rem 0.25rem;\n border-radius: calc(var(--chat-radius) * 0.65);\n font-size: var(--chat-font-size);\n}\n.chat-widget__bubble--user {\n background: var(--chat-primary);\n color: var(--chat-user-text);\n border-bottom-right-radius: 0.35rem;\n}\n.chat-widget__bubble--assistant {\n background: var(--chat-assistant-bg);\n color: var(--chat-assistant-text);\n border-bottom-left-radius: 0.35rem;\n}\n.chat-widget__markdown {\n white-space: normal;\n font-size: var(--chat-font-size);\n}\n.chat-widget__markdown h1 {\n font-size: calc(var(--chat-font-size) * 1.4);\n}\n.chat-widget__markdown h2 {\n font-size: calc(var(--chat-font-size) * 1.25);\n}\n.chat-widget__markdown h3 {\n font-size: calc(var(--chat-font-size) * 1.1);\n}\n.chat-widget__markdown h4 {\n font-size: calc(var(--chat-font-size) * 1.05);\n}\n.chat-widget__markdown h5 {\n font-size: calc(var(--chat-font-size) * 1);\n}\n.chat-widget__markdown h6 {\n font-size: calc(var(--chat-font-size) * 0.95);\n}\n.chat-widget__anchor-button {\n position: fixed;\n bottom: 20px;\n right: 20px;\n display: inline-flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.65rem 0.85rem;\n background: var(--chat-primary);\n color: var(--chat-primary-text);\n border: none;\n border-radius: 999px;\n box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);\n cursor: pointer;\n font-weight: 600;\n z-index: 99999;\n}\n.chat-widget__anchor-button:hover {\n background: var(--chat-primary-hover);\n}\n.chat-widget__anchor--left {\n right: auto;\n left: 20px;\n}\n.chat-widget__anchor-icon {\n width: 1.1rem;\n height: 1.1rem;\n}\n.chat-widget__popup {\n position: fixed;\n bottom: 80px;\n right: 20px;\n z-index: 99998;\n}\n.chat-widget__anchor--left.chat-widget__popup {\n right: auto;\n left: 20px;\n}\n.chat-widget__popup-inner {\n width: 384px;\n max-width: calc(100vw - 40px);\n height: 500px;\n max-height: calc(100vh - 140px);\n box-shadow: 0 20px 45px rgba(15, 23, 42, 0.12);\n border-radius: 12px;\n overflow: hidden;\n}\n.chat-widget__markdown table {\n width: 100%;\n border-collapse: collapse;\n margin: 0.5rem 0;\n}\n.chat-widget__markdown th,\n.chat-widget__markdown td {\n border: 1px solid var(--chat-border);\n padding: 0.5rem;\n text-align: left;\n vertical-align: top;\n}\n.chat-widget__markdown thead th {\n background: var(--chat-assistant-bg);\n color: var(--chat-assistant-text);\n font-weight: 600;\n}\n.chat-widget__thoughts {\n min-width: 0;\n --chat-font-size: var(--chat-thought-font-size);\n}\n.chat-widget__details {\n border: 0;\n}\n.chat-widget__thoughts-summary {\n list-style: none;\n display: flex;\n align-items: center;\n gap: 0.35rem;\n cursor: pointer;\n color: #6b7280;\n font-size: 0.8125rem;\n}\n.chat-widget__thoughts-summary:hover {\n color: var(--chat-assistant-text);\n}\n.chat-widget__thoughts-icon-container {\n display: flex;\n border: 1px solid #d1d5db;\n border-radius: 999px;\n align-items: center;\n justify-content: center;\n width: 1rem;\n height: 1rem;\n}\n.chat-widget__thoughts-icon {\n width: 0.75rem;\n height: 0.75rem;\n transition: transform 0.2s ease;\n}\n.chat-widget__details[open] .chat-widget__thoughts-icon {\n transform: rotate(90deg);\n}\n.chat-widget__thoughts-content {\n margin-top: 0.5rem;\n margin-left: 0.4rem;\n padding: 0.75rem;\n border-left: 2px solid var(--chat-thought-border);\n border-color: var(--chat-primary);\n max-width: 100%;\n overflow-x: auto;\n}\n.chat-widget__thoughts-text {\n margin: 0;\n line-height: 1.5;\n color: #4b5563;\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n "Liberation Mono",\n "Courier New",\n monospace;\n white-space: pre-wrap;\n word-break: break-word;\n overflow-wrap: anywhere;\n display: block;\n}\n.chat-widget__loading {\n display: flex;\n justify-content: flex-start;\n}\n.chat-widget__loading-bubble {\n background: var(--chat-assistant-bg);\n color: var(--chat-assistant-text);\n border-radius: calc(var(--chat-radius) * 0.65);\n border-bottom-left-radius: 0.35rem;\n padding: 0.5rem 0.75rem;\n}\n.chat-widget__loading-dots {\n display: flex;\n gap: 0.35rem;\n}\n.chat-widget__loading-dot {\n width: 0.5rem;\n height: 0.5rem;\n border-radius: 999px;\n background: #9ca3af;\n animation: chat-widget-bounce 1s infinite ease-in-out;\n}\n.chat-widget__loading-dot[data-delay="1"] {\n animation-delay: 0.1s;\n}\n.chat-widget__loading-dot[data-delay="2"] {\n animation-delay: 0.2s;\n}\n@keyframes chat-widget-bounce {\n 0%, 80%, 100% {\n transform: scale(0.6);\n opacity: 0.4;\n }\n 40% {\n transform: scale(1);\n opacity: 1;\n }\n}\n.chat-widget__input {\n border-top: 1px solid var(--chat-border);\n padding: 0.25rem 0 0.75rem;\n background: var(--chat-input-bg);\n}\n.chat-widget__form {\n position: relative;\n}\n.chat-widget__textarea {\n width: 100%;\n border: 0;\n padding: 0.75rem 5.25rem 0.75rem 0.75rem;\n background: transparent;\n font-size: 0.925rem;\n resize: none;\n color: var(--chat-input-text);\n font-family: inherit;\n}\n.chat-widget__textarea::-moz-placeholder {\n color: var(--chat-input-placeholder);\n}\n.chat-widget__textarea::placeholder {\n color: var(--chat-input-placeholder);\n}\n.chat-widget__textarea:focus-visible {\n outline: none;\n}\n.chat-widget__textarea:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.chat-widget__toolbar {\n position: absolute;\n top: 0;\n right: 3.75rem;\n height: 100%;\n display: flex;\n align-items: center;\n padding: 0 0.5rem;\n border-right: 1px solid var(--chat-border);\n}\n.chat-widget__submit {\n position: absolute;\n top: 50%;\n right: 0.75rem;\n transform: translateY(-50%);\n background: transparent;\n border: 0;\n width: 2.5rem;\n height: 2.5rem;\n display: grid;\n place-items: center;\n color: var(--chat-primary);\n cursor: pointer;\n}\n.chat-widget__submit:disabled {\n color: #9ca3af;\n cursor: not-allowed;\n}\n.chat-widget__submit:not(:disabled):hover {\n color: var(--chat-primary-hover);\n}\n.chat-widget__send-icon {\n width: 1.2rem;\n height: 1.2rem;\n}\n.chat-widget__mic-button {\n position: relative;\n border: none;\n background: transparent;\n width: 2.25rem;\n height: 2.25rem;\n display: grid;\n place-items: center;\n color: var(--chat-primary);\n cursor: pointer;\n border-radius: 999px;\n}\n.chat-widget__mic-button:disabled {\n color: #9ca3af;\n cursor: not-allowed;\n}\n.chat-widget__mic-button--active {\n color: var(--chat-primary-hover);\n background: rgba(59, 130, 246, 0.08);\n}\n.chat-widget__mic-icon {\n width: 1rem;\n height: 1rem;\n}\n.chat-widget__mic-bar {\n position: absolute;\n bottom: 0.1rem;\n left: 50%;\n width: 16px;\n height: 2px;\n border-radius: 999px;\n background: rgba(148, 163, 184, 0.4);\n overflow: hidden;\n display: block;\n transform: translateX(-50%);\n pointer-events: none;\n}\n.chat-widget__mic-bar-fill {\n display: block;\n width: 100%;\n height: 100%;\n background: currentColor;\n transform-origin: left;\n transition: transform 0.12s linear;\n}\n.chat-widget__voice {\n display: flex;\n margin-top: 0.25rem;\n}\n.chat-widget__voice-button {\n border: none;\n background: none;\n display: inline-flex;\n align-items: center;\n gap: 0.35rem;\n padding: 0.1rem 0;\n font-size: 0.8rem;\n font-weight: 500;\n color: var(--chat-primary);\n cursor: pointer;\n}\n.chat-widget__voice-button:disabled {\n color: #9ca3af;\n cursor: not-allowed;\n}\n.chat-widget__voice-button--active {\n color: var(--chat-primary-hover);\n}\n.chat-widget__voice-icon {\n width: 0.95rem;\n height: 0.95rem;\n}\n.chat-widget__voice-icon--spin {\n animation: chat-widget-spin 1s linear infinite;\n}\n@keyframes chat-widget-spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n');
|
|
18915
|
+
styleInject(':root[data-chat-widget],\n[data-chat-widget] {\n --chat-primary: #3b82f6;\n --chat-primary-text: #ffffff;\n --chat-primary-hover: #2563eb;\n --chat-background: #ffffff;\n --chat-border: #e5e7eb;\n --chat-header-text: #ffffff;\n --chat-user-text: #ffffff;\n --chat-assistant-bg: transparent;\n --chat-assistant-text: #111827;\n --chat-font-family:\n "Inter",\n system-ui,\n -apple-system,\n BlinkMacSystemFont,\n sans-serif;\n --chat-radius: 0.75rem;\n --chat-input-bg: #ffffff;\n --chat-input-text: #111827;\n --chat-input-placeholder: #6b7280;\n --chat-thought-border: #d1d5db;\n --chat-font-size: 0.925rem;\n --chat-thought-font-size: 0.75rem;\n}\n.chat-widget {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n min-height: 24rem;\n background: var(--chat-background);\n border: 1px solid var(--chat-border);\n border-radius: var(--chat-radius);\n box-shadow: 0 20px 45px rgba(15, 23, 42, 0.12);\n overflow: hidden;\n font-family: var(--chat-font-family);\n color: var(--chat-assistant-text);\n}\n.chat-widget__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 40px;\n padding: 0.75rem 1rem;\n background: var(--chat-primary);\n color: var(--chat-header-text);\n}\n.chat-widget__title {\n margin: 0;\n font-size: 0.875rem;\n font-weight: 600;\n}\n.chat-widget__messages {\n flex: 1;\n overflow-y: auto;\n padding: 1rem;\n display: flex;\n flex-direction: column;\n gap: 1rem;\n}\n.chat-widget__message {\n display: flex;\n flex-direction: column;\n gap: 0;\n}\n.chat-widget__message-row {\n display: flex;\n}\n.chat-widget__message-row--user {\n justify-content: flex-end;\n}\n.chat-widget__message-row--assistant {\n justify-content: flex-start;\n}\n.chat-widget__bubble {\n max-width: 90%;\n padding: 0.5rem 0.25rem;\n border-radius: calc(var(--chat-radius) * 0.65);\n font-size: var(--chat-font-size);\n}\n.chat-widget__bubble--user {\n background: var(--chat-primary);\n color: var(--chat-user-text);\n border-bottom-right-radius: 0.35rem;\n}\n.chat-widget__bubble--assistant {\n width: 90%;\n background: var(--chat-assistant-bg);\n color: var(--chat-assistant-text);\n border-bottom-left-radius: 0.35rem;\n}\n.chat-widget__widget {\n width: 100%;\n}\n.chat-widget__markdown {\n white-space: normal;\n font-size: var(--chat-font-size);\n}\n.chat-widget__markdown h1 {\n font-size: calc(var(--chat-font-size) * 1.4);\n}\n.chat-widget__markdown h2 {\n font-size: calc(var(--chat-font-size) * 1.25);\n}\n.chat-widget__markdown h3 {\n font-size: calc(var(--chat-font-size) * 1.1);\n}\n.chat-widget__markdown h4 {\n font-size: calc(var(--chat-font-size) * 1.05);\n}\n.chat-widget__markdown h5 {\n font-size: calc(var(--chat-font-size) * 1);\n}\n.chat-widget__markdown h6 {\n font-size: calc(var(--chat-font-size) * 0.95);\n}\n.chat-widget__anchor-button {\n position: fixed;\n bottom: 20px;\n right: 20px;\n display: inline-flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.65rem 0.85rem;\n background: var(--chat-primary);\n color: var(--chat-primary-text);\n border: none;\n border-radius: 999px;\n box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);\n cursor: pointer;\n font-weight: 600;\n z-index: 99999;\n}\n.chat-widget__anchor-button:hover {\n background: var(--chat-primary-hover);\n}\n.chat-widget__anchor--left {\n right: auto;\n left: 20px;\n}\n.chat-widget__anchor-icon {\n width: 1.1rem;\n height: 1.1rem;\n}\n.chat-widget__popup {\n position: fixed;\n bottom: 80px;\n right: 20px;\n z-index: 99998;\n}\n.chat-widget__anchor--left.chat-widget__popup {\n right: auto;\n left: 20px;\n}\n.chat-widget__popup-inner {\n width: 384px;\n max-width: calc(100vw - 40px);\n height: 500px;\n max-height: calc(100vh - 140px);\n box-shadow: 0 20px 45px rgba(15, 23, 42, 0.12);\n border-radius: 12px;\n overflow: hidden;\n}\n.chat-widget__markdown table {\n width: 100%;\n border-collapse: collapse;\n margin: 0.5rem 0;\n}\n.chat-widget__markdown th,\n.chat-widget__markdown td {\n border: 1px solid var(--chat-border);\n padding: 0.5rem;\n text-align: left;\n vertical-align: top;\n}\n.chat-widget__markdown thead th {\n background: var(--chat-assistant-bg);\n color: var(--chat-assistant-text);\n font-weight: 600;\n}\n.chat-widget__thoughts {\n min-width: 0;\n --chat-font-size: var(--chat-thought-font-size);\n}\n.chat-widget__details {\n border: 0;\n}\n.chat-widget__thoughts-summary {\n list-style: none;\n display: flex;\n align-items: center;\n gap: 0.35rem;\n cursor: pointer;\n color: #6b7280;\n font-size: 0.8125rem;\n}\n.chat-widget__thoughts-summary:hover {\n color: var(--chat-assistant-text);\n}\n.chat-widget__thoughts-icon-container {\n display: flex;\n border: 1px solid #d1d5db;\n border-radius: 999px;\n align-items: center;\n justify-content: center;\n width: 1rem;\n height: 1rem;\n}\n.chat-widget__thoughts-icon {\n width: 0.75rem;\n height: 0.75rem;\n transition: transform 0.2s ease;\n}\n.chat-widget__details[open] .chat-widget__thoughts-icon {\n transform: rotate(90deg);\n}\n.chat-widget__thoughts-content {\n margin-top: 0.5rem;\n margin-left: 0.4rem;\n padding: 0.75rem;\n border-left: 2px solid var(--chat-thought-border);\n border-color: var(--chat-primary);\n max-width: 100%;\n overflow-x: auto;\n}\n.chat-widget__thoughts-text {\n margin: 0;\n line-height: 1.5;\n color: #4b5563;\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n "Liberation Mono",\n "Courier New",\n monospace;\n white-space: pre-wrap;\n word-break: break-word;\n overflow-wrap: anywhere;\n display: block;\n}\n.chat-widget__loading {\n display: flex;\n justify-content: flex-start;\n}\n.chat-widget__loading-bubble {\n background: var(--chat-assistant-bg);\n color: var(--chat-assistant-text);\n border-radius: calc(var(--chat-radius) * 0.65);\n border-bottom-left-radius: 0.35rem;\n padding: 0.5rem 0.75rem;\n}\n.chat-widget__loading-dots {\n display: flex;\n gap: 0.35rem;\n}\n.chat-widget__loading-dot {\n width: 0.5rem;\n height: 0.5rem;\n border-radius: 999px;\n background: #9ca3af;\n animation: chat-widget-bounce 1s infinite ease-in-out;\n}\n.chat-widget__loading-dot[data-delay="1"] {\n animation-delay: 0.1s;\n}\n.chat-widget__loading-dot[data-delay="2"] {\n animation-delay: 0.2s;\n}\n@keyframes chat-widget-bounce {\n 0%, 80%, 100% {\n transform: scale(0.6);\n opacity: 0.4;\n }\n 40% {\n transform: scale(1);\n opacity: 1;\n }\n}\n.chat-widget__input {\n border-top: 1px solid var(--chat-border);\n padding: 0.25rem 0 0.75rem;\n background: var(--chat-input-bg);\n}\n.chat-widget__form {\n position: relative;\n}\n.chat-widget__textarea {\n width: 100%;\n border: 0;\n padding: 0.75rem 5.25rem 0.75rem 0.75rem;\n background: transparent;\n font-size: 0.925rem;\n resize: none;\n color: var(--chat-input-text);\n font-family: inherit;\n}\n.chat-widget__textarea::-moz-placeholder {\n color: var(--chat-input-placeholder);\n}\n.chat-widget__textarea::placeholder {\n color: var(--chat-input-placeholder);\n}\n.chat-widget__textarea:focus-visible {\n outline: none;\n}\n.chat-widget__textarea:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.chat-widget__toolbar {\n position: absolute;\n top: 0;\n right: 3.75rem;\n height: 100%;\n display: flex;\n align-items: center;\n padding: 0 0.5rem;\n border-right: 1px solid var(--chat-border);\n}\n.chat-widget__submit {\n position: absolute;\n top: 50%;\n right: 0.75rem;\n transform: translateY(-50%);\n background: transparent;\n border: 0;\n width: 2.5rem;\n height: 2.5rem;\n display: grid;\n place-items: center;\n color: var(--chat-primary);\n cursor: pointer;\n}\n.chat-widget__submit:disabled {\n color: #9ca3af;\n cursor: not-allowed;\n}\n.chat-widget__submit:not(:disabled):hover {\n color: var(--chat-primary-hover);\n}\n.chat-widget__send-icon {\n width: 1.2rem;\n height: 1.2rem;\n}\n.chat-widget__mic-button {\n position: relative;\n border: none;\n background: transparent;\n width: 2.25rem;\n height: 2.25rem;\n display: grid;\n place-items: center;\n color: var(--chat-primary);\n cursor: pointer;\n border-radius: 999px;\n}\n.chat-widget__mic-button:disabled {\n color: #9ca3af;\n cursor: not-allowed;\n}\n.chat-widget__mic-button--active {\n color: var(--chat-primary-hover);\n background: rgba(59, 130, 246, 0.08);\n}\n.chat-widget__mic-icon {\n width: 1rem;\n height: 1rem;\n}\n.chat-widget__mic-bar {\n position: absolute;\n bottom: 0.1rem;\n left: 50%;\n width: 16px;\n height: 2px;\n border-radius: 999px;\n background: rgba(148, 163, 184, 0.4);\n overflow: hidden;\n display: block;\n transform: translateX(-50%);\n pointer-events: none;\n}\n.chat-widget__mic-bar-fill {\n display: block;\n width: 100%;\n height: 100%;\n background: currentColor;\n transform-origin: left;\n transition: transform 0.12s linear;\n}\n.chat-widget__voice {\n display: flex;\n margin-top: 0.25rem;\n}\n.chat-widget__voice-button {\n border: none;\n background: none;\n display: inline-flex;\n align-items: center;\n gap: 0.35rem;\n padding: 0.1rem 0;\n font-size: 0.8rem;\n font-weight: 500;\n color: var(--chat-primary);\n cursor: pointer;\n}\n.chat-widget__voice-button:disabled {\n color: #9ca3af;\n cursor: not-allowed;\n}\n.chat-widget__voice-button--active {\n color: var(--chat-primary-hover);\n}\n.chat-widget__voice-icon {\n width: 0.95rem;\n height: 0.95rem;\n}\n.chat-widget__voice-icon--spin {\n animation: chat-widget-spin 1s linear infinite;\n}\n@keyframes chat-widget-spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n');
|
|
18913
18916
|
|
|
18914
18917
|
// lib/components/ChatWidget.tsx
|
|
18915
18918
|
import { ChevronRight as ChevronRight2, Send, StopCircle } from "lucide-react";
|
|
18916
|
-
import React3, { useCallback as useCallback4, useEffect as useEffect4, useMemo, useRef as
|
|
18919
|
+
import React3, { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo2, useRef as useRef3, useState as useState6 } from "react";
|
|
18917
18920
|
import ReactMarkdown from "react-markdown";
|
|
18918
18921
|
|
|
18919
18922
|
// ../../node_modules/ccount/index.js
|
|
@@ -23667,12 +23670,12 @@ async function registerChatWidgets({
|
|
|
23667
23670
|
widgets
|
|
23668
23671
|
}) {
|
|
23669
23672
|
const widgetSchemas = widgets.map(({ widgetType, schema, enrich }) => {
|
|
23670
|
-
|
|
23673
|
+
const extendedSchema = schema.extend({
|
|
23671
23674
|
widgetType: zod_default.literal(widgetType)
|
|
23672
23675
|
});
|
|
23673
23676
|
return {
|
|
23674
23677
|
widgetType,
|
|
23675
|
-
schema: toJsonSchema(
|
|
23678
|
+
schema: toJsonSchema(extendedSchema),
|
|
23676
23679
|
enrich
|
|
23677
23680
|
};
|
|
23678
23681
|
});
|
|
@@ -23884,7 +23887,7 @@ import { Mic, MicOff } from "lucide-react";
|
|
|
23884
23887
|
import {
|
|
23885
23888
|
useCallback as useCallback3,
|
|
23886
23889
|
useEffect as useEffect3,
|
|
23887
|
-
useRef,
|
|
23890
|
+
useRef as useRef2,
|
|
23888
23891
|
useState as useState4
|
|
23889
23892
|
} from "react";
|
|
23890
23893
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
@@ -23909,13 +23912,13 @@ function SpeechToTextButton({
|
|
|
23909
23912
|
const [isListening, setIsListening] = useState4(false);
|
|
23910
23913
|
const [isSupported, setIsSupported] = useState4(false);
|
|
23911
23914
|
const [countdown, setCountdown] = useState4(0);
|
|
23912
|
-
const recognitionRef =
|
|
23915
|
+
const recognitionRef = useRef2(null);
|
|
23913
23916
|
const [countdownActive, setCountdownActive] = useState4(false);
|
|
23914
|
-
const silenceTimer =
|
|
23915
|
-
const finalTimer =
|
|
23916
|
-
const finalTextRef =
|
|
23917
|
-
const countdownFrameRef =
|
|
23918
|
-
const countdownEndRef =
|
|
23917
|
+
const silenceTimer = useRef2(null);
|
|
23918
|
+
const finalTimer = useRef2(null);
|
|
23919
|
+
const finalTextRef = useRef2("");
|
|
23920
|
+
const countdownFrameRef = useRef2(null);
|
|
23921
|
+
const countdownEndRef = useRef2(0);
|
|
23919
23922
|
const recognitionLanguage = language ?? "en-US";
|
|
23920
23923
|
const clearSilenceTimer = useCallback3(() => {
|
|
23921
23924
|
if (silenceTimer.current) {
|
|
@@ -24270,7 +24273,7 @@ function MessageItemComponent({
|
|
|
24270
24273
|
] }, key);
|
|
24271
24274
|
}
|
|
24272
24275
|
const widget = item;
|
|
24273
|
-
return /* @__PURE__ */ jsx5("div", { className: "chat-widget__widget", children: widgetDef.render(
|
|
24276
|
+
return /* @__PURE__ */ jsx5("div", { className: "chat-widget__widget", children: widgetDef.render(widget.payload, widget.enriched ?? {}) }, key);
|
|
24274
24277
|
}
|
|
24275
24278
|
return null;
|
|
24276
24279
|
};
|
|
@@ -24428,11 +24431,11 @@ function ChatWidget({
|
|
|
24428
24431
|
widgets,
|
|
24429
24432
|
feedback
|
|
24430
24433
|
}) {
|
|
24431
|
-
const theme =
|
|
24434
|
+
const theme = useMemo2(
|
|
24432
24435
|
() => ({ ...defaultTheme, ...styleProps || {} }),
|
|
24433
24436
|
[styleProps]
|
|
24434
24437
|
);
|
|
24435
|
-
const themeVariables =
|
|
24438
|
+
const themeVariables = useMemo2(
|
|
24436
24439
|
() => ({
|
|
24437
24440
|
"--chat-primary": theme.primaryColor,
|
|
24438
24441
|
"--chat-primary-text": theme.primaryTextColor,
|
|
@@ -24455,11 +24458,11 @@ function ChatWidget({
|
|
|
24455
24458
|
const [input, setInput] = useState6("");
|
|
24456
24459
|
const [isMicActive, setIsMicActive] = useState6(false);
|
|
24457
24460
|
const [isSpeechPending, setIsSpeechPending] = useState6(false);
|
|
24458
|
-
const messagesEndRef =
|
|
24459
|
-
const scrollContainerRef =
|
|
24460
|
-
const isAtBottomRef =
|
|
24461
|
-
const textareaRef =
|
|
24462
|
-
const suppressScrollRef =
|
|
24461
|
+
const messagesEndRef = useRef3(null);
|
|
24462
|
+
const scrollContainerRef = useRef3(null);
|
|
24463
|
+
const isAtBottomRef = useRef3(true);
|
|
24464
|
+
const textareaRef = useRef3(null);
|
|
24465
|
+
const suppressScrollRef = useRef3(false);
|
|
24463
24466
|
const {
|
|
24464
24467
|
messages,
|
|
24465
24468
|
status,
|
|
@@ -24504,7 +24507,7 @@ function ChatWidget({
|
|
|
24504
24507
|
return next;
|
|
24505
24508
|
});
|
|
24506
24509
|
}, []);
|
|
24507
|
-
const voiceConfig =
|
|
24510
|
+
const voiceConfig = useMemo2(() => {
|
|
24508
24511
|
if (!voice || voice.enabled === false || !voice.url) {
|
|
24509
24512
|
return null;
|
|
24510
24513
|
}
|
|
@@ -24606,7 +24609,7 @@ function ChatWidget({
|
|
|
24606
24609
|
setIsMicActive(false);
|
|
24607
24610
|
}
|
|
24608
24611
|
}, [speechEnabled]);
|
|
24609
|
-
const lastRegisteredRef =
|
|
24612
|
+
const lastRegisteredRef = useRef3({
|
|
24610
24613
|
threadId: "",
|
|
24611
24614
|
widgets: null
|
|
24612
24615
|
});
|
|
@@ -24715,7 +24718,7 @@ styleInject(".chat-popup__anchor {\n position: fixed;\n inset-block-end: 20px;
|
|
|
24715
24718
|
|
|
24716
24719
|
// lib/components/PopupChatWidget.tsx
|
|
24717
24720
|
import { MessageSquare as MessageSquare2, X } from "lucide-react";
|
|
24718
|
-
import { useEffect as useEffect5, useMemo as
|
|
24721
|
+
import { useEffect as useEffect5, useMemo as useMemo3, useState as useState7 } from "react";
|
|
24719
24722
|
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
24720
24723
|
function PopupChatWidget({ anchor, ...props }) {
|
|
24721
24724
|
const [isOpen, setIsOpen] = useState7(anchor?.initiallyOpen ?? false);
|
|
@@ -24740,7 +24743,7 @@ function PopupChatWidget({ anchor, ...props }) {
|
|
|
24740
24743
|
const anchorPositionClass = anchor?.position === "bottom-start" ? "chat-popup--start" : "chat-popup--end";
|
|
24741
24744
|
const closeConfig = anchor?.closeButton ?? props.closeButton;
|
|
24742
24745
|
const showClose = closeConfig?.show !== false;
|
|
24743
|
-
const themeStyle =
|
|
24746
|
+
const themeStyle = useMemo3(() => {
|
|
24744
24747
|
const primary = props.styles?.primaryColor ?? "#3b82f6";
|
|
24745
24748
|
const primaryText = props.styles?.primaryTextColor ?? "#ffffff";
|
|
24746
24749
|
const background = props.styles?.backgroundColor ?? "#ffffff";
|
|
@@ -24764,7 +24767,7 @@ function PopupChatWidget({ anchor, ...props }) {
|
|
|
24764
24767
|
"--chat-header-text": headerText
|
|
24765
24768
|
};
|
|
24766
24769
|
}, [props.styles]);
|
|
24767
|
-
const popupStyle =
|
|
24770
|
+
const popupStyle = useMemo3(() => {
|
|
24768
24771
|
const size = props.popupSize ?? {};
|
|
24769
24772
|
return {
|
|
24770
24773
|
width: size.width ?? "600px",
|
|
@@ -24872,7 +24875,7 @@ var createWidget = ({
|
|
|
24872
24875
|
widgetType,
|
|
24873
24876
|
schema,
|
|
24874
24877
|
enrich,
|
|
24875
|
-
render
|
|
24878
|
+
render
|
|
24876
24879
|
});
|
|
24877
24880
|
|
|
24878
24881
|
// lib/widgets/default-widgets.tsx
|
|
@@ -24885,7 +24888,7 @@ var defaultChatWidgets = [
|
|
|
24885
24888
|
profileUri: zod_default.string().optional(),
|
|
24886
24889
|
details: zod_default.record(zod_default.any()).optional()
|
|
24887
24890
|
}).describe("showing a person card with name, photo and additional details"),
|
|
24888
|
-
render: (
|
|
24891
|
+
render: (payload) => /* @__PURE__ */ jsx8(
|
|
24889
24892
|
"div",
|
|
24890
24893
|
{
|
|
24891
24894
|
style: {
|
|
@@ -24934,7 +24937,7 @@ var defaultChatWidgets = [
|
|
|
24934
24937
|
uri: zod_default.string().url(),
|
|
24935
24938
|
text: zod_default.string().optional()
|
|
24936
24939
|
}).describe("rendering a clickable link"),
|
|
24937
|
-
render: (
|
|
24940
|
+
render: (payload) => /* @__PURE__ */ jsx8(
|
|
24938
24941
|
"a",
|
|
24939
24942
|
{
|
|
24940
24943
|
href: payload.uri,
|
|
@@ -24971,21 +24974,34 @@ var defaultChatWidgets = [
|
|
|
24971
24974
|
widgetType: "vendor-cards",
|
|
24972
24975
|
schema: zod_default.object({
|
|
24973
24976
|
vendors: zod_default.array(zod_default.object({
|
|
24974
|
-
|
|
24975
|
-
rank: zod_default.number().describe("ranking position of the vendor from 1 to N"),
|
|
24976
|
-
reason: zod_default.string().describe("reason for the vendor ranking")
|
|
24977
|
+
vendor_id: zod_default.string(),
|
|
24978
|
+
rank: zod_default.number().optional().describe("ranking position of the vendor from 1 to N when applicable"),
|
|
24979
|
+
reason: zod_default.string().optional().describe("reason for the vendor ranking when applicable")
|
|
24977
24980
|
}))
|
|
24978
|
-
}).describe("displaying a list of vendor cards with rankings and reasons"),
|
|
24981
|
+
}).describe("displaying a list of vendor cards with rankings and reasons. Only use this widget when calling Care Network vendor search tools."),
|
|
24979
24982
|
enrich: {
|
|
24980
|
-
|
|
24981
|
-
|
|
24982
|
-
|
|
24983
|
+
vendorDetails: {
|
|
24984
|
+
toolId: "CPgsswom7FkUYvplmy6H",
|
|
24985
|
+
inputs: {
|
|
24986
|
+
vendorIds: "${vendors|map('vendor_id')|join(',')}"
|
|
24987
|
+
}
|
|
24983
24988
|
}
|
|
24984
24989
|
},
|
|
24985
|
-
render: (
|
|
24986
|
-
const
|
|
24987
|
-
|
|
24988
|
-
|
|
24990
|
+
render: (payload, { vendorDetails }) => {
|
|
24991
|
+
const typedPayload = payload;
|
|
24992
|
+
const vendorData = vendorDetails?.data ?? {};
|
|
24993
|
+
const formatLanguage = (code3) => {
|
|
24994
|
+
const langMap = { en: "English", es: "Spanish", zh: "Chinese", fr: "French" };
|
|
24995
|
+
return langMap[code3.trim()] || code3.trim();
|
|
24996
|
+
};
|
|
24997
|
+
return /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: typedPayload.vendors.map((v) => {
|
|
24998
|
+
const data = vendorData[v.vendor_id];
|
|
24999
|
+
const name17 = data?.names?.find((n) => n.type === "org")?.value ?? "Care Provider";
|
|
25000
|
+
const languages = data?.languages ?? [];
|
|
25001
|
+
const ageGroups = data?.details?.age_groups ?? [];
|
|
25002
|
+
const services = data?.details?.services ?? [];
|
|
25003
|
+
const address = data?.location?.formatted_address;
|
|
25004
|
+
const hours = data?.scheduling?.hours;
|
|
24989
25005
|
return /* @__PURE__ */ jsxs7(
|
|
24990
25006
|
"div",
|
|
24991
25007
|
{
|
|
@@ -25002,26 +25018,53 @@ var defaultChatWidgets = [
|
|
|
25002
25018
|
children: [
|
|
25003
25019
|
/* @__PURE__ */ jsxs7("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
25004
25020
|
/* @__PURE__ */ jsxs7("span", { style: { fontWeight: 600, fontSize: "1rem", color: "#111827" }, children: [
|
|
25005
|
-
"
|
|
25006
|
-
|
|
25007
|
-
" ",
|
|
25008
|
-
data?.name ?? `Vendor ${v.id}`
|
|
25021
|
+
v.rank ? `#${v.rank} ` : "",
|
|
25022
|
+
name17
|
|
25009
25023
|
] }),
|
|
25010
|
-
|
|
25011
|
-
"\u2B50 ",
|
|
25012
|
-
data.rating.toFixed(1)
|
|
25013
|
-
] })
|
|
25024
|
+
hours && /* @__PURE__ */ jsx8("span", { style: { fontSize: "0.75rem", color: "#6b7280" }, children: hours })
|
|
25014
25025
|
] }),
|
|
25015
|
-
|
|
25016
|
-
/* @__PURE__ */
|
|
25026
|
+
address && /* @__PURE__ */ jsx8("div", { style: { fontSize: "0.875rem", color: "#6b7280" }, children: address }),
|
|
25027
|
+
services.length > 0 && /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.375rem" }, children: services.map((service) => /* @__PURE__ */ jsx8(
|
|
25028
|
+
"span",
|
|
25029
|
+
{
|
|
25030
|
+
style: {
|
|
25031
|
+
fontSize: "0.75rem",
|
|
25032
|
+
padding: "0.125rem 0.5rem",
|
|
25033
|
+
background: "#dbeafe",
|
|
25034
|
+
color: "#1e40af",
|
|
25035
|
+
borderRadius: "9999px"
|
|
25036
|
+
},
|
|
25037
|
+
children: service
|
|
25038
|
+
},
|
|
25039
|
+
service
|
|
25040
|
+
)) }),
|
|
25041
|
+
languages.length > 0 && /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.375rem" }, children: languages.map((lang) => /* @__PURE__ */ jsx8(
|
|
25042
|
+
"span",
|
|
25043
|
+
{
|
|
25044
|
+
style: {
|
|
25045
|
+
fontSize: "0.75rem",
|
|
25046
|
+
padding: "0.125rem 0.5rem",
|
|
25047
|
+
background: "#f3e8ff",
|
|
25048
|
+
color: "#7c3aed",
|
|
25049
|
+
borderRadius: "9999px"
|
|
25050
|
+
},
|
|
25051
|
+
children: formatLanguage(lang)
|
|
25052
|
+
},
|
|
25053
|
+
lang
|
|
25054
|
+
)) }),
|
|
25055
|
+
ageGroups.length > 0 && /* @__PURE__ */ jsxs7("div", { style: { fontSize: "0.75rem", color: "#6b7280" }, children: [
|
|
25056
|
+
/* @__PURE__ */ jsx8("strong", { children: "Ages:" }),
|
|
25057
|
+
" ",
|
|
25058
|
+
ageGroups.join(", ")
|
|
25059
|
+
] }),
|
|
25060
|
+
v.reason && /* @__PURE__ */ jsxs7("div", { style: { fontSize: "0.875rem", color: "#374151" }, children: [
|
|
25017
25061
|
/* @__PURE__ */ jsx8("strong", { children: "Why:" }),
|
|
25018
25062
|
" ",
|
|
25019
25063
|
v.reason
|
|
25020
|
-
] })
|
|
25021
|
-
data?.address && /* @__PURE__ */ jsx8("div", { style: { fontSize: "0.75rem", color: "#9ca3af" }, children: data.address })
|
|
25064
|
+
] })
|
|
25022
25065
|
]
|
|
25023
25066
|
},
|
|
25024
|
-
v.
|
|
25067
|
+
v.vendor_id
|
|
25025
25068
|
);
|
|
25026
25069
|
}) });
|
|
25027
25070
|
}
|