ablok-components 0.3.72 → 0.3.74

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