@assistant-ui/react-generative-ui 0.0.23 → 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 (338) hide show
  1. package/README.md +2 -0
  2. package/dist/a2ui.d.ts +1 -4
  3. package/dist/a2ui.d.ts.map +1 -1
  4. package/dist/a2ui.js +1 -4
  5. package/dist/index.d.ts +1 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -10
  8. package/dist/index.server.d.ts +1 -2
  9. package/dist/index.server.d.ts.map +1 -1
  10. package/dist/index.server.js +1 -10
  11. package/dist/ir.d.ts +1 -111
  12. package/dist/ir.d.ts.map +1 -1
  13. package/dist/ir.js +1 -175
  14. package/dist/slack.d.ts +1 -4
  15. package/dist/slack.d.ts.map +1 -1
  16. package/dist/slack.js +1 -4
  17. package/dist/teams.d.ts +1 -4
  18. package/dist/teams.d.ts.map +1 -1
  19. package/dist/teams.js +1 -4
  20. package/package.json +5 -5
  21. package/src/a2ui.ts +1 -22
  22. package/src/index.server.ts +1 -2
  23. package/src/index.test.ts +75 -0
  24. package/src/index.ts +1 -2
  25. package/src/ir.ts +1 -279
  26. package/src/slack.ts +1 -39
  27. package/src/teams.ts +1 -35
  28. package/dist/JSONGenerativeUI.client.d.ts +0 -28
  29. package/dist/JSONGenerativeUI.client.d.ts.map +0 -1
  30. package/dist/JSONGenerativeUI.client.js +0 -101
  31. package/dist/JSONGenerativeUI.client.js.map +0 -1
  32. package/dist/JSONGenerativeUI.server.d.ts +0 -21
  33. package/dist/JSONGenerativeUI.server.d.ts.map +0 -1
  34. package/dist/JSONGenerativeUI.server.js +0 -32
  35. package/dist/JSONGenerativeUI.server.js.map +0 -1
  36. package/dist/JSONGenerativeUI.shared.d.ts +0 -63
  37. package/dist/JSONGenerativeUI.shared.d.ts.map +0 -1
  38. package/dist/JSONGenerativeUI.shared.js +0 -31
  39. package/dist/JSONGenerativeUI.shared.js.map +0 -1
  40. package/dist/RadioGroupScope.d.ts +0 -6
  41. package/dist/RadioGroupScope.d.ts.map +0 -1
  42. package/dist/RadioGroupScope.js +0 -25
  43. package/dist/RadioGroupScope.js.map +0 -1
  44. package/dist/a2ui/BindingContext.d.ts +0 -11
  45. package/dist/a2ui/BindingContext.d.ts.map +0 -1
  46. package/dist/a2ui/BindingContext.js +0 -12
  47. package/dist/a2ui/BindingContext.js.map +0 -1
  48. package/dist/a2ui/PresentRenderer.d.ts +0 -11
  49. package/dist/a2ui/PresentRenderer.d.ts.map +0 -1
  50. package/dist/a2ui/PresentRenderer.js +0 -39
  51. package/dist/a2ui/PresentRenderer.js.map +0 -1
  52. package/dist/a2ui/convert.d.ts +0 -15
  53. package/dist/a2ui/convert.d.ts.map +0 -1
  54. package/dist/a2ui/convert.js +0 -728
  55. package/dist/a2ui/convert.js.map +0 -1
  56. package/dist/a2ui/dataModel.d.ts +0 -9
  57. package/dist/a2ui/dataModel.d.ts.map +0 -1
  58. package/dist/a2ui/dataModel.js +0 -44
  59. package/dist/a2ui/dataModel.js.map +0 -1
  60. package/dist/a2ui/reducer.d.ts +0 -8
  61. package/dist/a2ui/reducer.d.ts.map +0 -1
  62. package/dist/a2ui/reducer.js +0 -242
  63. package/dist/a2ui/reducer.js.map +0 -1
  64. package/dist/a2ui/snapshot.d.ts +0 -3
  65. package/dist/a2ui/snapshot.d.ts.map +0 -1
  66. package/dist/a2ui/snapshot.js +0 -33
  67. package/dist/a2ui/snapshot.js.map +0 -1
  68. package/dist/a2ui/types.d.ts +0 -88
  69. package/dist/a2ui/types.d.ts.map +0 -1
  70. package/dist/a2ui/types.js +0 -6
  71. package/dist/a2ui/types.js.map +0 -1
  72. package/dist/a2ui/valueFunctions.d.ts +0 -16
  73. package/dist/a2ui/valueFunctions.d.ts.map +0 -1
  74. package/dist/a2ui/valueFunctions.js +0 -332
  75. package/dist/a2ui/valueFunctions.js.map +0 -1
  76. package/dist/actionRegistry.d.ts +0 -29
  77. package/dist/actionRegistry.d.ts.map +0 -1
  78. package/dist/actionRegistry.js +0 -41
  79. package/dist/actionRegistry.js.map +0 -1
  80. package/dist/answeredValues.d.ts +0 -16
  81. package/dist/answeredValues.d.ts.map +0 -1
  82. package/dist/answeredValues.js +0 -37
  83. package/dist/answeredValues.js.map +0 -1
  84. package/dist/buildPresentParameters.d.ts +0 -21
  85. package/dist/buildPresentParameters.d.ts.map +0 -1
  86. package/dist/buildPresentParameters.js +0 -95
  87. package/dist/buildPresentParameters.js.map +0 -1
  88. package/dist/constants.d.ts +0 -15
  89. package/dist/constants.d.ts.map +0 -1
  90. package/dist/constants.js +0 -19
  91. package/dist/constants.js.map +0 -1
  92. package/dist/convert/boundSpec.d.ts +0 -48
  93. package/dist/convert/boundSpec.d.ts.map +0 -1
  94. package/dist/convert/boundSpec.js +0 -108
  95. package/dist/convert/boundSpec.js.map +0 -1
  96. package/dist/convert/copyBounded.d.ts +0 -25
  97. package/dist/convert/copyBounded.d.ts.map +0 -1
  98. package/dist/convert/copyBounded.js +0 -38
  99. package/dist/convert/copyBounded.js.map +0 -1
  100. package/dist/convert/isElement.d.ts +0 -3
  101. package/dist/convert/isElement.d.ts.map +0 -1
  102. package/dist/convert/isElement.js +0 -6
  103. package/dist/convert/isElement.js.map +0 -1
  104. package/dist/convert/takeRun.d.ts +0 -6
  105. package/dist/convert/takeRun.d.ts.map +0 -1
  106. package/dist/convert/takeRun.js +0 -20
  107. package/dist/convert/takeRun.js.map +0 -1
  108. package/dist/defineGenerativeComponents.d.ts +0 -29
  109. package/dist/defineGenerativeComponents.d.ts.map +0 -1
  110. package/dist/defineGenerativeComponents.js +0 -34
  111. package/dist/defineGenerativeComponents.js.map +0 -1
  112. package/dist/fieldReferences.d.ts +0 -9
  113. package/dist/fieldReferences.d.ts.map +0 -1
  114. package/dist/fieldReferences.js +0 -53
  115. package/dist/fieldReferences.js.map +0 -1
  116. package/dist/generativeUIToJSX.d.ts +0 -18
  117. package/dist/generativeUIToJSX.d.ts.map +0 -1
  118. package/dist/generativeUIToJSX.js +0 -76
  119. package/dist/generativeUIToJSX.js.map +0 -1
  120. package/dist/index.shared.d.ts +0 -15
  121. package/dist/index.shared.d.ts.map +0 -1
  122. package/dist/index.shared.js +0 -9
  123. package/dist/ir.js.map +0 -1
  124. package/dist/renderGenerativeUI.d.ts +0 -14
  125. package/dist/renderGenerativeUI.d.ts.map +0 -1
  126. package/dist/renderGenerativeUI.js +0 -83
  127. package/dist/renderGenerativeUI.js.map +0 -1
  128. package/dist/scopeSchema.d.ts +0 -6
  129. package/dist/scopeSchema.d.ts.map +0 -1
  130. package/dist/scopeSchema.js +0 -56
  131. package/dist/scopeSchema.js.map +0 -1
  132. package/dist/slack/constants.d.ts +0 -93
  133. package/dist/slack/constants.d.ts.map +0 -1
  134. package/dist/slack/constants.js +0 -146
  135. package/dist/slack/constants.js.map +0 -1
  136. package/dist/slack/decodeBlockAction.d.ts +0 -10
  137. package/dist/slack/decodeBlockAction.d.ts.map +0 -1
  138. package/dist/slack/decodeBlockAction.js +0 -129
  139. package/dist/slack/decodeBlockAction.js.map +0 -1
  140. package/dist/slack/fromSlackBlocks.d.ts +0 -27
  141. package/dist/slack/fromSlackBlocks.d.ts.map +0 -1
  142. package/dist/slack/fromSlackBlocks.js +0 -483
  143. package/dist/slack/fromSlackBlocks.js.map +0 -1
  144. package/dist/slack/toSlackBlocks.d.ts +0 -4
  145. package/dist/slack/toSlackBlocks.d.ts.map +0 -1
  146. package/dist/slack/toSlackBlocks.js +0 -901
  147. package/dist/slack/toSlackBlocks.js.map +0 -1
  148. package/dist/slack/types.d.ts +0 -204
  149. package/dist/slack/types.d.ts.map +0 -1
  150. package/dist/slack/types.js +0 -0
  151. package/dist/teams/constants.d.ts +0 -34
  152. package/dist/teams/constants.d.ts.map +0 -1
  153. package/dist/teams/constants.js +0 -68
  154. package/dist/teams/constants.js.map +0 -1
  155. package/dist/teams/decodeSubmitData.d.ts +0 -26
  156. package/dist/teams/decodeSubmitData.d.ts.map +0 -1
  157. package/dist/teams/decodeSubmitData.js +0 -70
  158. package/dist/teams/decodeSubmitData.js.map +0 -1
  159. package/dist/teams/temporalId.d.ts +0 -5
  160. package/dist/teams/temporalId.d.ts.map +0 -1
  161. package/dist/teams/temporalId.js +0 -28
  162. package/dist/teams/temporalId.js.map +0 -1
  163. package/dist/teams/toAdaptiveCard.d.ts +0 -45
  164. package/dist/teams/toAdaptiveCard.d.ts.map +0 -1
  165. package/dist/teams/toAdaptiveCard.js +0 -642
  166. package/dist/teams/toAdaptiveCard.js.map +0 -1
  167. package/dist/teams/toTeamsAttachments.d.ts +0 -10
  168. package/dist/teams/toTeamsAttachments.d.ts.map +0 -1
  169. package/dist/teams/toTeamsAttachments.js +0 -99
  170. package/dist/teams/toTeamsAttachments.js.map +0 -1
  171. package/dist/teams/types.d.ts +0 -224
  172. package/dist/teams/types.d.ts.map +0 -1
  173. package/dist/teams/types.js +0 -0
  174. package/dist/temporal.d.ts +0 -33
  175. package/dist/temporal.d.ts.map +0 -1
  176. package/dist/temporal.js +0 -152
  177. package/dist/temporal.js.map +0 -1
  178. package/dist/types.d.ts +0 -99
  179. package/dist/types.d.ts.map +0 -1
  180. package/dist/types.js +0 -0
  181. package/dist/vocabulary/alert.d.ts +0 -32
  182. package/dist/vocabulary/alert.d.ts.map +0 -1
  183. package/dist/vocabulary/alert.js +0 -160
  184. package/dist/vocabulary/alert.js.map +0 -1
  185. package/dist/vocabulary/collectFormValues.d.ts +0 -23
  186. package/dist/vocabulary/collectFormValues.d.ts.map +0 -1
  187. package/dist/vocabulary/collectFormValues.js +0 -44
  188. package/dist/vocabulary/collectFormValues.js.map +0 -1
  189. package/dist/vocabulary/data.d.ts +0 -66
  190. package/dist/vocabulary/data.d.ts.map +0 -1
  191. package/dist/vocabulary/data.js +0 -503
  192. package/dist/vocabulary/data.js.map +0 -1
  193. package/dist/vocabulary/dispatch.d.ts +0 -9
  194. package/dist/vocabulary/dispatch.d.ts.map +0 -1
  195. package/dist/vocabulary/dispatch.js +0 -50
  196. package/dist/vocabulary/dispatch.js.map +0 -1
  197. package/dist/vocabulary/fact.d.ts +0 -19
  198. package/dist/vocabulary/fact.d.ts.map +0 -1
  199. package/dist/vocabulary/fact.js +0 -51
  200. package/dist/vocabulary/fact.js.map +0 -1
  201. package/dist/vocabulary/form.d.ts +0 -11
  202. package/dist/vocabulary/form.d.ts.map +0 -1
  203. package/dist/vocabulary/form.js +0 -23
  204. package/dist/vocabulary/form.js.map +0 -1
  205. package/dist/vocabulary/formatValue.d.ts +0 -7
  206. package/dist/vocabulary/formatValue.d.ts.map +0 -1
  207. package/dist/vocabulary/formatValue.js +0 -76
  208. package/dist/vocabulary/formatValue.js.map +0 -1
  209. package/dist/vocabulary/icon.d.ts +0 -41
  210. package/dist/vocabulary/icon.d.ts.map +0 -1
  211. package/dist/vocabulary/icon.js +0 -272
  212. package/dist/vocabulary/icon.js.map +0 -1
  213. package/dist/vocabulary/index.d.ts +0 -12
  214. package/dist/vocabulary/index.d.ts.map +0 -1
  215. package/dist/vocabulary/index.js +0 -36
  216. package/dist/vocabulary/index.js.map +0 -1
  217. package/dist/vocabulary/interactive.d.ts +0 -230
  218. package/dist/vocabulary/interactive.d.ts.map +0 -1
  219. package/dist/vocabulary/interactive.js +0 -530
  220. package/dist/vocabulary/interactive.js.map +0 -1
  221. package/dist/vocabulary/layout.d.ts +0 -79
  222. package/dist/vocabulary/layout.d.ts.map +0 -1
  223. package/dist/vocabulary/layout.js +0 -139
  224. package/dist/vocabulary/layout.js.map +0 -1
  225. package/dist/vocabulary/list.d.ts +0 -14
  226. package/dist/vocabulary/list.d.ts.map +0 -1
  227. package/dist/vocabulary/list.js +0 -50
  228. package/dist/vocabulary/list.js.map +0 -1
  229. package/dist/vocabulary/media.d.ts +0 -25
  230. package/dist/vocabulary/media.d.ts.map +0 -1
  231. package/dist/vocabulary/media.js +0 -42
  232. package/dist/vocabulary/media.js.map +0 -1
  233. package/dist/vocabulary/text.d.ts +0 -57
  234. package/dist/vocabulary/text.d.ts.map +0 -1
  235. package/dist/vocabulary/text.js +0 -49
  236. package/dist/vocabulary/text.js.map +0 -1
  237. package/dist/vocabulary/toTextContent.d.ts +0 -2
  238. package/dist/vocabulary/toTextContent.d.ts.map +0 -1
  239. package/dist/vocabulary/toTextContent.js +0 -6
  240. package/dist/vocabulary/toTextContent.js.map +0 -1
  241. package/src/JSONGenerativeUI.client.tsx +0 -168
  242. package/src/JSONGenerativeUI.server.tsx +0 -39
  243. package/src/JSONGenerativeUI.shared.ts +0 -90
  244. package/src/JSONGenerativeUI.test.tsx +0 -1298
  245. package/src/RadioGroupScope.server.test.tsx +0 -24
  246. package/src/RadioGroupScope.tsx +0 -34
  247. package/src/a2ui/BindingContext.ts +0 -26
  248. package/src/a2ui/PresentRenderer.tsx +0 -83
  249. package/src/a2ui/convert.test.ts +0 -2923
  250. package/src/a2ui/convert.ts +0 -1207
  251. package/src/a2ui/dataModel.ts +0 -69
  252. package/src/a2ui/reducer.test.ts +0 -422
  253. package/src/a2ui/reducer.ts +0 -363
  254. package/src/a2ui/snapshot.test.ts +0 -52
  255. package/src/a2ui/snapshot.ts +0 -52
  256. package/src/a2ui/types.ts +0 -114
  257. package/src/a2ui/valueFunctions.test.ts +0 -271
  258. package/src/a2ui/valueFunctions.ts +0 -523
  259. package/src/actionRegistry.test.ts +0 -90
  260. package/src/actionRegistry.ts +0 -88
  261. package/src/answeredValues.test.ts +0 -33
  262. package/src/answeredValues.tsx +0 -70
  263. package/src/buildPresentParameters.test.ts +0 -246
  264. package/src/buildPresentParameters.ts +0 -130
  265. package/src/constants.ts +0 -17
  266. package/src/convert/boundSpec.test.ts +0 -192
  267. package/src/convert/boundSpec.ts +0 -134
  268. package/src/convert/copyBounded.test.ts +0 -131
  269. package/src/convert/copyBounded.ts +0 -38
  270. package/src/convert/isElement.ts +0 -6
  271. package/src/convert/takeRun.test.ts +0 -64
  272. package/src/convert/takeRun.ts +0 -19
  273. package/src/defineGenerativeComponents.ts +0 -38
  274. package/src/fieldReferences.test.ts +0 -66
  275. package/src/fieldReferences.ts +0 -83
  276. package/src/generativeUIToJSX.test.ts +0 -268
  277. package/src/generativeUIToJSX.ts +0 -152
  278. package/src/index.server.test.ts +0 -106
  279. package/src/index.shared.ts +0 -61
  280. package/src/ir.test.ts +0 -203
  281. package/src/renderGenerativeUI.test.tsx +0 -373
  282. package/src/renderGenerativeUI.tsx +0 -165
  283. package/src/scopeSchema.test.ts +0 -72
  284. package/src/scopeSchema.ts +0 -71
  285. package/src/slack/a2uiSlack.test.ts +0 -198
  286. package/src/slack/constants.ts +0 -194
  287. package/src/slack/datePicker.test.ts +0 -612
  288. package/src/slack/decodeBlockAction.test.ts +0 -233
  289. package/src/slack/decodeBlockAction.ts +0 -232
  290. package/src/slack/fromSlackBlocks.test.ts +0 -1465
  291. package/src/slack/fromSlackBlocks.ts +0 -789
  292. package/src/slack/toSlackBlocks.test.ts +0 -3065
  293. package/src/slack/toSlackBlocks.ts +0 -1818
  294. package/src/slack/types.ts +0 -264
  295. package/src/teams/constants.ts +0 -93
  296. package/src/teams/decodeSubmitData.test.ts +0 -397
  297. package/src/teams/decodeSubmitData.ts +0 -110
  298. package/src/teams/temporal.test.ts +0 -766
  299. package/src/teams/temporalId.ts +0 -56
  300. package/src/teams/toAdaptiveCard.test.ts +0 -1897
  301. package/src/teams/toAdaptiveCard.ts +0 -1057
  302. package/src/teams/toTeamsAttachments.test.ts +0 -74
  303. package/src/teams/toTeamsAttachments.ts +0 -133
  304. package/src/teams/types.ts +0 -266
  305. package/src/temporal.test.ts +0 -319
  306. package/src/temporal.ts +0 -259
  307. package/src/types.ts +0 -119
  308. package/src/vocabulary/alert.test.tsx +0 -427
  309. package/src/vocabulary/alert.tsx +0 -217
  310. package/src/vocabulary/collectFormValues.test.ts +0 -389
  311. package/src/vocabulary/collectFormValues.ts +0 -116
  312. package/src/vocabulary/data.test.tsx +0 -858
  313. package/src/vocabulary/data.tsx +0 -819
  314. package/src/vocabulary/datepicker.dom.test.tsx +0 -1148
  315. package/src/vocabulary/dispatch.ts +0 -83
  316. package/src/vocabulary/fact.test.tsx +0 -94
  317. package/src/vocabulary/fact.tsx +0 -54
  318. package/src/vocabulary/form.test.tsx +0 -113
  319. package/src/vocabulary/form.tsx +0 -39
  320. package/src/vocabulary/formatValue.test.ts +0 -72
  321. package/src/vocabulary/formatValue.ts +0 -127
  322. package/src/vocabulary/icon.test.tsx +0 -64
  323. package/src/vocabulary/icon.tsx +0 -174
  324. package/src/vocabulary/index.test.ts +0 -65
  325. package/src/vocabulary/index.ts +0 -33
  326. package/src/vocabulary/interactive.dispatch.test.tsx +0 -454
  327. package/src/vocabulary/interactive.dom.test.tsx +0 -1747
  328. package/src/vocabulary/interactive.test.tsx +0 -377
  329. package/src/vocabulary/interactive.tsx +0 -1048
  330. package/src/vocabulary/layout.test.tsx +0 -323
  331. package/src/vocabulary/layout.tsx +0 -247
  332. package/src/vocabulary/list.test.tsx +0 -222
  333. package/src/vocabulary/list.tsx +0 -50
  334. package/src/vocabulary/media.test.tsx +0 -85
  335. package/src/vocabulary/media.tsx +0 -56
  336. package/src/vocabulary/text.test.tsx +0 -102
  337. package/src/vocabulary/text.tsx +0 -60
  338. package/src/vocabulary/toTextContent.ts +0 -2
@@ -1,642 +0,0 @@
1
- import { normalizeSpec } from "../ir.js";
2
- import { classifyTemporal, splitTemporalMinutes, temporalOffsetLabel } from "../temporal.js";
3
- import { copyBounded } from "../convert/copyBounded.js";
4
- import { boundSpec, clampReasonDetail } from "../convert/boundSpec.js";
5
- import { isElement } from "../convert/isElement.js";
6
- import { takeRun } from "../convert/takeRun.js";
7
- import { factTrend, formatFactDelta, formatValue } from "../vocabulary/formatValue.js";
8
- import { encodeTemporalInputId } from "./temporalId.js";
9
- import { PAYLOAD_SOFT_CAP, buildCard, buildSubmitAction, utf8ByteLength } from "./constants.js";
10
- //#region src/teams/toAdaptiveCard.ts
11
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
12
- const asString = (value) => typeof value === "string" ? value : "";
13
- const asFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
14
- const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
15
- const SUBTLE_COLORS = /* @__PURE__ */ new Set([
16
- "secondary",
17
- "alpha-70",
18
- "white",
19
- "white-70",
20
- "white-50"
21
- ]);
22
- const isSubtleColor = (color) => typeof color === "string" && SUBTLE_COLORS.has(color);
23
- const BOLDER_WEIGHTS = /* @__PURE__ */ new Set([
24
- "medium",
25
- "semibold",
26
- "bold"
27
- ]);
28
- const isBolderWeight = (weight) => typeof weight === "string" && BOLDER_WEIGHTS.has(weight);
29
- const TEXT_SIZE_MAP = {
30
- sm: "small",
31
- lg: "medium",
32
- xl: "large",
33
- "2xl": "extraLarge",
34
- "3xl": "extraLarge"
35
- };
36
- const warn = (context, code, component, detail) => {
37
- context.warnings.push({
38
- code,
39
- component,
40
- detail
41
- });
42
- };
43
- /**
44
- * The `aui` key is reserved for the submit envelope (see
45
- * {@link buildSubmitData} and `decodeSubmitData`): Adaptive Cards merge
46
- * every input's current value into the same submit object keyed by its
47
- * `id`, so an input id of `aui` would clobber the envelope. Renamed to an
48
- * unused id derived from `aui_` instead of being emitted as-is.
49
- */
50
- const RESERVED_INPUT_ID = "aui";
51
- function reservedSafeId(id, component, context) {
52
- const reserved = id === RESERVED_INPUT_ID;
53
- const temporalReserved = /^_*aui:datetime:/.test(id);
54
- const base = reserved ? `${RESERVED_INPUT_ID}_` : temporalReserved ? `_${id}` : id;
55
- let candidate = base;
56
- let n = 2;
57
- while (context.usedInputIds.has(candidate)) {
58
- candidate = `${base}_${n}`;
59
- n += 1;
60
- }
61
- if (reserved) warn(context, "fallback", component, `the input id "${RESERVED_INPUT_ID}" collides with the submit envelope's reserved key and was renamed to "${candidate}".`);
62
- else if (temporalReserved) warn(context, "fallback", component, `the input id "${id}" collides with the reserved datetime namespace and was renamed to "${candidate}".`);
63
- else if (candidate !== base) warn(context, "fallback", component, `the input id "${base}" was already used on this card and was renamed to "${candidate}".`);
64
- context.usedInputIds.add(candidate);
65
- return candidate;
66
- }
67
- /**
68
- * The shared bounded-iteration primitive: copies `value` to `cap` entries
69
- * without ever reading past that many indices, so a hostile array (sparse or
70
- * proxied with a fabricated `length`) cannot stall the event loop.
71
- */
72
- const clampArray = (value, cap) => {
73
- if (!Array.isArray(value)) return {
74
- items: [],
75
- truncated: false
76
- };
77
- return copyBounded(value, cap);
78
- };
79
- const normalizedList = (node) => {
80
- if (node === void 0 || node === null) return [];
81
- if (!Array.isArray(node)) return [node];
82
- return node.flatMap((child) => normalizedList(child));
83
- };
84
- function textBlock(text, extra) {
85
- return {
86
- type: "TextBlock",
87
- text,
88
- wrap: true,
89
- ...extra
90
- };
91
- }
92
- function applyPending(element, separator, spacing) {
93
- if (!separator && !spacing) return element;
94
- return {
95
- ...element,
96
- ...separator ? { separator: true } : {},
97
- ...spacing ? { spacing: "large" } : {}
98
- };
99
- }
100
- const toChoice = (option) => {
101
- if (!isRecord(option) || typeof option["value"] !== "string") return;
102
- const label = asString(option["label"]);
103
- const description = asString(option["description"]);
104
- return {
105
- title: description ? [label, description].filter(Boolean).join(": ") : label,
106
- value: option["value"]
107
- };
108
- };
109
- const choicesFrom = (optionsProp, component, context) => {
110
- const { items, truncated } = clampArray(optionsProp, 100);
111
- if (truncated) warn(context, "clamped", component, `options were clamped to 100 entries.`);
112
- const choices = [];
113
- for (const item of items) {
114
- const choice = toChoice(item);
115
- if (choice !== void 0) choices.push(choice);
116
- }
117
- const dropped = items.length - choices.length;
118
- if (dropped > 0) warn(context, "dropped", component, `${dropped} ${dropped === 1 ? "option was" : "options were"} dropped for want of a string value.`);
119
- return choices;
120
- };
121
- function convertFacts(facts) {
122
- return {
123
- type: "FactSet",
124
- facts: facts.map((fact) => {
125
- const value = asString(fact.props["value"]);
126
- const delta = fact.props["delta"];
127
- const deltaText = typeof delta === "string" ? formatFactDelta(delta, factTrend(delta, fact.props["trend"])) : void 0;
128
- return {
129
- title: asString(fact.props["label"]),
130
- value: deltaText === void 0 ? value : `${value} (${deltaText})`
131
- };
132
- })
133
- };
134
- }
135
- function convertButtons(buttons, context) {
136
- if (buttons.length > 6) warn(context, "fallback", "Button", `actions beyond 6 were set to secondary mode.`);
137
- return {
138
- type: "ActionSet",
139
- actions: buttons.map((button, index) => buildSubmitAction(asString(button.props["label"]), button.action, index >= 6 ? "secondary" : void 0))
140
- };
141
- }
142
- function withCompanionSubmit(element, input, context) {
143
- if (element.action === void 0) return [input];
144
- warn(context, "fallback", element.type, "Teams inputs cannot dispatch on change; a companion submit action was appended.");
145
- return [input, {
146
- type: "ActionSet",
147
- actions: [buildSubmitAction("Submit", element.action)]
148
- }];
149
- }
150
- function cardFooterActionSet(props) {
151
- const actions = ["confirm", "cancel"].map((key) => props[key]).filter(isRecord).map((footer) => buildSubmitAction(asString(footer["label"]), footer["$action"]));
152
- return actions.length > 0 ? {
153
- type: "ActionSet",
154
- actions
155
- } : void 0;
156
- }
157
- const ALERT_STYLE_MAP = {
158
- info: "accent",
159
- success: "good",
160
- warning: "warning",
161
- danger: "attention"
162
- };
163
- function convertTable(props, context) {
164
- const { items: rawColumns, truncated: columnsTruncated } = clampArray(props["columns"], 20);
165
- const { items: rawRows, truncated: rowsTruncated } = clampArray(props["rows"], 100);
166
- if (columnsTruncated) warn(context, "clamped", "Table", `columns were clamped to 20 entries.`);
167
- if (rowsTruncated) warn(context, "clamped", "Table", `rows were clamped to 100 entries.`);
168
- const unlabeled = rawColumns.filter((column) => !isRecord(column) || typeof column["label"] !== "string").length;
169
- if (unlabeled > 0) warn(context, "dropped", "Table", `${unlabeled} column ${unlabeled === 1 ? "header was" : "headers were"} left blank for want of a string label.`);
170
- const hasColumns = rawColumns.length > 0;
171
- const columns = rawColumns.map(() => ({ width: 1 }));
172
- const headerRow = hasColumns ? {
173
- type: "TableRow",
174
- cells: rawColumns.map((column) => ({
175
- type: "TableCell",
176
- items: [textBlock(isRecord(column) ? asString(column["label"]) : "")]
177
- }))
178
- } : void 0;
179
- const dataRows = rawRows.map((row) => ({
180
- type: "TableRow",
181
- cells: (Array.isArray(row) ? copyBounded(row, 20).items : []).map((cell, index) => ({
182
- type: "TableCell",
183
- items: [textBlock(formatValue(cell, isRecord(rawColumns[index]) ? rawColumns[index]["format"] : void 0))]
184
- }))
185
- }));
186
- return {
187
- type: "Table",
188
- firstRowAsHeaders: hasColumns,
189
- columns,
190
- rows: headerRow !== void 0 ? [headerRow, ...dataRows] : dataRows
191
- };
192
- }
193
- function convertListViewItem(element, context, depth) {
194
- const items = convertSequence(element.children, context, depth + 1);
195
- const selectAction = isRecord(element.action) ? buildSubmitAction("Open", element.action) : void 0;
196
- return {
197
- type: "Container",
198
- items,
199
- ...selectAction !== void 0 ? { selectAction } : {}
200
- };
201
- }
202
- /**
203
- * Converts a child whose output is thrown away, and reports whether anything
204
- * was lost with it. A scratch context keeps the ids it claims out of the card,
205
- * where they would rename a control that survives; only its `dropped` warnings
206
- * are forwarded, because those describe the tree the caller wrote, while a
207
- * clamp or a rename would describe content never delivered.
208
- */
209
- const discardedChild = (child, context, depth) => {
210
- const scratch = {
211
- ...context,
212
- warnings: [],
213
- usedInputIds: new Set(context.usedInputIds)
214
- };
215
- const produced = convertSequence(child, scratch, depth).length > 0;
216
- const lost = scratch.warnings.filter((warning) => warning.code === "dropped");
217
- context.warnings.push(...lost);
218
- return produced || lost.length > 0;
219
- };
220
- function convertElement(element, context, depth) {
221
- const { props } = element;
222
- switch (element.type) {
223
- case "Header": return [textBlock(asString(props["text"]), {
224
- size: "large",
225
- weight: "bolder",
226
- style: "heading"
227
- })];
228
- case "Text": {
229
- const mappedSize = typeof props["size"] === "string" ? TEXT_SIZE_MAP[props["size"]] : void 0;
230
- return [textBlock(asString(props["value"]), {
231
- ...mappedSize !== void 0 ? { size: mappedSize } : {},
232
- ...isBolderWeight(props["weight"]) ? { weight: "bolder" } : {},
233
- ...isSubtleColor(props["color"]) ? { isSubtle: true } : {}
234
- })];
235
- }
236
- case "Caption": return [textBlock(asString(props["value"]), {
237
- size: "small",
238
- isSubtle: true
239
- })];
240
- case "Badge": return [textBlock(asString(props["value"]), {
241
- size: "small",
242
- isSubtle: true
243
- })];
244
- case "Markdown": return [textBlock(asString(props["value"]))];
245
- case "Fact": return [convertFacts([element])];
246
- case "Image": {
247
- const size = props["size"];
248
- let mappedSize;
249
- if (size === "sm") mappedSize = "small";
250
- else if (size === "md") mappedSize = "medium";
251
- else if (size === "lg") mappedSize = "large";
252
- else if (typeof size === "number") warn(context, "dropped", "Image", "A numeric size was dropped.");
253
- return [{
254
- type: "Image",
255
- url: asString(props["src"]),
256
- altText: asString(props["alt"]),
257
- ...mappedSize !== void 0 ? { size: mappedSize } : {}
258
- }];
259
- }
260
- case "Divider":
261
- case "Spacer":
262
- case "Icon": return [];
263
- case "Button": return [convertButtons([element], context)];
264
- case "Select": {
265
- const name = asString(props["name"]);
266
- const placeholder = asString(props["placeholder"]);
267
- const label = asString(props["label"]);
268
- const defaultValue = props["defaultValue"];
269
- return withCompanionSubmit(element, {
270
- type: "Input.ChoiceSet",
271
- id: reservedSafeId(name || "select", "Select", context),
272
- style: "compact",
273
- choices: choicesFrom(props["options"], "Select", context),
274
- ...typeof defaultValue === "string" && defaultValue ? { value: defaultValue } : {},
275
- ...placeholder ? { placeholder } : {},
276
- ...label ? { label } : {}
277
- }, context);
278
- }
279
- case "RadioGroup": {
280
- const name = asString(props["name"]);
281
- const label = asString(props["label"]);
282
- const defaultValue = props["defaultValue"];
283
- return withCompanionSubmit(element, {
284
- type: "Input.ChoiceSet",
285
- id: reservedSafeId(name || "radiogroup", "RadioGroup", context),
286
- style: "expanded",
287
- choices: choicesFrom(props["options"], "RadioGroup", context),
288
- ...typeof defaultValue === "string" && defaultValue ? { value: defaultValue } : {},
289
- ...label ? { label } : {}
290
- }, context);
291
- }
292
- case "CheckboxGroup": {
293
- const name = asString(props["name"]);
294
- const label = asString(props["label"]);
295
- const checked = Array.isArray(props["defaultValue"]) ? props["defaultValue"].filter((value) => typeof value === "string" && value !== "") : [];
296
- return withCompanionSubmit(element, {
297
- type: "Input.ChoiceSet",
298
- id: reservedSafeId(name || "checkboxgroup", "CheckboxGroup", context),
299
- style: "expanded",
300
- isMultiSelect: true,
301
- choices: choicesFrom(props["options"], "CheckboxGroup", context),
302
- ...checked.length > 0 ? { value: checked.join(",") } : {},
303
- ...label ? { label } : {}
304
- }, context);
305
- }
306
- case "Checkbox": {
307
- const name = asString(props["name"]);
308
- const label = asString(props["label"]);
309
- return withCompanionSubmit(element, {
310
- type: "Input.Toggle",
311
- id: reservedSafeId(name || label || "checkbox", "Checkbox", context),
312
- title: label,
313
- value: props["defaultChecked"] === true ? "true" : "false",
314
- valueOn: "true",
315
- valueOff: "false"
316
- }, context);
317
- }
318
- case "Slider": {
319
- const name = asString(props["name"]);
320
- const label = asString(props["label"]);
321
- const min = asFiniteNumber(props["min"]);
322
- const max = asFiniteNumber(props["max"]);
323
- const defaultValue = asFiniteNumber(props["defaultValue"]);
324
- return withCompanionSubmit(element, {
325
- type: "Input.Number",
326
- id: reservedSafeId(name || "slider", "Slider", context),
327
- ...label ? { label } : {},
328
- ...min !== void 0 ? { min } : {},
329
- ...max !== void 0 ? { max } : {},
330
- ...defaultValue !== void 0 ? { value: defaultValue } : {}
331
- }, context);
332
- }
333
- case "Input": {
334
- const name = asString(props["name"]);
335
- const label = asString(props["label"]);
336
- const placeholder = asString(props["placeholder"]);
337
- const defaultValue = props["defaultValue"];
338
- return withCompanionSubmit(element, {
339
- type: "Input.Text",
340
- id: reservedSafeId(name || "input", "Input", context),
341
- ...props["inputType"] === "password" ? { style: "password" } : {},
342
- ...label ? { label } : {},
343
- ...placeholder ? { placeholder } : {},
344
- ...typeof defaultValue === "string" && defaultValue ? { value: defaultValue } : {},
345
- ...props["multiline"] === true && (props["inputType"] === void 0 || props["inputType"] === "text") ? { isMultiline: true } : {}
346
- }, context);
347
- }
348
- case "DatePicker": {
349
- const name = asString(props["name"]);
350
- const label = asString(props["label"]);
351
- const mode = props["inputType"];
352
- if (mode === "time") {
353
- const id = reservedSafeId(name || "datepicker", "DatePicker", context);
354
- const rawValue = asString(props["value"]);
355
- const parts = splitTemporalMinutes(rawValue);
356
- if (classifyTemporal(rawValue).kind === "time" && parts?.droppedPrecision) warn(context, "dropped", "DatePicker", "Nonzero seconds were dropped from the time value.");
357
- const value = parts?.time;
358
- const rawMin = asString(props["min"]);
359
- const minParts = splitTemporalMinutes(rawMin);
360
- let min = minParts?.time;
361
- if (classifyTemporal(rawMin).kind === "time" && minParts?.droppedPrecision) {
362
- const minuteOfDay = Number(minParts.time.slice(0, 2)) * 60 + Number(minParts.time.slice(3, 5)) + 1;
363
- if (minuteOfDay === 1440) {
364
- min = void 0;
365
- warn(context, "dropped", "DatePicker", "The time minimum rounds past 23:59 and was dropped.");
366
- } else min = `${String(Math.floor(minuteOfDay / 60)).padStart(2, "0")}:${String(minuteOfDay % 60).padStart(2, "0")}`;
367
- }
368
- const rawMax = asString(props["max"]);
369
- const maxParts = splitTemporalMinutes(rawMax);
370
- const max = maxParts?.time;
371
- if (classifyTemporal(rawMax).kind === "time" && maxParts?.droppedPrecision) warn(context, "dropped", "DatePicker", rawMax.slice(6, 8) === "00" ? "Nonzero fractional seconds were dropped from the time maximum." : /\.\d*[1-9]/.test(rawMax) ? "Nonzero seconds and fractional seconds were dropped from the time maximum." : "Nonzero seconds were dropped from the time maximum.");
372
- return withCompanionSubmit(element, {
373
- type: "Input.Time",
374
- id,
375
- ...label ? { label } : {},
376
- ...classifyTemporal(rawValue).kind === "time" && value !== void 0 ? { value } : {},
377
- ...classifyTemporal(rawMin).kind === "time" && min !== void 0 ? { min } : {},
378
- ...classifyTemporal(rawMax).kind === "time" && max !== void 0 ? { max } : {}
379
- }, context);
380
- }
381
- if (mode === "datetime") {
382
- const rawValue = asString(props["value"]);
383
- const temporal = classifyTemporal(rawValue);
384
- const fieldId = reservedSafeId(name || "datepicker", "DatePicker", context);
385
- const dateId = encodeTemporalInputId({
386
- fieldId,
387
- role: "date"
388
- });
389
- const timeId = encodeTemporalInputId({
390
- fieldId,
391
- role: "time",
392
- ...temporal.kind === "instant" ? { previousValue: rawValue } : {}
393
- });
394
- const parts = splitTemporalMinutes(rawValue);
395
- if (temporal.kind === "floating" && parts?.droppedPrecision) warn(context, "dropped", "DatePicker", "Nonzero seconds were dropped from the datetime value.");
396
- const offsetLabel = temporalOffsetLabel(rawValue);
397
- const boundDate = (raw) => {
398
- const value = asString(raw);
399
- return classifyTemporal(value).kind === "date" ? value : splitTemporalMinutes(value, temporal.kind === "instant" ? temporal.offset : void 0)?.date;
400
- };
401
- const min = boundDate(props["min"]);
402
- const max = boundDate(props["max"]);
403
- const dateInput = {
404
- type: "Input.Date",
405
- id: dateId,
406
- ...label ? { label } : {},
407
- ...parts?.date !== void 0 ? { value: parts.date } : {},
408
- ...min !== void 0 ? { min } : {},
409
- ...max !== void 0 ? { max } : {}
410
- };
411
- const timeInput = {
412
- type: "Input.Time",
413
- id: timeId,
414
- ...label || offsetLabel ? { label: `${label ? `${label} time` : "Time"}${offsetLabel ? ` (${offsetLabel})` : ""}` } : {},
415
- ...parts?.time !== void 0 ? { value: parts.time } : {}
416
- };
417
- if (element.action === void 0) return [dateInput, timeInput];
418
- const [input, submit] = withCompanionSubmit(element, timeInput, context);
419
- return [
420
- dateInput,
421
- input,
422
- submit
423
- ];
424
- }
425
- if (mode !== void 0 && mode !== "date") warn(context, "dropped", "DatePicker", "Unsupported inputType was dropped; the picker was rendered as a date input.");
426
- const rawValue = props["value"];
427
- const value = typeof rawValue === "string" && DATE_PATTERN.test(rawValue) ? rawValue : void 0;
428
- const rawMin = props["min"];
429
- const min = typeof rawMin === "string" && DATE_PATTERN.test(rawMin) ? rawMin : void 0;
430
- const rawMax = props["max"];
431
- const max = typeof rawMax === "string" && DATE_PATTERN.test(rawMax) ? rawMax : void 0;
432
- return withCompanionSubmit(element, {
433
- type: "Input.Date",
434
- id: reservedSafeId(name || "datepicker", "DatePicker", context),
435
- ...label ? { label } : {},
436
- ...value !== void 0 ? { value } : {},
437
- ...min !== void 0 ? { min } : {},
438
- ...max !== void 0 ? { max } : {}
439
- }, context);
440
- }
441
- case "Form": return [...convertSequence(element.children, context, depth + 1), {
442
- type: "ActionSet",
443
- actions: [buildSubmitAction("Submit", element.action)]
444
- }];
445
- case "Card": {
446
- const titleText = asString(props["title"]);
447
- const items = [];
448
- if (titleText) items.push(textBlock(titleText, {
449
- size: "large",
450
- weight: "bolder",
451
- style: "heading"
452
- }));
453
- items.push(...convertSequence(element.children, context, depth + 1));
454
- const container = {
455
- type: "Container",
456
- style: "default",
457
- items
458
- };
459
- const actionSet = cardFooterActionSet(props);
460
- return actionSet !== void 0 ? [container, actionSet] : [container];
461
- }
462
- case "Col":
463
- case "Box": return [{
464
- type: "Container",
465
- items: convertSequence(element.children, context, depth + 1)
466
- }];
467
- case "Row": {
468
- const children = normalizedList(element.children);
469
- if (children.length > 3) warn(context, "advisory", "Row", "Teams recommends at most 3 columns.");
470
- return [{
471
- type: "ColumnSet",
472
- columns: children.map((child) => ({
473
- type: "Column",
474
- width: "auto",
475
- items: convertSequence(child, context, depth + 1)
476
- }))
477
- }];
478
- }
479
- case "ListView": {
480
- const containers = [];
481
- let discarded = 0;
482
- for (const child of normalizedList(element.children)) {
483
- if (isElement(child) && child.type === "ListViewItem") {
484
- containers.push(convertListViewItem(child, context, depth + 1));
485
- continue;
486
- }
487
- if (discardedChild(child, context, depth + 1)) discarded += 1;
488
- }
489
- if (discarded > 0) warn(context, "dropped", "ListView", `${discarded} non-item ${discarded === 1 ? "child was" : "children were"} dropped.`);
490
- return containers.map((container, index) => index > 0 ? {
491
- ...container,
492
- separator: true
493
- } : container);
494
- }
495
- case "ListViewItem": return [convertListViewItem(element, context, depth)];
496
- case "Table": return [convertTable(props, context)];
497
- case "Alert": {
498
- const tone = props["tone"] ?? "info";
499
- const style = typeof tone === "string" ? ALERT_STYLE_MAP[tone] ?? "default" : "default";
500
- const titleText = asString(props["title"]);
501
- const description = asString(props["description"]);
502
- const items = [];
503
- if (titleText) items.push(textBlock(titleText, { weight: "bolder" }));
504
- if (description) items.push(textBlock(description));
505
- return [{
506
- type: "Container",
507
- style,
508
- items
509
- }];
510
- }
511
- case "Carousel": {
512
- warn(context, "fallback", "Carousel", "A carousel was rendered as sequential cards because it is not at the root.");
513
- const cards = [];
514
- let droppedCards = 0;
515
- for (const child of normalizedList(element.children)) {
516
- if (isElement(child) && child.type === "Card") {
517
- cards.push(child);
518
- continue;
519
- }
520
- if (discardedChild(child, context, depth + 1)) droppedCards += 1;
521
- }
522
- if (droppedCards > 0) warn(context, "dropped", "Carousel", `${droppedCards} non-card ${droppedCards === 1 ? "child was" : "children were"} dropped.`);
523
- return cards.flatMap((card) => convertElement(card, context, depth + 1));
524
- }
525
- case "Chart":
526
- warn(context, "dropped", "Chart", "Chart was replaced by a Teams omission note.");
527
- return [textBlock("Chart omitted on Teams.", {
528
- isSubtle: true,
529
- size: "small"
530
- })];
531
- default:
532
- warn(context, "dropped", element.type, "Unknown component type was dropped.");
533
- return [];
534
- }
535
- }
536
- /**
537
- * Walks a normalized sequence into card body elements. Nested arrays are
538
- * flattened into one flat sibling sequence first (via {@link normalizedList}),
539
- * so a `Divider`/`Fact`/`Button` run merges correctly even when the model
540
- * wrapped some of its siblings in their own array. Consecutive `Fact`
541
- * siblings merge into one FactSet and consecutive `Button` siblings merge
542
- * into one ActionSet; a `Divider`/`Spacer` emits nothing itself but sets
543
- * `separator`/`spacing` on the next emitted sibling (a trailing or orphan
544
- * one is dropped silently, since there is no sibling left to carry it).
545
- * `depth` advances by exactly one per element-nesting level: this call does
546
- * not itself add a level, since flattening a sibling array or converting a
547
- * sibling element is not a descent; only a container's own recursive
548
- * `convertSequence(children, depth + 1)` call is.
549
- */
550
- function convertSequence(node, context, depth) {
551
- if (node === void 0 || node === null || depth > 64) return [];
552
- const nodes = normalizedList(node);
553
- const items = [];
554
- let pendingSeparator = false;
555
- let pendingSpacing = false;
556
- const emit = (converted) => {
557
- const [first, ...rest] = converted;
558
- if (first === void 0) return;
559
- items.push(applyPending(first, pendingSeparator, pendingSpacing), ...rest);
560
- pendingSeparator = false;
561
- pendingSpacing = false;
562
- };
563
- for (let index = 0; index < nodes.length;) {
564
- const current = nodes[index];
565
- if (current === void 0 || current === null) {
566
- index += 1;
567
- continue;
568
- }
569
- if (isElement(current) && current.type === "Divider") {
570
- pendingSeparator = true;
571
- index += 1;
572
- continue;
573
- }
574
- if (isElement(current) && current.type === "Spacer") {
575
- pendingSpacing = true;
576
- index += 1;
577
- continue;
578
- }
579
- if (isElement(current) && current.type === "Fact") {
580
- const { run: facts, next } = takeRun(nodes, index, (candidate) => candidate.type === "Fact");
581
- index = next;
582
- emit([convertFacts(facts)]);
583
- continue;
584
- }
585
- if (isElement(current) && current.type === "Button") {
586
- const { run: buttons, next } = takeRun(nodes, index, (candidate) => candidate.type === "Button");
587
- index = next;
588
- emit([convertButtons(buttons, context)]);
589
- continue;
590
- }
591
- if (typeof current === "string" || typeof current === "number") emit([textBlock(String(current))]);
592
- else emit(convertElement(current, context, depth));
593
- index += 1;
594
- }
595
- return items;
596
- }
597
- /** Builds a full card (schema envelope plus body) from an already-normalized root, checking the soft payload budget. */
598
- function convertRootToCard(root, context) {
599
- context.usedInputIds = /* @__PURE__ */ new Set();
600
- const body = convertSequence(root, context, 0);
601
- const card = buildCard(body);
602
- const size = utf8ByteLength(JSON.stringify(card));
603
- if (size > 8e4) warn(context, "advisory", "Root", `the card is ${size} bytes, over the ${PAYLOAD_SOFT_CAP}-byte soft budget kept below Teams' 100 KB bot message limit.`);
604
- return card;
605
- }
606
- /**
607
- * Converts a generative-ui tree into a Microsoft Teams Adaptive Card and
608
- * non-fatal conversion warnings. Sizes, weights, and colors map to Adaptive
609
- * Card's semantic enums rather than raw values. An Input/Select/RadioGroup/
610
- * CheckboxGroup/Checkbox/Slider/DatePicker whose id would be the reserved
611
- * {@link RESERVED_INPUT_ID} is renamed with a warning (see `decodeSubmitData`).
612
- * Never throws: an unknown `$type` is skipped with a "dropped" warning, and a
613
- * malformed input resolves to an empty card plus a "dropped" warning instead
614
- * of throwing.
615
- */
616
- function toAdaptiveCard(node, _options) {
617
- const context = {
618
- warnings: [],
619
- usedInputIds: /* @__PURE__ */ new Set()
620
- };
621
- try {
622
- const bounded = boundSpec(node, (reason) => warn(context, "clamped", "Root", clampReasonDetail(reason)));
623
- const { root } = normalizeSpec(bounded);
624
- return {
625
- card: convertRootToCard(root, context),
626
- warnings: context.warnings
627
- };
628
- } catch {
629
- return {
630
- card: buildCard([]),
631
- warnings: [{
632
- code: "dropped",
633
- component: "Root",
634
- detail: "Input could not be converted."
635
- }]
636
- };
637
- }
638
- }
639
- //#endregion
640
- export { convertElement, convertRootToCard, convertSequence, discardedChild, toAdaptiveCard };
641
-
642
- //# sourceMappingURL=toAdaptiveCard.js.map