dynamsoft-barcode-reader-bundle 11.6.2000 → 11.6.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.
- package/LEGAL.txt +1 -1
- package/README.html +16 -16
- package/README.md +16 -16
- package/dist/dbr.bundle.d.ts +1 -1
- package/dist/dbr.bundle.esm.js +2 -2
- package/dist/dbr.bundle.js +2 -2
- package/dist/dbr.bundle.mjs +2 -2
- package/dist/dbr.bundle.worker.js +2 -2
- package/dist/dynamsoft-barcode-reader-bundle-ml-simd-pthread-with-pdf.wasm +0 -0
- package/dist/dynamsoft-barcode-reader-bundle-ml-simd-pthread.wasm +0 -0
- package/dist/dynamsoft-barcode-reader-bundle-ml-simd-with-pdf.wasm +0 -0
- package/dist/dynamsoft-barcode-reader-bundle-ml-simd.wasm +0 -0
- package/dist/dynamsoft-barcode-reader-bundle.wasm +0 -0
- package/package.json +1 -1
- package/samples.url +1 -1
package/dist/dbr.bundle.js
CHANGED
|
@@ -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.6.
|
|
7
|
+
* @version 11.6.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){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function i(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function s(e,i){return e.get(t(e,i))}function n(e,t,s){i(e,t),t.set(e,s)}function o(e,i,s){return e.set(t(e,i),s),s}function r(e,t){i(e,t),t.add(e)}function a(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}var c,l;e.EnumScanMode=void 0,(c=e.EnumScanMode||(e.EnumScanMode={}))[c.SM_SINGLE=0]="SM_SINGLE",c[c.SM_MULTI_UNIQUE=1]="SM_MULTI_UNIQUE",e.EnumResultStatus=void 0,(l=e.EnumResultStatus||(e.EnumResultStatus={}))[l.RS_SUCCESS=0]="RS_SUCCESS",l[l.RS_CANCELLED=1]="RS_CANCELLED",l[l.RS_FAILED=2]="RS_FAILED";const d=e=>e&&"object"==typeof e&&"function"==typeof e.then,u=(async()=>{})().constructor;function h(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 _(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 m,g,p;"function"==typeof SuppressedError&&SuppressedError,function(e){e[e.BOPM_BLOCK=0]="BOPM_BLOCK",e[e.BOPM_UPDATE=1]="BOPM_UPDATE"}(m||(m={})),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"}(g||(g={})),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"}(p||(p={}));const f="undefined"==typeof self,E="function"==typeof importScripts,y=(()=>{if(!E){if(!f&&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"./"}})(),I=e=>{if(null==e&&(e="./"),f||E);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},v=e=>Object.prototype.toString.call(e),R=e=>Array.isArray?Array.isArray(e):"[object Array]"===v(e),C=e=>"number"==typeof e&&!Number.isNaN(e),T=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),w=e=>!(!T(e)||!C(e.width)||e.width<=0||!C(e.height)||e.height<=0||!C(e.stride)||e.stride<=0||!("format"in e)||"tag"in e&&!A(e.tag)),S=e=>!!w(e)&&e.bytes instanceof Uint8Array,A=e=>null===e||!!T(e)&&!!C(e.imageId)&&"type"in e,D=e=>!!T(e)&&!!C(e.x)&&!!C(e.y),b=async(e,t,i)=>await new Promise((s,n)=>{const o=new XMLHttpRequest;o.responseType=t,o.onloadstart=()=>{i&&i.loadstartCallback&&i.loadstartCallback(o)},o.onloadend=async e=>{i&&i.loadendCallback&&i.loadendCallback(o),o.status<200||o.status>=300?n(o.status):s(o.response)},o.onprogress=e=>{i&&i.progressCallback&&i.progressCallback(e,o)},o.open("GET",e,!0),o.send()}),O=e=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(e),L=e=>{const t={};for(let i in e){if("rootDirectory"===i)continue;let s=i,n=e[s],o=n&&"object"==typeof n&&n.path?n.path:n,r=e.rootDirectory;if(r&&!r.endsWith("/")&&(r+="/"),"object"==typeof n&&n.isInternal)r&&(o=e[s].version?`${r}${U[s]}@${e[s].version}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`:`${r}${U[s]}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`);else{const i=/^@engineRootDirectory(\/?)/;if("string"==typeof o&&(o=o.replace(i,r||"")),"object"==typeof o&&"dwt"===s){const n=e[s].resourcesPath,o=e[s].serviceInstallerLocation;t[s]={resourcesPath:n.replace(i,r||""),serviceInstallerLocation:o.replace(i,r||"")};continue}}t[s]=I(o)}return t},N=async(e,t,i)=>await new Promise(async(s,n)=>{try{const n=t.split(".");let o=n[n.length-1];const r=await F(`image/${o}`,e);n.length<=1&&(o="png");const a=new File([r],t,{type:`image/${o}`});if(i){const e=URL.createObjectURL(a),i=document.createElement("a");i.href=e,i.download=t,i.click()}s(a)}catch(e){n()}}),M=e=>{S(e)&&(e=P(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},B=(e,t)=>{S(t)&&(t=P(t));const i=M(t);let s=new Image,n=i.toDataURL(e);return s.src=n,s},F=async(e,t)=>{S(t)&&(t=P(t));const i=M(t);if("image/bmp"===e){const e=i.getContext("2d"),t=x(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)})},x=e=>{const t=e.width,i=e.height,s=e.data,n=4*Math.floor((24*t+31)/32),o=n*i,r=54+o,a=new ArrayBuffer(r),c=new DataView(a);c.setUint16(0,19778,!0),c.setUint32(2,r,!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,o,!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),o=s[n],r=s[n+1],a=s[n+2];c.setUint8(l++,a),c.setUint8(l++,r),c.setUint8(l++,o)}for(let e=0;e<d;e++)c.setUint8(l++,0)}return a},P=e=>{let t,i=e.bytes;if(!(i&&i instanceof Uint8Array))throw Error("Parameter type error");if(Number(e.format)===p.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)===p.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)===p.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)===p.IPF_BINARY_8||Number(e.format)===p.IPF_BINARY_8_INVERTED){const s=i.length,n=e.width,o=e.height,r=e.stride;t=new Uint8ClampedArray(n*o*4);for(let e=0;e<s;e++){let s=i[e],o=e%r,a=Math.floor(e/r);for(let e=0;e<8;e++){let i=o+e,r=4*(a*n+i);if(i>=n)break;t[r]=t[r+1]=t[r+2]=(128&s)/128*255,t[r+3]=255,s<<=1}}}else if(Number(e.format)===p.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)===p.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),p.IPF_BINARY_8_INVERTED;return new ImageData(t,e.width,e.height)},k=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:p.IPF_ABGR_8888}}finally{URL.revokeObjectURL(t)}},U={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 V,G,W,j,Z,H,q,Y;let z,$,K,X,Q,J=class e{get _isFetchingStarted(){return h(this,Z,"f")}constructor(){V.add(this),G.set(this,[]),W.set(this,1),j.set(this,m.BOPM_BLOCK),Z.set(this,!1),H.set(this,void 0),q.set(this,g.CCUT_AUTO)}setErrorListener(e){}addImageToBuffer(e){var t;if(!S(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(h(this,G,"f").length>=h(this,W,"f"))switch(h(this,j,"f")){case m.BOPM_BLOCK:break;case m.BOPM_UPDATE:if(h(this,G,"f").push(e),T(h(this,H,"f"))&&C(h(this,H,"f").imageId)&&1==h(this,H,"f").keepInBuffer)for(;h(this,G,"f").length>h(this,W,"f");){const e=h(this,G,"f").findIndex(e=>{var t;return(null===(t=e.imageTag)||void 0===t?void 0:t.imageId)!==h(this,H,"f").imageId});h(this,G,"f").splice(e,1)}else h(this,G,"f").splice(0,h(this,G,"f").length-h(this,W,"f"))}else h(this,G,"f").push(e)}getImage(){if(0===h(this,G,"f").length)return null;let t;if(h(this,H,"f")&&C(h(this,H,"f").imageId)){const e=h(this,V,"m",Y).call(this,h(this,H,"f").imageId);if(e<0)throw new Error(`Image with id ${h(this,H,"f").imageId} doesn't exist.`);t=h(this,G,"f").slice(e,e+1)[0]}else t=h(this,G,"f").pop();if([p.IPF_RGB_565,p.IPF_RGB_555,p.IPF_RGB_888,p.IPF_ARGB_8888,p.IPF_RGB_161616,p.IPF_ARGB_16161616,p.IPF_ABGR_8888,p.IPF_ABGR_16161616,p.IPF_BGR_888].includes(t.format)){if(h(this,q,"f")===g.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 p.IPF_RGB_565:case p.IPF_RGB_555:case p.IPF_RGB_888:case p.IPF_RGB_161616:i[e]=t.bytes[3*e+2];break;case p.IPF_ARGB_8888:case p.IPF_ARGB_16161616:i[e]=t.bytes[4*e+2];break;case p.IPF_BGR_888:i[e]=t.bytes[3*e];break;case p.IPF_ABGR_8888:case p.IPF_ABGR_16161616:i[e]=t.bytes[4*e]}t.bytes=i,t.stride=t.width,t.format=p.IPF_GRAYSCALED}else if(h(this,q,"f")===g.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 p.IPF_RGB_565:case p.IPF_RGB_555:case p.IPF_RGB_888:case p.IPF_RGB_161616:case p.IPF_BGR_888:i[e]=t.bytes[3*e+1];break;case p.IPF_ARGB_8888:case p.IPF_ARGB_16161616:case p.IPF_ABGR_8888:case p.IPF_ABGR_16161616:i[e]=t.bytes[4*e+1]}t.bytes=i,t.stride=t.width,t.format=p.IPF_GRAYSCALED}else if(h(this,q,"f")===g.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 p.IPF_RGB_565:case p.IPF_RGB_555:case p.IPF_RGB_888:case p.IPF_RGB_161616:i[e]=t.bytes[3*e];break;case p.IPF_ARGB_8888:case p.IPF_ARGB_16161616:i[e]=t.bytes[4*e];break;case p.IPF_BGR_888:i[e]=t.bytes[3*e+2];break;case p.IPF_ABGR_8888:case p.IPF_ABGR_16161616:i[e]=t.bytes[4*e+2]}t.bytes=i,t.stride=t.width,t.format=p.IPF_GRAYSCALED}}else[p.IPF_NV21,p.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=>C(e)))(e))throw new TypeError("Invalid 'imageId'.");if(void 0!==t&&"[object Boolean]"!==v(t))throw new TypeError("Invalid 'keepInBuffer'.");_(this,H,{imageId:e,keepInBuffer:t},"f")}_resetNextReturnedImage(){_(this,H,null,"f")}hasImage(e){return h(this,V,"m",Y).call(this,e)>=0}startFetching(){_(this,Z,!0,"f")}stopFetching(){_(this,Z,!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(_(this,W,e,"f");h(this,G,"f")&&h(this,G,"f").length>e;)h(this,G,"f").shift()}getMaxImageCount(){return h(this,W,"f")}getImageCount(){return h(this,G,"f").length}clearBuffer(){h(this,G,"f").length=0}isBufferEmpty(){return 0===h(this,G,"f").length}setBufferOverflowProtectionMode(e){_(this,j,e,"f")}getBufferOverflowProtectionMode(){return h(this,j,"f")}setColourChannelUsageType(e){_(this,q,e,"f")}getColourChannelUsageType(){return h(this,q,"f")}};G=new WeakMap,W=new WeakMap,j=new WeakMap,Z=new WeakMap,H=new WeakMap,q=new WeakMap,V=new WeakSet,Y=function(e){if("number"!=typeof e)throw new TypeError("Invalid 'imageId'.");return h(this,G,"f").findIndex(t=>{var i;return(null===(i=t.imageTag)||void 0===i?void 0:i.imageId)===e})},"undefined"!=typeof navigator&&(z=navigator,$=z.userAgent,K=z.platform,X=z.mediaDevices),function(){if(!f){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:z.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:K,search:"Win"},Mac:{str:K},Linux:{str:K}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let o=n.str||$,r=n.search||t,a=n.verStr||$,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=o.indexOf(r)){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||$,o=i.search||e;if(-1!=s.indexOf(o)){n=e;break}}"Linux"==n&&-1!=$.indexOf("Windows NT")&&(n="HarmonyOS"),Q={browser:i,version:s,OS:n}}f&&(Q={browser:"ssr",version:0,OS:"ssr"})}();const ee="undefined"!=typeof WebAssembly&&$&&!(/Safari/.test($)&&!/Chrome/.test($)&&/\(.+\s11_2_([2-6]).*\)/.test($)),te=!("undefined"==typeof Worker),ie=!(!X||!X.getUserMedia),se=async()=>{let e=!1;if(ie)try{(await X.getUserMedia({video:!0})).getTracks().forEach(e=>{e.stop()}),e=!0}catch(e){}return e};var ne,oe,re,ae,ce,le,de,ue,he;"Chrome"===Q.browser&&Q.version>66||"Safari"===Q.browser&&Q.version>13||"OPR"===Q.browser&&Q.version>43||"Edge"===Q.browser&&Q.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"}(ne||(ne={})),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"}(oe||(oe={})),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"}(re||(re={})),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"}(ae||(ae={})),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"}(ce||(ce={})),function(e){e[e.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",e[e.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(le||(le={})),function(e){e[e.PDFRM_VECTOR=1]="PDFRM_VECTOR",e[e.PDFRM_RASTER=2]="PDFRM_RASTER",e[e.PDFRM_MULTIMODAL=3]="PDFRM_MULTIMODAL"}(de||(de={})),function(e){e[e.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",e[e.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(ue||(ue={})),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"}(he||(he={}));const _e={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 me,ge,pe,fe,Ee,ye,Ie;!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"}(me||(me={})),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"}(ge||(ge={})),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"}(pe||(pe={})),function(e){e[e.ICDM_NEAR=0]="ICDM_NEAR",e[e.ICDM_FAR=1]="ICDM_FAR"}(fe||(fe={})),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"}(Ee||(Ee={})),function(e){e[e.MU_PIXEL=0]="MU_PIXEL",e[e.MU_PERCENTAGE=1]="MU_PERCENTAGE"}(ye||(ye={})),function(e){e.BASELINE="baseline",e.ML="ml",e.ML_SIMD="ml-simd",e.ML_SIMD_PTHREAD="ml-simd-pthread",e.ML_SIMD_WITH_PDF="ml-simd-with-pdf",e.ML_SIMD_PTHREAD_WITH_PDF="ml-simd-pthread-with-pdf",e.AUTO="auto"}(Ie||(Ie={}));let ve,Re=0;const Ce=()=>Re++,Te={};let we=!1;const Se=e=>{we=e,ve&&ve.postMessage({type:"setBDebug",body:{value:e}})},Ae={},De={},be={core:{version:"4.6.20-dev-20260813111327",path:y,isInternal:!0}},Oe=new class extends u{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,d(e)?t=e:"function"==typeof e&&(t=new u(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&&(d(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};let Le=5;"undefined"!=typeof navigator&&(Le=navigator.hardwareConcurrency?Math.max(navigator.hardwareConcurrency-1,5):5),Te[-3]=async e=>{Ne.onWasmLoadProgressChanged&&Ne.onWasmLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class Ne{static get engineResourcePaths(){return be}static set engineResourcePaths(e){Object.assign(be,e)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _bDebug(){return we}static set _bDebug(e){Se(e)}static get _workerName(){return`${Ne._bundleEnv.toLowerCase()}.bundle.worker.js`}static get wasmLoadOptions(){return Ne._wasmLoadOptions}static set wasmLoadOptions(e){if("number"==typeof e.pthreadPoolSize&&e.pthreadPoolSize<0)throw new Error(`Invalid thread count parameter ${e.pthreadPoolSize}.`);Object.assign(Ne._wasmLoadOptions,e)}static isModuleLoaded(){return!!(null==Oe?void 0:Oe.isFulfilled)}static async loadWasm(){return await(async()=>{Oe.isEmpty&&(Oe.task=async(e,t)=>{const i=L(be),s={engineResourcePaths:i,_bundleEnv:Ne._bundleEnv,wasmLoadOptions:Ne.wasmLoadOptions};let n=i[`${Ne._bundleEnv.toLowerCase()}Bundle`]+Ne._workerName;n.startsWith(location.origin)||(n=await fetch(n).then(e=>e.blob()).then(e=>URL.createObjectURL(e))),ve=new Worker(n),ve.onerror=e=>{const i=new Error(e.message);t(i)},ve.addEventListener("message",e=>{var t;let i=e.data?e.data:e,s=i.type,n=i.id,o=i.body;switch(s){case"log":we&&(null===(t=Ne._onLog)||void 0===t||t.call(Ne,i.message));break;case"warning":console.warn(i.message);break;case"task":try{Te[n]&&(Te[n](o),delete Te[n])}catch(e){throw delete Te[n],e}break;case"event":try{Te[n](o)}catch(e){throw e}break;default:console.log(e)}}),s.bd=we,s.dm=location.origin.startsWith("http")?location.origin:"https://localhost";const o=Re++;Te[o]=i=>{if(i.success)Object.assign(Ae,i.versions),"{}"!==JSON.stringify(i.versions)&&(Ne._versions=i.versions),Ne.loadedWasmType=i.loadedWasmType,e(void 0);else{const e=Error(i.message);i.stack&&(e.stack=i.stack),t(e)}},ve.postMessage({type:"loadWasm",id:o,body:s})}),await Oe})()}static async detectEnvironment(){return await(async()=>({wasm:ee,worker:te,getUserMedia:ie,camera:await se(),browser:Q.browser,version:Q.version,OS:Q.OS}))()}static async getModuleVersion(){return await new Promise((e,t)=>{let i=Ce();Te[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)}},ve.postMessage({type:"getModuleVersion",id:i})})}static getVersion(){return`4.6.20-dev-20260813111327(Worker: ${Ae.core&&Ae.core.worker||"Not Loaded"}, Wasm: ${Ae.core&&Ae.core.wasm||"Not Loaded"})`}static enableLogging(){J._onLog=console.log,Ne._onLog=console.log}static disableLogging(){J._onLog=null,Ne._onLog=null}static async cfd(e){return await new Promise((t,i)=>{let s=Ce();Te[s]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},ve.postMessage({type:"cfd",id:s,body:{count:e}})})}}Ne._bSupportDce4Module=-1,Ne._bSupportIRTModule=-1,Ne._versions=null,Ne._onLog=console.log,Ne._bundleEnv="DCV",Ne._wasmLoadOptions={wasmType:Ie.AUTO,pthreadPoolSize:Le},Ne.loadedWasmType=Ie.ML_SIMD_PTHREAD,Ne.browserInfo=Q;var Me=Object.freeze({__proto__:null,CoreModule:Ne,get EnumBufferOverflowProtectionMode(){return m},get EnumCapturedResultItemType(){return ne},get EnumColourChannelUsageType(){return g},get EnumCornerType(){return oe},get EnumCrossVerificationStatus(){return he},get EnumErrorCode(){return re},get EnumGrayscaleEnhancementMode(){return ae},get EnumGrayscaleTransformationMode(){return ce},get EnumImageCaptureDistanceMode(){return fe},get EnumImageFileFormat(){return pe},get EnumImagePixelFormat(){return p},get EnumImageTagType(){return le},EnumIntermediateResultUnitType:_e,get EnumMeasureUnit(){return ye},get EnumModuleName(){return Ee},get EnumPDFReadingMode(){return de},get EnumRasterDataSource(){return ue},get EnumRegionObjectElementType(){return me},get EnumSectionType(){return ge},get EnumWasmType(){return Ie},ImageSourceAdapter:J,_saveToFile:N,_toBlob:F,_toCanvas:M,_toImage:B,get bDebug(){return we},blobToDsImage:k,checkIsLink:O,compareVersion:(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 o=parseInt(i[e]),r=parseInt(s[e]);return o===r||Number.isNaN(o)&&Number.isNaN(r)?t<n?-1:1:o<r||Number.isNaN(o)&&Number.isInteger(r)?-1:1}return i.length===s.length?0:i.length<s.length?-1:1},createImageData:P,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),o=s.slice(12),r=new TextEncoder,a=await crypto.subtle.importKey("raw",r.encode(t),"PBKDF2",!1,["deriveKey"]),c=await crypto.subtle.deriveKey({name:"PBKDF2",salt:r.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,o);return(new TextDecoder).decode(l)},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"]),o=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:o,tagLength:128},n,i.encode(e)),a=new Uint8Array(o.length+r.byteLength);return a.set(o),a.set(new Uint8Array(r),o.length),btoa(String.fromCharCode.apply(null,a))},encodeBMP:x,getNextTaskID:Ce,handleEngineResourcePaths:L,imagePtrToUint8Array:async e=>await new Promise((t,i)=>{let s=Ce();Te[s]=async e=>{if(e.success)return t(e.u8);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},ve.postMessage({type:"imagePtrToUint8Array",id:s,body:{data:e}})}),innerVersions:Ae,isArc:e=>!(!T(e)||!C(e.x)||!C(e.y)||!C(e.radius)||e.radius<0||!C(e.startAngle)||!C(e.endAngle)),isContour:e=>!!T(e)&&!!R(e.points)&&0!=e.points.length&&!e.points.some(e=>!D(e)),isDSImageData:S,isDSRect:e=>!(!T(e)||!C(e.left)||e.left<0||!C(e.top)||e.top<0||!C(e.right)||e.right<0||!C(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:A,isLineSegment:e=>!(!T(e)||!D(e.startPoint)||!D(e.endPoint)||e.startPoint.x==e.endPoint.x&&e.startPoint.y==e.endPoint.y),isObject:T,isOriginalDsImageData:e=>!(!w(e)||!C(e.bytes.length)&&!C(e.bytes.ptr)),isPoint:D,isPolygon:e=>!!T(e)&&!!R(e.points)&&0!=e.points.length&&!e.points.some(e=>!D(e)),isQuad:e=>!!T(e)&&!!R(e.points)&&0!=e.points.length&&4==e.points.length&&!e.points.some(e=>!D(e)),isRect:e=>!(!T(e)||!C(e.x)||!C(e.y)||!C(e.width)||e.width<0||!C(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])),mapPackageRegister:De,mapTaskCallBack:Te,productNameMap:U,requestResource:b,resolveDsImageData:async e=>await new Promise((t,i)=>{let s=Ce();Te[s]=async e=>{if(e.success)return t(e.result);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},ve.postMessage({type:"resolveDsImageData",id:s,body:{point:e}})}),setBDebug:Se,get worker(){return ve}}),Be={license:"",scanMode:e.EnumScanMode.SM_SINGLE,templateFilePath:void 0,utilizedTemplateNames:{single:"ReadBarcodes_SpeedFirst",multi_unique:"ReadBarcodes_SpeedFirst",image:"ReadBarcodes_ReadRateFirst"},engineResourcePaths:Ne.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 Fe=e=>e&&"object"==typeof e&&"function"==typeof e.then,xe=(async()=>{})().constructor;class Pe extends xe{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,Fe(e)?t=e:"function"==typeof e&&(t=new xe(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&&(Fe(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}var ke,Ue;const Ve=e=>e&&"object"==typeof e&&"function"==typeof e.then,Ge=(async()=>{})().constructor;let We=class extends Ge{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,Ve(e)?t=e:"function"==typeof e&&(t=new Ge(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&&(Ve(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}},je=class{constructor(e){a(this,"_cvr",void 0),this._cvr=e}async getMaxBufferedItems(){return await new Promise((e,t)=>{let i=Ce();Te[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)}},ve.postMessage({type:"cvr_getMaxBufferedItems",id:i,instanceID:this._cvr._instanceID})})}async setMaxBufferedItems(e){return await new Promise((t,i)=>{let s=Ce();Te[s]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},ve.postMessage({type:"cvr_setMaxBufferedItems",id:s,instanceID:this._cvr._instanceID,body:{count:e}})})}async getBufferedCharacterItemSet(){return await new Promise((e,t)=>{let i=Ce();Te[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)}},ve.postMessage({type:"cvr_getBufferedCharacterItemSet",id:i,instanceID:this._cvr._instanceID})})}};const Ze={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},He={onTaskResultsReceived:()=>{},isFilter:!0},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){a(this,"_cvr",void 0),a(this,"_irrRegistryState",JSON.parse(JSON.stringify(Ze))),a(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=Ce();Te[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,s(e)}},ve.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=Ce();Te[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},ve.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=Ce();Te[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},ve.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})})}getOriginalImage(){return this._cvr.provideDsImage}};const ze="undefined"==typeof self,$e="function"==typeof importScripts,Ke=(()=>{if(!$e){if(!ze&&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"./"}})();Ne.engineResourcePaths.cvr={version:"3.6.20-dev-20260813111333",path:Ke,isInternal:!0},De.cvr={};let Xe=class{static getVersion(){return this._version}};function Qe(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}Qe(e.referencedItem,t)}}function Je(e){if(e.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}function et(e){return{type:ne.CRIT_ORIGINAL_IMAGE,referenceItem:null,targetROIDefName:"",taskName:"",imageData:e,toCanvas:()=>M(e),toImage:t=>B(t,e),toBlob:t=>F(t,e)}}function tt(e){let t=!1;const i=[re.EC_UNSUPPORTED_JSON_KEY_WARNING,re.EC_LICENSE_AUTH_QUOTA_EXCEEDED,re.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 it(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 st(e){return Math.abs(e)<1e-6?0:e<0?-1:1}function nt(e,t,i,s){let n=e[0]*(i[1]-t[1])+t[0]*(e[1]-i[1])+i[0]*(t[1]-e[1]),o=e[0]*(s[1]-t[1])+t[0]*(e[1]-s[1])+s[0]*(t[1]-e[1]);return!((n^o)>=0&&0!==n&&0!==o||(n=i[0]*(e[1]-s[1])+s[0]*(i[1]-e[1])+e[0]*(s[1]-i[1]),o=i[0]*(t[1]-s[1])+s[0]*(i[1]-t[1])+t[0]*(s[1]-i[1]),(n^o)>=0&&0!==n&&0!==o))}a(Xe,"_version",`3.6.20-dev-20260813111333(Worker: ${null===(Ue=Ae.cvr)||void 0===Ue?void 0:Ue.worker}, Wasm: loading...`),BigInt(0),BigInt("0xFFFFFFFEFFFFFFFF"),BigInt(4265345023);const ot=BigInt(3147775),rt=(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)),at=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 ct=class{constructor(e){a(this,"cameraEnhancer",void 0),a(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]}),a(this,"isSupportDCEModule",!0),a(this,"consumeTime",void 0),a(this,"onTaskResultsReceived",async e=>{if(!this.isSupportDCEModule)return;let t=this.cameraEnhancer;(4&t._dceEnhancedFeatures||16&t._dceEnhancedFeatures||64&t._dceEnhancedFeatures)&&(0!==Ne.bSupportDce4Module?(this.isSupportDCEModule=!1,console.warn("Warning: The license required for Enhanced Features was not found.")):(!this.consumeTime||Date.now()-this.consumeTime>1e4)&&(Ne.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,o=!1;for(let e of i){if(e.unitType===_e.IRUT_DECODED_BARCODES&&e.decodedBarcodes.length){n=!0;break}e.unitType===_e.IRUT_LOCALIZED_BARCODES&&e.localizedBarcodes.length&&(o=!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)},r=async e=>{await t.setFocus(e)};if(o){s.x,s.y;const o=s.width,a=s.height,c=s.width,l=s.height;let d;{let e,n,o,r,a;{const e=t.video.videoWidth*(1-this._autoZoomParameters.autoZoomDetectionArea)/2,i=t.video.videoWidth*(1+this._autoZoomParameters.autoZoomDetectionArea)/2,s=i,n=e,o=t.video.videoHeight*(1-this._autoZoomParameters.autoZoomDetectionArea)/2,r=o,c=t.video.videoHeight*(1+this._autoZoomParameters.autoZoomDetectionArea)/2;a=[{x:e,y:o},{x:i,y:r},{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 o=0;o<n;o++){const r=e[o],a=e[(o+1)%n];if(it(r,a,{x:t,y:i}))return!0;st(r.y-i)>0!=st(a.y-i)>0&&st(t-(i-r.y)*(r.x-a.x)/(r.y-a.y)-r.x)<0&&(s=!s)}return s}(t,e.x,e.y)},s=(e,t)=>!!(nt([e[0],e[1]],[e[2],e[3]],[t[0].x,t[0].y],[t[1].x,t[1].y])||nt([e[0],e[1]],[e[2],e[3]],[t[1].x,t[1].y],[t[2].x,t[2].y])||nt([e[0],e[1]],[e[2],e[3]],[t[2].x,t[2].y],[t[3].x,t[3].y])||nt([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===_e.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==rt||e.possibleFormats==at);if(e.length||(e=u.filter(e=>e.possibleFormats==ot),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),o=Math.min(t[0].y,t[1].y,t[2].y,t[3].y),r=Math.max(t[0].y,t[1].y,t[2].y,t[3].y),d={points:[{x:e,y:o},{x:n,y:o},{x:n,y:r},{x:e,y:r}],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/o,l=(o-d.points[2].x)/o,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&&r({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),o=Math.min(...i,this._autoZoomParameters.autoZoomInIdealModuleSize/d.result.moduleSize),r=t.getZoomSettings().factor;let a=Math.max(Math.pow(r*o,1/this._autoZoomParameters.autoZoomInMaxTimes),this._autoZoomParameters.autoZoomInMinStep);a=Math.min(a,o);let _=r*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 r({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 r({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&&r({mode:"continuous"}).catch(()=>{})}!(16&t._dceEnhancedFeatures)&&4&t._dceEnhancedFeatures&&(this._autoZoomParameters.autoFocusFrameArray.length=0,r({mode:"continuous"}).catch(()=>{}))}}}),a(this,"isDce",!0),this.cameraEnhancer=e}};var lt,dt;!function(e){e[e.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",e[e.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}(lt||(lt={})),Te[-2]=async e=>{St.onDataLoadProgressChanged&&St.onDataLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};var ut=new WeakMap,ht=new WeakMap,_t=new WeakMap,mt=new WeakMap,gt=new WeakMap,pt=new WeakMap,ft=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 WeakSet;let St=class e{constructor(){r(this,wt),a(this,"maxImageSideLength",["iPhone","Android","HarmonyOS"].includes(Ne.browserInfo.OS)?2048:4096),a(this,"onCaptureError",null),a(this,"provideDsImage",null),a(this,"_instanceID",void 0),a(this,"_loopReadVideoTimeoutId",void 0),a(this,"_isOutputOriginalImage",!1),a(this,"_isOpenDetectVerify",!1),a(this,"_isOpenNormalizeVerify",!1),a(this,"_isOpenBarcodeVerify",!1),a(this,"_isOpenLabelVerify",!1),a(this,"_minImageCaptureInterval",0),a(this,"_averageProcessintTimeArray",[]),a(this,"_averageFetchImageTimeArray",[]),a(this,"_averageTime",999),a(this,"_dynamsoft",!0),a(this,"_enhancedFeaturesIrr",null),a(this,"_templateName",""),a(this,"_isCapturing",!1),a(this,"_s",!1),n(this,ut,null),n(this,ht,null),n(this,_t,null),n(this,mt,null),n(this,gt,null),n(this,pt,new Set),n(this,ft,new Set),n(this,Et,new Set),n(this,yt,500),n(this,It,0),n(this,vt,0),n(this,Rt,0),n(this,Ct,!1),n(this,Tt,!1),a(this,"_singleFrameModeCallbackBind",this._singleFrameModeCallback.bind(this))}get disposed(){return s(Tt,this)}get isCapturing(){return this._isCapturing}static async createInstance(t=!0){if(!De.license)throw Error("The `license` module cannot be found.");return await De.license.dynamsoft(),await Ne.loadWasm(),await new Promise((i,s)=>{const n=new e,r=Ce();Te[r]=async t=>{var r;t.success?(n._instanceID=t.instanceID,null!==(r=e._fr4DisposeCvrWasm)&&void 0!==r&&r.register(n,t.instanceID,n),e._isNoOnnx=t.isNoOnnx,Xe._version=`3.6.20-dev-20260813111333(Worker: ${Ae.cvr.worker}, Wasm: ${t.version})`,o(Ct,n,!0),o(mt,n,n.getIntermediateResultManager()),o(Ct,n,!1),i(n)):tt({message:t.message,rj:s,stack:t.stack,functionName:"createInstance"})},ve.postMessage({type:"cvr_createInstance",id:r,body:{loadPresetTemplates:t}})})}static async appendDLModelBuffer(t,i){return await Ne.loadWasm(),e._isNoOnnx?Promise.reject("Model not supported in the current environment."):await new Promise((e,s)=>{const n=Ce(),o=L(Ne.engineResourcePaths);let r;Te[n]=async t=>{if(t.success){const i=JSON.parse(t.response);if(0!==i.errorCode&&tt({message:i.errorString?i.errorString:"Append Model Buffer Failed.",rj:s,errorCode:i.errorCode,functionName:"appendDLModelBuffer"}))return;return e(i)}tt({message:t.message,rj:s,stack:t.stack,functionName:"appendDLModelBuffer"})},i?(r=new URL(i,location.href).href,r=r.endsWith("/")?r:r+"/"):"DCV"===Ne._bundleEnv?r=o.dcvData+"models/":"DBR"===Ne._bundleEnv&&(r=o.dbrBundle+"models/");let a=Array.isArray(t)?t:[t];a=a.map(e=>e.replace(/\.data$/i,"")),ve.postMessage({type:"cvr_appendDLModelBuffer",id:n,body:{modelNames:a,path:r}})})}static async clearDLModelBuffers(){return await new Promise((e,t)=>{const i=Ce();Te[i]=async i=>{if(i.success)return e();tt({message:i.message,rj:t,stack:i.stack,functionName:"clearDLModelBuffers"})},ve.postMessage({type:"cvr_clearDLModelBuffers",id:i})})}async _singleFrameModeCallback(){const e=s(ut,this)._singleFrameModeResultForDcv;if(!e)return;t(wt,this,At).call(this,e);const i={bytes:new Uint8Array(e.bytes),width:e.width,height:e.height,stride:e.stride,format:e.format,imageTag:e.imageTag},n=await this.capture(i,this._templateName);n.originalImageTag=e.imageTag,s(ut,this)._cameraView._capturedResultReceiver.onCapturedResultReceived(n,{isDetectVerifyOpen:!1,isNormalizeVerifyOpen:!1,isBarcodeVerifyOpen:!1,isLabelVerifyOpen:!1}),t(wt,this,Ot).call(this,n),s(ut,this)._singleFrameModeResultForDcv=null}setInput(e){if(Je(this),!this.isCapturing)if(o(ut,this,e),null!=e&&e.isCameraEnhancer){if(this._enhancedFeaturesIrr)return;this._enhancedFeaturesIrr=new ct(e),s(mt,this).addResultReceiver(this._enhancedFeaturesIrr)}else s(mt,this).removeResultReceiver(this._enhancedFeaturesIrr),this._enhancedFeaturesIrr=null}getInput(){return s(ut,this)}addImageSourceStateListener(e){if(Je(this),"object"!=typeof e)return console.warn("Invalid ISA state listener.");e&&Object.keys(e)&&s(ft,this).add(e)}removeImageSourceStateListener(e){return Je(this),s(ft,this).delete(e)}async addResultReceiver(e){if(Je(this),"object"!=typeof e)throw new Error("Invalid receiver.");e&&Object.keys(e).length&&(s(pt,this).add(e),await this._setCrrRegistry())}async removeResultReceiver(e){Je(this),s(pt,this).delete(e),await this._setCrrRegistry()}async removeAllResultReceivers(){Je(this),s(pt,this).clear(),await this._setCrrRegistry()}async _setCrrRegistry(){const e={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onProcessedDocumentResultReceived:!1,onParsedResultsReceived:!1};for(let t of s(pt,this))t.isDce||(e.onCapturedResultReceived=!!t.onCapturedResultReceived,e.onDecodedBarcodesReceived=!!t.onDecodedBarcodesReceived,e.onRecognizedTextLinesReceived=!!t.onRecognizedTextLinesReceived,e.onProcessedDocumentResultReceived=!!t.onProcessedDocumentResultReceived,e.onParsedResultsReceived=!!t.onParsedResultsReceived);const t=Ce();return await new Promise((i,s)=>{Te[t]=async e=>{e.success?i():tt({message:e.message,rj:s,stack:e.stack,functionName:"addResultReceiver"})},ve.postMessage({type:"cvr_setCrrRegistry",id:t,instanceID:this._instanceID,body:{receiver:JSON.stringify(e)}})})}async addResultFilter(e){if(Je(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.");s(Et,this).add(e),e._dynamsoft(),await this._handleFilterUpdate()}async removeResultFilter(e){Je(this),s(Et,this).delete(e),await this._handleFilterUpdate()}async removeAllResultFilters(){Je(this),s(Et,this).clear(),await this._handleFilterUpdate()}async _handleFilterUpdate(){if(s(mt,this).removeResultReceiver(He),0===s(Et,this).size){this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1;const e={[ne.CRIT_BARCODE]:!1,[ne.CRIT_TEXT_LINE]:!1,[ne.CRIT_DETECTED_QUAD]:!1,[ne.CRIT_DESKEWED_IMAGE]:!1,[ne.CRIT_ENHANCED_IMAGE]:!1},i={[ne.CRIT_BARCODE]:!1,[ne.CRIT_TEXT_LINE]:!1,[ne.CRIT_DETECTED_QUAD]:!1,[ne.CRIT_DESKEWED_IMAGE]:!1,[ne.CRIT_ENHANCED_IMAGE]:!1};return await t(wt,this,Lt).call(this,e),void await t(wt,this,Nt).call(this,i)}for(let e of s(Et,this))this._isOpenBarcodeVerify=e.isResultCrossVerificationEnabled(ne.CRIT_BARCODE),this._isOpenLabelVerify=e.isResultCrossVerificationEnabled(ne.CRIT_TEXT_LINE),this._isOpenDetectVerify=e.isResultCrossVerificationEnabled(ne.CRIT_DETECTED_QUAD),this._isOpenNormalizeVerify=e.isResultCrossVerificationEnabled(ne.CRIT_DESKEWED_IMAGE),e.isLatestOverlappingEnabled(ne.CRIT_BARCODE)&&([...s(mt,this)._intermediateResultReceiverSet.values()].find(e=>e.isFilter)||s(mt,this).addResultReceiver(He)),await t(wt,this,Lt).call(this,e.verificationEnabled),await t(wt,this,Nt).call(this,e.duplicateFilterEnabled),await t(wt,this,Mt).call(this,e.duplicateForgetTime),await t(wt,this,Bt).call(this,e.crossVerificationCriteria)}async startCapturing(t){var i;if(Je(this),this.isCapturing)return;if(!s(ut,this))throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");t||(t=e._defaultTemplate);for(let e of s(Et,this))await this.addResultFilter(e);const n=L(Ne.engineResourcePaths);if(s(_t,this)&&s(_t,this).isPending)return s(_t,this);const r=o(Rt,this,(i=s(Rt,this),++i));return o(_t,this,new We((e,i)=>{if(this.disposed)return;const o=Ce();Te[o]=async n=>{s(_t,this)&&!s(_t,this).isFulfilled&&r===s(Rt,this)&&(n.success?(this._isCapturing=!0,this._templateName=t,void 0!==s(ut,this).singleFrameMode&&"disabled"!==s(ut,this).singleFrameMode?(s(ut,this).on("singleFrameAcquired",this._singleFrameModeCallbackBind),this._singleFrameModeCallback(),e()):(this._isOutputOriginalImage=n.isOutputOriginalImage,this._minImageCaptureInterval=n.minImageCaptureInterval,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(async()=>{if(r===s(Rt,this)&&this.isCapturing){-1!==this._minImageCaptureInterval&&s(ut,this).startFetching();for(let e of s(ft,this))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(lt.ISS_BUFFER_EMPTY);this.barcodeScanLoop(t,r),e()}},0))):tt({message:n.message,rj:i,stack:n.stack,functionName:"startCapturing"}))},ve.postMessage({type:"cvr_startCapturing",id:o,instanceID:this._instanceID,body:{templateName:t,engineResourcePaths:n}})})),await s(_t,this)}stopCapturing(){var e;if(Je(this),!s(ut,this))return;o(Rt,this,(e=s(Rt,this),++e)),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=null,s(ut,this).stopFetching(),this._averageProcessintTimeArray=[],this._isCapturing=!1,this._averageTime=999,o(_t,this,null),s(ut,this).isCameraEnhancer&&s(ut,this).off("singleFrameAcquired",this._singleFrameModeCallbackBind);const t=Ce();ve.postMessage({type:"cvr_stopCapturing",id:t,instanceID:this._instanceID})}async containsTask(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t(JSON.parse(e.tasks));tt({message:e.message,rj:i,stack:e.stack,functionName:"containsTask"})},ve.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(i,n=s(Rt,this)){if(n!==s(Rt,this)||!this.isCapturing)return;if(s(ut,this).isBufferEmpty())if(s(ut,this).hasNextImageToFetch())for(let e of s(ft,this))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(lt.ISS_BUFFER_EMPTY);else for(let e of s(ft,this))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(lt.ISS_EXHAUSTED);const o=s(ut,this).getImage();if(!o)return s(ut,this)._bClosedBecauseOfNotInDOM?void this.stopCapturing():(await new Promise(e=>setTimeout(e,100)),void this.continueLoop(i,n));if(o.imageTag&&Date.now()-o.imageTag.timeStamp>200)return void this.continueLoop(i,n);t(wt,this,At).call(this,o),o._s=!0;const r=Date.now();this._captureInWorker(o,i).then(async a=>{if(n!==s(Rt,this)||!this.isCapturing)return;if(e._onLog&&e._onLog("no js handle time: "+(Date.now()-r)),!this.isCapturing)return void this.continueLoop(i,n);a.originalImageTag=o.imageTag?o.imageTag:null,s(ut,this)._capturedResultReceiver&&s(ut,this)._cameraView._capturedResultReceiver.onCapturedResultReceived(a,{isDetectVerifyOpen:this._isOpenDetectVerify,isNormalizeVerifyOpen:this._isOpenNormalizeVerify,isBarcodeVerifyOpen:this._isOpenBarcodeVerify,isLabelVerifyOpen:this._isOpenLabelVerify});for(let e of s(Et,this)){const t=e;t.onOriginalImageResultReceived(a),t.onDecodedBarcodesReceived(a),t.onRecognizedTextLinesReceived(a),t.onProcessedDocumentResultReceived(a),t.onParsedResultsReceived(a)}t(wt,this,Ot).call(this,a);const c=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()-r),this._averageFetchImageTimeArray.push(o&&o.imageTag?o.imageTag.timeSpent:0),this._averageTime=Math.min(...this._averageProcessintTimeArray)-Math.max(...this._averageFetchImageTimeArray),this._averageTime=this._averageTime>0?this._averageTime:0,e._onLog&&(e._onLog(`minImageCaptureInterval: ${this._minImageCaptureInterval}`),e._onLog(`averageProcessintTimeArray: ${this._averageProcessintTimeArray}`),e._onLog(`averageFetchImageTimeArray: ${this._averageFetchImageTimeArray}`),e._onLog(`averageTime: ${this._averageTime}`))),e._onLog){const t=Date.now()-c;t>10&&e._onLog(`fetch image calculate time: ${t}`)}e._onLog&&e._onLog(`time finish decode: ${Date.now()}`),e._onLog&&e._onLog("main time: "+(Date.now()-r)),e._onLog&&e._onLog("===================================================="),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._minImageCaptureInterval>0&&this._minImageCaptureInterval>=this._averageTime?this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(i,n)},this._minImageCaptureInterval-this._averageTime):this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(i,n)},Math.max(this._minImageCaptureInterval,0))}).catch(e=>{n===s(Rt,this)&&(s(ut,this).stopFetching(),"platform error"!==e.message&&(e.errorCode&&0===e.errorCode&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{s(ut,this).startFetching(),this.barcodeScanLoop(i,n)},Math.max(this._minImageCaptureInterval,1e3))),setTimeout(()=>{if(n===s(Rt,this)){if(!this.onCaptureError)throw e;this.onCaptureError(e)}},0)))})}continueLoop(e,t=s(Rt,this)){t===s(Rt,this)&&this.isCapturing&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(e,t)},0))}async getClarity(e,t,i,s,n){const{bytes:o,width:r,height:a,stride:c,format:l}=e,d=Ce();return new Promise((e,u)=>{Te[d]=async t=>{t.success?e(t.clarity):tt({message:t.message,rj:u,stack:t.stack,functionName:"getClarity"})},ve.postMessage({type:"cvr_getClarity",id:d,instanceID:this._instanceID,body:{bytes:o,width:r,height:a,stride:c,format:l,bitcount:t,wr:i,hr:s,grayThreshold:n}},[o.buffer])})}async capture(t,i){let s;if(Je(this),i||(i=e._defaultTemplate),S(t))s=await this._captureDsimage(t,i);else if("string"==typeof t)s="data:image/"==t.substring(0,11)?await this._captureBase64(t,i):await this._captureUrl(t,i);else if(t instanceof Blob)s=await this._captureBlob(t,i);else if(t instanceof HTMLImageElement)s=await this._captureImage(t,i);else if(t instanceof HTMLCanvasElement)s=await this._captureCanvas(t,i);else{if(!(t instanceof HTMLVideoElement))throw new TypeError("'capture(imageOrFile, templateName)': Type of 'imageOrFile' should be 'DSImageData', 'Url', 'Base64', 'Blob', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement'.");s=await this._captureVideo(t,i)}return s}async captureMultiPages(i,n="",r){Je(this),n||(n=e._defaultTemplate);const a={pages:[],dpi:300};return Object.assign(a,r),await new Promise(async(e,r)=>{let c;if(c="string"==typeof i?await b(i,"blob"):i,"application/pdf"!==c.type)return void r("Unsupported file type. Only PDF are allowed.");const l=await c.arrayBuffer(),d=new Uint8Array(l),u=Ce();Te[u]=i=>{if(i.success){var n;for(let e of i.capturedResults)t(wt,this,Dt).call(this,e);t(wt,this,bt).call(this,i.intermediateResult);const r=Date.now();r-s(It,this)>s(yt,this)&&null!==i.mliRecord&&(null!==(n=localStorage)&&void 0!==n&&n.setItem("dynamsoft",i.mliRecord),o(It,this,r)),e(i.capturedResults)}else tt({message:i.message,rj:r,stack:i.stack,functionName:"captureMultiPages"})},ve.postMessage({type:"cvr_captureMultiPages",id:u,instanceID:this._instanceID,body:{bytes:d,templateName:n,defaultOptions:a}},[d.buffer])})}async _captureDsimage(e,t){return await this._captureInWorker(e,t)}async _captureUrl(e,t){let i=await b(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 t=>await new Promise((i,s)=>{let n=URL.createObjectURL(t),o=new Image;o.src=n,o.onload=()=>{URL.revokeObjectURL(o.dbrObjUrl),i(o)},o.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,n,r=e instanceof HTMLImageElement?e.naturalWidth:e.width,a=e instanceof HTMLImageElement?e.naturalHeight:e.height,c=Math.max(r,a);c>this.maxImageSideLength?(o(vt,this,this.maxImageSideLength/c),i=Math.round(r*s(vt,this)),n=Math.round(a*s(vt,this))):(i=r,n=a),s(ht,this)||o(ht,this,document.createElement("canvas"));const l=s(ht,this);return l.width===i&&l.height===n||(l.width=i,l.height=n),l.ctx2d||(l.ctx2d=l.getContext("2d",{willReadFrequently:!0})),l.ctx2d.drawImage(e,0,0,r,a,0,0,i,n),e.dbrObjUrl&&URL.revokeObjectURL(e.dbrObjUrl),await this._captureCanvas(l,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:p.IPF_ABGR_8888};return await this._captureInWorker(s,t)}async _captureVideo(e,t){if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";let i,n,r=e.videoWidth,a=e.videoHeight,c=Math.max(r,a);c>this.maxImageSideLength?(o(vt,this,this.maxImageSideLength/c),i=Math.round(r*s(vt,this)),n=Math.round(a*s(vt,this))):(i=r,n=a),s(ht,this)||o(ht,this,document.createElement("canvas"));const l=s(ht,this);return l.width===i&&l.height===n||(l.width=i,l.height=n),l.ctx2d||(l.ctx2d=l.getContext("2d",{willReadFrequently:!0})),l.ctx2d.drawImage(e,0,0,r,a,0,0,i,n),await this._captureCanvas(l,t)}async _captureInWorker(i,n){let{bytes:r,width:a,height:c,stride:l,format:d,imageTag:u}=i;const h=Ce();return await new Promise((_,m)=>{this.provideDsImage=i,Te[h]=n=>{if(n.success){const a=Date.now();e._onLog&&(e._onLog(`get result time from worker: ${a}`),e._onLog("worker to main time consume: "+(a-n.workerReturnMsgTime)));try{var r;t(wt,this,Dt).call(this,n.capturedResult,i),i.bytes=n.bytes,n._s||o(vt,this,0),t(wt,this,bt).call(this,n.intermediateResult,u);const e=Date.now();return e-s(It,this)>s(yt,this)&&null!==n.mliRecord&&(null!==(r=localStorage)&&void 0!==r&&r.setItem("dynamsoft",n.mliRecord),o(It,this,e)),_(n.capturedResult)}catch(e){tt({message:e.message,rj:m,stack:e.stack,functionName:"capture"})}}else tt({message:n.message,rj:m,stack:n.stack,functionName:"capture"})},e._onLog&&e._onLog(`send buffer to worker: ${Date.now()}`);const g=i.hasOwnProperty("_s")?i._s:this._s;ve.postMessage({type:"cvr_capture",id:h,instanceID:this._instanceID,body:{bytes:r,width:a,height:c,stride:l,format:d,templateName:n||"",dynamsoft:this._dynamsoft,_s:g}},[r.buffer])})}async initSettings(t){if(Je(this),t&&["string","object"].includes(typeof t))return"string"==typeof t?t.trimStart().startsWith("{")||(t=await b(t,"text")):"object"==typeof t&&(t=JSON.stringify(t)),await new Promise((i,s)=>{const n=Ce();Te[n]=async n=>{if(n.success){const o=JSON.parse(n.response);if(0!==o.errorCode&&tt({message:o.errorString?o.errorString:"Init Settings Failed.",rj:s,errorCode:o.errorCode,functionName:"initSettings"}))return;const r=JSON.parse(t);return this._isOutputOriginalImage=!!r.CaptureVisionTemplates[0].OutputOriginalImage,e._defaultTemplate=r.CaptureVisionTemplates[0].Name,i(o)}tt({message:n.message,rj:s,stack:n.stack,functionName:"initSettings"})},ve.postMessage({type:"cvr_initSettings",id:n,instanceID:this._instanceID,body:{settings:t}})});console.error("Invalid template.")}async outputSettings(e,t){return Je(this),await new Promise((i,s)=>{const n=Ce();Te[n]=async e=>{if(e.success){const t=JSON.parse(e.response);if(0!==t.errorCode&&tt({message:t.errorString,rj:s,errorCode:t.errorCode,functionName:"outputSettings"}))return;return i(JSON.parse(t.data))}tt({message:e.message,rj:s,stack:e.stack,functionName:"outputSettings"})},ve.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),o=new Blob([JSON.stringify(n,null,2,(e,t)=>t instanceof Array?JSON.stringify(t):t,2)],{type:"application/json"});if(i){const e=document.createElement("a");e.href=URL.createObjectURL(o),t.endsWith(".json")&&(t=t.replace(".json","")),e.download=`${t}.json`,e.onclick=()=>{setTimeout(()=>{URL.revokeObjectURL(e.href)},500)},e.click()}return o}async getTemplateNames(){return Je(this),await new Promise((e,t)=>{const i=Ce();Te[i]=async i=>{if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&tt({message:s.errorString,rj:t,errorCode:s.errorCode,functionName:"getTemplateNames"}))return;return e(JSON.parse(s.data))}tt({message:i.message,rj:t,stack:i.stack,functionName:"getTemplateNames"})},ve.postMessage({type:"cvr_getTemplateNames",id:i,instanceID:this._instanceID})})}async getSimplifiedSettings(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success){const s=JSON.parse(e.response);if(0!==s.errorCode&&tt({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 t(n)}tt({message:e.message,rj:i,stack:e.stack,functionName:"getSimplifiedSettings"})},ve.postMessage({type:"cvr_getSimplifiedSettings",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async updateSettings(e,t){return Je(this),await new Promise((i,s)=>{const n=Ce();Te[n]=async e=>{if(e.success){const n=JSON.parse(e.response);if(this._isOutputOriginalImage=t.outputOriginalImage,0!==n.errorCode&&tt({message:n.errorString?n.errorString:"Update Settings Failed.",rj:s,errorCode:n.errorCode,functionName:"updateSettings"}))return;return i(n)}tt({message:e.message,rj:s,stack:e.stack,functionName:"updateSettings"})},ve.postMessage({type:"cvr_updateSettings",id:n,instanceID:this._instanceID,body:{settings:t,templateName:e}})})}async resetSettings(){return Je(this),this.isCapturing?Promise.reject(new Error("resetSettings:-10062:Failed to call the function while capturing in progress.")):await new Promise((e,t)=>{const i=Ce();Te[i]=async i=>{if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&tt({message:s.errorString?s.errorString:"Reset Settings Failed.",rj:t,errorCode:s.errorCode,functionName:"resetSettings"}))return;return e(s)}tt({message:i.message,rj:t,stack:i.stack,functionName:"resetSettings"})},ve.postMessage({type:"cvr_resetSettings",id:i,instanceID:this._instanceID})})}getBufferedItemsManager(){return s(gt,this)||o(gt,this,new je(this)),s(gt,this)}getIntermediateResultManager(){if(Je(this),!s(Ct,this)&&0!==Ne.bSupportIRTModule)throw new Error("The current license does not support the use of intermediate results.");return s(mt,this)||o(mt,this,new Ye(this)),s(mt,this)}static async setGlobalIntraOpNumThreads(e=0){return e>4||e<0?Promise.reject(new RangeError("'intraOpNumThreads' should be between 0 and 4.")):(await Ne.loadWasm(),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t();tt({message:e.message,rj:i,stack:e.stack,functionName:"setGlobalIntraOpNumThreads"})},ve.postMessage({type:"cvr_setGlobalIntraOpNumThreads",id:s,body:{intraOpNumThreads:e}})}))}async checkTemplateNameValidity(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>e.success?t(e.isValid):t(!1),ve.postMessage({type:"cvr_checkTemplateNameValidity",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async parseRequiredResources(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t(JSON.parse(e.resources));tt({message:e.message,rj:i,stack:e.stack,functionName:"parseRequiredResources"})},ve.postMessage({type:"cvr_parseRequiredResources",id:s,instanceID:this._instanceID,body:{templateName:e}})})}static disposeCvrWasm(t){e._onLog&&e._onLog(`disposeCvrWasm: ${t}`);const i=Ce();Te[i]=e=>{e.success||tt({message:e.message,stack:e.stack,isShouldThrow:!0,functionName:"dispose"})},ve.postMessage({type:"cvr_dispose",id:i,instanceID:t})}dispose(){var t;Je(this),e._onLog&&e._onLog("dispose"),s(_t,this)&&this.stopCapturing(),o(ut,this,null),s(pt,this).clear(),s(ft,this).clear(),s(Et,this).clear(),s(mt,this)._intermediateResultReceiverSet.clear(),o(Tt,this,!0),e.disposeCvrWasm(this._instanceID),null===(t=e._fr4DisposeCvrWasm)||void 0===t||t.unregister(this)}_getInternalData(){return{isa:s(ut,this),promiseStartScan:s(_t,this),intermediateResultManager:s(mt,this),bufferdItemsManager:s(gt,this),resultReceiverSet:s(pt,this),isaStateListenerSet:s(ft,this),resultFilterSet:s(Et,this),compressRate:s(vt,this),canvas:s(ht,this),innerUseTag:s(Ct,this),isDestroyed:s(Tt,this)}}async _getWasmFilterState(){return await new Promise((e,t)=>{const i=Ce();Te[i]=async i=>{if(i.success){const t=JSON.parse(i.response);return e(t)}tt({message:i.message,rj:t,stack:i.stack,functionName:""})},ve.postMessage({type:"cvr_getWasmFilterState",id:i,instanceID:this._instanceID})})}};function At(e){for(let t of s(pt,this))this._isOutputOriginalImage&&t.onOriginalImageResultReceived&&t.onOriginalImageResultReceived(et(e))}function Dt(e,t){var i,n,o,r,a,c,l,d,u,h,_,m;for(let g=0;g<e.items.length;g++){const p=e.items[g];switch(0!==s(vt,this)&&Qe(p,s(vt,this)),p.type){case ne.CRIT_ORIGINAL_IMAGE:t&&(e.items[g]=et(t));break;case ne.CRIT_BARCODE:null!==(n=(i=e.decodedBarcodesResult).barcodeResultItems)&&void 0!==n||(i.barcodeResultItems=[]),e.decodedBarcodesResult.barcodeResultItems.push(p);break;case ne.CRIT_TEXT_LINE:null!==(r=(o=e.recognizedTextLinesResult).textLineResultItems)&&void 0!==r||(o.textLineResultItems=[]),e.recognizedTextLinesResult.textLineResultItems.push(p);break;case ne.CRIT_DETECTED_QUAD:null!==(c=(a=e.processedDocumentResult).detectedQuadResultItems)&&void 0!==c||(a.detectedQuadResultItems=[]),e.processedDocumentResult.detectedQuadResultItems.push(p);break;case ne.CRIT_DESKEWED_IMAGE:De.ddn&&De.ddn.handleDeskewedAndEnhancedImageResultItem(p),null!==(d=(l=e.processedDocumentResult).deskewedImageResultItems)&&void 0!==d||(l.deskewedImageResultItems=[]),e.processedDocumentResult.deskewedImageResultItems.push(p);break;case ne.CRIT_ENHANCED_IMAGE:De.ddn&&De.ddn.handleDeskewedAndEnhancedImageResultItem(p),null!==(h=(u=e.processedDocumentResult).enhancedImageResultItems)&&void 0!==h||(u.enhancedImageResultItems=[]),e.processedDocumentResult.enhancedImageResultItems.push(p);break;case ne.CRIT_PARSED_RESULT:De.dcp&&De.dcp.handleParsedResultItem(p),null!==(m=(_=e.parsedResult).parsedResultItems)&&void 0!==m||(_.parsedResultItems=[]),e.parsedResult.parsedResultItems.push(p)}}}function bt(e,t){const i=e;if(i){let e=0;for(let n of s(mt,this)._intermediateResultReceiverSet){e++;for(let o of i){if(["onTaskResultsReceived","onTargetROIResultsReceived"].includes(o.info.callbackName)){for(let e of o.intermediateResultUnits)e.originalImageTag=t||null;n[o.info.callbackName]&&n[o.info.callbackName]({intermediateResultUnits:o.intermediateResultUnits},o.info)}else n[o.info.callbackName]&&n[o.info.callbackName](o.result,o.info);e===s(mt,this)._intermediateResultReceiverSet.size&&delete o.info.callbackName}}}}function Ot(e){for(let t of s(pt,this))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)}async function Lt(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t(e.result);tt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},ve.postMessage({type:"cvr_enableResultCrossVerification",id:s,instanceID:this._instanceID,body:{verificationEnabled:e}})})}async function Nt(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t(e.result);tt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},ve.postMessage({type:"cvr_enableResultDeduplication",id:s,instanceID:this._instanceID,body:{duplicateFilterEnabled:e}})})}async function Mt(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t(e.result);tt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},ve.postMessage({type:"cvr_setDuplicateForgetTime",id:s,instanceID:this._instanceID,body:{duplicateForgetTime:e}})})}async function Bt(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t();tt({message:e.message,rj:i,stack:e.stack,functionName:"setResultCrossVerificationCriteria"})},ve.postMessage({type:"cvr_setResultCrossVerificationCriteria",id:s,instanceID:this._instanceID,body:{criteria:e}})})}ke=St,a(St,"_onLog",void 0),a(St,"_defaultTemplate","Default"),a(St,"_isNoOnnx",!1),a(St,"onDataLoadProgressChanged",void 0),a(St,"_fr4DisposeCvrWasm","undefined"!=typeof FinalizationRegistry?new FinalizationRegistry(ke.disposeCvrWasm):null);let Ft=class{constructor(){a(this,"onCapturedResultReceived",null),a(this,"onOriginalImageResultReceived",null),a(this,"onDecodedBarcodesReceived",void 0),a(this,"onRecognizedTextLinesReceived",void 0),a(this,"onProcessedDocumentResultReceived",void 0),a(this,"onParsedResultsReceived",void 0)}};!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"}(dt||(dt={}));var xt,Pt,kt,Ut=Object.freeze({__proto__:null,CaptureVisionRouter:St,CaptureVisionRouterModule:Xe,CapturedResultReceiver:Ft,get EnumImageSourceState(){return lt},get EnumPresetTemplate(){return dt},IntermediateResultReceiver:class{constructor(){a(this,"_observedResultUnitTypes",_e.IRUT_ALL),a(this,"_observedTaskMap",new Map),a(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)}),a(this,"onTaskResultsReceived",null),a(this,"onPredetectedRegionsReceived",null),a(this,"onTargetROIResultsReceived",void 0),a(this,"onColourImageUnitReceived",null),a(this,"onScaledColourImageUnitReceived",null),a(this,"onGrayscaleImageUnitReceived",null),a(this,"onTransformedGrayscaleImageUnitReceived",null),a(this,"onEnhancedGrayscaleImageUnitReceived",null),a(this,"onBinaryImageUnitReceived",null),a(this,"onTextureDetectionResultUnitReceived",null),a(this,"onTextureRemovedGrayscaleImageUnitReceived",null),a(this,"onTextureRemovedBinaryImageUnitReceived",null),a(this,"onContoursUnitReceived",null),a(this,"onLineSegmentsUnitReceived",null),a(this,"onTextZonesUnitReceived",null),a(this,"onTextRemovedBinaryImageUnitReceived",null),a(this,"onShortLinesUnitReceived",null),a(this,"onCandidateBarcodeZonesUnitReceived",void 0),a(this,"onComplementedBarcodeImageUnitReceived",void 0),a(this,"onDecodedBarcodesReceived",void 0),a(this,"onDeformationResistedBarcodeImageUnitReceived",void 0),a(this,"onLocalizedBarcodesReceived",void 0),a(this,"onScaledBarcodeImageUnitReceived",void 0),a(this,"onLocalizedTextLinesReceived",void 0),a(this,"onRawTextLinesUnitReceived",void 0),a(this,"onRecognizedTextLinesReceived",void 0),a(this,"onCandidateQuadEdgesUnitReceived",void 0),a(this,"onCornersUnitReceived",void 0),a(this,"onDeskewedImageReceived",void 0),a(this,"onDetectedQuadsReceived",void 0),a(this,"onEnhancedImageReceived",void 0),a(this,"onLogicLinesUnitReceived",void 0),a(this,"onLongLinesUnitReceived",void 0)}getObservationParameters(){return this._parameters}}});function Vt(e){return e&&"object"==typeof e&&"string"==typeof e.path}const Gt=/<style>([\s\S]*?)<\/style>/g,Wt=/style="([\s\S]*?)"/g,jt="undefined"!=typeof FinalizationRegistry?new FinalizationRegistry(e=>{URL.revokeObjectURL(e)}):null,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(Gt,(e,s,n,o)=>{let r=s.split("}");const a=r.length-1;let c=[],l=null,d=0;for(let e=0;e<a;++e){let t=0;for(;-1!==(t=r[e].indexOf("{",t));)d+=1,t+=1;if(l)1===d?(c.push(l+r[e]+"}"),l=null,d=0):(l+=r[e]+"}",--d);else{if(d<1)throw new Error("invalid style");1===d?(c.push(r[e].trimStart()+"}"),d=0):(l=r[e].trimStart()+"}",--d)}}if(l||d)throw new Error("invalid style");for(let e of c)t.insertRule(e,i.length);return""}))}const o=[];s&&(e=e.replace(Gt,(e,t,i,s)=>(o.push(new Blob([t],{type:"text/css"})),"<HasStyle></HasStyle>")));const r=[];e=e.replace(Wt,(e,t,i,s)=>(r.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<o.length;t++){const i=o[t],s=e[t],n=document.createElement("link");n._linkJsWrapper=n,n.rel="stylesheet",n.href=URL.createObjectURL(i),null!=jt&&jt.register(n,n.href),s.replaceWith(n)}}const c=a.querySelectorAll("[hasstyle]");for(let e=0;e<r.length;e++){const t=r[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._scriptJsWrapper=t,t.src=URL.createObjectURL(new Blob([e.textContent],{type:"text/javascript"})),null==jt||jt.register(t,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},Ht=e=>e&&"object"==typeof e&&"function"==typeof e.then,qt=(async()=>{})().constructor;class Yt extends qt{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,Ht(e)?t=e:"function"==typeof e&&(t=new qt(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&&(Ht(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}const zt="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})(),$t="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(xt=window)&&void 0!==xt&&xt.MSStream),Kt="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent)&&/Firefox/i.test(navigator.userAgent),Xt="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 $t&&i})(),Qt=zt?{width:1920,height:1080}:{width:1280,height:720},Jt=function(){const e=MediaDeviceInfo.prototype.toJSON.apply(this);return e.trackLabel=this.trackLabel,e.capabilities=this.capabilities,e.isFront=this.isFront,e},ei="The camera feature is available only in secure contexts (HTTPS).";let ti=class e{constructor(){a(this,"_coreShell",void 0),a(this,"_video",void 0),a(this,"_coreInnerLayer",void 0),a(this,"_coreOuterLayer",void 0),a(this,"_regionBoxWrapper",void 0),a(this,"_regionBoxMask",void 0),a(this,"_regionBoxBorder",void 0),a(this,"_objectFit","contain"),a(this,"_uiInlineScript2Blob",!0),a(this,"_uiInternalCss2Blob",!0),a(this,"_uiInternalCss2ExistedSheet",!1),a(this,"_ui",void 0),a(this,"_pOpen",void 0),a(this,"_getUserMediaTimeout",1e4),a(this,"_paused",!1),a(this,"_shouldClose",!1),a(this,"_cameraChangedWhenPaused",!1),a(this,"_requestedCamera","back"),a(this,"_requestedResolution",Qt),a(this,"_regionBox",{unit:"view-size",center:{x:0,y:0},maskStyle:{background:"rgba(0, 0, 0, 0.5)"},borderStyle:{border:"1px solid #00ff7f"}}),a(this,"_eventListeners",{}),a(this,"_bTryAnotherCameraWhenFailToOpen",!0),a(this,"_constraints4Fallback",!!zt||{facingMode:"environment"}),a(this,"_taskIdIOSResizeProblem",void 0),a(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:o}=this._coreShell.getBoundingClientRect(),r=`${t.videoWidth} / ${t.videoHeight}`;r!=i.aspectRatio&&(i.aspectRatio=r),s&&r!=s.aspectRatio&&(s.aspectRatio=r);const a=n/o-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.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;if("opened"!==this.status&&"paused"!==this.status)return null;const s=null===(t=this.track)||void 0===t||null===(t=t.getSettings())||void 0===t?void 0:t.deviceId;return s?null===(i=e._mapDeviceInfo)||void 0===i?void 0:i[s]:null}get currentResolution(){return{width:this.video.videoWidth,height:this.video.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;if(e.isFront)return!1;const i=null===(t=e.capabilities)||void 0===t||null===(t=t.focusDistance)||void 0===t?void 0:t.min;return void 0!==i&&i<.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(ei);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(!e._currentOpenedCamera&&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 o=i.find(e=>e.deviceId===n);o?(o.trackLabel=e.label,o.capabilities=null===(s=e.getCapabilities)||void 0===s?void 0:s.call(e),o.isFront="user"===e.getSettings().facingMode,o.toJSON=Jt):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(Jt===n.toJSON)continue;let o=null===(i=e._mapDeviceInfo)||void 0===i?void 0:i[n.deviceId];if(Jt===(null==o?void 0:o.toJSON))n.trackLabel=o.trackLabel,n.capabilities=o.capabilities,n.isFront=o.isFront,n.toJSON=o.toJSON;else if(!e._currentOpenedCamera){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=Jt}}}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 Yt,"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("closing"===this.status)throw Error("Camera closed.");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("closing"===this.status)throw Error("Camera closed.");if(!t.length)throw Error("No camera found.");const i=t.reduce((e,t)=>{var i,s;if(null!=t&&t.isFront)return e;const n=null==e||null===(i=e.capabilities)||void 0===i||null===(i=i.focusDistance)||void 0===i?void 0:i.min;if(!e||!n)return t;const o=null==t||null===(s=t.capabilities)||void 0===s||null===(s=s.focusDistance)||void 0===s?void 0:s.min;return o&&o<n?t:e});s={deviceId:(null==i?void 0:i.deviceId)||t[t.length-1].deviceId};break}default:throw Error(`Unknown camera preset: ${this._requestedCamera}`)}zt&&s.deviceId&&(s.deviceId={exact:s.deviceId}),this._requestedCamera=s}else s=this._requestedCamera;const n={video:Object.assign({},s,this._requestedResolution),audio:!1};if(Object.keys(n.video).length||(n.video=!0),null===(t=navigator)||void 0===t||!t.mediaDevices)throw Error(ei);e._delayBeforeGetUserMedia&&await new Promise(t=>setTimeout(t,e._delayBeforeGetUserMedia));let o,r=navigator.mediaDevices.getUserMedia(n);try{o=await(this._getUserMediaTimeout?Promise.race([r,new Promise((e,t)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",t(e)},this._getUserMediaTimeout))]):r)}catch(t){if(this._bTryAnotherCameraWhenFailToOpen||!["NotReadableError","AbortError","OverconstrainedError","DMCameraTimeout"].includes(null==t?void 0:t.name))throw t;console.warn(t),console.warn("Try default camera."),r=navigator.mediaDevices.getUserMedia({video:this._constraints4Fallback});try{let e=this._getUserMediaTimeout;e>5e3&&(e=5e3),o=await(e?Promise.race([r,new Promise((t,i)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",i(e)},e))]):r)}catch(i){if(console.warn(i),!zt||!e._mapDeviceInfo)throw t;const s=Object.keys(e._mapDeviceInfo);if(s.length<2)throw t;console.warn("Try other cameras.");let n=this._getUserMediaTimeout;n>2500&&(n=2500);for(let e of s)try{r=navigator.mediaDevices.getUserMedia({video:{deviceId:{exact:e}}}),o=await(n?Promise.race([r,new Promise((e,t)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",t(e)},n))]):r);break}catch(e){console.warn(e)}if(!o)throw t}}if("closing"===this.status)throw Error("Camera closed.");this._video.srcObject=o}else{if(await this._video.play(),"closing"===this.status)throw Error("Camera closed.");let e=0;for(;++e<100&&!(this.video.readyState>=HTMLMediaElement.HAVE_ENOUGH_DATA);)if(await new Promise(e=>setTimeout(e,100)),"closing"===this.status)throw Error("Camera closed.")}if(Xt&&"customized-video"!==this._requestedCamera){if(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)}),"closing"===this.status)throw Error("Camera closed.");await Promise.race([this.video.play(),new Promise((t,i)=>setTimeout(()=>{i(Error("`video.play()` unresponsive in current iOS PWA environment. Please use `singleFrameMode='camera'` instead."))},e._videoPlayTimeout))])}else await Promise.race([this.video.play(),new Promise((t,i)=>setTimeout(()=>{i(Error("video play timeout"))},e._videoPlayTimeout))]);if("closing"===this.status)throw Error("Camera closed.");if(this.track){var s;const t=this.track.getSettings();if("customized-video"!==this._requestedCamera&&t.deviceId&&(null===(s=e._mapDeviceInfo)||void 0===s||!s[t.deviceId])){var n,o,r;const i=t.deviceId;null!==(n=e._mapDeviceInfo)&&void 0!==n||(e._mapDeviceInfo={}),e._mapDeviceInfo[i]={trackLabel:this.track.label,capabilities:null===(o=(r=this.track).getCapabilities)||void 0===o?void 0:o.call(r),isFront:"user"===this.track.getSettings().facingMode,toJSON:Jt}}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);)if(await new Promise(e=>setTimeout(e,100)),"closing"===this.status)throw Error("Camera closed.")}this._pOpen.resolve()}else{if(this._pOpen=new Yt,await this._video.play(),"closing"===this.status)throw Error("Camera closed.");this._paused=!1,this._pOpen.resolve()}e._currentOpenedCamera=this;for(let t of e._arrOnOpen)t.call(this);this._callOpenedListeners()}catch(e){var a,c;null!==(a=this._video.srcObject)&&void 0!==a&&null!==(c=a.getTracks)&&void 0!==c&&null!==(c=c.call(a))&&void 0!==c&&c.forEach(e=>e.stop()),this._video.srcObject=null;const t=this._pOpen;this._pOpen=null,this._shouldClose=!1,t.catch(e=>{}),t.reject();const i=Error(`Error opening camera: ${null==e?void 0:e.message}`,{cause:e});throw i.name=null==e?void 0:e.name,i}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(){for(let t of e._arrBeforeClose)t.call(this);if(this===e._currentOpenedCamera&&(e._currentOpenedCamera=null),"closed"!==this.status)if("opening"===this.status&&(this._shouldClose=!0),"closing"!==this.status){var t,i,s;null!==(t=this._video.srcObject)&&void 0!==t&&null!==(i=t.getTracks)&&void 0!==i&&null!==(i=i.call(t))&&void 0!==i&&i.forEach(e=>e.stop()),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)}})}else try{await this._pOpen}catch(e){}}async requestCamera(e){if("string"==typeof e)ii.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=Qt),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:o}=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 r=(null==o?void 0:o.canvas)||document.createElement("canvas");return r.width!=s&&(r.width=s),r.height!=n&&(r.height=n),(o||r.getContext("2d")).drawImage(this._video,t,i,s,n,0,0,s,n),r}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));const i=this._regionBoxMask,s=this._regionBoxBorder,n=e.width,o=e.height,r=e.center;"string"==typeof e.innerUi&&(e.innerUi=Zt(e.innerUi)),e.innerUi instanceof DocumentFragment?(s.textContent="",s.append(e.innerUi),e.innerUi=s.childNodes):e.innerUi instanceof Node?1==s.childNodes.length&&s.firstChild==e.innerUi||(s.textContent="",s.append(e.innerUi)):e.innerUi instanceof NodeList?s.childNodes!==e.innerUi&&(s.textContent="",s.append(...e.innerUi),e.innerUi=s.childNodes):e.innerUi instanceof Array?(s.textContent="",s.append(...e.innerUi),e.innerUi=s.childNodes):s.textContent="";let a=100*r.y-50*o+50+"%",c=100*r.x+50*n+50+"%",l=100*r.y+50*o+50+"%",d=100*r.x-50*n+50+"%";Object.assign(i.style,{clipPath:`polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, ${d} ${a}, ${d} ${l}, ${c} ${l}, ${c} ${a}, ${d} ${a})`}),"view-min"===e.unit&&(a=`calc(${100*r.y+50}% + max(-${50*o}cqmin, -${50*o}cqmax))`,c=`calc(${100*r.x+50}% + ${50*n}cqmin)`,l=`calc(${100*r.y+50}% + ${50*o}cqmin)`,d=`calc(${100*r.x+50}% + max(-${50*n}cqmin, -${50*n}cqmax))`,Object.assign(i.style,{clipPath:`polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, ${d} ${a}, ${d} ${l}, ${c} ${l}, ${c} ${a}, ${d} ${a})`})),Object.assign(i.style,{...e.maskStyle}),Object.assign(s.style,{width:100*n+"%",height:100*o+"%"}),"view-min"===e.unit&&Object.assign(s.style,{width:100*n+"cqmin",height:100*o+"cqmin"}),Object.assign(s.style,{top:100*r.y+50+"%",left:100*r.x+50+"%",...e.borderStyle}),"view-size"===e.unit&&1===n&&1===o&&(s.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(),o=parseFloat(s.borderLeftWidth),r=parseFloat(s.borderTopWidth);return e.map(e=>({left:(this._isMirrored?t.videoWidth-e.x:e.x)/t.videoWidth*i.width+i.x-n.x-o,top:e.y/t.videoHeight*i.height+i.y-n.y-r}))}}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),o=parseFloat(t.borderRightWidth),r=parseFloat(t.borderBottomWidth);s.x+=i,s.y+=n,s.width-=i+o,s.height-=n+r}else{const e=this._coreShell.getBoundingClientRect();s={x:e.x,y:e.y,width:e.width,height:e.height}}const n=this._video.getBoundingClientRect(),o={x:(s.x-n.x)/n.width,y:(s.y-n.y)/n.height,width:s.width/n.width,height:s.height/n.height};o.x<0&&(o.width+=o.x,o.x=0),o.x>1&&(o.width-=o.x-1,o.x=1),o.y<0&&(o.height+=o.y,o.y=0),o.y>1&&(o.height-=o.y-1,o.y=1),o.x+o.width>1&&(o.width=1-o.x),o.x+o.width<0&&(o.width=-o.x),o.y+o.height>1&&(o.height=1-o.y),o.y+o.height<0&&(o.height=-o.y);const r=this._video.videoWidth,a=this._video.videoHeight;let c=(this._isMirrored?1-o.x-o.width:o.x)*r,l=o.y*a,d=o.width*r,u=o.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}}};a(ti,"_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"]]),a(ti,"_currentOpenedCamera",void 0),a(ti,"_mapDeviceInfo",void 0),a(ti,"_delayBeforeEnumerateDevices",0),a(ti,"_delayBeforeGetUserMedia",Kt?1e3:0),a(ti,"_delayBeforeApplyConstraints",0),a(ti,"_countEnsureResolution",Kt?20:10),a(ti,"_videoPlayTimeout",zt?1e4:3e3),a(ti,"_bReopenWhenChangeResolution",$t),a(ti,"_arrConstructors",[]),a(ti,"_arrOnOpen",[]),a(ti,"_arrBeforeClose",[]),a(ti,"_arrOnClose",[]);const ii=["back","front","macro-back","quick-back","customized-video"];ti.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 o=null===(s=i.currentCamera)||void 0===s||null===(s=s.capabilities)||void 0===s?void 0:s[t],{min:r,step:a,max:c}=o||{};null!=r&&n<r?n=r:null!=c&&n>c&&(n=c),null!=a&&null!=r&&(n=r+Math.round((n-r)/a)*a,c&&n>c&&(n-=a)),e[t]=n}}return e},ti._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(ti.prototype,"softZoom",{get(){return this._softZoom}}),Object.defineProperty(ti.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(ti.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(ti.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)}}),ti.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},ti.prototype.setZoom=async function(e){const t=this;if("opened"!==t.status)throw Error("Camera not open");ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await t.applyConstraints(t.correctAdvancedConstraint(t.correctAdvancedConstraint({advanced:[{zoom:e}]})))},ti.prototype.setSoftZoom=function(e,t){const i=this;let{center:s,limit:n}=t||{},{x:o=0,y:r=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;o<-t?o=-t:o>t&&(o=t),r<-t?r=-t:r>t&&(r=t)}a+=` translate(${o*=-100}%, ${r*=-100}%)`}i._softZoom={zoom:e,center:{x:o,y:r}},i._coreInnerLayer.style.transform=a},ti.prototype._changeZoomByWheel=function(e){var t;const i=this,s=Date.now();let n=i._softZoom.zoom,o=n-e.deltaY/200;o>i.maxZoom4GestureWheel&&(o=i.maxZoom4GestureWheel),o<1&&(o=1),o!==n&&(i.setSoftZoom(o,{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)}}))},ti.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],o=e.touches[1],r=t._mapZoomTouchs.get(n.identifier),a=t._mapZoomTouchs.get(o.identifier);if(!r||!a)break;let c=Math.pow(Math.pow(r.x-a.x,2)+Math.pow(r.y-a.y,2),.5),l=Math.pow(Math.pow(n.clientX-o.clientX,2)+Math.pow(n.clientY-o.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})},ti._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"}),ti._getImageContrast=(e,t,i)=>{let s=0;for(let n=0;n<i-1;n++)for(let i=0;i<t-1;i++){const o=4*(n*t+i),r=o+4,a=o+4*t,c=e[o]-e[r],l=e[o+1]-e[r+1],d=e[o+2]-e[r+2],u=e[o]-e[a],h=e[o+1]-e[a+1],_=e[o+2]-e[a+2];s+=c*c+l*l+d*d+u*u+h*h+_*_}return s},ti.prototype._simpleFocus=async function(){var e,t,i,s,n;const o=this;if("opened"!==o.status)throw Error("Camera not open");if(o._isFocusing)return;const r=null===(e=o.currentCamera)||void 0===e?void 0:e.capabilities;let a,c;if(null!=r&&null!==(t=r.focusMode)&&void 0!==t&&t.includes("manual"))if(null!=r&&null!==(i=r.focusMode)&&void 0!==i&&i.includes("continuous"))a="manual",c="continuous";else{var l;if(null==r||null===(l=r.focusMode)||void 0===l||!l.includes("single-shot"))return void o._advancedFocus();a="manual",c="single-shot"}else if(null!=r&&null!==(s=r.focusMode)&&void 0!==s&&s.includes("single-shot"))null!=r&&null!==(n=r.focusMode)&&void 0!==n&&n.includes("continuous")?(a="continuous",c="single-shot"):(a=null,c="single-shot");else{var d;if(null==r||null===(d=r.focusMode)||void 0===d||!d.includes("continuous"))return;a=null,c="continuous"}o._isFocusing=!0;try{var u;a&&("manual"===a?(ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await o.applyConstraints(o.correctAdvancedConstraint({advanced:[{focusMode:"manual",focusDistance:(null==r||null===(u=r.focusDistance)||void 0===u?void 0:u.max)||10}]}))):(ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await o.applyConstraints({advanced:[{focusMode:a}]})),await new Promise(e=>setTimeout(e,500))),ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await o.applyConstraints({advanced:[{focusMode:c}]}),await new Promise(e=>setTimeout(e,500))}catch(r){"opened"===o.status&&console.warn("Error while do simple focus",r)}o._isFocusing=!1},ti.prototype._advancedFocus=async function(e,t,i){var s,n,o,r;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,_=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),h=e.x-t/2,_=e.y-i/2):(t=d,i=u),a._isFocusing=!0;const m=++a._advancedFocusTaskId;let g=null==c||null===(o=c.focusDistance)||void 0===o?void 0:o.min;(!g||g<l.minFocusDistanceLimit)&&(g=l.minFocusDistanceLimit);let p=null==c||null===(r=c.focusDistance)||void 0===r?void 0:r.max;(!p||p>l.maxFocusDistanceLimit)&&(p=l.maxFocusDistanceLimit);let f=-1/0,E=-1/0,y=1/0,I=p,v=!1,R=!0;const C=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});let T=0;try{for(;++T<l.maxStepCount;){let e;ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._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:h,y:_,width:t,height:i,reusedContext:C});const s=C.getImageData(0,0,t,i).data,n=ti._getImageContrast(s,t,i);if(v){if(n<=f){ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await a.applyConstraints(a.correctAdvancedConstraint({advanced:[{focusMode:"manual",bestFocusDistance:y}]})),ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await a.applyConstraints(a.correctAdvancedConstraint({advanced:[{focusMode:"manual",bestFocusDistance:y}]}));break}if(p===I)break;f=n,n>E&&(E=n,y=I),I*=l.fineTuneRate,I>p&&(I=p)}else(n<=E*l.coarseTuneTolerance||g===I)&&(v=!0),f=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){ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints));try{await a.applyConstraints({advanced:[{focusMode:"continuous"}]})}catch(e){}}},l.backToContinousDuration)},Object.defineProperty(ti.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:o}]=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)/(o-s)*t._video.videoHeight})}else t._simpleFocus()},t._coreShell.addEventListener("pointerdown",t._tapToFocusListner)):t._tapToFocusListner&&(t._coreShell.removeEventListener("pointerdown",t._tapToFocusListner),t._tapToFocusListner=null)}}),ti._arrConstructors.push(function(){this._isTorchOn=!1,this._autoTorchParameters={shortDelay:250,longDelay:1e3,shortLongDelaySwitchCount:10,grayThreshold:20,maxDarkCount:3}}),ti._arrOnClose.push(function(){this._isTorchOn=!1}),Object.defineProperty(ti.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(ti.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}}),ti.prototype.turnOnTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints));try{await e.applyConstraints({advanced:[{torch:!0}]})}catch(t){throw e._isTorchOn=!1,t}e._isTorchOn=!0},ti.prototype.turnOffTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await e.applyConstraints({advanced:[{torch:!1}]}),e._isTorchOn=!1},ti.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,o=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 r;await e.turnOnTorch(),null===(r=e._eventListeners.torchAutoOn)||void 0===r||r.forEach(t=>{try{t.call(e)}catch(e){console.error(e)}})}catch(e){}break}await new Promise(e=>setTimeout(e,o<t.shortLongDelaySwitchCount?t.shortDelay:t.longDelay)),++o}})()};const si="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(Pt=window)&&void 0!==Pt&&Pt.MSStream),ni="undefined"!=typeof navigator&&/MiuiBrowser/.test(navigator.userAgent),oi="undefined"!=typeof navigator&&/SamsungBrowser/.test(navigator.userAgent);let ri,ai;ti._arrConstructors.push(function(){this._shouldCloseWhenHide=!0,this._maxReopenTry4CloseWhenHide=4}),ti._arrOnOpen.push(function(){this._bindCloseWhenHide()}),ti._arrBeforeClose.push(function(){this._isDuringCloseWhenHide||this._unbindCloseWhenHide()}),Object.defineProperty(ti.prototype,"shouldCloseWhenHide",{get(){return this._shouldCloseWhenHide},set(e){const t=this;t._shouldCloseWhenHide=e,("opened"===t.status||"paused"===t.status&&!t._paused)&&(e?t._bindCloseWhenHide():t._unbindCloseWhenHide())}}),ti.prototype._closeWhenHide=async function(){var e;const t=this;if("hidden"===document.visibilityState)("opened"===t.status||"paused"===t.status&&!t._paused&&(si&&"live"===(null===(e=t.track)||void 0===e?void 0:e.readyState)||ni&&"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}}},ti.prototype._bindCloseWhenHide=function(){const e=this;e._shouldCloseWhenHide&&(e._closeWhenHideListener||(e._closeWhenHideListener=()=>{e._closeWhenHide()},document.addEventListener("visibilitychange",e._closeWhenHideListener),oi&&window.addEventListener("blur",e._closeWhenHideListener)))},ti.prototype._unbindCloseWhenHide=function(){const e=this;e._closeWhenHideListener&&(document.removeEventListener("visibilitychange",e._closeWhenHideListener),oi&&window.removeEventListener("blur",e._closeWhenHideListener),e._closeWhenHideListener=null,e._isOpenBeforeHide=!1)},ti._id4CloseWhenNotInDOM=0,ti._stMSBNotInDOMCamera=new Set,ti._arrConstructors.push(function(){this._id4CloseWhenNotInDOM=++ti._id4CloseWhenNotInDOM,this._shouldCloseWhenNotInDOM=!0,this._bClosedBecauseOfNotInDOM=!1}),ti.prototype._updateMo4CloseWhenNotInDOM=function(){var e;if(null!==(e=this._mo4CloseWhenNotInDOM)&&void 0!==e&&e.disconnect(),!this._shouldCloseWhenNotInDOM||!["opened","paused"].includes(this.status))return this._mo4CloseWhenNotInDOM=null,void ti._stMSBNotInDOMCamera.delete(this);let t;if(this._video.isConnected){ti._stMSBNotInDOMCamera.delete(this);for(let e of ti._stMSBNotInDOMCamera)e._id4CloseWhenNotInDOM<this._id4CloseWhenNotInDOM&&(e.close(),e._bClosedBecauseOfNotInDOM=!0,ti._stMSBNotInDOMCamera.delete(e));t=new MutationObserver(()=>{this._video.isConnected||(t.disconnect(),this.close(),this._bClosedBecauseOfNotInDOM=!0)})}else ti._stMSBNotInDOMCamera.add(this),t=new MutationObserver(()=>{this._video.isConnected&&this._updateMo4CloseWhenNotInDOM()});this._mo4CloseWhenNotInDOM=t,t.observe(document.body,{childList:!0,subtree:!0})},ti._arrOnOpen.push(function(){this._updateMo4CloseWhenNotInDOM(),this._bClosedBecauseOfNotInDOM=!1}),ti._arrBeforeClose.push(function(){this._updateMo4CloseWhenNotInDOM()}),Object.defineProperty(ti.prototype,"shouldCloseWhenNotInDOM",{get(){return this._shouldCloseWhenNotInDOM},set(e){this._shouldCloseWhenNotInDOM=!!e,this._updateMo4CloseWhenNotInDOM()}}),ti.showFilePicker=async function(e){var t;null===(t=ri)||void 0===t||t.remove();const i=ri=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,t){i.addEventListener("change",function(){var s;null!==(s=i.files)&&void 0!==s&&s.length?e(Array.from(i.files)):t(new Error("No file selected.")),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},ti.filePicker2CanvasMaxWH=4096,ti.showFilePicker2Canvas=async function(e){var t;let i=ti.filePicker2CanvasMaxWH;(null===(t=e)||void 0===t?void 0:t.canvasMaxWH)&&(i=e.canvasMaxWH,delete(e={...e}).canvasMaxWH);let s=await ti.showFilePicker(e),n=[];for(let e of s){const t=document.createElement("canvas"),s=t.getContext("2d"),o=URL.createObjectURL(e),r=new Image;r.src=o,await r.decode(),r.naturalWidth<i&&r.naturalHeight<i?(t.width=r.width,t.height=r.height,s.drawImage(r,0,0)):(r.naturalWidth/r.naturalHeight>1?(t.width=i,t.height=Math.round(r.naturalHeight/r.naturalWidth*i)):(t.height=i,t.width=Math.round(r.naturalWidth/r.naturalHeight*i)),s.drawImage(r,0,0,t.width,t.height)),URL.revokeObjectURL(o),n.push(t)}return n};let ci=class{constructor(e){a(this,"camera",void 0),a(this,"_ctx",void 0),a(this,"_data",void 0),a(this,"_dataTime",-1/0),a(this,"_x",void 0),a(this,"_y",void 0),a(this,"_w",void 0),a(this,"_h",void 0),a(this,"_type",void 0),a(this,"maxTimeout",500),a(this,"_pipeTaskId",void 0),a(this,"isSaveOriginalRgba",!1),a(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);if("gray"===this._type)for(let i=0;i<e.length;i+=4)t[i/4]=.3*e[i]+.59*e[i+1]+.11*e[i+2];else if("r"===this._type)for(let i=0;i<e.length;i+=4)t[i/4]=e[i];else if("g"===this._type)for(let i=0;i<e.length;i+=4)t[i/4]=e[i+1];else if("b"===this._type)for(let i=0;i<e.length;i+=4)t[i/4]=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:o="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 r=t!==this._x||i!==this._y||s!==this._w||n!==this._h||o!==this._type;let a;return r&&(this._x=t,this._y=i,this._w=s,this._h=n,this._type=o),!r&&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}},li=class{constructor(){a(this,"_stAudioFree",new Set),a(this,"_stAudioPlaying",new Set),a(this,"_timeLastPlay",0),a(this,"_bWarnedMaxTrack",!1),a(this,"maxPlayingBeep",16),a(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=void 0),!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 di=()=>{(null!=ai?ai:ai=new li).beep()},ui=(e=300)=>{var t;if(null===(t=navigator)||void 0===t||!t.vibrate)throw new Error("Not supported.");navigator.vibrate(e)},hi=ti,_i=ti;if(null!==(kt=document)&&void 0!==kt&&kt.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 mi={x:0,y:0,width:100,height:100,isMeasuredInPercentage:!0};hi.createInstance=async function(e){let t;if(e instanceof ti?(t=e,e=void 0):t=new ti,void 0===t.disposed){if(t.isCameraEnhancer=!0,t.disposed=!1,t._cameraEnhancer=t._cameraView=t,t._framePipeline=new ci(t),t._dceScanRegion=mi,t._dceEventListeners={},t._bAutoSingleFrameModeWhenIosPwaFail=!0,t._oriOpen=t.open,t.open=gi,t._oriUpdateCanvasSize=t._updateCanvasSize,t._updateCanvasSize=fi,t._oriAddCanvas=t.addCanvas,t.addCanvas=Ei,t._dceZoom=1,t._dceEnhancedFeatures=0,t._dceAutoZoomRange={min:1,max:10},t._oriSetZoom=t.setZoom,t.setZoom=yi,t.singleFrameMode="disabled",t._singleFrameModeObjectFit="contain",t._ifSaveLastUsedCamera=!1,t._pixelFormat=10,t._colourChannelUsageType=1,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=_i.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:ki.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 o=null===(s=t.currentCamera)||void 0===s?void 0:s.deviceId,r=t._dceLastDeviceId;o!==r&&(t._dceLastDeviceId=o,null===(n=this._dceEventListeners.cameraChange)||void 0===n||n.forEach(e=>{try{e.call(this,o,r)}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 Bi)return e.quad.points;if(e instanceof Fi||e instanceof xi||e instanceof Pi){let{x:t,y:i,width:s,height:n}=e.rect,o=t+s,r=i+n;return[{x:t,y:i},{x:t,y:r},{x:o,y:r},{x:o,y:i}]}return e instanceof Mi?[e.line.startPoint,e.line.endPoint]:void 0}).flat()).map(e=>[e.left,e.top]);let o=n.length;for(let t=s.length-1;t>=0;--t){let a=s[t],c=!1;if(a instanceof Bi||a instanceof Fi||a instanceof xi||a instanceof Pi?(c=Li(i,[n[o-4],n[o-3],n[o-2],n[o-1]]),o-=4):a instanceof Mi&&(c=Li(i,[n[o-2],n[o-1]]),o-=2),c){var r;e.targetItem=a,e.itemPageX=n[o][0],e.itemPageY=n[o][1],e.itemClientX=e.itemPageX-e.pageX+e.clientX,e.itemClientY=e.itemPageY-e.pageY+e.clientY,null===(r=a._dceEventListeners[e.type])||void 0===r||r.forEach(t=>{try{t.call(this,e)}catch(e){console.error(e)}});break}}})}),"undefined"!=typeof ResizeObserver&&(t._singleFrameModeUIAutoFitRO=new ResizeObserver(()=>{var e;if(!t._coreShell.isConnected||!t._singleFrameModeCvs)return;t._singleFrameModeUpdateObjectFit();const i=null===(e=navigator)||void 0===e?void 0:e.userAgent;if(i&&/iPhone|iPad/i.test(i)){t._taskIdIOSResizeProblem&&clearInterval(t._taskIdIOSResizeProblem);let e=0;t._taskIdIOSResizeProblem=setInterval(()=>{if(++e>10||!t._coreShell.isConnected||!t._singleFrameModeCvs)return clearInterval(t._taskIdIOSResizeProblem),void(t._taskIdIOSResizeProblem=null);t._singleFrameModeUpdateObjectFit()},100)}}))}return t},hi.defaultUIElementURL="@engineResourcePath/ui/dce.ui.xml",Object.defineProperty(hi.prototype,"cameraOpenTimeout",{get(){return this._getUserMediaTimeout},set(e){this._getUserMediaTimeout=e}});const gi=async function(){var e,t,i,s,n;const o=this;if("disabled"!==o.singleFrameMode){var r;let e=await pi("camera"===o.singleFrameMode);{let t;switch(o._colourChannelUsageType){case 1:break;case 2:t="gray";case 3:t="r";case 4:t="g";case 5:t="b";const i=e.bytes,s=new Uint8Array(i.length/4);if("gray"===t)for(let e=0;e<i.length;e+=4)s[e/4]=.3*i[e]+.59*i[e+1]+.11*i[e+2];else if("r"===t)for(let e=0;e<i.length;e+=4)s[e/4]=i[e];else if("g"===t)for(let e=0;e<i.length;e+=4)s[e/4]=i[e+1];else if("b"===t)for(let e=0;e<i.length;e+=4)s[e/4]=i[e+2];e={bytes:s,width:e.width,height:e.height,stride:e.width,format:2,toCanvas:function(){return Ii(this.bytes,this.width,this.height,this.format)},imageTag:{imageId:++vi,type:0}}}}const t=o.ui.querySelector(".dce-bg-camera");"closed"!==o.status&&await o.close(),t&&(t.style.opacity="0");{var a;o._singleFrameModeCvs&&o._singleFrameModeCvs.remove();const t=o._singleFrameModeCvs=e.toCanvas();Object.assign(t.style,{width:"100%",height:"100%",position:"absolute",left:"0px",top:"0px"}),o._video.parentElement.querySelectorAll("canvas").forEach(e=>{e.width!==t.width&&(e.width=t.width),e.height!==t.height&&(e.height=t.height)}),o._singleFrameModeUpdateObjectFit(),o._video.before(t),null===(a=o._singleFrameModeUIAutoFitRO)||void 0===a||a.observe(o._coreShell)}return o._singleFrameModeResultForDcv=e,void(null===(r=o._dceEventListeners.singleFrameAcquired)||void 0===r||r.forEach(t=>{try{t.call(this,e)}catch(t){console.error(t)}}))}o.videoSrc&&(o.video.src=o._dceVideoSrc);const c=o.ui.querySelector(".dce-bg-loading");c&&(c.style.display="");try{await o._oriOpen()}catch(e){var l,d,u;if(hi.onWarning&&hi.onWarning(null==e?void 0:e.message),o._bAutoSingleFrameModeWhenIosPwaFail&&null!=e&&null!==(l=e.message)&&void 0!==l&&l.includes("iOS PWA"))return console.warn(e.message),c&&(c.style.display="none"),console.warn("Auto switch to `singleFrameMode = 'camera'`."),o.singleFrameMode="camera",void(null===(d=o.funcShowToast)||void 0===d||d.call(o,"Click to Capture",8e3));throw c&&(c.style.display="none"),null!==(u=o.funcShowToast)&&void 0!==u&&u.call(o,null==e?void 0:e.message,8e3),e}return o._ifSaveLastUsedCamera&&null!==(e=o.currentCamera)&&void 0!==e&&e.deviceId&&(null!==(t=localStorage)&&void 0!==t&&t.setItem("dce-last-used-camera",null===(i=o.currentCamera)||void 0===i?void 0:i.deviceId),null!==(s=localStorage)&&void 0!==s&&s.setItem("dce-last-used-resolution",JSON.stringify(o.requestedResolution))),c&&(c.style.display="none"),await new Promise(e=>setTimeout(e,0)),{deviceId:null===(n=o.currentCamera)||void 0===n?void 0:n.deviceId,...o.currentResolution}},pi=async function(e){const t={multiple:!1};e&&(t.capture="environment");const i=(await ti.showFilePicker2Canvas(t))[0],s=i.getContext("2d").getImageData(0,0,i.width,i.height).data;return{bytes:new Uint8Array(s.buffer,s.byteOffset,s.length),width:i.width,height:i.height,stride:4*i.width,format:10,toCanvas:()=>i,imageTag:{imageId:++vi,type:0}}},fi=function(){"disabled"===this.singleFrameMode&&this._oriUpdateCanvasSize()},Ei=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};hi.prototype.dispose=function(){this.disposed=!0,this.close(),this.setScanLaserVisible(!1)},hi.prototype.getAllCameras=async function(){return(await ti.getDeviceInfos()).map(e=>({deviceId:e.deviceId,label:e.label||e.trackLabel}))},hi.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 o,r,a,c;await e.requestResolution(i),((null===(o=e.currentResolution)||void 0===o?void 0:o.width)===i[0]&&(null===(r=e.currentResolution)||void 0===r?void 0:r.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},hi.prototype.getCameraState=function(){let e=this.status;return"closing"===e||"paused"===e||"closed"===e?"closed":"opened"===e?"open":"opening"===e?"opening":void 0},hi.prototype.getResolution=function(){return"opened"===this.status?this.currentResolution:this.requestedResolution},hi.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},hi.prototype.getVideoSettings=function(){let e={};return"object"==typeof this.requestedCamera&&Object.assign(e,this.requestedCamera),Object.assign(e,this.requestedResolution),{video:e}},Object.defineProperty(hi.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 o=null===(s=localStorage)||void 0===s?void 0:s.getItem("dce-last-used-resolution");if(o)try{t.requestResolution(JSON.parse(o))}catch(e){}}}}),Object.defineProperty(hi.prototype,"ifSkipCameraInspection",{get(){return"quick-back"===this.requestedCamera},set(e){e?this.requestCamera("quick-back"):this.requestCamera("back")}}),hi.prototype.isOpen=function(){return"opened"===this.status},hi.prototype.isPaused=function(){return"paused"===this.status},hi.prototype.resume=async function(){await this._oriOpen()},hi.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}},hi.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}},hi.testCameraAccess=async function(){let e=!0,t="Successfully accessed the camera.";try{await ti.getDeviceInfos()}catch(i){e=!1,t=i.message||i}return{ok:e,message:t}},hi.prototype.updateVideoSettings=async function(e){const t="object"!=typeof e?null:null==e?void 0:e.video;await this.requestCamera(t)},Object.defineProperty(hi.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))}}),hi.prototype.disableEnhancedFeatures=function(e){this._dceEnhancedFeatures=this._dceEnhancedFeatures-(this._dceEnhancedFeatures&e)},hi.prototype.enableEnhancedFeatures=function(e){this._dceEnhancedFeatures|=e},hi.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},hi.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},hi.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},hi.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},hi.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},hi.prototype.setColorTemperature=async function(e){var t;const i=this;i.getColorTemperature(),ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{colorTemperature:e,whiteBalanceMode:"manual"}]})))},hi.prototype.setExposureCompensation=async function(e){var t;const i=this;i.getExposureCompensation(),ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{exposureCompensation:e}]})))},hi.prototype.setFrameRate=async function(e){var t;const i=this;i.getFrameRate(),ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{frameRate:e}]})))},hi.prototype.getZoomSettings=function(){return{factor:this._dceZoom}};const yi=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 Ii(e,t,i,s){const n=document.createElement("canvas");n.width=t,n.height=i;const o=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 r=new Uint8ClampedArray(e),a=new ImageData(r,t,i);return o.putImageData(a,0,0),n}hi.prototype.resetZoom=async function(){this._dceZoom=1,this.setSoftZoom(1,{center:{x:0,y:0}});try{await this._oriSetZoom(1)}catch(e){}},hi.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),o=null==n?void 0:n.focusMode;if(void 0===o)throw Error("Not supported");return s=o===(null===(i=this._dceFocusSettings)||void 0===i?void 0:i.mode)?this._dceFocusSettings:{mode:o},"manual"===s.mode&&(s.distance=null==n?void 0:n.focusDistance),s},hi.prototype.setFocus=async function(e){const t=this;if(!t.track)throw Error("Camera not open");if(t._dceFocusSettings=e,"manual"!==e.mode)ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await t.applyConstraints({advanced:[{focusMode:e.mode}]});else if(e.distance)ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._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,o=e.area.height,r=t.currentResolution.width,a=t.currentResolution.height;"string"==typeof i&&(i=i.endsWith("%")?parseFloat(i)*r:parseFloat(i)),"string"==typeof s&&(s=s.endsWith("%")?parseFloat(s)*a:parseFloat(s)),"string"==typeof n&&(n=n.endsWith("%")?parseFloat(n)*r:parseFloat(n)),"string"==typeof o&&(o=o.endsWith("%")?parseFloat(o)*a:parseFloat(o)),await t._advancedFocus({x:i,y:s},n,o)}},hi.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)},hi.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},hi.prototype.toggleMirroring=function(e){this.isMirrored=e};let vi=0;hi.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:++vi,type:1}}},hi.prototype.getImage=function(){var e;const t=this,i=t.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0});let s;switch(t._colourChannelUsageType){case 1:default:s="rgba";break;case 2:s="gray";break;case 3:s="r";break;case 4:s="g";break;case 5:s="b"}let n=t._framePipeline.getData({...i,type:s});if(!n)return null;let{width:o,height:r}=i,a="rgba"===s?10:2;const c={bytes:n,width:o,height:r,stride:i.width*("rgba"===s?4:1),format:a,toCanvas:function(){return Ii(this.bytes,this.width,this.height,this.format)},imageTag:{imageId:++vi,type:1}};return null!==(e=this._dceEventListeners.frameAddedToBuffer)&&void 0!==e&&e.forEach(e=>{try{e.call(this,c)}catch(e){console.error(e)}}),c},hi.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 pi(!0);return i&&await t._oriOpen(),null!=e&&e(s),s},Object.defineProperty(hi.prototype,"singleFrameMode",{get(){return this._singleFrameMode},set(e){var t,i;const s=this;e?["image","camera","disabled"].includes(e)||(e="image"):e="disabled",s._singleFrameMode=e;const n=s.ui.querySelector(".dce-bg-camera");null!==(t=s._singleFrameModeCvs)&&void 0!==t&&t.remove(),s._singleFrameModeCvs=null,s._singleFrameModeResultForDcv=null,null!==(i=s._singleFrameModeUIAutoFitRO)&&void 0!==i&&i.disconnect(),"disabled"!==e?(s.close(),s._dceSettingsBeforeSingleFrameMode||(s._dceSettingsBeforeSingleFrameMode={shouldCloseWhenHide:s.shouldCloseWhenHide,regionBox:{...s.regionBox},requestedCamera:s.requestedCamera},s.shouldCloseWhenHide=!1,s.setRegionBox({width:1,height:1,unit:"view-size",center:{x:0,y:0},innerUi:void 0}),s.requestCamera("customized-video")),n&&(s._singleFrameModeClickCallback||(s._singleFrameModeClickCallback=()=>{s.open()},n.addEventListener("click",s._singleFrameModeClickCallback)),n.style.display="",n.style.opacity="")):(s._dceSettingsBeforeSingleFrameMode&&(s.shouldCloseWhenHide=s._dceSettingsBeforeSingleFrameMode.shouldCloseWhenHide,s.setRegionBox(s._dceSettingsBeforeSingleFrameMode.regionBox),s.requestCamera(s._dceSettingsBeforeSingleFrameMode.requestedCamera),s._dceSettingsBeforeSingleFrameMode=null),s._singleFrameModeClickCallback&&(n.removeEventListener("click",s._singleFrameModeClickCallback),s._singleFrameModeClickCallback=null),n&&(n.style.display="none"))}}),hi.prototype._singleFrameModeUpdateObjectFit=function(){const e=this,t=e._singleFrameModeCvs;if(!t)return;const i=e._coreOuterLayer.style;if("fill"===this._singleFrameModeObjectFit||void 0===i.aspectRatio)"100%"!==i.width&&(i.width="100%"),"100%"!==i.height&&(i.height="100%");else{const{width:s,height:n}=e._coreShell.getBoundingClientRect(),o=`${t.width} / ${t.height}`;o!=i.aspectRatio&&(i.aspectRatio=o);const r=s/n-t.width/t.height,a=.001;if(Math.abs(r)>a){let t=!1;r>0&&(t=!t),"cover"===e._singleFrameModeObjectFit&&(t=!t),t?("auto"!=i.width&&(i.width="auto"),"100%"!=i.height&&(i.height="100%")):("100%"!=i.width&&(i.width="100%"),"auto"!=i.height&&(i.height="auto"))}}},hi.prototype.getScanRegion=function(){return this._dceScanRegion},hi.prototype.hasNextImageToFetch=function(){return"opened"===this.status},hi.prototype.isBufferEmpty=function(){return"opened"!==this.status},hi.prototype.getPixelFormat=function(){return this._pixelFormat},hi.prototype.setPixelFormat=function(e){2===e?(this._pixelFormat=2,this._colourChannelUsageType=2):(this._pixelFormat=10,this._colourChannelUsageType=1)},hi.prototype.setColourChannelUsageType=function(e){switch(e){case 1:this._pixelFormat=10,this._colourChannelUsageType=1;break;case 2:this._pixelFormat=2,this._colourChannelUsageType=2;break;case 3:this._pixelFormat=2,this._colourChannelUsageType=3;break;case 4:this._pixelFormat=2,this._colourChannelUsageType=4;break;case 5:this._pixelFormat=2,this._colourChannelUsageType=5;break;default:2===this._pixelFormat?this._colourChannelUsageType=2:this._colourChannelUsageType=1}},hi.prototype.getColourChannelUsageType=function(){return this._colourChannelUsageType},hi.prototype.setScanRegion=function(e){this._dceScanRegion=null!=e?e:e=mi;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 o=e;this.setRegionBox({width:Math.min(o.width/s,1),height:Math.min(o.height/n,1),center:{x:0,y:0},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}else{let o=e;this.setRegionBox({width:Math.min((o.right-o.left)/s,1),height:Math.min((o.bottom-o.top)/n,1),center:{x:0,y:0},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}}},hi.prototype.setCameraView=function(e){if(e===this)return;const t=e.ui.parentElement;t&&(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)},hi.prototype.getCameraView=function(){return this},hi.prototype.getVideoEl=function(){return this.video},hi.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]},hi.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]},hi.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)}},hi.prototype.convertToContainCoordinates=function(e){const t=this;let i,s,n,o;{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,o=i}const r=t.video.videoWidth,a=t.video.videoHeight;let c=t.videoXY2AbsoluteLT([{x:0,y:0},{x:r,y:a}]);return{x:(e.x+n-i)/r*(c[1].left-c[0].left),y:(e.y+o-s)/a*(c[1].top-c[0].top)}},hi.prototype.on=function(e,t){var i,s;(null!==(s=(i=this._dceEventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)},hi.prototype.off=function(e,t){var i;null===(i=this._dceEventListeners[e])||void 0===i||i.delete(t)},_i.prototype.getUIElement=function(){return this.ui},_i.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(_i.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=hi.handleEngineResourcePaths(hi.CoreModule.engineResourcePaths);i=i.replace("@engineResourcePath/","DBR"===hi.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 ti.getDeviceInfos(),n=t.currentCamera;if(!n)return;const o=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===o&&(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")),o=parseInt(e.getAttribute("data-height"));await t.requestResolution({width:i,height:o})}),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 o=e.querySelector(".dce-bg-camera");if(o 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",o.parentElement.append(e),o.classList.remove("dce-bg-camera"),e.classList.add("dce-bg-camera"),e.append(o),o.style.display="",o=e}else o&&o.parentElement.append(o);let r=e.querySelector(".dm-camera-mn-toast,.dce-mn-toast");if(!r&&o){r=document.createElement("div"),r.classList.add("dm-camera-mn-toast"),Object.assign(r.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"}),o.parentElement.append(r);let e=null;t.funcShowToast=(t,i=3e3)=>{r&&(r.textContent=t,r.style.display="",null!=e&&(clearTimeout(e),e=null),i&&(e=setTimeout(()=>{r.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"),o=e.querySelector(".dce-mn-torch-off");s&&(s.style.display=void 0===t.isTorchOn?"":"none"),n&&(n.style.display=!0===t.isTorchOn?"":"none"),o&&(o.style.display=!1===t.isTorchOn?"":"none");const r=e.querySelector(".dce-mn-beep-on"),c=e.querySelector(".dce-mn-beep-off");r&&(r.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 p=e.querySelector(".dce-mn-camera-switch");p&&(p.style.display="none");const f=e.querySelector(".dce-mn-camera-and-resolution-settings");f&&(f.style.display="none");const E=null==f?void 0:f.querySelector(".dce-mn-cameras"),y=null==f?void 0:f.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||!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 ti.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 ti.hasFrontCamera()&&p&&(p.style.display="")}}),t.addEventListener("closed",()=>{t.disposed||(a.style.display="none",i&&(i.style.display="none"),u&&(u.style.display="none"),p&&(p.style.display="none"),f&&(f.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",o.style.display="")}),null!=o&&o.addEventListener("pointerdown",()=>{t.disposed||(t.isSupportTorch?(t.turnAutoTorch(),o.style.display="none",s.style.display=""):R("Torch Not Supported"))}),null!=r&&r.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!1,r.style.display="none",c.style.display="")}),null!=c&&c.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!0,c.style.display="none",r.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;const e=i.getAttribute("data-device-id");await t.requestCamera(e),"opened"!==t.status&&await t.open();const s=t.currentCamera;if(null!=s&&s.deviceId&&s.deviceId!=e){const e=s.trackLabel||s.label||s.deviceId;R(`Fallback to ${e}`)}}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==f?void 0:f.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(f&&(f.style.display=f.style.display?"":"none"))}f&&""===f.style.display&&(f.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==p||p.addEventListener("pointerdown",async()=>{"opened"===t.status&&await t.requestCamera(t.currentCamera.isFront?"back":"front")})}}s.classList.add(i)}}s||e.classList.add(i),t.ui=e},_i.prototype.getVideoElement=function(){return this.video},_i.prototype.setVideoFit=function(e){this.objectFit=e},_i.prototype.getVideoFit=function(){return this.objectFit},_i.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}}},_i.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}`:""}})},_i.prototype.getScanRegionMaskStyle=function(){return this._dceRegionMaskStyle},_i.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}`:""}})},_i.prototype.isScanRegionMaskVisible=function(){return this._dceRegionMaskVisible},_i.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)},_i.prototype.isScanLaserVisible=function(){var e;return!(null===(e=this.regionBox)||void 0===e||!e.innerUi)&&"none"!==this.regionBox.innerUi.style.display},_i.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")},_i.prototype.isPowerByMessageVisible=function(){let e=this.ui.querySelector(".dce-msg-poweredby,.dm-camera-mn-msg-poweredby");return e&&"none"!==e.style.display},_i.prototype.getTipConfig=function(){return{duration:this._dceTipDuration}},_i.prototype.setTipConfig=function(e){this._dceTipDuration=e.duration},_i.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")}},_i.prototype.isTipVisible=function(){const e=this.ui.querySelector(".dm-camera-mn-toast");return!!e&&"none"!=e.style.display},_i.prototype.updateTipMessage=function(e){var t;this._dceTipMessage=e,null===(t=this.funcShowToast)||void 0===t||t.call(this,this._dceTipMessage,this._dceTipDuration)},_i.prototype.createDrawingLayer=function(){const e=new Oi;return e._dce=this,e._ctx=this.addCanvas().getContext("2d"),this._drawingLayers.push(e),e},_i.prototype.getDrawingLayer=function(e){if(e instanceof Oi)return e;if("number"!=typeof e)return null;let t=this._drawingLayers[e];return t||1!==e&&2!==e&&3!==e||(t=new Oi,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},_i.prototype.getAllDrawingLayers=function(){for(let e=1;e<=3;e++)this.getDrawingLayer(e);return this._drawingLayers.filter(e=>e)},_i.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},_i.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])},_i.prototype.clearAllInnerDrawingItems=function(e){for(let t of this._drawingLayers.slice(1,4))!t||e&&"editor"===t._mode||t.clearDrawingItems()};let Ri=class{static beep(){null!=this._beepInstance?this._beepInstance.beep():di()}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 li),this._beepInstance.beepSoundSource=e}static vibrate(){null!=this.vibrateDuration?ui(this.vibrateDuration):ui()}};a(Ri,"_beepInstance",void 0),a(Ri,"vibrateDuration",void 0);const Ci="73,245,73",Ti="73,173,245",wi="254,180,32",Si="245,236,73",Ai=(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},Di=[null,Ai(Ti),Ai(Ci),Ai(wi),Ai(Si),Ai(Ti,"f"),Ai(Ci,"f"),Ai(wi,"f"),Ai(Si,"f"),Ai(Ti,"t"),Ai(Ci,"t"),Ai(wi,"t"),Ai(Si,"t")],bi={STYLE_BLUE_STROKE:Di[1],STYLE_GREEN_STROKE:Di[2],STYLE_ORANGE_STROKE:Di[3],STYLE_YELLOW_STROKE:Di[4],STYLE_BLUE_STROKE_FILL:Di[5],STYLE_GREEN_STROKE_FILL:Di[6],STYLE_ORANGE_STROKE_FILL:Di[7],STYLE_YELLOW_STROKE_FILL:Di[8],STYLE_BLUE_STROKE_TRANSPARENT:Di[9],STYLE_GREEN_STROKE_TRANSPARENT:Di[10],STYLE_ORANGE_STROKE_TRANSPARENT:Di[11],STYLE_YELLOW_STROKE_TRANSPARENT:Di[12],createDrawingStyle(e){let t=Object.assign({},this.STYLE_YELLOW_STROKE_FILL,e);return Object.assign(e,t),e},getDrawingStyle:e=>"number"==typeof e?Di[e]:e,getAllDrawingStyles:()=>Di.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 Oi=class{constructor(){a(this,"_visible",!0),a(this,"_dce",void 0),a(this,"_ctx",void 0),a(this,"_defaultStyle",bi.STYLE_YELLOW_STROKE_FILL),a(this,"_drawingItems",[]),a(this,"_mode","viewer"),a(this,"_editorView",void 0),a(this,"_extraEditorView",void 0),a(this,"_renderTask",void 0),a(this,"_newSelectedDrawingItems",[]),a(this,"_newDeselectedDrawingItems",[]),a(this,"_selectionChangedTask",void 0),a(this,"_onSelectionChanged",void 0)}getId(){return this}isVisible(){return this._extraEditorView?this._extraEditorView._firstLayer.isVisible():this._visible}setVisible(e){if(this._extraEditorView)return this._extraEditorView._firstLayer.setVisible(e);this._visible=e,this._delayRenderAll()}setDefaultStyle(e,t,i){if(this._extraEditorView)return this._extraEditorView._firstLayer.setDefaultStyle(e,t,i);this._defaultStyle=bi.getDrawingStyle(e),this._delayRenderAll()}addDrawingItems(e){if(this._extraEditorView)return this._extraEditorView._firstLayer.addDrawingItems(e);for(let t of e)t.drawingLayerId=this;this._drawingItems=this._drawingItems.concat(e),this._delayRenderAll()}removeDrawingItems(e){if(this._extraEditorView)return this._extraEditorView._firstLayer.removeDrawingItems(e);this._drawingItems=this._drawingItems.filter(t=>!e.includes(t)),this._delayRenderAll()}setDrawingItems(e){if(this._extraEditorView)return this._extraEditorView._firstLayer.setDrawingItems(e);for(let t of e)t.drawingLayerId=this;this._drawingItems=[...e],this._delayRenderAll()}getDrawingItems(e){return this._extraEditorView?this._extraEditorView._firstLayer.getDrawingItems(e):this._drawingItems.filter(t=>!e||e(t))}hasDrawingItem(e){return this._extraEditorView?this._extraEditorView._firstLayer.hasDrawingItem(e):this._drawingItems.includes(e)}getSelectedDrawingItems(){return this._extraEditorView?this._extraEditorView._firstLayer.getSelectedDrawingItems():this._drawingItems.filter(e=>e._bSelected)}clearDrawingItems(){if(this._extraEditorView)return this._extraEditorView._firstLayer.clearDrawingItems();this._drawingItems=[],this._delayRenderAll()}_delayRenderAll(){this._renderTask||(this._renderTask=setTimeout(()=>{this.renderAll(),this._renderTask=null},0))}renderAll(){var e;if(this._extraEditorView)return this._extraEditorView._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 xi){const o=e.text.split("\n"),{x:r,y:a,width:c,height:l}=e.rect,d=Math.min(i.fontSize*n,l/o.length);t.font=`${d}px ${i.fontFamily}`,t.textBaseline="top";const u=r+s.x;for(let e=0;e<o.length;++e){const i=a+l/o.length*e+s.y;t.fillText(o[e],u,i,c),t.strokeText(o[e],u,i,c)}continue}if(e instanceof Pi){const i=e.image,n=i.naturalWidth||i.videoWidth||i.width||0,o=i.naturalHeight||i.videoHeight||i.height||0;if(!n||!o)continue;let{x:r,y:a,width:c,height:l}=e.rect;e.maintainAspectRatio&&(l=c/n*o),t.drawImage(i,r+s.x,a+s.y,c,l);continue}if(e._bSelected&&(t.strokeStyle="#0f0",t.lineWidth=2*n,t.setLineDash([4,4])),t.beginPath(),e instanceof Bi){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 Mi){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 Fi){const{x:i,y:n,width:o,height:r}=e.rect;t.moveTo(i+s.x,n+s.y),t.lineTo(i+o+s.x,n+s.y),t.lineTo(i+o+s.x,n+r+s.y),t.lineTo(i+s.x,n+r+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._extraEditorView?this._extraEditorView._firstLayer.onSelectionChanged:this._onSelectionChanged}set onSelectionChanged(e){this._extraEditorView?this._extraEditorView._firstLayer.onSelectionChanged=e:this._onSelectionChanged=e}};function Li(e,t){const[i,s]=e;let n=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const[r,a]=t[e],[c,l]=t[o];if(i===r&&s===a||i===c&&s===l)return!0;if((i<=r&&i>=c||i>=r&&i<=c)&&(s<=a&&s>=l||s>=a&&s<=l)&&(i-r)*(s-a)===(i-c)*(s-l))return!0;a>s!=l>s&&i<(c-r)*(s-a)/(l-a)+r&&(n=!n)}return n}let Ni=class{constructor(){a(this,"coordinateBase","image"),a(this,"drawingLayerId",void 0),a(this,"drawingStyleId",void 0),a(this,"mediaType",void 0),a(this,"_notes",[]),a(this,"_bSelected",!1),a(this,"_dceEventListeners",{})}get _ps(){return null}getState(){return this._bSelected?Vi.DIS_SELECTED:Vi.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)}},Mi=class extends Ni{get _ps(){const e=this.line.startPoint,t=this.line.endPoint;return[e,e,t,t]}constructor(e,t){super(),a(this,"line",void 0),this.mediaType=Ui.DIMT_LINE,this.line=e,this.drawingStyleId=t}getLine(){return this.line}setLine(e){this.line=e,this._delayRenderAll()}},Bi=class extends Ni{get _ps(){return this.quad.points}constructor(e,t){super(),a(this,"quad",void 0),this.mediaType=Ui.DIMT_QUADRILATERAL,this.quad=e,this.drawingStyleId=t}getQuad(){return this.quad}setQuad(e){this.quad=e,this._delayRenderAll()}},Fi=class extends Ni{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(),a(this,"rect",void 0),this.mediaType=Ui.DIMT_RECTANGLE,this.rect=e,this.drawingStyleId=t}getRect(){return this.rect}setRect(e){this.rect=e,this._delayRenderAll()}},xi=class extends Ni{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(),a(this,"text",void 0),a(this,"rect",void 0),this.mediaType=Ui.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()}},Pi=class extends Ni{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(),a(this,"image",void 0),a(this,"rect",void 0),a(this,"maintainAspectRatio",void 0),this.mediaType=Ui.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=Ii(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 ki=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,o;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?o=bi.STYLE_ORANGE_STROKE_TRANSPARENT:(i._dceMNIsBeepBarcode&&di(),i._dceMNIsVibrateBarcode&&ui());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&&(o=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&&(o=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&&(o=bi.STYLE_BLUE_STROKE_TRANSPARENT);break;default:continue}s.addDrawingItems([new Bi({points:n},o)])}};var Ui,Vi,Gi,Wi;!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"}(Ui||(Ui={})),function(e){e[e.DIS_DEFAULT=1]="DIS_DEFAULT",e[e.DIS_SELECTED=2]="DIS_SELECTED"}(Vi||(Vi={})),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"}(Gi||(Gi={})),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"}(Wi||(Wi={}));var ji=Object.freeze({__proto__:null,Beep:li,Camera:ti,CameraEnhancer:hi,CameraEnhancerModule:{getVersion:()=>"5.0.0-dev-2026080315080"},CameraView:_i,DrawingItem:Ni,DrawingLayer:Oi,DrawingStyleManager:bi,get EnumDrawingItemMediaType(){return Ui},get EnumDrawingItemState(){return Vi},get EnumEnhancedFeatures(){return Gi},get EnumPixelFormat(){return Wi},Feedback:Ri,FramePipeline:ci,ImageDrawingItem:Pi,LineDrawingItem:Mi,QuadDrawingItem:Bi,RectDrawingItem:Fi,TextDrawingItem:xi,_bufferToCanvas:Ii,_distToSegment:function(e,t){const[i,s]=e,[[n,o],[r,a]]=t,c=r-n,l=a-o,d=c*c+l*l;if(0===d)return Math.sqrt((i-n)**2+(s-o)**2);let u=((i-n)*c+(s-o)*l)/d;u=Math.max(0,Math.min(1,u));const h=i-(n+u*c),_=s-(o+u*l);return Math.sqrt(h*h+_*_)},_isPointInPolygon:Li,beep:di,stringToHtml:Zt,vibrate:ui});const Zi="undefined"==typeof self,Hi=Zi?{}:self,qi="function"==typeof importScripts,Yi=(()=>{if(!qi){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"./"}})(),zi=e=>e&&"object"==typeof e&&"function"==typeof e.then,$i=(async()=>{})().constructor;let Ki=class extends $i{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,zi(e)?t=e:"function"==typeof e&&(t=new $i(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&&(zi(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};const Xi=" is not allowed to change after `createInstance` or `loadWasm` is called.",Qi=!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"))||"",Ji=(e,t)=>{const i=e;if(i._license!==t){if(!i._pLoad.isEmpty)throw new Error("`license`"+Xi);i._license=t}};!Zi&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword");const es=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},ts=(e,t)=>{t=es(t);const i=e;if(i._licenseServer!==t){if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+Xi);i._licenseServer=t}},is=(e,t)=>{t=t||"";const i=e;if(i._deviceFriendlyName!==t){if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+Xi);i._deviceFriendlyName=t}};let ss,ns,os,rs,as;"undefined"!=typeof navigator&&(ss=navigator,ns=ss.userAgent,os=ss.platform,rs=ss.mediaDevices),function(){if(!Zi){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:ss.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:os,search:"Win"},Mac:{str:os},Linux:{str:os}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let o=n.str||ns,r=n.search||t,a=n.verStr||ns,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=o.indexOf(r)){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||ns,o=i.search||e;if(-1!=s.indexOf(o)){n=e;break}}"Linux"==n&&-1!=ns.indexOf("Windows NT")&&(n="HarmonyOS"),as={browser:i,version:s,OS:n}}Zi&&(as={browser:"ssr",version:0,OS:"ssr"})}(),rs&&rs.getUserMedia,"Chrome"===as.browser&&as.version>66||"Safari"===as.browser&&as.version>13||"OPR"===as.browser&&as.version>43||"Edge"===as.browser&&as.version;const cs=new Ki,ls=async()=>(cs.isEmpty&&(cs.task=async(e,t)=>{await Ne.loadWasm();let{lt:i,l:s,ls:n,sp:o,rmk:r,cv:a}=((e,t=!1)=>{const i=e;if(i._pLoad.isEmpty){let s,n,o,r=i._license||"",a=JSON.parse(JSON.stringify(i._licenseServer)),c=i._sessionPassword,l=0;if(r.startsWith("t")||r.startsWith("f"))l=0;else if(0===r.length||r.startsWith("P")||r.startsWith("L")||r.startsWith("Y")||r.startsWith("A"))l=1;else{l=2;const t=r.indexOf(":");-1!=t&&(r=r.substring(t+1));const i=r.indexOf("?");if(-1!=i&&(n=r.substring(i+1),r=r.substring(0,i)),r.startsWith("DLC2"))l=0;else{if(r.startsWith("DLS2")){let t;try{let e=r.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(r=t.handshakeCode?t.handshakeCode:t.organizationID?t.organizationID:"","number"==typeof r&&(r=JSON.stringify(r)),0===a.length){let e=[];t.mainServerURL&&(e[0]=t.mainServerURL),t.standbyServerURL&&(e[1]=t.standbyServerURL),a=es(e)}!c&&t.sessionPassword&&(c=t.sessionPassword),s=t.remark}r&&"200001"!==r&&!r.startsWith("200001-")||(l=1)}}if(l&&(t||(Hi.crypto||(o="Please upgrade your browser to support online key."),Hi.crypto.subtle||(o="Require https to use online key in this browser."))),o)throw new Error(o);return 1===l&&console.warn("Applying for a public trial license ..."),{lt:l,l:r,ls:a,sp:c,rmk:s,cv:n}}throw new Error("Can't preprocess license again"+Xi)})(us);const c="undefined"!=typeof self?self:{};let l;us._pLoad.task=cs,(async()=>{try{await us._pLoad}catch(e){}})(),i&&(c.dyarm||(c.dyarm={}),c.dyarm[s]?l=(await c.dyarm[s]).ar:c.dyarm[s]=(async()=>(await cs,c.dyarm[s]=await ds(),c.dyarm[s]))());let d=Ce();Te[d]=s=>{var n;if(s.message&&us._onAuthMessage){let e=us._onAuthMessage(s.message);null!=e&&(s.message=e)}let o,r=!1;if(1===i&&(r=!0),s.success?(we&&(null===(n=Ne._onLog)||void 0===n||n.call(Ne,"init license success")),s.message&&console.warn(s.message),Ne._bSupportIRTModule=s.bSupportIRTModule,Ne._bSupportDce4Module=s.bSupportDce4Module,us.bPassValidation=!0,[0,-10076].includes(s.initLicenseInfo.errorCode)?[-10076].includes(s.initLicenseInfo.errorCode)&&console.warn(s.initLicenseInfo.errorString):t(new Error(s.initLicenseInfo.errorString))):(o=Error(s.message),s.stack&&(o.stack=s.stack),s.ltsErrorCode&&(o.ltsErrorCode=s.ltsErrorCode),r||111==s.ltsErrorCode&&-1!=s.message.toLowerCase().indexOf("trial license")&&(r=!0)),l&&(r=!1),r){const e=L(Ne.engineResourcePaths),t=("DCV"===Ne._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 o=document.createElement("div");o.insertAdjacentHTML("beforeend",n);let r=[];for(let e=0;e<o.childElementCount;++e){let t=o.children[e];t instanceof HTMLStyleElement&&(r.push(t),document.head.append(t))}let a=1==o.childElementCount?o.children[0]:o;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 r)e.remove()}});else if(!l&&e.classList.contains("dls-license-icon-close"))l=e,e.addEventListener("click",()=>{a.remove();for(let e of r)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),o=t.indexOf(")",n);if(-1==i||-1==s||-1==n||-1==o){e.appendChild(new Text(t));break}i>0&&e.appendChild(new Text(t.substring(0,i)));let r=document.createElement("a"),a=t.substring(i+1,s);r.innerText=a;let c=t.substring(n+1,o);r.setAttribute("href",c),r.setAttribute("target","_blank"),e.appendChild(r),t=t.substring(o+1)}}document.body.appendChild(a)}catch(t){e._onLog&&e._onLog(t.message||t)}})({_bNeverShowDialog:us._bNeverShowDialog,engineResourcePath:t,_onLog:Ne._onLog},s.success?"warn":"error",s.message)}s.success?e(void 0):t(o)};const u=await Ne.getModuleVersion();ve.postMessage({type:"l_dynamsoft",body:{v:"DCV"===Ne._bundleEnv?u.CVR.replace(/\.\d+$/,""):u.DBR.replace(/\.\d+$/,""),brtk:!!i,bptk:1===i,l:s,os:as,fn:us.deviceFriendlyName,ls:n,sp:o,rmk:r,cv:a,ar:l,_e:us._e,mliRecord:null===localStorage||void 0===localStorage?void 0:localStorage.getItem("dynamsoft")},id:d})}),await cs),ds=async()=>(cs&&cs.isRejected&&await cs,ve?new Promise((e,t)=>{const i=Ce();Te[i]=async i=>{if(i.success){delete i.success;{let e=us.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)}},ve.postMessage({type:"l_getAR",id:i})}):null);let us=class e{static setLicenseServer(t){ts(e,t)}static get license(){return this._license}static set license(t){Ji(e,t)}static get licenseServer(){return this._licenseServer}static set licenseServer(t){ts(e,t)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(t){is(e,t)}static async initLicense(t,i){if(Ji(e,t),e.bCallInitLicense=!0,"boolean"==typeof i&&i||"object"==typeof i&&i.executeNow)return await ls()}static setDeviceFriendlyName(t){is(e,t)}static getDeviceFriendlyName(){return e._deviceFriendlyName}static async getDeviceUUID(){return await(async()=>(await Ne.loadWasm(),await new Promise((e,t)=>{const i=Ce();Te[i]=i=>{if(i.success)e(i.uuid);else{const e=Error(i.message);i.stack&&(e.stack=i.stack),t(e)}},ve.postMessage({type:"l_getDeviceUUID",id:i})})))()}};us._pLoad=new Ki,us.bPassValidation=!1,us.bCallInitLicense=!1,us._license=Qi,us._licenseServer=[],us._deviceFriendlyName="",us._e=!0,De.license={},De.license.dynamsoft=ls,De.license.getAR=ds,Ne.engineResourcePaths.license={version:"4.6.20-dev-20260813111340",path:Yi,isInternal:!0},De.license.LicenseManager=us;var hs=Object.freeze({__proto__:null,LicenseManager:us,LicenseModule:class{static getVersion(){return`4.6.20-dev-20260813111340(Worker: ${Ae.license&&Ae.license.worker||"Not Loaded"}, Wasm: ${Ae.license&&Ae.license.wasm||"Not Loaded"})`}}});const _s=()=>window.matchMedia("(orientation: landscape)").matches,ms=e=>Object.prototype.toString.call(e).slice(8,-1);function gs(e,t){for(const i in t)"Object"===ms(t[i])&&"Object"===ms(e[i])&&i in e?gs(e[i],t[i]):("cameraFeatures"===i&&(t[i]=Array.isArray(t[i])?t[i]:[t[i]]),e[i]=t[i]);return e}function ps(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 fs(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]=fs(e[i])}else{t={};for(let i in e)e.hasOwnProperty(i)&&(t[i]=fs(e[i]))}return t}function Es(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 ys="undefined"==typeof self,Is="function"==typeof importScripts,vs=(()=>{if(!Is){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"./"}})();Ne.engineResourcePaths.dbr={version:"11.6.20-dev-20260813111358",path:vs,isInternal:!0},De.dbr={};const Rs={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 Cs,Ts,ws,Ss;!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"}(Cs||(Cs={})),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"}(Ts||(Ts={})),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"}(ws||(ws={})),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"}(Ss||(Ss={}));var As=Object.freeze({__proto__:null,BarcodeReaderModule:class{static getVersion(){const e=Ae.dbr&&Ae.dbr.wasm;return`11.6.20-dev-20260813111358(Worker: ${Ae.dbr&&Ae.dbr.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}},EnumBarcodeFormat:Rs,get EnumDeblurMode(){return Ss},get EnumExtendedBarcodeResultType(){return Cs},get EnumLocalizationMode(){return ws},get EnumQRCodeErrorCorrectionLevel(){return Ts}});const Ds="undefined"==typeof self,bs="function"==typeof importScripts,Os=(()=>{if(!bs){if(!Ds&&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"./"}})(),Ls=e=>{if(null==e&&(e="./"),Ds||bs);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},Ns="undefined"==typeof self,Ms="function"==typeof importScripts,Bs=(()=>{if(!Ms){if(!Ns&&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"./"}})();Ne.engineResourcePaths.utility={version:"2.6.20-dev-20260813111350",path:Bs,isInternal:!0};function Fs(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 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"./"}})();Ne.engineResourcePaths.dbr={version:"11.6.10-dev-20260601155910",path:ks,isInternal:!0},De.dbr={};const Us={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 Vs,Gs,Ws,js,Zs;(Zs=Vs||(Vs={}))[Zs.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",Zs[Zs.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",Zs[Zs.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"}(Gs||(Gs={})),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"}(Ws||(Ws={})),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"}(js||(js={}));const Hs=async(e,t)=>{let i,s=document.createElement("canvas"),n=s.getContext("2d"),o=e;try{if(o instanceof Blob){i=URL.createObjectURL(o);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),o=n.getImageData(0,0,s.width,s.height)}else s.width=o.width,s.height=o.height,n.putImageData(o,0,0);if("image/bmp"===t){const e=x(o);return new Blob([e],{type:"image/bmp"})}return await new Promise(e=>{s.toBlob(t=>{e(t)},t)})}finally{URL.revokeObjectURL(i)}};function qs(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 o=(n+1)%e.length;if(i(e[n],e[o],t)<0){s=!1;break}}return s}function Ys(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function zs(e,t){const[i,s]=e,n=i.x,o=i.y,r=s.x,a=s.y,c=t.x,l=t.y,d=(r-n)**2+(a-o)**2;if(0===d)return Math.sqrt((c-n)**2+(l-o)**2);const u=((c-n)*(r-n)+(l-o)*(a-o))/d;if(u<0)return Math.sqrt((c-n)**2+(l-o)**2);if(u>1)return Math.sqrt((c-r)**2+(l-a)**2);{const e=n+u*(r-n),t=o+u*(a-o);return Math.sqrt((c-e)**2+(l-t)**2)}}function $s(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 Ks(e){const[t,i]=e;return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}function Xs(e,t,i,s){const n=t.x-e.x,o=t.y-e.y,r=s.x-i.x,a=s.y-i.y,c=(-o*(e.x-i.x)+n*(e.y-i.y))/(-r*o+n*a),l=(r*(e.y-i.y)-a*(e.x-i.x))/(-r*o+n*a);return c>=0&&c<=1&&l>=0&&l<=1?{x:e.x+l*n,y:e.y+l*o}:null}function Qs(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 Js(e,t,i){let s=t.x-e.x,n=t.y-e.y,o=i.x-e.x;return s*(i.y-e.y)-n*o>0}function en(e,t){for(let i=0;i<4;i++)if(!Js(e.points[i],e.points[(i+1)%4],t))return!1;return!0}function tn(e,t,i,s){const n=e.points,o=t.points;let r=8*i;r=Math.max(r,5);const a=$s(n)[3],c=$s(n)[1],l=$s(o)[3],d=$s(o)[1];let u,h=0;if(u=Math.max(Math.abs(zs(a,t.points[0])),Math.abs(zs(a,t.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(zs(c,t.points[1])),Math.abs(zs(c,t.points[2]))),u>h&&(h=u),u=Math.max(Math.abs(zs(l,e.points[0])),Math.abs(zs(l,e.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(zs(d,e.points[1])),Math.abs(zs(d,e.points[2]))),u>h&&(h=u),h>r)return!1;const _=Ks($s(n)[0]),m=Ks($s(n)[2]),g=Ks($s(o)[0]),p=Ks($s(o)[2]),f=Ys(_,p),E=Ys(g,m),y=f>E,I=Math.min(f,E),v=Ys(_,m),R=Ys(g,p);let C=12*i;return C=Math.max(C,5),C=Math.min(C,v),C=Math.min(C,R),!!(I<C||qs(n,y?g:p)||qs(o,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=Qs(s.points),!0)}class sn{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),o=new Array(4).fill(0),r=0,a=0;for(let e=0;e<4;++e)n[e]=Math.round(100*(s.points[e].x-i.points[e].x))/100,r+=n[e],o[e]=Math.round(100*(s.points[e].y-i.points[e].y))/100,a+=o[e];r/=4,a/=4;for(let e=0;e<4;++e){if(Math.abs(n[e]-r)>this.strictLimit||Math.abs(r)>.8)return!1;if(Math.abs(o[e]-a)>this.strictLimit||Math.abs(a)>.8)return!1}return t.x=r,t.y=a,!0}isLocationOverlap(e,t){if(this.locationArea>t){for(let t=0;t<4;t++)if(en(this.location,e.points[t]))return!0;const t=this.getCenterPoint(e.points);if(en(this.location,t))return!0}else{for(let t=0;t<4;t++)if(en(e,this.location.points[t]))return!0;if(en(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],o=0===e||3===e?s:n;if(Math.abs(zs(o,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 o=Xs(e[s],e[(s+1)%4],t[n],t[(n+1)%4]);o&&i.push(o)}return e.forEach(e=>{qs(t,e)&&i.push(e)}),t.forEach(t=>{qs(e,t)&&i.push(t)}),Qs(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 nn,on,rn,an,cn,ln;const dn={barcode:2,text_line:4,detected_quad:8,deskewed_image:16},un=(e,t)=>"string"==typeof e?t[dn[e]]:t[e],hn=(e,t,i)=>{"string"==typeof e?t[dn[e]]=i:t[e]=i},_n=(e,t,i)=>{const s=[{type:ne.CRIT_BARCODE,resultName:"decodedBarcodesResult",itemNames:["barcodeResultItems"]},{type:ne.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},mn=e=>{const t=[];return e&ne.CRIT_BARCODE&&t.push(ne.CRIT_BARCODE),e&ne.CRIT_TEXT_LINE&&t.push(ne.CRIT_TEXT_LINE),e&ne.CRIT_DETECTED_QUAD&&t.push(ne.CRIT_DETECTED_QUAD),e&ne.CRIT_DESKEWED_IMAGE&&t.push(ne.CRIT_DESKEWED_IMAGE),t};class gn{constructor(){this.verificationEnabled={[ne.CRIT_BARCODE]:!1,[ne.CRIT_TEXT_LINE]:!0,[ne.CRIT_DETECTED_QUAD]:!0,[ne.CRIT_DESKEWED_IMAGE]:!1},this.duplicateFilterEnabled={[ne.CRIT_BARCODE]:!1,[ne.CRIT_TEXT_LINE]:!1,[ne.CRIT_DETECTED_QUAD]:!1,[ne.CRIT_DESKEWED_IMAGE]:!1},this.duplicateForgetTime={[ne.CRIT_BARCODE]:3e3,[ne.CRIT_TEXT_LINE]:3e3,[ne.CRIT_DETECTED_QUAD]:3e3,[ne.CRIT_DESKEWED_IMAGE]:3e3},this.crossVerificationCriteria={[ne.CRIT_BARCODE]:{frameWindow:5,minConsistentFrames:2},[ne.CRIT_TEXT_LINE]:{frameWindow:5,minConsistentFrames:2},[ne.CRIT_DETECTED_QUAD]:{frameWindow:6,minConsistentFrames:4},[ne.CRIT_DESKEWED_IMAGE]:{frameWindow:6,minConsistentFrames:4}},nn.set(this,new Map),on.set(this,new Map),rn.set(this,new Map),an.set(this,new Map),cn.set(this,new Map),ln.set(this,new Map),this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,this.latestOverlappingEnabled={[ne.CRIT_BARCODE]:!1,[ne.CRIT_TEXT_LINE]:!1,[ne.CRIT_DETECTED_QUAD]:!1,[ne.CRIT_DESKEWED_IMAGE]:!1},this.maxOverlappingFrames={[ne.CRIT_BARCODE]:this.crossVerificationFrames,[ne.CRIT_TEXT_LINE]:this.crossVerificationFrames,[ne.CRIT_DETECTED_QUAD]:this.crossVerificationFrames,[ne.CRIT_DESKEWED_IMAGE]:this.crossVerificationFrames},Object.defineProperties(this,{onOriginalImageResultReceived:{value:e=>{},writable:!1},onDecodedBarcodesReceived:{value:e=>{this.latestOverlappingFilter(e),_n(this,e,ne.CRIT_BARCODE)},writable:!1},onRecognizedTextLinesReceived:{value:e=>{_n(this,e,ne.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===ne.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(){Fs(this,nn,"f").forEach((e,t)=>{hn(t,this.verificationEnabled,e)}),Fs(this,on,"f").forEach((e,t)=>{hn(t,this.duplicateFilterEnabled,e)}),Fs(this,rn,"f").forEach((e,t)=>{hn(t,this.duplicateForgetTime,e)}),Fs(this,an,"f").forEach((e,t)=>{hn(t,this.latestOverlappingEnabled,e)}),Fs(this,cn,"f").forEach((e,t)=>{hn(t,this.maxOverlappingFrames,e)}),Fs(this,ln,"f").forEach((e,t)=>{hn(t,this.crossVerificationCriteria,e)})}enableResultCrossVerification(e,t=!0){if("number"==typeof e){const i=mn(e);for(let e of i)Fs(this,nn,"f").set(e,t)}else Fs(this,nn,"f").set(e,t)}isResultCrossVerificationEnabled(e){return un(e,this.verificationEnabled)}enableResultDeduplication(e,t=!0){if(t&&this.enableLatestOverlapping(e,!1),"number"==typeof e){const i=mn(e);for(let e of i)Fs(this,on,"f").set(e,t)}else Fs(this,on,"f").set(e,t)}isResultDeduplicationEnabled(e){return un(e,this.duplicateFilterEnabled)}setDuplicateForgetTime(e,t){if(t>18e4&&(t=18e4),t<0&&(t=0),"number"==typeof e){const i=mn(e);for(let e of i)Fs(this,rn,"f").set(e,t)}else Fs(this,rn,"f").set(e,t)}getDuplicateForgetTime(e){return un(e,this.duplicateForgetTime)}getFilteredResultItemTypes(){let e=0;const t=[ne.CRIT_BARCODE,ne.CRIT_TEXT_LINE,ne.CRIT_DETECTED_QUAD,ne.CRIT_DESKEWED_IMAGE,ne.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=mn(e);for(let e of s)Fs(this,ln,"f").set(e,{frameWindow:t,minConsistentFrames:i})}else Fs(this,ln,"f").set(e,{frameWindow:t,minConsistentFrames:i})}getResultCrossVerificationCriteria(e){return un(e,this.crossVerificationCriteria)}enableLatestOverlapping(e,t=!0){if(t&&this.enableResultDeduplication(e,!1),"number"==typeof e){const i=mn(e);for(let e of i)Fs(this,an,"f").set(e,t)}else Fs(this,an,"f").set(e,t)}isLatestOverlappingEnabled(e){return un(e,this.latestOverlappingEnabled)}setMaxOverlappingFrames(e,t){if("number"==typeof e){const i=mn(e);for(let e of i)Fs(this,cn,"f").set(e,t)}else Fs(this,cn,"f").set(e,t)}getMaxOverlappingFrames(e){return un(e,this.maxOverlappingFrames)}latestOverlappingFilter(e){var t,i,s;const n=this.isResultCrossVerificationEnabled(ne.CRIT_BARCODE),o=this.isLatestOverlappingEnabled(ne.CRIT_BARCODE);if(o){const r=this.crossVerificationFrames,a=60,c=o?this.getMaxOverlappingFrames(ne.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),p=0;const f=e.items.map(e=>{if(1!==e.type){const t=(BigInt(e.format)&BigInt(Us.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0);return new sn(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(!f[t])continue;const o=f[t].item;for(let r=0;r<this.overlapSet.length;r++){if(e[t][r]<1)continue;const a=this.overlapSet[r],c=a.item;if(o.format===c.format&&o.text===c.text){if(n=a.isProbablySameLocationWithOffset(f[t],i),n){s[t]=r,e[t][r]=0;break}}else e[t][r]=0}if(n)break}if(n){for(let n=0;n<l;n++){if(n===t||!f[n])continue;const o=f[n].item;for(let t=0;t<this.overlapSet.length;t++){if(e[n][t]<1)continue;if(s.includes(t))continue;const r=this.overlapSet[t],a=r.item;if(o.format===a.format&&o.text===a.text){if(r.isMatchedLocationWithOffset(f[n],i)){s[n]=t,e[n][t]=0;break}}else e[n][t]=0}}const n=s.filter(e=>-1!==e).length;n>p&&(p=n,g=s,m.x=i.x,m.y=i.y)}}if(0===p){for(let t=0;t<l;t++){const i=f[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],o=n.item;if(i.format===o.format&&i.text===o.text){if(n.isMatchedLocationWithOffset(f[t])){g[t]=s,e[t][s]=0;break}}else e[t][s]=0}}p+=g.filter(e=>-1!=e).length}let i=this.overlapSet.length<=3?p>=1:p>=2;if(!i&&o&&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(Us.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0),o=e.confidence<a,r=new sn(c,s?1:2,s,i);n&&s&&o&&_.push(t),this.overlapSet.push(r)}});else{let t=!0;o?(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&&f[i]){const e=f[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 o=this.overlapSet[n].item.text,r=this.overlapSet[n].item.format;if(e.format===r&&e.text===o){if(this.overlapSet[n].isOverlappedLocationWithOffset(e,m,!1)){const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(Us.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0),o=s?1:2;this.overlapSet[n]=new sn(c,o,s,t),g[i]=n;break}if(f[i].isOneD){let o={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++)o.points[e].x=t?this.overlapSet[n].location.points[e].x:this.overlapSet[n].location.points[e].x+m.x,o.points[e].y=t?this.overlapSet[n].location.points[e].y:this.overlapSet[n].location.points[e].y+m.y;let r={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};if(tn(s,o,e.moduleSize,r)){e.location=r;const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(Us.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0),o=s?1:2;this.overlapSet[n]=new sn(c,o,s,t),g[i]=n;break}}}}}else{if(t)f[i]&&(f[i].item.location=this.overlapSet[e].location);else{const t=Object.assign({},f[i].item),s=(BigInt(t.format)&BigInt(Us.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0),n=s?1:2;this.overlapSet[e]=new sn(c,n,s,t)}this.overlapSet[e]&&(this.overlapSet[e].overlapCount=c,this.overlapSet[e].verificationCount=2,this.overlapSet[e].crossVerificationFrame=r)}}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(o&&n>0){for(let e=0;e<l;e++)if(s.isOverlappedLocationWithOffset(f[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(o&&!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]||!f[e])continue;const i=f[e].item;if(t){for(let t=0;t<4;t++)f[e].location.points[t].x-=m.x,f[e].location.points[t].y-=m.y;i.location=f[e].location}let s=!1;for(let t of this.overlapSet)if(!(t.crossVerificationFrame<=0&&t.verificationCount<=0)&&(s=t.isLocationOverlap(f[e].location,f[e].locationArea),s))break;if(s){_.push(e);continue}const o=Object.assign({},i),r=(BigInt(i.format)&BigInt(Us.BF_ONED))!=BigInt(0)||(BigInt(i.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0),l=i.confidence<a,d=new sn(c,r?1:2,r,o);n&&r&&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 pn,fn,En,yn;nn=new WeakMap,on=new WeakMap,rn=new WeakMap,an=new WeakMap,cn=new WeakMap,ln=new WeakMap;class In{static async readFromFile(e){if("string"==typeof e){if(!O(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 k(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=P(e);return N(s,t,i)}static async readFromMemory(e){if(!Fs(pn,pn,"f",fn).has(e))throw new Error("Image data ID does not exist.");return Fs(pn,pn,"f",fn).get(e)}static async saveToMemory(e,t){var i,s,n;const o=await Hs(e,t),r=await k(o),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=pn,pn,(n=Fs(i,pn,"f",En),s=n++,n),0,En),s);return Fs(pn,pn,"f",fn).set(a,r),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 k(t)}static async saveToBase64String(e,t){e instanceof Blob&&(e=await k(e));let i=P(e);const s=await Hs(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)}}pn=In,fn={value:new Map},En={value:0};!function(e){e[e.LP_UNKNOWN=0]="LP_UNKNOWN",e[e.LP_LINES=1]="LP_LINES",e[e.LP_MATRIX=2]="LP_MATRIX"}(yn||(yn={}));const vn={pattern:yn.LP_UNKNOWN,axes:[{elementCount:-1,isStaggered:!1,angle:-1,isEqualSpacing:!1,spacing:-1,spacingUnit:ye.MU_PIXEL},{elementCount:-1,isStaggered:!1,angle:-1,isEqualSpacing:!1,spacing:-1,spacingUnit:ye.MU_PIXEL}],inputImageWidth:0,inputImageHeight:0};var Rn,Cn;!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"}(Rn||(Rn={})),function(e){e[e.LES_NONE=0]="LES_NONE",e[e.LES_INPUT=1]="LES_INPUT",e[e.LES_INFERRED=2]="LES_INFERRED"}(Cn||(Cn={}));var Tn,wn,Sn=Object.freeze({__proto__:null,get EnumFilterType(){return Rn},get EnumLayoutElementSource(){return Cn},get EnumLayoutPattern(){return yn},ImageDrawer:class{static async drawOnImage(e,t,i,s=4294901760,n=1,o="test.png",r){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 k(e);else if("string"==typeof e){let t=await b(e,"blob");a=await k(t)}else S(e)&&(a=e,"bigint"==typeof a.format&&(a.format=Number(a.format)));return await new Promise((e,c)=>{let l=Ce();Te[l]=async t=>{if(t.success)return r&&In.saveToFile(t.image,o,r),e(t.image);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,c(e)}},ve.postMessage({type:"utility_drawOnImage",id:l,body:{dsImage:a,drawingItem:Array.isArray(t)?t:[t],color:s,thickness:n,type:i}})})}},ImageIO:In,ImageProcessor:class{static async cropImage(e,t){const{bytes:i,width:s,height:n,stride:o,format:r}=S(e)?e:await k(e);return await new Promise((e,a)=>{let c=Ce();Te[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)}},ve.postMessage({type:"utility_cropImage",id:c,body:{type:"Rect",bytes:i,width:s,height:n,stride:o,format:r,roi:t}})})}static async adjustBrightness(e,t){const{bytes:i,width:s,height:n,stride:o,format:r}=S(e)?e:await k(e);return await new Promise((e,a)=>{let c=Ce();Te[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)}},ve.postMessage({type:"utility_adjustBrightness",id:c,body:{bytes:i,width:s,height:n,stride:o,format:r,brightness:t}})})}static async adjustContrast(e,t){const{bytes:i,width:s,height:n,stride:o,format:r}=S(e)?e:await k(e);return await new Promise((e,a)=>{let c=Ce();Te[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)}},ve.postMessage({type:"utility_adjustContrast",id:c,body:{bytes:i,width:s,height:n,stride:o,format:r,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:o,format:r}=S(e)?e:await k(e);return await new Promise((e,a)=>{let c=Ce();Te[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)}},ve.postMessage({type:"utility_filterImage",id:c,body:{bytes:i,width:s,height:n,stride:o,format:r,filterType:t}})})}static async convertToGray(e,t,i,s){const{bytes:n,width:o,height:r,stride:a,format:c}=S(e)?e:await k(e);return await new Promise((e,l)=>{let d=Ce();Te[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)}},ve.postMessage({type:"utility_convertToGray",id:d,body:{bytes:n,width:o,height:r,stride:a,format:c,R:t,G:i,B:s}})})}static async convertToBinaryGlobal(e,t=-1,i=!1){const{bytes:s,width:n,height:o,stride:r,format:a}=S(e)?e:await k(e);return await new Promise((e,c)=>{let l=Ce();Te[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)}},ve.postMessage({type:"utility_convertToBinaryGlobal",id:l,body:{bytes:s,width:n,height:o,stride:r,format:a,threshold:t,invert:i}})})}static async convertToBinaryLocal(e,t=0,i=10,s=!1){const{bytes:n,width:o,height:r,stride:a,format:c}=S(e)?e:await k(e);return await new Promise((e,l)=>{let d=Ce();Te[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)}},ve.postMessage({type:"utility_convertToBinaryLocal",id:d,body:{bytes:n,width:o,height:r,stride:a,format:c,blockSize:t,compensation:i,invert:s}})})}static async cropAndDeskewImage(e,t,i=0,s=0,n=0){const{bytes:o,width:r,height:a,stride:c,format:l}=S(e)?e:await k(e);return await new Promise((e,d)=>{let u=Ce();Te[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)}},ve.postMessage({type:"utility_cropAndDeskewImage",id:u,body:{bytes:o,width:r,height:a,stride:c,format:l,roi:t,dstWidth:i,dstHeight:s,padding:n}})})}},LayoutAnalyzer:class{static async analyze(e,t){return Object.assign(vn,t),await new Promise(async(t,i)=>{let s=Ce();Te[s]=e=>{if(!e.success){let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}t(e.analyzeResult)},ve.postMessage({type:"utility_analyze",id:s,body:{inputQuads:e,parameter:vn}})})}},MultiFrameResultCrossFilter:gn,UtilityModule:class{static getVersion(){return`2.6.20-dev-20260813111350(Worker: ${Ae.utility&&Ae.utility.worker||"Not Loaded"}, Wasm: ${Ae.utility&&Ae.utility.wasm||"Not Loaded"})`}}}),An=new WeakMap,Dn=new WeakMap,bn=new WeakMap,On=new WeakMap,Ln=new WeakMap,Nn=new WeakMap,Mn=new WeakMap,Bn=new WeakMap,Fn=new WeakMap,xn=new WeakMap,Pn=new WeakSet;class kn{constructor(t){if(r(this,Pn),a(this,"_cameraEnhancer",void 0),a(this,"_cameraView",void 0),a(this,"_cvRouter",void 0),n(this,An,!1),n(this,Dn,void 0),n(this,bn,void 0),n(this,On,void 0),n(this,Ln,void 0),n(this,Nn,new Map),n(this,Mn,[]),n(this,Bn,void 0),n(this,Fn,new Pe),n(this,xn,{status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},barcodeResults:[]}),a(this,"config",fs(Be)),t&&"object"!=typeof t||Array.isArray(t))throw new Error("Invalid config.");o(Bn,this,t),gs(this.config,t)}get disposed(){return s(An,this)}async launch(){if(s(An,this))throw new Error("The BarcodeScanner instance has been destroyed.");if(t(kn,wn,lo)._&&!t(kn,wn,lo)._.isFulfilled&&!t(kn,wn,lo)._.isRejected)throw new Error("Cannot call `launch()` while a previous task is still running.");if(lo._=t(kn,wn,new Pe),!us.getDeviceFriendlyName())try{us.setDeviceFriendlyName("dbr_rtu")}catch{}return t(Pn,this,Un).call(this),t(kn,wn,lo)._}async decode(e,i){if(this.disposed)return Promise.reject(new Error("Cannot call decode on a disposed instance. This instance was disposed after launch completed."));const n=new Ft;try{await t(Pn,this,Vn).call(this,!0),s(Ln,this)||o(Ln,this,new gn),s(Ln,this).enableResultCrossVerification(2,!1),await this._cvRouter.addResultFilter(s(Ln,this)),n.onCapturedResultReceived=()=>{},this._cvRouter.addResultReceiver(n),i||(i=this.config.utilizedTemplateNames.image);return await this._cvRouter.capture(e,i)}catch(e){throw e}finally{var r;s(Ln,this)&&(s(Ln,this).enableResultCrossVerification(2,!0),await this._cvRouter.addResultFilter(s(Ln,this))),null===(r=this._cvRouter)||void 0===r||r.removeResultReceiver(n)}}dispose(){var e,i,n,r,a,c,l;o(An,this,!0),t(kn,wn,lo)._&&t(kn,wn,lo)._.isPending&&t(kn,wn,lo)._.resolve(s(xn,this)),null===(e=this._cameraEnhancer)||void 0===e||e.dispose(),null===(i=this._cameraView)||void 0===i||i.dispose(),null===(n=this._cvRouter)||void 0===n||n.dispose(),this._cameraEnhancer=null,this._cameraView=null,this._cvRouter=null,null===(r=document.querySelector(".scanner-view-container"))||void 0===r||r.remove(),null===(a=document.querySelector(".result-view-container"))||void 0===a||a.remove(),null===(c=document.querySelector(".barcode-scanner-container"))||void 0===c||c.remove(),null===(l=document.querySelector(".loading-page"))||void 0===l||l.remove();for(let[e,t]of s(Nn,this))for(let i of t)window.removeEventListener(e,i);s(Nn,this).clear();for(let e of s(Mn,this))document.head.removeChild(e);o(Mn,this,[])}}async function Un(){try{if(this.config.onInitPrepare&&this.config.onInitPrepare(),this.disposed)return;if(await t(Pn,this,Vn).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...",await this._cameraEnhancer.open(),ps(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(i){t(Pn,this,no).call(this,{auto:!1,open:!1,close:!1,notSupport:!1});const s=document.querySelector(".camera-control");s&&(s.style.display="none");const n=document.querySelector(".no-camera-view");if(n&&(n.style.display="flex"),this.config.onCameraOpenFailed&&this.config.onCameraOpenFailed(i),e=!0,this.disposed)return}if(this.config.autoStartCapturing&&!e&&(await this._cvRouter.startCapturing(s(bn,this)),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed))return}catch(i){s(xn,this).status={code:e.EnumResultStatus.RS_FAILED,message:i.message||i},t(Tn,wn,lo)._.reject(new Error(s(xn,this).status.message)),this.dispose()}finally{t(Pn,this,oo).call(this,"Loading...",!1)}}async function Vn(i=!1){Ne.engineResourcePaths=this.config.engineResourcePaths;const n=L(Ne.engineResourcePaths);if(!i){let i=t(Tn,wn,uo)._.get("dceUI");if(i||(i=await b(n.dbrBundle+"ui/dce.rtu.ui.xml","text"),t(Tn,wn,uo)._.set("dceUI",i)),this.disposed)return;if(this._cameraView=await _i.createInstance(i),this.disposed)return;if(this.config.scanMode===e.EnumScanMode.SM_SINGLE||this.config.scannerViewConfig.customHighlightForBarcode){this._cameraView.getDrawingLayer(2).setVisible(!1)}if(this._cameraEnhancer=await hi.createInstance(this._cameraView),this.disposed)return;if(await t(Pn,this,Wn).call(this),this.disposed)return;this.config.scannerViewConfig.customHighlightForBarcode&&o(On,this,this._cameraEnhancer.getCameraView().createDrawingLayer())}if([null,void 0].includes(this.config.license)||(us._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)"),await us.initLicense(this.config.license,{executeNow:!0})),this.disposed)return;if(this._cvRouter=this._cvRouter||await St.createInstance(!1),this._cvRouter._s=!0,this.disposed)return;let r=t(Tn,wn,uo)._.get("presetTemplates");if(r||(r=await b(n.dbrBundle+"templates/DBR-PresetTemplates.json","text"),t(Tn,wn,uo)._.set("presetTemplates",r)),!s(Fn,this).isPending||(await this._cvRouter.initSettings(r),await t(Pn,this,Gn).call(this,i),!this.disposed)){if(!i){if(this._cvRouter.setInput(this._cameraEnhancer),t(Pn,this,Kn).call(this),await t(Pn,this,Xn).call(this),this.disposed)return;this._cvRouter.onCaptureError=e=>{t(Tn,wn,lo)._.reject(new Error(e.message)),this.dispose()},this._cvRouter._dynamsoft=!(this.config.scanMode===e.EnumScanMode.SM_SINGLE)}s(Fn,this).resolve()}}async function Gn(i=!1){let n=this.config.templateFilePath;if(n){let e,i=!1;if(Vt(n)&&(i=n.reloadResource,n=n.path),i)e=await b(n,"text"),t(Tn,wn,uo)._.delete("templateFile");else{e=t(Tn,wn,uo)._.get("templateFile"),e||(e=await b(n,"text"),t(Tn,wn,uo)._.set("templateFile",e)),e=JSON.parse(e);const i=e.CaptureVisionTemplates[0].Name;s(Bn,this).utilizedTemplateNames?(s(Bn,this).utilizedTemplateNames.image||(this.config.utilizedTemplateNames.image=i),s(Bn,this).utilizedTemplateNames.multi_unique||(this.config.utilizedTemplateNames.multi_unique=i),s(Bn,this).utilizedTemplateNames.single||(this.config.utilizedTemplateNames.single=i)):this.config.utilizedTemplateNames={image:i,multi_unique:i,single:i}}if(this.disposed)return;if(await this._cvRouter.initSettings(e),this.disposed)return}const r=await this._cvRouter.outputSettings("*",!0);if(this.disposed)return;if(!i&&this.config.scanMode===e.EnumScanMode.SM_SINGLE)for(let e of r.CaptureVisionTemplates)e.OutputOriginalImage=1;let a=this.config.barcodeFormats;if(a){Array.isArray(a)||(a=[a]);const e=(e,t)=>t!==BigInt(0)&&(e&t)===t;for(let t of r.BarcodeReaderTaskSettingOptions){t.BarcodeFormatIds=[];for(let i in Rs)for(let s in a)e(a[s],Rs[i])&&t.BarcodeFormatIds.push(i)}}await this._cvRouter.initSettings(r),this.disposed||i||(this.config.scanMode===e.EnumScanMode.SM_SINGLE?o(bn,this,this.config.utilizedTemplateNames.single):this.config.scanMode===e.EnumScanMode.SM_MULTI_UNIQUE&&o(bn,this,this.config.utilizedTemplateNames.multi_unique))}async function Wn(){let i,n,r=this.config.uiPath||L(this.config.engineResourcePaths).dbrBundle,a=!1;Vt(r)&&(a=r.reloadResource,r=r.path);let c=r.endsWith("/")?Ls(r)+"ui/barcode-scanner.ui.xml":Ls(r).slice(0,-1);if(a?(i=await b(c,"text"),t(Tn,wn,uo)._.delete("dbsUI")):(i=t(Tn,wn,uo)._.get("dbsUI"),i||(i=await b(c,"text"),t(Tn,wn,uo)._.set("dbsUI",i))),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})(i),this.disposed)return;if(n.querySelectorAll("style").forEach(e=>{const t=e.cloneNode(!0);s(Mn,this).push(t),document.head.appendChild(t)}),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)}o(Dn,this,n.querySelector(".result-item")),t(Pn,this,jn).call(this,n),t(Pn,this,Zn).call(this,n),t(Pn,this,Hn).call(this,n),t(Pn,this,qn).call(this,n),await t(Pn,this,Yn).call(this,n),t(Pn,this,so).call(this,n),t(Pn,this,$n).call(this,n),t(Pn,this,zn).call(this,n)}function jn(e){const i=e.querySelector(".btn-clear");var n;if(i&&(i.addEventListener("click",()=>{s(xn,this).barcodeResults=[],t(Pn,this,to).call(this)}),null!==(n=this.config)&&void 0!==n&&null!==(n=n.resultViewConfig)&&void 0!==n&&null!==(n=n.toolbarButtonsConfig)&&void 0!==n&&n.clear)){const t=this.config.resultViewConfig.toolbarButtonsConfig.clear;i.style.display=t.isHidden?"none":"flex",i.className=t.className,i.innerText=t.label,t.isHidden&&(e.querySelector(".toolbar-btns").style.justifyContent="center")}}function Zn(e){const t=e.querySelector(".btn-done");var i;if(t&&(t.addEventListener("click",()=>{const e=document.querySelector(".loading-page");e&&"none"===getComputedStyle(e).display&&this.dispose()}),null!==(i=this.config)&&void 0!==i&&null!==(i=i.resultViewConfig)&&void 0!==i&&null!==(i=i.toolbarButtonsConfig)&&void 0!==i&&i.done)){const i=this.config.resultViewConfig.toolbarButtonsConfig.done;t.style.display=i.isHidden?"none":"flex",t.className=i.className,t.innerText=i.label,i.isHidden&&(e.querySelector(".toolbar-btns").style.justifyContent="center")}}function Hn(t){var i;if(null===(i=this.config)||void 0===i||null===(i=i.scannerViewConfig)||void 0===i?void 0:i.showCloseButton){const i=t.querySelector(".btn-close");i&&(i.style.display="inline",i.addEventListener("click",()=>{s(xn,this).barcodeResults=[],s(xn,this).status={code:e.EnumResultStatus.RS_CANCELLED,message:"Cancelled."},this.dispose()}))}}function qn(e){var i;if(null===(i=this.config)||void 0===i?void 0:i.scannerViewConfig.showFlashButton){const i=e.querySelector(".btn-flash-auto"),s=e.querySelector(".btn-flash-open"),n=e.querySelector(".btn-flash-close");i&&(i.style.display="inline",this._cameraEnhancer.addEventListener("opened",async()=>{if(!this._cameraEnhancer.currentCamera)return void t(Pn,this,no).call(this,{auto:!1,open:!1,close:!1,notSupport:!1});const e=this._cameraEnhancer.isSupportTorch;for(this.config.scannerViewConfig.showFlashButton&&(e?t(Pn,this,no).call(this,{auto:!0,open:!1,close:!1,notSupport:!1}):t(Pn,this,no).call(this,{auto:!1,open:!1,close:!1,notSupport:!0})),await new Promise(e=>setTimeout(e,1e3));null!==(i=this._cameraEnhancer)&&void 0!==i&&i._isOpenBeforeHide;){var i;await new Promise(e=>setTimeout(e,1e3))}this.disposed||this._cameraEnhancer.isOpen()&&e&&this._cameraEnhancer.turnAutoTorch()}),i.addEventListener("click",async()=>{await this._cameraEnhancer.turnOnTorch(),i.style.display="none",s.style.display="inline",n.style.display="none"}),s.addEventListener("click",async()=>{await this._cameraEnhancer.turnOffTorch(),i.style.display="none",s.style.display="none",n.style.display="inline"}),n.addEventListener("click",async()=>{this._cameraEnhancer.turnAutoTorch(),i.style.display="inline",s.style.display="none",n.style.display="none"}))}}async function Yn(e){let i=this.config.scannerViewConfig.cameraSwitchControl;["toggleFrontBack","listAll","hidden"].includes(i)||(this.config.scannerViewConfig.cameraSwitchControl="hidden");if("hidden"!==this.config.scannerViewConfig.cameraSwitchControl){const i=e.querySelector(".camera-control");if(i){i.style.display="block";const n=await this._cameraEnhancer.getAllCameras(),o=this.config.scannerViewConfig.cameraSwitchControl,r=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"===o){const i=e.querySelector(".camera-list");for(let e of n){const t=r(e);i.append(t)}const o=()=>{const e=document.querySelector(".camera-list");e&&(e.style.display="none")},a=s(Nn,this).get("click")||[];s(Nn,this).set("click",[...a,o]),window.addEventListener("click",o);const c=e=>{for(let t of l)t.deviceId===e.deviceId?t.style.color="#FE8E14":t.style.color="#FFFFFF"};i.addEventListener("click",async e=>{e.stopPropagation();const n=e.target;t(Pn,this,oo).call(this,"Accessing Camera...",!0),this._cvRouter.stopCapturing(),await this._cameraEnhancer.selectCamera({deviceId:n.deviceId,label:n.label});const o=this._cameraEnhancer.getSelectedCamera();ps(o)&&this.config.scannerViewConfig.mirrorFrontCamera?this._cameraEnhancer.isMirrored=!0:this._cameraEnhancer.isMirrored=!1,c(o),this.config.onCameraOpen&&this.config.onCameraOpen({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.config.autoStartCapturing&&(await this._cvRouter.startCapturing(s(bn,this)),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter})),t(Pn,this,oo).call(this,"Loading...",!1),i.style.display="none"});const l=e.querySelectorAll(".camera-list div");return async()=>{const e=this._cameraEnhancer.getSelectedCamera();c(e);const t=document.querySelector(".camera-list");"none"===getComputedStyle(t).display?t.style.display="block":t.style.display="none"}}return"toggleFrontBack"===o?async()=>{t(Pn,this,oo).call(this,"Accessing Camera...",!0);const e=ps(this._cameraEnhancer.getSelectedCamera());console.log(e),await this._cameraEnhancer.requestCamera(e?"back":"front");ps(this._cameraEnhancer.getSelectedCamera())?(this.config.scannerViewConfig.mirrorFrontCamera&&(this._cameraEnhancer.isMirrored=!0),this.config.scannerViewConfig.showFlashButton&&t(Pn,this,no).call(this,{auto:!1,open:!1,close:!1,notSupport:!0})):(this._cameraEnhancer.isMirrored=!1,this.config.scannerViewConfig.showFlashButton&&t(Pn,this,no).call(this,{auto:!0,open:!1,close:!1,notSupport:!1})),t(Pn,this,oo).call(this,"Loading...",!1)}:void 0},c=a();i.addEventListener("click",async e=>{e.stopPropagation(),c&&await c()})}}}function zn(t){const i=this._cameraView.getUIElement();this._cameraView.setVideoFit("cover");const n=t.querySelector(".barcode-scanner-container");n.style.display=_s()?"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 r;if(this.config.container?(n.style.position="relative",r=this.config.container):r=document.body,"string"==typeof r&&(r=document.querySelector(r),null===r))throw new Error("Failed to get the container");let a=this.config.scannerViewConfig.container;if("string"==typeof a&&(a=document.querySelector(a),null===a))throw new Error("Failed to get the container of the scanner view.");let c=this.config.resultViewConfig.container;if("string"==typeof c&&(c=document.querySelector(c),null===c))throw new Error("Failed to get the container of the result view.");const l=t.querySelector(".scanner-view-container"),d=t.querySelector(".result-view-container"),u=t.querySelector(".loading-page");l.append(u),a&&(l.append(i),a.append(l)),c&&c.append(d),a||c?a&&!c?(this.config.container||(d.style.position="absolute"),c=d,r.append(d)):!a&&c&&(this.config.container||(l.style.position="absolute"),a=l,l.append(i),r.append(l)):(a=l,c=d,o&&(Object.assign(l.style,{width:_s()?"50%":"100%",height:_s()?"100%":"50%"}),Object.assign(d.style,{width:_s()?"50%":"100%",height:_s()?"100%":"50%"})),l.append(i),r.append(n)),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");const h=()=>{Object.assign(n.style,{display:_s()?"flex":"block"}),!o||this.config.scannerViewConfig.container||this.config.resultViewConfig.container||(Object.assign(a.style,{width:_s()?"50%":"100%",height:_s()?"100%":"50%"}),Object.assign(c.style,{width:_s()?"50%":"100%",height:_s()?"100%":"50%"}))},_=s(Nn,this).get("resize")||[];s(Nn,this).set("resize",[..._,h]),window.addEventListener("resize",h)}function $n(e){var t;null===(t=e.querySelector(".resume"))||void 0===t||t.addEventListener("click",async()=>{var e,t,i;null!==(e=this.config)&&void 0!==e&&null!==(e=e.scannerViewConfig)&&void 0!==e&&e.showCloseButton&&(document.querySelector(".btn-close").style.display="block"),document.querySelector(".features-group").style.display="flex",document.querySelector(".resume").style.display="none",null===(t=this._cameraView.getUIElement().shadowRoot.querySelector(".single-mode-mask"))||void 0===t||t.remove(),null===(i=this._cameraView.getUIElement().shadowRoot.querySelectorAll(".single-barcode-result-option"))||void 0===i||i.forEach(e=>null==e?void 0:e.remove()),await this._cameraEnhancer.resume(),await new Promise(e=>{setTimeout(e,100)}),this._cvRouter.startCapturing(s(bn,this))})}function Kn(){const i=new Ft;i.onCapturedResultReceived=async i=>{if(s(On,this)&&s(On,this).clearDrawingItems(),i.decodedBarcodesResult){if(this.config.scannerViewConfig.customHighlightForBarcode){let e=[];for(let t of i.decodedBarcodesResult.barcodeResultItems)e.push(this.config.scannerViewConfig.customHighlightForBarcode(t));s(On,this).addDrawingItems(e)}this.config.scanMode===e.EnumScanMode.SM_SINGLE?t(Pn,this,Qn).call(this,i):t(Pn,this,Jn).call(this,i)}},this._cvRouter.addResultReceiver(i)}async function Xn(){s(Ln,this)||o(Ln,this,new gn),s(Ln,this).enableResultCrossVerification(2,!0),s(Ln,this).enableResultDeduplication(2,!0),s(Ln,this).setDuplicateForgetTime(2,this.config.duplicateForgetTime),await this._cvRouter.addResultFilter(s(Ln,this)),s(Ln,this).isResultCrossVerificationEnabled=()=>!1,s(Ln,this).isResultDeduplicationEnabled=()=>!1}function Qn(i){const s=this._cameraView.getUIElement().shadowRoot;let n=new Promise(e=>{if(i.decodedBarcodesResult.barcodeResultItems.length>1){t(Pn,this,eo).call(this);let n=[];for(let t of i.decodedBarcodesResult.barcodeResultItems){let i=0,s=0;for(let e=0;e<4;++e){let n=t.location.points[e];i+=n.x,s+=n.y}let o=this._cameraEnhancer.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0}),r=this._cameraEnhancer.videoXY2FixedLT([{x:o.x+i/4,y:o.y+s/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=r[0].left+"px",a.style.top=r[0].top+"px",a.addEventListener("click",()=>{e(t)}),n.push(a)}s.append(...n)}else e(i.decodedBarcodesResult.barcodeResultItems[0])});n.then(async s=>{const n=i.items.filter(e=>e.type===ne.CRIT_ORIGINAL_IMAGE)[0],o=n.imageData,r={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},originalImageResult:o,barcodeImage:(()=>{const e=M(o),t=s.location.points,i=Math.min(...t.map(e=>e.x)),n=Math.min(...t.map(e=>e.y)),r=Math.max(...t.map(e=>e.x)),a=Math.max(...t.map(e=>e.y)),c=r-i,l=a-n,d=document.createElement("canvas");d.width=c,d.height=l;const u=d.getContext("2d");if(!u)return console.warn("Failed to create canvas context."),null;u.beginPath(),u.moveTo(t[0].x-i,t[0].y-n);for(let e=1;e<t.length;e++)u.lineTo(t[e].x-i,t[e].y-n);u.closePath(),u.clip(),u.drawImage(e,-i,-n);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:p.IPF_ABGR_8888}})(),barcodeResults:[s]};t(Pn,this,ro).call(this,s),t(Tn,wn,lo)._.resolve(r),this.dispose()})}function Jn(e){for(let i of e.decodedBarcodesResult.barcodeResultItems){if(!1!==i.duplicate)continue;const e=s(xn,this).barcodeResults.findIndex(e=>`${e.formatString}_${e.text}`==`${i.formatString}_${i.text}`);-1===e?(i.count=1,s(xn,this).barcodeResults.unshift(i),t(Pn,this,to).call(this,i)):(s(xn,this).barcodeResults[e].count++,t(Pn,this,io).call(this,e)),this.config.onUniqueBarcodeScanned&&this.config.onUniqueBarcodeScanned(i)}}function eo(){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()}function to(t){if(!this.config.showResultView)return;const i=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&&(i.style.display="inline"));i.style.display="none";const o=(e=>{const t=s(Dn,this).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")],i=t.findIndex(t=>t.id===`${e.formatString}_${e.text}`);s(xn,this).barcodeResults.splice(i,1),t[i].remove(),0===s(xn,this).barcodeResults.length&&this.config.showPoweredByDynamsoft&&(document.querySelector(".no-result-svg").style.display="inline")}),t})(t);n.insertBefore(o,document.querySelector(".result-item"))}function io(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}function so(i){if(this.config.showUploadImageButton){const n=i.querySelector(".btn-upload-image");n.style.display="flex",n.addEventListener("change",async i=>{const n=i.target.files;if(!n)return;const o={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},barcodeResults:[]};let r=0;t(Pn,this,oo).call(this,`Capturing... [${r}/${n.length}]`,!0);let a=!1;for(let e=0;e<n.length;e++)if(!Es(n[e])){a=!0;break}if(a)return t(Tn,wn,lo)._.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 i of n)try{this._cvRouter.stopCapturing();const a=await this.decode(i,this.config.utilizedTemplateNames.image);if(a.decodedBarcodesResult)if(this.config.scanMode===e.EnumScanMode.SM_MULTI_UNIQUE)for(let e of a.decodedBarcodesResult.barcodeResultItems){const i=s(xn,this).barcodeResults.findIndex(t=>`${t.formatString}_${t.text}`==`${e.formatString}_${e.text}`);-1===i?(e.count=1,s(xn,this).barcodeResults.unshift(e),t(Pn,this,to).call(this,e)):(s(xn,this).barcodeResults[i].count++,t(Pn,this,io).call(this,i)),this.config.onUniqueBarcodeScanned&&this.config.onUniqueBarcodeScanned(e)}else if(a.decodedBarcodesResult.barcodeResultItems)for(let e of a.decodedBarcodesResult.barcodeResultItems){const t=o.barcodeResults.find(t=>`${t.text}_${t.formatString}`==`${e.text}_${e.formatString}`);t?t.count++:(e.count=1,o.barcodeResults.push(e))}t(Pn,this,oo).call(this,`Capturing... [${++r}/${n.length}]`,!0)}catch(i){return o.status={code:e.EnumResultStatus.RS_FAILED,message:i.message||i},t(Tn,wn,lo)._.reject(new Error(o.status.message)),void this.dispose()}t(Pn,this,oo).call(this,"Loading...",!1),this.config.scanMode===e.EnumScanMode.SM_SINGLE?(t(Tn,wn,lo)._.resolve(o),this.dispose()):this._cvRouter.startCapturing(s(bn,this)),i.target.value=""})}}function no(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"}function oo(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")}function ro(e){let t=Ce();Te[t]=()=>{},ve.postMessage({type:"cvr_cc",id:t,instanceID:this._cvRouter._instanceID,body:{text:e.text,strFormat:e.format.toString(),isDPM:e.isDPM}})}Tn=kn;var ao,co,lo={_:null},uo={_:new Map};function ho(e){delete e.moduleId;const t=JSON.parse(e.jsonString).ResultInfo,i=e.fullCodeString,s=e.fieldNames;e.getFieldValue=e=>"fullcodestring"===e.toLowerCase()?i:_o(t,e,"map"),e.getFieldRawValue=e=>"fullcodestring"===e.toLowerCase()?i:_o(t,e,"raw"),e.getFieldMappingStatus=e=>{var i;return null!==(i=mo(t,e))&&void 0!==i?i:ao.MS_NONE},e.getFieldValidationStatus=e=>{var i;return null!==(i=go(t,e))&&void 0!==i?i:co.VS_NONE},e.getAllFieldNames=()=>s,delete e.fieldNames,delete e.fullCodeString}function _o(e,t,i){var s;for(const n of e){if(n.FieldName===t)return"raw"===i&&n.RawValue?n.RawValue:n.Value;if(null===(s=n.ChildFields)||void 0===s?void 0:s.length)for(const e of n.ChildFields){const s=_o(e,t,i);if(void 0!==s)return s}}}function mo(e,t){var i;for(const s of e){if(s.FieldName===t)return s.MappingStatus?Number(ao[s.MappingStatus]):ao.MS_NONE;if(null===(i=s.ChildFields)||void 0===i?void 0:i.length)for(const e of s.ChildFields){const i=mo(e,t);if(void 0!==i)return i}}}function go(e,t){var i;for(const s of e){if(s.FieldName===t)return s.ValidationStatus?co[s.ValidationStatus]:co.VS_NONE;if(null===(i=s.ChildFields)||void 0===i?void 0:i.length)for(const e of s.ChildFields){const i=go(e,t);if(void 0!==i)return i}}}function po(e){if(e.disposed)throw new Error('"CodeParser" instance has been disposed')}wn=kn,function(e){e[e.MS_NONE=0]="MS_NONE",e[e.MS_SUCCEEDED=1]="MS_SUCCEEDED",e[e.MS_FAILED=2]="MS_FAILED"}(ao||(ao={})),function(e){e[e.VS_NONE=0]="VS_NONE",e[e.VS_SUCCEEDED=1]="VS_SUCCEEDED",e[e.VS_FAILED=2]="VS_FAILED"}(co||(co={}));const fo=e=>e&&"object"==typeof e&&"function"==typeof e.then,Eo=(async()=>{})().constructor;class yo extends Eo{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,fo(e)?t=e:"function"==typeof e&&(t=new Eo(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&&(fo(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}class Io{constructor(){this._instanceID=void 0,this.bDestroyed=!1}static async createInstance(){await De.license.dynamsoft(),await Ne.loadWasm();const e=new Io,t=new yo;let i=Ce();return Te[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)}},ve.postMessage({type:"dcp_createInstance",id:i}),t}async dispose(){po(this);let e=Ce();this.bDestroyed=!0,Te[e]=e=>{if(!e.success){let t=new Error(e.message);throw t.stack=e.stack+"\n"+t.stack,t}},ve.postMessage({type:"dcp_dispose",id:e,instanceID:this._instanceID})}get disposed(){return this.bDestroyed}async initSettings(e){if(po(this),e&&["string","object"].includes(typeof e))return"string"==typeof e?e.trimStart().startsWith("{")||(e=await b(e,"text")):"object"==typeof e&&(e=JSON.stringify(e)),await new Promise((t,i)=>{let s=Ce();Te[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)}},ve.postMessage({type:"dcp_initSettings",id:s,instanceID:this._instanceID,body:{settings:e}})});console.error("Invalid settings.")}async resetSettings(){return po(this),await new Promise((e,t)=>{let i=Ce();Te[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},ve.postMessage({type:"dcp_resetSettings",id:i,instanceID:this._instanceID})})}async parse(e,t=""){if(po(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=Ce();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))),Te[n]=async e=>{if(e.success){let t=JSON.parse(e.parseResponse);return t.errorCode?s(new Error(t.errorString)):(ho(t),i(t))}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,s(t)}},ve.postMessage({type:"dcp_parse",id:n,instanceID:this._instanceID,body:{source:e,taskSettingName:t}})})}}const vo="undefined"==typeof self,Ro="function"==typeof importScripts,Co=(()=>{if(!Ro){if(!vo&&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"./"}})();Ne.engineResourcePaths.dcp={version:"3.6.20-dev-20260813111422",path:Co,isInternal:!0},De.dcp={handleParsedResultItem:ho},Te[-4]=async e=>{To.onSpecLoadProgressChanged&&To.onSpecLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class To{static getVersion(){const e=Ae.dcp&&Ae.dcp.wasm;return`3.6.20-dev-20260813111422(Worker: ${Ae.dcp&&Ae.dcp.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}static async loadSpec(e,t){return await Ne.loadWasm(),await new Promise((i,s)=>{let n,o=Ce();if(Te[o]=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)n=new URL(t,location.href).href,n=n.endsWith("/")?n:n+"/";else{const e=L(Ne.engineResourcePaths);n=`${"DBR"===Ne._bundleEnv?e.dbrBundle:e.dcvData}parser-resources/`}let r=(e instanceof Array?e:[e]).map(e=>e.replace(/^MRTD.*$/,"MRTD"));r=r.map(e=>e.replace(/\.data$/i,"")),ve.postMessage({type:"dcp_appendResourceBuffer",id:o,body:{specificationPath:n,specificationNames:r}})})}}var wo;!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"}(wo||(wo={}));var So=Object.freeze({__proto__:null,CodeParser:Io,CodeParserModule:To,get EnumCodeType(){return wo},get EnumMappingStatus(){return ao},get EnumValidationStatus(){return co}});var Ao=Object.freeze({__proto__:null,ImageProcessingModule:class{static getVersion(){return`3.6.20-dev-20260813111438(Worker: ${Ae.dip&&Ae.dip.worker||"Not Loaded"}, Wasm: ${Ae.dip&&Ae.dip.wasm||"Not Loaded"})`}}});Ne._bundleEnv="DBR",St._defaultTemplate="ReadSingleBarcode",Ne.engineResourcePaths.dbrBundle={version:"11.6.2000",path:Os,isInternal:!0},hi.CoreModule=Ne,hi.handleEngineResourcePaths=L,us._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)"),e.BarcodeScanner=kn,e.CVR=Ut,e.Core=Me,e.DBR=As,e.DCE=ji,e.DCP=So,e.DIP=Ao,e.License=hs,e.Utility=Sn,e.isPathConfig=Vt});
|
|
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){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function i(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function s(e,i){return e.get(t(e,i))}function n(e,t,s){i(e,t),t.set(e,s)}function o(e,i,s){return e.set(t(e,i),s),s}function r(e,t){i(e,t),t.add(e)}function a(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}var c,l;e.EnumScanMode=void 0,(c=e.EnumScanMode||(e.EnumScanMode={}))[c.SM_SINGLE=0]="SM_SINGLE",c[c.SM_MULTI_UNIQUE=1]="SM_MULTI_UNIQUE",e.EnumResultStatus=void 0,(l=e.EnumResultStatus||(e.EnumResultStatus={}))[l.RS_SUCCESS=0]="RS_SUCCESS",l[l.RS_CANCELLED=1]="RS_CANCELLED",l[l.RS_FAILED=2]="RS_FAILED";const d=e=>e&&"object"==typeof e&&"function"==typeof e.then,u=(async()=>{})().constructor;function h(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 _(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 m,g,p;"function"==typeof SuppressedError&&SuppressedError,function(e){e[e.BOPM_BLOCK=0]="BOPM_BLOCK",e[e.BOPM_UPDATE=1]="BOPM_UPDATE"}(m||(m={})),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"}(g||(g={})),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"}(p||(p={}));const f="undefined"==typeof self,E="function"==typeof importScripts,y=(()=>{if(!E){if(!f&&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"./"}})(),I=e=>{if(null==e&&(e="./"),f||E);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},v=e=>Object.prototype.toString.call(e),R=e=>Array.isArray?Array.isArray(e):"[object Array]"===v(e),C=e=>"number"==typeof e&&!Number.isNaN(e),T=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),w=e=>!(!T(e)||!C(e.width)||e.width<=0||!C(e.height)||e.height<=0||!C(e.stride)||e.stride<=0||!("format"in e)||"tag"in e&&!A(e.tag)),S=e=>!!w(e)&&e.bytes instanceof Uint8Array,A=e=>null===e||!!T(e)&&!!C(e.imageId)&&"type"in e,D=e=>!!T(e)&&!!C(e.x)&&!!C(e.y),b=async(e,t,i)=>await new Promise((s,n)=>{const o=new XMLHttpRequest;o.responseType=t,o.onloadstart=()=>{i&&i.loadstartCallback&&i.loadstartCallback(o)},o.onloadend=async e=>{i&&i.loadendCallback&&i.loadendCallback(o),o.status<200||o.status>=300?n(o.status):s(o.response)},o.onprogress=e=>{i&&i.progressCallback&&i.progressCallback(e,o)},o.open("GET",e,!0),o.send()}),O=e=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(e),L=e=>{const t={};for(let i in e){if("rootDirectory"===i)continue;let s=i,n=e[s],o=n&&"object"==typeof n&&n.path?n.path:n,r=e.rootDirectory;if(r&&!r.endsWith("/")&&(r+="/"),"object"==typeof n&&n.isInternal)r&&(o=e[s].version?`${r}${U[s]}@${e[s].version}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`:`${r}${U[s]}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`);else{const i=/^@engineRootDirectory(\/?)/;if("string"==typeof o&&(o=o.replace(i,r||"")),"object"==typeof o&&"dwt"===s){const n=e[s].resourcesPath,o=e[s].serviceInstallerLocation;t[s]={resourcesPath:n.replace(i,r||""),serviceInstallerLocation:o.replace(i,r||"")};continue}}t[s]=I(o)}return t},N=async(e,t,i)=>await new Promise(async(s,n)=>{try{const n=t.split(".");let o=n[n.length-1];const r=await F(`image/${o}`,e);n.length<=1&&(o="png");const a=new File([r],t,{type:`image/${o}`});if(i){const e=URL.createObjectURL(a),i=document.createElement("a");i.href=e,i.download=t,i.click()}s(a)}catch(e){n()}}),M=e=>{S(e)&&(e=P(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},B=(e,t)=>{S(t)&&(t=P(t));const i=M(t);let s=new Image,n=i.toDataURL(e);return s.src=n,s},F=async(e,t)=>{S(t)&&(t=P(t));const i=M(t);if("image/bmp"===e){const e=i.getContext("2d"),t=x(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)})},x=e=>{const t=e.width,i=e.height,s=e.data,n=4*Math.floor((24*t+31)/32),o=n*i,r=54+o,a=new ArrayBuffer(r),c=new DataView(a);c.setUint16(0,19778,!0),c.setUint32(2,r,!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,o,!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),o=s[n],r=s[n+1],a=s[n+2];c.setUint8(l++,a),c.setUint8(l++,r),c.setUint8(l++,o)}for(let e=0;e<d;e++)c.setUint8(l++,0)}return a},P=e=>{let t,i=e.bytes;if(!(i&&i instanceof Uint8Array))throw Error("Parameter type error");if(Number(e.format)===p.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)===p.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)===p.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)===p.IPF_BINARY_8||Number(e.format)===p.IPF_BINARY_8_INVERTED){const s=i.length,n=e.width,o=e.height,r=e.stride;t=new Uint8ClampedArray(n*o*4);for(let e=0;e<s;e++){let s=i[e],o=e%r,a=Math.floor(e/r);for(let e=0;e<8;e++){let i=o+e,r=4*(a*n+i);if(i>=n)break;t[r]=t[r+1]=t[r+2]=(128&s)/128*255,t[r+3]=255,s<<=1}}}else if(Number(e.format)===p.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)===p.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),p.IPF_BINARY_8_INVERTED;return new ImageData(t,e.width,e.height)},k=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:p.IPF_ABGR_8888}}finally{URL.revokeObjectURL(t)}},U={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 V,G,W,j,Z,H,q,Y;let z,$,K,X,Q,J=class e{get _isFetchingStarted(){return h(this,Z,"f")}constructor(){V.add(this),G.set(this,[]),W.set(this,1),j.set(this,m.BOPM_BLOCK),Z.set(this,!1),H.set(this,void 0),q.set(this,g.CCUT_AUTO)}setErrorListener(e){}addImageToBuffer(e){var t;if(!S(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(h(this,G,"f").length>=h(this,W,"f"))switch(h(this,j,"f")){case m.BOPM_BLOCK:break;case m.BOPM_UPDATE:if(h(this,G,"f").push(e),T(h(this,H,"f"))&&C(h(this,H,"f").imageId)&&1==h(this,H,"f").keepInBuffer)for(;h(this,G,"f").length>h(this,W,"f");){const e=h(this,G,"f").findIndex(e=>{var t;return(null===(t=e.imageTag)||void 0===t?void 0:t.imageId)!==h(this,H,"f").imageId});h(this,G,"f").splice(e,1)}else h(this,G,"f").splice(0,h(this,G,"f").length-h(this,W,"f"))}else h(this,G,"f").push(e)}getImage(){if(0===h(this,G,"f").length)return null;let t;if(h(this,H,"f")&&C(h(this,H,"f").imageId)){const e=h(this,V,"m",Y).call(this,h(this,H,"f").imageId);if(e<0)throw new Error(`Image with id ${h(this,H,"f").imageId} doesn't exist.`);t=h(this,G,"f").slice(e,e+1)[0]}else t=h(this,G,"f").pop();if([p.IPF_RGB_565,p.IPF_RGB_555,p.IPF_RGB_888,p.IPF_ARGB_8888,p.IPF_RGB_161616,p.IPF_ARGB_16161616,p.IPF_ABGR_8888,p.IPF_ABGR_16161616,p.IPF_BGR_888].includes(t.format)){if(h(this,q,"f")===g.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 p.IPF_RGB_565:case p.IPF_RGB_555:case p.IPF_RGB_888:case p.IPF_RGB_161616:i[e]=t.bytes[3*e+2];break;case p.IPF_ARGB_8888:case p.IPF_ARGB_16161616:i[e]=t.bytes[4*e+2];break;case p.IPF_BGR_888:i[e]=t.bytes[3*e];break;case p.IPF_ABGR_8888:case p.IPF_ABGR_16161616:i[e]=t.bytes[4*e]}t.bytes=i,t.stride=t.width,t.format=p.IPF_GRAYSCALED}else if(h(this,q,"f")===g.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 p.IPF_RGB_565:case p.IPF_RGB_555:case p.IPF_RGB_888:case p.IPF_RGB_161616:case p.IPF_BGR_888:i[e]=t.bytes[3*e+1];break;case p.IPF_ARGB_8888:case p.IPF_ARGB_16161616:case p.IPF_ABGR_8888:case p.IPF_ABGR_16161616:i[e]=t.bytes[4*e+1]}t.bytes=i,t.stride=t.width,t.format=p.IPF_GRAYSCALED}else if(h(this,q,"f")===g.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 p.IPF_RGB_565:case p.IPF_RGB_555:case p.IPF_RGB_888:case p.IPF_RGB_161616:i[e]=t.bytes[3*e];break;case p.IPF_ARGB_8888:case p.IPF_ARGB_16161616:i[e]=t.bytes[4*e];break;case p.IPF_BGR_888:i[e]=t.bytes[3*e+2];break;case p.IPF_ABGR_8888:case p.IPF_ABGR_16161616:i[e]=t.bytes[4*e+2]}t.bytes=i,t.stride=t.width,t.format=p.IPF_GRAYSCALED}}else[p.IPF_NV21,p.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=>C(e)))(e))throw new TypeError("Invalid 'imageId'.");if(void 0!==t&&"[object Boolean]"!==v(t))throw new TypeError("Invalid 'keepInBuffer'.");_(this,H,{imageId:e,keepInBuffer:t},"f")}_resetNextReturnedImage(){_(this,H,null,"f")}hasImage(e){return h(this,V,"m",Y).call(this,e)>=0}startFetching(){_(this,Z,!0,"f")}stopFetching(){_(this,Z,!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(_(this,W,e,"f");h(this,G,"f")&&h(this,G,"f").length>e;)h(this,G,"f").shift()}getMaxImageCount(){return h(this,W,"f")}getImageCount(){return h(this,G,"f").length}clearBuffer(){h(this,G,"f").length=0}isBufferEmpty(){return 0===h(this,G,"f").length}setBufferOverflowProtectionMode(e){_(this,j,e,"f")}getBufferOverflowProtectionMode(){return h(this,j,"f")}setColourChannelUsageType(e){_(this,q,e,"f")}getColourChannelUsageType(){return h(this,q,"f")}};G=new WeakMap,W=new WeakMap,j=new WeakMap,Z=new WeakMap,H=new WeakMap,q=new WeakMap,V=new WeakSet,Y=function(e){if("number"!=typeof e)throw new TypeError("Invalid 'imageId'.");return h(this,G,"f").findIndex(t=>{var i;return(null===(i=t.imageTag)||void 0===i?void 0:i.imageId)===e})},"undefined"!=typeof navigator&&(z=navigator,$=z.userAgent,K=z.platform,X=z.mediaDevices),function(){if(!f){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:z.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:K,search:"Win"},Mac:{str:K},Linux:{str:K}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let o=n.str||$,r=n.search||t,a=n.verStr||$,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=o.indexOf(r)){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||$,o=i.search||e;if(-1!=s.indexOf(o)){n=e;break}}"Linux"==n&&-1!=$.indexOf("Windows NT")&&(n="HarmonyOS"),Q={browser:i,version:s,OS:n}}f&&(Q={browser:"ssr",version:0,OS:"ssr"})}();const ee="undefined"!=typeof WebAssembly&&$&&!(/Safari/.test($)&&!/Chrome/.test($)&&/\(.+\s11_2_([2-6]).*\)/.test($)),te=!("undefined"==typeof Worker),ie=!(!X||!X.getUserMedia),se=async()=>{let e=!1;if(ie)try{(await X.getUserMedia({video:!0})).getTracks().forEach(e=>{e.stop()}),e=!0}catch(e){}return e};var ne,oe,re,ae,ce,le,de,ue,he;"Chrome"===Q.browser&&Q.version>66||"Safari"===Q.browser&&Q.version>13||"OPR"===Q.browser&&Q.version>43||"Edge"===Q.browser&&Q.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"}(ne||(ne={})),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"}(oe||(oe={})),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"}(re||(re={})),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"}(ae||(ae={})),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"}(ce||(ce={})),function(e){e[e.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",e[e.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(le||(le={})),function(e){e[e.PDFRM_VECTOR=1]="PDFRM_VECTOR",e[e.PDFRM_RASTER=2]="PDFRM_RASTER",e[e.PDFRM_MULTIMODAL=3]="PDFRM_MULTIMODAL"}(de||(de={})),function(e){e[e.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",e[e.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(ue||(ue={})),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"}(he||(he={}));const _e={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 me,ge,pe,fe,Ee,ye,Ie;!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"}(me||(me={})),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"}(ge||(ge={})),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"}(pe||(pe={})),function(e){e[e.ICDM_NEAR=0]="ICDM_NEAR",e[e.ICDM_FAR=1]="ICDM_FAR"}(fe||(fe={})),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"}(Ee||(Ee={})),function(e){e[e.MU_PIXEL=0]="MU_PIXEL",e[e.MU_PERCENTAGE=1]="MU_PERCENTAGE"}(ye||(ye={})),function(e){e.BASELINE="baseline",e.ML="ml",e.ML_SIMD="ml-simd",e.ML_SIMD_PTHREAD="ml-simd-pthread",e.ML_SIMD_WITH_PDF="ml-simd-with-pdf",e.ML_SIMD_PTHREAD_WITH_PDF="ml-simd-pthread-with-pdf",e.AUTO="auto"}(Ie||(Ie={}));let ve,Re=0;const Ce=()=>Re++,Te={};let we=!1;const Se=e=>{we=e,ve&&ve.postMessage({type:"setBDebug",body:{value:e}})},Ae={},De={},be={core:{version:"4.6.30-dev-20260824140325",path:y,isInternal:!0}},Oe=new class extends u{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,d(e)?t=e:"function"==typeof e&&(t=new u(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&&(d(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};let Le=5;"undefined"!=typeof navigator&&(Le=navigator.hardwareConcurrency?Math.max(navigator.hardwareConcurrency-1,5):5),Te[-3]=async e=>{Ne.onWasmLoadProgressChanged&&Ne.onWasmLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class Ne{static get engineResourcePaths(){return be}static set engineResourcePaths(e){Object.assign(be,e)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _bDebug(){return we}static set _bDebug(e){Se(e)}static get _workerName(){return`${Ne._bundleEnv.toLowerCase()}.bundle.worker.js`}static get wasmLoadOptions(){return Ne._wasmLoadOptions}static set wasmLoadOptions(e){if("number"==typeof e.pthreadPoolSize&&e.pthreadPoolSize<0)throw new Error(`Invalid thread count parameter ${e.pthreadPoolSize}.`);Object.assign(Ne._wasmLoadOptions,e)}static isModuleLoaded(){return!!(null==Oe?void 0:Oe.isFulfilled)}static async loadWasm(){return await(async()=>{Oe.isEmpty&&(Oe.task=async(e,t)=>{const i=L(be),s={engineResourcePaths:i,_bundleEnv:Ne._bundleEnv,wasmLoadOptions:Ne.wasmLoadOptions};let n=i[`${Ne._bundleEnv.toLowerCase()}Bundle`]+Ne._workerName;n.startsWith(location.origin)||(n=await fetch(n).then(e=>e.blob()).then(e=>URL.createObjectURL(e))),ve=new Worker(n),ve.onerror=e=>{const i=new Error(e.message);t(i)},ve.addEventListener("message",e=>{var t;let i=e.data?e.data:e,s=i.type,n=i.id,o=i.body;switch(s){case"log":we&&(null===(t=Ne._onLog)||void 0===t||t.call(Ne,i.message));break;case"warning":console.warn(i.message);break;case"task":try{Te[n]&&(Te[n](o),delete Te[n])}catch(e){throw delete Te[n],e}break;case"event":try{Te[n](o)}catch(e){throw e}break;default:console.log(e)}}),s.bd=we,s.dm=location.origin.startsWith("http")?location.origin:"https://localhost";const o=Re++;Te[o]=i=>{if(i.success)Object.assign(Ae,i.versions),"{}"!==JSON.stringify(i.versions)&&(Ne._versions=i.versions),Ne.loadedWasmType=i.loadedWasmType,Ne._isNoOnnx=i.isNoOnnx,e(void 0);else{const e=Error(i.message);i.stack&&(e.stack=i.stack),t(e)}},ve.postMessage({type:"loadWasm",id:o,body:s})}),await Oe})()}static async detectEnvironment(){return await(async()=>({wasm:ee,worker:te,getUserMedia:ie,camera:await se(),browser:Q.browser,version:Q.version,OS:Q.OS}))()}static async getModuleVersion(){return await new Promise((e,t)=>{let i=Ce();Te[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)}},ve.postMessage({type:"getModuleVersion",id:i})})}static getVersion(){return`4.6.30-dev-20260824140325(Worker: ${Ae.core&&Ae.core.worker||"Not Loaded"}, Wasm: ${Ae.core&&Ae.core.wasm||"Not Loaded"})`}static enableLogging(){J._onLog=console.log,Ne._onLog=console.log}static disableLogging(){J._onLog=null,Ne._onLog=null}static async cfd(e){return await new Promise((t,i)=>{let s=Ce();Te[s]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},ve.postMessage({type:"cfd",id:s,body:{count:e}})})}}Ne._bSupportDce4Module=-1,Ne._bSupportIRTModule=-1,Ne._versions=null,Ne._isNoOnnx=!1,Ne._onLog=console.log,Ne._bundleEnv="DCV",Ne._wasmLoadOptions={wasmType:Ie.AUTO,pthreadPoolSize:Le},Ne.loadedWasmType=Ie.ML_SIMD_PTHREAD,Ne.browserInfo=Q;var Me=Object.freeze({__proto__:null,CoreModule:Ne,get EnumBufferOverflowProtectionMode(){return m},get EnumCapturedResultItemType(){return ne},get EnumColourChannelUsageType(){return g},get EnumCornerType(){return oe},get EnumCrossVerificationStatus(){return he},get EnumErrorCode(){return re},get EnumGrayscaleEnhancementMode(){return ae},get EnumGrayscaleTransformationMode(){return ce},get EnumImageCaptureDistanceMode(){return fe},get EnumImageFileFormat(){return pe},get EnumImagePixelFormat(){return p},get EnumImageTagType(){return le},EnumIntermediateResultUnitType:_e,get EnumMeasureUnit(){return ye},get EnumModuleName(){return Ee},get EnumPDFReadingMode(){return de},get EnumRasterDataSource(){return ue},get EnumRegionObjectElementType(){return me},get EnumSectionType(){return ge},get EnumWasmType(){return Ie},ImageSourceAdapter:J,_saveToFile:N,_toBlob:F,_toCanvas:M,_toImage:B,get bDebug(){return we},blobToDsImage:k,checkIsLink:O,compareVersion:(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 o=parseInt(i[e]),r=parseInt(s[e]);return o===r||Number.isNaN(o)&&Number.isNaN(r)?t<n?-1:1:o<r||Number.isNaN(o)&&Number.isInteger(r)?-1:1}return i.length===s.length?0:i.length<s.length?-1:1},createImageData:P,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),o=s.slice(12),r=new TextEncoder,a=await crypto.subtle.importKey("raw",r.encode(t),"PBKDF2",!1,["deriveKey"]),c=await crypto.subtle.deriveKey({name:"PBKDF2",salt:r.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,o);return(new TextDecoder).decode(l)},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"]),o=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:o,tagLength:128},n,i.encode(e)),a=new Uint8Array(o.length+r.byteLength);return a.set(o),a.set(new Uint8Array(r),o.length),btoa(String.fromCharCode.apply(null,a))},encodeBMP:x,getNextTaskID:Ce,handleEngineResourcePaths:L,imagePtrToUint8Array:async e=>await new Promise((t,i)=>{let s=Ce();Te[s]=async e=>{if(e.success)return t(e.u8);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},ve.postMessage({type:"imagePtrToUint8Array",id:s,body:{data:e}})}),innerVersions:Ae,isArc:e=>!(!T(e)||!C(e.x)||!C(e.y)||!C(e.radius)||e.radius<0||!C(e.startAngle)||!C(e.endAngle)),isContour:e=>!!T(e)&&!!R(e.points)&&0!=e.points.length&&!e.points.some(e=>!D(e)),isDSImageData:S,isDSRect:e=>!(!T(e)||!C(e.left)||e.left<0||!C(e.top)||e.top<0||!C(e.right)||e.right<0||!C(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:A,isLineSegment:e=>!(!T(e)||!D(e.startPoint)||!D(e.endPoint)||e.startPoint.x==e.endPoint.x&&e.startPoint.y==e.endPoint.y),isObject:T,isOriginalDsImageData:e=>!(!w(e)||!C(e.bytes.length)&&!C(e.bytes.ptr)),isPoint:D,isPolygon:e=>!!T(e)&&!!R(e.points)&&0!=e.points.length&&!e.points.some(e=>!D(e)),isQuad:e=>!!T(e)&&!!R(e.points)&&0!=e.points.length&&4==e.points.length&&!e.points.some(e=>!D(e)),isRect:e=>!(!T(e)||!C(e.x)||!C(e.y)||!C(e.width)||e.width<0||!C(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])),mapPackageRegister:De,mapTaskCallBack:Te,productNameMap:U,requestResource:b,resolveDsImageData:async e=>await new Promise((t,i)=>{let s=Ce();Te[s]=async e=>{if(e.success)return t(e.result);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},ve.postMessage({type:"resolveDsImageData",id:s,body:{point:e}})}),setBDebug:Se,get worker(){return ve}}),Be={license:"",scanMode:e.EnumScanMode.SM_SINGLE,templateFilePath:void 0,utilizedTemplateNames:{single:"ReadBarcodes_SpeedFirst",multi_unique:"ReadBarcodes_SpeedFirst",image:"ReadBarcodes_ReadRateFirst"},engineResourcePaths:Ne.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 Fe=e=>e&&"object"==typeof e&&"function"==typeof e.then,xe=(async()=>{})().constructor;class Pe extends xe{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,Fe(e)?t=e:"function"==typeof e&&(t=new xe(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&&(Fe(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}var ke,Ue;const Ve=e=>e&&"object"==typeof e&&"function"==typeof e.then,Ge=(async()=>{})().constructor;let We=class extends Ge{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,Ve(e)?t=e:"function"==typeof e&&(t=new Ge(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&&(Ve(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}},je=class{constructor(e){a(this,"_cvr",void 0),this._cvr=e}async getMaxBufferedItems(){return await new Promise((e,t)=>{let i=Ce();Te[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)}},ve.postMessage({type:"cvr_getMaxBufferedItems",id:i,instanceID:this._cvr._instanceID})})}async setMaxBufferedItems(e){return await new Promise((t,i)=>{let s=Ce();Te[s]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},ve.postMessage({type:"cvr_setMaxBufferedItems",id:s,instanceID:this._cvr._instanceID,body:{count:e}})})}async getBufferedCharacterItemSet(){return await new Promise((e,t)=>{let i=Ce();Te[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)}},ve.postMessage({type:"cvr_getBufferedCharacterItemSet",id:i,instanceID:this._cvr._instanceID})})}};const Ze={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},He={onTaskResultsReceived:()=>{},isFilter:!0},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){a(this,"_cvr",void 0),a(this,"_irrRegistryState",JSON.parse(JSON.stringify(Ze))),a(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=Ce();Te[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,s(e)}},ve.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=Ce();Te[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},ve.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=Ce();Te[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},ve.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})})}getOriginalImage(){return this._cvr.provideDsImage}};const ze="undefined"==typeof self,$e="function"==typeof importScripts,Ke=(()=>{if(!$e){if(!ze&&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"./"}})();Ne.engineResourcePaths.cvr={version:"3.6.30-dev-20260824140332",path:Ke,isInternal:!0},De.cvr={};let Xe=class{static getVersion(){return this._version}};function Qe(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}Qe(e.referencedItem,t)}}function Je(e){if(e.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}function et(e){return{type:ne.CRIT_ORIGINAL_IMAGE,referenceItem:null,targetROIDefName:"",taskName:"",imageData:e,toCanvas:()=>M(e),toImage:t=>B(t,e),toBlob:t=>F(t,e)}}function tt(e){let t=!1;const i=[re.EC_UNSUPPORTED_JSON_KEY_WARNING,re.EC_LICENSE_AUTH_QUOTA_EXCEEDED,re.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 it(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 st(e){return Math.abs(e)<1e-6?0:e<0?-1:1}function nt(e,t,i,s){let n=e[0]*(i[1]-t[1])+t[0]*(e[1]-i[1])+i[0]*(t[1]-e[1]),o=e[0]*(s[1]-t[1])+t[0]*(e[1]-s[1])+s[0]*(t[1]-e[1]);return!((n^o)>=0&&0!==n&&0!==o||(n=i[0]*(e[1]-s[1])+s[0]*(i[1]-e[1])+e[0]*(s[1]-i[1]),o=i[0]*(t[1]-s[1])+s[0]*(i[1]-t[1])+t[0]*(s[1]-i[1]),(n^o)>=0&&0!==n&&0!==o))}a(Xe,"_version",`3.6.30-dev-20260824140332(Worker: ${null===(Ue=Ae.cvr)||void 0===Ue?void 0:Ue.worker}, Wasm: loading...`),BigInt(0),BigInt("0xFFFFFFFEFFFFFFFF"),BigInt(4265345023);const ot=BigInt(3147775),rt=(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)),at=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 ct=class{constructor(e){a(this,"cameraEnhancer",void 0),a(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]}),a(this,"isSupportDCEModule",!0),a(this,"consumeTime",void 0),a(this,"onTaskResultsReceived",async e=>{if(!this.isSupportDCEModule)return;let t=this.cameraEnhancer;(4&t._dceEnhancedFeatures||16&t._dceEnhancedFeatures||64&t._dceEnhancedFeatures)&&(0!==Ne.bSupportDce4Module?(this.isSupportDCEModule=!1,console.warn("Warning: The license required for Enhanced Features was not found.")):(!this.consumeTime||Date.now()-this.consumeTime>1e4)&&(Ne.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,o=!1;for(let e of i){if(e.unitType===_e.IRUT_DECODED_BARCODES&&e.decodedBarcodes.length){n=!0;break}e.unitType===_e.IRUT_LOCALIZED_BARCODES&&e.localizedBarcodes.length&&(o=!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)},r=async e=>{await t.setFocus(e)};if(o){s.x,s.y;const o=s.width,a=s.height,c=s.width,l=s.height;let d;{let e,n,o,r,a;{const e=t.video.videoWidth*(1-this._autoZoomParameters.autoZoomDetectionArea)/2,i=t.video.videoWidth*(1+this._autoZoomParameters.autoZoomDetectionArea)/2,s=i,n=e,o=t.video.videoHeight*(1-this._autoZoomParameters.autoZoomDetectionArea)/2,r=o,c=t.video.videoHeight*(1+this._autoZoomParameters.autoZoomDetectionArea)/2;a=[{x:e,y:o},{x:i,y:r},{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 o=0;o<n;o++){const r=e[o],a=e[(o+1)%n];if(it(r,a,{x:t,y:i}))return!0;st(r.y-i)>0!=st(a.y-i)>0&&st(t-(i-r.y)*(r.x-a.x)/(r.y-a.y)-r.x)<0&&(s=!s)}return s}(t,e.x,e.y)},s=(e,t)=>!!(nt([e[0],e[1]],[e[2],e[3]],[t[0].x,t[0].y],[t[1].x,t[1].y])||nt([e[0],e[1]],[e[2],e[3]],[t[1].x,t[1].y],[t[2].x,t[2].y])||nt([e[0],e[1]],[e[2],e[3]],[t[2].x,t[2].y],[t[3].x,t[3].y])||nt([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===_e.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==rt||e.possibleFormats==at);if(e.length||(e=u.filter(e=>e.possibleFormats==ot),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),o=Math.min(t[0].y,t[1].y,t[2].y,t[3].y),r=Math.max(t[0].y,t[1].y,t[2].y,t[3].y),d={points:[{x:e,y:o},{x:n,y:o},{x:n,y:r},{x:e,y:r}],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/o,l=(o-d.points[2].x)/o,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&&r({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),o=Math.min(...i,this._autoZoomParameters.autoZoomInIdealModuleSize/d.result.moduleSize),r=t.getZoomSettings().factor;let a=Math.max(Math.pow(r*o,1/this._autoZoomParameters.autoZoomInMaxTimes),this._autoZoomParameters.autoZoomInMinStep);a=Math.min(a,o);let _=r*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 r({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 r({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&&r({mode:"continuous"}).catch(()=>{})}!(16&t._dceEnhancedFeatures)&&4&t._dceEnhancedFeatures&&(this._autoZoomParameters.autoFocusFrameArray.length=0,r({mode:"continuous"}).catch(()=>{}))}}}),a(this,"isDce",!0),this.cameraEnhancer=e}};var lt,dt;!function(e){e[e.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",e[e.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}(lt||(lt={})),Te[-2]=async e=>{St.onDataLoadProgressChanged&&St.onDataLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};var ut=new WeakMap,ht=new WeakMap,_t=new WeakMap,mt=new WeakMap,gt=new WeakMap,pt=new WeakMap,ft=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 WeakSet;let St=class e{constructor(){r(this,wt),a(this,"maxImageSideLength",["iPhone","Android","HarmonyOS"].includes(Ne.browserInfo.OS)?2048:4096),a(this,"onCaptureError",null),a(this,"provideDsImage",null),a(this,"_instanceID",void 0),a(this,"_loopReadVideoTimeoutId",void 0),a(this,"_isOutputOriginalImage",!1),a(this,"_isOpenDetectVerify",!1),a(this,"_isOpenNormalizeVerify",!1),a(this,"_isOpenBarcodeVerify",!1),a(this,"_isOpenLabelVerify",!1),a(this,"_minImageCaptureInterval",0),a(this,"_averageProcessintTimeArray",[]),a(this,"_averageFetchImageTimeArray",[]),a(this,"_averageTime",999),a(this,"_dynamsoft",!0),a(this,"_enhancedFeaturesIrr",null),a(this,"_templateName",""),a(this,"_isCapturing",!1),a(this,"_s",!1),n(this,ut,null),n(this,ht,null),n(this,_t,null),n(this,mt,null),n(this,gt,null),n(this,pt,new Set),n(this,ft,new Set),n(this,Et,new Set),n(this,yt,500),n(this,It,0),n(this,vt,0),n(this,Rt,0),n(this,Ct,!1),n(this,Tt,!1),a(this,"_singleFrameModeCallbackBind",this._singleFrameModeCallback.bind(this))}get disposed(){return s(Tt,this)}get isCapturing(){return this._isCapturing}static async createInstance(t=!0){if(!De.license)throw Error("The `license` module cannot be found.");return await De.license.dynamsoft(),await Ne.loadWasm(),await new Promise((i,s)=>{const n=new e,r=Ce();Te[r]=async t=>{var r;t.success?(n._instanceID=t.instanceID,null!==(r=e._fr4DisposeCvrWasm)&&void 0!==r&&r.register(n,t.instanceID,n),Xe._version=`3.6.30-dev-20260824140332(Worker: ${Ae.cvr.worker}, Wasm: ${t.version})`,o(Ct,n,!0),o(mt,n,n.getIntermediateResultManager()),o(Ct,n,!1),i(n)):tt({message:t.message,rj:s,stack:t.stack,functionName:"createInstance"})},ve.postMessage({type:"cvr_createInstance",id:r,body:{loadPresetTemplates:t}})})}static async appendDLModelBuffer(e,t){return await Ne.loadWasm(),Ne._isNoOnnx?Promise.reject("Model not supported in the current environment."):await new Promise((i,s)=>{const n=Ce(),o=L(Ne.engineResourcePaths);let r;Te[n]=async e=>{if(e.success){const t=JSON.parse(e.response);if(0!==t.errorCode&&tt({message:t.errorString?t.errorString:"Append Model Buffer Failed.",rj:s,errorCode:t.errorCode,functionName:"appendDLModelBuffer"}))return;return i(t)}tt({message:e.message,rj:s,stack:e.stack,functionName:"appendDLModelBuffer"})},t?(r=new URL(t,location.href).href,r=r.endsWith("/")?r:r+"/"):"DCV"===Ne._bundleEnv?r=o.dcvData+"models/":"DBR"===Ne._bundleEnv&&(r=o.dbrBundle+"models/");let a=Array.isArray(e)?e:[e];a=a.map(e=>e.replace(/\.data$/i,"")),ve.postMessage({type:"cvr_appendDLModelBuffer",id:n,body:{modelNames:a,path:r}})})}static async clearDLModelBuffers(){return await new Promise((e,t)=>{const i=Ce();Te[i]=async i=>{if(i.success)return e();tt({message:i.message,rj:t,stack:i.stack,functionName:"clearDLModelBuffers"})},ve.postMessage({type:"cvr_clearDLModelBuffers",id:i})})}async _singleFrameModeCallback(){const e=s(ut,this)._singleFrameModeResultForDcv;if(!e)return;t(wt,this,At).call(this,e);const i={bytes:new Uint8Array(e.bytes),width:e.width,height:e.height,stride:e.stride,format:e.format,imageTag:e.imageTag},n=await this.capture(i,this._templateName);n.originalImageTag=e.imageTag,s(ut,this)._cameraView._capturedResultReceiver.onCapturedResultReceived(n,{isDetectVerifyOpen:!1,isNormalizeVerifyOpen:!1,isBarcodeVerifyOpen:!1,isLabelVerifyOpen:!1}),t(wt,this,Ot).call(this,n),s(ut,this)._singleFrameModeResultForDcv=null}setInput(e){if(Je(this),!this.isCapturing)if(o(ut,this,e),null!=e&&e.isCameraEnhancer){if(this._enhancedFeaturesIrr)return;this._enhancedFeaturesIrr=new ct(e),s(mt,this).addResultReceiver(this._enhancedFeaturesIrr)}else s(mt,this).removeResultReceiver(this._enhancedFeaturesIrr),this._enhancedFeaturesIrr=null}getInput(){return s(ut,this)}addImageSourceStateListener(e){if(Je(this),"object"!=typeof e)return console.warn("Invalid ISA state listener.");e&&Object.keys(e)&&s(ft,this).add(e)}removeImageSourceStateListener(e){return Je(this),s(ft,this).delete(e)}async addResultReceiver(e){if(Je(this),"object"!=typeof e)throw new Error("Invalid receiver.");e&&Object.keys(e).length&&(s(pt,this).add(e),await this._setCrrRegistry())}async removeResultReceiver(e){Je(this),s(pt,this).delete(e),await this._setCrrRegistry()}async removeAllResultReceivers(){Je(this),s(pt,this).clear(),await this._setCrrRegistry()}async _setCrrRegistry(){const e={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onProcessedDocumentResultReceived:!1,onParsedResultsReceived:!1};for(let t of s(pt,this))t.isDce||(e.onCapturedResultReceived=!!t.onCapturedResultReceived,e.onDecodedBarcodesReceived=!!t.onDecodedBarcodesReceived,e.onRecognizedTextLinesReceived=!!t.onRecognizedTextLinesReceived,e.onProcessedDocumentResultReceived=!!t.onProcessedDocumentResultReceived,e.onParsedResultsReceived=!!t.onParsedResultsReceived);const t=Ce();return await new Promise((i,s)=>{Te[t]=async e=>{e.success?i():tt({message:e.message,rj:s,stack:e.stack,functionName:"addResultReceiver"})},ve.postMessage({type:"cvr_setCrrRegistry",id:t,instanceID:this._instanceID,body:{receiver:JSON.stringify(e)}})})}async addResultFilter(e){if(Je(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.");s(Et,this).add(e),e._dynamsoft(),await this._handleFilterUpdate()}async removeResultFilter(e){Je(this),s(Et,this).delete(e),await this._handleFilterUpdate()}async removeAllResultFilters(){Je(this),s(Et,this).clear(),await this._handleFilterUpdate()}async _handleFilterUpdate(){if(s(mt,this).removeResultReceiver(He),0===s(Et,this).size){this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1;const e={[ne.CRIT_BARCODE]:!1,[ne.CRIT_TEXT_LINE]:!1,[ne.CRIT_DETECTED_QUAD]:!1,[ne.CRIT_DESKEWED_IMAGE]:!1,[ne.CRIT_ENHANCED_IMAGE]:!1},i={[ne.CRIT_BARCODE]:!1,[ne.CRIT_TEXT_LINE]:!1,[ne.CRIT_DETECTED_QUAD]:!1,[ne.CRIT_DESKEWED_IMAGE]:!1,[ne.CRIT_ENHANCED_IMAGE]:!1};return await t(wt,this,Lt).call(this,e),void await t(wt,this,Nt).call(this,i)}for(let e of s(Et,this))this._isOpenBarcodeVerify=e.isResultCrossVerificationEnabled(ne.CRIT_BARCODE),this._isOpenLabelVerify=e.isResultCrossVerificationEnabled(ne.CRIT_TEXT_LINE),this._isOpenDetectVerify=e.isResultCrossVerificationEnabled(ne.CRIT_DETECTED_QUAD),this._isOpenNormalizeVerify=e.isResultCrossVerificationEnabled(ne.CRIT_DESKEWED_IMAGE),e.isLatestOverlappingEnabled(ne.CRIT_BARCODE)&&([...s(mt,this)._intermediateResultReceiverSet.values()].find(e=>e.isFilter)||s(mt,this).addResultReceiver(He)),await t(wt,this,Lt).call(this,e.verificationEnabled),await t(wt,this,Nt).call(this,e.duplicateFilterEnabled),await t(wt,this,Mt).call(this,e.duplicateForgetTime),await t(wt,this,Bt).call(this,e.crossVerificationCriteria)}async startCapturing(t){var i;if(Je(this),this.isCapturing)return;if(!s(ut,this))throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");t||(t=e._defaultTemplate);for(let e of s(Et,this))await this.addResultFilter(e);const n=L(Ne.engineResourcePaths);if(s(_t,this)&&s(_t,this).isPending)return s(_t,this);const r=o(Rt,this,(i=s(Rt,this),++i));return o(_t,this,new We((e,i)=>{if(this.disposed)return;const o=Ce();Te[o]=async n=>{s(_t,this)&&!s(_t,this).isFulfilled&&r===s(Rt,this)&&(n.success?(this._isCapturing=!0,this._templateName=t,void 0!==s(ut,this).singleFrameMode&&"disabled"!==s(ut,this).singleFrameMode?(s(ut,this).on("singleFrameAcquired",this._singleFrameModeCallbackBind),this._singleFrameModeCallback(),e()):(this._isOutputOriginalImage=n.isOutputOriginalImage,this._minImageCaptureInterval=n.minImageCaptureInterval,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(async()=>{if(r===s(Rt,this)&&this.isCapturing){-1!==this._minImageCaptureInterval&&s(ut,this).startFetching();for(let e of s(ft,this))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(lt.ISS_BUFFER_EMPTY);this.barcodeScanLoop(t,r),e()}},0))):tt({message:n.message,rj:i,stack:n.stack,functionName:"startCapturing"}))},ve.postMessage({type:"cvr_startCapturing",id:o,instanceID:this._instanceID,body:{templateName:t,engineResourcePaths:n}})})),await s(_t,this)}stopCapturing(){var e;if(Je(this),!s(ut,this))return;o(Rt,this,(e=s(Rt,this),++e)),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=null,s(ut,this).stopFetching(),this._averageProcessintTimeArray=[],this._isCapturing=!1,this._averageTime=999,o(_t,this,null),s(ut,this).isCameraEnhancer&&s(ut,this).off("singleFrameAcquired",this._singleFrameModeCallbackBind);const t=Ce();ve.postMessage({type:"cvr_stopCapturing",id:t,instanceID:this._instanceID})}async containsTask(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t(JSON.parse(e.tasks));tt({message:e.message,rj:i,stack:e.stack,functionName:"containsTask"})},ve.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(i,n=s(Rt,this)){if(n!==s(Rt,this)||!this.isCapturing)return;if(s(ut,this).isBufferEmpty())if(s(ut,this).hasNextImageToFetch())for(let e of s(ft,this))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(lt.ISS_BUFFER_EMPTY);else for(let e of s(ft,this))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(lt.ISS_EXHAUSTED);const o=s(ut,this).getImage();if(!o)return s(ut,this)._bClosedBecauseOfNotInDOM?void this.stopCapturing():(await new Promise(e=>setTimeout(e,100)),void this.continueLoop(i,n));if(o.imageTag&&Date.now()-o.imageTag.timeStamp>200)return void this.continueLoop(i,n);t(wt,this,At).call(this,o),o._s=!0;const r=Date.now();this._captureInWorker(o,i).then(async a=>{if(n!==s(Rt,this)||!this.isCapturing)return;if(e._onLog&&e._onLog("no js handle time: "+(Date.now()-r)),!this.isCapturing)return void this.continueLoop(i,n);a.originalImageTag=o.imageTag?o.imageTag:null,s(ut,this)._capturedResultReceiver&&s(ut,this)._cameraView._capturedResultReceiver.onCapturedResultReceived(a,{isDetectVerifyOpen:this._isOpenDetectVerify,isNormalizeVerifyOpen:this._isOpenNormalizeVerify,isBarcodeVerifyOpen:this._isOpenBarcodeVerify,isLabelVerifyOpen:this._isOpenLabelVerify});for(let e of s(Et,this)){const t=e;t.onOriginalImageResultReceived(a),t.onDecodedBarcodesReceived(a),t.onRecognizedTextLinesReceived(a),t.onProcessedDocumentResultReceived(a),t.onParsedResultsReceived(a)}t(wt,this,Ot).call(this,a);const c=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()-r),this._averageFetchImageTimeArray.push(o&&o.imageTag?o.imageTag.timeSpent:0),this._averageTime=Math.min(...this._averageProcessintTimeArray)-Math.max(...this._averageFetchImageTimeArray),this._averageTime=this._averageTime>0?this._averageTime:0,e._onLog&&(e._onLog(`minImageCaptureInterval: ${this._minImageCaptureInterval}`),e._onLog(`averageProcessintTimeArray: ${this._averageProcessintTimeArray}`),e._onLog(`averageFetchImageTimeArray: ${this._averageFetchImageTimeArray}`),e._onLog(`averageTime: ${this._averageTime}`))),e._onLog){const t=Date.now()-c;t>10&&e._onLog(`fetch image calculate time: ${t}`)}e._onLog&&e._onLog(`time finish decode: ${Date.now()}`),e._onLog&&e._onLog("main time: "+(Date.now()-r)),e._onLog&&e._onLog("===================================================="),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._minImageCaptureInterval>0&&this._minImageCaptureInterval>=this._averageTime?this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(i,n)},this._minImageCaptureInterval-this._averageTime):this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(i,n)},Math.max(this._minImageCaptureInterval,0))}).catch(e=>{n===s(Rt,this)&&(s(ut,this).stopFetching(),"platform error"!==e.message&&(e.errorCode&&0===e.errorCode&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{s(ut,this).startFetching(),this.barcodeScanLoop(i,n)},Math.max(this._minImageCaptureInterval,1e3))),setTimeout(()=>{if(n===s(Rt,this)){if(!this.onCaptureError)throw e;this.onCaptureError(e)}},0)))})}continueLoop(e,t=s(Rt,this)){t===s(Rt,this)&&this.isCapturing&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{this.barcodeScanLoop(e,t)},0))}async getClarity(e,t,i,s,n){const{bytes:o,width:r,height:a,stride:c,format:l}=e,d=Ce();return new Promise((e,u)=>{Te[d]=async t=>{t.success?e(t.clarity):tt({message:t.message,rj:u,stack:t.stack,functionName:"getClarity"})},ve.postMessage({type:"cvr_getClarity",id:d,instanceID:this._instanceID,body:{bytes:o,width:r,height:a,stride:c,format:l,bitcount:t,wr:i,hr:s,grayThreshold:n}},[o.buffer])})}async capture(t,i){let s;if(Je(this),i||(i=e._defaultTemplate),S(t))s=await this._captureDsimage(t,i);else if("string"==typeof t)s="data:image/"==t.substring(0,11)?await this._captureBase64(t,i):await this._captureUrl(t,i);else if(t instanceof Blob)s=await this._captureBlob(t,i);else if(t instanceof HTMLImageElement)s=await this._captureImage(t,i);else if(t instanceof HTMLCanvasElement)s=await this._captureCanvas(t,i);else{if(!(t instanceof HTMLVideoElement))throw new TypeError("'capture(imageOrFile, templateName)': Type of 'imageOrFile' should be 'DSImageData', 'Url', 'Base64', 'Blob', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement'.");s=await this._captureVideo(t,i)}return s}async captureMultiPages(i,n="",r){Je(this),n||(n=e._defaultTemplate);const a={pages:[],dpi:300};return Object.assign(a,r),await new Promise(async(e,r)=>{let c;if(c="string"==typeof i?await b(i,"blob"):i,"application/pdf"!==c.type)return void r("Unsupported file type. Only PDF are allowed.");const l=await c.arrayBuffer(),d=new Uint8Array(l),u=Ce();Te[u]=i=>{if(i.success){var n;for(let e of i.capturedResults)t(wt,this,Dt).call(this,e);t(wt,this,bt).call(this,i.intermediateResult);const r=Date.now();r-s(It,this)>s(yt,this)&&null!==i.mliRecord&&(null!==(n=localStorage)&&void 0!==n&&n.setItem("dynamsoft",i.mliRecord),o(It,this,r)),e(i.capturedResults)}else tt({message:i.message,rj:r,stack:i.stack,functionName:"captureMultiPages"})},ve.postMessage({type:"cvr_captureMultiPages",id:u,instanceID:this._instanceID,body:{bytes:d,templateName:n,defaultOptions:a}},[d.buffer])})}async _captureDsimage(e,t){return await this._captureInWorker(e,t)}async _captureUrl(e,t){let i=await b(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 t=>await new Promise((i,s)=>{let n=URL.createObjectURL(t),o=new Image;o.src=n,o.onload=()=>{URL.revokeObjectURL(o.dbrObjUrl),i(o)},o.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,n,r=e instanceof HTMLImageElement?e.naturalWidth:e.width,a=e instanceof HTMLImageElement?e.naturalHeight:e.height,c=Math.max(r,a);c>this.maxImageSideLength?(o(vt,this,this.maxImageSideLength/c),i=Math.round(r*s(vt,this)),n=Math.round(a*s(vt,this))):(i=r,n=a),s(ht,this)||o(ht,this,document.createElement("canvas"));const l=s(ht,this);return l.width===i&&l.height===n||(l.width=i,l.height=n),l.ctx2d||(l.ctx2d=l.getContext("2d",{willReadFrequently:!0})),l.ctx2d.drawImage(e,0,0,r,a,0,0,i,n),e.dbrObjUrl&&URL.revokeObjectURL(e.dbrObjUrl),await this._captureCanvas(l,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:p.IPF_ABGR_8888};return await this._captureInWorker(s,t)}async _captureVideo(e,t){if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";let i,n,r=e.videoWidth,a=e.videoHeight,c=Math.max(r,a);c>this.maxImageSideLength?(o(vt,this,this.maxImageSideLength/c),i=Math.round(r*s(vt,this)),n=Math.round(a*s(vt,this))):(i=r,n=a),s(ht,this)||o(ht,this,document.createElement("canvas"));const l=s(ht,this);return l.width===i&&l.height===n||(l.width=i,l.height=n),l.ctx2d||(l.ctx2d=l.getContext("2d",{willReadFrequently:!0})),l.ctx2d.drawImage(e,0,0,r,a,0,0,i,n),await this._captureCanvas(l,t)}async _captureInWorker(i,n){let{bytes:r,width:a,height:c,stride:l,format:d,imageTag:u}=i;const h=Ce();return await new Promise((_,m)=>{this.provideDsImage=i,Te[h]=n=>{if(n.success){const a=Date.now();e._onLog&&(e._onLog(`get result time from worker: ${a}`),e._onLog("worker to main time consume: "+(a-n.workerReturnMsgTime)));try{var r;t(wt,this,Dt).call(this,n.capturedResult,i),i.bytes=n.bytes,n._s||o(vt,this,0),t(wt,this,bt).call(this,n.intermediateResult,u);const e=Date.now();return e-s(It,this)>s(yt,this)&&null!==n.mliRecord&&(null!==(r=localStorage)&&void 0!==r&&r.setItem("dynamsoft",n.mliRecord),o(It,this,e)),_(n.capturedResult)}catch(e){tt({message:e.message,rj:m,stack:e.stack,functionName:"capture"})}}else tt({message:n.message,rj:m,stack:n.stack,functionName:"capture"})},e._onLog&&e._onLog(`send buffer to worker: ${Date.now()}`);const g=i.hasOwnProperty("_s")?i._s:this._s;ve.postMessage({type:"cvr_capture",id:h,instanceID:this._instanceID,body:{bytes:r,width:a,height:c,stride:l,format:d,templateName:n||"",dynamsoft:this._dynamsoft,_s:g}},[r.buffer])})}async initSettings(t){if(Je(this),t&&["string","object"].includes(typeof t))return"string"==typeof t?t.trimStart().startsWith("{")||(t=await b(t,"text")):"object"==typeof t&&(t=JSON.stringify(t)),await new Promise((i,s)=>{const n=Ce();Te[n]=async n=>{if(n.success){const o=JSON.parse(n.response);if(0!==o.errorCode&&tt({message:o.errorString?o.errorString:"Init Settings Failed.",rj:s,errorCode:o.errorCode,functionName:"initSettings"}))return;const r=JSON.parse(t);return this._isOutputOriginalImage=!!r.CaptureVisionTemplates[0].OutputOriginalImage,e._defaultTemplate=r.CaptureVisionTemplates[0].Name,i(o)}tt({message:n.message,rj:s,stack:n.stack,functionName:"initSettings"})},ve.postMessage({type:"cvr_initSettings",id:n,instanceID:this._instanceID,body:{settings:t}})});console.error("Invalid template.")}async outputSettings(e,t){return Je(this),await new Promise((i,s)=>{const n=Ce();Te[n]=async e=>{if(e.success){const t=JSON.parse(e.response);if(0!==t.errorCode&&tt({message:t.errorString,rj:s,errorCode:t.errorCode,functionName:"outputSettings"}))return;return i(JSON.parse(t.data))}tt({message:e.message,rj:s,stack:e.stack,functionName:"outputSettings"})},ve.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),o=new Blob([JSON.stringify(n,null,2,(e,t)=>t instanceof Array?JSON.stringify(t):t,2)],{type:"application/json"});if(i){const e=document.createElement("a");e.href=URL.createObjectURL(o),t.endsWith(".json")&&(t=t.replace(".json","")),e.download=`${t}.json`,e.onclick=()=>{setTimeout(()=>{URL.revokeObjectURL(e.href)},500)},e.click()}return o}async getTemplateNames(){return Je(this),await new Promise((e,t)=>{const i=Ce();Te[i]=async i=>{if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&tt({message:s.errorString,rj:t,errorCode:s.errorCode,functionName:"getTemplateNames"}))return;return e(JSON.parse(s.data))}tt({message:i.message,rj:t,stack:i.stack,functionName:"getTemplateNames"})},ve.postMessage({type:"cvr_getTemplateNames",id:i,instanceID:this._instanceID})})}async getSimplifiedSettings(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success){const s=JSON.parse(e.response),n=s.data.replace(/("barcodeFormatIds"\s*:\s*)(-?\d+)(?=\s*[,}])/g,'$1"$2"');if(0!==s.errorCode&&tt({message:s.errorString,rj:i,errorCode:s.errorCode,functionName:"getSimplifiedSettings"}))return;const o=JSON.parse(n,(e,t)=>"barcodeFormatIds"===e?BigInt(t):t);return t(o)}tt({message:e.message,rj:i,stack:e.stack,functionName:"getSimplifiedSettings"})},ve.postMessage({type:"cvr_getSimplifiedSettings",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async updateSettings(e,t){return Je(this),await new Promise((i,s)=>{const n=Ce();Te[n]=async e=>{if(e.success){const n=JSON.parse(e.response);if(this._isOutputOriginalImage=t.outputOriginalImage,0!==n.errorCode&&tt({message:n.errorString?n.errorString:"Update Settings Failed.",rj:s,errorCode:n.errorCode,functionName:"updateSettings"}))return;return i(n)}tt({message:e.message,rj:s,stack:e.stack,functionName:"updateSettings"})},ve.postMessage({type:"cvr_updateSettings",id:n,instanceID:this._instanceID,body:{settings:t,templateName:e}})})}async resetSettings(){return Je(this),this.isCapturing?Promise.reject(new Error("resetSettings:-10062:Failed to call the function while capturing in progress.")):await new Promise((e,t)=>{const i=Ce();Te[i]=async i=>{if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&tt({message:s.errorString?s.errorString:"Reset Settings Failed.",rj:t,errorCode:s.errorCode,functionName:"resetSettings"}))return;return e(s)}tt({message:i.message,rj:t,stack:i.stack,functionName:"resetSettings"})},ve.postMessage({type:"cvr_resetSettings",id:i,instanceID:this._instanceID})})}getBufferedItemsManager(){return s(gt,this)||o(gt,this,new je(this)),s(gt,this)}getIntermediateResultManager(){if(Je(this),!s(Ct,this)&&0!==Ne.bSupportIRTModule)throw new Error("The current license does not support the use of intermediate results.");return s(mt,this)||o(mt,this,new Ye(this)),s(mt,this)}static async setGlobalIntraOpNumThreads(e=0){return e>4||e<0?Promise.reject(new RangeError("'intraOpNumThreads' should be between 0 and 4.")):(await Ne.loadWasm(),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t();tt({message:e.message,rj:i,stack:e.stack,functionName:"setGlobalIntraOpNumThreads"})},ve.postMessage({type:"cvr_setGlobalIntraOpNumThreads",id:s,body:{intraOpNumThreads:e}})}))}async checkTemplateNameValidity(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>e.success?t(e.isValid):t(!1),ve.postMessage({type:"cvr_checkTemplateNameValidity",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async parseRequiredResources(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t(JSON.parse(e.resources));tt({message:e.message,rj:i,stack:e.stack,functionName:"parseRequiredResources"})},ve.postMessage({type:"cvr_parseRequiredResources",id:s,instanceID:this._instanceID,body:{templateName:e}})})}static disposeCvrWasm(t){e._onLog&&e._onLog(`disposeCvrWasm: ${t}`);const i=Ce();Te[i]=e=>{e.success||tt({message:e.message,stack:e.stack,isShouldThrow:!0,functionName:"dispose"})},ve.postMessage({type:"cvr_dispose",id:i,instanceID:t})}dispose(){var t;Je(this),e._onLog&&e._onLog("dispose"),s(_t,this)&&this.stopCapturing(),o(ut,this,null),s(pt,this).clear(),s(ft,this).clear(),s(Et,this).clear(),s(mt,this)._intermediateResultReceiverSet.clear(),o(Tt,this,!0),e.disposeCvrWasm(this._instanceID),null===(t=e._fr4DisposeCvrWasm)||void 0===t||t.unregister(this)}_getInternalData(){return{isa:s(ut,this),promiseStartScan:s(_t,this),intermediateResultManager:s(mt,this),bufferdItemsManager:s(gt,this),resultReceiverSet:s(pt,this),isaStateListenerSet:s(ft,this),resultFilterSet:s(Et,this),compressRate:s(vt,this),canvas:s(ht,this),innerUseTag:s(Ct,this),isDestroyed:s(Tt,this)}}async _getWasmFilterState(){return await new Promise((e,t)=>{const i=Ce();Te[i]=async i=>{if(i.success){const t=JSON.parse(i.response);return e(t)}tt({message:i.message,rj:t,stack:i.stack,functionName:""})},ve.postMessage({type:"cvr_getWasmFilterState",id:i,instanceID:this._instanceID})})}};function At(e){for(let t of s(pt,this))this._isOutputOriginalImage&&t.onOriginalImageResultReceived&&t.onOriginalImageResultReceived(et(e))}function Dt(e,t){var i,n,o,r,a,c,l,d,u,h,_,m;for(let g=0;g<e.items.length;g++){const p=e.items[g];switch(0!==s(vt,this)&&Qe(p,s(vt,this)),p.type){case ne.CRIT_ORIGINAL_IMAGE:t&&(e.items[g]=et(t));break;case ne.CRIT_BARCODE:null!==(n=(i=e.decodedBarcodesResult).barcodeResultItems)&&void 0!==n||(i.barcodeResultItems=[]),e.decodedBarcodesResult.barcodeResultItems.push(p);break;case ne.CRIT_TEXT_LINE:null!==(r=(o=e.recognizedTextLinesResult).textLineResultItems)&&void 0!==r||(o.textLineResultItems=[]),e.recognizedTextLinesResult.textLineResultItems.push(p);break;case ne.CRIT_DETECTED_QUAD:null!==(c=(a=e.processedDocumentResult).detectedQuadResultItems)&&void 0!==c||(a.detectedQuadResultItems=[]),e.processedDocumentResult.detectedQuadResultItems.push(p);break;case ne.CRIT_DESKEWED_IMAGE:De.ddn&&De.ddn.handleDeskewedAndEnhancedImageResultItem(p),null!==(d=(l=e.processedDocumentResult).deskewedImageResultItems)&&void 0!==d||(l.deskewedImageResultItems=[]),e.processedDocumentResult.deskewedImageResultItems.push(p);break;case ne.CRIT_ENHANCED_IMAGE:De.ddn&&De.ddn.handleDeskewedAndEnhancedImageResultItem(p),null!==(h=(u=e.processedDocumentResult).enhancedImageResultItems)&&void 0!==h||(u.enhancedImageResultItems=[]),e.processedDocumentResult.enhancedImageResultItems.push(p);break;case ne.CRIT_PARSED_RESULT:De.dcp&&De.dcp.handleParsedResultItem(p),null!==(m=(_=e.parsedResult).parsedResultItems)&&void 0!==m||(_.parsedResultItems=[]),e.parsedResult.parsedResultItems.push(p)}}}function bt(e,t){const i=e;if(i){let e=0;for(let n of s(mt,this)._intermediateResultReceiverSet){e++;for(let o of i){if(["onTaskResultsReceived","onTargetROIResultsReceived"].includes(o.info.callbackName)){for(let e of o.intermediateResultUnits)e.originalImageTag=t||null;n[o.info.callbackName]&&n[o.info.callbackName]({intermediateResultUnits:o.intermediateResultUnits},o.info)}else n[o.info.callbackName]&&n[o.info.callbackName](o.result,o.info);e===s(mt,this)._intermediateResultReceiverSet.size&&delete o.info.callbackName}}}}function Ot(e){for(let t of s(pt,this))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)}async function Lt(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t(e.result);tt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},ve.postMessage({type:"cvr_enableResultCrossVerification",id:s,instanceID:this._instanceID,body:{verificationEnabled:e}})})}async function Nt(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t(e.result);tt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},ve.postMessage({type:"cvr_enableResultDeduplication",id:s,instanceID:this._instanceID,body:{duplicateFilterEnabled:e}})})}async function Mt(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t(e.result);tt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},ve.postMessage({type:"cvr_setDuplicateForgetTime",id:s,instanceID:this._instanceID,body:{duplicateForgetTime:e}})})}async function Bt(e){return Je(this),await new Promise((t,i)=>{const s=Ce();Te[s]=async e=>{if(e.success)return t();tt({message:e.message,rj:i,stack:e.stack,functionName:"setResultCrossVerificationCriteria"})},ve.postMessage({type:"cvr_setResultCrossVerificationCriteria",id:s,instanceID:this._instanceID,body:{criteria:e}})})}ke=St,a(St,"_onLog",void 0),a(St,"_defaultTemplate","Default"),a(St,"onDataLoadProgressChanged",void 0),a(St,"_fr4DisposeCvrWasm","undefined"!=typeof FinalizationRegistry?new FinalizationRegistry(ke.disposeCvrWasm):null);let Ft=class{constructor(){a(this,"onCapturedResultReceived",null),a(this,"onOriginalImageResultReceived",null),a(this,"onDecodedBarcodesReceived",void 0),a(this,"onRecognizedTextLinesReceived",void 0),a(this,"onProcessedDocumentResultReceived",void 0),a(this,"onParsedResultsReceived",void 0)}};!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"}(dt||(dt={}));var xt,Pt,kt,Ut=Object.freeze({__proto__:null,CaptureVisionRouter:St,CaptureVisionRouterModule:Xe,CapturedResultReceiver:Ft,get EnumImageSourceState(){return lt},get EnumPresetTemplate(){return dt},IntermediateResultReceiver:class{constructor(){a(this,"_observedResultUnitTypes",_e.IRUT_ALL),a(this,"_observedTaskMap",new Map),a(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)}),a(this,"onTaskResultsReceived",null),a(this,"onPredetectedRegionsReceived",null),a(this,"onTargetROIResultsReceived",void 0),a(this,"onColourImageUnitReceived",null),a(this,"onScaledColourImageUnitReceived",null),a(this,"onGrayscaleImageUnitReceived",null),a(this,"onTransformedGrayscaleImageUnitReceived",null),a(this,"onEnhancedGrayscaleImageUnitReceived",null),a(this,"onBinaryImageUnitReceived",null),a(this,"onTextureDetectionResultUnitReceived",null),a(this,"onTextureRemovedGrayscaleImageUnitReceived",null),a(this,"onTextureRemovedBinaryImageUnitReceived",null),a(this,"onContoursUnitReceived",null),a(this,"onLineSegmentsUnitReceived",null),a(this,"onTextZonesUnitReceived",null),a(this,"onTextRemovedBinaryImageUnitReceived",null),a(this,"onShortLinesUnitReceived",null),a(this,"onCandidateBarcodeZonesUnitReceived",void 0),a(this,"onComplementedBarcodeImageUnitReceived",void 0),a(this,"onDecodedBarcodesReceived",void 0),a(this,"onDeformationResistedBarcodeImageUnitReceived",void 0),a(this,"onLocalizedBarcodesReceived",void 0),a(this,"onScaledBarcodeImageUnitReceived",void 0),a(this,"onLocalizedTextLinesReceived",void 0),a(this,"onRawTextLinesUnitReceived",void 0),a(this,"onRecognizedTextLinesReceived",void 0),a(this,"onCandidateQuadEdgesUnitReceived",void 0),a(this,"onCornersUnitReceived",void 0),a(this,"onDeskewedImageReceived",void 0),a(this,"onDetectedQuadsReceived",void 0),a(this,"onEnhancedImageReceived",void 0),a(this,"onLogicLinesUnitReceived",void 0),a(this,"onLongLinesUnitReceived",void 0)}getObservationParameters(){return this._parameters}}});function Vt(e){return e&&"object"==typeof e&&"string"==typeof e.path}const Gt=/<style>([\s\S]*?)<\/style>/g,Wt=/style="([\s\S]*?)"/g,jt="undefined"!=typeof FinalizationRegistry?new FinalizationRegistry(e=>{URL.revokeObjectURL(e)}):null,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(Gt,(e,s,n,o)=>{let r=s.split("}");const a=r.length-1;let c=[],l=null,d=0;for(let e=0;e<a;++e){let t=0;for(;-1!==(t=r[e].indexOf("{",t));)d+=1,t+=1;if(l)1===d?(c.push(l+r[e]+"}"),l=null,d=0):(l+=r[e]+"}",--d);else{if(d<1)throw new Error("invalid style");1===d?(c.push(r[e].trimStart()+"}"),d=0):(l=r[e].trimStart()+"}",--d)}}if(l||d)throw new Error("invalid style");for(let e of c)t.insertRule(e,i.length);return""}))}const o=[];s&&(e=e.replace(Gt,(e,t,i,s)=>(o.push(new Blob([t],{type:"text/css"})),"<HasStyle></HasStyle>")));const r=[];e=e.replace(Wt,(e,t,i,s)=>(r.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<o.length;t++){const i=o[t],s=e[t],n=document.createElement("link");n._linkJsWrapper=n,n.rel="stylesheet",n.href=URL.createObjectURL(i),null!=jt&&jt.register(n,n.href),s.replaceWith(n)}}const c=a.querySelectorAll("[hasstyle]");for(let e=0;e<r.length;e++){const t=r[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._scriptJsWrapper=t,t.src=URL.createObjectURL(new Blob([e.textContent],{type:"text/javascript"})),null==jt||jt.register(t,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},Ht=e=>e&&"object"==typeof e&&"function"==typeof e.then,qt=(async()=>{})().constructor;class Yt extends qt{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,Ht(e)?t=e:"function"==typeof e&&(t=new qt(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&&(Ht(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}const zt="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})(),$t="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(xt=window)&&void 0!==xt&&xt.MSStream),Kt="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent)&&/Firefox/i.test(navigator.userAgent),Xt="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 $t&&i})(),Qt=zt?{width:1920,height:1080}:{width:1280,height:720},Jt=function(){const e=MediaDeviceInfo.prototype.toJSON.apply(this);return e.trackLabel=this.trackLabel,e.capabilities=this.capabilities,e.isFront=this.isFront,e},ei="The camera feature is available only in secure contexts (HTTPS).";let ti=class e{constructor(){a(this,"_coreShell",void 0),a(this,"_video",void 0),a(this,"_coreInnerLayer",void 0),a(this,"_coreOuterLayer",void 0),a(this,"_regionBoxWrapper",void 0),a(this,"_regionBoxMask",void 0),a(this,"_regionBoxBorder",void 0),a(this,"_objectFit","contain"),a(this,"_uiInlineScript2Blob",!0),a(this,"_uiInternalCss2Blob",!0),a(this,"_uiInternalCss2ExistedSheet",!1),a(this,"_ui",void 0),a(this,"_pOpen",void 0),a(this,"_getUserMediaTimeout",1e4),a(this,"_paused",!1),a(this,"_shouldClose",!1),a(this,"_cameraChangedWhenPaused",!1),a(this,"_requestedCamera","back"),a(this,"_requestedResolution",Qt),a(this,"_regionBox",{unit:"view-size",center:{x:0,y:0},maskStyle:{background:"rgba(0, 0, 0, 0.5)"},borderStyle:{border:"1px solid #00ff7f"}}),a(this,"_eventListeners",{}),a(this,"_bTryAnotherCameraWhenFailToOpen",!0),a(this,"_constraints4Fallback",!!zt||{facingMode:"environment"}),a(this,"_taskIdIOSResizeProblem",void 0),a(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:o}=this._coreShell.getBoundingClientRect(),r=`${t.videoWidth} / ${t.videoHeight}`;r!=i.aspectRatio&&(i.aspectRatio=r),s&&r!=s.aspectRatio&&(s.aspectRatio=r);const a=n/o-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.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;if("opened"!==this.status&&"paused"!==this.status)return null;const s=null===(t=this.track)||void 0===t||null===(t=t.getSettings())||void 0===t?void 0:t.deviceId;return s?null===(i=e._mapDeviceInfo)||void 0===i?void 0:i[s]:null}get currentResolution(){return{width:this.video.videoWidth,height:this.video.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;if(e.isFront)return!1;const i=null===(t=e.capabilities)||void 0===t||null===(t=t.focusDistance)||void 0===t?void 0:t.min;return void 0!==i&&i<.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(ei);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(!e._currentOpenedCamera&&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 o=i.find(e=>e.deviceId===n);o?(o.trackLabel=e.label,o.capabilities=null===(s=e.getCapabilities)||void 0===s?void 0:s.call(e),o.isFront="user"===e.getSettings().facingMode,o.toJSON=Jt):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(Jt===n.toJSON)continue;let o=null===(i=e._mapDeviceInfo)||void 0===i?void 0:i[n.deviceId];if(Jt===(null==o?void 0:o.toJSON))n.trackLabel=o.trackLabel,n.capabilities=o.capabilities,n.isFront=o.isFront,n.toJSON=o.toJSON;else if(!e._currentOpenedCamera){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=Jt}}}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 Yt,"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("closing"===this.status)throw Error("Camera closed.");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("closing"===this.status)throw Error("Camera closed.");if(!t.length)throw Error("No camera found.");const i=t.reduce((e,t)=>{var i,s;if(null!=t&&t.isFront)return e;const n=null==e||null===(i=e.capabilities)||void 0===i||null===(i=i.focusDistance)||void 0===i?void 0:i.min;if(!e||!n)return t;const o=null==t||null===(s=t.capabilities)||void 0===s||null===(s=s.focusDistance)||void 0===s?void 0:s.min;return o&&o<n?t:e});s={deviceId:(null==i?void 0:i.deviceId)||t[t.length-1].deviceId};break}default:throw Error(`Unknown camera preset: ${this._requestedCamera}`)}zt&&s.deviceId&&(s.deviceId={exact:s.deviceId}),this._requestedCamera=s}else s=this._requestedCamera;const n={video:Object.assign({},s,this._requestedResolution),audio:!1};if(Object.keys(n.video).length||(n.video=!0),null===(t=navigator)||void 0===t||!t.mediaDevices)throw Error(ei);e._delayBeforeGetUserMedia&&await new Promise(t=>setTimeout(t,e._delayBeforeGetUserMedia));let o,r=navigator.mediaDevices.getUserMedia(n);try{o=await(this._getUserMediaTimeout?Promise.race([r,new Promise((e,t)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",t(e)},this._getUserMediaTimeout))]):r)}catch(t){if(this._bTryAnotherCameraWhenFailToOpen||!["NotReadableError","AbortError","OverconstrainedError","DMCameraTimeout"].includes(null==t?void 0:t.name))throw t;console.warn(t),console.warn("Try default camera."),r=navigator.mediaDevices.getUserMedia({video:this._constraints4Fallback});try{let e=this._getUserMediaTimeout;e>5e3&&(e=5e3),o=await(e?Promise.race([r,new Promise((t,i)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",i(e)},e))]):r)}catch(i){if(console.warn(i),!zt||!e._mapDeviceInfo)throw t;const s=Object.keys(e._mapDeviceInfo);if(s.length<2)throw t;console.warn("Try other cameras.");let n=this._getUserMediaTimeout;n>2500&&(n=2500);for(let e of s)try{r=navigator.mediaDevices.getUserMedia({video:{deviceId:{exact:e}}}),o=await(n?Promise.race([r,new Promise((e,t)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",t(e)},n))]):r);break}catch(e){console.warn(e)}if(!o)throw t}}if("closing"===this.status)throw Error("Camera closed.");this._video.srcObject=o}else{if(await this._video.play(),"closing"===this.status)throw Error("Camera closed.");let e=0;for(;++e<100&&!(this.video.readyState>=HTMLMediaElement.HAVE_ENOUGH_DATA);)if(await new Promise(e=>setTimeout(e,100)),"closing"===this.status)throw Error("Camera closed.")}if(Xt&&"customized-video"!==this._requestedCamera){if(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)}),"closing"===this.status)throw Error("Camera closed.");await Promise.race([this.video.play(),new Promise((t,i)=>setTimeout(()=>{i(Error("`video.play()` unresponsive in current iOS PWA environment. Please use `singleFrameMode='camera'` instead."))},e._videoPlayTimeout))])}else await Promise.race([this.video.play(),new Promise((t,i)=>setTimeout(()=>{i(Error("video play timeout"))},e._videoPlayTimeout))]);if("closing"===this.status)throw Error("Camera closed.");if(this.track){var s;const t=this.track.getSettings();if("customized-video"!==this._requestedCamera&&t.deviceId&&(null===(s=e._mapDeviceInfo)||void 0===s||!s[t.deviceId])){var n,o,r;const i=t.deviceId;null!==(n=e._mapDeviceInfo)&&void 0!==n||(e._mapDeviceInfo={}),e._mapDeviceInfo[i]={trackLabel:this.track.label,capabilities:null===(o=(r=this.track).getCapabilities)||void 0===o?void 0:o.call(r),isFront:"user"===this.track.getSettings().facingMode,toJSON:Jt}}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);)if(await new Promise(e=>setTimeout(e,100)),"closing"===this.status)throw Error("Camera closed.")}this._pOpen.resolve()}else{if(this._pOpen=new Yt,await this._video.play(),"closing"===this.status)throw Error("Camera closed.");this._paused=!1,this._pOpen.resolve()}e._currentOpenedCamera=this;for(let t of e._arrOnOpen)t.call(this);this._callOpenedListeners()}catch(e){var a,c;null!==(a=this._video.srcObject)&&void 0!==a&&null!==(c=a.getTracks)&&void 0!==c&&null!==(c=c.call(a))&&void 0!==c&&c.forEach(e=>e.stop()),this._video.srcObject=null;const t=this._pOpen;this._pOpen=null,this._shouldClose=!1,t.catch(e=>{}),t.reject();const i=Error(`Error opening camera: ${null==e?void 0:e.message}`,{cause:e});throw i.name=null==e?void 0:e.name,i}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(){for(let t of e._arrBeforeClose)t.call(this);if(this===e._currentOpenedCamera&&(e._currentOpenedCamera=null),"closed"!==this.status)if("opening"===this.status&&(this._shouldClose=!0),"closing"!==this.status){var t,i,s;null!==(t=this._video.srcObject)&&void 0!==t&&null!==(i=t.getTracks)&&void 0!==i&&null!==(i=i.call(t))&&void 0!==i&&i.forEach(e=>e.stop()),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)}})}else try{await this._pOpen}catch(e){}}async requestCamera(e){if("string"==typeof e)ii.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=Qt),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:o}=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 r=(null==o?void 0:o.canvas)||document.createElement("canvas");return r.width!=s&&(r.width=s),r.height!=n&&(r.height=n),(o||r.getContext("2d")).drawImage(this._video,t,i,s,n,0,0,s,n),r}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));const i=this._regionBoxMask,s=this._regionBoxBorder,n=e.width,o=e.height,r=e.center;"string"==typeof e.innerUi&&(e.innerUi=Zt(e.innerUi)),e.innerUi instanceof DocumentFragment?(s.textContent="",s.append(e.innerUi),e.innerUi=s.childNodes):e.innerUi instanceof Node?1==s.childNodes.length&&s.firstChild==e.innerUi||(s.textContent="",s.append(e.innerUi)):e.innerUi instanceof NodeList?s.childNodes!==e.innerUi&&(s.textContent="",s.append(...e.innerUi),e.innerUi=s.childNodes):e.innerUi instanceof Array?(s.textContent="",s.append(...e.innerUi),e.innerUi=s.childNodes):s.textContent="";let a=100*r.y-50*o+50+"%",c=100*r.x+50*n+50+"%",l=100*r.y+50*o+50+"%",d=100*r.x-50*n+50+"%";Object.assign(i.style,{clipPath:`polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, ${d} ${a}, ${d} ${l}, ${c} ${l}, ${c} ${a}, ${d} ${a})`}),"view-min"===e.unit&&(a=`calc(${100*r.y+50}% + max(-${50*o}cqmin, -${50*o}cqmax))`,c=`calc(${100*r.x+50}% + ${50*n}cqmin)`,l=`calc(${100*r.y+50}% + ${50*o}cqmin)`,d=`calc(${100*r.x+50}% + max(-${50*n}cqmin, -${50*n}cqmax))`,Object.assign(i.style,{clipPath:`polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, ${d} ${a}, ${d} ${l}, ${c} ${l}, ${c} ${a}, ${d} ${a})`})),Object.assign(i.style,{...e.maskStyle}),Object.assign(s.style,{width:100*n+"%",height:100*o+"%"}),"view-min"===e.unit&&Object.assign(s.style,{width:100*n+"cqmin",height:100*o+"cqmin"}),Object.assign(s.style,{top:100*r.y+50+"%",left:100*r.x+50+"%",...e.borderStyle}),"view-size"===e.unit&&1===n&&1===o&&(s.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(),o=parseFloat(s.borderLeftWidth),r=parseFloat(s.borderTopWidth);return e.map(e=>({left:(this._isMirrored?t.videoWidth-e.x:e.x)/t.videoWidth*i.width+i.x-n.x-o,top:e.y/t.videoHeight*i.height+i.y-n.y-r}))}}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),o=parseFloat(t.borderRightWidth),r=parseFloat(t.borderBottomWidth);s.x+=i,s.y+=n,s.width-=i+o,s.height-=n+r}else{const e=this._coreShell.getBoundingClientRect();s={x:e.x,y:e.y,width:e.width,height:e.height}}const n=this._video.getBoundingClientRect(),o={x:(s.x-n.x)/n.width,y:(s.y-n.y)/n.height,width:s.width/n.width,height:s.height/n.height};o.x<0&&(o.width+=o.x,o.x=0),o.x>1&&(o.width-=o.x-1,o.x=1),o.y<0&&(o.height+=o.y,o.y=0),o.y>1&&(o.height-=o.y-1,o.y=1),o.x+o.width>1&&(o.width=1-o.x),o.x+o.width<0&&(o.width=-o.x),o.y+o.height>1&&(o.height=1-o.y),o.y+o.height<0&&(o.height=-o.y);const r=this._video.videoWidth,a=this._video.videoHeight;let c=(this._isMirrored?1-o.x-o.width:o.x)*r,l=o.y*a,d=o.width*r,u=o.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}}};a(ti,"_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"]]),a(ti,"_currentOpenedCamera",void 0),a(ti,"_mapDeviceInfo",void 0),a(ti,"_delayBeforeEnumerateDevices",0),a(ti,"_delayBeforeGetUserMedia",Kt?1e3:0),a(ti,"_delayBeforeApplyConstraints",0),a(ti,"_countEnsureResolution",Kt?20:10),a(ti,"_videoPlayTimeout",zt?1e4:3e3),a(ti,"_bReopenWhenChangeResolution",$t),a(ti,"_arrConstructors",[]),a(ti,"_arrOnOpen",[]),a(ti,"_arrBeforeClose",[]),a(ti,"_arrOnClose",[]);const ii=["back","front","macro-back","quick-back","customized-video"];ti.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 o=null===(s=i.currentCamera)||void 0===s||null===(s=s.capabilities)||void 0===s?void 0:s[t],{min:r,step:a,max:c}=o||{};null!=r&&n<r?n=r:null!=c&&n>c&&(n=c),null!=a&&null!=r&&(n=r+Math.round((n-r)/a)*a,c&&n>c&&(n-=a)),e[t]=n}}return e},ti._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(ti.prototype,"softZoom",{get(){return this._softZoom}}),Object.defineProperty(ti.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(ti.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(ti.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)}}),ti.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},ti.prototype.setZoom=async function(e){const t=this;if("opened"!==t.status)throw Error("Camera not open");ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await t.applyConstraints(t.correctAdvancedConstraint(t.correctAdvancedConstraint({advanced:[{zoom:e}]})))},ti.prototype.setSoftZoom=function(e,t){const i=this;let{center:s,limit:n}=t||{},{x:o=0,y:r=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;o<-t?o=-t:o>t&&(o=t),r<-t?r=-t:r>t&&(r=t)}a+=` translate(${o*=-100}%, ${r*=-100}%)`}i._softZoom={zoom:e,center:{x:o,y:r}},i._coreInnerLayer.style.transform=a},ti.prototype._changeZoomByWheel=function(e){var t;const i=this,s=Date.now();let n=i._softZoom.zoom,o=n-e.deltaY/200;o>i.maxZoom4GestureWheel&&(o=i.maxZoom4GestureWheel),o<1&&(o=1),o!==n&&(i.setSoftZoom(o,{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)}}))},ti.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],o=e.touches[1],r=t._mapZoomTouchs.get(n.identifier),a=t._mapZoomTouchs.get(o.identifier);if(!r||!a)break;let c=Math.pow(Math.pow(r.x-a.x,2)+Math.pow(r.y-a.y,2),.5),l=Math.pow(Math.pow(n.clientX-o.clientX,2)+Math.pow(n.clientY-o.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})},ti._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"}),ti._getImageContrast=(e,t,i)=>{let s=0;for(let n=0;n<i-1;n++)for(let i=0;i<t-1;i++){const o=4*(n*t+i),r=o+4,a=o+4*t,c=e[o]-e[r],l=e[o+1]-e[r+1],d=e[o+2]-e[r+2],u=e[o]-e[a],h=e[o+1]-e[a+1],_=e[o+2]-e[a+2];s+=c*c+l*l+d*d+u*u+h*h+_*_}return s},ti.prototype._simpleFocus=async function(){var e,t,i,s,n;const o=this;if("opened"!==o.status)throw Error("Camera not open");if(o._isFocusing)return;const r=null===(e=o.currentCamera)||void 0===e?void 0:e.capabilities;let a,c;if(null!=r&&null!==(t=r.focusMode)&&void 0!==t&&t.includes("manual"))if(null!=r&&null!==(i=r.focusMode)&&void 0!==i&&i.includes("continuous"))a="manual",c="continuous";else{var l;if(null==r||null===(l=r.focusMode)||void 0===l||!l.includes("single-shot"))return void o._advancedFocus();a="manual",c="single-shot"}else if(null!=r&&null!==(s=r.focusMode)&&void 0!==s&&s.includes("single-shot"))null!=r&&null!==(n=r.focusMode)&&void 0!==n&&n.includes("continuous")?(a="continuous",c="single-shot"):(a=null,c="single-shot");else{var d;if(null==r||null===(d=r.focusMode)||void 0===d||!d.includes("continuous"))return;a=null,c="continuous"}o._isFocusing=!0;try{var u;a&&("manual"===a?(ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await o.applyConstraints(o.correctAdvancedConstraint({advanced:[{focusMode:"manual",focusDistance:(null==r||null===(u=r.focusDistance)||void 0===u?void 0:u.max)||10}]}))):(ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await o.applyConstraints({advanced:[{focusMode:a}]})),await new Promise(e=>setTimeout(e,500))),ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await o.applyConstraints({advanced:[{focusMode:c}]}),await new Promise(e=>setTimeout(e,500))}catch(r){"opened"===o.status&&console.warn("Error while do simple focus",r)}o._isFocusing=!1},ti.prototype._advancedFocus=async function(e,t,i){var s,n,o,r;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,_=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),h=e.x-t/2,_=e.y-i/2):(t=d,i=u),a._isFocusing=!0;const m=++a._advancedFocusTaskId;let g=null==c||null===(o=c.focusDistance)||void 0===o?void 0:o.min;(!g||g<l.minFocusDistanceLimit)&&(g=l.minFocusDistanceLimit);let p=null==c||null===(r=c.focusDistance)||void 0===r?void 0:r.max;(!p||p>l.maxFocusDistanceLimit)&&(p=l.maxFocusDistanceLimit);let f=-1/0,E=-1/0,y=1/0,I=p,v=!1,R=!0;const C=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});let T=0;try{for(;++T<l.maxStepCount;){let e;ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._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:h,y:_,width:t,height:i,reusedContext:C});const s=C.getImageData(0,0,t,i).data,n=ti._getImageContrast(s,t,i);if(v){if(n<=f){ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await a.applyConstraints(a.correctAdvancedConstraint({advanced:[{focusMode:"manual",bestFocusDistance:y}]})),ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await a.applyConstraints(a.correctAdvancedConstraint({advanced:[{focusMode:"manual",bestFocusDistance:y}]}));break}if(p===I)break;f=n,n>E&&(E=n,y=I),I*=l.fineTuneRate,I>p&&(I=p)}else(n<=E*l.coarseTuneTolerance||g===I)&&(v=!0),f=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){ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints));try{await a.applyConstraints({advanced:[{focusMode:"continuous"}]})}catch(e){}}},l.backToContinousDuration)},Object.defineProperty(ti.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:o}]=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)/(o-s)*t._video.videoHeight})}else t._simpleFocus()},t._coreShell.addEventListener("pointerdown",t._tapToFocusListner)):t._tapToFocusListner&&(t._coreShell.removeEventListener("pointerdown",t._tapToFocusListner),t._tapToFocusListner=null)}}),ti._arrConstructors.push(function(){this._isTorchOn=!1,this._autoTorchParameters={shortDelay:250,longDelay:1e3,shortLongDelaySwitchCount:10,grayThreshold:20,maxDarkCount:3}}),ti._arrOnClose.push(function(){this._isTorchOn=!1}),Object.defineProperty(ti.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(ti.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}}),ti.prototype.turnOnTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints));try{await e.applyConstraints({advanced:[{torch:!0}]})}catch(t){throw e._isTorchOn=!1,t}e._isTorchOn=!0},ti.prototype.turnOffTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await e.applyConstraints({advanced:[{torch:!1}]}),e._isTorchOn=!1},ti.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,o=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 r;await e.turnOnTorch(),null===(r=e._eventListeners.torchAutoOn)||void 0===r||r.forEach(t=>{try{t.call(e)}catch(e){console.error(e)}})}catch(e){}break}await new Promise(e=>setTimeout(e,o<t.shortLongDelaySwitchCount?t.shortDelay:t.longDelay)),++o}})()};const si="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(Pt=window)&&void 0!==Pt&&Pt.MSStream),ni="undefined"!=typeof navigator&&/MiuiBrowser/.test(navigator.userAgent),oi="undefined"!=typeof navigator&&/SamsungBrowser/.test(navigator.userAgent);let ri,ai;ti._arrConstructors.push(function(){this._shouldCloseWhenHide=!0,this._maxReopenTry4CloseWhenHide=4}),ti._arrOnOpen.push(function(){this._bindCloseWhenHide()}),ti._arrBeforeClose.push(function(){this._isDuringCloseWhenHide||this._unbindCloseWhenHide()}),Object.defineProperty(ti.prototype,"shouldCloseWhenHide",{get(){return this._shouldCloseWhenHide},set(e){const t=this;t._shouldCloseWhenHide=e,("opened"===t.status||"paused"===t.status&&!t._paused)&&(e?t._bindCloseWhenHide():t._unbindCloseWhenHide())}}),ti.prototype._closeWhenHide=async function(){var e;const t=this;if("hidden"===document.visibilityState)("opened"===t.status||"paused"===t.status&&!t._paused&&(si&&"live"===(null===(e=t.track)||void 0===e?void 0:e.readyState)||ni&&"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}}},ti.prototype._bindCloseWhenHide=function(){const e=this;e._shouldCloseWhenHide&&(e._closeWhenHideListener||(e._closeWhenHideListener=()=>{e._closeWhenHide()},document.addEventListener("visibilitychange",e._closeWhenHideListener),oi&&window.addEventListener("blur",e._closeWhenHideListener)))},ti.prototype._unbindCloseWhenHide=function(){const e=this;e._closeWhenHideListener&&(document.removeEventListener("visibilitychange",e._closeWhenHideListener),oi&&window.removeEventListener("blur",e._closeWhenHideListener),e._closeWhenHideListener=null,e._isOpenBeforeHide=!1)},ti._id4CloseWhenNotInDOM=0,ti._stMSBNotInDOMCamera=new Set,ti._arrConstructors.push(function(){this._id4CloseWhenNotInDOM=++ti._id4CloseWhenNotInDOM,this._shouldCloseWhenNotInDOM=!0,this._bClosedBecauseOfNotInDOM=!1}),ti.prototype._updateMo4CloseWhenNotInDOM=function(){var e;if(null!==(e=this._mo4CloseWhenNotInDOM)&&void 0!==e&&e.disconnect(),!this._shouldCloseWhenNotInDOM||!["opened","paused"].includes(this.status))return this._mo4CloseWhenNotInDOM=null,void ti._stMSBNotInDOMCamera.delete(this);let t;if(this._video.isConnected){ti._stMSBNotInDOMCamera.delete(this);for(let e of ti._stMSBNotInDOMCamera)e._id4CloseWhenNotInDOM<this._id4CloseWhenNotInDOM&&(e.close(),e._bClosedBecauseOfNotInDOM=!0,ti._stMSBNotInDOMCamera.delete(e));t=new MutationObserver(()=>{this._video.isConnected||(t.disconnect(),this.close(),this._bClosedBecauseOfNotInDOM=!0)})}else ti._stMSBNotInDOMCamera.add(this),t=new MutationObserver(()=>{this._video.isConnected&&this._updateMo4CloseWhenNotInDOM()});this._mo4CloseWhenNotInDOM=t,t.observe(document.body,{childList:!0,subtree:!0})},ti._arrOnOpen.push(function(){this._updateMo4CloseWhenNotInDOM(),this._bClosedBecauseOfNotInDOM=!1}),ti._arrBeforeClose.push(function(){this._updateMo4CloseWhenNotInDOM()}),Object.defineProperty(ti.prototype,"shouldCloseWhenNotInDOM",{get(){return this._shouldCloseWhenNotInDOM},set(e){this._shouldCloseWhenNotInDOM=!!e,this._updateMo4CloseWhenNotInDOM()}}),ti.showFilePicker=async function(e){var t;null===(t=ri)||void 0===t||t.remove();const i=ri=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,t){i.addEventListener("change",function(){var s;null!==(s=i.files)&&void 0!==s&&s.length?e(Array.from(i.files)):t(new Error("No file selected.")),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},ti.filePicker2CanvasMaxWH=4096,ti.showFilePicker2Canvas=async function(e){var t;let i=ti.filePicker2CanvasMaxWH;(null===(t=e)||void 0===t?void 0:t.canvasMaxWH)&&(i=e.canvasMaxWH,delete(e={...e}).canvasMaxWH);let s=await ti.showFilePicker(e),n=[];for(let e of s){const t=document.createElement("canvas"),s=t.getContext("2d"),o=URL.createObjectURL(e),r=new Image;r.src=o,await r.decode(),r.naturalWidth<i&&r.naturalHeight<i?(t.width=r.width,t.height=r.height,s.drawImage(r,0,0)):(r.naturalWidth/r.naturalHeight>1?(t.width=i,t.height=Math.round(r.naturalHeight/r.naturalWidth*i)):(t.height=i,t.width=Math.round(r.naturalWidth/r.naturalHeight*i)),s.drawImage(r,0,0,t.width,t.height)),URL.revokeObjectURL(o),n.push(t)}return n};let ci=class{constructor(e){a(this,"camera",void 0),a(this,"_ctx",void 0),a(this,"_data",void 0),a(this,"_dataTime",-1/0),a(this,"_x",void 0),a(this,"_y",void 0),a(this,"_w",void 0),a(this,"_h",void 0),a(this,"_type",void 0),a(this,"maxTimeout",500),a(this,"_pipeTaskId",void 0),a(this,"isSaveOriginalRgba",!1),a(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);if("gray"===this._type)for(let i=0;i<e.length;i+=4)t[i/4]=.3*e[i]+.59*e[i+1]+.11*e[i+2];else if("r"===this._type)for(let i=0;i<e.length;i+=4)t[i/4]=e[i];else if("g"===this._type)for(let i=0;i<e.length;i+=4)t[i/4]=e[i+1];else if("b"===this._type)for(let i=0;i<e.length;i+=4)t[i/4]=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:o="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 r=t!==this._x||i!==this._y||s!==this._w||n!==this._h||o!==this._type;let a;return r&&(this._x=t,this._y=i,this._w=s,this._h=n,this._type=o),!r&&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}},li=class{constructor(){a(this,"_stAudioFree",new Set),a(this,"_stAudioPlaying",new Set),a(this,"_timeLastPlay",0),a(this,"_bWarnedMaxTrack",!1),a(this,"maxPlayingBeep",16),a(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=void 0),!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 di=()=>{(null!=ai?ai:ai=new li).beep()},ui=(e=300)=>{var t;if(null===(t=navigator)||void 0===t||!t.vibrate)throw new Error("Not supported.");navigator.vibrate(e)},hi=ti,_i=ti;if(null!==(kt=document)&&void 0!==kt&&kt.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 mi={x:0,y:0,width:100,height:100,isMeasuredInPercentage:!0};hi.createInstance=async function(e){let t;if(e instanceof ti?(t=e,e=void 0):t=new ti,void 0===t.disposed){if(t.isCameraEnhancer=!0,t.disposed=!1,t._cameraEnhancer=t._cameraView=t,t._framePipeline=new ci(t),t._dceScanRegion=mi,t._dceEventListeners={},t._bAutoSingleFrameModeWhenIosPwaFail=!0,t._oriOpen=t.open,t.open=gi,t._oriUpdateCanvasSize=t._updateCanvasSize,t._updateCanvasSize=fi,t._oriAddCanvas=t.addCanvas,t.addCanvas=Ei,t._dceZoom=1,t._dceEnhancedFeatures=0,t._dceAutoZoomRange={min:1,max:10},t._oriSetZoom=t.setZoom,t.setZoom=yi,t.singleFrameMode="disabled",t._singleFrameModeObjectFit="contain",t._ifSaveLastUsedCamera=!1,t._pixelFormat=10,t._colourChannelUsageType=1,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=_i.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:ki.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 o=null===(s=t.currentCamera)||void 0===s?void 0:s.deviceId,r=t._dceLastDeviceId;o!==r&&(t._dceLastDeviceId=o,null===(n=this._dceEventListeners.cameraChange)||void 0===n||n.forEach(e=>{try{e.call(this,o,r)}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 Bi)return e.quad.points;if(e instanceof Fi||e instanceof xi||e instanceof Pi){let{x:t,y:i,width:s,height:n}=e.rect,o=t+s,r=i+n;return[{x:t,y:i},{x:t,y:r},{x:o,y:r},{x:o,y:i}]}return e instanceof Mi?[e.line.startPoint,e.line.endPoint]:void 0}).flat()).map(e=>[e.left,e.top]);let o=n.length;for(let t=s.length-1;t>=0;--t){let a=s[t],c=!1;if(a instanceof Bi||a instanceof Fi||a instanceof xi||a instanceof Pi?(c=Li(i,[n[o-4],n[o-3],n[o-2],n[o-1]]),o-=4):a instanceof Mi&&(c=Li(i,[n[o-2],n[o-1]]),o-=2),c){var r;e.targetItem=a,e.itemPageX=n[o][0],e.itemPageY=n[o][1],e.itemClientX=e.itemPageX-e.pageX+e.clientX,e.itemClientY=e.itemPageY-e.pageY+e.clientY,null===(r=a._dceEventListeners[e.type])||void 0===r||r.forEach(t=>{try{t.call(this,e)}catch(e){console.error(e)}});break}}})}),"undefined"!=typeof ResizeObserver&&(t._singleFrameModeUIAutoFitRO=new ResizeObserver(()=>{var e;if(!t._coreShell.isConnected||!t._singleFrameModeCvs)return;t._singleFrameModeUpdateObjectFit();const i=null===(e=navigator)||void 0===e?void 0:e.userAgent;if(i&&/iPhone|iPad/i.test(i)){t._taskIdIOSResizeProblem&&clearInterval(t._taskIdIOSResizeProblem);let e=0;t._taskIdIOSResizeProblem=setInterval(()=>{if(++e>10||!t._coreShell.isConnected||!t._singleFrameModeCvs)return clearInterval(t._taskIdIOSResizeProblem),void(t._taskIdIOSResizeProblem=null);t._singleFrameModeUpdateObjectFit()},100)}}))}return t},hi.defaultUIElementURL="@engineResourcePath/ui/dce.ui.xml",Object.defineProperty(hi.prototype,"cameraOpenTimeout",{get(){return this._getUserMediaTimeout},set(e){this._getUserMediaTimeout=e}});const gi=async function(){var e,t,i,s,n;const o=this;if("disabled"!==o.singleFrameMode){var r;let e=await pi("camera"===o.singleFrameMode);{let t;switch(o._colourChannelUsageType){case 1:break;case 2:t="gray";case 3:t="r";case 4:t="g";case 5:t="b";const i=e.bytes,s=new Uint8Array(i.length/4);if("gray"===t)for(let e=0;e<i.length;e+=4)s[e/4]=.3*i[e]+.59*i[e+1]+.11*i[e+2];else if("r"===t)for(let e=0;e<i.length;e+=4)s[e/4]=i[e];else if("g"===t)for(let e=0;e<i.length;e+=4)s[e/4]=i[e+1];else if("b"===t)for(let e=0;e<i.length;e+=4)s[e/4]=i[e+2];e={bytes:s,width:e.width,height:e.height,stride:e.width,format:2,toCanvas:function(){return Ii(this.bytes,this.width,this.height,this.format)},imageTag:{imageId:++vi,type:0}}}}const t=o.ui.querySelector(".dce-bg-camera");"closed"!==o.status&&await o.close(),t&&(t.style.opacity="0");{var a;o._singleFrameModeCvs&&o._singleFrameModeCvs.remove();const t=o._singleFrameModeCvs=e.toCanvas();Object.assign(t.style,{width:"100%",height:"100%",position:"absolute",left:"0px",top:"0px"}),o._video.parentElement.querySelectorAll("canvas").forEach(e=>{e.width!==t.width&&(e.width=t.width),e.height!==t.height&&(e.height=t.height)}),o._singleFrameModeUpdateObjectFit(),o._video.before(t),null===(a=o._singleFrameModeUIAutoFitRO)||void 0===a||a.observe(o._coreShell)}return o._singleFrameModeResultForDcv=e,void(null===(r=o._dceEventListeners.singleFrameAcquired)||void 0===r||r.forEach(t=>{try{t.call(this,e)}catch(t){console.error(t)}}))}o.videoSrc&&(o.video.src=o._dceVideoSrc);const c=o.ui.querySelector(".dce-bg-loading");c&&(c.style.display="");try{await o._oriOpen()}catch(e){var l,d,u;if(hi.onWarning&&hi.onWarning(null==e?void 0:e.message),o._bAutoSingleFrameModeWhenIosPwaFail&&null!=e&&null!==(l=e.message)&&void 0!==l&&l.includes("iOS PWA"))return console.warn(e.message),c&&(c.style.display="none"),console.warn("Auto switch to `singleFrameMode = 'camera'`."),o.singleFrameMode="camera",void(null===(d=o.funcShowToast)||void 0===d||d.call(o,"Click to Capture",8e3));throw c&&(c.style.display="none"),null!==(u=o.funcShowToast)&&void 0!==u&&u.call(o,null==e?void 0:e.message,8e3),e}return o._ifSaveLastUsedCamera&&null!==(e=o.currentCamera)&&void 0!==e&&e.deviceId&&(null!==(t=localStorage)&&void 0!==t&&t.setItem("dce-last-used-camera",null===(i=o.currentCamera)||void 0===i?void 0:i.deviceId),null!==(s=localStorage)&&void 0!==s&&s.setItem("dce-last-used-resolution",JSON.stringify(o.requestedResolution))),c&&(c.style.display="none"),await new Promise(e=>setTimeout(e,0)),{deviceId:null===(n=o.currentCamera)||void 0===n?void 0:n.deviceId,...o.currentResolution}},pi=async function(e){const t={multiple:!1};e&&(t.capture="environment");const i=(await ti.showFilePicker2Canvas(t))[0],s=i.getContext("2d").getImageData(0,0,i.width,i.height).data;return{bytes:new Uint8Array(s.buffer,s.byteOffset,s.length),width:i.width,height:i.height,stride:4*i.width,format:10,toCanvas:()=>i,imageTag:{imageId:++vi,type:0}}},fi=function(){"disabled"===this.singleFrameMode&&this._oriUpdateCanvasSize()},Ei=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};hi.prototype.dispose=function(){this.disposed=!0,this.close(),this.setScanLaserVisible(!1)},hi.prototype.getAllCameras=async function(){return(await ti.getDeviceInfos()).map(e=>({deviceId:e.deviceId,label:e.label||e.trackLabel}))},hi.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 o,r,a,c;await e.requestResolution(i),((null===(o=e.currentResolution)||void 0===o?void 0:o.width)===i[0]&&(null===(r=e.currentResolution)||void 0===r?void 0:r.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},hi.prototype.getCameraState=function(){let e=this.status;return"closing"===e||"paused"===e||"closed"===e?"closed":"opened"===e?"open":"opening"===e?"opening":void 0},hi.prototype.getResolution=function(){return"opened"===this.status?this.currentResolution:this.requestedResolution},hi.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},hi.prototype.getVideoSettings=function(){let e={};return"object"==typeof this.requestedCamera&&Object.assign(e,this.requestedCamera),Object.assign(e,this.requestedResolution),{video:e}},Object.defineProperty(hi.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 o=null===(s=localStorage)||void 0===s?void 0:s.getItem("dce-last-used-resolution");if(o)try{t.requestResolution(JSON.parse(o))}catch(e){}}}}),Object.defineProperty(hi.prototype,"ifSkipCameraInspection",{get(){return"quick-back"===this.requestedCamera},set(e){e?this.requestCamera("quick-back"):this.requestCamera("back")}}),hi.prototype.isOpen=function(){return"opened"===this.status},hi.prototype.isPaused=function(){return"paused"===this.status},hi.prototype.resume=async function(){await this._oriOpen()},hi.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}},hi.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}},hi.testCameraAccess=async function(){let e=!0,t="Successfully accessed the camera.";try{await ti.getDeviceInfos()}catch(i){e=!1,t=i.message||i}return{ok:e,message:t}},hi.prototype.updateVideoSettings=async function(e){const t="object"!=typeof e?null:null==e?void 0:e.video;await this.requestCamera(t)},Object.defineProperty(hi.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))}}),hi.prototype.disableEnhancedFeatures=function(e){this._dceEnhancedFeatures=this._dceEnhancedFeatures-(this._dceEnhancedFeatures&e)},hi.prototype.enableEnhancedFeatures=function(e){this._dceEnhancedFeatures|=e},hi.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},hi.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},hi.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},hi.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},hi.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},hi.prototype.setColorTemperature=async function(e){var t;const i=this;i.getColorTemperature(),ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{colorTemperature:e,whiteBalanceMode:"manual"}]})))},hi.prototype.setExposureCompensation=async function(e){var t;const i=this;i.getExposureCompensation(),ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{exposureCompensation:e}]})))},hi.prototype.setFrameRate=async function(e){var t;const i=this;i.getFrameRate(),ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{frameRate:e}]})))},hi.prototype.getZoomSettings=function(){return{factor:this._dceZoom}};const yi=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 Ii(e,t,i,s){const n=document.createElement("canvas");n.width=t,n.height=i;const o=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 r=new Uint8ClampedArray(e),a=new ImageData(r,t,i);return o.putImageData(a,0,0),n}hi.prototype.resetZoom=async function(){this._dceZoom=1,this.setSoftZoom(1,{center:{x:0,y:0}});try{await this._oriSetZoom(1)}catch(e){}},hi.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),o=null==n?void 0:n.focusMode;if(void 0===o)throw Error("Not supported");return s=o===(null===(i=this._dceFocusSettings)||void 0===i?void 0:i.mode)?this._dceFocusSettings:{mode:o},"manual"===s.mode&&(s.distance=null==n?void 0:n.focusDistance),s},hi.prototype.setFocus=async function(e){const t=this;if(!t.track)throw Error("Camera not open");if(t._dceFocusSettings=e,"manual"!==e.mode)ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._delayBeforeApplyConstraints)),await t.applyConstraints({advanced:[{focusMode:e.mode}]});else if(e.distance)ti._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,ti._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,o=e.area.height,r=t.currentResolution.width,a=t.currentResolution.height;"string"==typeof i&&(i=i.endsWith("%")?parseFloat(i)*r:parseFloat(i)),"string"==typeof s&&(s=s.endsWith("%")?parseFloat(s)*a:parseFloat(s)),"string"==typeof n&&(n=n.endsWith("%")?parseFloat(n)*r:parseFloat(n)),"string"==typeof o&&(o=o.endsWith("%")?parseFloat(o)*a:parseFloat(o)),await t._advancedFocus({x:i,y:s},n,o)}},hi.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)},hi.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},hi.prototype.toggleMirroring=function(e){this.isMirrored=e};let vi=0;hi.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:++vi,type:1}}},hi.prototype.getImage=function(){var e;const t=this,i=t.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0});let s;switch(t._colourChannelUsageType){case 1:default:s="rgba";break;case 2:s="gray";break;case 3:s="r";break;case 4:s="g";break;case 5:s="b"}let n=t._framePipeline.getData({...i,type:s});if(!n)return null;let{width:o,height:r}=i,a="rgba"===s?10:2;const c={bytes:n,width:o,height:r,stride:i.width*("rgba"===s?4:1),format:a,toCanvas:function(){return Ii(this.bytes,this.width,this.height,this.format)},imageTag:{imageId:++vi,type:1}};return null!==(e=this._dceEventListeners.frameAddedToBuffer)&&void 0!==e&&e.forEach(e=>{try{e.call(this,c)}catch(e){console.error(e)}}),c},hi.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 pi(!0);return i&&await t._oriOpen(),null!=e&&e(s),s},Object.defineProperty(hi.prototype,"singleFrameMode",{get(){return this._singleFrameMode},set(e){var t,i;const s=this;e?["image","camera","disabled"].includes(e)||(e="image"):e="disabled",s._singleFrameMode=e;const n=s.ui.querySelector(".dce-bg-camera");null!==(t=s._singleFrameModeCvs)&&void 0!==t&&t.remove(),s._singleFrameModeCvs=null,s._singleFrameModeResultForDcv=null,null!==(i=s._singleFrameModeUIAutoFitRO)&&void 0!==i&&i.disconnect(),"disabled"!==e?(s.close(),s._dceSettingsBeforeSingleFrameMode||(s._dceSettingsBeforeSingleFrameMode={shouldCloseWhenHide:s.shouldCloseWhenHide,regionBox:{...s.regionBox},requestedCamera:s.requestedCamera},s.shouldCloseWhenHide=!1,s.setRegionBox({width:1,height:1,unit:"view-size",center:{x:0,y:0},innerUi:void 0}),s.requestCamera("customized-video")),n&&(s._singleFrameModeClickCallback||(s._singleFrameModeClickCallback=()=>{s.open()},n.addEventListener("click",s._singleFrameModeClickCallback)),n.style.display="",n.style.opacity="")):(s._dceSettingsBeforeSingleFrameMode&&(s.shouldCloseWhenHide=s._dceSettingsBeforeSingleFrameMode.shouldCloseWhenHide,s.setRegionBox(s._dceSettingsBeforeSingleFrameMode.regionBox),s.requestCamera(s._dceSettingsBeforeSingleFrameMode.requestedCamera),s._dceSettingsBeforeSingleFrameMode=null),s._singleFrameModeClickCallback&&(n.removeEventListener("click",s._singleFrameModeClickCallback),s._singleFrameModeClickCallback=null),n&&(n.style.display="none"))}}),hi.prototype._singleFrameModeUpdateObjectFit=function(){const e=this,t=e._singleFrameModeCvs;if(!t)return;const i=e._coreOuterLayer.style;if("fill"===this._singleFrameModeObjectFit||void 0===i.aspectRatio)"100%"!==i.width&&(i.width="100%"),"100%"!==i.height&&(i.height="100%");else{const{width:s,height:n}=e._coreShell.getBoundingClientRect(),o=`${t.width} / ${t.height}`;o!=i.aspectRatio&&(i.aspectRatio=o);const r=s/n-t.width/t.height,a=.001;if(Math.abs(r)>a){let t=!1;r>0&&(t=!t),"cover"===e._singleFrameModeObjectFit&&(t=!t),t?("auto"!=i.width&&(i.width="auto"),"100%"!=i.height&&(i.height="100%")):("100%"!=i.width&&(i.width="100%"),"auto"!=i.height&&(i.height="auto"))}}},hi.prototype.getScanRegion=function(){return this._dceScanRegion},hi.prototype.hasNextImageToFetch=function(){return"opened"===this.status},hi.prototype.isBufferEmpty=function(){return"opened"!==this.status},hi.prototype.getPixelFormat=function(){return this._pixelFormat},hi.prototype.setPixelFormat=function(e){2===e?(this._pixelFormat=2,this._colourChannelUsageType=2):(this._pixelFormat=10,this._colourChannelUsageType=1)},hi.prototype.setColourChannelUsageType=function(e){switch(e){case 1:this._pixelFormat=10,this._colourChannelUsageType=1;break;case 2:this._pixelFormat=2,this._colourChannelUsageType=2;break;case 3:this._pixelFormat=2,this._colourChannelUsageType=3;break;case 4:this._pixelFormat=2,this._colourChannelUsageType=4;break;case 5:this._pixelFormat=2,this._colourChannelUsageType=5;break;default:2===this._pixelFormat?this._colourChannelUsageType=2:this._colourChannelUsageType=1}},hi.prototype.getColourChannelUsageType=function(){return this._colourChannelUsageType},hi.prototype.setScanRegion=function(e){this._dceScanRegion=null!=e?e:e=mi;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 o=e;this.setRegionBox({width:Math.min(o.width/s,1),height:Math.min(o.height/n,1),center:{x:0,y:0},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}else{let o=e;this.setRegionBox({width:Math.min((o.right-o.left)/s,1),height:Math.min((o.bottom-o.top)/n,1),center:{x:0,y:0},maskStyle:{background:t?i.fillStyle:""},borderStyle:{border:t?`${i.lineWidth}px solid ${i.strokeStyle}`:""}})}}},hi.prototype.setCameraView=function(e){if(e===this)return;const t=e.ui.parentElement;t&&(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)},hi.prototype.getCameraView=function(){return this},hi.prototype.getVideoEl=function(){return this.video},hi.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]},hi.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]},hi.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)}},hi.prototype.convertToContainCoordinates=function(e){const t=this;let i,s,n,o;{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,o=i}const r=t.video.videoWidth,a=t.video.videoHeight;let c=t.videoXY2AbsoluteLT([{x:0,y:0},{x:r,y:a}]);return{x:(e.x+n-i)/r*(c[1].left-c[0].left),y:(e.y+o-s)/a*(c[1].top-c[0].top)}},hi.prototype.on=function(e,t){var i,s;(null!==(s=(i=this._dceEventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)},hi.prototype.off=function(e,t){var i;null===(i=this._dceEventListeners[e])||void 0===i||i.delete(t)},_i.prototype.getUIElement=function(){return this.ui},_i.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(_i.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=hi.handleEngineResourcePaths(hi.CoreModule.engineResourcePaths);i=i.replace("@engineResourcePath/","DBR"===hi.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 ti.getDeviceInfos(),n=t.currentCamera;if(!n)return;const o=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===o&&(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")),o=parseInt(e.getAttribute("data-height"));await t.requestResolution({width:i,height:o})}),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 o=e.querySelector(".dce-bg-camera");if(o 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",o.parentElement.append(e),o.classList.remove("dce-bg-camera"),e.classList.add("dce-bg-camera"),e.append(o),o.style.display="",o=e}else o&&o.parentElement.append(o);let r=e.querySelector(".dm-camera-mn-toast,.dce-mn-toast");if(!r&&o){r=document.createElement("div"),r.classList.add("dm-camera-mn-toast"),Object.assign(r.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"}),o.parentElement.append(r);let e=null;t.funcShowToast=(t,i=3e3)=>{r&&(r.textContent=t,r.style.display="",null!=e&&(clearTimeout(e),e=null),i&&(e=setTimeout(()=>{r.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"),o=e.querySelector(".dce-mn-torch-off");s&&(s.style.display=void 0===t.isTorchOn?"":"none"),n&&(n.style.display=!0===t.isTorchOn?"":"none"),o&&(o.style.display=!1===t.isTorchOn?"":"none");const r=e.querySelector(".dce-mn-beep-on"),c=e.querySelector(".dce-mn-beep-off");r&&(r.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 p=e.querySelector(".dce-mn-camera-switch");p&&(p.style.display="none");const f=e.querySelector(".dce-mn-camera-and-resolution-settings");f&&(f.style.display="none");const E=null==f?void 0:f.querySelector(".dce-mn-cameras"),y=null==f?void 0:f.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||!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 ti.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 ti.hasFrontCamera()&&p&&(p.style.display="")}}),t.addEventListener("closed",()=>{t.disposed||(a.style.display="none",i&&(i.style.display="none"),u&&(u.style.display="none"),p&&(p.style.display="none"),f&&(f.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",o.style.display="")}),null!=o&&o.addEventListener("pointerdown",()=>{t.disposed||(t.isSupportTorch?(t.turnAutoTorch(),o.style.display="none",s.style.display=""):R("Torch Not Supported"))}),null!=r&&r.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!1,r.style.display="none",c.style.display="")}),null!=c&&c.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!0,c.style.display="none",r.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;const e=i.getAttribute("data-device-id");await t.requestCamera(e),"opened"!==t.status&&await t.open();const s=t.currentCamera;if(null!=s&&s.deviceId&&s.deviceId!=e){const e=s.trackLabel||s.label||s.deviceId;R(`Fallback to ${e}`)}}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==f?void 0:f.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(f&&(f.style.display=f.style.display?"":"none"))}f&&""===f.style.display&&(f.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==p||p.addEventListener("pointerdown",async()=>{"opened"===t.status&&await t.requestCamera(t.currentCamera.isFront?"back":"front")})}}s.classList.add(i)}}s||e.classList.add(i),t.ui=e},_i.prototype.getVideoElement=function(){return this.video},_i.prototype.setVideoFit=function(e){this.objectFit=e},_i.prototype.getVideoFit=function(){return this.objectFit},_i.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}}},_i.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}`:""}})},_i.prototype.getScanRegionMaskStyle=function(){return this._dceRegionMaskStyle},_i.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}`:""}})},_i.prototype.isScanRegionMaskVisible=function(){return this._dceRegionMaskVisible},_i.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)},_i.prototype.isScanLaserVisible=function(){var e;return!(null===(e=this.regionBox)||void 0===e||!e.innerUi)&&"none"!==this.regionBox.innerUi.style.display},_i.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")},_i.prototype.isPowerByMessageVisible=function(){let e=this.ui.querySelector(".dce-msg-poweredby,.dm-camera-mn-msg-poweredby");return e&&"none"!==e.style.display},_i.prototype.getTipConfig=function(){return{duration:this._dceTipDuration}},_i.prototype.setTipConfig=function(e){this._dceTipDuration=e.duration},_i.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")}},_i.prototype.isTipVisible=function(){const e=this.ui.querySelector(".dm-camera-mn-toast");return!!e&&"none"!=e.style.display},_i.prototype.updateTipMessage=function(e){var t;this._dceTipMessage=e,null===(t=this.funcShowToast)||void 0===t||t.call(this,this._dceTipMessage,this._dceTipDuration)},_i.prototype.createDrawingLayer=function(){const e=new Oi;return e._dce=this,e._ctx=this.addCanvas().getContext("2d"),this._drawingLayers.push(e),e},_i.prototype.getDrawingLayer=function(e){if(e instanceof Oi)return e;if("number"!=typeof e)return null;let t=this._drawingLayers[e];return t||1!==e&&2!==e&&3!==e||(t=new Oi,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},_i.prototype.getAllDrawingLayers=function(){for(let e=1;e<=3;e++)this.getDrawingLayer(e);return this._drawingLayers.filter(e=>e)},_i.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},_i.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])},_i.prototype.clearAllInnerDrawingItems=function(e){for(let t of this._drawingLayers.slice(1,4))!t||e&&"editor"===t._mode||t.clearDrawingItems()};let Ri=class{static beep(){null!=this._beepInstance?this._beepInstance.beep():di()}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 li),this._beepInstance.beepSoundSource=e}static vibrate(){null!=this.vibrateDuration?ui(this.vibrateDuration):ui()}};a(Ri,"_beepInstance",void 0),a(Ri,"vibrateDuration",void 0);const Ci="73,245,73",Ti="73,173,245",wi="254,180,32",Si="245,236,73",Ai=(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},Di=[null,Ai(Ti),Ai(Ci),Ai(wi),Ai(Si),Ai(Ti,"f"),Ai(Ci,"f"),Ai(wi,"f"),Ai(Si,"f"),Ai(Ti,"t"),Ai(Ci,"t"),Ai(wi,"t"),Ai(Si,"t")],bi={STYLE_BLUE_STROKE:Di[1],STYLE_GREEN_STROKE:Di[2],STYLE_ORANGE_STROKE:Di[3],STYLE_YELLOW_STROKE:Di[4],STYLE_BLUE_STROKE_FILL:Di[5],STYLE_GREEN_STROKE_FILL:Di[6],STYLE_ORANGE_STROKE_FILL:Di[7],STYLE_YELLOW_STROKE_FILL:Di[8],STYLE_BLUE_STROKE_TRANSPARENT:Di[9],STYLE_GREEN_STROKE_TRANSPARENT:Di[10],STYLE_ORANGE_STROKE_TRANSPARENT:Di[11],STYLE_YELLOW_STROKE_TRANSPARENT:Di[12],createDrawingStyle(e){let t=Object.assign({},this.STYLE_YELLOW_STROKE_FILL,e);return Object.assign(e,t),e},getDrawingStyle:e=>"number"==typeof e?Di[e]:e,getAllDrawingStyles:()=>Di.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 Oi=class{constructor(){a(this,"_visible",!0),a(this,"_dce",void 0),a(this,"_ctx",void 0),a(this,"_defaultStyle",bi.STYLE_YELLOW_STROKE_FILL),a(this,"_drawingItems",[]),a(this,"_mode","viewer"),a(this,"_editorView",void 0),a(this,"_extraEditorView",void 0),a(this,"_renderTask",void 0),a(this,"_newSelectedDrawingItems",[]),a(this,"_newDeselectedDrawingItems",[]),a(this,"_selectionChangedTask",void 0),a(this,"_onSelectionChanged",void 0)}getId(){return this}isVisible(){return this._extraEditorView?this._extraEditorView._firstLayer.isVisible():this._visible}setVisible(e){if(this._extraEditorView)return this._extraEditorView._firstLayer.setVisible(e);this._visible=e,this._delayRenderAll()}setDefaultStyle(e,t,i){if(this._extraEditorView)return this._extraEditorView._firstLayer.setDefaultStyle(e,t,i);this._defaultStyle=bi.getDrawingStyle(e),this._delayRenderAll()}addDrawingItems(e){if(this._extraEditorView)return this._extraEditorView._firstLayer.addDrawingItems(e);for(let t of e)t.drawingLayerId=this;this._drawingItems=this._drawingItems.concat(e),this._delayRenderAll()}removeDrawingItems(e){if(this._extraEditorView)return this._extraEditorView._firstLayer.removeDrawingItems(e);this._drawingItems=this._drawingItems.filter(t=>!e.includes(t)),this._delayRenderAll()}setDrawingItems(e){if(this._extraEditorView)return this._extraEditorView._firstLayer.setDrawingItems(e);for(let t of e)t.drawingLayerId=this;this._drawingItems=[...e],this._delayRenderAll()}getDrawingItems(e){return this._extraEditorView?this._extraEditorView._firstLayer.getDrawingItems(e):this._drawingItems.filter(t=>!e||e(t))}hasDrawingItem(e){return this._extraEditorView?this._extraEditorView._firstLayer.hasDrawingItem(e):this._drawingItems.includes(e)}getSelectedDrawingItems(){return this._extraEditorView?this._extraEditorView._firstLayer.getSelectedDrawingItems():this._drawingItems.filter(e=>e._bSelected)}clearDrawingItems(){if(this._extraEditorView)return this._extraEditorView._firstLayer.clearDrawingItems();this._drawingItems=[],this._delayRenderAll()}_delayRenderAll(){this._renderTask||(this._renderTask=setTimeout(()=>{this.renderAll(),this._renderTask=null},0))}renderAll(){var e;if(this._extraEditorView)return this._extraEditorView._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 xi){const o=e.text.split("\n"),{x:r,y:a,width:c,height:l}=e.rect,d=Math.min(i.fontSize*n,l/o.length);t.font=`${d}px ${i.fontFamily}`,t.textBaseline="top";const u=r+s.x;for(let e=0;e<o.length;++e){const i=a+l/o.length*e+s.y;t.fillText(o[e],u,i,c),t.strokeText(o[e],u,i,c)}continue}if(e instanceof Pi){const i=e.image,n=i.naturalWidth||i.videoWidth||i.width||0,o=i.naturalHeight||i.videoHeight||i.height||0;if(!n||!o)continue;let{x:r,y:a,width:c,height:l}=e.rect;e.maintainAspectRatio&&(l=c/n*o),t.drawImage(i,r+s.x,a+s.y,c,l);continue}if(e._bSelected&&(t.strokeStyle="#0f0",t.lineWidth=2*n,t.setLineDash([4,4])),t.beginPath(),e instanceof Bi){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 Mi){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 Fi){const{x:i,y:n,width:o,height:r}=e.rect;t.moveTo(i+s.x,n+s.y),t.lineTo(i+o+s.x,n+s.y),t.lineTo(i+o+s.x,n+r+s.y),t.lineTo(i+s.x,n+r+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._extraEditorView?this._extraEditorView._firstLayer.onSelectionChanged:this._onSelectionChanged}set onSelectionChanged(e){this._extraEditorView?this._extraEditorView._firstLayer.onSelectionChanged=e:this._onSelectionChanged=e}};function Li(e,t){const[i,s]=e;let n=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const[r,a]=t[e],[c,l]=t[o];if(i===r&&s===a||i===c&&s===l)return!0;if((i<=r&&i>=c||i>=r&&i<=c)&&(s<=a&&s>=l||s>=a&&s<=l)&&(i-r)*(s-a)===(i-c)*(s-l))return!0;a>s!=l>s&&i<(c-r)*(s-a)/(l-a)+r&&(n=!n)}return n}let Ni=class{constructor(){a(this,"coordinateBase","image"),a(this,"drawingLayerId",void 0),a(this,"drawingStyleId",void 0),a(this,"mediaType",void 0),a(this,"_notes",[]),a(this,"_bSelected",!1),a(this,"_dceEventListeners",{})}get _ps(){return null}getState(){return this._bSelected?Vi.DIS_SELECTED:Vi.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)}},Mi=class extends Ni{get _ps(){const e=this.line.startPoint,t=this.line.endPoint;return[e,e,t,t]}constructor(e,t){super(),a(this,"line",void 0),this.mediaType=Ui.DIMT_LINE,this.line=e,this.drawingStyleId=t}getLine(){return this.line}setLine(e){this.line=e,this._delayRenderAll()}},Bi=class extends Ni{get _ps(){return this.quad.points}constructor(e,t){super(),a(this,"quad",void 0),this.mediaType=Ui.DIMT_QUADRILATERAL,this.quad=e,this.drawingStyleId=t}getQuad(){return this.quad}setQuad(e){this.quad=e,this._delayRenderAll()}},Fi=class extends Ni{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(),a(this,"rect",void 0),this.mediaType=Ui.DIMT_RECTANGLE,this.rect=e,this.drawingStyleId=t}getRect(){return this.rect}setRect(e){this.rect=e,this._delayRenderAll()}},xi=class extends Ni{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(),a(this,"text",void 0),a(this,"rect",void 0),this.mediaType=Ui.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()}},Pi=class extends Ni{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(),a(this,"image",void 0),a(this,"rect",void 0),a(this,"maintainAspectRatio",void 0),this.mediaType=Ui.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=Ii(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 ki=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,o;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?o=bi.STYLE_ORANGE_STROKE_TRANSPARENT:(i._dceMNIsBeepBarcode&&di(),i._dceMNIsVibrateBarcode&&ui());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&&(o=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&&(o=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&&(o=bi.STYLE_BLUE_STROKE_TRANSPARENT);break;default:continue}s.addDrawingItems([new Bi({points:n},o)])}};var Ui,Vi,Gi,Wi;!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"}(Ui||(Ui={})),function(e){e[e.DIS_DEFAULT=1]="DIS_DEFAULT",e[e.DIS_SELECTED=2]="DIS_SELECTED"}(Vi||(Vi={})),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"}(Gi||(Gi={})),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"}(Wi||(Wi={}));var ji=Object.freeze({__proto__:null,Beep:li,Camera:ti,CameraEnhancer:hi,CameraEnhancerModule:{getVersion:()=>"5.0.0-dev-2026080315080"},CameraView:_i,DrawingItem:Ni,DrawingLayer:Oi,DrawingStyleManager:bi,get EnumDrawingItemMediaType(){return Ui},get EnumDrawingItemState(){return Vi},get EnumEnhancedFeatures(){return Gi},get EnumPixelFormat(){return Wi},Feedback:Ri,FramePipeline:ci,ImageDrawingItem:Pi,LineDrawingItem:Mi,QuadDrawingItem:Bi,RectDrawingItem:Fi,TextDrawingItem:xi,_bufferToCanvas:Ii,_distToSegment:function(e,t){const[i,s]=e,[[n,o],[r,a]]=t,c=r-n,l=a-o,d=c*c+l*l;if(0===d)return Math.sqrt((i-n)**2+(s-o)**2);let u=((i-n)*c+(s-o)*l)/d;u=Math.max(0,Math.min(1,u));const h=i-(n+u*c),_=s-(o+u*l);return Math.sqrt(h*h+_*_)},_isPointInPolygon:Li,beep:di,stringToHtml:Zt,vibrate:ui});const Zi="undefined"==typeof self,Hi=Zi?{}:self,qi="function"==typeof importScripts,Yi=(()=>{if(!qi){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"./"}})(),zi=e=>e&&"object"==typeof e&&"function"==typeof e.then,$i=(async()=>{})().constructor;let Ki=class extends $i{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,zi(e)?t=e:"function"==typeof e&&(t=new $i(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&&(zi(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};const Xi=" is not allowed to change after `createInstance` or `loadWasm` is called.",Qi=!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"))||"",Ji=(e,t)=>{const i=e;if(i._license!==t){if(!i._pLoad.isEmpty)throw new Error("`license`"+Xi);i._license=t}};!Zi&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword");const es=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},ts=(e,t)=>{t=es(t);const i=e;if(i._licenseServer!==t){if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+Xi);i._licenseServer=t}},is=(e,t)=>{t=t||"";const i=e;if(i._deviceFriendlyName!==t){if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+Xi);i._deviceFriendlyName=t}};let ss,ns,os,rs,as;"undefined"!=typeof navigator&&(ss=navigator,ns=ss.userAgent,os=ss.platform,rs=ss.mediaDevices),function(){if(!Zi){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:ss.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:os,search:"Win"},Mac:{str:os},Linux:{str:os}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let o=n.str||ns,r=n.search||t,a=n.verStr||ns,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=o.indexOf(r)){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||ns,o=i.search||e;if(-1!=s.indexOf(o)){n=e;break}}"Linux"==n&&-1!=ns.indexOf("Windows NT")&&(n="HarmonyOS"),as={browser:i,version:s,OS:n}}Zi&&(as={browser:"ssr",version:0,OS:"ssr"})}(),rs&&rs.getUserMedia,"Chrome"===as.browser&&as.version>66||"Safari"===as.browser&&as.version>13||"OPR"===as.browser&&as.version>43||"Edge"===as.browser&&as.version;const cs=new Ki,ls=async()=>(cs.isEmpty&&(cs.task=async(e,t)=>{await Ne.loadWasm();let{lt:i,l:s,ls:n,sp:o,rmk:r,cv:a}=((e,t=!1)=>{const i=e;if(i._pLoad.isEmpty){let s,n,o,r=i._license||"",a=JSON.parse(JSON.stringify(i._licenseServer)),c=i._sessionPassword,l=0;if(r.startsWith("t")||r.startsWith("f"))l=0;else if(0===r.length||r.startsWith("P")||r.startsWith("L")||r.startsWith("Y")||r.startsWith("A"))l=1;else{l=2;const t=r.indexOf(":");-1!=t&&(r=r.substring(t+1));const i=r.indexOf("?");if(-1!=i&&(n=r.substring(i+1),r=r.substring(0,i)),r.startsWith("DLC2"))l=0;else{if(r.startsWith("DLS2")){let t;try{let e=r.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(r=t.handshakeCode?t.handshakeCode:t.organizationID?t.organizationID:"","number"==typeof r&&(r=JSON.stringify(r)),0===a.length){let e=[];t.mainServerURL&&(e[0]=t.mainServerURL),t.standbyServerURL&&(e[1]=t.standbyServerURL),a=es(e)}!c&&t.sessionPassword&&(c=t.sessionPassword),s=t.remark}r&&"200001"!==r&&!r.startsWith("200001-")||(l=1)}}if(l&&(t||(Hi.crypto||(o="Please upgrade your browser to support online key."),Hi.crypto.subtle||(o="Require https to use online key in this browser."))),o)throw new Error(o);return 1===l&&console.warn("Applying for a public trial license ..."),{lt:l,l:r,ls:a,sp:c,rmk:s,cv:n}}throw new Error("Can't preprocess license again"+Xi)})(us);const c="undefined"!=typeof self?self:{};let l;us._pLoad.task=cs,(async()=>{try{await us._pLoad}catch(e){}})(),i&&(c.dyarm||(c.dyarm={}),c.dyarm[s]?l=(await c.dyarm[s]).ar:c.dyarm[s]=(async()=>(await cs,c.dyarm[s]=await ds(),c.dyarm[s]))());let d=Ce();Te[d]=s=>{var n;if(s.message&&us._onAuthMessage){let e=us._onAuthMessage(s.message);null!=e&&(s.message=e)}let o,r=!1;if(1===i&&(r=!0),s.success?(we&&(null===(n=Ne._onLog)||void 0===n||n.call(Ne,"init license success")),s.message&&console.warn(s.message),Ne._bSupportIRTModule=s.bSupportIRTModule,Ne._bSupportDce4Module=s.bSupportDce4Module,us.bPassValidation=!0,[0,-10076].includes(s.initLicenseInfo.errorCode)?[-10076].includes(s.initLicenseInfo.errorCode)&&console.warn(s.initLicenseInfo.errorString):t(new Error(s.initLicenseInfo.errorString))):(o=Error(s.message),s.stack&&(o.stack=s.stack),s.ltsErrorCode&&(o.ltsErrorCode=s.ltsErrorCode),r||111==s.ltsErrorCode&&-1!=s.message.toLowerCase().indexOf("trial license")&&(r=!0)),l&&(r=!1),r){const e=L(Ne.engineResourcePaths),t=("DCV"===Ne._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 o=document.createElement("div");o.insertAdjacentHTML("beforeend",n);let r=[];for(let e=0;e<o.childElementCount;++e){let t=o.children[e];t instanceof HTMLStyleElement&&(r.push(t),document.head.append(t))}let a=1==o.childElementCount?o.children[0]:o;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 r)e.remove()}});else if(!l&&e.classList.contains("dls-license-icon-close"))l=e,e.addEventListener("click",()=>{a.remove();for(let e of r)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),o=t.indexOf(")",n);if(-1==i||-1==s||-1==n||-1==o){e.appendChild(new Text(t));break}i>0&&e.appendChild(new Text(t.substring(0,i)));let r=document.createElement("a"),a=t.substring(i+1,s);r.innerText=a;let c=t.substring(n+1,o);r.setAttribute("href",c),r.setAttribute("target","_blank"),e.appendChild(r),t=t.substring(o+1)}}document.body.appendChild(a)}catch(t){e._onLog&&e._onLog(t.message||t)}})({_bNeverShowDialog:us._bNeverShowDialog,engineResourcePath:t,_onLog:Ne._onLog},s.success?"warn":"error",s.message)}s.success?e(void 0):t(o)};const u=await Ne.getModuleVersion();ve.postMessage({type:"l_dynamsoft",body:{v:"DCV"===Ne._bundleEnv?u.CVR.replace(/\.\d+$/,""):u.DBR.replace(/\.\d+$/,""),brtk:!!i,bptk:1===i,l:s,os:as,fn:us.deviceFriendlyName,ls:n,sp:o,rmk:r,cv:a,ar:l,_e:us._e,mliRecord:null===localStorage||void 0===localStorage?void 0:localStorage.getItem("dynamsoft")},id:d})}),await cs),ds=async()=>(cs&&cs.isRejected&&await cs,ve?new Promise((e,t)=>{const i=Ce();Te[i]=async i=>{if(i.success){delete i.success;{let e=us.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)}},ve.postMessage({type:"l_getAR",id:i})}):null);let us=class e{static setLicenseServer(t){ts(e,t)}static get license(){return this._license}static set license(t){Ji(e,t)}static get licenseServer(){return this._licenseServer}static set licenseServer(t){ts(e,t)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(t){is(e,t)}static async initLicense(t,i){if(Ji(e,t),e.bCallInitLicense=!0,"boolean"==typeof i&&i||"object"==typeof i&&i.executeNow)return await ls()}static setDeviceFriendlyName(t){is(e,t)}static getDeviceFriendlyName(){return e._deviceFriendlyName}static async getDeviceUUID(){return await(async()=>(await Ne.loadWasm(),await new Promise((e,t)=>{const i=Ce();Te[i]=i=>{if(i.success)e(i.uuid);else{const e=Error(i.message);i.stack&&(e.stack=i.stack),t(e)}},ve.postMessage({type:"l_getDeviceUUID",id:i})})))()}};us._pLoad=new Ki,us.bPassValidation=!1,us.bCallInitLicense=!1,us._license=Qi,us._licenseServer=[],us._deviceFriendlyName="",us._e=!0,De.license={},De.license.dynamsoft=ls,De.license.getAR=ds,Ne.engineResourcePaths.license={version:"4.6.30-dev-20260824140340",path:Yi,isInternal:!0},De.license.LicenseManager=us;var hs=Object.freeze({__proto__:null,LicenseManager:us,LicenseModule:class{static getVersion(){return`4.6.30-dev-20260824140340(Worker: ${Ae.license&&Ae.license.worker||"Not Loaded"}, Wasm: ${Ae.license&&Ae.license.wasm||"Not Loaded"})`}}});const _s=()=>window.matchMedia("(orientation: landscape)").matches,ms=e=>Object.prototype.toString.call(e).slice(8,-1);function gs(e,t){for(const i in t)"Object"===ms(t[i])&&"Object"===ms(e[i])&&i in e?gs(e[i],t[i]):("cameraFeatures"===i&&(t[i]=Array.isArray(t[i])?t[i]:[t[i]]),e[i]=t[i]);return e}function ps(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 fs(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]=fs(e[i])}else{t={};for(let i in e)e.hasOwnProperty(i)&&(t[i]=fs(e[i]))}return t}function Es(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 ys="undefined"==typeof self,Is="function"==typeof importScripts,vs=(()=>{if(!Is){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"./"}})();Ne.engineResourcePaths.dbr={version:"11.6.30-dev-20260824140359",path:vs,isInternal:!0},De.dbr={};const Rs={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 Cs,Ts,ws,Ss;!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"}(Cs||(Cs={})),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"}(Ts||(Ts={})),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"}(ws||(ws={})),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"}(Ss||(Ss={}));var As=Object.freeze({__proto__:null,BarcodeReaderModule:class{static getVersion(){const e=Ae.dbr&&Ae.dbr.wasm;return`11.6.30-dev-20260824140359(Worker: ${Ae.dbr&&Ae.dbr.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}},EnumBarcodeFormat:Rs,get EnumDeblurMode(){return Ss},get EnumExtendedBarcodeResultType(){return Cs},get EnumLocalizationMode(){return ws},get EnumQRCodeErrorCorrectionLevel(){return Ts}});const Ds="undefined"==typeof self,bs="function"==typeof importScripts,Os=(()=>{if(!bs){if(!Ds&&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"./"}})(),Ls=e=>{if(null==e&&(e="./"),Ds||bs);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},Ns="undefined"==typeof self,Ms="function"==typeof importScripts,Bs=(()=>{if(!Ms){if(!Ns&&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"./"}})();Ne.engineResourcePaths.utility={version:"2.6.30-dev-20260824140349",path:Bs,isInternal:!0};function Fs(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 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"./"}})();Ne.engineResourcePaths.dbr={version:"11.6.10-dev-20260601155910",path:ks,isInternal:!0},De.dbr={};const Us={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 Vs,Gs,Ws,js,Zs;(Zs=Vs||(Vs={}))[Zs.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",Zs[Zs.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",Zs[Zs.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"}(Gs||(Gs={})),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"}(Ws||(Ws={})),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"}(js||(js={}));const Hs=async(e,t)=>{let i,s=document.createElement("canvas"),n=s.getContext("2d"),o=e;try{if(o instanceof Blob){i=URL.createObjectURL(o);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),o=n.getImageData(0,0,s.width,s.height)}else s.width=o.width,s.height=o.height,n.putImageData(o,0,0);if("image/bmp"===t){const e=x(o);return new Blob([e],{type:"image/bmp"})}return await new Promise(e=>{s.toBlob(t=>{e(t)},t)})}finally{URL.revokeObjectURL(i)}};function qs(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 o=(n+1)%e.length;if(i(e[n],e[o],t)<0){s=!1;break}}return s}function Ys(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function zs(e,t){const[i,s]=e,n=i.x,o=i.y,r=s.x,a=s.y,c=t.x,l=t.y,d=(r-n)**2+(a-o)**2;if(0===d)return Math.sqrt((c-n)**2+(l-o)**2);const u=((c-n)*(r-n)+(l-o)*(a-o))/d;if(u<0)return Math.sqrt((c-n)**2+(l-o)**2);if(u>1)return Math.sqrt((c-r)**2+(l-a)**2);{const e=n+u*(r-n),t=o+u*(a-o);return Math.sqrt((c-e)**2+(l-t)**2)}}function $s(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 Ks(e){const[t,i]=e;return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}function Xs(e,t,i,s){const n=t.x-e.x,o=t.y-e.y,r=s.x-i.x,a=s.y-i.y,c=(-o*(e.x-i.x)+n*(e.y-i.y))/(-r*o+n*a),l=(r*(e.y-i.y)-a*(e.x-i.x))/(-r*o+n*a);return c>=0&&c<=1&&l>=0&&l<=1?{x:e.x+l*n,y:e.y+l*o}:null}function Qs(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 Js(e,t,i){let s=t.x-e.x,n=t.y-e.y,o=i.x-e.x;return s*(i.y-e.y)-n*o>0}function en(e,t){for(let i=0;i<4;i++)if(!Js(e.points[i],e.points[(i+1)%4],t))return!1;return!0}function tn(e,t,i,s){const n=e.points,o=t.points;let r=8*i;r=Math.max(r,5);const a=$s(n)[3],c=$s(n)[1],l=$s(o)[3],d=$s(o)[1];let u,h=0;if(u=Math.max(Math.abs(zs(a,t.points[0])),Math.abs(zs(a,t.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(zs(c,t.points[1])),Math.abs(zs(c,t.points[2]))),u>h&&(h=u),u=Math.max(Math.abs(zs(l,e.points[0])),Math.abs(zs(l,e.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(zs(d,e.points[1])),Math.abs(zs(d,e.points[2]))),u>h&&(h=u),h>r)return!1;const _=Ks($s(n)[0]),m=Ks($s(n)[2]),g=Ks($s(o)[0]),p=Ks($s(o)[2]),f=Ys(_,p),E=Ys(g,m),y=f>E,I=Math.min(f,E),v=Ys(_,m),R=Ys(g,p);let C=12*i;return C=Math.max(C,5),C=Math.min(C,v),C=Math.min(C,R),!!(I<C||qs(n,y?g:p)||qs(o,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=Qs(s.points),!0)}class sn{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),o=new Array(4).fill(0),r=0,a=0;for(let e=0;e<4;++e)n[e]=Math.round(100*(s.points[e].x-i.points[e].x))/100,r+=n[e],o[e]=Math.round(100*(s.points[e].y-i.points[e].y))/100,a+=o[e];r/=4,a/=4;for(let e=0;e<4;++e){if(Math.abs(n[e]-r)>this.strictLimit||Math.abs(r)>.8)return!1;if(Math.abs(o[e]-a)>this.strictLimit||Math.abs(a)>.8)return!1}return t.x=r,t.y=a,!0}isLocationOverlap(e,t){if(this.locationArea>t){for(let t=0;t<4;t++)if(en(this.location,e.points[t]))return!0;const t=this.getCenterPoint(e.points);if(en(this.location,t))return!0}else{for(let t=0;t<4;t++)if(en(e,this.location.points[t]))return!0;if(en(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],o=0===e||3===e?s:n;if(Math.abs(zs(o,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 o=Xs(e[s],e[(s+1)%4],t[n],t[(n+1)%4]);o&&i.push(o)}return e.forEach(e=>{qs(t,e)&&i.push(e)}),t.forEach(t=>{qs(e,t)&&i.push(t)}),Qs(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 nn,on,rn,an,cn,ln;const dn={barcode:2,text_line:4,detected_quad:8,deskewed_image:16},un=(e,t)=>"string"==typeof e?t[dn[e]]:t[e],hn=(e,t,i)=>{"string"==typeof e?t[dn[e]]=i:t[e]=i},_n=(e,t,i)=>{const s=[{type:ne.CRIT_BARCODE,resultName:"decodedBarcodesResult",itemNames:["barcodeResultItems"]},{type:ne.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},mn=e=>{const t=[];return e&ne.CRIT_BARCODE&&t.push(ne.CRIT_BARCODE),e&ne.CRIT_TEXT_LINE&&t.push(ne.CRIT_TEXT_LINE),e&ne.CRIT_DETECTED_QUAD&&t.push(ne.CRIT_DETECTED_QUAD),e&ne.CRIT_DESKEWED_IMAGE&&t.push(ne.CRIT_DESKEWED_IMAGE),t};class gn{constructor(){this.verificationEnabled={[ne.CRIT_BARCODE]:!1,[ne.CRIT_TEXT_LINE]:!0,[ne.CRIT_DETECTED_QUAD]:!0,[ne.CRIT_DESKEWED_IMAGE]:!1},this.duplicateFilterEnabled={[ne.CRIT_BARCODE]:!1,[ne.CRIT_TEXT_LINE]:!1,[ne.CRIT_DETECTED_QUAD]:!1,[ne.CRIT_DESKEWED_IMAGE]:!1},this.duplicateForgetTime={[ne.CRIT_BARCODE]:3e3,[ne.CRIT_TEXT_LINE]:3e3,[ne.CRIT_DETECTED_QUAD]:3e3,[ne.CRIT_DESKEWED_IMAGE]:3e3},this.crossVerificationCriteria={[ne.CRIT_BARCODE]:{frameWindow:5,minConsistentFrames:2},[ne.CRIT_TEXT_LINE]:{frameWindow:5,minConsistentFrames:2},[ne.CRIT_DETECTED_QUAD]:{frameWindow:6,minConsistentFrames:4},[ne.CRIT_DESKEWED_IMAGE]:{frameWindow:6,minConsistentFrames:4}},nn.set(this,new Map),on.set(this,new Map),rn.set(this,new Map),an.set(this,new Map),cn.set(this,new Map),ln.set(this,new Map),this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,this.latestOverlappingEnabled={[ne.CRIT_BARCODE]:!1,[ne.CRIT_TEXT_LINE]:!1,[ne.CRIT_DETECTED_QUAD]:!1,[ne.CRIT_DESKEWED_IMAGE]:!1},this.maxOverlappingFrames={[ne.CRIT_BARCODE]:this.crossVerificationFrames,[ne.CRIT_TEXT_LINE]:this.crossVerificationFrames,[ne.CRIT_DETECTED_QUAD]:this.crossVerificationFrames,[ne.CRIT_DESKEWED_IMAGE]:this.crossVerificationFrames},Object.defineProperties(this,{onOriginalImageResultReceived:{value:e=>{},writable:!1},onDecodedBarcodesReceived:{value:e=>{this.latestOverlappingFilter(e),_n(this,e,ne.CRIT_BARCODE)},writable:!1},onRecognizedTextLinesReceived:{value:e=>{_n(this,e,ne.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===ne.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(){Fs(this,nn,"f").forEach((e,t)=>{hn(t,this.verificationEnabled,e)}),Fs(this,on,"f").forEach((e,t)=>{hn(t,this.duplicateFilterEnabled,e)}),Fs(this,rn,"f").forEach((e,t)=>{hn(t,this.duplicateForgetTime,e)}),Fs(this,an,"f").forEach((e,t)=>{hn(t,this.latestOverlappingEnabled,e)}),Fs(this,cn,"f").forEach((e,t)=>{hn(t,this.maxOverlappingFrames,e)}),Fs(this,ln,"f").forEach((e,t)=>{hn(t,this.crossVerificationCriteria,e)})}enableResultCrossVerification(e,t=!0){if("number"==typeof e){const i=mn(e);for(let e of i)Fs(this,nn,"f").set(e,t)}else Fs(this,nn,"f").set(e,t)}isResultCrossVerificationEnabled(e){return un(e,this.verificationEnabled)}enableResultDeduplication(e,t=!0){if(t&&this.enableLatestOverlapping(e,!1),"number"==typeof e){const i=mn(e);for(let e of i)Fs(this,on,"f").set(e,t)}else Fs(this,on,"f").set(e,t)}isResultDeduplicationEnabled(e){return un(e,this.duplicateFilterEnabled)}setDuplicateForgetTime(e,t){if(t>18e4&&(t=18e4),t<0&&(t=0),"number"==typeof e){const i=mn(e);for(let e of i)Fs(this,rn,"f").set(e,t)}else Fs(this,rn,"f").set(e,t)}getDuplicateForgetTime(e){return un(e,this.duplicateForgetTime)}getFilteredResultItemTypes(){let e=0;const t=[ne.CRIT_BARCODE,ne.CRIT_TEXT_LINE,ne.CRIT_DETECTED_QUAD,ne.CRIT_DESKEWED_IMAGE,ne.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=mn(e);for(let e of s)Fs(this,ln,"f").set(e,{frameWindow:t,minConsistentFrames:i})}else Fs(this,ln,"f").set(e,{frameWindow:t,minConsistentFrames:i})}getResultCrossVerificationCriteria(e){return un(e,this.crossVerificationCriteria)}enableLatestOverlapping(e,t=!0){if(t&&this.enableResultDeduplication(e,!1),"number"==typeof e){const i=mn(e);for(let e of i)Fs(this,an,"f").set(e,t)}else Fs(this,an,"f").set(e,t)}isLatestOverlappingEnabled(e){return un(e,this.latestOverlappingEnabled)}setMaxOverlappingFrames(e,t){if("number"==typeof e){const i=mn(e);for(let e of i)Fs(this,cn,"f").set(e,t)}else Fs(this,cn,"f").set(e,t)}getMaxOverlappingFrames(e){return un(e,this.maxOverlappingFrames)}latestOverlappingFilter(e){var t,i,s;const n=this.isResultCrossVerificationEnabled(ne.CRIT_BARCODE),o=this.isLatestOverlappingEnabled(ne.CRIT_BARCODE);if(o){const r=this.crossVerificationFrames,a=60,c=o?this.getMaxOverlappingFrames(ne.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),p=0;const f=e.items.map(e=>{if(1!==e.type){const t=(BigInt(e.format)&BigInt(Us.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0);return new sn(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(!f[t])continue;const o=f[t].item;for(let r=0;r<this.overlapSet.length;r++){if(e[t][r]<1)continue;const a=this.overlapSet[r],c=a.item;if(o.format===c.format&&o.text===c.text){if(n=a.isProbablySameLocationWithOffset(f[t],i),n){s[t]=r,e[t][r]=0;break}}else e[t][r]=0}if(n)break}if(n){for(let n=0;n<l;n++){if(n===t||!f[n])continue;const o=f[n].item;for(let t=0;t<this.overlapSet.length;t++){if(e[n][t]<1)continue;if(s.includes(t))continue;const r=this.overlapSet[t],a=r.item;if(o.format===a.format&&o.text===a.text){if(r.isMatchedLocationWithOffset(f[n],i)){s[n]=t,e[n][t]=0;break}}else e[n][t]=0}}const n=s.filter(e=>-1!==e).length;n>p&&(p=n,g=s,m.x=i.x,m.y=i.y)}}if(0===p){for(let t=0;t<l;t++){const i=f[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],o=n.item;if(i.format===o.format&&i.text===o.text){if(n.isMatchedLocationWithOffset(f[t])){g[t]=s,e[t][s]=0;break}}else e[t][s]=0}}p+=g.filter(e=>-1!=e).length}let i=this.overlapSet.length<=3?p>=1:p>=2;if(!i&&o&&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(Us.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0),o=e.confidence<a,r=new sn(c,s?1:2,s,i);n&&s&&o&&_.push(t),this.overlapSet.push(r)}});else{let t=!0;o?(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&&f[i]){const e=f[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 o=this.overlapSet[n].item.text,r=this.overlapSet[n].item.format;if(e.format===r&&e.text===o){if(this.overlapSet[n].isOverlappedLocationWithOffset(e,m,!1)){const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(Us.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0),o=s?1:2;this.overlapSet[n]=new sn(c,o,s,t),g[i]=n;break}if(f[i].isOneD){let o={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++)o.points[e].x=t?this.overlapSet[n].location.points[e].x:this.overlapSet[n].location.points[e].x+m.x,o.points[e].y=t?this.overlapSet[n].location.points[e].y:this.overlapSet[n].location.points[e].y+m.y;let r={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};if(tn(s,o,e.moduleSize,r)){e.location=r;const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(Us.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0),o=s?1:2;this.overlapSet[n]=new sn(c,o,s,t),g[i]=n;break}}}}}else{if(t)f[i]&&(f[i].item.location=this.overlapSet[e].location);else{const t=Object.assign({},f[i].item),s=(BigInt(t.format)&BigInt(Us.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0),n=s?1:2;this.overlapSet[e]=new sn(c,n,s,t)}this.overlapSet[e]&&(this.overlapSet[e].overlapCount=c,this.overlapSet[e].verificationCount=2,this.overlapSet[e].crossVerificationFrame=r)}}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(o&&n>0){for(let e=0;e<l;e++)if(s.isOverlappedLocationWithOffset(f[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(o&&!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]||!f[e])continue;const i=f[e].item;if(t){for(let t=0;t<4;t++)f[e].location.points[t].x-=m.x,f[e].location.points[t].y-=m.y;i.location=f[e].location}let s=!1;for(let t of this.overlapSet)if(!(t.crossVerificationFrame<=0&&t.verificationCount<=0)&&(s=t.isLocationOverlap(f[e].location,f[e].locationArea),s))break;if(s){_.push(e);continue}const o=Object.assign({},i),r=(BigInt(i.format)&BigInt(Us.BF_ONED))!=BigInt(0)||(BigInt(i.format)&BigInt(Us.BF_GS1_DATABAR))!=BigInt(0),l=i.confidence<a,d=new sn(c,r?1:2,r,o);n&&r&&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 pn,fn,En,yn;nn=new WeakMap,on=new WeakMap,rn=new WeakMap,an=new WeakMap,cn=new WeakMap,ln=new WeakMap;class In{static async readFromFile(e){if("string"==typeof e){if(!O(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 k(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=P(e);return N(s,t,i)}static async readFromMemory(e){if(!Fs(pn,pn,"f",fn).has(e))throw new Error("Image data ID does not exist.");return Fs(pn,pn,"f",fn).get(e)}static async saveToMemory(e,t){var i,s,n;const o=await Hs(e,t),r=await k(o),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=pn,pn,(n=Fs(i,pn,"f",En),s=n++,n),0,En),s);return Fs(pn,pn,"f",fn).set(a,r),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 k(t)}static async saveToBase64String(e,t){e instanceof Blob&&(e=await k(e));let i=P(e);const s=await Hs(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)}}pn=In,fn={value:new Map},En={value:0};!function(e){e[e.LP_UNKNOWN=0]="LP_UNKNOWN",e[e.LP_LINES=1]="LP_LINES",e[e.LP_MATRIX=2]="LP_MATRIX"}(yn||(yn={}));const vn={pattern:yn.LP_UNKNOWN,axes:[{elementCount:-1,isStaggered:!1,angle:-1,isEqualSpacing:!1,spacing:-1,spacingUnit:ye.MU_PIXEL},{elementCount:-1,isStaggered:!1,angle:-1,isEqualSpacing:!1,spacing:-1,spacingUnit:ye.MU_PIXEL}],inputImageWidth:0,inputImageHeight:0};var Rn,Cn;!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"}(Rn||(Rn={})),function(e){e[e.LES_NONE=0]="LES_NONE",e[e.LES_INPUT=1]="LES_INPUT",e[e.LES_INFERRED=2]="LES_INFERRED"}(Cn||(Cn={}));var Tn,wn,Sn=Object.freeze({__proto__:null,get EnumFilterType(){return Rn},get EnumLayoutElementSource(){return Cn},get EnumLayoutPattern(){return yn},ImageDrawer:class{static async drawOnImage(e,t,i,s=4294901760,n=1,o="test.png",r){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 k(e);else if("string"==typeof e){let t=await b(e,"blob");a=await k(t)}else S(e)&&(a=e,"bigint"==typeof a.format&&(a.format=Number(a.format)));return await new Promise((e,c)=>{let l=Ce();Te[l]=async t=>{if(t.success)return r&&In.saveToFile(t.image,o,r),e(t.image);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,c(e)}},ve.postMessage({type:"utility_drawOnImage",id:l,body:{dsImage:a,drawingItem:Array.isArray(t)?t:[t],color:s,thickness:n,type:i}})})}},ImageIO:In,ImageProcessor:class{static async cropImage(e,t){const{bytes:i,width:s,height:n,stride:o,format:r}=S(e)?e:await k(e);return await new Promise((e,a)=>{let c=Ce();Te[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)}},ve.postMessage({type:"utility_cropImage",id:c,body:{type:"Rect",bytes:i,width:s,height:n,stride:o,format:r,roi:t}})})}static async adjustBrightness(e,t){const{bytes:i,width:s,height:n,stride:o,format:r}=S(e)?e:await k(e);return await new Promise((e,a)=>{let c=Ce();Te[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)}},ve.postMessage({type:"utility_adjustBrightness",id:c,body:{bytes:i,width:s,height:n,stride:o,format:r,brightness:t}})})}static async adjustContrast(e,t){const{bytes:i,width:s,height:n,stride:o,format:r}=S(e)?e:await k(e);return await new Promise((e,a)=>{let c=Ce();Te[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)}},ve.postMessage({type:"utility_adjustContrast",id:c,body:{bytes:i,width:s,height:n,stride:o,format:r,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:o,format:r}=S(e)?e:await k(e);return await new Promise((e,a)=>{let c=Ce();Te[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)}},ve.postMessage({type:"utility_filterImage",id:c,body:{bytes:i,width:s,height:n,stride:o,format:r,filterType:t}})})}static async convertToGray(e,t,i,s){const{bytes:n,width:o,height:r,stride:a,format:c}=S(e)?e:await k(e);return await new Promise((e,l)=>{let d=Ce();Te[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)}},ve.postMessage({type:"utility_convertToGray",id:d,body:{bytes:n,width:o,height:r,stride:a,format:c,R:t,G:i,B:s}})})}static async convertToBinaryGlobal(e,t=-1,i=!1){const{bytes:s,width:n,height:o,stride:r,format:a}=S(e)?e:await k(e);return await new Promise((e,c)=>{let l=Ce();Te[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)}},ve.postMessage({type:"utility_convertToBinaryGlobal",id:l,body:{bytes:s,width:n,height:o,stride:r,format:a,threshold:t,invert:i}})})}static async convertToBinaryLocal(e,t=0,i=10,s=!1){const{bytes:n,width:o,height:r,stride:a,format:c}=S(e)?e:await k(e);return await new Promise((e,l)=>{let d=Ce();Te[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)}},ve.postMessage({type:"utility_convertToBinaryLocal",id:d,body:{bytes:n,width:o,height:r,stride:a,format:c,blockSize:t,compensation:i,invert:s}})})}static async cropAndDeskewImage(e,t,i=0,s=0,n=0){const{bytes:o,width:r,height:a,stride:c,format:l}=S(e)?e:await k(e);return await new Promise((e,d)=>{let u=Ce();Te[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)}},ve.postMessage({type:"utility_cropAndDeskewImage",id:u,body:{bytes:o,width:r,height:a,stride:c,format:l,roi:t,dstWidth:i,dstHeight:s,padding:n}})})}},LayoutAnalyzer:class{static async analyze(e,t){return Object.assign(vn,t),await new Promise(async(t,i)=>{let s=Ce();Te[s]=e=>{if(!e.success){let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}t(e.analyzeResult)},ve.postMessage({type:"utility_analyze",id:s,body:{inputQuads:e,parameter:vn}})})}},MultiFrameResultCrossFilter:gn,UtilityModule:class{static getVersion(){return`2.6.30-dev-20260824140349(Worker: ${Ae.utility&&Ae.utility.worker||"Not Loaded"}, Wasm: ${Ae.utility&&Ae.utility.wasm||"Not Loaded"})`}}}),An=new WeakMap,Dn=new WeakMap,bn=new WeakMap,On=new WeakMap,Ln=new WeakMap,Nn=new WeakMap,Mn=new WeakMap,Bn=new WeakMap,Fn=new WeakMap,xn=new WeakMap,Pn=new WeakSet;class kn{constructor(t){if(r(this,Pn),a(this,"_cameraEnhancer",void 0),a(this,"_cameraView",void 0),a(this,"_cvRouter",void 0),n(this,An,!1),n(this,Dn,void 0),n(this,bn,void 0),n(this,On,void 0),n(this,Ln,void 0),n(this,Nn,new Map),n(this,Mn,[]),n(this,Bn,void 0),n(this,Fn,new Pe),n(this,xn,{status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},barcodeResults:[]}),a(this,"config",fs(Be)),t&&"object"!=typeof t||Array.isArray(t))throw new Error("Invalid config.");o(Bn,this,t),gs(this.config,t)}get disposed(){return s(An,this)}async launch(){if(s(An,this))throw new Error("The BarcodeScanner instance has been destroyed.");if(t(kn,wn,lo)._&&!t(kn,wn,lo)._.isFulfilled&&!t(kn,wn,lo)._.isRejected)throw new Error("Cannot call `launch()` while a previous task is still running.");if(lo._=t(kn,wn,new Pe),!us.getDeviceFriendlyName())try{us.setDeviceFriendlyName("dbr_rtu")}catch{}return t(Pn,this,Un).call(this),t(kn,wn,lo)._}async decode(e,i){if(this.disposed)return Promise.reject(new Error("Cannot call decode on a disposed instance. This instance was disposed after launch completed."));const n=new Ft;try{await t(Pn,this,Vn).call(this,!0),s(Ln,this)||o(Ln,this,new gn),s(Ln,this).enableResultCrossVerification(2,!1),await this._cvRouter.addResultFilter(s(Ln,this)),n.onCapturedResultReceived=()=>{},this._cvRouter.addResultReceiver(n),i||(i=this.config.utilizedTemplateNames.image);return await this._cvRouter.capture(e,i)}catch(e){throw e}finally{var r;s(Ln,this)&&(s(Ln,this).enableResultCrossVerification(2,!0),await this._cvRouter.addResultFilter(s(Ln,this))),null===(r=this._cvRouter)||void 0===r||r.removeResultReceiver(n)}}dispose(){var e,i,n,r,a,c,l;o(An,this,!0),t(kn,wn,lo)._&&t(kn,wn,lo)._.isPending&&t(kn,wn,lo)._.resolve(s(xn,this)),null===(e=this._cameraEnhancer)||void 0===e||e.dispose(),null===(i=this._cameraView)||void 0===i||i.dispose(),null===(n=this._cvRouter)||void 0===n||n.dispose(),this._cameraEnhancer=null,this._cameraView=null,this._cvRouter=null,null===(r=document.querySelector(".scanner-view-container"))||void 0===r||r.remove(),null===(a=document.querySelector(".result-view-container"))||void 0===a||a.remove(),null===(c=document.querySelector(".barcode-scanner-container"))||void 0===c||c.remove(),null===(l=document.querySelector(".loading-page"))||void 0===l||l.remove();for(let[e,t]of s(Nn,this))for(let i of t)window.removeEventListener(e,i);s(Nn,this).clear();for(let e of s(Mn,this))document.head.removeChild(e);o(Mn,this,[])}}async function Un(){try{if(this.config.onInitPrepare&&this.config.onInitPrepare(),this.disposed)return;if(await t(Pn,this,Vn).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...",await this._cameraEnhancer.open(),ps(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(i){t(Pn,this,no).call(this,{auto:!1,open:!1,close:!1,notSupport:!1});const s=document.querySelector(".camera-control");s&&(s.style.display="none");const n=document.querySelector(".no-camera-view");if(n&&(n.style.display="flex"),this.config.onCameraOpenFailed&&this.config.onCameraOpenFailed(i),e=!0,this.disposed)return}if(this.config.autoStartCapturing&&!e&&(await this._cvRouter.startCapturing(s(bn,this)),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed))return}catch(i){s(xn,this).status={code:e.EnumResultStatus.RS_FAILED,message:i.message||i},t(Tn,wn,lo)._.reject(new Error(s(xn,this).status.message)),this.dispose()}finally{t(Pn,this,oo).call(this,"Loading...",!1)}}async function Vn(i=!1){Ne.engineResourcePaths=this.config.engineResourcePaths;const n=L(Ne.engineResourcePaths);if(!i){let i=t(Tn,wn,uo)._.get("dceUI");if(i||(i=await b(n.dbrBundle+"ui/dce.rtu.ui.xml","text"),t(Tn,wn,uo)._.set("dceUI",i)),this.disposed)return;if(this._cameraView=await _i.createInstance(i),this.disposed)return;if(this.config.scanMode===e.EnumScanMode.SM_SINGLE||this.config.scannerViewConfig.customHighlightForBarcode){this._cameraView.getDrawingLayer(2).setVisible(!1)}if(this._cameraEnhancer=await hi.createInstance(this._cameraView),this.disposed)return;if(await t(Pn,this,Wn).call(this),this.disposed)return;this.config.scannerViewConfig.customHighlightForBarcode&&o(On,this,this._cameraEnhancer.getCameraView().createDrawingLayer())}if([null,void 0].includes(this.config.license)||(us._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)"),await us.initLicense(this.config.license,{executeNow:!0})),this.disposed)return;if(this._cvRouter=this._cvRouter||await St.createInstance(!1),this._cvRouter._s=!0,this.disposed)return;let r=t(Tn,wn,uo)._.get("presetTemplates");if(r||(r=await b(n.dbrBundle+"templates/DBR-PresetTemplates.json","text"),t(Tn,wn,uo)._.set("presetTemplates",r)),!s(Fn,this).isPending||(await this._cvRouter.initSettings(r),await t(Pn,this,Gn).call(this,i),!this.disposed)){if(!i){if(this._cvRouter.setInput(this._cameraEnhancer),t(Pn,this,Kn).call(this),await t(Pn,this,Xn).call(this),this.disposed)return;this._cvRouter.onCaptureError=e=>{t(Tn,wn,lo)._.reject(new Error(e.message)),this.dispose()},this._cvRouter._dynamsoft=!(this.config.scanMode===e.EnumScanMode.SM_SINGLE)}s(Fn,this).resolve()}}async function Gn(i=!1){let n=this.config.templateFilePath;if(n){let e,i=!1;if(Vt(n)&&(i=n.reloadResource,n=n.path),i)e=await b(n,"text"),t(Tn,wn,uo)._.delete("templateFile");else{e=t(Tn,wn,uo)._.get("templateFile"),e||(e=await b(n,"text"),t(Tn,wn,uo)._.set("templateFile",e)),e=JSON.parse(e);const i=e.CaptureVisionTemplates[0].Name;s(Bn,this).utilizedTemplateNames?(s(Bn,this).utilizedTemplateNames.image||(this.config.utilizedTemplateNames.image=i),s(Bn,this).utilizedTemplateNames.multi_unique||(this.config.utilizedTemplateNames.multi_unique=i),s(Bn,this).utilizedTemplateNames.single||(this.config.utilizedTemplateNames.single=i)):this.config.utilizedTemplateNames={image:i,multi_unique:i,single:i}}if(this.disposed)return;if(await this._cvRouter.initSettings(e),this.disposed)return}const r=await this._cvRouter.outputSettings("*",!0);if(this.disposed)return;if(!i&&this.config.scanMode===e.EnumScanMode.SM_SINGLE)for(let e of r.CaptureVisionTemplates)e.OutputOriginalImage=1;let a=this.config.barcodeFormats;if(a){Array.isArray(a)||(a=[a]);const e=(e,t)=>t!==BigInt(0)&&(e&t)===t;for(let t of r.BarcodeReaderTaskSettingOptions){t.BarcodeFormatIds=[];for(let i in Rs)for(let s in a)e(a[s],Rs[i])&&t.BarcodeFormatIds.push(i)}}await this._cvRouter.initSettings(r),this.disposed||i||(this.config.scanMode===e.EnumScanMode.SM_SINGLE?o(bn,this,this.config.utilizedTemplateNames.single):this.config.scanMode===e.EnumScanMode.SM_MULTI_UNIQUE&&o(bn,this,this.config.utilizedTemplateNames.multi_unique))}async function Wn(){let i,n,r=this.config.uiPath||L(this.config.engineResourcePaths).dbrBundle,a=!1;Vt(r)&&(a=r.reloadResource,r=r.path);let c=r.endsWith("/")?Ls(r)+"ui/barcode-scanner.ui.xml":Ls(r).slice(0,-1);if(a?(i=await b(c,"text"),t(Tn,wn,uo)._.delete("dbsUI")):(i=t(Tn,wn,uo)._.get("dbsUI"),i||(i=await b(c,"text"),t(Tn,wn,uo)._.set("dbsUI",i))),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})(i),this.disposed)return;if(n.querySelectorAll("style").forEach(e=>{const t=e.cloneNode(!0);s(Mn,this).push(t),document.head.appendChild(t)}),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)}o(Dn,this,n.querySelector(".result-item")),t(Pn,this,jn).call(this,n),t(Pn,this,Zn).call(this,n),t(Pn,this,Hn).call(this,n),t(Pn,this,qn).call(this,n),await t(Pn,this,Yn).call(this,n),t(Pn,this,so).call(this,n),t(Pn,this,$n).call(this,n),t(Pn,this,zn).call(this,n)}function jn(e){const i=e.querySelector(".btn-clear");var n;if(i&&(i.addEventListener("click",()=>{s(xn,this).barcodeResults=[],t(Pn,this,to).call(this)}),null!==(n=this.config)&&void 0!==n&&null!==(n=n.resultViewConfig)&&void 0!==n&&null!==(n=n.toolbarButtonsConfig)&&void 0!==n&&n.clear)){const t=this.config.resultViewConfig.toolbarButtonsConfig.clear;i.style.display=t.isHidden?"none":"flex",i.className=t.className,i.innerText=t.label,t.isHidden&&(e.querySelector(".toolbar-btns").style.justifyContent="center")}}function Zn(e){const t=e.querySelector(".btn-done");var i;if(t&&(t.addEventListener("click",()=>{const e=document.querySelector(".loading-page");e&&"none"===getComputedStyle(e).display&&this.dispose()}),null!==(i=this.config)&&void 0!==i&&null!==(i=i.resultViewConfig)&&void 0!==i&&null!==(i=i.toolbarButtonsConfig)&&void 0!==i&&i.done)){const i=this.config.resultViewConfig.toolbarButtonsConfig.done;t.style.display=i.isHidden?"none":"flex",t.className=i.className,t.innerText=i.label,i.isHidden&&(e.querySelector(".toolbar-btns").style.justifyContent="center")}}function Hn(t){var i;if(null===(i=this.config)||void 0===i||null===(i=i.scannerViewConfig)||void 0===i?void 0:i.showCloseButton){const i=t.querySelector(".btn-close");i&&(i.style.display="inline",i.addEventListener("click",()=>{s(xn,this).barcodeResults=[],s(xn,this).status={code:e.EnumResultStatus.RS_CANCELLED,message:"Cancelled."},this.dispose()}))}}function qn(e){var i;if(null===(i=this.config)||void 0===i?void 0:i.scannerViewConfig.showFlashButton){const i=e.querySelector(".btn-flash-auto"),s=e.querySelector(".btn-flash-open"),n=e.querySelector(".btn-flash-close");i&&(i.style.display="inline",this._cameraEnhancer.addEventListener("opened",async()=>{if(!this._cameraEnhancer.currentCamera)return void t(Pn,this,no).call(this,{auto:!1,open:!1,close:!1,notSupport:!1});const e=this._cameraEnhancer.isSupportTorch;for(this.config.scannerViewConfig.showFlashButton&&(e?t(Pn,this,no).call(this,{auto:!0,open:!1,close:!1,notSupport:!1}):t(Pn,this,no).call(this,{auto:!1,open:!1,close:!1,notSupport:!0})),await new Promise(e=>setTimeout(e,1e3));null!==(i=this._cameraEnhancer)&&void 0!==i&&i._isOpenBeforeHide;){var i;await new Promise(e=>setTimeout(e,1e3))}this.disposed||this._cameraEnhancer.isOpen()&&e&&this._cameraEnhancer.turnAutoTorch()}),i.addEventListener("click",async()=>{await this._cameraEnhancer.turnOnTorch(),i.style.display="none",s.style.display="inline",n.style.display="none"}),s.addEventListener("click",async()=>{await this._cameraEnhancer.turnOffTorch(),i.style.display="none",s.style.display="none",n.style.display="inline"}),n.addEventListener("click",async()=>{this._cameraEnhancer.turnAutoTorch(),i.style.display="inline",s.style.display="none",n.style.display="none"}))}}async function Yn(e){let i=this.config.scannerViewConfig.cameraSwitchControl;["toggleFrontBack","listAll","hidden"].includes(i)||(this.config.scannerViewConfig.cameraSwitchControl="hidden");if("hidden"!==this.config.scannerViewConfig.cameraSwitchControl){const i=e.querySelector(".camera-control");if(i){i.style.display="block";const n=await this._cameraEnhancer.getAllCameras(),o=this.config.scannerViewConfig.cameraSwitchControl,r=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"===o){const i=e.querySelector(".camera-list");for(let e of n){const t=r(e);i.append(t)}const o=()=>{const e=document.querySelector(".camera-list");e&&(e.style.display="none")},a=s(Nn,this).get("click")||[];s(Nn,this).set("click",[...a,o]),window.addEventListener("click",o);const c=e=>{for(let t of l)t.deviceId===e.deviceId?t.style.color="#FE8E14":t.style.color="#FFFFFF"};i.addEventListener("click",async e=>{e.stopPropagation();const n=e.target;t(Pn,this,oo).call(this,"Accessing Camera...",!0),this._cvRouter.stopCapturing(),await this._cameraEnhancer.selectCamera({deviceId:n.deviceId,label:n.label});const o=this._cameraEnhancer.getSelectedCamera();ps(o)&&this.config.scannerViewConfig.mirrorFrontCamera?this._cameraEnhancer.isMirrored=!0:this._cameraEnhancer.isMirrored=!1,c(o),this.config.onCameraOpen&&this.config.onCameraOpen({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.config.autoStartCapturing&&(await this._cvRouter.startCapturing(s(bn,this)),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter})),t(Pn,this,oo).call(this,"Loading...",!1),i.style.display="none"});const l=e.querySelectorAll(".camera-list div");return async()=>{const e=this._cameraEnhancer.getSelectedCamera();c(e);const t=document.querySelector(".camera-list");"none"===getComputedStyle(t).display?t.style.display="block":t.style.display="none"}}return"toggleFrontBack"===o?async()=>{t(Pn,this,oo).call(this,"Accessing Camera...",!0);const e=ps(this._cameraEnhancer.getSelectedCamera());console.log(e),await this._cameraEnhancer.requestCamera(e?"back":"front");ps(this._cameraEnhancer.getSelectedCamera())?(this.config.scannerViewConfig.mirrorFrontCamera&&(this._cameraEnhancer.isMirrored=!0),this.config.scannerViewConfig.showFlashButton&&t(Pn,this,no).call(this,{auto:!1,open:!1,close:!1,notSupport:!0})):(this._cameraEnhancer.isMirrored=!1,this.config.scannerViewConfig.showFlashButton&&t(Pn,this,no).call(this,{auto:!0,open:!1,close:!1,notSupport:!1})),t(Pn,this,oo).call(this,"Loading...",!1)}:void 0},c=a();i.addEventListener("click",async e=>{e.stopPropagation(),c&&await c()})}}}function zn(t){const i=this._cameraView.getUIElement();this._cameraView.setVideoFit("cover");const n=t.querySelector(".barcode-scanner-container");n.style.display=_s()?"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 r;if(this.config.container?(n.style.position="relative",r=this.config.container):r=document.body,"string"==typeof r&&(r=document.querySelector(r),null===r))throw new Error("Failed to get the container");let a=this.config.scannerViewConfig.container;if("string"==typeof a&&(a=document.querySelector(a),null===a))throw new Error("Failed to get the container of the scanner view.");let c=this.config.resultViewConfig.container;if("string"==typeof c&&(c=document.querySelector(c),null===c))throw new Error("Failed to get the container of the result view.");const l=t.querySelector(".scanner-view-container"),d=t.querySelector(".result-view-container"),u=t.querySelector(".loading-page");l.append(u),a&&(l.append(i),a.append(l)),c&&c.append(d),a||c?a&&!c?(this.config.container||(d.style.position="absolute"),c=d,r.append(d)):!a&&c&&(this.config.container||(l.style.position="absolute"),a=l,l.append(i),r.append(l)):(a=l,c=d,o&&(Object.assign(l.style,{width:_s()?"50%":"100%",height:_s()?"100%":"50%"}),Object.assign(d.style,{width:_s()?"50%":"100%",height:_s()?"100%":"50%"})),l.append(i),r.append(n)),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");const h=()=>{Object.assign(n.style,{display:_s()?"flex":"block"}),!o||this.config.scannerViewConfig.container||this.config.resultViewConfig.container||(Object.assign(a.style,{width:_s()?"50%":"100%",height:_s()?"100%":"50%"}),Object.assign(c.style,{width:_s()?"50%":"100%",height:_s()?"100%":"50%"}))},_=s(Nn,this).get("resize")||[];s(Nn,this).set("resize",[..._,h]),window.addEventListener("resize",h)}function $n(e){var t;null===(t=e.querySelector(".resume"))||void 0===t||t.addEventListener("click",async()=>{var e,t,i;null!==(e=this.config)&&void 0!==e&&null!==(e=e.scannerViewConfig)&&void 0!==e&&e.showCloseButton&&(document.querySelector(".btn-close").style.display="block"),document.querySelector(".features-group").style.display="flex",document.querySelector(".resume").style.display="none",null===(t=this._cameraView.getUIElement().shadowRoot.querySelector(".single-mode-mask"))||void 0===t||t.remove(),null===(i=this._cameraView.getUIElement().shadowRoot.querySelectorAll(".single-barcode-result-option"))||void 0===i||i.forEach(e=>null==e?void 0:e.remove()),await this._cameraEnhancer.resume(),await new Promise(e=>{setTimeout(e,100)}),this._cvRouter.startCapturing(s(bn,this))})}function Kn(){const i=new Ft;i.onCapturedResultReceived=async i=>{if(s(On,this)&&s(On,this).clearDrawingItems(),i.decodedBarcodesResult){if(this.config.scannerViewConfig.customHighlightForBarcode){let e=[];for(let t of i.decodedBarcodesResult.barcodeResultItems)e.push(this.config.scannerViewConfig.customHighlightForBarcode(t));s(On,this).addDrawingItems(e)}this.config.scanMode===e.EnumScanMode.SM_SINGLE?t(Pn,this,Qn).call(this,i):t(Pn,this,Jn).call(this,i)}},this._cvRouter.addResultReceiver(i)}async function Xn(){s(Ln,this)||o(Ln,this,new gn),s(Ln,this).enableResultCrossVerification(2,!0),s(Ln,this).enableResultDeduplication(2,!0),s(Ln,this).setDuplicateForgetTime(2,this.config.duplicateForgetTime),await this._cvRouter.addResultFilter(s(Ln,this)),s(Ln,this).isResultCrossVerificationEnabled=()=>!1,s(Ln,this).isResultDeduplicationEnabled=()=>!1}function Qn(i){const s=this._cameraView.getUIElement().shadowRoot;let n=new Promise(e=>{if(i.decodedBarcodesResult.barcodeResultItems.length>1){t(Pn,this,eo).call(this);let n=[];for(let t of i.decodedBarcodesResult.barcodeResultItems){let i=0,s=0;for(let e=0;e<4;++e){let n=t.location.points[e];i+=n.x,s+=n.y}let o=this._cameraEnhancer.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0}),r=this._cameraEnhancer.videoXY2FixedLT([{x:o.x+i/4,y:o.y+s/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=r[0].left+"px",a.style.top=r[0].top+"px",a.addEventListener("click",()=>{e(t)}),n.push(a)}s.append(...n)}else e(i.decodedBarcodesResult.barcodeResultItems[0])});n.then(async s=>{const n=i.items.filter(e=>e.type===ne.CRIT_ORIGINAL_IMAGE)[0],o=n.imageData,r={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},originalImageResult:o,barcodeImage:(()=>{const e=M(o),t=s.location.points,i=Math.min(...t.map(e=>e.x)),n=Math.min(...t.map(e=>e.y)),r=Math.max(...t.map(e=>e.x)),a=Math.max(...t.map(e=>e.y)),c=r-i,l=a-n,d=document.createElement("canvas");d.width=c,d.height=l;const u=d.getContext("2d");if(!u)return console.warn("Failed to create canvas context."),null;u.beginPath(),u.moveTo(t[0].x-i,t[0].y-n);for(let e=1;e<t.length;e++)u.lineTo(t[e].x-i,t[e].y-n);u.closePath(),u.clip(),u.drawImage(e,-i,-n);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:p.IPF_ABGR_8888}})(),barcodeResults:[s]};t(Pn,this,ro).call(this,s),t(Tn,wn,lo)._.resolve(r),this.dispose()})}function Jn(e){for(let i of e.decodedBarcodesResult.barcodeResultItems){if(!1!==i.duplicate)continue;const e=s(xn,this).barcodeResults.findIndex(e=>`${e.formatString}_${e.text}`==`${i.formatString}_${i.text}`);-1===e?(i.count=1,s(xn,this).barcodeResults.unshift(i),t(Pn,this,to).call(this,i)):(s(xn,this).barcodeResults[e].count++,t(Pn,this,io).call(this,e)),this.config.onUniqueBarcodeScanned&&this.config.onUniqueBarcodeScanned(i)}}function eo(){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()}function to(t){if(!this.config.showResultView)return;const i=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&&(i.style.display="inline"));i.style.display="none";const o=(e=>{const t=s(Dn,this).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")],i=t.findIndex(t=>t.id===`${e.formatString}_${e.text}`);s(xn,this).barcodeResults.splice(i,1),t[i].remove(),0===s(xn,this).barcodeResults.length&&this.config.showPoweredByDynamsoft&&(document.querySelector(".no-result-svg").style.display="inline")}),t})(t);n.insertBefore(o,document.querySelector(".result-item"))}function io(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}function so(i){if(this.config.showUploadImageButton){const n=i.querySelector(".btn-upload-image");n.style.display="flex",n.addEventListener("change",async i=>{const n=i.target.files;if(!n)return;const o={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success."},barcodeResults:[]};let r=0;t(Pn,this,oo).call(this,`Capturing... [${r}/${n.length}]`,!0);let a=!1;for(let e=0;e<n.length;e++)if(!Es(n[e])){a=!0;break}if(a)return t(Tn,wn,lo)._.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 i of n)try{this._cvRouter.stopCapturing();const a=await this.decode(i,this.config.utilizedTemplateNames.image);if(a.decodedBarcodesResult)if(this.config.scanMode===e.EnumScanMode.SM_MULTI_UNIQUE)for(let e of a.decodedBarcodesResult.barcodeResultItems){const i=s(xn,this).barcodeResults.findIndex(t=>`${t.formatString}_${t.text}`==`${e.formatString}_${e.text}`);-1===i?(e.count=1,s(xn,this).barcodeResults.unshift(e),t(Pn,this,to).call(this,e)):(s(xn,this).barcodeResults[i].count++,t(Pn,this,io).call(this,i)),this.config.onUniqueBarcodeScanned&&this.config.onUniqueBarcodeScanned(e)}else if(a.decodedBarcodesResult.barcodeResultItems)for(let e of a.decodedBarcodesResult.barcodeResultItems){const t=o.barcodeResults.find(t=>`${t.text}_${t.formatString}`==`${e.text}_${e.formatString}`);t?t.count++:(e.count=1,o.barcodeResults.push(e))}t(Pn,this,oo).call(this,`Capturing... [${++r}/${n.length}]`,!0)}catch(i){return o.status={code:e.EnumResultStatus.RS_FAILED,message:i.message||i},t(Tn,wn,lo)._.reject(new Error(o.status.message)),void this.dispose()}t(Pn,this,oo).call(this,"Loading...",!1),this.config.scanMode===e.EnumScanMode.SM_SINGLE?(t(Tn,wn,lo)._.resolve(o),this.dispose()):this._cvRouter.startCapturing(s(bn,this)),i.target.value=""})}}function no(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"}function oo(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")}function ro(e){let t=Ce();Te[t]=()=>{},ve.postMessage({type:"cvr_cc",id:t,instanceID:this._cvRouter._instanceID,body:{text:e.text,strFormat:e.format.toString(),isDPM:e.isDPM}})}Tn=kn;var ao,co,lo={_:null},uo={_:new Map};function ho(e){delete e.moduleId;const t=JSON.parse(e.jsonString).ResultInfo,i=e.fullCodeString,s=e.fieldNames;e.getFieldValue=e=>"fullcodestring"===e.toLowerCase()?i:_o(t,e,"map"),e.getFieldRawValue=e=>"fullcodestring"===e.toLowerCase()?i:_o(t,e,"raw"),e.getFieldMappingStatus=e=>{var i;return null!==(i=mo(t,e))&&void 0!==i?i:ao.MS_NONE},e.getFieldValidationStatus=e=>{var i;return null!==(i=go(t,e))&&void 0!==i?i:co.VS_NONE},e.getAllFieldNames=()=>s,delete e.fieldNames,delete e.fullCodeString}function _o(e,t,i){var s;for(const n of e){if(n.FieldName===t)return"raw"===i&&n.RawValue?n.RawValue:n.Value;if(null===(s=n.ChildFields)||void 0===s?void 0:s.length)for(const e of n.ChildFields){const s=_o(e,t,i);if(void 0!==s)return s}}}function mo(e,t){var i;for(const s of e){if(s.FieldName===t)return s.MappingStatus?Number(ao[s.MappingStatus]):ao.MS_NONE;if(null===(i=s.ChildFields)||void 0===i?void 0:i.length)for(const e of s.ChildFields){const i=mo(e,t);if(void 0!==i)return i}}}function go(e,t){var i;for(const s of e){if(s.FieldName===t)return s.ValidationStatus?co[s.ValidationStatus]:co.VS_NONE;if(null===(i=s.ChildFields)||void 0===i?void 0:i.length)for(const e of s.ChildFields){const i=go(e,t);if(void 0!==i)return i}}}function po(e){if(e.disposed)throw new Error('"CodeParser" instance has been disposed')}wn=kn,function(e){e[e.MS_NONE=0]="MS_NONE",e[e.MS_SUCCEEDED=1]="MS_SUCCEEDED",e[e.MS_FAILED=2]="MS_FAILED"}(ao||(ao={})),function(e){e[e.VS_NONE=0]="VS_NONE",e[e.VS_SUCCEEDED=1]="VS_SUCCEEDED",e[e.VS_FAILED=2]="VS_FAILED"}(co||(co={}));const fo=e=>e&&"object"==typeof e&&"function"==typeof e.then,Eo=(async()=>{})().constructor;class yo extends Eo{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,fo(e)?t=e:"function"==typeof e&&(t=new Eo(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&&(fo(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}class Io{constructor(){this._instanceID=void 0,this.bDestroyed=!1}static async createInstance(){await De.license.dynamsoft(),await Ne.loadWasm();const e=new Io,t=new yo;let i=Ce();return Te[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)}},ve.postMessage({type:"dcp_createInstance",id:i}),t}async dispose(){po(this);let e=Ce();this.bDestroyed=!0,Te[e]=e=>{if(!e.success){let t=new Error(e.message);throw t.stack=e.stack+"\n"+t.stack,t}},ve.postMessage({type:"dcp_dispose",id:e,instanceID:this._instanceID})}get disposed(){return this.bDestroyed}async initSettings(e){if(po(this),e&&["string","object"].includes(typeof e))return"string"==typeof e?e.trimStart().startsWith("{")||(e=await b(e,"text")):"object"==typeof e&&(e=JSON.stringify(e)),await new Promise((t,i)=>{let s=Ce();Te[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)}},ve.postMessage({type:"dcp_initSettings",id:s,instanceID:this._instanceID,body:{settings:e}})});console.error("Invalid settings.")}async resetSettings(){return po(this),await new Promise((e,t)=>{let i=Ce();Te[i]=async i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},ve.postMessage({type:"dcp_resetSettings",id:i,instanceID:this._instanceID})})}async parse(e,t=""){if(po(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=Ce();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))),Te[n]=async e=>{if(e.success){let t=JSON.parse(e.parseResponse);return t.errorCode?s(new Error(t.errorString)):(ho(t),i(t))}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,s(t)}},ve.postMessage({type:"dcp_parse",id:n,instanceID:this._instanceID,body:{source:e,taskSettingName:t}})})}}const vo="undefined"==typeof self,Ro="function"==typeof importScripts,Co=(()=>{if(!Ro){if(!vo&&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"./"}})();Ne.engineResourcePaths.dcp={version:"3.6.30-dev-20260824140430",path:Co,isInternal:!0},De.dcp={handleParsedResultItem:ho},Te[-4]=async e=>{To.onSpecLoadProgressChanged&&To.onSpecLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class To{static getVersion(){const e=Ae.dcp&&Ae.dcp.wasm;return`3.6.30-dev-20260824140430(Worker: ${Ae.dcp&&Ae.dcp.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}static async loadSpec(e,t){return await Ne.loadWasm(),await new Promise((i,s)=>{let n,o=Ce();if(Te[o]=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)n=new URL(t,location.href).href,n=n.endsWith("/")?n:n+"/";else{const e=L(Ne.engineResourcePaths);n=`${"DBR"===Ne._bundleEnv?e.dbrBundle:e.dcvData}parser-resources/`}let r=(e instanceof Array?e:[e]).map(e=>e.replace(/^MRTD.*$/,"MRTD"));r=r.map(e=>e.replace(/\.data$/i,"")),ve.postMessage({type:"dcp_appendResourceBuffer",id:o,body:{specificationPath:n,specificationNames:r}})})}}var wo;!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"}(wo||(wo={}));var So=Object.freeze({__proto__:null,CodeParser:Io,CodeParserModule:To,get EnumCodeType(){return wo},get EnumMappingStatus(){return ao},get EnumValidationStatus(){return co}});var Ao=Object.freeze({__proto__:null,ImageProcessingModule:class{static getVersion(){return`3.6.30-dev-20260824140451(Worker: ${Ae.dip&&Ae.dip.worker||"Not Loaded"}, Wasm: ${Ae.dip&&Ae.dip.wasm||"Not Loaded"})`}}});Ne._bundleEnv="DBR",St._defaultTemplate="ReadSingleBarcode",Ne.engineResourcePaths.dbrBundle={version:"11.6.3000",path:Os,isInternal:!0},hi.CoreModule=Ne,hi.handleEngineResourcePaths=L,us._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)"),e.BarcodeScanner=kn,e.CVR=Ut,e.Core=Me,e.DBR=As,e.DCE=ji,e.DCP=So,e.DIP=Ao,e.License=hs,e.Utility=Sn,e.isPathConfig=Vt});
|