@exige/web-scanner-sdk 0.2.38 → 0.2.40

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