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