@exige/web-scanner-sdk 0.2.36 → 0.2.38

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