@8wave/ai-elements 0.125.0-beta.6 → 0.125.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/Agent-DZhK49jg.js.map +1 -1
- package/dist/_chunks/PkToolShowCalendarEvent-DWtTo28t.js +148 -0
- package/dist/_chunks/PkToolShowCalendarEvent-DWtTo28t.js.map +1 -0
- package/dist/_chunks/{PkToolShowQrCode-e6DxEcWY.js → PkToolShowQrCode-DGMhVUbp.js} +28 -22
- package/dist/_chunks/PkToolShowQrCode-DGMhVUbp.js.map +1 -0
- package/dist/ai-elements.es.js +2 -2
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/_chunks/Agent-BtXBSGy6.js.map +1 -1
- package/dist-vue/_chunks/{PkChatbot-Qrk8yEM0.js → PkChatbot-CLOfTLQy.js} +2 -2
- package/dist-vue/_chunks/{PkChatbot-Qrk8yEM0.js.map → PkChatbot-CLOfTLQy.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotMessages-DAwGWRtd.js → PkChatbotMessages-BxkCGmqV.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotMessages-DAwGWRtd.js.map → PkChatbotMessages-BxkCGmqV.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-CMFc4eLD.js → PkChatbotViewChat-BwXOt2WW.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewChat-CMFc4eLD.js.map → PkChatbotViewChat-BwXOt2WW.js.map} +1 -1
- package/dist-vue/_chunks/PkToolShowCalendarEvent-CAejFLQI.js +148 -0
- package/dist-vue/_chunks/PkToolShowCalendarEvent-CAejFLQI.js.map +1 -0
- package/dist-vue/_chunks/PkToolShowQrCode-96KzD1rX.js +78 -0
- package/dist-vue/_chunks/PkToolShowQrCode-96KzD1rX.js.map +1 -0
- package/dist-vue/index.js +5 -5
- package/dist-vue/packages/models/src/schema/Agent.d.ts +9 -0
- package/package.json +1 -1
- package/dist/_chunks/PkToolShowCalendarEvent-mVY2FS24.js +0 -148
- package/dist/_chunks/PkToolShowCalendarEvent-mVY2FS24.js.map +0 -1
- package/dist/_chunks/PkToolShowQrCode-e6DxEcWY.js.map +0 -1
- package/dist-vue/_chunks/PkToolShowCalendarEvent-BsAOYLjp.js +0 -148
- package/dist-vue/_chunks/PkToolShowCalendarEvent-BsAOYLjp.js.map +0 -1
- package/dist-vue/_chunks/PkToolShowQrCode-skWaARYV.js +0 -72
- package/dist-vue/_chunks/PkToolShowQrCode-skWaARYV.js.map +0 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Dt as e, E as t, S as n, Tt as r, g as i, h as a, k as o, kt as s, ot as c, tt 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 g } from "./vue-i18n-POtLvOl1.js";
|
|
3
|
+
import "./src-JJyCGvqH.js";
|
|
4
|
+
import { n as _ } from "./url-validation-CJV9pp4v.js";
|
|
5
|
+
import { i as v } from "./dist-B3-I_01H.js";
|
|
6
|
+
import { a as y, p as b, t as x, u as S } from "./index.es-C7ON2BA3.js";
|
|
7
|
+
import { t as C } from "./VvButtonLocalized-KEhD3ono.js";
|
|
8
|
+
import { n as w } from "./useShortUrlResolver-C30QRypC.js";
|
|
9
|
+
// ../../packages/components/src/chat/PkToolShowCalendarEvent.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
+
o(), r(), c();
|
|
11
|
+
var T = {
|
|
12
|
+
key: 0,
|
|
13
|
+
class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-surface"
|
|
14
|
+
}, E = { class: "px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8" }, D = { class: "font-bold" }, O = { class: "p-sm flex gap-sm items-start" }, k = { class: "shrink-0 w-44 rounded-xl overflow-hidden border border-surface-3 text-center" }, A = { class: "bg-brand px-8 py-2 text-brand-contrast text-10 font-bold uppercase tracking-wide" }, j = { class: "bg-surface-1 py-4 text-word-1 text-24 font-bold leading-none" }, M = { class: "flex flex-col gap-4 min-w-0" }, N = { class: "font-semibold text-word-1 text-14" }, P = { class: "flex items-center gap-8 text-12 text-word-3" }, F = ["datetime"], I = {
|
|
15
|
+
key: 0,
|
|
16
|
+
class: "flex items-center gap-8 text-12 text-word-3"
|
|
17
|
+
}, L = [
|
|
18
|
+
"href",
|
|
19
|
+
"target",
|
|
20
|
+
"rel"
|
|
21
|
+
], R = { key: 1 }, z = {
|
|
22
|
+
key: 1,
|
|
23
|
+
class: "flex items-start gap-8 text-12 text-word-3"
|
|
24
|
+
}, B = /* @__PURE__ */ d({
|
|
25
|
+
__name: "PkToolShowCalendarEvent",
|
|
26
|
+
props: { part: { type: null } },
|
|
27
|
+
setup(r) {
|
|
28
|
+
let o = r, { copy: c, copied: d } = v(), { d: B } = g(), V = a(() => o.part), { resolveText: H } = w(), U = H(() => V.value.input?.title), W = H(() => V.value.input?.location), G = H(() => V.value.input?.additionalInfo), K = a(() => {
|
|
29
|
+
let e = V.value.input;
|
|
30
|
+
if (!e) return "";
|
|
31
|
+
let { startDate: t, endDate: n, allDay: r } = e, i = new Date(t), a = new Date(n), o = t.slice(0, 10), s = n.slice(0, 10);
|
|
32
|
+
return r ? o === s ? B(i, "date-medium") : `${B(i, "date-medium")} - ${B(a, "date-medium")}` : o === s ? `${B(i, "date-time-medium")} - ${B(a, "time")}` : `${B(i, "date-time-medium")} - ${B(a, "date-time-medium")}`;
|
|
33
|
+
}), q = a(() => V.value.input ? new Date(V.value.input.startDate) : null), J = a(() => q.value?.getDate().toString() ?? ""), Y = a(() => q.value ? B(q.value, "month-short") : ""), X = (e) => e.replace(/[-:]/g, "").replace(/\.\d{3}$/, ""), Z = (e) => e.replace(/\\/g, "\\\\").replace(/;/g, "\\;").replace(/,/g, "\\,").replace(/\n/g, "\\n"), Q = () => {
|
|
34
|
+
let e = V.value.input;
|
|
35
|
+
if (!e) return;
|
|
36
|
+
let { startDate: t, endDate: n } = e, r = [
|
|
37
|
+
"BEGIN:VCALENDAR",
|
|
38
|
+
"VERSION:2.0",
|
|
39
|
+
"PRODID:-//8wave//8bot//EN",
|
|
40
|
+
"BEGIN:VEVENT",
|
|
41
|
+
`DTSTART:${X(t)}`,
|
|
42
|
+
`DTEND:${X(n)}`,
|
|
43
|
+
`SUMMARY:${Z(U.value)}`,
|
|
44
|
+
W.value ? `LOCATION:${Z(W.value)}` : "",
|
|
45
|
+
G.value ? `DESCRIPTION:${Z(G.value)}` : "",
|
|
46
|
+
`DTSTAMP:${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/, "")}`,
|
|
47
|
+
`UID:${crypto.randomUUID()}@8bot.ai`,
|
|
48
|
+
"END:VEVENT",
|
|
49
|
+
"END:VCALENDAR"
|
|
50
|
+
].filter(Boolean).join("\r\n"), i = new Blob([r], { type: "text/calendar;charset=utf-8" }), a = URL.createObjectURL(i), o = document.createElement("a");
|
|
51
|
+
o.href = a, o.download = `${U.value.replace(/[^\p{L}\p{N}\s-]/gu, "").trim() || "event"}.ics`, o.click(), URL.revokeObjectURL(a);
|
|
52
|
+
}, $ = () => {
|
|
53
|
+
let e = V.value.input;
|
|
54
|
+
if (!e) return;
|
|
55
|
+
let t = X(e.startDate), n = X(e.endDate), r = new URLSearchParams({
|
|
56
|
+
action: "TEMPLATE",
|
|
57
|
+
text: U.value,
|
|
58
|
+
dates: `${t}/${n}`
|
|
59
|
+
});
|
|
60
|
+
W.value && r.set("location", W.value), G.value && r.set("details", G.value), window.open(`https://calendar.google.com/calendar/render?${r.toString()}`, "_blank");
|
|
61
|
+
}, ee = () => {
|
|
62
|
+
let e = V.value.input;
|
|
63
|
+
if (!e) return;
|
|
64
|
+
let t = new URLSearchParams({
|
|
65
|
+
subject: U.value,
|
|
66
|
+
startdt: e.startDate,
|
|
67
|
+
enddt: e.endDate
|
|
68
|
+
});
|
|
69
|
+
W.value && t.set("location", W.value), G.value && t.set("body", G.value), window.open(`https://outlook.office.com/calendar/0/action/compose?${t.toString()}`, "_blank");
|
|
70
|
+
}, te = () => {
|
|
71
|
+
if (!V.value.input) return;
|
|
72
|
+
let e = [U.value, K.value];
|
|
73
|
+
W.value && e.push(W.value), G.value && e.push(G.value), c(e.join("\n"));
|
|
74
|
+
};
|
|
75
|
+
return (r, a) => {
|
|
76
|
+
let o = x, c = C, g = b, v = S, w = y;
|
|
77
|
+
return V.value?.input ? (h(), m("div", T, [i("div", E, [
|
|
78
|
+
n(o, {
|
|
79
|
+
name: "ri:calendar-event-line",
|
|
80
|
+
class: "text-16"
|
|
81
|
+
}),
|
|
82
|
+
i("strong", D, s(r.$t("label.calendarEvent")), 1),
|
|
83
|
+
n(w, {
|
|
84
|
+
modifiers: "compact",
|
|
85
|
+
class: "ml-auto shrink-0"
|
|
86
|
+
}, {
|
|
87
|
+
default: l(() => [n(c, {
|
|
88
|
+
modifiers: "action-quiet-small",
|
|
89
|
+
icon: f(d) ? "ri:check-line" : "ri:file-copy-line",
|
|
90
|
+
label: f(d) ? r.$t("action.copied") : r.$t("action.copy"),
|
|
91
|
+
onClick: te
|
|
92
|
+
}, null, 8, ["icon", "label"]), n(v, e(t({
|
|
93
|
+
placement: "bottom-end",
|
|
94
|
+
modifiers: "menu",
|
|
95
|
+
flip: !0,
|
|
96
|
+
offset: 3,
|
|
97
|
+
strategy: "fixed"
|
|
98
|
+
})), {
|
|
99
|
+
items: l(() => [
|
|
100
|
+
n(g, { onClick: $ }, {
|
|
101
|
+
default: l(() => [n(o, { name: "ri:google-line" }), a[0] ||= p(" Google Calendar ", -1)]),
|
|
102
|
+
_: 1
|
|
103
|
+
}),
|
|
104
|
+
n(g, { onClick: ee }, {
|
|
105
|
+
default: l(() => [n(o, { name: "ri:microsoft-line" }), a[1] ||= p(" Outlook ", -1)]),
|
|
106
|
+
_: 1
|
|
107
|
+
}),
|
|
108
|
+
n(g, { onClick: Q }, {
|
|
109
|
+
default: l(() => [n(o, { name: "ri:download-line" }), p(" " + s(r.$t("action.downloadIcs")), 1)]),
|
|
110
|
+
_: 1
|
|
111
|
+
})
|
|
112
|
+
]),
|
|
113
|
+
default: l(() => [n(c, {
|
|
114
|
+
icon: "ri:calendar-line",
|
|
115
|
+
modifiers: "action-quiet-small",
|
|
116
|
+
label: r.$t("action.addToCalendar")
|
|
117
|
+
}, null, 8, ["label"])]),
|
|
118
|
+
_: 1
|
|
119
|
+
}, 16)]),
|
|
120
|
+
_: 1
|
|
121
|
+
})
|
|
122
|
+
]), i("div", O, [i("div", k, [i("div", A, s(Y.value), 1), i("div", j, s(J.value), 1)]), i("div", M, [
|
|
123
|
+
i("p", N, s(f(U)), 1),
|
|
124
|
+
i("div", P, [n(o, {
|
|
125
|
+
name: "ri:time-line",
|
|
126
|
+
class: "text-14 shrink-0"
|
|
127
|
+
}), i("time", { datetime: V.value.input.startDate }, s(K.value), 9, F)]),
|
|
128
|
+
f(W) ? (h(), m("div", I, [n(o, {
|
|
129
|
+
name: "ri:map-pin-line",
|
|
130
|
+
class: "text-14 shrink-0"
|
|
131
|
+
}), f(W).startsWith("http") ? (h(), m("a", {
|
|
132
|
+
key: 0,
|
|
133
|
+
href: f(W),
|
|
134
|
+
target: f(_)(f(W)) ? void 0 : "_blank",
|
|
135
|
+
rel: f(_)(f(W)) ? void 0 : "noopener noreferrer",
|
|
136
|
+
class: "underline truncate"
|
|
137
|
+
}, s(f(W)), 9, L)) : (h(), m("span", R, s(f(W)), 1))])) : u("", !0),
|
|
138
|
+
f(G) ? (h(), m("div", z, [n(o, {
|
|
139
|
+
name: "ri:sticky-note-line",
|
|
140
|
+
class: "text-14 shrink-0 mt-1"
|
|
141
|
+
}), i("span", null, s(f(G)), 1)])) : u("", !0)
|
|
142
|
+
])])])) : u("", !0);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
export { B as default };
|
|
147
|
+
|
|
148
|
+
//# sourceMappingURL=PkToolShowCalendarEvent-DWtTo28t.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PkToolShowCalendarEvent-DWtTo28t.js","names":["$t","__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","__unplugin_components_3","__unplugin_components_4","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_withCtx","_unref","_normalizeProps","_guardReactiveProps","_createTextVNode","_createCommentVNode","_sfc_main","normalizeProps","guardReactiveProps","createVNode","init_shared_esm_bundler","createBaseVNode","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","withCtx","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","isSameSite","useClipboard","au","su","Ce","na","VvButtonLocalized","useShortUrlResolver","_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","PkToolShowCalendarEvent_default","props","__props","toolPart","title","resolveText","eventLocation","additionalInfo","dateDisplay","input","start","startDate","end","endDate","startDay","endDay","allDay","d","calendarStart","calendarDay","calendarMonth","toIcsDateTime","iso","escapeIcs","str","generateIcs","ics","blob","url","a","openGoogleCalendar","params","openOutlook","copyEvent","lines","copy","_component_VvIcon","_component_VvButton","_component_VvDropdownAction","_component_VvDropdown","_component_VvButtonGroup","_ctx","copied","_cache"],"sources":["../../../../packages/components/src/chat/PkToolShowCalendarEvent.vue","../../../../packages/components/src/chat/PkToolShowCalendarEvent.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useClipboard } from '@vueuse/core'\n import { isSameSite } from 'utils'\n import { useShortUrlResolver } from 'composables'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const { copy, copied } = useClipboard()\n const { d } = useI18n()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title: string\n startDate: string\n endDate: string\n location?: string\n additionalInfo?: string\n allDay?: boolean\n }\n }\n return part\n })\n\n // The event leaves the app (an .ics file, Google or Outlook, the\n // clipboard), so a short url the model copied from a tool becomes its real\n // target there, and on the card that shows what will go out.\n const { resolveText } = useShortUrlResolver()\n const title = resolveText(() => toolPart.value.input?.title)\n const eventLocation = resolveText(() => toolPart.value.input?.location)\n const additionalInfo = resolveText(\n () => toolPart.value.input?.additionalInfo,\n )\n\n const dateDisplay = computed(() => {\n const input = toolPart.value.input\n if (!input) {\n return ''\n }\n const { startDate, endDate, allDay } = input\n const start = new Date(startDate)\n const end = new Date(endDate)\n const startDay = startDate.slice(0, 10)\n const endDay = endDate.slice(0, 10)\n if (allDay) {\n if (startDay === endDay) {\n return d(start, 'date-medium')\n }\n return `${d(start, 'date-medium')} - ${d(end, 'date-medium')}`\n }\n if (startDay === endDay) {\n return `${d(start, 'date-time-medium')} - ${d(end, 'time')}`\n }\n return `${d(start, 'date-time-medium')} - ${d(end, 'date-time-medium')}`\n })\n\n const calendarStart = computed(() =>\n toolPart.value.input ? new Date(toolPart.value.input.startDate) : null,\n )\n\n const calendarDay = computed(\n () => calendarStart.value?.getDate().toString() ?? '',\n )\n\n const calendarMonth = computed(() =>\n calendarStart.value ? d(calendarStart.value, 'month-short') : '',\n )\n\n // Floating time: remove dashes/colons without converting to UTC\n const toIcsDateTime = (iso: string) =>\n iso.replace(/[-:]/g, '').replace(/\\.\\d{3}$/, '')\n\n const escapeIcs = (str: string) =>\n str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/;/g, '\\\\;')\n .replace(/,/g, '\\\\,')\n .replace(/\\n/g, '\\\\n')\n\n const generateIcs = () => {\n const input = toolPart.value.input\n if (!input) {\n return\n }\n const { startDate, endDate } = input\n const ics = [\n 'BEGIN:VCALENDAR',\n 'VERSION:2.0',\n 'PRODID:-//8wave//8bot//EN',\n 'BEGIN:VEVENT',\n `DTSTART:${toIcsDateTime(startDate)}`,\n `DTEND:${toIcsDateTime(endDate)}`,\n `SUMMARY:${escapeIcs(title.value)}`,\n eventLocation.value\n ? `LOCATION:${escapeIcs(eventLocation.value)}`\n : '',\n additionalInfo.value\n ? `DESCRIPTION:${escapeIcs(additionalInfo.value)}`\n : '',\n `DTSTAMP:${new Date()\n .toISOString()\n .replace(/[-:]/g, '')\n .replace(/\\.\\d{3}/, '')}`,\n `UID:${crypto.randomUUID()}@8bot.ai`,\n 'END:VEVENT',\n 'END:VCALENDAR',\n ]\n .filter(Boolean)\n .join('\\r\\n')\n\n const blob = new Blob([ics], { type: 'text/calendar;charset=utf-8' })\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n // Letters of any alphabet: \"Riunione è\" kept its accent out, and a\n // title of none left a file called \".ics\".\n const fileName = title.value.replace(/[^\\p{L}\\p{N}\\s-]/gu, '').trim()\n a.download = `${fileName || 'event'}.ics`\n a.click()\n URL.revokeObjectURL(url)\n }\n\n const openGoogleCalendar = () => {\n const input = toolPart.value.input\n if (!input) {\n return\n }\n const start = toIcsDateTime(input.startDate)\n const end = toIcsDateTime(input.endDate)\n const params = new URLSearchParams({\n action: 'TEMPLATE',\n text: title.value,\n dates: `${start}/${end}`,\n })\n if (eventLocation.value) {\n params.set('location', eventLocation.value)\n }\n if (additionalInfo.value) {\n params.set('details', additionalInfo.value)\n }\n window.open(\n `https://calendar.google.com/calendar/render?${params.toString()}`,\n '_blank',\n )\n }\n\n const openOutlook = () => {\n const input = toolPart.value.input\n if (!input) {\n return\n }\n const params = new URLSearchParams({\n subject: title.value,\n startdt: input.startDate,\n enddt: input.endDate,\n })\n if (eventLocation.value) {\n params.set('location', eventLocation.value)\n }\n if (additionalInfo.value) {\n params.set('body', additionalInfo.value)\n }\n window.open(\n `https://outlook.office.com/calendar/0/action/compose?${params.toString()}`,\n '_blank',\n )\n }\n\n const copyEvent = () => {\n const input = toolPart.value.input\n if (!input) {\n return\n }\n const lines = [title.value, dateDisplay.value]\n if (eventLocation.value) {\n lines.push(eventLocation.value)\n }\n if (additionalInfo.value) {\n lines.push(additionalInfo.value)\n }\n copy(lines.join('\\n'))\n }\n</script>\n\n<template>\n <div\n v-if=\"toolPart?.input\"\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon name=\"ri:calendar-event-line\" class=\"text-16\" />\n <strong class=\"font-bold\">{{ $t('label.calendarEvent') }}</strong>\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n @click=\"copyEvent\" />\n <VvDropdown\n v-bind=\"{\n placement: 'bottom-end',\n modifiers: 'menu',\n flip: true,\n offset: 3,\n strategy: 'fixed',\n }\">\n <VvButton\n icon=\"ri:calendar-line\"\n modifiers=\"action-quiet-small\"\n :label=\"$t('action.addToCalendar')\" />\n <template #items>\n <VvDropdownAction @click=\"openGoogleCalendar\">\n <VvIcon name=\"ri:google-line\" />\n Google Calendar\n </VvDropdownAction>\n <VvDropdownAction @click=\"openOutlook\">\n <VvIcon name=\"ri:microsoft-line\" />\n Outlook\n </VvDropdownAction>\n <VvDropdownAction @click=\"generateIcs\">\n <VvIcon name=\"ri:download-line\" />\n {{ $t('action.downloadIcs') }}\n </VvDropdownAction>\n </template>\n </VvDropdown>\n </VvButtonGroup>\n </div>\n <div class=\"p-sm flex gap-sm items-start\">\n <div\n class=\"shrink-0 w-44 rounded-xl overflow-hidden border border-surface-3 text-center\">\n <div\n class=\"bg-brand px-8 py-2 text-brand-contrast text-10 font-bold uppercase tracking-wide\">\n {{ calendarMonth }}\n </div>\n <div\n class=\"bg-surface-1 py-4 text-word-1 text-24 font-bold leading-none\">\n {{ calendarDay }}\n </div>\n </div>\n <div class=\"flex flex-col gap-4 min-w-0\">\n <p class=\"font-semibold text-word-1 text-14\">\n {{ title }}\n </p>\n <div class=\"flex items-center gap-8 text-12 text-word-3\">\n <VvIcon name=\"ri:time-line\" class=\"text-14 shrink-0\" />\n <time :datetime=\"toolPart.input.startDate\">{{\n dateDisplay\n }}</time>\n </div>\n <div\n v-if=\"eventLocation\"\n class=\"flex items-center gap-8 text-12 text-word-3\">\n <VvIcon name=\"ri:map-pin-line\" class=\"text-14 shrink-0\" />\n <a\n v-if=\"eventLocation.startsWith('http')\"\n :href=\"eventLocation\"\n :target=\"\n isSameSite(eventLocation) ? undefined : '_blank'\n \"\n :rel=\"\n isSameSite(eventLocation)\n ? undefined\n : 'noopener noreferrer'\n \"\n class=\"underline truncate\">\n {{ eventLocation }}\n </a>\n <span v-else>{{ eventLocation }}</span>\n </div>\n <div\n v-if=\"additionalInfo\"\n class=\"flex items-start gap-8 text-12 text-word-3\">\n <VvIcon\n name=\"ri:sticky-note-line\"\n class=\"text-14 shrink-0 mt-1\" />\n <span>{{ additionalInfo }}</span>\n </div>\n </div>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useClipboard } from '@vueuse/core'\n import { isSameSite } from 'utils'\n import { useShortUrlResolver } from 'composables'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const { copy, copied } = useClipboard()\n const { d } = useI18n()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title: string\n startDate: string\n endDate: string\n location?: string\n additionalInfo?: string\n allDay?: boolean\n }\n }\n return part\n })\n\n // The event leaves the app (an .ics file, Google or Outlook, the\n // clipboard), so a short url the model copied from a tool becomes its real\n // target there, and on the card that shows what will go out.\n const { resolveText } = useShortUrlResolver()\n const title = resolveText(() => toolPart.value.input?.title)\n const eventLocation = resolveText(() => toolPart.value.input?.location)\n const additionalInfo = resolveText(\n () => toolPart.value.input?.additionalInfo,\n )\n\n const dateDisplay = computed(() => {\n const input = toolPart.value.input\n if (!input) {\n return ''\n }\n const { startDate, endDate, allDay } = input\n const start = new Date(startDate)\n const end = new Date(endDate)\n const startDay = startDate.slice(0, 10)\n const endDay = endDate.slice(0, 10)\n if (allDay) {\n if (startDay === endDay) {\n return d(start, 'date-medium')\n }\n return `${d(start, 'date-medium')} - ${d(end, 'date-medium')}`\n }\n if (startDay === endDay) {\n return `${d(start, 'date-time-medium')} - ${d(end, 'time')}`\n }\n return `${d(start, 'date-time-medium')} - ${d(end, 'date-time-medium')}`\n })\n\n const calendarStart = computed(() =>\n toolPart.value.input ? new Date(toolPart.value.input.startDate) : null,\n )\n\n const calendarDay = computed(\n () => calendarStart.value?.getDate().toString() ?? '',\n )\n\n const calendarMonth = computed(() =>\n calendarStart.value ? d(calendarStart.value, 'month-short') : '',\n )\n\n // Floating time: remove dashes/colons without converting to UTC\n const toIcsDateTime = (iso: string) =>\n iso.replace(/[-:]/g, '').replace(/\\.\\d{3}$/, '')\n\n const escapeIcs = (str: string) =>\n str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/;/g, '\\\\;')\n .replace(/,/g, '\\\\,')\n .replace(/\\n/g, '\\\\n')\n\n const generateIcs = () => {\n const input = toolPart.value.input\n if (!input) {\n return\n }\n const { startDate, endDate } = input\n const ics = [\n 'BEGIN:VCALENDAR',\n 'VERSION:2.0',\n 'PRODID:-//8wave//8bot//EN',\n 'BEGIN:VEVENT',\n `DTSTART:${toIcsDateTime(startDate)}`,\n `DTEND:${toIcsDateTime(endDate)}`,\n `SUMMARY:${escapeIcs(title.value)}`,\n eventLocation.value\n ? `LOCATION:${escapeIcs(eventLocation.value)}`\n : '',\n additionalInfo.value\n ? `DESCRIPTION:${escapeIcs(additionalInfo.value)}`\n : '',\n `DTSTAMP:${new Date()\n .toISOString()\n .replace(/[-:]/g, '')\n .replace(/\\.\\d{3}/, '')}`,\n `UID:${crypto.randomUUID()}@8bot.ai`,\n 'END:VEVENT',\n 'END:VCALENDAR',\n ]\n .filter(Boolean)\n .join('\\r\\n')\n\n const blob = new Blob([ics], { type: 'text/calendar;charset=utf-8' })\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n // Letters of any alphabet: \"Riunione è\" kept its accent out, and a\n // title of none left a file called \".ics\".\n const fileName = title.value.replace(/[^\\p{L}\\p{N}\\s-]/gu, '').trim()\n a.download = `${fileName || 'event'}.ics`\n a.click()\n URL.revokeObjectURL(url)\n }\n\n const openGoogleCalendar = () => {\n const input = toolPart.value.input\n if (!input) {\n return\n }\n const start = toIcsDateTime(input.startDate)\n const end = toIcsDateTime(input.endDate)\n const params = new URLSearchParams({\n action: 'TEMPLATE',\n text: title.value,\n dates: `${start}/${end}`,\n })\n if (eventLocation.value) {\n params.set('location', eventLocation.value)\n }\n if (additionalInfo.value) {\n params.set('details', additionalInfo.value)\n }\n window.open(\n `https://calendar.google.com/calendar/render?${params.toString()}`,\n '_blank',\n )\n }\n\n const openOutlook = () => {\n const input = toolPart.value.input\n if (!input) {\n return\n }\n const params = new URLSearchParams({\n subject: title.value,\n startdt: input.startDate,\n enddt: input.endDate,\n })\n if (eventLocation.value) {\n params.set('location', eventLocation.value)\n }\n if (additionalInfo.value) {\n params.set('body', additionalInfo.value)\n }\n window.open(\n `https://outlook.office.com/calendar/0/action/compose?${params.toString()}`,\n '_blank',\n )\n }\n\n const copyEvent = () => {\n const input = toolPart.value.input\n if (!input) {\n return\n }\n const lines = [title.value, dateDisplay.value]\n if (eventLocation.value) {\n lines.push(eventLocation.value)\n }\n if (additionalInfo.value) {\n lines.push(additionalInfo.value)\n }\n copy(lines.join('\\n'))\n }\n</script>\n\n<template>\n <div\n v-if=\"toolPart?.input\"\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon name=\"ri:calendar-event-line\" class=\"text-16\" />\n <strong class=\"font-bold\">{{ $t('label.calendarEvent') }}</strong>\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n @click=\"copyEvent\" />\n <VvDropdown\n v-bind=\"{\n placement: 'bottom-end',\n modifiers: 'menu',\n flip: true,\n offset: 3,\n strategy: 'fixed',\n }\">\n <VvButton\n icon=\"ri:calendar-line\"\n modifiers=\"action-quiet-small\"\n :label=\"$t('action.addToCalendar')\" />\n <template #items>\n <VvDropdownAction @click=\"openGoogleCalendar\">\n <VvIcon name=\"ri:google-line\" />\n Google Calendar\n </VvDropdownAction>\n <VvDropdownAction @click=\"openOutlook\">\n <VvIcon name=\"ri:microsoft-line\" />\n Outlook\n </VvDropdownAction>\n <VvDropdownAction @click=\"generateIcs\">\n <VvIcon name=\"ri:download-line\" />\n {{ $t('action.downloadIcs') }}\n </VvDropdownAction>\n </template>\n </VvDropdown>\n </VvButtonGroup>\n </div>\n <div class=\"p-sm flex gap-sm items-start\">\n <div\n class=\"shrink-0 w-44 rounded-xl overflow-hidden border border-surface-3 text-center\">\n <div\n class=\"bg-brand px-8 py-2 text-brand-contrast text-10 font-bold uppercase tracking-wide\">\n {{ calendarMonth }}\n </div>\n <div\n class=\"bg-surface-1 py-4 text-word-1 text-24 font-bold leading-none\">\n {{ calendarDay }}\n </div>\n </div>\n <div class=\"flex flex-col gap-4 min-w-0\">\n <p class=\"font-semibold text-word-1 text-14\">\n {{ title }}\n </p>\n <div class=\"flex items-center gap-8 text-12 text-word-3\">\n <VvIcon name=\"ri:time-line\" class=\"text-14 shrink-0\" />\n <time :datetime=\"toolPart.input.startDate\">{{\n dateDisplay\n }}</time>\n </div>\n <div\n v-if=\"eventLocation\"\n class=\"flex items-center gap-8 text-12 text-word-3\">\n <VvIcon name=\"ri:map-pin-line\" class=\"text-14 shrink-0\" />\n <a\n v-if=\"eventLocation.startsWith('http')\"\n :href=\"eventLocation\"\n :target=\"\n isSameSite(eventLocation) ? undefined : '_blank'\n \"\n :rel=\"\n isSameSite(eventLocation)\n ? undefined\n : 'noopener noreferrer'\n \"\n class=\"underline truncate\">\n {{ eventLocation }}\n </a>\n <span v-else>{{ eventLocation }}</span>\n </div>\n <div\n v-if=\"additionalInfo\"\n class=\"flex items-start gap-8 text-12 text-word-3\">\n <VvIcon\n name=\"ri:sticky-note-line\"\n class=\"text-14 shrink-0 mt-1\" />\n <span>{{ additionalInfo }}</span>\n </div>\n </div>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAOI,IAAM2D,IAAQC,GAIR,EAAE,SAAM,cAAWxB,EAAa,GAChC,EAAE,SAAMF,EAAQ,GAEhB2B,IAAWtC,QACAoC,EAAM,IAWtB,GAKK,EAAE,mBAAgBjB,EAAoB,GACtCoB,IAAQC,QAAkBF,EAAS,MAAM,OAAO,KAAK,GACrDG,IAAgBD,QAAkBF,EAAS,MAAM,OAAO,QAAQ,GAChEI,IAAiBF,QACbF,EAAS,MAAM,OAAO,cAChC,GAEMK,IAAc3C,QAAe;GAC/B,IAAM4C,IAAQN,EAAS,MAAM;GAC7B,IAAI,CAACM,GACD,OAAO;GAEX,IAAM,EAAE,cAAW,YAAS,cAAWA,GACjCC,IAAQ,IAAI,KAAKC,CAAS,GAC1BC,IAAM,IAAI,KAAKC,CAAO,GACtBC,IAAWH,EAAU,MAAM,GAAG,EAAE,GAChCI,IAASF,EAAQ,MAAM,GAAG,EAAE;GAUlC,OATIG,IACIF,MAAaC,IACNE,EAAEP,GAAO,aAAa,IAE1B,GAAGO,EAAEP,GAAO,aAAa,EAAE,KAAKO,EAAEL,GAAK,aAAa,MAE3DE,MAAaC,IACN,GAAGE,EAAEP,GAAO,kBAAkB,EAAE,KAAKO,EAAEL,GAAK,MAAM,MAEtD,GAAGK,EAAEP,GAAO,kBAAkB,EAAE,KAAKO,EAAE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as l, v as u, w as d, wt as f, y as p, z as m } from "./vue.runtime.esm-bundler-C2U5uTqB.js";
|
|
2
2
|
import { i as h } from "./dist-B3-I_01H.js";
|
|
3
3
|
import { a as g, t as _ } from "./index.es-C7ON2BA3.js";
|
|
4
4
|
import { t as v } from "./VvButtonLocalized-KEhD3ono.js";
|
|
5
|
+
import { n as y } from "./useShortUrlResolver-C30QRypC.js";
|
|
5
6
|
// ../../packages/components/src/chat/PkToolShowQrCode.vue?vue&type=script&setup=true&lang.ts
|
|
6
7
|
o(), n(), c();
|
|
7
|
-
var
|
|
8
|
+
var b = {
|
|
8
9
|
key: 0,
|
|
9
10
|
class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-surface"
|
|
10
|
-
},
|
|
11
|
+
}, x = { class: "px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8" }, S = { class: "font-bold" }, C = { class: "p-sm flex flex-col items-center" }, w = ["innerHTML"], T = {
|
|
11
12
|
key: 0,
|
|
12
13
|
class: "text-12 text-word-3 text-center"
|
|
13
|
-
},
|
|
14
|
+
}, E = /* @__PURE__ */ d({
|
|
14
15
|
__name: "PkToolShowQrCode",
|
|
15
16
|
props: { part: { type: null } },
|
|
16
17
|
setup(n) {
|
|
17
|
-
let o = n, { copy: c, copied: d } = h(),
|
|
18
|
-
e(async () => {
|
|
19
|
-
let e = T.value.input?.content;
|
|
18
|
+
let o = n, { copy: c, copied: d } = h(), E = a(() => o.part), { resolveText: D } = y(), O = D(() => E.value.input?.content), k = i(""), A = i();
|
|
19
|
+
e(O, async (e) => {
|
|
20
20
|
if (!e) return;
|
|
21
|
-
let { default: t } = await import("https://cdn.jsdelivr.net/npm/qrcode@1/+esm")
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
let { default: t } = await import("https://cdn.jsdelivr.net/npm/qrcode@1/+esm"), n = async (e) => {
|
|
22
|
+
try {
|
|
23
|
+
return await t.toString(e, { type: "svg" });
|
|
24
|
+
} catch {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}, r = await n(e) ?? await n(E.value.input?.content ?? "");
|
|
28
|
+
r && O.value === e && (k.value = r);
|
|
29
|
+
}, { immediate: !0 });
|
|
30
|
+
let j = async () => {
|
|
31
|
+
let e = A.value?.querySelector("svg");
|
|
26
32
|
if (!e) return;
|
|
27
33
|
let t = new XMLSerializer().serializeToString(e), n = new Blob([t], { type: "image/svg+xml;charset=utf-8" }), r = URL.createObjectURL(n), i = document.createElement("canvas");
|
|
28
34
|
i.width = 512, i.height = 512;
|
|
@@ -35,12 +41,12 @@ var y = {
|
|
|
35
41
|
};
|
|
36
42
|
return (e, n) => {
|
|
37
43
|
let i = _, a = v, o = g;
|
|
38
|
-
return
|
|
44
|
+
return E.value?.input ? (m(), p("div", b, [r("div", x, [
|
|
39
45
|
t(i, {
|
|
40
46
|
name: "ri:qr-code-line",
|
|
41
47
|
class: "text-16"
|
|
42
48
|
}),
|
|
43
|
-
r("strong",
|
|
49
|
+
r("strong", S, s(e.$t("label.qrCode")), 1),
|
|
44
50
|
t(o, {
|
|
45
51
|
modifiers: "compact",
|
|
46
52
|
class: "ml-auto shrink-0"
|
|
@@ -49,24 +55,24 @@ var y = {
|
|
|
49
55
|
modifiers: "action-quiet-small",
|
|
50
56
|
icon: f(d) ? "ri:check-line" : "ri:file-copy-line",
|
|
51
57
|
label: f(d) ? e.$t("action.copied") : e.$t("action.copy"),
|
|
52
|
-
onClick: n[0] ||= (e) => f(c)(
|
|
58
|
+
onClick: n[0] ||= (e) => f(c)(f(O))
|
|
53
59
|
}, null, 8, ["icon", "label"]), t(a, {
|
|
54
60
|
modifiers: "action-quiet-small",
|
|
55
61
|
icon: "ri:download-line",
|
|
56
62
|
label: e.$t("action.download"),
|
|
57
|
-
onClick:
|
|
63
|
+
onClick: j
|
|
58
64
|
}, null, 8, ["label"])]),
|
|
59
65
|
_: 1
|
|
60
66
|
})
|
|
61
|
-
]), r("div",
|
|
67
|
+
]), r("div", C, [r("div", {
|
|
62
68
|
ref_key: "qrContainerRef",
|
|
63
|
-
ref:
|
|
69
|
+
ref: A,
|
|
64
70
|
class: "w-144 h-144",
|
|
65
|
-
innerHTML:
|
|
66
|
-
}, null, 8,
|
|
71
|
+
innerHTML: k.value
|
|
72
|
+
}, null, 8, w), E.value.input.label ? (m(), p("p", T, s(E.value.input.label), 1)) : u("", !0)])])) : u("", !0);
|
|
67
73
|
};
|
|
68
74
|
}
|
|
69
75
|
});
|
|
70
|
-
export {
|
|
76
|
+
export { E as default };
|
|
71
77
|
|
|
72
|
-
//# sourceMappingURL=PkToolShowQrCode-
|
|
78
|
+
//# sourceMappingURL=PkToolShowQrCode-DGMhVUbp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PkToolShowQrCode-DGMhVUbp.js","names":["$t","__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_withCtx","_unref","_createCommentVNode","_sfc_main","watch","createVNode","init_shared_esm_bundler","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","withCtx","createCommentVNode","defineComponent","unref","createElementBlock","openBlock","useClipboard","au","Ce","VvButtonLocalized","useShortUrlResolver","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","PkToolShowQrCode_default","props","__props","toolPart","content","resolveText","svgContent","qrContainerRef","value","QRCode","draw","text","svg","downloadQr","svgEl","svgData","svgBlob","svgUrl","canvas","ctx","img","a","_component_VvIcon","_component_VvButton","_component_VvButtonGroup","_ctx","copied","_cache","copy"],"sources":["../../../../packages/components/src/chat/PkToolShowQrCode.vue","../../../../packages/components/src/chat/PkToolShowQrCode.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref, watch } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useShortUrlResolver } from 'composables'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const { copy, copied } = useClipboard()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n content: string\n label?: string\n }\n }\n return part\n })\n\n // The code leaves the app (scanned, downloaded, copied): a short url the\n // model copied from a tool is encoded as its real target, drawn again\n // once the resolver answers.\n const { resolveText } = useShortUrlResolver()\n const content = resolveText(() => toolPart.value.input?.content)\n\n const svgContent = ref('')\n const qrContainerRef = ref<HTMLElement>()\n\n watch(\n content,\n async (value) => {\n if (!value) {\n return\n }\n const { default: QRCode } = await import('qrcode')\n const draw = async (text: string) => {\n try {\n return await QRCode.toString(text, { type: 'svg' })\n } catch {\n return undefined\n }\n }\n // An address past what a QR code holds: the short link the model\n // wrote still fits, and still leads there.\n const svg =\n (await draw(value)) ??\n (await draw(toolPart.value.input?.content ?? ''))\n // A later value may have been drawn while this one was.\n if (svg && content.value === value) {\n svgContent.value = svg\n }\n },\n { immediate: true },\n )\n\n const downloadQr = async () => {\n const svgEl = qrContainerRef.value?.querySelector('svg')\n if (!svgEl) {\n return\n }\n const svgData = new XMLSerializer().serializeToString(svgEl)\n const svgBlob = new Blob([svgData], {\n type: 'image/svg+xml;charset=utf-8',\n })\n const svgUrl = URL.createObjectURL(svgBlob)\n\n const canvas = document.createElement('canvas')\n canvas.width = 512\n canvas.height = 512\n const ctx = canvas.getContext('2d')\n const img = new Image()\n img.onload = () => {\n ctx?.drawImage(img, 0, 0, 512, 512)\n URL.revokeObjectURL(svgUrl)\n const a = document.createElement('a')\n a.href = canvas.toDataURL('image/png')\n a.download = 'qrcode.png'\n a.click()\n }\n img.src = svgUrl\n }\n</script>\n\n<template>\n <div\n v-if=\"toolPart?.input\"\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon name=\"ri:qr-code-line\" class=\"text-16\" />\n <strong class=\"font-bold\">{{ $t('label.qrCode') }}</strong>\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n @click=\"copy(content)\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n @click=\"downloadQr\" />\n </VvButtonGroup>\n </div>\n <div class=\"p-sm flex flex-col items-center\">\n <div ref=\"qrContainerRef\" class=\"w-144 h-144\" v-html=\"svgContent\" />\n <p\n v-if=\"toolPart.input.label\"\n class=\"text-12 text-word-3 text-center\">\n {{ toolPart.input.label }}\n </p>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref, watch } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useShortUrlResolver } from 'composables'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const { copy, copied } = useClipboard()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n content: string\n label?: string\n }\n }\n return part\n })\n\n // The code leaves the app (scanned, downloaded, copied): a short url the\n // model copied from a tool is encoded as its real target, drawn again\n // once the resolver answers.\n const { resolveText } = useShortUrlResolver()\n const content = resolveText(() => toolPart.value.input?.content)\n\n const svgContent = ref('')\n const qrContainerRef = ref<HTMLElement>()\n\n watch(\n content,\n async (value) => {\n if (!value) {\n return\n }\n const { default: QRCode } = await import('qrcode')\n const draw = async (text: string) => {\n try {\n return await QRCode.toString(text, { type: 'svg' })\n } catch {\n return undefined\n }\n }\n // An address past what a QR code holds: the short link the model\n // wrote still fits, and still leads there.\n const svg =\n (await draw(value)) ??\n (await draw(toolPart.value.input?.content ?? ''))\n // A later value may have been drawn while this one was.\n if (svg && content.value === value) {\n svgContent.value = svg\n }\n },\n { immediate: true },\n )\n\n const downloadQr = async () => {\n const svgEl = qrContainerRef.value?.querySelector('svg')\n if (!svgEl) {\n return\n }\n const svgData = new XMLSerializer().serializeToString(svgEl)\n const svgBlob = new Blob([svgData], {\n type: 'image/svg+xml;charset=utf-8',\n })\n const svgUrl = URL.createObjectURL(svgBlob)\n\n const canvas = document.createElement('canvas')\n canvas.width = 512\n canvas.height = 512\n const ctx = canvas.getContext('2d')\n const img = new Image()\n img.onload = () => {\n ctx?.drawImage(img, 0, 0, 512, 512)\n URL.revokeObjectURL(svgUrl)\n const a = document.createElement('a')\n a.href = canvas.toDataURL('image/png')\n a.download = 'qrcode.png'\n a.click()\n }\n img.src = svgUrl\n }\n</script>\n\n<template>\n <div\n v-if=\"toolPart?.input\"\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon name=\"ri:qr-code-line\" class=\"text-16\" />\n <strong class=\"font-bold\">{{ $t('label.qrCode') }}</strong>\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n @click=\"copy(content)\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n @click=\"downloadQr\" />\n </VvButtonGroup>\n </div>\n <div class=\"p-sm flex flex-col items-center\">\n <div ref=\"qrContainerRef\" class=\"w-144 h-144\" v-html=\"svgContent\" />\n <p\n v-if=\"toolPart.input.label\"\n class=\"text-12 text-word-3 text-center\">\n {{ toolPart.input.label }}\n </p>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;EAKI,IAAMwC,IAAQC,GAIR,EAAE,SAAM,cAAWb,EAAa,GAEhCc,IAAWxB,QACAsB,EAAM,IAOtB,GAKK,EAAE,mBAAgBR,EAAoB,GACtCW,IAAUC,QAAkBF,EAAS,MAAM,OAAO,OAAO,GAEzDG,IAAa5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K;KAAkB,OAAM;;IACrCvD,EAA2D,UAA3D6B,GAA2D3B,EAA9BR,EAAAA,GAAE,cAAA,CAAA,GAAA,CAAA;IAC/BO,EAWgBwD,GAAA;KAXD,WAAU;KAAU,OAAM;;KACrC,SAAAtD,QAI6B,CAJ7BF,EAI6BuD,GAAA;MAHzB,WAAU;MACT,MAAMpD,EAAAuD,CAAA,IAAM,kBAAA;MACZ,OAAOvD,EAAAuD,CAAA,IAASjE,EAAAA,GAAE,eAAA,IAAoBA,EAAAA,GAAE,aAAA;MACxC,SAAK,AAAAkE,EAAA,QAAA,MAAExD,EAAAyD,CAAA,CAAI,CAACzD,EAAAiC,CAAA,CAAO;K,gCACxBpC,EAI0BuD,GAAA;MAHtB,WAAU;MACV,MAAK;MACJ,OAAO9D,EAAAA,GAAE,iBAAA;MACT,SAAOoD;;;;G,IAGpB9C,EAOM,OAPN8B,GAOM,CANF9B,EAAoE,OAAA;IAA3D,SAAA;IAAJ,KAAIwC;IAAiB,OAAM;IAAc,WAAQD,EAAA;G,gBAE5CH,EAAA,MAAS,MAAM,SADzBtC,EAAA,GAAAC,EAII,KAJJiC,GAII9B,EADGkC,EAAA,MAAS,MAAM,KAAK,GAAA,CAAA,K"}
|
package/dist/ai-elements.es.js
CHANGED
|
@@ -15488,7 +15488,7 @@ var sy = {
|
|
|
15488
15488
|
requestOAuthConnection: T(() => import("./_chunks/PkToolRequestOAuthConnection-BU-4Sm3z.js")),
|
|
15489
15489
|
shareDocument: T(() => import("./_chunks/PkToolShareDocument-Buzu27rQ.js")),
|
|
15490
15490
|
showArtifact: T(() => import("./_chunks/PkToolShowArtifact-utxGuLLt.js")),
|
|
15491
|
-
showCalendarEvent: T(() => import("./_chunks/PkToolShowCalendarEvent-
|
|
15491
|
+
showCalendarEvent: T(() => import("./_chunks/PkToolShowCalendarEvent-DWtTo28t.js")),
|
|
15492
15492
|
showComparison: T(() => import("./_chunks/PkToolShowComparison-7NCImocZ.js")),
|
|
15493
15493
|
showContactForm: T(() => import("./_chunks/PkToolShowContactForm-DTtE93D3.js")),
|
|
15494
15494
|
showDiagram: T(() => import("./_chunks/PkToolShowDiagram-BHd-C_cx.js")),
|
|
@@ -15499,7 +15499,7 @@ var sy = {
|
|
|
15499
15499
|
showForm: T(() => import("./_chunks/PkToolShowForm-I4pKopEI.js")),
|
|
15500
15500
|
showMultipleChoice: T(() => import("./_chunks/PkToolShowForm-I4pKopEI.js")),
|
|
15501
15501
|
showProductList: T(() => import("./_chunks/PkToolShowProductList-CcdOQoxf.js")),
|
|
15502
|
-
showQrCode: T(() => import("./_chunks/PkToolShowQrCode-
|
|
15502
|
+
showQrCode: T(() => import("./_chunks/PkToolShowQrCode-DGMhVUbp.js")),
|
|
15503
15503
|
showSources: T(() => import("./_chunks/PkToolShowSources-DLmVS3bL.js")),
|
|
15504
15504
|
showSuggestedReply: T(() => import("./_chunks/PkToolShowSuggestedReply-Cv-WVCFN.js")),
|
|
15505
15505
|
showVideo: T(() => import("./_chunks/PkToolShowVideo-D_K95gTR.js")),
|
package/dist-vue/PkChatbot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbot-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbot-CLOfTLQy.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbotMessages-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbotMessages-BxkCGmqV.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbotViewChat-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbotViewChat-BwXOt2WW.js";
|