@exige/web-scanner-sdk 0.2.9 → 0.2.11

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 { m as e, o as t, p as n, s as r, v as i } from "./finder-DFueuWuS.js";
2
+ import { m as e, o as t, p as n, s as r, v as i } from "./finder-BeINpYm3.js";
3
3
  import { createContext as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
4
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
4
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
5
5
  //#region src/sdk/display-quad.ts
6
- function m(e) {
6
+ function h(e) {
7
7
  return [
8
8
  e.topLeft,
9
9
  e.topRight,
@@ -11,7 +11,7 @@ function m(e) {
11
11
  e.bottomLeft
12
12
  ];
13
13
  }
14
- function h(e) {
14
+ function g(e) {
15
15
  let [t, n, r, i] = e;
16
16
  return {
17
17
  topLeft: t,
@@ -38,8 +38,8 @@ function h(e) {
38
38
  }
39
39
  };
40
40
  }
41
- function g(e) {
42
- return h(m(e).map((e) => ({ ...e })));
41
+ function _(e) {
42
+ return g(h(e).map((e) => ({ ...e })));
43
43
  }
44
44
  var ee = class {
45
45
  current;
@@ -50,11 +50,11 @@ var ee = 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 || m(e).some((e, t) => {
54
- let n = m(this.current)[t];
53
+ let r = Math.max(1, Math.hypot(t, n)), i = !this.current || h(e).some((e, t) => {
54
+ let n = h(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 = g(e), i && (this.current = g(e)), {
57
+ return this.target = _(e), i && (this.current = _(e)), {
58
58
  quad: this.current,
59
59
  snapped: i
60
60
  };
@@ -62,8 +62,8 @@ var ee = 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 = h(m(this.current).map((e, n) => {
66
- let r = m(this.target)[n];
65
+ return this.current = g(h(this.current).map((e, n) => {
66
+ let r = h(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,43 +76,59 @@ var ee = class {
76
76
  getCurrent() {
77
77
  return this.current;
78
78
  }
79
- }, _ = a(null);
79
+ }, te = a(null);
80
80
  //#endregion
81
81
  //#region src/react/context.tsx
82
- function v({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onCapture: p, onCancel: m, onError: h, onSettings: g, onFinderStatus: v, modelUrl: y, ortWasmPaths: b, detectionIntervalMs: x, apiRef: S, children: C }) {
82
+ function v(e) {
83
+ e?.startsWith("blob:") && URL.revokeObjectURL(e);
84
+ }
85
+ function ne(e) {
86
+ try {
87
+ let t = e.toDataURL("image/jpeg", .92);
88
+ return t.startsWith("data:image/") ? t : void 0;
89
+ } catch {
90
+ return;
91
+ }
92
+ }
93
+ function y({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onCapture: f, onCancel: m, onError: h, onSettings: g, onFinderStatus: _, modelUrl: y, ortWasmPaths: b, detectionIntervalMs: x, apiRef: S, children: C }) {
83
94
  let w = u(void 0), T = u(void 0), E = u(void 0), D = u(void 0), O = u({}), k = u(new ee()), A = u(!1), j = u({
84
- onCapture: p,
95
+ onCapture: f,
85
96
  onCancel: m,
86
97
  onError: h,
87
98
  onSettings: g,
88
- onFinderStatus: v
89
- }), M = u(null), [N, te] = d(null), [ne, P] = d("starting"), [F, I] = d(), [re, L] = d(), [R, ie] = d({
99
+ onFinderStatus: _
100
+ }), M = u(null), [N, P] = d(null), [re, F] = d("starting"), [I, L] = d(), [ie, R] = d(), [ae, oe] = d({
90
101
  width: 1,
91
102
  height: 1
92
- }), [ae, oe] = d(), [se, z] = d(), [ce, B] = d(""), [V, le] = d(0), [ue, H] = d(), [de, U] = d(), [fe, W] = d("idle");
103
+ }), [se, ce] = d(), [le, z] = d(), [ue, B] = d(""), [V, de] = d(0), [fe, H] = d(), [pe, U] = d(), [me, W] = d("idle"), [he, G] = d(), K = u(void 0), q = o(() => {
104
+ v(K.current), K.current = void 0, G(void 0);
105
+ }, []), J = o((e, t) => {
106
+ let n = ne(e);
107
+ v(K.current), K.current = n, G(n), t?.pause();
108
+ }, []);
93
109
  c(() => {
94
110
  j.current = {
95
- onCapture: p,
111
+ onCapture: f,
96
112
  onCancel: m,
97
113
  onError: h,
98
114
  onSettings: g,
99
- onFinderStatus: v
115
+ onFinderStatus: _
100
116
  };
101
117
  }, [
102
- p,
118
+ f,
103
119
  m,
104
120
  h,
105
121
  g,
106
- v
122
+ _
107
123
  ]);
108
- let pe = o((e) => {
109
- te(e);
124
+ let ge = o((e) => {
125
+ P(e);
110
126
  }, []);
111
127
  c(() => {
112
128
  if (!n || !N) return;
113
129
  let e = () => {
114
130
  let e = N.getBoundingClientRect();
115
- ie({
131
+ oe({
116
132
  width: e.width,
117
133
  height: e.height
118
134
  });
@@ -131,16 +147,16 @@ function v({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onC
131
147
  if (!n) return;
132
148
  let e = 0, t = performance.now(), r = (n) => {
133
149
  let i = k.current.step(n - t);
134
- t = n, i && L(i), e = requestAnimationFrame(r);
150
+ t = n, i && R(i), e = requestAnimationFrame(r);
135
151
  };
136
152
  return e = requestAnimationFrame(r), () => cancelAnimationFrame(e);
137
153
  }, [n]), c(() => {
138
154
  if (!n || !N) return;
139
155
  let e = !1, t = () => {
140
- T.current?.stop(), T.current = void 0, w.current?.stop(), w.current = void 0, D.current = void 0, E.current = void 0, O.current = {};
156
+ T.current?.stop(), T.current = void 0, w.current?.stop(), w.current = void 0, D.current = void 0, E.current = void 0, O.current = {}, q();
141
157
  };
142
158
  return (async () => {
143
- t(), A.current = !1, P("starting"), B(""), I(void 0), z(void 0), U(void 0), W("idle");
159
+ t(), A.current = !1, F("starting"), B(""), L(void 0), z(void 0), U(void 0), W("idle"), q();
144
160
  try {
145
161
  let t = await i(N, { torch: s });
146
162
  if (e) {
@@ -149,7 +165,7 @@ function v({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onC
149
165
  }
150
166
  w.current = t;
151
167
  let n = t.getSettings();
152
- oe(n), j.current.onSettings?.(n), console.info("[ScannerProvider] camera settings", n), T.current = await r({
168
+ ce(n), j.current.onSettings?.(n), console.info("[ScannerProvider] camera settings", n), T.current = await r({
153
169
  source: N,
154
170
  autoCapture: a,
155
171
  intervalMs: x,
@@ -158,24 +174,24 @@ function v({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onC
158
174
  ortWasmPaths: b
159
175
  },
160
176
  onStatus: (e) => {
161
- if (E.current = e, I(e), j.current.onFinderStatus?.(e), e.quad && e.sourceWidth && e.sourceHeight) {
177
+ if (E.current = e, L(e), j.current.onFinderStatus?.(e), e.quad && e.sourceWidth && e.sourceHeight) {
162
178
  let t = k.current.setTarget(e.quad, e.sourceWidth, e.sourceHeight);
163
- L(t.quad);
164
- } else k.current.clear(), L(void 0);
165
- e.state !== "captured" && !A.current && P("ready");
179
+ R(t.quad);
180
+ } else k.current.clear(), R(void 0);
181
+ e.state !== "captured" && !A.current && F("ready");
166
182
  },
167
183
  captureFrame: async () => {
168
- P("capturing"), O.current = {
184
+ F("capturing"), O.current = {
169
185
  quad: k.current.getCurrent(),
170
186
  sourceWidth: E.current?.sourceWidth,
171
187
  sourceHeight: E.current?.sourceHeight
172
188
  };
173
189
  let e = await t.capturePhoto();
174
190
  if (D.current = e, z(e.method), U(e.diagnostics), H(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.`);
175
- return e.frame;
191
+ return J(e.frame, N), F("captured"), e.frame;
176
192
  },
177
193
  onCaptureError: (e) => {
178
- A.current = !0, P("error"), B(e.message);
194
+ A.current = !0, F("error"), B(e.message);
179
195
  let t = w.current?.getDiagnostics();
180
196
  t && H(t), j.current.onError?.(e);
181
197
  },
@@ -198,7 +214,7 @@ function v({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onC
198
214
  if (e) return;
199
215
  t();
200
216
  let r = n instanceof Error ? n : /* @__PURE__ */ Error("Camera access failed.");
201
- B(r.message), P("error"), j.current.onError?.(r);
217
+ B(r.message), F("error"), j.current.onError?.(r);
202
218
  }
203
219
  })(), () => {
204
220
  e = !0, t();
@@ -211,48 +227,51 @@ function v({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onC
211
227
  y,
212
228
  b,
213
229
  x,
214
- V
230
+ V,
231
+ q,
232
+ J
215
233
  ]);
216
- let G = {
234
+ let Y = {
217
235
  open: n,
218
- phase: ne,
236
+ phase: re,
219
237
  autoCapture: a,
220
- finderStatus: F,
221
- displayQuad: re,
222
- previewSize: R,
223
- settings: ae,
224
- captureMethod: se,
225
- error: ce,
226
- diagnostics: ue,
227
- shutterDiagnostics: de,
228
- copyState: fe,
229
- guidanceHint: F ? t(F.guidance, F.lighting) : void 0,
230
- detectorStatus: F?.modelStatus === "failed" ? "ML failed" : F?.detector === "ml" ? `ML ${F.modelProvider ?? ""}`.trim() : "ML loading"
238
+ finderStatus: I,
239
+ displayQuad: ie,
240
+ previewSize: ae,
241
+ settings: se,
242
+ captureMethod: le,
243
+ error: ue,
244
+ diagnostics: fe,
245
+ shutterDiagnostics: pe,
246
+ copyState: me,
247
+ guidanceHint: I ? t(I.guidance, I.lighting) : void 0,
248
+ detectorStatus: I?.modelStatus === "failed" ? "ML failed" : I?.detector === "ml" ? `ML ${I.modelProvider ?? ""}`.trim() : "ML loading",
249
+ frozenPreviewUrl: he
231
250
  };
232
251
  c(() => {
233
- M.current = G;
252
+ M.current = Y;
234
253
  });
235
- let K = o(() => {
254
+ let X = o(() => {
236
255
  j.current.onCancel();
237
- }, []), q = o(async () => {
256
+ }, []), Z = o(async () => {
238
257
  try {
239
258
  await T.current?.capture();
240
259
  } catch (e) {
241
260
  let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not capture the camera frame.");
242
261
  A.current = !0, B(t.message);
243
262
  let n = w.current?.getDiagnostics();
244
- n && H(n), D.current?.diagnostics && U(D.current.diagnostics), P("error"), j.current.onError?.(t);
263
+ n && H(n), D.current?.diagnostics && U(D.current.diagnostics), F("error"), j.current.onError?.(t);
245
264
  }
246
- }, []), J = o(() => {
247
- A.current = !1, B(""), U(void 0), W("idle");
265
+ }, []), Q = o(() => {
266
+ A.current = !1, B(""), U(void 0), W("idle"), q();
248
267
  let e = w.current;
249
- P(e ? "ready" : "starting"), e || le((e) => e + 1);
250
- }, []), Y = o(async (e) => {
268
+ N?.paused && N.play(), F(e ? "ready" : "starting"), e || de((e) => e + 1);
269
+ }, [q, N]), _e = o(async (e) => {
251
270
  let t = w.current;
252
271
  t && (await t.setTorch(e), H(t.getDiagnostics()));
253
- }, []), X = o((e) => {
272
+ }, []), ve = o((e) => {
254
273
  T.current?.setAutoCapture(e);
255
- }, []), Z = o(async () => {
274
+ }, []), ye = o(async () => {
256
275
  let t = M.current, n = w.current?.getDiagnostics() ?? t.diagnostics, r = t.finderStatus, i = e({
257
276
  error: t.error || void 0,
258
277
  captureMethod: t.captureMethod,
@@ -283,51 +302,51 @@ function v({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onC
283
302
  } catch {
284
303
  W("failed");
285
304
  }
286
- }, []), Q = o(() => M.current, []), $ = l(() => ({
287
- capture: q,
288
- cancel: K,
289
- retry: J,
290
- setTorch: Y,
291
- setAutoCapture: X,
292
- copyReport: Z,
293
- getState: Q
305
+ }, []), be = o(() => M.current, []), $ = l(() => ({
306
+ capture: Z,
307
+ cancel: X,
308
+ retry: Q,
309
+ setTorch: _e,
310
+ setAutoCapture: ve,
311
+ copyReport: ye,
312
+ getState: be
294
313
  }), [
295
- q,
296
- K,
297
- J,
298
- Y,
299
- X,
300
314
  Z,
301
- Q
315
+ X,
316
+ Q,
317
+ _e,
318
+ ve,
319
+ ye,
320
+ be
302
321
  ]);
303
322
  c(() => {
304
323
  if (S) return S.current = $, () => {
305
324
  S.current = null;
306
325
  };
307
326
  }, [$, S]);
308
- let me = {
309
- ...G,
327
+ let xe = {
328
+ ...Y,
310
329
  ...$,
311
- bindPreview: pe
330
+ bindPreview: ge
312
331
  };
313
- return /* @__PURE__ */ f(_.Provider, {
314
- value: me,
332
+ return /* @__PURE__ */ p(te.Provider, {
333
+ value: xe,
315
334
  children: C
316
335
  });
317
336
  }
318
337
  //#endregion
319
338
  //#region src/react/hooks.ts
320
- function y() {
339
+ function b() {
321
340
  return u(null);
322
341
  }
323
- function b() {
324
- let e = s(_);
342
+ function x() {
343
+ let e = s(te);
325
344
  if (!e) throw Error("useScanner must be used within ScannerProvider.");
326
345
  return e;
327
346
  }
328
347
  //#endregion
329
348
  //#region src/live-overlay-geometry.ts
330
- function x(e, t, n, r, i) {
349
+ function S(e, t, n, r, i) {
331
350
  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;
332
351
  if (i === "contain") return {
333
352
  viewBox: `0 0 ${a} ${o}`,
@@ -347,10 +366,10 @@ function x(e, t, n, r, i) {
347
366
  }
348
367
  //#endregion
349
368
  //#region src/components/ModelDownloadRing.tsx
350
- function S({ snapshot: e }) {
369
+ function C({ snapshot: e }) {
351
370
  if (!e.downloading) return null;
352
371
  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;
353
- return /* @__PURE__ */ p("div", {
372
+ return /* @__PURE__ */ m("div", {
354
373
  className: `model-download-ring${t === null ? " is-indeterminate" : ""}`,
355
374
  role: "progressbar",
356
375
  "aria-label": "Model download",
@@ -359,15 +378,15 @@ function S({ snapshot: e }) {
359
378
  "aria-valuenow": n ?? void 0,
360
379
  "data-loaded": e.loaded,
361
380
  "data-total": e.total ?? "",
362
- children: [/* @__PURE__ */ p("svg", {
381
+ children: [/* @__PURE__ */ m("svg", {
363
382
  viewBox: "0 0 72 72",
364
383
  "aria-hidden": "true",
365
- children: [/* @__PURE__ */ f("circle", {
384
+ children: [/* @__PURE__ */ p("circle", {
366
385
  className: "track",
367
386
  cx: "36",
368
387
  cy: "36",
369
388
  r: 28
370
- }), /* @__PURE__ */ f("circle", {
389
+ }), /* @__PURE__ */ p("circle", {
371
390
  className: "value",
372
391
  cx: "36",
373
392
  cy: "36",
@@ -375,15 +394,15 @@ function S({ snapshot: e }) {
375
394
  strokeDasharray: t === null ? void 0 : `${r} ${r}`,
376
395
  strokeDashoffset: t === null ? void 0 : r * (1 - t)
377
396
  })]
378
- }), n === null ? /* @__PURE__ */ f("strong", {
397
+ }), n === null ? /* @__PURE__ */ p("strong", {
379
398
  className: "model-download-ring__pending",
380
399
  children: "…"
381
- }) : /* @__PURE__ */ p("strong", { children: [n, "%"] })]
400
+ }) : /* @__PURE__ */ m("strong", { children: [n, "%"] })]
382
401
  });
383
402
  }
384
403
  //#endregion
385
404
  //#region src/react/parts.tsx
386
- var C = {
405
+ var w = {
387
406
  primaryColorHex: "--scanner-overlay-primary",
388
407
  seekingColorHex: "--scanner-overlay-seeking",
389
408
  detectingColorHex: "--scanner-overlay-detecting",
@@ -391,23 +410,23 @@ var C = {
391
410
  readyColorHex: "--scanner-overlay-ready",
392
411
  capturedColorHex: "--scanner-overlay-captured"
393
412
  };
394
- function w(e) {
413
+ function T(e) {
395
414
  if (!e) return;
396
415
  let t = {};
397
- for (let [n, r] of Object.entries(C)) {
416
+ for (let [n, r] of Object.entries(w)) {
398
417
  let i = e[n]?.trim();
399
418
  i && (t[r] = i);
400
419
  }
401
420
  return Object.keys(t).length > 0 ? t : void 0;
402
421
  }
403
- function T({ theme: e, style: t, title: n = "Scan a document", children: r }) {
404
- let i = b();
422
+ function E({ theme: e, style: t, title: n = "Scan a document", children: r }) {
423
+ let i = x();
405
424
  if (!i.open) return null;
406
- let a = w(e), o = a ? {
425
+ let a = T(e), o = a ? {
407
426
  ...t,
408
427
  ...a
409
428
  } : t;
410
- return /* @__PURE__ */ f("div", {
429
+ return /* @__PURE__ */ p("div", {
411
430
  className: `scanner-camera-overlay ${i.finderStatus?.state === "captured" ? "is-captured" : ""}`.trim(),
412
431
  style: o,
413
432
  role: "dialog",
@@ -416,43 +435,54 @@ function T({ theme: e, style: t, title: n = "Scan a document", children: r }) {
416
435
  children: r
417
436
  });
418
437
  }
419
- function E() {
420
- let { bindPreview: e } = b();
421
- return /* @__PURE__ */ f("video", {
422
- ref: e,
438
+ function D() {
439
+ let { bindPreview: e, frozenPreviewUrl: t } = x(), n = u(null), r = o((t) => {
440
+ n.current = t, e(t);
441
+ }, [e]);
442
+ return c(() => {
443
+ t && n.current?.pause();
444
+ }, [t]), /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("video", {
445
+ ref: r,
423
446
  className: "scanner-camera-overlay__video",
424
447
  muted: !0,
425
448
  autoPlay: !0,
426
449
  playsInline: !0,
427
450
  style: { objectFit: "cover" },
451
+ "aria-hidden": !!t,
428
452
  "aria-label": "Rear camera preview"
429
- });
453
+ }), t ? /* @__PURE__ */ p("img", {
454
+ src: t,
455
+ className: "scanner-camera-overlay__video scanner-camera-overlay__still",
456
+ alt: "",
457
+ "aria-label": "Captured document"
458
+ }) : null] });
430
459
  }
431
- function D() {
432
- let { finderStatus: e, displayQuad: t, previewSize: n } = b();
460
+ function O() {
461
+ let { finderStatus: e, displayQuad: t, previewSize: n } = x();
433
462
  if (!t || !e?.sourceWidth || !e.sourceHeight) return null;
434
- let r = x(e.sourceWidth, e.sourceHeight, n.width, n.height, "cover");
435
- return /* @__PURE__ */ f("svg", {
463
+ let r = S(e.sourceWidth, e.sourceHeight, n.width, n.height, "cover");
464
+ return /* @__PURE__ */ p("svg", {
436
465
  className: `scanner-camera-overlay__quad ${e.state}`,
437
466
  viewBox: r.viewBox,
438
467
  preserveAspectRatio: r.preserveAspectRatio,
439
468
  "aria-label": `${e.state} document boundary`,
440
- children: /* @__PURE__ */ f("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}` })
469
+ children: /* @__PURE__ */ p("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}` })
441
470
  });
442
471
  }
443
- function O({ title: e = "Scan a document" }) {
444
- let { phase: t, guidanceHint: n, cancel: r } = b();
445
- return /* @__PURE__ */ p("div", {
472
+ function k({ title: e = "Scan a document" }) {
473
+ let { phase: t, guidanceHint: n, cancel: r } = x();
474
+ return /* @__PURE__ */ m("div", {
446
475
  className: "scanner-camera-overlay__topbar",
447
- children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("strong", { children: e }), /* @__PURE__ */ p("span", {
476
+ children: [/* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("strong", { children: e }), /* @__PURE__ */ m("span", {
448
477
  "aria-live": "polite",
449
478
  children: [
450
479
  t === "starting" && "Starting rear camera…",
451
480
  t === "ready" && (n ?? "Place the document in the frame"),
452
481
  t === "capturing" && "Capturing full resolution…",
482
+ t === "captured" && "Document captured",
453
483
  t === "error" && "Camera unavailable"
454
484
  ]
455
- })] }), /* @__PURE__ */ f("button", {
485
+ })] }), /* @__PURE__ */ p("button", {
456
486
  type: "button",
457
487
  onClick: r,
458
488
  "aria-label": "Close camera",
@@ -460,51 +490,51 @@ function O({ title: e = "Scan a document" }) {
460
490
  })]
461
491
  });
462
492
  }
463
- function k() {
464
- let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o } = b();
465
- return e === "error" ? /* @__PURE__ */ p("div", {
493
+ function A() {
494
+ let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o } = x();
495
+ return e === "error" ? /* @__PURE__ */ m("div", {
466
496
  className: "scanner-camera-overlay__message",
467
497
  role: "alert",
468
498
  children: [
469
- /* @__PURE__ */ f("strong", { children: n ? "Capture failed" : "Could not open the camera" }),
470
- /* @__PURE__ */ f("p", { children: t }),
471
- /* @__PURE__ */ p("div", { children: [
472
- /* @__PURE__ */ f("button", {
499
+ /* @__PURE__ */ p("strong", { children: n ? "Capture failed" : "Could not open the camera" }),
500
+ /* @__PURE__ */ p("p", { children: t }),
501
+ /* @__PURE__ */ m("div", { children: [
502
+ /* @__PURE__ */ p("button", {
473
503
  type: "button",
474
504
  onClick: i,
475
505
  children: "Try again"
476
506
  }),
477
- /* @__PURE__ */ f("button", {
507
+ /* @__PURE__ */ p("button", {
478
508
  type: "button",
479
509
  onClick: () => void a(),
480
510
  children: r === "copied" ? "Copied" : r === "failed" ? "Copy failed" : "Copy report"
481
511
  }),
482
- /* @__PURE__ */ f("button", {
512
+ /* @__PURE__ */ p("button", {
483
513
  type: "button",
484
514
  onClick: o,
485
515
  children: "Cancel"
486
516
  })
487
517
  ] })
488
518
  ]
489
- }) : e === "starting" ? /* @__PURE__ */ p("div", {
519
+ }) : e === "starting" ? /* @__PURE__ */ m("div", {
490
520
  className: "scanner-camera-overlay__message",
491
521
  "aria-live": "polite",
492
522
  children: [
493
- /* @__PURE__ */ f("span", { className: "scanner-camera-overlay__spinner" }),
494
- /* @__PURE__ */ f("strong", { children: "Requesting the highest practical resolution" }),
495
- /* @__PURE__ */ f("p", { children: "Allow camera access to continue." })
523
+ /* @__PURE__ */ p("span", { className: "scanner-camera-overlay__spinner" }),
524
+ /* @__PURE__ */ p("strong", { children: "Requesting the highest practical resolution" }),
525
+ /* @__PURE__ */ p("p", { children: "Allow camera access to continue." })
496
526
  ]
497
527
  }) : null;
498
528
  }
499
- function A() {
500
- let { finderStatus: e, detectorStatus: t, settings: n } = b(), r = n?.width, i = n?.height;
501
- return /* @__PURE__ */ f("div", {
529
+ function j() {
530
+ let { finderStatus: e, detectorStatus: t, settings: n } = x(), r = n?.width, i = n?.height;
531
+ return /* @__PURE__ */ p("div", {
502
532
  className: "scanner-camera-overlay__status",
503
533
  "aria-live": "polite",
504
- children: /* @__PURE__ */ p("div", {
534
+ children: /* @__PURE__ */ m("div", {
505
535
  className: "scanner-camera-overlay__status-line",
506
536
  children: [
507
- /* @__PURE__ */ f("span", { className: e?.state ?? "detecting" }),
537
+ /* @__PURE__ */ p("span", { className: e?.state ?? "detecting" }),
508
538
  e?.state ?? "detecting",
509
539
  e ? ` · ${Math.round(e.confidence * 100)}% · ${e.stableFrames}/${e.requiredStableFrames}` : "",
510
540
  ` · ${t}`,
@@ -514,25 +544,25 @@ function A() {
514
544
  })
515
545
  });
516
546
  }
517
- function j() {
518
- let { diagnostics: e, shutterDiagnostics: t, captureMethod: r, copyState: i, copyReport: a } = b(), o = e?.engine ?? n();
519
- return /* @__PURE__ */ p("dl", {
547
+ function M() {
548
+ let { diagnostics: e, shutterDiagnostics: t, captureMethod: r, copyState: i, copyReport: a } = x(), o = e?.engine ?? n();
549
+ return /* @__PURE__ */ m("dl", {
520
550
  className: "scanner-camera-overlay__diagnostics",
521
551
  "aria-label": "Camera diagnostics",
522
552
  children: [
523
- /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "engine" }), /* @__PURE__ */ p("dd", { children: [
553
+ /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "engine" }), /* @__PURE__ */ m("dd", { children: [
524
554
  o.engine,
525
555
  "/",
526
556
  o.browser,
527
557
  o.iosWebKit ? " ios" : ""
528
558
  ] })] }),
529
- /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "video" }), /* @__PURE__ */ f("dd", { children: e ? `${e.videoWidth}×${e.videoHeight} rs${e.readyState}${e.paused ? " paused" : ""}${e.rendered ? "" : " hidden"}` : "starting" })] }),
530
- /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "track" }), /* @__PURE__ */ f("dd", { children: e ? `${e.trackReadyState}${e.trackMuted ? " muted" : ""}${e.trackEnabled ? "" : " disabled"}` : "—" })] }),
531
- /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "torch" }), /* @__PURE__ */ f("dd", { children: e ? `${e.torch.mode} · ${e.torch.supported ? e.torch.on ? "on" : "off" : "unsupported"}` : "starting" })] }),
532
- /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "luma" }), /* @__PURE__ */ f("dd", { children: e ? `live ${e.liveLuminance.toFixed(1)} · mirror ${e.mirrorLuminance.toFixed(1)}${Number.isFinite(e.mirrorAgeMs) ? ` (${Math.round(e.mirrorAgeMs)}ms)` : " (none)"}` : "—" })] }),
533
- /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "path" }), /* @__PURE__ */ f("dd", { children: r ?? "video-frame / live-mirror" })] }),
534
- t ? /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "shutter" }), /* @__PURE__ */ f("dd", { children: `live ${t.liveLuminance.toFixed(1)} · mirror ${t.mirrorLuminance.toFixed(1)}${Number.isFinite(t.mirrorAgeMs) ? ` (${Math.round(t.mirrorAgeMs)}ms)` : " (none)"}` })] }) : null,
535
- /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "share" }), /* @__PURE__ */ f("dd", { children: /* @__PURE__ */ f("button", {
559
+ /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "video" }), /* @__PURE__ */ p("dd", { children: e ? `${e.videoWidth}×${e.videoHeight} rs${e.readyState}${e.paused ? " paused" : ""}${e.rendered ? "" : " hidden"}` : "starting" })] }),
560
+ /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "track" }), /* @__PURE__ */ p("dd", { children: e ? `${e.trackReadyState}${e.trackMuted ? " muted" : ""}${e.trackEnabled ? "" : " disabled"}` : "—" })] }),
561
+ /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "torch" }), /* @__PURE__ */ p("dd", { children: e ? `${e.torch.mode} · ${e.torch.supported ? e.torch.on ? "on" : "off" : "unsupported"}` : "starting" })] }),
562
+ /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "luma" }), /* @__PURE__ */ p("dd", { children: e ? `live ${e.liveLuminance.toFixed(1)} · mirror ${e.mirrorLuminance.toFixed(1)}${Number.isFinite(e.mirrorAgeMs) ? ` (${Math.round(e.mirrorAgeMs)}ms)` : " (none)"}` : "—" })] }),
563
+ /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "path" }), /* @__PURE__ */ p("dd", { children: r ?? "video-frame / live-mirror" })] }),
564
+ t ? /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "shutter" }), /* @__PURE__ */ p("dd", { children: `live ${t.liveLuminance.toFixed(1)} · mirror ${t.mirrorLuminance.toFixed(1)}${Number.isFinite(t.mirrorAgeMs) ? ` (${Math.round(t.mirrorAgeMs)}ms)` : " (none)"}` })] }) : null,
565
+ /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "share" }), /* @__PURE__ */ p("dd", { children: /* @__PURE__ */ p("button", {
536
566
  type: "button",
537
567
  className: "scanner-camera-overlay__copy",
538
568
  onClick: () => void a(),
@@ -541,35 +571,35 @@ function j() {
541
571
  ]
542
572
  });
543
573
  }
544
- function M() {
545
- let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l } = b(), u = a?.width, d = a?.height;
546
- return /* @__PURE__ */ p("div", {
574
+ function N() {
575
+ let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l } = x(), u = a?.width, d = a?.height;
576
+ return /* @__PURE__ */ m("div", {
547
577
  className: "scanner-camera-overlay__controls",
548
578
  children: [
549
- /* @__PURE__ */ f("button", {
579
+ /* @__PURE__ */ p("button", {
550
580
  type: "button",
551
581
  className: "scanner-camera-overlay__cancel",
552
582
  onClick: o,
553
583
  children: "Cancel"
554
584
  }),
555
- /* @__PURE__ */ p("div", {
585
+ /* @__PURE__ */ m("div", {
556
586
  className: "scanner-camera-overlay__capture",
557
- children: [e !== "only" && /* @__PURE__ */ f("button", {
587
+ children: [e !== "only" && /* @__PURE__ */ p("button", {
558
588
  type: "button",
559
589
  className: "scanner-camera-overlay__shutter",
560
590
  onClick: () => void s(),
561
591
  disabled: t !== "ready",
562
592
  "aria-label": "Capture full-resolution photo",
563
- children: /* @__PURE__ */ f("span", {})
564
- }), /* @__PURE__ */ p("div", {
593
+ children: /* @__PURE__ */ p("span", {})
594
+ }), /* @__PURE__ */ m("div", {
565
595
  className: "scanner-camera-overlay__toggles",
566
- children: [n?.autoCapture.visible && /* @__PURE__ */ p("label", { children: [/* @__PURE__ */ f("input", {
596
+ children: [n?.autoCapture.visible && /* @__PURE__ */ m("label", { children: [/* @__PURE__ */ p("input", {
567
597
  type: "checkbox",
568
598
  checked: n.autoCapture.checked,
569
599
  onChange: (e) => c(e.target.checked)
570
- }), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ p("label", {
600
+ }), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ m("label", {
571
601
  title: r.torch.automatic ? "Torch is controlled automatically from scene brightness" : void 0,
572
- children: [/* @__PURE__ */ f("input", {
602
+ children: [/* @__PURE__ */ p("input", {
573
603
  type: "checkbox",
574
604
  checked: r.torch.on,
575
605
  disabled: !r.torch.mutable,
@@ -578,17 +608,17 @@ function M() {
578
608
  })]
579
609
  })]
580
610
  }),
581
- /* @__PURE__ */ p("div", {
611
+ /* @__PURE__ */ m("div", {
582
612
  className: "scanner-camera-overlay__quality",
583
- children: [/* @__PURE__ */ f("span", { children: i === "live-mirror" ? "Mirror" : "Camera" }), /* @__PURE__ */ f("strong", { children: u && d ? `${u} × ${d}` : "Measuring…" })]
613
+ children: [/* @__PURE__ */ p("span", { children: i === "live-mirror" ? "Mirror" : "Camera" }), /* @__PURE__ */ p("strong", { children: u && d ? `${u} × ${d}` : "Measuring…" })]
584
614
  })
585
615
  ]
586
616
  });
587
617
  }
588
- function N({ snapshot: e }) {
589
- return b(), e ? /* @__PURE__ */ f(S, { snapshot: e }) : null;
618
+ function P({ snapshot: e }) {
619
+ return x(), e ? /* @__PURE__ */ p(C, { snapshot: e }) : null;
590
620
  }
591
621
  //#endregion
592
- export { M as ScannerControls, j as ScannerDiagnostics, T as ScannerFrame, N as ScannerModelDownload, k as ScannerNotice, E as ScannerPreview, v as ScannerProvider, D as ScannerQuad, A as ScannerStatus, O as ScannerTopBar, b as useScanner, y as useScannerRef };
622
+ export { N as ScannerControls, M as ScannerDiagnostics, E as ScannerFrame, P as ScannerModelDownload, A as ScannerNotice, D as ScannerPreview, y as ScannerProvider, O as ScannerQuad, j as ScannerStatus, k as ScannerTopBar, x as useScanner, b as useScannerRef };
593
623
 
594
624
  //# sourceMappingURL=react.js.map