vuedit-image-editor 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
function
|
|
1
|
+
import { reactive as rt, ref as H, shallowRef as ct, computed as j, readonly as ut, provide as Ze, inject as ie, toRaw as dt, markRaw as ht, defineComponent as J, openBlock as S, createElementBlock as z, normalizeClass as N, renderSlot as vt, createCommentVNode as G, toDisplayString as q, createElementVNode as y, createVNode as X, unref as I, withCtx as ne, onMounted as ge, watch as re, onBeforeUnmount as he, withModifiers as ve, createBlock as pe, resolveDynamicComponent as Pe, onUpdated as ft, Fragment as Y, renderList as Z, Transition as Te, normalizeStyle as le, onUnmounted as pt, withKeys as Me, nextTick as Se, Teleport as mt } from "vue";
|
|
2
|
+
function $e() {
|
|
3
3
|
return {
|
|
4
4
|
crop: {
|
|
5
5
|
x: 0,
|
|
@@ -26,6 +26,7 @@ function ge() {
|
|
|
26
26
|
intensity: 1
|
|
27
27
|
},
|
|
28
28
|
stickers: [],
|
|
29
|
+
annotations: [],
|
|
29
30
|
frame: {
|
|
30
31
|
style: null,
|
|
31
32
|
size: 0.025,
|
|
@@ -39,28 +40,28 @@ function ge() {
|
|
|
39
40
|
backgroundColor: [0, 0, 0, 1]
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
return JSON.parse(JSON.stringify(
|
|
43
|
+
function ye(o) {
|
|
44
|
+
return JSON.parse(JSON.stringify(o));
|
|
44
45
|
}
|
|
45
|
-
class
|
|
46
|
+
class gt {
|
|
46
47
|
constructor(e = 50) {
|
|
47
48
|
this.states = [], this.pointer = -1, this.maxSize = e;
|
|
48
49
|
}
|
|
49
50
|
/** Push a new state snapshot. Truncates any future (redo) states. */
|
|
50
51
|
push(e) {
|
|
51
|
-
this.states = this.states.slice(0, this.pointer + 1), this.states.push(
|
|
52
|
+
this.states = this.states.slice(0, this.pointer + 1), this.states.push(ye(e)), this.states.length > this.maxSize && this.states.shift(), this.pointer = this.states.length - 1;
|
|
52
53
|
}
|
|
53
54
|
/** Undo: return the previous state, or null if at the beginning. */
|
|
54
55
|
undo() {
|
|
55
|
-
return this.pointer <= 0 ? null : (this.pointer--,
|
|
56
|
+
return this.pointer <= 0 ? null : (this.pointer--, ye(this.states[this.pointer]));
|
|
56
57
|
}
|
|
57
58
|
/** Redo: return the next state, or null if at the end. */
|
|
58
59
|
redo() {
|
|
59
|
-
return this.pointer >= this.states.length - 1 ? null : (this.pointer++,
|
|
60
|
+
return this.pointer >= this.states.length - 1 ? null : (this.pointer++, ye(this.states[this.pointer]));
|
|
60
61
|
}
|
|
61
62
|
/** Reset history with a single initial state. */
|
|
62
63
|
reset(e) {
|
|
63
|
-
this.states = [
|
|
64
|
+
this.states = [ye(e)], this.pointer = 0;
|
|
64
65
|
}
|
|
65
66
|
get canUndo() {
|
|
66
67
|
return this.pointer > 0;
|
|
@@ -75,122 +76,172 @@ class Qe {
|
|
|
75
76
|
return this.states.length;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
async function
|
|
79
|
-
const e = await
|
|
79
|
+
async function yt(o) {
|
|
80
|
+
const e = await wt(o);
|
|
80
81
|
return new Promise((n, t) => {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
typeof
|
|
84
|
-
},
|
|
85
|
-
typeof
|
|
86
|
-
},
|
|
82
|
+
const a = new Image();
|
|
83
|
+
a.crossOrigin = "anonymous", a.onload = () => {
|
|
84
|
+
typeof o != "string" && URL.revokeObjectURL(e), n(a);
|
|
85
|
+
}, a.onerror = () => {
|
|
86
|
+
typeof o != "string" && URL.revokeObjectURL(e), t(new Error(`Failed to load image: ${typeof o == "string" ? o : "Blob/File"}`));
|
|
87
|
+
}, a.src = e;
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
|
-
async function
|
|
90
|
-
return typeof
|
|
90
|
+
async function wt(o) {
|
|
91
|
+
return typeof o == "string" ? o : URL.createObjectURL(o);
|
|
91
92
|
}
|
|
92
|
-
const
|
|
93
|
-
function
|
|
94
|
-
return JSON.parse(JSON.stringify(
|
|
93
|
+
const Je = Symbol("vuedit-image-editor"), oe = Symbol("vuedit-locale");
|
|
94
|
+
function we(o) {
|
|
95
|
+
return JSON.parse(JSON.stringify(dt(o)));
|
|
95
96
|
}
|
|
96
|
-
function
|
|
97
|
-
const e =
|
|
98
|
-
|
|
99
|
-
), n =
|
|
100
|
-
t.reset(
|
|
101
|
-
const
|
|
102
|
-
let
|
|
103
|
-
const i =
|
|
104
|
-
async function
|
|
105
|
-
const O = ++
|
|
106
|
-
|
|
97
|
+
function kt(o) {
|
|
98
|
+
const e = rt(
|
|
99
|
+
o.initialState ? { ...$e(), ...JSON.parse(JSON.stringify(o.initialState)) } : $e()
|
|
100
|
+
), n = we(e), t = new gt(50);
|
|
101
|
+
t.reset(we(e));
|
|
102
|
+
const a = H(null), h = H(!1), r = H(null);
|
|
103
|
+
let s = 0;
|
|
104
|
+
const i = ct([]), v = H(null), l = H(1), c = H(null), m = H({ x: 0, y: 0 }), d = H(0), x = j(() => v.value && i.value.find((E) => E.id === v.value) || null), _ = j(() => (d.value, t.canUndo)), $ = j(() => (d.value, t.canRedo)), w = j(() => (d.value, t.currentIndex > 0));
|
|
105
|
+
async function u(E) {
|
|
106
|
+
const O = ++s;
|
|
107
|
+
h.value = !0, r.value = null;
|
|
107
108
|
try {
|
|
108
|
-
const
|
|
109
|
-
if (O !==
|
|
110
|
-
|
|
111
|
-
} catch (
|
|
112
|
-
if (O !==
|
|
113
|
-
|
|
109
|
+
const M = await yt(E);
|
|
110
|
+
if (O !== s) return;
|
|
111
|
+
a.value = M, L();
|
|
112
|
+
} catch (M) {
|
|
113
|
+
if (O !== s) return;
|
|
114
|
+
r.value = M instanceof Error ? M.message : "Failed to load image";
|
|
114
115
|
} finally {
|
|
115
|
-
O ===
|
|
116
|
+
O === s && (h.value = !1);
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
|
-
function
|
|
119
|
-
if (!
|
|
120
|
-
console.warn("[VueditImageEditor] Plugin missing required fields (id, controls):",
|
|
119
|
+
function g(E) {
|
|
120
|
+
if (!E.id || !E.controls) {
|
|
121
|
+
console.warn("[VueditImageEditor] Plugin missing required fields (id, controls):", E);
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
|
-
i.value.some((O) => O.id ===
|
|
124
|
+
i.value.some((O) => O.id === E.id) || (i.value = [...i.value, ht(E)], v.value || (v.value = E.id));
|
|
124
125
|
}
|
|
125
|
-
function
|
|
126
|
+
function k(E) {
|
|
126
127
|
var O;
|
|
127
|
-
i.value = i.value.filter((
|
|
128
|
+
i.value = i.value.filter((M) => M.id !== E), v.value === E && (v.value = ((O = i.value[0]) == null ? void 0 : O.id) || null);
|
|
128
129
|
}
|
|
129
|
-
function
|
|
130
|
-
const O =
|
|
131
|
-
O != null && O.onDeactivate && O.onDeactivate(),
|
|
132
|
-
const
|
|
133
|
-
|
|
130
|
+
function C(E) {
|
|
131
|
+
const O = x.value;
|
|
132
|
+
O != null && O.onDeactivate && O.onDeactivate(), v.value = E;
|
|
133
|
+
const M = i.value.find((F) => F.id === E);
|
|
134
|
+
M != null && M.onActivate && M.onActivate(), L();
|
|
134
135
|
}
|
|
135
|
-
function
|
|
136
|
-
|
|
136
|
+
function P(E) {
|
|
137
|
+
E(e), t.push(we(e)), d.value++, L();
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
-
const
|
|
140
|
-
|
|
139
|
+
function V() {
|
|
140
|
+
const E = t.undo();
|
|
141
|
+
E && (Object.assign(e, E), d.value++, L());
|
|
141
142
|
}
|
|
142
|
-
function
|
|
143
|
-
const
|
|
144
|
-
|
|
143
|
+
function A() {
|
|
144
|
+
const E = t.redo();
|
|
145
|
+
E && (Object.assign(e, E), d.value++, L());
|
|
145
146
|
}
|
|
146
|
-
function
|
|
147
|
-
const
|
|
148
|
-
|
|
147
|
+
function D() {
|
|
148
|
+
const E = x.value;
|
|
149
|
+
E != null && E.onDeactivate && E.onDeactivate(), Object.assign(e, JSON.parse(JSON.stringify(n))), t.reset(we(e)), d.value++, E != null && E.onActivate && E.onActivate(), L();
|
|
149
150
|
}
|
|
150
|
-
function
|
|
151
|
-
|
|
151
|
+
function K(E) {
|
|
152
|
+
l.value = Math.max(0.1, Math.min(10, E)), L();
|
|
152
153
|
}
|
|
153
|
-
function
|
|
154
|
-
c.value && c.value();
|
|
154
|
+
function L(E = !1) {
|
|
155
|
+
c.value && c.value(E);
|
|
155
156
|
}
|
|
156
157
|
return {
|
|
157
158
|
state: e,
|
|
158
|
-
readonlyState:
|
|
159
|
-
sourceImage:
|
|
160
|
-
loading:
|
|
161
|
-
error:
|
|
159
|
+
readonlyState: ut(e),
|
|
160
|
+
sourceImage: a,
|
|
161
|
+
loading: h,
|
|
162
|
+
error: r,
|
|
162
163
|
plugins: i,
|
|
163
|
-
activePluginId:
|
|
164
|
-
activePlugin:
|
|
165
|
-
hasEdits:
|
|
166
|
-
canUndo:
|
|
164
|
+
activePluginId: v,
|
|
165
|
+
activePlugin: x,
|
|
166
|
+
hasEdits: w,
|
|
167
|
+
canUndo: _,
|
|
167
168
|
canRedo: $,
|
|
168
|
-
zoom:
|
|
169
|
-
options:
|
|
170
|
-
load:
|
|
171
|
-
registerPlugin:
|
|
172
|
-
unregisterPlugin:
|
|
173
|
-
setActivePlugin:
|
|
174
|
-
updateState:
|
|
175
|
-
undo:
|
|
176
|
-
redo:
|
|
177
|
-
revert:
|
|
178
|
-
setZoom:
|
|
179
|
-
requestRender:
|
|
169
|
+
zoom: l,
|
|
170
|
+
options: o,
|
|
171
|
+
load: u,
|
|
172
|
+
registerPlugin: g,
|
|
173
|
+
unregisterPlugin: k,
|
|
174
|
+
setActivePlugin: C,
|
|
175
|
+
updateState: P,
|
|
176
|
+
undo: V,
|
|
177
|
+
redo: A,
|
|
178
|
+
revert: D,
|
|
179
|
+
setZoom: K,
|
|
180
|
+
requestRender: L,
|
|
180
181
|
onRender: c,
|
|
181
|
-
cropDragPan:
|
|
182
|
+
cropDragPan: m
|
|
182
183
|
};
|
|
183
184
|
}
|
|
184
|
-
function
|
|
185
|
-
|
|
185
|
+
function bt(o) {
|
|
186
|
+
Ze(Je, o);
|
|
186
187
|
}
|
|
187
|
-
function
|
|
188
|
-
const
|
|
189
|
-
if (!
|
|
188
|
+
function ee() {
|
|
189
|
+
const o = ie(Je);
|
|
190
|
+
if (!o)
|
|
190
191
|
throw new Error("[VueditImageEditor] useEditor() called outside of editor context. Make sure to use it inside <EditorShell> or <ImageEditorModal>.");
|
|
191
|
-
return
|
|
192
|
+
return o;
|
|
192
193
|
}
|
|
193
|
-
|
|
194
|
+
function De(o) {
|
|
195
|
+
return `rgba(${Math.round(o[0] * 255)}, ${Math.round(o[1] * 255)}, ${Math.round(o[2] * 255)}, ${o[3]})`;
|
|
196
|
+
}
|
|
197
|
+
function Ee(o, e, n, t, a, h) {
|
|
198
|
+
const r = n + e.x * a, s = t + e.y * h, i = e.width * a, v = e.height * h, l = e.strokeWidth * Math.max(a, h);
|
|
199
|
+
if (o.save(), o.globalAlpha = e.opacity, e.rotation !== 0) {
|
|
200
|
+
const w = r + i / 2, u = s + v / 2;
|
|
201
|
+
o.translate(w, u), o.rotate(e.rotation), o.translate(-w, -u);
|
|
202
|
+
}
|
|
203
|
+
const c = e.fontSize * h, m = e.fontStyle === "italic" ? "italic " : "", d = e.fontWeight === "bold" ? "bold " : "";
|
|
204
|
+
o.font = `${m}${d}${c}px ${e.fontFamily}`, o.fillStyle = De(e.fillColor), o.textAlign = e.textAlign, o.textBaseline = "top", o.save(), o.beginPath(), o.rect(r, s, i, v), o.clip();
|
|
205
|
+
let x = r;
|
|
206
|
+
e.textAlign === "center" ? x = r + i / 2 : e.textAlign === "right" && (x = r + i);
|
|
207
|
+
const _ = Ct(o, e.text, i), $ = c * 1.2;
|
|
208
|
+
for (let w = 0; w < _.length; w++)
|
|
209
|
+
o.fillText(_[w], x, s + w * $);
|
|
210
|
+
o.restore(), e.strokeColor[3] > 0 && l > 0.5 && (o.strokeStyle = De(e.strokeColor), o.lineWidth = l * 0.5, o.strokeRect(r, s, i, v)), o.restore();
|
|
211
|
+
}
|
|
212
|
+
function xt(o, e, n, t, a, h, r) {
|
|
213
|
+
if (n.width <= 0 || n.height <= 0) return;
|
|
214
|
+
const s = _t(e, n);
|
|
215
|
+
s && Ee(o, s, t, a, h, r);
|
|
216
|
+
}
|
|
217
|
+
function _t(o, e) {
|
|
218
|
+
const n = (o.x - e.x) / e.width, t = (o.y - e.y) / e.height, a = o.width / e.width, h = o.height / e.height;
|
|
219
|
+
return n + a < 0 || n > 1 || t + h < 0 || t > 1 ? null : {
|
|
220
|
+
...o,
|
|
221
|
+
x: n,
|
|
222
|
+
y: t,
|
|
223
|
+
width: a,
|
|
224
|
+
height: h,
|
|
225
|
+
strokeWidth: o.strokeWidth / Math.max(e.width, e.height),
|
|
226
|
+
fontSize: o.fontSize / e.height
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function Ct(o, e, n) {
|
|
230
|
+
if (!e) return [""];
|
|
231
|
+
const t = e.split(`
|
|
232
|
+
`), a = [];
|
|
233
|
+
for (const h of t) {
|
|
234
|
+
const r = h.split(" ");
|
|
235
|
+
let s = "";
|
|
236
|
+
for (const i of r) {
|
|
237
|
+
const v = s ? `${s} ${i}` : i;
|
|
238
|
+
o.measureText(v).width > n && s ? (a.push(s), s = i) : s = v;
|
|
239
|
+
}
|
|
240
|
+
a.push(s);
|
|
241
|
+
}
|
|
242
|
+
return a;
|
|
243
|
+
}
|
|
244
|
+
const We = [
|
|
194
245
|
1,
|
|
195
246
|
0,
|
|
196
247
|
0,
|
|
@@ -212,41 +263,41 @@ const xe = [
|
|
|
212
263
|
1,
|
|
213
264
|
0
|
|
214
265
|
];
|
|
215
|
-
function
|
|
266
|
+
function Mt(o, e) {
|
|
216
267
|
const n = new Array(20).fill(0);
|
|
217
268
|
for (let t = 0; t < 4; t++)
|
|
218
|
-
for (let
|
|
219
|
-
let
|
|
220
|
-
for (let
|
|
221
|
-
|
|
222
|
-
|
|
269
|
+
for (let a = 0; a < 5; a++) {
|
|
270
|
+
let h = 0;
|
|
271
|
+
for (let r = 0; r < 4; r++)
|
|
272
|
+
h += o[t * 5 + r] * e[r * 5 + a];
|
|
273
|
+
a === 4 && (h += o[t * 5 + 4]), n[t * 5 + a] = h;
|
|
223
274
|
}
|
|
224
275
|
return n;
|
|
225
276
|
}
|
|
226
|
-
function
|
|
227
|
-
if (
|
|
228
|
-
let e =
|
|
229
|
-
for (let n = 1; n <
|
|
230
|
-
e =
|
|
277
|
+
function Ge(...o) {
|
|
278
|
+
if (o.length === 0) return [...We];
|
|
279
|
+
let e = o[0];
|
|
280
|
+
for (let n = 1; n < o.length; n++)
|
|
281
|
+
e = Mt(o[n], e);
|
|
231
282
|
return e;
|
|
232
283
|
}
|
|
233
|
-
function
|
|
284
|
+
function Qe(o) {
|
|
234
285
|
return [
|
|
235
286
|
1,
|
|
236
287
|
0,
|
|
237
288
|
0,
|
|
238
289
|
0,
|
|
239
|
-
|
|
290
|
+
o,
|
|
240
291
|
0,
|
|
241
292
|
1,
|
|
242
293
|
0,
|
|
243
294
|
0,
|
|
244
|
-
|
|
295
|
+
o,
|
|
245
296
|
0,
|
|
246
297
|
0,
|
|
247
298
|
1,
|
|
248
299
|
0,
|
|
249
|
-
|
|
300
|
+
o,
|
|
250
301
|
0,
|
|
251
302
|
0,
|
|
252
303
|
0,
|
|
@@ -254,8 +305,8 @@ function Le(s) {
|
|
|
254
305
|
0
|
|
255
306
|
];
|
|
256
307
|
}
|
|
257
|
-
function
|
|
258
|
-
const e =
|
|
308
|
+
function et(o) {
|
|
309
|
+
const e = o + 1, n = -0.5 * e + 0.5;
|
|
259
310
|
return [
|
|
260
311
|
e,
|
|
261
312
|
0,
|
|
@@ -279,22 +330,22 @@ function Ae(s) {
|
|
|
279
330
|
0
|
|
280
331
|
];
|
|
281
332
|
}
|
|
282
|
-
function
|
|
283
|
-
const e =
|
|
333
|
+
function tt(o) {
|
|
334
|
+
const e = o + 1, n = 1 - e, t = 0.2126 * n, a = 0.7152 * n, h = 0.0722 * n;
|
|
284
335
|
return [
|
|
285
336
|
t + e,
|
|
286
|
-
|
|
287
|
-
|
|
337
|
+
a,
|
|
338
|
+
h,
|
|
288
339
|
0,
|
|
289
340
|
0,
|
|
290
341
|
t,
|
|
291
|
-
|
|
292
|
-
|
|
342
|
+
a + e,
|
|
343
|
+
h,
|
|
293
344
|
0,
|
|
294
345
|
0,
|
|
295
346
|
t,
|
|
296
|
-
|
|
297
|
-
|
|
347
|
+
a,
|
|
348
|
+
h + e,
|
|
298
349
|
0,
|
|
299
350
|
0,
|
|
300
351
|
0,
|
|
@@ -304,8 +355,8 @@ function Fe(s) {
|
|
|
304
355
|
0
|
|
305
356
|
];
|
|
306
357
|
}
|
|
307
|
-
function
|
|
308
|
-
const e = Math.pow(2,
|
|
358
|
+
function nt(o) {
|
|
359
|
+
const e = Math.pow(2, o);
|
|
309
360
|
return [
|
|
310
361
|
e,
|
|
311
362
|
0,
|
|
@@ -329,9 +380,9 @@ function He(s) {
|
|
|
329
380
|
0
|
|
330
381
|
];
|
|
331
382
|
}
|
|
332
|
-
function
|
|
383
|
+
function it(o) {
|
|
333
384
|
return [
|
|
334
|
-
1 +
|
|
385
|
+
1 + o,
|
|
335
386
|
0,
|
|
336
387
|
0,
|
|
337
388
|
0,
|
|
@@ -343,7 +394,7 @@ function Ve(s) {
|
|
|
343
394
|
0,
|
|
344
395
|
0,
|
|
345
396
|
0,
|
|
346
|
-
1 -
|
|
397
|
+
1 - o,
|
|
347
398
|
0,
|
|
348
399
|
0,
|
|
349
400
|
0,
|
|
@@ -353,194 +404,196 @@ function Ve(s) {
|
|
|
353
404
|
0
|
|
354
405
|
];
|
|
355
406
|
}
|
|
356
|
-
function
|
|
357
|
-
const n =
|
|
358
|
-
for (let
|
|
359
|
-
const
|
|
360
|
-
n[
|
|
407
|
+
function Ae(o, e) {
|
|
408
|
+
const n = o.data, t = n.length, a = e[0], h = e[1], r = e[2], s = e[3], i = e[4] * 255, v = e[5], l = e[6], c = e[7], m = e[8], d = e[9] * 255, x = e[10], _ = e[11], $ = e[12], w = e[13], u = e[14] * 255, g = e[15], k = e[16], C = e[17], P = e[18], V = e[19] * 255;
|
|
409
|
+
for (let A = 0; A < t; A += 4) {
|
|
410
|
+
const D = n[A], K = n[A + 1], L = n[A + 2], E = n[A + 3];
|
|
411
|
+
n[A] = ce(D * a + K * h + L * r + E * s + i), n[A + 1] = ce(D * v + K * l + L * c + E * m + d), n[A + 2] = ce(D * x + K * _ + L * $ + E * w + u), n[A + 3] = ce(D * g + K * k + L * C + E * P + V);
|
|
361
412
|
}
|
|
362
413
|
}
|
|
363
|
-
function
|
|
414
|
+
function Re(o, e) {
|
|
364
415
|
if (e === 1) return;
|
|
365
|
-
const n =
|
|
366
|
-
for (let
|
|
367
|
-
|
|
368
|
-
for (let
|
|
369
|
-
n[
|
|
416
|
+
const n = o.data, t = 1 / e, a = new Uint8Array(256);
|
|
417
|
+
for (let h = 0; h < 256; h++)
|
|
418
|
+
a[h] = ce(Math.pow(h / 255, t) * 255);
|
|
419
|
+
for (let h = 0; h < n.length; h += 4)
|
|
420
|
+
n[h] = a[n[h]], n[h + 1] = a[n[h + 1]], n[h + 2] = a[n[h + 2]];
|
|
370
421
|
}
|
|
371
|
-
function
|
|
422
|
+
function ze(o, e, n, t) {
|
|
372
423
|
if (e === 0) return;
|
|
373
|
-
const
|
|
424
|
+
const a = o.data, h = n / 2, r = t / 2, s = Math.sqrt(h * h + r * r);
|
|
374
425
|
for (let i = 0; i < t; i++)
|
|
375
|
-
for (let
|
|
376
|
-
const
|
|
377
|
-
|
|
426
|
+
for (let v = 0; v < n; v++) {
|
|
427
|
+
const l = (i * n + v) * 4, c = v - h, m = i - r, d = Math.sqrt(c * c + m * m) / s, x = 1 - e * d * d;
|
|
428
|
+
a[l] = ce(a[l] * x), a[l + 1] = ce(a[l + 1] * x), a[l + 2] = ce(a[l + 2] * x);
|
|
378
429
|
}
|
|
379
430
|
}
|
|
380
|
-
function
|
|
431
|
+
function Ie(o, e) {
|
|
381
432
|
if (e === 0) return;
|
|
382
|
-
const { data: n, width: t, height:
|
|
383
|
-
for (let
|
|
433
|
+
const { data: n, width: t, height: a } = o, h = e * 4, r = new Uint8ClampedArray(n);
|
|
434
|
+
for (let s = 1; s < a - 1; s++)
|
|
384
435
|
for (let i = 1; i < t - 1; i++) {
|
|
385
|
-
const
|
|
386
|
-
for (let
|
|
387
|
-
const c =
|
|
388
|
-
n[
|
|
436
|
+
const v = (s * t + i) * 4;
|
|
437
|
+
for (let l = 0; l < 3; l++) {
|
|
438
|
+
const c = r[v + l], m = c * 4 - r[((s - 1) * t + i) * 4 + l] - r[((s + 1) * t + i) * 4 + l] - r[(s * t + (i - 1)) * 4 + l] - r[(s * t + (i + 1)) * 4 + l], d = c + h * m;
|
|
439
|
+
n[v + l] = d < 0 ? 0 : d > 255 ? 255 : d + 0.5 | 0;
|
|
389
440
|
}
|
|
390
441
|
}
|
|
391
442
|
}
|
|
392
|
-
function
|
|
393
|
-
return
|
|
443
|
+
function ce(o) {
|
|
444
|
+
return o < 0 ? 0 : o > 255 ? 255 : o + 0.5 | 0;
|
|
394
445
|
}
|
|
395
|
-
const
|
|
396
|
-
class
|
|
446
|
+
const St = 16777216;
|
|
447
|
+
class $t {
|
|
397
448
|
/**
|
|
398
449
|
* Process image at FULL RESOLUTION.
|
|
399
450
|
* Applies all transformations and exports as Blob.
|
|
400
451
|
*/
|
|
401
452
|
async process(e, n, t = {}) {
|
|
402
453
|
const {
|
|
403
|
-
mimeType:
|
|
404
|
-
quality:
|
|
405
|
-
maxCanvasPixels:
|
|
406
|
-
} = t,
|
|
407
|
-
let
|
|
408
|
-
|
|
409
|
-
let
|
|
454
|
+
mimeType: a = "image/jpeg",
|
|
455
|
+
quality: h = 0.92,
|
|
456
|
+
maxCanvasPixels: r = St
|
|
457
|
+
} = t, s = n.crop, i = n.finetune;
|
|
458
|
+
let v = Math.round(s.x * e.naturalWidth), l = Math.round(s.y * e.naturalHeight), c = Math.round(s.width * e.naturalWidth), m = Math.round(s.height * e.naturalHeight);
|
|
459
|
+
v = Math.max(0, Math.min(v, e.naturalWidth)), l = Math.max(0, Math.min(l, e.naturalHeight)), c = Math.min(c, e.naturalWidth - v), m = Math.min(m, e.naturalHeight - l);
|
|
460
|
+
let d = c, x = m;
|
|
410
461
|
if (n.resize.width || n.resize.height) {
|
|
411
|
-
const
|
|
412
|
-
if (
|
|
413
|
-
if (
|
|
414
|
-
|
|
415
|
-
else if (
|
|
416
|
-
const
|
|
417
|
-
|
|
462
|
+
const A = n.resize.width, D = n.resize.height, K = n.resize.fit;
|
|
463
|
+
if (A && D)
|
|
464
|
+
if (K === "force")
|
|
465
|
+
d = A, x = D;
|
|
466
|
+
else if (K === "cover") {
|
|
467
|
+
const L = Math.max(A / c, D / m);
|
|
468
|
+
d = Math.round(c * L), x = Math.round(m * L);
|
|
418
469
|
} else {
|
|
419
|
-
const
|
|
420
|
-
|
|
470
|
+
const L = Math.min(A / c, D / m);
|
|
471
|
+
d = Math.round(c * L), x = Math.round(m * L);
|
|
421
472
|
}
|
|
422
|
-
else if (
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
} else if (
|
|
426
|
-
const
|
|
427
|
-
|
|
473
|
+
else if (A) {
|
|
474
|
+
const L = A / c;
|
|
475
|
+
d = A, x = Math.round(m * L);
|
|
476
|
+
} else if (D) {
|
|
477
|
+
const L = D / m;
|
|
478
|
+
d = Math.round(c * L), x = D;
|
|
428
479
|
}
|
|
429
|
-
n.resize.upscale || (
|
|
480
|
+
n.resize.upscale || (d = Math.min(d, c), x = Math.min(x, m));
|
|
430
481
|
}
|
|
431
|
-
const
|
|
432
|
-
if (
|
|
433
|
-
const
|
|
434
|
-
|
|
482
|
+
const _ = d * x;
|
|
483
|
+
if (_ > r) {
|
|
484
|
+
const A = Math.sqrt(r / _);
|
|
485
|
+
d = Math.floor(d * A), x = Math.floor(x * A);
|
|
435
486
|
}
|
|
436
|
-
|
|
437
|
-
const $ = Math.abs(
|
|
438
|
-
let
|
|
487
|
+
d = Math.max(1, d), x = Math.max(1, x);
|
|
488
|
+
const $ = Math.abs(s.rotation);
|
|
489
|
+
let w = d, u = x;
|
|
439
490
|
if ($ > 1e-3) {
|
|
440
|
-
const
|
|
441
|
-
|
|
491
|
+
const A = Math.abs(Math.cos(s.rotation)), D = Math.abs(Math.sin(s.rotation));
|
|
492
|
+
w = Math.ceil(d * A + x * D), u = Math.ceil(d * D + x * A);
|
|
442
493
|
}
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
const
|
|
446
|
-
|
|
494
|
+
const g = document.createElement("canvas");
|
|
495
|
+
g.width = w, g.height = u;
|
|
496
|
+
const k = g.getContext("2d"), C = n.backgroundColor;
|
|
497
|
+
C[3] > 0 && (k.fillStyle = `rgba(${Math.round(C[0] * 255)}, ${Math.round(C[1] * 255)}, ${Math.round(C[2] * 255)}, ${C[3]})`, k.fillRect(0, 0, w, u)), k.save(), k.translate(w / 2, u / 2), k.rotate(s.rotation), k.scale(s.flipX ? -1 : 1, s.flipY ? -1 : 1), k.drawImage(
|
|
447
498
|
e,
|
|
448
|
-
h,
|
|
449
|
-
a,
|
|
450
|
-
c,
|
|
451
|
-
y,
|
|
452
|
-
-v / 2,
|
|
453
|
-
-w / 2,
|
|
454
499
|
v,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
500
|
+
l,
|
|
501
|
+
c,
|
|
502
|
+
m,
|
|
503
|
+
-d / 2,
|
|
504
|
+
-x / 2,
|
|
505
|
+
d,
|
|
506
|
+
x
|
|
507
|
+
), k.restore();
|
|
508
|
+
const P = [];
|
|
509
|
+
if (i.brightness !== 0 && P.push(Qe(i.brightness)), i.contrast !== 0 && P.push(et(i.contrast)), i.saturation !== 0 && P.push(tt(i.saturation)), i.exposure !== 0 && P.push(nt(i.exposure)), i.temperature !== 0 && P.push(it(i.temperature)), n.filter.matrix)
|
|
459
510
|
if (n.filter.intensity < 1) {
|
|
460
|
-
const
|
|
461
|
-
|
|
511
|
+
const A = n.filter.matrix, D = n.filter.intensity, K = We.map((L, E) => L * (1 - D) + A[E] * D);
|
|
512
|
+
P.push(K);
|
|
462
513
|
} else
|
|
463
|
-
|
|
464
|
-
if (
|
|
465
|
-
const
|
|
466
|
-
|
|
514
|
+
P.push(n.filter.matrix);
|
|
515
|
+
if (P.length > 0) {
|
|
516
|
+
const A = Ge(...P), D = k.getImageData(0, 0, w, u);
|
|
517
|
+
Ae(D, A), i.gamma !== 1 && Re(D, i.gamma), i.clarity !== 0 && Ie(D, i.clarity), i.vignette !== 0 && ze(D, i.vignette, w, u), k.putImageData(D, 0, 0);
|
|
467
518
|
} else if (i.gamma !== 1 || i.clarity !== 0 || i.vignette !== 0) {
|
|
468
|
-
const
|
|
469
|
-
i.gamma !== 1 &&
|
|
470
|
-
}
|
|
471
|
-
n.frame.style &&
|
|
472
|
-
for (const
|
|
473
|
-
await
|
|
519
|
+
const A = k.getImageData(0, 0, w, u);
|
|
520
|
+
i.gamma !== 1 && Re(A, i.gamma), i.clarity !== 0 && Ie(A, i.clarity), i.vignette !== 0 && ze(A, i.vignette, w, u), k.putImageData(A, 0, 0);
|
|
521
|
+
}
|
|
522
|
+
n.frame.style && Rt(k, n.frame.style, n.frame.size, n.frame.color, n.frame.radius, w, u);
|
|
523
|
+
for (const A of n.stickers)
|
|
524
|
+
await It(k, A, w, u);
|
|
525
|
+
for (const A of n.annotations)
|
|
526
|
+
Ee(k, A, 0, 0, w, u);
|
|
474
527
|
return {
|
|
475
|
-
blob: await new Promise((
|
|
476
|
-
|
|
477
|
-
(
|
|
478
|
-
|
|
479
|
-
|
|
528
|
+
blob: await new Promise((A, D) => {
|
|
529
|
+
g.toBlob(
|
|
530
|
+
(K) => K ? A(K) : D(new Error("Failed to encode image")),
|
|
531
|
+
a,
|
|
532
|
+
h
|
|
480
533
|
);
|
|
481
534
|
}),
|
|
482
535
|
imageState: JSON.parse(JSON.stringify(n))
|
|
483
536
|
};
|
|
484
537
|
}
|
|
485
538
|
}
|
|
486
|
-
function
|
|
487
|
-
const
|
|
488
|
-
switch (
|
|
539
|
+
function Rt(o, e, n, t, a, h, r) {
|
|
540
|
+
const s = Math.round(Math.max(h, r) * n), i = Math.round(a), v = `rgba(${Math.round(t[0] * 255)}, ${Math.round(t[1] * 255)}, ${Math.round(t[2] * 255)}, ${t[3]})`;
|
|
541
|
+
switch (o.strokeStyle = v, o.fillStyle = v, e) {
|
|
489
542
|
case "solidSharp":
|
|
490
|
-
|
|
543
|
+
o.lineWidth = s, o.strokeRect(s / 2, s / 2, h - s, r - s);
|
|
491
544
|
break;
|
|
492
545
|
case "solidRound":
|
|
493
|
-
|
|
546
|
+
o.lineWidth = s, zt(o, s / 2, s / 2, h - s, r - s, i + s / 2), o.stroke();
|
|
494
547
|
break;
|
|
495
548
|
case "lineSingle": {
|
|
496
|
-
const
|
|
497
|
-
|
|
549
|
+
const l = s * 2;
|
|
550
|
+
o.lineWidth = 1, o.strokeRect(l, l, h - l * 2, r - l * 2);
|
|
498
551
|
break;
|
|
499
552
|
}
|
|
500
553
|
case "lineMultiple": {
|
|
501
|
-
|
|
502
|
-
for (let
|
|
503
|
-
const c =
|
|
504
|
-
|
|
554
|
+
o.lineWidth = 1;
|
|
555
|
+
for (let l = 1; l <= 3; l++) {
|
|
556
|
+
const c = s * l;
|
|
557
|
+
o.strokeRect(c, c, h - c * 2, r - c * 2);
|
|
505
558
|
}
|
|
506
559
|
break;
|
|
507
560
|
}
|
|
508
561
|
case "hook": {
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
const c =
|
|
512
|
-
|
|
562
|
+
const l = Math.min(h, r) * 0.1;
|
|
563
|
+
o.lineWidth = s * 0.5;
|
|
564
|
+
const c = s;
|
|
565
|
+
o.beginPath(), o.moveTo(c, c + l), o.lineTo(c, c), o.lineTo(c + l, c), o.stroke(), o.beginPath(), o.moveTo(h - c - l, c), o.lineTo(h - c, c), o.lineTo(h - c, c + l), o.stroke(), o.beginPath(), o.moveTo(c, r - c - l), o.lineTo(c, r - c), o.lineTo(c + l, r - c), o.stroke(), o.beginPath(), o.moveTo(h - c - l, r - c), o.lineTo(h - c, r - c), o.lineTo(h - c, r - c - l), o.stroke();
|
|
513
566
|
break;
|
|
514
567
|
}
|
|
515
568
|
case "polaroid": {
|
|
516
|
-
const
|
|
517
|
-
|
|
569
|
+
const l = s, c = s * 4;
|
|
570
|
+
o.fillRect(0, 0, h, l), o.fillRect(0, 0, l, r), o.fillRect(h - l, 0, l, r), o.fillRect(0, r - c, h, c);
|
|
518
571
|
break;
|
|
519
572
|
}
|
|
520
573
|
default:
|
|
521
|
-
|
|
574
|
+
o.lineWidth = s * 0.5, o.strokeRect(s, s, h - s * 2, r - s * 2);
|
|
522
575
|
break;
|
|
523
576
|
}
|
|
524
577
|
}
|
|
525
|
-
function
|
|
526
|
-
|
|
578
|
+
function zt(o, e, n, t, a, h) {
|
|
579
|
+
o.beginPath(), o.moveTo(e + h, n), o.lineTo(e + t - h, n), o.arcTo(e + t, n, e + t, n + h, h), o.lineTo(e + t, n + a - h), o.arcTo(e + t, n + a, e + t - h, n + a, h), o.lineTo(e + h, n + a), o.arcTo(e, n + a, e, n + a - h, h), o.lineTo(e, n + h), o.arcTo(e, n, e + h, n, h), o.closePath();
|
|
527
580
|
}
|
|
528
|
-
async function
|
|
529
|
-
const
|
|
530
|
-
if (
|
|
531
|
-
const i = Math.min(
|
|
532
|
-
|
|
581
|
+
async function It(o, e, n, t) {
|
|
582
|
+
const a = e.x * n, h = e.y * t, r = e.width * n, s = e.height * t;
|
|
583
|
+
if (o.save(), o.globalAlpha = e.opacity, o.translate(a + r / 2, h + s / 2), o.rotate(e.rotation), o.scale(e.flipX ? -1 : 1, e.flipY ? -1 : 1), !e.src.startsWith("http") && !e.src.startsWith("data:") && !e.src.startsWith("blob:") && !e.src.startsWith("/") && !e.src.startsWith(".")) {
|
|
584
|
+
const i = Math.min(r, s) * 0.8;
|
|
585
|
+
o.font = `${i}px sans-serif`, o.textAlign = "center", o.textBaseline = "middle", o.fillText(e.src, 0, 0);
|
|
533
586
|
} else
|
|
534
587
|
try {
|
|
535
588
|
const i = new Image();
|
|
536
|
-
i.crossOrigin = "anonymous", await new Promise((
|
|
537
|
-
i.onload = () =>
|
|
538
|
-
}),
|
|
589
|
+
i.crossOrigin = "anonymous", await new Promise((v, l) => {
|
|
590
|
+
i.onload = () => v(), i.onerror = () => l(), i.src = e.src;
|
|
591
|
+
}), o.drawImage(i, -r / 2, -s / 2, r, s);
|
|
539
592
|
} catch {
|
|
540
593
|
}
|
|
541
|
-
|
|
594
|
+
o.restore();
|
|
542
595
|
}
|
|
543
|
-
const
|
|
596
|
+
const Pt = {
|
|
544
597
|
// Toolbar
|
|
545
598
|
undo: "Undo",
|
|
546
599
|
redo: "Redo",
|
|
@@ -627,10 +680,20 @@ const ut = {
|
|
|
627
680
|
processing: "Processing...",
|
|
628
681
|
// Crop overlay
|
|
629
682
|
cropApply: "Apply",
|
|
683
|
+
// Text annotation labels
|
|
684
|
+
text: "Text",
|
|
685
|
+
fillColor: "Fill Color",
|
|
686
|
+
fontSize: "Font Size",
|
|
687
|
+
fontFamily: "Font Family",
|
|
688
|
+
bold: "Bold",
|
|
689
|
+
italic: "Italic",
|
|
690
|
+
textAlign: "Text Align",
|
|
691
|
+
delete: "Delete",
|
|
692
|
+
opacity: "Opacity",
|
|
630
693
|
// Confirmation
|
|
631
694
|
unsavedChanges: "You have unsaved changes. Are you sure you want to close?",
|
|
632
695
|
confirm: "Confirm"
|
|
633
|
-
},
|
|
696
|
+
}, Tt = {
|
|
634
697
|
// Toolbar
|
|
635
698
|
undo: "تراجع",
|
|
636
699
|
redo: "إعادة",
|
|
@@ -717,16 +780,26 @@ const ut = {
|
|
|
717
780
|
processing: "جاري المعالجة...",
|
|
718
781
|
// Crop overlay
|
|
719
782
|
cropApply: "تطبيق",
|
|
783
|
+
// Text annotation labels
|
|
784
|
+
text: "نص",
|
|
785
|
+
fillColor: "لون التعبئة",
|
|
786
|
+
fontSize: "حجم الخط",
|
|
787
|
+
fontFamily: "نوع الخط",
|
|
788
|
+
bold: "عريض",
|
|
789
|
+
italic: "مائل",
|
|
790
|
+
textAlign: "محاذاة النص",
|
|
791
|
+
delete: "حذف",
|
|
792
|
+
opacity: "الشفافية",
|
|
720
793
|
// Confirmation
|
|
721
794
|
unsavedChanges: "لديك تغييرات غير محفوظة. هل أنت متأكد أنك تريد الإغلاق؟",
|
|
722
795
|
confirm: "تأكيد"
|
|
723
|
-
},
|
|
796
|
+
}, Et = ["disabled", "title"], Wt = {
|
|
724
797
|
key: 0,
|
|
725
798
|
class: "vie-icon-btn__icon"
|
|
726
|
-
},
|
|
799
|
+
}, At = {
|
|
727
800
|
key: 1,
|
|
728
801
|
class: "vie-icon-btn__label"
|
|
729
|
-
},
|
|
802
|
+
}, se = /* @__PURE__ */ J({
|
|
730
803
|
__name: "IconButton",
|
|
731
804
|
props: {
|
|
732
805
|
title: {},
|
|
@@ -735,27 +808,27 @@ const ut = {
|
|
|
735
808
|
variant: {}
|
|
736
809
|
},
|
|
737
810
|
emits: ["click"],
|
|
738
|
-
setup(
|
|
739
|
-
return (e, n) => (
|
|
740
|
-
class:
|
|
811
|
+
setup(o) {
|
|
812
|
+
return (e, n) => (S(), z("button", {
|
|
813
|
+
class: N([
|
|
741
814
|
"vie-icon-btn",
|
|
742
|
-
{ "vie-icon-btn--accent":
|
|
815
|
+
{ "vie-icon-btn--accent": o.variant === "accent" }
|
|
743
816
|
]),
|
|
744
|
-
disabled:
|
|
745
|
-
title:
|
|
817
|
+
disabled: o.disabled,
|
|
818
|
+
title: o.title,
|
|
746
819
|
onClick: n[0] || (n[0] = (t) => e.$emit("click", t))
|
|
747
820
|
}, [
|
|
748
|
-
e.$slots.default ? (
|
|
749
|
-
|
|
750
|
-
])) :
|
|
751
|
-
|
|
752
|
-
], 10,
|
|
821
|
+
e.$slots.default ? (S(), z("span", Wt, [
|
|
822
|
+
vt(e.$slots, "default")
|
|
823
|
+
])) : G("", !0),
|
|
824
|
+
o.label ? (S(), z("span", At, q(o.label), 1)) : G("", !0)
|
|
825
|
+
], 10, Et));
|
|
753
826
|
}
|
|
754
|
-
}),
|
|
827
|
+
}), Ft = { class: "vie-toolbar" }, Dt = { class: "vie-toolbar-group" }, Lt = { class: "vie-toolbar-group" }, Kt = ["title"], Ht = { class: "vie-toolbar-group" }, Vt = {
|
|
755
828
|
key: 0,
|
|
756
829
|
class: "vie-spinner",
|
|
757
830
|
style: { width: "16px", height: "16px", "border-width": "2px" }
|
|
758
|
-
},
|
|
831
|
+
}, Bt = {
|
|
759
832
|
key: 1,
|
|
760
833
|
viewBox: "0 0 24 24",
|
|
761
834
|
fill: "none",
|
|
@@ -763,23 +836,23 @@ const ut = {
|
|
|
763
836
|
"stroke-width": "2.5",
|
|
764
837
|
"stroke-linecap": "round",
|
|
765
838
|
"stroke-linejoin": "round"
|
|
766
|
-
},
|
|
839
|
+
}, Le = /* @__PURE__ */ J({
|
|
767
840
|
__name: "EditorToolbar",
|
|
768
841
|
props: {
|
|
769
842
|
processing: { type: Boolean }
|
|
770
843
|
},
|
|
771
844
|
emits: ["done"],
|
|
772
|
-
setup(
|
|
773
|
-
const e =
|
|
774
|
-
return (t,
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
title:
|
|
778
|
-
disabled: !
|
|
779
|
-
onClick:
|
|
845
|
+
setup(o) {
|
|
846
|
+
const e = ie(oe, (t) => t), n = ee();
|
|
847
|
+
return (t, a) => (S(), z("div", Ft, [
|
|
848
|
+
y("div", Dt, [
|
|
849
|
+
X(se, {
|
|
850
|
+
title: I(e)("undo"),
|
|
851
|
+
disabled: !I(n).canUndo.value,
|
|
852
|
+
onClick: a[0] || (a[0] = (h) => I(n).undo())
|
|
780
853
|
}, {
|
|
781
|
-
default:
|
|
782
|
-
|
|
854
|
+
default: ne(() => [...a[7] || (a[7] = [
|
|
855
|
+
y("svg", {
|
|
783
856
|
viewBox: "0 0 24 24",
|
|
784
857
|
fill: "none",
|
|
785
858
|
stroke: "currentColor",
|
|
@@ -787,20 +860,20 @@ const ut = {
|
|
|
787
860
|
"stroke-linecap": "round",
|
|
788
861
|
"stroke-linejoin": "round"
|
|
789
862
|
}, [
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
863
|
+
y("path", { d: "M3 10h10a5 5 0 0 1 0 10H9" }),
|
|
864
|
+
y("path", { d: "M3 10l4-4" }),
|
|
865
|
+
y("path", { d: "M3 10l4 4" })
|
|
793
866
|
], -1)
|
|
794
867
|
])]),
|
|
795
868
|
_: 1
|
|
796
869
|
}, 8, ["title", "disabled"]),
|
|
797
|
-
|
|
798
|
-
title:
|
|
799
|
-
disabled: !
|
|
800
|
-
onClick:
|
|
870
|
+
X(se, {
|
|
871
|
+
title: I(e)("redo"),
|
|
872
|
+
disabled: !I(n).canRedo.value,
|
|
873
|
+
onClick: a[1] || (a[1] = (h) => I(n).redo())
|
|
801
874
|
}, {
|
|
802
|
-
default:
|
|
803
|
-
|
|
875
|
+
default: ne(() => [...a[8] || (a[8] = [
|
|
876
|
+
y("svg", {
|
|
804
877
|
viewBox: "0 0 24 24",
|
|
805
878
|
fill: "none",
|
|
806
879
|
stroke: "currentColor",
|
|
@@ -808,20 +881,20 @@ const ut = {
|
|
|
808
881
|
"stroke-linecap": "round",
|
|
809
882
|
"stroke-linejoin": "round"
|
|
810
883
|
}, [
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
884
|
+
y("path", { d: "M21 10H11a5 5 0 0 0 0 10h4" }),
|
|
885
|
+
y("path", { d: "M21 10l-4-4" }),
|
|
886
|
+
y("path", { d: "M21 10l-4 4" })
|
|
814
887
|
], -1)
|
|
815
888
|
])]),
|
|
816
889
|
_: 1
|
|
817
890
|
}, 8, ["title", "disabled"]),
|
|
818
|
-
|
|
819
|
-
title:
|
|
820
|
-
disabled: !
|
|
821
|
-
onClick:
|
|
891
|
+
X(se, {
|
|
892
|
+
title: I(e)("revert"),
|
|
893
|
+
disabled: !I(n).hasEdits.value,
|
|
894
|
+
onClick: a[2] || (a[2] = (h) => I(n).revert())
|
|
822
895
|
}, {
|
|
823
|
-
default:
|
|
824
|
-
|
|
896
|
+
default: ne(() => [...a[9] || (a[9] = [
|
|
897
|
+
y("svg", {
|
|
825
898
|
viewBox: "0 0 24 24",
|
|
826
899
|
fill: "none",
|
|
827
900
|
stroke: "currentColor",
|
|
@@ -829,75 +902,75 @@ const ut = {
|
|
|
829
902
|
"stroke-linecap": "round",
|
|
830
903
|
"stroke-linejoin": "round"
|
|
831
904
|
}, [
|
|
832
|
-
|
|
833
|
-
|
|
905
|
+
y("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
|
|
906
|
+
y("path", { d: "M3 3v5h5" })
|
|
834
907
|
], -1)
|
|
835
908
|
])]),
|
|
836
909
|
_: 1
|
|
837
910
|
}, 8, ["title", "disabled"])
|
|
838
911
|
]),
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
title:
|
|
842
|
-
onClick:
|
|
912
|
+
y("div", Lt, [
|
|
913
|
+
X(se, {
|
|
914
|
+
title: I(e)("zoomOut"),
|
|
915
|
+
onClick: a[3] || (a[3] = (h) => I(n).setZoom(I(n).zoom.value - 0.1))
|
|
843
916
|
}, {
|
|
844
|
-
default:
|
|
845
|
-
|
|
917
|
+
default: ne(() => [...a[10] || (a[10] = [
|
|
918
|
+
y("svg", {
|
|
846
919
|
viewBox: "0 0 24 24",
|
|
847
920
|
fill: "none",
|
|
848
921
|
stroke: "currentColor",
|
|
849
922
|
"stroke-width": "2",
|
|
850
923
|
"stroke-linecap": "round"
|
|
851
924
|
}, [
|
|
852
|
-
|
|
925
|
+
y("circle", {
|
|
853
926
|
cx: "11",
|
|
854
927
|
cy: "11",
|
|
855
928
|
r: "8"
|
|
856
929
|
}),
|
|
857
|
-
|
|
930
|
+
y("path", { d: "M8 11h6" })
|
|
858
931
|
], -1)
|
|
859
932
|
])]),
|
|
860
933
|
_: 1
|
|
861
934
|
}, 8, ["title"]),
|
|
862
|
-
|
|
935
|
+
y("button", {
|
|
863
936
|
class: "vie-zoom-label",
|
|
864
|
-
title:
|
|
865
|
-
onClick:
|
|
866
|
-
}, q(Math.round(
|
|
867
|
-
|
|
868
|
-
title:
|
|
869
|
-
onClick:
|
|
937
|
+
title: I(e)("zoomToFit"),
|
|
938
|
+
onClick: a[4] || (a[4] = (h) => I(n).setZoom(1))
|
|
939
|
+
}, q(Math.round(I(n).zoom.value * 100)) + "% ", 9, Kt),
|
|
940
|
+
X(se, {
|
|
941
|
+
title: I(e)("zoomIn"),
|
|
942
|
+
onClick: a[5] || (a[5] = (h) => I(n).setZoom(I(n).zoom.value + 0.1))
|
|
870
943
|
}, {
|
|
871
|
-
default:
|
|
872
|
-
|
|
944
|
+
default: ne(() => [...a[11] || (a[11] = [
|
|
945
|
+
y("svg", {
|
|
873
946
|
viewBox: "0 0 24 24",
|
|
874
947
|
fill: "none",
|
|
875
948
|
stroke: "currentColor",
|
|
876
949
|
"stroke-width": "2",
|
|
877
950
|
"stroke-linecap": "round"
|
|
878
951
|
}, [
|
|
879
|
-
|
|
952
|
+
y("circle", {
|
|
880
953
|
cx: "11",
|
|
881
954
|
cy: "11",
|
|
882
955
|
r: "8"
|
|
883
956
|
}),
|
|
884
|
-
|
|
885
|
-
|
|
957
|
+
y("path", { d: "M8 11h6" }),
|
|
958
|
+
y("path", { d: "M11 8v6" })
|
|
886
959
|
], -1)
|
|
887
960
|
])]),
|
|
888
961
|
_: 1
|
|
889
962
|
}, 8, ["title"])
|
|
890
963
|
]),
|
|
891
|
-
|
|
892
|
-
|
|
964
|
+
y("div", Ht, [
|
|
965
|
+
X(se, {
|
|
893
966
|
variant: "accent",
|
|
894
|
-
label:
|
|
895
|
-
disabled:
|
|
896
|
-
onClick:
|
|
967
|
+
label: o.processing ? I(e)("processing") : I(e)("done"),
|
|
968
|
+
disabled: o.processing,
|
|
969
|
+
onClick: a[6] || (a[6] = (h) => t.$emit("done"))
|
|
897
970
|
}, {
|
|
898
|
-
default:
|
|
899
|
-
|
|
900
|
-
|
|
971
|
+
default: ne(() => [
|
|
972
|
+
o.processing ? (S(), z("span", Vt)) : (S(), z("svg", Bt, [...a[12] || (a[12] = [
|
|
973
|
+
y("polyline", { points: "20 6 9 17 4 12" }, null, -1)
|
|
901
974
|
])]))
|
|
902
975
|
]),
|
|
903
976
|
_: 1
|
|
@@ -906,7 +979,7 @@ const ut = {
|
|
|
906
979
|
]));
|
|
907
980
|
}
|
|
908
981
|
});
|
|
909
|
-
class
|
|
982
|
+
class jt {
|
|
910
983
|
constructor(e) {
|
|
911
984
|
this.sourceImage = null, this.animFrameId = null, this.needsRender = !0, this.viewport = { zoom: 1, panX: 0, panY: 0 }, this.activePluginId = null, this.fullImageRect = { x: 0, y: 0, width: 0, height: 0 }, this.previewCanvas = null, this.previewCtx = null, this.previewCacheKey = "", this.previewMaxSize = 1024, this.stickerImageCache = /* @__PURE__ */ new Map(), this.afterRender = null, this.getState = null, this.canvas = e;
|
|
912
985
|
const n = e.getContext("2d");
|
|
@@ -921,9 +994,13 @@ class _t {
|
|
|
921
994
|
const t = window.devicePixelRatio || 1;
|
|
922
995
|
this.canvas.width = e * t, this.canvas.height = n * t, this.canvas.style.width = `${e}px`, this.canvas.style.height = `${n}px`, this.ctx.setTransform(t, 0, 0, t, 0, 0), this.needsRender = !0;
|
|
923
996
|
}
|
|
924
|
-
/** Request a render on the next animation frame */
|
|
925
|
-
requestRender() {
|
|
926
|
-
this.needsRender = !0, this.scheduleRender();
|
|
997
|
+
/** Request a render on the next animation frame, or immediately if `immediate` is true */
|
|
998
|
+
requestRender(e = !1) {
|
|
999
|
+
this.needsRender = !0, e ? this.renderNow() : this.scheduleRender();
|
|
1000
|
+
}
|
|
1001
|
+
/** Render synchronously (cancels pending RAF). Used during drag for zero-lag updates. */
|
|
1002
|
+
renderNow() {
|
|
1003
|
+
this.animFrameId !== null && (cancelAnimationFrame(this.animFrameId), this.animFrameId = null), this.needsRender && this.getState && (this.render(this.getState()), this.needsRender = !1);
|
|
927
1004
|
}
|
|
928
1005
|
/** Start the render loop */
|
|
929
1006
|
startRenderLoop(e) {
|
|
@@ -958,29 +1035,29 @@ class _t {
|
|
|
958
1035
|
* otherwise returns a cached offscreen canvas with effects applied.
|
|
959
1036
|
*/
|
|
960
1037
|
getPreviewSource(e) {
|
|
961
|
-
const n = this.sourceImage, { finetune: t, filter:
|
|
962
|
-
if (!this.hasColorEffects(t,
|
|
1038
|
+
const n = this.sourceImage, { finetune: t, filter: a } = e;
|
|
1039
|
+
if (!this.hasColorEffects(t, a))
|
|
963
1040
|
return n;
|
|
964
|
-
const
|
|
965
|
-
if (
|
|
1041
|
+
const h = this.buildEffectsCacheKey(t, a);
|
|
1042
|
+
if (h === this.previewCacheKey && this.previewCanvas)
|
|
966
1043
|
return this.previewCanvas;
|
|
967
|
-
const
|
|
1044
|
+
const r = Math.min(
|
|
968
1045
|
this.previewMaxSize / n.naturalWidth,
|
|
969
1046
|
this.previewMaxSize / n.naturalHeight,
|
|
970
1047
|
1
|
|
971
|
-
),
|
|
972
|
-
(!this.previewCanvas || this.previewCanvas.width !==
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
const
|
|
976
|
-
if (t.brightness !== 0 &&
|
|
977
|
-
if (
|
|
978
|
-
const
|
|
979
|
-
|
|
1048
|
+
), s = Math.round(n.naturalWidth * r), i = Math.round(n.naturalHeight * r);
|
|
1049
|
+
(!this.previewCanvas || this.previewCanvas.width !== s || this.previewCanvas.height !== i) && (this.previewCanvas = document.createElement("canvas"), this.previewCanvas.width = s, this.previewCanvas.height = i, this.previewCtx = this.previewCanvas.getContext("2d"));
|
|
1050
|
+
const v = this.previewCtx;
|
|
1051
|
+
v.drawImage(n, 0, 0, s, i);
|
|
1052
|
+
const l = [];
|
|
1053
|
+
if (t.brightness !== 0 && l.push(Qe(t.brightness)), t.contrast !== 0 && l.push(et(t.contrast)), t.saturation !== 0 && l.push(tt(t.saturation)), t.exposure !== 0 && l.push(nt(t.exposure)), t.temperature !== 0 && l.push(it(t.temperature)), a.matrix)
|
|
1054
|
+
if (a.intensity < 1) {
|
|
1055
|
+
const m = a.matrix, d = a.intensity;
|
|
1056
|
+
l.push(We.map((x, _) => x * (1 - d) + m[_] * d));
|
|
980
1057
|
} else
|
|
981
|
-
|
|
982
|
-
const c =
|
|
983
|
-
return
|
|
1058
|
+
l.push(a.matrix);
|
|
1059
|
+
const c = v.getImageData(0, 0, s, i);
|
|
1060
|
+
return l.length > 0 && Ae(c, Ge(...l)), t.gamma !== 1 && Re(c, t.gamma), t.clarity !== 0 && Ie(c, t.clarity), t.vignette !== 0 && ze(c, t.vignette, s, i), v.putImageData(c, 0, 0), this.previewCacheKey = h, this.previewCanvas;
|
|
984
1061
|
}
|
|
985
1062
|
/** Check if crop is not at full-image defaults */
|
|
986
1063
|
isCropActive(e) {
|
|
@@ -993,102 +1070,108 @@ class _t {
|
|
|
993
1070
|
* On other tabs: renders only the cropped region fitted to canvas.
|
|
994
1071
|
*/
|
|
995
1072
|
render(e) {
|
|
996
|
-
const n = this.ctx, t = this.canvas,
|
|
997
|
-
if (n.clearRect(0, 0,
|
|
998
|
-
const
|
|
999
|
-
|
|
1073
|
+
const n = this.ctx, t = this.canvas, a = window.devicePixelRatio || 1, h = t.width / a, r = t.height / a;
|
|
1074
|
+
if (n.clearRect(0, 0, h, r), !this.sourceImage) return;
|
|
1075
|
+
const s = this.sourceImage, i = e.crop, v = 40, l = h - v * 2, c = r - v * 2, m = this.activePluginId !== "crop" && this.isCropActive(i), d = this.getPreviewSource(e);
|
|
1076
|
+
m ? this.renderCroppedView(n, e, d, h, r, l, c) : this.renderFullView(n, e, d, s, h, r, l, c), this.afterRender && this.afterRender(n, e, this.fullImageRect);
|
|
1000
1077
|
}
|
|
1001
1078
|
/**
|
|
1002
1079
|
* Render full image view (used on the crop tab).
|
|
1003
1080
|
*/
|
|
1004
|
-
renderFullView(e, n, t,
|
|
1005
|
-
const
|
|
1006
|
-
this.fullImageRect = { x:
|
|
1007
|
-
const
|
|
1008
|
-
e.translate(
|
|
1009
|
-
const $ =
|
|
1010
|
-
e.translate($,
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1081
|
+
renderFullView(e, n, t, a, h, r, s, i) {
|
|
1082
|
+
const v = n.crop, l = Math.min(s / a.naturalWidth, i / a.naturalHeight), c = a.naturalWidth * l, m = a.naturalHeight * l, d = (h - c) / 2, x = (r - m) / 2;
|
|
1083
|
+
this.fullImageRect = { x: d, y: x, width: c, height: m }, e.save();
|
|
1084
|
+
const _ = this.viewport;
|
|
1085
|
+
e.translate(h / 2 + _.panX, r / 2 + _.panY), e.scale(_.zoom, _.zoom), e.translate(-h / 2, -r / 2);
|
|
1086
|
+
const $ = d + c / 2, w = x + m / 2;
|
|
1087
|
+
e.translate($, w), e.rotate(v.rotation), e.scale(v.flipX ? -1 : 1, v.flipY ? -1 : 1), e.translate(-$, -w);
|
|
1088
|
+
const u = n.backgroundColor;
|
|
1089
|
+
if (u[3] > 0 && (e.fillStyle = `rgba(${Math.round(u[0] * 255)}, ${Math.round(u[1] * 255)}, ${Math.round(u[2] * 255)}, ${u[3]})`, e.fillRect(d, x, c, m)), e.drawImage(t, d, x, c, m), n.frame.style && this.renderFramePreview(e, n, d, x, c, m), n.stickers.length > 0 && this.renderStickers(e, n.stickers, d, x, c, m), n.annotations.length > 0)
|
|
1090
|
+
for (const g of n.annotations)
|
|
1091
|
+
Ee(e, g, d, x, c, m);
|
|
1092
|
+
e.restore();
|
|
1013
1093
|
}
|
|
1014
1094
|
/**
|
|
1015
1095
|
* Render cropped view (used on non-crop tabs).
|
|
1016
1096
|
* Shows only the crop region fitted to the canvas.
|
|
1017
1097
|
*/
|
|
1018
|
-
renderCroppedView(e, n, t,
|
|
1019
|
-
const i = this.sourceImage,
|
|
1020
|
-
let
|
|
1098
|
+
renderCroppedView(e, n, t, a, h, r, s) {
|
|
1099
|
+
const i = this.sourceImage, v = n.crop, l = i.naturalWidth * v.width, c = i.naturalHeight * v.height, m = Math.min(r / l, s / c);
|
|
1100
|
+
let d = 1;
|
|
1021
1101
|
if (this.activePluginId === "resize" && (n.resize.width || n.resize.height)) {
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1102
|
+
const D = n.resize.width || Math.round(l * (n.resize.height / c)), K = n.resize.height || Math.round(c * (n.resize.width / l));
|
|
1103
|
+
d = Math.min(D / l, K / c), !n.resize.upscale && d > 1 && (d = 1), d > 1 && (d = Math.min(d, r / (l * m), s / (c * m)));
|
|
1024
1104
|
}
|
|
1025
|
-
const
|
|
1026
|
-
this.fullImageRect = { x:
|
|
1027
|
-
const
|
|
1105
|
+
const x = m * d, _ = l * x, $ = c * x, w = (a - _) / 2, u = (h - $) / 2;
|
|
1106
|
+
this.fullImageRect = { x: w, y: u, width: _, height: $ };
|
|
1107
|
+
const g = t instanceof HTMLImageElement ? t.naturalWidth : t.width, k = t instanceof HTMLImageElement ? t.naturalHeight : t.height;
|
|
1028
1108
|
e.save();
|
|
1029
|
-
const
|
|
1030
|
-
e.translate(
|
|
1031
|
-
const
|
|
1032
|
-
e.translate(
|
|
1033
|
-
const
|
|
1034
|
-
if (
|
|
1109
|
+
const C = this.viewport;
|
|
1110
|
+
e.translate(a / 2 + C.panX, h / 2 + C.panY), e.scale(C.zoom, C.zoom), e.translate(-a / 2, -h / 2);
|
|
1111
|
+
const P = w + _ / 2, V = u + $ / 2;
|
|
1112
|
+
e.translate(P, V), e.rotate(v.rotation), e.scale(v.flipX ? -1 : 1, v.flipY ? -1 : 1), e.translate(-P, -V);
|
|
1113
|
+
const A = n.backgroundColor;
|
|
1114
|
+
if (A[3] > 0 && (e.fillStyle = `rgba(${Math.round(A[0] * 255)}, ${Math.round(A[1] * 255)}, ${Math.round(A[2] * 255)}, ${A[3]})`, e.fillRect(w, u, _, $)), e.drawImage(
|
|
1035
1115
|
t,
|
|
1036
|
-
|
|
1037
|
-
|
|
1116
|
+
v.x * g,
|
|
1117
|
+
v.y * k,
|
|
1038
1118
|
// source x, y
|
|
1039
|
-
|
|
1040
|
-
|
|
1119
|
+
v.width * g,
|
|
1120
|
+
v.height * k,
|
|
1041
1121
|
// source w, h
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1122
|
+
w,
|
|
1123
|
+
u,
|
|
1124
|
+
_,
|
|
1045
1125
|
$
|
|
1046
1126
|
// dest x, y, w, h
|
|
1047
|
-
), n.frame.style && this.renderFramePreview(e, n,
|
|
1048
|
-
|
|
1127
|
+
), n.frame.style && this.renderFramePreview(e, n, w, u, _, $), n.stickers.length > 0 && this.renderStickersInCrop(e, n.stickers, v, w, u, _, $), n.annotations.length > 0)
|
|
1128
|
+
for (const D of n.annotations)
|
|
1129
|
+
xt(e, D, v, w, u, _, $);
|
|
1130
|
+
if (e.restore(), this.activePluginId === "resize" && (n.resize.width || n.resize.height)) {
|
|
1131
|
+
const D = n.resize.width || Math.round(l * (n.resize.height / c)), K = n.resize.height || Math.round(c * (n.resize.width / l)), L = `${D} × ${K} px`;
|
|
1049
1132
|
e.save(), e.font = '12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', e.textAlign = "center", e.textBaseline = "top";
|
|
1050
|
-
const
|
|
1051
|
-
e.fillStyle = "rgba(0, 0, 0, 0.6)", e.beginPath(), e.roundRect(
|
|
1133
|
+
const E = a / 2, O = u + $ + 8, F = e.measureText(L).width + 16, f = 22;
|
|
1134
|
+
e.fillStyle = "rgba(0, 0, 0, 0.6)", e.beginPath(), e.roundRect(E - F / 2, O, F, f, 4), e.fill(), e.fillStyle = "#fff", e.fillText(L, E, O + 4), e.restore();
|
|
1052
1135
|
}
|
|
1053
1136
|
}
|
|
1054
1137
|
/**
|
|
1055
1138
|
* Render frame preview overlay on the canvas.
|
|
1056
1139
|
*/
|
|
1057
|
-
renderFramePreview(e, n, t,
|
|
1058
|
-
const
|
|
1059
|
-
switch (e.strokeStyle =
|
|
1140
|
+
renderFramePreview(e, n, t, a, h, r) {
|
|
1141
|
+
const s = n.frame, i = Math.round(Math.max(h, r) * s.size), v = s.color, l = `rgba(${Math.round(v[0] * 255)}, ${Math.round(v[1] * 255)}, ${Math.round(v[2] * 255)}, ${v[3]})`, c = Math.round(s.radius);
|
|
1142
|
+
switch (e.strokeStyle = l, e.fillStyle = l, s.style) {
|
|
1060
1143
|
case "solidSharp":
|
|
1061
|
-
e.lineWidth = i, e.strokeRect(t + i / 2,
|
|
1144
|
+
e.lineWidth = i, e.strokeRect(t + i / 2, a + i / 2, h - i, r - i);
|
|
1062
1145
|
break;
|
|
1063
1146
|
case "solidRound":
|
|
1064
|
-
e.lineWidth = i, e.beginPath(), e.roundRect(t + i / 2,
|
|
1147
|
+
e.lineWidth = i, e.beginPath(), e.roundRect(t + i / 2, a + i / 2, h - i, r - i, c + i / 2), e.stroke();
|
|
1065
1148
|
break;
|
|
1066
1149
|
case "lineSingle": {
|
|
1067
|
-
const
|
|
1068
|
-
e.lineWidth = 1, e.strokeRect(t +
|
|
1150
|
+
const m = i * 2;
|
|
1151
|
+
e.lineWidth = 1, e.strokeRect(t + m, a + m, h - m * 2, r - m * 2);
|
|
1069
1152
|
break;
|
|
1070
1153
|
}
|
|
1071
1154
|
case "lineMultiple":
|
|
1072
1155
|
e.lineWidth = 1;
|
|
1073
|
-
for (let
|
|
1074
|
-
const
|
|
1075
|
-
e.strokeRect(t +
|
|
1156
|
+
for (let m = 1; m <= 3; m++) {
|
|
1157
|
+
const d = i * m;
|
|
1158
|
+
e.strokeRect(t + d, a + d, h - d * 2, r - d * 2);
|
|
1076
1159
|
}
|
|
1077
1160
|
break;
|
|
1078
1161
|
case "hook": {
|
|
1079
|
-
const
|
|
1162
|
+
const m = Math.min(h, r) * 0.1;
|
|
1080
1163
|
e.lineWidth = i * 0.5;
|
|
1081
|
-
const
|
|
1082
|
-
e.beginPath(), e.moveTo(t +
|
|
1164
|
+
const d = i;
|
|
1165
|
+
e.beginPath(), e.moveTo(t + d, a + d + m), e.lineTo(t + d, a + d), e.lineTo(t + d + m, a + d), e.stroke(), e.beginPath(), e.moveTo(t + h - d - m, a + d), e.lineTo(t + h - d, a + d), e.lineTo(t + h - d, a + d + m), e.stroke(), e.beginPath(), e.moveTo(t + d, a + r - d - m), e.lineTo(t + d, a + r - d), e.lineTo(t + d + m, a + r - d), e.stroke(), e.beginPath(), e.moveTo(t + h - d - m, a + r - d), e.lineTo(t + h - d, a + r - d), e.lineTo(t + h - d, a + r - d - m), e.stroke();
|
|
1083
1166
|
break;
|
|
1084
1167
|
}
|
|
1085
1168
|
case "polaroid": {
|
|
1086
|
-
const
|
|
1087
|
-
e.fillRect(t,
|
|
1169
|
+
const m = i, d = i * 4;
|
|
1170
|
+
e.fillRect(t, a, h, m), e.fillRect(t, a, m, r), e.fillRect(t + h - m, a, m, r), e.fillRect(t, a + r - d, h, d);
|
|
1088
1171
|
break;
|
|
1089
1172
|
}
|
|
1090
1173
|
default:
|
|
1091
|
-
e.lineWidth = i * 0.5, e.strokeRect(t + i,
|
|
1174
|
+
e.lineWidth = i * 0.5, e.strokeRect(t + i, a + i, h - i * 2, r - i * 2);
|
|
1092
1175
|
break;
|
|
1093
1176
|
}
|
|
1094
1177
|
}
|
|
@@ -1102,26 +1185,26 @@ class _t {
|
|
|
1102
1185
|
/**
|
|
1103
1186
|
* Render stickers on the canvas viewport.
|
|
1104
1187
|
*/
|
|
1105
|
-
renderStickers(e, n, t,
|
|
1106
|
-
for (const
|
|
1107
|
-
const i = t +
|
|
1108
|
-
if (e.save(), e.globalAlpha =
|
|
1109
|
-
const
|
|
1110
|
-
e.font = `${
|
|
1188
|
+
renderStickers(e, n, t, a, h, r) {
|
|
1189
|
+
for (const s of n) {
|
|
1190
|
+
const i = t + s.x * h, v = a + s.y * r, l = s.width * h, c = s.height * r;
|
|
1191
|
+
if (e.save(), e.globalAlpha = s.opacity, e.translate(i + l / 2, v + c / 2), e.rotate(s.rotation), e.scale(s.flipX ? -1 : 1, s.flipY ? -1 : 1), !s.src.startsWith("http") && !s.src.startsWith("data:") && !s.src.startsWith("blob:") && !s.src.startsWith("/") && !s.src.startsWith(".")) {
|
|
1192
|
+
const d = Math.max(8, Math.min(l, c) * 0.8);
|
|
1193
|
+
e.font = `${d}px sans-serif`, e.textAlign = "center", e.textBaseline = "middle", e.fillText(s.src, 0, 0);
|
|
1111
1194
|
} else {
|
|
1112
|
-
let
|
|
1113
|
-
if (!
|
|
1195
|
+
let d = this.stickerImageCache.get(s.src);
|
|
1196
|
+
if (!d) {
|
|
1114
1197
|
if (this.stickerImageCache.size >= 50) {
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1198
|
+
const x = this.stickerImageCache.keys().next().value;
|
|
1199
|
+
x !== void 0 && this.stickerImageCache.delete(x);
|
|
1117
1200
|
}
|
|
1118
|
-
|
|
1201
|
+
d = new Image(), d.crossOrigin = "anonymous", d.src = s.src, this.stickerImageCache.set(s.src, d), d.onload = () => {
|
|
1119
1202
|
this.requestRender();
|
|
1120
|
-
},
|
|
1121
|
-
this.stickerImageCache.delete(
|
|
1203
|
+
}, d.onerror = () => {
|
|
1204
|
+
this.stickerImageCache.delete(s.src);
|
|
1122
1205
|
};
|
|
1123
1206
|
}
|
|
1124
|
-
|
|
1207
|
+
d.complete && d.naturalWidth > 0 && e.drawImage(d, -l / 2, -c / 2, l, c);
|
|
1125
1208
|
}
|
|
1126
1209
|
e.restore();
|
|
1127
1210
|
}
|
|
@@ -1129,29 +1212,29 @@ class _t {
|
|
|
1129
1212
|
/**
|
|
1130
1213
|
* Render stickers with positions remapped relative to the crop region.
|
|
1131
1214
|
*/
|
|
1132
|
-
renderStickersInCrop(e, n, t,
|
|
1215
|
+
renderStickersInCrop(e, n, t, a, h, r, s) {
|
|
1133
1216
|
if (!(t.width <= 0 || t.height <= 0))
|
|
1134
1217
|
for (const i of n) {
|
|
1135
|
-
const
|
|
1136
|
-
if (
|
|
1137
|
-
const
|
|
1138
|
-
if (e.save(), e.globalAlpha = i.opacity, e.translate(
|
|
1139
|
-
const
|
|
1140
|
-
e.font = `${
|
|
1218
|
+
const v = (i.x - t.x) / t.width, l = (i.y - t.y) / t.height, c = i.width / t.width, m = i.height / t.height;
|
|
1219
|
+
if (v + c < 0 || v > 1 || l + m < 0 || l > 1) continue;
|
|
1220
|
+
const d = a + v * r, x = h + l * s, _ = c * r, $ = m * s;
|
|
1221
|
+
if (e.save(), e.globalAlpha = i.opacity, e.translate(d + _ / 2, x + $ / 2), e.rotate(i.rotation), e.scale(i.flipX ? -1 : 1, i.flipY ? -1 : 1), !i.src.startsWith("http") && !i.src.startsWith("data:") && !i.src.startsWith("blob:") && !i.src.startsWith("/") && !i.src.startsWith(".")) {
|
|
1222
|
+
const u = Math.max(8, Math.min(_, $) * 0.8);
|
|
1223
|
+
e.font = `${u}px sans-serif`, e.textAlign = "center", e.textBaseline = "middle", e.fillText(i.src, 0, 0);
|
|
1141
1224
|
} else {
|
|
1142
|
-
let
|
|
1143
|
-
if (!
|
|
1225
|
+
let u = this.stickerImageCache.get(i.src);
|
|
1226
|
+
if (!u) {
|
|
1144
1227
|
if (this.stickerImageCache.size >= 50) {
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1228
|
+
const g = this.stickerImageCache.keys().next().value;
|
|
1229
|
+
g !== void 0 && this.stickerImageCache.delete(g);
|
|
1147
1230
|
}
|
|
1148
|
-
|
|
1231
|
+
u = new Image(), u.crossOrigin = "anonymous", u.src = i.src, this.stickerImageCache.set(i.src, u), u.onload = () => {
|
|
1149
1232
|
this.requestRender();
|
|
1150
|
-
},
|
|
1233
|
+
}, u.onerror = () => {
|
|
1151
1234
|
this.stickerImageCache.delete(i.src);
|
|
1152
1235
|
};
|
|
1153
1236
|
}
|
|
1154
|
-
|
|
1237
|
+
u.complete && u.naturalWidth > 0 && e.drawImage(u, -_ / 2, -$ / 2, _, $);
|
|
1155
1238
|
}
|
|
1156
1239
|
e.restore();
|
|
1157
1240
|
}
|
|
@@ -1160,147 +1243,147 @@ class _t {
|
|
|
1160
1243
|
this.stopRenderLoop(), this.sourceImage = null, this.previewCanvas = null, this.previewCtx = null, this.stickerImageCache.clear();
|
|
1161
1244
|
}
|
|
1162
1245
|
}
|
|
1163
|
-
const
|
|
1246
|
+
const Ot = {
|
|
1164
1247
|
key: 0,
|
|
1165
1248
|
class: "vie-canvas-overlay vie-canvas-overlay--interactive"
|
|
1166
|
-
},
|
|
1249
|
+
}, Xt = {
|
|
1167
1250
|
key: 1,
|
|
1168
1251
|
class: "vie-canvas-loading"
|
|
1169
|
-
},
|
|
1252
|
+
}, qt = {
|
|
1170
1253
|
key: 2,
|
|
1171
1254
|
class: "vie-canvas-loading",
|
|
1172
1255
|
style: { color: "var(--vie-danger)" }
|
|
1173
|
-
},
|
|
1256
|
+
}, Ke = /* @__PURE__ */ J({
|
|
1174
1257
|
__name: "EditorCanvas",
|
|
1175
|
-
setup(
|
|
1176
|
-
const n =
|
|
1177
|
-
let i = null,
|
|
1178
|
-
function
|
|
1179
|
-
i && (
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
if (!
|
|
1183
|
-
i = new
|
|
1184
|
-
for (const
|
|
1185
|
-
const { width:
|
|
1186
|
-
|
|
1258
|
+
setup(o, { expose: e }) {
|
|
1259
|
+
const n = ie(oe, (f) => f), t = ee(), a = H(null), h = H(null), r = H({ x: 0, y: 0, width: 0, height: 0 }), s = H({ width: 0, height: 0 });
|
|
1260
|
+
let i = null, v = null, l = null, c = null;
|
|
1261
|
+
function m() {
|
|
1262
|
+
i && (r.value = i.getImageRect());
|
|
1263
|
+
}
|
|
1264
|
+
ge(() => {
|
|
1265
|
+
if (!h.value || !a.value) return;
|
|
1266
|
+
i = new jt(h.value), v = new ResizeObserver((b) => {
|
|
1267
|
+
for (const R of b) {
|
|
1268
|
+
const { width: T, height: W } = R.contentRect;
|
|
1269
|
+
T > 0 && W > 0 && (s.value = { width: T, height: W }, i == null || i.resize(T, W), i == null || i.requestRender(), requestAnimationFrame(m));
|
|
1187
1270
|
}
|
|
1188
|
-
}),
|
|
1189
|
-
function
|
|
1190
|
-
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1193
|
-
const { width:
|
|
1194
|
-
|
|
1195
|
-
},
|
|
1271
|
+
}), v.observe(a.value);
|
|
1272
|
+
function f() {
|
|
1273
|
+
l == null || l.removeEventListener("change", c);
|
|
1274
|
+
const b = window.devicePixelRatio || 1;
|
|
1275
|
+
l = window.matchMedia(`(resolution: ${b}dppx)`), c = () => {
|
|
1276
|
+
const { width: R, height: T } = s.value;
|
|
1277
|
+
R > 0 && T > 0 && (i == null || i.resize(R, T), i == null || i.requestRender()), f();
|
|
1278
|
+
}, l.addEventListener("change", c);
|
|
1196
1279
|
}
|
|
1197
|
-
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
const
|
|
1201
|
-
|
|
1202
|
-
}, t.onRender.value = () => {
|
|
1203
|
-
i == null || i.requestRender(), requestAnimationFrame(
|
|
1204
|
-
}, i.activePluginId = t.activePluginId.value,
|
|
1205
|
-
}),
|
|
1206
|
-
i &&
|
|
1207
|
-
}),
|
|
1208
|
-
i && (i.viewport.zoom =
|
|
1209
|
-
}),
|
|
1210
|
-
i && (i.activePluginId =
|
|
1211
|
-
}),
|
|
1212
|
-
i && (i.viewport.panX =
|
|
1280
|
+
f();
|
|
1281
|
+
const p = a.value.getBoundingClientRect();
|
|
1282
|
+
s.value = { width: p.width, height: p.height }, i.resize(p.width, p.height), i.startRenderLoop(() => t.state), i.afterRender = (b, R, T) => {
|
|
1283
|
+
const W = t.activePlugin.value;
|
|
1284
|
+
W != null && W.onRender && W.onRender({ ctx: b, state: R, imageRect: T });
|
|
1285
|
+
}, t.onRender.value = (b) => {
|
|
1286
|
+
i == null || i.requestRender(b), requestAnimationFrame(m);
|
|
1287
|
+
}, i.activePluginId = t.activePluginId.value, d = t.zoom.value, x = t.zoom.value, $ = 0, w = 0, u = 0, g = 0, t.options.src && t.load(t.options.src);
|
|
1288
|
+
}), re(() => t.sourceImage.value, (f) => {
|
|
1289
|
+
i && f && (i.setSource(f), i.requestRender(), requestAnimationFrame(() => requestAnimationFrame(m)));
|
|
1290
|
+
}), re(() => t.zoom.value, (f) => {
|
|
1291
|
+
i && (i.viewport.zoom = f, i.requestRender(), requestAnimationFrame(m)), _ || (d = f, x = f, f <= 1.005 && ($ = 0, w = 0, u = 0, g = 0, k()));
|
|
1292
|
+
}), re(() => t.activePluginId.value, (f) => {
|
|
1293
|
+
i && (i.activePluginId = f, i.requestRender(), requestAnimationFrame(m));
|
|
1294
|
+
}), re(() => t.cropDragPan.value, (f) => {
|
|
1295
|
+
i && (i.viewport.panX = u + f.x, i.viewport.panY = g + f.y, i.requestRender());
|
|
1213
1296
|
}, { deep: !0 });
|
|
1214
|
-
let
|
|
1215
|
-
function
|
|
1216
|
-
i && (i.viewport.panX =
|
|
1217
|
-
}
|
|
1218
|
-
function
|
|
1219
|
-
const
|
|
1220
|
-
$ =
|
|
1221
|
-
}
|
|
1222
|
-
function
|
|
1223
|
-
const
|
|
1224
|
-
if (Math.abs(
|
|
1225
|
-
|
|
1297
|
+
let d = 1, x = 1, _ = !1, $ = 0, w = 0, u = 0, g = 0;
|
|
1298
|
+
function k() {
|
|
1299
|
+
i && (i.viewport.panX = u, i.viewport.panY = g, i.requestRender(), requestAnimationFrame(m));
|
|
1300
|
+
}
|
|
1301
|
+
function C(f) {
|
|
1302
|
+
const p = f.deltaY > 0 ? 0.95 : 1.05, b = Math.max(0.1, Math.min(10, d * p)), R = a.value.getBoundingClientRect(), T = f.clientX - R.left - R.width / 2, W = f.clientY - R.top - R.height / 2, B = b / d;
|
|
1303
|
+
$ = T - (T - $) * B, w = W - (W - w) * B, d = b, d <= 1.005 && ($ = 0, w = 0), _ || (_ = !0, P());
|
|
1304
|
+
}
|
|
1305
|
+
function P() {
|
|
1306
|
+
const f = d - x, p = $ - u, b = w - g;
|
|
1307
|
+
if (Math.abs(f) < 1e-3 && Math.abs(p) < 0.5 && Math.abs(b) < 0.5) {
|
|
1308
|
+
x = d, u = $, g = w, t.setZoom(x), k(), _ = !1;
|
|
1226
1309
|
return;
|
|
1227
1310
|
}
|
|
1228
|
-
const
|
|
1229
|
-
|
|
1230
|
-
}
|
|
1231
|
-
const
|
|
1232
|
-
function
|
|
1233
|
-
if (
|
|
1234
|
-
|
|
1235
|
-
const
|
|
1236
|
-
$ =
|
|
1237
|
-
},
|
|
1238
|
-
|
|
1311
|
+
const T = 0.15;
|
|
1312
|
+
x += f * T, u += p * T, g += b * T, t.setZoom(x), k(), requestAnimationFrame(P);
|
|
1313
|
+
}
|
|
1314
|
+
const V = H(!1), A = j(() => t.zoom.value > 1.005 && t.activePluginId.value !== "crop");
|
|
1315
|
+
function D(f) {
|
|
1316
|
+
if (f.button !== 0 || !A.value || f.target !== a.value && f.target !== h.value) return;
|
|
1317
|
+
f.preventDefault(), V.value = !0;
|
|
1318
|
+
const p = f.clientX, b = f.clientY, R = $, T = w, W = (U) => {
|
|
1319
|
+
$ = R + (U.clientX - p), w = T + (U.clientY - b), u = $, g = w, k();
|
|
1320
|
+
}, B = () => {
|
|
1321
|
+
V.value = !1, window.removeEventListener("mousemove", W), window.removeEventListener("mouseup", B);
|
|
1239
1322
|
};
|
|
1240
|
-
window.addEventListener("mousemove",
|
|
1241
|
-
}
|
|
1242
|
-
let
|
|
1243
|
-
function
|
|
1244
|
-
const
|
|
1245
|
-
return Math.sqrt(
|
|
1246
|
-
}
|
|
1247
|
-
function O(
|
|
1248
|
-
|
|
1249
|
-
}
|
|
1250
|
-
function
|
|
1251
|
-
if (
|
|
1252
|
-
const
|
|
1253
|
-
if (
|
|
1254
|
-
const
|
|
1255
|
-
t.setZoom(
|
|
1323
|
+
window.addEventListener("mousemove", W), window.addEventListener("mouseup", B);
|
|
1324
|
+
}
|
|
1325
|
+
let K = 0, L = 1;
|
|
1326
|
+
function E(f, p) {
|
|
1327
|
+
const b = f.clientX - p.clientX, R = f.clientY - p.clientY;
|
|
1328
|
+
return Math.sqrt(b * b + R * R);
|
|
1329
|
+
}
|
|
1330
|
+
function O(f) {
|
|
1331
|
+
f.touches.length === 2 && (K = E(f.touches[0], f.touches[1]), L = t.zoom.value);
|
|
1332
|
+
}
|
|
1333
|
+
function M(f) {
|
|
1334
|
+
if (f.touches.length === 2) {
|
|
1335
|
+
const p = E(f.touches[0], f.touches[1]);
|
|
1336
|
+
if (K > 0) {
|
|
1337
|
+
const b = p / K;
|
|
1338
|
+
t.setZoom(L * b);
|
|
1256
1339
|
}
|
|
1257
1340
|
}
|
|
1258
1341
|
}
|
|
1259
|
-
function
|
|
1260
|
-
|
|
1342
|
+
function F(f) {
|
|
1343
|
+
K = 0;
|
|
1261
1344
|
}
|
|
1262
|
-
return
|
|
1263
|
-
|
|
1345
|
+
return he(() => {
|
|
1346
|
+
v == null || v.disconnect(), l == null || l.removeEventListener("change", c), l = null, i == null || i.destroy(), i = null, t.onRender.value = null;
|
|
1264
1347
|
}), e({
|
|
1265
1348
|
getRenderer: () => i
|
|
1266
|
-
}), (
|
|
1267
|
-
var
|
|
1268
|
-
return
|
|
1269
|
-
class:
|
|
1349
|
+
}), (f, p) => {
|
|
1350
|
+
var b;
|
|
1351
|
+
return S(), z("div", {
|
|
1352
|
+
class: N(["vie-canvas-wrapper", { "vie-canvas-wrapper--grab": A.value, "vie-canvas-wrapper--grabbing": V.value }]),
|
|
1270
1353
|
ref_key: "wrapperRef",
|
|
1271
|
-
ref:
|
|
1272
|
-
onWheel:
|
|
1273
|
-
onMousedown:
|
|
1354
|
+
ref: a,
|
|
1355
|
+
onWheel: ve(C, ["prevent"]),
|
|
1356
|
+
onMousedown: D,
|
|
1274
1357
|
onTouchstartPassive: O,
|
|
1275
|
-
onTouchmove:
|
|
1276
|
-
onTouchendPassive:
|
|
1358
|
+
onTouchmove: ve(M, ["prevent"]),
|
|
1359
|
+
onTouchendPassive: F
|
|
1277
1360
|
}, [
|
|
1278
|
-
|
|
1361
|
+
y("canvas", {
|
|
1279
1362
|
ref_key: "canvasRef",
|
|
1280
|
-
ref:
|
|
1363
|
+
ref: h,
|
|
1281
1364
|
class: "vie-canvas"
|
|
1282
1365
|
}, null, 512),
|
|
1283
|
-
(
|
|
1284
|
-
(
|
|
1285
|
-
"canvas-rect":
|
|
1286
|
-
"wrapper-size":
|
|
1366
|
+
(b = I(t).activePlugin.value) != null && b.overlay ? (S(), z("div", Ot, [
|
|
1367
|
+
(S(), pe(Pe(I(t).activePlugin.value.overlay), {
|
|
1368
|
+
"canvas-rect": r.value,
|
|
1369
|
+
"wrapper-size": s.value
|
|
1287
1370
|
}, null, 8, ["canvas-rect", "wrapper-size"]))
|
|
1288
|
-
])) :
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
])) :
|
|
1293
|
-
|
|
1371
|
+
])) : G("", !0),
|
|
1372
|
+
I(t).loading.value ? (S(), z("div", Xt, [
|
|
1373
|
+
p[0] || (p[0] = y("span", { class: "vie-spinner" }, null, -1)),
|
|
1374
|
+
y("span", null, q(I(n)("loading")), 1)
|
|
1375
|
+
])) : G("", !0),
|
|
1376
|
+
I(t).error.value ? (S(), z("div", qt, q(I(n)("loadError")), 1)) : G("", !0)
|
|
1294
1377
|
], 34);
|
|
1295
1378
|
};
|
|
1296
1379
|
}
|
|
1297
|
-
}),
|
|
1380
|
+
}), Yt = {
|
|
1298
1381
|
class: "vie-tab-bar",
|
|
1299
1382
|
role: "tablist"
|
|
1300
|
-
},
|
|
1383
|
+
}, Ut = ["aria-selected", "onClick"], Nt = { class: "vie-tab__label" }, He = /* @__PURE__ */ J({
|
|
1301
1384
|
__name: "EditorTabs",
|
|
1302
|
-
setup(
|
|
1303
|
-
const e =
|
|
1385
|
+
setup(o) {
|
|
1386
|
+
const e = ie(oe, (i) => i), n = ee(), t = H([]), a = /* @__PURE__ */ new Set([
|
|
1304
1387
|
"svg",
|
|
1305
1388
|
"path",
|
|
1306
1389
|
"circle",
|
|
@@ -1316,7 +1399,7 @@ const xt = {
|
|
|
1316
1399
|
"use",
|
|
1317
1400
|
"text",
|
|
1318
1401
|
"tspan"
|
|
1319
|
-
]),
|
|
1402
|
+
]), h = /* @__PURE__ */ new Set([
|
|
1320
1403
|
"viewbox",
|
|
1321
1404
|
"width",
|
|
1322
1405
|
"height",
|
|
@@ -1350,80 +1433,80 @@ const xt = {
|
|
|
1350
1433
|
"stroke-dasharray",
|
|
1351
1434
|
"stroke-dashoffset"
|
|
1352
1435
|
]);
|
|
1353
|
-
function
|
|
1436
|
+
function r(i) {
|
|
1354
1437
|
const c = new DOMParser().parseFromString(i, "image/svg+xml").documentElement;
|
|
1355
|
-
function
|
|
1356
|
-
const
|
|
1357
|
-
for (const
|
|
1358
|
-
if (!
|
|
1359
|
-
|
|
1438
|
+
function m(d) {
|
|
1439
|
+
const x = Array.from(d.children);
|
|
1440
|
+
for (const _ of x)
|
|
1441
|
+
if (!a.has(_.tagName.toLowerCase()))
|
|
1442
|
+
_.remove();
|
|
1360
1443
|
else {
|
|
1361
|
-
for (const $ of Array.from(
|
|
1362
|
-
|
|
1363
|
-
|
|
1444
|
+
for (const $ of Array.from(_.attributes))
|
|
1445
|
+
h.has($.name.toLowerCase()) || _.removeAttribute($.name);
|
|
1446
|
+
m(_);
|
|
1364
1447
|
}
|
|
1365
1448
|
}
|
|
1366
|
-
return
|
|
1449
|
+
return m(c), c.outerHTML;
|
|
1367
1450
|
}
|
|
1368
|
-
function
|
|
1369
|
-
const i = n.plugins.value.filter((
|
|
1370
|
-
t.value.forEach((
|
|
1371
|
-
|
|
1451
|
+
function s() {
|
|
1452
|
+
const i = n.plugins.value.filter((v) => typeof v.icon == "string");
|
|
1453
|
+
t.value.forEach((v, l) => {
|
|
1454
|
+
v && i[l] && (v.innerHTML = r(i[l].icon));
|
|
1372
1455
|
});
|
|
1373
1456
|
}
|
|
1374
|
-
return
|
|
1375
|
-
(
|
|
1376
|
-
key:
|
|
1457
|
+
return ge(s), ft(s), (i, v) => (S(), z("div", Yt, [
|
|
1458
|
+
(S(!0), z(Y, null, Z(I(n).plugins.value, (l) => (S(), z("button", {
|
|
1459
|
+
key: l.id,
|
|
1377
1460
|
role: "tab",
|
|
1378
|
-
"aria-selected":
|
|
1379
|
-
class:
|
|
1461
|
+
"aria-selected": l.id === I(n).activePluginId.value,
|
|
1462
|
+
class: N([
|
|
1380
1463
|
"vie-tab",
|
|
1381
|
-
{ "vie-tab--active":
|
|
1464
|
+
{ "vie-tab--active": l.id === I(n).activePluginId.value }
|
|
1382
1465
|
]),
|
|
1383
|
-
onClick: (c) =>
|
|
1466
|
+
onClick: (c) => I(n).setActivePlugin(l.id)
|
|
1384
1467
|
}, [
|
|
1385
|
-
typeof
|
|
1468
|
+
typeof l.icon == "string" ? (S(), z("span", {
|
|
1386
1469
|
key: 0,
|
|
1387
1470
|
class: "vie-tab__icon",
|
|
1388
1471
|
ref_for: !0,
|
|
1389
1472
|
ref_key: "iconRefs",
|
|
1390
1473
|
ref: t
|
|
1391
|
-
}, null, 512)) : (
|
|
1474
|
+
}, null, 512)) : (S(), pe(Pe(l.icon), {
|
|
1392
1475
|
key: 1,
|
|
1393
1476
|
class: "vie-tab__icon"
|
|
1394
1477
|
})),
|
|
1395
|
-
|
|
1396
|
-
], 10,
|
|
1478
|
+
y("span", Nt, q(I(e)(l.labelKey)), 1)
|
|
1479
|
+
], 10, Ut))), 128))
|
|
1397
1480
|
]));
|
|
1398
1481
|
}
|
|
1399
|
-
}),
|
|
1482
|
+
}), Zt = {
|
|
1400
1483
|
key: 0,
|
|
1401
1484
|
class: "vie-control-panel"
|
|
1402
|
-
},
|
|
1485
|
+
}, Ve = /* @__PURE__ */ J({
|
|
1403
1486
|
__name: "EditorControlPanel",
|
|
1404
|
-
setup(
|
|
1405
|
-
const e =
|
|
1487
|
+
setup(o) {
|
|
1488
|
+
const e = ee();
|
|
1406
1489
|
return (n, t) => {
|
|
1407
|
-
var
|
|
1408
|
-
return (
|
|
1409
|
-
|
|
1490
|
+
var a;
|
|
1491
|
+
return (a = I(e).activePlugin.value) != null && a.controls ? (S(), z("div", Zt, [
|
|
1492
|
+
X(Te, {
|
|
1410
1493
|
name: "vie-panel",
|
|
1411
1494
|
mode: "out-in"
|
|
1412
1495
|
}, {
|
|
1413
|
-
default:
|
|
1414
|
-
(
|
|
1415
|
-
key:
|
|
1496
|
+
default: ne(() => [
|
|
1497
|
+
(S(), pe(Pe(I(e).activePlugin.value.controls), {
|
|
1498
|
+
key: I(e).activePluginId.value
|
|
1416
1499
|
}))
|
|
1417
1500
|
]),
|
|
1418
1501
|
_: 1
|
|
1419
1502
|
})
|
|
1420
|
-
])) :
|
|
1503
|
+
])) : G("", !0);
|
|
1421
1504
|
};
|
|
1422
1505
|
}
|
|
1423
|
-
}),
|
|
1506
|
+
}), Jt = ["aria-valuemin", "aria-valuemax", "aria-valuenow", "aria-labelledby"], Gt = { class: "vie-slider__track" }, Qt = {
|
|
1424
1507
|
key: 0,
|
|
1425
1508
|
class: "vie-slider__tooltip"
|
|
1426
|
-
},
|
|
1509
|
+
}, en = { class: "vie-slider__value" }, fe = /* @__PURE__ */ J({
|
|
1427
1510
|
__name: "Slider",
|
|
1428
1511
|
props: {
|
|
1429
1512
|
modelValue: {},
|
|
@@ -1436,174 +1519,179 @@ const xt = {
|
|
|
1436
1519
|
ticks: {}
|
|
1437
1520
|
},
|
|
1438
1521
|
emits: ["update:modelValue"],
|
|
1439
|
-
setup(
|
|
1440
|
-
const n = `vie-slider-${Math.random().toString(36).slice(2, 9)}`, t =
|
|
1441
|
-
const
|
|
1522
|
+
setup(o, { emit: e }) {
|
|
1523
|
+
const n = `vie-slider-${Math.random().toString(36).slice(2, 9)}`, t = o, a = e, h = H(null), r = H(!1), s = j(() => (t.modelValue - t.min) / (t.max - t.min)), i = j(() => (t.base - t.min) / (t.max - t.min)), v = j(() => t.ticks ? t.ticks.map((w) => (w - t.min) / (t.max - t.min)) : []), l = j(() => Math.max(0, Math.min(100, s.value * 100))), c = j(() => {
|
|
1524
|
+
const w = Math.max(0, Math.min(1, Math.min(i.value, s.value))), u = Math.max(0, Math.min(1, Math.max(i.value, s.value)));
|
|
1442
1525
|
return {
|
|
1443
|
-
|
|
1444
|
-
|
|
1526
|
+
insetInlineStart: w * 100 + "%",
|
|
1527
|
+
insetInlineEnd: (1 - u) * 100 + "%"
|
|
1445
1528
|
};
|
|
1446
|
-
}),
|
|
1447
|
-
function
|
|
1448
|
-
if (!
|
|
1449
|
-
const
|
|
1450
|
-
let
|
|
1451
|
-
|
|
1452
|
-
let
|
|
1453
|
-
return
|
|
1454
|
-
}
|
|
1455
|
-
function w
|
|
1456
|
-
if (
|
|
1457
|
-
|
|
1458
|
-
const
|
|
1459
|
-
|
|
1460
|
-
},
|
|
1461
|
-
|
|
1529
|
+
}), m = j(() => t.format === "percent" ? Math.round(t.modelValue * 100) + "%" : t.modelValue.toFixed(2));
|
|
1530
|
+
function d(w) {
|
|
1531
|
+
if (!h.value) return t.modelValue;
|
|
1532
|
+
const u = h.value.getBoundingClientRect(), g = getComputedStyle(h.value).direction === "rtl";
|
|
1533
|
+
let k;
|
|
1534
|
+
g ? k = (u.right - w.clientX) / u.width : k = (w.clientX - u.left) / u.width, k = Math.max(0, Math.min(1, k));
|
|
1535
|
+
let C = t.min + k * (t.max - t.min);
|
|
1536
|
+
return C = Math.round(C / t.step) * t.step, Math.max(t.min, Math.min(t.max, C));
|
|
1537
|
+
}
|
|
1538
|
+
function x(w) {
|
|
1539
|
+
if (w.button !== 0) return;
|
|
1540
|
+
r.value = !0, a("update:modelValue", d(w));
|
|
1541
|
+
const u = (k) => {
|
|
1542
|
+
a("update:modelValue", d(k));
|
|
1543
|
+
}, g = () => {
|
|
1544
|
+
r.value = !1, window.removeEventListener("pointermove", u), window.removeEventListener("pointerup", g);
|
|
1462
1545
|
};
|
|
1463
|
-
window.addEventListener("pointermove",
|
|
1546
|
+
window.addEventListener("pointermove", u), window.addEventListener("pointerup", g);
|
|
1464
1547
|
}
|
|
1465
|
-
function
|
|
1466
|
-
|
|
1548
|
+
function _() {
|
|
1549
|
+
a("update:modelValue", t.base);
|
|
1467
1550
|
}
|
|
1468
|
-
function $(
|
|
1469
|
-
let
|
|
1470
|
-
|
|
1551
|
+
function $(w) {
|
|
1552
|
+
let u = t.modelValue;
|
|
1553
|
+
const k = (h.value ? getComputedStyle(h.value).direction === "rtl" : !1) ? -t.step : t.step;
|
|
1554
|
+
switch (w.key) {
|
|
1471
1555
|
case "ArrowRight":
|
|
1472
|
-
|
|
1473
|
-
l = Math.min(t.max, t.modelValue + t.step);
|
|
1556
|
+
u = t.modelValue + k;
|
|
1474
1557
|
break;
|
|
1475
1558
|
case "ArrowLeft":
|
|
1559
|
+
u = t.modelValue - k;
|
|
1560
|
+
break;
|
|
1561
|
+
case "ArrowUp":
|
|
1562
|
+
u = t.modelValue + t.step;
|
|
1563
|
+
break;
|
|
1476
1564
|
case "ArrowDown":
|
|
1477
|
-
|
|
1565
|
+
u = t.modelValue - t.step;
|
|
1478
1566
|
break;
|
|
1479
1567
|
case "Home":
|
|
1480
|
-
|
|
1568
|
+
u = t.min;
|
|
1481
1569
|
break;
|
|
1482
1570
|
case "End":
|
|
1483
|
-
|
|
1571
|
+
u = t.max;
|
|
1484
1572
|
break;
|
|
1485
1573
|
default:
|
|
1486
1574
|
return;
|
|
1487
1575
|
}
|
|
1488
|
-
|
|
1576
|
+
w.preventDefault(), u = Math.max(t.min, Math.min(t.max, u)), a("update:modelValue", Math.round(u / t.step) * t.step);
|
|
1489
1577
|
}
|
|
1490
|
-
return (
|
|
1491
|
-
class:
|
|
1578
|
+
return (w, u) => (S(), z("div", {
|
|
1579
|
+
class: N(["vie-slider", { "vie-slider--dragging": r.value }])
|
|
1492
1580
|
}, [
|
|
1493
|
-
|
|
1581
|
+
o.label ? (S(), z("span", {
|
|
1494
1582
|
key: 0,
|
|
1495
1583
|
class: "vie-slider__label",
|
|
1496
1584
|
id: n
|
|
1497
|
-
}, q(
|
|
1498
|
-
|
|
1585
|
+
}, q(o.label), 1)) : G("", !0),
|
|
1586
|
+
y("div", {
|
|
1499
1587
|
ref_key: "trackRef",
|
|
1500
|
-
ref:
|
|
1588
|
+
ref: h,
|
|
1501
1589
|
class: "vie-slider__track-wrapper",
|
|
1502
1590
|
role: "slider",
|
|
1503
1591
|
tabindex: "0",
|
|
1504
|
-
"aria-valuemin":
|
|
1505
|
-
"aria-valuemax":
|
|
1506
|
-
"aria-valuenow":
|
|
1507
|
-
"aria-labelledby":
|
|
1508
|
-
onPointerdown:
|
|
1509
|
-
onDblclick:
|
|
1592
|
+
"aria-valuemin": o.min,
|
|
1593
|
+
"aria-valuemax": o.max,
|
|
1594
|
+
"aria-valuenow": o.modelValue,
|
|
1595
|
+
"aria-labelledby": o.label ? n : void 0,
|
|
1596
|
+
onPointerdown: x,
|
|
1597
|
+
onDblclick: _,
|
|
1510
1598
|
onKeydown: $
|
|
1511
1599
|
}, [
|
|
1512
|
-
|
|
1513
|
-
|
|
1600
|
+
y("div", Gt, [
|
|
1601
|
+
y("div", {
|
|
1514
1602
|
class: "vie-slider__base-mark",
|
|
1515
|
-
style:
|
|
1603
|
+
style: le({ insetInlineStart: i.value * 100 + "%" })
|
|
1516
1604
|
}, null, 4),
|
|
1517
|
-
(
|
|
1518
|
-
key:
|
|
1605
|
+
(S(!0), z(Y, null, Z(v.value, (g, k) => (S(), z("div", {
|
|
1606
|
+
key: k,
|
|
1519
1607
|
class: "vie-slider__tick",
|
|
1520
|
-
style:
|
|
1608
|
+
style: le({ insetInlineStart: g * 100 + "%" })
|
|
1521
1609
|
}, null, 4))), 128)),
|
|
1522
|
-
|
|
1610
|
+
y("div", {
|
|
1523
1611
|
class: "vie-slider__fill",
|
|
1524
|
-
style:
|
|
1612
|
+
style: le(c.value)
|
|
1525
1613
|
}, null, 4),
|
|
1526
|
-
|
|
1614
|
+
y("div", {
|
|
1527
1615
|
class: "vie-slider__thumb",
|
|
1528
|
-
style:
|
|
1616
|
+
style: le({ insetInlineStart: l.value + "%" })
|
|
1529
1617
|
}, [
|
|
1530
|
-
|
|
1531
|
-
|
|
1618
|
+
u[0] || (u[0] = y("span", { class: "vie-slider__thumb-dot" }, null, -1)),
|
|
1619
|
+
r.value ? (S(), z("span", Qt, q(m.value), 1)) : G("", !0)
|
|
1532
1620
|
], 4)
|
|
1533
1621
|
])
|
|
1534
|
-
], 40,
|
|
1535
|
-
|
|
1622
|
+
], 40, Jt),
|
|
1623
|
+
y("span", en, q(m.value), 1)
|
|
1536
1624
|
], 2));
|
|
1537
1625
|
}
|
|
1538
|
-
}),
|
|
1626
|
+
}), tn = ["aria-expanded"], nn = {
|
|
1539
1627
|
key: 0,
|
|
1540
1628
|
class: "vie-dropdown__menu",
|
|
1541
1629
|
role: "listbox"
|
|
1542
|
-
},
|
|
1630
|
+
}, on = ["aria-selected", "onClick"], an = /* @__PURE__ */ J({
|
|
1543
1631
|
__name: "Dropdown",
|
|
1544
1632
|
props: {
|
|
1545
1633
|
modelValue: {},
|
|
1546
1634
|
options: {}
|
|
1547
1635
|
},
|
|
1548
1636
|
emits: ["update:modelValue"],
|
|
1549
|
-
setup(
|
|
1550
|
-
const n =
|
|
1551
|
-
const
|
|
1552
|
-
return
|
|
1637
|
+
setup(o, { emit: e }) {
|
|
1638
|
+
const n = o, t = e, a = H(!1), h = H(null), r = j(() => {
|
|
1639
|
+
const v = n.options.find((l) => l.value === n.modelValue);
|
|
1640
|
+
return v ? v.label : "";
|
|
1553
1641
|
});
|
|
1554
|
-
function
|
|
1555
|
-
t("update:modelValue",
|
|
1642
|
+
function s(v) {
|
|
1643
|
+
t("update:modelValue", v), a.value = !1;
|
|
1556
1644
|
}
|
|
1557
|
-
function i(
|
|
1558
|
-
|
|
1645
|
+
function i(v) {
|
|
1646
|
+
h.value && !h.value.contains(v.target) && (a.value = !1);
|
|
1559
1647
|
}
|
|
1560
|
-
return
|
|
1561
|
-
|
|
1562
|
-
}),
|
|
1648
|
+
return re(a, (v) => {
|
|
1649
|
+
v ? document.addEventListener("click", i) : document.removeEventListener("click", i);
|
|
1650
|
+
}), he(() => {
|
|
1563
1651
|
document.removeEventListener("click", i);
|
|
1564
|
-
}), (
|
|
1652
|
+
}), (v, l) => (S(), z("div", {
|
|
1565
1653
|
class: "vie-dropdown",
|
|
1566
1654
|
ref_key: "dropdownRef",
|
|
1567
|
-
ref:
|
|
1655
|
+
ref: h
|
|
1568
1656
|
}, [
|
|
1569
|
-
|
|
1657
|
+
y("button", {
|
|
1570
1658
|
class: "vie-dropdown__trigger",
|
|
1571
1659
|
role: "combobox",
|
|
1572
|
-
"aria-expanded":
|
|
1660
|
+
"aria-expanded": a.value,
|
|
1573
1661
|
"aria-haspopup": "listbox",
|
|
1574
|
-
onClick:
|
|
1662
|
+
onClick: l[0] || (l[0] = (c) => a.value = !a.value)
|
|
1575
1663
|
}, [
|
|
1576
|
-
|
|
1577
|
-
|
|
1664
|
+
y("span", null, q(r.value), 1),
|
|
1665
|
+
l[1] || (l[1] = y("svg", {
|
|
1578
1666
|
class: "vie-dropdown__chevron",
|
|
1579
1667
|
viewBox: "0 0 24 24",
|
|
1580
1668
|
fill: "none",
|
|
1581
1669
|
stroke: "currentColor",
|
|
1582
1670
|
"stroke-width": "2"
|
|
1583
1671
|
}, [
|
|
1584
|
-
|
|
1672
|
+
y("path", { d: "M6 9l6 6 6-6" })
|
|
1585
1673
|
], -1))
|
|
1586
|
-
], 8,
|
|
1587
|
-
|
|
1588
|
-
default:
|
|
1589
|
-
|
|
1590
|
-
(
|
|
1674
|
+
], 8, tn),
|
|
1675
|
+
X(Te, { name: "vie-dropdown" }, {
|
|
1676
|
+
default: ne(() => [
|
|
1677
|
+
a.value ? (S(), z("div", nn, [
|
|
1678
|
+
(S(!0), z(Y, null, Z(o.options, (c) => (S(), z("button", {
|
|
1591
1679
|
key: c.value,
|
|
1592
1680
|
role: "option",
|
|
1593
|
-
"aria-selected": c.value ===
|
|
1594
|
-
class:
|
|
1681
|
+
"aria-selected": c.value === o.modelValue,
|
|
1682
|
+
class: N([
|
|
1595
1683
|
"vie-dropdown__item",
|
|
1596
|
-
{ "vie-dropdown__item--active": c.value ===
|
|
1684
|
+
{ "vie-dropdown__item--active": c.value === o.modelValue }
|
|
1597
1685
|
]),
|
|
1598
|
-
onClick: (
|
|
1599
|
-
}, q(c.label), 11,
|
|
1600
|
-
])) :
|
|
1686
|
+
onClick: (m) => s(c.value)
|
|
1687
|
+
}, q(c.label), 11, on))), 128))
|
|
1688
|
+
])) : G("", !0)
|
|
1601
1689
|
]),
|
|
1602
1690
|
_: 1
|
|
1603
1691
|
})
|
|
1604
1692
|
], 512));
|
|
1605
1693
|
}
|
|
1606
|
-
}),
|
|
1694
|
+
}), sn = [
|
|
1607
1695
|
{ labelKey: "custom", value: null },
|
|
1608
1696
|
{ labelKey: "square", value: 1 },
|
|
1609
1697
|
{ labelKey: "landscape", value: 4 / 3 },
|
|
@@ -1611,113 +1699,113 @@ const xt = {
|
|
|
1611
1699
|
{ labelKey: "portrait", value: 3 / 4 },
|
|
1612
1700
|
{ labelKey: "portrait", value: 9 / 16 }
|
|
1613
1701
|
];
|
|
1614
|
-
function
|
|
1615
|
-
if (
|
|
1616
|
-
if (
|
|
1702
|
+
function ln(o, e) {
|
|
1703
|
+
if (o.value === null) return e("custom");
|
|
1704
|
+
if (o.value === 1) return e("square") + " 1:1";
|
|
1617
1705
|
const t = {
|
|
1618
1706
|
[4 / 3]: "4:3",
|
|
1619
1707
|
[16 / 9]: "16:9",
|
|
1620
1708
|
[3 / 4]: "3:4",
|
|
1621
1709
|
[9 / 16]: "9:16"
|
|
1622
|
-
}[
|
|
1623
|
-
return `${e(
|
|
1710
|
+
}[o.value] || `${o.value.toFixed(2)}`, a = o.value > 1 ? "landscape" : "portrait";
|
|
1711
|
+
return `${e(a)} ${t}`;
|
|
1624
1712
|
}
|
|
1625
|
-
const
|
|
1713
|
+
const rn = { class: "vie-crop-controls" }, cn = { class: "vie-crop-controls__section" }, un = { class: "vie-crop-controls__section" }, dn = { class: "vie-crop-controls__section" }, hn = { class: "vie-crop-controls__rotation" }, vn = /* @__PURE__ */ J({
|
|
1626
1714
|
__name: "CropControls",
|
|
1627
|
-
setup(
|
|
1628
|
-
const e =
|
|
1715
|
+
setup(o) {
|
|
1716
|
+
const e = ie(oe, (w) => w), n = ee();
|
|
1629
1717
|
let t = !1;
|
|
1630
|
-
|
|
1631
|
-
if (!
|
|
1632
|
-
const
|
|
1633
|
-
if (!(
|
|
1718
|
+
re(() => n.sourceImage.value, (w) => {
|
|
1719
|
+
if (!w || t) return;
|
|
1720
|
+
const u = n.state.crop;
|
|
1721
|
+
if (!(u.x === 0 && u.y === 0 && u.width === 1 && u.height === 1 && u.aspectRatio === null && u.rotation === 0 && !u.flipX && !u.flipY)) return;
|
|
1634
1722
|
t = !0;
|
|
1635
|
-
const
|
|
1636
|
-
if (
|
|
1637
|
-
const
|
|
1638
|
-
n.updateState((
|
|
1639
|
-
|
|
1723
|
+
const k = w.naturalWidth / w.naturalHeight;
|
|
1724
|
+
if (k >= 1) {
|
|
1725
|
+
const C = 1 / k;
|
|
1726
|
+
n.updateState((P) => {
|
|
1727
|
+
P.crop.x = (1 - C) / 2, P.crop.y = 0, P.crop.width = C, P.crop.height = 1, P.crop.aspectRatio = 1;
|
|
1640
1728
|
});
|
|
1641
1729
|
} else {
|
|
1642
|
-
const
|
|
1643
|
-
n.updateState((
|
|
1644
|
-
|
|
1730
|
+
const C = k;
|
|
1731
|
+
n.updateState((P) => {
|
|
1732
|
+
P.crop.x = 0, P.crop.y = (1 - C) / 2, P.crop.width = 1, P.crop.height = C, P.crop.aspectRatio = 1;
|
|
1645
1733
|
});
|
|
1646
1734
|
}
|
|
1647
1735
|
}, { immediate: !0 });
|
|
1648
|
-
const
|
|
1649
|
-
() =>
|
|
1650
|
-
label:
|
|
1651
|
-
value:
|
|
1736
|
+
const a = j(
|
|
1737
|
+
() => sn.map((w) => ({
|
|
1738
|
+
label: ln(w, e),
|
|
1739
|
+
value: w.value == null ? "custom" : w.value
|
|
1652
1740
|
}))
|
|
1653
|
-
),
|
|
1654
|
-
const
|
|
1655
|
-
return
|
|
1741
|
+
), h = j(() => {
|
|
1742
|
+
const w = n.state.crop.aspectRatio;
|
|
1743
|
+
return w === null ? "custom" : w;
|
|
1656
1744
|
});
|
|
1657
|
-
function
|
|
1658
|
-
const
|
|
1659
|
-
n.updateState((
|
|
1660
|
-
if (
|
|
1661
|
-
const
|
|
1662
|
-
if (
|
|
1663
|
-
const
|
|
1664
|
-
|
|
1745
|
+
function r(w) {
|
|
1746
|
+
const u = w === "custom" ? null : Number(w);
|
|
1747
|
+
n.updateState((g) => {
|
|
1748
|
+
if (g.crop.aspectRatio = u, u !== null) {
|
|
1749
|
+
const k = g.crop.width, C = g.crop.height;
|
|
1750
|
+
if (k / C > u) {
|
|
1751
|
+
const V = C * u;
|
|
1752
|
+
g.crop.x += (k - V) / 2, g.crop.width = V;
|
|
1665
1753
|
} else {
|
|
1666
|
-
const
|
|
1667
|
-
|
|
1754
|
+
const V = k / u;
|
|
1755
|
+
g.crop.y += (C - V) / 2, g.crop.height = V;
|
|
1668
1756
|
}
|
|
1669
1757
|
}
|
|
1670
1758
|
});
|
|
1671
1759
|
}
|
|
1672
|
-
const
|
|
1673
|
-
|
|
1674
|
-
function
|
|
1675
|
-
return n.state.crop.rotation -
|
|
1760
|
+
const s = H(0), i = n.state.crop.rotation, v = Math.round(i / (Math.PI / 2));
|
|
1761
|
+
s.value = (v % 4 + 4) % 4;
|
|
1762
|
+
function l() {
|
|
1763
|
+
return n.state.crop.rotation - s.value * (Math.PI / 2);
|
|
1676
1764
|
}
|
|
1677
|
-
const c =
|
|
1678
|
-
function
|
|
1679
|
-
n.updateState((
|
|
1680
|
-
|
|
1765
|
+
const c = j(() => l() * 180 / Math.PI);
|
|
1766
|
+
function m(w) {
|
|
1767
|
+
n.updateState((u) => {
|
|
1768
|
+
u.crop.rotation = s.value * (Math.PI / 2) + w * Math.PI / 180;
|
|
1681
1769
|
});
|
|
1682
1770
|
}
|
|
1683
|
-
function
|
|
1684
|
-
const
|
|
1685
|
-
|
|
1686
|
-
|
|
1771
|
+
function d() {
|
|
1772
|
+
const w = l();
|
|
1773
|
+
s.value = ((s.value - 1) % 4 + 4) % 4, n.updateState((u) => {
|
|
1774
|
+
u.crop.rotation = s.value * (Math.PI / 2) + w;
|
|
1687
1775
|
});
|
|
1688
1776
|
}
|
|
1689
|
-
function
|
|
1690
|
-
const
|
|
1691
|
-
|
|
1692
|
-
|
|
1777
|
+
function x() {
|
|
1778
|
+
const w = l();
|
|
1779
|
+
s.value = (s.value + 1) % 4, n.updateState((u) => {
|
|
1780
|
+
u.crop.rotation = s.value * (Math.PI / 2) + w;
|
|
1693
1781
|
});
|
|
1694
1782
|
}
|
|
1695
|
-
function
|
|
1696
|
-
n.updateState((
|
|
1697
|
-
|
|
1783
|
+
function _() {
|
|
1784
|
+
n.updateState((w) => {
|
|
1785
|
+
w.crop.flipX = !w.crop.flipX;
|
|
1698
1786
|
});
|
|
1699
1787
|
}
|
|
1700
1788
|
function $() {
|
|
1701
|
-
n.updateState((
|
|
1702
|
-
|
|
1789
|
+
n.updateState((w) => {
|
|
1790
|
+
w.crop.flipY = !w.crop.flipY;
|
|
1703
1791
|
});
|
|
1704
1792
|
}
|
|
1705
|
-
return (
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
"model-value":
|
|
1709
|
-
options:
|
|
1710
|
-
"onUpdate:modelValue":
|
|
1793
|
+
return (w, u) => (S(), z("div", rn, [
|
|
1794
|
+
y("div", cn, [
|
|
1795
|
+
X(an, {
|
|
1796
|
+
"model-value": h.value,
|
|
1797
|
+
options: a.value,
|
|
1798
|
+
"onUpdate:modelValue": r
|
|
1711
1799
|
}, null, 8, ["model-value", "options"])
|
|
1712
1800
|
]),
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
title:
|
|
1717
|
-
onClick:
|
|
1801
|
+
u[4] || (u[4] = y("div", { class: "vie-crop-controls__divider" }, null, -1)),
|
|
1802
|
+
y("div", un, [
|
|
1803
|
+
X(se, {
|
|
1804
|
+
title: I(e)("rotateLeft"),
|
|
1805
|
+
onClick: d
|
|
1718
1806
|
}, {
|
|
1719
|
-
default:
|
|
1720
|
-
|
|
1807
|
+
default: ne(() => [...u[0] || (u[0] = [
|
|
1808
|
+
y("svg", {
|
|
1721
1809
|
viewBox: "0 0 24 24",
|
|
1722
1810
|
fill: "none",
|
|
1723
1811
|
stroke: "currentColor",
|
|
@@ -1725,18 +1813,18 @@ const Ht = { class: "vie-crop-controls" }, Vt = { class: "vie-crop-controls__sec
|
|
|
1725
1813
|
"stroke-linecap": "round",
|
|
1726
1814
|
"stroke-linejoin": "round"
|
|
1727
1815
|
}, [
|
|
1728
|
-
|
|
1729
|
-
|
|
1816
|
+
y("path", { d: "M2.5 2v6h6" }),
|
|
1817
|
+
y("path", { d: "M2.5 8C5 4 9 2 13 2a9 9 0 1 1-6 15.7" })
|
|
1730
1818
|
], -1)
|
|
1731
1819
|
])]),
|
|
1732
1820
|
_: 1
|
|
1733
1821
|
}, 8, ["title"]),
|
|
1734
|
-
|
|
1735
|
-
title:
|
|
1736
|
-
onClick:
|
|
1822
|
+
X(se, {
|
|
1823
|
+
title: I(e)("rotateRight"),
|
|
1824
|
+
onClick: x
|
|
1737
1825
|
}, {
|
|
1738
|
-
default:
|
|
1739
|
-
|
|
1826
|
+
default: ne(() => [...u[1] || (u[1] = [
|
|
1827
|
+
y("svg", {
|
|
1740
1828
|
viewBox: "0 0 24 24",
|
|
1741
1829
|
fill: "none",
|
|
1742
1830
|
stroke: "currentColor",
|
|
@@ -1744,58 +1832,58 @@ const Ht = { class: "vie-crop-controls" }, Vt = { class: "vie-crop-controls__sec
|
|
|
1744
1832
|
"stroke-linecap": "round",
|
|
1745
1833
|
"stroke-linejoin": "round"
|
|
1746
1834
|
}, [
|
|
1747
|
-
|
|
1748
|
-
|
|
1835
|
+
y("path", { d: "M21.5 2v6h-6" }),
|
|
1836
|
+
y("path", { d: "M21.5 8C19 4 15 2 11 2a9 9 0 1 0 6 15.7" })
|
|
1749
1837
|
], -1)
|
|
1750
1838
|
])]),
|
|
1751
1839
|
_: 1
|
|
1752
1840
|
}, 8, ["title"])
|
|
1753
1841
|
]),
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
title:
|
|
1758
|
-
onClick:
|
|
1842
|
+
u[5] || (u[5] = y("div", { class: "vie-crop-controls__divider" }, null, -1)),
|
|
1843
|
+
y("div", dn, [
|
|
1844
|
+
X(se, {
|
|
1845
|
+
title: I(e)("flipHorizontal"),
|
|
1846
|
+
onClick: _
|
|
1759
1847
|
}, {
|
|
1760
|
-
default:
|
|
1761
|
-
|
|
1848
|
+
default: ne(() => [...u[2] || (u[2] = [
|
|
1849
|
+
y("svg", {
|
|
1762
1850
|
viewBox: "0 0 24 24",
|
|
1763
1851
|
fill: "none",
|
|
1764
1852
|
stroke: "currentColor",
|
|
1765
1853
|
"stroke-width": "2",
|
|
1766
1854
|
"stroke-linecap": "round"
|
|
1767
1855
|
}, [
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1856
|
+
y("path", { d: "M12 3v18" }),
|
|
1857
|
+
y("path", { d: "M16 7l4 5-4 5" }),
|
|
1858
|
+
y("path", { d: "M8 7L4 12l4 5" })
|
|
1771
1859
|
], -1)
|
|
1772
1860
|
])]),
|
|
1773
1861
|
_: 1
|
|
1774
1862
|
}, 8, ["title"]),
|
|
1775
|
-
|
|
1776
|
-
title:
|
|
1863
|
+
X(se, {
|
|
1864
|
+
title: I(e)("flipVertical"),
|
|
1777
1865
|
onClick: $
|
|
1778
1866
|
}, {
|
|
1779
|
-
default:
|
|
1780
|
-
|
|
1867
|
+
default: ne(() => [...u[3] || (u[3] = [
|
|
1868
|
+
y("svg", {
|
|
1781
1869
|
viewBox: "0 0 24 24",
|
|
1782
1870
|
fill: "none",
|
|
1783
1871
|
stroke: "currentColor",
|
|
1784
1872
|
"stroke-width": "2",
|
|
1785
1873
|
"stroke-linecap": "round"
|
|
1786
1874
|
}, [
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1875
|
+
y("path", { d: "M3 12h18" }),
|
|
1876
|
+
y("path", { d: "M7 8L12 4l5 4" }),
|
|
1877
|
+
y("path", { d: "M7 16l5 4 5-4" })
|
|
1790
1878
|
], -1)
|
|
1791
1879
|
])]),
|
|
1792
1880
|
_: 1
|
|
1793
1881
|
}, 8, ["title"])
|
|
1794
1882
|
]),
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
label:
|
|
1883
|
+
u[6] || (u[6] = y("div", { class: "vie-crop-controls__divider" }, null, -1)),
|
|
1884
|
+
y("div", hn, [
|
|
1885
|
+
X(fe, {
|
|
1886
|
+
label: I(e)("rotation"),
|
|
1799
1887
|
"model-value": c.value,
|
|
1800
1888
|
min: -45,
|
|
1801
1889
|
max: 45,
|
|
@@ -1803,262 +1891,262 @@ const Ht = { class: "vie-crop-controls" }, Vt = { class: "vie-crop-controls__sec
|
|
|
1803
1891
|
base: 0,
|
|
1804
1892
|
format: "number",
|
|
1805
1893
|
ticks: [-45, -30, -15, 0, 15, 30, 45],
|
|
1806
|
-
"onUpdate:modelValue":
|
|
1894
|
+
"onUpdate:modelValue": m
|
|
1807
1895
|
}, null, 8, ["label", "model-value"])
|
|
1808
1896
|
])
|
|
1809
1897
|
]));
|
|
1810
1898
|
}
|
|
1811
|
-
}),
|
|
1899
|
+
}), fn = ["viewBox", "width", "height"], pn = ["width", "height"], mn = ["x", "y", "width", "height"], gn = ["width", "height", "mask"], yn = ["x", "y", "width", "height"], wn = {
|
|
1812
1900
|
key: 0,
|
|
1813
1901
|
class: "vie-crop-grid"
|
|
1814
|
-
},
|
|
1902
|
+
}, kn = ["x1", "y1", "x2", "y2"], bn = ["x1", "y1", "x2", "y2"], xn = ["x", "y", "width", "height"], _n = ["x", "y", "data-handle"], Cn = ["x", "y", "width", "height", "data-handle"], Mn = ["x", "y"], Sn = {
|
|
1815
1903
|
xmlns: "http://www.w3.org/1999/xhtml",
|
|
1816
1904
|
style: { display: "flex", "justify-content": "center", "pointer-events": "none" }
|
|
1817
|
-
},
|
|
1905
|
+
}, de = 12, $n = 8, Rn = 32, zn = /* @__PURE__ */ J({
|
|
1818
1906
|
__name: "CropOverlay",
|
|
1819
1907
|
props: {
|
|
1820
1908
|
canvasRect: {},
|
|
1821
1909
|
wrapperSize: {}
|
|
1822
1910
|
},
|
|
1823
|
-
setup(
|
|
1824
|
-
const e = `vie-crop-mask-${Math.random().toString(36).slice(2, 9)}`, n =
|
|
1825
|
-
const
|
|
1911
|
+
setup(o) {
|
|
1912
|
+
const e = `vie-crop-mask-${Math.random().toString(36).slice(2, 9)}`, n = o, t = ee(), a = ie(oe, (g) => g), h = j(() => n.wrapperSize.width || 800), r = j(() => n.wrapperSize.height || 600), s = j(() => {
|
|
1913
|
+
const g = n.canvasRect, k = t.state.crop;
|
|
1826
1914
|
return {
|
|
1827
|
-
x:
|
|
1828
|
-
y:
|
|
1829
|
-
width:
|
|
1830
|
-
height:
|
|
1915
|
+
x: g.x + k.x * g.width,
|
|
1916
|
+
y: g.y + k.y * g.height,
|
|
1917
|
+
width: k.width * g.width,
|
|
1918
|
+
height: k.height * g.height
|
|
1831
1919
|
};
|
|
1832
|
-
}), i =
|
|
1833
|
-
const
|
|
1920
|
+
}), i = j(() => {
|
|
1921
|
+
const g = s.value, C = de / 2;
|
|
1834
1922
|
return [
|
|
1835
|
-
{ id: "nw", x:
|
|
1836
|
-
{ id: "ne", x:
|
|
1837
|
-
{ id: "sw", x:
|
|
1838
|
-
{ id: "se", x:
|
|
1923
|
+
{ id: "nw", x: g.x - C, y: g.y - C },
|
|
1924
|
+
{ id: "ne", x: g.x + g.width - C, y: g.y - C },
|
|
1925
|
+
{ id: "sw", x: g.x - C, y: g.y + g.height - C },
|
|
1926
|
+
{ id: "se", x: g.x + g.width - C, y: g.y + g.height - C }
|
|
1839
1927
|
];
|
|
1840
|
-
}),
|
|
1841
|
-
const
|
|
1928
|
+
}), v = j(() => {
|
|
1929
|
+
const g = s.value, k = Math.min(Rn, g.width * 0.3, g.height * 0.3), C = $n;
|
|
1842
1930
|
return [
|
|
1843
|
-
{ id: "n", x:
|
|
1844
|
-
{ id: "s", x:
|
|
1845
|
-
{ id: "w", x:
|
|
1846
|
-
{ id: "e", x:
|
|
1931
|
+
{ id: "n", x: g.x + (g.width - k) / 2, y: g.y - C / 2, w: k, h: C },
|
|
1932
|
+
{ id: "s", x: g.x + (g.width - k) / 2, y: g.y + g.height - C / 2, w: k, h: C },
|
|
1933
|
+
{ id: "w", x: g.x - C / 2, y: g.y + (g.height - k) / 2, w: C, h: k },
|
|
1934
|
+
{ id: "e", x: g.x + g.width - C / 2, y: g.y + (g.height - k) / 2, w: C, h: k }
|
|
1847
1935
|
];
|
|
1848
|
-
}),
|
|
1849
|
-
let
|
|
1850
|
-
function
|
|
1851
|
-
const
|
|
1852
|
-
if (!
|
|
1853
|
-
|
|
1854
|
-
const
|
|
1855
|
-
|
|
1856
|
-
const
|
|
1857
|
-
if (!
|
|
1858
|
-
const
|
|
1859
|
-
if (
|
|
1860
|
-
const
|
|
1861
|
-
switch (
|
|
1936
|
+
}), l = H(null), c = H({ x: 0, y: 0 }), m = H({ x: 0, y: 0, width: 0, height: 0 }), d = H(!1);
|
|
1937
|
+
let x = null;
|
|
1938
|
+
function _(g) {
|
|
1939
|
+
const k = g.target, C = k.getAttribute("data-handle");
|
|
1940
|
+
if (!C) return;
|
|
1941
|
+
g.preventDefault();
|
|
1942
|
+
const P = k.ownerSVGElement || k;
|
|
1943
|
+
P.setPointerCapture(g.pointerId), l.value = C, c.value = { x: g.clientX, y: g.clientY }, m.value = { ...t.state.crop };
|
|
1944
|
+
const V = (K) => {
|
|
1945
|
+
if (!l.value) return;
|
|
1946
|
+
const L = n.canvasRect;
|
|
1947
|
+
if (L.width === 0 || L.height === 0) return;
|
|
1948
|
+
const E = (K.clientX - c.value.x) / L.width, O = (K.clientY - c.value.y) / L.height, M = m.value, F = t.state.crop, f = F.aspectRatio;
|
|
1949
|
+
switch (l.value) {
|
|
1862
1950
|
case "move": {
|
|
1863
|
-
const
|
|
1864
|
-
t.cropDragPan.value = { x:
|
|
1951
|
+
const p = K.clientX - c.value.x, b = K.clientY - c.value.y, R = u(M.x - p / L.width, 0, 1 - F.width), T = u(M.y - b / L.height, 0, 1 - F.height), W = (M.x - R) * L.width, B = (M.y - T) * L.height;
|
|
1952
|
+
t.cropDragPan.value = { x: W, y: B };
|
|
1865
1953
|
break;
|
|
1866
1954
|
}
|
|
1867
1955
|
case "nw": {
|
|
1868
|
-
let
|
|
1869
|
-
|
|
1956
|
+
let p = u(M.x + E), b = u(M.y + O), R = M.x + M.width - p, T = M.y + M.height - b;
|
|
1957
|
+
f && (T = R / f, b = M.y + M.height - T, b < 0 && (b = 0, T = M.y + M.height, R = T * f, p = M.x + M.width - R)), R > 0.02 && T > 0.02 && p >= 0 && b >= 0 && (F.x = p, F.y = b, F.width = R, F.height = T);
|
|
1870
1958
|
break;
|
|
1871
1959
|
}
|
|
1872
1960
|
case "ne": {
|
|
1873
|
-
let
|
|
1874
|
-
|
|
1961
|
+
let p = u(M.width + E, 0.02, 1 - M.x), b = M.y + O, R = M.y + M.height - b;
|
|
1962
|
+
f && (R = p / f, b = M.y + M.height - R, b < 0 && (b = 0, R = M.y + M.height, p = R * f)), p > 0.02 && R > 0.02 && b >= 0 && M.x + p <= 1 && (F.y = b, F.width = p, F.height = R);
|
|
1875
1963
|
break;
|
|
1876
1964
|
}
|
|
1877
1965
|
case "sw": {
|
|
1878
|
-
let
|
|
1879
|
-
|
|
1966
|
+
let p = u(M.x + E), b = M.x + M.width - p, R = u(M.height + O, 0.02, 1 - M.y);
|
|
1967
|
+
f && (b = R * f, p = M.x + M.width - b, p < 0 && (p = 0, b = M.x + M.width, R = b / f)), b > 0.02 && R > 0.02 && p >= 0 && M.y + R <= 1 && (F.x = p, F.width = b, F.height = R);
|
|
1880
1968
|
break;
|
|
1881
1969
|
}
|
|
1882
1970
|
case "se": {
|
|
1883
|
-
let
|
|
1884
|
-
|
|
1971
|
+
let p = u(M.width + E, 0.02, 1 - M.x), b = u(M.height + O, 0.02, 1 - M.y);
|
|
1972
|
+
f && (b = p / f, M.y + b > 1 && (b = 1 - M.y, p = b * f)), p > 0.02 && b > 0.02 && M.x + p <= 1 && M.y + b <= 1 && (F.width = p, F.height = b);
|
|
1885
1973
|
break;
|
|
1886
1974
|
}
|
|
1887
1975
|
case "n": {
|
|
1888
|
-
let
|
|
1889
|
-
if (
|
|
1890
|
-
const
|
|
1891
|
-
|
|
1976
|
+
let p = u(M.y + O), b = M.y + M.height - p;
|
|
1977
|
+
if (f) {
|
|
1978
|
+
const R = b * f, T = R - M.width, W = u(M.x - T / 2, 0, 1 - R);
|
|
1979
|
+
R > 0.02 && W >= 0 && W + R <= 1 && (F.x = W, F.width = R);
|
|
1892
1980
|
}
|
|
1893
|
-
|
|
1981
|
+
b > 0.02 && p >= 0 && (F.y = p, F.height = b);
|
|
1894
1982
|
break;
|
|
1895
1983
|
}
|
|
1896
1984
|
case "s": {
|
|
1897
|
-
let
|
|
1898
|
-
if (
|
|
1899
|
-
const
|
|
1900
|
-
|
|
1985
|
+
let p = u(M.height + O, 0.02, 1 - M.y);
|
|
1986
|
+
if (f) {
|
|
1987
|
+
const b = p * f, R = b - M.width, T = u(M.x - R / 2, 0, 1 - b);
|
|
1988
|
+
b > 0.02 && T >= 0 && T + b <= 1 && (F.x = T, F.width = b);
|
|
1901
1989
|
}
|
|
1902
|
-
|
|
1990
|
+
p > 0.02 && M.y + p <= 1 && (F.height = p);
|
|
1903
1991
|
break;
|
|
1904
1992
|
}
|
|
1905
1993
|
case "w": {
|
|
1906
|
-
let
|
|
1907
|
-
if (
|
|
1908
|
-
const
|
|
1909
|
-
|
|
1994
|
+
let p = u(M.x + E), b = M.x + M.width - p;
|
|
1995
|
+
if (f) {
|
|
1996
|
+
const R = b / f, T = R - M.height, W = u(M.y - T / 2, 0, 1 - R);
|
|
1997
|
+
R > 0.02 && W >= 0 && W + R <= 1 && (F.y = W, F.height = R);
|
|
1910
1998
|
}
|
|
1911
|
-
|
|
1999
|
+
b > 0.02 && p >= 0 && (F.x = p, F.width = b);
|
|
1912
2000
|
break;
|
|
1913
2001
|
}
|
|
1914
2002
|
case "e": {
|
|
1915
|
-
let
|
|
1916
|
-
if (
|
|
1917
|
-
const
|
|
1918
|
-
|
|
2003
|
+
let p = u(M.width + E, 0.02, 1 - M.x);
|
|
2004
|
+
if (f) {
|
|
2005
|
+
const b = p / f, R = b - M.height, T = u(M.y - R / 2, 0, 1 - b);
|
|
2006
|
+
b > 0.02 && T >= 0 && T + b <= 1 && (F.y = T, F.height = b);
|
|
1919
2007
|
}
|
|
1920
|
-
|
|
2008
|
+
p > 0.02 && M.x + p <= 1 && (F.width = p);
|
|
1921
2009
|
break;
|
|
1922
2010
|
}
|
|
1923
2011
|
}
|
|
1924
2012
|
t.requestRender();
|
|
1925
|
-
},
|
|
1926
|
-
window.removeEventListener("pointermove",
|
|
1927
|
-
},
|
|
1928
|
-
if (
|
|
1929
|
-
const
|
|
1930
|
-
|
|
2013
|
+
}, A = () => {
|
|
2014
|
+
window.removeEventListener("pointermove", V), window.removeEventListener("pointerup", D), x = null;
|
|
2015
|
+
}, D = (K) => {
|
|
2016
|
+
if (l.value === "move") {
|
|
2017
|
+
const L = K.clientX - c.value.x, E = K.clientY - c.value.y, O = n.canvasRect, M = m.value, F = t.state.crop;
|
|
2018
|
+
F.x = u(M.x - L / O.width, 0, 1 - F.width), F.y = u(M.y - E / O.height, 0, 1 - F.height), t.cropDragPan.value = { x: 0, y: 0 };
|
|
1931
2019
|
}
|
|
1932
|
-
|
|
1933
|
-
})),
|
|
2020
|
+
l.value && (l.value !== "move" && (d.value = !0), t.updateState(() => {
|
|
2021
|
+
})), l.value = null;
|
|
1934
2022
|
try {
|
|
1935
|
-
|
|
2023
|
+
P.releasePointerCapture(K.pointerId);
|
|
1936
2024
|
} catch {
|
|
1937
2025
|
}
|
|
1938
|
-
|
|
2026
|
+
A();
|
|
1939
2027
|
};
|
|
1940
|
-
window.addEventListener("pointermove",
|
|
2028
|
+
window.addEventListener("pointermove", V), window.addEventListener("pointerup", D), x = A;
|
|
1941
2029
|
}
|
|
1942
|
-
|
|
1943
|
-
|
|
2030
|
+
he(() => {
|
|
2031
|
+
x == null || x(), t.cropDragPan.value = { x: 0, y: 0 };
|
|
1944
2032
|
});
|
|
1945
|
-
const $ =
|
|
1946
|
-
const
|
|
1947
|
-
return
|
|
2033
|
+
const $ = j(() => {
|
|
2034
|
+
const g = t.state.crop;
|
|
2035
|
+
return d.value && !l.value && s.value.width > 60 && s.value.height > 60 && (g.x > 1e-3 || g.y > 1e-3 || g.width < 0.999 || g.height < 0.999);
|
|
1948
2036
|
});
|
|
1949
|
-
|
|
1950
|
-
|
|
2037
|
+
re(() => t.state.crop.aspectRatio, () => {
|
|
2038
|
+
d.value = !1;
|
|
1951
2039
|
});
|
|
1952
|
-
function
|
|
1953
|
-
const
|
|
1954
|
-
|
|
2040
|
+
function w() {
|
|
2041
|
+
const g = t.plugins.value, k = g.findIndex((C) => C.id === t.activePluginId.value);
|
|
2042
|
+
k >= 0 && k < g.length - 1 && t.setActivePlugin(g[k + 1].id);
|
|
1955
2043
|
}
|
|
1956
|
-
function
|
|
1957
|
-
return Math.max(
|
|
2044
|
+
function u(g, k = 0, C = 1) {
|
|
2045
|
+
return Math.max(k, Math.min(C, g));
|
|
1958
2046
|
}
|
|
1959
|
-
return (
|
|
1960
|
-
class:
|
|
2047
|
+
return (g, k) => (S(), z("svg", {
|
|
2048
|
+
class: N(["vie-crop-overlay", { "vie-crop-overlay--dragging": l.value }]),
|
|
1961
2049
|
role: "application",
|
|
1962
2050
|
"aria-label": "Crop region",
|
|
1963
|
-
viewBox: `0 0 ${
|
|
1964
|
-
width:
|
|
1965
|
-
height:
|
|
2051
|
+
viewBox: `0 0 ${h.value} ${r.value}`,
|
|
2052
|
+
width: h.value,
|
|
2053
|
+
height: r.value,
|
|
1966
2054
|
style: { "touch-action": "none" },
|
|
1967
|
-
onPointerdown:
|
|
2055
|
+
onPointerdown: _
|
|
1968
2056
|
}, [
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
2057
|
+
y("defs", null, [
|
|
2058
|
+
y("mask", { id: e }, [
|
|
2059
|
+
y("rect", {
|
|
1972
2060
|
x: "0",
|
|
1973
2061
|
y: "0",
|
|
1974
|
-
width:
|
|
1975
|
-
height:
|
|
2062
|
+
width: h.value,
|
|
2063
|
+
height: r.value,
|
|
1976
2064
|
fill: "white"
|
|
1977
|
-
}, null, 8,
|
|
1978
|
-
|
|
1979
|
-
x:
|
|
1980
|
-
y:
|
|
1981
|
-
width: Math.max(0,
|
|
1982
|
-
height: Math.max(0,
|
|
2065
|
+
}, null, 8, pn),
|
|
2066
|
+
y("rect", {
|
|
2067
|
+
x: s.value.x,
|
|
2068
|
+
y: s.value.y,
|
|
2069
|
+
width: Math.max(0, s.value.width),
|
|
2070
|
+
height: Math.max(0, s.value.height),
|
|
1983
2071
|
fill: "black"
|
|
1984
|
-
}, null, 8,
|
|
2072
|
+
}, null, 8, mn)
|
|
1985
2073
|
])
|
|
1986
2074
|
]),
|
|
1987
|
-
|
|
2075
|
+
y("rect", {
|
|
1988
2076
|
x: "0",
|
|
1989
2077
|
y: "0",
|
|
1990
|
-
width:
|
|
1991
|
-
height:
|
|
2078
|
+
width: h.value,
|
|
2079
|
+
height: r.value,
|
|
1992
2080
|
class: "vie-crop-mask",
|
|
1993
2081
|
mask: `url(#${e})`
|
|
1994
|
-
}, null, 8,
|
|
1995
|
-
|
|
1996
|
-
x:
|
|
1997
|
-
y:
|
|
1998
|
-
width: Math.max(0,
|
|
1999
|
-
height: Math.max(0,
|
|
2082
|
+
}, null, 8, gn),
|
|
2083
|
+
y("rect", {
|
|
2084
|
+
x: s.value.x,
|
|
2085
|
+
y: s.value.y,
|
|
2086
|
+
width: Math.max(0, s.value.width),
|
|
2087
|
+
height: Math.max(0, s.value.height),
|
|
2000
2088
|
class: "vie-crop-border"
|
|
2001
|
-
}, null, 8,
|
|
2002
|
-
|
|
2003
|
-
(
|
|
2004
|
-
key: "h" +
|
|
2005
|
-
x1:
|
|
2006
|
-
y1:
|
|
2007
|
-
x2:
|
|
2008
|
-
y2:
|
|
2009
|
-
}, null, 8,
|
|
2010
|
-
(
|
|
2011
|
-
key: "v" +
|
|
2012
|
-
x1:
|
|
2013
|
-
y1:
|
|
2014
|
-
x2:
|
|
2015
|
-
y2:
|
|
2016
|
-
}, null, 8,
|
|
2017
|
-
])) :
|
|
2018
|
-
|
|
2019
|
-
x:
|
|
2020
|
-
y:
|
|
2021
|
-
width: Math.max(0,
|
|
2022
|
-
height: Math.max(0,
|
|
2089
|
+
}, null, 8, yn),
|
|
2090
|
+
s.value.width > 10 && s.value.height > 10 ? (S(), z("g", wn, [
|
|
2091
|
+
(S(), z(Y, null, Z(2, (C) => y("line", {
|
|
2092
|
+
key: "h" + C,
|
|
2093
|
+
x1: s.value.x,
|
|
2094
|
+
y1: s.value.y + s.value.height * (C / 3),
|
|
2095
|
+
x2: s.value.x + s.value.width,
|
|
2096
|
+
y2: s.value.y + s.value.height * (C / 3)
|
|
2097
|
+
}, null, 8, kn)), 64)),
|
|
2098
|
+
(S(), z(Y, null, Z(2, (C) => y("line", {
|
|
2099
|
+
key: "v" + C,
|
|
2100
|
+
x1: s.value.x + s.value.width * (C / 3),
|
|
2101
|
+
y1: s.value.y,
|
|
2102
|
+
x2: s.value.x + s.value.width * (C / 3),
|
|
2103
|
+
y2: s.value.y + s.value.height
|
|
2104
|
+
}, null, 8, bn)), 64))
|
|
2105
|
+
])) : G("", !0),
|
|
2106
|
+
y("rect", {
|
|
2107
|
+
x: s.value.x + de,
|
|
2108
|
+
y: s.value.y + de,
|
|
2109
|
+
width: Math.max(0, s.value.width - de * 2),
|
|
2110
|
+
height: Math.max(0, s.value.height - de * 2),
|
|
2023
2111
|
class: "vie-crop-move",
|
|
2024
2112
|
"data-handle": "move"
|
|
2025
|
-
}, null, 8,
|
|
2026
|
-
(
|
|
2027
|
-
key:
|
|
2028
|
-
x:
|
|
2029
|
-
y:
|
|
2030
|
-
width:
|
|
2031
|
-
height:
|
|
2032
|
-
class:
|
|
2033
|
-
"data-handle":
|
|
2113
|
+
}, null, 8, xn),
|
|
2114
|
+
(S(!0), z(Y, null, Z(i.value, (C) => (S(), z("rect", {
|
|
2115
|
+
key: C.id,
|
|
2116
|
+
x: C.x,
|
|
2117
|
+
y: C.y,
|
|
2118
|
+
width: de,
|
|
2119
|
+
height: de,
|
|
2120
|
+
class: N(["vie-crop-handle", `vie-crop-handle--${C.id}`]),
|
|
2121
|
+
"data-handle": C.id,
|
|
2034
2122
|
rx: "2"
|
|
2035
|
-
}, null, 10,
|
|
2036
|
-
(
|
|
2037
|
-
key:
|
|
2038
|
-
x:
|
|
2039
|
-
y:
|
|
2040
|
-
width:
|
|
2041
|
-
height:
|
|
2042
|
-
class:
|
|
2043
|
-
"data-handle":
|
|
2123
|
+
}, null, 10, _n))), 128)),
|
|
2124
|
+
(S(!0), z(Y, null, Z(v.value, (C) => (S(), z("rect", {
|
|
2125
|
+
key: C.id,
|
|
2126
|
+
x: C.x,
|
|
2127
|
+
y: C.y,
|
|
2128
|
+
width: C.w,
|
|
2129
|
+
height: C.h,
|
|
2130
|
+
class: N(["vie-crop-handle", `vie-crop-handle--${C.id}`]),
|
|
2131
|
+
"data-handle": C.id,
|
|
2044
2132
|
rx: "2"
|
|
2045
|
-
}, null, 10,
|
|
2046
|
-
$.value ? (
|
|
2133
|
+
}, null, 10, Cn))), 128)),
|
|
2134
|
+
$.value ? (S(), z("foreignObject", {
|
|
2047
2135
|
key: 1,
|
|
2048
|
-
x:
|
|
2049
|
-
y:
|
|
2136
|
+
x: s.value.x + (s.value.width - 100) / 2,
|
|
2137
|
+
y: s.value.y + s.value.height - 14,
|
|
2050
2138
|
width: "100",
|
|
2051
2139
|
height: "36",
|
|
2052
2140
|
style: { "pointer-events": "none", overflow: "visible" }
|
|
2053
2141
|
}, [
|
|
2054
|
-
|
|
2055
|
-
|
|
2142
|
+
y("div", Sn, [
|
|
2143
|
+
y("button", {
|
|
2056
2144
|
class: "vie-crop-confirm-pill",
|
|
2057
|
-
onPointerdown:
|
|
2145
|
+
onPointerdown: k[0] || (k[0] = ve(() => {
|
|
2058
2146
|
}, ["stop"])),
|
|
2059
|
-
onClick:
|
|
2147
|
+
onClick: ve(w, ["stop"])
|
|
2060
2148
|
}, [
|
|
2061
|
-
|
|
2149
|
+
k[1] || (k[1] = y("svg", {
|
|
2062
2150
|
viewBox: "0 0 24 24",
|
|
2063
2151
|
width: "14",
|
|
2064
2152
|
height: "14",
|
|
@@ -2068,30 +2156,30 @@ const Ht = { class: "vie-crop-controls" }, Vt = { class: "vie-crop-controls__sec
|
|
|
2068
2156
|
"stroke-linecap": "round",
|
|
2069
2157
|
"stroke-linejoin": "round"
|
|
2070
2158
|
}, [
|
|
2071
|
-
|
|
2159
|
+
y("polyline", { points: "20 6 9 17 4 12" })
|
|
2072
2160
|
], -1)),
|
|
2073
|
-
|
|
2161
|
+
y("span", null, q(I(a)("cropApply")), 1)
|
|
2074
2162
|
], 32)
|
|
2075
2163
|
])
|
|
2076
|
-
], 8,
|
|
2077
|
-
], 42,
|
|
2164
|
+
], 8, Mn)) : G("", !0)
|
|
2165
|
+
], 42, fn));
|
|
2078
2166
|
}
|
|
2079
|
-
}),
|
|
2167
|
+
}), In = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2080
2168
|
<path d="M6 2v4" />
|
|
2081
2169
|
<path d="M6 6h12a2 2 0 0 1 2 2v8" />
|
|
2082
2170
|
<path d="M18 22v-4" />
|
|
2083
2171
|
<path d="M18 18H6a2 2 0 0 1-2-2V8" />
|
|
2084
2172
|
</svg>`;
|
|
2085
|
-
function
|
|
2173
|
+
function Pn() {
|
|
2086
2174
|
return {
|
|
2087
2175
|
id: "crop",
|
|
2088
|
-
icon:
|
|
2176
|
+
icon: In,
|
|
2089
2177
|
labelKey: "crop",
|
|
2090
|
-
controls:
|
|
2091
|
-
overlay:
|
|
2178
|
+
controls: vn,
|
|
2179
|
+
overlay: zn
|
|
2092
2180
|
};
|
|
2093
2181
|
}
|
|
2094
|
-
const
|
|
2182
|
+
const Tn = [
|
|
2095
2183
|
{ key: "brightness", labelKey: "brightness", min: -0.25, max: 0.25, base: 0, step: 0.01 },
|
|
2096
2184
|
{ key: "contrast", labelKey: "contrast", min: -0.25, max: 0.25, base: 0, step: 0.01 },
|
|
2097
2185
|
{ key: "saturation", labelKey: "saturation", min: -0.25, max: 0.25, base: 0, step: 0.01 },
|
|
@@ -2100,30 +2188,30 @@ const dn = [
|
|
|
2100
2188
|
{ key: "gamma", labelKey: "gamma", min: 0.2, max: 5, base: 1, step: 0.05 },
|
|
2101
2189
|
{ key: "clarity", labelKey: "clarity", min: -0.25, max: 0.25, base: 0, step: 0.01 },
|
|
2102
2190
|
{ key: "vignette", labelKey: "vignette", min: -1, max: 1, base: 0, step: 0.05 }
|
|
2103
|
-
],
|
|
2191
|
+
], En = { class: "vie-finetune-controls" }, Wn = /* @__PURE__ */ J({
|
|
2104
2192
|
__name: "FinetuneControls",
|
|
2105
|
-
setup(
|
|
2106
|
-
const e =
|
|
2107
|
-
function t(
|
|
2108
|
-
e.updateState((
|
|
2109
|
-
|
|
2193
|
+
setup(o) {
|
|
2194
|
+
const e = ee(), n = ie(oe, (a) => a);
|
|
2195
|
+
function t(a, h) {
|
|
2196
|
+
e.updateState((r) => {
|
|
2197
|
+
r.finetune[a] = h;
|
|
2110
2198
|
});
|
|
2111
2199
|
}
|
|
2112
|
-
return (
|
|
2113
|
-
(
|
|
2114
|
-
key:
|
|
2115
|
-
modelValue:
|
|
2116
|
-
min:
|
|
2117
|
-
max:
|
|
2118
|
-
step:
|
|
2119
|
-
base:
|
|
2120
|
-
label:
|
|
2121
|
-
format:
|
|
2122
|
-
"onUpdate:modelValue": (
|
|
2200
|
+
return (a, h) => (S(), z("div", En, [
|
|
2201
|
+
(S(!0), z(Y, null, Z(I(Tn), (r) => (S(), pe(fe, {
|
|
2202
|
+
key: r.key,
|
|
2203
|
+
modelValue: I(e).state.finetune[r.key],
|
|
2204
|
+
min: r.min,
|
|
2205
|
+
max: r.max,
|
|
2206
|
+
step: r.step,
|
|
2207
|
+
base: r.base,
|
|
2208
|
+
label: I(n)(r.labelKey),
|
|
2209
|
+
format: r.key === "gamma" ? "number" : "percent",
|
|
2210
|
+
"onUpdate:modelValue": (s) => t(r.key, s)
|
|
2123
2211
|
}, null, 8, ["modelValue", "min", "max", "step", "base", "label", "format", "onUpdate:modelValue"]))), 128))
|
|
2124
2212
|
]));
|
|
2125
2213
|
}
|
|
2126
|
-
}),
|
|
2214
|
+
}), An = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2127
2215
|
<line x1="4" y1="21" x2="4" y2="14" />
|
|
2128
2216
|
<line x1="4" y1="10" x2="4" y2="3" />
|
|
2129
2217
|
<line x1="12" y1="21" x2="12" y2="12" />
|
|
@@ -2134,15 +2222,15 @@ const dn = [
|
|
|
2134
2222
|
<line x1="9" y1="8" x2="15" y2="8" />
|
|
2135
2223
|
<line x1="17" y1="16" x2="23" y2="16" />
|
|
2136
2224
|
</svg>`;
|
|
2137
|
-
function
|
|
2225
|
+
function Fn() {
|
|
2138
2226
|
return {
|
|
2139
2227
|
id: "finetune",
|
|
2140
|
-
icon:
|
|
2228
|
+
icon: An,
|
|
2141
2229
|
labelKey: "finetune",
|
|
2142
|
-
controls:
|
|
2230
|
+
controls: Wn
|
|
2143
2231
|
};
|
|
2144
2232
|
}
|
|
2145
|
-
const
|
|
2233
|
+
const be = [
|
|
2146
2234
|
{
|
|
2147
2235
|
id: "chrome",
|
|
2148
2236
|
labelKey: "chrome",
|
|
@@ -2481,122 +2569,122 @@ const pe = [
|
|
|
2481
2569
|
0
|
|
2482
2570
|
]
|
|
2483
2571
|
}
|
|
2484
|
-
],
|
|
2572
|
+
], Dn = { class: "vie-filter-controls" }, Ln = { class: "vie-filter-strip" }, Kn = { class: "vie-filter-thumb__label" }, Hn = ["onClick"], Vn = { class: "vie-filter-thumb__label" }, Bn = /* @__PURE__ */ J({
|
|
2485
2573
|
__name: "FilterControls",
|
|
2486
|
-
setup(
|
|
2487
|
-
const e =
|
|
2488
|
-
let
|
|
2489
|
-
function
|
|
2490
|
-
|
|
2491
|
-
}
|
|
2492
|
-
function i(
|
|
2493
|
-
e.updateState((
|
|
2494
|
-
|
|
2574
|
+
setup(o) {
|
|
2575
|
+
const e = ee(), n = ie(oe, (x) => x), t = H(null), a = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Set();
|
|
2576
|
+
let r = null;
|
|
2577
|
+
function s(x, _) {
|
|
2578
|
+
_ && (a.set(x, _), r == null || r.observe(_));
|
|
2579
|
+
}
|
|
2580
|
+
function i(x) {
|
|
2581
|
+
e.updateState((_) => {
|
|
2582
|
+
x ? (_.filter.id = x.id, _.filter.matrix = [...x.matrix]) : (_.filter.id = null, _.filter.matrix = void 0);
|
|
2495
2583
|
});
|
|
2496
2584
|
}
|
|
2497
|
-
function
|
|
2498
|
-
e.updateState((
|
|
2499
|
-
|
|
2585
|
+
function v(x) {
|
|
2586
|
+
e.updateState((_) => {
|
|
2587
|
+
_.filter.intensity = x;
|
|
2500
2588
|
});
|
|
2501
2589
|
}
|
|
2502
|
-
function
|
|
2590
|
+
function l(x, _) {
|
|
2503
2591
|
const $ = e.sourceImage.value;
|
|
2504
2592
|
if (!$) return;
|
|
2505
|
-
const
|
|
2506
|
-
|
|
2507
|
-
const
|
|
2508
|
-
|
|
2593
|
+
const w = 96, u = x.getContext("2d");
|
|
2594
|
+
u.drawImage($, 0, 0, w, w);
|
|
2595
|
+
const g = u.getImageData(0, 0, w, w);
|
|
2596
|
+
Ae(g, _.matrix), u.putImageData(g, 0, 0), h.add(_.id);
|
|
2509
2597
|
}
|
|
2510
2598
|
function c() {
|
|
2511
|
-
const
|
|
2512
|
-
if (!
|
|
2513
|
-
t.value.getContext("2d").drawImage(
|
|
2514
|
-
}
|
|
2515
|
-
function
|
|
2516
|
-
|
|
2517
|
-
for (const
|
|
2518
|
-
if (!
|
|
2519
|
-
const $ =
|
|
2520
|
-
|
|
2599
|
+
const x = e.sourceImage.value;
|
|
2600
|
+
if (!x || !t.value) return;
|
|
2601
|
+
t.value.getContext("2d").drawImage(x, 0, 0, 96, 96);
|
|
2602
|
+
}
|
|
2603
|
+
function m() {
|
|
2604
|
+
r = new IntersectionObserver((x) => {
|
|
2605
|
+
for (const _ of x) {
|
|
2606
|
+
if (!_.isIntersecting) continue;
|
|
2607
|
+
const $ = _.target, w = be.find((u) => a.get(u.id) === $);
|
|
2608
|
+
w && !h.has(w.id) && l($, w);
|
|
2521
2609
|
}
|
|
2522
2610
|
}, { threshold: 0.1 });
|
|
2523
|
-
for (const
|
|
2524
|
-
|
|
2525
|
-
}
|
|
2526
|
-
function
|
|
2527
|
-
|
|
2528
|
-
for (const
|
|
2529
|
-
const
|
|
2530
|
-
|
|
2611
|
+
for (const x of a.values())
|
|
2612
|
+
r.observe(x);
|
|
2613
|
+
}
|
|
2614
|
+
function d() {
|
|
2615
|
+
h.clear(), c();
|
|
2616
|
+
for (const x of be) {
|
|
2617
|
+
const _ = a.get(x.id);
|
|
2618
|
+
_ && (r == null || r.unobserve(_));
|
|
2531
2619
|
}
|
|
2532
|
-
for (const
|
|
2533
|
-
|
|
2620
|
+
for (const x of a.values())
|
|
2621
|
+
r == null || r.observe(x);
|
|
2534
2622
|
}
|
|
2535
|
-
return
|
|
2536
|
-
setTimeout(
|
|
2537
|
-
}),
|
|
2538
|
-
|
|
2623
|
+
return re(() => e.sourceImage.value, () => {
|
|
2624
|
+
setTimeout(d, 50);
|
|
2625
|
+
}), ge(() => {
|
|
2626
|
+
m(), setTimeout(() => {
|
|
2539
2627
|
c();
|
|
2540
2628
|
}, 50);
|
|
2541
|
-
}),
|
|
2542
|
-
|
|
2543
|
-
}), (
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
class:
|
|
2547
|
-
onClick:
|
|
2629
|
+
}), pt(() => {
|
|
2630
|
+
r == null || r.disconnect(), r = null;
|
|
2631
|
+
}), (x, _) => (S(), z("div", Dn, [
|
|
2632
|
+
y("div", Ln, [
|
|
2633
|
+
y("button", {
|
|
2634
|
+
class: N(["vie-filter-thumb", { "vie-filter-thumb--active": !I(e).state.filter.id }]),
|
|
2635
|
+
onClick: _[0] || (_[0] = ($) => i(null))
|
|
2548
2636
|
}, [
|
|
2549
|
-
|
|
2637
|
+
y("canvas", {
|
|
2550
2638
|
ref_key: "originalThumbRef",
|
|
2551
2639
|
ref: t,
|
|
2552
2640
|
width: "96",
|
|
2553
2641
|
height: "96",
|
|
2554
2642
|
class: "vie-filter-thumb__canvas"
|
|
2555
2643
|
}, null, 512),
|
|
2556
|
-
|
|
2644
|
+
y("span", Kn, q(I(n)("original")), 1)
|
|
2557
2645
|
], 2),
|
|
2558
|
-
(
|
|
2646
|
+
(S(!0), z(Y, null, Z(I(be), ($) => (S(), z("button", {
|
|
2559
2647
|
key: $.id,
|
|
2560
|
-
class:
|
|
2561
|
-
onClick: (
|
|
2648
|
+
class: N(["vie-filter-thumb", { "vie-filter-thumb--active": I(e).state.filter.id === $.id }]),
|
|
2649
|
+
onClick: (w) => i($)
|
|
2562
2650
|
}, [
|
|
2563
|
-
|
|
2651
|
+
y("canvas", {
|
|
2564
2652
|
ref_for: !0,
|
|
2565
|
-
ref: (
|
|
2653
|
+
ref: (w) => s($.id, w),
|
|
2566
2654
|
width: "96",
|
|
2567
2655
|
height: "96",
|
|
2568
2656
|
class: "vie-filter-thumb__canvas"
|
|
2569
2657
|
}, null, 512),
|
|
2570
|
-
|
|
2571
|
-
], 10,
|
|
2658
|
+
y("span", Vn, q(I(n)($.labelKey) || $.labelKey), 1)
|
|
2659
|
+
], 10, Hn))), 128))
|
|
2572
2660
|
]),
|
|
2573
|
-
|
|
2661
|
+
I(e).state.filter.id ? (S(), pe(fe, {
|
|
2574
2662
|
key: 0,
|
|
2575
|
-
modelValue:
|
|
2663
|
+
modelValue: I(e).state.filter.intensity,
|
|
2576
2664
|
min: 0,
|
|
2577
2665
|
max: 1,
|
|
2578
2666
|
step: 0.01,
|
|
2579
2667
|
base: 1,
|
|
2580
|
-
label:
|
|
2668
|
+
label: I(n)("intensity"),
|
|
2581
2669
|
format: "percent",
|
|
2582
|
-
"onUpdate:modelValue":
|
|
2583
|
-
}, null, 8, ["modelValue", "label"])) :
|
|
2670
|
+
"onUpdate:modelValue": v
|
|
2671
|
+
}, null, 8, ["modelValue", "label"])) : G("", !0)
|
|
2584
2672
|
]));
|
|
2585
2673
|
}
|
|
2586
|
-
}),
|
|
2674
|
+
}), jn = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2587
2675
|
<path d="M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z" />
|
|
2588
2676
|
<path d="M12 20a8 8 0 1 0 0-16" fill="currentColor" opacity="0.3" />
|
|
2589
2677
|
<path d="M12 4v16" />
|
|
2590
2678
|
</svg>`;
|
|
2591
|
-
function
|
|
2679
|
+
function On() {
|
|
2592
2680
|
return {
|
|
2593
2681
|
id: "filter",
|
|
2594
|
-
icon:
|
|
2682
|
+
icon: jn,
|
|
2595
2683
|
labelKey: "filter",
|
|
2596
|
-
controls:
|
|
2684
|
+
controls: Bn
|
|
2597
2685
|
};
|
|
2598
2686
|
}
|
|
2599
|
-
const
|
|
2687
|
+
const xe = [
|
|
2600
2688
|
{
|
|
2601
2689
|
id: "emoji",
|
|
2602
2690
|
labelKey: "emoji",
|
|
@@ -2649,25 +2737,25 @@ const fe = [
|
|
|
2649
2737
|
"♦️"
|
|
2650
2738
|
]
|
|
2651
2739
|
}
|
|
2652
|
-
],
|
|
2653
|
-
function
|
|
2654
|
-
let e =
|
|
2655
|
-
return e || (e = H(null),
|
|
2740
|
+
], Be = /* @__PURE__ */ new WeakMap();
|
|
2741
|
+
function ot(o) {
|
|
2742
|
+
let e = Be.get(o);
|
|
2743
|
+
return e || (e = H(null), Be.set(o, e)), e;
|
|
2656
2744
|
}
|
|
2657
|
-
const
|
|
2745
|
+
const Xn = { class: "vie-sticker-controls" }, qn = { class: "vie-sticker-tabs" }, Yn = ["onClick"], Un = { class: "vie-sticker-grid" }, Nn = ["onClick"], Zn = /* @__PURE__ */ J({
|
|
2658
2746
|
__name: "StickerControls",
|
|
2659
|
-
setup(
|
|
2747
|
+
setup(o) {
|
|
2660
2748
|
var i;
|
|
2661
|
-
const e =
|
|
2662
|
-
const
|
|
2663
|
-
return (
|
|
2749
|
+
const e = ee(), n = ie(oe, (v) => v), t = ot(e.state), a = H(((i = xe[0]) == null ? void 0 : i.id) || "emoji"), h = j(() => {
|
|
2750
|
+
const v = xe.find((l) => l.id === a.value);
|
|
2751
|
+
return (v == null ? void 0 : v.stickers) || [];
|
|
2664
2752
|
});
|
|
2665
|
-
function
|
|
2666
|
-
const
|
|
2667
|
-
e.updateState((
|
|
2668
|
-
|
|
2669
|
-
id:
|
|
2670
|
-
src:
|
|
2753
|
+
function r(v) {
|
|
2754
|
+
const l = `sticker-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`, c = e.state.stickers.length % 5 * 0.03;
|
|
2755
|
+
e.updateState((m) => {
|
|
2756
|
+
m.stickers.push({
|
|
2757
|
+
id: l,
|
|
2758
|
+
src: v,
|
|
2671
2759
|
x: 0.35 + c,
|
|
2672
2760
|
y: 0.35 + c,
|
|
2673
2761
|
width: 0.15,
|
|
@@ -2677,230 +2765,230 @@ const Cn = { class: "vie-sticker-controls" }, Mn = { class: "vie-sticker-tabs" }
|
|
|
2677
2765
|
flipY: !1,
|
|
2678
2766
|
opacity: 1
|
|
2679
2767
|
});
|
|
2680
|
-
}), t.value =
|
|
2768
|
+
}), t.value = l;
|
|
2681
2769
|
}
|
|
2682
|
-
function
|
|
2770
|
+
function s() {
|
|
2683
2771
|
if (!t.value) return;
|
|
2684
|
-
const
|
|
2685
|
-
e.updateState((
|
|
2686
|
-
const c =
|
|
2687
|
-
c >= 0 &&
|
|
2772
|
+
const v = t.value;
|
|
2773
|
+
e.updateState((l) => {
|
|
2774
|
+
const c = l.stickers.findIndex((m) => m.id === v);
|
|
2775
|
+
c >= 0 && l.stickers.splice(c, 1);
|
|
2688
2776
|
}), t.value = null;
|
|
2689
2777
|
}
|
|
2690
|
-
return (
|
|
2691
|
-
|
|
2692
|
-
(
|
|
2778
|
+
return (v, l) => (S(), z("div", Xn, [
|
|
2779
|
+
y("div", qn, [
|
|
2780
|
+
(S(!0), z(Y, null, Z(I(xe), (c) => (S(), z("button", {
|
|
2693
2781
|
key: c.id,
|
|
2694
|
-
class:
|
|
2695
|
-
onClick: (
|
|
2696
|
-
}, q(
|
|
2697
|
-
|
|
2782
|
+
class: N(["vie-sticker-tab", { "vie-sticker-tab--active": a.value === c.id }]),
|
|
2783
|
+
onClick: (m) => a.value = c.id
|
|
2784
|
+
}, q(I(n)(c.labelKey) || c.labelKey), 11, Yn))), 128)),
|
|
2785
|
+
I(t) ? (S(), z("button", {
|
|
2698
2786
|
key: 0,
|
|
2699
2787
|
class: "vie-sticker-tab vie-sticker-tab--delete",
|
|
2700
|
-
onClick:
|
|
2701
|
-
}, q(
|
|
2788
|
+
onClick: s
|
|
2789
|
+
}, q(I(n)("delete") || "Delete"), 1)) : G("", !0)
|
|
2702
2790
|
]),
|
|
2703
|
-
|
|
2704
|
-
(
|
|
2791
|
+
y("div", Un, [
|
|
2792
|
+
(S(!0), z(Y, null, Z(h.value, (c) => (S(), z("button", {
|
|
2705
2793
|
key: c,
|
|
2706
2794
|
class: "vie-sticker-item",
|
|
2707
|
-
onClick: (
|
|
2708
|
-
}, q(c), 9,
|
|
2795
|
+
onClick: (m) => r(c)
|
|
2796
|
+
}, q(c), 9, Nn))), 128))
|
|
2709
2797
|
])
|
|
2710
2798
|
]));
|
|
2711
2799
|
}
|
|
2712
|
-
}),
|
|
2800
|
+
}), Jn = ["viewBox", "width", "height"], Gn = ["x", "y", "width", "height", "data-sticker-id"], Qn = ["x", "y", "width", "height"], ei = ["x", "y", "data-handle"], ti = ["x1", "y1", "x2", "y2"], ni = ["cx", "cy"], _e = 10, je = 20, Oe = 6, ii = /* @__PURE__ */ J({
|
|
2713
2801
|
__name: "StickerOverlay",
|
|
2714
2802
|
props: {
|
|
2715
2803
|
canvasRect: {},
|
|
2716
2804
|
wrapperSize: {}
|
|
2717
2805
|
},
|
|
2718
|
-
setup(
|
|
2719
|
-
const e =
|
|
2720
|
-
|
|
2806
|
+
setup(o) {
|
|
2807
|
+
const e = o, n = ee(), t = H(null), a = ot(n.state);
|
|
2808
|
+
he(() => {
|
|
2721
2809
|
i.value && (n.updateState(() => {
|
|
2722
|
-
}), i.value = null,
|
|
2810
|
+
}), i.value = null, v.value = null), window.removeEventListener("pointermove", x), window.removeEventListener("pointerup", _);
|
|
2723
2811
|
});
|
|
2724
|
-
const
|
|
2725
|
-
const
|
|
2726
|
-
return n.state.stickers.map((
|
|
2727
|
-
id:
|
|
2728
|
-
x:
|
|
2729
|
-
y:
|
|
2730
|
-
w:
|
|
2731
|
-
h:
|
|
2812
|
+
const h = j(() => {
|
|
2813
|
+
const u = e.canvasRect;
|
|
2814
|
+
return n.state.stickers.map((g) => ({
|
|
2815
|
+
id: g.id,
|
|
2816
|
+
x: u.x + g.x * u.width,
|
|
2817
|
+
y: u.y + g.y * u.height,
|
|
2818
|
+
w: g.width * u.width,
|
|
2819
|
+
h: g.height * u.height
|
|
2732
2820
|
}));
|
|
2733
|
-
}),
|
|
2734
|
-
if (!
|
|
2735
|
-
const
|
|
2821
|
+
}), r = j(() => a.value && h.value.find((u) => u.id === a.value) || null), s = j(() => {
|
|
2822
|
+
if (!r.value) return [];
|
|
2823
|
+
const u = r.value, k = _e / 2;
|
|
2736
2824
|
return [
|
|
2737
|
-
{ id: "nw", x:
|
|
2738
|
-
{ id: "ne", x:
|
|
2739
|
-
{ id: "sw", x:
|
|
2740
|
-
{ id: "se", x:
|
|
2825
|
+
{ id: "nw", x: u.x - k, y: u.y - k },
|
|
2826
|
+
{ id: "ne", x: u.x + u.w - k, y: u.y - k },
|
|
2827
|
+
{ id: "sw", x: u.x - k, y: u.y + u.h - k },
|
|
2828
|
+
{ id: "se", x: u.x + u.w - k, y: u.y + u.h - k }
|
|
2741
2829
|
];
|
|
2742
|
-
}), i = H(null),
|
|
2743
|
-
function
|
|
2744
|
-
var
|
|
2745
|
-
const
|
|
2746
|
-
if (
|
|
2747
|
-
|
|
2830
|
+
}), i = H(null), v = H(null), l = H({ x: 0, y: 0 }), c = H({ x: 0, y: 0, width: 0, height: 0, rotation: 0 });
|
|
2831
|
+
function m(u) {
|
|
2832
|
+
var P;
|
|
2833
|
+
const g = u.target, k = g.getAttribute("data-handle");
|
|
2834
|
+
if (k === "rotate" && a.value) {
|
|
2835
|
+
u.preventDefault(), d(u, "rotate", k);
|
|
2748
2836
|
return;
|
|
2749
2837
|
}
|
|
2750
|
-
if (
|
|
2751
|
-
|
|
2838
|
+
if (k && ["nw", "ne", "sw", "se"].includes(k) && a.value) {
|
|
2839
|
+
u.preventDefault(), d(u, "resize", k);
|
|
2752
2840
|
return;
|
|
2753
2841
|
}
|
|
2754
|
-
const
|
|
2755
|
-
if (
|
|
2756
|
-
|
|
2842
|
+
const C = g.getAttribute("data-sticker-id");
|
|
2843
|
+
if (C) {
|
|
2844
|
+
u.preventDefault(), a.value = C, d(u, "move", null), (P = t.value) == null || P.focus();
|
|
2757
2845
|
return;
|
|
2758
2846
|
}
|
|
2759
|
-
|
|
2760
|
-
}
|
|
2761
|
-
function
|
|
2762
|
-
i.value =
|
|
2763
|
-
const
|
|
2764
|
-
|
|
2765
|
-
x:
|
|
2766
|
-
y:
|
|
2767
|
-
width:
|
|
2768
|
-
height:
|
|
2769
|
-
rotation:
|
|
2770
|
-
}), window.addEventListener("pointermove",
|
|
2771
|
-
}
|
|
2772
|
-
function
|
|
2773
|
-
if (!i.value || !
|
|
2774
|
-
const
|
|
2775
|
-
if (
|
|
2776
|
-
const
|
|
2777
|
-
if (
|
|
2847
|
+
a.value = null;
|
|
2848
|
+
}
|
|
2849
|
+
function d(u, g, k) {
|
|
2850
|
+
i.value = g, v.value = k, l.value = { x: u.clientX, y: u.clientY };
|
|
2851
|
+
const C = n.state.stickers.find((P) => P.id === a.value);
|
|
2852
|
+
C && (c.value = {
|
|
2853
|
+
x: C.x,
|
|
2854
|
+
y: C.y,
|
|
2855
|
+
width: C.width,
|
|
2856
|
+
height: C.height,
|
|
2857
|
+
rotation: C.rotation
|
|
2858
|
+
}), window.addEventListener("pointermove", x), window.addEventListener("pointerup", _);
|
|
2859
|
+
}
|
|
2860
|
+
function x(u) {
|
|
2861
|
+
if (!i.value || !a.value) return;
|
|
2862
|
+
const g = e.canvasRect;
|
|
2863
|
+
if (g.width === 0 || g.height === 0) return;
|
|
2864
|
+
const k = (u.clientX - l.value.x) / g.width, C = (u.clientY - l.value.y) / g.height, P = c.value, V = n.state.stickers.find((A) => A.id === a.value);
|
|
2865
|
+
if (V) {
|
|
2778
2866
|
switch (i.value) {
|
|
2779
2867
|
case "move": {
|
|
2780
|
-
|
|
2868
|
+
V.x = w(P.x + k, 0, 1 - V.width), V.y = w(P.y + C, 0, 1 - V.height);
|
|
2781
2869
|
break;
|
|
2782
2870
|
}
|
|
2783
2871
|
case "resize": {
|
|
2784
|
-
switch (
|
|
2872
|
+
switch (v.value) {
|
|
2785
2873
|
case "se": {
|
|
2786
|
-
|
|
2874
|
+
V.width = w(P.width + k, 0.03, 1 - P.x), V.height = w(P.height + C, 0.03, 1 - P.y);
|
|
2787
2875
|
break;
|
|
2788
2876
|
}
|
|
2789
2877
|
case "ne": {
|
|
2790
|
-
const
|
|
2791
|
-
|
|
2878
|
+
const D = w(P.width + k, 0.03, 1 - P.x), K = w(P.height - C, 0.03, P.y + P.height), L = P.y + P.height - K;
|
|
2879
|
+
V.width = D, V.height = K, V.y = L;
|
|
2792
2880
|
break;
|
|
2793
2881
|
}
|
|
2794
2882
|
case "sw": {
|
|
2795
|
-
const
|
|
2796
|
-
|
|
2883
|
+
const D = w(P.width - k, 0.03, P.x + P.width), K = w(P.height + C, 0.03, 1 - P.y), L = P.x + P.width - D;
|
|
2884
|
+
V.width = D, V.height = K, V.x = L;
|
|
2797
2885
|
break;
|
|
2798
2886
|
}
|
|
2799
2887
|
case "nw": {
|
|
2800
|
-
const
|
|
2801
|
-
|
|
2888
|
+
const D = w(P.width - k, 0.03, P.x + P.width), K = w(P.height - C, 0.03, P.y + P.height), L = P.x + P.width - D, E = P.y + P.height - K;
|
|
2889
|
+
V.width = D, V.height = K, V.x = L, V.y = E;
|
|
2802
2890
|
break;
|
|
2803
2891
|
}
|
|
2804
2892
|
}
|
|
2805
2893
|
break;
|
|
2806
2894
|
}
|
|
2807
2895
|
case "rotate": {
|
|
2808
|
-
const
|
|
2809
|
-
|
|
2896
|
+
const A = g.x + V.x * g.width + V.width * g.width / 2, D = g.y + V.y * g.height + V.height * g.height / 2, K = Math.atan2(u.clientX - A, -(u.clientY - D));
|
|
2897
|
+
V.rotation = K;
|
|
2810
2898
|
break;
|
|
2811
2899
|
}
|
|
2812
2900
|
}
|
|
2813
2901
|
n.requestRender();
|
|
2814
2902
|
}
|
|
2815
2903
|
}
|
|
2816
|
-
function
|
|
2904
|
+
function _() {
|
|
2817
2905
|
i.value && n.updateState(() => {
|
|
2818
|
-
}), i.value = null,
|
|
2819
|
-
}
|
|
2820
|
-
function $(
|
|
2821
|
-
if ((
|
|
2822
|
-
|
|
2823
|
-
const
|
|
2824
|
-
n.updateState((
|
|
2825
|
-
const
|
|
2826
|
-
|
|
2827
|
-
}),
|
|
2906
|
+
}), i.value = null, v.value = null, window.removeEventListener("pointermove", x), window.removeEventListener("pointerup", _);
|
|
2907
|
+
}
|
|
2908
|
+
function $(u) {
|
|
2909
|
+
if ((u.key === "Delete" || u.key === "Backspace") && a.value) {
|
|
2910
|
+
u.preventDefault();
|
|
2911
|
+
const g = a.value;
|
|
2912
|
+
n.updateState((k) => {
|
|
2913
|
+
const C = k.stickers.findIndex((P) => P.id === g);
|
|
2914
|
+
C >= 0 && k.stickers.splice(C, 1);
|
|
2915
|
+
}), a.value = null;
|
|
2828
2916
|
}
|
|
2829
2917
|
}
|
|
2830
|
-
function
|
|
2831
|
-
return Math.max(
|
|
2918
|
+
function w(u, g, k) {
|
|
2919
|
+
return Math.max(g, Math.min(k, u));
|
|
2832
2920
|
}
|
|
2833
|
-
return (
|
|
2921
|
+
return (u, g) => (S(), z("svg", {
|
|
2834
2922
|
ref_key: "svgRef",
|
|
2835
2923
|
ref: t,
|
|
2836
2924
|
class: "vie-sticker-overlay",
|
|
2837
|
-
viewBox: `0 0 ${
|
|
2838
|
-
width:
|
|
2839
|
-
height:
|
|
2840
|
-
onPointerdown:
|
|
2925
|
+
viewBox: `0 0 ${o.wrapperSize.width} ${o.wrapperSize.height}`,
|
|
2926
|
+
width: o.wrapperSize.width,
|
|
2927
|
+
height: o.wrapperSize.height,
|
|
2928
|
+
onPointerdown: m,
|
|
2841
2929
|
onKeydown: $,
|
|
2842
2930
|
tabindex: "0"
|
|
2843
2931
|
}, [
|
|
2844
|
-
(
|
|
2845
|
-
key:
|
|
2846
|
-
x:
|
|
2847
|
-
y:
|
|
2848
|
-
width:
|
|
2849
|
-
height:
|
|
2932
|
+
(S(!0), z(Y, null, Z(h.value, (k) => (S(), z("rect", {
|
|
2933
|
+
key: k.id,
|
|
2934
|
+
x: k.x,
|
|
2935
|
+
y: k.y,
|
|
2936
|
+
width: k.w,
|
|
2937
|
+
height: k.h,
|
|
2850
2938
|
fill: "transparent",
|
|
2851
2939
|
class: "vie-sticker-hitarea",
|
|
2852
|
-
"data-sticker-id":
|
|
2853
|
-
}, null, 8,
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
x:
|
|
2857
|
-
y:
|
|
2858
|
-
width:
|
|
2859
|
-
height:
|
|
2940
|
+
"data-sticker-id": k.id
|
|
2941
|
+
}, null, 8, Gn))), 128)),
|
|
2942
|
+
r.value ? (S(), z(Y, { key: 0 }, [
|
|
2943
|
+
y("rect", {
|
|
2944
|
+
x: r.value.x,
|
|
2945
|
+
y: r.value.y,
|
|
2946
|
+
width: r.value.w,
|
|
2947
|
+
height: r.value.h,
|
|
2860
2948
|
class: "vie-sticker-selection"
|
|
2861
|
-
}, null, 8,
|
|
2862
|
-
(
|
|
2863
|
-
key:
|
|
2864
|
-
x:
|
|
2865
|
-
y:
|
|
2866
|
-
width:
|
|
2867
|
-
height:
|
|
2949
|
+
}, null, 8, Qn),
|
|
2950
|
+
(S(!0), z(Y, null, Z(s.value, (k) => (S(), z("rect", {
|
|
2951
|
+
key: k.id,
|
|
2952
|
+
x: k.x,
|
|
2953
|
+
y: k.y,
|
|
2954
|
+
width: _e,
|
|
2955
|
+
height: _e,
|
|
2868
2956
|
class: "vie-sticker-handle",
|
|
2869
|
-
"data-handle":
|
|
2870
|
-
}, null, 8,
|
|
2871
|
-
|
|
2872
|
-
x1:
|
|
2873
|
-
y1:
|
|
2874
|
-
x2:
|
|
2875
|
-
y2:
|
|
2957
|
+
"data-handle": k.id
|
|
2958
|
+
}, null, 8, ei))), 128)),
|
|
2959
|
+
y("line", {
|
|
2960
|
+
x1: r.value.x + r.value.w / 2,
|
|
2961
|
+
y1: r.value.y - je,
|
|
2962
|
+
x2: r.value.x + r.value.w / 2,
|
|
2963
|
+
y2: r.value.y,
|
|
2876
2964
|
class: "vie-sticker-rotate-line"
|
|
2877
|
-
}, null, 8,
|
|
2878
|
-
|
|
2879
|
-
cx:
|
|
2880
|
-
cy:
|
|
2881
|
-
r:
|
|
2965
|
+
}, null, 8, ti),
|
|
2966
|
+
y("circle", {
|
|
2967
|
+
cx: r.value.x + r.value.w / 2,
|
|
2968
|
+
cy: r.value.y - je - Oe,
|
|
2969
|
+
r: Oe,
|
|
2882
2970
|
class: "vie-sticker-rotate-handle",
|
|
2883
2971
|
"data-handle": "rotate"
|
|
2884
|
-
}, null, 8,
|
|
2885
|
-
], 64)) :
|
|
2886
|
-
], 40,
|
|
2972
|
+
}, null, 8, ni)
|
|
2973
|
+
], 64)) : G("", !0)
|
|
2974
|
+
], 40, Jn));
|
|
2887
2975
|
}
|
|
2888
|
-
}),
|
|
2976
|
+
}), oi = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2889
2977
|
<circle cx="12" cy="12" r="10" />
|
|
2890
2978
|
<path d="M8 14s1.5 2 4 2 4-2 4-2" />
|
|
2891
2979
|
<line x1="9" y1="9" x2="9.01" y2="9" />
|
|
2892
2980
|
<line x1="15" y1="9" x2="15.01" y2="9" />
|
|
2893
2981
|
</svg>`;
|
|
2894
|
-
function
|
|
2982
|
+
function ai() {
|
|
2895
2983
|
return {
|
|
2896
2984
|
id: "sticker",
|
|
2897
|
-
icon:
|
|
2985
|
+
icon: oi,
|
|
2898
2986
|
labelKey: "sticker",
|
|
2899
|
-
controls:
|
|
2900
|
-
overlay:
|
|
2987
|
+
controls: Zn,
|
|
2988
|
+
overlay: ii
|
|
2901
2989
|
};
|
|
2902
2990
|
}
|
|
2903
|
-
const
|
|
2991
|
+
const si = [
|
|
2904
2992
|
{ id: "solidSharp", labelKey: "solidSharp" },
|
|
2905
2993
|
{ id: "solidRound", labelKey: "solidRound" },
|
|
2906
2994
|
{ id: "lineSingle", labelKey: "lineSingle" },
|
|
@@ -2910,7 +2998,7 @@ const Fn = [
|
|
|
2910
2998
|
{ id: "edgeSeparate", labelKey: "edgeSeparate" },
|
|
2911
2999
|
{ id: "edgeCross", labelKey: "edgeCross" },
|
|
2912
3000
|
{ id: "edgeOverlap", labelKey: "edgeOverlap" }
|
|
2913
|
-
],
|
|
3001
|
+
], li = [
|
|
2914
3002
|
[1, 1, 1, 1],
|
|
2915
3003
|
// White
|
|
2916
3004
|
[0, 0, 0, 1],
|
|
@@ -2923,89 +3011,89 @@ const Fn = [
|
|
|
2923
3011
|
// Navy
|
|
2924
3012
|
[0.8, 0.2, 0.2, 1]
|
|
2925
3013
|
// Red
|
|
2926
|
-
],
|
|
3014
|
+
], ri = { class: "vie-frame-controls" }, ci = { class: "vie-frame-strip" }, ui = { class: "vie-frame-style__label" }, di = ["onClick"], hi = { class: "vie-frame-style__label" }, vi = { class: "vie-frame-colors" }, fi = { class: "vie-frame-colors__label" }, pi = { class: "vie-frame-colors__swatches" }, mi = ["onClick"], gi = /* @__PURE__ */ J({
|
|
2927
3015
|
__name: "FrameControls",
|
|
2928
|
-
setup(
|
|
2929
|
-
const e =
|
|
3016
|
+
setup(o) {
|
|
3017
|
+
const e = ee(), n = ie(oe, (i) => i);
|
|
2930
3018
|
function t(i) {
|
|
2931
|
-
e.updateState((
|
|
2932
|
-
|
|
3019
|
+
e.updateState((v) => {
|
|
3020
|
+
v.frame.style = i;
|
|
2933
3021
|
});
|
|
2934
3022
|
}
|
|
2935
|
-
function
|
|
2936
|
-
e.updateState((
|
|
2937
|
-
|
|
3023
|
+
function a(i) {
|
|
3024
|
+
e.updateState((v) => {
|
|
3025
|
+
v.frame.size = i;
|
|
2938
3026
|
});
|
|
2939
3027
|
}
|
|
2940
|
-
function
|
|
2941
|
-
e.updateState((
|
|
2942
|
-
|
|
3028
|
+
function h(i) {
|
|
3029
|
+
e.updateState((v) => {
|
|
3030
|
+
v.frame.color = [...i];
|
|
2943
3031
|
});
|
|
2944
3032
|
}
|
|
2945
|
-
function u(i) {
|
|
2946
|
-
const h = e.state.frame.color;
|
|
2947
|
-
return h[0] === i[0] && h[1] === i[1] && h[2] === i[2] && h[3] === i[3];
|
|
2948
|
-
}
|
|
2949
3033
|
function r(i) {
|
|
3034
|
+
const v = e.state.frame.color;
|
|
3035
|
+
return v[0] === i[0] && v[1] === i[1] && v[2] === i[2] && v[3] === i[3];
|
|
3036
|
+
}
|
|
3037
|
+
function s(i) {
|
|
2950
3038
|
return `rgba(${Math.round(i[0] * 255)}, ${Math.round(i[1] * 255)}, ${Math.round(i[2] * 255)}, ${i[3]})`;
|
|
2951
3039
|
}
|
|
2952
|
-
return (i,
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
class:
|
|
2956
|
-
onClick:
|
|
3040
|
+
return (i, v) => (S(), z("div", ri, [
|
|
3041
|
+
y("div", ci, [
|
|
3042
|
+
y("button", {
|
|
3043
|
+
class: N(["vie-frame-style", { "vie-frame-style--active": !I(e).state.frame.style }]),
|
|
3044
|
+
onClick: v[0] || (v[0] = (l) => t(null))
|
|
2957
3045
|
}, [
|
|
2958
|
-
|
|
3046
|
+
y("span", ui, q(I(n)("none")), 1)
|
|
2959
3047
|
], 2),
|
|
2960
|
-
(
|
|
2961
|
-
key:
|
|
2962
|
-
class:
|
|
2963
|
-
onClick: (c) => t(
|
|
3048
|
+
(S(!0), z(Y, null, Z(I(si), (l) => (S(), z("button", {
|
|
3049
|
+
key: l.id,
|
|
3050
|
+
class: N(["vie-frame-style", { "vie-frame-style--active": I(e).state.frame.style === l.id }]),
|
|
3051
|
+
onClick: (c) => t(l.id)
|
|
2964
3052
|
}, [
|
|
2965
|
-
|
|
2966
|
-
], 10,
|
|
3053
|
+
y("span", hi, q(I(n)(l.labelKey)), 1)
|
|
3054
|
+
], 10, di))), 128))
|
|
2967
3055
|
]),
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
modelValue:
|
|
3056
|
+
I(e).state.frame.style ? (S(), z(Y, { key: 0 }, [
|
|
3057
|
+
X(fe, {
|
|
3058
|
+
modelValue: I(e).state.frame.size,
|
|
2971
3059
|
min: 5e-3,
|
|
2972
3060
|
max: 0.15,
|
|
2973
3061
|
step: 5e-3,
|
|
2974
3062
|
base: 0.025,
|
|
2975
|
-
label:
|
|
3063
|
+
label: I(n)("frameSize"),
|
|
2976
3064
|
format: "percent",
|
|
2977
|
-
"onUpdate:modelValue":
|
|
3065
|
+
"onUpdate:modelValue": a
|
|
2978
3066
|
}, null, 8, ["modelValue", "label"]),
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
(
|
|
3067
|
+
y("div", vi, [
|
|
3068
|
+
y("span", fi, q(I(n)("frameColor")), 1),
|
|
3069
|
+
y("div", pi, [
|
|
3070
|
+
(S(!0), z(Y, null, Z(I(li), (l, c) => (S(), z("button", {
|
|
2983
3071
|
key: c,
|
|
2984
|
-
class:
|
|
2985
|
-
style:
|
|
2986
|
-
onClick: (
|
|
2987
|
-
}, null, 14,
|
|
3072
|
+
class: N(["vie-frame-color-swatch", { "vie-frame-color-swatch--active": r(l) }]),
|
|
3073
|
+
style: le({ backgroundColor: s(l) }),
|
|
3074
|
+
onClick: (m) => h(l)
|
|
3075
|
+
}, null, 14, mi))), 128))
|
|
2988
3076
|
])
|
|
2989
3077
|
])
|
|
2990
|
-
], 64)) :
|
|
3078
|
+
], 64)) : G("", !0)
|
|
2991
3079
|
]));
|
|
2992
3080
|
}
|
|
2993
|
-
}),
|
|
3081
|
+
}), yi = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2994
3082
|
<rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
|
|
2995
3083
|
<rect x="7" y="7" width="10" height="10" />
|
|
2996
3084
|
</svg>`;
|
|
2997
|
-
function
|
|
3085
|
+
function wi() {
|
|
2998
3086
|
return {
|
|
2999
3087
|
id: "frame",
|
|
3000
|
-
icon:
|
|
3088
|
+
icon: yi,
|
|
3001
3089
|
labelKey: "frame",
|
|
3002
|
-
controls:
|
|
3090
|
+
controls: gi
|
|
3003
3091
|
};
|
|
3004
3092
|
}
|
|
3005
|
-
const
|
|
3093
|
+
const ki = { class: "vie-fill-controls" }, bi = { class: "vie-fill-strip" }, xi = ["title", "onClick"], _i = /* @__PURE__ */ J({
|
|
3006
3094
|
__name: "FillControls",
|
|
3007
|
-
setup(
|
|
3008
|
-
const e =
|
|
3095
|
+
setup(o) {
|
|
3096
|
+
const e = ee(), n = ie(oe, (s) => s), t = [
|
|
3009
3097
|
[0, 0, 0, 0],
|
|
3010
3098
|
// Transparent
|
|
3011
3099
|
[1, 1, 1, 1],
|
|
@@ -3041,109 +3129,109 @@ const Qn = { class: "vie-fill-controls" }, ei = { class: "vie-fill-strip" }, ti
|
|
|
3041
3129
|
[0.61, 0.15, 0.69, 1]
|
|
3042
3130
|
// Purple
|
|
3043
3131
|
];
|
|
3044
|
-
function
|
|
3132
|
+
function a(s) {
|
|
3045
3133
|
e.updateState((i) => {
|
|
3046
|
-
i.backgroundColor = [...
|
|
3134
|
+
i.backgroundColor = [...s];
|
|
3047
3135
|
});
|
|
3048
3136
|
}
|
|
3049
|
-
function
|
|
3137
|
+
function h(s) {
|
|
3050
3138
|
const i = e.state.backgroundColor;
|
|
3051
|
-
return i[0] ===
|
|
3052
|
-
}
|
|
3053
|
-
function
|
|
3054
|
-
return `rgba(${Math.round(
|
|
3055
|
-
}
|
|
3056
|
-
return (
|
|
3057
|
-
|
|
3058
|
-
(
|
|
3059
|
-
key:
|
|
3060
|
-
class:
|
|
3061
|
-
"vie-fill-swatch--active":
|
|
3062
|
-
"vie-fill-swatch--transparent":
|
|
3139
|
+
return i[0] === s[0] && i[1] === s[1] && i[2] === s[2] && i[3] === s[3];
|
|
3140
|
+
}
|
|
3141
|
+
function r(s) {
|
|
3142
|
+
return `rgba(${Math.round(s[0] * 255)}, ${Math.round(s[1] * 255)}, ${Math.round(s[2] * 255)}, ${s[3]})`;
|
|
3143
|
+
}
|
|
3144
|
+
return (s, i) => (S(), z("div", ki, [
|
|
3145
|
+
y("div", bi, [
|
|
3146
|
+
(S(), z(Y, null, Z(t, (v, l) => y("button", {
|
|
3147
|
+
key: l,
|
|
3148
|
+
class: N(["vie-fill-swatch", {
|
|
3149
|
+
"vie-fill-swatch--active": h(v),
|
|
3150
|
+
"vie-fill-swatch--transparent": v[3] === 0
|
|
3063
3151
|
}]),
|
|
3064
|
-
style:
|
|
3065
|
-
title:
|
|
3066
|
-
onClick: (c) =>
|
|
3067
|
-
}, null, 14,
|
|
3152
|
+
style: le(v[3] > 0 ? { backgroundColor: r(v) } : void 0),
|
|
3153
|
+
title: l === 0 ? I(n)("transparent") : void 0,
|
|
3154
|
+
onClick: (c) => a(v)
|
|
3155
|
+
}, null, 14, xi)), 64))
|
|
3068
3156
|
])
|
|
3069
3157
|
]));
|
|
3070
3158
|
}
|
|
3071
|
-
}),
|
|
3159
|
+
}), Ci = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
3072
3160
|
<path d="M12 2.69l5.66 5.66a8 8 0 1 1-11.31 0z" />
|
|
3073
3161
|
</svg>`;
|
|
3074
|
-
function
|
|
3162
|
+
function Mi() {
|
|
3075
3163
|
return {
|
|
3076
3164
|
id: "fill",
|
|
3077
|
-
icon:
|
|
3165
|
+
icon: Ci,
|
|
3078
3166
|
labelKey: "fill",
|
|
3079
|
-
controls:
|
|
3167
|
+
controls: _i
|
|
3080
3168
|
};
|
|
3081
3169
|
}
|
|
3082
|
-
const
|
|
3170
|
+
const Si = { class: "vie-resize-controls" }, $i = { class: "vie-resize-title" }, Ri = { class: "vie-resize-dimensions" }, zi = { class: "vie-resize-input" }, Ii = { class: "vie-resize-input__label" }, Pi = { class: "vie-resize-input__field-wrapper" }, Ti = ["value"], Ei = ["title"], Wi = {
|
|
3083
3171
|
viewBox: "0 0 24 24",
|
|
3084
3172
|
width: "16",
|
|
3085
3173
|
height: "16",
|
|
3086
3174
|
fill: "none",
|
|
3087
3175
|
stroke: "currentColor",
|
|
3088
3176
|
"stroke-width": "2"
|
|
3089
|
-
},
|
|
3177
|
+
}, Ai = {
|
|
3090
3178
|
key: 0,
|
|
3091
3179
|
d: "M7 11V7a5 5 0 0 1 10 0v4"
|
|
3092
|
-
},
|
|
3180
|
+
}, Fi = {
|
|
3093
3181
|
key: 1,
|
|
3094
3182
|
d: "M7 11V7a5 5 0 0 1 9.9-1"
|
|
3095
|
-
},
|
|
3183
|
+
}, Di = { class: "vie-resize-input" }, Li = { class: "vie-resize-input__label" }, Ki = { class: "vie-resize-input__field-wrapper" }, Hi = ["value"], Vi = { class: "vie-resize-hint" }, Bi = /* @__PURE__ */ J({
|
|
3096
3184
|
__name: "ResizeControls",
|
|
3097
|
-
setup(
|
|
3098
|
-
const e =
|
|
3099
|
-
const
|
|
3100
|
-
if (!
|
|
3101
|
-
const
|
|
3102
|
-
return
|
|
3103
|
-
}),
|
|
3185
|
+
setup(o) {
|
|
3186
|
+
const e = ee(), n = ie(oe, (v) => v), t = H(!0), a = j(() => {
|
|
3187
|
+
const v = e.sourceImage.value;
|
|
3188
|
+
if (!v) return 1;
|
|
3189
|
+
const l = e.state.crop;
|
|
3190
|
+
return v.naturalWidth * l.width / (v.naturalHeight * l.height);
|
|
3191
|
+
}), h = j(() => {
|
|
3104
3192
|
if (e.state.resize.width) return e.state.resize.width;
|
|
3105
|
-
const
|
|
3106
|
-
return
|
|
3107
|
-
}),
|
|
3193
|
+
const v = e.sourceImage.value;
|
|
3194
|
+
return v ? Math.round(v.naturalWidth * e.state.crop.width) : 0;
|
|
3195
|
+
}), r = j(() => {
|
|
3108
3196
|
if (e.state.resize.height) return e.state.resize.height;
|
|
3109
|
-
const
|
|
3110
|
-
return
|
|
3197
|
+
const v = e.sourceImage.value;
|
|
3198
|
+
return v ? Math.round(v.naturalHeight * e.state.crop.height) : 0;
|
|
3111
3199
|
});
|
|
3112
|
-
function
|
|
3113
|
-
const
|
|
3114
|
-
!
|
|
3115
|
-
c.resize.width =
|
|
3200
|
+
function s(v) {
|
|
3201
|
+
const l = parseInt(v, 10);
|
|
3202
|
+
!l || l < 1 || e.updateState((c) => {
|
|
3203
|
+
c.resize.width = l, t.value && (c.resize.height = Math.round(l / a.value));
|
|
3116
3204
|
});
|
|
3117
3205
|
}
|
|
3118
|
-
function i(
|
|
3119
|
-
const
|
|
3120
|
-
!
|
|
3121
|
-
c.resize.height =
|
|
3206
|
+
function i(v) {
|
|
3207
|
+
const l = parseInt(v, 10);
|
|
3208
|
+
!l || l < 1 || e.updateState((c) => {
|
|
3209
|
+
c.resize.height = l, t.value && (c.resize.width = Math.round(l * a.value));
|
|
3122
3210
|
});
|
|
3123
3211
|
}
|
|
3124
|
-
return (
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3212
|
+
return (v, l) => (S(), z("div", Si, [
|
|
3213
|
+
y("p", $i, q(I(n)("imageOutputSize")), 1),
|
|
3214
|
+
y("div", Ri, [
|
|
3215
|
+
y("div", zi, [
|
|
3216
|
+
y("label", Ii, q(I(n)("width")), 1),
|
|
3217
|
+
y("div", Pi, [
|
|
3218
|
+
y("input", {
|
|
3131
3219
|
type: "number",
|
|
3132
3220
|
class: "vie-resize-input__field",
|
|
3133
|
-
value:
|
|
3221
|
+
value: h.value,
|
|
3134
3222
|
min: "1",
|
|
3135
|
-
onInput:
|
|
3136
|
-
}, null, 40,
|
|
3137
|
-
|
|
3223
|
+
onInput: l[0] || (l[0] = (c) => s(c.target.value))
|
|
3224
|
+
}, null, 40, Ti),
|
|
3225
|
+
l[3] || (l[3] = y("span", { class: "vie-resize-input__unit" }, "px", -1))
|
|
3138
3226
|
])
|
|
3139
3227
|
]),
|
|
3140
|
-
|
|
3141
|
-
class:
|
|
3142
|
-
onClick:
|
|
3143
|
-
title:
|
|
3228
|
+
y("button", {
|
|
3229
|
+
class: N(["vie-resize-lock", { "vie-resize-lock--active": t.value }]),
|
|
3230
|
+
onClick: l[1] || (l[1] = (c) => t.value = !t.value),
|
|
3231
|
+
title: I(n)("lockAspectRatio")
|
|
3144
3232
|
}, [
|
|
3145
|
-
(
|
|
3146
|
-
|
|
3233
|
+
(S(), z("svg", Wi, [
|
|
3234
|
+
l[4] || (l[4] = y("rect", {
|
|
3147
3235
|
x: "3",
|
|
3148
3236
|
y: "11",
|
|
3149
3237
|
width: "18",
|
|
@@ -3151,94 +3239,589 @@ const ai = { class: "vie-resize-controls" }, si = { class: "vie-resize-title" },
|
|
|
3151
3239
|
rx: "2",
|
|
3152
3240
|
ry: "2"
|
|
3153
3241
|
}, null, -1)),
|
|
3154
|
-
t.value ? (
|
|
3242
|
+
t.value ? (S(), z("path", Ai)) : (S(), z("path", Fi))
|
|
3155
3243
|
]))
|
|
3156
|
-
], 10,
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3244
|
+
], 10, Ei),
|
|
3245
|
+
y("div", Di, [
|
|
3246
|
+
y("label", Li, q(I(n)("height")), 1),
|
|
3247
|
+
y("div", Ki, [
|
|
3248
|
+
y("input", {
|
|
3161
3249
|
type: "number",
|
|
3162
3250
|
class: "vie-resize-input__field",
|
|
3163
|
-
value:
|
|
3251
|
+
value: r.value,
|
|
3164
3252
|
min: "1",
|
|
3165
|
-
onInput:
|
|
3166
|
-
}, null, 40,
|
|
3167
|
-
|
|
3253
|
+
onInput: l[2] || (l[2] = (c) => i(c.target.value))
|
|
3254
|
+
}, null, 40, Hi),
|
|
3255
|
+
l[5] || (l[5] = y("span", { class: "vie-resize-input__unit" }, "px", -1))
|
|
3168
3256
|
])
|
|
3169
3257
|
])
|
|
3170
3258
|
]),
|
|
3171
|
-
|
|
3259
|
+
y("p", Vi, q(I(n)("resizeHint")), 1)
|
|
3172
3260
|
]));
|
|
3173
3261
|
}
|
|
3174
|
-
}),
|
|
3262
|
+
}), ji = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
3175
3263
|
<polyline points="15 3 21 3 21 9" />
|
|
3176
3264
|
<polyline points="9 21 3 21 3 15" />
|
|
3177
3265
|
<line x1="21" y1="3" x2="14" y2="10" />
|
|
3178
3266
|
<line x1="3" y1="21" x2="10" y2="14" />
|
|
3179
3267
|
</svg>`;
|
|
3180
|
-
function
|
|
3268
|
+
function Oi() {
|
|
3181
3269
|
return {
|
|
3182
3270
|
id: "resize",
|
|
3183
|
-
icon:
|
|
3271
|
+
icon: ji,
|
|
3184
3272
|
labelKey: "resize",
|
|
3185
|
-
controls:
|
|
3273
|
+
controls: Bi
|
|
3274
|
+
};
|
|
3275
|
+
}
|
|
3276
|
+
const Xe = /* @__PURE__ */ new WeakMap();
|
|
3277
|
+
function at(o) {
|
|
3278
|
+
let e = Xe.get(o);
|
|
3279
|
+
return e || (e = H(null), Xe.set(o, e)), e;
|
|
3280
|
+
}
|
|
3281
|
+
const Xi = { class: "vie-annotate-controls" }, qi = {
|
|
3282
|
+
key: 0,
|
|
3283
|
+
class: "vie-annotate-toolbar"
|
|
3284
|
+
}, Yi = ["title"], Ui = {
|
|
3285
|
+
key: 1,
|
|
3286
|
+
class: "vie-annotate-props"
|
|
3287
|
+
}, Ni = { class: "vie-annotate-prop-row" }, Zi = { class: "vie-annotate-prop-label" }, Ji = { class: "vie-annotate-color-picker" }, Gi = ["title", "onClick"], Qi = { class: "vie-annotate-prop-row" }, eo = { class: "vie-annotate-prop-label" }, to = { class: "vie-annotate-font-buttons" }, no = ["onClick"], io = { class: "vie-annotate-prop-row" }, oo = /* @__PURE__ */ J({
|
|
3288
|
+
__name: "AnnotateControls",
|
|
3289
|
+
setup(o) {
|
|
3290
|
+
const e = ee(), n = ie(oe, (c) => c), t = at(e.state), a = j(() => t.value && e.state.annotations.find((c) => c.id === t.value) || null), h = [
|
|
3291
|
+
{ label: "Black", value: [0, 0, 0, 1] },
|
|
3292
|
+
{ label: "White", value: [1, 1, 1, 1] },
|
|
3293
|
+
{ label: "Red", value: [0.9, 0.15, 0.15, 1] },
|
|
3294
|
+
{ label: "Orange", value: [0.95, 0.55, 0.1, 1] },
|
|
3295
|
+
{ label: "Yellow", value: [0.95, 0.85, 0.1, 1] },
|
|
3296
|
+
{ label: "Green", value: [0.2, 0.75, 0.3, 1] },
|
|
3297
|
+
{ label: "Blue", value: [0.2, 0.45, 0.85, 1] },
|
|
3298
|
+
{ label: "Purple", value: [0.55, 0.25, 0.8, 1] },
|
|
3299
|
+
{ label: "Accent", value: [0.106, 0.286, 0.396, 1] }
|
|
3300
|
+
], r = [
|
|
3301
|
+
{ label: "Sans", value: "sans-serif" },
|
|
3302
|
+
{ label: "Serif", value: "serif" },
|
|
3303
|
+
{ label: "Mono", value: "monospace" }
|
|
3304
|
+
];
|
|
3305
|
+
function s(c) {
|
|
3306
|
+
return `rgba(${Math.round(c[0] * 255)}, ${Math.round(c[1] * 255)}, ${Math.round(c[2] * 255)}, ${c[3]})`;
|
|
3307
|
+
}
|
|
3308
|
+
function i(c, m) {
|
|
3309
|
+
return Math.abs(c[0] - m[0]) < 0.01 && Math.abs(c[1] - m[1]) < 0.01 && Math.abs(c[2] - m[2]) < 0.01 && Math.abs(c[3] - m[3]) < 0.01;
|
|
3310
|
+
}
|
|
3311
|
+
function v(c, m) {
|
|
3312
|
+
if (!t.value) return;
|
|
3313
|
+
const d = t.value;
|
|
3314
|
+
e.updateState((x) => {
|
|
3315
|
+
const _ = x.annotations.find(($) => $.id === d);
|
|
3316
|
+
_ && (_[c] = m);
|
|
3317
|
+
});
|
|
3318
|
+
}
|
|
3319
|
+
function l() {
|
|
3320
|
+
if (!t.value) return;
|
|
3321
|
+
const c = t.value;
|
|
3322
|
+
e.updateState((m) => {
|
|
3323
|
+
const d = m.annotations.findIndex((x) => x.id === c);
|
|
3324
|
+
d >= 0 && m.annotations.splice(d, 1);
|
|
3325
|
+
}), t.value = null;
|
|
3326
|
+
}
|
|
3327
|
+
return (c, m) => (S(), z("div", Xi, [
|
|
3328
|
+
I(t) ? (S(), z("div", qi, [
|
|
3329
|
+
y("button", {
|
|
3330
|
+
class: "vie-annotate-tool vie-annotate-tool--delete",
|
|
3331
|
+
title: I(n)("delete"),
|
|
3332
|
+
onClick: l
|
|
3333
|
+
}, [...m[4] || (m[4] = [
|
|
3334
|
+
y("svg", {
|
|
3335
|
+
viewBox: "0 0 24 24",
|
|
3336
|
+
fill: "none",
|
|
3337
|
+
stroke: "currentColor",
|
|
3338
|
+
"stroke-width": "2",
|
|
3339
|
+
"stroke-linecap": "round",
|
|
3340
|
+
"stroke-linejoin": "round"
|
|
3341
|
+
}, [
|
|
3342
|
+
y("polyline", { points: "3 6 5 6 21 6" }),
|
|
3343
|
+
y("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
|
|
3344
|
+
], -1)
|
|
3345
|
+
])], 8, Yi)
|
|
3346
|
+
])) : G("", !0),
|
|
3347
|
+
a.value ? (S(), z("div", Ui, [
|
|
3348
|
+
y("div", Ni, [
|
|
3349
|
+
y("span", Zi, q(I(n)("fillColor")), 1),
|
|
3350
|
+
y("div", Ji, [
|
|
3351
|
+
(S(), z(Y, null, Z(h, (d) => y("button", {
|
|
3352
|
+
key: "text-" + d.label,
|
|
3353
|
+
class: N(["vie-annotate-color-swatch", { "vie-annotate-color-swatch--active": i(a.value.fillColor, d.value) }]),
|
|
3354
|
+
style: le({ backgroundColor: s(d.value) }),
|
|
3355
|
+
title: d.label,
|
|
3356
|
+
onClick: (x) => v("fillColor", [...d.value])
|
|
3357
|
+
}, null, 14, Gi)), 64))
|
|
3358
|
+
])
|
|
3359
|
+
]),
|
|
3360
|
+
X(fe, {
|
|
3361
|
+
label: I(n)("fontSize"),
|
|
3362
|
+
modelValue: a.value.fontSize * 1e3,
|
|
3363
|
+
min: 15,
|
|
3364
|
+
max: 120,
|
|
3365
|
+
step: 1,
|
|
3366
|
+
base: 40,
|
|
3367
|
+
format: "number",
|
|
3368
|
+
"onUpdate:modelValue": m[0] || (m[0] = (d) => v("fontSize", d / 1e3))
|
|
3369
|
+
}, null, 8, ["label", "modelValue"]),
|
|
3370
|
+
y("div", Qi, [
|
|
3371
|
+
y("span", eo, q(I(n)("fontFamily")), 1),
|
|
3372
|
+
y("div", to, [
|
|
3373
|
+
(S(), z(Y, null, Z(r, (d) => y("button", {
|
|
3374
|
+
key: d.value,
|
|
3375
|
+
class: N(["vie-annotate-font-btn", { "vie-annotate-font-btn--active": a.value.fontFamily === d.value }]),
|
|
3376
|
+
style: le({ fontFamily: d.value }),
|
|
3377
|
+
onClick: (x) => v("fontFamily", d.value)
|
|
3378
|
+
}, q(d.label), 15, no)), 64))
|
|
3379
|
+
])
|
|
3380
|
+
]),
|
|
3381
|
+
y("div", io, [
|
|
3382
|
+
y("button", {
|
|
3383
|
+
class: N(["vie-annotate-toggle", { "vie-annotate-toggle--active": a.value.fontWeight === "bold" }]),
|
|
3384
|
+
onClick: m[1] || (m[1] = (d) => v("fontWeight", a.value.fontWeight === "bold" ? "normal" : "bold"))
|
|
3385
|
+
}, [...m[5] || (m[5] = [
|
|
3386
|
+
y("strong", null, "B", -1)
|
|
3387
|
+
])], 2),
|
|
3388
|
+
y("button", {
|
|
3389
|
+
class: N(["vie-annotate-toggle", { "vie-annotate-toggle--active": a.value.fontStyle === "italic" }]),
|
|
3390
|
+
onClick: m[2] || (m[2] = (d) => v("fontStyle", a.value.fontStyle === "italic" ? "normal" : "italic"))
|
|
3391
|
+
}, [...m[6] || (m[6] = [
|
|
3392
|
+
y("em", null, "I", -1)
|
|
3393
|
+
])], 2)
|
|
3394
|
+
]),
|
|
3395
|
+
X(fe, {
|
|
3396
|
+
label: I(n)("opacity"),
|
|
3397
|
+
modelValue: a.value.opacity,
|
|
3398
|
+
min: 0.1,
|
|
3399
|
+
max: 1,
|
|
3400
|
+
step: 0.05,
|
|
3401
|
+
base: 1,
|
|
3402
|
+
format: "percent",
|
|
3403
|
+
"onUpdate:modelValue": m[3] || (m[3] = (d) => v("opacity", d))
|
|
3404
|
+
}, null, 8, ["label", "modelValue"])
|
|
3405
|
+
])) : G("", !0)
|
|
3406
|
+
]));
|
|
3407
|
+
}
|
|
3408
|
+
});
|
|
3409
|
+
let ao = 0;
|
|
3410
|
+
function so() {
|
|
3411
|
+
return `ann-${Date.now()}-${++ao}-${Math.random().toString(36).slice(2, 6)}`;
|
|
3412
|
+
}
|
|
3413
|
+
const lo = [1, 1, 1, 1];
|
|
3414
|
+
function ro(o, e, n, t) {
|
|
3415
|
+
return {
|
|
3416
|
+
id: so(),
|
|
3417
|
+
x: o,
|
|
3418
|
+
y: e,
|
|
3419
|
+
width: n,
|
|
3420
|
+
height: t,
|
|
3421
|
+
rotation: 0,
|
|
3422
|
+
strokeColor: [0, 0, 0, 0],
|
|
3423
|
+
strokeWidth: 0,
|
|
3424
|
+
opacity: 1,
|
|
3425
|
+
type: "text",
|
|
3426
|
+
text: "",
|
|
3427
|
+
fontSize: 0.04,
|
|
3428
|
+
fontFamily: "sans-serif",
|
|
3429
|
+
fontWeight: "normal",
|
|
3430
|
+
fontStyle: "normal",
|
|
3431
|
+
fillColor: [...lo],
|
|
3432
|
+
textAlign: "left"
|
|
3186
3433
|
};
|
|
3187
3434
|
}
|
|
3188
|
-
const
|
|
3435
|
+
const co = ["viewBox", "width", "height"], uo = ["x", "y", "width", "height", "data-annotation-id"], ho = ["transform"], vo = ["x", "y", "width", "height"], fo = ["x", "y", "data-handle"], po = ["x1", "y1", "x2", "y2"], mo = ["cx", "cy"], go = ["x", "y", "width", "height"], yo = ["value", "onKeydown"], Ce = 10, qe = 20, Ye = 6, Ue = 6, Ne = 4, wo = /* @__PURE__ */ J({
|
|
3436
|
+
__name: "AnnotateOverlay",
|
|
3437
|
+
props: {
|
|
3438
|
+
canvasRect: {},
|
|
3439
|
+
wrapperSize: {}
|
|
3440
|
+
},
|
|
3441
|
+
setup(o) {
|
|
3442
|
+
function e(f, p, b, R, T, W) {
|
|
3443
|
+
const U = document.createElement("canvas").getContext("2d");
|
|
3444
|
+
U.font = `${T} ${R} ${p}px ${b}`;
|
|
3445
|
+
const Q = p * 1.2, te = f.split(`
|
|
3446
|
+
`);
|
|
3447
|
+
let ae = 0, me = 0;
|
|
3448
|
+
for (const st of te) {
|
|
3449
|
+
const lt = st.split(" ");
|
|
3450
|
+
let ue = "";
|
|
3451
|
+
for (const ke of lt) {
|
|
3452
|
+
const Fe = ue ? `${ue} ${ke}` : ke;
|
|
3453
|
+
U.measureText(Fe).width > W && ue ? (ae = Math.max(ae, U.measureText(ue).width), me++, ue = ke) : ue = Fe;
|
|
3454
|
+
}
|
|
3455
|
+
ae = Math.max(ae, U.measureText(ue).width), me++;
|
|
3456
|
+
}
|
|
3457
|
+
return { width: ae, height: me * Q };
|
|
3458
|
+
}
|
|
3459
|
+
const n = o, t = ee(), a = H(null), h = H(null), r = at(t.state), s = H(!1), i = H(""), v = H(null), l = H({
|
|
3460
|
+
size: 14,
|
|
3461
|
+
family: "sans-serif",
|
|
3462
|
+
weight: "normal",
|
|
3463
|
+
style: "normal",
|
|
3464
|
+
color: "#ffffff"
|
|
3465
|
+
}), c = j(() => ({
|
|
3466
|
+
fontSize: l.value.size + "px",
|
|
3467
|
+
fontFamily: l.value.family,
|
|
3468
|
+
fontWeight: l.value.weight,
|
|
3469
|
+
fontStyle: l.value.style,
|
|
3470
|
+
color: l.value.color
|
|
3471
|
+
}));
|
|
3472
|
+
he(() => {
|
|
3473
|
+
$.value && (t.updateState(() => {
|
|
3474
|
+
}), $.value = null, w.value = null), window.removeEventListener("pointermove", E), window.removeEventListener("pointerup", O);
|
|
3475
|
+
});
|
|
3476
|
+
const m = j(() => {
|
|
3477
|
+
const f = n.canvasRect;
|
|
3478
|
+
return t.state.annotations.map((p) => ({
|
|
3479
|
+
id: p.id,
|
|
3480
|
+
dx: f.x + p.x * f.width,
|
|
3481
|
+
dy: f.y + p.y * f.height,
|
|
3482
|
+
dw: p.width * f.width,
|
|
3483
|
+
dh: p.height * f.height
|
|
3484
|
+
}));
|
|
3485
|
+
}), d = j(() => r.value && m.value.find((f) => f.id === r.value) || null), x = j(() => {
|
|
3486
|
+
if (!r.value || !d.value) return "";
|
|
3487
|
+
const f = t.state.annotations.find((T) => T.id === r.value);
|
|
3488
|
+
if (!f || f.rotation === 0) return "";
|
|
3489
|
+
const p = d.value.dx + d.value.dw / 2, b = d.value.dy + d.value.dh / 2;
|
|
3490
|
+
return `rotate(${f.rotation * 180 / Math.PI} ${p} ${b})`;
|
|
3491
|
+
}), _ = j(() => {
|
|
3492
|
+
if (!d.value) return [];
|
|
3493
|
+
const f = d.value, p = Ce / 2;
|
|
3494
|
+
return [
|
|
3495
|
+
{ id: "nw", x: f.dx - p, y: f.dy - p },
|
|
3496
|
+
{ id: "ne", x: f.dx + f.dw - p, y: f.dy - p },
|
|
3497
|
+
{ id: "sw", x: f.dx - p, y: f.dy + f.dh - p },
|
|
3498
|
+
{ id: "se", x: f.dx + f.dw - p, y: f.dy + f.dh - p }
|
|
3499
|
+
];
|
|
3500
|
+
}), $ = H(null), w = H(null), u = H({ x: 0, y: 0 }), g = H({ x: 0, y: 0, width: 0, height: 0, rotation: 0 });
|
|
3501
|
+
function k(f) {
|
|
3502
|
+
var b;
|
|
3503
|
+
const p = (b = a.value) == null ? void 0 : b.getBoundingClientRect();
|
|
3504
|
+
return p ? { x: f.clientX - p.left, y: f.clientY - p.top } : { x: f.clientX, y: f.clientY };
|
|
3505
|
+
}
|
|
3506
|
+
function C(f) {
|
|
3507
|
+
var te;
|
|
3508
|
+
const p = f.target, b = p.getAttribute("data-handle");
|
|
3509
|
+
if (b === "rotate" && r.value) {
|
|
3510
|
+
f.preventDefault(), L(f, "rotate", b);
|
|
3511
|
+
return;
|
|
3512
|
+
}
|
|
3513
|
+
if (b && ["nw", "ne", "sw", "se"].includes(b) && r.value) {
|
|
3514
|
+
f.preventDefault(), L(f, "resize", b);
|
|
3515
|
+
return;
|
|
3516
|
+
}
|
|
3517
|
+
const R = p.getAttribute("data-annotation-id");
|
|
3518
|
+
if (R) {
|
|
3519
|
+
f.preventDefault(), r.value = R, s.value = !1;
|
|
3520
|
+
const ae = t.state.annotations.find((me) => me.id === R);
|
|
3521
|
+
if (ae && f.detail >= 2) {
|
|
3522
|
+
V(ae);
|
|
3523
|
+
return;
|
|
3524
|
+
}
|
|
3525
|
+
L(f, "move", null), (te = a.value) == null || te.focus();
|
|
3526
|
+
return;
|
|
3527
|
+
}
|
|
3528
|
+
if (f.preventDefault(), s.value) {
|
|
3529
|
+
K(), r.value = null;
|
|
3530
|
+
return;
|
|
3531
|
+
}
|
|
3532
|
+
r.value = null;
|
|
3533
|
+
const T = n.canvasRect, W = k(f), B = (W.x - T.x) / T.width, U = (W.y - T.y) / T.height, Q = ro(F(B, 0, 0.9), F(U, 0, 0.9), 0.25, 0.06);
|
|
3534
|
+
t.updateState((ae) => ae.annotations.push(Q)), r.value = Q.id, Se(() => V(Q));
|
|
3535
|
+
}
|
|
3536
|
+
function P(f) {
|
|
3537
|
+
return `rgba(${Math.round(f[0] * 255)}, ${Math.round(f[1] * 255)}, ${Math.round(f[2] * 255)}, ${f[3]})`;
|
|
3538
|
+
}
|
|
3539
|
+
function V(f) {
|
|
3540
|
+
s.value = !0, i.value = f.text;
|
|
3541
|
+
const p = n.canvasRect, b = f.fontSize * p.height;
|
|
3542
|
+
v.value = {
|
|
3543
|
+
x: p.x + f.x * p.width - Ue,
|
|
3544
|
+
y: p.y + f.y * p.height - Ne,
|
|
3545
|
+
w: Math.max(120, f.width * p.width + Ue * 2),
|
|
3546
|
+
h: Math.max(b * 1.6, f.height * p.height + Ne * 2)
|
|
3547
|
+
}, l.value = {
|
|
3548
|
+
size: b,
|
|
3549
|
+
family: f.fontFamily,
|
|
3550
|
+
weight: f.fontWeight,
|
|
3551
|
+
style: f.fontStyle,
|
|
3552
|
+
color: P(f.fillColor)
|
|
3553
|
+
}, Se(() => {
|
|
3554
|
+
h.value && (h.value.focus(), D());
|
|
3555
|
+
});
|
|
3556
|
+
}
|
|
3557
|
+
function A(f) {
|
|
3558
|
+
i.value = f.target.value, D();
|
|
3559
|
+
}
|
|
3560
|
+
function D() {
|
|
3561
|
+
const f = h.value;
|
|
3562
|
+
if (!f || !v.value) return;
|
|
3563
|
+
f.style.height = "0";
|
|
3564
|
+
const p = f.scrollHeight + 4;
|
|
3565
|
+
f.style.height = "100%", p > v.value.h && (v.value.h = p);
|
|
3566
|
+
}
|
|
3567
|
+
function K() {
|
|
3568
|
+
if (r.value) {
|
|
3569
|
+
const f = t.state.annotations.find((p) => p.id === r.value);
|
|
3570
|
+
f && (f.text = i.value);
|
|
3571
|
+
}
|
|
3572
|
+
if (r.value) {
|
|
3573
|
+
const f = n.canvasRect, p = t.state.annotations.find((b) => b.id === r.value);
|
|
3574
|
+
if (p && p.text.trim() && f.width > 0 && f.height > 0) {
|
|
3575
|
+
const b = p.fontSize * f.height, R = p.width * f.width, T = e(
|
|
3576
|
+
p.text,
|
|
3577
|
+
b,
|
|
3578
|
+
p.fontFamily,
|
|
3579
|
+
p.fontWeight,
|
|
3580
|
+
p.fontStyle,
|
|
3581
|
+
R
|
|
3582
|
+
);
|
|
3583
|
+
p.width = T.width / f.width, p.height = T.height / f.height;
|
|
3584
|
+
}
|
|
3585
|
+
}
|
|
3586
|
+
if (s.value = !1, v.value = null, r.value) {
|
|
3587
|
+
const f = t.state.annotations.find((p) => p.id === r.value);
|
|
3588
|
+
if (f && !f.text.trim()) {
|
|
3589
|
+
const p = r.value;
|
|
3590
|
+
t.updateState((b) => {
|
|
3591
|
+
const R = b.annotations.findIndex((T) => T.id === p);
|
|
3592
|
+
R >= 0 && b.annotations.splice(R, 1);
|
|
3593
|
+
}), r.value = null;
|
|
3594
|
+
} else f && t.updateState(() => {
|
|
3595
|
+
});
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
function L(f, p, b) {
|
|
3599
|
+
$.value = p, w.value = b;
|
|
3600
|
+
const R = k(f);
|
|
3601
|
+
u.value = { x: R.x, y: R.y };
|
|
3602
|
+
const T = t.state.annotations.find((W) => W.id === r.value);
|
|
3603
|
+
T && (g.value = {
|
|
3604
|
+
x: T.x,
|
|
3605
|
+
y: T.y,
|
|
3606
|
+
width: T.width,
|
|
3607
|
+
height: T.height,
|
|
3608
|
+
rotation: T.rotation
|
|
3609
|
+
}), window.addEventListener("pointermove", E), window.addEventListener("pointerup", O);
|
|
3610
|
+
}
|
|
3611
|
+
function E(f) {
|
|
3612
|
+
if (!$.value) return;
|
|
3613
|
+
const p = n.canvasRect;
|
|
3614
|
+
if (p.width === 0 || p.height === 0) return;
|
|
3615
|
+
const b = k(f), R = (b.x - u.value.x) / p.width, T = (b.y - u.value.y) / p.height, W = g.value;
|
|
3616
|
+
switch ($.value) {
|
|
3617
|
+
case "move": {
|
|
3618
|
+
if (!r.value) break;
|
|
3619
|
+
const B = t.state.annotations.find((U) => U.id === r.value);
|
|
3620
|
+
if (!B) break;
|
|
3621
|
+
B.x = F(W.x + R, 0, 1 - B.width), B.y = F(W.y + T, 0, 1 - B.height), t.requestRender(!0);
|
|
3622
|
+
break;
|
|
3623
|
+
}
|
|
3624
|
+
case "resize": {
|
|
3625
|
+
if (!r.value) break;
|
|
3626
|
+
const B = t.state.annotations.find((Q) => Q.id === r.value);
|
|
3627
|
+
if (!B) break;
|
|
3628
|
+
const U = 0.01;
|
|
3629
|
+
switch (w.value) {
|
|
3630
|
+
case "se":
|
|
3631
|
+
B.width = F(W.width + R, U, 1 - W.x), B.height = F(W.height + T, U, 1 - W.y);
|
|
3632
|
+
break;
|
|
3633
|
+
case "ne": {
|
|
3634
|
+
const Q = F(W.width + R, U, 1 - W.x), te = F(W.height - T, U, W.y + W.height);
|
|
3635
|
+
B.width = Q, B.height = te, B.y = W.y + W.height - te;
|
|
3636
|
+
break;
|
|
3637
|
+
}
|
|
3638
|
+
case "sw": {
|
|
3639
|
+
const Q = F(W.width - R, U, W.x + W.width), te = F(W.height + T, U, 1 - W.y);
|
|
3640
|
+
B.width = Q, B.height = te, B.x = W.x + W.width - Q;
|
|
3641
|
+
break;
|
|
3642
|
+
}
|
|
3643
|
+
case "nw": {
|
|
3644
|
+
const Q = F(W.width - R, U, W.x + W.width), te = F(W.height - T, U, W.y + W.height);
|
|
3645
|
+
B.width = Q, B.height = te, B.x = W.x + W.width - Q, B.y = W.y + W.height - te;
|
|
3646
|
+
break;
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
t.requestRender(!0);
|
|
3650
|
+
break;
|
|
3651
|
+
}
|
|
3652
|
+
case "rotate": {
|
|
3653
|
+
if (!r.value) break;
|
|
3654
|
+
const B = t.state.annotations.find((ae) => ae.id === r.value);
|
|
3655
|
+
if (!B) break;
|
|
3656
|
+
const U = p.x + B.x * p.width + B.width * p.width / 2, Q = p.y + B.y * p.height + B.height * p.height / 2, te = Math.atan2(b.x - U, -(b.y - Q));
|
|
3657
|
+
B.rotation = te, t.requestRender(!0);
|
|
3658
|
+
break;
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3662
|
+
function O() {
|
|
3663
|
+
$.value && t.updateState(() => {
|
|
3664
|
+
}), $.value = null, w.value = null, window.removeEventListener("pointermove", E), window.removeEventListener("pointerup", O);
|
|
3665
|
+
}
|
|
3666
|
+
function M(f) {
|
|
3667
|
+
if ((f.key === "Delete" || f.key === "Backspace") && r.value && !s.value) {
|
|
3668
|
+
f.preventDefault();
|
|
3669
|
+
const p = r.value;
|
|
3670
|
+
t.updateState((b) => {
|
|
3671
|
+
const R = b.annotations.findIndex((T) => T.id === p);
|
|
3672
|
+
R >= 0 && b.annotations.splice(R, 1);
|
|
3673
|
+
}), r.value = null;
|
|
3674
|
+
}
|
|
3675
|
+
f.key === "Escape" && (s.value ? K() : r.value = null);
|
|
3676
|
+
}
|
|
3677
|
+
function F(f, p, b) {
|
|
3678
|
+
return Math.max(p, Math.min(b, f));
|
|
3679
|
+
}
|
|
3680
|
+
return (f, p) => (S(), z("svg", {
|
|
3681
|
+
ref_key: "svgRef",
|
|
3682
|
+
ref: a,
|
|
3683
|
+
class: "vie-annotate-overlay",
|
|
3684
|
+
viewBox: `0 0 ${o.wrapperSize.width} ${o.wrapperSize.height}`,
|
|
3685
|
+
width: o.wrapperSize.width,
|
|
3686
|
+
height: o.wrapperSize.height,
|
|
3687
|
+
onPointerdown: C,
|
|
3688
|
+
onKeydown: M,
|
|
3689
|
+
tabindex: "0"
|
|
3690
|
+
}, [
|
|
3691
|
+
(S(!0), z(Y, null, Z(m.value, (b) => (S(), z("rect", {
|
|
3692
|
+
key: b.id,
|
|
3693
|
+
x: b.dx,
|
|
3694
|
+
y: b.dy,
|
|
3695
|
+
width: b.dw,
|
|
3696
|
+
height: b.dh,
|
|
3697
|
+
fill: "transparent",
|
|
3698
|
+
class: "vie-annotate-hitarea",
|
|
3699
|
+
"data-annotation-id": b.id
|
|
3700
|
+
}, null, 8, uo))), 128)),
|
|
3701
|
+
d.value ? (S(), z("g", {
|
|
3702
|
+
key: 0,
|
|
3703
|
+
transform: x.value
|
|
3704
|
+
}, [
|
|
3705
|
+
y("rect", {
|
|
3706
|
+
x: d.value.dx,
|
|
3707
|
+
y: d.value.dy,
|
|
3708
|
+
width: d.value.dw,
|
|
3709
|
+
height: d.value.dh,
|
|
3710
|
+
class: "vie-annotate-selection"
|
|
3711
|
+
}, null, 8, vo),
|
|
3712
|
+
(S(!0), z(Y, null, Z(_.value, (b) => (S(), z("rect", {
|
|
3713
|
+
key: b.id,
|
|
3714
|
+
x: b.x,
|
|
3715
|
+
y: b.y,
|
|
3716
|
+
width: Ce,
|
|
3717
|
+
height: Ce,
|
|
3718
|
+
class: "vie-annotate-handle",
|
|
3719
|
+
"data-handle": b.id
|
|
3720
|
+
}, null, 8, fo))), 128)),
|
|
3721
|
+
y("line", {
|
|
3722
|
+
x1: d.value.dx + d.value.dw / 2,
|
|
3723
|
+
y1: d.value.dy - qe,
|
|
3724
|
+
x2: d.value.dx + d.value.dw / 2,
|
|
3725
|
+
y2: d.value.dy,
|
|
3726
|
+
class: "vie-annotate-rotate-line"
|
|
3727
|
+
}, null, 8, po),
|
|
3728
|
+
y("circle", {
|
|
3729
|
+
cx: d.value.dx + d.value.dw / 2,
|
|
3730
|
+
cy: d.value.dy - qe - Ye,
|
|
3731
|
+
r: Ye,
|
|
3732
|
+
class: "vie-annotate-rotate-handle",
|
|
3733
|
+
"data-handle": "rotate"
|
|
3734
|
+
}, null, 8, mo)
|
|
3735
|
+
], 8, ho)) : G("", !0),
|
|
3736
|
+
s.value && v.value ? (S(), z("foreignObject", {
|
|
3737
|
+
key: 1,
|
|
3738
|
+
x: v.value.x,
|
|
3739
|
+
y: v.value.y,
|
|
3740
|
+
width: v.value.w,
|
|
3741
|
+
height: v.value.h
|
|
3742
|
+
}, [
|
|
3743
|
+
y("textarea", {
|
|
3744
|
+
ref_key: "textareaRef",
|
|
3745
|
+
ref: h,
|
|
3746
|
+
class: "vie-annotate-text-input",
|
|
3747
|
+
style: le(c.value),
|
|
3748
|
+
value: i.value,
|
|
3749
|
+
onInput: A,
|
|
3750
|
+
onBlur: K,
|
|
3751
|
+
onKeydown: Me(ve(K, ["prevent"]), ["escape"])
|
|
3752
|
+
}, null, 44, yo)
|
|
3753
|
+
], 8, go)) : G("", !0)
|
|
3754
|
+
], 40, co));
|
|
3755
|
+
}
|
|
3756
|
+
}), ko = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
3757
|
+
<polyline points="4 7 4 4 20 4 20 7"/>
|
|
3758
|
+
<line x1="9.5" y1="20" x2="14.5" y2="20"/>
|
|
3759
|
+
<line x1="12" y1="4" x2="12" y2="20"/>
|
|
3760
|
+
</svg>`;
|
|
3761
|
+
function bo() {
|
|
3762
|
+
return {
|
|
3763
|
+
id: "text",
|
|
3764
|
+
icon: ko,
|
|
3765
|
+
labelKey: "text",
|
|
3766
|
+
controls: oo,
|
|
3767
|
+
overlay: wo
|
|
3768
|
+
};
|
|
3769
|
+
}
|
|
3770
|
+
const xo = ["dir"], _o = { class: "vie-main" }, Co = /* @__PURE__ */ J({
|
|
3189
3771
|
__name: "EditorShell",
|
|
3190
3772
|
props: {
|
|
3191
3773
|
options: {}
|
|
3192
3774
|
},
|
|
3193
3775
|
emits: ["process", "close"],
|
|
3194
|
-
setup(
|
|
3195
|
-
const n =
|
|
3196
|
-
|
|
3197
|
-
const
|
|
3198
|
-
const
|
|
3776
|
+
setup(o, { emit: e }) {
|
|
3777
|
+
const n = o, t = e, a = kt(n.options);
|
|
3778
|
+
bt(a);
|
|
3779
|
+
const h = { en: Pt, ar: Tt }, r = j(() => {
|
|
3780
|
+
const _ = n.options.locale || "en";
|
|
3199
3781
|
return ($) => {
|
|
3200
|
-
var
|
|
3201
|
-
return ((
|
|
3782
|
+
var w;
|
|
3783
|
+
return ((w = h[_]) == null ? void 0 : w[$]) || h.en[$] || $;
|
|
3202
3784
|
};
|
|
3203
3785
|
});
|
|
3204
|
-
|
|
3205
|
-
const
|
|
3206
|
-
crop: () =>
|
|
3207
|
-
finetune: () =>
|
|
3208
|
-
filter: () =>
|
|
3209
|
-
sticker: () =>
|
|
3210
|
-
frame: () =>
|
|
3211
|
-
fill: () =>
|
|
3212
|
-
resize: () =>
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3786
|
+
Ze(oe, (_) => r.value(_));
|
|
3787
|
+
const s = {
|
|
3788
|
+
crop: () => a.registerPlugin(Pn()),
|
|
3789
|
+
finetune: () => a.registerPlugin(Fn()),
|
|
3790
|
+
filter: () => a.registerPlugin(On()),
|
|
3791
|
+
sticker: () => a.registerPlugin(ai()),
|
|
3792
|
+
frame: () => a.registerPlugin(wi()),
|
|
3793
|
+
fill: () => a.registerPlugin(Mi()),
|
|
3794
|
+
resize: () => a.registerPlugin(Oi()),
|
|
3795
|
+
text: () => a.registerPlugin(bo())
|
|
3796
|
+
}, i = n.options.plugins || ["crop", "finetune", "filter", "text", "sticker", "frame", "resize"];
|
|
3797
|
+
for (const _ of i)
|
|
3798
|
+
s[_] && s[_]();
|
|
3216
3799
|
if (n.options.customPlugins)
|
|
3217
|
-
for (const
|
|
3218
|
-
|
|
3219
|
-
const
|
|
3800
|
+
for (const _ of n.options.customPlugins)
|
|
3801
|
+
a.registerPlugin(_);
|
|
3802
|
+
const v = H(null), l = H(!1);
|
|
3220
3803
|
let c = null;
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
for (const $ of
|
|
3224
|
-
const { width:
|
|
3225
|
-
|
|
3804
|
+
ge(() => {
|
|
3805
|
+
v.value && (c = new ResizeObserver((_) => {
|
|
3806
|
+
for (const $ of _) {
|
|
3807
|
+
const { width: w, height: u } = $.contentRect;
|
|
3808
|
+
l.value = w > u && w > 700;
|
|
3226
3809
|
}
|
|
3227
|
-
}), c.observe(
|
|
3228
|
-
}),
|
|
3810
|
+
}), c.observe(v.value), v.value.focus());
|
|
3811
|
+
}), he(() => {
|
|
3229
3812
|
c == null || c.disconnect();
|
|
3230
3813
|
});
|
|
3231
|
-
function
|
|
3232
|
-
|
|
3814
|
+
function m(_) {
|
|
3815
|
+
_.ctrlKey || _.metaKey ? _.key === "z" && !_.shiftKey ? (_.preventDefault(), a.undo()) : (_.key === "z" && _.shiftKey || _.key === "y") && (_.preventDefault(), a.redo()) : _.key === "Escape" && t("close");
|
|
3233
3816
|
}
|
|
3234
|
-
const
|
|
3235
|
-
async function
|
|
3236
|
-
if (!(!
|
|
3237
|
-
|
|
3817
|
+
const d = H(!1);
|
|
3818
|
+
async function x() {
|
|
3819
|
+
if (!(!a.sourceImage.value || d.value)) {
|
|
3820
|
+
d.value = !0;
|
|
3238
3821
|
try {
|
|
3239
|
-
const $ = await new
|
|
3240
|
-
|
|
3241
|
-
|
|
3822
|
+
const $ = await new $t().process(
|
|
3823
|
+
a.sourceImage.value,
|
|
3824
|
+
a.state,
|
|
3242
3825
|
{
|
|
3243
3826
|
mimeType: n.options.outputMimeType || "image/jpeg",
|
|
3244
3827
|
quality: n.options.outputQuality ?? 0.92,
|
|
@@ -3247,45 +3830,45 @@ const Ci = ["dir"], Mi = { class: "vie-main" }, Si = /* @__PURE__ */ Y({
|
|
|
3247
3830
|
);
|
|
3248
3831
|
t("process", $);
|
|
3249
3832
|
} finally {
|
|
3250
|
-
|
|
3833
|
+
d.value = !1;
|
|
3251
3834
|
}
|
|
3252
3835
|
}
|
|
3253
3836
|
}
|
|
3254
|
-
return (
|
|
3837
|
+
return (_, $) => (S(), z("div", {
|
|
3255
3838
|
ref_key: "shellRef",
|
|
3256
|
-
ref:
|
|
3257
|
-
class:
|
|
3839
|
+
ref: v,
|
|
3840
|
+
class: N([
|
|
3258
3841
|
"vie-editor",
|
|
3259
3842
|
"vie-shell",
|
|
3260
|
-
|
|
3261
|
-
|
|
3843
|
+
l.value ? "vie-shell--horizontal" : "",
|
|
3844
|
+
o.options.theme === "dark" ? "vie-theme-dark" : ""
|
|
3262
3845
|
]),
|
|
3263
|
-
dir:
|
|
3264
|
-
onKeydown:
|
|
3846
|
+
dir: o.options.dir || "ltr",
|
|
3847
|
+
onKeydown: m,
|
|
3265
3848
|
tabindex: "0"
|
|
3266
3849
|
}, [
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
onDone:
|
|
3272
|
-
processing:
|
|
3850
|
+
l.value ? (S(), z(Y, { key: 0 }, [
|
|
3851
|
+
X(He),
|
|
3852
|
+
y("div", _o, [
|
|
3853
|
+
X(Le, {
|
|
3854
|
+
onDone: x,
|
|
3855
|
+
processing: d.value
|
|
3273
3856
|
}, null, 8, ["processing"]),
|
|
3274
|
-
|
|
3275
|
-
|
|
3857
|
+
X(Ke),
|
|
3858
|
+
X(Ve)
|
|
3276
3859
|
])
|
|
3277
|
-
], 64)) : (
|
|
3278
|
-
|
|
3279
|
-
onDone:
|
|
3280
|
-
processing:
|
|
3860
|
+
], 64)) : (S(), z(Y, { key: 1 }, [
|
|
3861
|
+
X(Le, {
|
|
3862
|
+
onDone: x,
|
|
3863
|
+
processing: d.value
|
|
3281
3864
|
}, null, 8, ["processing"]),
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3865
|
+
X(Ke),
|
|
3866
|
+
X(Ve),
|
|
3867
|
+
X(He)
|
|
3285
3868
|
], 64))
|
|
3286
|
-
], 42,
|
|
3869
|
+
], 42, xo));
|
|
3287
3870
|
}
|
|
3288
|
-
}),
|
|
3871
|
+
}), Mo = { class: "vie-modal-container" }, So = /* @__PURE__ */ J({
|
|
3289
3872
|
__name: "EditorModal",
|
|
3290
3873
|
props: {
|
|
3291
3874
|
src: {},
|
|
@@ -3299,8 +3882,8 @@ const Ci = ["dir"], Mi = { class: "vie-main" }, Si = /* @__PURE__ */ Y({
|
|
|
3299
3882
|
initialState: {}
|
|
3300
3883
|
},
|
|
3301
3884
|
emits: ["process", "close"],
|
|
3302
|
-
setup(
|
|
3303
|
-
const n =
|
|
3885
|
+
setup(o, { emit: e }) {
|
|
3886
|
+
const n = o, t = e, a = H(null), h = j(() => ({
|
|
3304
3887
|
src: n.src,
|
|
3305
3888
|
plugins: n.plugins,
|
|
3306
3889
|
locale: n.locale,
|
|
@@ -3311,48 +3894,48 @@ const Ci = ["dir"], Mi = { class: "vie-main" }, Si = /* @__PURE__ */ Y({
|
|
|
3311
3894
|
maxCanvasPixels: n.maxCanvasPixels,
|
|
3312
3895
|
initialState: n.initialState
|
|
3313
3896
|
}));
|
|
3314
|
-
function
|
|
3897
|
+
function r() {
|
|
3315
3898
|
t("close");
|
|
3316
3899
|
}
|
|
3317
|
-
function
|
|
3318
|
-
window.confirm("Close editor? Unsaved changes will be lost.") &&
|
|
3900
|
+
function s() {
|
|
3901
|
+
window.confirm("Close editor? Unsaved changes will be lost.") && r();
|
|
3319
3902
|
}
|
|
3320
|
-
function i(
|
|
3321
|
-
const c =
|
|
3903
|
+
function i(l) {
|
|
3904
|
+
const c = a.value;
|
|
3322
3905
|
if (!c) return;
|
|
3323
|
-
const
|
|
3906
|
+
const m = c.querySelectorAll(
|
|
3324
3907
|
'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
3325
3908
|
);
|
|
3326
|
-
if (
|
|
3327
|
-
const
|
|
3328
|
-
|
|
3329
|
-
}
|
|
3330
|
-
let
|
|
3331
|
-
return
|
|
3332
|
-
var
|
|
3333
|
-
|
|
3334
|
-
}),
|
|
3335
|
-
document.body.style.overflow =
|
|
3336
|
-
}), (
|
|
3337
|
-
|
|
3338
|
-
default:
|
|
3339
|
-
|
|
3909
|
+
if (m.length === 0) return;
|
|
3910
|
+
const d = m[0], x = m[m.length - 1];
|
|
3911
|
+
l.shiftKey ? document.activeElement === d && (l.preventDefault(), x.focus()) : document.activeElement === x && (l.preventDefault(), d.focus());
|
|
3912
|
+
}
|
|
3913
|
+
let v = "";
|
|
3914
|
+
return ge(async () => {
|
|
3915
|
+
var l, c;
|
|
3916
|
+
v = document.body.style.overflow, document.body.style.overflow = "hidden", await Se(), (c = (l = a.value) == null ? void 0 : l.querySelector('[tabindex="0"]')) == null || c.focus();
|
|
3917
|
+
}), he(() => {
|
|
3918
|
+
document.body.style.overflow = v;
|
|
3919
|
+
}), (l, c) => (S(), pe(mt, { to: "body" }, [
|
|
3920
|
+
X(Te, { name: "vie-modal" }, {
|
|
3921
|
+
default: ne(() => [
|
|
3922
|
+
y("div", {
|
|
3340
3923
|
class: "vie-modal-backdrop",
|
|
3341
3924
|
role: "dialog",
|
|
3342
3925
|
"aria-modal": "true",
|
|
3343
|
-
onClick:
|
|
3926
|
+
onClick: ve(s, ["self"]),
|
|
3344
3927
|
onKeydown: [
|
|
3345
|
-
|
|
3346
|
-
|
|
3928
|
+
Me(r, ["esc"]),
|
|
3929
|
+
Me(i, ["tab"])
|
|
3347
3930
|
],
|
|
3348
3931
|
ref_key: "backdropRef",
|
|
3349
|
-
ref:
|
|
3932
|
+
ref: a
|
|
3350
3933
|
}, [
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
options:
|
|
3354
|
-
onProcess: c[0] || (c[0] = (
|
|
3355
|
-
onClose:
|
|
3934
|
+
y("div", Mo, [
|
|
3935
|
+
X(Co, {
|
|
3936
|
+
options: h.value,
|
|
3937
|
+
onProcess: c[0] || (c[0] = (m) => l.$emit("process", m)),
|
|
3938
|
+
onClose: r
|
|
3356
3939
|
}, null, 8, ["options"])
|
|
3357
3940
|
])
|
|
3358
3941
|
], 544)
|
|
@@ -3362,11 +3945,11 @@ const Ci = ["dir"], Mi = { class: "vie-main" }, Si = /* @__PURE__ */ Y({
|
|
|
3362
3945
|
]));
|
|
3363
3946
|
}
|
|
3364
3947
|
});
|
|
3365
|
-
function
|
|
3366
|
-
return JSON.stringify(
|
|
3948
|
+
function zo(o) {
|
|
3949
|
+
return JSON.stringify(o);
|
|
3367
3950
|
}
|
|
3368
|
-
function
|
|
3369
|
-
const e = JSON.parse(
|
|
3951
|
+
function Io(o) {
|
|
3952
|
+
const e = JSON.parse(o);
|
|
3370
3953
|
if (typeof e != "object" || e === null || Array.isArray(e))
|
|
3371
3954
|
throw new Error("Invalid state: expected an object");
|
|
3372
3955
|
if (Array.isArray(e.stickers)) {
|
|
@@ -3378,64 +3961,66 @@ function Ti(s) {
|
|
|
3378
3961
|
}
|
|
3379
3962
|
return e;
|
|
3380
3963
|
}
|
|
3381
|
-
function
|
|
3382
|
-
const e =
|
|
3964
|
+
function Po(o) {
|
|
3965
|
+
const e = $e();
|
|
3383
3966
|
return {
|
|
3384
3967
|
...e,
|
|
3385
|
-
...
|
|
3386
|
-
crop: { ...e.crop, ...
|
|
3387
|
-
finetune: { ...e.finetune, ...
|
|
3388
|
-
filter: { ...e.filter, ...
|
|
3389
|
-
frame: { ...e.frame, ...
|
|
3390
|
-
resize: { ...e.resize, ...
|
|
3391
|
-
stickers:
|
|
3392
|
-
backgroundColor:
|
|
3968
|
+
...o,
|
|
3969
|
+
crop: { ...e.crop, ...o.crop || {} },
|
|
3970
|
+
finetune: { ...e.finetune, ...o.finetune || {} },
|
|
3971
|
+
filter: { ...e.filter, ...o.filter || {} },
|
|
3972
|
+
frame: { ...e.frame, ...o.frame || {} },
|
|
3973
|
+
resize: { ...e.resize, ...o.resize || {} },
|
|
3974
|
+
stickers: o.stickers || e.stickers,
|
|
3975
|
+
backgroundColor: o.backgroundColor || e.backgroundColor
|
|
3393
3976
|
};
|
|
3394
3977
|
}
|
|
3395
|
-
function
|
|
3396
|
-
|
|
3978
|
+
function $o(o) {
|
|
3979
|
+
o.component("ImageEditorModal", So);
|
|
3397
3980
|
}
|
|
3398
|
-
const
|
|
3981
|
+
const To = { install: $o };
|
|
3399
3982
|
export {
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3983
|
+
bo as AnnotatePlugin,
|
|
3984
|
+
jt as CanvasRenderer,
|
|
3985
|
+
Pn as CropPlugin,
|
|
3986
|
+
Mi as FillPlugin,
|
|
3987
|
+
On as FilterPlugin,
|
|
3988
|
+
Fn as FinetunePlugin,
|
|
3989
|
+
wi as FramePlugin,
|
|
3990
|
+
gt as History,
|
|
3991
|
+
We as IDENTITY_MATRIX,
|
|
3992
|
+
So as ImageEditorModal,
|
|
3993
|
+
Co as ImageEditorShell,
|
|
3994
|
+
$t as ImageProcessor,
|
|
3995
|
+
oe as LOCALE_KEY,
|
|
3996
|
+
Oi as ResizePlugin,
|
|
3997
|
+
ai as StickerPlugin,
|
|
3998
|
+
bo as TextPlugin,
|
|
3999
|
+
Ie as applyClarity,
|
|
4000
|
+
Ae as applyColorMatrix,
|
|
4001
|
+
Re as applyGamma,
|
|
4002
|
+
ze as applyVignette,
|
|
4003
|
+
Tt as ar,
|
|
4004
|
+
Qe as brightnessMatrix,
|
|
4005
|
+
Ge as composeMatrices,
|
|
4006
|
+
et as contrastMatrix,
|
|
4007
|
+
$e as createDefaultImageState,
|
|
4008
|
+
kt as createEditorEngine,
|
|
4009
|
+
To as default,
|
|
4010
|
+
xe as defaultStickerCategories,
|
|
4011
|
+
Io as deserializeState,
|
|
4012
|
+
Pt as en,
|
|
4013
|
+
nt as exposureMatrix,
|
|
4014
|
+
be as filterPresets,
|
|
4015
|
+
Tn as finetuneEffects,
|
|
4016
|
+
si as frameStyles,
|
|
4017
|
+
$o as install,
|
|
4018
|
+
yt as loadImage,
|
|
4019
|
+
Po as mergeWithDefaults,
|
|
4020
|
+
Mt as multiplyMatrices,
|
|
4021
|
+
tt as saturationMatrix,
|
|
4022
|
+
zo as serializeState,
|
|
4023
|
+
it as temperatureMatrix,
|
|
4024
|
+
ee as useEditor
|
|
3440
4025
|
};
|
|
3441
4026
|
//# sourceMappingURL=vuedit-image-editor.es.js.map
|