@ensembleapp/client-sdk 0.0.14 → 0.0.16

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 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
- * Configuration for enriching widget data server-side by calling a tool.
17
- * Uses JEXL expressions to build tool inputs from the widget payload.
11
+ * fetch data via tool call.
18
12
  */
19
- type WidgetEnrichConfig = {
20
- /** Tool ID to call for enrichment */
13
+ type ToolCallConfig = {
21
14
  toolId: string;
22
15
  /**
23
- * Tool version selector. Defaults to 'latest'.
24
- * - 'latest': prefer draft, fallback to published
25
- * - 'published': prefer published, fallback to draft
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
- * Maps tool input names to JEXL expressions.
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
- /** Enrichment result containing the full tool response. TThis should mirror ToolResult on server-side. */
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 result from tool call. This mirror ToolResult on server-side. */
59
- enrichedResult?: EnrichmentResult$1;
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
- * Props passed to widget render functions.
191
- * Contains both the validated payload and optional enriched result.
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 a tool to enrich the data.
204
- * The enriched data is passed to the render function as `enrichedResult.data`.
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
- render(props: WidgetRenderProps<z.infer<TSchema>, TEnrichedData>): ReactNode;
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, TEnrichedData = unknown>({ widgetType, schema, enrich, render, }: UIWidgetDefinition<TSchema, TEnrichedData>) => UIWidgetDefinition<TSchema, TEnrichedData>;
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, type WidgetRenderProps, cn, createChatWidget, createWidget, defaultChatWidgets, registerChatWidgets, useChat, useFeedback };
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
@@ -23670,12 +23670,12 @@ async function registerChatWidgets({
23670
23670
  widgets
23671
23671
  }) {
23672
23672
  const widgetSchemas = widgets.map(({ widgetType, schema, enrich }) => {
23673
- schema = schema.extend({
23673
+ const extendedSchema = schema.extend({
23674
23674
  widgetType: zod_default.literal(widgetType)
23675
23675
  });
23676
23676
  return {
23677
23677
  widgetType,
23678
- schema: toJsonSchema(schema),
23678
+ schema: toJsonSchema(extendedSchema),
23679
23679
  enrich
23680
23680
  };
23681
23681
  });
@@ -24273,7 +24273,7 @@ function MessageItemComponent({
24273
24273
  ] }, key);
24274
24274
  }
24275
24275
  const widget = item;
24276
- return /* @__PURE__ */ jsx5("div", { className: "chat-widget__widget", children: widgetDef.render({ payload: widget.payload, enrichedResult: widget.enrichedResult }) }, key);
24276
+ return /* @__PURE__ */ jsx5("div", { className: "chat-widget__widget", children: widgetDef.render(widget.payload, widget.enriched ?? {}) }, key);
24277
24277
  }
24278
24278
  return null;
24279
24279
  };
@@ -24875,11 +24875,143 @@ var createWidget = ({
24875
24875
  widgetType,
24876
24876
  schema,
24877
24877
  enrich,
24878
- render: (props) => render(props)
24878
+ render
24879
24879
  });
24880
24880
 
24881
- // lib/widgets/default-widgets.tsx
24881
+ // lib/widgets/VendorCards.tsx
24882
24882
  import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
24883
+ var vendorCardsSchema = zod_default.object({
24884
+ fromLocation: zod_default.string().describe("The location the user is searching for"),
24885
+ fromCoordinates: zod_default.object({
24886
+ latitude: zod_default.number(),
24887
+ longitude: zod_default.number()
24888
+ }).describe("The location's lat/lng coordinates. This must come from the previous geocoding tool as-is - do NOT guess"),
24889
+ vendors: zod_default.array(zod_default.object({
24890
+ vendor_id: zod_default.string(),
24891
+ notes: zod_default.string().optional().describe("Why this vendor was recommended"),
24892
+ vendorCoordinates: zod_default.object({
24893
+ latitude: zod_default.number(),
24894
+ longitude: zod_default.number()
24895
+ }).describe("The lat/lng coordinates of this vendor. This must come from the vendor's location.coordinates from the previous vendor search tool - do NOT guess")
24896
+ }))
24897
+ }).describe("displaying a list of vendor cards. Use this widget to represent data from CareNetwork vendor search tool.");
24898
+ function VendorCards({ payload, enriched }) {
24899
+ if (!enriched || !enriched.vendorDetails || !enriched.distanceMatrix) {
24900
+ return /* @__PURE__ */ jsx8("div", { children: "Outdated vendor-cards widget" });
24901
+ }
24902
+ const { vendorDetails, distanceMatrix } = enriched;
24903
+ const vendorData = vendorDetails?.data ?? {};
24904
+ const distances = distanceMatrix?.data ?? [];
24905
+ const formatDistance = (meters) => {
24906
+ const miles = meters / 1609.34;
24907
+ return miles < 0.1 ? "< 0.1 mi" : `${miles.toFixed(1)} mi`;
24908
+ };
24909
+ return /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: payload.vendors.map((v, index) => {
24910
+ const data = vendorData[v.vendor_id];
24911
+ const name17 = data?.names?.find((n) => n.type === "org")?.value ?? "";
24912
+ const address = data?.location?.address;
24913
+ const distanceEntry = distances.find((d) => d.destinationIndex === index);
24914
+ const distance = distanceEntry && distanceEntry.distanceMeters ? formatDistance(distanceEntry.distanceMeters) : void 0;
24915
+ const hourlyRate = data?.financials?.fees?.find((f) => f.fee_type?.includes("Hourly"))?.amount;
24916
+ const avgRating = data?.avg_rating;
24917
+ const reviewCount = data?.review_count;
24918
+ const booleans = data?.booleans;
24919
+ const verification = data?.verification;
24920
+ return /* @__PURE__ */ jsxs7(
24921
+ "div",
24922
+ {
24923
+ style: {
24924
+ display: "flex",
24925
+ flexDirection: "column",
24926
+ gap: "0.2rem",
24927
+ padding: "1rem",
24928
+ background: "#ffffff",
24929
+ border: "1px solid #e5e7eb",
24930
+ borderRadius: "0.5rem",
24931
+ boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1)",
24932
+ fontSize: "0.875rem"
24933
+ },
24934
+ children: [
24935
+ /* @__PURE__ */ jsx8("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-start" }, children: /* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
24936
+ /* @__PURE__ */ jsx8("div", { style: {
24937
+ width: "2rem",
24938
+ height: "2rem",
24939
+ borderRadius: "9999px",
24940
+ background: "#bfd1f5",
24941
+ display: "flex",
24942
+ alignItems: "center",
24943
+ justifyContent: "center",
24944
+ fontWeight: 600,
24945
+ fontSize: "0.875rem",
24946
+ color: "#374151"
24947
+ }, children: name17.charAt(0).toUpperCase() }),
24948
+ /* @__PURE__ */ jsx8("span", { style: { fontWeight: 600, fontSize: "1rem", color: "#111827" }, children: name17 })
24949
+ ] }) }),
24950
+ /* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem", color: "#6b7280" }, children: [
24951
+ /* @__PURE__ */ jsx8("span", { style: { color: "#facc15" }, children: "\u2605" }),
24952
+ /* @__PURE__ */ jsx8("span", { children: avgRating?.toFixed(1) ?? "\u2014" }),
24953
+ /* @__PURE__ */ jsxs7("span", { style: { color: "#9ca3af" }, children: [
24954
+ "(",
24955
+ reviewCount ?? 0,
24956
+ " reviews)"
24957
+ ] })
24958
+ ] }),
24959
+ address && /* @__PURE__ */ jsx8("div", { style: { color: "#6b7280" }, children: address }),
24960
+ distance && /* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#6b7280" }, children: [
24961
+ /* @__PURE__ */ jsx8("span", { children: "\u{1F4CD}" }),
24962
+ /* @__PURE__ */ jsxs7("span", { children: [
24963
+ distance,
24964
+ " from ",
24965
+ payload.fromLocation
24966
+ ] })
24967
+ ] }),
24968
+ hourlyRate && /* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#6b7280" }, children: [
24969
+ /* @__PURE__ */ jsx8("span", { children: "\u{1F4B0}" }),
24970
+ /* @__PURE__ */ jsxs7("span", { children: [
24971
+ "Rate: $",
24972
+ hourlyRate,
24973
+ "/hr"
24974
+ ] })
24975
+ ] }),
24976
+ v.notes && /* @__PURE__ */ jsxs7("div", { style: { color: "#374151", marginTop: "0.4rem" }, children: [
24977
+ /* @__PURE__ */ jsx8("span", { style: { marginRight: "0.25rem" }, children: "\u2728" }),
24978
+ /* @__PURE__ */ jsx8("strong", { children: "Recommendation notes" }),
24979
+ /* @__PURE__ */ jsx8("div", { style: { marginLeft: "1.25rem", marginTop: "0.25rem", color: "#6b7280" }, children: v.notes })
24980
+ ] }),
24981
+ /* @__PURE__ */ jsxs7("div", { style: {
24982
+ display: "flex",
24983
+ flexWrap: "wrap",
24984
+ gap: "0.5rem",
24985
+ marginTop: "0.25rem",
24986
+ paddingTop: "0.5rem",
24987
+ borderTop: "1px solid #f3f4f6"
24988
+ }, children: [
24989
+ verification?.verified && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#22c55e", fontSize: "0.75rem" }, children: [
24990
+ /* @__PURE__ */ jsx8("span", { style: { fontSize: "0.875rem" }, children: "\u2713" }),
24991
+ " Verified"
24992
+ ] }),
24993
+ booleans?.is_agency_insured && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#22c55e", fontSize: "0.75rem" }, children: [
24994
+ /* @__PURE__ */ jsx8("span", { style: { fontSize: "0.875rem" }, children: "\u2713" }),
24995
+ " Insured"
24996
+ ] }),
24997
+ booleans?.free_in_home_evaluation && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#3b82f6", fontSize: "0.75rem" }, children: [
24998
+ /* @__PURE__ */ jsx8("span", { style: { fontSize: "0.875rem" }, children: "\u{1F3E0}" }),
24999
+ " Free In-Home Evaluation"
25000
+ ] }),
25001
+ booleans?.can_request_same_caregiver && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#6b7280", fontSize: "0.75rem" }, children: [
25002
+ /* @__PURE__ */ jsx8("span", { style: { fontSize: "0.875rem" }, children: "\u{1F464}" }),
25003
+ " Same Caregiver Available"
25004
+ ] })
25005
+ ] })
25006
+ ]
25007
+ },
25008
+ v.vendor_id
25009
+ );
25010
+ }) });
25011
+ }
25012
+
25013
+ // lib/widgets/default-widgets.tsx
25014
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
24883
25015
  var defaultChatWidgets = [
24884
25016
  createWidget({
24885
25017
  widgetType: "person-card",
@@ -24888,7 +25020,7 @@ var defaultChatWidgets = [
24888
25020
  profileUri: zod_default.string().optional(),
24889
25021
  details: zod_default.record(zod_default.any()).optional()
24890
25022
  }).describe("showing a person card with name, photo and additional details"),
24891
- render: ({ payload }) => /* @__PURE__ */ jsx8(
25023
+ render: (payload) => /* @__PURE__ */ jsx9(
24892
25024
  "div",
24893
25025
  {
24894
25026
  style: {
@@ -24901,8 +25033,8 @@ var defaultChatWidgets = [
24901
25033
  borderRadius: "0.5rem",
24902
25034
  boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)"
24903
25035
  },
24904
- children: /* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "flex-start", gap: "0.75rem" }, children: [
24905
- payload.profileUri && /* @__PURE__ */ jsx8(
25036
+ children: /* @__PURE__ */ jsxs8("div", { style: { display: "flex", alignItems: "flex-start", gap: "0.75rem" }, children: [
25037
+ payload.profileUri && /* @__PURE__ */ jsx9(
24906
25038
  "img",
24907
25039
  {
24908
25040
  src: payload.profileUri,
@@ -24917,14 +25049,14 @@ var defaultChatWidgets = [
24917
25049
  loading: "lazy"
24918
25050
  }
24919
25051
  ),
24920
- /* @__PURE__ */ jsxs7("div", { style: { flex: 1, minWidth: 0 }, children: [
24921
- /* @__PURE__ */ jsx8("div", { style: { fontWeight: 600, fontSize: "1rem", color: "#111827", marginBottom: "0.25rem" }, children: payload.name }),
24922
- payload.details ? /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexDirection: "column", gap: "0.25rem" }, children: Object.entries(payload.details).map(([key, value]) => /* @__PURE__ */ jsxs7("div", { style: { display: "flex", gap: "0.5rem", fontSize: "0.875rem" }, children: [
24923
- /* @__PURE__ */ jsxs7("span", { style: { color: "#6b7280", fontWeight: 500, minWidth: "fit-content" }, children: [
25052
+ /* @__PURE__ */ jsxs8("div", { style: { flex: 1, minWidth: 0 }, children: [
25053
+ /* @__PURE__ */ jsx9("div", { style: { fontWeight: 600, fontSize: "1rem", color: "#111827", marginBottom: "0.25rem" }, children: payload.name }),
25054
+ payload.details ? /* @__PURE__ */ jsx9("div", { style: { display: "flex", flexDirection: "column", gap: "0.25rem" }, children: Object.entries(payload.details).map(([key, value]) => /* @__PURE__ */ jsxs8("div", { style: { display: "flex", gap: "0.5rem", fontSize: "0.875rem" }, children: [
25055
+ /* @__PURE__ */ jsxs8("span", { style: { color: "#6b7280", fontWeight: 500, minWidth: "fit-content" }, children: [
24924
25056
  key,
24925
25057
  ":"
24926
25058
  ] }),
24927
- /* @__PURE__ */ jsx8("span", { style: { color: "#374151" }, children: String(value) })
25059
+ /* @__PURE__ */ jsx9("span", { style: { color: "#374151" }, children: String(value) })
24928
25060
  ] }, key)) }) : null
24929
25061
  ] })
24930
25062
  ] })
@@ -24937,7 +25069,7 @@ var defaultChatWidgets = [
24937
25069
  uri: zod_default.string().url(),
24938
25070
  text: zod_default.string().optional()
24939
25071
  }).describe("rendering a clickable link"),
24940
- render: ({ payload }) => /* @__PURE__ */ jsx8(
25072
+ render: (payload) => /* @__PURE__ */ jsx9(
24941
25073
  "a",
24942
25074
  {
24943
25075
  href: payload.uri,
@@ -24972,100 +25104,31 @@ var defaultChatWidgets = [
24972
25104
  }),
24973
25105
  createWidget({
24974
25106
  widgetType: "vendor-cards",
24975
- schema: zod_default.object({
24976
- vendors: zod_default.array(zod_default.object({
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")
24980
- }))
24981
- }).describe("displaying a list of vendor cards with rankings and reasons. Only use this widget when calling Care Network vendor search tools."),
25107
+ schema: vendorCardsSchema,
24982
25108
  enrich: {
24983
- toolId: "CPgsswom7FkUYvplmy6H",
24984
- inputs: {
24985
- vendorIds: "${vendors|map('vendor_id')|join(',')}"
25109
+ /** fetch vendor details from the list of IDs */
25110
+ vendorDetails: {
25111
+ toolId: "CPgsswom7FkUYvplmy6H",
25112
+ inputs: {
25113
+ vendorIds: "${vendors|map('vendor_id')|join(',')}"
25114
+ }
25115
+ },
25116
+ /* calculate distance from user to each vendor */
25117
+ distanceMatrix: {
25118
+ toolId: "DwsbeKAxOctXSGgghvW8",
25119
+ inputs: {
25120
+ origin: "${fromCoordinates}",
25121
+ destinations: "${vendors|map('vendorCoordinates')}"
25122
+ }
24986
25123
  }
24987
25124
  },
24988
- render: ({ payload, enrichedResult }) => {
24989
- const typedPayload = payload;
24990
- const vendorData = enrichedResult?.data ?? {};
24991
- const formatLanguage = (code3) => {
24992
- const langMap = { en: "English", es: "Spanish", zh: "Chinese", fr: "French" };
24993
- return langMap[code3.trim()] || code3.trim();
24994
- };
24995
- return /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: typedPayload.vendors.map((v) => {
24996
- const data = vendorData[v.vendor_id];
24997
- const name17 = data?.names?.find((n) => n.type === "org")?.value ?? "Care Provider";
24998
- const languages = data?.languages ?? [];
24999
- const ageGroups = data?.details?.age_groups ?? [];
25000
- const services = data?.details?.services ?? [];
25001
- const address = data?.location?.formatted_address;
25002
- const hours = data?.scheduling?.hours;
25003
- return /* @__PURE__ */ jsxs7(
25004
- "div",
25005
- {
25006
- style: {
25007
- display: "flex",
25008
- flexDirection: "column",
25009
- gap: "0.5rem",
25010
- padding: "1rem",
25011
- background: "#ffffff",
25012
- border: "1px solid #e5e7eb",
25013
- borderRadius: "0.5rem",
25014
- boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1)"
25015
- },
25016
- children: [
25017
- /* @__PURE__ */ jsxs7("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
25018
- /* @__PURE__ */ jsxs7("span", { style: { fontWeight: 600, fontSize: "1rem", color: "#111827" }, children: [
25019
- v.rank ? `#${v.rank} ` : "",
25020
- name17
25021
- ] }),
25022
- hours && /* @__PURE__ */ jsx8("span", { style: { fontSize: "0.75rem", color: "#6b7280" }, children: hours })
25023
- ] }),
25024
- address && /* @__PURE__ */ jsx8("div", { style: { fontSize: "0.875rem", color: "#6b7280" }, children: address }),
25025
- services.length > 0 && /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.375rem" }, children: services.map((service) => /* @__PURE__ */ jsx8(
25026
- "span",
25027
- {
25028
- style: {
25029
- fontSize: "0.75rem",
25030
- padding: "0.125rem 0.5rem",
25031
- background: "#dbeafe",
25032
- color: "#1e40af",
25033
- borderRadius: "9999px"
25034
- },
25035
- children: service
25036
- },
25037
- service
25038
- )) }),
25039
- languages.length > 0 && /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.375rem" }, children: languages.map((lang) => /* @__PURE__ */ jsx8(
25040
- "span",
25041
- {
25042
- style: {
25043
- fontSize: "0.75rem",
25044
- padding: "0.125rem 0.5rem",
25045
- background: "#f3e8ff",
25046
- color: "#7c3aed",
25047
- borderRadius: "9999px"
25048
- },
25049
- children: formatLanguage(lang)
25050
- },
25051
- lang
25052
- )) }),
25053
- ageGroups.length > 0 && /* @__PURE__ */ jsxs7("div", { style: { fontSize: "0.75rem", color: "#6b7280" }, children: [
25054
- /* @__PURE__ */ jsx8("strong", { children: "Ages:" }),
25055
- " ",
25056
- ageGroups.join(", ")
25057
- ] }),
25058
- v.reason && /* @__PURE__ */ jsxs7("div", { style: { fontSize: "0.875rem", color: "#374151" }, children: [
25059
- /* @__PURE__ */ jsx8("strong", { children: "Why:" }),
25060
- " ",
25061
- v.reason
25062
- ] })
25063
- ]
25064
- },
25065
- v.vendor_id
25066
- );
25067
- }) });
25068
- }
25125
+ render: (payload, enriched) => /* @__PURE__ */ jsx9(
25126
+ VendorCards,
25127
+ {
25128
+ payload,
25129
+ enriched
25130
+ }
25131
+ )
25069
25132
  })
25070
25133
  ];
25071
25134
  export {