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