ablok-components 0.3.77 → 0.3.78
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,29 +1,29 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { debounce as
|
|
1
|
+
import { defineComponent as at, ref as u, computed as h, watch as Ie, onMounted as it, nextTick as nt, onBeforeUnmount as ot, openBlock as y, createElementBlock as b, normalizeClass as de, createElementVNode as p, createVNode as ve, withCtx as lt, createCommentVNode as R, withDirectives as xe, normalizeStyle as he, vShow as Re, toDisplayString as me, createBlock as rt, withModifiers as st } from "vue";
|
|
2
|
+
import { debounce as ut } from "lodash";
|
|
3
3
|
import ct from "../../atoms/loading-spinner/loading-spinner.vue.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import
|
|
5
|
+
import dt from "../../atoms/svg-icon/svg-icon.vue.js";
|
|
6
6
|
/* empty css */
|
|
7
|
-
import
|
|
7
|
+
import vt from "../input-dropdown/input-dropdown.vue.js";
|
|
8
8
|
/* empty css */
|
|
9
|
-
import { dataURItoBlob as
|
|
10
|
-
import { useCameraFilter as
|
|
11
|
-
import
|
|
9
|
+
import { dataURItoBlob as ht } from "../../../utilities/helpers.js";
|
|
10
|
+
import { useCameraFilter as mt } from "../../../composables/useCameraFilter.js";
|
|
11
|
+
import ft from "../../atoms/zoom-slider/zoom-slider.vue.js";
|
|
12
12
|
/* empty css */
|
|
13
|
-
import
|
|
14
|
-
const wt = { class: "camera__preview" },
|
|
13
|
+
import gt from "../../../assets/img/guide.png.js";
|
|
14
|
+
const wt = { class: "camera__preview" }, pt = {
|
|
15
15
|
key: 0,
|
|
16
16
|
class: "camera__bg-notification"
|
|
17
|
-
},
|
|
17
|
+
}, yt = ["innerHTML"], bt = ["width", "height"], _t = {
|
|
18
18
|
key: 1,
|
|
19
19
|
class: "camera__countdown-overlay"
|
|
20
|
-
},
|
|
20
|
+
}, Et = ["innerHTML", "data-countdown"], Ct = ["src"], St = {
|
|
21
21
|
key: 3,
|
|
22
22
|
class: "camera__zoom-slider"
|
|
23
|
-
},
|
|
23
|
+
}, kt = { class: "camera__controls" }, Dt = { class: "container" }, Mt = { class: "row" }, It = { class: "col" }, xt = { class: "btn-group" }, Rt = { key: 0 }, Ot = { key: 1 }, Lt = {
|
|
24
24
|
key: 0,
|
|
25
25
|
class: "camera__select-device"
|
|
26
|
-
},
|
|
26
|
+
}, Tt = { class: "col" }, At = { class: "" }, zt = {
|
|
27
27
|
name: "BaseCamera",
|
|
28
28
|
inheritAttrs: !1
|
|
29
29
|
}, Oe = {
|
|
@@ -36,8 +36,8 @@ const wt = { class: "camera__preview" }, gt = {
|
|
|
36
36
|
"5x4": { width: 1200, height: 960 },
|
|
37
37
|
"16x9": { width: 1280, height: 720 },
|
|
38
38
|
"9x16": { width: 720, height: 1280 }
|
|
39
|
-
},
|
|
40
|
-
...
|
|
39
|
+
}, Xt = /* @__PURE__ */ at({
|
|
40
|
+
...zt,
|
|
41
41
|
props: {
|
|
42
42
|
modelValue: {
|
|
43
43
|
type: null
|
|
@@ -60,7 +60,7 @@ const wt = { class: "camera__preview" }, gt = {
|
|
|
60
60
|
},
|
|
61
61
|
guideSrc: {
|
|
62
62
|
type: String,
|
|
63
|
-
default: () =>
|
|
63
|
+
default: () => gt
|
|
64
64
|
},
|
|
65
65
|
countdown: {
|
|
66
66
|
type: Number,
|
|
@@ -73,7 +73,7 @@ const wt = { class: "camera__preview" }, gt = {
|
|
|
73
73
|
filter: {
|
|
74
74
|
type: String,
|
|
75
75
|
default: "none",
|
|
76
|
-
validator: (
|
|
76
|
+
validator: (m) => ["none", "grayscale", "sepia"].includes(m)
|
|
77
77
|
},
|
|
78
78
|
tintColor: {
|
|
79
79
|
type: String,
|
|
@@ -113,422 +113,418 @@ const wt = { class: "camera__preview" }, gt = {
|
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
115
|
emits: ["update:modelValue"],
|
|
116
|
-
setup(
|
|
117
|
-
const
|
|
118
|
-
let
|
|
119
|
-
const
|
|
116
|
+
setup(m, { expose: Le, emit: Te }) {
|
|
117
|
+
const r = m, Ae = Te, n = u(), o = u(), fe = u(!1), W = u([]), c = u(), O = u(), j = u(), L = u(!1), K = u(!1), X = u(0), J = u(0), k = u(), d = u(r.zoom || 1), ge = u(!1), V = u(!1), ae = u(null), ie = u(!1);
|
|
118
|
+
let $, D;
|
|
119
|
+
const ze = typeof window < "u" && "DeviceMotionEvent" in window && (window.matchMedia?.("(pointer: coarse)")?.matches || "ontouchstart" in window), we = h(() => r.correctOrientation && ze), ne = h(() => fe.value && (!we.value || ie.value));
|
|
120
120
|
function oe() {
|
|
121
|
-
|
|
121
|
+
D && (window.removeEventListener("pointerdown", D, !0), window.removeEventListener("touchend", D, !0), D = void 0);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
ie.value = !0,
|
|
123
|
+
function Q() {
|
|
124
|
+
ie.value = !0, $ && (clearTimeout($), $ = void 0), oe();
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
126
|
+
function Ve() {
|
|
127
|
+
D || (D = () => {
|
|
128
128
|
le();
|
|
129
|
-
}, window.addEventListener("pointerdown",
|
|
129
|
+
}, window.addEventListener("pointerdown", D, !0), window.addEventListener("touchend", D, !0));
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function pe(e) {
|
|
132
132
|
const t = e.accelerationIncludingGravity;
|
|
133
133
|
if (!t || t.x == null || t.y == null) return;
|
|
134
134
|
const a = Math.round(Math.atan2(t.x, t.y) * 180 / Math.PI);
|
|
135
135
|
if (ae.value = a, !(typeof screen < "u" && screen.orientation && screen.orientation.type || "portrait-primary").startsWith("portrait"))
|
|
136
|
-
|
|
136
|
+
V.value = !1;
|
|
137
137
|
else {
|
|
138
|
-
const
|
|
139
|
-
!
|
|
138
|
+
const g = Math.abs(Math.abs(a) - 90);
|
|
139
|
+
!V.value && g < 40 ? V.value = !0 : V.value && g > 50 && (V.value = !1);
|
|
140
140
|
}
|
|
141
|
-
ie.value ||
|
|
141
|
+
ie.value || Q();
|
|
142
142
|
}
|
|
143
143
|
async function le() {
|
|
144
|
-
if (!(!
|
|
144
|
+
if (!(!r.correctOrientation || ge.value))
|
|
145
145
|
try {
|
|
146
146
|
const e = window.DeviceOrientationEvent, t = window.DeviceMotionEvent;
|
|
147
147
|
if (e && typeof e.requestPermission == "function" && await e.requestPermission() !== "granted") {
|
|
148
|
-
|
|
148
|
+
Q();
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
t && typeof t.requestPermission == "function" && await t.requestPermission().catch(() => {
|
|
152
|
-
}), window.addEventListener("devicemotion",
|
|
152
|
+
}), window.addEventListener("devicemotion", pe, !0), ge.value = !0, oe();
|
|
153
153
|
} catch (e) {
|
|
154
|
-
console.error(e, "enableMotion: failed"),
|
|
154
|
+
console.error(e, "enableMotion: failed"), Q();
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
const
|
|
158
|
-
function
|
|
157
|
+
const G = h(() => ({ ...Oe, ...r.resolutions })), $e = h(() => Object.values(G.value)[0]);
|
|
158
|
+
function Be(e) {
|
|
159
159
|
return String(e || "").trim().toLowerCase().replace(/\s+/g, "").replace(/[:/]/g, "x");
|
|
160
160
|
}
|
|
161
|
-
const
|
|
162
|
-
if (
|
|
163
|
-
return
|
|
164
|
-
const e =
|
|
165
|
-
if (
|
|
161
|
+
const M = h(() => {
|
|
162
|
+
if (G.value[r.ratio])
|
|
163
|
+
return r.ratio;
|
|
164
|
+
const e = Be(r.ratio);
|
|
165
|
+
if (G.value[e])
|
|
166
166
|
return e;
|
|
167
|
-
}),
|
|
168
|
-
const e =
|
|
167
|
+
}), T = h(() => M.value ? G.value[M.value] : $e.value), He = h(() => {
|
|
168
|
+
const e = M.value ? G.value[M.value] : void 0;
|
|
169
169
|
return e ? `${e.width} / ${e.height}` : void 0;
|
|
170
|
-
}),
|
|
171
|
-
function
|
|
172
|
-
e && !
|
|
170
|
+
}), I = h(() => W.value.filter((e) => e.kind === "videoinput")), ye = h(() => W.value.filter((e) => e.kind === "audioinput")), N = u([]), re = h(() => I.value.filter((e) => !N.value.includes(e.deviceId)));
|
|
171
|
+
function Ue(e) {
|
|
172
|
+
e && !N.value.includes(e) && (N.value = [...N.value, e]);
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
const t =
|
|
174
|
+
function be(e) {
|
|
175
|
+
const t = I.value;
|
|
176
176
|
if (!t.length) return;
|
|
177
|
-
const a = t.findIndex((
|
|
178
|
-
for (let
|
|
179
|
-
const
|
|
180
|
-
if (
|
|
181
|
-
return
|
|
177
|
+
const a = t.findIndex((l) => l.deviceId === e);
|
|
178
|
+
for (let l = 1; l <= t.length; l++) {
|
|
179
|
+
const f = t[(Math.max(a, 0) + l) % t.length];
|
|
180
|
+
if (f && !N.value.includes(f.deviceId))
|
|
181
|
+
return f;
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
const
|
|
184
|
+
const We = h(() => re.value.map((e, t) => ({
|
|
185
185
|
text: e.label.slice(0, e.label.indexOf("(")) || `Camera ${t + 1}`,
|
|
186
186
|
value: e.deviceId
|
|
187
|
-
}))),
|
|
187
|
+
}))), _e = h({
|
|
188
188
|
get() {
|
|
189
189
|
return c.value && c.value.deviceId;
|
|
190
190
|
},
|
|
191
191
|
set(e) {
|
|
192
|
-
c.value =
|
|
192
|
+
c.value = I.value.find((t) => t.deviceId === e), j.value = void 0;
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
|
-
|
|
195
|
+
h({
|
|
196
196
|
get() {
|
|
197
197
|
return O.value && O.value.deviceId;
|
|
198
198
|
},
|
|
199
199
|
set(e) {
|
|
200
|
-
O.value =
|
|
200
|
+
O.value = ye.value.find((t) => t.deviceId === e);
|
|
201
201
|
}
|
|
202
202
|
});
|
|
203
|
-
const
|
|
204
|
-
const e = c.value &&
|
|
205
|
-
return
|
|
206
|
-
}),
|
|
207
|
-
const e = c.value &&
|
|
208
|
-
return
|
|
209
|
-
}), { tintRgb:
|
|
210
|
-
function
|
|
211
|
-
if (
|
|
212
|
-
|
|
203
|
+
const B = h(() => {
|
|
204
|
+
const e = c.value && I.value.findIndex((t) => t.deviceId === c.value?.deviceId);
|
|
205
|
+
return r.enableMirrorCamera && e === 0 ? "mirror-cam" : "";
|
|
206
|
+
}), je = h(() => {
|
|
207
|
+
const e = c.value && W.value.findIndex((t) => t.deviceId === c.value?.deviceId);
|
|
208
|
+
return B.value ? `${B.value} mirror-device-${e}` : "";
|
|
209
|
+
}), { tintRgb: Vt, applyFilterToCanvas: Ee } = mt(r);
|
|
210
|
+
function Ce() {
|
|
211
|
+
if (M.value && T.value) {
|
|
212
|
+
X.value = T.value.width, J.value = T.value.height;
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
|
-
|
|
215
|
+
X.value = n.value.parentElement && n.value.parentElement.clientWidth, J.value = n.value.parentElement && n.value.parentElement.clientHeight;
|
|
216
216
|
}
|
|
217
|
-
const
|
|
218
|
-
|
|
217
|
+
const Se = ut(() => {
|
|
218
|
+
Ce();
|
|
219
219
|
}, 300, { trailing: !0, leading: !1 });
|
|
220
|
-
function
|
|
220
|
+
function se(e) {
|
|
221
221
|
return new Promise((t) => setTimeout(t, e));
|
|
222
222
|
}
|
|
223
|
-
async function
|
|
224
|
-
const e =
|
|
223
|
+
async function Ge() {
|
|
224
|
+
const e = T.value ? { width: T.value.width, height: T.value.height } : void 0, t = e ? Math.max(e.width, e.height) : void 0, a = e ? Math.min(e.width, e.height) : void 0, l = r.enableAudio && {
|
|
225
225
|
...O.value ? { deviceId: O.value.deviceId } : {}
|
|
226
226
|
// deviceId: activeAudioDevice.value ? { exact: activeAudioDevice.value } : undefined
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
for (const
|
|
230
|
-
for (let
|
|
227
|
+
}, f = c.value && c.value.deviceId, g = j.value, i = [];
|
|
228
|
+
f ? (t && a && i.push({ deviceId: { exact: f }, width: { ideal: t }, height: { ideal: a } }), i.push({ deviceId: { exact: f } })) : g ? (t && a && i.push({ facingMode: { exact: g }, width: { ideal: t }, height: { ideal: a } }), i.push({ facingMode: { exact: g } }), t && a && i.push({ width: { ideal: t }, height: { ideal: a } }), i.push({})) : (t && a && i.push({ width: { ideal: t }, height: { ideal: a } }), i.push({}));
|
|
229
|
+
for (const s of i)
|
|
230
|
+
for (let v = 0; v < 5; v++)
|
|
231
231
|
try {
|
|
232
|
-
return await navigator.mediaDevices.getUserMedia({ audio:
|
|
233
|
-
} catch (
|
|
234
|
-
const
|
|
235
|
-
if (
|
|
236
|
-
await
|
|
232
|
+
return await navigator.mediaDevices.getUserMedia({ audio: l, video: s });
|
|
233
|
+
} catch (z) {
|
|
234
|
+
const C = z && z.name;
|
|
235
|
+
if (C === "NotReadableError" || C === "AbortError") {
|
|
236
|
+
await se(500);
|
|
237
237
|
continue;
|
|
238
238
|
}
|
|
239
239
|
break;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
function Y() {
|
|
243
|
-
|
|
243
|
+
n.value && n.value.srcObject && (n.value.srcObject.getTracks().forEach((t) => {
|
|
244
244
|
t.stop();
|
|
245
|
-
}),
|
|
245
|
+
}), n.value.srcObject = null);
|
|
246
246
|
}
|
|
247
|
-
let
|
|
248
|
-
const
|
|
249
|
-
let
|
|
250
|
-
function
|
|
251
|
-
|
|
247
|
+
let A = 0;
|
|
248
|
+
const Ne = 350, Pe = 8e3;
|
|
249
|
+
let P, ee;
|
|
250
|
+
function H() {
|
|
251
|
+
P && (clearTimeout(P), P = void 0), ee && (ee(), ee = void 0);
|
|
252
252
|
}
|
|
253
|
-
function
|
|
254
|
-
|
|
255
|
-
const t =
|
|
253
|
+
function Fe(e) {
|
|
254
|
+
Ue(e);
|
|
255
|
+
const t = be(e);
|
|
256
256
|
t && t.deviceId !== e && (c.value = t);
|
|
257
257
|
}
|
|
258
|
-
function
|
|
259
|
-
|
|
260
|
-
const t = c.value && c.value.deviceId, a =
|
|
258
|
+
function qe(e) {
|
|
259
|
+
H();
|
|
260
|
+
const t = c.value && c.value.deviceId, a = n.value;
|
|
261
261
|
if (!t || !a) return;
|
|
262
|
-
const
|
|
263
|
-
if (!
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
},
|
|
269
|
-
e ===
|
|
270
|
-
},
|
|
271
|
-
|
|
262
|
+
const l = a.srcObject && a.srcObject.getVideoTracks?.()[0];
|
|
263
|
+
if (!l || !(typeof l.addEventListener == "function") || a.videoWidth > 0) return;
|
|
264
|
+
const g = () => {
|
|
265
|
+
if (H(), e !== A || !n.value) return;
|
|
266
|
+
const v = be(t);
|
|
267
|
+
v && v.deviceId !== t && (Y(), Fe(t));
|
|
268
|
+
}, i = () => {
|
|
269
|
+
e === A && n.value && n.value.videoWidth > 0 && H();
|
|
270
|
+
}, s = () => {
|
|
271
|
+
g();
|
|
272
272
|
};
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
},
|
|
276
|
-
|
|
277
|
-
},
|
|
273
|
+
l.addEventListener("unmute", i), l.addEventListener("ended", s), ee = () => {
|
|
274
|
+
l.removeEventListener("unmute", i), l.removeEventListener("ended", s);
|
|
275
|
+
}, P = setTimeout(() => {
|
|
276
|
+
P = void 0, !(e !== A || !n.value) && (n.value.videoWidth === 0 ? g() : H());
|
|
277
|
+
}, Pe);
|
|
278
278
|
}
|
|
279
|
-
const
|
|
280
|
-
let
|
|
281
|
-
async function
|
|
282
|
-
const e = ++
|
|
283
|
-
|
|
284
|
-
const t = !!(
|
|
285
|
-
if (Y(), t && (await
|
|
279
|
+
const Ze = 2;
|
|
280
|
+
let ue = 0;
|
|
281
|
+
async function U() {
|
|
282
|
+
const e = ++A;
|
|
283
|
+
H();
|
|
284
|
+
const t = !!(n.value && n.value.srcObject);
|
|
285
|
+
if (Y(), t && (await se(Ne), e !== A))
|
|
286
286
|
return;
|
|
287
|
-
const a = await
|
|
288
|
-
if (e !==
|
|
289
|
-
a?.getTracks?.().forEach((
|
|
287
|
+
const a = await Ge();
|
|
288
|
+
if (e !== A) {
|
|
289
|
+
a?.getTracks?.().forEach((l) => l.stop());
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
|
-
if (a &&
|
|
293
|
-
|
|
292
|
+
if (a && n.value) {
|
|
293
|
+
ue = 0, n.value.srcObject = a, n.value.muted = !0;
|
|
294
294
|
try {
|
|
295
|
-
await
|
|
295
|
+
await n.value.play?.();
|
|
296
296
|
} catch {
|
|
297
297
|
}
|
|
298
|
-
|
|
298
|
+
qe(e);
|
|
299
299
|
} else if (!a && c.value) {
|
|
300
|
-
|
|
300
|
+
ue < Ze && (ue++, await se(600), e === A && await U());
|
|
301
301
|
return;
|
|
302
302
|
}
|
|
303
|
-
return
|
|
304
|
-
}
|
|
305
|
-
function Ze() {
|
|
306
|
-
R.value ? (R.value = !1, Z.value = !1, Y()) : (R.value = !0, N());
|
|
303
|
+
return W.value = await navigator.mediaDevices.enumerateDevices(), { stream: n.value && n.value.srcObject, devices: W.value };
|
|
307
304
|
}
|
|
308
305
|
function Ke() {
|
|
309
|
-
|
|
310
|
-
if (e.length > 1) {
|
|
311
|
-
const t = e.findIndex((a) => a.deviceId === c.value?.deviceId);
|
|
312
|
-
c.value = e[t === e.length - 1 ? 0 : t + 1];
|
|
313
|
-
}
|
|
306
|
+
L.value ? (L.value = !1, K.value = !1, Y()) : (L.value = !0, U());
|
|
314
307
|
}
|
|
315
|
-
|
|
316
|
-
|
|
308
|
+
function Xe() {
|
|
309
|
+
c.value = void 0, j.value = j.value === "user" ? "environment" : "user", U();
|
|
317
310
|
}
|
|
318
|
-
|
|
311
|
+
async function ke(e, t) {
|
|
312
|
+
e && (!t || e.deviceId !== t.deviceId) && await U();
|
|
313
|
+
}
|
|
314
|
+
Ie(() => c.value, ke), Ie(() => O.value, ke);
|
|
319
315
|
function ce() {
|
|
320
|
-
|
|
316
|
+
r.countdown ? (k.value = k.value ? k.value - 1 : r.countdown, k.value ? setTimeout(ce, 1e3) : De()) : De();
|
|
321
317
|
}
|
|
322
|
-
|
|
323
|
-
function
|
|
324
|
-
if (!
|
|
318
|
+
Le({ onCapture: ce, enableMotion: le, camera: n.value, zoom: d });
|
|
319
|
+
function Je() {
|
|
320
|
+
if (!r.correctOrientation || ae.value == null) return 0;
|
|
325
321
|
const e = ((ae.value - 180) % 360 + 360) % 360;
|
|
326
322
|
return (-1 * (Math.round(e / 90) * 90 % 360) % 360 + 360) % 360;
|
|
327
323
|
}
|
|
328
|
-
function
|
|
329
|
-
const
|
|
330
|
-
e.translate(
|
|
331
|
-
const
|
|
332
|
-
e.drawImage(t, -
|
|
324
|
+
function Qe(e, t, a, l, f) {
|
|
325
|
+
const g = o.value.width, i = o.value.height;
|
|
326
|
+
e.translate(g / 2, i / 2), B.value && e.scale(-1, 1), e.rotate(a * Math.PI / 180);
|
|
327
|
+
const s = i, v = g, C = Math.max(s / l, v / f) * (d.value && d.value > 0 ? d.value : 1), F = l * C, S = f * C;
|
|
328
|
+
e.drawImage(t, -F / 2, -S / 2, F, S);
|
|
333
329
|
}
|
|
334
|
-
function
|
|
335
|
-
|
|
336
|
-
const e =
|
|
337
|
-
if (
|
|
330
|
+
function De() {
|
|
331
|
+
K.value = !0;
|
|
332
|
+
const e = o.value.getContext("2d"), t = n.value, a = t && t.srcObject && t.srcObject.getTracks(), { aspectRatio: l, width: f, height: g } = a.length && a[0].getSettings(), i = t?.videoWidth || f || X.value, s = t?.videoHeight || g || J.value, v = i && s ? i / s : l, z = T.value || { width: i, height: s }, C = z?.width || i, F = M.value ? z?.height || s : Math.round(C / v), S = C / F;
|
|
333
|
+
if (o.value.width = C, o.value.height = F, !i || !s || !v)
|
|
338
334
|
return;
|
|
339
|
-
const te =
|
|
335
|
+
const te = Je();
|
|
340
336
|
if (e.save(), te === 90 || te === 270) {
|
|
341
|
-
|
|
337
|
+
Qe(e, t, te, i, s), e.restore(), Ee(e, o.value.width, o.value.height), Me(o.value.toDataURL("image/png"));
|
|
342
338
|
return;
|
|
343
339
|
}
|
|
344
|
-
if (te === 180 && (e.translate(
|
|
345
|
-
let _ = 0,
|
|
346
|
-
if (
|
|
347
|
-
const
|
|
348
|
-
_ += (
|
|
340
|
+
if (te === 180 && (e.translate(o.value.width, o.value.height), e.scale(-1, -1)), B.value && (e.translate(o.value.width, 0), e.scale(-1, 1)), r.enableCropImage) {
|
|
341
|
+
let _ = 0, x = 0, w = i, E = s;
|
|
342
|
+
if (v > S ? (w = s * S, _ = (i - w) / 2) : v < S && (E = i / S, x = (s - E) / 2), d.value && d.value !== 1) {
|
|
343
|
+
const q = w / d.value, Z = E / d.value;
|
|
344
|
+
_ += (w - q) / 2, x += (E - Z) / 2, w = q, E = Z;
|
|
349
345
|
}
|
|
350
346
|
e.drawImage(
|
|
351
347
|
t,
|
|
352
348
|
_,
|
|
353
|
-
|
|
354
|
-
|
|
349
|
+
x,
|
|
350
|
+
w,
|
|
355
351
|
E,
|
|
356
352
|
0,
|
|
357
353
|
0,
|
|
358
|
-
|
|
359
|
-
|
|
354
|
+
o.value.width,
|
|
355
|
+
o.value.height
|
|
360
356
|
);
|
|
361
357
|
} else {
|
|
362
|
-
let _ =
|
|
363
|
-
if (
|
|
364
|
-
const
|
|
365
|
-
|
|
358
|
+
let _ = o.value.width, x = o.value.height, w = 0, E = 0;
|
|
359
|
+
if (v > S ? (x = o.value.width / v, E = (o.value.height - x) / 2) : v < S && (_ = o.value.height * v, w = (o.value.width - _) / 2), d.value && d.value !== 1) {
|
|
360
|
+
const q = i / d.value, Z = s / d.value, et = (i - q) / 2, tt = (s - Z) / 2;
|
|
361
|
+
B.value && (w = o.value.width - w - _), e.drawImage(
|
|
366
362
|
t,
|
|
367
|
-
Ye,
|
|
368
363
|
et,
|
|
369
|
-
|
|
364
|
+
tt,
|
|
370
365
|
q,
|
|
371
|
-
|
|
366
|
+
Z,
|
|
367
|
+
w,
|
|
372
368
|
E,
|
|
373
369
|
_,
|
|
374
|
-
|
|
370
|
+
x
|
|
375
371
|
);
|
|
376
372
|
} else
|
|
377
|
-
|
|
373
|
+
B.value && (w = o.value.width - w - _), e.drawImage(
|
|
378
374
|
t,
|
|
379
375
|
0,
|
|
380
376
|
0,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
377
|
+
i,
|
|
378
|
+
s,
|
|
379
|
+
w,
|
|
384
380
|
E,
|
|
385
381
|
_,
|
|
386
|
-
|
|
382
|
+
x
|
|
387
383
|
);
|
|
388
384
|
}
|
|
389
|
-
e.restore(),
|
|
390
|
-
const
|
|
391
|
-
|
|
385
|
+
e.restore(), Ee(e, o.value.width, o.value.height);
|
|
386
|
+
const Ye = o.value.toDataURL("image/png");
|
|
387
|
+
Me(Ye);
|
|
392
388
|
}
|
|
393
|
-
function
|
|
394
|
-
const t =
|
|
395
|
-
|
|
389
|
+
function Me(e) {
|
|
390
|
+
const t = ht(e);
|
|
391
|
+
Ae("update:modelValue", {
|
|
396
392
|
name: `cam-pic-${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
397
393
|
id: `cam-pic-${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
398
394
|
blob: t,
|
|
399
395
|
size: t.size
|
|
400
396
|
});
|
|
401
397
|
}
|
|
402
|
-
return
|
|
403
|
-
await
|
|
404
|
-
const e =
|
|
405
|
-
if (c.value = e,
|
|
406
|
-
await
|
|
407
|
-
}), window.addEventListener("resize",
|
|
408
|
-
|
|
398
|
+
return it(async () => {
|
|
399
|
+
await U(), L.value = !0, j.value = r.defaultRearCamera ? "environment" : "user";
|
|
400
|
+
const e = r.defaultRearCamera && I.value.length > 1 ? I.value[I.value.length - 1] : I.value[0];
|
|
401
|
+
if (c.value = e, r.enableAudio && (O.value = ye.value[0]), navigator.mediaDevices.addEventListener("devicechange", async (t) => {
|
|
402
|
+
await U();
|
|
403
|
+
}), window.addEventListener("resize", Se), Ce(), we.value) {
|
|
404
|
+
$ = setTimeout(Q, 3e3);
|
|
409
405
|
const t = window.DeviceOrientationEvent;
|
|
410
|
-
t && typeof t.requestPermission == "function" ?
|
|
406
|
+
t && typeof t.requestPermission == "function" ? Ve() : le();
|
|
411
407
|
}
|
|
412
|
-
await
|
|
413
|
-
}),
|
|
414
|
-
|
|
408
|
+
await nt(), fe.value = !0;
|
|
409
|
+
}), ot(() => {
|
|
410
|
+
L.value = !1, K.value = !1, H(), Y(), window.removeEventListener("resize", Se), window.removeEventListener("devicemotion", pe, !0), $ && clearTimeout($), oe();
|
|
415
411
|
}), (e, t) => (y(), b("div", {
|
|
416
|
-
class:
|
|
412
|
+
class: de(["camera", je.value])
|
|
417
413
|
}, [
|
|
418
414
|
p("div", wt, [
|
|
419
|
-
ne.value ?
|
|
420
|
-
|
|
421
|
-
default:
|
|
415
|
+
ne.value ? R("", !0) : (y(), b("div", pt, [
|
|
416
|
+
ve(ct, { color: "#000" }, {
|
|
417
|
+
default: lt(() => [
|
|
422
418
|
p("span", {
|
|
423
|
-
class:
|
|
419
|
+
class: de("d-block text-center"),
|
|
424
420
|
innerHTML: e.$t("camera.waitForCameraNotification")
|
|
425
|
-
}, null, 8,
|
|
421
|
+
}, null, 8, yt)
|
|
426
422
|
]),
|
|
427
423
|
_: 1
|
|
428
424
|
})
|
|
429
425
|
])),
|
|
430
|
-
|
|
431
|
-
class:
|
|
432
|
-
style:
|
|
426
|
+
xe(p("div", {
|
|
427
|
+
class: de(["camera__video-wrapper", M.value ? `aspect-ratio--${M.value}` : ""]),
|
|
428
|
+
style: he({ aspectRatio: He.value || void 0, transform: d.value !== 1 ? `scale(${d.value})` : void 0 })
|
|
433
429
|
}, [
|
|
434
430
|
p("video", {
|
|
435
431
|
ref_key: "camera",
|
|
436
|
-
ref:
|
|
432
|
+
ref: n,
|
|
437
433
|
class: "camera__video",
|
|
438
|
-
style:
|
|
439
|
-
filter:
|
|
440
|
-
transform:
|
|
434
|
+
style: he({
|
|
435
|
+
filter: r.filter === "grayscale" ? "grayscale(100%)" : r.filter === "sepia" ? "sepia(100%)" : "none",
|
|
436
|
+
transform: m.correctOrientation && V.value ? "rotate(180deg)" : void 0
|
|
441
437
|
}),
|
|
442
438
|
autoplay: "",
|
|
443
439
|
muted: "",
|
|
444
440
|
playsinline: ""
|
|
445
441
|
}, null, 4),
|
|
446
|
-
|
|
442
|
+
m.tintColor ? (y(), b("div", {
|
|
447
443
|
key: 0,
|
|
448
444
|
class: "camera__tint-overlay",
|
|
449
|
-
style:
|
|
450
|
-
backgroundColor:
|
|
451
|
-
opacity:
|
|
445
|
+
style: he({
|
|
446
|
+
backgroundColor: m.tintColor,
|
|
447
|
+
opacity: m.tintIntensity,
|
|
452
448
|
mixBlendMode: "multiply"
|
|
453
449
|
})
|
|
454
|
-
}, null, 4)) :
|
|
450
|
+
}, null, 4)) : R("", !0)
|
|
455
451
|
], 6), [
|
|
456
|
-
[
|
|
452
|
+
[Re, ne.value]
|
|
457
453
|
]),
|
|
458
|
-
|
|
454
|
+
xe(p("canvas", {
|
|
459
455
|
ref_key: "canvas",
|
|
460
|
-
ref:
|
|
456
|
+
ref: o,
|
|
461
457
|
class: "camera__canvas",
|
|
462
|
-
width:
|
|
463
|
-
height:
|
|
464
|
-
}, null, 8,
|
|
465
|
-
[
|
|
458
|
+
width: X.value,
|
|
459
|
+
height: J.value
|
|
460
|
+
}, null, 8, bt), [
|
|
461
|
+
[Re, K.value]
|
|
466
462
|
]),
|
|
467
|
-
|
|
463
|
+
k.value ? (y(), b("div", _t, [
|
|
468
464
|
(y(), b("p", {
|
|
469
465
|
class: "countdown",
|
|
470
|
-
key:
|
|
471
|
-
innerHTML:
|
|
472
|
-
"data-countdown":
|
|
473
|
-
}, null, 8,
|
|
474
|
-
])) :
|
|
475
|
-
|
|
466
|
+
key: k.value,
|
|
467
|
+
innerHTML: k.value,
|
|
468
|
+
"data-countdown": k.value
|
|
469
|
+
}, null, 8, Et))
|
|
470
|
+
])) : R("", !0),
|
|
471
|
+
m.enableGuide && L.value && ne.value ? (y(), b("img", {
|
|
476
472
|
key: 2,
|
|
477
473
|
class: "camera__guide",
|
|
478
|
-
src:
|
|
479
|
-
}, null, 8,
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
modelValue:
|
|
483
|
-
"onUpdate:modelValue": t[0] || (t[0] = (a) =>
|
|
474
|
+
src: m.guideSrc
|
|
475
|
+
}, null, 8, Ct)) : R("", !0),
|
|
476
|
+
m.enableZoomSlider ? (y(), b("div", St, [
|
|
477
|
+
ve(ft, {
|
|
478
|
+
modelValue: d.value,
|
|
479
|
+
"onUpdate:modelValue": t[0] || (t[0] = (a) => d.value = a)
|
|
484
480
|
}, null, 8, ["modelValue"])
|
|
485
|
-
])) :
|
|
481
|
+
])) : R("", !0)
|
|
486
482
|
]),
|
|
487
|
-
p("div",
|
|
488
|
-
p("div",
|
|
489
|
-
p("div",
|
|
490
|
-
p("div",
|
|
491
|
-
p("div",
|
|
483
|
+
p("div", kt, [
|
|
484
|
+
p("div", Dt, [
|
|
485
|
+
p("div", Mt, [
|
|
486
|
+
p("div", It, [
|
|
487
|
+
p("div", xt, [
|
|
492
488
|
p("button", {
|
|
493
489
|
type: "button",
|
|
494
490
|
class: "camera__toggle btn btn-primary",
|
|
495
|
-
onClick:
|
|
491
|
+
onClick: Ke
|
|
496
492
|
}, [
|
|
497
|
-
|
|
493
|
+
L.value ? (y(), b("span", Ot, me(e.$t("common.pause")), 1)) : (y(), b("span", Rt, me(e.$t("common.play")), 1))
|
|
498
494
|
]),
|
|
499
495
|
p("button", {
|
|
500
496
|
type: "button",
|
|
501
497
|
class: "camera__capture btn btn-primary",
|
|
502
498
|
onClick: ce
|
|
503
|
-
},
|
|
499
|
+
}, me(e.$t("camera.capture")), 1)
|
|
504
500
|
])
|
|
505
501
|
])
|
|
506
502
|
])
|
|
507
503
|
])
|
|
508
504
|
]),
|
|
509
|
-
(
|
|
510
|
-
p("div",
|
|
511
|
-
|
|
505
|
+
(m.enableSwitchCamera || m.enableSelectDevice) && re.value && re.value.length > 1 ? (y(), b("div", Lt, [
|
|
506
|
+
p("div", Tt, [
|
|
507
|
+
m.enableSelectDevice ? (y(), rt(vt, {
|
|
512
508
|
key: 0,
|
|
513
|
-
modelValue:
|
|
514
|
-
"onUpdate:modelValue": t[1] || (t[1] = (a) =>
|
|
515
|
-
options:
|
|
509
|
+
modelValue: _e.value,
|
|
510
|
+
"onUpdate:modelValue": t[1] || (t[1] = (a) => _e.value = a),
|
|
511
|
+
options: We.value,
|
|
516
512
|
class: "w-100"
|
|
517
|
-
}, null, 8, ["modelValue", "options"])) :
|
|
513
|
+
}, null, 8, ["modelValue", "options"])) : R("", !0)
|
|
518
514
|
]),
|
|
519
|
-
p("div",
|
|
520
|
-
|
|
515
|
+
p("div", At, [
|
|
516
|
+
m.enableSwitchCamera ? (y(), b("button", {
|
|
521
517
|
key: 0,
|
|
522
518
|
class: "btn",
|
|
523
|
-
onClick:
|
|
519
|
+
onClick: st(Xe, ["prevent"])
|
|
524
520
|
}, [
|
|
525
|
-
|
|
526
|
-
])) :
|
|
521
|
+
ve(dt, { symbol: "switch-camera" })
|
|
522
|
+
])) : R("", !0)
|
|
527
523
|
])
|
|
528
|
-
])) :
|
|
524
|
+
])) : R("", !0)
|
|
529
525
|
], 2));
|
|
530
526
|
}
|
|
531
527
|
});
|
|
532
528
|
export {
|
|
533
|
-
|
|
529
|
+
Xt as default
|
|
534
530
|
};
|