@8wave/ai-elements 0.125.0-beta.39 → 0.125.0-beta.40
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-Dt0ygdJM.js → PkChatbotFilePreview-o0zIuCgN.js} +2 -2
- package/dist/_chunks/{PkChatbotFilePreview-Dt0ygdJM.js.map → PkChatbotFilePreview-o0zIuCgN.js.map} +1 -1
- package/dist/_chunks/{PkFilePreview-CT3_vRcU.js → PkFilePreview-D_1ZgiiA.js} +438 -438
- package/dist/_chunks/{PkFilePreview-CT3_vRcU.js.map → PkFilePreview-D_1ZgiiA.js.map} +1 -1
- package/dist/_chunks/{PkFilePreviewDialog-BOKJCapN.js → PkFilePreviewDialog-CI22huzK.js} +2 -2
- package/dist/_chunks/{PkFilePreviewDialog-BOKJCapN.js.map → PkFilePreviewDialog-CI22huzK.js.map} +1 -1
- package/dist/_chunks/{PkImageEditorDialog-D-ikpGo8.js → PkImageEditorDialog-CAEninFi.js} +152 -130
- package/dist/_chunks/PkImageEditorDialog-CAEninFi.js.map +1 -0
- package/dist/_chunks/{PkSelectionActions-CXQTnSXQ.js → PkSelectionActions-BriGyWCi.js} +2 -2
- package/dist/_chunks/{PkSelectionActions-CXQTnSXQ.js.map → PkSelectionActions-BriGyWCi.js.map} +1 -1
- package/dist/_chunks/{PkStreamingMarkdown-5fgxYt_s.js → PkStreamingMarkdown--9i0feuM.js} +3 -3
- package/dist/_chunks/{PkStreamingMarkdown-5fgxYt_s.js.map → PkStreamingMarkdown--9i0feuM.js.map} +1 -1
- package/dist/_chunks/{PkToolChatFile-Cbmu6I0S.js → PkToolChatFile-BKGUnWrj.js} +3 -3
- package/dist/_chunks/{PkToolChatFile-Cbmu6I0S.js.map → PkToolChatFile-BKGUnWrj.js.map} +1 -1
- package/dist/_chunks/{PkToolShareDocument-Bxm1pSpj.js → PkToolShareDocument-BUg-uDTO.js} +2 -2
- package/dist/_chunks/{PkToolShareDocument-Bxm1pSpj.js.map → PkToolShareDocument-BUg-uDTO.js.map} +1 -1
- package/dist/_chunks/{PkToolShowArtifact-CGUmoTfN.js → PkToolShowArtifact-BfLpz2-W.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-CGUmoTfN.js.map → PkToolShowArtifact-BfLpz2-W.js.map} +1 -1
- package/dist/_chunks/{PkToolShowContactForm-DZ-kgXa6.js → PkToolShowContactForm-BsF6DFzV.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-DZ-kgXa6.js.map → PkToolShowContactForm-BsF6DFzV.js.map} +1 -1
- package/dist/_chunks/{PkToolShowDiagram-CwINVecL.js → PkToolShowDiagram-CcRJNDHo.js} +2 -2
- package/dist/_chunks/{PkToolShowDiagram-CwINVecL.js.map → PkToolShowDiagram-CcRJNDHo.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-BrxNGFCH.js → PkToolShowForm-w6RvbKEB.js} +3 -3
- package/dist/_chunks/{PkToolShowForm-BrxNGFCH.js.map → PkToolShowForm-w6RvbKEB.js.map} +1 -1
- package/dist/_chunks/{PkToolShowImageGallery-BGTncXxq.js → PkToolShowImageGallery-BEddh4He.js} +2 -2
- package/dist/_chunks/{PkToolShowImageGallery-BGTncXxq.js.map → PkToolShowImageGallery-BEddh4He.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-B3RSUWP7.js → PkToolShowSources-CGESvGrm.js} +2 -2
- package/dist/_chunks/{PkToolShowSources-B3RSUWP7.js.map → PkToolShowSources-CGESvGrm.js.map} +1 -1
- package/dist/_chunks/{useLightbox-C54BCSbU.js → useLightbox-TagJmiah.js} +38 -37
- package/dist/_chunks/useLightbox-TagJmiah.js.map +1 -0
- package/dist/_chunks/{utils-Do6urHUh.js → utils-zkq8kMz-.js} +7 -4
- package/{dist-vue/_chunks/utils-Do3JWPJe.js.map → dist/_chunks/utils-zkq8kMz-.js.map} +1 -1
- package/dist/ai-elements.es.js +2711 -2711
- 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/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/{PkChart-BsF3OtnS.js → PkChart-DyyBXkd3.js} +2 -2
- package/dist-vue/_chunks/{PkChart-BsF3OtnS.js.map → PkChart-DyyBXkd3.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbot-BIQh81cA.js → PkChatbot-wsqj3EpU.js} +5 -5
- package/dist-vue/_chunks/{PkChatbot-BIQh81cA.js.map → PkChatbot-wsqj3EpU.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotEmptyState-pAeFPPQc.js → PkChatbotEmptyState-DcgIfNkX.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-pAeFPPQc.js.map → PkChatbotEmptyState-DcgIfNkX.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotFilePreview-BIta8Yg-.js → PkChatbotFilePreview-BDU2vY0F.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotFilePreview-BIta8Yg-.js.map → PkChatbotFilePreview-BDU2vY0F.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotInput-CN4rmNgu.js +520 -0
- package/dist-vue/_chunks/PkChatbotInput-CN4rmNgu.js.map +1 -0
- package/dist-vue/_chunks/PkChatbotMessages-BlF4Xp0_.js +1054 -0
- package/dist-vue/_chunks/{PkChatbotMessages-CZu8feEz.js.map → PkChatbotMessages-BlF4Xp0_.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepPayload-r25JHO7_.js → PkChatbotStepPayload-q9uXE5mr.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-r25JHO7_.js.map → PkChatbotStepPayload-q9uXE5mr.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-C897BpRX.js → PkChatbotStepToolDetail-BJz6Qwh3.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-C897BpRX.js.map → PkChatbotStepToolDetail-BJz6Qwh3.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotSteps-CRtIVwJV.js → PkChatbotSteps-DvJYNl_k.js} +5 -5
- package/dist-vue/_chunks/{PkChatbotSteps-CRtIVwJV.js.map → PkChatbotSteps-DvJYNl_k.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-BBCxj4Qz.js → PkChatbotViewChat-tmHyxxT3.js} +23 -23
- package/dist-vue/_chunks/{PkChatbotViewChat-BBCxj4Qz.js.map → PkChatbotViewChat-tmHyxxT3.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewConversations-rXGl7NKA.js → PkChatbotViewConversations-DOzUh_A7.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewConversations-rXGl7NKA.js.map → PkChatbotViewConversations-DOzUh_A7.js.map} +1 -1
- package/dist-vue/_chunks/{PkFilePreview-1ZNyDAo5.js → PkFilePreview-Bp5-Pl54.js} +227 -227
- package/dist-vue/_chunks/{PkFilePreview-1ZNyDAo5.js.map → PkFilePreview-Bp5-Pl54.js.map} +1 -1
- package/dist-vue/_chunks/{PkFilePreviewDialog-DnbUHGG2.js → PkFilePreviewDialog-CS885vBR.js} +2 -2
- package/dist-vue/_chunks/{PkFilePreviewDialog-DnbUHGG2.js.map → PkFilePreviewDialog-CS885vBR.js.map} +1 -1
- package/dist-vue/_chunks/{PkImageEditorDialog-Dn3HV_ny.js → PkImageEditorDialog-BhfdnsmX.js} +300 -278
- package/dist-vue/_chunks/PkImageEditorDialog-BhfdnsmX.js.map +1 -0
- package/dist-vue/_chunks/{PkStreamingMarkdown-COQLmP8b.js → PkStreamingMarkdown-NgrJUZPI.js} +3 -3
- package/dist-vue/_chunks/{PkStreamingMarkdown-COQLmP8b.js.map → PkStreamingMarkdown-NgrJUZPI.js.map} +1 -1
- package/dist-vue/_chunks/{PkSvgViewer-vkd5Dluw.js → PkSvgViewer-CRNwb6Yn.js} +2 -2
- package/dist-vue/_chunks/{PkSvgViewer-vkd5Dluw.js.map → PkSvgViewer-CRNwb6Yn.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolChatFile-e-7a0k7l.js → PkToolChatFile-DnmiNGF4.js} +3 -3
- package/dist-vue/_chunks/{PkToolChatFile-e-7a0k7l.js.map → PkToolChatFile-DnmiNGF4.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShareDocument-CspvFwRR.js → PkToolShareDocument-Bf7OE8XA.js} +2 -2
- package/dist-vue/_chunks/{PkToolShareDocument-CspvFwRR.js.map → PkToolShareDocument-Bf7OE8XA.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowArtifact-CUP3VaC9.js → PkToolShowArtifact-C8ueuIGQ.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-CUP3VaC9.js.map → PkToolShowArtifact-C8ueuIGQ.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowChart-X6JZDAWD.js → PkToolShowChart-BWO6Hzlq.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowChart-X6JZDAWD.js.map → PkToolShowChart-BWO6Hzlq.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowContactForm-BM8d9M5a.js → PkToolShowContactForm-BBcDsLEO.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-BM8d9M5a.js.map → PkToolShowContactForm-BBcDsLEO.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-DOdzpndK.js → PkToolShowDiagram-BzUcxOKy.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowDiagram-DOdzpndK.js.map → PkToolShowDiagram-BzUcxOKy.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-TYBf8q6g.js → PkToolShowForm-B6uhHzJ8.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowForm-TYBf8q6g.js.map → PkToolShowForm-B6uhHzJ8.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowImageGallery-BvwuoyF6.js → PkToolShowImageGallery-C39nlJrJ.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowImageGallery-BvwuoyF6.js.map → PkToolShowImageGallery-C39nlJrJ.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowLocation-WdRqG8Wi.js → PkToolShowLocation-Nhh_LwmN.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowLocation-WdRqG8Wi.js.map → PkToolShowLocation-Nhh_LwmN.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-_MHBAgNI.js → PkToolShowProductList-FLLkRCnm.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-_MHBAgNI.js.map → PkToolShowProductList-FLLkRCnm.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-CHw7qZtw.js → PkToolShowSources-Cb7r5jrX.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSources-CHw7qZtw.js.map → PkToolShowSources-Cb7r5jrX.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowVideo-D7oiBe4p.js → PkToolShowVideo-QDLhVlau.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowVideo-D7oiBe4p.js.map → PkToolShowVideo-QDLhVlau.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-CRq9Jhmw.js → PkToolShowWebPages-P6PdJTEE.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-CRq9Jhmw.js.map → PkToolShowWebPages-P6PdJTEE.js.map} +1 -1
- package/dist-vue/_chunks/{useLightbox-Ctl9zaMX.js → useLightbox-DmtNa8bJ.js} +38 -37
- package/dist-vue/_chunks/useLightbox-DmtNa8bJ.js.map +1 -0
- package/dist-vue/_chunks/{utils-Do3JWPJe.js → utils-D4B1FVGF.js} +6 -3
- package/dist-vue/_chunks/utils-D4B1FVGF.js.map +1 -0
- package/dist-vue/composables.js +1 -1
- package/dist-vue/index.js +61 -61
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/packages/components/src/chat/imageEdits.d.ts +3 -1
- package/dist-vue/packages/components/src/chat/utils.d.ts +6 -0
- package/dist-vue/packages/components/src/composables/useLightbox.d.ts +6 -0
- package/package.json +1 -1
- package/dist/_chunks/PkImageEditorDialog-D-ikpGo8.js.map +0 -1
- package/dist/_chunks/useLightbox-C54BCSbU.js.map +0 -1
- package/dist/_chunks/utils-Do6urHUh.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotInput-DSyIo0xB.js +0 -520
- package/dist-vue/_chunks/PkChatbotInput-DSyIo0xB.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotMessages-CZu8feEz.js +0 -1054
- package/dist-vue/_chunks/PkImageEditorDialog-Dn3HV_ny.js.map +0 -1
- package/dist-vue/_chunks/useLightbox-Ctl9zaMX.js.map +0 -1
package/dist-vue/_chunks/{PkImageEditorDialog-Dn3HV_ny.js → PkImageEditorDialog-BhfdnsmX.js}
RENAMED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { t as e } from "./PkEditorRadioButtons-Bw576DPQ.js";
|
|
2
2
|
import { t } from "./VvButtonLocalized-C-vx25u4.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { A as n } from "./utils-D4B1FVGF.js";
|
|
4
|
+
import { VvAlert as r, VvButtonGroup as i, VvDialog as a, VvIcon as o } from "@volverjs/ui-vue/components";
|
|
5
|
+
import { Fragment as s, computed as c, createBlock as l, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createSlots as p, createVNode as m, defineComponent as h, mergeModels as g, nextTick as _, normalizeClass as v, normalizeStyle as y, onBeforeUnmount as ee, onMounted as te, openBlock as b, ref as x, renderList as S, shallowRef as ne, toDisplayString as C, unref as w, useId as T, useModel as E, useTemplateRef as D, vModelText as re, watch as O, withCtx as k, withDirectives as ie, withKeys as ae, withModifiers as oe } from "vue";
|
|
6
|
+
import { useI18n as se } from "vue-i18n";
|
|
7
|
+
import { useMediaQuery as A, useResizeObserver as ce } from "@vueuse/core";
|
|
7
8
|
// ../../packages/components/src/chat/imageEdits.ts
|
|
8
|
-
var
|
|
9
|
+
var le = {
|
|
9
10
|
red: {
|
|
10
11
|
fill: "#ff3b30",
|
|
11
12
|
edge: "#ffffff"
|
|
@@ -30,12 +31,12 @@ var j = {
|
|
|
30
31
|
fill: "#000000",
|
|
31
32
|
edge: "#ffffff"
|
|
32
33
|
}
|
|
33
|
-
},
|
|
34
|
+
}, ue = "system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif", j = 16777216, de = .92, M = 12, N = 32, P = 3, F = 160, fe = 16, pe = 28, me = 12, he = 1.2, I = 4, ge = 2.2, _e = .6, ve = {
|
|
34
35
|
"image/jpeg": "jpg",
|
|
35
36
|
"image/png": "png",
|
|
36
37
|
"image/webp": "webp"
|
|
37
38
|
};
|
|
38
|
-
function L(e, t =
|
|
39
|
+
function L(e, t = j) {
|
|
39
40
|
let n = e.width * e.height;
|
|
40
41
|
if (n <= t) return {
|
|
41
42
|
width: e.width,
|
|
@@ -47,7 +48,7 @@ function L(e, t = M) {
|
|
|
47
48
|
height: Math.max(1, Math.floor(e.height * r))
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function ye(e, t) {
|
|
51
52
|
let { width: n, height: r } = e;
|
|
52
53
|
for (let e of t) e.kind === "rotate" ? [n, r] = [r, n] : e.kind === "crop" && ({width: n, height: r} = e.rect);
|
|
53
54
|
return {
|
|
@@ -56,37 +57,41 @@ function ve(e, t) {
|
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
59
|
function R(e) {
|
|
59
|
-
return Math.max(
|
|
60
|
-
}
|
|
61
|
-
function ye(e) {
|
|
62
|
-
return Math.max(F, Math.round(Math.min(e.width, e.height) / I));
|
|
60
|
+
return Math.max(M, Math.round(Math.min(e.width, e.height) / N));
|
|
63
61
|
}
|
|
64
62
|
function be(e) {
|
|
65
|
-
return Math.max(
|
|
63
|
+
return Math.max(P, Math.round(Math.min(e.width, e.height) / F));
|
|
66
64
|
}
|
|
67
65
|
function xe(e) {
|
|
66
|
+
return Math.max(fe, Math.round(Math.min(e.width, e.height) / pe));
|
|
67
|
+
}
|
|
68
|
+
function Se(e) {
|
|
68
69
|
return Math.max(1, Math.round(e / 3));
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
-
let r = []
|
|
72
|
-
for (let
|
|
73
|
-
let e =
|
|
74
|
-
|
|
75
|
-
i = e;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
let
|
|
82
|
-
for (;
|
|
83
|
-
|
|
71
|
+
function Ce(e, t, n) {
|
|
72
|
+
let r = [];
|
|
73
|
+
for (let i of e.split("\n")) {
|
|
74
|
+
let e = "";
|
|
75
|
+
for (let a of i.split(/[ \t]+/).filter(Boolean)) {
|
|
76
|
+
let i = e ? `${e} ${a}` : a;
|
|
77
|
+
if (n(i) <= t) {
|
|
78
|
+
e = i;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
e && r.push(e);
|
|
82
|
+
let o = a;
|
|
83
|
+
for (; o.length > 1 && n(o) > t;) {
|
|
84
|
+
let e = o.length - 1;
|
|
85
|
+
for (; e > 1 && n(o.slice(0, e)) > t;) e--;
|
|
86
|
+
r.push(o.slice(0, e)), o = o.slice(e);
|
|
87
|
+
}
|
|
88
|
+
e = o;
|
|
84
89
|
}
|
|
85
|
-
|
|
90
|
+
r.push(e);
|
|
86
91
|
}
|
|
87
|
-
return
|
|
92
|
+
return r;
|
|
88
93
|
}
|
|
89
|
-
function
|
|
94
|
+
function we(e, t, n) {
|
|
90
95
|
let r = t.x - e.x, i = t.y - e.y, a = Math.hypot(r, i);
|
|
91
96
|
if (!a) return {
|
|
92
97
|
lineEnd: t,
|
|
@@ -96,7 +101,7 @@ function Ce(e, t, n) {
|
|
|
96
101
|
t
|
|
97
102
|
]
|
|
98
103
|
};
|
|
99
|
-
let o = r / a, s = i / a, c = Math.min(n *
|
|
104
|
+
let o = r / a, s = i / a, c = Math.min(n * I, a * _e), l = c * ge / I, u = {
|
|
100
105
|
x: t.x - o * c,
|
|
101
106
|
y: t.y - s * c
|
|
102
107
|
};
|
|
@@ -118,7 +123,7 @@ function Ce(e, t, n) {
|
|
|
118
123
|
]
|
|
119
124
|
};
|
|
120
125
|
}
|
|
121
|
-
function
|
|
126
|
+
function Te(e, t, n, r) {
|
|
122
127
|
let i = J(e.x, 0, n.width), a = J(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);
|
|
123
128
|
if (r) {
|
|
124
129
|
let e = Math.max(Math.abs(o), Math.abs(s) * r);
|
|
@@ -158,7 +163,7 @@ function z(e, t, n, r) {
|
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
function B(e, t, n) {
|
|
161
|
-
let r =
|
|
166
|
+
let r = ve[n];
|
|
162
167
|
if (n === t || !r) return e;
|
|
163
168
|
let i = e.lastIndexOf(".");
|
|
164
169
|
return `${i > 0 ? e.slice(0, i) : e}.${r}`;
|
|
@@ -178,7 +183,7 @@ async function V(e) {
|
|
|
178
183
|
t.close();
|
|
179
184
|
}
|
|
180
185
|
}
|
|
181
|
-
function
|
|
186
|
+
function Ee(e, t) {
|
|
182
187
|
let n = U(e);
|
|
183
188
|
W(n).drawImage(e, 0, 0);
|
|
184
189
|
for (let e of t) {
|
|
@@ -187,37 +192,37 @@ function Te(e, t) {
|
|
|
187
192
|
continue;
|
|
188
193
|
}
|
|
189
194
|
if (e.kind !== "rotate" && e.kind !== "crop") {
|
|
190
|
-
|
|
195
|
+
De(W(n), e);
|
|
191
196
|
continue;
|
|
192
197
|
}
|
|
193
|
-
let t = e.kind === "rotate" ? G(n, e.turn) :
|
|
198
|
+
let t = e.kind === "rotate" ? G(n, e.turn) : ke(n, e.rect);
|
|
194
199
|
H(n), n = t;
|
|
195
200
|
}
|
|
196
201
|
return n;
|
|
197
202
|
}
|
|
198
|
-
function
|
|
199
|
-
let { fill: n, edge: r } =
|
|
203
|
+
function De(e, t) {
|
|
204
|
+
let { fill: n, edge: r } = le[t.color];
|
|
200
205
|
if (e.save(), e.lineCap = "round", e.lineJoin = "round", t.kind === "text") {
|
|
201
206
|
let { at: i, size: a } = t;
|
|
202
|
-
e.font = `700 ${a}px ${
|
|
203
|
-
let o =
|
|
207
|
+
e.font = `700 ${a}px ${ue}`, e.textBaseline = "top", e.lineWidth = Math.max(1, Math.round(a / me)) * 2, e.strokeStyle = r, e.fillStyle = n;
|
|
208
|
+
let o = Ce(t.text, t.maxWidth, (t) => e.measureText(t).width), s = (e) => i.y + a * (e * he + .19999999999999996 / 2);
|
|
204
209
|
o.forEach((t, n) => e.strokeText(t, i.x, s(n))), o.forEach((t, n) => e.fillText(t, i.x, s(n))), e.restore();
|
|
205
210
|
return;
|
|
206
211
|
}
|
|
207
|
-
let i =
|
|
212
|
+
let i = Se(t.width);
|
|
208
213
|
for (let [a, o] of [[r, i * 2], [n, 0]]) if (e.strokeStyle = a, e.fillStyle = a, e.lineWidth = t.width + o, t.kind === "rect") {
|
|
209
214
|
let { x: n, y: r, width: i, height: a } = t.rect;
|
|
210
215
|
e.strokeRect(n, r, i, a);
|
|
211
216
|
} else if (t.kind === "path") q(e, t.points), e.stroke();
|
|
212
217
|
else {
|
|
213
|
-
let { lineEnd: n, head: r } =
|
|
218
|
+
let { lineEnd: n, head: r } = we(t.from, t.to, t.width);
|
|
214
219
|
e.beginPath(), e.moveTo(t.from.x, t.from.y), e.lineTo(n.x, n.y), e.stroke(), e.beginPath(), e.moveTo(r[0].x, r[0].y), e.lineTo(r[1].x, r[1].y), e.lineTo(r[2].x, r[2].y), e.closePath(), e.fill(), o && (e.lineWidth = o, e.stroke());
|
|
215
220
|
}
|
|
216
221
|
e.restore();
|
|
217
222
|
}
|
|
218
|
-
function
|
|
223
|
+
function Oe(e, t) {
|
|
219
224
|
return new Promise((n, r) => {
|
|
220
|
-
e.toBlob((e) => e ? n(e) : r(/* @__PURE__ */ Error("The image could not be written")), t,
|
|
225
|
+
e.toBlob((e) => e ? n(e) : r(/* @__PURE__ */ Error("The image could not be written")), t, de);
|
|
221
226
|
});
|
|
222
227
|
}
|
|
223
228
|
function H(e) {
|
|
@@ -239,7 +244,7 @@ function G(e, t) {
|
|
|
239
244
|
}), r = W(n);
|
|
240
245
|
return r.save(), r.translate(n.width / 2, n.height / 2), r.rotate(t * Math.PI / 2), r.drawImage(e, -e.width / 2, -e.height / 2), r.restore(), n;
|
|
241
246
|
}
|
|
242
|
-
function
|
|
247
|
+
function ke(e, t) {
|
|
243
248
|
let n = U(t);
|
|
244
249
|
return W(n).drawImage(e, t.x, t.y, t.width, t.height, 0, 0, t.width, t.height), n;
|
|
245
250
|
}
|
|
@@ -263,7 +268,7 @@ function q(e, t) {
|
|
|
263
268
|
let a = i ?? n;
|
|
264
269
|
e.lineTo(a.x, a.y);
|
|
265
270
|
}
|
|
266
|
-
function
|
|
271
|
+
function Ae(e, t) {
|
|
267
272
|
return {
|
|
268
273
|
x: J(e.x, 0, t.width),
|
|
269
274
|
y: J(e.y, 0, t.height)
|
|
@@ -273,57 +278,57 @@ function J(e, t, n) {
|
|
|
273
278
|
return Math.min(n, Math.max(t, e));
|
|
274
279
|
}
|
|
275
280
|
// ../../packages/components/src/chat/PkImageEditor.vue?vue&type=script&setup=true&lang.ts
|
|
276
|
-
var
|
|
281
|
+
var je = { class: "pk-image-editor" }, Me = { class: "pk-image-editor__toolbar" }, Ne = ["title"], Pe = { class: "pk-image-editor__tool-label" }, Fe = ["id"], Ie = { class: "pk-image-editor__hint" }, Le = { class: "pk-image-editor__hint" }, Re = ["id"], ze = ["title"], Be = { class: "u-visually-hidden" }, Ve = { class: "pk-image-editor__hint" }, He = ["aria-label"], Ue = 6, We = 2, Ge = 200, Y = /* @__PURE__ */ h({
|
|
277
282
|
__name: "PkImageEditor",
|
|
278
|
-
props: /*@__PURE__*/
|
|
283
|
+
props: /*@__PURE__*/ g({
|
|
279
284
|
image: {},
|
|
280
285
|
initialTool: {}
|
|
281
286
|
}, {
|
|
282
287
|
edits: { required: !0 },
|
|
283
288
|
editsModifiers: {}
|
|
284
289
|
}),
|
|
285
|
-
emits: /*@__PURE__*/
|
|
286
|
-
setup(
|
|
287
|
-
let
|
|
290
|
+
emits: /*@__PURE__*/ g(["error"], ["update:edits"]),
|
|
291
|
+
setup(r, { expose: a, emit: l }) {
|
|
292
|
+
let h = r, g = l, A = E(r, "edits"), { t: j } = se({ useScope: "global" }), de = {
|
|
288
293
|
free: void 0,
|
|
289
294
|
"1:1": 1,
|
|
290
295
|
"4:3": 4 / 3,
|
|
291
296
|
"16:9": 16 / 9
|
|
292
|
-
},
|
|
297
|
+
}, M = x(h.initialTool ?? "crop"), N = x("free"), P = x("solid"), F = x("red"), fe = c(() => [
|
|
293
298
|
{
|
|
294
299
|
value: "crop",
|
|
295
|
-
label:
|
|
300
|
+
label: j("imageEditor.crop"),
|
|
296
301
|
icon: "ri:crop-line"
|
|
297
302
|
},
|
|
298
303
|
{
|
|
299
304
|
value: "cover",
|
|
300
|
-
label:
|
|
305
|
+
label: j("imageEditor.cover"),
|
|
301
306
|
icon: "ri:eye-off-line"
|
|
302
307
|
},
|
|
303
308
|
{
|
|
304
309
|
value: "arrow",
|
|
305
|
-
label:
|
|
310
|
+
label: j("imageEditor.arrow"),
|
|
306
311
|
icon: "ri:arrow-right-up-line"
|
|
307
312
|
},
|
|
308
313
|
{
|
|
309
314
|
value: "rect",
|
|
310
|
-
label:
|
|
315
|
+
label: j("imageEditor.rect"),
|
|
311
316
|
icon: "ri:checkbox-blank-line"
|
|
312
317
|
},
|
|
313
318
|
{
|
|
314
319
|
value: "path",
|
|
315
|
-
label:
|
|
320
|
+
label: j("imageEditor.path"),
|
|
316
321
|
icon: "ri:pencil-line"
|
|
317
322
|
},
|
|
318
323
|
{
|
|
319
324
|
value: "text",
|
|
320
|
-
label:
|
|
325
|
+
label: j("imageEditor.text"),
|
|
321
326
|
icon: "ri:text"
|
|
322
327
|
}
|
|
323
|
-
]),
|
|
328
|
+
]), pe = c(() => [
|
|
324
329
|
{
|
|
325
330
|
value: "free",
|
|
326
|
-
label:
|
|
331
|
+
label: j("imageEditor.aspectFree")
|
|
327
332
|
},
|
|
328
333
|
{
|
|
329
334
|
value: "1:1",
|
|
@@ -337,128 +342,128 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
337
342
|
value: "16:9",
|
|
338
343
|
label: "16:9"
|
|
339
344
|
}
|
|
340
|
-
]),
|
|
345
|
+
]), me = c(() => [{
|
|
341
346
|
value: "solid",
|
|
342
|
-
label:
|
|
347
|
+
label: j("imageEditor.coverSolid")
|
|
343
348
|
}, {
|
|
344
349
|
value: "pixelate",
|
|
345
|
-
label:
|
|
346
|
-
}]),
|
|
350
|
+
label: j("imageEditor.coverPixelate")
|
|
351
|
+
}]), I = c(() => [
|
|
347
352
|
{
|
|
348
353
|
value: "red",
|
|
349
|
-
label:
|
|
354
|
+
label: j("imageEditor.colorRed")
|
|
350
355
|
},
|
|
351
356
|
{
|
|
352
357
|
value: "yellow",
|
|
353
|
-
label:
|
|
358
|
+
label: j("imageEditor.colorYellow")
|
|
354
359
|
},
|
|
355
360
|
{
|
|
356
361
|
value: "green",
|
|
357
|
-
label:
|
|
362
|
+
label: j("imageEditor.colorGreen")
|
|
358
363
|
},
|
|
359
364
|
{
|
|
360
365
|
value: "blue",
|
|
361
|
-
label:
|
|
366
|
+
label: j("imageEditor.colorBlue")
|
|
362
367
|
},
|
|
363
368
|
{
|
|
364
369
|
value: "white",
|
|
365
|
-
label:
|
|
370
|
+
label: j("imageEditor.colorWhite")
|
|
366
371
|
},
|
|
367
372
|
{
|
|
368
373
|
value: "black",
|
|
369
|
-
label:
|
|
374
|
+
label: j("imageEditor.colorBlack")
|
|
370
375
|
}
|
|
371
|
-
]),
|
|
372
|
-
switch (
|
|
373
|
-
case "arrow": return
|
|
374
|
-
case "rect": return
|
|
375
|
-
case "path": return
|
|
376
|
-
default: return
|
|
376
|
+
]), ge = c(() => {
|
|
377
|
+
switch (M.value) {
|
|
378
|
+
case "arrow": return j("imageEditor.arrowHint");
|
|
379
|
+
case "rect": return j("imageEditor.rectHint");
|
|
380
|
+
case "path": return j("imageEditor.pathHint");
|
|
381
|
+
default: return j("imageEditor.textHint");
|
|
377
382
|
}
|
|
378
|
-
}),
|
|
383
|
+
}), _e = T(), ve = T(), L = x([]);
|
|
379
384
|
function R(e) {
|
|
380
385
|
A.value = [...A.value, e], L.value = [];
|
|
381
386
|
}
|
|
382
|
-
function
|
|
387
|
+
function Se() {
|
|
383
388
|
q.value = void 0;
|
|
384
389
|
let e = A.value[A.value.length - 1];
|
|
385
390
|
e && (A.value = A.value.slice(0, -1), L.value = [...L.value, e]);
|
|
386
391
|
}
|
|
387
|
-
function
|
|
392
|
+
function Ce() {
|
|
388
393
|
q.value = void 0;
|
|
389
394
|
let e = L.value[L.value.length - 1];
|
|
390
395
|
e && (A.value = [...A.value, e], L.value = L.value.slice(0, -1));
|
|
391
396
|
}
|
|
392
|
-
function
|
|
397
|
+
function we(e) {
|
|
393
398
|
q.value = void 0, R({
|
|
394
399
|
kind: "rotate",
|
|
395
400
|
turn: e
|
|
396
401
|
});
|
|
397
402
|
}
|
|
398
|
-
let z =
|
|
399
|
-
function
|
|
403
|
+
let z = c(() => ye(h.image, A.value)), B = D("stageEl"), V;
|
|
404
|
+
function Oe() {
|
|
400
405
|
if (!B.value) return;
|
|
401
406
|
let e;
|
|
402
407
|
try {
|
|
403
|
-
e =
|
|
408
|
+
e = Ee(h.image, A.value);
|
|
404
409
|
} catch {
|
|
405
|
-
|
|
410
|
+
g("error");
|
|
406
411
|
return;
|
|
407
412
|
}
|
|
408
|
-
e.setAttribute("role", "img"), e.setAttribute("aria-label",
|
|
413
|
+
e.setAttribute("role", "img"), e.setAttribute("aria-label", j("imageEditor.canvasLabel")), B.value.replaceChildren(e), V && H(V), V = e;
|
|
409
414
|
}
|
|
410
|
-
|
|
415
|
+
te(Oe), O([() => h.image, A], Oe, { flush: "post" }), ee(() => {
|
|
411
416
|
V && H(V), Qe.value && H(Qe.value);
|
|
412
417
|
});
|
|
413
|
-
let U =
|
|
418
|
+
let U = D("areaEl"), W = x({
|
|
414
419
|
width: 0,
|
|
415
420
|
height: 0
|
|
416
421
|
});
|
|
417
|
-
|
|
422
|
+
ce(U, ([e]) => {
|
|
418
423
|
e && (W.value = {
|
|
419
424
|
width: e.contentRect.width,
|
|
420
425
|
height: e.contentRect.height
|
|
421
426
|
});
|
|
422
427
|
});
|
|
423
|
-
let G =
|
|
428
|
+
let G = c(() => Math.min(1, W.value.width / z.value.width, W.value.height / z.value.height)), ke = c(() => ({
|
|
424
429
|
width: `${Math.max(1, Math.floor(z.value.width * G.value))}px`,
|
|
425
430
|
height: `${Math.max(1, Math.floor(z.value.height * G.value))}px`
|
|
426
|
-
})), K =
|
|
431
|
+
})), K = D("frameEl"), q = x(), J = x(), Y = ne(), X;
|
|
427
432
|
function Ke(e) {
|
|
428
433
|
let t = K.value?.getBoundingClientRect();
|
|
429
434
|
return !t?.width || !t.height ? {
|
|
430
435
|
x: 0,
|
|
431
436
|
y: 0
|
|
432
|
-
} :
|
|
437
|
+
} : Ae({
|
|
433
438
|
x: (e.clientX - t.left) / t.width * z.value.width,
|
|
434
439
|
y: (e.clientY - t.top) / t.height * z.value.height
|
|
435
440
|
}, z.value);
|
|
436
441
|
}
|
|
437
442
|
function qe(e) {
|
|
438
443
|
if (e.button !== 0 || X !== void 0) return;
|
|
439
|
-
|
|
444
|
+
K.value?.setPointerCapture(e.pointerId), X = e.pointerId;
|
|
440
445
|
let t = Ke(e);
|
|
441
|
-
J.value = t, q.value = void 0,
|
|
446
|
+
J.value = t, q.value = void 0, M.value === "path" && (Y.value = {
|
|
442
447
|
kind: "path",
|
|
443
448
|
points: [t],
|
|
444
|
-
color:
|
|
445
|
-
width:
|
|
449
|
+
color: F.value,
|
|
450
|
+
width: be(z.value)
|
|
446
451
|
});
|
|
447
452
|
}
|
|
448
453
|
function Je(e) {
|
|
449
454
|
let t = J.value;
|
|
450
455
|
if (!t || e.pointerId !== X) return;
|
|
451
|
-
let n = Ke(e), r =
|
|
452
|
-
switch (
|
|
456
|
+
let n = Ke(e), r = be(z.value);
|
|
457
|
+
switch (M.value) {
|
|
453
458
|
case "crop":
|
|
454
459
|
case "cover":
|
|
455
|
-
q.value =
|
|
460
|
+
q.value = Te(t, n, z.value, M.value === "crop" ? de[N.value] : void 0);
|
|
456
461
|
break;
|
|
457
462
|
case "rect":
|
|
458
463
|
Y.value = {
|
|
459
464
|
kind: "rect",
|
|
460
|
-
rect:
|
|
461
|
-
color:
|
|
465
|
+
rect: Te(t, n, z.value),
|
|
466
|
+
color: F.value,
|
|
462
467
|
width: r
|
|
463
468
|
};
|
|
464
469
|
break;
|
|
@@ -467,13 +472,13 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
467
472
|
kind: "arrow",
|
|
468
473
|
from: t,
|
|
469
474
|
to: n,
|
|
470
|
-
color:
|
|
475
|
+
color: F.value,
|
|
471
476
|
width: r
|
|
472
477
|
};
|
|
473
478
|
break;
|
|
474
479
|
case "path": {
|
|
475
480
|
let e = Y.value, t = e?.kind === "path" ? e.points[e.points.length - 1] : void 0;
|
|
476
|
-
e?.kind === "path" && t &&
|
|
481
|
+
e?.kind === "path" && t && mt(t, n) * G.value >= We && (Y.value = {
|
|
477
482
|
...e,
|
|
478
483
|
points: [...e.points, n]
|
|
479
484
|
});
|
|
@@ -484,20 +489,20 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
484
489
|
function Ye(e) {
|
|
485
490
|
let t = J.value;
|
|
486
491
|
if (!t || e.pointerId !== X) return;
|
|
487
|
-
if (X = void 0, J.value = void 0,
|
|
492
|
+
if (X = void 0, J.value = void 0, M.value === "crop" || M.value === "cover") {
|
|
488
493
|
let e = q.value;
|
|
489
494
|
if (!e || !Z(e.width) || !Z(e.height)) {
|
|
490
495
|
q.value = void 0;
|
|
491
496
|
return;
|
|
492
497
|
}
|
|
493
|
-
|
|
498
|
+
M.value === "cover" && (q.value = void 0, R({
|
|
494
499
|
kind: "cover",
|
|
495
500
|
rect: e,
|
|
496
|
-
style:
|
|
501
|
+
style: P.value
|
|
497
502
|
}));
|
|
498
503
|
return;
|
|
499
504
|
}
|
|
500
|
-
if (
|
|
505
|
+
if (M.value === "text") {
|
|
501
506
|
it(t);
|
|
502
507
|
return;
|
|
503
508
|
}
|
|
@@ -512,13 +517,13 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
512
517
|
}
|
|
513
518
|
function Ze(e) {
|
|
514
519
|
switch (e.kind) {
|
|
515
|
-
case "arrow": return Z(
|
|
520
|
+
case "arrow": return Z(mt(e.from, e.to));
|
|
516
521
|
case "rect": return Z(e.rect.width) && Z(e.rect.height);
|
|
517
522
|
case "path": return e.points.length > 1;
|
|
518
523
|
default: return !0;
|
|
519
524
|
}
|
|
520
525
|
}
|
|
521
|
-
let Qe =
|
|
526
|
+
let Qe = D("draftEl");
|
|
522
527
|
function $e() {
|
|
523
528
|
let e = Qe.value, t = K.value;
|
|
524
529
|
if (!e || !t) return;
|
|
@@ -527,15 +532,16 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
527
532
|
H(e);
|
|
528
533
|
return;
|
|
529
534
|
}
|
|
530
|
-
let r = window.devicePixelRatio || 1;
|
|
531
|
-
e.width
|
|
532
|
-
let
|
|
533
|
-
if (!
|
|
534
|
-
|
|
535
|
-
|
|
535
|
+
let r = window.devicePixelRatio || 1, i = Math.round(t.clientWidth * r), a = Math.round(t.clientHeight * r);
|
|
536
|
+
(e.width !== i || e.height !== a) && (e.width = i, e.height = a);
|
|
537
|
+
let o = e.getContext("2d");
|
|
538
|
+
if (!o) return;
|
|
539
|
+
o.setTransform(1, 0, 0, 1, 0, 0), o.clearRect(0, 0, i, a);
|
|
540
|
+
let s = i / z.value.width;
|
|
541
|
+
o.setTransform(s, 0, 0, s, 0, 0), De(o, n);
|
|
536
542
|
}
|
|
537
|
-
|
|
538
|
-
let et =
|
|
543
|
+
O(Y, $e, { flush: "post" });
|
|
544
|
+
let et = c(() => M.value === "crop" && !J.value && !!q.value);
|
|
539
545
|
function tt() {
|
|
540
546
|
let e = q.value;
|
|
541
547
|
et.value && e && (q.value = void 0, (e.width !== z.value.width || e.height !== z.value.height) && R({
|
|
@@ -543,14 +549,14 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
543
549
|
rect: e
|
|
544
550
|
}));
|
|
545
551
|
}
|
|
546
|
-
|
|
552
|
+
O(N, (e) => {
|
|
547
553
|
let t = q.value;
|
|
548
|
-
t &&
|
|
554
|
+
t && M.value === "crop" && (q.value = Te(t, {
|
|
549
555
|
x: t.x + t.width,
|
|
550
556
|
y: t.y + t.height
|
|
551
|
-
}, z.value,
|
|
557
|
+
}, z.value, de[e]));
|
|
552
558
|
});
|
|
553
|
-
let nt =
|
|
559
|
+
let nt = c(() => {
|
|
554
560
|
let e = q.value;
|
|
555
561
|
if (e) return {
|
|
556
562
|
left: `${e.x / z.value.width * 100}%`,
|
|
@@ -558,12 +564,12 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
558
564
|
width: `${e.width / z.value.width * 100}%`,
|
|
559
565
|
height: `${e.height / z.value.height * 100}%`
|
|
560
566
|
};
|
|
561
|
-
}), Q =
|
|
567
|
+
}), Q = x(), rt = D("textEl");
|
|
562
568
|
async function it(e) {
|
|
563
569
|
$(), Q.value = {
|
|
564
570
|
at: e,
|
|
565
571
|
text: ""
|
|
566
|
-
}, await
|
|
572
|
+
}, await _(), dt(), rt.value?.focus();
|
|
567
573
|
}
|
|
568
574
|
function $() {
|
|
569
575
|
let e = Q.value;
|
|
@@ -573,112 +579,121 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
573
579
|
kind: "text",
|
|
574
580
|
at: e.at,
|
|
575
581
|
text: t,
|
|
576
|
-
color:
|
|
577
|
-
size:
|
|
582
|
+
color: F.value,
|
|
583
|
+
size: xe(z.value),
|
|
578
584
|
maxWidth: z.value.width - e.at.x
|
|
579
585
|
});
|
|
580
586
|
}
|
|
581
|
-
let at = (
|
|
587
|
+
let at = D("optionsEl");
|
|
582
588
|
function ot(e) {
|
|
583
|
-
|
|
589
|
+
document.hasFocus() && (e.relatedTarget instanceof Node && at.value?.contains(e.relatedTarget) || $());
|
|
584
590
|
}
|
|
585
591
|
function st(e) {
|
|
586
|
-
|
|
592
|
+
Q.value && e.preventDefault();
|
|
593
|
+
}
|
|
594
|
+
function ct(e) {
|
|
595
|
+
e.detail && Q.value && rt.value?.focus();
|
|
587
596
|
}
|
|
588
|
-
function
|
|
597
|
+
function lt(e) {
|
|
598
|
+
n(e) || (e.preventDefault(), $());
|
|
599
|
+
}
|
|
600
|
+
function ut(e) {
|
|
601
|
+
n(e) || (e.preventDefault(), Q.value = void 0);
|
|
602
|
+
}
|
|
603
|
+
function dt() {
|
|
589
604
|
let e = rt.value;
|
|
590
605
|
e && (e.style.height = "auto", e.style.height = `${e.scrollHeight}px`);
|
|
591
606
|
}
|
|
592
|
-
let
|
|
607
|
+
let ft = c(() => !!Q.value?.text.trim()), pt = c(() => {
|
|
593
608
|
let e = Q.value;
|
|
594
609
|
if (!e) return;
|
|
595
|
-
let { fill: t, edge: n } =
|
|
610
|
+
let { fill: t, edge: n } = le[F.value];
|
|
596
611
|
return {
|
|
597
612
|
left: `${e.at.x / z.value.width * 100}%`,
|
|
598
613
|
top: `${e.at.y / z.value.height * 100}%`,
|
|
599
|
-
fontFamily:
|
|
600
|
-
fontSize: `${
|
|
601
|
-
lineHeight: String(
|
|
614
|
+
fontFamily: ue,
|
|
615
|
+
fontSize: `${xe(z.value) * G.value}px`,
|
|
616
|
+
lineHeight: String(he),
|
|
602
617
|
color: t,
|
|
603
618
|
"--pk-image-editor-text-edge": n
|
|
604
619
|
};
|
|
605
620
|
});
|
|
606
|
-
|
|
621
|
+
O(M, () => {
|
|
607
622
|
q.value = void 0, Y.value = void 0, $();
|
|
608
|
-
}),
|
|
609
|
-
pending:
|
|
623
|
+
}), a({
|
|
624
|
+
pending: c(() => et.value || ft.value),
|
|
610
625
|
applyPending: () => {
|
|
611
626
|
tt(), $();
|
|
612
627
|
},
|
|
613
628
|
shownCanvas: () => V
|
|
614
629
|
});
|
|
615
|
-
function
|
|
630
|
+
function mt(e, t) {
|
|
616
631
|
return Math.hypot(t.x - e.x, t.y - e.y);
|
|
617
632
|
}
|
|
618
|
-
return (n,
|
|
619
|
-
let
|
|
620
|
-
return
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
modelValue:
|
|
624
|
-
"onUpdate:modelValue":
|
|
633
|
+
return (n, r) => {
|
|
634
|
+
let a = o, c = t, l = i;
|
|
635
|
+
return b(), d("div", je, [
|
|
636
|
+
f("div", Me, [
|
|
637
|
+
m(e, {
|
|
638
|
+
modelValue: M.value,
|
|
639
|
+
"onUpdate:modelValue": r[0] ||= (e) => M.value = e,
|
|
625
640
|
name: "pk-image-editor-tool",
|
|
626
641
|
segmented: "",
|
|
627
642
|
class: "mb-0",
|
|
628
|
-
"aria-label":
|
|
629
|
-
options:
|
|
630
|
-
},
|
|
643
|
+
"aria-label": w(j)("imageEditor.tool"),
|
|
644
|
+
options: fe.value
|
|
645
|
+
}, p({ _: 2 }, [S(fe.value, (e) => ({
|
|
631
646
|
name: e.value,
|
|
632
|
-
fn:
|
|
647
|
+
fn: k(() => [f("span", {
|
|
633
648
|
class: "pk-image-editor__tool",
|
|
634
649
|
title: e.label
|
|
635
|
-
}, [
|
|
650
|
+
}, [m(a, {
|
|
636
651
|
name: e.icon,
|
|
637
652
|
class: "w-16 h-16"
|
|
638
|
-
}, null, 8, ["name"]),
|
|
653
|
+
}, null, 8, ["name"]), f("span", Pe, C(e.label), 1)], 8, Ne)])
|
|
639
654
|
}))]), 1032, [
|
|
640
655
|
"modelValue",
|
|
641
656
|
"aria-label",
|
|
642
657
|
"options"
|
|
643
658
|
]),
|
|
644
|
-
|
|
645
|
-
default:
|
|
659
|
+
m(l, { modifiers: "compact" }, {
|
|
660
|
+
default: k(() => [m(c, {
|
|
646
661
|
modifiers: "action-quiet",
|
|
647
662
|
icon: "ri:anticlockwise-line",
|
|
648
|
-
title:
|
|
649
|
-
"aria-label":
|
|
650
|
-
onClick:
|
|
651
|
-
}, null, 8, ["title", "aria-label"]),
|
|
663
|
+
title: w(j)("imageEditor.rotateLeft"),
|
|
664
|
+
"aria-label": w(j)("imageEditor.rotateLeft"),
|
|
665
|
+
onClick: r[1] ||= (e) => we(-1)
|
|
666
|
+
}, null, 8, ["title", "aria-label"]), m(c, {
|
|
652
667
|
modifiers: "action-quiet",
|
|
653
668
|
icon: "ri:clockwise-line",
|
|
654
|
-
title:
|
|
655
|
-
"aria-label":
|
|
656
|
-
onClick:
|
|
669
|
+
title: w(j)("imageEditor.rotateRight"),
|
|
670
|
+
"aria-label": w(j)("imageEditor.rotateRight"),
|
|
671
|
+
onClick: r[2] ||= (e) => we(1)
|
|
657
672
|
}, null, 8, ["title", "aria-label"])]),
|
|
658
673
|
_: 1
|
|
659
674
|
}),
|
|
660
|
-
|
|
675
|
+
m(l, {
|
|
661
676
|
modifiers: "compact",
|
|
662
677
|
class: "ml-auto"
|
|
663
678
|
}, {
|
|
664
|
-
default:
|
|
679
|
+
default: k(() => [m(c, {
|
|
665
680
|
modifiers: "action-quiet",
|
|
666
681
|
icon: "ri:arrow-go-back-line",
|
|
667
|
-
title:
|
|
668
|
-
"aria-label":
|
|
682
|
+
title: w(j)("imageEditor.undo"),
|
|
683
|
+
"aria-label": w(j)("imageEditor.undo"),
|
|
669
684
|
disabled: !A.value.length,
|
|
670
|
-
onClick:
|
|
685
|
+
onClick: Se
|
|
671
686
|
}, null, 8, [
|
|
672
687
|
"title",
|
|
673
688
|
"aria-label",
|
|
674
689
|
"disabled"
|
|
675
|
-
]),
|
|
690
|
+
]), m(c, {
|
|
676
691
|
modifiers: "action-quiet",
|
|
677
692
|
icon: "ri:arrow-go-forward-line",
|
|
678
|
-
title:
|
|
679
|
-
"aria-label":
|
|
693
|
+
title: w(j)("imageEditor.redo"),
|
|
694
|
+
"aria-label": w(j)("imageEditor.redo"),
|
|
680
695
|
disabled: !L.value.length,
|
|
681
|
-
onClick:
|
|
696
|
+
onClick: Ce
|
|
682
697
|
}, null, 8, [
|
|
683
698
|
"title",
|
|
684
699
|
"aria-label",
|
|
@@ -687,93 +702,100 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
687
702
|
_: 1
|
|
688
703
|
})
|
|
689
704
|
]),
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
705
|
+
f("div", {
|
|
706
|
+
ref_key: "optionsEl",
|
|
707
|
+
ref: at,
|
|
708
|
+
class: "pk-image-editor__options",
|
|
709
|
+
onMousedown: st,
|
|
710
|
+
onClick: ct
|
|
711
|
+
}, [M.value === "crop" ? (b(), d(s, { key: 0 }, [
|
|
712
|
+
f("span", {
|
|
713
|
+
id: w(_e),
|
|
693
714
|
class: "pk-image-editor__label"
|
|
694
|
-
},
|
|
695
|
-
|
|
696
|
-
modelValue:
|
|
697
|
-
"onUpdate:modelValue":
|
|
715
|
+
}, C(w(j)("imageEditor.aspect")), 9, Fe),
|
|
716
|
+
m(e, {
|
|
717
|
+
modelValue: N.value,
|
|
718
|
+
"onUpdate:modelValue": r[3] ||= (e) => N.value = e,
|
|
698
719
|
name: "pk-image-editor-aspect",
|
|
699
720
|
segmented: "",
|
|
700
721
|
class: "mb-0",
|
|
701
|
-
"aria-labelledby":
|
|
702
|
-
options:
|
|
722
|
+
"aria-labelledby": w(_e),
|
|
723
|
+
options: pe.value
|
|
703
724
|
}, null, 8, [
|
|
704
725
|
"modelValue",
|
|
705
726
|
"aria-labelledby",
|
|
706
727
|
"options"
|
|
707
728
|
]),
|
|
708
|
-
|
|
709
|
-
|
|
729
|
+
f("span", Ie, C(w(j)("imageEditor.cropHint")), 1),
|
|
730
|
+
m(c, {
|
|
710
731
|
class: "ml-auto",
|
|
711
732
|
modifiers: "secondary",
|
|
712
|
-
label:
|
|
733
|
+
label: w(j)("action.apply"),
|
|
713
734
|
disabled: !et.value,
|
|
714
735
|
onClick: tt
|
|
715
736
|
}, null, 8, ["label", "disabled"])
|
|
716
|
-
], 64)) :
|
|
717
|
-
modelValue:
|
|
718
|
-
"onUpdate:modelValue":
|
|
737
|
+
], 64)) : M.value === "cover" ? (b(), d(s, { key: 1 }, [m(e, {
|
|
738
|
+
modelValue: P.value,
|
|
739
|
+
"onUpdate:modelValue": r[4] ||= (e) => P.value = e,
|
|
719
740
|
name: "pk-image-editor-cover",
|
|
720
741
|
segmented: "",
|
|
721
742
|
class: "mb-0",
|
|
722
|
-
"aria-label":
|
|
723
|
-
options:
|
|
743
|
+
"aria-label": w(j)("imageEditor.coverStyle"),
|
|
744
|
+
options: me.value
|
|
724
745
|
}, null, 8, [
|
|
725
746
|
"modelValue",
|
|
726
747
|
"aria-label",
|
|
727
748
|
"options"
|
|
728
|
-
]),
|
|
729
|
-
|
|
730
|
-
id:
|
|
749
|
+
]), f("span", Le, C(w(j)("imageEditor.coverHint")), 1)], 64)) : (b(), d(s, { key: 2 }, [
|
|
750
|
+
f("span", {
|
|
751
|
+
id: w(ve),
|
|
731
752
|
class: "pk-image-editor__label"
|
|
732
|
-
},
|
|
733
|
-
|
|
734
|
-
modelValue:
|
|
735
|
-
"onUpdate:modelValue":
|
|
753
|
+
}, C(w(j)("imageEditor.color")), 9, Re),
|
|
754
|
+
m(e, {
|
|
755
|
+
modelValue: F.value,
|
|
756
|
+
"onUpdate:modelValue": r[5] ||= (e) => F.value = e,
|
|
736
757
|
name: "pk-image-editor-color",
|
|
737
758
|
segmented: "",
|
|
738
759
|
class: "mb-0",
|
|
739
|
-
"aria-labelledby":
|
|
740
|
-
options:
|
|
741
|
-
},
|
|
760
|
+
"aria-labelledby": w(ve),
|
|
761
|
+
options: I.value
|
|
762
|
+
}, p({ _: 2 }, [S(I.value, (e) => ({
|
|
742
763
|
name: e.value,
|
|
743
|
-
fn:
|
|
764
|
+
fn: k(() => [f("span", {
|
|
744
765
|
class: "pk-image-editor__color",
|
|
745
766
|
title: e.label
|
|
746
|
-
}, [
|
|
767
|
+
}, [f("span", {
|
|
747
768
|
class: "pk-image-editor__swatch",
|
|
748
|
-
style:
|
|
749
|
-
}, null, 4),
|
|
769
|
+
style: y({ backgroundColor: w(le)[e.value].fill })
|
|
770
|
+
}, null, 4), f("span", Be, C(e.label), 1)], 8, ze)])
|
|
750
771
|
}))]), 1032, [
|
|
751
772
|
"modelValue",
|
|
752
773
|
"aria-labelledby",
|
|
753
774
|
"options"
|
|
754
775
|
]),
|
|
755
|
-
|
|
756
|
-
], 64))]),
|
|
757
|
-
|
|
776
|
+
f("span", Ve, C(ge.value), 1)
|
|
777
|
+
], 64))], 544),
|
|
778
|
+
f("div", {
|
|
758
779
|
ref_key: "areaEl",
|
|
759
780
|
ref: U,
|
|
760
781
|
class: "pk-image-editor__area"
|
|
761
|
-
}, [
|
|
782
|
+
}, [f("div", {
|
|
762
783
|
ref_key: "frameEl",
|
|
763
784
|
ref: K,
|
|
764
|
-
class:
|
|
765
|
-
style:
|
|
785
|
+
class: v(["pk-image-editor__frame", { "pk-image-editor__frame--text": M.value === "text" }]),
|
|
786
|
+
style: y(ke.value),
|
|
766
787
|
onPointerdown: qe,
|
|
767
788
|
onPointermove: Je,
|
|
768
789
|
onPointerup: Ye,
|
|
769
|
-
onPointercancel: Xe
|
|
790
|
+
onPointercancel: Xe,
|
|
791
|
+
onLostpointercapture: Xe
|
|
770
792
|
}, [
|
|
771
|
-
|
|
793
|
+
f("div", {
|
|
772
794
|
ref_key: "stageEl",
|
|
773
795
|
ref: B,
|
|
774
796
|
class: "pk-image-editor__stage"
|
|
775
797
|
}, null, 512),
|
|
776
|
-
|
|
798
|
+
f("canvas", {
|
|
777
799
|
ref_key: "draftEl",
|
|
778
800
|
ref: Qe,
|
|
779
801
|
class: "pk-image-editor__draft",
|
|
@@ -781,26 +803,26 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
781
803
|
height: "0",
|
|
782
804
|
"aria-hidden": "true"
|
|
783
805
|
}, null, 512),
|
|
784
|
-
q.value ? (
|
|
806
|
+
q.value ? (b(), d("div", {
|
|
785
807
|
key: 0,
|
|
786
|
-
class:
|
|
787
|
-
style:
|
|
788
|
-
}, null, 6)) :
|
|
789
|
-
Q.value ?
|
|
808
|
+
class: v(["pk-image-editor__selection", `pk-image-editor__selection--${M.value}`]),
|
|
809
|
+
style: y(nt.value)
|
|
810
|
+
}, null, 6)) : u("", !0),
|
|
811
|
+
Q.value ? ie((b(), d("textarea", {
|
|
790
812
|
key: 1,
|
|
791
813
|
ref_key: "textEl",
|
|
792
814
|
ref: rt,
|
|
793
|
-
"onUpdate:modelValue":
|
|
815
|
+
"onUpdate:modelValue": r[6] ||= (e) => Q.value.text = e,
|
|
794
816
|
class: "pk-image-editor__text",
|
|
795
817
|
rows: "1",
|
|
796
818
|
maxlength: Ge,
|
|
797
|
-
"aria-label":
|
|
798
|
-
style:
|
|
799
|
-
onPointerdown:
|
|
800
|
-
onInput:
|
|
801
|
-
onKeydown: [
|
|
802
|
-
onBlur:
|
|
803
|
-
}, null, 44, He)), [[
|
|
819
|
+
"aria-label": w(j)("imageEditor.textLabel"),
|
|
820
|
+
style: y(pt.value),
|
|
821
|
+
onPointerdown: r[7] ||= oe(() => {}, ["stop"]),
|
|
822
|
+
onInput: dt,
|
|
823
|
+
onKeydown: [ae(lt, ["enter"]), ae(ut, ["esc"])],
|
|
824
|
+
onBlur: ot
|
|
825
|
+
}, null, 44, He)), [[re, Q.value.text]]) : u("", !0)
|
|
804
826
|
], 38)], 512)
|
|
805
827
|
]);
|
|
806
828
|
};
|
|
@@ -808,81 +830,81 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
808
830
|
}), X = ["aria-label"], Ke = {
|
|
809
831
|
key: 3,
|
|
810
832
|
class: "pk-image-editor-dialog__size"
|
|
811
|
-
}, qe = /* @__PURE__ */
|
|
833
|
+
}, qe = /* @__PURE__ */ h({
|
|
812
834
|
__name: "PkImageEditorDialog",
|
|
813
835
|
props: {
|
|
814
836
|
file: {},
|
|
815
837
|
initialTool: {}
|
|
816
838
|
},
|
|
817
839
|
emits: ["close", "apply"],
|
|
818
|
-
setup(e, { emit:
|
|
819
|
-
let
|
|
820
|
-
|
|
840
|
+
setup(e, { emit: n }) {
|
|
841
|
+
let s = e, f = n, { t: p } = se({ useScope: "global" }), h = A("(max-width: 575.98px)"), g = ne(), v = ne(), y = x(), S = x([]), T = x(!1), E = D("editorEl"), re = !1;
|
|
842
|
+
te(async () => {
|
|
821
843
|
try {
|
|
822
|
-
let e = await
|
|
823
|
-
if (
|
|
844
|
+
let e = await s.file, t = await V(e);
|
|
845
|
+
if (re) {
|
|
824
846
|
H(t.image);
|
|
825
847
|
return;
|
|
826
848
|
}
|
|
827
|
-
g.value = e,
|
|
849
|
+
g.value = e, v.value = t;
|
|
828
850
|
} catch {
|
|
829
|
-
|
|
851
|
+
y.value = "load";
|
|
830
852
|
}
|
|
831
|
-
}),
|
|
832
|
-
|
|
853
|
+
}), ee(() => {
|
|
854
|
+
re = !0, v.value && H(v.value.image);
|
|
833
855
|
});
|
|
834
|
-
let
|
|
835
|
-
async function
|
|
856
|
+
let O = c(() => v.value && ye(v.value.image, S.value)), ie = c(() => !!v.value && v.value.image.width < v.value.original.width), ae = c(() => S.value.length > 0 || !!E.value?.pending);
|
|
857
|
+
async function oe() {
|
|
836
858
|
let e = E.value, t = g.value;
|
|
837
859
|
if (e && t) {
|
|
838
|
-
if (e.applyPending(), !
|
|
860
|
+
if (e.applyPending(), !S.value.length) f("close");
|
|
839
861
|
else {
|
|
840
|
-
|
|
862
|
+
y.value = void 0, T.value = !0;
|
|
841
863
|
try {
|
|
842
|
-
await
|
|
864
|
+
await _();
|
|
843
865
|
let n = e.shownCanvas();
|
|
844
|
-
if (
|
|
866
|
+
if (y.value === "draw") return;
|
|
845
867
|
if (!n) throw Error("No image drawn");
|
|
846
|
-
let r = await
|
|
868
|
+
let r = await Oe(n, t.type);
|
|
847
869
|
f("apply", new File([r], B(t.name, t.type, r.type), {
|
|
848
870
|
type: r.type,
|
|
849
871
|
lastModified: Date.now()
|
|
850
872
|
}));
|
|
851
873
|
} catch {
|
|
852
|
-
|
|
874
|
+
y.value = "export";
|
|
853
875
|
} finally {
|
|
854
|
-
|
|
876
|
+
T.value = !1;
|
|
855
877
|
}
|
|
856
878
|
}
|
|
857
879
|
}
|
|
858
880
|
}
|
|
859
|
-
let
|
|
860
|
-
switch (
|
|
861
|
-
case "export": return
|
|
862
|
-
case "draw": return
|
|
863
|
-
default: return
|
|
881
|
+
let ce = c(() => {
|
|
882
|
+
switch (y.value) {
|
|
883
|
+
case "export": return p("imageEditor.exportFailed");
|
|
884
|
+
case "draw": return p("imageEditor.drawFailed");
|
|
885
|
+
default: return p("imageEditor.loadFailed");
|
|
864
886
|
}
|
|
865
887
|
});
|
|
866
|
-
return (
|
|
867
|
-
let
|
|
868
|
-
return
|
|
888
|
+
return (n, s) => {
|
|
889
|
+
let c = r, g = o, _ = t, ee = i, te = a;
|
|
890
|
+
return b(), l(te, {
|
|
869
891
|
"model-value": !0,
|
|
870
|
-
title:
|
|
871
|
-
modifiers:
|
|
892
|
+
title: w(p)("imageEditor.title"),
|
|
893
|
+
modifiers: w(h) ? "fullscreen" : void 0,
|
|
872
894
|
"keep-open": "",
|
|
873
895
|
class: "pk-image-editor-dialog",
|
|
874
896
|
"onUpdate:modelValue": s[3] ||= (e) => !e && f("close")
|
|
875
897
|
}, {
|
|
876
|
-
footer:
|
|
877
|
-
default:
|
|
898
|
+
footer: k(() => [m(ee, null, {
|
|
899
|
+
default: k(() => [m(_, {
|
|
878
900
|
modifiers: "secondary",
|
|
879
|
-
label:
|
|
901
|
+
label: w(p)("action.cancel"),
|
|
880
902
|
onClick: s[2] ||= (e) => f("close")
|
|
881
|
-
}, null, 8, ["label"]),
|
|
882
|
-
label:
|
|
883
|
-
loading:
|
|
884
|
-
disabled:
|
|
885
|
-
onClick:
|
|
903
|
+
}, null, 8, ["label"]), m(_, {
|
|
904
|
+
label: w(p)("imageEditor.use"),
|
|
905
|
+
loading: T.value,
|
|
906
|
+
disabled: T.value || !ae.value || y.value === "draw",
|
|
907
|
+
onClick: oe
|
|
886
908
|
}, null, 8, [
|
|
887
909
|
"label",
|
|
888
910
|
"loading",
|
|
@@ -890,39 +912,39 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
890
912
|
])]),
|
|
891
913
|
_: 1
|
|
892
914
|
})]),
|
|
893
|
-
default:
|
|
894
|
-
|
|
915
|
+
default: k(() => [
|
|
916
|
+
y.value ? (b(), l(c, {
|
|
895
917
|
key: 0,
|
|
896
918
|
modifiers: "danger",
|
|
897
919
|
class: "m-md",
|
|
898
|
-
content:
|
|
899
|
-
}, null, 8, ["content"])) :
|
|
900
|
-
|
|
920
|
+
content: ce.value
|
|
921
|
+
}, null, 8, ["content"])) : u("", !0),
|
|
922
|
+
v.value && y.value !== "draw" ? (b(), l(Y, {
|
|
901
923
|
key: 1,
|
|
902
924
|
ref_key: "editorEl",
|
|
903
925
|
ref: E,
|
|
904
|
-
edits:
|
|
905
|
-
"onUpdate:edits": s[0] ||= (e) =>
|
|
906
|
-
image:
|
|
926
|
+
edits: S.value,
|
|
927
|
+
"onUpdate:edits": s[0] ||= (e) => S.value = e,
|
|
928
|
+
image: v.value.image,
|
|
907
929
|
"initial-tool": e.initialTool,
|
|
908
|
-
onError: s[1] ||= (e) =>
|
|
930
|
+
onError: s[1] ||= (e) => y.value = "draw"
|
|
909
931
|
}, null, 8, [
|
|
910
932
|
"edits",
|
|
911
933
|
"image",
|
|
912
934
|
"initial-tool"
|
|
913
|
-
])) :
|
|
935
|
+
])) : y.value ? u("", !0) : (b(), d("div", {
|
|
914
936
|
key: 2,
|
|
915
937
|
class: "pk-image-editor-dialog__loading",
|
|
916
938
|
role: "status",
|
|
917
|
-
"aria-label":
|
|
918
|
-
}, [
|
|
919
|
-
|
|
920
|
-
width:
|
|
921
|
-
height:
|
|
922
|
-
}) :
|
|
923
|
-
width:
|
|
924
|
-
height:
|
|
925
|
-
})), 1)) :
|
|
939
|
+
"aria-label": w(p)("imageEditor.loading")
|
|
940
|
+
}, [m(g, { name: "loading-loop" })], 8, X)),
|
|
941
|
+
O.value ? (b(), d("p", Ke, C(ie.value ? w(p)("imageEditor.sizeScaledDown", {
|
|
942
|
+
width: O.value.width,
|
|
943
|
+
height: O.value.height
|
|
944
|
+
}) : w(p)("imageEditor.size", {
|
|
945
|
+
width: O.value.width,
|
|
946
|
+
height: O.value.height
|
|
947
|
+
})), 1)) : u("", !0)
|
|
926
948
|
]),
|
|
927
949
|
_: 1
|
|
928
950
|
}, 8, ["title", "modifiers"]);
|
|
@@ -931,4 +953,4 @@ var Ae = { class: "pk-image-editor" }, je = { class: "pk-image-editor__toolbar"
|
|
|
931
953
|
});
|
|
932
954
|
export { qe as default };
|
|
933
955
|
|
|
934
|
-
//# sourceMappingURL=PkImageEditorDialog-
|
|
956
|
+
//# sourceMappingURL=PkImageEditorDialog-BhfdnsmX.js.map
|