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