@aigentyc/chat-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +156 -0
  3. package/dist/JsonRenderResult-Ftw4AKwb.d.cts +18 -0
  4. package/dist/JsonRenderResult-Ftw4AKwb.d.ts +18 -0
  5. package/dist/JsonRenderResult-GQOYPLVH.cjs +15 -0
  6. package/dist/JsonRenderResult-GQOYPLVH.cjs.map +1 -0
  7. package/dist/JsonRenderResult-ZFJ6VWMS.js +6 -0
  8. package/dist/JsonRenderResult-ZFJ6VWMS.js.map +1 -0
  9. package/dist/SlotsContext-CBtt36al.d.ts +148 -0
  10. package/dist/SlotsContext-CHvISDJT.d.cts +148 -0
  11. package/dist/VisualizationRenderer-FNFYNN66.js +5 -0
  12. package/dist/VisualizationRenderer-FNFYNN66.js.map +1 -0
  13. package/dist/VisualizationRenderer-VKMZXRUX.cjs +20 -0
  14. package/dist/VisualizationRenderer-VKMZXRUX.cjs.map +1 -0
  15. package/dist/ai-elements.cjs +4608 -0
  16. package/dist/ai-elements.cjs.map +1 -0
  17. package/dist/ai-elements.d.cts +897 -0
  18. package/dist/ai-elements.d.ts +897 -0
  19. package/dist/ai-elements.js +4363 -0
  20. package/dist/ai-elements.js.map +1 -0
  21. package/dist/chunk-3MP2EGEJ.cjs +270 -0
  22. package/dist/chunk-3MP2EGEJ.cjs.map +1 -0
  23. package/dist/chunk-3RW7O444.js +26 -0
  24. package/dist/chunk-3RW7O444.js.map +1 -0
  25. package/dist/chunk-42ARGQXE.js +51 -0
  26. package/dist/chunk-42ARGQXE.js.map +1 -0
  27. package/dist/chunk-4FBVV64J.js +257 -0
  28. package/dist/chunk-4FBVV64J.js.map +1 -0
  29. package/dist/chunk-4QT25AXI.js +21 -0
  30. package/dist/chunk-4QT25AXI.js.map +1 -0
  31. package/dist/chunk-525KS5HM.cjs +30 -0
  32. package/dist/chunk-525KS5HM.cjs.map +1 -0
  33. package/dist/chunk-5F3O3ZJH.js +299 -0
  34. package/dist/chunk-5F3O3ZJH.js.map +1 -0
  35. package/dist/chunk-5QSXB6UL.cjs +259 -0
  36. package/dist/chunk-5QSXB6UL.cjs.map +1 -0
  37. package/dist/chunk-5T4FJ2SR.js +664 -0
  38. package/dist/chunk-5T4FJ2SR.js.map +1 -0
  39. package/dist/chunk-7BNYTOTE.cjs +67 -0
  40. package/dist/chunk-7BNYTOTE.cjs.map +1 -0
  41. package/dist/chunk-AWAJOSFP.cjs +96 -0
  42. package/dist/chunk-AWAJOSFP.cjs.map +1 -0
  43. package/dist/chunk-BKDV2H6Z.js +224 -0
  44. package/dist/chunk-BKDV2H6Z.js.map +1 -0
  45. package/dist/chunk-FQN6OBGN.cjs +171 -0
  46. package/dist/chunk-FQN6OBGN.cjs.map +1 -0
  47. package/dist/chunk-FYPJSHCL.js +190 -0
  48. package/dist/chunk-FYPJSHCL.js.map +1 -0
  49. package/dist/chunk-J2H6MLQF.cjs +680 -0
  50. package/dist/chunk-J2H6MLQF.cjs.map +1 -0
  51. package/dist/chunk-J2K7EJYP.cjs +198 -0
  52. package/dist/chunk-J2K7EJYP.cjs.map +1 -0
  53. package/dist/chunk-JI5KCSOI.cjs +23 -0
  54. package/dist/chunk-JI5KCSOI.cjs.map +1 -0
  55. package/dist/chunk-JOO6C3XT.cjs +44 -0
  56. package/dist/chunk-JOO6C3XT.cjs.map +1 -0
  57. package/dist/chunk-KBGPBUTI.cjs +78 -0
  58. package/dist/chunk-KBGPBUTI.cjs.map +1 -0
  59. package/dist/chunk-MT2AMINB.js +75 -0
  60. package/dist/chunk-MT2AMINB.js.map +1 -0
  61. package/dist/chunk-MZQKGNWF.js +4 -0
  62. package/dist/chunk-MZQKGNWF.js.map +1 -0
  63. package/dist/chunk-NG7OTWXQ.cjs +226 -0
  64. package/dist/chunk-NG7OTWXQ.cjs.map +1 -0
  65. package/dist/chunk-NPJKLYLV.js +68 -0
  66. package/dist/chunk-NPJKLYLV.js.map +1 -0
  67. package/dist/chunk-NW2ESHRV.js +685 -0
  68. package/dist/chunk-NW2ESHRV.js.map +1 -0
  69. package/dist/chunk-NWF735F5.js +1631 -0
  70. package/dist/chunk-NWF735F5.js.map +1 -0
  71. package/dist/chunk-NYQSM3EB.cjs +305 -0
  72. package/dist/chunk-NYQSM3EB.cjs.map +1 -0
  73. package/dist/chunk-OU7OROOE.cjs +1643 -0
  74. package/dist/chunk-OU7OROOE.cjs.map +1 -0
  75. package/dist/chunk-PS3U7T37.js +42 -0
  76. package/dist/chunk-PS3U7T37.js.map +1 -0
  77. package/dist/chunk-Q7T3VAJV.cjs +687 -0
  78. package/dist/chunk-Q7T3VAJV.cjs.map +1 -0
  79. package/dist/chunk-QYCEHFAB.js +265 -0
  80. package/dist/chunk-QYCEHFAB.js.map +1 -0
  81. package/dist/chunk-RPDJXB3U.js +676 -0
  82. package/dist/chunk-RPDJXB3U.js.map +1 -0
  83. package/dist/chunk-UKEL7FWS.js +64 -0
  84. package/dist/chunk-UKEL7FWS.js.map +1 -0
  85. package/dist/chunk-VS3NZ7FX.js +164 -0
  86. package/dist/chunk-VS3NZ7FX.js.map +1 -0
  87. package/dist/chunk-WZLWAVSS.cjs +73 -0
  88. package/dist/chunk-WZLWAVSS.cjs.map +1 -0
  89. package/dist/chunk-X5YEOOPK.cjs +758 -0
  90. package/dist/chunk-X5YEOOPK.cjs.map +1 -0
  91. package/dist/chunk-X7R334SB.cjs +5 -0
  92. package/dist/chunk-X7R334SB.cjs.map +1 -0
  93. package/dist/chunk-XXNDL5SJ.cjs +432 -0
  94. package/dist/chunk-XXNDL5SJ.cjs.map +1 -0
  95. package/dist/chunk-YQELMJW5.js +429 -0
  96. package/dist/chunk-YQELMJW5.js.map +1 -0
  97. package/dist/components.cjs +551 -0
  98. package/dist/components.cjs.map +1 -0
  99. package/dist/components.d.cts +181 -0
  100. package/dist/components.d.ts +181 -0
  101. package/dist/components.js +483 -0
  102. package/dist/components.js.map +1 -0
  103. package/dist/core.cjs +283 -0
  104. package/dist/core.cjs.map +1 -0
  105. package/dist/core.d.cts +455 -0
  106. package/dist/core.d.ts +455 -0
  107. package/dist/core.js +241 -0
  108. package/dist/core.js.map +1 -0
  109. package/dist/hooks.cjs +324 -0
  110. package/dist/hooks.cjs.map +1 -0
  111. package/dist/hooks.d.cts +163 -0
  112. package/dist/hooks.d.ts +163 -0
  113. package/dist/hooks.js +277 -0
  114. package/dist/hooks.js.map +1 -0
  115. package/dist/i18n.cjs +26 -0
  116. package/dist/i18n.cjs.map +1 -0
  117. package/dist/i18n.d.cts +50 -0
  118. package/dist/i18n.d.ts +50 -0
  119. package/dist/i18n.js +5 -0
  120. package/dist/i18n.js.map +1 -0
  121. package/dist/index.cjs +466 -0
  122. package/dist/index.cjs.map +1 -0
  123. package/dist/index.d.cts +80 -0
  124. package/dist/index.d.ts +80 -0
  125. package/dist/index.js +438 -0
  126. package/dist/index.js.map +1 -0
  127. package/dist/interaction-tracker-D9P1Oq4j.d.cts +83 -0
  128. package/dist/interaction-tracker-D9P1Oq4j.d.ts +83 -0
  129. package/dist/json-render.cjs +23 -0
  130. package/dist/json-render.cjs.map +1 -0
  131. package/dist/json-render.d.cts +857 -0
  132. package/dist/json-render.d.ts +857 -0
  133. package/dist/json-render.js +6 -0
  134. package/dist/json-render.js.map +1 -0
  135. package/dist/live-chat-transport-4XLOIPOE.js +4 -0
  136. package/dist/live-chat-transport-4XLOIPOE.js.map +1 -0
  137. package/dist/live-chat-transport-ALVRGWX7.cjs +13 -0
  138. package/dist/live-chat-transport-ALVRGWX7.cjs.map +1 -0
  139. package/dist/select-B4l9yoyn.d.cts +99 -0
  140. package/dist/select-B4l9yoyn.d.ts +99 -0
  141. package/dist/styles.css +2 -0
  142. package/dist/theme.cjs +18 -0
  143. package/dist/theme.cjs.map +1 -0
  144. package/dist/theme.d.cts +55 -0
  145. package/dist/theme.d.ts +55 -0
  146. package/dist/theme.js +5 -0
  147. package/dist/theme.js.map +1 -0
  148. package/dist/tools.cjs +32 -0
  149. package/dist/tools.cjs.map +1 -0
  150. package/dist/tools.d.cts +117 -0
  151. package/dist/tools.d.ts +117 -0
  152. package/dist/tools.js +11 -0
  153. package/dist/tools.js.map +1 -0
  154. package/dist/types-DKJ_-nbG.d.cts +349 -0
  155. package/dist/types-DKJ_-nbG.d.ts +349 -0
  156. package/dist/ui.cjs +667 -0
  157. package/dist/ui.cjs.map +1 -0
  158. package/dist/ui.d.cts +95 -0
  159. package/dist/ui.d.ts +95 -0
  160. package/dist/ui.js +414 -0
  161. package/dist/ui.js.map +1 -0
  162. package/package.json +255 -0
@@ -0,0 +1,680 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var chunkQ7T3VAJV_cjs = require('./chunk-Q7T3VAJV.cjs');
5
+ var react = require('@json-render/react');
6
+ var react$1 = require('react');
7
+ var shadcn = require('@json-render/shadcn');
8
+ var core = require('@json-render/core');
9
+ var schema = require('@json-render/react/schema');
10
+ var catalog$1 = require('@json-render/shadcn/catalog');
11
+ var zod = require('zod');
12
+ var jsxRuntime = require('react/jsx-runtime');
13
+
14
+ var seriesSchema = zod.z.object({
15
+ dataKey: zod.z.string(),
16
+ label: zod.z.string(),
17
+ color: zod.z.string().nullable().optional(),
18
+ type: zod.z.enum(["line", "bar", "area"]).nullable().optional()
19
+ });
20
+ var chartConfigSchema = zod.z.object({
21
+ xAxis: zod.z.string().nullable().optional(),
22
+ series: zod.z.array(seriesSchema),
23
+ showGrid: zod.z.boolean().nullable().optional(),
24
+ showLegend: zod.z.boolean().nullable().optional(),
25
+ stacked: zod.z.boolean().nullable().optional(),
26
+ valueFormatter: zod.z.enum(["currency", "percent", "number", "compact"]).nullable().optional()
27
+ });
28
+ var chartBaseProps = {
29
+ title: zod.z.string().nullable().optional(),
30
+ description: zod.z.string().nullable().optional(),
31
+ data: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown())),
32
+ config: chartConfigSchema,
33
+ height: zod.z.number().nullable().optional()
34
+ };
35
+ var catalog = core.defineCatalog(schema.schema, {
36
+ components: {
37
+ // ── Layout ──────────────────────────────────────────────
38
+ Card: catalog$1.shadcnComponentDefinitions.Card,
39
+ Stack: catalog$1.shadcnComponentDefinitions.Stack,
40
+ Grid: catalog$1.shadcnComponentDefinitions.Grid,
41
+ Separator: catalog$1.shadcnComponentDefinitions.Separator,
42
+ Tabs: catalog$1.shadcnComponentDefinitions.Tabs,
43
+ Accordion: catalog$1.shadcnComponentDefinitions.Accordion,
44
+ Collapsible: catalog$1.shadcnComponentDefinitions.Collapsible,
45
+ Dialog: catalog$1.shadcnComponentDefinitions.Dialog,
46
+ Drawer: catalog$1.shadcnComponentDefinitions.Drawer,
47
+ Carousel: catalog$1.shadcnComponentDefinitions.Carousel,
48
+ // ── Typography ──────────────────────────────────────────
49
+ Heading: catalog$1.shadcnComponentDefinitions.Heading,
50
+ Text: catalog$1.shadcnComponentDefinitions.Text,
51
+ Badge: catalog$1.shadcnComponentDefinitions.Badge,
52
+ Link: catalog$1.shadcnComponentDefinitions.Link,
53
+ Alert: catalog$1.shadcnComponentDefinitions.Alert,
54
+ // ── Media ───────────────────────────────────────────────
55
+ Image: catalog$1.shadcnComponentDefinitions.Image,
56
+ Avatar: catalog$1.shadcnComponentDefinitions.Avatar,
57
+ // ── Data ────────────────────────────────────────────────
58
+ Table: catalog$1.shadcnComponentDefinitions.Table,
59
+ // ── Charts & Visualization ────────────────────────────
60
+ LineChart: {
61
+ props: zod.z.object(chartBaseProps),
62
+ description: "Line chart for trends over time. Provide data array + config.xAxis + config.series.",
63
+ example: {
64
+ title: "Monthly Sales",
65
+ data: [{ month: "Jan", sales: 100 }, { month: "Feb", sales: 150 }],
66
+ config: { xAxis: "month", series: [{ dataKey: "sales", label: "Sales" }] }
67
+ }
68
+ },
69
+ BarChart: {
70
+ props: zod.z.object(chartBaseProps),
71
+ description: "Bar chart for comparing categories. Provide data array + config.xAxis + config.series.",
72
+ example: {
73
+ title: "Product Comparison",
74
+ data: [{ product: "A", revenue: 500 }, { product: "B", revenue: 300 }],
75
+ config: { xAxis: "product", series: [{ dataKey: "revenue", label: "Revenue" }] }
76
+ }
77
+ },
78
+ PieChart: {
79
+ props: zod.z.object({
80
+ title: zod.z.string().nullable().optional(),
81
+ description: zod.z.string().nullable().optional(),
82
+ data: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown())),
83
+ dataKey: zod.z.string(),
84
+ nameKey: zod.z.string().nullable().optional(),
85
+ height: zod.z.number().nullable().optional()
86
+ }),
87
+ description: "Pie chart for proportional breakdown. Each data item needs a name and a value field.",
88
+ example: {
89
+ title: "Market Share",
90
+ data: [{ name: "Product A", value: 60 }, { name: "Product B", value: 40 }],
91
+ dataKey: "value",
92
+ nameKey: "name"
93
+ }
94
+ },
95
+ AreaChart: {
96
+ props: zod.z.object(chartBaseProps),
97
+ description: "Area chart for cumulative values over time with gradient fills.",
98
+ example: {
99
+ title: "Traffic Volume",
100
+ data: [{ day: "Mon", visits: 200 }, { day: "Tue", visits: 350 }],
101
+ config: { xAxis: "day", series: [{ dataKey: "visits", label: "Visits" }] }
102
+ }
103
+ },
104
+ MetricCards: {
105
+ props: zod.z.object({
106
+ title: zod.z.string().nullable().optional(),
107
+ metrics: zod.z.array(
108
+ zod.z.object({
109
+ label: zod.z.string(),
110
+ value: zod.z.string(),
111
+ unit: zod.z.string().nullable().optional(),
112
+ trend: zod.z.string().nullable().optional(),
113
+ trendDirection: zod.z.enum(["up", "down", "neutral"]).nullable().optional(),
114
+ description: zod.z.string().nullable().optional()
115
+ })
116
+ )
117
+ }),
118
+ description: "KPI metric cards grid with big numbers and optional trend indicators.",
119
+ example: {
120
+ metrics: [
121
+ { label: "Revenue", value: "$1.2M", trend: "+12%", trendDirection: "up" },
122
+ { label: "Users", value: "45K", trend: "-3%", trendDirection: "down" }
123
+ ]
124
+ }
125
+ },
126
+ ComparisonTable: {
127
+ props: zod.z.object({
128
+ title: zod.z.string().nullable().optional(),
129
+ items: zod.z.array(
130
+ zod.z.object({
131
+ name: zod.z.string(),
132
+ highlight: zod.z.boolean().nullable().optional(),
133
+ features: zod.z.record(zod.z.string(), zod.z.union([zod.z.string(), zod.z.boolean(), zod.z.number()]))
134
+ })
135
+ ),
136
+ fields: zod.z.array(
137
+ zod.z.object({
138
+ key: zod.z.string(),
139
+ label: zod.z.string(),
140
+ type: zod.z.enum(["text", "boolean", "rating"]).nullable().optional()
141
+ })
142
+ )
143
+ }),
144
+ description: "Side-by-side comparison table. Items are columns, fields are rows.",
145
+ example: {
146
+ title: "Plan Comparison",
147
+ items: [
148
+ { name: "Basic", features: { price: "$9/mo", storage: "10GB", support: true } },
149
+ { name: "Pro", highlight: true, features: { price: "$29/mo", storage: "100GB", support: true } }
150
+ ],
151
+ fields: [
152
+ { key: "price", label: "Price", type: "text" },
153
+ { key: "storage", label: "Storage", type: "text" },
154
+ { key: "support", label: "Support", type: "boolean" }
155
+ ]
156
+ }
157
+ },
158
+ Timeline: {
159
+ props: zod.z.object({
160
+ title: zod.z.string().nullable().optional(),
161
+ events: zod.z.array(
162
+ zod.z.object({
163
+ date: zod.z.string().nullable().optional(),
164
+ title: zod.z.string(),
165
+ description: zod.z.string().nullable().optional(),
166
+ status: zod.z.enum(["completed", "current", "upcoming"]).nullable().optional()
167
+ })
168
+ )
169
+ }),
170
+ description: "Vertical timeline for chronological events or process steps.",
171
+ example: {
172
+ events: [
173
+ { title: "Order Placed", date: "Jan 1", status: "completed" },
174
+ { title: "Shipped", date: "Jan 3", status: "current" },
175
+ { title: "Delivered", status: "upcoming" }
176
+ ]
177
+ }
178
+ },
179
+ ProgressBars: {
180
+ props: zod.z.object({
181
+ title: zod.z.string().nullable().optional(),
182
+ goals: zod.z.array(
183
+ zod.z.object({
184
+ label: zod.z.string(),
185
+ current: zod.z.number(),
186
+ target: zod.z.number(),
187
+ unit: zod.z.string().nullable().optional()
188
+ })
189
+ )
190
+ }),
191
+ description: "Progress bars for goal tracking with current/target values.",
192
+ example: {
193
+ goals: [
194
+ { label: "Revenue", current: 75e3, target: 1e5, unit: "$" },
195
+ { label: "Users", current: 800, target: 1e3 }
196
+ ]
197
+ }
198
+ },
199
+ // ── Form ────────────────────────────────────────────────
200
+ Input: catalog$1.shadcnComponentDefinitions.Input,
201
+ Textarea: catalog$1.shadcnComponentDefinitions.Textarea,
202
+ Select: catalog$1.shadcnComponentDefinitions.Select,
203
+ Checkbox: catalog$1.shadcnComponentDefinitions.Checkbox,
204
+ Radio: catalog$1.shadcnComponentDefinitions.Radio,
205
+ Switch: catalog$1.shadcnComponentDefinitions.Switch,
206
+ Slider: catalog$1.shadcnComponentDefinitions.Slider,
207
+ Button: catalog$1.shadcnComponentDefinitions.Button,
208
+ ButtonGroup: catalog$1.shadcnComponentDefinitions.ButtonGroup,
209
+ Toggle: catalog$1.shadcnComponentDefinitions.Toggle,
210
+ ToggleGroup: catalog$1.shadcnComponentDefinitions.ToggleGroup,
211
+ DropdownMenu: catalog$1.shadcnComponentDefinitions.DropdownMenu,
212
+ // ── Feedback ────────────────────────────────────────────
213
+ Progress: catalog$1.shadcnComponentDefinitions.Progress,
214
+ Spinner: catalog$1.shadcnComponentDefinitions.Spinner,
215
+ Skeleton: catalog$1.shadcnComponentDefinitions.Skeleton,
216
+ Tooltip: catalog$1.shadcnComponentDefinitions.Tooltip,
217
+ Popover: catalog$1.shadcnComponentDefinitions.Popover,
218
+ // ── Navigation ──────────────────────────────────────────
219
+ Pagination: catalog$1.shadcnComponentDefinitions.Pagination
220
+ },
221
+ actions: {
222
+ navigate_url: {
223
+ params: zod.z.object({
224
+ url: zod.z.string(),
225
+ target: zod.z.enum(["_self", "_blank"]).default("_blank")
226
+ }),
227
+ description: "Open a URL in a new tab or the current tab."
228
+ },
229
+ send_message: {
230
+ params: zod.z.object({
231
+ message: zod.z.string()
232
+ }),
233
+ description: "Send a follow-up chat message on behalf of the user."
234
+ },
235
+ call_api: {
236
+ params: zod.z.object({
237
+ endpoint: zod.z.string(),
238
+ method: zod.z.enum(["GET", "POST", "PUT", "DELETE"]).default("POST"),
239
+ body: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
240
+ }),
241
+ description: "Make a proxied API call through the platform backend."
242
+ }
243
+ }
244
+ });
245
+ var { registry, handlers: createActionHandlers } = react.defineRegistry(
246
+ catalog,
247
+ {
248
+ components: {
249
+ // ── Layout ──────────────────────────────────────────────
250
+ Card: (p) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full [&>div]:border-0 [&>div]:shadow-none", children: shadcn.shadcnComponents.Card(p) }),
251
+ Stack: shadcn.shadcnComponents.Stack,
252
+ Grid: shadcn.shadcnComponents.Grid,
253
+ Separator: shadcn.shadcnComponents.Separator,
254
+ Tabs: shadcn.shadcnComponents.Tabs,
255
+ Accordion: shadcn.shadcnComponents.Accordion,
256
+ Collapsible: shadcn.shadcnComponents.Collapsible,
257
+ Dialog: shadcn.shadcnComponents.Dialog,
258
+ Drawer: shadcn.shadcnComponents.Drawer,
259
+ Carousel: shadcn.shadcnComponents.Carousel,
260
+ // ── Typography ──────────────────────────────────────────
261
+ Heading: shadcn.shadcnComponents.Heading,
262
+ Text: shadcn.shadcnComponents.Text,
263
+ Badge: shadcn.shadcnComponents.Badge,
264
+ Link: shadcn.shadcnComponents.Link,
265
+ Alert: shadcn.shadcnComponents.Alert,
266
+ // ── Media ───────────────────────────────────────────────
267
+ Image: shadcn.shadcnComponents.Image,
268
+ Avatar: shadcn.shadcnComponents.Avatar,
269
+ // ── Data ────────────────────────────────────────────────
270
+ Table: shadcn.shadcnComponents.Table,
271
+ // ── Charts & Visualization ────────────────────────────
272
+ LineChart: ({ props }) => /* @__PURE__ */ jsxRuntime.jsx(
273
+ chunkQ7T3VAJV_cjs.VisualizationRenderer,
274
+ {
275
+ spec: {
276
+ type: "line_chart",
277
+ title: props.title ?? void 0,
278
+ description: props.description ?? void 0,
279
+ data: props.data,
280
+ config: {
281
+ xAxis: props.config?.xAxis ?? void 0,
282
+ series: props.config?.series?.map((s) => ({
283
+ dataKey: s.dataKey,
284
+ label: s.label,
285
+ color: s.color ?? void 0
286
+ })),
287
+ showGrid: props.config?.showGrid ?? void 0,
288
+ showLegend: props.config?.showLegend ?? void 0,
289
+ stacked: props.config?.stacked ?? void 0,
290
+ valueFormatter: props.config?.valueFormatter ?? void 0
291
+ }
292
+ }
293
+ }
294
+ ),
295
+ BarChart: ({ props }) => /* @__PURE__ */ jsxRuntime.jsx(
296
+ chunkQ7T3VAJV_cjs.VisualizationRenderer,
297
+ {
298
+ spec: {
299
+ type: "bar_chart",
300
+ title: props.title ?? void 0,
301
+ description: props.description ?? void 0,
302
+ data: props.data,
303
+ config: {
304
+ xAxis: props.config?.xAxis ?? void 0,
305
+ series: props.config?.series?.map((s) => ({
306
+ dataKey: s.dataKey,
307
+ label: s.label,
308
+ color: s.color ?? void 0
309
+ })),
310
+ showGrid: props.config?.showGrid ?? void 0,
311
+ showLegend: props.config?.showLegend ?? void 0,
312
+ stacked: props.config?.stacked ?? void 0,
313
+ valueFormatter: props.config?.valueFormatter ?? void 0
314
+ }
315
+ }
316
+ }
317
+ ),
318
+ PieChart: ({ props }) => /* @__PURE__ */ jsxRuntime.jsx(
319
+ chunkQ7T3VAJV_cjs.VisualizationRenderer,
320
+ {
321
+ spec: {
322
+ type: "pie_chart",
323
+ title: props.title ?? void 0,
324
+ description: props.description ?? void 0,
325
+ data: props.data,
326
+ config: {
327
+ series: [{ dataKey: props.dataKey, label: props.dataKey }]
328
+ }
329
+ }
330
+ }
331
+ ),
332
+ AreaChart: ({ props }) => /* @__PURE__ */ jsxRuntime.jsx(
333
+ chunkQ7T3VAJV_cjs.VisualizationRenderer,
334
+ {
335
+ spec: {
336
+ type: "area_chart",
337
+ title: props.title ?? void 0,
338
+ description: props.description ?? void 0,
339
+ data: props.data,
340
+ config: {
341
+ xAxis: props.config?.xAxis ?? void 0,
342
+ series: props.config?.series?.map((s) => ({
343
+ dataKey: s.dataKey,
344
+ label: s.label,
345
+ color: s.color ?? void 0
346
+ })),
347
+ showGrid: props.config?.showGrid ?? void 0,
348
+ showLegend: props.config?.showLegend ?? void 0,
349
+ stacked: props.config?.stacked ?? void 0,
350
+ valueFormatter: props.config?.valueFormatter ?? void 0
351
+ }
352
+ }
353
+ }
354
+ ),
355
+ MetricCards: ({ props }) => /* @__PURE__ */ jsxRuntime.jsx(
356
+ chunkQ7T3VAJV_cjs.VisualizationRenderer,
357
+ {
358
+ spec: {
359
+ type: "metric_cards",
360
+ title: props.title ?? void 0,
361
+ metrics: props.metrics?.map((m) => ({
362
+ label: m.label,
363
+ value: m.value,
364
+ unit: m.unit ?? void 0,
365
+ trend: m.trend ?? void 0,
366
+ trendDirection: m.trendDirection ?? void 0,
367
+ description: m.description ?? void 0
368
+ }))
369
+ }
370
+ }
371
+ ),
372
+ ComparisonTable: ({ props }) => /* @__PURE__ */ jsxRuntime.jsx(
373
+ chunkQ7T3VAJV_cjs.VisualizationRenderer,
374
+ {
375
+ spec: {
376
+ type: "comparison",
377
+ title: props.title ?? void 0,
378
+ items: props.items?.map((item) => ({
379
+ name: item.name,
380
+ highlight: item.highlight ?? void 0,
381
+ features: item.features
382
+ })),
383
+ comparisonFields: props.fields?.map((f) => ({
384
+ key: f.key,
385
+ label: f.label,
386
+ type: f.type ?? void 0
387
+ }))
388
+ }
389
+ }
390
+ ),
391
+ Timeline: ({ props }) => /* @__PURE__ */ jsxRuntime.jsx(
392
+ chunkQ7T3VAJV_cjs.VisualizationRenderer,
393
+ {
394
+ spec: {
395
+ type: "timeline",
396
+ title: props.title ?? void 0,
397
+ events: props.events?.map((e) => ({
398
+ date: e.date ?? void 0,
399
+ title: e.title,
400
+ description: e.description ?? void 0,
401
+ status: e.status ?? void 0
402
+ }))
403
+ }
404
+ }
405
+ ),
406
+ ProgressBars: ({ props }) => /* @__PURE__ */ jsxRuntime.jsx(
407
+ chunkQ7T3VAJV_cjs.VisualizationRenderer,
408
+ {
409
+ spec: {
410
+ type: "progress",
411
+ title: props.title ?? void 0,
412
+ goals: props.goals?.map((g) => ({
413
+ label: g.label,
414
+ current: g.current,
415
+ target: g.target,
416
+ unit: g.unit ?? void 0
417
+ }))
418
+ }
419
+ }
420
+ ),
421
+ // ── Form (wrapped with w-full for proper layout) ────────
422
+ Input: (p) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: shadcn.shadcnComponents.Input(p) }),
423
+ Textarea: (p) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: shadcn.shadcnComponents.Textarea(p) }),
424
+ Select: (p) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: shadcn.shadcnComponents.Select(p) }),
425
+ Checkbox: shadcn.shadcnComponents.Checkbox,
426
+ Radio: shadcn.shadcnComponents.Radio,
427
+ Switch: shadcn.shadcnComponents.Switch,
428
+ Slider: shadcn.shadcnComponents.Slider,
429
+ Button: shadcn.shadcnComponents.Button,
430
+ ButtonGroup: shadcn.shadcnComponents.ButtonGroup,
431
+ Toggle: shadcn.shadcnComponents.Toggle,
432
+ ToggleGroup: shadcn.shadcnComponents.ToggleGroup,
433
+ DropdownMenu: shadcn.shadcnComponents.DropdownMenu,
434
+ // ── Feedback ────────────────────────────────────────────
435
+ Progress: shadcn.shadcnComponents.Progress,
436
+ Spinner: shadcn.shadcnComponents.Spinner,
437
+ Skeleton: shadcn.shadcnComponents.Skeleton,
438
+ Tooltip: shadcn.shadcnComponents.Tooltip,
439
+ Popover: shadcn.shadcnComponents.Popover,
440
+ // ── Navigation ──────────────────────────────────────────
441
+ Pagination: shadcn.shadcnComponents.Pagination
442
+ },
443
+ actions: {
444
+ navigate_url: async (params) => {
445
+ if (params?.url) {
446
+ window.open(params.url, params.target ?? "_blank");
447
+ }
448
+ },
449
+ send_message: async (params) => {
450
+ console.log("[json-render] send_message action:", params?.message);
451
+ },
452
+ call_api: async (params) => {
453
+ const p = params;
454
+ const url = p?.endpoint || p?.url;
455
+ if (!url) {
456
+ console.warn("[json-render] call_api: missing endpoint/url");
457
+ return;
458
+ }
459
+ const method = (params?.method || "POST").toUpperCase();
460
+ try {
461
+ const res = await fetch(url, {
462
+ method,
463
+ headers: { "Content-Type": "application/json" },
464
+ ...method !== "GET" && params?.body ? { body: JSON.stringify(params.body) } : {}
465
+ });
466
+ const data = await res.json().catch(() => null);
467
+ console.log("[json-render] call_api response:", res.status, data);
468
+ return data;
469
+ } catch (err) {
470
+ console.error("[json-render] call_api error:", err);
471
+ }
472
+ }
473
+ }
474
+ }
475
+ );
476
+ function normalizeSpec(raw) {
477
+ if (typeof raw.root === "string" && raw.elements) {
478
+ return raw;
479
+ }
480
+ const elements = {};
481
+ for (const [key, value] of Object.entries(raw)) {
482
+ if (value && typeof value === "object" && "type" in value) {
483
+ elements[key] = value;
484
+ }
485
+ }
486
+ return { root: "root", elements };
487
+ }
488
+ function extractSpecState(raw) {
489
+ const state = raw.state;
490
+ if (!state || typeof state !== "object") return {};
491
+ const result = {};
492
+ function walk(obj, prefix) {
493
+ for (const [key, value] of Object.entries(obj)) {
494
+ const path = `${prefix}/${key}`;
495
+ result[path] = value;
496
+ if (value && typeof value === "object" && !Array.isArray(value)) {
497
+ walk(value, path);
498
+ }
499
+ }
500
+ }
501
+ walk(state, "");
502
+ return result;
503
+ }
504
+ function deepResolve(value, stateMap) {
505
+ if (value === null || value === void 0) return value;
506
+ if (typeof value === "object" && !Array.isArray(value)) {
507
+ const obj = value;
508
+ if (Object.keys(obj).length === 1 && typeof obj.$state === "string") {
509
+ return stateMap[obj.$state];
510
+ }
511
+ const resolved = {};
512
+ for (const [key, val] of Object.entries(obj)) {
513
+ resolved[key] = deepResolve(val, stateMap);
514
+ }
515
+ return resolved;
516
+ }
517
+ if (Array.isArray(value)) {
518
+ return value.map((item) => deepResolve(item, stateMap));
519
+ }
520
+ return value;
521
+ }
522
+ function JsonRenderResult({
523
+ spec: rawSpec,
524
+ data,
525
+ onSendMessage,
526
+ className,
527
+ conversationMessages,
528
+ apiKey
529
+ }) {
530
+ const rawSpecObj = rawSpec;
531
+ const spec = react$1.useMemo(() => normalizeSpec(rawSpecObj), [rawSpecObj]);
532
+ const formConfig = react$1.useMemo(
533
+ () => rawSpecObj._formConfig || null,
534
+ [rawSpecObj]
535
+ );
536
+ const initialState = react$1.useMemo(() => {
537
+ const specState = extractSpecState(rawSpecObj);
538
+ return {
539
+ "/data": data,
540
+ ...conversationMessages ? { "/conversationMessages": conversationMessages } : {},
541
+ ...specState
542
+ };
543
+ }, [data, rawSpecObj, conversationMessages]);
544
+ const stateRef = react$1.useRef(initialState);
545
+ const validateRef = react$1.useRef(null);
546
+ const handleStateChange = react$1.useCallback(
547
+ (changes) => {
548
+ for (const { path, value } of changes) {
549
+ stateRef.current[path] = value;
550
+ }
551
+ },
552
+ []
553
+ );
554
+ const handlers = react$1.useMemo(
555
+ () => ({
556
+ navigate_url: async (params) => {
557
+ if (params?.url) {
558
+ window.open(
559
+ params.url,
560
+ params.target ?? "_blank"
561
+ );
562
+ }
563
+ },
564
+ send_message: async (params) => {
565
+ if (onSendMessage && params?.message && typeof params.message === "string") {
566
+ onSendMessage(params.message);
567
+ }
568
+ },
569
+ call_api: async (params) => {
570
+ if (validateRef.current) {
571
+ const isValid = validateRef.current();
572
+ if (!isValid) {
573
+ throw new Error("Validation failed");
574
+ }
575
+ }
576
+ const resolved = deepResolve(
577
+ params,
578
+ stateRef.current
579
+ );
580
+ const url = resolved?.endpoint || resolved?.url;
581
+ if (!url) {
582
+ throw new Error("Missing endpoint/url in call_api params");
583
+ }
584
+ const method = (resolved?.method || "POST").toUpperCase();
585
+ const headers = {
586
+ "Content-Type": "application/json"
587
+ };
588
+ if (apiKey) {
589
+ headers.Authorization = `Bearer ${apiKey}`;
590
+ }
591
+ const res = await fetch(url, {
592
+ method,
593
+ headers,
594
+ credentials: "include",
595
+ ...method !== "GET" && resolved?.body ? { body: JSON.stringify(resolved.body) } : {}
596
+ });
597
+ if (!res.ok) {
598
+ const errBody = await res.text().catch(() => "");
599
+ throw new Error(
600
+ errBody || `Request failed with status ${res.status}`
601
+ );
602
+ }
603
+ const responseData = await res.json().catch(() => null);
604
+ return responseData;
605
+ }
606
+ }),
607
+ [onSendMessage, apiKey]
608
+ );
609
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsxs(
610
+ react.JSONUIProvider,
611
+ {
612
+ registry,
613
+ initialState,
614
+ handlers,
615
+ onStateChange: handleStateChange,
616
+ children: [
617
+ /* @__PURE__ */ jsxRuntime.jsx(ValidationBridge, { validateRef }),
618
+ formConfig ? /* @__PURE__ */ jsxRuntime.jsx(FormFeedbackWrapper, { formConfig, children: /* @__PURE__ */ jsxRuntime.jsx(react.Renderer, { spec, registry }) }) : /* @__PURE__ */ jsxRuntime.jsx(react.Renderer, { spec, registry })
619
+ ]
620
+ }
621
+ ) });
622
+ }
623
+ function FormFeedbackWrapper({
624
+ formConfig,
625
+ children
626
+ }) {
627
+ const formSubmitted = react.useStateValue("/formSubmitted");
628
+ const formError = react.useStateValue("/formError");
629
+ const isSubmitted = formSubmitted === true;
630
+ const hasError = !!formError && formError !== "" && formError !== false;
631
+ if (isSubmitted && formConfig.hideFormAfter) {
632
+ return /* @__PURE__ */ jsxRuntime.jsx(
633
+ "div",
634
+ {
635
+ className: "rounded-lg border border-green-200 bg-green-50 p-4 dark:border-green-800 dark:bg-green-950/30",
636
+ role: "alert",
637
+ children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-green-800 dark:text-green-200", children: formConfig.successMessage || "Submitted successfully!" })
638
+ }
639
+ );
640
+ }
641
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
642
+ isSubmitted && formConfig.successMessage && /* @__PURE__ */ jsxRuntime.jsx(
643
+ "div",
644
+ {
645
+ className: "rounded-lg border border-green-200 bg-green-50 p-3 mb-3 dark:border-green-800 dark:bg-green-950/30",
646
+ role: "alert",
647
+ children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-green-800 dark:text-green-200", children: formConfig.successMessage })
648
+ }
649
+ ),
650
+ hasError && formConfig.errorMessage && /* @__PURE__ */ jsxRuntime.jsx(
651
+ "div",
652
+ {
653
+ className: "rounded-lg border border-red-200 bg-red-50 p-3 mb-3 dark:border-red-800 dark:bg-red-950/30",
654
+ role: "alert",
655
+ children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-red-800 dark:text-red-200", children: formConfig.errorMessage })
656
+ }
657
+ ),
658
+ children
659
+ ] });
660
+ }
661
+ function ValidationBridge({
662
+ validateRef
663
+ }) {
664
+ const validation = react.useValidation();
665
+ react$1.useEffect(() => {
666
+ if (validation?.validateAll) {
667
+ validateRef.current = () => validation.validateAll();
668
+ }
669
+ return () => {
670
+ validateRef.current = null;
671
+ };
672
+ }, [validation, validateRef]);
673
+ return null;
674
+ }
675
+
676
+ exports.JsonRenderResult = JsonRenderResult;
677
+ exports.catalog = catalog;
678
+ exports.registry = registry;
679
+ //# sourceMappingURL=chunk-J2H6MLQF.cjs.map
680
+ //# sourceMappingURL=chunk-J2H6MLQF.cjs.map