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