@exige/web-scanner-sdk 0.2.29 → 0.2.31

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