dynamsoft-barcode-reader-bundle 11.4.2001 → 11.4.3000

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,8 @@
4
4
  * @website http://www.dynamsoft.com
5
5
  * @copyright Copyright 2026, Dynamsoft Corporation
6
6
  * @author Dynamsoft
7
- * @version 11.4.2001
7
+ * @version 11.4.3000
8
8
  * @fileoverview Dynamsoft JavaScript Library for Barcode Reader
9
9
  * More info on dbr JS: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/
10
10
  */
11
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Dynamsoft=t.Dynamsoft||{})}(this,function(e){"use strict";function t(e,t,i,s){return new(i||(i=Promise))(function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,a)}c((s=s.apply(e,t||[])).next())})}function i(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}function s(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i}var n,r;"function"==typeof SuppressedError&&SuppressedError,e.EnumScanMode=void 0,(n=e.EnumScanMode||(e.EnumScanMode={}))[n.SM_SINGLE=0]="SM_SINGLE",n[n.SM_MULTI_UNIQUE=1]="SM_MULTI_UNIQUE",e.EnumResultStatus=void 0,(r=e.EnumResultStatus||(e.EnumResultStatus={}))[r.RS_SUCCESS=0]="RS_SUCCESS",r[r.RS_CANCELLED=1]="RS_CANCELLED",r[r.RS_FAILED=2]="RS_FAILED";const o=e=>e&&"object"==typeof e&&"function"==typeof e.then,a=(async()=>{})().constructor;let c=class extends a{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,o(e)?t=e:"function"==typeof e&&(t=new a(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(o(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};function l(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}function d(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i}var u,h,_;"function"==typeof SuppressedError&&SuppressedError,function(e){e[e.BOPM_BLOCK=0]="BOPM_BLOCK",e[e.BOPM_UPDATE=1]="BOPM_UPDATE"}(u||(u={})),function(e){e[e.CCUT_AUTO=0]="CCUT_AUTO",e[e.CCUT_FULL_CHANNEL=1]="CCUT_FULL_CHANNEL",e[e.CCUT_Y_CHANNEL_ONLY=2]="CCUT_Y_CHANNEL_ONLY",e[e.CCUT_RGB_R_CHANNEL_ONLY=3]="CCUT_RGB_R_CHANNEL_ONLY",e[e.CCUT_RGB_G_CHANNEL_ONLY=4]="CCUT_RGB_G_CHANNEL_ONLY",e[e.CCUT_RGB_B_CHANNEL_ONLY=5]="CCUT_RGB_B_CHANNEL_ONLY"}(h||(h={})),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",e[e.IPF_BINARY_8=13]="IPF_BINARY_8",e[e.IPF_NV12=14]="IPF_NV12",e[e.IPF_BINARY_8_INVERTED=15]="IPF_BINARY_8_INVERTED"}(_||(_={}));const m="undefined"==typeof self,g="function"==typeof importScripts,f=(()=>{if(!g){if(!m&&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"./"}})(),p=e=>{if(null==e&&(e="./"),m||g);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},E=e=>Object.prototype.toString.call(e),y=e=>Array.isArray?Array.isArray(e):"[object Array]"===E(e),I=e=>"number"==typeof e&&!Number.isNaN(e),v=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),R=e=>!(!v(e)||!I(e.width)||e.width<=0||!I(e.height)||e.height<=0||!I(e.stride)||e.stride<=0||!("format"in e)||"tag"in e&&!T(e.tag)),C=e=>!!R(e)&&e.bytes instanceof Uint8Array,T=e=>null===e||!!v(e)&&!!I(e.imageId)&&"type"in e,w=e=>!!v(e)&&!!I(e.x)&&!!I(e.y),S=async(e,t,i)=>await new Promise((s,n)=>{let r=new XMLHttpRequest;r.responseType=t,r.onloadstart=()=>{i&&i.loadstartCallback&&i.loadstartCallback()},r.onloadend=async e=>{i&&i.loadendCallback&&i.loadendCallback(),r.status<200||r.status>=300?n(r.status):s(r.response)},r.onprogress=e=>{i&&i.progressCallback&&i.progressCallback(e)},r.onerror=e=>{n(e)},r.open("GET",e,!0),r.send()}),A=e=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(e),D=(e,t)=>{let i=e.split("."),s=t.split(".");for(let e=0;e<i.length&&e<s.length;++e){let t=i[e],n=s[e];if(t===n)continue;let r=parseInt(i[e]),o=parseInt(s[e]);return r===o||Number.isNaN(r)&&Number.isNaN(o)?t<n?-1:1:r<o||Number.isNaN(r)&&Number.isInteger(o)?-1:1}return i.length===s.length?0:i.length<s.length?-1:1},b=e=>{const t={};for(let i in e){if("rootDirectory"===i)continue;let s=i,n=e[s],r=n&&"object"==typeof n&&n.path?n.path:n,o=e.rootDirectory;if(o&&!o.endsWith("/")&&(o+="/"),"object"==typeof n&&n.isInternal)o&&(r=e[s].version?`${o}${P[s]}@${e[s].version}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`:`${o}${P[s]}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`);else{const i=/^@engineRootDirectory(\/?)/;if("string"==typeof r&&(r=r.replace(i,o||"")),"object"==typeof r&&"dwt"===s){const n=e[s].resourcesPath,r=e[s].serviceInstallerLocation;t[s]={resourcesPath:n.replace(i,o||""),serviceInstallerLocation:r.replace(i,o||"")};continue}}t[s]=p(r)}return t},L=async(e,t,i)=>await new Promise(async(s,n)=>{try{const n=t.split(".");let r=n[n.length-1];const o=await M(`image/${r}`,e);n.length<=1&&(r="png");const a=new File([o],t,{type:`image/${r}`});if(i){const e=URL.createObjectURL(a),i=document.createElement("a");i.href=e,i.download=t,i.click()}s(a)}catch(e){n()}}),O=e=>{C(e)&&(e=F(e));const t=document.createElement("canvas");return t.width=e.width,t.height=e.height,t.getContext("2d",{willReadFrequently:!0}).putImageData(e,0,0),t},N=(e,t)=>{C(t)&&(t=F(t));const i=O(t);let s=new Image,n=i.toDataURL(e);return s.src=n,s},M=async(e,t)=>{C(t)&&(t=F(t));const i=O(t);if("image/bmp"===e){const e=i.getContext("2d"),t=B(e.getImageData(0,0,i.width,i.height));return new Blob([t],{type:"image/bmp"})}return new Promise((t,s)=>{i.toBlob(e=>t(e),e)})},B=e=>{const t=e.width,i=e.height,s=e.data,n=4*Math.floor((24*t+31)/32),r=n*i,o=54+r,a=new ArrayBuffer(o),c=new DataView(a);c.setUint16(0,19778,!0),c.setUint32(2,o,!0),c.setUint16(6,0,!0),c.setUint16(8,0,!0),c.setUint32(10,54,!0),c.setUint32(14,40,!0),c.setInt32(18,t,!0),c.setInt32(22,-i,!0),c.setUint16(26,1,!0),c.setUint16(28,24,!0),c.setUint32(30,0,!0),c.setUint32(34,r,!0),c.setInt32(38,2835,!0),c.setInt32(42,2835,!0),c.setUint32(46,0,!0),c.setUint32(50,0,!0);let l=54;const d=n-3*t;for(let e=0;e<i;e++){for(let i=0;i<t;i++){const n=4*(e*t+i),r=s[n],o=s[n+1],a=s[n+2];c.setUint8(l++,a),c.setUint8(l++,o),c.setUint8(l++,r)}for(let e=0;e<d;e++)c.setUint8(l++,0)}return a},F=e=>{let t,i=e.bytes;if(!(i&&i instanceof Uint8Array))throw Error("Parameter type error");if(Number(e.format)===_.IPF_BGR_888){const e=i.length/3;t=new Uint8ClampedArray(4*e);for(let s=0;s<e;++s)t[4*s]=i[3*s],t[4*s+1]=i[3*s+1],t[4*s+2]=i[3*s+2],t[4*s+3]=255}else if(Number(e.format)===_.IPF_RGB_888){const e=i.length/3;t=new Uint8ClampedArray(4*e);for(let s=0;s<e;++s)t[4*s]=i[3*s+2],t[4*s+1]=i[3*s+1],t[4*s+2]=i[3*s],t[4*s+3]=255}else if(Number(e.format)===_.IPF_GRAYSCALED){const e=i.length;t=new Uint8ClampedArray(4*e);for(let s=0;s<e;s++)t[4*s]=t[4*s+1]=t[4*s+2]=i[s],t[4*s+3]=255}else if(Number(e.format)===_.IPF_BINARY_8||Number(e.format)===_.IPF_BINARY_8_INVERTED){const s=i.length,n=e.width,r=e.height,o=e.stride;t=new Uint8ClampedArray(n*r*4);for(let e=0;e<s;e++){let s=i[e],r=e%o,a=Math.floor(e/o);for(let e=0;e<8;e++){let i=r+e,o=4*(a*n+i);if(i>=n)break;t[o]=t[o+1]=t[o+2]=(128&s)/128*255,t[o+3]=255,s<<=1}}}else if(Number(e.format)===_.IPF_ABGR_8888){const e=i.length/4;t=new Uint8ClampedArray(i.length);for(let s=0;s<e;++s)t[4*s]=i[4*s],t[4*s+1]=i[4*s+1],t[4*s+2]=i[4*s+2],t[4*s+3]=i[4*s+3]}else if(Number(e.format)===_.IPF_ARGB_8888){const e=i.length/4;t=new Uint8ClampedArray(i.length);for(let s=0;s<e;++s)t[4*s]=i[4*s+2],t[4*s+1]=i[4*s+1],t[4*s+2]=i[4*s],t[4*s+3]=i[4*s+3]}else Number(e.format),_.IPF_BINARY_8_INVERTED;return new ImageData(t,e.width,e.height)},x=async e=>{let t=URL.createObjectURL(e);try{const e=await new Promise((e,i)=>{const s=new Image;s.onload=()=>e(s),s.onerror=i,s.src=t}),i=document.createElement("canvas"),s=i.getContext("2d");i.width=e.width,i.height=e.height,s.drawImage(e,0,0);return{bytes:Uint8Array.from(s.getImageData(0,0,i.width,i.height).data),width:i.width,height:i.height,stride:4*i.width,format:_.IPF_ABGR_8888}}finally{URL.revokeObjectURL(t)}},P={std:"dynamsoft-capture-vision-std",dip:"dynamsoft-image-processing",core:"dynamsoft-core",dnn:"dynamsoft-capture-vision-dnn",license:"dynamsoft-license",utility:"dynamsoft-utility",cvr:"dynamsoft-capture-vision-router",dbr:"dynamsoft-barcode-reader",dlr:"dynamsoft-label-recognizer",ddn:"dynamsoft-document-normalizer",dcp:"dynamsoft-code-parser",dcvData:"dynamsoft-capture-vision-data",dce:"dynamsoft-camera-enhancer",identityutility:"dynamsoft-identity-utility",ddv:"dynamsoft-document-viewer",dwt:"dwt",dbrBundle:"dynamsoft-barcode-reader-bundle",dcvBundle:"dynamsoft-capture-vision-bundle"};var k,U,V,G,W,j,Z,H;let q,Y,$,z,K,X=class e{get _isFetchingStarted(){return l(this,W,"f")}constructor(){k.add(this),U.set(this,[]),V.set(this,1),G.set(this,u.BOPM_BLOCK),W.set(this,!1),j.set(this,void 0),Z.set(this,h.CCUT_AUTO)}setErrorListener(e){}addImageToBuffer(e){var t;if(!C(e))throw new TypeError("Invalid 'image'.");if((null===(t=e.imageTag)||void 0===t?void 0:t.hasOwnProperty("imageId"))&&"number"==typeof e.imageTag.imageId&&this.hasImage(e.imageTag.imageId))throw new Error("Existed imageId.");if(l(this,U,"f").length>=l(this,V,"f"))switch(l(this,G,"f")){case u.BOPM_BLOCK:break;case u.BOPM_UPDATE:if(l(this,U,"f").push(e),v(l(this,j,"f"))&&I(l(this,j,"f").imageId)&&1==l(this,j,"f").keepInBuffer)for(;l(this,U,"f").length>l(this,V,"f");){const e=l(this,U,"f").findIndex(e=>{var t;return(null===(t=e.imageTag)||void 0===t?void 0:t.imageId)!==l(this,j,"f").imageId});l(this,U,"f").splice(e,1)}else l(this,U,"f").splice(0,l(this,U,"f").length-l(this,V,"f"))}else l(this,U,"f").push(e)}getImage(){if(0===l(this,U,"f").length)return null;let t;if(l(this,j,"f")&&I(l(this,j,"f").imageId)){const e=l(this,k,"m",H).call(this,l(this,j,"f").imageId);if(e<0)throw new Error(`Image with id ${l(this,j,"f").imageId} doesn't exist.`);t=l(this,U,"f").slice(e,e+1)[0]}else t=l(this,U,"f").pop();if([_.IPF_RGB_565,_.IPF_RGB_555,_.IPF_RGB_888,_.IPF_ARGB_8888,_.IPF_RGB_161616,_.IPF_ARGB_16161616,_.IPF_ABGR_8888,_.IPF_ABGR_16161616,_.IPF_BGR_888].includes(t.format)){if(l(this,Z,"f")===h.CCUT_RGB_R_CHANNEL_ONLY){e._onLog&&e._onLog("only get R channel data.");const i=new Uint8Array(t.width*t.height);for(let e=0;e<i.length;e++)switch(t.format){case _.IPF_RGB_565:case _.IPF_RGB_555:case _.IPF_RGB_888:case _.IPF_RGB_161616:i[e]=t.bytes[3*e+2];break;case _.IPF_ARGB_8888:case _.IPF_ARGB_16161616:i[e]=t.bytes[4*e+2];break;case _.IPF_BGR_888:i[e]=t.bytes[3*e];break;case _.IPF_ABGR_8888:case _.IPF_ABGR_16161616:i[e]=t.bytes[4*e]}t.bytes=i,t.stride=t.width,t.format=_.IPF_GRAYSCALED}else if(l(this,Z,"f")===h.CCUT_RGB_G_CHANNEL_ONLY){e._onLog&&e._onLog("only get G channel data.");const i=new Uint8Array(t.width*t.height);for(let e=0;e<i.length;e++)switch(t.format){case _.IPF_RGB_565:case _.IPF_RGB_555:case _.IPF_RGB_888:case _.IPF_RGB_161616:case _.IPF_BGR_888:i[e]=t.bytes[3*e+1];break;case _.IPF_ARGB_8888:case _.IPF_ARGB_16161616:case _.IPF_ABGR_8888:case _.IPF_ABGR_16161616:i[e]=t.bytes[4*e+1]}t.bytes=i,t.stride=t.width,t.format=_.IPF_GRAYSCALED}else if(l(this,Z,"f")===h.CCUT_RGB_B_CHANNEL_ONLY){e._onLog&&e._onLog("only get B channel data.");const i=new Uint8Array(t.width*t.height);for(let e=0;e<i.length;e++)switch(t.format){case _.IPF_RGB_565:case _.IPF_RGB_555:case _.IPF_RGB_888:case _.IPF_RGB_161616:i[e]=t.bytes[3*e];break;case _.IPF_ARGB_8888:case _.IPF_ARGB_16161616:i[e]=t.bytes[4*e];break;case _.IPF_BGR_888:i[e]=t.bytes[3*e+2];break;case _.IPF_ABGR_8888:case _.IPF_ABGR_16161616:i[e]=t.bytes[4*e+2]}t.bytes=i,t.stride=t.width,t.format=_.IPF_GRAYSCALED}}else[_.IPF_NV21,_.IPF_NV12].includes(t.format)&&e._onLog&&e._onLog("NV21 or NV12 is not supported.");return t}setNextImageToReturn(e,t){if(!((...e)=>0!==e.length&&e.every(e=>I(e)))(e))throw new TypeError("Invalid 'imageId'.");if(void 0!==t&&"[object Boolean]"!==E(t))throw new TypeError("Invalid 'keepInBuffer'.");d(this,j,{imageId:e,keepInBuffer:t},"f")}_resetNextReturnedImage(){d(this,j,null,"f")}hasImage(e){return l(this,k,"m",H).call(this,e)>=0}startFetching(){d(this,W,!0,"f")}stopFetching(){d(this,W,!1,"f")}setMaxImageCount(e){if("number"!=typeof e)throw new TypeError("Invalid 'count'.");if(e<1||Math.round(e)!==e)throw new Error("Invalid 'count'.");for(d(this,V,e,"f");l(this,U,"f")&&l(this,U,"f").length>e;)l(this,U,"f").shift()}getMaxImageCount(){return l(this,V,"f")}getImageCount(){return l(this,U,"f").length}clearBuffer(){l(this,U,"f").length=0}isBufferEmpty(){return 0===l(this,U,"f").length}setBufferOverflowProtectionMode(e){d(this,G,e,"f")}getBufferOverflowProtectionMode(){return l(this,G,"f")}setColourChannelUsageType(e){d(this,Z,e,"f")}getColourChannelUsageType(){return l(this,Z,"f")}};U=new WeakMap,V=new WeakMap,G=new WeakMap,W=new WeakMap,j=new WeakMap,Z=new WeakMap,k=new WeakSet,H=function(e){if("number"!=typeof e)throw new TypeError("Invalid 'imageId'.");return l(this,U,"f").findIndex(t=>{var i;return(null===(i=t.imageTag)||void 0===i?void 0:i.imageId)===e})},"undefined"!=typeof navigator&&(q=navigator,Y=q.userAgent,$=q.platform,z=q.mediaDevices),function(){if(!m){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:q.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},t={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:$,search:"Win"},Mac:{str:$},Linux:{str:$}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let r=n.str||Y,o=n.search||t,a=n.verStr||Y,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=r.indexOf(o)){i=t;for(let e of c){let t=a.indexOf(e);if(-1!=t){s=parseFloat(a.substring(t+e.length+1));break}}break}}for(let e in t){const i=t[e]||{};let s=i.str||Y,r=i.search||e;if(-1!=s.indexOf(r)){n=e;break}}"Linux"==n&&-1!=Y.indexOf("Windows NT")&&(n="HarmonyOS"),K={browser:i,version:s,OS:n}}m&&(K={browser:"ssr",version:0,OS:"ssr"})}();const Q="undefined"!=typeof WebAssembly&&Y&&!(/Safari/.test(Y)&&!/Chrome/.test(Y)&&/\(.+\s11_2_([2-6]).*\)/.test(Y)),J=!("undefined"==typeof Worker),ee=!(!z||!z.getUserMedia),te=async()=>{let e=!1;if(ee)try{(await z.getUserMedia({video:!0})).getTracks().forEach(e=>{e.stop()}),e=!0}catch(e){}return e};var ie,se,ne,re,oe,ae,ce,le,de;"Chrome"===K.browser&&K.version>66||"Safari"===K.browser&&K.version>13||"OPR"===K.browser&&K.version>43||"Edge"===K.browser&&K.version,function(e){e[e.CRIT_ORIGINAL_IMAGE=1]="CRIT_ORIGINAL_IMAGE",e[e.CRIT_BARCODE=2]="CRIT_BARCODE",e[e.CRIT_TEXT_LINE=4]="CRIT_TEXT_LINE",e[e.CRIT_DETECTED_QUAD=8]="CRIT_DETECTED_QUAD",e[e.CRIT_DESKEWED_IMAGE=16]="CRIT_DESKEWED_IMAGE",e[e.CRIT_PARSED_RESULT=32]="CRIT_PARSED_RESULT",e[e.CRIT_ENHANCED_IMAGE=64]="CRIT_ENHANCED_IMAGE"}(ie||(ie={})),function(e){e[e.CT_NORMAL_INTERSECTED=0]="CT_NORMAL_INTERSECTED",e[e.CT_T_INTERSECTED=1]="CT_T_INTERSECTED",e[e.CT_CROSS_INTERSECTED=2]="CT_CROSS_INTERSECTED",e[e.CT_NOT_INTERSECTED=3]="CT_NOT_INTERSECTED"}(se||(se={})),function(e){e[e.EC_OK=0]="EC_OK",e[e.EC_UNKNOWN=-1e4]="EC_UNKNOWN",e[e.EC_NO_MEMORY=-10001]="EC_NO_MEMORY",e[e.EC_NULL_POINTER=-10002]="EC_NULL_POINTER",e[e.EC_LICENSE_INVALID=-10003]="EC_LICENSE_INVALID",e[e.EC_LICENSE_EXPIRED=-10004]="EC_LICENSE_EXPIRED",e[e.EC_FILE_NOT_FOUND=-10005]="EC_FILE_NOT_FOUND",e[e.EC_FILE_TYPE_NOT_SUPPORTED=-10006]="EC_FILE_TYPE_NOT_SUPPORTED",e[e.EC_BPP_NOT_SUPPORTED=-10007]="EC_BPP_NOT_SUPPORTED",e[e.EC_INDEX_INVALID=-10008]="EC_INDEX_INVALID",e[e.EC_CUSTOM_REGION_INVALID=-10010]="EC_CUSTOM_REGION_INVALID",e[e.EC_IMAGE_READ_FAILED=-10012]="EC_IMAGE_READ_FAILED",e[e.EC_TIFF_READ_FAILED=-10013]="EC_TIFF_READ_FAILED",e[e.EC_DIB_BUFFER_INVALID=-10018]="EC_DIB_BUFFER_INVALID",e[e.EC_PDF_READ_FAILED=-10021]="EC_PDF_READ_FAILED",e[e.EC_PDF_DLL_MISSING=-10022]="EC_PDF_DLL_MISSING",e[e.EC_PAGE_NUMBER_INVALID=-10023]="EC_PAGE_NUMBER_INVALID",e[e.EC_CUSTOM_SIZE_INVALID=-10024]="EC_CUSTOM_SIZE_INVALID",e[e.EC_TIMEOUT=-10026]="EC_TIMEOUT",e[e.EC_JSON_PARSE_FAILED=-10030]="EC_JSON_PARSE_FAILED",e[e.EC_JSON_TYPE_INVALID=-10031]="EC_JSON_TYPE_INVALID",e[e.EC_JSON_KEY_INVALID=-10032]="EC_JSON_KEY_INVALID",e[e.EC_JSON_VALUE_INVALID=-10033]="EC_JSON_VALUE_INVALID",e[e.EC_JSON_NAME_KEY_MISSING=-10034]="EC_JSON_NAME_KEY_MISSING",e[e.EC_JSON_NAME_VALUE_DUPLICATED=-10035]="EC_JSON_NAME_VALUE_DUPLICATED",e[e.EC_TEMPLATE_NAME_INVALID=-10036]="EC_TEMPLATE_NAME_INVALID",e[e.EC_JSON_NAME_REFERENCE_INVALID=-10037]="EC_JSON_NAME_REFERENCE_INVALID",e[e.EC_PARAMETER_VALUE_INVALID=-10038]="EC_PARAMETER_VALUE_INVALID",e[e.EC_DOMAIN_NOT_MATCH=-10039]="EC_DOMAIN_NOT_MATCH",e[e.EC_LICENSE_KEY_NOT_MATCH=-10043]="EC_LICENSE_KEY_NOT_MATCH",e[e.EC_SET_MODE_ARGUMENT_ERROR=-10051]="EC_SET_MODE_ARGUMENT_ERROR",e[e.EC_GET_MODE_ARGUMENT_ERROR=-10055]="EC_GET_MODE_ARGUMENT_ERROR",e[e.EC_IRT_LICENSE_INVALID=-10056]="EC_IRT_LICENSE_INVALID",e[e.EC_FILE_SAVE_FAILED=-10058]="EC_FILE_SAVE_FAILED",e[e.EC_STAGE_TYPE_INVALID=-10059]="EC_STAGE_TYPE_INVALID",e[e.EC_IMAGE_ORIENTATION_INVALID=-10060]="EC_IMAGE_ORIENTATION_INVALID",e[e.EC_CONVERT_COMPLEX_TEMPLATE_ERROR=-10061]="EC_CONVERT_COMPLEX_TEMPLATE_ERROR",e[e.EC_CALL_REJECTED_WHEN_CAPTURING=-10062]="EC_CALL_REJECTED_WHEN_CAPTURING",e[e.EC_NO_IMAGE_SOURCE=-10063]="EC_NO_IMAGE_SOURCE",e[e.EC_READ_DIRECTORY_FAILED=-10064]="EC_READ_DIRECTORY_FAILED",e[e.EC_MODULE_NOT_FOUND=-10065]="EC_MODULE_NOT_FOUND",e[e.EC_MULTI_PAGES_NOT_SUPPORTED=-10066]="EC_MULTI_PAGES_NOT_SUPPORTED",e[e.EC_FILE_ALREADY_EXISTS=-10067]="EC_FILE_ALREADY_EXISTS",e[e.EC_CREATE_FILE_FAILED=-10068]="EC_CREATE_FILE_FAILED",e[e.EC_IMAGE_DATA_INVALID=-10069]="EC_IMAGE_DATA_INVALID",e[e.EC_IMAGE_SIZE_NOT_MATCH=-10070]="EC_IMAGE_SIZE_NOT_MATCH",e[e.EC_IMAGE_PIXEL_FORMAT_NOT_MATCH=-10071]="EC_IMAGE_PIXEL_FORMAT_NOT_MATCH",e[e.EC_SECTION_LEVEL_RESULT_IRREPLACEABLE=-10072]="EC_SECTION_LEVEL_RESULT_IRREPLACEABLE",e[e.EC_AXIS_DEFINITION_INCORRECT=-10073]="EC_AXIS_DEFINITION_INCORRECT",e[e.EC_RESULT_TYPE_MISMATCH_IRREPLACEABLE=-10074]="EC_RESULT_TYPE_MISMATCH_IRREPLACEABLE",e[e.EC_PDF_LIBRARY_LOAD_FAILED=-10075]="EC_PDF_LIBRARY_LOAD_FAILED",e[e.EC_UNSUPPORTED_JSON_KEY_WARNING=-10077]="EC_UNSUPPORTED_JSON_KEY_WARNING",e[e.EC_MODEL_FILE_NOT_FOUND=-10078]="EC_MODEL_FILE_NOT_FOUND",e[e.EC_PDF_LICENSE_NOT_FOUND=-10079]="EC_PDF_LICENSE_NOT_FOUND",e[e.EC_RECT_INVALID=-10080]="EC_RECT_INVALID",e[e.EC_TEMPLATE_VERSION_INCOMPATIBLE=-10081]="EC_TEMPLATE_VERSION_INCOMPATIBLE",e[e.EC_PORTRAIT_ZONE_NOT_FOUND=-10082]="EC_PORTRAIT_ZONE_NOT_FOUND",e[e.EC_NO_LICENSE=-2e4]="EC_NO_LICENSE",e[e.EC_LICENSE_BUFFER_FAILED=-20002]="EC_LICENSE_BUFFER_FAILED",e[e.EC_LICENSE_SYNC_FAILED=-20003]="EC_LICENSE_SYNC_FAILED",e[e.EC_DEVICE_NOT_MATCH=-20004]="EC_DEVICE_NOT_MATCH",e[e.EC_BIND_DEVICE_FAILED=-20005]="EC_BIND_DEVICE_FAILED",e[e.EC_INSTANCE_COUNT_OVER_LIMIT=-20008]="EC_INSTANCE_COUNT_OVER_LIMIT",e[e.EC_TRIAL_LICENSE=-20010]="EC_TRIAL_LICENSE",e[e.EC_LICENSE_VERSION_NOT_MATCH=-20011]="EC_LICENSE_VERSION_NOT_MATCH",e[e.EC_LICENSE_CACHE_USED=-20012]="EC_LICENSE_CACHE_USED",e[e.EC_LICENSE_AUTH_QUOTA_EXCEEDED=-20013]="EC_LICENSE_AUTH_QUOTA_EXCEEDED",e[e.EC_LICENSE_RESULTS_LIMIT_EXCEEDED=-20014]="EC_LICENSE_RESULTS_LIMIT_EXCEEDED",e[e.EC_BARCODE_FORMAT_INVALID=-30009]="EC_BARCODE_FORMAT_INVALID",e[e.EC_CUSTOM_MODULESIZE_INVALID=-30025]="EC_CUSTOM_MODULESIZE_INVALID",e[e.EC_TEXT_LINE_GROUP_LAYOUT_CONFLICT=-40101]="EC_TEXT_LINE_GROUP_LAYOUT_CONFLICT",e[e.EC_TEXT_LINE_GROUP_REGEX_CONFLICT=-40102]="EC_TEXT_LINE_GROUP_REGEX_CONFLICT",e[e.EC_QUADRILATERAL_INVALID=-50057]="EC_QUADRILATERAL_INVALID",e[e.EC_PANORAMA_LICENSE_INVALID=-70060]="EC_PANORAMA_LICENSE_INVALID",e[e.EC_RESOURCE_PATH_NOT_EXIST=-90001]="EC_RESOURCE_PATH_NOT_EXIST",e[e.EC_RESOURCE_LOAD_FAILED=-90002]="EC_RESOURCE_LOAD_FAILED",e[e.EC_CODE_SPECIFICATION_NOT_FOUND=-90003]="EC_CODE_SPECIFICATION_NOT_FOUND",e[e.EC_FULL_CODE_EMPTY=-90004]="EC_FULL_CODE_EMPTY",e[e.EC_FULL_CODE_PREPROCESS_FAILED=-90005]="EC_FULL_CODE_PREPROCESS_FAILED",e[e.EC_LICENSE_WARNING=-10076]="EC_LICENSE_WARNING",e[e.EC_BARCODE_READER_LICENSE_NOT_FOUND=-30063]="EC_BARCODE_READER_LICENSE_NOT_FOUND",e[e.EC_LABEL_RECOGNIZER_LICENSE_NOT_FOUND=-40103]="EC_LABEL_RECOGNIZER_LICENSE_NOT_FOUND",e[e.EC_DOCUMENT_NORMALIZER_LICENSE_NOT_FOUND=-50058]="EC_DOCUMENT_NORMALIZER_LICENSE_NOT_FOUND",e[e.EC_CODE_PARSER_LICENSE_NOT_FOUND=-90012]="EC_CODE_PARSER_LICENSE_NOT_FOUND"}(ne||(ne={})),function(e){e[e.GEM_SKIP=0]="GEM_SKIP",e[e.GEM_AUTO=1]="GEM_AUTO",e[e.GEM_GENERAL=2]="GEM_GENERAL",e[e.GEM_GRAY_EQUALIZE=4]="GEM_GRAY_EQUALIZE",e[e.GEM_GRAY_SMOOTH=8]="GEM_GRAY_SMOOTH",e[e.GEM_SHARPEN_SMOOTH=16]="GEM_SHARPEN_SMOOTH",e[e.GEM_REV=-2147483648]="GEM_REV",e[e.GEM_END=-1]="GEM_END"}(re||(re={})),function(e){e[e.GTM_SKIP=0]="GTM_SKIP",e[e.GTM_INVERTED=1]="GTM_INVERTED",e[e.GTM_ORIGINAL=2]="GTM_ORIGINAL",e[e.GTM_AUTO=4]="GTM_AUTO",e[e.GTM_REV=-2147483648]="GTM_REV",e[e.GTM_END=-1]="GTM_END"}(oe||(oe={})),function(e){e[e.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",e[e.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(ae||(ae={})),function(e){e[e.PDFRM_VECTOR=1]="PDFRM_VECTOR",e[e.PDFRM_RASTER=2]="PDFRM_RASTER",e[e.PDFRM_REV=-2147483648]="PDFRM_REV"}(ce||(ce={})),function(e){e[e.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",e[e.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(le||(le={})),function(e){e[e.CVS_NOT_VERIFIED=0]="CVS_NOT_VERIFIED",e[e.CVS_PASSED=1]="CVS_PASSED",e[e.CVS_FAILED=2]="CVS_FAILED"}(de||(de={}));const ue={IRUT_NULL:BigInt(0),IRUT_COLOUR_IMAGE:BigInt(1),IRUT_SCALED_COLOUR_IMAGE:BigInt(2),IRUT_GRAYSCALE_IMAGE:BigInt(4),IRUT_TRANSOFORMED_GRAYSCALE_IMAGE:BigInt(8),IRUT_ENHANCED_GRAYSCALE_IMAGE:BigInt(16),IRUT_PREDETECTED_REGIONS:BigInt(32),IRUT_BINARY_IMAGE:BigInt(64),IRUT_TEXTURE_DETECTION_RESULT:BigInt(128),IRUT_TEXTURE_REMOVED_GRAYSCALE_IMAGE:BigInt(256),IRUT_TEXTURE_REMOVED_BINARY_IMAGE:BigInt(512),IRUT_CONTOURS:BigInt(1024),IRUT_LINE_SEGMENTS:BigInt(2048),IRUT_TEXT_ZONES:BigInt(4096),IRUT_TEXT_REMOVED_BINARY_IMAGE:BigInt(8192),IRUT_CANDIDATE_BARCODE_ZONES:BigInt(16384),IRUT_LOCALIZED_BARCODES:BigInt(32768),IRUT_SCALED_BARCODE_IMAGE:BigInt(65536),IRUT_DEFORMATION_RESISTED_BARCODE_IMAGE:BigInt(1<<17),IRUT_COMPLEMENTED_BARCODE_IMAGE:BigInt(1<<18),IRUT_DECODED_BARCODES:BigInt(1<<19),IRUT_LONG_LINES:BigInt(1<<20),IRUT_CORNERS:BigInt(1<<21),IRUT_CANDIDATE_QUAD_EDGES:BigInt(1<<22),IRUT_DETECTED_QUADS:BigInt(1<<23),IRUT_LOCALIZED_TEXT_LINES:BigInt(1<<24),IRUT_RECOGNIZED_TEXT_LINES:BigInt(1<<25),IRUT_DESKEWED_IMAGE:BigInt(1<<26),IRUT_SHORT_LINES:BigInt(1<<27),IRUT_RAW_TEXT_LINES:BigInt(1<<28),IRUT_LOGIC_LINES:BigInt(1<<29),IRUT_ENHANCED_IMAGE:BigInt(Math.pow(2,30)),IRUT_ALL:BigInt("0xFFFFFFFFFFFFFFFF")};var he,_e,me,ge,fe;!function(e){e[e.ROET_PREDETECTED_REGION=0]="ROET_PREDETECTED_REGION",e[e.ROET_LOCALIZED_BARCODE=1]="ROET_LOCALIZED_BARCODE",e[e.ROET_DECODED_BARCODE=2]="ROET_DECODED_BARCODE",e[e.ROET_LOCALIZED_TEXT_LINE=3]="ROET_LOCALIZED_TEXT_LINE",e[e.ROET_RECOGNIZED_TEXT_LINE=4]="ROET_RECOGNIZED_TEXT_LINE",e[e.ROET_DETECTED_QUAD=5]="ROET_DETECTED_QUAD",e[e.ROET_DESKEWED_IMAGE=6]="ROET_DESKEWED_IMAGE",e[e.ROET_SOURCE_IMAGE=7]="ROET_SOURCE_IMAGE",e[e.ROET_TARGET_ROI=8]="ROET_TARGET_ROI",e[e.ROET_ENHANCED_IMAGE=9]="ROET_ENHANCED_IMAGE",e[e.ROET_AUXILIARY_REGION=10]="ROET_AUXILIARY_REGION"}(he||(he={})),function(e){e[e.ST_NULL=0]="ST_NULL",e[e.ST_REGION_PREDETECTION=1]="ST_REGION_PREDETECTION",e[e.ST_BARCODE_LOCALIZATION=2]="ST_BARCODE_LOCALIZATION",e[e.ST_BARCODE_DECODING=3]="ST_BARCODE_DECODING",e[e.ST_TEXT_LINE_LOCALIZATION=4]="ST_TEXT_LINE_LOCALIZATION",e[e.ST_TEXT_LINE_RECOGNITION=5]="ST_TEXT_LINE_RECOGNITION",e[e.ST_DOCUMENT_DETECTION=6]="ST_DOCUMENT_DETECTION",e[e.ST_DOCUMENT_DESKEWING=7]="ST_DOCUMENT_DESKEWING",e[e.ST_IMAGE_ENHANCEMENT=8]="ST_IMAGE_ENHANCEMENT"}(_e||(_e={})),function(e){e[e.IFF_JPEG=0]="IFF_JPEG",e[e.IFF_PNG=1]="IFF_PNG",e[e.IFF_BMP=2]="IFF_BMP",e[e.IFF_PDF=3]="IFF_PDF"}(me||(me={})),function(e){e[e.ICDM_NEAR=0]="ICDM_NEAR",e[e.ICDM_FAR=1]="ICDM_FAR"}(ge||(ge={})),function(e){e.MN_DYNAMSOFT_CAPTURE_VISION_ROUTER="cvr",e.MN_DYNAMSOFT_CORE="core",e.MN_DYNAMSOFT_LICENSE="license",e.MN_DYNAMSOFT_IMAGE_PROCESSING="dip",e.MN_DYNAMSOFT_UTILITY="utility",e.MN_DYNAMSOFT_BARCODE_READER="dbr",e.MN_DYNAMSOFT_DOCUMENT_NORMALIZER="ddn",e.MN_DYNAMSOFT_LABEL_RECOGNIZER="dlr",e.MN_DYNAMSOFT_CAPTURE_VISION_DATA="dcvData",e.MN_DYNAMSOFT_NEURAL_NETWORK="dnn",e.MN_DYNAMSOFT_CODE_PARSER="dcp",e.MN_DYNAMSOFT_CAMERA_ENHANCER="dce",e.MN_DYNAMSOFT_CAPTURE_VISION_STD="std"}(fe||(fe={}));const pe={},Ee=async e=>{let t="string"==typeof e?[e]:e,i=[];for(let e of t)i.push(pe[e]=pe[e]||new c);await Promise.all(i)},ye=async(e,t)=>{let i,s="string"==typeof e?[e]:e,n=[];for(let e of s){let s;n.push(s=pe[e]=pe[e]||new c(i=i||t())),s.isEmpty&&(s.task=i=i||t())}await Promise.all(n)};let Ie,ve=0;const Re=()=>ve++,Ce={};let Te;const we=e=>{Te=e,Ie&&Ie.postMessage({type:"setBLog",body:{value:!!e}})};let Se=!1;const Ae=e=>{Se=e,Ie&&Ie.postMessage({type:"setBDebug",body:{value:!!e}})},De={},be={},Le={dip:{wasm:!0}},Oe={std:{version:"2.0.0",path:p(f+"../../dynamsoft-capture-vision-std@2.0.0/dist/"),isInternal:!0},core:{version:"4.4.20-dev-20260415104041",path:f,isInternal:!0}};let Ne=5;"undefined"!=typeof navigator&&(Ne=navigator.hardwareConcurrency?navigator.hardwareConcurrency-1:5),Ce[-3]=async e=>{Me.onWasmLoadProgressChanged&&Me.onWasmLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class Me{static get engineResourcePaths(){return Oe}static set engineResourcePaths(e){Object.assign(Oe,e)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _onLog(){return Te}static set _onLog(e){we(e)}static get _bDebug(){return Se}static set _bDebug(e){Ae(e)}static get _workerName(){return`${Me._bundleEnv.toLowerCase()}.bundle.worker.js`}static get wasmLoadOptions(){return Me._wasmLoadOptions}static set wasmLoadOptions(e){Object.assign(Me._wasmLoadOptions,e)}static isModuleLoaded(e){return e=(e=e||"core").toLowerCase(),!!pe[e]&&pe[e].isFulfilled}static async loadWasm(){return await(async()=>{let e,t;e instanceof Array||(e=e?[e]:[]);let i=pe.core;t=!i||i.isEmpty,t||await Ee("core");let s=new Map;const n=e=>{if(e=e.toLowerCase(),fe.MN_DYNAMSOFT_CAPTURE_VISION_STD==e||fe.MN_DYNAMSOFT_CORE==e)return;let t=Le[e].deps;if(null==t?void 0:t.length)for(let e of t)n(e);let i=pe[e];s.has(e)||s.set(e,!i||i.isEmpty)};for(let t of e)n(t);let r=[];t&&r.push("core"),r.push(...s.keys());const o=[...s.entries()].filter(e=>!e[1]).map(e=>e[0]);await ye(r,async()=>{const e=[...s.entries()].filter(e=>e[1]).map(e=>e[0]);await Ee(o);const i=b(Oe),n={};for(let t of e)n[t]=Le[t];const r={engineResourcePaths:i,autoResources:n,names:e,_bundleEnv:Me._bundleEnv,wasmLoadOptions:Me.wasmLoadOptions};let a=new c;if(t){r.needLoadCore=!0;let e=i[`${Me._bundleEnv.toLowerCase()}Bundle`]+Me._workerName;e.startsWith(location.origin)||(e=await fetch(e).then(e=>e.blob()).then(e=>URL.createObjectURL(e))),Ie=new Worker(e),Ie.onerror=e=>{let t=new Error(e.message);a.reject(t)},Ie.addEventListener("message",e=>{let t=e.data?e.data:e,i=t.type,s=t.id,n=t.body;switch(i){case"log":Te&&Te(t.message);break;case"warning":console.warn(t.message);break;case"task":try{Ce[s]&&(Ce[s](n),delete Ce[s])}catch(e){throw delete Ce[s],e}break;case"event":try{Ce[s](n)}catch(e){throw e}break;default:console.log(e)}}),r.bLog=!!Te,r.bd=Se,r.dm=location.origin.startsWith("http")?location.origin:"https://localhost"}else await Ee("core");let l=ve++;Ce[l]=e=>{if(e.success)Object.assign(De,e.versions),"{}"!==JSON.stringify(e.versions)&&(Me._versions=e.versions),Me.loadedWasmType=e.loadedWasmType,a.resolve(void 0);else{const t=Error(e.message);e.stack&&(t.stack=e.stack),a.reject(t)}},Ie.postMessage({type:"loadWasm",id:l,body:r}),await a})})()}static async detectEnvironment(){return await(async()=>({wasm:Q,worker:J,getUserMedia:ee,camera:await te(),browser:K.browser,version:K.version,OS:K.OS}))()}static async getModuleVersion(){return await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e(i.versions);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"getModuleVersion",id:i})})}static getVersion(){return`4.4.20-dev-20260415104041(Worker: ${De.core&&De.core.worker||"Not Loaded"}, Wasm: ${De.core&&De.core.wasm||"Not Loaded"})`}static enableLogging(){X._onLog=console.log,Me._onLog=console.log}static disableLogging(){X._onLog=null,Me._onLog=null}static async cfd(e){return await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},Ie.postMessage({type:"cfd",id:s,body:{count:e}})})}}Me._bSupportDce4Module=-1,Me._bSupportIRTModule=-1,Me._versions=null,Me._bundleEnv="DCV",Me._wasmLoadOptions={wasmType:"auto",pthreadPoolSize:Ne},Me.loadedWasmType="ml-simd-pthread",Me.browserInfo=K;var Be=Object.freeze({__proto__:null,CoreModule:Me,get EnumBufferOverflowProtectionMode(){return u},get EnumCapturedResultItemType(){return ie},get EnumColourChannelUsageType(){return h},get EnumCornerType(){return se},get EnumCrossVerificationStatus(){return de},get EnumErrorCode(){return ne},get EnumGrayscaleEnhancementMode(){return re},get EnumGrayscaleTransformationMode(){return oe},get EnumImageCaptureDistanceMode(){return ge},get EnumImageFileFormat(){return me},get EnumImagePixelFormat(){return _},get EnumImageTagType(){return ae},EnumIntermediateResultUnitType:ue,get EnumModuleName(){return fe},get EnumPDFReadingMode(){return ce},get EnumRasterDataSource(){return le},get EnumRegionObjectElementType(){return he},get EnumSectionType(){return _e},ImageSourceAdapter:X,_saveToFile:L,_toBlob:M,_toCanvas:O,_toImage:N,get bDebug(){return Se},blobToDsImage:x,checkIsLink:A,compareVersion:D,createImageData:F,d:async(e,t)=>{const i=atob(e),s=new Uint8Array(i.length);for(let e=0;e<i.length;e++)s[e]=i.charCodeAt(e);const n=s.slice(0,12),r=s.slice(12),o=new TextEncoder,a=await crypto.subtle.importKey("raw",o.encode(t),"PBKDF2",!1,["deriveKey"]),c=await crypto.subtle.deriveKey({name:"PBKDF2",salt:o.encode("salt-for-key-derivation"),iterations:1e5,hash:"SHA-256"},a,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"]),l=await crypto.subtle.decrypt({name:"AES-GCM",iv:n,tagLength:128},c,r);return(new TextDecoder).decode(l)},doOrWaitAsyncDependency:ye,e:async(e,t)=>{const i=new TextEncoder,s=await crypto.subtle.importKey("raw",i.encode(t),"PBKDF2",!1,["deriveKey"]),n=await crypto.subtle.deriveKey({name:"PBKDF2",salt:i.encode("salt-for-key-derivation"),iterations:1e5,hash:"SHA-256"},s,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"]),r=crypto.getRandomValues(new Uint8Array(12)),o=await crypto.subtle.encrypt({name:"AES-GCM",iv:r,tagLength:128},n,i.encode(e)),a=new Uint8Array(r.length+o.byteLength);return a.set(r),a.set(new Uint8Array(o),r.length),btoa(String.fromCharCode.apply(null,a))},encodeBMP:B,getNextTaskID:Re,handleEngineResourcePaths:b,imagePtrToUint8Array:async e=>await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(e.u8);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},Ie.postMessage({type:"imagePtrToUint8Array",id:s,body:{data:e}})}),innerVersions:De,isArc:e=>!(!v(e)||!I(e.x)||!I(e.y)||!I(e.radius)||e.radius<0||!I(e.startAngle)||!I(e.endAngle)),isContour:e=>!!v(e)&&!!y(e.points)&&0!=e.points.length&&!e.points.some(e=>!w(e)),isDSImageData:C,isDSRect:e=>!(!v(e)||!I(e.left)||e.left<0||!I(e.top)||e.top<0||!I(e.right)||e.right<0||!I(e.bottom)||e.bottom<0||e.left>=e.right||e.top>=e.bottom),isDsImageKeyValue:(e,t)=>"bytes"===e&&"object"==typeof t&&"number"==typeof t.ptr&&"number"==typeof t.length,isImageTag:T,isLineSegment:e=>!(!v(e)||!w(e.startPoint)||!w(e.endPoint)||e.startPoint.x==e.endPoint.x&&e.startPoint.y==e.endPoint.y),isObject:v,isOriginalDsImageData:e=>!(!R(e)||!I(e.bytes.length)&&!I(e.bytes.ptr)),isPoint:w,isPolygon:e=>!!v(e)&&!!y(e.points)&&0!=e.points.length&&!e.points.some(e=>!w(e)),isQuad:e=>!!v(e)&&!!y(e.points)&&0!=e.points.length&&4==e.points.length&&!e.points.some(e=>!w(e)),isRect:e=>!(!v(e)||!I(e.x)||!I(e.y)||!I(e.width)||e.width<0||!I(e.height)||e.height<0),isSimdSupported:()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),mapAsyncDependency:pe,mapPackageRegister:be,mapTaskCallBack:Ce,get onLog(){return Te},productNameMap:P,requestResource:S,resolveDsImageData:async e=>await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(e.result);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},Ie.postMessage({type:"resolveDsImageData",id:s,body:{point:e}})}),setBDebug:Ae,setOnLog:we,waitAsyncDependency:Ee,get worker(){return Ie},workerAutoResources:Le}),Fe={license:"",scanMode:e.EnumScanMode.SM_SINGLE,templateFilePath:void 0,utilizedTemplateNames:{single:"ReadBarcodes_SpeedFirst",multi_unique:"ReadBarcodes_SpeedFirst",image:"ReadBarcodes_ReadRateFirst"},engineResourcePaths:Me.engineResourcePaths,barcodeFormats:void 0,duplicateForgetTime:3e3,container:void 0,onUniqueBarcodeScanned:void 0,showResultView:void 0,showUploadImageButton:!1,showPoweredByDynamsoft:!0,autoStartCapturing:!0,uiPath:void 0,onInitPrepare:void 0,onInitReady:void 0,onCameraOpen:void 0,onCameraOpenFailed:void 0,onCaptureStart:void 0,scannerViewConfig:{container:void 0,showCloseButton:!0,mirrorFrontCamera:!0,cameraSwitchControl:"hidden",showFlashButton:!1},resultViewConfig:{container:void 0,toolbarButtonsConfig:{clear:{label:"Clear",className:"btn-clear",isHidden:!1},done:{label:"Done",className:"btn-done",isHidden:!1}}}};const xe=e=>e&&"object"==typeof e&&"function"==typeof e.then,Pe=(async()=>{})().constructor;class ke extends Pe{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,xe(e)?t=e:"function"==typeof e&&(t=new Pe(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(xe(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}function Ue(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}function Ve(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i}"function"==typeof SuppressedError&&SuppressedError;const Ge=e=>e&&"object"==typeof e&&"function"==typeof e.then,We=(async()=>{})().constructor;let je=class extends We{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,Ge(e)?t=e:"function"==typeof e&&(t=new We(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(Ge(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}},Ze=class{constructor(e){this._cvr=e}async getMaxBufferedItems(){return await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e(i.count);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"cvr_getMaxBufferedItems",id:i,instanceID:this._cvr._instanceID})})}async setMaxBufferedItems(e){return await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},Ie.postMessage({type:"cvr_setMaxBufferedItems",id:s,instanceID:this._cvr._instanceID,body:{count:e}})})}async getBufferedCharacterItemSet(){return await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e(i.itemSet);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"cvr_getBufferedCharacterItemSet",id:i,instanceID:this._cvr._instanceID})})}};var He={onTaskResultsReceived:!1,onTargetROIResultsReceived:!1,onTaskResultsReceivedForDce:!1,onPredetectedRegionsReceived:!1,onLocalizedBarcodesReceived:!1,onDecodedBarcodesReceived:!1,onLocalizedTextLinesReceived:!1,onRecognizedTextLinesReceived:!1,onDetectedQuadsReceived:!1,onDeskewedImageReceived:!1,onEnhancedImageReceived:!1,onColourImageUnitReceived:!1,onScaledColourImageUnitReceived:!1,onGrayscaleImageUnitReceived:!1,onTransformedGrayscaleImageUnitReceived:!1,onEnhancedGrayscaleImageUnitReceived:!1,onBinaryImageUnitReceived:!1,onTextureDetectionResultUnitReceived:!1,onTextureRemovedGrayscaleImageUnitReceived:!1,onTextureRemovedBinaryImageUnitReceived:!1,onContoursUnitReceived:!1,onLineSegmentsUnitReceived:!1,onTextZonesUnitReceived:!1,onTextRemovedBinaryImageUnitReceived:!1,onRawTextLinesUnitReceived:!1,onLongLinesUnitReceived:!1,onCornersUnitReceived:!1,onCandidateQuadEdgesUnitReceived:!1,onCandidateBarcodeZonesUnitReceived:!1,onScaledBarcodeImageUnitReceived:!1,onDeformationResistedBarcodeImageUnitReceived:!1,onComplementedBarcodeImageUnitReceived:!1,onShortLinesUnitReceived:!1,onLogicLinesUnitReceived:!1};const qe=e=>{for(let t in e._irrRegistryState)e._irrRegistryState[t]=!1;for(let t of e._intermediateResultReceiverSet)if(t.isDce||t.isFilter)e._irrRegistryState.onTaskResultsReceivedForDce=!0;else for(let i in t)e._irrRegistryState[i]||(e._irrRegistryState[i]=!!t[i])};let Ye=class{constructor(e){this._irrRegistryState=He,this._intermediateResultReceiverSet=new Set,this._cvr=e}async addResultReceiver(e){if("object"!=typeof e)throw new Error("Invalid receiver.");this._intermediateResultReceiverSet.add(e),qe(this);let t=-1,i={};if(!e.isDce&&!e.isFilter){if(!e._observedResultUnitTypes||!e._observedTaskMap)throw new Error("Invalid Intermediate Result Receiver.");t=e._observedResultUnitTypes,e._observedTaskMap.forEach((e,t)=>{i[t]=e}),e._observedTaskMap.clear()}return await new Promise((e,s)=>{let n=Re();Ce[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,s(e)}},Ie.postMessage({type:"cvr_setIrrRegistry",id:n,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState,observedResultUnitTypes:t.toString(),observedTaskMap:i}})})}async removeResultReceiver(e){return this._intermediateResultReceiverSet.delete(e),qe(this),await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})})}async removeAllResultReceivers(){for(const e of this._intermediateResultReceiverSet)e.hasOwnProperty("isFilter")||e.hasOwnProperty("isDce")||this._intermediateResultReceiverSet.delete(e);return qe(this),await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})})}getOriginalImage(){return this._cvr.provideDsImage}};const $e="undefined"==typeof self,ze="function"==typeof importScripts,Ke=(()=>{if(!ze){if(!$e&&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"./"}})(),Xe=e=>{if(null==e&&(e="./"),$e||ze);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e};var Qe;Me.engineResourcePaths.cvr={version:"3.4.20-dev-20260423155104",path:Ke,isInternal:!0},Le.cvr={js:!0,wasm:!0,deps:[fe.MN_DYNAMSOFT_LICENSE,fe.MN_DYNAMSOFT_IMAGE_PROCESSING,fe.MN_DYNAMSOFT_NEURAL_NETWORK]},Le.dnn={wasm:!0,deps:[fe.MN_DYNAMSOFT_IMAGE_PROCESSING]},be.cvr={};const Je="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,Je)<0&&(Me.engineResourcePaths.std={version:Je,path:Xe(Ke+`../../dynamsoft-capture-vision-std@${Je}/dist/`),isInternal:!0});const et="3.0.10";(!Me.engineResourcePaths.dip||"string"!=typeof Me.engineResourcePaths.dip&&D(Me.engineResourcePaths.dip.version,et)<0)&&(Me.engineResourcePaths.dip={version:et,path:Xe(Ke+`../../dynamsoft-image-processing@${et}/dist/`),isInternal:!0});const tt="2.0.10";(!Me.engineResourcePaths.dnn||"string"!=typeof Me.engineResourcePaths.dnn&&D(Me.engineResourcePaths.dnn.version,tt)<0)&&(Me.engineResourcePaths.dnn={version:tt,path:Xe(Ke+`../../dynamsoft-capture-vision-dnn@${tt}/dist/`),isInternal:!0});let it=class{static getVersion(){return this._version}};function st(e,t){if(e){if(e.sourceLocation){const i=e.sourceLocation.points;for(let e of i)e.x=e.x/t,e.y=e.y/t}if(e.location){const i=e.location.points;for(let e of i)e.x=e.x/t,e.y=e.y/t}st(e.referencedItem,t)}}function nt(e){if(e.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}function rt(e){return{type:ie.CRIT_ORIGINAL_IMAGE,referenceItem:null,targetROIDefName:"",taskName:"",imageData:e,toCanvas:()=>O(e),toImage:t=>N(t,e),toBlob:t=>M(t,e)}}function ot(e){let t=!1;const i=[ne.EC_UNSUPPORTED_JSON_KEY_WARNING,ne.EC_LICENSE_AUTH_QUOTA_EXCEEDED,ne.EC_LICENSE_RESULTS_LIMIT_EXCEEDED];if(e.errorCode&&i.includes(e.errorCode))return void console.warn(e.message);let s=new Error(e.errorCode?`[${e.functionName}] [${e.errorCode}] ${e.message}`:`[${e.functionName}] ${e.message}`);if(s.stack&&(s.stack=e.stack),e.isShouldThrow)throw s;return e.rj&&e.rj(s),t=!0,true}function at(e,t,i){return(i.x-e.x)*(t.y-e.y)==(t.x-e.x)*(i.y-e.y)&&Math.min(e.x,t.x)<=i.x&&i.x<=Math.max(e.x,t.x)&&Math.min(e.y,t.y)<=i.y&&i.y<=Math.max(e.y,t.y)}function ct(e){return Math.abs(e)<1e-6?0:e<0?-1:1}function lt(e,t,i,s){let n=e[0]*(i[1]-t[1])+t[0]*(e[1]-i[1])+i[0]*(t[1]-e[1]),r=e[0]*(s[1]-t[1])+t[0]*(e[1]-s[1])+s[0]*(t[1]-e[1]);return!((n^r)>=0&&0!==n&&0!==r||(n=i[0]*(e[1]-s[1])+s[0]*(i[1]-e[1])+e[0]*(s[1]-i[1]),r=i[0]*(t[1]-s[1])+s[0]*(i[1]-t[1])+t[0]*(s[1]-i[1]),(n^r)>=0&&0!==n&&0!==r))}it._version=`3.4.20-dev-20260423155104(Worker: ${null===(Qe=De.cvr)||void 0===Qe?void 0:Qe.worker}, Wasm: loading...`,BigInt(0),BigInt("0xFFFFFFFEFFFFFFFF"),BigInt(4265345023);const dt=BigInt(3147775),ut=(BigInt(260096),BigInt(1),BigInt(2),BigInt(4),BigInt(8),BigInt(16),BigInt(32),BigInt(64),BigInt(128),BigInt(256),BigInt(512),BigInt(1024),BigInt(2048),BigInt(4096),BigInt(8192),BigInt(16384),BigInt(32768),BigInt(65536),BigInt(131072),BigInt(262144),BigInt(16777216),BigInt(33554432),BigInt(67108864)),ht=BigInt(134217728);BigInt(268435456),BigInt(536870912),BigInt(1073741824),BigInt(524288),BigInt(2147483648),BigInt(1048576),BigInt(2097152),BigInt(4194304),BigInt(8388608),BigInt(68719476736),BigInt(0x3f0000000000000),BigInt(4294967296),BigInt(4503599627370496),BigInt(9007199254740992),BigInt(0x40000000000000),BigInt(0x80000000000000),BigInt(72057594037927940),BigInt(0x200000000000000),BigInt(8589934592),BigInt(17179869184),BigInt(34359738368),BigInt(51539607552),BigInt(137438953472),BigInt(274877906944);let _t=class{constructor(e){this._autoZoomParameters={minValue:1,maxValue:999,autoFocusFrameArray:[],autoFocusFrameLimit:[5,3],autoZoomDetectionArea:.5,autoZoomTargetBorder:.9,autoZoomIdealArea:[0,.05],autoZoomInFrameArray:[],autoZoomInFrameLimit:[5,3],autoZoomInMaxTimes:5,autoZoomInMinStep:Math.pow(10,.2),autoZoomInIdealModuleSize:6,autoZoomOutFrameCount:0,autoZoomOutFrameLimit:3,autoZoomOutStepRate:1/3,autoZoomOutStepRate_2:.05,autoZoomOutMinStep:2,frameArrayInIdealZoom:[],frameLimitInIdealZoom:[5,3]},this.isSupportDCEModule=!0,this.onTaskResultsReceived=async e=>{if(!this.isSupportDCEModule)return;let t=this.cameraEnhancer;(4&t._dceEnhancedFeatures||16&t._dceEnhancedFeatures||64&t._dceEnhancedFeatures)&&(0!==Me.bSupportDce4Module?(this.isSupportDCEModule=!1,console.warn("Warning: The license required for Enhanced Features was not found.")):(!this.consumeTime||Date.now()-this.consumeTime>1e4)&&(Me.cfd(1),this.consumeTime=Date.now()));const i=e.intermediateResultUnits;if(!t.isOpen()||t.isPaused())return;const s=t.getVisibleAreaInVideoXY({isConsiderRegionBox:!0});if(isNaN(s.x)||isNaN(s.y)||isNaN(s.width)||isNaN(s.height))return;let n=!1,r=!1;for(let e of i){if(e.unitType===ue.IRUT_DECODED_BARCODES&&e.decodedBarcodes.length){n=!0;break}e.unitType===ue.IRUT_LOCALIZED_BARCODES&&e.localizedBarcodes.length&&(r=!0)}if(16&t._dceEnhancedFeatures||4&t._dceEnhancedFeatures)if(n)this._autoZoomParameters.autoZoomInFrameArray.length=0,this._autoZoomParameters.autoZoomOutFrameCount=0,this._autoZoomParameters.frameArrayInIdealZoom.length=0,this._autoZoomParameters.autoFocusFrameArray.length=0;else{const n=async e=>{await t.setZoom(e)},o=async e=>{await t.setFocus(e)};if(r){s.x,s.y;const r=s.width,a=s.height,c=s.width,l=s.height;let d;{let e,n,r,o,a;{const e=t.video.videoWidth*(1-this._autoZoomParameters.autoZoomDetectionArea)/2,i=t.video.videoWidth*(1+this._autoZoomParameters.autoZoomDetectionArea)/2,s=i,n=e,r=t.video.videoHeight*(1-this._autoZoomParameters.autoZoomDetectionArea)/2,o=r,c=t.video.videoHeight*(1+this._autoZoomParameters.autoZoomDetectionArea)/2;a=[{x:e,y:r},{x:i,y:o},{x:s,y:c},{x:n,y:c}]}const u=[];{const e=(e,t)=>{const i=(e,t)=>{if(!e&&!t)throw new Error("Invalid arguments.");return function(e,t,i){let s=!1;const n=e.length;if(n<=2)return!1;for(let r=0;r<n;r++){const o=e[r],a=e[(r+1)%n];if(at(o,a,{x:t,y:i}))return!0;ct(o.y-i)>0!=ct(a.y-i)>0&&ct(t-(i-o.y)*(o.x-a.x)/(o.y-a.y)-o.x)<0&&(s=!s)}return s}(t,e.x,e.y)},s=(e,t)=>!!(lt([e[0],e[1]],[e[2],e[3]],[t[0].x,t[0].y],[t[1].x,t[1].y])||lt([e[0],e[1]],[e[2],e[3]],[t[1].x,t[1].y],[t[2].x,t[2].y])||lt([e[0],e[1]],[e[2],e[3]],[t[2].x,t[2].y],[t[3].x,t[3].y])||lt([e[0],e[1]],[e[2],e[3]],[t[3].x,t[3].y],[t[0].x,t[0].y]));return!!(i({x:e[0].x,y:e[0].y},t)||i({x:e[1].x,y:e[1].y},t)||i({x:e[2].x,y:e[2].y},t)||i({x:e[3].x,y:e[3].y},t))||!!(i({x:t[0].x,y:t[0].y},e)||i({x:t[1].x,y:t[1].y},e)||i({x:t[2].x,y:t[2].y},e)||i({x:t[3].x,y:t[3].y},e))||!!(s([t[0].x,t[0].y,t[1].x,t[1].y],e)||s([t[1].x,t[1].y,t[2].x,t[2].y],e)||s([t[2].x,t[2].y,t[3].x,t[3].y],e)||s([t[3].x,t[3].y,t[0].x,t[0].y],e))};for(let t of i)if(t.unitType===ue.IRUT_LOCALIZED_BARCODES)for(let i of t.localizedBarcodes)i&&e(a,i.location.points.map(e=>({x:e.x+s.x,y:e.y+s.y})))&&u.push(i)}if(!u.length)return;let h;if(u.length){let e=u.filter(e=>e.possibleFormats==ut||e.possibleFormats==ht);if(e.length||(e=u.filter(e=>e.possibleFormats==dt),e.length||(e=u)),e.length){const t=e=>{const t=e.location.points,i=(t[0].x+t[1].x+t[2].x+t[3].x)/4,s=(t[0].y+t[1].y+t[2].y+t[3].y)/4;return(i-c/2)*(i-c/2)+(s-l/2)*(s-l/2)};h=e[0];let i=t(h);if(1!=e.length)for(let s=1;s<e.length;s++){const n=t(e[s]);(e[s].confidence>1.1*h.confidence||e[s].confidence>.9*h.confidence&&n<i)&&(h=e[s],i=n)}}}if(h){const t=h.location.points;e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),n=Math.max(t[0].x,t[1].x,t[2].x,t[3].x),r=Math.min(t[0].y,t[1].y,t[2].y,t[3].y),o=Math.max(t[0].y,t[1].y,t[2].y,t[3].y),d={points:[{x:e,y:r},{x:n,y:r},{x:n,y:o},{x:e,y:o}],result:h}}}if(!d)return;if(this._autoZoomParameters.autoZoomOutFrameCount=0,16&t._dceEnhancedFeatures){const i=this._autoZoomParameters.autoZoomIdealArea[1];let s=(1-this._autoZoomParameters.autoZoomTargetBorder)/2;const c=d.points[0].x/r,l=(r-d.points[2].x)/r,u=d.points[0].y/a,h=(a-d.points[2].y)/a;if(c>i&&l>i&&u>i&&h>i&&d.result.moduleSize<this._autoZoomParameters.autoZoomInIdealModuleSize){if(this._autoZoomParameters.autoZoomInFrameArray.push(!0),this._autoZoomParameters.autoZoomInFrameArray.splice(0,this._autoZoomParameters.autoZoomInFrameArray.length-this._autoZoomParameters.autoZoomInFrameLimit[0]),this._autoZoomParameters.frameArrayInIdealZoom.length=0,4&t._dceEnhancedFeatures&&o({mode:"continuous"}).catch(()=>{}),this._autoZoomParameters.autoZoomInFrameArray.filter(e=>!0===e).length>=this._autoZoomParameters.autoZoomInFrameLimit[1]){this._autoZoomParameters.autoZoomInFrameArray.length=0;const i=[(.5-s)/(.5-c),(.5-s)/(.5-l),(.5-s)/(.5-u),(.5-s)/(.5-h)].filter(e=>e>0),r=Math.min(...i,this._autoZoomParameters.autoZoomInIdealModuleSize/d.result.moduleSize),o=t.getZoomSettings().factor;let a=Math.max(Math.pow(o*r,1/this._autoZoomParameters.autoZoomInMaxTimes),this._autoZoomParameters.autoZoomInMinStep);a=Math.min(a,r);let _=o*a;_=Math.max(t._dceAutoZoomRange.min,_),_=Math.min(t._dceAutoZoomRange.max,_);try{await n({factor:_})}catch(e){const t=e.message||e;console.warn(t)}t._framePipeline&&(t._framePipeline._data=null)}}else if(this._autoZoomParameters.autoZoomInFrameArray.length=0,this._autoZoomParameters.frameArrayInIdealZoom.push(!0),this._autoZoomParameters.frameArrayInIdealZoom.splice(0,this._autoZoomParameters.frameArrayInIdealZoom.length-this._autoZoomParameters.frameLimitInIdealZoom[0]),this._autoZoomParameters.frameArrayInIdealZoom.filter(e=>!0===e).length>=this._autoZoomParameters.frameLimitInIdealZoom[1]&&(this._autoZoomParameters.frameArrayInIdealZoom.length=0,4&t._dceEnhancedFeatures)){const i=d.points;try{await o({mode:"manual",area:{centerPoint:{x:(i[0].x+i[2].x)/2+"px",y:(i[0].y+i[2].y)/2+"px"},width:i[2].x-i[0].x+"px",height:i[2].y-i[0].y+"px"}})}catch(e){const t=e.message||e;console.warn(t)}t._framePipeline&&(t._framePipeline._data=null)}}if(!(16&t._dceEnhancedFeatures)&&4&t._dceEnhancedFeatures&&(this._autoZoomParameters.autoFocusFrameArray.push(!0),this._autoZoomParameters.autoFocusFrameArray.splice(0,this._autoZoomParameters.autoFocusFrameArray.length-this._autoZoomParameters.autoFocusFrameLimit[0]),this._autoZoomParameters.autoFocusFrameArray.filter(e=>!0===e).length>=this._autoZoomParameters.autoFocusFrameLimit[1])){this._autoZoomParameters.autoFocusFrameArray.length=0;try{const e=d.points;await o({mode:"manual",area:{centerPoint:{x:(e[0].x+e[2].x)/2+"px",y:(e[0].y+e[2].y)/2+"px"},width:e[2].x-e[0].x+"px",height:e[2].y-e[0].y+"px"}})}catch(e){const t=e.message||e;console.warn(t)}t._framePipeline&&(t._framePipeline._data=null)}}else{if(16&t._dceEnhancedFeatures){if(this._autoZoomParameters.autoZoomInFrameArray.push(!1),this._autoZoomParameters.autoZoomInFrameArray.splice(0,this._autoZoomParameters.autoZoomInFrameArray.length-this._autoZoomParameters.autoZoomInFrameLimit[0]),this._autoZoomParameters.autoZoomOutFrameCount++,this._autoZoomParameters.frameArrayInIdealZoom.push(!1),this._autoZoomParameters.frameArrayInIdealZoom.splice(0,this._autoZoomParameters.frameArrayInIdealZoom.length-this._autoZoomParameters.frameLimitInIdealZoom[0]),this._autoZoomParameters.autoZoomOutFrameCount>=this._autoZoomParameters.autoZoomOutFrameLimit){this._autoZoomParameters.autoZoomOutFrameCount=0;const i=t.getZoomSettings().factor;let s=i-Math.max((i-1)*this._autoZoomParameters.autoZoomOutStepRate,this._autoZoomParameters.autoZoomOutMinStep);s=Math.max(t._dceAutoZoomRange.min,s),s=Math.min(t._dceAutoZoomRange.max,s);try{await n({factor:s})}catch(e){const t=e.message||e;console.warn(t)}t._framePipeline&&(t._framePipeline._data=null)}4&t._dceEnhancedFeatures&&o({mode:"continuous"}).catch(()=>{})}!(16&t._dceEnhancedFeatures)&&4&t._dceEnhancedFeatures&&(this._autoZoomParameters.autoFocusFrameArray.length=0,o({mode:"continuous"}).catch(()=>{}))}}},this.isDce=!0,this.cameraEnhancer=e}};var mt,gt,ft,pt,Et,yt,It,vt,Rt,Ct,Tt,wt,St,At,Dt,bt,Lt,Ot,Nt,Mt,Bt,Ft,xt;!function(e){e[e.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",e[e.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}(mt||(mt={}));const Pt={onTaskResultsReceived:()=>{},isFilter:!0};Ce[-2]=async e=>{kt.onDataLoadProgressChanged&&kt.onDataLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class kt{constructor(){gt.add(this),this.maxImageSideLength=["iPhone","Android","HarmonyOS"].includes(Me.browserInfo.OS)?2048:4096,this.onCaptureError=null,this.provideDsImage=null,this._isOutputOriginalImage=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1,this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._minImageCaptureInterval=0,this._averageProcessintTimeArray=[],this._averageFetchImageTimeArray=[],this._currentSettings=null,this._averageTime=999,this._dynamsoft=!0,this._enhancedFeaturesIrr=null,this._templateName="",this._isCapturing=!1,this._s=!1,ft.set(this,null),pt.set(this,null),Et.set(this,null),yt.set(this,null),It.set(this,null),vt.set(this,new Set),Rt.set(this,new Set),Ct.set(this,new Set),Tt.set(this,500),wt.set(this,0),St.set(this,0),At.set(this,0),Dt.set(this,!1),bt.set(this,!1),this._singleFrameModeCallbackBind=this._singleFrameModeCallback.bind(this)}get disposed(){return Ue(this,bt,"f")}get isCapturing(){return this._isCapturing}static async createInstance(e=!0){if(!be.license)throw Error("The `license` module cannot be found.");return await be.license.dynamsoft(),await Me.loadWasm(),await new Promise((t,i)=>{const s=new kt;let n=Re();Ce[n]=async e=>{e.success?(s._instanceID=e.instanceID,s._currentSettings=JSON.parse(JSON.parse(e.outputSettings).data),kt._isNoOnnx=e.isNoOnnx,it._version=`3.4.20-dev-20260423155104(Worker: ${De.cvr.worker}, Wasm: ${e.version})`,Ve(s,Dt,!0,"f"),Ve(s,yt,s.getIntermediateResultManager(),"f"),Ve(s,Dt,!1,"f"),t(s)):ot({message:e.message,rj:i,stack:e.stack,functionName:"createInstance"})},Ie.postMessage({type:"cvr_createInstance",id:n,body:{loadPresetTemplates:e}})})}static async appendDLModelBuffer(e,t){return await Me.loadWasm(),kt._isNoOnnx?Promise.reject("Model not supported in the current environment."):await new Promise((i,s)=>{let n=Re();const r=b(Me.engineResourcePaths);let o;Ce[n]=async e=>{if(e.success){const t=JSON.parse(e.response);if(0!==t.errorCode&&ot({message:t.errorString?t.errorString:"Append Model Buffer Failed.",rj:s,errorCode:t.errorCode,functionName:"appendDLModelBuffer"}))return;return i(t)}ot({message:e.message,rj:s,stack:e.stack,functionName:"appendDLModelBuffer"})},t?o=t.endsWith("/")?t:t+"/":"DCV"===Me._bundleEnv?o=r.dcvData+"models/":"DBR"===Me._bundleEnv&&(o=r.dbrBundle+"models/");let a=Array.isArray(e)?e:[e];a=a.map(e=>e.replace(/\.data$/i,"")),Ie.postMessage({type:"cvr_appendDLModelBuffer",id:n,body:{modelNames:a,path:o}})})}static async clearDLModelBuffers(){return await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e();ot({message:i.message,rj:t,stack:i.stack,functionName:"clearDLModelBuffers"})},Ie.postMessage({type:"cvr_clearDLModelBuffers",id:i})})}async _singleFrameModeCallback(){const e=Ue(this,ft,"f")._singleFrameModeResultForDcv;if(!e)return;for(let t of Ue(this,vt,"f"))this._isOutputOriginalImage&&t.onOriginalImageResultReceived&&t.onOriginalImageResultReceived(rt(e));const t={bytes:new Uint8Array(e.bytes),width:e.width,height:e.height,stride:e.stride,format:e.format,imageTag:e.imageTag},i=await this.capture(t,this._templateName);i.originalImageTag=e.imageTag,Ue(this,ft,"f")._cameraView._capturedResultReceiver.onCapturedResultReceived(i,{isDetectVerifyOpen:this._isOpenDetectVerify,isNormalizeVerifyOpen:this._isOpenNormalizeVerify,isBarcodeVerifyOpen:this._isOpenBarcodeVerify,isLabelVerifyOpen:this._isOpenLabelVerify}),Ue(this,gt,"m",Nt).call(this,i),Ue(this,ft,"f")._singleFrameModeResultForDcv=null}setInput(e){if(nt(this),!this.isCapturing)if(Ve(this,ft,e,"f"),null==e?void 0:e.isCameraEnhancer){if(this._enhancedFeaturesIrr)return;this._enhancedFeaturesIrr=new _t(e),Ue(this,yt,"f").addResultReceiver(this._enhancedFeaturesIrr)}else Ue(this,yt,"f").removeResultReceiver(this._enhancedFeaturesIrr),this._enhancedFeaturesIrr=null}getInput(){return Ue(this,ft,"f")}addImageSourceStateListener(e){if(nt(this),"object"!=typeof e)return console.warn("Invalid ISA state listener.");e&&Object.keys(e)&&Ue(this,Rt,"f").add(e)}removeImageSourceStateListener(e){return nt(this),Ue(this,Rt,"f").delete(e)}async addResultReceiver(e){if(nt(this),"object"!=typeof e)throw new Error("Invalid receiver.");e&&Object.keys(e).length&&(Ue(this,vt,"f").add(e),await this._setCrrRegistry())}async removeResultReceiver(e){nt(this),Ue(this,vt,"f").delete(e),await this._setCrrRegistry()}async removeAllResultReceivers(){nt(this),Ue(this,vt,"f").clear(),await this._setCrrRegistry()}async _setCrrRegistry(){const e={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onProcessedDocumentResultReceived:!1,onParsedResultsReceived:!1};for(let t of Ue(this,vt,"f"))t.isDce||(e.onCapturedResultReceived=!!t.onCapturedResultReceived,e.onDecodedBarcodesReceived=!!t.onDecodedBarcodesReceived,e.onRecognizedTextLinesReceived=!!t.onRecognizedTextLinesReceived,e.onProcessedDocumentResultReceived=!!t.onProcessedDocumentResultReceived,e.onParsedResultsReceived=!!t.onParsedResultsReceived);let t=Re();return await new Promise((i,s)=>{Ce[t]=async e=>{e.success?i():ot({message:e.message,rj:s,stack:e.stack,functionName:"addResultReceiver"})},Ie.postMessage({type:"cvr_setCrrRegistry",id:t,instanceID:this._instanceID,body:{receiver:JSON.stringify(e)}})})}async addResultFilter(e){if(nt(this),!e._dynamsoft)throw new Error("User defined CapturedResultFilter is not supported.");if(!e||"object"!=typeof e||!Object.keys(e).length)return console.warn("Invalid filter.");Ue(this,Ct,"f").add(e),e._dynamsoft(),await this._handleFilterUpdate()}async removeResultFilter(e){nt(this),Ue(this,Ct,"f").delete(e),await this._handleFilterUpdate()}async removeAllResultFilters(){nt(this),Ue(this,Ct,"f").clear(),await this._handleFilterUpdate()}async _handleFilterUpdate(){if(Ue(this,yt,"f").removeResultReceiver(Pt),0===Ue(this,Ct,"f").size){this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1;const e={[ie.CRIT_BARCODE]:!1,[ie.CRIT_TEXT_LINE]:!1,[ie.CRIT_DETECTED_QUAD]:!1,[ie.CRIT_DESKEWED_IMAGE]:!1,[ie.CRIT_ENHANCED_IMAGE]:!1},t={[ie.CRIT_BARCODE]:!1,[ie.CRIT_TEXT_LINE]:!1,[ie.CRIT_DETECTED_QUAD]:!1,[ie.CRIT_DESKEWED_IMAGE]:!1,[ie.CRIT_ENHANCED_IMAGE]:!1};return await Ue(this,gt,"m",Mt).call(this,e),void await Ue(this,gt,"m",Bt).call(this,t)}for(let e of Ue(this,Ct,"f"))this._isOpenBarcodeVerify=e.isResultCrossVerificationEnabled(ie.CRIT_BARCODE),this._isOpenLabelVerify=e.isResultCrossVerificationEnabled(ie.CRIT_TEXT_LINE),this._isOpenDetectVerify=e.isResultCrossVerificationEnabled(ie.CRIT_DETECTED_QUAD),this._isOpenNormalizeVerify=e.isResultCrossVerificationEnabled(ie.CRIT_DESKEWED_IMAGE),e.isLatestOverlappingEnabled(ie.CRIT_BARCODE)&&([...Ue(this,yt,"f")._intermediateResultReceiverSet.values()].find(e=>e.isFilter)||Ue(this,yt,"f").addResultReceiver(Pt)),await Ue(this,gt,"m",Mt).call(this,e.verificationEnabled),await Ue(this,gt,"m",Bt).call(this,e.duplicateFilterEnabled),await Ue(this,gt,"m",Ft).call(this,e.duplicateForgetTime),await Ue(this,gt,"m",xt).call(this,e.crossVerificationCriteria)}async startCapturing(e){var t;if(nt(this),this.isCapturing)return;if(!Ue(this,ft,"f"))throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");e||(e=kt._defaultTemplate);for(let e of Ue(this,Ct,"f"))await this.addResultFilter(e);const i=b(Me.engineResourcePaths);if(Ue(this,Et,"f")&&Ue(this,Et,"f").isPending)return Ue(this,Et,"f");const s=Ve(this,At,(t=Ue(this,At,"f"),++t),"f");return Ve(this,Et,new je((t,n)=>{if(this.disposed)return;let r=Re();Ce[r]=async i=>{Ue(this,Et,"f")&&!Ue(this,Et,"f").isFulfilled&&s===Ue(this,At,"f")&&(i.success?(this._isCapturing=!0,this._templateName=e,void 0!==Ue(this,ft,"f").singleFrameMode&&"disabled"!==Ue(this,ft,"f").singleFrameMode?(Ue(this,ft,"f").on("singleFrameAcquired",this._singleFrameModeCallbackBind),this._singleFrameModeCallback(),t()):(this._isOutputOriginalImage=i.isOutputOriginalImage,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(async()=>{if(s===Ue(this,At,"f")&&this.isCapturing){-1!==this._minImageCaptureInterval&&Ue(this,ft,"f").startFetching();for(let e of Ue(this,Rt,"f"))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(mt.ISS_BUFFER_EMPTY);this.barcodeScanLoop(e,s),t()}},0))):ot({message:i.message,rj:n,stack:i.stack,functionName:"startCapturing"}))},Ie.postMessage({type:"cvr_startCapturing",id:r,instanceID:this._instanceID,body:{templateName:e,engineResourcePaths:i}})}),"f"),await Ue(this,Et,"f")}stopCapturing(){var e;if(nt(this),!Ue(this,ft,"f"))return;Ve(this,At,(e=Ue(this,At,"f"),++e),"f"),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=null,Ue(this,ft,"f").stopFetching(),this._averageProcessintTimeArray=[],this._isCapturing=!1,this._averageTime=999,Ve(this,Et,null,"f"),Ue(this,ft,"f").isCameraEnhancer&&Ue(this,ft,"f").off("singleFrameAcquired",this._singleFrameModeCallbackBind);const t=Re();Ie.postMessage({type:"cvr_stopCapturing",id:t,instanceID:this._instanceID})}async containsTask(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(JSON.parse(e.tasks));ot({message:e.message,rj:i,stack:e.stack,functionName:"containsTask"})},Ie.postMessage({type:"cvr_containsTask",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async switchCapturingTemplate(e){const t=!this.isCapturing;if(!t){if(this.stopCapturing(),!await this.checkTemplateNameValidity(e))return await this.startCapturing(this._templateName),Promise.reject(new Error("[switchCapturingTemplate] [-10036] The template name is invalid."));if(!t)try{await this.startCapturing(e)}catch(e){return"string"==typeof e.message&&(e.message=e.message.replace("startCapturing","switchCapturingTemplate")),Promise.reject(e)}}}async barcodeScanLoop(e,t=Ue(this,At,"f")){if(t!==Ue(this,At,"f")||!this.isCapturing)return;if(Ue(this,ft,"f").isBufferEmpty())if(Ue(this,ft,"f").hasNextImageToFetch())for(let e of Ue(this,Rt,"f"))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(mt.ISS_BUFFER_EMPTY);else if(!Ue(this,ft,"f").hasNextImageToFetch())for(let e of Ue(this,Rt,"f"))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(mt.ISS_EXHAUSTED);const i=Ue(this,ft,"f").getImage();if(!i)return void this.continueLoop(e,t);if(i.imageTag&&Date.now()-i.imageTag.timeStamp>200)return void this.continueLoop(e,t);for(let e of Ue(this,vt,"f"))this._isOutputOriginalImage&&e.onOriginalImageResultReceived&&e.onOriginalImageResultReceived(rt(i));i._s=!0;const s=Date.now();this._captureInWorker(i,e).then(async n=>{if(t!==Ue(this,At,"f")||!this.isCapturing)return;if(kt._onLog&&kt._onLog("no js handle time: "+(Date.now()-s)),!this.isCapturing)return void this.continueLoop(e,t);n.originalImageTag=i.imageTag?i.imageTag:null,Ue(this,ft,"f")._capturedResultReceiver&&Ue(this,ft,"f")._cameraView._capturedResultReceiver.onCapturedResultReceived(n,{isDetectVerifyOpen:this._isOpenDetectVerify,isNormalizeVerifyOpen:this._isOpenNormalizeVerify,isBarcodeVerifyOpen:this._isOpenBarcodeVerify,isLabelVerifyOpen:this._isOpenLabelVerify});for(let e of Ue(this,Ct,"f")){const t=e;t.onOriginalImageResultReceived(n),t.onDecodedBarcodesReceived(n),t.onRecognizedTextLinesReceived(n),t.onProcessedDocumentResultReceived(n),t.onParsedResultsReceived(n)}Ue(this,gt,"m",Nt).call(this,n);const r=Date.now();if(this._minImageCaptureInterval>-1&&(5===this._averageProcessintTimeArray.length&&this._averageProcessintTimeArray.shift(),5===this._averageFetchImageTimeArray.length&&this._averageFetchImageTimeArray.shift(),this._averageProcessintTimeArray.push(Date.now()-s),this._averageFetchImageTimeArray.push(i&&i.imageTag?i.imageTag.timeSpent:0),this._averageTime=Math.min(...this._averageProcessintTimeArray)-Math.max(...this._averageFetchImageTimeArray),this._averageTime=this._averageTime>0?this._averageTime:0,kt._onLog&&(kt._onLog(`minImageCaptureInterval: ${this._minImageCaptureInterval}`),kt._onLog(`averageProcessintTimeArray: ${this._averageProcessintTimeArray}`),kt._onLog(`averageFetchImageTimeArray: ${this._averageFetchImageTimeArray}`),kt._onLog(`averageTime: ${this._averageTime}`))),kt._onLog){const e=Date.now()-r;e>10&&kt._onLog(`fetch image calculate time: ${e}`)}kt._onLog&&kt._onLog(`time finish decode: ${Date.now()}`),kt._onLog&&kt._onLog("main time: "+(Date.now()-s)),kt._onLog&&kt._onLog("===================================================="),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._minImageCaptureInterval>0&&this._minImageCaptureInterval>=this._averageTime?this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(e,t)},this._minImageCaptureInterval-this._averageTime):this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(e,t)},Math.max(this._minImageCaptureInterval,0))}).catch(i=>{t===Ue(this,At,"f")&&(Ue(this,ft,"f").stopFetching(),"platform error"!==i.message&&(i.errorCode&&0===i.errorCode&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{Ue(this,ft,"f").startFetching(),this.barcodeScanLoop(e,t)},Math.max(this._minImageCaptureInterval,1e3))),setTimeout(()=>{if(t===Ue(this,At,"f")){if(!this.onCaptureError)throw i;this.onCaptureError(i)}},0)))})}continueLoop(e,t=Ue(this,At,"f")){t===Ue(this,At,"f")&&this.isCapturing&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(e,t)},0))}async getClarity(e,t,i,s,n){const{bytes:r,width:o,height:a,stride:c,format:l}=e;let d=Re();return new Promise((e,u)=>{Ce[d]=async t=>{t.success?e(t.clarity):ot({message:t.message,rj:u,stack:t.stack,functionName:"getClarity"})},Ie.postMessage({type:"cvr_getClarity",id:d,instanceID:this._instanceID,body:{bytes:r,width:o,height:a,stride:c,format:l,bitcount:t,wr:i,hr:s,grayThreshold:n}},[r.buffer])})}async capture(e,t){let i;if(nt(this),t||(t=kt._defaultTemplate),C(e))i=await this._captureDsimage(e,t);else if("string"==typeof e)i="data:image/"==e.substring(0,11)?await this._captureBase64(e,t):await this._captureUrl(e,t);else if(e instanceof Blob)i=await this._captureBlob(e,t);else if(e instanceof HTMLImageElement)i=await this._captureImage(e,t);else if(e instanceof HTMLCanvasElement)i=await this._captureCanvas(e,t);else{if(!(e instanceof HTMLVideoElement))throw new TypeError("'capture(imageOrFile, templateName)': Type of 'imageOrFile' should be 'DSImageData', 'Url', 'Base64', 'Blob', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement'.");i=await this._captureVideo(e,t)}return i}async _captureDsimage(e,t){return await this._captureInWorker(e,t)}async _captureUrl(e,t){let i=await S(e,"blob");return await this._captureBlob(i,t)}async _captureBase64(e,t){e=e.substring(e.indexOf(",")+1);let i=atob(e),s=i.length,n=new Uint8Array(s);for(;s--;)n[s]=i.charCodeAt(s);return await this._captureBlob(new Blob([n]),t)}async _captureBlob(e,t){let i=null,s=null;if("undefined"!=typeof createImageBitmap)try{i=await createImageBitmap(e)}catch(e){}i||(s=await async function(t){return await new Promise((i,s)=>{let n=URL.createObjectURL(t),r=new Image;r.src=n,r.onload=()=>{URL.revokeObjectURL(r.dbrObjUrl),i(r)},r.onerror=()=>{let t="Unsupported image format. Please upload files in one of the following formats: .jpg,.jpeg,.ico,.gif,.svg,.webp,.png,.bmp";"image/svg+xml"===e.type&&(t="Invalid SVG file. The file appears to be malformed or contains invalid XML."),s(new Error(t))}})}(e));let n=await this._captureImage(i||s,t);return i&&i.close(),n}async _captureImage(e,t){let i,s,n=e instanceof HTMLImageElement?e.naturalWidth:e.width,r=e instanceof HTMLImageElement?e.naturalHeight:e.height,o=Math.max(n,r);o>this.maxImageSideLength?(Ve(this,St,this.maxImageSideLength/o,"f"),i=Math.round(n*Ue(this,St,"f")),s=Math.round(r*Ue(this,St,"f"))):(i=n,s=r),Ue(this,pt,"f")||Ve(this,pt,document.createElement("canvas"),"f");const a=Ue(this,pt,"f");return a.width===i&&a.height===s||(a.width=i,a.height=s),a.ctx2d||(a.ctx2d=a.getContext("2d",{willReadFrequently:!0})),a.ctx2d.drawImage(e,0,0,n,r,0,0,i,s),e.dbrObjUrl&&URL.revokeObjectURL(e.dbrObjUrl),await this._captureCanvas(a,t)}async _captureCanvas(e,t){if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";if([e.width,e.height].includes(0))throw Error("The width or height of the 'canvas' is 0.");const i=e.ctx2d||e.getContext("2d",{willReadFrequently:!0}),s={bytes:Uint8Array.from(i.getImageData(0,0,e.width,e.height).data),width:e.width,height:e.height,stride:4*e.width,format:_.IPF_ABGR_8888};return await this._captureInWorker(s,t)}async _captureVideo(e,t){if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";let i,s,n=e.videoWidth,r=e.videoHeight,o=Math.max(n,r);o>this.maxImageSideLength?(Ve(this,St,this.maxImageSideLength/o,"f"),i=Math.round(n*Ue(this,St,"f")),s=Math.round(r*Ue(this,St,"f"))):(i=n,s=r),Ue(this,pt,"f")||Ve(this,pt,document.createElement("canvas"),"f");const a=Ue(this,pt,"f");return a.width===i&&a.height===s||(a.width=i,a.height=s),a.ctx2d||(a.ctx2d=a.getContext("2d",{willReadFrequently:!0})),a.ctx2d.drawImage(e,0,0,n,r,0,0,i,s),await this._captureCanvas(a,t)}async _captureInWorker(e,t){let{bytes:i,width:s,height:n,stride:r,format:o,imageTag:a}=e,c=Re();return await new Promise((l,d)=>{this.provideDsImage=e,Ce[c]=t=>{if(t.success){const i=Date.now();kt._onLog&&(kt._onLog(`get result time from worker: ${i}`),kt._onLog("worker to main time consume: "+(i-t.workerReturnMsgTime)));try{Ue(this,gt,"m",Lt).call(this,t.captureResult,e),e.bytes=t.bytes,t._s||Ve(this,St,0,"f"),Ue(this,gt,"m",Ot).call(this,t.intermediateResult,a);const i=Date.now();return i-Ue(this,wt,"f")>Ue(this,Tt,"f")&&null!==t.mliRecord&&(null===localStorage||void 0===localStorage||localStorage.setItem("dynamsoft",t.mliRecord),Ve(this,wt,i,"f")),l(t.captureResult)}catch(e){ot({message:e.message,rj:d,stack:e.stack,functionName:"capture"})}}else ot({message:t.message,rj:d,stack:t.stack,functionName:"capture"})},kt._onLog&&kt._onLog(`send buffer to worker: ${Date.now()}`);const u=e.hasOwnProperty("_s")?e._s:this._s;Ie.postMessage({type:"cvr_capture",id:c,instanceID:this._instanceID,body:{bytes:i,width:s,height:n,stride:r,format:o,templateName:t||"",dynamsoft:this._dynamsoft,_s:u}},[i.buffer])})}async initSettings(e){return nt(this),this.isCapturing?Promise.reject(new Error("initSettings:-10062:Failed to call the function while capturing in progress.")):e&&["string","object"].includes(typeof e)?("string"==typeof e?e.trimStart().startsWith("{")||(e=await S(e,"text")):"object"==typeof e&&(e=JSON.stringify(e)),await new Promise((t,i)=>{let s=Re();Ce[s]=async s=>{if(s.success){const n=JSON.parse(s.response);if(0!==n.errorCode&&ot({message:n.errorString?n.errorString:"Init Settings Failed.",rj:i,errorCode:n.errorCode,functionName:"initSettings"}))return;const r=JSON.parse(e);return this._currentSettings=r,this._isOutputOriginalImage=1===this._currentSettings.CaptureVisionTemplates[0].OutputOriginalImage,kt._defaultTemplate=this._currentSettings.CaptureVisionTemplates[0].Name,t(n)}ot({message:s.message,rj:i,stack:s.stack,functionName:"initSettings"})},Ie.postMessage({type:"cvr_initSettings",id:s,instanceID:this._instanceID,body:{settings:e}})})):void console.error("Invalid template.")}async outputSettings(e,t){return nt(this),await new Promise((i,s)=>{let n=Re();Ce[n]=async e=>{if(e.success){const t=JSON.parse(e.response);if(0!==t.errorCode&&ot({message:t.errorString,rj:s,errorCode:t.errorCode,functionName:"outputSettings"}))return;return i(JSON.parse(t.data))}ot({message:e.message,rj:s,stack:e.stack,functionName:"outputSettings"})},Ie.postMessage({type:"cvr_outputSettings",id:n,instanceID:this._instanceID,body:{templateName:e,includeDefaultValues:!!t}})})}async outputSettingsToFile(e,t,i,s){const n=await this.outputSettings(e,s),r=new Blob([JSON.stringify(n,null,2,function(e,t){return t instanceof Array?JSON.stringify(t):t},2)],{type:"application/json"});if(i){const e=document.createElement("a");e.href=URL.createObjectURL(r),t.endsWith(".json")&&(t=t.replace(".json","")),e.download=`${t}.json`,e.onclick=()=>{setTimeout(()=>{URL.revokeObjectURL(e.href)},500)},e.click()}return r}async getTemplateNames(){return nt(this),await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&ot({message:s.errorString,rj:t,errorCode:s.errorCode,functionName:"getTemplateNames"}))return;return e(JSON.parse(s.data))}ot({message:i.message,rj:t,stack:i.stack,functionName:"getTemplateNames"})},Ie.postMessage({type:"cvr_getTemplateNames",id:i,instanceID:this._instanceID})})}async getSimplifiedSettings(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success){const s=JSON.parse(e.response);if(0!==s.errorCode&&ot({message:s.errorString,rj:i,errorCode:s.errorCode,functionName:"getSimplifiedSettings"}))return;const n=JSON.parse(s.data,(e,t)=>"barcodeFormatIds"===e?BigInt(t):t);return n.minImageCaptureInterval=this._minImageCaptureInterval,t(n)}ot({message:e.message,rj:i,stack:e.stack,functionName:"getSimplifiedSettings"})},Ie.postMessage({type:"cvr_getSimplifiedSettings",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async updateSettings(e,t){return nt(this),await new Promise((i,s)=>{let n=Re();Ce[n]=async e=>{if(e.success){const n=JSON.parse(e.response);if(t.minImageCaptureInterval&&t.minImageCaptureInterval>=-1&&(this._minImageCaptureInterval=t.minImageCaptureInterval),this._isOutputOriginalImage=e.isOutputOriginalImage,0!==n.errorCode&&ot({message:n.errorString?n.errorString:"Update Settings Failed.",rj:s,errorCode:n.errorCode,functionName:"updateSettings"}))return;return this._currentSettings=await this.outputSettings("*"),i(n)}ot({message:e.message,rj:s,stack:e.stack,functionName:"updateSettings"})},Ie.postMessage({type:"cvr_updateSettings",id:n,instanceID:this._instanceID,body:{settings:t,templateName:e}})})}async resetSettings(){return nt(this),this.isCapturing?Promise.reject(new Error("resetSettings:-10062:Failed to call the function while capturing in progress.")):await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&ot({message:s.errorString?s.errorString:"Reset Settings Failed.",rj:t,errorCode:s.errorCode,functionName:"resetSettings"}))return;return this._currentSettings=await this.outputSettings("*"),e(s)}ot({message:i.message,rj:t,stack:i.stack,functionName:"resetSettings"})},Ie.postMessage({type:"cvr_resetSettings",id:i,instanceID:this._instanceID})})}getBufferedItemsManager(){return Ue(this,It,"f")||Ve(this,It,new Ze(this),"f"),Ue(this,It,"f")}getIntermediateResultManager(){if(nt(this),!Ue(this,Dt,"f")&&0!==Me.bSupportIRTModule)throw new Error("The current license does not support the use of intermediate results.");return Ue(this,yt,"f")||Ve(this,yt,new Ye(this),"f"),Ue(this,yt,"f")}static async setGlobalIntraOpNumThreads(e=0){return e>4||e<0?Promise.reject(new RangeError("'intraOpNumThreads' should be between 0 and 4.")):(await Me.loadWasm(),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t();ot({message:e.message,rj:i,stack:e.stack,functionName:"setGlobalIntraOpNumThreads"})},Ie.postMessage({type:"cvr_setGlobalIntraOpNumThreads",id:s,body:{intraOpNumThreads:e}})}))}async checkTemplateNameValidity(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>e.success?t(e.isValid):t(!1),Ie.postMessage({type:"cvr_checkTemplateNameValidity",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async parseRequiredResources(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(JSON.parse(e.resources));ot({message:e.message,rj:i,stack:e.stack,functionName:"parseRequiredResources"})},Ie.postMessage({type:"cvr_parseRequiredResources",id:s,instanceID:this._instanceID,body:{templateName:e}})})}dispose(){nt(this),Ue(this,Et,"f")&&this.stopCapturing(),Ve(this,ft,null,"f"),Ue(this,vt,"f").clear(),Ue(this,Rt,"f").clear(),Ue(this,Ct,"f").clear(),Ue(this,yt,"f")._intermediateResultReceiverSet.clear(),Ve(this,bt,!0,"f");let e=Re();Ce[e]=e=>{e.success||ot({message:e.message,stack:e.stack,isShouldThrow:!0,functionName:"dispose"})},Ie.postMessage({type:"cvr_dispose",id:e,instanceID:this._instanceID})}_getInternalData(){return{isa:Ue(this,ft,"f"),promiseStartScan:Ue(this,Et,"f"),intermediateResultManager:Ue(this,yt,"f"),bufferdItemsManager:Ue(this,It,"f"),resultReceiverSet:Ue(this,vt,"f"),isaStateListenerSet:Ue(this,Rt,"f"),resultFilterSet:Ue(this,Ct,"f"),compressRate:Ue(this,St,"f"),canvas:Ue(this,pt,"f"),innerUseTag:Ue(this,Dt,"f"),isDestroyed:Ue(this,bt,"f")}}async _getWasmFilterState(){return await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success){const t=JSON.parse(i.response);return e(t)}ot({message:i.message,rj:t,stack:i.stack,functionName:""})},Ie.postMessage({type:"cvr_getWasmFilterState",id:i,instanceID:this._instanceID})})}}ft=new WeakMap,pt=new WeakMap,Et=new WeakMap,yt=new WeakMap,It=new WeakMap,vt=new WeakMap,Rt=new WeakMap,Ct=new WeakMap,Tt=new WeakMap,wt=new WeakMap,St=new WeakMap,At=new WeakMap,Dt=new WeakMap,bt=new WeakMap,gt=new WeakSet,Lt=function(e,t){var i,s,n,r,o,a,c,l,d,u,h,_;for(let m=0;m<e.items.length;m++){const g=e.items[m];switch(0!==Ue(this,St,"f")&&st(g,Ue(this,St,"f")),g.type){case ie.CRIT_ORIGINAL_IMAGE:e.items[m]=rt(t);break;case ie.CRIT_BARCODE:null!==(i=(c=e.decodedBarcodesResult).barcodeResultItems)&&void 0!==i||(c.barcodeResultItems=[]),e.decodedBarcodesResult.barcodeResultItems.push(g);break;case ie.CRIT_TEXT_LINE:null!==(s=(l=e.recognizedTextLinesResult).textLineResultItems)&&void 0!==s||(l.textLineResultItems=[]),e.recognizedTextLinesResult.textLineResultItems.push(g);break;case ie.CRIT_DETECTED_QUAD:null!==(n=(d=e.processedDocumentResult).detectedQuadResultItems)&&void 0!==n||(d.detectedQuadResultItems=[]),e.processedDocumentResult.detectedQuadResultItems.push(g);break;case ie.CRIT_DESKEWED_IMAGE:be.ddn&&be.ddn.handleDeskewedAndEnhancedImageResultItem(g),null!==(r=(u=e.processedDocumentResult).deskewedImageResultItems)&&void 0!==r||(u.deskewedImageResultItems=[]),e.processedDocumentResult.deskewedImageResultItems.push(g);break;case ie.CRIT_ENHANCED_IMAGE:be.ddn&&be.ddn.handleDeskewedAndEnhancedImageResultItem(g),null!==(o=(h=e.processedDocumentResult).enhancedImageResultItems)&&void 0!==o||(h.enhancedImageResultItems=[]),e.processedDocumentResult.enhancedImageResultItems.push(g);break;case ie.CRIT_PARSED_RESULT:be.dcp&&be.dcp.handleParsedResultItem(g),null!==(a=(_=e.parsedResult).parsedResultItems)&&void 0!==a||(_.parsedResultItems=[]),e.parsedResult.parsedResultItems.push(g)}}},Ot=function(e,t){const i=e;if(i){let e=0;for(let s of Ue(this,yt,"f")._intermediateResultReceiverSet){e++;for(let n of i){if(["onTaskResultsReceived","onTargetROIResultsReceived"].includes(n.info.callbackName)){for(let e of n.intermediateResultUnits)e.originalImageTag=t||null;s[n.info.callbackName]&&s[n.info.callbackName]({intermediateResultUnits:n.intermediateResultUnits},n.info)}else s[n.info.callbackName]&&s[n.info.callbackName](n.result,n.info);e===Ue(this,yt,"f")._intermediateResultReceiverSet.size&&delete n.info.callbackName}}}},Nt=function(e){for(let t of Ue(this,vt,"f"))e.decodedBarcodesResult&&t.onDecodedBarcodesReceived&&t.onDecodedBarcodesReceived(e.decodedBarcodesResult),e.recognizedTextLinesResult&&t.onRecognizedTextLinesReceived&&t.onRecognizedTextLinesReceived(e.recognizedTextLinesResult),e.processedDocumentResult&&t.onProcessedDocumentResultReceived&&t.onProcessedDocumentResultReceived(e.processedDocumentResult),e.parsedResult&&t.onParsedResultsReceived&&t.onParsedResultsReceived(e.parsedResult),t.onCapturedResultReceived&&t.onCapturedResultReceived(e)},Mt=async function(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(e.result);ot({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Ie.postMessage({type:"cvr_enableResultCrossVerification",id:s,instanceID:this._instanceID,body:{verificationEnabled:e}})})},Bt=async function(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(e.result);ot({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Ie.postMessage({type:"cvr_enableResultDeduplication",id:s,instanceID:this._instanceID,body:{duplicateFilterEnabled:e}})})},Ft=async function(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(e.result);ot({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Ie.postMessage({type:"cvr_setDuplicateForgetTime",id:s,instanceID:this._instanceID,body:{duplicateForgetTime:e}})})},xt=async function(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t();ot({message:e.message,rj:i,stack:e.stack,functionName:"setResultCrossVerificationCriteria"})},Ie.postMessage({type:"cvr_setResultCrossVerificationCriteria",id:s,instanceID:this._instanceID,body:{criteria:e}})})},kt._defaultTemplate="Default",kt._isNoOnnx=!1;class Ut{constructor(){this.onCapturedResultReceived=null,this.onOriginalImageResultReceived=null}}var Vt;!function(e){e.PT_DEFAULT="Default",e.PT_READ_BARCODES="ReadBarcodes_Default",e.PT_RECOGNIZE_TEXT_LINES="RecognizeTextLines_Default",e.PT_DETECT_DOCUMENT_BOUNDARIES="DetectDocumentBoundaries_Default",e.PT_DETECT_AND_NORMALIZE_DOCUMENT="DetectAndNormalizeDocument_Default",e.PT_NORMALIZE_DOCUMENT="NormalizeDocument_Default",e.PT_READ_BARCODES_SPEED_FIRST="ReadBarcodes_SpeedFirst",e.PT_READ_BARCODES_READ_RATE_FIRST="ReadBarcodes_ReadRateFirst",e.PT_READ_BARCODES_BALANCE="ReadBarcodes_Balance",e.PT_READ_SINGLE_BARCODE="ReadSingleBarcode",e.PT_READ_DENSE_BARCODES="ReadDenseBarcodes",e.PT_READ_DISTANT_BARCODES="ReadDistantBarcodes",e.PT_RECOGNIZE_NUMBERS="RecognizeNumbers",e.PT_RECOGNIZE_LETTERS="RecognizeLetters",e.PT_RECOGNIZE_NUMBERS_AND_LETTERS="RecognizeNumbersAndLetters",e.PT_RECOGNIZE_NUMBERS_AND_UPPERCASE_LETTERS="RecognizeNumbersAndUppercaseLetters",e.PT_RECOGNIZE_UPPERCASE_LETTERS="RecognizeUppercaseLetters"}(Vt||(Vt={}));var Gt,Wt,jt,Zt=Object.freeze({__proto__:null,CaptureVisionRouter:kt,CaptureVisionRouterModule:it,CapturedResultReceiver:Ut,get EnumImageSourceState(){return mt},get EnumPresetTemplate(){return Vt},IntermediateResultReceiver:class{constructor(){this._observedResultUnitTypes=ue.IRUT_ALL,this._observedTaskMap=new Map,this._parameters={setObservedResultUnitTypes:e=>{this._observedResultUnitTypes=e},getObservedResultUnitTypes:()=>this._observedResultUnitTypes,isResultUnitTypeObserved:e=>!!(e&this._observedResultUnitTypes),addObservedTask:e=>{this._observedTaskMap.set(e,!0)},removeObservedTask:e=>{this._observedTaskMap.set(e,!1)},isTaskObserved:e=>0===this._observedTaskMap.size||!!this._observedTaskMap.get(e)},this.onTaskResultsReceived=null,this.onPredetectedRegionsReceived=null,this.onColourImageUnitReceived=null,this.onScaledColourImageUnitReceived=null,this.onGrayscaleImageUnitReceived=null,this.onTransformedGrayscaleImageUnitReceived=null,this.onEnhancedGrayscaleImageUnitReceived=null,this.onBinaryImageUnitReceived=null,this.onTextureDetectionResultUnitReceived=null,this.onTextureRemovedGrayscaleImageUnitReceived=null,this.onTextureRemovedBinaryImageUnitReceived=null,this.onContoursUnitReceived=null,this.onLineSegmentsUnitReceived=null,this.onTextZonesUnitReceived=null,this.onTextRemovedBinaryImageUnitReceived=null,this.onShortLinesUnitReceived=null}getObservationParameters(){return this._parameters}}});function Ht(e){return e&&"object"==typeof e&&"string"==typeof e.path}function qt(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const Yt=/<style>([\s\S]*?)<\/style>/g,$t=/style="([\s\S]*?)"/g,zt=(e,t)=>{const{inlineScript2Blob:i,internalCss2Blob:s,insertInternalCss2ExistedSheet:n}=t||{};if(n){let t,i;for(let s=0;s<document.styleSheets.length;++s){const n=document.styleSheets[s];try{i=n.cssRules,t=n;break}catch(e){}}t&&(e=e.replace(Yt,(e,s,n,r)=>{let o=s.split("}");const a=o.length-1;let c=[],l=null,d=0;for(let e=0;e<a;++e){let t=0;for(;-1!==(t=o[e].indexOf("{",t));)d+=1,t+=1;if(l)1===d?(c.push(l+o[e]+"}"),l=null,d=0):(l+=o[e]+"}",--d);else{if(d<1)throw new Error("invalid style");1===d?(c.push(o[e].trimStart()+"}"),d=0):(l=o[e].trimStart()+"}",--d)}}if(l||d)throw new Error("invalid style");for(let e of c)t.insertRule(e,i.length);return""}))}const r=[];s&&(e=e.replace(Yt,(e,t,i,s)=>(r.push(new Blob([t],{type:"text/css"})),"<HasStyle></HasStyle>")));const o=[];e=e.replace($t,(e,t,i,s)=>(o.push(t),"hasstyle"));const a=document.createElement("div");if(a.insertAdjacentHTML("beforeend",e),a.normalize(),s){const e=a.querySelectorAll("HasStyle");for(let t=0;t<r.length;t++){const i=r[t],s=e[t],n=document.createElement("link");n.rel="stylesheet",n.href=URL.createObjectURL(i),s.replaceWith(n)}}const c=a.querySelectorAll("[hasstyle]");for(let e=0;e<o.length;e++){const t=o[e],i=c[e];i.removeAttribute("hasstyle");const s=t.split(";").map(e=>e.trim()).filter(e=>e);if(i.style)for(let e of s){const t=e.split(":");i.style[t[0].trim()]=t[1].trim()}}for(let e of a.querySelectorAll("script")){const t=document.createElement("script");e.textContent&&(i&&!e.src?(t.src=URL.createObjectURL(new Blob([e.textContent],{type:"text/javascript"})),t.addEventListener("load",()=>URL.revokeObjectURL(t.src))):t.textContent=e.textContent);for(let i of e.attributes)t.setAttribute(i.name,i.value);e.replaceWith(t)}let l=new DocumentFragment;return l.append(...a.childNodes),1===l.childNodes.length?l.firstChild:l},Kt=e=>e&&"object"==typeof e&&"function"==typeof e.then,Xt=(async()=>{})().constructor;class Qt extends Xt{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,Kt(e)?t=e:"function"==typeof e&&(t=new Xt(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(Kt(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}const Jt="undefined"!=typeof navigator&&((e,t)=>{const i=null===(e=navigator)||void 0===e?void 0:e.userAgent,s=null===(t=navigator)||void 0===t?void 0:t.platform,n=i&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(i);return s&&/Win|Mac|Linux/i.test(s)&&!n})(),ei="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(Gt=window)&&void 0!==Gt&&Gt.MSStream),ti="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent)&&/Firefox/i.test(navigator.userAgent),ii="undefined"!=typeof navigator&&((e,t)=>{const i=navigator.standalone||(null===(e=(t=window).matchMedia)||void 0===e||null===(e=e.call(t,"(display-mode: standalone)"))||void 0===e?void 0:e.matches);return ei&&i})(),si=Jt?{width:1920,height:1080}:{width:1280,height:720},ni=function(){const e=this,t=MediaDeviceInfo.prototype.toJSON.apply(e);return t.trackLabel=e.trackLabel,t.capabilities=e.capabilities,t.isFront=e.isFront,t},ri="The camera feature is available only in secure contexts (HTTPS).";let oi=class e{constructor(){qt(this,"_coreShell",void 0),qt(this,"_video",void 0),qt(this,"_coreInnerLayer",void 0),qt(this,"_coreOuterLayer",void 0),qt(this,"_regionBoxWrapper",void 0),qt(this,"_regionBoxMask",void 0),qt(this,"_regionBoxBorder",void 0),qt(this,"_objectFit","contain"),qt(this,"_uiInlineScript2Blob",!0),qt(this,"_uiInternalCss2Blob",!0),qt(this,"_uiInternalCss2ExistedSheet",!1),qt(this,"_ui",void 0),qt(this,"_pOpen",void 0),qt(this,"_getUserMediaTimeout",1e4),qt(this,"_paused",!1),qt(this,"_shouldClose",!1),qt(this,"_cameraChangedWhenPaused",!1),qt(this,"_requestedCamera","back"),qt(this,"_requestedResolution",si),qt(this,"_regionBox",{unit:"view-size",center:{x:0,y:0},maskStyle:{background:"rgba(0, 0, 0, 0.5)"},borderStyle:{border:"1px solid #00ff7f"}}),qt(this,"_eventListeners",{}),qt(this,"_taskIdIOSResizeProblem",void 0),qt(this,"onOpened",void 0);const t=this._coreShell=document.createElement("div");Object.assign(t.style,{width:"100%",height:"100%",minWidth:"100px",minHeight:"100px",backgroundColor:"black",display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",position:"relative"});const i=this._coreOuterLayer=document.createElement("div");Object.assign(i.style,{width:"auto",height:"100%",minWidth:"100px",minHeight:"100px",aspectRatio:"1",flex:"none",position:"relative",overflow:"hidden"});const s=this._coreInnerLayer=document.createElement("div");Object.assign(s.style,{width:"100%",height:"100%",position:"relative",transformOrigin:"center"});const n=this._video=document.createElement("video");Object.assign(n.style,{width:"100%",height:"100%",position:"absolute",left:"0",top:"0",objectFit:"fill"}),n.muted=!0,n.playsInline=!0,n.addEventListener("resize",()=>{try{this._updateObjectFit()}catch(e){console.error(e)}try{this._updateCanvasSize()}catch(e){console.error(e)}}),s.append(n),i.append(s),t.append(i),"undefined"!=typeof ResizeObserver&&new ResizeObserver(()=>{var e;if(!t.isConnected)return;this._updateObjectFit();const i=null===(e=navigator)||void 0===e?void 0:e.userAgent;if(i&&/iPhone|iPad/i.test(i)){this._taskIdIOSResizeProblem&&clearInterval(this._taskIdIOSResizeProblem);let e=0;this._taskIdIOSResizeProblem=setInterval(()=>{if(++e>10||!t.isConnected)return clearInterval(this._taskIdIOSResizeProblem),void(this._taskIdIOSResizeProblem=null);this._updateObjectFit()},100)}}).observe(t);for(let t of e._arrConstructors)t.call(this)}_updateObjectFit(){var e;const t=this._video;if(!t.isConnected||!t.videoWidth||!t.videoHeight)return;const i=this._coreOuterLayer.style,s=null===(e=this._regionBoxWrapper)||void 0===e?void 0:e.style;if("fill"===this._objectFit||void 0===i.aspectRatio)return"100%"!==i.width&&(i.width="100%"),"100%"!==i.height&&(i.height="100%"),void(s&&("100%"!==s.width&&(s.width="100%"),"100%"!==s.height&&(s.height="100%")));const{width:n,height:r}=this._coreShell.getBoundingClientRect(),o=`${t.videoWidth} / ${t.videoHeight}`;o!=i.aspectRatio&&(i.aspectRatio=o),s&&o!=s.aspectRatio&&(s.aspectRatio=o);const a=n/r-t.videoWidth/t.videoHeight;if(Math.abs(a)<.001)return;let c=!1;a>0&&(c=!c),"cover"===this._objectFit&&(c=!c);const l=s&&"contain"===this._objectFit,d=s&&"cover"===this._objectFit;c?("auto"!=i.width&&(i.width="auto"),"100%"!=i.height&&(i.height="100%"),l&&("auto"!=s.width&&(s.width="auto"),"100%"!=s.height&&(s.height="100%"))):("100%"!=i.width&&(i.width="100%"),"auto"!=i.height&&(i.height="auto"),l&&("100%"!=s.width&&(s.width="100%"),"auto"!=s.height&&(s.height="auto"))),d&&("100%"!==s.width&&(s.width="100%"),"100%"!==s.height&&(s.height="100%"))}get video(){return this._video}get track(){var e;return null===(e=this._video)||void 0===e||null===(e=e.srcObject)||void 0===e?void 0:e.getTracks().filter(e=>"video"===e.kind)[0]}get objectFit(){return this._objectFit}set objectFit(e){this._objectFit=e,this._updateObjectFit()}get ui(){return this._ui||this._coreShell}set ui(e){if(!e)return void(this._ui=void 0);if(e instanceof HTMLElement&&e.contains(this._coreShell))return void(this._ui=e);if("string"==typeof e){if(!e.trim().startsWith("<"))throw Error("Invalid html string.");e=zt(e,{inlineScript2Blob:this._uiInlineScript2Blob,internalCss2Blob:this._uiInternalCss2Blob,insertInternalCss2ExistedSheet:this._uiInternalCss2ExistedSheet})}let t;if(e instanceof HTMLElement)t=e;else{if(!(e instanceof DocumentFragment))throw Error("Seems no HTMLElement.");t=document.createElement("div"),Object.assign(t.style,{width:"100%",height:"100%"}),t.append(e)}const i="dm-camera-core-container",s=t.classList.contains(i)?t:t.querySelector(`.${i}`);if(!s)throw Error(`Can't find element with class \`${i}\`.`);this._ui=t;for(let e of t.querySelectorAll("script"))e.currentDMCamera=this;s.append(this._coreShell)}get status(){var e;return this._pOpen?this._pOpen.isPending?this._shouldClose?"closing":"opening":this._paused||this._video.paused||"ended"===(null===(e=this.track)||void 0===e?void 0:e.readyState)?"paused":"opened":"closed"}get requestedCamera(){return JSON.parse(JSON.stringify(this._requestedCamera))}get requestedResolution(){return JSON.parse(JSON.stringify(this._requestedResolution))}get currentCamera(){var t,i;return"opened"!==this.status&&"paused"!==this.status?null:null===(t=e._mapDeviceInfo)||void 0===t?void 0:t[null===(i=this.track)||void 0===i||null===(i=i.getSettings())||void 0===i?void 0:i.deviceId]}get currentResolution(){var e,t;return{width:null===(e=this.video)||void 0===e?void 0:e.videoWidth,height:null===(t=this.video)||void 0===t?void 0:t.videoHeight}}get regionBox(){return this._regionBox}static async hasCamera(){var t;return!(null===(t=navigator)||void 0===t||!t.mediaDevices)&&!!(await e.getDeviceInfos()).length}static async hasMacroCamera(){var t;return!(null===(t=navigator)||void 0===t||!t.mediaDevices)&&!!(await e.getDeviceInfos()).find(e=>{var t;return!e.isFront&&(null===(t=e.capabilities)||void 0===t||null===(t=t.focusDistance)||void 0===t?void 0:t.min)<.061})}static async hasFrontCamera(){var t;return!(null===(t=navigator)||void 0===t||!t.mediaDevices)&&!!(await e.getDeviceInfos()).find(e=>e.isFront)}static async getDeviceInfos(){var t;if(null===(t=navigator)||void 0===t||!t.mediaDevices)throw Error(ri);e._delayBeforeEnumerateDevices&&await new Promise(t=>setTimeout(t,e._delayBeforeEnumerateDevices));let i=(await navigator.mediaDevices.enumerateDevices()).filter(e=>"videoinput"===e.kind);if(!i.length)return[];if(i.some(e=>!e.deviceId)){let t;try{e._delayBeforeGetUserMedia&&await new Promise(t=>setTimeout(t,e._delayBeforeGetUserMedia)),t=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1}),e._delayBeforeEnumerateDevices&&await new Promise(t=>setTimeout(t,e._delayBeforeEnumerateDevices)),i=(await navigator.mediaDevices.enumerateDevices()).filter(e=>"videoinput"===e.kind),i.some(e=>!e.deviceId)&&console.warn("Some camera does not have deviceId.")}catch(i){console.warn("Failed to get device ID by opening camera.",i)}if(t){var s;const e=t.getTracks().filter(e=>"video"===e.kind)[0],n=e.getSettings().deviceId;let r=i.find(e=>e.deviceId===n);r?(r.trackLabel=e.label,r.capabilities=null===(s=e.getCapabilities)||void 0===s?void 0:s.call(e),r.isFront="user"===e.getSettings().facingMode,r.toJSON=ni):console.warn("Can't find current device by `track.getSettings().deviceId`."),t.getTracks().forEach(e=>e.stop())}}await e._setCapabilities(i);const n=i.reduce((e,t)=>(e[t.deviceId]=t,e),{});return e._mapDeviceInfo=n,[...i]}static async _setCapabilities(t){for(let n of t){var i;if(!n.deviceId)continue;if(ni===n.toJSON)continue;let r=null===(i=e._mapDeviceInfo)||void 0===i?void 0:i[n.deviceId];if(r)n.trackLabel=r.trackLabel,n.capabilities=r.capabilities,n.isFront=r.isFront;else try{var s;e._delayBeforeGetUserMedia&&await new Promise(t=>setTimeout(t,e._delayBeforeGetUserMedia));const t=await navigator.mediaDevices.getUserMedia({video:{deviceId:{exact:n.deviceId}},audio:!1}),i=t.getTracks().filter(e=>"video"===e.kind)[0];n.trackLabel=i.label,n.capabilities=null===(s=i.getCapabilities)||void 0===s?void 0:s.call(i),n.isFront="user"===i.getSettings().facingMode,t.getTracks().forEach(e=>e.stop())}catch(t){console.warn("Failed to get `trackLabel` and `capabilities`, by opening camera.",t)}n.toJSON=ni}}async open(){if("opened"!==this.status)if("closed"===this.status||"paused"===this.status)try{if("paused"===this.status&&this._cameraChangedWhenPaused&&await this.close(),"closed"===this.status){if(this._pOpen=new Qt,"customized-video"!==this._requestedCamera){var t;let s;if("string"==typeof this._requestedCamera){switch(this._requestedCamera){case"front":s={facingMode:"user"};break;case"quick-back":s={facingMode:"environment"};break;case"back":{const t=await e.getDeviceInfos();if(!t.length)throw Error("No camera found.");for(let n of e._cameraNameMatcher){for(let e of t){var i;const t=null===(i=e.trackLabel||e.label)||void 0===i?void 0:i.toLowerCase();for(let i of n)if(t.includes(i)){s={deviceId:e.deviceId};break}if(s)break}if(s)break}if(s)break;t.reverse();for(let e of t)if(!e.isFront){s={deviceId:e.deviceId};break}if(s)break;s={deviceId:t[0].deviceId};break}case"macro-back":{const t=await e.getDeviceInfos();if(!t.length)throw Error("No camera found.");const i=t.reduce((e,t)=>{var i,s,n;return null!=t&&t.isFront?e:e&&null!=e&&null!==(i=e.capabilities)&&void 0!==i&&null!==(i=i.focusDistance)&&void 0!==i&&i.min?(null==t||null===(s=t.capabilities)||void 0===s||null===(s=s.focusDistance)||void 0===s?void 0:s.min)<(null==e||null===(n=e.capabilities)||void 0===n||null===(n=n.focusDistance)||void 0===n?void 0:n.min)?t:e:t});s={deviceId:(null==i?void 0:i.deviceId)||t[t.length-1].deviceId};break}default:throw Error(`Unknown camera preset: ${this._requestedCamera}`)}this._requestedCamera=s}else s=this._requestedCamera;const n={video:Object.assign({},s,this._requestedResolution),audio:!1};if(null===(t=navigator)||void 0===t||!t.mediaDevices)throw Error(ri);e._delayBeforeGetUserMedia&&await new Promise(t=>setTimeout(t,e._delayBeforeGetUserMedia));const r=navigator.mediaDevices.getUserMedia(n),o=await(this._getUserMediaTimeout?Promise.race([r,new Promise((e,t)=>setTimeout(()=>t(Error("Camera open timeout.")),this._getUserMediaTimeout))]):r);if("closing"===this.status)throw Error("Camera closed.");this._video.srcObject=o}else{await this._video.play();let e=0;for(;++e<100&&!(this.video.readyState>=HTMLMediaElement.HAVE_ENOUGH_DATA);)await new Promise(e=>setTimeout(e,100))}if(ii&&"customized-video"!==this._requestedCamera){this._noUseButWorkaroundIosPwaProblem=this._video.offsetHeight,await new Promise(e=>{let t=!1,i=()=>{this._video.removeEventListener("loadedmetadata",i),t=!0,e()};this._video.addEventListener("loadedmetadata",i),setTimeout(()=>{t||(console.warn("video loadedmetadata timeout"),i())},1e3)});let t=!1;if(await Promise.race([this.video.play().then(()=>{t=!0}),new Promise(i=>setTimeout(()=>{t||i()},e._videoPlayTimeout))]),!t)throw Error("`video.play()` unresponsive in current iOS PWA environment. Please use `singleFrameMode='camera'` instead.")}else{let t=!1;await Promise.race([this.video.play(),(async()=>{if(await new Promise(t=>setTimeout(t,e._videoPlayTimeout)),!t)throw Error("video play timeout")})()]),t=!0}if("closing"===this.status)throw Error("Camera closed.");if(this.track){const t=this.track.getSettings();let i=0;for(;++i<e._countEnsureResolution&&!(t.width===this.video.videoWidth&&t.height===this.video.videoHeight||t.height===this.video.videoWidth&&t.width===this.video.videoHeight);)await new Promise(e=>setTimeout(e,100))}if("closing"===this.status)throw Error("Camera closed.");this._pOpen.resolve()}else{if(this._pOpen=new Qt,await this._video.play(),"closing"===this.status)throw Error("Camera closed.");this._paused=!1,this._pOpen.resolve()}for(let t of e._arrOnOpen)t.call(this);this._callOpenedListeners()}catch(e){var s,n;let t=null===(s=this._video)||void 0===s||null===(s=s.srcObject)||void 0===s||null===(n=s.getTracks)||void 0===n?void 0:n.call(s);if(t)for(let e of t)null==e||e.stop();this._video.srcObject=null;const i=this._pOpen;this._pOpen=null,this._shouldClose=!1,i.catch(e=>{}),i.reject();const r=Error(`Error opening camera: ${null==e?void 0:e.message}`,{cause:e});throw r.name=e.name,r}else{if("opening"!==this.status&&"closing"!==this.status)throw Error("Never");await this._pOpen}}async pause(){try{await this._pOpen}catch(e){}"opened"===this.status&&(this._video.pause(),this._paused=!0)}async close(){var t,i,s;for(let t of e._arrBeforeClose)t.call(this);if("closed"===this.status)return;if("opening"===this.status&&(this._shouldClose=!0),"closing"===this.status){try{await this._pOpen}catch(n){}return}let n=null===(t=this._video)||void 0===t||null===(t=t.srcObject)||void 0===t||null===(i=t.getTracks)||void 0===i?void 0:i.call(t);if(n)for(let e of n)null==e||e.stop();this._video&&(this._video.srcObject=null),this._pOpen=null,this._paused=!1,this._cameraChangedWhenPaused=!1;for(let t of e._arrOnClose)t.call(this);this._regionBoxWrapper&&(this._regionBoxWrapper.style.visibility="hidden"),null===(s=this._eventListeners.closed)||void 0===s||s.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}})}async requestCamera(e){if("string"==typeof e)ai.includes(e)?this._requestedCamera=e:this._requestedCamera={deviceId:{exact:e}};else if(e)if("videoinput"===e.kind)e.deviceId?this._requestedCamera={deviceId:{exact:e.deviceId}}:this._requestedCamera="back";else{const t=this._requestedCamera=JSON.parse(JSON.stringify(e));if(t.width||t.height||t.aspectRatio){const e=this._requestedResolution={};t.width&&(e.width=t.width,delete t.width),t.height&&(e.height=t.height,delete t.height),t.aspectRatio&&(e.aspectRatio=t.aspectRatio,delete t.aspectRatio)}}else null===e?this._requestedCamera=null:void 0===e&&(this._requestedCamera="back");"opened"===this.status?(await this.close(),await this.open()):"paused"===this.status&&(this._cameraChangedWhenPaused=!0)}async requestResolution(t,i){let s={};if("number"==typeof t?(s.width=t,"number"==typeof i&&(s.height=i)):Array.isArray(t)?(t[0]&&(s.width=t[0]),t[1]&&(s.height=t[1])):t?((t=JSON.parse(JSON.stringify(t))).width&&(s.width=t.width),t.height&&(s.height=t.height),t.aspectRatio&&(s.aspectRatio=t.aspectRatio)):null===t?s=null:void 0===t&&(s=si),this._requestedResolution=s,"opened"===this.status)if(e._bReopenWhenChangeResolution)await this.close(),await this.open();else{e._delayBeforeApplyConstraints&&await new Promise(t=>setTimeout(t,e._delayBeforeApplyConstraints)),await this.track.applyConstraints({...this._requestedCamera,...s});const t=this.track.getSettings();let i=0;for(;++i<e._countEnsureResolution&&!(t.width===this.video.videoWidth&&t.height===this.video.videoHeight||t.height===this.video.videoWidth&&t.width===this.video.videoHeight);)await new Promise(e=>setTimeout(e,100));this._callOpenedListeners()}else"paused"===this.status&&(e._bReopenWhenChangeResolution?this._cameraChangedWhenPaused=!0:(e._delayBeforeApplyConstraints&&await new Promise(t=>setTimeout(t,e._delayBeforeApplyConstraints)),await this.track.applyConstraints({...this._requestedCamera,...s})))}async applyConstraints(e){this.track&&"customized-video"!==this._requestedCamera&&(null!=e||(e={}),await this.track.applyConstraints({...this._requestedCamera,...this._requestedResolution,...e}))}getFrame(e){if("opened"!==this.status&&"paused"!==this.status)throw Error("Camera not open");let{x:t=0,y:i=0,width:s=this._video.videoWidth,height:n=this._video.videoHeight,reusedContext:r}=e||{};s=Math.round(s+t)-Math.round(t),n=Math.round(n+i)-Math.round(i),t=Math.round(t),i=Math.round(i);const o=(null==r?void 0:r.canvas)||document.createElement("canvas");return o.width!=s&&(o.width=s),o.height!=n&&(o.height=n),(r||o.getContext("2d")).drawImage(this._video,t,i,s,n,0,0,s,n),o}setRegionBox(e){if(!(e=Object.assign(this._regionBox,e)).width||!e.height){var t;if(!e.innerUi)return null!==(t=this._regionBoxWrapper)&&void 0!==t&&t.remove(),this._regionBoxWrapper=null,this._regionBoxMask=null,void(this._regionBoxBorder=null);Object.assign(e,{width:1,height:1,unit:"view-size",center:{x:0,y:0}})}this._regionBoxWrapper||(this._regionBoxWrapper=document.createElement("div"),Object.assign(this._regionBoxWrapper.style,{width:"auto",height:"100%",maxWidth:"100%",maxHeight:"100%",minWidth:"100px",minHeight:"100px",aspectRatio:"1",flex:"none",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",containerType:"size",visibility:"opened"===this.status?"":"hidden"}),this._regionBoxMask=document.createElement("div"),Object.assign(this._regionBoxMask.style,{width:"100%",height:"100%",flex:"none"}),this._regionBoxWrapper.append(this._regionBoxMask),this._regionBoxBorder=document.createElement("div"),Object.assign(this._regionBoxBorder.style,{flex:"none",boxSizing:"content-box",position:"absolute",transform:"translate(-50%,-50%)"}),this._regionBoxWrapper.append(this._regionBoxBorder),this._coreShell.append(this._regionBoxWrapper)),"string"==typeof e.innerUi&&(e.innerUi=zt(e.innerUi)),e.innerUi instanceof DocumentFragment?(this._regionBoxBorder.textContent="",this._regionBoxBorder.append(e.innerUi),e.innerUi=this._regionBoxBorder.childNodes):e.innerUi instanceof Node?1==this._regionBoxBorder.childNodes.length&&this._regionBoxBorder.firstChild==e.innerUi||(this._regionBoxBorder.textContent="",this._regionBoxBorder.append(e.innerUi)):e.innerUi instanceof NodeList?this._regionBoxBorder.childNodes!==e.innerUi&&(this._regionBoxBorder.textContent="",this._regionBoxBorder.append(...e.innerUi),e.innerUi=this._regionBoxBorder.childNodes):e.innerUi instanceof Array?(this._regionBoxBorder.textContent="",this._regionBoxBorder.append(...e.innerUi),e.innerUi=this._regionBoxBorder.childNodes):this._regionBoxBorder.textContent="";let i=100*e.center.y-50*e.height+50+"%",s=100*e.center.x+50*e.width+50+"%",n=100*e.center.y+50*e.height+50+"%",r=100*e.center.x-50*e.width+50+"%";Object.assign(this._regionBoxMask.style,{clipPath:`polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, ${r} ${i}, ${r} ${n}, ${s} ${n}, ${s} ${i}, ${r} ${i})`}),"view-min"===e.unit&&(i=`calc(${100*e.center.y+50}% + max(-${50*e.height}cqmin, -${50*e.height}cqmax))`,s=`calc(${100*e.center.x+50}% + ${50*e.width}cqmin)`,n=`calc(${100*e.center.y+50}% + ${50*e.height}cqmin)`,r=`calc(${100*e.center.x+50}% + max(-${50*e.width}cqmin, -${50*e.width}cqmax))`,Object.assign(this._regionBoxMask.style,{clipPath:`polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, ${r} ${i}, ${r} ${n}, ${s} ${n}, ${s} ${i}, ${r} ${i})`})),Object.assign(this._regionBoxMask.style,{...e.maskStyle}),Object.assign(this._regionBoxBorder.style,{width:100*e.width+"%",height:100*e.height+"%"}),"view-min"===e.unit&&Object.assign(this._regionBoxBorder.style,{width:100*e.width+"cqmin",height:100*e.height+"cqmin"}),Object.assign(this._regionBoxBorder.style,{top:100*e.center.y+50+"%",left:100*e.center.x+50+"%",...e.borderStyle}),"view-size"===e.unit&&1===e.width&&1===e.height&&(this._regionBoxBorder.style.borderWidth="0"),this._updateObjectFit()}addCanvas(){const e=document.createElement("canvas");return Object.assign(e.style,{position:"absolute",left:0,top:0,width:"100%",height:"100%"}),"opened"!==this.status&&"paused"!==this.status||(e.width=this._video.videoWidth,e.height=this._video.videoHeight),this._video.parentElement.append(e),e}_updateCanvasSize(){const e=this._video;e.videoWidth&&e.videoHeight&&this._video.parentElement.querySelectorAll("canvas").forEach(t=>{t.width!==e.videoWidth&&(t.width=e.videoWidth),t.height!==e.videoHeight&&(t.height=e.videoHeight)})}addEventListener(e,t){var i,s;(null!==(s=(i=this._eventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)}removeEventListener(e,t){var i;null===(i=this._eventListeners[e])||void 0===i||i.delete(t)}_callOpenedListeners(){var e;try{var t;null===(t=this.onOpened)||void 0===t||t.call(this,this)}catch(e){console.error(e)}this._regionBoxWrapper&&(this._regionBoxWrapper.style.visibility=""),null===(e=this._eventListeners.opened)||void 0===e||e.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}})}videoXY2AbsoluteLT(e){const t=this._video,i=t.getBoundingClientRect(),s=getComputedStyle(document.body);if("static"===s.position){const s=document.documentElement.getBoundingClientRect();return e.map(e=>({left:(this._isMirrored?t.videoWidth-e.x:e.x)/t.videoWidth*i.width+i.x-s.x,top:e.y/t.videoHeight*i.height+i.y-s.y}))}{const n=document.body.getBoundingClientRect(),r=parseFloat(s.borderLeftWidth),o=parseFloat(s.borderTopWidth);return e.map(e=>({left:(this._isMirrored?t.videoWidth-e.x:e.x)/t.videoWidth*i.width+i.x-n.x-r,top:e.y/t.videoHeight*i.height+i.y-n.y-o}))}}videoXY2FixedLT(e){const t=this._video,i=t.getBoundingClientRect();return e.map(e=>({left:(this._isMirrored?t.videoWidth-e.x:e.x)/t.videoWidth*i.width+i.x,top:e.y/t.videoHeight*i.height+i.y}))}getVisibleAreaInVideoXY(e){const{isConsiderRegionBox:t=!1,rounded:i=!1}=e||{};let s;if(t&&this._regionBoxBorder){const e=this._regionBoxBorder.getBoundingClientRect();s={x:e.x,y:e.y,width:e.width,height:e.height};const t=getComputedStyle(this._regionBoxBorder),i=parseFloat(t.borderLeftWidth),n=parseFloat(t.borderTopWidth),r=parseFloat(t.borderRightWidth),o=parseFloat(t.borderBottomWidth);s.x+=i,s.y+=n,s.width-=i+r,s.height-=n+o}else{const e=this._coreShell.getBoundingClientRect();s={x:e.x,y:e.y,width:e.width,height:e.height}}const n=this._video.getBoundingClientRect(),r={x:(s.x-n.x)/n.width,y:(s.y-n.y)/n.height,width:s.width/n.width,height:s.height/n.height};r.x<0&&(r.width+=r.x,r.x=0),r.x>1&&(r.width-=r.x-1,r.x=1),r.y<0&&(r.height+=r.y,r.y=0),r.y>1&&(r.height-=r.y-1,r.y=1),r.x+r.width>1&&(r.width=1-r.x),r.x+r.width<0&&(r.width=-r.x),r.y+r.height>1&&(r.height=1-r.y),r.y+r.height<0&&(r.height=-r.y);const o=this._video.videoWidth,a=this._video.videoHeight;let c=(this._isMirrored?1-r.x-r.width:r.x)*o,l=r.y*a,d=r.width*o,u=r.height*a;return i&&(d=Math.round(d+c)-Math.round(c),u=Math.round(u+l)-Math.round(l),c=Math.round(c),l=Math.round(l)),{x:c,y:l,width:d,height:u}}};qt(oi,"_cameraNameMatcher",[["트리플","三镜头","三鏡頭","トリプル","สาม","ट्रिपल","ثلاثية","משולשת","үштік","тройная","тройна","потроєна","τριπλή","üçlü","trójobiektywowy","trostruka","trojný","trojitá","trippelt","trippel","triplă","triple","tripla","tiga","kolmois","ba camera"],["듀얼 와이드","雙廣角","双广角","デュアル広角","คู่ด้านหลังมุมกว้าง","ड्युअल वाइड","مزدوجة عريضة","כפולה רחבה","қос кең бұрышты","здвоєна ширококутна","двойная широкоугольная","двойна широкоъгълна","διπλή ευρεία","çift geniş","laajakulmainen kaksois","kép rộng mặt sau","kettős, széles látószögű","grande angular dupla","ganda","dwuobiektywowy","dwikamera","dvostruka široka","duální širokoúhlý","duálna širokouhlá","dupla grande-angular","dublă","dubbel vidvinkel","dual-weitwinkel","dual wide","dual con gran angular","dual","double","doppia con grandangolo","doble","dobbelt vidvinkelkamera"],["camera2 0,"],["camera 0,"],["후","背面","背置","後面","後置","后面","后置","านหลัง","หลัง","बैक","خلفية","אחורית","задняя","задня","задней","задна","πίσω","zadní","zadná","tylny","trás","trasera","traseira","taka","stražnja","spate","sau","rück","rear","posteriore","posterior","hátsó","darrere","belakang","baksidan","bakre","bak","bagside","back","aртқы","arrière","arka","achterzijde"]]),qt(oi,"_mapDeviceInfo",void 0),qt(oi,"_delayBeforeEnumerateDevices",0),qt(oi,"_delayBeforeGetUserMedia",ti?1e3:0),qt(oi,"_delayBeforeApplyConstraints",0),qt(oi,"_countEnsureResolution",ti?20:10),qt(oi,"_videoPlayTimeout",3e3),qt(oi,"_bReopenWhenChangeResolution",ei),qt(oi,"_arrConstructors",[]),qt(oi,"_arrOnOpen",[]),qt(oi,"_arrBeforeClose",[]),qt(oi,"_arrOnClose",[]);const ai=["back","front","macro-back","quick-back","customized-video"];oi.prototype.correctAdvancedConstraint=function(e){e=JSON.parse(JSON.stringify(e));const{advanced:t}=e||{};if(null==t||!t.length)return e;const i=this;for(const e of t)for(const t in e){let n=e[t];if("number"==typeof n){var s;const r=null===(s=i.currentCamera)||void 0===s||null===(s=s.capabilities)||void 0===s?void 0:s[t],{min:o,step:a,max:c}=r||{};null!=o&&n<o?n=o:null!=c&&n>c&&(n=c),null!=a&&null!=o&&(n=o+Math.round((n-o)/a)*a,c&&n>c&&(n-=a)),e[t]=n}}return e},oi._arrConstructors.push(function(){const e=this;e._softZoom={zoom:1,center:{x:0,y:0}},e.maxZoom4GestureWheel=20,e._lastZoomTime=-1/0,e._mapZoomTouchs=new Map,e.enableGestureZoom=!0,e.enableWheelZoom=!1}),Object.defineProperty(oi.prototype,"softZoom",{get(){return this._softZoom}}),Object.defineProperty(oi.prototype,"isMirrored",{get(){return this._isMirrored},set(e){const t=this;t._isMirrored=e,t.setSoftZoom(t.softZoom.zoom,{center:t.softZoom.center})}}),Object.defineProperty(oi.prototype,"enableGestureZoom",{get(){return!!this._gestureZoomListener},set(e){const t=this;e?t._gestureZoomListener||(t._gestureZoomListener=e=>{t._changeZoomByTouch(e)},t._coreShell.addEventListener("touchstart",t._gestureZoomListener),t._coreShell.addEventListener("touchmove",t._gestureZoomListener),t._coreShell.addEventListener("touchend",t._gestureZoomListener),t._coreShell.addEventListener("touchcancel",t._gestureZoomListener)):t._gestureZoomListener&&(t._coreShell.removeEventListener("touchstart",t._gestureZoomListener),t._coreShell.removeEventListener("touchmove",t._gestureZoomListener),t._coreShell.removeEventListener("touchend",t._gestureZoomListener),t._coreShell.removeEventListener("touchcancel",t._gestureZoomListener),t._gestureZoomListener=null)}}),Object.defineProperty(oi.prototype,"enableWheelZoom",{get(){return!!this._wheelZoomListener},set(e){const t=this;e?t._wheelZoomListener||(t._wheelZoomListener=e=>{t._changeZoomByWheel(e)},t._coreShell.addEventListener("wheel",t._wheelZoomListener)):t._wheelZoomListener&&(t._coreShell.removeEventListener("wheel",t._wheelZoomListener),t._wheelZoomListener=null)}}),oi.prototype.getZoomRange=function(){var e,t;if("opened"!==this.status)throw Error("Camera not open");return null===(e=(t=this.track).getCapabilities)||void 0===e||null===(e=e.call(t))||void 0===e?void 0:e.zoom},oi.prototype.setZoom=async function(e){const t=this;if("opened"!==t.status)throw Error("Camera not open");oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await t.applyConstraints(t.correctAdvancedConstraint(t.correctAdvancedConstraint({advanced:[{zoom:e}]})))},oi.prototype.setSoftZoom=function(e,t){const i=this;let{center:s,limit:n}=t||{},{x:r=0,y:o=0}=s||{};n&&e<1&&(e=1);let a=i._isMirrored?`scale(${-e},${e})`:`scale(${e})`;if(s){if(n){const t=.5-.5/e;r<-t?r=-t:r>t&&(r=t),o<-t?o=-t:o>t&&(o=t)}a+=` translate(${r*=-100}%, ${o*=-100}%)`}i._softZoom={zoom:e,center:{x:r,y:o}},i._coreInnerLayer.style.transform=a},oi.prototype._changeZoomByWheel=function(e){var t;const i=this,s=Date.now();let n=i._softZoom.zoom,r=n-e.deltaY/200;r>i.maxZoom4GestureWheel&&(r=i.maxZoom4GestureWheel),r<1&&(r=1),r!==n&&(i.setSoftZoom(r,{center:i._softZoom.center,limit:!0}),i._lastZoomTime=s,e.preventDefault(),null===(t=i._eventListeners.zoom)||void 0===t||t.forEach(e=>{try{e.call(i,JSON.parse(JSON.stringify(i._softZoom)))}catch(e){console.error(e)}}))},oi.prototype._changeZoomByTouch=function(e){const t=this;for(e.touches.length>=2&&"touchmove"==e.type&&e.preventDefault();e.changedTouches.length>1&&2==e.touches.length;){var i;let s=Date.now();if(s-t._lastZoomTime<100)return;let n=e.touches[0],r=e.touches[1],o=t._mapZoomTouchs.get(n.identifier),a=t._mapZoomTouchs.get(r.identifier);if(!o||!a)break;let c=Math.pow(Math.pow(o.x-a.x,2)+Math.pow(o.y-a.y,2),.5),l=Math.pow(Math.pow(n.clientX-r.clientX,2)+Math.pow(n.clientY-r.clientY,2),.5),d=t._softZoom.zoom;d*=l/c,d>t.maxZoom4GestureWheel&&(d=t.maxZoom4GestureWheel),d<1&&(d=1),t.setSoftZoom(d,{center:t._softZoom.center,limit:!0}),t._lastZoomTime=s,null===(i=t._eventListeners.zoom)||void 0===i||i.forEach(e=>{try{e.call(t,JSON.parse(JSON.stringify(t._softZoom)))}catch(e){console.error(e)}});break}t._mapZoomTouchs.clear();for(let i of e.touches)t._mapZoomTouchs.set(i.identifier,{x:i.clientX,y:i.clientY})},oi._arrConstructors.push(function(){const e=this;e._isFocusing=!1,e._advancedFocusParameters={minFocusDistanceLimit:.01,maxFocusDistanceLimit:10,firstStepWaitDuration:500,coarseStepWaitDuration:350,switchStepWaitDuration:400,fineStepWaitDuration:350,maxStepCount:30,backToContinousDuration:5e3,focusWH:.2,coarseTuneRate:.5,coarseTuneTolerance:.5,fineTuneRate:1.1},e._advancedFocusTaskId=0,e.enableTapToFocus="simple"}),oi._getImageContrast=(e,t,i)=>{let s=0;for(let n=0;n<i-1;n++)for(let i=0;i<t-1;i++){const r=4*(n*t+i),o=r+4,a=r+4*t,c=e[r]-e[o],l=e[r+1]-e[o+1],d=e[r+2]-e[o+2],u=e[r]-e[a],h=e[r+1]-e[a+1],_=e[r+2]-e[a+2];s+=c*c+l*l+d*d+u*u+h*h+_*_}return s},oi.prototype._simpleFocus=async function(){var e,t,i,s,n;const r=this;if("opened"!==r.status)throw Error("Camera not open");if(r._isFocusing)return;const o=null===(e=r.currentCamera)||void 0===e?void 0:e.capabilities;let a,c;if(null!=o&&null!==(t=o.focusMode)&&void 0!==t&&t.includes("manual"))if(null!=o&&null!==(i=o.focusMode)&&void 0!==i&&i.includes("continuous"))a="manual",c="continuous";else{var l;if(null==o||null===(l=o.focusMode)||void 0===l||!l.includes("single-shot"))return void r._advancedFocus();a="manual",c="single-shot"}else if(null!=o&&null!==(s=o.focusMode)&&void 0!==s&&s.includes("single-shot"))null!=o&&null!==(n=o.focusMode)&&void 0!==n&&n.includes("continuous")?(a="continuous",c="single-shot"):(a=null,c="single-shot");else{var d;if(null==o||null===(d=o.focusMode)||void 0===d||!d.includes("continuous"))return;a=null,c="continuous"}r._isFocusing=!0;try{var u;a&&("manual"===a?(oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await r.applyConstraints(r.correctAdvancedConstraint({advanced:[{focusMode:"manual",focusDistance:(null==o||null===(u=o.focusDistance)||void 0===u?void 0:u.max)||10}]}))):(oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await r.applyConstraints({advanced:[{focusMode:a}]})),await new Promise(e=>setTimeout(e,500))),oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await r.applyConstraints({advanced:[{focusMode:c}]}),await new Promise(e=>setTimeout(e,500))}catch(o){"opened"===r.status&&console.warn("Error while do simple focus",o)}r._isFocusing=!1},oi.prototype._advancedFocus=async function(e,t,i){var s,n,r,o;const a=this;if("opened"!==a.status)throw Error("Camera not open");if(a._isFocusing)return;const c=null===(s=a.currentCamera)||void 0===s?void 0:s.capabilities;if(null==c||null===(n=c.focusMode)||void 0===n||!n.includes("manual"))return void a._simpleFocus();const l=a._advancedFocusParameters,d=a._video.videoWidth,u=a._video.videoHeight;if(d<2||u<2)return;let h,_=0;e?(e.x=Math.round(e.x),e.y=Math.round(e.y),t||(t=Math.min(d,u)*l.focusWH),t<2&&(t=2),t>d&&(t=d),t=2*Math.round(t/2),i||(i=t),i<2&&(i=2),i>u&&(i=u),i=2*Math.round(i/2),e.x<t/2&&(e.x=t/2),e.x>d-t/2&&(e.x=d-t/2),e.y<i/2&&(e.y=i/2),e.y>u-i/2&&(e.y=u-i/2),_=e.x-t/2,h=e.y-i/2):(t=d,i=u),a._isFocusing=!0;const m=++a._advancedFocusTaskId;let g=null==c||null===(r=c.focusDistance)||void 0===r?void 0:r.min;(!g||g<l.minFocusDistanceLimit)&&(g=l.minFocusDistanceLimit);let f=null==c||null===(o=c.focusDistance)||void 0===o?void 0:o.max;(!f||f>l.maxFocusDistanceLimit)&&(f=l.maxFocusDistanceLimit);let p=-1/0,E=-1/0,y=1/0,I=f,v=!1,R=!0;const C=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});let T=0;try{for(;++T<l.maxStepCount;){let e;oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await a.applyConstraints(a.correctAdvancedConstraint({advanced:[{focusMode:"manual",focusDistance:I}]})),v?R?(R=!1,e=l.switchStepWaitDuration):e=l.fineStepWaitDuration:R?(R=!1,e=l.firstStepWaitDuration):e=l.coarseStepWaitDuration,await new Promise(t=>setTimeout(t,e)),a.getFrame({x:_,y:h,width:t,height:i,reusedContext:C});const s=C.getImageData(0,0,t,i).data,n=oi._getImageContrast(s,t,i);if(v){if(n<=p){oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await a.applyConstraints(a.correctAdvancedConstraint({advanced:[{focusMode:"manual",bestFocusDistance:y}]})),oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await a.applyConstraints(a.correctAdvancedConstraint({advanced:[{focusMode:"manual",bestFocusDistance:y}]}));break}if(f===I)break;p=n,n>E&&(E=n,y=I),I*=l.fineTuneRate,I>f&&(I=f)}else(n<=E*l.coarseTuneTolerance||g===I)&&(v=!0),p=n,n>E&&(E=n,y=I),v?(I=Math.sqrt(I*y),R=!0):(I*=l.coarseTuneRate,I<g&&(I=g))}}catch(e){"opened"===a.status&&console.warn("Error while do advanced focus",e)}a._isFocusing=!1,l.backToContinousDuration>0&&setTimeout(async()=>{if(a._advancedFocusTaskId===m){oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints));try{await a.applyConstraints({advanced:[{focusMode:"continuous"}]})}catch(e){}}},l.backToContinousDuration)},Object.defineProperty(oi.prototype,"enableTapToFocus",{get(){return this._enableTapToFocus},set(e){const t=this;t._enableTapToFocus=e,e?t._tapToFocusListner||(t._tapToFocusListner=async e=>{if(!("opened"!==t.status||!t._enableTapToFocus||!e.isPrimary||e.button||e.altKey||e.ctrlKey||e.shiftKey||e.metaKey||"touch"===e.pointerType&&t.enableGestureZoom&&(await new Promise(e=>setTimeout(e,300)),"opened"!==t.status||!t._enableTapToFocus||t._lastZoomTime>Date.now()-1e3||t._mapZoomTouchs.size>1)))if("experimental-advanced"===t._enableTapToFocus){const[{left:i,top:s},{left:n,top:r}]=t.videoXY2FixedLT([{x:0,y:0},{x:t._video.videoWidth,y:t._video.videoHeight}]);t._advancedFocus({x:(e.clientX-i)/(n-i)*t._video.videoWidth,y:(e.clientY-s)/(r-s)*t._video.videoHeight})}else t._simpleFocus()},t._coreShell.addEventListener("pointerdown",t._tapToFocusListner)):t._tapToFocusListner&&(t._coreShell.removeEventListener("pointerdown",t._tapToFocusListner),t._tapToFocusListner=null)}}),oi._arrConstructors.push(function(){this._isTorchOn=!1,this._autoTorchParameters={shortDelay:250,longDelay:1e3,shortLongDelaySwitchCount:10,grayThreshold:20,maxDarkCount:3}}),oi._arrOnClose.push(function(){this._isTorchOn=!1}),Object.defineProperty(oi.prototype,"isSupportTorch",{get(){var e,t;const i=null===(e=navigator)||void 0===e?void 0:e.userAgent;return i&&/iPhone/i.test(i)||!(null===(t=this.currentCamera)||void 0===t||null===(t=t.capabilities)||void 0===t||!t.torch)}}),Object.defineProperty(oi.prototype,"isTorchOn",{get(){var e,t;const i=this;return!1===(null===(e=i.track)||void 0===e||null===(t=e.getSettings)||void 0===t||null===(t=t.call(e))||void 0===t?void 0:t.torch)&&!0===i._isTorchOn&&(i._isTorchOn=!1,i.turnOffTorch()),i._isTorchOn}}),oi.prototype.turnOnTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints));try{await e.applyConstraints({advanced:[{torch:!0}]})}catch(t){throw e._isTorchOn=!1,t}e._isTorchOn=!0},oi.prototype.turnOffTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await e.applyConstraints({advanced:[{torch:!1}]}),e._isTorchOn=!1},oi.prototype.turnAutoTorch=function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");if(null==e._isTorchOn)return;e._isTorchOn=void 0;const t=e._autoTorchParameters,i=document.createElement("canvas"),s=i.getContext("2d",{willReadFrequently:!0});let n=0,r=0;(async()=>{for(;null==e._isTorchOn;){try{if("opened"!==e.status){e._isTorchOn=!1;break}e.getFrame({reusedContext:s})}catch(t){e._isTorchOn=!1;break}const a=s.getImageData(0,0,i.width,i.height).data;let c=0;for(let e=0;e<a.length;e+=4)c+=a[e]+a[e+1]+a[e+2];if(c/=a.length/4*3,c<t.grayThreshold&&++n>=t.maxDarkCount){try{var o;await e.turnOnTorch(),null===(o=e._eventListeners.torchAutoOn)||void 0===o||o.forEach(t=>{try{t.call(e)}catch(e){console.error(e)}})}catch(e){}break}await new Promise(e=>setTimeout(e,r<t.shortLongDelaySwitchCount?t.shortDelay:t.longDelay)),++r}})()};const ci="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(Wt=window)&&void 0!==Wt&&Wt.MSStream),li="undefined"!=typeof navigator&&/MiuiBrowser/.test(navigator.userAgent),di="undefined"!=typeof navigator&&/SamsungBrowser/.test(navigator.userAgent);let ui,hi;oi._arrConstructors.push(function(){this._shouldCloseWhenHide=!0,this._maxReopenTry4CloseWhenHide=4}),oi._arrOnOpen.push(function(){const e=this;e._shouldCloseWhenHide&&(e._closeWhenHideListener||(e._closeWhenHideListener=()=>{e._closeWhenHide()},document.addEventListener("visibilitychange",e._closeWhenHideListener),di&&window.addEventListener("blur",e._closeWhenHideListener)))}),oi._arrBeforeClose.push(function(){const e=this;e._closeWhenHideListener&&!e._isDuringCloseWhenHide&&(document.removeEventListener("visibilitychange",e._closeWhenHideListener),di&&window.removeEventListener("blur",e._closeWhenHideListener),e._closeWhenHideListener=null,e._isOpenBeforeHide=!1)}),Object.defineProperty(oi.prototype,"shouldCloseWhenHide",{get(){return this._shouldCloseWhenHide},set(e){const t=this;t._shouldCloseWhenHide=e,("opened"===t.status||"paused"===t.status&&!t._paused)&&(e?t._closeWhenHideListener||(t._closeWhenHideListener=()=>{t._closeWhenHide()},document.addEventListener("visibilitychange",t._closeWhenHideListener),di&&window.addEventListener("blur",t._closeWhenHideListener)):t._closeWhenHideListener&&(document.removeEventListener("visibilitychange",t._closeWhenHideListener),di&&window.removeEventListener("blur",t._closeWhenHideListener),t._closeWhenHideListener=null,t._isOpenBeforeHide=!1))}}),oi.prototype._closeWhenHide=async function(){var e;const t=this;if("hidden"===document.visibilityState)("opened"===t.status||"paused"===t.status&&!t._paused&&(ci&&"live"===(null===(e=t.track)||void 0===e?void 0:e.readyState)||li&&"customized-video"!==t.requestedCamera))&&(t._isDuringCloseWhenHide=!0,t._isOpenBeforeHide=!0,await t.close(),t._isDuringCloseWhenHide=!1);else{if(!t._isOpenBeforeHide)return;let e=0;for(;e++<t._maxReopenTry4CloseWhenHide&&"visible"===document.visibilityState;){try{if("closing"===t.status)try{await t._pOpen}catch(t){}await t.open(),t._isOpenBeforeHide=!1}catch(t){await new Promise(e=>setTimeout(e,300));continue}break}}},oi.showFilePicker=async function(e){var t;null===(t=ui)||void 0===t||t.remove();const i=ui=document.createElement("input");i.type="file",i.accept="image/jpeg, image/png, image/gif, image/bmp, image/webp, image/tiff",i.multiple=!0;let s=new Promise(function(e){i.addEventListener("change",function(){e(Array.from(i.files)),i.remove()})});Object.assign(i,e),Object.assign(i.style,{width:"1px",height:"1px",position:"fixed",left:"0",top:"0",opacity:"0.1",overflow:"hidden",zIndex:"-1"}),document.body.append(i);let n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});return i.dispatchEvent(n),s};let _i=class{constructor(e){qt(this,"camera",void 0),qt(this,"_ctx",void 0),qt(this,"_data",void 0),qt(this,"_dataTime",-1/0),qt(this,"_x",void 0),qt(this,"_y",void 0),qt(this,"_w",void 0),qt(this,"_h",void 0),qt(this,"_type",void 0),qt(this,"maxTimeout",500),qt(this,"_pipeTaskId",void 0),qt(this,"isSaveOriginalRgba",!1),qt(this,"originalRgba",void 0),this.camera=e;const t=document.createElement("canvas");this._ctx=t.getContext("2d",{willReadFrequently:!0})}_getData(){if("opened"!==this.camera.status)return null;this.camera.getFrame({x:this._x,y:this._y,width:this._w,height:this._h,reusedContext:this._ctx});const e=this._ctx.getImageData(0,0,this._w,this._h).data;if(this.originalRgba=this.isSaveOriginalRgba?e:null,"rgba"===this._type)return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);const t=new Uint8Array(e.length/4);for(let i=0;i<e.length;i+=4)t[i/4]=.3*e[i]+.59*e[i+1]+.11*e[i+2];return t}getData(e){let{x:t=0,y:i=0,width:s=this.camera._video.videoWidth,height:n=this.camera._video.videoHeight,type:r="rgba"}=e||{};if(s=Math.round(s+t)-Math.round(t),n=Math.round(n+i)-Math.round(i),t=Math.round(t),i=Math.round(i),0===s||0===n||isNaN(s)||isNaN(n))return null;const o=t!==this._x||i!==this._y||s!==this._w||n!==this._h||r!==this._type;let a;return o&&(this._x=t,this._y=i,this._w=s,this._h=n,this._type=r),!o&&this._dataTime+this.maxTimeout>Date.now()&&this._data?(a=this._data,this._data=null):a=this._getData(),this._pipeTaskId||(this._pipeTaskId=setTimeout(()=>{this._pipeTaskId=null,this._data=this._getData(),this._dataTime=Date.now()},0)),a}},mi=class{constructor(){qt(this,"_stAudioFree",new Set),qt(this,"_stAudioPlaying",new Set),qt(this,"_timeLastPlay",0),qt(this,"_bWarnedMaxTrack",!1),qt(this,"maxPlayingBeep",16),qt(this,"beepSoundSource","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")}beep(){if(!this.beepSoundSource)return;let e,t=Date.now();if(!(t-this._timeLastPlay<100)){if(this._timeLastPlay=t,this._stAudioFree.size&&(e=this._stAudioFree.values().next().value,this.beepSoundSource==e.src?(this._stAudioFree.delete(e),e.play()):e=null),!e)if(this._stAudioPlaying.size<this.maxPlayingBeep){e=new Audio(this.beepSoundSource);let t=null,i=()=>{e.removeEventListener("loadedmetadata",i),e.play(),t=setTimeout(()=>{this._stAudioPlaying.delete(e)},2e3*e.duration)};e.addEventListener("loadedmetadata",i),e.addEventListener("ended",()=>{null!=t&&(clearTimeout(t),t=null),e.pause(),e.currentTime=0,this._stAudioPlaying.delete(e),this._stAudioFree.add(e)})}else this._bWarnedMaxTrack||(this._bWarnedMaxTrack=!0,console.warn(`The requested audio tracks exceed ${this.maxPlayingBeep} and will not be played.`));e&&this._stAudioPlaying.add(e)}}};const gi=()=>{(null!=hi?hi:hi=new mi).beep()},fi=(e=300)=>{var t;if(null===(t=navigator)||void 0===t||!t.vibrate)throw new Error("Not supported.");navigator.vibrate(e)},pi=oi,Ei=oi;if(null!==(jt=document)&&void 0!==jt&&jt.head){const e=new Blob(["@keyframes dce-scanlight{from{top:0;}to{top:97%;}}"],{type:"text/css"}),t=document.createElement("link");t.rel="stylesheet",t.href=URL.createObjectURL(e),document.head.append(t)}const yi={x:0,y:0,width:100,height:100,isMeasuredInPercentage:!0};pi.createInstance=async function(e){let t;if(e instanceof oi?(t=e,e=void 0):t=new oi,void 0===t.disposed){if(t.isCameraEnhancer=!0,t.disposed=!1,t._cameraEnhancer=t._cameraView=t,t._framePipeline=new _i(t),t._dceScanRegion=yi,t._dceEventListeners={},t._bTryAnotherCameraWhenFailToOpen=!0,t._bAutoSingleFrameModeWhenIosPwaFail=!0,t._oriOpen=t.open,t.open=Ii,t._oriUpdateCanvasSize=t._updateCanvasSize,t._updateCanvasSize=Ri,t._oriAddCanvas=t.addCanvas,t.addCanvas=Ci,t._dceZoom=1,t._dceEnhancedFeatures=0,t._dceAutoZoomRange={min:1,max:10},t._oriSetZoom=t.setZoom,t.setZoom=Ti,t.singleFrameMode="disabled",t._ifSaveLastUsedCamera=!1,t._pixelFormat=10,t._colourChannelUsageType=0,t.addImageToBuffer=t.clearBuffer=t.startFetching=t.stopFetching=t.setBufferOverflowProtectionMode=t.setErrorListener=t.setImageFetchInterval=t.setMaxImageCount=t.setNextImageToReturn=()=>{},t.getImageCount=t.getMaxImageCount=t.getImageFetchInterval=t.getBufferOverflowProtectionMode=()=>0,t.hasImage=()=>!1,null!=e||(e=Ei.defaultUIElementURL),e&&await t.setUIElement(e),t._dceRegionMaskStyle={lineWidth:2,strokeStyle:"rgb(254,142,20)",fillStyle:"rgba(0,0,0,0.5)"},t._dceRegionMaskVisible=!0,t._dceTipDuration=3e3,t._drawingLayers=[],t._drawingLayers.length=100,t._capturedResultReceiver={onCapturedResultReceived:ji.bind(t)},!t.regionBox.innerUi){const e=document.createElement("div");Object.assign(e.style,{position:"absolute",width:"100%",height:"3%",borderRadius:"50%",boxShadow:"0px 0px 2vw 1px #00e5ff",background:"#fff",animation:"3s infinite dce-scanlight",pointerEvents:"none",userSelect:"none",display:"none"}),t.setRegionBox({innerUi:e})}t.addEventListener("opened",function(){var e,i,s,n;null!==(e=this._dceEventListeners.cameraOpen)&&void 0!==e&&e.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}}),null===(i=this._dceEventListeners.played)||void 0===i||i.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}});const r=null===(s=t.currentCamera)||void 0===s?void 0:s.deviceId,o=t._dceLastDeviceId;r!==o&&(t._dceLastDeviceId=r,null===(n=this._dceEventListeners.cameraChange)||void 0===n||n.forEach(e=>{try{e.call(this,r,o)}catch(e){console.error(e)}}))}),t.addEventListener("closed",function(){var e;t.clearAllInnerDrawingItems(!0),t.videoSrc&&(t.video.src=""),null===(e=this._dceEventListeners.cameraClose)||void 0===e||e.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}})}),t.video.addEventListener("resize",()=>{var e;if(!t.video.videoWidth||!t.video.videoHeight)return;const i=t.currentResolution,s=t._dceLastResolution;i.width===(null==s?void 0:s.width)&&i.height===(null==s?void 0:s.height)||(t._dceLastResolution=i,null===(e=t._dceEventListeners.resolutionChange)||void 0===e||e.forEach(e=>{try{e.call(this,i,s)}catch(e){console.error(e)}}))}),["mousedown","mouseup","dblclick"].forEach(e=>{t._coreShell.addEventListener(e,function(e){const i=[e.clientX,e.clientY],s=t._drawingLayers.filter(e=>null==e?void 0:e._visible).map(e=>e._drawingItems).flat(),n=t.videoXY2AbsoluteLT(s.map(e=>{if(e instanceof Ui)return e.quad.points;if(e instanceof Vi||e instanceof Gi||e instanceof Wi){let{x:t,y:i,width:s,height:n}=e.rect,r=t+s,o=i+n;return[{x:t,y:i},{x:t,y:o},{x:r,y:o},{x:r,y:i}]}return e instanceof ki?[e.line.startPoint,e.line.endPoint]:void 0}).flat()).map(e=>[e.left,e.top]);let r=0;s.forEach(t=>{var s;let o=!1;t instanceof Ui||t instanceof Vi||t instanceof Gi||t instanceof Wi?(o=xi(i,[n[r],n[r+1],n[r+2],n[r+3]]),r+=4):t instanceof ki&&(o=xi(i,[n[r],n[r+1]]),r+=2),o&&(null===(s=t._dceEventListeners[e.type])||void 0===s||s.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}}))})})})}return t},pi.defaultUIElementURL="@engineResourcePath/ui/dce.ui.xml",Object.defineProperty(pi.prototype,"cameraOpenTimeout",{get(){return this._getUserMediaTimeout},set(e){this._getUserMediaTimeout=e}});const Ii=async function(){var e,t,i,s,n;const r=this;if("camera"===r.singleFrameMode||"image"===r.singleFrameMode){var o;const e=await vi("camera"===r.singleFrameMode),t=r.ui.querySelector(".dce-bg-camera");"closed"!==r.status&&await r.close(),t&&(t.style.opacity="0");{r._singleFrameModeCvs&&r._singleFrameModeCvs.remove();const t=r._singleFrameModeCvs=e.toCanvas();Object.assign(t.style,{width:"100%",height:"100%",position:"absolute",left:"0px",top:"0px"}),r._video.parentElement.querySelectorAll("canvas").forEach(e=>{e.width!==t.width&&(e.width=t.width),e.height!==t.height&&(e.height=t.height)});{const e=r._coreOuterLayer.style;if("fill"===this._objectFit||void 0===e.aspectRatio)"100%"!==e.width&&(e.width="100%"),"100%"!==e.height&&(e.height="100%");else{const{width:i,height:s}=r._coreShell.getBoundingClientRect(),n=`${t.width} / ${t.height}`;n!=e.aspectRatio&&(e.aspectRatio=n);const o=i/s-t.width/t.height,a=.001;if(Math.abs(o)>a){let t=!1;o>0&&(t=!t),"cover"===r._objectFit&&(t=!t),t?("auto"!=e.width&&(e.width="auto"),"100%"!=e.height&&(e.height="100%")):("100%"!=e.width&&(e.width="100%"),"auto"!=e.height&&(e.height="auto"))}}}r._video.before(t)}return r._singleFrameModeResultForDcv=e,void(null===(o=r._dceEventListeners.singleFrameAcquired)||void 0===o||o.forEach(t=>{try{t.call(this,e)}catch(t){console.error(t)}}))}r.videoSrc&&(r.video.src=r._dceVideoSrc);const a=r.ui.querySelector(".dce-bg-loading");a&&(a.style.display="");try{await r._oriOpen()}catch(e){if(pi.onWarning&&pi.onWarning(null==e?void 0:e.message),!r._bTryAnotherCameraWhenFailToOpen||"customized-video"===r.requestedCamera||!["NotReadableError","AbortError","OverconstrainedError"].includes(null==e?void 0:e.name)){var c,l,d;if(r._bAutoSingleFrameModeWhenIosPwaFail&&null!=e&&null!==(c=e.message)&&void 0!==c&&c.includes("iOS PWA"))return console.warn(e.message),a&&(a.style.display="none"),console.warn("Auto switch to `singleFrameMode = 'camera'`."),r.singleFrameMode="camera",void(null===(l=this.funcShowToast)||void 0===l||l.call(this,"Click to Capture",8e3));throw a&&(a.style.display="none"),null!==(d=this.funcShowToast)&&void 0!==d&&d.call(this,null==e?void 0:e.message,8e3),e}{var u;console.warn(e),await r.requestCamera("quick-back");try{await r._oriOpen()}catch(r){var h;throw a&&(a.style.display="none"),null!==(h=this.funcShowToast)&&void 0!==h&&h.call(this,null==r?void 0:r.message,8e3),r}const t=r.currentCamera,i=t?t.trackLabel||t.label||t.deviceId:"available camera";null===(u=this.funcShowToast)||void 0===u||u.call(this,`Fallback to ${i}`)}}return r._ifSaveLastUsedCamera&&null!==(e=r.currentCamera)&&void 0!==e&&e.deviceId&&(null!==(t=localStorage)&&void 0!==t&&t.setItem("dce-last-used-camera",null===(i=r.currentCamera)||void 0===i?void 0:i.deviceId),null!==(s=localStorage)&&void 0!==s&&s.setItem("dce-last-used-resolution",JSON.stringify(r.requestedResolution))),a&&(a.style.display="none"),await new Promise(e=>setTimeout(e,0)),{deviceId:null===(n=r.currentCamera)||void 0===n?void 0:n.deviceId,...r.currentResolution}},vi=async function(e){const t={multiple:!1};e&&(t.capture="environment");const i=(await oi.showFilePicker(t))[0],s=document.createElement("canvas"),n=s.getContext("2d"),r=URL.createObjectURL(i),o=new Image;o.src=r,await o.decode(),s.width=o.width,s.height=o.height,n.drawImage(o,0,0),URL.revokeObjectURL(r);const a=n.getImageData(0,0,s.width,s.height).data;return{bytes:new Uint8Array(a.buffer,a.byteOffset,a.length),width:s.width,height:s.height,stride:4*s.width,format:10,toCanvas:()=>s,imageTag:{imageId:++Si,type:0}}},Ri=function(){"disabled"===this.singleFrameMode&&this._oriUpdateCanvasSize()},Ci=function(){const e=this,t=e._oriAddCanvas();if("disabled"!==e.singleFrameMode&&e._singleFrameModeCvs){const i=e._singleFrameModeCvs;t.width!==i.width&&(t.width=i.width),t.height!==i.height&&(t.height=i.height)}return t};pi.prototype.dispose=function(){this.disposed=!0,this.close(),this.setScanLaserVisible(!1)},pi.prototype.getAllCameras=async function(){return(await oi.getDeviceInfos()).map(e=>({deviceId:e.deviceId,label:e.label||e.trackLabel}))},pi.prototype.getAvailableResolutions=async function(){const e=this,t=[],i=e.requestedCamera,s=e.requestedResolution,n="opened"===e.status;n||await e._oriOpen();for(let i of[[160,120],[320,240],[480,360],[640,480],[800,600],[960,720],[1280,720],[1920,1080],[2560,1440],[3840,2160]]){var r,o,a,c;await e.requestResolution(i),((null===(r=e.currentResolution)||void 0===r?void 0:r.width)===i[0]&&(null===(o=e.currentResolution)||void 0===o?void 0:o.height)===i[1]||(null===(a=e.currentResolution)||void 0===a?void 0:a.width)===i[1]&&(null===(c=e.currentResolution)||void 0===c?void 0:c.height)===i[0])&&t.push({width:i[0],height:i[1]})}return n||await e.close(),await e.requestCamera(i),await e.requestResolution(s),t},pi.prototype.getCameraState=function(){let e=this.status;return"closing"===e||"paused"===e||"closed"===e?"closed":"opened"===e?"open":"opening"===e?"opening":void 0},pi.prototype.getResolution=function(){return"opened"===this.status?this.currentResolution:this.requestedResolution},pi.prototype.getSelectedCamera=function(){var e,t;return"opened"===this.status?{deviceId:null===(e=this.currentCamera)||void 0===e?void 0:e.deviceId,label:null===(t=this.currentCamera)||void 0===t?void 0:t.label}:null},pi.prototype.getVideoSettings=function(){let e={};return"object"==typeof this.requestedCamera&&Object.assign(e,this.requestedCamera),Object.assign(e,this.requestedResolution),{video:e}},Object.defineProperty(pi.prototype,"ifSaveLastUsedCamera",{get(){return this._ifSaveLastUsedCamera},set(e){const t=this;if(t._ifSaveLastUsedCamera=e,e&&"closed"===t.status){var i,s;const n=null===(i=localStorage)||void 0===i?void 0:i.getItem("dce-last-used-camera");n&&t.requestCamera(n);const r=null===(s=localStorage)||void 0===s?void 0:s.getItem("dce-last-used-resolution");if(r)try{t.requestResolution(JSON.parse(r))}catch(e){}}}}),Object.defineProperty(pi.prototype,"ifSkipCameraInspection",{get(){return"quick-back"===this.requestedCamera},set(e){e?this.requestCamera("quick-back"):this.requestCamera("back")}}),pi.prototype.isOpen=function(){return"opened"===this.status},pi.prototype.isPaused=function(){return"paused"===this.status},pi.prototype.resume=async function(){await this._oriOpen()},pi.prototype.selectCamera=async function(e){var t;return await this.requestCamera("string"==typeof e?e:e.deviceId),{deviceId:null===(t=this.currentCamera)||void 0===t?void 0:t.deviceId,...this.currentResolution}},pi.prototype.setResolution=async function(e){var t;return await this.requestResolution(e),{deviceId:null===(t=this.currentCamera)||void 0===t?void 0:t.deviceId,...this.currentResolution}},pi.testCameraAccess=async function(){let e=!0,t="Successfully accessed the camera.";try{await oi.getDeviceInfos()}catch(i){e=!1,t=i.message||i}return{ok:e,message:t}},pi.prototype.updateVideoSettings=async function(e){await this.requestCamera(null==e?void 0:e.video)},Object.defineProperty(pi.prototype,"videoSrc",{get(){return this._dceVideoSrc},set(e){const t=this;t._dceVideoSrc=e,e?t.requestCamera("customized-video"):(t.video.src="",t.requestCamera(void 0))}}),pi.prototype.disableEnhancedFeatures=function(e){this._dceEnhancedFeatures=this._dceEnhancedFeatures-(this._dceEnhancedFeatures&e)},pi.prototype.enableEnhancedFeatures=function(e){this._dceEnhancedFeatures|=e},pi.prototype.getCameraSettings=function(){var e,t;if(!this.track)throw Error("Camera not open");let i=null===(e=(t=this.track).getSettings)||void 0===e?void 0:e.call(t);if(void 0===i)throw Error("Not supported");return i},pi.prototype.getCapabilities=function(){var e,t;if(!this.track)throw Error("Camera not open");let i=null===(e=(t=this.track).getCapabilities)||void 0===e?void 0:e.call(t);if(void 0===i)throw Error("Not supported");return i},pi.prototype.getColorTemperature=function(){var e,t;if(!this.track)throw Error("Camera not open");let i=null===(e=this.track)||void 0===e||null===(t=e.getSettings)||void 0===t||null===(t=t.call(e))||void 0===t?void 0:t.colorTemperature;if(void 0===i)throw Error("Not supported");return i},pi.prototype.getExposureCompensation=function(){var e,t;if(!this.track)throw Error("Camera not open");let i=null===(e=this.track)||void 0===e||null===(t=e.getSettings)||void 0===t||null===(t=t.call(e))||void 0===t?void 0:t.exposureCompensation;if(void 0===i)throw Error("Not supported");return i},pi.prototype.getFrameRate=function(){var e,t;if(!this.track)throw Error("Camera not open");let i=null===(e=this.track)||void 0===e||null===(t=e.getSettings)||void 0===t||null===(t=t.call(e))||void 0===t?void 0:t.frameRate;if(void 0===i)throw Error("Not supported");return i},pi.prototype.setColorTemperature=async function(e){var t;const i=this;i.getColorTemperature(),oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{colorTemperature:e,whiteBalanceMode:"manual"}]})))},pi.prototype.setExposureCompensation=async function(e){var t;const i=this;i.getExposureCompensation(),oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{exposureCompensation:e}]})))},pi.prototype.setFrameRate=async function(e){var t;const i=this;i.getFrameRate(),oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{frameRate:e}]})))},pi.prototype.getZoomSettings=function(){return{factor:this._dceZoom}};const Ti=async function(e){const t=this;if("number"==typeof e)return void await t._oriSetZoom(e);let i,s=e.factor;try{i=t.getZoomRange().max}catch(e){i=null}i?s<i?(await t._oriSetZoom(s),t.setSoftZoom(1)):(await t._oriSetZoom(i),t.setSoftZoom(s/i)):t.setSoftZoom(s),t._dceZoom=s};function wi(e,t,i,s){const n=document.createElement("canvas");n.width=t,n.height=i;const r=n.getContext("2d");if(10!==s){let s=new Uint8Array(t*i*4);for(let t=0;t<e.length;++t){let i=4*t;s[i+2]=s[i+1]=s[i]=e[t],s[i+3]=255}e=s}const o=new Uint8ClampedArray(e),a=new ImageData(o,t,i);return r.putImageData(a,0,0),n}pi.prototype.resetZoom=async function(){this._dceZoom=1,this.setSoftZoom(1,{center:{x:0,y:0}});try{await this._oriSetZoom(1)}catch(e){}},pi.prototype.getFocusSettings=function(){var e,t,i;if(!this.track)throw Error("Camera not open");let s,n=null===(e=this.track)||void 0===e||null===(t=e.getSettings)||void 0===t?void 0:t.call(e),r=null==n?void 0:n.focusMode;if(void 0===r)throw Error("Not supported");return s=r===(null===(i=this._dceFocusSettings)||void 0===i?void 0:i.mode)?this._dceFocusSettings:{mode:r},"manual"===s.mode&&(s.distance=null==n?void 0:n.focusDistance),s},pi.prototype.setFocus=async function(e){const t=this;if(!t.track)throw Error("Camera not open");if(t._dceFocusSettings=e,"manual"!==e.mode)oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await t.applyConstraints({advanced:[{focusMode:e.mode}]});else if(e.distance)oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await t.applyConstraints(t.correctAdvancedConstraint({advanced:[{focusMode:"manual",focusDistance:e.distance}]}));else if(e.area){let{x:i,y:s}=e.area.centerPoint,n=e.area.width,r=e.area.height,o=t.currentResolution.width,a=t.currentResolution.height;"string"==typeof i&&(i=i.endsWith("%")?parseFloat(i)*o:parseFloat(i)),"string"==typeof s&&(s=s.endsWith("%")?parseFloat(s)*a:parseFloat(s)),"string"==typeof n&&(n=n.endsWith("%")?parseFloat(n)*o:parseFloat(n)),"string"==typeof r&&(r=r.endsWith("%")?parseFloat(r)*a:parseFloat(r)),await t._advancedFocus({x:i,y:s},n,r)}},pi.prototype.setAutoZoomRange=function(e){var t;this._dceAutoZoomRange=e;const i=null===(t=this._enhancedFeaturesIrr)||void 0===t?void 0:t._autoZoomParameters;i&&(i.minValue=e.min,i.maxValue=e.max)},pi.prototype.getAutoZoomRange=function(){var e;const t=null===(e=this._enhancedFeaturesIrr)||void 0===e?void 0:e._autoZoomParameters;return t?{min:t.minValue,max:t.maxValue}:this._dceAutoZoomRange},pi.prototype.toggleMirroring=function(e){this.isMirrored=e};let Si=0;pi.prototype.fetchImage=function(){const e=this.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0});let{width:t,height:i}=e;const s=this.getFrame(e),n=s.getContext("2d").getImageData(0,0,t,i).data;return{bytes:new Uint8Array(n.buffer,n.byteOffset,n.byteLength),width:t,height:i,stride:4*e.width,format:10,toCanvas:()=>s,imageTag:{imageId:++Si,type:1}}},pi.prototype.getImage=function(){var e;const t=this,i=t.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0}),s=2!=t._pixelFormat;let n=t._framePipeline.getData({...i,type:s?"rgba":"gray"});if(!n)return null;let{width:r,height:o}=i,a=s?10:2,c=i.width*(s?4:1);if(s&&[3,4,5].includes(t._colourChannelUsageType)){const e=r*o,i=t._colourChannelUsageType-3,s=new Uint8Array(r*o);for(let t=0;t<e;++t)s[t]=n[4*t+i];n=s,a=2,c/=4}const l={bytes:n,width:r,height:o,stride:c,format:a,toCanvas:function(){return wi(this.bytes,this.width,this.height,this.format)},imageTag:{imageId:++Si,type:1}};return null!==(e=this._dceEventListeners.frameAddedToBuffer)&&void 0!==e&&e.forEach(e=>{try{e.call(this,l)}catch(e){console.error(e)}}),l},pi.prototype.takePhoto=async function(e){const t=this;let i=!1;"opened"===t.status&&(i=!0,await t.close()),await t.close();const s=await vi(!0);return i&&await t._oriOpen(),null!=e&&e(s),s},Object.defineProperty(pi.prototype,"singleFrameMode",{get(){return this._singleFrameMode},set(e){var t;const i=this;i._singleFrameMode=e;const s=i.ui.querySelector(".dce-bg-camera");null!==(t=i._singleFrameModeCvs)&&void 0!==t&&t.remove(),i._singleFrameModeCvs=null,i._singleFrameModeResultForDcv=null,"disabled"!==e?(i.close(),i._dceSettingsBeforeSingleFrameMode||(i._dceSettingsBeforeSingleFrameMode={shouldCloseWhenHide:i.shouldCloseWhenHide,regionBox:{...i.regionBox},requestedCamera:i.requestedCamera},i.shouldCloseWhenHide=!1,i.setRegionBox({width:1,height:1,unit:"view-size",center:{x:0,y:0},innerUi:null}),i.requestCamera("customized-video")),s&&(i._singleFrameModeClickCallback||(i._singleFrameModeClickCallback=()=>{i.open()},s.addEventListener("click",i._singleFrameModeClickCallback)),s.style.display="",s.style.opacity="")):(i._dceSettingsBeforeSingleFrameMode&&(i.shouldCloseWhenHide=i._dceSettingsBeforeSingleFrameMode.shouldCloseWhenHide,i.setRegionBox(i._dceSettingsBeforeSingleFrameMode.regionBox),i.requestCamera(i._dceSettingsBeforeSingleFrameMode.requestedCamera),i._dceSettingsBeforeSingleFrameMode=null),i._singleFrameModeClickCallback&&(s.removeEventListener("click",i._singleFrameModeClickCallback),i._singleFrameModeClickCallback=null),s&&(s.style.display="none"))}}),pi.prototype.getScanRegion=function(){return this._dceScanRegion},pi.prototype.hasNextImageToFetch=function(){return"opened"===this.status},pi.prototype.isBufferEmpty=function(){return"opened"!==this.status},pi.prototype.getPixelFormat=function(){return this._pixelFormat},pi.prototype.setPixelFormat=function(e){this._pixelFormat=e},pi.prototype.setColourChannelUsageType=function(e){this._colourChannelUsageType=e},pi.prototype.getColourChannelUsageType=function(){return this._colourChannelUsageType},pi.prototype.setScanRegion=function(e){this._dceScanRegion=null!=e?e:e=yi;const t=this._dceRegionMaskVisible,i=this._dceRegionMaskStyle;if(e.isMeasuredInPercentage)if(void 0!==e.x){let s=e;this.setRegionBox({width:s.width/100,height:s.height/100,center:{x:(s.x+s.width/2-50)/100,y:(s.y+s.height/2-50)/100},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}else{let s=e;this.setRegionBox({width:(s.right-s.left)/100,height:(s.bottom-s.top)/100,center:{x:((s.left+s.right)/2-50)/100,y:((s.top+s.bottom)/2-50)/100},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}else{let s=this.video.videoWidth||720,n=this.video.videoHeight||1280;if(void 0!==e.x){let r=e;this.setRegionBox({width:Math.min(r.width/s,1),height:Math.min(r.height/n,1),center:{x:0,y:0},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}else{let r=e;this.setRegionBox({width:Math.min((r.right-r.left)/s,1),height:Math.min((r.bottom-r.top)/n,1),center:{x:0,y:0},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}}},pi.prototype.setCameraView=function(e){if(e===this)return;const t=e.ui.parentElement;e.ui.parentElement&&(e.ui.remove(),t.append(this.ui));let i=[];for(let t in e)"function"==typeof e[t]&&i.push(t);for(let t of i)e[t]=this[t].bind(this)},pi.prototype.getCameraView=function(){return this},pi.prototype.getVideoEl=function(){return this.video},pi.prototype.convertToPageCoordinates=function(e){let{x:t,y:i}=this.getVisibleAreaInVideoXY({isConsiderRegionBox:!0});return(isNaN(t)||isNaN(i))&&(t=i=0),this.videoXY2AbsoluteLT([{x:e.x+t,y:e.y+i}]).map(e=>({x:e.left,y:e.top}))[0]},pi.prototype.convertToClientCoordinates=function(e){let{x:t,y:i}=this.getVisibleAreaInVideoXY({isConsiderRegionBox:!0});return(isNaN(t)||isNaN(i))&&(t=i=0),this.videoXY2FixedLT([{x:e.x+t,y:e.y+i}]).map(e=>({x:e.left,y:e.top}))[0]},pi.prototype.convertToScanRegionCoordinates=function(e){const t=this,i=t.video.videoWidth,s=t.video.videoHeight;let n=t.videoXY2AbsoluteLT([{x:0,y:0},{x:i,y:s}]);return{x:e.x/i*(n[1].left-n[0].left),y:e.y/s*(n[1].top-n[0].top)}},pi.prototype.convertToContainCoordinates=function(e){const t=this;let i,s,n,r;{let{x:e,y:n}=t.getVisibleAreaInVideoXY();if(isNaN(e)||isNaN(n))return{x:0,y:0};i=e,s=n}{let{x:e,y:i}=t.getVisibleAreaInVideoXY({isConsiderRegionBox:!0});if(isNaN(e)||isNaN(i))return{x:0,y:0};n=e,r=i}const o=t.video.videoWidth,a=t.video.videoHeight;let c=t.videoXY2AbsoluteLT([{x:0,y:0},{x:o,y:a}]);return{x:(e.x+n-i)/o*(c[1].left-c[0].left),y:(e.y+r-s)/a*(c[1].top-c[0].top)}},pi.prototype.on=function(e,t){var i,s;(null!==(s=(i=this._dceEventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)},pi.prototype.off=function(e,t){var i;null===(i=this._dceEventListeners[e])||void 0===i||i.delete(t)},Ei.prototype.getUIElement=function(){return this.ui},Ei.prototype.setUIElement=async function(e){const t=this;if(!e)return void(t._ui=void 0);if(e instanceof HTMLElement&&e.contains(t._coreShell))return void(t._ui=e);if(e instanceof HTMLElement&&!e.childElementCount)return await t.setUIElement(Ei.defaultUIElementURL),e.append(t.getUIElement()),void(t.ui=e);if("string"==typeof e){let i=e.trim();if(!i.trimStart().startsWith("<")){if(i.includes("@engineResourcePath/")){const e=pi.handleEngineResourcePaths(pi.CoreModule.engineResourcePaths);i=i.replace("@engineResourcePath/","DBR"===pi.CoreModule._bundleEnv?e.dbrBundle:e.dcvData)}i=await fetch(i).then(e=>e.text()),i=i.trim()}if(!i.startsWith("<"))throw Error("Invalid html string.");if(i.startsWith("<template>")&&(i=i.substring(10,i.length-11).trim()),!i.startsWith("<"))throw Error("Invalid html string.");let s,n=zt(i,{inlineScript2Blob:t._uiInlineScript2Blob,internalCss2Blob:t._uiInternalCss2Blob,insertInternalCss2ExistedSheet:t._uiInternalCss2ExistedSheet});if(n instanceof HTMLElement)s=n;else{if(!(n instanceof DocumentFragment))throw Error("Seems no HTMLElement.");s=document.createElement("div"),Object.assign(s.style,{width:"100%",height:"100%"}),s.append(n)}e=s,Object.defineProperty(e,"shadowRoot",{value:e,writable:!0})}if(!(e instanceof HTMLElement))throw Error("Invalid html string.");const i="dm-camera-core-container";let s=e.classList.contains(i)?e:e.querySelector(`.${i}`);if(!s){const n="dce-video-container";if(s=e.classList.contains(n)?e:e.querySelector(`.${n}`),s){e.style.overflow="hidden";{const i=e.querySelector("select.dce-sel-camera"),s=e.querySelector("select.dce-sel-resolution");if(i&&!i._dce_binded&&"none"!=i.style.display){i._dce_binded=!0;const e=i.style.zIndex;let s;i.style.position||(i.style.position="relative"),i.style.zIndex="-1",t.addEventListener("opened",async()=>{const s=await oi.getDeviceInfos(),n=t.currentCamera;if(!n)return;const r=n.trackLabel||n.label;i.textContent="";for(let e of s){const t=document.createElement("option");t.value=e.deviceId,t.textContent=e.trackLabel||e.label,i.append(t),t.textContent===r&&(i.value=e.deviceId)}i.style.zIndex=e}),i.addEventListener("change",s=async()=>{t.disposed?t.removeEventListener("change",s):(await t.requestCamera(i.value),"opened"!==t.status&&await t.open())}),t.addEventListener("closed",async()=>{i.style.zIndex="-1"})}if(s&&!s._dce_binded&&"none"!=s.style.display){s._dce_binded=!0;const e=s.style.zIndex;let i,n;if(s.style.position||(s.style.position="relative"),s.style.zIndex="-1",s.children.length)i=s.querySelector(".dce-opt-gotResolution");else{i=document.createElement("option"),i.classList.add("dce-opt-gotResolution"),i.value="got",s.append(i);for(let[e,t]of[[1920,1080],[1280,720],[640,480]]){const i=document.createElement("option");i.setAttribute("data-width",`${e}`),i.setAttribute("data-height",`${t}`),i.textContent=`ask ${e}x${t}`,s.append(i)}}s.addEventListener("change",n=async()=>{if(t.disposed)return void t.removeEventListener("change",n);const e=s.selectedOptions[0];let i=parseInt(e.getAttribute("data-width")),r=parseInt(e.getAttribute("data-height"));await t.requestResolution({width:i,height:r})}),i&&t.addEventListener("opened",async()=>{let n=t.currentResolution;i.textContent=`${n.width}x${n.height}`,s.value="got",s.style.zIndex=e}),t.addEventListener("closed",async()=>{s.style.zIndex="-1"})}let n=e.querySelector(".dce-bg-loading");n&&(n.parentElement.append(n),n.style.display="none");let r=e.querySelector(".dce-bg-camera");if(r instanceof SVGElement){const e=document.createElement("div");Object.assign(e.style,{display:"none",position:"absolute",left:"0",top:"0",width:"100%",height:"100%",cursor:"pointer",pointerEvents:"auto"}),e.title="Take a photo",r.parentElement.append(e),r.classList.remove("dce-bg-camera"),e.classList.add("dce-bg-camera"),e.append(r),r.style.display="",r=e}else r&&r.parentElement.append(r);let o=e.querySelector(".dm-camera-mn-toast,.dce-mn-toast");if(!o&&r){o=document.createElement("div"),o.classList.add("dm-camera-mn-toast"),Object.assign(o.style,{position:"absolute",maxWidth:"90%",fontSize:"max(1.25vmin, 10px)",lineHeight:"max(2vmin, 16px)",padding:"max(0.25vmin, 2px) max(0.5vmin, 4px)",left:"50%",bottom:"max(12.5vmin, 100px)",transform:"translateX(-50%)",color:"#fff",borderRadius:"max(0.5vmin, 4px)",background:"rgba(100, 100, 100, 0.5)",whiteSpace:"pre-wrap",overflowWrap:"break-word",display:"none",zIndex:"1"}),r.parentElement.append(o);let e=null;t.funcShowToast=(t,i=3e3)=>{o&&(o.textContent=t,o.style.display="",null!=e&&(clearTimeout(e),e=null),i&&(e=setTimeout(()=>{o.style.display="none",e=null},i)))}}const a=e.querySelector(".dce-macro-use-mobile-native-like-ui");if(a&&!a._dce_binded){const e=a;e._dce_binded=!0;const i=e.querySelector(".dce-mn-torch"),s=e.querySelector(".dce-mn-torch-auto"),n=e.querySelector(".dce-mn-torch-on"),r=e.querySelector(".dce-mn-torch-off");s&&(s.style.display=void 0===t.isTorchOn?"":"none"),n&&(n.style.display=!0===t.isTorchOn?"":"none"),r&&(r.style.display=!1===t.isTorchOn?"":"none");const o=e.querySelector(".dce-mn-beep-on"),c=e.querySelector(".dce-mn-beep-off");o&&(o.style.display=t._dceMNIsBeepBarcode?"":"none"),c&&(c.style.display=t._dceMNIsBeepBarcode?"none":"");const l=e.querySelector(".dce-mn-vibrate-on"),d=e.querySelector(".dce-mn-vibrate-off");l&&(l.style.display=t._dceMNIsVibrateBarcode?"":"none"),d&&(d.style.display=t._dceMNIsVibrateBarcode?"none":"");const u=e.querySelector(".dce-mn-resolution-box"),h=e.querySelector(".dce-mn-zoom");let _;h&&(h.style.display="none",_=h.querySelector("span"));const m=e.querySelector(".dce-mn-toast");m&&(m.style.display="none",m.classList.add("dm-camera-mn-toast"),m.style.zIndex||(m.style.zIndex="1"));const g=e.querySelector(".dce-mn-camera-close");e.querySelector(".dce-mn-take-photo");const f=e.querySelector(".dce-mn-camera-switch");f&&(f.style.display="none");const p=e.querySelector(".dce-mn-camera-and-resolution-settings");p&&(p.style.display="none");const E=null==p?void 0:p.querySelector(".dce-mn-cameras"),y=null==p?void 0:p.querySelectorAll(".dce-mn-resolution-option");t.addEventListener("opened",async()=>{if(!t.disposed&&"customized-video"!=t.requestedCamera){var e;if(a.style.display="",t.isMirrored=null===(e=t.currentCamera)||void 0===e?void 0:e.isFront,i&&(i.style.display=""),u||null!=y&&y.length){let e;{let i=t.currentResolution,s=Math.max(i.width,i.height),n=Math.min(i.width,i.height);e=n<=1080?n+"P":s<3e3?"2K":Math.round(s/1e3)+"K"}if(u&&(u.textContent=e,u.style.display=""),null!=y&&y.length)for(let t of y)t.textContent===e?t.setAttribute("selected",""):t.hasAttribute("selected")&&t.removeAttribute("selected")}if(E){const e=await oi.getDeviceInfos(),i=t.currentCamera;if(!i)return;const s=i.trackLabel||i.label;E.textContent="";for(let t of e){const e=document.createElement("div");e.classList.add("dce-mn-camera-option"),e.setAttribute("data-device-id",t.deviceId),e.textContent=t.trackLabel||t.label,e.textContent===s&&e.setAttribute("selected",""),E.append(e)}}await oi.hasFrontCamera()&&f&&(f.style.display="")}}),t.addEventListener("closed",()=>{t.disposed||(a.style.display="none",i&&(i.style.display="none"),u&&(u.style.display="none"),f&&(f.style.display="none"),p&&(p.style.display="none"))}),null!=s&&s.addEventListener("pointerdown",()=>{t.disposed||(t.turnOnTorch(),s.style.display="none",n.style.display="")}),null!=n&&n.addEventListener("pointerdown",()=>{t.disposed||(t.turnOffTorch(),n.style.display="none",r.style.display="")}),null!=r&&r.addEventListener("pointerdown",()=>{t.disposed||(t.isSupportTorch?(t.turnAutoTorch(),r.style.display="none",s.style.display=""):R("Torch Not Supported"))}),null!=o&&o.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!1,o.style.display="none",c.style.display="")}),null!=c&&c.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!0,c.style.display="none",o.style.display="")}),null!=l&&l.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsVibrateBarcode=!1,l.style.display="none",d.style.display="")}),null!=d&&d.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsVibrateBarcode=!0,d.style.display="none",l.style.display="")}),t.addEventListener("torchAutoOn",()=>{t.disposed||(R("Torch Auto On"),s&&(s.style.display="none"),n&&(n.style.display=""))}),e.addEventListener("click",async e=>{if(t.disposed)return;let i,s=e.target;if(i=s.closest(".dce-mn-camera-option")){if(i.hasAttribute("selected"))return;await t.requestCamera(i.getAttribute("data-device-id")),"opened"!==t.status&&await t.open()}else if(i=s.closest(".dce-mn-resolution-option")){if(i.hasAttribute("selected"))return;let e=parseInt(i.getAttribute("data-width")),s=parseInt(i.getAttribute("data-height"));if(await t.requestResolution({width:e,height:s}),y.length){const e=null==p?void 0:p.querySelector(".dce-mn-resolution-option[selected]");e&&e.textContent!=i.textContent&&R(`Fallback to ${e.textContent}`)}}else{if(s.closest(".dce-mn-camera-and-resolution-settings"))return;if(s.closest(".dce-mn-resolution-box"))return void(p&&(p.style.display=p.style.display?"":"none"))}p&&""===p.style.display&&(p.style.display="none")});let I=null;t.addEventListener("zoom",({zoom:e})=>{t.disposed||h&&_&&(_.textContent=e.toFixed(1),h.style.display="",null!=I&&(clearTimeout(I),I=null),I=setTimeout(()=>{h.style.display="none",I=null},3e3))});let v=null;const R=t.funcShowToast=(e,t=3e3)=>{m&&(m.textContent=e,m.style.display="",null!=v&&(clearTimeout(v),v=null),t&&(v=setTimeout(()=>{m.style.display="none",v=null},t)))};null!=g&&g.addEventListener("click",()=>{t.disposed||t.close()}),null==f||f.addEventListener("pointerdown",async()=>{t.disposed||await t.requestCamera(t.currentCamera.isFront?"back":"front")})}}s.classList.add(i)}}s||e.classList.add(i),t.ui=e},Ei.prototype.getVideoElement=function(){return this.video},Ei.prototype.setVideoFit=function(e){this.objectFit=e},Ei.prototype.getVideoFit=function(){return this.objectFit},Ei.prototype.getVisibleRegionOfVideo=function(e){const t=this;let{inPixels:i}=e||{inPixels:!1};const s=t.getVisibleAreaInVideoXY();if(i)return{...s,isMeasuredInPercentage:!1};{let{width:e,height:i}=t.currentResolution;return{x:s.x/e*100,y:s.y/i*100,width:s.width/e*100,height:s.height/i*100,isMeasuredInPercentage:!0}}},Ei.prototype.setScanRegionMaskStyle=function(e){const t=this._dceRegionMaskVisible;this._dceRegionMaskStyle={...e},this.setRegionBox({maskStyle:{background:t?e.fillStyle:""},borderStyle:{border:t?`${e.lineWidth}px solid ${e.strokeStyle}`:""}})},Ei.prototype.getScanRegionMaskStyle=function(){return this._dceRegionMaskStyle},Ei.prototype.setScanRegionMaskVisible=function(e){this._dceRegionMaskVisible=e;const t=this._dceRegionMaskStyle;this.setRegionBox({maskStyle:{background:e?t.fillStyle:""},borderStyle:{border:e?`${t.lineWidth}px solid ${t.strokeStyle}`:""}})},Ei.prototype.isScanRegionMaskVisible=function(){return this._dceRegionMaskVisible},Ei.prototype.setScanLaserVisible=function(e){var t;if(null===(t=this.regionBox)||void 0===t||!t.innerUi)return;const i=this.regionBox.innerUi.style;i.display=e?"":"none",setTimeout(()=>{i.display="none",e&&(i.display="")},0)},Ei.prototype.isScanLaserVisible=function(){var e;return!(null===(e=this.regionBox)||void 0===e||!e.innerUi)&&"none"!==this.regionBox.innerUi.style.display},Ei.prototype.setPowerByMessageVisible=function(e){let t=this.ui.querySelector(".dce-msg-poweredby,.dce-mn-msg-poweredby,.dm-camera-mn-msg-poweredby");t&&(e?"none"===t.style.display&&(t.style.display=""):t.style.display="none")},Ei.prototype.isPowerByMessageVisible=function(){let e=this.ui.querySelector(".dce-msg-poweredby,.dm-camera-mn-msg-poweredby");return e&&"none"!==e.style.display},Ei.prototype.getTipConfig=function(){return{duration:this._dceTipDuration}},Ei.prototype.setTipConfig=function(e){this._dceTipDuration=e.duration},Ei.prototype.setTipVisible=function(e){var t;if(e)null===(t=this.funcShowToast)||void 0===t||t.call(this,this._dceTipMessage,this._dceTipDuration);else{const e=this.ui.querySelector(".dm-camera-mn-toast");e&&(e.style.display="none")}},Ei.prototype.isTipVisible=function(){const e=this.ui.querySelector(".dm-camera-mn-toast");return!!e&&"none"!=e.style.display},Ei.prototype.updateTipMessage=function(e){var t;this._dceTipMessage=e,null===(t=this.funcShowToast)||void 0===t||t.call(this,this._dceTipMessage,this._dceTipDuration)},Ei.prototype.createDrawingLayer=function(){const e=new Fi;return e._dce=this,e._ctx=this.addCanvas().getContext("2d"),this._drawingLayers.push(e),e},Ei.prototype.getDrawingLayer=function(e){if(e instanceof Fi)return e;if("number"!=typeof e)return null;let t=this._drawingLayers[e];return t||1!==e&&2!==e&&3!==e||(t=new Fi,t._dce=this,t._ctx=this.addCanvas().getContext("2d"),this._drawingLayers[e]=t,1===e?t._defaultStyle=Bi.STYLE_BLUE_STROKE:2===e?t._defaultStyle=Bi.STYLE_ORANGE_STROKE_FILL:3===e&&(t._defaultStyle=Bi.STYLE_GREEN_STROKE_FILL)),t},Ei.prototype.getAllDrawingLayers=function(){for(let e=1;e<=3;e++)this.getDrawingLayer(e);return this._drawingLayers.filter(e=>e)},Ei.prototype.clearUserDefinedDrawingLayers=function(){for(let t=100;t<this._drawingLayers.length;++t){var e;null===(e=this._drawingLayers[t])||void 0===e||null===(e=e._ctx)||void 0===e||e.canvas.remove()}this._drawingLayers.length=100},Ei.prototype.deleteUserDefinedDrawingLayer=function(e){var t;e<100||(null!==(t=this._drawingLayers[e])&&void 0!==t&&null!==(t=t._ctx)&&void 0!==t&&t.canvas.remove(),delete this._drawingLayers[e])},Ei.prototype.clearAllInnerDrawingItems=function(e){for(let t of this._drawingLayers.slice(1,4))!t||e&&"editor"===t._mode||t.clearDrawingItems()};let Ai=class{static beep(){null!=this._beepInstance?this._beepInstance.beep():gi()}static get beepSoundSource(){var e;return null===(e=this._beepInstance)||void 0===e?void 0:e.beepSoundSource}static set beepSoundSource(e){var t;null!==(t=this._beepInstance)&&void 0!==t||(this._beepInstance=new mi),this._beepInstance.beepSoundSource=e}static vibrate(){null!=this.vibrateDuration?fi(this.vibrateDuration):fi()}};qt(Ai,"_beepInstance",void 0),qt(Ai,"vibrateDuration",void 0);const Di="73,245,73",bi="73,173,245",Li="254,180,32",Oi="245,236,73",Ni=(e,t)=>{let i,s;"f"===t?(i="strokeAndFill",s="0.3"):"t"===t?(i="fill",s="0.2"):(i="stroke",s="0.3");const n={lineWidth:2,fillStyle:`rgba(${e},${s})`,strokeStyle:`rgba(${e},0.9)`,fontFamily:"consolas",fontSize:40,paintMode:i};return n.id=n,n},Mi=[null,Ni(bi),Ni(Di),Ni(Li),Ni(Oi),Ni(bi,"f"),Ni(Di,"f"),Ni(Li,"f"),Ni(Oi,"f"),Ni(bi,"t"),Ni(Di,"t"),Ni(Li,"t"),Ni(Oi,"t")],Bi={STYLE_BLUE_STROKE:Mi[1],STYLE_GREEN_STROKE:Mi[2],STYLE_ORANGE_STROKE:Mi[3],STYLE_YELLOW_STROKE:Mi[4],STYLE_BLUE_STROKE_FILL:Mi[5],STYLE_GREEN_STROKE_FILL:Mi[6],STYLE_ORANGE_STROKE_FILL:Mi[7],STYLE_YELLOW_STROKE_FILL:Mi[8],STYLE_BLUE_STROKE_TRANSPARENT:Mi[9],STYLE_GREEN_STROKE_TRANSPARENT:Mi[10],STYLE_ORANGE_STROKE_TRANSPARENT:Mi[11],STYLE_YELLOW_STROKE_TRANSPARENT:Mi[12],createDrawingStyle(e){let t=Object.assign({},this.STYLE_YELLOW_STROKE_FILL,e);return Object.assign(e,t),e},getDrawingStyle:e=>"number"==typeof e?Mi[e]:e,getAllDrawingStyles:()=>Mi.filter(e=>e),updateDrawingStyle(e,t){e=this.getDrawingStyle(e),Object.keys(e).forEach(t=>{delete e[t]}),Object.assign(e,t),e.id=e}};let Fi=class{constructor(){qt(this,"_visible",!0),qt(this,"_dce",void 0),qt(this,"_ctx",void 0),qt(this,"_defaultStyle",Bi.STYLE_YELLOW_STROKE_FILL),qt(this,"_drawingItems",[]),qt(this,"_mode","viewer"),qt(this,"_editorView",void 0),qt(this,"_renderTask",void 0),qt(this,"_newSelectedDrawingItems",[]),qt(this,"_newDeselectedDrawingItems",[]),qt(this,"_selectionChangedTask",void 0),qt(this,"_onSelectionChanged",void 0)}getId(){return this}isVisible(){return this._editorView?this._editorView._firstLayer.isVisible():this._visible}setVisible(e){if(this._editorView)return this._editorView._firstLayer.setVisible(e);this._visible=e,this._delayRenderAll()}setDefaultStyle(e,t,i){if(this._editorView)return this._editorView._firstLayer.setDefaultStyle(e,t,i);this._defaultStyle=Bi.getDrawingStyle(e),this._delayRenderAll()}addDrawingItems(e){if(this._editorView)return this._editorView._firstLayer.addDrawingItems(e);for(let t of e)t.drawingLayerId=this;this._drawingItems=this._drawingItems.concat(e),this._delayRenderAll()}removeDrawingItems(e){if(this._editorView)return this._editorView._firstLayer.removeDrawingItems(e);this._drawingItems=this._drawingItems.filter(t=>!e.includes(t)),this._delayRenderAll()}setDrawingItems(e){if(this._editorView)return this._editorView._firstLayer.setDrawingItems(e);for(let t of e)t.drawingLayerId=this;this._drawingItems=[...e],this._delayRenderAll()}getDrawingItems(e){return this._editorView?this._editorView._firstLayer.getDrawingItems(e):this._drawingItems.filter(t=>!e||e(t))}hasDrawingItem(e){return this._editorView?this._editorView._firstLayer.hasDrawingItem(e):this._drawingItems.includes(e)}getSelectedDrawingItems(){return this._editorView?this._editorView._firstLayer.getSelectedDrawingItems():this._drawingItems.filter(e=>e._bSelected)}clearDrawingItems(){if(this._editorView)return this._editorView._firstLayer.clearDrawingItems();this._drawingItems=[],this._delayRenderAll()}_delayRenderAll(){this._renderTask||(this._renderTask=setTimeout(()=>{this.renderAll(),this._renderTask=null},0))}renderAll(){var e;if(this._editorView)return this._editorView._firstLayer.renderAll();if(!this._ctx)return;const t=this._ctx,i=t.canvas;if(t.clearRect(0,0,i.width,i.height),!this._visible)return;let s={x:0,y:0};"disabled"===(null===(e=this._dce)||void 0===e?void 0:e.singleFrameMode)&&(s=this._dce.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0}));let n=i.width/i.getBoundingClientRect().width;n>1&&n<i.width||(n=1);for(let e of this._drawingItems){const i=Bi.getDrawingStyle(e.drawingStyleId||this._defaultStyle);if(t.fillStyle=i.fillStyle,t.strokeStyle=i.strokeStyle,t.lineWidth=i.lineWidth*n,t.setLineDash([]),e instanceof Gi){const r=e.text.split("\n"),{x:o,y:a,width:c,height:l}=e.rect,d=Math.min(i.fontSize*n,l/r.length);t.font=`${d}px ${i.fontFamily}`,t.textBaseline="top";const u=o+s.x;for(let e=0;e<r.length;++e){const i=a+l/r.length*e+s.y;t.fillText(r[e],u,i,c),t.strokeText(r[e],u,i,c)}}else if(e instanceof Wi){const i=e.image,n=i.naturalWidth||i.videoWidth||i.width||0,r=i.naturalHeight||i.videoHeight||i.height||0;if(!n||!r)continue;let{x:o,y:a,width:c,height:l}=e.rect;e.maintainAspectRatio&&(l=c/n*r),t.drawImage(i,o+s.x,a+s.y,c,l)}else{if(e._bSelected&&(t.strokeStyle="#0f0",t.lineWidth=2*n,t.setLineDash([4,4])),t.beginPath(),e instanceof Ui){const i=e.quad.points;t.moveTo(i[0].x+s.x,i[0].y+s.y),t.lineTo(i[1].x+s.x,i[1].y+s.y),t.lineTo(i[2].x+s.x,i[2].y+s.y),t.lineTo(i[3].x+s.x,i[3].y+s.y)}else if(e instanceof ki){const i=e.line.startPoint,n=e.line.endPoint;t.moveTo(i.x+s.x,i.y+s.y),t.lineTo(n.x+s.x,n.y+s.y)}else if(e instanceof Vi){const{x:i,y:n,width:r,height:o}=e.rect;t.moveTo(i+s.x,n+s.y),t.lineTo(i+r+s.x,n+s.y),t.lineTo(i+r+s.x,n+o+s.y),t.lineTo(i+s.x,n+o+s.y)}i.paintMode.toLowerCase().includes("fill")&&t.fill(),t.closePath(),i.paintMode.toLowerCase().includes("stroke")&&t.stroke()}}}getMode(){return this._mode}async setMode(e){}_delaySelectionChanged(){this._onSelectionChanged&&!this._selectionChangedTask&&(this._selectionChangedTask=setTimeout(()=>{try{this._onSelectionChanged([...this._newSelectedDrawingItems],[...this._newDeselectedDrawingItems])}catch(e){}this._newSelectedDrawingItems.length=this._newDeselectedDrawingItems.length=0,this._selectionChangedTask=null},0))}get onSelectionChanged(){return this._editorView?this._editorView._firstLayer.onSelectionChanged:this._onSelectionChanged}set onSelectionChanged(e){this._editorView?this._editorView._firstLayer.onSelectionChanged=e:this._onSelectionChanged=e}};function xi(e,t){const[i,s]=e;let n=!1;for(let e=0,r=t.length-1;e<t.length;r=e++){const[o,a]=t[e],[c,l]=t[r];if(i===o&&s===a||i===c&&s===l)return!0;if((i<=o&&i>=c||i>=o&&i<=c)&&(s<=a&&s>=l||s>=a&&s<=l)&&(i-o)*(s-a)==(i-c)*(s-l))return!0;a>s!=l>s&&i<(c-o)*(s-a)/(l-a)+o&&(n=!n)}return n}let Pi=class{constructor(){qt(this,"coordinateBase","image"),qt(this,"drawingLayerId",void 0),qt(this,"drawingStyleId",void 0),qt(this,"mediaType",void 0),qt(this,"_notes",[]),qt(this,"_bSelected",!1),qt(this,"_dceEventListeners",{})}get _ps(){return null}getState(){return this._bSelected?Hi.DIS_SELECTED:Hi.DIS_DEFAULT}addNote(e,t){if(t){let t=!1;for(let i=0;i<this._notes.length;++i)this._notes[i].name===e.name&&(this._notes.splice(i,1,e),t=!0);t||this._notes.push(e)}else this._notes.push(e)}getNote(e){for(let t of this._notes)if(e===t.name)return t;return null}getNotes(){return[...this._notes]}hasNote(e){for(let t of this._notes)if(e===t.name)return!0;return!1}updateNote(e,t,i){for(let s of this._notes)e===s.name&&(i&&s.content&&t&&"object"==typeof s.content&&"object"==typeof t?s.content={...s.content,content:t}:i&&s.content&&t&&"string"==typeof s.content&&"string"==typeof t?s.content+=","+t:s.content=t)}deleteNote(e){this._notes=this._notes.filter(t=>t.name!==e)}clearNotes(){this._notes=[]}_delayRenderAll(){var e;null===(e=this.drawingLayerId)||void 0===e||e._delayRenderAll()}_setSelected(e){if(e===this._bSelected)return;this._bSelected=e,this._delayRenderAll();let t=this.drawingLayerId;t&&(e?t._newSelectedDrawingItems.push(this):t._newDeselectedDrawingItems.push(this),t._delaySelectionChanged())}on(e,t){var i,s;(null!==(s=(i=this._dceEventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)}off(e,t){var i;null===(i=this._dceEventListeners[e])||void 0===i||i.delete(t)}},ki=class extends Pi{get _ps(){const e=this.line.startPoint,t=this.line.endPoint;return[e,e,t,t]}constructor(e,t){super(),qt(this,"line",void 0),this.mediaType=Zi.DIMT_LINE,this.line=e,this.drawingStyleId=t}getLine(){return this.line}setLine(e){this.line=e,this._delayRenderAll()}},Ui=class extends Pi{get _ps(){return this.quad.points}constructor(e,t){super(),qt(this,"quad",void 0),this.mediaType=Zi.DIMT_QUADRILATERAL,this.quad=e,this.drawingStyleId=t}getQuad(){return this.quad}setQuad(e){this.quad=e,this._delayRenderAll()}},Vi=class extends Pi{get _ps(){const{x:e,y:t,width:i,height:s}=this.rect;return[{x:e,y:t},{x:e+i,y:t},{x:e+i,y:t+s},{x:e,y:t+s}]}constructor(e,t){super(),qt(this,"rect",void 0),this.mediaType=Zi.DIMT_RECTANGLE,this.rect=e,this.drawingStyleId=t}getRect(){return this.rect}setRect(e){this.rect=e,this._delayRenderAll()}},Gi=class extends Pi{get _ps(){const{x:e,y:t,width:i,height:s}=this.rect;return[{x:e,y:t},{x:e+i,y:t},{x:e+i,y:t+s},{x:e,y:t+s}]}constructor(e,t,i){super(),qt(this,"text",void 0),qt(this,"rect",void 0),this.mediaType=Zi.DIMT_TEXT,this.text=e,this.rect=t,this.drawingStyleId=i}getText(){return this.text}setText(e){this.text=e,this._delayRenderAll()}getTextRect(){return this.rect}setTextRect(e){this.rect=e,this._delayRenderAll()}},Wi=class extends Pi{get _ps(){const{x:e,y:t,width:i,height:s}=this.rect;return[{x:e,y:t},{x:e+i,y:t},{x:e+i,y:t+s},{x:e,y:t+s}]}constructor(e,t,i,s){super(),qt(this,"image",void 0),qt(this,"rect",void 0),qt(this,"maintainAspectRatio",void 0),this.mediaType=Zi.DIMT_IMAGE,this.setImage(e),this.rect=t,this.maintainAspectRatio=i,this.drawingStyleId=s}getImage(){return this.image}setImage(e){e.bytes&&e.format&&(e=wi(e.bytes,e.width,e.height,e.format)),this.image=e,this._delayRenderAll()}getImageRect(){return this.rect}setImageRect(e){this.rect=e,this._delayRenderAll()}};const ji=function(e,t){const i=this;if(i.disposed||["closed","closing"].includes(i.status)&&"disabled"===i.singleFrameMode)return;i.clearAllInnerDrawingItems();const s=null==e?void 0:e.items;if(null!=s&&s.length)for(let e of s){let s,n,r;switch(e.type){case 2:s=i.getDrawingLayer(2),n=e.location.points.map(e=>({x:e.x,y:e.y})),null!=t&&t.isBarcodeVerifyOpen&&!e.verified?r=Bi.STYLE_ORANGE_STROKE_TRANSPARENT:(i._dceMNIsBeepBarcode&&gi(),i._dceMNIsVibrateBarcode&&fi());break;case 4:s=i.getDrawingLayer(3),n=e.location.points.map(e=>({x:e.x,y:e.y})),(null==t?void 0:t.isLabelVerifyOpen)&&!e.verified&&(r=Bi.STYLE_GREEN_STROKE_TRANSPARENT);break;case 8:s=i.getDrawingLayer(1),n=e.location.points.map(e=>({x:e.x,y:e.y})),(null==t?void 0:t.isDetectVerifyOpen)&&1!==e.crossVerificationStatus&&(r=Bi.STYLE_BLUE_STROKE_TRANSPARENT);break;case 16:s=i.getDrawingLayer(1),n=e.sourceLocation.points.map(e=>({x:e.x,y:e.y})),(null==t?void 0:t.isNormalizeVerifyOpen)&&1!==e.crossVerificationStatus&&(r=Bi.STYLE_BLUE_STROKE_TRANSPARENT);break;default:continue}s.addDrawingItems([new Ui({points:n},r)])}};var Zi,Hi,qi,Yi;!function(e){e[e.DIMT_RECTANGLE=1]="DIMT_RECTANGLE",e[e.DIMT_QUADRILATERAL=2]="DIMT_QUADRILATERAL",e[e.DIMT_TEXT=4]="DIMT_TEXT",e[e.DIMT_IMAGE=16]="DIMT_IMAGE",e[e.DIMT_LINE=64]="DIMT_LINE"}(Zi||(Zi={})),function(e){e[e.DIS_DEFAULT=1]="DIS_DEFAULT",e[e.DIS_SELECTED=2]="DIS_SELECTED"}(Hi||(Hi={})),function(e){e[e.EF_ENHANCED_FOCUS=4]="EF_ENHANCED_FOCUS",e[e.EF_AUTO_ZOOM=16]="EF_AUTO_ZOOM",e[e.EF_TAP_TO_FOCUS=64]="EF_TAP_TO_FOCUS"}(qi||(qi={})),function(e){e.GREY="grey",e.GREY32="grey32",e.RGBA="rgba",e.RBGA="rbga",e.GRBA="grba",e.GBRA="gbra",e.BRGA="brga",e.BGRA="bgra"}(Yi||(Yi={}));var $i=Object.freeze({__proto__:null,Beep:mi,Camera:oi,CameraEnhancer:pi,CameraEnhancerModule:{getVersion:()=>"5.0.0-dev-20260424104300"},CameraView:Ei,DrawingItem:Pi,DrawingLayer:Fi,DrawingStyleManager:Bi,get EnumDrawingItemMediaType(){return Zi},get EnumDrawingItemState(){return Hi},get EnumEnhancedFeatures(){return qi},get EnumPixelFormat(){return Yi},Feedback:Ai,FramePipeline:_i,ImageDrawingItem:Wi,LineDrawingItem:ki,QuadDrawingItem:Ui,RectDrawingItem:Vi,TextDrawingItem:Gi,_bufferToCanvas:wi,_distToSegment:function(e,t){const[i,s]=e,[[n,r],[o,a]]=t,c=o-n,l=a-r,d=c*c+l*l;if(0===d)return Math.sqrt((i-n)**2+(s-r)**2);let u=((i-n)*c+(s-r)*l)/d;u=Math.max(0,Math.min(1,u));const h=i-(n+u*c),_=s-(r+u*l);return Math.sqrt(h*h+_*_)},_isPointInPolygon:xi,beep:gi,stringToHtml:zt,vibrate:fi});const zi="undefined"==typeof self,Ki=zi?{}:self,Xi="function"==typeof importScripts,Qi=(()=>{if(!Xi){if(!zi&&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"./"}})(),Ji=e=>e&&"object"==typeof e&&"function"==typeof e.then,es=(async()=>{})().constructor;let ts=class extends es{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,Ji(e)?t=e:"function"==typeof e&&(t=new es(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(Ji(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};const is=" is not allowed to change after `createInstance` or `loadWasm` is called.",ss=!zi&&document.currentScript&&(document.currentScript.getAttribute("data-license")||document.currentScript.getAttribute("data-productKeys")||document.currentScript.getAttribute("data-licenseKey")||document.currentScript.getAttribute("data-handshakeCode")||document.currentScript.getAttribute("data-organizationID"))||"",ns=(e,t)=>{const i=e;if(i._license!==t){if(!i._pLoad.isEmpty)throw new Error("`license`"+is);i._license=t}};!zi&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword");const rs=e=>{if(null==e)e=[];else{e=e instanceof Array?[...e]:[e];for(let t=0;t<e.length;++t){if(!zi){let i=document.createElement("a");i.href=e[t],e[t]=i.href}e[t].endsWith("/")||(e[t]+="/")}}return e},os=(e,t)=>{t=rs(t);const i=e;if(i._licenseServer!==t){if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+is);i._licenseServer=t}},as=(e,t)=>{t=t||"";const i=e;if(i._deviceFriendlyName!==t){if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+is);i._deviceFriendlyName=t}};let cs,ls,ds,us,hs;"undefined"!=typeof navigator&&(cs=navigator,ls=cs.userAgent,ds=cs.platform,us=cs.mediaDevices),function(){if(!zi){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:cs.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},t={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:ds,search:"Win"},Mac:{str:ds},Linux:{str:ds}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let r=n.str||ls,o=n.search||t,a=n.verStr||ls,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=r.indexOf(o)){i=t;for(let e of c){let t=a.indexOf(e);if(-1!=t){s=parseFloat(a.substring(t+e.length+1));break}}break}}for(let e in t){const i=t[e]||{};let s=i.str||ls,r=i.search||e;if(-1!=s.indexOf(r)){n=e;break}}"Linux"==n&&-1!=ls.indexOf("Windows NT")&&(n="HarmonyOS"),hs={browser:i,version:s,OS:n}}zi&&(hs={browser:"ssr",version:0,OS:"ssr"})}(),us&&us.getUserMedia,"Chrome"===hs.browser&&hs.version>66||"Safari"===hs.browser&&hs.version>13||"OPR"===hs.browser&&hs.version>43||"Edge"===hs.browser&&hs.version;const _s=()=>(Me.loadWasm(),ye("dynamsoft_inited",async()=>{let{lt:e,l:t,ls:i,sp:s,rmk:n,cv:r}=((e,t=!1)=>{const i=e;if(i._pLoad.isEmpty){let s,n,r,o=i._license||"",a=JSON.parse(JSON.stringify(i._licenseServer)),c=i._sessionPassword,l=0;if(o.startsWith("t")||o.startsWith("f"))l=0;else if(0===o.length||o.startsWith("P")||o.startsWith("L")||o.startsWith("Y")||o.startsWith("A"))l=1;else{l=2;const t=o.indexOf(":");-1!=t&&(o=o.substring(t+1));const i=o.indexOf("?");if(-1!=i&&(n=o.substring(i+1),o=o.substring(0,i)),o.startsWith("DLC2"))l=0;else{if(o.startsWith("DLS2")){let t;try{let e=o.substring(4);e=atob(e),t=JSON.parse(e)}catch(e){throw new Error("Format Error: The license string you specified is invalid, please check to make sure it is correct.")}if(o=t.handshakeCode?t.handshakeCode:t.organizationID?t.organizationID:"","number"==typeof o&&(o=JSON.stringify(o)),0===a.length){let e=[];t.mainServerURL&&(e[0]=t.mainServerURL),t.standbyServerURL&&(e[1]=t.standbyServerURL),a=rs(e)}!c&&t.sessionPassword&&(c=t.sessionPassword),s=t.remark}o&&"200001"!==o&&!o.startsWith("200001-")||(l=1)}}if(l&&(t||(Ki.crypto||(r="Please upgrade your browser to support online key."),Ki.crypto.subtle||(r="Require https to use online key in this browser."))),r)throw new Error(r);return 1===l&&(o="",console.warn("Applying for a public trial license ...")),{lt:l,l:o,ls:a,sp:c,rmk:s,cv:n}}throw new Error("Can't preprocess license again"+is)})(gs),o=new ts;gs._pLoad.task=o,(async()=>{try{await gs._pLoad}catch(e){}})();let a=Re();Ce[a]=t=>{if(t.message&&gs._onAuthMessage){let e=gs._onAuthMessage(t.message);null!=e&&(t.message=e)}let i,s=!1;if(1===e&&(s=!0),t.success?(Te&&Te("init license success"),t.message&&console.warn(t.message),Me._bSupportIRTModule=t.bSupportIRTModule,Me._bSupportDce4Module=t.bSupportDce4Module,gs.bPassValidation=!0,[0,-10076].includes(t.initLicenseInfo.errorCode)?[-10076].includes(t.initLicenseInfo.errorCode)&&console.warn(t.initLicenseInfo.errorString):o.reject(new Error(t.initLicenseInfo.errorString))):(i=Error(t.message),t.stack&&(i.stack=t.stack),t.ltsErrorCode&&(i.ltsErrorCode=t.ltsErrorCode),s||111==t.ltsErrorCode&&-1!=t.message.toLowerCase().indexOf("trial license")&&(s=!0)),s){const e=b(Me.engineResourcePaths),i=("DCV"===Me._bundleEnv?e.dcvData:e.dbrBundle)+"ui/";(async(e,t,i)=>{if(!e._bNeverShowDialog)try{let s=await fetch(e.engineResourcePath+"dls.license.dialog.html");if(!s.ok)throw Error("Get license dialog fail. Network Error: "+s.statusText);let n=await s.text();if(!n.trim().startsWith("<"))throw Error("Get license dialog fail. Can't get valid HTMLElement.");let r=document.createElement("div");r.insertAdjacentHTML("beforeend",n);let o=[];for(let e=0;e<r.childElementCount;++e){let t=r.children[e];t instanceof HTMLStyleElement&&(o.push(t),document.head.append(t))}let a=1==r.childElementCount?r.children[0]:r;a.remove();let c,l,d,u,h,_=[a],m=a.children;for(let e of m)_.push(e);for(let e=0;e<_.length;++e)for(let t of _[e].children)_.push(t);for(let e of _)if(!c&&e.classList.contains("dls-license-mask"))c=e,e.addEventListener("click",t=>{if(e==t.target){a.remove();for(let e of o)e.remove()}});else if(!l&&e.classList.contains("dls-license-icon-close"))l=e,e.addEventListener("click",()=>{a.remove();for(let e of o)e.remove()});else if(!d&&e.classList.contains("dls-license-icon-error"))d=e,"error"!=t&&e.remove();else if(!u&&e.classList.contains("dls-license-icon-warn"))u=e,"warn"!=t&&e.remove();else if(!h&&e.classList.contains("dls-license-msg-content")){h=e;let t=i;for(;t;){let i=t.indexOf("["),s=t.indexOf("]",i),n=t.indexOf("(",s),r=t.indexOf(")",n);if(-1==i||-1==s||-1==n||-1==r){e.appendChild(new Text(t));break}i>0&&e.appendChild(new Text(t.substring(0,i)));let o=document.createElement("a"),a=t.substring(i+1,s);o.innerText=a;let c=t.substring(n+1,r);o.setAttribute("href",c),o.setAttribute("target","_blank"),e.appendChild(o),t=t.substring(r+1)}}document.body.appendChild(a)}catch(t){e._onLog&&e._onLog(t.message||t)}})({_bNeverShowDialog:gs._bNeverShowDialog,engineResourcePath:i,_onLog:Te},t.success?"warn":"error",t.message)}t.success?o.resolve(void 0):o.reject(i)},await Ee("core");const c=await Me.getModuleVersion();Ie.postMessage({type:"license_dynamsoft",body:{v:"DCV"===Me._bundleEnv?c.CVR.replace(/\.\d+$/,""):c.DBR.replace(/\.\d+$/,""),brtk:!!e,bptk:1===e,l:t,os:hs,fn:gs.deviceFriendlyName,ls:i,sp:s,rmk:n,cv:r,_e:gs._e,mliRecord:null===localStorage||void 0===localStorage?void 0:localStorage.getItem("dynamsoft")},id:a}),gs.bCallInitLicense=!0,await o}));let ms;be.license={},be.license.dynamsoft=_s,be.license.getAR=async()=>{{let e=pe.dynamsoft_inited;e&&e.isRejected&&await e}return Ie?new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success){delete i.success;{let e=gs.license;e&&(e.startsWith("t")||e.startsWith("f"))&&(i.pk=e)}if(Object.keys(i).length){if(i.lem){let e=Error(i.lem);e.ltsErrorCode=i.lec,delete i.lem,delete i.lec,i.ae=e}e(i)}else e(null)}else{let e=Error(i.message);i.stack&&(e.stack=i.stack),t(e)}},Ie.postMessage({type:"license_getAR",id:i})}):null};let gs=class e{static setLicenseServer(t){os(e,t)}static get license(){return this._license}static set license(t){ns(e,t)}static get licenseServer(){return this._licenseServer}static set licenseServer(t){os(e,t)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(t){as(e,t)}static initLicense(t,i){if(ns(e,t),e.bCallInitLicense=!0,"boolean"==typeof i&&i||"object"==typeof i&&i.executeNow)return _s()}static setDeviceFriendlyName(t){as(e,t)}static getDeviceFriendlyName(){return e._deviceFriendlyName}static getDeviceUUID(){return(async()=>(await ye("dynamsoft_uuid",async()=>{await Me.loadWasm();let e=new ts,t=Re();Ce[t]=t=>{if(t.success)e.resolve(t.uuid);else{const i=Error(t.message);t.stack&&(i.stack=t.stack),e.reject(i)}},Ie.postMessage({type:"license_getDeviceUUID",id:t}),ms=await e}),ms))()}};gs._pLoad=new ts,gs.bPassValidation=!1,gs.bCallInitLicense=!1,gs._license=ss,gs._licenseServer=[],gs._deviceFriendlyName="",gs._e=!0,Me.engineResourcePaths.license={version:"4.4.20-dev-20260415104056",path:Qi,isInternal:!0},Le.license={wasm:!0,js:!0},be.license.LicenseManager=gs;const fs="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,fs)<0&&(Me.engineResourcePaths.std={version:fs,path:(e=>{if(null==e&&(e="./"),zi||Xi);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e})(Qi+`../../dynamsoft-capture-vision-std@${fs}/dist/`),isInternal:!0});var ps=Object.freeze({__proto__:null,LicenseManager:gs,LicenseModule:class{static getVersion(){return`4.4.20-dev-20260415104056(Worker: ${De.license&&De.license.worker||"Not Loaded"}, Wasm: ${De.license&&De.license.wasm||"Not Loaded"})`}}});const Es=()=>window.matchMedia("(orientation: landscape)").matches,ys=e=>Object.prototype.toString.call(e).slice(8,-1);function Is(e,t){for(const i in t)"Object"===ys(t[i])&&"Object"===ys(e[i])&&i in e?Is(e[i],t[i]):("cameraFeatures"===i&&(t[i]=Array.isArray(t[i])?t[i]:[t[i]]),e[i]=t[i]);return e}function vs(e){var t;const i=null===(t=e.label)||void 0===t?void 0:t.toLowerCase();return!!i&&["front","user","selfie","前置","前摄","自拍","前面","インカメラ","フロント","전면","셀카","фронтальная","передняя","frontal","delantera","selfi","frontal","frente","avant","frontal","caméra frontale","vorder","vorderseite","frontkamera","anteriore","frontale","amamiya","al-amam","مقدمة","أمامية","aage","आगे","फ्रंट","सेल्फी","ด้านหน้า","กล้องหน้า","trước","mặt trước","ön","ön kamera","depan","kamera depan","przednia","přední","voorkant","voorzijde","față","frontală","εμπρός","πρόσθια","קדמית","קדמי","selfcamera","facecam","facetime"].some(e=>i.includes(e))}function Rs(e){if("object"!=typeof e||null===e)return e;let t;if(Array.isArray(e)){t=[];for(let i=0;i<e.length;i++)t[i]=Rs(e[i])}else{t={};for(let i in e)e.hasOwnProperty(i)&&(t[i]=Rs(e[i]))}return t}function Cs(e){if(!e)return!1;const t=e.name.toLowerCase();if(![".jpg",".jpeg",".ico",".gif",".svg",".webp",".png",".bmp"].some(e=>t.endsWith(e)))return!1;return!!e.type.startsWith("image/")}const Ts="undefined"==typeof self,ws="function"==typeof importScripts,Ss=(()=>{if(!ws){if(!Ts&&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"./"}})(),As=e=>{if(null==e&&(e="./"),Ts||ws);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e};Me.engineResourcePaths.dbr={version:"11.4.20-dev-20260417175846",path:Ss,isInternal:!0},Le.dbr={js:!1,wasm:!0,deps:[fe.MN_DYNAMSOFT_LICENSE,fe.MN_DYNAMSOFT_IMAGE_PROCESSING]},be.dbr={};const Ds="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,Ds)<0&&(Me.engineResourcePaths.std={version:Ds,path:As(Ss+`../../dynamsoft-capture-vision-std@${Ds}/dist/`),isInternal:!0});const bs="3.0.10";(!Me.engineResourcePaths.dip||"string"!=typeof Me.engineResourcePaths.dip&&D(Me.engineResourcePaths.dip.version,bs)<0)&&(Me.engineResourcePaths.dip={version:bs,path:As(Ss+`../../dynamsoft-image-processing@${bs}/dist/`),isInternal:!0});const Ls={BF_NULL:BigInt(0),BF_ALL:BigInt("0xFFFFFFFEFFFFFFFF"),BF_DEFAULT:BigInt(4265345023),BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096),BF_CODE_39:BigInt(1),BF_CODE_128:BigInt(2),BF_CODE_93:BigInt(4),BF_CODABAR:BigInt(8),BF_ITF:BigInt(16),BF_EAN_13:BigInt(32),BF_EAN_8:BigInt(64),BF_UPC_A:BigInt(128),BF_UPC_E:BigInt(256),BF_INDUSTRIAL_25:BigInt(512),BF_CODE_39_EXTENDED:BigInt(1024),BF_GS1_DATABAR_OMNIDIRECTIONAL:BigInt(2048),BF_GS1_DATABAR_TRUNCATED:BigInt(4096),BF_GS1_DATABAR_STACKED:BigInt(8192),BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL:BigInt(16384),BF_GS1_DATABAR_EXPANDED:BigInt(32768),BF_GS1_DATABAR_EXPANDED_STACKED:BigInt(65536),BF_GS1_DATABAR_LIMITED:BigInt(131072),BF_PATCHCODE:BigInt(262144),BF_CODE_32:BigInt(16777216),BF_PDF417:BigInt(33554432),BF_QR_CODE:BigInt(67108864),BF_DATAMATRIX:BigInt(134217728),BF_AZTEC:BigInt(268435456),BF_MAXICODE:BigInt(536870912),BF_MICRO_QR:BigInt(1073741824),BF_MICRO_PDF417:BigInt(524288),BF_GS1_COMPOSITE:BigInt(2147483648),BF_MSI_CODE:BigInt(1048576),BF_CODE_11:BigInt(2097152),BF_TWO_DIGIT_ADD_ON:BigInt(4194304),BF_FIVE_DIGIT_ADD_ON:BigInt(8388608),BF_MATRIX_25:BigInt(68719476736),BF_POSTALCODE:BigInt(0x3f0000000000000),BF_NONSTANDARD_BARCODE:BigInt(4294967296),BF_USPSINTELLIGENTMAIL:BigInt(4503599627370496),BF_POSTNET:BigInt(9007199254740992),BF_PLANET:BigInt(0x40000000000000),BF_AUSTRALIANPOST:BigInt(0x80000000000000),BF_RM4SCC:BigInt(72057594037927940),BF_KIX:BigInt(0x200000000000000),BF_DOTCODE:BigInt(8589934592),BF_PHARMACODE_ONE_TRACK:BigInt(17179869184),BF_PHARMACODE_TWO_TRACK:BigInt(34359738368),BF_PHARMACODE:BigInt(51539607552),BF_TELEPEN:BigInt(137438953472),BF_TELEPEN_NUMERIC:BigInt(274877906944)};var Os,Ns,Ms,Bs;!function(e){e[e.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",e[e.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",e[e.EBRT_PARTIAL_RESULT=2]="EBRT_PARTIAL_RESULT"}(Os||(Os={})),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"}(Ns||(Ns={})),function(e){e[e.LM_AUTO=1]="LM_AUTO",e[e.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",e[e.LM_STATISTICS=4]="LM_STATISTICS",e[e.LM_LINES=8]="LM_LINES",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_ONED_FAST_SCAN=256]="LM_ONED_FAST_SCAN",e[e.LM_NEURAL_NETWORK=512]="LM_NEURAL_NETWORK",e[e.LM_REV=-2147483648]="LM_REV",e[e.LM_SKIP=0]="LM_SKIP",e[e.LM_END=-1]="LM_END"}(Ms||(Ms={})),function(e){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",e[e.DM_BASED_ON_LOC_BIN=128]="DM_BASED_ON_LOC_BIN",e[e.DM_SHARPENING_SMOOTHING=256]="DM_SHARPENING_SMOOTHING",e[e.DM_NEURAL_NETWORK=512]="DM_NEURAL_NETWORK",e[e.DM_REV=-2147483648]="DM_REV",e[e.DM_SKIP=0]="DM_SKIP",e[e.DM_END=-1]="DM_END"}(Bs||(Bs={}));var Fs=Object.freeze({__proto__:null,BarcodeReaderModule:class{static getVersion(){const e=De.dbr&&De.dbr.wasm;return`11.4.20-dev-20260417175846(Worker: ${De.dbr&&De.dbr.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}},EnumBarcodeFormat:Ls,get EnumDeblurMode(){return Bs},get EnumExtendedBarcodeResultType(){return Os},get EnumLocalizationMode(){return Ms},get EnumQRCodeErrorCorrectionLevel(){return Ns}});const xs="undefined"==typeof self,Ps="function"==typeof importScripts,ks=(()=>{if(!Ps){if(!xs&&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"./"}})(),Us=e=>{if(null==e&&(e="./"),xs||Ps);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},Vs="undefined"==typeof self,Gs="function"==typeof importScripts,Ws=(()=>{if(!Gs){if(!Vs&&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"./"}})(),js=e=>{if(null==e&&(e="./"),Vs||Gs);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e};Me.engineResourcePaths.utility={version:"2.4.20-dev-20260415104100",path:Ws,isInternal:!0},Le.utility={js:!0,wasm:!0};const Zs="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,Zs)<0&&(Me.engineResourcePaths.std={version:Zs,path:js(Ws+`../../dynamsoft-capture-vision-std@${Zs}/dist/`),isInternal:!0});const Hs="3.0.10";(!Me.engineResourcePaths.dip||"string"!=typeof Me.engineResourcePaths.dip&&D(Me.engineResourcePaths.dip.version,Hs)<0)&&(Me.engineResourcePaths.dip={version:Hs,path:js(Ws+`../../dynamsoft-image-processing@${Hs}/dist/`),isInternal:!0});function qs(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}"function"==typeof SuppressedError&&SuppressedError;const Ys="undefined"==typeof self,$s="function"==typeof importScripts,zs=(()=>{if(!$s){if(!Ys&&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"./"}})(),Ks=e=>{if(null==e&&(e="./"),Ys||$s);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e};Me.engineResourcePaths.dbr={version:"11.0.30-dev-20250522174049",path:zs,isInternal:!0},Le.dbr={js:!1,wasm:!0,deps:[fe.MN_DYNAMSOFT_LICENSE,fe.MN_DYNAMSOFT_IMAGE_PROCESSING]},be.dbr={};const Xs="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,Xs)<0&&(Me.engineResourcePaths.std={version:Xs,path:Ks(zs+`../../dynamsoft-capture-vision-std@${Xs}/dist/`),isInternal:!0});const Qs="3.0.10";(!Me.engineResourcePaths.dip||"string"!=typeof Me.engineResourcePaths.dip&&D(Me.engineResourcePaths.dip.version,Qs)<0)&&(Me.engineResourcePaths.dip={version:Qs,path:Ks(zs+`../../dynamsoft-image-processing@${Qs}/dist/`),isInternal:!0});const Js={BF_NULL:BigInt(0),BF_ALL:BigInt("0xFFFFFFFEFFFFFFFF"),BF_DEFAULT:BigInt(4265345023),BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096),BF_CODE_39:BigInt(1),BF_CODE_128:BigInt(2),BF_CODE_93:BigInt(4),BF_CODABAR:BigInt(8),BF_ITF:BigInt(16),BF_EAN_13:BigInt(32),BF_EAN_8:BigInt(64),BF_UPC_A:BigInt(128),BF_UPC_E:BigInt(256),BF_INDUSTRIAL_25:BigInt(512),BF_CODE_39_EXTENDED:BigInt(1024),BF_GS1_DATABAR_OMNIDIRECTIONAL:BigInt(2048),BF_GS1_DATABAR_TRUNCATED:BigInt(4096),BF_GS1_DATABAR_STACKED:BigInt(8192),BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL:BigInt(16384),BF_GS1_DATABAR_EXPANDED:BigInt(32768),BF_GS1_DATABAR_EXPANDED_STACKED:BigInt(65536),BF_GS1_DATABAR_LIMITED:BigInt(131072),BF_PATCHCODE:BigInt(262144),BF_CODE_32:BigInt(16777216),BF_PDF417:BigInt(33554432),BF_QR_CODE:BigInt(67108864),BF_DATAMATRIX:BigInt(134217728),BF_AZTEC:BigInt(268435456),BF_MAXICODE:BigInt(536870912),BF_MICRO_QR:BigInt(1073741824),BF_MICRO_PDF417:BigInt(524288),BF_GS1_COMPOSITE:BigInt(2147483648),BF_MSI_CODE:BigInt(1048576),BF_CODE_11:BigInt(2097152),BF_TWO_DIGIT_ADD_ON:BigInt(4194304),BF_FIVE_DIGIT_ADD_ON:BigInt(8388608),BF_MATRIX_25:BigInt(68719476736),BF_POSTALCODE:BigInt(0x3f0000000000000),BF_NONSTANDARD_BARCODE:BigInt(4294967296),BF_USPSINTELLIGENTMAIL:BigInt(4503599627370496),BF_POSTNET:BigInt(9007199254740992),BF_PLANET:BigInt(0x40000000000000),BF_AUSTRALIANPOST:BigInt(0x80000000000000),BF_RM4SCC:BigInt(72057594037927940),BF_KIX:BigInt(0x200000000000000),BF_DOTCODE:BigInt(8589934592),BF_PHARMACODE_ONE_TRACK:BigInt(17179869184),BF_PHARMACODE_TWO_TRACK:BigInt(34359738368),BF_PHARMACODE:BigInt(51539607552),BF_TELEPEN:BigInt(137438953472),BF_TELEPEN_NUMERIC:BigInt(274877906944)};var en,tn,sn,nn,rn;(rn=en||(en={}))[rn.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",rn[rn.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",rn[rn.EBRT_PARTIAL_RESULT=2]="EBRT_PARTIAL_RESULT",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"}(tn||(tn={})),function(e){e[e.LM_AUTO=1]="LM_AUTO",e[e.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",e[e.LM_STATISTICS=4]="LM_STATISTICS",e[e.LM_LINES=8]="LM_LINES",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_ONED_FAST_SCAN=256]="LM_ONED_FAST_SCAN",e[e.LM_REV=-2147483648]="LM_REV",e[e.LM_SKIP=0]="LM_SKIP",e[e.LM_END=4294967295]="LM_END"}(sn||(sn={})),function(e){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",e[e.DM_BASED_ON_LOC_BIN=128]="DM_BASED_ON_LOC_BIN",e[e.DM_SHARPENING_SMOOTHING=256]="DM_SHARPENING_SMOOTHING",e[e.DM_NEURAL_NETWORK=512]="DM_NEURAL_NETWORK",e[e.DM_REV=-2147483648]="DM_REV",e[e.DM_SKIP=0]="DM_SKIP",e[e.DM_END=4294967295]="DM_END"}(nn||(nn={}));const on=async(e,t)=>{let i,s=document.createElement("canvas"),n=s.getContext("2d"),r=e;try{if(r instanceof Blob){i=URL.createObjectURL(r);const e=await new Promise((e,t)=>{const s=new Image;s.onload=()=>e(s),s.onerror=t,s.src=i});s.width=e.width,s.height=e.height,n.drawImage(e,0,0),r=n.getImageData(0,0,s.width,s.height)}else s.width=r.width,s.height=r.height,n.putImageData(r,0,0);if("image/bmp"===t){const e=B(r);return new Blob([e],{type:"image/bmp"})}return await new Promise(e=>{s.toBlob(t=>{e(t)},t)})}finally{URL.revokeObjectURL(i)}};function an(e,t){let i=!0;for(let o=0;o<e.length;o++){const a=(o+1)%e.length;if(s=e[o],r=t,((n=e[a]).x-s.x)*(r.y-s.y)-(n.y-s.y)*(r.x-s.x)<0){i=!1;break}}var s,n,r;return i}function cn(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function ln(e,t){const[i,s]=e,n=i.x,r=i.y,o=s.x,a=s.y,c=t.x,l=t.y,d=(o-n)**2+(a-r)**2;if(0===d)return Math.sqrt((c-n)**2+(l-r)**2);const u=((c-n)*(o-n)+(l-r)*(a-r))/d;if(u<0)return Math.sqrt((c-n)**2+(l-r)**2);if(u>1)return Math.sqrt((c-o)**2+(l-a)**2);{const e=n+u*(o-n),t=r+u*(a-r);return Math.sqrt((c-e)**2+(l-t)**2)}}function dn(e){const t=[];for(let i=0;i<e.length;i++){const s=e[i],n=e[(i+1)%e.length];t.push([s,n])}return t}function un(e){const[t,i]=e;return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}function hn(e,t,i,s){const n=t.x-e.x,r=t.y-e.y,o=s.x-i.x,a=s.y-i.y,c=(-r*(e.x-i.x)+n*(e.y-i.y))/(-o*r+n*a),l=(o*(e.y-i.y)-a*(e.x-i.x))/(-o*r+n*a);return c>=0&&c<=1&&l>=0&&l<=1?{x:e.x+l*n,y:e.y+l*r}:null}function _n(e){let t=0;for(let i=0;i<e.length;i++){const s=(i+1)%e.length;t+=e[i].x*e[s].y,t-=e[s].x*e[i].y}return Math.abs(t/2)}function mn(e,t,i){let s=t.x-e.x,n=t.y-e.y,r=i.x-e.x;return s*(i.y-e.y)-n*r>0}function gn(e,t){for(let i=0;i<4;i++)if(!mn(e.points[i],e.points[(i+1)%4],t))return!1;return!0}function fn(e,t,i,s){const n=e.points,r=t.points;let o=8*i;o=Math.max(o,5);const a=dn(n)[3],c=dn(n)[1],l=dn(r)[3],d=dn(r)[1];let u,h=0;if(u=Math.max(Math.abs(ln(a,t.points[0])),Math.abs(ln(a,t.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(ln(c,t.points[1])),Math.abs(ln(c,t.points[2]))),u>h&&(h=u),u=Math.max(Math.abs(ln(l,e.points[0])),Math.abs(ln(l,e.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(ln(d,e.points[1])),Math.abs(ln(d,e.points[2]))),u>h&&(h=u),h>o)return!1;const _=un(dn(n)[0]),m=un(dn(n)[2]),g=un(dn(r)[0]),f=un(dn(r)[2]),p=cn(_,f),E=cn(g,m),y=p>E,I=Math.min(p,E),v=cn(_,m),R=cn(g,f);let C=12*i;return C=Math.max(C,5),C=Math.min(C,v),C=Math.min(C,R),!!(I<C||an(n,y?g:f)||an(r,y?m:_))&&(y?(s.points[0]=e.points[0],s.points[1]=e.points[1],s.points[2]=t.points[2],s.points[3]=t.points[3]):(s.points[0]=t.points[0],s.points[1]=t.points[1],s.points[2]=e.points[2],s.points[3]=e.points[3]),s.area=_n(s.points),!0)}class pn{constructor(e,t,i,s){this.overlapCount=e,this.verificationCount=t,this.crossVerificationFrame=5,this.location=s.location,this.locationArea=s.location.area,this.locationAngle=s.angle,this.format=s.format,this.text=s.text,this.isOneD=i,this.item=s,this.locationThreshold=5*s.moduleSize,this.strictLimit=Math.max(this.locationThreshold,1),this.strictLimit=Math.min(this.strictLimit,15)}getCenterPoint(e){const t={x:0,y:0};return e.forEach(({x:e,y:i})=>{t.x+=e,t.y+=i}),t.x/=e.length,t.y/=e.length,t}isProbablySameLocationWithOffset(e,t){const i=this.item.location,s=e.location;if(i.area<=0)return!1;if(Math.abs(i.area-s.area)>.4*i.area)return!1;let n=new Array(4).fill(0),r=new Array(4).fill(0),o=0,a=0;for(let e=0;e<4;++e)n[e]=Math.round(100*(s.points[e].x-i.points[e].x))/100,o+=n[e],r[e]=Math.round(100*(s.points[e].y-i.points[e].y))/100,a+=r[e];o/=4,a/=4;for(let e=0;e<4;++e){if(Math.abs(n[e]-o)>this.strictLimit||Math.abs(o)>.8)return!1;if(Math.abs(r[e]-a)>this.strictLimit||Math.abs(a)>.8)return!1}return t.x=o,t.y=a,!0}isLocationOverlap(e,t){if(this.locationArea>t){for(let t=0;t<4;t++)if(gn(this.location,e.points[t]))return!0;const t=this.getCenterPoint(e.points);if(gn(this.location,t))return!0}else{for(let t=0;t<4;t++)if(gn(e,this.location.points[t]))return!0;if(gn(e,this.getCenterPoint(this.location.points)))return!0}return!1}isMatchedLocationWithOffset(e,t={x:0,y:0}){if(this.isOneD){const i=Object.assign({},e.location);for(let e=0;e<4;e++)i.points[e].x-=t.x,i.points[e].y-=t.y;if(!this.isLocationOverlap(i,e.locationArea))return!1;const s=[this.location.points[0],this.location.points[3]],n=[this.location.points[1],this.location.points[2]];for(let e=0;e<4;e++){const t=i.points[e],r=0===e||3===e?s:n;if(Math.abs(ln(r,t))>this.locationThreshold)return!1}}else for(let i=0;i<4;i++){const s=e.location.points[i],n=this.location.points[i];if(!(Math.abs(n.x+t.x-s.x)<this.locationThreshold))return!1;if(Math.abs(n.y+t.y-s.y)>=this.locationThreshold)return!1}return!0}isOverlappedLocationWithOffset(e,t,i=!0){const s=Object.assign({},e.location);for(let e=0;e<4;e++)s.points[e].x-=t.x,s.points[e].y-=t.y;if(!this.isLocationOverlap(s,e.location.area))return!1;if(i){const e=.75;return function(e,t){const i=[];for(let s=0;s<4;s++)for(let n=0;n<4;n++){const r=hn(e[s],e[(s+1)%4],t[n],t[(n+1)%4]);r&&i.push(r)}return e.forEach(e=>{an(t,e)&&i.push(e)}),t.forEach(t=>{an(e,t)&&i.push(t)}),_n(function(e){if(e.length<=1)return e;e.sort((e,t)=>e.x-t.x||e.y-t.y);const t=e.shift();return e.sort((e,i)=>Math.atan2(e.y-t.y,e.x-t.x)-Math.atan2(i.y-t.y,i.x-t.x)),[t,...e]}(i))}([...this.location.points],s.points)>this.locationArea*e}return!0}}var En,yn,In,vn,Rn,Cn;const Tn={barcode:2,text_line:4,detected_quad:8,deskewed_image:16},wn=(e,t)=>"string"==typeof e?t[Tn[e]]:t[e],Sn=(e,t,i)=>{"string"==typeof e?t[Tn[e]]=i:t[e]=i},An=(e,t,i)=>{const s=[{type:ie.CRIT_BARCODE,resultName:"decodedBarcodesResult",itemNames:["barcodeResultItems"]},{type:ie.CRIT_TEXT_LINE,resultName:"recognizedTextLinesResult",itemNames:["textLineResultItems"]}],n=t.items;if(e.isResultCrossVerificationEnabled(i)){for(let e=n.length-1;e>=0;e--)n[e].type!==i||n[e].verified||n.splice(e,1);const e=s.filter(e=>e.type===i)[0];t[e.resultName]&&e.itemNames.forEach(s=>{const n=t[e.resultName][s];t[e.resultName][s]=n.filter(e=>e.type===i&&e.verified)})}if(e.isResultDeduplicationEnabled(i)){for(let e=n.length-1;e>=0;e--)n[e].type===i&&n[e].duplicate&&n.splice(e,1);const e=s.filter(e=>e.type===i)[0];t[e.resultName]&&e.itemNames.forEach(s=>{const n=t[e.resultName][s];t[e.resultName][s]=n.filter(e=>e.type===i&&!e.duplicate)})}t.decodedBarcodesResult&&0===t.decodedBarcodesResult.barcodeResultItems.length&&delete t.decodedBarcodesResult,t.recognizedTextLinesResult&&0===t.recognizedTextLinesResult.textLineResultItems.length&&delete t.recognizedTextLinesResult},Dn=e=>{const t=[];return e&ie.CRIT_BARCODE&&t.push(ie.CRIT_BARCODE),e&ie.CRIT_TEXT_LINE&&t.push(ie.CRIT_TEXT_LINE),e&ie.CRIT_DETECTED_QUAD&&t.push(ie.CRIT_DETECTED_QUAD),e&ie.CRIT_DESKEWED_IMAGE&&t.push(ie.CRIT_DESKEWED_IMAGE),t};class bn{constructor(){this.verificationEnabled={[ie.CRIT_BARCODE]:!1,[ie.CRIT_TEXT_LINE]:!0,[ie.CRIT_DETECTED_QUAD]:!0,[ie.CRIT_DESKEWED_IMAGE]:!1},this.duplicateFilterEnabled={[ie.CRIT_BARCODE]:!1,[ie.CRIT_TEXT_LINE]:!1,[ie.CRIT_DETECTED_QUAD]:!1,[ie.CRIT_DESKEWED_IMAGE]:!1},this.duplicateForgetTime={[ie.CRIT_BARCODE]:3e3,[ie.CRIT_TEXT_LINE]:3e3,[ie.CRIT_DETECTED_QUAD]:3e3,[ie.CRIT_DESKEWED_IMAGE]:3e3},this.crossVerificationCriteria={[ie.CRIT_BARCODE]:{frameWindow:5,minConsistentFrames:2},[ie.CRIT_TEXT_LINE]:{frameWindow:5,minConsistentFrames:2},[ie.CRIT_DETECTED_QUAD]:{frameWindow:6,minConsistentFrames:4},[ie.CRIT_DESKEWED_IMAGE]:{frameWindow:6,minConsistentFrames:4}},En.set(this,new Map),yn.set(this,new Map),In.set(this,new Map),vn.set(this,new Map),Rn.set(this,new Map),Cn.set(this,new Map),this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,this.latestOverlappingEnabled={[ie.CRIT_BARCODE]:!1,[ie.CRIT_TEXT_LINE]:!1,[ie.CRIT_DETECTED_QUAD]:!1,[ie.CRIT_DESKEWED_IMAGE]:!1},this.maxOverlappingFrames={[ie.CRIT_BARCODE]:this.crossVerificationFrames,[ie.CRIT_TEXT_LINE]:this.crossVerificationFrames,[ie.CRIT_DETECTED_QUAD]:this.crossVerificationFrames,[ie.CRIT_DESKEWED_IMAGE]:this.crossVerificationFrames},Object.defineProperties(this,{onOriginalImageResultReceived:{value:e=>{},writable:!1},onDecodedBarcodesReceived:{value:e=>{this.latestOverlappingFilter(e),An(this,e,ie.CRIT_BARCODE)},writable:!1},onRecognizedTextLinesReceived:{value:e=>{An(this,e,ie.CRIT_TEXT_LINE)},writable:!1},onProcessedDocumentResultReceived:{value:e=>{},writable:!1},onParsedResultsReceived:{value:e=>{const t=e.items;for(let e=t.length-1;e>=0;e--)t[e].type===ie.CRIT_PARSED_RESULT&&t[e].isFilter&&t.splice(e,1);e.parsedResult&&(e.parsedResult.parsedResultItems=e.parsedResult.parsedResultItems.filter(e=>!e.isFilter),0===e.parsedResult.parsedResultItems.length&&delete e.parsedResult)},writable:!1}})}_dynamsoft(){qs(this,En,"f").forEach((e,t)=>{Sn(t,this.verificationEnabled,e)}),qs(this,yn,"f").forEach((e,t)=>{Sn(t,this.duplicateFilterEnabled,e)}),qs(this,In,"f").forEach((e,t)=>{Sn(t,this.duplicateForgetTime,e)}),qs(this,vn,"f").forEach((e,t)=>{Sn(t,this.latestOverlappingEnabled,e)}),qs(this,Rn,"f").forEach((e,t)=>{Sn(t,this.maxOverlappingFrames,e)}),qs(this,Cn,"f").forEach((e,t)=>{Sn(t,this.crossVerificationCriteria,e)})}enableResultCrossVerification(e,t=!0){if("number"==typeof e){const i=Dn(e);for(let e of i)qs(this,En,"f").set(e,t)}else qs(this,En,"f").set(e,t)}isResultCrossVerificationEnabled(e){return wn(e,this.verificationEnabled)}enableResultDeduplication(e,t=!0){if(t&&this.enableLatestOverlapping(e,!1),"number"==typeof e){const i=Dn(e);for(let e of i)qs(this,yn,"f").set(e,t)}else qs(this,yn,"f").set(e,t)}isResultDeduplicationEnabled(e){return wn(e,this.duplicateFilterEnabled)}setDuplicateForgetTime(e,t){if(t>18e4&&(t=18e4),t<0&&(t=0),"number"==typeof e){const i=Dn(e);for(let e of i)qs(this,In,"f").set(e,t)}else qs(this,In,"f").set(e,t)}getDuplicateForgetTime(e){return wn(e,this.duplicateForgetTime)}getFilteredResultItemTypes(){let e=0;const t=[ie.CRIT_BARCODE,ie.CRIT_TEXT_LINE,ie.CRIT_DETECTED_QUAD,ie.CRIT_DESKEWED_IMAGE,ie.CRIT_ENHANCED_IMAGE];for(let i=0;i<t.length;i++)(this.verificationEnabled[t[i]]||this.duplicateFilterEnabled[t[i]])&&(e|=t[i]);return e}setResultCrossVerificationCriteria(e,t,i){if(t<i&&(t=i),"number"==typeof e){const s=Dn(e);for(let e of s)qs(this,Cn,"f").set(e,{frameWindow:t,minConsistentFrames:i})}else qs(this,Cn,"f").set(e,{frameWindow:t,minConsistentFrames:i})}getResultCrossVerificationCriteria(e){return wn(e,this.crossVerificationCriteria)}enableLatestOverlapping(e,t=!0){if(t&&this.enableResultDeduplication(e,!1),"number"==typeof e){const i=Dn(e);for(let e of i)qs(this,vn,"f").set(e,t)}else qs(this,vn,"f").set(e,t)}isLatestOverlappingEnabled(e){return wn(e,this.latestOverlappingEnabled)}setMaxOverlappingFrames(e,t){if("number"==typeof e){const i=Dn(e);for(let e of i)qs(this,Rn,"f").set(e,t)}else qs(this,Rn,"f").set(e,t)}getMaxOverlappingFrames(e){return wn(e,this.maxOverlappingFrames)}latestOverlappingFilter(e){var t,i,s;const n=this.isResultCrossVerificationEnabled(ie.CRIT_BARCODE),r=this.isLatestOverlappingEnabled(ie.CRIT_BARCODE);if(r){const o=this.crossVerificationFrames,a=60,c=r?this.getMaxOverlappingFrames(ie.CRIT_BARCODE):this.crossVerificationFrames,l=e.items.length,d=null===(s=null===(i=null===(t=null==e?void 0:e.intermediateResult)||void 0===t?void 0:t[0])||void 0===i?void 0:i.intermediateResultUnits)||void 0===s?void 0:s[1].localizedBarcodes,u=d?d.length:0;let h=[];const _=[],m={x:0,y:0};let g=new Array(l).fill(-1),f=0;const p=e.items.map(e=>{if(1!==e.type){const t=(BigInt(e.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0);return new pn(c,t?1:2,t,e)}}).filter(Boolean);if(this.overlapSet.length>0){const e=new Array(l).fill(new Array(this.overlapSet.length).fill(1));let t=0;for(;t<l;){const i={x:0,y:0},s=new Array(l).fill(-1);let n=!1;for(;t<l;t++){if(!p[t])continue;const r=p[t].item;for(let o=0;o<this.overlapSet.length;o++){if(e[t][o]<1)continue;const a=this.overlapSet[o],c=a.item;if(r.format===c.format&&r.text===c.text){if(n=a.isProbablySameLocationWithOffset(p[t],i),n){s[t]=o,e[t][o]=0;break}}else e[t][o]=0}if(n)break}if(n){for(let n=0;n<l;n++){if(n===t||!p[n])continue;const r=p[n].item;for(let t=0;t<this.overlapSet.length;t++){if(e[n][t]<1)continue;if(s.includes(t))continue;const o=this.overlapSet[t],a=o.item;if(r.format===a.format&&r.text===a.text){if(o.isMatchedLocationWithOffset(p[n],i)){s[n]=t,e[n][t]=0;break}}else e[n][t]=0}}const n=s.filter(e=>-1!==e).length;n>f&&(f=n,g=s,m.x=i.x,m.y=i.y)}}if(0===f){for(let t=0;t<l;t++){const i=p[t].item;for(let s=0;s<this.overlapSet.length;s++){if(e[t][s]<1)continue;if(g.includes(s))continue;const n=this.overlapSet[s],r=n.item;if(i.format===r.format&&i.text===r.text){if(n.isMatchedLocationWithOffset(p[t])){g[t]=s,e[t][s]=0;break}}else e[t][s]=0}}f+=g.filter(e=>-1!=e).length}let i=this.overlapSet.length<=3?f>=1:f>=2;if(!i&&r&&u>0){let e=0;for(let t=0;t<this.overlapSet.length;t++){const i=this.overlapSet[t];for(let t=0;t<u;t++)if(i.isOverlappedLocationWithOffset(d[t],m)){e++;break}}i=this.overlapSet.length<=3?e>=1:e>=3}i||(this.overlapSet=[])}if(0===this.overlapSet.length)this.stabilityCount=0,e.items.forEach((e,t)=>{if(1!==e.type){const i=Object.assign({},e),s=(BigInt(e.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0),r=e.confidence<a,o=new pn(c,s?1:2,s,i);n&&s&&r&&_.push(t),this.overlapSet.push(o)}});else{let t=!0;r?(Math.abs(m.x)>5||Math.abs(m.y)>5)&&(t=!1):t=!1;for(let i=0;i<e.items.length;i++){const e=g[i];if(e<0&&p[i]){const e=p[i].item;let s={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};for(let i=0;i<4;i++)s.points[i].x=t?e.location.points[i].x-m.x:e.location.points[i].x,s.points[i].y=t?e.location.points[i].y-m.y:e.location.points[i].y;for(let n=0;n<this.overlapSet.length;n++){if(g.includes(n))continue;const r=this.overlapSet[n].item.text,o=this.overlapSet[n].item.format;if(e.format===o&&e.text===r){if(this.overlapSet[n].isOverlappedLocationWithOffset(e,m,!1)){const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0),r=s?1:2;this.overlapSet[n]=new pn(c,r,s,t),g[i]=n;break}if(p[i].isOneD){let r={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};for(let e=0;e<4;e++)r.points[e].x=t?this.overlapSet[n].location.points[e].x:this.overlapSet[n].location.points[e].x+m.x,r.points[e].y=t?this.overlapSet[n].location.points[e].y:this.overlapSet[n].location.points[e].y+m.y;let o={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};if(fn(s,r,e.moduleSize,o)){e.location=o;const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0),r=s?1:2;this.overlapSet[n]=new pn(c,r,s,t),g[i]=n;break}}}}}else{if(t)p[i]&&(p[i].item.location=this.overlapSet[e].location);else{const t=Object.assign({},p[i].item),s=(BigInt(t.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0),n=s?1:2;this.overlapSet[e]=new pn(c,n,s,t)}this.overlapSet[e]&&(this.overlapSet[e].overlapCount=c,this.overlapSet[e].verificationCount=2,this.overlapSet[e].crossVerificationFrame=o)}}t?this.stabilityCount<15&&this.stabilityCount++:this.stabilityCount=0;let i=!0;for(let e=0;e<this.overlapSet.length;e++){if(g.includes(e))continue;const s=this.overlapSet[e];s.overlapCount--,s.crossVerificationFrame--;const n=s.overlapCount+this.stabilityCount;if(r&&n>0){for(let e=0;e<l;e++)if(s.isOverlappedLocationWithOffset(p[e],m,!1)){i=!1;break}if(!i)break;const e=s.item;if(!t){for(let e=0;e<4;e++)s.location.points[e].x+=m.x,s.location.points[e].y+=m.y;e.location=s.location}2===s.verificationCount&&h.push(e)}}if(r&&!i){h=[];for(let e=0;e<this.overlapSet.length;e++){if(g.includes(e))continue;const t=this.overlapSet[e];t.overlapCount=0-this.stabilityCount,t.crossVerificationFrame=0,t.verificationCount=0}}for(let e=0;e<l;e++){if(-1!==g[e]||!p[e])continue;const i=p[e].item;if(t){for(let t=0;t<4;t++)p[e].location.points[t].x-=m.x,p[e].location.points[t].y-=m.y;i.location=p[e].location}let s=!1;for(let t of this.overlapSet)if(!(t.crossVerificationFrame<=0&&t.verificationCount<=0)&&(s=t.isLocationOverlap(p[e].location,p[e].locationArea),s))break;if(s){_.push(e);continue}const r=Object.assign({},i),o=(BigInt(i.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(i.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0),l=i.confidence<a,d=new pn(c,o?1:2,o,r);n&&o&&l?_.push(e):d.verificationCount=2,this.overlapSet.push(d)}this.overlapSet=this.overlapSet.filter(e=>!(e.overlapCount+this.stabilityCount<=0&&e.crossVerificationFrame<=0))}_.sort((e,t)=>t-e).forEach((t,i)=>{e.items.splice(t,1)}),h.forEach(t=>{e.items.push(Object.assign(Object.assign({},t),{overlapped:!0}))})}}}var Ln,On,Nn,Mn;En=new WeakMap,yn=new WeakMap,In=new WeakMap,vn=new WeakMap,Rn=new WeakMap,Cn=new WeakMap;class Bn{static async readFromFile(e){if("string"==typeof e){if(!A(e))return Promise.reject(new TypeError("The input string is not a valid URL."));{const t=await fetch(e);e=await t.blob()}}return await x(e)}static async saveToFile(e,t,i){if(!e||!t)return null;if("string"!=typeof t)throw new TypeError("FileName must be of type string.");const s=F(e);return L(s,t,i)}static async readFromMemory(e){if(!qs(Bn,Ln,"f",On).has(e))throw new Error("Image data ID does not exist.");return qs(Bn,Ln,"f",On).get(e)}static async saveToMemory(e,t){var i,s,n;const r=await on(e,t),o=await x(r),a=(function(e,t,i,s,n){if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");n?n.value=i:t.set(e,i)}(i=Bn,Ln,(n=qs(i,Ln,"f",Nn),s=n++,n),0,Nn),s);return qs(Bn,Ln,"f",On).set(a,o),a}static async readFromBase64String(e){const t=await(async e=>{let t,i="image/png";if(e.includes("base64,")){const s=e.split(","),n=s[0].match(/:(.*?);/);n&&(i=n[1]),t=atob(s[1])}else t=atob(e);const s=new ArrayBuffer(t.length),n=new Uint8Array(s);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new Blob([n],{type:i})})(e);return await x(t)}static async saveToBase64String(e,t){e instanceof Blob&&(e=await x(e));let i=F(e);const s=await on(i,t);return await(async e=>await new Promise((t,i)=>{const s=new FileReader;s.onload=()=>{t(s.result)},s.onerror=e=>{i(e)},s.readAsDataURL(e)}))(s)}}Ln=Bn,On={value:new Map},Nn={value:0};!function(e){e[e.FT_HIGH_PASS=0]="FT_HIGH_PASS",e[e.FT_SHARPEN=1]="FT_SHARPEN",e[e.FT_SMOOTH=2]="FT_SMOOTH"}(Mn||(Mn={}));var Fn,xn,Pn,kn,Un,Vn,Gn,Wn,jn,Zn,Hn,qn,Yn,$n,zn,Kn,Xn,Qn,Jn,er,tr,ir,sr,nr,rr,or,ar,cr,lr,dr,ur,hr,_r,mr,gr,fr=Object.freeze({__proto__:null,get EnumFilterType(){return Mn},ImageDrawer:class{static async drawOnImage(e,t,i,s=4294901760,n=1,r="test.png",o){if(!e)throw new Error("Invalid image.");if(!t)throw new Error("Invalid drawingItem.");if(!i)throw new Error("Invalid type.");let a;if(e instanceof Blob)a=await x(e);else if("string"==typeof e){let t=await S(e,"blob");a=await x(t)}else C(e)&&(a=e,"bigint"==typeof a.format&&(a.format=Number(a.format)));return await new Promise((e,c)=>{let l=Re();Ce[l]=async t=>{if(t.success)return o&&Bn.saveToFile(t.image,r,o),e(t.image);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,c(e)}},Ie.postMessage({type:"utility_drawOnImage",id:l,body:{dsImage:a,drawingItem:Array.isArray(t)?t:[t],color:s,thickness:n,type:i}})})}},ImageIO:Bn,ImageProcessor:class{static async cropImage(e,t){const{bytes:i,width:s,height:n,stride:r,format:o}=C(e)?e:await x(e);return await new Promise((e,a)=>{let c=Re();Ce[c]=async t=>{if(t.success)return e(t.cropImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,a(e)}},Ie.postMessage({type:"utility_cropImage",id:c,body:{type:"Rect",bytes:i,width:s,height:n,stride:r,format:o,roi:t}})})}static async adjustBrightness(e,t){const{bytes:i,width:s,height:n,stride:r,format:o}=C(e)?e:await x(e);return await new Promise((e,a)=>{let c=Re();Ce[c]=async t=>{if(t.success)return e(t.adjustBrightness);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,a(e)}},Ie.postMessage({type:"utility_adjustBrightness",id:c,body:{bytes:i,width:s,height:n,stride:r,format:o,brightness:t}})})}static async adjustContrast(e,t){const{bytes:i,width:s,height:n,stride:r,format:o}=C(e)?e:await x(e);return await new Promise((e,a)=>{let c=Re();Ce[c]=async t=>{if(t.success)return e(t.adjustContrast);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,a(e)}},Ie.postMessage({type:"utility_adjustContrast",id:c,body:{bytes:i,width:s,height:n,stride:r,format:o,contrast:t}})})}static async filterImage(e,t){if(![0,1,2].includes(t))throw new Error("Invalid filterType.");const{bytes:i,width:s,height:n,stride:r,format:o}=C(e)?e:await x(e);return await new Promise((e,a)=>{let c=Re();Ce[c]=async t=>{if(t.success)return e(t.filterImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,a(e)}},Ie.postMessage({type:"utility_filterImage",id:c,body:{bytes:i,width:s,height:n,stride:r,format:o,filterType:t}})})}static async convertToGray(e,t,i,s){const{bytes:n,width:r,height:o,stride:a,format:c}=C(e)?e:await x(e);return await new Promise((e,l)=>{let d=Re();Ce[d]=async t=>{if(t.success)return e(t.convertToGray);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,l(e)}},Ie.postMessage({type:"utility_convertToGray",id:d,body:{bytes:n,width:r,height:o,stride:a,format:c,R:t,G:i,B:s}})})}static async convertToBinaryGlobal(e,t=-1,i=!1){const{bytes:s,width:n,height:r,stride:o,format:a}=C(e)?e:await x(e);return await new Promise((e,c)=>{let l=Re();Ce[l]=async t=>{if(t.success)return e(t.convertToBinaryGlobal);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,c(e)}},Ie.postMessage({type:"utility_convertToBinaryGlobal",id:l,body:{bytes:s,width:n,height:r,stride:o,format:a,threshold:t,invert:i}})})}static async convertToBinaryLocal(e,t=0,i=10,s=!1){const{bytes:n,width:r,height:o,stride:a,format:c}=C(e)?e:await x(e);return await new Promise((e,l)=>{let d=Re();Ce[d]=async t=>{if(t.success)return e(t.convertToBinaryLocal);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,l(e)}},Ie.postMessage({type:"utility_convertToBinaryLocal",id:d,body:{bytes:n,width:r,height:o,stride:a,format:c,blockSize:t,compensation:i,invert:s}})})}static async cropAndDeskewImage(e,t,i=0,s=0,n=0){const{bytes:r,width:o,height:a,stride:c,format:l}=C(e)?e:await x(e);return await new Promise((e,d)=>{let u=Re();Ce[u]=async t=>{if(t.success)return e(t.cropAndDeskewImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,d(e)}},Ie.postMessage({type:"utility_cropAndDeskewImage",id:u,body:{bytes:r,width:o,height:a,stride:c,format:l,roi:t,dstWidth:i,dstHeight:s,padding:n}})})}},MultiFrameResultCrossFilter:bn,UtilityModule:class{static getVersion(){return`2.4.20-dev-20260415104100(Worker: ${De.utility&&De.utility.worker||"Not Loaded"}, Wasm: ${De.utility&&De.utility.wasm||"Not Loaded"})`}}});class pr{constructor(t){if(Fn.add(this),Un.set(this,void 0),Vn.set(this,!1),Gn.set(this,void 0),Wn.set(this,void 0),jn.set(this,void 0),Zn.set(this,void 0),Hn.set(this,{status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},barcodeResults:[]}),this.config=Rs(Fe),t&&"object"!=typeof t||Array.isArray(t))throw"Invalid config.";Is(this.config,t)}get disposed(){return i(this,Vn,"f")}launch(){return t(this,void 0,void 0,function*(){if(i(this,Vn,"f"))throw new Error("The BarcodeScanner instance has been destroyed.");if(i(pr,xn,"f",Pn)&&!i(pr,xn,"f",Pn).isFulfilled&&!i(pr,xn,"f",Pn).isRejected)throw new Error("Cannot call `launch()` while a previous task is still running.");if(s(pr,xn,new ke,"f",Pn),!gs.getDeviceFriendlyName())try{gs.setDeviceFriendlyName("dbr_rtu")}catch(e){}return i(this,Fn,"m",qn).call(this),i(pr,xn,"f",Pn)})}decode(e,n="ReadBarcodes_Default"){return t(this,void 0,void 0,function*(){yield i(this,Fn,"m",Yn).call(this,!0),i(this,Zn,"f")||s(this,Zn,new bn,"f"),i(this,Zn,"f").enableResultCrossVerification(2,!1),yield this._cvRouter.addResultFilter(i(this,Zn,"f"));const t=new Ut;t.onCapturedResultReceived=()=>{},this._cvRouter.addResultReceiver(t);const r=yield this._cvRouter.capture(e,n);return i(this,Zn,"f").enableResultCrossVerification(2,!0),yield this._cvRouter.addResultFilter(i(this,Zn,"f")),this._cvRouter.removeResultReceiver(t),r})}dispose(){var e,t,n,r,o,a,c;s(this,Vn,!0,"f"),i(pr,xn,"f",Pn)&&i(pr,xn,"f",Pn).isPending&&i(pr,xn,"f",Pn).resolve(i(this,Hn,"f")),null===(e=this._cameraEnhancer)||void 0===e||e.dispose(),null===(t=this._cameraView)||void 0===t||t.dispose(),null===(n=this._cvRouter)||void 0===n||n.dispose(),this._cameraEnhancer=null,this._cameraView=null,this._cvRouter=null,window.removeEventListener("resize",i(this,Un,"f")),null===(r=document.querySelector(".scanner-view-container"))||void 0===r||r.remove(),null===(o=document.querySelector(".result-view-container"))||void 0===o||o.remove(),null===(a=document.querySelector(".barcode-scanner-container"))||void 0===a||a.remove(),null===(c=document.querySelector(".loading-page"))||void 0===c||c.remove()}}function Er(e){delete e.moduleId;const t=JSON.parse(e.jsonString).ResultInfo,i=e.fullCodeString,s=e.fieldNames;e.getFieldValue=e=>"fullcodestring"===e.toLowerCase()?i:yr(t,e,"map"),e.getFieldRawValue=e=>"fullcodestring"===e.toLowerCase()?i:yr(t,e,"raw"),e.getFieldMappingStatus=e=>Ir(t,e),e.getFieldValidationStatus=e=>vr(t,e),e.getAllFieldNames=()=>s,delete e.fieldNames,delete e.fullCodeString}function yr(e,t,i){for(let s of e){if(s.FieldName===t)return"raw"===i&&s.RawValue?s.RawValue:s.Value;if(s.ChildFields&&s.ChildFields.length>0){let e;for(let n of s.ChildFields)e=yr(n,t,i);if(void 0!==e)return e}}}function Ir(e,t){for(let i of e){if(i.FieldName===t)return i.MappingStatus?Number(mr[i.MappingStatus]):mr.MS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let e;for(let s of i.ChildFields)e=Ir(s,t);if(void 0!==e)return e}}return mr.MS_NONE}function vr(e,t){for(let i of e){if(i.FieldName===t&&i.ValidationStatus)return i.ValidationStatus?Number(gr[i.ValidationStatus]):gr.VS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let e;for(let s of i.ChildFields)e=vr(s,t);if(void 0!==e)return e}}return gr.VS_NONE}function Rr(e){if(e.disposed)throw new Error('"CodeParser" instance has been disposed')}xn=pr,Un=new WeakMap,Vn=new WeakMap,Gn=new WeakMap,Wn=new WeakMap,jn=new WeakMap,Zn=new WeakMap,Hn=new WeakMap,Fn=new WeakSet,qn=function(){return t(this,void 0,void 0,function*(){try{if(this.config.onInitPrepare&&this.config.onInitPrepare(),this.disposed)return;if(yield i(this,Fn,"m",Yn).call(this),this.config.onInitReady&&this.config.onInitReady({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed)return;let e=!1;try{if(document.querySelector(".loading-page span").innerText="Accessing Camera...",yield this._cameraEnhancer.open(),vs(this._cameraEnhancer.getSelectedCamera())&&this.config.scannerViewConfig.mirrorFrontCamera&&(this._cameraEnhancer.isMirrored=!0),this.config.onCameraOpen&&this.config.onCameraOpen({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed)return}catch(t){i(this,Fn,"m",ur).call(this,{auto:!1,open:!1,close:!1,notSupport:!1}),document.querySelector(".btn-camera-switch-control").style.display="none";if(document.querySelector(".no-camera-view").style.display="flex",this.config.onCameraOpenFailed&&this.config.onCameraOpenFailed(t),e=!0,this.disposed)return}if(this.config.autoStartCapturing&&!e&&(yield this._cvRouter.startCapturing(i(this,Wn,"f")),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed))return}catch(t){i(this,Hn,"f").status={code:e.EnumResultStatus.RS_FAILED,message:t.message||t},i(pr,xn,"f",Pn).reject(new Error(i(this,Hn,"f").status.message)),this.dispose()}finally{i(this,Fn,"m",hr).call(this,"Loading...",!1)}})},Yn=function(n=!1){return t(this,void 0,void 0,function*(){Me.engineResourcePaths=this.config.engineResourcePaths;const t=b(Me.engineResourcePaths);if(!n){let n=i(pr,xn,"f",kn).get("dceUI");if(n||(n=yield S(t.dbrBundle+"ui/dce.rtu.ui.xml","text"),i(pr,xn,"f",kn).set("dceUI",n)),this.disposed)return;if(this._cameraView=yield Ei.createInstance(n),this.disposed)return;if(this.config.scanMode===e.EnumScanMode.SM_SINGLE||this.config.scannerViewConfig.customHighlightForBarcode){this._cameraView.getDrawingLayer(2).setVisible(!1)}if(this._cameraEnhancer=yield pi.createInstance(this._cameraView),this.disposed)return;if(yield i(this,Fn,"m",zn).call(this),this.disposed)return;this.config.scannerViewConfig.customHighlightForBarcode&&s(this,jn,this._cameraEnhancer.getCameraView().createDrawingLayer(),"f")}if([null,void 0].includes(this.config.license)||(gs._onAuthMessage=e=>e.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&deploymenttype=web)"),yield gs.initLicense(this.config.license,{executeNow:!0})),this.disposed)return;if(this._cvRouter=this._cvRouter||(yield kt.createInstance(!1)),this._cvRouter._s=!0,this.disposed)return;let r=i(pr,xn,"f",kn).get("presetTemplates");if(r||(r=yield S(t.dbrBundle+"templates/DBR-PresetTemplates.json","text"),i(pr,xn,"f",kn).set("presetTemplates",r)),yield this._cvRouter.initSettings(r),yield i(this,Fn,"m",$n).call(this,n),!this.disposed&&!n){if(this._cvRouter.setInput(this._cameraEnhancer),i(this,Fn,"m",sr).call(this),yield i(this,Fn,"m",nr).call(this),this.disposed)return;this._cvRouter.onCaptureError=e=>{i(pr,xn,"f",Pn).reject(new Error(e.message)),this.dispose()},this._cvRouter._dynamsoft=!(this.config.scanMode===e.EnumScanMode.SM_SINGLE)}})},$n=function(n=!1){return t(this,void 0,void 0,function*(){n||(this.config.scanMode===e.EnumScanMode.SM_SINGLE?s(this,Wn,this.config.utilizedTemplateNames.single,"f"):this.config.scanMode===e.EnumScanMode.SM_MULTI_UNIQUE&&s(this,Wn,this.config.utilizedTemplateNames.multi_unique,"f"));let t=this.config.templateFilePath;if(t){let e,s=!1;if(Ht(t)&&(s=t.reloadResource,t=t.path),s?(e=yield S(t,"text"),i(pr,xn,"f",kn).delete("templateFile")):(e=i(pr,xn,"f",kn).get("templateFile"),e||(e=yield S(t,"text"),i(pr,xn,"f",kn).set("templateFile",e))),this.disposed)return;if(yield this._cvRouter.initSettings(e),this.disposed)return}const r=yield this._cvRouter.outputSettings("*",!0);if(this.disposed)return;if(!n&&this.config.scanMode===e.EnumScanMode.SM_SINGLE)for(let e of r.CaptureVisionTemplates)e.OutputOriginalImage=1;let o=this.config.barcodeFormats;if(o){Array.isArray(o)||(o=[o]);const e=(e,t)=>t!==BigInt(0)&&(e&t)===t;for(let t of r.BarcodeReaderTaskSettingOptions){t.BarcodeFormatIds=[];for(let i in Ls)for(let s in o)e(o[s],Ls[i])&&t.BarcodeFormatIds.push(i)}}yield this._cvRouter.initSettings(r),this.disposed})},zn=function(){return t(this,void 0,void 0,function*(){let t,n,r=this.config.uiPath||b(this.config.engineResourcePaths).dbrBundle,o=!1;Ht(r)&&(o=r.reloadResource,r=r.path);let a=r.endsWith("/")?Us(r)+"ui/barcode-scanner.ui.xml":Us(r).slice(0,-1);if(o?(t=yield S(a,"text"),i(pr,xn,"f",kn).delete("dbsUI")):(t=i(pr,xn,"f",kn).get("dbsUI"),t||(t=yield S(a,"text"),i(pr,xn,"f",kn).set("dbsUI",t))),n=(e=>{if(!e.trim().startsWith("<"))throw Error("Unable to get valid HTMLElement.");const t=document.createElement("div");if(t.insertAdjacentHTML("beforeend",e),1===t.childElementCount&&t.firstChild instanceof HTMLTemplateElement)return t.firstChild.content;const i=new DocumentFragment;for(let e of t.children)i.append(e);return i})(t),this.disposed)return;if(n.querySelectorAll("style").forEach(e=>{document.head.appendChild(e.cloneNode(!0))}),this.config.scanMode===e.EnumScanMode.SM_SINGLE){const e=document.createElement("style");e.innerText="\n @keyframes result-option-flash {\n from {transform: translate(-50%, -50%) scale(1);}\n to {transform: translate(-50%, -50%) scale(0.8);}\n }\n ".trim();this._cameraView.getUIElement().shadowRoot.append(e)}s(this,Gn,n.querySelector(".result-item"),"f"),i(this,Fn,"m",Kn).call(this,n),i(this,Fn,"m",Xn).call(this,n),i(this,Fn,"m",Qn).call(this,n),i(this,Fn,"m",Jn).call(this,n),yield i(this,Fn,"m",er).call(this,n),i(this,Fn,"m",dr).call(this,n),i(this,Fn,"m",ir).call(this,n),i(this,Fn,"m",tr).call(this,n)})},Kn=function(e){var t,s,n;const r=e.querySelector(".btn-clear");if(r&&(r.addEventListener("click",()=>{i(this,Hn,"f").barcodeResults=[],i(this,Fn,"m",cr).call(this)}),null===(n=null===(s=null===(t=this.config)||void 0===t?void 0:t.resultViewConfig)||void 0===s?void 0:s.toolbarButtonsConfig)||void 0===n?void 0:n.clear)){const t=this.config.resultViewConfig.toolbarButtonsConfig.clear;r.style.display=t.isHidden?"none":"flex",r.className=t.className,r.innerText=t.label,t.isHidden&&(e.querySelector(".toolbar-btns").style.justifyContent="center")}},Xn=function(e){var t,i,s;const n=e.querySelector(".btn-done");if(n&&(n.addEventListener("click",()=>{const e=document.querySelector(".loading-page");e&&"none"===getComputedStyle(e).display&&this.dispose()}),null===(s=null===(i=null===(t=this.config)||void 0===t?void 0:t.resultViewConfig)||void 0===i?void 0:i.toolbarButtonsConfig)||void 0===s?void 0:s.done)){const t=this.config.resultViewConfig.toolbarButtonsConfig.done;n.style.display=t.isHidden?"none":"flex",n.className=t.className,n.innerText=t.label,t.isHidden&&(e.querySelector(".toolbar-btns").style.justifyContent="center")}},Qn=function(t){var s,n;if(null===(n=null===(s=this.config)||void 0===s?void 0:s.scannerViewConfig)||void 0===n?void 0:n.showCloseButton){const s=t.querySelector(".btn-close");s&&(s.style.display="inline",s.addEventListener("click",()=>{i(this,Hn,"f").barcodeResults=[],i(this,Hn,"f").status={code:e.EnumResultStatus.RS_CANCELLED,message:"Cancelled."},this.dispose()}))}},Jn=function(e){var s;if(null===(s=this.config)||void 0===s?void 0:s.scannerViewConfig.showFlashButton){const s=e.querySelector(".btn-flash-auto"),n=e.querySelector(".btn-flash-open"),r=e.querySelector(".btn-flash-close");s&&(s.style.display="inline",this._cameraEnhancer.addEventListener("opened",()=>t(this,void 0,void 0,function*(){var e;if(!this._cameraEnhancer.currentCamera)return void i(this,Fn,"m",ur).call(this,{auto:!1,open:!1,close:!1,notSupport:!1});const t=this._cameraEnhancer.isSupportTorch;for(this.config.scannerViewConfig.showFlashButton&&(t?i(this,Fn,"m",ur).call(this,{auto:!0,open:!1,close:!1,notSupport:!1}):i(this,Fn,"m",ur).call(this,{auto:!1,open:!1,close:!1,notSupport:!0})),yield new Promise(e=>setTimeout(e,1e3));null===(e=this._cameraEnhancer)||void 0===e?void 0:e._isOpenBeforeHide;)yield new Promise(e=>setTimeout(e,1e3));this.disposed||this._cameraEnhancer.isOpen()&&t&&this._cameraEnhancer.turnAutoTorch()})),s.addEventListener("click",()=>t(this,void 0,void 0,function*(){yield this._cameraEnhancer.turnOnTorch(),s.style.display="none",n.style.display="inline",r.style.display="none"})),n.addEventListener("click",()=>t(this,void 0,void 0,function*(){yield this._cameraEnhancer.turnOffTorch(),s.style.display="none",n.style.display="none",r.style.display="inline"})),r.addEventListener("click",()=>t(this,void 0,void 0,function*(){this._cameraEnhancer.turnAutoTorch(),s.style.display="inline",n.style.display="none",r.style.display="none"})))}},er=function(e){return t(this,void 0,void 0,function*(){let s=this.config.scannerViewConfig.cameraSwitchControl;["toggleFrontBack","listAll","hidden"].includes(s)||(this.config.scannerViewConfig.cameraSwitchControl="hidden");if("hidden"!==this.config.scannerViewConfig.cameraSwitchControl){const s=e.querySelector(".camera-control");if(s){s.style.display="block";const n=yield this._cameraEnhancer.getAllCameras(),r=this.config.scannerViewConfig.cameraSwitchControl,o=e=>{const t=document.createElement("div");return t.label=e.label,t.deviceId=e.deviceId,t._checked=e._checked,t.innerText=e.label?e.label:`Camera ${e.deviceId.substring(0,7)}`,Object.assign(t.style,{height:"40px",backgroundColor:"#2E2E2E",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontSize:"14px",lineHeight:"40px",padding:"0 14px",cursor:"pointer"}),t},a=()=>{if(0===n.length)return null;if("listAll"===r){const s=e.querySelector(".camera-list");for(let e of n){const t=o(e);s.append(t)}window.addEventListener("click",()=>{const e=document.querySelector(".camera-list");e&&(e.style.display="none")});const r=e=>{for(let t of a)t.deviceId===e.deviceId?t.style.color="#FE8E14":t.style.color="#FFFFFF"};s.addEventListener("click",e=>t(this,void 0,void 0,function*(){e.stopPropagation();const t=e.target;i(this,Fn,"m",hr).call(this,"Accessing Camera...",!0),this._cvRouter.stopCapturing(),yield this._cameraEnhancer.selectCamera({deviceId:t.deviceId,label:t.label});const s=this._cameraEnhancer.getSelectedCamera();vs(s)&&this.config.scannerViewConfig.mirrorFrontCamera?this._cameraEnhancer.isMirrored=!0:this._cameraEnhancer.isMirrored=!1,r(s),this.config.onCameraOpen&&this.config.onCameraOpen({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.config.autoStartCapturing&&(yield this._cvRouter.startCapturing(i(this,Wn,"f")),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter})),i(this,Fn,"m",hr).call(this,"Loading...",!1)}));const a=e.querySelectorAll(".camera-list div");return()=>t(this,void 0,void 0,function*(){const e=this._cameraEnhancer.getSelectedCamera();r(e);const t=document.querySelector(".camera-list");"none"===getComputedStyle(t).display?t.style.display="block":t.style.display="none"})}return"toggleFrontBack"===r?()=>t(this,void 0,void 0,function*(){i(this,Fn,"m",hr).call(this,"Accessing Camera...",!0);const e=vs(this._cameraEnhancer.getSelectedCamera());yield this._cameraEnhancer.requestCamera(e?"back":"front");vs(this._cameraEnhancer.getSelectedCamera())?(this.config.scannerViewConfig.mirrorFrontCamera&&(this._cameraEnhancer.isMirrored=!0),this.config.scannerViewConfig.showFlashButton&&i(this,Fn,"m",ur).call(this,{auto:!1,open:!1,close:!1,notSupport:!0})):(this._cameraEnhancer.isMirrored=!1,this.config.scannerViewConfig.showFlashButton&&i(this,Fn,"m",ur).call(this,{auto:!0,open:!1,close:!1,notSupport:!1})),i(this,Fn,"m",hr).call(this,"Loading...",!1)}):void 0},c=a();s.addEventListener("click",e=>t(this,void 0,void 0,function*(){e.stopPropagation(),c&&(yield c())}))}}})},tr=function(t){const n=this._cameraView.getUIElement();this._cameraView.setVideoFit("cover");const r=t.querySelector(".barcode-scanner-container");r.style.display=Es()?"flex":"block",this.config.scanMode===e.EnumScanMode.SM_MULTI_UNIQUE&&!1!==this.config.showResultView?this.config.showResultView=!0:this.config.scanMode===e.EnumScanMode.SM_SINGLE&&(this.config.showResultView=!1);const o=this.config.showResultView;let a;if(this.config.container?(r.style.position="relative",a=this.config.container):a=document.body,"string"==typeof a&&(a=document.querySelector(a),null===a))throw new Error("Failed to get the container");let c=this.config.scannerViewConfig.container;if("string"==typeof c&&(c=document.querySelector(c),null===c))throw new Error("Failed to get the container of the scanner view.");let l=this.config.resultViewConfig.container;if("string"==typeof l&&(l=document.querySelector(l),null===l))throw new Error("Failed to get the container of the result view.");const d=t.querySelector(".scanner-view-container"),u=t.querySelector(".result-view-container"),h=t.querySelector(".loading-page");d.append(h),c&&(d.append(n),c.append(d)),l&&l.append(u),c||l?c&&!l?(this.config.container||(u.style.position="absolute"),l=u,a.append(u)):!c&&l&&(this.config.container||(d.style.position="absolute"),c=d,d.append(n),a.append(d)):(c=d,l=u,o&&(Object.assign(d.style,{width:Es()?"50%":"100%",height:Es()?"100%":"50%"}),Object.assign(u.style,{width:Es()?"50%":"100%",height:Es()?"100%":"50%"})),d.append(n),a.append(r)),document.querySelector(".result-view-container").style.display=o?"block":"none",this.config.showPoweredByDynamsoft||(this._cameraEnhancer.setPowerByMessageVisible(!1),document.querySelector(".no-result-svg").style.display="none"),s(this,Un,()=>{Object.assign(r.style,{display:Es()?"flex":"block"}),!o||this.config.scannerViewConfig.container||this.config.resultViewConfig.container||(Object.assign(c.style,{width:Es()?"50%":"100%",height:Es()?"100%":"50%"}),Object.assign(l.style,{width:Es()?"50%":"100%",height:Es()?"100%":"50%"}))},"f"),window.addEventListener("resize",i(this,Un,"f"))},ir=function(e){e.querySelector(".resume").addEventListener("click",()=>t(this,void 0,void 0,function*(){document.querySelector(".features-group").style.display="flex",document.querySelector(".btn-close").style.display="block",document.querySelector(".resume").style.display="none",this._cameraView.getUIElement().shadowRoot.querySelector(".single-mode-mask").remove(),this._cameraView.getUIElement().shadowRoot.querySelectorAll(".single-barcode-result-option").forEach(e=>e.remove()),yield this._cameraEnhancer.resume(),yield new Promise(e=>{setTimeout(e,100)}),this._cvRouter.startCapturing(i(this,Wn,"f"))}))},sr=function(){const s=new Ut;s.onCapturedResultReceived=s=>t(this,void 0,void 0,function*(){if(i(this,jn,"f")&&i(this,jn,"f").clearDrawingItems(),s.decodedBarcodesResult){if(this.config.scannerViewConfig.customHighlightForBarcode){let e=[];for(let t of s.decodedBarcodesResult.barcodeResultItems)e.push(this.config.scannerViewConfig.customHighlightForBarcode(t));i(this,jn,"f").addDrawingItems(e)}this.config.scanMode===e.EnumScanMode.SM_SINGLE?i(this,Fn,"m",rr).call(this,s):i(this,Fn,"m",or).call(this,s)}}),this._cvRouter.addResultReceiver(s)},nr=function(){return t(this,void 0,void 0,function*(){i(this,Zn,"f")||s(this,Zn,new bn,"f"),i(this,Zn,"f").enableResultCrossVerification(2,!0),i(this,Zn,"f").enableResultDeduplication(2,!0),i(this,Zn,"f").setDuplicateForgetTime(2,this.config.duplicateForgetTime),yield this._cvRouter.addResultFilter(i(this,Zn,"f")),i(this,Zn,"f").isResultCrossVerificationEnabled=()=>!1,i(this,Zn,"f").isResultDeduplicationEnabled=()=>!1})},rr=function(s){const n=this._cameraView.getUIElement().shadowRoot;let r=new Promise(e=>{if(s.decodedBarcodesResult.barcodeResultItems.length>1){i(this,Fn,"m",ar).call(this);let t=[];for(let i of s.decodedBarcodesResult.barcodeResultItems){let s=0,n=0;for(let e=0;e<4;++e){let t=i.location.points[e];s+=t.x,n+=t.y}let r=this._cameraEnhancer.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0}),o=this._cameraEnhancer.videoXY2FixedLT([{x:r.x+s/4,y:r.y+n/4}]),a=document.createElement("div");a.className="single-barcode-result-option",Object.assign(a.style,{position:"fixed",width:"25px",height:"25px",border:"#fff solid 4px",transform:"translate(-50%, -50%)",animation:"1s infinite alternate result-option-flash","box-sizing":"border-box","border-radius":"16px",background:"#080",cursor:"pointer"}),a.style.left=o[0].left+"px",a.style.top=o[0].top+"px",a.addEventListener("click",()=>{e(i)}),t.push(a)}n.append(...t)}else e(s.decodedBarcodesResult.barcodeResultItems[0])});r.then(n=>t(this,void 0,void 0,function*(){const t=s.items.filter(e=>e.type===ie.CRIT_ORIGINAL_IMAGE)[0],r=t.imageData,o={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},originalImageResult:r,barcodeImage:(()=>{const e=O(r),t=n.location.points,i=Math.min(...t.map(e=>e.x)),s=Math.min(...t.map(e=>e.y)),o=Math.max(...t.map(e=>e.x)),a=Math.max(...t.map(e=>e.y)),c=o-i,l=a-s,d=document.createElement("canvas");d.width=c,d.height=l;const u=d.getContext("2d");u.beginPath(),u.moveTo(t[0].x-i,t[0].y-s);for(let e=1;e<t.length;e++)u.lineTo(t[e].x-i,t[e].y-s);u.closePath(),u.clip(),u.drawImage(e,-i,-s);const h=u.getImageData(0,0,d.width,d.height);return{bytes:new Uint8Array(h.data),width:h.width,height:h.height,stride:4*h.width,format:_.IPF_ABGR_8888}})(),barcodeResults:[n]};i(this,Fn,"m",_r).call(this,n),i(pr,xn,"f",Pn).resolve(o),this.dispose()}))},or=function(e){for(let t of e.decodedBarcodesResult.barcodeResultItems){if(!1!==t.duplicate)continue;const e=i(this,Hn,"f").barcodeResults.findIndex(e=>`${e.formatString}_${e.text}`==`${t.formatString}_${t.text}`);-1===e?(t.count=1,i(this,Hn,"f").barcodeResults.unshift(t),i(this,Fn,"m",cr).call(this,t)):(i(this,Hn,"f").barcodeResults[e].count++,i(this,Fn,"m",lr).call(this,e)),this.config.onUniqueBarcodeScanned&&this.config.onUniqueBarcodeScanned(t)}},ar=function(){const e=this._cameraView.getUIElement().shadowRoot;if(e.querySelector(".single-mode-mask"))return;const t=document.createElement("div");t.className="single-mode-mask",Object.assign(t.style,{width:"100%",height:"100%",position:"absolute",top:"0",left:"0",right:"0",bottom:"0",opacity:"0.5","background-color":"#4C4C4C"}),e.append(t),document.querySelector(".features-group").style.display="none",document.querySelector(".btn-close").style.display="none",document.querySelector(".resume").style.display="block",this._cameraEnhancer.pause(),this._cvRouter.stopCapturing()},cr=function(t){if(!this.config.showResultView)return;const s=document.querySelector(".no-result-svg");if(!(this.config.showResultView&&this.config.scanMode!==e.EnumScanMode.SM_SINGLE))return;const n=document.querySelector(".main-list");if(!t)return n.textContent="",void(this.config.showPoweredByDynamsoft&&(s.style.display="inline"));s.style.display="none";const r=(e=>{const t=i(this,Gn,"f").cloneNode(!0);t.querySelector(".format-string").innerText=e.formatString;t.querySelector(".text-string").innerText=e.text.replace(/\n|\r/g,""),t.id=`${e.formatString}_${e.text}`;return t.querySelector(".delete-icon").addEventListener("click",()=>{const t=[...document.querySelectorAll(".main-list .result-item")],s=t.findIndex(t=>t.id===`${e.formatString}_${e.text}`);i(this,Hn,"f").barcodeResults.splice(s,1),t[s].remove(),0===i(this,Hn,"f").barcodeResults.length&&this.config.showPoweredByDynamsoft&&(document.querySelector(".no-result-svg").style.display="inline")}),t})(t);n.insertBefore(r,document.querySelector(".result-item"))},lr=function(e){if(!this.config.showResultView)return;const t=document.querySelectorAll(".main-list .result-item"),i=t[e].querySelector(".result-count");let s=parseInt(i.textContent.replace("x",""));t[e].querySelector(".result-count").textContent="x"+ ++s},dr=function(s){if(this.config.showUploadImageButton){const n=s.querySelector(".btn-upload-image");n.style.display="flex",n.onchange=s=>t(this,void 0,void 0,function*(){const t=s.target.files,n={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},barcodeResults:[]};let r=0;i(this,Fn,"m",hr).call(this,`Capturing... [${r}/${t.length}]`,!0);let o=!1;for(let e=0;e<t.length;e++)if(!Cs(t[e])){o=!0;break}if(o)return i(pr,xn,"f",Pn).reject(new Error("Upload failed: one or more files are in unsupported formats. Please make sure all files are .jpg,.jpeg,.ico,.gif,.svg,.webp,.png,.bmp.")),void this.dispose();for(let s of t)try{this._cvRouter.stopCapturing();const o=yield this.decode(s,this.config.utilizedTemplateNames.image);if(o.decodedBarcodesResult)if(this.config.scanMode===e.EnumScanMode.SM_MULTI_UNIQUE)for(let e of o.decodedBarcodesResult.barcodeResultItems){const t=i(this,Hn,"f").barcodeResults.findIndex(t=>`${t.formatString}_${t.text}`==`${e.formatString}_${e.text}`);-1===t?(e.count=1,i(this,Hn,"f").barcodeResults.unshift(e),i(this,Fn,"m",cr).call(this,e)):(i(this,Hn,"f").barcodeResults[t].count++,i(this,Fn,"m",lr).call(this,t))}else if(o.decodedBarcodesResult.barcodeResultItems)for(let e of o.decodedBarcodesResult.barcodeResultItems){const t=n.barcodeResults.find(t=>`${t.text}_${t.formatString}`==`${e.text}_${e.formatString}`);t?t.count++:(e.count=1,n.barcodeResults.push(e))}i(this,Fn,"m",hr).call(this,`Capturing... [${++r}/${t.length}]`,!0)}catch(t){return n.status={code:e.EnumResultStatus.RS_FAILED,message:t.message||t},i(pr,xn,"f",Pn).reject(new Error(n.status.message)),void this.dispose()}i(this,Fn,"m",hr).call(this,"Loading...",!1),this.config.scanMode===e.EnumScanMode.SM_SINGLE?(i(pr,xn,"f",Pn).resolve(n),this.dispose()):this._cvRouter.startCapturing(i(this,Wn,"f")),s.target.value=""})}},ur=function(e){document.querySelector(".btn-flash-not-support").style.display=e.notSupport?"inline":"none",document.querySelector(".btn-flash-auto").style.display=e.auto?"inline":"none",document.querySelector(".btn-flash-open").style.display=e.open?"inline":"none",document.querySelector(".btn-flash-close").style.display=e.close?"inline":"none"},hr=function(e,t){const i=document.querySelector(".loading-page"),s=document.querySelector(".loading-page span");s&&(s.innerText=e),i&&(i.style.display=t?"flex":"none")},_r=function(e){let t=Re();Ce[t]=()=>{},Ie.postMessage({type:"cvr_cc",id:t,instanceID:this._cvRouter._instanceID,body:{text:e.text,strFormat:e.format.toString(),isDPM:e.isDPM}})},Pn={value:null},kn={value:new Map},function(e){e[e.MS_NONE=0]="MS_NONE",e[e.MS_SUCCEEDED=1]="MS_SUCCEEDED",e[e.MS_FAILED=2]="MS_FAILED"}(mr||(mr={})),function(e){e[e.VS_NONE=0]="VS_NONE",e[e.VS_SUCCEEDED=1]="VS_SUCCEEDED",e[e.VS_FAILED=2]="VS_FAILED"}(gr||(gr={}));const Cr=e=>e&&"object"==typeof e&&"function"==typeof e.then,Tr=(async()=>{})().constructor;class wr extends Tr{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,Cr(e)?t=e:"function"==typeof e&&(t=new Tr(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(Cr(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}class Sr{constructor(){this._instanceID=void 0,this.bDestroyed=!1}static async createInstance(){await be.license.dynamsoft(),await Me.loadWasm();const e=new Sr,t=new wr;let i=Re();return Ce[i]=async i=>{if(i.success)e._instanceID=i.instanceID,t.resolve(e);else{const e=Error(i.message);i.stack&&(e.stack=i.stack),t.reject(e)}},Ie.postMessage({type:"dcp_createInstance",id:i}),t}async dispose(){Rr(this);let e=Re();this.bDestroyed=!0,Ce[e]=e=>{if(!e.success){let t=new Error(e.message);throw t.stack=e.stack+"\n"+t.stack,t}},Ie.postMessage({type:"dcp_dispose",id:e,instanceID:this._instanceID})}get disposed(){return this.bDestroyed}async initSettings(e){if(Rr(this),e&&["string","object"].includes(typeof e))return"string"==typeof e?e.trimStart().startsWith("{")||(e=await S(e,"text")):"object"==typeof e&&(e=JSON.stringify(e)),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success){const s=JSON.parse(e.response);if(0!==s.errorCode){let e=new Error(s.errorString?s.errorString:"Init Settings Failed.");return e.errorCode=s.errorCode,i(e)}return t(s)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},Ie.postMessage({type:"dcp_initSettings",id:s,instanceID:this._instanceID,body:{settings:e}})});console.error("Invalid settings.")}async resetSettings(){return Rr(this),await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"dcp_resetSettings",id:i,instanceID:this._instanceID})})}async parse(e,t=""){if(Rr(this),!e||!(e instanceof Array||e instanceof Uint8Array||"string"==typeof e))throw new Error("`parse` must pass in an Array or Uint8Array or string");return await new Promise((i,s)=>{let n=Re();e instanceof Array&&(e=Uint8Array.from(e)),"string"==typeof e&&(e=Uint8Array.from(function(e){let t=[];for(let i=0;i<e.length;++i)t.push(e.charCodeAt(i));return t}(e))),Ce[n]=async e=>{if(e.success){let t=JSON.parse(e.parseResponse);return t.errorCode?s(new Error(t.errorString)):(Er(t),i(t))}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,s(t)}},Ie.postMessage({type:"dcp_parse",id:n,instanceID:this._instanceID,body:{source:e,taskSettingName:t}})})}}const Ar="undefined"==typeof self,Dr="function"==typeof importScripts,br=(()=>{if(!Dr){if(!Ar&&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"./"}})();Me.engineResourcePaths.dcp={version:"3.4.20-dev-20260415104120",path:br,isInternal:!0},Le.dcp={js:!0,wasm:!0,deps:[fe.MN_DYNAMSOFT_LICENSE]},be.dcp={handleParsedResultItem:Er};const Lr="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,Lr)<0&&(Me.engineResourcePaths.std={version:Lr,path:(e=>{if(null==e&&(e="./"),Ar||Dr);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e})(br+`../../dynamsoft-capture-vision-std@${Lr}/dist/`),isInternal:!0}),Ce[-4]=async e=>{Or.onSpecLoadProgressChanged&&Or.onSpecLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class Or{static getVersion(){const e=De.dcp&&De.dcp.wasm;return`3.4.20-dev-20260415104120(Worker: ${De.dcp&&De.dcp.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}static async loadSpec(e,t){return await Me.loadWasm(),await new Promise((i,s)=>{let n=Re();Ce[n]=async e=>{if(e.success)return i(e.result);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,s(t)}},t&&!t.endsWith("/")&&(t+="/");let r=(e instanceof Array?e:[e]).map(e=>e.replace(/^MRTD.*$/,"MRTD"));r=r.map(e=>e.replace(/\.data$/i,""));let o=b(Me.engineResourcePaths);Ie.postMessage({type:"dcp_appendResourceBuffer",id:n,body:{specificationPath:t||`${"DBR"===Me._bundleEnv?o.dbrBundle:o.dcvData}parser-resources/`,specificationNames:r}})})}}var Nr;!function(e){e.CT_MRTD_TD1_ID="MRTD_TD1_ID",e.CT_MRTD_TD2_ID="MRTD_TD2_ID",e.CT_MRTD_TD2_VISA="MRTD_TD2_VISA",e.CT_MRTD_TD3_PASSPORT="MRTD_TD3_PASSPORT",e.CT_MRTD_TD3_VISA="MRTD_TD3_VISA",e.CT_MRTD_TD2_FRENCH_ID="MRTD_TD2_FRENCH_ID",e.CT_AAMVA_DL_ID="AAMVA_DL_ID",e.CT_AAMVA_DL_ID_WITH_MAG_STRIPE="AAMVA_DL_ID_WITH_MAG_STRIPE",e.CT_SOUTH_AFRICA_DL="SOUTH_AFRICA_DL",e.CT_AADHAAR="AADHAAR",e.CT_VIN="VIN",e.CT_GS1_AI="GS1_AI"}(Nr||(Nr={}));var Mr=Object.freeze({__proto__:null,CodeParser:Sr,CodeParserModule:Or,get EnumCodeType(){return Nr},get EnumMappingStatus(){return mr},get EnumValidationStatus(){return gr}});Me._bundleEnv="DBR",kt._defaultTemplate="ReadSingleBarcode",Me.engineResourcePaths.dbrBundle={version:"11.4.2001",path:ks,isInternal:!0},pi.CoreModule=Me,pi.handleEngineResourcePaths=b,e.BarcodeScanner=pr,e.CVR=Zt,e.Core=Be,e.DBR=Fs,e.DCE=$i,e.DCP=Mr,e.License=ps,e.Utility=fr,e.isPathConfig=Ht});
11
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Dynamsoft=t.Dynamsoft||{})}(this,function(e){"use strict";function t(e,t,i,s){return new(i||(i=Promise))(function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,a)}c((s=s.apply(e,t||[])).next())})}function i(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}function s(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i}var n,r;"function"==typeof SuppressedError&&SuppressedError,e.EnumScanMode=void 0,(n=e.EnumScanMode||(e.EnumScanMode={}))[n.SM_SINGLE=0]="SM_SINGLE",n[n.SM_MULTI_UNIQUE=1]="SM_MULTI_UNIQUE",e.EnumResultStatus=void 0,(r=e.EnumResultStatus||(e.EnumResultStatus={}))[r.RS_SUCCESS=0]="RS_SUCCESS",r[r.RS_CANCELLED=1]="RS_CANCELLED",r[r.RS_FAILED=2]="RS_FAILED";const o=e=>e&&"object"==typeof e&&"function"==typeof e.then,a=(async()=>{})().constructor;let c=class extends a{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,o(e)?t=e:"function"==typeof e&&(t=new a(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(o(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};function l(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}function d(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i}var u,h,_;"function"==typeof SuppressedError&&SuppressedError,function(e){e[e.BOPM_BLOCK=0]="BOPM_BLOCK",e[e.BOPM_UPDATE=1]="BOPM_UPDATE"}(u||(u={})),function(e){e[e.CCUT_AUTO=0]="CCUT_AUTO",e[e.CCUT_FULL_CHANNEL=1]="CCUT_FULL_CHANNEL",e[e.CCUT_Y_CHANNEL_ONLY=2]="CCUT_Y_CHANNEL_ONLY",e[e.CCUT_RGB_R_CHANNEL_ONLY=3]="CCUT_RGB_R_CHANNEL_ONLY",e[e.CCUT_RGB_G_CHANNEL_ONLY=4]="CCUT_RGB_G_CHANNEL_ONLY",e[e.CCUT_RGB_B_CHANNEL_ONLY=5]="CCUT_RGB_B_CHANNEL_ONLY"}(h||(h={})),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",e[e.IPF_BINARY_8=13]="IPF_BINARY_8",e[e.IPF_NV12=14]="IPF_NV12",e[e.IPF_BINARY_8_INVERTED=15]="IPF_BINARY_8_INVERTED"}(_||(_={}));const m="undefined"==typeof self,g="function"==typeof importScripts,f=(()=>{if(!g){if(!m&&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"./"}})(),p=e=>{if(null==e&&(e="./"),m||g);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},E=e=>Object.prototype.toString.call(e),y=e=>Array.isArray?Array.isArray(e):"[object Array]"===E(e),I=e=>"number"==typeof e&&!Number.isNaN(e),v=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),R=e=>!(!v(e)||!I(e.width)||e.width<=0||!I(e.height)||e.height<=0||!I(e.stride)||e.stride<=0||!("format"in e)||"tag"in e&&!T(e.tag)),C=e=>!!R(e)&&e.bytes instanceof Uint8Array,T=e=>null===e||!!v(e)&&!!I(e.imageId)&&"type"in e,w=e=>!!v(e)&&!!I(e.x)&&!!I(e.y),S=async(e,t,i)=>await new Promise((s,n)=>{let r=new XMLHttpRequest;r.responseType=t,r.onloadstart=()=>{i&&i.loadstartCallback&&i.loadstartCallback()},r.onloadend=async e=>{i&&i.loadendCallback&&i.loadendCallback(),r.status<200||r.status>=300?n(r.status):s(r.response)},r.onprogress=e=>{i&&i.progressCallback&&i.progressCallback(e)},r.onerror=e=>{n(e)},r.open("GET",e,!0),r.send()}),A=e=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(e),D=(e,t)=>{let i=e.split("."),s=t.split(".");for(let e=0;e<i.length&&e<s.length;++e){let t=i[e],n=s[e];if(t===n)continue;let r=parseInt(i[e]),o=parseInt(s[e]);return r===o||Number.isNaN(r)&&Number.isNaN(o)?t<n?-1:1:r<o||Number.isNaN(r)&&Number.isInteger(o)?-1:1}return i.length===s.length?0:i.length<s.length?-1:1},b=e=>{const t={};for(let i in e){if("rootDirectory"===i)continue;let s=i,n=e[s],r=n&&"object"==typeof n&&n.path?n.path:n,o=e.rootDirectory;if(o&&!o.endsWith("/")&&(o+="/"),"object"==typeof n&&n.isInternal)o&&(r=e[s].version?`${o}${P[s]}@${e[s].version}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`:`${o}${P[s]}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`);else{const i=/^@engineRootDirectory(\/?)/;if("string"==typeof r&&(r=r.replace(i,o||"")),"object"==typeof r&&"dwt"===s){const n=e[s].resourcesPath,r=e[s].serviceInstallerLocation;t[s]={resourcesPath:n.replace(i,o||""),serviceInstallerLocation:r.replace(i,o||"")};continue}}t[s]=p(r)}return t},L=async(e,t,i)=>await new Promise(async(s,n)=>{try{const n=t.split(".");let r=n[n.length-1];const o=await M(`image/${r}`,e);n.length<=1&&(r="png");const a=new File([o],t,{type:`image/${r}`});if(i){const e=URL.createObjectURL(a),i=document.createElement("a");i.href=e,i.download=t,i.click()}s(a)}catch(e){n()}}),O=e=>{C(e)&&(e=F(e));const t=document.createElement("canvas");return t.width=e.width,t.height=e.height,t.getContext("2d",{willReadFrequently:!0}).putImageData(e,0,0),t},N=(e,t)=>{C(t)&&(t=F(t));const i=O(t);let s=new Image,n=i.toDataURL(e);return s.src=n,s},M=async(e,t)=>{C(t)&&(t=F(t));const i=O(t);if("image/bmp"===e){const e=i.getContext("2d"),t=B(e.getImageData(0,0,i.width,i.height));return new Blob([t],{type:"image/bmp"})}return new Promise((t,s)=>{i.toBlob(e=>t(e),e)})},B=e=>{const t=e.width,i=e.height,s=e.data,n=4*Math.floor((24*t+31)/32),r=n*i,o=54+r,a=new ArrayBuffer(o),c=new DataView(a);c.setUint16(0,19778,!0),c.setUint32(2,o,!0),c.setUint16(6,0,!0),c.setUint16(8,0,!0),c.setUint32(10,54,!0),c.setUint32(14,40,!0),c.setInt32(18,t,!0),c.setInt32(22,-i,!0),c.setUint16(26,1,!0),c.setUint16(28,24,!0),c.setUint32(30,0,!0),c.setUint32(34,r,!0),c.setInt32(38,2835,!0),c.setInt32(42,2835,!0),c.setUint32(46,0,!0),c.setUint32(50,0,!0);let l=54;const d=n-3*t;for(let e=0;e<i;e++){for(let i=0;i<t;i++){const n=4*(e*t+i),r=s[n],o=s[n+1],a=s[n+2];c.setUint8(l++,a),c.setUint8(l++,o),c.setUint8(l++,r)}for(let e=0;e<d;e++)c.setUint8(l++,0)}return a},F=e=>{let t,i=e.bytes;if(!(i&&i instanceof Uint8Array))throw Error("Parameter type error");if(Number(e.format)===_.IPF_BGR_888){const e=i.length/3;t=new Uint8ClampedArray(4*e);for(let s=0;s<e;++s)t[4*s]=i[3*s],t[4*s+1]=i[3*s+1],t[4*s+2]=i[3*s+2],t[4*s+3]=255}else if(Number(e.format)===_.IPF_RGB_888){const e=i.length/3;t=new Uint8ClampedArray(4*e);for(let s=0;s<e;++s)t[4*s]=i[3*s+2],t[4*s+1]=i[3*s+1],t[4*s+2]=i[3*s],t[4*s+3]=255}else if(Number(e.format)===_.IPF_GRAYSCALED){const e=i.length;t=new Uint8ClampedArray(4*e);for(let s=0;s<e;s++)t[4*s]=t[4*s+1]=t[4*s+2]=i[s],t[4*s+3]=255}else if(Number(e.format)===_.IPF_BINARY_8||Number(e.format)===_.IPF_BINARY_8_INVERTED){const s=i.length,n=e.width,r=e.height,o=e.stride;t=new Uint8ClampedArray(n*r*4);for(let e=0;e<s;e++){let s=i[e],r=e%o,a=Math.floor(e/o);for(let e=0;e<8;e++){let i=r+e,o=4*(a*n+i);if(i>=n)break;t[o]=t[o+1]=t[o+2]=(128&s)/128*255,t[o+3]=255,s<<=1}}}else if(Number(e.format)===_.IPF_ABGR_8888){const e=i.length/4;t=new Uint8ClampedArray(i.length);for(let s=0;s<e;++s)t[4*s]=i[4*s],t[4*s+1]=i[4*s+1],t[4*s+2]=i[4*s+2],t[4*s+3]=i[4*s+3]}else if(Number(e.format)===_.IPF_ARGB_8888){const e=i.length/4;t=new Uint8ClampedArray(i.length);for(let s=0;s<e;++s)t[4*s]=i[4*s+2],t[4*s+1]=i[4*s+1],t[4*s+2]=i[4*s],t[4*s+3]=i[4*s+3]}else Number(e.format),_.IPF_BINARY_8_INVERTED;return new ImageData(t,e.width,e.height)},x=async e=>{let t=URL.createObjectURL(e);try{const e=await new Promise((e,i)=>{const s=new Image;s.onload=()=>e(s),s.onerror=i,s.src=t}),i=document.createElement("canvas"),s=i.getContext("2d");i.width=e.width,i.height=e.height,s.drawImage(e,0,0);return{bytes:Uint8Array.from(s.getImageData(0,0,i.width,i.height).data),width:i.width,height:i.height,stride:4*i.width,format:_.IPF_ABGR_8888}}finally{URL.revokeObjectURL(t)}},P={std:"dynamsoft-capture-vision-std",dip:"dynamsoft-image-processing",core:"dynamsoft-core",dnn:"dynamsoft-capture-vision-dnn",license:"dynamsoft-license",utility:"dynamsoft-utility",cvr:"dynamsoft-capture-vision-router",dbr:"dynamsoft-barcode-reader",dlr:"dynamsoft-label-recognizer",ddn:"dynamsoft-document-normalizer",dcp:"dynamsoft-code-parser",dcvData:"dynamsoft-capture-vision-data",dce:"dynamsoft-camera-enhancer",identityutility:"dynamsoft-identity-utility",ddv:"dynamsoft-document-viewer",dwt:"dwt",dbrBundle:"dynamsoft-barcode-reader-bundle",dcvBundle:"dynamsoft-capture-vision-bundle"};var k,U,V,G,W,j,Z,H;let q,Y,$,z,K,X=class e{get _isFetchingStarted(){return l(this,W,"f")}constructor(){k.add(this),U.set(this,[]),V.set(this,1),G.set(this,u.BOPM_BLOCK),W.set(this,!1),j.set(this,void 0),Z.set(this,h.CCUT_AUTO)}setErrorListener(e){}addImageToBuffer(e){var t;if(!C(e))throw new TypeError("Invalid 'image'.");if((null===(t=e.imageTag)||void 0===t?void 0:t.hasOwnProperty("imageId"))&&"number"==typeof e.imageTag.imageId&&this.hasImage(e.imageTag.imageId))throw new Error("Existed imageId.");if(l(this,U,"f").length>=l(this,V,"f"))switch(l(this,G,"f")){case u.BOPM_BLOCK:break;case u.BOPM_UPDATE:if(l(this,U,"f").push(e),v(l(this,j,"f"))&&I(l(this,j,"f").imageId)&&1==l(this,j,"f").keepInBuffer)for(;l(this,U,"f").length>l(this,V,"f");){const e=l(this,U,"f").findIndex(e=>{var t;return(null===(t=e.imageTag)||void 0===t?void 0:t.imageId)!==l(this,j,"f").imageId});l(this,U,"f").splice(e,1)}else l(this,U,"f").splice(0,l(this,U,"f").length-l(this,V,"f"))}else l(this,U,"f").push(e)}getImage(){if(0===l(this,U,"f").length)return null;let t;if(l(this,j,"f")&&I(l(this,j,"f").imageId)){const e=l(this,k,"m",H).call(this,l(this,j,"f").imageId);if(e<0)throw new Error(`Image with id ${l(this,j,"f").imageId} doesn't exist.`);t=l(this,U,"f").slice(e,e+1)[0]}else t=l(this,U,"f").pop();if([_.IPF_RGB_565,_.IPF_RGB_555,_.IPF_RGB_888,_.IPF_ARGB_8888,_.IPF_RGB_161616,_.IPF_ARGB_16161616,_.IPF_ABGR_8888,_.IPF_ABGR_16161616,_.IPF_BGR_888].includes(t.format)){if(l(this,Z,"f")===h.CCUT_RGB_R_CHANNEL_ONLY){e._onLog&&e._onLog("only get R channel data.");const i=new Uint8Array(t.width*t.height);for(let e=0;e<i.length;e++)switch(t.format){case _.IPF_RGB_565:case _.IPF_RGB_555:case _.IPF_RGB_888:case _.IPF_RGB_161616:i[e]=t.bytes[3*e+2];break;case _.IPF_ARGB_8888:case _.IPF_ARGB_16161616:i[e]=t.bytes[4*e+2];break;case _.IPF_BGR_888:i[e]=t.bytes[3*e];break;case _.IPF_ABGR_8888:case _.IPF_ABGR_16161616:i[e]=t.bytes[4*e]}t.bytes=i,t.stride=t.width,t.format=_.IPF_GRAYSCALED}else if(l(this,Z,"f")===h.CCUT_RGB_G_CHANNEL_ONLY){e._onLog&&e._onLog("only get G channel data.");const i=new Uint8Array(t.width*t.height);for(let e=0;e<i.length;e++)switch(t.format){case _.IPF_RGB_565:case _.IPF_RGB_555:case _.IPF_RGB_888:case _.IPF_RGB_161616:case _.IPF_BGR_888:i[e]=t.bytes[3*e+1];break;case _.IPF_ARGB_8888:case _.IPF_ARGB_16161616:case _.IPF_ABGR_8888:case _.IPF_ABGR_16161616:i[e]=t.bytes[4*e+1]}t.bytes=i,t.stride=t.width,t.format=_.IPF_GRAYSCALED}else if(l(this,Z,"f")===h.CCUT_RGB_B_CHANNEL_ONLY){e._onLog&&e._onLog("only get B channel data.");const i=new Uint8Array(t.width*t.height);for(let e=0;e<i.length;e++)switch(t.format){case _.IPF_RGB_565:case _.IPF_RGB_555:case _.IPF_RGB_888:case _.IPF_RGB_161616:i[e]=t.bytes[3*e];break;case _.IPF_ARGB_8888:case _.IPF_ARGB_16161616:i[e]=t.bytes[4*e];break;case _.IPF_BGR_888:i[e]=t.bytes[3*e+2];break;case _.IPF_ABGR_8888:case _.IPF_ABGR_16161616:i[e]=t.bytes[4*e+2]}t.bytes=i,t.stride=t.width,t.format=_.IPF_GRAYSCALED}}else[_.IPF_NV21,_.IPF_NV12].includes(t.format)&&e._onLog&&e._onLog("NV21 or NV12 is not supported.");return t}setNextImageToReturn(e,t){if(!((...e)=>0!==e.length&&e.every(e=>I(e)))(e))throw new TypeError("Invalid 'imageId'.");if(void 0!==t&&"[object Boolean]"!==E(t))throw new TypeError("Invalid 'keepInBuffer'.");d(this,j,{imageId:e,keepInBuffer:t},"f")}_resetNextReturnedImage(){d(this,j,null,"f")}hasImage(e){return l(this,k,"m",H).call(this,e)>=0}startFetching(){d(this,W,!0,"f")}stopFetching(){d(this,W,!1,"f")}setMaxImageCount(e){if("number"!=typeof e)throw new TypeError("Invalid 'count'.");if(e<1||Math.round(e)!==e)throw new Error("Invalid 'count'.");for(d(this,V,e,"f");l(this,U,"f")&&l(this,U,"f").length>e;)l(this,U,"f").shift()}getMaxImageCount(){return l(this,V,"f")}getImageCount(){return l(this,U,"f").length}clearBuffer(){l(this,U,"f").length=0}isBufferEmpty(){return 0===l(this,U,"f").length}setBufferOverflowProtectionMode(e){d(this,G,e,"f")}getBufferOverflowProtectionMode(){return l(this,G,"f")}setColourChannelUsageType(e){d(this,Z,e,"f")}getColourChannelUsageType(){return l(this,Z,"f")}};U=new WeakMap,V=new WeakMap,G=new WeakMap,W=new WeakMap,j=new WeakMap,Z=new WeakMap,k=new WeakSet,H=function(e){if("number"!=typeof e)throw new TypeError("Invalid 'imageId'.");return l(this,U,"f").findIndex(t=>{var i;return(null===(i=t.imageTag)||void 0===i?void 0:i.imageId)===e})},"undefined"!=typeof navigator&&(q=navigator,Y=q.userAgent,$=q.platform,z=q.mediaDevices),function(){if(!m){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:q.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},t={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:$,search:"Win"},Mac:{str:$},Linux:{str:$}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let r=n.str||Y,o=n.search||t,a=n.verStr||Y,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=r.indexOf(o)){i=t;for(let e of c){let t=a.indexOf(e);if(-1!=t){s=parseFloat(a.substring(t+e.length+1));break}}break}}for(let e in t){const i=t[e]||{};let s=i.str||Y,r=i.search||e;if(-1!=s.indexOf(r)){n=e;break}}"Linux"==n&&-1!=Y.indexOf("Windows NT")&&(n="HarmonyOS"),K={browser:i,version:s,OS:n}}m&&(K={browser:"ssr",version:0,OS:"ssr"})}();const Q="undefined"!=typeof WebAssembly&&Y&&!(/Safari/.test(Y)&&!/Chrome/.test(Y)&&/\(.+\s11_2_([2-6]).*\)/.test(Y)),J=!("undefined"==typeof Worker),ee=!(!z||!z.getUserMedia),te=async()=>{let e=!1;if(ee)try{(await z.getUserMedia({video:!0})).getTracks().forEach(e=>{e.stop()}),e=!0}catch(e){}return e};var ie,se,ne,re,oe,ae,ce,le,de;"Chrome"===K.browser&&K.version>66||"Safari"===K.browser&&K.version>13||"OPR"===K.browser&&K.version>43||"Edge"===K.browser&&K.version,function(e){e[e.CRIT_ORIGINAL_IMAGE=1]="CRIT_ORIGINAL_IMAGE",e[e.CRIT_BARCODE=2]="CRIT_BARCODE",e[e.CRIT_TEXT_LINE=4]="CRIT_TEXT_LINE",e[e.CRIT_DETECTED_QUAD=8]="CRIT_DETECTED_QUAD",e[e.CRIT_DESKEWED_IMAGE=16]="CRIT_DESKEWED_IMAGE",e[e.CRIT_PARSED_RESULT=32]="CRIT_PARSED_RESULT",e[e.CRIT_ENHANCED_IMAGE=64]="CRIT_ENHANCED_IMAGE"}(ie||(ie={})),function(e){e[e.CT_NORMAL_INTERSECTED=0]="CT_NORMAL_INTERSECTED",e[e.CT_T_INTERSECTED=1]="CT_T_INTERSECTED",e[e.CT_CROSS_INTERSECTED=2]="CT_CROSS_INTERSECTED",e[e.CT_NOT_INTERSECTED=3]="CT_NOT_INTERSECTED"}(se||(se={})),function(e){e[e.EC_OK=0]="EC_OK",e[e.EC_UNKNOWN=-1e4]="EC_UNKNOWN",e[e.EC_NO_MEMORY=-10001]="EC_NO_MEMORY",e[e.EC_NULL_POINTER=-10002]="EC_NULL_POINTER",e[e.EC_LICENSE_INVALID=-10003]="EC_LICENSE_INVALID",e[e.EC_LICENSE_EXPIRED=-10004]="EC_LICENSE_EXPIRED",e[e.EC_FILE_NOT_FOUND=-10005]="EC_FILE_NOT_FOUND",e[e.EC_FILE_TYPE_NOT_SUPPORTED=-10006]="EC_FILE_TYPE_NOT_SUPPORTED",e[e.EC_BPP_NOT_SUPPORTED=-10007]="EC_BPP_NOT_SUPPORTED",e[e.EC_INDEX_INVALID=-10008]="EC_INDEX_INVALID",e[e.EC_CUSTOM_REGION_INVALID=-10010]="EC_CUSTOM_REGION_INVALID",e[e.EC_IMAGE_READ_FAILED=-10012]="EC_IMAGE_READ_FAILED",e[e.EC_TIFF_READ_FAILED=-10013]="EC_TIFF_READ_FAILED",e[e.EC_DIB_BUFFER_INVALID=-10018]="EC_DIB_BUFFER_INVALID",e[e.EC_PDF_READ_FAILED=-10021]="EC_PDF_READ_FAILED",e[e.EC_PDF_DLL_MISSING=-10022]="EC_PDF_DLL_MISSING",e[e.EC_PAGE_NUMBER_INVALID=-10023]="EC_PAGE_NUMBER_INVALID",e[e.EC_CUSTOM_SIZE_INVALID=-10024]="EC_CUSTOM_SIZE_INVALID",e[e.EC_TIMEOUT=-10026]="EC_TIMEOUT",e[e.EC_JSON_PARSE_FAILED=-10030]="EC_JSON_PARSE_FAILED",e[e.EC_JSON_TYPE_INVALID=-10031]="EC_JSON_TYPE_INVALID",e[e.EC_JSON_KEY_INVALID=-10032]="EC_JSON_KEY_INVALID",e[e.EC_JSON_VALUE_INVALID=-10033]="EC_JSON_VALUE_INVALID",e[e.EC_JSON_NAME_KEY_MISSING=-10034]="EC_JSON_NAME_KEY_MISSING",e[e.EC_JSON_NAME_VALUE_DUPLICATED=-10035]="EC_JSON_NAME_VALUE_DUPLICATED",e[e.EC_TEMPLATE_NAME_INVALID=-10036]="EC_TEMPLATE_NAME_INVALID",e[e.EC_JSON_NAME_REFERENCE_INVALID=-10037]="EC_JSON_NAME_REFERENCE_INVALID",e[e.EC_PARAMETER_VALUE_INVALID=-10038]="EC_PARAMETER_VALUE_INVALID",e[e.EC_DOMAIN_NOT_MATCH=-10039]="EC_DOMAIN_NOT_MATCH",e[e.EC_LICENSE_KEY_NOT_MATCH=-10043]="EC_LICENSE_KEY_NOT_MATCH",e[e.EC_SET_MODE_ARGUMENT_ERROR=-10051]="EC_SET_MODE_ARGUMENT_ERROR",e[e.EC_GET_MODE_ARGUMENT_ERROR=-10055]="EC_GET_MODE_ARGUMENT_ERROR",e[e.EC_IRT_LICENSE_INVALID=-10056]="EC_IRT_LICENSE_INVALID",e[e.EC_FILE_SAVE_FAILED=-10058]="EC_FILE_SAVE_FAILED",e[e.EC_STAGE_TYPE_INVALID=-10059]="EC_STAGE_TYPE_INVALID",e[e.EC_IMAGE_ORIENTATION_INVALID=-10060]="EC_IMAGE_ORIENTATION_INVALID",e[e.EC_CONVERT_COMPLEX_TEMPLATE_ERROR=-10061]="EC_CONVERT_COMPLEX_TEMPLATE_ERROR",e[e.EC_CALL_REJECTED_WHEN_CAPTURING=-10062]="EC_CALL_REJECTED_WHEN_CAPTURING",e[e.EC_NO_IMAGE_SOURCE=-10063]="EC_NO_IMAGE_SOURCE",e[e.EC_READ_DIRECTORY_FAILED=-10064]="EC_READ_DIRECTORY_FAILED",e[e.EC_MODULE_NOT_FOUND=-10065]="EC_MODULE_NOT_FOUND",e[e.EC_MULTI_PAGES_NOT_SUPPORTED=-10066]="EC_MULTI_PAGES_NOT_SUPPORTED",e[e.EC_FILE_ALREADY_EXISTS=-10067]="EC_FILE_ALREADY_EXISTS",e[e.EC_CREATE_FILE_FAILED=-10068]="EC_CREATE_FILE_FAILED",e[e.EC_IMAGE_DATA_INVALID=-10069]="EC_IMAGE_DATA_INVALID",e[e.EC_IMAGE_SIZE_NOT_MATCH=-10070]="EC_IMAGE_SIZE_NOT_MATCH",e[e.EC_IMAGE_PIXEL_FORMAT_NOT_MATCH=-10071]="EC_IMAGE_PIXEL_FORMAT_NOT_MATCH",e[e.EC_SECTION_LEVEL_RESULT_IRREPLACEABLE=-10072]="EC_SECTION_LEVEL_RESULT_IRREPLACEABLE",e[e.EC_AXIS_DEFINITION_INCORRECT=-10073]="EC_AXIS_DEFINITION_INCORRECT",e[e.EC_RESULT_TYPE_MISMATCH_IRREPLACEABLE=-10074]="EC_RESULT_TYPE_MISMATCH_IRREPLACEABLE",e[e.EC_PDF_LIBRARY_LOAD_FAILED=-10075]="EC_PDF_LIBRARY_LOAD_FAILED",e[e.EC_UNSUPPORTED_JSON_KEY_WARNING=-10077]="EC_UNSUPPORTED_JSON_KEY_WARNING",e[e.EC_MODEL_FILE_NOT_FOUND=-10078]="EC_MODEL_FILE_NOT_FOUND",e[e.EC_PDF_LICENSE_NOT_FOUND=-10079]="EC_PDF_LICENSE_NOT_FOUND",e[e.EC_RECT_INVALID=-10080]="EC_RECT_INVALID",e[e.EC_TEMPLATE_VERSION_INCOMPATIBLE=-10081]="EC_TEMPLATE_VERSION_INCOMPATIBLE",e[e.EC_PORTRAIT_ZONE_NOT_FOUND=-10082]="EC_PORTRAIT_ZONE_NOT_FOUND",e[e.EC_NO_LICENSE=-2e4]="EC_NO_LICENSE",e[e.EC_LICENSE_BUFFER_FAILED=-20002]="EC_LICENSE_BUFFER_FAILED",e[e.EC_LICENSE_SYNC_FAILED=-20003]="EC_LICENSE_SYNC_FAILED",e[e.EC_DEVICE_NOT_MATCH=-20004]="EC_DEVICE_NOT_MATCH",e[e.EC_BIND_DEVICE_FAILED=-20005]="EC_BIND_DEVICE_FAILED",e[e.EC_INSTANCE_COUNT_OVER_LIMIT=-20008]="EC_INSTANCE_COUNT_OVER_LIMIT",e[e.EC_TRIAL_LICENSE=-20010]="EC_TRIAL_LICENSE",e[e.EC_LICENSE_VERSION_NOT_MATCH=-20011]="EC_LICENSE_VERSION_NOT_MATCH",e[e.EC_LICENSE_CACHE_USED=-20012]="EC_LICENSE_CACHE_USED",e[e.EC_LICENSE_AUTH_QUOTA_EXCEEDED=-20013]="EC_LICENSE_AUTH_QUOTA_EXCEEDED",e[e.EC_LICENSE_RESULTS_LIMIT_EXCEEDED=-20014]="EC_LICENSE_RESULTS_LIMIT_EXCEEDED",e[e.EC_BARCODE_FORMAT_INVALID=-30009]="EC_BARCODE_FORMAT_INVALID",e[e.EC_CUSTOM_MODULESIZE_INVALID=-30025]="EC_CUSTOM_MODULESIZE_INVALID",e[e.EC_TEXT_LINE_GROUP_LAYOUT_CONFLICT=-40101]="EC_TEXT_LINE_GROUP_LAYOUT_CONFLICT",e[e.EC_TEXT_LINE_GROUP_REGEX_CONFLICT=-40102]="EC_TEXT_LINE_GROUP_REGEX_CONFLICT",e[e.EC_QUADRILATERAL_INVALID=-50057]="EC_QUADRILATERAL_INVALID",e[e.EC_PANORAMA_LICENSE_INVALID=-70060]="EC_PANORAMA_LICENSE_INVALID",e[e.EC_RESOURCE_PATH_NOT_EXIST=-90001]="EC_RESOURCE_PATH_NOT_EXIST",e[e.EC_RESOURCE_LOAD_FAILED=-90002]="EC_RESOURCE_LOAD_FAILED",e[e.EC_CODE_SPECIFICATION_NOT_FOUND=-90003]="EC_CODE_SPECIFICATION_NOT_FOUND",e[e.EC_FULL_CODE_EMPTY=-90004]="EC_FULL_CODE_EMPTY",e[e.EC_FULL_CODE_PREPROCESS_FAILED=-90005]="EC_FULL_CODE_PREPROCESS_FAILED",e[e.EC_LICENSE_WARNING=-10076]="EC_LICENSE_WARNING",e[e.EC_BARCODE_READER_LICENSE_NOT_FOUND=-30063]="EC_BARCODE_READER_LICENSE_NOT_FOUND",e[e.EC_LABEL_RECOGNIZER_LICENSE_NOT_FOUND=-40103]="EC_LABEL_RECOGNIZER_LICENSE_NOT_FOUND",e[e.EC_DOCUMENT_NORMALIZER_LICENSE_NOT_FOUND=-50058]="EC_DOCUMENT_NORMALIZER_LICENSE_NOT_FOUND",e[e.EC_CODE_PARSER_LICENSE_NOT_FOUND=-90012]="EC_CODE_PARSER_LICENSE_NOT_FOUND"}(ne||(ne={})),function(e){e[e.GEM_SKIP=0]="GEM_SKIP",e[e.GEM_AUTO=1]="GEM_AUTO",e[e.GEM_GENERAL=2]="GEM_GENERAL",e[e.GEM_GRAY_EQUALIZE=4]="GEM_GRAY_EQUALIZE",e[e.GEM_GRAY_SMOOTH=8]="GEM_GRAY_SMOOTH",e[e.GEM_SHARPEN_SMOOTH=16]="GEM_SHARPEN_SMOOTH",e[e.GEM_REV=-2147483648]="GEM_REV",e[e.GEM_END=-1]="GEM_END"}(re||(re={})),function(e){e[e.GTM_SKIP=0]="GTM_SKIP",e[e.GTM_INVERTED=1]="GTM_INVERTED",e[e.GTM_ORIGINAL=2]="GTM_ORIGINAL",e[e.GTM_AUTO=4]="GTM_AUTO",e[e.GTM_REV=-2147483648]="GTM_REV",e[e.GTM_END=-1]="GTM_END"}(oe||(oe={})),function(e){e[e.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",e[e.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(ae||(ae={})),function(e){e[e.PDFRM_VECTOR=1]="PDFRM_VECTOR",e[e.PDFRM_RASTER=2]="PDFRM_RASTER",e[e.PDFRM_REV=-2147483648]="PDFRM_REV"}(ce||(ce={})),function(e){e[e.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",e[e.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(le||(le={})),function(e){e[e.CVS_NOT_VERIFIED=0]="CVS_NOT_VERIFIED",e[e.CVS_PASSED=1]="CVS_PASSED",e[e.CVS_FAILED=2]="CVS_FAILED"}(de||(de={}));const ue={IRUT_NULL:BigInt(0),IRUT_COLOUR_IMAGE:BigInt(1),IRUT_SCALED_COLOUR_IMAGE:BigInt(2),IRUT_GRAYSCALE_IMAGE:BigInt(4),IRUT_TRANSOFORMED_GRAYSCALE_IMAGE:BigInt(8),IRUT_ENHANCED_GRAYSCALE_IMAGE:BigInt(16),IRUT_PREDETECTED_REGIONS:BigInt(32),IRUT_BINARY_IMAGE:BigInt(64),IRUT_TEXTURE_DETECTION_RESULT:BigInt(128),IRUT_TEXTURE_REMOVED_GRAYSCALE_IMAGE:BigInt(256),IRUT_TEXTURE_REMOVED_BINARY_IMAGE:BigInt(512),IRUT_CONTOURS:BigInt(1024),IRUT_LINE_SEGMENTS:BigInt(2048),IRUT_TEXT_ZONES:BigInt(4096),IRUT_TEXT_REMOVED_BINARY_IMAGE:BigInt(8192),IRUT_CANDIDATE_BARCODE_ZONES:BigInt(16384),IRUT_LOCALIZED_BARCODES:BigInt(32768),IRUT_SCALED_BARCODE_IMAGE:BigInt(65536),IRUT_DEFORMATION_RESISTED_BARCODE_IMAGE:BigInt(1<<17),IRUT_COMPLEMENTED_BARCODE_IMAGE:BigInt(1<<18),IRUT_DECODED_BARCODES:BigInt(1<<19),IRUT_LONG_LINES:BigInt(1<<20),IRUT_CORNERS:BigInt(1<<21),IRUT_CANDIDATE_QUAD_EDGES:BigInt(1<<22),IRUT_DETECTED_QUADS:BigInt(1<<23),IRUT_LOCALIZED_TEXT_LINES:BigInt(1<<24),IRUT_RECOGNIZED_TEXT_LINES:BigInt(1<<25),IRUT_DESKEWED_IMAGE:BigInt(1<<26),IRUT_SHORT_LINES:BigInt(1<<27),IRUT_RAW_TEXT_LINES:BigInt(1<<28),IRUT_LOGIC_LINES:BigInt(1<<29),IRUT_ENHANCED_IMAGE:BigInt(Math.pow(2,30)),IRUT_ALL:BigInt("0xFFFFFFFFFFFFFFFF")};var he,_e,me,ge,fe;!function(e){e[e.ROET_PREDETECTED_REGION=0]="ROET_PREDETECTED_REGION",e[e.ROET_LOCALIZED_BARCODE=1]="ROET_LOCALIZED_BARCODE",e[e.ROET_DECODED_BARCODE=2]="ROET_DECODED_BARCODE",e[e.ROET_LOCALIZED_TEXT_LINE=3]="ROET_LOCALIZED_TEXT_LINE",e[e.ROET_RECOGNIZED_TEXT_LINE=4]="ROET_RECOGNIZED_TEXT_LINE",e[e.ROET_DETECTED_QUAD=5]="ROET_DETECTED_QUAD",e[e.ROET_DESKEWED_IMAGE=6]="ROET_DESKEWED_IMAGE",e[e.ROET_SOURCE_IMAGE=7]="ROET_SOURCE_IMAGE",e[e.ROET_TARGET_ROI=8]="ROET_TARGET_ROI",e[e.ROET_ENHANCED_IMAGE=9]="ROET_ENHANCED_IMAGE",e[e.ROET_AUXILIARY_REGION=10]="ROET_AUXILIARY_REGION"}(he||(he={})),function(e){e[e.ST_NULL=0]="ST_NULL",e[e.ST_REGION_PREDETECTION=1]="ST_REGION_PREDETECTION",e[e.ST_BARCODE_LOCALIZATION=2]="ST_BARCODE_LOCALIZATION",e[e.ST_BARCODE_DECODING=3]="ST_BARCODE_DECODING",e[e.ST_TEXT_LINE_LOCALIZATION=4]="ST_TEXT_LINE_LOCALIZATION",e[e.ST_TEXT_LINE_RECOGNITION=5]="ST_TEXT_LINE_RECOGNITION",e[e.ST_DOCUMENT_DETECTION=6]="ST_DOCUMENT_DETECTION",e[e.ST_DOCUMENT_DESKEWING=7]="ST_DOCUMENT_DESKEWING",e[e.ST_IMAGE_ENHANCEMENT=8]="ST_IMAGE_ENHANCEMENT"}(_e||(_e={})),function(e){e[e.IFF_JPEG=0]="IFF_JPEG",e[e.IFF_PNG=1]="IFF_PNG",e[e.IFF_BMP=2]="IFF_BMP",e[e.IFF_PDF=3]="IFF_PDF"}(me||(me={})),function(e){e[e.ICDM_NEAR=0]="ICDM_NEAR",e[e.ICDM_FAR=1]="ICDM_FAR"}(ge||(ge={})),function(e){e.MN_DYNAMSOFT_CAPTURE_VISION_ROUTER="cvr",e.MN_DYNAMSOFT_CORE="core",e.MN_DYNAMSOFT_LICENSE="license",e.MN_DYNAMSOFT_IMAGE_PROCESSING="dip",e.MN_DYNAMSOFT_UTILITY="utility",e.MN_DYNAMSOFT_BARCODE_READER="dbr",e.MN_DYNAMSOFT_DOCUMENT_NORMALIZER="ddn",e.MN_DYNAMSOFT_LABEL_RECOGNIZER="dlr",e.MN_DYNAMSOFT_CAPTURE_VISION_DATA="dcvData",e.MN_DYNAMSOFT_NEURAL_NETWORK="dnn",e.MN_DYNAMSOFT_CODE_PARSER="dcp",e.MN_DYNAMSOFT_CAMERA_ENHANCER="dce",e.MN_DYNAMSOFT_CAPTURE_VISION_STD="std"}(fe||(fe={}));const pe={},Ee=async e=>{let t="string"==typeof e?[e]:e,i=[];for(let e of t)i.push(pe[e]=pe[e]||new c);await Promise.all(i)},ye=async(e,t)=>{let i,s="string"==typeof e?[e]:e,n=[];for(let e of s){let s;n.push(s=pe[e]=pe[e]||new c(i=i||t())),s.isEmpty&&(s.task=i=i||t())}await Promise.all(n)};let Ie,ve=0;const Re=()=>ve++,Ce={};let Te;const we=e=>{Te=e,Ie&&Ie.postMessage({type:"setBLog",body:{value:!!e}})};let Se=!1;const Ae=e=>{Se=e,Ie&&Ie.postMessage({type:"setBDebug",body:{value:!!e}})},De={},be={},Le={dip:{wasm:!0}},Oe={std:{version:"2.0.0",path:p(f+"../../dynamsoft-capture-vision-std@2.0.0/dist/"),isInternal:!0},core:{version:"4.4.30-dev-20260629163026",path:f,isInternal:!0}};let Ne=5;"undefined"!=typeof navigator&&(Ne=navigator.hardwareConcurrency?navigator.hardwareConcurrency-1:5),Ce[-3]=async e=>{Me.onWasmLoadProgressChanged&&Me.onWasmLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class Me{static get engineResourcePaths(){return Oe}static set engineResourcePaths(e){Object.assign(Oe,e)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _onLog(){return Te}static set _onLog(e){we(e)}static get _bDebug(){return Se}static set _bDebug(e){Ae(e)}static get _workerName(){return`${Me._bundleEnv.toLowerCase()}.bundle.worker.js`}static get wasmLoadOptions(){return Me._wasmLoadOptions}static set wasmLoadOptions(e){Object.assign(Me._wasmLoadOptions,e)}static isModuleLoaded(e){return e=(e=e||"core").toLowerCase(),!!pe[e]&&pe[e].isFulfilled}static async loadWasm(){return await(async()=>{let e,t;e instanceof Array||(e=e?[e]:[]);let i=pe.core;t=!i||i.isEmpty,t||await Ee("core");let s=new Map;const n=e=>{if(e=e.toLowerCase(),fe.MN_DYNAMSOFT_CAPTURE_VISION_STD==e||fe.MN_DYNAMSOFT_CORE==e)return;let t=Le[e].deps;if(null==t?void 0:t.length)for(let e of t)n(e);let i=pe[e];s.has(e)||s.set(e,!i||i.isEmpty)};for(let t of e)n(t);let r=[];t&&r.push("core"),r.push(...s.keys());const o=[...s.entries()].filter(e=>!e[1]).map(e=>e[0]);await ye(r,async()=>{const e=[...s.entries()].filter(e=>e[1]).map(e=>e[0]);await Ee(o);const i=b(Oe),n={};for(let t of e)n[t]=Le[t];const r={engineResourcePaths:i,autoResources:n,names:e,_bundleEnv:Me._bundleEnv,wasmLoadOptions:Me.wasmLoadOptions};let a=new c;if(t){r.needLoadCore=!0;let e=i[`${Me._bundleEnv.toLowerCase()}Bundle`]+Me._workerName;e.startsWith(location.origin)||(e=await fetch(e).then(e=>e.blob()).then(e=>URL.createObjectURL(e))),Ie=new Worker(e),Ie.onerror=e=>{let t=new Error(e.message);a.reject(t)},Ie.addEventListener("message",e=>{let t=e.data?e.data:e,i=t.type,s=t.id,n=t.body;switch(i){case"log":Te&&Te(t.message);break;case"warning":console.warn(t.message);break;case"task":try{Ce[s]&&(Ce[s](n),delete Ce[s])}catch(e){throw delete Ce[s],e}break;case"event":try{Ce[s](n)}catch(e){throw e}break;default:console.log(e)}}),r.bLog=!!Te,r.bd=Se,r.dm=location.origin.startsWith("http")?location.origin:"https://localhost"}else await Ee("core");let l=ve++;Ce[l]=e=>{if(e.success)Object.assign(De,e.versions),"{}"!==JSON.stringify(e.versions)&&(Me._versions=e.versions),Me.loadedWasmType=e.loadedWasmType,a.resolve(void 0);else{const t=Error(e.message);e.stack&&(t.stack=e.stack),a.reject(t)}},Ie.postMessage({type:"loadWasm",id:l,body:r}),await a})})()}static async detectEnvironment(){return await(async()=>({wasm:Q,worker:J,getUserMedia:ee,camera:await te(),browser:K.browser,version:K.version,OS:K.OS}))()}static async getModuleVersion(){return await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e(i.versions);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"getModuleVersion",id:i})})}static getVersion(){return`4.4.30-dev-20260629163026(Worker: ${De.core&&De.core.worker||"Not Loaded"}, Wasm: ${De.core&&De.core.wasm||"Not Loaded"})`}static enableLogging(){X._onLog=console.log,Me._onLog=console.log}static disableLogging(){X._onLog=null,Me._onLog=null}static async cfd(e){return await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},Ie.postMessage({type:"cfd",id:s,body:{count:e}})})}}Me._bSupportDce4Module=-1,Me._bSupportIRTModule=-1,Me._versions=null,Me._bundleEnv="DCV",Me._wasmLoadOptions={wasmType:"auto",pthreadPoolSize:Ne},Me.loadedWasmType="ml-simd-pthread",Me.browserInfo=K;var Be=Object.freeze({__proto__:null,CoreModule:Me,get EnumBufferOverflowProtectionMode(){return u},get EnumCapturedResultItemType(){return ie},get EnumColourChannelUsageType(){return h},get EnumCornerType(){return se},get EnumCrossVerificationStatus(){return de},get EnumErrorCode(){return ne},get EnumGrayscaleEnhancementMode(){return re},get EnumGrayscaleTransformationMode(){return oe},get EnumImageCaptureDistanceMode(){return ge},get EnumImageFileFormat(){return me},get EnumImagePixelFormat(){return _},get EnumImageTagType(){return ae},EnumIntermediateResultUnitType:ue,get EnumModuleName(){return fe},get EnumPDFReadingMode(){return ce},get EnumRasterDataSource(){return le},get EnumRegionObjectElementType(){return he},get EnumSectionType(){return _e},ImageSourceAdapter:X,_saveToFile:L,_toBlob:M,_toCanvas:O,_toImage:N,get bDebug(){return Se},blobToDsImage:x,checkIsLink:A,compareVersion:D,createImageData:F,d:async(e,t)=>{const i=atob(e),s=new Uint8Array(i.length);for(let e=0;e<i.length;e++)s[e]=i.charCodeAt(e);const n=s.slice(0,12),r=s.slice(12),o=new TextEncoder,a=await crypto.subtle.importKey("raw",o.encode(t),"PBKDF2",!1,["deriveKey"]),c=await crypto.subtle.deriveKey({name:"PBKDF2",salt:o.encode("salt-for-key-derivation"),iterations:1e5,hash:"SHA-256"},a,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"]),l=await crypto.subtle.decrypt({name:"AES-GCM",iv:n,tagLength:128},c,r);return(new TextDecoder).decode(l)},doOrWaitAsyncDependency:ye,e:async(e,t)=>{const i=new TextEncoder,s=await crypto.subtle.importKey("raw",i.encode(t),"PBKDF2",!1,["deriveKey"]),n=await crypto.subtle.deriveKey({name:"PBKDF2",salt:i.encode("salt-for-key-derivation"),iterations:1e5,hash:"SHA-256"},s,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"]),r=crypto.getRandomValues(new Uint8Array(12)),o=await crypto.subtle.encrypt({name:"AES-GCM",iv:r,tagLength:128},n,i.encode(e)),a=new Uint8Array(r.length+o.byteLength);return a.set(r),a.set(new Uint8Array(o),r.length),btoa(String.fromCharCode.apply(null,a))},encodeBMP:B,getNextTaskID:Re,handleEngineResourcePaths:b,imagePtrToUint8Array:async e=>await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(e.u8);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},Ie.postMessage({type:"imagePtrToUint8Array",id:s,body:{data:e}})}),innerVersions:De,isArc:e=>!(!v(e)||!I(e.x)||!I(e.y)||!I(e.radius)||e.radius<0||!I(e.startAngle)||!I(e.endAngle)),isContour:e=>!!v(e)&&!!y(e.points)&&0!=e.points.length&&!e.points.some(e=>!w(e)),isDSImageData:C,isDSRect:e=>!(!v(e)||!I(e.left)||e.left<0||!I(e.top)||e.top<0||!I(e.right)||e.right<0||!I(e.bottom)||e.bottom<0||e.left>=e.right||e.top>=e.bottom),isDsImageKeyValue:(e,t)=>"bytes"===e&&"object"==typeof t&&"number"==typeof t.ptr&&"number"==typeof t.length,isImageTag:T,isLineSegment:e=>!(!v(e)||!w(e.startPoint)||!w(e.endPoint)||e.startPoint.x==e.endPoint.x&&e.startPoint.y==e.endPoint.y),isObject:v,isOriginalDsImageData:e=>!(!R(e)||!I(e.bytes.length)&&!I(e.bytes.ptr)),isPoint:w,isPolygon:e=>!!v(e)&&!!y(e.points)&&0!=e.points.length&&!e.points.some(e=>!w(e)),isQuad:e=>!!v(e)&&!!y(e.points)&&0!=e.points.length&&4==e.points.length&&!e.points.some(e=>!w(e)),isRect:e=>!(!v(e)||!I(e.x)||!I(e.y)||!I(e.width)||e.width<0||!I(e.height)||e.height<0),isSimdSupported:()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),mapAsyncDependency:pe,mapPackageRegister:be,mapTaskCallBack:Ce,get onLog(){return Te},productNameMap:P,requestResource:S,resolveDsImageData:async e=>await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(e.result);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},Ie.postMessage({type:"resolveDsImageData",id:s,body:{point:e}})}),setBDebug:Ae,setOnLog:we,waitAsyncDependency:Ee,get worker(){return Ie},workerAutoResources:Le}),Fe={license:"",scanMode:e.EnumScanMode.SM_SINGLE,templateFilePath:void 0,utilizedTemplateNames:{single:"ReadBarcodes_SpeedFirst",multi_unique:"ReadBarcodes_SpeedFirst",image:"ReadBarcodes_ReadRateFirst"},engineResourcePaths:Me.engineResourcePaths,barcodeFormats:void 0,duplicateForgetTime:3e3,container:void 0,onUniqueBarcodeScanned:void 0,showResultView:void 0,showUploadImageButton:!1,showPoweredByDynamsoft:!0,autoStartCapturing:!0,uiPath:void 0,onInitPrepare:void 0,onInitReady:void 0,onCameraOpen:void 0,onCameraOpenFailed:void 0,onCaptureStart:void 0,scannerViewConfig:{container:void 0,showCloseButton:!0,mirrorFrontCamera:!0,cameraSwitchControl:"hidden",showFlashButton:!1},resultViewConfig:{container:void 0,toolbarButtonsConfig:{clear:{label:"Clear",className:"btn-clear",isHidden:!1},done:{label:"Done",className:"btn-done",isHidden:!1}}}};const xe=e=>e&&"object"==typeof e&&"function"==typeof e.then,Pe=(async()=>{})().constructor;class ke extends Pe{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,xe(e)?t=e:"function"==typeof e&&(t=new Pe(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(xe(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}function Ue(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}function Ve(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i}"function"==typeof SuppressedError&&SuppressedError;const Ge=e=>e&&"object"==typeof e&&"function"==typeof e.then,We=(async()=>{})().constructor;let je=class extends We{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,Ge(e)?t=e:"function"==typeof e&&(t=new We(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(Ge(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}},Ze=class{constructor(e){this._cvr=e}async getMaxBufferedItems(){return await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e(i.count);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"cvr_getMaxBufferedItems",id:i,instanceID:this._cvr._instanceID})})}async setMaxBufferedItems(e){return await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},Ie.postMessage({type:"cvr_setMaxBufferedItems",id:s,instanceID:this._cvr._instanceID,body:{count:e}})})}async getBufferedCharacterItemSet(){return await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e(i.itemSet);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"cvr_getBufferedCharacterItemSet",id:i,instanceID:this._cvr._instanceID})})}};var He={onTaskResultsReceived:!1,onTargetROIResultsReceived:!1,onTaskResultsReceivedForDce:!1,onPredetectedRegionsReceived:!1,onLocalizedBarcodesReceived:!1,onDecodedBarcodesReceived:!1,onLocalizedTextLinesReceived:!1,onRecognizedTextLinesReceived:!1,onDetectedQuadsReceived:!1,onDeskewedImageReceived:!1,onEnhancedImageReceived:!1,onColourImageUnitReceived:!1,onScaledColourImageUnitReceived:!1,onGrayscaleImageUnitReceived:!1,onTransformedGrayscaleImageUnitReceived:!1,onEnhancedGrayscaleImageUnitReceived:!1,onBinaryImageUnitReceived:!1,onTextureDetectionResultUnitReceived:!1,onTextureRemovedGrayscaleImageUnitReceived:!1,onTextureRemovedBinaryImageUnitReceived:!1,onContoursUnitReceived:!1,onLineSegmentsUnitReceived:!1,onTextZonesUnitReceived:!1,onTextRemovedBinaryImageUnitReceived:!1,onRawTextLinesUnitReceived:!1,onLongLinesUnitReceived:!1,onCornersUnitReceived:!1,onCandidateQuadEdgesUnitReceived:!1,onCandidateBarcodeZonesUnitReceived:!1,onScaledBarcodeImageUnitReceived:!1,onDeformationResistedBarcodeImageUnitReceived:!1,onComplementedBarcodeImageUnitReceived:!1,onShortLinesUnitReceived:!1,onLogicLinesUnitReceived:!1};const qe=e=>{for(let t in e._irrRegistryState)e._irrRegistryState[t]=!1;for(let t of e._intermediateResultReceiverSet)if(t.isDce||t.isFilter)e._irrRegistryState.onTaskResultsReceivedForDce=!0;else for(let i in t)e._irrRegistryState[i]||(e._irrRegistryState[i]=!!t[i])};let Ye=class{constructor(e){this._irrRegistryState=He,this._intermediateResultReceiverSet=new Set,this._cvr=e}async addResultReceiver(e){if("object"!=typeof e)throw new Error("Invalid receiver.");this._intermediateResultReceiverSet.add(e),qe(this);let t=-1,i={};if(!e.isDce&&!e.isFilter){if(!e._observedResultUnitTypes||!e._observedTaskMap)throw new Error("Invalid Intermediate Result Receiver.");t=e._observedResultUnitTypes,e._observedTaskMap.forEach((e,t)=>{i[t]=e}),e._observedTaskMap.clear()}return await new Promise((e,s)=>{let n=Re();Ce[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,s(e)}},Ie.postMessage({type:"cvr_setIrrRegistry",id:n,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState,observedResultUnitTypes:t.toString(),observedTaskMap:i}})})}async removeResultReceiver(e){return this._intermediateResultReceiverSet.delete(e),qe(this),await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})})}async removeAllResultReceivers(){for(const e of this._intermediateResultReceiverSet)e.hasOwnProperty("isFilter")||e.hasOwnProperty("isDce")||this._intermediateResultReceiverSet.delete(e);return qe(this),await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})})}getOriginalImage(){return this._cvr.provideDsImage}};const $e="undefined"==typeof self,ze="function"==typeof importScripts,Ke=(()=>{if(!ze){if(!$e&&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"./"}})(),Xe=e=>{if(null==e&&(e="./"),$e||ze);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e};var Qe;Me.engineResourcePaths.cvr={version:"3.4.30-dev-20260629163033",path:Ke,isInternal:!0},Le.cvr={js:!0,wasm:!0,deps:[fe.MN_DYNAMSOFT_LICENSE,fe.MN_DYNAMSOFT_IMAGE_PROCESSING,fe.MN_DYNAMSOFT_NEURAL_NETWORK]},Le.dnn={wasm:!0,deps:[fe.MN_DYNAMSOFT_IMAGE_PROCESSING]},be.cvr={};const Je="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,Je)<0&&(Me.engineResourcePaths.std={version:Je,path:Xe(Ke+`../../dynamsoft-capture-vision-std@${Je}/dist/`),isInternal:!0});const et="3.0.10";(!Me.engineResourcePaths.dip||"string"!=typeof Me.engineResourcePaths.dip&&D(Me.engineResourcePaths.dip.version,et)<0)&&(Me.engineResourcePaths.dip={version:et,path:Xe(Ke+`../../dynamsoft-image-processing@${et}/dist/`),isInternal:!0});const tt="2.0.10";(!Me.engineResourcePaths.dnn||"string"!=typeof Me.engineResourcePaths.dnn&&D(Me.engineResourcePaths.dnn.version,tt)<0)&&(Me.engineResourcePaths.dnn={version:tt,path:Xe(Ke+`../../dynamsoft-capture-vision-dnn@${tt}/dist/`),isInternal:!0});let it=class{static getVersion(){return this._version}};function st(e,t){if(e){if(e.sourceLocation){const i=e.sourceLocation.points;for(let e of i)e.x=e.x/t,e.y=e.y/t}if(e.location){const i=e.location.points;for(let e of i)e.x=e.x/t,e.y=e.y/t}st(e.referencedItem,t)}}function nt(e){if(e.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}function rt(e){return{type:ie.CRIT_ORIGINAL_IMAGE,referenceItem:null,targetROIDefName:"",taskName:"",imageData:e,toCanvas:()=>O(e),toImage:t=>N(t,e),toBlob:t=>M(t,e)}}function ot(e){let t=!1;const i=[ne.EC_UNSUPPORTED_JSON_KEY_WARNING,ne.EC_LICENSE_AUTH_QUOTA_EXCEEDED,ne.EC_LICENSE_RESULTS_LIMIT_EXCEEDED];if(e.errorCode&&i.includes(e.errorCode))return void console.warn(e.message);let s=new Error(e.errorCode?`[${e.functionName}] [${e.errorCode}] ${e.message}`:`[${e.functionName}] ${e.message}`);if(s.stack&&(s.stack=e.stack),e.isShouldThrow)throw s;return e.rj&&e.rj(s),t=!0,true}function at(e,t,i){return(i.x-e.x)*(t.y-e.y)===(t.x-e.x)*(i.y-e.y)&&Math.min(e.x,t.x)<=i.x&&i.x<=Math.max(e.x,t.x)&&Math.min(e.y,t.y)<=i.y&&i.y<=Math.max(e.y,t.y)}function ct(e){return Math.abs(e)<1e-6?0:e<0?-1:1}function lt(e,t,i,s){let n=e[0]*(i[1]-t[1])+t[0]*(e[1]-i[1])+i[0]*(t[1]-e[1]),r=e[0]*(s[1]-t[1])+t[0]*(e[1]-s[1])+s[0]*(t[1]-e[1]);return!((n^r)>=0&&0!==n&&0!==r||(n=i[0]*(e[1]-s[1])+s[0]*(i[1]-e[1])+e[0]*(s[1]-i[1]),r=i[0]*(t[1]-s[1])+s[0]*(i[1]-t[1])+t[0]*(s[1]-i[1]),(n^r)>=0&&0!==n&&0!==r))}it._version=`3.4.30-dev-20260629163033(Worker: ${null===(Qe=De.cvr)||void 0===Qe?void 0:Qe.worker}, Wasm: loading...`,BigInt(0),BigInt("0xFFFFFFFEFFFFFFFF"),BigInt(4265345023);const dt=BigInt(3147775),ut=(BigInt(260096),BigInt(1),BigInt(2),BigInt(4),BigInt(8),BigInt(16),BigInt(32),BigInt(64),BigInt(128),BigInt(256),BigInt(512),BigInt(1024),BigInt(2048),BigInt(4096),BigInt(8192),BigInt(16384),BigInt(32768),BigInt(65536),BigInt(131072),BigInt(262144),BigInt(16777216),BigInt(33554432),BigInt(67108864)),ht=BigInt(134217728);BigInt(268435456),BigInt(536870912),BigInt(1073741824),BigInt(524288),BigInt(2147483648),BigInt(1048576),BigInt(2097152),BigInt(4194304),BigInt(8388608),BigInt(68719476736),BigInt(0x3f0000000000000),BigInt(4294967296),BigInt(4503599627370496),BigInt(9007199254740992),BigInt(0x40000000000000),BigInt(0x80000000000000),BigInt(72057594037927940),BigInt(0x200000000000000),BigInt(8589934592),BigInt(17179869184),BigInt(34359738368),BigInt(51539607552),BigInt(137438953472),BigInt(274877906944);let _t=class{constructor(e){this._autoZoomParameters={minValue:1,maxValue:999,autoFocusFrameArray:[],autoFocusFrameLimit:[5,3],autoZoomDetectionArea:.5,autoZoomTargetBorder:.9,autoZoomIdealArea:[0,.05],autoZoomInFrameArray:[],autoZoomInFrameLimit:[5,3],autoZoomInMaxTimes:5,autoZoomInMinStep:Math.pow(10,.2),autoZoomInIdealModuleSize:6,autoZoomOutFrameCount:0,autoZoomOutFrameLimit:3,autoZoomOutStepRate:1/3,autoZoomOutStepRate_2:.05,autoZoomOutMinStep:2,frameArrayInIdealZoom:[],frameLimitInIdealZoom:[5,3]},this.isSupportDCEModule=!0,this.onTaskResultsReceived=async e=>{if(!this.isSupportDCEModule)return;let t=this.cameraEnhancer;(4&t._dceEnhancedFeatures||16&t._dceEnhancedFeatures||64&t._dceEnhancedFeatures)&&(0!==Me.bSupportDce4Module?(this.isSupportDCEModule=!1,console.warn("Warning: The license required for Enhanced Features was not found.")):(!this.consumeTime||Date.now()-this.consumeTime>1e4)&&(Me.cfd(1),this.consumeTime=Date.now()));const i=e.intermediateResultUnits;if(!t.isOpen()||t.isPaused())return;const s=t.getVisibleAreaInVideoXY({isConsiderRegionBox:!0});if(isNaN(s.x)||isNaN(s.y)||isNaN(s.width)||isNaN(s.height))return;let n=!1,r=!1;for(let e of i){if(e.unitType===ue.IRUT_DECODED_BARCODES&&e.decodedBarcodes.length){n=!0;break}e.unitType===ue.IRUT_LOCALIZED_BARCODES&&e.localizedBarcodes.length&&(r=!0)}if(16&t._dceEnhancedFeatures||4&t._dceEnhancedFeatures)if(n)this._autoZoomParameters.autoZoomInFrameArray.length=0,this._autoZoomParameters.autoZoomOutFrameCount=0,this._autoZoomParameters.frameArrayInIdealZoom.length=0,this._autoZoomParameters.autoFocusFrameArray.length=0;else{const n=async e=>{await t.setZoom(e)},o=async e=>{await t.setFocus(e)};if(r){s.x,s.y;const r=s.width,a=s.height,c=s.width,l=s.height;let d;{let e,n,r,o,a;{const e=t.video.videoWidth*(1-this._autoZoomParameters.autoZoomDetectionArea)/2,i=t.video.videoWidth*(1+this._autoZoomParameters.autoZoomDetectionArea)/2,s=i,n=e,r=t.video.videoHeight*(1-this._autoZoomParameters.autoZoomDetectionArea)/2,o=r,c=t.video.videoHeight*(1+this._autoZoomParameters.autoZoomDetectionArea)/2;a=[{x:e,y:r},{x:i,y:o},{x:s,y:c},{x:n,y:c}]}const u=[];{const e=(e,t)=>{const i=(e,t)=>{if(!e&&!t)throw new Error("Invalid arguments.");return function(e,t,i){let s=!1;const n=e.length;if(n<=2)return!1;for(let r=0;r<n;r++){const o=e[r],a=e[(r+1)%n];if(at(o,a,{x:t,y:i}))return!0;ct(o.y-i)>0!=ct(a.y-i)>0&&ct(t-(i-o.y)*(o.x-a.x)/(o.y-a.y)-o.x)<0&&(s=!s)}return s}(t,e.x,e.y)},s=(e,t)=>!!(lt([e[0],e[1]],[e[2],e[3]],[t[0].x,t[0].y],[t[1].x,t[1].y])||lt([e[0],e[1]],[e[2],e[3]],[t[1].x,t[1].y],[t[2].x,t[2].y])||lt([e[0],e[1]],[e[2],e[3]],[t[2].x,t[2].y],[t[3].x,t[3].y])||lt([e[0],e[1]],[e[2],e[3]],[t[3].x,t[3].y],[t[0].x,t[0].y]));return!!(i({x:e[0].x,y:e[0].y},t)||i({x:e[1].x,y:e[1].y},t)||i({x:e[2].x,y:e[2].y},t)||i({x:e[3].x,y:e[3].y},t))||!!(i({x:t[0].x,y:t[0].y},e)||i({x:t[1].x,y:t[1].y},e)||i({x:t[2].x,y:t[2].y},e)||i({x:t[3].x,y:t[3].y},e))||!!(s([t[0].x,t[0].y,t[1].x,t[1].y],e)||s([t[1].x,t[1].y,t[2].x,t[2].y],e)||s([t[2].x,t[2].y,t[3].x,t[3].y],e)||s([t[3].x,t[3].y,t[0].x,t[0].y],e))};for(let t of i)if(t.unitType===ue.IRUT_LOCALIZED_BARCODES)for(let i of t.localizedBarcodes)i&&e(a,i.location.points.map(e=>({x:e.x+s.x,y:e.y+s.y})))&&u.push(i)}if(!u.length)return;let h;if(u.length){let e=u.filter(e=>e.possibleFormats==ut||e.possibleFormats==ht);if(e.length||(e=u.filter(e=>e.possibleFormats==dt),e.length||(e=u)),e.length){const t=e=>{const t=e.location.points,i=(t[0].x+t[1].x+t[2].x+t[3].x)/4,s=(t[0].y+t[1].y+t[2].y+t[3].y)/4;return(i-c/2)*(i-c/2)+(s-l/2)*(s-l/2)};h=e[0];let i=t(h);if(1!=e.length)for(let s=1;s<e.length;s++){const n=t(e[s]);(e[s].confidence>1.1*h.confidence||e[s].confidence>.9*h.confidence&&n<i)&&(h=e[s],i=n)}}}if(h){const t=h.location.points;e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),n=Math.max(t[0].x,t[1].x,t[2].x,t[3].x),r=Math.min(t[0].y,t[1].y,t[2].y,t[3].y),o=Math.max(t[0].y,t[1].y,t[2].y,t[3].y),d={points:[{x:e,y:r},{x:n,y:r},{x:n,y:o},{x:e,y:o}],result:h}}}if(!d)return;if(this._autoZoomParameters.autoZoomOutFrameCount=0,16&t._dceEnhancedFeatures){const i=this._autoZoomParameters.autoZoomIdealArea[1];let s=(1-this._autoZoomParameters.autoZoomTargetBorder)/2;const c=d.points[0].x/r,l=(r-d.points[2].x)/r,u=d.points[0].y/a,h=(a-d.points[2].y)/a;if(c>i&&l>i&&u>i&&h>i&&d.result.moduleSize<this._autoZoomParameters.autoZoomInIdealModuleSize){if(this._autoZoomParameters.autoZoomInFrameArray.push(!0),this._autoZoomParameters.autoZoomInFrameArray.splice(0,this._autoZoomParameters.autoZoomInFrameArray.length-this._autoZoomParameters.autoZoomInFrameLimit[0]),this._autoZoomParameters.frameArrayInIdealZoom.length=0,4&t._dceEnhancedFeatures&&o({mode:"continuous"}).catch(()=>{}),this._autoZoomParameters.autoZoomInFrameArray.filter(e=>!0===e).length>=this._autoZoomParameters.autoZoomInFrameLimit[1]){this._autoZoomParameters.autoZoomInFrameArray.length=0;const i=[(.5-s)/(.5-c),(.5-s)/(.5-l),(.5-s)/(.5-u),(.5-s)/(.5-h)].filter(e=>e>0),r=Math.min(...i,this._autoZoomParameters.autoZoomInIdealModuleSize/d.result.moduleSize),o=t.getZoomSettings().factor;let a=Math.max(Math.pow(o*r,1/this._autoZoomParameters.autoZoomInMaxTimes),this._autoZoomParameters.autoZoomInMinStep);a=Math.min(a,r);let _=o*a;_=Math.max(t._dceAutoZoomRange.min,_),_=Math.min(t._dceAutoZoomRange.max,_);try{await n({factor:_})}catch(e){const t=e.message||e;console.warn(t)}t._framePipeline&&(t._framePipeline._data=null)}}else if(this._autoZoomParameters.autoZoomInFrameArray.length=0,this._autoZoomParameters.frameArrayInIdealZoom.push(!0),this._autoZoomParameters.frameArrayInIdealZoom.splice(0,this._autoZoomParameters.frameArrayInIdealZoom.length-this._autoZoomParameters.frameLimitInIdealZoom[0]),this._autoZoomParameters.frameArrayInIdealZoom.filter(e=>!0===e).length>=this._autoZoomParameters.frameLimitInIdealZoom[1]&&(this._autoZoomParameters.frameArrayInIdealZoom.length=0,4&t._dceEnhancedFeatures)){const i=d.points;try{await o({mode:"manual",area:{centerPoint:{x:(i[0].x+i[2].x)/2+"px",y:(i[0].y+i[2].y)/2+"px"},width:i[2].x-i[0].x+"px",height:i[2].y-i[0].y+"px"}})}catch(e){const t=e.message||e;console.warn(t)}t._framePipeline&&(t._framePipeline._data=null)}}if(!(16&t._dceEnhancedFeatures)&&4&t._dceEnhancedFeatures&&(this._autoZoomParameters.autoFocusFrameArray.push(!0),this._autoZoomParameters.autoFocusFrameArray.splice(0,this._autoZoomParameters.autoFocusFrameArray.length-this._autoZoomParameters.autoFocusFrameLimit[0]),this._autoZoomParameters.autoFocusFrameArray.filter(e=>!0===e).length>=this._autoZoomParameters.autoFocusFrameLimit[1])){this._autoZoomParameters.autoFocusFrameArray.length=0;try{const e=d.points;await o({mode:"manual",area:{centerPoint:{x:(e[0].x+e[2].x)/2+"px",y:(e[0].y+e[2].y)/2+"px"},width:e[2].x-e[0].x+"px",height:e[2].y-e[0].y+"px"}})}catch(e){const t=e.message||e;console.warn(t)}t._framePipeline&&(t._framePipeline._data=null)}}else{if(16&t._dceEnhancedFeatures){if(this._autoZoomParameters.autoZoomInFrameArray.push(!1),this._autoZoomParameters.autoZoomInFrameArray.splice(0,this._autoZoomParameters.autoZoomInFrameArray.length-this._autoZoomParameters.autoZoomInFrameLimit[0]),this._autoZoomParameters.autoZoomOutFrameCount++,this._autoZoomParameters.frameArrayInIdealZoom.push(!1),this._autoZoomParameters.frameArrayInIdealZoom.splice(0,this._autoZoomParameters.frameArrayInIdealZoom.length-this._autoZoomParameters.frameLimitInIdealZoom[0]),this._autoZoomParameters.autoZoomOutFrameCount>=this._autoZoomParameters.autoZoomOutFrameLimit){this._autoZoomParameters.autoZoomOutFrameCount=0;const i=t.getZoomSettings().factor;let s=i-Math.max((i-1)*this._autoZoomParameters.autoZoomOutStepRate,this._autoZoomParameters.autoZoomOutMinStep);s=Math.max(t._dceAutoZoomRange.min,s),s=Math.min(t._dceAutoZoomRange.max,s);try{await n({factor:s})}catch(e){const t=e.message||e;console.warn(t)}t._framePipeline&&(t._framePipeline._data=null)}4&t._dceEnhancedFeatures&&o({mode:"continuous"}).catch(()=>{})}!(16&t._dceEnhancedFeatures)&&4&t._dceEnhancedFeatures&&(this._autoZoomParameters.autoFocusFrameArray.length=0,o({mode:"continuous"}).catch(()=>{}))}}},this.isDce=!0,this.cameraEnhancer=e}};var mt,gt,ft,pt,Et,yt,It,vt,Rt,Ct,Tt,wt,St,At,Dt,bt,Lt,Ot,Nt,Mt,Bt,Ft,xt;!function(e){e[e.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",e[e.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}(mt||(mt={}));const Pt={onTaskResultsReceived:()=>{},isFilter:!0};Ce[-2]=async e=>{kt.onDataLoadProgressChanged&&kt.onDataLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class kt{constructor(){gt.add(this),this.maxImageSideLength=["iPhone","Android","HarmonyOS"].includes(Me.browserInfo.OS)?2048:4096,this.onCaptureError=null,this.provideDsImage=null,this._isOutputOriginalImage=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1,this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._minImageCaptureInterval=0,this._averageProcessintTimeArray=[],this._averageFetchImageTimeArray=[],this._currentSettings=null,this._averageTime=999,this._dynamsoft=!0,this._enhancedFeaturesIrr=null,this._templateName="",this._isCapturing=!1,this._s=!1,ft.set(this,null),pt.set(this,null),Et.set(this,null),yt.set(this,null),It.set(this,null),vt.set(this,new Set),Rt.set(this,new Set),Ct.set(this,new Set),Tt.set(this,500),wt.set(this,0),St.set(this,0),At.set(this,0),Dt.set(this,!1),bt.set(this,!1),this._singleFrameModeCallbackBind=this._singleFrameModeCallback.bind(this)}get disposed(){return Ue(this,bt,"f")}get isCapturing(){return this._isCapturing}static async createInstance(e=!0){if(!be.license)throw Error("The `license` module cannot be found.");return await be.license.dynamsoft(),await Me.loadWasm(),await new Promise((t,i)=>{const s=new kt;let n=Re();Ce[n]=async e=>{e.success?(s._instanceID=e.instanceID,s._currentSettings=JSON.parse(JSON.parse(e.outputSettings).data),kt._isNoOnnx=e.isNoOnnx,it._version=`3.4.30-dev-20260629163033(Worker: ${De.cvr.worker}, Wasm: ${e.version})`,Ve(s,Dt,!0,"f"),Ve(s,yt,s.getIntermediateResultManager(),"f"),Ve(s,Dt,!1,"f"),t(s)):ot({message:e.message,rj:i,stack:e.stack,functionName:"createInstance"})},Ie.postMessage({type:"cvr_createInstance",id:n,body:{loadPresetTemplates:e}})})}static async appendDLModelBuffer(e,t){return await Me.loadWasm(),kt._isNoOnnx?Promise.reject("Model not supported in the current environment."):await new Promise((i,s)=>{let n=Re();const r=b(Me.engineResourcePaths);let o;Ce[n]=async e=>{if(e.success){const t=JSON.parse(e.response);if(0!==t.errorCode&&ot({message:t.errorString?t.errorString:"Append Model Buffer Failed.",rj:s,errorCode:t.errorCode,functionName:"appendDLModelBuffer"}))return;return i(t)}ot({message:e.message,rj:s,stack:e.stack,functionName:"appendDLModelBuffer"})},t?o=t.endsWith("/")?t:t+"/":"DCV"===Me._bundleEnv?o=r.dcvData+"models/":"DBR"===Me._bundleEnv&&(o=r.dbrBundle+"models/");let a=Array.isArray(e)?e:[e];a=a.map(e=>e.replace(/\.data$/i,"")),Ie.postMessage({type:"cvr_appendDLModelBuffer",id:n,body:{modelNames:a,path:o}})})}static async clearDLModelBuffers(){return await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e();ot({message:i.message,rj:t,stack:i.stack,functionName:"clearDLModelBuffers"})},Ie.postMessage({type:"cvr_clearDLModelBuffers",id:i})})}async _singleFrameModeCallback(){const e=Ue(this,ft,"f")._singleFrameModeResultForDcv;if(!e)return;for(let t of Ue(this,vt,"f"))this._isOutputOriginalImage&&t.onOriginalImageResultReceived&&t.onOriginalImageResultReceived(rt(e));const t={bytes:new Uint8Array(e.bytes),width:e.width,height:e.height,stride:e.stride,format:e.format,imageTag:e.imageTag},i=await this.capture(t,this._templateName);i.originalImageTag=e.imageTag,Ue(this,ft,"f")._cameraView._capturedResultReceiver.onCapturedResultReceived(i,{isDetectVerifyOpen:this._isOpenDetectVerify,isNormalizeVerifyOpen:this._isOpenNormalizeVerify,isBarcodeVerifyOpen:this._isOpenBarcodeVerify,isLabelVerifyOpen:this._isOpenLabelVerify}),Ue(this,gt,"m",Nt).call(this,i),Ue(this,ft,"f")._singleFrameModeResultForDcv=null}setInput(e){if(nt(this),!this.isCapturing)if(Ve(this,ft,e,"f"),null==e?void 0:e.isCameraEnhancer){if(this._enhancedFeaturesIrr)return;this._enhancedFeaturesIrr=new _t(e),Ue(this,yt,"f").addResultReceiver(this._enhancedFeaturesIrr)}else Ue(this,yt,"f").removeResultReceiver(this._enhancedFeaturesIrr),this._enhancedFeaturesIrr=null}getInput(){return Ue(this,ft,"f")}addImageSourceStateListener(e){if(nt(this),"object"!=typeof e)return console.warn("Invalid ISA state listener.");e&&Object.keys(e)&&Ue(this,Rt,"f").add(e)}removeImageSourceStateListener(e){return nt(this),Ue(this,Rt,"f").delete(e)}async addResultReceiver(e){if(nt(this),"object"!=typeof e)throw new Error("Invalid receiver.");e&&Object.keys(e).length&&(Ue(this,vt,"f").add(e),await this._setCrrRegistry())}async removeResultReceiver(e){nt(this),Ue(this,vt,"f").delete(e),await this._setCrrRegistry()}async removeAllResultReceivers(){nt(this),Ue(this,vt,"f").clear(),await this._setCrrRegistry()}async _setCrrRegistry(){const e={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onProcessedDocumentResultReceived:!1,onParsedResultsReceived:!1};for(let t of Ue(this,vt,"f"))t.isDce||(e.onCapturedResultReceived=!!t.onCapturedResultReceived,e.onDecodedBarcodesReceived=!!t.onDecodedBarcodesReceived,e.onRecognizedTextLinesReceived=!!t.onRecognizedTextLinesReceived,e.onProcessedDocumentResultReceived=!!t.onProcessedDocumentResultReceived,e.onParsedResultsReceived=!!t.onParsedResultsReceived);let t=Re();return await new Promise((i,s)=>{Ce[t]=async e=>{e.success?i():ot({message:e.message,rj:s,stack:e.stack,functionName:"addResultReceiver"})},Ie.postMessage({type:"cvr_setCrrRegistry",id:t,instanceID:this._instanceID,body:{receiver:JSON.stringify(e)}})})}async addResultFilter(e){if(nt(this),!e._dynamsoft)throw new Error("User defined CapturedResultFilter is not supported.");if(!e||"object"!=typeof e||!Object.keys(e).length)return console.warn("Invalid filter.");Ue(this,Ct,"f").add(e),e._dynamsoft(),await this._handleFilterUpdate()}async removeResultFilter(e){nt(this),Ue(this,Ct,"f").delete(e),await this._handleFilterUpdate()}async removeAllResultFilters(){nt(this),Ue(this,Ct,"f").clear(),await this._handleFilterUpdate()}async _handleFilterUpdate(){if(Ue(this,yt,"f").removeResultReceiver(Pt),0===Ue(this,Ct,"f").size){this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1;const e={[ie.CRIT_BARCODE]:!1,[ie.CRIT_TEXT_LINE]:!1,[ie.CRIT_DETECTED_QUAD]:!1,[ie.CRIT_DESKEWED_IMAGE]:!1,[ie.CRIT_ENHANCED_IMAGE]:!1},t={[ie.CRIT_BARCODE]:!1,[ie.CRIT_TEXT_LINE]:!1,[ie.CRIT_DETECTED_QUAD]:!1,[ie.CRIT_DESKEWED_IMAGE]:!1,[ie.CRIT_ENHANCED_IMAGE]:!1};return await Ue(this,gt,"m",Mt).call(this,e),void await Ue(this,gt,"m",Bt).call(this,t)}for(let e of Ue(this,Ct,"f"))this._isOpenBarcodeVerify=e.isResultCrossVerificationEnabled(ie.CRIT_BARCODE),this._isOpenLabelVerify=e.isResultCrossVerificationEnabled(ie.CRIT_TEXT_LINE),this._isOpenDetectVerify=e.isResultCrossVerificationEnabled(ie.CRIT_DETECTED_QUAD),this._isOpenNormalizeVerify=e.isResultCrossVerificationEnabled(ie.CRIT_DESKEWED_IMAGE),e.isLatestOverlappingEnabled(ie.CRIT_BARCODE)&&([...Ue(this,yt,"f")._intermediateResultReceiverSet.values()].find(e=>e.isFilter)||Ue(this,yt,"f").addResultReceiver(Pt)),await Ue(this,gt,"m",Mt).call(this,e.verificationEnabled),await Ue(this,gt,"m",Bt).call(this,e.duplicateFilterEnabled),await Ue(this,gt,"m",Ft).call(this,e.duplicateForgetTime),await Ue(this,gt,"m",xt).call(this,e.crossVerificationCriteria)}async startCapturing(e){var t;if(nt(this),this.isCapturing)return;if(!Ue(this,ft,"f"))throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");e||(e=kt._defaultTemplate);for(let e of Ue(this,Ct,"f"))await this.addResultFilter(e);const i=b(Me.engineResourcePaths);if(Ue(this,Et,"f")&&Ue(this,Et,"f").isPending)return Ue(this,Et,"f");const s=Ve(this,At,(t=Ue(this,At,"f"),++t),"f");return Ve(this,Et,new je((t,n)=>{if(this.disposed)return;let r=Re();Ce[r]=async i=>{Ue(this,Et,"f")&&!Ue(this,Et,"f").isFulfilled&&s===Ue(this,At,"f")&&(i.success?(this._isCapturing=!0,this._templateName=e,void 0!==Ue(this,ft,"f").singleFrameMode&&"disabled"!==Ue(this,ft,"f").singleFrameMode?(Ue(this,ft,"f").on("singleFrameAcquired",this._singleFrameModeCallbackBind),this._singleFrameModeCallback(),t()):(this._isOutputOriginalImage=i.isOutputOriginalImage,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(async()=>{if(s===Ue(this,At,"f")&&this.isCapturing){-1!==this._minImageCaptureInterval&&Ue(this,ft,"f").startFetching();for(let e of Ue(this,Rt,"f"))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(mt.ISS_BUFFER_EMPTY);this.barcodeScanLoop(e,s),t()}},0))):ot({message:i.message,rj:n,stack:i.stack,functionName:"startCapturing"}))},Ie.postMessage({type:"cvr_startCapturing",id:r,instanceID:this._instanceID,body:{templateName:e,engineResourcePaths:i}})}),"f"),await Ue(this,Et,"f")}stopCapturing(){var e;if(nt(this),!Ue(this,ft,"f"))return;Ve(this,At,(e=Ue(this,At,"f"),++e),"f"),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=null,Ue(this,ft,"f").stopFetching(),this._averageProcessintTimeArray=[],this._isCapturing=!1,this._averageTime=999,Ve(this,Et,null,"f"),Ue(this,ft,"f").isCameraEnhancer&&Ue(this,ft,"f").off("singleFrameAcquired",this._singleFrameModeCallbackBind);const t=Re();Ie.postMessage({type:"cvr_stopCapturing",id:t,instanceID:this._instanceID})}async containsTask(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(JSON.parse(e.tasks));ot({message:e.message,rj:i,stack:e.stack,functionName:"containsTask"})},Ie.postMessage({type:"cvr_containsTask",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async switchCapturingTemplate(e){const t=!this.isCapturing;if(!t){if(this.stopCapturing(),!await this.checkTemplateNameValidity(e))return await this.startCapturing(this._templateName),Promise.reject(new Error("[switchCapturingTemplate] [-10036] The template name is invalid."));if(!t)try{await this.startCapturing(e)}catch(e){return"string"==typeof e.message&&(e.message=e.message.replace("startCapturing","switchCapturingTemplate")),Promise.reject(e)}}}async barcodeScanLoop(e,t=Ue(this,At,"f")){if(t!==Ue(this,At,"f")||!this.isCapturing)return;if(Ue(this,ft,"f").isBufferEmpty())if(Ue(this,ft,"f").hasNextImageToFetch())for(let e of Ue(this,Rt,"f"))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(mt.ISS_BUFFER_EMPTY);else if(!Ue(this,ft,"f").hasNextImageToFetch())for(let e of Ue(this,Rt,"f"))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(mt.ISS_EXHAUSTED);const i=Ue(this,ft,"f").getImage();if(!i)return void this.continueLoop(e,t);if(i.imageTag&&Date.now()-i.imageTag.timeStamp>200)return void this.continueLoop(e,t);for(let e of Ue(this,vt,"f"))this._isOutputOriginalImage&&e.onOriginalImageResultReceived&&e.onOriginalImageResultReceived(rt(i));i._s=!0;const s=Date.now();this._captureInWorker(i,e).then(async n=>{if(t!==Ue(this,At,"f")||!this.isCapturing)return;if(kt._onLog&&kt._onLog("no js handle time: "+(Date.now()-s)),!this.isCapturing)return void this.continueLoop(e,t);n.originalImageTag=i.imageTag?i.imageTag:null,Ue(this,ft,"f")._capturedResultReceiver&&Ue(this,ft,"f")._cameraView._capturedResultReceiver.onCapturedResultReceived(n,{isDetectVerifyOpen:this._isOpenDetectVerify,isNormalizeVerifyOpen:this._isOpenNormalizeVerify,isBarcodeVerifyOpen:this._isOpenBarcodeVerify,isLabelVerifyOpen:this._isOpenLabelVerify});for(let e of Ue(this,Ct,"f")){const t=e;t.onOriginalImageResultReceived(n),t.onDecodedBarcodesReceived(n),t.onRecognizedTextLinesReceived(n),t.onProcessedDocumentResultReceived(n),t.onParsedResultsReceived(n)}Ue(this,gt,"m",Nt).call(this,n);const r=Date.now();if(this._minImageCaptureInterval>-1&&(5===this._averageProcessintTimeArray.length&&this._averageProcessintTimeArray.shift(),5===this._averageFetchImageTimeArray.length&&this._averageFetchImageTimeArray.shift(),this._averageProcessintTimeArray.push(Date.now()-s),this._averageFetchImageTimeArray.push(i&&i.imageTag?i.imageTag.timeSpent:0),this._averageTime=Math.min(...this._averageProcessintTimeArray)-Math.max(...this._averageFetchImageTimeArray),this._averageTime=this._averageTime>0?this._averageTime:0,kt._onLog&&(kt._onLog(`minImageCaptureInterval: ${this._minImageCaptureInterval}`),kt._onLog(`averageProcessintTimeArray: ${this._averageProcessintTimeArray}`),kt._onLog(`averageFetchImageTimeArray: ${this._averageFetchImageTimeArray}`),kt._onLog(`averageTime: ${this._averageTime}`))),kt._onLog){const e=Date.now()-r;e>10&&kt._onLog(`fetch image calculate time: ${e}`)}kt._onLog&&kt._onLog(`time finish decode: ${Date.now()}`),kt._onLog&&kt._onLog("main time: "+(Date.now()-s)),kt._onLog&&kt._onLog("===================================================="),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._minImageCaptureInterval>0&&this._minImageCaptureInterval>=this._averageTime?this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(e,t)},this._minImageCaptureInterval-this._averageTime):this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(e,t)},Math.max(this._minImageCaptureInterval,0))}).catch(i=>{t===Ue(this,At,"f")&&(Ue(this,ft,"f").stopFetching(),"platform error"!==i.message&&(i.errorCode&&0===i.errorCode&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{Ue(this,ft,"f").startFetching(),this.barcodeScanLoop(e,t)},Math.max(this._minImageCaptureInterval,1e3))),setTimeout(()=>{if(t===Ue(this,At,"f")){if(!this.onCaptureError)throw i;this.onCaptureError(i)}},0)))})}continueLoop(e,t=Ue(this,At,"f")){t===Ue(this,At,"f")&&this.isCapturing&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(e,t)},0))}async getClarity(e,t,i,s,n){const{bytes:r,width:o,height:a,stride:c,format:l}=e;let d=Re();return new Promise((e,u)=>{Ce[d]=async t=>{t.success?e(t.clarity):ot({message:t.message,rj:u,stack:t.stack,functionName:"getClarity"})},Ie.postMessage({type:"cvr_getClarity",id:d,instanceID:this._instanceID,body:{bytes:r,width:o,height:a,stride:c,format:l,bitcount:t,wr:i,hr:s,grayThreshold:n}},[r.buffer])})}async capture(e,t){let i;if(nt(this),t||(t=kt._defaultTemplate),C(e))i=await this._captureDsimage(e,t);else if("string"==typeof e)i="data:image/"==e.substring(0,11)?await this._captureBase64(e,t):await this._captureUrl(e,t);else if(e instanceof Blob)i=await this._captureBlob(e,t);else if(e instanceof HTMLImageElement)i=await this._captureImage(e,t);else if(e instanceof HTMLCanvasElement)i=await this._captureCanvas(e,t);else{if(!(e instanceof HTMLVideoElement))throw new TypeError("'capture(imageOrFile, templateName)': Type of 'imageOrFile' should be 'DSImageData', 'Url', 'Base64', 'Blob', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement'.");i=await this._captureVideo(e,t)}return i}async _captureDsimage(e,t){return await this._captureInWorker(e,t)}async _captureUrl(e,t){let i=await S(e,"blob");return await this._captureBlob(i,t)}async _captureBase64(e,t){e=e.substring(e.indexOf(",")+1);let i=atob(e),s=i.length,n=new Uint8Array(s);for(;s--;)n[s]=i.charCodeAt(s);return await this._captureBlob(new Blob([n]),t)}async _captureBlob(e,t){let i=null,s=null;if("undefined"!=typeof createImageBitmap)try{i=await createImageBitmap(e)}catch(e){}i||(s=await async function(t){return await new Promise((i,s)=>{let n=URL.createObjectURL(t),r=new Image;r.src=n,r.onload=()=>{URL.revokeObjectURL(r.dbrObjUrl),i(r)},r.onerror=()=>{let t="Unsupported image format. Please upload files in one of the following formats: .jpg,.jpeg,.ico,.gif,.svg,.webp,.png,.bmp";"image/svg+xml"===e.type&&(t="Invalid SVG file. The file appears to be malformed or contains invalid XML."),s(new Error(t))}})}(e));let n=await this._captureImage(i||s,t);return i&&i.close(),n}async _captureImage(e,t){let i,s,n=e instanceof HTMLImageElement?e.naturalWidth:e.width,r=e instanceof HTMLImageElement?e.naturalHeight:e.height,o=Math.max(n,r);o>this.maxImageSideLength?(Ve(this,St,this.maxImageSideLength/o,"f"),i=Math.round(n*Ue(this,St,"f")),s=Math.round(r*Ue(this,St,"f"))):(i=n,s=r),Ue(this,pt,"f")||Ve(this,pt,document.createElement("canvas"),"f");const a=Ue(this,pt,"f");return a.width===i&&a.height===s||(a.width=i,a.height=s),a.ctx2d||(a.ctx2d=a.getContext("2d",{willReadFrequently:!0})),a.ctx2d.drawImage(e,0,0,n,r,0,0,i,s),e.dbrObjUrl&&URL.revokeObjectURL(e.dbrObjUrl),await this._captureCanvas(a,t)}async _captureCanvas(e,t){if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";if([e.width,e.height].includes(0))throw Error("The width or height of the 'canvas' is 0.");const i=e.ctx2d||e.getContext("2d",{willReadFrequently:!0}),s={bytes:Uint8Array.from(i.getImageData(0,0,e.width,e.height).data),width:e.width,height:e.height,stride:4*e.width,format:_.IPF_ABGR_8888};return await this._captureInWorker(s,t)}async _captureVideo(e,t){if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";let i,s,n=e.videoWidth,r=e.videoHeight,o=Math.max(n,r);o>this.maxImageSideLength?(Ve(this,St,this.maxImageSideLength/o,"f"),i=Math.round(n*Ue(this,St,"f")),s=Math.round(r*Ue(this,St,"f"))):(i=n,s=r),Ue(this,pt,"f")||Ve(this,pt,document.createElement("canvas"),"f");const a=Ue(this,pt,"f");return a.width===i&&a.height===s||(a.width=i,a.height=s),a.ctx2d||(a.ctx2d=a.getContext("2d",{willReadFrequently:!0})),a.ctx2d.drawImage(e,0,0,n,r,0,0,i,s),await this._captureCanvas(a,t)}async _captureInWorker(e,t){let{bytes:i,width:s,height:n,stride:r,format:o,imageTag:a}=e,c=Re();return await new Promise((l,d)=>{this.provideDsImage=e,Ce[c]=t=>{if(t.success){const i=Date.now();kt._onLog&&(kt._onLog(`get result time from worker: ${i}`),kt._onLog("worker to main time consume: "+(i-t.workerReturnMsgTime)));try{Ue(this,gt,"m",Lt).call(this,t.captureResult,e),e.bytes=t.bytes,t._s||Ve(this,St,0,"f"),Ue(this,gt,"m",Ot).call(this,t.intermediateResult,a);const i=Date.now();return i-Ue(this,wt,"f")>Ue(this,Tt,"f")&&null!==t.mliRecord&&(null===localStorage||void 0===localStorage||localStorage.setItem("dynamsoft",t.mliRecord),Ve(this,wt,i,"f")),l(t.captureResult)}catch(e){ot({message:e.message,rj:d,stack:e.stack,functionName:"capture"})}}else ot({message:t.message,rj:d,stack:t.stack,functionName:"capture"})},kt._onLog&&kt._onLog(`send buffer to worker: ${Date.now()}`);const u=e.hasOwnProperty("_s")?e._s:this._s;Ie.postMessage({type:"cvr_capture",id:c,instanceID:this._instanceID,body:{bytes:i,width:s,height:n,stride:r,format:o,templateName:t||"",dynamsoft:this._dynamsoft,_s:u}},[i.buffer])})}async initSettings(e){return nt(this),this.isCapturing?Promise.reject(new Error("initSettings:-10062:Failed to call the function while capturing in progress.")):e&&["string","object"].includes(typeof e)?("string"==typeof e?e.trimStart().startsWith("{")||(e=await S(e,"text")):"object"==typeof e&&(e=JSON.stringify(e)),await new Promise((t,i)=>{let s=Re();Ce[s]=async s=>{if(s.success){const n=JSON.parse(s.response);if(0!==n.errorCode&&ot({message:n.errorString?n.errorString:"Init Settings Failed.",rj:i,errorCode:n.errorCode,functionName:"initSettings"}))return;const r=JSON.parse(e);return this._currentSettings=r,this._isOutputOriginalImage=1===this._currentSettings.CaptureVisionTemplates[0].OutputOriginalImage,kt._defaultTemplate=this._currentSettings.CaptureVisionTemplates[0].Name,t(n)}ot({message:s.message,rj:i,stack:s.stack,functionName:"initSettings"})},Ie.postMessage({type:"cvr_initSettings",id:s,instanceID:this._instanceID,body:{settings:e}})})):void console.error("Invalid template.")}async outputSettings(e,t){return nt(this),await new Promise((i,s)=>{let n=Re();Ce[n]=async e=>{if(e.success){const t=JSON.parse(e.response);if(0!==t.errorCode&&ot({message:t.errorString,rj:s,errorCode:t.errorCode,functionName:"outputSettings"}))return;return i(JSON.parse(t.data))}ot({message:e.message,rj:s,stack:e.stack,functionName:"outputSettings"})},Ie.postMessage({type:"cvr_outputSettings",id:n,instanceID:this._instanceID,body:{templateName:e,includeDefaultValues:!!t}})})}async outputSettingsToFile(e,t,i,s){const n=await this.outputSettings(e,s),r=new Blob([JSON.stringify(n,null,2,function(e,t){return t instanceof Array?JSON.stringify(t):t},2)],{type:"application/json"});if(i){const e=document.createElement("a");e.href=URL.createObjectURL(r),t.endsWith(".json")&&(t=t.replace(".json","")),e.download=`${t}.json`,e.onclick=()=>{setTimeout(()=>{URL.revokeObjectURL(e.href)},500)},e.click()}return r}async getTemplateNames(){return nt(this),await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&ot({message:s.errorString,rj:t,errorCode:s.errorCode,functionName:"getTemplateNames"}))return;return e(JSON.parse(s.data))}ot({message:i.message,rj:t,stack:i.stack,functionName:"getTemplateNames"})},Ie.postMessage({type:"cvr_getTemplateNames",id:i,instanceID:this._instanceID})})}async getSimplifiedSettings(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success){const s=JSON.parse(e.response);if(0!==s.errorCode&&ot({message:s.errorString,rj:i,errorCode:s.errorCode,functionName:"getSimplifiedSettings"}))return;const n=JSON.parse(s.data,(e,t)=>"barcodeFormatIds"===e?BigInt(t):t);return n.minImageCaptureInterval=this._minImageCaptureInterval,t(n)}ot({message:e.message,rj:i,stack:e.stack,functionName:"getSimplifiedSettings"})},Ie.postMessage({type:"cvr_getSimplifiedSettings",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async updateSettings(e,t){return nt(this),await new Promise((i,s)=>{let n=Re();Ce[n]=async e=>{if(e.success){const n=JSON.parse(e.response);if(t.minImageCaptureInterval&&t.minImageCaptureInterval>=-1&&(this._minImageCaptureInterval=t.minImageCaptureInterval),this._isOutputOriginalImage=e.isOutputOriginalImage,0!==n.errorCode&&ot({message:n.errorString?n.errorString:"Update Settings Failed.",rj:s,errorCode:n.errorCode,functionName:"updateSettings"}))return;return this._currentSettings=await this.outputSettings("*"),i(n)}ot({message:e.message,rj:s,stack:e.stack,functionName:"updateSettings"})},Ie.postMessage({type:"cvr_updateSettings",id:n,instanceID:this._instanceID,body:{settings:t,templateName:e}})})}async resetSettings(){return nt(this),this.isCapturing?Promise.reject(new Error("resetSettings:-10062:Failed to call the function while capturing in progress.")):await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&ot({message:s.errorString?s.errorString:"Reset Settings Failed.",rj:t,errorCode:s.errorCode,functionName:"resetSettings"}))return;return this._currentSettings=await this.outputSettings("*"),e(s)}ot({message:i.message,rj:t,stack:i.stack,functionName:"resetSettings"})},Ie.postMessage({type:"cvr_resetSettings",id:i,instanceID:this._instanceID})})}getBufferedItemsManager(){return Ue(this,It,"f")||Ve(this,It,new Ze(this),"f"),Ue(this,It,"f")}getIntermediateResultManager(){if(nt(this),!Ue(this,Dt,"f")&&0!==Me.bSupportIRTModule)throw new Error("The current license does not support the use of intermediate results.");return Ue(this,yt,"f")||Ve(this,yt,new Ye(this),"f"),Ue(this,yt,"f")}static async setGlobalIntraOpNumThreads(e=0){return e>4||e<0?Promise.reject(new RangeError("'intraOpNumThreads' should be between 0 and 4.")):(await Me.loadWasm(),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t();ot({message:e.message,rj:i,stack:e.stack,functionName:"setGlobalIntraOpNumThreads"})},Ie.postMessage({type:"cvr_setGlobalIntraOpNumThreads",id:s,body:{intraOpNumThreads:e}})}))}async checkTemplateNameValidity(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>e.success?t(e.isValid):t(!1),Ie.postMessage({type:"cvr_checkTemplateNameValidity",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async parseRequiredResources(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(JSON.parse(e.resources));ot({message:e.message,rj:i,stack:e.stack,functionName:"parseRequiredResources"})},Ie.postMessage({type:"cvr_parseRequiredResources",id:s,instanceID:this._instanceID,body:{templateName:e}})})}dispose(){nt(this),Ue(this,Et,"f")&&this.stopCapturing(),Ve(this,ft,null,"f"),Ue(this,vt,"f").clear(),Ue(this,Rt,"f").clear(),Ue(this,Ct,"f").clear(),Ue(this,yt,"f")._intermediateResultReceiverSet.clear(),Ve(this,bt,!0,"f");let e=Re();Ce[e]=e=>{e.success||ot({message:e.message,stack:e.stack,isShouldThrow:!0,functionName:"dispose"})},Ie.postMessage({type:"cvr_dispose",id:e,instanceID:this._instanceID})}_getInternalData(){return{isa:Ue(this,ft,"f"),promiseStartScan:Ue(this,Et,"f"),intermediateResultManager:Ue(this,yt,"f"),bufferdItemsManager:Ue(this,It,"f"),resultReceiverSet:Ue(this,vt,"f"),isaStateListenerSet:Ue(this,Rt,"f"),resultFilterSet:Ue(this,Ct,"f"),compressRate:Ue(this,St,"f"),canvas:Ue(this,pt,"f"),innerUseTag:Ue(this,Dt,"f"),isDestroyed:Ue(this,bt,"f")}}async _getWasmFilterState(){return await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success){const t=JSON.parse(i.response);return e(t)}ot({message:i.message,rj:t,stack:i.stack,functionName:""})},Ie.postMessage({type:"cvr_getWasmFilterState",id:i,instanceID:this._instanceID})})}}ft=new WeakMap,pt=new WeakMap,Et=new WeakMap,yt=new WeakMap,It=new WeakMap,vt=new WeakMap,Rt=new WeakMap,Ct=new WeakMap,Tt=new WeakMap,wt=new WeakMap,St=new WeakMap,At=new WeakMap,Dt=new WeakMap,bt=new WeakMap,gt=new WeakSet,Lt=function(e,t){var i,s,n,r,o,a,c,l,d,u,h,_;for(let m=0;m<e.items.length;m++){const g=e.items[m];switch(0!==Ue(this,St,"f")&&st(g,Ue(this,St,"f")),g.type){case ie.CRIT_ORIGINAL_IMAGE:e.items[m]=rt(t);break;case ie.CRIT_BARCODE:null!==(i=(c=e.decodedBarcodesResult).barcodeResultItems)&&void 0!==i||(c.barcodeResultItems=[]),e.decodedBarcodesResult.barcodeResultItems.push(g);break;case ie.CRIT_TEXT_LINE:null!==(s=(l=e.recognizedTextLinesResult).textLineResultItems)&&void 0!==s||(l.textLineResultItems=[]),e.recognizedTextLinesResult.textLineResultItems.push(g);break;case ie.CRIT_DETECTED_QUAD:null!==(n=(d=e.processedDocumentResult).detectedQuadResultItems)&&void 0!==n||(d.detectedQuadResultItems=[]),e.processedDocumentResult.detectedQuadResultItems.push(g);break;case ie.CRIT_DESKEWED_IMAGE:be.ddn&&be.ddn.handleDeskewedAndEnhancedImageResultItem(g),null!==(r=(u=e.processedDocumentResult).deskewedImageResultItems)&&void 0!==r||(u.deskewedImageResultItems=[]),e.processedDocumentResult.deskewedImageResultItems.push(g);break;case ie.CRIT_ENHANCED_IMAGE:be.ddn&&be.ddn.handleDeskewedAndEnhancedImageResultItem(g),null!==(o=(h=e.processedDocumentResult).enhancedImageResultItems)&&void 0!==o||(h.enhancedImageResultItems=[]),e.processedDocumentResult.enhancedImageResultItems.push(g);break;case ie.CRIT_PARSED_RESULT:be.dcp&&be.dcp.handleParsedResultItem(g),null!==(a=(_=e.parsedResult).parsedResultItems)&&void 0!==a||(_.parsedResultItems=[]),e.parsedResult.parsedResultItems.push(g)}}},Ot=function(e,t){const i=e;if(i){let e=0;for(let s of Ue(this,yt,"f")._intermediateResultReceiverSet){e++;for(let n of i){if(["onTaskResultsReceived","onTargetROIResultsReceived"].includes(n.info.callbackName)){for(let e of n.intermediateResultUnits)e.originalImageTag=t||null;s[n.info.callbackName]&&s[n.info.callbackName]({intermediateResultUnits:n.intermediateResultUnits},n.info)}else s[n.info.callbackName]&&s[n.info.callbackName](n.result,n.info);e===Ue(this,yt,"f")._intermediateResultReceiverSet.size&&delete n.info.callbackName}}}},Nt=function(e){for(let t of Ue(this,vt,"f"))e.decodedBarcodesResult&&t.onDecodedBarcodesReceived&&t.onDecodedBarcodesReceived(e.decodedBarcodesResult),e.recognizedTextLinesResult&&t.onRecognizedTextLinesReceived&&t.onRecognizedTextLinesReceived(e.recognizedTextLinesResult),e.processedDocumentResult&&t.onProcessedDocumentResultReceived&&t.onProcessedDocumentResultReceived(e.processedDocumentResult),e.parsedResult&&t.onParsedResultsReceived&&t.onParsedResultsReceived(e.parsedResult),t.onCapturedResultReceived&&t.onCapturedResultReceived(e)},Mt=async function(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(e.result);ot({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Ie.postMessage({type:"cvr_enableResultCrossVerification",id:s,instanceID:this._instanceID,body:{verificationEnabled:e}})})},Bt=async function(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(e.result);ot({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Ie.postMessage({type:"cvr_enableResultDeduplication",id:s,instanceID:this._instanceID,body:{duplicateFilterEnabled:e}})})},Ft=async function(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t(e.result);ot({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Ie.postMessage({type:"cvr_setDuplicateForgetTime",id:s,instanceID:this._instanceID,body:{duplicateForgetTime:e}})})},xt=async function(e){return nt(this),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success)return t();ot({message:e.message,rj:i,stack:e.stack,functionName:"setResultCrossVerificationCriteria"})},Ie.postMessage({type:"cvr_setResultCrossVerificationCriteria",id:s,instanceID:this._instanceID,body:{criteria:e}})})},kt._defaultTemplate="Default",kt._isNoOnnx=!1;class Ut{constructor(){this.onCapturedResultReceived=null,this.onOriginalImageResultReceived=null}}var Vt;!function(e){e.PT_DEFAULT="Default",e.PT_READ_BARCODES="ReadBarcodes_Default",e.PT_RECOGNIZE_TEXT_LINES="RecognizeTextLines_Default",e.PT_DETECT_DOCUMENT_BOUNDARIES="DetectDocumentBoundaries_Default",e.PT_DETECT_AND_NORMALIZE_DOCUMENT="DetectAndNormalizeDocument_Default",e.PT_NORMALIZE_DOCUMENT="NormalizeDocument_Default",e.PT_READ_BARCODES_SPEED_FIRST="ReadBarcodes_SpeedFirst",e.PT_READ_BARCODES_READ_RATE_FIRST="ReadBarcodes_ReadRateFirst",e.PT_READ_BARCODES_BALANCE="ReadBarcodes_Balance",e.PT_READ_SINGLE_BARCODE="ReadSingleBarcode",e.PT_READ_DENSE_BARCODES="ReadDenseBarcodes",e.PT_READ_DISTANT_BARCODES="ReadDistantBarcodes",e.PT_RECOGNIZE_NUMBERS="RecognizeNumbers",e.PT_RECOGNIZE_LETTERS="RecognizeLetters",e.PT_RECOGNIZE_NUMBERS_AND_LETTERS="RecognizeNumbersAndLetters",e.PT_RECOGNIZE_NUMBERS_AND_UPPERCASE_LETTERS="RecognizeNumbersAndUppercaseLetters",e.PT_RECOGNIZE_UPPERCASE_LETTERS="RecognizeUppercaseLetters"}(Vt||(Vt={}));var Gt,Wt,jt,Zt=Object.freeze({__proto__:null,CaptureVisionRouter:kt,CaptureVisionRouterModule:it,CapturedResultReceiver:Ut,get EnumImageSourceState(){return mt},get EnumPresetTemplate(){return Vt},IntermediateResultReceiver:class{constructor(){this._observedResultUnitTypes=ue.IRUT_ALL,this._observedTaskMap=new Map,this._parameters={setObservedResultUnitTypes:e=>{this._observedResultUnitTypes=e},getObservedResultUnitTypes:()=>this._observedResultUnitTypes,isResultUnitTypeObserved:e=>!!(e&this._observedResultUnitTypes),addObservedTask:e=>{this._observedTaskMap.set(e,!0)},removeObservedTask:e=>{this._observedTaskMap.set(e,!1)},isTaskObserved:e=>0===this._observedTaskMap.size||!!this._observedTaskMap.get(e)},this.onTaskResultsReceived=null,this.onPredetectedRegionsReceived=null,this.onColourImageUnitReceived=null,this.onScaledColourImageUnitReceived=null,this.onGrayscaleImageUnitReceived=null,this.onTransformedGrayscaleImageUnitReceived=null,this.onEnhancedGrayscaleImageUnitReceived=null,this.onBinaryImageUnitReceived=null,this.onTextureDetectionResultUnitReceived=null,this.onTextureRemovedGrayscaleImageUnitReceived=null,this.onTextureRemovedBinaryImageUnitReceived=null,this.onContoursUnitReceived=null,this.onLineSegmentsUnitReceived=null,this.onTextZonesUnitReceived=null,this.onTextRemovedBinaryImageUnitReceived=null,this.onShortLinesUnitReceived=null}getObservationParameters(){return this._parameters}}});function Ht(e){return e&&"object"==typeof e&&"string"==typeof e.path}function qt(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const Yt=/<style>([\s\S]*?)<\/style>/g,$t=/style="([\s\S]*?)"/g,zt=(e,t)=>{const{inlineScript2Blob:i,internalCss2Blob:s,insertInternalCss2ExistedSheet:n}=t||{};if(n){let t,i;for(let s=0;s<document.styleSheets.length;++s){const n=document.styleSheets[s];try{i=n.cssRules,t=n;break}catch(e){}}t&&(e=e.replace(Yt,(e,s,n,r)=>{let o=s.split("}");const a=o.length-1;let c=[],l=null,d=0;for(let e=0;e<a;++e){let t=0;for(;-1!==(t=o[e].indexOf("{",t));)d+=1,t+=1;if(l)1===d?(c.push(l+o[e]+"}"),l=null,d=0):(l+=o[e]+"}",--d);else{if(d<1)throw new Error("invalid style");1===d?(c.push(o[e].trimStart()+"}"),d=0):(l=o[e].trimStart()+"}",--d)}}if(l||d)throw new Error("invalid style");for(let e of c)t.insertRule(e,i.length);return""}))}const r=[];s&&(e=e.replace(Yt,(e,t,i,s)=>(r.push(new Blob([t],{type:"text/css"})),"<HasStyle></HasStyle>")));const o=[];e=e.replace($t,(e,t,i,s)=>(o.push(t),"hasstyle"));const a=document.createElement("div");if(a.insertAdjacentHTML("beforeend",e),a.normalize(),s){const e=a.querySelectorAll("HasStyle");for(let t=0;t<r.length;t++){const i=r[t],s=e[t],n=document.createElement("link");n.rel="stylesheet",n.href=URL.createObjectURL(i),s.replaceWith(n)}}const c=a.querySelectorAll("[hasstyle]");for(let e=0;e<o.length;e++){const t=o[e],i=c[e];i.removeAttribute("hasstyle");const s=t.split(";").map(e=>e.trim()).filter(e=>e);if(i.style)for(let e of s){const t=e.split(":");i.style[t[0].trim()]=t[1].trim()}}for(let e of a.querySelectorAll("script")){const t=document.createElement("script");e.textContent&&(i&&!e.src?(t.src=URL.createObjectURL(new Blob([e.textContent],{type:"text/javascript"})),t.addEventListener("load",()=>URL.revokeObjectURL(t.src))):t.textContent=e.textContent);for(let i of e.attributes)t.setAttribute(i.name,i.value);e.replaceWith(t)}let l=new DocumentFragment;return l.append(...a.childNodes),1===l.childNodes.length?l.firstChild:l},Kt=e=>e&&"object"==typeof e&&"function"==typeof e.then,Xt=(async()=>{})().constructor;class Qt extends Xt{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,Kt(e)?t=e:"function"==typeof e&&(t=new Xt(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(Kt(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}const Jt="undefined"!=typeof navigator&&((e,t)=>{const i=null===(e=navigator)||void 0===e?void 0:e.userAgent,s=null===(t=navigator)||void 0===t?void 0:t.platform,n=i&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(i);return s&&/Win|Mac|Linux/i.test(s)&&!n})(),ei="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(Gt=window)&&void 0!==Gt&&Gt.MSStream),ti="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent)&&/Firefox/i.test(navigator.userAgent),ii="undefined"!=typeof navigator&&((e,t)=>{const i=navigator.standalone||(null===(e=(t=window).matchMedia)||void 0===e||null===(e=e.call(t,"(display-mode: standalone)"))||void 0===e?void 0:e.matches);return ei&&i})(),si=Jt?{width:1920,height:1080}:{width:1280,height:720},ni=function(){const e=this,t=MediaDeviceInfo.prototype.toJSON.apply(e);return t.trackLabel=e.trackLabel,t.capabilities=e.capabilities,t.isFront=e.isFront,t},ri="The camera feature is available only in secure contexts (HTTPS).";let oi=class e{constructor(){qt(this,"_coreShell",void 0),qt(this,"_video",void 0),qt(this,"_coreInnerLayer",void 0),qt(this,"_coreOuterLayer",void 0),qt(this,"_regionBoxWrapper",void 0),qt(this,"_regionBoxMask",void 0),qt(this,"_regionBoxBorder",void 0),qt(this,"_objectFit","contain"),qt(this,"_uiInlineScript2Blob",!0),qt(this,"_uiInternalCss2Blob",!0),qt(this,"_uiInternalCss2ExistedSheet",!1),qt(this,"_ui",void 0),qt(this,"_pOpen",void 0),qt(this,"_getUserMediaTimeout",1e4),qt(this,"_paused",!1),qt(this,"_shouldClose",!1),qt(this,"_cameraChangedWhenPaused",!1),qt(this,"_requestedCamera","back"),qt(this,"_requestedResolution",si),qt(this,"_regionBox",{unit:"view-size",center:{x:0,y:0},maskStyle:{background:"rgba(0, 0, 0, 0.5)"},borderStyle:{border:"1px solid #00ff7f"}}),qt(this,"_eventListeners",{}),qt(this,"_taskIdIOSResizeProblem",void 0),qt(this,"onOpened",void 0);const t=this._coreShell=document.createElement("div");Object.assign(t.style,{width:"100%",height:"100%",minWidth:"100px",minHeight:"100px",backgroundColor:"black",display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",position:"relative"});const i=this._coreOuterLayer=document.createElement("div");Object.assign(i.style,{width:"auto",height:"100%",minWidth:"100px",minHeight:"100px",aspectRatio:"1",flex:"none",position:"relative",overflow:"hidden"});const s=this._coreInnerLayer=document.createElement("div");Object.assign(s.style,{width:"100%",height:"100%",position:"relative",transformOrigin:"center"});const n=this._video=document.createElement("video");Object.assign(n.style,{width:"100%",height:"100%",position:"absolute",left:"0",top:"0",objectFit:"fill"}),n.muted=!0,n.playsInline=!0,n.addEventListener("resize",()=>{try{this._updateObjectFit()}catch(e){console.error(e)}try{this._updateCanvasSize()}catch(e){console.error(e)}}),s.append(n),i.append(s),t.append(i),"undefined"!=typeof ResizeObserver&&new ResizeObserver(()=>{var e;if(!t.isConnected)return;this._updateObjectFit();const i=null===(e=navigator)||void 0===e?void 0:e.userAgent;if(i&&/iPhone|iPad/i.test(i)){this._taskIdIOSResizeProblem&&clearInterval(this._taskIdIOSResizeProblem);let e=0;this._taskIdIOSResizeProblem=setInterval(()=>{if(++e>10||!t.isConnected)return clearInterval(this._taskIdIOSResizeProblem),void(this._taskIdIOSResizeProblem=null);this._updateObjectFit()},100)}}).observe(t);for(let t of e._arrConstructors)t.call(this)}_updateObjectFit(){var e;const t=this._video;if(!t.isConnected||!t.videoWidth||!t.videoHeight)return;const i=this._coreOuterLayer.style,s=null===(e=this._regionBoxWrapper)||void 0===e?void 0:e.style;if("fill"===this._objectFit||void 0===i.aspectRatio)return"100%"!==i.width&&(i.width="100%"),"100%"!==i.height&&(i.height="100%"),void(s&&("100%"!==s.width&&(s.width="100%"),"100%"!==s.height&&(s.height="100%")));const{width:n,height:r}=this._coreShell.getBoundingClientRect(),o=`${t.videoWidth} / ${t.videoHeight}`;o!=i.aspectRatio&&(i.aspectRatio=o),s&&o!=s.aspectRatio&&(s.aspectRatio=o);const a=n/r-t.videoWidth/t.videoHeight;if(Math.abs(a)<.001)return;let c=!1;a>0&&(c=!c),"cover"===this._objectFit&&(c=!c);const l=s&&"contain"===this._objectFit,d=s&&"cover"===this._objectFit;c?("auto"!=i.width&&(i.width="auto"),"100%"!=i.height&&(i.height="100%"),l&&("auto"!=s.width&&(s.width="auto"),"100%"!=s.height&&(s.height="100%"))):("100%"!=i.width&&(i.width="100%"),"auto"!=i.height&&(i.height="auto"),l&&("100%"!=s.width&&(s.width="100%"),"auto"!=s.height&&(s.height="auto"))),d&&("100%"!==s.width&&(s.width="100%"),"100%"!==s.height&&(s.height="100%"))}get video(){return this._video}get track(){var e;return null===(e=this._video)||void 0===e||null===(e=e.srcObject)||void 0===e?void 0:e.getTracks().filter(e=>"video"===e.kind)[0]}get objectFit(){return this._objectFit}set objectFit(e){this._objectFit=e,this._updateObjectFit()}get ui(){return this._ui||this._coreShell}set ui(e){if(!e)return void(this._ui=void 0);if(e instanceof HTMLElement&&e.contains(this._coreShell))return void(this._ui=e);if("string"==typeof e){if(!e.trim().startsWith("<"))throw Error("Invalid html string.");e=zt(e,{inlineScript2Blob:this._uiInlineScript2Blob,internalCss2Blob:this._uiInternalCss2Blob,insertInternalCss2ExistedSheet:this._uiInternalCss2ExistedSheet})}let t;if(e instanceof HTMLElement)t=e;else{if(!(e instanceof DocumentFragment))throw Error("Seems no HTMLElement.");t=document.createElement("div"),Object.assign(t.style,{width:"100%",height:"100%"}),t.append(e)}const i="dm-camera-core-container",s=t.classList.contains(i)?t:t.querySelector(`.${i}`);if(!s)throw Error(`Can't find element with class \`${i}\`.`);this._ui=t;for(let e of t.querySelectorAll("script"))e.currentDMCamera=this;s.append(this._coreShell)}get status(){var e;return this._pOpen?this._pOpen.isPending?this._shouldClose?"closing":"opening":this._paused||this._video.paused||"ended"===(null===(e=this.track)||void 0===e?void 0:e.readyState)?"paused":"opened":"closed"}get requestedCamera(){return JSON.parse(JSON.stringify(this._requestedCamera))}get requestedResolution(){return JSON.parse(JSON.stringify(this._requestedResolution))}get currentCamera(){var t,i;return"opened"!==this.status&&"paused"!==this.status?null:null===(t=e._mapDeviceInfo)||void 0===t?void 0:t[null===(i=this.track)||void 0===i||null===(i=i.getSettings())||void 0===i?void 0:i.deviceId]}get currentResolution(){var e,t;return{width:null===(e=this.video)||void 0===e?void 0:e.videoWidth,height:null===(t=this.video)||void 0===t?void 0:t.videoHeight}}get regionBox(){return this._regionBox}static async hasCamera(){var t;return!(null===(t=navigator)||void 0===t||!t.mediaDevices)&&!!(await e.getDeviceInfos()).length}static async hasMacroCamera(){var t;return!(null===(t=navigator)||void 0===t||!t.mediaDevices)&&!!(await e.getDeviceInfos()).find(e=>{var t;return!e.isFront&&(null===(t=e.capabilities)||void 0===t||null===(t=t.focusDistance)||void 0===t?void 0:t.min)<.061})}static async hasFrontCamera(){var t;return!(null===(t=navigator)||void 0===t||!t.mediaDevices)&&!!(await e.getDeviceInfos()).find(e=>e.isFront)}static async getDeviceInfos(){var t;if(null===(t=navigator)||void 0===t||!t.mediaDevices)throw Error(ri);e._delayBeforeEnumerateDevices&&await new Promise(t=>setTimeout(t,e._delayBeforeEnumerateDevices));let i=(await navigator.mediaDevices.enumerateDevices()).filter(e=>"videoinput"===e.kind);if(!i.length)return[];if(i.some(e=>!e.deviceId)){let t;try{e._delayBeforeGetUserMedia&&await new Promise(t=>setTimeout(t,e._delayBeforeGetUserMedia)),t=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1}),e._delayBeforeEnumerateDevices&&await new Promise(t=>setTimeout(t,e._delayBeforeEnumerateDevices)),i=(await navigator.mediaDevices.enumerateDevices()).filter(e=>"videoinput"===e.kind),i.some(e=>!e.deviceId)&&console.warn("Some camera does not have deviceId.")}catch(i){console.warn("Failed to get device ID by opening camera.",i)}if(t){var s;const e=t.getTracks().filter(e=>"video"===e.kind)[0],n=e.getSettings().deviceId;let r=i.find(e=>e.deviceId===n);r?(r.trackLabel=e.label,r.capabilities=null===(s=e.getCapabilities)||void 0===s?void 0:s.call(e),r.isFront="user"===e.getSettings().facingMode,r.toJSON=ni):console.warn("Can't find current device by `track.getSettings().deviceId`."),t.getTracks().forEach(e=>e.stop())}}await e._setCapabilities(i);const n=i.reduce((e,t)=>(e[t.deviceId]=t,e),{});return e._mapDeviceInfo=n,[...i]}static async _setCapabilities(t){for(let n of t){var i;if(!n.deviceId)continue;if(ni===n.toJSON)continue;let r=null===(i=e._mapDeviceInfo)||void 0===i?void 0:i[n.deviceId];if(r)n.trackLabel=r.trackLabel,n.capabilities=r.capabilities,n.isFront=r.isFront;else try{var s;e._delayBeforeGetUserMedia&&await new Promise(t=>setTimeout(t,e._delayBeforeGetUserMedia));const t=await navigator.mediaDevices.getUserMedia({video:{deviceId:{exact:n.deviceId}},audio:!1}),i=t.getTracks().filter(e=>"video"===e.kind)[0];n.trackLabel=i.label,n.capabilities=null===(s=i.getCapabilities)||void 0===s?void 0:s.call(i),n.isFront="user"===i.getSettings().facingMode,t.getTracks().forEach(e=>e.stop())}catch(t){console.warn("Failed to get `trackLabel` and `capabilities`, by opening camera.",t)}n.toJSON=ni}}async open(){if("opened"!==this.status)if("closed"===this.status||"paused"===this.status)try{if("paused"===this.status&&this._cameraChangedWhenPaused&&await this.close(),"closed"===this.status){if(this._pOpen=new Qt,"customized-video"!==this._requestedCamera){var t;let s;if("string"==typeof this._requestedCamera){switch(this._requestedCamera){case"front":s={facingMode:"user"};break;case"quick-back":s={facingMode:"environment"};break;case"back":{const t=await e.getDeviceInfos();if(!t.length)throw Error("No camera found.");for(let n of e._cameraNameMatcher){for(let e of t){var i;const t=null===(i=e.trackLabel||e.label)||void 0===i?void 0:i.toLowerCase();for(let i of n)if(t.includes(i)){s={deviceId:e.deviceId};break}if(s)break}if(s)break}if(s)break;t.reverse();for(let e of t)if(!e.isFront){s={deviceId:e.deviceId};break}if(s)break;s={deviceId:t[0].deviceId};break}case"macro-back":{const t=await e.getDeviceInfos();if(!t.length)throw Error("No camera found.");const i=t.reduce((e,t)=>{var i,s,n;return null!=t&&t.isFront?e:e&&null!=e&&null!==(i=e.capabilities)&&void 0!==i&&null!==(i=i.focusDistance)&&void 0!==i&&i.min?(null==t||null===(s=t.capabilities)||void 0===s||null===(s=s.focusDistance)||void 0===s?void 0:s.min)<(null==e||null===(n=e.capabilities)||void 0===n||null===(n=n.focusDistance)||void 0===n?void 0:n.min)?t:e:t});s={deviceId:(null==i?void 0:i.deviceId)||t[t.length-1].deviceId};break}default:throw Error(`Unknown camera preset: ${this._requestedCamera}`)}this._requestedCamera=s}else s=this._requestedCamera;const n={video:Object.assign({},s,this._requestedResolution),audio:!1};if(null===(t=navigator)||void 0===t||!t.mediaDevices)throw Error(ri);e._delayBeforeGetUserMedia&&await new Promise(t=>setTimeout(t,e._delayBeforeGetUserMedia));const r=navigator.mediaDevices.getUserMedia(n),o=await(this._getUserMediaTimeout?Promise.race([r,new Promise((e,t)=>setTimeout(()=>t(Error("Camera open timeout.")),this._getUserMediaTimeout))]):r);if("closing"===this.status)throw Error("Camera closed.");this._video.srcObject=o}else{await this._video.play();let e=0;for(;++e<100&&!(this.video.readyState>=HTMLMediaElement.HAVE_ENOUGH_DATA);)await new Promise(e=>setTimeout(e,100))}if(ii&&"customized-video"!==this._requestedCamera){this._noUseButWorkaroundIosPwaProblem=this._video.offsetHeight,await new Promise(e=>{let t=!1,i=()=>{this._video.removeEventListener("loadedmetadata",i),t=!0,e()};this._video.addEventListener("loadedmetadata",i),setTimeout(()=>{t||(console.warn("video loadedmetadata timeout"),i())},1e3)});let t=!1;if(await Promise.race([this.video.play().then(()=>{t=!0}),new Promise(i=>setTimeout(()=>{t||i()},e._videoPlayTimeout))]),!t)throw Error("`video.play()` unresponsive in current iOS PWA environment. Please use `singleFrameMode='camera'` instead.")}else{let t=!1;await Promise.race([this.video.play(),(async()=>{if(await new Promise(t=>setTimeout(t,e._videoPlayTimeout)),!t)throw Error("video play timeout")})()]),t=!0}if("closing"===this.status)throw Error("Camera closed.");if(this.track){const t=this.track.getSettings();let i=0;for(;++i<e._countEnsureResolution&&!(t.width===this.video.videoWidth&&t.height===this.video.videoHeight||t.height===this.video.videoWidth&&t.width===this.video.videoHeight);)await new Promise(e=>setTimeout(e,100))}if("closing"===this.status)throw Error("Camera closed.");this._pOpen.resolve()}else{if(this._pOpen=new Qt,await this._video.play(),"closing"===this.status)throw Error("Camera closed.");this._paused=!1,this._pOpen.resolve()}for(let t of e._arrOnOpen)t.call(this);this._callOpenedListeners()}catch(e){var s,n;let t=null===(s=this._video)||void 0===s||null===(s=s.srcObject)||void 0===s||null===(n=s.getTracks)||void 0===n?void 0:n.call(s);if(t)for(let e of t)null==e||e.stop();this._video.srcObject=null;const i=this._pOpen;this._pOpen=null,this._shouldClose=!1,i.catch(e=>{}),i.reject();const r=Error(`Error opening camera: ${null==e?void 0:e.message}`,{cause:e});throw r.name=e.name,r}else{if("opening"!==this.status&&"closing"!==this.status)throw Error("Never");await this._pOpen}}async pause(){try{await this._pOpen}catch(e){}"opened"===this.status&&(this._video.pause(),this._paused=!0)}async close(){var t,i,s;for(let t of e._arrBeforeClose)t.call(this);if("closed"===this.status)return;if("opening"===this.status&&(this._shouldClose=!0),"closing"===this.status){try{await this._pOpen}catch(n){}return}let n=null===(t=this._video)||void 0===t||null===(t=t.srcObject)||void 0===t||null===(i=t.getTracks)||void 0===i?void 0:i.call(t);if(n)for(let e of n)null==e||e.stop();this._video&&(this._video.srcObject=null),this._pOpen=null,this._paused=!1,this._cameraChangedWhenPaused=!1;for(let t of e._arrOnClose)t.call(this);this._regionBoxWrapper&&(this._regionBoxWrapper.style.visibility="hidden"),null===(s=this._eventListeners.closed)||void 0===s||s.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}})}async requestCamera(e){if("string"==typeof e)ai.includes(e)?this._requestedCamera=e:this._requestedCamera={deviceId:{exact:e}};else if(e)if("videoinput"===e.kind)e.deviceId?this._requestedCamera={deviceId:{exact:e.deviceId}}:this._requestedCamera="back";else{const t=this._requestedCamera=JSON.parse(JSON.stringify(e));if(t.width||t.height||t.aspectRatio){const e=this._requestedResolution={};t.width&&(e.width=t.width,delete t.width),t.height&&(e.height=t.height,delete t.height),t.aspectRatio&&(e.aspectRatio=t.aspectRatio,delete t.aspectRatio)}}else null===e?this._requestedCamera=null:void 0===e&&(this._requestedCamera="back");"opened"===this.status?(await this.close(),await this.open()):"paused"===this.status&&(this._cameraChangedWhenPaused=!0)}async requestResolution(t,i){let s={};if("number"==typeof t?(s.width=t,"number"==typeof i&&(s.height=i)):Array.isArray(t)?(t[0]&&(s.width=t[0]),t[1]&&(s.height=t[1])):t?((t=JSON.parse(JSON.stringify(t))).width&&(s.width=t.width),t.height&&(s.height=t.height),t.aspectRatio&&(s.aspectRatio=t.aspectRatio)):null===t?s=null:void 0===t&&(s=si),this._requestedResolution=s,"opened"===this.status)if(e._bReopenWhenChangeResolution)await this.close(),await this.open();else{e._delayBeforeApplyConstraints&&await new Promise(t=>setTimeout(t,e._delayBeforeApplyConstraints)),await this.track.applyConstraints({...this._requestedCamera,...s});const t=this.track.getSettings();let i=0;for(;++i<e._countEnsureResolution&&!(t.width===this.video.videoWidth&&t.height===this.video.videoHeight||t.height===this.video.videoWidth&&t.width===this.video.videoHeight);)await new Promise(e=>setTimeout(e,100));this._callOpenedListeners()}else"paused"===this.status&&(e._bReopenWhenChangeResolution?this._cameraChangedWhenPaused=!0:(e._delayBeforeApplyConstraints&&await new Promise(t=>setTimeout(t,e._delayBeforeApplyConstraints)),await this.track.applyConstraints({...this._requestedCamera,...s})))}async applyConstraints(e){this.track&&"customized-video"!==this._requestedCamera&&(null!=e||(e={}),await this.track.applyConstraints({...this._requestedCamera,...this._requestedResolution,...e}))}getFrame(e){if("opened"!==this.status&&"paused"!==this.status)throw Error("Camera not open");let{x:t=0,y:i=0,width:s=this._video.videoWidth,height:n=this._video.videoHeight,reusedContext:r}=e||{};s=Math.round(s+t)-Math.round(t),n=Math.round(n+i)-Math.round(i),t=Math.round(t),i=Math.round(i);const o=(null==r?void 0:r.canvas)||document.createElement("canvas");return o.width!=s&&(o.width=s),o.height!=n&&(o.height=n),(r||o.getContext("2d")).drawImage(this._video,t,i,s,n,0,0,s,n),o}setRegionBox(e){if(!(e=Object.assign(this._regionBox,e)).width||!e.height){var t;if(!e.innerUi)return null!==(t=this._regionBoxWrapper)&&void 0!==t&&t.remove(),this._regionBoxWrapper=null,this._regionBoxMask=null,void(this._regionBoxBorder=null);Object.assign(e,{width:1,height:1,unit:"view-size",center:{x:0,y:0}})}this._regionBoxWrapper||(this._regionBoxWrapper=document.createElement("div"),Object.assign(this._regionBoxWrapper.style,{width:"auto",height:"100%",maxWidth:"100%",maxHeight:"100%",minWidth:"100px",minHeight:"100px",aspectRatio:"1",flex:"none",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",containerType:"size",visibility:"opened"===this.status?"":"hidden"}),this._regionBoxMask=document.createElement("div"),Object.assign(this._regionBoxMask.style,{width:"100%",height:"100%",flex:"none"}),this._regionBoxWrapper.append(this._regionBoxMask),this._regionBoxBorder=document.createElement("div"),Object.assign(this._regionBoxBorder.style,{flex:"none",boxSizing:"content-box",position:"absolute",transform:"translate(-50%,-50%)"}),this._regionBoxWrapper.append(this._regionBoxBorder),this._coreShell.append(this._regionBoxWrapper)),"string"==typeof e.innerUi&&(e.innerUi=zt(e.innerUi)),e.innerUi instanceof DocumentFragment?(this._regionBoxBorder.textContent="",this._regionBoxBorder.append(e.innerUi),e.innerUi=this._regionBoxBorder.childNodes):e.innerUi instanceof Node?1==this._regionBoxBorder.childNodes.length&&this._regionBoxBorder.firstChild==e.innerUi||(this._regionBoxBorder.textContent="",this._regionBoxBorder.append(e.innerUi)):e.innerUi instanceof NodeList?this._regionBoxBorder.childNodes!==e.innerUi&&(this._regionBoxBorder.textContent="",this._regionBoxBorder.append(...e.innerUi),e.innerUi=this._regionBoxBorder.childNodes):e.innerUi instanceof Array?(this._regionBoxBorder.textContent="",this._regionBoxBorder.append(...e.innerUi),e.innerUi=this._regionBoxBorder.childNodes):this._regionBoxBorder.textContent="";let i=100*e.center.y-50*e.height+50+"%",s=100*e.center.x+50*e.width+50+"%",n=100*e.center.y+50*e.height+50+"%",r=100*e.center.x-50*e.width+50+"%";Object.assign(this._regionBoxMask.style,{clipPath:`polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, ${r} ${i}, ${r} ${n}, ${s} ${n}, ${s} ${i}, ${r} ${i})`}),"view-min"===e.unit&&(i=`calc(${100*e.center.y+50}% + max(-${50*e.height}cqmin, -${50*e.height}cqmax))`,s=`calc(${100*e.center.x+50}% + ${50*e.width}cqmin)`,n=`calc(${100*e.center.y+50}% + ${50*e.height}cqmin)`,r=`calc(${100*e.center.x+50}% + max(-${50*e.width}cqmin, -${50*e.width}cqmax))`,Object.assign(this._regionBoxMask.style,{clipPath:`polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, ${r} ${i}, ${r} ${n}, ${s} ${n}, ${s} ${i}, ${r} ${i})`})),Object.assign(this._regionBoxMask.style,{...e.maskStyle}),Object.assign(this._regionBoxBorder.style,{width:100*e.width+"%",height:100*e.height+"%"}),"view-min"===e.unit&&Object.assign(this._regionBoxBorder.style,{width:100*e.width+"cqmin",height:100*e.height+"cqmin"}),Object.assign(this._regionBoxBorder.style,{top:100*e.center.y+50+"%",left:100*e.center.x+50+"%",...e.borderStyle}),"view-size"===e.unit&&1===e.width&&1===e.height&&(this._regionBoxBorder.style.borderWidth="0"),this._updateObjectFit()}addCanvas(){const e=document.createElement("canvas");return Object.assign(e.style,{position:"absolute",left:0,top:0,width:"100%",height:"100%"}),"opened"!==this.status&&"paused"!==this.status||(e.width=this._video.videoWidth,e.height=this._video.videoHeight),this._video.parentElement.append(e),e}_updateCanvasSize(){const e=this._video;e.videoWidth&&e.videoHeight&&this._video.parentElement.querySelectorAll("canvas").forEach(t=>{t.width!==e.videoWidth&&(t.width=e.videoWidth),t.height!==e.videoHeight&&(t.height=e.videoHeight)})}addEventListener(e,t){var i,s;(null!==(s=(i=this._eventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)}removeEventListener(e,t){var i;null===(i=this._eventListeners[e])||void 0===i||i.delete(t)}_callOpenedListeners(){var e;try{var t;null===(t=this.onOpened)||void 0===t||t.call(this,this)}catch(e){console.error(e)}this._regionBoxWrapper&&(this._regionBoxWrapper.style.visibility=""),null===(e=this._eventListeners.opened)||void 0===e||e.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}})}videoXY2AbsoluteLT(e){const t=this._video,i=t.getBoundingClientRect(),s=getComputedStyle(document.body);if("static"===s.position){const s=document.documentElement.getBoundingClientRect();return e.map(e=>({left:(this._isMirrored?t.videoWidth-e.x:e.x)/t.videoWidth*i.width+i.x-s.x,top:e.y/t.videoHeight*i.height+i.y-s.y}))}{const n=document.body.getBoundingClientRect(),r=parseFloat(s.borderLeftWidth),o=parseFloat(s.borderTopWidth);return e.map(e=>({left:(this._isMirrored?t.videoWidth-e.x:e.x)/t.videoWidth*i.width+i.x-n.x-r,top:e.y/t.videoHeight*i.height+i.y-n.y-o}))}}videoXY2FixedLT(e){const t=this._video,i=t.getBoundingClientRect();return e.map(e=>({left:(this._isMirrored?t.videoWidth-e.x:e.x)/t.videoWidth*i.width+i.x,top:e.y/t.videoHeight*i.height+i.y}))}getVisibleAreaInVideoXY(e){const{isConsiderRegionBox:t=!1,rounded:i=!1}=e||{};let s;if(t&&this._regionBoxBorder){const e=this._regionBoxBorder.getBoundingClientRect();s={x:e.x,y:e.y,width:e.width,height:e.height};const t=getComputedStyle(this._regionBoxBorder),i=parseFloat(t.borderLeftWidth),n=parseFloat(t.borderTopWidth),r=parseFloat(t.borderRightWidth),o=parseFloat(t.borderBottomWidth);s.x+=i,s.y+=n,s.width-=i+r,s.height-=n+o}else{const e=this._coreShell.getBoundingClientRect();s={x:e.x,y:e.y,width:e.width,height:e.height}}const n=this._video.getBoundingClientRect(),r={x:(s.x-n.x)/n.width,y:(s.y-n.y)/n.height,width:s.width/n.width,height:s.height/n.height};r.x<0&&(r.width+=r.x,r.x=0),r.x>1&&(r.width-=r.x-1,r.x=1),r.y<0&&(r.height+=r.y,r.y=0),r.y>1&&(r.height-=r.y-1,r.y=1),r.x+r.width>1&&(r.width=1-r.x),r.x+r.width<0&&(r.width=-r.x),r.y+r.height>1&&(r.height=1-r.y),r.y+r.height<0&&(r.height=-r.y);const o=this._video.videoWidth,a=this._video.videoHeight;let c=(this._isMirrored?1-r.x-r.width:r.x)*o,l=r.y*a,d=r.width*o,u=r.height*a;return i&&(d=Math.round(d+c)-Math.round(c),u=Math.round(u+l)-Math.round(l),c=Math.round(c),l=Math.round(l)),{x:c,y:l,width:d,height:u}}};qt(oi,"_cameraNameMatcher",[["트리플","三镜头","三鏡頭","トリプル","สาม","ट्रिपल","ثلاثية","משולשת","үштік","тройная","тройна","потроєна","τριπλή","üçlü","trójobiektywowy","trostruka","trojný","trojitá","trippelt","trippel","triplă","triple","tripla","tiga","kolmois","ba camera"],["듀얼 와이드","雙廣角","双广角","デュアル広角","คู่ด้านหลังมุมกว้าง","ड्युअल वाइड","مزدوجة عريضة","כפולה רחבה","қос кең бұрышты","здвоєна ширококутна","двойная широкоугольная","двойна широкоъгълна","διπλή ευρεία","çift geniş","laajakulmainen kaksois","kép rộng mặt sau","kettős, széles látószögű","grande angular dupla","ganda","dwuobiektywowy","dwikamera","dvostruka široka","duální širokoúhlý","duálna širokouhlá","dupla grande-angular","dublă","dubbel vidvinkel","dual-weitwinkel","dual wide","dual con gran angular","dual","double","doppia con grandangolo","doble","dobbelt vidvinkelkamera"],["camera2 0,"],["camera 0,"],["후","背面","背置","後面","後置","后面","后置","านหลัง","หลัง","बैक","خلفية","אחורית","задняя","задня","задней","задна","πίσω","zadní","zadná","tylny","trás","trasera","traseira","taka","stražnja","spate","sau","rück","rear","posteriore","posterior","hátsó","darrere","belakang","baksidan","bakre","bak","bagside","back","aртқы","arrière","arka","achterzijde"]]),qt(oi,"_mapDeviceInfo",void 0),qt(oi,"_delayBeforeEnumerateDevices",0),qt(oi,"_delayBeforeGetUserMedia",ti?1e3:0),qt(oi,"_delayBeforeApplyConstraints",0),qt(oi,"_countEnsureResolution",ti?20:10),qt(oi,"_videoPlayTimeout",3e3),qt(oi,"_bReopenWhenChangeResolution",ei),qt(oi,"_arrConstructors",[]),qt(oi,"_arrOnOpen",[]),qt(oi,"_arrBeforeClose",[]),qt(oi,"_arrOnClose",[]);const ai=["back","front","macro-back","quick-back","customized-video"];oi.prototype.correctAdvancedConstraint=function(e){e=JSON.parse(JSON.stringify(e));const{advanced:t}=e||{};if(null==t||!t.length)return e;const i=this;for(const e of t)for(const t in e){let n=e[t];if("number"==typeof n){var s;const r=null===(s=i.currentCamera)||void 0===s||null===(s=s.capabilities)||void 0===s?void 0:s[t],{min:o,step:a,max:c}=r||{};null!=o&&n<o?n=o:null!=c&&n>c&&(n=c),null!=a&&null!=o&&(n=o+Math.round((n-o)/a)*a,c&&n>c&&(n-=a)),e[t]=n}}return e},oi._arrConstructors.push(function(){const e=this;e._softZoom={zoom:1,center:{x:0,y:0}},e.maxZoom4GestureWheel=20,e._lastZoomTime=-1/0,e._mapZoomTouchs=new Map,e.enableGestureZoom=!0,e.enableWheelZoom=!1}),Object.defineProperty(oi.prototype,"softZoom",{get(){return this._softZoom}}),Object.defineProperty(oi.prototype,"isMirrored",{get(){return this._isMirrored},set(e){const t=this;t._isMirrored=e,t.setSoftZoom(t.softZoom.zoom,{center:t.softZoom.center})}}),Object.defineProperty(oi.prototype,"enableGestureZoom",{get(){return!!this._gestureZoomListener},set(e){const t=this;e?t._gestureZoomListener||(t._gestureZoomListener=e=>{t._changeZoomByTouch(e)},t._coreShell.addEventListener("touchstart",t._gestureZoomListener),t._coreShell.addEventListener("touchmove",t._gestureZoomListener),t._coreShell.addEventListener("touchend",t._gestureZoomListener),t._coreShell.addEventListener("touchcancel",t._gestureZoomListener)):t._gestureZoomListener&&(t._coreShell.removeEventListener("touchstart",t._gestureZoomListener),t._coreShell.removeEventListener("touchmove",t._gestureZoomListener),t._coreShell.removeEventListener("touchend",t._gestureZoomListener),t._coreShell.removeEventListener("touchcancel",t._gestureZoomListener),t._gestureZoomListener=null)}}),Object.defineProperty(oi.prototype,"enableWheelZoom",{get(){return!!this._wheelZoomListener},set(e){const t=this;e?t._wheelZoomListener||(t._wheelZoomListener=e=>{t._changeZoomByWheel(e)},t._coreShell.addEventListener("wheel",t._wheelZoomListener)):t._wheelZoomListener&&(t._coreShell.removeEventListener("wheel",t._wheelZoomListener),t._wheelZoomListener=null)}}),oi.prototype.getZoomRange=function(){var e,t;if("opened"!==this.status)throw Error("Camera not open");return null===(e=(t=this.track).getCapabilities)||void 0===e||null===(e=e.call(t))||void 0===e?void 0:e.zoom},oi.prototype.setZoom=async function(e){const t=this;if("opened"!==t.status)throw Error("Camera not open");oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await t.applyConstraints(t.correctAdvancedConstraint(t.correctAdvancedConstraint({advanced:[{zoom:e}]})))},oi.prototype.setSoftZoom=function(e,t){const i=this;let{center:s,limit:n}=t||{},{x:r=0,y:o=0}=s||{};n&&e<1&&(e=1);let a=i._isMirrored?`scale(${-e},${e})`:`scale(${e})`;if(s){if(n){const t=.5-.5/e;r<-t?r=-t:r>t&&(r=t),o<-t?o=-t:o>t&&(o=t)}a+=` translate(${r*=-100}%, ${o*=-100}%)`}i._softZoom={zoom:e,center:{x:r,y:o}},i._coreInnerLayer.style.transform=a},oi.prototype._changeZoomByWheel=function(e){var t;const i=this,s=Date.now();let n=i._softZoom.zoom,r=n-e.deltaY/200;r>i.maxZoom4GestureWheel&&(r=i.maxZoom4GestureWheel),r<1&&(r=1),r!==n&&(i.setSoftZoom(r,{center:i._softZoom.center,limit:!0}),i._lastZoomTime=s,e.preventDefault(),null===(t=i._eventListeners.zoom)||void 0===t||t.forEach(e=>{try{e.call(i,JSON.parse(JSON.stringify(i._softZoom)))}catch(e){console.error(e)}}))},oi.prototype._changeZoomByTouch=function(e){const t=this;for(e.touches.length>=2&&"touchmove"==e.type&&e.preventDefault();e.changedTouches.length>1&&2==e.touches.length;){var i;let s=Date.now();if(s-t._lastZoomTime<100)return;let n=e.touches[0],r=e.touches[1],o=t._mapZoomTouchs.get(n.identifier),a=t._mapZoomTouchs.get(r.identifier);if(!o||!a)break;let c=Math.pow(Math.pow(o.x-a.x,2)+Math.pow(o.y-a.y,2),.5),l=Math.pow(Math.pow(n.clientX-r.clientX,2)+Math.pow(n.clientY-r.clientY,2),.5),d=t._softZoom.zoom;d*=l/c,d>t.maxZoom4GestureWheel&&(d=t.maxZoom4GestureWheel),d<1&&(d=1),t.setSoftZoom(d,{center:t._softZoom.center,limit:!0}),t._lastZoomTime=s,null===(i=t._eventListeners.zoom)||void 0===i||i.forEach(e=>{try{e.call(t,JSON.parse(JSON.stringify(t._softZoom)))}catch(e){console.error(e)}});break}t._mapZoomTouchs.clear();for(let i of e.touches)t._mapZoomTouchs.set(i.identifier,{x:i.clientX,y:i.clientY})},oi._arrConstructors.push(function(){const e=this;e._isFocusing=!1,e._advancedFocusParameters={minFocusDistanceLimit:.01,maxFocusDistanceLimit:10,firstStepWaitDuration:500,coarseStepWaitDuration:350,switchStepWaitDuration:400,fineStepWaitDuration:350,maxStepCount:30,backToContinousDuration:5e3,focusWH:.2,coarseTuneRate:.5,coarseTuneTolerance:.5,fineTuneRate:1.1},e._advancedFocusTaskId=0,e.enableTapToFocus="simple"}),oi._getImageContrast=(e,t,i)=>{let s=0;for(let n=0;n<i-1;n++)for(let i=0;i<t-1;i++){const r=4*(n*t+i),o=r+4,a=r+4*t,c=e[r]-e[o],l=e[r+1]-e[o+1],d=e[r+2]-e[o+2],u=e[r]-e[a],h=e[r+1]-e[a+1],_=e[r+2]-e[a+2];s+=c*c+l*l+d*d+u*u+h*h+_*_}return s},oi.prototype._simpleFocus=async function(){var e,t,i,s,n;const r=this;if("opened"!==r.status)throw Error("Camera not open");if(r._isFocusing)return;const o=null===(e=r.currentCamera)||void 0===e?void 0:e.capabilities;let a,c;if(null!=o&&null!==(t=o.focusMode)&&void 0!==t&&t.includes("manual"))if(null!=o&&null!==(i=o.focusMode)&&void 0!==i&&i.includes("continuous"))a="manual",c="continuous";else{var l;if(null==o||null===(l=o.focusMode)||void 0===l||!l.includes("single-shot"))return void r._advancedFocus();a="manual",c="single-shot"}else if(null!=o&&null!==(s=o.focusMode)&&void 0!==s&&s.includes("single-shot"))null!=o&&null!==(n=o.focusMode)&&void 0!==n&&n.includes("continuous")?(a="continuous",c="single-shot"):(a=null,c="single-shot");else{var d;if(null==o||null===(d=o.focusMode)||void 0===d||!d.includes("continuous"))return;a=null,c="continuous"}r._isFocusing=!0;try{var u;a&&("manual"===a?(oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await r.applyConstraints(r.correctAdvancedConstraint({advanced:[{focusMode:"manual",focusDistance:(null==o||null===(u=o.focusDistance)||void 0===u?void 0:u.max)||10}]}))):(oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await r.applyConstraints({advanced:[{focusMode:a}]})),await new Promise(e=>setTimeout(e,500))),oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await r.applyConstraints({advanced:[{focusMode:c}]}),await new Promise(e=>setTimeout(e,500))}catch(o){"opened"===r.status&&console.warn("Error while do simple focus",o)}r._isFocusing=!1},oi.prototype._advancedFocus=async function(e,t,i){var s,n,r,o;const a=this;if("opened"!==a.status)throw Error("Camera not open");if(a._isFocusing)return;const c=null===(s=a.currentCamera)||void 0===s?void 0:s.capabilities;if(null==c||null===(n=c.focusMode)||void 0===n||!n.includes("manual"))return void a._simpleFocus();const l=a._advancedFocusParameters,d=a._video.videoWidth,u=a._video.videoHeight;if(d<2||u<2)return;let h,_=0;e?(e.x=Math.round(e.x),e.y=Math.round(e.y),t||(t=Math.min(d,u)*l.focusWH),t<2&&(t=2),t>d&&(t=d),t=2*Math.round(t/2),i||(i=t),i<2&&(i=2),i>u&&(i=u),i=2*Math.round(i/2),e.x<t/2&&(e.x=t/2),e.x>d-t/2&&(e.x=d-t/2),e.y<i/2&&(e.y=i/2),e.y>u-i/2&&(e.y=u-i/2),_=e.x-t/2,h=e.y-i/2):(t=d,i=u),a._isFocusing=!0;const m=++a._advancedFocusTaskId;let g=null==c||null===(r=c.focusDistance)||void 0===r?void 0:r.min;(!g||g<l.minFocusDistanceLimit)&&(g=l.minFocusDistanceLimit);let f=null==c||null===(o=c.focusDistance)||void 0===o?void 0:o.max;(!f||f>l.maxFocusDistanceLimit)&&(f=l.maxFocusDistanceLimit);let p=-1/0,E=-1/0,y=1/0,I=f,v=!1,R=!0;const C=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});let T=0;try{for(;++T<l.maxStepCount;){let e;oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await a.applyConstraints(a.correctAdvancedConstraint({advanced:[{focusMode:"manual",focusDistance:I}]})),v?R?(R=!1,e=l.switchStepWaitDuration):e=l.fineStepWaitDuration:R?(R=!1,e=l.firstStepWaitDuration):e=l.coarseStepWaitDuration,await new Promise(t=>setTimeout(t,e)),a.getFrame({x:_,y:h,width:t,height:i,reusedContext:C});const s=C.getImageData(0,0,t,i).data,n=oi._getImageContrast(s,t,i);if(v){if(n<=p){oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await a.applyConstraints(a.correctAdvancedConstraint({advanced:[{focusMode:"manual",bestFocusDistance:y}]})),oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await a.applyConstraints(a.correctAdvancedConstraint({advanced:[{focusMode:"manual",bestFocusDistance:y}]}));break}if(f===I)break;p=n,n>E&&(E=n,y=I),I*=l.fineTuneRate,I>f&&(I=f)}else(n<=E*l.coarseTuneTolerance||g===I)&&(v=!0),p=n,n>E&&(E=n,y=I),v?(I=Math.sqrt(I*y),R=!0):(I*=l.coarseTuneRate,I<g&&(I=g))}}catch(e){"opened"===a.status&&console.warn("Error while do advanced focus",e)}a._isFocusing=!1,l.backToContinousDuration>0&&setTimeout(async()=>{if(a._advancedFocusTaskId===m){oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints));try{await a.applyConstraints({advanced:[{focusMode:"continuous"}]})}catch(e){}}},l.backToContinousDuration)},Object.defineProperty(oi.prototype,"enableTapToFocus",{get(){return this._enableTapToFocus},set(e){const t=this;t._enableTapToFocus=e,e?t._tapToFocusListner||(t._tapToFocusListner=async e=>{if(!("opened"!==t.status||!t._enableTapToFocus||!e.isPrimary||e.button||e.altKey||e.ctrlKey||e.shiftKey||e.metaKey||"touch"===e.pointerType&&t.enableGestureZoom&&(await new Promise(e=>setTimeout(e,300)),"opened"!==t.status||!t._enableTapToFocus||t._lastZoomTime>Date.now()-1e3||t._mapZoomTouchs.size>1)))if("experimental-advanced"===t._enableTapToFocus){const[{left:i,top:s},{left:n,top:r}]=t.videoXY2FixedLT([{x:0,y:0},{x:t._video.videoWidth,y:t._video.videoHeight}]);t._advancedFocus({x:(e.clientX-i)/(n-i)*t._video.videoWidth,y:(e.clientY-s)/(r-s)*t._video.videoHeight})}else t._simpleFocus()},t._coreShell.addEventListener("pointerdown",t._tapToFocusListner)):t._tapToFocusListner&&(t._coreShell.removeEventListener("pointerdown",t._tapToFocusListner),t._tapToFocusListner=null)}}),oi._arrConstructors.push(function(){this._isTorchOn=!1,this._autoTorchParameters={shortDelay:250,longDelay:1e3,shortLongDelaySwitchCount:10,grayThreshold:20,maxDarkCount:3}}),oi._arrOnClose.push(function(){this._isTorchOn=!1}),Object.defineProperty(oi.prototype,"isSupportTorch",{get(){var e,t;const i=null===(e=navigator)||void 0===e?void 0:e.userAgent;return i&&/iPhone/i.test(i)||!(null===(t=this.currentCamera)||void 0===t||null===(t=t.capabilities)||void 0===t||!t.torch)}}),Object.defineProperty(oi.prototype,"isTorchOn",{get(){var e,t;const i=this;return!1===(null===(e=i.track)||void 0===e||null===(t=e.getSettings)||void 0===t||null===(t=t.call(e))||void 0===t?void 0:t.torch)&&!0===i._isTorchOn&&(i._isTorchOn=!1,i.turnOffTorch()),i._isTorchOn}}),oi.prototype.turnOnTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints));try{await e.applyConstraints({advanced:[{torch:!0}]})}catch(t){throw e._isTorchOn=!1,t}e._isTorchOn=!0},oi.prototype.turnOffTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await e.applyConstraints({advanced:[{torch:!1}]}),e._isTorchOn=!1},oi.prototype.turnAutoTorch=function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");if(null==e._isTorchOn)return;e._isTorchOn=void 0;const t=e._autoTorchParameters,i=document.createElement("canvas"),s=i.getContext("2d",{willReadFrequently:!0});let n=0,r=0;(async()=>{for(;null==e._isTorchOn;){try{if("opened"!==e.status){e._isTorchOn=!1;break}e.getFrame({reusedContext:s})}catch(t){e._isTorchOn=!1;break}const a=s.getImageData(0,0,i.width,i.height).data;let c=0;for(let e=0;e<a.length;e+=4)c+=a[e]+a[e+1]+a[e+2];if(c/=a.length/4*3,c<t.grayThreshold&&++n>=t.maxDarkCount){try{var o;await e.turnOnTorch(),null===(o=e._eventListeners.torchAutoOn)||void 0===o||o.forEach(t=>{try{t.call(e)}catch(e){console.error(e)}})}catch(e){}break}await new Promise(e=>setTimeout(e,r<t.shortLongDelaySwitchCount?t.shortDelay:t.longDelay)),++r}})()};const ci="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(Wt=window)&&void 0!==Wt&&Wt.MSStream),li="undefined"!=typeof navigator&&/MiuiBrowser/.test(navigator.userAgent),di="undefined"!=typeof navigator&&/SamsungBrowser/.test(navigator.userAgent);let ui,hi;oi._arrConstructors.push(function(){this._shouldCloseWhenHide=!0,this._maxReopenTry4CloseWhenHide=4}),oi._arrOnOpen.push(function(){const e=this;e._shouldCloseWhenHide&&(e._closeWhenHideListener||(e._closeWhenHideListener=()=>{e._closeWhenHide()},document.addEventListener("visibilitychange",e._closeWhenHideListener),di&&window.addEventListener("blur",e._closeWhenHideListener)))}),oi._arrBeforeClose.push(function(){const e=this;e._closeWhenHideListener&&!e._isDuringCloseWhenHide&&(document.removeEventListener("visibilitychange",e._closeWhenHideListener),di&&window.removeEventListener("blur",e._closeWhenHideListener),e._closeWhenHideListener=null,e._isOpenBeforeHide=!1)}),Object.defineProperty(oi.prototype,"shouldCloseWhenHide",{get(){return this._shouldCloseWhenHide},set(e){const t=this;t._shouldCloseWhenHide=e,("opened"===t.status||"paused"===t.status&&!t._paused)&&(e?t._closeWhenHideListener||(t._closeWhenHideListener=()=>{t._closeWhenHide()},document.addEventListener("visibilitychange",t._closeWhenHideListener),di&&window.addEventListener("blur",t._closeWhenHideListener)):t._closeWhenHideListener&&(document.removeEventListener("visibilitychange",t._closeWhenHideListener),di&&window.removeEventListener("blur",t._closeWhenHideListener),t._closeWhenHideListener=null,t._isOpenBeforeHide=!1))}}),oi.prototype._closeWhenHide=async function(){var e;const t=this;if("hidden"===document.visibilityState)("opened"===t.status||"paused"===t.status&&!t._paused&&(ci&&"live"===(null===(e=t.track)||void 0===e?void 0:e.readyState)||li&&"customized-video"!==t.requestedCamera))&&(t._isDuringCloseWhenHide=!0,t._isOpenBeforeHide=!0,await t.close(),t._isDuringCloseWhenHide=!1);else{if(!t._isOpenBeforeHide)return;let e=0;for(;e++<t._maxReopenTry4CloseWhenHide&&"visible"===document.visibilityState;){try{if("closing"===t.status)try{await t._pOpen}catch(t){}await t.open(),t._isOpenBeforeHide=!1}catch(t){await new Promise(e=>setTimeout(e,300));continue}break}}},oi.showFilePicker=async function(e){var t;null===(t=ui)||void 0===t||t.remove();const i=ui=document.createElement("input");i.type="file",i.accept="image/jpeg, image/png, image/gif, image/bmp, image/webp, image/tiff",i.multiple=!0;let s=new Promise(function(e){i.addEventListener("change",function(){e(Array.from(i.files)),i.remove()})});Object.assign(i,e),Object.assign(i.style,{width:"1px",height:"1px",position:"fixed",left:"0",top:"0",opacity:"0.1",overflow:"hidden",zIndex:"-1"}),document.body.append(i);let n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});return i.dispatchEvent(n),s};let _i=class{constructor(e){qt(this,"camera",void 0),qt(this,"_ctx",void 0),qt(this,"_data",void 0),qt(this,"_dataTime",-1/0),qt(this,"_x",void 0),qt(this,"_y",void 0),qt(this,"_w",void 0),qt(this,"_h",void 0),qt(this,"_type",void 0),qt(this,"maxTimeout",500),qt(this,"_pipeTaskId",void 0),qt(this,"isSaveOriginalRgba",!1),qt(this,"originalRgba",void 0),this.camera=e;const t=document.createElement("canvas");this._ctx=t.getContext("2d",{willReadFrequently:!0})}_getData(){if("opened"!==this.camera.status)return null;this.camera.getFrame({x:this._x,y:this._y,width:this._w,height:this._h,reusedContext:this._ctx});const e=this._ctx.getImageData(0,0,this._w,this._h).data;if(this.originalRgba=this.isSaveOriginalRgba?e:null,"rgba"===this._type)return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);const t=new Uint8Array(e.length/4);for(let i=0;i<e.length;i+=4)t[i/4]=.3*e[i]+.59*e[i+1]+.11*e[i+2];return t}getData(e){let{x:t=0,y:i=0,width:s=this.camera._video.videoWidth,height:n=this.camera._video.videoHeight,type:r="rgba"}=e||{};if(s=Math.round(s+t)-Math.round(t),n=Math.round(n+i)-Math.round(i),t=Math.round(t),i=Math.round(i),0===s||0===n||isNaN(s)||isNaN(n))return null;const o=t!==this._x||i!==this._y||s!==this._w||n!==this._h||r!==this._type;let a;return o&&(this._x=t,this._y=i,this._w=s,this._h=n,this._type=r),!o&&this._dataTime+this.maxTimeout>Date.now()&&this._data?(a=this._data,this._data=null):a=this._getData(),this._pipeTaskId||(this._pipeTaskId=setTimeout(()=>{this._pipeTaskId=null,this._data=this._getData(),this._dataTime=Date.now()},0)),a}},mi=class{constructor(){qt(this,"_stAudioFree",new Set),qt(this,"_stAudioPlaying",new Set),qt(this,"_timeLastPlay",0),qt(this,"_bWarnedMaxTrack",!1),qt(this,"maxPlayingBeep",16),qt(this,"beepSoundSource","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")}beep(){if(!this.beepSoundSource)return;let e,t=Date.now();if(!(t-this._timeLastPlay<100)){if(this._timeLastPlay=t,this._stAudioFree.size&&(e=this._stAudioFree.values().next().value,this.beepSoundSource==e.src?(this._stAudioFree.delete(e),e.play()):e=null),!e)if(this._stAudioPlaying.size<this.maxPlayingBeep){e=new Audio(this.beepSoundSource);let t=null,i=()=>{e.removeEventListener("loadedmetadata",i),e.play(),t=setTimeout(()=>{this._stAudioPlaying.delete(e)},2e3*e.duration)};e.addEventListener("loadedmetadata",i),e.addEventListener("ended",()=>{null!=t&&(clearTimeout(t),t=null),e.pause(),e.currentTime=0,this._stAudioPlaying.delete(e),this._stAudioFree.add(e)})}else this._bWarnedMaxTrack||(this._bWarnedMaxTrack=!0,console.warn(`The requested audio tracks exceed ${this.maxPlayingBeep} and will not be played.`));e&&this._stAudioPlaying.add(e)}}};const gi=()=>{(null!=hi?hi:hi=new mi).beep()},fi=(e=300)=>{var t;if(null===(t=navigator)||void 0===t||!t.vibrate)throw new Error("Not supported.");navigator.vibrate(e)},pi=oi,Ei=oi;if(null!==(jt=document)&&void 0!==jt&&jt.head){const e=new Blob(["@keyframes dce-scanlight{from{top:0;}to{top:97%;}}"],{type:"text/css"}),t=document.createElement("link");t.rel="stylesheet",t.href=URL.createObjectURL(e),document.head.append(t)}const yi={x:0,y:0,width:100,height:100,isMeasuredInPercentage:!0};pi.createInstance=async function(e){let t;if(e instanceof oi?(t=e,e=void 0):t=new oi,void 0===t.disposed){if(t.isCameraEnhancer=!0,t.disposed=!1,t._cameraEnhancer=t._cameraView=t,t._framePipeline=new _i(t),t._dceScanRegion=yi,t._dceEventListeners={},t._bTryAnotherCameraWhenFailToOpen=!0,t._bAutoSingleFrameModeWhenIosPwaFail=!0,t._oriOpen=t.open,t.open=Ii,t._oriUpdateCanvasSize=t._updateCanvasSize,t._updateCanvasSize=Ri,t._oriAddCanvas=t.addCanvas,t.addCanvas=Ci,t._dceZoom=1,t._dceEnhancedFeatures=0,t._dceAutoZoomRange={min:1,max:10},t._oriSetZoom=t.setZoom,t.setZoom=Ti,t.singleFrameMode="disabled",t._ifSaveLastUsedCamera=!1,t._pixelFormat=10,t._colourChannelUsageType=0,t.addImageToBuffer=t.clearBuffer=t.startFetching=t.stopFetching=t.setBufferOverflowProtectionMode=t.setErrorListener=t.setImageFetchInterval=t.setMaxImageCount=t.setNextImageToReturn=()=>{},t.getImageCount=t.getMaxImageCount=t.getImageFetchInterval=t.getBufferOverflowProtectionMode=()=>0,t.hasImage=()=>!1,null!=e||(e=Ei.defaultUIElementURL),e&&await t.setUIElement(e),t._dceRegionMaskStyle={lineWidth:2,strokeStyle:"rgb(254,142,20)",fillStyle:"rgba(0,0,0,0.5)"},t._dceRegionMaskVisible=!0,t._dceTipDuration=3e3,t._drawingLayers=[],t._drawingLayers.length=100,t._capturedResultReceiver={onCapturedResultReceived:ji.bind(t)},!t.regionBox.innerUi){const e=document.createElement("div");Object.assign(e.style,{position:"absolute",width:"100%",height:"3%",borderRadius:"50%",boxShadow:"0px 0px 2vw 1px #00e5ff",background:"#fff",animation:"3s infinite dce-scanlight",pointerEvents:"none",userSelect:"none",display:"none"}),t.setRegionBox({innerUi:e})}t.addEventListener("opened",function(){var e,i,s,n;null!==(e=this._dceEventListeners.cameraOpen)&&void 0!==e&&e.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}}),null===(i=this._dceEventListeners.played)||void 0===i||i.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}});const r=null===(s=t.currentCamera)||void 0===s?void 0:s.deviceId,o=t._dceLastDeviceId;r!==o&&(t._dceLastDeviceId=r,null===(n=this._dceEventListeners.cameraChange)||void 0===n||n.forEach(e=>{try{e.call(this,r,o)}catch(e){console.error(e)}}))}),t.addEventListener("closed",function(){var e;t.clearAllInnerDrawingItems(!0),t.videoSrc&&(t.video.src=""),null===(e=this._dceEventListeners.cameraClose)||void 0===e||e.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}})}),t.video.addEventListener("resize",()=>{var e;if(!t.video.videoWidth||!t.video.videoHeight)return;const i=t.currentResolution,s=t._dceLastResolution;i.width===(null==s?void 0:s.width)&&i.height===(null==s?void 0:s.height)||(t._dceLastResolution=i,null===(e=t._dceEventListeners.resolutionChange)||void 0===e||e.forEach(e=>{try{e.call(this,i,s)}catch(e){console.error(e)}}))}),["mousedown","mouseup","dblclick"].forEach(e=>{t._coreShell.addEventListener(e,function(e){const i=[e.clientX,e.clientY],s=t._drawingLayers.filter(e=>null==e?void 0:e._visible).map(e=>e._drawingItems).flat(),n=t.videoXY2AbsoluteLT(s.map(e=>{if(e instanceof Ui)return e.quad.points;if(e instanceof Vi||e instanceof Gi||e instanceof Wi){let{x:t,y:i,width:s,height:n}=e.rect,r=t+s,o=i+n;return[{x:t,y:i},{x:t,y:o},{x:r,y:o},{x:r,y:i}]}return e instanceof ki?[e.line.startPoint,e.line.endPoint]:void 0}).flat()).map(e=>[e.left,e.top]);let r=0;s.forEach(t=>{var s;let o=!1;t instanceof Ui||t instanceof Vi||t instanceof Gi||t instanceof Wi?(o=xi(i,[n[r],n[r+1],n[r+2],n[r+3]]),r+=4):t instanceof ki&&(o=xi(i,[n[r],n[r+1]]),r+=2),o&&(null===(s=t._dceEventListeners[e.type])||void 0===s||s.forEach(e=>{try{e.call(this)}catch(e){console.error(e)}}))})})})}return t},pi.defaultUIElementURL="@engineResourcePath/ui/dce.ui.xml",Object.defineProperty(pi.prototype,"cameraOpenTimeout",{get(){return this._getUserMediaTimeout},set(e){this._getUserMediaTimeout=e}});const Ii=async function(){var e,t,i,s,n;const r=this;if("camera"===r.singleFrameMode||"image"===r.singleFrameMode){var o;const e=await vi("camera"===r.singleFrameMode),t=r.ui.querySelector(".dce-bg-camera");"closed"!==r.status&&await r.close(),t&&(t.style.opacity="0");{r._singleFrameModeCvs&&r._singleFrameModeCvs.remove();const t=r._singleFrameModeCvs=e.toCanvas();Object.assign(t.style,{width:"100%",height:"100%",position:"absolute",left:"0px",top:"0px"}),r._video.parentElement.querySelectorAll("canvas").forEach(e=>{e.width!==t.width&&(e.width=t.width),e.height!==t.height&&(e.height=t.height)});{const e=r._coreOuterLayer.style;if("fill"===this._objectFit||void 0===e.aspectRatio)"100%"!==e.width&&(e.width="100%"),"100%"!==e.height&&(e.height="100%");else{const{width:i,height:s}=r._coreShell.getBoundingClientRect(),n=`${t.width} / ${t.height}`;n!=e.aspectRatio&&(e.aspectRatio=n);const o=i/s-t.width/t.height,a=.001;if(Math.abs(o)>a){let t=!1;o>0&&(t=!t),"cover"===r._objectFit&&(t=!t),t?("auto"!=e.width&&(e.width="auto"),"100%"!=e.height&&(e.height="100%")):("100%"!=e.width&&(e.width="100%"),"auto"!=e.height&&(e.height="auto"))}}}r._video.before(t)}return r._singleFrameModeResultForDcv=e,void(null===(o=r._dceEventListeners.singleFrameAcquired)||void 0===o||o.forEach(t=>{try{t.call(this,e)}catch(t){console.error(t)}}))}r.videoSrc&&(r.video.src=r._dceVideoSrc);const a=r.ui.querySelector(".dce-bg-loading");a&&(a.style.display="");try{await r._oriOpen()}catch(e){if(pi.onWarning&&pi.onWarning(null==e?void 0:e.message),!r._bTryAnotherCameraWhenFailToOpen||"customized-video"===r.requestedCamera||!["NotReadableError","AbortError","OverconstrainedError"].includes(null==e?void 0:e.name)){var c,l,d;if(r._bAutoSingleFrameModeWhenIosPwaFail&&null!=e&&null!==(c=e.message)&&void 0!==c&&c.includes("iOS PWA"))return console.warn(e.message),a&&(a.style.display="none"),console.warn("Auto switch to `singleFrameMode = 'camera'`."),r.singleFrameMode="camera",void(null===(l=this.funcShowToast)||void 0===l||l.call(this,"Click to Capture",8e3));throw a&&(a.style.display="none"),null!==(d=this.funcShowToast)&&void 0!==d&&d.call(this,null==e?void 0:e.message,8e3),e}{var u;console.warn(e),await r.requestCamera("quick-back");try{await r._oriOpen()}catch(r){var h;throw a&&(a.style.display="none"),null!==(h=this.funcShowToast)&&void 0!==h&&h.call(this,null==r?void 0:r.message,8e3),r}const t=r.currentCamera,i=t?t.trackLabel||t.label||t.deviceId:"available camera";null===(u=this.funcShowToast)||void 0===u||u.call(this,`Fallback to ${i}`)}}return r._ifSaveLastUsedCamera&&null!==(e=r.currentCamera)&&void 0!==e&&e.deviceId&&(null!==(t=localStorage)&&void 0!==t&&t.setItem("dce-last-used-camera",null===(i=r.currentCamera)||void 0===i?void 0:i.deviceId),null!==(s=localStorage)&&void 0!==s&&s.setItem("dce-last-used-resolution",JSON.stringify(r.requestedResolution))),a&&(a.style.display="none"),await new Promise(e=>setTimeout(e,0)),{deviceId:null===(n=r.currentCamera)||void 0===n?void 0:n.deviceId,...r.currentResolution}},vi=async function(e){const t={multiple:!1};e&&(t.capture="environment");const i=(await oi.showFilePicker(t))[0],s=document.createElement("canvas"),n=s.getContext("2d"),r=URL.createObjectURL(i),o=new Image;o.src=r,await o.decode(),s.width=o.width,s.height=o.height,n.drawImage(o,0,0),URL.revokeObjectURL(r);const a=n.getImageData(0,0,s.width,s.height).data;return{bytes:new Uint8Array(a.buffer,a.byteOffset,a.length),width:s.width,height:s.height,stride:4*s.width,format:10,toCanvas:()=>s,imageTag:{imageId:++Si,type:0}}},Ri=function(){"disabled"===this.singleFrameMode&&this._oriUpdateCanvasSize()},Ci=function(){const e=this,t=e._oriAddCanvas();if("disabled"!==e.singleFrameMode&&e._singleFrameModeCvs){const i=e._singleFrameModeCvs;t.width!==i.width&&(t.width=i.width),t.height!==i.height&&(t.height=i.height)}return t};pi.prototype.dispose=function(){this.disposed=!0,this.close(),this.setScanLaserVisible(!1)},pi.prototype.getAllCameras=async function(){return(await oi.getDeviceInfos()).map(e=>({deviceId:e.deviceId,label:e.label||e.trackLabel}))},pi.prototype.getAvailableResolutions=async function(){const e=this,t=[],i=e.requestedCamera,s=e.requestedResolution,n="opened"===e.status;n||await e._oriOpen();for(let i of[[160,120],[320,240],[480,360],[640,480],[800,600],[960,720],[1280,720],[1920,1080],[2560,1440],[3840,2160]]){var r,o,a,c;await e.requestResolution(i),((null===(r=e.currentResolution)||void 0===r?void 0:r.width)===i[0]&&(null===(o=e.currentResolution)||void 0===o?void 0:o.height)===i[1]||(null===(a=e.currentResolution)||void 0===a?void 0:a.width)===i[1]&&(null===(c=e.currentResolution)||void 0===c?void 0:c.height)===i[0])&&t.push({width:i[0],height:i[1]})}return n||await e.close(),await e.requestCamera(i),await e.requestResolution(s),t},pi.prototype.getCameraState=function(){let e=this.status;return"closing"===e||"paused"===e||"closed"===e?"closed":"opened"===e?"open":"opening"===e?"opening":void 0},pi.prototype.getResolution=function(){return"opened"===this.status?this.currentResolution:this.requestedResolution},pi.prototype.getSelectedCamera=function(){var e,t;return"opened"===this.status?{deviceId:null===(e=this.currentCamera)||void 0===e?void 0:e.deviceId,label:null===(t=this.currentCamera)||void 0===t?void 0:t.label}:null},pi.prototype.getVideoSettings=function(){let e={};return"object"==typeof this.requestedCamera&&Object.assign(e,this.requestedCamera),Object.assign(e,this.requestedResolution),{video:e}},Object.defineProperty(pi.prototype,"ifSaveLastUsedCamera",{get(){return this._ifSaveLastUsedCamera},set(e){const t=this;if(t._ifSaveLastUsedCamera=e,e&&"closed"===t.status){var i,s;const n=null===(i=localStorage)||void 0===i?void 0:i.getItem("dce-last-used-camera");n&&t.requestCamera(n);const r=null===(s=localStorage)||void 0===s?void 0:s.getItem("dce-last-used-resolution");if(r)try{t.requestResolution(JSON.parse(r))}catch(e){}}}}),Object.defineProperty(pi.prototype,"ifSkipCameraInspection",{get(){return"quick-back"===this.requestedCamera},set(e){e?this.requestCamera("quick-back"):this.requestCamera("back")}}),pi.prototype.isOpen=function(){return"opened"===this.status},pi.prototype.isPaused=function(){return"paused"===this.status},pi.prototype.resume=async function(){await this._oriOpen()},pi.prototype.selectCamera=async function(e){var t;return await this.requestCamera("string"==typeof e?e:e.deviceId),{deviceId:null===(t=this.currentCamera)||void 0===t?void 0:t.deviceId,...this.currentResolution}},pi.prototype.setResolution=async function(e){var t;return await this.requestResolution(e),{deviceId:null===(t=this.currentCamera)||void 0===t?void 0:t.deviceId,...this.currentResolution}},pi.testCameraAccess=async function(){let e=!0,t="Successfully accessed the camera.";try{await oi.getDeviceInfos()}catch(i){e=!1,t=i.message||i}return{ok:e,message:t}},pi.prototype.updateVideoSettings=async function(e){await this.requestCamera(null==e?void 0:e.video)},Object.defineProperty(pi.prototype,"videoSrc",{get(){return this._dceVideoSrc},set(e){const t=this;t._dceVideoSrc=e,e?t.requestCamera("customized-video"):(t.video.src="",t.requestCamera(void 0))}}),pi.prototype.disableEnhancedFeatures=function(e){this._dceEnhancedFeatures=this._dceEnhancedFeatures-(this._dceEnhancedFeatures&e)},pi.prototype.enableEnhancedFeatures=function(e){this._dceEnhancedFeatures|=e},pi.prototype.getCameraSettings=function(){var e,t;if(!this.track)throw Error("Camera not open");let i=null===(e=(t=this.track).getSettings)||void 0===e?void 0:e.call(t);if(void 0===i)throw Error("Not supported");return i},pi.prototype.getCapabilities=function(){var e,t;if(!this.track)throw Error("Camera not open");let i=null===(e=(t=this.track).getCapabilities)||void 0===e?void 0:e.call(t);if(void 0===i)throw Error("Not supported");return i},pi.prototype.getColorTemperature=function(){var e,t;if(!this.track)throw Error("Camera not open");let i=null===(e=this.track)||void 0===e||null===(t=e.getSettings)||void 0===t||null===(t=t.call(e))||void 0===t?void 0:t.colorTemperature;if(void 0===i)throw Error("Not supported");return i},pi.prototype.getExposureCompensation=function(){var e,t;if(!this.track)throw Error("Camera not open");let i=null===(e=this.track)||void 0===e||null===(t=e.getSettings)||void 0===t||null===(t=t.call(e))||void 0===t?void 0:t.exposureCompensation;if(void 0===i)throw Error("Not supported");return i},pi.prototype.getFrameRate=function(){var e,t;if(!this.track)throw Error("Camera not open");let i=null===(e=this.track)||void 0===e||null===(t=e.getSettings)||void 0===t||null===(t=t.call(e))||void 0===t?void 0:t.frameRate;if(void 0===i)throw Error("Not supported");return i},pi.prototype.setColorTemperature=async function(e){var t;const i=this;i.getColorTemperature(),oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{colorTemperature:e,whiteBalanceMode:"manual"}]})))},pi.prototype.setExposureCompensation=async function(e){var t;const i=this;i.getExposureCompensation(),oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{exposureCompensation:e}]})))},pi.prototype.setFrameRate=async function(e){var t;const i=this;i.getFrameRate(),oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{frameRate:e}]})))},pi.prototype.getZoomSettings=function(){return{factor:this._dceZoom}};const Ti=async function(e){const t=this;if("number"==typeof e)return void await t._oriSetZoom(e);let i,s=e.factor;try{i=t.getZoomRange().max}catch(e){i=null}i?s<i?(await t._oriSetZoom(s),t.setSoftZoom(1)):(await t._oriSetZoom(i),t.setSoftZoom(s/i)):t.setSoftZoom(s),t._dceZoom=s};function wi(e,t,i,s){const n=document.createElement("canvas");n.width=t,n.height=i;const r=n.getContext("2d");if(10!==s){let s=new Uint8Array(t*i*4);for(let t=0;t<e.length;++t){let i=4*t;s[i+2]=s[i+1]=s[i]=e[t],s[i+3]=255}e=s}const o=new Uint8ClampedArray(e),a=new ImageData(o,t,i);return r.putImageData(a,0,0),n}pi.prototype.resetZoom=async function(){this._dceZoom=1,this.setSoftZoom(1,{center:{x:0,y:0}});try{await this._oriSetZoom(1)}catch(e){}},pi.prototype.getFocusSettings=function(){var e,t,i;if(!this.track)throw Error("Camera not open");let s,n=null===(e=this.track)||void 0===e||null===(t=e.getSettings)||void 0===t?void 0:t.call(e),r=null==n?void 0:n.focusMode;if(void 0===r)throw Error("Not supported");return s=r===(null===(i=this._dceFocusSettings)||void 0===i?void 0:i.mode)?this._dceFocusSettings:{mode:r},"manual"===s.mode&&(s.distance=null==n?void 0:n.focusDistance),s},pi.prototype.setFocus=async function(e){const t=this;if(!t.track)throw Error("Camera not open");if(t._dceFocusSettings=e,"manual"!==e.mode)oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await t.applyConstraints({advanced:[{focusMode:e.mode}]});else if(e.distance)oi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,oi._delayBeforeApplyConstraints)),await t.applyConstraints(t.correctAdvancedConstraint({advanced:[{focusMode:"manual",focusDistance:e.distance}]}));else if(e.area){let{x:i,y:s}=e.area.centerPoint,n=e.area.width,r=e.area.height,o=t.currentResolution.width,a=t.currentResolution.height;"string"==typeof i&&(i=i.endsWith("%")?parseFloat(i)*o:parseFloat(i)),"string"==typeof s&&(s=s.endsWith("%")?parseFloat(s)*a:parseFloat(s)),"string"==typeof n&&(n=n.endsWith("%")?parseFloat(n)*o:parseFloat(n)),"string"==typeof r&&(r=r.endsWith("%")?parseFloat(r)*a:parseFloat(r)),await t._advancedFocus({x:i,y:s},n,r)}},pi.prototype.setAutoZoomRange=function(e){var t;this._dceAutoZoomRange=e;const i=null===(t=this._enhancedFeaturesIrr)||void 0===t?void 0:t._autoZoomParameters;i&&(i.minValue=e.min,i.maxValue=e.max)},pi.prototype.getAutoZoomRange=function(){var e;const t=null===(e=this._enhancedFeaturesIrr)||void 0===e?void 0:e._autoZoomParameters;return t?{min:t.minValue,max:t.maxValue}:this._dceAutoZoomRange},pi.prototype.toggleMirroring=function(e){this.isMirrored=e};let Si=0;pi.prototype.fetchImage=function(){const e=this.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0});let{width:t,height:i}=e;const s=this.getFrame(e),n=s.getContext("2d").getImageData(0,0,t,i).data;return{bytes:new Uint8Array(n.buffer,n.byteOffset,n.byteLength),width:t,height:i,stride:4*e.width,format:10,toCanvas:()=>s,imageTag:{imageId:++Si,type:1}}},pi.prototype.getImage=function(){var e;const t=this,i=t.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0}),s=2!=t._pixelFormat;let n=t._framePipeline.getData({...i,type:s?"rgba":"gray"});if(!n)return null;let{width:r,height:o}=i,a=s?10:2,c=i.width*(s?4:1);if(s&&[3,4,5].includes(t._colourChannelUsageType)){const e=r*o,i=t._colourChannelUsageType-3,s=new Uint8Array(r*o);for(let t=0;t<e;++t)s[t]=n[4*t+i];n=s,a=2,c/=4}const l={bytes:n,width:r,height:o,stride:c,format:a,toCanvas:function(){return wi(this.bytes,this.width,this.height,this.format)},imageTag:{imageId:++Si,type:1}};return null!==(e=this._dceEventListeners.frameAddedToBuffer)&&void 0!==e&&e.forEach(e=>{try{e.call(this,l)}catch(e){console.error(e)}}),l},pi.prototype.takePhoto=async function(e){const t=this;let i=!1;"opened"===t.status&&(i=!0,await t.close()),await t.close();const s=await vi(!0);return i&&await t._oriOpen(),null!=e&&e(s),s},Object.defineProperty(pi.prototype,"singleFrameMode",{get(){return this._singleFrameMode},set(e){var t;const i=this;i._singleFrameMode=e;const s=i.ui.querySelector(".dce-bg-camera");null!==(t=i._singleFrameModeCvs)&&void 0!==t&&t.remove(),i._singleFrameModeCvs=null,i._singleFrameModeResultForDcv=null,"disabled"!==e?(i.close(),i._dceSettingsBeforeSingleFrameMode||(i._dceSettingsBeforeSingleFrameMode={shouldCloseWhenHide:i.shouldCloseWhenHide,regionBox:{...i.regionBox},requestedCamera:i.requestedCamera},i.shouldCloseWhenHide=!1,i.setRegionBox({width:1,height:1,unit:"view-size",center:{x:0,y:0},innerUi:null}),i.requestCamera("customized-video")),s&&(i._singleFrameModeClickCallback||(i._singleFrameModeClickCallback=()=>{i.open()},s.addEventListener("click",i._singleFrameModeClickCallback)),s.style.display="",s.style.opacity="")):(i._dceSettingsBeforeSingleFrameMode&&(i.shouldCloseWhenHide=i._dceSettingsBeforeSingleFrameMode.shouldCloseWhenHide,i.setRegionBox(i._dceSettingsBeforeSingleFrameMode.regionBox),i.requestCamera(i._dceSettingsBeforeSingleFrameMode.requestedCamera),i._dceSettingsBeforeSingleFrameMode=null),i._singleFrameModeClickCallback&&(s.removeEventListener("click",i._singleFrameModeClickCallback),i._singleFrameModeClickCallback=null),s&&(s.style.display="none"))}}),pi.prototype.getScanRegion=function(){return this._dceScanRegion},pi.prototype.hasNextImageToFetch=function(){return"opened"===this.status},pi.prototype.isBufferEmpty=function(){return"opened"!==this.status},pi.prototype.getPixelFormat=function(){return this._pixelFormat},pi.prototype.setPixelFormat=function(e){this._pixelFormat=e},pi.prototype.setColourChannelUsageType=function(e){this._colourChannelUsageType=e},pi.prototype.getColourChannelUsageType=function(){return this._colourChannelUsageType},pi.prototype.setScanRegion=function(e){this._dceScanRegion=null!=e?e:e=yi;const t=this._dceRegionMaskVisible,i=this._dceRegionMaskStyle;if(e.isMeasuredInPercentage)if(void 0!==e.x){let s=e;this.setRegionBox({width:s.width/100,height:s.height/100,center:{x:(s.x+s.width/2-50)/100,y:(s.y+s.height/2-50)/100},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}else{let s=e;this.setRegionBox({width:(s.right-s.left)/100,height:(s.bottom-s.top)/100,center:{x:((s.left+s.right)/2-50)/100,y:((s.top+s.bottom)/2-50)/100},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}else{let s=this.video.videoWidth||720,n=this.video.videoHeight||1280;if(void 0!==e.x){let r=e;this.setRegionBox({width:Math.min(r.width/s,1),height:Math.min(r.height/n,1),center:{x:0,y:0},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}else{let r=e;this.setRegionBox({width:Math.min((r.right-r.left)/s,1),height:Math.min((r.bottom-r.top)/n,1),center:{x:0,y:0},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}}},pi.prototype.setCameraView=function(e){if(e===this)return;const t=e.ui.parentElement;e.ui.parentElement&&(e.ui.remove(),t.append(this.ui));let i=[];for(let t in e)"function"==typeof e[t]&&i.push(t);for(let t of i)e[t]=this[t].bind(this)},pi.prototype.getCameraView=function(){return this},pi.prototype.getVideoEl=function(){return this.video},pi.prototype.convertToPageCoordinates=function(e){let{x:t,y:i}=this.getVisibleAreaInVideoXY({isConsiderRegionBox:!0});return(isNaN(t)||isNaN(i))&&(t=i=0),this.videoXY2AbsoluteLT([{x:e.x+t,y:e.y+i}]).map(e=>({x:e.left,y:e.top}))[0]},pi.prototype.convertToClientCoordinates=function(e){let{x:t,y:i}=this.getVisibleAreaInVideoXY({isConsiderRegionBox:!0});return(isNaN(t)||isNaN(i))&&(t=i=0),this.videoXY2FixedLT([{x:e.x+t,y:e.y+i}]).map(e=>({x:e.left,y:e.top}))[0]},pi.prototype.convertToScanRegionCoordinates=function(e){const t=this,i=t.video.videoWidth,s=t.video.videoHeight;let n=t.videoXY2AbsoluteLT([{x:0,y:0},{x:i,y:s}]);return{x:e.x/i*(n[1].left-n[0].left),y:e.y/s*(n[1].top-n[0].top)}},pi.prototype.convertToContainCoordinates=function(e){const t=this;let i,s,n,r;{let{x:e,y:n}=t.getVisibleAreaInVideoXY();if(isNaN(e)||isNaN(n))return{x:0,y:0};i=e,s=n}{let{x:e,y:i}=t.getVisibleAreaInVideoXY({isConsiderRegionBox:!0});if(isNaN(e)||isNaN(i))return{x:0,y:0};n=e,r=i}const o=t.video.videoWidth,a=t.video.videoHeight;let c=t.videoXY2AbsoluteLT([{x:0,y:0},{x:o,y:a}]);return{x:(e.x+n-i)/o*(c[1].left-c[0].left),y:(e.y+r-s)/a*(c[1].top-c[0].top)}},pi.prototype.on=function(e,t){var i,s;(null!==(s=(i=this._dceEventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)},pi.prototype.off=function(e,t){var i;null===(i=this._dceEventListeners[e])||void 0===i||i.delete(t)},Ei.prototype.getUIElement=function(){return this.ui},Ei.prototype.setUIElement=async function(e){const t=this;if(!e)return void(t._ui=void 0);if(e instanceof HTMLElement&&e.contains(t._coreShell))return void(t._ui=e);if(e instanceof HTMLElement&&!e.childElementCount)return await t.setUIElement(Ei.defaultUIElementURL),e.append(t.getUIElement()),void(t.ui=e);if("string"==typeof e){let i=e.trim();if(!i.trimStart().startsWith("<")){if(i.includes("@engineResourcePath/")){const e=pi.handleEngineResourcePaths(pi.CoreModule.engineResourcePaths);i=i.replace("@engineResourcePath/","DBR"===pi.CoreModule._bundleEnv?e.dbrBundle:e.dcvData)}i=await fetch(i).then(e=>e.text()),i=i.trim()}if(!i.startsWith("<"))throw Error("Invalid html string.");if(i.startsWith("<template>")&&(i=i.substring(10,i.length-11).trim()),!i.startsWith("<"))throw Error("Invalid html string.");let s,n=zt(i,{inlineScript2Blob:t._uiInlineScript2Blob,internalCss2Blob:t._uiInternalCss2Blob,insertInternalCss2ExistedSheet:t._uiInternalCss2ExistedSheet});if(n instanceof HTMLElement)s=n;else{if(!(n instanceof DocumentFragment))throw Error("Seems no HTMLElement.");s=document.createElement("div"),Object.assign(s.style,{width:"100%",height:"100%"}),s.append(n)}e=s,Object.defineProperty(e,"shadowRoot",{value:e,writable:!0})}if(!(e instanceof HTMLElement))throw Error("Invalid html string.");const i="dm-camera-core-container";let s=e.classList.contains(i)?e:e.querySelector(`.${i}`);if(!s){const n="dce-video-container";if(s=e.classList.contains(n)?e:e.querySelector(`.${n}`),s){e.style.overflow="hidden";{const i=e.querySelector("select.dce-sel-camera"),s=e.querySelector("select.dce-sel-resolution");if(i&&!i._dce_binded&&"none"!=i.style.display){i._dce_binded=!0;const e=i.style.zIndex;let s;i.style.position||(i.style.position="relative"),i.style.zIndex="-1",t.addEventListener("opened",async()=>{const s=await oi.getDeviceInfos(),n=t.currentCamera;if(!n)return;const r=n.trackLabel||n.label;i.textContent="";for(let e of s){const t=document.createElement("option");t.value=e.deviceId,t.textContent=e.trackLabel||e.label,i.append(t),t.textContent===r&&(i.value=e.deviceId)}i.style.zIndex=e}),i.addEventListener("change",s=async()=>{t.disposed?t.removeEventListener("change",s):(await t.requestCamera(i.value),"opened"!==t.status&&await t.open())}),t.addEventListener("closed",async()=>{i.style.zIndex="-1"})}if(s&&!s._dce_binded&&"none"!=s.style.display){s._dce_binded=!0;const e=s.style.zIndex;let i,n;if(s.style.position||(s.style.position="relative"),s.style.zIndex="-1",s.children.length)i=s.querySelector(".dce-opt-gotResolution");else{i=document.createElement("option"),i.classList.add("dce-opt-gotResolution"),i.value="got",s.append(i);for(let[e,t]of[[1920,1080],[1280,720],[640,480]]){const i=document.createElement("option");i.setAttribute("data-width",`${e}`),i.setAttribute("data-height",`${t}`),i.textContent=`ask ${e}x${t}`,s.append(i)}}s.addEventListener("change",n=async()=>{if(t.disposed)return void t.removeEventListener("change",n);const e=s.selectedOptions[0];let i=parseInt(e.getAttribute("data-width")),r=parseInt(e.getAttribute("data-height"));await t.requestResolution({width:i,height:r})}),i&&t.addEventListener("opened",async()=>{let n=t.currentResolution;i.textContent=`${n.width}x${n.height}`,s.value="got",s.style.zIndex=e}),t.addEventListener("closed",async()=>{s.style.zIndex="-1"})}let n=e.querySelector(".dce-bg-loading");n&&(n.parentElement.append(n),n.style.display="none");let r=e.querySelector(".dce-bg-camera");if(r instanceof SVGElement){const e=document.createElement("div");Object.assign(e.style,{display:"none",position:"absolute",left:"0",top:"0",width:"100%",height:"100%",cursor:"pointer",pointerEvents:"auto"}),e.title="Take a photo",r.parentElement.append(e),r.classList.remove("dce-bg-camera"),e.classList.add("dce-bg-camera"),e.append(r),r.style.display="",r=e}else r&&r.parentElement.append(r);let o=e.querySelector(".dm-camera-mn-toast,.dce-mn-toast");if(!o&&r){o=document.createElement("div"),o.classList.add("dm-camera-mn-toast"),Object.assign(o.style,{position:"absolute",maxWidth:"90%",fontSize:"max(1.25vmin, 10px)",lineHeight:"max(2vmin, 16px)",padding:"max(0.25vmin, 2px) max(0.5vmin, 4px)",left:"50%",bottom:"max(12.5vmin, 100px)",transform:"translateX(-50%)",color:"#fff",borderRadius:"max(0.5vmin, 4px)",background:"rgba(100, 100, 100, 0.5)",whiteSpace:"pre-wrap",overflowWrap:"break-word",display:"none",zIndex:"1"}),r.parentElement.append(o);let e=null;t.funcShowToast=(t,i=3e3)=>{o&&(o.textContent=t,o.style.display="",null!=e&&(clearTimeout(e),e=null),i&&(e=setTimeout(()=>{o.style.display="none",e=null},i)))}}const a=e.querySelector(".dce-macro-use-mobile-native-like-ui");if(a&&!a._dce_binded){const e=a;e._dce_binded=!0;const i=e.querySelector(".dce-mn-torch"),s=e.querySelector(".dce-mn-torch-auto"),n=e.querySelector(".dce-mn-torch-on"),r=e.querySelector(".dce-mn-torch-off");s&&(s.style.display=void 0===t.isTorchOn?"":"none"),n&&(n.style.display=!0===t.isTorchOn?"":"none"),r&&(r.style.display=!1===t.isTorchOn?"":"none");const o=e.querySelector(".dce-mn-beep-on"),c=e.querySelector(".dce-mn-beep-off");o&&(o.style.display=t._dceMNIsBeepBarcode?"":"none"),c&&(c.style.display=t._dceMNIsBeepBarcode?"none":"");const l=e.querySelector(".dce-mn-vibrate-on"),d=e.querySelector(".dce-mn-vibrate-off");l&&(l.style.display=t._dceMNIsVibrateBarcode?"":"none"),d&&(d.style.display=t._dceMNIsVibrateBarcode?"none":"");const u=e.querySelector(".dce-mn-resolution-box"),h=e.querySelector(".dce-mn-zoom");let _;h&&(h.style.display="none",_=h.querySelector("span"));const m=e.querySelector(".dce-mn-toast");m&&(m.style.display="none",m.classList.add("dm-camera-mn-toast"),m.style.zIndex||(m.style.zIndex="1"));const g=e.querySelector(".dce-mn-camera-close");e.querySelector(".dce-mn-take-photo");const f=e.querySelector(".dce-mn-camera-switch");f&&(f.style.display="none");const p=e.querySelector(".dce-mn-camera-and-resolution-settings");p&&(p.style.display="none");const E=null==p?void 0:p.querySelector(".dce-mn-cameras"),y=null==p?void 0:p.querySelectorAll(".dce-mn-resolution-option");t.addEventListener("opened",async()=>{if(!t.disposed&&"customized-video"!=t.requestedCamera){var e;if(a.style.display="",t.isMirrored=null===(e=t.currentCamera)||void 0===e?void 0:e.isFront,i&&(i.style.display=""),u||null!=y&&y.length){let e;{let i=t.currentResolution,s=Math.max(i.width,i.height),n=Math.min(i.width,i.height);e=n<=1080?n+"P":s<3e3?"2K":Math.round(s/1e3)+"K"}if(u&&(u.textContent=e,u.style.display=""),null!=y&&y.length)for(let t of y)t.textContent===e?t.setAttribute("selected",""):t.hasAttribute("selected")&&t.removeAttribute("selected")}if(E){const e=await oi.getDeviceInfos(),i=t.currentCamera;if(!i)return;const s=i.trackLabel||i.label;E.textContent="";for(let t of e){const e=document.createElement("div");e.classList.add("dce-mn-camera-option"),e.setAttribute("data-device-id",t.deviceId),e.textContent=t.trackLabel||t.label,e.textContent===s&&e.setAttribute("selected",""),E.append(e)}}await oi.hasFrontCamera()&&f&&(f.style.display="")}}),t.addEventListener("closed",()=>{t.disposed||(a.style.display="none",i&&(i.style.display="none"),u&&(u.style.display="none"),f&&(f.style.display="none"),p&&(p.style.display="none"))}),null!=s&&s.addEventListener("pointerdown",()=>{t.disposed||(t.turnOnTorch(),s.style.display="none",n.style.display="")}),null!=n&&n.addEventListener("pointerdown",()=>{t.disposed||(t.turnOffTorch(),n.style.display="none",r.style.display="")}),null!=r&&r.addEventListener("pointerdown",()=>{t.disposed||(t.isSupportTorch?(t.turnAutoTorch(),r.style.display="none",s.style.display=""):R("Torch Not Supported"))}),null!=o&&o.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!1,o.style.display="none",c.style.display="")}),null!=c&&c.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!0,c.style.display="none",o.style.display="")}),null!=l&&l.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsVibrateBarcode=!1,l.style.display="none",d.style.display="")}),null!=d&&d.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsVibrateBarcode=!0,d.style.display="none",l.style.display="")}),t.addEventListener("torchAutoOn",()=>{t.disposed||(R("Torch Auto On"),s&&(s.style.display="none"),n&&(n.style.display=""))}),e.addEventListener("click",async e=>{if(t.disposed)return;let i,s=e.target;if(i=s.closest(".dce-mn-camera-option")){if(i.hasAttribute("selected"))return;await t.requestCamera(i.getAttribute("data-device-id")),"opened"!==t.status&&await t.open()}else if(i=s.closest(".dce-mn-resolution-option")){if(i.hasAttribute("selected"))return;let e=parseInt(i.getAttribute("data-width")),s=parseInt(i.getAttribute("data-height"));if(await t.requestResolution({width:e,height:s}),y.length){const e=null==p?void 0:p.querySelector(".dce-mn-resolution-option[selected]");e&&e.textContent!=i.textContent&&R(`Fallback to ${e.textContent}`)}}else{if(s.closest(".dce-mn-camera-and-resolution-settings"))return;if(s.closest(".dce-mn-resolution-box"))return void(p&&(p.style.display=p.style.display?"":"none"))}p&&""===p.style.display&&(p.style.display="none")});let I=null;t.addEventListener("zoom",({zoom:e})=>{t.disposed||h&&_&&(_.textContent=e.toFixed(1),h.style.display="",null!=I&&(clearTimeout(I),I=null),I=setTimeout(()=>{h.style.display="none",I=null},3e3))});let v=null;const R=t.funcShowToast=(e,t=3e3)=>{m&&(m.textContent=e,m.style.display="",null!=v&&(clearTimeout(v),v=null),t&&(v=setTimeout(()=>{m.style.display="none",v=null},t)))};null!=g&&g.addEventListener("click",()=>{t.disposed||t.close()}),null==f||f.addEventListener("pointerdown",async()=>{t.disposed||await t.requestCamera(t.currentCamera.isFront?"back":"front")})}}s.classList.add(i)}}s||e.classList.add(i),t.ui=e},Ei.prototype.getVideoElement=function(){return this.video},Ei.prototype.setVideoFit=function(e){this.objectFit=e},Ei.prototype.getVideoFit=function(){return this.objectFit},Ei.prototype.getVisibleRegionOfVideo=function(e){const t=this;let{inPixels:i}=e||{inPixels:!1};const s=t.getVisibleAreaInVideoXY();if(i)return{...s,isMeasuredInPercentage:!1};{let{width:e,height:i}=t.currentResolution;return{x:s.x/e*100,y:s.y/i*100,width:s.width/e*100,height:s.height/i*100,isMeasuredInPercentage:!0}}},Ei.prototype.setScanRegionMaskStyle=function(e){const t=this._dceRegionMaskVisible;this._dceRegionMaskStyle={...e},this.setRegionBox({maskStyle:{background:t?e.fillStyle:""},borderStyle:{border:t?`${e.lineWidth}px solid ${e.strokeStyle}`:""}})},Ei.prototype.getScanRegionMaskStyle=function(){return this._dceRegionMaskStyle},Ei.prototype.setScanRegionMaskVisible=function(e){this._dceRegionMaskVisible=e;const t=this._dceRegionMaskStyle;this.setRegionBox({maskStyle:{background:e?t.fillStyle:""},borderStyle:{border:e?`${t.lineWidth}px solid ${t.strokeStyle}`:""}})},Ei.prototype.isScanRegionMaskVisible=function(){return this._dceRegionMaskVisible},Ei.prototype.setScanLaserVisible=function(e){var t;if(null===(t=this.regionBox)||void 0===t||!t.innerUi)return;const i=this.regionBox.innerUi.style;i.display=e?"":"none",setTimeout(()=>{i.display="none",e&&(i.display="")},0)},Ei.prototype.isScanLaserVisible=function(){var e;return!(null===(e=this.regionBox)||void 0===e||!e.innerUi)&&"none"!==this.regionBox.innerUi.style.display},Ei.prototype.setPowerByMessageVisible=function(e){let t=this.ui.querySelector(".dce-msg-poweredby,.dce-mn-msg-poweredby,.dm-camera-mn-msg-poweredby");t&&(e?"none"===t.style.display&&(t.style.display=""):t.style.display="none")},Ei.prototype.isPowerByMessageVisible=function(){let e=this.ui.querySelector(".dce-msg-poweredby,.dm-camera-mn-msg-poweredby");return e&&"none"!==e.style.display},Ei.prototype.getTipConfig=function(){return{duration:this._dceTipDuration}},Ei.prototype.setTipConfig=function(e){this._dceTipDuration=e.duration},Ei.prototype.setTipVisible=function(e){var t;if(e)null===(t=this.funcShowToast)||void 0===t||t.call(this,this._dceTipMessage,this._dceTipDuration);else{const e=this.ui.querySelector(".dm-camera-mn-toast");e&&(e.style.display="none")}},Ei.prototype.isTipVisible=function(){const e=this.ui.querySelector(".dm-camera-mn-toast");return!!e&&"none"!=e.style.display},Ei.prototype.updateTipMessage=function(e){var t;this._dceTipMessage=e,null===(t=this.funcShowToast)||void 0===t||t.call(this,this._dceTipMessage,this._dceTipDuration)},Ei.prototype.createDrawingLayer=function(){const e=new Fi;return e._dce=this,e._ctx=this.addCanvas().getContext("2d"),this._drawingLayers.push(e),e},Ei.prototype.getDrawingLayer=function(e){if(e instanceof Fi)return e;if("number"!=typeof e)return null;let t=this._drawingLayers[e];return t||1!==e&&2!==e&&3!==e||(t=new Fi,t._dce=this,t._ctx=this.addCanvas().getContext("2d"),this._drawingLayers[e]=t,1===e?t._defaultStyle=Bi.STYLE_BLUE_STROKE:2===e?t._defaultStyle=Bi.STYLE_ORANGE_STROKE_FILL:3===e&&(t._defaultStyle=Bi.STYLE_GREEN_STROKE_FILL)),t},Ei.prototype.getAllDrawingLayers=function(){for(let e=1;e<=3;e++)this.getDrawingLayer(e);return this._drawingLayers.filter(e=>e)},Ei.prototype.clearUserDefinedDrawingLayers=function(){for(let t=100;t<this._drawingLayers.length;++t){var e;null===(e=this._drawingLayers[t])||void 0===e||null===(e=e._ctx)||void 0===e||e.canvas.remove()}this._drawingLayers.length=100},Ei.prototype.deleteUserDefinedDrawingLayer=function(e){var t;e<100||(null!==(t=this._drawingLayers[e])&&void 0!==t&&null!==(t=t._ctx)&&void 0!==t&&t.canvas.remove(),delete this._drawingLayers[e])},Ei.prototype.clearAllInnerDrawingItems=function(e){for(let t of this._drawingLayers.slice(1,4))!t||e&&"editor"===t._mode||t.clearDrawingItems()};let Ai=class{static beep(){null!=this._beepInstance?this._beepInstance.beep():gi()}static get beepSoundSource(){var e;return null===(e=this._beepInstance)||void 0===e?void 0:e.beepSoundSource}static set beepSoundSource(e){var t;null!==(t=this._beepInstance)&&void 0!==t||(this._beepInstance=new mi),this._beepInstance.beepSoundSource=e}static vibrate(){null!=this.vibrateDuration?fi(this.vibrateDuration):fi()}};qt(Ai,"_beepInstance",void 0),qt(Ai,"vibrateDuration",void 0);const Di="73,245,73",bi="73,173,245",Li="254,180,32",Oi="245,236,73",Ni=(e,t)=>{let i,s;"f"===t?(i="strokeAndFill",s="0.3"):"t"===t?(i="fill",s="0.2"):(i="stroke",s="0.3");const n={lineWidth:2,fillStyle:`rgba(${e},${s})`,strokeStyle:`rgba(${e},0.9)`,fontFamily:"consolas",fontSize:40,paintMode:i};return n.id=n,n},Mi=[null,Ni(bi),Ni(Di),Ni(Li),Ni(Oi),Ni(bi,"f"),Ni(Di,"f"),Ni(Li,"f"),Ni(Oi,"f"),Ni(bi,"t"),Ni(Di,"t"),Ni(Li,"t"),Ni(Oi,"t")],Bi={STYLE_BLUE_STROKE:Mi[1],STYLE_GREEN_STROKE:Mi[2],STYLE_ORANGE_STROKE:Mi[3],STYLE_YELLOW_STROKE:Mi[4],STYLE_BLUE_STROKE_FILL:Mi[5],STYLE_GREEN_STROKE_FILL:Mi[6],STYLE_ORANGE_STROKE_FILL:Mi[7],STYLE_YELLOW_STROKE_FILL:Mi[8],STYLE_BLUE_STROKE_TRANSPARENT:Mi[9],STYLE_GREEN_STROKE_TRANSPARENT:Mi[10],STYLE_ORANGE_STROKE_TRANSPARENT:Mi[11],STYLE_YELLOW_STROKE_TRANSPARENT:Mi[12],createDrawingStyle(e){let t=Object.assign({},this.STYLE_YELLOW_STROKE_FILL,e);return Object.assign(e,t),e},getDrawingStyle:e=>"number"==typeof e?Mi[e]:e,getAllDrawingStyles:()=>Mi.filter(e=>e),updateDrawingStyle(e,t){e=this.getDrawingStyle(e),Object.keys(e).forEach(t=>{delete e[t]}),Object.assign(e,t),e.id=e}};let Fi=class{constructor(){qt(this,"_visible",!0),qt(this,"_dce",void 0),qt(this,"_ctx",void 0),qt(this,"_defaultStyle",Bi.STYLE_YELLOW_STROKE_FILL),qt(this,"_drawingItems",[]),qt(this,"_mode","viewer"),qt(this,"_editorView",void 0),qt(this,"_renderTask",void 0),qt(this,"_newSelectedDrawingItems",[]),qt(this,"_newDeselectedDrawingItems",[]),qt(this,"_selectionChangedTask",void 0),qt(this,"_onSelectionChanged",void 0)}getId(){return this}isVisible(){return this._editorView?this._editorView._firstLayer.isVisible():this._visible}setVisible(e){if(this._editorView)return this._editorView._firstLayer.setVisible(e);this._visible=e,this._delayRenderAll()}setDefaultStyle(e,t,i){if(this._editorView)return this._editorView._firstLayer.setDefaultStyle(e,t,i);this._defaultStyle=Bi.getDrawingStyle(e),this._delayRenderAll()}addDrawingItems(e){if(this._editorView)return this._editorView._firstLayer.addDrawingItems(e);for(let t of e)t.drawingLayerId=this;this._drawingItems=this._drawingItems.concat(e),this._delayRenderAll()}removeDrawingItems(e){if(this._editorView)return this._editorView._firstLayer.removeDrawingItems(e);this._drawingItems=this._drawingItems.filter(t=>!e.includes(t)),this._delayRenderAll()}setDrawingItems(e){if(this._editorView)return this._editorView._firstLayer.setDrawingItems(e);for(let t of e)t.drawingLayerId=this;this._drawingItems=[...e],this._delayRenderAll()}getDrawingItems(e){return this._editorView?this._editorView._firstLayer.getDrawingItems(e):this._drawingItems.filter(t=>!e||e(t))}hasDrawingItem(e){return this._editorView?this._editorView._firstLayer.hasDrawingItem(e):this._drawingItems.includes(e)}getSelectedDrawingItems(){return this._editorView?this._editorView._firstLayer.getSelectedDrawingItems():this._drawingItems.filter(e=>e._bSelected)}clearDrawingItems(){if(this._editorView)return this._editorView._firstLayer.clearDrawingItems();this._drawingItems=[],this._delayRenderAll()}_delayRenderAll(){this._renderTask||(this._renderTask=setTimeout(()=>{this.renderAll(),this._renderTask=null},0))}renderAll(){var e;if(this._editorView)return this._editorView._firstLayer.renderAll();if(!this._ctx)return;const t=this._ctx,i=t.canvas;if(t.clearRect(0,0,i.width,i.height),!this._visible)return;let s={x:0,y:0};"disabled"===(null===(e=this._dce)||void 0===e?void 0:e.singleFrameMode)&&(s=this._dce.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0}));let n=i.width/i.getBoundingClientRect().width;n>1&&n<i.width||(n=1);for(let e of this._drawingItems){const i=Bi.getDrawingStyle(e.drawingStyleId||this._defaultStyle);if(t.fillStyle=i.fillStyle,t.strokeStyle=i.strokeStyle,t.lineWidth=i.lineWidth*n,t.setLineDash([]),e instanceof Gi){const r=e.text.split("\n"),{x:o,y:a,width:c,height:l}=e.rect,d=Math.min(i.fontSize*n,l/r.length);t.font=`${d}px ${i.fontFamily}`,t.textBaseline="top";const u=o+s.x;for(let e=0;e<r.length;++e){const i=a+l/r.length*e+s.y;t.fillText(r[e],u,i,c),t.strokeText(r[e],u,i,c)}}else if(e instanceof Wi){const i=e.image,n=i.naturalWidth||i.videoWidth||i.width||0,r=i.naturalHeight||i.videoHeight||i.height||0;if(!n||!r)continue;let{x:o,y:a,width:c,height:l}=e.rect;e.maintainAspectRatio&&(l=c/n*r),t.drawImage(i,o+s.x,a+s.y,c,l)}else{if(e._bSelected&&(t.strokeStyle="#0f0",t.lineWidth=2*n,t.setLineDash([4,4])),t.beginPath(),e instanceof Ui){const i=e.quad.points;t.moveTo(i[0].x+s.x,i[0].y+s.y),t.lineTo(i[1].x+s.x,i[1].y+s.y),t.lineTo(i[2].x+s.x,i[2].y+s.y),t.lineTo(i[3].x+s.x,i[3].y+s.y)}else if(e instanceof ki){const i=e.line.startPoint,n=e.line.endPoint;t.moveTo(i.x+s.x,i.y+s.y),t.lineTo(n.x+s.x,n.y+s.y)}else if(e instanceof Vi){const{x:i,y:n,width:r,height:o}=e.rect;t.moveTo(i+s.x,n+s.y),t.lineTo(i+r+s.x,n+s.y),t.lineTo(i+r+s.x,n+o+s.y),t.lineTo(i+s.x,n+o+s.y)}i.paintMode.toLowerCase().includes("fill")&&t.fill(),t.closePath(),i.paintMode.toLowerCase().includes("stroke")&&t.stroke()}}}getMode(){return this._mode}async setMode(e){}_delaySelectionChanged(){this._onSelectionChanged&&!this._selectionChangedTask&&(this._selectionChangedTask=setTimeout(()=>{try{this._onSelectionChanged([...this._newSelectedDrawingItems],[...this._newDeselectedDrawingItems])}catch(e){}this._newSelectedDrawingItems.length=this._newDeselectedDrawingItems.length=0,this._selectionChangedTask=null},0))}get onSelectionChanged(){return this._editorView?this._editorView._firstLayer.onSelectionChanged:this._onSelectionChanged}set onSelectionChanged(e){this._editorView?this._editorView._firstLayer.onSelectionChanged=e:this._onSelectionChanged=e}};function xi(e,t){const[i,s]=e;let n=!1;for(let e=0,r=t.length-1;e<t.length;r=e++){const[o,a]=t[e],[c,l]=t[r];if(i===o&&s===a||i===c&&s===l)return!0;if((i<=o&&i>=c||i>=o&&i<=c)&&(s<=a&&s>=l||s>=a&&s<=l)&&(i-o)*(s-a)==(i-c)*(s-l))return!0;a>s!=l>s&&i<(c-o)*(s-a)/(l-a)+o&&(n=!n)}return n}let Pi=class{constructor(){qt(this,"coordinateBase","image"),qt(this,"drawingLayerId",void 0),qt(this,"drawingStyleId",void 0),qt(this,"mediaType",void 0),qt(this,"_notes",[]),qt(this,"_bSelected",!1),qt(this,"_dceEventListeners",{})}get _ps(){return null}getState(){return this._bSelected?Hi.DIS_SELECTED:Hi.DIS_DEFAULT}addNote(e,t){if(t){let t=!1;for(let i=0;i<this._notes.length;++i)this._notes[i].name===e.name&&(this._notes.splice(i,1,e),t=!0);t||this._notes.push(e)}else this._notes.push(e)}getNote(e){for(let t of this._notes)if(e===t.name)return t;return null}getNotes(){return[...this._notes]}hasNote(e){for(let t of this._notes)if(e===t.name)return!0;return!1}updateNote(e,t,i){for(let s of this._notes)e===s.name&&(i&&s.content&&t&&"object"==typeof s.content&&"object"==typeof t?s.content={...s.content,content:t}:i&&s.content&&t&&"string"==typeof s.content&&"string"==typeof t?s.content+=","+t:s.content=t)}deleteNote(e){this._notes=this._notes.filter(t=>t.name!==e)}clearNotes(){this._notes=[]}_delayRenderAll(){var e;null===(e=this.drawingLayerId)||void 0===e||e._delayRenderAll()}_setSelected(e){if(e===this._bSelected)return;this._bSelected=e,this._delayRenderAll();let t=this.drawingLayerId;t&&(e?t._newSelectedDrawingItems.push(this):t._newDeselectedDrawingItems.push(this),t._delaySelectionChanged())}on(e,t){var i,s;(null!==(s=(i=this._dceEventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)}off(e,t){var i;null===(i=this._dceEventListeners[e])||void 0===i||i.delete(t)}},ki=class extends Pi{get _ps(){const e=this.line.startPoint,t=this.line.endPoint;return[e,e,t,t]}constructor(e,t){super(),qt(this,"line",void 0),this.mediaType=Zi.DIMT_LINE,this.line=e,this.drawingStyleId=t}getLine(){return this.line}setLine(e){this.line=e,this._delayRenderAll()}},Ui=class extends Pi{get _ps(){return this.quad.points}constructor(e,t){super(),qt(this,"quad",void 0),this.mediaType=Zi.DIMT_QUADRILATERAL,this.quad=e,this.drawingStyleId=t}getQuad(){return this.quad}setQuad(e){this.quad=e,this._delayRenderAll()}},Vi=class extends Pi{get _ps(){const{x:e,y:t,width:i,height:s}=this.rect;return[{x:e,y:t},{x:e+i,y:t},{x:e+i,y:t+s},{x:e,y:t+s}]}constructor(e,t){super(),qt(this,"rect",void 0),this.mediaType=Zi.DIMT_RECTANGLE,this.rect=e,this.drawingStyleId=t}getRect(){return this.rect}setRect(e){this.rect=e,this._delayRenderAll()}},Gi=class extends Pi{get _ps(){const{x:e,y:t,width:i,height:s}=this.rect;return[{x:e,y:t},{x:e+i,y:t},{x:e+i,y:t+s},{x:e,y:t+s}]}constructor(e,t,i){super(),qt(this,"text",void 0),qt(this,"rect",void 0),this.mediaType=Zi.DIMT_TEXT,this.text=e,this.rect=t,this.drawingStyleId=i}getText(){return this.text}setText(e){this.text=e,this._delayRenderAll()}getTextRect(){return this.rect}setTextRect(e){this.rect=e,this._delayRenderAll()}},Wi=class extends Pi{get _ps(){const{x:e,y:t,width:i,height:s}=this.rect;return[{x:e,y:t},{x:e+i,y:t},{x:e+i,y:t+s},{x:e,y:t+s}]}constructor(e,t,i,s){super(),qt(this,"image",void 0),qt(this,"rect",void 0),qt(this,"maintainAspectRatio",void 0),this.mediaType=Zi.DIMT_IMAGE,this.setImage(e),this.rect=t,this.maintainAspectRatio=i,this.drawingStyleId=s}getImage(){return this.image}setImage(e){e.bytes&&e.format&&(e=wi(e.bytes,e.width,e.height,e.format)),this.image=e,this._delayRenderAll()}getImageRect(){return this.rect}setImageRect(e){this.rect=e,this._delayRenderAll()}};const ji=function(e,t){const i=this;if(i.disposed||["closed","closing"].includes(i.status)&&"disabled"===i.singleFrameMode)return;i.clearAllInnerDrawingItems();const s=null==e?void 0:e.items;if(null!=s&&s.length)for(let e of s){let s,n,r;switch(e.type){case 2:s=i.getDrawingLayer(2),n=e.location.points.map(e=>({x:e.x,y:e.y})),null!=t&&t.isBarcodeVerifyOpen&&!e.verified?r=Bi.STYLE_ORANGE_STROKE_TRANSPARENT:(i._dceMNIsBeepBarcode&&gi(),i._dceMNIsVibrateBarcode&&fi());break;case 4:s=i.getDrawingLayer(3),n=e.location.points.map(e=>({x:e.x,y:e.y})),(null==t?void 0:t.isLabelVerifyOpen)&&!e.verified&&(r=Bi.STYLE_GREEN_STROKE_TRANSPARENT);break;case 8:s=i.getDrawingLayer(1),n=e.location.points.map(e=>({x:e.x,y:e.y})),(null==t?void 0:t.isDetectVerifyOpen)&&1!==e.crossVerificationStatus&&(r=Bi.STYLE_BLUE_STROKE_TRANSPARENT);break;case 16:s=i.getDrawingLayer(1),n=e.sourceLocation.points.map(e=>({x:e.x,y:e.y})),(null==t?void 0:t.isNormalizeVerifyOpen)&&1!==e.crossVerificationStatus&&(r=Bi.STYLE_BLUE_STROKE_TRANSPARENT);break;default:continue}s.addDrawingItems([new Ui({points:n},r)])}};var Zi,Hi,qi,Yi;!function(e){e[e.DIMT_RECTANGLE=1]="DIMT_RECTANGLE",e[e.DIMT_QUADRILATERAL=2]="DIMT_QUADRILATERAL",e[e.DIMT_TEXT=4]="DIMT_TEXT",e[e.DIMT_IMAGE=16]="DIMT_IMAGE",e[e.DIMT_LINE=64]="DIMT_LINE"}(Zi||(Zi={})),function(e){e[e.DIS_DEFAULT=1]="DIS_DEFAULT",e[e.DIS_SELECTED=2]="DIS_SELECTED"}(Hi||(Hi={})),function(e){e[e.EF_ENHANCED_FOCUS=4]="EF_ENHANCED_FOCUS",e[e.EF_AUTO_ZOOM=16]="EF_AUTO_ZOOM",e[e.EF_TAP_TO_FOCUS=64]="EF_TAP_TO_FOCUS"}(qi||(qi={})),function(e){e.GREY="grey",e.GREY32="grey32",e.RGBA="rgba",e.RBGA="rbga",e.GRBA="grba",e.GBRA="gbra",e.BRGA="brga",e.BGRA="bgra"}(Yi||(Yi={}));var $i=Object.freeze({__proto__:null,Beep:mi,Camera:oi,CameraEnhancer:pi,CameraEnhancerModule:{getVersion:()=>"5.0.0-dev-20260424104300"},CameraView:Ei,DrawingItem:Pi,DrawingLayer:Fi,DrawingStyleManager:Bi,get EnumDrawingItemMediaType(){return Zi},get EnumDrawingItemState(){return Hi},get EnumEnhancedFeatures(){return qi},get EnumPixelFormat(){return Yi},Feedback:Ai,FramePipeline:_i,ImageDrawingItem:Wi,LineDrawingItem:ki,QuadDrawingItem:Ui,RectDrawingItem:Vi,TextDrawingItem:Gi,_bufferToCanvas:wi,_distToSegment:function(e,t){const[i,s]=e,[[n,r],[o,a]]=t,c=o-n,l=a-r,d=c*c+l*l;if(0===d)return Math.sqrt((i-n)**2+(s-r)**2);let u=((i-n)*c+(s-r)*l)/d;u=Math.max(0,Math.min(1,u));const h=i-(n+u*c),_=s-(r+u*l);return Math.sqrt(h*h+_*_)},_isPointInPolygon:xi,beep:gi,stringToHtml:zt,vibrate:fi});const zi="undefined"==typeof self,Ki=zi?{}:self,Xi="function"==typeof importScripts,Qi=(()=>{if(!Xi){if(!zi&&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"./"}})(),Ji=e=>e&&"object"==typeof e&&"function"==typeof e.then,es=(async()=>{})().constructor;let ts=class extends es{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,Ji(e)?t=e:"function"==typeof e&&(t=new es(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(Ji(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};const is=" is not allowed to change after `createInstance` or `loadWasm` is called.",ss=!zi&&document.currentScript&&(document.currentScript.getAttribute("data-license")||document.currentScript.getAttribute("data-productKeys")||document.currentScript.getAttribute("data-licenseKey")||document.currentScript.getAttribute("data-handshakeCode")||document.currentScript.getAttribute("data-organizationID"))||"",ns=(e,t)=>{const i=e;if(i._license!==t){if(!i._pLoad.isEmpty)throw new Error("`license`"+is);i._license=t}};!zi&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword");const rs=e=>{if(null==e)e=[];else{e=e instanceof Array?[...e]:[e];for(let t=0;t<e.length;++t){if(!zi){let i=document.createElement("a");i.href=e[t],e[t]=i.href}e[t].endsWith("/")||(e[t]+="/")}}return e},os=(e,t)=>{t=rs(t);const i=e;if(i._licenseServer!==t){if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+is);i._licenseServer=t}},as=(e,t)=>{t=t||"";const i=e;if(i._deviceFriendlyName!==t){if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+is);i._deviceFriendlyName=t}};let cs,ls,ds,us,hs;"undefined"!=typeof navigator&&(cs=navigator,ls=cs.userAgent,ds=cs.platform,us=cs.mediaDevices),function(){if(!zi){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:cs.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},t={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:ds,search:"Win"},Mac:{str:ds},Linux:{str:ds}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let r=n.str||ls,o=n.search||t,a=n.verStr||ls,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=r.indexOf(o)){i=t;for(let e of c){let t=a.indexOf(e);if(-1!=t){s=parseFloat(a.substring(t+e.length+1));break}}break}}for(let e in t){const i=t[e]||{};let s=i.str||ls,r=i.search||e;if(-1!=s.indexOf(r)){n=e;break}}"Linux"==n&&-1!=ls.indexOf("Windows NT")&&(n="HarmonyOS"),hs={browser:i,version:s,OS:n}}zi&&(hs={browser:"ssr",version:0,OS:"ssr"})}(),us&&us.getUserMedia,"Chrome"===hs.browser&&hs.version>66||"Safari"===hs.browser&&hs.version>13||"OPR"===hs.browser&&hs.version>43||"Edge"===hs.browser&&hs.version;const _s=()=>(Me.loadWasm(),ye("dynamsoft_inited",async()=>{let{lt:e,l:t,ls:i,sp:s,rmk:n,cv:r}=((e,t=!1)=>{const i=e;if(i._pLoad.isEmpty){let s,n,r,o=i._license||"",a=JSON.parse(JSON.stringify(i._licenseServer)),c=i._sessionPassword,l=0;if(o.startsWith("t")||o.startsWith("f"))l=0;else if(0===o.length||o.startsWith("P")||o.startsWith("L")||o.startsWith("Y")||o.startsWith("A"))l=1;else{l=2;const t=o.indexOf(":");-1!=t&&(o=o.substring(t+1));const i=o.indexOf("?");if(-1!=i&&(n=o.substring(i+1),o=o.substring(0,i)),o.startsWith("DLC2"))l=0;else{if(o.startsWith("DLS2")){let t;try{let e=o.substring(4);e=atob(e),t=JSON.parse(e)}catch(e){throw new Error("Format Error: The license string you specified is invalid, please check to make sure it is correct.")}if(o=t.handshakeCode?t.handshakeCode:t.organizationID?t.organizationID:"","number"==typeof o&&(o=JSON.stringify(o)),0===a.length){let e=[];t.mainServerURL&&(e[0]=t.mainServerURL),t.standbyServerURL&&(e[1]=t.standbyServerURL),a=rs(e)}!c&&t.sessionPassword&&(c=t.sessionPassword),s=t.remark}o&&"200001"!==o&&!o.startsWith("200001-")||(l=1)}}if(l&&(t||(Ki.crypto||(r="Please upgrade your browser to support online key."),Ki.crypto.subtle||(r="Require https to use online key in this browser."))),r)throw new Error(r);return 1===l&&(o="",console.warn("Applying for a public trial license ...")),{lt:l,l:o,ls:a,sp:c,rmk:s,cv:n}}throw new Error("Can't preprocess license again"+is)})(gs),o=new ts;gs._pLoad.task=o,(async()=>{try{await gs._pLoad}catch(e){}})();let a=Re();Ce[a]=t=>{if(t.message&&gs._onAuthMessage){let e=gs._onAuthMessage(t.message);null!=e&&(t.message=e)}let i,s=!1;if(1===e&&(s=!0),t.success?(Te&&Te("init license success"),t.message&&console.warn(t.message),Me._bSupportIRTModule=t.bSupportIRTModule,Me._bSupportDce4Module=t.bSupportDce4Module,gs.bPassValidation=!0,[0,-10076].includes(t.initLicenseInfo.errorCode)?[-10076].includes(t.initLicenseInfo.errorCode)&&console.warn(t.initLicenseInfo.errorString):o.reject(new Error(t.initLicenseInfo.errorString))):(i=Error(t.message),t.stack&&(i.stack=t.stack),t.ltsErrorCode&&(i.ltsErrorCode=t.ltsErrorCode),s||111==t.ltsErrorCode&&-1!=t.message.toLowerCase().indexOf("trial license")&&(s=!0)),s){const e=b(Me.engineResourcePaths),i=("DCV"===Me._bundleEnv?e.dcvData:e.dbrBundle)+"ui/";(async(e,t,i)=>{if(!e._bNeverShowDialog)try{let s=await fetch(e.engineResourcePath+"dls.license.dialog.html");if(!s.ok)throw Error("Get license dialog fail. Network Error: "+s.statusText);let n=await s.text();if(!n.trim().startsWith("<"))throw Error("Get license dialog fail. Can't get valid HTMLElement.");let r=document.createElement("div");r.insertAdjacentHTML("beforeend",n);let o=[];for(let e=0;e<r.childElementCount;++e){let t=r.children[e];t instanceof HTMLStyleElement&&(o.push(t),document.head.append(t))}let a=1==r.childElementCount?r.children[0]:r;a.remove();let c,l,d,u,h,_=[a],m=a.children;for(let e of m)_.push(e);for(let e=0;e<_.length;++e)for(let t of _[e].children)_.push(t);for(let e of _)if(!c&&e.classList.contains("dls-license-mask"))c=e,e.addEventListener("click",t=>{if(e==t.target){a.remove();for(let e of o)e.remove()}});else if(!l&&e.classList.contains("dls-license-icon-close"))l=e,e.addEventListener("click",()=>{a.remove();for(let e of o)e.remove()});else if(!d&&e.classList.contains("dls-license-icon-error"))d=e,"error"!=t&&e.remove();else if(!u&&e.classList.contains("dls-license-icon-warn"))u=e,"warn"!=t&&e.remove();else if(!h&&e.classList.contains("dls-license-msg-content")){h=e;let t=i;for(;t;){let i=t.indexOf("["),s=t.indexOf("]",i),n=t.indexOf("(",s),r=t.indexOf(")",n);if(-1==i||-1==s||-1==n||-1==r){e.appendChild(new Text(t));break}i>0&&e.appendChild(new Text(t.substring(0,i)));let o=document.createElement("a"),a=t.substring(i+1,s);o.innerText=a;let c=t.substring(n+1,r);o.setAttribute("href",c),o.setAttribute("target","_blank"),e.appendChild(o),t=t.substring(r+1)}}document.body.appendChild(a)}catch(t){e._onLog&&e._onLog(t.message||t)}})({_bNeverShowDialog:gs._bNeverShowDialog,engineResourcePath:i,_onLog:Te},t.success?"warn":"error",t.message)}t.success?o.resolve(void 0):o.reject(i)},await Ee("core");const c=await Me.getModuleVersion();Ie.postMessage({type:"license_dynamsoft",body:{v:"DCV"===Me._bundleEnv?c.CVR.replace(/\.\d+$/,""):c.DBR.replace(/\.\d+$/,""),brtk:!!e,bptk:1===e,l:t,os:hs,fn:gs.deviceFriendlyName,ls:i,sp:s,rmk:n,cv:r,_e:gs._e,mliRecord:null===localStorage||void 0===localStorage?void 0:localStorage.getItem("dynamsoft")},id:a}),gs.bCallInitLicense=!0,await o}));let ms;be.license={},be.license.dynamsoft=_s,be.license.getAR=async()=>{{let e=pe.dynamsoft_inited;e&&e.isRejected&&await e}return Ie?new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success){delete i.success;{let e=gs.license;e&&(e.startsWith("t")||e.startsWith("f"))&&(i.pk=e)}if(Object.keys(i).length){if(i.lem){let e=Error(i.lem);e.ltsErrorCode=i.lec,delete i.lem,delete i.lec,i.ae=e}e(i)}else e(null)}else{let e=Error(i.message);i.stack&&(e.stack=i.stack),t(e)}},Ie.postMessage({type:"license_getAR",id:i})}):null};let gs=class e{static setLicenseServer(t){os(e,t)}static get license(){return this._license}static set license(t){ns(e,t)}static get licenseServer(){return this._licenseServer}static set licenseServer(t){os(e,t)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(t){as(e,t)}static initLicense(t,i){if(ns(e,t),e.bCallInitLicense=!0,"boolean"==typeof i&&i||"object"==typeof i&&i.executeNow)return _s()}static setDeviceFriendlyName(t){as(e,t)}static getDeviceFriendlyName(){return e._deviceFriendlyName}static getDeviceUUID(){return(async()=>(await ye("dynamsoft_uuid",async()=>{await Me.loadWasm();let e=new ts,t=Re();Ce[t]=t=>{if(t.success)e.resolve(t.uuid);else{const i=Error(t.message);t.stack&&(i.stack=t.stack),e.reject(i)}},Ie.postMessage({type:"license_getDeviceUUID",id:t}),ms=await e}),ms))()}};gs._pLoad=new ts,gs.bPassValidation=!1,gs.bCallInitLicense=!1,gs._license=ss,gs._licenseServer=[],gs._deviceFriendlyName="",gs._e=!0,Me.engineResourcePaths.license={version:"4.4.30-dev-20260629163040",path:Qi,isInternal:!0},Le.license={wasm:!0,js:!0},be.license.LicenseManager=gs;const fs="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,fs)<0&&(Me.engineResourcePaths.std={version:fs,path:(e=>{if(null==e&&(e="./"),zi||Xi);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e})(Qi+`../../dynamsoft-capture-vision-std@${fs}/dist/`),isInternal:!0});var ps=Object.freeze({__proto__:null,LicenseManager:gs,LicenseModule:class{static getVersion(){return`4.4.30-dev-20260629163040(Worker: ${De.license&&De.license.worker||"Not Loaded"}, Wasm: ${De.license&&De.license.wasm||"Not Loaded"})`}}});const Es=()=>window.matchMedia("(orientation: landscape)").matches,ys=e=>Object.prototype.toString.call(e).slice(8,-1);function Is(e,t){for(const i in t)"Object"===ys(t[i])&&"Object"===ys(e[i])&&i in e?Is(e[i],t[i]):("cameraFeatures"===i&&(t[i]=Array.isArray(t[i])?t[i]:[t[i]]),e[i]=t[i]);return e}function vs(e){var t;const i=null===(t=e.label)||void 0===t?void 0:t.toLowerCase();return!!i&&["front","user","selfie","前置","前摄","自拍","前面","インカメラ","フロント","전면","셀카","фронтальная","передняя","frontal","delantera","selfi","frontal","frente","avant","frontal","caméra frontale","vorder","vorderseite","frontkamera","anteriore","frontale","amamiya","al-amam","مقدمة","أمامية","aage","आगे","फ्रंट","सेल्फी","ด้านหน้า","กล้องหน้า","trước","mặt trước","ön","ön kamera","depan","kamera depan","przednia","přední","voorkant","voorzijde","față","frontală","εμπρός","πρόσθια","קדמית","קדמי","selfcamera","facecam","facetime"].some(e=>i.includes(e))}function Rs(e){if("object"!=typeof e||null===e)return e;let t;if(Array.isArray(e)){t=[];for(let i=0;i<e.length;i++)t[i]=Rs(e[i])}else{t={};for(let i in e)e.hasOwnProperty(i)&&(t[i]=Rs(e[i]))}return t}function Cs(e){if(!e)return!1;const t=e.name.toLowerCase();if(![".jpg",".jpeg",".ico",".gif",".svg",".webp",".png",".bmp"].some(e=>t.endsWith(e)))return!1;return!!e.type.startsWith("image/")}const Ts="undefined"==typeof self,ws="function"==typeof importScripts,Ss=(()=>{if(!ws){if(!Ts&&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"./"}})(),As=e=>{if(null==e&&(e="./"),Ts||ws);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e};Me.engineResourcePaths.dbr={version:"11.4.30-dev-20260629163107",path:Ss,isInternal:!0},Le.dbr={js:!1,wasm:!0,deps:[fe.MN_DYNAMSOFT_LICENSE,fe.MN_DYNAMSOFT_IMAGE_PROCESSING]},be.dbr={};const Ds="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,Ds)<0&&(Me.engineResourcePaths.std={version:Ds,path:As(Ss+`../../dynamsoft-capture-vision-std@${Ds}/dist/`),isInternal:!0});const bs="3.0.10";(!Me.engineResourcePaths.dip||"string"!=typeof Me.engineResourcePaths.dip&&D(Me.engineResourcePaths.dip.version,bs)<0)&&(Me.engineResourcePaths.dip={version:bs,path:As(Ss+`../../dynamsoft-image-processing@${bs}/dist/`),isInternal:!0});const Ls={BF_NULL:BigInt(0),BF_ALL:BigInt("0xFFFFFFFEFFFFFFFF"),BF_DEFAULT:BigInt(4265345023),BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096),BF_CODE_39:BigInt(1),BF_CODE_128:BigInt(2),BF_CODE_93:BigInt(4),BF_CODABAR:BigInt(8),BF_ITF:BigInt(16),BF_EAN_13:BigInt(32),BF_EAN_8:BigInt(64),BF_UPC_A:BigInt(128),BF_UPC_E:BigInt(256),BF_INDUSTRIAL_25:BigInt(512),BF_CODE_39_EXTENDED:BigInt(1024),BF_GS1_DATABAR_OMNIDIRECTIONAL:BigInt(2048),BF_GS1_DATABAR_TRUNCATED:BigInt(4096),BF_GS1_DATABAR_STACKED:BigInt(8192),BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL:BigInt(16384),BF_GS1_DATABAR_EXPANDED:BigInt(32768),BF_GS1_DATABAR_EXPANDED_STACKED:BigInt(65536),BF_GS1_DATABAR_LIMITED:BigInt(131072),BF_PATCHCODE:BigInt(262144),BF_CODE_32:BigInt(16777216),BF_PDF417:BigInt(33554432),BF_QR_CODE:BigInt(67108864),BF_DATAMATRIX:BigInt(134217728),BF_AZTEC:BigInt(268435456),BF_MAXICODE:BigInt(536870912),BF_MICRO_QR:BigInt(1073741824),BF_MICRO_PDF417:BigInt(524288),BF_GS1_COMPOSITE:BigInt(2147483648),BF_MSI_CODE:BigInt(1048576),BF_CODE_11:BigInt(2097152),BF_TWO_DIGIT_ADD_ON:BigInt(4194304),BF_FIVE_DIGIT_ADD_ON:BigInt(8388608),BF_MATRIX_25:BigInt(68719476736),BF_POSTALCODE:BigInt(0x3f0000000000000),BF_NONSTANDARD_BARCODE:BigInt(4294967296),BF_USPSINTELLIGENTMAIL:BigInt(4503599627370496),BF_POSTNET:BigInt(9007199254740992),BF_PLANET:BigInt(0x40000000000000),BF_AUSTRALIANPOST:BigInt(0x80000000000000),BF_RM4SCC:BigInt(72057594037927940),BF_KIX:BigInt(0x200000000000000),BF_DOTCODE:BigInt(8589934592),BF_PHARMACODE_ONE_TRACK:BigInt(17179869184),BF_PHARMACODE_TWO_TRACK:BigInt(34359738368),BF_PHARMACODE:BigInt(51539607552),BF_TELEPEN:BigInt(137438953472),BF_TELEPEN_NUMERIC:BigInt(274877906944)};var Os,Ns,Ms,Bs;!function(e){e[e.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",e[e.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",e[e.EBRT_PARTIAL_RESULT=2]="EBRT_PARTIAL_RESULT"}(Os||(Os={})),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"}(Ns||(Ns={})),function(e){e[e.LM_AUTO=1]="LM_AUTO",e[e.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",e[e.LM_STATISTICS=4]="LM_STATISTICS",e[e.LM_LINES=8]="LM_LINES",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_ONED_FAST_SCAN=256]="LM_ONED_FAST_SCAN",e[e.LM_NEURAL_NETWORK=512]="LM_NEURAL_NETWORK",e[e.LM_REV=-2147483648]="LM_REV",e[e.LM_SKIP=0]="LM_SKIP",e[e.LM_END=-1]="LM_END"}(Ms||(Ms={})),function(e){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",e[e.DM_BASED_ON_LOC_BIN=128]="DM_BASED_ON_LOC_BIN",e[e.DM_SHARPENING_SMOOTHING=256]="DM_SHARPENING_SMOOTHING",e[e.DM_NEURAL_NETWORK=512]="DM_NEURAL_NETWORK",e[e.DM_REV=-2147483648]="DM_REV",e[e.DM_SKIP=0]="DM_SKIP",e[e.DM_END=-1]="DM_END"}(Bs||(Bs={}));var Fs=Object.freeze({__proto__:null,BarcodeReaderModule:class{static getVersion(){const e=De.dbr&&De.dbr.wasm;return`11.4.30-dev-20260629163107(Worker: ${De.dbr&&De.dbr.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}},EnumBarcodeFormat:Ls,get EnumDeblurMode(){return Bs},get EnumExtendedBarcodeResultType(){return Os},get EnumLocalizationMode(){return Ms},get EnumQRCodeErrorCorrectionLevel(){return Ns}});const xs="undefined"==typeof self,Ps="function"==typeof importScripts,ks=(()=>{if(!Ps){if(!xs&&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"./"}})(),Us=e=>{if(null==e&&(e="./"),xs||Ps);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},Vs="undefined"==typeof self,Gs="function"==typeof importScripts,Ws=(()=>{if(!Gs){if(!Vs&&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"./"}})(),js=e=>{if(null==e&&(e="./"),Vs||Gs);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e};Me.engineResourcePaths.utility={version:"2.4.30-dev-20260629163047",path:Ws,isInternal:!0},Le.utility={js:!0,wasm:!0};const Zs="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,Zs)<0&&(Me.engineResourcePaths.std={version:Zs,path:js(Ws+`../../dynamsoft-capture-vision-std@${Zs}/dist/`),isInternal:!0});const Hs="3.0.10";(!Me.engineResourcePaths.dip||"string"!=typeof Me.engineResourcePaths.dip&&D(Me.engineResourcePaths.dip.version,Hs)<0)&&(Me.engineResourcePaths.dip={version:Hs,path:js(Ws+`../../dynamsoft-image-processing@${Hs}/dist/`),isInternal:!0});function qs(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}"function"==typeof SuppressedError&&SuppressedError;const Ys="undefined"==typeof self,$s="function"==typeof importScripts,zs=(()=>{if(!$s){if(!Ys&&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"./"}})(),Ks=e=>{if(null==e&&(e="./"),Ys||$s);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e};Me.engineResourcePaths.dbr={version:"11.0.30-dev-20250522174049",path:zs,isInternal:!0},Le.dbr={js:!1,wasm:!0,deps:[fe.MN_DYNAMSOFT_LICENSE,fe.MN_DYNAMSOFT_IMAGE_PROCESSING]},be.dbr={};const Xs="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,Xs)<0&&(Me.engineResourcePaths.std={version:Xs,path:Ks(zs+`../../dynamsoft-capture-vision-std@${Xs}/dist/`),isInternal:!0});const Qs="3.0.10";(!Me.engineResourcePaths.dip||"string"!=typeof Me.engineResourcePaths.dip&&D(Me.engineResourcePaths.dip.version,Qs)<0)&&(Me.engineResourcePaths.dip={version:Qs,path:Ks(zs+`../../dynamsoft-image-processing@${Qs}/dist/`),isInternal:!0});const Js={BF_NULL:BigInt(0),BF_ALL:BigInt("0xFFFFFFFEFFFFFFFF"),BF_DEFAULT:BigInt(4265345023),BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096),BF_CODE_39:BigInt(1),BF_CODE_128:BigInt(2),BF_CODE_93:BigInt(4),BF_CODABAR:BigInt(8),BF_ITF:BigInt(16),BF_EAN_13:BigInt(32),BF_EAN_8:BigInt(64),BF_UPC_A:BigInt(128),BF_UPC_E:BigInt(256),BF_INDUSTRIAL_25:BigInt(512),BF_CODE_39_EXTENDED:BigInt(1024),BF_GS1_DATABAR_OMNIDIRECTIONAL:BigInt(2048),BF_GS1_DATABAR_TRUNCATED:BigInt(4096),BF_GS1_DATABAR_STACKED:BigInt(8192),BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL:BigInt(16384),BF_GS1_DATABAR_EXPANDED:BigInt(32768),BF_GS1_DATABAR_EXPANDED_STACKED:BigInt(65536),BF_GS1_DATABAR_LIMITED:BigInt(131072),BF_PATCHCODE:BigInt(262144),BF_CODE_32:BigInt(16777216),BF_PDF417:BigInt(33554432),BF_QR_CODE:BigInt(67108864),BF_DATAMATRIX:BigInt(134217728),BF_AZTEC:BigInt(268435456),BF_MAXICODE:BigInt(536870912),BF_MICRO_QR:BigInt(1073741824),BF_MICRO_PDF417:BigInt(524288),BF_GS1_COMPOSITE:BigInt(2147483648),BF_MSI_CODE:BigInt(1048576),BF_CODE_11:BigInt(2097152),BF_TWO_DIGIT_ADD_ON:BigInt(4194304),BF_FIVE_DIGIT_ADD_ON:BigInt(8388608),BF_MATRIX_25:BigInt(68719476736),BF_POSTALCODE:BigInt(0x3f0000000000000),BF_NONSTANDARD_BARCODE:BigInt(4294967296),BF_USPSINTELLIGENTMAIL:BigInt(4503599627370496),BF_POSTNET:BigInt(9007199254740992),BF_PLANET:BigInt(0x40000000000000),BF_AUSTRALIANPOST:BigInt(0x80000000000000),BF_RM4SCC:BigInt(72057594037927940),BF_KIX:BigInt(0x200000000000000),BF_DOTCODE:BigInt(8589934592),BF_PHARMACODE_ONE_TRACK:BigInt(17179869184),BF_PHARMACODE_TWO_TRACK:BigInt(34359738368),BF_PHARMACODE:BigInt(51539607552),BF_TELEPEN:BigInt(137438953472),BF_TELEPEN_NUMERIC:BigInt(274877906944)};var en,tn,sn,nn,rn;(rn=en||(en={}))[rn.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",rn[rn.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",rn[rn.EBRT_PARTIAL_RESULT=2]="EBRT_PARTIAL_RESULT",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"}(tn||(tn={})),function(e){e[e.LM_AUTO=1]="LM_AUTO",e[e.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",e[e.LM_STATISTICS=4]="LM_STATISTICS",e[e.LM_LINES=8]="LM_LINES",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_ONED_FAST_SCAN=256]="LM_ONED_FAST_SCAN",e[e.LM_REV=-2147483648]="LM_REV",e[e.LM_SKIP=0]="LM_SKIP",e[e.LM_END=4294967295]="LM_END"}(sn||(sn={})),function(e){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",e[e.DM_BASED_ON_LOC_BIN=128]="DM_BASED_ON_LOC_BIN",e[e.DM_SHARPENING_SMOOTHING=256]="DM_SHARPENING_SMOOTHING",e[e.DM_NEURAL_NETWORK=512]="DM_NEURAL_NETWORK",e[e.DM_REV=-2147483648]="DM_REV",e[e.DM_SKIP=0]="DM_SKIP",e[e.DM_END=4294967295]="DM_END"}(nn||(nn={}));const on=async(e,t)=>{let i,s=document.createElement("canvas"),n=s.getContext("2d"),r=e;try{if(r instanceof Blob){i=URL.createObjectURL(r);const e=await new Promise((e,t)=>{const s=new Image;s.onload=()=>e(s),s.onerror=t,s.src=i});s.width=e.width,s.height=e.height,n.drawImage(e,0,0),r=n.getImageData(0,0,s.width,s.height)}else s.width=r.width,s.height=r.height,n.putImageData(r,0,0);if("image/bmp"===t){const e=B(r);return new Blob([e],{type:"image/bmp"})}return await new Promise(e=>{s.toBlob(t=>{e(t)},t)})}finally{URL.revokeObjectURL(i)}};function an(e,t){function i(e,t,i){return(t.x-e.x)*(i.y-e.y)-(t.y-e.y)*(i.x-e.x)}let s=!0;for(let n=0;n<e.length;n++){const r=(n+1)%e.length;if(i(e[n],e[r],t)<0){s=!1;break}}return s}function cn(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function ln(e,t){const[i,s]=e,n=i.x,r=i.y,o=s.x,a=s.y,c=t.x,l=t.y,d=(o-n)**2+(a-r)**2;if(0===d)return Math.sqrt((c-n)**2+(l-r)**2);const u=((c-n)*(o-n)+(l-r)*(a-r))/d;if(u<0)return Math.sqrt((c-n)**2+(l-r)**2);if(u>1)return Math.sqrt((c-o)**2+(l-a)**2);{const e=n+u*(o-n),t=r+u*(a-r);return Math.sqrt((c-e)**2+(l-t)**2)}}function dn(e){const t=[];for(let i=0;i<e.length;i++){const s=e[i],n=e[(i+1)%e.length];t.push([s,n])}return t}function un(e){const[t,i]=e;return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}function hn(e,t,i,s){const n=t.x-e.x,r=t.y-e.y,o=s.x-i.x,a=s.y-i.y,c=(-r*(e.x-i.x)+n*(e.y-i.y))/(-o*r+n*a),l=(o*(e.y-i.y)-a*(e.x-i.x))/(-o*r+n*a);return c>=0&&c<=1&&l>=0&&l<=1?{x:e.x+l*n,y:e.y+l*r}:null}function _n(e){let t=0;for(let i=0;i<e.length;i++){const s=(i+1)%e.length;t+=e[i].x*e[s].y,t-=e[s].x*e[i].y}return Math.abs(t/2)}function mn(e,t,i){let s=t.x-e.x,n=t.y-e.y,r=i.x-e.x;return s*(i.y-e.y)-n*r>0}function gn(e,t){for(let i=0;i<4;i++)if(!mn(e.points[i],e.points[(i+1)%4],t))return!1;return!0}function fn(e,t,i,s){const n=e.points,r=t.points;let o=8*i;o=Math.max(o,5);const a=dn(n)[3],c=dn(n)[1],l=dn(r)[3],d=dn(r)[1];let u,h=0;if(u=Math.max(Math.abs(ln(a,t.points[0])),Math.abs(ln(a,t.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(ln(c,t.points[1])),Math.abs(ln(c,t.points[2]))),u>h&&(h=u),u=Math.max(Math.abs(ln(l,e.points[0])),Math.abs(ln(l,e.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(ln(d,e.points[1])),Math.abs(ln(d,e.points[2]))),u>h&&(h=u),h>o)return!1;const _=un(dn(n)[0]),m=un(dn(n)[2]),g=un(dn(r)[0]),f=un(dn(r)[2]),p=cn(_,f),E=cn(g,m),y=p>E,I=Math.min(p,E),v=cn(_,m),R=cn(g,f);let C=12*i;return C=Math.max(C,5),C=Math.min(C,v),C=Math.min(C,R),!!(I<C||an(n,y?g:f)||an(r,y?m:_))&&(y?(s.points[0]=e.points[0],s.points[1]=e.points[1],s.points[2]=t.points[2],s.points[3]=t.points[3]):(s.points[0]=t.points[0],s.points[1]=t.points[1],s.points[2]=e.points[2],s.points[3]=e.points[3]),s.area=_n(s.points),!0)}class pn{constructor(e,t,i,s){this.overlapCount=e,this.verificationCount=t,this.crossVerificationFrame=5,this.location=s.location,this.locationArea=s.location.area,this.locationAngle=s.angle,this.format=s.format,this.text=s.text,this.isOneD=i,this.item=s,this.locationThreshold=5*s.moduleSize,this.strictLimit=Math.max(this.locationThreshold,1),this.strictLimit=Math.min(this.strictLimit,15)}getCenterPoint(e){const t={x:0,y:0};return e.forEach(({x:e,y:i})=>{t.x+=e,t.y+=i}),t.x/=e.length,t.y/=e.length,t}isProbablySameLocationWithOffset(e,t){const i=this.item.location,s=e.location;if(i.area<=0)return!1;if(Math.abs(i.area-s.area)>.4*i.area)return!1;let n=new Array(4).fill(0),r=new Array(4).fill(0),o=0,a=0;for(let e=0;e<4;++e)n[e]=Math.round(100*(s.points[e].x-i.points[e].x))/100,o+=n[e],r[e]=Math.round(100*(s.points[e].y-i.points[e].y))/100,a+=r[e];o/=4,a/=4;for(let e=0;e<4;++e){if(Math.abs(n[e]-o)>this.strictLimit||Math.abs(o)>.8)return!1;if(Math.abs(r[e]-a)>this.strictLimit||Math.abs(a)>.8)return!1}return t.x=o,t.y=a,!0}isLocationOverlap(e,t){if(this.locationArea>t){for(let t=0;t<4;t++)if(gn(this.location,e.points[t]))return!0;const t=this.getCenterPoint(e.points);if(gn(this.location,t))return!0}else{for(let t=0;t<4;t++)if(gn(e,this.location.points[t]))return!0;if(gn(e,this.getCenterPoint(this.location.points)))return!0}return!1}isMatchedLocationWithOffset(e,t={x:0,y:0}){if(this.isOneD){const i=Object.assign({},e.location);for(let e=0;e<4;e++)i.points[e].x-=t.x,i.points[e].y-=t.y;if(!this.isLocationOverlap(i,e.locationArea))return!1;const s=[this.location.points[0],this.location.points[3]],n=[this.location.points[1],this.location.points[2]];for(let e=0;e<4;e++){const t=i.points[e],r=0===e||3===e?s:n;if(Math.abs(ln(r,t))>this.locationThreshold)return!1}}else for(let i=0;i<4;i++){const s=e.location.points[i],n=this.location.points[i];if(!(Math.abs(n.x+t.x-s.x)<this.locationThreshold))return!1;if(Math.abs(n.y+t.y-s.y)>=this.locationThreshold)return!1}return!0}isOverlappedLocationWithOffset(e,t,i=!0){const s=Object.assign({},e.location);for(let e=0;e<4;e++)s.points[e].x-=t.x,s.points[e].y-=t.y;if(!this.isLocationOverlap(s,e.location.area))return!1;if(i){const e=.75;return function(e,t){const i=[];for(let s=0;s<4;s++)for(let n=0;n<4;n++){const r=hn(e[s],e[(s+1)%4],t[n],t[(n+1)%4]);r&&i.push(r)}return e.forEach(e=>{an(t,e)&&i.push(e)}),t.forEach(t=>{an(e,t)&&i.push(t)}),_n(function(e){if(e.length<=1)return e;e.sort((e,t)=>e.x-t.x||e.y-t.y);const t=e.shift();return e.sort((e,i)=>Math.atan2(e.y-t.y,e.x-t.x)-Math.atan2(i.y-t.y,i.x-t.x)),[t,...e]}(i))}([...this.location.points],s.points)>this.locationArea*e}return!0}}var En,yn,In,vn,Rn,Cn;const Tn={barcode:2,text_line:4,detected_quad:8,deskewed_image:16},wn=(e,t)=>"string"==typeof e?t[Tn[e]]:t[e],Sn=(e,t,i)=>{"string"==typeof e?t[Tn[e]]=i:t[e]=i},An=(e,t,i)=>{const s=[{type:ie.CRIT_BARCODE,resultName:"decodedBarcodesResult",itemNames:["barcodeResultItems"]},{type:ie.CRIT_TEXT_LINE,resultName:"recognizedTextLinesResult",itemNames:["textLineResultItems"]}],n=t.items;if(e.isResultCrossVerificationEnabled(i)){for(let e=n.length-1;e>=0;e--)n[e].type!==i||n[e].verified||n.splice(e,1);const e=s.filter(e=>e.type===i)[0];t[e.resultName]&&e.itemNames.forEach(s=>{const n=t[e.resultName][s];t[e.resultName][s]=n.filter(e=>e.type===i&&e.verified)})}if(e.isResultDeduplicationEnabled(i)){for(let e=n.length-1;e>=0;e--)n[e].type===i&&n[e].duplicate&&n.splice(e,1);const e=s.filter(e=>e.type===i)[0];t[e.resultName]&&e.itemNames.forEach(s=>{const n=t[e.resultName][s];t[e.resultName][s]=n.filter(e=>e.type===i&&!e.duplicate)})}t.decodedBarcodesResult&&0===t.decodedBarcodesResult.barcodeResultItems.length&&delete t.decodedBarcodesResult,t.recognizedTextLinesResult&&0===t.recognizedTextLinesResult.textLineResultItems.length&&delete t.recognizedTextLinesResult},Dn=e=>{const t=[];return e&ie.CRIT_BARCODE&&t.push(ie.CRIT_BARCODE),e&ie.CRIT_TEXT_LINE&&t.push(ie.CRIT_TEXT_LINE),e&ie.CRIT_DETECTED_QUAD&&t.push(ie.CRIT_DETECTED_QUAD),e&ie.CRIT_DESKEWED_IMAGE&&t.push(ie.CRIT_DESKEWED_IMAGE),t};class bn{constructor(){this.verificationEnabled={[ie.CRIT_BARCODE]:!1,[ie.CRIT_TEXT_LINE]:!0,[ie.CRIT_DETECTED_QUAD]:!0,[ie.CRIT_DESKEWED_IMAGE]:!1},this.duplicateFilterEnabled={[ie.CRIT_BARCODE]:!1,[ie.CRIT_TEXT_LINE]:!1,[ie.CRIT_DETECTED_QUAD]:!1,[ie.CRIT_DESKEWED_IMAGE]:!1},this.duplicateForgetTime={[ie.CRIT_BARCODE]:3e3,[ie.CRIT_TEXT_LINE]:3e3,[ie.CRIT_DETECTED_QUAD]:3e3,[ie.CRIT_DESKEWED_IMAGE]:3e3},this.crossVerificationCriteria={[ie.CRIT_BARCODE]:{frameWindow:5,minConsistentFrames:2},[ie.CRIT_TEXT_LINE]:{frameWindow:5,minConsistentFrames:2},[ie.CRIT_DETECTED_QUAD]:{frameWindow:6,minConsistentFrames:4},[ie.CRIT_DESKEWED_IMAGE]:{frameWindow:6,minConsistentFrames:4}},En.set(this,new Map),yn.set(this,new Map),In.set(this,new Map),vn.set(this,new Map),Rn.set(this,new Map),Cn.set(this,new Map),this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,this.latestOverlappingEnabled={[ie.CRIT_BARCODE]:!1,[ie.CRIT_TEXT_LINE]:!1,[ie.CRIT_DETECTED_QUAD]:!1,[ie.CRIT_DESKEWED_IMAGE]:!1},this.maxOverlappingFrames={[ie.CRIT_BARCODE]:this.crossVerificationFrames,[ie.CRIT_TEXT_LINE]:this.crossVerificationFrames,[ie.CRIT_DETECTED_QUAD]:this.crossVerificationFrames,[ie.CRIT_DESKEWED_IMAGE]:this.crossVerificationFrames},Object.defineProperties(this,{onOriginalImageResultReceived:{value:e=>{},writable:!1},onDecodedBarcodesReceived:{value:e=>{this.latestOverlappingFilter(e),An(this,e,ie.CRIT_BARCODE)},writable:!1},onRecognizedTextLinesReceived:{value:e=>{An(this,e,ie.CRIT_TEXT_LINE)},writable:!1},onProcessedDocumentResultReceived:{value:e=>{},writable:!1},onParsedResultsReceived:{value:e=>{const t=e.items;for(let e=t.length-1;e>=0;e--)t[e].type===ie.CRIT_PARSED_RESULT&&t[e].isFilter&&t.splice(e,1);e.parsedResult&&(e.parsedResult.parsedResultItems=e.parsedResult.parsedResultItems.filter(e=>!e.isFilter),0===e.parsedResult.parsedResultItems.length&&delete e.parsedResult)},writable:!1}})}_dynamsoft(){qs(this,En,"f").forEach((e,t)=>{Sn(t,this.verificationEnabled,e)}),qs(this,yn,"f").forEach((e,t)=>{Sn(t,this.duplicateFilterEnabled,e)}),qs(this,In,"f").forEach((e,t)=>{Sn(t,this.duplicateForgetTime,e)}),qs(this,vn,"f").forEach((e,t)=>{Sn(t,this.latestOverlappingEnabled,e)}),qs(this,Rn,"f").forEach((e,t)=>{Sn(t,this.maxOverlappingFrames,e)}),qs(this,Cn,"f").forEach((e,t)=>{Sn(t,this.crossVerificationCriteria,e)})}enableResultCrossVerification(e,t=!0){if("number"==typeof e){const i=Dn(e);for(let e of i)qs(this,En,"f").set(e,t)}else qs(this,En,"f").set(e,t)}isResultCrossVerificationEnabled(e){return wn(e,this.verificationEnabled)}enableResultDeduplication(e,t=!0){if(t&&this.enableLatestOverlapping(e,!1),"number"==typeof e){const i=Dn(e);for(let e of i)qs(this,yn,"f").set(e,t)}else qs(this,yn,"f").set(e,t)}isResultDeduplicationEnabled(e){return wn(e,this.duplicateFilterEnabled)}setDuplicateForgetTime(e,t){if(t>18e4&&(t=18e4),t<0&&(t=0),"number"==typeof e){const i=Dn(e);for(let e of i)qs(this,In,"f").set(e,t)}else qs(this,In,"f").set(e,t)}getDuplicateForgetTime(e){return wn(e,this.duplicateForgetTime)}getFilteredResultItemTypes(){let e=0;const t=[ie.CRIT_BARCODE,ie.CRIT_TEXT_LINE,ie.CRIT_DETECTED_QUAD,ie.CRIT_DESKEWED_IMAGE,ie.CRIT_ENHANCED_IMAGE];for(let i=0;i<t.length;i++)(this.verificationEnabled[t[i]]||this.duplicateFilterEnabled[t[i]])&&(e|=t[i]);return e}setResultCrossVerificationCriteria(e,t,i){if(t<i&&(t=i),"number"==typeof e){const s=Dn(e);for(let e of s)qs(this,Cn,"f").set(e,{frameWindow:t,minConsistentFrames:i})}else qs(this,Cn,"f").set(e,{frameWindow:t,minConsistentFrames:i})}getResultCrossVerificationCriteria(e){return wn(e,this.crossVerificationCriteria)}enableLatestOverlapping(e,t=!0){if(t&&this.enableResultDeduplication(e,!1),"number"==typeof e){const i=Dn(e);for(let e of i)qs(this,vn,"f").set(e,t)}else qs(this,vn,"f").set(e,t)}isLatestOverlappingEnabled(e){return wn(e,this.latestOverlappingEnabled)}setMaxOverlappingFrames(e,t){if("number"==typeof e){const i=Dn(e);for(let e of i)qs(this,Rn,"f").set(e,t)}else qs(this,Rn,"f").set(e,t)}getMaxOverlappingFrames(e){return wn(e,this.maxOverlappingFrames)}latestOverlappingFilter(e){var t,i,s;const n=this.isResultCrossVerificationEnabled(ie.CRIT_BARCODE),r=this.isLatestOverlappingEnabled(ie.CRIT_BARCODE);if(r){const o=this.crossVerificationFrames,a=60,c=r?this.getMaxOverlappingFrames(ie.CRIT_BARCODE):this.crossVerificationFrames,l=e.items.length,d=null===(s=null===(i=null===(t=null==e?void 0:e.intermediateResult)||void 0===t?void 0:t[0])||void 0===i?void 0:i.intermediateResultUnits)||void 0===s?void 0:s[1].localizedBarcodes,u=d?d.length:0;let h=[];const _=[],m={x:0,y:0};let g=new Array(l).fill(-1),f=0;const p=e.items.map(e=>{if(1!==e.type){const t=(BigInt(e.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0);return new pn(c,t?1:2,t,e)}}).filter(Boolean);if(this.overlapSet.length>0){const e=new Array(l).fill(new Array(this.overlapSet.length).fill(1));let t=0;for(;t<l;){const i={x:0,y:0},s=new Array(l).fill(-1);let n=!1;for(;t<l;t++){if(!p[t])continue;const r=p[t].item;for(let o=0;o<this.overlapSet.length;o++){if(e[t][o]<1)continue;const a=this.overlapSet[o],c=a.item;if(r.format===c.format&&r.text===c.text){if(n=a.isProbablySameLocationWithOffset(p[t],i),n){s[t]=o,e[t][o]=0;break}}else e[t][o]=0}if(n)break}if(n){for(let n=0;n<l;n++){if(n===t||!p[n])continue;const r=p[n].item;for(let t=0;t<this.overlapSet.length;t++){if(e[n][t]<1)continue;if(s.includes(t))continue;const o=this.overlapSet[t],a=o.item;if(r.format===a.format&&r.text===a.text){if(o.isMatchedLocationWithOffset(p[n],i)){s[n]=t,e[n][t]=0;break}}else e[n][t]=0}}const n=s.filter(e=>-1!==e).length;n>f&&(f=n,g=s,m.x=i.x,m.y=i.y)}}if(0===f){for(let t=0;t<l;t++){const i=p[t].item;for(let s=0;s<this.overlapSet.length;s++){if(e[t][s]<1)continue;if(g.includes(s))continue;const n=this.overlapSet[s],r=n.item;if(i.format===r.format&&i.text===r.text){if(n.isMatchedLocationWithOffset(p[t])){g[t]=s,e[t][s]=0;break}}else e[t][s]=0}}f+=g.filter(e=>-1!=e).length}let i=this.overlapSet.length<=3?f>=1:f>=2;if(!i&&r&&u>0){let e=0;for(let t=0;t<this.overlapSet.length;t++){const i=this.overlapSet[t];for(let t=0;t<u;t++)if(i.isOverlappedLocationWithOffset(d[t],m)){e++;break}}i=this.overlapSet.length<=3?e>=1:e>=3}i||(this.overlapSet=[])}if(0===this.overlapSet.length)this.stabilityCount=0,e.items.forEach((e,t)=>{if(1!==e.type){const i=Object.assign({},e),s=(BigInt(e.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0),r=e.confidence<a,o=new pn(c,s?1:2,s,i);n&&s&&r&&_.push(t),this.overlapSet.push(o)}});else{let t=!0;r?(Math.abs(m.x)>5||Math.abs(m.y)>5)&&(t=!1):t=!1;for(let i=0;i<e.items.length;i++){const e=g[i];if(e<0&&p[i]){const e=p[i].item;let s={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};for(let i=0;i<4;i++)s.points[i].x=t?e.location.points[i].x-m.x:e.location.points[i].x,s.points[i].y=t?e.location.points[i].y-m.y:e.location.points[i].y;for(let n=0;n<this.overlapSet.length;n++){if(g.includes(n))continue;const r=this.overlapSet[n].item.text,o=this.overlapSet[n].item.format;if(e.format===o&&e.text===r){if(this.overlapSet[n].isOverlappedLocationWithOffset(e,m,!1)){const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0),r=s?1:2;this.overlapSet[n]=new pn(c,r,s,t),g[i]=n;break}if(p[i].isOneD){let r={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};for(let e=0;e<4;e++)r.points[e].x=t?this.overlapSet[n].location.points[e].x:this.overlapSet[n].location.points[e].x+m.x,r.points[e].y=t?this.overlapSet[n].location.points[e].y:this.overlapSet[n].location.points[e].y+m.y;let o={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};if(fn(s,r,e.moduleSize,o)){e.location=o;const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0),r=s?1:2;this.overlapSet[n]=new pn(c,r,s,t),g[i]=n;break}}}}}else{if(t)p[i]&&(p[i].item.location=this.overlapSet[e].location);else{const t=Object.assign({},p[i].item),s=(BigInt(t.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0),n=s?1:2;this.overlapSet[e]=new pn(c,n,s,t)}this.overlapSet[e]&&(this.overlapSet[e].overlapCount=c,this.overlapSet[e].verificationCount=2,this.overlapSet[e].crossVerificationFrame=o)}}t?this.stabilityCount<15&&this.stabilityCount++:this.stabilityCount=0;let i=!0;for(let e=0;e<this.overlapSet.length;e++){if(g.includes(e))continue;const s=this.overlapSet[e];s.overlapCount--,s.crossVerificationFrame--;const n=s.overlapCount+this.stabilityCount;if(r&&n>0){for(let e=0;e<l;e++)if(s.isOverlappedLocationWithOffset(p[e],m,!1)){i=!1;break}if(!i)break;const e=s.item;if(!t){for(let e=0;e<4;e++)s.location.points[e].x+=m.x,s.location.points[e].y+=m.y;e.location=s.location}2===s.verificationCount&&h.push(e)}}if(r&&!i){h=[];for(let e=0;e<this.overlapSet.length;e++){if(g.includes(e))continue;const t=this.overlapSet[e];t.overlapCount=0-this.stabilityCount,t.crossVerificationFrame=0,t.verificationCount=0}}for(let e=0;e<l;e++){if(-1!==g[e]||!p[e])continue;const i=p[e].item;if(t){for(let t=0;t<4;t++)p[e].location.points[t].x-=m.x,p[e].location.points[t].y-=m.y;i.location=p[e].location}let s=!1;for(let t of this.overlapSet)if(!(t.crossVerificationFrame<=0&&t.verificationCount<=0)&&(s=t.isLocationOverlap(p[e].location,p[e].locationArea),s))break;if(s){_.push(e);continue}const r=Object.assign({},i),o=(BigInt(i.format)&BigInt(Js.BF_ONED))!=BigInt(0)||(BigInt(i.format)&BigInt(Js.BF_GS1_DATABAR))!=BigInt(0),l=i.confidence<a,d=new pn(c,o?1:2,o,r);n&&o&&l?_.push(e):d.verificationCount=2,this.overlapSet.push(d)}this.overlapSet=this.overlapSet.filter(e=>!(e.overlapCount+this.stabilityCount<=0&&e.crossVerificationFrame<=0))}_.sort((e,t)=>t-e).forEach((t,i)=>{e.items.splice(t,1)}),h.forEach(t=>{e.items.push(Object.assign(Object.assign({},t),{overlapped:!0}))})}}}var Ln,On,Nn,Mn;En=new WeakMap,yn=new WeakMap,In=new WeakMap,vn=new WeakMap,Rn=new WeakMap,Cn=new WeakMap;class Bn{static async readFromFile(e){if("string"==typeof e){if(!A(e))return Promise.reject(new TypeError("The input string is not a valid URL."));{const t=await fetch(e);e=await t.blob()}}return await x(e)}static async saveToFile(e,t,i){if(!e||!t)return null;if("string"!=typeof t)throw new TypeError("FileName must be of type string.");const s=F(e);return L(s,t,i)}static async readFromMemory(e){if(!qs(Bn,Ln,"f",On).has(e))throw new Error("Image data ID does not exist.");return qs(Bn,Ln,"f",On).get(e)}static async saveToMemory(e,t){var i,s,n;const r=await on(e,t),o=await x(r),a=(function(e,t,i,s,n){if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");n?n.value=i:t.set(e,i)}(i=Bn,Ln,(n=qs(i,Ln,"f",Nn),s=n++,n),0,Nn),s);return qs(Bn,Ln,"f",On).set(a,o),a}static async readFromBase64String(e){const t=await(async e=>{let t,i="image/png";if(e.includes("base64,")){const s=e.split(","),n=s[0].match(/:(.*?);/);n&&(i=n[1]),t=atob(s[1])}else t=atob(e);const s=new ArrayBuffer(t.length),n=new Uint8Array(s);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new Blob([n],{type:i})})(e);return await x(t)}static async saveToBase64String(e,t){e instanceof Blob&&(e=await x(e));let i=F(e);const s=await on(i,t);return await(async e=>await new Promise((t,i)=>{const s=new FileReader;s.onload=()=>{t(s.result)},s.onerror=e=>{i(e)},s.readAsDataURL(e)}))(s)}}Ln=Bn,On={value:new Map},Nn={value:0};!function(e){e[e.FT_HIGH_PASS=0]="FT_HIGH_PASS",e[e.FT_SHARPEN=1]="FT_SHARPEN",e[e.FT_SMOOTH=2]="FT_SMOOTH"}(Mn||(Mn={}));var Fn,xn,Pn,kn,Un,Vn,Gn,Wn,jn,Zn,Hn,qn,Yn,$n,zn,Kn,Xn,Qn,Jn,er,tr,ir,sr,nr,rr,or,ar,cr,lr,dr,ur,hr,_r,mr,gr,fr=Object.freeze({__proto__:null,get EnumFilterType(){return Mn},ImageDrawer:class{static async drawOnImage(e,t,i,s=4294901760,n=1,r="test.png",o){if(!e)throw new Error("Invalid image.");if(!t)throw new Error("Invalid drawingItem.");if(!i)throw new Error("Invalid type.");let a;if(e instanceof Blob)a=await x(e);else if("string"==typeof e){let t=await S(e,"blob");a=await x(t)}else C(e)&&(a=e,"bigint"==typeof a.format&&(a.format=Number(a.format)));return await new Promise((e,c)=>{let l=Re();Ce[l]=async t=>{if(t.success)return o&&Bn.saveToFile(t.image,r,o),e(t.image);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,c(e)}},Ie.postMessage({type:"utility_drawOnImage",id:l,body:{dsImage:a,drawingItem:Array.isArray(t)?t:[t],color:s,thickness:n,type:i}})})}},ImageIO:Bn,ImageProcessor:class{static async cropImage(e,t){const{bytes:i,width:s,height:n,stride:r,format:o}=C(e)?e:await x(e);return await new Promise((e,a)=>{let c=Re();Ce[c]=async t=>{if(t.success)return e(t.cropImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,a(e)}},Ie.postMessage({type:"utility_cropImage",id:c,body:{type:"Rect",bytes:i,width:s,height:n,stride:r,format:o,roi:t}})})}static async adjustBrightness(e,t){const{bytes:i,width:s,height:n,stride:r,format:o}=C(e)?e:await x(e);return await new Promise((e,a)=>{let c=Re();Ce[c]=async t=>{if(t.success)return e(t.adjustBrightness);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,a(e)}},Ie.postMessage({type:"utility_adjustBrightness",id:c,body:{bytes:i,width:s,height:n,stride:r,format:o,brightness:t}})})}static async adjustContrast(e,t){const{bytes:i,width:s,height:n,stride:r,format:o}=C(e)?e:await x(e);return await new Promise((e,a)=>{let c=Re();Ce[c]=async t=>{if(t.success)return e(t.adjustContrast);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,a(e)}},Ie.postMessage({type:"utility_adjustContrast",id:c,body:{bytes:i,width:s,height:n,stride:r,format:o,contrast:t}})})}static async filterImage(e,t){if(![0,1,2].includes(t))throw new Error("Invalid filterType.");const{bytes:i,width:s,height:n,stride:r,format:o}=C(e)?e:await x(e);return await new Promise((e,a)=>{let c=Re();Ce[c]=async t=>{if(t.success)return e(t.filterImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,a(e)}},Ie.postMessage({type:"utility_filterImage",id:c,body:{bytes:i,width:s,height:n,stride:r,format:o,filterType:t}})})}static async convertToGray(e,t,i,s){const{bytes:n,width:r,height:o,stride:a,format:c}=C(e)?e:await x(e);return await new Promise((e,l)=>{let d=Re();Ce[d]=async t=>{if(t.success)return e(t.convertToGray);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,l(e)}},Ie.postMessage({type:"utility_convertToGray",id:d,body:{bytes:n,width:r,height:o,stride:a,format:c,R:t,G:i,B:s}})})}static async convertToBinaryGlobal(e,t=-1,i=!1){const{bytes:s,width:n,height:r,stride:o,format:a}=C(e)?e:await x(e);return await new Promise((e,c)=>{let l=Re();Ce[l]=async t=>{if(t.success)return e(t.convertToBinaryGlobal);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,c(e)}},Ie.postMessage({type:"utility_convertToBinaryGlobal",id:l,body:{bytes:s,width:n,height:r,stride:o,format:a,threshold:t,invert:i}})})}static async convertToBinaryLocal(e,t=0,i=10,s=!1){const{bytes:n,width:r,height:o,stride:a,format:c}=C(e)?e:await x(e);return await new Promise((e,l)=>{let d=Re();Ce[d]=async t=>{if(t.success)return e(t.convertToBinaryLocal);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,l(e)}},Ie.postMessage({type:"utility_convertToBinaryLocal",id:d,body:{bytes:n,width:r,height:o,stride:a,format:c,blockSize:t,compensation:i,invert:s}})})}static async cropAndDeskewImage(e,t,i=0,s=0,n=0){const{bytes:r,width:o,height:a,stride:c,format:l}=C(e)?e:await x(e);return await new Promise((e,d)=>{let u=Re();Ce[u]=async t=>{if(t.success)return e(t.cropAndDeskewImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,d(e)}},Ie.postMessage({type:"utility_cropAndDeskewImage",id:u,body:{bytes:r,width:o,height:a,stride:c,format:l,roi:t,dstWidth:i,dstHeight:s,padding:n}})})}},MultiFrameResultCrossFilter:bn,UtilityModule:class{static getVersion(){return`2.4.30-dev-20260629163047(Worker: ${De.utility&&De.utility.worker||"Not Loaded"}, Wasm: ${De.utility&&De.utility.wasm||"Not Loaded"})`}}});class pr{constructor(t){if(Fn.add(this),Un.set(this,void 0),Vn.set(this,!1),Gn.set(this,void 0),Wn.set(this,void 0),jn.set(this,void 0),Zn.set(this,void 0),Hn.set(this,{status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},barcodeResults:[]}),this.config=Rs(Fe),t&&"object"!=typeof t||Array.isArray(t))throw"Invalid config.";Is(this.config,t)}get disposed(){return i(this,Vn,"f")}launch(){return t(this,void 0,void 0,function*(){if(i(this,Vn,"f"))throw new Error("The BarcodeScanner instance has been destroyed.");if(i(pr,xn,"f",Pn)&&!i(pr,xn,"f",Pn).isFulfilled&&!i(pr,xn,"f",Pn).isRejected)throw new Error("Cannot call `launch()` while a previous task is still running.");if(s(pr,xn,new ke,"f",Pn),!gs.getDeviceFriendlyName())try{gs.setDeviceFriendlyName("dbr_rtu")}catch(e){}return i(this,Fn,"m",qn).call(this),i(pr,xn,"f",Pn)})}decode(e,n="ReadBarcodes_Default"){return t(this,void 0,void 0,function*(){yield i(this,Fn,"m",Yn).call(this,!0),i(this,Zn,"f")||s(this,Zn,new bn,"f"),i(this,Zn,"f").enableResultCrossVerification(2,!1),yield this._cvRouter.addResultFilter(i(this,Zn,"f"));const t=new Ut;t.onCapturedResultReceived=()=>{},this._cvRouter.addResultReceiver(t);const r=yield this._cvRouter.capture(e,n);return i(this,Zn,"f").enableResultCrossVerification(2,!0),yield this._cvRouter.addResultFilter(i(this,Zn,"f")),this._cvRouter.removeResultReceiver(t),r})}dispose(){var e,t,n,r,o,a,c;s(this,Vn,!0,"f"),i(pr,xn,"f",Pn)&&i(pr,xn,"f",Pn).isPending&&i(pr,xn,"f",Pn).resolve(i(this,Hn,"f")),null===(e=this._cameraEnhancer)||void 0===e||e.dispose(),null===(t=this._cameraView)||void 0===t||t.dispose(),null===(n=this._cvRouter)||void 0===n||n.dispose(),this._cameraEnhancer=null,this._cameraView=null,this._cvRouter=null,window.removeEventListener("resize",i(this,Un,"f")),null===(r=document.querySelector(".scanner-view-container"))||void 0===r||r.remove(),null===(o=document.querySelector(".result-view-container"))||void 0===o||o.remove(),null===(a=document.querySelector(".barcode-scanner-container"))||void 0===a||a.remove(),null===(c=document.querySelector(".loading-page"))||void 0===c||c.remove()}}function Er(e){delete e.moduleId;const t=JSON.parse(e.jsonString).ResultInfo,i=e.fullCodeString,s=e.fieldNames;e.getFieldValue=e=>"fullcodestring"===e.toLowerCase()?i:yr(t,e,"map"),e.getFieldRawValue=e=>"fullcodestring"===e.toLowerCase()?i:yr(t,e,"raw"),e.getFieldMappingStatus=e=>Ir(t,e),e.getFieldValidationStatus=e=>vr(t,e),e.getAllFieldNames=()=>s,delete e.fieldNames,delete e.fullCodeString}function yr(e,t,i){for(let s of e){if(s.FieldName===t)return"raw"===i&&s.RawValue?s.RawValue:s.Value;if(s.ChildFields&&s.ChildFields.length>0){let e;for(let n of s.ChildFields)e=yr(n,t,i);if(void 0!==e)return e}}}function Ir(e,t){for(let i of e){if(i.FieldName===t)return i.MappingStatus?Number(mr[i.MappingStatus]):mr.MS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let e;for(let s of i.ChildFields)e=Ir(s,t);if(void 0!==e)return e}}return mr.MS_NONE}function vr(e,t){for(let i of e){if(i.FieldName===t&&i.ValidationStatus)return i.ValidationStatus?Number(gr[i.ValidationStatus]):gr.VS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let e;for(let s of i.ChildFields)e=vr(s,t);if(void 0!==e)return e}}return gr.VS_NONE}function Rr(e){if(e.disposed)throw new Error('"CodeParser" instance has been disposed')}xn=pr,Un=new WeakMap,Vn=new WeakMap,Gn=new WeakMap,Wn=new WeakMap,jn=new WeakMap,Zn=new WeakMap,Hn=new WeakMap,Fn=new WeakSet,qn=function(){return t(this,void 0,void 0,function*(){try{if(this.config.onInitPrepare&&this.config.onInitPrepare(),this.disposed)return;if(yield i(this,Fn,"m",Yn).call(this),this.config.onInitReady&&this.config.onInitReady({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed)return;let e=!1;try{if(document.querySelector(".loading-page span").innerText="Accessing Camera...",yield this._cameraEnhancer.open(),vs(this._cameraEnhancer.getSelectedCamera())&&this.config.scannerViewConfig.mirrorFrontCamera&&(this._cameraEnhancer.isMirrored=!0),this.config.onCameraOpen&&this.config.onCameraOpen({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed)return}catch(t){i(this,Fn,"m",ur).call(this,{auto:!1,open:!1,close:!1,notSupport:!1}),document.querySelector(".btn-camera-switch-control").style.display="none";if(document.querySelector(".no-camera-view").style.display="flex",this.config.onCameraOpenFailed&&this.config.onCameraOpenFailed(t),e=!0,this.disposed)return}if(this.config.autoStartCapturing&&!e&&(yield this._cvRouter.startCapturing(i(this,Wn,"f")),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed))return}catch(t){i(this,Hn,"f").status={code:e.EnumResultStatus.RS_FAILED,message:t.message||t},i(pr,xn,"f",Pn).reject(new Error(i(this,Hn,"f").status.message)),this.dispose()}finally{i(this,Fn,"m",hr).call(this,"Loading...",!1)}})},Yn=function(n=!1){return t(this,void 0,void 0,function*(){Me.engineResourcePaths=this.config.engineResourcePaths;const t=b(Me.engineResourcePaths);if(!n){let n=i(pr,xn,"f",kn).get("dceUI");if(n||(n=yield S(t.dbrBundle+"ui/dce.rtu.ui.xml","text"),i(pr,xn,"f",kn).set("dceUI",n)),this.disposed)return;if(this._cameraView=yield Ei.createInstance(n),this.disposed)return;if(this.config.scanMode===e.EnumScanMode.SM_SINGLE||this.config.scannerViewConfig.customHighlightForBarcode){this._cameraView.getDrawingLayer(2).setVisible(!1)}if(this._cameraEnhancer=yield pi.createInstance(this._cameraView),this.disposed)return;if(yield i(this,Fn,"m",zn).call(this),this.disposed)return;this.config.scannerViewConfig.customHighlightForBarcode&&s(this,jn,this._cameraEnhancer.getCameraView().createDrawingLayer(),"f")}if([null,void 0].includes(this.config.license)||(gs._onAuthMessage=e=>e.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&deploymenttype=web)"),yield gs.initLicense(this.config.license,{executeNow:!0})),this.disposed)return;if(this._cvRouter=this._cvRouter||(yield kt.createInstance(!1)),this._cvRouter._s=!0,this.disposed)return;let r=i(pr,xn,"f",kn).get("presetTemplates");if(r||(r=yield S(t.dbrBundle+"templates/DBR-PresetTemplates.json","text"),i(pr,xn,"f",kn).set("presetTemplates",r)),yield this._cvRouter.initSettings(r),yield i(this,Fn,"m",$n).call(this,n),!this.disposed&&!n){if(this._cvRouter.setInput(this._cameraEnhancer),i(this,Fn,"m",sr).call(this),yield i(this,Fn,"m",nr).call(this),this.disposed)return;this._cvRouter.onCaptureError=e=>{i(pr,xn,"f",Pn).reject(new Error(e.message)),this.dispose()},this._cvRouter._dynamsoft=!(this.config.scanMode===e.EnumScanMode.SM_SINGLE)}})},$n=function(n=!1){return t(this,void 0,void 0,function*(){n||(this.config.scanMode===e.EnumScanMode.SM_SINGLE?s(this,Wn,this.config.utilizedTemplateNames.single,"f"):this.config.scanMode===e.EnumScanMode.SM_MULTI_UNIQUE&&s(this,Wn,this.config.utilizedTemplateNames.multi_unique,"f"));let t=this.config.templateFilePath;if(t){let e,s=!1;if(Ht(t)&&(s=t.reloadResource,t=t.path),s?(e=yield S(t,"text"),i(pr,xn,"f",kn).delete("templateFile")):(e=i(pr,xn,"f",kn).get("templateFile"),e||(e=yield S(t,"text"),i(pr,xn,"f",kn).set("templateFile",e))),this.disposed)return;if(yield this._cvRouter.initSettings(e),this.disposed)return}const r=yield this._cvRouter.outputSettings("*",!0);if(this.disposed)return;if(!n&&this.config.scanMode===e.EnumScanMode.SM_SINGLE)for(let e of r.CaptureVisionTemplates)e.OutputOriginalImage=1;let o=this.config.barcodeFormats;if(o){Array.isArray(o)||(o=[o]);const e=(e,t)=>t!==BigInt(0)&&(e&t)===t;for(let t of r.BarcodeReaderTaskSettingOptions){t.BarcodeFormatIds=[];for(let i in Ls)for(let s in o)e(o[s],Ls[i])&&t.BarcodeFormatIds.push(i)}}yield this._cvRouter.initSettings(r),this.disposed})},zn=function(){return t(this,void 0,void 0,function*(){let t,n,r=this.config.uiPath||b(this.config.engineResourcePaths).dbrBundle,o=!1;Ht(r)&&(o=r.reloadResource,r=r.path);let a=r.endsWith("/")?Us(r)+"ui/barcode-scanner.ui.xml":Us(r).slice(0,-1);if(o?(t=yield S(a,"text"),i(pr,xn,"f",kn).delete("dbsUI")):(t=i(pr,xn,"f",kn).get("dbsUI"),t||(t=yield S(a,"text"),i(pr,xn,"f",kn).set("dbsUI",t))),n=(e=>{if(!e.trim().startsWith("<"))throw Error("Unable to get valid HTMLElement.");const t=document.createElement("div");if(t.insertAdjacentHTML("beforeend",e),1===t.childElementCount&&t.firstChild instanceof HTMLTemplateElement)return t.firstChild.content;const i=new DocumentFragment;for(let e of t.children)i.append(e);return i})(t),this.disposed)return;if(n.querySelectorAll("style").forEach(e=>{document.head.appendChild(e.cloneNode(!0))}),this.config.scanMode===e.EnumScanMode.SM_SINGLE){const e=document.createElement("style");e.innerText="\n @keyframes result-option-flash {\n from {transform: translate(-50%, -50%) scale(1);}\n to {transform: translate(-50%, -50%) scale(0.8);}\n }\n ".trim();this._cameraView.getUIElement().shadowRoot.append(e)}s(this,Gn,n.querySelector(".result-item"),"f"),i(this,Fn,"m",Kn).call(this,n),i(this,Fn,"m",Xn).call(this,n),i(this,Fn,"m",Qn).call(this,n),i(this,Fn,"m",Jn).call(this,n),yield i(this,Fn,"m",er).call(this,n),i(this,Fn,"m",dr).call(this,n),i(this,Fn,"m",ir).call(this,n),i(this,Fn,"m",tr).call(this,n)})},Kn=function(e){var t,s,n;const r=e.querySelector(".btn-clear");if(r&&(r.addEventListener("click",()=>{i(this,Hn,"f").barcodeResults=[],i(this,Fn,"m",cr).call(this)}),null===(n=null===(s=null===(t=this.config)||void 0===t?void 0:t.resultViewConfig)||void 0===s?void 0:s.toolbarButtonsConfig)||void 0===n?void 0:n.clear)){const t=this.config.resultViewConfig.toolbarButtonsConfig.clear;r.style.display=t.isHidden?"none":"flex",r.className=t.className,r.innerText=t.label,t.isHidden&&(e.querySelector(".toolbar-btns").style.justifyContent="center")}},Xn=function(e){var t,i,s;const n=e.querySelector(".btn-done");if(n&&(n.addEventListener("click",()=>{const e=document.querySelector(".loading-page");e&&"none"===getComputedStyle(e).display&&this.dispose()}),null===(s=null===(i=null===(t=this.config)||void 0===t?void 0:t.resultViewConfig)||void 0===i?void 0:i.toolbarButtonsConfig)||void 0===s?void 0:s.done)){const t=this.config.resultViewConfig.toolbarButtonsConfig.done;n.style.display=t.isHidden?"none":"flex",n.className=t.className,n.innerText=t.label,t.isHidden&&(e.querySelector(".toolbar-btns").style.justifyContent="center")}},Qn=function(t){var s,n;if(null===(n=null===(s=this.config)||void 0===s?void 0:s.scannerViewConfig)||void 0===n?void 0:n.showCloseButton){const s=t.querySelector(".btn-close");s&&(s.style.display="inline",s.addEventListener("click",()=>{i(this,Hn,"f").barcodeResults=[],i(this,Hn,"f").status={code:e.EnumResultStatus.RS_CANCELLED,message:"Cancelled."},this.dispose()}))}},Jn=function(e){var s;if(null===(s=this.config)||void 0===s?void 0:s.scannerViewConfig.showFlashButton){const s=e.querySelector(".btn-flash-auto"),n=e.querySelector(".btn-flash-open"),r=e.querySelector(".btn-flash-close");s&&(s.style.display="inline",this._cameraEnhancer.addEventListener("opened",()=>t(this,void 0,void 0,function*(){var e;if(!this._cameraEnhancer.currentCamera)return void i(this,Fn,"m",ur).call(this,{auto:!1,open:!1,close:!1,notSupport:!1});const t=this._cameraEnhancer.isSupportTorch;for(this.config.scannerViewConfig.showFlashButton&&(t?i(this,Fn,"m",ur).call(this,{auto:!0,open:!1,close:!1,notSupport:!1}):i(this,Fn,"m",ur).call(this,{auto:!1,open:!1,close:!1,notSupport:!0})),yield new Promise(e=>setTimeout(e,1e3));null===(e=this._cameraEnhancer)||void 0===e?void 0:e._isOpenBeforeHide;)yield new Promise(e=>setTimeout(e,1e3));this.disposed||this._cameraEnhancer.isOpen()&&t&&this._cameraEnhancer.turnAutoTorch()})),s.addEventListener("click",()=>t(this,void 0,void 0,function*(){yield this._cameraEnhancer.turnOnTorch(),s.style.display="none",n.style.display="inline",r.style.display="none"})),n.addEventListener("click",()=>t(this,void 0,void 0,function*(){yield this._cameraEnhancer.turnOffTorch(),s.style.display="none",n.style.display="none",r.style.display="inline"})),r.addEventListener("click",()=>t(this,void 0,void 0,function*(){this._cameraEnhancer.turnAutoTorch(),s.style.display="inline",n.style.display="none",r.style.display="none"})))}},er=function(e){return t(this,void 0,void 0,function*(){let s=this.config.scannerViewConfig.cameraSwitchControl;["toggleFrontBack","listAll","hidden"].includes(s)||(this.config.scannerViewConfig.cameraSwitchControl="hidden");if("hidden"!==this.config.scannerViewConfig.cameraSwitchControl){const s=e.querySelector(".camera-control");if(s){s.style.display="block";const n=yield this._cameraEnhancer.getAllCameras(),r=this.config.scannerViewConfig.cameraSwitchControl,o=e=>{const t=document.createElement("div");return t.label=e.label,t.deviceId=e.deviceId,t._checked=e._checked,t.innerText=e.label?e.label:`Camera ${e.deviceId.substring(0,7)}`,Object.assign(t.style,{height:"40px",backgroundColor:"#2E2E2E",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontSize:"14px",lineHeight:"40px",padding:"0 14px",cursor:"pointer"}),t},a=()=>{if(0===n.length)return null;if("listAll"===r){const s=e.querySelector(".camera-list");for(let e of n){const t=o(e);s.append(t)}window.addEventListener("click",()=>{const e=document.querySelector(".camera-list");e&&(e.style.display="none")});const r=e=>{for(let t of a)t.deviceId===e.deviceId?t.style.color="#FE8E14":t.style.color="#FFFFFF"};s.addEventListener("click",e=>t(this,void 0,void 0,function*(){e.stopPropagation();const t=e.target;i(this,Fn,"m",hr).call(this,"Accessing Camera...",!0),this._cvRouter.stopCapturing(),yield this._cameraEnhancer.selectCamera({deviceId:t.deviceId,label:t.label});const s=this._cameraEnhancer.getSelectedCamera();vs(s)&&this.config.scannerViewConfig.mirrorFrontCamera?this._cameraEnhancer.isMirrored=!0:this._cameraEnhancer.isMirrored=!1,r(s),this.config.onCameraOpen&&this.config.onCameraOpen({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.config.autoStartCapturing&&(yield this._cvRouter.startCapturing(i(this,Wn,"f")),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter})),i(this,Fn,"m",hr).call(this,"Loading...",!1)}));const a=e.querySelectorAll(".camera-list div");return()=>t(this,void 0,void 0,function*(){const e=this._cameraEnhancer.getSelectedCamera();r(e);const t=document.querySelector(".camera-list");"none"===getComputedStyle(t).display?t.style.display="block":t.style.display="none"})}return"toggleFrontBack"===r?()=>t(this,void 0,void 0,function*(){i(this,Fn,"m",hr).call(this,"Accessing Camera...",!0);const e=vs(this._cameraEnhancer.getSelectedCamera());yield this._cameraEnhancer.requestCamera(e?"back":"front");vs(this._cameraEnhancer.getSelectedCamera())?(this.config.scannerViewConfig.mirrorFrontCamera&&(this._cameraEnhancer.isMirrored=!0),this.config.scannerViewConfig.showFlashButton&&i(this,Fn,"m",ur).call(this,{auto:!1,open:!1,close:!1,notSupport:!0})):(this._cameraEnhancer.isMirrored=!1,this.config.scannerViewConfig.showFlashButton&&i(this,Fn,"m",ur).call(this,{auto:!0,open:!1,close:!1,notSupport:!1})),i(this,Fn,"m",hr).call(this,"Loading...",!1)}):void 0},c=a();s.addEventListener("click",e=>t(this,void 0,void 0,function*(){e.stopPropagation(),c&&(yield c())}))}}})},tr=function(t){const n=this._cameraView.getUIElement();this._cameraView.setVideoFit("cover");const r=t.querySelector(".barcode-scanner-container");r.style.display=Es()?"flex":"block",this.config.scanMode===e.EnumScanMode.SM_MULTI_UNIQUE&&!1!==this.config.showResultView?this.config.showResultView=!0:this.config.scanMode===e.EnumScanMode.SM_SINGLE&&(this.config.showResultView=!1);const o=this.config.showResultView;let a;if(this.config.container?(r.style.position="relative",a=this.config.container):a=document.body,"string"==typeof a&&(a=document.querySelector(a),null===a))throw new Error("Failed to get the container");let c=this.config.scannerViewConfig.container;if("string"==typeof c&&(c=document.querySelector(c),null===c))throw new Error("Failed to get the container of the scanner view.");let l=this.config.resultViewConfig.container;if("string"==typeof l&&(l=document.querySelector(l),null===l))throw new Error("Failed to get the container of the result view.");const d=t.querySelector(".scanner-view-container"),u=t.querySelector(".result-view-container"),h=t.querySelector(".loading-page");d.append(h),c&&(d.append(n),c.append(d)),l&&l.append(u),c||l?c&&!l?(this.config.container||(u.style.position="absolute"),l=u,a.append(u)):!c&&l&&(this.config.container||(d.style.position="absolute"),c=d,d.append(n),a.append(d)):(c=d,l=u,o&&(Object.assign(d.style,{width:Es()?"50%":"100%",height:Es()?"100%":"50%"}),Object.assign(u.style,{width:Es()?"50%":"100%",height:Es()?"100%":"50%"})),d.append(n),a.append(r)),document.querySelector(".result-view-container").style.display=o?"block":"none",this.config.showPoweredByDynamsoft||(this._cameraEnhancer.setPowerByMessageVisible(!1),document.querySelector(".no-result-svg").style.display="none"),s(this,Un,()=>{Object.assign(r.style,{display:Es()?"flex":"block"}),!o||this.config.scannerViewConfig.container||this.config.resultViewConfig.container||(Object.assign(c.style,{width:Es()?"50%":"100%",height:Es()?"100%":"50%"}),Object.assign(l.style,{width:Es()?"50%":"100%",height:Es()?"100%":"50%"}))},"f"),window.addEventListener("resize",i(this,Un,"f"))},ir=function(e){e.querySelector(".resume").addEventListener("click",()=>t(this,void 0,void 0,function*(){document.querySelector(".features-group").style.display="flex",document.querySelector(".btn-close").style.display="block",document.querySelector(".resume").style.display="none",this._cameraView.getUIElement().shadowRoot.querySelector(".single-mode-mask").remove(),this._cameraView.getUIElement().shadowRoot.querySelectorAll(".single-barcode-result-option").forEach(e=>e.remove()),yield this._cameraEnhancer.resume(),yield new Promise(e=>{setTimeout(e,100)}),this._cvRouter.startCapturing(i(this,Wn,"f"))}))},sr=function(){const s=new Ut;s.onCapturedResultReceived=s=>t(this,void 0,void 0,function*(){if(i(this,jn,"f")&&i(this,jn,"f").clearDrawingItems(),s.decodedBarcodesResult){if(this.config.scannerViewConfig.customHighlightForBarcode){let e=[];for(let t of s.decodedBarcodesResult.barcodeResultItems)e.push(this.config.scannerViewConfig.customHighlightForBarcode(t));i(this,jn,"f").addDrawingItems(e)}this.config.scanMode===e.EnumScanMode.SM_SINGLE?i(this,Fn,"m",rr).call(this,s):i(this,Fn,"m",or).call(this,s)}}),this._cvRouter.addResultReceiver(s)},nr=function(){return t(this,void 0,void 0,function*(){i(this,Zn,"f")||s(this,Zn,new bn,"f"),i(this,Zn,"f").enableResultCrossVerification(2,!0),i(this,Zn,"f").enableResultDeduplication(2,!0),i(this,Zn,"f").setDuplicateForgetTime(2,this.config.duplicateForgetTime),yield this._cvRouter.addResultFilter(i(this,Zn,"f")),i(this,Zn,"f").isResultCrossVerificationEnabled=()=>!1,i(this,Zn,"f").isResultDeduplicationEnabled=()=>!1})},rr=function(s){const n=this._cameraView.getUIElement().shadowRoot;let r=new Promise(e=>{if(s.decodedBarcodesResult.barcodeResultItems.length>1){i(this,Fn,"m",ar).call(this);let t=[];for(let i of s.decodedBarcodesResult.barcodeResultItems){let s=0,n=0;for(let e=0;e<4;++e){let t=i.location.points[e];s+=t.x,n+=t.y}let r=this._cameraEnhancer.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0}),o=this._cameraEnhancer.videoXY2FixedLT([{x:r.x+s/4,y:r.y+n/4}]),a=document.createElement("div");a.className="single-barcode-result-option",Object.assign(a.style,{position:"fixed",width:"25px",height:"25px",border:"#fff solid 4px",transform:"translate(-50%, -50%)",animation:"1s infinite alternate result-option-flash","box-sizing":"border-box","border-radius":"16px",background:"#080",cursor:"pointer"}),a.style.left=o[0].left+"px",a.style.top=o[0].top+"px",a.addEventListener("click",()=>{e(i)}),t.push(a)}n.append(...t)}else e(s.decodedBarcodesResult.barcodeResultItems[0])});r.then(n=>t(this,void 0,void 0,function*(){const t=s.items.filter(e=>e.type===ie.CRIT_ORIGINAL_IMAGE)[0],r=t.imageData,o={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},originalImageResult:r,barcodeImage:(()=>{const e=O(r),t=n.location.points,i=Math.min(...t.map(e=>e.x)),s=Math.min(...t.map(e=>e.y)),o=Math.max(...t.map(e=>e.x)),a=Math.max(...t.map(e=>e.y)),c=o-i,l=a-s,d=document.createElement("canvas");d.width=c,d.height=l;const u=d.getContext("2d");u.beginPath(),u.moveTo(t[0].x-i,t[0].y-s);for(let e=1;e<t.length;e++)u.lineTo(t[e].x-i,t[e].y-s);u.closePath(),u.clip(),u.drawImage(e,-i,-s);const h=u.getImageData(0,0,d.width,d.height);return{bytes:new Uint8Array(h.data),width:h.width,height:h.height,stride:4*h.width,format:_.IPF_ABGR_8888}})(),barcodeResults:[n]};i(this,Fn,"m",_r).call(this,n),i(pr,xn,"f",Pn).resolve(o),this.dispose()}))},or=function(e){for(let t of e.decodedBarcodesResult.barcodeResultItems){if(!1!==t.duplicate)continue;const e=i(this,Hn,"f").barcodeResults.findIndex(e=>`${e.formatString}_${e.text}`==`${t.formatString}_${t.text}`);-1===e?(t.count=1,i(this,Hn,"f").barcodeResults.unshift(t),i(this,Fn,"m",cr).call(this,t)):(i(this,Hn,"f").barcodeResults[e].count++,i(this,Fn,"m",lr).call(this,e)),this.config.onUniqueBarcodeScanned&&this.config.onUniqueBarcodeScanned(t)}},ar=function(){const e=this._cameraView.getUIElement().shadowRoot;if(e.querySelector(".single-mode-mask"))return;const t=document.createElement("div");t.className="single-mode-mask",Object.assign(t.style,{width:"100%",height:"100%",position:"absolute",top:"0",left:"0",right:"0",bottom:"0",opacity:"0.5","background-color":"#4C4C4C"}),e.append(t),document.querySelector(".features-group").style.display="none",document.querySelector(".btn-close").style.display="none",document.querySelector(".resume").style.display="block",this._cameraEnhancer.pause(),this._cvRouter.stopCapturing()},cr=function(t){if(!this.config.showResultView)return;const s=document.querySelector(".no-result-svg");if(!(this.config.showResultView&&this.config.scanMode!==e.EnumScanMode.SM_SINGLE))return;const n=document.querySelector(".main-list");if(!t)return n.textContent="",void(this.config.showPoweredByDynamsoft&&(s.style.display="inline"));s.style.display="none";const r=(e=>{const t=i(this,Gn,"f").cloneNode(!0);t.querySelector(".format-string").innerText=e.formatString;t.querySelector(".text-string").innerText=e.text.replace(/\n|\r/g,""),t.id=`${e.formatString}_${e.text}`;return t.querySelector(".delete-icon").addEventListener("click",()=>{const t=[...document.querySelectorAll(".main-list .result-item")],s=t.findIndex(t=>t.id===`${e.formatString}_${e.text}`);i(this,Hn,"f").barcodeResults.splice(s,1),t[s].remove(),0===i(this,Hn,"f").barcodeResults.length&&this.config.showPoweredByDynamsoft&&(document.querySelector(".no-result-svg").style.display="inline")}),t})(t);n.insertBefore(r,document.querySelector(".result-item"))},lr=function(e){if(!this.config.showResultView)return;const t=document.querySelectorAll(".main-list .result-item"),i=t[e].querySelector(".result-count");let s=parseInt(i.textContent.replace("x",""));t[e].querySelector(".result-count").textContent="x"+ ++s},dr=function(s){if(this.config.showUploadImageButton){const n=s.querySelector(".btn-upload-image");n.style.display="flex",n.onchange=s=>t(this,void 0,void 0,function*(){const t=s.target.files,n={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},barcodeResults:[]};let r=0;i(this,Fn,"m",hr).call(this,`Capturing... [${r}/${t.length}]`,!0);let o=!1;for(let e=0;e<t.length;e++)if(!Cs(t[e])){o=!0;break}if(o)return i(pr,xn,"f",Pn).reject(new Error("Upload failed: one or more files are in unsupported formats. Please make sure all files are .jpg,.jpeg,.ico,.gif,.svg,.webp,.png,.bmp.")),void this.dispose();for(let s of t)try{this._cvRouter.stopCapturing();const o=yield this.decode(s,this.config.utilizedTemplateNames.image);if(o.decodedBarcodesResult)if(this.config.scanMode===e.EnumScanMode.SM_MULTI_UNIQUE)for(let e of o.decodedBarcodesResult.barcodeResultItems){const t=i(this,Hn,"f").barcodeResults.findIndex(t=>`${t.formatString}_${t.text}`==`${e.formatString}_${e.text}`);-1===t?(e.count=1,i(this,Hn,"f").barcodeResults.unshift(e),i(this,Fn,"m",cr).call(this,e)):(i(this,Hn,"f").barcodeResults[t].count++,i(this,Fn,"m",lr).call(this,t))}else if(o.decodedBarcodesResult.barcodeResultItems)for(let e of o.decodedBarcodesResult.barcodeResultItems){const t=n.barcodeResults.find(t=>`${t.text}_${t.formatString}`==`${e.text}_${e.formatString}`);t?t.count++:(e.count=1,n.barcodeResults.push(e))}i(this,Fn,"m",hr).call(this,`Capturing... [${++r}/${t.length}]`,!0)}catch(t){return n.status={code:e.EnumResultStatus.RS_FAILED,message:t.message||t},i(pr,xn,"f",Pn).reject(new Error(n.status.message)),void this.dispose()}i(this,Fn,"m",hr).call(this,"Loading...",!1),this.config.scanMode===e.EnumScanMode.SM_SINGLE?(i(pr,xn,"f",Pn).resolve(n),this.dispose()):this._cvRouter.startCapturing(i(this,Wn,"f")),s.target.value=""})}},ur=function(e){document.querySelector(".btn-flash-not-support").style.display=e.notSupport?"inline":"none",document.querySelector(".btn-flash-auto").style.display=e.auto?"inline":"none",document.querySelector(".btn-flash-open").style.display=e.open?"inline":"none",document.querySelector(".btn-flash-close").style.display=e.close?"inline":"none"},hr=function(e,t){const i=document.querySelector(".loading-page"),s=document.querySelector(".loading-page span");s&&(s.innerText=e),i&&(i.style.display=t?"flex":"none")},_r=function(e){let t=Re();Ce[t]=()=>{},Ie.postMessage({type:"cvr_cc",id:t,instanceID:this._cvRouter._instanceID,body:{text:e.text,strFormat:e.format.toString(),isDPM:e.isDPM}})},Pn={value:null},kn={value:new Map},function(e){e[e.MS_NONE=0]="MS_NONE",e[e.MS_SUCCEEDED=1]="MS_SUCCEEDED",e[e.MS_FAILED=2]="MS_FAILED"}(mr||(mr={})),function(e){e[e.VS_NONE=0]="VS_NONE",e[e.VS_SUCCEEDED=1]="VS_SUCCEEDED",e[e.VS_FAILED=2]="VS_FAILED"}(gr||(gr={}));const Cr=e=>e&&"object"==typeof e&&"function"==typeof e.then,Tr=(async()=>{})().constructor;class wr extends Tr{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,Cr(e)?t=e:"function"==typeof e&&(t=new Tr(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let t,i;super((e,s)=>{t=e,i=s}),this._s="pending",this.resolve=e=>{this.isPending&&(Cr(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}class Sr{constructor(){this._instanceID=void 0,this.bDestroyed=!1}static async createInstance(){await be.license.dynamsoft(),await Me.loadWasm();const e=new Sr,t=new wr;let i=Re();return Ce[i]=async i=>{if(i.success)e._instanceID=i.instanceID,t.resolve(e);else{const e=Error(i.message);i.stack&&(e.stack=i.stack),t.reject(e)}},Ie.postMessage({type:"dcp_createInstance",id:i}),t}async dispose(){Rr(this);let e=Re();this.bDestroyed=!0,Ce[e]=e=>{if(!e.success){let t=new Error(e.message);throw t.stack=e.stack+"\n"+t.stack,t}},Ie.postMessage({type:"dcp_dispose",id:e,instanceID:this._instanceID})}get disposed(){return this.bDestroyed}async initSettings(e){if(Rr(this),e&&["string","object"].includes(typeof e))return"string"==typeof e?e.trimStart().startsWith("{")||(e=await S(e,"text")):"object"==typeof e&&(e=JSON.stringify(e)),await new Promise((t,i)=>{let s=Re();Ce[s]=async e=>{if(e.success){const s=JSON.parse(e.response);if(0!==s.errorCode){let e=new Error(s.errorString?s.errorString:"Init Settings Failed.");return e.errorCode=s.errorCode,i(e)}return t(s)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},Ie.postMessage({type:"dcp_initSettings",id:s,instanceID:this._instanceID,body:{settings:e}})});console.error("Invalid settings.")}async resetSettings(){return Rr(this),await new Promise((e,t)=>{let i=Re();Ce[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Ie.postMessage({type:"dcp_resetSettings",id:i,instanceID:this._instanceID})})}async parse(e,t=""){if(Rr(this),!e||!(e instanceof Array||e instanceof Uint8Array||"string"==typeof e))throw new Error("`parse` must pass in an Array or Uint8Array or string");return await new Promise((i,s)=>{let n=Re();e instanceof Array&&(e=Uint8Array.from(e)),"string"==typeof e&&(e=Uint8Array.from(function(e){let t=[];for(let i=0;i<e.length;++i)t.push(e.charCodeAt(i));return t}(e))),Ce[n]=async e=>{if(e.success){let t=JSON.parse(e.parseResponse);return t.errorCode?s(new Error(t.errorString)):(Er(t),i(t))}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,s(t)}},Ie.postMessage({type:"dcp_parse",id:n,instanceID:this._instanceID,body:{source:e,taskSettingName:t}})})}}const Ar="undefined"==typeof self,Dr="function"==typeof importScripts,br=(()=>{if(!Dr){if(!Ar&&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"./"}})();Me.engineResourcePaths.dcp={version:"3.4.30-dev-20260629163135",path:br,isInternal:!0},Le.dcp={js:!0,wasm:!0,deps:[fe.MN_DYNAMSOFT_LICENSE]},be.dcp={handleParsedResultItem:Er};const Lr="2.0.0";"string"!=typeof Me.engineResourcePaths.std&&D(Me.engineResourcePaths.std.version,Lr)<0&&(Me.engineResourcePaths.std={version:Lr,path:(e=>{if(null==e&&(e="./"),Ar||Dr);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e})(br+`../../dynamsoft-capture-vision-std@${Lr}/dist/`),isInternal:!0}),Ce[-4]=async e=>{Or.onSpecLoadProgressChanged&&Or.onSpecLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class Or{static getVersion(){const e=De.dcp&&De.dcp.wasm;return`3.4.30-dev-20260629163135(Worker: ${De.dcp&&De.dcp.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}static async loadSpec(e,t){return await Me.loadWasm(),await new Promise((i,s)=>{let n=Re();Ce[n]=async e=>{if(e.success)return i(e.result);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,s(t)}},t&&!t.endsWith("/")&&(t+="/");let r=(e instanceof Array?e:[e]).map(e=>e.replace(/^MRTD.*$/,"MRTD"));r=r.map(e=>e.replace(/\.data$/i,""));let o=b(Me.engineResourcePaths);Ie.postMessage({type:"dcp_appendResourceBuffer",id:n,body:{specificationPath:t||`${"DBR"===Me._bundleEnv?o.dbrBundle:o.dcvData}parser-resources/`,specificationNames:r}})})}}var Nr;!function(e){e.CT_MRTD_TD1_ID="MRTD_TD1_ID",e.CT_MRTD_TD2_ID="MRTD_TD2_ID",e.CT_MRTD_TD2_VISA="MRTD_TD2_VISA",e.CT_MRTD_TD3_PASSPORT="MRTD_TD3_PASSPORT",e.CT_MRTD_TD3_VISA="MRTD_TD3_VISA",e.CT_MRTD_TD2_FRENCH_ID="MRTD_TD2_FRENCH_ID",e.CT_AAMVA_DL_ID="AAMVA_DL_ID",e.CT_AAMVA_DL_ID_WITH_MAG_STRIPE="AAMVA_DL_ID_WITH_MAG_STRIPE",e.CT_SOUTH_AFRICA_DL="SOUTH_AFRICA_DL",e.CT_AADHAAR="AADHAAR",e.CT_VIN="VIN",e.CT_GS1_AI="GS1_AI"}(Nr||(Nr={}));var Mr=Object.freeze({__proto__:null,CodeParser:Sr,CodeParserModule:Or,get EnumCodeType(){return Nr},get EnumMappingStatus(){return mr},get EnumValidationStatus(){return gr}});Me._bundleEnv="DBR",kt._defaultTemplate="ReadSingleBarcode",Me.engineResourcePaths.dbrBundle={version:"11.4.3000",path:ks,isInternal:!0},pi.CoreModule=Me,pi.handleEngineResourcePaths=b,e.BarcodeScanner=pr,e.CVR=Zt,e.Core=Be,e.DBR=Fs,e.DCE=$i,e.DCP=Mr,e.License=ps,e.Utility=fr,e.isPathConfig=Ht});