-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathdbr.js
More file actions
11 lines (11 loc) · 82.7 KB
/
dbr.js
File metadata and controls
11 lines (11 loc) · 82.7 KB
1
2
3
4
5
6
7
8
9
10
11
/**
* Dynamsoft JavaScript Library
* @product Dynamsoft Barcode Reader JS Edition
* @website http://www.dynamsoft.com
* @preserve Copyright 2021, Dynamsoft Corporation
* @author Dynamsoft
* @version 8.4.0 (js 20210628)
* @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,r,n){return function(e){var t={};function i(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},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 r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},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=r},function(e,t){e.exports=n},function(e,t,i){"use strict";var r,n,o,s;i.r(t),i.d(t,"DBR",(function(){return W})),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 f})),i.d(t,"EnumClarityCalculationMethod",(function(){return A})),i.d(t,"EnumClarityFilterMode",(function(){return m})),i.d(t,"EnumColourClusteringMode",(function(){return S})),i.d(t,"EnumColourConversionMode",(function(){return D})),i.d(t,"EnumConflictMode",(function(){return T})),i.d(t,"EnumDeblurMode",(function(){return v})),i.d(t,"EnumDeformationResistingMode",(function(){return p})),i.d(t,"EnumDPMCodeReadingMode",(function(){return M})),i.d(t,"EnumErrorCode",(function(){return n})),i.d(t,"EnumGrayscaleTransformationMode",(function(){return C})),i.d(t,"EnumImagePixelFormat",(function(){return r})),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 b})),i.d(t,"EnumPDFReadingMode",(function(){return N})),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,"EnumTextFilterMode",(function(){return V})),i.d(t,"EnumTextResultOrderMode",(function(){return G})),i.d(t,"EnumTextureDetectionMode",(function(){return x})),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"}(r||(r={})),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"}(n||(n={})),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,r){return new(i||(i=Promise))((function(n,o){function s(e){try{d(r.next(e))}catch(e){o(e)}}function a(e){try{d(r.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((r=r.apply(e,t||[])).next())}))};const d=!!("object"==typeof global&&global.process&&global.process.release&&global.process.release.name&&"undefined"==typeof HTMLCanvasElement),_=!d&&"undefined"==typeof self,l=d?global:_?{}: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._setWarnnedEx=new Set,this._lastErrorCode=0,this._lastErrorString="",this._lastInnerDecodeDuration=0}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.");"number"==typeof e&&(e=e.toString()),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:!!(d?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<e.length;++t){if(!d&&!_){let i=document.createElement("a");i.href=e[t],e[t]=i.href}e[t].endsWith("/")||(e[t]+="/")}c._licenseServer=e}}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(e){if("unload"!=this._loadWasmStatus)throw new Error("`deviceFriendlyName` is not allowed to change after loadWasm is called.");c._deviceFriendlyName=e||""}static get _bUseFullFeature(){return this.__bUseFullFeature}static set _bUseFullFeature(e){if("unload"!=this._loadWasmStatus)throw new Error("`_bUseFullFeature` is not allowed to change after loadWasm is called.");c.__bUseFullFeature=e}set region(e){this._region=e}get region(){return this._region}static isLoaded(){return"loadSuccess"==this._loadWasmStatus}static get lastErrorCode(){return this._lastErrorCode}static get lastErrorString(){return this._lastErrorString}get lastErrorCode(){return this._lastErrorCode}get lastErrorString(){return this._lastErrorString}static loadWasm(){return a(this,void 0,void 0,(function*(){if(d&&process.version<"v12")throw new Error("DBRJS SDK requires nodejs version >= v12.");let e,t=this.productKeys,r=(0==t.length||t.startsWith("P")||t.startsWith("L"))&&0==this.organizationID.length,o=r||t.length>=8&&!t.startsWith("t")&&!t.startsWith("f")&&!t.startsWith("P")&&!t.startsWith("L")||0==t.length&&0!=this.organizationID.length;if(o&&(d?process.version<"v15"&&(e="To use handshake requires nodejs version >= v15."):(l.crypto||(e="Please upgrade your browser to support handshake code."),l.crypto.subtle||(e="Require https to use handshake code in this browser."))),e){if(!r)throw new Error(e);r=!1,o=!1,console.warn(e),this._lastErrorCode=n.DMERR_FAILED_TO_REACH_LTS,this._lastErrorString=e}return r&&(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(d||this.engineResourcePath.startsWith(location.origin)||(e=yield fetch(e).then(e=>e.blob()).then(e=>URL.createObjectURL(e))),d){const t=i(0);c._dbrWorker=new t.Worker(e)}else c._dbrWorker=new Worker(e);this._dbrWorker.onerror=e=>{c._loadWasmStatus="loadFail";let t=new Error(e.message);this._loadWasmErr=t;for(let e of this._loadWasmCallbackArr)e(t);this._loadWasmCallbackArr=[]},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":{t.message&&(t.message=t.message.replace("(https://www.dynamsoft.com/purchase-center/)","(https://www.dynamsoft.com/store/dynamsoft-barcode-reader/#javascript)"));let e=!1;if(r&&(e=!0),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._loadWasmCallbackArr=[],this._dbrWorker.onerror=null,t.message&&console.warn(t.message)}else{let i=new Error(t.message);i.stack=t.stack+"\n"+i.stack,c._loadWasmStatus="loadFail",this._loadWasmErr=i;for(let e of this._loadWasmCallbackArr)e(i);this._loadWasmCallbackArr=[],e||111==t.ltsErrorCode&&-1!=t.message.toLowerCase().indexOf("trial license")&&(e=!0)}e&&this.showDialog(t.success?"warn":"error",t.message);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)}})),d&&this._dbrWorker.on("message",this._dbrWorker.onmessage),this._dbrWorker.postMessage({type:"loadWasm",bd:this._bWasmDebug,engineResourcePath:this.engineResourcePath,version:this._jsVersion,brtk:o,bptk:r,pk:t,og:this.organizationID,dm:!d&&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(this._loadWasmErr)}})))}))}static showDialog(e,t){return a(this,void 0,void 0,(function*(){if(!d&&!this._bNeverShowDialog)try{let i=yield fetch(c.engineResourcePath+"lts.license.dialog.html");if(!i.ok)throw Error("Get license dialog fail. Network Error: "+i.statusText);let r=yield i.text();if(!r.trim().startsWith("<"))throw Error("Get license dialog fail. Can't get valid HTMLElement.");let n=document.createElement("div");n.innerHTML=r;let o=[];for(let e=0;e<n.childElementCount;++e){let t=n.children[e];t instanceof HTMLStyleElement&&(o.push(t),document.head.append(t))}let s=1==n.childElementCount?n.children[0]:n;s.remove();let a,d,_,l,h,u=[s],g=s.children;for(let e of g)u.push(e);for(let e=0;e<u.length;++e)for(let t of u[e].children)u.push(t);for(let i of u)if(!a&&i.classList.contains("lts-license-mask"))a=i,i.addEventListener("click",e=>{if(i==e.target){s.remove();for(let e of o)e.remove()}});else if(!d&&i.classList.contains("lts-license-icon-close"))d=i,i.addEventListener("click",()=>{s.remove();for(let e of o)e.remove()});else if(!_&&i.classList.contains("lts-license-icon-error"))_=i,"error"!=e&&i.remove();else if(!l&&i.classList.contains("lts-license-icon-warn"))l=i,"warn"!=e&&i.remove();else if(!h&&i.classList.contains("lts-license-msg-content")){h=i;let e=t;for(;e;){let t=e.indexOf("["),r=e.indexOf("]",t),n=e.indexOf("(",r),o=e.indexOf(")",n);if(-1==t||-1==r||-1==n||-1==o){i.appendChild(new Text(e));break}t>0&&i.appendChild(new Text(e.substring(0,t)));let s=document.createElement("a"),a=e.substring(t+1,r);s.innerText=a;let d=e.substring(n+1,o);s.setAttribute("href",d),s.setAttribute("target","_blank"),i.appendChild(s),e=e.substring(o+1)}}document.body.appendChild(s)}catch(e){c._onLog&&c._onLog(e.message||e)}}))}static createInstanceInWorker(e=!1){return a(this,void 0,void 0,(function*(){return yield this.loadWasm(),yield new Promise((t,i)=>{let r=c._nextTaskID++;this._taskCallbackMap.set(r,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:r,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()),d)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,r,n,o){return a(this,void 0,void 0,(function*(){return yield new Promise((s,a)=>{let d=c._nextTaskID++;c._taskCallbackMap.set(d,e=>{if(e.success){let t,i=c._onLog?Date.now():0;this.bufferShared&&!this.bufferShared.length&&(this.bufferShared=e.buffer),this._lastInnerDecodeDuration=e.duration;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:d,instanceID:this._instanceID,body:{buffer:e,width:t,height:i,stride:r,format:n,config:o}},[e.buffer])})}))}_decodeBuffer_Blob(e,t,i,r,n,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 r=new FileReader;r.readAsArrayBuffer(e),r.onload=()=>{t(r.result)},r.onerror=()=>{i(r.error)}}).then(e=>this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,r,n,o))}))}decodeBuffer(e,t,i,r,n,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()),d?e instanceof Uint8Array?s=yield this._decodeBuffer_Uint8Array(e,t,i,r,n,o):e instanceof Buffer&&(s=yield this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,r,n,o)):e instanceof Uint8Array||e instanceof Uint8ClampedArray?s=yield this._decodeBuffer_Uint8Array(e,t,i,r,n,o):e instanceof ArrayBuffer?s=yield this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,r,n,o):e instanceof Blob&&(s=yield this._decodeBuffer_Blob(e,t,i,r,n,o)),s}))}_decodeFileInMemory_Uint8Array(e){return a(this,void 0,void 0,(function*(){return yield new Promise((t,i)=>{let r=c._nextTaskID++;c._taskCallbackMap.set(r,e=>{if(e.success){let r;this._lastInnerDecodeDuration=e.duration;try{r=this._handleRetJsonString(e.decodeReturn)}catch(e){return i(e)}return t(r)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}}),c._dbrWorker.postMessage({type:"decodeFileInMemory",id:r,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(!d)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 r=c._nextTaskID++;c._taskCallbackMap.set(r,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:r,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 r=c._nextTaskID++;c._taskCallbackMap.set(r,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:r,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,r=null;if("undefined"!=typeof createImageBitmap)try{i=yield createImageBitmap(e)}catch(e){}i||(r=yield function(e){return new Promise((t,i)=>{let r=URL.createObjectURL(e),n=new Image;n.dbrObjUrl=r,n.src=r,n.onload=()=>{t(n)},n.onerror=e=>{i(new Error("Can't convert blob to image : "+(e instanceof Event?e.type:e)))}})}(e));let n=yield this._decode_Image(i||r,t);return i&&i.close(),n}))}_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,r,n=e instanceof HTMLImageElement?e.naturalWidth:e.width,o=e instanceof HTMLImageElement?e.naturalHeight:e.height,s=Math.max(n,o);if(s>this._canvasMaxWH){let e=this._canvasMaxWH/s;i=Math.round(n*e),r=Math.round(o*e)}else i=n,r=o;let a,d=0,_=0,h=n,u=o,g=n,E=o,R=t.region;if(R){let e,t,s,a;R.regionMeasuredByPercentage?(e=R.regionLeft*i/100,t=R.regionTop*r/100,s=R.regionRight*i/100,a=R.regionBottom*r/100):(e=R.regionLeft,t=R.regionTop,s=R.regionRight,a=R.regionBottom),g=s-e,h=Math.round(g/i*n),E=a-t,u=Math.round(E/r*o),d=Math.round(e/i*n),_=Math.round(t/r*o)}!this.bSaveOriCanvas&&l.OffscreenCanvas?a=new OffscreenCanvas(g,E):(a=document.createElement("canvas"),a.width=g,a.height=E);let I,f=a.getContext("2d");0==d&&0==_&&n==h&&o==u&&n==g&&o==E?f.drawImage(e,0,0):f.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 A=yield this._decode_Canvas(a,I);return c.fixResultLocationWhenFilterRegionInJs(R,A,d,_,h,u,g,E),A}))}_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,r.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||{};const i=e.videoWidth,n=e.videoHeight,o=Math.max(i,n);let s,a;if(o>this._canvasMaxWH){let e=this._canvasMaxWH/o;s=Math.round(i*e),a=Math.round(n*e)}else s=i,a=n;let d=0,_=0,h=i,u=n,g=i,E=n,R=t.region;if(R){let e,t,r,o;R.regionMeasuredByPercentage?(e=R.regionLeft*s/100,t=R.regionTop*a/100,r=R.regionRight*s/100,o=R.regionBottom*a/100):(e=R.regionLeft,t=R.regionTop,r=R.regionRight,o=R.regionBottom),g=r-e,h=Math.round(g/s*i),E=o-t,u=Math.round(E/a*n),d=Math.round(e/s*i),_=Math.round(t/a*n)}let I=0==d&&0==_&&i==h&&n==u&&i==g&&n==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 r=i.createProgram();i.attachShader(r,e),i.attachShader(r,t),i.linkProgram(r),i.getProgramParameter(r,i.LINK_STATUS)||console.error("Unable to initialize the shader program: "+i.getProgramInfoLog(r)),i.useProgram(r),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 n=i.getAttribLocation(r,"a_position");i.enableVertexAttribArray(n),i.vertexAttribPointer(n,2,i.FLOAT,!1,16,0);let o=i.getAttribLocation(r,"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(r,"u_texture"),0)}(!this.glImgData||this.glImgData.length<g*E*4)&&(this.glImgData=new Uint8Array(g*E*4)),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e);let n=c._onLog?Date.now():0;i.drawArrays(i.TRIANGLE_STRIP,0,4),c._onLog&&c._onLog("Grey cost: "+(Date.now()-n));let o=this.glImgData;i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,o);let s=c._onLog?Date.now():0,a=g*E;(!this.bufferShared||this.bufferShared.length<a)&&(this.bufferShared=new Uint8Array(a));let d=this.bufferShared;for(let e=0;e<a;++e)d[e]=o[4*e];return c._onLog&&c._onLog("Extract grey cost: "+(Date.now()-s)),yield this._decodeBuffer_Uint8Array(d,g,E,g,r.IPF_GrayScaled)}{let i=null;if(this.bSaveOriCanvas)i=document.createElement("canvas"),i.width=g,i.height=E,i.dbrCtx2d=i.getContext("2d");else{for(let e of this.videoCvses)if(e.width==g&&e.height==E){i=e;break}i||(l.OffscreenCanvas?i=new OffscreenCanvas(g,E):(i=document.createElement("canvas"),i.width=g,i.height=E),i.dbrCtx2d=i.getContext("2d"),this.videoCvses.length>=this.maxVideoCvsLength&&(this.videoCvses=this.videoCvses.slice(1)),this.videoCvses.push(i))}const r=i.dbrCtx2d;let n;I?r.drawImage(e,0,0):r.drawImage(e,d,_,h,u,0,0,g,E),R?(n=JSON.parse(JSON.stringify(t)),delete n.region):n=t;let o=yield this._decode_Canvas(i,n);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)),d){let t=Buffer.from(e,"base64");return yield this._decodeFileInMemory_Uint8Array(new Uint8Array(t))}{let i=atob(e),r=i.length,n=new Uint8Array(r);for(;r--;)n[r]=i.charCodeAt(r);return yield this._decode_Blob(new Blob([n]),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(d){let t=yield new Promise((t,r)=>{(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 r("http get fail, statusCode: "+e.statusCode)})});return yield this._decodeFileInMemory_Uint8Array(t)}{let i=yield new Promise((t,i)=>{let r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="blob",r.send(),r.onloadend=()=>a(this,void 0,void 0,(function*(){t(r.response)})),r.onerror=()=>{i(new Error("Network Error: "+r.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)"),!d)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 r=yield new Promise((i,r)=>{t.readFile(e,(e,t)=>{e?r(e):i(new Uint8Array(t))})});return yield this._decodeFileInMemory_Uint8Array(r)}))}static fixResultLocationWhenFilterRegionInJs(e,t,i,r,n,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);let d=s/n,_=a/o;t.x1=t.x1/d+i,t.x2=t.x2/d+i,t.x3=t.x3/d+i,t.x4=t.x4/d+i,t.y1=t.y1/_+r,t.y2=t.y2/_+r,t.y3=t.y3/_+r,t.y4=t.y4/_+r,2==t.resultCoordinateType&&(t.x1*=100/n,t.x2*=100/n,t.x3*=100/n,t.x4*=100/n,t.y1*=100/o,t.y2*=100/o,t.y3*=100/o,t.y4*=100/o)}}static BarcodeReaderException(e,t){let i,r=n.DBR_UNKNOWN;return"number"==typeof e?(r=e,i=new Error(t)):i=new Error(e),i.code=r,i}_handleRetJsonString(e){let t=n;if(e.textResults){for(let t=0;t<e.textResults.length;t++){let i=e.textResults[t];try{let e=i.barcodeText,t="";for(let i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);try{i.barcodeText=decodeURIComponent(escape(t))}catch(e){i.barcodeText=t}}catch(e){i.barcodeText=""}if(null!=i.exception){this._setWarnnedEx.has(i.exception)||(this._setWarnnedEx.add(i.exception),console.warn(i.exception));let e={};i.exception.split(";").forEach(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.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,r){return a(this,void 0,void 0,(function*(){return yield new Promise((n,o)=>{let s=c._nextTaskID++;c._taskCallbackMap.set(s,e=>{if(e.success){try{this._handleRetJsonString(e.setReturn)}catch(e){return o(e)}return n()}{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:r}})})}))}getModeArgument(e,t,i){return a(this,void 0,void 0,(function*(){return yield new Promise((r,n)=>{let o=c._nextTaskID++;c._taskCallbackMap.set(o,e=>{if(e.success){let t;try{t=this._handleRetJsonString(e.getReturn)}catch(e){return n(e)}return r(t)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,n(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 n;switch(c._onLog&&c._onLog(" "+i.length+" "+i.byteLength+" "+e.width+" "+e.height+" "+e.stride+" "+e.format),e.format){case r.IPF_ABGR_8888:n=new Uint8ClampedArray(i);break;case r.IPF_RGB_888:{const e=i.length/3;n=new Uint8ClampedArray(4*e);for(let t=0;t<e;++t)n[4*t]=i[3*t+2],n[4*t+1]=i[3*t+1],n[4*t+2]=i[3*t],n[4*t+3]=255;break}case r.IPF_GrayScaled:{const e=i.length;n=new Uint8ClampedArray(4*e);for(let t=0;t<e;t++)n[4*t]=n[4*t+1]=n[4*t+2]=i[t],n[4*t+3]=255;break}case r.IPF_Binary:case r.IPF_BinaryInverted:{e.width=8*e.stride,e.height=i.length/e.stride;const t=i.length;n=new Uint8ClampedArray(8*t*4);for(let e=0;e<t;e++){let t=i[e];for(let i=0;i<8;++i)n[4*(8*e+i)]=n[4*(8*e+i)+1]=n[4*(8*e+i)+2]=(128&t)/128*255,n[4*(8*e+i)+3]=255,t<<=1}break}default:console.warn("unknow intermediate image",e)}if(!n)continue;let o=new ImageData(n,e.width,e.height),s=document.createElement("canvas");s.width=e.width,s.height=e.height,s.getContext("2d").putImageData(o,0,0),t.push(s)}return t}))}destroy(){return c._onLog&&c._onLog("destroy()"),this.bDestroyed=!0,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:"destroy",id:i,instanceID:this._instanceID})})}}c._jsVersion="8.4.0",c._jsEditVersion="20210628",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._sessionPassword=d||_||!document.currentScript?"":document.currentScript.getAttribute("data-sessionPassword")||"",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<e.length;t++){var i=e[t].string,r=e[t].prop;if(this.versionSearchString=e[t].versionSearch||e[t].identity,i){if(-1!=i.indexOf(e[t].subString))return e[t].identity}else if(r)return e[t].identity}},searchVersion:function(e){var t=e.indexOf(this.versionSearchString);if(-1!=t)return parseFloat(e.substring(t+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Edge",identity:"Edge"},{string:navigator.userAgent,subString:"OPR",identity:"OPR"},{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"}],dataOS:[{string:navigator.userAgent,subString:"Android",identity:"Android"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone"},{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};return e.init(),{browser:e.browser,version:e.version,OS:e.OS}}if(_)return{browser:"ssr",version:0,OS:"ssr"};{const e=i(4);return{browser:"node",version:process.version.substring(1),OS:e&&e.platform?e.platform()+e.release():"Unknown"}}}(),c._workerName="dbr-"+c._jsVersion+".worker.js",c._engineResourcePath=(()=>{if(d)return __dirname+"/";if(!_&&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._bNeverShowDialog=!1,c.__bUseFullFeature=d,c._nextTaskID=0,c._taskCallbackMap=new Map,c._loadWasmStatus="unload",c._loadWasmCallbackArr=[],c._lastErrorCode=0,c._lastErrorString="",c._loadWasmErr=null;var h=function(e,t,i,r){return new(i||(i=Promise))((function(n,o){function s(e){try{d(r.next(e))}catch(e){o(e)}}function a(e){try{d(r.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((r=r.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()})},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()})},this._onCloseBtnClick=()=>{this.hide()},this.iPlayRound=0,this.promisePlay=null}static get defaultUIElementURL(){var e;return null===(e=this._defaultUIElementURL)||void 0===e?void 0:e.replace("@engineResourcePath/",c.engineResourcePath)}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("setUIElement(elementOrUrl): 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<t.childElementCount;++e){let i=t.children[e];i instanceof HTMLStyleElement&&(this.styleEls.push(i),document.head.append(i))}(e=1==t.childElementCount?t.children[0]:t).remove()}this.UIElement=e}))}get singleFrameMode(){return this._singleFrameMode}set singleFrameMode(e){if(this._isOpen)throw new Error("`singleFrameMode` is not allowed to change when scanner is open.");this._singleFrameMode=e,this._singleFrameMode&&(()=>{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 yield t.setUIElement(this.defaultUIElementURL),t.singleFrameMode&&console.warn("The `navigator.mediaDevices.getUserMedia` is unavailable. automatically change to `singleFrameMode`."),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,r,n,o){return super.decodeBuffer(e,t,i,r,n,o)}decodeCurrentFrame(e){return h(this,void 0,void 0,(function*(){return this._assertOpen(),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<e.length;++t){let i=e[t];i&&((i.regionLeft||i.regionTop||i.regionRight||i.regionBottom||i.regionMeasuredByPercentage)&&(i.regionLeft||i.regionTop||100!=i.regionRight||100!=i.regionBottom||!i.regionMeasuredByPercentage)||(e[t]=null))}this.region=e}else this.region=null;else(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;this.bFilterRegionInJs&&(t.region={regionLeft:0,regionTop:0,regionRight:0,regionBottom:0,regionMeasuredByPercentage:0})}yield new Promise((e,i)=>{let r=c._nextTaskID++;c._taskCallbackMap.set(r,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:r,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(){if(!this.UIElement)throw new Error("Need to define `UIElement` before opening.");let e=[this.UIElement],t=this.UIElement.children;for(let i of t)e.push(i);for(let t=0;t<e.length;++t)for(let i of e[t].children)e.push(i);let i=null;for(let t of e)!this._video&&t.classList.contains("dbrScanner-video")?(this._video=t,this._video.setAttribute("playsinline","true")):!this._cvsDrawArea&&t.classList.contains("dbrScanner-cvs-drawarea")?this._cvsDrawArea=t:!this._divScanArea&&t.classList.contains("dbrScanner-cvs-scanarea")?this._divScanArea=t:!this._divScanLight&&t.classList.contains("dbrScanner-scanlight")?this._divScanLight=t:!this._bgLoading&&t.classList.contains("dbrScanner-bg-loading")?this._bgLoading=t:!this._bgCamera&&t.classList.contains("dbrScanner-bg-camera")?this._bgCamera=t:!this._selCam&&t.classList.contains("dbrScanner-sel-camera")?this._selCam=t:!this._selRsl&&t.classList.contains("dbrScanner-sel-resolution")?(this._selRsl=t,this._selRsl.options.length||(this._selRsl.innerHTML=[this._optGotRsl?"":'<option class="dbrScanner-opt-gotResolution" value="got"></option>','<option data-width="1920" data-height="1080">ask 1920 x 1080</option>','<option data-width="1280" data-height="720">ask 1280 x 720</option>','<option data-width="640" data-height="480">ask 640 x 480</option>'].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(){if(this._selCam&&(this._selCam.innerHTML=""),this._selCam){let e;for(let t of this._allCameras){let i=document.createElement("option");i.value=t.deviceId,i.innerText=t.label,this._selCam.append(i),t.deviceId&&this._currentCamera&&this._currentCamera.deviceId==t.deviceId&&(e=i)}this._selCam.value=e?e.value:""}}getAllCameras(){return h(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices(),t=[];let i=0;for(let r=0;r<e.length;r++){let n,o=e[r];"videoinput"==o.kind&&(n={},n.deviceId=o.deviceId,n.label=o.label?o.label:"camera "+i++,t.push(n))}return this._allCameras=t,Promise.resolve(t)}))}getCurrentCamera(){return h(this,void 0,void 0,(function*(){let e=void 0;if(this._video)for(let t of this._video.srcObject.getVideoTracks()){if(e)break;for(let i of this._allCameras)if(t.label==i.label){e=i,this._lastDeviceId=i.deviceId;break}}return this._currentCamera=e,e}))}setCurrentCamera(e){return h(this,void 0,void 0,(function*(){return yield this.play(e.deviceId||e)}))}getResolution(){return this._isOpen?[this._video.videoWidth,this._video.videoHeight]:null}setResolution(e,t){return h(this,void 0,void 0,(function*(){let i,r;return this._isOpen?(e instanceof Array?(i=e[0],r=e[1]):(i=e,r=t),yield this.play(null,i,r)):yield Promise.reject(new Error("The camera is not open."))}))}getScanSettings(){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){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 r=c._nextTaskID++;c._taskCallbackMap.set(r,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:r,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"),this._drawRegionsults()}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}const r=++this.iPlayRound;return this.promisePlay&&(yield this.promisePlay,r<this.iPlayRound)?{width:this._video.videoWidth,height:this._video.videoHeight}:(this.promisePlay=(()=>h(this,void 0,void 0,(function*(){try{this._video&&this._video.srcObject&&this.stop(),c._onLog&&c._onLog("======before video========"),"Android"==c.browserInfo.OS&&(yield this.getAllCameras());let r=()=>{if(this.bDestroyed)throw new Error("The BarcodeScanner instance has been destroyed.")};const n=JSON.parse(JSON.stringify(this.videoSettings));let o,s;if("boolean"==typeof n.video&&(n.video={}),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={exact: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)),c._onLog&&c._onLog(n);let a,d=[0,500],_=null,l=e=>h(this,void 0,void 0,(function*(){for(let t of d){r(),t&&(yield new Promise(e=>setTimeout(e,t))),r();try{s=yield navigator.mediaDevices.getUserMedia(e);break}catch(e){_=e,c._onLog&&c._onLog(e.message||e)}}}));if(yield l(n),!s){if(c._onLog&&c._onLog("======try getUserMedia again========"),a=JSON.parse(JSON.stringify(n)),"object"==typeof a.video){"iPhone"==c.browserInfo.OS?(t>=1280||i>=1280?a.video.width=1280:t>=640||i>=640?a.video.width=640:(t<640||i<640)&&(a.video.width=320),delete a.video.height):o?(delete a.video.facingMode,this._allCameras.length&&(a.video.deviceId={ideal:this._allCameras[this._allCameras.length-1].deviceId})):a.video=!0}c._onLog&&c._onLog(a),yield l(a)}if(s||(d=[1e3,2e3],yield l(n)),s||(yield l(a)),!s)throw _;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])}c._onLog&&c._onLog("======play video========"),yield new Promise((e,t)=>{this._video.srcObject=s,this._video.onloadedmetadata=()=>h(this,void 0,void 0,(function*(){this._video.onloadedmetadata=null,yield this._video.play(),e()})),setTimeout(()=>t(new Error("Failed to play video. Timeout.")),4e3)}),c._onLog&&c._onLog("======played video========"),this._bgLoading&&(this._bgLoading.style.animationPlayState="paused");const u="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=u,this._selRsl&&this._optGotRsl.parentNode==this._selRsl&&(this._selRsl.value="got")),c._onLog&&c._onLog(u),yield this.getAllCameras(),yield this.getCurrentCamera(),this._renderSelCameraInfo();let g={width:this._video.videoWidth,height:this._video.videoHeight};return this.onPlayed&&setTimeout(()=>{this.onPlayed(g)},0),this.promisePlay=null,g}catch(e){throw this.promisePlay=null,e}})))(),yield this.promisePlay)}))}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 e<t.min?e=t.min:e>t.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 e<t.min?e=t.min:e>t.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 e<t.min?e=t.min:e>t.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 e<t.min?e=t.min:e>t.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 ======="),c._onLog&&(this._timeStartDecode=Date.now());const 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.decodeCurrentFrame(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: "+(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=>{c._onLog&&c._onLog(e.message||e),setTimeout(()=>{this._loopReadVideo()},Math.max(this.intervalTime,1e3)),"platform error"==e.message||console.warn(e.message)})}))}_drawRegionsults(e){let t,i,r;if(this.beingLazyDrawRegionsults=!1,this.singleFrameMode){if(!this.oriCanvas)return;t="contain",i=this.oriCanvas.width,r=this.oriCanvas.height}else{if(!this._video)return;t=this._video.style.objectFit||"contain",i=this._video.videoWidth,r=this._video.videoHeight}let n=this.region;if(n&&(!n.regionLeft&&!n.regionRight&&!n.regionTop&&!n.regionBottom&&!n.regionMeasuredByPercentage||n instanceof Array?n=null:n.regionMeasuredByPercentage?n=n.regionLeft||n.regionRight||100!==n.regionTop||100!==n.regionBottom?{regionLeft:Math.round(n.regionLeft/100*i),regionTop:Math.round(n.regionTop/100*r),regionRight:Math.round(n.regionRight/100*i),regionBottom:Math.round(n.regionBottom/100*r)}:null:(n=JSON.parse(JSON.stringify(n)),delete n.regionMeasuredByPercentage)),this._cvsDrawArea){this._cvsDrawArea.style.objectFit=t;let o=this._cvsDrawArea;o.width=i,o.height=r;let s=o.getContext("2d");if(n){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(n.regionLeft-e,n.regionTop-e,n.regionRight-n.regionLeft+2*e,n.regionBottom-n.regionTop+2*e),s.globalCompositeOperation="source-over",s.strokeStyle=this.regionMaskStrokeStyle,s.lineWidth=this.regionMaskLineWidth,s.rect(n.regionLeft,n.regionTop,n.regionRight-n.regionLeft,n.regionBottom-n.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/t<i/r?(o=e/i,this._divScanArea.style.left="0",this._divScanArea.style.top=Math.round((t-r*o)/2)+"px"):(o=t/r,this._divScanArea.style.left=Math.round((e-i*o)/2)+"px",this._divScanArea.style.top="0");let s=n?Math.round(n.regionLeft*o):0,a=n?Math.round(n.regionTop*o):0,d=n?Math.round(n.regionRight*o-s):Math.round(i*o),_=n?Math.round(n.regionBottom*o-a):Math.round(r*o);this._divScanArea.style.marginLeft=s+"px",this._divScanArea.style.marginTop=a+"px",this._divScanArea.style.width=d+"px",this._divScanArea.style.height=_+"px"}}_clearRegionsults(){this._cvsDrawArea&&(this._cvsDrawArea.width=this._cvsDrawArea.height=0)}open(){return h(this,void 0,void 0,(function*(){this._bindUI();let e=yield this.play();return this.singleFrameMode||this._loopReadVideo(),e}))}openVideo(){return h(this,void 0,void 0,(function*(){this._bindUI();let e=yield this.play();return this._bPauseScan=!0,this.singleFrameMode||this._loopReadVideo(),e}))}close(){return h(this,void 0,void 0,(function*(){this.stop(),this._unbindUI(),this._bPauseScan=!1}))}show(){return h(this,void 0,void 0,(function*(){this._bindUI(),this._show();let e=yield this.play();return this.singleFrameMode||this._loopReadVideo(),e}))}showVideo(){return h(this,void 0,void 0,(function*(){this._bindUI(),this._show();let e=yield this.play();return this._bPauseScan=!0,this.singleFrameMode||this._loopReadVideo(),e}))}hide(){return h(this,void 0,void 0,(function*(){this.stop(),this._unbindUI(),this._bPauseScan=!1,this.UIElement.style.display="none"}))}destroy(){const e=Object.create(null,{destroy:{get:()=>super.destroy}});return h(this,void 0,void 0,(function*(){document.removeEventListener("visibilitychange",this._ev_documentHideEvent),yield 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,f,A,m,S,D,T,v,p,M,C,y,L,O,b,N,B,P,F,w,U,k,V,G,x;g._defaultUIElementURL="@engineResourcePath/dbr.scanner.html",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"}(f||(f={})),function(e){e[e.ECCM_CONTRAST=1]="ECCM_CONTRAST"}(A||(A={})),function(e){e[e.CFM_GENERAL=1]="CFM_GENERAL"}(m||(m={})),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"}(S||(S={})),function(e){e[e.CICM_GENERAL=1]="CICM_GENERAL",e[e.CICM_SKIP=0]="CICM_SKIP",e[e.CICM_REV=2147483648]="CICM_REV"}(D||(D={})),function(e){e[e.CM_IGNORE=1]="CM_IGNORE",e[e.CM_OVERWRITE=2]="CM_OVERWRITE"}(T||(T={})),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"}(v||(v={})),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"}(p||(p={})),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"}(M||(M={})),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"}(C||(C={})),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"}(b||(b={})),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"}(N||(N={})),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.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"}(V||(V={})),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"}(G||(G={})),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"}(x||(x={}));class W{static get version(){return c.version}static get productKeys(){return c.productKeys}static set productKeys(e){c.productKeys=e}static get handshakeCode(){return c.handshakeCode}static set handshakeCode(e){c.handshakeCode=e}static get organizationID(){return c.organizationID}static set organizationID(e){c.organizationID=e}static get sessionPassword(){return c.sessionPassword}static set sessionPassword(e){c.sessionPassword=e}static get browserInfo(){return c.browserInfo}static detectEnvironment(){return c.detectEnvironment()}static get _workerName(){return c._workerName}static set _workerName(e){c._workerName=e}static get engineResourcePath(){return c.engineResourcePath}static set engineResourcePath(e){c.engineResourcePath=e}static get licenseServer(){return c.licenseServer}static set licenseServer(e){c.licenseServer=e}static get deviceFriendlyName(){return c.deviceFriendlyName}static set deviceFriendlyName(e){c.deviceFriendlyName=e}static get _onLog(){return c._onLog}static set _onLog(e){c._onLog=e}static get _bWasmDebug(){return c._bWasmDebug}static set _bWasmDebug(e){c._bWasmDebug=e}static get _bUseFullFeature(){return c._bUseFullFeature}static set _bUseFullFeature(e){c._bUseFullFeature=e}static get _dbrWorker(){return c._dbrWorker}static isLoaded(){return c.isLoaded()}static loadWasm(){return c.loadWasm()}}W.BarcodeReader=c,W.BarcodeScanner=g,W.EnumBarcodeColourMode=E,W.EnumBarcodeComplementMode=R,W.EnumBarcodeFormat=s,W.EnumBarcodeFormat_2=I,W.EnumBinarizationMode=f,W.EnumClarityCalculationMethod=A,W.EnumClarityFilterMode=m,W.EnumColourClusteringMode=S,W.EnumColourConversionMode=D,W.EnumConflictMode=T,W.EnumDeblurMode=v,W.EnumDeformationResistingMode=p,W.EnumDPMCodeReadingMode=M,W.EnumErrorCode=n,W.EnumGrayscaleTransformationMode=C,W.EnumImagePixelFormat=r,W.EnumImagePreprocessingMode=y,W.EnumIMResultDataType=o,W.EnumIntermediateResultSavingMode=L,W.EnumIntermediateResultType=O,W.EnumLocalizationMode=b,W.EnumPDFReadingMode=N,W.EnumQRCodeErrorCorrectionLevel=B,W.EnumRegionPredetectionMode=P,W.EnumResultCoordinateType=F,W.EnumResultType=w,W.EnumScaleUpMode=U,W.EnumTerminatePhase=k,W.EnumTextFilterMode=V,W.EnumTextResultOrderMode=G,W.EnumTextureDetectionMode=x;t.default=W}])}));if(typeof dbr!="undefined"){if(dbr.DBR)dbr=dbr.DBR;if(typeof Dynamsoft=="undefined"){Dynamsoft={};}if(typeof Dynamsoft.DBR=="undefined"){Dynamsoft.DBR=dbr;}else{let _dbr = Dynamsoft.DBR;Dynamsoft.DBR=dbr;for(let key in _dbr){Dynamsoft.DBR[key]=Dynamsoft.DBR[key]||_dbr[key];}}}