@8wave/ai-elements 0.124.0-beta.9 → 0.124.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{PkFilePreview-D_piCsAW.js → PkFilePreview-BwHe4-m1.js} +368 -346
- package/dist/_chunks/PkFilePreview-BwHe4-m1.js.map +1 -0
- package/dist/_chunks/{PkFilePreviewDialog-Bq0ipzrJ.js → PkFilePreviewDialog-LWxNgkzk.js} +2 -2
- package/dist/_chunks/{PkFilePreviewDialog-Bq0ipzrJ.js.map → PkFilePreviewDialog-LWxNgkzk.js.map} +1 -1
- package/dist/_chunks/{PkStreamingMarkdown-CHwrLP75.js → PkStreamingMarkdown-BvgO6aHe.js} +2 -2
- package/dist/_chunks/{PkStreamingMarkdown-CHwrLP75.js.map → PkStreamingMarkdown-BvgO6aHe.js.map} +1 -1
- package/dist/_chunks/{PkToolChatFile-DO4zjMJr.js → PkToolChatFile-OuaeZTxw.js} +62 -54
- package/dist/_chunks/PkToolChatFile-OuaeZTxw.js.map +1 -0
- package/dist/_chunks/{PkToolShowArtifact-B2-3-k2F.js → PkToolShowArtifact-BqgW3E6D.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-B2-3-k2F.js.map → PkToolShowArtifact-BqgW3E6D.js.map} +1 -1
- package/dist/_chunks/{PkToolShowContactForm-DbOZHB_G.js → PkToolShowContactForm-DDDXopZp.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-DbOZHB_G.js.map → PkToolShowContactForm-DDDXopZp.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-o2LuWDNq.js → PkToolShowForm-D2LZ8Kkl.js} +3 -3
- package/dist/_chunks/{PkToolShowForm-o2LuWDNq.js.map → PkToolShowForm-D2LZ8Kkl.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-CUNneZCp.js → PkToolShowSources-DA4SOt-H.js} +2 -2
- package/dist/_chunks/{PkToolShowSources-CUNneZCp.js.map → PkToolShowSources-DA4SOt-H.js.map} +1 -1
- package/dist/_chunks/excelNumberFormat-CIbRUEwQ.js +543 -0
- package/dist/_chunks/excelNumberFormat-CIbRUEwQ.js.map +1 -0
- package/dist/_chunks/{utils-BHvRrCzW.js → utils-euH8esYP.js} +7 -6
- package/dist/_chunks/utils-euH8esYP.js.map +1 -0
- package/dist/ai-elements.es.js +8 -8
- 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/_chunks/{PkChatbot-DQssgXm3.js → PkChatbot-BRttF7Lo.js} +5 -5
- package/dist-vue/_chunks/{PkChatbot-DQssgXm3.js.map → PkChatbot-BRttF7Lo.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotEmptyState-B6qxJAPT.js → PkChatbotEmptyState-CLOH5Z2d.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-B6qxJAPT.js.map → PkChatbotEmptyState-CLOH5Z2d.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotInput-Bk8OS1xU.js → PkChatbotInput-BK7f1jFE.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotInput-Bk8OS1xU.js.map → PkChatbotInput-BK7f1jFE.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotMessages-D4LJZxv7.js → PkChatbotMessages-Ck0ofhtK.js} +14 -14
- package/dist-vue/_chunks/{PkChatbotMessages-D4LJZxv7.js.map → PkChatbotMessages-Ck0ofhtK.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepPayload-_0WRbSR6.js → PkChatbotStepPayload-D682n3VR.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-_0WRbSR6.js.map → PkChatbotStepPayload-D682n3VR.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-DiaervF2.js → PkChatbotStepToolDetail-D5c8rqj9.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-DiaervF2.js.map → PkChatbotStepToolDetail-D5c8rqj9.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotSteps-BqL-ClgI.js → PkChatbotSteps-CtKRHqaG.js} +5 -5
- package/dist-vue/_chunks/{PkChatbotSteps-BqL-ClgI.js.map → PkChatbotSteps-CtKRHqaG.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-BfVLCU_j.js → PkChatbotViewChat-D8depeWQ.js} +6 -6
- package/dist-vue/_chunks/{PkChatbotViewChat-BfVLCU_j.js.map → PkChatbotViewChat-D8depeWQ.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewConversations-C32O6SsT.js → PkChatbotViewConversations-B-dmLi-8.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewConversations-C32O6SsT.js.map → PkChatbotViewConversations-B-dmLi-8.js.map} +1 -1
- package/dist-vue/_chunks/PkFilePreview-B54Dp_Rs.js +1149 -0
- package/dist-vue/_chunks/PkFilePreview-B54Dp_Rs.js.map +1 -0
- package/dist-vue/_chunks/{PkFilePreviewDialog-BSvgiM9A.js → PkFilePreviewDialog-QDPoZh1v.js} +2 -2
- package/dist-vue/_chunks/{PkFilePreviewDialog-BSvgiM9A.js.map → PkFilePreviewDialog-QDPoZh1v.js.map} +1 -1
- package/dist-vue/_chunks/{PkStreamingMarkdown-Dk3iXhTm.js → PkStreamingMarkdown-qnKwvrCg.js} +2 -2
- package/dist-vue/_chunks/{PkStreamingMarkdown-Dk3iXhTm.js.map → PkStreamingMarkdown-qnKwvrCg.js.map} +1 -1
- package/dist-vue/_chunks/PkToolChatFile-i0rHgFxB.js +227 -0
- package/dist-vue/_chunks/PkToolChatFile-i0rHgFxB.js.map +1 -0
- package/dist-vue/_chunks/{PkToolShowArtifact-BtCGilTJ.js → PkToolShowArtifact-Dh4ogn6A.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-BtCGilTJ.js.map → PkToolShowArtifact-Dh4ogn6A.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowContactForm-BZNIeJpf.js → PkToolShowContactForm-BGTI1sio.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-BZNIeJpf.js.map → PkToolShowContactForm-BGTI1sio.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-KD4MfVkP.js → PkToolShowDiagram-xef3wJb0.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-KD4MfVkP.js.map → PkToolShowDiagram-xef3wJb0.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-Dtfpi58S.js → PkToolShowForm-Crg4Kl6v.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowForm-Dtfpi58S.js.map → PkToolShowForm-Crg4Kl6v.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowImageGallery-DnS04nTs.js → PkToolShowImageGallery-D9hdGBHK.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowImageGallery-DnS04nTs.js.map → PkToolShowImageGallery-D9hdGBHK.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-BlFKAtqQ.js → PkToolShowProductList-SC5aKDCw.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-BlFKAtqQ.js.map → PkToolShowProductList-SC5aKDCw.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-DM177ZlR.js → PkToolShowSources-Bf9_JwFL.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSources-DM177ZlR.js.map → PkToolShowSources-Bf9_JwFL.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowVideo-DQdVpaWT.js → PkToolShowVideo-C2ITZDNo.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowVideo-DQdVpaWT.js.map → PkToolShowVideo-C2ITZDNo.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-Cx2Ft_wN.js → PkToolShowWebPages-BrefGxKQ.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-Cx2Ft_wN.js.map → PkToolShowWebPages-BrefGxKQ.js.map} +1 -1
- package/dist-vue/_chunks/excelNumberFormat-COn5tHoH.js +543 -0
- package/dist-vue/_chunks/excelNumberFormat-COn5tHoH.js.map +1 -0
- package/dist-vue/_chunks/{utils-BuxgMuKv.js → utils-B0PnU1Rk.js} +7 -6
- package/dist-vue/_chunks/utils-B0PnU1Rk.js.map +1 -0
- package/dist-vue/composables.js +1 -1
- package/dist-vue/index.js +21 -21
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/packages/components/src/chat/excelNumberFormat.d.ts +34 -0
- package/dist-vue/packages/components/src/chat/useChatFilePreview.d.ts +20 -0
- package/dist-vue/packages/components/src/chat/utils.d.ts +2 -0
- package/dist-vue/packages/models/src/schema/SpreadsheetPreview.d.ts +26 -0
- package/dist-vue/packages/models/src/schema/WordPreview.d.ts +11 -0
- package/package.json +1 -1
- package/dist/_chunks/PkFilePreview-D_piCsAW.js.map +0 -1
- package/dist/_chunks/PkToolChatFile-DO4zjMJr.js.map +0 -1
- package/dist/_chunks/utils-BHvRrCzW.js.map +0 -1
- package/dist-vue/_chunks/PkFilePreview-jeqvHDm7.js +0 -1127
- package/dist-vue/_chunks/PkFilePreview-jeqvHDm7.js.map +0 -1
- package/dist-vue/_chunks/PkToolChatFile-Bnj-YFLh.js +0 -219
- package/dist-vue/_chunks/PkToolChatFile-Bnj-YFLh.js.map +0 -1
- package/dist-vue/_chunks/utils-BuxgMuKv.js.map +0 -1
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
import { S as e, Tt as t, V as n, f as r, g as i, gt as a, h as o, k as s, kt as c, ot as l, v as u, w as d, wt as f, x as p, y as m, z as h } from "./vue.runtime.esm-bundler-C2U5uTqB.js";
|
|
2
|
-
import { r as
|
|
3
|
-
import { f as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import { t as
|
|
2
|
+
import { r as ee } from "./vue-i18n-POtLvOl1.js";
|
|
3
|
+
import { f as te, v as g } from "./Agent-BBWFD4nI.js";
|
|
4
|
+
import { i as _, r as v, t as ne } from "./excelNumberFormat-CIbRUEwQ.js";
|
|
5
|
+
import { c as y } from "./utils-euH8esYP.js";
|
|
6
|
+
import { t as re } from "./index.es-C7ON2BA3.js";
|
|
7
|
+
import { t as b } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
|
|
8
|
+
import { t as ie } from "./PkChatbotFilePreview-DuvRnOes.js";
|
|
8
9
|
// ../../packages/components/src/chat/PkToolChatFile.vue?vue&type=script&setup=true&lang.ts
|
|
9
10
|
s(), t(), l();
|
|
10
|
-
var
|
|
11
|
+
var ae = {
|
|
11
12
|
key: 0,
|
|
12
13
|
class: "pk-tool-chat-file"
|
|
13
|
-
},
|
|
14
|
+
}, x = {
|
|
14
15
|
key: 0,
|
|
15
16
|
class: "pk-tool-chat-file__changes mt-xs"
|
|
16
|
-
},
|
|
17
|
+
}, S = { class: "pk-tool-chat-file__summary" }, C = {
|
|
17
18
|
key: 0,
|
|
18
19
|
class: "pk-tool-chat-file__scroll"
|
|
19
|
-
},
|
|
20
|
+
}, w = {
|
|
20
21
|
key: 0,
|
|
21
22
|
class: "pk-tool-chat-file__table"
|
|
22
|
-
},
|
|
23
|
+
}, T = {
|
|
23
24
|
scope: "col",
|
|
24
25
|
class: "pk-tool-chat-file__cell"
|
|
25
|
-
},
|
|
26
|
+
}, E = { scope: "col" }, D = { scope: "col" }, O = {
|
|
26
27
|
colspan: "3",
|
|
27
28
|
scope: "rowgroup",
|
|
28
29
|
class: "pk-tool-chat-file__sheet"
|
|
29
|
-
},
|
|
30
|
+
}, k = {
|
|
30
31
|
key: 0,
|
|
31
32
|
colspan: "3",
|
|
32
33
|
class: "pk-tool-chat-file__after"
|
|
33
|
-
},
|
|
34
|
+
}, A = { class: "pk-tool-chat-file__cell" }, j = { class: "pk-tool-chat-file__before" }, M = { class: "pk-tool-chat-file__after" }, N = {
|
|
34
35
|
key: 1,
|
|
35
36
|
class: "pk-tool-chat-file__paragraphs"
|
|
36
|
-
},
|
|
37
|
+
}, P = { class: "pk-tool-chat-file__what" }, F = { class: "pk-tool-chat-file__text" }, I = {
|
|
37
38
|
key: 0,
|
|
38
39
|
class: "pk-tool-chat-file__removed"
|
|
39
|
-
},
|
|
40
|
+
}, oe = {
|
|
40
41
|
key: 1,
|
|
41
42
|
class: "pk-tool-chat-file__added"
|
|
42
|
-
},
|
|
43
|
+
}, L = { key: 2 }, R = {
|
|
43
44
|
key: 2,
|
|
44
45
|
class: "pk-tool-chat-file__note"
|
|
45
|
-
},
|
|
46
|
+
}, z = ["aria-expanded"], B = {
|
|
46
47
|
key: 1,
|
|
47
48
|
class: "text-12 text-word-3 mt-xs mb-0"
|
|
48
|
-
},
|
|
49
|
+
}, V = 3, H = /*#__PURE__*/ b(/* @__PURE__ */ d({
|
|
49
50
|
__name: "PkToolChatFile",
|
|
50
51
|
props: {
|
|
51
52
|
part: { type: null },
|
|
@@ -55,7 +56,7 @@ var ee = {
|
|
|
55
56
|
restore: { type: Function }
|
|
56
57
|
},
|
|
57
58
|
setup(t) {
|
|
58
|
-
let s = /* @__PURE__ */ new Set(["tool-editWordDocument", "tool-createWordDocument"]), l = t, { t: d } =
|
|
59
|
+
let s = /* @__PURE__ */ new Set(["tool-editWordDocument", "tool-createWordDocument"]), l = t, { t: d, locale: b } = ee({ useScope: "global" }), H = a(!1), U = (e) => e?.replace(/… \(\d+ characters\)$/, "…"), W = (e, t, n) => {
|
|
59
60
|
let r = e.split(/(\s+)/).filter(Boolean);
|
|
60
61
|
return r.length <= (t && n ? 24 : 12) ? e : t && n ? `${r.slice(0, 12).join("")}… ${r.slice(-12).join("")}` : n ? `…${r.slice(-12).join("")}` : `${r.slice(0, 12).join("")}…`;
|
|
61
62
|
}, G = (e, t) => {
|
|
@@ -95,7 +96,7 @@ var ee = {
|
|
|
95
96
|
kind: "same"
|
|
96
97
|
}]
|
|
97
98
|
};
|
|
98
|
-
},
|
|
99
|
+
}, se = (e) => {
|
|
99
100
|
let t = e.cell ?? "", n = e.before ? void 0 : /^new sheet, (\d+) row\(s\)$/.exec(e.after ?? "")?.[1], r = e.newSheetRows ?? (n ? Number(n) : void 0);
|
|
100
101
|
if (r !== void 0) return {
|
|
101
102
|
sheet: t,
|
|
@@ -105,9 +106,16 @@ var ee = {
|
|
|
105
106
|
return {
|
|
106
107
|
sheet: t.slice(0, Math.max(i, 0)),
|
|
107
108
|
cell: o && o[1] === o[2] ? d("messagePart.chatFileRow", { row: o[1] }) : a,
|
|
108
|
-
before: U(e.before)
|
|
109
|
-
after: U(e.after)
|
|
109
|
+
before: J(U(e.before), e.beforeFormat),
|
|
110
|
+
after: J(U(e.after), e.afterFormat)
|
|
110
111
|
};
|
|
112
|
+
}, J = (e, t) => {
|
|
113
|
+
if (!e || !t || e.startsWith("=")) return e || void 0;
|
|
114
|
+
try {
|
|
115
|
+
return _(t) ? ne(e, t, b.value) ?? e : /^-?\d+(\.\d+)?(e[+-]?\d+)?$/i.test(e) ? v(t, Number(e), b.value).text : e;
|
|
116
|
+
} catch {
|
|
117
|
+
return e;
|
|
118
|
+
}
|
|
111
119
|
}, Y = o(() => {
|
|
112
120
|
let e = l.part;
|
|
113
121
|
if (e.state !== "output-available" || !e.output?.storedFileName) return;
|
|
@@ -124,15 +132,15 @@ var ee = {
|
|
|
124
132
|
restored: t.restoredFrom
|
|
125
133
|
})), {
|
|
126
134
|
output: t,
|
|
127
|
-
mediaType: n ?
|
|
135
|
+
mediaType: n ? g : te,
|
|
128
136
|
summary: o,
|
|
129
|
-
cells: n ? [] : i.map(
|
|
137
|
+
cells: n ? [] : i.map(se),
|
|
130
138
|
paragraphs: n ? i.map(q) : [],
|
|
131
139
|
count: i.length,
|
|
132
140
|
more: t.moreChanges ?? 0,
|
|
133
141
|
reminders: a
|
|
134
142
|
};
|
|
135
|
-
}), X = (e) =>
|
|
143
|
+
}), X = (e) => H.value ? e ?? [] : (e ?? []).slice(0, V), ce = o(() => X(Y.value?.paragraphs)), le = o(() => {
|
|
136
144
|
let e = /* @__PURE__ */ new Map();
|
|
137
145
|
for (let t of X(Y.value?.cells)) {
|
|
138
146
|
let n = e.get(t.sheet);
|
|
@@ -142,16 +150,16 @@ var ee = {
|
|
|
142
150
|
});
|
|
143
151
|
}
|
|
144
152
|
return [...e.values()];
|
|
145
|
-
}),
|
|
153
|
+
}), Z = o(() => (Y.value?.count ?? 0) - V), Q = o(() => {
|
|
146
154
|
let e = Y.value?.output, t = e?.fileId ? l.latestVersions?.get(e.fileId) : void 0;
|
|
147
155
|
return e?.fileId && e.version && t && e.version < t ? {
|
|
148
156
|
fileId: e.fileId,
|
|
149
157
|
version: e.version,
|
|
150
158
|
filename: y(e.filename ?? e.storedFileName, e.version)
|
|
151
159
|
} : void 0;
|
|
152
|
-
}),
|
|
153
|
-
|
|
154
|
-
},
|
|
160
|
+
}), $ = () => {
|
|
161
|
+
Q.value && l.restore?.(Q.value);
|
|
162
|
+
}, ue = () => {
|
|
155
163
|
let e = Y.value?.output;
|
|
156
164
|
e && l.preview && l.preview({
|
|
157
165
|
kind: Y.value?.mediaType === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ? "word" : "spreadsheet",
|
|
@@ -162,15 +170,15 @@ var ee = {
|
|
|
162
170
|
});
|
|
163
171
|
};
|
|
164
172
|
return (a, o) => {
|
|
165
|
-
let s =
|
|
166
|
-
return Y.value ? (h(), m("div",
|
|
173
|
+
let s = re;
|
|
174
|
+
return Y.value ? (h(), m("div", ae, [e(ie, {
|
|
167
175
|
"media-type": Y.value.mediaType,
|
|
168
176
|
url: t.fileUrl(Y.value.output.storedFileName),
|
|
169
177
|
filename: Y.value.output.filename,
|
|
170
178
|
size: Y.value.output.sizeBytes,
|
|
171
179
|
"show-download": "",
|
|
172
|
-
"on-preview": t.preview ?
|
|
173
|
-
"on-restore": t.restore &&
|
|
180
|
+
"on-preview": t.preview ? ue : void 0,
|
|
181
|
+
"on-restore": t.restore && Q.value ? $ : void 0
|
|
174
182
|
}, null, 8, [
|
|
175
183
|
"media-type",
|
|
176
184
|
"url",
|
|
@@ -178,31 +186,31 @@ var ee = {
|
|
|
178
186
|
"size",
|
|
179
187
|
"on-preview",
|
|
180
188
|
"on-restore"
|
|
181
|
-
]), Y.value.count || Y.value.output.restoredFrom ? (h(), m("section",
|
|
182
|
-
i("h4",
|
|
183
|
-
Y.value.count ? (h(), m("div",
|
|
184
|
-
i("th",
|
|
185
|
-
i("th",
|
|
186
|
-
i("th",
|
|
187
|
-
])]), (h(!0), m(r, null, n(
|
|
188
|
-
i("td",
|
|
189
|
-
i("td",
|
|
190
|
-
i("td",
|
|
191
|
-
], 64))]))), 128))]))), 128))])) : (h(), m("ul",
|
|
189
|
+
]), Y.value.count || Y.value.output.restoredFrom ? (h(), m("section", x, [
|
|
190
|
+
i("h4", S, c(Y.value.summary), 1),
|
|
191
|
+
Y.value.count ? (h(), m("div", C, [Y.value.cells.length ? (h(), m("table", w, [i("thead", null, [i("tr", null, [
|
|
192
|
+
i("th", T, c(f(d)("messagePart.chatFileCell")), 1),
|
|
193
|
+
i("th", E, c(f(d)("messagePart.chatFileBefore")), 1),
|
|
194
|
+
i("th", D, c(f(d)("messagePart.chatFileAfter")), 1)
|
|
195
|
+
])]), (h(!0), m(r, null, n(le.value, (e, t) => (h(), m("tbody", { key: t }, [i("tr", null, [i("th", O, c(f(d)("messagePart.chatFileSheet", { name: e.sheet })), 1)]), (h(!0), m(r, null, n(e.rows, (e, t) => (h(), m("tr", { key: t }, [e.newSheet ? (h(), m("td", k, c(e.newSheet), 1)) : (h(), m(r, { key: 1 }, [
|
|
196
|
+
i("td", A, c(e.cell), 1),
|
|
197
|
+
i("td", j, c(e.before), 1),
|
|
198
|
+
i("td", M, c(e.after), 1)
|
|
199
|
+
], 64))]))), 128))]))), 128))])) : (h(), m("ul", N, [(h(!0), m(r, null, n(ce.value, (e, t) => (h(), m("li", {
|
|
192
200
|
key: t,
|
|
193
201
|
class: "pk-tool-chat-file__paragraph"
|
|
194
|
-
}, [i("span",
|
|
195
|
-
|
|
202
|
+
}, [i("span", P, c(e.what), 1), i("span", F, [(h(!0), m(r, null, n(e.segments, (e, t) => (h(), m(r, { key: t }, [e.kind === "removed" ? (h(), m("del", I, c(e.text), 1)) : e.kind === "added" ? (h(), m("ins", oe, c(e.text), 1)) : (h(), m("span", L, c(e.text), 1))], 64))), 128))])]))), 128))])), H.value && Y.value.more ? (h(), m("p", R, c(f(d)("messagePart.chatFileMoreChanges", Y.value.more)), 1)) : u("", !0)])) : u("", !0),
|
|
203
|
+
Z.value > 0 ? (h(), m("button", {
|
|
196
204
|
key: 1,
|
|
197
205
|
type: "button",
|
|
198
206
|
class: "pk-tool-chat-file__more",
|
|
199
|
-
"aria-expanded":
|
|
200
|
-
onClick: o[0] ||= (e) =>
|
|
207
|
+
"aria-expanded": H.value,
|
|
208
|
+
onClick: o[0] ||= (e) => H.value = !H.value
|
|
201
209
|
}, [e(s, {
|
|
202
|
-
name:
|
|
210
|
+
name: H.value ? "ri:arrow-up-s-line" : "ri:arrow-down-s-line",
|
|
203
211
|
class: "text-16",
|
|
204
212
|
"aria-hidden": "true"
|
|
205
|
-
}, null, 8, ["name"]), p(" " + c(
|
|
213
|
+
}, null, 8, ["name"]), p(" " + c(H.value ? f(d)("action.showLess") : f(d)("action.showMore", { count: Z.value })), 1)], 8, z)) : u("", !0),
|
|
206
214
|
(h(!0), m(r, null, n(Y.value.reminders, (t) => (h(), m("p", {
|
|
207
215
|
key: t,
|
|
208
216
|
class: "pk-tool-chat-file__reminder"
|
|
@@ -211,10 +219,10 @@ var ee = {
|
|
|
211
219
|
class: "pk-tool-chat-file__reminder-icon",
|
|
212
220
|
"aria-hidden": "true"
|
|
213
221
|
}), p(" " + c(t), 1)]))), 128))
|
|
214
|
-
])) : Y.value.summary ? (h(), m("p",
|
|
222
|
+
])) : Y.value.summary ? (h(), m("p", B, c(Y.value.summary), 1)) : u("", !0)])) : u("", !0);
|
|
215
223
|
};
|
|
216
224
|
}
|
|
217
225
|
}), [["styles", [".pk-tool-chat-file__changes{border:var(--border) solid var(--color-surface-3);border-radius:var(--rounded-lg);background-color:var(--color-surface);max-width:36rem;font-size:var(--text-12);overflow:hidden}.pk-tool-chat-file__summary{padding:var(--spacing-8) var(--spacing-12);border-bottom:var(--border) solid var(--color-surface-3);color:var(--color-word-2);font-size:var(--text-12);font-weight:var(--font-medium);margin:0}.pk-tool-chat-file__summary:last-child{border-bottom:0}.pk-tool-chat-file__scroll{max-height:20rem;overflow-y:auto}.pk-tool-chat-file__table{border-collapse:collapse;width:100%}.pk-tool-chat-file__table th,.pk-tool-chat-file__table td{padding:var(--spacing-8) var(--spacing-12);border-bottom:var(--border) solid var(--color-surface-2);text-align:start;vertical-align:top;overflow-wrap:anywhere}.pk-tool-chat-file__table th{color:var(--color-word-3);font-weight:var(--font-medium)}.pk-tool-chat-file__table tbody:last-child tr:last-child td{border-bottom:0}.pk-tool-chat-file__table .pk-tool-chat-file__sheet{padding-block:var(--spacing-6);background-color:var(--color-surface-1);color:var(--color-word-2)}.pk-tool-chat-file__cell{width:1%;color:var(--color-word-2);font-variant-numeric:tabular-nums;white-space:nowrap}.pk-tool-chat-file__before{width:50%;color:var(--color-word-3)}.pk-tool-chat-file__after{width:50%;color:var(--color-word-1)}.pk-tool-chat-file__paragraphs{margin:0;padding:0;list-style:none}.pk-tool-chat-file__paragraph{gap:var(--spacing-4) var(--spacing-md);padding:var(--spacing-8) var(--spacing-12);border-bottom:var(--border) solid var(--color-surface-2);grid-template-columns:minmax(4rem,max-content) 1fr;display:grid}.pk-tool-chat-file__paragraph:last-child{border-bottom:0}.pk-tool-chat-file__what{color:var(--color-word-3);white-space:nowrap}.pk-tool-chat-file__text{min-width:0;color:var(--color-word-2);overflow-wrap:anywhere}.pk-tool-chat-file__removed{color:var(--u-danger-text);text-decoration:line-through}.pk-tool-chat-file__added{color:var(--u-success-text);font-weight:var(--font-medium);text-underline-offset:.2em;text-decoration:underline}.pk-tool-chat-file__removed+.pk-tool-chat-file__added{margin-inline-start:var(--spacing-4)}.pk-tool-chat-file__note{padding:var(--spacing-8) var(--spacing-12);border-top:var(--border) solid var(--color-surface-2);color:var(--color-word-3);margin:0}.pk-tool-chat-file__more{justify-content:center;align-items:center;gap:var(--spacing-4);width:100%;padding:var(--spacing-8) var(--spacing-12);border:0;border-top:var(--border) solid var(--color-surface-2);color:var(--color-word-2);font:inherit;cursor:pointer;transition:background-color var(--duration-150) var(--ease-out);background:0 0;display:flex}.pk-tool-chat-file__more:hover{background-color:var(--color-surface-1)}.pk-tool-chat-file__more:focus-visible{outline:var(--spacing-2) solid var(--input-focus-color);outline-offset:calc(var(--spacing-2) * -1)}.pk-tool-chat-file__reminder{align-items:flex-start;gap:var(--spacing-8);padding:var(--spacing-8) var(--spacing-12);border-top:var(--border) solid var(--color-surface-2);color:var(--color-word-2);margin:0;display:flex}.pk-tool-chat-file__reminder-icon{margin-top:var(--spacing-2);color:var(--color-word-3);font-size:var(--text-14);flex-shrink:0}"]]]);
|
|
218
|
-
export {
|
|
226
|
+
export { H as default };
|
|
219
227
|
|
|
220
|
-
//# sourceMappingURL=PkToolChatFile-
|
|
228
|
+
//# sourceMappingURL=PkToolChatFile-OuaeZTxw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PkToolChatFile-OuaeZTxw.js","names":["__unplugin_components_0","_openBlock","_createElementBlock","_createVNode","PkChatbotFilePreview","_createElementVNode","_toDisplayString","_unref","_Fragment","_renderList","_createCommentVNode","_createTextVNode","_sfc_main","_style_0","createVNode","init_shared_esm_bundler","renderList","Fragment","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","SPREADSHEET_MIME_TYPE","WORD_MIME_TYPE","isSpreadsheetDateFormat","formatExcelNumber","excelDateText","chatFileName","Ce","_plugin_vue_export_helper_default","PkChatbotFilePreview_default","_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_default","WORD_TOOL_PARTS","props","__props","$t","showAll","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","part","output","word","changed","changes","reminders","summary","shown","shownParagraphs","shownSheets","groups","row","group","hiddenRows","olderVersion","latest","restoreThis","openPreview","_component_VvIcon","g","index","s","segment","_cache","reminder"],"sources":["../../../../packages/components/src/chat/PkToolChatFile.vue","../../../../packages/components/src/chat/PkToolChatFile.vue","../../../../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","<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","<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,GAkFU8D,IAAgB,G;;;;;;;;;;EANtB,IAAME,oBAAkB,IAAI,IAAI,CAC5B,yBACA,yBACJ,CAAC,GAgBKC,IAAQC,GAeR,EAAE,GAAGC,GAAI,cAAWrC,GAAQ,EAAE,UAAU,SAAS,CAAC,GAElDsC,IAAUjD,EAAI,EAAK,GAQnBkD,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,MA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AAGuH,CAAQ,GAAA,CAAA,C;G,MAGLzB,EAAA,MAAK,WAAnBnG,EAAA,GAAAC,EAEI,KAFJ2D,GAEIvD,EADG8F,EAAA,MAAK,OAAO,GAAA,CAAA,K"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Et as e, Q as t, S as n, Tt as r, _ as i, g as a, gt as o, h as s, k as c, kt as l, ot as u, w as d, wt as f, x as p, y as m, z as h } from "./vue.runtime.esm-bundler-C2U5uTqB.js";
|
|
2
|
-
import { t as g } from "./PkStreamingMarkdown-
|
|
2
|
+
import { t as g } from "./PkStreamingMarkdown-BvgO6aHe.js";
|
|
3
3
|
import { i as _ } from "./dist-B3-I_01H.js";
|
|
4
4
|
import { t as v } from "./VvButtonLocalized-KEhD3ono.js";
|
|
5
5
|
// ../../packages/components/src/chat/PkCode.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -91,4 +91,4 @@ var x = { class: "border border-surface-3 rounded-xl w-full overflow-hidden" },
|
|
|
91
91
|
});
|
|
92
92
|
export { E as default };
|
|
93
93
|
|
|
94
|
-
//# sourceMappingURL=PkToolShowArtifact-
|
|
94
|
+
//# sourceMappingURL=PkToolShowArtifact-BqgW3E6D.js.map
|
package/dist/_chunks/{PkToolShowArtifact-B2-3-k2F.js.map → PkToolShowArtifact-BqgW3E6D.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowArtifact-B2-3-k2F.js","names":["$attrs","_hoisted_1","_openBlock","_createElementBlock","_normalizeClass","_createTextVNode","_createElementVNode","_sfc_main","$t","__unplugin_components_0","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","_unref","_createBlock","PkCode","PkStreamingMarkdown","_normalizeClass","_sfc_main","normalizeClass","watch","createVNode","init_shared_esm_bundler","createBlock","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","defineComponent","unref","createTextVNode","createElementBlock","openBlock","PkStreamingMarkdown_default","useClipboard","VvButtonLocalized","_hoisted_1$1","PkCode_default","props","__props","highlightedHtml","hasCode","highlight","hljs","result","_ctx","_cache","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","PkToolShowArtifact_default","toolPart","artifactTypeLabel","languageLabel","isCodeType","isMarkdownType","codeLanguage","_component_VvButton","copied","copy"],"sources":["../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkToolShowArtifact.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, 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","<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,IAAM0C,IAAQC,GAMRC,IAAkBjB,EAAI,EAAE,GAExBkB,IAAUjB,QACR,OAAOc,EAAM,QAAS,WACfA,EAAM,OAEV,KAAK,UAAUA,EAAM,MAAM,MAAM,CAAC,CAC5C;EAED,eAAeI,IAAY;GACvB,IAAMC,KAAQ,MAAM,OAAO,6DAAA,CAA4B;GACvD,IAAI;IACA,IAAMC,IAASN,EAAM,WACfK,EAAK,UAAUF,EAAQ,OAAO,EAAE,UAAUH,EAAM,SAAS,CAAC,IAC1DK,EAAK,cAAcF,EAAQ,KAAK;IACtC,EAAgB,QAAQG,EAAO;GACnC,QAAQ;IACJ,EAAgB,QAAQH,EAAQ,MAC3B,QAAQ,MAAM,OAAO,CAAA,CACrB,QAAQ,MAAM,MAAM,CAAA,CACpB,QAAQ,MAAM,MAAM;GAC7B;EACJ;E,OAEAvB,EAAMuB,GAASC,GAAW,EAAE,WAAW,GAAK,CAAC,I,UAI7C5C,EAAA,GAAAC,EAOM,OAAA,EAND,OAAKC,EAAeJ,EAAAA,OAAO,QAAwBA,EAAAA,OAAO,Q;GAIzD,AAAAkD,EAAA,OAAA7C,EAAA,YACF,EAAA;GAAAC,EAAmH,QAAA;IAA5G,OAAKF,EAAA;KAAA;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AAA,KAAiB,IAAA7C,EAAM8C,EAAA,KAAa,GAAA,CAAA,C,IAG/C7C,EAMoDiD,GAAA;IAL/C,MAAMhD,EAAAiD,CAAA,IAAM,kBAAA;IACZ,OAAOjD,EAAAiD,CAAA,IAASxD,EAAAA,GAAE,eAAA,IAAoBA,EAAAA,GAAE,aAAA;IACzC,WAAU;IACT,OAAOA,EAAAA,GAAE,aAAA;IACV,OAAM;IACL,SAAK,AAAA0C,EAAA,QAAA,MAAEnC,EAAAkD,CAAA,CAAI,CAACR,EAAA,OAAU,OAAO,WAAO,EAAA;;;;;G,MAE7C7C,EAkBM,OAlBN2C,GAkBM,CAhBQK,EAAA,SADVlD,EAAA,GAAAM,EAG+BC,GAAA;;IAD1B,MAAMwC,EAAA,OAAU,OAAO;IACvB,UAAUK,EAAA;G,qCAEAD,EAAA,SADfnD,EAAA,GAAAM,EAGkCE,GAAA;;IAD7B,UAAUuC,EAAA,OAAU,OAAO;IAC5B,OAAM;G,8BACV/C,EAAA,GAAAC,EAQyC,OAAA;;IANrC,OAAKQ,EAAA,CAAC,+CAA6C,E,QACWsC,EAAA,OAAU,OAAO,iBAAY,cAA2CA,EAAA,OAAU,OAAO,iBAAY,O;GAK/J,GAAA5C,EAAA4C,EAAA,OAAU,OAAO,OAAO,GAAA,CAAA,E"}
|
|
1
|
+
{"version":3,"file":"PkToolShowArtifact-BqgW3E6D.js","names":["$attrs","_hoisted_1","_openBlock","_createElementBlock","_normalizeClass","_createTextVNode","_createElementVNode","_sfc_main","$t","__unplugin_components_0","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","_unref","_createBlock","PkCode","PkStreamingMarkdown","_normalizeClass","_sfc_main","normalizeClass","watch","createVNode","init_shared_esm_bundler","createBlock","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","defineComponent","unref","createTextVNode","createElementBlock","openBlock","PkStreamingMarkdown_default","useClipboard","VvButtonLocalized","_hoisted_1$1","PkCode_default","props","__props","highlightedHtml","hasCode","highlight","hljs","result","_ctx","_cache","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","PkToolShowArtifact_default","toolPart","artifactTypeLabel","languageLabel","isCodeType","isMarkdownType","codeLanguage","_component_VvButton","copied","copy"],"sources":["../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkToolShowArtifact.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, 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","<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,IAAM0C,IAAQC,GAMRC,IAAkBjB,EAAI,EAAE,GAExBkB,IAAUjB,QACR,OAAOc,EAAM,QAAS,WACfA,EAAM,OAEV,KAAK,UAAUA,EAAM,MAAM,MAAM,CAAC,CAC5C;EAED,eAAeI,IAAY;GACvB,IAAMC,KAAQ,MAAM,OAAO,6DAAA,CAA4B;GACvD,IAAI;IACA,IAAMC,IAASN,EAAM,WACfK,EAAK,UAAUF,EAAQ,OAAO,EAAE,UAAUH,EAAM,SAAS,CAAC,IAC1DK,EAAK,cAAcF,EAAQ,KAAK;IACtC,EAAgB,QAAQG,EAAO;GACnC,QAAQ;IACJ,EAAgB,QAAQH,EAAQ,MAC3B,QAAQ,MAAM,OAAO,CAAA,CACrB,QAAQ,MAAM,MAAM,CAAA,CACpB,QAAQ,MAAM,MAAM;GAC7B;EACJ;E,OAEAvB,EAAMuB,GAASC,GAAW,EAAE,WAAW,GAAK,CAAC,I,UAI7C5C,EAAA,GAAAC,EAOM,OAAA,EAND,OAAKC,EAAeJ,EAAAA,OAAO,QAAwBA,EAAAA,OAAO,Q;GAIzD,AAAAkD,EAAA,OAAA7C,EAAA,YACF,EAAA;GAAAC,EAAmH,QAAA;IAA5G,OAAKF,EAAA;KAAA;KAAWuC,EAAA,OAAI,wBAAA;KAA6CA,EAAA;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AAA,CAAA,C,IAG/C7C,EAMoDiD,GAAA;IAL/C,MAAMhD,EAAAiD,CAAA,IAAM,kBAAA;IACZ,OAAOjD,EAAAiD,CAAA,IAASxD,EAAAA,GAAE,eAAA,IAAoBA,EAAAA,GAAE,aAAA;IACzC,WAAU;IACT,OAAOA,EAAAA,GAAE,aAAA;IACV,OAAM;IACL,SAAK,AAAA0C,EAAA,QAAA,MAAEnC,EAAAkD,CAAA,CAAI,CAACR,EAAA,OAAU,OAAO,WAAO,EAAA;;;;;G,MAE7C7C,EAkBM,OAlBN2C,GAkBM,CAhBQK,EAAA,SADVlD,EAAA,GAAAM,EAG+BC,GAAA;;IAD1B,MAAMwC,EAAA,OAAU,OAAO;IACvB,UAAUK,EAAA;G,qCAEAD,EAAA,SADfnD,EAAA,GAAAM,EAGkCE,GAAA;;IAD7B,UAAUuC,EAAA,OAAU,OAAO;IAC5B,OAAM;G,8BACV/C,EAAA,GAAAC,EAQyC,OAAA;;IANrC,OAAKQ,EAAA,CAAC,+CAA6C,E,QACWsC,EAAA,OAAU,OAAO,iBAAY,cAA2CA,EAAA,OAAU,OAAO,iBAAY,O;GAK/J,GAAA5C,EAAA4C,EAAA,OAAU,OAAO,OAAO,GAAA,CAAA,E"}
|
package/dist/_chunks/{PkToolShowContactForm-DbOZHB_G.js → PkToolShowContactForm-DDDXopZp.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as e, b as t, d as n } from "./zod-Cty6wiWN.js";
|
|
2
2
|
import { Q as r, S as i, Tt as a, V as o, _ as s, f as ee, g as c, h as l, k as u, kt as d, ot as f, r as p, t as m, tt as h, ut as g, v as _, w as v, wt as y, x as b, y as x, z as S } from "./vue.runtime.esm-bundler-C2U5uTqB.js";
|
|
3
3
|
import { r as C } from "./vue-i18n-POtLvOl1.js";
|
|
4
|
-
import { t as w } from "./PkStreamingMarkdown-
|
|
4
|
+
import { t as w } from "./PkStreamingMarkdown-BvgO6aHe.js";
|
|
5
5
|
import { t as T } from "./src-JJyCGvqH.js";
|
|
6
6
|
import { s as E, t as D } from "./index.es-C7ON2BA3.js";
|
|
7
7
|
import { t as O } from "./VvButtonLocalized-KEhD3ono.js";
|
|
@@ -154,4 +154,4 @@ var M = { class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-s
|
|
|
154
154
|
});
|
|
155
155
|
export { K as default };
|
|
156
156
|
|
|
157
|
-
//# sourceMappingURL=PkToolShowContactForm-
|
|
157
|
+
//# sourceMappingURL=PkToolShowContactForm-DDDXopZp.js.map
|