@8wave/ai-elements 0.125.0-beta.31 → 0.125.0-beta.33
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/{PkChatbotFilePreview-CqxtVySb.js → PkChatbotFilePreview-DsRAk1js.js} +2 -2
- package/dist/_chunks/{PkChatbotFilePreview-CqxtVySb.js.map → PkChatbotFilePreview-DsRAk1js.js.map} +1 -1
- package/dist/_chunks/PkImageEditorDialog-BQwM06kT.js +939 -0
- package/dist/_chunks/PkImageEditorDialog-BQwM06kT.js.map +1 -0
- package/dist/_chunks/{PkStreamingMarkdown-BqDooeUU.js → PkStreamingMarkdown-CjL7l_3E.js} +2 -2
- package/dist/_chunks/{PkStreamingMarkdown-BqDooeUU.js.map → PkStreamingMarkdown-CjL7l_3E.js.map} +1 -1
- package/dist/_chunks/{PkToolChatFile-DpStX3wS.js → PkToolChatFile-weptM8iA.js} +2 -2
- package/dist/_chunks/{PkToolChatFile-DpStX3wS.js.map → PkToolChatFile-weptM8iA.js.map} +1 -1
- package/dist/_chunks/{PkToolShareDocument-BvHklbzb.js → PkToolShareDocument-D5K3uJ2x.js} +2 -2
- package/dist/_chunks/{PkToolShareDocument-BvHklbzb.js.map → PkToolShareDocument-D5K3uJ2x.js.map} +1 -1
- package/dist/_chunks/{PkToolShowArtifact-YPwJLLlW.js → PkToolShowArtifact-Bm2zS5YS.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-YPwJLLlW.js.map → PkToolShowArtifact-Bm2zS5YS.js.map} +1 -1
- package/dist/_chunks/{PkToolShowContactForm-CTc1mbA8.js → PkToolShowContactForm-BKJCv5To.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-CTc1mbA8.js.map → PkToolShowContactForm-BKJCv5To.js.map} +1 -1
- package/dist/_chunks/{PkToolShowDiagram-COt1Z3q9.js → PkToolShowDiagram-jpaEAi2X.js} +2 -2
- package/dist/_chunks/{PkToolShowDiagram-COt1Z3q9.js.map → PkToolShowDiagram-jpaEAi2X.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-DT5EyYVY.js → PkToolShowForm-DvAcJgDP.js} +2 -2
- package/dist/_chunks/{PkToolShowForm-DT5EyYVY.js.map → PkToolShowForm-DvAcJgDP.js.map} +1 -1
- package/dist/_chunks/{PkToolShowImageGallery-DKrCrrB5.js → PkToolShowImageGallery-D0htuXNL.js} +4 -4
- package/dist/_chunks/{PkToolShowImageGallery-DKrCrrB5.js.map → PkToolShowImageGallery-D0htuXNL.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-CzSknPo6.js → PkToolShowSources-Cfj6iRGj.js} +2 -2
- package/dist/_chunks/{PkToolShowSources-CzSknPo6.js.map → PkToolShowSources-Cfj6iRGj.js.map} +1 -1
- package/dist/_chunks/{useLightbox-D2Zi-Fpe.js → useLightbox-C54BCSbU.js} +130 -89
- package/dist/_chunks/useLightbox-C54BCSbU.js.map +1 -0
- package/dist/ai-elements.es.js +2774 -2721
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotEmptyState.js +1 -1
- package/dist-vue/PkChatbotFilePreview.js +1 -1
- package/dist-vue/PkChatbotInput.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotSteps.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/_chunks/{PkChatbot-DLgPqMWd.js → PkChatbot-Bc2hlwFO.js} +3 -3
- package/dist-vue/_chunks/{PkChatbot-DLgPqMWd.js.map → PkChatbot-Bc2hlwFO.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotEmptyState-DMPEj1Qa.js → PkChatbotEmptyState-NHarCaDm.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-DMPEj1Qa.js.map → PkChatbotEmptyState-NHarCaDm.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotFilePreview-j_8sDZUE.js → PkChatbotFilePreview-BIta8Yg-.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotFilePreview-j_8sDZUE.js.map → PkChatbotFilePreview-BIta8Yg-.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotInput-TamSYiA7.js → PkChatbotInput-BSzDRoDD.js} +192 -181
- package/dist-vue/_chunks/PkChatbotInput-BSzDRoDD.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotMessages-bPBOSAv7.js → PkChatbotMessages-DEMKZDCb.js} +17 -17
- package/dist-vue/_chunks/{PkChatbotMessages-bPBOSAv7.js.map → PkChatbotMessages-DEMKZDCb.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotSteps-pibgqxus.js → PkChatbotSteps-DGQoYxJ9.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotSteps-pibgqxus.js.map → PkChatbotSteps-DGQoYxJ9.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-y60IA9aQ.js → PkChatbotViewChat-aKi08vCz.js} +440 -431
- package/dist-vue/_chunks/PkChatbotViewChat-aKi08vCz.js.map +1 -0
- package/dist-vue/_chunks/{PkFilePreview-CPSYaOV7.js → PkFilePreview-D2HInDoA.js} +2 -2
- package/dist-vue/_chunks/{PkFilePreview-CPSYaOV7.js.map → PkFilePreview-D2HInDoA.js.map} +1 -1
- package/dist-vue/_chunks/{PkFilePreviewDialog-D6zFO_H_.js → PkFilePreviewDialog-jxcUSzPx.js} +2 -2
- package/dist-vue/_chunks/{PkFilePreviewDialog-D6zFO_H_.js.map → PkFilePreviewDialog-jxcUSzPx.js.map} +1 -1
- package/dist-vue/_chunks/PkImageEditorDialog-Dn3HV_ny.js +934 -0
- package/dist-vue/_chunks/PkImageEditorDialog-Dn3HV_ny.js.map +1 -0
- package/dist-vue/_chunks/{PkStreamingMarkdown-B3VWOaWb.js → PkStreamingMarkdown-DdOv86Eb.js} +11 -11
- package/dist-vue/_chunks/{PkStreamingMarkdown-B3VWOaWb.js.map → PkStreamingMarkdown-DdOv86Eb.js.map} +1 -1
- package/dist-vue/_chunks/{PkSvgViewer-BsdSOBpH.js → PkSvgViewer-vkd5Dluw.js} +2 -2
- package/dist-vue/_chunks/{PkSvgViewer-BsdSOBpH.js.map → PkSvgViewer-vkd5Dluw.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolChatFile-PXpiJLZ6.js → PkToolChatFile-8nx166iM.js} +2 -2
- package/dist-vue/_chunks/{PkToolChatFile-PXpiJLZ6.js.map → PkToolChatFile-8nx166iM.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShareDocument-cMUqik6v.js → PkToolShareDocument-CspvFwRR.js} +2 -2
- package/dist-vue/_chunks/{PkToolShareDocument-cMUqik6v.js.map → PkToolShareDocument-CspvFwRR.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowArtifact-DouCz_dZ.js → PkToolShowArtifact-BppP_xSN.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-DouCz_dZ.js.map → PkToolShowArtifact-BppP_xSN.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowContactForm-BmiNlFfx.js → PkToolShowContactForm-Bm0icz24.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-BmiNlFfx.js.map → PkToolShowContactForm-Bm0icz24.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-D6mYTDU-.js → PkToolShowDiagram-CgukB1Ss.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-D6mYTDU-.js.map → PkToolShowDiagram-CgukB1Ss.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-CksTiimD.js → PkToolShowForm-CyyN7GQP.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowForm-CksTiimD.js.map → PkToolShowForm-CyyN7GQP.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowImageGallery-B-lVY0xH.js → PkToolShowImageGallery-zQF_lsxI.js} +5 -5
- package/dist-vue/_chunks/{PkToolShowImageGallery-B-lVY0xH.js.map → PkToolShowImageGallery-zQF_lsxI.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowLocation-B8FE_Sqd.js → PkToolShowLocation-WdRqG8Wi.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowLocation-B8FE_Sqd.js.map → PkToolShowLocation-WdRqG8Wi.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-Dcq3Kdse.js → PkToolShowProductList-DW_P0gC2.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-Dcq3Kdse.js.map → PkToolShowProductList-DW_P0gC2.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-DApWmwvk.js → PkToolShowSources-BugMybUx.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSources-DApWmwvk.js.map → PkToolShowSources-BugMybUx.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowVideo-CjrYh9-q.js → PkToolShowVideo-BW7aRKs_.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowVideo-CjrYh9-q.js.map → PkToolShowVideo-BW7aRKs_.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-DSIAizw-.js → PkToolShowWebPages-DxKimT-2.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-DSIAizw-.js.map → PkToolShowWebPages-DxKimT-2.js.map} +1 -1
- package/dist-vue/_chunks/{useLightbox-FDyQrPWe.js → useLightbox-Ctl9zaMX.js} +132 -91
- package/dist-vue/_chunks/useLightbox-Ctl9zaMX.js.map +1 -0
- package/dist-vue/composables.js +36 -2
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/index.js +22 -22
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +34 -0
- package/dist-vue/packages/components/src/chat/PkChatbotInput.d.ts +5 -0
- package/dist-vue/packages/components/src/chat/PkImageEditor.d.ts +11 -9
- package/dist-vue/packages/components/src/chat/PkImageEditorDialog.d.ts +12 -5
- package/dist-vue/packages/components/src/chat/imageEdits.d.ts +77 -1
- package/dist-vue/packages/components/src/composables/useLightbox.d.ts +26 -0
- package/dist-vue/style.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/PkImageEditorDialog-Cq8y_PtC.js +0 -555
- package/dist/_chunks/PkImageEditorDialog-Cq8y_PtC.js.map +0 -1
- package/dist/_chunks/useLightbox-D2Zi-Fpe.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotInput-TamSYiA7.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotViewChat-y60IA9aQ.js.map +0 -1
- package/dist-vue/_chunks/PkImageEditorDialog-BLUyILVi.js +0 -550
- package/dist-vue/_chunks/PkImageEditorDialog-BLUyILVi.js.map +0 -1
- package/dist-vue/_chunks/useLightbox-FDyQrPWe.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,555 +0,0 @@
|
|
|
1
|
-
import { Et as e, F as t, I as n, J as r, L as i, N as a, Ot as o, Q as s, S as c, Tt as l, X as u, _ as d, f, g as p, gt as m, h, k as g, kt as _, ot as v, q as y, tt as b, v as x, vt as S, w as C, wt as w, x as T, y as E, z as D } from "./vue.runtime.esm-bundler-C2U5uTqB.js";
|
|
2
|
-
import { r as ee } from "./vue-i18n-POtLvOl1.js";
|
|
3
|
-
import { h as O, y as k } from "./dist-D6oUr4J_.js";
|
|
4
|
-
import { a as A, d as j, s as M, t as te } from "./index.es-D-aOuzzp.js";
|
|
5
|
-
import { t as N } from "./VvButtonLocalized-B32dBwWJ.js";
|
|
6
|
-
import { t as P } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
|
|
7
|
-
import { t as F } from "./PkEditorRadioButtons-ClUWPayk.js";
|
|
8
|
-
// ../../packages/components/src/chat/imageEdits.ts
|
|
9
|
-
var ne = 16777216, re = .92, I = 12, L = 32, R = {
|
|
10
|
-
"image/jpeg": "jpg",
|
|
11
|
-
"image/png": "png",
|
|
12
|
-
"image/webp": "webp"
|
|
13
|
-
};
|
|
14
|
-
function ie(e, t = ne) {
|
|
15
|
-
let n = e.width * e.height;
|
|
16
|
-
if (n <= t) return {
|
|
17
|
-
width: e.width,
|
|
18
|
-
height: e.height
|
|
19
|
-
};
|
|
20
|
-
let r = Math.sqrt(t / n);
|
|
21
|
-
return {
|
|
22
|
-
width: Math.max(1, Math.floor(e.width * r)),
|
|
23
|
-
height: Math.max(1, Math.floor(e.height * r))
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function ae(e, t) {
|
|
27
|
-
let { width: n, height: r } = e;
|
|
28
|
-
for (let e of t) e.kind === "rotate" ? [n, r] = [r, n] : e.kind === "crop" && ({width: n, height: r} = e.rect);
|
|
29
|
-
return {
|
|
30
|
-
width: n,
|
|
31
|
-
height: r
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function oe(e) {
|
|
35
|
-
return Math.max(I, Math.round(Math.min(e.width, e.height) / L));
|
|
36
|
-
}
|
|
37
|
-
function z(e, t, n, r) {
|
|
38
|
-
let i = Y(e.x, 0, n.width), a = Y(e.y, 0, n.height), o = t.x - i, s = t.y - a, c = o < 0 ? i : n.width - i, l = s < 0 ? a : n.height - a, u = Math.min(Math.abs(o), c), d = Math.min(Math.abs(s), l);
|
|
39
|
-
if (r) {
|
|
40
|
-
let e = Math.max(Math.abs(o), Math.abs(s) * r);
|
|
41
|
-
u = Math.min(e, c, l * r), d = u / r;
|
|
42
|
-
}
|
|
43
|
-
let f = Math.round(o < 0 ? i - u : i), p = Math.round(s < 0 ? a - d : a);
|
|
44
|
-
return {
|
|
45
|
-
x: f,
|
|
46
|
-
y: p,
|
|
47
|
-
width: Math.min(Math.round(u), n.width - f),
|
|
48
|
-
height: Math.min(Math.round(d), n.height - p)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function B(e, t, n, r) {
|
|
52
|
-
let i = (e, t) => e + 2 * r > t ? t : e + r;
|
|
53
|
-
for (let r = 0; r < n; r = i(r, n)) {
|
|
54
|
-
let a = i(r, n);
|
|
55
|
-
for (let n = 0; n < t; n = i(n, t)) {
|
|
56
|
-
let o = i(n, t), s = 0, c = 0, l = 0, u = 0;
|
|
57
|
-
for (let i = r; i < a; i++) for (let r = n; r < o; r++) {
|
|
58
|
-
let n = (i * t + r) * 4, a = e[n + 3];
|
|
59
|
-
s += e[n] * a, c += e[n + 1] * a, l += e[n + 2] * a, u += a;
|
|
60
|
-
}
|
|
61
|
-
let d = (a - r) * (o - n), f = u > 0 ? [
|
|
62
|
-
s / u,
|
|
63
|
-
c / u,
|
|
64
|
-
l / u,
|
|
65
|
-
u / d
|
|
66
|
-
] : [
|
|
67
|
-
0,
|
|
68
|
-
0,
|
|
69
|
-
0,
|
|
70
|
-
0
|
|
71
|
-
];
|
|
72
|
-
for (let i = r; i < a; i++) for (let r = n; r < o; r++) e.set(f, (i * t + r) * 4);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function V(e, t, n) {
|
|
77
|
-
let r = R[n];
|
|
78
|
-
if (n === t || !r) return e;
|
|
79
|
-
let i = e.lastIndexOf(".");
|
|
80
|
-
return `${i > 0 ? e.slice(0, i) : e}.${r}`;
|
|
81
|
-
}
|
|
82
|
-
async function H(e) {
|
|
83
|
-
let t = await createImageBitmap(e, { imageOrientation: "from-image" });
|
|
84
|
-
try {
|
|
85
|
-
let e = {
|
|
86
|
-
width: t.width,
|
|
87
|
-
height: t.height
|
|
88
|
-
}, n = G(ie(e)), r = K(n);
|
|
89
|
-
return r.imageSmoothingQuality = "high", r.drawImage(t, 0, 0, n.width, n.height), {
|
|
90
|
-
image: n,
|
|
91
|
-
original: e
|
|
92
|
-
};
|
|
93
|
-
} finally {
|
|
94
|
-
t.close();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function se(e, t) {
|
|
98
|
-
let n = G(e);
|
|
99
|
-
K(n).drawImage(e, 0, 0);
|
|
100
|
-
for (let e of t) {
|
|
101
|
-
if (e.kind === "cover") {
|
|
102
|
-
ce(n, e.rect, e.style);
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
let t = e.kind === "rotate" ? q(n, e.turn) : J(n, e.rect);
|
|
106
|
-
W(n), n = t;
|
|
107
|
-
}
|
|
108
|
-
return n;
|
|
109
|
-
}
|
|
110
|
-
function U(e, t) {
|
|
111
|
-
return new Promise((n, r) => {
|
|
112
|
-
e.toBlob((e) => e ? n(e) : r(/* @__PURE__ */ Error("The image could not be written")), t, re);
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
function W(e) {
|
|
116
|
-
e.width = 0, e.height = 0;
|
|
117
|
-
}
|
|
118
|
-
function G(e) {
|
|
119
|
-
let t = document.createElement("canvas");
|
|
120
|
-
return t.width = e.width, t.height = e.height, t;
|
|
121
|
-
}
|
|
122
|
-
function K(e) {
|
|
123
|
-
let t = e.getContext("2d");
|
|
124
|
-
if (!t) throw Error("No 2D canvas in this browser");
|
|
125
|
-
return t;
|
|
126
|
-
}
|
|
127
|
-
function q(e, t) {
|
|
128
|
-
let n = G({
|
|
129
|
-
width: e.height,
|
|
130
|
-
height: e.width
|
|
131
|
-
}), r = K(n);
|
|
132
|
-
return r.translate(n.width / 2, n.height / 2), r.rotate(t * Math.PI / 2), r.drawImage(e, -e.width / 2, -e.height / 2), n;
|
|
133
|
-
}
|
|
134
|
-
function J(e, t) {
|
|
135
|
-
let n = G(t);
|
|
136
|
-
return K(n).drawImage(e, t.x, t.y, t.width, t.height, 0, 0, t.width, t.height), n;
|
|
137
|
-
}
|
|
138
|
-
function ce(e, t, n) {
|
|
139
|
-
let r = K(e);
|
|
140
|
-
if (n === "solid") {
|
|
141
|
-
r.fillStyle = "#000000", r.fillRect(t.x, t.y, t.width, t.height);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
let i = r.getImageData(t.x, t.y, t.width, t.height);
|
|
145
|
-
B(i.data, t.width, t.height, oe(e)), r.putImageData(i, t.x, t.y);
|
|
146
|
-
}
|
|
147
|
-
function Y(e, t, n) {
|
|
148
|
-
return Math.min(n, Math.max(t, e));
|
|
149
|
-
}
|
|
150
|
-
// ../../packages/components/src/chat/PkImageEditor.vue?vue&type=script&setup=true&lang.ts
|
|
151
|
-
g(), v(), l();
|
|
152
|
-
var le = { class: "pk-image-editor" }, ue = { class: "pk-image-editor__toolbar" }, de = { class: "pk-image-editor__options" }, fe = ["id"], pe = { class: "pk-image-editor__hint" }, me = { class: "pk-image-editor__hint" }, he = 6, X = /*#__PURE__*/ P(/* @__PURE__ */ C({
|
|
153
|
-
__name: "PkImageEditor",
|
|
154
|
-
props: /*@__PURE__*/ a({ image: { type: null } }, {
|
|
155
|
-
edits: { required: !0 },
|
|
156
|
-
editsModifiers: {}
|
|
157
|
-
}),
|
|
158
|
-
emits: /*@__PURE__*/ a(["error"], ["update:edits"]),
|
|
159
|
-
setup(t, { expose: a, emit: l }) {
|
|
160
|
-
let d = t, g = l, v = r(t, "edits"), { t: S } = ee({ useScope: "global" }), C = {
|
|
161
|
-
free: void 0,
|
|
162
|
-
"1:1": 1,
|
|
163
|
-
"4:3": 4 / 3,
|
|
164
|
-
"16:9": 16 / 9
|
|
165
|
-
}, O = m("crop"), j = m("free"), M = m("solid"), P = h(() => [{
|
|
166
|
-
value: "crop",
|
|
167
|
-
label: S("imageEditor.crop")
|
|
168
|
-
}, {
|
|
169
|
-
value: "cover",
|
|
170
|
-
label: S("imageEditor.cover")
|
|
171
|
-
}]), ne = h(() => [
|
|
172
|
-
{
|
|
173
|
-
value: "free",
|
|
174
|
-
label: S("imageEditor.aspectFree")
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
value: "1:1",
|
|
178
|
-
label: "1:1"
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
value: "4:3",
|
|
182
|
-
label: "4:3"
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
value: "16:9",
|
|
186
|
-
label: "16:9"
|
|
187
|
-
}
|
|
188
|
-
]), re = h(() => [{
|
|
189
|
-
value: "solid",
|
|
190
|
-
label: S("imageEditor.coverSolid")
|
|
191
|
-
}, {
|
|
192
|
-
value: "pixelate",
|
|
193
|
-
label: S("imageEditor.coverPixelate")
|
|
194
|
-
}]), I = y(), L = m([]);
|
|
195
|
-
function R(e) {
|
|
196
|
-
v.value = [...v.value, e], L.value = [];
|
|
197
|
-
}
|
|
198
|
-
function ie() {
|
|
199
|
-
X.value = void 0;
|
|
200
|
-
let e = v.value[v.value.length - 1];
|
|
201
|
-
e && (v.value = v.value.slice(0, -1), L.value = [...L.value, e]);
|
|
202
|
-
}
|
|
203
|
-
function oe() {
|
|
204
|
-
X.value = void 0;
|
|
205
|
-
let e = L.value[L.value.length - 1];
|
|
206
|
-
e && (v.value = [...v.value, e], L.value = L.value.slice(0, -1));
|
|
207
|
-
}
|
|
208
|
-
function B(e) {
|
|
209
|
-
X.value = void 0, R({
|
|
210
|
-
kind: "rotate",
|
|
211
|
-
turn: e
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
let V = h(() => ae(d.image, v.value)), H = u("stageEl"), U;
|
|
215
|
-
function G() {
|
|
216
|
-
if (!H.value) return;
|
|
217
|
-
let e;
|
|
218
|
-
try {
|
|
219
|
-
e = se(d.image, v.value);
|
|
220
|
-
} catch {
|
|
221
|
-
g("error");
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
e.setAttribute("role", "img"), e.setAttribute("aria-label", S("imageEditor.canvasLabel")), H.value.replaceChildren(e), U && W(U), U = e;
|
|
225
|
-
}
|
|
226
|
-
i(G), s([() => d.image, v], G, { flush: "post" }), n(() => {
|
|
227
|
-
U && W(U);
|
|
228
|
-
});
|
|
229
|
-
let K = u("areaEl"), q = m({
|
|
230
|
-
width: 0,
|
|
231
|
-
height: 0
|
|
232
|
-
});
|
|
233
|
-
k(K, ([e]) => {
|
|
234
|
-
e && (q.value = {
|
|
235
|
-
width: e.contentRect.width,
|
|
236
|
-
height: e.contentRect.height
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
let J = h(() => Math.min(1, q.value.width / V.value.width, q.value.height / V.value.height)), ce = h(() => ({
|
|
240
|
-
width: `${Math.max(1, Math.floor(V.value.width * J.value))}px`,
|
|
241
|
-
height: `${Math.max(1, Math.floor(V.value.height * J.value))}px`
|
|
242
|
-
})), Y = u("frameEl"), X = m(), Z = m();
|
|
243
|
-
function Q(e) {
|
|
244
|
-
let t = Y.value?.getBoundingClientRect();
|
|
245
|
-
return !t?.width || !t.height ? {
|
|
246
|
-
x: 0,
|
|
247
|
-
y: 0
|
|
248
|
-
} : {
|
|
249
|
-
x: (e.clientX - t.left) / t.width * V.value.width,
|
|
250
|
-
y: (e.clientY - t.top) / t.height * V.value.height
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
function ge(e) {
|
|
254
|
-
e.button === 0 && (Y.value?.setPointerCapture(e.pointerId), Z.value = Q(e), X.value = void 0);
|
|
255
|
-
}
|
|
256
|
-
function _e(e) {
|
|
257
|
-
Z.value && (X.value = z(Z.value, Q(e), V.value, O.value === "crop" ? C[j.value] : void 0));
|
|
258
|
-
}
|
|
259
|
-
function ve() {
|
|
260
|
-
if (!Z.value) return;
|
|
261
|
-
Z.value = void 0;
|
|
262
|
-
let e = X.value;
|
|
263
|
-
!e || e.width * J.value < he || e.height * J.value < he ? X.value = void 0 : O.value === "cover" && (X.value = void 0, R({
|
|
264
|
-
kind: "cover",
|
|
265
|
-
rect: e,
|
|
266
|
-
style: M.value
|
|
267
|
-
}));
|
|
268
|
-
}
|
|
269
|
-
function ye() {
|
|
270
|
-
Z.value = void 0, X.value = void 0;
|
|
271
|
-
}
|
|
272
|
-
let $ = h(() => O.value === "crop" && !Z.value && !!X.value);
|
|
273
|
-
function be() {
|
|
274
|
-
let e = X.value;
|
|
275
|
-
$.value && e && (X.value = void 0, (e.width !== V.value.width || e.height !== V.value.height) && R({
|
|
276
|
-
kind: "crop",
|
|
277
|
-
rect: e
|
|
278
|
-
}));
|
|
279
|
-
}
|
|
280
|
-
s(O, () => {
|
|
281
|
-
X.value = void 0;
|
|
282
|
-
}), s(j, (e) => {
|
|
283
|
-
let t = X.value;
|
|
284
|
-
t && O.value === "crop" && (X.value = z(t, {
|
|
285
|
-
x: t.x + t.width,
|
|
286
|
-
y: t.y + t.height
|
|
287
|
-
}, V.value, C[e]));
|
|
288
|
-
});
|
|
289
|
-
let xe = h(() => {
|
|
290
|
-
let e = X.value;
|
|
291
|
-
if (e) return {
|
|
292
|
-
left: `${e.x / V.value.width * 100}%`,
|
|
293
|
-
top: `${e.y / V.value.height * 100}%`,
|
|
294
|
-
width: `${e.width / V.value.width * 100}%`,
|
|
295
|
-
height: `${e.height / V.value.height * 100}%`
|
|
296
|
-
};
|
|
297
|
-
});
|
|
298
|
-
return a({
|
|
299
|
-
pendingCrop: $,
|
|
300
|
-
applyCrop: be,
|
|
301
|
-
shownCanvas: () => U
|
|
302
|
-
}), (t, n) => {
|
|
303
|
-
let r = te, i = N, a = A;
|
|
304
|
-
return D(), E("div", le, [
|
|
305
|
-
p("div", ue, [
|
|
306
|
-
c(F, {
|
|
307
|
-
modelValue: O.value,
|
|
308
|
-
"onUpdate:modelValue": n[0] ||= (e) => O.value = e,
|
|
309
|
-
name: "pk-image-editor-tool",
|
|
310
|
-
segmented: "",
|
|
311
|
-
class: "mb-0",
|
|
312
|
-
"aria-label": w(S)("imageEditor.tool"),
|
|
313
|
-
options: P.value
|
|
314
|
-
}, {
|
|
315
|
-
crop: b(({ option: e }) => [c(r, {
|
|
316
|
-
name: "ri:crop-line",
|
|
317
|
-
class: "w-16 h-16"
|
|
318
|
-
}), T(" " + _(e.label), 1)]),
|
|
319
|
-
cover: b(({ option: e }) => [c(r, {
|
|
320
|
-
name: "ri:eye-off-line",
|
|
321
|
-
class: "w-16 h-16"
|
|
322
|
-
}), T(" " + _(e.label), 1)]),
|
|
323
|
-
_: 1
|
|
324
|
-
}, 8, [
|
|
325
|
-
"modelValue",
|
|
326
|
-
"aria-label",
|
|
327
|
-
"options"
|
|
328
|
-
]),
|
|
329
|
-
c(a, { modifiers: "compact" }, {
|
|
330
|
-
default: b(() => [c(i, {
|
|
331
|
-
modifiers: "action-quiet",
|
|
332
|
-
icon: "ri:anticlockwise-line",
|
|
333
|
-
title: w(S)("imageEditor.rotateLeft"),
|
|
334
|
-
"aria-label": w(S)("imageEditor.rotateLeft"),
|
|
335
|
-
onClick: n[1] ||= (e) => B(-1)
|
|
336
|
-
}, null, 8, ["title", "aria-label"]), c(i, {
|
|
337
|
-
modifiers: "action-quiet",
|
|
338
|
-
icon: "ri:clockwise-line",
|
|
339
|
-
title: w(S)("imageEditor.rotateRight"),
|
|
340
|
-
"aria-label": w(S)("imageEditor.rotateRight"),
|
|
341
|
-
onClick: n[2] ||= (e) => B(1)
|
|
342
|
-
}, null, 8, ["title", "aria-label"])]),
|
|
343
|
-
_: 1
|
|
344
|
-
}),
|
|
345
|
-
c(a, {
|
|
346
|
-
modifiers: "compact",
|
|
347
|
-
class: "ml-auto"
|
|
348
|
-
}, {
|
|
349
|
-
default: b(() => [c(i, {
|
|
350
|
-
modifiers: "action-quiet",
|
|
351
|
-
icon: "ri:arrow-go-back-line",
|
|
352
|
-
title: w(S)("imageEditor.undo"),
|
|
353
|
-
"aria-label": w(S)("imageEditor.undo"),
|
|
354
|
-
disabled: !v.value.length,
|
|
355
|
-
onClick: ie
|
|
356
|
-
}, null, 8, [
|
|
357
|
-
"title",
|
|
358
|
-
"aria-label",
|
|
359
|
-
"disabled"
|
|
360
|
-
]), c(i, {
|
|
361
|
-
modifiers: "action-quiet",
|
|
362
|
-
icon: "ri:arrow-go-forward-line",
|
|
363
|
-
title: w(S)("imageEditor.redo"),
|
|
364
|
-
"aria-label": w(S)("imageEditor.redo"),
|
|
365
|
-
disabled: !L.value.length,
|
|
366
|
-
onClick: oe
|
|
367
|
-
}, null, 8, [
|
|
368
|
-
"title",
|
|
369
|
-
"aria-label",
|
|
370
|
-
"disabled"
|
|
371
|
-
])]),
|
|
372
|
-
_: 1
|
|
373
|
-
})
|
|
374
|
-
]),
|
|
375
|
-
p("div", de, [O.value === "crop" ? (D(), E(f, { key: 0 }, [
|
|
376
|
-
p("span", {
|
|
377
|
-
id: w(I),
|
|
378
|
-
class: "pk-image-editor__label"
|
|
379
|
-
}, _(w(S)("imageEditor.aspect")), 9, fe),
|
|
380
|
-
c(F, {
|
|
381
|
-
modelValue: j.value,
|
|
382
|
-
"onUpdate:modelValue": n[3] ||= (e) => j.value = e,
|
|
383
|
-
name: "pk-image-editor-aspect",
|
|
384
|
-
segmented: "",
|
|
385
|
-
class: "mb-0",
|
|
386
|
-
"aria-labelledby": w(I),
|
|
387
|
-
options: ne.value
|
|
388
|
-
}, null, 8, [
|
|
389
|
-
"modelValue",
|
|
390
|
-
"aria-labelledby",
|
|
391
|
-
"options"
|
|
392
|
-
]),
|
|
393
|
-
p("span", pe, _(w(S)("imageEditor.cropHint")), 1),
|
|
394
|
-
c(i, {
|
|
395
|
-
class: "ml-auto",
|
|
396
|
-
modifiers: "secondary",
|
|
397
|
-
label: w(S)("action.apply"),
|
|
398
|
-
disabled: !$.value,
|
|
399
|
-
onClick: be
|
|
400
|
-
}, null, 8, ["label", "disabled"])
|
|
401
|
-
], 64)) : (D(), E(f, { key: 1 }, [c(F, {
|
|
402
|
-
modelValue: M.value,
|
|
403
|
-
"onUpdate:modelValue": n[4] ||= (e) => M.value = e,
|
|
404
|
-
name: "pk-image-editor-cover",
|
|
405
|
-
segmented: "",
|
|
406
|
-
class: "mb-0",
|
|
407
|
-
"aria-label": w(S)("imageEditor.coverStyle"),
|
|
408
|
-
options: re.value
|
|
409
|
-
}, null, 8, [
|
|
410
|
-
"modelValue",
|
|
411
|
-
"aria-label",
|
|
412
|
-
"options"
|
|
413
|
-
]), p("span", me, _(w(S)("imageEditor.coverHint")), 1)], 64))]),
|
|
414
|
-
p("div", {
|
|
415
|
-
ref_key: "areaEl",
|
|
416
|
-
ref: K,
|
|
417
|
-
class: "pk-image-editor__area"
|
|
418
|
-
}, [p("div", {
|
|
419
|
-
ref_key: "frameEl",
|
|
420
|
-
ref: Y,
|
|
421
|
-
class: "pk-image-editor__frame",
|
|
422
|
-
style: o(ce.value),
|
|
423
|
-
onPointerdown: ge,
|
|
424
|
-
onPointermove: _e,
|
|
425
|
-
onPointerup: ve,
|
|
426
|
-
onPointercancel: ye
|
|
427
|
-
}, [p("div", {
|
|
428
|
-
ref_key: "stageEl",
|
|
429
|
-
ref: H,
|
|
430
|
-
class: "pk-image-editor__stage"
|
|
431
|
-
}, null, 512), X.value ? (D(), E("div", {
|
|
432
|
-
key: 0,
|
|
433
|
-
class: e(["pk-image-editor__selection", `pk-image-editor__selection--${O.value}`]),
|
|
434
|
-
style: o(xe.value)
|
|
435
|
-
}, null, 6)) : x("", !0)], 36)], 512)
|
|
436
|
-
]);
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
}), [["styles", [".pk-image-editor{flex-direction:column;flex:1;min-height:0;display:flex}.pk-image-editor__toolbar,.pk-image-editor__options{align-items:center;gap:var(--spacing-8);padding:var(--spacing-8) var(--spacing-md);border-bottom:1px solid var(--color-surface-3);flex-wrap:wrap;display:flex}.pk-image-editor__toolbar{background-color:var(--color-surface-1)}.pk-image-editor__toolbar>.vv-radio-group,.pk-image-editor__options>.vv-radio-group{flex:none;width:auto}.pk-image-editor__toolbar>.vv-radio-group .vv-radio,.pk-image-editor__options>.vv-radio-group .vv-radio{flex:none}.pk-image-editor__label{color:var(--color-word-2);font-size:var(--text-14)}.pk-image-editor__hint{color:var(--color-word-3);font-size:var(--text-12)}.pk-image-editor__area{min-height:12rem;padding:var(--spacing-md);background:repeating-conic-gradient(var(--color-surface-2) 0% 25%, var(--color-surface) 0% 50%) 50%/16px 16px;flex:1;justify-content:center;align-items:center;display:flex;overflow:hidden}.pk-image-editor__frame{box-shadow:var(--shadow-sm);cursor:crosshair;touch-action:none;-webkit-user-select:none;user-select:none;flex-shrink:0;position:relative;overflow:hidden}.pk-image-editor__stage,.pk-image-editor__stage>canvas{width:100%;height:100%;display:block}.pk-image-editor__selection{pointer-events:none;border:2px solid var(--color-white);outline:1px solid color-mix(in srgb, var(--color-black) 50%, transparent);position:absolute}.pk-image-editor__selection--crop{box-shadow:0 0 0 100vmax color-mix(in srgb, var(--color-black) 55%, transparent)}.pk-image-editor__selection--cover{background-color:color-mix(in srgb, var(--color-black) 30%, transparent);border-style:dashed}"]]]);
|
|
440
|
-
// ../../packages/components/src/chat/PkImageEditorDialog.vue?vue&type=script&setup=true&lang.ts
|
|
441
|
-
g(), v(), l();
|
|
442
|
-
var Z = ["aria-label"], Q = {
|
|
443
|
-
key: 3,
|
|
444
|
-
class: "pk-image-editor-dialog__size"
|
|
445
|
-
}, ge = /*#__PURE__*/ P(/* @__PURE__ */ C({
|
|
446
|
-
__name: "PkImageEditorDialog",
|
|
447
|
-
props: { file: { type: null } },
|
|
448
|
-
emits: ["close", "apply"],
|
|
449
|
-
setup(e, { emit: r }) {
|
|
450
|
-
let a = e, o = r, { t: s } = ee({ useScope: "global" }), l = O("(max-width: 575.98px)"), f = S(), p = m(), g = m([]), v = m(!1), y = u("editorEl");
|
|
451
|
-
i(async () => {
|
|
452
|
-
try {
|
|
453
|
-
f.value = await H(a.file);
|
|
454
|
-
} catch {
|
|
455
|
-
p.value = "load";
|
|
456
|
-
}
|
|
457
|
-
}), n(() => {
|
|
458
|
-
f.value && W(f.value.image);
|
|
459
|
-
});
|
|
460
|
-
let C = h(() => f.value && ae(f.value.image, g.value)), T = h(() => !!f.value && f.value.image.width < f.value.original.width), k = h(() => g.value.length > 0 || !!y.value?.pendingCrop);
|
|
461
|
-
async function P() {
|
|
462
|
-
let e = y.value;
|
|
463
|
-
if (e) {
|
|
464
|
-
if (e.applyCrop(), !g.value.length) o("close");
|
|
465
|
-
else {
|
|
466
|
-
p.value = void 0, v.value = !0;
|
|
467
|
-
try {
|
|
468
|
-
await t();
|
|
469
|
-
let n = e.shownCanvas();
|
|
470
|
-
if (p.value === "draw") return;
|
|
471
|
-
if (!n) throw Error("No image drawn");
|
|
472
|
-
let r = await U(n, a.file.type);
|
|
473
|
-
o("apply", new File([r], V(a.file.name, a.file.type, r.type), {
|
|
474
|
-
type: r.type,
|
|
475
|
-
lastModified: Date.now()
|
|
476
|
-
}));
|
|
477
|
-
} catch {
|
|
478
|
-
p.value = "export";
|
|
479
|
-
} finally {
|
|
480
|
-
v.value = !1;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
let F = h(() => {
|
|
486
|
-
switch (p.value) {
|
|
487
|
-
case "export": return s("imageEditor.exportFailed");
|
|
488
|
-
case "draw": return s("imageEditor.drawFailed");
|
|
489
|
-
default: return s("imageEditor.loadFailed");
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
return (e, t) => {
|
|
493
|
-
let n = M, r = te, i = N, a = A, u = j;
|
|
494
|
-
return D(), d(u, {
|
|
495
|
-
"model-value": !0,
|
|
496
|
-
title: w(s)("imageEditor.title"),
|
|
497
|
-
modifiers: w(l) ? "fullscreen" : void 0,
|
|
498
|
-
"keep-open": "",
|
|
499
|
-
class: "pk-image-editor-dialog",
|
|
500
|
-
"onUpdate:modelValue": t[3] ||= (e) => !e && o("close")
|
|
501
|
-
}, {
|
|
502
|
-
footer: b(() => [c(a, null, {
|
|
503
|
-
default: b(() => [c(i, {
|
|
504
|
-
modifiers: "secondary",
|
|
505
|
-
label: w(s)("action.cancel"),
|
|
506
|
-
onClick: t[2] ||= (e) => o("close")
|
|
507
|
-
}, null, 8, ["label"]), c(i, {
|
|
508
|
-
label: w(s)("imageEditor.use"),
|
|
509
|
-
loading: v.value,
|
|
510
|
-
disabled: v.value || !k.value || p.value === "draw",
|
|
511
|
-
onClick: P
|
|
512
|
-
}, null, 8, [
|
|
513
|
-
"label",
|
|
514
|
-
"loading",
|
|
515
|
-
"disabled"
|
|
516
|
-
])]),
|
|
517
|
-
_: 1
|
|
518
|
-
})]),
|
|
519
|
-
default: b(() => [
|
|
520
|
-
p.value ? (D(), d(n, {
|
|
521
|
-
key: 0,
|
|
522
|
-
modifiers: "danger",
|
|
523
|
-
class: "m-md",
|
|
524
|
-
content: F.value
|
|
525
|
-
}, null, 8, ["content"])) : x("", !0),
|
|
526
|
-
f.value && p.value !== "draw" ? (D(), d(X, {
|
|
527
|
-
key: 1,
|
|
528
|
-
ref_key: "editorEl",
|
|
529
|
-
ref: y,
|
|
530
|
-
edits: g.value,
|
|
531
|
-
"onUpdate:edits": t[0] ||= (e) => g.value = e,
|
|
532
|
-
image: f.value.image,
|
|
533
|
-
onError: t[1] ||= (e) => p.value = "draw"
|
|
534
|
-
}, null, 8, ["edits", "image"])) : p.value ? x("", !0) : (D(), E("div", {
|
|
535
|
-
key: 2,
|
|
536
|
-
class: "pk-image-editor-dialog__loading",
|
|
537
|
-
role: "status",
|
|
538
|
-
"aria-label": w(s)("imageEditor.loading")
|
|
539
|
-
}, [c(r, { name: "loading-loop" })], 8, Z)),
|
|
540
|
-
C.value ? (D(), E("p", Q, _(T.value ? w(s)("imageEditor.sizeScaledDown", {
|
|
541
|
-
width: C.value.width,
|
|
542
|
-
height: C.value.height
|
|
543
|
-
}) : w(s)("imageEditor.size", {
|
|
544
|
-
width: C.value.width,
|
|
545
|
-
height: C.value.height
|
|
546
|
-
})), 1)) : x("", !0)
|
|
547
|
-
]),
|
|
548
|
-
_: 1
|
|
549
|
-
}, 8, ["title", "modifiers"]);
|
|
550
|
-
};
|
|
551
|
-
}
|
|
552
|
-
}), [["styles", [".pk-image-editor-dialog:not(.vv-dialog--fullscreen)>article{width:min(64rem,94dvw);height:min(48rem,92dvh)}.pk-image-editor-dialog.vv-dialog--fullscreen>article{max-height:none}.pk-image-editor-dialog .vv-dialog__content{flex-direction:column;flex:1;min-height:0;padding:0;display:flex}.pk-image-editor-dialog__loading{color:var(--color-word-3);font-size:var(--text-24);flex:1;justify-content:center;align-items:center;display:flex}.pk-image-editor-dialog__size{padding:var(--spacing-8) var(--spacing-md);border-top:1px solid var(--color-surface-3);color:var(--color-word-3);font-size:var(--text-12);font-variant-numeric:tabular-nums;margin:0}"]]]);
|
|
553
|
-
export { ge as default };
|
|
554
|
-
|
|
555
|
-
//# sourceMappingURL=PkImageEditorDialog-Cq8y_PtC.js.map
|