ablok-components 0.3.74 → 0.3.76

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