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.mjs
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(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 t(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function i(t,i){return t.get(e(t,i))}function s(e,i,s){t(e,i),i.set(e,s)}function n(t,i,s){return t.set(e(t,i),s),s}function o(e,i){t(e,i),i.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}function r(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function c(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?r(Object(i),!0).forEach(function(t){a(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var l,d;!function(e){e[e.SM_SINGLE=0]="SM_SINGLE",e[e.SM_MULTI_UNIQUE=1]="SM_MULTI_UNIQUE"}(l||(l={})),function(e){e[e.RS_SUCCESS=0]="RS_SUCCESS",e[e.RS_CANCELLED=1]="RS_CANCELLED",e[e.RS_FAILED=2]="RS_FAILED"}(d||(d={}));const u=e=>e&&"object"==typeof e&&"function"==typeof e.then,h=(async()=>{})().constructor;function _(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 m(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 g,p,f;"function"==typeof SuppressedError&&SuppressedError,function(e){e[e.BOPM_BLOCK=0]="BOPM_BLOCK",e[e.BOPM_UPDATE=1]="BOPM_UPDATE"}(g||(g={})),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"}(p||(p={})),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"}(f||(f={}));const E="undefined"==typeof self,y="function"==typeof importScripts,I=(()=>{if(!y){if(!E&&document.currentScript){let e=document.currentScript.src,t=e.indexOf("?");if(-1!=t)e=e.substring(0,t);else{let t=e.indexOf("#");-1!=t&&(e=e.substring(0,t))}return e.substring(0,e.lastIndexOf("/")+1)}return"./"}})(),v=e=>{if(null==e&&(e="./"),E||y);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},R=e=>Object.prototype.toString.call(e),C=e=>Array.isArray?Array.isArray(e):"[object Array]"===R(e),T=e=>"number"==typeof e&&!Number.isNaN(e),w=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),S=e=>!(!w(e)||!T(e.x)||!T(e.y)||!T(e.radius)||e.radius<0||!T(e.startAngle)||!T(e.endAngle)),A=e=>!!w(e)&&!!C(e.points)&&0!=e.points.length&&!e.points.some(e=>!F(e)),D=e=>!(!w(e)||!T(e.width)||e.width<=0||!T(e.height)||e.height<=0||!T(e.stride)||e.stride<=0||!("format"in e)||"tag"in e&&!M(e.tag)),b=(e,t)=>"bytes"===e&&"object"==typeof t&&"number"==typeof t.ptr&&"number"==typeof t.length,O=e=>!(!D(e)||!T(e.bytes.length)&&!T(e.bytes.ptr)),L=e=>!!D(e)&&e.bytes instanceof Uint8Array,N=e=>!(!w(e)||!T(e.left)||e.left<0||!T(e.top)||e.top<0||!T(e.right)||e.right<0||!T(e.bottom)||e.bottom<0||e.left>=e.right||e.top>=e.bottom),M=e=>null===e||!!w(e)&&!!T(e.imageId)&&"type"in e,B=e=>!(!w(e)||!F(e.startPoint)||!F(e.endPoint)||e.startPoint.x==e.endPoint.x&&e.startPoint.y==e.endPoint.y),F=e=>!!w(e)&&!!T(e.x)&&!!T(e.y),x=e=>!!w(e)&&!!C(e.points)&&0!=e.points.length&&!e.points.some(e=>!F(e)),P=e=>!!w(e)&&!!C(e.points)&&0!=e.points.length&&4==e.points.length&&!e.points.some(e=>!F(e)),k=e=>!(!w(e)||!T(e.x)||!T(e.y)||!T(e.width)||e.width<0||!T(e.height)||e.height<0),U=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()}),V=e=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(e),G=(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]),a=parseInt(s[e]);return o===a||Number.isNaN(o)&&Number.isNaN(a)?t<n?-1:1:o<a||Number.isNaN(o)&&Number.isInteger(a)?-1:1}return i.length===s.length?0:i.length<s.length?-1:1},W=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,a=e.rootDirectory;if(a&&!a.endsWith("/")&&(a+="/"),"object"==typeof n&&n.isInternal)a&&(o=e[s].version?`${a}${J[s]}@${e[s].version}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`:`${a}${J[s]}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`);else{const i=/^@engineRootDirectory(\/?)/;if("string"==typeof o&&(o=o.replace(i,a||"")),"object"==typeof o&&"dwt"===s){const n=e[s].resourcesPath,o=e[s].serviceInstallerLocation;t[s]={resourcesPath:n.replace(i,a||""),serviceInstallerLocation:o.replace(i,a||"")};continue}}t[s]=v(o)}return t},j=async(e,t,i)=>await new Promise(async(s,n)=>{try{const n=t.split(".");let o=n[n.length-1];const a=await q(`image/${o}`,e);n.length<=1&&(o="png");const r=new File([a],t,{type:`image/${o}`});if(i){const e=URL.createObjectURL(r),i=document.createElement("a");i.href=e,i.download=t,i.click()}s(r)}catch(e){n()}}),Z=e=>{L(e)&&(e=z(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},H=(e,t)=>{L(t)&&(t=z(t));const i=Z(t);let s=new Image,n=i.toDataURL(e);return s.src=n,s},q=async(e,t)=>{L(t)&&(t=z(t));const i=Z(t);if("image/bmp"===e){const e=i.getContext("2d"),t=Y(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)})},Y=e=>{const t=e.width,i=e.height,s=e.data,n=4*Math.floor((24*t+31)/32),o=n*i,a=54+o,r=new ArrayBuffer(a),c=new DataView(r);c.setUint16(0,19778,!0),c.setUint32(2,a,!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],a=s[n+1],r=s[n+2];c.setUint8(l++,r),c.setUint8(l++,a),c.setUint8(l++,o)}for(let e=0;e<d;e++)c.setUint8(l++,0)}return r},z=e=>{let t,i=e.bytes;if(!(i&&i instanceof Uint8Array))throw Error("Parameter type error");if(Number(e.format)===f.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)===f.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)===f.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)===f.IPF_BINARY_8||Number(e.format)===f.IPF_BINARY_8_INVERTED){const s=i.length,n=e.width,o=e.height,a=e.stride;t=new Uint8ClampedArray(n*o*4);for(let e=0;e<s;e++){let s=i[e],o=e%a,r=Math.floor(e/a);for(let e=0;e<8;e++){let i=o+e,a=4*(r*n+i);if(i>=n)break;t[a]=t[a+1]=t[a+2]=(128&s)/128*255,t[a+3]=255,s<<=1}}}else if(Number(e.format)===f.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)===f.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),f.IPF_BINARY_8_INVERTED;return new ImageData(t,e.width,e.height)},$=()=>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])),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:f.IPF_ABGR_8888}}finally{URL.revokeObjectURL(t)}},X=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)),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:o,tagLength:128},n,i.encode(e)),r=new Uint8Array(o.length+a.byteLength);return r.set(o),r.set(new Uint8Array(a),o.length),btoa(String.fromCharCode.apply(null,r))},Q=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),a=new TextEncoder,r=await crypto.subtle.importKey("raw",a.encode(t),"PBKDF2",!1,["deriveKey"]),c=await crypto.subtle.deriveKey({name:"PBKDF2",salt:a.encode("salt-for-key-derivation"),iterations:1e5,hash:"SHA-256"},r,{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)},J={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 ee,te,ie,se,ne,oe,ae,re;let ce,le,de,ue,he,_e=class e{get _isFetchingStarted(){return _(this,ne,"f")}constructor(){ee.add(this),te.set(this,[]),ie.set(this,1),se.set(this,g.BOPM_BLOCK),ne.set(this,!1),oe.set(this,void 0),ae.set(this,p.CCUT_AUTO)}setErrorListener(e){}addImageToBuffer(e){var t;if(!L(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(_(this,te,"f").length>=_(this,ie,"f"))switch(_(this,se,"f")){case g.BOPM_BLOCK:break;case g.BOPM_UPDATE:if(_(this,te,"f").push(e),w(_(this,oe,"f"))&&T(_(this,oe,"f").imageId)&&1==_(this,oe,"f").keepInBuffer)for(;_(this,te,"f").length>_(this,ie,"f");){const e=_(this,te,"f").findIndex(e=>{var t;return(null===(t=e.imageTag)||void 0===t?void 0:t.imageId)!==_(this,oe,"f").imageId});_(this,te,"f").splice(e,1)}else _(this,te,"f").splice(0,_(this,te,"f").length-_(this,ie,"f"))}else _(this,te,"f").push(e)}getImage(){if(0===_(this,te,"f").length)return null;let t;if(_(this,oe,"f")&&T(_(this,oe,"f").imageId)){const e=_(this,ee,"m",re).call(this,_(this,oe,"f").imageId);if(e<0)throw new Error(`Image with id ${_(this,oe,"f").imageId} doesn't exist.`);t=_(this,te,"f").slice(e,e+1)[0]}else t=_(this,te,"f").pop();if([f.IPF_RGB_565,f.IPF_RGB_555,f.IPF_RGB_888,f.IPF_ARGB_8888,f.IPF_RGB_161616,f.IPF_ARGB_16161616,f.IPF_ABGR_8888,f.IPF_ABGR_16161616,f.IPF_BGR_888].includes(t.format)){if(_(this,ae,"f")===p.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 f.IPF_RGB_565:case f.IPF_RGB_555:case f.IPF_RGB_888:case f.IPF_RGB_161616:i[e]=t.bytes[3*e+2];break;case f.IPF_ARGB_8888:case f.IPF_ARGB_16161616:i[e]=t.bytes[4*e+2];break;case f.IPF_BGR_888:i[e]=t.bytes[3*e];break;case f.IPF_ABGR_8888:case f.IPF_ABGR_16161616:i[e]=t.bytes[4*e]}t.bytes=i,t.stride=t.width,t.format=f.IPF_GRAYSCALED}else if(_(this,ae,"f")===p.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 f.IPF_RGB_565:case f.IPF_RGB_555:case f.IPF_RGB_888:case f.IPF_RGB_161616:case f.IPF_BGR_888:i[e]=t.bytes[3*e+1];break;case f.IPF_ARGB_8888:case f.IPF_ARGB_16161616:case f.IPF_ABGR_8888:case f.IPF_ABGR_16161616:i[e]=t.bytes[4*e+1]}t.bytes=i,t.stride=t.width,t.format=f.IPF_GRAYSCALED}else if(_(this,ae,"f")===p.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 f.IPF_RGB_565:case f.IPF_RGB_555:case f.IPF_RGB_888:case f.IPF_RGB_161616:i[e]=t.bytes[3*e];break;case f.IPF_ARGB_8888:case f.IPF_ARGB_16161616:i[e]=t.bytes[4*e];break;case f.IPF_BGR_888:i[e]=t.bytes[3*e+2];break;case f.IPF_ABGR_8888:case f.IPF_ABGR_16161616:i[e]=t.bytes[4*e+2]}t.bytes=i,t.stride=t.width,t.format=f.IPF_GRAYSCALED}}else[f.IPF_NV21,f.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=>T(e)))(e))throw new TypeError("Invalid 'imageId'.");if(void 0!==t&&"[object Boolean]"!==R(t))throw new TypeError("Invalid 'keepInBuffer'.");m(this,oe,{imageId:e,keepInBuffer:t},"f")}_resetNextReturnedImage(){m(this,oe,null,"f")}hasImage(e){return _(this,ee,"m",re).call(this,e)>=0}startFetching(){m(this,ne,!0,"f")}stopFetching(){m(this,ne,!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(m(this,ie,e,"f");_(this,te,"f")&&_(this,te,"f").length>e;)_(this,te,"f").shift()}getMaxImageCount(){return _(this,ie,"f")}getImageCount(){return _(this,te,"f").length}clearBuffer(){_(this,te,"f").length=0}isBufferEmpty(){return 0===_(this,te,"f").length}setBufferOverflowProtectionMode(e){m(this,se,e,"f")}getBufferOverflowProtectionMode(){return _(this,se,"f")}setColourChannelUsageType(e){m(this,ae,e,"f")}getColourChannelUsageType(){return _(this,ae,"f")}};te=new WeakMap,ie=new WeakMap,se=new WeakMap,ne=new WeakMap,oe=new WeakMap,ae=new WeakMap,ee=new WeakSet,re=function(e){if("number"!=typeof e)throw new TypeError("Invalid 'imageId'.");return _(this,te,"f").findIndex(t=>{var i;return(null===(i=t.imageTag)||void 0===i?void 0:i.imageId)===e})},"undefined"!=typeof navigator&&(ce=navigator,le=ce.userAgent,de=ce.platform,ue=ce.mediaDevices),function(){if(!E){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:ce.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:de,search:"Win"},Mac:{str:de},Linux:{str:de}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let o=n.str||le,a=n.search||t,r=n.verStr||le,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=o.indexOf(a)){i=t;for(let e of c){let t=r.indexOf(e);if(-1!=t){s=parseFloat(r.substring(t+e.length+1));break}}break}}for(let e in t){const i=t[e]||{};let s=i.str||le,o=i.search||e;if(-1!=s.indexOf(o)){n=e;break}}"Linux"==n&&-1!=le.indexOf("Windows NT")&&(n="HarmonyOS"),he={browser:i,version:s,OS:n}}E&&(he={browser:"ssr",version:0,OS:"ssr"})}();const me="undefined"!=typeof WebAssembly&&le&&!(/Safari/.test(le)&&!/Chrome/.test(le)&&/\(.+\s11_2_([2-6]).*\)/.test(le)),ge=!("undefined"==typeof Worker),pe=!(!ue||!ue.getUserMedia),fe=async()=>{let e=!1;if(pe)try{(await ue.getUserMedia({video:!0})).getTracks().forEach(e=>{e.stop()}),e=!0}catch(e){}return e};var Ee,ye,Ie,ve,Re,Ce,Te,we,Se;"Chrome"===he.browser&&he.version>66||"Safari"===he.browser&&he.version>13||"OPR"===he.browser&&he.version>43||"Edge"===he.browser&&he.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"}(Ee||(Ee={})),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"}(ye||(ye={})),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"}(Ie||(Ie={})),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"}(ve||(ve={})),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"}(Re||(Re={})),function(e){e[e.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",e[e.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(Ce||(Ce={})),function(e){e[e.PDFRM_VECTOR=1]="PDFRM_VECTOR",e[e.PDFRM_RASTER=2]="PDFRM_RASTER",e[e.PDFRM_MULTIMODAL=3]="PDFRM_MULTIMODAL"}(Te||(Te={})),function(e){e[e.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",e[e.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(we||(we={})),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"}(Se||(Se={}));const Ae={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 De,be,Oe,Le,Ne,Me,Be;!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"}(De||(De={})),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"}(be||(be={})),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"}(Oe||(Oe={})),function(e){e[e.ICDM_NEAR=0]="ICDM_NEAR",e[e.ICDM_FAR=1]="ICDM_FAR"}(Le||(Le={})),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"}(Ne||(Ne={})),function(e){e[e.MU_PIXEL=0]="MU_PIXEL",e[e.MU_PERCENTAGE=1]="MU_PERCENTAGE"}(Me||(Me={})),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"}(Be||(Be={}));const Fe=async e=>await new Promise((t,i)=>{let s=Ue();Ve[s]=async e=>{if(e.success)return t(e.u8);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},Pe.postMessage({type:"imagePtrToUint8Array",id:s,body:{data:e}})}),xe=async e=>await new Promise((t,i)=>{let s=Ue();Ve[s]=async e=>{if(e.success)return t(e.result);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},Pe.postMessage({type:"resolveDsImageData",id:s,body:{point:e}})});let Pe,ke=0;const Ue=()=>ke++,Ve={};let Ge=!1;const We=e=>{Ge=e,Pe&&Pe.postMessage({type:"setBDebug",body:{value:e}})},je={},Ze={},He={core:{version:"4.6.20-dev-20260813111327",path:I,isInternal:!0}},qe=new class extends h{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){var t=this;let i;this._task=e,u(e)?i=e:"function"==typeof e&&(i=new h(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(u(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};let Ye=5;"undefined"!=typeof navigator&&(Ye=navigator.hardwareConcurrency?Math.max(navigator.hardwareConcurrency-1,5):5),Ve[-3]=async e=>{ze.onWasmLoadProgressChanged&&ze.onWasmLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class ze{static get engineResourcePaths(){return He}static set engineResourcePaths(e){Object.assign(He,e)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _bDebug(){return Ge}static set _bDebug(e){We(e)}static get _workerName(){return`${ze._bundleEnv.toLowerCase()}.bundle.worker.js`}static get wasmLoadOptions(){return ze._wasmLoadOptions}static set wasmLoadOptions(e){if("number"==typeof e.pthreadPoolSize&&e.pthreadPoolSize<0)throw new Error(`Invalid thread count parameter ${e.pthreadPoolSize}.`);Object.assign(ze._wasmLoadOptions,e)}static isModuleLoaded(){return!!(null==qe?void 0:qe.isFulfilled)}static async loadWasm(){return await async function(){qe.isEmpty&&(qe.task=async function(e,t){const i=W(He),s={engineResourcePaths:i,_bundleEnv:ze._bundleEnv,wasmLoadOptions:ze.wasmLoadOptions};let n=i[`${ze._bundleEnv.toLowerCase()}Bundle`]+ze._workerName;n.startsWith(location.origin)||(n=await fetch(n).then(e=>e.blob()).then(e=>URL.createObjectURL(e))),Pe=new Worker(n),Pe.onerror=e=>{const i=new Error(e.message);t(i)},Pe.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":Ge&&(null===(t=ze._onLog)||void 0===t||t.call(ze,i.message));break;case"warning":console.warn(i.message);break;case"task":try{Ve[n]&&(Ve[n](o),delete Ve[n])}catch(e){throw delete Ve[n],e}break;case"event":try{Ve[n](o)}catch(e){throw e}break;default:console.log(e)}}),s.bd=Ge,s.dm=location.origin.startsWith("http")?location.origin:"https://localhost";const o=ke++;Ve[o]=i=>{if(i.success)Object.assign(je,i.versions),"{}"!==JSON.stringify(i.versions)&&(ze._versions=i.versions),ze.loadedWasmType=i.loadedWasmType,e(void 0);else{const e=Error(i.message);i.stack&&(e.stack=i.stack),t(e)}},Pe.postMessage({type:"loadWasm",id:o,body:s})}),await qe}()}static async detectEnvironment(){return await async function(){return{wasm:me,worker:ge,getUserMedia:pe,camera:await fe(),browser:he.browser,version:he.version,OS:he.OS}}()}static async getModuleVersion(){return await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e(i.versions);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.postMessage({type:"getModuleVersion",id:i})})}static getVersion(){return`4.6.20-dev-20260813111327(Worker: ${je.core&&je.core.worker||"Not Loaded"}, Wasm: ${je.core&&je.core.wasm||"Not Loaded"})`}static enableLogging(){_e._onLog=console.log,ze._onLog=console.log}static disableLogging(){_e._onLog=null,ze._onLog=null}static async cfd(e){return await new Promise((t,i)=>{let s=Ue();Ve[s]=async function(e){if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},Pe.postMessage({type:"cfd",id:s,body:{count:e}})})}}ze._bSupportDce4Module=-1,ze._bSupportIRTModule=-1,ze._versions=null,ze._onLog=console.log,ze._bundleEnv="DCV",ze._wasmLoadOptions={wasmType:Be.AUTO,pthreadPoolSize:Ye},ze.loadedWasmType=Be.ML_SIMD_PTHREAD,ze.browserInfo=he;var $e={license:"",scanMode:l.SM_SINGLE,templateFilePath:void 0,utilizedTemplateNames:{single:"ReadBarcodes_SpeedFirst",multi_unique:"ReadBarcodes_SpeedFirst",image:"ReadBarcodes_ReadRateFirst"},engineResourcePaths:ze.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 Ke=e=>e&&"object"==typeof e&&"function"==typeof e.then,Xe=(async()=>{})().constructor;class Qe 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){var t=this;let i;this._task=e,Ke(e)?i=e:"function"==typeof e&&(i=new Xe(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(Ke(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}var Je,et;const tt=e=>e&&"object"==typeof e&&"function"==typeof e.then,it=(async()=>{})().constructor;let st=class extends it{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){var t=this;let i;this._task=e,tt(e)?i=e:"function"==typeof e&&(i=new it(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(tt(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}},nt=class{constructor(e){a(this,"_cvr",void 0),this._cvr=e}async getMaxBufferedItems(){return await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e(i.count);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.postMessage({type:"cvr_getMaxBufferedItems",id:i,instanceID:this._cvr._instanceID})})}async setMaxBufferedItems(e){return await new Promise((t,i)=>{let s=Ue();Ve[s]=async function(e){if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},Pe.postMessage({type:"cvr_setMaxBufferedItems",id:s,instanceID:this._cvr._instanceID,body:{count:e}})})}async getBufferedCharacterItemSet(){return await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e(i.itemSet);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.postMessage({type:"cvr_getBufferedCharacterItemSet",id:i,instanceID:this._cvr._instanceID})})}};const ot={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},at={onTaskResultsReceived:()=>{},isFilter:!0},rt=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 ct=class{constructor(e){a(this,"_cvr",void 0),a(this,"_irrRegistryState",JSON.parse(JSON.stringify(ot))),a(this,"_intermediateResultReceiverSet",new Set),this._cvr=e}async addResultReceiver(e){if("object"!=typeof e)throw new Error("Invalid receiver.");this._intermediateResultReceiverSet.add(e),rt(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=Ue();Ve[n]=async function(t){if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,s(e)}},Pe.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),rt(this),await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.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 rt(this),await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})})}getOriginalImage(){return this._cvr.provideDsImage}};const lt="undefined"==typeof self,dt="function"==typeof importScripts,ut=(()=>{if(!dt){if(!lt&&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"./"}})();ze.engineResourcePaths.cvr={version:"3.6.20-dev-20260813111333",path:ut,isInternal:!0},Ze.cvr={};let ht=class{static getVersion(){return this._version}};function _t(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}_t(e.referencedItem,t)}}function mt(e){if(e.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}function gt(e){return{type:Ee.CRIT_ORIGINAL_IMAGE,referenceItem:null,targetROIDefName:"",taskName:"",imageData:e,toCanvas:()=>Z(e),toImage:t=>H(t,e),toBlob:t=>q(t,e)}}function pt(e){let t=!1;const i=[Ie.EC_UNSUPPORTED_JSON_KEY_WARNING,Ie.EC_LICENSE_AUTH_QUOTA_EXCEEDED,Ie.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 ft(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 Et(e){return Math.abs(e)<1e-6?0:e<0?-1:1}function yt(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(ht,"_version",`3.6.20-dev-20260813111333(Worker: ${null===(et=je.cvr)||void 0===et?void 0:et.worker}, Wasm: loading...`),BigInt(0),BigInt("0xFFFFFFFEFFFFFFFF"),BigInt(4265345023);const It=BigInt(3147775),vt=(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)),Rt=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){var t=this;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 function(e){if(!t.isSupportDCEModule)return;let i=t.cameraEnhancer;(4&i._dceEnhancedFeatures||16&i._dceEnhancedFeatures||64&i._dceEnhancedFeatures)&&(0!==ze.bSupportDce4Module?(t.isSupportDCEModule=!1,console.warn("Warning: The license required for Enhanced Features was not found.")):(!t.consumeTime||Date.now()-t.consumeTime>1e4)&&(ze.cfd(1),t.consumeTime=Date.now()));const s=e.intermediateResultUnits;if(!i.isOpen()||i.isPaused())return;const n=i.getVisibleAreaInVideoXY({isConsiderRegionBox:!0});if(isNaN(n.x)||isNaN(n.y)||isNaN(n.width)||isNaN(n.height))return;let o=!1,a=!1;for(let e of s){if(e.unitType===Ae.IRUT_DECODED_BARCODES&&e.decodedBarcodes.length){o=!0;break}e.unitType===Ae.IRUT_LOCALIZED_BARCODES&&e.localizedBarcodes.length&&(a=!0)}if(16&i._dceEnhancedFeatures||4&i._dceEnhancedFeatures)if(o)t._autoZoomParameters.autoZoomInFrameArray.length=0,t._autoZoomParameters.autoZoomOutFrameCount=0,t._autoZoomParameters.frameArrayInIdealZoom.length=0,t._autoZoomParameters.autoFocusFrameArray.length=0;else{const o=async function(e){await i.setZoom(e)},r=async function(e){await i.setFocus(e)};if(a){n.x,n.y;const a=n.width,c=n.height,l=n.width,d=n.height;let u;{let e,o,a,r,c;{const e=i.video.videoWidth*(1-t._autoZoomParameters.autoZoomDetectionArea)/2,s=i.video.videoWidth*(1+t._autoZoomParameters.autoZoomDetectionArea)/2,n=s,o=e,a=i.video.videoHeight*(1-t._autoZoomParameters.autoZoomDetectionArea)/2,r=a,l=i.video.videoHeight*(1+t._autoZoomParameters.autoZoomDetectionArea)/2;c=[{x:e,y:a},{x:s,y:r},{x:n,y:l},{x:o,y:l}]}const h=[];{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 a=e[o],r=e[(o+1)%n];if(ft(a,r,{x:t,y:i}))return!0;Et(a.y-i)>0!=Et(r.y-i)>0&&Et(t-(i-a.y)*(a.x-r.x)/(a.y-r.y)-a.x)<0&&(s=!s)}return s}(t,e.x,e.y)},s=(e,t)=>!!(yt([e[0],e[1]],[e[2],e[3]],[t[0].x,t[0].y],[t[1].x,t[1].y])||yt([e[0],e[1]],[e[2],e[3]],[t[1].x,t[1].y],[t[2].x,t[2].y])||yt([e[0],e[1]],[e[2],e[3]],[t[2].x,t[2].y],[t[3].x,t[3].y])||yt([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 s)if(t.unitType===Ae.IRUT_LOCALIZED_BARCODES)for(let i of t.localizedBarcodes)i&&e(c,i.location.points.map(e=>({x:e.x+n.x,y:e.y+n.y})))&&h.push(i)}if(!h.length)return;let _;if(h.length){let e=h.filter(e=>e.possibleFormats==vt||e.possibleFormats==Rt);if(e.length||(e=h.filter(e=>e.possibleFormats==It),e.length||(e=h)),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-l/2)*(i-l/2)+(s-d/2)*(s-d/2)};_=e[0];let i=t(_);if(1!=e.length)for(let s=1;s<e.length;s++){const n=t(e[s]);(e[s].confidence>1.1*_.confidence||e[s].confidence>.9*_.confidence&&n<i)&&(_=e[s],i=n)}}}if(_){const t=_.location.points;e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),o=Math.max(t[0].x,t[1].x,t[2].x,t[3].x),a=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),u={points:[{x:e,y:a},{x:o,y:a},{x:o,y:r},{x:e,y:r}],result:_}}}if(!u)return;if(t._autoZoomParameters.autoZoomOutFrameCount=0,16&i._dceEnhancedFeatures){const s=t._autoZoomParameters.autoZoomIdealArea[1];let n=(1-t._autoZoomParameters.autoZoomTargetBorder)/2;const l=u.points[0].x/a,d=(a-u.points[2].x)/a,h=u.points[0].y/c,_=(c-u.points[2].y)/c;if(l>s&&d>s&&h>s&&_>s&&u.result.moduleSize<t._autoZoomParameters.autoZoomInIdealModuleSize){if(t._autoZoomParameters.autoZoomInFrameArray.push(!0),t._autoZoomParameters.autoZoomInFrameArray.splice(0,t._autoZoomParameters.autoZoomInFrameArray.length-t._autoZoomParameters.autoZoomInFrameLimit[0]),t._autoZoomParameters.frameArrayInIdealZoom.length=0,4&i._dceEnhancedFeatures&&r({mode:"continuous"}).catch(()=>{}),t._autoZoomParameters.autoZoomInFrameArray.filter(e=>!0===e).length>=t._autoZoomParameters.autoZoomInFrameLimit[1]){t._autoZoomParameters.autoZoomInFrameArray.length=0;const s=[(.5-n)/(.5-l),(.5-n)/(.5-d),(.5-n)/(.5-h),(.5-n)/(.5-_)].filter(e=>e>0),a=Math.min(...s,t._autoZoomParameters.autoZoomInIdealModuleSize/u.result.moduleSize),r=i.getZoomSettings().factor;let c=Math.max(Math.pow(r*a,1/t._autoZoomParameters.autoZoomInMaxTimes),t._autoZoomParameters.autoZoomInMinStep);c=Math.min(c,a);let m=r*c;m=Math.max(i._dceAutoZoomRange.min,m),m=Math.min(i._dceAutoZoomRange.max,m);try{await o({factor:m})}catch(e){const t=e.message||e;console.warn(t)}i._framePipeline&&(i._framePipeline._data=null)}}else if(t._autoZoomParameters.autoZoomInFrameArray.length=0,t._autoZoomParameters.frameArrayInIdealZoom.push(!0),t._autoZoomParameters.frameArrayInIdealZoom.splice(0,t._autoZoomParameters.frameArrayInIdealZoom.length-t._autoZoomParameters.frameLimitInIdealZoom[0]),t._autoZoomParameters.frameArrayInIdealZoom.filter(e=>!0===e).length>=t._autoZoomParameters.frameLimitInIdealZoom[1]&&(t._autoZoomParameters.frameArrayInIdealZoom.length=0,4&i._dceEnhancedFeatures)){const t=u.points;try{await r({mode:"manual",area:{centerPoint:{x:(t[0].x+t[2].x)/2+"px",y:(t[0].y+t[2].y)/2+"px"},width:t[2].x-t[0].x+"px",height:t[2].y-t[0].y+"px"}})}catch(e){const t=e.message||e;console.warn(t)}i._framePipeline&&(i._framePipeline._data=null)}}if(!(16&i._dceEnhancedFeatures)&&4&i._dceEnhancedFeatures&&(t._autoZoomParameters.autoFocusFrameArray.push(!0),t._autoZoomParameters.autoFocusFrameArray.splice(0,t._autoZoomParameters.autoFocusFrameArray.length-t._autoZoomParameters.autoFocusFrameLimit[0]),t._autoZoomParameters.autoFocusFrameArray.filter(e=>!0===e).length>=t._autoZoomParameters.autoFocusFrameLimit[1])){t._autoZoomParameters.autoFocusFrameArray.length=0;try{const e=u.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)}i._framePipeline&&(i._framePipeline._data=null)}}else{if(16&i._dceEnhancedFeatures){if(t._autoZoomParameters.autoZoomInFrameArray.push(!1),t._autoZoomParameters.autoZoomInFrameArray.splice(0,t._autoZoomParameters.autoZoomInFrameArray.length-t._autoZoomParameters.autoZoomInFrameLimit[0]),t._autoZoomParameters.autoZoomOutFrameCount++,t._autoZoomParameters.frameArrayInIdealZoom.push(!1),t._autoZoomParameters.frameArrayInIdealZoom.splice(0,t._autoZoomParameters.frameArrayInIdealZoom.length-t._autoZoomParameters.frameLimitInIdealZoom[0]),t._autoZoomParameters.autoZoomOutFrameCount>=t._autoZoomParameters.autoZoomOutFrameLimit){t._autoZoomParameters.autoZoomOutFrameCount=0;const s=i.getZoomSettings().factor;let n=s-Math.max((s-1)*t._autoZoomParameters.autoZoomOutStepRate,t._autoZoomParameters.autoZoomOutMinStep);n=Math.max(i._dceAutoZoomRange.min,n),n=Math.min(i._dceAutoZoomRange.max,n);try{await o({factor:n})}catch(e){const t=e.message||e;console.warn(t)}i._framePipeline&&(i._framePipeline._data=null)}4&i._dceEnhancedFeatures&&r({mode:"continuous"}).catch(()=>{})}!(16&i._dceEnhancedFeatures)&&4&i._dceEnhancedFeatures&&(t._autoZoomParameters.autoFocusFrameArray.length=0,r({mode:"continuous"}).catch(()=>{}))}}}),a(this,"isDce",!0),this.cameraEnhancer=e}};var Tt,wt;!function(e){e[e.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",e[e.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}(Tt||(Tt={})),Ve[-2]=async e=>{Gt.onDataLoadProgressChanged&&Gt.onDataLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};var St=new WeakMap,At=new WeakMap,Dt=new WeakMap,bt=new WeakMap,Ot=new WeakMap,Lt=new WeakMap,Nt=new WeakMap,Mt=new WeakMap,Bt=new WeakMap,Ft=new WeakMap,xt=new WeakMap,Pt=new WeakMap,kt=new WeakMap,Ut=new WeakMap,Vt=new WeakSet;let Gt=class t{constructor(){o(this,Vt),a(this,"maxImageSideLength",["iPhone","Android","HarmonyOS"].includes(ze.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),s(this,St,null),s(this,At,null),s(this,Dt,null),s(this,bt,null),s(this,Ot,null),s(this,Lt,new Set),s(this,Nt,new Set),s(this,Mt,new Set),s(this,Bt,500),s(this,Ft,0),s(this,xt,0),s(this,Pt,0),s(this,kt,!1),s(this,Ut,!1),a(this,"_singleFrameModeCallbackBind",this._singleFrameModeCallback.bind(this))}get disposed(){return i(Ut,this)}get isCapturing(){return this._isCapturing}static async createInstance(e=!0){if(!Ze.license)throw Error("The `license` module cannot be found.");return await Ze.license.dynamsoft(),await ze.loadWasm(),await new Promise((i,s)=>{const o=new t,a=Ue();Ve[a]=async function(e){var a;e.success?(o._instanceID=e.instanceID,null!==(a=t._fr4DisposeCvrWasm)&&void 0!==a&&a.register(o,e.instanceID,o),t._isNoOnnx=e.isNoOnnx,ht._version=`3.6.20-dev-20260813111333(Worker: ${je.cvr.worker}, Wasm: ${e.version})`,n(kt,o,!0),n(bt,o,o.getIntermediateResultManager()),n(kt,o,!1),i(o)):pt({message:e.message,rj:s,stack:e.stack,functionName:"createInstance"})},Pe.postMessage({type:"cvr_createInstance",id:a,body:{loadPresetTemplates:e}})})}static async appendDLModelBuffer(e,i){return await ze.loadWasm(),t._isNoOnnx?Promise.reject("Model not supported in the current environment."):await new Promise((t,s)=>{const n=Ue(),o=W(ze.engineResourcePaths);let a;Ve[n]=async function(e){if(e.success){const i=JSON.parse(e.response);if(0!==i.errorCode&&pt({message:i.errorString?i.errorString:"Append Model Buffer Failed.",rj:s,errorCode:i.errorCode,functionName:"appendDLModelBuffer"}))return;return t(i)}pt({message:e.message,rj:s,stack:e.stack,functionName:"appendDLModelBuffer"})},i?(a=new URL(i,location.href).href,a=a.endsWith("/")?a:a+"/"):"DCV"===ze._bundleEnv?a=o.dcvData+"models/":"DBR"===ze._bundleEnv&&(a=o.dbrBundle+"models/");let r=Array.isArray(e)?e:[e];r=r.map(e=>e.replace(/\.data$/i,"")),Pe.postMessage({type:"cvr_appendDLModelBuffer",id:n,body:{modelNames:r,path:a}})})}static async clearDLModelBuffers(){return await new Promise((e,t)=>{const i=Ue();Ve[i]=async function(i){if(i.success)return e();pt({message:i.message,rj:t,stack:i.stack,functionName:"clearDLModelBuffers"})},Pe.postMessage({type:"cvr_clearDLModelBuffers",id:i})})}async _singleFrameModeCallback(){const t=i(St,this)._singleFrameModeResultForDcv;if(!t)return;e(Vt,this,Wt).call(this,t);const s={bytes:new Uint8Array(t.bytes),width:t.width,height:t.height,stride:t.stride,format:t.format,imageTag:t.imageTag},n=await this.capture(s,this._templateName);n.originalImageTag=t.imageTag,i(St,this)._cameraView._capturedResultReceiver.onCapturedResultReceived(n,{isDetectVerifyOpen:!1,isNormalizeVerifyOpen:!1,isBarcodeVerifyOpen:!1,isLabelVerifyOpen:!1}),e(Vt,this,Ht).call(this,n),i(St,this)._singleFrameModeResultForDcv=null}setInput(e){if(mt(this),!this.isCapturing)if(n(St,this,e),null!=e&&e.isCameraEnhancer){if(this._enhancedFeaturesIrr)return;this._enhancedFeaturesIrr=new Ct(e),i(bt,this).addResultReceiver(this._enhancedFeaturesIrr)}else i(bt,this).removeResultReceiver(this._enhancedFeaturesIrr),this._enhancedFeaturesIrr=null}getInput(){return i(St,this)}addImageSourceStateListener(e){if(mt(this),"object"!=typeof e)return console.warn("Invalid ISA state listener.");e&&Object.keys(e)&&i(Nt,this).add(e)}removeImageSourceStateListener(e){return mt(this),i(Nt,this).delete(e)}async addResultReceiver(e){if(mt(this),"object"!=typeof e)throw new Error("Invalid receiver.");e&&Object.keys(e).length&&(i(Lt,this).add(e),await this._setCrrRegistry())}async removeResultReceiver(e){mt(this),i(Lt,this).delete(e),await this._setCrrRegistry()}async removeAllResultReceivers(){mt(this),i(Lt,this).clear(),await this._setCrrRegistry()}async _setCrrRegistry(){const e={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onProcessedDocumentResultReceived:!1,onParsedResultsReceived:!1};for(let t of i(Lt,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=Ue();return await new Promise((i,s)=>{Ve[t]=async function(e){e.success?i():pt({message:e.message,rj:s,stack:e.stack,functionName:"addResultReceiver"})},Pe.postMessage({type:"cvr_setCrrRegistry",id:t,instanceID:this._instanceID,body:{receiver:JSON.stringify(e)}})})}async addResultFilter(e){if(mt(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.");i(Mt,this).add(e),e._dynamsoft(),await this._handleFilterUpdate()}async removeResultFilter(e){mt(this),i(Mt,this).delete(e),await this._handleFilterUpdate()}async removeAllResultFilters(){mt(this),i(Mt,this).clear(),await this._handleFilterUpdate()}async _handleFilterUpdate(){if(i(bt,this).removeResultReceiver(at),0===i(Mt,this).size){this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1;const t={[Ee.CRIT_BARCODE]:!1,[Ee.CRIT_TEXT_LINE]:!1,[Ee.CRIT_DETECTED_QUAD]:!1,[Ee.CRIT_DESKEWED_IMAGE]:!1,[Ee.CRIT_ENHANCED_IMAGE]:!1},i={[Ee.CRIT_BARCODE]:!1,[Ee.CRIT_TEXT_LINE]:!1,[Ee.CRIT_DETECTED_QUAD]:!1,[Ee.CRIT_DESKEWED_IMAGE]:!1,[Ee.CRIT_ENHANCED_IMAGE]:!1};return await e(Vt,this,qt).call(this,t),void await e(Vt,this,Yt).call(this,i)}for(let t of i(Mt,this))this._isOpenBarcodeVerify=t.isResultCrossVerificationEnabled(Ee.CRIT_BARCODE),this._isOpenLabelVerify=t.isResultCrossVerificationEnabled(Ee.CRIT_TEXT_LINE),this._isOpenDetectVerify=t.isResultCrossVerificationEnabled(Ee.CRIT_DETECTED_QUAD),this._isOpenNormalizeVerify=t.isResultCrossVerificationEnabled(Ee.CRIT_DESKEWED_IMAGE),t.isLatestOverlappingEnabled(Ee.CRIT_BARCODE)&&([...i(bt,this)._intermediateResultReceiverSet.values()].find(e=>e.isFilter)||i(bt,this).addResultReceiver(at)),await e(Vt,this,qt).call(this,t.verificationEnabled),await e(Vt,this,Yt).call(this,t.duplicateFilterEnabled),await e(Vt,this,zt).call(this,t.duplicateForgetTime),await e(Vt,this,$t).call(this,t.crossVerificationCriteria)}async startCapturing(e){var s,o=this;if(mt(this),this.isCapturing)return;if(!i(St,this))throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");e||(e=t._defaultTemplate);for(let e of i(Mt,this))await this.addResultFilter(e);const a=W(ze.engineResourcePaths);if(i(Dt,this)&&i(Dt,this).isPending)return i(Dt,this);const r=n(Pt,this,(s=i(Pt,this),++s));return n(Dt,this,new st((t,s)=>{if(this.disposed)return;const n=Ue();Ve[n]=async function(n){i(Dt,o)&&!i(Dt,o).isFulfilled&&r===i(Pt,o)&&(n.success?(o._isCapturing=!0,o._templateName=e,void 0!==i(St,o).singleFrameMode&&"disabled"!==i(St,o).singleFrameMode?(i(St,o).on("singleFrameAcquired",o._singleFrameModeCallbackBind),o._singleFrameModeCallback(),t()):(o._isOutputOriginalImage=n.isOutputOriginalImage,o._minImageCaptureInterval=n.minImageCaptureInterval,o._loopReadVideoTimeoutId&&clearTimeout(o._loopReadVideoTimeoutId),o._loopReadVideoTimeoutId=setTimeout(async function(){if(r===i(Pt,o)&&o.isCapturing){-1!==o._minImageCaptureInterval&&i(St,o).startFetching();for(let e of i(Nt,o))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(Tt.ISS_BUFFER_EMPTY);o.barcodeScanLoop(e,r),t()}},0))):pt({message:n.message,rj:s,stack:n.stack,functionName:"startCapturing"}))},Pe.postMessage({type:"cvr_startCapturing",id:n,instanceID:this._instanceID,body:{templateName:e,engineResourcePaths:a}})})),await i(Dt,this)}stopCapturing(){var e;if(mt(this),!i(St,this))return;n(Pt,this,(e=i(Pt,this),++e)),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=null,i(St,this).stopFetching(),this._averageProcessintTimeArray=[],this._isCapturing=!1,this._averageTime=999,n(Dt,this,null),i(St,this).isCameraEnhancer&&i(St,this).off("singleFrameAcquired",this._singleFrameModeCallbackBind);const t=Ue();Pe.postMessage({type:"cvr_stopCapturing",id:t,instanceID:this._instanceID})}async containsTask(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async function(e){if(e.success)return t(JSON.parse(e.tasks));pt({message:e.message,rj:i,stack:e.stack,functionName:"containsTask"})},Pe.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(s,n=i(Pt,this)){var o=this;if(n!==i(Pt,this)||!this.isCapturing)return;if(i(St,this).isBufferEmpty())if(i(St,this).hasNextImageToFetch())for(let e of i(Nt,this))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(Tt.ISS_BUFFER_EMPTY);else for(let e of i(Nt,this))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(Tt.ISS_EXHAUSTED);const a=i(St,this).getImage();if(!a)return i(St,this)._bClosedBecauseOfNotInDOM?void this.stopCapturing():(await new Promise(e=>setTimeout(e,100)),void this.continueLoop(s,n));if(a.imageTag&&Date.now()-a.imageTag.timeStamp>200)return void this.continueLoop(s,n);e(Vt,this,Wt).call(this,a),a._s=!0;const r=Date.now();this._captureInWorker(a,s).then(async function(c){if(n!==i(Pt,o)||!o.isCapturing)return;if(t._onLog&&t._onLog("no js handle time: "+(Date.now()-r)),!o.isCapturing)return void o.continueLoop(s,n);c.originalImageTag=a.imageTag?a.imageTag:null,i(St,o)._capturedResultReceiver&&i(St,o)._cameraView._capturedResultReceiver.onCapturedResultReceived(c,{isDetectVerifyOpen:o._isOpenDetectVerify,isNormalizeVerifyOpen:o._isOpenNormalizeVerify,isBarcodeVerifyOpen:o._isOpenBarcodeVerify,isLabelVerifyOpen:o._isOpenLabelVerify});for(let e of i(Mt,o)){const t=e;t.onOriginalImageResultReceived(c),t.onDecodedBarcodesReceived(c),t.onRecognizedTextLinesReceived(c),t.onProcessedDocumentResultReceived(c),t.onParsedResultsReceived(c)}e(Vt,o,Ht).call(o,c);const l=Date.now();if(o._minImageCaptureInterval>-1&&(5===o._averageProcessintTimeArray.length&&o._averageProcessintTimeArray.shift(),5===o._averageFetchImageTimeArray.length&&o._averageFetchImageTimeArray.shift(),o._averageProcessintTimeArray.push(Date.now()-r),o._averageFetchImageTimeArray.push(a&&a.imageTag?a.imageTag.timeSpent:0),o._averageTime=Math.min(...o._averageProcessintTimeArray)-Math.max(...o._averageFetchImageTimeArray),o._averageTime=o._averageTime>0?o._averageTime:0,t._onLog&&(t._onLog(`minImageCaptureInterval: ${o._minImageCaptureInterval}`),t._onLog(`averageProcessintTimeArray: ${o._averageProcessintTimeArray}`),t._onLog(`averageFetchImageTimeArray: ${o._averageFetchImageTimeArray}`),t._onLog(`averageTime: ${o._averageTime}`))),t._onLog){const e=Date.now()-l;e>10&&t._onLog(`fetch image calculate time: ${e}`)}t._onLog&&t._onLog(`time finish decode: ${Date.now()}`),t._onLog&&t._onLog("main time: "+(Date.now()-r)),t._onLog&&t._onLog("===================================================="),o._loopReadVideoTimeoutId&&clearTimeout(o._loopReadVideoTimeoutId),o._minImageCaptureInterval>0&&o._minImageCaptureInterval>=o._averageTime?o._loopReadVideoTimeoutId=setTimeout(()=>{o.barcodeScanLoop(s,n)},o._minImageCaptureInterval-o._averageTime):o._loopReadVideoTimeoutId=setTimeout(()=>{o.barcodeScanLoop(s,n)},Math.max(o._minImageCaptureInterval,0))}).catch(e=>{n===i(Pt,this)&&(i(St,this).stopFetching(),"platform error"!==e.message&&(e.errorCode&&0===e.errorCode&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{i(St,this).startFetching(),this.barcodeScanLoop(s,n)},Math.max(this._minImageCaptureInterval,1e3))),setTimeout(()=>{if(n===i(Pt,this)){if(!this.onCaptureError)throw e;this.onCaptureError(e)}},0)))})}continueLoop(e,t=i(Pt,this)){t===i(Pt,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:a,height:r,stride:c,format:l}=e,d=Ue();return new Promise((e,u)=>{Ve[d]=async function(t){t.success?e(t.clarity):pt({message:t.message,rj:u,stack:t.stack,functionName:"getClarity"})},Pe.postMessage({type:"cvr_getClarity",id:d,instanceID:this._instanceID,body:{bytes:o,width:a,height:r,stride:c,format:l,bitcount:t,wr:i,hr:s,grayThreshold:n}},[o.buffer])})}async capture(e,i){let s;if(mt(this),i||(i=t._defaultTemplate),L(e))s=await this._captureDsimage(e,i);else if("string"==typeof e)s="data:image/"==e.substring(0,11)?await this._captureBase64(e,i):await this._captureUrl(e,i);else if(e instanceof Blob)s=await this._captureBlob(e,i);else if(e instanceof HTMLImageElement)s=await this._captureImage(e,i);else if(e instanceof HTMLCanvasElement)s=await this._captureCanvas(e,i);else{if(!(e instanceof HTMLVideoElement))throw new TypeError("'capture(imageOrFile, templateName)': Type of 'imageOrFile' should be 'DSImageData', 'Url', 'Base64', 'Blob', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement'.");s=await this._captureVideo(e,i)}return s}async captureMultiPages(s,o="",a){var r=this;mt(this),o||(o=t._defaultTemplate);const c={pages:[],dpi:300};return Object.assign(c,a),await new Promise(async function(t,a){let l;if(l="string"==typeof s?await U(s,"blob"):s,"application/pdf"!==l.type)return void a("Unsupported file type. Only PDF are allowed.");const d=await l.arrayBuffer(),u=new Uint8Array(d),h=Ue();Ve[h]=s=>{if(s.success){var o;for(let t of s.capturedResults)e(Vt,r,jt).call(r,t);e(Vt,r,Zt).call(r,s.intermediateResult);const a=Date.now();a-i(Ft,r)>i(Bt,r)&&null!==s.mliRecord&&(null!==(o=localStorage)&&void 0!==o&&o.setItem("dynamsoft",s.mliRecord),n(Ft,r,a)),t(s.capturedResults)}else pt({message:s.message,rj:a,stack:s.stack,functionName:"captureMultiPages"})},Pe.postMessage({type:"cvr_captureMultiPages",id:h,instanceID:r._instanceID,body:{bytes:u,templateName:o,defaultOptions:c}},[u.buffer])})}async _captureDsimage(e,t){return await this._captureInWorker(e,t)}async _captureUrl(e,t){let i=await U(e,"blob");return await this._captureBlob(i,t)}async _captureBase64(e,t){e=e.substring(e.indexOf(",")+1);let i=atob(e),s=i.length,n=new Uint8Array(s);for(;s--;)n[s]=i.charCodeAt(s);return await this._captureBlob(new Blob([n]),t)}async _captureBlob(e,t){let i=null,s=null;if("undefined"!=typeof createImageBitmap)try{i=await createImageBitmap(e)}catch(e){}i||(s=await async function(t){return await new Promise((i,s)=>{let n=URL.createObjectURL(t),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 s,o,a=e instanceof HTMLImageElement?e.naturalWidth:e.width,r=e instanceof HTMLImageElement?e.naturalHeight:e.height,c=Math.max(a,r);c>this.maxImageSideLength?(n(xt,this,this.maxImageSideLength/c),s=Math.round(a*i(xt,this)),o=Math.round(r*i(xt,this))):(s=a,o=r),i(At,this)||n(At,this,document.createElement("canvas"));const l=i(At,this);return l.width===s&&l.height===o||(l.width=s,l.height=o),l.ctx2d||(l.ctx2d=l.getContext("2d",{willReadFrequently:!0})),l.ctx2d.drawImage(e,0,0,a,r,0,0,s,o),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:f.IPF_ABGR_8888};return await this._captureInWorker(s,t)}async _captureVideo(e,t){if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";let s,o,a=e.videoWidth,r=e.videoHeight,c=Math.max(a,r);c>this.maxImageSideLength?(n(xt,this,this.maxImageSideLength/c),s=Math.round(a*i(xt,this)),o=Math.round(r*i(xt,this))):(s=a,o=r),i(At,this)||n(At,this,document.createElement("canvas"));const l=i(At,this);return l.width===s&&l.height===o||(l.width=s,l.height=o),l.ctx2d||(l.ctx2d=l.getContext("2d",{willReadFrequently:!0})),l.ctx2d.drawImage(e,0,0,a,r,0,0,s,o),await this._captureCanvas(l,t)}async _captureInWorker(s,o){let{bytes:a,width:r,height:c,stride:l,format:d,imageTag:u}=s;const h=Ue();return await new Promise((_,m)=>{this.provideDsImage=s,Ve[h]=o=>{if(o.success){const r=Date.now();t._onLog&&(t._onLog(`get result time from worker: ${r}`),t._onLog("worker to main time consume: "+(r-o.workerReturnMsgTime)));try{var a;e(Vt,this,jt).call(this,o.capturedResult,s),s.bytes=o.bytes,o._s||n(xt,this,0),e(Vt,this,Zt).call(this,o.intermediateResult,u);const t=Date.now();return t-i(Ft,this)>i(Bt,this)&&null!==o.mliRecord&&(null!==(a=localStorage)&&void 0!==a&&a.setItem("dynamsoft",o.mliRecord),n(Ft,this,t)),_(o.capturedResult)}catch(e){pt({message:e.message,rj:m,stack:e.stack,functionName:"capture"})}}else pt({message:o.message,rj:m,stack:o.stack,functionName:"capture"})},t._onLog&&t._onLog(`send buffer to worker: ${Date.now()}`);const g=s.hasOwnProperty("_s")?s._s:this._s;Pe.postMessage({type:"cvr_capture",id:h,instanceID:this._instanceID,body:{bytes:a,width:r,height:c,stride:l,format:d,templateName:o||"",dynamsoft:this._dynamsoft,_s:g}},[a.buffer])})}async initSettings(e){var i=this;if(mt(this),e&&["string","object"].includes(typeof e))return"string"==typeof e?e.trimStart().startsWith("{")||(e=await U(e,"text")):"object"==typeof e&&(e=JSON.stringify(e)),await new Promise((s,n)=>{const o=Ue();Ve[o]=async function(o){if(o.success){const a=JSON.parse(o.response);if(0!==a.errorCode&&pt({message:a.errorString?a.errorString:"Init Settings Failed.",rj:n,errorCode:a.errorCode,functionName:"initSettings"}))return;const r=JSON.parse(e);return i._isOutputOriginalImage=!!r.CaptureVisionTemplates[0].OutputOriginalImage,t._defaultTemplate=r.CaptureVisionTemplates[0].Name,s(a)}pt({message:o.message,rj:n,stack:o.stack,functionName:"initSettings"})},Pe.postMessage({type:"cvr_initSettings",id:o,instanceID:this._instanceID,body:{settings:e}})});console.error("Invalid template.")}async outputSettings(e,t){return mt(this),await new Promise((i,s)=>{const n=Ue();Ve[n]=async function(e){if(e.success){const t=JSON.parse(e.response);if(0!==t.errorCode&&pt({message:t.errorString,rj:s,errorCode:t.errorCode,functionName:"outputSettings"}))return;return i(JSON.parse(t.data))}pt({message:e.message,rj:s,stack:e.stack,functionName:"outputSettings"})},Pe.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 mt(this),await new Promise((e,t)=>{const i=Ue();Ve[i]=async function(i){if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&pt({message:s.errorString,rj:t,errorCode:s.errorCode,functionName:"getTemplateNames"}))return;return e(JSON.parse(s.data))}pt({message:i.message,rj:t,stack:i.stack,functionName:"getTemplateNames"})},Pe.postMessage({type:"cvr_getTemplateNames",id:i,instanceID:this._instanceID})})}async getSimplifiedSettings(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async function(e){if(e.success){const s=JSON.parse(e.response);if(0!==s.errorCode&&pt({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)}pt({message:e.message,rj:i,stack:e.stack,functionName:"getSimplifiedSettings"})},Pe.postMessage({type:"cvr_getSimplifiedSettings",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async updateSettings(e,t){var i=this;return mt(this),await new Promise((s,n)=>{const o=Ue();Ve[o]=async function(e){if(e.success){const o=JSON.parse(e.response);if(i._isOutputOriginalImage=t.outputOriginalImage,0!==o.errorCode&&pt({message:o.errorString?o.errorString:"Update Settings Failed.",rj:n,errorCode:o.errorCode,functionName:"updateSettings"}))return;return s(o)}pt({message:e.message,rj:n,stack:e.stack,functionName:"updateSettings"})},Pe.postMessage({type:"cvr_updateSettings",id:o,instanceID:this._instanceID,body:{settings:t,templateName:e}})})}async resetSettings(){return mt(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=Ue();Ve[i]=async function(i){if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&pt({message:s.errorString?s.errorString:"Reset Settings Failed.",rj:t,errorCode:s.errorCode,functionName:"resetSettings"}))return;return e(s)}pt({message:i.message,rj:t,stack:i.stack,functionName:"resetSettings"})},Pe.postMessage({type:"cvr_resetSettings",id:i,instanceID:this._instanceID})})}getBufferedItemsManager(){return i(Ot,this)||n(Ot,this,new nt(this)),i(Ot,this)}getIntermediateResultManager(){if(mt(this),!i(kt,this)&&0!==ze.bSupportIRTModule)throw new Error("The current license does not support the use of intermediate results.");return i(bt,this)||n(bt,this,new ct(this)),i(bt,this)}static async setGlobalIntraOpNumThreads(e=0){return e>4||e<0?Promise.reject(new RangeError("'intraOpNumThreads' should be between 0 and 4.")):(await ze.loadWasm(),await new Promise((t,i)=>{const s=Ue();Ve[s]=async function(e){if(e.success)return t();pt({message:e.message,rj:i,stack:e.stack,functionName:"setGlobalIntraOpNumThreads"})},Pe.postMessage({type:"cvr_setGlobalIntraOpNumThreads",id:s,body:{intraOpNumThreads:e}})}))}async checkTemplateNameValidity(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async function(e){return e.success?t(e.isValid):t(!1)},Pe.postMessage({type:"cvr_checkTemplateNameValidity",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async parseRequiredResources(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async function(e){if(e.success)return t(JSON.parse(e.resources));pt({message:e.message,rj:i,stack:e.stack,functionName:"parseRequiredResources"})},Pe.postMessage({type:"cvr_parseRequiredResources",id:s,instanceID:this._instanceID,body:{templateName:e}})})}static disposeCvrWasm(e){t._onLog&&t._onLog(`disposeCvrWasm: ${e}`);const i=Ue();Ve[i]=e=>{e.success||pt({message:e.message,stack:e.stack,isShouldThrow:!0,functionName:"dispose"})},Pe.postMessage({type:"cvr_dispose",id:i,instanceID:e})}dispose(){var e;mt(this),t._onLog&&t._onLog("dispose"),i(Dt,this)&&this.stopCapturing(),n(St,this,null),i(Lt,this).clear(),i(Nt,this).clear(),i(Mt,this).clear(),i(bt,this)._intermediateResultReceiverSet.clear(),n(Ut,this,!0),t.disposeCvrWasm(this._instanceID),null===(e=t._fr4DisposeCvrWasm)||void 0===e||e.unregister(this)}_getInternalData(){return{isa:i(St,this),promiseStartScan:i(Dt,this),intermediateResultManager:i(bt,this),bufferdItemsManager:i(Ot,this),resultReceiverSet:i(Lt,this),isaStateListenerSet:i(Nt,this),resultFilterSet:i(Mt,this),compressRate:i(xt,this),canvas:i(At,this),innerUseTag:i(kt,this),isDestroyed:i(Ut,this)}}async _getWasmFilterState(){return await new Promise((e,t)=>{const i=Ue();Ve[i]=async function(i){if(i.success){const t=JSON.parse(i.response);return e(t)}pt({message:i.message,rj:t,stack:i.stack,functionName:""})},Pe.postMessage({type:"cvr_getWasmFilterState",id:i,instanceID:this._instanceID})})}};function Wt(e){for(let t of i(Lt,this))this._isOutputOriginalImage&&t.onOriginalImageResultReceived&&t.onOriginalImageResultReceived(gt(e))}function jt(e,t){var s,n,o,a,r,c,l,d,u,h,_,m;for(let g=0;g<e.items.length;g++){const p=e.items[g];switch(0!==i(xt,this)&&_t(p,i(xt,this)),p.type){case Ee.CRIT_ORIGINAL_IMAGE:t&&(e.items[g]=gt(t));break;case Ee.CRIT_BARCODE:null!==(n=(s=e.decodedBarcodesResult).barcodeResultItems)&&void 0!==n||(s.barcodeResultItems=[]),e.decodedBarcodesResult.barcodeResultItems.push(p);break;case Ee.CRIT_TEXT_LINE:null!==(a=(o=e.recognizedTextLinesResult).textLineResultItems)&&void 0!==a||(o.textLineResultItems=[]),e.recognizedTextLinesResult.textLineResultItems.push(p);break;case Ee.CRIT_DETECTED_QUAD:null!==(c=(r=e.processedDocumentResult).detectedQuadResultItems)&&void 0!==c||(r.detectedQuadResultItems=[]),e.processedDocumentResult.detectedQuadResultItems.push(p);break;case Ee.CRIT_DESKEWED_IMAGE:Ze.ddn&&Ze.ddn.handleDeskewedAndEnhancedImageResultItem(p),null!==(d=(l=e.processedDocumentResult).deskewedImageResultItems)&&void 0!==d||(l.deskewedImageResultItems=[]),e.processedDocumentResult.deskewedImageResultItems.push(p);break;case Ee.CRIT_ENHANCED_IMAGE:Ze.ddn&&Ze.ddn.handleDeskewedAndEnhancedImageResultItem(p),null!==(h=(u=e.processedDocumentResult).enhancedImageResultItems)&&void 0!==h||(u.enhancedImageResultItems=[]),e.processedDocumentResult.enhancedImageResultItems.push(p);break;case Ee.CRIT_PARSED_RESULT:Ze.dcp&&Ze.dcp.handleParsedResultItem(p),null!==(m=(_=e.parsedResult).parsedResultItems)&&void 0!==m||(_.parsedResultItems=[]),e.parsedResult.parsedResultItems.push(p)}}}function Zt(e,t){const s=e;if(s){let e=0;for(let n of i(bt,this)._intermediateResultReceiverSet){e++;for(let o of s){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===i(bt,this)._intermediateResultReceiverSet.size&&delete o.info.callbackName}}}}function Ht(e){for(let t of i(Lt,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 qt(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async e=>{if(e.success)return t(e.result);pt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Pe.postMessage({type:"cvr_enableResultCrossVerification",id:s,instanceID:this._instanceID,body:{verificationEnabled:e}})})}async function Yt(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async e=>{if(e.success)return t(e.result);pt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Pe.postMessage({type:"cvr_enableResultDeduplication",id:s,instanceID:this._instanceID,body:{duplicateFilterEnabled:e}})})}async function zt(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async e=>{if(e.success)return t(e.result);pt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Pe.postMessage({type:"cvr_setDuplicateForgetTime",id:s,instanceID:this._instanceID,body:{duplicateForgetTime:e}})})}async function $t(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async e=>{if(e.success)return t();pt({message:e.message,rj:i,stack:e.stack,functionName:"setResultCrossVerificationCriteria"})},Pe.postMessage({type:"cvr_setResultCrossVerificationCriteria",id:s,instanceID:this._instanceID,body:{criteria:e}})})}Je=Gt,a(Gt,"_onLog",void 0),a(Gt,"_defaultTemplate","Default"),a(Gt,"_isNoOnnx",!1),a(Gt,"onDataLoadProgressChanged",void 0),a(Gt,"_fr4DisposeCvrWasm","undefined"!=typeof FinalizationRegistry?new FinalizationRegistry(Je.disposeCvrWasm):null);let Kt=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)}},Xt=class{constructor(){a(this,"_observedResultUnitTypes",Ae.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 Qt(e){return e&&"object"==typeof e&&"string"==typeof e.path}var Jt,ei,ti;!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"}(wt||(wt={}));const ii=/<style>([\s\S]*?)<\/style>/g,si=/style="([\s\S]*?)"/g,ni="undefined"!=typeof FinalizationRegistry?new FinalizationRegistry(e=>{URL.revokeObjectURL(e)}):null,oi=(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(ii,(e,s,n,o)=>{let a=s.split("}");const r=a.length-1;let c=[],l=null,d=0;for(let e=0;e<r;++e){let t=0;for(;-1!==(t=a[e].indexOf("{",t));)d+=1,t+=1;if(l)1===d?(c.push(l+a[e]+"}"),l=null,d=0):(l+=a[e]+"}",--d);else{if(d<1)throw new Error("invalid style");1===d?(c.push(a[e].trimStart()+"}"),d=0):(l=a[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(ii,(e,t,i,s)=>(o.push(new Blob([t],{type:"text/css"})),"<HasStyle></HasStyle>")));const a=[];e=e.replace(si,(e,t,i,s)=>(a.push(t),"hasstyle"));const r=document.createElement("div");if(r.insertAdjacentHTML("beforeend",e),r.normalize(),s){const e=r.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!=ni&&ni.register(n,n.href),s.replaceWith(n)}}const c=r.querySelectorAll("[hasstyle]");for(let e=0;e<a.length;e++){const t=a[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 r.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==ni||ni.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(...r.childNodes),1===l.childNodes.length?l.firstChild:l},ai=e=>e&&"object"==typeof e&&"function"==typeof e.then,ri=(async()=>{})().constructor;class ci extends ri{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){var t=this;let i;this._task=e,ai(e)?i=e:"function"==typeof e&&(i=new ri(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(ai(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}const li="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})(),di="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(Jt=window)&&void 0!==Jt&&Jt.MSStream),ui="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent)&&/Firefox/i.test(navigator.userAgent),hi="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 di&&i})(),_i=li?{width:1920,height:1080}:{width:1280,height:720},mi=function(){const e=MediaDeviceInfo.prototype.toJSON.apply(this);return e.trackLabel=this.trackLabel,e.capabilities=this.capabilities,e.isFront=this.isFront,e},gi="The camera feature is available only in secure contexts (HTTPS).";let pi=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",_i),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",!!li||{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(),a=`${t.videoWidth} / ${t.videoHeight}`;a!=i.aspectRatio&&(i.aspectRatio=a),s&&a!=s.aspectRatio&&(s.aspectRatio=a);const r=n/o-t.videoWidth/t.videoHeight;if(Math.abs(r)<.001)return;let c=!1;r>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=oi(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(gi);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=mi):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(mi===n.toJSON)continue;let o=null===(i=e._mapDeviceInfo)||void 0===i?void 0:i[n.deviceId];if(mi===(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=mi}}}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 ci,"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}`)}li&&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(gi);e._delayBeforeGetUserMedia&&await new Promise(t=>setTimeout(t,e._delayBeforeGetUserMedia));let o,a=navigator.mediaDevices.getUserMedia(n);try{o=await(this._getUserMediaTimeout?Promise.race([a,new Promise((e,t)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",t(e)},this._getUserMediaTimeout))]):a)}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."),a=navigator.mediaDevices.getUserMedia({video:this._constraints4Fallback});try{let e=this._getUserMediaTimeout;e>5e3&&(e=5e3),o=await(e?Promise.race([a,new Promise((t,i)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",i(e)},e))]):a)}catch(i){if(console.warn(i),!li||!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{a=navigator.mediaDevices.getUserMedia({video:{deviceId:{exact:e}}}),o=await(n?Promise.race([a,new Promise((e,t)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",t(e)},n))]):a);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(hi&&"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,a;const i=t.deviceId;null!==(n=e._mapDeviceInfo)&&void 0!==n||(e._mapDeviceInfo={}),e._mapDeviceInfo[i]={trackLabel:this.track.label,capabilities:null===(o=(a=this.track).getCapabilities)||void 0===o?void 0:o.call(a),isFront:"user"===this.track.getSettings().facingMode,toJSON:mi}}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 ci,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 r,c;null!==(r=this._video.srcObject)&&void 0!==r&&null!==(c=r.getTracks)&&void 0!==c&&null!==(c=c.call(r))&&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)fi.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=_i),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(c(c({},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(c(c({},this._requestedCamera),s))))}async applyConstraints(e){this.track&&"customized-video"!==this._requestedCamera&&(null!=e||(e={}),await this.track.applyConstraints(c(c(c({},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 a=(null==o?void 0:o.canvas)||document.createElement("canvas");return a.width!=s&&(a.width=s),a.height!=n&&(a.height=n),(o||a.getContext("2d")).drawImage(this._video,t,i,s,n,0,0,s,n),a}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,a=e.center;"string"==typeof e.innerUi&&(e.innerUi=oi(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 r=100*a.y-50*o+50+"%",l=100*a.x+50*n+50+"%",d=100*a.y+50*o+50+"%",u=100*a.x-50*n+50+"%";Object.assign(i.style,{clipPath:`polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, ${u} ${r}, ${u} ${d}, ${l} ${d}, ${l} ${r}, ${u} ${r})`}),"view-min"===e.unit&&(r=`calc(${100*a.y+50}% + max(-${50*o}cqmin, -${50*o}cqmax))`,l=`calc(${100*a.x+50}% + ${50*n}cqmin)`,d=`calc(${100*a.y+50}% + ${50*o}cqmin)`,u=`calc(${100*a.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%, ${u} ${r}, ${u} ${d}, ${l} ${d}, ${l} ${r}, ${u} ${r})`})),Object.assign(i.style,c({},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,c({top:100*a.y+50+"%",left:100*a.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),a=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-a}))}}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),a=parseFloat(t.borderBottomWidth);s.x+=i,s.y+=n,s.width-=i+o,s.height-=n+a}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 a=this._video.videoWidth,r=this._video.videoHeight;let c=(this._isMirrored?1-o.x-o.width:o.x)*a,l=o.y*r,d=o.width*a,u=o.height*r;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(pi,"_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(pi,"_currentOpenedCamera",void 0),a(pi,"_mapDeviceInfo",void 0),a(pi,"_delayBeforeEnumerateDevices",0),a(pi,"_delayBeforeGetUserMedia",ui?1e3:0),a(pi,"_delayBeforeApplyConstraints",0),a(pi,"_countEnsureResolution",ui?20:10),a(pi,"_videoPlayTimeout",li?1e4:3e3),a(pi,"_bReopenWhenChangeResolution",di),a(pi,"_arrConstructors",[]),a(pi,"_arrOnOpen",[]),a(pi,"_arrBeforeClose",[]),a(pi,"_arrOnClose",[]);const fi=["back","front","macro-back","quick-back","customized-video"];pi.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:a,step:r,max:c}=o||{};null!=a&&n<a?n=a:null!=c&&n>c&&(n=c),null!=r&&null!=a&&(n=a+Math.round((n-a)/r)*r,c&&n>c&&(n-=r)),e[t]=n}}return e},pi._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(pi.prototype,"softZoom",{get(){return this._softZoom}}),Object.defineProperty(pi.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(pi.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(pi.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)}}),pi.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},pi.prototype.setZoom=async function(e){const t=this;if("opened"!==t.status)throw Error("Camera not open");pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await t.applyConstraints(t.correctAdvancedConstraint(t.correctAdvancedConstraint({advanced:[{zoom:e}]})))},pi.prototype.setSoftZoom=function(e,t){const i=this;let{center:s,limit:n}=t||{},{x:o=0,y:a=0}=s||{};n&&e<1&&(e=1);let r=i._isMirrored?`scale(${-e},${e})`:`scale(${e})`;if(s){if(n){const t=.5-.5/e;o<-t?o=-t:o>t&&(o=t),a<-t?a=-t:a>t&&(a=t)}r+=` translate(${o*=-100}%, ${a*=-100}%)`}i._softZoom={zoom:e,center:{x:o,y:a}},i._coreInnerLayer.style.transform=r},pi.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)}}))},pi.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],a=t._mapZoomTouchs.get(n.identifier),r=t._mapZoomTouchs.get(o.identifier);if(!a||!r)break;let c=Math.pow(Math.pow(a.x-r.x,2)+Math.pow(a.y-r.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})},pi._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"}),pi._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),a=o+4,r=o+4*t,c=e[o]-e[a],l=e[o+1]-e[a+1],d=e[o+2]-e[a+2],u=e[o]-e[r],h=e[o+1]-e[r+1],_=e[o+2]-e[r+2];s+=c*c+l*l+d*d+u*u+h*h+_*_}return s},pi.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 a=null===(e=o.currentCamera)||void 0===e?void 0:e.capabilities;let r,c;if(null!=a&&null!==(t=a.focusMode)&&void 0!==t&&t.includes("manual"))if(null!=a&&null!==(i=a.focusMode)&&void 0!==i&&i.includes("continuous"))r="manual",c="continuous";else{var l;if(null==a||null===(l=a.focusMode)||void 0===l||!l.includes("single-shot"))return void o._advancedFocus();r="manual",c="single-shot"}else if(null!=a&&null!==(s=a.focusMode)&&void 0!==s&&s.includes("single-shot"))null!=a&&null!==(n=a.focusMode)&&void 0!==n&&n.includes("continuous")?(r="continuous",c="single-shot"):(r=null,c="single-shot");else{var d;if(null==a||null===(d=a.focusMode)||void 0===d||!d.includes("continuous"))return;r=null,c="continuous"}o._isFocusing=!0;try{var u;r&&("manual"===r?(pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await o.applyConstraints(o.correctAdvancedConstraint({advanced:[{focusMode:"manual",focusDistance:(null==a||null===(u=a.focusDistance)||void 0===u?void 0:u.max)||10}]}))):(pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await o.applyConstraints({advanced:[{focusMode:r}]})),await new Promise(e=>setTimeout(e,500))),pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await o.applyConstraints({advanced:[{focusMode:c}]}),await new Promise(e=>setTimeout(e,500))}catch(a){"opened"===o.status&&console.warn("Error while do simple focus",a)}o._isFocusing=!1},pi.prototype._advancedFocus=async function(e,t,i){var s,n,o,a;const r=this;if("opened"!==r.status)throw Error("Camera not open");if(r._isFocusing)return;const c=null===(s=r.currentCamera)||void 0===s?void 0:s.capabilities;if(null==c||null===(n=c.focusMode)||void 0===n||!n.includes("manual"))return void r._simpleFocus();const l=r._advancedFocusParameters,d=r._video.videoWidth,u=r._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),r._isFocusing=!0;const m=++r._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===(a=c.focusDistance)||void 0===a?void 0:a.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;pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await r.applyConstraints(r.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)),r.getFrame({x:h,y:_,width:t,height:i,reusedContext:C});const s=C.getImageData(0,0,t,i).data,n=pi._getImageContrast(s,t,i);if(v){if(n<=f){pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await r.applyConstraints(r.correctAdvancedConstraint({advanced:[{focusMode:"manual",bestFocusDistance:y}]})),pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await r.applyConstraints(r.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"===r.status&&console.warn("Error while do advanced focus",e)}r._isFocusing=!1,l.backToContinousDuration>0&&setTimeout(async()=>{if(r._advancedFocusTaskId===m){pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints));try{await r.applyConstraints({advanced:[{focusMode:"continuous"}]})}catch(e){}}},l.backToContinousDuration)},Object.defineProperty(pi.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)}}),pi._arrConstructors.push(function(){this._isTorchOn=!1,this._autoTorchParameters={shortDelay:250,longDelay:1e3,shortLongDelaySwitchCount:10,grayThreshold:20,maxDarkCount:3}}),pi._arrOnClose.push(function(){this._isTorchOn=!1}),Object.defineProperty(pi.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(pi.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}}),pi.prototype.turnOnTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints));try{await e.applyConstraints({advanced:[{torch:!0}]})}catch(t){throw e._isTorchOn=!1,t}e._isTorchOn=!0},pi.prototype.turnOffTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await e.applyConstraints({advanced:[{torch:!1}]}),e._isTorchOn=!1},pi.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 r=s.getImageData(0,0,i.width,i.height).data;let c=0;for(let e=0;e<r.length;e+=4)c+=r[e]+r[e+1]+r[e+2];if(c/=r.length/4*3,c<t.grayThreshold&&++n>=t.maxDarkCount){try{var a;await e.turnOnTorch(),null===(a=e._eventListeners.torchAutoOn)||void 0===a||a.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 Ei="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(ei=window)&&void 0!==ei&&ei.MSStream),yi="undefined"!=typeof navigator&&/MiuiBrowser/.test(navigator.userAgent),Ii="undefined"!=typeof navigator&&/SamsungBrowser/.test(navigator.userAgent);let vi,Ri;pi._arrConstructors.push(function(){this._shouldCloseWhenHide=!0,this._maxReopenTry4CloseWhenHide=4}),pi._arrOnOpen.push(function(){this._bindCloseWhenHide()}),pi._arrBeforeClose.push(function(){this._isDuringCloseWhenHide||this._unbindCloseWhenHide()}),Object.defineProperty(pi.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())}}),pi.prototype._closeWhenHide=async function(){var e;const t=this;if("hidden"===document.visibilityState)("opened"===t.status||"paused"===t.status&&!t._paused&&(Ei&&"live"===(null===(e=t.track)||void 0===e?void 0:e.readyState)||yi&&"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}}},pi.prototype._bindCloseWhenHide=function(){const e=this;e._shouldCloseWhenHide&&(e._closeWhenHideListener||(e._closeWhenHideListener=()=>{e._closeWhenHide()},document.addEventListener("visibilitychange",e._closeWhenHideListener),Ii&&window.addEventListener("blur",e._closeWhenHideListener)))},pi.prototype._unbindCloseWhenHide=function(){const e=this;e._closeWhenHideListener&&(document.removeEventListener("visibilitychange",e._closeWhenHideListener),Ii&&window.removeEventListener("blur",e._closeWhenHideListener),e._closeWhenHideListener=null,e._isOpenBeforeHide=!1)},pi._id4CloseWhenNotInDOM=0,pi._stMSBNotInDOMCamera=new Set,pi._arrConstructors.push(function(){this._id4CloseWhenNotInDOM=++pi._id4CloseWhenNotInDOM,this._shouldCloseWhenNotInDOM=!0,this._bClosedBecauseOfNotInDOM=!1}),pi.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 pi._stMSBNotInDOMCamera.delete(this);let t;if(this._video.isConnected){pi._stMSBNotInDOMCamera.delete(this);for(let e of pi._stMSBNotInDOMCamera)e._id4CloseWhenNotInDOM<this._id4CloseWhenNotInDOM&&(e.close(),e._bClosedBecauseOfNotInDOM=!0,pi._stMSBNotInDOMCamera.delete(e));t=new MutationObserver(()=>{this._video.isConnected||(t.disconnect(),this.close(),this._bClosedBecauseOfNotInDOM=!0)})}else pi._stMSBNotInDOMCamera.add(this),t=new MutationObserver(()=>{this._video.isConnected&&this._updateMo4CloseWhenNotInDOM()});this._mo4CloseWhenNotInDOM=t,t.observe(document.body,{childList:!0,subtree:!0})},pi._arrOnOpen.push(function(){this._updateMo4CloseWhenNotInDOM(),this._bClosedBecauseOfNotInDOM=!1}),pi._arrBeforeClose.push(function(){this._updateMo4CloseWhenNotInDOM()}),Object.defineProperty(pi.prototype,"shouldCloseWhenNotInDOM",{get(){return this._shouldCloseWhenNotInDOM},set(e){this._shouldCloseWhenNotInDOM=!!e,this._updateMo4CloseWhenNotInDOM()}}),pi.showFilePicker=async function(e){var t;null===(t=vi)||void 0===t||t.remove();const i=vi=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},pi.filePicker2CanvasMaxWH=4096,pi.showFilePicker2Canvas=async function(e){var t;let i=pi.filePicker2CanvasMaxWH;(null===(t=e)||void 0===t?void 0:t.canvasMaxWH)&&(i=e.canvasMaxWH,delete(e=c({},e)).canvasMaxWH);let s=await pi.showFilePicker(e),n=[];for(let e of s){const t=document.createElement("canvas"),s=t.getContext("2d"),o=URL.createObjectURL(e),a=new Image;a.src=o,await a.decode(),a.naturalWidth<i&&a.naturalHeight<i?(t.width=a.width,t.height=a.height,s.drawImage(a,0,0)):(a.naturalWidth/a.naturalHeight>1?(t.width=i,t.height=Math.round(a.naturalHeight/a.naturalWidth*i)):(t.height=i,t.width=Math.round(a.naturalWidth/a.naturalHeight*i)),s.drawImage(a,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 a=t!==this._x||i!==this._y||s!==this._w||n!==this._h||o!==this._type;let r;return a&&(this._x=t,this._y=i,this._w=s,this._h=n,this._type=o),!a&&this._dataTime+this.maxTimeout>Date.now()&&this._data?(r=this._data,this._data=null):r=this._getData(),this._pipeTaskId||(this._pipeTaskId=setTimeout(()=>{this._pipeTaskId=null,this._data=this._getData(),this._dataTime=Date.now()},0)),r}},Ti=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 wi=()=>{(null!=Ri?Ri:Ri=new Ti).beep()},Si=(e=300)=>{var t;if(null===(t=navigator)||void 0===t||!t.vibrate)throw new Error("Not supported.");navigator.vibrate(e)},Ai={getVersion:()=>"5.0.0-dev-2026080315080"},Di=pi,bi=pi;if(null!==(ti=document)&&void 0!==ti&&ti.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 Oi={x:0,y:0,width:100,height:100,isMeasuredInPercentage:!0};Di.createInstance=async function(e){let t;if(e instanceof pi?(t=e,e=void 0):t=new pi,void 0===t.disposed){if(t.isCameraEnhancer=!0,t.disposed=!1,t._cameraEnhancer=t._cameraView=t,t._framePipeline=new Ci(t),t._dceScanRegion=Oi,t._dceEventListeners={},t._bAutoSingleFrameModeWhenIosPwaFail=!0,t._oriOpen=t.open,t.open=Li,t._oriUpdateCanvasSize=t._updateCanvasSize,t._updateCanvasSize=Mi,t._oriAddCanvas=t.addCanvas,t.addCanvas=Bi,t._dceZoom=1,t._dceEnhancedFeatures=0,t._dceAutoZoomRange={min:1,max:10},t._oriSetZoom=t.setZoom,t.setZoom=Fi,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=bi.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:ts.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,a=t._dceLastDeviceId;o!==a&&(t._dceLastDeviceId=o,null===(n=this._dceEventListeners.cameraChange)||void 0===n||n.forEach(e=>{try{e.call(this,o,a)}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 Xi)return e.quad.points;if(e instanceof Qi||e instanceof Ji||e instanceof es){let{x:t,y:i,width:s,height:n}=e.rect,o=t+s,a=i+n;return[{x:t,y:i},{x:t,y:a},{x:o,y:a},{x:o,y:i}]}return e instanceof Ki?[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 r=s[t],c=!1;if(r instanceof Xi||r instanceof Qi||r instanceof Ji||r instanceof es?(c=Yi(i,[n[o-4],n[o-3],n[o-2],n[o-1]]),o-=4):r instanceof Ki&&(c=Yi(i,[n[o-2],n[o-1]]),o-=2),c){var a;e.targetItem=r,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===(a=r._dceEventListeners[e.type])||void 0===a||a.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},Di.defaultUIElementURL="@engineResourcePath/ui/dce.ui.xml",Object.defineProperty(Di.prototype,"cameraOpenTimeout",{get(){return this._getUserMediaTimeout},set(e){this._getUserMediaTimeout=e}});const Li=async function(){var e,t,i,s,n;const o=this;if("disabled"!==o.singleFrameMode){var a;let e=await Ni("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 xi(this.bytes,this.width,this.height,this.format)},imageTag:{imageId:++Pi,type:0}}}}const t=o.ui.querySelector(".dce-bg-camera");"closed"!==o.status&&await o.close(),t&&(t.style.opacity="0");{var r;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===(r=o._singleFrameModeUIAutoFitRO)||void 0===r||r.observe(o._coreShell)}return o._singleFrameModeResultForDcv=e,void(null===(a=o._dceEventListeners.singleFrameAcquired)||void 0===a||a.forEach(t=>{try{t.call(this,e)}catch(t){console.error(t)}}))}o.videoSrc&&(o.video.src=o._dceVideoSrc);const l=o.ui.querySelector(".dce-bg-loading");l&&(l.style.display="");try{await o._oriOpen()}catch(e){var d,u,h;if(Di.onWarning&&Di.onWarning(null==e?void 0:e.message),o._bAutoSingleFrameModeWhenIosPwaFail&&null!=e&&null!==(d=e.message)&&void 0!==d&&d.includes("iOS PWA"))return console.warn(e.message),l&&(l.style.display="none"),console.warn("Auto switch to `singleFrameMode = 'camera'`."),o.singleFrameMode="camera",void(null===(u=o.funcShowToast)||void 0===u||u.call(o,"Click to Capture",8e3));throw l&&(l.style.display="none"),null!==(h=o.funcShowToast)&&void 0!==h&&h.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))),l&&(l.style.display="none"),await new Promise(e=>setTimeout(e,0)),c({deviceId:null===(n=o.currentCamera)||void 0===n?void 0:n.deviceId},o.currentResolution)},Ni=async function(e){const t={multiple:!1};e&&(t.capture="environment");const i=(await pi.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:++Pi,type:0}}},Mi=function(){"disabled"===this.singleFrameMode&&this._oriUpdateCanvasSize()},Bi=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};Di.prototype.dispose=function(){this.disposed=!0,this.close(),this.setScanLaserVisible(!1)},Di.prototype.getAllCameras=async function(){return(await pi.getDeviceInfos()).map(e=>({deviceId:e.deviceId,label:e.label||e.trackLabel}))},Di.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,a,r,c;await e.requestResolution(i),((null===(o=e.currentResolution)||void 0===o?void 0:o.width)===i[0]&&(null===(a=e.currentResolution)||void 0===a?void 0:a.height)===i[1]||(null===(r=e.currentResolution)||void 0===r?void 0:r.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},Di.prototype.getCameraState=function(){let e=this.status;return"closing"===e||"paused"===e||"closed"===e?"closed":"opened"===e?"open":"opening"===e?"opening":void 0},Di.prototype.getResolution=function(){return"opened"===this.status?this.currentResolution:this.requestedResolution},Di.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},Di.prototype.getVideoSettings=function(){let e={};return"object"==typeof this.requestedCamera&&Object.assign(e,this.requestedCamera),Object.assign(e,this.requestedResolution),{video:e}},Object.defineProperty(Di.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(Di.prototype,"ifSkipCameraInspection",{get(){return"quick-back"===this.requestedCamera},set(e){e?this.requestCamera("quick-back"):this.requestCamera("back")}}),Di.prototype.isOpen=function(){return"opened"===this.status},Di.prototype.isPaused=function(){return"paused"===this.status},Di.prototype.resume=async function(){await this._oriOpen()},Di.prototype.selectCamera=async function(e){var t;return await this.requestCamera("string"==typeof e?e:e.deviceId),c({deviceId:null===(t=this.currentCamera)||void 0===t?void 0:t.deviceId},this.currentResolution)},Di.prototype.setResolution=async function(e){var t;return await this.requestResolution(e),c({deviceId:null===(t=this.currentCamera)||void 0===t?void 0:t.deviceId},this.currentResolution)},Di.testCameraAccess=async function(){let e=!0,t="Successfully accessed the camera.";try{await pi.getDeviceInfos()}catch(i){e=!1,t=i.message||i}return{ok:e,message:t}},Di.prototype.updateVideoSettings=async function(e){const t="object"!=typeof e?null:null==e?void 0:e.video;await this.requestCamera(t)},Object.defineProperty(Di.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))}}),Di.prototype.disableEnhancedFeatures=function(e){this._dceEnhancedFeatures=this._dceEnhancedFeatures-(this._dceEnhancedFeatures&e)},Di.prototype.enableEnhancedFeatures=function(e){this._dceEnhancedFeatures|=e},Di.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},Di.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},Di.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},Di.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},Di.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},Di.prototype.setColorTemperature=async function(e){var t;const i=this;i.getColorTemperature(),pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{colorTemperature:e,whiteBalanceMode:"manual"}]})))},Di.prototype.setExposureCompensation=async function(e){var t;const i=this;i.getExposureCompensation(),pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{exposureCompensation:e}]})))},Di.prototype.setFrameRate=async function(e){var t;const i=this;i.getFrameRate(),pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{frameRate:e}]})))},Di.prototype.getZoomSettings=function(){return{factor:this._dceZoom}};const Fi=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 xi(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 a=new Uint8ClampedArray(e),r=new ImageData(a,t,i);return o.putImageData(r,0,0),n}Di.prototype.resetZoom=async function(){this._dceZoom=1,this.setSoftZoom(1,{center:{x:0,y:0}});try{await this._oriSetZoom(1)}catch(e){}},Di.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},Di.prototype.setFocus=async function(e){const t=this;if(!t.track)throw Error("Camera not open");if(t._dceFocusSettings=e,"manual"!==e.mode)pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await t.applyConstraints({advanced:[{focusMode:e.mode}]});else if(e.distance)pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._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,a=t.currentResolution.width,r=t.currentResolution.height;"string"==typeof i&&(i=i.endsWith("%")?parseFloat(i)*a:parseFloat(i)),"string"==typeof s&&(s=s.endsWith("%")?parseFloat(s)*r:parseFloat(s)),"string"==typeof n&&(n=n.endsWith("%")?parseFloat(n)*a:parseFloat(n)),"string"==typeof o&&(o=o.endsWith("%")?parseFloat(o)*r:parseFloat(o)),await t._advancedFocus({x:i,y:s},n,o)}},Di.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)},Di.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},Di.prototype.toggleMirroring=function(e){this.isMirrored=e};let Pi=0;Di.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:++Pi,type:1}}},Di.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(c(c({},i),{},{type:s}));if(!n)return null;let{width:o,height:a}=i,r="rgba"===s?10:2;const l={bytes:n,width:o,height:a,stride:i.width*("rgba"===s?4:1),format:r,toCanvas:function(){return xi(this.bytes,this.width,this.height,this.format)},imageTag:{imageId:++Pi,type:1}};return null!==(e=this._dceEventListeners.frameAddedToBuffer)&&void 0!==e&&e.forEach(e=>{try{e.call(this,l)}catch(e){console.error(e)}}),l},Di.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 Ni(!0);return i&&await t._oriOpen(),null!=e&&e(s),s},Object.defineProperty(Di.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:c({},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"))}}),Di.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 a=s/n-t.width/t.height,r=.001;if(Math.abs(a)>r){let t=!1;a>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"))}}},Di.prototype.getScanRegion=function(){return this._dceScanRegion},Di.prototype.hasNextImageToFetch=function(){return"opened"===this.status},Di.prototype.isBufferEmpty=function(){return"opened"!==this.status},Di.prototype.getPixelFormat=function(){return this._pixelFormat},Di.prototype.setPixelFormat=function(e){2===e?(this._pixelFormat=2,this._colourChannelUsageType=2):(this._pixelFormat=10,this._colourChannelUsageType=1)},Di.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}},Di.prototype.getColourChannelUsageType=function(){return this._colourChannelUsageType},Di.prototype.setScanRegion=function(e){this._dceScanRegion=null!=e?e:e=Oi;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}`:""}})}}},Di.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)},Di.prototype.getCameraView=function(){return this},Di.prototype.getVideoEl=function(){return this.video},Di.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]},Di.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]},Di.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)}},Di.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 a=t.video.videoWidth,r=t.video.videoHeight;let c=t.videoXY2AbsoluteLT([{x:0,y:0},{x:a,y:r}]);return{x:(e.x+n-i)/a*(c[1].left-c[0].left),y:(e.y+o-s)/r*(c[1].top-c[0].top)}},Di.prototype.on=function(e,t){var i,s;(null!==(s=(i=this._dceEventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)},Di.prototype.off=function(e,t){var i;null===(i=this._dceEventListeners[e])||void 0===i||i.delete(t)},bi.prototype.getUIElement=function(){return this.ui},bi.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(bi.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=Di.handleEngineResourcePaths(Di.CoreModule.engineResourcePaths);i=i.replace("@engineResourcePath/","DBR"===Di.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=oi(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 pi.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 a=e.querySelector(".dm-camera-mn-toast,.dce-mn-toast");if(!a&&o){a=document.createElement("div"),a.classList.add("dm-camera-mn-toast"),Object.assign(a.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(a);let e=null;t.funcShowToast=(t,i=3e3)=>{a&&(a.textContent=t,a.style.display="",null!=e&&(clearTimeout(e),e=null),i&&(e=setTimeout(()=>{a.style.display="none",e=null},i)))}}const r=e.querySelector(".dce-macro-use-mobile-native-like-ui");if(r&&!r._dce_binded){const e=r;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 a=e.querySelector(".dce-mn-beep-on"),c=e.querySelector(".dce-mn-beep-off");a&&(a.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(r.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 pi.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 pi.hasFrontCamera()&&p&&(p.style.display="")}}),t.addEventListener("closed",()=>{t.disposed||(r.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!=a&&a.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!1,a.style.display="none",c.style.display="")}),null!=c&&c.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!0,c.style.display="none",a.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},bi.prototype.getVideoElement=function(){return this.video},bi.prototype.setVideoFit=function(e){this.objectFit=e},bi.prototype.getVideoFit=function(){return this.objectFit},bi.prototype.getVisibleRegionOfVideo=function(e){const t=this;let{inPixels:i}=e||{inPixels:!1};const s=t.getVisibleAreaInVideoXY();if(i)return c(c({},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}}},bi.prototype.setScanRegionMaskStyle=function(e){const t=this._dceRegionMaskVisible;this._dceRegionMaskStyle=c({},e),this.setRegionBox({maskStyle:{background:t?e.fillStyle:""},borderStyle:{border:t?`${e.lineWidth}px solid ${e.strokeStyle}`:""}})},bi.prototype.getScanRegionMaskStyle=function(){return this._dceRegionMaskStyle},bi.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}`:""}})},bi.prototype.isScanRegionMaskVisible=function(){return this._dceRegionMaskVisible},bi.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)},bi.prototype.isScanLaserVisible=function(){var e;return!(null===(e=this.regionBox)||void 0===e||!e.innerUi)&&"none"!==this.regionBox.innerUi.style.display},bi.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")},bi.prototype.isPowerByMessageVisible=function(){let e=this.ui.querySelector(".dce-msg-poweredby,.dm-camera-mn-msg-poweredby");return e&&"none"!==e.style.display},bi.prototype.getTipConfig=function(){return{duration:this._dceTipDuration}},bi.prototype.setTipConfig=function(e){this._dceTipDuration=e.duration},bi.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")}},bi.prototype.isTipVisible=function(){const e=this.ui.querySelector(".dm-camera-mn-toast");return!!e&&"none"!=e.style.display},bi.prototype.updateTipMessage=function(e){var t;this._dceTipMessage=e,null===(t=this.funcShowToast)||void 0===t||t.call(this,this._dceTipMessage,this._dceTipDuration)},bi.prototype.createDrawingLayer=function(){const e=new qi;return e._dce=this,e._ctx=this.addCanvas().getContext("2d"),this._drawingLayers.push(e),e},bi.prototype.getDrawingLayer=function(e){if(e instanceof qi)return e;if("number"!=typeof e)return null;let t=this._drawingLayers[e];return t||1!==e&&2!==e&&3!==e||(t=new qi,t._dce=this,t._ctx=this.addCanvas().getContext("2d"),this._drawingLayers[e]=t,1===e?t._defaultStyle=Hi.STYLE_BLUE_STROKE:2===e?t._defaultStyle=Hi.STYLE_ORANGE_STROKE_FILL:3===e&&(t._defaultStyle=Hi.STYLE_GREEN_STROKE_FILL)),t},bi.prototype.getAllDrawingLayers=function(){for(let e=1;e<=3;e++)this.getDrawingLayer(e);return this._drawingLayers.filter(e=>e)},bi.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},bi.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])},bi.prototype.clearAllInnerDrawingItems=function(e){for(let t of this._drawingLayers.slice(1,4))!t||e&&"editor"===t._mode||t.clearDrawingItems()};let ki=class{static beep(){null!=this._beepInstance?this._beepInstance.beep():wi()}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 Ti),this._beepInstance.beepSoundSource=e}static vibrate(){null!=this.vibrateDuration?Si(this.vibrateDuration):Si()}};a(ki,"_beepInstance",void 0),a(ki,"vibrateDuration",void 0);const Ui="73,245,73",Vi="73,173,245",Gi="254,180,32",Wi="245,236,73",ji=(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},Zi=[null,ji(Vi),ji(Ui),ji(Gi),ji(Wi),ji(Vi,"f"),ji(Ui,"f"),ji(Gi,"f"),ji(Wi,"f"),ji(Vi,"t"),ji(Ui,"t"),ji(Gi,"t"),ji(Wi,"t")],Hi={STYLE_BLUE_STROKE:Zi[1],STYLE_GREEN_STROKE:Zi[2],STYLE_ORANGE_STROKE:Zi[3],STYLE_YELLOW_STROKE:Zi[4],STYLE_BLUE_STROKE_FILL:Zi[5],STYLE_GREEN_STROKE_FILL:Zi[6],STYLE_ORANGE_STROKE_FILL:Zi[7],STYLE_YELLOW_STROKE_FILL:Zi[8],STYLE_BLUE_STROKE_TRANSPARENT:Zi[9],STYLE_GREEN_STROKE_TRANSPARENT:Zi[10],STYLE_ORANGE_STROKE_TRANSPARENT:Zi[11],STYLE_YELLOW_STROKE_TRANSPARENT:Zi[12],createDrawingStyle(e){let t=Object.assign({},this.STYLE_YELLOW_STROKE_FILL,e);return Object.assign(e,t),e},getDrawingStyle:e=>"number"==typeof e?Zi[e]:e,getAllDrawingStyles:()=>Zi.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 qi=class{constructor(){a(this,"_visible",!0),a(this,"_dce",void 0),a(this,"_ctx",void 0),a(this,"_defaultStyle",Hi.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=Hi.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=Hi.getDrawingStyle(e.drawingStyleId||this._defaultStyle);if(t.fillStyle=i.fillStyle,t.strokeStyle=i.strokeStyle,t.lineWidth=i.lineWidth*n,t.setLineDash([]),e instanceof Ji){const o=e.text.split("\n"),{x:a,y:r,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=a+s.x;for(let e=0;e<o.length;++e){const i=r+l/o.length*e+s.y;t.fillText(o[e],u,i,c),t.strokeText(o[e],u,i,c)}continue}if(e instanceof es){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:a,y:r,width:c,height:l}=e.rect;e.maintainAspectRatio&&(l=c/n*o),t.drawImage(i,a+s.x,r+s.y,c,l);continue}if(e._bSelected&&(t.strokeStyle="#0f0",t.lineWidth=2*n,t.setLineDash([4,4])),t.beginPath(),e instanceof Xi){const i=e.quad.points;t.moveTo(i[0].x+s.x,i[0].y+s.y),t.lineTo(i[1].x+s.x,i[1].y+s.y),t.lineTo(i[2].x+s.x,i[2].y+s.y),t.lineTo(i[3].x+s.x,i[3].y+s.y)}else if(e instanceof Ki){const i=e.line.startPoint,n=e.line.endPoint;t.moveTo(i.x+s.x,i.y+s.y),t.lineTo(n.x+s.x,n.y+s.y)}else if(e instanceof Qi){const{x:i,y:n,width:o,height:a}=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+a+s.y),t.lineTo(i+s.x,n+a+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 Yi(e,t){const[i,s]=e;let n=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const[a,r]=t[e],[c,l]=t[o];if(i===a&&s===r||i===c&&s===l)return!0;if((i<=a&&i>=c||i>=a&&i<=c)&&(s<=r&&s>=l||s>=r&&s<=l)&&(i-a)*(s-r)===(i-c)*(s-l))return!0;r>s!=l>s&&i<(c-a)*(s-r)/(l-r)+a&&(n=!n)}return n}function zi(e,t){const[i,s]=e,[[n,o],[a,r]]=t,c=a-n,l=r-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+_*_)}let $i=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?ss.DIS_SELECTED:ss.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=c(c({},s.content),{},{content:t}):i&&s.content&&t&&"string"==typeof s.content&&"string"==typeof t?s.content+=","+t:s.content=t)}deleteNote(e){this._notes=this._notes.filter(t=>t.name!==e)}clearNotes(){this._notes=[]}_delayRenderAll(){var e;null===(e=this.drawingLayerId)||void 0===e||e._delayRenderAll()}_setSelected(e){if(e===this._bSelected)return;this._bSelected=e,this._delayRenderAll();let t=this.drawingLayerId;t&&(e?t._newSelectedDrawingItems.push(this):t._newDeselectedDrawingItems.push(this),t._delaySelectionChanged())}on(e,t){var i,s;(null!==(s=(i=this._dceEventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)}off(e,t){var i;null===(i=this._dceEventListeners[e])||void 0===i||i.delete(t)}},Ki=class extends $i{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=is.DIMT_LINE,this.line=e,this.drawingStyleId=t}getLine(){return this.line}setLine(e){this.line=e,this._delayRenderAll()}},Xi=class extends $i{get _ps(){return this.quad.points}constructor(e,t){super(),a(this,"quad",void 0),this.mediaType=is.DIMT_QUADRILATERAL,this.quad=e,this.drawingStyleId=t}getQuad(){return this.quad}setQuad(e){this.quad=e,this._delayRenderAll()}},Qi=class extends $i{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=is.DIMT_RECTANGLE,this.rect=e,this.drawingStyleId=t}getRect(){return this.rect}setRect(e){this.rect=e,this._delayRenderAll()}},Ji=class extends $i{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=is.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()}},es=class extends $i{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=is.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=xi(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 ts=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=Hi.STYLE_ORANGE_STROKE_TRANSPARENT:(i._dceMNIsBeepBarcode&&wi(),i._dceMNIsVibrateBarcode&&Si());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=Hi.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=Hi.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=Hi.STYLE_BLUE_STROKE_TRANSPARENT);break;default:continue}s.addDrawingItems([new Xi({points:n},o)])}};var is,ss,ns,os;!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"}(is||(is={})),function(e){e[e.DIS_DEFAULT=1]="DIS_DEFAULT",e[e.DIS_SELECTED=2]="DIS_SELECTED"}(ss||(ss={})),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"}(ns||(ns={})),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"}(os||(os={}));const as="undefined"==typeof self,rs=as?{}:self,cs="function"==typeof importScripts,ls=(()=>{if(!cs){if(!as&&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"./"}})(),ds=e=>e&&"object"==typeof e&&"function"==typeof e.then,us=(async()=>{})().constructor;let hs=class extends us{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){var t=this;let i;this._task=e,ds(e)?i=e:"function"==typeof e&&(i=new us(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(ds(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};const _s=" is not allowed to change after `createInstance` or `loadWasm` is called.",ms=!as&&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"))||"",gs=(e,t)=>{const i=e;if(i._license!==t){if(!i._pLoad.isEmpty)throw new Error("`license`"+_s);i._license=t}};!as&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword");const ps=e=>{if(null==e)e=[];else{e=e instanceof Array?[...e]:[e];for(let t=0;t<e.length;++t){if(!as){let i=document.createElement("a");i.href=e[t],e[t]=i.href}e[t].endsWith("/")||(e[t]+="/")}}return e},fs=(e,t)=>{t=ps(t);const i=e;if(i._licenseServer!==t){if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+_s);i._licenseServer=t}},Es=(e,t)=>{t=t||"";const i=e;if(i._deviceFriendlyName!==t){if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+_s);i._deviceFriendlyName=t}};let ys,Is,vs,Rs,Cs;"undefined"!=typeof navigator&&(ys=navigator,Is=ys.userAgent,vs=ys.platform,Rs=ys.mediaDevices),function(){if(!as){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:ys.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:vs,search:"Win"},Mac:{str:vs},Linux:{str:vs}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let o=n.str||Is,a=n.search||t,r=n.verStr||Is,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=o.indexOf(a)){i=t;for(let e of c){let t=r.indexOf(e);if(-1!=t){s=parseFloat(r.substring(t+e.length+1));break}}break}}for(let e in t){const i=t[e]||{};let s=i.str||Is,o=i.search||e;if(-1!=s.indexOf(o)){n=e;break}}"Linux"==n&&-1!=Is.indexOf("Windows NT")&&(n="HarmonyOS"),Cs={browser:i,version:s,OS:n}}as&&(Cs={browser:"ssr",version:0,OS:"ssr"})}(),Rs&&Rs.getUserMedia,"Chrome"===Cs.browser&&Cs.version>66||"Safari"===Cs.browser&&Cs.version>13||"OPR"===Cs.browser&&Cs.version>43||"Edge"===Cs.browser&&Cs.version;const Ts=new hs,ws=async()=>(Ts.isEmpty&&(Ts.task=async(e,t)=>{await ze.loadWasm();let{lt:i,l:s,ls:n,sp:o,rmk:a,cv:r}=((e,t=!1)=>{const i=As;if(i._pLoad.isEmpty){let s,n,o,a=i._license||"",r=JSON.parse(JSON.stringify(i._licenseServer)),c=i._sessionPassword,l=0;if(a.startsWith("t")||a.startsWith("f"))l=0;else if(0===a.length||a.startsWith("P")||a.startsWith("L")||a.startsWith("Y")||a.startsWith("A"))l=1;else{l=2;const t=a.indexOf(":");-1!=t&&(a=a.substring(t+1));const i=a.indexOf("?");if(-1!=i&&(n=a.substring(i+1),a=a.substring(0,i)),a.startsWith("DLC2"))l=0;else{if(a.startsWith("DLS2")){let t;try{let e=a.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(a=t.handshakeCode?t.handshakeCode:t.organizationID?t.organizationID:"","number"==typeof a&&(a=JSON.stringify(a)),0===r.length){let e=[];t.mainServerURL&&(e[0]=t.mainServerURL),t.standbyServerURL&&(e[1]=t.standbyServerURL),r=ps(e)}!c&&t.sessionPassword&&(c=t.sessionPassword),s=t.remark}a&&"200001"!==a&&!a.startsWith("200001-")||(l=1)}}if(l&&(t||(rs.crypto||(o="Please upgrade your browser to support online key."),rs.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:a,ls:r,sp:c,rmk:s,cv:n}}throw new Error("Can't preprocess license again"+_s)})();const c="undefined"!=typeof self?self:{};let l;As._pLoad.task=Ts,(async()=>{try{await As._pLoad}catch(e){}})(),i&&(c.dyarm||(c.dyarm={}),c.dyarm[s]?l=(await c.dyarm[s]).ar:c.dyarm[s]=(async()=>(await Ts,c.dyarm[s]=await Ss(),c.dyarm[s]))());let d=Ue();Ve[d]=s=>{var n;if(s.message&&As._onAuthMessage){let e=As._onAuthMessage(s.message);null!=e&&(s.message=e)}let o,a=!1;if(1===i&&(a=!0),s.success?(Ge&&(null===(n=ze._onLog)||void 0===n||n.call(ze,"init license success")),s.message&&console.warn(s.message),ze._bSupportIRTModule=s.bSupportIRTModule,ze._bSupportDce4Module=s.bSupportDce4Module,As.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),a||111==s.ltsErrorCode&&-1!=s.message.toLowerCase().indexOf("trial license")&&(a=!0)),l&&(a=!1),a){const e=W(ze.engineResourcePaths),t=("DCV"===ze._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 a=[];for(let e=0;e<o.childElementCount;++e){let t=o.children[e];t instanceof HTMLStyleElement&&(a.push(t),document.head.append(t))}let r=1==o.childElementCount?o.children[0]:o;r.remove();let c,l,d,u,h,_=[r],m=r.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){r.remove();for(let e of a)e.remove()}});else if(!l&&e.classList.contains("dls-license-icon-close"))l=e,e.addEventListener("click",()=>{r.remove();for(let e of a)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 a=document.createElement("a"),r=t.substring(i+1,s);a.innerText=r;let c=t.substring(n+1,o);a.setAttribute("href",c),a.setAttribute("target","_blank"),e.appendChild(a),t=t.substring(o+1)}}document.body.appendChild(r)}catch(t){e._onLog&&e._onLog(t.message||t)}})({_bNeverShowDialog:As._bNeverShowDialog,engineResourcePath:t,_onLog:ze._onLog},s.success?"warn":"error",s.message)}s.success?e(void 0):t(o)};const u=await ze.getModuleVersion();Pe.postMessage({type:"l_dynamsoft",body:{v:"DCV"===ze._bundleEnv?u.CVR.replace(/\.\d+$/,""):u.DBR.replace(/\.\d+$/,""),brtk:!!i,bptk:1===i,l:s,os:Cs,fn:As.deviceFriendlyName,ls:n,sp:o,rmk:a,cv:r,ar:l,_e:As._e,mliRecord:null===localStorage||void 0===localStorage?void 0:localStorage.getItem("dynamsoft")},id:d})}),await Ts),Ss=async()=>(Ts&&Ts.isRejected&&await Ts,Pe?new Promise((e,t)=>{const i=Ue();Ve[i]=async i=>{if(i.success){delete i.success;{let e=As.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)}},Pe.postMessage({type:"l_getAR",id:i})}):null);let As=class e{static setLicenseServer(t){fs(e,t)}static get license(){return this._license}static set license(t){gs(e,t)}static get licenseServer(){return this._licenseServer}static set licenseServer(t){fs(e,t)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(t){Es(e,t)}static async initLicense(t,i){if(gs(e,t),e.bCallInitLicense=!0,"boolean"==typeof i&&i||"object"==typeof i&&i.executeNow)return await ws()}static setDeviceFriendlyName(t){Es(e,t)}static getDeviceFriendlyName(){return e._deviceFriendlyName}static async getDeviceUUID(){return await async function(){return await ze.loadWasm(),await new Promise((e,t)=>{const i=Ue();Ve[i]=i=>{if(i.success)e(i.uuid);else{const e=Error(i.message);i.stack&&(e.stack=i.stack),t(e)}},Pe.postMessage({type:"l_getDeviceUUID",id:i})})}()}};As._pLoad=new hs,As.bPassValidation=!1,As.bCallInitLicense=!1,As._license=ms,As._licenseServer=[],As._deviceFriendlyName="",As._e=!0,Ze.license={},Ze.license.dynamsoft=ws,Ze.license.getAR=Ss,ze.engineResourcePaths.license={version:"4.6.20-dev-20260813111340",path:ls,isInternal:!0},Ze.license.LicenseManager=As;let Ds=class{static getVersion(){return`4.6.20-dev-20260813111340(Worker: ${je.license&&je.license.worker||"Not Loaded"}, Wasm: ${je.license&&je.license.wasm||"Not Loaded"})`}};const bs=()=>window.matchMedia("(orientation: landscape)").matches,Os=e=>Object.prototype.toString.call(e).slice(8,-1);function Ls(e,t){for(const i in t)"Object"===Os(t[i])&&"Object"===Os(e[i])&&i in e?Ls(e[i],t[i]):("cameraFeatures"===i&&(t[i]=Array.isArray(t[i])?t[i]:[t[i]]),e[i]=t[i]);return e}function Ns(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 Ms(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]=Ms(e[i])}else{t={};for(let i in e)e.hasOwnProperty(i)&&(t[i]=Ms(e[i]))}return t}function Bs(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 Fs="undefined"==typeof self,xs="function"==typeof importScripts,Ps=(()=>{if(!xs){if(!Fs&&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"./"}})();ze.engineResourcePaths.dbr={version:"11.6.20-dev-20260813111358",path:Ps,isInternal:!0},Ze.dbr={};let ks=class{static getVersion(){const e=je.dbr&&je.dbr.wasm;return`11.6.20-dev-20260813111358(Worker: ${je.dbr&&je.dbr.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}};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;!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"}(Vs||(Vs={})),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 Zs="undefined"==typeof self,Hs="function"==typeof importScripts,qs=(()=>{if(!Hs){if(!Zs&&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"./"}})(),Ys=e=>{if(null==e&&(e="./"),Zs||Hs);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},zs="undefined"==typeof self,$s="function"==typeof importScripts,Ks=(()=>{if(!$s){if(!zs&&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"./"}})();ze.engineResourcePaths.utility={version:"2.6.20-dev-20260813111350",path:Ks,isInternal:!0};let Xs=class{static getVersion(){return`2.6.20-dev-20260813111350(Worker: ${je.utility&&je.utility.worker||"Not Loaded"}, Wasm: ${je.utility&&je.utility.wasm||"Not Loaded"})`}};function Qs(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}"function"==typeof SuppressedError&&SuppressedError;const Js="undefined"==typeof self,en="function"==typeof importScripts,tn=(()=>{if(!en){if(!Js&&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"./"}})();ze.engineResourcePaths.dbr={version:"11.6.10-dev-20260601155910",path:tn,isInternal:!0},Ze.dbr={};const sn={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 nn,on,an,rn,cn;(cn=nn||(nn={}))[cn.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",cn[cn.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",cn[cn.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"}(on||(on={})),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"}(an||(an={})),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"}(rn||(rn={}));const ln=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=Y(o);return new Blob([e],{type:"image/bmp"})}return await new Promise(e=>{s.toBlob(t=>{e(t)},t)})}finally{URL.revokeObjectURL(i)}};function dn(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 un(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function hn(e,t){const[i,s]=e,n=i.x,o=i.y,a=s.x,r=s.y,c=t.x,l=t.y,d=(a-n)**2+(r-o)**2;if(0===d)return Math.sqrt((c-n)**2+(l-o)**2);const u=((c-n)*(a-n)+(l-o)*(r-o))/d;if(u<0)return Math.sqrt((c-n)**2+(l-o)**2);if(u>1)return Math.sqrt((c-a)**2+(l-r)**2);{const e=n+u*(a-n),t=o+u*(r-o);return Math.sqrt((c-e)**2+(l-t)**2)}}function _n(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 mn(e){const[t,i]=e;return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}function gn(e,t,i,s){const n=t.x-e.x,o=t.y-e.y,a=s.x-i.x,r=s.y-i.y,c=(-o*(e.x-i.x)+n*(e.y-i.y))/(-a*o+n*r),l=(a*(e.y-i.y)-r*(e.x-i.x))/(-a*o+n*r);return c>=0&&c<=1&&l>=0&&l<=1?{x:e.x+l*n,y:e.y+l*o}:null}function pn(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 fn(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(!fn(e.points[i],e.points[(i+1)%4],t))return!1;return!0}function yn(e,t,i,s){const n=e.points,o=t.points;let a=8*i;a=Math.max(a,5);const r=_n(n)[3],c=_n(n)[1],l=_n(o)[3],d=_n(o)[1];let u,h=0;if(u=Math.max(Math.abs(hn(r,t.points[0])),Math.abs(hn(r,t.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(hn(c,t.points[1])),Math.abs(hn(c,t.points[2]))),u>h&&(h=u),u=Math.max(Math.abs(hn(l,e.points[0])),Math.abs(hn(l,e.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(hn(d,e.points[1])),Math.abs(hn(d,e.points[2]))),u>h&&(h=u),h>a)return!1;const _=mn(_n(n)[0]),m=mn(_n(n)[2]),g=mn(_n(o)[0]),p=mn(_n(o)[2]),f=un(_,p),E=un(g,m),y=f>E,I=Math.min(f,E),v=un(_,m),R=un(g,p);let C=12*i;return C=Math.max(C,5),C=Math.min(C,v),C=Math.min(C,R),!!(I<C||dn(n,y?g:p)||dn(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=pn(s.points),!0)}class In{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),a=0,r=0;for(let e=0;e<4;++e)n[e]=Math.round(100*(s.points[e].x-i.points[e].x))/100,a+=n[e],o[e]=Math.round(100*(s.points[e].y-i.points[e].y))/100,r+=o[e];a/=4,r/=4;for(let e=0;e<4;++e){if(Math.abs(n[e]-a)>this.strictLimit||Math.abs(a)>.8)return!1;if(Math.abs(o[e]-r)>this.strictLimit||Math.abs(r)>.8)return!1}return t.x=a,t.y=r,!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(hn(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=gn(e[s],e[(s+1)%4],t[n],t[(n+1)%4]);o&&i.push(o)}return e.forEach(e=>{dn(t,e)&&i.push(e)}),t.forEach(t=>{dn(e,t)&&i.push(t)}),pn(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 vn,Rn,Cn,Tn,wn,Sn;const An={barcode:2,text_line:4,detected_quad:8,deskewed_image:16},Dn=(e,t)=>"string"==typeof e?t[An[e]]:t[e],bn=(e,t,i)=>{"string"==typeof e?t[An[e]]=i:t[e]=i},On=(e,t,i)=>{const s=[{type:Ee.CRIT_BARCODE,resultName:"decodedBarcodesResult",itemNames:["barcodeResultItems"]},{type:Ee.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},Ln=e=>{const t=[];return e&Ee.CRIT_BARCODE&&t.push(Ee.CRIT_BARCODE),e&Ee.CRIT_TEXT_LINE&&t.push(Ee.CRIT_TEXT_LINE),e&Ee.CRIT_DETECTED_QUAD&&t.push(Ee.CRIT_DETECTED_QUAD),e&Ee.CRIT_DESKEWED_IMAGE&&t.push(Ee.CRIT_DESKEWED_IMAGE),t};class Nn{constructor(){this.verificationEnabled={[Ee.CRIT_BARCODE]:!1,[Ee.CRIT_TEXT_LINE]:!0,[Ee.CRIT_DETECTED_QUAD]:!0,[Ee.CRIT_DESKEWED_IMAGE]:!1},this.duplicateFilterEnabled={[Ee.CRIT_BARCODE]:!1,[Ee.CRIT_TEXT_LINE]:!1,[Ee.CRIT_DETECTED_QUAD]:!1,[Ee.CRIT_DESKEWED_IMAGE]:!1},this.duplicateForgetTime={[Ee.CRIT_BARCODE]:3e3,[Ee.CRIT_TEXT_LINE]:3e3,[Ee.CRIT_DETECTED_QUAD]:3e3,[Ee.CRIT_DESKEWED_IMAGE]:3e3},this.crossVerificationCriteria={[Ee.CRIT_BARCODE]:{frameWindow:5,minConsistentFrames:2},[Ee.CRIT_TEXT_LINE]:{frameWindow:5,minConsistentFrames:2},[Ee.CRIT_DETECTED_QUAD]:{frameWindow:6,minConsistentFrames:4},[Ee.CRIT_DESKEWED_IMAGE]:{frameWindow:6,minConsistentFrames:4}},vn.set(this,new Map),Rn.set(this,new Map),Cn.set(this,new Map),Tn.set(this,new Map),wn.set(this,new Map),Sn.set(this,new Map),this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,this.latestOverlappingEnabled={[Ee.CRIT_BARCODE]:!1,[Ee.CRIT_TEXT_LINE]:!1,[Ee.CRIT_DETECTED_QUAD]:!1,[Ee.CRIT_DESKEWED_IMAGE]:!1},this.maxOverlappingFrames={[Ee.CRIT_BARCODE]:this.crossVerificationFrames,[Ee.CRIT_TEXT_LINE]:this.crossVerificationFrames,[Ee.CRIT_DETECTED_QUAD]:this.crossVerificationFrames,[Ee.CRIT_DESKEWED_IMAGE]:this.crossVerificationFrames},Object.defineProperties(this,{onOriginalImageResultReceived:{value:e=>{},writable:!1},onDecodedBarcodesReceived:{value:e=>{this.latestOverlappingFilter(e),On(this,e,Ee.CRIT_BARCODE)},writable:!1},onRecognizedTextLinesReceived:{value:e=>{On(this,e,Ee.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===Ee.CRIT_PARSED_RESULT&&t[e].isFilter&&t.splice(e,1);e.parsedResult&&(e.parsedResult.parsedResultItems=e.parsedResult.parsedResultItems.filter(e=>!e.isFilter),0===e.parsedResult.parsedResultItems.length&&delete e.parsedResult)},writable:!1}})}_dynamsoft(){Qs(this,vn,"f").forEach((e,t)=>{bn(t,this.verificationEnabled,e)}),Qs(this,Rn,"f").forEach((e,t)=>{bn(t,this.duplicateFilterEnabled,e)}),Qs(this,Cn,"f").forEach((e,t)=>{bn(t,this.duplicateForgetTime,e)}),Qs(this,Tn,"f").forEach((e,t)=>{bn(t,this.latestOverlappingEnabled,e)}),Qs(this,wn,"f").forEach((e,t)=>{bn(t,this.maxOverlappingFrames,e)}),Qs(this,Sn,"f").forEach((e,t)=>{bn(t,this.crossVerificationCriteria,e)})}enableResultCrossVerification(e,t=!0){if("number"==typeof e){const i=Ln(e);for(let e of i)Qs(this,vn,"f").set(e,t)}else Qs(this,vn,"f").set(e,t)}isResultCrossVerificationEnabled(e){return Dn(e,this.verificationEnabled)}enableResultDeduplication(e,t=!0){if(t&&this.enableLatestOverlapping(e,!1),"number"==typeof e){const i=Ln(e);for(let e of i)Qs(this,Rn,"f").set(e,t)}else Qs(this,Rn,"f").set(e,t)}isResultDeduplicationEnabled(e){return Dn(e,this.duplicateFilterEnabled)}setDuplicateForgetTime(e,t){if(t>18e4&&(t=18e4),t<0&&(t=0),"number"==typeof e){const i=Ln(e);for(let e of i)Qs(this,Cn,"f").set(e,t)}else Qs(this,Cn,"f").set(e,t)}getDuplicateForgetTime(e){return Dn(e,this.duplicateForgetTime)}getFilteredResultItemTypes(){let e=0;const t=[Ee.CRIT_BARCODE,Ee.CRIT_TEXT_LINE,Ee.CRIT_DETECTED_QUAD,Ee.CRIT_DESKEWED_IMAGE,Ee.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=Ln(e);for(let e of s)Qs(this,Sn,"f").set(e,{frameWindow:t,minConsistentFrames:i})}else Qs(this,Sn,"f").set(e,{frameWindow:t,minConsistentFrames:i})}getResultCrossVerificationCriteria(e){return Dn(e,this.crossVerificationCriteria)}enableLatestOverlapping(e,t=!0){if(t&&this.enableResultDeduplication(e,!1),"number"==typeof e){const i=Ln(e);for(let e of i)Qs(this,Tn,"f").set(e,t)}else Qs(this,Tn,"f").set(e,t)}isLatestOverlappingEnabled(e){return Dn(e,this.latestOverlappingEnabled)}setMaxOverlappingFrames(e,t){if("number"==typeof e){const i=Ln(e);for(let e of i)Qs(this,wn,"f").set(e,t)}else Qs(this,wn,"f").set(e,t)}getMaxOverlappingFrames(e){return Dn(e,this.maxOverlappingFrames)}latestOverlappingFilter(e){var t,i,s;const n=this.isResultCrossVerificationEnabled(Ee.CRIT_BARCODE),o=this.isLatestOverlappingEnabled(Ee.CRIT_BARCODE);if(o){const a=this.crossVerificationFrames,r=60,c=o?this.getMaxOverlappingFrames(Ee.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(sn.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0);return new In(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 a=0;a<this.overlapSet.length;a++){if(e[t][a]<1)continue;const r=this.overlapSet[a],c=r.item;if(o.format===c.format&&o.text===c.text){if(n=r.isProbablySameLocationWithOffset(f[t],i),n){s[t]=a,e[t][a]=0;break}}else e[t][a]=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 a=this.overlapSet[t],r=a.item;if(o.format===r.format&&o.text===r.text){if(a.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(sn.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0),o=e.confidence<r,a=new In(c,s?1:2,s,i);n&&s&&o&&_.push(t),this.overlapSet.push(a)}});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,a=this.overlapSet[n].item.format;if(e.format===a&&e.text===o){if(this.overlapSet[n].isOverlappedLocationWithOffset(e,m,!1)){const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(sn.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0),o=s?1:2;this.overlapSet[n]=new In(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 a={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};if(yn(s,o,e.moduleSize,a)){e.location=a;const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(sn.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0),o=s?1:2;this.overlapSet[n]=new In(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(sn.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0),n=s?1:2;this.overlapSet[e]=new In(c,n,s,t)}this.overlapSet[e]&&(this.overlapSet[e].overlapCount=c,this.overlapSet[e].verificationCount=2,this.overlapSet[e].crossVerificationFrame=a)}}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),a=(BigInt(i.format)&BigInt(sn.BF_ONED))!=BigInt(0)||(BigInt(i.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0),l=i.confidence<r,d=new In(c,a?1:2,a,o);n&&a&&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 Mn,Bn,Fn,xn;vn=new WeakMap,Rn=new WeakMap,Cn=new WeakMap,Tn=new WeakMap,wn=new WeakMap,Sn=new WeakMap;class Pn{static async readFromFile(e){if("string"==typeof e){if(!V(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=z(e);return j(s,t,i)}static async readFromMemory(e){if(!Qs(Mn,Mn,"f",Bn).has(e))throw new Error("Image data ID does not exist.");return Qs(Mn,Mn,"f",Bn).get(e)}static async saveToMemory(e,t){var i,s,n;const o=await ln(e,t),a=await K(o),r=(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=Mn,Mn,(n=Qs(i,Mn,"f",Fn),s=n++,n),0,Fn),s);return Qs(Mn,Mn,"f",Bn).set(r,a),r}static async readFromBase64String(e){const t=await async function(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=z(e);const s=await ln(i,t);return await async function(e){return await new Promise((t,i)=>{const s=new FileReader;s.onload=()=>{t(s.result)},s.onerror=e=>{i(e)},s.readAsDataURL(e)})}(s)}}Mn=Pn,Bn={value:new Map},Fn={value:0};class kn{static async drawOnImage(e,t,i,s=4294901760,n=1,o="test.png",a){if(!e)throw new Error("Invalid image.");if(!t)throw new Error("Invalid drawingItem.");if(!i)throw new Error("Invalid type.");let r;if(e instanceof Blob)r=await K(e);else if("string"==typeof e){let t=await U(e,"blob");r=await K(t)}else L(e)&&(r=e,"bigint"==typeof r.format&&(r.format=Number(r.format)));return await new Promise((e,c)=>{let l=Ue();Ve[l]=async function(t){if(t.success)return a&&Pn.saveToFile(t.image,o,a),e(t.image);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,c(e)}},Pe.postMessage({type:"utility_drawOnImage",id:l,body:{dsImage:r,drawingItem:Array.isArray(t)?t:[t],color:s,thickness:n,type:i}})})}}class Un{static async cropImage(e,t){const{bytes:i,width:s,height:n,stride:o,format:a}=L(e)?e:await K(e);return await new Promise((e,r)=>{let c=Ue();Ve[c]=async function(t){if(t.success)return e(t.cropImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,r(e)}},Pe.postMessage({type:"utility_cropImage",id:c,body:{type:"Rect",bytes:i,width:s,height:n,stride:o,format:a,roi:t}})})}static async adjustBrightness(e,t){const{bytes:i,width:s,height:n,stride:o,format:a}=L(e)?e:await K(e);return await new Promise((e,r)=>{let c=Ue();Ve[c]=async function(t){if(t.success)return e(t.adjustBrightness);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,r(e)}},Pe.postMessage({type:"utility_adjustBrightness",id:c,body:{bytes:i,width:s,height:n,stride:o,format:a,brightness:t}})})}static async adjustContrast(e,t){const{bytes:i,width:s,height:n,stride:o,format:a}=L(e)?e:await K(e);return await new Promise((e,r)=>{let c=Ue();Ve[c]=async function(t){if(t.success)return e(t.adjustContrast);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,r(e)}},Pe.postMessage({type:"utility_adjustContrast",id:c,body:{bytes:i,width:s,height:n,stride:o,format:a,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:a}=L(e)?e:await K(e);return await new Promise((e,r)=>{let c=Ue();Ve[c]=async function(t){if(t.success)return e(t.filterImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,r(e)}},Pe.postMessage({type:"utility_filterImage",id:c,body:{bytes:i,width:s,height:n,stride:o,format:a,filterType:t}})})}static async convertToGray(e,t,i,s){const{bytes:n,width:o,height:a,stride:r,format:c}=L(e)?e:await K(e);return await new Promise((e,l)=>{let d=Ue();Ve[d]=async function(t){if(t.success)return e(t.convertToGray);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,l(e)}},Pe.postMessage({type:"utility_convertToGray",id:d,body:{bytes:n,width:o,height:a,stride:r,format:c,R:t,G:i,B:s}})})}static async convertToBinaryGlobal(e,t=-1,i=!1){const{bytes:s,width:n,height:o,stride:a,format:r}=L(e)?e:await K(e);return await new Promise((e,c)=>{let l=Ue();Ve[l]=async function(t){if(t.success)return e(t.convertToBinaryGlobal);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,c(e)}},Pe.postMessage({type:"utility_convertToBinaryGlobal",id:l,body:{bytes:s,width:n,height:o,stride:a,format:r,threshold:t,invert:i}})})}static async convertToBinaryLocal(e,t=0,i=10,s=!1){const{bytes:n,width:o,height:a,stride:r,format:c}=L(e)?e:await K(e);return await new Promise((e,l)=>{let d=Ue();Ve[d]=async function(t){if(t.success)return e(t.convertToBinaryLocal);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,l(e)}},Pe.postMessage({type:"utility_convertToBinaryLocal",id:d,body:{bytes:n,width:o,height:a,stride:r,format:c,blockSize:t,compensation:i,invert:s}})})}static async cropAndDeskewImage(e,t,i=0,s=0,n=0){const{bytes:o,width:a,height:r,stride:c,format:l}=L(e)?e:await K(e);return await new Promise((e,d)=>{let u=Ue();Ve[u]=async function(t){if(t.success)return e(t.cropAndDeskewImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,d(e)}},Pe.postMessage({type:"utility_cropAndDeskewImage",id:u,body:{bytes:o,width:a,height:r,stride:c,format:l,roi:t,dstWidth:i,dstHeight:s,padding:n}})})}}!function(e){e[e.LP_UNKNOWN=0]="LP_UNKNOWN",e[e.LP_LINES=1]="LP_LINES",e[e.LP_MATRIX=2]="LP_MATRIX"}(xn||(xn={}));const Vn={pattern:xn.LP_UNKNOWN,axes:[{elementCount:-1,isStaggered:!1,angle:-1,isEqualSpacing:!1,spacing:-1,spacingUnit:Me.MU_PIXEL},{elementCount:-1,isStaggered:!1,angle:-1,isEqualSpacing:!1,spacing:-1,spacingUnit:Me.MU_PIXEL}],inputImageWidth:0,inputImageHeight:0};class Gn{static async analyze(e,t){return Object.assign(Vn,t),await new Promise(async function(t,i){let s=Ue();Ve[s]=e=>{if(!e.success){let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}t(e.analyzeResult)},Pe.postMessage({type:"utility_analyze",id:s,body:{inputQuads:e,parameter:Vn}})})}}var Wn,jn,Zn,Hn;!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"}(Wn||(Wn={})),function(e){e[e.LES_NONE=0]="LES_NONE",e[e.LES_INPUT=1]="LES_INPUT",e[e.LES_INFERRED=2]="LES_INFERRED"}(jn||(jn={}));var qn=new WeakMap,Yn=new WeakMap,zn=new WeakMap,$n=new WeakMap,Kn=new WeakMap,Xn=new WeakMap,Qn=new WeakMap,Jn=new WeakMap,eo=new WeakMap,to=new WeakMap,io=new WeakSet;class so{constructor(e){if(o(this,io),a(this,"_cameraEnhancer",void 0),a(this,"_cameraView",void 0),a(this,"_cvRouter",void 0),s(this,qn,!1),s(this,Yn,void 0),s(this,zn,void 0),s(this,$n,void 0),s(this,Kn,void 0),s(this,Xn,new Map),s(this,Qn,[]),s(this,Jn,void 0),s(this,eo,new Qe),s(this,to,{status:{code:d.RS_SUCCESS,message:"Success."},barcodeResults:[]}),a(this,"config",Ms($e)),e&&"object"!=typeof e||Array.isArray(e))throw new Error("Invalid config.");n(Jn,this,e),Ls(this.config,e)}get disposed(){return i(qn,this)}async launch(){if(i(qn,this))throw new Error("The BarcodeScanner instance has been destroyed.");if(e(so,Hn,bo)._&&!e(so,Hn,bo)._.isFulfilled&&!e(so,Hn,bo)._.isRejected)throw new Error("Cannot call `launch()` while a previous task is still running.");if(bo._=e(so,Hn,new Qe),!As.getDeviceFriendlyName())try{As.setDeviceFriendlyName("dbr_rtu")}catch(e){}return e(io,this,no).call(this),e(so,Hn,bo)._}async decode(t,s){if(this.disposed)return Promise.reject(new Error("Cannot call decode on a disposed instance. This instance was disposed after launch completed."));const o=new Kt;try{await e(io,this,oo).call(this,!0),i(Kn,this)||n(Kn,this,new Nn),i(Kn,this).enableResultCrossVerification(2,!1),await this._cvRouter.addResultFilter(i(Kn,this)),o.onCapturedResultReceived=()=>{},this._cvRouter.addResultReceiver(o),s||(s=this.config.utilizedTemplateNames.image);return await this._cvRouter.capture(t,s)}catch(e){throw e}finally{var a;i(Kn,this)&&(i(Kn,this).enableResultCrossVerification(2,!0),await this._cvRouter.addResultFilter(i(Kn,this))),null===(a=this._cvRouter)||void 0===a||a.removeResultReceiver(o)}}dispose(){var t,s,o,a,r,c,l;n(qn,this,!0),e(so,Hn,bo)._&&e(so,Hn,bo)._.isPending&&e(so,Hn,bo)._.resolve(i(to,this)),null===(t=this._cameraEnhancer)||void 0===t||t.dispose(),null===(s=this._cameraView)||void 0===s||s.dispose(),null===(o=this._cvRouter)||void 0===o||o.dispose(),this._cameraEnhancer=null,this._cameraView=null,this._cvRouter=null,null===(a=document.querySelector(".scanner-view-container"))||void 0===a||a.remove(),null===(r=document.querySelector(".result-view-container"))||void 0===r||r.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 i(Xn,this))for(let i of t)window.removeEventListener(e,i);i(Xn,this).clear();for(let e of i(Qn,this))document.head.removeChild(e);n(Qn,this,[])}}async function no(){try{if(this.config.onInitPrepare&&this.config.onInitPrepare(),this.disposed)return;if(await e(io,this,oo).call(this),this.config.onInitReady&&this.config.onInitReady({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed)return;let t=!1;try{if(document.querySelector(".loading-page span").innerText="Accessing Camera...",await this._cameraEnhancer.open(),Ns(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){e(io,this,To).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),t=!0,this.disposed)return}if(this.config.autoStartCapturing&&!t&&(await this._cvRouter.startCapturing(i(zn,this)),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed))return}catch(t){i(to,this).status={code:d.RS_FAILED,message:t.message||t},e(Zn,Hn,bo)._.reject(new Error(i(to,this).status.message)),this.dispose()}finally{e(io,this,wo).call(this,"Loading...",!1)}}async function oo(t=!1){ze.engineResourcePaths=this.config.engineResourcePaths;const s=W(ze.engineResourcePaths);if(!t){let t=e(Zn,Hn,Oo)._.get("dceUI");if(t||(t=await U(s.dbrBundle+"ui/dce.rtu.ui.xml","text"),e(Zn,Hn,Oo)._.set("dceUI",t)),this.disposed)return;if(this._cameraView=await bi.createInstance(t),this.disposed)return;if(this.config.scanMode===l.SM_SINGLE||this.config.scannerViewConfig.customHighlightForBarcode){this._cameraView.getDrawingLayer(2).setVisible(!1)}if(this._cameraEnhancer=await Di.createInstance(this._cameraView),this.disposed)return;if(await e(io,this,ro).call(this),this.disposed)return;this.config.scannerViewConfig.customHighlightForBarcode&&n($n,this,this._cameraEnhancer.getCameraView().createDrawingLayer())}if([null,void 0].includes(this.config.license)||(As._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 As.initLicense(this.config.license,{executeNow:!0})),this.disposed)return;if(this._cvRouter=this._cvRouter||await Gt.createInstance(!1),this._cvRouter._s=!0,this.disposed)return;let o=e(Zn,Hn,Oo)._.get("presetTemplates");if(o||(o=await U(s.dbrBundle+"templates/DBR-PresetTemplates.json","text"),e(Zn,Hn,Oo)._.set("presetTemplates",o)),!i(eo,this).isPending||(await this._cvRouter.initSettings(o),await e(io,this,ao).call(this,t),!this.disposed)){if(!t){if(this._cvRouter.setInput(this._cameraEnhancer),e(io,this,po).call(this),await e(io,this,fo).call(this),this.disposed)return;this._cvRouter.onCaptureError=t=>{e(Zn,Hn,bo)._.reject(new Error(t.message)),this.dispose()},this._cvRouter._dynamsoft=!(this.config.scanMode===l.SM_SINGLE)}i(eo,this).resolve()}}async function ao(t=!1){let s=this.config.templateFilePath;if(s){let t,n=!1;if(Qt(s)&&(n=s.reloadResource,s=s.path),n)t=await U(s,"text"),e(Zn,Hn,Oo)._.delete("templateFile");else{t=e(Zn,Hn,Oo)._.get("templateFile"),t||(t=await U(s,"text"),e(Zn,Hn,Oo)._.set("templateFile",t)),t=JSON.parse(t);const n=t.CaptureVisionTemplates[0].Name;i(Jn,this).utilizedTemplateNames?(i(Jn,this).utilizedTemplateNames.image||(this.config.utilizedTemplateNames.image=n),i(Jn,this).utilizedTemplateNames.multi_unique||(this.config.utilizedTemplateNames.multi_unique=n),i(Jn,this).utilizedTemplateNames.single||(this.config.utilizedTemplateNames.single=n)):this.config.utilizedTemplateNames={image:n,multi_unique:n,single:n}}if(this.disposed)return;if(await this._cvRouter.initSettings(t),this.disposed)return}const o=await this._cvRouter.outputSettings("*",!0);if(this.disposed)return;if(!t&&this.config.scanMode===l.SM_SINGLE)for(let e of o.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 o.BarcodeReaderTaskSettingOptions){t.BarcodeFormatIds=[];for(let i in Us)for(let s in a)e(a[s],Us[i])&&t.BarcodeFormatIds.push(i)}}await this._cvRouter.initSettings(o),this.disposed||t||(this.config.scanMode===l.SM_SINGLE?n(zn,this,this.config.utilizedTemplateNames.single):this.config.scanMode===l.SM_MULTI_UNIQUE&&n(zn,this,this.config.utilizedTemplateNames.multi_unique))}async function ro(){let t,s,o=this.config.uiPath||W(this.config.engineResourcePaths).dbrBundle,a=!1;Qt(o)&&(a=o.reloadResource,o=o.path);let r=o.endsWith("/")?Ys(o)+"ui/barcode-scanner.ui.xml":Ys(o).slice(0,-1);if(a?(t=await U(r,"text"),e(Zn,Hn,Oo)._.delete("dbsUI")):(t=e(Zn,Hn,Oo)._.get("dbsUI"),t||(t=await U(r,"text"),e(Zn,Hn,Oo)._.set("dbsUI",t))),s=(e=>{if(!e.trim().startsWith("<"))throw Error("Unable to get valid HTMLElement.");const t=document.createElement("div");if(t.insertAdjacentHTML("beforeend",e),1===t.childElementCount&&t.firstChild instanceof HTMLTemplateElement)return t.firstChild.content;const i=new DocumentFragment;for(let e of t.children)i.append(e);return i})(t),this.disposed)return;if(s.querySelectorAll("style").forEach(e=>{const t=e.cloneNode(!0);i(Qn,this).push(t),document.head.appendChild(t)}),this.config.scanMode===l.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)}n(Yn,this,s.querySelector(".result-item")),e(io,this,co).call(this,s),e(io,this,lo).call(this,s),e(io,this,uo).call(this,s),e(io,this,ho).call(this,s),await e(io,this,_o).call(this,s),e(io,this,Co).call(this,s),e(io,this,go).call(this,s),e(io,this,mo).call(this,s)}function co(t){const s=t.querySelector(".btn-clear");var n;if(s&&(s.addEventListener("click",()=>{i(to,this).barcodeResults=[],e(io,this,vo).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 e=this.config.resultViewConfig.toolbarButtonsConfig.clear;s.style.display=e.isHidden?"none":"flex",s.className=e.className,s.innerText=e.label,e.isHidden&&(t.querySelector(".toolbar-btns").style.justifyContent="center")}}function lo(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 uo(e){var t;if(null===(t=this.config)||void 0===t||null===(t=t.scannerViewConfig)||void 0===t?void 0:t.showCloseButton){const t=e.querySelector(".btn-close");t&&(t.style.display="inline",t.addEventListener("click",()=>{i(to,this).barcodeResults=[],i(to,this).status={code:d.RS_CANCELLED,message:"Cancelled."},this.dispose()}))}}function ho(t){var i;if(null===(i=this.config)||void 0===i?void 0:i.scannerViewConfig.showFlashButton){const i=t.querySelector(".btn-flash-auto"),s=t.querySelector(".btn-flash-open"),n=t.querySelector(".btn-flash-close");i&&(i.style.display="inline",this._cameraEnhancer.addEventListener("opened",async()=>{if(!this._cameraEnhancer.currentCamera)return void e(io,this,To).call(this,{auto:!1,open:!1,close:!1,notSupport:!1});const t=this._cameraEnhancer.isSupportTorch;for(this.config.scannerViewConfig.showFlashButton&&(t?e(io,this,To).call(this,{auto:!0,open:!1,close:!1,notSupport:!1}):e(io,this,To).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()&&t&&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 _o(t){let s=this.config.scannerViewConfig.cameraSwitchControl;["toggleFrontBack","listAll","hidden"].includes(s)||(this.config.scannerViewConfig.cameraSwitchControl="hidden");if("hidden"!==this.config.scannerViewConfig.cameraSwitchControl){const s=t.querySelector(".camera-control");if(s){s.style.display="block";const n=await this._cameraEnhancer.getAllCameras(),o=this.config.scannerViewConfig.cameraSwitchControl,a=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},r=()=>{if(0===n.length)return null;if("listAll"===o){const s=t.querySelector(".camera-list");for(let e of n){const t=a(e);s.append(t)}const o=()=>{const e=document.querySelector(".camera-list");e&&(e.style.display="none")},r=i(Xn,this).get("click")||[];i(Xn,this).set("click",[...r,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"};s.addEventListener("click",async t=>{t.stopPropagation();const n=t.target;e(io,this,wo).call(this,"Accessing Camera...",!0),this._cvRouter.stopCapturing(),await this._cameraEnhancer.selectCamera({deviceId:n.deviceId,label:n.label});const o=this._cameraEnhancer.getSelectedCamera();Ns(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(i(zn,this)),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter})),e(io,this,wo).call(this,"Loading...",!1),s.style.display="none"});const l=t.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()=>{e(io,this,wo).call(this,"Accessing Camera...",!0);const t=Ns(this._cameraEnhancer.getSelectedCamera());console.log(t),await this._cameraEnhancer.requestCamera(t?"back":"front");Ns(this._cameraEnhancer.getSelectedCamera())?(this.config.scannerViewConfig.mirrorFrontCamera&&(this._cameraEnhancer.isMirrored=!0),this.config.scannerViewConfig.showFlashButton&&e(io,this,To).call(this,{auto:!1,open:!1,close:!1,notSupport:!0})):(this._cameraEnhancer.isMirrored=!1,this.config.scannerViewConfig.showFlashButton&&e(io,this,To).call(this,{auto:!0,open:!1,close:!1,notSupport:!1})),e(io,this,wo).call(this,"Loading...",!1)}:void 0},c=r();s.addEventListener("click",async e=>{e.stopPropagation(),c&&await c()})}}}function mo(e){const t=this._cameraView.getUIElement();this._cameraView.setVideoFit("cover");const s=e.querySelector(".barcode-scanner-container");s.style.display=bs()?"flex":"block",this.config.scanMode===l.SM_MULTI_UNIQUE&&!1!==this.config.showResultView?this.config.showResultView=!0:this.config.scanMode===l.SM_SINGLE&&(this.config.showResultView=!1);const n=this.config.showResultView;let o;if(this.config.container?(s.style.position="relative",o=this.config.container):o=document.body,"string"==typeof o&&(o=document.querySelector(o),null===o))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 r=this.config.resultViewConfig.container;if("string"==typeof r&&(r=document.querySelector(r),null===r))throw new Error("Failed to get the container of the result view.");const c=e.querySelector(".scanner-view-container"),d=e.querySelector(".result-view-container"),u=e.querySelector(".loading-page");c.append(u),a&&(c.append(t),a.append(c)),r&&r.append(d),a||r?a&&!r?(this.config.container||(d.style.position="absolute"),r=d,o.append(d)):!a&&r&&(this.config.container||(c.style.position="absolute"),a=c,c.append(t),o.append(c)):(a=c,r=d,n&&(Object.assign(c.style,{width:bs()?"50%":"100%",height:bs()?"100%":"50%"}),Object.assign(d.style,{width:bs()?"50%":"100%",height:bs()?"100%":"50%"})),c.append(t),o.append(s)),document.querySelector(".result-view-container").style.display=n?"block":"none",this.config.showPoweredByDynamsoft||(this._cameraEnhancer.setPowerByMessageVisible(!1),document.querySelector(".no-result-svg").style.display="none");const h=()=>{Object.assign(s.style,{display:bs()?"flex":"block"}),!n||this.config.scannerViewConfig.container||this.config.resultViewConfig.container||(Object.assign(a.style,{width:bs()?"50%":"100%",height:bs()?"100%":"50%"}),Object.assign(r.style,{width:bs()?"50%":"100%",height:bs()?"100%":"50%"}))},_=i(Xn,this).get("resize")||[];i(Xn,this).set("resize",[..._,h]),window.addEventListener("resize",h)}function go(e){var t;null===(t=e.querySelector(".resume"))||void 0===t||t.addEventListener("click",async()=>{var e,t,s;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===(s=this._cameraView.getUIElement().shadowRoot.querySelectorAll(".single-barcode-result-option"))||void 0===s||s.forEach(e=>null==e?void 0:e.remove()),await this._cameraEnhancer.resume(),await new Promise(e=>{setTimeout(e,100)}),this._cvRouter.startCapturing(i(zn,this))})}function po(){const t=new Kt;t.onCapturedResultReceived=async t=>{if(i($n,this)&&i($n,this).clearDrawingItems(),t.decodedBarcodesResult){if(this.config.scannerViewConfig.customHighlightForBarcode){let e=[];for(let i of t.decodedBarcodesResult.barcodeResultItems)e.push(this.config.scannerViewConfig.customHighlightForBarcode(i));i($n,this).addDrawingItems(e)}this.config.scanMode===l.SM_SINGLE?e(io,this,Eo).call(this,t):e(io,this,yo).call(this,t)}},this._cvRouter.addResultReceiver(t)}async function fo(){i(Kn,this)||n(Kn,this,new Nn),i(Kn,this).enableResultCrossVerification(2,!0),i(Kn,this).enableResultDeduplication(2,!0),i(Kn,this).setDuplicateForgetTime(2,this.config.duplicateForgetTime),await this._cvRouter.addResultFilter(i(Kn,this)),i(Kn,this).isResultCrossVerificationEnabled=()=>!1,i(Kn,this).isResultDeduplicationEnabled=()=>!1}function Eo(t){const i=this._cameraView.getUIElement().shadowRoot;let s=new Promise(s=>{if(t.decodedBarcodesResult.barcodeResultItems.length>1){e(io,this,Io).call(this);let n=[];for(let e of t.decodedBarcodesResult.barcodeResultItems){let t=0,i=0;for(let s=0;s<4;++s){let n=e.location.points[s];t+=n.x,i+=n.y}let o=this._cameraEnhancer.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0}),a=this._cameraEnhancer.videoXY2FixedLT([{x:o.x+t/4,y:o.y+i/4}]),r=document.createElement("div");r.className="single-barcode-result-option",Object.assign(r.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"}),r.style.left=a[0].left+"px",r.style.top=a[0].top+"px",r.addEventListener("click",()=>{s(e)}),n.push(r)}i.append(...n)}else s(t.decodedBarcodesResult.barcodeResultItems[0])});s.then(async i=>{const s=t.items.filter(e=>e.type===Ee.CRIT_ORIGINAL_IMAGE)[0],n=s.imageData,o={status:{code:d.RS_SUCCESS,message:"Success."},originalImageResult:n,barcodeImage:(()=>{const e=Z(n),t=i.location.points,s=Math.min(...t.map(e=>e.x)),o=Math.min(...t.map(e=>e.y)),a=Math.max(...t.map(e=>e.x)),r=Math.max(...t.map(e=>e.y)),c=a-s,l=r-o,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-s,t[0].y-o);for(let e=1;e<t.length;e++)u.lineTo(t[e].x-s,t[e].y-o);u.closePath(),u.clip(),u.drawImage(e,-s,-o);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:f.IPF_ABGR_8888}})(),barcodeResults:[i]};e(io,this,So).call(this,i),e(Zn,Hn,bo)._.resolve(o),this.dispose()})}function yo(t){for(let s of t.decodedBarcodesResult.barcodeResultItems){if(!1!==s.duplicate)continue;const t=i(to,this).barcodeResults.findIndex(e=>`${e.formatString}_${e.text}`==`${s.formatString}_${s.text}`);-1===t?(s.count=1,i(to,this).barcodeResults.unshift(s),e(io,this,vo).call(this,s)):(i(to,this).barcodeResults[t].count++,e(io,this,Ro).call(this,t)),this.config.onUniqueBarcodeScanned&&this.config.onUniqueBarcodeScanned(s)}}function Io(){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 vo(e){if(!this.config.showResultView)return;const t=document.querySelector(".no-result-svg");if(!(this.config.showResultView&&this.config.scanMode!==l.SM_SINGLE))return;const s=document.querySelector(".main-list");if(!e)return s.textContent="",void(this.config.showPoweredByDynamsoft&&(t.style.display="inline"));t.style.display="none";const n=(e=>{const t=i(Yn,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")],s=t.findIndex(t=>t.id===`${e.formatString}_${e.text}`);i(to,this).barcodeResults.splice(s,1),t[s].remove(),0===i(to,this).barcodeResults.length&&this.config.showPoweredByDynamsoft&&(document.querySelector(".no-result-svg").style.display="inline")}),t})(e);s.insertBefore(n,document.querySelector(".result-item"))}function Ro(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 Co(t){if(this.config.showUploadImageButton){const s=t.querySelector(".btn-upload-image");s.style.display="flex",s.addEventListener("change",async t=>{const s=t.target.files;if(!s)return;const n={status:{code:d.RS_SUCCESS,message:"Success."},barcodeResults:[]};let o=0;e(io,this,wo).call(this,`Capturing... [${o}/${s.length}]`,!0);let a=!1;for(let e=0;e<s.length;e++)if(!Bs(s[e])){a=!0;break}if(a)return e(Zn,Hn,bo)._.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 t of s)try{this._cvRouter.stopCapturing();const a=await this.decode(t,this.config.utilizedTemplateNames.image);if(a.decodedBarcodesResult)if(this.config.scanMode===l.SM_MULTI_UNIQUE)for(let t of a.decodedBarcodesResult.barcodeResultItems){const s=i(to,this).barcodeResults.findIndex(e=>`${e.formatString}_${e.text}`==`${t.formatString}_${t.text}`);-1===s?(t.count=1,i(to,this).barcodeResults.unshift(t),e(io,this,vo).call(this,t)):(i(to,this).barcodeResults[s].count++,e(io,this,Ro).call(this,s)),this.config.onUniqueBarcodeScanned&&this.config.onUniqueBarcodeScanned(t)}else if(a.decodedBarcodesResult.barcodeResultItems)for(let e of a.decodedBarcodesResult.barcodeResultItems){const t=n.barcodeResults.find(t=>`${t.text}_${t.formatString}`==`${e.text}_${e.formatString}`);t?t.count++:(e.count=1,n.barcodeResults.push(e))}e(io,this,wo).call(this,`Capturing... [${++o}/${s.length}]`,!0)}catch(t){return n.status={code:d.RS_FAILED,message:t.message||t},e(Zn,Hn,bo)._.reject(new Error(n.status.message)),void this.dispose()}e(io,this,wo).call(this,"Loading...",!1),this.config.scanMode===l.SM_SINGLE?(e(Zn,Hn,bo)._.resolve(n),this.dispose()):this._cvRouter.startCapturing(i(zn,this)),t.target.value=""})}}function To(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 wo(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 So(e){let t=Ue();Ve[t]=()=>{},Pe.postMessage({type:"cvr_cc",id:t,instanceID:this._cvRouter._instanceID,body:{text:e.text,strFormat:e.format.toString(),isDPM:e.isDPM}})}Zn=so;var Ao,Do,bo={_:null},Oo={_:new Map};function Lo(e){delete e.moduleId;const t=JSON.parse(e.jsonString).ResultInfo,i=e.fullCodeString,s=e.fieldNames;e.getFieldValue=e=>"fullcodestring"===e.toLowerCase()?i:No(t,e,"map"),e.getFieldRawValue=e=>"fullcodestring"===e.toLowerCase()?i:No(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=Bo(t,e))&&void 0!==i?i:Do.VS_NONE},e.getAllFieldNames=()=>s,delete e.fieldNames,delete e.fullCodeString}function No(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=No(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 Bo(e,t){var i;for(const s of e){if(s.FieldName===t)return s.ValidationStatus?Do[s.ValidationStatus]:Do.VS_NONE;if(null===(i=s.ChildFields)||void 0===i?void 0:i.length)for(const e of s.ChildFields){const i=Bo(e,t);if(void 0!==i)return i}}}function Fo(e){if(e.disposed)throw new Error('"CodeParser" instance has been disposed')}Hn=so,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"}(Do||(Do={}));const xo=e=>e&&"object"==typeof e&&"function"==typeof e.then,Po=(async()=>{})().constructor;class ko extends Po{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){var t=this;let i;this._task=e,xo(e)?i=e:"function"==typeof e&&(i=new Po(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(xo(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}class Uo{constructor(){this._instanceID=void 0,this.bDestroyed=!1}static async createInstance(){await Ze.license.dynamsoft(),await ze.loadWasm();const e=new Uo,t=new ko;let i=Ue();return Ve[i]=async function(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)}},Pe.postMessage({type:"dcp_createInstance",id:i}),t}async dispose(){Fo(this);let e=Ue();this.bDestroyed=!0,Ve[e]=e=>{if(!e.success){let t=new Error(e.message);throw t.stack=e.stack+"\n"+t.stack,t}},Pe.postMessage({type:"dcp_dispose",id:e,instanceID:this._instanceID})}get disposed(){return this.bDestroyed}async initSettings(e){if(Fo(this),e&&["string","object"].includes(typeof e))return"string"==typeof e?e.trimStart().startsWith("{")||(e=await U(e,"text")):"object"==typeof e&&(e=JSON.stringify(e)),await new Promise((t,i)=>{let s=Ue();Ve[s]=async function(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)}},Pe.postMessage({type:"dcp_initSettings",id:s,instanceID:this._instanceID,body:{settings:e}})});console.error("Invalid settings.")}async resetSettings(){return Fo(this),await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.postMessage({type:"dcp_resetSettings",id:i,instanceID:this._instanceID})})}async parse(e,t=""){if(Fo(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=Ue();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))),Ve[n]=async function(e){if(e.success){let t=JSON.parse(e.parseResponse);return t.errorCode?s(new Error(t.errorString)):(Lo(t),i(t))}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,s(t)}},Pe.postMessage({type:"dcp_parse",id:n,instanceID:this._instanceID,body:{source:e,taskSettingName:t}})})}}const Vo="undefined"==typeof self,Go="function"==typeof importScripts,Wo=(()=>{if(!Go){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"./"}})();ze.engineResourcePaths.dcp={version:"3.6.20-dev-20260813111422",path:Wo,isInternal:!0},Ze.dcp={handleParsedResultItem:Lo},Ve[-4]=async e=>{jo.onSpecLoadProgressChanged&&jo.onSpecLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class jo{static getVersion(){const e=je.dcp&&je.dcp.wasm;return`3.6.20-dev-20260813111422(Worker: ${je.dcp&&je.dcp.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}static async loadSpec(e,t){return await ze.loadWasm(),await new Promise((i,s)=>{let n,o=Ue();if(Ve[o]=async function(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=W(ze.engineResourcePaths);n=`${"DBR"===ze._bundleEnv?e.dbrBundle:e.dcvData}parser-resources/`}let a=(e instanceof Array?e:[e]).map(e=>e.replace(/^MRTD.*$/,"MRTD"));a=a.map(e=>e.replace(/\.data$/i,"")),Pe.postMessage({type:"dcp_appendResourceBuffer",id:o,body:{specificationPath:n,specificationNames:a}})})}}var Zo,Ho,qo,Yo,zo,$o,Ko,Xo,Qo,Jo;!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"}(Zo||(Zo={}));class ea{static getVersion(){return`3.6.20-dev-20260813111438(Worker: ${je.dip&&je.dip.worker||"Not Loaded"}, Wasm: ${je.dip&&je.dip.wasm||"Not Loaded"})`}}(ze._bundleEnv="DBR",Gt._defaultTemplate="ReadSingleBarcode",ze.engineResourcePaths.rootDirectory=Ys(qs+"../../"),ze.engineResourcePaths.dbrBundle={version:"11.6.2000",path:qs,isInternal:!0},null!==(Ho=window)&&void 0!==Ho&&null!==(Ho=Ho.Dynamsoft)&&void 0!==Ho&&Ho.Core)||(null!==(Yo=(qo=window).Dynamsoft)&&void 0!==Yo||(qo.Dynamsoft={}),null!==($o=(zo=window.Dynamsoft).Core)&&void 0!==$o||(zo.Core={}),null!==(Xo=(Ko=window.Dynamsoft.Core).CoreModule)&&void 0!==Xo||(Ko.CoreModule=ze),null!==(Jo=(Qo=window.Dynamsoft.Core).mapPackageRegister)&&void 0!==Jo||(Qo.mapPackageRegister=Ze));As._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)"),Di.CoreModule=ze,Di.handleEngineResourcePaths=W;export{ks as BarcodeReaderModule,so as BarcodeScanner,Ti as Beep,pi as Camera,Di as CameraEnhancer,Ai as CameraEnhancerModule,bi as CameraView,Gt as CaptureVisionRouter,ht as CaptureVisionRouterModule,Kt as CapturedResultReceiver,Uo as CodeParser,jo as CodeParserModule,ze as CoreModule,$i as DrawingItem,qi as DrawingLayer,Hi as DrawingStyleManager,Us as EnumBarcodeFormat,g as EnumBufferOverflowProtectionMode,Ee as EnumCapturedResultItemType,Zo as EnumCodeType,p as EnumColourChannelUsageType,ye as EnumCornerType,Se as EnumCrossVerificationStatus,js as EnumDeblurMode,is as EnumDrawingItemMediaType,ss as EnumDrawingItemState,ns as EnumEnhancedFeatures,Ie as EnumErrorCode,Vs as EnumExtendedBarcodeResultType,Wn as EnumFilterType,ve as EnumGrayscaleEnhancementMode,Re as EnumGrayscaleTransformationMode,Le as EnumImageCaptureDistanceMode,Oe as EnumImageFileFormat,f as EnumImagePixelFormat,Tt as EnumImageSourceState,Ce as EnumImageTagType,Ae as EnumIntermediateResultUnitType,jn as EnumLayoutElementSource,xn as EnumLayoutPattern,Ws as EnumLocalizationMode,Ao as EnumMappingStatus,Me as EnumMeasureUnit,Ne as EnumModuleName,Te as EnumPDFReadingMode,os as EnumPixelFormat,wt as EnumPresetTemplate,Gs as EnumQRCodeErrorCorrectionLevel,we as EnumRasterDataSource,De as EnumRegionObjectElementType,d as EnumResultStatus,l as EnumScanMode,be as EnumSectionType,Do as EnumValidationStatus,Be as EnumWasmType,ki as Feedback,Ci as FramePipeline,kn as ImageDrawer,es as ImageDrawingItem,Pn as ImageIO,ea as ImageProcessingModule,Un as ImageProcessor,_e as ImageSourceAdapter,Xt as IntermediateResultReceiver,Gn as LayoutAnalyzer,As as LicenseManager,Ds as LicenseModule,Ki as LineDrawingItem,Nn as MultiFrameResultCrossFilter,Xi as QuadDrawingItem,Qi as RectDrawingItem,Ji as TextDrawingItem,Xs as UtilityModule,xi as _bufferToCanvas,zi as _distToSegment,Yi as _isPointInPolygon,j as _saveToFile,q as _toBlob,Z as _toCanvas,H as _toImage,Ge as bDebug,wi as beep,K as blobToDsImage,V as checkIsLink,G as compareVersion,z as createImageData,Q as d,X as e,Y as encodeBMP,Ue as getNextTaskID,W as handleEngineResourcePaths,Fe as imagePtrToUint8Array,je as innerVersions,S as isArc,A as isContour,L as isDSImageData,N as isDSRect,b as isDsImageKeyValue,M as isImageTag,B as isLineSegment,w as isObject,O as isOriginalDsImageData,Qt as isPathConfig,F as isPoint,x as isPolygon,P as isQuad,k as isRect,$ as isSimdSupported,Ze as mapPackageRegister,Ve as mapTaskCallBack,J as productNameMap,U as requestResource,xe as resolveDsImageData,We as setBDebug,oi as stringToHtml,Si as vibrate,Pe as worker};
|
|
11
|
+
function e(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 t(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function i(t,i){return t.get(e(t,i))}function s(e,i,s){t(e,i),i.set(e,s)}function n(t,i,s){return t.set(e(t,i),s),s}function o(e,i){t(e,i),i.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}function r(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function c(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?r(Object(i),!0).forEach(function(t){a(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var l,d;!function(e){e[e.SM_SINGLE=0]="SM_SINGLE",e[e.SM_MULTI_UNIQUE=1]="SM_MULTI_UNIQUE"}(l||(l={})),function(e){e[e.RS_SUCCESS=0]="RS_SUCCESS",e[e.RS_CANCELLED=1]="RS_CANCELLED",e[e.RS_FAILED=2]="RS_FAILED"}(d||(d={}));const u=e=>e&&"object"==typeof e&&"function"==typeof e.then,h=(async()=>{})().constructor;function _(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 m(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 g,p,f;"function"==typeof SuppressedError&&SuppressedError,function(e){e[e.BOPM_BLOCK=0]="BOPM_BLOCK",e[e.BOPM_UPDATE=1]="BOPM_UPDATE"}(g||(g={})),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"}(p||(p={})),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"}(f||(f={}));const E="undefined"==typeof self,y="function"==typeof importScripts,I=(()=>{if(!y){if(!E&&document.currentScript){let e=document.currentScript.src,t=e.indexOf("?");if(-1!=t)e=e.substring(0,t);else{let t=e.indexOf("#");-1!=t&&(e=e.substring(0,t))}return e.substring(0,e.lastIndexOf("/")+1)}return"./"}})(),v=e=>{if(null==e&&(e="./"),E||y);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},R=e=>Object.prototype.toString.call(e),C=e=>Array.isArray?Array.isArray(e):"[object Array]"===R(e),T=e=>"number"==typeof e&&!Number.isNaN(e),w=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),S=e=>!(!w(e)||!T(e.x)||!T(e.y)||!T(e.radius)||e.radius<0||!T(e.startAngle)||!T(e.endAngle)),A=e=>!!w(e)&&!!C(e.points)&&0!=e.points.length&&!e.points.some(e=>!F(e)),D=e=>!(!w(e)||!T(e.width)||e.width<=0||!T(e.height)||e.height<=0||!T(e.stride)||e.stride<=0||!("format"in e)||"tag"in e&&!M(e.tag)),b=(e,t)=>"bytes"===e&&"object"==typeof t&&"number"==typeof t.ptr&&"number"==typeof t.length,O=e=>!(!D(e)||!T(e.bytes.length)&&!T(e.bytes.ptr)),L=e=>!!D(e)&&e.bytes instanceof Uint8Array,N=e=>!(!w(e)||!T(e.left)||e.left<0||!T(e.top)||e.top<0||!T(e.right)||e.right<0||!T(e.bottom)||e.bottom<0||e.left>=e.right||e.top>=e.bottom),M=e=>null===e||!!w(e)&&!!T(e.imageId)&&"type"in e,B=e=>!(!w(e)||!F(e.startPoint)||!F(e.endPoint)||e.startPoint.x==e.endPoint.x&&e.startPoint.y==e.endPoint.y),F=e=>!!w(e)&&!!T(e.x)&&!!T(e.y),x=e=>!!w(e)&&!!C(e.points)&&0!=e.points.length&&!e.points.some(e=>!F(e)),P=e=>!!w(e)&&!!C(e.points)&&0!=e.points.length&&4==e.points.length&&!e.points.some(e=>!F(e)),k=e=>!(!w(e)||!T(e.x)||!T(e.y)||!T(e.width)||e.width<0||!T(e.height)||e.height<0),U=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()}),V=e=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(e),G=(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]),a=parseInt(s[e]);return o===a||Number.isNaN(o)&&Number.isNaN(a)?t<n?-1:1:o<a||Number.isNaN(o)&&Number.isInteger(a)?-1:1}return i.length===s.length?0:i.length<s.length?-1:1},W=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,a=e.rootDirectory;if(a&&!a.endsWith("/")&&(a+="/"),"object"==typeof n&&n.isInternal)a&&(o=e[s].version?`${a}${J[s]}@${e[s].version}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`:`${a}${J[s]}/${"dcvData"===s?"":"dist/"}${"ddv"===s?"engine":""}`);else{const i=/^@engineRootDirectory(\/?)/;if("string"==typeof o&&(o=o.replace(i,a||"")),"object"==typeof o&&"dwt"===s){const n=e[s].resourcesPath,o=e[s].serviceInstallerLocation;t[s]={resourcesPath:n.replace(i,a||""),serviceInstallerLocation:o.replace(i,a||"")};continue}}t[s]=v(o)}return t},j=async(e,t,i)=>await new Promise(async(s,n)=>{try{const n=t.split(".");let o=n[n.length-1];const a=await q(`image/${o}`,e);n.length<=1&&(o="png");const r=new File([a],t,{type:`image/${o}`});if(i){const e=URL.createObjectURL(r),i=document.createElement("a");i.href=e,i.download=t,i.click()}s(r)}catch(e){n()}}),Z=e=>{L(e)&&(e=z(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},H=(e,t)=>{L(t)&&(t=z(t));const i=Z(t);let s=new Image,n=i.toDataURL(e);return s.src=n,s},q=async(e,t)=>{L(t)&&(t=z(t));const i=Z(t);if("image/bmp"===e){const e=i.getContext("2d"),t=Y(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)})},Y=e=>{const t=e.width,i=e.height,s=e.data,n=4*Math.floor((24*t+31)/32),o=n*i,a=54+o,r=new ArrayBuffer(a),c=new DataView(r);c.setUint16(0,19778,!0),c.setUint32(2,a,!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],a=s[n+1],r=s[n+2];c.setUint8(l++,r),c.setUint8(l++,a),c.setUint8(l++,o)}for(let e=0;e<d;e++)c.setUint8(l++,0)}return r},z=e=>{let t,i=e.bytes;if(!(i&&i instanceof Uint8Array))throw Error("Parameter type error");if(Number(e.format)===f.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)===f.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)===f.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)===f.IPF_BINARY_8||Number(e.format)===f.IPF_BINARY_8_INVERTED){const s=i.length,n=e.width,o=e.height,a=e.stride;t=new Uint8ClampedArray(n*o*4);for(let e=0;e<s;e++){let s=i[e],o=e%a,r=Math.floor(e/a);for(let e=0;e<8;e++){let i=o+e,a=4*(r*n+i);if(i>=n)break;t[a]=t[a+1]=t[a+2]=(128&s)/128*255,t[a+3]=255,s<<=1}}}else if(Number(e.format)===f.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)===f.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),f.IPF_BINARY_8_INVERTED;return new ImageData(t,e.width,e.height)},$=()=>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])),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:f.IPF_ABGR_8888}}finally{URL.revokeObjectURL(t)}},X=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)),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:o,tagLength:128},n,i.encode(e)),r=new Uint8Array(o.length+a.byteLength);return r.set(o),r.set(new Uint8Array(a),o.length),btoa(String.fromCharCode.apply(null,r))},Q=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),a=new TextEncoder,r=await crypto.subtle.importKey("raw",a.encode(t),"PBKDF2",!1,["deriveKey"]),c=await crypto.subtle.deriveKey({name:"PBKDF2",salt:a.encode("salt-for-key-derivation"),iterations:1e5,hash:"SHA-256"},r,{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)},J={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 ee,te,ie,se,ne,oe,ae,re;let ce,le,de,ue,he,_e=class e{get _isFetchingStarted(){return _(this,ne,"f")}constructor(){ee.add(this),te.set(this,[]),ie.set(this,1),se.set(this,g.BOPM_BLOCK),ne.set(this,!1),oe.set(this,void 0),ae.set(this,p.CCUT_AUTO)}setErrorListener(e){}addImageToBuffer(e){var t;if(!L(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(_(this,te,"f").length>=_(this,ie,"f"))switch(_(this,se,"f")){case g.BOPM_BLOCK:break;case g.BOPM_UPDATE:if(_(this,te,"f").push(e),w(_(this,oe,"f"))&&T(_(this,oe,"f").imageId)&&1==_(this,oe,"f").keepInBuffer)for(;_(this,te,"f").length>_(this,ie,"f");){const e=_(this,te,"f").findIndex(e=>{var t;return(null===(t=e.imageTag)||void 0===t?void 0:t.imageId)!==_(this,oe,"f").imageId});_(this,te,"f").splice(e,1)}else _(this,te,"f").splice(0,_(this,te,"f").length-_(this,ie,"f"))}else _(this,te,"f").push(e)}getImage(){if(0===_(this,te,"f").length)return null;let t;if(_(this,oe,"f")&&T(_(this,oe,"f").imageId)){const e=_(this,ee,"m",re).call(this,_(this,oe,"f").imageId);if(e<0)throw new Error(`Image with id ${_(this,oe,"f").imageId} doesn't exist.`);t=_(this,te,"f").slice(e,e+1)[0]}else t=_(this,te,"f").pop();if([f.IPF_RGB_565,f.IPF_RGB_555,f.IPF_RGB_888,f.IPF_ARGB_8888,f.IPF_RGB_161616,f.IPF_ARGB_16161616,f.IPF_ABGR_8888,f.IPF_ABGR_16161616,f.IPF_BGR_888].includes(t.format)){if(_(this,ae,"f")===p.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 f.IPF_RGB_565:case f.IPF_RGB_555:case f.IPF_RGB_888:case f.IPF_RGB_161616:i[e]=t.bytes[3*e+2];break;case f.IPF_ARGB_8888:case f.IPF_ARGB_16161616:i[e]=t.bytes[4*e+2];break;case f.IPF_BGR_888:i[e]=t.bytes[3*e];break;case f.IPF_ABGR_8888:case f.IPF_ABGR_16161616:i[e]=t.bytes[4*e]}t.bytes=i,t.stride=t.width,t.format=f.IPF_GRAYSCALED}else if(_(this,ae,"f")===p.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 f.IPF_RGB_565:case f.IPF_RGB_555:case f.IPF_RGB_888:case f.IPF_RGB_161616:case f.IPF_BGR_888:i[e]=t.bytes[3*e+1];break;case f.IPF_ARGB_8888:case f.IPF_ARGB_16161616:case f.IPF_ABGR_8888:case f.IPF_ABGR_16161616:i[e]=t.bytes[4*e+1]}t.bytes=i,t.stride=t.width,t.format=f.IPF_GRAYSCALED}else if(_(this,ae,"f")===p.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 f.IPF_RGB_565:case f.IPF_RGB_555:case f.IPF_RGB_888:case f.IPF_RGB_161616:i[e]=t.bytes[3*e];break;case f.IPF_ARGB_8888:case f.IPF_ARGB_16161616:i[e]=t.bytes[4*e];break;case f.IPF_BGR_888:i[e]=t.bytes[3*e+2];break;case f.IPF_ABGR_8888:case f.IPF_ABGR_16161616:i[e]=t.bytes[4*e+2]}t.bytes=i,t.stride=t.width,t.format=f.IPF_GRAYSCALED}}else[f.IPF_NV21,f.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=>T(e)))(e))throw new TypeError("Invalid 'imageId'.");if(void 0!==t&&"[object Boolean]"!==R(t))throw new TypeError("Invalid 'keepInBuffer'.");m(this,oe,{imageId:e,keepInBuffer:t},"f")}_resetNextReturnedImage(){m(this,oe,null,"f")}hasImage(e){return _(this,ee,"m",re).call(this,e)>=0}startFetching(){m(this,ne,!0,"f")}stopFetching(){m(this,ne,!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(m(this,ie,e,"f");_(this,te,"f")&&_(this,te,"f").length>e;)_(this,te,"f").shift()}getMaxImageCount(){return _(this,ie,"f")}getImageCount(){return _(this,te,"f").length}clearBuffer(){_(this,te,"f").length=0}isBufferEmpty(){return 0===_(this,te,"f").length}setBufferOverflowProtectionMode(e){m(this,se,e,"f")}getBufferOverflowProtectionMode(){return _(this,se,"f")}setColourChannelUsageType(e){m(this,ae,e,"f")}getColourChannelUsageType(){return _(this,ae,"f")}};te=new WeakMap,ie=new WeakMap,se=new WeakMap,ne=new WeakMap,oe=new WeakMap,ae=new WeakMap,ee=new WeakSet,re=function(e){if("number"!=typeof e)throw new TypeError("Invalid 'imageId'.");return _(this,te,"f").findIndex(t=>{var i;return(null===(i=t.imageTag)||void 0===i?void 0:i.imageId)===e})},"undefined"!=typeof navigator&&(ce=navigator,le=ce.userAgent,de=ce.platform,ue=ce.mediaDevices),function(){if(!E){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:ce.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:de,search:"Win"},Mac:{str:de},Linux:{str:de}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let o=n.str||le,a=n.search||t,r=n.verStr||le,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=o.indexOf(a)){i=t;for(let e of c){let t=r.indexOf(e);if(-1!=t){s=parseFloat(r.substring(t+e.length+1));break}}break}}for(let e in t){const i=t[e]||{};let s=i.str||le,o=i.search||e;if(-1!=s.indexOf(o)){n=e;break}}"Linux"==n&&-1!=le.indexOf("Windows NT")&&(n="HarmonyOS"),he={browser:i,version:s,OS:n}}E&&(he={browser:"ssr",version:0,OS:"ssr"})}();const me="undefined"!=typeof WebAssembly&&le&&!(/Safari/.test(le)&&!/Chrome/.test(le)&&/\(.+\s11_2_([2-6]).*\)/.test(le)),ge=!("undefined"==typeof Worker),pe=!(!ue||!ue.getUserMedia),fe=async()=>{let e=!1;if(pe)try{(await ue.getUserMedia({video:!0})).getTracks().forEach(e=>{e.stop()}),e=!0}catch(e){}return e};var Ee,ye,Ie,ve,Re,Ce,Te,we,Se;"Chrome"===he.browser&&he.version>66||"Safari"===he.browser&&he.version>13||"OPR"===he.browser&&he.version>43||"Edge"===he.browser&&he.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"}(Ee||(Ee={})),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"}(ye||(ye={})),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"}(Ie||(Ie={})),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"}(ve||(ve={})),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"}(Re||(Re={})),function(e){e[e.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",e[e.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(Ce||(Ce={})),function(e){e[e.PDFRM_VECTOR=1]="PDFRM_VECTOR",e[e.PDFRM_RASTER=2]="PDFRM_RASTER",e[e.PDFRM_MULTIMODAL=3]="PDFRM_MULTIMODAL"}(Te||(Te={})),function(e){e[e.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",e[e.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(we||(we={})),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"}(Se||(Se={}));const Ae={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 De,be,Oe,Le,Ne,Me,Be;!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"}(De||(De={})),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"}(be||(be={})),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"}(Oe||(Oe={})),function(e){e[e.ICDM_NEAR=0]="ICDM_NEAR",e[e.ICDM_FAR=1]="ICDM_FAR"}(Le||(Le={})),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"}(Ne||(Ne={})),function(e){e[e.MU_PIXEL=0]="MU_PIXEL",e[e.MU_PERCENTAGE=1]="MU_PERCENTAGE"}(Me||(Me={})),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"}(Be||(Be={}));const Fe=async e=>await new Promise((t,i)=>{let s=Ue();Ve[s]=async e=>{if(e.success)return t(e.u8);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},Pe.postMessage({type:"imagePtrToUint8Array",id:s,body:{data:e}})}),xe=async e=>await new Promise((t,i)=>{let s=Ue();Ve[s]=async e=>{if(e.success)return t(e.result);{const t=Error(e.message);e.stack&&(t.stack=e.stack),i(t)}},Pe.postMessage({type:"resolveDsImageData",id:s,body:{point:e}})});let Pe,ke=0;const Ue=()=>ke++,Ve={};let Ge=!1;const We=e=>{Ge=e,Pe&&Pe.postMessage({type:"setBDebug",body:{value:e}})},je={},Ze={},He={core:{version:"4.6.30-dev-20260824140325",path:I,isInternal:!0}},qe=new class extends h{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){var t=this;let i;this._task=e,u(e)?i=e:"function"==typeof e&&(i=new h(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(u(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};let Ye=5;"undefined"!=typeof navigator&&(Ye=navigator.hardwareConcurrency?Math.max(navigator.hardwareConcurrency-1,5):5),Ve[-3]=async e=>{ze.onWasmLoadProgressChanged&&ze.onWasmLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class ze{static get engineResourcePaths(){return He}static set engineResourcePaths(e){Object.assign(He,e)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _bDebug(){return Ge}static set _bDebug(e){We(e)}static get _workerName(){return`${ze._bundleEnv.toLowerCase()}.bundle.worker.js`}static get wasmLoadOptions(){return ze._wasmLoadOptions}static set wasmLoadOptions(e){if("number"==typeof e.pthreadPoolSize&&e.pthreadPoolSize<0)throw new Error(`Invalid thread count parameter ${e.pthreadPoolSize}.`);Object.assign(ze._wasmLoadOptions,e)}static isModuleLoaded(){return!!(null==qe?void 0:qe.isFulfilled)}static async loadWasm(){return await async function(){qe.isEmpty&&(qe.task=async function(e,t){const i=W(He),s={engineResourcePaths:i,_bundleEnv:ze._bundleEnv,wasmLoadOptions:ze.wasmLoadOptions};let n=i[`${ze._bundleEnv.toLowerCase()}Bundle`]+ze._workerName;n.startsWith(location.origin)||(n=await fetch(n).then(e=>e.blob()).then(e=>URL.createObjectURL(e))),Pe=new Worker(n),Pe.onerror=e=>{const i=new Error(e.message);t(i)},Pe.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":Ge&&(null===(t=ze._onLog)||void 0===t||t.call(ze,i.message));break;case"warning":console.warn(i.message);break;case"task":try{Ve[n]&&(Ve[n](o),delete Ve[n])}catch(e){throw delete Ve[n],e}break;case"event":try{Ve[n](o)}catch(e){throw e}break;default:console.log(e)}}),s.bd=Ge,s.dm=location.origin.startsWith("http")?location.origin:"https://localhost";const o=ke++;Ve[o]=i=>{if(i.success)Object.assign(je,i.versions),"{}"!==JSON.stringify(i.versions)&&(ze._versions=i.versions),ze.loadedWasmType=i.loadedWasmType,ze._isNoOnnx=i.isNoOnnx,e(void 0);else{const e=Error(i.message);i.stack&&(e.stack=i.stack),t(e)}},Pe.postMessage({type:"loadWasm",id:o,body:s})}),await qe}()}static async detectEnvironment(){return await async function(){return{wasm:me,worker:ge,getUserMedia:pe,camera:await fe(),browser:he.browser,version:he.version,OS:he.OS}}()}static async getModuleVersion(){return await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e(i.versions);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.postMessage({type:"getModuleVersion",id:i})})}static getVersion(){return`4.6.30-dev-20260824140325(Worker: ${je.core&&je.core.worker||"Not Loaded"}, Wasm: ${je.core&&je.core.wasm||"Not Loaded"})`}static enableLogging(){_e._onLog=console.log,ze._onLog=console.log}static disableLogging(){_e._onLog=null,ze._onLog=null}static async cfd(e){return await new Promise((t,i)=>{let s=Ue();Ve[s]=async function(e){if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},Pe.postMessage({type:"cfd",id:s,body:{count:e}})})}}ze._bSupportDce4Module=-1,ze._bSupportIRTModule=-1,ze._versions=null,ze._isNoOnnx=!1,ze._onLog=console.log,ze._bundleEnv="DCV",ze._wasmLoadOptions={wasmType:Be.AUTO,pthreadPoolSize:Ye},ze.loadedWasmType=Be.ML_SIMD_PTHREAD,ze.browserInfo=he;var $e={license:"",scanMode:l.SM_SINGLE,templateFilePath:void 0,utilizedTemplateNames:{single:"ReadBarcodes_SpeedFirst",multi_unique:"ReadBarcodes_SpeedFirst",image:"ReadBarcodes_ReadRateFirst"},engineResourcePaths:ze.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 Ke=e=>e&&"object"==typeof e&&"function"==typeof e.then,Xe=(async()=>{})().constructor;class Qe 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){var t=this;let i;this._task=e,Ke(e)?i=e:"function"==typeof e&&(i=new Xe(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(Ke(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}var Je,et;const tt=e=>e&&"object"==typeof e&&"function"==typeof e.then,it=(async()=>{})().constructor;let st=class extends it{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){var t=this;let i;this._task=e,tt(e)?i=e:"function"==typeof e&&(i=new it(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(tt(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}},nt=class{constructor(e){a(this,"_cvr",void 0),this._cvr=e}async getMaxBufferedItems(){return await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e(i.count);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.postMessage({type:"cvr_getMaxBufferedItems",id:i,instanceID:this._cvr._instanceID})})}async setMaxBufferedItems(e){return await new Promise((t,i)=>{let s=Ue();Ve[s]=async function(e){if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},Pe.postMessage({type:"cvr_setMaxBufferedItems",id:s,instanceID:this._cvr._instanceID,body:{count:e}})})}async getBufferedCharacterItemSet(){return await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e(i.itemSet);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.postMessage({type:"cvr_getBufferedCharacterItemSet",id:i,instanceID:this._cvr._instanceID})})}};const ot={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},at={onTaskResultsReceived:()=>{},isFilter:!0},rt=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 ct=class{constructor(e){a(this,"_cvr",void 0),a(this,"_irrRegistryState",JSON.parse(JSON.stringify(ot))),a(this,"_intermediateResultReceiverSet",new Set),this._cvr=e}async addResultReceiver(e){if("object"!=typeof e)throw new Error("Invalid receiver.");this._intermediateResultReceiverSet.add(e),rt(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=Ue();Ve[n]=async function(t){if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,s(e)}},Pe.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),rt(this),await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.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 rt(this),await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})})}getOriginalImage(){return this._cvr.provideDsImage}};const lt="undefined"==typeof self,dt="function"==typeof importScripts,ut=(()=>{if(!dt){if(!lt&&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"./"}})();ze.engineResourcePaths.cvr={version:"3.6.30-dev-20260824140332",path:ut,isInternal:!0},Ze.cvr={};let ht=class{static getVersion(){return this._version}};function _t(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}_t(e.referencedItem,t)}}function mt(e){if(e.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}function gt(e){return{type:Ee.CRIT_ORIGINAL_IMAGE,referenceItem:null,targetROIDefName:"",taskName:"",imageData:e,toCanvas:()=>Z(e),toImage:t=>H(t,e),toBlob:t=>q(t,e)}}function pt(e){let t=!1;const i=[Ie.EC_UNSUPPORTED_JSON_KEY_WARNING,Ie.EC_LICENSE_AUTH_QUOTA_EXCEEDED,Ie.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 ft(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 Et(e){return Math.abs(e)<1e-6?0:e<0?-1:1}function yt(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(ht,"_version",`3.6.30-dev-20260824140332(Worker: ${null===(et=je.cvr)||void 0===et?void 0:et.worker}, Wasm: loading...`),BigInt(0),BigInt("0xFFFFFFFEFFFFFFFF"),BigInt(4265345023);const It=BigInt(3147775),vt=(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)),Rt=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){var t=this;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 function(e){if(!t.isSupportDCEModule)return;let i=t.cameraEnhancer;(4&i._dceEnhancedFeatures||16&i._dceEnhancedFeatures||64&i._dceEnhancedFeatures)&&(0!==ze.bSupportDce4Module?(t.isSupportDCEModule=!1,console.warn("Warning: The license required for Enhanced Features was not found.")):(!t.consumeTime||Date.now()-t.consumeTime>1e4)&&(ze.cfd(1),t.consumeTime=Date.now()));const s=e.intermediateResultUnits;if(!i.isOpen()||i.isPaused())return;const n=i.getVisibleAreaInVideoXY({isConsiderRegionBox:!0});if(isNaN(n.x)||isNaN(n.y)||isNaN(n.width)||isNaN(n.height))return;let o=!1,a=!1;for(let e of s){if(e.unitType===Ae.IRUT_DECODED_BARCODES&&e.decodedBarcodes.length){o=!0;break}e.unitType===Ae.IRUT_LOCALIZED_BARCODES&&e.localizedBarcodes.length&&(a=!0)}if(16&i._dceEnhancedFeatures||4&i._dceEnhancedFeatures)if(o)t._autoZoomParameters.autoZoomInFrameArray.length=0,t._autoZoomParameters.autoZoomOutFrameCount=0,t._autoZoomParameters.frameArrayInIdealZoom.length=0,t._autoZoomParameters.autoFocusFrameArray.length=0;else{const o=async function(e){await i.setZoom(e)},r=async function(e){await i.setFocus(e)};if(a){n.x,n.y;const a=n.width,c=n.height,l=n.width,d=n.height;let u;{let e,o,a,r,c;{const e=i.video.videoWidth*(1-t._autoZoomParameters.autoZoomDetectionArea)/2,s=i.video.videoWidth*(1+t._autoZoomParameters.autoZoomDetectionArea)/2,n=s,o=e,a=i.video.videoHeight*(1-t._autoZoomParameters.autoZoomDetectionArea)/2,r=a,l=i.video.videoHeight*(1+t._autoZoomParameters.autoZoomDetectionArea)/2;c=[{x:e,y:a},{x:s,y:r},{x:n,y:l},{x:o,y:l}]}const h=[];{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 a=e[o],r=e[(o+1)%n];if(ft(a,r,{x:t,y:i}))return!0;Et(a.y-i)>0!=Et(r.y-i)>0&&Et(t-(i-a.y)*(a.x-r.x)/(a.y-r.y)-a.x)<0&&(s=!s)}return s}(t,e.x,e.y)},s=(e,t)=>!!(yt([e[0],e[1]],[e[2],e[3]],[t[0].x,t[0].y],[t[1].x,t[1].y])||yt([e[0],e[1]],[e[2],e[3]],[t[1].x,t[1].y],[t[2].x,t[2].y])||yt([e[0],e[1]],[e[2],e[3]],[t[2].x,t[2].y],[t[3].x,t[3].y])||yt([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 s)if(t.unitType===Ae.IRUT_LOCALIZED_BARCODES)for(let i of t.localizedBarcodes)i&&e(c,i.location.points.map(e=>({x:e.x+n.x,y:e.y+n.y})))&&h.push(i)}if(!h.length)return;let _;if(h.length){let e=h.filter(e=>e.possibleFormats==vt||e.possibleFormats==Rt);if(e.length||(e=h.filter(e=>e.possibleFormats==It),e.length||(e=h)),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-l/2)*(i-l/2)+(s-d/2)*(s-d/2)};_=e[0];let i=t(_);if(1!=e.length)for(let s=1;s<e.length;s++){const n=t(e[s]);(e[s].confidence>1.1*_.confidence||e[s].confidence>.9*_.confidence&&n<i)&&(_=e[s],i=n)}}}if(_){const t=_.location.points;e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),o=Math.max(t[0].x,t[1].x,t[2].x,t[3].x),a=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),u={points:[{x:e,y:a},{x:o,y:a},{x:o,y:r},{x:e,y:r}],result:_}}}if(!u)return;if(t._autoZoomParameters.autoZoomOutFrameCount=0,16&i._dceEnhancedFeatures){const s=t._autoZoomParameters.autoZoomIdealArea[1];let n=(1-t._autoZoomParameters.autoZoomTargetBorder)/2;const l=u.points[0].x/a,d=(a-u.points[2].x)/a,h=u.points[0].y/c,_=(c-u.points[2].y)/c;if(l>s&&d>s&&h>s&&_>s&&u.result.moduleSize<t._autoZoomParameters.autoZoomInIdealModuleSize){if(t._autoZoomParameters.autoZoomInFrameArray.push(!0),t._autoZoomParameters.autoZoomInFrameArray.splice(0,t._autoZoomParameters.autoZoomInFrameArray.length-t._autoZoomParameters.autoZoomInFrameLimit[0]),t._autoZoomParameters.frameArrayInIdealZoom.length=0,4&i._dceEnhancedFeatures&&r({mode:"continuous"}).catch(()=>{}),t._autoZoomParameters.autoZoomInFrameArray.filter(e=>!0===e).length>=t._autoZoomParameters.autoZoomInFrameLimit[1]){t._autoZoomParameters.autoZoomInFrameArray.length=0;const s=[(.5-n)/(.5-l),(.5-n)/(.5-d),(.5-n)/(.5-h),(.5-n)/(.5-_)].filter(e=>e>0),a=Math.min(...s,t._autoZoomParameters.autoZoomInIdealModuleSize/u.result.moduleSize),r=i.getZoomSettings().factor;let c=Math.max(Math.pow(r*a,1/t._autoZoomParameters.autoZoomInMaxTimes),t._autoZoomParameters.autoZoomInMinStep);c=Math.min(c,a);let m=r*c;m=Math.max(i._dceAutoZoomRange.min,m),m=Math.min(i._dceAutoZoomRange.max,m);try{await o({factor:m})}catch(e){const t=e.message||e;console.warn(t)}i._framePipeline&&(i._framePipeline._data=null)}}else if(t._autoZoomParameters.autoZoomInFrameArray.length=0,t._autoZoomParameters.frameArrayInIdealZoom.push(!0),t._autoZoomParameters.frameArrayInIdealZoom.splice(0,t._autoZoomParameters.frameArrayInIdealZoom.length-t._autoZoomParameters.frameLimitInIdealZoom[0]),t._autoZoomParameters.frameArrayInIdealZoom.filter(e=>!0===e).length>=t._autoZoomParameters.frameLimitInIdealZoom[1]&&(t._autoZoomParameters.frameArrayInIdealZoom.length=0,4&i._dceEnhancedFeatures)){const t=u.points;try{await r({mode:"manual",area:{centerPoint:{x:(t[0].x+t[2].x)/2+"px",y:(t[0].y+t[2].y)/2+"px"},width:t[2].x-t[0].x+"px",height:t[2].y-t[0].y+"px"}})}catch(e){const t=e.message||e;console.warn(t)}i._framePipeline&&(i._framePipeline._data=null)}}if(!(16&i._dceEnhancedFeatures)&&4&i._dceEnhancedFeatures&&(t._autoZoomParameters.autoFocusFrameArray.push(!0),t._autoZoomParameters.autoFocusFrameArray.splice(0,t._autoZoomParameters.autoFocusFrameArray.length-t._autoZoomParameters.autoFocusFrameLimit[0]),t._autoZoomParameters.autoFocusFrameArray.filter(e=>!0===e).length>=t._autoZoomParameters.autoFocusFrameLimit[1])){t._autoZoomParameters.autoFocusFrameArray.length=0;try{const e=u.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)}i._framePipeline&&(i._framePipeline._data=null)}}else{if(16&i._dceEnhancedFeatures){if(t._autoZoomParameters.autoZoomInFrameArray.push(!1),t._autoZoomParameters.autoZoomInFrameArray.splice(0,t._autoZoomParameters.autoZoomInFrameArray.length-t._autoZoomParameters.autoZoomInFrameLimit[0]),t._autoZoomParameters.autoZoomOutFrameCount++,t._autoZoomParameters.frameArrayInIdealZoom.push(!1),t._autoZoomParameters.frameArrayInIdealZoom.splice(0,t._autoZoomParameters.frameArrayInIdealZoom.length-t._autoZoomParameters.frameLimitInIdealZoom[0]),t._autoZoomParameters.autoZoomOutFrameCount>=t._autoZoomParameters.autoZoomOutFrameLimit){t._autoZoomParameters.autoZoomOutFrameCount=0;const s=i.getZoomSettings().factor;let n=s-Math.max((s-1)*t._autoZoomParameters.autoZoomOutStepRate,t._autoZoomParameters.autoZoomOutMinStep);n=Math.max(i._dceAutoZoomRange.min,n),n=Math.min(i._dceAutoZoomRange.max,n);try{await o({factor:n})}catch(e){const t=e.message||e;console.warn(t)}i._framePipeline&&(i._framePipeline._data=null)}4&i._dceEnhancedFeatures&&r({mode:"continuous"}).catch(()=>{})}!(16&i._dceEnhancedFeatures)&&4&i._dceEnhancedFeatures&&(t._autoZoomParameters.autoFocusFrameArray.length=0,r({mode:"continuous"}).catch(()=>{}))}}}),a(this,"isDce",!0),this.cameraEnhancer=e}};var Tt,wt;!function(e){e[e.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",e[e.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}(Tt||(Tt={})),Ve[-2]=async e=>{Gt.onDataLoadProgressChanged&&Gt.onDataLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};var St=new WeakMap,At=new WeakMap,Dt=new WeakMap,bt=new WeakMap,Ot=new WeakMap,Lt=new WeakMap,Nt=new WeakMap,Mt=new WeakMap,Bt=new WeakMap,Ft=new WeakMap,xt=new WeakMap,Pt=new WeakMap,kt=new WeakMap,Ut=new WeakMap,Vt=new WeakSet;let Gt=class t{constructor(){o(this,Vt),a(this,"maxImageSideLength",["iPhone","Android","HarmonyOS"].includes(ze.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),s(this,St,null),s(this,At,null),s(this,Dt,null),s(this,bt,null),s(this,Ot,null),s(this,Lt,new Set),s(this,Nt,new Set),s(this,Mt,new Set),s(this,Bt,500),s(this,Ft,0),s(this,xt,0),s(this,Pt,0),s(this,kt,!1),s(this,Ut,!1),a(this,"_singleFrameModeCallbackBind",this._singleFrameModeCallback.bind(this))}get disposed(){return i(Ut,this)}get isCapturing(){return this._isCapturing}static async createInstance(e=!0){if(!Ze.license)throw Error("The `license` module cannot be found.");return await Ze.license.dynamsoft(),await ze.loadWasm(),await new Promise((i,s)=>{const o=new t,a=Ue();Ve[a]=async function(e){var a;e.success?(o._instanceID=e.instanceID,null!==(a=t._fr4DisposeCvrWasm)&&void 0!==a&&a.register(o,e.instanceID,o),ht._version=`3.6.30-dev-20260824140332(Worker: ${je.cvr.worker}, Wasm: ${e.version})`,n(kt,o,!0),n(bt,o,o.getIntermediateResultManager()),n(kt,o,!1),i(o)):pt({message:e.message,rj:s,stack:e.stack,functionName:"createInstance"})},Pe.postMessage({type:"cvr_createInstance",id:a,body:{loadPresetTemplates:e}})})}static async appendDLModelBuffer(e,t){return await ze.loadWasm(),ze._isNoOnnx?Promise.reject("Model not supported in the current environment."):await new Promise((i,s)=>{const n=Ue(),o=W(ze.engineResourcePaths);let a;Ve[n]=async function(e){if(e.success){const t=JSON.parse(e.response);if(0!==t.errorCode&&pt({message:t.errorString?t.errorString:"Append Model Buffer Failed.",rj:s,errorCode:t.errorCode,functionName:"appendDLModelBuffer"}))return;return i(t)}pt({message:e.message,rj:s,stack:e.stack,functionName:"appendDLModelBuffer"})},t?(a=new URL(t,location.href).href,a=a.endsWith("/")?a:a+"/"):"DCV"===ze._bundleEnv?a=o.dcvData+"models/":"DBR"===ze._bundleEnv&&(a=o.dbrBundle+"models/");let r=Array.isArray(e)?e:[e];r=r.map(e=>e.replace(/\.data$/i,"")),Pe.postMessage({type:"cvr_appendDLModelBuffer",id:n,body:{modelNames:r,path:a}})})}static async clearDLModelBuffers(){return await new Promise((e,t)=>{const i=Ue();Ve[i]=async function(i){if(i.success)return e();pt({message:i.message,rj:t,stack:i.stack,functionName:"clearDLModelBuffers"})},Pe.postMessage({type:"cvr_clearDLModelBuffers",id:i})})}async _singleFrameModeCallback(){const t=i(St,this)._singleFrameModeResultForDcv;if(!t)return;e(Vt,this,Wt).call(this,t);const s={bytes:new Uint8Array(t.bytes),width:t.width,height:t.height,stride:t.stride,format:t.format,imageTag:t.imageTag},n=await this.capture(s,this._templateName);n.originalImageTag=t.imageTag,i(St,this)._cameraView._capturedResultReceiver.onCapturedResultReceived(n,{isDetectVerifyOpen:!1,isNormalizeVerifyOpen:!1,isBarcodeVerifyOpen:!1,isLabelVerifyOpen:!1}),e(Vt,this,Ht).call(this,n),i(St,this)._singleFrameModeResultForDcv=null}setInput(e){if(mt(this),!this.isCapturing)if(n(St,this,e),null!=e&&e.isCameraEnhancer){if(this._enhancedFeaturesIrr)return;this._enhancedFeaturesIrr=new Ct(e),i(bt,this).addResultReceiver(this._enhancedFeaturesIrr)}else i(bt,this).removeResultReceiver(this._enhancedFeaturesIrr),this._enhancedFeaturesIrr=null}getInput(){return i(St,this)}addImageSourceStateListener(e){if(mt(this),"object"!=typeof e)return console.warn("Invalid ISA state listener.");e&&Object.keys(e)&&i(Nt,this).add(e)}removeImageSourceStateListener(e){return mt(this),i(Nt,this).delete(e)}async addResultReceiver(e){if(mt(this),"object"!=typeof e)throw new Error("Invalid receiver.");e&&Object.keys(e).length&&(i(Lt,this).add(e),await this._setCrrRegistry())}async removeResultReceiver(e){mt(this),i(Lt,this).delete(e),await this._setCrrRegistry()}async removeAllResultReceivers(){mt(this),i(Lt,this).clear(),await this._setCrrRegistry()}async _setCrrRegistry(){const e={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onProcessedDocumentResultReceived:!1,onParsedResultsReceived:!1};for(let t of i(Lt,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=Ue();return await new Promise((i,s)=>{Ve[t]=async function(e){e.success?i():pt({message:e.message,rj:s,stack:e.stack,functionName:"addResultReceiver"})},Pe.postMessage({type:"cvr_setCrrRegistry",id:t,instanceID:this._instanceID,body:{receiver:JSON.stringify(e)}})})}async addResultFilter(e){if(mt(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.");i(Mt,this).add(e),e._dynamsoft(),await this._handleFilterUpdate()}async removeResultFilter(e){mt(this),i(Mt,this).delete(e),await this._handleFilterUpdate()}async removeAllResultFilters(){mt(this),i(Mt,this).clear(),await this._handleFilterUpdate()}async _handleFilterUpdate(){if(i(bt,this).removeResultReceiver(at),0===i(Mt,this).size){this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1;const t={[Ee.CRIT_BARCODE]:!1,[Ee.CRIT_TEXT_LINE]:!1,[Ee.CRIT_DETECTED_QUAD]:!1,[Ee.CRIT_DESKEWED_IMAGE]:!1,[Ee.CRIT_ENHANCED_IMAGE]:!1},i={[Ee.CRIT_BARCODE]:!1,[Ee.CRIT_TEXT_LINE]:!1,[Ee.CRIT_DETECTED_QUAD]:!1,[Ee.CRIT_DESKEWED_IMAGE]:!1,[Ee.CRIT_ENHANCED_IMAGE]:!1};return await e(Vt,this,qt).call(this,t),void await e(Vt,this,Yt).call(this,i)}for(let t of i(Mt,this))this._isOpenBarcodeVerify=t.isResultCrossVerificationEnabled(Ee.CRIT_BARCODE),this._isOpenLabelVerify=t.isResultCrossVerificationEnabled(Ee.CRIT_TEXT_LINE),this._isOpenDetectVerify=t.isResultCrossVerificationEnabled(Ee.CRIT_DETECTED_QUAD),this._isOpenNormalizeVerify=t.isResultCrossVerificationEnabled(Ee.CRIT_DESKEWED_IMAGE),t.isLatestOverlappingEnabled(Ee.CRIT_BARCODE)&&([...i(bt,this)._intermediateResultReceiverSet.values()].find(e=>e.isFilter)||i(bt,this).addResultReceiver(at)),await e(Vt,this,qt).call(this,t.verificationEnabled),await e(Vt,this,Yt).call(this,t.duplicateFilterEnabled),await e(Vt,this,zt).call(this,t.duplicateForgetTime),await e(Vt,this,$t).call(this,t.crossVerificationCriteria)}async startCapturing(e){var s,o=this;if(mt(this),this.isCapturing)return;if(!i(St,this))throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");e||(e=t._defaultTemplate);for(let e of i(Mt,this))await this.addResultFilter(e);const a=W(ze.engineResourcePaths);if(i(Dt,this)&&i(Dt,this).isPending)return i(Dt,this);const r=n(Pt,this,(s=i(Pt,this),++s));return n(Dt,this,new st((t,s)=>{if(this.disposed)return;const n=Ue();Ve[n]=async function(n){i(Dt,o)&&!i(Dt,o).isFulfilled&&r===i(Pt,o)&&(n.success?(o._isCapturing=!0,o._templateName=e,void 0!==i(St,o).singleFrameMode&&"disabled"!==i(St,o).singleFrameMode?(i(St,o).on("singleFrameAcquired",o._singleFrameModeCallbackBind),o._singleFrameModeCallback(),t()):(o._isOutputOriginalImage=n.isOutputOriginalImage,o._minImageCaptureInterval=n.minImageCaptureInterval,o._loopReadVideoTimeoutId&&clearTimeout(o._loopReadVideoTimeoutId),o._loopReadVideoTimeoutId=setTimeout(async function(){if(r===i(Pt,o)&&o.isCapturing){-1!==o._minImageCaptureInterval&&i(St,o).startFetching();for(let e of i(Nt,o))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(Tt.ISS_BUFFER_EMPTY);o.barcodeScanLoop(e,r),t()}},0))):pt({message:n.message,rj:s,stack:n.stack,functionName:"startCapturing"}))},Pe.postMessage({type:"cvr_startCapturing",id:n,instanceID:this._instanceID,body:{templateName:e,engineResourcePaths:a}})})),await i(Dt,this)}stopCapturing(){var e;if(mt(this),!i(St,this))return;n(Pt,this,(e=i(Pt,this),++e)),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=null,i(St,this).stopFetching(),this._averageProcessintTimeArray=[],this._isCapturing=!1,this._averageTime=999,n(Dt,this,null),i(St,this).isCameraEnhancer&&i(St,this).off("singleFrameAcquired",this._singleFrameModeCallbackBind);const t=Ue();Pe.postMessage({type:"cvr_stopCapturing",id:t,instanceID:this._instanceID})}async containsTask(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async function(e){if(e.success)return t(JSON.parse(e.tasks));pt({message:e.message,rj:i,stack:e.stack,functionName:"containsTask"})},Pe.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(s,n=i(Pt,this)){var o=this;if(n!==i(Pt,this)||!this.isCapturing)return;if(i(St,this).isBufferEmpty())if(i(St,this).hasNextImageToFetch())for(let e of i(Nt,this))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(Tt.ISS_BUFFER_EMPTY);else for(let e of i(Nt,this))e.onImageSourceStateReceived&&e.onImageSourceStateReceived(Tt.ISS_EXHAUSTED);const a=i(St,this).getImage();if(!a)return i(St,this)._bClosedBecauseOfNotInDOM?void this.stopCapturing():(await new Promise(e=>setTimeout(e,100)),void this.continueLoop(s,n));if(a.imageTag&&Date.now()-a.imageTag.timeStamp>200)return void this.continueLoop(s,n);e(Vt,this,Wt).call(this,a),a._s=!0;const r=Date.now();this._captureInWorker(a,s).then(async function(c){if(n!==i(Pt,o)||!o.isCapturing)return;if(t._onLog&&t._onLog("no js handle time: "+(Date.now()-r)),!o.isCapturing)return void o.continueLoop(s,n);c.originalImageTag=a.imageTag?a.imageTag:null,i(St,o)._capturedResultReceiver&&i(St,o)._cameraView._capturedResultReceiver.onCapturedResultReceived(c,{isDetectVerifyOpen:o._isOpenDetectVerify,isNormalizeVerifyOpen:o._isOpenNormalizeVerify,isBarcodeVerifyOpen:o._isOpenBarcodeVerify,isLabelVerifyOpen:o._isOpenLabelVerify});for(let e of i(Mt,o)){const t=e;t.onOriginalImageResultReceived(c),t.onDecodedBarcodesReceived(c),t.onRecognizedTextLinesReceived(c),t.onProcessedDocumentResultReceived(c),t.onParsedResultsReceived(c)}e(Vt,o,Ht).call(o,c);const l=Date.now();if(o._minImageCaptureInterval>-1&&(5===o._averageProcessintTimeArray.length&&o._averageProcessintTimeArray.shift(),5===o._averageFetchImageTimeArray.length&&o._averageFetchImageTimeArray.shift(),o._averageProcessintTimeArray.push(Date.now()-r),o._averageFetchImageTimeArray.push(a&&a.imageTag?a.imageTag.timeSpent:0),o._averageTime=Math.min(...o._averageProcessintTimeArray)-Math.max(...o._averageFetchImageTimeArray),o._averageTime=o._averageTime>0?o._averageTime:0,t._onLog&&(t._onLog(`minImageCaptureInterval: ${o._minImageCaptureInterval}`),t._onLog(`averageProcessintTimeArray: ${o._averageProcessintTimeArray}`),t._onLog(`averageFetchImageTimeArray: ${o._averageFetchImageTimeArray}`),t._onLog(`averageTime: ${o._averageTime}`))),t._onLog){const e=Date.now()-l;e>10&&t._onLog(`fetch image calculate time: ${e}`)}t._onLog&&t._onLog(`time finish decode: ${Date.now()}`),t._onLog&&t._onLog("main time: "+(Date.now()-r)),t._onLog&&t._onLog("===================================================="),o._loopReadVideoTimeoutId&&clearTimeout(o._loopReadVideoTimeoutId),o._minImageCaptureInterval>0&&o._minImageCaptureInterval>=o._averageTime?o._loopReadVideoTimeoutId=setTimeout(()=>{o.barcodeScanLoop(s,n)},o._minImageCaptureInterval-o._averageTime):o._loopReadVideoTimeoutId=setTimeout(()=>{o.barcodeScanLoop(s,n)},Math.max(o._minImageCaptureInterval,0))}).catch(e=>{n===i(Pt,this)&&(i(St,this).stopFetching(),"platform error"!==e.message&&(e.errorCode&&0===e.errorCode&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{i(St,this).startFetching(),this.barcodeScanLoop(s,n)},Math.max(this._minImageCaptureInterval,1e3))),setTimeout(()=>{if(n===i(Pt,this)){if(!this.onCaptureError)throw e;this.onCaptureError(e)}},0)))})}continueLoop(e,t=i(Pt,this)){t===i(Pt,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:a,height:r,stride:c,format:l}=e,d=Ue();return new Promise((e,u)=>{Ve[d]=async function(t){t.success?e(t.clarity):pt({message:t.message,rj:u,stack:t.stack,functionName:"getClarity"})},Pe.postMessage({type:"cvr_getClarity",id:d,instanceID:this._instanceID,body:{bytes:o,width:a,height:r,stride:c,format:l,bitcount:t,wr:i,hr:s,grayThreshold:n}},[o.buffer])})}async capture(e,i){let s;if(mt(this),i||(i=t._defaultTemplate),L(e))s=await this._captureDsimage(e,i);else if("string"==typeof e)s="data:image/"==e.substring(0,11)?await this._captureBase64(e,i):await this._captureUrl(e,i);else if(e instanceof Blob)s=await this._captureBlob(e,i);else if(e instanceof HTMLImageElement)s=await this._captureImage(e,i);else if(e instanceof HTMLCanvasElement)s=await this._captureCanvas(e,i);else{if(!(e instanceof HTMLVideoElement))throw new TypeError("'capture(imageOrFile, templateName)': Type of 'imageOrFile' should be 'DSImageData', 'Url', 'Base64', 'Blob', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement'.");s=await this._captureVideo(e,i)}return s}async captureMultiPages(s,o="",a){var r=this;mt(this),o||(o=t._defaultTemplate);const c={pages:[],dpi:300};return Object.assign(c,a),await new Promise(async function(t,a){let l;if(l="string"==typeof s?await U(s,"blob"):s,"application/pdf"!==l.type)return void a("Unsupported file type. Only PDF are allowed.");const d=await l.arrayBuffer(),u=new Uint8Array(d),h=Ue();Ve[h]=s=>{if(s.success){var o;for(let t of s.capturedResults)e(Vt,r,jt).call(r,t);e(Vt,r,Zt).call(r,s.intermediateResult);const a=Date.now();a-i(Ft,r)>i(Bt,r)&&null!==s.mliRecord&&(null!==(o=localStorage)&&void 0!==o&&o.setItem("dynamsoft",s.mliRecord),n(Ft,r,a)),t(s.capturedResults)}else pt({message:s.message,rj:a,stack:s.stack,functionName:"captureMultiPages"})},Pe.postMessage({type:"cvr_captureMultiPages",id:h,instanceID:r._instanceID,body:{bytes:u,templateName:o,defaultOptions:c}},[u.buffer])})}async _captureDsimage(e,t){return await this._captureInWorker(e,t)}async _captureUrl(e,t){let i=await U(e,"blob");return await this._captureBlob(i,t)}async _captureBase64(e,t){e=e.substring(e.indexOf(",")+1);let i=atob(e),s=i.length,n=new Uint8Array(s);for(;s--;)n[s]=i.charCodeAt(s);return await this._captureBlob(new Blob([n]),t)}async _captureBlob(e,t){let i=null,s=null;if("undefined"!=typeof createImageBitmap)try{i=await createImageBitmap(e)}catch(e){}i||(s=await async function(t){return await new Promise((i,s)=>{let n=URL.createObjectURL(t),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 s,o,a=e instanceof HTMLImageElement?e.naturalWidth:e.width,r=e instanceof HTMLImageElement?e.naturalHeight:e.height,c=Math.max(a,r);c>this.maxImageSideLength?(n(xt,this,this.maxImageSideLength/c),s=Math.round(a*i(xt,this)),o=Math.round(r*i(xt,this))):(s=a,o=r),i(At,this)||n(At,this,document.createElement("canvas"));const l=i(At,this);return l.width===s&&l.height===o||(l.width=s,l.height=o),l.ctx2d||(l.ctx2d=l.getContext("2d",{willReadFrequently:!0})),l.ctx2d.drawImage(e,0,0,a,r,0,0,s,o),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:f.IPF_ABGR_8888};return await this._captureInWorker(s,t)}async _captureVideo(e,t){if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";let s,o,a=e.videoWidth,r=e.videoHeight,c=Math.max(a,r);c>this.maxImageSideLength?(n(xt,this,this.maxImageSideLength/c),s=Math.round(a*i(xt,this)),o=Math.round(r*i(xt,this))):(s=a,o=r),i(At,this)||n(At,this,document.createElement("canvas"));const l=i(At,this);return l.width===s&&l.height===o||(l.width=s,l.height=o),l.ctx2d||(l.ctx2d=l.getContext("2d",{willReadFrequently:!0})),l.ctx2d.drawImage(e,0,0,a,r,0,0,s,o),await this._captureCanvas(l,t)}async _captureInWorker(s,o){let{bytes:a,width:r,height:c,stride:l,format:d,imageTag:u}=s;const h=Ue();return await new Promise((_,m)=>{this.provideDsImage=s,Ve[h]=o=>{if(o.success){const r=Date.now();t._onLog&&(t._onLog(`get result time from worker: ${r}`),t._onLog("worker to main time consume: "+(r-o.workerReturnMsgTime)));try{var a;e(Vt,this,jt).call(this,o.capturedResult,s),s.bytes=o.bytes,o._s||n(xt,this,0),e(Vt,this,Zt).call(this,o.intermediateResult,u);const t=Date.now();return t-i(Ft,this)>i(Bt,this)&&null!==o.mliRecord&&(null!==(a=localStorage)&&void 0!==a&&a.setItem("dynamsoft",o.mliRecord),n(Ft,this,t)),_(o.capturedResult)}catch(e){pt({message:e.message,rj:m,stack:e.stack,functionName:"capture"})}}else pt({message:o.message,rj:m,stack:o.stack,functionName:"capture"})},t._onLog&&t._onLog(`send buffer to worker: ${Date.now()}`);const g=s.hasOwnProperty("_s")?s._s:this._s;Pe.postMessage({type:"cvr_capture",id:h,instanceID:this._instanceID,body:{bytes:a,width:r,height:c,stride:l,format:d,templateName:o||"",dynamsoft:this._dynamsoft,_s:g}},[a.buffer])})}async initSettings(e){var i=this;if(mt(this),e&&["string","object"].includes(typeof e))return"string"==typeof e?e.trimStart().startsWith("{")||(e=await U(e,"text")):"object"==typeof e&&(e=JSON.stringify(e)),await new Promise((s,n)=>{const o=Ue();Ve[o]=async function(o){if(o.success){const a=JSON.parse(o.response);if(0!==a.errorCode&&pt({message:a.errorString?a.errorString:"Init Settings Failed.",rj:n,errorCode:a.errorCode,functionName:"initSettings"}))return;const r=JSON.parse(e);return i._isOutputOriginalImage=!!r.CaptureVisionTemplates[0].OutputOriginalImage,t._defaultTemplate=r.CaptureVisionTemplates[0].Name,s(a)}pt({message:o.message,rj:n,stack:o.stack,functionName:"initSettings"})},Pe.postMessage({type:"cvr_initSettings",id:o,instanceID:this._instanceID,body:{settings:e}})});console.error("Invalid template.")}async outputSettings(e,t){return mt(this),await new Promise((i,s)=>{const n=Ue();Ve[n]=async function(e){if(e.success){const t=JSON.parse(e.response);if(0!==t.errorCode&&pt({message:t.errorString,rj:s,errorCode:t.errorCode,functionName:"outputSettings"}))return;return i(JSON.parse(t.data))}pt({message:e.message,rj:s,stack:e.stack,functionName:"outputSettings"})},Pe.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 mt(this),await new Promise((e,t)=>{const i=Ue();Ve[i]=async function(i){if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&pt({message:s.errorString,rj:t,errorCode:s.errorCode,functionName:"getTemplateNames"}))return;return e(JSON.parse(s.data))}pt({message:i.message,rj:t,stack:i.stack,functionName:"getTemplateNames"})},Pe.postMessage({type:"cvr_getTemplateNames",id:i,instanceID:this._instanceID})})}async getSimplifiedSettings(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async function(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&&pt({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)}pt({message:e.message,rj:i,stack:e.stack,functionName:"getSimplifiedSettings"})},Pe.postMessage({type:"cvr_getSimplifiedSettings",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async updateSettings(e,t){var i=this;return mt(this),await new Promise((s,n)=>{const o=Ue();Ve[o]=async function(e){if(e.success){const o=JSON.parse(e.response);if(i._isOutputOriginalImage=t.outputOriginalImage,0!==o.errorCode&&pt({message:o.errorString?o.errorString:"Update Settings Failed.",rj:n,errorCode:o.errorCode,functionName:"updateSettings"}))return;return s(o)}pt({message:e.message,rj:n,stack:e.stack,functionName:"updateSettings"})},Pe.postMessage({type:"cvr_updateSettings",id:o,instanceID:this._instanceID,body:{settings:t,templateName:e}})})}async resetSettings(){return mt(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=Ue();Ve[i]=async function(i){if(i.success){const s=JSON.parse(i.response);if(0!==s.errorCode&&pt({message:s.errorString?s.errorString:"Reset Settings Failed.",rj:t,errorCode:s.errorCode,functionName:"resetSettings"}))return;return e(s)}pt({message:i.message,rj:t,stack:i.stack,functionName:"resetSettings"})},Pe.postMessage({type:"cvr_resetSettings",id:i,instanceID:this._instanceID})})}getBufferedItemsManager(){return i(Ot,this)||n(Ot,this,new nt(this)),i(Ot,this)}getIntermediateResultManager(){if(mt(this),!i(kt,this)&&0!==ze.bSupportIRTModule)throw new Error("The current license does not support the use of intermediate results.");return i(bt,this)||n(bt,this,new ct(this)),i(bt,this)}static async setGlobalIntraOpNumThreads(e=0){return e>4||e<0?Promise.reject(new RangeError("'intraOpNumThreads' should be between 0 and 4.")):(await ze.loadWasm(),await new Promise((t,i)=>{const s=Ue();Ve[s]=async function(e){if(e.success)return t();pt({message:e.message,rj:i,stack:e.stack,functionName:"setGlobalIntraOpNumThreads"})},Pe.postMessage({type:"cvr_setGlobalIntraOpNumThreads",id:s,body:{intraOpNumThreads:e}})}))}async checkTemplateNameValidity(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async function(e){return e.success?t(e.isValid):t(!1)},Pe.postMessage({type:"cvr_checkTemplateNameValidity",id:s,instanceID:this._instanceID,body:{templateName:e}})})}async parseRequiredResources(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async function(e){if(e.success)return t(JSON.parse(e.resources));pt({message:e.message,rj:i,stack:e.stack,functionName:"parseRequiredResources"})},Pe.postMessage({type:"cvr_parseRequiredResources",id:s,instanceID:this._instanceID,body:{templateName:e}})})}static disposeCvrWasm(e){t._onLog&&t._onLog(`disposeCvrWasm: ${e}`);const i=Ue();Ve[i]=e=>{e.success||pt({message:e.message,stack:e.stack,isShouldThrow:!0,functionName:"dispose"})},Pe.postMessage({type:"cvr_dispose",id:i,instanceID:e})}dispose(){var e;mt(this),t._onLog&&t._onLog("dispose"),i(Dt,this)&&this.stopCapturing(),n(St,this,null),i(Lt,this).clear(),i(Nt,this).clear(),i(Mt,this).clear(),i(bt,this)._intermediateResultReceiverSet.clear(),n(Ut,this,!0),t.disposeCvrWasm(this._instanceID),null===(e=t._fr4DisposeCvrWasm)||void 0===e||e.unregister(this)}_getInternalData(){return{isa:i(St,this),promiseStartScan:i(Dt,this),intermediateResultManager:i(bt,this),bufferdItemsManager:i(Ot,this),resultReceiverSet:i(Lt,this),isaStateListenerSet:i(Nt,this),resultFilterSet:i(Mt,this),compressRate:i(xt,this),canvas:i(At,this),innerUseTag:i(kt,this),isDestroyed:i(Ut,this)}}async _getWasmFilterState(){return await new Promise((e,t)=>{const i=Ue();Ve[i]=async function(i){if(i.success){const t=JSON.parse(i.response);return e(t)}pt({message:i.message,rj:t,stack:i.stack,functionName:""})},Pe.postMessage({type:"cvr_getWasmFilterState",id:i,instanceID:this._instanceID})})}};function Wt(e){for(let t of i(Lt,this))this._isOutputOriginalImage&&t.onOriginalImageResultReceived&&t.onOriginalImageResultReceived(gt(e))}function jt(e,t){var s,n,o,a,r,c,l,d,u,h,_,m;for(let g=0;g<e.items.length;g++){const p=e.items[g];switch(0!==i(xt,this)&&_t(p,i(xt,this)),p.type){case Ee.CRIT_ORIGINAL_IMAGE:t&&(e.items[g]=gt(t));break;case Ee.CRIT_BARCODE:null!==(n=(s=e.decodedBarcodesResult).barcodeResultItems)&&void 0!==n||(s.barcodeResultItems=[]),e.decodedBarcodesResult.barcodeResultItems.push(p);break;case Ee.CRIT_TEXT_LINE:null!==(a=(o=e.recognizedTextLinesResult).textLineResultItems)&&void 0!==a||(o.textLineResultItems=[]),e.recognizedTextLinesResult.textLineResultItems.push(p);break;case Ee.CRIT_DETECTED_QUAD:null!==(c=(r=e.processedDocumentResult).detectedQuadResultItems)&&void 0!==c||(r.detectedQuadResultItems=[]),e.processedDocumentResult.detectedQuadResultItems.push(p);break;case Ee.CRIT_DESKEWED_IMAGE:Ze.ddn&&Ze.ddn.handleDeskewedAndEnhancedImageResultItem(p),null!==(d=(l=e.processedDocumentResult).deskewedImageResultItems)&&void 0!==d||(l.deskewedImageResultItems=[]),e.processedDocumentResult.deskewedImageResultItems.push(p);break;case Ee.CRIT_ENHANCED_IMAGE:Ze.ddn&&Ze.ddn.handleDeskewedAndEnhancedImageResultItem(p),null!==(h=(u=e.processedDocumentResult).enhancedImageResultItems)&&void 0!==h||(u.enhancedImageResultItems=[]),e.processedDocumentResult.enhancedImageResultItems.push(p);break;case Ee.CRIT_PARSED_RESULT:Ze.dcp&&Ze.dcp.handleParsedResultItem(p),null!==(m=(_=e.parsedResult).parsedResultItems)&&void 0!==m||(_.parsedResultItems=[]),e.parsedResult.parsedResultItems.push(p)}}}function Zt(e,t){const s=e;if(s){let e=0;for(let n of i(bt,this)._intermediateResultReceiverSet){e++;for(let o of s){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===i(bt,this)._intermediateResultReceiverSet.size&&delete o.info.callbackName}}}}function Ht(e){for(let t of i(Lt,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 qt(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async e=>{if(e.success)return t(e.result);pt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Pe.postMessage({type:"cvr_enableResultCrossVerification",id:s,instanceID:this._instanceID,body:{verificationEnabled:e}})})}async function Yt(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async e=>{if(e.success)return t(e.result);pt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Pe.postMessage({type:"cvr_enableResultDeduplication",id:s,instanceID:this._instanceID,body:{duplicateFilterEnabled:e}})})}async function zt(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async e=>{if(e.success)return t(e.result);pt({message:e.message,rj:i,stack:e.stack,functionName:"addResultFilter"})},Pe.postMessage({type:"cvr_setDuplicateForgetTime",id:s,instanceID:this._instanceID,body:{duplicateForgetTime:e}})})}async function $t(e){return mt(this),await new Promise((t,i)=>{const s=Ue();Ve[s]=async e=>{if(e.success)return t();pt({message:e.message,rj:i,stack:e.stack,functionName:"setResultCrossVerificationCriteria"})},Pe.postMessage({type:"cvr_setResultCrossVerificationCriteria",id:s,instanceID:this._instanceID,body:{criteria:e}})})}Je=Gt,a(Gt,"_onLog",void 0),a(Gt,"_defaultTemplate","Default"),a(Gt,"onDataLoadProgressChanged",void 0),a(Gt,"_fr4DisposeCvrWasm","undefined"!=typeof FinalizationRegistry?new FinalizationRegistry(Je.disposeCvrWasm):null);let Kt=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)}},Xt=class{constructor(){a(this,"_observedResultUnitTypes",Ae.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 Qt(e){return e&&"object"==typeof e&&"string"==typeof e.path}var Jt,ei,ti;!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"}(wt||(wt={}));const ii=/<style>([\s\S]*?)<\/style>/g,si=/style="([\s\S]*?)"/g,ni="undefined"!=typeof FinalizationRegistry?new FinalizationRegistry(e=>{URL.revokeObjectURL(e)}):null,oi=(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(ii,(e,s,n,o)=>{let a=s.split("}");const r=a.length-1;let c=[],l=null,d=0;for(let e=0;e<r;++e){let t=0;for(;-1!==(t=a[e].indexOf("{",t));)d+=1,t+=1;if(l)1===d?(c.push(l+a[e]+"}"),l=null,d=0):(l+=a[e]+"}",--d);else{if(d<1)throw new Error("invalid style");1===d?(c.push(a[e].trimStart()+"}"),d=0):(l=a[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(ii,(e,t,i,s)=>(o.push(new Blob([t],{type:"text/css"})),"<HasStyle></HasStyle>")));const a=[];e=e.replace(si,(e,t,i,s)=>(a.push(t),"hasstyle"));const r=document.createElement("div");if(r.insertAdjacentHTML("beforeend",e),r.normalize(),s){const e=r.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!=ni&&ni.register(n,n.href),s.replaceWith(n)}}const c=r.querySelectorAll("[hasstyle]");for(let e=0;e<a.length;e++){const t=a[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 r.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==ni||ni.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(...r.childNodes),1===l.childNodes.length?l.firstChild:l},ai=e=>e&&"object"==typeof e&&"function"==typeof e.then,ri=(async()=>{})().constructor;class ci extends ri{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){var t=this;let i;this._task=e,ai(e)?i=e:"function"==typeof e&&(i=new ri(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(ai(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}const li="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})(),di="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(Jt=window)&&void 0!==Jt&&Jt.MSStream),ui="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent)&&/Firefox/i.test(navigator.userAgent),hi="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 di&&i})(),_i=li?{width:1920,height:1080}:{width:1280,height:720},mi=function(){const e=MediaDeviceInfo.prototype.toJSON.apply(this);return e.trackLabel=this.trackLabel,e.capabilities=this.capabilities,e.isFront=this.isFront,e},gi="The camera feature is available only in secure contexts (HTTPS).";let pi=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",_i),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",!!li||{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(),a=`${t.videoWidth} / ${t.videoHeight}`;a!=i.aspectRatio&&(i.aspectRatio=a),s&&a!=s.aspectRatio&&(s.aspectRatio=a);const r=n/o-t.videoWidth/t.videoHeight;if(Math.abs(r)<.001)return;let c=!1;r>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=oi(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(gi);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=mi):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(mi===n.toJSON)continue;let o=null===(i=e._mapDeviceInfo)||void 0===i?void 0:i[n.deviceId];if(mi===(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=mi}}}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 ci,"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}`)}li&&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(gi);e._delayBeforeGetUserMedia&&await new Promise(t=>setTimeout(t,e._delayBeforeGetUserMedia));let o,a=navigator.mediaDevices.getUserMedia(n);try{o=await(this._getUserMediaTimeout?Promise.race([a,new Promise((e,t)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",t(e)},this._getUserMediaTimeout))]):a)}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."),a=navigator.mediaDevices.getUserMedia({video:this._constraints4Fallback});try{let e=this._getUserMediaTimeout;e>5e3&&(e=5e3),o=await(e?Promise.race([a,new Promise((t,i)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",i(e)},e))]):a)}catch(i){if(console.warn(i),!li||!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{a=navigator.mediaDevices.getUserMedia({video:{deviceId:{exact:e}}}),o=await(n?Promise.race([a,new Promise((e,t)=>setTimeout(()=>{const e=Error("Camera open timeout.");e.name="DMCameraTimeout",t(e)},n))]):a);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(hi&&"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,a;const i=t.deviceId;null!==(n=e._mapDeviceInfo)&&void 0!==n||(e._mapDeviceInfo={}),e._mapDeviceInfo[i]={trackLabel:this.track.label,capabilities:null===(o=(a=this.track).getCapabilities)||void 0===o?void 0:o.call(a),isFront:"user"===this.track.getSettings().facingMode,toJSON:mi}}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 ci,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 r,c;null!==(r=this._video.srcObject)&&void 0!==r&&null!==(c=r.getTracks)&&void 0!==c&&null!==(c=c.call(r))&&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)fi.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=_i),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(c(c({},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(c(c({},this._requestedCamera),s))))}async applyConstraints(e){this.track&&"customized-video"!==this._requestedCamera&&(null!=e||(e={}),await this.track.applyConstraints(c(c(c({},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 a=(null==o?void 0:o.canvas)||document.createElement("canvas");return a.width!=s&&(a.width=s),a.height!=n&&(a.height=n),(o||a.getContext("2d")).drawImage(this._video,t,i,s,n,0,0,s,n),a}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,a=e.center;"string"==typeof e.innerUi&&(e.innerUi=oi(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 r=100*a.y-50*o+50+"%",l=100*a.x+50*n+50+"%",d=100*a.y+50*o+50+"%",u=100*a.x-50*n+50+"%";Object.assign(i.style,{clipPath:`polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, ${u} ${r}, ${u} ${d}, ${l} ${d}, ${l} ${r}, ${u} ${r})`}),"view-min"===e.unit&&(r=`calc(${100*a.y+50}% + max(-${50*o}cqmin, -${50*o}cqmax))`,l=`calc(${100*a.x+50}% + ${50*n}cqmin)`,d=`calc(${100*a.y+50}% + ${50*o}cqmin)`,u=`calc(${100*a.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%, ${u} ${r}, ${u} ${d}, ${l} ${d}, ${l} ${r}, ${u} ${r})`})),Object.assign(i.style,c({},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,c({top:100*a.y+50+"%",left:100*a.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),a=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-a}))}}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),a=parseFloat(t.borderBottomWidth);s.x+=i,s.y+=n,s.width-=i+o,s.height-=n+a}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 a=this._video.videoWidth,r=this._video.videoHeight;let c=(this._isMirrored?1-o.x-o.width:o.x)*a,l=o.y*r,d=o.width*a,u=o.height*r;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(pi,"_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(pi,"_currentOpenedCamera",void 0),a(pi,"_mapDeviceInfo",void 0),a(pi,"_delayBeforeEnumerateDevices",0),a(pi,"_delayBeforeGetUserMedia",ui?1e3:0),a(pi,"_delayBeforeApplyConstraints",0),a(pi,"_countEnsureResolution",ui?20:10),a(pi,"_videoPlayTimeout",li?1e4:3e3),a(pi,"_bReopenWhenChangeResolution",di),a(pi,"_arrConstructors",[]),a(pi,"_arrOnOpen",[]),a(pi,"_arrBeforeClose",[]),a(pi,"_arrOnClose",[]);const fi=["back","front","macro-back","quick-back","customized-video"];pi.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:a,step:r,max:c}=o||{};null!=a&&n<a?n=a:null!=c&&n>c&&(n=c),null!=r&&null!=a&&(n=a+Math.round((n-a)/r)*r,c&&n>c&&(n-=r)),e[t]=n}}return e},pi._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(pi.prototype,"softZoom",{get(){return this._softZoom}}),Object.defineProperty(pi.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(pi.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(pi.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)}}),pi.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},pi.prototype.setZoom=async function(e){const t=this;if("opened"!==t.status)throw Error("Camera not open");pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await t.applyConstraints(t.correctAdvancedConstraint(t.correctAdvancedConstraint({advanced:[{zoom:e}]})))},pi.prototype.setSoftZoom=function(e,t){const i=this;let{center:s,limit:n}=t||{},{x:o=0,y:a=0}=s||{};n&&e<1&&(e=1);let r=i._isMirrored?`scale(${-e},${e})`:`scale(${e})`;if(s){if(n){const t=.5-.5/e;o<-t?o=-t:o>t&&(o=t),a<-t?a=-t:a>t&&(a=t)}r+=` translate(${o*=-100}%, ${a*=-100}%)`}i._softZoom={zoom:e,center:{x:o,y:a}},i._coreInnerLayer.style.transform=r},pi.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)}}))},pi.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],a=t._mapZoomTouchs.get(n.identifier),r=t._mapZoomTouchs.get(o.identifier);if(!a||!r)break;let c=Math.pow(Math.pow(a.x-r.x,2)+Math.pow(a.y-r.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})},pi._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"}),pi._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),a=o+4,r=o+4*t,c=e[o]-e[a],l=e[o+1]-e[a+1],d=e[o+2]-e[a+2],u=e[o]-e[r],h=e[o+1]-e[r+1],_=e[o+2]-e[r+2];s+=c*c+l*l+d*d+u*u+h*h+_*_}return s},pi.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 a=null===(e=o.currentCamera)||void 0===e?void 0:e.capabilities;let r,c;if(null!=a&&null!==(t=a.focusMode)&&void 0!==t&&t.includes("manual"))if(null!=a&&null!==(i=a.focusMode)&&void 0!==i&&i.includes("continuous"))r="manual",c="continuous";else{var l;if(null==a||null===(l=a.focusMode)||void 0===l||!l.includes("single-shot"))return void o._advancedFocus();r="manual",c="single-shot"}else if(null!=a&&null!==(s=a.focusMode)&&void 0!==s&&s.includes("single-shot"))null!=a&&null!==(n=a.focusMode)&&void 0!==n&&n.includes("continuous")?(r="continuous",c="single-shot"):(r=null,c="single-shot");else{var d;if(null==a||null===(d=a.focusMode)||void 0===d||!d.includes("continuous"))return;r=null,c="continuous"}o._isFocusing=!0;try{var u;r&&("manual"===r?(pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await o.applyConstraints(o.correctAdvancedConstraint({advanced:[{focusMode:"manual",focusDistance:(null==a||null===(u=a.focusDistance)||void 0===u?void 0:u.max)||10}]}))):(pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await o.applyConstraints({advanced:[{focusMode:r}]})),await new Promise(e=>setTimeout(e,500))),pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await o.applyConstraints({advanced:[{focusMode:c}]}),await new Promise(e=>setTimeout(e,500))}catch(a){"opened"===o.status&&console.warn("Error while do simple focus",a)}o._isFocusing=!1},pi.prototype._advancedFocus=async function(e,t,i){var s,n,o,a;const r=this;if("opened"!==r.status)throw Error("Camera not open");if(r._isFocusing)return;const c=null===(s=r.currentCamera)||void 0===s?void 0:s.capabilities;if(null==c||null===(n=c.focusMode)||void 0===n||!n.includes("manual"))return void r._simpleFocus();const l=r._advancedFocusParameters,d=r._video.videoWidth,u=r._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),r._isFocusing=!0;const m=++r._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===(a=c.focusDistance)||void 0===a?void 0:a.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;pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await r.applyConstraints(r.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)),r.getFrame({x:h,y:_,width:t,height:i,reusedContext:C});const s=C.getImageData(0,0,t,i).data,n=pi._getImageContrast(s,t,i);if(v){if(n<=f){pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await r.applyConstraints(r.correctAdvancedConstraint({advanced:[{focusMode:"manual",bestFocusDistance:y}]})),pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await r.applyConstraints(r.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"===r.status&&console.warn("Error while do advanced focus",e)}r._isFocusing=!1,l.backToContinousDuration>0&&setTimeout(async()=>{if(r._advancedFocusTaskId===m){pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints));try{await r.applyConstraints({advanced:[{focusMode:"continuous"}]})}catch(e){}}},l.backToContinousDuration)},Object.defineProperty(pi.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)}}),pi._arrConstructors.push(function(){this._isTorchOn=!1,this._autoTorchParameters={shortDelay:250,longDelay:1e3,shortLongDelaySwitchCount:10,grayThreshold:20,maxDarkCount:3}}),pi._arrOnClose.push(function(){this._isTorchOn=!1}),Object.defineProperty(pi.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(pi.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}}),pi.prototype.turnOnTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints));try{await e.applyConstraints({advanced:[{torch:!0}]})}catch(t){throw e._isTorchOn=!1,t}e._isTorchOn=!0},pi.prototype.turnOffTorch=async function(){const e=this;if("opened"!==e.status)throw Error("Camera not open");pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await e.applyConstraints({advanced:[{torch:!1}]}),e._isTorchOn=!1},pi.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 r=s.getImageData(0,0,i.width,i.height).data;let c=0;for(let e=0;e<r.length;e+=4)c+=r[e]+r[e+1]+r[e+2];if(c/=r.length/4*3,c<t.grayThreshold&&++n>=t.maxDarkCount){try{var a;await e.turnOnTorch(),null===(a=e._eventListeners.torchAutoOn)||void 0===a||a.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 Ei="undefined"!=typeof navigator&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!(null!==(ei=window)&&void 0!==ei&&ei.MSStream),yi="undefined"!=typeof navigator&&/MiuiBrowser/.test(navigator.userAgent),Ii="undefined"!=typeof navigator&&/SamsungBrowser/.test(navigator.userAgent);let vi,Ri;pi._arrConstructors.push(function(){this._shouldCloseWhenHide=!0,this._maxReopenTry4CloseWhenHide=4}),pi._arrOnOpen.push(function(){this._bindCloseWhenHide()}),pi._arrBeforeClose.push(function(){this._isDuringCloseWhenHide||this._unbindCloseWhenHide()}),Object.defineProperty(pi.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())}}),pi.prototype._closeWhenHide=async function(){var e;const t=this;if("hidden"===document.visibilityState)("opened"===t.status||"paused"===t.status&&!t._paused&&(Ei&&"live"===(null===(e=t.track)||void 0===e?void 0:e.readyState)||yi&&"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}}},pi.prototype._bindCloseWhenHide=function(){const e=this;e._shouldCloseWhenHide&&(e._closeWhenHideListener||(e._closeWhenHideListener=()=>{e._closeWhenHide()},document.addEventListener("visibilitychange",e._closeWhenHideListener),Ii&&window.addEventListener("blur",e._closeWhenHideListener)))},pi.prototype._unbindCloseWhenHide=function(){const e=this;e._closeWhenHideListener&&(document.removeEventListener("visibilitychange",e._closeWhenHideListener),Ii&&window.removeEventListener("blur",e._closeWhenHideListener),e._closeWhenHideListener=null,e._isOpenBeforeHide=!1)},pi._id4CloseWhenNotInDOM=0,pi._stMSBNotInDOMCamera=new Set,pi._arrConstructors.push(function(){this._id4CloseWhenNotInDOM=++pi._id4CloseWhenNotInDOM,this._shouldCloseWhenNotInDOM=!0,this._bClosedBecauseOfNotInDOM=!1}),pi.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 pi._stMSBNotInDOMCamera.delete(this);let t;if(this._video.isConnected){pi._stMSBNotInDOMCamera.delete(this);for(let e of pi._stMSBNotInDOMCamera)e._id4CloseWhenNotInDOM<this._id4CloseWhenNotInDOM&&(e.close(),e._bClosedBecauseOfNotInDOM=!0,pi._stMSBNotInDOMCamera.delete(e));t=new MutationObserver(()=>{this._video.isConnected||(t.disconnect(),this.close(),this._bClosedBecauseOfNotInDOM=!0)})}else pi._stMSBNotInDOMCamera.add(this),t=new MutationObserver(()=>{this._video.isConnected&&this._updateMo4CloseWhenNotInDOM()});this._mo4CloseWhenNotInDOM=t,t.observe(document.body,{childList:!0,subtree:!0})},pi._arrOnOpen.push(function(){this._updateMo4CloseWhenNotInDOM(),this._bClosedBecauseOfNotInDOM=!1}),pi._arrBeforeClose.push(function(){this._updateMo4CloseWhenNotInDOM()}),Object.defineProperty(pi.prototype,"shouldCloseWhenNotInDOM",{get(){return this._shouldCloseWhenNotInDOM},set(e){this._shouldCloseWhenNotInDOM=!!e,this._updateMo4CloseWhenNotInDOM()}}),pi.showFilePicker=async function(e){var t;null===(t=vi)||void 0===t||t.remove();const i=vi=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},pi.filePicker2CanvasMaxWH=4096,pi.showFilePicker2Canvas=async function(e){var t;let i=pi.filePicker2CanvasMaxWH;(null===(t=e)||void 0===t?void 0:t.canvasMaxWH)&&(i=e.canvasMaxWH,delete(e=c({},e)).canvasMaxWH);let s=await pi.showFilePicker(e),n=[];for(let e of s){const t=document.createElement("canvas"),s=t.getContext("2d"),o=URL.createObjectURL(e),a=new Image;a.src=o,await a.decode(),a.naturalWidth<i&&a.naturalHeight<i?(t.width=a.width,t.height=a.height,s.drawImage(a,0,0)):(a.naturalWidth/a.naturalHeight>1?(t.width=i,t.height=Math.round(a.naturalHeight/a.naturalWidth*i)):(t.height=i,t.width=Math.round(a.naturalWidth/a.naturalHeight*i)),s.drawImage(a,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 a=t!==this._x||i!==this._y||s!==this._w||n!==this._h||o!==this._type;let r;return a&&(this._x=t,this._y=i,this._w=s,this._h=n,this._type=o),!a&&this._dataTime+this.maxTimeout>Date.now()&&this._data?(r=this._data,this._data=null):r=this._getData(),this._pipeTaskId||(this._pipeTaskId=setTimeout(()=>{this._pipeTaskId=null,this._data=this._getData(),this._dataTime=Date.now()},0)),r}},Ti=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 wi=()=>{(null!=Ri?Ri:Ri=new Ti).beep()},Si=(e=300)=>{var t;if(null===(t=navigator)||void 0===t||!t.vibrate)throw new Error("Not supported.");navigator.vibrate(e)},Ai={getVersion:()=>"5.0.0-dev-2026080315080"},Di=pi,bi=pi;if(null!==(ti=document)&&void 0!==ti&&ti.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 Oi={x:0,y:0,width:100,height:100,isMeasuredInPercentage:!0};Di.createInstance=async function(e){let t;if(e instanceof pi?(t=e,e=void 0):t=new pi,void 0===t.disposed){if(t.isCameraEnhancer=!0,t.disposed=!1,t._cameraEnhancer=t._cameraView=t,t._framePipeline=new Ci(t),t._dceScanRegion=Oi,t._dceEventListeners={},t._bAutoSingleFrameModeWhenIosPwaFail=!0,t._oriOpen=t.open,t.open=Li,t._oriUpdateCanvasSize=t._updateCanvasSize,t._updateCanvasSize=Mi,t._oriAddCanvas=t.addCanvas,t.addCanvas=Bi,t._dceZoom=1,t._dceEnhancedFeatures=0,t._dceAutoZoomRange={min:1,max:10},t._oriSetZoom=t.setZoom,t.setZoom=Fi,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=bi.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:ts.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,a=t._dceLastDeviceId;o!==a&&(t._dceLastDeviceId=o,null===(n=this._dceEventListeners.cameraChange)||void 0===n||n.forEach(e=>{try{e.call(this,o,a)}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 Xi)return e.quad.points;if(e instanceof Qi||e instanceof Ji||e instanceof es){let{x:t,y:i,width:s,height:n}=e.rect,o=t+s,a=i+n;return[{x:t,y:i},{x:t,y:a},{x:o,y:a},{x:o,y:i}]}return e instanceof Ki?[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 r=s[t],c=!1;if(r instanceof Xi||r instanceof Qi||r instanceof Ji||r instanceof es?(c=Yi(i,[n[o-4],n[o-3],n[o-2],n[o-1]]),o-=4):r instanceof Ki&&(c=Yi(i,[n[o-2],n[o-1]]),o-=2),c){var a;e.targetItem=r,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===(a=r._dceEventListeners[e.type])||void 0===a||a.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},Di.defaultUIElementURL="@engineResourcePath/ui/dce.ui.xml",Object.defineProperty(Di.prototype,"cameraOpenTimeout",{get(){return this._getUserMediaTimeout},set(e){this._getUserMediaTimeout=e}});const Li=async function(){var e,t,i,s,n;const o=this;if("disabled"!==o.singleFrameMode){var a;let e=await Ni("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 xi(this.bytes,this.width,this.height,this.format)},imageTag:{imageId:++Pi,type:0}}}}const t=o.ui.querySelector(".dce-bg-camera");"closed"!==o.status&&await o.close(),t&&(t.style.opacity="0");{var r;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===(r=o._singleFrameModeUIAutoFitRO)||void 0===r||r.observe(o._coreShell)}return o._singleFrameModeResultForDcv=e,void(null===(a=o._dceEventListeners.singleFrameAcquired)||void 0===a||a.forEach(t=>{try{t.call(this,e)}catch(t){console.error(t)}}))}o.videoSrc&&(o.video.src=o._dceVideoSrc);const l=o.ui.querySelector(".dce-bg-loading");l&&(l.style.display="");try{await o._oriOpen()}catch(e){var d,u,h;if(Di.onWarning&&Di.onWarning(null==e?void 0:e.message),o._bAutoSingleFrameModeWhenIosPwaFail&&null!=e&&null!==(d=e.message)&&void 0!==d&&d.includes("iOS PWA"))return console.warn(e.message),l&&(l.style.display="none"),console.warn("Auto switch to `singleFrameMode = 'camera'`."),o.singleFrameMode="camera",void(null===(u=o.funcShowToast)||void 0===u||u.call(o,"Click to Capture",8e3));throw l&&(l.style.display="none"),null!==(h=o.funcShowToast)&&void 0!==h&&h.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))),l&&(l.style.display="none"),await new Promise(e=>setTimeout(e,0)),c({deviceId:null===(n=o.currentCamera)||void 0===n?void 0:n.deviceId},o.currentResolution)},Ni=async function(e){const t={multiple:!1};e&&(t.capture="environment");const i=(await pi.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:++Pi,type:0}}},Mi=function(){"disabled"===this.singleFrameMode&&this._oriUpdateCanvasSize()},Bi=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};Di.prototype.dispose=function(){this.disposed=!0,this.close(),this.setScanLaserVisible(!1)},Di.prototype.getAllCameras=async function(){return(await pi.getDeviceInfos()).map(e=>({deviceId:e.deviceId,label:e.label||e.trackLabel}))},Di.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,a,r,c;await e.requestResolution(i),((null===(o=e.currentResolution)||void 0===o?void 0:o.width)===i[0]&&(null===(a=e.currentResolution)||void 0===a?void 0:a.height)===i[1]||(null===(r=e.currentResolution)||void 0===r?void 0:r.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},Di.prototype.getCameraState=function(){let e=this.status;return"closing"===e||"paused"===e||"closed"===e?"closed":"opened"===e?"open":"opening"===e?"opening":void 0},Di.prototype.getResolution=function(){return"opened"===this.status?this.currentResolution:this.requestedResolution},Di.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},Di.prototype.getVideoSettings=function(){let e={};return"object"==typeof this.requestedCamera&&Object.assign(e,this.requestedCamera),Object.assign(e,this.requestedResolution),{video:e}},Object.defineProperty(Di.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(Di.prototype,"ifSkipCameraInspection",{get(){return"quick-back"===this.requestedCamera},set(e){e?this.requestCamera("quick-back"):this.requestCamera("back")}}),Di.prototype.isOpen=function(){return"opened"===this.status},Di.prototype.isPaused=function(){return"paused"===this.status},Di.prototype.resume=async function(){await this._oriOpen()},Di.prototype.selectCamera=async function(e){var t;return await this.requestCamera("string"==typeof e?e:e.deviceId),c({deviceId:null===(t=this.currentCamera)||void 0===t?void 0:t.deviceId},this.currentResolution)},Di.prototype.setResolution=async function(e){var t;return await this.requestResolution(e),c({deviceId:null===(t=this.currentCamera)||void 0===t?void 0:t.deviceId},this.currentResolution)},Di.testCameraAccess=async function(){let e=!0,t="Successfully accessed the camera.";try{await pi.getDeviceInfos()}catch(i){e=!1,t=i.message||i}return{ok:e,message:t}},Di.prototype.updateVideoSettings=async function(e){const t="object"!=typeof e?null:null==e?void 0:e.video;await this.requestCamera(t)},Object.defineProperty(Di.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))}}),Di.prototype.disableEnhancedFeatures=function(e){this._dceEnhancedFeatures=this._dceEnhancedFeatures-(this._dceEnhancedFeatures&e)},Di.prototype.enableEnhancedFeatures=function(e){this._dceEnhancedFeatures|=e},Di.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},Di.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},Di.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},Di.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},Di.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},Di.prototype.setColorTemperature=async function(e){var t;const i=this;i.getColorTemperature(),pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{colorTemperature:e,whiteBalanceMode:"manual"}]})))},Di.prototype.setExposureCompensation=async function(e){var t;const i=this;i.getExposureCompensation(),pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{exposureCompensation:e}]})))},Di.prototype.setFrameRate=async function(e){var t;const i=this;i.getFrameRate(),pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await(null===(t=i.applyConstraints)||void 0===t?void 0:t.call(i,i.correctAdvancedConstraint({advanced:[{frameRate:e}]})))},Di.prototype.getZoomSettings=function(){return{factor:this._dceZoom}};const Fi=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 xi(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 a=new Uint8ClampedArray(e),r=new ImageData(a,t,i);return o.putImageData(r,0,0),n}Di.prototype.resetZoom=async function(){this._dceZoom=1,this.setSoftZoom(1,{center:{x:0,y:0}});try{await this._oriSetZoom(1)}catch(e){}},Di.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},Di.prototype.setFocus=async function(e){const t=this;if(!t.track)throw Error("Camera not open");if(t._dceFocusSettings=e,"manual"!==e.mode)pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._delayBeforeApplyConstraints)),await t.applyConstraints({advanced:[{focusMode:e.mode}]});else if(e.distance)pi._delayBeforeApplyConstraints&&await new Promise(e=>setTimeout(e,pi._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,a=t.currentResolution.width,r=t.currentResolution.height;"string"==typeof i&&(i=i.endsWith("%")?parseFloat(i)*a:parseFloat(i)),"string"==typeof s&&(s=s.endsWith("%")?parseFloat(s)*r:parseFloat(s)),"string"==typeof n&&(n=n.endsWith("%")?parseFloat(n)*a:parseFloat(n)),"string"==typeof o&&(o=o.endsWith("%")?parseFloat(o)*r:parseFloat(o)),await t._advancedFocus({x:i,y:s},n,o)}},Di.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)},Di.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},Di.prototype.toggleMirroring=function(e){this.isMirrored=e};let Pi=0;Di.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:++Pi,type:1}}},Di.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(c(c({},i),{},{type:s}));if(!n)return null;let{width:o,height:a}=i,r="rgba"===s?10:2;const l={bytes:n,width:o,height:a,stride:i.width*("rgba"===s?4:1),format:r,toCanvas:function(){return xi(this.bytes,this.width,this.height,this.format)},imageTag:{imageId:++Pi,type:1}};return null!==(e=this._dceEventListeners.frameAddedToBuffer)&&void 0!==e&&e.forEach(e=>{try{e.call(this,l)}catch(e){console.error(e)}}),l},Di.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 Ni(!0);return i&&await t._oriOpen(),null!=e&&e(s),s},Object.defineProperty(Di.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:c({},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"))}}),Di.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 a=s/n-t.width/t.height,r=.001;if(Math.abs(a)>r){let t=!1;a>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"))}}},Di.prototype.getScanRegion=function(){return this._dceScanRegion},Di.prototype.hasNextImageToFetch=function(){return"opened"===this.status},Di.prototype.isBufferEmpty=function(){return"opened"!==this.status},Di.prototype.getPixelFormat=function(){return this._pixelFormat},Di.prototype.setPixelFormat=function(e){2===e?(this._pixelFormat=2,this._colourChannelUsageType=2):(this._pixelFormat=10,this._colourChannelUsageType=1)},Di.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}},Di.prototype.getColourChannelUsageType=function(){return this._colourChannelUsageType},Di.prototype.setScanRegion=function(e){this._dceScanRegion=null!=e?e:e=Oi;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}`:""}})}}},Di.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)},Di.prototype.getCameraView=function(){return this},Di.prototype.getVideoEl=function(){return this.video},Di.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]},Di.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]},Di.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)}},Di.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 a=t.video.videoWidth,r=t.video.videoHeight;let c=t.videoXY2AbsoluteLT([{x:0,y:0},{x:a,y:r}]);return{x:(e.x+n-i)/a*(c[1].left-c[0].left),y:(e.y+o-s)/r*(c[1].top-c[0].top)}},Di.prototype.on=function(e,t){var i,s;(null!==(s=(i=this._dceEventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)},Di.prototype.off=function(e,t){var i;null===(i=this._dceEventListeners[e])||void 0===i||i.delete(t)},bi.prototype.getUIElement=function(){return this.ui},bi.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(bi.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=Di.handleEngineResourcePaths(Di.CoreModule.engineResourcePaths);i=i.replace("@engineResourcePath/","DBR"===Di.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=oi(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 pi.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 a=e.querySelector(".dm-camera-mn-toast,.dce-mn-toast");if(!a&&o){a=document.createElement("div"),a.classList.add("dm-camera-mn-toast"),Object.assign(a.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(a);let e=null;t.funcShowToast=(t,i=3e3)=>{a&&(a.textContent=t,a.style.display="",null!=e&&(clearTimeout(e),e=null),i&&(e=setTimeout(()=>{a.style.display="none",e=null},i)))}}const r=e.querySelector(".dce-macro-use-mobile-native-like-ui");if(r&&!r._dce_binded){const e=r;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 a=e.querySelector(".dce-mn-beep-on"),c=e.querySelector(".dce-mn-beep-off");a&&(a.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(r.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 pi.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 pi.hasFrontCamera()&&p&&(p.style.display="")}}),t.addEventListener("closed",()=>{t.disposed||(r.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!=a&&a.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!1,a.style.display="none",c.style.display="")}),null!=c&&c.addEventListener("pointerdown",()=>{t.disposed||(t._dceMNIsBeepBarcode=!0,c.style.display="none",a.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},bi.prototype.getVideoElement=function(){return this.video},bi.prototype.setVideoFit=function(e){this.objectFit=e},bi.prototype.getVideoFit=function(){return this.objectFit},bi.prototype.getVisibleRegionOfVideo=function(e){const t=this;let{inPixels:i}=e||{inPixels:!1};const s=t.getVisibleAreaInVideoXY();if(i)return c(c({},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}}},bi.prototype.setScanRegionMaskStyle=function(e){const t=this._dceRegionMaskVisible;this._dceRegionMaskStyle=c({},e),this.setRegionBox({maskStyle:{background:t?e.fillStyle:""},borderStyle:{border:t?`${e.lineWidth}px solid ${e.strokeStyle}`:""}})},bi.prototype.getScanRegionMaskStyle=function(){return this._dceRegionMaskStyle},bi.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}`:""}})},bi.prototype.isScanRegionMaskVisible=function(){return this._dceRegionMaskVisible},bi.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)},bi.prototype.isScanLaserVisible=function(){var e;return!(null===(e=this.regionBox)||void 0===e||!e.innerUi)&&"none"!==this.regionBox.innerUi.style.display},bi.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")},bi.prototype.isPowerByMessageVisible=function(){let e=this.ui.querySelector(".dce-msg-poweredby,.dm-camera-mn-msg-poweredby");return e&&"none"!==e.style.display},bi.prototype.getTipConfig=function(){return{duration:this._dceTipDuration}},bi.prototype.setTipConfig=function(e){this._dceTipDuration=e.duration},bi.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")}},bi.prototype.isTipVisible=function(){const e=this.ui.querySelector(".dm-camera-mn-toast");return!!e&&"none"!=e.style.display},bi.prototype.updateTipMessage=function(e){var t;this._dceTipMessage=e,null===(t=this.funcShowToast)||void 0===t||t.call(this,this._dceTipMessage,this._dceTipDuration)},bi.prototype.createDrawingLayer=function(){const e=new qi;return e._dce=this,e._ctx=this.addCanvas().getContext("2d"),this._drawingLayers.push(e),e},bi.prototype.getDrawingLayer=function(e){if(e instanceof qi)return e;if("number"!=typeof e)return null;let t=this._drawingLayers[e];return t||1!==e&&2!==e&&3!==e||(t=new qi,t._dce=this,t._ctx=this.addCanvas().getContext("2d"),this._drawingLayers[e]=t,1===e?t._defaultStyle=Hi.STYLE_BLUE_STROKE:2===e?t._defaultStyle=Hi.STYLE_ORANGE_STROKE_FILL:3===e&&(t._defaultStyle=Hi.STYLE_GREEN_STROKE_FILL)),t},bi.prototype.getAllDrawingLayers=function(){for(let e=1;e<=3;e++)this.getDrawingLayer(e);return this._drawingLayers.filter(e=>e)},bi.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},bi.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])},bi.prototype.clearAllInnerDrawingItems=function(e){for(let t of this._drawingLayers.slice(1,4))!t||e&&"editor"===t._mode||t.clearDrawingItems()};let ki=class{static beep(){null!=this._beepInstance?this._beepInstance.beep():wi()}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 Ti),this._beepInstance.beepSoundSource=e}static vibrate(){null!=this.vibrateDuration?Si(this.vibrateDuration):Si()}};a(ki,"_beepInstance",void 0),a(ki,"vibrateDuration",void 0);const Ui="73,245,73",Vi="73,173,245",Gi="254,180,32",Wi="245,236,73",ji=(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},Zi=[null,ji(Vi),ji(Ui),ji(Gi),ji(Wi),ji(Vi,"f"),ji(Ui,"f"),ji(Gi,"f"),ji(Wi,"f"),ji(Vi,"t"),ji(Ui,"t"),ji(Gi,"t"),ji(Wi,"t")],Hi={STYLE_BLUE_STROKE:Zi[1],STYLE_GREEN_STROKE:Zi[2],STYLE_ORANGE_STROKE:Zi[3],STYLE_YELLOW_STROKE:Zi[4],STYLE_BLUE_STROKE_FILL:Zi[5],STYLE_GREEN_STROKE_FILL:Zi[6],STYLE_ORANGE_STROKE_FILL:Zi[7],STYLE_YELLOW_STROKE_FILL:Zi[8],STYLE_BLUE_STROKE_TRANSPARENT:Zi[9],STYLE_GREEN_STROKE_TRANSPARENT:Zi[10],STYLE_ORANGE_STROKE_TRANSPARENT:Zi[11],STYLE_YELLOW_STROKE_TRANSPARENT:Zi[12],createDrawingStyle(e){let t=Object.assign({},this.STYLE_YELLOW_STROKE_FILL,e);return Object.assign(e,t),e},getDrawingStyle:e=>"number"==typeof e?Zi[e]:e,getAllDrawingStyles:()=>Zi.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 qi=class{constructor(){a(this,"_visible",!0),a(this,"_dce",void 0),a(this,"_ctx",void 0),a(this,"_defaultStyle",Hi.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=Hi.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=Hi.getDrawingStyle(e.drawingStyleId||this._defaultStyle);if(t.fillStyle=i.fillStyle,t.strokeStyle=i.strokeStyle,t.lineWidth=i.lineWidth*n,t.setLineDash([]),e instanceof Ji){const o=e.text.split("\n"),{x:a,y:r,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=a+s.x;for(let e=0;e<o.length;++e){const i=r+l/o.length*e+s.y;t.fillText(o[e],u,i,c),t.strokeText(o[e],u,i,c)}continue}if(e instanceof es){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:a,y:r,width:c,height:l}=e.rect;e.maintainAspectRatio&&(l=c/n*o),t.drawImage(i,a+s.x,r+s.y,c,l);continue}if(e._bSelected&&(t.strokeStyle="#0f0",t.lineWidth=2*n,t.setLineDash([4,4])),t.beginPath(),e instanceof Xi){const i=e.quad.points;t.moveTo(i[0].x+s.x,i[0].y+s.y),t.lineTo(i[1].x+s.x,i[1].y+s.y),t.lineTo(i[2].x+s.x,i[2].y+s.y),t.lineTo(i[3].x+s.x,i[3].y+s.y)}else if(e instanceof Ki){const i=e.line.startPoint,n=e.line.endPoint;t.moveTo(i.x+s.x,i.y+s.y),t.lineTo(n.x+s.x,n.y+s.y)}else if(e instanceof Qi){const{x:i,y:n,width:o,height:a}=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+a+s.y),t.lineTo(i+s.x,n+a+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 Yi(e,t){const[i,s]=e;let n=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const[a,r]=t[e],[c,l]=t[o];if(i===a&&s===r||i===c&&s===l)return!0;if((i<=a&&i>=c||i>=a&&i<=c)&&(s<=r&&s>=l||s>=r&&s<=l)&&(i-a)*(s-r)===(i-c)*(s-l))return!0;r>s!=l>s&&i<(c-a)*(s-r)/(l-r)+a&&(n=!n)}return n}function zi(e,t){const[i,s]=e,[[n,o],[a,r]]=t,c=a-n,l=r-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+_*_)}let $i=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?ss.DIS_SELECTED:ss.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=c(c({},s.content),{},{content:t}):i&&s.content&&t&&"string"==typeof s.content&&"string"==typeof t?s.content+=","+t:s.content=t)}deleteNote(e){this._notes=this._notes.filter(t=>t.name!==e)}clearNotes(){this._notes=[]}_delayRenderAll(){var e;null===(e=this.drawingLayerId)||void 0===e||e._delayRenderAll()}_setSelected(e){if(e===this._bSelected)return;this._bSelected=e,this._delayRenderAll();let t=this.drawingLayerId;t&&(e?t._newSelectedDrawingItems.push(this):t._newDeselectedDrawingItems.push(this),t._delaySelectionChanged())}on(e,t){var i,s;(null!==(s=(i=this._dceEventListeners)[e])&&void 0!==s?s:i[e]=new Set).add(t)}off(e,t){var i;null===(i=this._dceEventListeners[e])||void 0===i||i.delete(t)}},Ki=class extends $i{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=is.DIMT_LINE,this.line=e,this.drawingStyleId=t}getLine(){return this.line}setLine(e){this.line=e,this._delayRenderAll()}},Xi=class extends $i{get _ps(){return this.quad.points}constructor(e,t){super(),a(this,"quad",void 0),this.mediaType=is.DIMT_QUADRILATERAL,this.quad=e,this.drawingStyleId=t}getQuad(){return this.quad}setQuad(e){this.quad=e,this._delayRenderAll()}},Qi=class extends $i{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=is.DIMT_RECTANGLE,this.rect=e,this.drawingStyleId=t}getRect(){return this.rect}setRect(e){this.rect=e,this._delayRenderAll()}},Ji=class extends $i{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=is.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()}},es=class extends $i{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=is.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=xi(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 ts=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=Hi.STYLE_ORANGE_STROKE_TRANSPARENT:(i._dceMNIsBeepBarcode&&wi(),i._dceMNIsVibrateBarcode&&Si());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=Hi.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=Hi.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=Hi.STYLE_BLUE_STROKE_TRANSPARENT);break;default:continue}s.addDrawingItems([new Xi({points:n},o)])}};var is,ss,ns,os;!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"}(is||(is={})),function(e){e[e.DIS_DEFAULT=1]="DIS_DEFAULT",e[e.DIS_SELECTED=2]="DIS_SELECTED"}(ss||(ss={})),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"}(ns||(ns={})),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"}(os||(os={}));const as="undefined"==typeof self,rs=as?{}:self,cs="function"==typeof importScripts,ls=(()=>{if(!cs){if(!as&&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"./"}})(),ds=e=>e&&"object"==typeof e&&"function"==typeof e.then,us=(async()=>{})().constructor;let hs=class extends us{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){var t=this;let i;this._task=e,ds(e)?i=e:"function"==typeof e&&(i=new us(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(ds(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}};const _s=" is not allowed to change after `createInstance` or `loadWasm` is called.",ms=!as&&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"))||"",gs=(e,t)=>{const i=e;if(i._license!==t){if(!i._pLoad.isEmpty)throw new Error("`license`"+_s);i._license=t}};!as&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword");const ps=e=>{if(null==e)e=[];else{e=e instanceof Array?[...e]:[e];for(let t=0;t<e.length;++t){if(!as){let i=document.createElement("a");i.href=e[t],e[t]=i.href}e[t].endsWith("/")||(e[t]+="/")}}return e},fs=(e,t)=>{t=ps(t);const i=e;if(i._licenseServer!==t){if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+_s);i._licenseServer=t}},Es=(e,t)=>{t=t||"";const i=e;if(i._deviceFriendlyName!==t){if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+_s);i._deviceFriendlyName=t}};let ys,Is,vs,Rs,Cs;"undefined"!=typeof navigator&&(ys=navigator,Is=ys.userAgent,vs=ys.platform,Rs=ys.mediaDevices),function(){if(!as){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:ys.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:vs,search:"Win"},Mac:{str:vs},Linux:{str:vs}};let i="unknownBrowser",s=0,n="unknownOS";for(let t in e){const n=e[t]||{};let o=n.str||Is,a=n.search||t,r=n.verStr||Is,c=n.verSearch||t;if(c instanceof Array||(c=[c]),-1!=o.indexOf(a)){i=t;for(let e of c){let t=r.indexOf(e);if(-1!=t){s=parseFloat(r.substring(t+e.length+1));break}}break}}for(let e in t){const i=t[e]||{};let s=i.str||Is,o=i.search||e;if(-1!=s.indexOf(o)){n=e;break}}"Linux"==n&&-1!=Is.indexOf("Windows NT")&&(n="HarmonyOS"),Cs={browser:i,version:s,OS:n}}as&&(Cs={browser:"ssr",version:0,OS:"ssr"})}(),Rs&&Rs.getUserMedia,"Chrome"===Cs.browser&&Cs.version>66||"Safari"===Cs.browser&&Cs.version>13||"OPR"===Cs.browser&&Cs.version>43||"Edge"===Cs.browser&&Cs.version;const Ts=new hs,ws=async()=>(Ts.isEmpty&&(Ts.task=async(e,t)=>{await ze.loadWasm();let{lt:i,l:s,ls:n,sp:o,rmk:a,cv:r}=((e,t=!1)=>{const i=As;if(i._pLoad.isEmpty){let s,n,o,a=i._license||"",r=JSON.parse(JSON.stringify(i._licenseServer)),c=i._sessionPassword,l=0;if(a.startsWith("t")||a.startsWith("f"))l=0;else if(0===a.length||a.startsWith("P")||a.startsWith("L")||a.startsWith("Y")||a.startsWith("A"))l=1;else{l=2;const t=a.indexOf(":");-1!=t&&(a=a.substring(t+1));const i=a.indexOf("?");if(-1!=i&&(n=a.substring(i+1),a=a.substring(0,i)),a.startsWith("DLC2"))l=0;else{if(a.startsWith("DLS2")){let t;try{let e=a.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(a=t.handshakeCode?t.handshakeCode:t.organizationID?t.organizationID:"","number"==typeof a&&(a=JSON.stringify(a)),0===r.length){let e=[];t.mainServerURL&&(e[0]=t.mainServerURL),t.standbyServerURL&&(e[1]=t.standbyServerURL),r=ps(e)}!c&&t.sessionPassword&&(c=t.sessionPassword),s=t.remark}a&&"200001"!==a&&!a.startsWith("200001-")||(l=1)}}if(l&&(t||(rs.crypto||(o="Please upgrade your browser to support online key."),rs.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:a,ls:r,sp:c,rmk:s,cv:n}}throw new Error("Can't preprocess license again"+_s)})();const c="undefined"!=typeof self?self:{};let l;As._pLoad.task=Ts,(async()=>{try{await As._pLoad}catch(e){}})(),i&&(c.dyarm||(c.dyarm={}),c.dyarm[s]?l=(await c.dyarm[s]).ar:c.dyarm[s]=(async()=>(await Ts,c.dyarm[s]=await Ss(),c.dyarm[s]))());let d=Ue();Ve[d]=s=>{var n;if(s.message&&As._onAuthMessage){let e=As._onAuthMessage(s.message);null!=e&&(s.message=e)}let o,a=!1;if(1===i&&(a=!0),s.success?(Ge&&(null===(n=ze._onLog)||void 0===n||n.call(ze,"init license success")),s.message&&console.warn(s.message),ze._bSupportIRTModule=s.bSupportIRTModule,ze._bSupportDce4Module=s.bSupportDce4Module,As.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),a||111==s.ltsErrorCode&&-1!=s.message.toLowerCase().indexOf("trial license")&&(a=!0)),l&&(a=!1),a){const e=W(ze.engineResourcePaths),t=("DCV"===ze._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 a=[];for(let e=0;e<o.childElementCount;++e){let t=o.children[e];t instanceof HTMLStyleElement&&(a.push(t),document.head.append(t))}let r=1==o.childElementCount?o.children[0]:o;r.remove();let c,l,d,u,h,_=[r],m=r.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){r.remove();for(let e of a)e.remove()}});else if(!l&&e.classList.contains("dls-license-icon-close"))l=e,e.addEventListener("click",()=>{r.remove();for(let e of a)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 a=document.createElement("a"),r=t.substring(i+1,s);a.innerText=r;let c=t.substring(n+1,o);a.setAttribute("href",c),a.setAttribute("target","_blank"),e.appendChild(a),t=t.substring(o+1)}}document.body.appendChild(r)}catch(t){e._onLog&&e._onLog(t.message||t)}})({_bNeverShowDialog:As._bNeverShowDialog,engineResourcePath:t,_onLog:ze._onLog},s.success?"warn":"error",s.message)}s.success?e(void 0):t(o)};const u=await ze.getModuleVersion();Pe.postMessage({type:"l_dynamsoft",body:{v:"DCV"===ze._bundleEnv?u.CVR.replace(/\.\d+$/,""):u.DBR.replace(/\.\d+$/,""),brtk:!!i,bptk:1===i,l:s,os:Cs,fn:As.deviceFriendlyName,ls:n,sp:o,rmk:a,cv:r,ar:l,_e:As._e,mliRecord:null===localStorage||void 0===localStorage?void 0:localStorage.getItem("dynamsoft")},id:d})}),await Ts),Ss=async()=>(Ts&&Ts.isRejected&&await Ts,Pe?new Promise((e,t)=>{const i=Ue();Ve[i]=async i=>{if(i.success){delete i.success;{let e=As.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)}},Pe.postMessage({type:"l_getAR",id:i})}):null);let As=class e{static setLicenseServer(t){fs(e,t)}static get license(){return this._license}static set license(t){gs(e,t)}static get licenseServer(){return this._licenseServer}static set licenseServer(t){fs(e,t)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(t){Es(e,t)}static async initLicense(t,i){if(gs(e,t),e.bCallInitLicense=!0,"boolean"==typeof i&&i||"object"==typeof i&&i.executeNow)return await ws()}static setDeviceFriendlyName(t){Es(e,t)}static getDeviceFriendlyName(){return e._deviceFriendlyName}static async getDeviceUUID(){return await async function(){return await ze.loadWasm(),await new Promise((e,t)=>{const i=Ue();Ve[i]=i=>{if(i.success)e(i.uuid);else{const e=Error(i.message);i.stack&&(e.stack=i.stack),t(e)}},Pe.postMessage({type:"l_getDeviceUUID",id:i})})}()}};As._pLoad=new hs,As.bPassValidation=!1,As.bCallInitLicense=!1,As._license=ms,As._licenseServer=[],As._deviceFriendlyName="",As._e=!0,Ze.license={},Ze.license.dynamsoft=ws,Ze.license.getAR=Ss,ze.engineResourcePaths.license={version:"4.6.30-dev-20260824140340",path:ls,isInternal:!0},Ze.license.LicenseManager=As;let Ds=class{static getVersion(){return`4.6.30-dev-20260824140340(Worker: ${je.license&&je.license.worker||"Not Loaded"}, Wasm: ${je.license&&je.license.wasm||"Not Loaded"})`}};const bs=()=>window.matchMedia("(orientation: landscape)").matches,Os=e=>Object.prototype.toString.call(e).slice(8,-1);function Ls(e,t){for(const i in t)"Object"===Os(t[i])&&"Object"===Os(e[i])&&i in e?Ls(e[i],t[i]):("cameraFeatures"===i&&(t[i]=Array.isArray(t[i])?t[i]:[t[i]]),e[i]=t[i]);return e}function Ns(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 Ms(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]=Ms(e[i])}else{t={};for(let i in e)e.hasOwnProperty(i)&&(t[i]=Ms(e[i]))}return t}function Bs(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 Fs="undefined"==typeof self,xs="function"==typeof importScripts,Ps=(()=>{if(!xs){if(!Fs&&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"./"}})();ze.engineResourcePaths.dbr={version:"11.6.30-dev-20260824140359",path:Ps,isInternal:!0},Ze.dbr={};let ks=class{static getVersion(){const e=je.dbr&&je.dbr.wasm;return`11.6.30-dev-20260824140359(Worker: ${je.dbr&&je.dbr.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}};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;!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"}(Vs||(Vs={})),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 Zs="undefined"==typeof self,Hs="function"==typeof importScripts,qs=(()=>{if(!Hs){if(!Zs&&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"./"}})(),Ys=e=>{if(null==e&&(e="./"),Zs||Hs);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},zs="undefined"==typeof self,$s="function"==typeof importScripts,Ks=(()=>{if(!$s){if(!zs&&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"./"}})();ze.engineResourcePaths.utility={version:"2.6.30-dev-20260824140349",path:Ks,isInternal:!0};let Xs=class{static getVersion(){return`2.6.30-dev-20260824140349(Worker: ${je.utility&&je.utility.worker||"Not Loaded"}, Wasm: ${je.utility&&je.utility.wasm||"Not Loaded"})`}};function Qs(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}"function"==typeof SuppressedError&&SuppressedError;const Js="undefined"==typeof self,en="function"==typeof importScripts,tn=(()=>{if(!en){if(!Js&&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"./"}})();ze.engineResourcePaths.dbr={version:"11.6.10-dev-20260601155910",path:tn,isInternal:!0},Ze.dbr={};const sn={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 nn,on,an,rn,cn;(cn=nn||(nn={}))[cn.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",cn[cn.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",cn[cn.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"}(on||(on={})),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"}(an||(an={})),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"}(rn||(rn={}));const ln=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=Y(o);return new Blob([e],{type:"image/bmp"})}return await new Promise(e=>{s.toBlob(t=>{e(t)},t)})}finally{URL.revokeObjectURL(i)}};function dn(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 un(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function hn(e,t){const[i,s]=e,n=i.x,o=i.y,a=s.x,r=s.y,c=t.x,l=t.y,d=(a-n)**2+(r-o)**2;if(0===d)return Math.sqrt((c-n)**2+(l-o)**2);const u=((c-n)*(a-n)+(l-o)*(r-o))/d;if(u<0)return Math.sqrt((c-n)**2+(l-o)**2);if(u>1)return Math.sqrt((c-a)**2+(l-r)**2);{const e=n+u*(a-n),t=o+u*(r-o);return Math.sqrt((c-e)**2+(l-t)**2)}}function _n(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 mn(e){const[t,i]=e;return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}function gn(e,t,i,s){const n=t.x-e.x,o=t.y-e.y,a=s.x-i.x,r=s.y-i.y,c=(-o*(e.x-i.x)+n*(e.y-i.y))/(-a*o+n*r),l=(a*(e.y-i.y)-r*(e.x-i.x))/(-a*o+n*r);return c>=0&&c<=1&&l>=0&&l<=1?{x:e.x+l*n,y:e.y+l*o}:null}function pn(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 fn(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(!fn(e.points[i],e.points[(i+1)%4],t))return!1;return!0}function yn(e,t,i,s){const n=e.points,o=t.points;let a=8*i;a=Math.max(a,5);const r=_n(n)[3],c=_n(n)[1],l=_n(o)[3],d=_n(o)[1];let u,h=0;if(u=Math.max(Math.abs(hn(r,t.points[0])),Math.abs(hn(r,t.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(hn(c,t.points[1])),Math.abs(hn(c,t.points[2]))),u>h&&(h=u),u=Math.max(Math.abs(hn(l,e.points[0])),Math.abs(hn(l,e.points[3]))),u>h&&(h=u),u=Math.max(Math.abs(hn(d,e.points[1])),Math.abs(hn(d,e.points[2]))),u>h&&(h=u),h>a)return!1;const _=mn(_n(n)[0]),m=mn(_n(n)[2]),g=mn(_n(o)[0]),p=mn(_n(o)[2]),f=un(_,p),E=un(g,m),y=f>E,I=Math.min(f,E),v=un(_,m),R=un(g,p);let C=12*i;return C=Math.max(C,5),C=Math.min(C,v),C=Math.min(C,R),!!(I<C||dn(n,y?g:p)||dn(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=pn(s.points),!0)}class In{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),a=0,r=0;for(let e=0;e<4;++e)n[e]=Math.round(100*(s.points[e].x-i.points[e].x))/100,a+=n[e],o[e]=Math.round(100*(s.points[e].y-i.points[e].y))/100,r+=o[e];a/=4,r/=4;for(let e=0;e<4;++e){if(Math.abs(n[e]-a)>this.strictLimit||Math.abs(a)>.8)return!1;if(Math.abs(o[e]-r)>this.strictLimit||Math.abs(r)>.8)return!1}return t.x=a,t.y=r,!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(hn(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=gn(e[s],e[(s+1)%4],t[n],t[(n+1)%4]);o&&i.push(o)}return e.forEach(e=>{dn(t,e)&&i.push(e)}),t.forEach(t=>{dn(e,t)&&i.push(t)}),pn(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 vn,Rn,Cn,Tn,wn,Sn;const An={barcode:2,text_line:4,detected_quad:8,deskewed_image:16},Dn=(e,t)=>"string"==typeof e?t[An[e]]:t[e],bn=(e,t,i)=>{"string"==typeof e?t[An[e]]=i:t[e]=i},On=(e,t,i)=>{const s=[{type:Ee.CRIT_BARCODE,resultName:"decodedBarcodesResult",itemNames:["barcodeResultItems"]},{type:Ee.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},Ln=e=>{const t=[];return e&Ee.CRIT_BARCODE&&t.push(Ee.CRIT_BARCODE),e&Ee.CRIT_TEXT_LINE&&t.push(Ee.CRIT_TEXT_LINE),e&Ee.CRIT_DETECTED_QUAD&&t.push(Ee.CRIT_DETECTED_QUAD),e&Ee.CRIT_DESKEWED_IMAGE&&t.push(Ee.CRIT_DESKEWED_IMAGE),t};class Nn{constructor(){this.verificationEnabled={[Ee.CRIT_BARCODE]:!1,[Ee.CRIT_TEXT_LINE]:!0,[Ee.CRIT_DETECTED_QUAD]:!0,[Ee.CRIT_DESKEWED_IMAGE]:!1},this.duplicateFilterEnabled={[Ee.CRIT_BARCODE]:!1,[Ee.CRIT_TEXT_LINE]:!1,[Ee.CRIT_DETECTED_QUAD]:!1,[Ee.CRIT_DESKEWED_IMAGE]:!1},this.duplicateForgetTime={[Ee.CRIT_BARCODE]:3e3,[Ee.CRIT_TEXT_LINE]:3e3,[Ee.CRIT_DETECTED_QUAD]:3e3,[Ee.CRIT_DESKEWED_IMAGE]:3e3},this.crossVerificationCriteria={[Ee.CRIT_BARCODE]:{frameWindow:5,minConsistentFrames:2},[Ee.CRIT_TEXT_LINE]:{frameWindow:5,minConsistentFrames:2},[Ee.CRIT_DETECTED_QUAD]:{frameWindow:6,minConsistentFrames:4},[Ee.CRIT_DESKEWED_IMAGE]:{frameWindow:6,minConsistentFrames:4}},vn.set(this,new Map),Rn.set(this,new Map),Cn.set(this,new Map),Tn.set(this,new Map),wn.set(this,new Map),Sn.set(this,new Map),this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,this.latestOverlappingEnabled={[Ee.CRIT_BARCODE]:!1,[Ee.CRIT_TEXT_LINE]:!1,[Ee.CRIT_DETECTED_QUAD]:!1,[Ee.CRIT_DESKEWED_IMAGE]:!1},this.maxOverlappingFrames={[Ee.CRIT_BARCODE]:this.crossVerificationFrames,[Ee.CRIT_TEXT_LINE]:this.crossVerificationFrames,[Ee.CRIT_DETECTED_QUAD]:this.crossVerificationFrames,[Ee.CRIT_DESKEWED_IMAGE]:this.crossVerificationFrames},Object.defineProperties(this,{onOriginalImageResultReceived:{value:e=>{},writable:!1},onDecodedBarcodesReceived:{value:e=>{this.latestOverlappingFilter(e),On(this,e,Ee.CRIT_BARCODE)},writable:!1},onRecognizedTextLinesReceived:{value:e=>{On(this,e,Ee.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===Ee.CRIT_PARSED_RESULT&&t[e].isFilter&&t.splice(e,1);e.parsedResult&&(e.parsedResult.parsedResultItems=e.parsedResult.parsedResultItems.filter(e=>!e.isFilter),0===e.parsedResult.parsedResultItems.length&&delete e.parsedResult)},writable:!1}})}_dynamsoft(){Qs(this,vn,"f").forEach((e,t)=>{bn(t,this.verificationEnabled,e)}),Qs(this,Rn,"f").forEach((e,t)=>{bn(t,this.duplicateFilterEnabled,e)}),Qs(this,Cn,"f").forEach((e,t)=>{bn(t,this.duplicateForgetTime,e)}),Qs(this,Tn,"f").forEach((e,t)=>{bn(t,this.latestOverlappingEnabled,e)}),Qs(this,wn,"f").forEach((e,t)=>{bn(t,this.maxOverlappingFrames,e)}),Qs(this,Sn,"f").forEach((e,t)=>{bn(t,this.crossVerificationCriteria,e)})}enableResultCrossVerification(e,t=!0){if("number"==typeof e){const i=Ln(e);for(let e of i)Qs(this,vn,"f").set(e,t)}else Qs(this,vn,"f").set(e,t)}isResultCrossVerificationEnabled(e){return Dn(e,this.verificationEnabled)}enableResultDeduplication(e,t=!0){if(t&&this.enableLatestOverlapping(e,!1),"number"==typeof e){const i=Ln(e);for(let e of i)Qs(this,Rn,"f").set(e,t)}else Qs(this,Rn,"f").set(e,t)}isResultDeduplicationEnabled(e){return Dn(e,this.duplicateFilterEnabled)}setDuplicateForgetTime(e,t){if(t>18e4&&(t=18e4),t<0&&(t=0),"number"==typeof e){const i=Ln(e);for(let e of i)Qs(this,Cn,"f").set(e,t)}else Qs(this,Cn,"f").set(e,t)}getDuplicateForgetTime(e){return Dn(e,this.duplicateForgetTime)}getFilteredResultItemTypes(){let e=0;const t=[Ee.CRIT_BARCODE,Ee.CRIT_TEXT_LINE,Ee.CRIT_DETECTED_QUAD,Ee.CRIT_DESKEWED_IMAGE,Ee.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=Ln(e);for(let e of s)Qs(this,Sn,"f").set(e,{frameWindow:t,minConsistentFrames:i})}else Qs(this,Sn,"f").set(e,{frameWindow:t,minConsistentFrames:i})}getResultCrossVerificationCriteria(e){return Dn(e,this.crossVerificationCriteria)}enableLatestOverlapping(e,t=!0){if(t&&this.enableResultDeduplication(e,!1),"number"==typeof e){const i=Ln(e);for(let e of i)Qs(this,Tn,"f").set(e,t)}else Qs(this,Tn,"f").set(e,t)}isLatestOverlappingEnabled(e){return Dn(e,this.latestOverlappingEnabled)}setMaxOverlappingFrames(e,t){if("number"==typeof e){const i=Ln(e);for(let e of i)Qs(this,wn,"f").set(e,t)}else Qs(this,wn,"f").set(e,t)}getMaxOverlappingFrames(e){return Dn(e,this.maxOverlappingFrames)}latestOverlappingFilter(e){var t,i,s;const n=this.isResultCrossVerificationEnabled(Ee.CRIT_BARCODE),o=this.isLatestOverlappingEnabled(Ee.CRIT_BARCODE);if(o){const a=this.crossVerificationFrames,r=60,c=o?this.getMaxOverlappingFrames(Ee.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(sn.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0);return new In(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 a=0;a<this.overlapSet.length;a++){if(e[t][a]<1)continue;const r=this.overlapSet[a],c=r.item;if(o.format===c.format&&o.text===c.text){if(n=r.isProbablySameLocationWithOffset(f[t],i),n){s[t]=a,e[t][a]=0;break}}else e[t][a]=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 a=this.overlapSet[t],r=a.item;if(o.format===r.format&&o.text===r.text){if(a.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(sn.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0),o=e.confidence<r,a=new In(c,s?1:2,s,i);n&&s&&o&&_.push(t),this.overlapSet.push(a)}});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,a=this.overlapSet[n].item.format;if(e.format===a&&e.text===o){if(this.overlapSet[n].isOverlappedLocationWithOffset(e,m,!1)){const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(sn.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0),o=s?1:2;this.overlapSet[n]=new In(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 a={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};if(yn(s,o,e.moduleSize,a)){e.location=a;const t=Object.assign({},e),s=(BigInt(t.format)&BigInt(sn.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0),o=s?1:2;this.overlapSet[n]=new In(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(sn.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0),n=s?1:2;this.overlapSet[e]=new In(c,n,s,t)}this.overlapSet[e]&&(this.overlapSet[e].overlapCount=c,this.overlapSet[e].verificationCount=2,this.overlapSet[e].crossVerificationFrame=a)}}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),a=(BigInt(i.format)&BigInt(sn.BF_ONED))!=BigInt(0)||(BigInt(i.format)&BigInt(sn.BF_GS1_DATABAR))!=BigInt(0),l=i.confidence<r,d=new In(c,a?1:2,a,o);n&&a&&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 Mn,Bn,Fn,xn;vn=new WeakMap,Rn=new WeakMap,Cn=new WeakMap,Tn=new WeakMap,wn=new WeakMap,Sn=new WeakMap;class Pn{static async readFromFile(e){if("string"==typeof e){if(!V(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=z(e);return j(s,t,i)}static async readFromMemory(e){if(!Qs(Mn,Mn,"f",Bn).has(e))throw new Error("Image data ID does not exist.");return Qs(Mn,Mn,"f",Bn).get(e)}static async saveToMemory(e,t){var i,s,n;const o=await ln(e,t),a=await K(o),r=(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=Mn,Mn,(n=Qs(i,Mn,"f",Fn),s=n++,n),0,Fn),s);return Qs(Mn,Mn,"f",Bn).set(r,a),r}static async readFromBase64String(e){const t=await async function(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=z(e);const s=await ln(i,t);return await async function(e){return await new Promise((t,i)=>{const s=new FileReader;s.onload=()=>{t(s.result)},s.onerror=e=>{i(e)},s.readAsDataURL(e)})}(s)}}Mn=Pn,Bn={value:new Map},Fn={value:0};class kn{static async drawOnImage(e,t,i,s=4294901760,n=1,o="test.png",a){if(!e)throw new Error("Invalid image.");if(!t)throw new Error("Invalid drawingItem.");if(!i)throw new Error("Invalid type.");let r;if(e instanceof Blob)r=await K(e);else if("string"==typeof e){let t=await U(e,"blob");r=await K(t)}else L(e)&&(r=e,"bigint"==typeof r.format&&(r.format=Number(r.format)));return await new Promise((e,c)=>{let l=Ue();Ve[l]=async function(t){if(t.success)return a&&Pn.saveToFile(t.image,o,a),e(t.image);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,c(e)}},Pe.postMessage({type:"utility_drawOnImage",id:l,body:{dsImage:r,drawingItem:Array.isArray(t)?t:[t],color:s,thickness:n,type:i}})})}}class Un{static async cropImage(e,t){const{bytes:i,width:s,height:n,stride:o,format:a}=L(e)?e:await K(e);return await new Promise((e,r)=>{let c=Ue();Ve[c]=async function(t){if(t.success)return e(t.cropImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,r(e)}},Pe.postMessage({type:"utility_cropImage",id:c,body:{type:"Rect",bytes:i,width:s,height:n,stride:o,format:a,roi:t}})})}static async adjustBrightness(e,t){const{bytes:i,width:s,height:n,stride:o,format:a}=L(e)?e:await K(e);return await new Promise((e,r)=>{let c=Ue();Ve[c]=async function(t){if(t.success)return e(t.adjustBrightness);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,r(e)}},Pe.postMessage({type:"utility_adjustBrightness",id:c,body:{bytes:i,width:s,height:n,stride:o,format:a,brightness:t}})})}static async adjustContrast(e,t){const{bytes:i,width:s,height:n,stride:o,format:a}=L(e)?e:await K(e);return await new Promise((e,r)=>{let c=Ue();Ve[c]=async function(t){if(t.success)return e(t.adjustContrast);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,r(e)}},Pe.postMessage({type:"utility_adjustContrast",id:c,body:{bytes:i,width:s,height:n,stride:o,format:a,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:a}=L(e)?e:await K(e);return await new Promise((e,r)=>{let c=Ue();Ve[c]=async function(t){if(t.success)return e(t.filterImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,r(e)}},Pe.postMessage({type:"utility_filterImage",id:c,body:{bytes:i,width:s,height:n,stride:o,format:a,filterType:t}})})}static async convertToGray(e,t,i,s){const{bytes:n,width:o,height:a,stride:r,format:c}=L(e)?e:await K(e);return await new Promise((e,l)=>{let d=Ue();Ve[d]=async function(t){if(t.success)return e(t.convertToGray);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,l(e)}},Pe.postMessage({type:"utility_convertToGray",id:d,body:{bytes:n,width:o,height:a,stride:r,format:c,R:t,G:i,B:s}})})}static async convertToBinaryGlobal(e,t=-1,i=!1){const{bytes:s,width:n,height:o,stride:a,format:r}=L(e)?e:await K(e);return await new Promise((e,c)=>{let l=Ue();Ve[l]=async function(t){if(t.success)return e(t.convertToBinaryGlobal);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,c(e)}},Pe.postMessage({type:"utility_convertToBinaryGlobal",id:l,body:{bytes:s,width:n,height:o,stride:a,format:r,threshold:t,invert:i}})})}static async convertToBinaryLocal(e,t=0,i=10,s=!1){const{bytes:n,width:o,height:a,stride:r,format:c}=L(e)?e:await K(e);return await new Promise((e,l)=>{let d=Ue();Ve[d]=async function(t){if(t.success)return e(t.convertToBinaryLocal);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,l(e)}},Pe.postMessage({type:"utility_convertToBinaryLocal",id:d,body:{bytes:n,width:o,height:a,stride:r,format:c,blockSize:t,compensation:i,invert:s}})})}static async cropAndDeskewImage(e,t,i=0,s=0,n=0){const{bytes:o,width:a,height:r,stride:c,format:l}=L(e)?e:await K(e);return await new Promise((e,d)=>{let u=Ue();Ve[u]=async function(t){if(t.success)return e(t.cropAndDeskewImage);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,d(e)}},Pe.postMessage({type:"utility_cropAndDeskewImage",id:u,body:{bytes:o,width:a,height:r,stride:c,format:l,roi:t,dstWidth:i,dstHeight:s,padding:n}})})}}!function(e){e[e.LP_UNKNOWN=0]="LP_UNKNOWN",e[e.LP_LINES=1]="LP_LINES",e[e.LP_MATRIX=2]="LP_MATRIX"}(xn||(xn={}));const Vn={pattern:xn.LP_UNKNOWN,axes:[{elementCount:-1,isStaggered:!1,angle:-1,isEqualSpacing:!1,spacing:-1,spacingUnit:Me.MU_PIXEL},{elementCount:-1,isStaggered:!1,angle:-1,isEqualSpacing:!1,spacing:-1,spacingUnit:Me.MU_PIXEL}],inputImageWidth:0,inputImageHeight:0};class Gn{static async analyze(e,t){return Object.assign(Vn,t),await new Promise(async function(t,i){let s=Ue();Ve[s]=e=>{if(!e.success){let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}t(e.analyzeResult)},Pe.postMessage({type:"utility_analyze",id:s,body:{inputQuads:e,parameter:Vn}})})}}var Wn,jn,Zn,Hn;!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"}(Wn||(Wn={})),function(e){e[e.LES_NONE=0]="LES_NONE",e[e.LES_INPUT=1]="LES_INPUT",e[e.LES_INFERRED=2]="LES_INFERRED"}(jn||(jn={}));var qn=new WeakMap,Yn=new WeakMap,zn=new WeakMap,$n=new WeakMap,Kn=new WeakMap,Xn=new WeakMap,Qn=new WeakMap,Jn=new WeakMap,eo=new WeakMap,to=new WeakMap,io=new WeakSet;class so{constructor(e){if(o(this,io),a(this,"_cameraEnhancer",void 0),a(this,"_cameraView",void 0),a(this,"_cvRouter",void 0),s(this,qn,!1),s(this,Yn,void 0),s(this,zn,void 0),s(this,$n,void 0),s(this,Kn,void 0),s(this,Xn,new Map),s(this,Qn,[]),s(this,Jn,void 0),s(this,eo,new Qe),s(this,to,{status:{code:d.RS_SUCCESS,message:"Success."},barcodeResults:[]}),a(this,"config",Ms($e)),e&&"object"!=typeof e||Array.isArray(e))throw new Error("Invalid config.");n(Jn,this,e),Ls(this.config,e)}get disposed(){return i(qn,this)}async launch(){if(i(qn,this))throw new Error("The BarcodeScanner instance has been destroyed.");if(e(so,Hn,bo)._&&!e(so,Hn,bo)._.isFulfilled&&!e(so,Hn,bo)._.isRejected)throw new Error("Cannot call `launch()` while a previous task is still running.");if(bo._=e(so,Hn,new Qe),!As.getDeviceFriendlyName())try{As.setDeviceFriendlyName("dbr_rtu")}catch(e){}return e(io,this,no).call(this),e(so,Hn,bo)._}async decode(t,s){if(this.disposed)return Promise.reject(new Error("Cannot call decode on a disposed instance. This instance was disposed after launch completed."));const o=new Kt;try{await e(io,this,oo).call(this,!0),i(Kn,this)||n(Kn,this,new Nn),i(Kn,this).enableResultCrossVerification(2,!1),await this._cvRouter.addResultFilter(i(Kn,this)),o.onCapturedResultReceived=()=>{},this._cvRouter.addResultReceiver(o),s||(s=this.config.utilizedTemplateNames.image);return await this._cvRouter.capture(t,s)}catch(e){throw e}finally{var a;i(Kn,this)&&(i(Kn,this).enableResultCrossVerification(2,!0),await this._cvRouter.addResultFilter(i(Kn,this))),null===(a=this._cvRouter)||void 0===a||a.removeResultReceiver(o)}}dispose(){var t,s,o,a,r,c,l;n(qn,this,!0),e(so,Hn,bo)._&&e(so,Hn,bo)._.isPending&&e(so,Hn,bo)._.resolve(i(to,this)),null===(t=this._cameraEnhancer)||void 0===t||t.dispose(),null===(s=this._cameraView)||void 0===s||s.dispose(),null===(o=this._cvRouter)||void 0===o||o.dispose(),this._cameraEnhancer=null,this._cameraView=null,this._cvRouter=null,null===(a=document.querySelector(".scanner-view-container"))||void 0===a||a.remove(),null===(r=document.querySelector(".result-view-container"))||void 0===r||r.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 i(Xn,this))for(let i of t)window.removeEventListener(e,i);i(Xn,this).clear();for(let e of i(Qn,this))document.head.removeChild(e);n(Qn,this,[])}}async function no(){try{if(this.config.onInitPrepare&&this.config.onInitPrepare(),this.disposed)return;if(await e(io,this,oo).call(this),this.config.onInitReady&&this.config.onInitReady({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed)return;let t=!1;try{if(document.querySelector(".loading-page span").innerText="Accessing Camera...",await this._cameraEnhancer.open(),Ns(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){e(io,this,To).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),t=!0,this.disposed)return}if(this.config.autoStartCapturing&&!t&&(await this._cvRouter.startCapturing(i(zn,this)),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter}),this.disposed))return}catch(t){i(to,this).status={code:d.RS_FAILED,message:t.message||t},e(Zn,Hn,bo)._.reject(new Error(i(to,this).status.message)),this.dispose()}finally{e(io,this,wo).call(this,"Loading...",!1)}}async function oo(t=!1){ze.engineResourcePaths=this.config.engineResourcePaths;const s=W(ze.engineResourcePaths);if(!t){let t=e(Zn,Hn,Oo)._.get("dceUI");if(t||(t=await U(s.dbrBundle+"ui/dce.rtu.ui.xml","text"),e(Zn,Hn,Oo)._.set("dceUI",t)),this.disposed)return;if(this._cameraView=await bi.createInstance(t),this.disposed)return;if(this.config.scanMode===l.SM_SINGLE||this.config.scannerViewConfig.customHighlightForBarcode){this._cameraView.getDrawingLayer(2).setVisible(!1)}if(this._cameraEnhancer=await Di.createInstance(this._cameraView),this.disposed)return;if(await e(io,this,ro).call(this),this.disposed)return;this.config.scannerViewConfig.customHighlightForBarcode&&n($n,this,this._cameraEnhancer.getCameraView().createDrawingLayer())}if([null,void 0].includes(this.config.license)||(As._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 As.initLicense(this.config.license,{executeNow:!0})),this.disposed)return;if(this._cvRouter=this._cvRouter||await Gt.createInstance(!1),this._cvRouter._s=!0,this.disposed)return;let o=e(Zn,Hn,Oo)._.get("presetTemplates");if(o||(o=await U(s.dbrBundle+"templates/DBR-PresetTemplates.json","text"),e(Zn,Hn,Oo)._.set("presetTemplates",o)),!i(eo,this).isPending||(await this._cvRouter.initSettings(o),await e(io,this,ao).call(this,t),!this.disposed)){if(!t){if(this._cvRouter.setInput(this._cameraEnhancer),e(io,this,po).call(this),await e(io,this,fo).call(this),this.disposed)return;this._cvRouter.onCaptureError=t=>{e(Zn,Hn,bo)._.reject(new Error(t.message)),this.dispose()},this._cvRouter._dynamsoft=!(this.config.scanMode===l.SM_SINGLE)}i(eo,this).resolve()}}async function ao(t=!1){let s=this.config.templateFilePath;if(s){let t,n=!1;if(Qt(s)&&(n=s.reloadResource,s=s.path),n)t=await U(s,"text"),e(Zn,Hn,Oo)._.delete("templateFile");else{t=e(Zn,Hn,Oo)._.get("templateFile"),t||(t=await U(s,"text"),e(Zn,Hn,Oo)._.set("templateFile",t)),t=JSON.parse(t);const n=t.CaptureVisionTemplates[0].Name;i(Jn,this).utilizedTemplateNames?(i(Jn,this).utilizedTemplateNames.image||(this.config.utilizedTemplateNames.image=n),i(Jn,this).utilizedTemplateNames.multi_unique||(this.config.utilizedTemplateNames.multi_unique=n),i(Jn,this).utilizedTemplateNames.single||(this.config.utilizedTemplateNames.single=n)):this.config.utilizedTemplateNames={image:n,multi_unique:n,single:n}}if(this.disposed)return;if(await this._cvRouter.initSettings(t),this.disposed)return}const o=await this._cvRouter.outputSettings("*",!0);if(this.disposed)return;if(!t&&this.config.scanMode===l.SM_SINGLE)for(let e of o.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 o.BarcodeReaderTaskSettingOptions){t.BarcodeFormatIds=[];for(let i in Us)for(let s in a)e(a[s],Us[i])&&t.BarcodeFormatIds.push(i)}}await this._cvRouter.initSettings(o),this.disposed||t||(this.config.scanMode===l.SM_SINGLE?n(zn,this,this.config.utilizedTemplateNames.single):this.config.scanMode===l.SM_MULTI_UNIQUE&&n(zn,this,this.config.utilizedTemplateNames.multi_unique))}async function ro(){let t,s,o=this.config.uiPath||W(this.config.engineResourcePaths).dbrBundle,a=!1;Qt(o)&&(a=o.reloadResource,o=o.path);let r=o.endsWith("/")?Ys(o)+"ui/barcode-scanner.ui.xml":Ys(o).slice(0,-1);if(a?(t=await U(r,"text"),e(Zn,Hn,Oo)._.delete("dbsUI")):(t=e(Zn,Hn,Oo)._.get("dbsUI"),t||(t=await U(r,"text"),e(Zn,Hn,Oo)._.set("dbsUI",t))),s=(e=>{if(!e.trim().startsWith("<"))throw Error("Unable to get valid HTMLElement.");const t=document.createElement("div");if(t.insertAdjacentHTML("beforeend",e),1===t.childElementCount&&t.firstChild instanceof HTMLTemplateElement)return t.firstChild.content;const i=new DocumentFragment;for(let e of t.children)i.append(e);return i})(t),this.disposed)return;if(s.querySelectorAll("style").forEach(e=>{const t=e.cloneNode(!0);i(Qn,this).push(t),document.head.appendChild(t)}),this.config.scanMode===l.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)}n(Yn,this,s.querySelector(".result-item")),e(io,this,co).call(this,s),e(io,this,lo).call(this,s),e(io,this,uo).call(this,s),e(io,this,ho).call(this,s),await e(io,this,_o).call(this,s),e(io,this,Co).call(this,s),e(io,this,go).call(this,s),e(io,this,mo).call(this,s)}function co(t){const s=t.querySelector(".btn-clear");var n;if(s&&(s.addEventListener("click",()=>{i(to,this).barcodeResults=[],e(io,this,vo).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 e=this.config.resultViewConfig.toolbarButtonsConfig.clear;s.style.display=e.isHidden?"none":"flex",s.className=e.className,s.innerText=e.label,e.isHidden&&(t.querySelector(".toolbar-btns").style.justifyContent="center")}}function lo(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 uo(e){var t;if(null===(t=this.config)||void 0===t||null===(t=t.scannerViewConfig)||void 0===t?void 0:t.showCloseButton){const t=e.querySelector(".btn-close");t&&(t.style.display="inline",t.addEventListener("click",()=>{i(to,this).barcodeResults=[],i(to,this).status={code:d.RS_CANCELLED,message:"Cancelled."},this.dispose()}))}}function ho(t){var i;if(null===(i=this.config)||void 0===i?void 0:i.scannerViewConfig.showFlashButton){const i=t.querySelector(".btn-flash-auto"),s=t.querySelector(".btn-flash-open"),n=t.querySelector(".btn-flash-close");i&&(i.style.display="inline",this._cameraEnhancer.addEventListener("opened",async()=>{if(!this._cameraEnhancer.currentCamera)return void e(io,this,To).call(this,{auto:!1,open:!1,close:!1,notSupport:!1});const t=this._cameraEnhancer.isSupportTorch;for(this.config.scannerViewConfig.showFlashButton&&(t?e(io,this,To).call(this,{auto:!0,open:!1,close:!1,notSupport:!1}):e(io,this,To).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()&&t&&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 _o(t){let s=this.config.scannerViewConfig.cameraSwitchControl;["toggleFrontBack","listAll","hidden"].includes(s)||(this.config.scannerViewConfig.cameraSwitchControl="hidden");if("hidden"!==this.config.scannerViewConfig.cameraSwitchControl){const s=t.querySelector(".camera-control");if(s){s.style.display="block";const n=await this._cameraEnhancer.getAllCameras(),o=this.config.scannerViewConfig.cameraSwitchControl,a=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},r=()=>{if(0===n.length)return null;if("listAll"===o){const s=t.querySelector(".camera-list");for(let e of n){const t=a(e);s.append(t)}const o=()=>{const e=document.querySelector(".camera-list");e&&(e.style.display="none")},r=i(Xn,this).get("click")||[];i(Xn,this).set("click",[...r,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"};s.addEventListener("click",async t=>{t.stopPropagation();const n=t.target;e(io,this,wo).call(this,"Accessing Camera...",!0),this._cvRouter.stopCapturing(),await this._cameraEnhancer.selectCamera({deviceId:n.deviceId,label:n.label});const o=this._cameraEnhancer.getSelectedCamera();Ns(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(i(zn,this)),this.config.onCaptureStart&&this.config.onCaptureStart({cameraView:this._cameraView,cameraEnhancer:this._cameraEnhancer,cvRouter:this._cvRouter})),e(io,this,wo).call(this,"Loading...",!1),s.style.display="none"});const l=t.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()=>{e(io,this,wo).call(this,"Accessing Camera...",!0);const t=Ns(this._cameraEnhancer.getSelectedCamera());console.log(t),await this._cameraEnhancer.requestCamera(t?"back":"front");Ns(this._cameraEnhancer.getSelectedCamera())?(this.config.scannerViewConfig.mirrorFrontCamera&&(this._cameraEnhancer.isMirrored=!0),this.config.scannerViewConfig.showFlashButton&&e(io,this,To).call(this,{auto:!1,open:!1,close:!1,notSupport:!0})):(this._cameraEnhancer.isMirrored=!1,this.config.scannerViewConfig.showFlashButton&&e(io,this,To).call(this,{auto:!0,open:!1,close:!1,notSupport:!1})),e(io,this,wo).call(this,"Loading...",!1)}:void 0},c=r();s.addEventListener("click",async e=>{e.stopPropagation(),c&&await c()})}}}function mo(e){const t=this._cameraView.getUIElement();this._cameraView.setVideoFit("cover");const s=e.querySelector(".barcode-scanner-container");s.style.display=bs()?"flex":"block",this.config.scanMode===l.SM_MULTI_UNIQUE&&!1!==this.config.showResultView?this.config.showResultView=!0:this.config.scanMode===l.SM_SINGLE&&(this.config.showResultView=!1);const n=this.config.showResultView;let o;if(this.config.container?(s.style.position="relative",o=this.config.container):o=document.body,"string"==typeof o&&(o=document.querySelector(o),null===o))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 r=this.config.resultViewConfig.container;if("string"==typeof r&&(r=document.querySelector(r),null===r))throw new Error("Failed to get the container of the result view.");const c=e.querySelector(".scanner-view-container"),d=e.querySelector(".result-view-container"),u=e.querySelector(".loading-page");c.append(u),a&&(c.append(t),a.append(c)),r&&r.append(d),a||r?a&&!r?(this.config.container||(d.style.position="absolute"),r=d,o.append(d)):!a&&r&&(this.config.container||(c.style.position="absolute"),a=c,c.append(t),o.append(c)):(a=c,r=d,n&&(Object.assign(c.style,{width:bs()?"50%":"100%",height:bs()?"100%":"50%"}),Object.assign(d.style,{width:bs()?"50%":"100%",height:bs()?"100%":"50%"})),c.append(t),o.append(s)),document.querySelector(".result-view-container").style.display=n?"block":"none",this.config.showPoweredByDynamsoft||(this._cameraEnhancer.setPowerByMessageVisible(!1),document.querySelector(".no-result-svg").style.display="none");const h=()=>{Object.assign(s.style,{display:bs()?"flex":"block"}),!n||this.config.scannerViewConfig.container||this.config.resultViewConfig.container||(Object.assign(a.style,{width:bs()?"50%":"100%",height:bs()?"100%":"50%"}),Object.assign(r.style,{width:bs()?"50%":"100%",height:bs()?"100%":"50%"}))},_=i(Xn,this).get("resize")||[];i(Xn,this).set("resize",[..._,h]),window.addEventListener("resize",h)}function go(e){var t;null===(t=e.querySelector(".resume"))||void 0===t||t.addEventListener("click",async()=>{var e,t,s;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===(s=this._cameraView.getUIElement().shadowRoot.querySelectorAll(".single-barcode-result-option"))||void 0===s||s.forEach(e=>null==e?void 0:e.remove()),await this._cameraEnhancer.resume(),await new Promise(e=>{setTimeout(e,100)}),this._cvRouter.startCapturing(i(zn,this))})}function po(){const t=new Kt;t.onCapturedResultReceived=async t=>{if(i($n,this)&&i($n,this).clearDrawingItems(),t.decodedBarcodesResult){if(this.config.scannerViewConfig.customHighlightForBarcode){let e=[];for(let i of t.decodedBarcodesResult.barcodeResultItems)e.push(this.config.scannerViewConfig.customHighlightForBarcode(i));i($n,this).addDrawingItems(e)}this.config.scanMode===l.SM_SINGLE?e(io,this,Eo).call(this,t):e(io,this,yo).call(this,t)}},this._cvRouter.addResultReceiver(t)}async function fo(){i(Kn,this)||n(Kn,this,new Nn),i(Kn,this).enableResultCrossVerification(2,!0),i(Kn,this).enableResultDeduplication(2,!0),i(Kn,this).setDuplicateForgetTime(2,this.config.duplicateForgetTime),await this._cvRouter.addResultFilter(i(Kn,this)),i(Kn,this).isResultCrossVerificationEnabled=()=>!1,i(Kn,this).isResultDeduplicationEnabled=()=>!1}function Eo(t){const i=this._cameraView.getUIElement().shadowRoot;let s=new Promise(s=>{if(t.decodedBarcodesResult.barcodeResultItems.length>1){e(io,this,Io).call(this);let n=[];for(let e of t.decodedBarcodesResult.barcodeResultItems){let t=0,i=0;for(let s=0;s<4;++s){let n=e.location.points[s];t+=n.x,i+=n.y}let o=this._cameraEnhancer.getVisibleAreaInVideoXY({isConsiderRegionBox:!0,rounded:!0}),a=this._cameraEnhancer.videoXY2FixedLT([{x:o.x+t/4,y:o.y+i/4}]),r=document.createElement("div");r.className="single-barcode-result-option",Object.assign(r.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"}),r.style.left=a[0].left+"px",r.style.top=a[0].top+"px",r.addEventListener("click",()=>{s(e)}),n.push(r)}i.append(...n)}else s(t.decodedBarcodesResult.barcodeResultItems[0])});s.then(async i=>{const s=t.items.filter(e=>e.type===Ee.CRIT_ORIGINAL_IMAGE)[0],n=s.imageData,o={status:{code:d.RS_SUCCESS,message:"Success."},originalImageResult:n,barcodeImage:(()=>{const e=Z(n),t=i.location.points,s=Math.min(...t.map(e=>e.x)),o=Math.min(...t.map(e=>e.y)),a=Math.max(...t.map(e=>e.x)),r=Math.max(...t.map(e=>e.y)),c=a-s,l=r-o,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-s,t[0].y-o);for(let e=1;e<t.length;e++)u.lineTo(t[e].x-s,t[e].y-o);u.closePath(),u.clip(),u.drawImage(e,-s,-o);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:f.IPF_ABGR_8888}})(),barcodeResults:[i]};e(io,this,So).call(this,i),e(Zn,Hn,bo)._.resolve(o),this.dispose()})}function yo(t){for(let s of t.decodedBarcodesResult.barcodeResultItems){if(!1!==s.duplicate)continue;const t=i(to,this).barcodeResults.findIndex(e=>`${e.formatString}_${e.text}`==`${s.formatString}_${s.text}`);-1===t?(s.count=1,i(to,this).barcodeResults.unshift(s),e(io,this,vo).call(this,s)):(i(to,this).barcodeResults[t].count++,e(io,this,Ro).call(this,t)),this.config.onUniqueBarcodeScanned&&this.config.onUniqueBarcodeScanned(s)}}function Io(){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 vo(e){if(!this.config.showResultView)return;const t=document.querySelector(".no-result-svg");if(!(this.config.showResultView&&this.config.scanMode!==l.SM_SINGLE))return;const s=document.querySelector(".main-list");if(!e)return s.textContent="",void(this.config.showPoweredByDynamsoft&&(t.style.display="inline"));t.style.display="none";const n=(e=>{const t=i(Yn,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")],s=t.findIndex(t=>t.id===`${e.formatString}_${e.text}`);i(to,this).barcodeResults.splice(s,1),t[s].remove(),0===i(to,this).barcodeResults.length&&this.config.showPoweredByDynamsoft&&(document.querySelector(".no-result-svg").style.display="inline")}),t})(e);s.insertBefore(n,document.querySelector(".result-item"))}function Ro(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 Co(t){if(this.config.showUploadImageButton){const s=t.querySelector(".btn-upload-image");s.style.display="flex",s.addEventListener("change",async t=>{const s=t.target.files;if(!s)return;const n={status:{code:d.RS_SUCCESS,message:"Success."},barcodeResults:[]};let o=0;e(io,this,wo).call(this,`Capturing... [${o}/${s.length}]`,!0);let a=!1;for(let e=0;e<s.length;e++)if(!Bs(s[e])){a=!0;break}if(a)return e(Zn,Hn,bo)._.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 t of s)try{this._cvRouter.stopCapturing();const a=await this.decode(t,this.config.utilizedTemplateNames.image);if(a.decodedBarcodesResult)if(this.config.scanMode===l.SM_MULTI_UNIQUE)for(let t of a.decodedBarcodesResult.barcodeResultItems){const s=i(to,this).barcodeResults.findIndex(e=>`${e.formatString}_${e.text}`==`${t.formatString}_${t.text}`);-1===s?(t.count=1,i(to,this).barcodeResults.unshift(t),e(io,this,vo).call(this,t)):(i(to,this).barcodeResults[s].count++,e(io,this,Ro).call(this,s)),this.config.onUniqueBarcodeScanned&&this.config.onUniqueBarcodeScanned(t)}else if(a.decodedBarcodesResult.barcodeResultItems)for(let e of a.decodedBarcodesResult.barcodeResultItems){const t=n.barcodeResults.find(t=>`${t.text}_${t.formatString}`==`${e.text}_${e.formatString}`);t?t.count++:(e.count=1,n.barcodeResults.push(e))}e(io,this,wo).call(this,`Capturing... [${++o}/${s.length}]`,!0)}catch(t){return n.status={code:d.RS_FAILED,message:t.message||t},e(Zn,Hn,bo)._.reject(new Error(n.status.message)),void this.dispose()}e(io,this,wo).call(this,"Loading...",!1),this.config.scanMode===l.SM_SINGLE?(e(Zn,Hn,bo)._.resolve(n),this.dispose()):this._cvRouter.startCapturing(i(zn,this)),t.target.value=""})}}function To(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 wo(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 So(e){let t=Ue();Ve[t]=()=>{},Pe.postMessage({type:"cvr_cc",id:t,instanceID:this._cvRouter._instanceID,body:{text:e.text,strFormat:e.format.toString(),isDPM:e.isDPM}})}Zn=so;var Ao,Do,bo={_:null},Oo={_:new Map};function Lo(e){delete e.moduleId;const t=JSON.parse(e.jsonString).ResultInfo,i=e.fullCodeString,s=e.fieldNames;e.getFieldValue=e=>"fullcodestring"===e.toLowerCase()?i:No(t,e,"map"),e.getFieldRawValue=e=>"fullcodestring"===e.toLowerCase()?i:No(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=Bo(t,e))&&void 0!==i?i:Do.VS_NONE},e.getAllFieldNames=()=>s,delete e.fieldNames,delete e.fullCodeString}function No(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=No(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 Bo(e,t){var i;for(const s of e){if(s.FieldName===t)return s.ValidationStatus?Do[s.ValidationStatus]:Do.VS_NONE;if(null===(i=s.ChildFields)||void 0===i?void 0:i.length)for(const e of s.ChildFields){const i=Bo(e,t);if(void 0!==i)return i}}}function Fo(e){if(e.disposed)throw new Error('"CodeParser" instance has been disposed')}Hn=so,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"}(Do||(Do={}));const xo=e=>e&&"object"==typeof e&&"function"==typeof e.then,Po=(async()=>{})().constructor;class ko extends Po{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){var t=this;let i;this._task=e,xo(e)?i=e:"function"==typeof e&&(i=new Po(e)),i&&async function(){try{const s=await i;e===t._task&&t.resolve(s)}catch(i){e===t._task&&t.reject(i)}}()}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&&(xo(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}}class Uo{constructor(){this._instanceID=void 0,this.bDestroyed=!1}static async createInstance(){await Ze.license.dynamsoft(),await ze.loadWasm();const e=new Uo,t=new ko;let i=Ue();return Ve[i]=async function(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)}},Pe.postMessage({type:"dcp_createInstance",id:i}),t}async dispose(){Fo(this);let e=Ue();this.bDestroyed=!0,Ve[e]=e=>{if(!e.success){let t=new Error(e.message);throw t.stack=e.stack+"\n"+t.stack,t}},Pe.postMessage({type:"dcp_dispose",id:e,instanceID:this._instanceID})}get disposed(){return this.bDestroyed}async initSettings(e){if(Fo(this),e&&["string","object"].includes(typeof e))return"string"==typeof e?e.trimStart().startsWith("{")||(e=await U(e,"text")):"object"==typeof e&&(e=JSON.stringify(e)),await new Promise((t,i)=>{let s=Ue();Ve[s]=async function(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)}},Pe.postMessage({type:"dcp_initSettings",id:s,instanceID:this._instanceID,body:{settings:e}})});console.error("Invalid settings.")}async resetSettings(){return Fo(this),await new Promise((e,t)=>{let i=Ue();Ve[i]=async function(i){if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}},Pe.postMessage({type:"dcp_resetSettings",id:i,instanceID:this._instanceID})})}async parse(e,t=""){if(Fo(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=Ue();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))),Ve[n]=async function(e){if(e.success){let t=JSON.parse(e.parseResponse);return t.errorCode?s(new Error(t.errorString)):(Lo(t),i(t))}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,s(t)}},Pe.postMessage({type:"dcp_parse",id:n,instanceID:this._instanceID,body:{source:e,taskSettingName:t}})})}}const Vo="undefined"==typeof self,Go="function"==typeof importScripts,Wo=(()=>{if(!Go){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"./"}})();ze.engineResourcePaths.dcp={version:"3.6.30-dev-20260824140430",path:Wo,isInternal:!0},Ze.dcp={handleParsedResultItem:Lo},Ve[-4]=async e=>{jo.onSpecLoadProgressChanged&&jo.onSpecLoadProgressChanged(e.resourcesPath,e.tag,{loaded:e.loaded,total:e.total})};class jo{static getVersion(){const e=je.dcp&&je.dcp.wasm;return`3.6.30-dev-20260824140430(Worker: ${je.dcp&&je.dcp.worker||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}static async loadSpec(e,t){return await ze.loadWasm(),await new Promise((i,s)=>{let n,o=Ue();if(Ve[o]=async function(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=W(ze.engineResourcePaths);n=`${"DBR"===ze._bundleEnv?e.dbrBundle:e.dcvData}parser-resources/`}let a=(e instanceof Array?e:[e]).map(e=>e.replace(/^MRTD.*$/,"MRTD"));a=a.map(e=>e.replace(/\.data$/i,"")),Pe.postMessage({type:"dcp_appendResourceBuffer",id:o,body:{specificationPath:n,specificationNames:a}})})}}var Zo,Ho,qo,Yo,zo,$o,Ko,Xo,Qo,Jo;!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"}(Zo||(Zo={}));class ea{static getVersion(){return`3.6.30-dev-20260824140451(Worker: ${je.dip&&je.dip.worker||"Not Loaded"}, Wasm: ${je.dip&&je.dip.wasm||"Not Loaded"})`}}(ze._bundleEnv="DBR",Gt._defaultTemplate="ReadSingleBarcode",ze.engineResourcePaths.rootDirectory=Ys(qs+"../../"),ze.engineResourcePaths.dbrBundle={version:"11.6.3000",path:qs,isInternal:!0},null!==(Ho=window)&&void 0!==Ho&&null!==(Ho=Ho.Dynamsoft)&&void 0!==Ho&&Ho.Core)||(null!==(Yo=(qo=window).Dynamsoft)&&void 0!==Yo||(qo.Dynamsoft={}),null!==($o=(zo=window.Dynamsoft).Core)&&void 0!==$o||(zo.Core={}),null!==(Xo=(Ko=window.Dynamsoft.Core).CoreModule)&&void 0!==Xo||(Ko.CoreModule=ze),null!==(Jo=(Qo=window.Dynamsoft.Core).mapPackageRegister)&&void 0!==Jo||(Qo.mapPackageRegister=Ze));As._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)"),Di.CoreModule=ze,Di.handleEngineResourcePaths=W;export{ks as BarcodeReaderModule,so as BarcodeScanner,Ti as Beep,pi as Camera,Di as CameraEnhancer,Ai as CameraEnhancerModule,bi as CameraView,Gt as CaptureVisionRouter,ht as CaptureVisionRouterModule,Kt as CapturedResultReceiver,Uo as CodeParser,jo as CodeParserModule,ze as CoreModule,$i as DrawingItem,qi as DrawingLayer,Hi as DrawingStyleManager,Us as EnumBarcodeFormat,g as EnumBufferOverflowProtectionMode,Ee as EnumCapturedResultItemType,Zo as EnumCodeType,p as EnumColourChannelUsageType,ye as EnumCornerType,Se as EnumCrossVerificationStatus,js as EnumDeblurMode,is as EnumDrawingItemMediaType,ss as EnumDrawingItemState,ns as EnumEnhancedFeatures,Ie as EnumErrorCode,Vs as EnumExtendedBarcodeResultType,Wn as EnumFilterType,ve as EnumGrayscaleEnhancementMode,Re as EnumGrayscaleTransformationMode,Le as EnumImageCaptureDistanceMode,Oe as EnumImageFileFormat,f as EnumImagePixelFormat,Tt as EnumImageSourceState,Ce as EnumImageTagType,Ae as EnumIntermediateResultUnitType,jn as EnumLayoutElementSource,xn as EnumLayoutPattern,Ws as EnumLocalizationMode,Ao as EnumMappingStatus,Me as EnumMeasureUnit,Ne as EnumModuleName,Te as EnumPDFReadingMode,os as EnumPixelFormat,wt as EnumPresetTemplate,Gs as EnumQRCodeErrorCorrectionLevel,we as EnumRasterDataSource,De as EnumRegionObjectElementType,d as EnumResultStatus,l as EnumScanMode,be as EnumSectionType,Do as EnumValidationStatus,Be as EnumWasmType,ki as Feedback,Ci as FramePipeline,kn as ImageDrawer,es as ImageDrawingItem,Pn as ImageIO,ea as ImageProcessingModule,Un as ImageProcessor,_e as ImageSourceAdapter,Xt as IntermediateResultReceiver,Gn as LayoutAnalyzer,As as LicenseManager,Ds as LicenseModule,Ki as LineDrawingItem,Nn as MultiFrameResultCrossFilter,Xi as QuadDrawingItem,Qi as RectDrawingItem,Ji as TextDrawingItem,Xs as UtilityModule,xi as _bufferToCanvas,zi as _distToSegment,Yi as _isPointInPolygon,j as _saveToFile,q as _toBlob,Z as _toCanvas,H as _toImage,Ge as bDebug,wi as beep,K as blobToDsImage,V as checkIsLink,G as compareVersion,z as createImageData,Q as d,X as e,Y as encodeBMP,Ue as getNextTaskID,W as handleEngineResourcePaths,Fe as imagePtrToUint8Array,je as innerVersions,S as isArc,A as isContour,L as isDSImageData,N as isDSRect,b as isDsImageKeyValue,M as isImageTag,B as isLineSegment,w as isObject,O as isOriginalDsImageData,Qt as isPathConfig,F as isPoint,x as isPolygon,P as isQuad,k as isRect,$ as isSimdSupported,Ze as mapPackageRegister,Ve as mapTaskCallBack,J as productNameMap,U as requestResource,xe as resolveDsImageData,We as setBDebug,oi as stringToHtml,Si as vibrate,Pe as worker};
|