chat 3.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vercel, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # chat
2
+
3
+ A unified SDK for building chat bots across Slack, Microsoft Teams, and Google Chat.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install chat
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { Chat, emoji } from "chat";
15
+ import { createSlackAdapter } from "@chat-adapter/slack";
16
+ import { createRedisState } from "@chat-adapter/state-redis";
17
+
18
+ const bot = new Chat({
19
+ userName: "mybot",
20
+ adapters: {
21
+ slack: createSlackAdapter({
22
+ botToken: process.env.SLACK_BOT_TOKEN!,
23
+ signingSecret: process.env.SLACK_SIGNING_SECRET!,
24
+ }),
25
+ },
26
+ state: createRedisState({ url: process.env.REDIS_URL! }),
27
+ });
28
+
29
+ // Handle @mentions
30
+ bot.onNewMention(async (thread) => {
31
+ await thread.subscribe();
32
+ await thread.post(`${emoji.wave} Hello! I'm listening.`);
33
+ });
34
+
35
+ // Handle follow-up messages
36
+ bot.onSubscribedMessage(async (thread, message) => {
37
+ await thread.post(`You said: ${message.text}`);
38
+ });
39
+ ```
40
+
41
+ ## Adapters
42
+
43
+ | Package | Platform |
44
+ |---------|----------|
45
+ | [@chat-adapter/slack](https://github.com/vercel-labs/chat/tree/main/packages/adapter-slack) | Slack |
46
+ | [@chat-adapter/teams](https://github.com/vercel-labs/chat/tree/main/packages/adapter-teams) | Microsoft Teams |
47
+ | [@chat-adapter/gchat](https://github.com/vercel-labs/chat/tree/main/packages/adapter-gchat) | Google Chat |
48
+
49
+ ## State Adapters
50
+
51
+ | Package | Backend |
52
+ |---------|---------|
53
+ | [@chat-adapter/state-redis](https://github.com/vercel-labs/chat/tree/main/packages/state-redis) | Redis (production) |
54
+ | [@chat-adapter/state-ioredis](https://github.com/vercel-labs/chat/tree/main/packages/state-ioredis) | Redis via ioredis |
55
+ | [@chat-adapter/state-memory](https://github.com/vercel-labs/chat/tree/main/packages/state-memory) | In-memory (dev only) |
56
+
57
+ ## Features
58
+
59
+ - **Multi-platform**: Write once, deploy to Slack, Teams, and Google Chat
60
+ - **Thread subscriptions**: Follow conversations after @mentions
61
+ - **Rich cards**: JSX-based cards that convert to Block Kit, Adaptive Cards, etc.
62
+ - **Action callbacks**: Handle button clicks across platforms
63
+ - **Reactions**: Type-safe emoji with cross-platform normalization
64
+ - **File uploads**: Send files with messages
65
+ - **Direct messages**: Initiate DMs programmatically
66
+ - **Serverless-ready**: Pluggable state backends for distributed deployments
67
+
68
+ ## Documentation
69
+
70
+ See the [main repository](https://github.com/vercel-labs/chat) for full documentation.
71
+
72
+ ## License
73
+
74
+ MIT
@@ -0,0 +1,356 @@
1
+ // src/cards.ts
2
+ function isCardElement(value) {
3
+ return typeof value === "object" && value !== null && "type" in value && value.type === "card";
4
+ }
5
+ function Card(options = {}) {
6
+ return {
7
+ type: "card",
8
+ title: options.title,
9
+ subtitle: options.subtitle,
10
+ imageUrl: options.imageUrl,
11
+ children: options.children ?? []
12
+ };
13
+ }
14
+ function Text(content, options = {}) {
15
+ return {
16
+ type: "text",
17
+ content,
18
+ style: options.style
19
+ };
20
+ }
21
+ var CardText = Text;
22
+ function Image(options) {
23
+ return {
24
+ type: "image",
25
+ url: options.url,
26
+ alt: options.alt
27
+ };
28
+ }
29
+ function Divider() {
30
+ return { type: "divider" };
31
+ }
32
+ function Section(children) {
33
+ return {
34
+ type: "section",
35
+ children
36
+ };
37
+ }
38
+ function Actions(children) {
39
+ return {
40
+ type: "actions",
41
+ children
42
+ };
43
+ }
44
+ function Button(options) {
45
+ return {
46
+ type: "button",
47
+ id: options.id,
48
+ label: options.label,
49
+ style: options.style,
50
+ value: options.value
51
+ };
52
+ }
53
+ function Field(options) {
54
+ return {
55
+ type: "field",
56
+ label: options.label,
57
+ value: options.value
58
+ };
59
+ }
60
+ function Fields(children) {
61
+ return {
62
+ type: "fields",
63
+ children
64
+ };
65
+ }
66
+ function isReactElement(value) {
67
+ if (typeof value !== "object" || value === null) {
68
+ return false;
69
+ }
70
+ const maybeElement = value;
71
+ if (typeof maybeElement.$$typeof !== "symbol") {
72
+ return false;
73
+ }
74
+ const symbolStr = maybeElement.$$typeof.toString();
75
+ return symbolStr.includes("react.element") || symbolStr.includes("react.transitional.element");
76
+ }
77
+ var componentMap = /* @__PURE__ */ new Map([
78
+ [Card, "Card"],
79
+ [Text, "Text"],
80
+ [Image, "Image"],
81
+ [Divider, "Divider"],
82
+ [Section, "Section"],
83
+ [Actions, "Actions"],
84
+ [Button, "Button"],
85
+ [Field, "Field"],
86
+ [Fields, "Fields"]
87
+ ]);
88
+ function fromReactElement(element) {
89
+ if (!isReactElement(element)) {
90
+ if (isCardElement(element)) {
91
+ return element;
92
+ }
93
+ if (typeof element === "object" && element !== null && "type" in element) {
94
+ return element;
95
+ }
96
+ return null;
97
+ }
98
+ const { type, props } = element;
99
+ const componentName = componentMap.get(type);
100
+ if (!componentName) {
101
+ if (typeof type === "string") {
102
+ throw new Error(
103
+ `HTML element <${type}> is not supported in card elements. Use Card, Text, Section, Actions, Button, Fields, Field, Image, or Divider components instead.`
104
+ );
105
+ }
106
+ if (props.children) {
107
+ return convertChildren(props.children)[0] ?? null;
108
+ }
109
+ return null;
110
+ }
111
+ const convertedChildren = props.children ? convertChildren(props.children) : [];
112
+ const isCardChild = (el) => el.type !== "card" && el.type !== "button" && el.type !== "field";
113
+ switch (componentName) {
114
+ case "Card":
115
+ return Card({
116
+ title: props.title,
117
+ subtitle: props.subtitle,
118
+ imageUrl: props.imageUrl,
119
+ children: convertedChildren.filter(isCardChild)
120
+ });
121
+ case "Text": {
122
+ const content = extractTextContent(props.children);
123
+ return Text(content, { style: props.style });
124
+ }
125
+ case "Image":
126
+ return Image({
127
+ url: props.url,
128
+ alt: props.alt
129
+ });
130
+ case "Divider":
131
+ return Divider();
132
+ case "Section":
133
+ return Section(convertedChildren.filter(isCardChild));
134
+ case "Actions":
135
+ return Actions(
136
+ convertedChildren.filter(
137
+ (c) => c.type === "button"
138
+ )
139
+ );
140
+ case "Button": {
141
+ const label = extractTextContent(props.children);
142
+ return Button({
143
+ id: props.id,
144
+ label: props.label ?? label,
145
+ style: props.style,
146
+ value: props.value
147
+ });
148
+ }
149
+ case "Field":
150
+ return Field({
151
+ label: props.label,
152
+ value: props.value
153
+ });
154
+ case "Fields":
155
+ return Fields(
156
+ convertedChildren.filter((c) => c.type === "field")
157
+ );
158
+ default:
159
+ return null;
160
+ }
161
+ }
162
+ function convertChildren(children) {
163
+ if (children == null) {
164
+ return [];
165
+ }
166
+ if (Array.isArray(children)) {
167
+ return children.flatMap(convertChildren);
168
+ }
169
+ const converted = fromReactElement(children);
170
+ if (converted && typeof converted === "object" && "type" in converted) {
171
+ if (converted.type === "card") {
172
+ return converted.children;
173
+ }
174
+ return [converted];
175
+ }
176
+ return [];
177
+ }
178
+ function extractTextContent(children) {
179
+ if (typeof children === "string") {
180
+ return children;
181
+ }
182
+ if (typeof children === "number") {
183
+ return String(children);
184
+ }
185
+ if (Array.isArray(children)) {
186
+ return children.map(extractTextContent).join("");
187
+ }
188
+ return "";
189
+ }
190
+ function cardToFallbackText(card) {
191
+ const parts = [];
192
+ if (card.title) {
193
+ parts.push(card.title);
194
+ }
195
+ if (card.subtitle) {
196
+ parts.push(card.subtitle);
197
+ }
198
+ for (const child of card.children) {
199
+ const text = childToFallbackText(child);
200
+ if (text) {
201
+ parts.push(text);
202
+ }
203
+ }
204
+ return parts.join("\n");
205
+ }
206
+ function childToFallbackText(child) {
207
+ switch (child.type) {
208
+ case "text":
209
+ return child.content;
210
+ case "fields":
211
+ return child.children.map((f) => `${f.label}: ${f.value}`).join("\n");
212
+ case "actions":
213
+ return `[${child.children.map((b) => b.label).join("] [")}]`;
214
+ case "section":
215
+ return child.children.map((c) => childToFallbackText(c)).filter(Boolean).join("\n");
216
+ default:
217
+ return null;
218
+ }
219
+ }
220
+
221
+ // src/jsx-runtime.ts
222
+ var JSX_ELEMENT = /* @__PURE__ */ Symbol.for("chat.jsx.element");
223
+ function isJSXElement(value) {
224
+ return typeof value === "object" && value !== null && value.$$typeof === JSX_ELEMENT;
225
+ }
226
+ function processChildren(children) {
227
+ if (children == null) {
228
+ return [];
229
+ }
230
+ if (Array.isArray(children)) {
231
+ return children.flatMap(processChildren);
232
+ }
233
+ if (isJSXElement(children)) {
234
+ const resolved = resolveJSXElement(children);
235
+ if (resolved) {
236
+ return [resolved];
237
+ }
238
+ return [];
239
+ }
240
+ if (typeof children === "object" && "type" in children) {
241
+ return [children];
242
+ }
243
+ if (typeof children === "string") {
244
+ return [children];
245
+ }
246
+ return [];
247
+ }
248
+ function resolveJSXElement(element) {
249
+ const { type, props, children } = element;
250
+ const processedChildren = processChildren(children);
251
+ const fn = type;
252
+ if (fn === Text) {
253
+ const content = processedChildren.length > 0 ? String(processedChildren[0]) : props.children ?? "";
254
+ return Text(content, { style: props.style });
255
+ }
256
+ if (fn === Section) {
257
+ return Section(processedChildren);
258
+ }
259
+ if (fn === Actions) {
260
+ return Actions(processedChildren);
261
+ }
262
+ if (fn === Fields) {
263
+ return Fields(processedChildren);
264
+ }
265
+ if (fn === Button) {
266
+ const label = processedChildren.length > 0 ? String(processedChildren[0]) : props.label ?? "";
267
+ return Button({
268
+ id: props.id,
269
+ label,
270
+ style: props.style,
271
+ value: props.value
272
+ });
273
+ }
274
+ if (fn === Image) {
275
+ return Image({ url: props.url, alt: props.alt });
276
+ }
277
+ if (fn === Field) {
278
+ return Field({
279
+ label: props.label,
280
+ value: props.value
281
+ });
282
+ }
283
+ if (fn === Divider) {
284
+ return Divider();
285
+ }
286
+ return type({
287
+ ...props,
288
+ children: processedChildren
289
+ });
290
+ }
291
+ function jsx(type, props, _key) {
292
+ const { children, ...restProps } = props;
293
+ return {
294
+ $$typeof: JSX_ELEMENT,
295
+ type,
296
+ props: restProps,
297
+ children: children != null ? [children] : []
298
+ };
299
+ }
300
+ function jsxs(type, props, _key) {
301
+ const { children, ...restProps } = props;
302
+ return {
303
+ $$typeof: JSX_ELEMENT,
304
+ type,
305
+ props: restProps,
306
+ children: Array.isArray(children) ? children : children != null ? [children] : []
307
+ };
308
+ }
309
+ var jsxDEV = jsx;
310
+ function Fragment(props) {
311
+ return processChildren(props.children);
312
+ }
313
+ function toCardElement(jsxElement) {
314
+ if (isJSXElement(jsxElement)) {
315
+ const resolved = resolveJSXElement(jsxElement);
316
+ if (resolved && typeof resolved === "object" && "type" in resolved && resolved.type === "card") {
317
+ return resolved;
318
+ }
319
+ }
320
+ if (typeof jsxElement === "object" && jsxElement !== null && "type" in jsxElement && jsxElement.type === "card") {
321
+ return jsxElement;
322
+ }
323
+ return null;
324
+ }
325
+ function isJSX(value) {
326
+ if (isJSXElement(value)) {
327
+ return true;
328
+ }
329
+ if (typeof value === "object" && value !== null && "$$typeof" in value && typeof value.$$typeof === "symbol") {
330
+ const symbolStr = value.$$typeof.toString();
331
+ return symbolStr.includes("react.element") || symbolStr.includes("react.transitional.element");
332
+ }
333
+ return false;
334
+ }
335
+
336
+ export {
337
+ isCardElement,
338
+ Card,
339
+ CardText,
340
+ Image,
341
+ Divider,
342
+ Section,
343
+ Actions,
344
+ Button,
345
+ Field,
346
+ Fields,
347
+ fromReactElement,
348
+ cardToFallbackText,
349
+ jsx,
350
+ jsxs,
351
+ jsxDEV,
352
+ Fragment,
353
+ toCardElement,
354
+ isJSX
355
+ };
356
+ //# sourceMappingURL=chunk-ACQNDPTB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cards.ts","../src/jsx-runtime.ts"],"sourcesContent":["/**\n * Card elements for cross-platform rich messaging.\n *\n * Provides a builder API for creating rich cards that automatically\n * convert to platform-specific formats:\n * - Slack: Block Kit\n * - Teams: Adaptive Cards\n * - Google Chat: Card v2\n *\n * Supports both function-call and JSX syntax:\n *\n * @example Function API\n * ```ts\n * import { Card, Text, Actions, Button } from \"chat\";\n *\n * await thread.post(\n * Card({\n * title: \"Order #1234\",\n * children: [\n * Text(\"Total: $50.00\"),\n * Actions([\n * Button({ id: \"approve\", label: \"Approve\", style: \"primary\" }),\n * Button({ id: \"reject\", label: \"Reject\", style: \"danger\" }),\n * ]),\n * ],\n * })\n * );\n * ```\n *\n * @example JSX API (requires jsxImportSource: \"chat\" in tsconfig)\n * ```tsx\n * /** @jsxImportSource chat *\\/\n * import { Card, Text, Actions, Button } from \"chat\";\n *\n * await thread.post(\n * <Card title=\"Order #1234\">\n * <Text>Total: $50.00</Text>\n * <Actions>\n * <Button id=\"approve\" style=\"primary\">Approve</Button>\n * <Button id=\"reject\" style=\"danger\">Reject</Button>\n * </Actions>\n * </Card>\n * );\n * ```\n */\n\n// ============================================================================\n// Card Element Types\n// ============================================================================\n\n/** Button style options */\nexport type ButtonStyle = \"primary\" | \"danger\" | \"default\";\n\n/** Text style options */\nexport type TextStyle = \"plain\" | \"bold\" | \"muted\";\n\n/** Button element for interactive actions */\nexport interface ButtonElement {\n type: \"button\";\n /** Unique action ID for callback routing */\n id: string;\n /** Button label text */\n label: string;\n /** Visual style */\n style?: ButtonStyle;\n /** Optional payload value sent with action callback */\n value?: string;\n}\n\n/** Text content element */\nexport interface TextElement {\n type: \"text\";\n /** Text content (supports markdown in some platforms) */\n content: string;\n /** Text style */\n style?: TextStyle;\n}\n\n/** Image element */\nexport interface ImageElement {\n type: \"image\";\n /** Image URL */\n url: string;\n /** Alt text for accessibility */\n alt?: string;\n}\n\n/** Visual divider/separator */\nexport interface DividerElement {\n type: \"divider\";\n}\n\n/** Container for action buttons */\nexport interface ActionsElement {\n type: \"actions\";\n /** Button elements */\n children: ButtonElement[];\n}\n\n/** Section container for grouping elements */\nexport interface SectionElement {\n type: \"section\";\n /** Section children */\n children: CardChild[];\n}\n\n/** Field for key-value display */\nexport interface FieldElement {\n type: \"field\";\n /** Field label */\n label: string;\n /** Field value */\n value: string;\n}\n\n/** Fields container for multi-column layout */\nexport interface FieldsElement {\n type: \"fields\";\n /** Field elements */\n children: FieldElement[];\n}\n\n/** Union of all card child element types */\nexport type CardChild =\n | TextElement\n | ImageElement\n | DividerElement\n | ActionsElement\n | SectionElement\n | FieldsElement;\n\n/** Union of all element types (including nested children) */\ntype AnyCardElement = CardChild | CardElement | ButtonElement | FieldElement;\n\n/** Root card element */\nexport interface CardElement {\n type: \"card\";\n /** Card title */\n title?: string;\n /** Card subtitle */\n subtitle?: string;\n /** Header image URL */\n imageUrl?: string;\n /** Card content */\n children: CardChild[];\n}\n\n/** Type guard for CardElement */\nexport function isCardElement(value: unknown): value is CardElement {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"type\" in value &&\n (value as CardElement).type === \"card\"\n );\n}\n\n// ============================================================================\n// Builder Functions\n// ============================================================================\n\n/** Options for Card */\nexport interface CardOptions {\n title?: string;\n subtitle?: string;\n imageUrl?: string;\n children?: CardChild[];\n}\n\n/**\n * Create a Card element.\n *\n * @example\n * ```ts\n * Card({\n * title: \"Welcome\",\n * children: [Text(\"Hello!\")],\n * })\n * ```\n */\nexport function Card(options: CardOptions = {}): CardElement {\n return {\n type: \"card\",\n title: options.title,\n subtitle: options.subtitle,\n imageUrl: options.imageUrl,\n children: options.children ?? [],\n };\n}\n\n/**\n * Create a Text element.\n *\n * @example\n * ```ts\n * Text(\"Hello, world!\")\n * Text(\"Important\", { style: \"bold\" })\n * ```\n */\nexport function Text(\n content: string,\n options: { style?: TextStyle } = {},\n): TextElement {\n return {\n type: \"text\",\n content,\n style: options.style,\n };\n}\n\n/**\n * Alias for Text that avoids conflicts with DOM's global Text constructor.\n * Use this when importing in environments where `Text` would conflict.\n *\n * @example\n * ```ts\n * import { CardText } from \"chat\";\n * CardText(\"Hello, world!\")\n * ```\n */\nexport const CardText = Text;\n\n/**\n * Create an Image element.\n *\n * @example\n * ```ts\n * Image({ url: \"https://example.com/image.png\", alt: \"Description\" })\n * ```\n */\nexport function Image(options: { url: string; alt?: string }): ImageElement {\n return {\n type: \"image\",\n url: options.url,\n alt: options.alt,\n };\n}\n\n/**\n * Create a Divider element.\n *\n * @example\n * ```ts\n * Divider()\n * ```\n */\nexport function Divider(): DividerElement {\n return { type: \"divider\" };\n}\n\n/**\n * Create a Section container.\n *\n * @example\n * ```ts\n * Section([\n * Text(\"Grouped content\"),\n * Image({ url: \"...\" }),\n * ])\n * ```\n */\nexport function Section(children: CardChild[]): SectionElement {\n return {\n type: \"section\",\n children,\n };\n}\n\n/**\n * Create an Actions container for buttons.\n *\n * @example\n * ```ts\n * Actions([\n * Button({ id: \"ok\", label: \"OK\" }),\n * Button({ id: \"cancel\", label: \"Cancel\" }),\n * ])\n * ```\n */\nexport function Actions(children: ButtonElement[]): ActionsElement {\n return {\n type: \"actions\",\n children,\n };\n}\n\n/** Options for Button */\nexport interface ButtonOptions {\n /** Unique action ID for callback routing */\n id: string;\n /** Button label text */\n label: string;\n /** Visual style */\n style?: ButtonStyle;\n /** Optional payload value sent with action callback */\n value?: string;\n}\n\n/**\n * Create a Button element.\n *\n * @example\n * ```ts\n * Button({ id: \"submit\", label: \"Submit\", style: \"primary\" })\n * Button({ id: \"delete\", label: \"Delete\", style: \"danger\", value: \"item-123\" })\n * ```\n */\nexport function Button(options: ButtonOptions): ButtonElement {\n return {\n type: \"button\",\n id: options.id,\n label: options.label,\n style: options.style,\n value: options.value,\n };\n}\n\n/**\n * Create a Field element for key-value display.\n *\n * @example\n * ```ts\n * Field({ label: \"Status\", value: \"Active\" })\n * ```\n */\nexport function Field(options: { label: string; value: string }): FieldElement {\n return {\n type: \"field\",\n label: options.label,\n value: options.value,\n };\n}\n\n/**\n * Create a Fields container for multi-column layout.\n *\n * @example\n * ```ts\n * Fields([\n * Field({ label: \"Name\", value: \"John\" }),\n * Field({ label: \"Email\", value: \"john@example.com\" }),\n * ])\n * ```\n */\nexport function Fields(children: FieldElement[]): FieldsElement {\n return {\n type: \"fields\",\n children,\n };\n}\n\n// ============================================================================\n// React Element Support\n// ============================================================================\n\n/** React element shape (minimal typing to avoid React dependency) */\ninterface ReactElement {\n $$typeof: symbol;\n type: unknown;\n props: Record<string, unknown>;\n}\n\n/**\n * Check if a value is a React element.\n */\nfunction isReactElement(value: unknown): value is ReactElement {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const maybeElement = value as { $$typeof?: unknown };\n if (typeof maybeElement.$$typeof !== \"symbol\") {\n return false;\n }\n const symbolStr = maybeElement.$$typeof.toString();\n return (\n symbolStr.includes(\"react.element\") ||\n symbolStr.includes(\"react.transitional.element\")\n );\n}\n\n/**\n * Map of component functions to their names for React element conversion.\n */\nconst componentMap = new Map<unknown, string>([\n [Card, \"Card\"],\n [Text, \"Text\"],\n [Image, \"Image\"],\n [Divider, \"Divider\"],\n [Section, \"Section\"],\n [Actions, \"Actions\"],\n [Button, \"Button\"],\n [Field, \"Field\"],\n [Fields, \"Fields\"],\n]);\n\n/**\n * Convert a React element tree to a CardElement tree.\n * This allows using React's JSX with our card components.\n *\n * @example\n * ```tsx\n * import React from \"react\";\n * import { Card, Text, fromReactElement } from \"chat\";\n *\n * const element = (\n * <Card title=\"Hello\">\n * <Text>World</Text>\n * </Card>\n * );\n *\n * const card = fromReactElement(element);\n * await thread.post(card);\n * ```\n */\nexport function fromReactElement(element: unknown): AnyCardElement | null {\n if (!isReactElement(element)) {\n // Already a card element or primitive\n if (isCardElement(element)) {\n return element;\n }\n if (typeof element === \"object\" && element !== null && \"type\" in element) {\n return element as CardChild;\n }\n return null;\n }\n\n const { type, props } = element;\n const componentName = componentMap.get(type);\n\n if (!componentName) {\n // Check if it's an HTML element (string type like \"div\", \"a\", \"span\")\n if (typeof type === \"string\") {\n throw new Error(\n `HTML element <${type}> is not supported in card elements. ` +\n `Use Card, Text, Section, Actions, Button, Fields, Field, Image, or Divider components instead.`,\n );\n }\n\n // Unknown custom component - try to extract children\n if (props.children) {\n return convertChildren(props.children)[0] ?? null;\n }\n return null;\n }\n\n // Convert children recursively\n const convertedChildren = props.children\n ? convertChildren(props.children)\n : [];\n\n // Helper to filter for CardChild elements\n const isCardChild = (el: AnyCardElement): el is CardChild =>\n el.type !== \"card\" && el.type !== \"button\" && el.type !== \"field\";\n\n // Call the appropriate builder function based on component type\n switch (componentName) {\n case \"Card\":\n return Card({\n title: props.title as string | undefined,\n subtitle: props.subtitle as string | undefined,\n imageUrl: props.imageUrl as string | undefined,\n children: convertedChildren.filter(isCardChild),\n });\n\n case \"Text\": {\n // JSX: <Text style=\"bold\">content</Text>\n const content = extractTextContent(props.children);\n return Text(content, { style: props.style as TextStyle | undefined });\n }\n\n case \"Image\":\n return Image({\n url: props.url as string,\n alt: props.alt as string | undefined,\n });\n\n case \"Divider\":\n return Divider();\n\n case \"Section\":\n return Section(convertedChildren.filter(isCardChild));\n\n case \"Actions\":\n return Actions(\n convertedChildren.filter(\n (c): c is ButtonElement => c.type === \"button\",\n ),\n );\n\n case \"Button\": {\n // JSX: <Button id=\"x\" style=\"primary\">Label</Button>\n const label = extractTextContent(props.children);\n return Button({\n id: props.id as string,\n label: (props.label as string | undefined) ?? label,\n style: props.style as ButtonStyle | undefined,\n value: props.value as string | undefined,\n });\n }\n\n case \"Field\":\n return Field({\n label: props.label as string,\n value: props.value as string,\n });\n\n case \"Fields\":\n return Fields(\n convertedChildren.filter((c): c is FieldElement => c.type === \"field\"),\n );\n\n default:\n return null;\n }\n}\n\n/**\n * Convert React children to card elements.\n */\nfunction convertChildren(children: unknown): AnyCardElement[] {\n if (children == null) {\n return [];\n }\n\n if (Array.isArray(children)) {\n return children.flatMap(convertChildren);\n }\n\n const converted = fromReactElement(children);\n if (converted && typeof converted === \"object\" && \"type\" in converted) {\n // If it's a card, extract its children\n if (converted.type === \"card\") {\n return (converted as CardElement).children;\n }\n return [converted];\n }\n\n return [];\n}\n\n/**\n * Extract text content from React children.\n */\nfunction extractTextContent(children: unknown): string {\n if (typeof children === \"string\") {\n return children;\n }\n if (typeof children === \"number\") {\n return String(children);\n }\n if (Array.isArray(children)) {\n return children.map(extractTextContent).join(\"\");\n }\n return \"\";\n}\n\n// ============================================================================\n// Fallback Text Generation\n// ============================================================================\n\n/**\n * Generate plain text fallback from a CardElement.\n * Used for platforms/clients that can't render rich cards,\n * and for the SentMessage.text property.\n */\nexport function cardToFallbackText(card: CardElement): string {\n const parts: string[] = [];\n\n if (card.title) {\n parts.push(card.title);\n }\n\n if (card.subtitle) {\n parts.push(card.subtitle);\n }\n\n for (const child of card.children) {\n const text = childToFallbackText(child);\n if (text) {\n parts.push(text);\n }\n }\n\n return parts.join(\"\\n\");\n}\n\n/**\n * Generate fallback text from a card child element.\n */\nfunction childToFallbackText(child: CardChild): string | null {\n switch (child.type) {\n case \"text\":\n return child.content;\n case \"fields\":\n return child.children.map((f) => `${f.label}: ${f.value}`).join(\"\\n\");\n case \"actions\":\n return `[${child.children.map((b) => b.label).join(\"] [\")}]`;\n case \"section\":\n return child.children\n .map((c) => childToFallbackText(c))\n .filter(Boolean)\n .join(\"\\n\");\n default:\n return null;\n }\n}\n","/**\n * Custom JSX runtime for chat cards.\n *\n * This allows using JSX syntax without React. Configure your bundler:\n *\n * tsconfig.json:\n * {\n * \"compilerOptions\": {\n * \"jsx\": \"react-jsx\",\n * \"jsxImportSource\": \"chat\"\n * }\n * }\n *\n * Or per-file:\n * /** @jsxImportSource chat *\\/\n *\n * Usage:\n * ```tsx\n * import { Card, Text, Button, Actions } from \"chat\";\n *\n * const card = (\n * <Card title=\"Order #1234\">\n * <Text>Your order is ready!</Text>\n * <Actions>\n * <Button id=\"pickup\" style=\"primary\">Schedule Pickup</Button>\n * </Actions>\n * </Card>\n * );\n * ```\n */\n\nimport {\n Actions,\n Button,\n type ButtonElement,\n type CardChild,\n type CardElement,\n Divider,\n Field,\n type FieldElement,\n Fields,\n Image,\n Section,\n Text,\n type TextStyle,\n} from \"./cards\";\n\n// Symbol to identify our JSX elements before they're processed\nconst JSX_ELEMENT = Symbol.for(\"chat.jsx.element\");\n\n/**\n * Represents a JSX element from the chat JSX runtime.\n * This is the type returned when using JSX syntax with chat components.\n */\nexport interface CardJSXElement {\n $$typeof: typeof JSX_ELEMENT;\n type: CardComponentFunction;\n props: Record<string, unknown>;\n children: unknown[];\n}\n\n// Internal alias for backwards compatibility\ntype JSXElement = CardJSXElement;\n\n// biome-ignore lint/suspicious/noExplicitAny: Card builder functions have varying signatures\ntype CardComponentFunction = (...args: any[]) => CardElement | CardChild;\n\n/**\n * Check if a value is a JSX element from our runtime.\n */\nfunction isJSXElement(value: unknown): value is JSXElement {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as JSXElement).$$typeof === JSX_ELEMENT\n );\n}\n\n/** Non-null card element for children arrays */\ntype CardChildOrNested = CardChild | ButtonElement | FieldElement;\n\n/**\n * Process children, converting JSX elements to card elements.\n */\nfunction processChildren(children: unknown): CardChildOrNested[] {\n if (children == null) {\n return [];\n }\n\n if (Array.isArray(children)) {\n return children.flatMap(processChildren);\n }\n\n // If it's a JSX element, resolve it\n if (isJSXElement(children)) {\n const resolved = resolveJSXElement(children);\n if (resolved) {\n return [resolved as CardChildOrNested];\n }\n return [];\n }\n\n // If it's already a card element, return it\n if (typeof children === \"object\" && \"type\" in children) {\n return [children as CardChildOrNested];\n }\n\n // If it's a string, it might be text content for a Button\n if (typeof children === \"string\") {\n // Return as-is, the component will handle it\n return [children as unknown as CardChildOrNested];\n }\n\n return [];\n}\n\n/** Any card element type that can be created */\ntype AnyCardElement =\n | CardElement\n | CardChild\n | ButtonElement\n | FieldElement\n | null;\n\n/**\n * Resolve a JSX element by calling its component function.\n * Transforms JSX props into the format each builder function expects.\n */\nfunction resolveJSXElement(element: JSXElement): AnyCardElement {\n const { type, props, children } = element;\n\n // Process children first\n const processedChildren = processChildren(children);\n\n // Use identity comparison to determine which builder function this is\n // This is necessary because function names get minified in production builds\n // Cast to unknown first to allow comparison between different function types\n const fn = type as unknown;\n\n if (fn === Text) {\n // Text(content: string, options?: { style })\n // JSX children become the content string\n const content =\n processedChildren.length > 0\n ? String(processedChildren[0])\n : ((props.children as string) ?? \"\");\n return Text(content, { style: props.style as TextStyle | undefined });\n }\n\n if (fn === Section) {\n // Section takes array as first argument\n return Section(processedChildren as CardChild[]);\n }\n\n if (fn === Actions) {\n // Actions takes array of ButtonElements\n return Actions(processedChildren as unknown as ButtonElement[]);\n }\n\n if (fn === Fields) {\n // Fields takes array of FieldElements\n return Fields(processedChildren as unknown as FieldElement[]);\n }\n\n if (fn === Button) {\n // Button({ id, label, style, value })\n // JSX children become the label\n const label =\n processedChildren.length > 0\n ? String(processedChildren[0])\n : ((props.label as string) ?? \"\");\n return Button({\n id: props.id as string,\n label,\n style: props.style as ButtonElement[\"style\"],\n value: props.value as string | undefined,\n });\n }\n\n if (fn === Image) {\n // Image({ url, alt })\n return Image({ url: props.url as string, alt: props.alt as string });\n }\n\n if (fn === Field) {\n // Field({ label, value })\n return Field({\n label: props.label as string,\n value: props.value as string,\n });\n }\n\n if (fn === Divider) {\n // Divider() - no args\n return Divider();\n }\n\n // Default: Card({ title, subtitle, imageUrl, children })\n // Pass props with processed children\n return type({\n ...props,\n children: processedChildren,\n });\n}\n\n/**\n * JSX factory function (used by the JSX transform).\n * Creates a lazy JSX element that will be resolved when needed.\n */\nexport function jsx(\n type: CardComponentFunction,\n props: Record<string, unknown>,\n _key?: string,\n): JSXElement {\n const { children, ...restProps } = props;\n return {\n $$typeof: JSX_ELEMENT,\n type,\n props: restProps,\n children: children != null ? [children] : [],\n };\n}\n\n/**\n * JSX factory for elements with multiple children.\n */\nexport function jsxs(\n type: CardComponentFunction,\n props: Record<string, unknown>,\n _key?: string,\n): JSXElement {\n const { children, ...restProps } = props;\n return {\n $$typeof: JSX_ELEMENT,\n type,\n props: restProps,\n children: Array.isArray(children)\n ? children\n : children != null\n ? [children]\n : [],\n };\n}\n\n/**\n * Development JSX factory (same as jsx, but called in dev mode).\n */\nexport const jsxDEV = jsx;\n\n/**\n * Fragment support (flattens children).\n */\nexport function Fragment(props: { children?: unknown }): CardChild[] {\n return processChildren(props.children) as CardChild[];\n}\n\n/**\n * Convert a JSX element tree to a CardElement.\n * Call this on the root JSX element to get a usable CardElement.\n */\nexport function toCardElement(jsxElement: unknown): CardElement | null {\n if (isJSXElement(jsxElement)) {\n const resolved = resolveJSXElement(jsxElement);\n if (\n resolved &&\n typeof resolved === \"object\" &&\n \"type\" in resolved &&\n resolved.type === \"card\"\n ) {\n return resolved as CardElement;\n }\n }\n\n // Already a CardElement\n if (\n typeof jsxElement === \"object\" &&\n jsxElement !== null &&\n \"type\" in jsxElement &&\n (jsxElement as CardElement).type === \"card\"\n ) {\n return jsxElement as CardElement;\n }\n\n return null;\n}\n\n/**\n * Check if a value is a JSX element (from our runtime or React).\n */\nexport function isJSX(value: unknown): boolean {\n if (isJSXElement(value)) {\n return true;\n }\n // Check for React elements\n if (\n typeof value === \"object\" &&\n value !== null &&\n \"$$typeof\" in value &&\n typeof (value as { $$typeof: unknown }).$$typeof === \"symbol\"\n ) {\n const symbolStr = (value as { $$typeof: symbol }).$$typeof.toString();\n return (\n symbolStr.includes(\"react.element\") ||\n symbolStr.includes(\"react.transitional.element\")\n );\n }\n return false;\n}\n\n// Re-export for JSX namespace\nexport namespace JSX {\n export interface Element extends JSXElement {}\n // biome-ignore lint/complexity/noBannedTypes: Required for JSX namespace\n export type IntrinsicElements = {};\n export interface ElementChildrenAttribute {\n // biome-ignore lint/complexity/noBannedTypes: Required for JSX children attribute\n children: {};\n }\n}\n"],"mappings":";AAoJO,SAAS,cAAc,OAAsC;AAClE,SACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACT,MAAsB,SAAS;AAEpC;AAyBO,SAAS,KAAK,UAAuB,CAAC,GAAgB;AAC3D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO,QAAQ;AAAA,IACf,UAAU,QAAQ;AAAA,IAClB,UAAU,QAAQ;AAAA,IAClB,UAAU,QAAQ,YAAY,CAAC;AAAA,EACjC;AACF;AAWO,SAAS,KACd,SACA,UAAiC,CAAC,GACrB;AACb,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,OAAO,QAAQ;AAAA,EACjB;AACF;AAYO,IAAM,WAAW;AAUjB,SAAS,MAAM,SAAsD;AAC1E,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK,QAAQ;AAAA,IACb,KAAK,QAAQ;AAAA,EACf;AACF;AAUO,SAAS,UAA0B;AACxC,SAAO,EAAE,MAAM,UAAU;AAC3B;AAaO,SAAS,QAAQ,UAAuC;AAC7D,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAaO,SAAS,QAAQ,UAA2C;AACjE,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAuBO,SAAS,OAAO,SAAuC;AAC5D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,IAAI,QAAQ;AAAA,IACZ,OAAO,QAAQ;AAAA,IACf,OAAO,QAAQ;AAAA,IACf,OA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