@exige/web-scanner-sdk 0.2.28 → 0.2.30

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