@exige/web-scanner-sdk 0.2.38 → 0.2.39

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