barcode-detector 1.0.3 → 2.0.0

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.
Files changed (61) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +251 -63
  3. package/dist/cjs/BarcodeDetector.d.ts +35 -0
  4. package/dist/cjs/index.d.ts +2 -0
  5. package/dist/cjs/index.js +1 -0
  6. package/dist/cjs/package.json +3 -0
  7. package/dist/cjs/pure.d.ts +1 -0
  8. package/dist/cjs/pure.js +3 -0
  9. package/dist/cjs/side-effects.d.ts +24 -0
  10. package/dist/cjs/side-effects.js +1 -0
  11. package/dist/cjs/utils.d.ts +9 -0
  12. package/dist/es/BarcodeDetector.d.ts +35 -0
  13. package/dist/es/index.d.ts +2 -0
  14. package/dist/es/index.js +6 -0
  15. package/dist/es/pure.d.ts +1 -0
  16. package/dist/es/pure.js +2067 -0
  17. package/dist/es/side-effects.d.ts +24 -0
  18. package/dist/es/side-effects.js +6 -0
  19. package/dist/es/utils.d.ts +9 -0
  20. package/dist/iife/index.js +3 -0
  21. package/dist/iife/pure.js +3 -0
  22. package/dist/iife/side-effects.js +3 -0
  23. package/package.json +88 -24
  24. package/.github/workflows/semantic-release.yml +0 -53
  25. package/dist/BarcodeDetector.d.ts +0 -2
  26. package/dist/BarcodeDetectorJsqr.d.ts +0 -10
  27. package/dist/SleepyWorker.d.ts +0 -7
  28. package/dist/barcode-detector.js +0 -2
  29. package/dist/barcode-detector.js.map +0 -1
  30. package/dist/barcode-detector.module.js +0 -2
  31. package/dist/barcode-detector.module.js.map +0 -1
  32. package/dist/barcode-detector.umd.js +0 -2
  33. package/dist/barcode-detector.umd.js.map +0 -1
  34. package/dist/image-data.d.ts +0 -1
  35. package/example_codes/aztec.gif +0 -0
  36. package/example_codes/codabar.png +0 -0
  37. package/example_codes/code_128.gif +0 -0
  38. package/example_codes/code_39.png +0 -0
  39. package/example_codes/code_93.png +0 -0
  40. package/example_codes/data_matrix.png +0 -0
  41. package/example_codes/ean_13.png +0 -0
  42. package/example_codes/ean_8.png +0 -0
  43. package/example_codes/ift.png +0 -0
  44. package/example_codes/multi_qr_code.jpeg +0 -0
  45. package/example_codes/pdf417.png +0 -0
  46. package/example_codes/qr_code.png +0 -0
  47. package/example_codes/upc_a.png +0 -0
  48. package/example_codes/upc_e.png +0 -0
  49. package/example_codes/upca.gif +0 -0
  50. package/example_codes/upca.jpeg +0 -0
  51. package/index.html +0 -81
  52. package/src/BarcodeDetector.ts +0 -3
  53. package/src/BarcodeDetectorJsqr.ts +0 -73
  54. package/src/BarcodeDetectorZXing.ts +0 -114
  55. package/src/SleepyWorker.ts +0 -30
  56. package/src/basic-types.ts +0 -33
  57. package/src/image-data.ts +0 -130
  58. package/src/worker/build.sh +0 -27
  59. package/src/worker/tsconfig.json +0 -6
  60. package/src/worker/worker.ts +0 -57
  61. package/test/Dockerfile +0 -7
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Niklas Gruhn
3
+ Copyright (c) 2023 Ze-Zheng Wu
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,77 +1,265 @@
1
- # :construction: WIP: BarcodeDetector Polyfill :construction:
2
- Spec compliant polyfill of the [Barcode Detection API](https://wicg.github.io/shape-detection-api/#barcode-detection-api).
3
- It can be used for barcode/QR-code recognition in images from various kinds of
4
- sources including `<canvas>`, `<img>`, `<image>` (inside SVGs), `<video>`, `File`, `Blob`, `ImageData`, `ImageBitmap`, `OffscreenCanvas`.
1
+ # barcode-detector
5
2
 
6
- [simple demo](https://gruhn.github.io/barcode-detector/index.html)
3
+ [![npm](https://img.shields.io/npm/v/barcode-detector)](https://www.npmjs.com/package/barcode-detector/v/latest) [![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/%40sec-ant/barcode-detector)](https://www.npmjs.com/package/barcode-detector/v/latest) [![jsDelivr hits (npm scoped)](https://img.shields.io/jsdelivr/npm/hm/%40sec-ant%2Fbarcode-detector?color=%23ff5627)](https://cdn.jsdelivr.net/npm/barcode-detector@latest/)
7
4
 
8
- Design goals:
9
- * spec compliance
10
- * support as many barcode formats as possible
11
- * detect multiple codes in one image
12
- * provide position/coordinate information of detected codes
13
- * sufficient performance to process live video streams
5
+ A [Barcode Detection API](https://wicg.github.io/shape-detection-api/#barcode-detection-api) polyfill that uses [ZXing webassembly](https://github.com/Sec-ant/zxing-wasm) under the hood.
14
6
 
15
- ## Installation
7
+ > This package was originally published as [`@sec-ant/barcode-detector`](https://www.npmjs.com/package/@sec-ant/barcode-detector) on the npm registry. With appreciation for the generous offer from [@gruhn](https://github.com/gruhn), the package is now released under the name `barcode-detector` starting from version 2.0.0. The original name `@sec-ant/barcode-detector` will continue to be used for versions prior to 2.0.0, and will be retained solely for maintenance purposes. Eventually, it will be deprecated at an appropriate juncture.
16
8
 
17
- ```sh
18
- npm install barcode-detector
9
+ ## Install
10
+
11
+ To install, run the following command:
12
+
13
+ ```bash
14
+ npm i barcode-detector
15
+ ```
16
+
17
+ ## Recommended Usage with Node + ESM
18
+
19
+ This package can be imported in three different ways:
20
+
21
+ ### Pure Module
22
+
23
+ ```ts
24
+ import { BarcodeDetector } from "barcode-detector/pure";
25
+ ```
26
+
27
+ To avoid potential namespace collisions, you can also rename the export:
28
+
29
+ ```ts
30
+ import { BarcodeDetector as BarcodeDetectorPolyfill } from "barcode-detector/pure";
31
+ ```
32
+
33
+ This approach is beneficial when you want to use a package to detect barcodes without polluting `globalThis`, or when your runtime already provides an implementation of the Barcode Detection API, but you still want this package to function.
34
+
35
+ ### Side Effects
36
+
37
+ ```ts
38
+ import "barcode-detector/side-effects";
39
+ ```
40
+
41
+ This approach is beneficial when you need a drop-in polyfill. If there's already an implementation of Barcode Detection API on `globalThis`, this won't take effect (type declarations will, as we cannot optionally declare types). In such cases, please use the [pure module](#pure-module) instead.
42
+
43
+ ### Both
44
+
45
+ ```ts
46
+ import { BarcodeDetector } from "barcode-detector";
47
+ ```
48
+
49
+ This approach combines the [pure module](#pure-module) and [side effects](#side-effects).
50
+
51
+ ## Recommended Usage in Modern Browsers
52
+
53
+ For [modern browsers that support ES modules](https://caniuse.com/es6-module), this package can be imported via the `<script type="module">` tags:
54
+
55
+ 1. Include side effects:
56
+
57
+ ```html
58
+ <!-- register -->
59
+ <script
60
+ type="module"
61
+ src="https://cdn.jsdelivr.net/npm/barcode-detector@2/dist/es/side-effects.min.js"
62
+ ></script>
63
+
64
+ <!-- use -->
65
+ <script type="module">
66
+ const barcodeDetector = new BarcodeDetector();
67
+ </script>
68
+ ```
69
+
70
+ 2. Script scoped access:
71
+
72
+ ```html
73
+ <script type="module">
74
+ import { BarcodeDetector } from "https://cdn.jsdelivr.net/npm/barcode-detector@2/dist/es/pure.min.js";
75
+ const barcodeDetector = new BarcodeDetector();
76
+ </script>
77
+ ```
78
+
79
+ 3. With import maps:
80
+
81
+ ```html
82
+ <!-- import map -->
83
+ <script type="importmap">
84
+ {
85
+ "imports": {
86
+ "barcode-detector/pure": "https://cdn.jsdelivr.net/npm/barcode-detector@2/dist/es/pure.min.js"
87
+ }
88
+ }
89
+ </script>
90
+
91
+ <!-- script scoped access -->
92
+ <script type="module">
93
+ import { BarcodeDetector } from "barcode-detector/pure";
94
+ const barcodeDetector = new BarcodeDetector();
95
+ </script>
96
+ ```
97
+
98
+ ## Usage with Legacy Compatibility
99
+
100
+ Starting from v1.2, this package supports IIFE and CJS build outputs for use cases that require legacy compatibility.
101
+
102
+ ### IIFE
103
+
104
+ For legacy browsers that lack support for module type `<script>` tags, or for userscripts, IIFE is the preferred choice. Upon executing the IIFE script, a variable named `BarcodeDetectionAPI` will be registered in the global.
105
+
106
+ ```html
107
+ <!--
108
+ IIFE pure.js registers:
109
+ window.BarcodeDetectionAPI.BarcodeDetector
110
+ window.BarcodeDetectionAPI.setZXingModuleOverrides
111
+ -->
112
+ <script src="https://cdn.jsdelivr.net/npm/barcode-detector@2/dist/iife/pure.min.js"></script>
113
+
114
+ <!--
115
+ IIFE side-effects.js registers:
116
+ window.BarcodeDetector
117
+ window.BarcodeDetectionAPI.setZXingModuleOverrides
118
+ -->
119
+ <script src="https://cdn.jsdelivr.net/npm/barcode-detector@2/dist/iife/side-effects.min.js"></script>
120
+
121
+ <!--
122
+ IIFE index.js registers:
123
+ window.BarcodeDetector
124
+ window.BarcodeDetectionAPI.BarcodeDetector
125
+ window.BarcodeDetectionAPI.setZXingModuleOverrides
126
+ -->
127
+ <script src="https://cdn.jsdelivr.net/npm/barcode-detector@2/dist/iife/index.min.js"></script>
128
+ ```
129
+
130
+ ### CJS
131
+
132
+ This package can also be consumed as a commonjs package:
133
+
134
+ 1. Vanilla Javascript:
135
+
136
+ ```js
137
+ // src/index.js
138
+ const { BarcodeDetector } = require("barcode-detector/pure");
139
+ ```
140
+
141
+ 2. With Typescript:
142
+
143
+ ```ts
144
+ // src/index.ts
145
+ import { BarcodeDetector } from "barcode-detector/pure";
146
+ ```
147
+
148
+ `tsconfig.json`:
149
+
150
+ ```json
151
+ {
152
+ "compilerOptions": {
153
+ "module": "CommonJS",
154
+ "moduleResolution": "Node",
155
+ "skipLibCheck": true
156
+ },
157
+ "include": ["src"]
158
+ }
159
+ ```
160
+
161
+ ## `setZXingModuleOverrides`
162
+
163
+ In addition to `BarcodeDetector`, this package exports another function called `setZXingModuleOverrides`.
164
+
165
+ This package employs [Sec-ant/zxing-wasm](https://github.com/Sec-ant/zxing-wasm) to enable the core barcode reading functionality. As a result, a `.wasm` binary file is fetched at runtime. The default fetch path for this binary file is:
166
+
167
+ ```
168
+ https://cdn.jsdelivr.net/npm/@sec-ant/zxing-wasm@<version>/dist/reader/zxing_reader.wasm
169
+ ```
170
+
171
+ The `setZXingModuleOverrides` function allows you to govern where the `.wasm` binary is served from, thereby enabling offline use of the package, use within a local network, or within a site having strict [CSP](https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#unsafe_webassembly_execution) rules.
172
+
173
+ For instance, should you want to inline this `.wasm` file in your build output for offline usage, with the assistance of build tools, you could try:
174
+
175
+ ```ts
176
+ // src/index.ts
177
+ import wasmFile from "../node_modules/@sec-ant/zxing-wasm/dist/reader/zxing_reader.wasm?url";
178
+
179
+ import {
180
+ setZXingModuleOverrides,
181
+ BarcodeDetector,
182
+ } from "barcode-detector/pure";
183
+
184
+ setZXingModuleOverrides({
185
+ locateFile: (path, prefix) => {
186
+ if (path.endsWith(".wasm")) {
187
+ return wasmFile;
188
+ }
189
+ return prefix + path;
190
+ },
191
+ });
192
+
193
+ const barcodeDetector = new BarcodeDetector();
194
+
195
+ // detect barcodes
196
+ // ...
197
+ ```
198
+
199
+ Alternatively, the `.wasm` file could be copied to your dist folder to be served from your local server, without incorporating it into the output as an extensive base64 data URL.
200
+
201
+ It's noteworthy that you'll always want to choose the correct version of the `.wasm` file, so the APIs exported by it are exactly what the js code expects.
202
+
203
+ For more information on how to use this function, you can check [the notes here](https://github.com/Sec-ant/zxing-wasm#notes) and [discussions here](https://github.com/gruhn/vue-qrcode-reader/issues/354).
204
+
205
+ This function is exported from all the subpaths, including the [side effects](#side-effects).
206
+
207
+ ## API
208
+
209
+ Please check the [spec](https://wicg.github.io/shape-detection-api/#barcode-detection-api), [MDN doc](https://developer.mozilla.org/docs/Web/API/Barcode_Detection_API) and [Chromium implementation](https://github.com/chromium/chromium/tree/main/third_party/blink/renderer/modules/shapedetection) for more information.
210
+
211
+ ## Lifecycle Events
212
+
213
+ The `BarcodeDetector` provided by this package also extends class `EventTarget` and provides 2 lifecycle events: `load` and `error`. You can use `addEventListener` and `removeEventListener` to register and remove callback hooks on these events.
214
+
215
+ ### `load` Event
216
+
217
+ The `load` event, which is a `CustomEvent`, will be dispatched on the successful instanciation of ZXing wasm module. For advanced usage, the instanciated module is passed as the `detail` parameter.
218
+
219
+ ```ts
220
+ import { BarcodeDetector } from "barcode-detector/pure";
221
+
222
+ const barcodeDetector = new BarcodeDetector();
223
+
224
+ barcodeDetector.addEventListener("load", ({ detail }) => {
225
+ console.log(detail); // zxing wasm module
226
+ });
19
227
  ```
20
- ```js
21
- import BarcodeDetector from "barcode-detector"
22
228
 
23
- // polyfill unless already supported
24
- if (!("BarcodeDetector" in window)) {
25
- window.BarcodeDetector = BarcodeDetector
26
- }
229
+ ### `error` Event
230
+
231
+ The `error` event, which is a `CustomEvent`, will be dispatched if the instanciation of ZXing wasm module is failed. An error is passed as the `detail` parameter.
232
+
233
+ ```ts
234
+ import { BarcodeDetector } from "barcode-detector/pure";
235
+
236
+ const barcodeDetector = new BarcodeDetector();
237
+
238
+ barcodeDetector.addEventListener("error", ({ detail }) => {
239
+ console.log(detail); // an error
240
+ });
27
241
  ```
28
242
 
29
- ## Usage
243
+ ## Example
30
244
 
31
- ```js
32
- // pick barcode formats. Other formats will be ignored
33
- const barcodeDetector = new BarcodeDetector({ formats: ["qr_code"] })
245
+ ```ts
246
+ import { BarcodeDetector } from "barcode-detector/pure";
34
247
 
35
- // directly pass an image element, video element, ...
36
- const barcodes = await barcodeDetector.detect(someImageSource)
248
+ const barcodeDetector: BarcodeDetector = new BarcodeDetector({
249
+ formats: ["qr_code"],
250
+ });
37
251
 
38
- // can detect multiple barcodes in one image
39
- const [ barcode1, barcode2, ...evenMoreBarcodes ] = barcodes
252
+ const imageFile = await fetch(
253
+ "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=Hello%20world!",
254
+ ).then((resp) => resp.blob());
40
255
 
41
- // access encoded string
42
- const { rawValue } = barcode1
256
+ barcodeDetector.detect(imageFile).then(console.log);
43
257
  ```
44
258
 
45
- For in-depth documentation checkout the [corresponding MDN page](https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API).
46
-
47
- ### Supported Formats
48
-
49
- `src/BarcodeDetectorJsqr.ts`:
50
- - :x: `aztec`
51
- - :x: `code_128`
52
- - :x: `code_39`
53
- - :x: `code_93`
54
- - :x: `codabar`
55
- - :x: `data_matrix`
56
- - :x: `ean_13`
57
- - :x: `ean_8`
58
- - :x: `itf`
59
- - :x: `pdf417`
60
- - :heavy_check_mark: `qr_code`
61
- - :x: `upc_a`
62
- - :x: `upc_e`
63
-
64
- `src/BarcodeDetectorZXing.ts` (not exposed at the moment. See [#1](https://github.com/gruhn/barcode-detector-polyfill/issues/1)):
65
- - :heavy_check_mark: `aztec`
66
- - :heavy_check_mark: `code_128`
67
- - :heavy_check_mark: `code_39`
68
- - :x: `code_93`
69
- - :x: `codabar`
70
- - :heavy_check_mark: `data_matrix`
71
- - :heavy_check_mark: `ean_13`
72
- - :heavy_check_mark: `ean_8`
73
- - :heavy_check_mark: `itf`
74
- - :heavy_check_mark: `pdf417`
75
- - :heavy_check_mark: `qr_code`
76
- - :x: `upc_a`
77
- - :x: `upc_e`
259
+ ## License
260
+
261
+ The source code in this repository, as well as the build output, except for the parts listed below, is licensed under the [MIT license](./LICENSE).
262
+
263
+ Test samples and resources are collected from [zxing-cpp/zxing-cpp](https://github.com/zxing-cpp/zxing-cpp), which is licensed under the [Apache-2.0 license](https://raw.githubusercontent.com/zxing-cpp/zxing-cpp/master/LICENSE), and [web-platform-tests/wpt](https://github.com/web-platform-tests/wpt), which is licensed under the [3-Clause BSD license](https://raw.githubusercontent.com/web-platform-tests/wpt/master/LICENSE.md).
264
+
265
+ This package has an indirect dependency on [Sec-ant/zxing-wasm-build](https://github.com/Sec-ant/zxing-wasm-build), which is licensed under the [Apache-2.0 license](https://raw.githubusercontent.com/Sec-ant/zxing-wasm-build/main/LICENSE).
@@ -0,0 +1,35 @@
1
+ /// <reference types="dom-webcodecs" />
2
+ import { ZXingModule } from "@sec-ant/zxing-wasm/reader";
3
+ import { BARCODE_DETECTOR_FORMATS } from "./utils.js";
4
+ export type BarcodeFormat = (typeof BARCODE_DETECTOR_FORMATS)[number];
5
+ export interface BarcodeDetectorOptions {
6
+ formats?: BarcodeFormat[];
7
+ }
8
+ export interface Point2D {
9
+ x: number;
10
+ y: number;
11
+ }
12
+ export interface DetectedBarcode {
13
+ boundingBox: DOMRectReadOnly;
14
+ rawValue: string;
15
+ format: BarcodeFormat;
16
+ cornerPoints: [Point2D, Point2D, Point2D, Point2D];
17
+ }
18
+ interface CustomEventMap {
19
+ load: CustomEvent<ZXingModule<"reader">>;
20
+ error: CustomEvent<unknown>;
21
+ }
22
+ type ChangeEventListener = <K extends keyof CustomEventMap>(type: K, callback: ((evt: CustomEventMap[K]) => void) | {
23
+ handleEvent(evt: CustomEventMap[K]): void;
24
+ } | null, options?: boolean | AddEventListenerOptions | undefined) => void;
25
+ export interface BarcodeDetector {
26
+ addEventListener: ChangeEventListener;
27
+ removeEventListener: ChangeEventListener;
28
+ }
29
+ export declare class BarcodeDetector extends EventTarget {
30
+ #private;
31
+ constructor(barcodeDectorOptions?: BarcodeDetectorOptions);
32
+ static getSupportedFormats(): Promise<readonly BarcodeFormat[]>;
33
+ detect(image: ImageBitmapSourceWebCodecs): Promise<DetectedBarcode[]>;
34
+ }
35
+ export { setZXingModuleOverrides } from "@sec-ant/zxing-wasm";
@@ -0,0 +1,2 @@
1
+ import "./side-effects.js";
2
+ export * from "./pure.js";
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./side-effects.js");const e=require("./pure.js");exports.BarcodeDetector=e.BarcodeDetector;exports.setZXingModuleOverrides=e.setZXingModuleOverrides;
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1 @@
1
+ export * from "./BarcodeDetector.js";
@@ -0,0 +1,3 @@
1
+ "use strict";var He=(c,p,u)=>{if(!p.has(c))throw TypeError("Cannot "+u)};var ke=(c,p,u)=>(He(c,p,"read from private field"),u?u.call(c):p.get(c)),Ue=(c,p,u)=>{if(p.has(c))throw TypeError("Cannot add the same private member more than once");p instanceof WeakSet?p.add(c):p.set(c,u)},Be=(c,p,u,$)=>(He(c,p,"write to private field"),$?$.call(c,u):p.set(c,u),u);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ve=["aztec","code_128","code_39","code_93","codabar","data_matrix","ean_13","ean_8","itf","pdf417","qr_code","upc_a","upc_e","unknown"];function Ra(c){if(Ge(c))return{width:c.naturalWidth,height:c.naturalHeight};if(Xe(c))return{width:c.width.baseVal.value,height:c.height.baseVal.value};if(qe(c))return{width:c.videoWidth,height:c.videoHeight};if(Ze(c))return{width:c.width,height:c.height};if(Ke(c))return{width:c.displayWidth,height:c.displayHeight};if(Je(c))return{width:c.width,height:c.height};if(Qe(c))return{width:c.width,height:c.height};throw new TypeError("The provided value is not of type '(Blob or HTMLCanvasElement or HTMLImageElement or HTMLVideoElement or ImageBitmap or ImageData or OffscreenCanvas or SVGImageElement or VideoFrame)'.")}function Ge(c){try{return c instanceof HTMLImageElement}catch{return!1}}function Xe(c){try{return c instanceof SVGImageElement}catch{return!1}}function qe(c){try{return c instanceof HTMLVideoElement}catch{return!1}}function Je(c){try{return c instanceof HTMLCanvasElement}catch{return!1}}function Ze(c){try{return c instanceof ImageBitmap}catch{return!1}}function Qe(c){try{return c instanceof OffscreenCanvas}catch{return!1}}function Ke(c){try{return c instanceof VideoFrame}catch{return!1}}function Ia(c){try{return c instanceof Blob}catch{return!1}}function Wa(c){try{return c instanceof ImageData}catch{return!1}}function Ha(c,p){try{const u=new OffscreenCanvas(c,p);if(u.getContext("2d")instanceof OffscreenCanvasRenderingContext2D)return u;throw void 0}catch{const u=document.createElement("canvas");return u.width=c,u.height=p,u}}async function tr(c){if(Ge(c)&&!await Va(c))throw new DOMException("Failed to load or decode HTMLImageElement.","InvalidStateError");if(Xe(c)&&!await za(c))throw new DOMException("Failed to load or decode SVGImageElement.","InvalidStateError");if(Ke(c)&&La(c))throw new DOMException("VideoFrame is closed.","InvalidStateError");if(qe(c)&&(c.readyState===0||c.readyState===1))throw new DOMException("Invalid element or state.","InvalidStateError");if(Ze(c)&&Na(c))throw new DOMException("The image source is detached.","InvalidStateError");const{width:p,height:u}=Ra(c);if(p===0||u===0)return null;const g=Ha(p,u).getContext("2d");g.drawImage(c,0,0);try{return g.getImageData(0,0,p,u)}catch{throw new DOMException("Source would taint origin.","SecurityError")}}async function ka(c){let p;try{p=await createImageBitmap(c)}catch{throw new DOMException("Failed to load or decode Blob.","InvalidStateError")}return await tr(p)}function Ua(c){const{width:p,height:u}=c;if(p===0||u===0)return null;const $=c.getContext("2d");try{return $.getImageData(0,0,p,u)}catch{throw new DOMException("Source would taint origin.","SecurityError")}}async function Ba(c){if(Ia(c))return await ka(c);if(Wa(c)){if(Ya(c))throw new DOMException("The image data has been detached.","InvalidStateError");return c}return Je(c)||Qe(c)?Ua(c):await tr(c)}async function Va(c){try{return await c.decode(),!0}catch{return!1}}async function za(c){var p;try{return await((p=c.decode)==null?void 0:p.call(c)),!0}catch{return!1}}function La(c){return c.format===null}function Ya(c){return c.data.buffer.byteLength===0}function Na(c){return c.width===0&&c.height===0}function ze(c,p){return c instanceof DOMException?new DOMException(`${p}: ${c.message}`,c.name):c instanceof Error?new c.constructor(`${p}: ${c.message}`):new Error(`${p}: ${c}`)}const Le=c=>{let p;const u=new Set,$=(M,G)=>{const k=typeof M=="function"?M(p):M;if(!Object.is(k,p)){const j=p;p=G??typeof k!="object"?k:Object.assign({},p,k),u.forEach(Y=>Y(p,j))}},g=()=>p,E={setState:$,getState:g,subscribe:M=>(u.add(M),()=>u.delete(M)),destroy:()=>{u.clear()}};return p=c($,g,E),E},Ga=c=>c?Le(c):Le,Xa={locateFile:(c,p)=>{var u;const $=(u=c.match(/_(.+?)\.wasm$/))==null?void 0:u[1];return $?`https://cdn.jsdelivr.net/npm/@sec-ant/zxing-wasm@2.1.3/dist/${$}/${c}`:p+c}},lt=Ga()(()=>({zxingModuleWeakMap:new WeakMap,zxingModuleOverrides:Xa}));function qa(c){lt.setState({zxingModuleOverrides:c})}function er(c,p=lt.getState().zxingModuleOverrides){const{zxingModuleWeakMap:u}=lt.getState(),$=u.get(c);if($&&Object.is(p,lt.getState().zxingModuleOverrides))return $;{lt.setState({zxingModuleOverrides:p});const g=c(p);return u.set(c,g),g}}const Ye=["Aztec","Codabar","Code128","Code39","Code93","DataBar","DataBarExpanded","DataMatrix","EAN-13","EAN-8","ITF","Linear-Codes","Matrix-Codes","MaxiCode","MicroQRCode","None","PDF417","QRCode","UPC-A","UPC-E"],rt={tryHarder:!0,formats:[],maxSymbols:255};async function Ja(c,{tryHarder:p=rt.tryHarder,formats:u=rt.formats,maxSymbols:$=rt.maxSymbols}=rt,g){const E=await er(g,lt.getState().zxingModuleOverrides),{data:M,width:G,height:k,data:{byteLength:j}}=c,Y=E._malloc(j);E.HEAP8.set(M,Y);const X=E.readBarcodesFromPixmap(Y,G,k,p,Za(u),$);E._free(Y);const V=[];for(let U=0;U<X.size();++U){const q=X.get(U);V.push({...q,format:Qa(q.format)})}return V}function Za(c){return c.join("|")}function Qa(c){const p=Ne(c);let u=0,$=Ye.length-1;for(;u<=$;){const g=Math.floor((u+$)/2),E=Ye[g],M=Ne(E);if(M===p)return E;M<p?u=g+1:$=g-1}return"None"}function Ne(c){return c.toLowerCase().replace(/_-\[\]/g,"")}var rr=(()=>{var c=typeof document>"u"?require("url").pathToFileURL(__filename).href:document.currentScript&&document.currentScript.src||new URL("pure.js",document.baseURI).href;return function(p={}){var u=p,$,g;u.ready=new Promise((t,e)=>{$=t,g=e});var E=Object.assign({},u),M="./this.program",G=typeof window=="object",k=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var j="";function Y(t){return u.locateFile?u.locateFile(t,j):j+t}var X;(G||k)&&(k?j=self.location.href:typeof document<"u"&&document.currentScript&&(j=document.currentScript.src),c&&(j=c),j.indexOf("blob:")!==0?j=j.substr(0,j.replace(/[?#].*/,"").lastIndexOf("/")+1):j="",k&&(X=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),u.print||console.log.bind(console);var V=u.printErr||console.error.bind(console);Object.assign(u,E),E=null,u.arguments&&u.arguments,u.thisProgram&&(M=u.thisProgram),u.quit&&u.quit;var U;u.wasmBinary&&(U=u.wasmBinary),u.noExitRuntime,typeof WebAssembly!="object"&&_t("no native wasm support detected");var q,A,bt=!1,z,B,ut,Ct,R,F,qt,Jt;function Zt(){var t=q.buffer;u.HEAP8=z=new Int8Array(t),u.HEAP16=ut=new Int16Array(t),u.HEAP32=R=new Int32Array(t),u.HEAPU8=B=new Uint8Array(t),u.HEAPU16=Ct=new Uint16Array(t),u.HEAPU32=F=new Uint32Array(t),u.HEAPF32=qt=new Float32Array(t),u.HEAPF64=Jt=new Float64Array(t)}var Qt,Kt=[],te=[],ee=[];function ar(){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)sr(u.preRun.shift());It(Kt)}function or(){It(te)}function ir(){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)cr(u.postRun.shift());It(ee)}function sr(t){Kt.unshift(t)}function ur(t){te.unshift(t)}function cr(t){ee.unshift(t)}var nt=0,dt=null;function fr(t){nt++,u.monitorRunDependencies&&u.monitorRunDependencies(nt)}function lr(t){if(nt--,u.monitorRunDependencies&&u.monitorRunDependencies(nt),nt==0&&dt){var e=dt;dt=null,e()}}function _t(t){u.onAbort&&u.onAbort(t),t="Aborted("+t+")",V(t),bt=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw g(e),e}var dr="data:application/octet-stream;base64,";function re(t){return t.startsWith(dr)}var at;u.locateFile?(at="zxing_reader.wasm",re(at)||(at=Y(at))):at=new URL("/reader/zxing_reader.wasm",self.location).href;function ne(t){if(t==at&&U)return new Uint8Array(U);if(X)return X(t);throw"both async and sync fetching of the wasm failed"}function hr(t){return!U&&(G||k)&&typeof fetch=="function"?fetch(t,{credentials:"same-origin"}).then(e=>{if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()}).catch(()=>ne(t)):Promise.resolve().then(()=>ne(t))}function ae(t,e,r){return hr(t).then(n=>WebAssembly.instantiate(n,e)).then(n=>n).then(r,n=>{V("failed to asynchronously prepare wasm: "+n),_t(n)})}function pr(t,e,r,n){return!t&&typeof WebAssembly.instantiateStreaming=="function"&&!re(e)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(a=>{var o=WebAssembly.instantiateStreaming(a,r);return o.then(n,function(i){return V("wasm streaming compile failed: "+i),V("falling back to ArrayBuffer instantiation"),ae(e,r,n)})}):ae(e,r,n)}function yr(){var t={a:ra};function e(n,a){var o=n.exports;return A=o,q=A.qa,Zt(),Qt=A.ua,ur(A.ra),lr(),o}fr();function r(n){e(n.instance)}if(u.instantiateWasm)try{return u.instantiateWasm(t,e)}catch(n){V("Module.instantiateWasm callback failed with error: "+n),g(n)}return pr(U,at,t,r).catch(g),{}}var It=t=>{for(;t.length>0;)t.shift()(u)},Tt=[],Pt=0;function vr(t){var e=new Et(t);return e.get_caught()||(e.set_caught(!0),Pt--),e.set_rethrown(!1),Tt.push(e),Oe(e.excPtr),e.get_exception_ptr()}var J=0;function mr(){w(0,0);var t=Tt.pop();Fe(t.excPtr),J=0}function Et(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(e){F[this.ptr+4>>2]=e},this.get_type=function(){return F[this.ptr+4>>2]},this.set_destructor=function(e){F[this.ptr+8>>2]=e},this.get_destructor=function(){return F[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,z[this.ptr+12>>0]=e},this.get_caught=function(){return z[this.ptr+12>>0]!=0},this.set_rethrown=function(e){e=e?1:0,z[this.ptr+13>>0]=e},this.get_rethrown=function(){return z[this.ptr+13>>0]!=0},this.init=function(e,r){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(r)},this.set_adjusted_ptr=function(e){F[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return F[this.ptr+16>>2]},this.get_exception_ptr=function(){var e=je(this.get_type());if(e)return F[this.excPtr>>2];var r=this.get_adjusted_ptr();return r!==0?r:this.excPtr}}function gr(t){throw J||(J=t),J}var Wt=t=>{var e=J;if(!e)return wt(0),0;var r=new Et(e);r.set_adjusted_ptr(e);var n=r.get_type();if(!n)return wt(0),e;for(var a in t){var o=t[a];if(o===0||o===n)break;var i=r.ptr+16;if(Me(o,n,i))return wt(o),e}return wt(n),e},wr=()=>Wt([]),$r=t=>Wt([t]),br=(t,e)=>Wt([t,e]);function Cr(t){var e=new Et(t).get_exception_ptr();return e}function _r(){var t=Tt.pop();t||_t("no exception to throw");var e=t.excPtr;throw t.get_rethrown()||(Tt.push(t),t.set_rethrown(!0),t.set_caught(!1),Pt++),J=e,J}function Tr(t,e,r){var n=new Et(t);throw n.init(e,r),J=t,Pt++,J}function Pr(){return Pt}var At={};function oe(t){for(;t.length;){var e=t.pop(),r=t.pop();r(e)}}function ht(t){return this.fromWireType(R[t>>2])}var ct={},ot={},Dt={},ie=void 0;function xt(t){throw new ie(t)}function it(t,e,r){t.forEach(function(s){Dt[s]=e});function n(s){var f=r(s);f.length!==t.length&&xt("Mismatched type converter count");for(var l=0;l<t.length;++l)Z(t[l],f[l])}var a=new Array(e.length),o=[],i=0;e.forEach((s,f)=>{ot.hasOwnProperty(s)?a[f]=ot[s]:(o.push(s),ct.hasOwnProperty(s)||(ct[s]=[]),ct[s].push(()=>{a[f]=ot[s],++i,i===o.length&&n(a)}))}),o.length===0&&n(a)}var Er=function(t){var e=At[t];delete At[t];var r=e.rawConstructor,n=e.rawDestructor,a=e.fields,o=a.map(i=>i.getterReturnType).concat(a.map(i=>i.setterArgumentType));it([t],o,i=>{var s={};return a.forEach((f,l)=>{var h=f.fieldName,v=i[l],m=f.getter,_=f.getterContext,D=i[l+a.length],I=f.setter,x=f.setterContext;s[h]={read:W=>v.fromWireType(m(_,W)),write:(W,d)=>{var y=[];I(x,W,D.toWireType(y,d)),oe(y)}}}),[{name:e.name,fromWireType:function(f){var l={};for(var h in s)l[h]=s[h].read(f);return n(f),l},toWireType:function(f,l){for(var h in s)if(!(h in l))throw new TypeError(`Missing field: "${h}"`);var v=r();for(h in s)s[h].write(v,l[h]);return f!==null&&f.push(n,v),v},argPackAdvance:8,readValueFromPointer:ht,destructorFunction:n}]})};function Ar(t,e,r,n,a){}function Ht(t){switch(t){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${t}`)}}function Dr(){for(var t=new Array(256),e=0;e<256;++e)t[e]=String.fromCharCode(e);se=t}var se=void 0;function H(t){for(var e="",r=t;B[r];)e+=se[B[r++]];return e}var ft=void 0;function T(t){throw new ft(t)}function xr(t,e,r={}){var n=e.name;if(t||T(`type "${n}" must have a positive integer typeid pointer`),ot.hasOwnProperty(t)){if(r.ignoreDuplicateRegistrations)return;T(`Cannot register type '${n}' twice`)}if(ot[t]=e,delete Dt[t],ct.hasOwnProperty(t)){var a=ct[t];delete ct[t],a.forEach(o=>o())}}function Z(t,e,r={}){if(!("argPackAdvance"in e))throw new TypeError("registerType registeredInstance requires argPackAdvance");return xr(t,e,r)}function Sr(t,e,r,n,a){var o=Ht(r);e=H(e),Z(t,{name:e,fromWireType:function(i){return!!i},toWireType:function(i,s){return s?n:a},argPackAdvance:8,readValueFromPointer:function(i){var s;if(r===1)s=z;else if(r===2)s=ut;else if(r===4)s=R;else throw new TypeError("Unknown boolean type size: "+e);return this.fromWireType(s[i>>o])},destructorFunction:null})}function Fr(t){if(!(this instanceof tt)||!(t instanceof tt))return!1;for(var e=this.$$.ptrType.registeredClass,r=this.$$.ptr,n=t.$$.ptrType.registeredClass,a=t.$$.ptr;e.baseClass;)r=e.upcast(r),e=e.baseClass;for(;n.baseClass;)a=n.upcast(a),n=n.baseClass;return e===n&&r===a}function Or(t){return{count:t.count,deleteScheduled:t.deleteScheduled,preservePointerOnDelete:t.preservePointerOnDelete,ptr:t.ptr,ptrType:t.ptrType,smartPtr:t.smartPtr,smartPtrType:t.smartPtrType}}function kt(t){function e(r){return r.$$.ptrType.registeredClass.name}T(e(t)+" instance already deleted")}var Ut=!1;function ue(t){}function Mr(t){t.smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr)}function ce(t){t.count.value-=1;var e=t.count.value===0;e&&Mr(t)}function fe(t,e,r){if(e===r)return t;if(r.baseClass===void 0)return null;var n=fe(t,e,r.baseClass);return n===null?null:r.downcast(n)}var le={};function jr(){return Object.keys(vt).length}function Rr(){var t=[];for(var e in vt)vt.hasOwnProperty(e)&&t.push(vt[e]);return t}var pt=[];function Bt(){for(;pt.length;){var t=pt.pop();t.$$.deleteScheduled=!1,t.delete()}}var yt=void 0;function Ir(t){yt=t,pt.length&&yt&&yt(Bt)}function Wr(){u.getInheritedInstanceCount=jr,u.getLiveInheritedInstances=Rr,u.flushPendingDeletes=Bt,u.setDelayFunction=Ir}var vt={};function Hr(t,e){for(e===void 0&&T("ptr should not be undefined");t.baseClass;)e=t.upcast(e),t=t.baseClass;return e}function kr(t,e){return e=Hr(t,e),vt[e]}function St(t,e){(!e.ptrType||!e.ptr)&&xt("makeClassHandle requires ptr and ptrType");var r=!!e.smartPtrType,n=!!e.smartPtr;return r!==n&&xt("Both smartPtrType and smartPtr must be specified"),e.count={value:1},mt(Object.create(t,{$$:{value:e}}))}function Ur(t){var e=this.getPointee(t);if(!e)return this.destructor(t),null;var r=kr(this.registeredClass,e);if(r!==void 0){if(r.$$.count.value===0)return r.$$.ptr=e,r.$$.smartPtr=t,r.clone();var n=r.clone();return this.destructor(t),n}function a(){return this.isSmartPointer?St(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:t}):St(this.registeredClass.instancePrototype,{ptrType:this,ptr:t})}var o=this.registeredClass.getActualType(e),i=le[o];if(!i)return a.call(this);var s;this.isConst?s=i.constPointerType:s=i.pointerType;var f=fe(e,this.registeredClass,s.registeredClass);return f===null?a.call(this):this.isSmartPointer?St(s.registeredClass.instancePrototype,{ptrType:s,ptr:f,smartPtrType:this,smartPtr:t}):St(s.registeredClass.instancePrototype,{ptrType:s,ptr:f})}var mt=function(t){return typeof FinalizationRegistry>"u"?(mt=e=>e,t):(Ut=new FinalizationRegistry(e=>{ce(e.$$)}),mt=e=>{var r=e.$$,n=!!r.smartPtr;if(n){var a={$$:r};Ut.register(e,a,e)}return e},ue=e=>Ut.unregister(e),mt(t))};function Br(){if(this.$$.ptr||kt(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t=mt(Object.create(Object.getPrototypeOf(this),{$$:{value:Or(this.$$)}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t}function Vr(){this.$$.ptr||kt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&T("Object already scheduled for deletion"),ue(this),ce(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function zr(){return!this.$$.ptr}function Lr(){return this.$$.ptr||kt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&T("Object already scheduled for deletion"),pt.push(this),pt.length===1&&yt&&yt(Bt),this.$$.deleteScheduled=!0,this}function Yr(){tt.prototype.isAliasOf=Fr,tt.prototype.clone=Br,tt.prototype.delete=Vr,tt.prototype.isDeleted=zr,tt.prototype.deleteLater=Lr}function tt(){}var Nr=48,Gr=57;function de(t){if(t===void 0)return"_unknown";t=t.replace(/[^a-zA-Z0-9_]/g,"$");var e=t.charCodeAt(0);return e>=Nr&&e<=Gr?`_${t}`:t}function he(t,e){return t=de(t),{[t]:function(){return e.apply(this,arguments)}}[t]}function pe(t,e,r){if(t[e].overloadTable===void 0){var n=t[e];t[e]=function(){return t[e].overloadTable.hasOwnProperty(arguments.length)||T(`Function '${r}' called with an invalid number of arguments (${arguments.length}) - expects one of (${t[e].overloadTable})!`),t[e].overloadTable[arguments.length].apply(this,arguments)},t[e].overloadTable=[],t[e].overloadTable[n.argCount]=n}}function ye(t,e,r){u.hasOwnProperty(t)?((r===void 0||u[t].overloadTable!==void 0&&u[t].overloadTable[r]!==void 0)&&T(`Cannot register public name '${t}' twice`),pe(u,t,t),u.hasOwnProperty(r)&&T(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),u[t].overloadTable[r]=e):(u[t]=e,r!==void 0&&(u[t].numArguments=r))}function Xr(t,e,r,n,a,o,i,s){this.name=t,this.constructor=e,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=a,this.getActualType=o,this.upcast=i,this.downcast=s,this.pureVirtualFunctions=[]}function Vt(t,e,r){for(;e!==r;)e.upcast||T(`Expected null or instance of ${r.name}, got an instance of ${e.name}`),t=e.upcast(t),e=e.baseClass;return t}function qr(t,e){if(e===null)return this.isReference&&T(`null is not a valid ${this.name}`),0;e.$$||T(`Cannot pass "${Yt(e)}" as a ${this.name}`),e.$$.ptr||T(`Cannot pass deleted object as a pointer of type ${this.name}`);var r=e.$$.ptrType.registeredClass,n=Vt(e.$$.ptr,r,this.registeredClass);return n}function Jr(t,e){var r;if(e===null)return this.isReference&&T(`null is not a valid ${this.name}`),this.isSmartPointer?(r=this.rawConstructor(),t!==null&&t.push(this.rawDestructor,r),r):0;e.$$||T(`Cannot pass "${Yt(e)}" as a ${this.name}`),e.$$.ptr||T(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&e.$$.ptrType.isConst&&T(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);var n=e.$$.ptrType.registeredClass;if(r=Vt(e.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(e.$$.smartPtr===void 0&&T("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?r=e.$$.smartPtr:T(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)r=e.$$.smartPtr;else{var a=e.clone();r=this.rawShare(r,et.toHandle(function(){a.delete()})),t!==null&&t.push(this.rawDestructor,r)}break;default:T("Unsupporting sharing policy")}return r}function Zr(t,e){if(e===null)return this.isReference&&T(`null is not a valid ${this.name}`),0;e.$$||T(`Cannot pass "${Yt(e)}" as a ${this.name}`),e.$$.ptr||T(`Cannot pass deleted object as a pointer of type ${this.name}`),e.$$.ptrType.isConst&&T(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);var r=e.$$.ptrType.registeredClass,n=Vt(e.$$.ptr,r,this.registeredClass);return n}function Qr(t){return this.rawGetPointee&&(t=this.rawGetPointee(t)),t}function Kr(t){this.rawDestructor&&this.rawDestructor(t)}function tn(t){t!==null&&t.delete()}function en(){Q.prototype.getPointee=Qr,Q.prototype.destructor=Kr,Q.prototype.argPackAdvance=8,Q.prototype.readValueFromPointer=ht,Q.prototype.deleteObject=tn,Q.prototype.fromWireType=Ur}function Q(t,e,r,n,a,o,i,s,f,l,h){this.name=t,this.registeredClass=e,this.isReference=r,this.isConst=n,this.isSmartPointer=a,this.pointeeType=o,this.sharingPolicy=i,this.rawGetPointee=s,this.rawConstructor=f,this.rawShare=l,this.rawDestructor=h,!a&&e.baseClass===void 0?n?(this.toWireType=qr,this.destructorFunction=null):(this.toWireType=Zr,this.destructorFunction=null):this.toWireType=Jr}function ve(t,e,r){u.hasOwnProperty(t)||xt("Replacing nonexistant public symbol"),u[t].overloadTable!==void 0&&r!==void 0?u[t].overloadTable[r]=e:(u[t]=e,u[t].argCount=r)}var rn=(t,e,r)=>{var n=u["dynCall_"+t];return r&&r.length?n.apply(null,[e].concat(r)):n.call(null,e)},Ft=[],P=t=>{var e=Ft[t];return e||(t>=Ft.length&&(Ft.length=t+1),Ft[t]=e=Qt.get(t)),e},nn=(t,e,r)=>{if(t.includes("j"))return rn(t,e,r);var n=P(e).apply(null,r);return n},an=(t,e)=>{var r=[];return function(){return r.length=0,Object.assign(r,arguments),nn(t,e,r)}};function N(t,e){t=H(t);function r(){return t.includes("j")?an(t,e):P(e)}var n=r();return typeof n!="function"&&T(`unknown function pointer with signature ${t}: ${e}`),n}function on(t,e){var r=he(e,function(n){this.name=e,this.message=n;var a=new Error(n).stack;a!==void 0&&(this.stack=this.toString()+`
2
+ `+a.replace(/^Error(:[^\n]*)?\n/,""))});return r.prototype=Object.create(t.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},r}var me=void 0;function ge(t){var e=Se(t),r=H(e);return K(e),r}function Ot(t,e){var r=[],n={};function a(o){if(!n[o]&&!ot[o]){if(Dt[o]){Dt[o].forEach(a);return}r.push(o),n[o]=!0}}throw e.forEach(a),new me(`${t}: `+r.map(ge).join([", "]))}function sn(t,e,r,n,a,o,i,s,f,l,h,v,m){h=H(h),o=N(a,o),s&&(s=N(i,s)),l&&(l=N(f,l)),m=N(v,m);var _=de(h);ye(_,function(){Ot(`Cannot construct ${h} due to unbound types`,[n])}),it([t,e,r],n?[n]:[],function(D){D=D[0];var I,x;n?(I=D.registeredClass,x=I.instancePrototype):x=tt.prototype;var W=he(_,function(){if(Object.getPrototypeOf(this)!==d)throw new ft("Use 'new' to construct "+h);if(y.constructor_body===void 0)throw new ft(h+" has no accessible constructor");var Rt=y.constructor_body[arguments.length];if(Rt===void 0)throw new ft(`Tried to invoke ctor of ${h} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(y.constructor_body).toString()}) parameters instead!`);return Rt.apply(this,arguments)}),d=Object.create(x,{constructor:{value:W}});W.prototype=d;var y=new Xr(h,W,d,m,I,o,s,l);y.baseClass&&(y.baseClass.__derivedClasses===void 0&&(y.baseClass.__derivedClasses=[]),y.baseClass.__derivedClasses.push(y));var S=new Q(h,y,!0,!1,!1),O=new Q(h+"*",y,!1,!1,!1),st=new Q(h+" const*",y,!1,!0,!1);return le[t]={pointerType:O,constPointerType:st},ve(_,W),[S,O,st]})}function zt(t,e){for(var r=[],n=0;n<t;n++)r.push(F[e+n*4>>2]);return r}function Lt(t,e,r,n,a,o){var i=e.length;i<2&&T("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=e[1]!==null&&r!==null,f=!1,l=1;l<e.length;++l)if(e[l]!==null&&e[l].destructorFunction===void 0){f=!0;break}var h=e[0].name!=="void",v=i-2,m=new Array(v),_=[],D=[];return function(){arguments.length!==v&&T(`function ${t} called with ${arguments.length} arguments, expected ${v} args!`),D.length=0;var I;_.length=s?2:1,_[0]=a,s&&(I=e[1].toWireType(D,this),_[1]=I);for(var x=0;x<v;++x)m[x]=e[x+2].toWireType(D,arguments[x]),_.push(m[x]);var W=n.apply(null,_);function d(y){if(f)oe(D);else for(var S=s?1:2;S<e.length;S++){var O=S===1?I:m[S-2];e[S].destructorFunction!==null&&e[S].destructorFunction(O)}if(h)return e[0].fromWireType(y)}return d(W)}}function un(t,e,r,n,a,o){var i=zt(e,r);a=N(n,a),it([],[t],function(s){s=s[0];var f=`constructor ${s.name}`;if(s.registeredClass.constructor_body===void 0&&(s.registeredClass.constructor_body=[]),s.registeredClass.constructor_body[e-1]!==void 0)throw new ft(`Cannot register multiple constructors with identical number of parameters (${e-1}) for class '${s.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return s.registeredClass.constructor_body[e-1]=()=>{Ot(`Cannot construct ${s.name} due to unbound types`,i)},it([],i,function(l){return l.splice(1,0,null),s.registeredClass.constructor_body[e-1]=Lt(f,l,null,a,o),[]}),[]})}function cn(t,e,r,n,a,o,i,s,f){var l=zt(r,n);e=H(e),o=N(a,o),it([],[t],function(h){h=h[0];var v=`${h.name}.${e}`;e.startsWith("@@")&&(e=Symbol[e.substring(2)]),s&&h.registeredClass.pureVirtualFunctions.push(e);function m(){Ot(`Cannot call ${v} due to unbound types`,l)}var _=h.registeredClass.instancePrototype,D=_[e];return D===void 0||D.overloadTable===void 0&&D.className!==h.name&&D.argCount===r-2?(m.argCount=r-2,m.className=h.name,_[e]=m):(pe(_,e,v),_[e].overloadTable[r-2]=m),it([],l,function(I){var x=Lt(v,I,h,o,i);return _[e].overloadTable===void 0?(x.argCount=r-2,_[e]=x):_[e].overloadTable[r-2]=x,[]}),[]})}function fn(){Object.assign(we.prototype,{get(t){return this.allocated[t]},has(t){return this.allocated[t]!==void 0},allocate(t){var e=this.freelist.pop()||this.allocated.length;return this.allocated[e]=t,e},free(t){this.allocated[t]=void 0,this.freelist.push(t)}})}function we(){this.allocated=[void 0],this.freelist=[]}var L=new we;function $e(t){t>=L.reserved&&--L.get(t).refcount===0&&L.free(t)}function ln(){for(var t=0,e=L.reserved;e<L.allocated.length;++e)L.allocated[e]!==void 0&&++t;return t}function dn(){L.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),L.reserved=L.allocated.length,u.count_emval_handles=ln}var et={toValue:t=>(t||T("Cannot use deleted val. handle = "+t),L.get(t).value),toHandle:t=>{switch(t){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return L.allocate({refcount:1,value:t})}}};function hn(t,e){e=H(e),Z(t,{name:e,fromWireType:function(r){var n=et.toValue(r);return $e(r),n},toWireType:function(r,n){return et.toHandle(n)},argPackAdvance:8,readValueFromPointer:ht,destructorFunction:null})}function Yt(t){if(t===null)return"null";var e=typeof t;return e==="object"||e==="array"||e==="function"?t.toString():""+t}function pn(t,e){switch(e){case 2:return function(r){return this.fromWireType(qt[r>>2])};case 3:return function(r){return this.fromWireType(Jt[r>>3])};default:throw new TypeError("Unknown float type: "+t)}}function yn(t,e,r){var n=Ht(r);e=H(e),Z(t,{name:e,fromWireType:function(a){return a},toWireType:function(a,o){return o},argPackAdvance:8,readValueFromPointer:pn(e,n),destructorFunction:null})}function vn(t,e,r,n,a,o,i){var s=zt(e,r);t=H(t),a=N(n,a),ye(t,function(){Ot(`Cannot call ${t} due to unbound types`,s)},e-1),it([],s,function(f){var l=[f[0],null].concat(f.slice(1));return ve(t,Lt(t,l,null,a,o),e-1),[]})}function mn(t,e,r){switch(e){case 0:return r?function(n){return z[n]}:function(n){return B[n]};case 1:return r?function(n){return ut[n>>1]}:function(n){return Ct[n>>1]};case 2:return r?function(n){return R[n>>2]}:function(n){return F[n>>2]};default:throw new TypeError("Unknown integer type: "+t)}}function gn(t,e,r,n,a){e=H(e);var o=Ht(r),i=v=>v;if(n===0){var s=32-8*r;i=v=>v<<s>>>s}var f=e.includes("unsigned"),l=(v,m)=>{},h;f?h=function(v,m){return l(m,this.name),m>>>0}:h=function(v,m){return l(m,this.name),m},Z(t,{name:e,fromWireType:i,toWireType:h,argPackAdvance:8,readValueFromPointer:mn(e,o,n!==0),destructorFunction:null})}function wn(t,e,r){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],a=n[e];function o(i){i=i>>2;var s=F,f=s[i],l=s[i+1];return new a(s.buffer,l,f)}r=H(r),Z(t,{name:r,fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})}var be=(t,e,r,n)=>{if(!(n>0))return 0;for(var a=r,o=r+n-1,i=0;i<t.length;++i){var s=t.charCodeAt(i);if(s>=55296&&s<=57343){var f=t.charCodeAt(++i);s=65536+((s&1023)<<10)|f&1023}if(s<=127){if(r>=o)break;e[r++]=s}else if(s<=2047){if(r+1>=o)break;e[r++]=192|s>>6,e[r++]=128|s&63}else if(s<=65535){if(r+2>=o)break;e[r++]=224|s>>12,e[r++]=128|s>>6&63,e[r++]=128|s&63}else{if(r+3>=o)break;e[r++]=240|s>>18,e[r++]=128|s>>12&63,e[r++]=128|s>>6&63,e[r++]=128|s&63}}return e[r]=0,r-a},$n=(t,e,r)=>be(t,B,e,r),Ce=t=>{for(var e=0,r=0;r<t.length;++r){var n=t.charCodeAt(r);n<=127?e++:n<=2047?e+=2:n>=55296&&n<=57343?(e+=4,++r):e+=3}return e},_e=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,bn=(t,e,r)=>{for(var n=e+r,a=e;t[a]&&!(a>=n);)++a;if(a-e>16&&t.buffer&&_e)return _e.decode(t.subarray(e,a));for(var o="";e<a;){var i=t[e++];if(!(i&128)){o+=String.fromCharCode(i);continue}var s=t[e++]&63;if((i&224)==192){o+=String.fromCharCode((i&31)<<6|s);continue}var f=t[e++]&63;if((i&240)==224?i=(i&15)<<12|s<<6|f:i=(i&7)<<18|s<<12|f<<6|t[e++]&63,i<65536)o+=String.fromCharCode(i);else{var l=i-65536;o+=String.fromCharCode(55296|l>>10,56320|l&1023)}}return o},Nt=(t,e)=>t?bn(B,t,e):"";function Cn(t,e){e=H(e);var r=e==="std::string";Z(t,{name:e,fromWireType:function(n){var a=F[n>>2],o=n+4,i;if(r)for(var s=o,f=0;f<=a;++f){var l=o+f;if(f==a||B[l]==0){var h=l-s,v=Nt(s,h);i===void 0?i=v:(i+=String.fromCharCode(0),i+=v),s=l+1}}else{for(var m=new Array(a),f=0;f<a;++f)m[f]=String.fromCharCode(B[o+f]);i=m.join("")}return K(n),i},toWireType:function(n,a){a instanceof ArrayBuffer&&(a=new Uint8Array(a));var o,i=typeof a=="string";i||a instanceof Uint8Array||a instanceof Uint8ClampedArray||a instanceof Int8Array||T("Cannot pass non-string to std::string"),r&&i?o=Ce(a):o=a.length;var s=Xt(4+o+1),f=s+4;if(F[s>>2]=o,r&&i)$n(a,f,o+1);else if(i)for(var l=0;l<o;++l){var h=a.charCodeAt(l);h>255&&(K(f),T("String has UTF-16 code units that do not fit in 8 bits")),B[f+l]=h}else for(var l=0;l<o;++l)B[f+l]=a[l];return n!==null&&n.push(K,s),s},argPackAdvance:8,readValueFromPointer:ht,destructorFunction:function(n){K(n)}})}var Te=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,_n=(t,e)=>{for(var r=t,n=r>>1,a=n+e/2;!(n>=a)&&Ct[n];)++n;if(r=n<<1,r-t>32&&Te)return Te.decode(B.subarray(t,r));for(var o="",i=0;!(i>=e/2);++i){var s=ut[t+i*2>>1];if(s==0)break;o+=String.fromCharCode(s)}return o},Tn=(t,e,r)=>{if(r===void 0&&(r=2147483647),r<2)return 0;r-=2;for(var n=e,a=r<t.length*2?r/2:t.length,o=0;o<a;++o){var i=t.charCodeAt(o);ut[e>>1]=i,e+=2}return ut[e>>1]=0,e-n},Pn=t=>t.length*2,En=(t,e)=>{for(var r=0,n="";!(r>=e/4);){var a=R[t+r*4>>2];if(a==0)break;if(++r,a>=65536){var o=a-65536;n+=String.fromCharCode(55296|o>>10,56320|o&1023)}else n+=String.fromCharCode(a)}return n},An=(t,e,r)=>{if(r===void 0&&(r=2147483647),r<4)return 0;for(var n=e,a=n+r-4,o=0;o<t.length;++o){var i=t.charCodeAt(o);if(i>=55296&&i<=57343){var s=t.charCodeAt(++o);i=65536+((i&1023)<<10)|s&1023}if(R[e>>2]=i,e+=4,e+4>a)break}return R[e>>2]=0,e-n},Dn=t=>{for(var e=0,r=0;r<t.length;++r){var n=t.charCodeAt(r);n>=55296&&n<=57343&&++r,e+=4}return e},xn=function(t,e,r){r=H(r);var n,a,o,i,s;e===2?(n=_n,a=Tn,i=Pn,o=()=>Ct,s=1):e===4&&(n=En,a=An,i=Dn,o=()=>F,s=2),Z(t,{name:r,fromWireType:function(f){for(var l=F[f>>2],h=o(),v,m=f+4,_=0;_<=l;++_){var D=f+4+_*e;if(_==l||h[D>>s]==0){var I=D-m,x=n(m,I);v===void 0?v=x:(v+=String.fromCharCode(0),v+=x),m=D+e}}return K(f),v},toWireType:function(f,l){typeof l!="string"&&T(`Cannot pass non-string to C++ string type ${r}`);var h=i(l),v=Xt(4+h+e);return F[v>>2]=h>>s,a(l,v+4,h+e),f!==null&&f.push(K,v),v},argPackAdvance:8,readValueFromPointer:ht,destructorFunction:function(f){K(f)}})};function Sn(t,e,r,n,a,o){At[t]={name:H(e),rawConstructor:N(r,n),rawDestructor:N(a,o),fields:[]}}function Fn(t,e,r,n,a,o,i,s,f,l){At[t].fields.push({fieldName:H(e),getterReturnType:r,getter:N(n,a),getterContext:o,setterArgumentType:i,setter:N(s,f),setterContext:l})}function On(t,e){e=H(e),Z(t,{isVoid:!0,name:e,argPackAdvance:0,fromWireType:function(){},toWireType:function(r,n){}})}var Mn={};function jn(t){var e=Mn[t];return e===void 0?H(t):e}function Pe(){if(typeof globalThis=="object")return globalThis;function t(e){e.$$$embind_global$$$=e;var r=typeof $$$embind_global$$$=="object"&&e.$$$embind_global$$$==e;return r||delete e.$$$embind_global$$$,r}if(typeof $$$embind_global$$$=="object"||(typeof global=="object"&&t(global)?$$$embind_global$$$=global:typeof self=="object"&&t(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function Rn(t){return t===0?et.toHandle(Pe()):(t=jn(t),et.toHandle(Pe()[t]))}function In(t){t>4&&(L.get(t).refcount+=1)}function Ee(t,e){var r=ot[t];return r===void 0&&T(e+" has unknown type "+ge(t)),r}function Wn(t){var e=new Array(t+1);return function(r,n,a){e[0]=r;for(var o=0;o<t;++o){var i=Ee(F[n+o*4>>2],"parameter "+o);e[o+1]=i.readValueFromPointer(a),a+=i.argPackAdvance}var s=new(r.bind.apply(r,e));return et.toHandle(s)}}var Ae={};function Hn(t,e,r,n){t=et.toValue(t);var a=Ae[e];return a||(a=Wn(e),Ae[e]=a),a(t,r,n)}function kn(t,e){t=Ee(t,"_emval_take_value");var r=t.readValueFromPointer(e);return et.toHandle(r)}var Un=()=>{_t("")},Bn=(t,e,r)=>B.copyWithin(t,e,e+r),Vn=()=>2147483648,zn=t=>{var e=q.buffer,r=t-e.byteLength+65535>>>16;try{return q.grow(r),Zt(),1}catch{}},Ln=t=>{var e=B.length;t>>>=0;var r=Vn();if(t>r)return!1;for(var n=(f,l)=>f+(l-f%l)%l,a=1;a<=4;a*=2){var o=e*(1+.2/a);o=Math.min(o,t+100663296);var i=Math.min(r,n(Math.max(t,o),65536)),s=zn(i);if(s)return!0}return!1},Gt={},Yn=()=>M||"./this.program",gt=()=>{if(!gt.strings){var t=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:t,_:Yn()};for(var r in Gt)Gt[r]===void 0?delete e[r]:e[r]=Gt[r];var n=[];for(var r in e)n.push(`${r}=${e[r]}`);gt.strings=n}return gt.strings},Nn=(t,e)=>{for(var r=0;r<t.length;++r)z[e++>>0]=t.charCodeAt(r);z[e>>0]=0},Gn=(t,e)=>{var r=0;return gt().forEach(function(n,a){var o=e+r;F[t+a*4>>2]=o,Nn(n,o),r+=n.length+1}),0},Xn=(t,e)=>{var r=gt();F[t>>2]=r.length;var n=0;return r.forEach(function(a){n+=a.length+1}),F[e>>2]=n,0};function qn(t){return t}var Mt=t=>t%4===0&&(t%100!==0||t%400===0),Jn=(t,e)=>{for(var r=0,n=0;n<=e;r+=t[n++]);return r},De=[31,29,31,30,31,30,31,31,30,31,30,31],xe=[31,28,31,30,31,30,31,31,30,31,30,31],Zn=(t,e)=>{for(var r=new Date(t.getTime());e>0;){var n=Mt(r.getFullYear()),a=r.getMonth(),o=(n?De:xe)[a];if(e>o-r.getDate())e-=o-r.getDate()+1,r.setDate(1),a<11?r.setMonth(a+1):(r.setMonth(0),r.setFullYear(r.getFullYear()+1));else return r.setDate(r.getDate()+e),r}return r};function Qn(t,e,r){var n=r>0?r:Ce(t)+1,a=new Array(n),o=be(t,a,0,a.length);return e&&(a.length=o),a}var Kn=(t,e)=>{z.set(t,e)},ta=(t,e,r,n)=>{var a=R[n+40>>2],o={tm_sec:R[n>>2],tm_min:R[n+4>>2],tm_hour:R[n+8>>2],tm_mday:R[n+12>>2],tm_mon:R[n+16>>2],tm_year:R[n+20>>2],tm_wday:R[n+24>>2],tm_yday:R[n+28>>2],tm_isdst:R[n+32>>2],tm_gmtoff:R[n+36>>2],tm_zone:a?Nt(a):""},i=Nt(r),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var f in s)i=i.replace(new RegExp(f,"g"),s[f]);var l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],h=["January","February","March","April","May","June","July","August","September","October","November","December"];function v(d,y,S){for(var O=typeof d=="number"?d.toString():d||"";O.length<y;)O=S[0]+O;return O}function m(d,y){return v(d,y,"0")}function _(d,y){function S(st){return st<0?-1:st>0?1:0}var O;return(O=S(d.getFullYear()-y.getFullYear()))===0&&(O=S(d.getMonth()-y.getMonth()))===0&&(O=S(d.getDate()-y.getDate())),O}function D(d){switch(d.getDay()){case 0:return new Date(d.getFullYear()-1,11,29);case 1:return d;case 2:return new Date(d.getFullYear(),0,3);case 3:return new Date(d.getFullYear(),0,2);case 4:return new Date(d.getFullYear(),0,1);case 5:return new Date(d.getFullYear()-1,11,31);case 6:return new Date(d.getFullYear()-1,11,30)}}function I(d){var y=Zn(new Date(d.tm_year+1900,0,1),d.tm_yday),S=new Date(y.getFullYear(),0,4),O=new Date(y.getFullYear()+1,0,4),st=D(S),Rt=D(O);return _(st,y)<=0?_(Rt,y)<=0?y.getFullYear()+1:y.getFullYear():y.getFullYear()-1}var x={"%a":d=>l[d.tm_wday].substring(0,3),"%A":d=>l[d.tm_wday],"%b":d=>h[d.tm_mon].substring(0,3),"%B":d=>h[d.tm_mon],"%C":d=>{var y=d.tm_year+1900;return m(y/100|0,2)},"%d":d=>m(d.tm_mday,2),"%e":d=>v(d.tm_mday,2," "),"%g":d=>I(d).toString().substring(2),"%G":d=>I(d),"%H":d=>m(d.tm_hour,2),"%I":d=>{var y=d.tm_hour;return y==0?y=12:y>12&&(y-=12),m(y,2)},"%j":d=>m(d.tm_mday+Jn(Mt(d.tm_year+1900)?De:xe,d.tm_mon-1),3),"%m":d=>m(d.tm_mon+1,2),"%M":d=>m(d.tm_min,2),"%n":()=>`
3
+ `,"%p":d=>d.tm_hour>=0&&d.tm_hour<12?"AM":"PM","%S":d=>m(d.tm_sec,2),"%t":()=>" ","%u":d=>d.tm_wday||7,"%U":d=>{var y=d.tm_yday+7-d.tm_wday;return m(Math.floor(y/7),2)},"%V":d=>{var y=Math.floor((d.tm_yday+7-(d.tm_wday+6)%7)/7);if((d.tm_wday+371-d.tm_yday-2)%7<=2&&y++,y){if(y==53){var S=(d.tm_wday+371-d.tm_yday)%7;S!=4&&(S!=3||!Mt(d.tm_year))&&(y=1)}}else{y=52;var O=(d.tm_wday+7-d.tm_yday-1)%7;(O==4||O==5&&Mt(d.tm_year%400-1))&&y++}return m(y,2)},"%w":d=>d.tm_wday,"%W":d=>{var y=d.tm_yday+7-(d.tm_wday+6)%7;return m(Math.floor(y/7),2)},"%y":d=>(d.tm_year+1900).toString().substring(2),"%Y":d=>d.tm_year+1900,"%z":d=>{var y=d.tm_gmtoff,S=y>=0;return y=Math.abs(y)/60,y=y/60*100+y%60,(S?"+":"-")+("0000"+y).slice(-4)},"%Z":d=>d.tm_zone,"%%":()=>"%"};i=i.replace(/%%/g,"\0\0");for(var f in x)i.includes(f)&&(i=i.replace(new RegExp(f,"g"),x[f](o)));i=i.replace(/\0\0/g,"%");var W=Qn(i,!1);return W.length>e?0:(Kn(W,t),W.length-1)},ea=(t,e,r,n,a)=>ta(t,e,r,n);ie=u.InternalError=class extends Error{constructor(t){super(t),this.name="InternalError"}},Dr(),ft=u.BindingError=class extends Error{constructor(t){super(t),this.name="BindingError"}},Yr(),Wr(),en(),me=u.UnboundTypeError=on(Error,"UnboundTypeError"),fn(),dn();var ra={q:vr,u:mr,a:wr,h:$r,l:br,I:Cr,P:_r,n:Tr,ba:Pr,d:gr,oa:Er,Y:Ar,fa:Sr,na:sn,ma:un,D:cn,ea:hn,W:yn,J:vn,w:gn,s:wn,V:Cn,L:xn,Q:Sn,pa:Fn,ga:On,U:$e,la:Rn,R:In,ia:Hn,ka:kn,K:Un,da:Bn,ca:Ln,$:Gn,aa:Xn,H:ba,T:Sa,B:_a,p:ga,b:na,C:$a,ha:Pa,c:ua,j:fa,i:ia,x:Ca,O:wa,v:va,G:Aa,N:Da,A:Ta,F:Fa,Z:Ma,X:ja,k:ca,f:sa,e:oa,g:aa,M:xa,m:ya,o:la,S:da,t:pa,ja:ma,y:Ea,r:ha,E:Oa,z:qn,_:ea};yr();var K=u._free=t=>(K=u._free=A.sa)(t),Xt=u._malloc=t=>(Xt=u._malloc=A.ta)(t),Se=t=>(Se=A.va)(t);u.__embind_initialize_bindings=()=>(u.__embind_initialize_bindings=A.wa)();var w=(t,e)=>(w=A.xa)(t,e),wt=t=>(wt=A.ya)(t),b=()=>(b=A.za)(),C=t=>(C=A.Aa)(t),Fe=t=>(Fe=A.Ba)(t),Oe=t=>(Oe=A.Ca)(t),Me=(t,e,r)=>(Me=A.Da)(t,e,r),je=t=>(je=A.Ea)(t);u.dynCall_viijii=(t,e,r,n,a,o,i)=>(u.dynCall_viijii=A.Fa)(t,e,r,n,a,o,i);var Re=u.dynCall_jiii=(t,e,r,n)=>(Re=u.dynCall_jiii=A.Ga)(t,e,r,n),Ie=u.dynCall_jiiii=(t,e,r,n,a)=>(Ie=u.dynCall_jiiii=A.Ha)(t,e,r,n,a);u.dynCall_iiiiij=(t,e,r,n,a,o,i)=>(u.dynCall_iiiiij=A.Ia)(t,e,r,n,a,o,i),u.dynCall_iiiiijj=(t,e,r,n,a,o,i,s,f)=>(u.dynCall_iiiiijj=A.Ja)(t,e,r,n,a,o,i,s,f),u.dynCall_iiiiiijj=(t,e,r,n,a,o,i,s,f,l)=>(u.dynCall_iiiiiijj=A.Ka)(t,e,r,n,a,o,i,s,f,l);function na(t,e){var r=b();try{return P(t)(e)}catch(n){if(C(r),n!==n+0)throw n;w(1,0)}}function aa(t,e,r,n){var a=b();try{P(t)(e,r,n)}catch(o){if(C(a),o!==o+0)throw o;w(1,0)}}function oa(t,e,r){var n=b();try{P(t)(e,r)}catch(a){if(C(n),a!==a+0)throw a;w(1,0)}}function ia(t,e,r,n,a){var o=b();try{return P(t)(e,r,n,a)}catch(i){if(C(o),i!==i+0)throw i;w(1,0)}}function sa(t,e){var r=b();try{P(t)(e)}catch(n){if(C(r),n!==n+0)throw n;w(1,0)}}function ua(t,e,r){var n=b();try{return P(t)(e,r)}catch(a){if(C(n),a!==a+0)throw a;w(1,0)}}function ca(t){var e=b();try{P(t)()}catch(r){if(C(e),r!==r+0)throw r;w(1,0)}}function fa(t,e,r,n){var a=b();try{return P(t)(e,r,n)}catch(o){if(C(a),o!==o+0)throw o;w(1,0)}}function la(t,e,r,n,a,o){var i=b();try{P(t)(e,r,n,a,o)}catch(s){if(C(i),s!==s+0)throw s;w(1,0)}}function da(t,e,r,n,a,o,i){var s=b();try{P(t)(e,r,n,a,o,i)}catch(f){if(C(s),f!==f+0)throw f;w(1,0)}}function ha(t,e,r,n,a,o,i,s,f,l,h){var v=b();try{P(t)(e,r,n,a,o,i,s,f,l,h)}catch(m){if(C(v),m!==m+0)throw m;w(1,0)}}function pa(t,e,r,n,a,o,i,s){var f=b();try{P(t)(e,r,n,a,o,i,s)}catch(l){if(C(f),l!==l+0)throw l;w(1,0)}}function ya(t,e,r,n,a){var o=b();try{P(t)(e,r,n,a)}catch(i){if(C(o),i!==i+0)throw i;w(1,0)}}function va(t,e,r,n,a,o,i){var s=b();try{return P(t)(e,r,n,a,o,i)}catch(f){if(C(s),f!==f+0)throw f;w(1,0)}}function ma(t,e,r,n,a,o,i,s,f){var l=b();try{P(t)(e,r,n,a,o,i,s,f)}catch(h){if(C(l),h!==h+0)throw h;w(1,0)}}function ga(t){var e=b();try{return P(t)()}catch(r){if(C(e),r!==r+0)throw r;w(1,0)}}function wa(t,e,r,n,a,o,i){var s=b();try{return P(t)(e,r,n,a,o,i)}catch(f){if(C(s),f!==f+0)throw f;w(1,0)}}function $a(t,e,r,n){var a=b();try{return P(t)(e,r,n)}catch(o){if(C(a),o!==o+0)throw o;w(1,0)}}function ba(t,e,r,n){var a=b();try{return P(t)(e,r,n)}catch(o){if(C(a),o!==o+0)throw o;w(1,0)}}function Ca(t,e,r,n,a,o){var i=b();try{return P(t)(e,r,n,a,o)}catch(s){if(C(i),s!==s+0)throw s;w(1,0)}}function _a(t,e,r,n,a,o){var i=b();try{return P(t)(e,r,n,a,o)}catch(s){if(C(i),s!==s+0)throw s;w(1,0)}}function Ta(t,e,r,n,a,o,i,s,f,l){var h=b();try{return P(t)(e,r,n,a,o,i,s,f,l)}catch(v){if(C(h),v!==v+0)throw v;w(1,0)}}function Pa(t,e,r){var n=b();try{return P(t)(e,r)}catch(a){if(C(n),a!==a+0)throw a;w(1,0)}}function Ea(t,e,r,n,a,o,i,s,f,l){var h=b();try{P(t)(e,r,n,a,o,i,s,f,l)}catch(v){if(C(h),v!==v+0)throw v;w(1,0)}}function Aa(t,e,r,n,a,o,i,s){var f=b();try{return P(t)(e,r,n,a,o,i,s)}catch(l){if(C(f),l!==l+0)throw l;w(1,0)}}function Da(t,e,r,n,a,o,i,s,f){var l=b();try{return P(t)(e,r,n,a,o,i,s,f)}catch(h){if(C(l),h!==h+0)throw h;w(1,0)}}function xa(t,e,r,n,a,o,i){var s=b();try{P(t)(e,r,n,a,o,i)}catch(f){if(C(s),f!==f+0)throw f;w(1,0)}}function Sa(t,e,r,n){var a=b();try{return P(t)(e,r,n)}catch(o){if(C(a),o!==o+0)throw o;w(1,0)}}function Fa(t,e,r,n,a,o,i,s,f,l,h,v){var m=b();try{return P(t)(e,r,n,a,o,i,s,f,l,h,v)}catch(_){if(C(m),_!==_+0)throw _;w(1,0)}}function Oa(t,e,r,n,a,o,i,s,f,l,h,v,m,_,D,I){var x=b();try{P(t)(e,r,n,a,o,i,s,f,l,h,v,m,_,D,I)}catch(W){if(C(x),W!==W+0)throw W;w(1,0)}}function Ma(t,e,r,n){var a=b();try{return Re(t,e,r,n)}catch(o){if(C(a),o!==o+0)throw o;w(1,0)}}function ja(t,e,r,n,a){var o=b();try{return Ie(t,e,r,n,a)}catch(i){if(C(o),i!==i+0)throw i;w(1,0)}}var jt;dt=function t(){jt||We(),jt||(dt=t)};function We(){if(nt>0||(ar(),nt>0))return;function t(){jt||(jt=!0,u.calledRun=!0,!bt&&(or(),$(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),ir()))}u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),t()},1)):t()}if(u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);u.preInit.length>0;)u.preInit.pop()();return We(),p.ready}})();function Ka(c){return er(rr,c)}async function to(c,{tryHarder:p=rt.tryHarder,formats:u=rt.formats,maxSymbols:$=rt.maxSymbols}=rt){return Ja(c,{tryHarder:p,formats:u,maxSymbols:$},rr)}const nr=new Map([["aztec","Aztec"],["code_128","Code128"],["code_39","Code39"],["code_93","Code93"],["codabar","Codabar"],["data_matrix","DataMatrix"],["ean_13","EAN-13"],["ean_8","EAN-8"],["itf","ITF"],["pdf417","PDF417"],["qr_code","QRCode"],["upc_a","UPC-A"],["upc_e","UPC-E"]]);function eo(c){for(const[p,u]of nr)if(c===u)return p;return"unknown"}var $t;class ro extends EventTarget{constructor(u={}){var $;super();Ue(this,$t,void 0);try{const g=($=u==null?void 0:u.formats)==null?void 0:$.filter(E=>E!=="unknown");if((g==null?void 0:g.length)===0)throw new TypeError("Hint option provided, but is empty.");g==null||g.forEach(E=>{if(!Ve.includes(E))throw new TypeError(`Failed to read the 'formats' property from 'BarcodeDetectorOptions': The provided value '${E}' is not a valid enum value of type BarcodeFormat.`)}),Be(this,$t,g??[]),Ka().then(E=>{this.dispatchEvent(new CustomEvent("load",{detail:E}))}).catch(E=>{this.dispatchEvent(new CustomEvent("error",{detail:E}))})}catch(g){throw ze(g,"Failed to construct 'BarcodeDetector'")}}static async getSupportedFormats(){return Ve.filter(u=>u!=="unknown")}async detect(u){try{const $=await Ba(u);if($===null)return[];let g;try{g=await to($,{tryHarder:!0,formats:ke(this,$t).map(E=>nr.get(E))})}catch{throw new DOMException("Barcode detection service unavailable. Use 'setZXingModuleOverrides' in offline or strict CSP environments.","NotSupportedError")}return g.map(E=>{const{topLeft:{x:M,y:G},topRight:{x:k,y:j},bottomLeft:{x:Y,y:X},bottomRight:{x:V,y:U}}=E.position,q=Math.min(M,k,Y,V),A=Math.min(G,j,X,U),bt=Math.max(M,k,Y,V),z=Math.max(G,j,X,U);return{boundingBox:new DOMRectReadOnly(q,A,bt-q,z-A),rawValue:new TextDecoder().decode(E.bytes),format:eo(E.format),cornerPoints:[{x:M,y:G},{x:k,y:j},{x:V,y:U},{x:Y,y:X}]}})}catch($){throw ze($,"Failed to execute 'detect' on 'BarcodeDetector'")}}}$t=new WeakMap;exports.BarcodeDetector=ro;exports.setZXingModuleOverrides=qa;
@@ -0,0 +1,24 @@
1
+ /// <reference types="dom-webcodecs" />
2
+ import { Point2D } from "./BarcodeDetector.js";
3
+ export { setZXingModuleOverrides } from "./BarcodeDetector.js";
4
+ import { BARCODE_DETECTOR_FORMATS } from "./utils.js";
5
+ declare global {
6
+ var BarcodeDetector: {
7
+ readonly prototype: BarcodeDetector;
8
+ new (barcodeDectorOptions?: BarcodeDetectorOptions): BarcodeDetector;
9
+ getSupportedFormats(): Promise<readonly BarcodeFormat[]>;
10
+ };
11
+ interface BarcodeDetector {
12
+ detect(image: ImageBitmapSourceWebCodecs): Promise<DetectedBarcode[]>;
13
+ }
14
+ type BarcodeFormat = (typeof BARCODE_DETECTOR_FORMATS)[number];
15
+ interface BarcodeDetectorOptions {
16
+ formats?: BarcodeFormat[];
17
+ }
18
+ interface DetectedBarcode {
19
+ boundingBox: DOMRectReadOnly;
20
+ rawValue: string;
21
+ format: BarcodeFormat;
22
+ cornerPoints: [Point2D, Point2D, Point2D, Point2D];
23
+ }
24
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./pure.js");globalThis.BarcodeDetector??(globalThis.BarcodeDetector=e.BarcodeDetector);exports.setZXingModuleOverrides=e.setZXingModuleOverrides;
@@ -0,0 +1,9 @@
1
+ /// <reference types="dom-webcodecs" />
2
+ export declare const BARCODE_DETECTOR_FORMATS: readonly ["aztec", "code_128", "code_39", "code_93", "codabar", "data_matrix", "ean_13", "ean_8", "itf", "pdf417", "qr_code", "upc_a", "upc_e", "unknown"];
3
+ export declare function getImageDataFromImageBitmapSource(image: ImageBitmapSourceWebCodecs): Promise<ImageData | null>;
4
+ declare global {
5
+ interface SVGImageElement {
6
+ decode?(): Promise<void>;
7
+ }
8
+ }
9
+ export declare function addPrefixToExceptionOrError(e: unknown, prefix: string): TypeError | DOMException;
@@ -0,0 +1,35 @@
1
+ /// <reference types="dom-webcodecs" />
2
+ import { ZXingModule } from "@sec-ant/zxing-wasm/reader";
3
+ import { BARCODE_DETECTOR_FORMATS } from "./utils.js";
4
+ export type BarcodeFormat = (typeof BARCODE_DETECTOR_FORMATS)[number];
5
+ export interface BarcodeDetectorOptions {
6
+ formats?: BarcodeFormat[];
7
+ }
8
+ export interface Point2D {
9
+ x: number;
10
+ y: number;
11
+ }
12
+ export interface DetectedBarcode {
13
+ boundingBox: DOMRectReadOnly;
14
+ rawValue: string;
15
+ format: BarcodeFormat;
16
+ cornerPoints: [Point2D, Point2D, Point2D, Point2D];
17
+ }
18
+ interface CustomEventMap {
19
+ load: CustomEvent<ZXingModule<"reader">>;
20
+ error: CustomEvent<unknown>;
21
+ }
22
+ type ChangeEventListener = <K extends keyof CustomEventMap>(type: K, callback: ((evt: CustomEventMap[K]) => void) | {
23
+ handleEvent(evt: CustomEventMap[K]): void;
24
+ } | null, options?: boolean | AddEventListenerOptions | undefined) => void;
25
+ export interface BarcodeDetector {
26
+ addEventListener: ChangeEventListener;
27
+ removeEventListener: ChangeEventListener;
28
+ }
29
+ export declare class BarcodeDetector extends EventTarget {
30
+ #private;
31
+ constructor(barcodeDectorOptions?: BarcodeDetectorOptions);
32
+ static getSupportedFormats(): Promise<readonly BarcodeFormat[]>;
33
+ detect(image: ImageBitmapSourceWebCodecs): Promise<DetectedBarcode[]>;
34
+ }
35
+ export { setZXingModuleOverrides } from "@sec-ant/zxing-wasm";
@@ -0,0 +1,2 @@
1
+ import "./side-effects.js";
2
+ export * from "./pure.js";
@@ -0,0 +1,6 @@
1
+ import "./side-effects.js";
2
+ import { BarcodeDetector as t, setZXingModuleOverrides as d } from "./pure.js";
3
+ export {
4
+ t as BarcodeDetector,
5
+ d as setZXingModuleOverrides
6
+ };
@@ -0,0 +1 @@
1
+ export * from "./BarcodeDetector.js";