diff --git a/README.md b/README.md
index 1ae84206..101864b7 100644
--- a/README.md
+++ b/README.md
@@ -25,9 +25,9 @@ $ npm install dynamsoft-javascript-barcode --save
cdn
```html
-
+
-
+
```
[Download zip](https://www.dynamsoft.com/barcode-reader/downloads/?utm_source=github&package=js)
@@ -36,7 +36,7 @@ cdn
Please visit https://www.dynamsoft.com/customer/license/trialLicense/?product=dbr&utm_source=github&package=js to get a valid license and update `PRODUCT-KEYS`:
```html
-
+
```
## Quick Usage
@@ -45,7 +45,7 @@ Please visit https://www.dynamsoft.com/customer/license/trialLicense/?product=db
-
+
+
+
```
The same can be done with other CDNs like `unpkg`
```javascript
-
+
```
> **NOTE**: : Since we do change the library a bit in each release, to make sure your application doesn't get interrupted by automatic updates, use a specific version in your production environment, as shown above. Using a general major version like `@7` is not recommended.
@@ -440,7 +440,7 @@ The following introduces the 3rd way. Check out the following code on how it's d
-
+
@@ -763,7 +833,7 @@ export declare class BarcodeScanner extends BarcodeReader {
/**
* A mode not use video, get a frame from OS camera instead.
* ```js
- * let scanner = await DBR.BarcodeReader.createInstance();
+ * let scanner = await Dynamsoft.DBR.BarcodeReader.createInstance();
* if(scanner.singleFrameMode){
* // the browser does not provide webrtc API, dbrjs automatically use singleFrameMode instead
* scanner.show();
@@ -774,7 +844,7 @@ export declare class BarcodeScanner extends BarcodeReader {
/**
* A mode not use video, get a frame from OS camera instead.
* ```js
- * let scanner = await DBR.BarcodeReader.createInstance();
+ * let scanner = await Dynamsoft.DBR.BarcodeReader.createInstance();
* scanner.singleFrameMode = true; // use singleFrameMode anyway
* scanner.show();
* ```
@@ -790,6 +860,8 @@ export declare class BarcodeScanner extends BarcodeReader {
/** @ignore */
_lastDeviceId: string;
private _intervalDetectVideoPause;
+ private _vc_bPlayingVideoBeforeHide;
+ private _ev_documentHideEvent;
/** @ignore */
_video: HTMLVideoElement;
/** @ignore */
@@ -840,6 +912,27 @@ export declare class BarcodeScanner extends BarcodeReader {
* refer: `favicon bug` https://bugs.chromium.org/p/chromium/issues/detail?id=1069731&q=favicon&can=2
*/
bPlaySoundOnSuccessfulRead: (boolean | string);
+ /**
+ * Whether to vibrate when the scanner reads a barcode successfully.
+ * Default value is `false`, which does not vibrate.
+ * Use `frame` or `true` to play a sound when any barcode is found within a frame.
+ * Use `unduplicated` to play a sound only when any unique/unduplicated barcode is found within a frame.
+ * ```js
+ * // https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#chrome_enterprise_policies
+ * startPlayButton.addEventListener('click', function() {
+ * scanner.bVibrateOnSuccessfulRead = false;
+ * scanner.bVibrateOnSuccessfulRead = true;
+ * scanner.bVibrateOnSuccessfulRead = "frame";
+ * scanner.bVibrateOnSuccessfulRead = "unduplicated";
+ * });
+ * ```
+ * refer: `favicon bug` https://bugs.chromium.org/p/chromium/issues/detail?id=1069731&q=favicon&can=2
+ */
+ bVibrateOnSuccessfulRead: (boolean | string);
+ /**
+ * @see [[bVibrateOnSuccessfulRead]]
+ */
+ vibrateDuration: number;
/** @ignore */
_allCameras: VideoDeviceInfo[];
/** @ignore */
@@ -879,7 +972,7 @@ export declare class BarcodeScanner extends BarcodeReader {
/**
* Create a `BarcodeScanner` object.
* ```
- * let scanner = await DBR.BarcodeScanner.createInstance();
+ * let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
* ```
* @param config
* @category Initialize and Destroy
@@ -893,20 +986,26 @@ export declare class BarcodeScanner extends BarcodeReader {
decodeUrl(source: string): Promise;
/** @ignore */
decodeBuffer(buffer: Uint8Array | Uint8ClampedArray | ArrayBuffer | Blob, width: number, height: number, stride: number, format: EnumImagePixelFormat, config?: any): Promise;
+ /**
+ * await scanner.showVideo();
+ * console.log(await scanner.decodeCurrentFrame());
+ */
+ decodeCurrentFrame(): Promise;
private clearMapDecodeRecord;
private static readonly singlePresetRegion;
private static isRegionSinglePreset;
private static isRegionNormalPreset;
/**
* Update runtime settings with a given struct, or a string of `speed`, `balance`, `coverage` and `single` to use preset settings for BarcodeScanner.
- * We recommend using the speed-optimized `single` preset if scanning only one barcode at a time. The `single` is only available in `BarcodeScanner`.
- * The default settings for BarcodeScanner is `single`, starting from version 8.0.0.
+ * We recommend using the speed-optimized `single` preset if scanning only one line at a time. The `single` is only available in `BarcodeScanner`.
+ * The default settings for BarcodeScanner is `single`.
* ```js
* await scanner.updateRuntimeSettings('balance');
* let settings = await scanner.getRuntimeSettings();
- * settings.barcodeFormatIds = DBR.EnumBarcodeFormat.BF_ONED;
+ * settings.barcodeFormatIds = Dynamsoft.DBR.EnumBarcodeFormat.BF_ONED;
* await scanner.updateRuntimeSettings(settings);
* ```
+ * @see [RuntimeSettings](https://www.dynamsoft.com/barcode-reader/programming/c-cplusplus/struct/PublicRuntimeSettings.html?ver=latest&utm_source=github&package=js)
* @category Runtime Settings
*/
updateRuntimeSettings(settings: RuntimeSettings | string): Promise;
@@ -1195,6 +1294,15 @@ export declare class BarcodeScanner extends BarcodeReader {
* @category Open and Close
*/
open(): Promise;
+ /**
+ * Bind UI, open the camera, but not decode.
+ * ```js
+ * await scanner.openVideo();
+ * console.log(await scanner.decodeCurrentFrame());
+ * ```
+ * @category Open and Close
+ */
+ openVideo(): Promise;
/**
* Stop decoding, release camera, unbind UI.
* @category Open and Close
@@ -1208,6 +1316,15 @@ export declare class BarcodeScanner extends BarcodeReader {
* @category Open and Close
*/
show(): Promise;
+ /**
+ * Bind UI, open the camera, but not decode, and remove the UIElement `display` style if the original style is `display:none;`.
+ * ```js
+ * await scanner.showVideo()
+ * console.log(await scanner.decodeCurrentFrame());
+ * ```
+ * @category Open and Close
+ */
+ showVideo(): Promise;
/**
* Stop decoding, release camera, unbind UI, and set the Element as `display:none;`.
* @category Open and Close
@@ -1290,70 +1407,6 @@ export declare enum EnumDPMCodeReadingMode {
DPMCRM_SKIP = 0,
DPMCRM_REV = 2147483648
}
-export declare enum EnumErrorCode {
- DBR_SYSTEM_EXCEPTION = 1,
- DBR_SUCCESS = 0,
- DBR_UNKNOWN = -10000,
- DBR_NO_MEMORY = -10001,
- DBR_NULL_REFERENCE = -10002,
- DBR_LICENSE_INVALID = -10003,
- DBR_LICENSE_EXPIRED = -10004,
- DBR_FILE_NOT_FOUND = -10005,
- DBR_FILETYPE_NOT_SUPPORTED = -10006,
- DBR_BPP_NOT_SUPPORTED = -10007,
- DBR_INDEX_INVALID = -10008,
- DBR_BARCODE_FORMAT_INVALID = -10009,
- DBR_CUSTOM_REGION_INVALID = -10010,
- DBR_MAX_BARCODE_NUMBER_INVALID = -10011,
- DBR_IMAGE_READ_FAILED = -10012,
- DBR_TIFF_READ_FAILED = -10013,
- DBR_QR_LICENSE_INVALID = -10016,
- DBR_1D_LICENSE_INVALID = -10017,
- DBR_DIB_BUFFER_INVALID = -10018,
- DBR_PDF417_LICENSE_INVALID = -10019,
- DBR_DATAMATRIX_LICENSE_INVALID = -10020,
- DBR_PDF_READ_FAILED = -10021,
- DBR_PDF_DLL_MISSING = -10022,
- DBR_PAGE_NUMBER_INVALID = -10023,
- DBR_CUSTOM_SIZE_INVALID = -10024,
- DBR_CUSTOM_MODULESIZE_INVALID = -10025,
- DBR_RECOGNITION_TIMEOUT = -10026,
- DBR_JSON_PARSE_FAILED = -10030,
- DBR_JSON_TYPE_INVALID = -10031,
- DBR_JSON_KEY_INVALID = -10032,
- DBR_JSON_VALUE_INVALID = -10033,
- DBR_JSON_NAME_KEY_MISSING = -10034,
- DBR_JSON_NAME_VALUE_DUPLICATED = -10035,
- DBR_TEMPLATE_NAME_INVALID = -10036,
- DBR_JSON_NAME_REFERENCE_INVALID = -10037,
- DBR_PARAMETER_VALUE_INVALID = -10038,
- DBR_DOMAIN_NOT_MATCHED = -10039,
- DBR_RESERVEDINFO_NOT_MATCHED = -10040,
- DBR_AZTEC_LICENSE_INVALID = -10041,
- DBR_LICENSE_DLL_MISSING = -10042,
- DBR_LICENSEKEY_NOT_MATCHED = -10043,
- DBR_REQUESTED_FAILED = -10044,
- DBR_LICENSE_INIT_FAILED = -10045,
- DBR_PATCHCODE_LICENSE_INVALID = -10046,
- DBR_POSTALCODE_LICENSE_INVALID = -10047,
- DBR_DPM_LICENSE_INVALID = -10048,
- DBR_FRAME_DECODING_THREAD_EXISTS = -10049,
- DBR_STOP_DECODING_THREAD_FAILED = -10050,
- DBR_SET_MODE_ARGUMENT_ERROR = -10051,
- DBR_LICENSE_CONTENT_INVALID = -10052,
- DBR_LICENSE_KEY_INVALID = -10053,
- DBR_LICENSE_DEVICE_RUNS_OUT = -10054,
- DBR_GET_MODE_ARGUMENT_ERROR = -10055,
- DBR_IRT_LICENSE_INVALID = -10056,
- DBR_MAXICODE_LICENSE_INVALID = -10057,
- DBR_GS1_DATABAR_LICENSE_INVALID = -10058,
- DBR_GS1_COMPOSITE_LICENSE_INVALID = -10059,
- DBR_DOTCODE_LICENSE_INVALID = -10061,
- DMERR_NO_LICENSE = -20000,
- DMERR_LICENSE_SYNC_FAILED = -20003,
- DMERR_TRIAL_LICENSE = -20010,
- DMERR_FAILED_TO_REACH_LTS = -20200
-}
export declare enum EnumGrayscaleTransformationMode {
GTM_INVERTED = 1,
GTM_ORIGINAL = 2,
diff --git a/dist/dbr.js b/dist/dbr.js
index d648c3e6..34da1d48 100644
--- a/dist/dbr.js
+++ b/dist/dbr.js
@@ -4,8 +4,8 @@
* @website http://www.dynamsoft.com
* @preserve Copyright 2021, Dynamsoft Corporation
* @author Dynamsoft
-* @version 8.2.1 (js 20210326)
+* @version 8.2.3 (js 20210413)
* @fileoverview Dynamsoft JavaScript Library for Barcode Reader
* More info on DBR JS: https://www.dynamsoft.com/Products/barcode-recognition-javascript.aspx
*/
-!function(e,t){let bNode=!!(typeof global=="object"&&global.process&&global.process.release&&global.process.release.name&&typeof HTMLCanvasElement=="undefined");"object"==typeof exports&&"object"==typeof module?module.exports=!bNode?t():t(require("worker_threads"),require("https"),require("http"),require("fs"),require("os")):"function"==typeof define&&define.amd?define(t):"object"==typeof exports?exports.dbr=!bNode?t():t(require("worker_threads"),require("https"),require("http"),require("fs"),require("os")):e.dbr=t(e.worker_threads,e.https,e.http,e.fs,e.os)}(("object"==typeof window?window:global),(function(e,t,i,n,r){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=5)}([function(t,i){t.exports=e},function(e,i){e.exports=t},function(e,t){e.exports=i},function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t,i){"use strict";var n,r,o,s;i.r(t),i.d(t,"BarcodeReader",(function(){return c})),i.d(t,"BarcodeScanner",(function(){return g})),i.d(t,"EnumBarcodeColourMode",(function(){return E})),i.d(t,"EnumBarcodeComplementMode",(function(){return R})),i.d(t,"EnumBarcodeFormat",(function(){return s})),i.d(t,"EnumBarcodeFormat_2",(function(){return A})),i.d(t,"EnumBinarizationMode",(function(){return I})),i.d(t,"EnumClarityCalculationMethod",(function(){return f})),i.d(t,"EnumClarityFilterMode",(function(){return D})),i.d(t,"EnumColourClusteringMode",(function(){return T})),i.d(t,"EnumColourConversionMode",(function(){return S})),i.d(t,"EnumConflictMode",(function(){return m})),i.d(t,"EnumDeblurMode",(function(){return M})),i.d(t,"EnumDeformationResistingMode",(function(){return C})),i.d(t,"EnumDPMCodeReadingMode",(function(){return p})),i.d(t,"EnumErrorCode",(function(){return r})),i.d(t,"EnumGrayscaleTransformationMode",(function(){return v})),i.d(t,"EnumImagePixelFormat",(function(){return n})),i.d(t,"EnumImagePreprocessingMode",(function(){return y})),i.d(t,"EnumIMResultDataType",(function(){return o})),i.d(t,"EnumIntermediateResultSavingMode",(function(){return L})),i.d(t,"EnumIntermediateResultType",(function(){return O})),i.d(t,"EnumLocalizationMode",(function(){return N})),i.d(t,"EnumPDFReadingMode",(function(){return B})),i.d(t,"EnumQRCodeErrorCorrectionLevel",(function(){return b})),i.d(t,"EnumRegionPredetectionMode",(function(){return P})),i.d(t,"EnumResultCoordinateType",(function(){return F})),i.d(t,"EnumResultType",(function(){return w})),i.d(t,"EnumScaleUpMode",(function(){return U})),i.d(t,"EnumTerminatePhase",(function(){return k})),i.d(t,"EnumTextAssistedCorrectionMode",(function(){return V})),i.d(t,"EnumTextFilterMode",(function(){return G})),i.d(t,"EnumTextResultOrderMode",(function(){return x})),i.d(t,"EnumTextureDetectionMode",(function(){return W})),i.d(t,"EnumLicenseModule",(function(){return H})),i.d(t,"EnumChargeWay",(function(){return K})),function(e){e[e.IPF_Binary=0]="IPF_Binary",e[e.IPF_BinaryInverted=1]="IPF_BinaryInverted",e[e.IPF_GrayScaled=2]="IPF_GrayScaled",e[e.IPF_NV21=3]="IPF_NV21",e[e.IPF_RGB_565=4]="IPF_RGB_565",e[e.IPF_RGB_555=5]="IPF_RGB_555",e[e.IPF_RGB_888=6]="IPF_RGB_888",e[e.IPF_ARGB_8888=7]="IPF_ARGB_8888",e[e.IPF_RGB_161616=8]="IPF_RGB_161616",e[e.IPF_ARGB_16161616=9]="IPF_ARGB_16161616",e[e.IPF_ABGR_8888=10]="IPF_ABGR_8888",e[e.IPF_ABGR_16161616=11]="IPF_ABGR_16161616",e[e.IPF_BGR_888=12]="IPF_BGR_888"}(n||(n={})),function(e){e[e.DBR_SYSTEM_EXCEPTION=1]="DBR_SYSTEM_EXCEPTION",e[e.DBR_SUCCESS=0]="DBR_SUCCESS",e[e.DBR_UNKNOWN=-1e4]="DBR_UNKNOWN",e[e.DBR_NO_MEMORY=-10001]="DBR_NO_MEMORY",e[e.DBR_NULL_REFERENCE=-10002]="DBR_NULL_REFERENCE",e[e.DBR_LICENSE_INVALID=-10003]="DBR_LICENSE_INVALID",e[e.DBR_LICENSE_EXPIRED=-10004]="DBR_LICENSE_EXPIRED",e[e.DBR_FILE_NOT_FOUND=-10005]="DBR_FILE_NOT_FOUND",e[e.DBR_FILETYPE_NOT_SUPPORTED=-10006]="DBR_FILETYPE_NOT_SUPPORTED",e[e.DBR_BPP_NOT_SUPPORTED=-10007]="DBR_BPP_NOT_SUPPORTED",e[e.DBR_INDEX_INVALID=-10008]="DBR_INDEX_INVALID",e[e.DBR_BARCODE_FORMAT_INVALID=-10009]="DBR_BARCODE_FORMAT_INVALID",e[e.DBR_CUSTOM_REGION_INVALID=-10010]="DBR_CUSTOM_REGION_INVALID",e[e.DBR_MAX_BARCODE_NUMBER_INVALID=-10011]="DBR_MAX_BARCODE_NUMBER_INVALID",e[e.DBR_IMAGE_READ_FAILED=-10012]="DBR_IMAGE_READ_FAILED",e[e.DBR_TIFF_READ_FAILED=-10013]="DBR_TIFF_READ_FAILED",e[e.DBR_QR_LICENSE_INVALID=-10016]="DBR_QR_LICENSE_INVALID",e[e.DBR_1D_LICENSE_INVALID=-10017]="DBR_1D_LICENSE_INVALID",e[e.DBR_DIB_BUFFER_INVALID=-10018]="DBR_DIB_BUFFER_INVALID",e[e.DBR_PDF417_LICENSE_INVALID=-10019]="DBR_PDF417_LICENSE_INVALID",e[e.DBR_DATAMATRIX_LICENSE_INVALID=-10020]="DBR_DATAMATRIX_LICENSE_INVALID",e[e.DBR_PDF_READ_FAILED=-10021]="DBR_PDF_READ_FAILED",e[e.DBR_PDF_DLL_MISSING=-10022]="DBR_PDF_DLL_MISSING",e[e.DBR_PAGE_NUMBER_INVALID=-10023]="DBR_PAGE_NUMBER_INVALID",e[e.DBR_CUSTOM_SIZE_INVALID=-10024]="DBR_CUSTOM_SIZE_INVALID",e[e.DBR_CUSTOM_MODULESIZE_INVALID=-10025]="DBR_CUSTOM_MODULESIZE_INVALID",e[e.DBR_RECOGNITION_TIMEOUT=-10026]="DBR_RECOGNITION_TIMEOUT",e[e.DBR_JSON_PARSE_FAILED=-10030]="DBR_JSON_PARSE_FAILED",e[e.DBR_JSON_TYPE_INVALID=-10031]="DBR_JSON_TYPE_INVALID",e[e.DBR_JSON_KEY_INVALID=-10032]="DBR_JSON_KEY_INVALID",e[e.DBR_JSON_VALUE_INVALID=-10033]="DBR_JSON_VALUE_INVALID",e[e.DBR_JSON_NAME_KEY_MISSING=-10034]="DBR_JSON_NAME_KEY_MISSING",e[e.DBR_JSON_NAME_VALUE_DUPLICATED=-10035]="DBR_JSON_NAME_VALUE_DUPLICATED",e[e.DBR_TEMPLATE_NAME_INVALID=-10036]="DBR_TEMPLATE_NAME_INVALID",e[e.DBR_JSON_NAME_REFERENCE_INVALID=-10037]="DBR_JSON_NAME_REFERENCE_INVALID",e[e.DBR_PARAMETER_VALUE_INVALID=-10038]="DBR_PARAMETER_VALUE_INVALID",e[e.DBR_DOMAIN_NOT_MATCHED=-10039]="DBR_DOMAIN_NOT_MATCHED",e[e.DBR_RESERVEDINFO_NOT_MATCHED=-10040]="DBR_RESERVEDINFO_NOT_MATCHED",e[e.DBR_AZTEC_LICENSE_INVALID=-10041]="DBR_AZTEC_LICENSE_INVALID",e[e.DBR_LICENSE_DLL_MISSING=-10042]="DBR_LICENSE_DLL_MISSING",e[e.DBR_LICENSEKEY_NOT_MATCHED=-10043]="DBR_LICENSEKEY_NOT_MATCHED",e[e.DBR_REQUESTED_FAILED=-10044]="DBR_REQUESTED_FAILED",e[e.DBR_LICENSE_INIT_FAILED=-10045]="DBR_LICENSE_INIT_FAILED",e[e.DBR_PATCHCODE_LICENSE_INVALID=-10046]="DBR_PATCHCODE_LICENSE_INVALID",e[e.DBR_POSTALCODE_LICENSE_INVALID=-10047]="DBR_POSTALCODE_LICENSE_INVALID",e[e.DBR_DPM_LICENSE_INVALID=-10048]="DBR_DPM_LICENSE_INVALID",e[e.DBR_FRAME_DECODING_THREAD_EXISTS=-10049]="DBR_FRAME_DECODING_THREAD_EXISTS",e[e.DBR_STOP_DECODING_THREAD_FAILED=-10050]="DBR_STOP_DECODING_THREAD_FAILED",e[e.DBR_SET_MODE_ARGUMENT_ERROR=-10051]="DBR_SET_MODE_ARGUMENT_ERROR",e[e.DBR_LICENSE_CONTENT_INVALID=-10052]="DBR_LICENSE_CONTENT_INVALID",e[e.DBR_LICENSE_KEY_INVALID=-10053]="DBR_LICENSE_KEY_INVALID",e[e.DBR_LICENSE_DEVICE_RUNS_OUT=-10054]="DBR_LICENSE_DEVICE_RUNS_OUT",e[e.DBR_GET_MODE_ARGUMENT_ERROR=-10055]="DBR_GET_MODE_ARGUMENT_ERROR",e[e.DBR_IRT_LICENSE_INVALID=-10056]="DBR_IRT_LICENSE_INVALID",e[e.DBR_MAXICODE_LICENSE_INVALID=-10057]="DBR_MAXICODE_LICENSE_INVALID",e[e.DBR_GS1_DATABAR_LICENSE_INVALID=-10058]="DBR_GS1_DATABAR_LICENSE_INVALID",e[e.DBR_GS1_COMPOSITE_LICENSE_INVALID=-10059]="DBR_GS1_COMPOSITE_LICENSE_INVALID",e[e.DBR_DOTCODE_LICENSE_INVALID=-10061]="DBR_DOTCODE_LICENSE_INVALID",e[e.DMERR_NO_LICENSE=-2e4]="DMERR_NO_LICENSE",e[e.DMERR_LICENSE_SYNC_FAILED=-20003]="DMERR_LICENSE_SYNC_FAILED",e[e.DMERR_TRIAL_LICENSE=-20010]="DMERR_TRIAL_LICENSE",e[e.DMERR_FAILED_TO_REACH_LTS=-20200]="DMERR_FAILED_TO_REACH_LTS"}(r||(r={})),function(e){e[e.IMRDT_IMAGE=1]="IMRDT_IMAGE",e[e.IMRDT_CONTOUR=2]="IMRDT_CONTOUR",e[e.IMRDT_LINESEGMENT=4]="IMRDT_LINESEGMENT",e[e.IMRDT_LOCALIZATIONRESULT=8]="IMRDT_LOCALIZATIONRESULT",e[e.IMRDT_REGIONOFINTEREST=16]="IMRDT_REGIONOFINTEREST",e[e.IMRDT_QUADRILATERAL=32]="IMRDT_QUADRILATERAL"}(o||(o={})),function(e){e[e.BF_ALL=-31457281]="BF_ALL",e[e.BF_ONED=1050623]="BF_ONED",e[e.BF_GS1_DATABAR=260096]="BF_GS1_DATABAR",e[e.BF_CODE_39=1]="BF_CODE_39",e[e.BF_CODE_128=2]="BF_CODE_128",e[e.BF_CODE_93=4]="BF_CODE_93",e[e.BF_CODABAR=8]="BF_CODABAR",e[e.BF_ITF=16]="BF_ITF",e[e.BF_EAN_13=32]="BF_EAN_13",e[e.BF_EAN_8=64]="BF_EAN_8",e[e.BF_UPC_A=128]="BF_UPC_A",e[e.BF_UPC_E=256]="BF_UPC_E",e[e.BF_INDUSTRIAL_25=512]="BF_INDUSTRIAL_25",e[e.BF_CODE_39_EXTENDED=1024]="BF_CODE_39_EXTENDED",e[e.BF_GS1_DATABAR_OMNIDIRECTIONAL=2048]="BF_GS1_DATABAR_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_TRUNCATED=4096]="BF_GS1_DATABAR_TRUNCATED",e[e.BF_GS1_DATABAR_STACKED=8192]="BF_GS1_DATABAR_STACKED",e[e.BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL=16384]="BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_EXPANDED=32768]="BF_GS1_DATABAR_EXPANDED",e[e.BF_GS1_DATABAR_EXPANDED_STACKED=65536]="BF_GS1_DATABAR_EXPANDED_STACKED",e[e.BF_GS1_DATABAR_LIMITED=131072]="BF_GS1_DATABAR_LIMITED",e[e.BF_PATCHCODE=262144]="BF_PATCHCODE",e[e.BF_PDF417=33554432]="BF_PDF417",e[e.BF_QR_CODE=67108864]="BF_QR_CODE",e[e.BF_DATAMATRIX=134217728]="BF_DATAMATRIX",e[e.BF_AZTEC=268435456]="BF_AZTEC",e[e.BF_MAXICODE=536870912]="BF_MAXICODE",e[e.BF_MICRO_QR=1073741824]="BF_MICRO_QR",e[e.BF_MICRO_PDF417=524288]="BF_MICRO_PDF417",e[e.BF_GS1_COMPOSITE=-2147483648]="BF_GS1_COMPOSITE",e[e.BF_MSI_CODE=1048576]="BF_MSI_CODE",e[e.BF_NULL=0]="BF_NULL"}(s||(s={}));var a=function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{_(n.next(e))}catch(e){o(e)}}function a(e){try{_(n.throw(e))}catch(e){o(e)}}function _(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}_((n=n.apply(e,t||[])).next())}))};const _=!!("object"==typeof global&&global.process&&global.process.release&&global.process.release.name&&"undefined"==typeof HTMLCanvasElement),d=!_&&"undefined"==typeof self,l=_?global:d?{}:self;class c{constructor(){this._canvasMaxWH="iPhone"==c.browserInfo.OS||"Android"==c.browserInfo.OS?2048:4096,this._instanceID=void 0,this.bSaveOriCanvas=!1,this.oriCanvas=null,this.maxVideoCvsLength=3,this.videoCvses=[],this.videoGlCvs=null,this.videoGl=null,this.glImgData=null,this.bFilterRegionInJs=!0,this._region=null,this._timeStartDecode=null,this._timeEnterInnerDBR=null,this._bUseWebgl=!0,this.decodeRecords=[],this.bDestroyed=!1,this._lastErrorCode=0,this._lastErrorString=""}static get version(){return this._version}static get productKeys(){return this._productKeys}static set productKeys(e){if("unload"!=this._loadWasmStatus)throw new Error("`productKeys` is not allowed to change after loadWasm is called.");c._productKeys=e}static get handshakeCode(){return this._productKeys}static set handshakeCode(e){if("unload"!=this._loadWasmStatus)throw new Error("`handshakeCode` is not allowed to change after loadWasm is called.");c._productKeys=e}static get organizationID(){return this._organizationID}static set organizationID(e){if("unload"!=this._loadWasmStatus)throw new Error("`organizationID` is not allowed to change after loadWasm is called.");c._organizationID=e}static set sessionPassword(e){if("unload"!=this._loadWasmStatus)throw new Error("`sessionPassword` is not allowed to change after loadWasm is called.");c._sessionPassword=e}static get sessionPassword(){return this._sessionPassword}static detectEnvironment(){return a(this,void 0,void 0,(function*(){let e={wasm:"undefined"!=typeof WebAssembly&&("undefined"==typeof navigator||!(/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&/\(.+\s11_2_([2-6]).*\)/.test(navigator.userAgent))),worker:!!(_?process.version>="v12":"undefined"!=typeof Worker),getUserMedia:!("undefined"==typeof navigator||!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia),camera:!1,browser:this.browserInfo.browser,version:this.browserInfo.version,OS:this.browserInfo.OS};if(e.getUserMedia)try{(yield navigator.mediaDevices.getUserMedia({video:!0})).getTracks().forEach(e=>{e.stop()}),e.camera=!0}catch(e){}return e}))}static get engineResourcePath(){return this._engineResourcePath}static set engineResourcePath(e){if("unload"!=this._loadWasmStatus)throw new Error("`engineResourcePath` is not allowed to change after loadWasm is called.");if(null==e&&(e="./"),_||d)c._engineResourcePath=e;else{let t=document.createElement("a");t.href=e,c._engineResourcePath=t.href}this._engineResourcePath.endsWith("/")||(c._engineResourcePath+="/")}static get licenseServer(){return this._licenseServer}static set licenseServer(e){if("unload"!=this._loadWasmStatus)throw new Error("`licenseServer` is not allowed to change after loadWasm is called.");if(null==e)c._licenseServer=[];else{e instanceof Array||(e=[e]);for(let t=0;t= v12.");let e,t=this.productKeys,n=t.startsWith("PUBLIC-TRIAL"),r=n||8==t.length||t.length>8&&!t.startsWith("t")&&!t.startsWith("f")&&!t.startsWith("P")&&!t.startsWith("L")||0==t.length&&0!=this.organizationID.length;if(r&&(_?process.version<"v15"&&(e=new Error("To use handshake need nodejs version >= v15.")):(l.crypto||(e=new Error("Please upgrade your browser to support handshake code.")),l.crypto.subtle||(e=new Error("Need https to use handshake code in this browser.")))),e){if(!n)throw e;n=!1,r=!1}return n&&(t="",console.warn("Automatically apply for a public trial license.")),yield new Promise((e,n)=>a(this,void 0,void 0,(function*(){switch(this._loadWasmStatus){case"unload":{c._loadWasmStatus="loading";let e=this.engineResourcePath+this._workerName;if(_||this.engineResourcePath.startsWith(location.origin)||(e=yield fetch(e).then(e=>e.blob()).then(e=>URL.createObjectURL(e))),_){const t=i(0);c._dbrWorker=new t.Worker(e)}else c._dbrWorker=new Worker(e);this._dbrWorker.onerror=e=>{c._loadWasmStatus="loadFail";for(let t of this._loadWasmCallbackArr)t(new Error(e.message))},this._dbrWorker.onmessage=e=>a(this,void 0,void 0,(function*(){let t=e.data?e.data:e;switch(t.type){case"log":this._onLog&&this._onLog(t.message);break;case"load":if(t.success){c._loadWasmStatus="loadSuccess",c._version=t.version+"(JS "+this._jsVersion+"."+this._jsEditVersion+")",this._onLog&&this._onLog("load dbr worker success");for(let e of this._loadWasmCallbackArr)e();this._dbrWorker.onerror=null}else{let e=new Error(t.message);e.stack=t.stack+"\n"+e.stack,c._loadWasmStatus="loadFail";for(let t of this._loadWasmCallbackArr)t(e)}break;case"task":{let e=t.id,i=t.body;try{this._taskCallbackMap.get(e)(i),this._taskCallbackMap.delete(e)}catch(t){throw this._taskCallbackMap.delete(e),t}break}default:this._onLog&&this._onLog(e)}})),_&&this._dbrWorker.on("message",this._dbrWorker.onmessage),this._dbrWorker.postMessage({type:"loadWasm",bd:this._bWasmDebug,engineResourcePath:this.engineResourcePath,version:this._jsVersion,brtk:r,pk:t,og:this.organizationID,dm:!_&&location.origin.startsWith("http")?location.origin:"https://localhost",bUseFullFeature:this._bUseFullFeature,browserInfo:this.browserInfo,deviceFriendlyName:this.deviceFriendlyName,ls:this.licenseServer,sp:this._sessionPassword,lm:this._limitModules,cw:this._chargeWay})}case"loading":this._loadWasmCallbackArr.push(t=>{t?n(t):e()});break;case"loadSuccess":e();break;case"loadFail":n()}})))}))}static createInstanceInWorker(e=!1){return a(this,void 0,void 0,(function*(){return yield this.loadWasm(),yield new Promise((t,i)=>{let n=c._nextTaskID++;this._taskCallbackMap.set(n,e=>{if(e.success)return t(e.instanceID);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),this._dbrWorker.postMessage({type:"createInstance",id:n,productKeys:"",bScanner:e})})}))}static createInstance(){return a(this,void 0,void 0,(function*(){let e=new c;return e._instanceID=yield this.createInstanceInWorker(),e}))}decode(e){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("decode(source: any)"),c._onLog&&(this._timeStartDecode=Date.now()),_)return e instanceof Buffer?yield this._decodeFileInMemory_Uint8Array(new Uint8Array(e)):e instanceof Uint8Array?yield this._decodeFileInMemory_Uint8Array(e):"string"==typeof e||e instanceof String?"data:image/"==e.substring(0,11)?yield this._decode_Base64(e):"http"==e.substring(0,4)?yield this._decode_Url(e):yield this._decode_FilePath(e):yield Promise.reject(TypeError("'_decode(source, config)': Type of 'source' should be 'Buffer', 'Uint8Array', 'String(base64 with image mime)' or 'String(url)'."));{let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),e instanceof Blob?yield this._decode_Blob(e,t):e instanceof ArrayBuffer?yield this._decode_ArrayBuffer(e,t):e instanceof Uint8Array||e instanceof Uint8ClampedArray?yield this._decode_Uint8Array(e,t):e instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?yield this._decode_Image(e,t):e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?yield this._decode_Canvas(e,t):e instanceof HTMLVideoElement?yield this._decode_Video(e,t):"string"==typeof e||e instanceof String?"data:image/"==e.substring(0,11)?yield this._decode_Base64(e,t):yield this._decode_Url(e,t):yield Promise.reject(TypeError("'_decode(source, config)': Type of 'source' should be 'Blob', 'ArrayBuffer', 'Uint8Array', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement', 'String(base64 with image mime)' or 'String(url)'."))}}))}decodeBase64String(e){return a(this,void 0,void 0,(function*(){let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),this._decode_Base64(e,t)}))}decodeUrl(e){return a(this,void 0,void 0,(function*(){let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),this._decode_Url(e,t)}))}_decodeBuffer_Uint8Array(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){return yield new Promise((s,a)=>{let _=c._nextTaskID++;c._taskCallbackMap.set(_,e=>{if(e.success){let t,i=c._onLog?Date.now():0;this.bufferShared&&!this.bufferShared.length&&(this.bufferShared=e.buffer);try{t=this._handleRetJsonString(e.decodeReturn)}catch(e){return a(e)}if(c._onLog){let e=Date.now();c._onLog("DBR time get result: "+i),c._onLog("Handle image cost: "+(this._timeEnterInnerDBR-this._timeStartDecode)),c._onLog("DBR worker decode image cost: "+(i-this._timeEnterInnerDBR)),c._onLog("DBR worker handle results: "+(e-i)),c._onLog("Total decode image cost: "+(e-this._timeStartDecode))}return s(t)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,a(t)}}),c._onLog&&(this._timeEnterInnerDBR=Date.now()),c._onLog&&c._onLog("Send buffer to worker:"+Date.now()),c._dbrWorker.postMessage({type:"decodeBuffer",id:_,instanceID:this._instanceID,body:{buffer:e,width:t,height:i,stride:n,format:r,config:o}},[e.buffer])})}))}_decodeBuffer_Blob(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){return c._onLog&&c._onLog("_decodeBuffer_Blob(buffer,width,height,stride,format)"),yield new Promise((t,i)=>{let n=new FileReader;n.readAsArrayBuffer(e),n.onload=()=>{t(n.result)},n.onerror=()=>{i(n.error)}}).then(e=>this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o))}))}decodeBuffer(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){let s;return c._onLog&&c._onLog("decodeBuffer(buffer,width,height,stride,format)"),c._onLog&&(this._timeStartDecode=Date.now()),_?e instanceof Uint8Array?s=yield this._decodeBuffer_Uint8Array(e,t,i,n,r,o):e instanceof Buffer&&(s=yield this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o)):e instanceof Uint8Array||e instanceof Uint8ClampedArray?s=yield this._decodeBuffer_Uint8Array(e,t,i,n,r,o):e instanceof ArrayBuffer?s=yield this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o):e instanceof Blob&&(s=yield this._decodeBuffer_Blob(e,t,i,n,r,o)),s}))}_decodeFileInMemory_Uint8Array(e){return a(this,void 0,void 0,(function*(){return yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success){let n;try{n=this._handleRetJsonString(e.decodeReturn)}catch(e){return i(e)}return t(n)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),c._dbrWorker.postMessage({type:"decodeFileInMemory",id:n,instanceID:this._instanceID,body:{bytes:e}})})}))}getRuntimeSettings(){return a(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success){let t=JSON.parse(i.results);return null!=this.userDefinedRegion&&(t.region=JSON.parse(JSON.stringify(this.userDefinedRegion))),e(t)}{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"getRuntimeSettings",id:i,instanceID:this._instanceID})})}))}updateRuntimeSettings(e){return a(this,void 0,void 0,(function*(){let t;if("string"==typeof e||"object"==typeof e&&e instanceof String)if("speed"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=3,t.expectedBarcodesCount=0,t.localizationModes=[2,0,0,0,0,0,0,0]}else if("balance"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=5,t.expectedBarcodesCount=512,t.localizationModes=[2,16,0,0,0,0,0,0]}else if("coverage"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region}else t=JSON.parse(e);else{if("object"!=typeof e)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");if(t=JSON.parse(JSON.stringify(e)),t.region instanceof Array){let e=t.region;[e.regionLeft,e.regionTop,e.regionLeft,e.regionBottom,e.regionMeasuredByPercentage].some(e=>void 0!==e)&&(t.region={regionLeft:e.regionLeft||0,regionTop:e.regionTop||0,regionRight:e.regionRight||0,regionBottom:e.regionBottom||0,regionMeasuredByPercentage:e.regionMeasuredByPercentage||0})}}if(!c._bUseFullFeature){if(0!=(t.barcodeFormatIds&~(s.BF_ONED|s.BF_QR_CODE|s.BF_PDF417|s.BF_DATAMATRIX))||0!=t.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=t.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}if(!_)if(this.bFilterRegionInJs){let e=t.region;if(e instanceof Array)throw Error("The `region` of type `Array` is only allowed in `BarcodeScanner`.");this.userDefinedRegion=JSON.parse(JSON.stringify(e)),(e.regionLeft||e.regionTop||e.regionRight||e.regionBottom||e.regionMeasuredByPercentage)&&(e.regionLeft||e.regionTop||100!=e.regionRight||100!=e.regionBottom||!e.regionMeasuredByPercentage)?this.region=e:this.region=null,t.region={regionLeft:0,regionTop:0,regionRight:0,regionBottom:0,regionMeasuredByPercentage:0}}else this.userDefinedRegion=null,this.region=null;return yield new Promise((e,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,t=>{if(t.success){try{this._handleRetJsonString(t.updateReturn)}catch(e){i(e)}return e()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}}),c._dbrWorker.postMessage({type:"updateRuntimeSettings",id:n,instanceID:this._instanceID,body:{settings:JSON.stringify(t)}})})}))}resetRuntimeSettings(){return a(this,void 0,void 0,(function*(){return this.userDefinedRegion=null,this.region=null,yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"resetRuntimeSettings",id:i,instanceID:this._instanceID})})}))}outputSettingsToString(){return a(this,void 0,void 0,(function*(){if(!c._bUseFullFeature)throw Error("outputSettingsToString() is not supported in the compact version. Please try the full-featured version.");return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e(i.results);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"outputSettingsToString",id:i,instanceID:this._instanceID})})}))}initRuntimeSettingsWithString(e){return a(this,void 0,void 0,(function*(){if(!c._bUseFullFeature)throw Error("initRuntimeSettingsWithString() is not supported in the compact version. Please try the full-featured version.");if("string"==typeof e||"object"==typeof e&&e instanceof String)e=e;else{if("object"!=typeof e)throw TypeError("'initRuntimeSettingstWithString(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");e=JSON.stringify(e)}return yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success){try{this._handleRetJsonString(e.initReturn)}catch(e){i(e)}return t()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),c._dbrWorker.postMessage({type:"initRuntimeSettingsWithString",id:n,instanceID:this._instanceID,body:{settings:e}})})}))}_decode_Blob(e,t){return a(this,void 0,void 0,(function*(){c._onLog&&c._onLog("_decode_Blob(blob: Blob)");let i=null,n=null;if("undefined"!=typeof createImageBitmap)try{i=yield createImageBitmap(e)}catch(e){}i||(n=yield function(e){return new Promise((t,i)=>{let n=URL.createObjectURL(e),r=new Image;r.dbrObjUrl=n,r.src=n,r.onload=()=>{t(r)},r.onerror=e=>{i(new Error("Can't convert blob to image : "+(e instanceof Event?e.type:e)))}})}(e));let r=yield this._decode_Image(i||n,t);return i&&i.close(),r}))}_decode_ArrayBuffer(e,t){return a(this,void 0,void 0,(function*(){return yield this._decode_Blob(new Blob([e]),t)}))}_decode_Uint8Array(e,t){return a(this,void 0,void 0,(function*(){return yield this._decode_Blob(new Blob([e]),t)}))}_decode_Image(e,t){return a(this,void 0,void 0,(function*(){c._onLog&&c._onLog("_decode_Image(image: HTMLImageElement|ImageBitmap)"),t=t||{};let i,n,r=e instanceof HTMLImageElement?e.naturalWidth:e.width,o=e instanceof HTMLImageElement?e.naturalHeight:e.height,s=Math.max(r,o);if(s>this._canvasMaxWH){let e=this._canvasMaxWH/s;i=Math.round(r*e),n=Math.round(o*e)}else i=r,n=o;let a,_=0,d=0,h=r,u=o,g=r,E=o,R=t.region;if(R){let e,t,s,a;R.regionMeasuredByPercentage?(e=R.regionLeft*i/100,t=R.regionTop*n/100,s=R.regionRight*i/100,a=R.regionBottom*n/100):(e=R.regionLeft,t=R.regionTop,s=R.regionRight,a=R.regionBottom),g=s-e,h=Math.round(g/i*r),E=a-t,u=Math.round(E/n*o),_=Math.round(e/i*r),d=Math.round(t/n*o)}!this.bSaveOriCanvas&&l.OffscreenCanvas?a=new OffscreenCanvas(g,E):(a=document.createElement("canvas"),a.width=g,a.height=E);let A,I=a.getContext("2d");0==_&&0==d&&r==h&&o==u&&r==g&&o==E?I.drawImage(e,0,0):I.drawImage(e,_,d,h,u,0,0,g,E),e.dbrObjUrl&&URL.revokeObjectURL(e.dbrObjUrl),R?(A=JSON.parse(JSON.stringify(t)),delete A.region):A=t;let f=yield this._decode_Canvas(a,A);if(R&&f.length>0)for(let e of f){let t=e.localizationResult;2==t.resultCoordinateType&&(t.x1*=.01*g,t.x2*=.01*g,t.x3*=.01*g,t.x4*=.01*g,t.y1*=.01*E,t.y2*=.01*E,t.y3*=.01*E,t.y4*=.01*E),t.x1+=_,t.x2+=_,t.x3+=_,t.x4+=_,t.y1+=d,t.y2+=d,t.y3+=d,t.y4+=d,2==t.resultCoordinateType&&(t.x1*=100/h,t.x2*=100/h,t.x3*=100/h,t.x4*=100/h,t.y1*=100/u,t.y2*=100/u,t.y3*=100/u,t.y4*=100/u)}return f}))}_decode_Canvas(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Canvas(canvas:HTMLCanvasElement)"),e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";(this.bSaveOriCanvas||this.singleFrameMode)&&(this.oriCanvas=e);let i=(e.dbrCtx2d||e.getContext("2d")).getImageData(0,0,e.width,e.height).data;return yield this._decodeBuffer_Uint8Array(i,e.width,e.height,4*e.width,n.IPF_ABGR_8888,t)}))}_decode_Video(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Video(video)"),!(e instanceof HTMLVideoElement))throw TypeError("'_decode_Video(video [, config] )': Type of 'video' should be 'HTMLVideoElement'.");if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";t=t||{};let i,r,o=e.videoWidth,s=e.videoHeight,a=Math.max(o,s);if(a>this._canvasMaxWH){let e=this._canvasMaxWH/a;i=Math.round(o*e),r=Math.round(s*e)}else i=o,r=s;let _=0,d=0,h=o,u=s,g=o,E=s,R=t.region;if(R){let e,t,n,a;R.regionMeasuredByPercentage?(e=R.regionLeft*i/100,t=R.regionTop*r/100,n=R.regionRight*i/100,a=R.regionBottom*r/100):(e=R.regionLeft,t=R.regionTop,n=R.regionRight,a=R.regionBottom),g=n-e,h=Math.round(g/i*o),E=a-t,u=Math.round(E/r*s),_=Math.round(e/i*o),d=Math.round(t/r*s)}let A=0==_&&0==d&&o==h&&s==u&&o==g&&s==E;if(!this.bSaveOriCanvas&&this._bUseWebgl&&A){this.videoGlCvs||(this.videoGlCvs=l.OffscreenCanvas?new OffscreenCanvas(g,E):document.createElement("canvas"));const t=this.videoGlCvs;t.width==g&&t.height==E||(t.height=E,t.width=g,this.videoGl&&this.videoGl.viewport(0,0,g,E));const i=this.videoGl||t.getContext("webgl",{alpha:!1,antialias:!1})||t.getContext("experimental-webgl",{alpha:!1,antialias:!1});if(!this.videoGl){this.videoGl=i;let e=i.createShader(i.VERTEX_SHADER);i.shaderSource(e,"\nattribute vec4 a_position;\nattribute vec2 a_uv;\n\nvarying vec2 v_uv;\n\nvoid main() {\n gl_Position = a_position;\n v_uv = a_uv;\n}\n"),i.compileShader(e),i.getShaderParameter(e,i.COMPILE_STATUS)||console.error("An error occurred compiling the shaders: "+i.getShaderInfoLog(e));let t=i.createShader(i.FRAGMENT_SHADER);i.shaderSource(t,"\nprecision lowp float;\n\nvarying vec2 v_uv;\n\nuniform sampler2D u_texture;\n\nvoid main() {\n vec4 sample = texture2D(u_texture, v_uv);\n float grey = 0.299 * sample.r + 0.587 * sample.g + 0.114 * sample.b;\n gl_FragColor = vec4(grey, 0.0, 0.0, 1.0);\n}\n"),i.compileShader(t),i.getShaderParameter(t,i.COMPILE_STATUS)||console.error("An error occurred compiling the shaders: "+i.getShaderInfoLog(t));let n=i.createProgram();i.attachShader(n,e),i.attachShader(n,t),i.linkProgram(n),i.getProgramParameter(n,i.LINK_STATUS)||console.error("Unable to initialize the shader program: "+i.getProgramInfoLog(n)),i.useProgram(n),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,1,0,1,1,1,1,1,-1,-1,0,0,1,-1,1,0]),i.STATIC_DRAW);let r=i.getAttribLocation(n,"a_position");i.enableVertexAttribArray(r),i.vertexAttribPointer(r,2,i.FLOAT,!1,16,0);let o=i.getAttribLocation(n,"a_uv");i.enableVertexAttribArray(o),i.vertexAttribPointer(o,2,i.FLOAT,!1,16,8),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,i.createTexture()),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.uniform1i(i.getUniformLocation(n,"u_texture"),0)}(!this.glImgData||this.glImgData.length=this.maxVideoCvsLength&&(this.videoCvses=this.videoCvses.slice(1)),this.videoCvses.push(i));const n=i.dbrCtx2d;let r;A?n.drawImage(e,0,0):n.drawImage(e,_,d,h,u,0,0,g,E),R?(r=JSON.parse(JSON.stringify(t)),delete r.region):r=t;let o=yield this._decode_Canvas(i,r);if(R&&o.length>0)for(let e of o){let t=e.localizationResult;2==t.resultCoordinateType&&(t.x1*=.01*g,t.x2*=.01*g,t.x3*=.01*g,t.x4*=.01*g,t.y1*=.01*E,t.y2*=.01*E,t.y3*=.01*E,t.y4*=.01*E),t.x1+=_,t.x2+=_,t.x3+=_,t.x4+=_,t.y1+=d,t.y2+=d,t.y3+=d,t.y4+=d,2==t.resultCoordinateType&&(t.x1*=100/h,t.x2*=100/h,t.x3*=100/h,t.x4*=100/h,t.y1*=100/u,t.y2*=100/u,t.y3*=100/u,t.y4*=100/u)}return o}}))}_decode_Base64(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Base64(base64Str)"),"string"!=typeof e&&"object"!=typeof e)return Promise.reject("'_decode_Base64(base64Str, config)': Type of 'base64Str' should be 'String'.");if("data:image/"==e.substring(0,11)&&(e=e.substring(e.indexOf(",")+1)),_){let t=Buffer.from(e,"base64");return yield this._decodeFileInMemory_Uint8Array(new Uint8Array(t))}{let i=atob(e),n=i.length,r=new Uint8Array(n);for(;n--;)r[n]=i.charCodeAt(n);return yield this._decode_Blob(new Blob([r]),t)}}))}_decode_Url(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Url(url)"),"string"!=typeof e&&"object"!=typeof e)throw TypeError("'_decode_Url(url, config)': Type of 'url' should be 'String'.");if(_){let t=yield new Promise((t,n)=>{(e.startsWith("https")?i(1):i(2)).get(e,e=>{if(200==e.statusCode){let i=[];e.on("data",e=>{i.push(e)}).on("end",()=>{t(new Uint8Array(Buffer.concat(i)))})}else n("http get fail, statusCode: "+e.statusCode)})});return yield this._decodeFileInMemory_Uint8Array(t)}{let i=yield new Promise((t,i)=>{let n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="blob",n.send(),n.onloadend=()=>a(this,void 0,void 0,(function*(){t(n.response)})),n.onerror=()=>{i(new Error("Network Error: "+n.statusText))}});return yield this._decode_Blob(i,t)}}))}_decode_FilePath(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_FilePath(path)"),!_)throw Error("'_decode_FilePath(path, config)': The method is only supported in node environment.");if("string"!=typeof e&&"object"!=typeof e)throw TypeError("'_decode_FilePath(path, config)': Type of 'path' should be 'String'.");const t=i(3);let n=yield new Promise((i,n)=>{t.readFile(e,(e,t)=>{e?n(e):i(new Uint8Array(t))})});return yield this._decodeFileInMemory_Uint8Array(n)}))}static BarcodeReaderException(e,t){let i,n=r.DBR_UNKNOWN;return"number"==typeof e?(n=e,i=new Error(t)):i=new Error(e),i.code=n,i}_handleRetJsonString(e){let t=r;if(e.textResults){for(let t=0;t{let i=t.indexOf(":");e[t.substring(0,i)]=t.substring(i+1)}),i.exception=e}}return e.decodeRecords&&(this.decodeRecords=e.decodeRecords),this._lastErrorCode=e.exception,this._lastErrorString=e.description,e.textResults}if(e.exception==t.DBR_SUCCESS)return e.data;throw c.BarcodeReaderException(e.exception,e.description)}setModeArgument(e,t,i,n){return a(this,void 0,void 0,(function*(){return yield new Promise((r,o)=>{let s=c._nextTaskID++;c._taskCallbackMap.set(s,e=>{if(e.success){try{this._handleRetJsonString(e.setReturn)}catch(e){return o(e)}return r()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}}),c._dbrWorker.postMessage({type:"setModeArgument",id:s,instanceID:this._instanceID,body:{modeName:e,index:t,argumentName:i,argumentValue:n}})})}))}getModeArgument(e,t,i){return a(this,void 0,void 0,(function*(){return yield new Promise((n,r)=>{let o=c._nextTaskID++;c._taskCallbackMap.set(o,e=>{if(e.success){let t;try{t=this._handleRetJsonString(e.getReturn)}catch(e){return r(e)}return n(t)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,r(t)}}),c._dbrWorker.postMessage({type:"getModeArgument",id:o,instanceID:this._instanceID,body:{modeName:e,index:t,argumentName:i}})})}))}getIntermediateResults(){return a(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e(i.results);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"getIntermediateResults",id:i,instanceID:this._instanceID})})}))}getIntermediateCanvas(){return a(this,void 0,void 0,(function*(){let e=yield this.getIntermediateResults(),t=[];for(let i of e)if(i.dataType==o.IMRDT_IMAGE)for(let e of i.results){const i=e.bytes;let r;switch(c._onLog&&c._onLog(" "+i.length+" "+i.byteLength+" "+e.width+" "+e.height+" "+e.stride+" "+e.format),e.format){case n.IPF_ABGR_8888:r=new Uint8ClampedArray(i);break;case n.IPF_RGB_888:{const e=i.length/3;r=new Uint8ClampedArray(4*e);for(let t=0;t{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"destroy",id:i,instanceID:this._instanceID})})}}c.bNode=_,c._jsVersion="8.2.1",c._jsEditVersion="20210326",c._version="loading...(JS "+c._jsVersion+"."+c._jsEditVersion+")",c._productKeys=_||d||!document.currentScript?"":document.currentScript.getAttribute("data-productKeys")||document.currentScript.getAttribute("data-licenseKey")||document.currentScript.getAttribute("data-handshakeCode")||"",c._organizationID=_||d||!document.currentScript?"":document.currentScript.getAttribute("data-organizationID")||"",c.browserInfo=function(){if(!_&&!d){var e={init:function(){this.browser=this.searchString(this.dataBrowser)||"unknownBrowser",this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"unknownVersion",this.OS=this.searchString(this.dataOS)||"unknownOS"},searchString:function(e){for(var t=0;t{if(_)return __dirname+"/";if(!d&&document.currentScript){let e=document.currentScript.src,t=e.indexOf("?");if(-1!=t)e=e.substring(0,t);else{let t=e.indexOf("#");-1!=t&&(e=e.substring(0,t))}return e.substring(0,e.lastIndexOf("/")+1)}return"./"})(),c._licenseServer=[],c._deviceFriendlyName="",c._isShowRelDecodeTimeInResults=!1,c._bWasmDebug=!1,c._bSendSmallRecordsForDebug=!1,c.__bUseFullFeature=_,c._nextTaskID=0,c._taskCallbackMap=new Map,c._loadWasmStatus="unload",c._loadWasmCallbackArr=[],c._lastErrorCode=0,c._lastErrorString="";var h=function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{_(n.next(e))}catch(e){o(e)}}function a(e){try{_(n.throw(e))}catch(e){o(e)}}function _(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}_((n=n.apply(e,t||[])).next())}))};const u=!!("object"==typeof global&&global.process&&global.process.release&&global.process.release.name&&"undefined"==typeof HTMLCanvasElement);class g extends c{constructor(){super(),this.styleEls=[],this.videoSettings={video:{width:{ideal:1280},height:{ideal:720},facingMode:{ideal:"environment"}}},this._singleFrameMode=!(navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),this._singleFrameModeIpt=(()=>{let e=document.createElement("input");return e.setAttribute("type","file"),e.setAttribute("accept","image/*"),e.setAttribute("capture",""),e.addEventListener("change",()=>h(this,void 0,void 0,(function*(){let t=e.files[0];e.value="";let i=yield this.decode(t);for(let e of i)delete e.bUnduplicated;if(this._drawRegionsults(i),this.onFrameRead&&this._isOpen&&!this._bPauseScan&&this.onFrameRead(i),this.onUnduplicatedRead&&this._isOpen&&!this._bPauseScan)for(let e of i)this.onUnduplicatedRead(e.barcodeText,e);yield this.clearMapDecodeRecord()}))),e})(),this._clickIptSingleFrameMode=()=>{this._singleFrameModeIpt.click()},this.intervalTime=0,this._isOpen=!1,this._bPauseScan=!1,this._lastDeviceId=void 0,this._intervalDetectVideoPause=1e3,this._video=null,this._cvsDrawArea=null,this._divScanArea=null,this._divScanLight=null,this._bgLoading=null,this._bgCamera=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._soundOnSuccessfullRead=new Audio("data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA/+M4wAAAAAAAAAAAAEluZm8AAAAPAAAABQAAAkAAgICAgICAgICAgICAgICAgICAgKCgoKCgoKCgoKCgoKCgoKCgoKCgwMDAwMDAwMDAwMDAwMDAwMDAwMDg4ODg4ODg4ODg4ODg4ODg4ODg4P//////////////////////////AAAAAExhdmM1OC41NAAAAAAAAAAAAAAAACQEUQAAAAAAAAJAk0uXRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+MYxAANQAbGeUEQAAHZYZ3fASqD4P5TKBgocg+Bw/8+CAYBA4XB9/4EBAEP4nB9+UOf/6gfUCAIKyjgQ/Kf//wfswAAAwQA/+MYxAYOqrbdkZGQAMA7DJLCsQxNOij///////////+tv///3RWiZGBEhsf/FO/+LoCSFs1dFVS/g8f/4Mhv0nhqAieHleLy/+MYxAYOOrbMAY2gABf/////////////////usPJ66R0wI4boY9/8jQYg//g2SPx1M0N3Z0kVJLIs///Uw4aMyvHJJYmPBYG/+MYxAgPMALBucAQAoGgaBoFQVBUFQWDv6gZBUFQVBUGgaBr5YSgqCoKhIGg7+IQVBUFQVBoGga//SsFSoKnf/iVTEFNRTMu/+MYxAYAAANIAAAAADEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"),this.bPlaySoundOnSuccessfulRead=!1,this._allCameras=[],this._currentCamera=null,this._videoTrack=null,this.regionMaskFillStyle="rgba(0,0,0,0.5)",this.regionMaskStrokeStyle="rgb(254,142,20)",this.regionMaskLineWidth=2,this.barcodeFillStyle="rgba(254,180,32,0.3)",this.barcodeStrokeStyle="rgba(254,180,32,0.9)",this.barcodeLineWidth=1,this.beingLazyDrawRegionsults=!1,this._indexVideoRegion=-1,this._onCameraSelChange=()=>{this.play(this._selCam.value).then(()=>{this._isOpen||this.stop()}).catch(e=>{alert("Play video failed: "+(e.message||e))})},this._onResolutionSelChange=()=>{let e,t;if(this._selRsl&&-1!=this._selRsl.selectedIndex){let i=this._selRsl.options[this._selRsl.selectedIndex];e=i.getAttribute("data-width"),t=i.getAttribute("data-height")}this.play(void 0,e,t).then(()=>{this._isOpen||this.stop()}).catch(e=>{alert("Play video failed: "+(e.message||e))})},this._onCloseBtnClick=()=>{this.hide()}}static get defaultUIElementURL(){return this._defaultUIElementURL?this._defaultUIElementURL:c.engineResourcePath+"dbr.scanner.html"}static set defaultUIElementURL(e){this._defaultUIElementURL=e}getUIElement(){return this.UIElement}setUIElement(e){return h(this,void 0,void 0,(function*(){if("string"==typeof e||e instanceof String){if(!e.trim().startsWith("<")){let t=yield fetch(e);if(!t.ok)throw Error("Network Error: "+t.statusText);e=yield t.text()}if(!e.trim().startsWith("<"))throw Error("setUIElement(elementOrUrl): Can't get valid HTMLElement.");let t=document.createElement("div");t.innerHTML=e;for(let e=0;e{h(this,void 0,void 0,(function*(){let e=yield this.getScanSettings();e.oneDTrustFrameCount=1,yield this.updateScanSettings(e)}))})()}_assertOpen(){if(!this._isOpen)throw Error("The scanner is not open.")}get soundOnSuccessfullRead(){return this._soundOnSuccessfullRead}set soundOnSuccessfullRead(e){e instanceof HTMLAudioElement?this._soundOnSuccessfullRead=e:this._soundOnSuccessfullRead=new Audio(e)}set region(e){this._region=e,this.singleFrameMode||(this.beingLazyDrawRegionsults=!0,setTimeout(()=>{this.beingLazyDrawRegionsults&&this._drawRegionsults()},500))}get region(){return this._region}static createInstance(e){return h(this,void 0,void 0,(function*(){if(u)throw new Error("`BarcodeScanner` is not supported in Node.js.");let t=new g;t._instanceID=yield g.createInstanceInWorker(!0),("string"==typeof e||e instanceof String)&&(e=JSON.parse(e));for(let i in e)t[i]=e[i];return t.UIElement||(yield t.setUIElement(this.defaultUIElementURL)),t.singleFrameMode||(yield t.updateRuntimeSettings("single")),t}))}decode(e){return super.decode(e)}decodeBase64String(e){return super.decodeBase64String(e)}decodeUrl(e){return super.decodeUrl(e)}decodeBuffer(e,t,i,n,r,o){return super.decodeBuffer(e,t,i,n,r,o)}clearMapDecodeRecord(){return h(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"clearMapDecodeRecord",id:i,instanceID:this._instanceID})})}))}static isRegionSinglePreset(e){return JSON.stringify(e)==JSON.stringify(this.singlePresetRegion)}static isRegionNormalPreset(e){return 0==e.regionLeft&&0==e.regionTop&&0==e.regionRight&&0==e.regionBottom&&0==e.regionMeasuredByPercentage}updateRuntimeSettings(e){return h(this,void 0,void 0,(function*(){let t;if("string"==typeof e||"object"==typeof e&&e instanceof String)if("speed"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region)}else if("balance"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region),t.deblurLevel=3,t.expectedBarcodesCount=512,t.localizationModes=[2,16,0,0,0,0,0,0],t.timeout=1e5}else if("coverage"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region),t.deblurLevel=5,t.expectedBarcodesCount=512,t.scaleDownThreshold=1e5,t.localizationModes=[2,16,4,8,0,0,0,0],t.timeout=1e5}else if("single"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionNormalPreset(e.region)?t.region=JSON.parse(JSON.stringify(g.singlePresetRegion)):t.region=e.region,t.expectedBarcodesCount=1,t.localizationModes=[16,2,0,0,0,0,0,0],t.barcodeZoneMinDistanceToImageBorders=0}else t=JSON.parse(e);else{if("object"!=typeof e)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");if(t=JSON.parse(JSON.stringify(e)),t.region instanceof Array){let i=e.region;[i.regionLeft,i.regionTop,i.regionLeft,i.regionBottom,i.regionMeasuredByPercentage].some(e=>void 0!==e)&&(t.region={regionLeft:i.regionLeft||0,regionTop:i.regionTop||0,regionRight:i.regionRight||0,regionBottom:i.regionBottom||0,regionMeasuredByPercentage:i.regionMeasuredByPercentage||0})}}if(!c._bUseFullFeature){if(0!=(t.barcodeFormatIds&~(s.BF_ONED|s.BF_QR_CODE|s.BF_PDF417|s.BF_DATAMATRIX))||0!=t.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=t.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}if(this.bFilterRegionInJs){let e=t.region;if(this.userDefinedRegion=JSON.parse(JSON.stringify(e)),e instanceof Array)if(e.length){for(let t=0;t{let n=c._nextTaskID++;c._taskCallbackMap.set(n,t=>{if(t.success){try{this._handleRetJsonString(t.updateReturn)}catch(e){i(e)}return e()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}}),c._dbrWorker.postMessage({type:"updateRuntimeSettings",id:n,instanceID:this._instanceID,body:{settings:JSON.stringify(t)}})}),"single"==e&&(yield this.setModeArgument("BinarizationModes",0,"EnableFillBinaryVacancy","0"),yield this.setModeArgument("LocalizationModes",0,"ScanDirection","2"),yield this.setModeArgument("BinarizationModes",0,"BlockSizeX","71"),yield this.setModeArgument("BinarizationModes",0,"BlockSizeY","71"))}))}_bindUI(){let e=[this.UIElement],t=this.UIElement.children;for(let i of t)e.push(i);for(let t=0;t','','','','','','','',''].join(""),this._optGotRsl=this._optGotRsl||this._selRsl.options[0])):!this._optGotRsl&&t.classList.contains("dbrScanner-opt-gotResolution")?this._optGotRsl=t:!this._btnClose&&t.classList.contains("dbrScanner-btn-close")?this._btnClose=t:!this._video&&t.classList.contains("dbrScanner-existingVideo")?(this._video=t,this._video.setAttribute("playsinline","true"),this.singleFrameMode=!1):!i&&t.tagName&&"video"==t.tagName.toLowerCase()&&(i=t);if(!this._video&&i&&(this._video=i),this.singleFrameMode?(this._video&&(this._video.addEventListener("click",this._clickIptSingleFrameMode),this._video.style.cursor="pointer",this._video.setAttribute("title","Take a photo")),this._cvsDrawArea&&(this._cvsDrawArea.addEventListener("click",this._clickIptSingleFrameMode),this._cvsDrawArea.style.cursor="pointer",this._cvsDrawArea.setAttribute("title","Take a photo")),this._divScanArea&&(this._divScanArea.addEventListener("click",this._clickIptSingleFrameMode),this._divScanArea.style.cursor="pointer",this._divScanArea.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="")):this._bgLoading&&(this._bgLoading.style.display=""),this._selCam&&this._selCam.addEventListener("change",this._onCameraSelChange),this._selRsl&&this._selRsl.addEventListener("change",this._onResolutionSelChange),this._btnClose&&this._btnClose.addEventListener("click",this._onCloseBtnClick),!this._video)throw this._unbindUI(),Error("Can not find HTMLVideoElement with class `dbrScanner-video`.");this._isOpen=!0}_unbindUI(){this._clearRegionsults(),this.singleFrameMode?(this._video&&(this._video.removeEventListener("click",this._clickIptSingleFrameMode),this._video.style.cursor="",this._video.removeAttribute("title")),this._cvsDrawArea&&(this._cvsDrawArea.removeEventListener("click",this._clickIptSingleFrameMode),this._cvsDrawArea.style.cursor="",this._cvsDrawArea.removeAttribute("title")),this._divScanArea&&(this._divScanArea.removeEventListener("click",this._clickIptSingleFrameMode),this._divScanArea.style.cursor="",this._divScanArea.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none")):this._bgLoading&&(this._bgLoading.style.display="none"),this._selCam&&this._selCam.removeEventListener("change",this._onCameraSelChange),this._selRsl&&this._selRsl.removeEventListener("change",this._onResolutionSelChange),this._btnClose&&this._btnClose.removeEventListener("click",this._onCloseBtnClick),this._video=null,this._cvsDrawArea=null,this._divScanArea=null,this._divScanLight=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._isOpen=!1}_renderSelCameraInfo(){let e,t;if(this._selCam&&(e=this._selCam.value,this._selCam.innerHTML=""),this._selCam){for(let i of this._allCameras){let n=document.createElement("option");n.value=i.deviceId,n.innerText=i.label,this._selCam.append(n),e==i.deviceId&&(t=n)}let i=this._selCam.childNodes;if(!t&&this._currentCamera&&i.length)for(let e of i)if(this._currentCamera.label==e.innerText){t=e;break}t&&(this._selCam.value=t.value)}}getAllCameras(){return h(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices(),t=[];let i=0;for(let n=0;n{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success){let t=i.results;return t.intervalTime=this.intervalTime,e(t)}{let e=new Error(i.message);return e.stack+="\n"+i.stack,t(e)}}),c._dbrWorker.postMessage({type:"getScanSettings",id:i,instanceID:this._instanceID})})}))}updateScanSettings(e){return h(this,void 0,void 0,(function*(){return this.intervalTime=e.intervalTime,yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack+="\n"+e.stack,i(t)}}),g._dbrWorker.postMessage({type:"updateScanSettings",id:n,instanceID:this._instanceID,body:{settings:e}})})}))}getVideoSettings(){return JSON.parse(JSON.stringify(this.videoSettings))}updateVideoSettings(e){return this.videoSettings=JSON.parse(JSON.stringify(e)),this._lastDeviceId=null,this._isOpen?this.play():Promise.resolve()}isOpen(){return this._isOpen}_show(){this.UIElement.parentNode||(this.UIElement.style.position="fixed",this.UIElement.style.left="0",this.UIElement.style.top="0",document.body.append(this.UIElement)),"none"==this.UIElement.style.display&&(this.UIElement.style.display="")}stop(){this._video&&this._video.srcObject&&(c._onLog&&c._onLog("======stop video========"),this._video.srcObject.getTracks().forEach(e=>{e.stop()}),this._video.srcObject=null,this._videoTrack=null),this._video&&this._video.classList.contains("dbrScanner-existingVideo")&&(c._onLog&&c._onLog("======stop existing video========"),this._video.pause(),this._video.currentTime=0),this._bgLoading&&(this._bgLoading.style.animationPlayState=""),this._divScanLight&&(this._divScanLight.style.display="none")}pause(){this._video&&this._video.pause(),this._divScanLight&&(this._divScanLight.style.display="none")}play(e,t,i){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.singleFrameMode)return this._clickIptSingleFrameMode(),{width:0,height:0};if(this._video&&this._video.classList.contains("dbrScanner-existingVideo")){yield this._video.play();let e={width:this._video.videoWidth,height:this._video.videoHeight};return this.onPlayed&&setTimeout(()=>{this.onPlayed(e)},0),e}if(this._video&&this._video.srcObject&&(this.stop(),yield new Promise(e=>setTimeout(e,500))),c._onLog&&c._onLog("======before video========"),"Android"==c.browserInfo.OS&&(yield this.getAllCameras()),this.bDestroyed)throw new Error("The BarcodeScanner instance has been destroyed.");const n=this.videoSettings;"boolean"==typeof n.video&&(n.video={});const r="iPhone"==c.browserInfo.OS;let o,s;if(r?t>=1280||i>=1280?n.video.width=1280:t>=640||i>=640?n.video.width=640:(t<640||i<640)&&(n.video.width=320):(t&&(n.video.width={ideal:t}),i&&(n.video.height={ideal:i})),e)delete n.video.facingMode,n.video.deviceId={exact:e},this._lastDeviceId=e;else if(n.video.deviceId);else if(this._lastDeviceId)delete n.video.facingMode,n.video.deviceId={ideal:this._lastDeviceId};else if(n.video.facingMode){let e=n.video.facingMode;if(e instanceof Array&&e.length&&(e=e[0]),e=e.exact||e.ideal||e,"environment"===e){for(let e of this._allCameras){let t=e.label.toLowerCase();if(t&&-1!=t.indexOf("facing back")&&/camera[0-9]?\s0,/.test(t)){delete n.video.facingMode,n.video.deviceId={ideal:e.deviceId};break}}o=!!n.video.facingMode}}c._onLog&&c._onLog("======try getUserMedia========"),c._onLog&&c._onLog("ask "+JSON.stringify(n.video.width)+"x"+JSON.stringify(n.video.height));try{c._onLog&&c._onLog(n),s=yield navigator.mediaDevices.getUserMedia(n)}catch(e){c._onLog&&c._onLog(e),c._onLog&&c._onLog("======try getUserMedia again========"),r?(delete n.video.width,delete n.video.height):o?(delete n.video.facingMode,this._allCameras.length&&(n.video.deviceId={ideal:this._allCameras[this._allCameras.length-1].deviceId})):n.video=!0,c._onLog&&c._onLog(n),s=yield navigator.mediaDevices.getUserMedia(n)}if(this.bDestroyed)throw s.getTracks().forEach(e=>{e.stop()}),new Error("The BarcodeScanner instance has been destroyed.");{const e=s.getVideoTracks();e.length&&(this._videoTrack=e[0])}this._video.srcObject=s,c._onLog&&c._onLog("======play video========");try{yield this._video.play()}catch(e){c._onLog&&c._onLog("======play video again========"),yield new Promise(e=>{setTimeout(e,1e3)}),yield this._video.play()}c._onLog&&c._onLog("======played video========"),this._bgLoading&&(this._bgLoading.style.animationPlayState="paused"),this._drawRegionsults();const a="got "+this._video.videoWidth+"x"+this._video.videoHeight;this._optGotRsl&&(this._optGotRsl.setAttribute("data-width",this._video.videoWidth),this._optGotRsl.setAttribute("data-height",this._video.videoHeight),this._optGotRsl.innerText=a,this._selRsl&&this._optGotRsl.parentNode==this._selRsl&&(this._selRsl.value="got")),c._onLog&&c._onLog(a),"Android"!==c.browserInfo.OS&&(yield this.getAllCameras()),yield this.getCurrentCamera(),this._renderSelCameraInfo();let _={width:this._video.videoWidth,height:this._video.videoHeight};return this.onPlayed&&setTimeout(()=>{this.onPlayed(_)},0),_}))}pauseScan(){this._assertOpen(),this._bPauseScan=!0,this._divScanLight&&(this._divScanLight.style.display="none")}resumeScan(){this._assertOpen(),this._bPauseScan=!1}getCapabilities(){return this._assertOpen(),this._videoTrack.getCapabilities?this._videoTrack.getCapabilities():{}}getCameraSettings(){return this._assertOpen(),this._videoTrack.getSettings()}getConstraints(){return this._assertOpen(),this._videoTrack.getConstraints()}applyConstraints(e){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),!this._videoTrack.applyConstraints)throw Error("Not supported.");return yield this._videoTrack.applyConstraints(e)}))}turnOnTorch(){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.getCapabilities().torch)return yield this._videoTrack.applyConstraints({advanced:[{torch:!0}]});throw Error("Not supported.")}))}turnOffTorch(){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.getCapabilities().torch)return yield this._videoTrack.applyConstraints({advanced:[{torch:!1}]});throw Error("Not supported.")}))}setColorTemperature(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().colorTemperature;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{colorTemperature:e}]})}))}setExposureCompensation(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().exposureCompensation;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{exposureCompensation:e}]})}))}setZoom(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().zoom;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{zoom:e}]})}))}setFrameRate(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().frameRate;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({width:{ideal:Math.max(this._video.videoWidth,this._video.videoHeight)},frameRate:e})}))}_cloneDecodeResults(e){if(e instanceof Array){let t=[];for(let i of e)t.push(this._cloneDecodeResults(i));return t}{let t=e;return JSON.parse(JSON.stringify(t,(e,t)=>"oriVideoCanvas"==e||"searchRegionCanvas"==e?void 0:t))}}_loopReadVideo(){return h(this,void 0,void 0,(function*(){if(this.bDestroyed)return;if(!this._isOpen)return void(yield this.clearMapDecodeRecord());if(this._video.paused||this._bPauseScan)return c._onLog&&c._onLog("Video or scan is paused. Ask in 1s."),yield this.clearMapDecodeRecord(),void setTimeout(()=>{this._loopReadVideo()},this._intervalDetectVideoPause);this._divScanLight&&"none"==this._divScanLight.style.display&&(this._divScanLight.style.display=""),c._onLog&&c._onLog("======= once read =======");(new Date).getTime();c._onLog&&(this._timeStartDecode=Date.now());let e={};if(this.region)if(this.region instanceof Array){++this._indexVideoRegion>=this.region.length&&(this._indexVideoRegion=0);let t=this.region[this._indexVideoRegion];t&&(e.region=JSON.parse(JSON.stringify(t)))}else e.region=JSON.parse(JSON.stringify(this.region));this._decode_Video(this._video,e).then(e=>{if(c._onLog&&c._onLog(e),this._isOpen&&!this._video.paused&&!this._bPauseScan){if(this.bPlaySoundOnSuccessfulRead&&e.length){let t=!1;if(!0===this.bPlaySoundOnSuccessfulRead||"frame"===this.bPlaySoundOnSuccessfulRead)t=!0;else if("unduplicated"===this.bPlaySoundOnSuccessfulRead)for(let i of e)if(i.bUnduplicated){t=!0;break}t&&(this.soundOnSuccessfullRead.currentTime=0,this.soundOnSuccessfullRead.play().catch(e=>{console.warn("Autoplay not allowed. User interaction required.")}))}if(this.onFrameRead){let t=this._cloneDecodeResults(e);for(let e of t)delete e.bUnduplicated;this.onFrameRead(t)}if(this.onUnduplicatedRead)for(let t of e)t.bUnduplicated&&this.onUnduplicatedRead(t.barcodeText,this._cloneDecodeResults(t));this._drawRegionsults(e)}setTimeout(()=>{this._loopReadVideo()},this.intervalTime)}).catch(e=>{if(c._onLog&&c._onLog(e.message||e),setTimeout(()=>{this._loopReadVideo()},Math.max(this.intervalTime,1e3)),"platform error"!=e.message)throw console.error(e.message),e})}))}_drawRegionsults(e){let t,i,n;if(this.beingLazyDrawRegionsults=!1,this.singleFrameMode){if(!this.oriCanvas)return;t="contain",i=this.oriCanvas.width,n=this.oriCanvas.height}else{if(!this._video)return;t=this._video.style.objectFit||"contain",i=this._video.videoWidth,n=this._video.videoHeight}let r=this.region;if(r&&(!r.regionLeft&&!r.regionRight&&!r.regionTop&&!r.regionBottom&&!r.regionMeasuredByPercentage||r instanceof Array?r=null:r.regionMeasuredByPercentage?r=r.regionLeft||r.regionRight||100!==r.regionTop||100!==r.regionBottom?{regionLeft:Math.round(r.regionLeft/100*i),regionTop:Math.round(r.regionTop/100*n),regionRight:Math.round(r.regionRight/100*i),regionBottom:Math.round(r.regionBottom/100*n)}:null:(r=JSON.parse(JSON.stringify(r)),delete r.regionMeasuredByPercentage)),this._cvsDrawArea){this._cvsDrawArea.style.objectFit=t;let o=this._cvsDrawArea;o.width=i,o.height=n;let s=o.getContext("2d");if(r){s.fillStyle=this.regionMaskFillStyle,s.fillRect(0,0,o.width,o.height),s.globalCompositeOperation="destination-out",s.fillStyle="#000";let e=Math.round(this.regionMaskLineWidth/2);s.fillRect(r.regionLeft-e,r.regionTop-e,r.regionRight-r.regionLeft+2*e,r.regionBottom-r.regionTop+2*e),s.globalCompositeOperation="source-over",s.strokeStyle=this.regionMaskStrokeStyle,s.lineWidth=this.regionMaskLineWidth,s.rect(r.regionLeft,r.regionTop,r.regionRight-r.regionLeft,r.regionBottom-r.regionTop),s.stroke()}if(e){s.globalCompositeOperation="destination-over",s.fillStyle=this.barcodeFillStyle,s.strokeStyle=this.barcodeStrokeStyle,s.lineWidth=this.barcodeLineWidth,e=e||[];for(let t of e){let e=t.localizationResult;s.beginPath(),s.moveTo(e.x1,e.y1),s.lineTo(e.x2,e.y2),s.lineTo(e.x3,e.y3),s.lineTo(e.x4,e.y4),s.fill(),s.beginPath(),s.moveTo(e.x1,e.y1),s.lineTo(e.x2,e.y2),s.lineTo(e.x3,e.y3),s.lineTo(e.x4,e.y4),s.closePath(),s.stroke()}}this.singleFrameMode&&(s.globalCompositeOperation="destination-over",s.drawImage(this.oriCanvas,0,0))}if(this._divScanArea){let e=this._video.offsetWidth,t=this._video.offsetHeight,o=1;e/tsuper.destroy}});return h(this,void 0,void 0,(function*(){this.close();for(let e of this.styleEls)e.remove();this.styleEls.splice(0,this.styleEls.length),this.bDestroyed||(yield e.destroy.call(this))}))}}var E,R,A,I,f,D,T,S,m,M,C,p,v,y,L,O,N,B,b,P,F,w,U,k,V,G,x,W,H,K;g.singlePresetRegion=[null,{regionLeft:0,regionTop:30,regionRight:100,regionBottom:70,regionMeasuredByPercentage:1},{regionLeft:25,regionTop:25,regionRight:75,regionBottom:75,regionMeasuredByPercentage:1},{regionLeft:25,regionTop:25,regionRight:75,regionBottom:75,regionMeasuredByPercentage:1}],function(e){e[e.BICM_DARK_ON_LIGHT=1]="BICM_DARK_ON_LIGHT",e[e.BICM_LIGHT_ON_DARK=2]="BICM_LIGHT_ON_DARK",e[e.BICM_DARK_ON_DARK=4]="BICM_DARK_ON_DARK",e[e.BICM_LIGHT_ON_LIGHT=8]="BICM_LIGHT_ON_LIGHT",e[e.BICM_DARK_LIGHT_MIXED=16]="BICM_DARK_LIGHT_MIXED",e[e.BICM_DARK_ON_LIGHT_DARK_SURROUNDING=32]="BICM_DARK_ON_LIGHT_DARK_SURROUNDING",e[e.BICM_SKIP=0]="BICM_SKIP",e[e.BICM_REV=2147483648]="BICM_REV"}(E||(E={})),function(e){e[e.BCM_AUTO=1]="BCM_AUTO",e[e.BCM_GENERAL=2]="BCM_GENERAL",e[e.BCM_SKIP=0]="BCM_SKIP",e[e.BCM_REV=2147483648]="BCM_REV"}(R||(R={})),function(e){e[e.BF2_NULL=0]="BF2_NULL",e[e.BF2_POSTALCODE=32505856]="BF2_POSTALCODE",e[e.BF2_NONSTANDARD_BARCODE=1]="BF2_NONSTANDARD_BARCODE",e[e.BF2_USPSINTELLIGENTMAIL=1048576]="BF2_USPSINTELLIGENTMAIL",e[e.BF2_POSTNET=2097152]="BF2_POSTNET",e[e.BF2_PLANET=4194304]="BF2_PLANET",e[e.BF2_AUSTRALIANPOST=8388608]="BF2_AUSTRALIANPOST",e[e.BF2_RM4SCC=16777216]="BF2_RM4SCC",e[e.BF2_DOTCODE=2]="BF2_DOTCODE"}(A||(A={})),function(e){e[e.BM_AUTO=1]="BM_AUTO",e[e.BM_LOCAL_BLOCK=2]="BM_LOCAL_BLOCK",e[e.BM_SKIP=0]="BM_SKIP",e[e.BM_THRESHOLD=4]="BM_THRESHOLD",e[e.BM_REV=2147483648]="BM_REV"}(I||(I={})),function(e){e[e.ECCM_CONTRAST=1]="ECCM_CONTRAST"}(f||(f={})),function(e){e[e.CFM_GENERAL=1]="CFM_GENERAL"}(D||(D={})),function(e){e[e.CCM_AUTO=1]="CCM_AUTO",e[e.CCM_GENERAL_HSV=2]="CCM_GENERAL_HSV",e[e.CCM_SKIP=0]="CCM_SKIP",e[e.CCM_REV=2147483648]="CCM_REV"}(T||(T={})),function(e){e[e.CICM_GENERAL=1]="CICM_GENERAL",e[e.CICM_SKIP=0]="CICM_SKIP",e[e.CICM_REV=2147483648]="CICM_REV"}(S||(S={})),function(e){e[e.CM_IGNORE=1]="CM_IGNORE",e[e.CM_OVERWRITE=2]="CM_OVERWRITE"}(m||(m={})),function(e){e[e.DM_SKIP=0]="DM_SKIP",e[e.DM_DIRECT_BINARIZATION=1]="DM_DIRECT_BINARIZATION",e[e.DM_THRESHOLD_BINARIZATION=2]="DM_THRESHOLD_BINARIZATION",e[e.DM_GRAY_EQUALIZATION=4]="DM_GRAY_EQUALIZATION",e[e.DM_SMOOTHING=8]="DM_SMOOTHING",e[e.DM_MORPHING=16]="DM_MORPHING",e[e.DM_DEEP_ANALYSIS=32]="DM_DEEP_ANALYSIS",e[e.DM_SHARPENING=64]="DM_SHARPENING"}(M||(M={})),function(e){e[e.DRM_AUTO=1]="DRM_AUTO",e[e.DRM_GENERAL=2]="DRM_GENERAL",e[e.DRM_SKIP=0]="DRM_SKIP",e[e.DRM_REV=2147483648]="DRM_REV"}(C||(C={})),function(e){e[e.DPMCRM_AUTO=1]="DPMCRM_AUTO",e[e.DPMCRM_GENERAL=2]="DPMCRM_GENERAL",e[e.DPMCRM_SKIP=0]="DPMCRM_SKIP",e[e.DPMCRM_REV=2147483648]="DPMCRM_REV"}(p||(p={})),function(e){e[e.GTM_INVERTED=1]="GTM_INVERTED",e[e.GTM_ORIGINAL=2]="GTM_ORIGINAL",e[e.GTM_SKIP=0]="GTM_SKIP",e[e.GTM_REV=2147483648]="GTM_REV"}(v||(v={})),function(e){e[e.IPM_AUTO=1]="IPM_AUTO",e[e.IPM_GENERAL=2]="IPM_GENERAL",e[e.IPM_GRAY_EQUALIZE=4]="IPM_GRAY_EQUALIZE",e[e.IPM_GRAY_SMOOTH=8]="IPM_GRAY_SMOOTH",e[e.IPM_SHARPEN_SMOOTH=16]="IPM_SHARPEN_SMOOTH",e[e.IPM_MORPHOLOGY=32]="IPM_MORPHOLOGY",e[e.IPM_SKIP=0]="IPM_SKIP",e[e.IPM_REV=2147483648]="IPM_REV"}(y||(y={})),function(e){e[e.IRSM_MEMORY=1]="IRSM_MEMORY",e[e.IRSM_FILESYSTEM=2]="IRSM_FILESYSTEM",e[e.IRSM_BOTH=4]="IRSM_BOTH"}(L||(L={})),function(e){e[e.IRT_NO_RESULT=0]="IRT_NO_RESULT",e[e.IRT_ORIGINAL_IMAGE=1]="IRT_ORIGINAL_IMAGE",e[e.IRT_COLOUR_CLUSTERED_IMAGE=2]="IRT_COLOUR_CLUSTERED_IMAGE",e[e.IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE=4]="IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE",e[e.IRT_TRANSFORMED_GRAYSCALE_IMAGE=8]="IRT_TRANSFORMED_GRAYSCALE_IMAGE",e[e.IRT_PREDETECTED_REGION=16]="IRT_PREDETECTED_REGION",e[e.IRT_PREPROCESSED_IMAGE=32]="IRT_PREPROCESSED_IMAGE",e[e.IRT_BINARIZED_IMAGE=64]="IRT_BINARIZED_IMAGE",e[e.IRT_TEXT_ZONE=128]="IRT_TEXT_ZONE",e[e.IRT_CONTOUR=256]="IRT_CONTOUR",e[e.IRT_LINE_SEGMENT=512]="IRT_LINE_SEGMENT",e[e.IRT_FORM=1024]="IRT_FORM",e[e.IRT_SEGMENTATION_BLOCK=2048]="IRT_SEGMENTATION_BLOCK",e[e.IRT_TYPED_BARCODE_ZONE=4096]="IRT_TYPED_BARCODE_ZONE",e[e.IRT_PREDETECTED_QUADRILATERAL=8192]="IRT_PREDETECTED_QUADRILATERAL"}(O||(O={})),function(e){e[e.LM_SKIP=0]="LM_SKIP",e[e.LM_AUTO=1]="LM_AUTO",e[e.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",e[e.LM_LINES=8]="LM_LINES",e[e.LM_STATISTICS=4]="LM_STATISTICS",e[e.LM_SCAN_DIRECTLY=16]="LM_SCAN_DIRECTLY",e[e.LM_STATISTICS_MARKS=32]="LM_STATISTICS_MARKS",e[e.LM_STATISTICS_POSTAL_CODE=64]="LM_STATISTICS_POSTAL_CODE",e[e.LM_CENTRE=128]="LM_CENTRE",e[e.LM_REV=2147483648]="LM_REV"}(N||(N={})),function(e){e[e.PDFRM_RASTER=1]="PDFRM_RASTER",e[e.PDFRM_AUTO=2]="PDFRM_AUTO",e[e.PDFRM_VECTOR=4]="PDFRM_VECTOR",e[e.PDFRM_REV=2147483648]="PDFRM_REV"}(B||(B={})),function(e){e[e.QRECL_ERROR_CORRECTION_H=0]="QRECL_ERROR_CORRECTION_H",e[e.QRECL_ERROR_CORRECTION_L=1]="QRECL_ERROR_CORRECTION_L",e[e.QRECL_ERROR_CORRECTION_M=2]="QRECL_ERROR_CORRECTION_M",e[e.QRECL_ERROR_CORRECTION_Q=3]="QRECL_ERROR_CORRECTION_Q"}(b||(b={})),function(e){e[e.RPM_AUTO=1]="RPM_AUTO",e[e.RPM_GENERAL=2]="RPM_GENERAL",e[e.RPM_GENERAL_RGB_CONTRAST=4]="RPM_GENERAL_RGB_CONTRAST",e[e.RPM_GENERAL_GRAY_CONTRAST=8]="RPM_GENERAL_GRAY_CONTRAST",e[e.RPM_GENERAL_HSV_CONTRAST=16]="RPM_GENERAL_HSV_CONTRAST",e[e.RPM_SKIP=0]="RPM_SKIP",e[e.RPM_REV=2147483648]="RPM_REV"}(P||(P={})),function(e){e[e.RCT_PIXEL=1]="RCT_PIXEL",e[e.RCT_PERCENTAGE=2]="RCT_PERCENTAGE"}(F||(F={})),function(e){e[e.RT_STANDARD_TEXT=0]="RT_STANDARD_TEXT",e[e.RT_RAW_TEXT=1]="RT_RAW_TEXT",e[e.RT_CANDIDATE_TEXT=2]="RT_CANDIDATE_TEXT",e[e.RT_PARTIAL_TEXT=3]="RT_PARTIAL_TEXT"}(w||(w={})),function(e){e[e.SUM_AUTO=1]="SUM_AUTO",e[e.SUM_LINEAR_INTERPOLATION=2]="SUM_LINEAR_INTERPOLATION",e[e.SUM_NEAREST_NEIGHBOUR_INTERPOLATION=4]="SUM_NEAREST_NEIGHBOUR_INTERPOLATION",e[e.SUM_SKIP=0]="SUM_SKIP",e[e.SUM_REV=2147483648]="SUM_REV"}(U||(U={})),function(e){e[e.TP_REGION_PREDETECTED=1]="TP_REGION_PREDETECTED",e[e.TP_IMAGE_PREPROCESSED=2]="TP_IMAGE_PREPROCESSED",e[e.TP_IMAGE_BINARIZED=4]="TP_IMAGE_BINARIZED",e[e.TP_BARCODE_LOCALIZED=8]="TP_BARCODE_LOCALIZED",e[e.TP_BARCODE_TYPE_DETERMINED=16]="TP_BARCODE_TYPE_DETERMINED",e[e.TP_BARCODE_RECOGNIZED=32]="TP_BARCODE_RECOGNIZED"}(k||(k={})),function(e){e[e.TACM_AUTO=1]="TACM_AUTO",e[e.TACM_VERIFYING=2]="TACM_VERIFYING",e[e.TACM_VERIFYING_PATCHING=4]="TACM_VERIFYING_PATCHING",e[e.TACM_SKIP=0]="TACM_SKIP",e[e.TACM_REV=2147483648]="TACM_REV"}(V||(V={})),function(e){e[e.TFM_AUTO=1]="TFM_AUTO",e[e.TFM_GENERAL_CONTOUR=2]="TFM_GENERAL_CONTOUR",e[e.TFM_SKIP=0]="TFM_SKIP",e[e.TFM_REV=2147483648]="TFM_REV"}(G||(G={})),function(e){e[e.TROM_CONFIDENCE=1]="TROM_CONFIDENCE",e[e.TROM_POSITION=2]="TROM_POSITION",e[e.TROM_FORMAT=4]="TROM_FORMAT",e[e.TROM_SKIP=0]="TROM_SKIP",e[e.TROM_REV=2147483648]="TROM_REV"}(x||(x={})),function(e){e[e.TDM_AUTO=1]="TDM_AUTO",e[e.TDM_GENERAL_WIDTH_CONCENTRATION=2]="TDM_GENERAL_WIDTH_CONCENTRATION",e[e.TDM_SKIP=0]="TDM_SKIP",e[e.TDM_REV=2147483648]="TDM_REV"}(W||(W={})),function(e){e.DM_LM_ONED="1",e.DM_LM_QR_CODE="2",e.DM_LM_PDF417="3",e.DM_LM_DATAMATRIX="4",e.DM_LM_AZTEC="5",e.DM_LM_MAXICODE="6",e.DM_LM_PATCHCODE="7",e.DM_LM_GS1_DATABAR="8",e.DM_LM_GS1_COMPOSITE="9",e.DM_LM_POSTALCODE="10",e.DM_LM_DOTCODE="11",e.DM_LM_INTERMEDIATE_RESULT="12",e.DM_LM_DPM="13",e.DM_LM_NONSTANDARD_BARCODE="16"}(H||(H={})),function(e){e.DM_CW_AUTO="",e.DM_CW_DEVICE_COUNT="DeviceCount",e.DM_CW_SCAN_COUNT="ScanCount",e.DM_CW_CONCURRENT_DEVICE_COUNT="ConcurrentDeviceCount",e.DM_CW_APP_DOMIAN_COUNT="Domain",e.DM_CW_ACTIVE_DEVICE_COUNT="ActiveDeviceCount",e.DM_CW_INSTANCE_COUNT="InstanceCount",e.DM_CW_CONCURRENT_INSTANCE_COUNT="ConcurrentInstanceCount"}(K||(K={}));const J={BarcodeReader:c,BarcodeScanner:g,EnumBarcodeColourMode:E,EnumBarcodeComplementMode:R,EnumBarcodeFormat:s,EnumBarcodeFormat_2:A,EnumBinarizationMode:I,EnumClarityCalculationMethod:f,EnumClarityFilterMode:D,EnumColourClusteringMode:T,EnumColourConversionMode:S,EnumConflictMode:m,EnumDeblurMode:M,EnumDeformationResistingMode:C,EnumDPMCodeReadingMode:p,EnumErrorCode:r,EnumGrayscaleTransformationMode:v,EnumImagePixelFormat:n,EnumImagePreprocessingMode:y,EnumIMResultDataType:o,EnumIntermediateResultSavingMode:L,EnumIntermediateResultType:O,EnumLocalizationMode:N,EnumPDFReadingMode:B,EnumQRCodeErrorCorrectionLevel:b,EnumRegionPredetectionMode:P,EnumResultCoordinateType:F,EnumResultType:w,EnumScaleUpMode:U,EnumTerminatePhase:k,EnumTextAssistedCorrectionMode:V,EnumTextFilterMode:G,EnumTextResultOrderMode:x,EnumTextureDetectionMode:W,EnumLicenseModule:H,EnumChargeWay:K};t.default=J}])}));if(typeof dbr!="undefined"){if(typeof Dynamsoft=="undefined"){Dynamsoft={};}if(typeof Dynamsoft.DBR=="undefined"){Dynamsoft.DBR={};}for(let key in dbr){Dynamsoft.DBR[key]=dbr[key];}}
\ No newline at end of file
+!function(e,t){let bNode=!!(typeof global=="object"&&global.process&&global.process.release&&global.process.release.name&&typeof HTMLCanvasElement=="undefined");"object"==typeof exports&&"object"==typeof module?module.exports=!bNode?t():t(require("worker_threads"),require("https"),require("http"),require("fs"),require("os")):"function"==typeof define&&define.amd?define(t):"object"==typeof exports?exports.dbr=!bNode?t():t(require("worker_threads"),require("https"),require("http"),require("fs"),require("os")):e.dbr=t(e.worker_threads,e.https,e.http,e.fs,e.os)}(("object"==typeof window?window:global),(function(e,t,i,n,r){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=5)}([function(t,i){t.exports=e},function(e,i){e.exports=t},function(e,t){e.exports=i},function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t,i){"use strict";var n,r,o,s;i.r(t),i.d(t,"BarcodeReader",(function(){return c})),i.d(t,"BarcodeScanner",(function(){return g})),i.d(t,"EnumBarcodeColourMode",(function(){return E})),i.d(t,"EnumBarcodeComplementMode",(function(){return R})),i.d(t,"EnumBarcodeFormat",(function(){return s})),i.d(t,"EnumBarcodeFormat_2",(function(){return I})),i.d(t,"EnumBinarizationMode",(function(){return A})),i.d(t,"EnumClarityCalculationMethod",(function(){return f})),i.d(t,"EnumClarityFilterMode",(function(){return D})),i.d(t,"EnumColourClusteringMode",(function(){return T})),i.d(t,"EnumColourConversionMode",(function(){return S})),i.d(t,"EnumConflictMode",(function(){return m})),i.d(t,"EnumDeblurMode",(function(){return M})),i.d(t,"EnumDeformationResistingMode",(function(){return C})),i.d(t,"EnumDPMCodeReadingMode",(function(){return v})),i.d(t,"EnumErrorCode",(function(){return r})),i.d(t,"EnumGrayscaleTransformationMode",(function(){return p})),i.d(t,"EnumImagePixelFormat",(function(){return n})),i.d(t,"EnumImagePreprocessingMode",(function(){return L})),i.d(t,"EnumIMResultDataType",(function(){return o})),i.d(t,"EnumIntermediateResultSavingMode",(function(){return y})),i.d(t,"EnumIntermediateResultType",(function(){return O})),i.d(t,"EnumLocalizationMode",(function(){return N})),i.d(t,"EnumPDFReadingMode",(function(){return B})),i.d(t,"EnumQRCodeErrorCorrectionLevel",(function(){return b})),i.d(t,"EnumRegionPredetectionMode",(function(){return P})),i.d(t,"EnumResultCoordinateType",(function(){return F})),i.d(t,"EnumResultType",(function(){return w})),i.d(t,"EnumScaleUpMode",(function(){return U})),i.d(t,"EnumTerminatePhase",(function(){return V})),i.d(t,"EnumTextAssistedCorrectionMode",(function(){return k})),i.d(t,"EnumTextFilterMode",(function(){return G})),i.d(t,"EnumTextResultOrderMode",(function(){return x})),i.d(t,"EnumTextureDetectionMode",(function(){return W})),i.d(t,"EnumLicenseModule",(function(){return H})),i.d(t,"EnumChargeWay",(function(){return K})),function(e){e[e.IPF_Binary=0]="IPF_Binary",e[e.IPF_BinaryInverted=1]="IPF_BinaryInverted",e[e.IPF_GrayScaled=2]="IPF_GrayScaled",e[e.IPF_NV21=3]="IPF_NV21",e[e.IPF_RGB_565=4]="IPF_RGB_565",e[e.IPF_RGB_555=5]="IPF_RGB_555",e[e.IPF_RGB_888=6]="IPF_RGB_888",e[e.IPF_ARGB_8888=7]="IPF_ARGB_8888",e[e.IPF_RGB_161616=8]="IPF_RGB_161616",e[e.IPF_ARGB_16161616=9]="IPF_ARGB_16161616",e[e.IPF_ABGR_8888=10]="IPF_ABGR_8888",e[e.IPF_ABGR_16161616=11]="IPF_ABGR_16161616",e[e.IPF_BGR_888=12]="IPF_BGR_888"}(n||(n={})),function(e){e[e.DBR_SYSTEM_EXCEPTION=1]="DBR_SYSTEM_EXCEPTION",e[e.DBR_SUCCESS=0]="DBR_SUCCESS",e[e.DBR_UNKNOWN=-1e4]="DBR_UNKNOWN",e[e.DBR_NO_MEMORY=-10001]="DBR_NO_MEMORY",e[e.DBR_NULL_REFERENCE=-10002]="DBR_NULL_REFERENCE",e[e.DBR_LICENSE_INVALID=-10003]="DBR_LICENSE_INVALID",e[e.DBR_LICENSE_EXPIRED=-10004]="DBR_LICENSE_EXPIRED",e[e.DBR_FILE_NOT_FOUND=-10005]="DBR_FILE_NOT_FOUND",e[e.DBR_FILETYPE_NOT_SUPPORTED=-10006]="DBR_FILETYPE_NOT_SUPPORTED",e[e.DBR_BPP_NOT_SUPPORTED=-10007]="DBR_BPP_NOT_SUPPORTED",e[e.DBR_INDEX_INVALID=-10008]="DBR_INDEX_INVALID",e[e.DBR_BARCODE_FORMAT_INVALID=-10009]="DBR_BARCODE_FORMAT_INVALID",e[e.DBR_CUSTOM_REGION_INVALID=-10010]="DBR_CUSTOM_REGION_INVALID",e[e.DBR_MAX_BARCODE_NUMBER_INVALID=-10011]="DBR_MAX_BARCODE_NUMBER_INVALID",e[e.DBR_IMAGE_READ_FAILED=-10012]="DBR_IMAGE_READ_FAILED",e[e.DBR_TIFF_READ_FAILED=-10013]="DBR_TIFF_READ_FAILED",e[e.DBR_QR_LICENSE_INVALID=-10016]="DBR_QR_LICENSE_INVALID",e[e.DBR_1D_LICENSE_INVALID=-10017]="DBR_1D_LICENSE_INVALID",e[e.DBR_DIB_BUFFER_INVALID=-10018]="DBR_DIB_BUFFER_INVALID",e[e.DBR_PDF417_LICENSE_INVALID=-10019]="DBR_PDF417_LICENSE_INVALID",e[e.DBR_DATAMATRIX_LICENSE_INVALID=-10020]="DBR_DATAMATRIX_LICENSE_INVALID",e[e.DBR_PDF_READ_FAILED=-10021]="DBR_PDF_READ_FAILED",e[e.DBR_PDF_DLL_MISSING=-10022]="DBR_PDF_DLL_MISSING",e[e.DBR_PAGE_NUMBER_INVALID=-10023]="DBR_PAGE_NUMBER_INVALID",e[e.DBR_CUSTOM_SIZE_INVALID=-10024]="DBR_CUSTOM_SIZE_INVALID",e[e.DBR_CUSTOM_MODULESIZE_INVALID=-10025]="DBR_CUSTOM_MODULESIZE_INVALID",e[e.DBR_RECOGNITION_TIMEOUT=-10026]="DBR_RECOGNITION_TIMEOUT",e[e.DBR_JSON_PARSE_FAILED=-10030]="DBR_JSON_PARSE_FAILED",e[e.DBR_JSON_TYPE_INVALID=-10031]="DBR_JSON_TYPE_INVALID",e[e.DBR_JSON_KEY_INVALID=-10032]="DBR_JSON_KEY_INVALID",e[e.DBR_JSON_VALUE_INVALID=-10033]="DBR_JSON_VALUE_INVALID",e[e.DBR_JSON_NAME_KEY_MISSING=-10034]="DBR_JSON_NAME_KEY_MISSING",e[e.DBR_JSON_NAME_VALUE_DUPLICATED=-10035]="DBR_JSON_NAME_VALUE_DUPLICATED",e[e.DBR_TEMPLATE_NAME_INVALID=-10036]="DBR_TEMPLATE_NAME_INVALID",e[e.DBR_JSON_NAME_REFERENCE_INVALID=-10037]="DBR_JSON_NAME_REFERENCE_INVALID",e[e.DBR_PARAMETER_VALUE_INVALID=-10038]="DBR_PARAMETER_VALUE_INVALID",e[e.DBR_DOMAIN_NOT_MATCHED=-10039]="DBR_DOMAIN_NOT_MATCHED",e[e.DBR_RESERVEDINFO_NOT_MATCHED=-10040]="DBR_RESERVEDINFO_NOT_MATCHED",e[e.DBR_AZTEC_LICENSE_INVALID=-10041]="DBR_AZTEC_LICENSE_INVALID",e[e.DBR_LICENSE_DLL_MISSING=-10042]="DBR_LICENSE_DLL_MISSING",e[e.DBR_LICENSEKEY_NOT_MATCHED=-10043]="DBR_LICENSEKEY_NOT_MATCHED",e[e.DBR_REQUESTED_FAILED=-10044]="DBR_REQUESTED_FAILED",e[e.DBR_LICENSE_INIT_FAILED=-10045]="DBR_LICENSE_INIT_FAILED",e[e.DBR_PATCHCODE_LICENSE_INVALID=-10046]="DBR_PATCHCODE_LICENSE_INVALID",e[e.DBR_POSTALCODE_LICENSE_INVALID=-10047]="DBR_POSTALCODE_LICENSE_INVALID",e[e.DBR_DPM_LICENSE_INVALID=-10048]="DBR_DPM_LICENSE_INVALID",e[e.DBR_FRAME_DECODING_THREAD_EXISTS=-10049]="DBR_FRAME_DECODING_THREAD_EXISTS",e[e.DBR_STOP_DECODING_THREAD_FAILED=-10050]="DBR_STOP_DECODING_THREAD_FAILED",e[e.DBR_SET_MODE_ARGUMENT_ERROR=-10051]="DBR_SET_MODE_ARGUMENT_ERROR",e[e.DBR_LICENSE_CONTENT_INVALID=-10052]="DBR_LICENSE_CONTENT_INVALID",e[e.DBR_LICENSE_KEY_INVALID=-10053]="DBR_LICENSE_KEY_INVALID",e[e.DBR_LICENSE_DEVICE_RUNS_OUT=-10054]="DBR_LICENSE_DEVICE_RUNS_OUT",e[e.DBR_GET_MODE_ARGUMENT_ERROR=-10055]="DBR_GET_MODE_ARGUMENT_ERROR",e[e.DBR_IRT_LICENSE_INVALID=-10056]="DBR_IRT_LICENSE_INVALID",e[e.DBR_MAXICODE_LICENSE_INVALID=-10057]="DBR_MAXICODE_LICENSE_INVALID",e[e.DBR_GS1_DATABAR_LICENSE_INVALID=-10058]="DBR_GS1_DATABAR_LICENSE_INVALID",e[e.DBR_GS1_COMPOSITE_LICENSE_INVALID=-10059]="DBR_GS1_COMPOSITE_LICENSE_INVALID",e[e.DBR_DOTCODE_LICENSE_INVALID=-10061]="DBR_DOTCODE_LICENSE_INVALID",e[e.DMERR_NO_LICENSE=-2e4]="DMERR_NO_LICENSE",e[e.DMERR_LICENSE_SYNC_FAILED=-20003]="DMERR_LICENSE_SYNC_FAILED",e[e.DMERR_TRIAL_LICENSE=-20010]="DMERR_TRIAL_LICENSE",e[e.DMERR_FAILED_TO_REACH_LTS=-20200]="DMERR_FAILED_TO_REACH_LTS"}(r||(r={})),function(e){e[e.IMRDT_IMAGE=1]="IMRDT_IMAGE",e[e.IMRDT_CONTOUR=2]="IMRDT_CONTOUR",e[e.IMRDT_LINESEGMENT=4]="IMRDT_LINESEGMENT",e[e.IMRDT_LOCALIZATIONRESULT=8]="IMRDT_LOCALIZATIONRESULT",e[e.IMRDT_REGIONOFINTEREST=16]="IMRDT_REGIONOFINTEREST",e[e.IMRDT_QUADRILATERAL=32]="IMRDT_QUADRILATERAL"}(o||(o={})),function(e){e[e.BF_ALL=-31457281]="BF_ALL",e[e.BF_ONED=1050623]="BF_ONED",e[e.BF_GS1_DATABAR=260096]="BF_GS1_DATABAR",e[e.BF_CODE_39=1]="BF_CODE_39",e[e.BF_CODE_128=2]="BF_CODE_128",e[e.BF_CODE_93=4]="BF_CODE_93",e[e.BF_CODABAR=8]="BF_CODABAR",e[e.BF_ITF=16]="BF_ITF",e[e.BF_EAN_13=32]="BF_EAN_13",e[e.BF_EAN_8=64]="BF_EAN_8",e[e.BF_UPC_A=128]="BF_UPC_A",e[e.BF_UPC_E=256]="BF_UPC_E",e[e.BF_INDUSTRIAL_25=512]="BF_INDUSTRIAL_25",e[e.BF_CODE_39_EXTENDED=1024]="BF_CODE_39_EXTENDED",e[e.BF_GS1_DATABAR_OMNIDIRECTIONAL=2048]="BF_GS1_DATABAR_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_TRUNCATED=4096]="BF_GS1_DATABAR_TRUNCATED",e[e.BF_GS1_DATABAR_STACKED=8192]="BF_GS1_DATABAR_STACKED",e[e.BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL=16384]="BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_EXPANDED=32768]="BF_GS1_DATABAR_EXPANDED",e[e.BF_GS1_DATABAR_EXPANDED_STACKED=65536]="BF_GS1_DATABAR_EXPANDED_STACKED",e[e.BF_GS1_DATABAR_LIMITED=131072]="BF_GS1_DATABAR_LIMITED",e[e.BF_PATCHCODE=262144]="BF_PATCHCODE",e[e.BF_PDF417=33554432]="BF_PDF417",e[e.BF_QR_CODE=67108864]="BF_QR_CODE",e[e.BF_DATAMATRIX=134217728]="BF_DATAMATRIX",e[e.BF_AZTEC=268435456]="BF_AZTEC",e[e.BF_MAXICODE=536870912]="BF_MAXICODE",e[e.BF_MICRO_QR=1073741824]="BF_MICRO_QR",e[e.BF_MICRO_PDF417=524288]="BF_MICRO_PDF417",e[e.BF_GS1_COMPOSITE=-2147483648]="BF_GS1_COMPOSITE",e[e.BF_MSI_CODE=1048576]="BF_MSI_CODE",e[e.BF_NULL=0]="BF_NULL"}(s||(s={}));var a=function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{_(n.next(e))}catch(e){o(e)}}function a(e){try{_(n.throw(e))}catch(e){o(e)}}function _(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}_((n=n.apply(e,t||[])).next())}))};const _=!!("object"==typeof global&&global.process&&global.process.release&&global.process.release.name&&"undefined"==typeof HTMLCanvasElement),d=!_&&"undefined"==typeof self,l=_?global:d?{}:self;class c{constructor(){this._canvasMaxWH="iPhone"==c.browserInfo.OS||"Android"==c.browserInfo.OS?2048:4096,this._instanceID=void 0,this.bSaveOriCanvas=!1,this.oriCanvas=null,this.maxVideoCvsLength=3,this.videoCvses=[],this.videoGlCvs=null,this.videoGl=null,this.glImgData=null,this.bFilterRegionInJs=!0,this._region=null,this._timeStartDecode=null,this._timeEnterInnerDBR=null,this._bUseWebgl=!0,this.decodeRecords=[],this.bDestroyed=!1,this._lastErrorCode=0,this._lastErrorString=""}static get version(){return this._version}static get productKeys(){return this._productKeys}static set productKeys(e){if("unload"!=this._loadWasmStatus)throw new Error("`productKeys` is not allowed to change after loadWasm is called.");c._productKeys=e}static get handshakeCode(){return this._productKeys}static set handshakeCode(e){if("unload"!=this._loadWasmStatus)throw new Error("`handshakeCode` is not allowed to change after loadWasm is called.");c._productKeys=e}static get organizationID(){return this._organizationID}static set organizationID(e){if("unload"!=this._loadWasmStatus)throw new Error("`organizationID` is not allowed to change after loadWasm is called.");c._organizationID=e}static set sessionPassword(e){if("unload"!=this._loadWasmStatus)throw new Error("`sessionPassword` is not allowed to change after loadWasm is called.");c._sessionPassword=e}static get sessionPassword(){return this._sessionPassword}static detectEnvironment(){return a(this,void 0,void 0,(function*(){let e={wasm:"undefined"!=typeof WebAssembly&&("undefined"==typeof navigator||!(/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&/\(.+\s11_2_([2-6]).*\)/.test(navigator.userAgent))),worker:!!(_?process.version>="v12":"undefined"!=typeof Worker),getUserMedia:!("undefined"==typeof navigator||!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia),camera:!1,browser:this.browserInfo.browser,version:this.browserInfo.version,OS:this.browserInfo.OS};if(e.getUserMedia)try{(yield navigator.mediaDevices.getUserMedia({video:!0})).getTracks().forEach(e=>{e.stop()}),e.camera=!0}catch(e){}return e}))}static get engineResourcePath(){return this._engineResourcePath}static set engineResourcePath(e){if("unload"!=this._loadWasmStatus)throw new Error("`engineResourcePath` is not allowed to change after loadWasm is called.");if(null==e&&(e="./"),_||d)c._engineResourcePath=e;else{let t=document.createElement("a");t.href=e,c._engineResourcePath=t.href}this._engineResourcePath.endsWith("/")||(c._engineResourcePath+="/")}static get licenseServer(){return this._licenseServer}static set licenseServer(e){if("unload"!=this._loadWasmStatus)throw new Error("`licenseServer` is not allowed to change after loadWasm is called.");if(null==e)c._licenseServer=[];else{e instanceof Array||(e=[e]);for(let t=0;t= v12.");let e,t=this.productKeys,n=t.startsWith("PUBLIC-TRIAL"),r=n||8==t.length||t.length>8&&!t.startsWith("t")&&!t.startsWith("f")&&!t.startsWith("P")&&!t.startsWith("L")||0==t.length&&0!=this.organizationID.length;if(r&&(_?process.version<"v15"&&(e=new Error("To use handshake requires nodejs version >= v15.")):(l.crypto||(e=new Error("Please upgrade your browser to support handshake code.")),l.crypto.subtle||(e=new Error("Require https to use handshake code in this browser.")))),e){if(!n)throw e;n=!1,r=!1}return n&&(t="",console.warn("Automatically apply for a public trial license.")),yield new Promise((e,n)=>a(this,void 0,void 0,(function*(){switch(this._loadWasmStatus){case"unload":{c._loadWasmStatus="loading";let e=this.engineResourcePath+this._workerName;if(_||this.engineResourcePath.startsWith(location.origin)||(e=yield fetch(e).then(e=>e.blob()).then(e=>URL.createObjectURL(e))),_){const t=i(0);c._dbrWorker=new t.Worker(e)}else c._dbrWorker=new Worker(e);this._dbrWorker.onerror=e=>{c._loadWasmStatus="loadFail";for(let t of this._loadWasmCallbackArr)t(new Error(e.message))},this._dbrWorker.onmessage=e=>a(this,void 0,void 0,(function*(){let t=e.data?e.data:e;switch(t.type){case"log":this._onLog&&this._onLog(t.message);break;case"load":if(t.success){c._loadWasmStatus="loadSuccess",c._version=t.version+"(JS "+this._jsVersion+"."+this._jsEditVersion+")",this._onLog&&this._onLog("load dbr worker success");for(let e of this._loadWasmCallbackArr)e();this._dbrWorker.onerror=null}else{let e=new Error(t.message);e.stack=t.stack+"\n"+e.stack,c._loadWasmStatus="loadFail";for(let t of this._loadWasmCallbackArr)t(e)}break;case"task":{let e=t.id,i=t.body;try{this._taskCallbackMap.get(e)(i),this._taskCallbackMap.delete(e)}catch(t){throw this._taskCallbackMap.delete(e),t}break}default:this._onLog&&this._onLog(e)}})),_&&this._dbrWorker.on("message",this._dbrWorker.onmessage),this._dbrWorker.postMessage({type:"loadWasm",bd:this._bWasmDebug,engineResourcePath:this.engineResourcePath,version:this._jsVersion,brtk:r,pk:t,og:this.organizationID,dm:!_&&location.origin.startsWith("http")?location.origin:"https://localhost",bUseFullFeature:this._bUseFullFeature,browserInfo:this.browserInfo,deviceFriendlyName:this.deviceFriendlyName,ls:this.licenseServer,sp:this._sessionPassword,lm:this._limitModules,cw:this._chargeWay})}case"loading":this._loadWasmCallbackArr.push(t=>{t?n(t):e()});break;case"loadSuccess":e();break;case"loadFail":n()}})))}))}static createInstanceInWorker(e=!1){return a(this,void 0,void 0,(function*(){return yield this.loadWasm(),yield new Promise((t,i)=>{let n=c._nextTaskID++;this._taskCallbackMap.set(n,e=>{if(e.success)return t(e.instanceID);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),this._dbrWorker.postMessage({type:"createInstance",id:n,productKeys:"",bScanner:e})})}))}static createInstance(){return a(this,void 0,void 0,(function*(){let e=new c;return e._instanceID=yield this.createInstanceInWorker(),e}))}decode(e){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("decode(source: any)"),c._onLog&&(this._timeStartDecode=Date.now()),_)return e instanceof Buffer?yield this._decodeFileInMemory_Uint8Array(new Uint8Array(e)):e instanceof Uint8Array?yield this._decodeFileInMemory_Uint8Array(e):"string"==typeof e||e instanceof String?"data:image/"==e.substring(0,11)?yield this._decode_Base64(e):"http"==e.substring(0,4)?yield this._decode_Url(e):yield this._decode_FilePath(e):yield Promise.reject(TypeError("'_decode(source, config)': Type of 'source' should be 'Buffer', 'Uint8Array', 'String(base64 with image mime)' or 'String(url)'."));{let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),e instanceof Blob?yield this._decode_Blob(e,t):e instanceof ArrayBuffer?yield this._decode_ArrayBuffer(e,t):e instanceof Uint8Array||e instanceof Uint8ClampedArray?yield this._decode_Uint8Array(e,t):e instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?yield this._decode_Image(e,t):e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?yield this._decode_Canvas(e,t):e instanceof HTMLVideoElement?yield this._decode_Video(e,t):"string"==typeof e||e instanceof String?"data:image/"==e.substring(0,11)?yield this._decode_Base64(e,t):yield this._decode_Url(e,t):yield Promise.reject(TypeError("'_decode(source, config)': Type of 'source' should be 'Blob', 'ArrayBuffer', 'Uint8Array', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement', 'String(base64 with image mime)' or 'String(url)'."))}}))}decodeBase64String(e){return a(this,void 0,void 0,(function*(){let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),this._decode_Base64(e,t)}))}decodeUrl(e){return a(this,void 0,void 0,(function*(){let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),this._decode_Url(e,t)}))}_decodeBuffer_Uint8Array(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){return yield new Promise((s,a)=>{let _=c._nextTaskID++;c._taskCallbackMap.set(_,e=>{if(e.success){let t,i=c._onLog?Date.now():0;this.bufferShared&&!this.bufferShared.length&&(this.bufferShared=e.buffer);try{t=this._handleRetJsonString(e.decodeReturn)}catch(e){return a(e)}if(c._onLog){let e=Date.now();c._onLog("DBR time get result: "+i),c._onLog("Handle image cost: "+(this._timeEnterInnerDBR-this._timeStartDecode)),c._onLog("DBR worker decode image cost: "+(i-this._timeEnterInnerDBR)),c._onLog("DBR worker handle results: "+(e-i)),c._onLog("Total decode image cost: "+(e-this._timeStartDecode))}return s(t)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,a(t)}}),c._onLog&&(this._timeEnterInnerDBR=Date.now()),c._onLog&&c._onLog("Send buffer to worker:"+Date.now()),c._dbrWorker.postMessage({type:"decodeBuffer",id:_,instanceID:this._instanceID,body:{buffer:e,width:t,height:i,stride:n,format:r,config:o}},[e.buffer])})}))}_decodeBuffer_Blob(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){return c._onLog&&c._onLog("_decodeBuffer_Blob(buffer,width,height,stride,format)"),yield new Promise((t,i)=>{let n=new FileReader;n.readAsArrayBuffer(e),n.onload=()=>{t(n.result)},n.onerror=()=>{i(n.error)}}).then(e=>this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o))}))}decodeBuffer(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){let s;return c._onLog&&c._onLog("decodeBuffer(buffer,width,height,stride,format)"),c._onLog&&(this._timeStartDecode=Date.now()),_?e instanceof Uint8Array?s=yield this._decodeBuffer_Uint8Array(e,t,i,n,r,o):e instanceof Buffer&&(s=yield this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o)):e instanceof Uint8Array||e instanceof Uint8ClampedArray?s=yield this._decodeBuffer_Uint8Array(e,t,i,n,r,o):e instanceof ArrayBuffer?s=yield this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o):e instanceof Blob&&(s=yield this._decodeBuffer_Blob(e,t,i,n,r,o)),s}))}_decodeFileInMemory_Uint8Array(e){return a(this,void 0,void 0,(function*(){return yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success){let n;try{n=this._handleRetJsonString(e.decodeReturn)}catch(e){return i(e)}return t(n)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),c._dbrWorker.postMessage({type:"decodeFileInMemory",id:n,instanceID:this._instanceID,body:{bytes:e}})})}))}getRuntimeSettings(){return a(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success){let t=JSON.parse(i.results);return null!=this.userDefinedRegion&&(t.region=JSON.parse(JSON.stringify(this.userDefinedRegion))),e(t)}{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"getRuntimeSettings",id:i,instanceID:this._instanceID})})}))}updateRuntimeSettings(e){return a(this,void 0,void 0,(function*(){let t;if("string"==typeof e||"object"==typeof e&&e instanceof String)if("speed"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=3,t.expectedBarcodesCount=0,t.localizationModes=[2,0,0,0,0,0,0,0]}else if("balance"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=5,t.expectedBarcodesCount=512,t.localizationModes=[2,16,0,0,0,0,0,0]}else if("coverage"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region}else t=JSON.parse(e);else{if("object"!=typeof e)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");if(t=JSON.parse(JSON.stringify(e)),t.region instanceof Array){let e=t.region;[e.regionLeft,e.regionTop,e.regionLeft,e.regionBottom,e.regionMeasuredByPercentage].some(e=>void 0!==e)&&(t.region={regionLeft:e.regionLeft||0,regionTop:e.regionTop||0,regionRight:e.regionRight||0,regionBottom:e.regionBottom||0,regionMeasuredByPercentage:e.regionMeasuredByPercentage||0})}}if(!c._bUseFullFeature){if(0!=(t.barcodeFormatIds&~(s.BF_ONED|s.BF_QR_CODE|s.BF_PDF417|s.BF_DATAMATRIX))||0!=t.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=t.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}if(!_)if(this.bFilterRegionInJs){let e=t.region;if(e instanceof Array)throw Error("The `region` of type `Array` is only allowed in `BarcodeScanner`.");this.userDefinedRegion=JSON.parse(JSON.stringify(e)),(e.regionLeft||e.regionTop||e.regionRight||e.regionBottom||e.regionMeasuredByPercentage)&&(e.regionLeft||e.regionTop||100!=e.regionRight||100!=e.regionBottom||!e.regionMeasuredByPercentage)?this.region=e:this.region=null,t.region={regionLeft:0,regionTop:0,regionRight:0,regionBottom:0,regionMeasuredByPercentage:0}}else this.userDefinedRegion=null,this.region=null;return yield new Promise((e,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,t=>{if(t.success){try{this._handleRetJsonString(t.updateReturn)}catch(e){i(e)}return e()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}}),c._dbrWorker.postMessage({type:"updateRuntimeSettings",id:n,instanceID:this._instanceID,body:{settings:JSON.stringify(t)}})})}))}resetRuntimeSettings(){return a(this,void 0,void 0,(function*(){return this.userDefinedRegion=null,this.region=null,yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"resetRuntimeSettings",id:i,instanceID:this._instanceID})})}))}outputSettingsToString(){return a(this,void 0,void 0,(function*(){if(!c._bUseFullFeature)throw Error("outputSettingsToString() is not supported in the compact version. Please try the full-featured version.");return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e(i.results);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"outputSettingsToString",id:i,instanceID:this._instanceID})})}))}initRuntimeSettingsWithString(e){return a(this,void 0,void 0,(function*(){if(!c._bUseFullFeature)throw Error("initRuntimeSettingsWithString() is not supported in the compact version. Please try the full-featured version.");if("string"==typeof e||"object"==typeof e&&e instanceof String)e=e;else{if("object"!=typeof e)throw TypeError("'initRuntimeSettingstWithString(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");e=JSON.stringify(e)}return yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success){try{this._handleRetJsonString(e.initReturn)}catch(e){i(e)}return t()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),c._dbrWorker.postMessage({type:"initRuntimeSettingsWithString",id:n,instanceID:this._instanceID,body:{settings:e}})})}))}_decode_Blob(e,t){return a(this,void 0,void 0,(function*(){c._onLog&&c._onLog("_decode_Blob(blob: Blob)");let i=null,n=null;if("undefined"!=typeof createImageBitmap)try{i=yield createImageBitmap(e)}catch(e){}i||(n=yield function(e){return new Promise((t,i)=>{let n=URL.createObjectURL(e),r=new Image;r.dbrObjUrl=n,r.src=n,r.onload=()=>{t(r)},r.onerror=e=>{i(new Error("Can't convert blob to image : "+(e instanceof Event?e.type:e)))}})}(e));let r=yield this._decode_Image(i||n,t);return i&&i.close(),r}))}_decode_ArrayBuffer(e,t){return a(this,void 0,void 0,(function*(){return yield this._decode_Blob(new Blob([e]),t)}))}_decode_Uint8Array(e,t){return a(this,void 0,void 0,(function*(){return yield this._decode_Blob(new Blob([e]),t)}))}_decode_Image(e,t){return a(this,void 0,void 0,(function*(){c._onLog&&c._onLog("_decode_Image(image: HTMLImageElement|ImageBitmap)"),t=t||{};let i,n,r=e instanceof HTMLImageElement?e.naturalWidth:e.width,o=e instanceof HTMLImageElement?e.naturalHeight:e.height,s=Math.max(r,o);if(s>this._canvasMaxWH){let e=this._canvasMaxWH/s;i=Math.round(r*e),n=Math.round(o*e)}else i=r,n=o;let a,_=0,d=0,h=r,u=o,g=r,E=o,R=t.region;if(R){let e,t,s,a;R.regionMeasuredByPercentage?(e=R.regionLeft*i/100,t=R.regionTop*n/100,s=R.regionRight*i/100,a=R.regionBottom*n/100):(e=R.regionLeft,t=R.regionTop,s=R.regionRight,a=R.regionBottom),g=s-e,h=Math.round(g/i*r),E=a-t,u=Math.round(E/n*o),_=Math.round(e/i*r),d=Math.round(t/n*o)}!this.bSaveOriCanvas&&l.OffscreenCanvas?a=new OffscreenCanvas(g,E):(a=document.createElement("canvas"),a.width=g,a.height=E);let I,A=a.getContext("2d");0==_&&0==d&&r==h&&o==u&&r==g&&o==E?A.drawImage(e,0,0):A.drawImage(e,_,d,h,u,0,0,g,E),e.dbrObjUrl&&URL.revokeObjectURL(e.dbrObjUrl),R?(I=JSON.parse(JSON.stringify(t)),delete I.region):I=t;let f=yield this._decode_Canvas(a,I);return c.fixResultLocationWhenFilterRegionInJs(R,f,_,d,h,u,g,E),f}))}_decode_Canvas(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Canvas(canvas:HTMLCanvasElement)"),e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";(this.bSaveOriCanvas||this.singleFrameMode)&&(this.oriCanvas=e);let i=(e.dbrCtx2d||e.getContext("2d")).getImageData(0,0,e.width,e.height).data;return yield this._decodeBuffer_Uint8Array(i,e.width,e.height,4*e.width,n.IPF_ABGR_8888,t)}))}_decode_Video(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Video(video)"),!(e instanceof HTMLVideoElement))throw TypeError("'_decode_Video(video [, config] )': Type of 'video' should be 'HTMLVideoElement'.");if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";t=t||{};let i,r,o=e.videoWidth,s=e.videoHeight,a=Math.max(o,s);if(a>this._canvasMaxWH){let e=this._canvasMaxWH/a;i=Math.round(o*e),r=Math.round(s*e)}else i=o,r=s;let _=0,d=0,h=o,u=s,g=o,E=s,R=t.region;if(R){let e,t,n,a;R.regionMeasuredByPercentage?(e=R.regionLeft*i/100,t=R.regionTop*r/100,n=R.regionRight*i/100,a=R.regionBottom*r/100):(e=R.regionLeft,t=R.regionTop,n=R.regionRight,a=R.regionBottom),g=n-e,h=Math.round(g/i*o),E=a-t,u=Math.round(E/r*s),_=Math.round(e/i*o),d=Math.round(t/r*s)}let I=0==_&&0==d&&o==h&&s==u&&o==g&&s==E;if(!this.bSaveOriCanvas&&this._bUseWebgl&&I){this.videoGlCvs||(this.videoGlCvs=l.OffscreenCanvas?new OffscreenCanvas(g,E):document.createElement("canvas"));const t=this.videoGlCvs;t.width==g&&t.height==E||(t.height=E,t.width=g,this.videoGl&&this.videoGl.viewport(0,0,g,E));const i=this.videoGl||t.getContext("webgl",{alpha:!1,antialias:!1})||t.getContext("experimental-webgl",{alpha:!1,antialias:!1});if(!this.videoGl){this.videoGl=i;let e=i.createShader(i.VERTEX_SHADER);i.shaderSource(e,"\nattribute vec4 a_position;\nattribute vec2 a_uv;\n\nvarying vec2 v_uv;\n\nvoid main() {\n gl_Position = a_position;\n v_uv = a_uv;\n}\n"),i.compileShader(e),i.getShaderParameter(e,i.COMPILE_STATUS)||console.error("An error occurred compiling the shaders: "+i.getShaderInfoLog(e));let t=i.createShader(i.FRAGMENT_SHADER);i.shaderSource(t,"\nprecision lowp float;\n\nvarying vec2 v_uv;\n\nuniform sampler2D u_texture;\n\nvoid main() {\n vec4 sample = texture2D(u_texture, v_uv);\n float grey = 0.299 * sample.r + 0.587 * sample.g + 0.114 * sample.b;\n gl_FragColor = vec4(grey, 0.0, 0.0, 1.0);\n}\n"),i.compileShader(t),i.getShaderParameter(t,i.COMPILE_STATUS)||console.error("An error occurred compiling the shaders: "+i.getShaderInfoLog(t));let n=i.createProgram();i.attachShader(n,e),i.attachShader(n,t),i.linkProgram(n),i.getProgramParameter(n,i.LINK_STATUS)||console.error("Unable to initialize the shader program: "+i.getProgramInfoLog(n)),i.useProgram(n),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,1,0,1,1,1,1,1,-1,-1,0,0,1,-1,1,0]),i.STATIC_DRAW);let r=i.getAttribLocation(n,"a_position");i.enableVertexAttribArray(r),i.vertexAttribPointer(r,2,i.FLOAT,!1,16,0);let o=i.getAttribLocation(n,"a_uv");i.enableVertexAttribArray(o),i.vertexAttribPointer(o,2,i.FLOAT,!1,16,8),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,i.createTexture()),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.uniform1i(i.getUniformLocation(n,"u_texture"),0)}(!this.glImgData||this.glImgData.length=this.maxVideoCvsLength&&(this.videoCvses=this.videoCvses.slice(1)),this.videoCvses.push(i));const n=i.dbrCtx2d;let r;I?n.drawImage(e,0,0):n.drawImage(e,_,d,h,u,0,0,g,E),R?(r=JSON.parse(JSON.stringify(t)),delete r.region):r=t;let o=yield this._decode_Canvas(i,r);return c.fixResultLocationWhenFilterRegionInJs(R,o,_,d,h,u,g,E),o}}))}_decode_Base64(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Base64(base64Str)"),"string"!=typeof e&&"object"!=typeof e)return Promise.reject("'_decode_Base64(base64Str, config)': Type of 'base64Str' should be 'String'.");if("data:image/"==e.substring(0,11)&&(e=e.substring(e.indexOf(",")+1)),_){let t=Buffer.from(e,"base64");return yield this._decodeFileInMemory_Uint8Array(new Uint8Array(t))}{let i=atob(e),n=i.length,r=new Uint8Array(n);for(;n--;)r[n]=i.charCodeAt(n);return yield this._decode_Blob(new Blob([r]),t)}}))}_decode_Url(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Url(url)"),"string"!=typeof e&&"object"!=typeof e)throw TypeError("'_decode_Url(url, config)': Type of 'url' should be 'String'.");if(_){let t=yield new Promise((t,n)=>{(e.startsWith("https")?i(1):i(2)).get(e,e=>{if(200==e.statusCode){let i=[];e.on("data",e=>{i.push(e)}).on("end",()=>{t(new Uint8Array(Buffer.concat(i)))})}else n("http get fail, statusCode: "+e.statusCode)})});return yield this._decodeFileInMemory_Uint8Array(t)}{let i=yield new Promise((t,i)=>{let n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="blob",n.send(),n.onloadend=()=>a(this,void 0,void 0,(function*(){t(n.response)})),n.onerror=()=>{i(new Error("Network Error: "+n.statusText))}});return yield this._decode_Blob(i,t)}}))}_decode_FilePath(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_FilePath(path)"),!_)throw Error("'_decode_FilePath(path, config)': The method is only supported in node environment.");if("string"!=typeof e&&"object"!=typeof e)throw TypeError("'_decode_FilePath(path, config)': Type of 'path' should be 'String'.");const t=i(3);let n=yield new Promise((i,n)=>{t.readFile(e,(e,t)=>{e?n(e):i(new Uint8Array(t))})});return yield this._decodeFileInMemory_Uint8Array(n)}))}static fixResultLocationWhenFilterRegionInJs(e,t,i,n,r,o,s,a){if(e&&t.length>0)for(let e of t){let t=e.localizationResult;2==t.resultCoordinateType&&(t.x1*=.01*s,t.x2*=.01*s,t.x3*=.01*s,t.x4*=.01*s,t.y1*=.01*a,t.y2*=.01*a,t.y3*=.01*a,t.y4*=.01*a),t.x1+=i,t.x2+=i,t.x3+=i,t.x4+=i,t.y1+=n,t.y2+=n,t.y3+=n,t.y4+=n,2==t.resultCoordinateType&&(t.x1*=100/r,t.x2*=100/r,t.x3*=100/r,t.x4*=100/r,t.y1*=100/o,t.y2*=100/o,t.y3*=100/o,t.y4*=100/o)}}static BarcodeReaderException(e,t){let i,n=r.DBR_UNKNOWN;return"number"==typeof e?(n=e,i=new Error(t)):i=new Error(e),i.code=n,i}_handleRetJsonString(e){let t=r;if(e.textResults){for(let t=0;t{let i=t.indexOf(":");e[t.substring(0,i)]=t.substring(i+1)}),i.exception=e}}return e.decodeRecords&&(this.decodeRecords=e.decodeRecords),this._lastErrorCode=e.exception,this._lastErrorString=e.description,e.textResults}if(e.exception==t.DBR_SUCCESS)return e.data;throw c.BarcodeReaderException(e.exception,e.description)}setModeArgument(e,t,i,n){return a(this,void 0,void 0,(function*(){return yield new Promise((r,o)=>{let s=c._nextTaskID++;c._taskCallbackMap.set(s,e=>{if(e.success){try{this._handleRetJsonString(e.setReturn)}catch(e){return o(e)}return r()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}}),c._dbrWorker.postMessage({type:"setModeArgument",id:s,instanceID:this._instanceID,body:{modeName:e,index:t,argumentName:i,argumentValue:n}})})}))}getModeArgument(e,t,i){return a(this,void 0,void 0,(function*(){return yield new Promise((n,r)=>{let o=c._nextTaskID++;c._taskCallbackMap.set(o,e=>{if(e.success){let t;try{t=this._handleRetJsonString(e.getReturn)}catch(e){return r(e)}return n(t)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,r(t)}}),c._dbrWorker.postMessage({type:"getModeArgument",id:o,instanceID:this._instanceID,body:{modeName:e,index:t,argumentName:i}})})}))}getIntermediateResults(){return a(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e(i.results);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"getIntermediateResults",id:i,instanceID:this._instanceID})})}))}getIntermediateCanvas(){return a(this,void 0,void 0,(function*(){let e=yield this.getIntermediateResults(),t=[];for(let i of e)if(i.dataType==o.IMRDT_IMAGE)for(let e of i.results){const i=e.bytes;let r;switch(c._onLog&&c._onLog(" "+i.length+" "+i.byteLength+" "+e.width+" "+e.height+" "+e.stride+" "+e.format),e.format){case n.IPF_ABGR_8888:r=new Uint8ClampedArray(i);break;case n.IPF_RGB_888:{const e=i.length/3;r=new Uint8ClampedArray(4*e);for(let t=0;t{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"destroy",id:i,instanceID:this._instanceID})})}}c.bNode=_,c._jsVersion="8.2.3",c._jsEditVersion="20210413",c._version="loading...(JS "+c._jsVersion+"."+c._jsEditVersion+")",c._productKeys=_||d||!document.currentScript?"":document.currentScript.getAttribute("data-productKeys")||document.currentScript.getAttribute("data-licenseKey")||document.currentScript.getAttribute("data-handshakeCode")||"",c._organizationID=_||d||!document.currentScript?"":document.currentScript.getAttribute("data-organizationID")||"",c.browserInfo=function(){if(!_&&!d){var e={init:function(){this.browser=this.searchString(this.dataBrowser)||"unknownBrowser",this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"unknownVersion",this.OS=this.searchString(this.dataOS)||"unknownOS"},searchString:function(e){for(var t=0;t{if(_)return __dirname+"/";if(!d&&document.currentScript){let e=document.currentScript.src,t=e.indexOf("?");if(-1!=t)e=e.substring(0,t);else{let t=e.indexOf("#");-1!=t&&(e=e.substring(0,t))}return e.substring(0,e.lastIndexOf("/")+1)}return"./"})(),c._licenseServer=[],c._deviceFriendlyName="",c._isShowRelDecodeTimeInResults=!1,c._bWasmDebug=!1,c._bSendSmallRecordsForDebug=!1,c.__bUseFullFeature=_,c._nextTaskID=0,c._taskCallbackMap=new Map,c._loadWasmStatus="unload",c._loadWasmCallbackArr=[],c._lastErrorCode=0,c._lastErrorString="";var h=function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{_(n.next(e))}catch(e){o(e)}}function a(e){try{_(n.throw(e))}catch(e){o(e)}}function _(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}_((n=n.apply(e,t||[])).next())}))};const u=!!("object"==typeof global&&global.process&&global.process.release&&global.process.release.name&&"undefined"==typeof HTMLCanvasElement);class g extends c{constructor(){super(),this.styleEls=[],this.videoSettings={video:{width:{ideal:1280},height:{ideal:720},facingMode:{ideal:"environment"}}},this._singleFrameMode=!(navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),this._singleFrameModeIpt=(()=>{let e=document.createElement("input");return e.setAttribute("type","file"),e.setAttribute("accept","image/*"),e.setAttribute("capture",""),e.addEventListener("change",()=>h(this,void 0,void 0,(function*(){let t=e.files[0];e.value="";let i=yield this.decode(t);for(let e of i)delete e.bUnduplicated;if(this._drawRegionsults(i),this.onFrameRead&&this._isOpen&&!this._bPauseScan&&this.onFrameRead(i),this.onUnduplicatedRead&&this._isOpen&&!this._bPauseScan)for(let e of i)this.onUnduplicatedRead(e.barcodeText,e);yield this.clearMapDecodeRecord()}))),e})(),this._clickIptSingleFrameMode=()=>{this._singleFrameModeIpt.click()},this.intervalTime=0,this._isOpen=!1,this._bPauseScan=!1,this._lastDeviceId=void 0,this._intervalDetectVideoPause=1e3,this._vc_bPlayingVideoBeforeHide=!1,this._ev_documentHideEvent=()=>{"visible"===document.visibilityState?this._vc_bPlayingVideoBeforeHide&&("Firefox"==c.browserInfo.browser?this.play():this._video.play(),this._vc_bPlayingVideoBeforeHide=!1):this._video&&!this._video.paused&&(this._vc_bPlayingVideoBeforeHide=!0,this._video.pause())},this._video=null,this._cvsDrawArea=null,this._divScanArea=null,this._divScanLight=null,this._bgLoading=null,this._bgCamera=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._soundOnSuccessfullRead=new Audio("data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA/+M4wAAAAAAAAAAAAEluZm8AAAAPAAAABQAAAkAAgICAgICAgICAgICAgICAgICAgKCgoKCgoKCgoKCgoKCgoKCgoKCgwMDAwMDAwMDAwMDAwMDAwMDAwMDg4ODg4ODg4ODg4ODg4ODg4ODg4P//////////////////////////AAAAAExhdmM1OC41NAAAAAAAAAAAAAAAACQEUQAAAAAAAAJAk0uXRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+MYxAANQAbGeUEQAAHZYZ3fASqD4P5TKBgocg+Bw/8+CAYBA4XB9/4EBAEP4nB9+UOf/6gfUCAIKyjgQ/Kf//wfswAAAwQA/+MYxAYOqrbdkZGQAMA7DJLCsQxNOij///////////+tv///3RWiZGBEhsf/FO/+LoCSFs1dFVS/g8f/4Mhv0nhqAieHleLy/+MYxAYOOrbMAY2gABf/////////////////usPJ66R0wI4boY9/8jQYg//g2SPx1M0N3Z0kVJLIs///Uw4aMyvHJJYmPBYG/+MYxAgPMALBucAQAoGgaBoFQVBUFQWDv6gZBUFQVBUGgaBr5YSgqCoKhIGg7+IQVBUFQVBoGga//SsFSoKnf/iVTEFNRTMu/+MYxAYAAANIAAAAADEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"),this.bPlaySoundOnSuccessfulRead=!1,this.bVibrateOnSuccessfulRead=!1,this.vibrateDuration=300,this._allCameras=[],this._currentCamera=null,this._videoTrack=null,this.regionMaskFillStyle="rgba(0,0,0,0.5)",this.regionMaskStrokeStyle="rgb(254,142,20)",this.regionMaskLineWidth=2,this.barcodeFillStyle="rgba(254,180,32,0.3)",this.barcodeStrokeStyle="rgba(254,180,32,0.9)",this.barcodeLineWidth=1,this.beingLazyDrawRegionsults=!1,this._indexVideoRegion=-1,this._onCameraSelChange=()=>{this.play(this._selCam.value).then(()=>{this._isOpen||this.stop()}).catch(e=>{alert("Play video failed: "+(e.message||e))})},this._onResolutionSelChange=()=>{let e,t;if(this._selRsl&&-1!=this._selRsl.selectedIndex){let i=this._selRsl.options[this._selRsl.selectedIndex];e=i.getAttribute("data-width"),t=i.getAttribute("data-height")}this.play(void 0,e,t).then(()=>{this._isOpen||this.stop()}).catch(e=>{alert("Play video failed: "+(e.message||e))})},this._onCloseBtnClick=()=>{this.hide()}}static get defaultUIElementURL(){return this._defaultUIElementURL?this._defaultUIElementURL:c.engineResourcePath+"dbr.scanner.html"}static set defaultUIElementURL(e){this._defaultUIElementURL=e}getUIElement(){return this.UIElement}setUIElement(e){return h(this,void 0,void 0,(function*(){if("string"==typeof e||e instanceof String){if(!e.trim().startsWith("<")){let t=yield fetch(e);if(!t.ok)throw Error("Network Error: "+t.statusText);e=yield t.text()}if(!e.trim().startsWith("<"))throw Error("setUIElement(elementOrUrl): Can't get valid HTMLElement.");let t=document.createElement("div");t.innerHTML=e;for(let e=0;e{h(this,void 0,void 0,(function*(){let e=yield this.getScanSettings();e.oneDTrustFrameCount=1,yield this.updateScanSettings(e)}))})()}_assertOpen(){if(!this._isOpen)throw Error("The scanner is not open.")}get soundOnSuccessfullRead(){return this._soundOnSuccessfullRead}set soundOnSuccessfullRead(e){e instanceof HTMLAudioElement?this._soundOnSuccessfullRead=e:this._soundOnSuccessfullRead=new Audio(e)}set region(e){this._region=e,this.singleFrameMode||(this.beingLazyDrawRegionsults=!0,setTimeout(()=>{this.beingLazyDrawRegionsults&&this._drawRegionsults()},500))}get region(){return this._region}static createInstance(e){return h(this,void 0,void 0,(function*(){if(u)throw new Error("`BarcodeScanner` is not supported in Node.js.");let t=new g;t._instanceID=yield g.createInstanceInWorker(!0),("string"==typeof e||e instanceof String)&&(e=JSON.parse(e));for(let i in e)t[i]=e[i];return t.UIElement||(yield t.setUIElement(this.defaultUIElementURL)),t.singleFrameMode||(yield t.updateRuntimeSettings("single")),document.addEventListener("visibilitychange",t._ev_documentHideEvent),t}))}decode(e){return super.decode(e)}decodeBase64String(e){return super.decodeBase64String(e)}decodeUrl(e){return super.decodeUrl(e)}decodeBuffer(e,t,i,n,r,o){return super.decodeBuffer(e,t,i,n,r,o)}decodeCurrentFrame(){return h(this,void 0,void 0,(function*(){this._assertOpen();let e={};if(this.region)if(this.region instanceof Array){++this._indexVideoRegion>=this.region.length&&(this._indexVideoRegion=0);let t=this.region[this._indexVideoRegion];t&&(e.region=JSON.parse(JSON.stringify(t)))}else e.region=JSON.parse(JSON.stringify(this.region));return this._decode_Video(this._video,e)}))}clearMapDecodeRecord(){return h(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"clearMapDecodeRecord",id:i,instanceID:this._instanceID})})}))}static isRegionSinglePreset(e){return JSON.stringify(e)==JSON.stringify(this.singlePresetRegion)}static isRegionNormalPreset(e){return 0==e.regionLeft&&0==e.regionTop&&0==e.regionRight&&0==e.regionBottom&&0==e.regionMeasuredByPercentage}updateRuntimeSettings(e){return h(this,void 0,void 0,(function*(){let t;if("string"==typeof e||"object"==typeof e&&e instanceof String)if("speed"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region)}else if("balance"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region),t.deblurLevel=3,t.expectedBarcodesCount=512,t.localizationModes=[2,16,0,0,0,0,0,0],t.timeout=1e5}else if("coverage"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region),t.deblurLevel=5,t.expectedBarcodesCount=512,t.scaleDownThreshold=1e5,t.localizationModes=[2,16,4,8,0,0,0,0],t.timeout=1e5}else if("single"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionNormalPreset(e.region)?t.region=JSON.parse(JSON.stringify(g.singlePresetRegion)):t.region=e.region,t.expectedBarcodesCount=1,t.localizationModes=[16,2,0,0,0,0,0,0],t.barcodeZoneMinDistanceToImageBorders=0}else t=JSON.parse(e);else{if("object"!=typeof e)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");if(t=JSON.parse(JSON.stringify(e)),t.region instanceof Array){let i=e.region;[i.regionLeft,i.regionTop,i.regionLeft,i.regionBottom,i.regionMeasuredByPercentage].some(e=>void 0!==e)&&(t.region={regionLeft:i.regionLeft||0,regionTop:i.regionTop||0,regionRight:i.regionRight||0,regionBottom:i.regionBottom||0,regionMeasuredByPercentage:i.regionMeasuredByPercentage||0})}}if(!c._bUseFullFeature){if(0!=(t.barcodeFormatIds&~(s.BF_ONED|s.BF_QR_CODE|s.BF_PDF417|s.BF_DATAMATRIX))||0!=t.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=t.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}{let e=t.region;if(this.bFilterRegionInJs?this.userDefinedRegion=JSON.parse(JSON.stringify(e)):this.userDefinedRegion=null,e instanceof Array)if(e.length){for(let t=0;t{let n=c._nextTaskID++;c._taskCallbackMap.set(n,t=>{if(t.success){try{this._handleRetJsonString(t.updateReturn)}catch(e){i(e)}return e()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}}),c._dbrWorker.postMessage({type:"updateRuntimeSettings",id:n,instanceID:this._instanceID,body:{settings:JSON.stringify(t)}})}),"single"==e&&(yield this.setModeArgument("BinarizationModes",0,"EnableFillBinaryVacancy","0"),yield this.setModeArgument("LocalizationModes",0,"ScanDirection","2"),yield this.setModeArgument("BinarizationModes",0,"BlockSizeX","71"),yield this.setModeArgument("BinarizationModes",0,"BlockSizeY","71"))}))}_bindUI(){let e=[this.UIElement],t=this.UIElement.children;for(let i of t)e.push(i);for(let t=0;t','','','','','','','',''].join(""),this._optGotRsl=this._optGotRsl||this._selRsl.options[0])):!this._optGotRsl&&t.classList.contains("dbrScanner-opt-gotResolution")?this._optGotRsl=t:!this._btnClose&&t.classList.contains("dbrScanner-btn-close")?this._btnClose=t:!this._video&&t.classList.contains("dbrScanner-existingVideo")?(this._video=t,this._video.setAttribute("playsinline","true"),this.singleFrameMode=!1):!i&&t.tagName&&"video"==t.tagName.toLowerCase()&&(i=t);if(!this._video&&i&&(this._video=i),this.singleFrameMode?(this._video&&(this._video.addEventListener("click",this._clickIptSingleFrameMode),this._video.style.cursor="pointer",this._video.setAttribute("title","Take a photo")),this._cvsDrawArea&&(this._cvsDrawArea.addEventListener("click",this._clickIptSingleFrameMode),this._cvsDrawArea.style.cursor="pointer",this._cvsDrawArea.setAttribute("title","Take a photo")),this._divScanArea&&(this._divScanArea.addEventListener("click",this._clickIptSingleFrameMode),this._divScanArea.style.cursor="pointer",this._divScanArea.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="")):this._bgLoading&&(this._bgLoading.style.display=""),this._selCam&&this._selCam.addEventListener("change",this._onCameraSelChange),this._selRsl&&this._selRsl.addEventListener("change",this._onResolutionSelChange),this._btnClose&&this._btnClose.addEventListener("click",this._onCloseBtnClick),!this._video)throw this._unbindUI(),Error("Can not find HTMLVideoElement with class `dbrScanner-video`.");this._isOpen=!0}_unbindUI(){this._clearRegionsults(),this.singleFrameMode?(this._video&&(this._video.removeEventListener("click",this._clickIptSingleFrameMode),this._video.style.cursor="",this._video.removeAttribute("title")),this._cvsDrawArea&&(this._cvsDrawArea.removeEventListener("click",this._clickIptSingleFrameMode),this._cvsDrawArea.style.cursor="",this._cvsDrawArea.removeAttribute("title")),this._divScanArea&&(this._divScanArea.removeEventListener("click",this._clickIptSingleFrameMode),this._divScanArea.style.cursor="",this._divScanArea.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none")):this._bgLoading&&(this._bgLoading.style.display="none"),this._selCam&&this._selCam.removeEventListener("change",this._onCameraSelChange),this._selRsl&&this._selRsl.removeEventListener("change",this._onResolutionSelChange),this._btnClose&&this._btnClose.removeEventListener("click",this._onCloseBtnClick),this._video=null,this._cvsDrawArea=null,this._divScanArea=null,this._divScanLight=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._isOpen=!1}_renderSelCameraInfo(){let e,t;if(this._selCam&&(e=this._selCam.value,this._selCam.innerHTML=""),this._selCam){for(let i of this._allCameras){let n=document.createElement("option");n.value=i.deviceId,n.innerText=i.label,this._selCam.append(n),e==i.deviceId&&(t=n)}let i=this._selCam.childNodes;if(!t&&this._currentCamera&&i.length)for(let e of i)if(this._currentCamera.label==e.innerText){t=e;break}t&&(this._selCam.value=t.value)}}getAllCameras(){return h(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices(),t=[];let i=0;for(let n=0;n{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success){let t=i.results;return t.intervalTime=this.intervalTime,e(t)}{let e=new Error(i.message);return e.stack+="\n"+i.stack,t(e)}}),c._dbrWorker.postMessage({type:"getScanSettings",id:i,instanceID:this._instanceID})})}))}updateScanSettings(e){return h(this,void 0,void 0,(function*(){return this.intervalTime=e.intervalTime,yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack+="\n"+e.stack,i(t)}}),g._dbrWorker.postMessage({type:"updateScanSettings",id:n,instanceID:this._instanceID,body:{settings:e}})})}))}getVideoSettings(){return JSON.parse(JSON.stringify(this.videoSettings))}updateVideoSettings(e){return this.videoSettings=JSON.parse(JSON.stringify(e)),this._lastDeviceId=null,this._isOpen?this.play():Promise.resolve()}isOpen(){return this._isOpen}_show(){this.UIElement.parentNode||(this.UIElement.style.position="fixed",this.UIElement.style.left="0",this.UIElement.style.top="0",document.body.append(this.UIElement)),"none"==this.UIElement.style.display&&(this.UIElement.style.display="")}stop(){this._video&&this._video.srcObject&&(c._onLog&&c._onLog("======stop video========"),this._video.srcObject.getTracks().forEach(e=>{e.stop()}),this._video.srcObject=null,this._videoTrack=null),this._video&&this._video.classList.contains("dbrScanner-existingVideo")&&(c._onLog&&c._onLog("======stop existing video========"),this._video.pause(),this._video.currentTime=0),this._bgLoading&&(this._bgLoading.style.animationPlayState=""),this._divScanLight&&(this._divScanLight.style.display="none")}pause(){this._video&&this._video.pause(),this._divScanLight&&(this._divScanLight.style.display="none")}play(e,t,i){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.singleFrameMode)return this._clickIptSingleFrameMode(),{width:0,height:0};if(this._video&&this._video.classList.contains("dbrScanner-existingVideo")){yield this._video.play();let e={width:this._video.videoWidth,height:this._video.videoHeight};return this.onPlayed&&setTimeout(()=>{this.onPlayed(e)},0),e}if(this._video&&this._video.srcObject&&(this.stop(),yield new Promise(e=>setTimeout(e,500))),c._onLog&&c._onLog("======before video========"),"Android"==c.browserInfo.OS&&(yield this.getAllCameras()),this.bDestroyed)throw new Error("The BarcodeScanner instance has been destroyed.");const n=this.videoSettings;"boolean"==typeof n.video&&(n.video={});const r="iPhone"==c.browserInfo.OS;let o,s;if(r?t>=1280||i>=1280?n.video.width=1280:t>=640||i>=640?n.video.width=640:(t<640||i<640)&&(n.video.width=320):(t&&(n.video.width={ideal:t}),i&&(n.video.height={ideal:i})),e)delete n.video.facingMode,n.video.deviceId={exact:e},this._lastDeviceId=e;else if(n.video.deviceId);else if(this._lastDeviceId)delete n.video.facingMode,n.video.deviceId={ideal:this._lastDeviceId};else if(n.video.facingMode){let e=n.video.facingMode;if(e instanceof Array&&e.length&&(e=e[0]),e=e.exact||e.ideal||e,"environment"===e){for(let e of this._allCameras){let t=e.label.toLowerCase();if(t&&-1!=t.indexOf("facing back")&&/camera[0-9]?\s0,/.test(t)){delete n.video.facingMode,n.video.deviceId={ideal:e.deviceId};break}}o=!!n.video.facingMode}}c._onLog&&c._onLog("======try getUserMedia========"),c._onLog&&c._onLog("ask "+JSON.stringify(n.video.width)+"x"+JSON.stringify(n.video.height));try{c._onLog&&c._onLog(n),s=yield navigator.mediaDevices.getUserMedia(n)}catch(e){c._onLog&&c._onLog(e),c._onLog&&c._onLog("======try getUserMedia again========"),r?(delete n.video.width,delete n.video.height):o?(delete n.video.facingMode,this._allCameras.length&&(n.video.deviceId={ideal:this._allCameras[this._allCameras.length-1].deviceId})):n.video=!0,c._onLog&&c._onLog(n),s=yield navigator.mediaDevices.getUserMedia(n)}if(this.bDestroyed)throw s.getTracks().forEach(e=>{e.stop()}),new Error("The BarcodeScanner instance has been destroyed.");{const e=s.getVideoTracks();e.length&&(this._videoTrack=e[0])}this._video.srcObject=s,c._onLog&&c._onLog("======play video========");try{yield Promise.race([this._video.play(),new Promise((e,t)=>{setTimeout(()=>t(new Error("Failed to play video. Timeout.")),4e3)})])}catch(e){c._onLog&&c._onLog("======play video again========"),yield new Promise(e=>{setTimeout(e,1e3)}),yield Promise.race([this._video.play(),new Promise((e,t)=>{setTimeout(()=>t(new Error("Failed to play video. Timeout.")),4e3)})])}c._onLog&&c._onLog("======played video========"),this._bgLoading&&(this._bgLoading.style.animationPlayState="paused"),this._drawRegionsults();const a="got "+this._video.videoWidth+"x"+this._video.videoHeight;this._optGotRsl&&(this._optGotRsl.setAttribute("data-width",this._video.videoWidth),this._optGotRsl.setAttribute("data-height",this._video.videoHeight),this._optGotRsl.innerText=a,this._selRsl&&this._optGotRsl.parentNode==this._selRsl&&(this._selRsl.value="got")),c._onLog&&c._onLog(a),"Android"!==c.browserInfo.OS&&(yield this.getAllCameras()),yield this.getCurrentCamera(),this._renderSelCameraInfo();let _={width:this._video.videoWidth,height:this._video.videoHeight};return this.onPlayed&&setTimeout(()=>{this.onPlayed(_)},0),_}))}pauseScan(){this._assertOpen(),this._bPauseScan=!0,this._divScanLight&&(this._divScanLight.style.display="none")}resumeScan(){this._assertOpen(),this._bPauseScan=!1}getCapabilities(){return this._assertOpen(),this._videoTrack.getCapabilities?this._videoTrack.getCapabilities():{}}getCameraSettings(){return this._assertOpen(),this._videoTrack.getSettings()}getConstraints(){return this._assertOpen(),this._videoTrack.getConstraints()}applyConstraints(e){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),!this._videoTrack.applyConstraints)throw Error("Not supported.");return yield this._videoTrack.applyConstraints(e)}))}turnOnTorch(){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.getCapabilities().torch)return yield this._videoTrack.applyConstraints({advanced:[{torch:!0}]});throw Error("Not supported.")}))}turnOffTorch(){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.getCapabilities().torch)return yield this._videoTrack.applyConstraints({advanced:[{torch:!1}]});throw Error("Not supported.")}))}setColorTemperature(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().colorTemperature;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{colorTemperature:e}]})}))}setExposureCompensation(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().exposureCompensation;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{exposureCompensation:e}]})}))}setZoom(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().zoom;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{zoom:e}]})}))}setFrameRate(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().frameRate;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({width:{ideal:Math.max(this._video.videoWidth,this._video.videoHeight)},frameRate:e})}))}_cloneDecodeResults(e){if(e instanceof Array){let t=[];for(let i of e)t.push(this._cloneDecodeResults(i));return t}{let t=e;return JSON.parse(JSON.stringify(t,(e,t)=>"oriVideoCanvas"==e||"searchRegionCanvas"==e?void 0:t))}}_loopReadVideo(){return h(this,void 0,void 0,(function*(){if(this.bDestroyed)return;if(!this._isOpen)return void(yield this.clearMapDecodeRecord());if(this._video.paused||this._bPauseScan)return c._onLog&&c._onLog("Video or scan is paused. Ask in 1s."),yield this.clearMapDecodeRecord(),void setTimeout(()=>{this._loopReadVideo()},this._intervalDetectVideoPause);this._divScanLight&&"none"==this._divScanLight.style.display&&(this._divScanLight.style.display=""),c._onLog&&c._onLog("======= once read =======");(new Date).getTime();c._onLog&&(this._timeStartDecode=Date.now()),this.decodeCurrentFrame().then(e=>{if(c._onLog&&c._onLog(e),this._isOpen&&!this._video.paused&&!this._bPauseScan){if(this.bPlaySoundOnSuccessfulRead&&e.length){let t=!1;if(!0===this.bPlaySoundOnSuccessfulRead||"frame"===this.bPlaySoundOnSuccessfulRead)t=!0;else if("unduplicated"===this.bPlaySoundOnSuccessfulRead)for(let i of e)if(i.bUnduplicated){t=!0;break}t&&(this.soundOnSuccessfullRead.currentTime=0,this.soundOnSuccessfullRead.play().catch(e=>{console.warn("Autoplay not allowed. User interaction required: "+(e.message||e))}))}if(navigator.vibrate&&this.bVibrateOnSuccessfulRead&&e.length){let t=!1;if(!0===this.bVibrateOnSuccessfulRead||"frame"===this.bVibrateOnSuccessfulRead)t=!0;else if("unduplicated"===this.bVibrateOnSuccessfulRead)for(let i of e)if(i.bUnduplicated){t=!0;break}if(t)try{navigator.vibrate(this.vibrateDuration)}catch(e){console.warn("Vibration not allowed. User interaction required: "+(e.message||e))}}if(this.onFrameRead){let t=this._cloneDecodeResults(e);for(let e of t)delete e.bUnduplicated;this.onFrameRead(t)}if(this.onUnduplicatedRead)for(let t of e)t.bUnduplicated&&this.onUnduplicatedRead(t.barcodeText,this._cloneDecodeResults(t));this._drawRegionsults(e)}setTimeout(()=>{this._loopReadVideo()},this.intervalTime)}).catch(e=>{if(c._onLog&&c._onLog(e.message||e),setTimeout(()=>{this._loopReadVideo()},Math.max(this.intervalTime,1e3)),"platform error"!=e.message)throw console.error(e.message),e})}))}_drawRegionsults(e){let t,i,n;if(this.beingLazyDrawRegionsults=!1,this.singleFrameMode){if(!this.oriCanvas)return;t="contain",i=this.oriCanvas.width,n=this.oriCanvas.height}else{if(!this._video)return;t=this._video.style.objectFit||"contain",i=this._video.videoWidth,n=this._video.videoHeight}let r=this.region;if(r&&(!r.regionLeft&&!r.regionRight&&!r.regionTop&&!r.regionBottom&&!r.regionMeasuredByPercentage||r instanceof Array?r=null:r.regionMeasuredByPercentage?r=r.regionLeft||r.regionRight||100!==r.regionTop||100!==r.regionBottom?{regionLeft:Math.round(r.regionLeft/100*i),regionTop:Math.round(r.regionTop/100*n),regionRight:Math.round(r.regionRight/100*i),regionBottom:Math.round(r.regionBottom/100*n)}:null:(r=JSON.parse(JSON.stringify(r)),delete r.regionMeasuredByPercentage)),this._cvsDrawArea){this._cvsDrawArea.style.objectFit=t;let o=this._cvsDrawArea;o.width=i,o.height=n;let s=o.getContext("2d");if(r){s.fillStyle=this.regionMaskFillStyle,s.fillRect(0,0,o.width,o.height),s.globalCompositeOperation="destination-out",s.fillStyle="#000";let e=Math.round(this.regionMaskLineWidth/2);s.fillRect(r.regionLeft-e,r.regionTop-e,r.regionRight-r.regionLeft+2*e,r.regionBottom-r.regionTop+2*e),s.globalCompositeOperation="source-over",s.strokeStyle=this.regionMaskStrokeStyle,s.lineWidth=this.regionMaskLineWidth,s.rect(r.regionLeft,r.regionTop,r.regionRight-r.regionLeft,r.regionBottom-r.regionTop),s.stroke()}if(e){s.globalCompositeOperation="destination-over",s.fillStyle=this.barcodeFillStyle,s.strokeStyle=this.barcodeStrokeStyle,s.lineWidth=this.barcodeLineWidth,e=e||[];for(let t of e){let e=t.localizationResult;s.beginPath(),s.moveTo(e.x1,e.y1),s.lineTo(e.x2,e.y2),s.lineTo(e.x3,e.y3),s.lineTo(e.x4,e.y4),s.fill(),s.beginPath(),s.moveTo(e.x1,e.y1),s.lineTo(e.x2,e.y2),s.lineTo(e.x3,e.y3),s.lineTo(e.x4,e.y4),s.closePath(),s.stroke()}}this.singleFrameMode&&(s.globalCompositeOperation="destination-over",s.drawImage(this.oriCanvas,0,0))}if(this._divScanArea){let e=this._video.offsetWidth,t=this._video.offsetHeight,o=1;e/tsuper.destroy}});return h(this,void 0,void 0,(function*(){document.removeEventListener("visibilitychange",this._ev_documentHideEvent),this.close();for(let e of this.styleEls)e.remove();this.styleEls.splice(0,this.styleEls.length),this.bDestroyed||(yield e.destroy.call(this))}))}}var E,R,I,A,f,D,T,S,m,M,C,v,p,L,y,O,N,B,b,P,F,w,U,V,k,G,x,W,H,K;g.singlePresetRegion=[null,{regionLeft:0,regionTop:30,regionRight:100,regionBottom:70,regionMeasuredByPercentage:1},{regionLeft:25,regionTop:25,regionRight:75,regionBottom:75,regionMeasuredByPercentage:1},{regionLeft:25,regionTop:25,regionRight:75,regionBottom:75,regionMeasuredByPercentage:1}],function(e){e[e.BICM_DARK_ON_LIGHT=1]="BICM_DARK_ON_LIGHT",e[e.BICM_LIGHT_ON_DARK=2]="BICM_LIGHT_ON_DARK",e[e.BICM_DARK_ON_DARK=4]="BICM_DARK_ON_DARK",e[e.BICM_LIGHT_ON_LIGHT=8]="BICM_LIGHT_ON_LIGHT",e[e.BICM_DARK_LIGHT_MIXED=16]="BICM_DARK_LIGHT_MIXED",e[e.BICM_DARK_ON_LIGHT_DARK_SURROUNDING=32]="BICM_DARK_ON_LIGHT_DARK_SURROUNDING",e[e.BICM_SKIP=0]="BICM_SKIP",e[e.BICM_REV=2147483648]="BICM_REV"}(E||(E={})),function(e){e[e.BCM_AUTO=1]="BCM_AUTO",e[e.BCM_GENERAL=2]="BCM_GENERAL",e[e.BCM_SKIP=0]="BCM_SKIP",e[e.BCM_REV=2147483648]="BCM_REV"}(R||(R={})),function(e){e[e.BF2_NULL=0]="BF2_NULL",e[e.BF2_POSTALCODE=32505856]="BF2_POSTALCODE",e[e.BF2_NONSTANDARD_BARCODE=1]="BF2_NONSTANDARD_BARCODE",e[e.BF2_USPSINTELLIGENTMAIL=1048576]="BF2_USPSINTELLIGENTMAIL",e[e.BF2_POSTNET=2097152]="BF2_POSTNET",e[e.BF2_PLANET=4194304]="BF2_PLANET",e[e.BF2_AUSTRALIANPOST=8388608]="BF2_AUSTRALIANPOST",e[e.BF2_RM4SCC=16777216]="BF2_RM4SCC",e[e.BF2_DOTCODE=2]="BF2_DOTCODE"}(I||(I={})),function(e){e[e.BM_AUTO=1]="BM_AUTO",e[e.BM_LOCAL_BLOCK=2]="BM_LOCAL_BLOCK",e[e.BM_SKIP=0]="BM_SKIP",e[e.BM_THRESHOLD=4]="BM_THRESHOLD",e[e.BM_REV=2147483648]="BM_REV"}(A||(A={})),function(e){e[e.ECCM_CONTRAST=1]="ECCM_CONTRAST"}(f||(f={})),function(e){e[e.CFM_GENERAL=1]="CFM_GENERAL"}(D||(D={})),function(e){e[e.CCM_AUTO=1]="CCM_AUTO",e[e.CCM_GENERAL_HSV=2]="CCM_GENERAL_HSV",e[e.CCM_SKIP=0]="CCM_SKIP",e[e.CCM_REV=2147483648]="CCM_REV"}(T||(T={})),function(e){e[e.CICM_GENERAL=1]="CICM_GENERAL",e[e.CICM_SKIP=0]="CICM_SKIP",e[e.CICM_REV=2147483648]="CICM_REV"}(S||(S={})),function(e){e[e.CM_IGNORE=1]="CM_IGNORE",e[e.CM_OVERWRITE=2]="CM_OVERWRITE"}(m||(m={})),function(e){e[e.DM_SKIP=0]="DM_SKIP",e[e.DM_DIRECT_BINARIZATION=1]="DM_DIRECT_BINARIZATION",e[e.DM_THRESHOLD_BINARIZATION=2]="DM_THRESHOLD_BINARIZATION",e[e.DM_GRAY_EQUALIZATION=4]="DM_GRAY_EQUALIZATION",e[e.DM_SMOOTHING=8]="DM_SMOOTHING",e[e.DM_MORPHING=16]="DM_MORPHING",e[e.DM_DEEP_ANALYSIS=32]="DM_DEEP_ANALYSIS",e[e.DM_SHARPENING=64]="DM_SHARPENING"}(M||(M={})),function(e){e[e.DRM_AUTO=1]="DRM_AUTO",e[e.DRM_GENERAL=2]="DRM_GENERAL",e[e.DRM_SKIP=0]="DRM_SKIP",e[e.DRM_REV=2147483648]="DRM_REV"}(C||(C={})),function(e){e[e.DPMCRM_AUTO=1]="DPMCRM_AUTO",e[e.DPMCRM_GENERAL=2]="DPMCRM_GENERAL",e[e.DPMCRM_SKIP=0]="DPMCRM_SKIP",e[e.DPMCRM_REV=2147483648]="DPMCRM_REV"}(v||(v={})),function(e){e[e.GTM_INVERTED=1]="GTM_INVERTED",e[e.GTM_ORIGINAL=2]="GTM_ORIGINAL",e[e.GTM_SKIP=0]="GTM_SKIP",e[e.GTM_REV=2147483648]="GTM_REV"}(p||(p={})),function(e){e[e.IPM_AUTO=1]="IPM_AUTO",e[e.IPM_GENERAL=2]="IPM_GENERAL",e[e.IPM_GRAY_EQUALIZE=4]="IPM_GRAY_EQUALIZE",e[e.IPM_GRAY_SMOOTH=8]="IPM_GRAY_SMOOTH",e[e.IPM_SHARPEN_SMOOTH=16]="IPM_SHARPEN_SMOOTH",e[e.IPM_MORPHOLOGY=32]="IPM_MORPHOLOGY",e[e.IPM_SKIP=0]="IPM_SKIP",e[e.IPM_REV=2147483648]="IPM_REV"}(L||(L={})),function(e){e[e.IRSM_MEMORY=1]="IRSM_MEMORY",e[e.IRSM_FILESYSTEM=2]="IRSM_FILESYSTEM",e[e.IRSM_BOTH=4]="IRSM_BOTH"}(y||(y={})),function(e){e[e.IRT_NO_RESULT=0]="IRT_NO_RESULT",e[e.IRT_ORIGINAL_IMAGE=1]="IRT_ORIGINAL_IMAGE",e[e.IRT_COLOUR_CLUSTERED_IMAGE=2]="IRT_COLOUR_CLUSTERED_IMAGE",e[e.IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE=4]="IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE",e[e.IRT_TRANSFORMED_GRAYSCALE_IMAGE=8]="IRT_TRANSFORMED_GRAYSCALE_IMAGE",e[e.IRT_PREDETECTED_REGION=16]="IRT_PREDETECTED_REGION",e[e.IRT_PREPROCESSED_IMAGE=32]="IRT_PREPROCESSED_IMAGE",e[e.IRT_BINARIZED_IMAGE=64]="IRT_BINARIZED_IMAGE",e[e.IRT_TEXT_ZONE=128]="IRT_TEXT_ZONE",e[e.IRT_CONTOUR=256]="IRT_CONTOUR",e[e.IRT_LINE_SEGMENT=512]="IRT_LINE_SEGMENT",e[e.IRT_FORM=1024]="IRT_FORM",e[e.IRT_SEGMENTATION_BLOCK=2048]="IRT_SEGMENTATION_BLOCK",e[e.IRT_TYPED_BARCODE_ZONE=4096]="IRT_TYPED_BARCODE_ZONE",e[e.IRT_PREDETECTED_QUADRILATERAL=8192]="IRT_PREDETECTED_QUADRILATERAL"}(O||(O={})),function(e){e[e.LM_SKIP=0]="LM_SKIP",e[e.LM_AUTO=1]="LM_AUTO",e[e.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",e[e.LM_LINES=8]="LM_LINES",e[e.LM_STATISTICS=4]="LM_STATISTICS",e[e.LM_SCAN_DIRECTLY=16]="LM_SCAN_DIRECTLY",e[e.LM_STATISTICS_MARKS=32]="LM_STATISTICS_MARKS",e[e.LM_STATISTICS_POSTAL_CODE=64]="LM_STATISTICS_POSTAL_CODE",e[e.LM_CENTRE=128]="LM_CENTRE",e[e.LM_REV=2147483648]="LM_REV"}(N||(N={})),function(e){e[e.PDFRM_RASTER=1]="PDFRM_RASTER",e[e.PDFRM_AUTO=2]="PDFRM_AUTO",e[e.PDFRM_VECTOR=4]="PDFRM_VECTOR",e[e.PDFRM_REV=2147483648]="PDFRM_REV"}(B||(B={})),function(e){e[e.QRECL_ERROR_CORRECTION_H=0]="QRECL_ERROR_CORRECTION_H",e[e.QRECL_ERROR_CORRECTION_L=1]="QRECL_ERROR_CORRECTION_L",e[e.QRECL_ERROR_CORRECTION_M=2]="QRECL_ERROR_CORRECTION_M",e[e.QRECL_ERROR_CORRECTION_Q=3]="QRECL_ERROR_CORRECTION_Q"}(b||(b={})),function(e){e[e.RPM_AUTO=1]="RPM_AUTO",e[e.RPM_GENERAL=2]="RPM_GENERAL",e[e.RPM_GENERAL_RGB_CONTRAST=4]="RPM_GENERAL_RGB_CONTRAST",e[e.RPM_GENERAL_GRAY_CONTRAST=8]="RPM_GENERAL_GRAY_CONTRAST",e[e.RPM_GENERAL_HSV_CONTRAST=16]="RPM_GENERAL_HSV_CONTRAST",e[e.RPM_SKIP=0]="RPM_SKIP",e[e.RPM_REV=2147483648]="RPM_REV"}(P||(P={})),function(e){e[e.RCT_PIXEL=1]="RCT_PIXEL",e[e.RCT_PERCENTAGE=2]="RCT_PERCENTAGE"}(F||(F={})),function(e){e[e.RT_STANDARD_TEXT=0]="RT_STANDARD_TEXT",e[e.RT_RAW_TEXT=1]="RT_RAW_TEXT",e[e.RT_CANDIDATE_TEXT=2]="RT_CANDIDATE_TEXT",e[e.RT_PARTIAL_TEXT=3]="RT_PARTIAL_TEXT"}(w||(w={})),function(e){e[e.SUM_AUTO=1]="SUM_AUTO",e[e.SUM_LINEAR_INTERPOLATION=2]="SUM_LINEAR_INTERPOLATION",e[e.SUM_NEAREST_NEIGHBOUR_INTERPOLATION=4]="SUM_NEAREST_NEIGHBOUR_INTERPOLATION",e[e.SUM_SKIP=0]="SUM_SKIP",e[e.SUM_REV=2147483648]="SUM_REV"}(U||(U={})),function(e){e[e.TP_REGION_PREDETECTED=1]="TP_REGION_PREDETECTED",e[e.TP_IMAGE_PREPROCESSED=2]="TP_IMAGE_PREPROCESSED",e[e.TP_IMAGE_BINARIZED=4]="TP_IMAGE_BINARIZED",e[e.TP_BARCODE_LOCALIZED=8]="TP_BARCODE_LOCALIZED",e[e.TP_BARCODE_TYPE_DETERMINED=16]="TP_BARCODE_TYPE_DETERMINED",e[e.TP_BARCODE_RECOGNIZED=32]="TP_BARCODE_RECOGNIZED"}(V||(V={})),function(e){e[e.TACM_AUTO=1]="TACM_AUTO",e[e.TACM_VERIFYING=2]="TACM_VERIFYING",e[e.TACM_VERIFYING_PATCHING=4]="TACM_VERIFYING_PATCHING",e[e.TACM_SKIP=0]="TACM_SKIP",e[e.TACM_REV=2147483648]="TACM_REV"}(k||(k={})),function(e){e[e.TFM_AUTO=1]="TFM_AUTO",e[e.TFM_GENERAL_CONTOUR=2]="TFM_GENERAL_CONTOUR",e[e.TFM_SKIP=0]="TFM_SKIP",e[e.TFM_REV=2147483648]="TFM_REV"}(G||(G={})),function(e){e[e.TROM_CONFIDENCE=1]="TROM_CONFIDENCE",e[e.TROM_POSITION=2]="TROM_POSITION",e[e.TROM_FORMAT=4]="TROM_FORMAT",e[e.TROM_SKIP=0]="TROM_SKIP",e[e.TROM_REV=2147483648]="TROM_REV"}(x||(x={})),function(e){e[e.TDM_AUTO=1]="TDM_AUTO",e[e.TDM_GENERAL_WIDTH_CONCENTRATION=2]="TDM_GENERAL_WIDTH_CONCENTRATION",e[e.TDM_SKIP=0]="TDM_SKIP",e[e.TDM_REV=2147483648]="TDM_REV"}(W||(W={})),function(e){e.DM_LM_ONED="1",e.DM_LM_QR_CODE="2",e.DM_LM_PDF417="3",e.DM_LM_DATAMATRIX="4",e.DM_LM_AZTEC="5",e.DM_LM_MAXICODE="6",e.DM_LM_PATCHCODE="7",e.DM_LM_GS1_DATABAR="8",e.DM_LM_GS1_COMPOSITE="9",e.DM_LM_POSTALCODE="10",e.DM_LM_DOTCODE="11",e.DM_LM_INTERMEDIATE_RESULT="12",e.DM_LM_DPM="13",e.DM_LM_NONSTANDARD_BARCODE="16"}(H||(H={})),function(e){e.DM_CW_AUTO="",e.DM_CW_DEVICE_COUNT="DeviceCount",e.DM_CW_SCAN_COUNT="ScanCount",e.DM_CW_CONCURRENT_DEVICE_COUNT="ConcurrentDeviceCount",e.DM_CW_APP_DOMIAN_COUNT="Domain",e.DM_CW_ACTIVE_DEVICE_COUNT="ActiveDeviceCount",e.DM_CW_INSTANCE_COUNT="InstanceCount",e.DM_CW_CONCURRENT_INSTANCE_COUNT="ConcurrentInstanceCount"}(K||(K={}));const J={BarcodeReader:c,BarcodeScanner:g,EnumBarcodeColourMode:E,EnumBarcodeComplementMode:R,EnumBarcodeFormat:s,EnumBarcodeFormat_2:I,EnumBinarizationMode:A,EnumClarityCalculationMethod:f,EnumClarityFilterMode:D,EnumColourClusteringMode:T,EnumColourConversionMode:S,EnumConflictMode:m,EnumDeblurMode:M,EnumDeformationResistingMode:C,EnumDPMCodeReadingMode:v,EnumErrorCode:r,EnumGrayscaleTransformationMode:p,EnumImagePixelFormat:n,EnumImagePreprocessingMode:L,EnumIMResultDataType:o,EnumIntermediateResultSavingMode:y,EnumIntermediateResultType:O,EnumLocalizationMode:N,EnumPDFReadingMode:B,EnumQRCodeErrorCorrectionLevel:b,EnumRegionPredetectionMode:P,EnumResultCoordinateType:F,EnumResultType:w,EnumScaleUpMode:U,EnumTerminatePhase:V,EnumTextAssistedCorrectionMode:k,EnumTextFilterMode:G,EnumTextResultOrderMode:x,EnumTextureDetectionMode:W,EnumLicenseModule:H,EnumChargeWay:K};t.default=J}])}));if(typeof dbr!="undefined"){if(typeof Dynamsoft=="undefined"){Dynamsoft={};}if(typeof Dynamsoft.DBR=="undefined"){Dynamsoft.DBR={};}for(let key in dbr){Dynamsoft.DBR[key]=dbr[key];}}
\ No newline at end of file
diff --git a/dist/dbr.mjs b/dist/dbr.mjs
index 1c91f358..d19539e7 100644
--- a/dist/dbr.mjs
+++ b/dist/dbr.mjs
@@ -4,8 +4,8 @@
* @website http://www.dynamsoft.com
* @preserve Copyright 2021, Dynamsoft Corporation
* @author Dynamsoft
-* @version 8.2.1 (js 20210326)
+* @version 8.2.3 (js 20210413)
* @fileoverview Dynamsoft JavaScript Library for Barcode Reader
* More info on DBR JS: https://www.dynamsoft.com/Products/barcode-recognition-javascript.aspx
*/
-import worker_threads from "worker_threads";import https from "https";import http from "http";import fs from "fs";import os from "os";import url from "url";!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(worker_threads,https,http,fs,os):"function"==typeof define&&define.amd?define(t):"object"==typeof exports?exports.dbr=t(worker_threads,https,http,fs,os):e.dbr=t(e.worker_threads,e.https,e.http,e.fs,e.os)}(("object"==typeof window?window:global),(function(e,t,i,n,r){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=5)}([function(t,i){t.exports=e},function(e,i){e.exports=t},function(e,t){e.exports=i},function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t,i){"use strict";var n,r,o,s;i.r(t),i.d(t,"BarcodeReader",(function(){return c})),i.d(t,"BarcodeScanner",(function(){return g})),i.d(t,"EnumBarcodeColourMode",(function(){return E})),i.d(t,"EnumBarcodeComplementMode",(function(){return R})),i.d(t,"EnumBarcodeFormat",(function(){return s})),i.d(t,"EnumBarcodeFormat_2",(function(){return A})),i.d(t,"EnumBinarizationMode",(function(){return I})),i.d(t,"EnumClarityCalculationMethod",(function(){return f})),i.d(t,"EnumClarityFilterMode",(function(){return D})),i.d(t,"EnumColourClusteringMode",(function(){return T})),i.d(t,"EnumColourConversionMode",(function(){return S})),i.d(t,"EnumConflictMode",(function(){return m})),i.d(t,"EnumDeblurMode",(function(){return M})),i.d(t,"EnumDeformationResistingMode",(function(){return C})),i.d(t,"EnumDPMCodeReadingMode",(function(){return p})),i.d(t,"EnumErrorCode",(function(){return r})),i.d(t,"EnumGrayscaleTransformationMode",(function(){return v})),i.d(t,"EnumImagePixelFormat",(function(){return n})),i.d(t,"EnumImagePreprocessingMode",(function(){return y})),i.d(t,"EnumIMResultDataType",(function(){return o})),i.d(t,"EnumIntermediateResultSavingMode",(function(){return L})),i.d(t,"EnumIntermediateResultType",(function(){return O})),i.d(t,"EnumLocalizationMode",(function(){return N})),i.d(t,"EnumPDFReadingMode",(function(){return B})),i.d(t,"EnumQRCodeErrorCorrectionLevel",(function(){return b})),i.d(t,"EnumRegionPredetectionMode",(function(){return P})),i.d(t,"EnumResultCoordinateType",(function(){return F})),i.d(t,"EnumResultType",(function(){return w})),i.d(t,"EnumScaleUpMode",(function(){return U})),i.d(t,"EnumTerminatePhase",(function(){return k})),i.d(t,"EnumTextAssistedCorrectionMode",(function(){return V})),i.d(t,"EnumTextFilterMode",(function(){return G})),i.d(t,"EnumTextResultOrderMode",(function(){return x})),i.d(t,"EnumTextureDetectionMode",(function(){return W})),i.d(t,"EnumLicenseModule",(function(){return H})),i.d(t,"EnumChargeWay",(function(){return K})),function(e){e[e.IPF_Binary=0]="IPF_Binary",e[e.IPF_BinaryInverted=1]="IPF_BinaryInverted",e[e.IPF_GrayScaled=2]="IPF_GrayScaled",e[e.IPF_NV21=3]="IPF_NV21",e[e.IPF_RGB_565=4]="IPF_RGB_565",e[e.IPF_RGB_555=5]="IPF_RGB_555",e[e.IPF_RGB_888=6]="IPF_RGB_888",e[e.IPF_ARGB_8888=7]="IPF_ARGB_8888",e[e.IPF_RGB_161616=8]="IPF_RGB_161616",e[e.IPF_ARGB_16161616=9]="IPF_ARGB_16161616",e[e.IPF_ABGR_8888=10]="IPF_ABGR_8888",e[e.IPF_ABGR_16161616=11]="IPF_ABGR_16161616",e[e.IPF_BGR_888=12]="IPF_BGR_888"}(n||(n={})),function(e){e[e.DBR_SYSTEM_EXCEPTION=1]="DBR_SYSTEM_EXCEPTION",e[e.DBR_SUCCESS=0]="DBR_SUCCESS",e[e.DBR_UNKNOWN=-1e4]="DBR_UNKNOWN",e[e.DBR_NO_MEMORY=-10001]="DBR_NO_MEMORY",e[e.DBR_NULL_REFERENCE=-10002]="DBR_NULL_REFERENCE",e[e.DBR_LICENSE_INVALID=-10003]="DBR_LICENSE_INVALID",e[e.DBR_LICENSE_EXPIRED=-10004]="DBR_LICENSE_EXPIRED",e[e.DBR_FILE_NOT_FOUND=-10005]="DBR_FILE_NOT_FOUND",e[e.DBR_FILETYPE_NOT_SUPPORTED=-10006]="DBR_FILETYPE_NOT_SUPPORTED",e[e.DBR_BPP_NOT_SUPPORTED=-10007]="DBR_BPP_NOT_SUPPORTED",e[e.DBR_INDEX_INVALID=-10008]="DBR_INDEX_INVALID",e[e.DBR_BARCODE_FORMAT_INVALID=-10009]="DBR_BARCODE_FORMAT_INVALID",e[e.DBR_CUSTOM_REGION_INVALID=-10010]="DBR_CUSTOM_REGION_INVALID",e[e.DBR_MAX_BARCODE_NUMBER_INVALID=-10011]="DBR_MAX_BARCODE_NUMBER_INVALID",e[e.DBR_IMAGE_READ_FAILED=-10012]="DBR_IMAGE_READ_FAILED",e[e.DBR_TIFF_READ_FAILED=-10013]="DBR_TIFF_READ_FAILED",e[e.DBR_QR_LICENSE_INVALID=-10016]="DBR_QR_LICENSE_INVALID",e[e.DBR_1D_LICENSE_INVALID=-10017]="DBR_1D_LICENSE_INVALID",e[e.DBR_DIB_BUFFER_INVALID=-10018]="DBR_DIB_BUFFER_INVALID",e[e.DBR_PDF417_LICENSE_INVALID=-10019]="DBR_PDF417_LICENSE_INVALID",e[e.DBR_DATAMATRIX_LICENSE_INVALID=-10020]="DBR_DATAMATRIX_LICENSE_INVALID",e[e.DBR_PDF_READ_FAILED=-10021]="DBR_PDF_READ_FAILED",e[e.DBR_PDF_DLL_MISSING=-10022]="DBR_PDF_DLL_MISSING",e[e.DBR_PAGE_NUMBER_INVALID=-10023]="DBR_PAGE_NUMBER_INVALID",e[e.DBR_CUSTOM_SIZE_INVALID=-10024]="DBR_CUSTOM_SIZE_INVALID",e[e.DBR_CUSTOM_MODULESIZE_INVALID=-10025]="DBR_CUSTOM_MODULESIZE_INVALID",e[e.DBR_RECOGNITION_TIMEOUT=-10026]="DBR_RECOGNITION_TIMEOUT",e[e.DBR_JSON_PARSE_FAILED=-10030]="DBR_JSON_PARSE_FAILED",e[e.DBR_JSON_TYPE_INVALID=-10031]="DBR_JSON_TYPE_INVALID",e[e.DBR_JSON_KEY_INVALID=-10032]="DBR_JSON_KEY_INVALID",e[e.DBR_JSON_VALUE_INVALID=-10033]="DBR_JSON_VALUE_INVALID",e[e.DBR_JSON_NAME_KEY_MISSING=-10034]="DBR_JSON_NAME_KEY_MISSING",e[e.DBR_JSON_NAME_VALUE_DUPLICATED=-10035]="DBR_JSON_NAME_VALUE_DUPLICATED",e[e.DBR_TEMPLATE_NAME_INVALID=-10036]="DBR_TEMPLATE_NAME_INVALID",e[e.DBR_JSON_NAME_REFERENCE_INVALID=-10037]="DBR_JSON_NAME_REFERENCE_INVALID",e[e.DBR_PARAMETER_VALUE_INVALID=-10038]="DBR_PARAMETER_VALUE_INVALID",e[e.DBR_DOMAIN_NOT_MATCHED=-10039]="DBR_DOMAIN_NOT_MATCHED",e[e.DBR_RESERVEDINFO_NOT_MATCHED=-10040]="DBR_RESERVEDINFO_NOT_MATCHED",e[e.DBR_AZTEC_LICENSE_INVALID=-10041]="DBR_AZTEC_LICENSE_INVALID",e[e.DBR_LICENSE_DLL_MISSING=-10042]="DBR_LICENSE_DLL_MISSING",e[e.DBR_LICENSEKEY_NOT_MATCHED=-10043]="DBR_LICENSEKEY_NOT_MATCHED",e[e.DBR_REQUESTED_FAILED=-10044]="DBR_REQUESTED_FAILED",e[e.DBR_LICENSE_INIT_FAILED=-10045]="DBR_LICENSE_INIT_FAILED",e[e.DBR_PATCHCODE_LICENSE_INVALID=-10046]="DBR_PATCHCODE_LICENSE_INVALID",e[e.DBR_POSTALCODE_LICENSE_INVALID=-10047]="DBR_POSTALCODE_LICENSE_INVALID",e[e.DBR_DPM_LICENSE_INVALID=-10048]="DBR_DPM_LICENSE_INVALID",e[e.DBR_FRAME_DECODING_THREAD_EXISTS=-10049]="DBR_FRAME_DECODING_THREAD_EXISTS",e[e.DBR_STOP_DECODING_THREAD_FAILED=-10050]="DBR_STOP_DECODING_THREAD_FAILED",e[e.DBR_SET_MODE_ARGUMENT_ERROR=-10051]="DBR_SET_MODE_ARGUMENT_ERROR",e[e.DBR_LICENSE_CONTENT_INVALID=-10052]="DBR_LICENSE_CONTENT_INVALID",e[e.DBR_LICENSE_KEY_INVALID=-10053]="DBR_LICENSE_KEY_INVALID",e[e.DBR_LICENSE_DEVICE_RUNS_OUT=-10054]="DBR_LICENSE_DEVICE_RUNS_OUT",e[e.DBR_GET_MODE_ARGUMENT_ERROR=-10055]="DBR_GET_MODE_ARGUMENT_ERROR",e[e.DBR_IRT_LICENSE_INVALID=-10056]="DBR_IRT_LICENSE_INVALID",e[e.DBR_MAXICODE_LICENSE_INVALID=-10057]="DBR_MAXICODE_LICENSE_INVALID",e[e.DBR_GS1_DATABAR_LICENSE_INVALID=-10058]="DBR_GS1_DATABAR_LICENSE_INVALID",e[e.DBR_GS1_COMPOSITE_LICENSE_INVALID=-10059]="DBR_GS1_COMPOSITE_LICENSE_INVALID",e[e.DBR_DOTCODE_LICENSE_INVALID=-10061]="DBR_DOTCODE_LICENSE_INVALID",e[e.DMERR_NO_LICENSE=-2e4]="DMERR_NO_LICENSE",e[e.DMERR_LICENSE_SYNC_FAILED=-20003]="DMERR_LICENSE_SYNC_FAILED",e[e.DMERR_TRIAL_LICENSE=-20010]="DMERR_TRIAL_LICENSE",e[e.DMERR_FAILED_TO_REACH_LTS=-20200]="DMERR_FAILED_TO_REACH_LTS"}(r||(r={})),function(e){e[e.IMRDT_IMAGE=1]="IMRDT_IMAGE",e[e.IMRDT_CONTOUR=2]="IMRDT_CONTOUR",e[e.IMRDT_LINESEGMENT=4]="IMRDT_LINESEGMENT",e[e.IMRDT_LOCALIZATIONRESULT=8]="IMRDT_LOCALIZATIONRESULT",e[e.IMRDT_REGIONOFINTEREST=16]="IMRDT_REGIONOFINTEREST",e[e.IMRDT_QUADRILATERAL=32]="IMRDT_QUADRILATERAL"}(o||(o={})),function(e){e[e.BF_ALL=-31457281]="BF_ALL",e[e.BF_ONED=1050623]="BF_ONED",e[e.BF_GS1_DATABAR=260096]="BF_GS1_DATABAR",e[e.BF_CODE_39=1]="BF_CODE_39",e[e.BF_CODE_128=2]="BF_CODE_128",e[e.BF_CODE_93=4]="BF_CODE_93",e[e.BF_CODABAR=8]="BF_CODABAR",e[e.BF_ITF=16]="BF_ITF",e[e.BF_EAN_13=32]="BF_EAN_13",e[e.BF_EAN_8=64]="BF_EAN_8",e[e.BF_UPC_A=128]="BF_UPC_A",e[e.BF_UPC_E=256]="BF_UPC_E",e[e.BF_INDUSTRIAL_25=512]="BF_INDUSTRIAL_25",e[e.BF_CODE_39_EXTENDED=1024]="BF_CODE_39_EXTENDED",e[e.BF_GS1_DATABAR_OMNIDIRECTIONAL=2048]="BF_GS1_DATABAR_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_TRUNCATED=4096]="BF_GS1_DATABAR_TRUNCATED",e[e.BF_GS1_DATABAR_STACKED=8192]="BF_GS1_DATABAR_STACKED",e[e.BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL=16384]="BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_EXPANDED=32768]="BF_GS1_DATABAR_EXPANDED",e[e.BF_GS1_DATABAR_EXPANDED_STACKED=65536]="BF_GS1_DATABAR_EXPANDED_STACKED",e[e.BF_GS1_DATABAR_LIMITED=131072]="BF_GS1_DATABAR_LIMITED",e[e.BF_PATCHCODE=262144]="BF_PATCHCODE",e[e.BF_PDF417=33554432]="BF_PDF417",e[e.BF_QR_CODE=67108864]="BF_QR_CODE",e[e.BF_DATAMATRIX=134217728]="BF_DATAMATRIX",e[e.BF_AZTEC=268435456]="BF_AZTEC",e[e.BF_MAXICODE=536870912]="BF_MAXICODE",e[e.BF_MICRO_QR=1073741824]="BF_MICRO_QR",e[e.BF_MICRO_PDF417=524288]="BF_MICRO_PDF417",e[e.BF_GS1_COMPOSITE=-2147483648]="BF_GS1_COMPOSITE",e[e.BF_MSI_CODE=1048576]="BF_MSI_CODE",e[e.BF_NULL=0]="BF_NULL"}(s||(s={}));var a=function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{_(n.next(e))}catch(e){o(e)}}function a(e){try{_(n.throw(e))}catch(e){o(e)}}function _(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}_((n=n.apply(e,t||[])).next())}))};const _=!0,d=!_&&"undefined"==typeof self,l=_?global:d?{}:self;class c{constructor(){this._canvasMaxWH="iPhone"==c.browserInfo.OS||"Android"==c.browserInfo.OS?2048:4096,this._instanceID=void 0,this.bSaveOriCanvas=!1,this.oriCanvas=null,this.maxVideoCvsLength=3,this.videoCvses=[],this.videoGlCvs=null,this.videoGl=null,this.glImgData=null,this.bFilterRegionInJs=!0,this._region=null,this._timeStartDecode=null,this._timeEnterInnerDBR=null,this._bUseWebgl=!0,this.decodeRecords=[],this.bDestroyed=!1,this._lastErrorCode=0,this._lastErrorString=""}static get version(){return this._version}static get productKeys(){return this._productKeys}static set productKeys(e){if("unload"!=this._loadWasmStatus)throw new Error("`productKeys` is not allowed to change after loadWasm is called.");c._productKeys=e}static get handshakeCode(){return this._productKeys}static set handshakeCode(e){if("unload"!=this._loadWasmStatus)throw new Error("`handshakeCode` is not allowed to change after loadWasm is called.");c._productKeys=e}static get organizationID(){return this._organizationID}static set organizationID(e){if("unload"!=this._loadWasmStatus)throw new Error("`organizationID` is not allowed to change after loadWasm is called.");c._organizationID=e}static set sessionPassword(e){if("unload"!=this._loadWasmStatus)throw new Error("`sessionPassword` is not allowed to change after loadWasm is called.");c._sessionPassword=e}static get sessionPassword(){return this._sessionPassword}static detectEnvironment(){return a(this,void 0,void 0,(function*(){let e={wasm:"undefined"!=typeof WebAssembly&&("undefined"==typeof navigator||!(/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&/\(.+\s11_2_([2-6]).*\)/.test(navigator.userAgent))),worker:!!(_?process.version>="v12":"undefined"!=typeof Worker),getUserMedia:!("undefined"==typeof navigator||!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia),camera:!1,browser:this.browserInfo.browser,version:this.browserInfo.version,OS:this.browserInfo.OS};if(e.getUserMedia)try{(yield navigator.mediaDevices.getUserMedia({video:!0})).getTracks().forEach(e=>{e.stop()}),e.camera=!0}catch(e){}return e}))}static get engineResourcePath(){return this._engineResourcePath}static set engineResourcePath(e){if("unload"!=this._loadWasmStatus)throw new Error("`engineResourcePath` is not allowed to change after loadWasm is called.");if(null==e&&(e="./"),_||d)c._engineResourcePath=e;else{let t=document.createElement("a");t.href=e,c._engineResourcePath=t.href}this._engineResourcePath.endsWith("/")||(c._engineResourcePath+="/")}static get licenseServer(){return this._licenseServer}static set licenseServer(e){if("unload"!=this._loadWasmStatus)throw new Error("`licenseServer` is not allowed to change after loadWasm is called.");if(null==e)c._licenseServer=[];else{e instanceof Array||(e=[e]);for(let t=0;t= v12.");let e,t=this.productKeys,n=t.startsWith("PUBLIC-TRIAL"),r=n||8==t.length||t.length>8&&!t.startsWith("t")&&!t.startsWith("f")&&!t.startsWith("P")&&!t.startsWith("L")||0==t.length&&0!=this.organizationID.length;if(r&&(_?process.version<"v15"&&(e=new Error("To use handshake need nodejs version >= v15.")):(l.crypto||(e=new Error("Please upgrade your browser to support handshake code.")),l.crypto.subtle||(e=new Error("Need https to use handshake code in this browser.")))),e){if(!n)throw e;n=!1,r=!1}return n&&(t="",console.warn("Automatically apply for a public trial license.")),yield new Promise((e,n)=>a(this,void 0,void 0,(function*(){switch(this._loadWasmStatus){case"unload":{c._loadWasmStatus="loading";let e=this.engineResourcePath+this._workerName;if(_||this.engineResourcePath.startsWith(location.origin)||(e=yield fetch(e).then(e=>e.blob()).then(e=>URL.createObjectURL(e))),_){const t=i(0);c._dbrWorker=new t.Worker(e)}else c._dbrWorker=new Worker(e);this._dbrWorker.onerror=e=>{c._loadWasmStatus="loadFail";for(let t of this._loadWasmCallbackArr)t(new Error(e.message))},this._dbrWorker.onmessage=e=>a(this,void 0,void 0,(function*(){let t=e.data?e.data:e;switch(t.type){case"log":this._onLog&&this._onLog(t.message);break;case"load":if(t.success){c._loadWasmStatus="loadSuccess",c._version=t.version+"(JS "+this._jsVersion+"."+this._jsEditVersion+")",this._onLog&&this._onLog("load dbr worker success");for(let e of this._loadWasmCallbackArr)e();this._dbrWorker.onerror=null}else{let e=new Error(t.message);e.stack=t.stack+"\n"+e.stack,c._loadWasmStatus="loadFail";for(let t of this._loadWasmCallbackArr)t(e)}break;case"task":{let e=t.id,i=t.body;try{this._taskCallbackMap.get(e)(i),this._taskCallbackMap.delete(e)}catch(t){throw this._taskCallbackMap.delete(e),t}break}default:this._onLog&&this._onLog(e)}})),_&&this._dbrWorker.on("message",this._dbrWorker.onmessage),this._dbrWorker.postMessage({type:"loadWasm",bd:this._bWasmDebug,engineResourcePath:this.engineResourcePath,version:this._jsVersion,brtk:r,pk:t,og:this.organizationID,dm:!_&&location.origin.startsWith("http")?location.origin:"https://localhost",bUseFullFeature:this._bUseFullFeature,browserInfo:this.browserInfo,deviceFriendlyName:this.deviceFriendlyName,ls:this.licenseServer,sp:this._sessionPassword,lm:this._limitModules,cw:this._chargeWay})}case"loading":this._loadWasmCallbackArr.push(t=>{t?n(t):e()});break;case"loadSuccess":e();break;case"loadFail":n()}})))}))}static createInstanceInWorker(e=!1){return a(this,void 0,void 0,(function*(){return yield this.loadWasm(),yield new Promise((t,i)=>{let n=c._nextTaskID++;this._taskCallbackMap.set(n,e=>{if(e.success)return t(e.instanceID);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),this._dbrWorker.postMessage({type:"createInstance",id:n,productKeys:"",bScanner:e})})}))}static createInstance(){return a(this,void 0,void 0,(function*(){let e=new c;return e._instanceID=yield this.createInstanceInWorker(),e}))}decode(e){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("decode(source: any)"),c._onLog&&(this._timeStartDecode=Date.now()),_)return e instanceof Buffer?yield this._decodeFileInMemory_Uint8Array(new Uint8Array(e)):e instanceof Uint8Array?yield this._decodeFileInMemory_Uint8Array(e):"string"==typeof e||e instanceof String?"data:image/"==e.substring(0,11)?yield this._decode_Base64(e):"http"==e.substring(0,4)?yield this._decode_Url(e):yield this._decode_FilePath(e):yield Promise.reject(TypeError("'_decode(source, config)': Type of 'source' should be 'Buffer', 'Uint8Array', 'String(base64 with image mime)' or 'String(url)'."));{let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),e instanceof Blob?yield this._decode_Blob(e,t):e instanceof ArrayBuffer?yield this._decode_ArrayBuffer(e,t):e instanceof Uint8Array||e instanceof Uint8ClampedArray?yield this._decode_Uint8Array(e,t):e instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?yield this._decode_Image(e,t):e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?yield this._decode_Canvas(e,t):e instanceof HTMLVideoElement?yield this._decode_Video(e,t):"string"==typeof e||e instanceof String?"data:image/"==e.substring(0,11)?yield this._decode_Base64(e,t):yield this._decode_Url(e,t):yield Promise.reject(TypeError("'_decode(source, config)': Type of 'source' should be 'Blob', 'ArrayBuffer', 'Uint8Array', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement', 'String(base64 with image mime)' or 'String(url)'."))}}))}decodeBase64String(e){return a(this,void 0,void 0,(function*(){let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),this._decode_Base64(e,t)}))}decodeUrl(e){return a(this,void 0,void 0,(function*(){let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),this._decode_Url(e,t)}))}_decodeBuffer_Uint8Array(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){return yield new Promise((s,a)=>{let _=c._nextTaskID++;c._taskCallbackMap.set(_,e=>{if(e.success){let t,i=c._onLog?Date.now():0;this.bufferShared&&!this.bufferShared.length&&(this.bufferShared=e.buffer);try{t=this._handleRetJsonString(e.decodeReturn)}catch(e){return a(e)}if(c._onLog){let e=Date.now();c._onLog("DBR time get result: "+i),c._onLog("Handle image cost: "+(this._timeEnterInnerDBR-this._timeStartDecode)),c._onLog("DBR worker decode image cost: "+(i-this._timeEnterInnerDBR)),c._onLog("DBR worker handle results: "+(e-i)),c._onLog("Total decode image cost: "+(e-this._timeStartDecode))}return s(t)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,a(t)}}),c._onLog&&(this._timeEnterInnerDBR=Date.now()),c._onLog&&c._onLog("Send buffer to worker:"+Date.now()),c._dbrWorker.postMessage({type:"decodeBuffer",id:_,instanceID:this._instanceID,body:{buffer:e,width:t,height:i,stride:n,format:r,config:o}},[e.buffer])})}))}_decodeBuffer_Blob(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){return c._onLog&&c._onLog("_decodeBuffer_Blob(buffer,width,height,stride,format)"),yield new Promise((t,i)=>{let n=new FileReader;n.readAsArrayBuffer(e),n.onload=()=>{t(n.result)},n.onerror=()=>{i(n.error)}}).then(e=>this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o))}))}decodeBuffer(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){let s;return c._onLog&&c._onLog("decodeBuffer(buffer,width,height,stride,format)"),c._onLog&&(this._timeStartDecode=Date.now()),_?e instanceof Uint8Array?s=yield this._decodeBuffer_Uint8Array(e,t,i,n,r,o):e instanceof Buffer&&(s=yield this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o)):e instanceof Uint8Array||e instanceof Uint8ClampedArray?s=yield this._decodeBuffer_Uint8Array(e,t,i,n,r,o):e instanceof ArrayBuffer?s=yield this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o):e instanceof Blob&&(s=yield this._decodeBuffer_Blob(e,t,i,n,r,o)),s}))}_decodeFileInMemory_Uint8Array(e){return a(this,void 0,void 0,(function*(){return yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success){let n;try{n=this._handleRetJsonString(e.decodeReturn)}catch(e){return i(e)}return t(n)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),c._dbrWorker.postMessage({type:"decodeFileInMemory",id:n,instanceID:this._instanceID,body:{bytes:e}})})}))}getRuntimeSettings(){return a(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success){let t=JSON.parse(i.results);return null!=this.userDefinedRegion&&(t.region=JSON.parse(JSON.stringify(this.userDefinedRegion))),e(t)}{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"getRuntimeSettings",id:i,instanceID:this._instanceID})})}))}updateRuntimeSettings(e){return a(this,void 0,void 0,(function*(){let t;if("string"==typeof e||"object"==typeof e&&e instanceof String)if("speed"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=3,t.expectedBarcodesCount=0,t.localizationModes=[2,0,0,0,0,0,0,0]}else if("balance"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=5,t.expectedBarcodesCount=512,t.localizationModes=[2,16,0,0,0,0,0,0]}else if("coverage"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region}else t=JSON.parse(e);else{if("object"!=typeof e)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");if(t=JSON.parse(JSON.stringify(e)),t.region instanceof Array){let e=t.region;[e.regionLeft,e.regionTop,e.regionLeft,e.regionBottom,e.regionMeasuredByPercentage].some(e=>void 0!==e)&&(t.region={regionLeft:e.regionLeft||0,regionTop:e.regionTop||0,regionRight:e.regionRight||0,regionBottom:e.regionBottom||0,regionMeasuredByPercentage:e.regionMeasuredByPercentage||0})}}if(!c._bUseFullFeature){if(0!=(t.barcodeFormatIds&~(s.BF_ONED|s.BF_QR_CODE|s.BF_PDF417|s.BF_DATAMATRIX))||0!=t.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=t.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}if(!_)if(this.bFilterRegionInJs){let e=t.region;if(e instanceof Array)throw Error("The `region` of type `Array` is only allowed in `BarcodeScanner`.");this.userDefinedRegion=JSON.parse(JSON.stringify(e)),(e.regionLeft||e.regionTop||e.regionRight||e.regionBottom||e.regionMeasuredByPercentage)&&(e.regionLeft||e.regionTop||100!=e.regionRight||100!=e.regionBottom||!e.regionMeasuredByPercentage)?this.region=e:this.region=null,t.region={regionLeft:0,regionTop:0,regionRight:0,regionBottom:0,regionMeasuredByPercentage:0}}else this.userDefinedRegion=null,this.region=null;return yield new Promise((e,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,t=>{if(t.success){try{this._handleRetJsonString(t.updateReturn)}catch(e){i(e)}return e()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}}),c._dbrWorker.postMessage({type:"updateRuntimeSettings",id:n,instanceID:this._instanceID,body:{settings:JSON.stringify(t)}})})}))}resetRuntimeSettings(){return a(this,void 0,void 0,(function*(){return this.userDefinedRegion=null,this.region=null,yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"resetRuntimeSettings",id:i,instanceID:this._instanceID})})}))}outputSettingsToString(){return a(this,void 0,void 0,(function*(){if(!c._bUseFullFeature)throw Error("outputSettingsToString() is not supported in the compact version. Please try the full-featured version.");return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e(i.results);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"outputSettingsToString",id:i,instanceID:this._instanceID})})}))}initRuntimeSettingsWithString(e){return a(this,void 0,void 0,(function*(){if(!c._bUseFullFeature)throw Error("initRuntimeSettingsWithString() is not supported in the compact version. Please try the full-featured version.");if("string"==typeof e||"object"==typeof e&&e instanceof String)e=e;else{if("object"!=typeof e)throw TypeError("'initRuntimeSettingstWithString(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");e=JSON.stringify(e)}return yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success){try{this._handleRetJsonString(e.initReturn)}catch(e){i(e)}return t()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),c._dbrWorker.postMessage({type:"initRuntimeSettingsWithString",id:n,instanceID:this._instanceID,body:{settings:e}})})}))}_decode_Blob(e,t){return a(this,void 0,void 0,(function*(){c._onLog&&c._onLog("_decode_Blob(blob: Blob)");let i=null,n=null;if("undefined"!=typeof createImageBitmap)try{i=yield createImageBitmap(e)}catch(e){}i||(n=yield function(e){return new Promise((t,i)=>{let n=URL.createObjectURL(e),r=new Image;r.dbrObjUrl=n,r.src=n,r.onload=()=>{t(r)},r.onerror=e=>{i(new Error("Can't convert blob to image : "+(e instanceof Event?e.type:e)))}})}(e));let r=yield this._decode_Image(i||n,t);return i&&i.close(),r}))}_decode_ArrayBuffer(e,t){return a(this,void 0,void 0,(function*(){return yield this._decode_Blob(new Blob([e]),t)}))}_decode_Uint8Array(e,t){return a(this,void 0,void 0,(function*(){return yield this._decode_Blob(new Blob([e]),t)}))}_decode_Image(e,t){return a(this,void 0,void 0,(function*(){c._onLog&&c._onLog("_decode_Image(image: HTMLImageElement|ImageBitmap)"),t=t||{};let i,n,r=e instanceof HTMLImageElement?e.naturalWidth:e.width,o=e instanceof HTMLImageElement?e.naturalHeight:e.height,s=Math.max(r,o);if(s>this._canvasMaxWH){let e=this._canvasMaxWH/s;i=Math.round(r*e),n=Math.round(o*e)}else i=r,n=o;let a,_=0,d=0,h=r,u=o,g=r,E=o,R=t.region;if(R){let e,t,s,a;R.regionMeasuredByPercentage?(e=R.regionLeft*i/100,t=R.regionTop*n/100,s=R.regionRight*i/100,a=R.regionBottom*n/100):(e=R.regionLeft,t=R.regionTop,s=R.regionRight,a=R.regionBottom),g=s-e,h=Math.round(g/i*r),E=a-t,u=Math.round(E/n*o),_=Math.round(e/i*r),d=Math.round(t/n*o)}!this.bSaveOriCanvas&&l.OffscreenCanvas?a=new OffscreenCanvas(g,E):(a=document.createElement("canvas"),a.width=g,a.height=E);let A,I=a.getContext("2d");0==_&&0==d&&r==h&&o==u&&r==g&&o==E?I.drawImage(e,0,0):I.drawImage(e,_,d,h,u,0,0,g,E),e.dbrObjUrl&&URL.revokeObjectURL(e.dbrObjUrl),R?(A=JSON.parse(JSON.stringify(t)),delete A.region):A=t;let f=yield this._decode_Canvas(a,A);if(R&&f.length>0)for(let e of f){let t=e.localizationResult;2==t.resultCoordinateType&&(t.x1*=.01*g,t.x2*=.01*g,t.x3*=.01*g,t.x4*=.01*g,t.y1*=.01*E,t.y2*=.01*E,t.y3*=.01*E,t.y4*=.01*E),t.x1+=_,t.x2+=_,t.x3+=_,t.x4+=_,t.y1+=d,t.y2+=d,t.y3+=d,t.y4+=d,2==t.resultCoordinateType&&(t.x1*=100/h,t.x2*=100/h,t.x3*=100/h,t.x4*=100/h,t.y1*=100/u,t.y2*=100/u,t.y3*=100/u,t.y4*=100/u)}return f}))}_decode_Canvas(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Canvas(canvas:HTMLCanvasElement)"),e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";(this.bSaveOriCanvas||this.singleFrameMode)&&(this.oriCanvas=e);let i=(e.dbrCtx2d||e.getContext("2d")).getImageData(0,0,e.width,e.height).data;return yield this._decodeBuffer_Uint8Array(i,e.width,e.height,4*e.width,n.IPF_ABGR_8888,t)}))}_decode_Video(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Video(video)"),!(e instanceof HTMLVideoElement))throw TypeError("'_decode_Video(video [, config] )': Type of 'video' should be 'HTMLVideoElement'.");if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";t=t||{};let i,r,o=e.videoWidth,s=e.videoHeight,a=Math.max(o,s);if(a>this._canvasMaxWH){let e=this._canvasMaxWH/a;i=Math.round(o*e),r=Math.round(s*e)}else i=o,r=s;let _=0,d=0,h=o,u=s,g=o,E=s,R=t.region;if(R){let e,t,n,a;R.regionMeasuredByPercentage?(e=R.regionLeft*i/100,t=R.regionTop*r/100,n=R.regionRight*i/100,a=R.regionBottom*r/100):(e=R.regionLeft,t=R.regionTop,n=R.regionRight,a=R.regionBottom),g=n-e,h=Math.round(g/i*o),E=a-t,u=Math.round(E/r*s),_=Math.round(e/i*o),d=Math.round(t/r*s)}let A=0==_&&0==d&&o==h&&s==u&&o==g&&s==E;if(!this.bSaveOriCanvas&&this._bUseWebgl&&A){this.videoGlCvs||(this.videoGlCvs=l.OffscreenCanvas?new OffscreenCanvas(g,E):document.createElement("canvas"));const t=this.videoGlCvs;t.width==g&&t.height==E||(t.height=E,t.width=g,this.videoGl&&this.videoGl.viewport(0,0,g,E));const i=this.videoGl||t.getContext("webgl",{alpha:!1,antialias:!1})||t.getContext("experimental-webgl",{alpha:!1,antialias:!1});if(!this.videoGl){this.videoGl=i;let e=i.createShader(i.VERTEX_SHADER);i.shaderSource(e,"\nattribute vec4 a_position;\nattribute vec2 a_uv;\n\nvarying vec2 v_uv;\n\nvoid main() {\n gl_Position = a_position;\n v_uv = a_uv;\n}\n"),i.compileShader(e),i.getShaderParameter(e,i.COMPILE_STATUS)||console.error("An error occurred compiling the shaders: "+i.getShaderInfoLog(e));let t=i.createShader(i.FRAGMENT_SHADER);i.shaderSource(t,"\nprecision lowp float;\n\nvarying vec2 v_uv;\n\nuniform sampler2D u_texture;\n\nvoid main() {\n vec4 sample = texture2D(u_texture, v_uv);\n float grey = 0.299 * sample.r + 0.587 * sample.g + 0.114 * sample.b;\n gl_FragColor = vec4(grey, 0.0, 0.0, 1.0);\n}\n"),i.compileShader(t),i.getShaderParameter(t,i.COMPILE_STATUS)||console.error("An error occurred compiling the shaders: "+i.getShaderInfoLog(t));let n=i.createProgram();i.attachShader(n,e),i.attachShader(n,t),i.linkProgram(n),i.getProgramParameter(n,i.LINK_STATUS)||console.error("Unable to initialize the shader program: "+i.getProgramInfoLog(n)),i.useProgram(n),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,1,0,1,1,1,1,1,-1,-1,0,0,1,-1,1,0]),i.STATIC_DRAW);let r=i.getAttribLocation(n,"a_position");i.enableVertexAttribArray(r),i.vertexAttribPointer(r,2,i.FLOAT,!1,16,0);let o=i.getAttribLocation(n,"a_uv");i.enableVertexAttribArray(o),i.vertexAttribPointer(o,2,i.FLOAT,!1,16,8),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,i.createTexture()),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.uniform1i(i.getUniformLocation(n,"u_texture"),0)}(!this.glImgData||this.glImgData.length=this.maxVideoCvsLength&&(this.videoCvses=this.videoCvses.slice(1)),this.videoCvses.push(i));const n=i.dbrCtx2d;let r;A?n.drawImage(e,0,0):n.drawImage(e,_,d,h,u,0,0,g,E),R?(r=JSON.parse(JSON.stringify(t)),delete r.region):r=t;let o=yield this._decode_Canvas(i,r);if(R&&o.length>0)for(let e of o){let t=e.localizationResult;2==t.resultCoordinateType&&(t.x1*=.01*g,t.x2*=.01*g,t.x3*=.01*g,t.x4*=.01*g,t.y1*=.01*E,t.y2*=.01*E,t.y3*=.01*E,t.y4*=.01*E),t.x1+=_,t.x2+=_,t.x3+=_,t.x4+=_,t.y1+=d,t.y2+=d,t.y3+=d,t.y4+=d,2==t.resultCoordinateType&&(t.x1*=100/h,t.x2*=100/h,t.x3*=100/h,t.x4*=100/h,t.y1*=100/u,t.y2*=100/u,t.y3*=100/u,t.y4*=100/u)}return o}}))}_decode_Base64(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Base64(base64Str)"),"string"!=typeof e&&"object"!=typeof e)return Promise.reject("'_decode_Base64(base64Str, config)': Type of 'base64Str' should be 'String'.");if("data:image/"==e.substring(0,11)&&(e=e.substring(e.indexOf(",")+1)),_){let t=Buffer.from(e,"base64");return yield this._decodeFileInMemory_Uint8Array(new Uint8Array(t))}{let i=atob(e),n=i.length,r=new Uint8Array(n);for(;n--;)r[n]=i.charCodeAt(n);return yield this._decode_Blob(new Blob([r]),t)}}))}_decode_Url(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Url(url)"),"string"!=typeof e&&"object"!=typeof e)throw TypeError("'_decode_Url(url, config)': Type of 'url' should be 'String'.");if(_){let t=yield new Promise((t,n)=>{(e.startsWith("https")?i(1):i(2)).get(e,e=>{if(200==e.statusCode){let i=[];e.on("data",e=>{i.push(e)}).on("end",()=>{t(new Uint8Array(Buffer.concat(i)))})}else n("http get fail, statusCode: "+e.statusCode)})});return yield this._decodeFileInMemory_Uint8Array(t)}{let i=yield new Promise((t,i)=>{let n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="blob",n.send(),n.onloadend=()=>a(this,void 0,void 0,(function*(){t(n.response)})),n.onerror=()=>{i(new Error("Network Error: "+n.statusText))}});return yield this._decode_Blob(i,t)}}))}_decode_FilePath(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_FilePath(path)"),!_)throw Error("'_decode_FilePath(path, config)': The method is only supported in node environment.");if("string"!=typeof e&&"object"!=typeof e)throw TypeError("'_decode_FilePath(path, config)': Type of 'path' should be 'String'.");const t=i(3);let n=yield new Promise((i,n)=>{t.readFile(e,(e,t)=>{e?n(e):i(new Uint8Array(t))})});return yield this._decodeFileInMemory_Uint8Array(n)}))}static BarcodeReaderException(e,t){let i,n=r.DBR_UNKNOWN;return"number"==typeof e?(n=e,i=new Error(t)):i=new Error(e),i.code=n,i}_handleRetJsonString(e){let t=r;if(e.textResults){for(let t=0;t{let i=t.indexOf(":");e[t.substring(0,i)]=t.substring(i+1)}),i.exception=e}}return e.decodeRecords&&(this.decodeRecords=e.decodeRecords),this._lastErrorCode=e.exception,this._lastErrorString=e.description,e.textResults}if(e.exception==t.DBR_SUCCESS)return e.data;throw c.BarcodeReaderException(e.exception,e.description)}setModeArgument(e,t,i,n){return a(this,void 0,void 0,(function*(){return yield new Promise((r,o)=>{let s=c._nextTaskID++;c._taskCallbackMap.set(s,e=>{if(e.success){try{this._handleRetJsonString(e.setReturn)}catch(e){return o(e)}return r()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}}),c._dbrWorker.postMessage({type:"setModeArgument",id:s,instanceID:this._instanceID,body:{modeName:e,index:t,argumentName:i,argumentValue:n}})})}))}getModeArgument(e,t,i){return a(this,void 0,void 0,(function*(){return yield new Promise((n,r)=>{let o=c._nextTaskID++;c._taskCallbackMap.set(o,e=>{if(e.success){let t;try{t=this._handleRetJsonString(e.getReturn)}catch(e){return r(e)}return n(t)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,r(t)}}),c._dbrWorker.postMessage({type:"getModeArgument",id:o,instanceID:this._instanceID,body:{modeName:e,index:t,argumentName:i}})})}))}getIntermediateResults(){return a(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e(i.results);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"getIntermediateResults",id:i,instanceID:this._instanceID})})}))}getIntermediateCanvas(){return a(this,void 0,void 0,(function*(){let e=yield this.getIntermediateResults(),t=[];for(let i of e)if(i.dataType==o.IMRDT_IMAGE)for(let e of i.results){const i=e.bytes;let r;switch(c._onLog&&c._onLog(" "+i.length+" "+i.byteLength+" "+e.width+" "+e.height+" "+e.stride+" "+e.format),e.format){case n.IPF_ABGR_8888:r=new Uint8ClampedArray(i);break;case n.IPF_RGB_888:{const e=i.length/3;r=new Uint8ClampedArray(4*e);for(let t=0;t{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"destroy",id:i,instanceID:this._instanceID})})}}c.bNode=_,c._jsVersion="8.2.1",c._jsEditVersion="20210326",c._version="loading...(JS "+c._jsVersion+"."+c._jsEditVersion+")",c._productKeys=_||d||!document.currentScript?"":document.currentScript.getAttribute("data-productKeys")||document.currentScript.getAttribute("data-licenseKey")||document.currentScript.getAttribute("data-handshakeCode")||"",c._organizationID=_||d||!document.currentScript?"":document.currentScript.getAttribute("data-organizationID")||"",c.browserInfo=function(){if(!_&&!d){var e={init:function(){this.browser=this.searchString(this.dataBrowser)||"unknownBrowser",this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"unknownVersion",this.OS=this.searchString(this.dataOS)||"unknownOS"},searchString:function(e){for(var t=0;t{if(_)return url.fileURLToPath(import.meta.url.substring(0,import.meta.url.lastIndexOf("/")))+"/";if(!d&&document.currentScript){let e=document.currentScript.src,t=e.indexOf("?");if(-1!=t)e=e.substring(0,t);else{let t=e.indexOf("#");-1!=t&&(e=e.substring(0,t))}return e.substring(0,e.lastIndexOf("/")+1)}return"./"})(),c._licenseServer=[],c._deviceFriendlyName="",c._isShowRelDecodeTimeInResults=!1,c._bWasmDebug=!1,c._bSendSmallRecordsForDebug=!1,c.__bUseFullFeature=_,c._nextTaskID=0,c._taskCallbackMap=new Map,c._loadWasmStatus="unload",c._loadWasmCallbackArr=[],c._lastErrorCode=0,c._lastErrorString="";var h=function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{_(n.next(e))}catch(e){o(e)}}function a(e){try{_(n.throw(e))}catch(e){o(e)}}function _(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}_((n=n.apply(e,t||[])).next())}))};const u=!!("object"==typeof global&&global.process&&global.process.release&&global.process.release.name&&"undefined"==typeof HTMLCanvasElement);class g extends c{constructor(){super(),this.styleEls=[],this.videoSettings={video:{width:{ideal:1280},height:{ideal:720},facingMode:{ideal:"environment"}}},this._singleFrameMode=!(navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),this._singleFrameModeIpt=(()=>{let e=document.createElement("input");return e.setAttribute("type","file"),e.setAttribute("accept","image/*"),e.setAttribute("capture",""),e.addEventListener("change",()=>h(this,void 0,void 0,(function*(){let t=e.files[0];e.value="";let i=yield this.decode(t);for(let e of i)delete e.bUnduplicated;if(this._drawRegionsults(i),this.onFrameRead&&this._isOpen&&!this._bPauseScan&&this.onFrameRead(i),this.onUnduplicatedRead&&this._isOpen&&!this._bPauseScan)for(let e of i)this.onUnduplicatedRead(e.barcodeText,e);yield this.clearMapDecodeRecord()}))),e})(),this._clickIptSingleFrameMode=()=>{this._singleFrameModeIpt.click()},this.intervalTime=0,this._isOpen=!1,this._bPauseScan=!1,this._lastDeviceId=void 0,this._intervalDetectVideoPause=1e3,this._video=null,this._cvsDrawArea=null,this._divScanArea=null,this._divScanLight=null,this._bgLoading=null,this._bgCamera=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._soundOnSuccessfullRead=new Audio("data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA/+M4wAAAAAAAAAAAAEluZm8AAAAPAAAABQAAAkAAgICAgICAgICAgICAgICAgICAgKCgoKCgoKCgoKCgoKCgoKCgoKCgwMDAwMDAwMDAwMDAwMDAwMDAwMDg4ODg4ODg4ODg4ODg4ODg4ODg4P//////////////////////////AAAAAExhdmM1OC41NAAAAAAAAAAAAAAAACQEUQAAAAAAAAJAk0uXRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+MYxAANQAbGeUEQAAHZYZ3fASqD4P5TKBgocg+Bw/8+CAYBA4XB9/4EBAEP4nB9+UOf/6gfUCAIKyjgQ/Kf//wfswAAAwQA/+MYxAYOqrbdkZGQAMA7DJLCsQxNOij///////////+tv///3RWiZGBEhsf/FO/+LoCSFs1dFVS/g8f/4Mhv0nhqAieHleLy/+MYxAYOOrbMAY2gABf/////////////////usPJ66R0wI4boY9/8jQYg//g2SPx1M0N3Z0kVJLIs///Uw4aMyvHJJYmPBYG/+MYxAgPMALBucAQAoGgaBoFQVBUFQWDv6gZBUFQVBUGgaBr5YSgqCoKhIGg7+IQVBUFQVBoGga//SsFSoKnf/iVTEFNRTMu/+MYxAYAAANIAAAAADEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"),this.bPlaySoundOnSuccessfulRead=!1,this._allCameras=[],this._currentCamera=null,this._videoTrack=null,this.regionMaskFillStyle="rgba(0,0,0,0.5)",this.regionMaskStrokeStyle="rgb(254,142,20)",this.regionMaskLineWidth=2,this.barcodeFillStyle="rgba(254,180,32,0.3)",this.barcodeStrokeStyle="rgba(254,180,32,0.9)",this.barcodeLineWidth=1,this.beingLazyDrawRegionsults=!1,this._indexVideoRegion=-1,this._onCameraSelChange=()=>{this.play(this._selCam.value).then(()=>{this._isOpen||this.stop()}).catch(e=>{alert("Play video failed: "+(e.message||e))})},this._onResolutionSelChange=()=>{let e,t;if(this._selRsl&&-1!=this._selRsl.selectedIndex){let i=this._selRsl.options[this._selRsl.selectedIndex];e=i.getAttribute("data-width"),t=i.getAttribute("data-height")}this.play(void 0,e,t).then(()=>{this._isOpen||this.stop()}).catch(e=>{alert("Play video failed: "+(e.message||e))})},this._onCloseBtnClick=()=>{this.hide()}}static get defaultUIElementURL(){return this._defaultUIElementURL?this._defaultUIElementURL:c.engineResourcePath+"dbr.scanner.html"}static set defaultUIElementURL(e){this._defaultUIElementURL=e}getUIElement(){return this.UIElement}setUIElement(e){return h(this,void 0,void 0,(function*(){if("string"==typeof e||e instanceof String){if(!e.trim().startsWith("<")){let t=yield fetch(e);if(!t.ok)throw Error("Network Error: "+t.statusText);e=yield t.text()}if(!e.trim().startsWith("<"))throw Error("setUIElement(elementOrUrl): Can't get valid HTMLElement.");let t=document.createElement("div");t.innerHTML=e;for(let e=0;e{h(this,void 0,void 0,(function*(){let e=yield this.getScanSettings();e.oneDTrustFrameCount=1,yield this.updateScanSettings(e)}))})()}_assertOpen(){if(!this._isOpen)throw Error("The scanner is not open.")}get soundOnSuccessfullRead(){return this._soundOnSuccessfullRead}set soundOnSuccessfullRead(e){e instanceof HTMLAudioElement?this._soundOnSuccessfullRead=e:this._soundOnSuccessfullRead=new Audio(e)}set region(e){this._region=e,this.singleFrameMode||(this.beingLazyDrawRegionsults=!0,setTimeout(()=>{this.beingLazyDrawRegionsults&&this._drawRegionsults()},500))}get region(){return this._region}static createInstance(e){return h(this,void 0,void 0,(function*(){if(u)throw new Error("`BarcodeScanner` is not supported in Node.js.");let t=new g;t._instanceID=yield g.createInstanceInWorker(!0),("string"==typeof e||e instanceof String)&&(e=JSON.parse(e));for(let i in e)t[i]=e[i];return t.UIElement||(yield t.setUIElement(this.defaultUIElementURL)),t.singleFrameMode||(yield t.updateRuntimeSettings("single")),t}))}decode(e){return super.decode(e)}decodeBase64String(e){return super.decodeBase64String(e)}decodeUrl(e){return super.decodeUrl(e)}decodeBuffer(e,t,i,n,r,o){return super.decodeBuffer(e,t,i,n,r,o)}clearMapDecodeRecord(){return h(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"clearMapDecodeRecord",id:i,instanceID:this._instanceID})})}))}static isRegionSinglePreset(e){return JSON.stringify(e)==JSON.stringify(this.singlePresetRegion)}static isRegionNormalPreset(e){return 0==e.regionLeft&&0==e.regionTop&&0==e.regionRight&&0==e.regionBottom&&0==e.regionMeasuredByPercentage}updateRuntimeSettings(e){return h(this,void 0,void 0,(function*(){let t;if("string"==typeof e||"object"==typeof e&&e instanceof String)if("speed"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region)}else if("balance"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region),t.deblurLevel=3,t.expectedBarcodesCount=512,t.localizationModes=[2,16,0,0,0,0,0,0],t.timeout=1e5}else if("coverage"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region),t.deblurLevel=5,t.expectedBarcodesCount=512,t.scaleDownThreshold=1e5,t.localizationModes=[2,16,4,8,0,0,0,0],t.timeout=1e5}else if("single"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionNormalPreset(e.region)?t.region=JSON.parse(JSON.stringify(g.singlePresetRegion)):t.region=e.region,t.expectedBarcodesCount=1,t.localizationModes=[16,2,0,0,0,0,0,0],t.barcodeZoneMinDistanceToImageBorders=0}else t=JSON.parse(e);else{if("object"!=typeof e)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");if(t=JSON.parse(JSON.stringify(e)),t.region instanceof Array){let i=e.region;[i.regionLeft,i.regionTop,i.regionLeft,i.regionBottom,i.regionMeasuredByPercentage].some(e=>void 0!==e)&&(t.region={regionLeft:i.regionLeft||0,regionTop:i.regionTop||0,regionRight:i.regionRight||0,regionBottom:i.regionBottom||0,regionMeasuredByPercentage:i.regionMeasuredByPercentage||0})}}if(!c._bUseFullFeature){if(0!=(t.barcodeFormatIds&~(s.BF_ONED|s.BF_QR_CODE|s.BF_PDF417|s.BF_DATAMATRIX))||0!=t.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=t.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}if(this.bFilterRegionInJs){let e=t.region;if(this.userDefinedRegion=JSON.parse(JSON.stringify(e)),e instanceof Array)if(e.length){for(let t=0;t{let n=c._nextTaskID++;c._taskCallbackMap.set(n,t=>{if(t.success){try{this._handleRetJsonString(t.updateReturn)}catch(e){i(e)}return e()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}}),c._dbrWorker.postMessage({type:"updateRuntimeSettings",id:n,instanceID:this._instanceID,body:{settings:JSON.stringify(t)}})}),"single"==e&&(yield this.setModeArgument("BinarizationModes",0,"EnableFillBinaryVacancy","0"),yield this.setModeArgument("LocalizationModes",0,"ScanDirection","2"),yield this.setModeArgument("BinarizationModes",0,"BlockSizeX","71"),yield this.setModeArgument("BinarizationModes",0,"BlockSizeY","71"))}))}_bindUI(){let e=[this.UIElement],t=this.UIElement.children;for(let i of t)e.push(i);for(let t=0;t','','','','','','','',''].join(""),this._optGotRsl=this._optGotRsl||this._selRsl.options[0])):!this._optGotRsl&&t.classList.contains("dbrScanner-opt-gotResolution")?this._optGotRsl=t:!this._btnClose&&t.classList.contains("dbrScanner-btn-close")?this._btnClose=t:!this._video&&t.classList.contains("dbrScanner-existingVideo")?(this._video=t,this._video.setAttribute("playsinline","true"),this.singleFrameMode=!1):!i&&t.tagName&&"video"==t.tagName.toLowerCase()&&(i=t);if(!this._video&&i&&(this._video=i),this.singleFrameMode?(this._video&&(this._video.addEventListener("click",this._clickIptSingleFrameMode),this._video.style.cursor="pointer",this._video.setAttribute("title","Take a photo")),this._cvsDrawArea&&(this._cvsDrawArea.addEventListener("click",this._clickIptSingleFrameMode),this._cvsDrawArea.style.cursor="pointer",this._cvsDrawArea.setAttribute("title","Take a photo")),this._divScanArea&&(this._divScanArea.addEventListener("click",this._clickIptSingleFrameMode),this._divScanArea.style.cursor="pointer",this._divScanArea.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="")):this._bgLoading&&(this._bgLoading.style.display=""),this._selCam&&this._selCam.addEventListener("change",this._onCameraSelChange),this._selRsl&&this._selRsl.addEventListener("change",this._onResolutionSelChange),this._btnClose&&this._btnClose.addEventListener("click",this._onCloseBtnClick),!this._video)throw this._unbindUI(),Error("Can not find HTMLVideoElement with class `dbrScanner-video`.");this._isOpen=!0}_unbindUI(){this._clearRegionsults(),this.singleFrameMode?(this._video&&(this._video.removeEventListener("click",this._clickIptSingleFrameMode),this._video.style.cursor="",this._video.removeAttribute("title")),this._cvsDrawArea&&(this._cvsDrawArea.removeEventListener("click",this._clickIptSingleFrameMode),this._cvsDrawArea.style.cursor="",this._cvsDrawArea.removeAttribute("title")),this._divScanArea&&(this._divScanArea.removeEventListener("click",this._clickIptSingleFrameMode),this._divScanArea.style.cursor="",this._divScanArea.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none")):this._bgLoading&&(this._bgLoading.style.display="none"),this._selCam&&this._selCam.removeEventListener("change",this._onCameraSelChange),this._selRsl&&this._selRsl.removeEventListener("change",this._onResolutionSelChange),this._btnClose&&this._btnClose.removeEventListener("click",this._onCloseBtnClick),this._video=null,this._cvsDrawArea=null,this._divScanArea=null,this._divScanLight=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._isOpen=!1}_renderSelCameraInfo(){let e,t;if(this._selCam&&(e=this._selCam.value,this._selCam.innerHTML=""),this._selCam){for(let i of this._allCameras){let n=document.createElement("option");n.value=i.deviceId,n.innerText=i.label,this._selCam.append(n),e==i.deviceId&&(t=n)}let i=this._selCam.childNodes;if(!t&&this._currentCamera&&i.length)for(let e of i)if(this._currentCamera.label==e.innerText){t=e;break}t&&(this._selCam.value=t.value)}}getAllCameras(){return h(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices(),t=[];let i=0;for(let n=0;n{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success){let t=i.results;return t.intervalTime=this.intervalTime,e(t)}{let e=new Error(i.message);return e.stack+="\n"+i.stack,t(e)}}),c._dbrWorker.postMessage({type:"getScanSettings",id:i,instanceID:this._instanceID})})}))}updateScanSettings(e){return h(this,void 0,void 0,(function*(){return this.intervalTime=e.intervalTime,yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack+="\n"+e.stack,i(t)}}),g._dbrWorker.postMessage({type:"updateScanSettings",id:n,instanceID:this._instanceID,body:{settings:e}})})}))}getVideoSettings(){return JSON.parse(JSON.stringify(this.videoSettings))}updateVideoSettings(e){return this.videoSettings=JSON.parse(JSON.stringify(e)),this._lastDeviceId=null,this._isOpen?this.play():Promise.resolve()}isOpen(){return this._isOpen}_show(){this.UIElement.parentNode||(this.UIElement.style.position="fixed",this.UIElement.style.left="0",this.UIElement.style.top="0",document.body.append(this.UIElement)),"none"==this.UIElement.style.display&&(this.UIElement.style.display="")}stop(){this._video&&this._video.srcObject&&(c._onLog&&c._onLog("======stop video========"),this._video.srcObject.getTracks().forEach(e=>{e.stop()}),this._video.srcObject=null,this._videoTrack=null),this._video&&this._video.classList.contains("dbrScanner-existingVideo")&&(c._onLog&&c._onLog("======stop existing video========"),this._video.pause(),this._video.currentTime=0),this._bgLoading&&(this._bgLoading.style.animationPlayState=""),this._divScanLight&&(this._divScanLight.style.display="none")}pause(){this._video&&this._video.pause(),this._divScanLight&&(this._divScanLight.style.display="none")}play(e,t,i){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.singleFrameMode)return this._clickIptSingleFrameMode(),{width:0,height:0};if(this._video&&this._video.classList.contains("dbrScanner-existingVideo")){yield this._video.play();let e={width:this._video.videoWidth,height:this._video.videoHeight};return this.onPlayed&&setTimeout(()=>{this.onPlayed(e)},0),e}if(this._video&&this._video.srcObject&&(this.stop(),yield new Promise(e=>setTimeout(e,500))),c._onLog&&c._onLog("======before video========"),"Android"==c.browserInfo.OS&&(yield this.getAllCameras()),this.bDestroyed)throw new Error("The BarcodeScanner instance has been destroyed.");const n=this.videoSettings;"boolean"==typeof n.video&&(n.video={});const r="iPhone"==c.browserInfo.OS;let o,s;if(r?t>=1280||i>=1280?n.video.width=1280:t>=640||i>=640?n.video.width=640:(t<640||i<640)&&(n.video.width=320):(t&&(n.video.width={ideal:t}),i&&(n.video.height={ideal:i})),e)delete n.video.facingMode,n.video.deviceId={exact:e},this._lastDeviceId=e;else if(n.video.deviceId);else if(this._lastDeviceId)delete n.video.facingMode,n.video.deviceId={ideal:this._lastDeviceId};else if(n.video.facingMode){let e=n.video.facingMode;if(e instanceof Array&&e.length&&(e=e[0]),e=e.exact||e.ideal||e,"environment"===e){for(let e of this._allCameras){let t=e.label.toLowerCase();if(t&&-1!=t.indexOf("facing back")&&/camera[0-9]?\s0,/.test(t)){delete n.video.facingMode,n.video.deviceId={ideal:e.deviceId};break}}o=!!n.video.facingMode}}c._onLog&&c._onLog("======try getUserMedia========"),c._onLog&&c._onLog("ask "+JSON.stringify(n.video.width)+"x"+JSON.stringify(n.video.height));try{c._onLog&&c._onLog(n),s=yield navigator.mediaDevices.getUserMedia(n)}catch(e){c._onLog&&c._onLog(e),c._onLog&&c._onLog("======try getUserMedia again========"),r?(delete n.video.width,delete n.video.height):o?(delete n.video.facingMode,this._allCameras.length&&(n.video.deviceId={ideal:this._allCameras[this._allCameras.length-1].deviceId})):n.video=!0,c._onLog&&c._onLog(n),s=yield navigator.mediaDevices.getUserMedia(n)}if(this.bDestroyed)throw s.getTracks().forEach(e=>{e.stop()}),new Error("The BarcodeScanner instance has been destroyed.");{const e=s.getVideoTracks();e.length&&(this._videoTrack=e[0])}this._video.srcObject=s,c._onLog&&c._onLog("======play video========");try{yield this._video.play()}catch(e){c._onLog&&c._onLog("======play video again========"),yield new Promise(e=>{setTimeout(e,1e3)}),yield this._video.play()}c._onLog&&c._onLog("======played video========"),this._bgLoading&&(this._bgLoading.style.animationPlayState="paused"),this._drawRegionsults();const a="got "+this._video.videoWidth+"x"+this._video.videoHeight;this._optGotRsl&&(this._optGotRsl.setAttribute("data-width",this._video.videoWidth),this._optGotRsl.setAttribute("data-height",this._video.videoHeight),this._optGotRsl.innerText=a,this._selRsl&&this._optGotRsl.parentNode==this._selRsl&&(this._selRsl.value="got")),c._onLog&&c._onLog(a),"Android"!==c.browserInfo.OS&&(yield this.getAllCameras()),yield this.getCurrentCamera(),this._renderSelCameraInfo();let _={width:this._video.videoWidth,height:this._video.videoHeight};return this.onPlayed&&setTimeout(()=>{this.onPlayed(_)},0),_}))}pauseScan(){this._assertOpen(),this._bPauseScan=!0,this._divScanLight&&(this._divScanLight.style.display="none")}resumeScan(){this._assertOpen(),this._bPauseScan=!1}getCapabilities(){return this._assertOpen(),this._videoTrack.getCapabilities?this._videoTrack.getCapabilities():{}}getCameraSettings(){return this._assertOpen(),this._videoTrack.getSettings()}getConstraints(){return this._assertOpen(),this._videoTrack.getConstraints()}applyConstraints(e){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),!this._videoTrack.applyConstraints)throw Error("Not supported.");return yield this._videoTrack.applyConstraints(e)}))}turnOnTorch(){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.getCapabilities().torch)return yield this._videoTrack.applyConstraints({advanced:[{torch:!0}]});throw Error("Not supported.")}))}turnOffTorch(){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.getCapabilities().torch)return yield this._videoTrack.applyConstraints({advanced:[{torch:!1}]});throw Error("Not supported.")}))}setColorTemperature(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().colorTemperature;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{colorTemperature:e}]})}))}setExposureCompensation(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().exposureCompensation;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{exposureCompensation:e}]})}))}setZoom(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().zoom;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{zoom:e}]})}))}setFrameRate(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().frameRate;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({width:{ideal:Math.max(this._video.videoWidth,this._video.videoHeight)},frameRate:e})}))}_cloneDecodeResults(e){if(e instanceof Array){let t=[];for(let i of e)t.push(this._cloneDecodeResults(i));return t}{let t=e;return JSON.parse(JSON.stringify(t,(e,t)=>"oriVideoCanvas"==e||"searchRegionCanvas"==e?void 0:t))}}_loopReadVideo(){return h(this,void 0,void 0,(function*(){if(this.bDestroyed)return;if(!this._isOpen)return void(yield this.clearMapDecodeRecord());if(this._video.paused||this._bPauseScan)return c._onLog&&c._onLog("Video or scan is paused. Ask in 1s."),yield this.clearMapDecodeRecord(),void setTimeout(()=>{this._loopReadVideo()},this._intervalDetectVideoPause);this._divScanLight&&"none"==this._divScanLight.style.display&&(this._divScanLight.style.display=""),c._onLog&&c._onLog("======= once read =======");(new Date).getTime();c._onLog&&(this._timeStartDecode=Date.now());let e={};if(this.region)if(this.region instanceof Array){++this._indexVideoRegion>=this.region.length&&(this._indexVideoRegion=0);let t=this.region[this._indexVideoRegion];t&&(e.region=JSON.parse(JSON.stringify(t)))}else e.region=JSON.parse(JSON.stringify(this.region));this._decode_Video(this._video,e).then(e=>{if(c._onLog&&c._onLog(e),this._isOpen&&!this._video.paused&&!this._bPauseScan){if(this.bPlaySoundOnSuccessfulRead&&e.length){let t=!1;if(!0===this.bPlaySoundOnSuccessfulRead||"frame"===this.bPlaySoundOnSuccessfulRead)t=!0;else if("unduplicated"===this.bPlaySoundOnSuccessfulRead)for(let i of e)if(i.bUnduplicated){t=!0;break}t&&(this.soundOnSuccessfullRead.currentTime=0,this.soundOnSuccessfullRead.play().catch(e=>{console.warn("Autoplay not allowed. User interaction required.")}))}if(this.onFrameRead){let t=this._cloneDecodeResults(e);for(let e of t)delete e.bUnduplicated;this.onFrameRead(t)}if(this.onUnduplicatedRead)for(let t of e)t.bUnduplicated&&this.onUnduplicatedRead(t.barcodeText,this._cloneDecodeResults(t));this._drawRegionsults(e)}setTimeout(()=>{this._loopReadVideo()},this.intervalTime)}).catch(e=>{if(c._onLog&&c._onLog(e.message||e),setTimeout(()=>{this._loopReadVideo()},Math.max(this.intervalTime,1e3)),"platform error"!=e.message)throw console.error(e.message),e})}))}_drawRegionsults(e){let t,i,n;if(this.beingLazyDrawRegionsults=!1,this.singleFrameMode){if(!this.oriCanvas)return;t="contain",i=this.oriCanvas.width,n=this.oriCanvas.height}else{if(!this._video)return;t=this._video.style.objectFit||"contain",i=this._video.videoWidth,n=this._video.videoHeight}let r=this.region;if(r&&(!r.regionLeft&&!r.regionRight&&!r.regionTop&&!r.regionBottom&&!r.regionMeasuredByPercentage||r instanceof Array?r=null:r.regionMeasuredByPercentage?r=r.regionLeft||r.regionRight||100!==r.regionTop||100!==r.regionBottom?{regionLeft:Math.round(r.regionLeft/100*i),regionTop:Math.round(r.regionTop/100*n),regionRight:Math.round(r.regionRight/100*i),regionBottom:Math.round(r.regionBottom/100*n)}:null:(r=JSON.parse(JSON.stringify(r)),delete r.regionMeasuredByPercentage)),this._cvsDrawArea){this._cvsDrawArea.style.objectFit=t;let o=this._cvsDrawArea;o.width=i,o.height=n;let s=o.getContext("2d");if(r){s.fillStyle=this.regionMaskFillStyle,s.fillRect(0,0,o.width,o.height),s.globalCompositeOperation="destination-out",s.fillStyle="#000";let e=Math.round(this.regionMaskLineWidth/2);s.fillRect(r.regionLeft-e,r.regionTop-e,r.regionRight-r.regionLeft+2*e,r.regionBottom-r.regionTop+2*e),s.globalCompositeOperation="source-over",s.strokeStyle=this.regionMaskStrokeStyle,s.lineWidth=this.regionMaskLineWidth,s.rect(r.regionLeft,r.regionTop,r.regionRight-r.regionLeft,r.regionBottom-r.regionTop),s.stroke()}if(e){s.globalCompositeOperation="destination-over",s.fillStyle=this.barcodeFillStyle,s.strokeStyle=this.barcodeStrokeStyle,s.lineWidth=this.barcodeLineWidth,e=e||[];for(let t of e){let e=t.localizationResult;s.beginPath(),s.moveTo(e.x1,e.y1),s.lineTo(e.x2,e.y2),s.lineTo(e.x3,e.y3),s.lineTo(e.x4,e.y4),s.fill(),s.beginPath(),s.moveTo(e.x1,e.y1),s.lineTo(e.x2,e.y2),s.lineTo(e.x3,e.y3),s.lineTo(e.x4,e.y4),s.closePath(),s.stroke()}}this.singleFrameMode&&(s.globalCompositeOperation="destination-over",s.drawImage(this.oriCanvas,0,0))}if(this._divScanArea){let e=this._video.offsetWidth,t=this._video.offsetHeight,o=1;e/tsuper.destroy}});return h(this,void 0,void 0,(function*(){this.close();for(let e of this.styleEls)e.remove();this.styleEls.splice(0,this.styleEls.length),this.bDestroyed||(yield e.destroy.call(this))}))}}var E,R,A,I,f,D,T,S,m,M,C,p,v,y,L,O,N,B,b,P,F,w,U,k,V,G,x,W,H,K;g.singlePresetRegion=[null,{regionLeft:0,regionTop:30,regionRight:100,regionBottom:70,regionMeasuredByPercentage:1},{regionLeft:25,regionTop:25,regionRight:75,regionBottom:75,regionMeasuredByPercentage:1},{regionLeft:25,regionTop:25,regionRight:75,regionBottom:75,regionMeasuredByPercentage:1}],function(e){e[e.BICM_DARK_ON_LIGHT=1]="BICM_DARK_ON_LIGHT",e[e.BICM_LIGHT_ON_DARK=2]="BICM_LIGHT_ON_DARK",e[e.BICM_DARK_ON_DARK=4]="BICM_DARK_ON_DARK",e[e.BICM_LIGHT_ON_LIGHT=8]="BICM_LIGHT_ON_LIGHT",e[e.BICM_DARK_LIGHT_MIXED=16]="BICM_DARK_LIGHT_MIXED",e[e.BICM_DARK_ON_LIGHT_DARK_SURROUNDING=32]="BICM_DARK_ON_LIGHT_DARK_SURROUNDING",e[e.BICM_SKIP=0]="BICM_SKIP",e[e.BICM_REV=2147483648]="BICM_REV"}(E||(E={})),function(e){e[e.BCM_AUTO=1]="BCM_AUTO",e[e.BCM_GENERAL=2]="BCM_GENERAL",e[e.BCM_SKIP=0]="BCM_SKIP",e[e.BCM_REV=2147483648]="BCM_REV"}(R||(R={})),function(e){e[e.BF2_NULL=0]="BF2_NULL",e[e.BF2_POSTALCODE=32505856]="BF2_POSTALCODE",e[e.BF2_NONSTANDARD_BARCODE=1]="BF2_NONSTANDARD_BARCODE",e[e.BF2_USPSINTELLIGENTMAIL=1048576]="BF2_USPSINTELLIGENTMAIL",e[e.BF2_POSTNET=2097152]="BF2_POSTNET",e[e.BF2_PLANET=4194304]="BF2_PLANET",e[e.BF2_AUSTRALIANPOST=8388608]="BF2_AUSTRALIANPOST",e[e.BF2_RM4SCC=16777216]="BF2_RM4SCC",e[e.BF2_DOTCODE=2]="BF2_DOTCODE"}(A||(A={})),function(e){e[e.BM_AUTO=1]="BM_AUTO",e[e.BM_LOCAL_BLOCK=2]="BM_LOCAL_BLOCK",e[e.BM_SKIP=0]="BM_SKIP",e[e.BM_THRESHOLD=4]="BM_THRESHOLD",e[e.BM_REV=2147483648]="BM_REV"}(I||(I={})),function(e){e[e.ECCM_CONTRAST=1]="ECCM_CONTRAST"}(f||(f={})),function(e){e[e.CFM_GENERAL=1]="CFM_GENERAL"}(D||(D={})),function(e){e[e.CCM_AUTO=1]="CCM_AUTO",e[e.CCM_GENERAL_HSV=2]="CCM_GENERAL_HSV",e[e.CCM_SKIP=0]="CCM_SKIP",e[e.CCM_REV=2147483648]="CCM_REV"}(T||(T={})),function(e){e[e.CICM_GENERAL=1]="CICM_GENERAL",e[e.CICM_SKIP=0]="CICM_SKIP",e[e.CICM_REV=2147483648]="CICM_REV"}(S||(S={})),function(e){e[e.CM_IGNORE=1]="CM_IGNORE",e[e.CM_OVERWRITE=2]="CM_OVERWRITE"}(m||(m={})),function(e){e[e.DM_SKIP=0]="DM_SKIP",e[e.DM_DIRECT_BINARIZATION=1]="DM_DIRECT_BINARIZATION",e[e.DM_THRESHOLD_BINARIZATION=2]="DM_THRESHOLD_BINARIZATION",e[e.DM_GRAY_EQUALIZATION=4]="DM_GRAY_EQUALIZATION",e[e.DM_SMOOTHING=8]="DM_SMOOTHING",e[e.DM_MORPHING=16]="DM_MORPHING",e[e.DM_DEEP_ANALYSIS=32]="DM_DEEP_ANALYSIS",e[e.DM_SHARPENING=64]="DM_SHARPENING"}(M||(M={})),function(e){e[e.DRM_AUTO=1]="DRM_AUTO",e[e.DRM_GENERAL=2]="DRM_GENERAL",e[e.DRM_SKIP=0]="DRM_SKIP",e[e.DRM_REV=2147483648]="DRM_REV"}(C||(C={})),function(e){e[e.DPMCRM_AUTO=1]="DPMCRM_AUTO",e[e.DPMCRM_GENERAL=2]="DPMCRM_GENERAL",e[e.DPMCRM_SKIP=0]="DPMCRM_SKIP",e[e.DPMCRM_REV=2147483648]="DPMCRM_REV"}(p||(p={})),function(e){e[e.GTM_INVERTED=1]="GTM_INVERTED",e[e.GTM_ORIGINAL=2]="GTM_ORIGINAL",e[e.GTM_SKIP=0]="GTM_SKIP",e[e.GTM_REV=2147483648]="GTM_REV"}(v||(v={})),function(e){e[e.IPM_AUTO=1]="IPM_AUTO",e[e.IPM_GENERAL=2]="IPM_GENERAL",e[e.IPM_GRAY_EQUALIZE=4]="IPM_GRAY_EQUALIZE",e[e.IPM_GRAY_SMOOTH=8]="IPM_GRAY_SMOOTH",e[e.IPM_SHARPEN_SMOOTH=16]="IPM_SHARPEN_SMOOTH",e[e.IPM_MORPHOLOGY=32]="IPM_MORPHOLOGY",e[e.IPM_SKIP=0]="IPM_SKIP",e[e.IPM_REV=2147483648]="IPM_REV"}(y||(y={})),function(e){e[e.IRSM_MEMORY=1]="IRSM_MEMORY",e[e.IRSM_FILESYSTEM=2]="IRSM_FILESYSTEM",e[e.IRSM_BOTH=4]="IRSM_BOTH"}(L||(L={})),function(e){e[e.IRT_NO_RESULT=0]="IRT_NO_RESULT",e[e.IRT_ORIGINAL_IMAGE=1]="IRT_ORIGINAL_IMAGE",e[e.IRT_COLOUR_CLUSTERED_IMAGE=2]="IRT_COLOUR_CLUSTERED_IMAGE",e[e.IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE=4]="IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE",e[e.IRT_TRANSFORMED_GRAYSCALE_IMAGE=8]="IRT_TRANSFORMED_GRAYSCALE_IMAGE",e[e.IRT_PREDETECTED_REGION=16]="IRT_PREDETECTED_REGION",e[e.IRT_PREPROCESSED_IMAGE=32]="IRT_PREPROCESSED_IMAGE",e[e.IRT_BINARIZED_IMAGE=64]="IRT_BINARIZED_IMAGE",e[e.IRT_TEXT_ZONE=128]="IRT_TEXT_ZONE",e[e.IRT_CONTOUR=256]="IRT_CONTOUR",e[e.IRT_LINE_SEGMENT=512]="IRT_LINE_SEGMENT",e[e.IRT_FORM=1024]="IRT_FORM",e[e.IRT_SEGMENTATION_BLOCK=2048]="IRT_SEGMENTATION_BLOCK",e[e.IRT_TYPED_BARCODE_ZONE=4096]="IRT_TYPED_BARCODE_ZONE",e[e.IRT_PREDETECTED_QUADRILATERAL=8192]="IRT_PREDETECTED_QUADRILATERAL"}(O||(O={})),function(e){e[e.LM_SKIP=0]="LM_SKIP",e[e.LM_AUTO=1]="LM_AUTO",e[e.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",e[e.LM_LINES=8]="LM_LINES",e[e.LM_STATISTICS=4]="LM_STATISTICS",e[e.LM_SCAN_DIRECTLY=16]="LM_SCAN_DIRECTLY",e[e.LM_STATISTICS_MARKS=32]="LM_STATISTICS_MARKS",e[e.LM_STATISTICS_POSTAL_CODE=64]="LM_STATISTICS_POSTAL_CODE",e[e.LM_CENTRE=128]="LM_CENTRE",e[e.LM_REV=2147483648]="LM_REV"}(N||(N={})),function(e){e[e.PDFRM_RASTER=1]="PDFRM_RASTER",e[e.PDFRM_AUTO=2]="PDFRM_AUTO",e[e.PDFRM_VECTOR=4]="PDFRM_VECTOR",e[e.PDFRM_REV=2147483648]="PDFRM_REV"}(B||(B={})),function(e){e[e.QRECL_ERROR_CORRECTION_H=0]="QRECL_ERROR_CORRECTION_H",e[e.QRECL_ERROR_CORRECTION_L=1]="QRECL_ERROR_CORRECTION_L",e[e.QRECL_ERROR_CORRECTION_M=2]="QRECL_ERROR_CORRECTION_M",e[e.QRECL_ERROR_CORRECTION_Q=3]="QRECL_ERROR_CORRECTION_Q"}(b||(b={})),function(e){e[e.RPM_AUTO=1]="RPM_AUTO",e[e.RPM_GENERAL=2]="RPM_GENERAL",e[e.RPM_GENERAL_RGB_CONTRAST=4]="RPM_GENERAL_RGB_CONTRAST",e[e.RPM_GENERAL_GRAY_CONTRAST=8]="RPM_GENERAL_GRAY_CONTRAST",e[e.RPM_GENERAL_HSV_CONTRAST=16]="RPM_GENERAL_HSV_CONTRAST",e[e.RPM_SKIP=0]="RPM_SKIP",e[e.RPM_REV=2147483648]="RPM_REV"}(P||(P={})),function(e){e[e.RCT_PIXEL=1]="RCT_PIXEL",e[e.RCT_PERCENTAGE=2]="RCT_PERCENTAGE"}(F||(F={})),function(e){e[e.RT_STANDARD_TEXT=0]="RT_STANDARD_TEXT",e[e.RT_RAW_TEXT=1]="RT_RAW_TEXT",e[e.RT_CANDIDATE_TEXT=2]="RT_CANDIDATE_TEXT",e[e.RT_PARTIAL_TEXT=3]="RT_PARTIAL_TEXT"}(w||(w={})),function(e){e[e.SUM_AUTO=1]="SUM_AUTO",e[e.SUM_LINEAR_INTERPOLATION=2]="SUM_LINEAR_INTERPOLATION",e[e.SUM_NEAREST_NEIGHBOUR_INTERPOLATION=4]="SUM_NEAREST_NEIGHBOUR_INTERPOLATION",e[e.SUM_SKIP=0]="SUM_SKIP",e[e.SUM_REV=2147483648]="SUM_REV"}(U||(U={})),function(e){e[e.TP_REGION_PREDETECTED=1]="TP_REGION_PREDETECTED",e[e.TP_IMAGE_PREPROCESSED=2]="TP_IMAGE_PREPROCESSED",e[e.TP_IMAGE_BINARIZED=4]="TP_IMAGE_BINARIZED",e[e.TP_BARCODE_LOCALIZED=8]="TP_BARCODE_LOCALIZED",e[e.TP_BARCODE_TYPE_DETERMINED=16]="TP_BARCODE_TYPE_DETERMINED",e[e.TP_BARCODE_RECOGNIZED=32]="TP_BARCODE_RECOGNIZED"}(k||(k={})),function(e){e[e.TACM_AUTO=1]="TACM_AUTO",e[e.TACM_VERIFYING=2]="TACM_VERIFYING",e[e.TACM_VERIFYING_PATCHING=4]="TACM_VERIFYING_PATCHING",e[e.TACM_SKIP=0]="TACM_SKIP",e[e.TACM_REV=2147483648]="TACM_REV"}(V||(V={})),function(e){e[e.TFM_AUTO=1]="TFM_AUTO",e[e.TFM_GENERAL_CONTOUR=2]="TFM_GENERAL_CONTOUR",e[e.TFM_SKIP=0]="TFM_SKIP",e[e.TFM_REV=2147483648]="TFM_REV"}(G||(G={})),function(e){e[e.TROM_CONFIDENCE=1]="TROM_CONFIDENCE",e[e.TROM_POSITION=2]="TROM_POSITION",e[e.TROM_FORMAT=4]="TROM_FORMAT",e[e.TROM_SKIP=0]="TROM_SKIP",e[e.TROM_REV=2147483648]="TROM_REV"}(x||(x={})),function(e){e[e.TDM_AUTO=1]="TDM_AUTO",e[e.TDM_GENERAL_WIDTH_CONCENTRATION=2]="TDM_GENERAL_WIDTH_CONCENTRATION",e[e.TDM_SKIP=0]="TDM_SKIP",e[e.TDM_REV=2147483648]="TDM_REV"}(W||(W={})),function(e){e.DM_LM_ONED="1",e.DM_LM_QR_CODE="2",e.DM_LM_PDF417="3",e.DM_LM_DATAMATRIX="4",e.DM_LM_AZTEC="5",e.DM_LM_MAXICODE="6",e.DM_LM_PATCHCODE="7",e.DM_LM_GS1_DATABAR="8",e.DM_LM_GS1_COMPOSITE="9",e.DM_LM_POSTALCODE="10",e.DM_LM_DOTCODE="11",e.DM_LM_INTERMEDIATE_RESULT="12",e.DM_LM_DPM="13",e.DM_LM_NONSTANDARD_BARCODE="16"}(H||(H={})),function(e){e.DM_CW_AUTO="",e.DM_CW_DEVICE_COUNT="DeviceCount",e.DM_CW_SCAN_COUNT="ScanCount",e.DM_CW_CONCURRENT_DEVICE_COUNT="ConcurrentDeviceCount",e.DM_CW_APP_DOMIAN_COUNT="Domain",e.DM_CW_ACTIVE_DEVICE_COUNT="ActiveDeviceCount",e.DM_CW_INSTANCE_COUNT="InstanceCount",e.DM_CW_CONCURRENT_INSTANCE_COUNT="ConcurrentInstanceCount"}(K||(K={}));const J={BarcodeReader:c,BarcodeScanner:g,EnumBarcodeColourMode:E,EnumBarcodeComplementMode:R,EnumBarcodeFormat:s,EnumBarcodeFormat_2:A,EnumBinarizationMode:I,EnumClarityCalculationMethod:f,EnumClarityFilterMode:D,EnumColourClusteringMode:T,EnumColourConversionMode:S,EnumConflictMode:m,EnumDeblurMode:M,EnumDeformationResistingMode:C,EnumDPMCodeReadingMode:p,EnumErrorCode:r,EnumGrayscaleTransformationMode:v,EnumImagePixelFormat:n,EnumImagePreprocessingMode:y,EnumIMResultDataType:o,EnumIntermediateResultSavingMode:L,EnumIntermediateResultType:O,EnumLocalizationMode:N,EnumPDFReadingMode:B,EnumQRCodeErrorCorrectionLevel:b,EnumRegionPredetectionMode:P,EnumResultCoordinateType:F,EnumResultType:w,EnumScaleUpMode:U,EnumTerminatePhase:k,EnumTextAssistedCorrectionMode:V,EnumTextFilterMode:G,EnumTextResultOrderMode:x,EnumTextureDetectionMode:W,EnumLicenseModule:H,EnumChargeWay:K};t.default=J}])}));const DBR={};{let _dbr;if(typeof dbr=="object"){_dbr=dbr;}else if(typeof module=="object"&&module.exports&&module.exports.default){_dbr=module.exports.default;}else if(typeof exports=="object"&&exports.dbr){_dbr=exports.dbr;}for(let key in _dbr){DBR[key]=_dbr[key];}}export default DBR;export const BarcodeReader=DBR.BarcodeReader;export const BarcodeScanner=DBR.BarcodeScanner;export const EnumBarcodeColourMode=DBR.EnumBarcodeColourMode;export const EnumBarcodeComplementMode=DBR.EnumBarcodeComplementMode;export const EnumBarcodeFormat=DBR.EnumBarcodeFormat;export const EnumBarcodeFormat_2=DBR.EnumBarcodeFormat_2;export const EnumBinarizationMode=DBR.EnumBinarizationMode;export const EnumClarityCalculationMethod=DBR.EnumClarityCalculationMethod;export const EnumClarityFilterMode=DBR.EnumClarityFilterMode;export const EnumColourClusteringMode=DBR.EnumColourClusteringMode;export const EnumColourConversionMode=DBR.EnumColourConversionMode;export const EnumConflictMode=DBR.EnumConflictMode;export const EnumDeblurMode=DBR.EnumDeblurMode;export const EnumDeformationResistingMode=DBR.EnumDeformationResistingMode;export const EnumDPMCodeReadingMode=DBR.EnumDPMCodeReadingMode;export const EnumErrorCode=DBR.EnumErrorCode;export const EnumGrayscaleTransformationMode=DBR.EnumGrayscaleTransformationMode;export const EnumImagePixelFormat=DBR.EnumImagePixelFormat;export const EnumImagePreprocessingMode=DBR.EnumImagePreprocessingMode;export const EnumIMResultDataType=DBR.EnumIMResultDataType;export const EnumIntermediateResultSavingMode=DBR.EnumIntermediateResultSavingMode;export const EnumIntermediateResultType=DBR.EnumIntermediateResultType;export const EnumLocalizationMode=DBR.EnumLocalizationMode;export const EnumPDFReadingMode=DBR.EnumPDFReadingMode;export const EnumQRCodeErrorCorrectionLevel=DBR.EnumQRCodeErrorCorrectionLevel;export const EnumRegionPredetectionMode=DBR.EnumRegionPredetectionMode;export const EnumResultCoordinateType=DBR.EnumResultCoordinateType;export const EnumResultType=DBR.EnumResultType;export const EnumScaleUpMode=DBR.EnumScaleUpMode;export const EnumTerminatePhase=DBR.EnumTerminatePhase;export const EnumTextAssistedCorrectionMode=DBR.EnumTextAssistedCorrectionMode;export const EnumTextFilterMode=DBR.EnumTextFilterMode;export const EnumTextResultOrderMode=DBR.EnumTextResultOrderMode;export const EnumTextureDetectionMode=DBR.EnumTextureDetectionMode;export const EnumLicenseModule=DBR.EnumLicenseModule;export const EnumChargeWay=DBR.EnumChargeWay;
\ No newline at end of file
+import worker_threads from "worker_threads";import https from "https";import http from "http";import fs from "fs";import os from "os";import url from "url";!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(worker_threads,https,http,fs,os):"function"==typeof define&&define.amd?define(t):"object"==typeof exports?exports.dbr=t(worker_threads,https,http,fs,os):e.dbr=t(e.worker_threads,e.https,e.http,e.fs,e.os)}(("object"==typeof window?window:global),(function(e,t,i,n,r){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=5)}([function(t,i){t.exports=e},function(e,i){e.exports=t},function(e,t){e.exports=i},function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t,i){"use strict";var n,r,o,s;i.r(t),i.d(t,"BarcodeReader",(function(){return c})),i.d(t,"BarcodeScanner",(function(){return g})),i.d(t,"EnumBarcodeColourMode",(function(){return E})),i.d(t,"EnumBarcodeComplementMode",(function(){return R})),i.d(t,"EnumBarcodeFormat",(function(){return s})),i.d(t,"EnumBarcodeFormat_2",(function(){return I})),i.d(t,"EnumBinarizationMode",(function(){return A})),i.d(t,"EnumClarityCalculationMethod",(function(){return f})),i.d(t,"EnumClarityFilterMode",(function(){return D})),i.d(t,"EnumColourClusteringMode",(function(){return T})),i.d(t,"EnumColourConversionMode",(function(){return S})),i.d(t,"EnumConflictMode",(function(){return m})),i.d(t,"EnumDeblurMode",(function(){return M})),i.d(t,"EnumDeformationResistingMode",(function(){return C})),i.d(t,"EnumDPMCodeReadingMode",(function(){return v})),i.d(t,"EnumErrorCode",(function(){return r})),i.d(t,"EnumGrayscaleTransformationMode",(function(){return p})),i.d(t,"EnumImagePixelFormat",(function(){return n})),i.d(t,"EnumImagePreprocessingMode",(function(){return L})),i.d(t,"EnumIMResultDataType",(function(){return o})),i.d(t,"EnumIntermediateResultSavingMode",(function(){return y})),i.d(t,"EnumIntermediateResultType",(function(){return O})),i.d(t,"EnumLocalizationMode",(function(){return N})),i.d(t,"EnumPDFReadingMode",(function(){return B})),i.d(t,"EnumQRCodeErrorCorrectionLevel",(function(){return b})),i.d(t,"EnumRegionPredetectionMode",(function(){return P})),i.d(t,"EnumResultCoordinateType",(function(){return F})),i.d(t,"EnumResultType",(function(){return w})),i.d(t,"EnumScaleUpMode",(function(){return U})),i.d(t,"EnumTerminatePhase",(function(){return V})),i.d(t,"EnumTextAssistedCorrectionMode",(function(){return k})),i.d(t,"EnumTextFilterMode",(function(){return G})),i.d(t,"EnumTextResultOrderMode",(function(){return x})),i.d(t,"EnumTextureDetectionMode",(function(){return W})),i.d(t,"EnumLicenseModule",(function(){return H})),i.d(t,"EnumChargeWay",(function(){return K})),function(e){e[e.IPF_Binary=0]="IPF_Binary",e[e.IPF_BinaryInverted=1]="IPF_BinaryInverted",e[e.IPF_GrayScaled=2]="IPF_GrayScaled",e[e.IPF_NV21=3]="IPF_NV21",e[e.IPF_RGB_565=4]="IPF_RGB_565",e[e.IPF_RGB_555=5]="IPF_RGB_555",e[e.IPF_RGB_888=6]="IPF_RGB_888",e[e.IPF_ARGB_8888=7]="IPF_ARGB_8888",e[e.IPF_RGB_161616=8]="IPF_RGB_161616",e[e.IPF_ARGB_16161616=9]="IPF_ARGB_16161616",e[e.IPF_ABGR_8888=10]="IPF_ABGR_8888",e[e.IPF_ABGR_16161616=11]="IPF_ABGR_16161616",e[e.IPF_BGR_888=12]="IPF_BGR_888"}(n||(n={})),function(e){e[e.DBR_SYSTEM_EXCEPTION=1]="DBR_SYSTEM_EXCEPTION",e[e.DBR_SUCCESS=0]="DBR_SUCCESS",e[e.DBR_UNKNOWN=-1e4]="DBR_UNKNOWN",e[e.DBR_NO_MEMORY=-10001]="DBR_NO_MEMORY",e[e.DBR_NULL_REFERENCE=-10002]="DBR_NULL_REFERENCE",e[e.DBR_LICENSE_INVALID=-10003]="DBR_LICENSE_INVALID",e[e.DBR_LICENSE_EXPIRED=-10004]="DBR_LICENSE_EXPIRED",e[e.DBR_FILE_NOT_FOUND=-10005]="DBR_FILE_NOT_FOUND",e[e.DBR_FILETYPE_NOT_SUPPORTED=-10006]="DBR_FILETYPE_NOT_SUPPORTED",e[e.DBR_BPP_NOT_SUPPORTED=-10007]="DBR_BPP_NOT_SUPPORTED",e[e.DBR_INDEX_INVALID=-10008]="DBR_INDEX_INVALID",e[e.DBR_BARCODE_FORMAT_INVALID=-10009]="DBR_BARCODE_FORMAT_INVALID",e[e.DBR_CUSTOM_REGION_INVALID=-10010]="DBR_CUSTOM_REGION_INVALID",e[e.DBR_MAX_BARCODE_NUMBER_INVALID=-10011]="DBR_MAX_BARCODE_NUMBER_INVALID",e[e.DBR_IMAGE_READ_FAILED=-10012]="DBR_IMAGE_READ_FAILED",e[e.DBR_TIFF_READ_FAILED=-10013]="DBR_TIFF_READ_FAILED",e[e.DBR_QR_LICENSE_INVALID=-10016]="DBR_QR_LICENSE_INVALID",e[e.DBR_1D_LICENSE_INVALID=-10017]="DBR_1D_LICENSE_INVALID",e[e.DBR_DIB_BUFFER_INVALID=-10018]="DBR_DIB_BUFFER_INVALID",e[e.DBR_PDF417_LICENSE_INVALID=-10019]="DBR_PDF417_LICENSE_INVALID",e[e.DBR_DATAMATRIX_LICENSE_INVALID=-10020]="DBR_DATAMATRIX_LICENSE_INVALID",e[e.DBR_PDF_READ_FAILED=-10021]="DBR_PDF_READ_FAILED",e[e.DBR_PDF_DLL_MISSING=-10022]="DBR_PDF_DLL_MISSING",e[e.DBR_PAGE_NUMBER_INVALID=-10023]="DBR_PAGE_NUMBER_INVALID",e[e.DBR_CUSTOM_SIZE_INVALID=-10024]="DBR_CUSTOM_SIZE_INVALID",e[e.DBR_CUSTOM_MODULESIZE_INVALID=-10025]="DBR_CUSTOM_MODULESIZE_INVALID",e[e.DBR_RECOGNITION_TIMEOUT=-10026]="DBR_RECOGNITION_TIMEOUT",e[e.DBR_JSON_PARSE_FAILED=-10030]="DBR_JSON_PARSE_FAILED",e[e.DBR_JSON_TYPE_INVALID=-10031]="DBR_JSON_TYPE_INVALID",e[e.DBR_JSON_KEY_INVALID=-10032]="DBR_JSON_KEY_INVALID",e[e.DBR_JSON_VALUE_INVALID=-10033]="DBR_JSON_VALUE_INVALID",e[e.DBR_JSON_NAME_KEY_MISSING=-10034]="DBR_JSON_NAME_KEY_MISSING",e[e.DBR_JSON_NAME_VALUE_DUPLICATED=-10035]="DBR_JSON_NAME_VALUE_DUPLICATED",e[e.DBR_TEMPLATE_NAME_INVALID=-10036]="DBR_TEMPLATE_NAME_INVALID",e[e.DBR_JSON_NAME_REFERENCE_INVALID=-10037]="DBR_JSON_NAME_REFERENCE_INVALID",e[e.DBR_PARAMETER_VALUE_INVALID=-10038]="DBR_PARAMETER_VALUE_INVALID",e[e.DBR_DOMAIN_NOT_MATCHED=-10039]="DBR_DOMAIN_NOT_MATCHED",e[e.DBR_RESERVEDINFO_NOT_MATCHED=-10040]="DBR_RESERVEDINFO_NOT_MATCHED",e[e.DBR_AZTEC_LICENSE_INVALID=-10041]="DBR_AZTEC_LICENSE_INVALID",e[e.DBR_LICENSE_DLL_MISSING=-10042]="DBR_LICENSE_DLL_MISSING",e[e.DBR_LICENSEKEY_NOT_MATCHED=-10043]="DBR_LICENSEKEY_NOT_MATCHED",e[e.DBR_REQUESTED_FAILED=-10044]="DBR_REQUESTED_FAILED",e[e.DBR_LICENSE_INIT_FAILED=-10045]="DBR_LICENSE_INIT_FAILED",e[e.DBR_PATCHCODE_LICENSE_INVALID=-10046]="DBR_PATCHCODE_LICENSE_INVALID",e[e.DBR_POSTALCODE_LICENSE_INVALID=-10047]="DBR_POSTALCODE_LICENSE_INVALID",e[e.DBR_DPM_LICENSE_INVALID=-10048]="DBR_DPM_LICENSE_INVALID",e[e.DBR_FRAME_DECODING_THREAD_EXISTS=-10049]="DBR_FRAME_DECODING_THREAD_EXISTS",e[e.DBR_STOP_DECODING_THREAD_FAILED=-10050]="DBR_STOP_DECODING_THREAD_FAILED",e[e.DBR_SET_MODE_ARGUMENT_ERROR=-10051]="DBR_SET_MODE_ARGUMENT_ERROR",e[e.DBR_LICENSE_CONTENT_INVALID=-10052]="DBR_LICENSE_CONTENT_INVALID",e[e.DBR_LICENSE_KEY_INVALID=-10053]="DBR_LICENSE_KEY_INVALID",e[e.DBR_LICENSE_DEVICE_RUNS_OUT=-10054]="DBR_LICENSE_DEVICE_RUNS_OUT",e[e.DBR_GET_MODE_ARGUMENT_ERROR=-10055]="DBR_GET_MODE_ARGUMENT_ERROR",e[e.DBR_IRT_LICENSE_INVALID=-10056]="DBR_IRT_LICENSE_INVALID",e[e.DBR_MAXICODE_LICENSE_INVALID=-10057]="DBR_MAXICODE_LICENSE_INVALID",e[e.DBR_GS1_DATABAR_LICENSE_INVALID=-10058]="DBR_GS1_DATABAR_LICENSE_INVALID",e[e.DBR_GS1_COMPOSITE_LICENSE_INVALID=-10059]="DBR_GS1_COMPOSITE_LICENSE_INVALID",e[e.DBR_DOTCODE_LICENSE_INVALID=-10061]="DBR_DOTCODE_LICENSE_INVALID",e[e.DMERR_NO_LICENSE=-2e4]="DMERR_NO_LICENSE",e[e.DMERR_LICENSE_SYNC_FAILED=-20003]="DMERR_LICENSE_SYNC_FAILED",e[e.DMERR_TRIAL_LICENSE=-20010]="DMERR_TRIAL_LICENSE",e[e.DMERR_FAILED_TO_REACH_LTS=-20200]="DMERR_FAILED_TO_REACH_LTS"}(r||(r={})),function(e){e[e.IMRDT_IMAGE=1]="IMRDT_IMAGE",e[e.IMRDT_CONTOUR=2]="IMRDT_CONTOUR",e[e.IMRDT_LINESEGMENT=4]="IMRDT_LINESEGMENT",e[e.IMRDT_LOCALIZATIONRESULT=8]="IMRDT_LOCALIZATIONRESULT",e[e.IMRDT_REGIONOFINTEREST=16]="IMRDT_REGIONOFINTEREST",e[e.IMRDT_QUADRILATERAL=32]="IMRDT_QUADRILATERAL"}(o||(o={})),function(e){e[e.BF_ALL=-31457281]="BF_ALL",e[e.BF_ONED=1050623]="BF_ONED",e[e.BF_GS1_DATABAR=260096]="BF_GS1_DATABAR",e[e.BF_CODE_39=1]="BF_CODE_39",e[e.BF_CODE_128=2]="BF_CODE_128",e[e.BF_CODE_93=4]="BF_CODE_93",e[e.BF_CODABAR=8]="BF_CODABAR",e[e.BF_ITF=16]="BF_ITF",e[e.BF_EAN_13=32]="BF_EAN_13",e[e.BF_EAN_8=64]="BF_EAN_8",e[e.BF_UPC_A=128]="BF_UPC_A",e[e.BF_UPC_E=256]="BF_UPC_E",e[e.BF_INDUSTRIAL_25=512]="BF_INDUSTRIAL_25",e[e.BF_CODE_39_EXTENDED=1024]="BF_CODE_39_EXTENDED",e[e.BF_GS1_DATABAR_OMNIDIRECTIONAL=2048]="BF_GS1_DATABAR_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_TRUNCATED=4096]="BF_GS1_DATABAR_TRUNCATED",e[e.BF_GS1_DATABAR_STACKED=8192]="BF_GS1_DATABAR_STACKED",e[e.BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL=16384]="BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_EXPANDED=32768]="BF_GS1_DATABAR_EXPANDED",e[e.BF_GS1_DATABAR_EXPANDED_STACKED=65536]="BF_GS1_DATABAR_EXPANDED_STACKED",e[e.BF_GS1_DATABAR_LIMITED=131072]="BF_GS1_DATABAR_LIMITED",e[e.BF_PATCHCODE=262144]="BF_PATCHCODE",e[e.BF_PDF417=33554432]="BF_PDF417",e[e.BF_QR_CODE=67108864]="BF_QR_CODE",e[e.BF_DATAMATRIX=134217728]="BF_DATAMATRIX",e[e.BF_AZTEC=268435456]="BF_AZTEC",e[e.BF_MAXICODE=536870912]="BF_MAXICODE",e[e.BF_MICRO_QR=1073741824]="BF_MICRO_QR",e[e.BF_MICRO_PDF417=524288]="BF_MICRO_PDF417",e[e.BF_GS1_COMPOSITE=-2147483648]="BF_GS1_COMPOSITE",e[e.BF_MSI_CODE=1048576]="BF_MSI_CODE",e[e.BF_NULL=0]="BF_NULL"}(s||(s={}));var a=function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{_(n.next(e))}catch(e){o(e)}}function a(e){try{_(n.throw(e))}catch(e){o(e)}}function _(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}_((n=n.apply(e,t||[])).next())}))};const _=!0,d=!_&&"undefined"==typeof self,l=_?global:d?{}:self;class c{constructor(){this._canvasMaxWH="iPhone"==c.browserInfo.OS||"Android"==c.browserInfo.OS?2048:4096,this._instanceID=void 0,this.bSaveOriCanvas=!1,this.oriCanvas=null,this.maxVideoCvsLength=3,this.videoCvses=[],this.videoGlCvs=null,this.videoGl=null,this.glImgData=null,this.bFilterRegionInJs=!0,this._region=null,this._timeStartDecode=null,this._timeEnterInnerDBR=null,this._bUseWebgl=!0,this.decodeRecords=[],this.bDestroyed=!1,this._lastErrorCode=0,this._lastErrorString=""}static get version(){return this._version}static get productKeys(){return this._productKeys}static set productKeys(e){if("unload"!=this._loadWasmStatus)throw new Error("`productKeys` is not allowed to change after loadWasm is called.");c._productKeys=e}static get handshakeCode(){return this._productKeys}static set handshakeCode(e){if("unload"!=this._loadWasmStatus)throw new Error("`handshakeCode` is not allowed to change after loadWasm is called.");c._productKeys=e}static get organizationID(){return this._organizationID}static set organizationID(e){if("unload"!=this._loadWasmStatus)throw new Error("`organizationID` is not allowed to change after loadWasm is called.");c._organizationID=e}static set sessionPassword(e){if("unload"!=this._loadWasmStatus)throw new Error("`sessionPassword` is not allowed to change after loadWasm is called.");c._sessionPassword=e}static get sessionPassword(){return this._sessionPassword}static detectEnvironment(){return a(this,void 0,void 0,(function*(){let e={wasm:"undefined"!=typeof WebAssembly&&("undefined"==typeof navigator||!(/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&/\(.+\s11_2_([2-6]).*\)/.test(navigator.userAgent))),worker:!!(_?process.version>="v12":"undefined"!=typeof Worker),getUserMedia:!("undefined"==typeof navigator||!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia),camera:!1,browser:this.browserInfo.browser,version:this.browserInfo.version,OS:this.browserInfo.OS};if(e.getUserMedia)try{(yield navigator.mediaDevices.getUserMedia({video:!0})).getTracks().forEach(e=>{e.stop()}),e.camera=!0}catch(e){}return e}))}static get engineResourcePath(){return this._engineResourcePath}static set engineResourcePath(e){if("unload"!=this._loadWasmStatus)throw new Error("`engineResourcePath` is not allowed to change after loadWasm is called.");if(null==e&&(e="./"),_||d)c._engineResourcePath=e;else{let t=document.createElement("a");t.href=e,c._engineResourcePath=t.href}this._engineResourcePath.endsWith("/")||(c._engineResourcePath+="/")}static get licenseServer(){return this._licenseServer}static set licenseServer(e){if("unload"!=this._loadWasmStatus)throw new Error("`licenseServer` is not allowed to change after loadWasm is called.");if(null==e)c._licenseServer=[];else{e instanceof Array||(e=[e]);for(let t=0;t= v12.");let e,t=this.productKeys,n=t.startsWith("PUBLIC-TRIAL"),r=n||8==t.length||t.length>8&&!t.startsWith("t")&&!t.startsWith("f")&&!t.startsWith("P")&&!t.startsWith("L")||0==t.length&&0!=this.organizationID.length;if(r&&(_?process.version<"v15"&&(e=new Error("To use handshake requires nodejs version >= v15.")):(l.crypto||(e=new Error("Please upgrade your browser to support handshake code.")),l.crypto.subtle||(e=new Error("Require https to use handshake code in this browser.")))),e){if(!n)throw e;n=!1,r=!1}return n&&(t="",console.warn("Automatically apply for a public trial license.")),yield new Promise((e,n)=>a(this,void 0,void 0,(function*(){switch(this._loadWasmStatus){case"unload":{c._loadWasmStatus="loading";let e=this.engineResourcePath+this._workerName;if(_||this.engineResourcePath.startsWith(location.origin)||(e=yield fetch(e).then(e=>e.blob()).then(e=>URL.createObjectURL(e))),_){const t=i(0);c._dbrWorker=new t.Worker(e)}else c._dbrWorker=new Worker(e);this._dbrWorker.onerror=e=>{c._loadWasmStatus="loadFail";for(let t of this._loadWasmCallbackArr)t(new Error(e.message))},this._dbrWorker.onmessage=e=>a(this,void 0,void 0,(function*(){let t=e.data?e.data:e;switch(t.type){case"log":this._onLog&&this._onLog(t.message);break;case"load":if(t.success){c._loadWasmStatus="loadSuccess",c._version=t.version+"(JS "+this._jsVersion+"."+this._jsEditVersion+")",this._onLog&&this._onLog("load dbr worker success");for(let e of this._loadWasmCallbackArr)e();this._dbrWorker.onerror=null}else{let e=new Error(t.message);e.stack=t.stack+"\n"+e.stack,c._loadWasmStatus="loadFail";for(let t of this._loadWasmCallbackArr)t(e)}break;case"task":{let e=t.id,i=t.body;try{this._taskCallbackMap.get(e)(i),this._taskCallbackMap.delete(e)}catch(t){throw this._taskCallbackMap.delete(e),t}break}default:this._onLog&&this._onLog(e)}})),_&&this._dbrWorker.on("message",this._dbrWorker.onmessage),this._dbrWorker.postMessage({type:"loadWasm",bd:this._bWasmDebug,engineResourcePath:this.engineResourcePath,version:this._jsVersion,brtk:r,pk:t,og:this.organizationID,dm:!_&&location.origin.startsWith("http")?location.origin:"https://localhost",bUseFullFeature:this._bUseFullFeature,browserInfo:this.browserInfo,deviceFriendlyName:this.deviceFriendlyName,ls:this.licenseServer,sp:this._sessionPassword,lm:this._limitModules,cw:this._chargeWay})}case"loading":this._loadWasmCallbackArr.push(t=>{t?n(t):e()});break;case"loadSuccess":e();break;case"loadFail":n()}})))}))}static createInstanceInWorker(e=!1){return a(this,void 0,void 0,(function*(){return yield this.loadWasm(),yield new Promise((t,i)=>{let n=c._nextTaskID++;this._taskCallbackMap.set(n,e=>{if(e.success)return t(e.instanceID);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),this._dbrWorker.postMessage({type:"createInstance",id:n,productKeys:"",bScanner:e})})}))}static createInstance(){return a(this,void 0,void 0,(function*(){let e=new c;return e._instanceID=yield this.createInstanceInWorker(),e}))}decode(e){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("decode(source: any)"),c._onLog&&(this._timeStartDecode=Date.now()),_)return e instanceof Buffer?yield this._decodeFileInMemory_Uint8Array(new Uint8Array(e)):e instanceof Uint8Array?yield this._decodeFileInMemory_Uint8Array(e):"string"==typeof e||e instanceof String?"data:image/"==e.substring(0,11)?yield this._decode_Base64(e):"http"==e.substring(0,4)?yield this._decode_Url(e):yield this._decode_FilePath(e):yield Promise.reject(TypeError("'_decode(source, config)': Type of 'source' should be 'Buffer', 'Uint8Array', 'String(base64 with image mime)' or 'String(url)'."));{let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),e instanceof Blob?yield this._decode_Blob(e,t):e instanceof ArrayBuffer?yield this._decode_ArrayBuffer(e,t):e instanceof Uint8Array||e instanceof Uint8ClampedArray?yield this._decode_Uint8Array(e,t):e instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?yield this._decode_Image(e,t):e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?yield this._decode_Canvas(e,t):e instanceof HTMLVideoElement?yield this._decode_Video(e,t):"string"==typeof e||e instanceof String?"data:image/"==e.substring(0,11)?yield this._decode_Base64(e,t):yield this._decode_Url(e,t):yield Promise.reject(TypeError("'_decode(source, config)': Type of 'source' should be 'Blob', 'ArrayBuffer', 'Uint8Array', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement', 'String(base64 with image mime)' or 'String(url)'."))}}))}decodeBase64String(e){return a(this,void 0,void 0,(function*(){let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),this._decode_Base64(e,t)}))}decodeUrl(e){return a(this,void 0,void 0,(function*(){let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),this._decode_Url(e,t)}))}_decodeBuffer_Uint8Array(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){return yield new Promise((s,a)=>{let _=c._nextTaskID++;c._taskCallbackMap.set(_,e=>{if(e.success){let t,i=c._onLog?Date.now():0;this.bufferShared&&!this.bufferShared.length&&(this.bufferShared=e.buffer);try{t=this._handleRetJsonString(e.decodeReturn)}catch(e){return a(e)}if(c._onLog){let e=Date.now();c._onLog("DBR time get result: "+i),c._onLog("Handle image cost: "+(this._timeEnterInnerDBR-this._timeStartDecode)),c._onLog("DBR worker decode image cost: "+(i-this._timeEnterInnerDBR)),c._onLog("DBR worker handle results: "+(e-i)),c._onLog("Total decode image cost: "+(e-this._timeStartDecode))}return s(t)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,a(t)}}),c._onLog&&(this._timeEnterInnerDBR=Date.now()),c._onLog&&c._onLog("Send buffer to worker:"+Date.now()),c._dbrWorker.postMessage({type:"decodeBuffer",id:_,instanceID:this._instanceID,body:{buffer:e,width:t,height:i,stride:n,format:r,config:o}},[e.buffer])})}))}_decodeBuffer_Blob(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){return c._onLog&&c._onLog("_decodeBuffer_Blob(buffer,width,height,stride,format)"),yield new Promise((t,i)=>{let n=new FileReader;n.readAsArrayBuffer(e),n.onload=()=>{t(n.result)},n.onerror=()=>{i(n.error)}}).then(e=>this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o))}))}decodeBuffer(e,t,i,n,r,o){return a(this,void 0,void 0,(function*(){let s;return c._onLog&&c._onLog("decodeBuffer(buffer,width,height,stride,format)"),c._onLog&&(this._timeStartDecode=Date.now()),_?e instanceof Uint8Array?s=yield this._decodeBuffer_Uint8Array(e,t,i,n,r,o):e instanceof Buffer&&(s=yield this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o)):e instanceof Uint8Array||e instanceof Uint8ClampedArray?s=yield this._decodeBuffer_Uint8Array(e,t,i,n,r,o):e instanceof ArrayBuffer?s=yield this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,n,r,o):e instanceof Blob&&(s=yield this._decodeBuffer_Blob(e,t,i,n,r,o)),s}))}_decodeFileInMemory_Uint8Array(e){return a(this,void 0,void 0,(function*(){return yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success){let n;try{n=this._handleRetJsonString(e.decodeReturn)}catch(e){return i(e)}return t(n)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),c._dbrWorker.postMessage({type:"decodeFileInMemory",id:n,instanceID:this._instanceID,body:{bytes:e}})})}))}getRuntimeSettings(){return a(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success){let t=JSON.parse(i.results);return null!=this.userDefinedRegion&&(t.region=JSON.parse(JSON.stringify(this.userDefinedRegion))),e(t)}{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"getRuntimeSettings",id:i,instanceID:this._instanceID})})}))}updateRuntimeSettings(e){return a(this,void 0,void 0,(function*(){let t;if("string"==typeof e||"object"==typeof e&&e instanceof String)if("speed"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=3,t.expectedBarcodesCount=0,t.localizationModes=[2,0,0,0,0,0,0,0]}else if("balance"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=5,t.expectedBarcodesCount=512,t.localizationModes=[2,16,0,0,0,0,0,0]}else if("coverage"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region}else t=JSON.parse(e);else{if("object"!=typeof e)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");if(t=JSON.parse(JSON.stringify(e)),t.region instanceof Array){let e=t.region;[e.regionLeft,e.regionTop,e.regionLeft,e.regionBottom,e.regionMeasuredByPercentage].some(e=>void 0!==e)&&(t.region={regionLeft:e.regionLeft||0,regionTop:e.regionTop||0,regionRight:e.regionRight||0,regionBottom:e.regionBottom||0,regionMeasuredByPercentage:e.regionMeasuredByPercentage||0})}}if(!c._bUseFullFeature){if(0!=(t.barcodeFormatIds&~(s.BF_ONED|s.BF_QR_CODE|s.BF_PDF417|s.BF_DATAMATRIX))||0!=t.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=t.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}if(!_)if(this.bFilterRegionInJs){let e=t.region;if(e instanceof Array)throw Error("The `region` of type `Array` is only allowed in `BarcodeScanner`.");this.userDefinedRegion=JSON.parse(JSON.stringify(e)),(e.regionLeft||e.regionTop||e.regionRight||e.regionBottom||e.regionMeasuredByPercentage)&&(e.regionLeft||e.regionTop||100!=e.regionRight||100!=e.regionBottom||!e.regionMeasuredByPercentage)?this.region=e:this.region=null,t.region={regionLeft:0,regionTop:0,regionRight:0,regionBottom:0,regionMeasuredByPercentage:0}}else this.userDefinedRegion=null,this.region=null;return yield new Promise((e,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,t=>{if(t.success){try{this._handleRetJsonString(t.updateReturn)}catch(e){i(e)}return e()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}}),c._dbrWorker.postMessage({type:"updateRuntimeSettings",id:n,instanceID:this._instanceID,body:{settings:JSON.stringify(t)}})})}))}resetRuntimeSettings(){return a(this,void 0,void 0,(function*(){return this.userDefinedRegion=null,this.region=null,yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"resetRuntimeSettings",id:i,instanceID:this._instanceID})})}))}outputSettingsToString(){return a(this,void 0,void 0,(function*(){if(!c._bUseFullFeature)throw Error("outputSettingsToString() is not supported in the compact version. Please try the full-featured version.");return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e(i.results);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"outputSettingsToString",id:i,instanceID:this._instanceID})})}))}initRuntimeSettingsWithString(e){return a(this,void 0,void 0,(function*(){if(!c._bUseFullFeature)throw Error("initRuntimeSettingsWithString() is not supported in the compact version. Please try the full-featured version.");if("string"==typeof e||"object"==typeof e&&e instanceof String)e=e;else{if("object"!=typeof e)throw TypeError("'initRuntimeSettingstWithString(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");e=JSON.stringify(e)}return yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success){try{this._handleRetJsonString(e.initReturn)}catch(e){i(e)}return t()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),c._dbrWorker.postMessage({type:"initRuntimeSettingsWithString",id:n,instanceID:this._instanceID,body:{settings:e}})})}))}_decode_Blob(e,t){return a(this,void 0,void 0,(function*(){c._onLog&&c._onLog("_decode_Blob(blob: Blob)");let i=null,n=null;if("undefined"!=typeof createImageBitmap)try{i=yield createImageBitmap(e)}catch(e){}i||(n=yield function(e){return new Promise((t,i)=>{let n=URL.createObjectURL(e),r=new Image;r.dbrObjUrl=n,r.src=n,r.onload=()=>{t(r)},r.onerror=e=>{i(new Error("Can't convert blob to image : "+(e instanceof Event?e.type:e)))}})}(e));let r=yield this._decode_Image(i||n,t);return i&&i.close(),r}))}_decode_ArrayBuffer(e,t){return a(this,void 0,void 0,(function*(){return yield this._decode_Blob(new Blob([e]),t)}))}_decode_Uint8Array(e,t){return a(this,void 0,void 0,(function*(){return yield this._decode_Blob(new Blob([e]),t)}))}_decode_Image(e,t){return a(this,void 0,void 0,(function*(){c._onLog&&c._onLog("_decode_Image(image: HTMLImageElement|ImageBitmap)"),t=t||{};let i,n,r=e instanceof HTMLImageElement?e.naturalWidth:e.width,o=e instanceof HTMLImageElement?e.naturalHeight:e.height,s=Math.max(r,o);if(s>this._canvasMaxWH){let e=this._canvasMaxWH/s;i=Math.round(r*e),n=Math.round(o*e)}else i=r,n=o;let a,_=0,d=0,h=r,u=o,g=r,E=o,R=t.region;if(R){let e,t,s,a;R.regionMeasuredByPercentage?(e=R.regionLeft*i/100,t=R.regionTop*n/100,s=R.regionRight*i/100,a=R.regionBottom*n/100):(e=R.regionLeft,t=R.regionTop,s=R.regionRight,a=R.regionBottom),g=s-e,h=Math.round(g/i*r),E=a-t,u=Math.round(E/n*o),_=Math.round(e/i*r),d=Math.round(t/n*o)}!this.bSaveOriCanvas&&l.OffscreenCanvas?a=new OffscreenCanvas(g,E):(a=document.createElement("canvas"),a.width=g,a.height=E);let I,A=a.getContext("2d");0==_&&0==d&&r==h&&o==u&&r==g&&o==E?A.drawImage(e,0,0):A.drawImage(e,_,d,h,u,0,0,g,E),e.dbrObjUrl&&URL.revokeObjectURL(e.dbrObjUrl),R?(I=JSON.parse(JSON.stringify(t)),delete I.region):I=t;let f=yield this._decode_Canvas(a,I);return c.fixResultLocationWhenFilterRegionInJs(R,f,_,d,h,u,g,E),f}))}_decode_Canvas(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Canvas(canvas:HTMLCanvasElement)"),e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";(this.bSaveOriCanvas||this.singleFrameMode)&&(this.oriCanvas=e);let i=(e.dbrCtx2d||e.getContext("2d")).getImageData(0,0,e.width,e.height).data;return yield this._decodeBuffer_Uint8Array(i,e.width,e.height,4*e.width,n.IPF_ABGR_8888,t)}))}_decode_Video(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Video(video)"),!(e instanceof HTMLVideoElement))throw TypeError("'_decode_Video(video [, config] )': Type of 'video' should be 'HTMLVideoElement'.");if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";t=t||{};let i,r,o=e.videoWidth,s=e.videoHeight,a=Math.max(o,s);if(a>this._canvasMaxWH){let e=this._canvasMaxWH/a;i=Math.round(o*e),r=Math.round(s*e)}else i=o,r=s;let _=0,d=0,h=o,u=s,g=o,E=s,R=t.region;if(R){let e,t,n,a;R.regionMeasuredByPercentage?(e=R.regionLeft*i/100,t=R.regionTop*r/100,n=R.regionRight*i/100,a=R.regionBottom*r/100):(e=R.regionLeft,t=R.regionTop,n=R.regionRight,a=R.regionBottom),g=n-e,h=Math.round(g/i*o),E=a-t,u=Math.round(E/r*s),_=Math.round(e/i*o),d=Math.round(t/r*s)}let I=0==_&&0==d&&o==h&&s==u&&o==g&&s==E;if(!this.bSaveOriCanvas&&this._bUseWebgl&&I){this.videoGlCvs||(this.videoGlCvs=l.OffscreenCanvas?new OffscreenCanvas(g,E):document.createElement("canvas"));const t=this.videoGlCvs;t.width==g&&t.height==E||(t.height=E,t.width=g,this.videoGl&&this.videoGl.viewport(0,0,g,E));const i=this.videoGl||t.getContext("webgl",{alpha:!1,antialias:!1})||t.getContext("experimental-webgl",{alpha:!1,antialias:!1});if(!this.videoGl){this.videoGl=i;let e=i.createShader(i.VERTEX_SHADER);i.shaderSource(e,"\nattribute vec4 a_position;\nattribute vec2 a_uv;\n\nvarying vec2 v_uv;\n\nvoid main() {\n gl_Position = a_position;\n v_uv = a_uv;\n}\n"),i.compileShader(e),i.getShaderParameter(e,i.COMPILE_STATUS)||console.error("An error occurred compiling the shaders: "+i.getShaderInfoLog(e));let t=i.createShader(i.FRAGMENT_SHADER);i.shaderSource(t,"\nprecision lowp float;\n\nvarying vec2 v_uv;\n\nuniform sampler2D u_texture;\n\nvoid main() {\n vec4 sample = texture2D(u_texture, v_uv);\n float grey = 0.299 * sample.r + 0.587 * sample.g + 0.114 * sample.b;\n gl_FragColor = vec4(grey, 0.0, 0.0, 1.0);\n}\n"),i.compileShader(t),i.getShaderParameter(t,i.COMPILE_STATUS)||console.error("An error occurred compiling the shaders: "+i.getShaderInfoLog(t));let n=i.createProgram();i.attachShader(n,e),i.attachShader(n,t),i.linkProgram(n),i.getProgramParameter(n,i.LINK_STATUS)||console.error("Unable to initialize the shader program: "+i.getProgramInfoLog(n)),i.useProgram(n),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,1,0,1,1,1,1,1,-1,-1,0,0,1,-1,1,0]),i.STATIC_DRAW);let r=i.getAttribLocation(n,"a_position");i.enableVertexAttribArray(r),i.vertexAttribPointer(r,2,i.FLOAT,!1,16,0);let o=i.getAttribLocation(n,"a_uv");i.enableVertexAttribArray(o),i.vertexAttribPointer(o,2,i.FLOAT,!1,16,8),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,i.createTexture()),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.uniform1i(i.getUniformLocation(n,"u_texture"),0)}(!this.glImgData||this.glImgData.length=this.maxVideoCvsLength&&(this.videoCvses=this.videoCvses.slice(1)),this.videoCvses.push(i));const n=i.dbrCtx2d;let r;I?n.drawImage(e,0,0):n.drawImage(e,_,d,h,u,0,0,g,E),R?(r=JSON.parse(JSON.stringify(t)),delete r.region):r=t;let o=yield this._decode_Canvas(i,r);return c.fixResultLocationWhenFilterRegionInJs(R,o,_,d,h,u,g,E),o}}))}_decode_Base64(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Base64(base64Str)"),"string"!=typeof e&&"object"!=typeof e)return Promise.reject("'_decode_Base64(base64Str, config)': Type of 'base64Str' should be 'String'.");if("data:image/"==e.substring(0,11)&&(e=e.substring(e.indexOf(",")+1)),_){let t=Buffer.from(e,"base64");return yield this._decodeFileInMemory_Uint8Array(new Uint8Array(t))}{let i=atob(e),n=i.length,r=new Uint8Array(n);for(;n--;)r[n]=i.charCodeAt(n);return yield this._decode_Blob(new Blob([r]),t)}}))}_decode_Url(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_Url(url)"),"string"!=typeof e&&"object"!=typeof e)throw TypeError("'_decode_Url(url, config)': Type of 'url' should be 'String'.");if(_){let t=yield new Promise((t,n)=>{(e.startsWith("https")?i(1):i(2)).get(e,e=>{if(200==e.statusCode){let i=[];e.on("data",e=>{i.push(e)}).on("end",()=>{t(new Uint8Array(Buffer.concat(i)))})}else n("http get fail, statusCode: "+e.statusCode)})});return yield this._decodeFileInMemory_Uint8Array(t)}{let i=yield new Promise((t,i)=>{let n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="blob",n.send(),n.onloadend=()=>a(this,void 0,void 0,(function*(){t(n.response)})),n.onerror=()=>{i(new Error("Network Error: "+n.statusText))}});return yield this._decode_Blob(i,t)}}))}_decode_FilePath(e,t){return a(this,void 0,void 0,(function*(){if(c._onLog&&c._onLog("_decode_FilePath(path)"),!_)throw Error("'_decode_FilePath(path, config)': The method is only supported in node environment.");if("string"!=typeof e&&"object"!=typeof e)throw TypeError("'_decode_FilePath(path, config)': Type of 'path' should be 'String'.");const t=i(3);let n=yield new Promise((i,n)=>{t.readFile(e,(e,t)=>{e?n(e):i(new Uint8Array(t))})});return yield this._decodeFileInMemory_Uint8Array(n)}))}static fixResultLocationWhenFilterRegionInJs(e,t,i,n,r,o,s,a){if(e&&t.length>0)for(let e of t){let t=e.localizationResult;2==t.resultCoordinateType&&(t.x1*=.01*s,t.x2*=.01*s,t.x3*=.01*s,t.x4*=.01*s,t.y1*=.01*a,t.y2*=.01*a,t.y3*=.01*a,t.y4*=.01*a),t.x1+=i,t.x2+=i,t.x3+=i,t.x4+=i,t.y1+=n,t.y2+=n,t.y3+=n,t.y4+=n,2==t.resultCoordinateType&&(t.x1*=100/r,t.x2*=100/r,t.x3*=100/r,t.x4*=100/r,t.y1*=100/o,t.y2*=100/o,t.y3*=100/o,t.y4*=100/o)}}static BarcodeReaderException(e,t){let i,n=r.DBR_UNKNOWN;return"number"==typeof e?(n=e,i=new Error(t)):i=new Error(e),i.code=n,i}_handleRetJsonString(e){let t=r;if(e.textResults){for(let t=0;t{let i=t.indexOf(":");e[t.substring(0,i)]=t.substring(i+1)}),i.exception=e}}return e.decodeRecords&&(this.decodeRecords=e.decodeRecords),this._lastErrorCode=e.exception,this._lastErrorString=e.description,e.textResults}if(e.exception==t.DBR_SUCCESS)return e.data;throw c.BarcodeReaderException(e.exception,e.description)}setModeArgument(e,t,i,n){return a(this,void 0,void 0,(function*(){return yield new Promise((r,o)=>{let s=c._nextTaskID++;c._taskCallbackMap.set(s,e=>{if(e.success){try{this._handleRetJsonString(e.setReturn)}catch(e){return o(e)}return r()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}}),c._dbrWorker.postMessage({type:"setModeArgument",id:s,instanceID:this._instanceID,body:{modeName:e,index:t,argumentName:i,argumentValue:n}})})}))}getModeArgument(e,t,i){return a(this,void 0,void 0,(function*(){return yield new Promise((n,r)=>{let o=c._nextTaskID++;c._taskCallbackMap.set(o,e=>{if(e.success){let t;try{t=this._handleRetJsonString(e.getReturn)}catch(e){return r(e)}return n(t)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,r(t)}}),c._dbrWorker.postMessage({type:"getModeArgument",id:o,instanceID:this._instanceID,body:{modeName:e,index:t,argumentName:i}})})}))}getIntermediateResults(){return a(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e(i.results);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"getIntermediateResults",id:i,instanceID:this._instanceID})})}))}getIntermediateCanvas(){return a(this,void 0,void 0,(function*(){let e=yield this.getIntermediateResults(),t=[];for(let i of e)if(i.dataType==o.IMRDT_IMAGE)for(let e of i.results){const i=e.bytes;let r;switch(c._onLog&&c._onLog(" "+i.length+" "+i.byteLength+" "+e.width+" "+e.height+" "+e.stride+" "+e.format),e.format){case n.IPF_ABGR_8888:r=new Uint8ClampedArray(i);break;case n.IPF_RGB_888:{const e=i.length/3;r=new Uint8ClampedArray(4*e);for(let t=0;t{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"destroy",id:i,instanceID:this._instanceID})})}}c.bNode=_,c._jsVersion="8.2.3",c._jsEditVersion="20210413",c._version="loading...(JS "+c._jsVersion+"."+c._jsEditVersion+")",c._productKeys=_||d||!document.currentScript?"":document.currentScript.getAttribute("data-productKeys")||document.currentScript.getAttribute("data-licenseKey")||document.currentScript.getAttribute("data-handshakeCode")||"",c._organizationID=_||d||!document.currentScript?"":document.currentScript.getAttribute("data-organizationID")||"",c.browserInfo=function(){if(!_&&!d){var e={init:function(){this.browser=this.searchString(this.dataBrowser)||"unknownBrowser",this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"unknownVersion",this.OS=this.searchString(this.dataOS)||"unknownOS"},searchString:function(e){for(var t=0;t{if(_)return url.fileURLToPath(import.meta.url.substring(0,import.meta.url.lastIndexOf("/")))+"/";if(!d&&document.currentScript){let e=document.currentScript.src,t=e.indexOf("?");if(-1!=t)e=e.substring(0,t);else{let t=e.indexOf("#");-1!=t&&(e=e.substring(0,t))}return e.substring(0,e.lastIndexOf("/")+1)}return"./"})(),c._licenseServer=[],c._deviceFriendlyName="",c._isShowRelDecodeTimeInResults=!1,c._bWasmDebug=!1,c._bSendSmallRecordsForDebug=!1,c.__bUseFullFeature=_,c._nextTaskID=0,c._taskCallbackMap=new Map,c._loadWasmStatus="unload",c._loadWasmCallbackArr=[],c._lastErrorCode=0,c._lastErrorString="";var h=function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{_(n.next(e))}catch(e){o(e)}}function a(e){try{_(n.throw(e))}catch(e){o(e)}}function _(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}_((n=n.apply(e,t||[])).next())}))};const u=!!("object"==typeof global&&global.process&&global.process.release&&global.process.release.name&&"undefined"==typeof HTMLCanvasElement);class g extends c{constructor(){super(),this.styleEls=[],this.videoSettings={video:{width:{ideal:1280},height:{ideal:720},facingMode:{ideal:"environment"}}},this._singleFrameMode=!(navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),this._singleFrameModeIpt=(()=>{let e=document.createElement("input");return e.setAttribute("type","file"),e.setAttribute("accept","image/*"),e.setAttribute("capture",""),e.addEventListener("change",()=>h(this,void 0,void 0,(function*(){let t=e.files[0];e.value="";let i=yield this.decode(t);for(let e of i)delete e.bUnduplicated;if(this._drawRegionsults(i),this.onFrameRead&&this._isOpen&&!this._bPauseScan&&this.onFrameRead(i),this.onUnduplicatedRead&&this._isOpen&&!this._bPauseScan)for(let e of i)this.onUnduplicatedRead(e.barcodeText,e);yield this.clearMapDecodeRecord()}))),e})(),this._clickIptSingleFrameMode=()=>{this._singleFrameModeIpt.click()},this.intervalTime=0,this._isOpen=!1,this._bPauseScan=!1,this._lastDeviceId=void 0,this._intervalDetectVideoPause=1e3,this._vc_bPlayingVideoBeforeHide=!1,this._ev_documentHideEvent=()=>{"visible"===document.visibilityState?this._vc_bPlayingVideoBeforeHide&&("Firefox"==c.browserInfo.browser?this.play():this._video.play(),this._vc_bPlayingVideoBeforeHide=!1):this._video&&!this._video.paused&&(this._vc_bPlayingVideoBeforeHide=!0,this._video.pause())},this._video=null,this._cvsDrawArea=null,this._divScanArea=null,this._divScanLight=null,this._bgLoading=null,this._bgCamera=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._soundOnSuccessfullRead=new Audio("data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA/+M4wAAAAAAAAAAAAEluZm8AAAAPAAAABQAAAkAAgICAgICAgICAgICAgICAgICAgKCgoKCgoKCgoKCgoKCgoKCgoKCgwMDAwMDAwMDAwMDAwMDAwMDAwMDg4ODg4ODg4ODg4ODg4ODg4ODg4P//////////////////////////AAAAAExhdmM1OC41NAAAAAAAAAAAAAAAACQEUQAAAAAAAAJAk0uXRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+MYxAANQAbGeUEQAAHZYZ3fASqD4P5TKBgocg+Bw/8+CAYBA4XB9/4EBAEP4nB9+UOf/6gfUCAIKyjgQ/Kf//wfswAAAwQA/+MYxAYOqrbdkZGQAMA7DJLCsQxNOij///////////+tv///3RWiZGBEhsf/FO/+LoCSFs1dFVS/g8f/4Mhv0nhqAieHleLy/+MYxAYOOrbMAY2gABf/////////////////usPJ66R0wI4boY9/8jQYg//g2SPx1M0N3Z0kVJLIs///Uw4aMyvHJJYmPBYG/+MYxAgPMALBucAQAoGgaBoFQVBUFQWDv6gZBUFQVBUGgaBr5YSgqCoKhIGg7+IQVBUFQVBoGga//SsFSoKnf/iVTEFNRTMu/+MYxAYAAANIAAAAADEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"),this.bPlaySoundOnSuccessfulRead=!1,this.bVibrateOnSuccessfulRead=!1,this.vibrateDuration=300,this._allCameras=[],this._currentCamera=null,this._videoTrack=null,this.regionMaskFillStyle="rgba(0,0,0,0.5)",this.regionMaskStrokeStyle="rgb(254,142,20)",this.regionMaskLineWidth=2,this.barcodeFillStyle="rgba(254,180,32,0.3)",this.barcodeStrokeStyle="rgba(254,180,32,0.9)",this.barcodeLineWidth=1,this.beingLazyDrawRegionsults=!1,this._indexVideoRegion=-1,this._onCameraSelChange=()=>{this.play(this._selCam.value).then(()=>{this._isOpen||this.stop()}).catch(e=>{alert("Play video failed: "+(e.message||e))})},this._onResolutionSelChange=()=>{let e,t;if(this._selRsl&&-1!=this._selRsl.selectedIndex){let i=this._selRsl.options[this._selRsl.selectedIndex];e=i.getAttribute("data-width"),t=i.getAttribute("data-height")}this.play(void 0,e,t).then(()=>{this._isOpen||this.stop()}).catch(e=>{alert("Play video failed: "+(e.message||e))})},this._onCloseBtnClick=()=>{this.hide()}}static get defaultUIElementURL(){return this._defaultUIElementURL?this._defaultUIElementURL:c.engineResourcePath+"dbr.scanner.html"}static set defaultUIElementURL(e){this._defaultUIElementURL=e}getUIElement(){return this.UIElement}setUIElement(e){return h(this,void 0,void 0,(function*(){if("string"==typeof e||e instanceof String){if(!e.trim().startsWith("<")){let t=yield fetch(e);if(!t.ok)throw Error("Network Error: "+t.statusText);e=yield t.text()}if(!e.trim().startsWith("<"))throw Error("setUIElement(elementOrUrl): Can't get valid HTMLElement.");let t=document.createElement("div");t.innerHTML=e;for(let e=0;e{h(this,void 0,void 0,(function*(){let e=yield this.getScanSettings();e.oneDTrustFrameCount=1,yield this.updateScanSettings(e)}))})()}_assertOpen(){if(!this._isOpen)throw Error("The scanner is not open.")}get soundOnSuccessfullRead(){return this._soundOnSuccessfullRead}set soundOnSuccessfullRead(e){e instanceof HTMLAudioElement?this._soundOnSuccessfullRead=e:this._soundOnSuccessfullRead=new Audio(e)}set region(e){this._region=e,this.singleFrameMode||(this.beingLazyDrawRegionsults=!0,setTimeout(()=>{this.beingLazyDrawRegionsults&&this._drawRegionsults()},500))}get region(){return this._region}static createInstance(e){return h(this,void 0,void 0,(function*(){if(u)throw new Error("`BarcodeScanner` is not supported in Node.js.");let t=new g;t._instanceID=yield g.createInstanceInWorker(!0),("string"==typeof e||e instanceof String)&&(e=JSON.parse(e));for(let i in e)t[i]=e[i];return t.UIElement||(yield t.setUIElement(this.defaultUIElementURL)),t.singleFrameMode||(yield t.updateRuntimeSettings("single")),document.addEventListener("visibilitychange",t._ev_documentHideEvent),t}))}decode(e){return super.decode(e)}decodeBase64String(e){return super.decodeBase64String(e)}decodeUrl(e){return super.decodeUrl(e)}decodeBuffer(e,t,i,n,r,o){return super.decodeBuffer(e,t,i,n,r,o)}decodeCurrentFrame(){return h(this,void 0,void 0,(function*(){this._assertOpen();let e={};if(this.region)if(this.region instanceof Array){++this._indexVideoRegion>=this.region.length&&(this._indexVideoRegion=0);let t=this.region[this._indexVideoRegion];t&&(e.region=JSON.parse(JSON.stringify(t)))}else e.region=JSON.parse(JSON.stringify(this.region));return this._decode_Video(this._video,e)}))}clearMapDecodeRecord(){return h(this,void 0,void 0,(function*(){return yield new Promise((e,t)=>{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}}),c._dbrWorker.postMessage({type:"clearMapDecodeRecord",id:i,instanceID:this._instanceID})})}))}static isRegionSinglePreset(e){return JSON.stringify(e)==JSON.stringify(this.singlePresetRegion)}static isRegionNormalPreset(e){return 0==e.regionLeft&&0==e.regionTop&&0==e.regionRight&&0==e.regionBottom&&0==e.regionMeasuredByPercentage}updateRuntimeSettings(e){return h(this,void 0,void 0,(function*(){let t;if("string"==typeof e||"object"==typeof e&&e instanceof String)if("speed"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region)}else if("balance"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region),t.deblurLevel=3,t.expectedBarcodesCount=512,t.localizationModes=[2,16,0,0,0,0,0,0],t.timeout=1e5}else if("coverage"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionSinglePreset(e.region)||(t.region=e.region),t.deblurLevel=5,t.expectedBarcodesCount=512,t.scaleDownThreshold=1e5,t.localizationModes=[2,16,4,8,0,0,0,0],t.timeout=1e5}else if("single"==e){let e=yield this.getRuntimeSettings();yield this.resetRuntimeSettings(),t=yield this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,g.isRegionNormalPreset(e.region)?t.region=JSON.parse(JSON.stringify(g.singlePresetRegion)):t.region=e.region,t.expectedBarcodesCount=1,t.localizationModes=[16,2,0,0,0,0,0,0],t.barcodeZoneMinDistanceToImageBorders=0}else t=JSON.parse(e);else{if("object"!=typeof e)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");if(t=JSON.parse(JSON.stringify(e)),t.region instanceof Array){let i=e.region;[i.regionLeft,i.regionTop,i.regionLeft,i.regionBottom,i.regionMeasuredByPercentage].some(e=>void 0!==e)&&(t.region={regionLeft:i.regionLeft||0,regionTop:i.regionTop||0,regionRight:i.regionRight||0,regionBottom:i.regionBottom||0,regionMeasuredByPercentage:i.regionMeasuredByPercentage||0})}}if(!c._bUseFullFeature){if(0!=(t.barcodeFormatIds&~(s.BF_ONED|s.BF_QR_CODE|s.BF_PDF417|s.BF_DATAMATRIX))||0!=t.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=t.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}{let e=t.region;if(this.bFilterRegionInJs?this.userDefinedRegion=JSON.parse(JSON.stringify(e)):this.userDefinedRegion=null,e instanceof Array)if(e.length){for(let t=0;t{let n=c._nextTaskID++;c._taskCallbackMap.set(n,t=>{if(t.success){try{this._handleRetJsonString(t.updateReturn)}catch(e){i(e)}return e()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}}),c._dbrWorker.postMessage({type:"updateRuntimeSettings",id:n,instanceID:this._instanceID,body:{settings:JSON.stringify(t)}})}),"single"==e&&(yield this.setModeArgument("BinarizationModes",0,"EnableFillBinaryVacancy","0"),yield this.setModeArgument("LocalizationModes",0,"ScanDirection","2"),yield this.setModeArgument("BinarizationModes",0,"BlockSizeX","71"),yield this.setModeArgument("BinarizationModes",0,"BlockSizeY","71"))}))}_bindUI(){let e=[this.UIElement],t=this.UIElement.children;for(let i of t)e.push(i);for(let t=0;t','','','','','','','',''].join(""),this._optGotRsl=this._optGotRsl||this._selRsl.options[0])):!this._optGotRsl&&t.classList.contains("dbrScanner-opt-gotResolution")?this._optGotRsl=t:!this._btnClose&&t.classList.contains("dbrScanner-btn-close")?this._btnClose=t:!this._video&&t.classList.contains("dbrScanner-existingVideo")?(this._video=t,this._video.setAttribute("playsinline","true"),this.singleFrameMode=!1):!i&&t.tagName&&"video"==t.tagName.toLowerCase()&&(i=t);if(!this._video&&i&&(this._video=i),this.singleFrameMode?(this._video&&(this._video.addEventListener("click",this._clickIptSingleFrameMode),this._video.style.cursor="pointer",this._video.setAttribute("title","Take a photo")),this._cvsDrawArea&&(this._cvsDrawArea.addEventListener("click",this._clickIptSingleFrameMode),this._cvsDrawArea.style.cursor="pointer",this._cvsDrawArea.setAttribute("title","Take a photo")),this._divScanArea&&(this._divScanArea.addEventListener("click",this._clickIptSingleFrameMode),this._divScanArea.style.cursor="pointer",this._divScanArea.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="")):this._bgLoading&&(this._bgLoading.style.display=""),this._selCam&&this._selCam.addEventListener("change",this._onCameraSelChange),this._selRsl&&this._selRsl.addEventListener("change",this._onResolutionSelChange),this._btnClose&&this._btnClose.addEventListener("click",this._onCloseBtnClick),!this._video)throw this._unbindUI(),Error("Can not find HTMLVideoElement with class `dbrScanner-video`.");this._isOpen=!0}_unbindUI(){this._clearRegionsults(),this.singleFrameMode?(this._video&&(this._video.removeEventListener("click",this._clickIptSingleFrameMode),this._video.style.cursor="",this._video.removeAttribute("title")),this._cvsDrawArea&&(this._cvsDrawArea.removeEventListener("click",this._clickIptSingleFrameMode),this._cvsDrawArea.style.cursor="",this._cvsDrawArea.removeAttribute("title")),this._divScanArea&&(this._divScanArea.removeEventListener("click",this._clickIptSingleFrameMode),this._divScanArea.style.cursor="",this._divScanArea.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none")):this._bgLoading&&(this._bgLoading.style.display="none"),this._selCam&&this._selCam.removeEventListener("change",this._onCameraSelChange),this._selRsl&&this._selRsl.removeEventListener("change",this._onResolutionSelChange),this._btnClose&&this._btnClose.removeEventListener("click",this._onCloseBtnClick),this._video=null,this._cvsDrawArea=null,this._divScanArea=null,this._divScanLight=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._isOpen=!1}_renderSelCameraInfo(){let e,t;if(this._selCam&&(e=this._selCam.value,this._selCam.innerHTML=""),this._selCam){for(let i of this._allCameras){let n=document.createElement("option");n.value=i.deviceId,n.innerText=i.label,this._selCam.append(n),e==i.deviceId&&(t=n)}let i=this._selCam.childNodes;if(!t&&this._currentCamera&&i.length)for(let e of i)if(this._currentCamera.label==e.innerText){t=e;break}t&&(this._selCam.value=t.value)}}getAllCameras(){return h(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices(),t=[];let i=0;for(let n=0;n{let i=c._nextTaskID++;c._taskCallbackMap.set(i,i=>{if(i.success){let t=i.results;return t.intervalTime=this.intervalTime,e(t)}{let e=new Error(i.message);return e.stack+="\n"+i.stack,t(e)}}),c._dbrWorker.postMessage({type:"getScanSettings",id:i,instanceID:this._instanceID})})}))}updateScanSettings(e){return h(this,void 0,void 0,(function*(){return this.intervalTime=e.intervalTime,yield new Promise((t,i)=>{let n=c._nextTaskID++;c._taskCallbackMap.set(n,e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack+="\n"+e.stack,i(t)}}),g._dbrWorker.postMessage({type:"updateScanSettings",id:n,instanceID:this._instanceID,body:{settings:e}})})}))}getVideoSettings(){return JSON.parse(JSON.stringify(this.videoSettings))}updateVideoSettings(e){return this.videoSettings=JSON.parse(JSON.stringify(e)),this._lastDeviceId=null,this._isOpen?this.play():Promise.resolve()}isOpen(){return this._isOpen}_show(){this.UIElement.parentNode||(this.UIElement.style.position="fixed",this.UIElement.style.left="0",this.UIElement.style.top="0",document.body.append(this.UIElement)),"none"==this.UIElement.style.display&&(this.UIElement.style.display="")}stop(){this._video&&this._video.srcObject&&(c._onLog&&c._onLog("======stop video========"),this._video.srcObject.getTracks().forEach(e=>{e.stop()}),this._video.srcObject=null,this._videoTrack=null),this._video&&this._video.classList.contains("dbrScanner-existingVideo")&&(c._onLog&&c._onLog("======stop existing video========"),this._video.pause(),this._video.currentTime=0),this._bgLoading&&(this._bgLoading.style.animationPlayState=""),this._divScanLight&&(this._divScanLight.style.display="none")}pause(){this._video&&this._video.pause(),this._divScanLight&&(this._divScanLight.style.display="none")}play(e,t,i){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.singleFrameMode)return this._clickIptSingleFrameMode(),{width:0,height:0};if(this._video&&this._video.classList.contains("dbrScanner-existingVideo")){yield this._video.play();let e={width:this._video.videoWidth,height:this._video.videoHeight};return this.onPlayed&&setTimeout(()=>{this.onPlayed(e)},0),e}if(this._video&&this._video.srcObject&&(this.stop(),yield new Promise(e=>setTimeout(e,500))),c._onLog&&c._onLog("======before video========"),"Android"==c.browserInfo.OS&&(yield this.getAllCameras()),this.bDestroyed)throw new Error("The BarcodeScanner instance has been destroyed.");const n=this.videoSettings;"boolean"==typeof n.video&&(n.video={});const r="iPhone"==c.browserInfo.OS;let o,s;if(r?t>=1280||i>=1280?n.video.width=1280:t>=640||i>=640?n.video.width=640:(t<640||i<640)&&(n.video.width=320):(t&&(n.video.width={ideal:t}),i&&(n.video.height={ideal:i})),e)delete n.video.facingMode,n.video.deviceId={exact:e},this._lastDeviceId=e;else if(n.video.deviceId);else if(this._lastDeviceId)delete n.video.facingMode,n.video.deviceId={ideal:this._lastDeviceId};else if(n.video.facingMode){let e=n.video.facingMode;if(e instanceof Array&&e.length&&(e=e[0]),e=e.exact||e.ideal||e,"environment"===e){for(let e of this._allCameras){let t=e.label.toLowerCase();if(t&&-1!=t.indexOf("facing back")&&/camera[0-9]?\s0,/.test(t)){delete n.video.facingMode,n.video.deviceId={ideal:e.deviceId};break}}o=!!n.video.facingMode}}c._onLog&&c._onLog("======try getUserMedia========"),c._onLog&&c._onLog("ask "+JSON.stringify(n.video.width)+"x"+JSON.stringify(n.video.height));try{c._onLog&&c._onLog(n),s=yield navigator.mediaDevices.getUserMedia(n)}catch(e){c._onLog&&c._onLog(e),c._onLog&&c._onLog("======try getUserMedia again========"),r?(delete n.video.width,delete n.video.height):o?(delete n.video.facingMode,this._allCameras.length&&(n.video.deviceId={ideal:this._allCameras[this._allCameras.length-1].deviceId})):n.video=!0,c._onLog&&c._onLog(n),s=yield navigator.mediaDevices.getUserMedia(n)}if(this.bDestroyed)throw s.getTracks().forEach(e=>{e.stop()}),new Error("The BarcodeScanner instance has been destroyed.");{const e=s.getVideoTracks();e.length&&(this._videoTrack=e[0])}this._video.srcObject=s,c._onLog&&c._onLog("======play video========");try{yield Promise.race([this._video.play(),new Promise((e,t)=>{setTimeout(()=>t(new Error("Failed to play video. Timeout.")),4e3)})])}catch(e){c._onLog&&c._onLog("======play video again========"),yield new Promise(e=>{setTimeout(e,1e3)}),yield Promise.race([this._video.play(),new Promise((e,t)=>{setTimeout(()=>t(new Error("Failed to play video. Timeout.")),4e3)})])}c._onLog&&c._onLog("======played video========"),this._bgLoading&&(this._bgLoading.style.animationPlayState="paused"),this._drawRegionsults();const a="got "+this._video.videoWidth+"x"+this._video.videoHeight;this._optGotRsl&&(this._optGotRsl.setAttribute("data-width",this._video.videoWidth),this._optGotRsl.setAttribute("data-height",this._video.videoHeight),this._optGotRsl.innerText=a,this._selRsl&&this._optGotRsl.parentNode==this._selRsl&&(this._selRsl.value="got")),c._onLog&&c._onLog(a),"Android"!==c.browserInfo.OS&&(yield this.getAllCameras()),yield this.getCurrentCamera(),this._renderSelCameraInfo();let _={width:this._video.videoWidth,height:this._video.videoHeight};return this.onPlayed&&setTimeout(()=>{this.onPlayed(_)},0),_}))}pauseScan(){this._assertOpen(),this._bPauseScan=!0,this._divScanLight&&(this._divScanLight.style.display="none")}resumeScan(){this._assertOpen(),this._bPauseScan=!1}getCapabilities(){return this._assertOpen(),this._videoTrack.getCapabilities?this._videoTrack.getCapabilities():{}}getCameraSettings(){return this._assertOpen(),this._videoTrack.getSettings()}getConstraints(){return this._assertOpen(),this._videoTrack.getConstraints()}applyConstraints(e){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),!this._videoTrack.applyConstraints)throw Error("Not supported.");return yield this._videoTrack.applyConstraints(e)}))}turnOnTorch(){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.getCapabilities().torch)return yield this._videoTrack.applyConstraints({advanced:[{torch:!0}]});throw Error("Not supported.")}))}turnOffTorch(){return h(this,void 0,void 0,(function*(){if(this._assertOpen(),this.getCapabilities().torch)return yield this._videoTrack.applyConstraints({advanced:[{torch:!1}]});throw Error("Not supported.")}))}setColorTemperature(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().colorTemperature;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{colorTemperature:e}]})}))}setExposureCompensation(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().exposureCompensation;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{exposureCompensation:e}]})}))}setZoom(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().zoom;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({advanced:[{zoom:e}]})}))}setFrameRate(e){return h(this,void 0,void 0,(function*(){this._assertOpen();let t=this.getCapabilities().frameRate;if(!t)throw Error("Not supported.");return et.max&&(e=t.max),yield this._videoTrack.applyConstraints({width:{ideal:Math.max(this._video.videoWidth,this._video.videoHeight)},frameRate:e})}))}_cloneDecodeResults(e){if(e instanceof Array){let t=[];for(let i of e)t.push(this._cloneDecodeResults(i));return t}{let t=e;return JSON.parse(JSON.stringify(t,(e,t)=>"oriVideoCanvas"==e||"searchRegionCanvas"==e?void 0:t))}}_loopReadVideo(){return h(this,void 0,void 0,(function*(){if(this.bDestroyed)return;if(!this._isOpen)return void(yield this.clearMapDecodeRecord());if(this._video.paused||this._bPauseScan)return c._onLog&&c._onLog("Video or scan is paused. Ask in 1s."),yield this.clearMapDecodeRecord(),void setTimeout(()=>{this._loopReadVideo()},this._intervalDetectVideoPause);this._divScanLight&&"none"==this._divScanLight.style.display&&(this._divScanLight.style.display=""),c._onLog&&c._onLog("======= once read =======");(new Date).getTime();c._onLog&&(this._timeStartDecode=Date.now()),this.decodeCurrentFrame().then(e=>{if(c._onLog&&c._onLog(e),this._isOpen&&!this._video.paused&&!this._bPauseScan){if(this.bPlaySoundOnSuccessfulRead&&e.length){let t=!1;if(!0===this.bPlaySoundOnSuccessfulRead||"frame"===this.bPlaySoundOnSuccessfulRead)t=!0;else if("unduplicated"===this.bPlaySoundOnSuccessfulRead)for(let i of e)if(i.bUnduplicated){t=!0;break}t&&(this.soundOnSuccessfullRead.currentTime=0,this.soundOnSuccessfullRead.play().catch(e=>{console.warn("Autoplay not allowed. User interaction required: "+(e.message||e))}))}if(navigator.vibrate&&this.bVibrateOnSuccessfulRead&&e.length){let t=!1;if(!0===this.bVibrateOnSuccessfulRead||"frame"===this.bVibrateOnSuccessfulRead)t=!0;else if("unduplicated"===this.bVibrateOnSuccessfulRead)for(let i of e)if(i.bUnduplicated){t=!0;break}if(t)try{navigator.vibrate(this.vibrateDuration)}catch(e){console.warn("Vibration not allowed. User interaction required: "+(e.message||e))}}if(this.onFrameRead){let t=this._cloneDecodeResults(e);for(let e of t)delete e.bUnduplicated;this.onFrameRead(t)}if(this.onUnduplicatedRead)for(let t of e)t.bUnduplicated&&this.onUnduplicatedRead(t.barcodeText,this._cloneDecodeResults(t));this._drawRegionsults(e)}setTimeout(()=>{this._loopReadVideo()},this.intervalTime)}).catch(e=>{if(c._onLog&&c._onLog(e.message||e),setTimeout(()=>{this._loopReadVideo()},Math.max(this.intervalTime,1e3)),"platform error"!=e.message)throw console.error(e.message),e})}))}_drawRegionsults(e){let t,i,n;if(this.beingLazyDrawRegionsults=!1,this.singleFrameMode){if(!this.oriCanvas)return;t="contain",i=this.oriCanvas.width,n=this.oriCanvas.height}else{if(!this._video)return;t=this._video.style.objectFit||"contain",i=this._video.videoWidth,n=this._video.videoHeight}let r=this.region;if(r&&(!r.regionLeft&&!r.regionRight&&!r.regionTop&&!r.regionBottom&&!r.regionMeasuredByPercentage||r instanceof Array?r=null:r.regionMeasuredByPercentage?r=r.regionLeft||r.regionRight||100!==r.regionTop||100!==r.regionBottom?{regionLeft:Math.round(r.regionLeft/100*i),regionTop:Math.round(r.regionTop/100*n),regionRight:Math.round(r.regionRight/100*i),regionBottom:Math.round(r.regionBottom/100*n)}:null:(r=JSON.parse(JSON.stringify(r)),delete r.regionMeasuredByPercentage)),this._cvsDrawArea){this._cvsDrawArea.style.objectFit=t;let o=this._cvsDrawArea;o.width=i,o.height=n;let s=o.getContext("2d");if(r){s.fillStyle=this.regionMaskFillStyle,s.fillRect(0,0,o.width,o.height),s.globalCompositeOperation="destination-out",s.fillStyle="#000";let e=Math.round(this.regionMaskLineWidth/2);s.fillRect(r.regionLeft-e,r.regionTop-e,r.regionRight-r.regionLeft+2*e,r.regionBottom-r.regionTop+2*e),s.globalCompositeOperation="source-over",s.strokeStyle=this.regionMaskStrokeStyle,s.lineWidth=this.regionMaskLineWidth,s.rect(r.regionLeft,r.regionTop,r.regionRight-r.regionLeft,r.regionBottom-r.regionTop),s.stroke()}if(e){s.globalCompositeOperation="destination-over",s.fillStyle=this.barcodeFillStyle,s.strokeStyle=this.barcodeStrokeStyle,s.lineWidth=this.barcodeLineWidth,e=e||[];for(let t of e){let e=t.localizationResult;s.beginPath(),s.moveTo(e.x1,e.y1),s.lineTo(e.x2,e.y2),s.lineTo(e.x3,e.y3),s.lineTo(e.x4,e.y4),s.fill(),s.beginPath(),s.moveTo(e.x1,e.y1),s.lineTo(e.x2,e.y2),s.lineTo(e.x3,e.y3),s.lineTo(e.x4,e.y4),s.closePath(),s.stroke()}}this.singleFrameMode&&(s.globalCompositeOperation="destination-over",s.drawImage(this.oriCanvas,0,0))}if(this._divScanArea){let e=this._video.offsetWidth,t=this._video.offsetHeight,o=1;e/tsuper.destroy}});return h(this,void 0,void 0,(function*(){document.removeEventListener("visibilitychange",this._ev_documentHideEvent),this.close();for(let e of this.styleEls)e.remove();this.styleEls.splice(0,this.styleEls.length),this.bDestroyed||(yield e.destroy.call(this))}))}}var E,R,I,A,f,D,T,S,m,M,C,v,p,L,y,O,N,B,b,P,F,w,U,V,k,G,x,W,H,K;g.singlePresetRegion=[null,{regionLeft:0,regionTop:30,regionRight:100,regionBottom:70,regionMeasuredByPercentage:1},{regionLeft:25,regionTop:25,regionRight:75,regionBottom:75,regionMeasuredByPercentage:1},{regionLeft:25,regionTop:25,regionRight:75,regionBottom:75,regionMeasuredByPercentage:1}],function(e){e[e.BICM_DARK_ON_LIGHT=1]="BICM_DARK_ON_LIGHT",e[e.BICM_LIGHT_ON_DARK=2]="BICM_LIGHT_ON_DARK",e[e.BICM_DARK_ON_DARK=4]="BICM_DARK_ON_DARK",e[e.BICM_LIGHT_ON_LIGHT=8]="BICM_LIGHT_ON_LIGHT",e[e.BICM_DARK_LIGHT_MIXED=16]="BICM_DARK_LIGHT_MIXED",e[e.BICM_DARK_ON_LIGHT_DARK_SURROUNDING=32]="BICM_DARK_ON_LIGHT_DARK_SURROUNDING",e[e.BICM_SKIP=0]="BICM_SKIP",e[e.BICM_REV=2147483648]="BICM_REV"}(E||(E={})),function(e){e[e.BCM_AUTO=1]="BCM_AUTO",e[e.BCM_GENERAL=2]="BCM_GENERAL",e[e.BCM_SKIP=0]="BCM_SKIP",e[e.BCM_REV=2147483648]="BCM_REV"}(R||(R={})),function(e){e[e.BF2_NULL=0]="BF2_NULL",e[e.BF2_POSTALCODE=32505856]="BF2_POSTALCODE",e[e.BF2_NONSTANDARD_BARCODE=1]="BF2_NONSTANDARD_BARCODE",e[e.BF2_USPSINTELLIGENTMAIL=1048576]="BF2_USPSINTELLIGENTMAIL",e[e.BF2_POSTNET=2097152]="BF2_POSTNET",e[e.BF2_PLANET=4194304]="BF2_PLANET",e[e.BF2_AUSTRALIANPOST=8388608]="BF2_AUSTRALIANPOST",e[e.BF2_RM4SCC=16777216]="BF2_RM4SCC",e[e.BF2_DOTCODE=2]="BF2_DOTCODE"}(I||(I={})),function(e){e[e.BM_AUTO=1]="BM_AUTO",e[e.BM_LOCAL_BLOCK=2]="BM_LOCAL_BLOCK",e[e.BM_SKIP=0]="BM_SKIP",e[e.BM_THRESHOLD=4]="BM_THRESHOLD",e[e.BM_REV=2147483648]="BM_REV"}(A||(A={})),function(e){e[e.ECCM_CONTRAST=1]="ECCM_CONTRAST"}(f||(f={})),function(e){e[e.CFM_GENERAL=1]="CFM_GENERAL"}(D||(D={})),function(e){e[e.CCM_AUTO=1]="CCM_AUTO",e[e.CCM_GENERAL_HSV=2]="CCM_GENERAL_HSV",e[e.CCM_SKIP=0]="CCM_SKIP",e[e.CCM_REV=2147483648]="CCM_REV"}(T||(T={})),function(e){e[e.CICM_GENERAL=1]="CICM_GENERAL",e[e.CICM_SKIP=0]="CICM_SKIP",e[e.CICM_REV=2147483648]="CICM_REV"}(S||(S={})),function(e){e[e.CM_IGNORE=1]="CM_IGNORE",e[e.CM_OVERWRITE=2]="CM_OVERWRITE"}(m||(m={})),function(e){e[e.DM_SKIP=0]="DM_SKIP",e[e.DM_DIRECT_BINARIZATION=1]="DM_DIRECT_BINARIZATION",e[e.DM_THRESHOLD_BINARIZATION=2]="DM_THRESHOLD_BINARIZATION",e[e.DM_GRAY_EQUALIZATION=4]="DM_GRAY_EQUALIZATION",e[e.DM_SMOOTHING=8]="DM_SMOOTHING",e[e.DM_MORPHING=16]="DM_MORPHING",e[e.DM_DEEP_ANALYSIS=32]="DM_DEEP_ANALYSIS",e[e.DM_SHARPENING=64]="DM_SHARPENING"}(M||(M={})),function(e){e[e.DRM_AUTO=1]="DRM_AUTO",e[e.DRM_GENERAL=2]="DRM_GENERAL",e[e.DRM_SKIP=0]="DRM_SKIP",e[e.DRM_REV=2147483648]="DRM_REV"}(C||(C={})),function(e){e[e.DPMCRM_AUTO=1]="DPMCRM_AUTO",e[e.DPMCRM_GENERAL=2]="DPMCRM_GENERAL",e[e.DPMCRM_SKIP=0]="DPMCRM_SKIP",e[e.DPMCRM_REV=2147483648]="DPMCRM_REV"}(v||(v={})),function(e){e[e.GTM_INVERTED=1]="GTM_INVERTED",e[e.GTM_ORIGINAL=2]="GTM_ORIGINAL",e[e.GTM_SKIP=0]="GTM_SKIP",e[e.GTM_REV=2147483648]="GTM_REV"}(p||(p={})),function(e){e[e.IPM_AUTO=1]="IPM_AUTO",e[e.IPM_GENERAL=2]="IPM_GENERAL",e[e.IPM_GRAY_EQUALIZE=4]="IPM_GRAY_EQUALIZE",e[e.IPM_GRAY_SMOOTH=8]="IPM_GRAY_SMOOTH",e[e.IPM_SHARPEN_SMOOTH=16]="IPM_SHARPEN_SMOOTH",e[e.IPM_MORPHOLOGY=32]="IPM_MORPHOLOGY",e[e.IPM_SKIP=0]="IPM_SKIP",e[e.IPM_REV=2147483648]="IPM_REV"}(L||(L={})),function(e){e[e.IRSM_MEMORY=1]="IRSM_MEMORY",e[e.IRSM_FILESYSTEM=2]="IRSM_FILESYSTEM",e[e.IRSM_BOTH=4]="IRSM_BOTH"}(y||(y={})),function(e){e[e.IRT_NO_RESULT=0]="IRT_NO_RESULT",e[e.IRT_ORIGINAL_IMAGE=1]="IRT_ORIGINAL_IMAGE",e[e.IRT_COLOUR_CLUSTERED_IMAGE=2]="IRT_COLOUR_CLUSTERED_IMAGE",e[e.IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE=4]="IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE",e[e.IRT_TRANSFORMED_GRAYSCALE_IMAGE=8]="IRT_TRANSFORMED_GRAYSCALE_IMAGE",e[e.IRT_PREDETECTED_REGION=16]="IRT_PREDETECTED_REGION",e[e.IRT_PREPROCESSED_IMAGE=32]="IRT_PREPROCESSED_IMAGE",e[e.IRT_BINARIZED_IMAGE=64]="IRT_BINARIZED_IMAGE",e[e.IRT_TEXT_ZONE=128]="IRT_TEXT_ZONE",e[e.IRT_CONTOUR=256]="IRT_CONTOUR",e[e.IRT_LINE_SEGMENT=512]="IRT_LINE_SEGMENT",e[e.IRT_FORM=1024]="IRT_FORM",e[e.IRT_SEGMENTATION_BLOCK=2048]="IRT_SEGMENTATION_BLOCK",e[e.IRT_TYPED_BARCODE_ZONE=4096]="IRT_TYPED_BARCODE_ZONE",e[e.IRT_PREDETECTED_QUADRILATERAL=8192]="IRT_PREDETECTED_QUADRILATERAL"}(O||(O={})),function(e){e[e.LM_SKIP=0]="LM_SKIP",e[e.LM_AUTO=1]="LM_AUTO",e[e.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",e[e.LM_LINES=8]="LM_LINES",e[e.LM_STATISTICS=4]="LM_STATISTICS",e[e.LM_SCAN_DIRECTLY=16]="LM_SCAN_DIRECTLY",e[e.LM_STATISTICS_MARKS=32]="LM_STATISTICS_MARKS",e[e.LM_STATISTICS_POSTAL_CODE=64]="LM_STATISTICS_POSTAL_CODE",e[e.LM_CENTRE=128]="LM_CENTRE",e[e.LM_REV=2147483648]="LM_REV"}(N||(N={})),function(e){e[e.PDFRM_RASTER=1]="PDFRM_RASTER",e[e.PDFRM_AUTO=2]="PDFRM_AUTO",e[e.PDFRM_VECTOR=4]="PDFRM_VECTOR",e[e.PDFRM_REV=2147483648]="PDFRM_REV"}(B||(B={})),function(e){e[e.QRECL_ERROR_CORRECTION_H=0]="QRECL_ERROR_CORRECTION_H",e[e.QRECL_ERROR_CORRECTION_L=1]="QRECL_ERROR_CORRECTION_L",e[e.QRECL_ERROR_CORRECTION_M=2]="QRECL_ERROR_CORRECTION_M",e[e.QRECL_ERROR_CORRECTION_Q=3]="QRECL_ERROR_CORRECTION_Q"}(b||(b={})),function(e){e[e.RPM_AUTO=1]="RPM_AUTO",e[e.RPM_GENERAL=2]="RPM_GENERAL",e[e.RPM_GENERAL_RGB_CONTRAST=4]="RPM_GENERAL_RGB_CONTRAST",e[e.RPM_GENERAL_GRAY_CONTRAST=8]="RPM_GENERAL_GRAY_CONTRAST",e[e.RPM_GENERAL_HSV_CONTRAST=16]="RPM_GENERAL_HSV_CONTRAST",e[e.RPM_SKIP=0]="RPM_SKIP",e[e.RPM_REV=2147483648]="RPM_REV"}(P||(P={})),function(e){e[e.RCT_PIXEL=1]="RCT_PIXEL",e[e.RCT_PERCENTAGE=2]="RCT_PERCENTAGE"}(F||(F={})),function(e){e[e.RT_STANDARD_TEXT=0]="RT_STANDARD_TEXT",e[e.RT_RAW_TEXT=1]="RT_RAW_TEXT",e[e.RT_CANDIDATE_TEXT=2]="RT_CANDIDATE_TEXT",e[e.RT_PARTIAL_TEXT=3]="RT_PARTIAL_TEXT"}(w||(w={})),function(e){e[e.SUM_AUTO=1]="SUM_AUTO",e[e.SUM_LINEAR_INTERPOLATION=2]="SUM_LINEAR_INTERPOLATION",e[e.SUM_NEAREST_NEIGHBOUR_INTERPOLATION=4]="SUM_NEAREST_NEIGHBOUR_INTERPOLATION",e[e.SUM_SKIP=0]="SUM_SKIP",e[e.SUM_REV=2147483648]="SUM_REV"}(U||(U={})),function(e){e[e.TP_REGION_PREDETECTED=1]="TP_REGION_PREDETECTED",e[e.TP_IMAGE_PREPROCESSED=2]="TP_IMAGE_PREPROCESSED",e[e.TP_IMAGE_BINARIZED=4]="TP_IMAGE_BINARIZED",e[e.TP_BARCODE_LOCALIZED=8]="TP_BARCODE_LOCALIZED",e[e.TP_BARCODE_TYPE_DETERMINED=16]="TP_BARCODE_TYPE_DETERMINED",e[e.TP_BARCODE_RECOGNIZED=32]="TP_BARCODE_RECOGNIZED"}(V||(V={})),function(e){e[e.TACM_AUTO=1]="TACM_AUTO",e[e.TACM_VERIFYING=2]="TACM_VERIFYING",e[e.TACM_VERIFYING_PATCHING=4]="TACM_VERIFYING_PATCHING",e[e.TACM_SKIP=0]="TACM_SKIP",e[e.TACM_REV=2147483648]="TACM_REV"}(k||(k={})),function(e){e[e.TFM_AUTO=1]="TFM_AUTO",e[e.TFM_GENERAL_CONTOUR=2]="TFM_GENERAL_CONTOUR",e[e.TFM_SKIP=0]="TFM_SKIP",e[e.TFM_REV=2147483648]="TFM_REV"}(G||(G={})),function(e){e[e.TROM_CONFIDENCE=1]="TROM_CONFIDENCE",e[e.TROM_POSITION=2]="TROM_POSITION",e[e.TROM_FORMAT=4]="TROM_FORMAT",e[e.TROM_SKIP=0]="TROM_SKIP",e[e.TROM_REV=2147483648]="TROM_REV"}(x||(x={})),function(e){e[e.TDM_AUTO=1]="TDM_AUTO",e[e.TDM_GENERAL_WIDTH_CONCENTRATION=2]="TDM_GENERAL_WIDTH_CONCENTRATION",e[e.TDM_SKIP=0]="TDM_SKIP",e[e.TDM_REV=2147483648]="TDM_REV"}(W||(W={})),function(e){e.DM_LM_ONED="1",e.DM_LM_QR_CODE="2",e.DM_LM_PDF417="3",e.DM_LM_DATAMATRIX="4",e.DM_LM_AZTEC="5",e.DM_LM_MAXICODE="6",e.DM_LM_PATCHCODE="7",e.DM_LM_GS1_DATABAR="8",e.DM_LM_GS1_COMPOSITE="9",e.DM_LM_POSTALCODE="10",e.DM_LM_DOTCODE="11",e.DM_LM_INTERMEDIATE_RESULT="12",e.DM_LM_DPM="13",e.DM_LM_NONSTANDARD_BARCODE="16"}(H||(H={})),function(e){e.DM_CW_AUTO="",e.DM_CW_DEVICE_COUNT="DeviceCount",e.DM_CW_SCAN_COUNT="ScanCount",e.DM_CW_CONCURRENT_DEVICE_COUNT="ConcurrentDeviceCount",e.DM_CW_APP_DOMIAN_COUNT="Domain",e.DM_CW_ACTIVE_DEVICE_COUNT="ActiveDeviceCount",e.DM_CW_INSTANCE_COUNT="InstanceCount",e.DM_CW_CONCURRENT_INSTANCE_COUNT="ConcurrentInstanceCount"}(K||(K={}));const J={BarcodeReader:c,BarcodeScanner:g,EnumBarcodeColourMode:E,EnumBarcodeComplementMode:R,EnumBarcodeFormat:s,EnumBarcodeFormat_2:I,EnumBinarizationMode:A,EnumClarityCalculationMethod:f,EnumClarityFilterMode:D,EnumColourClusteringMode:T,EnumColourConversionMode:S,EnumConflictMode:m,EnumDeblurMode:M,EnumDeformationResistingMode:C,EnumDPMCodeReadingMode:v,EnumErrorCode:r,EnumGrayscaleTransformationMode:p,EnumImagePixelFormat:n,EnumImagePreprocessingMode:L,EnumIMResultDataType:o,EnumIntermediateResultSavingMode:y,EnumIntermediateResultType:O,EnumLocalizationMode:N,EnumPDFReadingMode:B,EnumQRCodeErrorCorrectionLevel:b,EnumRegionPredetectionMode:P,EnumResultCoordinateType:F,EnumResultType:w,EnumScaleUpMode:U,EnumTerminatePhase:V,EnumTextAssistedCorrectionMode:k,EnumTextFilterMode:G,EnumTextResultOrderMode:x,EnumTextureDetectionMode:W,EnumLicenseModule:H,EnumChargeWay:K};t.default=J}])}));const DBR={};{let _dbr;if(typeof dbr=="object"){_dbr=dbr;}else if(typeof module=="object"&&module.exports&&module.exports.default){_dbr=module.exports.default;}else if(typeof exports=="object"&&exports.dbr){_dbr=exports.dbr;}for(let key in _dbr){DBR[key]=_dbr[key];}}export default DBR;export const BarcodeReader=DBR.BarcodeReader;export const BarcodeScanner=DBR.BarcodeScanner;export const EnumBarcodeColourMode=DBR.EnumBarcodeColourMode;export const EnumBarcodeComplementMode=DBR.EnumBarcodeComplementMode;export const EnumBarcodeFormat=DBR.EnumBarcodeFormat;export const EnumBarcodeFormat_2=DBR.EnumBarcodeFormat_2;export const EnumBinarizationMode=DBR.EnumBinarizationMode;export const EnumClarityCalculationMethod=DBR.EnumClarityCalculationMethod;export const EnumClarityFilterMode=DBR.EnumClarityFilterMode;export const EnumColourClusteringMode=DBR.EnumColourClusteringMode;export const EnumColourConversionMode=DBR.EnumColourConversionMode;export const EnumConflictMode=DBR.EnumConflictMode;export const EnumDeblurMode=DBR.EnumDeblurMode;export const EnumDeformationResistingMode=DBR.EnumDeformationResistingMode;export const EnumDPMCodeReadingMode=DBR.EnumDPMCodeReadingMode;export const EnumErrorCode=DBR.EnumErrorCode;export const EnumGrayscaleTransformationMode=DBR.EnumGrayscaleTransformationMode;export const EnumImagePixelFormat=DBR.EnumImagePixelFormat;export const EnumImagePreprocessingMode=DBR.EnumImagePreprocessingMode;export const EnumIMResultDataType=DBR.EnumIMResultDataType;export const EnumIntermediateResultSavingMode=DBR.EnumIntermediateResultSavingMode;export const EnumIntermediateResultType=DBR.EnumIntermediateResultType;export const EnumLocalizationMode=DBR.EnumLocalizationMode;export const EnumPDFReadingMode=DBR.EnumPDFReadingMode;export const EnumQRCodeErrorCorrectionLevel=DBR.EnumQRCodeErrorCorrectionLevel;export const EnumRegionPredetectionMode=DBR.EnumRegionPredetectionMode;export const EnumResultCoordinateType=DBR.EnumResultCoordinateType;export const EnumResultType=DBR.EnumResultType;export const EnumScaleUpMode=DBR.EnumScaleUpMode;export const EnumTerminatePhase=DBR.EnumTerminatePhase;export const EnumTextAssistedCorrectionMode=DBR.EnumTextAssistedCorrectionMode;export const EnumTextFilterMode=DBR.EnumTextFilterMode;export const EnumTextResultOrderMode=DBR.EnumTextResultOrderMode;export const EnumTextureDetectionMode=DBR.EnumTextureDetectionMode;export const EnumLicenseModule=DBR.EnumLicenseModule;export const EnumChargeWay=DBR.EnumChargeWay;
\ No newline at end of file
diff --git a/dist/dbr.reference.d.ts b/dist/dbr.reference.d.ts
index 7af07167..4a02116b 100644
--- a/dist/dbr.reference.d.ts
+++ b/dist/dbr.reference.d.ts
@@ -4,7 +4,7 @@
* @website http://www.dynamsoft.com
* @preserve Copyright 2021, Dynamsoft Corporation
* @author Dynamsoft
-* @version 8.2.1 (js 20210326)
+* @version 8.2.3 (js 20210413)
* @fileoverview Dynamsoft JavaScript Library for Barcode Reader
* More info on DBR JS: https://www.dynamsoft.com/Products/barcode-recognition-javascript.aspx
*/
@@ -271,10 +271,77 @@ declare enum EnumImagePixelFormat {
IPF_ABGR_16161616 = 11,
IPF_BGR_888 = 12
}
+declare enum EnumErrorCode {
+ DBR_SYSTEM_EXCEPTION = 1,
+ DBR_SUCCESS = 0,
+ DBR_UNKNOWN = -10000,
+ DBR_NO_MEMORY = -10001,
+ DBR_NULL_REFERENCE = -10002,
+ DBR_LICENSE_INVALID = -10003,
+ DBR_LICENSE_EXPIRED = -10004,
+ DBR_FILE_NOT_FOUND = -10005,
+ DBR_FILETYPE_NOT_SUPPORTED = -10006,
+ DBR_BPP_NOT_SUPPORTED = -10007,
+ DBR_INDEX_INVALID = -10008,
+ DBR_BARCODE_FORMAT_INVALID = -10009,
+ DBR_CUSTOM_REGION_INVALID = -10010,
+ DBR_MAX_BARCODE_NUMBER_INVALID = -10011,
+ DBR_IMAGE_READ_FAILED = -10012,
+ DBR_TIFF_READ_FAILED = -10013,
+ DBR_QR_LICENSE_INVALID = -10016,
+ DBR_1D_LICENSE_INVALID = -10017,
+ DBR_DIB_BUFFER_INVALID = -10018,
+ DBR_PDF417_LICENSE_INVALID = -10019,
+ DBR_DATAMATRIX_LICENSE_INVALID = -10020,
+ DBR_PDF_READ_FAILED = -10021,
+ DBR_PDF_DLL_MISSING = -10022,
+ DBR_PAGE_NUMBER_INVALID = -10023,
+ DBR_CUSTOM_SIZE_INVALID = -10024,
+ DBR_CUSTOM_MODULESIZE_INVALID = -10025,
+ DBR_RECOGNITION_TIMEOUT = -10026,
+ DBR_JSON_PARSE_FAILED = -10030,
+ DBR_JSON_TYPE_INVALID = -10031,
+ DBR_JSON_KEY_INVALID = -10032,
+ DBR_JSON_VALUE_INVALID = -10033,
+ DBR_JSON_NAME_KEY_MISSING = -10034,
+ DBR_JSON_NAME_VALUE_DUPLICATED = -10035,
+ DBR_TEMPLATE_NAME_INVALID = -10036,
+ DBR_JSON_NAME_REFERENCE_INVALID = -10037,
+ DBR_PARAMETER_VALUE_INVALID = -10038,
+ DBR_DOMAIN_NOT_MATCHED = -10039,
+ DBR_RESERVEDINFO_NOT_MATCHED = -10040,
+ DBR_AZTEC_LICENSE_INVALID = -10041,
+ DBR_LICENSE_DLL_MISSING = -10042,
+ DBR_LICENSEKEY_NOT_MATCHED = -10043,
+ DBR_REQUESTED_FAILED = -10044,
+ DBR_LICENSE_INIT_FAILED = -10045,
+ DBR_PATCHCODE_LICENSE_INVALID = -10046,
+ DBR_POSTALCODE_LICENSE_INVALID = -10047,
+ DBR_DPM_LICENSE_INVALID = -10048,
+ DBR_FRAME_DECODING_THREAD_EXISTS = -10049,
+ DBR_STOP_DECODING_THREAD_FAILED = -10050,
+ DBR_SET_MODE_ARGUMENT_ERROR = -10051,
+ DBR_LICENSE_CONTENT_INVALID = -10052,
+ DBR_LICENSE_KEY_INVALID = -10053,
+ DBR_LICENSE_DEVICE_RUNS_OUT = -10054,
+ DBR_GET_MODE_ARGUMENT_ERROR = -10055,
+ DBR_IRT_LICENSE_INVALID = -10056,
+ DBR_MAXICODE_LICENSE_INVALID = -10057,
+ DBR_GS1_DATABAR_LICENSE_INVALID = -10058,
+ DBR_GS1_COMPOSITE_LICENSE_INVALID = -10059,
+ DBR_DOTCODE_LICENSE_INVALID = -10061,
+ DMERR_NO_LICENSE = -20000,
+ DMERR_LICENSE_SYNC_FAILED = -20003,
+ DMERR_TRIAL_LICENSE = -20010,
+ DMERR_FAILED_TO_REACH_LTS = -20200
+}
+interface BarcodeReaderException extends Error {
+ code?: EnumErrorCode;
+}
/**
* A class dedicated to image decoding.
* ```js
- * let reader = await DBR.BarcodeReader.createInstance();
+ * let reader = await Dynamsoft.DBR.BarcodeReader.createInstance();
* let results = await reader.decode(imageSource);
* for(let result of results){
* console.log(result.barcodeText);
@@ -331,8 +398,8 @@ declare class BarcodeReader {
* The SDK will try to automatically explore the engine location.
* If the auto-explored engine location is not accurate, manually specify the engine location.
* ```js
- * DBR.BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@7.2.2/dist/";
- * await DBR.BarcodeReader.loadWasm();
+ * Dynamsoft.DBR.BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@7.2.2/dist/";
+ * await Dynamsoft.DBR.BarcodeReader.loadWasm();
* ```
*/
static set engineResourcePath(value: string);
@@ -479,7 +546,7 @@ declare class BarcodeReader {
/**
* Create a `BarcodeReader` object.
* ```
- * let reader = await DBR.BarcodeReader.createInstance();
+ * let reader = await Dynamsoft.DBR.BarcodeReader.createInstance();
* ```
* @category Initialize and Destroy
*/
@@ -557,6 +624,7 @@ declare class BarcodeReader {
* settings.deblurLevel = 5;
* await reader.updateRuntimeSettings(settings);
* ```
+ * @see [RuntimeSettings](https://www.dynamsoft.com/barcode-reader/programming/c-cplusplus/struct/PublicRuntimeSettings.html?ver=latest&utm_source=github&package=js)
* @category Runtime Settings
*/
getRuntimeSettings(): Promise;
@@ -566,9 +634,10 @@ declare class BarcodeReader {
* ```js
* await reader.updateRuntimeSettings('balance');
* let settings = await reader.getRuntimeSettings();
- * settings.barcodeFormatIds = DBR.EnumBarcodeFormat.BF_ONED;
+ * settings.barcodeFormatIds = Dynamsoft.DBR.EnumBarcodeFormat.BF_ONED;
* await reader.updateRuntimeSettings(settings);
* ```
+ * @see [RuntimeSettings](https://www.dynamsoft.com/barcode-reader/programming/c-cplusplus/struct/PublicRuntimeSettings.html?ver=latest&utm_source=github&package=js)
* @category Runtime Settings
*/
updateRuntimeSettings(settings: RuntimeSettings | string): Promise;
@@ -633,8 +702,9 @@ declare class BarcodeReader {
private _decode_Base64;
private _decode_Url;
private _decode_FilePath;
+ static fixResultLocationWhenFilterRegionInJs(region: any, results: TextResult[], sx: number, sy: number, sWidth: number, sHeight: number, dWidth: number, dHeight: number): void;
/** @ignore */
- static BarcodeReaderException(ag0: any, ag1: any): Error;
+ static BarcodeReaderException(ag0: any, ag1: any): BarcodeReaderException;
protected _handleRetJsonString(objRet: any): any;
/**
* Sets the optional argument for a specified mode in Modes parameters.
@@ -675,7 +745,7 @@ declare class BarcodeReader {
* Equivalent to the previous method `deleteInstance()`.
* @category Initialize and Destroy
*/
- destroy(): Promise;
+ destroy(): Promise;
}
interface FrameFilter {
/**
@@ -724,7 +794,7 @@ interface ScannerPlayCallbackInfo {
/**
* A class dedicated to video decoding.
* ```js
- * let scanner = await DBR.BarcodeScanner.createInstance();
+ * let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
* scanner.onUnduplicatedRead = txt => console.log(txt);
* await scanner.show();
* ```
@@ -746,7 +816,7 @@ declare class BarcodeScanner extends BarcodeReader {
* ```html
*
*
@@ -763,7 +833,7 @@ declare class BarcodeScanner extends BarcodeReader {
/**
* A mode not use video, get a frame from OS camera instead.
* ```js
- * let scanner = await DBR.BarcodeReader.createInstance();
+ * let scanner = await Dynamsoft.DBR.BarcodeReader.createInstance();
* if(scanner.singleFrameMode){
* // the browser does not provide webrtc API, dbrjs automatically use singleFrameMode instead
* scanner.show();
@@ -774,7 +844,7 @@ declare class BarcodeScanner extends BarcodeReader {
/**
* A mode not use video, get a frame from OS camera instead.
* ```js
- * let scanner = await DBR.BarcodeReader.createInstance();
+ * let scanner = await Dynamsoft.DBR.BarcodeReader.createInstance();
* scanner.singleFrameMode = true; // use singleFrameMode anyway
* scanner.show();
* ```
@@ -790,6 +860,8 @@ declare class BarcodeScanner extends BarcodeReader {
/** @ignore */
_lastDeviceId: string;
private _intervalDetectVideoPause;
+ private _vc_bPlayingVideoBeforeHide;
+ private _ev_documentHideEvent;
/** @ignore */
_video: HTMLVideoElement;
/** @ignore */
@@ -840,6 +912,27 @@ declare class BarcodeScanner extends BarcodeReader {
* refer: `favicon bug` https://bugs.chromium.org/p/chromium/issues/detail?id=1069731&q=favicon&can=2
*/
bPlaySoundOnSuccessfulRead: (boolean | string);
+ /**
+ * Whether to vibrate when the scanner reads a barcode successfully.
+ * Default value is `false`, which does not vibrate.
+ * Use `frame` or `true` to play a sound when any barcode is found within a frame.
+ * Use `unduplicated` to play a sound only when any unique/unduplicated barcode is found within a frame.
+ * ```js
+ * // https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#chrome_enterprise_policies
+ * startPlayButton.addEventListener('click', function() {
+ * scanner.bVibrateOnSuccessfulRead = false;
+ * scanner.bVibrateOnSuccessfulRead = true;
+ * scanner.bVibrateOnSuccessfulRead = "frame";
+ * scanner.bVibrateOnSuccessfulRead = "unduplicated";
+ * });
+ * ```
+ * refer: `favicon bug` https://bugs.chromium.org/p/chromium/issues/detail?id=1069731&q=favicon&can=2
+ */
+ bVibrateOnSuccessfulRead: (boolean | string);
+ /**
+ * @see [[bVibrateOnSuccessfulRead]]
+ */
+ vibrateDuration: number;
/** @ignore */
_allCameras: VideoDeviceInfo[];
/** @ignore */
@@ -879,7 +972,7 @@ declare class BarcodeScanner extends BarcodeReader {
/**
* Create a `BarcodeScanner` object.
* ```
- * let scanner = await DBR.BarcodeScanner.createInstance();
+ * let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
* ```
* @param config
* @category Initialize and Destroy
@@ -893,20 +986,26 @@ declare class BarcodeScanner extends BarcodeReader {
decodeUrl(source: string): Promise;
/** @ignore */
decodeBuffer(buffer: Uint8Array | Uint8ClampedArray | ArrayBuffer | Blob, width: number, height: number, stride: number, format: EnumImagePixelFormat, config?: any): Promise;
+ /**
+ * await scanner.showVideo();
+ * console.log(await scanner.decodeCurrentFrame());
+ */
+ decodeCurrentFrame(): Promise;
private clearMapDecodeRecord;
private static readonly singlePresetRegion;
private static isRegionSinglePreset;
private static isRegionNormalPreset;
/**
* Update runtime settings with a given struct, or a string of `speed`, `balance`, `coverage` and `single` to use preset settings for BarcodeScanner.
- * We recommend using the speed-optimized `single` preset if scanning only one barcode at a time. The `single` is only available in `BarcodeScanner`.
- * The default settings for BarcodeScanner is `single`, starting from version 8.0.0.
+ * We recommend using the speed-optimized `single` preset if scanning only one line at a time. The `single` is only available in `BarcodeScanner`.
+ * The default settings for BarcodeScanner is `single`.
* ```js
* await scanner.updateRuntimeSettings('balance');
* let settings = await scanner.getRuntimeSettings();
- * settings.barcodeFormatIds = DBR.EnumBarcodeFormat.BF_ONED;
+ * settings.barcodeFormatIds = Dynamsoft.DBR.EnumBarcodeFormat.BF_ONED;
* await scanner.updateRuntimeSettings(settings);
* ```
+ * @see [RuntimeSettings](https://www.dynamsoft.com/barcode-reader/programming/c-cplusplus/struct/PublicRuntimeSettings.html?ver=latest&utm_source=github&package=js)
* @category Runtime Settings
*/
updateRuntimeSettings(settings: RuntimeSettings | string): Promise;
@@ -1195,6 +1294,15 @@ declare class BarcodeScanner extends BarcodeReader {
* @category Open and Close
*/
open(): Promise;
+ /**
+ * Bind UI, open the camera, but not decode.
+ * ```js
+ * await scanner.openVideo();
+ * console.log(await scanner.decodeCurrentFrame());
+ * ```
+ * @category Open and Close
+ */
+ openVideo(): Promise;
/**
* Stop decoding, release camera, unbind UI.
* @category Open and Close
@@ -1208,6 +1316,15 @@ declare class BarcodeScanner extends BarcodeReader {
* @category Open and Close
*/
show(): Promise;
+ /**
+ * Bind UI, open the camera, but not decode, and remove the UIElement `display` style if the original style is `display:none;`.
+ * ```js
+ * await scanner.showVideo()
+ * console.log(await scanner.decodeCurrentFrame());
+ * ```
+ * @category Open and Close
+ */
+ showVideo(): Promise;
/**
* Stop decoding, release camera, unbind UI, and set the Element as `display:none;`.
* @category Open and Close
@@ -1290,70 +1407,6 @@ declare enum EnumDPMCodeReadingMode {
DPMCRM_SKIP = 0,
DPMCRM_REV = 2147483648
}
-declare enum EnumErrorCode {
- DBR_SYSTEM_EXCEPTION = 1,
- DBR_SUCCESS = 0,
- DBR_UNKNOWN = -10000,
- DBR_NO_MEMORY = -10001,
- DBR_NULL_REFERENCE = -10002,
- DBR_LICENSE_INVALID = -10003,
- DBR_LICENSE_EXPIRED = -10004,
- DBR_FILE_NOT_FOUND = -10005,
- DBR_FILETYPE_NOT_SUPPORTED = -10006,
- DBR_BPP_NOT_SUPPORTED = -10007,
- DBR_INDEX_INVALID = -10008,
- DBR_BARCODE_FORMAT_INVALID = -10009,
- DBR_CUSTOM_REGION_INVALID = -10010,
- DBR_MAX_BARCODE_NUMBER_INVALID = -10011,
- DBR_IMAGE_READ_FAILED = -10012,
- DBR_TIFF_READ_FAILED = -10013,
- DBR_QR_LICENSE_INVALID = -10016,
- DBR_1D_LICENSE_INVALID = -10017,
- DBR_DIB_BUFFER_INVALID = -10018,
- DBR_PDF417_LICENSE_INVALID = -10019,
- DBR_DATAMATRIX_LICENSE_INVALID = -10020,
- DBR_PDF_READ_FAILED = -10021,
- DBR_PDF_DLL_MISSING = -10022,
- DBR_PAGE_NUMBER_INVALID = -10023,
- DBR_CUSTOM_SIZE_INVALID = -10024,
- DBR_CUSTOM_MODULESIZE_INVALID = -10025,
- DBR_RECOGNITION_TIMEOUT = -10026,
- DBR_JSON_PARSE_FAILED = -10030,
- DBR_JSON_TYPE_INVALID = -10031,
- DBR_JSON_KEY_INVALID = -10032,
- DBR_JSON_VALUE_INVALID = -10033,
- DBR_JSON_NAME_KEY_MISSING = -10034,
- DBR_JSON_NAME_VALUE_DUPLICATED = -10035,
- DBR_TEMPLATE_NAME_INVALID = -10036,
- DBR_JSON_NAME_REFERENCE_INVALID = -10037,
- DBR_PARAMETER_VALUE_INVALID = -10038,
- DBR_DOMAIN_NOT_MATCHED = -10039,
- DBR_RESERVEDINFO_NOT_MATCHED = -10040,
- DBR_AZTEC_LICENSE_INVALID = -10041,
- DBR_LICENSE_DLL_MISSING = -10042,
- DBR_LICENSEKEY_NOT_MATCHED = -10043,
- DBR_REQUESTED_FAILED = -10044,
- DBR_LICENSE_INIT_FAILED = -10045,
- DBR_PATCHCODE_LICENSE_INVALID = -10046,
- DBR_POSTALCODE_LICENSE_INVALID = -10047,
- DBR_DPM_LICENSE_INVALID = -10048,
- DBR_FRAME_DECODING_THREAD_EXISTS = -10049,
- DBR_STOP_DECODING_THREAD_FAILED = -10050,
- DBR_SET_MODE_ARGUMENT_ERROR = -10051,
- DBR_LICENSE_CONTENT_INVALID = -10052,
- DBR_LICENSE_KEY_INVALID = -10053,
- DBR_LICENSE_DEVICE_RUNS_OUT = -10054,
- DBR_GET_MODE_ARGUMENT_ERROR = -10055,
- DBR_IRT_LICENSE_INVALID = -10056,
- DBR_MAXICODE_LICENSE_INVALID = -10057,
- DBR_GS1_DATABAR_LICENSE_INVALID = -10058,
- DBR_GS1_COMPOSITE_LICENSE_INVALID = -10059,
- DBR_DOTCODE_LICENSE_INVALID = -10061,
- DMERR_NO_LICENSE = -20000,
- DMERR_LICENSE_SYNC_FAILED = -20003,
- DMERR_TRIAL_LICENSE = -20010,
- DMERR_FAILED_TO_REACH_LTS = -20200
-}
declare enum EnumGrayscaleTransformationMode {
GTM_INVERTED = 1,
GTM_ORIGINAL = 2,
diff --git a/dist/dbr.scanner.html b/dist/dbr.scanner.html
index 3d750e8f..4caf7cea 100644
--- a/dist/dbr.scanner.html
+++ b/dist/dbr.scanner.html
@@ -11,6 +11,8 @@
+
+ Powered by Dynamsoft
diff --git a/example/web/vue3/src/components/BarcodeScanner.vue b/example/web/vue3/src/components/BarcodeScanner.vue
new file mode 100644
index 00000000..d9f9a946
--- /dev/null
+++ b/example/web/vue3/src/components/BarcodeScanner.vue
@@ -0,0 +1,168 @@
+
+
+
+
+
+
+
+
diff --git a/example/web/vue3/src/components/HelloWorld.vue b/example/web/vue3/src/components/HelloWorld.vue
new file mode 100644
index 00000000..dd1e649d
--- /dev/null
+++ b/example/web/vue3/src/components/HelloWorld.vue
@@ -0,0 +1,120 @@
+
+
+
{{ title }}
+
+
+ Choose image(s) to decode:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/web/vue3/src/dbr.js b/example/web/vue3/src/dbr.js
new file mode 100644
index 00000000..15aa7ec7
--- /dev/null
+++ b/example/web/vue3/src/dbr.js
@@ -0,0 +1,6 @@
+import DBR from "dynamsoft-javascript-barcode";
+DBR.BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.2.3/dist/";
+// Please visit https://www.dynamsoft.com/customer/license/trialLicense/?product=dbr&utm_source=github&package=js to get a trial license
+DBR.BarcodeReader.productKeys = "PRODUCT-KEYS";
+// DBR.BarcodeReader._bUseFullFeature = true; // Control of loading min wasm or full wasm.
+export default DBR;
diff --git a/example/web/vue3/src/main.js b/example/web/vue3/src/main.js
new file mode 100644
index 00000000..01433bca
--- /dev/null
+++ b/example/web/vue3/src/main.js
@@ -0,0 +1,4 @@
+import { createApp } from 'vue'
+import App from './App.vue'
+
+createApp(App).mount('#app')
diff --git a/example/web/webpack/package.json b/example/web/webpack/package.json
index 65f9c5a7..a7847842 100644
--- a/example/web/webpack/package.json
+++ b/example/web/webpack/package.json
@@ -12,6 +12,6 @@
"webpack": "^4.41.3"
},
"dependencies": {
- "dynamsoft-javascript-barcode": "8.2.1"
+ "dynamsoft-javascript-barcode": "8.2.3"
}
}
diff --git a/example/web/webpack/src/index.js b/example/web/webpack/src/index.js
index dc3f67ad..29af986b 100644
--- a/example/web/webpack/src/index.js
+++ b/example/web/webpack/src/index.js
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import { BarcodeReader, BarcodeScanner } from "dynamsoft-javascript-barcode";
-BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.2.1/dist/";
+BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.2.3/dist/";
// Please visit https://www.dynamsoft.com/customer/license/trialLicense/?product=dbr&utm_source=github&package=js to get a trial license
BarcodeReader.productKeys = "PRODUCT-KEYS";
// BarcodeReader._bUseFullFeature = true; // Control of loading min wasm or full wasm.
diff --git a/package.js b/package.js
index 89db3094..ec5206ed 100644
--- a/package.js
+++ b/package.js
@@ -12,13 +12,13 @@ Package.onUse(function(api) {
"/dist/dbr.js",
"/dist/dbr.mjs",
"/dist/dbr.browser.mjs",
- "/dist/dbr-8.2.1.worker.js",
- "/dist/dbr-8.2.1.wasm.js",
- "/dist/dbr-8.2.1.wasm",
- "/dist/dbr-8.2.1.full.wasm.js",
- "/dist/dbr-8.2.1.full.wasm",
- "/dist/dbr-8.2.1.node.wasm.js",
- "/dist/dbr-8.2.1.node.wasm",
+ "/dist/dbr-8.2.3.worker.js",
+ "/dist/dbr-8.2.3.wasm.js",
+ "/dist/dbr-8.2.3.wasm",
+ "/dist/dbr-8.2.3.full.wasm.js",
+ "/dist/dbr-8.2.3.full.wasm",
+ "/dist/dbr-8.2.3.node.wasm.js",
+ "/dist/dbr-8.2.3.node.wasm",
"/dist/dbr.d.ts",
"/dist/dbr.reference.d.ts",
"/dist/dbr.scanner.html"
diff --git a/package.json b/package.json
index 584a5a81..60085aca 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "dynamsoft-javascript-barcode",
- "version": "8.2.1",
+ "version": "8.2.3",
"description": "Dynamsoft Barcode Reader JS is a recognition SDK which enables you to embed barcode reading functionality in your web, desktop, and mobile applications. With a few lines of JavaScript code, you can develop a robust application to scan a linear barcode, QR Code, DaraMatrix, PDF417, and Aztec Code.",
"files": [
"/dist/dbr.js",