/*!
 * Dynamsoft JavaScript Library
 * @product Dynamsoft Barcode Reader JS Edition
 * @website http://www.dynamsoft.com
 * @copyright Copyright 2022, Dynamsoft Corporation
 * @author Dynamsoft
 * @version 9.4.0 (js 20220930)
 * @fileoverview Dynamsoft JavaScript Library for Barcode Reader
 * More info on DBR JS: https://www.dynamsoft.com/barcode-reader/sdk-javascript/
 */
!function(){"use strict";const e="undefined"==typeof self,t=e?{}:self,r=e=>e&&"object"==typeof e&&"function"==typeof e.then;class n extends Promise{constructor(e){let t,n;super(((e,r)=>{t=e,n=r})),this._s="pending",this.resolve=e=>{this.isPending&&(r(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",n(e))},this.task=e}get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(e){let t;this._task=e,r(e)?t=e:"function"==typeof e&&(t=new Promise(e)),t&&(async()=>{try{const r=await t;e===this._task&&this.resolve(r)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}}let o,i,s,a,c;if("undefined"!=typeof navigator&&(o=navigator,i=o.userAgent,s=o.platform,a=o.mediaDevices),!e){const e={init:function(){this.browser=this.searchString(this.dataBrowser)||"unknownBrowser",this.version=this.searchVersion(i)||this.searchVersion(o.appVersion)||0,this.OS=this.searchString(this.dataOS)||"unknownOS","Linux"==this.OS&&-1!=i.indexOf("Windows NT")&&(this.OS="HarmonyOS")},searchString:function(e){for(let t=0;t<e.length;t++){let r=e[t].string,n=e[t].prop;if(this.versionSearchString=e[t].versionSearch||e[t].identity,r){if(-1!=r.indexOf(e[t].subString))return e[t].identity}else if(n)return e[t].identity}},searchVersion:function(e){let t=e.indexOf(this.versionSearchString);if(-1!=t)return parseFloat(e.substring(t+this.versionSearchString.length+1))},dataBrowser:[{string:i,subString:"Edge",identity:"Edge"},{string:i,subString:"OPR",identity:"OPR"},{string:i,subString:"Chrome",identity:"Chrome"},{string:o.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{string:i,subString:"Firefox",identity:"Firefox"},{string:i,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"}],dataOS:[{string:i,subString:"HarmonyOS",identity:"HarmonyOS"},{string:i,subString:"Android",identity:"Android"},{string:i,subString:"iPhone",identity:"iPhone"},{string:s,subString:"Win",identity:"Windows"},{string:s,subString:"Mac",identity:"Mac"},{string:s,subString:"Linux",identity:"Linux"}]};e.init(),c={browser:e.browser,version:e.version,OS:e.OS}}e&&(c={browser:"ssr",version:0,OS:"ssr"}),"undefined"!=typeof WebAssembly&&i&&(!/Safari/.test(i)||/Chrome/.test(i)||/\(.+\s11_2_([2-6]).*\)/.test(i)),a&&a.getUserMedia;const d="Chrome"===c.browser&&c.version>66||"Safari"===c.browser&&c.version>13||"OPR"===c.browser&&c.version>43||"Edge"===c.browser&&c.version>15;var u=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}();function l(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var r=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),n=0;n<e.length;n+=1)r.append(e[n]);return r.getBlob(t.type)}}function f(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function h(e,t,r){"function"==typeof t&&e.then(t),"function"==typeof r&&e.catch(r)}function m(e){return"string"!=typeof e&&(console.warn(`${e} used as a key, but it is not a string.`),e=String(e)),e}function g(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}const y="local-forage-detect-blob-support";let p;const b={},v=Object.prototype.toString,w="readonly",S="readwrite";function _(e){return"boolean"==typeof p?Promise.resolve(p):function(e){return new Promise((function(t){var r=e.transaction(y,S),n=l([""]);r.objectStore(y).put(n,"key"),r.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},r.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),r=navigator.userAgent.match(/Edge\//);t(r||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}(e).then((function(e){return p=e,p}))}function k(e){var t=b[e.name],r={};r.promise=new Promise((function(e,t){r.resolve=e,r.reject=t})),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then((function(){return r.promise})):t.dbReady=r.promise}function I(e){var t=b[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function M(e,t){var r=b[e.name].deferredOperations.pop();if(r)return r.reject(t),r.promise}function x(e,t){return new Promise((function(r,n){if(b[e.name]=b[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return r(e.db);k(e),e.db.close()}var o=[e.name];t&&o.push(e.version);var i=u.open.apply(u,o);t&&(i.onupgradeneeded=function(t){var r=i.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(y)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),i.onerror=function(e){e.preventDefault(),n(i.error)},i.onsuccess=function(){var t=i.result;t.onversionchange=function(e){e.target.close()},r(t),I(e)}}))}function D(e){return x(e,!1)}function C(e){return x(e,!0)}function P(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.version<e.db.version,o=e.version>e.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||r){if(r){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function N(e){var t=function(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),o=0;o<t;o++)n[o]=e.charCodeAt(o);return r}(atob(e.data));return l([t],{type:e.type})}function R(e){var t=this,r=t._initReady().then((function(){var e=b[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return h(r,e,e),r}function O(e,t,r,n){void 0===n&&(n=1);try{var o=e.db.transaction(e.storeName,t);r(null,o)}catch(o){if(n>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return Promise.resolve().then((()=>{if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),C(e)})).then((()=>function(e){k(e);for(var t=b[e.name],r=t.forages,n=0;n<r.length;n++){const e=r[n];e._dbInfo.db&&(e._dbInfo.db.close(),e._dbInfo.db=null)}return e.db=null,D(e).then((t=>(e.db=t,P(e)?C(e):t))).then((n=>{e.db=t.db=n;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=n})).catch((t=>{throw M(e,t),t}))}(e).then((function(){O(e,t,r,n-1)})))).catch(r);r(o)}}var B={_driver:"asyncStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]=e[n];var o=b[r.name];o||(o={forages:[],db:null,dbReady:null,deferredOperations:[]},b[r.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=R);var i=[];function s(){return Promise.resolve()}for(var a=0;a<o.forages.length;a++){var c=o.forages[a];c!==t&&i.push(c._initReady().catch(s))}var d=o.forages.slice(0);return Promise.all(i).then((function(){return r.db=o.db,D(r)})).then((function(e){return r.db=e,P(r,t._defaultConfig.version)?C(r):e})).then((function(e){r.db=o.db=e,t._dbInfo=r;for(var n=0;n<d.length;n++){var i=d[n];i!==t&&(i._dbInfo.db=r.db,i._dbInfo.version=r.version)}}))},_support:function(){try{if(!u||!u.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}(),getItem:function(e,t){var r=this;e=m(e);var n=new Promise((function(t,n){r.ready().then((function(){O(r._dbInfo,w,(function(o,i){if(o)return n(o);try{var s=i.objectStore(r._dbInfo.storeName).get(e);s.onsuccess=function(){var e=s.result;void 0===e&&(e=null),function(e){return e&&e.__local_forage_encoded_blob}(e)&&(e=N(e)),t(e)},s.onerror=function(){n(s.error)}}catch(e){n(e)}}))})).catch(n)}));return f(n,t),n},setItem:function(e,t,r){var n=this;e=m(e);var o=new Promise((function(r,o){var i;n.ready().then((function(){return i=n._dbInfo,"[object Blob]"===v.call(t)?_(i.db).then((function(e){return e?t:(r=t,new Promise((function(e,t){var n=new FileReader;n.onerror=t,n.onloadend=function(t){var n=btoa(t.target.result||"");e({__local_forage_encoded_blob:!0,data:n,type:r.type})},n.readAsBinaryString(r)})));var r})):t})).then((function(t){O(n._dbInfo,S,(function(i,s){if(i)return o(i);try{var a=s.objectStore(n._dbInfo.storeName);null===t&&(t=void 0);var c=a.put(t,e);s.oncomplete=function(){void 0===t&&(t=null),r(t)},s.onabort=s.onerror=function(){var e=c.error?c.error:c.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return f(o,r),o},removeItem:function(e,t){var r=this;e=m(e);var n=new Promise((function(t,n){r.ready().then((function(){O(r._dbInfo,S,(function(o,i){if(o)return n(o);try{var s=i.objectStore(r._dbInfo.storeName).delete(e);i.oncomplete=function(){t()},i.onerror=function(){n(s.error)},i.onabort=function(){var e=s.error?s.error:s.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return f(n,t),n},clear:function(e){var t=this,r=new Promise((function(e,r){t.ready().then((function(){O(t._dbInfo,S,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).clear();o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=i.error?i.error:i.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return f(r,e),r},length:function(e){var t=this,r=new Promise((function(e,r){t.ready().then((function(){O(t._dbInfo,w,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).count();i.onsuccess=function(){e(i.result)},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return f(r,e),r},keys:function(e){var t=this,r=new Promise((function(e,r){t.ready().then((function(){O(t._dbInfo,w,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).openKeyCursor(),s=[];i.onsuccess=function(){var t=i.result;t?(s.push(t.key),t.continue()):e(s)},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return f(r,e),r},dropInstance:function(e,t){t=g.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var n,o=this;if(e.name){const t=e.name===r.name&&o._dbInfo.db?Promise.resolve(o._dbInfo.db):D(e).then((t=>{const r=b[e.name],n=r.forages;r.db=t;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=t;return t}));n=e.storeName?t.then((t=>{if(!t.objectStoreNames.contains(e.storeName))return;const r=t.version+1;k(e);const n=b[e.name],o=n.forages;t.close();for(let e=0;e<o.length;e++){const t=o[e];t._dbInfo.db=null,t._dbInfo.version=r}const i=new Promise(((t,n)=>{const o=u.open(e.name,r);o.onerror=e=>{o.result.close(),n(e)},o.onupgradeneeded=()=>{o.result.deleteObjectStore(e.storeName)},o.onsuccess=()=>{const e=o.result;e.close(),t(e)}}));return i.then((e=>{n.db=e;for(let t=0;t<o.length;t++){const r=o[t];r._dbInfo.db=e,I(r._dbInfo)}})).catch((t=>{throw(M(e,t)||Promise.resolve()).catch((()=>{})),t}))})):t.then((t=>{k(e);const r=b[e.name],n=r.forages;t.close();for(var o=0;o<n.length;o++){n[o]._dbInfo.db=null}const i=new Promise(((t,r)=>{var n=u.deleteDatabase(e.name);n.onerror=()=>{const e=n.result;e&&e.close(),r(n.error)},n.onblocked=()=>{console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},n.onsuccess=()=>{const e=n.result;e&&e.close(),t(e)}}));return i.then((e=>{r.db=e;for(var t=0;t<n.length;t++){I(n[t]._dbInfo)}})).catch((t=>{throw(M(e,t)||Promise.resolve()).catch((()=>{})),t}))}))}else n=Promise.reject("Invalid arguments");return f(n,t),n}};const E=new Map;function T(e,t){let r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}var F={_driver:"tempStorageWrapper",_initStorage:async function(e){const t={};if(e)for(let r in e)t[r]=e[r];const r=t.keyPrefix=T(e,this._defaultConfig);this._dbInfo=t,E.has(r)||E.set(r,new Map)},getItem:function(e,t){e=m(e);const r=this.ready().then((()=>E.get(this._dbInfo.keyPrefix).get(e)));return f(r,t),r},setItem:function(e,t,r){e=m(e);const n=this.ready().then((()=>(void 0===t&&(t=null),E.get(this._dbInfo.keyPrefix).set(e,t),t)));return f(n,r),n},removeItem:function(e,t){e=m(e);const r=this.ready().then((()=>{E.get(this._dbInfo.keyPrefix).delete(e)}));return f(r,t),r},clear:function(e){const t=this.ready().then((()=>{const e=this._dbInfo.keyPrefix;E.has(e)&&E.delete(e)}));return f(t,e),t},length:function(e){const t=this.ready().then((()=>E.get(this._dbInfo.keyPrefix).size));return f(t,e),t},keys:function(e){const t=this.ready().then((()=>[...E.get(this._dbInfo.keyPrefix).keys()]));return f(t,e),t},dropInstance:function(e,t){if(t=g.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){const t=this.config();e.name=e.name||t.name,e.storeName=e.storeName||t.storeName}let r;return r=e.name?new Promise((t=>{e.storeName?t(T(e,this._defaultConfig)):t(`${e.name}/`)})).then((e=>{E.delete(e)})):Promise.reject("Invalid arguments"),f(r,t),r}};const A=(e,t)=>{const r=e.length;let n=0;for(;n<r;){if((o=e[n])===(i=t)||"number"==typeof o&&"number"==typeof i&&isNaN(o)&&isNaN(i))return!0;n++}var o,i;return!1},j=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},U={},J={},W={INDEXEDDB:B,TEMPSTORAGE:F},z=[W.INDEXEDDB._driver,W.TEMPSTORAGE._driver],H=["dropInstance"],L=["clear","getItem","keys","length","removeItem","setItem"].concat(H),V={description:"",driver:z.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function $(e,t){e[t]=function(){const r=arguments;return e.ready().then((function(){return e[t].apply(e,r)}))}}function Z(){for(let e=1;e<arguments.length;e++){const t=arguments[e];if(t)for(let e in t)t.hasOwnProperty(e)&&(j(t[e])?arguments[0][e]=t[e].slice():arguments[0][e]=t[e])}return arguments[0]}class K{constructor(e){for(let e in W)if(W.hasOwnProperty(e)){const t=W[e],r=t._driver;this[e]=r,U[r]||this.defineDriver(t)}this._defaultConfig=Z({},V),this._config=Z({},this._defaultConfig,e),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((()=>{}))}config(e){if("object"==typeof e){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(let t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config}defineDriver(e,t,r){const n=new Promise((function(t,r){try{const n=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void r(o);const i=L.concat("_initStorage");for(let t=0,n=i.length;t<n;t++){const n=i[t];if((!A(H,n)||e[n])&&"function"!=typeof e[n])return void r(o)}const s=function(){const t=function(e){return function(){const t=new Error(`Method ${e} is not implemented by the current driver`),r=Promise.reject(t);return f(r,arguments[arguments.length-1]),r}};for(let r=0,n=H.length;r<n;r++){const n=H[r];e[n]||(e[n]=t(n))}};s();const a=function(r){U[n]&&console.info(`Redefining LocalForage driver: ${n}`),U[n]=e,J[n]=r,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(a,r):a(!!e._support):a(!0)}catch(e){r(e)}}));return h(n,t,r),n}driver(){return this._driver||null}getDriver(e,t,r){const n=U[e]?Promise.resolve(U[e]):Promise.reject(new Error("Driver not found."));return h(n,t,r),n}ready(e){const t=this,r=t._driverSet.then((()=>(null===t._ready&&(t._ready=t._initDriver()),t._ready)));return h(r,e,e),r}setDriver(e,t,r){const n=this;j(e)||(e=[e]);const o=this._getSupportedDrivers(e);function i(){n._config.driver=n.driver()}function s(e){return n._extend(e),i(),n._ready=n._initStorage(n._config),n._ready}const a=null!==this._driverSet?this._driverSet.catch((()=>Promise.resolve())):Promise.resolve();return this._driverSet=a.then((()=>{const e=o[0];return n._dbInfo=null,n._ready=null,n.getDriver(e).then((e=>{n._driver=e._driver,i(),n._wrapLibraryMethodsWithReady(),n._initDriver=function(e){return function(){let t=0;return function r(){for(;t<e.length;){let o=e[t];return t++,n._dbInfo=null,n._ready=null,n.getDriver(o).then(s).catch(r)}i();const o=new Error("No available storage method found.");return n._driverSet=Promise.reject(o),n._driverSet}()}}(o)}))})).catch((()=>{i();const e=new Error("No available storage method found.");return n._driverSet=Promise.reject(e),n._driverSet})),h(this._driverSet,t,r),this._driverSet}supports(e){return!!J[e]}_extend(e){Z(this,e)}_getSupportedDrivers(e){const t=[];for(let r=0,n=e.length;r<n;r++){const n=e[r];this.supports(n)&&t.push(n)}return t}_wrapLibraryMethodsWithReady(){for(let e=0,t=L.length;e<t;e++)$(this,L[e])}createInstance(e){return new K(e)}}var G=new K;Date.prototype.kUtilFormat=function(e){const t={"M+":this.getUTCMonth()+1,"d+":this.getUTCDate(),"H+":this.getUTCHours(),"h+":this.getUTCHours()%12||12,"m+":this.getUTCMinutes(),"s+":this.getUTCSeconds(),"q+":Math.floor((this.getUTCMonth()+3)/3),"S+":this.getUTCMilliseconds()};/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(this.getUTCFullYear()+"").substr(4-RegExp.$1.length)));for(let r in t)new RegExp("("+r+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?t[r]:("000"+t[r]).substr(("000"+t[r]).length-RegExp.$1.length)));return e};let X,Y,q,Q,ee,te,re,ne=e=>{let r,o,i,s,a,c,u,l,f,h,m=t.btoa,g=t.atob,y=e.bd;const p=["https://mlts.dynamsoft.com/","https://slts.dynamsoft.com/"];let b,v,w,S,_,k,I,M,x,D,C,P,N,R,O,B,E,T,F=p,A=!1,j=Promise.resolve(),U=e.log&&((...t)=>{try{e.log.apply(null,t)}catch(e){setTimeout((()=>{throw e}),0)}})||(()=>{}),J=y&&U||(()=>{}),W=e=>e.join(""),z={a:[80,88,27,82,145,164,199,211],b:[187,87,89,128,150,44,190,213],c:[89,51,74,53,99,72,82,118],d:[99,181,118,158,215,103,76,117],e:[99,51,86,105,100,71,120,108],f:[97,87,49,119,98,51,74,48,83,50,86,53],g:[81,85,86,84,76,85,100,68,84,81,32,32],h:[90,87,53,106,99,110,108,119,100,65,32,32],i:[90,71,86,106,99,110,108,119,100,65,32,32],j:[97,88,89,32],k:[29,83,122,137,5,180,157,114],l:[100,71,70,110,84,71,86,117,90,51,82,111]},H=()=>t[W(z.c)][W(z.e)][W(z.f)]("raw",new Uint8Array(z.a.concat(z.b,z.d,z.k)),W(z.g),!0,[W(z.h),W(z.i)]),L=async e=>{if(t[W(z.c)]&&t[W(z.c)][W(z.e)]&&t[W(z.c)][W(z.e)][W(z.f)]){let r=g(e),n=new Uint8Array(r.length);for(let e=0;e<r.length;++e)n[e]=r.charCodeAt(e);let o=n.subarray(0,12),i=n.subarray(o.length);R||(R=await H());let s=await t[W(z.c)][W(z.e)][W(z.i)]({name:W(z.g),[W(z.j)]:o,[W(z.l)]:128},R,i);return String.fromCharCode.apply(null,new Uint8Array(s))}},V=async e=>{if(t[W(z.c)]&&t[W(z.c)][W(z.e)]&&t[W(z.c)][W(z.e)][W(z.f)]){let r=new Uint8Array(e.length);for(let t=0;t<e.length;++t)r[t]=e.charCodeAt(t);let n=t.crypto.getRandomValues(new Uint8Array(12));R||(R=await H());let o=await t[W(z.c)][W(z.e)][W(z.h)]({name:W(z.g),[W(z.j)]:n,[W(z.l)]:128},R,r),i=new Uint8Array(o),s=new Uint8Array(n.length+i.length);return s.set(n),s.set(i,n.length),m(String.fromCharCode.apply(null,s))}},$=e=>g(g(e.replace(/\n/g,"+").replace(/\s/g,"=")).substring(1)),Z=e=>m(String.fromCharCode(97+25*Math.random())+m(e)).replace(/\+/g,"\n").replace(/=/g," "),K=()=>{if(O)return O;if(t.crypto){let e=new Uint8Array(36);t.crypto.getRandomValues(e);let r="";for(let t=0;t<36;++t){let n=e[t]%36;r+=n<10?n:String.fromCharCode(n+87)}return r}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},X="Failed to connect to the Dynamsoft License Server. The cached license has expired. Please get connected to the network as soon as possible or contact the site administrator for more information.",Y="Failed to connect to the Dynamsoft License Server: network timed out. Check your Internet connection or [contact Dynamsoft](https://www.dynamsoft.com/company/contact/) for more information.",q="Failed to connect to the Dynamsoft License Server: network timed out. Check your Internet connection or contact the site administrator for more information.",Q="Failed to connect to the Dynamsoft License Server: network connection error. Check your Internet connection or [contact Dynamsoft](https://www.dynamsoft.com/company/contact/) for more information.",ee="Failed to connect to the Dynamsoft License Server: network connection error. Check your Internet connection or contact the site administrator for more information.",te="Your system date and time appear to have been changed, causing the license to fail. Please correct the system data and time and try again.",re=async()=>{await(async()=>{k||(k=G)})(),W=e=>g(String.fromCharCode.apply(null,e).replace(/\n/g,"+").replace(/\s/g,"="));{let e=await k.createInstance({name:r+"jshello"});await e.setItem(r+"jshello","available")}if(M=await k.createInstance({name:"dynamltsinfo"}),x=O?null:m(m("v2")+String.fromCharCode(u.charCodeAt(u.length/2)+1)+m(u)),D=m(String.fromCharCode(s.charCodeAt(0)+10)+m(r)+m(s)+i+m(""+c)),!O){try{let e=await M.getItem(x);e&&([l,S]=JSON.parse(await $(e)))}catch(e){}try{null==l&&(l=K())}catch(e){}}I=await k.createInstance({name:"dynamdlsuns"+m(m("v2"))+m(String.fromCharCode(s.charCodeAt(0)+10)+m(r)+m(s)+i+m(""+c))});try{a=await M.getItem(D)}catch(e){}},ne=async e=>{B||(B=(async()=>{try{let t={pd:r,vm:i,v:o,dt:c||"browser",ed:"javascript",cu:l,ad:u,os:f,fn:h};w&&(t.rmk=w),s&&(t=-1!=s.indexOf("-")?{...t,hs:s}:{...t,og:s});let n={};if(S&&!O){let e=await M.getItem(x);e&&([l,S]=JSON.parse(await $(e))),n["lts-time"]=S}v&&(t.sp=v);let d=await Promise.race([(async()=>{let r,o=(new Date).kUtilFormat("yyyy-MM-ddTHH:mm:ss.SSSZ");S&&!O&&(M.setItem(x,await Z(JSON.stringify([l,o]))),S=o);let i,s="auth/?ext="+encodeURIComponent(m(JSON.stringify(t))),c=!1,d=!1,u=async e=>{if(e&&!e.ok)try{let t=await e.text();if(t){let e=JSON.parse(t);e.errorCode&&(i=e,e.errorCode>100&&e.errorCode<200&&(a=null,c=!0,d=!0))}}catch(e){}};try{r=await Promise.race([fetch(F[0]+s,{headers:n,cache:e?"reload":"default",mode:"cors"}),new Promise(((e,t)=>setTimeout(t,1e4)))]),await u(r)}catch(e){}if(!(a||r&&r.ok||c))try{r=await Promise.race([fetch(F[1]+s,{headers:n,mode:"cors"}),new Promise(((e,t)=>setTimeout(t,3e4)))]),await u(r)}catch(e){}if(!(a||r&&r.ok||c))try{r=await Promise.race([fetch(F[0]+s,{headers:n,mode:"cors"}),new Promise(((e,t)=>setTimeout(t,3e4)))]),await u(r)}catch(e){}i&&151==i.errorCode&&(O||M.removeItem(x),M.removeItem(D),l=K(),t.cu=l,S=void 0,s="auth/?ext="+encodeURIComponent(m(JSON.stringify(t))),r=await Promise.race([fetch(F[0]+s,{headers:n,mode:"cors"}),new Promise(((e,t)=>setTimeout(t,3e4)))]),await u(r));(()=>{if(!r||!r.ok){let e;d&&M.setItem(D,""),i?111==i.errorCode?e=i.message:(e=i.message.trim(),e.endsWith(".")||(e+="."),e=b?`An error occurred during authorization: ${e} [Contact Dynamsoft](https://www.dynamsoft.com/company/contact/) for more information.`:`An error occurred during authorization: ${e} Contact the site administrator for more information.`):e=b?Q:ee;let t=Error(e);throw i&&i.errorCode&&(t.ltsErrorCode=i.errorCode),t}})();let f=await r.text();try{S||O||(M.setItem(x,await Z(JSON.stringify([l,o]))),S=o),M.setItem(D,f)}catch(e){}return f})(),new Promise(((e,t)=>{let r;r=b?Y:q,setTimeout((()=>t(new Error(r))),a?3e3:15e3)}))]);a=d}catch(e){y&&console.error(e),_=e}B=null})()),await B,E||(E=Date.now()+6e4)},oe=async()=>{T||(T=(async()=>{if(J(l),!a){if(!A)throw U(_.message),_;return}let e={dm:u};y&&(e.bd=!0),e.brtk=!0,e.ls=F[0],s&&(-1!=s.indexOf("-")?e.hs=s:e.og=s),e.cu=l,h&&(e.fn=h),r&&(e.pd=r),o&&(e.v=o),c&&(e.dt=c),f&&(e.os=f),w&&(e.rmk=w),J(a);try{let t=JSON.parse(await L(a));t.ba&&(e.ba=t.ba),t.usu&&(e.usu=t.usu),t.trial&&(e.trial=t.trial),t.its&&(e.its=t.its),1==e.trial&&t.msg?e.msg=t.msg:_?e.msg=_.message||_:t.msg&&(e.msg=t.msg),e.ar=t.in,e.bafc=!!_}catch(e){}J(e);try{await C(e)}catch(e){}await ie(),A||(A=!0),T=null})()),await T},ie=async()=>{let e=(new Date).kUtilFormat("yyyy-MM-ddTHH:mm:ss.SSSZ"),t=await N();if(J(t),t&&t<e)throw _?new Error(X):new Error(te)};const se=new n;let ae=null,ce=async(e,t)=>(j=j.then((async()=>{try{let r=await I.keys();if(t||(se.isFulfilled?e&&(r=r.filter((t=>t<e))):e&&r.includes(e)?r=[e]:(r=[],J("Unexpected null key"))),!r.length)return;for(let e=0;e<r.length/1e3;++e){let t=r.slice(1e3*e,1e3*(e+1)),n=[];for(let e=0;e<t.length;++e)n.push(await I.getItem(t[e]));if(S=(new Date).kUtilFormat("yyyy-MM-ddTHH:mm:ss.SSSZ"),!O){let e=await M.getItem(x);e&&([l]=JSON.parse(await $(e))),M.setItem(x,await Z(JSON.stringify([l,S])))}try{let e=F[0]+"verify/v2";S&&!O&&(e+="?ltstime="+encodeURIComponent(S)),!se.isFulfilled&&d&&se.resolve();let r=await fetch(e,{method:"POST",body:n.join(";"),keepalive:!0});if(se.isFulfilled||se.resolve(),!r.ok)throw new Error("verify failed. Status Code: "+r.status);for(let e=0;e<t.length;++e)await I.removeItem(t[e])}catch(e){throw se.isFulfilled||se.resolve(),e}}}catch(e){}})),await j);return{i:async e=>{r=e.pd,o=e.v,i=o.split(".")[0],e.dt&&(c=e.dt),u=e.dm,s=e.l||"",f="string"!=typeof e.os?JSON.stringify(e.os):e.os,h=e.fn,"string"==typeof h&&(h=h.substring(0,50)),e.ls&&e.ls.length&&(F=e.ls,1==F.length&&F.push(F[0])),b=p===F&&(!s||"200001"===s||s.startsWith("200001-")),v=e.sp,w=e.rmk,e.lf&&(k=e.lf),e.lsu&&(l=O=e.lsu),e.fdaa&&(L=e.fdaa),e.feab&&(V=e.feab),C=e.updl,P=e.mnet,N=e.mxet,await re(),await ne(),await oe(),(!_||_.ltsErrorCode>=102&&_.ltsErrorCode<=120)&&ce(null,!0)},c:async()=>{let e=new Date,t=e.kUtilFormat("yyyy-MM-ddTHH:mm:ss.SSSZ"),r=await P(),n=await N();if(n&&n<t)await ne(!0),await oe();else if(r&&r<t){e.setMinutes(e.getMinutes()-6);let t=e;e=null;let r=t.kUtilFormat("yyyy-MM-ddTHH:mm:ss.SSSZ");S<r&&ne().then((()=>oe()))}},s:async(e,t,r,n)=>{try{let e;e=t.startsWith("{")&&t.endsWith("}")?await V(t):t,e?await I.setItem(r,e):J("ept ecpt")}catch(e){}n&&await ce(r),ae&&clearTimeout(ae),ae=setTimeout((async()=>{await ce()}),36e4)},p:se,r:async()=>{se.isPending&&E&&E<Date.now()&&(E=Date.now()+6e4,await fetch(F[1]+"lts/test"))}}},oe=t,ie=!1,se="BarcodeReaderWasm",ae=0,ce=0;let de=new n,ue=!1,le=async e=>{await de,ee=e.trial,te=e.msg,Module[se].init(JSON.stringify(e))},fe=()=>{let e=Module[se].getMinExpireTime;return e?e():null},he=()=>{let e=Module[se].getMaxExpireTime;return e?e():null},me=new Map,ge=0,ye=async function(e){const r=e.data?e.data:e,n=r.id,o=r.instanceID,i=r.body;switch(!Q||"decodeBuffer"!=r.type&&"decodeFileInMemory"!=r.type||await re.c(),r.type){case"loadWasm":try{X=r.bd,Y=r.engineResourcePath,ie=r.bUseFullFeature,q=r.v;let e=r.dm,n=r.l;Q=r.brtk;let o,i=r.bptk;(async()=>{if(ue)throw"can't load wasm twice";ue=!0,pe("wasm loading...");let e=Date.now();await new Promise((async e=>{t.KModule=t.Module={locateFile:function(e){return"libDynamsoftBarcodeReader.wasm"==e?Y+"dbr-"+q+(ie?".full":"")+".wasm":Y+e},print:e=>{pe(e)},printErr:e=>{console.error(e),pe(e)},onRuntimeInitialized:e},importScripts(Y+"dbr-"+q+(ie?".full":"")+".wasm.js")})),pe("wasm initialized, cost "+(Date.now()-e)+" ms"),Module=KModule,de.resolve()})();let s=async()=>{try{re=ne({log:pe,bd:X}),t.scsd=re.s,r.pd="dbr",r.updl=le,r.mnet=fe,r.mxet=he,await re.i(r)}catch(e){if(!i)throw e;Q=!1,await a(),o=e.ltsErrorCode,te=e.message||e}},a=async()=>{let t={pk:n,dm:e};X&&(t.bd=!0),await le(t)};Q?await s():await a(),oe.postMessage({type:"load",success:!0,version:Module[se].getVersion(),trial:ee,ltsErrorCode:o,message:te})}catch(e){let t=e&&e.message;oe.postMessage({type:"load",success:!1,ltsErrorCode:e&&e.ltsErrorCode,message:t,trial:ee,stack:X&&e?e.stack:null})}break;case"createInstance":{const e=ge++;try{let t=new Module[se](r.bScanner,e);me.set(e,t);let n=JSON.parse(t.getRuntimeSettings());r.bScanner?(n.localizationModes=[2,0,0,0,0,0,0,0],n.deblurLevel=0):(n.expectedBarcodesCount=512,n.scaleDownThreshold=1e5,n.timeout=1e5),ie||(n.barcodeFormatIds=238028799),t.updateRuntimeSettings(JSON.stringify(n))}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0,instanceID:e}});break}case"destroyContext":try{if(!me.get(o))break;me.get(o).delete(),me.delete(o)}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0}});break;case"decodeBuffer":{let e,t,r,s,a=Date.now();try{e=X?Date.now():0,c=i.buffer,(d=i.stride*i.height)>ae&&(ce&&Module._free(ce),ce=Module._malloc(d),ae=d),Module.HEAPU8.set(c.subarray(0,d),ce),t=X?Date.now():0,s=JSON.parse(me.get(o).decodeBufferPtr(ce,i.width,i.height,i.stride,i.format,!(!i.config||!i.config.bScanner))),r=Date.now()}catch(e){ve(e,n);break}re&&re.p.isPending&&await Promise.race([re.p,new Promise((e=>setTimeout(e,500)))]),oe.postMessage({type:"task",id:n,body:{success:!0,decodeReturn:s,buffer:i.buffer,duration:Date.now()-a}},[i.buffer.buffer]),be(["timeWorkerGetMsg: "+a,"timeBeforeSendBufferToWasm: "+e+" "+(e-a),"timeBeforeDecode: "+t+" "+(t-e),"timeFinishDecode: "+r+" "+(r-t)].join("\n"));break}case"decodeFileInMemory":{let e,t,r;try{t=X?Date.now():0,e=JSON.parse(me.get(o).decodeFileInMemory(i.bytes)),r=X?Date.now():0}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0,decodeReturn:e,duration:r-t}});break}case"clearMapDecodeRecord":try{me.get(o).clearMapDecodeRecord()}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0}});break;case"getRuntimeSettings":{let e;try{e=me.get(o).getRuntimeSettings()}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0,results:e}});break}case"updateRuntimeSettings":{let e;try{e=JSON.parse(me.get(o).updateRuntimeSettings(i.settings))}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0,updateReturn:e}});break}case"resetRuntimeSettings":try{let e=me.get(o);e.resetRuntimeSettings();let t=JSON.parse(e.getRuntimeSettings());e.bScanner?(t.expectedBarcodesCount=1,t.deblurLevel=0,t.localizationModes=[16,2,0,0,0,0,0,0],t.barcodeZoneMinDistanceToImageBorders=0):(t.expectedBarcodesCount=512,t.scaleDownThreshold=1e5,t.timeout=1e5),ie||(t.barcodeFormatIds=238028799),e.updateRuntimeSettings(JSON.stringify(t)),e.bScanner&&(e.setModeArgument("BinarizationModes",0,"EnableFillBinaryVacancy","0"),e.setModeArgument("LocalizationModes",0,"ScanDirection","2"),e.setModeArgument("BinarizationModes",0,"BlockSizeX","71"),e.setModeArgument("BinarizationModes",0,"BlockSizeY","71"))}catch(t){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0}});break;case"outputRuntimeSettingsToString":{let e;try{e=me.get(o).outputSettingsToString()}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0,results:e}});break}case"initRuntimeSettingsWithString":{let e;try{e=JSON.parse(me.get(o).initRuntimeSettingsWithString(i.settings))}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0,initReturn:e}});break}case"getIntermediateResults":{let e=[];try{var s=me.get(o).getIntermediateResults(),a=JSON.parse(s,((t,r)=>{if("bytes"===t&&"ptr"in r&&"length"in r){var n=r,o=n.ptr,i=n.length;let t=Module[se].getBytes(o,i);return t=t.slice(0),e.push(t.buffer),t}return r}))}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0,results:a}},e),me.get(o).freeIntermediateResults();break}case"setModeArgument":{let e;try{e=JSON.parse(me.get(o).setModeArgument(i.modeName,i.index,i.argumentName,i.argumentValue))}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0,setReturn:e}});break}case"getModeArgument":{let e;try{e=JSON.parse(me.get(o).getModeArgument(i.modeName,i.index,i.argumentName))}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0,getReturn:e}});break}case"updateScanSettings":try{let e=me.get(o),t=i.settings;e.duplicateForgetTime=t.duplicateForgetTime,e.oneDRememberFrameCount=t.oneDRememberFrameCount,e.oneDTrustFrameCount=t.oneDTrustFrameCount}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0}});break;case"getScanSettings":{let e={};try{let t=me.get(o);e.duplicateForgetTime=t.duplicateForgetTime,e.oneDRememberFrameCount=t.oneDRememberFrameCount,e.oneDTrustFrameCount=t.oneDTrustFrameCount}catch(e){ve(e,n);break}oe.postMessage({type:"task",id:n,body:{success:!0,results:e}});break}case"keepAlive":re&&await re.r();break;default:console.warn("Unmatched task: ",e)}var c,d};oe.onmessage=ye;let pe=e=>{oe.postMessage({type:"log",message:e})},be=e=>{X&&pe(e)},ve=(e,t)=>{oe.postMessage({type:"task",id:t,body:{success:!1,message:e.message,stack:e.stack}}),setTimeout((()=>{throw e}),0)}}();
