@exige/web-scanner-sdk 0.2.28 → 0.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/assets/zxing-wasm.LICENSE +21 -0
- package/dist/assets/zxing-wasm.NOTICE +4 -0
- package/dist/assets/zxing_reader.wasm +0 -0
- package/dist/assets-manifest.json +2 -1
- package/dist/driver-license-DpjQqOKx.js +2876 -0
- package/dist/driver-license-DpjQqOKx.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/react/context.d.ts +1 -1
- package/dist/react/types.d.ts +23 -2
- package/dist/react.d.ts +1 -1
- package/dist/react.js +427 -331
- package/dist/react.js.map +1 -1
- package/dist/scanner-sdk.js +17 -924
- package/dist/scanner-sdk.js.map +1 -1
- package/dist/sdk/aamva.d.ts +58 -0
- package/dist/sdk/barcode.d.ts +12 -0
- package/dist/sdk/driver-license.d.ts +63 -0
- package/dist/sdk/zxing-runtime.d.ts +22 -0
- package/package.json +4 -2
- package/dist/finder-BvBpdbHa.js +0 -1507
- package/dist/finder-BvBpdbHa.js.map +0 -1
package/dist/react.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { Fragment as
|
|
2
|
+
import { B as e, I as t, M as n, N as r, R as i, T as a, U as o, V as s, i as c, j as l, n as u, v as d, y as f } from "./driver-license-DpjQqOKx.js";
|
|
3
|
+
import { createContext as p, useCallback as m, useContext as h, useEffect as g, useLayoutEffect as ee, useMemo as te, useRef as _, useState as v } from "react";
|
|
4
|
+
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
5
5
|
//#region src/sdk/display-quad.ts
|
|
6
|
-
function
|
|
6
|
+
function S(e) {
|
|
7
7
|
return [
|
|
8
8
|
e.topLeft,
|
|
9
9
|
e.topRight,
|
|
@@ -11,7 +11,7 @@ function b(e) {
|
|
|
11
11
|
e.bottomLeft
|
|
12
12
|
];
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function C(e) {
|
|
15
15
|
let [t, n, r, i] = e;
|
|
16
16
|
return {
|
|
17
17
|
topLeft: t,
|
|
@@ -38,8 +38,8 @@ function x(e) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
41
|
+
function w(e) {
|
|
42
|
+
return C(S(e).map((e) => ({ ...e })));
|
|
43
43
|
}
|
|
44
44
|
var ne = class {
|
|
45
45
|
current;
|
|
@@ -50,11 +50,11 @@ var ne = class {
|
|
|
50
50
|
this.response = e.response ?? 14, this.snapDistance = e.snapDistance ?? .1;
|
|
51
51
|
}
|
|
52
52
|
setTarget(e, t, n) {
|
|
53
|
-
let r = Math.max(1, Math.hypot(t, n)), i = !this.current ||
|
|
54
|
-
let n =
|
|
53
|
+
let r = Math.max(1, Math.hypot(t, n)), i = !this.current || S(e).some((e, t) => {
|
|
54
|
+
let n = S(this.current)[t];
|
|
55
55
|
return Math.hypot(e.x - n.x, e.y - n.y) / r > this.snapDistance;
|
|
56
56
|
});
|
|
57
|
-
return this.target =
|
|
57
|
+
return this.target = w(e), i && (this.current = w(e)), {
|
|
58
58
|
quad: this.current,
|
|
59
59
|
snapped: i
|
|
60
60
|
};
|
|
@@ -62,8 +62,8 @@ var ne = class {
|
|
|
62
62
|
step(e) {
|
|
63
63
|
if (!this.current || !this.target) return this.current;
|
|
64
64
|
let t = 1 - Math.exp(-this.response * Math.max(0, e) / 1e3);
|
|
65
|
-
return this.current =
|
|
66
|
-
let r =
|
|
65
|
+
return this.current = C(S(this.current).map((e, n) => {
|
|
66
|
+
let r = S(this.target)[n];
|
|
67
67
|
return {
|
|
68
68
|
x: e.x + (r.x - e.x) * t,
|
|
69
69
|
y: e.y + (r.y - e.y) * t
|
|
@@ -76,7 +76,7 @@ var ne = class {
|
|
|
76
76
|
getCurrent() {
|
|
77
77
|
return this.current;
|
|
78
78
|
}
|
|
79
|
-
}, re =
|
|
79
|
+
}, re = p(null);
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/react/context.tsx
|
|
82
82
|
function ie(e) {
|
|
@@ -90,295 +90,376 @@ function ae(e) {
|
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
function oe(e, t) {
|
|
94
|
+
if (typeof e == "function") return e(t);
|
|
95
|
+
}
|
|
96
|
+
function T({ open: l, useCase: u = "document", autoCapture: p = "defaultOn", captureMode: h = "auto", torch: y = "defaultOff", onCapture: x, onDriverLicense: S, onCancel: C, onError: w, onSettings: T, onFinderStatus: E, modelUrl: D, ortWasmPaths: O, detectionIntervalMs: se, apiRef: k, children: ce }) {
|
|
97
|
+
let A = e(h), j = _(void 0), M = _(void 0), N = _(void 0), P = _(void 0), F = _({}), I = _(new ne()), L = _(!1), R = _(!1), z = _({
|
|
98
|
+
onCapture: x,
|
|
99
|
+
onDriverLicense: S,
|
|
100
|
+
onCancel: C,
|
|
101
|
+
onError: w,
|
|
102
|
+
onSettings: T,
|
|
103
|
+
onFinderStatus: E,
|
|
104
|
+
useCase: u
|
|
105
|
+
}), le = _(void 0), B = _(void 0), ue = _(async () => void 0), de = _(null), [V, fe] = v(null), [pe, H] = v(A && l ? "capturing" : A ? "ready" : "starting"), [U, me] = v(), [he, W] = v(), [ge, _e] = v({
|
|
101
106
|
width: 1,
|
|
102
107
|
height: 1
|
|
103
|
-
}), [
|
|
108
|
+
}), [ve, ye] = v(), [be, G] = v(), [xe, K] = v(""), [Se, Ce] = v(0), [we, q] = v(), [Te, J] = v(), [Ee, Y] = v("idle"), [De, Oe] = v(), X = _(void 0), [ke, Ae] = v("front"), je = _("front"), [Me, Ne] = v(!1), [Pe, Fe] = v({
|
|
104
109
|
downloading: !1,
|
|
105
110
|
loaded: 0,
|
|
106
111
|
total: null
|
|
107
|
-
}),
|
|
108
|
-
ie(
|
|
109
|
-
}, []),
|
|
112
|
+
}), Z = m(() => {
|
|
113
|
+
ie(X.current), X.current = void 0, Oe(void 0);
|
|
114
|
+
}, []), Q = m((e, t) => {
|
|
110
115
|
let n = ae(e);
|
|
111
|
-
ie(
|
|
116
|
+
ie(X.current), X.current = n, Oe(n), t?.pause();
|
|
112
117
|
}, []);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
onCapture:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
ee(() => {
|
|
119
|
+
z.current = {
|
|
120
|
+
onCapture: x,
|
|
121
|
+
onDriverLicense: S,
|
|
122
|
+
onCancel: C,
|
|
123
|
+
onError: w,
|
|
124
|
+
onSettings: T,
|
|
125
|
+
onFinderStatus: E,
|
|
126
|
+
useCase: u
|
|
120
127
|
};
|
|
121
128
|
}, [
|
|
122
|
-
y,
|
|
123
|
-
b,
|
|
124
129
|
x,
|
|
125
130
|
S,
|
|
126
|
-
C
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
C,
|
|
132
|
+
w,
|
|
133
|
+
T,
|
|
134
|
+
E,
|
|
135
|
+
u
|
|
136
|
+
]), g(() => o(Fe), []), g(() => {
|
|
137
|
+
if (!l || u !== "drivers-license") {
|
|
138
|
+
B.current = void 0, le.current = void 0, Ae("front"), Ne(!1);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
let e = c({ scan: {
|
|
142
|
+
modelUrl: D,
|
|
143
|
+
ortWasmPaths: O
|
|
144
|
+
} });
|
|
145
|
+
return B.current = e, e.then((e) => {
|
|
146
|
+
le.current = e;
|
|
147
|
+
}), () => {
|
|
148
|
+
e.then((e) => e.cancel()), le.current &&= void 0, B.current = void 0;
|
|
149
|
+
};
|
|
150
|
+
}, [
|
|
151
|
+
l,
|
|
152
|
+
u,
|
|
153
|
+
D,
|
|
154
|
+
O
|
|
155
|
+
]);
|
|
156
|
+
let Ie = m((e) => {
|
|
157
|
+
fe(e);
|
|
130
158
|
}, []);
|
|
131
|
-
|
|
132
|
-
if (!
|
|
159
|
+
g(() => {
|
|
160
|
+
if (!l || !V) return;
|
|
133
161
|
let e = () => {
|
|
134
|
-
let e =
|
|
135
|
-
|
|
162
|
+
let e = V.getBoundingClientRect();
|
|
163
|
+
_e({
|
|
136
164
|
width: e.width,
|
|
137
165
|
height: e.height
|
|
138
166
|
});
|
|
139
167
|
};
|
|
140
168
|
if (e(), typeof ResizeObserver > "u") return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
141
169
|
let t = new ResizeObserver(e);
|
|
142
|
-
return t.observe(
|
|
143
|
-
}, [
|
|
144
|
-
if (!
|
|
170
|
+
return t.observe(V), () => t.disconnect();
|
|
171
|
+
}, [l, V]), g(() => {
|
|
172
|
+
if (!l) return;
|
|
145
173
|
let e = window.setInterval(() => {
|
|
146
|
-
let e =
|
|
147
|
-
e &&
|
|
174
|
+
let e = j.current?.getDiagnostics();
|
|
175
|
+
e && q(e);
|
|
148
176
|
}, 500);
|
|
149
177
|
return () => window.clearInterval(e);
|
|
150
|
-
}, [
|
|
151
|
-
if (!
|
|
178
|
+
}, [l, Se]), g(() => {
|
|
179
|
+
if (!l) return;
|
|
152
180
|
let e = 0, t = performance.now(), n = (r) => {
|
|
153
|
-
let i =
|
|
154
|
-
t = r, i &&
|
|
181
|
+
let i = I.current.step(r - t);
|
|
182
|
+
t = r, i && W(i), e = requestAnimationFrame(n);
|
|
155
183
|
};
|
|
156
184
|
return e = requestAnimationFrame(n), () => cancelAnimationFrame(e);
|
|
157
|
-
}, [
|
|
158
|
-
if (!
|
|
185
|
+
}, [l]), g(() => {
|
|
186
|
+
if (!l || A || !V) return;
|
|
159
187
|
let e = !1, t = () => {
|
|
160
|
-
|
|
188
|
+
M.current?.stop(), M.current = void 0, j.current?.stop(), j.current = void 0, P.current = void 0, N.current = void 0, F.current = {}, Z();
|
|
161
189
|
};
|
|
162
190
|
return (async () => {
|
|
163
|
-
t(),
|
|
191
|
+
t(), L.current = !1, H("starting"), K(""), me(void 0), G(void 0), J(void 0), Y("idle"), Z();
|
|
164
192
|
try {
|
|
165
|
-
let t = await
|
|
193
|
+
let t = await s(V, { torch: y });
|
|
166
194
|
if (e) {
|
|
167
195
|
t.stop();
|
|
168
196
|
return;
|
|
169
197
|
}
|
|
170
|
-
|
|
198
|
+
j.current = t;
|
|
171
199
|
let n = t.getSettings();
|
|
172
|
-
|
|
173
|
-
source:
|
|
174
|
-
autoCapture:
|
|
175
|
-
intervalMs:
|
|
200
|
+
ye(n), z.current.onSettings?.(n), console.info("[ScannerProvider] camera settings", n), M.current = await f({
|
|
201
|
+
source: V,
|
|
202
|
+
autoCapture: p,
|
|
203
|
+
intervalMs: se,
|
|
176
204
|
detection: {
|
|
177
|
-
modelUrl:
|
|
178
|
-
ortWasmPaths:
|
|
205
|
+
modelUrl: D,
|
|
206
|
+
ortWasmPaths: O
|
|
179
207
|
},
|
|
180
208
|
onStatus: (e) => {
|
|
181
|
-
if (
|
|
182
|
-
let t =
|
|
183
|
-
|
|
184
|
-
} else
|
|
185
|
-
e.state !== "captured" && !
|
|
209
|
+
if (N.current = e, me(e), z.current.onFinderStatus?.(e), e.quad && e.sourceWidth && e.sourceHeight) {
|
|
210
|
+
let t = I.current.setTarget(e.quad, e.sourceWidth, e.sourceHeight);
|
|
211
|
+
W(t.quad);
|
|
212
|
+
} else I.current.clear(), W(void 0);
|
|
213
|
+
e.state !== "captured" && !L.current && H("ready");
|
|
186
214
|
},
|
|
187
215
|
captureFrame: async () => {
|
|
188
|
-
|
|
189
|
-
quad:
|
|
190
|
-
sourceWidth:
|
|
191
|
-
sourceHeight:
|
|
216
|
+
H("capturing"), F.current = {
|
|
217
|
+
quad: I.current.getCurrent(),
|
|
218
|
+
sourceWidth: N.current?.sourceWidth,
|
|
219
|
+
sourceHeight: N.current?.sourceHeight
|
|
192
220
|
};
|
|
193
221
|
let e = await t.capturePhoto();
|
|
194
|
-
if (
|
|
195
|
-
return
|
|
222
|
+
if (P.current = e, G(e.method), J(e.diagnostics), q(e.diagnostics), e.luminance <= 10) throw Error(`The captured frame was blank (luminance ${e.luminance.toFixed(1)} via ${e.method}). Keep the scanner visible while capturing and retake.`);
|
|
223
|
+
return Q(e.frame, V), H("captured"), e.frame;
|
|
196
224
|
},
|
|
197
225
|
onCaptureError: (e) => {
|
|
198
|
-
|
|
199
|
-
let t =
|
|
200
|
-
t &&
|
|
226
|
+
L.current = !0, H("error"), K(e.message);
|
|
227
|
+
let t = j.current?.getDiagnostics();
|
|
228
|
+
t && q(t), z.current.onError?.(e);
|
|
201
229
|
},
|
|
202
230
|
onCapture: async (e) => {
|
|
203
|
-
let n =
|
|
204
|
-
await new Promise((e) => window.setTimeout(e, 140))
|
|
231
|
+
let n = P.current;
|
|
232
|
+
await new Promise((e) => window.setTimeout(e, 140));
|
|
233
|
+
let r = {
|
|
205
234
|
...e,
|
|
206
235
|
method: n?.method ?? "video-frame",
|
|
207
236
|
settings: n?.settings ?? t.getSettings(),
|
|
208
237
|
fallbackReason: n?.fallbackReason,
|
|
209
238
|
luminance: n?.luminance,
|
|
210
239
|
diagnostics: n?.diagnostics,
|
|
211
|
-
displayedQuad:
|
|
212
|
-
displaySourceWidth:
|
|
213
|
-
displaySourceHeight:
|
|
214
|
-
}
|
|
240
|
+
displayedQuad: F.current.quad,
|
|
241
|
+
displaySourceWidth: F.current.sourceWidth,
|
|
242
|
+
displaySourceHeight: F.current.sourceHeight
|
|
243
|
+
};
|
|
244
|
+
if (z.current.useCase === "drivers-license") {
|
|
245
|
+
await ue.current(r);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
await oe(z.current.onCapture, r);
|
|
215
249
|
}
|
|
216
250
|
});
|
|
217
251
|
} catch (n) {
|
|
218
252
|
if (e) return;
|
|
219
253
|
t();
|
|
220
254
|
let r = n instanceof Error ? n : /* @__PURE__ */ Error("Camera access failed.");
|
|
221
|
-
|
|
255
|
+
K(r.message), H("error"), z.current.onError?.(r);
|
|
222
256
|
}
|
|
223
257
|
})(), () => {
|
|
224
258
|
e = !0, t();
|
|
225
259
|
};
|
|
226
260
|
}, [
|
|
227
|
-
|
|
228
|
-
|
|
261
|
+
l,
|
|
262
|
+
V,
|
|
263
|
+
A,
|
|
264
|
+
p,
|
|
265
|
+
y,
|
|
229
266
|
D,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
_e,
|
|
236
|
-
Y,
|
|
237
|
-
X
|
|
267
|
+
O,
|
|
268
|
+
se,
|
|
269
|
+
Se,
|
|
270
|
+
Z,
|
|
271
|
+
Q
|
|
238
272
|
]);
|
|
239
|
-
let
|
|
240
|
-
open:
|
|
241
|
-
phase:
|
|
242
|
-
autoCapture:
|
|
243
|
-
captureMode:
|
|
244
|
-
usingSystemCamera:
|
|
245
|
-
finderStatus:
|
|
246
|
-
displayQuad:
|
|
247
|
-
previewSize:
|
|
248
|
-
settings:
|
|
249
|
-
captureMethod:
|
|
250
|
-
error:
|
|
251
|
-
diagnostics:
|
|
252
|
-
shutterDiagnostics:
|
|
253
|
-
copyState:
|
|
254
|
-
guidanceHint:
|
|
255
|
-
detectorStatus:
|
|
256
|
-
modelDownload:
|
|
257
|
-
frozenPreviewUrl:
|
|
273
|
+
let Le = {
|
|
274
|
+
open: l,
|
|
275
|
+
phase: pe,
|
|
276
|
+
autoCapture: p,
|
|
277
|
+
captureMode: h,
|
|
278
|
+
usingSystemCamera: A,
|
|
279
|
+
finderStatus: U,
|
|
280
|
+
displayQuad: he,
|
|
281
|
+
previewSize: ge,
|
|
282
|
+
settings: ve,
|
|
283
|
+
captureMethod: be,
|
|
284
|
+
error: xe,
|
|
285
|
+
diagnostics: we,
|
|
286
|
+
shutterDiagnostics: Te,
|
|
287
|
+
copyState: Ee,
|
|
288
|
+
guidanceHint: U ? d(U.guidance, U.lighting) : void 0,
|
|
289
|
+
detectorStatus: U?.modelStatus === "failed" ? `ML failed${U.modelError ? `: ${U.modelError}` : ""}` : U?.detector === "ml" ? `ML ${U.modelProvider ?? ""}`.trim() : "ML loading",
|
|
290
|
+
modelDownload: Pe,
|
|
291
|
+
frozenPreviewUrl: De,
|
|
292
|
+
useCase: u,
|
|
293
|
+
licenseSide: u === "drivers-license" ? ke : void 0,
|
|
294
|
+
licenseBusy: u === "drivers-license" ? Me : void 0
|
|
258
295
|
};
|
|
259
|
-
|
|
260
|
-
|
|
296
|
+
g(() => {
|
|
297
|
+
de.current = Le;
|
|
261
298
|
});
|
|
262
|
-
let
|
|
263
|
-
|
|
264
|
-
}, []),
|
|
265
|
-
if (!
|
|
266
|
-
|
|
299
|
+
let Re = m(() => {
|
|
300
|
+
z.current.onCancel();
|
|
301
|
+
}, []), $ = m(async () => {
|
|
302
|
+
if (!R.current) {
|
|
303
|
+
R.current = !0, L.current = !1, K(""), W(void 0), I.current.clear(), H("capturing");
|
|
267
304
|
try {
|
|
268
|
-
let
|
|
269
|
-
|
|
305
|
+
let e = await i();
|
|
306
|
+
Q(e);
|
|
270
307
|
let n = {
|
|
271
|
-
width:
|
|
272
|
-
height:
|
|
308
|
+
width: e.width,
|
|
309
|
+
height: e.height
|
|
273
310
|
};
|
|
274
|
-
|
|
311
|
+
ye(n), z.current.onSettings?.(n), G("system-camera");
|
|
275
312
|
let r;
|
|
276
313
|
try {
|
|
277
|
-
let n =
|
|
278
|
-
n && (r =
|
|
314
|
+
let n = e.getContext("2d", { willReadFrequently: !0 })?.getImageData(0, 0, e.width, e.height).data;
|
|
315
|
+
n && (r = t(n));
|
|
279
316
|
} catch {
|
|
280
317
|
r = void 0;
|
|
281
318
|
}
|
|
282
|
-
let
|
|
283
|
-
modelUrl:
|
|
284
|
-
ortWasmPaths:
|
|
319
|
+
let o = await a(e, {
|
|
320
|
+
modelUrl: D,
|
|
321
|
+
ortWasmPaths: O
|
|
285
322
|
});
|
|
286
|
-
if (
|
|
287
|
-
|
|
323
|
+
if ((z.current.useCase !== "drivers-license" || je.current !== "back") && (o.status !== "success" || !o.corners || !o.quad)) {
|
|
324
|
+
L.current = !0, H("error"), K(o.message), z.current.onError?.(Error(o.message));
|
|
288
325
|
return;
|
|
289
326
|
}
|
|
290
|
-
|
|
291
|
-
quad:
|
|
292
|
-
sourceWidth:
|
|
293
|
-
sourceHeight:
|
|
294
|
-
},
|
|
295
|
-
|
|
296
|
-
|
|
327
|
+
F.current = {
|
|
328
|
+
quad: o.quad,
|
|
329
|
+
sourceWidth: o.sourceWidth,
|
|
330
|
+
sourceHeight: o.sourceHeight
|
|
331
|
+
}, o.quad && W(o.quad), H("captured");
|
|
332
|
+
let s = {
|
|
333
|
+
frame: e,
|
|
334
|
+
detection: o,
|
|
297
335
|
reason: "manual",
|
|
298
336
|
method: "system-camera",
|
|
299
337
|
settings: n,
|
|
300
338
|
luminance: r,
|
|
301
|
-
displayedQuad:
|
|
302
|
-
displaySourceWidth:
|
|
303
|
-
displaySourceHeight:
|
|
304
|
-
}
|
|
339
|
+
displayedQuad: o.quad,
|
|
340
|
+
displaySourceWidth: o.sourceWidth,
|
|
341
|
+
displaySourceHeight: o.sourceHeight
|
|
342
|
+
};
|
|
343
|
+
if (z.current.useCase === "drivers-license") {
|
|
344
|
+
await ue.current(s);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
await oe(z.current.onCapture, s);
|
|
305
348
|
} catch (e) {
|
|
306
349
|
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not take a photo.");
|
|
307
350
|
if (t.message === "No photo was selected.") {
|
|
308
|
-
if (
|
|
309
|
-
|
|
351
|
+
if (X.current) {
|
|
352
|
+
H("error");
|
|
310
353
|
return;
|
|
311
354
|
}
|
|
312
|
-
|
|
355
|
+
z.current.onCancel();
|
|
313
356
|
return;
|
|
314
357
|
}
|
|
315
|
-
|
|
358
|
+
L.current = !0, K(t.message), H("error"), z.current.onError?.(t);
|
|
316
359
|
} finally {
|
|
317
|
-
|
|
360
|
+
R.current = !1;
|
|
318
361
|
}
|
|
319
362
|
}
|
|
320
363
|
}, [
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
]),
|
|
325
|
-
|
|
326
|
-
|
|
364
|
+
Q,
|
|
365
|
+
D,
|
|
366
|
+
O
|
|
367
|
+
]), ze = m(async (e) => {
|
|
368
|
+
let t = await B.current;
|
|
369
|
+
if (t) {
|
|
370
|
+
Ne(!0);
|
|
371
|
+
try {
|
|
372
|
+
let n = await t.submitStill(e.frame, e.detection);
|
|
373
|
+
if (n.kind === "need-back") {
|
|
374
|
+
if (je.current = "back", Ae("back"), L.current = !1, K(""), W(void 0), I.current.clear(), Z(), A) {
|
|
375
|
+
H("ready");
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
V?.paused && V.play(), H("starting"), Ce((e) => e + 1);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (n.kind === "retry") {
|
|
382
|
+
L.current = !0, K(n.message), H("error");
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
await oe(z.current.onDriverLicense, n.result);
|
|
386
|
+
} catch (e) {
|
|
387
|
+
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Driver’s license scan failed.");
|
|
388
|
+
L.current = !0, K(t.message), H("error"), z.current.onError?.(t);
|
|
389
|
+
} finally {
|
|
390
|
+
Ne(!1);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}, [
|
|
394
|
+
Z,
|
|
395
|
+
V,
|
|
396
|
+
A
|
|
397
|
+
]);
|
|
398
|
+
ee(() => {
|
|
399
|
+
ue.current = ze;
|
|
400
|
+
}, [ze]);
|
|
401
|
+
let Be = m(async () => {
|
|
402
|
+
if (A) {
|
|
403
|
+
await $();
|
|
327
404
|
return;
|
|
328
405
|
}
|
|
329
406
|
try {
|
|
330
|
-
await
|
|
407
|
+
await M.current?.capture();
|
|
331
408
|
} catch (e) {
|
|
332
409
|
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not capture the camera frame.");
|
|
333
|
-
|
|
334
|
-
let n =
|
|
335
|
-
n &&
|
|
410
|
+
L.current = !0, K(t.message);
|
|
411
|
+
let n = j.current?.getDiagnostics();
|
|
412
|
+
n && q(n), P.current?.diagnostics && J(P.current.diagnostics), H("error"), z.current.onError?.(t);
|
|
336
413
|
}
|
|
337
|
-
}, [
|
|
338
|
-
|
|
339
|
-
let
|
|
414
|
+
}, [$, A]), Ve = _($);
|
|
415
|
+
Ve.current = $;
|
|
416
|
+
let He = _(!1);
|
|
340
417
|
ee(() => {
|
|
341
|
-
if (!
|
|
342
|
-
|
|
418
|
+
if (!l || !A) {
|
|
419
|
+
He.current = !1;
|
|
343
420
|
return;
|
|
344
421
|
}
|
|
345
|
-
if (!
|
|
346
|
-
if (
|
|
347
|
-
|
|
422
|
+
if (!He.current) {
|
|
423
|
+
if (He.current = !0, L.current = !1, K(""), me(void 0), G(void 0), J(void 0), Y("idle"), W(void 0), I.current.clear(), Z(), !r()) {
|
|
424
|
+
H("ready");
|
|
348
425
|
return;
|
|
349
426
|
}
|
|
350
|
-
|
|
427
|
+
Ve.current();
|
|
351
428
|
}
|
|
352
429
|
}, [
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
430
|
+
l,
|
|
431
|
+
A,
|
|
432
|
+
Z
|
|
356
433
|
]);
|
|
357
|
-
let
|
|
358
|
-
if (
|
|
359
|
-
|
|
434
|
+
let Ue = m(() => {
|
|
435
|
+
if (L.current = !1, K(""), J(void 0), Y("idle"), W(void 0), I.current.clear(), A) {
|
|
436
|
+
$();
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if (Z(), u === "drivers-license") {
|
|
440
|
+
H("starting"), Ce((e) => e + 1);
|
|
360
441
|
return;
|
|
361
442
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
R?.paused && R.play(), z(e ? "ready" : "starting"), e || ve((e) => e + 1);
|
|
443
|
+
let e = j.current;
|
|
444
|
+
V?.paused && V.play(), H(e ? "ready" : "starting"), e || Ce((e) => e + 1);
|
|
365
445
|
}, [
|
|
446
|
+
$,
|
|
366
447
|
Z,
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
]),
|
|
371
|
-
let t =
|
|
372
|
-
t && (await t.setTorch(e),
|
|
373
|
-
}, []),
|
|
374
|
-
|
|
375
|
-
}, []),
|
|
376
|
-
let e =
|
|
448
|
+
V,
|
|
449
|
+
u,
|
|
450
|
+
A
|
|
451
|
+
]), We = m(async (e) => {
|
|
452
|
+
let t = j.current;
|
|
453
|
+
t && (await t.setTorch(e), q(t.getDiagnostics()));
|
|
454
|
+
}, []), Ge = m((e) => {
|
|
455
|
+
M.current?.setAutoCapture(e);
|
|
456
|
+
}, []), Ke = m(async () => {
|
|
457
|
+
let e = de.current, t = j.current?.getDiagnostics() ?? e.diagnostics, r = e.finderStatus, i = n({
|
|
377
458
|
error: e.error || void 0,
|
|
378
459
|
captureMethod: e.captureMethod,
|
|
379
|
-
luminance:
|
|
380
|
-
fallbackReason:
|
|
381
|
-
shutter: e.shutterDiagnostics ??
|
|
460
|
+
luminance: P.current?.luminance,
|
|
461
|
+
fallbackReason: P.current?.fallbackReason,
|
|
462
|
+
shutter: e.shutterDiagnostics ?? P.current?.diagnostics,
|
|
382
463
|
live: t,
|
|
383
464
|
finder: r ? {
|
|
384
465
|
state: r.state,
|
|
@@ -403,55 +484,55 @@ function C({ open: s, autoCapture: d = "defaultOn", captureMode: p = "auto", tor
|
|
|
403
484
|
let t = document.execCommand("copy");
|
|
404
485
|
if (e.remove(), !t) throw Error("Clipboard copy is unavailable.");
|
|
405
486
|
}
|
|
406
|
-
|
|
487
|
+
Y("copied");
|
|
407
488
|
} catch {
|
|
408
|
-
|
|
489
|
+
Y("failed");
|
|
409
490
|
}
|
|
410
|
-
}, []),
|
|
411
|
-
capture:
|
|
412
|
-
cancel:
|
|
413
|
-
retry:
|
|
414
|
-
setTorch:
|
|
415
|
-
setAutoCapture:
|
|
416
|
-
copyReport:
|
|
417
|
-
getState:
|
|
491
|
+
}, []), qe = m(() => de.current, []), Je = te(() => ({
|
|
492
|
+
capture: Be,
|
|
493
|
+
cancel: Re,
|
|
494
|
+
retry: Ue,
|
|
495
|
+
setTorch: We,
|
|
496
|
+
setAutoCapture: Ge,
|
|
497
|
+
copyReport: Ke,
|
|
498
|
+
getState: qe
|
|
418
499
|
}), [
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
500
|
+
Be,
|
|
501
|
+
Re,
|
|
502
|
+
Ue,
|
|
503
|
+
We,
|
|
504
|
+
Ge,
|
|
505
|
+
Ke,
|
|
506
|
+
qe
|
|
426
507
|
]);
|
|
427
|
-
|
|
428
|
-
if (
|
|
429
|
-
|
|
508
|
+
g(() => {
|
|
509
|
+
if (k) return k.current = Je, () => {
|
|
510
|
+
k.current = null;
|
|
430
511
|
};
|
|
431
|
-
}, [
|
|
432
|
-
let
|
|
433
|
-
...
|
|
434
|
-
|
|
435
|
-
bindPreview:
|
|
512
|
+
}, [Je, k]);
|
|
513
|
+
let Ye = {
|
|
514
|
+
...Le,
|
|
515
|
+
...Je,
|
|
516
|
+
bindPreview: Ie
|
|
436
517
|
};
|
|
437
|
-
return /* @__PURE__ */
|
|
438
|
-
value:
|
|
439
|
-
children:
|
|
518
|
+
return /* @__PURE__ */ b(re.Provider, {
|
|
519
|
+
value: Ye,
|
|
520
|
+
children: ce
|
|
440
521
|
});
|
|
441
522
|
}
|
|
442
523
|
//#endregion
|
|
443
524
|
//#region src/react/hooks.ts
|
|
444
|
-
function
|
|
445
|
-
return
|
|
525
|
+
function E() {
|
|
526
|
+
return _(null);
|
|
446
527
|
}
|
|
447
|
-
function
|
|
448
|
-
let e =
|
|
528
|
+
function D() {
|
|
529
|
+
let e = h(re);
|
|
449
530
|
if (!e) throw Error("useScanner must be used within ScannerProvider.");
|
|
450
531
|
return e;
|
|
451
532
|
}
|
|
452
533
|
//#endregion
|
|
453
534
|
//#region src/live-overlay-geometry.ts
|
|
454
|
-
function
|
|
535
|
+
function O(e, t, n, r, i) {
|
|
455
536
|
let a = Math.max(1, e), o = Math.max(1, t), s = Math.max(1, n), c = Math.max(1, r), l = s / a, u = c / o, d = i === "cover" ? Math.max(l, u) : Math.min(l, u), f = (s - a * d) / 2, p = (c - o * d) / 2;
|
|
456
537
|
if (i === "contain") return {
|
|
457
538
|
viewBox: `0 0 ${a} ${o}`,
|
|
@@ -460,9 +541,9 @@ function oe(e, t, n, r, i) {
|
|
|
460
541
|
offsetX: f,
|
|
461
542
|
offsetY: p
|
|
462
543
|
};
|
|
463
|
-
let m = s / d,
|
|
544
|
+
let m = s / d, h = c / d;
|
|
464
545
|
return {
|
|
465
|
-
viewBox: `${-f / d} ${-p / d} ${m} ${
|
|
546
|
+
viewBox: `${-f / d} ${-p / d} ${m} ${h}`,
|
|
466
547
|
preserveAspectRatio: "none",
|
|
467
548
|
scale: d,
|
|
468
549
|
offsetX: f,
|
|
@@ -471,10 +552,10 @@ function oe(e, t, n, r, i) {
|
|
|
471
552
|
}
|
|
472
553
|
//#endregion
|
|
473
554
|
//#region src/components/ModelDownloadRing.tsx
|
|
474
|
-
function
|
|
555
|
+
function se({ snapshot: e }) {
|
|
475
556
|
if (!e.downloading) return null;
|
|
476
557
|
let t = e.total && e.total > 0 ? Math.min(1, e.loaded / e.total) : null, n = t === null ? null : Math.round(t * 100), r = 2 * Math.PI * 28;
|
|
477
|
-
return /* @__PURE__ */
|
|
558
|
+
return /* @__PURE__ */ x("div", {
|
|
478
559
|
className: `model-download-ring${t === null ? " is-indeterminate" : ""}`,
|
|
479
560
|
role: "progressbar",
|
|
480
561
|
"aria-label": "Model download",
|
|
@@ -483,15 +564,15 @@ function E({ snapshot: e }) {
|
|
|
483
564
|
"aria-valuenow": n ?? void 0,
|
|
484
565
|
"data-loaded": e.loaded,
|
|
485
566
|
"data-total": e.total ?? "",
|
|
486
|
-
children: [/* @__PURE__ */
|
|
567
|
+
children: [/* @__PURE__ */ x("svg", {
|
|
487
568
|
viewBox: "0 0 72 72",
|
|
488
569
|
"aria-hidden": "true",
|
|
489
|
-
children: [/* @__PURE__ */
|
|
570
|
+
children: [/* @__PURE__ */ b("circle", {
|
|
490
571
|
className: "track",
|
|
491
572
|
cx: "36",
|
|
492
573
|
cy: "36",
|
|
493
574
|
r: 28
|
|
494
|
-
}), /* @__PURE__ */
|
|
575
|
+
}), /* @__PURE__ */ b("circle", {
|
|
495
576
|
className: "value",
|
|
496
577
|
cx: "36",
|
|
497
578
|
cy: "36",
|
|
@@ -499,15 +580,15 @@ function E({ snapshot: e }) {
|
|
|
499
580
|
strokeDasharray: t === null ? void 0 : `${r} ${r}`,
|
|
500
581
|
strokeDashoffset: t === null ? void 0 : r * (1 - t)
|
|
501
582
|
})]
|
|
502
|
-
}), n === null ? /* @__PURE__ */
|
|
583
|
+
}), n === null ? /* @__PURE__ */ b("strong", {
|
|
503
584
|
className: "model-download-ring__pending",
|
|
504
585
|
children: "…"
|
|
505
|
-
}) : /* @__PURE__ */
|
|
586
|
+
}) : /* @__PURE__ */ x("strong", { children: [n, "%"] })]
|
|
506
587
|
});
|
|
507
588
|
}
|
|
508
589
|
//#endregion
|
|
509
590
|
//#region src/react/parts.tsx
|
|
510
|
-
var
|
|
591
|
+
var k = {
|
|
511
592
|
primaryColorHex: "--scanner-overlay-primary",
|
|
512
593
|
seekingColorHex: "--scanner-overlay-seeking",
|
|
513
594
|
detectingColorHex: "--scanner-overlay-detecting",
|
|
@@ -515,46 +596,46 @@ var se = {
|
|
|
515
596
|
readyColorHex: "--scanner-overlay-ready",
|
|
516
597
|
capturedColorHex: "--scanner-overlay-captured"
|
|
517
598
|
};
|
|
518
|
-
function
|
|
599
|
+
function ce(e) {
|
|
519
600
|
if (!e) return;
|
|
520
601
|
let t = {};
|
|
521
|
-
for (let [n, r] of Object.entries(
|
|
602
|
+
for (let [n, r] of Object.entries(k)) {
|
|
522
603
|
let i = e[n]?.trim();
|
|
523
604
|
i && (t[r] = i);
|
|
524
605
|
}
|
|
525
606
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
526
607
|
}
|
|
527
|
-
function
|
|
528
|
-
let i =
|
|
608
|
+
function A({ theme: e, style: t, title: n, children: r }) {
|
|
609
|
+
let i = D();
|
|
529
610
|
if (!i.open) return null;
|
|
530
|
-
let a =
|
|
611
|
+
let a = n ?? (i.useCase === "drivers-license" ? "Scan a driver’s license" : "Scan a document"), o = ce(e), s = o ? {
|
|
531
612
|
...t,
|
|
532
|
-
...
|
|
613
|
+
...o
|
|
533
614
|
} : t;
|
|
534
|
-
return /* @__PURE__ */
|
|
615
|
+
return /* @__PURE__ */ x("div", {
|
|
535
616
|
className: `scanner-camera-overlay ${i.phase === "captured" || i.finderStatus?.state === "captured" ? "is-captured" : ""} ${i.usingSystemCamera ? "is-system-camera" : ""}`.trim(),
|
|
536
|
-
style:
|
|
617
|
+
style: s,
|
|
537
618
|
role: "dialog",
|
|
538
619
|
"aria-modal": "true",
|
|
539
|
-
"aria-label":
|
|
540
|
-
children: [r, /* @__PURE__ */
|
|
620
|
+
"aria-label": a,
|
|
621
|
+
children: [r, /* @__PURE__ */ b(R, {})]
|
|
541
622
|
});
|
|
542
623
|
}
|
|
543
|
-
function
|
|
544
|
-
let { bindPreview: e, frozenPreviewUrl: t, usingSystemCamera: n } =
|
|
624
|
+
function j() {
|
|
625
|
+
let { bindPreview: e, frozenPreviewUrl: t, usingSystemCamera: n } = D(), r = _(null), i = m((t) => {
|
|
545
626
|
r.current = t, e(t);
|
|
546
627
|
}, [e]);
|
|
547
|
-
return
|
|
628
|
+
return g(() => {
|
|
548
629
|
t && r.current?.pause();
|
|
549
|
-
}, [t]), n ? t ? /* @__PURE__ */
|
|
630
|
+
}, [t]), n ? t ? /* @__PURE__ */ b("img", {
|
|
550
631
|
src: t,
|
|
551
632
|
className: "scanner-camera-overlay__video scanner-camera-overlay__still",
|
|
552
633
|
alt: "",
|
|
553
634
|
"aria-label": "Captured document"
|
|
554
|
-
}) : /* @__PURE__ */
|
|
635
|
+
}) : /* @__PURE__ */ b("div", {
|
|
555
636
|
className: "scanner-camera-overlay__video",
|
|
556
637
|
"aria-hidden": "true"
|
|
557
|
-
}) : /* @__PURE__ */ y
|
|
638
|
+
}) : /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("video", {
|
|
558
639
|
ref: i,
|
|
559
640
|
className: "scanner-camera-overlay__video",
|
|
560
641
|
muted: !0,
|
|
@@ -563,45 +644,50 @@ function k() {
|
|
|
563
644
|
style: { objectFit: "cover" },
|
|
564
645
|
"aria-hidden": !!t,
|
|
565
646
|
"aria-label": "Rear camera preview"
|
|
566
|
-
}), t ? /* @__PURE__ */
|
|
647
|
+
}), t ? /* @__PURE__ */ b("img", {
|
|
567
648
|
src: t,
|
|
568
649
|
className: "scanner-camera-overlay__video scanner-camera-overlay__still",
|
|
569
650
|
alt: "",
|
|
570
651
|
"aria-label": "Captured document"
|
|
571
652
|
}) : null] });
|
|
572
653
|
}
|
|
573
|
-
function
|
|
574
|
-
let { finderStatus: e, displayQuad: t, previewSize: n } =
|
|
654
|
+
function M() {
|
|
655
|
+
let { finderStatus: e, displayQuad: t, previewSize: n } = D();
|
|
575
656
|
if (!t || !e?.sourceWidth || !e.sourceHeight) return null;
|
|
576
|
-
let r =
|
|
577
|
-
return /* @__PURE__ */
|
|
657
|
+
let r = O(e.sourceWidth, e.sourceHeight, n.width, n.height, "cover");
|
|
658
|
+
return /* @__PURE__ */ b("svg", {
|
|
578
659
|
className: `scanner-camera-overlay__quad ${e.state}`,
|
|
579
660
|
viewBox: r.viewBox,
|
|
580
661
|
preserveAspectRatio: r.preserveAspectRatio,
|
|
581
662
|
"aria-label": `${e.state} document boundary`,
|
|
582
|
-
children: /* @__PURE__ */
|
|
663
|
+
children: /* @__PURE__ */ b("polygon", { points: `${t.topLeft.x},${t.topLeft.y} ${t.topRight.x},${t.topRight.y} ${t.bottomRight.x},${t.bottomRight.y} ${t.bottomLeft.x},${t.bottomLeft.y}` })
|
|
583
664
|
});
|
|
584
665
|
}
|
|
585
|
-
function
|
|
586
|
-
let { phase: t, guidanceHint: n, cancel: r, usingSystemCamera: i } =
|
|
587
|
-
return /* @__PURE__ */
|
|
666
|
+
function N({ title: e }) {
|
|
667
|
+
let { phase: t, guidanceHint: n, cancel: r, usingSystemCamera: i, useCase: a, licenseSide: o, licenseBusy: s } = D(), c = a === "drivers-license" ? u(o ?? "front", i) : void 0, l = e ?? c?.title ?? "Scan a document";
|
|
668
|
+
return /* @__PURE__ */ x("div", {
|
|
588
669
|
className: "scanner-camera-overlay__topbar",
|
|
589
|
-
children: [/* @__PURE__ */
|
|
670
|
+
children: [/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("strong", { children: l }), /* @__PURE__ */ x("span", {
|
|
590
671
|
"aria-live": "polite",
|
|
591
|
-
children:
|
|
592
|
-
|
|
593
|
-
t === "
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
672
|
+
children: [
|
|
673
|
+
s && (o === "back" ? "Reading the barcode…" : "Reading the front…"),
|
|
674
|
+
!s && c && /* @__PURE__ */ x(y, { children: [t === "error" && (o === "back" ? "Could not read the back" : "Could not read the front"), t !== "error" && c.headline] }),
|
|
675
|
+
!s && !c && i && /* @__PURE__ */ x(y, { children: [
|
|
676
|
+
t === "starting" && "Preparing the system camera…",
|
|
677
|
+
t === "ready" && "Take a photo. There is no live document guide.",
|
|
678
|
+
t === "capturing" && "Looking for a document…",
|
|
679
|
+
t === "captured" && "Document captured",
|
|
680
|
+
t === "error" && "No document found"
|
|
681
|
+
] }),
|
|
682
|
+
!s && !c && !i && /* @__PURE__ */ x(y, { children: [
|
|
683
|
+
t === "starting" && "Starting rear camera…",
|
|
684
|
+
t === "ready" && (n ?? "Place the document in the frame"),
|
|
685
|
+
t === "capturing" && "Capturing full resolution…",
|
|
686
|
+
t === "captured" && "Document captured",
|
|
687
|
+
t === "error" && "Camera unavailable"
|
|
688
|
+
] })
|
|
689
|
+
]
|
|
690
|
+
})] }), /* @__PURE__ */ b("button", {
|
|
605
691
|
type: "button",
|
|
606
692
|
onClick: r,
|
|
607
693
|
"aria-label": "Close camera",
|
|
@@ -609,102 +695,112 @@ function j({ title: e = "Scan a document" }) {
|
|
|
609
695
|
})]
|
|
610
696
|
});
|
|
611
697
|
}
|
|
612
|
-
function
|
|
613
|
-
let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o, usingSystemCamera: s, frozenPreviewUrl: c } =
|
|
614
|
-
return e === "error" ? /* @__PURE__ */
|
|
698
|
+
function P() {
|
|
699
|
+
let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o, usingSystemCamera: s, frozenPreviewUrl: c, useCase: l, licenseSide: d, licenseBusy: f } = D(), p = l === "drivers-license" ? u(d ?? "front", s) : void 0;
|
|
700
|
+
return e === "error" ? /* @__PURE__ */ x("div", {
|
|
615
701
|
className: "scanner-camera-overlay__message",
|
|
616
702
|
role: "alert",
|
|
617
703
|
children: [
|
|
618
|
-
/* @__PURE__ */
|
|
619
|
-
/* @__PURE__ */
|
|
620
|
-
/* @__PURE__ */
|
|
621
|
-
/* @__PURE__ */
|
|
704
|
+
/* @__PURE__ */ b("strong", { children: p ? d === "back" ? "Could not read the back" : "Could not read the front" : s ? c ? "No document found" : "Could not take a photo" : n ? "Capture failed" : "Could not open the camera" }),
|
|
705
|
+
/* @__PURE__ */ b("p", { children: t }),
|
|
706
|
+
/* @__PURE__ */ x("div", { children: [
|
|
707
|
+
/* @__PURE__ */ b("button", {
|
|
622
708
|
type: "button",
|
|
623
709
|
onClick: i,
|
|
624
710
|
children: "Try again"
|
|
625
711
|
}),
|
|
626
|
-
/* @__PURE__ */
|
|
712
|
+
/* @__PURE__ */ b("button", {
|
|
627
713
|
type: "button",
|
|
628
714
|
onClick: () => void a(),
|
|
629
715
|
children: r === "copied" ? "Copied" : r === "failed" ? "Copy failed" : "Copy report"
|
|
630
716
|
}),
|
|
631
|
-
/* @__PURE__ */
|
|
717
|
+
/* @__PURE__ */ b("button", {
|
|
632
718
|
type: "button",
|
|
633
719
|
onClick: o,
|
|
634
720
|
children: "Cancel"
|
|
635
721
|
})
|
|
636
722
|
] })
|
|
637
723
|
]
|
|
638
|
-
}) :
|
|
724
|
+
}) : f ? /* @__PURE__ */ x("div", {
|
|
639
725
|
className: "scanner-camera-overlay__message",
|
|
640
726
|
"aria-live": "polite",
|
|
641
727
|
children: [
|
|
642
|
-
/* @__PURE__ */
|
|
643
|
-
/* @__PURE__ */
|
|
644
|
-
/* @__PURE__ */
|
|
728
|
+
/* @__PURE__ */ b("span", { className: "scanner-camera-overlay__spinner" }),
|
|
729
|
+
/* @__PURE__ */ b("strong", { children: d === "back" ? "Reading the barcode" : "Reading the front" }),
|
|
730
|
+
/* @__PURE__ */ b("p", { children: d === "back" ? "Decoding the AAMVA PDF417 on the back." : "Finding the card and reading the front with OCR." })
|
|
645
731
|
]
|
|
646
|
-
}) : s && e === "
|
|
732
|
+
}) : s && e === "capturing" && !c ? /* @__PURE__ */ x("div", {
|
|
647
733
|
className: "scanner-camera-overlay__message",
|
|
648
734
|
"aria-live": "polite",
|
|
649
|
-
children: [
|
|
650
|
-
|
|
735
|
+
children: [
|
|
736
|
+
/* @__PURE__ */ b("span", { className: "scanner-camera-overlay__spinner" }),
|
|
737
|
+
/* @__PURE__ */ b("strong", { children: p ? p.headline : "Opening the system camera" }),
|
|
738
|
+
/* @__PURE__ */ b("p", { children: p ? p.detail : "There is no live document guide. We find the page after you take the photo." })
|
|
739
|
+
]
|
|
740
|
+
}) : s && e === "ready" && !c ? /* @__PURE__ */ x("div", {
|
|
741
|
+
className: "scanner-camera-overlay__message",
|
|
742
|
+
"aria-live": "polite",
|
|
743
|
+
children: [/* @__PURE__ */ b("strong", { children: p ? p.headline : "System camera" }), /* @__PURE__ */ b("p", { children: p ? p.detail : "Tap the shutter to open the Camera app. There is no live document guide." })]
|
|
744
|
+
}) : e === "starting" && !s ? /* @__PURE__ */ x("div", {
|
|
651
745
|
className: "scanner-camera-overlay__message",
|
|
652
746
|
"aria-live": "polite",
|
|
653
747
|
children: [
|
|
654
|
-
/* @__PURE__ */
|
|
655
|
-
/* @__PURE__ */
|
|
656
|
-
/* @__PURE__ */
|
|
748
|
+
/* @__PURE__ */ b("span", { className: "scanner-camera-overlay__spinner" }),
|
|
749
|
+
/* @__PURE__ */ b("strong", { children: "Requesting the highest practical resolution" }),
|
|
750
|
+
/* @__PURE__ */ b("p", { children: "Allow camera access to continue." })
|
|
657
751
|
]
|
|
658
752
|
}) : null;
|
|
659
753
|
}
|
|
660
|
-
function
|
|
661
|
-
let { finderStatus: e, detectorStatus: t, settings: n, usingSystemCamera: r, captureMethod: i, phase: a } =
|
|
662
|
-
return r ? /* @__PURE__ */
|
|
754
|
+
function F() {
|
|
755
|
+
let { finderStatus: e, detectorStatus: t, settings: n, usingSystemCamera: r, captureMethod: i, phase: a, useCase: o, licenseSide: s } = D(), c = n?.width, l = n?.height, u = o === "drivers-license" ? ` · ${s === "back" ? "back" : "front"}` : "";
|
|
756
|
+
return r ? /* @__PURE__ */ b("div", {
|
|
663
757
|
className: "scanner-camera-overlay__status",
|
|
664
758
|
"aria-live": "polite",
|
|
665
|
-
children: /* @__PURE__ */
|
|
759
|
+
children: /* @__PURE__ */ x("div", {
|
|
666
760
|
className: "scanner-camera-overlay__status-line",
|
|
667
761
|
children: [
|
|
668
|
-
/* @__PURE__ */
|
|
762
|
+
/* @__PURE__ */ b("span", { className: a === "captured" ? "ready" : a === "error" ? "seeking" : "detecting" }),
|
|
669
763
|
i === "system-camera" ? "system camera" : "system camera · waiting",
|
|
670
|
-
|
|
764
|
+
u,
|
|
765
|
+
c && l ? ` · ${c}×${l}` : ""
|
|
671
766
|
]
|
|
672
767
|
})
|
|
673
|
-
}) : /* @__PURE__ */
|
|
768
|
+
}) : /* @__PURE__ */ b("div", {
|
|
674
769
|
className: "scanner-camera-overlay__status",
|
|
675
770
|
"aria-live": "polite",
|
|
676
|
-
children: /* @__PURE__ */
|
|
771
|
+
children: /* @__PURE__ */ x("div", {
|
|
677
772
|
className: "scanner-camera-overlay__status-line",
|
|
678
773
|
children: [
|
|
679
|
-
/* @__PURE__ */
|
|
774
|
+
/* @__PURE__ */ b("span", { className: e?.state ?? "detecting" }),
|
|
680
775
|
e?.state ?? "detecting",
|
|
776
|
+
u,
|
|
681
777
|
e ? ` · ${Math.round(e.confidence * 100)}% · ${e.stableFrames}/${e.requiredStableFrames}` : "",
|
|
682
778
|
` · ${t}`,
|
|
683
779
|
e?.inferenceMs === void 0 ? "" : ` · ${Math.round(e.inferenceMs)}ms`,
|
|
684
|
-
|
|
780
|
+
c && l ? ` · ${c}×${l}` : ""
|
|
685
781
|
]
|
|
686
782
|
})
|
|
687
783
|
});
|
|
688
784
|
}
|
|
689
|
-
function
|
|
690
|
-
let { diagnostics: e, shutterDiagnostics: t, captureMethod: n, copyState: r, copyReport: i } =
|
|
691
|
-
return /* @__PURE__ */
|
|
785
|
+
function I() {
|
|
786
|
+
let { diagnostics: e, shutterDiagnostics: t, captureMethod: n, copyState: r, copyReport: i } = D(), a = e?.engine ?? l();
|
|
787
|
+
return /* @__PURE__ */ x("dl", {
|
|
692
788
|
className: "scanner-camera-overlay__diagnostics",
|
|
693
789
|
"aria-label": "Camera diagnostics",
|
|
694
790
|
children: [
|
|
695
|
-
/* @__PURE__ */
|
|
791
|
+
/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "engine" }), /* @__PURE__ */ x("dd", { children: [
|
|
696
792
|
a.engine,
|
|
697
793
|
"/",
|
|
698
794
|
a.browser,
|
|
699
795
|
a.iosWebKit ? " ios" : ""
|
|
700
796
|
] })] }),
|
|
701
|
-
/* @__PURE__ */
|
|
702
|
-
/* @__PURE__ */
|
|
703
|
-
/* @__PURE__ */
|
|
704
|
-
/* @__PURE__ */
|
|
705
|
-
/* @__PURE__ */
|
|
706
|
-
t ? /* @__PURE__ */
|
|
707
|
-
/* @__PURE__ */
|
|
797
|
+
/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "video" }), /* @__PURE__ */ b("dd", { children: e ? `${e.videoWidth}×${e.videoHeight} rs${e.readyState}${e.paused ? " paused" : ""}${e.rendered ? "" : " hidden"}` : "starting" })] }),
|
|
798
|
+
/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "track" }), /* @__PURE__ */ b("dd", { children: e ? `${e.trackReadyState}${e.trackMuted ? " muted" : ""}${e.trackEnabled ? "" : " disabled"}` : "—" })] }),
|
|
799
|
+
/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "torch" }), /* @__PURE__ */ b("dd", { children: e ? `${e.torch.mode} · ${e.torch.supported ? e.torch.on ? "on" : "off" : "unsupported"}` : "starting" })] }),
|
|
800
|
+
/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "luma" }), /* @__PURE__ */ b("dd", { children: e ? `live ${e.liveLuminance.toFixed(1)} · mirror ${e.mirrorLuminance.toFixed(1)}${Number.isFinite(e.mirrorAgeMs) ? ` (${Math.round(e.mirrorAgeMs)}ms)` : " (none)"}` : "—" })] }),
|
|
801
|
+
/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "path" }), /* @__PURE__ */ b("dd", { children: n ?? "video-frame / live-mirror" })] }),
|
|
802
|
+
t ? /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "shutter" }), /* @__PURE__ */ b("dd", { children: `live ${t.liveLuminance.toFixed(1)} · mirror ${t.mirrorLuminance.toFixed(1)}${Number.isFinite(t.mirrorAgeMs) ? ` (${Math.round(t.mirrorAgeMs)}ms)` : " (none)"}` })] }) : null,
|
|
803
|
+
/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "share" }), /* @__PURE__ */ b("dd", { children: /* @__PURE__ */ b("button", {
|
|
708
804
|
type: "button",
|
|
709
805
|
className: "scanner-camera-overlay__copy",
|
|
710
806
|
onClick: () => void i(),
|
|
@@ -713,35 +809,35 @@ function P() {
|
|
|
713
809
|
]
|
|
714
810
|
});
|
|
715
811
|
}
|
|
716
|
-
function
|
|
717
|
-
let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l, usingSystemCamera: u } =
|
|
718
|
-
return /* @__PURE__ */
|
|
812
|
+
function L() {
|
|
813
|
+
let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l, usingSystemCamera: u, licenseBusy: d } = D(), f = a?.width, p = a?.height;
|
|
814
|
+
return /* @__PURE__ */ x("div", {
|
|
719
815
|
className: "scanner-camera-overlay__controls",
|
|
720
816
|
children: [
|
|
721
|
-
/* @__PURE__ */
|
|
817
|
+
/* @__PURE__ */ b("button", {
|
|
722
818
|
type: "button",
|
|
723
819
|
className: "scanner-camera-overlay__cancel",
|
|
724
820
|
onClick: o,
|
|
725
821
|
children: "Cancel"
|
|
726
822
|
}),
|
|
727
|
-
/* @__PURE__ */
|
|
823
|
+
/* @__PURE__ */ x("div", {
|
|
728
824
|
className: "scanner-camera-overlay__capture",
|
|
729
|
-
children: [(u ? t === "ready" : e !== "only") && /* @__PURE__ */
|
|
825
|
+
children: [(u ? t === "ready" : e !== "only") && /* @__PURE__ */ b("button", {
|
|
730
826
|
type: "button",
|
|
731
827
|
className: "scanner-camera-overlay__shutter",
|
|
732
828
|
onClick: () => void s(),
|
|
733
|
-
disabled: t !== "ready",
|
|
829
|
+
disabled: t !== "ready" || !!d,
|
|
734
830
|
"aria-label": u ? "Take a photo with the system camera" : "Capture full-resolution photo",
|
|
735
|
-
children: /* @__PURE__ */
|
|
736
|
-
}), !u && /* @__PURE__ */
|
|
831
|
+
children: /* @__PURE__ */ b("span", {})
|
|
832
|
+
}), !u && /* @__PURE__ */ x("div", {
|
|
737
833
|
className: "scanner-camera-overlay__toggles",
|
|
738
|
-
children: [n?.autoCapture.visible && /* @__PURE__ */
|
|
834
|
+
children: [n?.autoCapture.visible && /* @__PURE__ */ x("label", { children: [/* @__PURE__ */ b("input", {
|
|
739
835
|
type: "checkbox",
|
|
740
836
|
checked: n.autoCapture.checked,
|
|
741
837
|
onChange: (e) => c(e.target.checked)
|
|
742
|
-
}), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */
|
|
838
|
+
}), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ x("label", {
|
|
743
839
|
title: r.torch.automatic ? "Torch is controlled automatically from scene brightness" : void 0,
|
|
744
|
-
children: [/* @__PURE__ */
|
|
840
|
+
children: [/* @__PURE__ */ b("input", {
|
|
745
841
|
type: "checkbox",
|
|
746
842
|
checked: r.torch.on,
|
|
747
843
|
disabled: !r.torch.mutable,
|
|
@@ -750,18 +846,18 @@ function F() {
|
|
|
750
846
|
})]
|
|
751
847
|
})]
|
|
752
848
|
}),
|
|
753
|
-
/* @__PURE__ */
|
|
849
|
+
/* @__PURE__ */ x("div", {
|
|
754
850
|
className: "scanner-camera-overlay__quality",
|
|
755
|
-
children: [/* @__PURE__ */
|
|
851
|
+
children: [/* @__PURE__ */ b("span", { children: u ? "System camera" : i === "live-mirror" ? "Mirror" : "Camera" }), /* @__PURE__ */ b("strong", { children: f && p ? `${f} × ${p}` : u ? "Tap to photograph" : "Measuring…" })]
|
|
756
852
|
})
|
|
757
853
|
]
|
|
758
854
|
});
|
|
759
855
|
}
|
|
760
|
-
function
|
|
761
|
-
let { modelDownload: t } =
|
|
762
|
-
return /* @__PURE__ */
|
|
856
|
+
function R({ snapshot: e }) {
|
|
857
|
+
let { modelDownload: t } = D();
|
|
858
|
+
return /* @__PURE__ */ b(se, { snapshot: e ?? t });
|
|
763
859
|
}
|
|
764
860
|
//#endregion
|
|
765
|
-
export {
|
|
861
|
+
export { L as ScannerControls, I as ScannerDiagnostics, A as ScannerFrame, R as ScannerModelDownload, P as ScannerNotice, j as ScannerPreview, T as ScannerProvider, M as ScannerQuad, F as ScannerStatus, N as ScannerTopBar, D as useScanner, E as useScannerRef };
|
|
766
862
|
|
|
767
863
|
//# sourceMappingURL=react.js.map
|