dynamsoft-mrz-scanner
Version:
Dynamsoft MRZ Scanner JavaScript Edition is a ready-to-use SDK for web applications that accurately recognizes and parses Machine-Readable Zones on Machine-Readable Travel Documents.
1 lines • 690 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Dynamsoft=t.Dynamsoft||{})}(this,(function(t){"use strict";const e=t=>t&&"object"==typeof t&&"function"==typeof t.then,i=(async()=>{})().constructor;let n=class extends i{get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(t){let n;this._task=t,e(t)?n=t:"function"==typeof t&&(n=new i(t)),n&&(async()=>{try{const e=await n;t===this._task&&this.resolve(e)}catch(e){t===this._task&&this.reject(e)}})()}get isEmpty(){return null==this._task}constructor(t){let i,n;super(((t,e)=>{i=t,n=e})),this._s="pending",this.resolve=t=>{this.isPending&&(e(t)?this.task=t:(this._s="fulfilled",i(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",n(t))},this.task=t}};function r(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}function s(t,e,i,n,r){if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,i),i}var a,o,l;"function"==typeof SuppressedError&&SuppressedError,function(t){t[t.BOPM_BLOCK=0]="BOPM_BLOCK",t[t.BOPM_UPDATE=1]="BOPM_UPDATE"}(a||(a={})),function(t){t[t.CCUT_AUTO=0]="CCUT_AUTO",t[t.CCUT_FULL_CHANNEL=1]="CCUT_FULL_CHANNEL",t[t.CCUT_Y_CHANNEL_ONLY=2]="CCUT_Y_CHANNEL_ONLY",t[t.CCUT_RGB_R_CHANNEL_ONLY=3]="CCUT_RGB_R_CHANNEL_ONLY",t[t.CCUT_RGB_G_CHANNEL_ONLY=4]="CCUT_RGB_G_CHANNEL_ONLY",t[t.CCUT_RGB_B_CHANNEL_ONLY=5]="CCUT_RGB_B_CHANNEL_ONLY"}(o||(o={})),function(t){t[t.IPF_BINARY=0]="IPF_BINARY",t[t.IPF_BINARYINVERTED=1]="IPF_BINARYINVERTED",t[t.IPF_GRAYSCALED=2]="IPF_GRAYSCALED",t[t.IPF_NV21=3]="IPF_NV21",t[t.IPF_RGB_565=4]="IPF_RGB_565",t[t.IPF_RGB_555=5]="IPF_RGB_555",t[t.IPF_RGB_888=6]="IPF_RGB_888",t[t.IPF_ARGB_8888=7]="IPF_ARGB_8888",t[t.IPF_RGB_161616=8]="IPF_RGB_161616",t[t.IPF_ARGB_16161616=9]="IPF_ARGB_16161616",t[t.IPF_ABGR_8888=10]="IPF_ABGR_8888",t[t.IPF_ABGR_16161616=11]="IPF_ABGR_16161616",t[t.IPF_BGR_888=12]="IPF_BGR_888",t[t.IPF_BINARY_8=13]="IPF_BINARY_8",t[t.IPF_NV12=14]="IPF_NV12",t[t.IPF_BINARY_8_INVERTED=15]="IPF_BINARY_8_INVERTED"}(l||(l={}));const h="undefined"==typeof self,c="function"==typeof importScripts,d=(()=>{if(!c){if(!h&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})(),u=t=>{if(null==t&&(t="./"),h||c);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t},f=t=>Object.prototype.toString.call(t),g=t=>Array.isArray?Array.isArray(t):"[object Array]"===f(t),m=t=>"number"==typeof t&&!Number.isNaN(t),p=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),_=t=>!(!p(t)||!m(t.width)||t.width<=0||!m(t.height)||t.height<=0||!m(t.stride)||t.stride<=0||!("format"in t)||"tag"in t&&!w(t.tag)),v=t=>!!_(t)&&t.bytes instanceof Uint8Array,y=t=>!(!p(t)||!m(t.left)||t.left<0||!m(t.top)||t.top<0||!m(t.right)||t.right<0||!m(t.bottom)||t.bottom<0||t.left>=t.right||t.top>=t.bottom),w=t=>null===t||!!p(t)&&!!m(t.imageId)&&"type"in t,E=t=>!(!p(t)||!C(t.startPoint)||!C(t.endPoint)||t.startPoint.x==t.endPoint.x&&t.startPoint.y==t.endPoint.y),C=t=>!!p(t)&&!!m(t.x)&&!!m(t.y),S=t=>!!p(t)&&!!g(t.points)&&0!=t.points.length&&!t.points.some((t=>!C(t))),T=t=>!!p(t)&&!!g(t.points)&&0!=t.points.length&&4==t.points.length&&!t.points.some((t=>!C(t))),b=t=>!(!p(t)||!m(t.x)||!m(t.y)||!m(t.width)||t.width<0||!m(t.height)||t.height<0),I=async(t,e)=>await new Promise(((i,n)=>{let r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType=e,r.send(),r.onloadend=async()=>{r.status<200||r.status>=300?n(new Error(t+" "+r.status)):i(r.response)},r.onerror=()=>{n(new Error("Network Error: "+r.statusText))}})),x=(t,e)=>{let i=t.split("."),n=e.split(".");for(let t=0;t<i.length&&t<n.length;++t){let e=i[t],r=n[t];if(e===r)continue;let s=parseInt(i[t]),a=parseInt(n[t]);return s===a||Number.isNaN(s)&&Number.isNaN(a)?e<r?-1:1:s<a||Number.isNaN(s)&&Number.isInteger(a)?-1:1}return i.length===n.length?0:i.length<n.length?-1:1},R=t=>{const e={};for(let i in t){if("rootDirectory"===i)continue;let n=i,r=t[n],s=r&&"object"==typeof r&&r.path?r.path:r,a=t.rootDirectory;if(a&&!a.endsWith("/")&&(a+="/"),"object"==typeof r&&r.isInternal)a&&(s=t[n].version?`${a}${F[n]}@${t[n].version}/${"dcvData"===n?"":"dist/"}${"ddv"===n?"engine":""}`:`${a}${F[n]}/${"dcvData"===n?"":"dist/"}${"ddv"===n?"engine":""}`);else{const i=/^@engineRootDirectory(\/?)/;if("string"==typeof s&&(s=s.replace(i,a||"")),"object"==typeof s&&"dwt"===n){const r=t[n].resourcesPath,s=t[n].serviceInstallerLocation;e[n]={resourcesPath:r.replace(i,a||""),serviceInstallerLocation:s.replace(i,a||"")};continue}}e[n]=u(s)}return e},O=async(t,e,i)=>await new Promise((async(n,r)=>{try{const r=e.split(".");let s=r[r.length-1];const a=await M(`image/${s}`,t);r.length<=1&&(s="png");const o=new File([a],e,{type:`image/${s}`});if(i){const t=URL.createObjectURL(o),i=document.createElement("a");i.href=t,i.download=e,i.click()}return n(o)}catch(t){return r()}})),D=t=>{v(t)&&(t=L(t));const e=document.createElement("canvas");return e.width=t.width,e.height=t.height,e.getContext("2d",{willReadFrequently:!0}).putImageData(t,0,0),e},A=(t,e)=>{v(e)&&(e=L(e));const i=D(e);let n=new Image,r=i.toDataURL(t);return n.src=r,n},M=async(t,e)=>{v(e)&&(e=L(e));const i=D(e);return new Promise(((e,n)=>{i.toBlob((t=>e(t)),t)}))},L=t=>{let e,i=t.bytes;if(!(i&&i instanceof Uint8Array))throw Error("Parameter type error");if(Number(t.format)===l.IPF_BGR_888){const t=i.length/3;e=new Uint8ClampedArray(4*t);for(let n=0;n<t;++n)e[4*n]=i[3*n],e[4*n+1]=i[3*n+1],e[4*n+2]=i[3*n+2],e[4*n+3]=255}else if(Number(t.format)===l.IPF_RGB_888){const t=i.length/3;e=new Uint8ClampedArray(4*t);for(let n=0;n<t;++n)e[4*n]=i[3*n+2],e[4*n+1]=i[3*n+1],e[4*n+2]=i[3*n],e[4*n+3]=255}else if(Number(t.format)===l.IPF_GRAYSCALED){const t=i.length;e=new Uint8ClampedArray(4*t);for(let n=0;n<t;n++)e[4*n]=e[4*n+1]=e[4*n+2]=i[n],e[4*n+3]=255}else if(Number(t.format)===l.IPF_BINARY_8){const n=i.length,r=t.width,s=t.height,a=t.stride;e=new Uint8ClampedArray(r*s*4);for(let t=0;t<n;t++){let n=i[t],s=t%a,o=Math.floor(t/a);for(let t=0;t<8;t++){let i=s+t,a=4*(o*r+i);if(i>=r)break;e[a]=e[a+1]=e[a+2]=(128&n)/128*255,e[a+3]=255,n<<=1}}}else if(Number(t.format)===l.IPF_ABGR_8888){const t=i.length/4;e=new Uint8ClampedArray(i.length);for(let n=0;n<t;++n)e[4*n]=i[4*n],e[4*n+1]=i[4*n+1],e[4*n+2]=i[4*n+2],e[4*n+3]=i[4*n+3]}else if(Number(t.format)===l.IPF_ARGB_8888){const t=i.length/4;e=new Uint8ClampedArray(i.length);for(let n=0;n<t;++n)e[4*n]=i[4*n+2],e[4*n+1]=i[4*n+1],e[4*n+2]=i[4*n],e[4*n+3]=i[4*n+3]}else if(Number(t.format)===l.IPF_BINARY_8_INVERTED){const n=i.length,r=t.width,s=t.height,a=t.stride;e=new Uint8ClampedArray(r*s*4);for(let t=0;t<n;t++){let n=i[t],s=t%a,o=Math.floor(t/a);for(let t=0;t<8;t++){let i=s+t,a=4*(o*r+i);if(i>=r)break;e[a]=e[a+1]=e[a+2]=128&n?0:255,e[a+3]=255,n<<=1}}}return new ImageData(e,t.width,t.height)},F={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",ddv:"dynamsoft-document-viewer",dwt:"dwt",dbrBundle:"dynamsoft-barcode-reader-bundle",dcvBundle:"dynamsoft-capture-vision-bundle"};var P,k,N,B,j,V,U,G;let W,Y,H,z,X,Z=class t{get _isFetchingStarted(){return r(this,j,"f")}constructor(){P.add(this),k.set(this,[]),N.set(this,1),B.set(this,a.BOPM_BLOCK),j.set(this,!1),V.set(this,void 0),U.set(this,o.CCUT_AUTO)}setErrorListener(t){}addImageToBuffer(t){var e;if(!v(t))throw new TypeError("Invalid 'image'.");if((null===(e=t.tag)||void 0===e?void 0:e.hasOwnProperty("imageId"))&&"number"==typeof t.tag.imageId&&this.hasImage(t.tag.imageId))throw new Error("Existed imageId.");if(r(this,k,"f").length>=r(this,N,"f"))switch(r(this,B,"f")){case a.BOPM_BLOCK:break;case a.BOPM_UPDATE:if(r(this,k,"f").push(t),p(r(this,V,"f"))&&m(r(this,V,"f").imageId)&&1==r(this,V,"f").keepInBuffer)for(;r(this,k,"f").length>r(this,N,"f");){const t=r(this,k,"f").findIndex((t=>{var e;return(null===(e=t.tag)||void 0===e?void 0:e.imageId)!==r(this,V,"f").imageId}));r(this,k,"f").splice(t,1)}else r(this,k,"f").splice(0,r(this,k,"f").length-r(this,N,"f"))}else r(this,k,"f").push(t)}getImage(){if(0===r(this,k,"f").length)return null;let e;if(r(this,V,"f")&&m(r(this,V,"f").imageId)){const t=r(this,P,"m",G).call(this,r(this,V,"f").imageId);if(t<0)throw new Error(`Image with id ${r(this,V,"f").imageId} doesn't exist.`);e=r(this,k,"f").slice(t,t+1)[0]}else e=r(this,k,"f").pop();if([l.IPF_RGB_565,l.IPF_RGB_555,l.IPF_RGB_888,l.IPF_ARGB_8888,l.IPF_RGB_161616,l.IPF_ARGB_16161616,l.IPF_ABGR_8888,l.IPF_ABGR_16161616,l.IPF_BGR_888].includes(e.format)){if(r(this,U,"f")===o.CCUT_RGB_R_CHANNEL_ONLY){t._onLog&&t._onLog("only get R channel data.");const i=new Uint8Array(e.width*e.height);for(let t=0;t<i.length;t++)switch(e.format){case l.IPF_RGB_565:case l.IPF_RGB_555:case l.IPF_RGB_888:case l.IPF_RGB_161616:i[t]=e.bytes[3*t+2];break;case l.IPF_ARGB_8888:case l.IPF_ARGB_16161616:i[t]=e.bytes[4*t+2];break;case l.IPF_BGR_888:i[t]=e.bytes[3*t];break;case l.IPF_ABGR_8888:case l.IPF_ABGR_16161616:i[t]=e.bytes[4*t]}e.bytes=i,e.stride=e.width,e.format=l.IPF_GRAYSCALED}else if(r(this,U,"f")===o.CCUT_RGB_G_CHANNEL_ONLY){t._onLog&&t._onLog("only get G channel data.");const i=new Uint8Array(e.width*e.height);for(let t=0;t<i.length;t++)switch(e.format){case l.IPF_RGB_565:case l.IPF_RGB_555:case l.IPF_RGB_888:case l.IPF_RGB_161616:case l.IPF_BGR_888:i[t]=e.bytes[3*t+1];break;case l.IPF_ARGB_8888:case l.IPF_ARGB_16161616:case l.IPF_ABGR_8888:case l.IPF_ABGR_16161616:i[t]=e.bytes[4*t+1]}e.bytes=i,e.stride=e.width,e.format=l.IPF_GRAYSCALED}else if(r(this,U,"f")===o.CCUT_RGB_B_CHANNEL_ONLY){t._onLog&&t._onLog("only get B channel data.");const i=new Uint8Array(e.width*e.height);for(let t=0;t<i.length;t++)switch(e.format){case l.IPF_RGB_565:case l.IPF_RGB_555:case l.IPF_RGB_888:case l.IPF_RGB_161616:i[t]=e.bytes[3*t];break;case l.IPF_ARGB_8888:case l.IPF_ARGB_16161616:i[t]=e.bytes[4*t];break;case l.IPF_BGR_888:i[t]=e.bytes[3*t+2];break;case l.IPF_ABGR_8888:case l.IPF_ABGR_16161616:i[t]=e.bytes[4*t+2]}e.bytes=i,e.stride=e.width,e.format=l.IPF_GRAYSCALED}}else[l.IPF_NV21,l.IPF_NV12].includes(e.format)&&t._onLog&&t._onLog("NV21 or NV12 is not supported.");return e}setNextImageToReturn(t,e){if(!((...t)=>0!==t.length&&t.every((t=>m(t))))(t))throw new TypeError("Invalid 'imageId'.");if(void 0!==e&&"[object Boolean]"!==f(e))throw new TypeError("Invalid 'keepInBuffer'.");s(this,V,{imageId:t,keepInBuffer:e})}_resetNextReturnedImage(){s(this,V,null)}hasImage(t){return r(this,P,"m",G).call(this,t)>=0}startFetching(){s(this,j,!0)}stopFetching(){s(this,j,!1)}setMaxImageCount(t){if("number"!=typeof t)throw new TypeError("Invalid 'count'.");if(t<1||Math.round(t)!==t)throw new Error("Invalid 'count'.");for(s(this,N,t);r(this,k,"f")&&r(this,k,"f").length>t;)r(this,k,"f").shift()}getMaxImageCount(){return r(this,N,"f")}getImageCount(){return r(this,k,"f").length}clearBuffer(){r(this,k,"f").length=0}isBufferEmpty(){return 0===r(this,k,"f").length}setBufferOverflowProtectionMode(t){s(this,B,t)}getBufferOverflowProtectionMode(){return r(this,B,"f")}setColourChannelUsageType(t){s(this,U,t)}getColourChannelUsageType(){return r(this,U,"f")}};k=new WeakMap,N=new WeakMap,B=new WeakMap,j=new WeakMap,V=new WeakMap,U=new WeakMap,P=new WeakSet,G=function(t){if("number"!=typeof t)throw new TypeError("Invalid 'imageId'.");return r(this,k,"f").findIndex((e=>{var i;return(null===(i=e.tag)||void 0===i?void 0:i.imageId)===t}))},"undefined"!=typeof navigator&&(W=navigator,Y=W.userAgent,H=W.platform,z=W.mediaDevices),function(){if(!h){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:W.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},e={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:H,search:"Win"},Mac:{str:H},Linux:{str:H}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||Y,a=r.search||e,o=r.verStr||Y,l=r.verSearch||e;if(l instanceof Array||(l=[l]),-1!=s.indexOf(a)){i=e;for(let t of l){let e=o.indexOf(t);if(-1!=e){n=parseFloat(o.substring(e+t.length+1));break}}break}}for(let t in e){const i=e[t]||{};let n=i.str||Y,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=Y.indexOf("Windows NT")&&(r="HarmonyOS"),X={browser:i,version:n,OS:r}}h&&(X={browser:"ssr",version:0,OS:"ssr"})}();const q="undefined"!=typeof WebAssembly&&Y&&!(/Safari/.test(Y)&&!/Chrome/.test(Y)&&/\(.+\s11_2_([2-6]).*\)/.test(Y)),K=!("undefined"==typeof Worker),J=!(!z||!z.getUserMedia),$=async()=>{let t=!1;if(J)try{(await z.getUserMedia({video:!0})).getTracks().forEach((t=>{t.stop()})),t=!0}catch(t){}return t};var Q,tt,et,it,nt,rt,st,at,ot;"Chrome"===X.browser&&X.version>66||"Safari"===X.browser&&X.version>13||"OPR"===X.browser&&X.version>43||"Edge"===X.browser&&X.version,function(t){t[t.CRIT_ORIGINAL_IMAGE=1]="CRIT_ORIGINAL_IMAGE",t[t.CRIT_BARCODE=2]="CRIT_BARCODE",t[t.CRIT_TEXT_LINE=4]="CRIT_TEXT_LINE",t[t.CRIT_DETECTED_QUAD=8]="CRIT_DETECTED_QUAD",t[t.CRIT_DESKEWED_IMAGE=16]="CRIT_DESKEWED_IMAGE",t[t.CRIT_PARSED_RESULT=32]="CRIT_PARSED_RESULT",t[t.CRIT_ENHANCED_IMAGE=64]="CRIT_ENHANCED_IMAGE"}(Q||(Q={})),function(t){t[t.CT_NORMAL_INTERSECTED=0]="CT_NORMAL_INTERSECTED",t[t.CT_T_INTERSECTED=1]="CT_T_INTERSECTED",t[t.CT_CROSS_INTERSECTED=2]="CT_CROSS_INTERSECTED",t[t.CT_NOT_INTERSECTED=3]="CT_NOT_INTERSECTED"}(tt||(tt={})),function(t){t[t.EC_OK=0]="EC_OK",t[t.EC_UNKNOWN=-1e4]="EC_UNKNOWN",t[t.EC_NO_MEMORY=-10001]="EC_NO_MEMORY",t[t.EC_NULL_POINTER=-10002]="EC_NULL_POINTER",t[t.EC_LICENSE_INVALID=-10003]="EC_LICENSE_INVALID",t[t.EC_LICENSE_EXPIRED=-10004]="EC_LICENSE_EXPIRED",t[t.EC_FILE_NOT_FOUND=-10005]="EC_FILE_NOT_FOUND",t[t.EC_FILE_TYPE_NOT_SUPPORTED=-10006]="EC_FILE_TYPE_NOT_SUPPORTED",t[t.EC_BPP_NOT_SUPPORTED=-10007]="EC_BPP_NOT_SUPPORTED",t[t.EC_INDEX_INVALID=-10008]="EC_INDEX_INVALID",t[t.EC_CUSTOM_REGION_INVALID=-10010]="EC_CUSTOM_REGION_INVALID",t[t.EC_IMAGE_READ_FAILED=-10012]="EC_IMAGE_READ_FAILED",t[t.EC_TIFF_READ_FAILED=-10013]="EC_TIFF_READ_FAILED",t[t.EC_DIB_BUFFER_INVALID=-10018]="EC_DIB_BUFFER_INVALID",t[t.EC_PDF_READ_FAILED=-10021]="EC_PDF_READ_FAILED",t[t.EC_PDF_DLL_MISSING=-10022]="EC_PDF_DLL_MISSING",t[t.EC_PAGE_NUMBER_INVALID=-10023]="EC_PAGE_NUMBER_INVALID",t[t.EC_CUSTOM_SIZE_INVALID=-10024]="EC_CUSTOM_SIZE_INVALID",t[t.EC_TIMEOUT=-10026]="EC_TIMEOUT",t[t.EC_JSON_PARSE_FAILED=-10030]="EC_JSON_PARSE_FAILED",t[t.EC_JSON_TYPE_INVALID=-10031]="EC_JSON_TYPE_INVALID",t[t.EC_JSON_KEY_INVALID=-10032]="EC_JSON_KEY_INVALID",t[t.EC_JSON_VALUE_INVALID=-10033]="EC_JSON_VALUE_INVALID",t[t.EC_JSON_NAME_KEY_MISSING=-10034]="EC_JSON_NAME_KEY_MISSING",t[t.EC_JSON_NAME_VALUE_DUPLICATED=-10035]="EC_JSON_NAME_VALUE_DUPLICATED",t[t.EC_TEMPLATE_NAME_INVALID=-10036]="EC_TEMPLATE_NAME_INVALID",t[t.EC_JSON_NAME_REFERENCE_INVALID=-10037]="EC_JSON_NAME_REFERENCE_INVALID",t[t.EC_PARAMETER_VALUE_INVALID=-10038]="EC_PARAMETER_VALUE_INVALID",t[t.EC_DOMAIN_NOT_MATCH=-10039]="EC_DOMAIN_NOT_MATCH",t[t.EC_LICENSE_KEY_NOT_MATCH=-10043]="EC_LICENSE_KEY_NOT_MATCH",t[t.EC_SET_MODE_ARGUMENT_ERROR=-10051]="EC_SET_MODE_ARGUMENT_ERROR",t[t.EC_GET_MODE_ARGUMENT_ERROR=-10055]="EC_GET_MODE_ARGUMENT_ERROR",t[t.EC_IRT_LICENSE_INVALID=-10056]="EC_IRT_LICENSE_INVALID",t[t.EC_FILE_SAVE_FAILED=-10058]="EC_FILE_SAVE_FAILED",t[t.EC_STAGE_TYPE_INVALID=-10059]="EC_STAGE_TYPE_INVALID",t[t.EC_IMAGE_ORIENTATION_INVALID=-10060]="EC_IMAGE_ORIENTATION_INVALID",t[t.EC_CONVERT_COMPLEX_TEMPLATE_ERROR=-10061]="EC_CONVERT_COMPLEX_TEMPLATE_ERROR",t[t.EC_CALL_REJECTED_WHEN_CAPTURING=-10062]="EC_CALL_REJECTED_WHEN_CAPTURING",t[t.EC_NO_IMAGE_SOURCE=-10063]="EC_NO_IMAGE_SOURCE",t[t.EC_READ_DIRECTORY_FAILED=-10064]="EC_READ_DIRECTORY_FAILED",t[t.EC_MODULE_NOT_FOUND=-10065]="EC_MODULE_NOT_FOUND",t[t.EC_MULTI_PAGES_NOT_SUPPORTED=-10066]="EC_MULTI_PAGES_NOT_SUPPORTED",t[t.EC_FILE_ALREADY_EXISTS=-10067]="EC_FILE_ALREADY_EXISTS",t[t.EC_CREATE_FILE_FAILED=-10068]="EC_CREATE_FILE_FAILED",t[t.EC_IMGAE_DATA_INVALID=-10069]="EC_IMGAE_DATA_INVALID",t[t.EC_IMAGE_SIZE_NOT_MATCH=-10070]="EC_IMAGE_SIZE_NOT_MATCH",t[t.EC_IMAGE_PIXEL_FORMAT_NOT_MATCH=-10071]="EC_IMAGE_PIXEL_FORMAT_NOT_MATCH",t[t.EC_SECTION_LEVEL_RESULT_IRREPLACEABLE=-10072]="EC_SECTION_LEVEL_RESULT_IRREPLACEABLE",t[t.EC_AXIS_DEFINITION_INCORRECT=-10073]="EC_AXIS_DEFINITION_INCORRECT",t[t.EC_RESULT_TYPE_MISMATCH_IRREPLACEABLE=-10074]="EC_RESULT_TYPE_MISMATCH_IRREPLACEABLE",t[t.EC_PDF_LIBRARY_LOAD_FAILED=-10075]="EC_PDF_LIBRARY_LOAD_FAILED",t[t.EC_UNSUPPORTED_JSON_KEY_WARNING=-10077]="EC_UNSUPPORTED_JSON_KEY_WARNING",t[t.EC_MODEL_FILE_NOT_FOUND=-10078]="EC_MODEL_FILE_NOT_FOUND",t[t.EC_PDF_LICENSE_NOT_FOUND=-10079]="EC_PDF_LICENSE_NOT_FOUND",t[t.EC_RECT_INVALID=-10080]="EC_RECT_INVALID",t[t.EC_NO_LICENSE=-2e4]="EC_NO_LICENSE",t[t.EC_LICENSE_BUFFER_FAILED=-20002]="EC_LICENSE_BUFFER_FAILED",t[t.EC_LICENSE_SYNC_FAILED=-20003]="EC_LICENSE_SYNC_FAILED",t[t.EC_DEVICE_NOT_MATCH=-20004]="EC_DEVICE_NOT_MATCH",t[t.EC_BIND_DEVICE_FAILED=-20005]="EC_BIND_DEVICE_FAILED",t[t.EC_INSTANCE_COUNT_OVER_LIMIT=-20008]="EC_INSTANCE_COUNT_OVER_LIMIT",t[t.EC_TRIAL_LICENSE=-20010]="EC_TRIAL_LICENSE",t[t.EC_BARCODE_FORMAT_INVALID=-30009]="EC_BARCODE_FORMAT_INVALID",t[t.EC_CUSTOM_MODULESIZE_INVALID=-30025]="EC_CUSTOM_MODULESIZE_INVALID",t[t.EC_TEXT_LINE_GROUP_LAYOUT_CONFLICT=-40101]="EC_TEXT_LINE_GROUP_LAYOUT_CONFLICT",t[t.EC_TEXT_LINE_GROUP_REGEX_CONFLICT=-40102]="EC_TEXT_LINE_GROUP_REGEX_CONFLICT",t[t.EC_QUADRILATERAL_INVALID=-50057]="EC_QUADRILATERAL_INVALID",t[t.EC_PANORAMA_LICENSE_INVALID=-70060]="EC_PANORAMA_LICENSE_INVALID",t[t.EC_RESOURCE_PATH_NOT_EXIST=-90001]="EC_RESOURCE_PATH_NOT_EXIST",t[t.EC_RESOURCE_LOAD_FAILED=-90002]="EC_RESOURCE_LOAD_FAILED",t[t.EC_CODE_SPECIFICATION_NOT_FOUND=-90003]="EC_CODE_SPECIFICATION_NOT_FOUND",t[t.EC_FULL_CODE_EMPTY=-90004]="EC_FULL_CODE_EMPTY",t[t.EC_FULL_CODE_PREPROCESS_FAILED=-90005]="EC_FULL_CODE_PREPROCESS_FAILED",t[t.EC_LICENSE_WARNING=-10076]="EC_LICENSE_WARNING",t[t.EC_BARCODE_READER_LICENSE_NOT_FOUND=-30063]="EC_BARCODE_READER_LICENSE_NOT_FOUND",t[t.EC_LABEL_RECOGNIZER_LICENSE_NOT_FOUND=-40103]="EC_LABEL_RECOGNIZER_LICENSE_NOT_FOUND",t[t.EC_DOCUMENT_NORMALIZER_LICENSE_NOT_FOUND=-50058]="EC_DOCUMENT_NORMALIZER_LICENSE_NOT_FOUND",t[t.EC_CODE_PARSER_LICENSE_NOT_FOUND=-90012]="EC_CODE_PARSER_LICENSE_NOT_FOUND"}(et||(et={})),function(t){t[t.GEM_SKIP=0]="GEM_SKIP",t[t.GEM_AUTO=1]="GEM_AUTO",t[t.GEM_GENERAL=2]="GEM_GENERAL",t[t.GEM_GRAY_EQUALIZE=4]="GEM_GRAY_EQUALIZE",t[t.GEM_GRAY_SMOOTH=8]="GEM_GRAY_SMOOTH",t[t.GEM_SHARPEN_SMOOTH=16]="GEM_SHARPEN_SMOOTH",t[t.GEM_REV=-2147483648]="GEM_REV",t[t.GEM_END=-1]="GEM_END"}(it||(it={})),function(t){t[t.GTM_SKIP=0]="GTM_SKIP",t[t.GTM_INVERTED=1]="GTM_INVERTED",t[t.GTM_ORIGINAL=2]="GTM_ORIGINAL",t[t.GTM_AUTO=4]="GTM_AUTO",t[t.GTM_REV=-2147483648]="GTM_REV",t[t.GTM_END=-1]="GTM_END"}(nt||(nt={})),function(t){t[t.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",t[t.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(rt||(rt={})),function(t){t[t.PDFRM_VECTOR=1]="PDFRM_VECTOR",t[t.PDFRM_RASTER=2]="PDFRM_RASTER",t[t.PDFRM_REV=-2147483648]="PDFRM_REV"}(st||(st={})),function(t){t[t.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",t[t.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(at||(at={})),function(t){t[t.CVS_NOT_VERIFIED=0]="CVS_NOT_VERIFIED",t[t.CVS_PASSED=1]="CVS_PASSED",t[t.CVS_FAILED=2]="CVS_FAILED"}(ot||(ot={}));const lt={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 ht,ct,dt,ut,ft,gt;!function(t){t[t.ROET_PREDETECTED_REGION=0]="ROET_PREDETECTED_REGION",t[t.ROET_LOCALIZED_BARCODE=1]="ROET_LOCALIZED_BARCODE",t[t.ROET_DECODED_BARCODE=2]="ROET_DECODED_BARCODE",t[t.ROET_LOCALIZED_TEXT_LINE=3]="ROET_LOCALIZED_TEXT_LINE",t[t.ROET_RECOGNIZED_TEXT_LINE=4]="ROET_RECOGNIZED_TEXT_LINE",t[t.ROET_DETECTED_QUAD=5]="ROET_DETECTED_QUAD",t[t.ROET_DESKEWED_IMAGE=6]="ROET_DESKEWED_IMAGE",t[t.ROET_SOURCE_IMAGE=7]="ROET_SOURCE_IMAGE",t[t.ROET_TARGET_ROI=8]="ROET_TARGET_ROI",t[t.ROET_ENHANCED_IMAGE=9]="ROET_ENHANCED_IMAGE"}(ht||(ht={})),function(t){t[t.ST_NULL=0]="ST_NULL",t[t.ST_REGION_PREDETECTION=1]="ST_REGION_PREDETECTION",t[t.ST_BARCODE_LOCALIZATION=2]="ST_BARCODE_LOCALIZATION",t[t.ST_BARCODE_DECODING=3]="ST_BARCODE_DECODING",t[t.ST_TEXT_LINE_LOCALIZATION=4]="ST_TEXT_LINE_LOCALIZATION",t[t.ST_TEXT_LINE_RECOGNITION=5]="ST_TEXT_LINE_RECOGNITION",t[t.ST_DOCUMENT_DETECTION=6]="ST_DOCUMENT_DETECTION",t[t.ST_DOCUMENT_DESKEWING=7]="ST_DOCUMENT_DESKEWING",t[t.ST_IMAGE_ENHANCEMENT=8]="ST_IMAGE_ENHANCEMENT"}(ct||(ct={})),function(t){t[t.IFF_JPEG=0]="IFF_JPEG",t[t.IFF_PNG=1]="IFF_PNG",t[t.IFF_BMP=2]="IFF_BMP",t[t.IFF_PDF=3]="IFF_PDF"}(dt||(dt={})),function(t){t[t.ICDM_NEAR=0]="ICDM_NEAR",t[t.ICDM_FAR=1]="ICDM_FAR"}(ut||(ut={})),function(t){t.MN_DYNAMSOFT_CAPTURE_VISION_ROUTER="cvr",t.MN_DYNAMSOFT_CORE="core",t.MN_DYNAMSOFT_LICENSE="license",t.MN_DYNAMSOFT_IMAGE_PROCESSING="dip",t.MN_DYNAMSOFT_UTILITY="utility",t.MN_DYNAMSOFT_BARCODE_READER="dbr",t.MN_DYNAMSOFT_DOCUMENT_NORMALIZER="ddn",t.MN_DYNAMSOFT_LABEL_RECOGNIZER="dlr",t.MN_DYNAMSOFT_CAPTURE_VISION_DATA="dcvData",t.MN_DYNAMSOFT_NEURAL_NETWORK="dnn",t.MN_DYNAMSOFT_CODE_PARSER="dcp",t.MN_DYNAMSOFT_CAMERA_ENHANCER="dce",t.MN_DYNAMSOFT_CAPTURE_VISION_STD="std"}(ft||(ft={})),function(t){t[t.TMT_LOCAL_TO_ORIGINAL_IMAGE=0]="TMT_LOCAL_TO_ORIGINAL_IMAGE",t[t.TMT_ORIGINAL_TO_LOCAL_IMAGE=1]="TMT_ORIGINAL_TO_LOCAL_IMAGE",t[t.TMT_LOCAL_TO_SECTION_IMAGE=2]="TMT_LOCAL_TO_SECTION_IMAGE",t[t.TMT_SECTION_TO_LOCAL_IMAGE=3]="TMT_SECTION_TO_LOCAL_IMAGE"}(gt||(gt={}));const mt={},pt=async t=>{let e="string"==typeof t?[t]:t,i=[];for(let t of e)i.push(mt[t]=mt[t]||new n);await Promise.all(i)},_t=async(t,e)=>{let i,r="string"==typeof t?[t]:t,s=[];for(let t of r){let r;s.push(r=mt[t]=mt[t]||new n(i=i||e())),r.isEmpty&&(r.task=i=i||e())}await Promise.all(s)};let vt,yt=0;const wt=()=>yt++,Et={};let Ct;const St=t=>{Ct=t,vt&&vt.postMessage({type:"setBLog",body:{value:!!t}})};let Tt=!1;const bt=t=>{Tt=t,vt&&vt.postMessage({type:"setBDebug",body:{value:!!t}})},It={},xt={},Rt={dip:{wasm:!0}},Ot={std:{version:"2.0.0",path:u(d+"../../dynamsoft-capture-vision-std@2.0.0/dist/"),isInternal:!0},core:{version:"4.0.30-dev-20250604160028",path:d,isInternal:!0}};class Dt{static get engineResourcePaths(){return Ot}static set engineResourcePaths(t){Object.assign(Ot,t)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _onLog(){return Ct}static set _onLog(t){St(t)}static get _bDebug(){return Tt}static set _bDebug(t){bt(t)}static isModuleLoaded(t){return t=(t=t||"core").toLowerCase(),!!mt[t]&&mt[t].isFulfilled}static async loadWasm(){return await(async()=>{let t,e;t instanceof Array||(t=t?[t]:[]);let i=mt.core;e=!i||i.isEmpty,e||await pt("core");let r=new Map;const s=t=>{if(t=t.toLowerCase(),ft.MN_DYNAMSOFT_CAPTURE_VISION_STD==t||ft.MN_DYNAMSOFT_CORE==t)return;let e=Rt[t].deps;if(null==e?void 0:e.length)for(let t of e)s(t);let i=mt[t];r.has(t)||r.set(t,!i||i.isEmpty)};for(let e of t)s(e);let a=[];e&&a.push("core"),a.push(...r.keys());const o=[...r.entries()].filter((t=>!t[1])).map((t=>t[0]));await _t(a,(async()=>{const t=[...r.entries()].filter((t=>t[1])).map((t=>t[0]));await pt(o);const i=R(Ot),s={};for(let e of t)s[e]=Rt[e];const a={engineResourcePaths:i,autoResources:s,names:t,_bundleEnv:Dt._bundleEnv,_useSimd:Dt._useSimd};let l=new n;if(e){a.needLoadCore=!0;let t=i[`${Dt._bundleEnv.toLowerCase()}Bundle`]+Dt._workerName;t.startsWith(location.origin)||(t=await fetch(t).then((t=>t.blob())).then((t=>URL.createObjectURL(t)))),vt=new Worker(t),vt.onerror=t=>{let e=new Error(t.message);l.reject(e)},vt.addEventListener("message",(t=>{let e=t.data?t.data:t,i=e.type,n=e.id,r=e.body;switch(i){case"log":Ct&&Ct(e.message);break;case"task":try{Et[n](r),delete Et[n]}catch(t){throw delete Et[n],t}break;case"event":try{Et[n](r)}catch(t){throw t}break;default:console.log(t)}})),a.bLog=!!Ct,a.bd=Tt,a.dm=location.origin.startsWith("http")?location.origin:"https://localhost"}else await pt("core");let h=yt++;Et[h]=t=>{if(t.success)Object.assign(It,t.versions),"{}"!==JSON.stringify(t.versions)&&(Dt._versions=t.versions),l.resolve(void 0);else{const e=Error(t.message);t.stack&&(e.stack=t.stack),l.reject(e)}},vt.postMessage({type:"loadWasm",id:h,body:a}),await l}))})()}static async detectEnvironment(){return await(async()=>({wasm:q,worker:K,getUserMedia:J,camera:await $(),browser:X.browser,version:X.version,OS:X.OS}))()}static async getModuleVersion(){return await new Promise(((t,e)=>{let i=wt();Et[i]=async i=>{if(i.success)return t(i.versions);{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},vt.postMessage({type:"getModuleVersion",id:i})}))}static getVersion(){return`4.0.30-dev-20250604160028(Worker: ${It.core&&It.core.worker||"Not Loaded"}, Wasm: ${It.core&&It.core.wasm||"Not Loaded"})`}static enableLogging(){Z._onLog=console.log,Dt._onLog=console.log}static disableLogging(){Z._onLog=null,Dt._onLog=null}static async cfd(t){return await new Promise(((e,i)=>{let n=wt();Et[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},vt.postMessage({type:"cfd",id:n,body:{count:t}})}))}}Dt._bSupportDce4Module=-1,Dt._bSupportIRTModule=-1,Dt._versions=null,Dt._bundleEnv="DCV",Dt._workerName="dcv.bundle.worker.js",Dt._useSimd=!0,Dt.browserInfo=X;const At="undefined"==typeof self,Mt="function"==typeof importScripts,Lt=(()=>{if(!Mt){if(!At&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})();function Ft(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}function Pt(t,e,i,n,r){if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;const kt=t=>t&&"object"==typeof t&&"function"==typeof t.then,Nt=(async()=>{})().constructor;class Bt extends Nt{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(t){let e;this._task=t,kt(t)?e=t:"function"==typeof t&&(e=new Nt(t)),e&&(async()=>{try{const i=await e;t===this._task&&this.resolve(i)}catch(e){t===this._task&&this.reject(e)}})()}get isEmpty(){return null==this._task}constructor(t){let e,i;super(((t,n)=>{e=t,i=n})),this._s="pending",this.resolve=t=>{this.isPending&&(kt(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}}class jt{constructor(t){this._cvr=t}async getMaxBufferedItems(){return await new Promise(((t,e)=>{let i=wt();Et[i]=async i=>{if(i.success)return t(i.count);{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},vt.postMessage({type:"cvr_getMaxBufferedItems",id:i,instanceID:this._cvr._instanceID})}))}async setMaxBufferedItems(t){return await new Promise(((e,i)=>{let n=wt();Et[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},vt.postMessage({type:"cvr_setMaxBufferedItems",id:n,instanceID:this._cvr._instanceID,body:{count:t}})}))}async getBufferedCharacterItemSet(){return await new Promise(((t,e)=>{let i=wt();Et[i]=async i=>{if(i.success)return t(i.itemSet);{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},vt.postMessage({type:"cvr_getBufferedCharacterItemSet",id:i,instanceID:this._cvr._instanceID})}))}}var Vt={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,onProcessedDocumentResultReceived:!1};const Ut=t=>{for(let e in t._irrRegistryState)t._irrRegistryState[e]=!1;for(let e of t._intermediateResultReceiverSet)if(e.isDce||e.isFilter)t._irrRegistryState.onTaskResultsReceivedForDce=!0;else for(let i in e)t._irrRegistryState[i]||(t._irrRegistryState[i]=!!e[i])};class Gt{constructor(t){this._irrRegistryState=Vt,this._intermediateResultReceiverSet=new Set,this._cvr=t}async addResultReceiver(t){if("object"!=typeof t)throw new Error("Invalid receiver.");this._intermediateResultReceiverSet.add(t),Ut(this);let e=-1,i={};if(!t.isDce&&!t.isFilter){if(!t._observedResultUnitTypes||!t._observedTaskMap)throw new Error("Invalid Intermediate Result Receiver.");e=t._observedResultUnitTypes,t._observedTaskMap.forEach(((t,e)=>{i[e]=t})),t._observedTaskMap.clear()}return await new Promise(((t,n)=>{let r=wt();Et[r]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,n(t)}},vt.postMessage({type:"cvr_setIrrRegistry",id:r,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState,observedResultUnitTypes:e.toString(),observedTaskMap:i}})}))}async removeResultReceiver(t){return this._intermediateResultReceiverSet.delete(t),Ut(this),await new Promise(((t,e)=>{let i=wt();Et[i]=async i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},vt.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})}))}getOriginalImage(){return this._cvr._dsImage}}const Wt="undefined"==typeof self,Yt="function"==typeof importScripts,Ht=(()=>{if(!Yt){if(!Wt&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})(),zt=t=>{if(null==t&&(t="./"),Wt||Yt);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};var Xt;Dt.engineResourcePaths.cvr={version:"3.0.30-dev-20250609101939",path:Ht,isInternal:!0},Rt.cvr={js:!0,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING,ft.MN_DYNAMSOFT_NEURAL_NETWORK]},Rt.dnn={wasm:!0,deps:[ft.MN_DYNAMSOFT_IMAGE_PROCESSING]},xt.cvr={};const Zt="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Zt)<0&&(Dt.engineResourcePaths.std={version:Zt,path:zt(Ht+`../../dynamsoft-capture-vision-std@${Zt}/dist/`),isInternal:!0});const qt="3.0.10";(!Dt.engineResourcePaths.dip||"string"!=typeof Dt.engineResourcePaths.dip&&x(Dt.engineResourcePaths.dip.version,qt)<0)&&(Dt.engineResourcePaths.dip={version:qt,path:zt(Ht+`../../dynamsoft-image-processing@${qt}/dist/`),isInternal:!0});const Kt="2.0.10";(!Dt.engineResourcePaths.dnn||"string"!=typeof Dt.engineResourcePaths.dnn&&x(Dt.engineResourcePaths.dnn.version,Kt)<0)&&(Dt.engineResourcePaths.dnn={version:Kt,path:zt(Ht+`../../dynamsoft-capture-vision-dnn@${Kt}/dist/`),isInternal:!0});class Jt{static getVersion(){return this._version}}var $t,Qt,te,ee,ie,ne,re,se,ae,oe,le,he,ce,de,ue,fe,ge,me,pe,_e,ve,ye;function we(t,e){if(t&&t.sourceLocation){const i=t.sourceLocation.points;for(let t of i)t.x=t.x/e,t.y=t.y/e;we(t.referencedItem,e)}}function Ee(t){if(t.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}function Ce(t){if(t.errorCode&&-10077===t.errorCode)return void console.warn(t.message);let e=new Error(t.errorCode?`[${t.errorCode}] ${t.message}`:t.message);if(e.stack&&(e.stack=t.stack),t.isShouleThrow)throw e;t.rj&&t.rj(e)}Jt._version=`3.0.30-dev-20250609101939(Worker: ${null===(Xt=It.cvr)||void 0===Xt?void 0:Xt.worker}, Wasm: loading...`,function(t){t[t.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",t[t.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}($t||($t={}));const Se={onTaskResultsReceived:()=>{},isFilter:!0};Et[-2]=async t=>{Te.onDataLoadProgressChanged&&Te.onDataLoadProgressChanged(t.resourcesPath,t.tag,{loaded:t.loaded,total:t.total})};class Te{constructor(){Qt.add(this),this.maxImageSideLength=["iPhone","Android","HarmonyOS"].includes(Dt.browserInfo.OS)?2048:4096,this.onCaptureError=null,this._instanceID=void 0,this._dsImage=null,this._isPauseScan=!0,this._isOutputOriginalImage=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1,this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._minImageCaptureInterval=0,this._averageProcessintTimeArray=[],this._averageFetchImageTimeArray=[],this._currentSettings=null,this._averageTime=999,this._dynamsoft=!0,te.set(this,null),ee.set(this,null),ie.set(this,null),ne.set(this,null),re.set(this,null),se.set(this,new Set),ae.set(this,new Set),oe.set(this,new Set),le.set(this,0),he.set(this,!1),ce.set(this,!1),de.set(this,!1),ue.set(this,null),fe.set(this,null),this._singleFrameModeCallbackBind=this._singleFrameModeCallback.bind(this)}get disposed(){return Ft(this,de,"f")}static async createInstance(t=!0){if(!xt.license)throw Error("The `license` module cannot be found.");await xt.license.dynamsoft(),await Dt.loadWasm();const e=new Te,i=new Bt;let n=wt();return Et[n]=async t=>{t.success?(e._instanceID=t.instanceID,e._currentSettings=JSON.parse(JSON.parse(t.outputSettings).data),Jt._version=`3.0.30-dev-20250609101939(Worker: ${It.cvr.worker}, Wasm: ${t.version})`,Pt(e,ce,!0),Pt(e,ne,e.getIntermediateResultManager()),Pt(e,ce,!1),i.resolve(e)):Ce({message:t.message,rj:i.reject,stack:t.stack})},vt.postMessage({type:"cvr_createInstance",id:n,body:{loadPresetTemplates:t}}),i}static async appendModelBuffer(t,e){return await Dt.loadWasm(),await new Promise(((i,n)=>{let r=wt();const s=R(Dt.engineResourcePaths);Et[r]=async t=>{if(t.success){const e=JSON.parse(t.response);return 0!==e.errorCode&&Ce({message:e.errorString?e.errorString:"Append Model Buffer Failed.",rj:n,errorCode:e.errorCode}),i(e)}Ce({message:t.message,rj:n,stack:t.stack})},vt.postMessage({type:"cvr_appendModelBuffer",id:r,body:{modelName:t,path:e||s.dcvData+"models/"}})}))}async _singleFrameModeCallback(t){for(let e of Ft(this,se,"f"))this._isOutputOriginalImage&&e.onOriginalImageResultReceived&&e.onOriginalImageResultReceived({imageData:t});const e={bytes:new Uint8Array(t.bytes),width:t.width,height:t.height,stride:t.stride,format:t.format,tag:t.tag};this._templateName||(this._templateName=this._currentSettings.CaptureVisionTemplates[0].Name);const i=await this.capture(e,this._templateName);i.originalImageTag=t.tag;for(let t of Ft(this,se,"f"))t.isDce?t.onCapturedResultReceived(i,{isDetectVerifyOpen:!1,isNormalizeVerifyOpen:!1,isBarcodeVerifyOpen:!1,isLabelVerifyOpen:!1}):Ft(this,Qt,"m",me).call(this,t,i)}setInput(t){if(Ee(this),!t)return Ft(this,ue,"f")&&(Ft(this,ne,"f").removeResultReceiver(Ft(this,ue,"f")),Pt(this,ue,null)),Ft(this,fe,"f")&&(Ft(this,se,"f").delete(Ft(this,fe,"f")),Pt(this,fe,null)),void Pt(this,te,null);if(Pt(this,te,t),t.isCameraEnhancer){Ft(this,ne,"f")&&(Ft(this,te,"f")._intermediateResultReceiver.isDce=!0,Ft(this,ne,"f").addResultReceiver(Ft(this,te,"f")._intermediateResultReceiver),Pt(this,ue,Ft(this,te,"f")._intermediateResultReceiver));const t=Ft(this,te,"f").getCameraView();if(t){const e=t._capturedResultReceiver;e.isDce=!0,Ft(this,se,"f").add(e),Pt(this,fe,e)}}}getInput(){return Ft(this,te,"f")}addImageSourceStateListener(t){if(Ee(this),"object"!=typeof t)return console.warn("Invalid ISA state listener.");t&&Object.keys(t)&&Ft(this,ae,"f").add(t)}removeImageSourceStateListener(t){return Ee(this),Ft(this,ae,"f").delete(t)}addResultReceiver(t){if(Ee(this),"object"!=typeof t)throw new Error("Invalid receiver.");t&&Object.keys(t).length&&(Ft(this,se,"f").add(t),this._setCrrRegistry())}removeResultReceiver(t){Ee(this),Ft(this,se,"f").delete(t),this._setCrrRegistry()}async _setCrrRegistry(){const t={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onProcessedDocumentResultReceived:!1,onParsedResultsReceived:!1};for(let e of Ft(this,se,"f"))e.isDce||(t.onCapturedResultReceived=!!e.onCapturedResultReceived,t.onDecodedBarcodesReceived=!!e.onDecodedBarcodesReceived,t.onRecognizedTextLinesReceived=!!e.onRecognizedTextLinesReceived,t.onProcessedDocumentResultReceived=!!e.onProcessedDocumentResultReceived,t.onParsedResultsReceived=!!e.onParsedResultsReceived);const e=new Bt;let i=wt();return Et[i]=async t=>{t.success?e.resolve():Ce({message:t.message,rj:e.reject,stack:t.stack})},vt.postMessage({type:"cvr_setCrrRegistry",id:i,instanceID:this._instanceID,body:{receiver:JSON.stringify(t)}}),e}async addResultFilter(t){if(Ee(this),!t||"object"!=typeof t||!Object.keys(t).length)return console.warn("Invalid filter.");Ft(this,oe,"f").add(t),t._dynamsoft(),await this._handleFilterUpdate()}async removeResultFilter(t){Ee(this),Ft(this,oe,"f").delete(t),await this._handleFilterUpdate()}async _handleFilterUpdate(){if(Ft(this,ne,"f").removeResultReceiver(Se),0===Ft(this,oe,"f").size){this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1;const t={[Q.CRIT_BARCODE]:!1,[Q.CRIT_TEXT_LINE]:!1,[Q.CRIT_DETECTED_QUAD]:!1,[Q.CRIT_DESKEWED_IMAGE]:!1},e={[Q.CRIT_BARCODE]:!1,[Q.CRIT_TEXT_LINE]:!1,[Q.CRIT_DETECTED_QUAD]:!1,[Q.CRIT_DESKEWED_IMAGE]:!1};return await Ft(this,Qt,"m",pe).call(this,t),void await Ft(this,Qt,"m",_e).call(this,e)}for(let t of Ft(this,oe,"f"))this._isOpenBarcodeVerify=t.isResultCrossVerificationEnabled(Q.CRIT_BARCODE),this._isOpenLabelVerify=t.isResultCrossVerificationEnabled(Q.CRIT_TEXT_LINE),this._isOpenDetectVerify=t.isResultCrossVerificationEnabled(Q.CRIT_DETECTED_QUAD),this._isOpenNormalizeVerify=t.isResultCrossVerificationEnabled(Q.CRIT_DESKEWED_IMAGE),t.isLatestOverlappingEnabled(Q.CRIT_BARCODE)&&([...Ft(this,ne,"f")._intermediateResultReceiverSet.values()].find((t=>t.isFilter))||Ft(this,ne,"f").addResultReceiver(Se)),await Ft(this,Qt,"m",pe).call(this,t.verificationEnabled),await Ft(this,Qt,"m",_e).call(this,t.duplicateFilterEnabled),await Ft(this,Qt,"m",ve).call(this,t.duplicateForgetTime)}async startCapturing(t){if(Ee(this),!this._isPauseScan)return;if(!Ft(this,te,"f"))throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");t||(t=Te._defaultTemplate);const e=await this.containsTask(t);for(let t of Ft(this,oe,"f"))await this.addResultFilter(t);const i=R(Dt.engineResourcePaths);return Ft(this,te,"f").isCameraEnhancer&&(e.includes("ddn")?Ft(this,te,"f").setPixelFormat(l.IPF_ABGR_8888):Ft(this,te,"f").setPixelFormat(l.IPF_GRAYSCALED)),void 0!==Ft(this,te,"f").singleFrameMode&&"disabled"!==Ft(this,te,"f").singleFrameMode?(this._templateName=t,void Ft(this,te,"f").on("singleFrameAcquired",this._singleFrameModeCallbackBind)):(Ft(this,te,"f").getColourChannelUsageType()===o.CCUT_AUTO&&Ft(this,te,"f").setColourChannelUsageType(e.includes("ddn")?o.CCUT_FULL_CHANNEL:o.CCUT_Y_CHANNEL_ONLY),Ft(this,ie,"f")&&Ft(this,ie,"f").isPending?Ft(this,ie,"f"):(Pt(this,ie,new Bt(((e,n)=>{if(this.disposed)return;let r=wt();Et[r]=async i=>{Ft(this,ie,"f")&&!Ft(this,ie,"f").isFulfilled&&(i.success?(this._isPauseScan=!1,this._isOutputOriginalImage=i.isOutputOriginalImage,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((async()=>{-1!==this._minImageCaptureInterval&&Ft(this,te,"f").startFetching(),this._loopReadVideo(t),e()}),0)):Ce({message:i.message,rj:n,stack:i.stack}))},vt.postMessage({type:"cvr_startCapturing",id:r,instanceID:this._instanceID,body:{templateName:t,engineResourcePaths:i}})}))),await Ft(this,ie,"f")))}stopCapturing(){Ee(this),Ft(this,te,"f")&&(Ft(this,te,"f").isCameraEnhancer&&void 0!==Ft(this,te,"f").singleFrameMode&&"disabled"!==Ft(this,te,"f").singleFrameMode?Ft(this,te,"f").off("singleFrameAcquired",this._singleFrameModeCallbackBind):(Ft(this,Qt,"m",ye).call(this),Ft(this,te,"f").stopFetching(),this._averageProcessintTimeArray=[],this._averageTime=999,this._isPauseScan=!0,Pt(this,ie,null),Ft(this,te,"f").setColourChannelUsageType(o.CCUT_AUTO)))}async containsTask(t){return Ee(this),await new Promise(((e,i)=>{let n=wt();Et[n]=async t=>{if(t.success)return e(JSON.parse(t.tasks));Ce({message:t.message,rj:i,stack:t.stack})},vt.postMessage({type:"cvr_containsTask",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async _loopReadVideo(t){if(this.disposed||this._isPauseScan)return;if(Pt(this,he,!0),Ft(this,te,"f").isBufferEmpty())if(Ft(this,te,"f").hasNextImageToFetch())for(let t of Ft(this,ae,"f"))t.onImageSourceStateReceived&&t.onImageSourceStateReceived($t.ISS_BUFFER_EMPTY);else if(!Ft(this,te,"f").hasNextImageToFetch())for(let t of Ft(this,ae,"f"))t.onImageSourceStateReceived&&t.onImageSourceStateReceived($t.ISS_EXHAUSTED);if(-1===this._minImageCaptureInterval||Ft(this,te,"f").isBufferEmpty()&&Ft(this,te,"f").isCameraEnhancer)try{Ft(this,te,"f").isBufferEmpty()&&Te._onLog&&Te._onLog("buffer is empty so fetch image"),Te._onLog&&Te._onLog(`DCE: start fetching a frame: ${Date.now()}`),this._dsImage=Ft(this,te,"f").fetchImage(),Te._onLog&&Te._onLog(`DCE: finish fetching a frame: ${Date.now()}`),Ft(this,te,"f").setImageFetchInterval(this._averageTime)}catch(e){return void this._reRunCurrnetFunc(t)}else if(Ft(this,te,"f").isCameraEnhancer&&Ft(this,te,"f").setImageFetchInterval(this._averageTime-(this._dsImage&&this._dsImage.tag?this._dsImage.tag.timeSpent:0)),this._dsImage=Ft(this,te,"f").getImage(),this._dsImage&&this._dsImage.tag&&Date.now()-this._dsImage.tag.timeStamp>200)return void this._reRunCurrnetFunc(t);if(!this._dsImage)return void this._reRunCurrnetFunc(t);for(let t of Ft(this,se,"f"))this._isOutputOriginalImage&&t.onOriginalImageResultReceived&&t.onOriginalImageResultReceived({imageData:this._dsImage});const e=Date.now();this._captureDsimage(this._dsImage,t).then((async i=>{Te._onLog&&Te._onLog("no js handle time: "+(Date.now()-e)),i.originalImageTag=this._dsImage.tag?this._dsImage.tag:null;for(let t of Ft(this,se,"f"))if(t.isDce){const e=Date.now();if(t.onCapturedResultReceived(i,{isDetectVerifyOpen:this._isOpenDetectVerify,isNormalizeVerifyOpen:this._isOpenNormalizeVerify,isBarcodeVerifyOpen:this._isOpenBarcodeVerify,isLabelVerifyOpen:this._isOpenLabelVerify,_isPauseScan:this._isPauseScan}),Te._onLog){const t=Date.now()-e;t>10&&Te._onLog(`draw result time: ${t}`)}}else{for(let t of Ft(this,oe,"f"))t.onDecodedBarcodesReceived(i),t.onRecognizedTextLinesReceived(i),t.onProcessedDocumentResultReceived(i);Ft(this,Qt,"m",me).call(this,t,i)}const n=Date.now();if(this._minImageCaptureInterval>-1&&(5===this._averageProcessintTimeArray.length&&this._averageProcessintTimeArray.shift(),5===this._averageFetchImageTimeArray.length&&this._averageFetchImageTimeArray.shift(),this._averageProcessintTimeArray.push(Date.now()-e),this._averageFetchImageTimeArray.push(this._dsImage&&this._dsImage.tag?this._dsImage.tag.timeSpent:0),this._averageTime=Math.min(...this._averageProcessintTimeArray)-Math.max(...this._averageFetchImageTimeArray),this._averageTime=this._averageTime>0?this._averageTime:0,Te._onLog&&(Te._onLog(`minImageCaptureInterval: ${this._minImageCaptureInterval}`),Te._onLog(`averageProcessintTimeArray: ${this._averageProcessintTimeArray}`),Te._onLog(`averageFetchImageTimeArray: ${this._averageFetchImageTimeArray}`),Te._onLog(`averageTime: ${this._averageTime}`))),Te._onLog){const t=Date.now()-n;t>10&&Te._onLog(`fetch image calculate time: ${t}`)}Te._onLog&&Te._onLog(`time finish decode: ${Date.now()}`),Te._onLog&&Te._onLog("main time: "+(Date.now()-e)),Te._onLog&&Te._onLog("===================================================="),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._minImageCaptureInterval>0&&this._minImageCaptureInterval>=this._averageTime?this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo(t)}),this._minImageCaptureInterval-this._averageTime):this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo(t)}),Math.max(this._minImageCaptureInterval,0))})).catch((e=>{Ft(this,te,"f").stopFetching(),"platform error"!==e.message&&(e.errorCode&&0===e.errorCode&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{Ft(this,te,"f").startFetching(),this._loopReadVideo(t)}),Math.max(this._minImageCaptureInterval,1e3))),setTimeout((()=>{if(!this.onCaptureError)throw e;this.onCaptureError(e)}),0))}))}_reRunCurrnetFunc(t){this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo(t)}),0)}async capture(t,e){let i;if(Ee(this),e||(e=Te._defaultTemplate),Pt(this,he,!1),v(t))i=await this._captureDsimage(t,e);else if("string"==typeof t)i="data:image/"==t.substring(0,11)?await this._captureBase64(t,e):await this._captureUrl(t,e);else if(t instanceof Blob)i=await this._captureBlob(t,e);else if(t instanceof HTMLImageElement)i=await this._captureImage(t,e);else if(t instanceof HTMLCanvasElement)i=await this._captureCanvas(t,e);else{if(!(t instanceof HTMLVideoElement))throw new TypeError("'capture(imageOrFile, templateName)': Type of 'imageOrFile' should be 'DSImageData', 'Url', 'Base64', 'Blob', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement'.");i=await this._captureVideo(t,e)}return i}async _captureDsimage(t,e){return await this._captureInWorker(t,e)}async _captureUrl(t,e){let i=await I(t,"blob");return await this._captureBlob(i,e)}async _captureBase64(t,e){t=t.substring(t.indexOf(",")+1);let i=atob(t),n=i.length,r=new Uint8Array(n);for(;n--;)r[n]=i.charCodeAt(n);return await this._captureBlob(new Blob([r]),e)}async _captureBlob(t,e){let i=null,n=null;if("undefined"!=typeof createImageBitmap)try{i=await createImageBitmap(t)}catch(t){}i||(n=await async function(t){return await new Promise(((e,i)=>{let n=URL.createObjectURL(t),r=new Image;r.src=n,r.onload=()=>{URL.revokeObjectURL(r.dbrObjUrl),e(r)},r.onerror=t=>{i(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}}))}(t));let r=await this._captureImage(i||n,e);return i&&i.close(),r}async _captureImage(t,e){let i,n,r=t instanceof HTMLImageElement?t.naturalWidth:t.width,s=t instanceof HTMLImageElement?t.naturalHeight:t.height,a=Math.max(r,s);a>this.maxImageSideLength?(Pt(this,le,this.maxImageSideLength/a),i=Math.round(r*Ft(this,le,"f")),n=Math.round(s*Ft(this,le,"f"))):(i=r,n=s),Ft(this,ee,"f")||Pt(this,ee,document.createElement("canvas"));const o=Ft(this,ee,"f");return o.width===i&&o.height===n||(o.width=i,o.height=n),o.ctx2d||(o.ctx2d=o.getContext("2d",{willReadFrequently:!0})),o.ctx2d.drawImage(t,0,0,r,s,0,0,i,n),t.dbrObjUrl&&URL.revokeObjectURL(t.dbrObjUrl),await this._captureCanvas(o,e)}async _captureCanvas(t,e){if(t.crossOrigin&&"anonymous"!=t.crossOrigin)throw"cors";if([t.width,t.height].includes(0))throw Error("The width or height of the 'canvas' is 0.");const i=t.ctx2d||t.getContext("2d",{willReadFrequently:!0}),n={bytes:Uint8Array.from(i.getImageData(0,0,t.width,t.height).data),width:t.width,height:t.height,stride:4*t.width,format:1