@8wave/ai-elements 0.125.0-beta.1 → 0.125.0-beta.10

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 (173) hide show
  1. package/dist/_chunks/{Agent-BBWFD4nI.js → Agent-DZhK49jg.js} +99 -96
  2. package/dist/_chunks/Agent-DZhK49jg.js.map +1 -0
  3. package/dist/_chunks/{PkFilePreview-BwHe4-m1.js → PkFilePreview-C3R3jrNi.js} +31 -31
  4. package/dist/_chunks/{PkFilePreview-BwHe4-m1.js.map → PkFilePreview-C3R3jrNi.js.map} +1 -1
  5. package/dist/_chunks/{PkFilePreviewDialog-LWxNgkzk.js → PkFilePreviewDialog-BAKFOnPI.js} +2 -2
  6. package/dist/_chunks/{PkFilePreviewDialog-LWxNgkzk.js.map → PkFilePreviewDialog-BAKFOnPI.js.map} +1 -1
  7. package/dist/_chunks/{PkStreamingMarkdown-BvgO6aHe.js → PkStreamingMarkdown-BM-DSTPr.js} +3 -3
  8. package/dist/_chunks/{PkStreamingMarkdown-BvgO6aHe.js.map → PkStreamingMarkdown-BM-DSTPr.js.map} +1 -1
  9. package/dist/_chunks/{PkToolChatFile-OuaeZTxw.js → PkToolChatFile-DbeOmRPh.js} +3 -3
  10. package/dist/_chunks/{PkToolChatFile-OuaeZTxw.js.map → PkToolChatFile-DbeOmRPh.js.map} +1 -1
  11. package/dist/_chunks/{PkToolRequestGeolocation-C9PSITRU.js → PkToolRequestGeolocation-CCz4REP9.js} +2 -2
  12. package/dist/_chunks/{PkToolRequestGeolocation-C9PSITRU.js.map → PkToolRequestGeolocation-CCz4REP9.js.map} +1 -1
  13. package/dist/_chunks/{PkToolRequestOAuthConnection-CWi5SeCi.js → PkToolRequestOAuthConnection-BU-4Sm3z.js} +2 -2
  14. package/dist/_chunks/{PkToolRequestOAuthConnection-CWi5SeCi.js.map → PkToolRequestOAuthConnection-BU-4Sm3z.js.map} +1 -1
  15. package/dist/_chunks/{PkToolShowArtifact-BqgW3E6D.js → PkToolShowArtifact-utxGuLLt.js} +2 -2
  16. package/dist/_chunks/{PkToolShowArtifact-BqgW3E6D.js.map → PkToolShowArtifact-utxGuLLt.js.map} +1 -1
  17. package/dist/_chunks/PkToolShowCalendarEvent-DWtTo28t.js +148 -0
  18. package/dist/_chunks/PkToolShowCalendarEvent-DWtTo28t.js.map +1 -0
  19. package/dist/_chunks/{PkToolShowContactForm-DDDXopZp.js → PkToolShowContactForm-DTtE93D3.js} +2 -2
  20. package/dist/_chunks/{PkToolShowContactForm-DDDXopZp.js.map → PkToolShowContactForm-DTtE93D3.js.map} +1 -1
  21. package/dist/_chunks/{PkToolShowForm-D2LZ8Kkl.js → PkToolShowForm-I4pKopEI.js} +6 -6
  22. package/dist/_chunks/{PkToolShowForm-D2LZ8Kkl.js.map → PkToolShowForm-I4pKopEI.js.map} +1 -1
  23. package/dist/_chunks/{PkToolShowImageGallery-DAcW2Dau.js → PkToolShowImageGallery-skV87BlD.js} +2 -2
  24. package/dist/_chunks/{PkToolShowImageGallery-DAcW2Dau.js.map → PkToolShowImageGallery-skV87BlD.js.map} +1 -1
  25. package/dist/_chunks/{PkToolShowProductList-OYwQCHar.js → PkToolShowProductList-CcdOQoxf.js} +2 -2
  26. package/dist/_chunks/{PkToolShowProductList-OYwQCHar.js.map → PkToolShowProductList-CcdOQoxf.js.map} +1 -1
  27. package/dist/_chunks/{PkToolShowQrCode-e6DxEcWY.js → PkToolShowQrCode-DGMhVUbp.js} +28 -22
  28. package/dist/_chunks/PkToolShowQrCode-DGMhVUbp.js.map +1 -0
  29. package/dist/_chunks/{PkToolShowSources-DA4SOt-H.js → PkToolShowSources-DLmVS3bL.js} +3 -3
  30. package/dist/_chunks/{PkToolShowSources-DA4SOt-H.js.map → PkToolShowSources-DLmVS3bL.js.map} +1 -1
  31. package/dist/_chunks/{PkToolShowSuggestedReply-BTE7TZ4Z.js → PkToolShowSuggestedReply-Cv-WVCFN.js} +2 -2
  32. package/dist/_chunks/{PkToolShowSuggestedReply-BTE7TZ4Z.js.map → PkToolShowSuggestedReply-Cv-WVCFN.js.map} +1 -1
  33. package/dist/_chunks/{PkToolShowVideo-bTWeXtZd.js → PkToolShowVideo-D_K95gTR.js} +2 -2
  34. package/dist/_chunks/{PkToolShowVideo-bTWeXtZd.js.map → PkToolShowVideo-D_K95gTR.js.map} +1 -1
  35. package/dist/_chunks/{PkToolShowWebPages-DNbdkSSz.js → PkToolShowWebPages-DsfMacw-.js} +2 -2
  36. package/dist/_chunks/{PkToolShowWebPages-DNbdkSSz.js.map → PkToolShowWebPages-DsfMacw-.js.map} +1 -1
  37. package/dist/_chunks/{chatImagePolicy-C4jFnVQl.js → chatImagePolicy-BfgdFbm_.js} +2 -2
  38. package/dist/_chunks/{chatImagePolicy-C4jFnVQl.js.map → chatImagePolicy-BfgdFbm_.js.map} +1 -1
  39. package/dist/_chunks/{markdown-DDYeZICP.js → markdown-CrMYpY8l.js} +10 -10
  40. package/dist/_chunks/{markdown-DDYeZICP.js.map → markdown-CrMYpY8l.js.map} +1 -1
  41. package/dist/_chunks/{utils-euH8esYP.js → utils-CbhqxYyx.js} +57 -57
  42. package/dist/_chunks/utils-CbhqxYyx.js.map +1 -0
  43. package/dist/ai-elements.es.js +4310 -4198
  44. package/dist/ai-elements.es.js.map +1 -1
  45. package/dist-vue/PkChatbot.js +1 -1
  46. package/dist-vue/PkChatbotEmptyState.js +1 -1
  47. package/dist-vue/PkChatbotInput.js +1 -1
  48. package/dist-vue/PkChatbotMessages.js +1 -1
  49. package/dist-vue/PkChatbotStepPayload.js +1 -1
  50. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  51. package/dist-vue/PkChatbotSteps.js +1 -1
  52. package/dist-vue/PkChatbotViewChat.js +1 -1
  53. package/dist-vue/PkChatbotViewConversations.js +1 -1
  54. package/dist-vue/PkChatbotViewFiles.js +1 -1
  55. package/dist-vue/PkChatbotViewProfile.js +1 -1
  56. package/dist-vue/_chunks/{Agent-DQl-tv4S.js → Agent-BtXBSGy6.js} +34 -31
  57. package/dist-vue/_chunks/Agent-BtXBSGy6.js.map +1 -0
  58. package/dist-vue/_chunks/{Document-DXDifFZE.js → Document-DERAWuR0.js} +10 -10
  59. package/dist-vue/_chunks/{Document-DXDifFZE.js.map → Document-DERAWuR0.js.map} +1 -1
  60. package/dist-vue/_chunks/PkChatbot-CLOfTLQy.js +294 -0
  61. package/dist-vue/_chunks/PkChatbot-CLOfTLQy.js.map +1 -0
  62. package/dist-vue/_chunks/{PkChatbotEmptyState-CLOH5Z2d.js → PkChatbotEmptyState-C9aUiynZ.js} +2 -2
  63. package/dist-vue/_chunks/{PkChatbotEmptyState-CLOH5Z2d.js.map → PkChatbotEmptyState-C9aUiynZ.js.map} +1 -1
  64. package/dist-vue/_chunks/{PkChatbotInput-BK7f1jFE.js → PkChatbotInput-Bs8nn-Jz.js} +154 -135
  65. package/dist-vue/_chunks/PkChatbotInput-Bs8nn-Jz.js.map +1 -0
  66. package/dist-vue/_chunks/PkChatbotMessages-BxkCGmqV.js +1039 -0
  67. package/dist-vue/_chunks/PkChatbotMessages-BxkCGmqV.js.map +1 -0
  68. package/dist-vue/_chunks/{PkChatbotStepPayload-D682n3VR.js → PkChatbotStepPayload-C45aVagz.js} +2 -2
  69. package/dist-vue/_chunks/{PkChatbotStepPayload-D682n3VR.js.map → PkChatbotStepPayload-C45aVagz.js.map} +1 -1
  70. package/dist-vue/_chunks/{PkChatbotStepToolDetail-D5c8rqj9.js → PkChatbotStepToolDetail-B0tC33x6.js} +16 -16
  71. package/dist-vue/_chunks/{PkChatbotStepToolDetail-D5c8rqj9.js.map → PkChatbotStepToolDetail-B0tC33x6.js.map} +1 -1
  72. package/dist-vue/_chunks/PkChatbotSteps-MTSA_RrY.js +215 -0
  73. package/dist-vue/_chunks/PkChatbotSteps-MTSA_RrY.js.map +1 -0
  74. package/dist-vue/_chunks/{PkChatbotViewChat-D8depeWQ.js → PkChatbotViewChat-BwXOt2WW.js} +450 -446
  75. package/dist-vue/_chunks/PkChatbotViewChat-BwXOt2WW.js.map +1 -0
  76. package/dist-vue/_chunks/{PkChatbotViewConversations-B-dmLi-8.js → PkChatbotViewConversations-CtxE_a1O.js} +3 -3
  77. package/dist-vue/_chunks/{PkChatbotViewConversations-B-dmLi-8.js.map → PkChatbotViewConversations-CtxE_a1O.js.map} +1 -1
  78. package/dist-vue/_chunks/{PkChatbotViewFiles-Du5AAS4v.js → PkChatbotViewFiles-B51zU374.js} +3 -3
  79. package/dist-vue/_chunks/{PkChatbotViewFiles-Du5AAS4v.js.map → PkChatbotViewFiles-B51zU374.js.map} +1 -1
  80. package/dist-vue/_chunks/{PkChatbotViewProfile-UZrZdOyM.js → PkChatbotViewProfile-BSKRU7Ae.js} +2 -2
  81. package/dist-vue/_chunks/{PkChatbotViewProfile-UZrZdOyM.js.map → PkChatbotViewProfile-BSKRU7Ae.js.map} +1 -1
  82. package/dist-vue/_chunks/{PkFilePreview-B54Dp_Rs.js → PkFilePreview-p-AGDrXi.js} +30 -30
  83. package/dist-vue/_chunks/{PkFilePreview-B54Dp_Rs.js.map → PkFilePreview-p-AGDrXi.js.map} +1 -1
  84. package/dist-vue/_chunks/{PkFilePreviewDialog-QDPoZh1v.js → PkFilePreviewDialog-BpeeWS6d.js} +2 -2
  85. package/dist-vue/_chunks/{PkFilePreviewDialog-QDPoZh1v.js.map → PkFilePreviewDialog-BpeeWS6d.js.map} +1 -1
  86. package/dist-vue/_chunks/{PkStreamingMarkdown-qnKwvrCg.js → PkStreamingMarkdown-DlcTV5je.js} +3 -3
  87. package/dist-vue/_chunks/{PkStreamingMarkdown-qnKwvrCg.js.map → PkStreamingMarkdown-DlcTV5je.js.map} +1 -1
  88. package/dist-vue/_chunks/{PkToolChatFile-i0rHgFxB.js → PkToolChatFile-HWGjtuaT.js} +3 -3
  89. package/dist-vue/_chunks/{PkToolChatFile-i0rHgFxB.js.map → PkToolChatFile-HWGjtuaT.js.map} +1 -1
  90. package/dist-vue/_chunks/{PkToolRequestGeolocation-SDzM1-Wl.js → PkToolRequestGeolocation-euI4VBVe.js} +2 -2
  91. package/dist-vue/_chunks/{PkToolRequestGeolocation-SDzM1-Wl.js.map → PkToolRequestGeolocation-euI4VBVe.js.map} +1 -1
  92. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-DNrlGxMX.js → PkToolRequestOAuthConnection-DAAYyufP.js} +2 -2
  93. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-DNrlGxMX.js.map → PkToolRequestOAuthConnection-DAAYyufP.js.map} +1 -1
  94. package/dist-vue/_chunks/{PkToolShowArtifact-Dh4ogn6A.js → PkToolShowArtifact-C8OIF_sy.js} +2 -2
  95. package/dist-vue/_chunks/{PkToolShowArtifact-Dh4ogn6A.js.map → PkToolShowArtifact-C8OIF_sy.js.map} +1 -1
  96. package/dist-vue/_chunks/PkToolShowCalendarEvent-CAejFLQI.js +148 -0
  97. package/dist-vue/_chunks/PkToolShowCalendarEvent-CAejFLQI.js.map +1 -0
  98. package/dist-vue/_chunks/{PkToolShowContactForm-BGTI1sio.js → PkToolShowContactForm-K6Z5MUXk.js} +2 -2
  99. package/dist-vue/_chunks/{PkToolShowContactForm-BGTI1sio.js.map → PkToolShowContactForm-K6Z5MUXk.js.map} +1 -1
  100. package/dist-vue/_chunks/{PkToolShowDiagram-xef3wJb0.js → PkToolShowDiagram-DrlGh_v6.js} +2 -2
  101. package/dist-vue/_chunks/{PkToolShowDiagram-xef3wJb0.js.map → PkToolShowDiagram-DrlGh_v6.js.map} +1 -1
  102. package/dist-vue/_chunks/{PkToolShowForm-Crg4Kl6v.js → PkToolShowForm-DzsXJfOl.js} +6 -6
  103. package/dist-vue/_chunks/{PkToolShowForm-Crg4Kl6v.js.map → PkToolShowForm-DzsXJfOl.js.map} +1 -1
  104. package/dist-vue/_chunks/{PkToolShowImageGallery-D9hdGBHK.js → PkToolShowImageGallery-sCyrPOIT.js} +2 -2
  105. package/dist-vue/_chunks/{PkToolShowImageGallery-D9hdGBHK.js.map → PkToolShowImageGallery-sCyrPOIT.js.map} +1 -1
  106. package/dist-vue/_chunks/{PkToolShowProductList-SC5aKDCw.js → PkToolShowProductList-DPDDeVu4.js} +2 -2
  107. package/dist-vue/_chunks/{PkToolShowProductList-SC5aKDCw.js.map → PkToolShowProductList-DPDDeVu4.js.map} +1 -1
  108. package/dist-vue/_chunks/PkToolShowQrCode-96KzD1rX.js +78 -0
  109. package/dist-vue/_chunks/PkToolShowQrCode-96KzD1rX.js.map +1 -0
  110. package/dist-vue/_chunks/{PkToolShowSources-Bf9_JwFL.js → PkToolShowSources-D4zjssdh.js} +3 -3
  111. package/dist-vue/_chunks/{PkToolShowSources-Bf9_JwFL.js.map → PkToolShowSources-D4zjssdh.js.map} +1 -1
  112. package/dist-vue/_chunks/{PkToolShowSuggestedReply-BlcEfMx8.js → PkToolShowSuggestedReply-smfC1hlT.js} +2 -2
  113. package/dist-vue/_chunks/{PkToolShowSuggestedReply-BlcEfMx8.js.map → PkToolShowSuggestedReply-smfC1hlT.js.map} +1 -1
  114. package/dist-vue/_chunks/{PkToolShowVideo-C2ITZDNo.js → PkToolShowVideo-C77DAqoZ.js} +2 -2
  115. package/dist-vue/_chunks/{PkToolShowVideo-C2ITZDNo.js.map → PkToolShowVideo-C77DAqoZ.js.map} +1 -1
  116. package/dist-vue/_chunks/{PkToolShowWebPages-BrefGxKQ.js → PkToolShowWebPages-D_tqGI6o.js} +2 -2
  117. package/dist-vue/_chunks/{PkToolShowWebPages-BrefGxKQ.js.map → PkToolShowWebPages-D_tqGI6o.js.map} +1 -1
  118. package/dist-vue/_chunks/{createChatbotApiClient-Bukf58dz.js → createChatbotApiClient-CO6l0P79.js} +87 -85
  119. package/dist-vue/_chunks/createChatbotApiClient-CO6l0P79.js.map +1 -0
  120. package/dist-vue/_chunks/{useChatbotStore-DcvdWkgq.js → useChatbotStore-CY1gAHOh.js} +1224 -1201
  121. package/dist-vue/_chunks/useChatbotStore-CY1gAHOh.js.map +1 -0
  122. package/dist-vue/_chunks/{utils-B0PnU1Rk.js → utils-CX4JuhXz.js} +66 -66
  123. package/dist-vue/_chunks/utils-CX4JuhXz.js.map +1 -0
  124. package/dist-vue/api.js +1 -1
  125. package/dist-vue/apps/web-component/src/composables/useChatbotAgent.d.ts +6 -0
  126. package/dist-vue/composables.js +20 -8
  127. package/dist-vue/composables.js.map +1 -1
  128. package/dist-vue/index.js +3394 -3359
  129. package/dist-vue/index.js.map +1 -1
  130. package/dist-vue/locales.js +20 -4
  131. package/dist-vue/packages/components/src/chat/PkAgentPageAccessSettings.d.ts +5 -0
  132. package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +6 -2
  133. package/dist-vue/packages/components/src/chat/PkChatbot.d.ts +10 -8
  134. package/dist-vue/packages/components/src/chat/PkChatbotInput.d.ts +11 -3
  135. package/dist-vue/packages/components/src/chat/PkChatbotMessages.d.ts +2 -2
  136. package/dist-vue/packages/components/src/chat/PkFieldChanges.d.ts +15 -0
  137. package/dist-vue/packages/components/src/chat/PkHostCallConfirmCard.d.ts +1 -2
  138. package/dist-vue/packages/components/src/chat/index.d.ts +1 -1
  139. package/dist-vue/packages/components/src/chat/utils.d.ts +18 -0
  140. package/dist-vue/packages/composable/src/chatbot/api/createChatbotApiClient.d.ts +2 -0
  141. package/dist-vue/packages/composable/src/chatbot/appTools.d.ts +11 -5
  142. package/dist-vue/packages/composable/src/chatbot/fieldChanges.d.ts +56 -0
  143. package/dist-vue/packages/composable/src/chatbot/hostTools.d.ts +19 -0
  144. package/dist-vue/packages/composable/src/chatbot/index.d.ts +1 -0
  145. package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +31 -4
  146. package/dist-vue/packages/models/src/schema/Agent.d.ts +50 -0
  147. package/dist-vue/packages/models/src/schema/Chat.d.ts +1 -0
  148. package/dist-vue/packages/models/src/schema/Organization.d.ts +9 -0
  149. package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +6 -0
  150. package/dist-vue/packages/models/src/schema/SubAgent.d.ts +6 -0
  151. package/dist-vue/style.css +1 -1
  152. package/package.json +1 -1
  153. package/dist/_chunks/Agent-BBWFD4nI.js.map +0 -1
  154. package/dist/_chunks/PkToolShowCalendarEvent-mVY2FS24.js +0 -148
  155. package/dist/_chunks/PkToolShowCalendarEvent-mVY2FS24.js.map +0 -1
  156. package/dist/_chunks/PkToolShowQrCode-e6DxEcWY.js.map +0 -1
  157. package/dist/_chunks/utils-euH8esYP.js.map +0 -1
  158. package/dist-vue/_chunks/Agent-DQl-tv4S.js.map +0 -1
  159. package/dist-vue/_chunks/PkChatbot-BRttF7Lo.js +0 -286
  160. package/dist-vue/_chunks/PkChatbot-BRttF7Lo.js.map +0 -1
  161. package/dist-vue/_chunks/PkChatbotInput-BK7f1jFE.js.map +0 -1
  162. package/dist-vue/_chunks/PkChatbotMessages-Ck0ofhtK.js +0 -1041
  163. package/dist-vue/_chunks/PkChatbotMessages-Ck0ofhtK.js.map +0 -1
  164. package/dist-vue/_chunks/PkChatbotSteps-CtKRHqaG.js +0 -189
  165. package/dist-vue/_chunks/PkChatbotSteps-CtKRHqaG.js.map +0 -1
  166. package/dist-vue/_chunks/PkChatbotViewChat-D8depeWQ.js.map +0 -1
  167. package/dist-vue/_chunks/PkToolShowCalendarEvent-BsAOYLjp.js +0 -148
  168. package/dist-vue/_chunks/PkToolShowCalendarEvent-BsAOYLjp.js.map +0 -1
  169. package/dist-vue/_chunks/PkToolShowQrCode-skWaARYV.js +0 -72
  170. package/dist-vue/_chunks/PkToolShowQrCode-skWaARYV.js.map +0 -1
  171. package/dist-vue/_chunks/createChatbotApiClient-Bukf58dz.js.map +0 -1
  172. package/dist-vue/_chunks/useChatbotStore-DcvdWkgq.js.map +0 -1
  173. package/dist-vue/_chunks/utils-B0PnU1Rk.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import "./vue.runtime.esm-bundler-C2U5uTqB.js";
2
- import { I as e, _ as t, d as n, p as r, t as i, y as a } from "./Agent-BBWFD4nI.js";
2
+ import { L as e, b as t, f as n, m as r, t as i, v as a } from "./Agent-DZhK49jg.js";
3
3
  import "./src-JJyCGvqH.js";
4
4
  import { n as o, t as s } from "./text-5F7L8EHi.js";
5
5
  // ../../packages/utils/src/message.ts
@@ -73,7 +73,7 @@ function ne(e) {
73
73
  }
74
74
  return t;
75
75
  }
76
- var g = (e) => l(e) && a(u(e));
76
+ var g = (e) => l(e) && t(u(e));
77
77
  function _(e) {
78
78
  let t = /* @__PURE__ */ new Map();
79
79
  for (let [n, r] of e.entries()) g(r) && r.state !== "output-error" && !S(r) && t.set(r.type, n);
@@ -142,21 +142,21 @@ var ie = {
142
142
  icon: "ri:links-line",
143
143
  label: "messagePart.pageTool.navigate"
144
144
  }
145
- }, ae = Symbol("hostStepTitles"), oe = {
145
+ }, ae = Symbol("hostStepTitles"), oe = Symbol("hostStepChanges"), se = {
146
146
  icon: "ri:survey-line",
147
147
  label: "messagePart.pageTool.form"
148
- }, x = (e) => e.toolMetadata?.provider === "page" ? ie[e.toolName] ?? (e.toolName.startsWith("form_") ? oe : void 0) : void 0;
149
- function se(e) {
148
+ }, x = (e) => e.toolMetadata?.provider === "page" ? ie[e.toolName] ?? (e.toolName.startsWith("form_") ? se : void 0) : void 0;
149
+ function ce(e) {
150
150
  return b(e)?.toolMetadata?.readOnly === !1;
151
151
  }
152
152
  function S(e) {
153
153
  return e && "state" in e ? e.state === "streaming" || e.state === "input-streaming" : !1;
154
154
  }
155
- var ce = 4e3, C = /^[ \t]*(?:(?:[-*+]|\d{1,9}[.)])[ \t]+|>[ \t]?)*(`{3,}|~{3,})(.*)$/gm;
156
- function w(e, t) {
155
+ var C = 4e3, w = /^[ \t]*(?:(?:[-*+]|\d{1,9}[.)])[ \t]+|>[ \t]?)*(`{3,}|~{3,})(.*)$/gm;
156
+ function T(e, t) {
157
157
  if (e.length <= t) return e;
158
158
  let n = e.length - t, r = n + t / 2, i = (e, t) => e !== -1 && e < r ? e + t : void 0, a = i(e.indexOf("\n\n", n), 2) ?? i(e.indexOf("\n", n), 1) ?? n, o;
159
- for (let t of e.matchAll(C)) {
159
+ for (let t of e.matchAll(w)) {
160
160
  if (t.index >= a) break;
161
161
  let [, e, n] = t;
162
162
  if (o) e[0] === o[0] && e.length >= o.length && !n.trim() && (o = void 0);
@@ -167,34 +167,34 @@ function w(e, t) {
167
167
  }
168
168
  return `…\n\n${o ? `${o}\n` : ""}${e.slice(a)}`;
169
169
  }
170
- var T = /* @__PURE__ */ new Set([
170
+ var E = /* @__PURE__ */ new Set([
171
171
  "approval-requested",
172
172
  "approval-responded",
173
173
  "output-denied"
174
174
  ]);
175
- function E(e) {
176
- return l(e) ? T.has(e.state) ? !0 : e.approval != null : !1;
177
- }
178
- var D = "requestConfirm";
179
- function O(e) {
180
- return l(e) && e.type === "tool-requestConfirm";
175
+ function D(e) {
176
+ return l(e) ? E.has(e.state) ? !0 : e.approval != null : !1;
181
177
  }
178
+ var O = "requestConfirm";
182
179
  function k(e) {
183
- return E(e) || O(e);
180
+ return l(e) && e.type === "tool-requestConfirm";
184
181
  }
185
182
  function A(e) {
186
- if (l(e)) return e.approval?.id;
183
+ return D(e) || k(e);
187
184
  }
188
185
  function j(e) {
186
+ if (l(e)) return e.approval?.id;
187
+ }
188
+ function M(e) {
189
189
  if (e && "state" in e) return e.state;
190
190
  }
191
- function M(e = "000000") {
191
+ function N(e = "000000") {
192
192
  let t = e.replace("#", "");
193
193
  t.length === 3 && (t = t.split("").map((e) => e + e).join(""));
194
194
  let n = parseInt(t.substring(0, 2), 16) / 255, r = parseInt(t.substring(2, 4), 16) / 255, i = parseInt(t.substring(4, 6), 16) / 255, a = (e) => e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
195
195
  return .2126 * a(n) + .7152 * a(r) + .0722 * a(i) > .179 ? "black" : "white";
196
196
  }
197
- function N(e) {
197
+ function P(e) {
198
198
  let t = e?.trim().replace("#", "") ?? "";
199
199
  if (/^[0-9a-f]{3}$/i.test(t) && (t = t.split("").map((e) => e + e).join("")), !/^[0-9a-f]{6}$/i.test(t)) return !1;
200
200
  let n = [
@@ -204,8 +204,8 @@ function N(e) {
204
204
  ].map((e) => parseInt(t.substring(e, e + 2), 16));
205
205
  return Math.max(...n) - Math.min(...n) < 32;
206
206
  }
207
- var P = (e) => `#${e.map((e) => e.toString(16).padStart(2, "0")).join("")}`;
208
- function F(e, t) {
207
+ var F = (e) => `#${e.map((e) => e.toString(16).padStart(2, "0")).join("")}`;
208
+ function I(e, t) {
209
209
  e.style.color = CSS.supports("color", "color-mix(in srgb, red 100%, transparent)") ? `color-mix(in srgb, ${t} 100%, transparent)` : t;
210
210
  let n = getComputedStyle(e).color;
211
211
  e.style.color = "";
@@ -220,11 +220,11 @@ function F(e, t) {
220
220
  i[3]
221
221
  ].map((e) => Math.round(Number(e))) : null;
222
222
  }
223
- function I(e, { mainColor: t, tones: n = "auto", secondColor: r }) {
223
+ function L(e, { mainColor: t, tones: n = "auto", secondColor: r }) {
224
224
  let i = document.createElement("span");
225
225
  i.hidden = !0, e.append(i);
226
226
  try {
227
- return L(i, {
227
+ return R(i, {
228
228
  mainColor: t,
229
229
  tones: n,
230
230
  secondColor: r
@@ -233,20 +233,20 @@ function I(e, { mainColor: t, tones: n = "auto", secondColor: r }) {
233
233
  i.remove();
234
234
  }
235
235
  }
236
- function L(e, { mainColor: t, tones: n, secondColor: r }) {
237
- let i = F(e, t ?? "currentcolor");
236
+ function R(e, { mainColor: t, tones: n, secondColor: r }) {
237
+ let i = I(e, t ?? "currentcolor");
238
238
  if (!i) return null;
239
- let a = P(i), o = N(a), s = (e, t = 0) => CSS.supports("color", "oklch(from red l c h)") ? `oklch(from ${e} clamp(0.55, l, 0.75) c calc(h + ${t}))` : e, c = F(e, s(o ? "var(--color-accent)" : a)), l = F(e, r ? s(r) : o ? s("var(--color-info)") : s(a, 40));
239
+ let a = F(i), o = P(a), s = (e, t = 0) => CSS.supports("color", "oklch(from red l c h)") ? `oklch(from ${e} clamp(0.55, l, 0.75) c calc(h + ${t}))` : e, c = I(e, s(o ? "var(--color-accent)" : a)), l = I(e, r ? s(r) : o ? s("var(--color-info)") : s(a, 40));
240
240
  return !c || !l ? null : {
241
241
  first: c,
242
242
  second: l,
243
243
  duo: n === "two" || n === "auto" && o
244
244
  };
245
245
  }
246
- function R(e, t) {
247
- return e === "white" || e === "black" ? e : M(t);
248
- }
249
246
  function z(e, t) {
247
+ return e === "white" || e === "black" ? e : N(t);
248
+ }
249
+ function B(e, t) {
250
250
  if (e) return {
251
251
  "--chatbot-main-color": e,
252
252
  "--chatbot-contrast-color": t,
@@ -255,10 +255,10 @@ function z(e, t) {
255
255
  "--input-focus-color": "var(--color-brand-graphic)"
256
256
  };
257
257
  }
258
- function B(e, t) {
258
+ function V(e, t) {
259
259
  if (!(t === void 0 || t < 50)) return e(t / 1e3, "seconds");
260
260
  }
261
- function V(e) {
261
+ function H(e) {
262
262
  if (e !== void 0) {
263
263
  if (typeof e == "string") return e.trim() || void 0;
264
264
  try {
@@ -269,10 +269,10 @@ function V(e) {
269
269
  }
270
270
  }
271
271
  }
272
- function H(e) {
273
- return V(e) !== void 0;
272
+ function U(e) {
273
+ return H(e) !== void 0;
274
274
  }
275
- function U(e, t) {
275
+ function W(e, t) {
276
276
  let n = e?.input;
277
277
  if (typeof t == "string") {
278
278
  let e = n?.question ?? n?.steps?.[0]?.question;
@@ -284,14 +284,14 @@ function U(e, t) {
284
284
  return i ? `${i} ${n}` : n;
285
285
  }).join(". ");
286
286
  }
287
- function W(e) {
287
+ function G(e) {
288
288
  return e?.options ? e.options.map((e) => ({
289
289
  label: e.label,
290
290
  value: e.label,
291
291
  description: e.description
292
292
  })) : [];
293
293
  }
294
- function G(e, t) {
294
+ function le(e, t) {
295
295
  let n = {};
296
296
  if (t == null) return n;
297
297
  if (typeof t == "string") return e.length === 1 && (n[0] = t), n;
@@ -307,7 +307,7 @@ function G(e, t) {
307
307
  for (let [e, n] of Object.entries(t)) n !== void 0 && r(e, n);
308
308
  return n;
309
309
  }
310
- var K = t.map((e) => `tool-${e}`), le = /* @__PURE__ */ new Set([
310
+ var K = a.map((e) => `tool-${e}`), ue = /* @__PURE__ */ new Set([
311
311
  "tool-searchInKnowledgeBase",
312
312
  "tool-retrieveRevisedAnswers",
313
313
  "tool-expandChunkContext",
@@ -318,8 +318,8 @@ var K = t.map((e) => `tool-${e}`), le = /* @__PURE__ */ new Set([
318
318
  "tool-saveUserMemory",
319
319
  ...K
320
320
  ]);
321
- function ue(e) {
322
- return l(e) && le.has(e.type);
321
+ function de(e) {
322
+ return l(e) && ue.has(e.type);
323
323
  }
324
324
  var q = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, J = (e, ...t) => {
325
325
  for (let n of t) {
@@ -327,7 +327,7 @@ var q = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, J =
327
327
  if (typeof t == "string" && t.trim()) return t;
328
328
  }
329
329
  };
330
- function de(e) {
330
+ function fe(e) {
331
331
  if (!l(e)) return;
332
332
  let t = q("input" in e ? e.input : void 0), n = q("output" in e ? e.output : void 0);
333
333
  if (e.type === "tool-searchInKnowledgeBase" || K.includes(e.type)) {
@@ -355,24 +355,24 @@ function de(e) {
355
355
  if (e.type === "tool-recallUserMemory") return J(t, "query");
356
356
  if (e.type === "tool-saveUserMemory") return J(t, "content", "query");
357
357
  }
358
- function fe(e) {
358
+ function pe(e) {
359
359
  let t = b(e);
360
360
  if (t) return x(t)?.icon ?? "ri:apps-line";
361
361
  if (l(e)) return e.type.includes("tool-subagent") ? "ri:robot-2-line" : e.type === "tool-runWorker" ? "ri:flow-chart" : e.type === "tool-scheduleWakeup" ? "ri:alarm-line" : e.type === "tool-fetchTeamsChannelHistory" ? "ri:chat-history-line" : e.type === "tool-readEarlierMessages" ? "ri:history-line" : e.type === "tool-readChatAttachment" ? "ri:attachment-line" : e.type === "tool-sendChatFile" ? "ri:send-plane-line" : e.type === "tool-enableTools" ? "ri:toggle-line" : e.type.includes("tool-mcp") ? "mcp" : e.type === "tool-retrieveRevisedAnswers" ? "ri:file-edit-line" : e.type === "tool-searchInKnowledgeBase" ? "ri:search-line" : e.type === "tool-expandChunkContext" ? "ri:file-search-line" : e.type === "tool-readDocumentFile" ? "ri:file-text-line" : e.type === "tool-readSpreadsheet" ? "ri:table-line" : e.type === "tool-editSpreadsheet" || e.type === "tool-createSpreadsheet" ? "ri:file-excel-2-line" : e.type === "tool-shareDocument" ? "ri:file-download-line" : e.type === "tool-readWordDocument" ? "ri:file-text-line" : e.type === "tool-editWordDocument" || e.type === "tool-createWordDocument" ? "ri:file-word-2-line" : e.type === "tool-querySpreadsheet" ? "ri:database-2-line" : e.type === "tool-geocode" ? "ri:map-2-line" : e.type === "tool-getWeather" ? "ri:sun-cloudy-line" : e.type === "tool-recallUserMemory" ? "ri:brain-line" : e.type === "tool-saveUserMemory" ? "ri:save-3-line" : e.type === "tool-showWeather" ? "ri:sun-line" : e.type === "tool-showDiagram" ? "ri:flow-chart" : e.type === "tool-showSources" ? "ri:book-2-line" : e.type === "tool-showForm" ? "ri:survey-line" : e.type === "tool-showMultipleChoice" ? "ri:checkbox-multiple-line" : e.type === "tool-showArtifact" ? "ri:file-code-line" : e.type === "tool-showEmail" ? "ri:mail-line" : e.type === "tool-showMessage" ? "ri:chat-1-line" : e.type === "tool-showWebPages" ? "ri:pages-line" : e.type === "tool-showProductList" ? "ri:shopping-bag-line" : e.type === "tool-showContactForm" ? "ri:send-plane-2-line" : e.type === "tool-showCalendarEvent" ? "ri:calendar-event-line" : e.type === "tool-showComparison" ? "ri:scales-line" : e.type === "tool-showLocation" ? "ri:map-pin-line" : e.type === "tool-showQrCode" ? "ri:qr-code-line" : e.type === "tool-showImageGallery" ? "ri:image-line" : e.type === "tool-showVideo" ? "ri:film-line" : e.type === "tool-showSuggestedReply" ? "ri:corner-down-right-line" : e.type === "tool-requestGeolocation" ? "ri:map-pin-user-line" : e.type === "tool-disconnectOAuthConnection" ? "ri:link-unlink" : e.type === "tool-requestAccountLink" ? "ri:link" : e.type === "tool-unlinkAccount" ? "ri:link-unlink" : K.includes(e.type) ? "ri:global-line" : "ri:tools-line";
362
362
  if (h(e)) return "ri:lightbulb-line";
363
363
  if (c(e)) return "ri:double-quotes-r";
364
364
  }
365
- var pe = [
365
+ var me = [
366
366
  i,
367
367
  n,
368
368
  r
369
369
  ];
370
370
  function Y(e, { t, te: n }) {
371
371
  if (n(`agent.tool.${e}`)) return t(`agent.tool.${e}`);
372
- let r = pe.find((t) => e.startsWith(t)), i = r ? e.slice(r.length) : e;
372
+ let r = me.find((t) => e.startsWith(t)), i = r ? e.slice(r.length) : e;
373
373
  return s(o(i).trim().toLowerCase());
374
374
  }
375
- var me = {
375
+ var he = {
376
376
  custom: (e) => e("messagePart.type.custom"),
377
377
  data: (e) => e("messagePart.type.data"),
378
378
  file: (e) => e("messagePart.type.file"),
@@ -382,13 +382,13 @@ var me = {
382
382
  "step-start": (e) => e("messagePart.type.stepStart"),
383
383
  text: (e) => e("messagePart.type.text")
384
384
  };
385
- function he(e, t) {
385
+ function ge(e, t) {
386
386
  if (l(e)) return Y(u(e), t);
387
387
  if (e.type === "dynamic-tool") return Y(e.toolName, t);
388
- let n = me[e.type.startsWith("data-") ? "data" : e.type];
388
+ let n = he[e.type.startsWith("data-") ? "data" : e.type];
389
389
  return n ? n(t.t) : s(o(e.type));
390
390
  }
391
- function ge(e, t) {
391
+ function _e(e, t) {
392
392
  if (!e) return e;
393
393
  let n = {
394
394
  Intent: t("conversationSummary.intent"),
@@ -398,7 +398,7 @@ function ge(e, t) {
398
398
  };
399
399
  return e.replace(/\*\*(Intent|Topics covered|Key facts|Open questions)(:?)\*\*/g, (e, t, r) => `**${n[t]}${r}**`);
400
400
  }
401
- function _e(e, t, n) {
401
+ function ve(e, t, n) {
402
402
  let r = b(t);
403
403
  if (r) {
404
404
  let t = r.toolCallId ? n?.[r.toolCallId] : void 0;
@@ -408,7 +408,7 @@ function _e(e, t, n) {
408
408
  }
409
409
  return l(t) ? t.type.includes("tool-subagent") ? e("messagePart.runSubagent") : t.type === "tool-runWorker" ? e("messagePart.runWorker") : t.type === "tool-scheduleWakeup" ? e("messagePart.scheduleWakeup") : t.type === "tool-fetchTeamsChannelHistory" ? e("messagePart.fetchTeamsChannelHistory") : t.type === "tool-readEarlierMessages" ? e("messagePart.readEarlierMessages") : t.type === "tool-readChatAttachment" ? e("messagePart.readChatAttachment") : t.type === "tool-sendChatFile" ? e("messagePart.sendChatFile") : t.type === "tool-enableTools" ? e("messagePart.enableTools") : t.type === "tool-retrieveRevisedAnswers" ? e("messagePart.revisedAnswers") : t.type === "tool-searchInKnowledgeBase" ? e("messagePart.searchingDocuments") : t.type === "tool-expandChunkContext" ? e("messagePart.expandChunkContext") : t.type === "tool-readDocumentFile" ? e("messagePart.readDocumentFile") : t.type === "tool-readSpreadsheet" ? e("messagePart.readSpreadsheet") : t.type === "tool-editSpreadsheet" ? e("messagePart.editSpreadsheet") : t.type === "tool-shareDocument" ? e("messagePart.shareDocument") : t.type === "tool-readWordDocument" ? e("messagePart.readWordDocument") : t.type === "tool-editWordDocument" ? e("messagePart.editWordDocument") : t.type === "tool-createSpreadsheet" ? e("messagePart.createSpreadsheet") : t.type === "tool-createWordDocument" ? e("messagePart.createWordDocument") : t.type === "tool-querySpreadsheet" ? e("messagePart.querySpreadsheet") : t.type === "tool-geocode" ? e("messagePart.geocode") : t.type === "tool-getWeather" ? e("messagePart.getWeather") : t.type === "tool-recallUserMemory" ? e("messagePart.recallUserMemory") : t.type === "tool-saveUserMemory" ? e("messagePart.saveUserMemory") : t.type === "tool-showWeather" ? e("messagePart.showWeather") : t.type === "tool-showForm" ? e("messagePart.showForm") : t.type === "tool-showDiagram" ? e("messagePart.showDiagram") : t.type === "tool-showSources" ? e("messagePart.showSources") : t.type === "tool-showMultipleChoice" ? e("messagePart.showMultipleChoice") : t.type === "tool-showArtifact" ? e("messagePart.showArtifact") : t.type === "tool-showEmail" ? e("messagePart.showEmail") : t.type === "tool-showMessage" ? e("messagePart.showMessage") : t.type === "tool-showWebPages" ? e("messagePart.showWebPages") : t.type === "tool-showProducts" ? e("messagePart.showProducts") : t.type === "tool-showContactForm" ? e("messagePart.showContactForm") : t.type === "tool-showCalendarEvent" ? e("messagePart.showCalendarEvent") : t.type === "tool-showComparison" ? e("messagePart.showComparison") : t.type === "tool-showLocation" ? e("messagePart.showLocation") : t.type === "tool-showQrCode" ? e("messagePart.showQrCode") : t.type === "tool-showImageGallery" ? e("messagePart.showImageGallery") : t.type === "tool-showVideo" ? e("messagePart.showVideo") : t.type === "tool-showSuggestedReply" ? e("messagePart.showSuggestedReply") : t.type === "tool-requestGeolocation" ? e("messagePart.requestGeolocation") : t.type === "tool-disconnectOAuthConnection" ? e("messagePart.disconnectOAuthConnection") : t.type === "tool-requestAccountLink" ? e("messagePart.requestAccountLink") : t.type === "tool-unlinkAccount" ? e("messagePart.unlinkAccount") : K.includes(t.type) ? e("messagePart.webSearch") : e("messagePart.tool") : h(t) ? e("messagePart.reasoning") : e("messagePart.streaming");
410
410
  }
411
- var ve = {
411
+ var ye = {
412
412
  calibri: "Calibri, Carlito, \"Segoe UI\", Arial, sans-serif",
413
413
  "calibri light": "\"Calibri Light\", Calibri, Carlito, \"Segoe UI\", sans-serif",
414
414
  aptos: "Aptos, Calibri, Carlito, \"Segoe UI\", Arial, sans-serif",
@@ -422,7 +422,7 @@ var ve = {
422
422
  georgia: "Georgia, serif",
423
423
  verdana: "Verdana, \"DejaVu Sans\", sans-serif",
424
424
  tahoma: "Tahoma, Verdana, sans-serif"
425
- }, ye = {
425
+ }, be = {
426
426
  calibri: 1.22,
427
427
  "calibri light": 1.22,
428
428
  cambria: 1.17,
@@ -433,10 +433,10 @@ var ve = {
433
433
  georgia: 1.14,
434
434
  verdana: 1.22,
435
435
  tahoma: 1.21
436
- }, be = (e) => ye[e.toLowerCase()] ?? 1.17, xe = (e) => ve[e.toLowerCase()] ?? `"${e.replace(/"/g, "")}", ${/roman|garamond|cambria|georgia|serif|book|times/i.test(e) ? "Georgia, serif" : "Calibri, Carlito, \"Segoe UI\", Arial, sans-serif"}`, Se = Symbol("wordPreviewImages"), Ce = (e, t) => {
436
+ }, xe = (e) => be[e.toLowerCase()] ?? 1.17, Se = (e) => ye[e.toLowerCase()] ?? `"${e.replace(/"/g, "")}", ${/roman|garamond|cambria|georgia|serif|book|times/i.test(e) ? "Georgia, serif" : "Calibri, Carlito, \"Segoe UI\", Arial, sans-serif"}`, Ce = Symbol("wordPreviewImages"), X = (e, t) => {
437
437
  let n = e?.[t];
438
438
  return n?.startsWith("data:image/webp;base64,") ? n : void 0;
439
- }, X = (e, t) => {
439
+ }, we = (e, t) => {
440
440
  let n = e.anchor;
441
441
  return {
442
442
  left: `${n.xFrom === "page" ? n.x : t.margins.left + n.x}pt`,
@@ -448,7 +448,7 @@ var ve = {
448
448
  }, Z = (e) => {
449
449
  let t = e.anchor;
450
450
  return t ? t.wrap === "around" ? "around" : t.wrap === "block" ? "block" : t.yFrom === "paragraph" ? "paragraph" : "page" : "inline";
451
- }, Q = (e, t) => e.filter((e) => t === "accepted" ? e.change !== "deleted" : t !== "original" || e.change !== "inserted"), $ = (e) => e.some((e) => e.image || e.text.trim()), we = (e, t) => {
451
+ }, Q = (e, t) => e.filter((e) => t === "accepted" ? e.change !== "deleted" : t !== "original" || e.change !== "inserted"), $ = (e) => e.some((e) => e.image || e.text.trim()), Te = (e, t) => {
452
452
  let n = [], r = !1, i, a = (e, t, a, o, s, c) => {
453
453
  let l = s ?? i;
454
454
  n.push({
@@ -470,11 +470,11 @@ var ve = {
470
470
  }), o(r, i);
471
471
  } else !e.runs.length || $(Q(e.runs, t)) ? a(`${n}`, n, void 0, !!e.style?.pageBreakBefore, e.section, !!e.style?.keepNext) : o(!!e.style?.pageBreakBefore, e.section);
472
472
  }), n;
473
- }, Te = (e, t) => e.flatMap((e) => e.kind === "table" ? [] : Q(e.runs, t).flatMap((e) => e.picture && Z(e.picture) === "page" ? [e.picture] : [])), Ee = (e, t) => t ? e.replace(RegExp(` \\(v${t}\\)(\\.\\w+)$`), "$1") : e;
474
- function De(e, t) {
473
+ }, Ee = (e, t) => e.flatMap((e) => e.kind === "table" ? [] : Q(e.runs, t).flatMap((e) => e.picture && Z(e.picture) === "page" ? [e.picture] : [])), De = (e, t) => t ? e.replace(RegExp(` \\(v${t}\\)(\\.\\w+)$`), "$1") : e;
474
+ function Oe(e, t) {
475
475
  let n = t / 2;
476
476
  return e.left <= n && e.right >= n && e.top <= 92 && e.bottom >= 48;
477
477
  }
478
- export { l as $, ge as A, be as B, H as C, se as D, k as E, V as F, f as G, Te as H, Y as I, u as J, p as K, we as L, y as M, R as N, S as O, I as P, c as Q, xe as R, de as S, N as T, Z as U, X as V, Ce as W, d as X, ee as Y, h as Z, fe as _, Se as a, A as b, Ee as c, U as d, m as et, G as f, w as g, b as h, K as i, ne as j, O as k, _ as l, B as m, ae as n, z as o, W as p, te as q, ce as r, De as s, D as t, re as u, j as v, ue as w, _e as x, he as y, Q as z };
478
+ export { c as $, k as A, Q as B, fe as C, A as D, P as E, L as F, X as G, we as H, H as I, te as J, f as K, Y as L, ne as M, y as N, ce as O, z as P, h as Q, Te as R, ve as S, de as T, Ee as U, xe as V, Z as W, ee as X, u as Y, d as Z, T as _, K as a, ge as b, Oe as c, re as d, l as et, W as f, b as g, V as h, C as i, _e as j, S as k, De as l, G as m, oe as n, Ce as o, le as p, p as q, ae as r, B as s, O as t, m as tt, _ as u, pe as v, U as w, j as x, M as y, Se as z };
479
479
 
480
- //# sourceMappingURL=utils-euH8esYP.js.map
480
+ //# sourceMappingURL=utils-CbhqxYyx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-CbhqxYyx.js","names":["isHostToolPart","isPresentationTool","MCP_TOOL_PREFIX","SUBAGENT_TOOL_PREFIX","API_TOOL_PREFIX","WEB_SEARCH_TOOL_KEYS","fromAnyCase","capitalizeFirstLetter","isTextPart","part","isToolPart","getToolPartName","isFilePart","getFilePartMedia","media","getFilePartTranscript","transcript","withAudioTranscripts","messages","own","updates","update","message","storedFileName","isReasoningPart","hasTextPart","getTextPart","parts","mergeConsecutiveTextParts","merged","prev","isWidgetPart","dropCorrectedWidgetErrors","lastDrawn","index","isStreamingPart","FILE_OUTPUT_PARTS","moveFileOutputsLast","files","feedPartKey","toolCallId","getHostCallPart","PAGE_TOOL_STEPS","HOST_STEP_TITLES","HOST_STEP_CHANGES","FORM_TOOL_STEP","pageToolStep","host","isHostActionPart","LIVE_REASONING_TAIL_LENGTH","FENCE_LINE","getMarkdownTail","markdown","maxLength","from","limit","boundary","length","cut","openFence","match","marker","rest","TOOL_APPROVAL_STATES","isToolApprovalPart","CONFIRM_TOOL_NAME","isToolConfirmPart","isConfirmationCardPart","getToolApprovalId","getPartState","getContrast","hex","hexcolor","char","r","g","b","linearize","c","isAchromaticColor","channels","at","channelsToHex","value","readCssColor","expression","computed","probe","srgb","rgb","resolveGlowTints","readGlowTints","source","mainColor","sourceHex","neutral","middle","color","hueShift","first","second","secondColor","tones","resolveContrastColor","textColor","agentThemeStyle","contrastColor","formatDuration","ms","$n","stringifyPayload","json","hasPayload","formAnswerAsSpoken","input","answer","question","questionById","step","said","id","formStepOptions","option","formAnswerSlots","slots","output","steps","assign","list","WEB_SEARCH_TOOL_TYPES","key","RICH_DETAIL_TOOL_TYPES","hasRichToolDetail","asRecord","pickString","keys","record","getToolPartSummary","queries","valid","query","sheet","range","getPartIcon","TOOL_KEY_PREFIXES","toolLabel","te","name","prefix","p","bare","PART_TYPE_LABELS","t","getPartTypeLabel","translator","label","localizeSummaryLabels","summary","labels","colon","getToolPartLabel","live","hostStepTitles","page","$t","WORD_FONT_STACKS","WORD_LINE_FACTORS","wordLineFactor","font","wordFontStack","WORD_PREVIEW_IMAGES","wordPictureSrc","src","images","ref","wordPageAnchorCss","anchor","picture","wordPicturePlacement","wordKeptRuns","runs","mode","hasWordText","wordFlowItems","out","breakPending","sectionPending","push","opens","section","row","breakBefore","keepNext","skip","blocks","block","breaks","cell","cells","wordPageAnchors","run","chatFileName","version","filename","chatCoversPageControlBar","center","windowWidth","chat"],"sources":["../../../../packages/utils/src/message.ts","../../../../packages/components/src/chat/utils.ts"],"sourcesContent":["import type { UIMessage } from 'ai'\nimport type { ChatAudioTranscript, MediaSource, UIChatMessage } from 'models'\n\ntype MessagePart = UIMessage['parts'][number]\n\nexport function isTextPart(\n part?: MessagePart | null | undefined,\n): part is Extract<MessagePart, { type: 'text' }> {\n if (!part) {\n return false\n }\n return part.type === 'text'\n}\n\nexport function isToolPart(\n part?: MessagePart | null | undefined,\n): part is Extract<MessagePart, { type: `tool-${string}` }> {\n if (!part) {\n return false\n }\n return part.type.startsWith('tool-')\n}\n\nexport function getToolPartName(part?: MessagePart): string {\n if (!isToolPart(part)) {\n return ''\n }\n return part.type.slice('tool-'.length)\n}\n\nexport function isFilePart(\n part?: MessagePart | null | undefined,\n): part is Extract<MessagePart, { type: 'file' }> {\n if (!part) {\n return false\n }\n return part.type === 'file'\n}\n\n/**\n * Returns the persisted `MediaSource` carried by a file part, when present.\n * Uploaded attachments stash the full upload metadata (size, extension,\n * storage handle…) under `providerMetadata['8bot'].media`, which survives\n * persistence — so saved messages can surface size/details without a schema\n * change or extra request.\n */\nexport function getFilePartMedia(\n part?: MessagePart | null | undefined,\n): MediaSource | undefined {\n if (!isFilePart(part)) {\n return undefined\n }\n const container = part.providerMetadata?.['8bot'] as\n { media?: unknown } | undefined\n const media = container?.media\n return media && typeof media === 'object' && !Array.isArray(media)\n ? (media as MediaSource)\n : undefined\n}\n\n/**\n * Returns the transcript a chat turn stamped on an audio file part, under\n * `providerMetadata['8bot'].transcript` (spec `audio-file-transcription.md`,\n * D4), when present.\n */\nexport function getFilePartTranscript(\n part?: MessagePart | null | undefined,\n): ChatAudioTranscript | undefined {\n if (!isFilePart(part)) {\n return undefined\n }\n const container = part.providerMetadata?.['8bot'] as\n { transcript?: unknown } | undefined\n const transcript = container?.transcript\n return transcript &&\n typeof transcript === 'object' &&\n !Array.isArray(transcript)\n ? (transcript as ChatAudioTranscript)\n : undefined\n}\n\n/** The transcript a turn made of one audio the client sent, as streamed. */\nexport interface AudioTranscriptUpdate {\n messageId: string\n storedFileName: string\n transcript: ChatAudioTranscript\n}\n\n/**\n * The messages with the transcripts a turn streamed (`data-audioTranscripts`)\n * stamped on their audio parts: the stored message has them, the client's\n * copy of the message it sent gets them here. What the updates do not name is\n * returned as it was, the same objects.\n */\nexport function withAudioTranscripts<T extends UIMessage>(\n messages: T[],\n updates: AudioTranscriptUpdate[],\n): T[] {\n return messages.map((message) => {\n const own = updates.filter((update) => update.messageId === message.id)\n if (own.length === 0) {\n return message\n }\n return {\n ...message,\n parts: message.parts.map((part) => {\n const update = own.find(\n ({ storedFileName }) =>\n storedFileName ===\n getFilePartMedia(part)?.storedFileName,\n )\n return update && isFilePart(part)\n ? {\n ...part,\n providerMetadata: {\n ...part.providerMetadata,\n '8bot': {\n ...part.providerMetadata?.['8bot'],\n transcript: update.transcript,\n },\n },\n }\n : part\n }),\n }\n })\n}\n\nexport function isReasoningPart(\n part?: MessagePart | null | undefined,\n): part is Extract<MessagePart, { type: 'reasoning' }> {\n if (!part) {\n return false\n }\n return part.type === 'reasoning'\n}\n\nexport function hasPartText(\n part?: MessagePart | null | undefined,\n): part is Extract<MessagePart, { text: string }> {\n if (!part) {\n return false\n }\n if (isTextPart(part)) {\n return true\n }\n return (\n 'text' in part &&\n part.text !== undefined &&\n part.text !== null &&\n part.text !== ''\n )\n}\n\nexport function hasTextPart(\n message?: UIMessage | UIChatMessage | null | undefined,\n): boolean {\n if (!message) {\n return false\n }\n return (message as UIMessage).parts.some((part) => isTextPart(part))\n}\n\nexport function getTextPart(\n message?: UIMessage | UIChatMessage | null | undefined,\n): string | undefined {\n if (!message) {\n return undefined\n }\n const parts = (message as UIMessage).parts\n if (!Array.isArray(parts)) {\n return undefined\n }\n const textPart = parts.find((part) => isTextPart(part))\n return textPart?.text\n}\n\nexport function getMessageText(\n message?: UIMessage | UIChatMessage | null | undefined,\n): string {\n if (!message) {\n return ''\n }\n const parts = (message as UIMessage).parts\n if (!Array.isArray(parts)) {\n return ''\n }\n return parts\n .filter((p): p is Extract<MessagePart, { type: 'text' }> =>\n isTextPart(p),\n )\n .map((p) => p.text)\n .join('')\n}\n","import type { UIMessage } from 'ai'\nimport type { CSSProperties, InjectionKey, Ref } from 'vue'\nimport {\n API_TOOL_PREFIX,\n MCP_TOOL_PREFIX,\n SUBAGENT_TOOL_PREFIX,\n WEB_SEARCH_TOOL_KEYS,\n isHostToolPart,\n isPresentationTool,\n type WordPreviewBlock,\n type WordPreviewPage,\n type WordPreviewPicture,\n type WordPreviewRun,\n} from 'models'\nimport {\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n hasPartText,\n hasTextPart,\n getTextPart,\n getMessageText,\n getToolPartName,\n capitalizeFirstLetter,\n fromAnyCase,\n} from 'utils'\n\nexport {\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n hasPartText,\n hasTextPart,\n getTextPart,\n getMessageText,\n}\n\n/**\n * Merges consecutive text parts into a single text part.\n * Claude (and other models) often produce multiple text parts during streaming\n * that should logically be a single block of text.\n */\nexport function mergeConsecutiveTextParts(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const merged: UIMessage['parts'] = []\n for (const part of parts) {\n if (!isTextPart(part)) {\n merged.push(part)\n continue\n }\n const prev = merged[merged.length - 1]\n if (prev && isTextPart(prev)) {\n merged[merged.length - 1] = { ...prev, text: prev.text + part.text }\n } else {\n merged.push(part)\n }\n }\n return merged\n}\n\nconst isWidgetPart = (\n part: UIMessage['parts'][number],\n): part is Extract<UIMessage['parts'][number], { type: `tool-${string}` }> =>\n isToolPart(part) && isPresentationTool(getToolPartName(part))\n\n/**\n * Drops a widget call refused for its arguments when a later call of the same\n * widget in the message was drawn: the turn corrected it (the backend's\n * `correctableInputRefusals`), and the refusal would sit next to the working\n * widget, `showForm` drawing its render error above the form. A refusal with\n * nothing drawn after it stays. Only the feed reads this: the steps timeline\n * keeps every call, the refused one included.\n */\nexport function dropCorrectedWidgetErrors(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const lastDrawn = new Map<string, number>()\n for (const [index, part] of parts.entries()) {\n if (\n isWidgetPart(part) &&\n part.state !== 'output-error' &&\n !isStreamingPart(part)\n ) {\n lastDrawn.set(part.type, index)\n }\n }\n return parts.filter(\n (part, index) =>\n !(\n isWidgetPart(part) &&\n part.state === 'output-error' &&\n (lastDrawn.get(part.type) ?? -1) > index\n ),\n )\n}\n\n/**\n * Tool calls whose output is a file for the user to download. The feed draws\n * them after the answer, where the reader arrives, wherever in the message the\n * model made the call: a version written before a long answer sat above it,\n * out of sight.\n */\nconst FILE_OUTPUT_PARTS: ReadonlySet<string> = new Set([\n 'tool-editSpreadsheet',\n 'tool-shareDocument',\n 'tool-editWordDocument',\n 'tool-createSpreadsheet',\n 'tool-createWordDocument',\n])\n\n/** The parts with the file outputs moved last, in their own order. */\nexport function moveFileOutputsLast(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const files = parts.filter((part) => FILE_OUTPUT_PARTS.has(part.type))\n return files.length > 0\n ? [\n ...parts.filter((part) => !FILE_OUTPUT_PARTS.has(part.type)),\n ...files,\n ]\n : parts\n}\n\n/**\n * The key of a part in the feed. Its position, except for a file output: that\n * one is always last, so its position moves as the answer grows, and keyed by\n * it the card would be redrawn at every new part.\n */\nexport function feedPartKey(\n part: UIMessage['parts'][number],\n index: number,\n): string | number {\n const toolCallId = (part as { toolCallId?: string }).toolCallId\n return FILE_OUTPUT_PARTS.has(part.type) && toolCallId\n ? `file-${toolCallId}`\n : index\n}\n\n/** A call the embedding page runs, as the backend stamped it (spec `host-tools.md`). */\ninterface HostCallPart {\n toolCallId?: string\n toolName: string\n title?: string\n state?: string\n errorText?: string\n toolMetadata?: { readOnly?: boolean; provider?: 'app' | 'page' }\n}\n\nexport function getHostCallPart(\n part: UIMessage['parts'][number] | null | undefined,\n): HostCallPart | undefined {\n return isHostToolPart(part) ? (part as unknown as HostCallPart) : undefined\n}\n\n/**\n * The page tools of the widget (spec `page-tools.md`): defined by the backend,\n * so their step is ours to name, in the user's language. A tool the app\n * registered is named by its own `title`.\n */\nconst PAGE_TOOL_STEPS: Record<string, { icon: string; label: string }> = {\n page_snapshot: {\n icon: 'ri:pages-line',\n label: 'messagePart.pageTool.snapshot',\n },\n page_read: {\n icon: 'ri:file-text-line',\n label: 'messagePart.pageTool.read',\n },\n page_click: { icon: 'ri:cursor-line', label: 'messagePart.pageTool.click' },\n page_fill: { icon: 'ri:edit-line', label: 'messagePart.pageTool.fill' },\n page_scroll: {\n icon: 'ri:arrow-up-down-line',\n label: 'messagePart.pageTool.scroll',\n },\n page_find: { icon: 'ri:search-line', label: 'messagePart.pageTool.find' },\n page_wait: { icon: 'ri:time-line', label: 'messagePart.pageTool.wait' },\n page_hover: {\n icon: 'ri:cursor-line',\n label: 'messagePart.pageTool.hover',\n },\n page_press: {\n icon: 'ri:keyboard-line',\n label: 'messagePart.pageTool.press',\n },\n page_back: {\n icon: 'ri:arrow-go-back-line',\n label: 'messagePart.pageTool.back',\n },\n page_navigate: {\n icon: 'ri:links-line',\n label: 'messagePart.pageTool.navigate',\n },\n}\n\n/**\n * The titles the widget gave this page's steps, by call, naming what each\n * acts on (spec `page-tools-improvements.md`, M8): provided by the chat view\n * from its store, read by the views that list the steps.\n */\nexport const HOST_STEP_TITLES: InjectionKey<Ref<Record<string, string>>> =\n Symbol('hostStepTitles')\n\n/** A setting a step changes: what it was, what it becomes. */\nexport type StepFieldChange = { label: string; value: string; before?: string }\n\n/**\n * What the steps the automatic confirmations ran without a card changed, by\n * call (spec `auto-confirmations.md`): provided by the chat view from its\n * store, shown under each step's line.\n */\nexport const HOST_STEP_CHANGES: InjectionKey<\n Ref<\n Record<\n string,\n {\n details?: StepFieldChange[]\n unchanged?: { label: string; value: string }[]\n }\n >\n >\n> = Symbol('hostStepChanges')\n\n/** A form the site annotated for agents: its tool is named `form_<toolname>`. */\nconst FORM_TOOL_STEP = {\n icon: 'ri:survey-line',\n label: 'messagePart.pageTool.form',\n}\n\nconst pageToolStep = (host: HostCallPart) =>\n host.toolMetadata?.provider === 'page'\n ? (PAGE_TOOL_STEPS[host.toolName] ??\n (host.toolName.startsWith('form_') ? FORM_TOOL_STEP : undefined))\n : undefined\n\n/**\n * A host call that changes something in the app or on the page: the feed\n * shows it even without the steps timeline, because what it did stays done.\n */\nexport function isHostActionPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return getHostCallPart(part)?.toolMetadata?.readOnly === false\n}\n\nexport function isStreamingPart(\n part: UIMessage['parts'][number] | null | undefined,\n): part is Extract<UIMessage['parts'][number], { streaming?: boolean }> {\n if (!part) {\n return false\n }\n if ('state' in part) {\n return part.state === 'streaming' || part.state === 'input-streaming'\n }\n return false\n}\n\n/**\n * How much of a reasoning still being written its live box renders. The box is\n * a few lines tall and follows the bottom, while the reasoning of one turn runs\n * to tens of kilobytes: chat `st0Eg8iG0zUX0HQN` wrote 92KB, and parsing all of\n * it at every delta froze the tab. Four thousand characters leave a few screens\n * to scroll back through, and a finished step renders all of it.\n */\nexport const LIVE_REASONING_TAIL_LENGTH = 4000\n\n// A fence opener or closer, also inside a list item or a quote, whose markers\n// and indentation are skipped. The rest of the line tells them apart: a\n// closing fence carries no info string.\nconst FENCE_LINE =\n /^[ \\t]*(?:(?:[-*+]|\\d{1,9}[.)])[ \\t]+|>[ \\t]?)*(`{3,}|~{3,})(.*)$/gm\n\n/**\n * The end of a markdown text, at most `maxLength` characters long, cut on a\n * blank line (a line break when there is none) so it does not open on half a\n * paragraph. A table or a formula can still be cut in two. An ellipsis marks\n * the cut. A cut inside a fenced code block reopens the fence, or the rest of\n * the text would render as code and the code as prose.\n */\nexport function getMarkdownTail(markdown: string, maxLength: number): string {\n if (markdown.length <= maxLength) {\n return markdown\n }\n const from = markdown.length - maxLength\n // The boundary is looked for in the first half of the window only: the one\n // blank line of the window can be the last thing written, and cutting there\n // would leave nothing to render.\n const limit = from + maxLength / 2\n const boundary = (index: number, length: number) =>\n index !== -1 && index < limit ? index + length : undefined\n const cut =\n boundary(markdown.indexOf('\\n\\n', from), 2) ??\n boundary(markdown.indexOf('\\n', from), 1) ??\n from\n let openFence: string | undefined\n for (const match of markdown.matchAll(FENCE_LINE)) {\n if (match.index >= cut) {\n break\n }\n const [, marker, rest] = match\n if (!openFence) {\n // A backtick in a backtick fence's info string makes it inline\n // code, not a fence.\n if (marker[0] === '`' && rest.includes('`')) {\n continue\n }\n openFence = marker\n } else if (\n marker[0] === openFence[0] &&\n marker.length >= openFence.length &&\n !rest.trim()\n ) {\n openFence = undefined\n }\n }\n const reopen = openFence ? `${openFence}\\n` : ''\n return `…\\n\\n${reopen}${markdown.slice(cut)}`\n}\n\n/**\n * States a tool part goes through when it needs the user's approval. They are\n * rendered by `PkToolApprovalCard` whatever the tool is, so the decision (and\n * its outcome) stays visible in the transcript.\n */\nconst TOOL_APPROVAL_STATES = new Set([\n 'approval-requested',\n 'approval-responded',\n 'output-denied',\n])\n\nexport function isToolApprovalPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n if (!isToolPart(part)) {\n return false\n }\n if (TOOL_APPROVAL_STATES.has(part.state)) {\n return true\n }\n // An executed (or errored) call that went through the gate keeps its\n // verdict in `approval`: the card stays in the transcript, so the user's\n // decision remains visible in the chat and in the log viewers (parity\n // with requestConfirm, whose 'confirmed' output is persisted).\n return (part as { approval?: unknown }).approval != null\n}\n\n/**\n * The client-side tool the model uses to have an action it described approved.\n * It predates the SDK's approval gate and keeps its own round-trip (it resolves\n * through `addToolOutput`), but it asks the user the very same question, so it\n * shares `PkToolApprovalCard` instead of having a card of its own.\n */\nexport const CONFIRM_TOOL_NAME = 'requestConfirm'\n\nexport function isToolConfirmPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return isToolPart(part) && part.type === `tool-${CONFIRM_TOOL_NAME}`\n}\n\n/** True for any part the confirmation card is responsible for. */\nexport function isConfirmationCardPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return isToolApprovalPart(part) || isToolConfirmPart(part)\n}\n\n/** The id of the pending approval request on a tool part, if any. */\nexport function getToolApprovalId(\n part: UIMessage['parts'][number] | null | undefined,\n): string | undefined {\n if (!isToolPart(part)) {\n return undefined\n }\n return (part as { approval?: { id?: string } }).approval?.id\n}\n\nexport function getPartState(\n part: UIMessage['parts'][number] | null | undefined,\n): string | undefined {\n if (!part) {\n return undefined\n }\n if ('state' in part) {\n return part.state\n }\n return undefined\n}\n\nexport function isLoadingState(state?: string): boolean {\n if (!state) {\n return false\n }\n return ['streaming'].includes(state)\n}\n\nexport function getContrast(hexcolor: string = '000000'): 'black' | 'white' {\n let hex = hexcolor.replace('#', '')\n\n // Expand 3-character hex to 6-character (e.g., #ccc -> #cccccc)\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map((char) => char + char)\n .join('')\n }\n\n // WCAG relative luminance\n const r = parseInt(hex.substring(0, 2), 16) / 255\n const g = parseInt(hex.substring(2, 4), 16) / 255\n const b = parseInt(hex.substring(4, 6), 16) / 255\n\n const linearize = (c: number) =>\n c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n\n const luminance =\n 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b)\n\n return luminance > 0.179 ? 'black' : 'white'\n}\n\n/**\n * True for a hex color with almost no hue: black, white and the grays between.\n * Anything else, a color the function cannot read included, counts as colored.\n */\nexport function isAchromaticColor(hexcolor: string | undefined): boolean {\n let hex = hexcolor?.trim().replace('#', '') ?? ''\n if (/^[0-9a-f]{3}$/i.test(hex)) {\n hex = hex\n .split('')\n .map((char) => char + char)\n .join('')\n }\n if (!/^[0-9a-f]{6}$/i.test(hex)) {\n return false\n }\n const channels = [0, 2, 4].map((at) =>\n parseInt(hex.substring(at, at + 2), 16),\n )\n return Math.max(...channels) - Math.min(...channels) < 32\n}\n\n/** A color as the glow's shader takes it: three channels, 0-255. */\nexport type RgbChannels = [number, number, number]\n\n/** The two tints of the empty chat's glow, and whether the second shows. */\nexport type GlowTints = {\n first: RgbChannels\n second: RgbChannels\n duo: boolean\n}\n\n/** `#rrggbb` from three 0-255 channels. */\nexport const channelsToHex = (channels: RgbChannels) =>\n `#${channels.map((value) => value.toString(16).padStart(2, '0')).join('')}`\n\n/**\n * The color a CSS expression resolves to where `probe` sits. Mixed into sRGB\n * first, it computes to `color(srgb r g b)` whatever syntax it was written in\n * (the design system's tokens derive with the relative color syntax). A\n * browser without `color-mix()` would drop the mix and leave the inherited\n * color for every expression: it reads the bare one, which computes to `rgb()`.\n */\nfunction readCssColor(\n probe: HTMLElement,\n expression: string,\n): RgbChannels | null {\n probe.style.color = CSS.supports(\n 'color',\n 'color-mix(in srgb, red 100%, transparent)',\n )\n ? `color-mix(in srgb, ${expression} 100%, transparent)`\n : expression\n const computed = getComputedStyle(probe).color\n probe.style.color = ''\n const srgb = computed.match(/^color\\(srgb ([^\\s)]+) ([^\\s)]+) ([^\\s)]+)/)\n const rgb = computed.match(/rgba?\\(([\\d.]+)[,\\s]+([\\d.]+)[,\\s]+([\\d.]+)/)\n if (srgb) {\n return [srgb[1], srgb[2], srgb[3]].map((value) =>\n Math.round(Math.min(1, Math.max(0, Number(value))) * 255),\n ) as RgbChannels\n }\n if (rgb) {\n return [rgb[1], rgb[2], rgb[3]].map((value) =>\n Math.round(Number(value)),\n ) as RgbChannels\n }\n return null\n}\n\n/**\n * The two tints of the glow behind the empty chat's input. A color without a\n * hue (black, the default, white, a gray) drew a grey smudge on the light\n * theme and nothing on the dark one: the platform's accent lights it instead,\n * with its info color as the second tone, as the working beam does. Any other\n * color gives its neighbour 40° along the hue wheel as the second tone,\n * unless the agent chose one. Every tone is held to a middle lightness, like\n * the beam's, so a chosen second color that matches the one shown keeps the\n * glow as it was. `auto` shows the second tone only for a color without a hue.\n *\n * The colors resolve where `host` sits (its tokens, its theme); without\n * `mainColor` the glow starts from the host's own color. Null when the\n * browser cannot read them.\n */\nexport function resolveGlowTints(\n host: HTMLElement,\n {\n mainColor,\n tones = 'auto',\n secondColor,\n }: {\n mainColor?: string\n tones?: 'auto' | 'one' | 'two'\n secondColor?: string\n },\n): GlowTints | null {\n // A throwaway child inherits the host's color and custom properties, and\n // reading through it leaves the host's own style alone\n const probe = document.createElement('span')\n probe.hidden = true\n host.append(probe)\n try {\n return readGlowTints(probe, { mainColor, tones, secondColor })\n } finally {\n probe.remove()\n }\n}\n\nfunction readGlowTints(\n probe: HTMLElement,\n {\n mainColor,\n tones,\n secondColor,\n }: {\n mainColor?: string\n tones: 'auto' | 'one' | 'two'\n secondColor?: string\n },\n): GlowTints | null {\n const source = readCssColor(probe, mainColor ?? 'currentcolor')\n if (!source) {\n return null\n }\n const sourceHex = channelsToHex(source)\n const neutral = isAchromaticColor(sourceHex)\n // Where the browser can derive it; the color as it is otherwise\n const middle = (color: string, hueShift = 0) =>\n CSS.supports('color', 'oklch(from red l c h)')\n ? `oklch(from ${color} clamp(0.55, l, 0.75) c calc(h + ${hueShift}))`\n : color\n const first = readCssColor(\n probe,\n middle(neutral ? 'var(--color-accent)' : sourceHex),\n )\n const second = readCssColor(\n probe,\n secondColor\n ? middle(secondColor)\n : neutral\n ? middle('var(--color-info)')\n : middle(sourceHex, 40),\n )\n if (!first || !second) {\n return null\n }\n return {\n first,\n second,\n duo: tones === 'two' || (tones === 'auto' && neutral),\n }\n}\n\n/**\n * Resolves the contrast color based on the user's `textColor` preference.\n * Falls back to WCAG auto-detection via `getContrast` when set to `'auto'` or `undefined`.\n */\nexport function resolveContrastColor(\n textColor: 'auto' | 'white' | 'black' | undefined,\n mainColor: string | undefined,\n): 'black' | 'white' {\n if (textColor === 'white' || textColor === 'black') {\n return textColor\n }\n return getContrast(mainColor)\n}\n\n/**\n * The style of a chat root (PkChatbot, the widget's shell): the agent's color\n * as the brand. Volver derives every role of the brand (graphic, readable,\n * contrast, tinted surface) on any element with `.theme`, which both roots\n * carry, so the focus ring, the primary buttons, the links and the checkboxes\n * take the agent's color with the contrast each theme needs, instead of the\n * platform's purple. The fields' focus takes the brand's graphic role in both\n * themes, since the dark theme's accent is the platform's too.\n */\nexport function agentThemeStyle(\n mainColor: string | undefined,\n contrastColor: 'black' | 'white',\n): Record<string, string> | undefined {\n if (!mainColor) {\n return undefined\n }\n return {\n '--chatbot-main-color': mainColor,\n '--chatbot-contrast-color': contrastColor,\n '--color-brand': mainColor,\n '--color-brand-contrast': contrastColor,\n '--input-focus-color': 'var(--color-brand-graphic)',\n }\n}\n\n/**\n * Formats a duration in milliseconds using the i18n `seconds` number format\n * (e.g. \"12,4 secondi\" / \"12.4 seconds\"). Returns undefined for durations\n * that would render as \"0 seconds\" (less than 0.05s).\n */\nexport function formatDuration(\n $n: (value: number, format: string) => string,\n ms?: number,\n): string | undefined {\n if (ms === undefined || ms < 50) {\n return undefined\n }\n return $n(ms / 1000, 'seconds')\n}\n\n/**\n * Stringifies a tool payload for the raw fallback view. Returns undefined for\n * empty values so the caller can skip rendering the block entirely.\n */\nexport function stringifyPayload(value: unknown): string | undefined {\n if (value === undefined) {\n return undefined\n }\n if (typeof value === 'string') {\n return value.trim() || undefined\n }\n try {\n const json = JSON.stringify(value, null, 2)\n return json === '{}' || json === '[]' ? undefined : json\n } catch {\n return undefined\n }\n}\n\n/**\n * True when a tool payload carries something worth rendering, so a caller can\n * skip the block without stringifying the value twice.\n */\nexport function hasPayload(value: unknown): boolean {\n return stringifyPayload(value) !== undefined\n}\n\n/**\n * Turns the answers of a form into the sentence the caller would have said.\n *\n * On a call the tool loop is over by the time the form is on screen, so the\n * answers go back to the agent as a user message (see `sendUserMessage` in\n * `useVoiceSession`). Each answer is paired with its question, because that is\n * how a person would say it and because the agent hears it with no widget\n * attached.\n */\nexport function formAnswerAsSpoken(\n part: unknown,\n answer: string | { answers: { id: string; value: unknown }[] },\n): string {\n const input = (\n part as {\n input?: {\n steps?: { id: string; question?: string }[]\n question?: string\n }\n }\n )?.input\n\n if (typeof answer === 'string') {\n const question = input?.question ?? input?.steps?.[0]?.question\n return question ? `${question} ${answer}` : answer\n }\n\n const questionById = new Map(\n (input?.steps ?? []).map((step) => [step.id, step.question]),\n )\n const lines = answer.answers\n .filter(\n ({ value }) =>\n value !== null &&\n value !== '' &&\n !(Array.isArray(value) && !value.length),\n )\n .map(({ id, value }) => {\n const said = Array.isArray(value) ? value.join(', ') : String(value)\n const question = questionById.get(id)\n return question ? `${question} ${said}` : said\n })\n\n return lines.join('. ')\n}\n\n/**\n * The choices of a form step, as the radio and checkbox editors take them.\n *\n * The `value` is the LABEL and not the position, because it is what travels\n * back to the model as the answer: it reads the words it wrote, not an index.\n * Nothing here caps the list, and nothing should: the number of options an\n * agent configures is advice to the model, so a step can legitimately carry\n * more (see `showForm.tool.ts`).\n */\nexport function formStepOptions(\n step: { options?: { label: string; description?: string }[] } | undefined,\n): { label: string; value: string; description?: string }[] {\n if (!step?.options) {\n return []\n }\n return step.options.map((option) => ({\n label: option.label,\n value: option.label,\n description: option.description,\n }))\n}\n\n/**\n * Spreads the answers a form comes back with onto one slot PER STEP.\n *\n * A form's answers travel paired with step ids, and the tool schema does not\n * enforce that those ids are unique: a `.refine()` there would refuse the whole\n * form over a duplicate, which is the failure the schema was just cured of (see\n * the gotchas entry \"A configurable cap does not belong in an inputSchema\").\n * So the duplicate has to be survivable here. Keyed by id, two steps sharing\n * one collapsed onto a single answer: the second question showed the first\n * one's reply, and submitting sent that reply twice. Keyed by position, each\n * step keeps its own.\n *\n * A duplicated id restores the same incoming value to every step claiming it,\n * which is as much as the payload allows: the ids are all it says.\n */\nexport function formAnswerSlots(\n steps: { id: string }[],\n output: unknown,\n): Record<number, unknown> {\n const slots: Record<number, unknown> = {}\n if (output === undefined || output === null) {\n return slots\n }\n // A legacy single-choice answer is the plain string, and it can only\n // belong to a single-step form.\n if (typeof output === 'string') {\n if (steps.length === 1) {\n slots[0] = output\n }\n return slots\n }\n const assign = (id: string, value: unknown) => {\n steps.forEach((step, index) => {\n if (step.id === id) {\n slots[index] = value\n }\n })\n }\n const list = (output as { answers?: unknown }).answers\n if (Array.isArray(list)) {\n for (const answer of list as { id?: unknown; value?: unknown }[]) {\n if (typeof answer?.id === 'string') {\n assign(answer.id, answer.value)\n }\n }\n return slots\n }\n // Forms answered on a platform channel (the Teams modal) come back as a\n // flat record keyed by step id.\n for (const [id, value] of Object.entries(\n output as Record<string, unknown>,\n )) {\n if (value !== undefined) {\n assign(id, value)\n }\n }\n return slots\n}\n\n// Web search tool part types, gateway and provider-native\nexport const WEB_SEARCH_TOOL_TYPES: string[] = WEB_SEARCH_TOOL_KEYS.map(\n (key) => `tool-${key}`,\n)\n\n// Tool part types with a dedicated rich rendering in PkChatbotStepToolDetail\nconst RICH_DETAIL_TOOL_TYPES = new Set([\n 'tool-searchInKnowledgeBase',\n 'tool-retrieveRevisedAnswers',\n 'tool-expandChunkContext',\n 'tool-readDocumentFile',\n 'tool-getWeather',\n 'tool-geocode',\n 'tool-recallUserMemory',\n 'tool-saveUserMemory',\n ...WEB_SEARCH_TOOL_TYPES,\n])\n\nexport function hasRichToolDetail(\n part?: UIMessage['parts'][number] | null,\n): boolean {\n return isToolPart(part) && RICH_DETAIL_TOOL_TYPES.has(part.type)\n}\n\nconst asRecord = (value: unknown): Record<string, unknown> | undefined =>\n value && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined\n\nconst pickString = (\n record: Record<string, unknown> | undefined,\n ...keys: string[]\n): string | undefined => {\n for (const key of keys) {\n const value = record?.[key]\n if (typeof value === 'string' && value.trim()) {\n return value\n }\n }\n return undefined\n}\n\n/**\n * Returns a short inline summary for a tool part (search queries, location,\n * document name, ...) to be shown next to the step label without expanding\n * the step body.\n */\nexport function getToolPartSummary(\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n if (!isToolPart(part)) {\n return undefined\n }\n const input = asRecord('input' in part ? part.input : undefined)\n const output = asRecord('output' in part ? part.output : undefined)\n if (\n part.type === 'tool-searchInKnowledgeBase' ||\n WEB_SEARCH_TOOL_TYPES.includes(part.type)\n ) {\n const queries = input?.queries\n if (Array.isArray(queries)) {\n const valid = queries.filter(\n (query): query is string =>\n typeof query === 'string' && Boolean(query.trim()),\n )\n return valid.length ? valid.join(' · ') : undefined\n }\n return pickString(input, 'query', 'objective')\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return pickString(input, 'query')\n }\n if (part.type === 'tool-getWeather') {\n return (\n pickString(output, 'location') ?? pickString(input, 'locationName')\n )\n }\n if (part.type === 'tool-geocode') {\n return pickString(input, 'locationName')\n }\n if (part.type === 'tool-expandChunkContext') {\n return pickString(output, 'documentName')\n }\n if (\n part.type === 'tool-readDocumentFile' ||\n part.type === 'tool-readChatAttachment' ||\n part.type === 'tool-sendChatFile' ||\n part.type === 'tool-shareDocument'\n ) {\n return pickString(output, 'name')\n }\n if (part.type === 'tool-readSpreadsheet') {\n const sheet = pickString(input, 'sheet')\n const range = pickString(input, 'range')\n return sheet && range ? `${sheet}!${range}` : sheet\n }\n if (part.type === 'tool-editSpreadsheet') {\n return pickString(output, 'filename')\n }\n if (part.type === 'tool-readWordDocument') {\n return pickString(input, 'search') ?? pickString(input, 'from')\n }\n if (part.type === 'tool-editWordDocument') {\n return pickString(output, 'filename')\n }\n if (\n part.type === 'tool-createSpreadsheet' ||\n part.type === 'tool-createWordDocument'\n ) {\n // The name the file got, or while the call runs the one asked for.\n return pickString(output, 'filename') ?? pickString(input, 'filename')\n }\n if (part.type === 'tool-querySpreadsheet') {\n // The file when the step asked for the schema; a query has no name.\n return pickString(output, 'file')\n }\n if (part.type === 'tool-recallUserMemory') {\n return pickString(input, 'query')\n }\n if (part.type === 'tool-saveUserMemory') {\n return pickString(input, 'content', 'query')\n }\n return undefined\n}\n\n// Get part icon\nexport function getPartIcon(\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n const host = getHostCallPart(part)\n if (host) {\n return pageToolStep(host)?.icon ?? 'ri:apps-line'\n }\n if (isToolPart(part)) {\n if (part.type.includes('tool-subagent')) {\n return 'ri:robot-2-line'\n }\n if (part.type === 'tool-runWorker') {\n return 'ri:flow-chart'\n }\n if (part.type === 'tool-scheduleWakeup') {\n return 'ri:alarm-line'\n }\n if (part.type === 'tool-fetchTeamsChannelHistory') {\n return 'ri:chat-history-line'\n }\n if (part.type === 'tool-readEarlierMessages') {\n return 'ri:history-line'\n }\n if (part.type === 'tool-readChatAttachment') {\n return 'ri:attachment-line'\n }\n if (part.type === 'tool-sendChatFile') {\n return 'ri:send-plane-line'\n }\n if (part.type === 'tool-enableTools') {\n return 'ri:toggle-line'\n }\n if (part.type.includes('tool-mcp')) {\n return 'mcp'\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return 'ri:file-edit-line'\n }\n if (part.type === 'tool-searchInKnowledgeBase') {\n return 'ri:search-line'\n }\n if (part.type === 'tool-expandChunkContext') {\n return 'ri:file-search-line'\n }\n if (part.type === 'tool-readDocumentFile') {\n return 'ri:file-text-line'\n }\n if (part.type === 'tool-readSpreadsheet') {\n return 'ri:table-line'\n }\n if (\n part.type === 'tool-editSpreadsheet' ||\n part.type === 'tool-createSpreadsheet'\n ) {\n return 'ri:file-excel-2-line'\n }\n if (part.type === 'tool-shareDocument') {\n return 'ri:file-download-line'\n }\n if (part.type === 'tool-readWordDocument') {\n return 'ri:file-text-line'\n }\n if (\n part.type === 'tool-editWordDocument' ||\n part.type === 'tool-createWordDocument'\n ) {\n return 'ri:file-word-2-line'\n }\n if (part.type === 'tool-querySpreadsheet') {\n return 'ri:database-2-line'\n }\n if (part.type === 'tool-geocode') {\n return 'ri:map-2-line'\n }\n if (part.type === 'tool-getWeather') {\n return 'ri:sun-cloudy-line'\n }\n if (part.type === 'tool-recallUserMemory') {\n return 'ri:brain-line'\n }\n if (part.type === 'tool-saveUserMemory') {\n return 'ri:save-3-line'\n }\n if (part.type === 'tool-showWeather') {\n return 'ri:sun-line'\n }\n if (part.type === 'tool-showDiagram') {\n return 'ri:flow-chart'\n }\n if (part.type === 'tool-showSources') {\n return 'ri:book-2-line'\n }\n if (part.type === 'tool-showForm') {\n return 'ri:survey-line'\n }\n if (part.type === 'tool-showMultipleChoice') {\n return 'ri:checkbox-multiple-line'\n }\n if (part.type === 'tool-showArtifact') {\n return 'ri:file-code-line'\n }\n if (part.type === 'tool-showEmail') {\n return 'ri:mail-line'\n }\n if (part.type === 'tool-showMessage') {\n return 'ri:chat-1-line'\n }\n if (part.type === 'tool-showWebPages') {\n return 'ri:pages-line'\n }\n if (part.type === 'tool-showProductList') {\n return 'ri:shopping-bag-line'\n }\n if (part.type === 'tool-showContactForm') {\n return 'ri:send-plane-2-line'\n }\n if (part.type === 'tool-showCalendarEvent') {\n return 'ri:calendar-event-line'\n }\n if (part.type === 'tool-showComparison') {\n return 'ri:scales-line'\n }\n if (part.type === 'tool-showLocation') {\n return 'ri:map-pin-line'\n }\n if (part.type === 'tool-showQrCode') {\n return 'ri:qr-code-line'\n }\n if (part.type === 'tool-showImageGallery') {\n return 'ri:image-line'\n }\n if (part.type === 'tool-showVideo') {\n return 'ri:film-line'\n }\n if (part.type === 'tool-showSuggestedReply') {\n return 'ri:corner-down-right-line'\n }\n if (part.type === 'tool-requestGeolocation') {\n return 'ri:map-pin-user-line'\n }\n if (part.type === 'tool-disconnectOAuthConnection') {\n return 'ri:link-unlink'\n }\n if (part.type === 'tool-requestAccountLink') {\n return 'ri:link'\n }\n if (part.type === 'tool-unlinkAccount') {\n return 'ri:link-unlink'\n }\n if (WEB_SEARCH_TOOL_TYPES.includes(part.type)) {\n return 'ri:global-line'\n }\n return 'ri:tools-line'\n }\n if (isReasoningPart(part)) {\n return 'ri:lightbulb-line'\n }\n if (isTextPart(part)) {\n return 'ri:double-quotes-r'\n }\n return undefined\n}\n\n/** What `toolLabel` and `getPartTypeLabel` need from vue-i18n. */\nexport interface LabelTranslator {\n t: (key: string) => string\n te: (key: string) => boolean\n}\n\nconst TOOL_KEY_PREFIXES = [\n API_TOOL_PREFIX,\n MCP_TOOL_PREFIX,\n SUBAGENT_TOOL_PREFIX,\n] as const\n\n/**\n * The name a person reads for a tool of the turn: the translated label of a\n * built-in tool, otherwise the name the agent configured, without its\n * tool-set prefix and in words (`api-festivita_nazionali` reads \"Festivita\n * nazionali\"). Never the raw key, and never an i18n key with no translation,\n * which vue-i18n would print as the key itself.\n */\nexport function toolLabel(name: string, { t, te }: LabelTranslator): string {\n if (te(`agent.tool.${name}`)) {\n return t(`agent.tool.${name}`)\n }\n const prefix = TOOL_KEY_PREFIXES.find((p) => name.startsWith(p))\n const bare = prefix ? name.slice(prefix.length) : name\n return capitalizeFirstLetter(fromAnyCase(bare).trim().toLowerCase())\n}\n\n/**\n * The kinds of message part a person can meet, each with its label. Written\n * as literal keys so the widget's library build, which keeps only the keys it\n * finds written out (apps/web-component/vite-plugins/chatLocales.ts), ships\n * them too.\n */\nconst PART_TYPE_LABELS: Record<string, (t: LabelTranslator['t']) => string> = {\n custom: (t) => t('messagePart.type.custom'),\n data: (t) => t('messagePart.type.data'),\n file: (t) => t('messagePart.type.file'),\n reasoning: (t) => t('messagePart.type.reasoning'),\n 'source-document': (t) => t('messagePart.type.sourceDocument'),\n 'source-url': (t) => t('messagePart.type.sourceUrl'),\n 'step-start': (t) => t('messagePart.type.stepStart'),\n text: (t) => t('messagePart.type.text'),\n}\n\n/**\n * The label of a message part in the message details: the tool for a tool\n * call, the translated kind otherwise (text, reasoning, provider data...),\n * and the kind in words for one the catalog does not know yet.\n */\nexport function getPartTypeLabel(\n part: UIMessage['parts'][number],\n translator: LabelTranslator,\n): string {\n if (isToolPart(part)) {\n return toolLabel(getToolPartName(part), translator)\n }\n if (part.type === 'dynamic-tool') {\n return toolLabel(part.toolName, translator)\n }\n const kind = part.type.startsWith('data-') ? 'data' : part.type\n const label = PART_TYPE_LABELS[kind]\n return label\n ? label(translator.t)\n : capitalizeFirstLetter(fromAnyCase(part.type))\n}\n\n/**\n * The commercial name of a provider the gateway routed a turn through, from\n * its slug (`anthropic`, `bedrock`): proper nouns, so no translation. A slug\n * not listed here shows with a capital, never as the bare id.\n */\nconst PROVIDER_NAMES: Record<string, string> = {\n alibaba: 'Alibaba Cloud',\n anthropic: 'Anthropic',\n azure: 'Microsoft Azure',\n baseten: 'Baseten',\n bedrock: 'Amazon Bedrock',\n cerebras: 'Cerebras',\n cohere: 'Cohere',\n deepinfra: 'DeepInfra',\n deepseek: 'DeepSeek',\n fireworks: 'Fireworks AI',\n google: 'Google',\n groq: 'Groq',\n mistral: 'Mistral AI',\n moonshotai: 'Moonshot AI',\n openai: 'OpenAI',\n perplexity: 'Perplexity',\n togetherai: 'Together AI',\n vertex: 'Google Vertex AI',\n xai: 'xAI',\n zai: 'Z.ai',\n}\n\n/** The name of a provider slug, see `PROVIDER_NAMES`. */\nexport function providerLabel(slug: string): string {\n return (\n PROVIDER_NAMES[slug.toLowerCase()] ??\n capitalizeFirstLetter(fromAnyCase(slug))\n )\n}\n\n/**\n * The conversation summary in the reader's language. The analysis asks the\n * model for four bold labels (`SUMMARY_FORMAT` in\n * apps/backend/src/prompts/analysis.prompt.ts) and the model copies them in\n * English whatever the conversation's language, so every stored summary\n * holds them: they are translated where a summary is read. An empty summary\n * comes back as it is, so a `??` fallback after it still works.\n */\nexport function localizeSummaryLabels<T extends string | null | undefined>(\n summary: T,\n t: (key: string) => string,\n): T {\n if (!summary) {\n return summary\n }\n const labels: Record<string, string> = {\n Intent: t('conversationSummary.intent'),\n 'Topics covered': t('conversationSummary.topicsCovered'),\n 'Key facts': t('conversationSummary.keyFacts'),\n 'Open questions': t('conversationSummary.openQuestions'),\n }\n return summary.replace(\n /\\*\\*(Intent|Topics covered|Key facts|Open questions)(:?)\\*\\*/g,\n (_, label: string, colon: string) => `**${labels[label]}${colon}**`,\n ) as T\n}\n\n// Get part label\nexport function getToolPartLabel(\n $t: (key: string) => string,\n part?: UIMessage['parts'][number] | null,\n /** The live titles of the page's steps, by call: they win when present. */\n hostStepTitles?: Record<string, string>,\n): string | undefined {\n const host = getHostCallPart(part)\n if (host) {\n const live = host.toolCallId\n ? hostStepTitles?.[host.toolCallId]\n : undefined\n if (live) {\n return live\n }\n const page = pageToolStep(host)\n return page ? $t(page.label) : host.title || host.toolName\n }\n if (isToolPart(part)) {\n if (part.type.includes('tool-subagent')) {\n return $t(`messagePart.runSubagent`)\n }\n if (part.type === 'tool-runWorker') {\n return $t(`messagePart.runWorker`)\n }\n if (part.type === 'tool-scheduleWakeup') {\n return $t(`messagePart.scheduleWakeup`)\n }\n if (part.type === 'tool-fetchTeamsChannelHistory') {\n return $t(`messagePart.fetchTeamsChannelHistory`)\n }\n if (part.type === 'tool-readEarlierMessages') {\n return $t(`messagePart.readEarlierMessages`)\n }\n if (part.type === 'tool-readChatAttachment') {\n return $t(`messagePart.readChatAttachment`)\n }\n if (part.type === 'tool-sendChatFile') {\n return $t(`messagePart.sendChatFile`)\n }\n if (part.type === 'tool-enableTools') {\n return $t(`messagePart.enableTools`)\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return $t(`messagePart.revisedAnswers`)\n }\n if (part.type === 'tool-searchInKnowledgeBase') {\n return $t(`messagePart.searchingDocuments`)\n }\n if (part.type === 'tool-expandChunkContext') {\n return $t(`messagePart.expandChunkContext`)\n }\n if (part.type === 'tool-readDocumentFile') {\n return $t(`messagePart.readDocumentFile`)\n }\n if (part.type === 'tool-readSpreadsheet') {\n return $t(`messagePart.readSpreadsheet`)\n }\n if (part.type === 'tool-editSpreadsheet') {\n return $t(`messagePart.editSpreadsheet`)\n }\n if (part.type === 'tool-shareDocument') {\n return $t(`messagePart.shareDocument`)\n }\n if (part.type === 'tool-readWordDocument') {\n return $t(`messagePart.readWordDocument`)\n }\n if (part.type === 'tool-editWordDocument') {\n return $t(`messagePart.editWordDocument`)\n }\n if (part.type === 'tool-createSpreadsheet') {\n return $t(`messagePart.createSpreadsheet`)\n }\n if (part.type === 'tool-createWordDocument') {\n return $t(`messagePart.createWordDocument`)\n }\n if (part.type === 'tool-querySpreadsheet') {\n return $t(`messagePart.querySpreadsheet`)\n }\n if (part.type === 'tool-geocode') {\n return $t(`messagePart.geocode`)\n }\n if (part.type === 'tool-getWeather') {\n return $t(`messagePart.getWeather`)\n }\n if (part.type === 'tool-recallUserMemory') {\n return $t(`messagePart.recallUserMemory`)\n }\n if (part.type === 'tool-saveUserMemory') {\n return $t(`messagePart.saveUserMemory`)\n }\n if (part.type === 'tool-showWeather') {\n return $t(`messagePart.showWeather`)\n }\n if (part.type === 'tool-showForm') {\n return $t(`messagePart.showForm`)\n }\n if (part.type === 'tool-showDiagram') {\n return $t(`messagePart.showDiagram`)\n }\n if (part.type === 'tool-showSources') {\n return $t(`messagePart.showSources`)\n }\n if (part.type === 'tool-showMultipleChoice') {\n return $t(`messagePart.showMultipleChoice`)\n }\n if (part.type === 'tool-showArtifact') {\n return $t(`messagePart.showArtifact`)\n }\n if (part.type === 'tool-showEmail') {\n return $t(`messagePart.showEmail`)\n }\n if (part.type === 'tool-showMessage') {\n return $t(`messagePart.showMessage`)\n }\n if (part.type === 'tool-showWebPages') {\n return $t(`messagePart.showWebPages`)\n }\n if (part.type === 'tool-showProducts') {\n return $t(`messagePart.showProducts`)\n }\n if (part.type === 'tool-showContactForm') {\n return $t(`messagePart.showContactForm`)\n }\n if (part.type === 'tool-showCalendarEvent') {\n return $t(`messagePart.showCalendarEvent`)\n }\n if (part.type === 'tool-showComparison') {\n return $t(`messagePart.showComparison`)\n }\n if (part.type === 'tool-showLocation') {\n return $t(`messagePart.showLocation`)\n }\n if (part.type === 'tool-showQrCode') {\n return $t(`messagePart.showQrCode`)\n }\n if (part.type === 'tool-showImageGallery') {\n return $t(`messagePart.showImageGallery`)\n }\n if (part.type === 'tool-showVideo') {\n return $t(`messagePart.showVideo`)\n }\n if (part.type === 'tool-showSuggestedReply') {\n return $t(`messagePart.showSuggestedReply`)\n }\n if (part.type === 'tool-requestGeolocation') {\n return $t(`messagePart.requestGeolocation`)\n }\n if (part.type === 'tool-disconnectOAuthConnection') {\n return $t(`messagePart.disconnectOAuthConnection`)\n }\n if (part.type === 'tool-requestAccountLink') {\n return $t(`messagePart.requestAccountLink`)\n }\n if (part.type === 'tool-unlinkAccount') {\n return $t(`messagePart.unlinkAccount`)\n }\n if (WEB_SEARCH_TOOL_TYPES.includes(part.type)) {\n return $t(`messagePart.webSearch`)\n }\n return $t(`messagePart.tool`)\n }\n if (isReasoningPart(part)) {\n return $t(`messagePart.reasoning`)\n }\n return $t(`messagePart.streaming`)\n}\n\n/** The version of a file stored in the chat that a preview opens. */\nexport type ChatFilePreviewTarget = {\n kind: 'word' | 'spreadsheet'\n storedFileName: string\n /** The name of the file, not of its version. */\n filename: string\n version?: number\n /** The file all its versions belong to, as the agent names it. */\n fileId?: string\n}\n\n/**\n * How the viewer draws a Word document's tracked changes: marked as Word\n * marks them, as if accepted, or as before them.\n */\nexport type WordPreviewMode = 'markup' | 'accepted' | 'original'\n\n/**\n * The fonts that stand in for Office's where the reader's system lacks them:\n * the metric-compatible ones of Linux and Chrome OS first, so the lines break\n * where Word breaks them, then the closest common ones.\n */\nconst WORD_FONT_STACKS: Record<string, string> = {\n calibri: 'Calibri, Carlito, \"Segoe UI\", Arial, sans-serif',\n 'calibri light':\n '\"Calibri Light\", Calibri, Carlito, \"Segoe UI\", sans-serif',\n aptos: 'Aptos, Calibri, Carlito, \"Segoe UI\", Arial, sans-serif',\n 'aptos display': '\"Aptos Display\", Aptos, Calibri, Carlito, sans-serif',\n cambria: 'Cambria, Caladea, Georgia, serif',\n 'times new roman':\n '\"Times New Roman\", Tinos, \"Liberation Serif\", Times, serif',\n arial: 'Arial, Arimo, \"Liberation Sans\", Helvetica, sans-serif',\n helvetica: 'Helvetica, Arial, Arimo, sans-serif',\n 'courier new': '\"Courier New\", Cousine, \"Liberation Mono\", monospace',\n garamond: 'Garamond, \"EB Garamond\", Georgia, serif',\n georgia: 'Georgia, serif',\n verdana: 'Verdana, \"DejaVu Sans\", sans-serif',\n tahoma: 'Tahoma, Verdana, sans-serif',\n}\n\n/**\n * Word's single line as a multiple of the font size, from the font's ascent,\n * descent and line gap: the lines keep the height of the document's font\n * where another font stands in for it.\n */\nconst WORD_LINE_FACTORS: Record<string, number> = {\n calibri: 1.22,\n 'calibri light': 1.22,\n cambria: 1.17,\n 'times new roman': 1.15,\n arial: 1.15,\n helvetica: 1.15,\n 'courier new': 1.13,\n georgia: 1.14,\n verdana: 1.22,\n tahoma: 1.21,\n}\n\n/** Word's single line for a font a Word document names. */\nexport const wordLineFactor = (font: string): number =>\n WORD_LINE_FACTORS[font.toLowerCase()] ?? 1.17\n\n/** The CSS font stack for a font a Word document names. */\nexport const wordFontStack = (font: string): string =>\n WORD_FONT_STACKS[font.toLowerCase()] ??\n `\"${font.replace(/\"/g, '')}\", ${\n /roman|garamond|cambria|georgia|serif|book|times/i.test(font)\n ? 'Georgia, serif'\n : 'Calibri, Carlito, \"Segoe UI\", Arial, sans-serif'\n }`\n\n/**\n * The images of the Word document in the viewer, by reference, which its\n * runs draw (`PkWordPreview` provides them).\n */\nexport const WORD_PREVIEW_IMAGES: InjectionKey<\n Ref<Record<string, string> | undefined>\n> = Symbol('wordPreviewImages')\n\n/**\n * The image a run draws, only a WebP the server wrote: anything else in the\n * map is not drawn.\n */\nexport const wordPictureSrc = (\n images: Record<string, string> | undefined,\n ref: string,\n): string | undefined => {\n const src = images?.[ref]\n return src?.startsWith('data:image/webp;base64,') ? src : undefined\n}\n\n/** The numbers the page number fields of a page show. */\nexport type WordPageNumbers = {\n page: number\n pages: number\n sectionPages: number\n}\n\n/**\n * Where an image Word positions on the page sits on it: from the page's top\n * left corner, in points, under the text or over it.\n */\nexport const wordPageAnchorCss = (\n picture: WordPreviewPicture,\n page: WordPreviewPage,\n): CSSProperties => {\n const anchor = picture.anchor!\n return {\n left: `${anchor.xFrom === 'page' ? anchor.x : page.margins.left + anchor.x}pt`,\n top: `${anchor.yFrom === 'page' ? anchor.y : page.margins.top + anchor.y}pt`,\n width: `${picture.width}pt`,\n height: `${picture.height}pt`,\n zIndex: anchor.wrap === 'behind' ? -1 : 1,\n }\n}\n\n/**\n * How an image of a run is placed: in the text, beside the text of its\n * paragraph, on a line of its own, from its paragraph, or on the page,\n * which the page draws.\n */\nexport const wordPicturePlacement = (\n picture: WordPreviewPicture,\n): 'inline' | 'around' | 'block' | 'paragraph' | 'page' => {\n const anchor = picture.anchor\n return !anchor\n ? 'inline'\n : anchor.wrap === 'around'\n ? 'around'\n : anchor.wrap === 'block'\n ? 'block'\n : anchor.yFrom === 'paragraph'\n ? 'paragraph'\n : 'page'\n}\n\n/** The runs a mode keeps: a deletion is gone once accepted. */\nexport const wordKeptRuns = (\n runs: WordPreviewRun[],\n mode: WordPreviewMode,\n): WordPreviewRun[] =>\n runs.filter((r) =>\n mode === 'accepted'\n ? r.change !== 'deleted'\n : mode === 'original'\n ? r.change !== 'inserted'\n : true,\n )\n\nconst hasWordText = (runs: WordPreviewRun[]) =>\n runs.some((r) => r.image || r.text.trim())\n\n/** A piece of a Word document's flow: a paragraph or a table row. */\nexport type WordFlowItem = {\n key: string\n block: number\n row?: number\n breakBefore: boolean\n /** The section it opens. */\n section?: number\n /** Stays on the page of the next piece (Word's \"Keep with next\"). */\n keepNext?: true\n}\n\n/**\n * The pieces of `blocks` in order, as the pages hold them. A paragraph or a\n * table row a mode empties is gone (a row inserted, as the original); one\n * empty in the document stays, a blank line as in Word. A section a gone\n * piece opened, with its page break, passes to the next one.\n */\nexport const wordFlowItems = (\n blocks: WordPreviewBlock[],\n mode: WordPreviewMode,\n): WordFlowItem[] => {\n const out: WordFlowItem[] = []\n let breakPending = false\n let sectionPending: number | undefined\n const push = (\n key: string,\n block: number,\n row: number | undefined,\n breakBefore: boolean,\n section: number | undefined,\n keepNext: boolean,\n ) => {\n const opens = section ?? sectionPending\n out.push({\n key,\n block,\n ...(row !== undefined ? { row } : {}),\n breakBefore: breakBefore || breakPending,\n ...(opens !== undefined ? { section: opens } : {}),\n ...(keepNext ? { keepNext: true as const } : {}),\n })\n breakPending = false\n sectionPending = undefined\n }\n // A gone piece's own page break goes with it; a section's start stays\n const skip = (breakBefore: boolean, section: number | undefined) => {\n breakPending ||= breakBefore && section !== undefined\n sectionPending = section ?? sectionPending\n }\n blocks.forEach((block, b) => {\n if (block.kind === 'table') {\n // The table's break and section go with its first row shown\n let breaks = !!block.pageBreakBefore\n let opens = block.section\n block.rows.forEach((cells, r) => {\n const filled = cells.some((cell) => cell.runs.length)\n if (\n filled &&\n !cells.some((cell) =>\n hasWordText(wordKeptRuns(cell.runs, mode)),\n )\n ) {\n return\n }\n push(\n `${b}:${r}`,\n b,\n r,\n breaks,\n opens,\n cells.some((cell) => cell.keepNext),\n )\n breaks = false\n opens = undefined\n })\n skip(breaks, opens)\n } else if (\n !block.runs.length ||\n hasWordText(wordKeptRuns(block.runs, mode))\n ) {\n push(\n `${b}`,\n b,\n undefined,\n !!block.style?.pageBreakBefore,\n block.section,\n !!block.style?.keepNext,\n )\n } else {\n skip(!!block.style?.pageBreakBefore, block.section)\n }\n })\n return out\n}\n\n/** The images Word positions on the page among the paragraphs of `blocks`. */\nexport const wordPageAnchors = (\n blocks: WordPreviewBlock[],\n mode: WordPreviewMode,\n): WordPreviewPicture[] =>\n blocks.flatMap((block) =>\n block.kind === 'table'\n ? []\n : wordKeptRuns(block.runs, mode).flatMap((run) =>\n run.picture && wordPicturePlacement(run.picture) === 'page'\n ? [run.picture]\n : [],\n ),\n )\n\n/** An earlier version of a file of the chat, for the agent to restore. */\nexport type ChatFileRestoreTarget = {\n /** The id the agent names the file with: the stored name of version 1. */\n fileId: string\n version: number\n filename: string\n}\n\n/**\n * The name of a file, not of its version: `listino (v2).xlsx` is version 2\n * of `listino.xlsx`.\n */\nexport const chatFileName = (filename: string, version?: number): string =>\n version\n ? filename.replace(new RegExp(` \\\\(v${version}\\\\)(\\\\.\\\\w+)$`), '$1')\n : filename\n\n/**\n * Whether a chat stands in front of the place of the bar that shows the\n * agent acting on the page (`PkPageControlBar`): the top centre of the\n * window, from the bar's `top` of 48px to about its 44px of height below.\n * There the bar would only cover the chat's header, and the chat shows the\n * steps and their stop itself.\n */\nexport function chatCoversPageControlBar(\n chat: Pick<DOMRect, 'left' | 'right' | 'top' | 'bottom'>,\n windowWidth: number,\n): boolean {\n const center = windowWidth / 2\n return (\n chat.left <= center &&\n chat.right >= center &&\n chat.top <= 92 &&\n chat.bottom >= 48\n )\n}\n"],"mappings":";;;;;AAKA,SAAgBQ,EACZ,GAC8C;CAI9C,OAHKC,IAGEA,EAAK,SAAS,SAFV;AAGf;AAEA,SAAgBC,EACZ,GACwD;CAIxD,OAHKD,IAGEA,EAAK,KAAK,WAAW,OAAO,IAFxB;AAGf;AAEA,SAAgBE,EAAgB,GAA4B;CAIxD,OAHKD,EAAWD,CAAI,IAGbA,EAAK,KAAK,MAAM,CAAc,IAF1B;AAGf;AAEA,SAAgBG,EACZ,GAC8C;CAI9C,OAHKH,IAGEA,EAAK,SAAS,SAFV;AAGf;AASA,SAAgBI,EACZ,GACuB;CACvB,IAAI,CAACD,EAAWH,CAAI,GAChB;CAIJ,IAAMK,IAFYL,EAAK,mBAAmB,OAAA,EAEjB;CACzB,OAAOK,KAAS,OAAOA,KAAU,YAAY,CAAC,MAAM,QAAQA,CAAK,IAC1DA,IACD,KAAA;AACV;AAOA,SAAgBC,EACZ,GAC+B;CAC/B,IAAI,CAACH,EAAWH,CAAI,GAChB;CAIJ,IAAMO,IAFYP,EAAK,mBAAmB,OAAA,EAEZ;CAC9B,OAAOO,KACH,OAAOA,KAAe,YACtB,CAAC,MAAM,QAAQA,CAAU,IACtBA,IACD,KAAA;AACV;AAeA,SAAgBC,EACZ,GACA,GACG;CACH,OAAOC,EAAS,KAAK,MAAY;EAC7B,IAAMC,IAAMC,EAAQ,QAAQ,MAAWC,EAAO,cAAcC,EAAQ,EAAE;EAItE,OAHIH,EAAI,WAAW,IACRG,IAEJ;GACH,GAAGA;GACH,OAAOA,EAAQ,MAAM,KAAK,MAAS;IAC/B,IAAMD,IAASF,EAAI,MACd,EAAE,w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