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