@8wave/ai-elements 0.126.0-beta.32 → 0.126.0-beta.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{Agent-COa7L9GK.js → Agent-DZEyfr8D.js} +2 -1
- package/dist/_chunks/Agent-DZEyfr8D.js.map +1 -0
- package/dist/_chunks/{PkFilePreview-SBGa95Ca.js → PkFilePreview-C6ZZablL.js} +3 -3
- package/dist/_chunks/{PkFilePreview-SBGa95Ca.js.map → PkFilePreview-C6ZZablL.js.map} +1 -1
- package/dist/_chunks/{PkFilePreviewDialog-Cc7iZWCl.js → PkFilePreviewDialog-BzBHAt8l.js} +2 -2
- package/dist/_chunks/{PkFilePreviewDialog-Cc7iZWCl.js.map → PkFilePreviewDialog-BzBHAt8l.js.map} +1 -1
- package/dist/_chunks/{PkImageEditorDialog-D13bWv-N.js → PkImageEditorDialog-Dm34WFmS.js} +2 -2
- package/dist/_chunks/{PkImageEditorDialog-D13bWv-N.js.map → PkImageEditorDialog-Dm34WFmS.js.map} +1 -1
- package/dist/_chunks/{PkSelectionActions-BaX_rsCt.js → PkSelectionActions-CYqbMEjg.js} +2 -2
- package/dist/_chunks/{PkSelectionActions-BaX_rsCt.js.map → PkSelectionActions-CYqbMEjg.js.map} +1 -1
- package/dist/_chunks/{PkStreamingMarkdown-GRB3Gg_x.js → PkStreamingMarkdown-B8rZbprU.js} +3 -3
- package/dist/_chunks/{PkStreamingMarkdown-GRB3Gg_x.js.map → PkStreamingMarkdown-B8rZbprU.js.map} +1 -1
- package/dist/_chunks/{PkToolChatFile-DTm5-CE4.js → PkToolChatFile-C0emIVfS.js} +3 -3
- package/dist/_chunks/{PkToolChatFile-DTm5-CE4.js.map → PkToolChatFile-C0emIVfS.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestGeolocation-DZenn1az.js → PkToolRequestGeolocation-DNzNRszE.js} +2 -2
- package/dist/_chunks/{PkToolRequestGeolocation-DZenn1az.js.map → PkToolRequestGeolocation-DNzNRszE.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestOAuthConnection-Dz0qfYu5.js → PkToolRequestOAuthConnection-BDxYXz4s.js} +2 -2
- package/dist/_chunks/{PkToolRequestOAuthConnection-Dz0qfYu5.js.map → PkToolRequestOAuthConnection-BDxYXz4s.js.map} +1 -1
- package/dist/_chunks/{PkToolShowArtifact-C9_DHr5Y.js → PkToolShowArtifact-B_KIIjEn.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-C9_DHr5Y.js.map → PkToolShowArtifact-B_KIIjEn.js.map} +1 -1
- package/dist/_chunks/{PkToolShowContactForm-DhyelktO.js → PkToolShowContactForm-DiHb3fRQ.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-DhyelktO.js.map → PkToolShowContactForm-DiHb3fRQ.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-Dz2Hnzts.js → PkToolShowForm-BmUAhIQy.js} +4 -4
- package/dist/_chunks/{PkToolShowForm-Dz2Hnzts.js.map → PkToolShowForm-BmUAhIQy.js.map} +1 -1
- package/dist/_chunks/{PkToolShowImageGallery-CiDfIboY.js → PkToolShowImageGallery-CZ394fdT.js} +2 -2
- package/dist/_chunks/{PkToolShowImageGallery-CiDfIboY.js.map → PkToolShowImageGallery-CZ394fdT.js.map} +1 -1
- package/dist/_chunks/{PkToolShowProductList-CY96IGWn.js → PkToolShowProductList-uNvUr2s9.js} +2 -2
- package/dist/_chunks/{PkToolShowProductList-CY96IGWn.js.map → PkToolShowProductList-uNvUr2s9.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-CRk-MOoE.js → PkToolShowSources-Dm0L4prK.js} +3 -3
- package/dist/_chunks/{PkToolShowSources-CRk-MOoE.js.map → PkToolShowSources-Dm0L4prK.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSuggestedReply-DKuV4mmV.js → PkToolShowSuggestedReply-B_dRrZfj.js} +2 -2
- package/dist/_chunks/{PkToolShowSuggestedReply-DKuV4mmV.js.map → PkToolShowSuggestedReply-B_dRrZfj.js.map} +1 -1
- package/dist/_chunks/{PkToolShowVideo-DI6ohcVU.js → PkToolShowVideo-DLgQjTq_.js} +2 -2
- package/dist/_chunks/{PkToolShowVideo-DI6ohcVU.js.map → PkToolShowVideo-DLgQjTq_.js.map} +1 -1
- package/dist/_chunks/{PkToolShowWebPages-Dh6L_n9T.js → PkToolShowWebPages-Cj2mJrs5.js} +2 -2
- package/dist/_chunks/{PkToolShowWebPages-Dh6L_n9T.js.map → PkToolShowWebPages-Cj2mJrs5.js.map} +1 -1
- package/dist/_chunks/{chatImagePolicy-Ckz-KAHA.js → chatImagePolicy-DMt6O5iK.js} +2 -2
- package/dist/_chunks/{chatImagePolicy-Ckz-KAHA.js.map → chatImagePolicy-DMt6O5iK.js.map} +1 -1
- package/dist/_chunks/{markdown-DHayRAiy.js → markdown-nw5sXwU0.js} +2 -2
- package/dist/_chunks/{markdown-DHayRAiy.js.map → markdown-nw5sXwU0.js.map} +1 -1
- package/dist/_chunks/{utils-3jpXeGGy.js → utils-DPGBO-HU.js} +2 -2
- package/dist/_chunks/{utils-3jpXeGGy.js.map → utils-DPGBO-HU.js.map} +1 -1
- package/dist/ai-elements.es.js +3927 -3858
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotEmptyState.js +1 -1
- package/dist-vue/PkChatbotInput.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotStepPayload.js +1 -1
- package/dist-vue/PkChatbotStepToolDetail.js +1 -1
- package/dist-vue/PkChatbotSteps.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/PkChatbotViewConversations.js +1 -1
- package/dist-vue/PkChatbotViewFiles.js +1 -1
- package/dist-vue/PkChatbotViewProfile.js +1 -1
- package/dist-vue/_chunks/{Agent-CRwhrv5Z.js → Agent-CBAd3F7k.js} +2 -1
- package/dist-vue/_chunks/Agent-CBAd3F7k.js.map +1 -0
- package/dist-vue/_chunks/{Document-Bp-qpa8v.js → Document-B3w5H0R0.js} +2 -2
- package/dist-vue/_chunks/{Document-Bp-qpa8v.js.map → Document-B3w5H0R0.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbot-CtrcDgBe.js → PkChatbot-CXpftmWm.js} +8 -8
- package/dist-vue/_chunks/{PkChatbot-CtrcDgBe.js.map → PkChatbot-CXpftmWm.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotEmptyState-BF3Odn3v.js → PkChatbotEmptyState-vA2v4FES.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-BF3Odn3v.js.map → PkChatbotEmptyState-vA2v4FES.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotInput-CIIJ1bpF.js +584 -0
- package/dist-vue/_chunks/PkChatbotInput-CIIJ1bpF.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotMessages-10eBKpC5.js → PkChatbotMessages-15R8RxAq.js} +18 -18
- package/dist-vue/_chunks/{PkChatbotMessages-10eBKpC5.js.map → PkChatbotMessages-15R8RxAq.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepPayload-C4ahOq6Z.js → PkChatbotStepPayload-BbNSav-U.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-C4ahOq6Z.js.map → PkChatbotStepPayload-BbNSav-U.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-CkIX0aKu.js → PkChatbotStepToolDetail-B_4pmbLe.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-CkIX0aKu.js.map → PkChatbotStepToolDetail-B_4pmbLe.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotSteps-BalLo6DZ.js → PkChatbotSteps-h4E6DH_g.js} +5 -5
- package/dist-vue/_chunks/{PkChatbotSteps-BalLo6DZ.js.map → PkChatbotSteps-h4E6DH_g.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotViewChat-CLQ0J9_f.js +1382 -0
- package/dist-vue/_chunks/PkChatbotViewChat-CLQ0J9_f.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotViewConversations-D0vDYTyo.js → PkChatbotViewConversations-DFBbypGg.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewConversations-D0vDYTyo.js.map → PkChatbotViewConversations-DFBbypGg.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewFiles-BwfAnywk.js → PkChatbotViewFiles-PHdrHZOf.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewFiles-BwfAnywk.js.map → PkChatbotViewFiles-PHdrHZOf.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewProfile-GW0WuMOy.js → PkChatbotViewProfile-B0AZvHTr.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewProfile-GW0WuMOy.js.map → PkChatbotViewProfile-B0AZvHTr.js.map} +1 -1
- package/dist-vue/_chunks/{PkFilePreview-qizsvSVW.js → PkFilePreview-Cb-1YRPN.js} +616 -666
- package/dist-vue/_chunks/PkFilePreview-Cb-1YRPN.js.map +1 -0
- package/dist-vue/_chunks/{PkFilePreviewDialog-WsVzH9hg.js → PkFilePreviewDialog-Bd7kEoCB.js} +2 -2
- package/dist-vue/_chunks/{PkFilePreviewDialog-WsVzH9hg.js.map → PkFilePreviewDialog-Bd7kEoCB.js.map} +1 -1
- package/dist-vue/_chunks/{PkImageEditorDialog-NQFpdqCU.js → PkImageEditorDialog-Bj4sUHXM.js} +2 -2
- package/dist-vue/_chunks/{PkImageEditorDialog-NQFpdqCU.js.map → PkImageEditorDialog-Bj4sUHXM.js.map} +1 -1
- package/dist-vue/_chunks/{PkStreamingMarkdown-CMxiJTMR.js → PkStreamingMarkdown-BcUq4ThC.js} +3 -3
- package/dist-vue/_chunks/{PkStreamingMarkdown-CMxiJTMR.js.map → PkStreamingMarkdown-BcUq4ThC.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolChatFile-Bd6Ci7i1.js → PkToolChatFile-BOexrlLt.js} +3 -3
- package/dist-vue/_chunks/{PkToolChatFile-Bd6Ci7i1.js.map → PkToolChatFile-BOexrlLt.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestGeolocation-C2OmF31d.js → PkToolRequestGeolocation-CyL_M1Rm.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestGeolocation-C2OmF31d.js.map → PkToolRequestGeolocation-CyL_M1Rm.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-CgD-o99C.js → PkToolRequestOAuthConnection-DWkeVLpx.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-CgD-o99C.js.map → PkToolRequestOAuthConnection-DWkeVLpx.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowArtifact-rlZ-AGWh.js → PkToolShowArtifact-C4gHB6lH.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-rlZ-AGWh.js.map → PkToolShowArtifact-C4gHB6lH.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowChart-B8xJi1yY.js → PkToolShowChart-CsPXNAb9.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowChart-B8xJi1yY.js.map → PkToolShowChart-CsPXNAb9.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowContactForm-BVBL7Unx.js → PkToolShowContactForm-2_HBPZaa.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-BVBL7Unx.js.map → PkToolShowContactForm-2_HBPZaa.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-Bs39QQZ3.js → PkToolShowDiagram-cCbeL6MK.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-Bs39QQZ3.js.map → PkToolShowDiagram-cCbeL6MK.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-D-RJeA2F.js → PkToolShowForm-DjB3fji5.js} +4 -4
- package/dist-vue/_chunks/{PkToolShowForm-D-RJeA2F.js.map → PkToolShowForm-DjB3fji5.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowImageGallery-CrkkKCVI.js → PkToolShowImageGallery-C22TCUKW.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowImageGallery-CrkkKCVI.js.map → PkToolShowImageGallery-C22TCUKW.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-BwfUG41_.js → PkToolShowProductList-BvtmiHBf.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-BwfUG41_.js.map → PkToolShowProductList-BvtmiHBf.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-q9gQIuam.js → PkToolShowSources-uKO4MQgd.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowSources-q9gQIuam.js.map → PkToolShowSources-uKO4MQgd.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-75Kc8-OQ.js → PkToolShowSuggestedReply-wKgwHTRO.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-75Kc8-OQ.js.map → PkToolShowSuggestedReply-wKgwHTRO.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowVideo-BK-jDVJd.js → PkToolShowVideo-DKj5N1vo.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowVideo-BK-jDVJd.js.map → PkToolShowVideo-DKj5N1vo.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-K3Jml1f7.js → PkToolShowWebPages-BNZmbCSf.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-K3Jml1f7.js.map → PkToolShowWebPages-BNZmbCSf.js.map} +1 -1
- package/dist-vue/_chunks/{createChatbotApiClient-Pb7_cU2s.js → createChatbotApiClient-DBKfGL6y.js} +5 -2
- package/dist-vue/_chunks/{createChatbotApiClient-Pb7_cU2s.js.map → createChatbotApiClient-DBKfGL6y.js.map} +1 -1
- package/dist-vue/_chunks/{useChatbotStore-ChrZVIDt.js → useChatbotStore-Hb5EjISl.js} +94 -85
- package/dist-vue/_chunks/useChatbotStore-Hb5EjISl.js.map +1 -0
- package/dist-vue/_chunks/{utils-Bdk5kFfi.js → utils-waie4Gfn.js} +2 -2
- package/dist-vue/_chunks/{utils-Bdk5kFfi.js.map → utils-waie4Gfn.js.map} +1 -1
- package/dist-vue/api.js +1 -1
- package/dist-vue/apps/web-component/src/composables/useChatbotAgent.d.ts +2 -0
- package/dist-vue/composables.js +8 -8
- package/dist-vue/index.js +408 -389
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +6 -0
- package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +9 -2
- package/dist-vue/packages/components/src/chat/PkChatbotInput.d.ts +6 -0
- package/dist-vue/packages/composable/src/chatbot/api/createChatbotApiClient.d.ts +5 -0
- package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +10 -1
- package/dist-vue/packages/models/src/schema/Agent.d.ts +8 -0
- package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +2 -0
- package/dist-vue/packages/models/src/schema/SubAgent.d.ts +2 -0
- package/dist-vue/packages/models/src/schema/constants.d.ts +11 -2
- package/dist-vue/style.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/Agent-COa7L9GK.js.map +0 -1
- package/dist-vue/_chunks/Agent-CRwhrv5Z.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotInput-DNXvFvyG.js +0 -520
- package/dist-vue/_chunks/PkChatbotInput-DNXvFvyG.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotViewChat-U6T-gG-c.js +0 -1336
- package/dist-vue/_chunks/PkChatbotViewChat-U6T-gG-c.js.map +0 -1
- package/dist-vue/_chunks/PkFilePreview-qizsvSVW.js.map +0 -1
- package/dist-vue/_chunks/useChatbotStore-ChrZVIDt.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-CGnMp29N.js";
|
|
2
2
|
import { i as t, r as n, t as r } from "./excelNumberFormat-CJwdxpPX.js";
|
|
3
|
-
import { D as i, N as a } from "./Agent-
|
|
3
|
+
import { D as i, N as a } from "./Agent-CBAd3F7k.js";
|
|
4
4
|
import { t as o } from "./PkChatbotFilePreview-aKJBtw04.js";
|
|
5
|
-
import { u as s } from "./utils-
|
|
5
|
+
import { u as s } from "./utils-waie4Gfn.js";
|
|
6
6
|
import { VvIcon as c } from "@volverjs/ui-vue/components";
|
|
7
7
|
import { Fragment as l, computed as u, createCommentVNode as d, createElementBlock as f, createElementVNode as p, createTextVNode as m, createVNode as h, defineComponent as g, openBlock as _, ref as v, renderList as y, toDisplayString as b, unref as x } from "vue";
|
|
8
8
|
import { useI18n as S } from "vue-i18n";
|
|
@@ -224,4 +224,4 @@ var C = {
|
|
|
224
224
|
}), V = /* @__PURE__ */ e({ default: () => H }), H = B;
|
|
225
225
|
export { V as n, H as t };
|
|
226
226
|
|
|
227
|
-
//# sourceMappingURL=PkToolChatFile-
|
|
227
|
+
//# sourceMappingURL=PkToolChatFile-BOexrlLt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolChatFile-Bd6Ci7i1.js","names":["_openBlock","_createElementBlock","_createVNode","PkChatbotFilePreview","_createElementVNode","_toDisplayString","_unref","_Fragment","_renderList","_createTextVNode","__exportAll","isSpreadsheetDateFormat","formatExcelNumber","excelDateText","SPREADSHEET_MIME_TYPE","WORD_MIME_TYPE","PkChatbotFilePreview_default","chatFileName","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","_hoisted_20","_hoisted_21","_hoisted_22","SHOWN_CHANGES","PkToolChatFile_vue_vue_type_script_setup_true_lang_default","WORD_TOOL_PARTS","props","__props","$t","useI18n","showAll","ref","withoutLength","text","contextOf","runs","before","after","excerptOf","a","b","common","i","j","push","last","kind","run","k","wordChangeLabel","op","paragraphRow","change","cellRow","legacy","rows","bang","cell","appended","shownAs","raw","format","locale","file","computed","part","output","word","changed","changes","reminders","summary","shown","shownParagraphs","shownSheets","groups","row","group","hiddenRows","olderVersion","latest","restoreThis","openPreview","_component_VvIcon","VvIcon","openBlock","createElementBlock","createVNode","createElementVNode","toDisplayString","unref","Fragment","renderList","g","index","s","segment","createCommentVNode","_cache","createTextVNode","reminder","PkToolChatFile_exports","PkToolChatFile_default"],"sources":["../../../../packages/components/src/chat/PkToolChatFile.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import {\n isSpreadsheetDateFormat,\n SPREADSHEET_MIME_TYPE,\n WORD_MIME_TYPE,\n } from 'models'\n import PkChatbotFilePreview from './PkChatbotFilePreview.vue'\n import { excelDateText, formatExcelNumber } from './excelNumberFormat'\n import {\n chatFileName,\n type ChatFilePreviewTarget,\n type ChatFileRestoreTarget,\n } from './utils'\n\n /**\n * One entry of `changes`: a cell (or an appended row, or a new sheet) of\n * `editSpreadsheet`, a paragraph or a table row of `editWordDocument`.\n */\n type ChatFileChange = {\n cell?: string\n op?: string\n before?: string\n after?: string\n newSheetRows?: number\n /**\n * The number format code of a side that is a number in the file,\n * from edits made since it was added.\n */\n beforeFormat?: string\n afterFormat?: string\n }\n\n /** What the four file tools return that the card shows. */\n type ChatFileOutput = {\n /** The file every version of it answers to. */\n fileId?: string\n storedFileName: string\n filename?: string\n sizeBytes?: number\n version?: number\n changedCells?: number\n changedParagraphs?: number\n changes?: ChatFileChange[]\n moreChanges?: number\n /** Of a Word edit: the changes are revisions. */\n tracked?: boolean\n stalePivots?: true\n staleTableOfContents?: true\n /** Of a restore: the version this one writes again. */\n restoredFrom?: number\n }\n\n /** A run of an excerpt: text kept, taken away or put in. */\n type Segment = { text: string; kind: 'same' | 'removed' | 'added' }\n\n /**\n * A changed cell as a row of the table: its value before and after, or\n * the line that stands for a new sheet.\n */\n type CellRow = {\n sheet: string\n cell?: string\n before?: string\n after?: string\n newSheet?: string\n }\n\n /** The rows of one sheet, under its name. */\n type SheetGroup = { sheet: string; rows: CellRow[] }\n\n /** A changed paragraph or table row: what happened, and its words. */\n type ParagraphRow = { what: string; segments: Segment[] }\n\n /** The tools whose output is a Word document; the others write a spreadsheet. */\n const WORD_TOOL_PARTS = new Set([\n 'tool-editWordDocument',\n 'tool-createWordDocument',\n ])\n\n /** Rows shown before \"View more\": most edits are one to three changes. */\n const SHOWN_CHANGES = 3\n /** Words of context kept on each side of a change in a paragraph. */\n const CONTEXT_WORDS = 6\n\n /**\n * The file a call of `editSpreadsheet`, `editWordDocument`,\n * `createSpreadsheet` or `createWordDocument` wrote, a new version or a\n * new file, to download. Drawn once the call has an output: while it runs,\n * the feed's activity indicator names it, and a refused call is explained\n * by the answer. Under an edit, a frame says what changed, its first\n * rows shown: a table of cells for a spreadsheet, the changed words of\n * each paragraph for a Word document, and what is left to do in Office.\n */\n const props = defineProps<{\n part: unknown\n /** The authenticated download URL of a file stored in this chat. */\n fileUrl: (storedFileName: string) => string\n /** Opens the preview of the file, where the chat has one. */\n preview?: (file: ChatFilePreviewTarget) => void\n /** The latest version of each file the conversation shows, by fileId. */\n latestVersions?: ReadonlyMap<string, number>\n /**\n * Asks the agent to write an earlier version again as the newest one,\n * where the chat can send a message.\n */\n restore?: (file: ChatFileRestoreTarget) => void\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n\n const showAll = ref(false)\n\n /**\n * The services cut a long text for the model and give its length\n * (`… (523 characters)`, the marker of every tool result, written by\n * `wordDocument.service.ts` and `spreadsheet.service.ts`): the card keeps\n * the ellipsis only.\n */\n const withoutLength = (text: string | undefined) =>\n text?.replace(/… \\(\\d+ characters\\)$/, '…')\n\n /**\n * A run of unchanged words cut to a few words on the side of each change\n * it touches: the head of the text keeps its end, the tail its start, a\n * run between two changes both, with an ellipsis where words went.\n */\n const contextOf = (text: string, before: boolean, after: boolean) => {\n const runs = text.split(/(\\s+)/).filter(Boolean)\n // Every word is followed by its space: twice as many runs.\n const keep = CONTEXT_WORDS * 2\n if (runs.length <= (before && after ? keep * 2 : keep)) {\n return text\n }\n if (before && after) {\n return `${runs.slice(0, keep).join('')}… ${runs.slice(-keep).join('')}`\n }\n return after\n ? `…${runs.slice(-keep).join('')}`\n : `${runs.slice(0, keep).join('')}…`\n }\n\n /**\n * The words of `before` and `after` that differ, word by word, so the\n * words two changes share between them stay plain. An echoed paragraph\n * is at most a few hundred characters, a few dozen words for the table.\n */\n const excerptOf = (before: string, after: string): Segment[] => {\n const a = before.split(/(\\s+)/).filter(Boolean)\n const b = after.split(/(\\s+)/).filter(Boolean)\n // Longest common subsequence, from the end\n const common = Array.from({ length: a.length + 1 }, () =>\n new Array<number>(b.length + 1).fill(0),\n )\n for (let i = a.length - 1; i >= 0; i--) {\n for (let j = b.length - 1; j >= 0; j--) {\n common[i][j] =\n a[i] === b[j]\n ? common[i + 1][j + 1] + 1\n : Math.max(common[i + 1][j], common[i][j + 1])\n }\n }\n const runs: Segment[] = []\n const push = (text: string, kind: Segment['kind']) => {\n const last = runs[runs.length - 1]\n if (last?.kind === kind) {\n last.text += text\n } else {\n runs.push({ text, kind })\n }\n }\n let i = 0\n let j = 0\n while (i < a.length || j < b.length) {\n if (i < a.length && j < b.length && a[i] === b[j]) {\n push(a[i++], 'same')\n j++\n } else if (\n j >= b.length ||\n (i < a.length && common[i + 1][j] >= common[i][j + 1])\n ) {\n push(a[i++], 'removed')\n } else {\n push(b[j++], 'added')\n }\n }\n return runs.map((run, k) =>\n run.kind === 'same'\n ? {\n ...run,\n text: contextOf(run.text, k > 0, k < runs.length - 1),\n }\n : run,\n )\n }\n\n /** What a Word operation did, as the row says it. */\n const wordChangeLabel = (op: string | undefined) => {\n switch (op) {\n case 'insertParagraphs':\n return $t('messagePart.chatFileParagraphAdded')\n case 'deleteParagraphs':\n return $t('messagePart.chatFileParagraphDeleted')\n case 'insertTableRow':\n return $t('messagePart.chatFileTableRowAdded')\n case 'deleteTableRow':\n return $t('messagePart.chatFileTableRowDeleted')\n case 'acceptRevisions':\n return $t('messagePart.chatFileRevisionAccepted')\n case 'rejectRevisions':\n return $t('messagePart.chatFileRevisionRejected')\n default:\n return $t('messagePart.chatFileParagraphChanged')\n }\n }\n\n /**\n * A paragraph marked as Word marks a revision, struck where words went\n * and underlined where they came. A paragraph only added or only removed\n * is said by its label: the text added stays plain, the text removed\n * stays struck.\n */\n const paragraphRow = (change: ChatFileChange): ParagraphRow => {\n const before = withoutLength(change.before)\n const after = withoutLength(change.after)\n return {\n what: wordChangeLabel(change.op),\n segments:\n before && after\n ? excerptOf(before, after)\n : [\n before\n ? { text: before, kind: 'removed' }\n : { text: after ?? '', kind: 'same' },\n ],\n }\n }\n\n /**\n * A cell as a person reads it: its sheet heads the group of its rows, so\n * the row says `C5` and not Excel's `Listino!C5`, and a row the edit\n * appended says \"Row 10\" and not `A10:F10`.\n */\n const cellRow = (change: ChatFileChange): CellRow => {\n const ref = change.cell ?? ''\n // A new sheet is named alone, with no cell. An edit made before the\n // card read `newSheetRows` said it only in the model's words.\n const legacy = change.before\n ? undefined\n : /^new sheet, (\\d+) row\\(s\\)$/.exec(change.after ?? '')?.[1]\n const rows =\n change.newSheetRows ?? (legacy ? Number(legacy) : undefined)\n if (rows !== undefined) {\n return {\n sheet: ref,\n newSheet: $t('messagePart.chatFileNewSheet', rows),\n }\n }\n\n const bang = ref.lastIndexOf('!')\n const cell = ref.slice(bang + 1)\n const appended = /^A(\\d+):[A-Z]+(\\d+)$/.exec(cell)\n return {\n sheet: ref.slice(0, Math.max(bang, 0)),\n cell:\n appended && appended[1] === appended[2]\n ? $t('messagePart.chatFileRow', { row: appended[1] })\n : cell,\n before: shownAs(withoutLength(change.before), change.beforeFormat),\n after: shownAs(withoutLength(change.after), change.afterFormat),\n }\n }\n\n /**\n * A value as its cell shows it, `0.05` as `5%` and a date serial as the\n * date; a formula, a text and a cell with no format stay as written.\n */\n const shownAs = (\n raw: string | undefined,\n format: string | undefined,\n ): string | undefined => {\n if (!raw || !format || raw.startsWith('=')) {\n return raw || undefined\n }\n try {\n if (isSpreadsheetDateFormat(format)) {\n return excelDateText(raw, format, locale.value) ?? raw\n }\n return /^-?\\d+(\\.\\d+)?(e[+-]?\\d+)?$/i.test(raw)\n ? formatExcelNumber(format, Number(raw), locale.value).text\n : raw\n } catch {\n // A code the interpreter cannot read: the value as written\n return raw\n }\n }\n\n const file = computed(() => {\n const part = props.part as {\n type?: string\n state?: string\n output?: Partial<ChatFileOutput>\n }\n if (part.state !== 'output-available' || !part.output?.storedFileName) {\n return undefined\n }\n const output = part.output as ChatFileOutput\n const word = WORD_TOOL_PARTS.has(part.type ?? '')\n // A new file has no count of changes. Each key is written out in its\n // own call: the widget ships only the keys it finds that way.\n let changed: string | undefined\n if (word && output.changedParagraphs !== undefined) {\n changed = output.tracked\n ? $t(\n 'messagePart.editWordDocumentRevisions',\n output.changedParagraphs,\n )\n : $t(\n 'messagePart.editWordDocumentParagraphs',\n output.changedParagraphs,\n )\n } else if (!word && output.changedCells !== undefined) {\n changed = $t(\n 'messagePart.editSpreadsheetCells',\n output.changedCells,\n )\n }\n const changes = changed ? (output.changes ?? []) : []\n const reminders: string[] = []\n if (output.stalePivots) {\n reminders.push($t('messagePart.chatFileRefreshPivots'))\n }\n if (output.staleTableOfContents) {\n reminders.push($t('messagePart.chatFileUpdateTableOfContents'))\n }\n let summary =\n changed && output.version\n ? $t('messagePart.chatFileVersionSummary', {\n version: output.version,\n changed,\n })\n : changed\n if (output.restoredFrom) {\n summary = $t('messagePart.chatFileRestored', {\n version: output.version,\n restored: output.restoredFrom,\n })\n }\n return {\n output,\n mediaType: word ? WORD_MIME_TYPE : SPREADSHEET_MIME_TYPE,\n summary,\n cells: word ? [] : changes.map(cellRow),\n paragraphs: word ? changes.map(paragraphRow) : [],\n count: changes.length,\n more: output.moreChanges ?? 0,\n reminders,\n }\n })\n\n const shown = <T,>(rows: T[] | undefined): T[] =>\n showAll.value ? (rows ?? []) : (rows ?? []).slice(0, SHOWN_CHANGES)\n const shownParagraphs = computed(() => shown(file.value?.paragraphs))\n /** The rows shown, a group per sheet in the order the edit reached it. */\n const shownSheets = computed(() => {\n const groups = new Map<string, SheetGroup>()\n for (const row of shown(file.value?.cells)) {\n const group = groups.get(row.sheet)\n if (group) {\n group.rows.push(row)\n } else {\n groups.set(row.sheet, { sheet: row.sheet, rows: [row] })\n }\n }\n return [...groups.values()]\n })\n const hiddenRows = computed(() => (file.value?.count ?? 0) - SHOWN_CHANGES)\n\n /**\n * The version this card wrote, when a later one of the same file is in\n * the conversation: the one the user can ask to have back.\n */\n const olderVersion = computed(() => {\n const output = file.value?.output\n const latest = output?.fileId\n ? props.latestVersions?.get(output.fileId)\n : undefined\n return output?.fileId &&\n output.version &&\n latest &&\n output.version < latest\n ? {\n fileId: output.fileId,\n version: output.version,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n }\n : undefined\n })\n\n /** Asks the agent for this version back. */\n const restoreThis = () => {\n if (olderVersion.value) {\n props.restore?.(olderVersion.value)\n }\n }\n\n /** Opens this version in the chat's viewer. */\n const openPreview = () => {\n const output = file.value?.output\n if (!output || !props.preview) {\n return\n }\n props.preview({\n kind:\n file.value?.mediaType === WORD_MIME_TYPE\n ? 'word'\n : 'spreadsheet',\n storedFileName: output.storedFileName,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n version: output.version,\n fileId: output.fileId,\n })\n }\n</script>\n\n<template>\n <div v-if=\"file\" class=\"pk-tool-chat-file\">\n <!-- Restore and open live in the file, beside its download: a\n bordered button under it weighed more than the file and the\n answer it belongs to -->\n <PkChatbotFilePreview\n :media-type=\"file.mediaType\"\n :url=\"fileUrl(file.output.storedFileName)\"\n :filename=\"file.output.filename\"\n :size=\"file.output.sizeBytes\"\n show-download\n :on-preview=\"preview ? openPreview : undefined\"\n :on-restore=\"restore && olderVersion ? restoreThis : undefined\" />\n <section\n v-if=\"file.count || file.output.restoredFrom\"\n class=\"pk-tool-chat-file__changes mt-xs\">\n <h4 class=\"pk-tool-chat-file__summary\">\n {{ file.summary }}\n </h4>\n <div v-if=\"file.count\" class=\"pk-tool-chat-file__scroll\">\n <table\n v-if=\"file.cells.length\"\n class=\"pk-tool-chat-file__table\">\n <thead>\n <tr>\n <th scope=\"col\" class=\"pk-tool-chat-file__cell\">\n {{ $t('messagePart.chatFileCell') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileBefore') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileAfter') }}\n </th>\n </tr>\n </thead>\n <tbody v-for=\"(group, g) in shownSheets\" :key=\"g\">\n <tr>\n <th\n colspan=\"3\"\n scope=\"rowgroup\"\n class=\"pk-tool-chat-file__sheet\">\n {{\n $t('messagePart.chatFileSheet', {\n name: group.sheet,\n })\n }}\n </th>\n </tr>\n <tr v-for=\"(row, index) in group.rows\" :key=\"index\">\n <td\n v-if=\"row.newSheet\"\n colspan=\"3\"\n class=\"pk-tool-chat-file__after\">\n {{ row.newSheet }}\n </td>\n <template v-else>\n <td class=\"pk-tool-chat-file__cell\">\n {{ row.cell }}\n </td>\n <td class=\"pk-tool-chat-file__before\">\n {{ row.before }}\n </td>\n <td class=\"pk-tool-chat-file__after\">\n {{ row.after }}\n </td>\n </template>\n </tr>\n </tbody>\n </table>\n <ul v-else class=\"pk-tool-chat-file__paragraphs\">\n <li\n v-for=\"(row, index) in shownParagraphs\"\n :key=\"index\"\n class=\"pk-tool-chat-file__paragraph\">\n <span class=\"pk-tool-chat-file__what\">\n {{ row.what }}\n </span>\n <span class=\"pk-tool-chat-file__text\">\n <template\n v-for=\"(segment, s) in row.segments\"\n :key=\"s\">\n <del\n v-if=\"segment.kind === 'removed'\"\n class=\"pk-tool-chat-file__removed\">\n {{ segment.text }}\n </del>\n <ins\n v-else-if=\"segment.kind === 'added'\"\n class=\"pk-tool-chat-file__added\">\n {{ segment.text }}\n </ins>\n <span v-else>{{ segment.text }}</span>\n </template>\n </span>\n </li>\n </ul>\n <p v-if=\"showAll && file.more\" class=\"pk-tool-chat-file__note\">\n {{ $t('messagePart.chatFileMoreChanges', file.more) }}\n </p>\n </div>\n <button\n v-if=\"hiddenRows > 0\"\n type=\"button\"\n class=\"pk-tool-chat-file__more\"\n :aria-expanded=\"showAll\"\n @click=\"showAll = !showAll\">\n <VvIcon\n :name=\"\n showAll ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\n \"\n class=\"text-16\"\n aria-hidden=\"true\" />\n {{\n showAll\n ? $t('action.showLess')\n : $t('action.showMore', { count: hiddenRows })\n }}\n </button>\n <p\n v-for=\"reminder in file.reminders\"\n :key=\"reminder\"\n class=\"pk-tool-chat-file__reminder\">\n <VvIcon\n name=\"ri:information-line\"\n class=\"pk-tool-chat-file__reminder-icon\"\n aria-hidden=\"true\" />\n {{ reminder }}\n </p>\n </section>\n <p v-else-if=\"file.summary\" class=\"text-12 text-word-3 mt-xs mb-0\">\n {{ file.summary }}\n </p>\n </div>\n</template>\n\n<style lang=\"scss\">\n // One frame (DESIGN.md, principle 4): a hairline at surface-3, rounded-lg,\n // a solid ground over the dots of the chat, as wide as a short paragraph\n // while the file above keeps its 280px. Inside it every divider is one\n // hairline at surface-2.\n .pk-tool-chat-file__changes {\n max-width: 36rem;\n overflow: hidden;\n border: var(--border) solid var(--color-surface-3);\n border-radius: var(--rounded-lg);\n background-color: var(--color-surface);\n font-size: var(--text-12);\n }\n\n .pk-tool-chat-file__summary {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-3);\n color: var(--color-word-2);\n font-size: var(--text-12);\n font-weight: var(--font-medium);\n\n // A restore says only what it wrote back\n &:last-child {\n border-bottom: 0;\n }\n }\n\n // Bounded, so fifty changes scroll inside the frame\n .pk-tool-chat-file__scroll {\n max-height: 20rem;\n overflow-y: auto;\n }\n\n .pk-tool-chat-file__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n text-align: start;\n vertical-align: top;\n overflow-wrap: anywhere;\n }\n\n // Told apart by its weight and colour, no heavier rule\n th {\n color: var(--color-word-3);\n font-weight: var(--font-medium);\n }\n\n tbody:last-child tr:last-child td {\n border-bottom: 0;\n }\n }\n\n // The name of a sheet heads its rows, one step of surface under it\n .pk-tool-chat-file__table .pk-tool-chat-file__sheet {\n padding-block: var(--spacing-6);\n background-color: var(--color-surface-1);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__cell {\n width: 1%;\n color: var(--color-word-2);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__before {\n width: 50%;\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__after {\n width: 50%;\n color: var(--color-word-1);\n }\n\n .pk-tool-chat-file__paragraphs {\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n .pk-tool-chat-file__paragraph {\n display: grid;\n grid-template-columns: minmax(4rem, max-content) 1fr;\n gap: var(--spacing-4) var(--spacing-md);\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n\n &:last-child {\n border-bottom: 0;\n }\n }\n\n .pk-tool-chat-file__what {\n color: var(--color-word-3);\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__text {\n min-width: 0;\n color: var(--color-word-2);\n overflow-wrap: anywhere;\n }\n\n // Marked as Word marks a revision, struck where words went and\n // underlined where they came, in the red and green of a comparison: the\n // change is what the row exists to report, the verdict exception of\n // DESIGN.md (principle 2). The readable text tokens hold the contrast in\n // both themes. The base styles take the line off `del`.\n .pk-tool-chat-file__removed {\n color: var(--u-danger-text);\n text-decoration: line-through;\n }\n\n .pk-tool-chat-file__added {\n color: var(--u-success-text);\n font-weight: var(--font-medium);\n text-decoration: underline;\n text-underline-offset: 0.2em;\n }\n\n .pk-tool-chat-file__removed + .pk-tool-chat-file__added {\n margin-inline-start: var(--spacing-4);\n }\n\n .pk-tool-chat-file__note {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__more {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: var(--spacing-4);\n width: 100%;\n padding: var(--spacing-8) var(--spacing-12);\n border: 0;\n border-top: var(--border) solid var(--color-surface-2);\n background: none;\n color: var(--color-word-2);\n font: inherit;\n cursor: pointer;\n transition: background-color var(--duration-150) var(--ease-out);\n\n &:hover {\n background-color: var(--color-surface-1);\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--input-focus-color);\n outline-offset: calc(var(--spacing-2) * -1);\n }\n }\n\n .pk-tool-chat-file__reminder {\n display: flex;\n align-items: flex-start;\n gap: var(--spacing-8);\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__reminder-icon {\n flex-shrink: 0;\n margin-top: var(--spacing-2);\n color: var(--color-word-3);\n font-size: var(--text-14);\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A,GAkFUwC,IAAgB,G;;;;;;;;;;EANtB,IAAME,oBAAkB,IAAI,IAAI,CAC5B,yBACA,yBACJ,CAAC,GAgBKC,IAAQC,GAeR,EAAE,GAAGC,GAAI,cAAWC,EAAQ,EAAE,UAAU,SAAS,CAAC,GAElDC,IAAUC,EAAI,EAAK,GAQnBC,KAAiB,MACnBC,GAAM,QAAQ,yBAAyB,GAAG,GAOxCC,KAAa,GAAc,GAAiB,MAAmB;GACjE,IAAMC,IAAOF,EAAK,MAAM,OAAO,CAAC,CAAC,OAAO,OAAO;GAS/C,OANIE,EAAK,WAAWC,KAAUC,IAAQ,KAAW,MACtCJ,IAEPG,KAAUC,IACH,GAAGF,EAAK,MAAM,GAAG,EAAI,CAAC,CAA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I,IAAS3F,EAAA,MACzBJ,EAAGgH,CAAQ,GAAA,CAAA,C;G,MAGLrC,EAAA,MAAK,WAAnBhF,EAAA,GAAAC,EAEI,KAFJsC,GAEIlC,EADG2E,EAAA,MAAK,OAAO,GAAA,CAAA,K"}
|
|
1
|
+
{"version":3,"file":"PkToolChatFile-BOexrlLt.js","names":["_openBlock","_createElementBlock","_createVNode","PkChatbotFilePreview","_createElementVNode","_toDisplayString","_unref","_Fragment","_renderList","_createTextVNode","__exportAll","isSpreadsheetDateFormat","formatExcelNumber","excelDateText","SPREADSHEET_MIME_TYPE","WORD_MIME_TYPE","PkChatbotFilePreview_default","chatFileName","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","_hoisted_20","_hoisted_21","_hoisted_22","SHOWN_CHANGES","PkToolChatFile_vue_vue_type_script_setup_true_lang_default","WORD_TOOL_PARTS","props","__props","$t","useI18n","showAll","ref","withoutLength","text","contextOf","runs","before","after","excerptOf","a","b","common","i","j","push","last","kind","run","k","wordChangeLabel","op","paragraphRow","change","cellRow","legacy","rows","bang","cell","appended","shownAs","raw","format","locale","file","computed","part","output","word","changed","changes","reminders","summary","shown","shownParagraphs","shownSheets","groups","row","group","hiddenRows","olderVersion","latest","restoreThis","openPreview","_component_VvIcon","VvIcon","openBlock","createElementBlock","createVNode","createElementVNode","toDisplayString","unref","Fragment","renderList","g","index","s","segment","createCommentVNode","_cache","createTextVNode","reminder","PkToolChatFile_exports","PkToolChatFile_default"],"sources":["../../../../packages/components/src/chat/PkToolChatFile.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import {\n isSpreadsheetDateFormat,\n SPREADSHEET_MIME_TYPE,\n WORD_MIME_TYPE,\n } from 'models'\n import PkChatbotFilePreview from './PkChatbotFilePreview.vue'\n import { excelDateText, formatExcelNumber } from './excelNumberFormat'\n import {\n chatFileName,\n type ChatFilePreviewTarget,\n type ChatFileRestoreTarget,\n } from './utils'\n\n /**\n * One entry of `changes`: a cell (or an appended row, or a new sheet) of\n * `editSpreadsheet`, a paragraph or a table row of `editWordDocument`.\n */\n type ChatFileChange = {\n cell?: string\n op?: string\n before?: string\n after?: string\n newSheetRows?: number\n /**\n * The number format code of a side that is a number in the file,\n * from edits made since it was added.\n */\n beforeFormat?: string\n afterFormat?: string\n }\n\n /** What the four file tools return that the card shows. */\n type ChatFileOutput = {\n /** The file every version of it answers to. */\n fileId?: string\n storedFileName: string\n filename?: string\n sizeBytes?: number\n version?: number\n changedCells?: number\n changedParagraphs?: number\n changes?: ChatFileChange[]\n moreChanges?: number\n /** Of a Word edit: the changes are revisions. */\n tracked?: boolean\n stalePivots?: true\n staleTableOfContents?: true\n /** Of a restore: the version this one writes again. */\n restoredFrom?: number\n }\n\n /** A run of an excerpt: text kept, taken away or put in. */\n type Segment = { text: string; kind: 'same' | 'removed' | 'added' }\n\n /**\n * A changed cell as a row of the table: its value before and after, or\n * the line that stands for a new sheet.\n */\n type CellRow = {\n sheet: string\n cell?: string\n before?: string\n after?: string\n newSheet?: string\n }\n\n /** The rows of one sheet, under its name. */\n type SheetGroup = { sheet: string; rows: CellRow[] }\n\n /** A changed paragraph or table row: what happened, and its words. */\n type ParagraphRow = { what: string; segments: Segment[] }\n\n /** The tools whose output is a Word document; the others write a spreadsheet. */\n const WORD_TOOL_PARTS = new Set([\n 'tool-editWordDocument',\n 'tool-createWordDocument',\n ])\n\n /** Rows shown before \"View more\": most edits are one to three changes. */\n const SHOWN_CHANGES = 3\n /** Words of context kept on each side of a change in a paragraph. */\n const CONTEXT_WORDS = 6\n\n /**\n * The file a call of `editSpreadsheet`, `editWordDocument`,\n * `createSpreadsheet` or `createWordDocument` wrote, a new version or a\n * new file, to download. Drawn once the call has an output: while it runs,\n * the feed's activity indicator names it, and a refused call is explained\n * by the answer. Under an edit, a frame says what changed, its first\n * rows shown: a table of cells for a spreadsheet, the changed words of\n * each paragraph for a Word document, and what is left to do in Office.\n */\n const props = defineProps<{\n part: unknown\n /** The authenticated download URL of a file stored in this chat. */\n fileUrl: (storedFileName: string) => string\n /** Opens the preview of the file, where the chat has one. */\n preview?: (file: ChatFilePreviewTarget) => void\n /** The latest version of each file the conversation shows, by fileId. */\n latestVersions?: ReadonlyMap<string, number>\n /**\n * Asks the agent to write an earlier version again as the newest one,\n * where the chat can send a message.\n */\n restore?: (file: ChatFileRestoreTarget) => void\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n\n const showAll = ref(false)\n\n /**\n * The services cut a long text for the model and give its length\n * (`… (523 characters)`, the marker of every tool result, written by\n * `wordDocument.service.ts` and `spreadsheet.service.ts`): the card keeps\n * the ellipsis only.\n */\n const withoutLength = (text: string | undefined) =>\n text?.replace(/… \\(\\d+ characters\\)$/, '…')\n\n /**\n * A run of unchanged words cut to a few words on the side of each change\n * it touches: the head of the text keeps its end, the tail its start, a\n * run between two changes both, with an ellipsis where words went.\n */\n const contextOf = (text: string, before: boolean, after: boolean) => {\n const runs = text.split(/(\\s+)/).filter(Boolean)\n // Every word is followed by its space: twice as many runs.\n const keep = CONTEXT_WORDS * 2\n if (runs.length <= (before && after ? keep * 2 : keep)) {\n return text\n }\n if (before && after) {\n return `${runs.slice(0, keep).join('')}… ${runs.slice(-keep).join('')}`\n }\n return after\n ? `…${runs.slice(-keep).join('')}`\n : `${runs.slice(0, keep).join('')}…`\n }\n\n /**\n * The words of `before` and `after` that differ, word by word, so the\n * words two changes share between them stay plain. An echoed paragraph\n * is at most a few hundred characters, a few dozen words for the table.\n */\n const excerptOf = (before: string, after: string): Segment[] => {\n const a = before.split(/(\\s+)/).filter(Boolean)\n const b = after.split(/(\\s+)/).filter(Boolean)\n // Longest common subsequence, from the end\n const common = Array.from({ length: a.length + 1 }, () =>\n new Array<number>(b.length + 1).fill(0),\n )\n for (let i = a.length - 1; i >= 0; i--) {\n for (let j = b.length - 1; j >= 0; j--) {\n common[i][j] =\n a[i] === b[j]\n ? common[i + 1][j + 1] + 1\n : Math.max(common[i + 1][j], common[i][j + 1])\n }\n }\n const runs: Segment[] = []\n const push = (text: string, kind: Segment['kind']) => {\n const last = runs[runs.length - 1]\n if (last?.kind === kind) {\n last.text += text\n } else {\n runs.push({ text, kind })\n }\n }\n let i = 0\n let j = 0\n while (i < a.length || j < b.length) {\n if (i < a.length && j < b.length && a[i] === b[j]) {\n push(a[i++], 'same')\n j++\n } else if (\n j >= b.length ||\n (i < a.length && common[i + 1][j] >= common[i][j + 1])\n ) {\n push(a[i++], 'removed')\n } else {\n push(b[j++], 'added')\n }\n }\n return runs.map((run, k) =>\n run.kind === 'same'\n ? {\n ...run,\n text: contextOf(run.text, k > 0, k < runs.length - 1),\n }\n : run,\n )\n }\n\n /** What a Word operation did, as the row says it. */\n const wordChangeLabel = (op: string | undefined) => {\n switch (op) {\n case 'insertParagraphs':\n return $t('messagePart.chatFileParagraphAdded')\n case 'deleteParagraphs':\n return $t('messagePart.chatFileParagraphDeleted')\n case 'insertTableRow':\n return $t('messagePart.chatFileTableRowAdded')\n case 'deleteTableRow':\n return $t('messagePart.chatFileTableRowDeleted')\n case 'acceptRevisions':\n return $t('messagePart.chatFileRevisionAccepted')\n case 'rejectRevisions':\n return $t('messagePart.chatFileRevisionRejected')\n default:\n return $t('messagePart.chatFileParagraphChanged')\n }\n }\n\n /**\n * A paragraph marked as Word marks a revision, struck where words went\n * and underlined where they came. A paragraph only added or only removed\n * is said by its label: the text added stays plain, the text removed\n * stays struck.\n */\n const paragraphRow = (change: ChatFileChange): ParagraphRow => {\n const before = withoutLength(change.before)\n const after = withoutLength(change.after)\n return {\n what: wordChangeLabel(change.op),\n segments:\n before && after\n ? excerptOf(before, after)\n : [\n before\n ? { text: before, kind: 'removed' }\n : { text: after ?? '', kind: 'same' },\n ],\n }\n }\n\n /**\n * A cell as a person reads it: its sheet heads the group of its rows, so\n * the row says `C5` and not Excel's `Listino!C5`, and a row the edit\n * appended says \"Row 10\" and not `A10:F10`.\n */\n const cellRow = (change: ChatFileChange): CellRow => {\n const ref = change.cell ?? ''\n // A new sheet is named alone, with no cell. An edit made before the\n // card read `newSheetRows` said it only in the model's words.\n const legacy = change.before\n ? undefined\n : /^new sheet, (\\d+) row\\(s\\)$/.exec(change.after ?? '')?.[1]\n const rows =\n change.newSheetRows ?? (legacy ? Number(legacy) : undefined)\n if (rows !== undefined) {\n return {\n sheet: ref,\n newSheet: $t('messagePart.chatFileNewSheet', rows),\n }\n }\n\n const bang = ref.lastIndexOf('!')\n const cell = ref.slice(bang + 1)\n const appended = /^A(\\d+):[A-Z]+(\\d+)$/.exec(cell)\n return {\n sheet: ref.slice(0, Math.max(bang, 0)),\n cell:\n appended && appended[1] === appended[2]\n ? $t('messagePart.chatFileRow', { row: appended[1] })\n : cell,\n before: shownAs(withoutLength(change.before), change.beforeFormat),\n after: shownAs(withoutLength(change.after), change.afterFormat),\n }\n }\n\n /**\n * A value as its cell shows it, `0.05` as `5%` and a date serial as the\n * date; a formula, a text and a cell with no format stay as written.\n */\n const shownAs = (\n raw: string | undefined,\n format: string | undefined,\n ): string | undefined => {\n if (!raw || !format || raw.startsWith('=')) {\n return raw || undefined\n }\n try {\n if (isSpreadsheetDateFormat(format)) {\n return excelDateText(raw, format, locale.value) ?? raw\n }\n return /^-?\\d+(\\.\\d+)?(e[+-]?\\d+)?$/i.test(raw)\n ? formatExcelNumber(format, Number(raw), locale.value).text\n : raw\n } catch {\n // A code the interpreter cannot read: the value as written\n return raw\n }\n }\n\n const file = computed(() => {\n const part = props.part as {\n type?: string\n state?: string\n output?: Partial<ChatFileOutput>\n }\n if (part.state !== 'output-available' || !part.output?.storedFileName) {\n return undefined\n }\n const output = part.output as ChatFileOutput\n const word = WORD_TOOL_PARTS.has(part.type ?? '')\n // A new file has no count of changes. Each key is written out in its\n // own call: the widget ships only the keys it finds that way.\n let changed: string | undefined\n if (word && output.changedParagraphs !== undefined) {\n changed = output.tracked\n ? $t(\n 'messagePart.editWordDocumentRevisions',\n output.changedParagraphs,\n )\n : $t(\n 'messagePart.editWordDocumentParagraphs',\n output.changedParagraphs,\n )\n } else if (!word && output.changedCells !== undefined) {\n changed = $t(\n 'messagePart.editSpreadsheetCells',\n output.changedCells,\n )\n }\n const changes = changed ? (output.changes ?? []) : []\n const reminders: string[] = []\n if (output.stalePivots) {\n reminders.push($t('messagePart.chatFileRefreshPivots'))\n }\n if (output.staleTableOfContents) {\n reminders.push($t('messagePart.chatFileUpdateTableOfContents'))\n }\n let summary =\n changed && output.version\n ? $t('messagePart.chatFileVersionSummary', {\n version: output.version,\n changed,\n })\n : changed\n if (output.restoredFrom) {\n summary = $t('messagePart.chatFileRestored', {\n version: output.version,\n restored: output.restoredFrom,\n })\n }\n return {\n output,\n mediaType: word ? WORD_MIME_TYPE : SPREADSHEET_MIME_TYPE,\n summary,\n cells: word ? [] : changes.map(cellRow),\n paragraphs: word ? changes.map(paragraphRow) : [],\n count: changes.length,\n more: output.moreChanges ?? 0,\n reminders,\n }\n })\n\n const shown = <T,>(rows: T[] | undefined): T[] =>\n showAll.value ? (rows ?? []) : (rows ?? []).slice(0, SHOWN_CHANGES)\n const shownParagraphs = computed(() => shown(file.value?.paragraphs))\n /** The rows shown, a group per sheet in the order the edit reached it. */\n const shownSheets = computed(() => {\n const groups = new Map<string, SheetGroup>()\n for (const row of shown(file.value?.cells)) {\n const group = groups.get(row.sheet)\n if (group) {\n group.rows.push(row)\n } else {\n groups.set(row.sheet, { sheet: row.sheet, rows: [row] })\n }\n }\n return [...groups.values()]\n })\n const hiddenRows = computed(() => (file.value?.count ?? 0) - SHOWN_CHANGES)\n\n /**\n * The version this card wrote, when a later one of the same file is in\n * the conversation: the one the user can ask to have back.\n */\n const olderVersion = computed(() => {\n const output = file.value?.output\n const latest = output?.fileId\n ? props.latestVersions?.get(output.fileId)\n : undefined\n return output?.fileId &&\n output.version &&\n latest &&\n output.version < latest\n ? {\n fileId: output.fileId,\n version: output.version,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n }\n : undefined\n })\n\n /** Asks the agent for this version back. */\n const restoreThis = () => {\n if (olderVersion.value) {\n props.restore?.(olderVersion.value)\n }\n }\n\n /** Opens this version in the chat's viewer. */\n const openPreview = () => {\n const output = file.value?.output\n if (!output || !props.preview) {\n return\n }\n props.preview({\n kind:\n file.value?.mediaType === WORD_MIME_TYPE\n ? 'word'\n : 'spreadsheet',\n storedFileName: output.storedFileName,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n version: output.version,\n fileId: output.fileId,\n })\n }\n</script>\n\n<template>\n <div v-if=\"file\" class=\"pk-tool-chat-file\">\n <!-- Restore and open live in the file, beside its download: a\n bordered button under it weighed more than the file and the\n answer it belongs to -->\n <PkChatbotFilePreview\n :media-type=\"file.mediaType\"\n :url=\"fileUrl(file.output.storedFileName)\"\n :filename=\"file.output.filename\"\n :size=\"file.output.sizeBytes\"\n show-download\n :on-preview=\"preview ? openPreview : undefined\"\n :on-restore=\"restore && olderVersion ? restoreThis : undefined\" />\n <section\n v-if=\"file.count || file.output.restoredFrom\"\n class=\"pk-tool-chat-file__changes mt-xs\">\n <h4 class=\"pk-tool-chat-file__summary\">\n {{ file.summary }}\n </h4>\n <div v-if=\"file.count\" class=\"pk-tool-chat-file__scroll\">\n <table\n v-if=\"file.cells.length\"\n class=\"pk-tool-chat-file__table\">\n <thead>\n <tr>\n <th scope=\"col\" class=\"pk-tool-chat-file__cell\">\n {{ $t('messagePart.chatFileCell') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileBefore') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileAfter') }}\n </th>\n </tr>\n </thead>\n <tbody v-for=\"(group, g) in shownSheets\" :key=\"g\">\n <tr>\n <th\n colspan=\"3\"\n scope=\"rowgroup\"\n class=\"pk-tool-chat-file__sheet\">\n {{\n $t('messagePart.chatFileSheet', {\n name: group.sheet,\n })\n }}\n </th>\n </tr>\n <tr v-for=\"(row, index) in group.rows\" :key=\"index\">\n <td\n v-if=\"row.newSheet\"\n colspan=\"3\"\n class=\"pk-tool-chat-file__after\">\n {{ row.newSheet }}\n </td>\n <template v-else>\n <td class=\"pk-tool-chat-file__cell\">\n {{ row.cell }}\n </td>\n <td class=\"pk-tool-chat-file__before\">\n {{ row.before }}\n </td>\n <td class=\"pk-tool-chat-file__after\">\n {{ row.after }}\n </td>\n </template>\n </tr>\n </tbody>\n </table>\n <ul v-else class=\"pk-tool-chat-file__paragraphs\">\n <li\n v-for=\"(row, index) in shownParagraphs\"\n :key=\"index\"\n class=\"pk-tool-chat-file__paragraph\">\n <span class=\"pk-tool-chat-file__what\">\n {{ row.what }}\n </span>\n <span class=\"pk-tool-chat-file__text\">\n <template\n v-for=\"(segment, s) in row.segments\"\n :key=\"s\">\n <del\n v-if=\"segment.kind === 'removed'\"\n class=\"pk-tool-chat-file__removed\">\n {{ segment.text }}\n </del>\n <ins\n v-else-if=\"segment.kind === 'added'\"\n class=\"pk-tool-chat-file__added\">\n {{ segment.text }}\n </ins>\n <span v-else>{{ segment.text }}</span>\n </template>\n </span>\n </li>\n </ul>\n <p v-if=\"showAll && file.more\" class=\"pk-tool-chat-file__note\">\n {{ $t('messagePart.chatFileMoreChanges', file.more) }}\n </p>\n </div>\n <button\n v-if=\"hiddenRows > 0\"\n type=\"button\"\n class=\"pk-tool-chat-file__more\"\n :aria-expanded=\"showAll\"\n @click=\"showAll = !showAll\">\n <VvIcon\n :name=\"\n showAll ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\n \"\n class=\"text-16\"\n aria-hidden=\"true\" />\n {{\n showAll\n ? $t('action.showLess')\n : $t('action.showMore', { count: hiddenRows })\n }}\n </button>\n <p\n v-for=\"reminder in file.reminders\"\n :key=\"reminder\"\n class=\"pk-tool-chat-file__reminder\">\n <VvIcon\n name=\"ri:information-line\"\n class=\"pk-tool-chat-file__reminder-icon\"\n aria-hidden=\"true\" />\n {{ reminder }}\n </p>\n </section>\n <p v-else-if=\"file.summary\" class=\"text-12 text-word-3 mt-xs mb-0\">\n {{ file.summary }}\n </p>\n </div>\n</template>\n\n<style lang=\"scss\">\n // One frame (DESIGN.md, principle 4): a hairline at surface-3, rounded-lg,\n // a solid ground over the dots of the chat, as wide as a short paragraph\n // while the file above keeps its 280px. Inside it every divider is one\n // hairline at surface-2.\n .pk-tool-chat-file__changes {\n max-width: 36rem;\n overflow: hidden;\n border: var(--border) solid var(--color-surface-3);\n border-radius: var(--rounded-lg);\n background-color: var(--color-surface);\n font-size: var(--text-12);\n }\n\n .pk-tool-chat-file__summary {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-3);\n color: var(--color-word-2);\n font-size: var(--text-12);\n font-weight: var(--font-medium);\n\n // A restore says only what it wrote back\n &:last-child {\n border-bottom: 0;\n }\n }\n\n // Bounded, so fifty changes scroll inside the frame\n .pk-tool-chat-file__scroll {\n max-height: 20rem;\n overflow-y: auto;\n }\n\n .pk-tool-chat-file__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n text-align: start;\n vertical-align: top;\n overflow-wrap: anywhere;\n }\n\n // Told apart by its weight and colour, no heavier rule\n th {\n color: var(--color-word-3);\n font-weight: var(--font-medium);\n }\n\n tbody:last-child tr:last-child td {\n border-bottom: 0;\n }\n }\n\n // The name of a sheet heads its rows, one step of surface under it\n .pk-tool-chat-file__table .pk-tool-chat-file__sheet {\n padding-block: var(--spacing-6);\n background-color: var(--color-surface-1);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__cell {\n width: 1%;\n color: var(--color-word-2);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__before {\n width: 50%;\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__after {\n width: 50%;\n color: var(--color-word-1);\n }\n\n .pk-tool-chat-file__paragraphs {\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n .pk-tool-chat-file__paragraph {\n display: grid;\n grid-template-columns: minmax(4rem, max-content) 1fr;\n gap: var(--spacing-4) var(--spacing-md);\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n\n &:last-child {\n border-bottom: 0;\n }\n }\n\n .pk-tool-chat-file__what {\n color: var(--color-word-3);\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__text {\n min-width: 0;\n color: var(--color-word-2);\n overflow-wrap: anywhere;\n }\n\n // Marked as Word marks a revision, struck where words went and\n // underlined where they came, in the red and green of a comparison: the\n // change is what the row exists to report, the verdict exception of\n // DESIGN.md (principle 2). The readable text tokens hold the contrast in\n // both themes. The base styles take the line off `del`.\n .pk-tool-chat-file__removed {\n color: var(--u-danger-text);\n text-decoration: line-through;\n }\n\n .pk-tool-chat-file__added {\n color: var(--u-success-text);\n font-weight: var(--font-medium);\n text-decoration: underline;\n text-underline-offset: 0.2em;\n }\n\n .pk-tool-chat-file__removed + .pk-tool-chat-file__added {\n margin-inline-start: var(--spacing-4);\n }\n\n .pk-tool-chat-file__note {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__more {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: var(--spacing-4);\n width: 100%;\n padding: var(--spacing-8) var(--spacing-12);\n border: 0;\n border-top: var(--border) solid var(--color-surface-2);\n background: none;\n color: var(--color-word-2);\n font: inherit;\n cursor: pointer;\n transition: background-color var(--duration-150) var(--ease-out);\n\n &:hover {\n background-color: var(--color-surface-1);\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--input-focus-color);\n outline-offset: calc(var(--spacing-2) * -1);\n }\n }\n\n .pk-tool-chat-file__reminder {\n display: flex;\n align-items: flex-start;\n gap: var(--spacing-8);\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__reminder-icon {\n flex-shrink: 0;\n margin-top: var(--spacing-2);\n color: var(--color-word-3);\n font-size: var(--text-14);\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A,GAkFUwC,IAAgB,G;;;;;;;;;;EANtB,IAAME,oBAAkB,IAAI,IAAI,CAC5B,yBACA,yBACJ,CAAC,GAgBKC,IAAQC,GAeR,EAAE,GAAGC,GAAI,cAAWC,EAAQ,EAAE,UAAU,SAAS,CAAC,GAElDC,IAAUC,EAAI,EAAK,GAQnBC,KAAiB,MACnBC,GAAM,QAAQ,yBAAyB,GAAG,GAOxCC,KAAa,GAAc,GAAiB,MAAmB;GACjE,IAAMC,IAAOF,EAAK,MAAM,OAAO,CAAC,CAAC,OAAO,OAAO;GAS/C,OANIE,EAAK,WAAWC,KAAUC,IAAQ,KAAW,MACtCJ,IAEPG,KAAUC,IACH,GAAGF,EAAK,MAAM,GAAG,EAAI,CAAC,CAAC,KAAK,EAAE,EAAE,IAAIA,EAAK,MAAM,GAAK,CAAC,CAAC,KAAK,EAAE,MAEjEE,IACD,IAAIF,EAAK,MAAM,GAAK,CAAC,CAAC,KAAK,EAAE,MAC7B,GAAGA,EAAK,MAAM,GAAG,EAAI,CAAC,CAAC,KAAK,EAAE,EAAE;EAC1C,GAOMG,KAAa,GAAgB,MAA6B;GAC5D,IAAMC,IAAIH,EAAO,MAAM,OAAO,CAAC,CAAC,OAAO,OAAO,GACxCI,IAAIH,EAAM,MAAM,OAAO,CAAC,CAAC,OAAO,OAAO,GAEvCI,IAAS,MAAM,KAAK,EAAE,QAAQF,EAAE,SAAS,EAAE,SACzC,MAAcC,EAAE,SAAS,CAAC,CAAC,CAAC,KAA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,SAAWiC,EAAA,MAAK,QAAzBhF,EAAA,GAAAC,EAEI,KAFJoC,GAEIhC,EADGC,EAAAuC,CAAA,CAAE,CAAA,mCAAoCmC,EAAA,MAAK,IAAI,CAAA,GAAA,CAAA,K;IAIhDe,EAAA,QAAU,KADpB/F,EAAA,GAAAC,EAiBS,UAAA;;KAfL,MAAK;KACL,OAAM;KACL,iBAAe8C,EAAA;KACf,SAAK,AAAAoE,EAAA,QAAA,MAAE,EAAA,QAAO,CAAIpE,EAAA;I,IACnB7C,EAKyBkG,GAAA;KAJpB,MAA+BrD,EAAA,QAAO,uBAAA;KAGvC,OAAM;KACN,eAAY;I,uBAAStC,EAAA,MACzBJ,EACI0C,EAAA,QAAkCzC,EAAAuC,CAAA,CAAE,CAAA,iBAAA,IAA8CvC,EAAAuC,CAAA,CAAE,CAAA,mBAAA,EAAA,OAA6BkD,EAAA,MAAU,CAAA,CAAA,GAAA,CAAA,C;KAKnI/F,EAAA,EAAA,GAAAC,EASIM,GAAA,MAAAC,EARmBwE,EAAA,MAAK,YAAjB,OADXhF,EAAA,GAAAC,EASI,KAAA;KAPC,KAAKoH;KACN,OAAM;I,IACNnH,EAGyBkG,GAAA;KAFrB,MAAK;KACL,OAAM;KACN,eAAY;I,IAAS3F,EAAA,MACzBJ,EAAGgH,CAAQ,GAAA,CAAA,C;G,MAGLrC,EAAA,MAAK,WAAnBhF,EAAA,GAAAC,EAEI,KAFJsC,GAEIlC,EADG2E,EAAA,MAAK,OAAO,GAAA,CAAA,K"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-CGnMp29N.js";
|
|
2
|
-
import { H as t } from "./Agent-
|
|
2
|
+
import { H as t } from "./Agent-CBAd3F7k.js";
|
|
3
3
|
import { VvIcon as n } from "@volverjs/ui-vue/components";
|
|
4
4
|
import { Fragment as r, computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, onMounted as d, openBlock as f, toDisplayString as p, unref as m } from "vue";
|
|
5
5
|
import { useI18n as h } from "vue-i18n";
|
|
@@ -63,4 +63,4 @@ var g = { class: "flex items-center gap-6 text-12 text-word-3 border border-surf
|
|
|
63
63
|
}), v = /* @__PURE__ */ e({ default: () => y }), y = _;
|
|
64
64
|
export { v as n, y as t };
|
|
65
65
|
|
|
66
|
-
//# sourceMappingURL=PkToolRequestGeolocation-
|
|
66
|
+
//# sourceMappingURL=PkToolRequestGeolocation-CyL_M1Rm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolRequestGeolocation-
|
|
1
|
+
{"version":3,"file":"PkToolRequestGeolocation-CyL_M1Rm.js","names":["$n","_openBlock","_createElementBlock","_Fragment","_createVNode","_createElementVNode","_toDisplayString","_unref","_createTextVNode","__exportAll","isVoiceRenderAck","_hoisted_1","PkToolRequestGeolocation_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","$t","useI18n","toolPart","computed","state","isRenderAck","isOutputAvailable","successOutput","out","errorOutput","mapGeolocationError","code","onMounted","position","city","latitude","longitude","error","_component_VvIcon","VvIcon","openBlock","createElementBlock","Fragment","createVNode","createElementVNode","createTextVNode","toDisplayString","_ctx","createCommentVNode","unref","PkToolRequestGeolocation_exports","PkToolRequestGeolocation_default"],"sources":["../../../../packages/components/src/chat/PkToolRequestGeolocation.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, onMounted } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n\n import type { ReverseGeocodeFn } from 'utils/src/device-context'\n\n type GeolocationOutput =\n | {\n latitude: number\n longitude: number\n accuracy?: number\n city?: string\n }\n | { error: 'permission_denied' | 'position_unavailable' | 'timeout' }\n\n const props = defineProps<{\n part: unknown\n reverseGeocode?: ReverseGeocodeFn\n /**\n * Whether a voice call is on the line right now. A request drawn\n * during a call arrives already resolved with the render ack, and the\n * browser prompt must fire only while the caller who was asked is\n * still there: reopening the conversation later must not ask again.\n */\n callLive?: boolean\n }>()\n\n const emit = defineEmits<{\n result: [output: GeolocationOutput]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n input?: { reason?: string }\n /** The position, or the voice render ack (a string). */\n output?: GeolocationOutput | string\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n\n /**\n * The ack is not a position: it only says the card was drawn during a\n * call (see `isVoiceRenderAck`, same rule as the forms). Besides gating\n * the prompt below, it must be kept away from the output parsing: `in`\n * on a string throws, which broke this card on every spoken turn.\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n const isOutputAvailable = computed(\n () => state.value === 'output-available' && !isRenderAck.value,\n )\n\n const successOutput = computed(() => {\n const out = toolPart.value.output\n if (!out || typeof out === 'string' || 'error' in out) {\n return undefined\n }\n return out\n })\n\n const errorOutput = computed(() => {\n const out = toolPart.value.output\n if (!out || typeof out === 'string' || !('error' in out)) {\n return undefined\n }\n return out\n })\n\n /** Maps GeolocationPositionError.code to a typed string */\n function mapGeolocationError(\n code: number,\n ): 'permission_denied' | 'position_unavailable' | 'timeout' {\n if (code === 1) {\n return 'permission_denied'\n }\n if (code === 3) {\n return 'timeout'\n }\n return 'position_unavailable'\n }\n\n onMounted(() => {\n const isAwaitingPosition =\n state.value === 'input-available' ||\n (isRenderAck.value && props.callLive === true)\n if (!isAwaitingPosition) {\n return\n }\n\n if (!navigator.geolocation) {\n emit('result', { error: 'position_unavailable' })\n return\n }\n\n navigator.geolocation.getCurrentPosition(\n async (position) => {\n const { latitude, longitude, accuracy } = position.coords\n const city = props.reverseGeocode\n ? await props\n .reverseGeocode(latitude, longitude)\n .catch(() => undefined)\n : undefined\n emit('result', { latitude, longitude, accuracy, city })\n },\n (error) => {\n emit('result', { error: mapGeolocationError(error.code) })\n },\n { timeout: 15000 },\n )\n })\n</script>\n\n<template>\n <div\n class=\"flex items-center gap-6 text-12 text-word-3 border border-surface-3 rounded-xl px-sm py-10\">\n <!-- Loading state -->\n <template v-if=\"!isOutputAvailable\">\n <VvIcon name=\"loading-loop\" class=\"text-16\" />\n <span>{{ $t('messagePart.requestGeolocation') }}</span>\n </template>\n\n <!-- Success state -->\n <template v-else-if=\"successOutput\">\n <VvIcon name=\"ri:map-pin-line\" class=\"text-16\" />\n <span>\n {{\n $n(successOutput.latitude, {\n style: 'decimal',\n minimumFractionDigits: 5,\n maximumFractionDigits: 5,\n })\n }},\n {{\n $n(successOutput.longitude, {\n style: 'decimal',\n minimumFractionDigits: 5,\n maximumFractionDigits: 5,\n })\n }}\n <template v-if=\"successOutput.accuracy !== undefined\">\n (±{{\n $n(successOutput.accuracy, {\n style: 'unit',\n unit: 'meter',\n })\n }})\n </template>\n </span>\n </template>\n\n <!-- Error state -->\n <template v-else-if=\"errorOutput\">\n <VvIcon\n name=\"ri:error-warning-line\"\n class=\"w-16 h-16 shrink-0 text-danger\" />\n <span>\n {{\n errorOutput.error === 'permission_denied'\n ? $t('message.geolocationPermissionDenied')\n : $t('message.geolocationUnavailable')\n }}\n </span>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;EAgBI,IAAMc,IAAQC,GAYRC,IAAOH,GAIP,EAAE,GAAGI,MAAOC,EAAQ,EAAE,UAAU,SAAS,CAAC,GAE1CC,IAAWC,QACNN,EAAM,IAMhB,GAEKO,IAAQD,QAAeD,EAAS,MAAM,SAAS,SAAS,GAQxDG,IAAcF,QAAeV,EAAiBS,EAAS,MAAM,MAAM,CAAC,GAEpEI,IAAoBH,QAChBC,EAAM,UAAU,sBAAsB,CAACC,EAAY,KAC7D,GAEME,IAAgBJ,QAAe;GACjC,IAAMK,IAAMN,EAAS,MAAM;GAC3B,IAAI,GAACM,KAAO,OAAOA,KAAQ,YAAY,WAAWA,IAGlD,OAAOA;EACX,CAAC,GAEKC,IAAcN,QAAe;GAC/B,IAAMK,IAAMN,EAAS,MAAM;GAC3B,IAAKM,KAAO,OAAOA,KAA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AArBzB,EAAA,GAAAC,EAWWC,GAAA,EAAA,KAAA,EAAA,GAAA,CAVPC,EAE6C+B,GAAA;IADzC,MAAK;IACL,OAAM;G,IACV9B,EAMO,QAAA,MAAAC,EAJCoB,EAAA,MAAY,UAAK,sBAAmDnB,EAAAU,CAAA,CAAE,CAAA,qCAAA,IAAkEV,EAAAU,CAAA,CAAE,CAAA,gCAAA,CAAA,GAAA,CAAA,C,uBAzCtJhB,EAAA,GAAAC,EAGWC,GAAA,EAAA,KAAA,EAAA,GAAA,CAFPC,EAA8C+B,GAAA;IAAtC,MAAK;IAAe,OAAM;G,IAClC9B,EAAuD,QAAA,MAAAC,EAA9CC,EAAAU,CAAA,CAAE,CAAA,gCAAA,CAAA,GAAA,CAAA,C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./VvButtonLocalized-C-vx25u4.js";
|
|
2
|
-
import { H as t } from "./Agent-
|
|
2
|
+
import { H as t } from "./Agent-CBAd3F7k.js";
|
|
3
3
|
import { t as n } from "./mcpOAuthReport-D-MtFYwN.js";
|
|
4
4
|
import { VvIcon as r } from "@volverjs/ui-vue/components";
|
|
5
5
|
import { Fragment as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createVNode as u, defineComponent as d, onMounted as f, onUnmounted as p, openBlock as m, ref as h, toDisplayString as g, unref as _ } from "vue";
|
|
@@ -114,4 +114,4 @@ var y = { class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-s
|
|
|
114
114
|
});
|
|
115
115
|
export { A as default };
|
|
116
116
|
|
|
117
|
-
//# sourceMappingURL=PkToolRequestOAuthConnection-
|
|
117
|
+
//# sourceMappingURL=PkToolRequestOAuthConnection-DWkeVLpx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolRequestOAuthConnection-CgD-o99C.js","names":["_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_createBlock","_Fragment","VvButtonLocalized","isVoiceRenderAck","isMcpOAuthReport","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","POLL_INTERVAL_MS","POLL_TIMEOUT_MS","PkToolRequestOAuthConnection_default","defineComponent","__emit","props","__props","emit","$t","useI18n","toolPart","computed","state","serverName","isRenderAck","isConnectedByOutput","isAwaitingConnection","mcpServerId","ref","hasConnected","isSigningIn","oauthError","isDone","canConnect","isConnectedNow","status","pollTimer","signInAttempt","signInWindow","stopWatching","settleConnected","connectedServerId","watchForConnection","attempt","popup","deadline","tick","connected","onMessage","event","reportedServerId","openAuthWindow","connection","err","onMounted","onUnmounted","_component_VvIcon","VvIcon","_component_VvButton","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","createBlock","createCommentVNode","Fragment"],"sources":["../../../../packages/components/src/chat/PkToolRequestOAuthConnection.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, onMounted, onUnmounted, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n import { isMcpOAuthReport } from './mcpOAuthReport'\n\n const props = defineProps<{\n part: unknown\n /**\n * The backend the chat talks to, where the sign-in's callback page\n * runs. Without it the card hears no report and relies on its poll.\n */\n backendUrl?: string\n resolveConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; authorizeUrl: string }>\n checkConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; connected: boolean }>\n }>()\n\n const emit = defineEmits<{\n connected: [mcpServerId: string]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n /** How often the connection is re-read while the sign-in window is out. */\n const POLL_INTERVAL_MS = 2000\n /**\n * How long we keep asking. The only end to a sign-in nobody finishes:\n * `popup.closed` cannot be that signal, because the browser disowns the\n * handle when the provider severs the opener (that is what\n * `Cross-Origin-Opener-Policy` does), so it reads as closed from the first\n * check of the very flow this watch exists for. Long enough for a password\n * manager and a second factor.\n */\n const POLL_TIMEOUT_MS = 5 * 60 * 1000\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n toolCallId?: string\n input?: { serverName: string }\n output?: unknown\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n const serverName = computed(() => toolPart.value.input?.serverName)\n\n /**\n * A card drawn during a CALL arrives already \"answered\": the turn could\n * not wait for the connection, so the backend closed the tool with a note\n * saying the card was drawn (see `isVoiceRenderAck`, same rule as the\n * forms). That note is not a connection, and without this the card\n * rendered its inert fallback: the caller was told to connect the account\n * and given nothing to click (measured 2026-08-07).\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n /** The output this card wrote itself once the connection went through. */\n const isConnectedByOutput = computed(\n () =>\n (toolPart.value.output as { connected?: unknown } | undefined)\n ?.connected === true,\n )\n\n const isAwaitingConnection = computed(\n () => state.value === 'input-available' || isRenderAck.value,\n )\n\n const mcpServerId = ref<string | null>(null)\n /**\n * Set once THIS card's sign-in went through, and never from a plain read of\n * the connection: a card still asking is the turn saying it could not use\n * that integration, and a token row can outlive its usefulness (a refresh\n * that failed transiently keeps the row, so the turn sees no usable token\n * while a status read still sees one). Trusting the read there would have\n * left the card claiming success, with no button, on a turn still waiting.\n * It doubles as the guard that resumes the turn exactly once, whichever\n * channel got there first.\n */\n const hasConnected = ref(false)\n /** A sign-in window we opened is still out there. */\n const isSigningIn = ref(false)\n const oauthError = ref<string | null>(null)\n\n const isDone = computed(\n () => hasConnected.value || isConnectedByOutput.value,\n )\n const canConnect = computed(\n () => Boolean(serverName.value) && Boolean(props.resolveConnection),\n )\n\n /**\n * Whether the server says this user has connected, asked without minting\n * anything: no OAuth `state` is burned by looking.\n */\n async function isConnectedNow(): Promise<boolean> {\n if (!serverName.value || !props.checkConnection) {\n return false\n }\n try {\n const status = await props.checkConnection(serverName.value)\n mcpServerId.value = status.mcpServerId\n return status.connected\n } catch {\n // Not knowing is not an error to show: the sign-in window is still\n // out there and the next read may well answer.\n return false\n }\n }\n\n let pollTimer: ReturnType<typeof setTimeout> | undefined\n /**\n * Which sign-in a running tick belongs to. A tick suspended on its read\n * outlives the attempt that scheduled it: without this it woke up inside\n * the NEXT attempt, restarted its own chain over that one's timer and then\n * stopped it on its own older deadline.\n */\n let signInAttempt = 0\n /** The window this attempt opened, the only sender we accept a report from. */\n let signInWindow: Window | null = null\n\n function stopWatching() {\n if (pollTimer !== undefined) {\n clearTimeout(pollTimer)\n pollTimer = undefined\n }\n signInAttempt += 1\n signInWindow = null\n isSigningIn.value = false\n }\n\n function settleConnected(connectedServerId: string) {\n stopWatching()\n if (hasConnected.value) {\n return\n }\n hasConnected.value = true\n mcpServerId.value = connectedServerId\n oauthError.value = null\n emit('connected', connectedServerId)\n }\n\n /**\n * Watches the connection from THIS window while the sign-in window is away.\n *\n * The callback page reports through `window.opener`, and a provider that\n * sends `Cross-Origin-Opener-Policy` anywhere in its redirect chain takes\n * that opener away: the connection then succeeds with nobody listening, the\n * card stays on its button and the suspended turn is never resumed\n * (reported 2026-08-27). This channel never goes through that window, so it\n * survives whatever the provider does to it. Chained rather than periodic:\n * a read slower than the interval would otherwise overlap the next one.\n */\n function watchForConnection(popup: Window) {\n stopWatching()\n const attempt = signInAttempt\n signInWindow = popup\n isSigningIn.value = true\n const deadline = Date.now() + POLL_TIMEOUT_MS\n const tick = async () => {\n if (attempt !== signInAttempt || Date.now() > deadline) {\n if (attempt === signInAttempt) {\n stopWatching()\n }\n return\n }\n const connected = await isConnectedNow()\n if (attempt !== signInAttempt) {\n return\n }\n if (connected && mcpServerId.value) {\n settleConnected(mcpServerId.value)\n return\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n\n /**\n * The callback page's own report, when the browser let it through: faster\n * than the poll, and the only channel carrying the failure reason.\n *\n * Accepted only as {@link isMcpOAuthReport} says, and only while that\n * sign-in is out: the listener stays up for as long as the card is on\n * screen, and nothing else with a handle on this page may resume a turn by\n * posting a message at it.\n */\n function onMessage(event: MessageEvent) {\n if (\n !isSigningIn.value ||\n !isMcpOAuthReport(event, signInWindow, props.backendUrl)\n ) {\n return\n }\n const reportedServerId = event.data.mcpServerId as string | undefined\n if (\n reportedServerId &&\n mcpServerId.value &&\n reportedServerId !== mcpServerId.value\n ) {\n return\n }\n if (!event.data.success) {\n // A failure carries no server id: the callback never got that far.\n stopWatching()\n oauthError.value = event.data.error ?? 'Unknown error'\n return\n }\n const connectedServerId = reportedServerId ?? mcpServerId.value\n if (connectedServerId) {\n settleConnected(connectedServerId)\n }\n }\n\n /**\n * Opens the provider's sign-in, on an authorize URL minted NOW.\n *\n * The URL carries an OAuth `state` that lives ten minutes server-side.\n * Minted when the card rendered, it was routinely expired by the time\n * anyone clicked, and the callback then failed on a sign-in the user had\n * just completed. The window is opened blank first, synchronously, or the\n * popup blocker kills it while we wait for the URL.\n */\n async function openAuthWindow() {\n if (\n !serverName.value ||\n !props.resolveConnection ||\n isSigningIn.value\n ) {\n return\n }\n oauthError.value = null\n const popup = window.open(\n '',\n 'mcp_oauth',\n 'width=600,height=700,menubar=no,toolbar=no',\n )\n if (!popup) {\n oauthError.value = $t('auth.popupBlocked')\n return\n }\n watchForConnection(popup)\n try {\n const connection = await props.resolveConnection(serverName.value)\n mcpServerId.value = connection.mcpServerId\n popup.location.href = connection.authorizeUrl\n } catch (err) {\n stopWatching()\n popup.close()\n oauthError.value =\n err instanceof Error ? err.message : 'Failed to resolve OAuth'\n }\n }\n\n // For the card's whole life, not just between the click and the answer: a\n // card that re-renders while the sign-in window is away used to lose the\n // listener with it, and the completion landed on nobody.\n onMounted(() => window.addEventListener('message', onMessage))\n onUnmounted(() => {\n window.removeEventListener('message', onMessage)\n stopWatching()\n })\n</script>\n\n<template>\n <!-- The same frame and header as the other tool cards: this was the only\n one drawing itself as a tinted box (DESIGN.md). -->\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface text-12\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon name=\"ri:link\" class=\"text-16 shrink-0\" />\n <strong class=\"truncate\">{{ serverName }}</strong>\n </div>\n <div class=\"p-sm\">\n <!-- Connected: just now, or by this card on an earlier visit -->\n <template v-if=\"isDone\">\n <div class=\"flex items-center gap-8\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <strong class=\"font-medium text-word-1\">\n {{\n $t('messagePart.requestOAuthConnectionSuccess', {\n name: serverName,\n })\n }}\n </strong>\n </div>\n </template>\n\n <!-- Signing in: the window is out and we are watching for it -->\n <template v-else-if=\"isSigningIn\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"loading-loop\" />\n <span class=\"text-10\">{{\n $t('messagePart.requestOAuthConnection')\n }}</span>\n </div>\n </template>\n\n <!-- OAuth error -->\n <template v-else-if=\"oauthError\">\n <div class=\"flex flex-col gap-xs\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:close-line\" class=\"text-danger\" />\n <strong class=\"text-10\">\n {{ oauthError }}\n </strong>\n </div>\n <VvButton\n v-if=\"canConnect\"\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </div>\n </template>\n\n <!-- Waiting on the user: show the connect button -->\n <template v-else-if=\"isAwaitingConnection && canConnect\">\n <div class=\"flex items-center gap-6 text-word-3 mb-xs\">\n <span>\n {{\n $t('messagePart.requestOAuthConnectionPrompt', {\n name: serverName,\n })\n }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </template>\n <!-- Fallback for unknown state -->\n <template v-else>\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:link\" />\n <span class=\"text-10\">\n {{\n $t('messagePart.requestOAuthConnectionInfo', {\n name: serverName,\n })\n }}\n </span>\n </div>\n </template>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;A,6BA4BUyB,IAAmB,KASnBC,IAAkB,K;;;;;;;;;;EA/BxB,IAAMI,IAAQC,GAeRC,IAAOH,GAIP,EAAE,GAAGI,MAAOC,EAAQ,EAAE,UAAU,SAAS,CAAC,GAc1CC,IAAWC,QACNN,EAAM,IAMhB,GAEKO,IAAQD,QAAeD,EAAS,MAAM,SAAS,SAAS,GACxDG,IAAaF,QAAeD,EAAS,MAAM,OAAO,UAAU,GAU5DI,IAAcH,QAAe3B,EAAiB0B,EAAS,MAAM,MAAM,CAAC,GAGpEK,IAAsBJ,QAEnBD,EAAS,MAAM,QACV,cAAc,EAC5B,GAEMM,IAAuBL,QACnBC,EAAM,UAAU,qBAAqBE,EAAY,KAC3D,GAEMG,IAAcC,EAAmB,IAAI,GAWrCC,IAAeD,EAAI,EAAK,GAExBE,IAAcF,EAAI,EAAK,GACvBG,IAAaH,EAAmB,IAAI,GAEpCI,IAASX,QACLQ,EAAa,SAASJ,EAAoB,KACpD,GACMQ,IAAaZ,QACT,EAAQE,EAAW,SAAU,EAAQR,EAAM,iBACrD;EAMA,eAAemB,IAAmC;GAC9C,IAAI,CAACX,EAAW,SAAS,CAACR,EAAM,iBAC5B,OAAO;GAEX,IAAI;IACA,IAAMoB,IAAS,MAAMpB,EAAM,gBAAgBQ,EAAW,KAAK;IAE3D,OADA,EAAY,QAAQY,EAAO,aACpBA,EAAO;GAClB,QAAQ;IAGJ,OAAO;GACX;EACJ;EAEA,IAAIC,GAOAC,IAAgB,GAEhBC,IAA8B;EAElC,SAASC,IAAe;GAOpB,AANIH,MAAc,KAAA,MACd,aAAaA,CAAS,GACtB,IAAY,KAAA,IAEhB,KAAiB,GACjB,IAAe,MACf,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AM,EAS8BmE,GAAA;;IAP1B,WAAU;IACV,MAAK;IACJ,OAAoCpE,EAAA4B,CAAA,CAAE,CAAA,4CAAA,EAAqF,MAAAK,EAAA,M;IAK3H,SAAO4B;G,yCAKCzB,EAAA,SAAwBO,EAAA,SAA7ChD,EAAA,GAAAC,EAmBWM,GAAA,EAAA,KAAA,EAAA,GAAA,CAlBPL,EAQM,OARNoB,IAQM,CAPFpB,EAMO,QAAA,MAAAE,EAJCC,EAAA4B,CAAA,CAAE,CAAA,4CAAA,EAAqF,MAAAK,EAAA,M,WAMnGnC,EAQ8BsE,GAAA;IAP1B,WAAU;IACV,MAAK;IACJ,OAAgCpE,EAAA4B,CAAA,CAAE,CAAA,4CAAA,EAAiF,MAAAK,EAAA,M;IAKnH,SAAO4B;G,iCAIZlE,EAAA,GAAAC,EASM,OATNsB,IASM,CARFpB,EAAyBoE,GAAA,EAAjB,MAAK,UAAS,CAAA,GACtBrE,EAMO,QANPsB,GAMOpB,EAJCC,EAAA4B,CAAA,CAAE,CAAA,0CAAA,EAAmF,MAAAK,EAAA,M"}
|
|
1
|
+
{"version":3,"file":"PkToolRequestOAuthConnection-DWkeVLpx.js","names":["_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_createBlock","_Fragment","VvButtonLocalized","isVoiceRenderAck","isMcpOAuthReport","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","POLL_INTERVAL_MS","POLL_TIMEOUT_MS","PkToolRequestOAuthConnection_default","defineComponent","__emit","props","__props","emit","$t","useI18n","toolPart","computed","state","serverName","isRenderAck","isConnectedByOutput","isAwaitingConnection","mcpServerId","ref","hasConnected","isSigningIn","oauthError","isDone","canConnect","isConnectedNow","status","pollTimer","signInAttempt","signInWindow","stopWatching","settleConnected","connectedServerId","watchForConnection","attempt","popup","deadline","tick","connected","onMessage","event","reportedServerId","openAuthWindow","connection","err","onMounted","onUnmounted","_component_VvIcon","VvIcon","_component_VvButton","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","createBlock","createCommentVNode","Fragment"],"sources":["../../../../packages/components/src/chat/PkToolRequestOAuthConnection.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, onMounted, onUnmounted, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n import { isMcpOAuthReport } from './mcpOAuthReport'\n\n const props = defineProps<{\n part: unknown\n /**\n * The backend the chat talks to, where the sign-in's callback page\n * runs. Without it the card hears no report and relies on its poll.\n */\n backendUrl?: string\n resolveConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; authorizeUrl: string }>\n checkConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; connected: boolean }>\n }>()\n\n const emit = defineEmits<{\n connected: [mcpServerId: string]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n /** How often the connection is re-read while the sign-in window is out. */\n const POLL_INTERVAL_MS = 2000\n /**\n * How long we keep asking. The only end to a sign-in nobody finishes:\n * `popup.closed` cannot be that signal, because the browser disowns the\n * handle when the provider severs the opener (that is what\n * `Cross-Origin-Opener-Policy` does), so it reads as closed from the first\n * check of the very flow this watch exists for. Long enough for a password\n * manager and a second factor.\n */\n const POLL_TIMEOUT_MS = 5 * 60 * 1000\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n toolCallId?: string\n input?: { serverName: string }\n output?: unknown\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n const serverName = computed(() => toolPart.value.input?.serverName)\n\n /**\n * A card drawn during a CALL arrives already \"answered\": the turn could\n * not wait for the connection, so the backend closed the tool with a note\n * saying the card was drawn (see `isVoiceRenderAck`, same rule as the\n * forms). That note is not a connection, and without this the card\n * rendered its inert fallback: the caller was told to connect the account\n * and given nothing to click (measured 2026-08-07).\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n /** The output this card wrote itself once the connection went through. */\n const isConnectedByOutput = computed(\n () =>\n (toolPart.value.output as { connected?: unknown } | undefined)\n ?.connected === true,\n )\n\n const isAwaitingConnection = computed(\n () => state.value === 'input-available' || isRenderAck.value,\n )\n\n const mcpServerId = ref<string | null>(null)\n /**\n * Set once THIS card's sign-in went through, and never from a plain read of\n * the connection: a card still asking is the turn saying it could not use\n * that integration, and a token row can outlive its usefulness (a refresh\n * that failed transiently keeps the row, so the turn sees no usable token\n * while a status read still sees one). Trusting the read there would have\n * left the card claiming success, with no button, on a turn still waiting.\n * It doubles as the guard that resumes the turn exactly once, whichever\n * channel got there first.\n */\n const hasConnected = ref(false)\n /** A sign-in window we opened is still out there. */\n const isSigningIn = ref(false)\n const oauthError = ref<string | null>(null)\n\n const isDone = computed(\n () => hasConnected.value || isConnectedByOutput.value,\n )\n const canConnect = computed(\n () => Boolean(serverName.value) && Boolean(props.resolveConnection),\n )\n\n /**\n * Whether the server says this user has connected, asked without minting\n * anything: no OAuth `state` is burned by looking.\n */\n async function isConnectedNow(): Promise<boolean> {\n if (!serverName.value || !props.checkConnection) {\n return false\n }\n try {\n const status = await props.checkConnection(serverName.value)\n mcpServerId.value = status.mcpServerId\n return status.connected\n } catch {\n // Not knowing is not an error to show: the sign-in window is still\n // out there and the next read may well answer.\n return false\n }\n }\n\n let pollTimer: ReturnType<typeof setTimeout> | undefined\n /**\n * Which sign-in a running tick belongs to. A tick suspended on its read\n * outlives the attempt that scheduled it: without this it woke up inside\n * the NEXT attempt, restarted its own chain over that one's timer and then\n * stopped it on its own older deadline.\n */\n let signInAttempt = 0\n /** The window this attempt opened, the only sender we accept a report from. */\n let signInWindow: Window | null = null\n\n function stopWatching() {\n if (pollTimer !== undefined) {\n clearTimeout(pollTimer)\n pollTimer = undefined\n }\n signInAttempt += 1\n signInWindow = null\n isSigningIn.value = false\n }\n\n function settleConnected(connectedServerId: string) {\n stopWatching()\n if (hasConnected.value) {\n return\n }\n hasConnected.value = true\n mcpServerId.value = connectedServerId\n oauthError.value = null\n emit('connected', connectedServerId)\n }\n\n /**\n * Watches the connection from THIS window while the sign-in window is away.\n *\n * The callback page reports through `window.opener`, and a provider that\n * sends `Cross-Origin-Opener-Policy` anywhere in its redirect chain takes\n * that opener away: the connection then succeeds with nobody listening, the\n * card stays on its button and the suspended turn is never resumed\n * (reported 2026-08-27). This channel never goes through that window, so it\n * survives whatever the provider does to it. Chained rather than periodic:\n * a read slower than the interval would otherwise overlap the next one.\n */\n function watchForConnection(popup: Window) {\n stopWatching()\n const attempt = signInAttempt\n signInWindow = popup\n isSigningIn.value = true\n const deadline = Date.now() + POLL_TIMEOUT_MS\n const tick = async () => {\n if (attempt !== signInAttempt || Date.now() > deadline) {\n if (attempt === signInAttempt) {\n stopWatching()\n }\n return\n }\n const connected = await isConnectedNow()\n if (attempt !== signInAttempt) {\n return\n }\n if (connected && mcpServerId.value) {\n settleConnected(mcpServerId.value)\n return\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n\n /**\n * The callback page's own report, when the browser let it through: faster\n * than the poll, and the only channel carrying the failure reason.\n *\n * Accepted only as {@link isMcpOAuthReport} says, and only while that\n * sign-in is out: the listener stays up for as long as the card is on\n * screen, and nothing else with a handle on this page may resume a turn by\n * posting a message at it.\n */\n function onMessage(event: MessageEvent) {\n if (\n !isSigningIn.value ||\n !isMcpOAuthReport(event, signInWindow, props.backendUrl)\n ) {\n return\n }\n const reportedServerId = event.data.mcpServerId as string | undefined\n if (\n reportedServerId &&\n mcpServerId.value &&\n reportedServerId !== mcpServerId.value\n ) {\n return\n }\n if (!event.data.success) {\n // A failure carries no server id: the callback never got that far.\n stopWatching()\n oauthError.value = event.data.error ?? 'Unknown error'\n return\n }\n const connectedServerId = reportedServerId ?? mcpServerId.value\n if (connectedServerId) {\n settleConnected(connectedServerId)\n }\n }\n\n /**\n * Opens the provider's sign-in, on an authorize URL minted NOW.\n *\n * The URL carries an OAuth `state` that lives ten minutes server-side.\n * Minted when the card rendered, it was routinely expired by the time\n * anyone clicked, and the callback then failed on a sign-in the user had\n * just completed. The window is opened blank first, synchronously, or the\n * popup blocker kills it while we wait for the URL.\n */\n async function openAuthWindow() {\n if (\n !serverName.value ||\n !props.resolveConnection ||\n isSigningIn.value\n ) {\n return\n }\n oauthError.value = null\n const popup = window.open(\n '',\n 'mcp_oauth',\n 'width=600,height=700,menubar=no,toolbar=no',\n )\n if (!popup) {\n oauthError.value = $t('auth.popupBlocked')\n return\n }\n watchForConnection(popup)\n try {\n const connection = await props.resolveConnection(serverName.value)\n mcpServerId.value = connection.mcpServerId\n popup.location.href = connection.authorizeUrl\n } catch (err) {\n stopWatching()\n popup.close()\n oauthError.value =\n err instanceof Error ? err.message : 'Failed to resolve OAuth'\n }\n }\n\n // For the card's whole life, not just between the click and the answer: a\n // card that re-renders while the sign-in window is away used to lose the\n // listener with it, and the completion landed on nobody.\n onMounted(() => window.addEventListener('message', onMessage))\n onUnmounted(() => {\n window.removeEventListener('message', onMessage)\n stopWatching()\n })\n</script>\n\n<template>\n <!-- The same frame and header as the other tool cards: this was the only\n one drawing itself as a tinted box (DESIGN.md). -->\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface text-12\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon name=\"ri:link\" class=\"text-16 shrink-0\" />\n <strong class=\"truncate\">{{ serverName }}</strong>\n </div>\n <div class=\"p-sm\">\n <!-- Connected: just now, or by this card on an earlier visit -->\n <template v-if=\"isDone\">\n <div class=\"flex items-center gap-8\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <strong class=\"font-medium text-word-1\">\n {{\n $t('messagePart.requestOAuthConnectionSuccess', {\n name: serverName,\n })\n }}\n </strong>\n </div>\n </template>\n\n <!-- Signing in: the window is out and we are watching for it -->\n <template v-else-if=\"isSigningIn\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"loading-loop\" />\n <span class=\"text-10\">{{\n $t('messagePart.requestOAuthConnection')\n }}</span>\n </div>\n </template>\n\n <!-- OAuth error -->\n <template v-else-if=\"oauthError\">\n <div class=\"flex flex-col gap-xs\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:close-line\" class=\"text-danger\" />\n <strong class=\"text-10\">\n {{ oauthError }}\n </strong>\n </div>\n <VvButton\n v-if=\"canConnect\"\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </div>\n </template>\n\n <!-- Waiting on the user: show the connect button -->\n <template v-else-if=\"isAwaitingConnection && canConnect\">\n <div class=\"flex items-center gap-6 text-word-3 mb-xs\">\n <span>\n {{\n $t('messagePart.requestOAuthConnectionPrompt', {\n name: serverName,\n })\n }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </template>\n <!-- Fallback for unknown state -->\n <template v-else>\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:link\" />\n <span class=\"text-10\">\n {{\n $t('messagePart.requestOAuthConnectionInfo', {\n name: serverName,\n })\n }}\n </span>\n </div>\n </template>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;A,6BA4BUyB,IAAmB,KASnBC,IAAkB,K;;;;;;;;;;EA/BxB,IAAMI,IAAQC,GAeRC,IAAOH,GAIP,EAAE,GAAGI,MAAOC,EAAQ,EAAE,UAAU,SAAS,CAAC,GAc1CC,IAAWC,QACNN,EAAM,IAMhB,GAEKO,IAAQD,QAAeD,EAAS,MAAM,SAAS,SAAS,GACxDG,IAAaF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AAE,CAAA,4CAAA,EAAiF,MAAAK,EAAA,M;IAKnH,SAAO4B;G,iCAIZlE,EAAA,GAAAC,EASM,OATNsB,IASM,CARFpB,EAAyBoE,GAAA,EAAjB,MAAK,UAAS,CAAA,GACtBrE,EAMO,QANPsB,GAMOpB,EAJCC,EAAA4B,CAAA,CAAE,CAAA,0CAAA,EAAmF,MAAAK,EAAA,M"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-CGnMp29N.js";
|
|
2
2
|
import { t } from "./VvButtonLocalized-C-vx25u4.js";
|
|
3
|
-
import { t as n } from "./PkStreamingMarkdown-
|
|
3
|
+
import { t as n } from "./PkStreamingMarkdown-BcUq4ThC.js";
|
|
4
4
|
import { computed as r, createBlock as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, normalizeClass as u, openBlock as d, ref as f, toDisplayString as p, unref as m, watch as h } from "vue";
|
|
5
5
|
import { useClipboard as g } from "@vueuse/core";
|
|
6
6
|
// ../../packages/components/src/chat/PkCode.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -88,4 +88,4 @@ var _ = ["innerHTML"], v = /* @__PURE__ */ l({
|
|
|
88
88
|
}), T = /* @__PURE__ */ e({ default: () => E }), E = w;
|
|
89
89
|
export { T as n, v as r, E as t };
|
|
90
90
|
|
|
91
|
-
//# sourceMappingURL=PkToolShowArtifact-
|
|
91
|
+
//# sourceMappingURL=PkToolShowArtifact-C4gHB6lH.js.map
|
package/dist-vue/_chunks/{PkToolShowArtifact-rlZ-AGWh.js.map → PkToolShowArtifact-C4gHB6lH.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowArtifact-
|
|
1
|
+
{"version":3,"file":"PkToolShowArtifact-C4gHB6lH.js","names":["$attrs","_openBlock","_createElementBlock","_normalizeClass","_createTextVNode","_createElementVNode","$t","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","_unref","_createBlock","PkCode","PkStreamingMarkdown","_normalizeClass","__exportAll","PkStreamingMarkdown_default","_hoisted_1$1","PkCode_default","defineComponent","props","__props","highlightedHtml","ref","hasCode","computed","highlight","hljs","result","watch","openBlock","createElementBlock","normalizeClass","_ctx","_cache","createTextVNode","createElementVNode","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","PkToolShowArtifact_vue_vue_type_script_setup_true_lang_default","useClipboard","toolPart","artifactTypeLabel","languageLabel","isCodeType","isMarkdownType","codeLanguage","_component_VvButton","VvButtonLocalized","toDisplayString","createVNode","unref","copied","copy","createBlock","PkToolShowArtifact_exports","PkToolShowArtifact_default"],"sources":["../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkToolShowArtifact.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref, watch } from 'vue'\n\n defineOptions({\n inheritAttrs: false,\n })\n\n const props = defineProps<{\n code: unknown\n language: string\n line?: boolean\n }>()\n\n const highlightedHtml = ref('')\n\n const hasCode = computed(() => {\n if (typeof props.code === 'string') {\n return props.code\n }\n return JSON.stringify(props.code, null, 2)\n })\n\n async function highlight() {\n const hljs = (await import('highlight.js/lib/common')).default\n try {\n const result = props.language\n ? hljs.highlight(hasCode.value, { language: props.language })\n : hljs.highlightAuto(hasCode.value)\n highlightedHtml.value = result.value\n } catch {\n highlightedHtml.value = hasCode.value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n }\n }\n\n watch(hasCode, highlight, { immediate: true })\n</script>\n\n<template>\n <pre\n :class=\"\n $attrs.class\n ? $attrs.class\n : 'font-mono leading-snug text-smaller bg-surface-1'\n \">\n <code :class=\"['hljs', line ? 'whitespace-pre-line' : 'whitespace-pre', language]\" v-html=\"highlightedHtml\"></code>\n </pre>\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import PkCode from './PkCode.vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { copy, copied } = useClipboard()\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title: string\n content: string\n artifactType: string\n language?: string\n }\n }\n return part\n })\n\n const artifactTypeLabel = computed(() => {\n const labels: Record<string, string> = {\n code: 'Code',\n document: 'Document',\n markdown: 'Markdown',\n json: 'JSON',\n xml: 'XML',\n csv: 'CSV',\n html: 'HTML',\n yaml: 'YAML',\n sql: 'SQL',\n text: 'Text',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'Artifact'\n }\n return labels[toolPart.value.input.artifactType] || 'Artifact'\n })\n\n const languageLabel = computed(() => {\n if (!toolPart.value.input?.language) {\n return ''\n }\n return ` (${toolPart.value.input.language})`\n })\n\n const isCodeType = computed(() => {\n return (\n toolPart.value.input?.artifactType === 'code' ||\n toolPart.value.input?.artifactType === 'json' ||\n toolPart.value.input?.artifactType === 'xml' ||\n toolPart.value.input?.artifactType === 'yaml' ||\n toolPart.value.input?.artifactType === 'html' ||\n toolPart.value.input?.artifactType === 'sql'\n )\n })\n\n const isMarkdownType = computed(() => {\n return toolPart.value.input?.artifactType === 'markdown'\n })\n\n const codeLanguage = computed(() => {\n if (toolPart.value.input?.language) {\n return toolPart.value.input.language\n }\n // Map artifact types to highlight.js languages\n const languageMap: Record<string, string> = {\n json: 'json',\n xml: 'xml',\n yaml: 'yaml',\n html: 'html',\n sql: 'sql',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'plaintext'\n }\n return languageMap[toolPart.value.input.artifactType] || 'plaintext'\n })\n</script>\n\n<template>\n <div class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center\">\n <div class=\"flex flex-col items-start gap-4\">\n <span>{{ toolPart?.input?.title }}</span>\n <span class=\"text-10 opacity-60 font-normal\">\n {{ artifactTypeLabel }}{{ languageLabel }}\n </span>\n </div>\n <VvButton\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n modifiers=\"action-quiet-small\"\n :title=\"$t('action.copy')\"\n class=\"shrink-0\"\n @click=\"copy(toolPart?.input?.content || '')\" />\n </div>\n <div class=\"px-sm py-10 bg-surface\">\n <PkCode\n v-if=\"isCodeType\"\n :code=\"toolPart?.input?.content\"\n :language=\"codeLanguage\" />\n <PkStreamingMarkdown\n v-else-if=\"isMarkdownType\"\n :markdown=\"toolPart?.input?.content\"\n class=\"wysiwyg text-word-2\" />\n <pre\n v-else\n class=\"text-word-2 whitespace-pre-wrap break-words\"\n :class=\"{\n italic:\n toolPart?.input?.artifactType === 'document' ||\n toolPart?.input?.artifactType === 'text',\n }\"\n >{{ toolPart?.input?.content }}</pre>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;EAOI,IAAMsB,IAAQC,GAMRC,IAAkBC,EAAI,EAAE,GAExBC,IAAUC,QACR,OAAOL,EAAM,QAAS,WACfA,EAAM,OAEV,KAAK,UAAUA,EAAM,MAAM,MAAM,CAAC,CAC5C;EAED,eAAeM,IAAY;GACvB,IAAMC,KAAQ,MAAM,OAAO,2BAAA,CAA4B;GACvD,IAAI;IACA,IAAMC,IAASR,EAAM,WACfO,EAAK,UAAUH,EAAQ,OAAO,EAAE,UAAUJ,EAAM,SAAS,CAAC,IAC1DO,EAAK,cAAcH,EAAQ,KAAK;IACtC,EAAgB,QAAQI,EAAO;GACnC,QAAQ;IACJ,EAAgB,QAAQJ,EAAQ,MAC3B,QAAQ,MAAM,OAAO,CAAA,CACrB,QAAQ,MAAM,MAAM,CAAA,CACpB,QAAQ,MAAM,MAAM;GAC7B;EACJ;E,OAEAK,EAAML,GAASE,GAAW,EAAE,WAAW,GAAK,CAAC,I,UAI7C3B,EAAA,GAAAC,EAOM,OAAA,EAND,OAAKC,EAAeH,EAAAA,OAAO,QAAwBA,EAAAA,OAAO,Q;GAIzD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AAhCoC,EAAA,OAAU,OAAO,KAAK,GAAA,CAAA,GAC/BrC,EAEO,QAFPiC,GAEOhC,EADAqC,EAAA,KAAiB,IAAArC,EAAMsC,EAAA,KAAa,GAAA,CAAA,C,IAG/CrC,EAMoDyC,GAAA;IAL/C,MAAMxC,EAAA6C,CAAA,IAAM,kBAAA;IACZ,OAAO7C,EAAA6C,CAAA,IAASnD,EAAAA,GAAE,eAAA,IAAoBA,EAAAA,GAAE,aAAA;IACzC,WAAU;IACT,OAAOA,EAAAA,GAAE,aAAA;IACV,OAAM;IACL,SAAK,AAAA8B,EAAA,QAAA,MAAExB,EAAA8C,CAAA,CAAI,CAACZ,EAAA,OAAU,OAAO,WAAO,EAAA;;;;;G,MAE7CrC,EAkBM,OAlBNkC,GAkBM,CAhBQM,EAAA,SADV1C,EAAA,GAAAM,EAG+BC,GAAA;;IAD1B,MAAMgC,EAAA,OAAU,OAAO;IACvB,UAAUK,EAAA;G,qCAEAD,EAAA,SADf3C,EAAA,GAAAM,EAGkCE,GAAA;;IAD7B,UAAU+B,EAAA,OAAU,OAAO;IAC5B,OAAM;G,8BACVvC,EAAA,GAAAC,EAQyC,OAAA;;IANrC,OAAKQ,EAAA,CAAC,+CAA6C,E,QACW8B,EAAA,OAAU,OAAO,iBAAY,cAA2CA,EAAA,OAAU,OAAO,iBAAY,O;GAK/J,GAAApC,EAAAoC,EAAA,OAAU,OAAO,OAAO,GAAA,CAAA,E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tt as e } from "./utils-
|
|
1
|
+
import { tt as e } from "./utils-waie4Gfn.js";
|
|
2
2
|
import { n as t } from "./Chart-BTPNjfNS.js";
|
|
3
3
|
import { t as n } from "./VvButtonLocalized-C-vx25u4.js";
|
|
4
4
|
import "./src-nb8MU1sh.js";
|
|
@@ -130,4 +130,4 @@ var T = { class: "pk-chart-card border border-surface-3 rounded-xl w-full overfl
|
|
|
130
130
|
});
|
|
131
131
|
export { R as default };
|
|
132
132
|
|
|
133
|
-
//# sourceMappingURL=PkToolShowChart-
|
|
133
|
+
//# sourceMappingURL=PkToolShowChart-CsPXNAb9.js.map
|
package/dist-vue/_chunks/{PkToolShowChart-B8xJi1yY.js.map → PkToolShowChart-CsPXNAb9.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowChart-B8xJi1yY.js","names":["_hoisted_1","_hoisted_2","_hoisted_3","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_withCtx","_createBlock","_Fragment","_renderList","$t","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","PkChartCard","_createVNode","_toDisplayString","toSnakeCase","ShowChartInputSchema","VvButtonLocalized","chartValueFormatter","chartAsTsv","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","PkChartCard_default","defineComponent","PkChart","defineAsyncComponent","props","__props","$t","useI18n","useClipboard","icon","computed","showTable","ref","format","locale","chartRef","useTemplateRef","downloadPng","blob","url","anchor","_component_VvIcon","VvIcon","_component_VvButton","_component_VvButtonGroup","VvButtonGroup","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","withCtx","_cache","copied","copy","createCommentVNode","createBlock","Fragment","renderList","series","i","category","_hoisted_1","_hoisted_2","_hoisted_3","PkToolShowChart_default","toolPart","streaming","refused","input","parsed","_ctx"],"sources":["../../../../packages/components/src/chat/PkChartCard.vue","../../../../packages/components/src/chat/PkToolShowChart.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, defineAsyncComponent, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import type { Chart } from 'models'\n import { toSnakeCase } from 'utils'\n import { chartAsTsv, chartValueFormatter } from './chartFormat'\n\n // Chart.js comes with it: a separate chunk, loaded with the first chart\n const PkChart = defineAsyncComponent(() => import('./PkChart.vue'))\n\n /**\n * One chart of `showChart` (spec `chat-charts.md`) in its card: the chart,\n * the same numbers as a table, \"Copy data\" for a sheet and the chart as a\n * PNG.\n */\n const props = defineProps<{\n chart: Chart\n /** A note below the chart, e.g. the source of the numbers. */\n caption?: string\n isDark?: boolean\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const icon = computed(() => {\n switch (props.chart.type) {\n case 'line':\n return 'ri:line-chart-line'\n case 'pie':\n return 'ri:pie-chart-line'\n case 'doughnut':\n return 'ri:donut-chart-line'\n default:\n return props.chart.horizontal\n ? 'ri:bar-chart-horizontal-line'\n : 'ri:bar-chart-2-line'\n }\n })\n\n const showTable = ref(false)\n const format = computed(() =>\n chartValueFormatter(locale.value, props.chart.format),\n )\n\n const chartRef = useTemplateRef<{ toBlob: () => Promise<Blob | null> }>(\n 'chartRef',\n )\n const downloadPng = async () => {\n const blob = await chartRef.value?.toBlob()\n if (!blob) {\n return\n }\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(props.chart.title || 'chart')}.png`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n</script>\n\n<template>\n <div\n class=\"pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"icon\" class=\"text-16 shrink-0\" />\n <strong class=\"font-bold truncate\">\n {{ chart.title || $t('label.chart') }}\n </strong>\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"pk-chart-card__actions ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"showTable ? icon : 'ri:table-line'\"\n :label=\"\n showTable\n ? $t('chart.showChart')\n : $t('chart.showTable')\n \"\n @click=\"showTable = !showTable\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('chart.copyData')\"\n @click=\"copy(chartAsTsv(chart, locale))\" />\n <VvButton\n v-if=\"!showTable\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n :title=\"$t('chart.downloadPng')\"\n @click=\"downloadPng\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"showTable\" class=\"pk-chart-card__table-wrap\">\n <table class=\"pk-chart-card__table text-12\">\n <thead>\n <tr>\n <th scope=\"col\">{{ chart.categoryLabel ?? '' }}</th>\n <th\n v-for=\"series in chart.series\"\n :key=\"series.name\"\n scope=\"col\">\n {{ series.name }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(category, i) in chart.categories\" :key=\"i\">\n <th scope=\"row\">{{ category }}</th>\n <td v-for=\"series in chart.series\" :key=\"series.name\">\n {{ format(series.values[i] ?? null) }}\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <div v-else class=\"pk-chart-card__stage px-sm py-sm\">\n <PkChart ref=\"chartRef\" :chart :is-dark />\n </div>\n <div\n v-if=\"caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart-card {\n // A container for the narrow card below. It is also the containing\n // block of any `position: fixed` inside it, so a menu added here\n // must open in the top layer (docs/agents/gotchas/frontend.md, \"The\n // chat measures its own width\"): today the card has none.\n container-type: inline-size;\n\n // On a narrow card the actions keep their icon and lose the word on\n // screen, still read by a screen reader: the title keeps the room\n // (at 390px it was cut to \"Fattori di ...\")\n @container (width < 30rem) {\n &__actions .vv-button__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n }\n\n // A fixed stage, as the diagram's: the chart loads in a chunk of its\n // own, and loader and chart must take the same room or the chat's\n // scroll jumps\n &__stage {\n height: 320px;\n }\n\n &__table-wrap {\n max-height: 320px;\n overflow: auto;\n }\n\n &__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-6) var(--spacing-sm);\n border-bottom: 1px solid var(--color-surface-3);\n text-align: right;\n white-space: nowrap;\n }\n\n th:first-child {\n text-align: left;\n white-space: normal;\n }\n\n thead th {\n color: var(--color-word-3);\n font-weight: 600;\n }\n\n tbody th {\n color: var(--color-word-2);\n font-weight: 400;\n }\n\n td {\n color: var(--color-word);\n font-variant-numeric: tabular-nums;\n }\n\n tbody tr:last-child > * {\n border-bottom: 0;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { ShowChartInputSchema } from 'models'\n import PkChartCard from './PkChartCard.vue'\n\n /**\n * The cards of `showChart` (spec `chat-charts.md`): every chart of the\n * call in its own card, one under the other, the caption under the last.\n */\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const toolPart = computed(\n () => props.part as { state?: string; input?: unknown },\n )\n // A half-written input has series shorter than the categories\n const streaming = computed(() => toolPart.value.state === 'input-streaming')\n // A call the tool refused for its input: the model reads why and calls\n // again, and the corrected chart follows it. Nothing to show here.\n const refused = computed(() => toolPart.value.state === 'output-error')\n /** The input as the tool validated it; a stored one that is not stays a message. */\n const input = computed(() => {\n if (streaming.value) {\n return undefined\n }\n const parsed = ShowChartInputSchema.safeParse(toolPart.value.input)\n return parsed.success ? parsed.data : undefined\n })\n</script>\n\n<template>\n <div v-if=\"input\" class=\"flex flex-col gap-sm w-full\">\n <PkChartCard\n v-for=\"(chart, i) in input.charts\"\n :key=\"i\"\n :chart\n :caption=\"i === input.charts.length - 1 ? input.caption : undefined\"\n :is-dark />\n </div>\n <div\n v-else-if=\"streaming\"\n class=\"pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center\">\n <VvIcon name=\"loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-else-if=\"!refused\"\n class=\"border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm\">\n {{ $t('message.chartRenderError') }}\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-chart {\n // The height of a card while the call is written: the card that\n // replaces it takes about as much, and the chat's scroll stays put\n &__loading {\n height: 360px;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EASI,IAAMsC,IAAUC,QAA2B,OAAO,wBAAgB,GAO5DC,IAAQC,GAOR,EAAE,GAAGC,GAAI,cAAWC,EAAQ,EAAE,UAAU,SAAS,CAAC,GAClD,EAAE,SAAM,cAAWC,EAAa,GAEhCC,IAAOC,QAAe;GACxB,QAAQN,EAAM,MAAM,MAApB;IACI,KAAK,QACD,OAAO;IACX,KAAK,OACD,OAAO;IACX,KAAK,YACD,OAAO;IACX,SACI,OAAOA,EAAM,MAAM,aACb,iCACA;GACd;EACJ,CAAC,GAEKO,IAAYC,EAAI,EAAK,GACrBC,IAASH,QACXrB,EAAoByB,EAAO,OAAOV,EAAM,MAAM,MAAM,CACxD,GAEMW,IAAWC,EACb,UACJ,GACMC,IAAc,YAAY;GAC5B,IAAMC,IAAO,MAAMH,EAAS,OAAO,OAAO;GAC1C,IAAI,CAACG,GACD;GAEJ,IAAMC,IAAM,IAAI,gBAAgBD,CAAI,GAC9BE,IAAS,SAAS,cAAc,GAAG;GAMzC,AALA,EAAO,OAAOD,GACd,EAAO,WAAW,GAAGjC,EAAYkB,EAAM,MAAM,SAAS,OAAO,EAAE,OAC/D,SAAS,KAAK,YAAYgB,CAAM,GAChCA,EAAO,MAAM,GACb,SAAS,KAAK,YAAYA,CAAM,GAChC,IAAI,gBAAgBD,CAAG;EAC3B;;;GAIA,OAAApD,EAAA,GAAAC,EAiEM,OAjENJ,GAiEM;IA/DFK,EA+BM,OA/BNJ,GA+BM;KA7BFK,EAAgDmD,GAAA;MAAvC,MAAMZ,EAAA;MAAM,OAAM;;KAC3BxC,EAES,UAFTH,GAESK,EADFkC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AAAC,EAJUqE,EAAA,MAAM,SAAnB,GAAO,OADnBxE,EAAA,GAAAI,EAKeC,GAAA;IAHV,KAAK0D;IACL;IACA,SAASA,MAAMS,EAAA,MAAM,OAAO,SAAM,IAAOA,EAAA,MAAM,UAAU,KAAA;IACzD,WAAA7C,EAAA;;;;;G,iBAGM2C,EAAA,SADftE,EAAA,GAAAC,EAIM,OAJNiE,GAIM,CADF5D,EAA4DqC,GAAA;IAApD,MAAK;IAAe,OAAM;G,QAGtB4B,EAAA,Q,aADhBvE,EAAA,GAAAC,EAIM,OAJNkE,GAIM5D,EADCR,EAAAA,GAAE,0BAAA,CAAA,GAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"PkToolShowChart-CsPXNAb9.js","names":["_hoisted_1","_hoisted_2","_hoisted_3","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_withCtx","_createBlock","_Fragment","_renderList","$t","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","PkChartCard","_createVNode","_toDisplayString","toSnakeCase","ShowChartInputSchema","VvButtonLocalized","chartValueFormatter","chartAsTsv","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","PkChartCard_default","defineComponent","PkChart","defineAsyncComponent","props","__props","$t","useI18n","useClipboard","icon","computed","showTable","ref","format","locale","chartRef","useTemplateRef","downloadPng","blob","url","anchor","_component_VvIcon","VvIcon","_component_VvButton","_component_VvButtonGroup","VvButtonGroup","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","withCtx","_cache","copied","copy","createCommentVNode","createBlock","Fragment","renderList","series","i","category","_hoisted_1","_hoisted_2","_hoisted_3","PkToolShowChart_default","toolPart","streaming","refused","input","parsed","_ctx"],"sources":["../../../../packages/components/src/chat/PkChartCard.vue","../../../../packages/components/src/chat/PkToolShowChart.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, defineAsyncComponent, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import type { Chart } from 'models'\n import { toSnakeCase } from 'utils'\n import { chartAsTsv, chartValueFormatter } from './chartFormat'\n\n // Chart.js comes with it: a separate chunk, loaded with the first chart\n const PkChart = defineAsyncComponent(() => import('./PkChart.vue'))\n\n /**\n * One chart of `showChart` (spec `chat-charts.md`) in its card: the chart,\n * the same numbers as a table, \"Copy data\" for a sheet and the chart as a\n * PNG.\n */\n const props = defineProps<{\n chart: Chart\n /** A note below the chart, e.g. the source of the numbers. */\n caption?: string\n isDark?: boolean\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const icon = computed(() => {\n switch (props.chart.type) {\n case 'line':\n return 'ri:line-chart-line'\n case 'pie':\n return 'ri:pie-chart-line'\n case 'doughnut':\n return 'ri:donut-chart-line'\n default:\n return props.chart.horizontal\n ? 'ri:bar-chart-horizontal-line'\n : 'ri:bar-chart-2-line'\n }\n })\n\n const showTable = ref(false)\n const format = computed(() =>\n chartValueFormatter(locale.value, props.chart.format),\n )\n\n const chartRef = useTemplateRef<{ toBlob: () => Promise<Blob | null> }>(\n 'chartRef',\n )\n const downloadPng = async () => {\n const blob = await chartRef.value?.toBlob()\n if (!blob) {\n return\n }\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(props.chart.title || 'chart')}.png`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n</script>\n\n<template>\n <div\n class=\"pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"icon\" class=\"text-16 shrink-0\" />\n <strong class=\"font-bold truncate\">\n {{ chart.title || $t('label.chart') }}\n </strong>\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"pk-chart-card__actions ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"showTable ? icon : 'ri:table-line'\"\n :label=\"\n showTable\n ? $t('chart.showChart')\n : $t('chart.showTable')\n \"\n @click=\"showTable = !showTable\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('chart.copyData')\"\n @click=\"copy(chartAsTsv(chart, locale))\" />\n <VvButton\n v-if=\"!showTable\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n :title=\"$t('chart.downloadPng')\"\n @click=\"downloadPng\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"showTable\" class=\"pk-chart-card__table-wrap\">\n <table class=\"pk-chart-card__table text-12\">\n <thead>\n <tr>\n <th scope=\"col\">{{ chart.categoryLabel ?? '' }}</th>\n <th\n v-for=\"series in chart.series\"\n :key=\"series.name\"\n scope=\"col\">\n {{ series.name }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(category, i) in chart.categories\" :key=\"i\">\n <th scope=\"row\">{{ category }}</th>\n <td v-for=\"series in chart.series\" :key=\"series.name\">\n {{ format(series.values[i] ?? null) }}\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <div v-else class=\"pk-chart-card__stage px-sm py-sm\">\n <PkChart ref=\"chartRef\" :chart :is-dark />\n </div>\n <div\n v-if=\"caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart-card {\n // A container for the narrow card below. It is also the containing\n // block of any `position: fixed` inside it, so a menu added here\n // must open in the top layer (docs/agents/gotchas/frontend.md, \"The\n // chat measures its own width\"): today the card has none.\n container-type: inline-size;\n\n // On a narrow card the actions keep their icon and lose the word on\n // screen, still read by a screen reader: the title keeps the room\n // (at 390px it was cut to \"Fattori di ...\")\n @container (width < 30rem) {\n &__actions .vv-button__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n }\n\n // A fixed stage, as the diagram's: the chart loads in a chunk of its\n // own, and loader and chart must take the same room or the chat's\n // scroll jumps\n &__stage {\n height: 320px;\n }\n\n &__table-wrap {\n max-height: 320px;\n overflow: auto;\n }\n\n &__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-6) var(--spacing-sm);\n border-bottom: 1px solid var(--color-surface-3);\n text-align: right;\n white-space: nowrap;\n }\n\n th:first-child {\n text-align: left;\n white-space: normal;\n }\n\n thead th {\n color: var(--color-word-3);\n font-weight: 600;\n }\n\n tbody th {\n color: var(--color-word-2);\n font-weight: 400;\n }\n\n td {\n color: var(--color-word);\n font-variant-numeric: tabular-nums;\n }\n\n tbody tr:last-child > * {\n border-bottom: 0;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { ShowChartInputSchema } from 'models'\n import PkChartCard from './PkChartCard.vue'\n\n /**\n * The cards of `showChart` (spec `chat-charts.md`): every chart of the\n * call in its own card, one under the other, the caption under the last.\n */\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const toolPart = computed(\n () => props.part as { state?: string; input?: unknown },\n )\n // A half-written input has series shorter than the categories\n const streaming = computed(() => toolPart.value.state === 'input-streaming')\n // A call the tool refused for its input: the model reads why and calls\n // again, and the corrected chart follows it. Nothing to show here.\n const refused = computed(() => toolPart.value.state === 'output-error')\n /** The input as the tool validated it; a stored one that is not stays a message. */\n const input = computed(() => {\n if (streaming.value) {\n return undefined\n }\n const parsed = ShowChartInputSchema.safeParse(toolPart.value.input)\n return parsed.success ? parsed.data : undefined\n })\n</script>\n\n<template>\n <div v-if=\"input\" class=\"flex flex-col gap-sm w-full\">\n <PkChartCard\n v-for=\"(chart, i) in input.charts\"\n :key=\"i\"\n :chart\n :caption=\"i === input.charts.length - 1 ? input.caption : undefined\"\n :is-dark />\n </div>\n <div\n v-else-if=\"streaming\"\n class=\"pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center\">\n <VvIcon name=\"loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-else-if=\"!refused\"\n class=\"border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm\">\n {{ $t('message.chartRenderError') }}\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-chart {\n // The height of a card while the call is written: the card that\n // replaces it takes about as much, and the chat's scroll stays put\n &__loading {\n height: 360px;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EASI,IAAMsC,IAAUC,QAA2B,OAAO,wBAAgB,GAO5DC,IAAQC,GAOR,EAAE,GAAGC,GAAI,cAAWC,EAAQ,EAAE,UAAU,SAAS,CAAC,GAClD,EAAE,SAAM,cAAWC,EAAa,GAEhCC,IAAOC,QAAe;GACxB,QAAQN,EAAM,MAAM,MAApB;IACI,KAAK,QACD,OAAO;IACX,KAAK,OACD,OAAO;IACX,KAAK,YACD,OAAO;IACX,SACI,OAAOA,EAAM,MAAM,aACb,iCACA;GACd;EACJ,CAAC,GAEKO,IAAYC,EAAI,EAAK,GACrBC,IAASH,QACXrB,EAAoByB,EAAO,OAAOV,EAAM,MAAM,MAAM,CACxD,GAEMW,IAAWC,EACb,UACJ,GACMC,IAAc,YAAY;GAC5B,IAAMC,IAAO,MAAMH,EAAS,OAAO,OAAO;GAC1C,IAAI,CAACG,GACD;GAEJ,IAAMC,IAAM,IAAI,gBAAgBD,CAAI,GAC9BE,IAAS,SAAS,cAAc,GAAG;GAMzC,AALA,EAAO,OAAOD,GACd,EAAO,WAAW,GAAGjC,EAAYkB,EAAM,MAAM,SAAS,OAAO,EAAE,OAC/D,SAAS,KAAK,YAAYgB,CAAM,GAChCA,EAAO,MAAM,GACb,SAAS,KAAK,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U,OACV;GAEJ,IAAMG,IAAShE,EAAqB,UAAU4D,EAAS,MAAM,KAAK;GAClE,OAAOI,EAAO,UAAUA,EAAO,OAAO,KAAA;EAC1C,CAAC;;;GAIU,OAAAD,EAAA,SAAXxE,EAAA,GAAAC,EAOM,OAPNgE,GAOM,EANFjE,EAAA,EAAA,GAAAC,EAKeC,GAAA,MAAAC,EAJUqE,EAAA,MAAM,SAAnB,GAAO,OADnBxE,EAAA,GAAAI,EAKeC,GAAA;IAHV,KAAK0D;IACL;IACA,SAASA,MAAMS,EAAA,MAAM,OAAO,SAAM,IAAOA,EAAA,MAAM,UAAU,KAAA;IACzD,WAAA7C,EAAA;;;;;G,iBAGM2C,EAAA,SADftE,EAAA,GAAAC,EAIM,OAJNiE,GAIM,CADF5D,EAA4DqC,GAAA;IAApD,MAAK;IAAe,OAAM;G,QAGtB4B,EAAA,Q,aADhBvE,EAAA,GAAAC,EAIM,OAJNkE,GAIM5D,EADCR,EAAAA,GAAE,0BAAA,CAAA,GAAA,CAAA"}
|
package/dist-vue/_chunks/{PkToolShowContactForm-BVBL7Unx.js → PkToolShowContactForm-2_HBPZaa.js}
RENAMED
|
@@ -5,7 +5,7 @@ import { t as a } from "./index.es-CwEgvvQD.js";
|
|
|
5
5
|
import { t as o } from "./useSafeLocalStorage-Bn4SsL8C.js";
|
|
6
6
|
import { t as s } from "./useLocalizedString-Dmn92nix.js";
|
|
7
7
|
import { t as ee } from "./src-nb8MU1sh.js";
|
|
8
|
-
import { t as c } from "./PkStreamingMarkdown-
|
|
8
|
+
import { t as c } from "./PkStreamingMarkdown-BcUq4ThC.js";
|
|
9
9
|
import { VvAlert as l, VvIcon as u } from "@volverjs/ui-vue/components";
|
|
10
10
|
import { Fragment as d, Transition as f, computed as p, createBlock as m, createCommentVNode as h, createElementBlock as g, createElementVNode as _, createTextVNode as v, createVNode as y, defineComponent as b, isRef as x, openBlock as S, renderList as C, toDisplayString as w, unref as T, watch as E, withCtx as D } from "vue";
|
|
11
11
|
import { useI18n as O } from "vue-i18n";
|
|
@@ -156,4 +156,4 @@ var k = { class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-s
|
|
|
156
156
|
}), W = /* @__PURE__ */ e({ default: () => G }), G = U;
|
|
157
157
|
export { W as n, G as t };
|
|
158
158
|
|
|
159
|
-
//# sourceMappingURL=PkToolShowContactForm-
|
|
159
|
+
//# sourceMappingURL=PkToolShowContactForm-2_HBPZaa.js.map
|