@exige/web-scanner-sdk 0.2.36 → 0.2.37

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-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";
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 T(e) {
15
15
  let [t, n, r, i] = e;
16
16
  return {
17
17
  topLeft: t,
@@ -38,8 +38,8 @@ function w(e) {
38
38
  }
39
39
  };
40
40
  }
41
- function T(e) {
42
- return w(C(e).map((e) => ({ ...e })));
41
+ function E(e) {
42
+ return T(w(e).map((e) => ({ ...e })));
43
43
  }
44
44
  var ae = class {
45
45
  current;
@@ -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 = E(e), i && (this.current = E(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 = T(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,7 +76,7 @@ var ae = class {
76
76
  getCurrent() {
77
77
  return this.current;
78
78
  }
79
- }, oe = h(null);
79
+ }, oe = g(null);
80
80
  //#endregion
81
81
  //#region src/react/context.tsx
82
82
  function se(e) {
@@ -93,252 +93,258 @@ function ce(e) {
93
93
  function le(e, t) {
94
94
  if (typeof e == "function") return e(t);
95
95
  }
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({
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({
106
106
  width: 1,
107
107
  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({
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({
109
109
  downloading: !1,
110
110
  loaded: 0,
111
111
  total: null
112
- }), Z = g(() => {
113
- se(Ne.current), Ne.current = void 0, Me(void 0);
114
- }, []), Q = g((e, t) => {
112
+ }), Z = _(() => {
113
+ se(Fe.current), Fe.current = void 0, Pe(void 0);
114
+ }, []), Q = _((e, t) => {
115
115
  let n = ce(e);
116
- se(Ne.current), Ne.current = n, Me(n), t?.pause();
116
+ se(Fe.current), Fe.current = n, Pe(n), t?.pause();
117
117
  }, []);
118
- re(() => {
119
- I.current = {
120
- onCapture: b,
121
- onDriverLicense: S,
122
- onCancel: C,
123
- onError: w,
124
- onSettings: T,
125
- onFinderStatus: ue,
126
- useCase: p
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
127
127
  };
128
128
  }, [
129
- b,
130
- S,
131
129
  C,
132
130
  w,
133
131
  T,
132
+ E,
134
133
  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);
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);
139
139
  return;
140
140
  }
141
- let e = s({ scan: {
142
- modelUrl: E,
143
- ortWasmPaths: D
141
+ let e = c({ scan: {
142
+ modelUrl: D,
143
+ ortWasmPaths: O
144
144
  } });
145
- return he.current = e, e.then((e) => {
146
- L.current = e;
145
+ return ge.current = e, e.then((e) => {
146
+ he.current = e;
147
147
  }), () => {
148
- e.then((e) => e.cancel()), L.current &&= void 0, he.current = void 0;
148
+ e.then((e) => e.cancel()), he.current &&= void 0, ge.current = void 0;
149
149
  };
150
150
  }, [
151
- n,
152
- p,
153
- E,
154
- D
151
+ m,
152
+ h,
153
+ D,
154
+ O
155
155
  ]);
156
- let Ve = g((e) => {
157
- _e(e);
156
+ let Ue = _((e) => {
157
+ ve(e);
158
158
  }, []);
159
- _(() => {
160
- if (!n || !V) return;
159
+ y(() => {
160
+ if (!m || !H) return;
161
161
  let e = () => {
162
- let e = V.getBoundingClientRect();
163
- xe({
162
+ let e = H.getBoundingClientRect();
163
+ Se({
164
164
  width: e.width,
165
165
  height: e.height
166
166
  });
167
167
  };
168
168
  if (e(), typeof ResizeObserver > "u") return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
169
169
  let t = new ResizeObserver(e);
170
- return t.observe(V), () => t.disconnect();
171
- }, [n, V]), _(() => {
172
- if (!n) return;
170
+ return t.observe(H), () => t.disconnect();
171
+ }, [m, H]), y(() => {
172
+ if (!m) return;
173
173
  let e = window.setInterval(() => {
174
- let e = A.current?.getDiagnostics();
175
- e && J(e);
174
+ let e = j.current?.getDiagnostics();
175
+ e && Y(e);
176
176
  }, 500);
177
177
  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);
178
+ }, [m, De]), y(() => {
179
+ if (!m) return;
180
+ 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);
183
183
  };
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();
184
+ 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();
191
191
  };
192
192
  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();
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();
194
194
  try {
195
- let n = await f(V, { torch: ne });
195
+ let o = await t(H, { torch: ie });
196
196
  if (e) {
197
- n.stop();
197
+ o.stop();
198
198
  return;
199
199
  }
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 () => {
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 () => {
204
204
  try {
205
- let r = await u(() => {
205
+ let t = 0, a = await d(async () => {
206
+ t += 1;
207
+ let e = r();
208
+ if (t % 4 == 0 && n(e, "ImageCapture" in globalThis)) try {
209
+ let e = await o.capturePhoto();
210
+ if (e.frame && e.luminance > 10) return e.frame;
211
+ } catch {}
206
212
  try {
207
- return n.capture(c);
213
+ return await o.captureLiveFrame(l);
208
214
  } catch {
209
215
  return;
210
216
  }
211
217
  }, {
212
- intervalMs: de ?? 140,
213
- signal: t.signal
218
+ intervalMs: fe ?? 140,
219
+ signal: i.signal
214
220
  });
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,
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,
218
224
  reason: "auto",
219
- method: "video-frame",
220
- settings: n.getSettings()
225
+ method: "live-mirror",
226
+ settings: o.getSettings()
221
227
  });
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);
228
+ } 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);
226
232
  }
227
233
  })();
228
234
  return;
229
235
  }
230
- j.current = await i({
231
- source: V,
232
- autoCapture: m,
233
- intervalMs: de,
236
+ M.current = await a({
237
+ source: H,
238
+ autoCapture: g,
239
+ intervalMs: fe,
234
240
  detection: {
235
- modelUrl: E,
236
- ortWasmPaths: D
241
+ modelUrl: D,
242
+ ortWasmPaths: O
237
243
  },
238
244
  onStatus: (e) => {
239
- if (pe.current = e, W(e), I.current.onFinderStatus?.(e), e.quad && e.sourceWidth && e.sourceHeight) {
240
- 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");
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");
244
250
  },
245
251
  captureFrame: async () => {
246
- H("capturing"), N.current = {
247
- quad: P.current.getCurrent(),
248
- sourceWidth: pe.current?.sourceWidth,
249
- sourceHeight: pe.current?.sourceHeight
252
+ U("capturing"), F.current = {
253
+ quad: I.current.getCurrent(),
254
+ sourceWidth: N.current?.sourceWidth,
255
+ sourceHeight: N.current?.sourceHeight
250
256
  };
251
- let e = await n.capturePhoto();
252
- 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;
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;
254
260
  },
255
261
  onCaptureError: (e) => {
256
- F.current = !0, H("error"), q(e.message);
257
- let t = A.current?.getDiagnostics();
258
- t && J(t), I.current.onError?.(e);
262
+ L.current = !0, U("error"), J(e.message);
263
+ let t = j.current?.getDiagnostics();
264
+ t && Y(t), R.current.onError?.(e);
259
265
  },
260
266
  onCapture: async (e) => {
261
- let t = M.current;
267
+ let t = P.current;
262
268
  await new Promise((e) => window.setTimeout(e, 140));
263
- let r = {
269
+ let n = {
264
270
  ...e,
265
271
  method: t?.method ?? "video-frame",
266
- settings: t?.settings ?? n.getSettings(),
272
+ settings: t?.settings ?? o.getSettings(),
267
273
  fallbackReason: t?.fallbackReason,
268
274
  luminance: t?.luminance,
269
275
  diagnostics: t?.diagnostics,
270
- displayedQuad: N.current.quad,
271
- displaySourceWidth: N.current.sourceWidth,
272
- displaySourceHeight: N.current.sourceHeight
276
+ displayedQuad: F.current.quad,
277
+ displaySourceWidth: F.current.sourceWidth,
278
+ displaySourceHeight: F.current.sourceHeight
273
279
  };
274
- if (I.current.useCase === "drivers-license") {
275
- await R.current(r);
280
+ if (R.current.useCase === "drivers-license") {
281
+ await z.current(n);
276
282
  return;
277
283
  }
278
- await le(I.current.onCapture, r);
284
+ await le(R.current.onCapture, n);
279
285
  }
280
286
  });
281
287
  } catch (t) {
282
288
  if (e) return;
283
- r();
289
+ o();
284
290
  let n = t instanceof Error ? t : /* @__PURE__ */ Error("Camera access failed.");
285
- q(n.message), H("error"), I.current.onError?.(n);
291
+ J(n.message), U("error"), R.current.onError?.(n);
286
292
  }
287
293
  })(), () => {
288
- e = !0, r();
294
+ e = !0, o();
289
295
  };
290
296
  }, [
291
- n,
292
- V,
293
- k,
294
297
  m,
295
- ne,
296
- E,
298
+ H,
299
+ A,
300
+ g,
301
+ ie,
297
302
  D,
298
- de,
299
- Ee,
303
+ O,
304
+ fe,
305
+ De,
300
306
  Z,
301
307
  Q
302
308
  ]);
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
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
325
331
  };
326
- _(() => {
327
- ge.current = He;
332
+ y(() => {
333
+ _e.current = We;
328
334
  });
329
- let Ue = g(() => {
330
- I.current.onCancel();
331
- }, []), $ = g(async () => {
335
+ let Ge = _(() => {
336
+ R.current.onCancel();
337
+ }, []), $ = _(async () => {
332
338
  if (!me.current) {
333
- me.current = !0, F.current = !1, q(""), G(void 0), P.current.clear(), H("capturing");
339
+ me.current = !0, L.current = !1, J(""), K(void 0), I.current.clear(), U("capturing");
334
340
  try {
335
- let t = await a();
341
+ let t = await o();
336
342
  Q(t);
337
343
  let n = {
338
344
  width: t.width,
339
345
  height: t.height
340
346
  };
341
- Ce(n), I.current.onSettings?.(n), K("system-camera");
347
+ we(n), R.current.onSettings?.(n), q("system-camera");
342
348
  let r;
343
349
  try {
344
350
  let n = t.getContext("2d", { willReadFrequently: !0 })?.getImageData(0, 0, t.width, t.height).data;
@@ -346,8 +352,8 @@ function ue({ open: n, useCase: p = "document", autoCapture: m = "defaultOn", ca
346
352
  } catch {
347
353
  r = void 0;
348
354
  }
349
- if (I.current.useCase === "drivers-license" && Ie.current === "back") {
350
- G(void 0), P.current.clear(), N.current = {}, H("captured"), await R.current({
355
+ if (R.current.useCase === "drivers-license" && Re.current === "back") {
356
+ K(void 0), I.current.clear(), F.current = {}, U("captured"), await z.current({
351
357
  frame: t,
352
358
  reason: "manual",
353
359
  method: "system-camera",
@@ -356,20 +362,20 @@ function ue({ open: n, useCase: p = "document", autoCapture: m = "defaultOn", ca
356
362
  });
357
363
  return;
358
364
  }
359
- let i = await l(t, {
360
- modelUrl: E,
361
- ortWasmPaths: D
365
+ let i = await u(t, {
366
+ modelUrl: D,
367
+ ortWasmPaths: O
362
368
  });
363
369
  if (i.status !== "success" || !i.corners || !i.quad) {
364
- F.current = !0, H("error"), q(i.message), I.current.onError?.(Error(i.message));
370
+ L.current = !0, U("error"), J(i.message), R.current.onError?.(Error(i.message));
365
371
  return;
366
372
  }
367
- N.current = {
373
+ F.current = {
368
374
  quad: i.quad,
369
375
  sourceWidth: i.sourceWidth,
370
376
  sourceHeight: i.sourceHeight
371
- }, i.quad && G(i.quad), H("captured");
372
- let o = {
377
+ }, i.quad && K(i.quad), U("captured");
378
+ let a = {
373
379
  frame: t,
374
380
  detection: i,
375
381
  reason: "manual",
@@ -380,75 +386,75 @@ function ue({ open: n, useCase: p = "document", autoCapture: m = "defaultOn", ca
380
386
  displaySourceWidth: i.sourceWidth,
381
387
  displaySourceHeight: i.sourceHeight
382
388
  };
383
- if (I.current.useCase === "drivers-license") {
384
- await R.current(o);
389
+ if (R.current.useCase === "drivers-license") {
390
+ await z.current(a);
385
391
  return;
386
392
  }
387
- await le(I.current.onCapture, o);
393
+ await le(R.current.onCapture, a);
388
394
  } catch (e) {
389
395
  let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not take a photo.");
390
396
  if (t.message === "No photo was selected.") {
391
- if (Ne.current) {
392
- H("error");
397
+ if (Fe.current) {
398
+ U("error");
393
399
  return;
394
400
  }
395
- I.current.onCancel();
401
+ R.current.onCancel();
396
402
  return;
397
403
  }
398
- F.current = !0, q(t.message), H("error"), I.current.onError?.(t);
404
+ L.current = !0, J(t.message), U("error"), R.current.onError?.(t);
399
405
  } finally {
400
406
  me.current = !1;
401
407
  }
402
408
  }
403
409
  }, [
404
410
  Q,
405
- E,
406
- D
407
- ]), We = g(async (e) => {
408
- let t = await he.current;
411
+ D,
412
+ O
413
+ ]), Ke = _(async (e) => {
414
+ let t = await ge.current;
409
415
  if (t) {
410
- Re(!0);
416
+ Be(!0);
411
417
  try {
412
418
  let n = await t.submitStill(e.frame, e.detection);
413
419
  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");
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");
416
422
  return;
417
423
  }
418
- V?.paused && V.play(), H("starting"), De((e) => e + 1);
424
+ H?.paused && H.play(), U("starting"), Oe((e) => e + 1);
419
425
  return;
420
426
  }
421
427
  if (n.kind === "retry") {
422
- F.current = !0, q(n.message), H("error");
428
+ L.current = !0, J(n.message), U("error");
423
429
  return;
424
430
  }
425
- await le(I.current.onDriverLicense, n.result);
431
+ await le(R.current.onDriverLicense, n.result);
426
432
  } catch (e) {
427
433
  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);
434
+ L.current = !0, J(t.message), U("error"), R.current.onError?.(t);
429
435
  } finally {
430
- Re(!1);
436
+ Be(!1);
431
437
  }
432
438
  }
433
439
  }, [
434
440
  Z,
435
- V,
436
- k
441
+ H,
442
+ A
437
443
  ]);
438
- re(() => {
439
- R.current = We;
440
- }, [We]);
441
- let Ge = g(async () => {
442
- if (k) {
444
+ ne(() => {
445
+ z.current = Ke;
446
+ }, [Ke]);
447
+ let qe = _(async () => {
448
+ if (A) {
443
449
  await $();
444
450
  return;
445
451
  }
446
- let e = A.current;
447
- if (e && I.current.useCase === "drivers-license" && Ie.current === "back") {
452
+ let e = j.current;
453
+ if (e && R.current.useCase === "drivers-license" && Re.current === "back") {
448
454
  try {
449
455
  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({
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({
452
458
  frame: t.frame,
453
459
  reason: "manual",
454
460
  method: t.method,
@@ -459,74 +465,74 @@ function ue({ open: n, useCase: p = "document", autoCapture: m = "defaultOn", ca
459
465
  });
460
466
  } catch (e) {
461
467
  let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not capture the camera frame.");
462
- 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);
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);
465
471
  }
466
472
  return;
467
473
  }
468
474
  try {
469
- await j.current?.capture();
475
+ await M.current?.capture();
470
476
  } catch (e) {
471
477
  let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not capture the camera frame.");
472
- 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);
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);
475
481
  }
476
482
  }, [
477
483
  $,
478
484
  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;
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;
487
493
  return;
488
494
  }
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");
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");
492
498
  return;
493
499
  }
494
- Ke.current();
500
+ Je.current();
495
501
  }
496
502
  }, [
497
- n,
498
- k,
503
+ m,
504
+ A,
499
505
  Z
500
506
  ]);
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) {
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) {
503
509
  $();
504
510
  return;
505
511
  }
506
- if (Z(), p === "drivers-license") {
507
- H("starting"), De((e) => e + 1);
512
+ if (Z(), h === "drivers-license") {
513
+ U("starting"), Oe((e) => e + 1);
508
514
  return;
509
515
  }
510
- let e = A.current;
511
- V?.paused && V.play(), H(e ? "ready" : "starting"), e || De((e) => e + 1);
516
+ let e = j.current;
517
+ H?.paused && H.play(), U(e ? "ready" : "starting"), e || Oe((e) => e + 1);
512
518
  }, [
513
519
  $,
514
520
  Z,
515
- V,
516
- p,
517
- k
518
- ]), Ye = g(async (e) => {
519
- let t = A.current;
520
- 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({
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({
525
531
  error: e.error || void 0,
526
532
  captureMethod: e.captureMethod,
527
- luminance: M.current?.luminance,
528
- fallbackReason: M.current?.fallbackReason,
529
- shutter: e.shutterDiagnostics ?? M.current?.diagnostics,
533
+ luminance: P.current?.luminance,
534
+ fallbackReason: P.current?.fallbackReason,
535
+ shutter: e.shutterDiagnostics ?? P.current?.diagnostics,
530
536
  live: t,
531
537
  finder: n ? {
532
538
  state: n.state,
@@ -544,62 +550,62 @@ function ue({ open: n, useCase: p = "document", autoCapture: m = "defaultOn", ca
544
550
  } : void 0
545
551
  });
546
552
  try {
547
- if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(i);
553
+ if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(r);
548
554
  else {
549
555
  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();
556
+ e.value = r, e.setAttribute("readonly", ""), e.style.position = "fixed", e.style.left = "-9999px", document.body.append(e), e.select();
551
557
  let t = document.execCommand("copy");
552
558
  if (e.remove(), !t) throw Error("Clipboard copy is unavailable.");
553
559
  }
554
- X("copied");
560
+ Me("copied");
555
561
  } catch {
556
- X("failed");
562
+ Me("failed");
557
563
  }
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
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
566
572
  }), [
573
+ qe,
567
574
  Ge,
568
- Ue,
569
- Je,
570
- Ye,
571
575
  Xe,
572
576
  Ze,
573
- Qe
577
+ Qe,
578
+ $e,
579
+ et
574
580
  ]);
575
- _(() => {
576
- if (O) return O.current = $e, () => {
577
- O.current = null;
581
+ y(() => {
582
+ if (k) return k.current = tt, () => {
583
+ k.current = null;
578
584
  };
579
- }, [$e, O]);
580
- let et = {
581
- ...He,
582
- ...$e,
583
- bindPreview: Ve
585
+ }, [tt, k]);
586
+ let nt = {
587
+ ...We,
588
+ ...tt,
589
+ bindPreview: Ue
584
590
  };
585
- return /* @__PURE__ */ x(oe.Provider, {
586
- value: et,
587
- children: fe
591
+ return /* @__PURE__ */ S(oe.Provider, {
592
+ value: nt,
593
+ children: pe
588
594
  });
589
595
  }
590
596
  //#endregion
591
597
  //#region src/react/hooks.ts
592
- function E() {
593
- return v(null);
598
+ function de() {
599
+ return b(null);
594
600
  }
595
601
  function D() {
596
- let e = ne(oe);
602
+ let e = v(oe);
597
603
  if (!e) throw Error("useScanner must be used within ScannerProvider.");
598
604
  return e;
599
605
  }
600
606
  //#endregion
601
607
  //#region src/live-overlay-geometry.ts
602
- function de(e, t, n, r, i) {
608
+ function O(e, t, n, r, i) {
603
609
  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
610
  if (i === "contain") return {
605
611
  viewBox: `0 0 ${a} ${o}`,
@@ -608,9 +614,9 @@ function de(e, t, n, r, i) {
608
614
  offsetX: f,
609
615
  offsetY: p
610
616
  };
611
- let ee = s / d, m = c / d;
617
+ let m = s / d, ee = c / d;
612
618
  return {
613
- viewBox: `${-f / d} ${-p / d} ${ee} ${m}`,
619
+ viewBox: `${-f / d} ${-p / d} ${m} ${ee}`,
614
620
  preserveAspectRatio: "none",
615
621
  scale: d,
616
622
  offsetX: f,
@@ -619,10 +625,10 @@ function de(e, t, n, r, i) {
619
625
  }
620
626
  //#endregion
621
627
  //#region src/components/ModelDownloadRing.tsx
622
- function O({ snapshot: e }) {
628
+ function fe({ snapshot: e }) {
623
629
  if (!e.downloading) return null;
624
630
  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", {
631
+ return /* @__PURE__ */ C("div", {
626
632
  className: `model-download-ring${t === null ? " is-indeterminate" : ""}`,
627
633
  role: "progressbar",
628
634
  "aria-label": "Model download",
@@ -631,15 +637,15 @@ function O({ snapshot: e }) {
631
637
  "aria-valuenow": n ?? void 0,
632
638
  "data-loaded": e.loaded,
633
639
  "data-total": e.total ?? "",
634
- children: [/* @__PURE__ */ S("svg", {
640
+ children: [/* @__PURE__ */ C("svg", {
635
641
  viewBox: "0 0 72 72",
636
642
  "aria-hidden": "true",
637
- children: [/* @__PURE__ */ x("circle", {
643
+ children: [/* @__PURE__ */ S("circle", {
638
644
  className: "track",
639
645
  cx: "36",
640
646
  cy: "36",
641
647
  r: 28
642
- }), /* @__PURE__ */ x("circle", {
648
+ }), /* @__PURE__ */ S("circle", {
643
649
  className: "value",
644
650
  cx: "36",
645
651
  cy: "36",
@@ -647,20 +653,20 @@ function O({ snapshot: e }) {
647
653
  strokeDasharray: t === null ? void 0 : `${r} ${r}`,
648
654
  strokeDashoffset: t === null ? void 0 : r * (1 - t)
649
655
  })]
650
- }), n === null ? /* @__PURE__ */ x("strong", {
656
+ }), n === null ? /* @__PURE__ */ S("strong", {
651
657
  className: "model-download-ring__pending",
652
658
  children: "…"
653
- }) : /* @__PURE__ */ S("strong", { children: [n, "%"] })]
659
+ }) : /* @__PURE__ */ C("strong", { children: [n, "%"] })]
654
660
  });
655
661
  }
656
662
  //#endregion
657
663
  //#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";
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";
660
666
  }
661
667
  //#endregion
662
668
  //#region src/react/parts.tsx
663
- var k = {
669
+ var pe = {
664
670
  primaryColorHex: "--scanner-overlay-primary",
665
671
  seekingColorHex: "--scanner-overlay-seeking",
666
672
  detectingColorHex: "--scanner-overlay-detecting",
@@ -671,7 +677,7 @@ var k = {
671
677
  function A(e) {
672
678
  if (!e) return;
673
679
  let t = {};
674
- for (let [n, r] of Object.entries(k)) {
680
+ for (let [n, r] of Object.entries(pe)) {
675
681
  let i = e[n]?.trim();
676
682
  i && (t[r] = i);
677
683
  }
@@ -684,30 +690,30 @@ function j({ theme: e, style: t, title: n, children: r }) {
684
690
  ...t,
685
691
  ...o
686
692
  } : t;
687
- return /* @__PURE__ */ S("div", {
693
+ return /* @__PURE__ */ C("div", {
688
694
  className: `scanner-camera-overlay ${i.phase === "captured" || i.finderStatus?.state === "captured" ? "is-captured" : ""} ${i.usingSystemCamera ? "is-system-camera" : ""}`.trim(),
689
695
  style: s,
690
696
  role: "dialog",
691
697
  "aria-modal": "true",
692
698
  "aria-label": a,
693
- children: [r, /* @__PURE__ */ x(L, {})]
699
+ children: [r, /* @__PURE__ */ S(R, {})]
694
700
  });
695
701
  }
696
- function pe() {
697
- let { bindPreview: e, frozenPreviewUrl: t, usingSystemCamera: n } = D(), r = v(null), i = g((t) => {
702
+ function M() {
703
+ let { bindPreview: e, frozenPreviewUrl: t, usingSystemCamera: n } = D(), r = b(null), i = _((t) => {
698
704
  r.current = t, e(t);
699
705
  }, [e]);
700
- return _(() => {
706
+ return y(() => {
701
707
  t && r.current?.pause();
702
- }, [t]), n ? t ? /* @__PURE__ */ x("img", {
708
+ }, [t]), n ? t ? /* @__PURE__ */ S("img", {
703
709
  src: t,
704
710
  className: "scanner-camera-overlay__video scanner-camera-overlay__still",
705
711
  alt: "",
706
712
  "aria-label": "Captured document"
707
- }) : /* @__PURE__ */ x("div", {
713
+ }) : /* @__PURE__ */ S("div", {
708
714
  className: "scanner-camera-overlay__video",
709
715
  "aria-hidden": "true"
710
- }) : /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("video", {
716
+ }) : /* @__PURE__ */ C(ie, { children: [/* @__PURE__ */ S("video", {
711
717
  ref: i,
712
718
  className: "scanner-camera-overlay__video",
713
719
  muted: !0,
@@ -716,35 +722,35 @@ function pe() {
716
722
  style: { objectFit: "cover" },
717
723
  "aria-hidden": !!t,
718
724
  "aria-label": "Rear camera preview"
719
- }), t ? /* @__PURE__ */ x("img", {
725
+ }), t ? /* @__PURE__ */ S("img", {
720
726
  src: t,
721
727
  className: "scanner-camera-overlay__video scanner-camera-overlay__still",
722
728
  alt: "",
723
729
  "aria-label": "Captured document"
724
730
  }) : null] });
725
731
  }
726
- function M() {
732
+ function N() {
727
733
  let { finderStatus: e, displayQuad: t, previewSize: n } = D();
728
734
  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", {
735
+ let r = O(e.sourceWidth, e.sourceHeight, n.width, n.height, "cover");
736
+ return /* @__PURE__ */ S("svg", {
731
737
  className: `scanner-camera-overlay__quad ${e.state}`,
732
738
  viewBox: r.viewBox,
733
739
  preserveAspectRatio: r.preserveAspectRatio,
734
740
  "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}` })
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}` })
736
742
  });
737
743
  }
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", {
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", {
741
747
  className: "scanner-camera-overlay__topbar",
742
- children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("strong", { children: c }), /* @__PURE__ */ S("span", {
748
+ children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("strong", { children: c }), /* @__PURE__ */ C("span", {
743
749
  "aria-live": "polite",
744
750
  children: [
745
751
  o && (a === "back" ? "Reading the barcode…" : "Reading the front…"),
746
752
  !o && s && t === "error" && (a === "back" ? "Could not read the back" : "Could not read the front"),
747
- !o && !s && r && /* @__PURE__ */ S(b, { children: [
753
+ !o && !s && r && /* @__PURE__ */ C(ie, { children: [
748
754
  t === "starting" && "Preparing the system camera…",
749
755
  t === "ready" && "Take a photo. There is no live document guide.",
750
756
  t === "capturing" && "Looking for a document…",
@@ -753,7 +759,7 @@ function N({ title: e }) {
753
759
  ] }),
754
760
  !o && !s && !r && t === "error" && "Camera unavailable"
755
761
  ]
756
- })] }), /* @__PURE__ */ x("button", {
762
+ })] }), /* @__PURE__ */ S("button", {
757
763
  type: "button",
758
764
  onClick: n,
759
765
  "aria-label": "Close camera",
@@ -761,71 +767,71 @@ function N({ title: e }) {
761
767
  })]
762
768
  });
763
769
  }
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", {
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", {
767
773
  className: "scanner-camera-overlay__message",
768
774
  role: "alert",
769
775
  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", {
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", {
774
780
  type: "button",
775
781
  onClick: i,
776
782
  children: "Try again"
777
783
  }),
778
- /* @__PURE__ */ x("button", {
784
+ /* @__PURE__ */ S("button", {
779
785
  type: "button",
780
786
  onClick: () => void a(),
781
787
  children: r === "copied" ? "Copied" : r === "failed" ? "Copy failed" : "Copy report"
782
788
  }),
783
- /* @__PURE__ */ x("button", {
789
+ /* @__PURE__ */ S("button", {
784
790
  type: "button",
785
791
  onClick: o,
786
792
  children: "Cancel"
787
793
  })
788
794
  ] })
789
795
  ]
790
- }) : d ? /* @__PURE__ */ S("div", {
796
+ }) : d ? /* @__PURE__ */ C("div", {
791
797
  className: "scanner-camera-overlay__message",
792
798
  "aria-live": "polite",
793
799
  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." })
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." })
797
803
  ]
798
- }) : s && e === "capturing" && !c ? /* @__PURE__ */ S("div", {
804
+ }) : s && e === "capturing" && !c ? /* @__PURE__ */ C("div", {
799
805
  className: "scanner-camera-overlay__message",
800
806
  "aria-live": "polite",
801
807
  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." })
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." })
805
811
  ]
806
- }) : s && e === "ready" && !c ? /* @__PURE__ */ S("div", {
812
+ }) : s && e === "ready" && !c ? /* @__PURE__ */ C("div", {
807
813
  className: "scanner-camera-overlay__message",
808
814
  "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", {
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", {
811
817
  className: "scanner-camera-overlay__message",
812
818
  "aria-live": "polite",
813
819
  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." })
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." })
817
823
  ]
818
824
  }) : null;
819
825
  }
820
- function F() {
826
+ function I() {
821
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"}` : "";
822
- if (r) return /* @__PURE__ */ x("div", {
828
+ if (r) return /* @__PURE__ */ S("div", {
823
829
  className: "scanner-camera-overlay__status",
824
830
  "aria-live": "polite",
825
- children: /* @__PURE__ */ S("div", {
831
+ children: /* @__PURE__ */ C("div", {
826
832
  className: "scanner-camera-overlay__status-line",
827
833
  children: [
828
- /* @__PURE__ */ x("span", { className: a === "captured" ? "ready" : a === "error" ? "seeking" : "detecting" }),
834
+ /* @__PURE__ */ S("span", { className: a === "captured" ? "ready" : a === "error" ? "seeking" : "detecting" }),
829
835
  i === "system-camera" ? "system camera" : "system camera · waiting",
830
836
  u,
831
837
  c && l ? ` · ${c}×${l}` : ""
@@ -833,13 +839,13 @@ function F() {
833
839
  })
834
840
  });
835
841
  let d = o === "drivers-license" && s === "back", f = d && !e ? "reading" : e?.state ?? "detecting";
836
- return /* @__PURE__ */ x("div", {
842
+ return /* @__PURE__ */ S("div", {
837
843
  className: "scanner-camera-overlay__status",
838
844
  "aria-live": "polite",
839
- children: /* @__PURE__ */ S("div", {
845
+ children: /* @__PURE__ */ C("div", {
840
846
  className: "scanner-camera-overlay__status-line",
841
847
  children: [
842
- /* @__PURE__ */ x("span", { className: d && !e ? "detecting" : e?.state ?? "detecting" }),
848
+ /* @__PURE__ */ S("span", { className: d && !e ? "detecting" : e?.state ?? "detecting" }),
843
849
  f,
844
850
  u,
845
851
  e ? ` · ${Math.round(e.confidence * 100)}% · ${e.stableFrames}/${e.requiredStableFrames}` : "",
@@ -850,25 +856,25 @@ function F() {
850
856
  })
851
857
  });
852
858
  }
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", {
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", {
856
862
  className: "scanner-camera-overlay__diagnostics",
857
863
  "aria-label": "Camera diagnostics",
858
864
  children: [
859
- /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("dt", { children: "engine" }), /* @__PURE__ */ S("dd", { children: [
865
+ /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("dt", { children: "engine" }), /* @__PURE__ */ C("dd", { children: [
860
866
  o.engine,
861
867
  "/",
862
868
  o.browser,
863
869
  o.iosWebKit ? " ios" : ""
864
870
  ] })] }),
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", {
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", {
872
878
  type: "button",
873
879
  className: "scanner-camera-overlay__copy",
874
880
  onClick: () => void a(),
@@ -877,50 +883,50 @@ function me() {
877
883
  ]
878
884
  });
879
885
  }
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({
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({
882
888
  usingSystemCamera: u,
883
889
  phase: t,
884
890
  licenseBusy: d,
885
891
  holdStillSeconds: n?.holdStillSeconds,
886
- guidanceHint: m,
892
+ guidanceHint: ee,
887
893
  guidanceReason: n?.guidance.reason,
888
- licenseHeadline: ne?.headline
889
- }), re = !!n?.holdStillSeconds;
890
- return /* @__PURE__ */ S("div", {
894
+ licenseHeadline: _?.headline
895
+ }), y = !!n?.holdStillSeconds;
896
+ return /* @__PURE__ */ C("div", {
891
897
  className: "scanner-camera-overlay__controls",
892
898
  children: [
893
- /* @__PURE__ */ x("button", {
899
+ /* @__PURE__ */ S("button", {
894
900
  type: "button",
895
901
  className: "scanner-camera-overlay__cancel",
896
902
  onClick: o,
897
903
  children: "Cancel"
898
904
  }),
899
- /* @__PURE__ */ S("div", {
905
+ /* @__PURE__ */ C("div", {
900
906
  className: "scanner-camera-overlay__capture",
901
907
  children: [
902
- _ && /* @__PURE__ */ x("p", {
903
- className: `scanner-camera-overlay__guidance${re ? " is-ready" : ""}`,
908
+ v && /* @__PURE__ */ S("p", {
909
+ className: `scanner-camera-overlay__guidance${y ? " is-ready" : ""}`,
904
910
  "aria-live": "polite",
905
- children: _
911
+ children: v
906
912
  }),
907
- g && /* @__PURE__ */ x("button", {
913
+ g && /* @__PURE__ */ S("button", {
908
914
  type: "button",
909
915
  className: "scanner-camera-overlay__shutter",
910
916
  onClick: () => void s(),
911
917
  disabled: t !== "ready" || !!d,
912
918
  "aria-label": u ? "Take a photo with the system camera" : "Capture full-resolution photo",
913
- children: /* @__PURE__ */ x("span", {})
919
+ children: /* @__PURE__ */ S("span", {})
914
920
  }),
915
- !u && /* @__PURE__ */ S("div", {
921
+ !u && /* @__PURE__ */ C("div", {
916
922
  className: "scanner-camera-overlay__toggles",
917
- children: [n?.autoCapture.visible && /* @__PURE__ */ S("label", { children: [/* @__PURE__ */ x("input", {
923
+ children: [n?.autoCapture.visible && /* @__PURE__ */ C("label", { children: [/* @__PURE__ */ S("input", {
918
924
  type: "checkbox",
919
925
  checked: n.autoCapture.checked,
920
926
  onChange: (e) => c(e.target.checked)
921
- }), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ S("label", {
927
+ }), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ C("label", {
922
928
  title: r.torch.automatic ? "Torch is controlled automatically from scene brightness" : void 0,
923
- children: [/* @__PURE__ */ x("input", {
929
+ children: [/* @__PURE__ */ S("input", {
924
930
  type: "checkbox",
925
931
  checked: r.torch.on,
926
932
  disabled: !r.torch.mutable,
@@ -930,18 +936,18 @@ function I() {
930
936
  })
931
937
  ]
932
938
  }),
933
- /* @__PURE__ */ S("div", {
939
+ /* @__PURE__ */ C("div", {
934
940
  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…" })]
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…" })]
936
942
  })
937
943
  ]
938
944
  });
939
945
  }
940
- function L({ snapshot: e }) {
946
+ function R({ snapshot: e }) {
941
947
  let { modelDownload: t } = D();
942
- return /* @__PURE__ */ x(O, { snapshot: e ?? t });
948
+ return /* @__PURE__ */ S(fe, { snapshot: e ?? t });
943
949
  }
944
950
  //#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 };
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 };
946
952
 
947
953
  //# sourceMappingURL=react.js.map