diff --git a/README.md b/README.md index cd45fbb..d22aa72 100644 --- a/README.md +++ b/README.md @@ -31,21 +31,21 @@ The simplest way to include the SDK is to use either the [**jsDelivr**](https:// - jsDelivr ```html - + ``` - UNPKG ```html - + ``` When using a framework such as **React**, **Vue** or **Angular**, we recommend adding the package as a dependency using a package manager such as **npm** or **yarn**: ```sh - npm i dynamsoft-mrz-scanner@2.1.0 -E + npm i dynamsoft-mrz-scanner@3.0.0-beta-202506160001 -E # or - yarn add dynamsoft-mrz-scanner@2.1.0 -E + yarn add dynamsoft-mrz-scanner@3.0.0-beta-202506160001 -E ``` > [!WARNING] @@ -60,7 +60,7 @@ Below is the complete Hello World sample page that uses the precompiled script s Dynamsoft MRZ Scanner - Hello World - + @@ -139,7 +139,7 @@ Let's now go through the code of the Hello World sample and understand the purpo Dynamsoft MRZ Scanner - Hello World - + diff --git a/dev-server/index.js b/dev-server/index.js index ae3612c..ff412a0 100644 --- a/dev-server/index.js +++ b/dev-server/index.js @@ -119,6 +119,7 @@ httpServer.listen(httpPort, () => { console.log("\x1b[33m Demo:\x1b[0m http://localhost:" + httpPort + "/demo"); console.log("\x1b[90m-------------------\x1b[0m"); console.log("\x1b[33m Use File Input:\x1b[0m http://localhost:" + httpPort + "/scenarios/use-file-input"); + console.log("\x1b[90m-------------------\x1b[0m"); }); httpsServer.listen(httpsPort, "0.0.0.0", () => { diff --git a/dist/mrz-scanner.bundle.esm.d.ts b/dist/mrz-scanner.bundle.esm.d.ts index b544f99..51e875c 100644 --- a/dist/mrz-scanner.bundle.esm.d.ts +++ b/dist/mrz-scanner.bundle.esm.d.ts @@ -1,13 +1,5 @@ -import { DSImageData, EngineResourcePaths } from 'dynamsoft-core'; -export * from 'dynamsoft-core'; -export * from 'dynamsoft-license'; -import { CapturedResult, CaptureVisionRouter } from 'dynamsoft-capture-vision-router'; -export * from 'dynamsoft-capture-vision-router'; -import { CameraEnhancer, CameraView } from 'dynamsoft-camera-enhancer'; -export * from 'dynamsoft-camera-enhancer'; -export * from 'dynamsoft-label-recognizer'; -export * from 'dynamsoft-code-parser'; -export * from 'dynamsoft-utility'; +import { DSImageData, CapturedResult, CaptureVisionRouter, CameraEnhancer, CameraView, EngineResourcePaths } from 'dynamsoft-capture-vision-bundle'; +export * from 'dynamsoft-capture-vision-bundle'; declare enum EnumMRZScanMode { Passport = "passport", @@ -158,12 +150,14 @@ declare class MRZScannerView { private initializeScanModeManager; private getScanMode; private DCEShowToast; + private firstFrame; private startCapturing; private toggleScanDocType; launch(): Promise; } interface MRZResultViewToolbarButtonsConfig { + cancel?: ToolbarButton; rescan?: ToolbarButtonConfig; done?: ToolbarButtonConfig; } @@ -173,7 +167,10 @@ interface MRZResultViewConfig { showOriginalImage?: boolean; showMRZText?: boolean; allowResultEditing?: boolean; + emptyResultMessage?: string; onDone?: (result: MRZResult) => Promise; + onCancel?: (result: MRZResult) => Promise; + _isFileMode?: boolean; } declare class MRZResultView { private resources; @@ -184,6 +181,7 @@ declare class MRZResultView { constructor(resources: SharedResources, config: MRZResultViewConfig, scannerView: MRZScannerView); launch(): Promise; private handleRescan; + private handleCancel; private handleDone; private createControls; private handleFieldEdit; @@ -219,6 +217,8 @@ declare class MRZScanner { private isInitialized; private isCapturing; private loadingScreen; + private isDynamsoftResourcesLoaded; + protected isFileMode: boolean; private showLoadingOverlay; private hideLoadingOverlay; constructor(config: MRZScannerConfig); @@ -229,6 +229,7 @@ declare class MRZScanner { resultView?: MRZResultView; }; }>; + private initializeDynamsoftResources; private initializeDCVResources; private shouldCreateDefaultContainer; private createDefaultMRZScannerContainer; diff --git a/dist/mrz-scanner.bundle.js b/dist/mrz-scanner.bundle.js index e496be5..669ad1c 100644 --- a/dist/mrz-scanner.bundle.js +++ b/dist/mrz-scanner.bundle.js @@ -1 +1 @@ -!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;class n 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,u=(()=>{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"./"}})(),d=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=>"[object Boolean]"===f(t),p=t=>"number"==typeof t&&!Number.isNaN(t),_=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),v=t=>!(!_(t)||!p(t.width)||t.width<=0||!p(t.height)||t.height<=0||!p(t.stride)||t.stride<=0||!("format"in t)||"tag"in t&&!E(t.tag)),y=t=>!!v(t)&&t.bytes instanceof Uint8Array,w=t=>!(!_(t)||!p(t.left)||t.left<0||!p(t.top)||t.top<0||!p(t.right)||t.right<0||!p(t.bottom)||t.bottom<0||t.left>=t.right||t.top>=t.bottom||!m(t.isMeasuredInPercentage)),E=t=>null===t||!!_(t)&&!!p(t.imageId)&&"type"in t,C=t=>!(!_(t)||!S(t.startPoint)||!S(t.endPoint)||t.startPoint.x==t.endPoint.x&&t.startPoint.y==t.endPoint.y),S=t=>!!_(t)&&!!p(t.x)&&!!p(t.y),T=t=>!!_(t)&&!!g(t.points)&&0!=t.points.length&&!t.points.some((t=>!S(t))),b=t=>!!_(t)&&!!g(t.points)&&0!=t.points.length&&4==t.points.length&&!t.points.some((t=>!S(t))),I=t=>!(!_(t)||!p(t.x)||!p(t.y)||!p(t.width)||t.width<0||!p(t.height)||t.height<0||"isMeasuredInPercentage"in t&&!m(t.isMeasuredInPercentage)),x=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))}})),R=(t,e)=>{let i=t.split("."),n=e.split(".");for(let t=0;t{const e={},i={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",dcpd:"dynamsoft-code-parser",dlrData:"dynamsoft-label-recognizer-data",dce:"dynamsoft-camera-enhancer",ddv:"dynamsoft-document-viewer"};for(let n in t){if("rootDirectory"===n)continue;let r=n,s=t[r],a=s&&"object"==typeof s&&s.path?s.path:s,o=t.rootDirectory;if(o&&!o.endsWith("/")&&(o+="/"),"object"==typeof s&&s.isInternal)o&&(a=t[r].version?`${o}${i[r]}@${t[r].version}/dist/${"ddv"===r?"engine":""}`:`${o}${i[r]}/dist/${"ddv"===r?"engine":""}`);else{const i=/^@engineRootDirectory(\/?)/;if("string"==typeof a&&(a=a.replace(i,o||"")),"object"==typeof a&&"dwt"===r){const n=t[r].resourcesPath,s=t[r].serviceInstallerLocation;e[r]={resourcesPath:n.replace(i,o||""),serviceInstallerLocation:s.replace(i,o||"")};continue}}e[r]=d(a)}return e},D=async(t,e,i)=>await new Promise((async(n,r)=>{try{const r=e.split(".");let s=r[r.length-1];const a=await L(`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()}})),A=t=>{y(t)&&(t=M(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},L=async(t,e)=>{y(e)&&(e=M(e));const i=A(e);return new Promise(((e,n)=>{i.toBlob((t=>e(t)),t)}))},M=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=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=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)};var F,P,k,N,B,V,j,U;let G,W,Y,z,H,X=class t{get _isFetchingStarted(){return r(this,B,"f")}constructor(){F.add(this),P.set(this,[]),k.set(this,1),N.set(this,a.BOPM_BLOCK),B.set(this,!1),V.set(this,void 0),j.set(this,o.CCUT_AUTO)}setErrorListener(t){}addImageToBuffer(t){var e;if(!y(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,P,"f").length>=r(this,k,"f"))switch(r(this,N,"f")){case a.BOPM_BLOCK:break;case a.BOPM_UPDATE:if(r(this,P,"f").push(t),_(r(this,V,"f"))&&p(r(this,V,"f").imageId)&&1==r(this,V,"f").keepInBuffer)for(;r(this,P,"f").length>r(this,k,"f");){const t=r(this,P,"f").findIndex((t=>{var e;return(null===(e=t.tag)||void 0===e?void 0:e.imageId)!==r(this,V,"f").imageId}));r(this,P,"f").splice(t,1)}else r(this,P,"f").splice(0,r(this,P,"f").length-r(this,k,"f"))}else r(this,P,"f").push(t)}getImage(){if(0===r(this,P,"f").length)return null;let e;if(r(this,V,"f")&&p(r(this,V,"f").imageId)){const t=r(this,F,"m",U).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,P,"f").slice(t,t+1)[0]}else e=r(this,P,"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,j,"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;t0!==t.length&&t.every((t=>p(t))))(t))throw new TypeError("Invalid 'imageId'.");if(void 0!==e&&!m(e))throw new TypeError("Invalid 'keepInBuffer'.");s(this,V,{imageId:t,keepInBuffer:e})}_resetNextReturnedImage(){s(this,V,null)}hasImage(t){return r(this,F,"m",U).call(this,t)>=0}startFetching(){s(this,B,!0)}stopFetching(){s(this,B,!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,k,t);r(this,P,"f")&&r(this,P,"f").length>t;)r(this,P,"f").shift()}getMaxImageCount(){return r(this,k,"f")}getImageCount(){return r(this,P,"f").length}clearBuffer(){r(this,P,"f").length=0}isBufferEmpty(){return 0===r(this,P,"f").length}setBufferOverflowProtectionMode(t){s(this,N,t)}getBufferOverflowProtectionMode(){return r(this,N,"f")}setColourChannelUsageType(t){s(this,j,t)}getColourChannelUsageType(){return r(this,j,"f")}};P=new WeakMap,k=new WeakMap,N=new WeakMap,B=new WeakMap,V=new WeakMap,j=new WeakMap,F=new WeakSet,U=function(t){if("number"!=typeof t)throw new TypeError("Invalid 'imageId'.");return r(this,P,"f").findIndex((e=>{var i;return(null===(i=e.tag)||void 0===i?void 0:i.imageId)===t}))},"undefined"!=typeof navigator&&(G=navigator,W=G.userAgent,Y=G.platform,z=G.mediaDevices),function(){if(!h){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:G.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:Y,search:"Win"},Mac:{str:Y},Linux:{str:Y}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||W,a=r.search||e,o=r.verStr||W,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||W,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=W.indexOf("Windows NT")&&(r="HarmonyOS"),H={browser:i,version:n,OS:r}}h&&(H={browser:"ssr",version:0,OS:"ssr"})}();const Z="undefined"!=typeof WebAssembly&&W&&!(/Safari/.test(W)&&!/Chrome/.test(W)&&/\(.+\s11_2_([2-6]).*\)/.test(W)),q=!("undefined"==typeof Worker),J=!(!z||!z.getUserMedia),K=async()=>{let t=!1;if(J)try{(await z.getUserMedia({video:!0})).getTracks().forEach((t=>{t.stop()})),t=!0}catch(t){}return t};"Chrome"===H.browser&&H.version>66||"Safari"===H.browser&&H.version>13||"OPR"===H.browser&&H.version>43||"Edge"===H.browser&&H.version;const $={},Q=async t=>{let e="string"==typeof t?[t]:t,i=[];for(let t of e)i.push($[t]=$[t]||new n);await Promise.all(i)},tt=async(t,e)=>{let i,r="string"==typeof t?[t]:t,s=[];for(let t of r){let r;s.push(r=$[t]=$[t]||new n(i=i||e())),r.isEmpty&&(r.task=i=i||e())}await Promise.all(s)};let et,it=0;const nt=()=>it++,rt={};let st;const at=t=>{st=t,et&&et.postMessage({type:"setBLog",body:{value:!!t}})};let ot=!1;const lt=t=>{ot=t,et&&et.postMessage({type:"setBDebug",body:{value:!!t}})},ht={},ct={},ut={dip:{wasm:!0}},dt={std:{version:"1.4.21",path:d(u+"../../dynamsoft-capture-vision-std@1.4.21/dist/"),isInternal:!0},core:{version:"3.4.31",path:u,isInternal:!0}},ft=async t=>{let e;t instanceof Array||(t=t?[t]:[]);let i=$.core;e=!i||i.isEmpty;let r=new Map;const s=t=>{if("std"==(t=t.toLowerCase())||"core"==t)return;if(!ut[t])throw Error("The '"+t+"' module cannot be found.");let e=ut[t].deps;if(null==e?void 0:e.length)for(let t of e)s(t);let i=$[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 tt(a,(async()=>{const t=[...r.entries()].filter((t=>t[1])).map((t=>t[0]));await Q(o);const i=O(dt),s={};for(let e of t)s[e]=ut[e];const a={engineResourcePaths:i,autoResources:s,names:t};let l=new n;if(e){a.needLoadCore=!0;let t=i.core+gt._workerName;t.startsWith(location.origin)||(t=await fetch(t).then((t=>t.blob())).then((t=>URL.createObjectURL(t)))),et=new Worker(t),et.onerror=t=>{let e=new Error(t.message);l.reject(e)},et.addEventListener("message",(t=>{let e=t.data?t.data:t,i=e.type,n=e.id,r=e.body;switch(i){case"log":st&&st(e.message);break;case"task":try{rt[n](r),delete rt[n]}catch(t){throw delete rt[n],t}break;case"event":try{rt[n](r)}catch(t){throw t}break;default:console.log(t)}})),a.bLog=!!st,a.bd=ot,a.dm=location.origin.startsWith("http")?location.origin:"https://localhost"}else await Q("core");let h=it++;rt[h]=t=>{if(t.success)Object.assign(ht,t.versions),"{}"!==JSON.stringify(t.versions)&&(gt._versions=t.versions),l.resolve(void 0);else{const e=Error(t.message);t.stack&&(e.stack=t.stack),l.reject(e)}},et.postMessage({type:"loadWasm",body:a,id:h}),await l}))};class gt{static get engineResourcePaths(){return dt}static set engineResourcePaths(t){Object.assign(dt,t)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _onLog(){return st}static set _onLog(t){at(t)}static get _bDebug(){return ot}static set _bDebug(t){lt(t)}static isModuleLoaded(t){return t=(t=t||"core").toLowerCase(),!!$[t]&&$[t].isFulfilled}static async loadWasm(t){return await ft(t)}static async detectEnvironment(){return await(async()=>({wasm:Z,worker:q,getUserMedia:J,camera:await K(),browser:H.browser,version:H.version,OS:H.OS}))()}static async getModuleVersion(){return await new Promise(((t,e)=>{let i=nt();rt[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)}},et.postMessage({type:"getModuleVersion",id:i})}))}static getVersion(){return`3.4.31(Worker: ${ht.core&&ht.core.worker||"Not Loaded"}, Wasm: ${ht.core&&ht.core.wasm||"Not Loaded"})`}static enableLogging(){X._onLog=console.log,gt._onLog=console.log}static disableLogging(){X._onLog=null,gt._onLog=null}static async cfd(t){return await new Promise(((e,i)=>{let n=nt();rt[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},et.postMessage({type:"cfd",id:n,body:{count:t}})}))}}var mt,pt,_t,vt,yt,wt,Et,Ct,St;gt._bSupportDce4Module=-1,gt._bSupportIRTModule=-1,gt._versions=null,gt._workerName="core.worker.js",gt.browserInfo=H,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_NORMALIZED_IMAGE=16]="CRIT_NORMALIZED_IMAGE",t[t.CRIT_PARSED_RESULT=32]="CRIT_PARSED_RESULT"}(mt||(mt={})),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"}(pt||(pt={})),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_RESERVED_INFO_NOT_MATCH=-10040]="EC_RESERVED_INFO_NOT_MATCH",t[t.EC_LICENSE_KEY_NOT_MATCH=-10043]="EC_LICENSE_KEY_NOT_MATCH",t[t.EC_REQUEST_FAILED=-10044]="EC_REQUEST_FAILED",t[t.EC_LICENSE_INIT_FAILED=-10045]="EC_LICENSE_INIT_FAILED",t[t.EC_SET_MODE_ARGUMENT_ERROR=-10051]="EC_SET_MODE_ARGUMENT_ERROR",t[t.EC_LICENSE_CONTENT_INVALID=-10052]="EC_LICENSE_CONTENT_INVALID",t[t.EC_LICENSE_KEY_INVALID=-10053]="EC_LICENSE_KEY_INVALID",t[t.EC_LICENSE_DEVICE_RUNS_OUT=-10054]="EC_LICENSE_DEVICE_RUNS_OUT",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_NO_LICENSE=-2e4]="EC_NO_LICENSE",t[t.EC_HANDSHAKE_CODE_INVALID=-20001]="EC_HANDSHAKE_CODE_INVALID",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_LICENSE_INIT_SEQUENCE_FAILED=-20009]="EC_LICENSE_INIT_SEQUENCE_FAILED",t[t.EC_TRIAL_LICENSE=-20010]="EC_TRIAL_LICENSE",t[t.EC_FAILED_TO_REACH_DLS=-20200]="EC_FAILED_TO_REACH_DLS",t[t.EC_LICENSE_CACHE_USED=-20012]="EC_LICENSE_CACHE_USED",t[t.EC_BARCODE_FORMAT_INVALID=-30009]="EC_BARCODE_FORMAT_INVALID",t[t.EC_QR_LICENSE_INVALID=-30016]="EC_QR_LICENSE_INVALID",t[t.EC_1D_LICENSE_INVALID=-30017]="EC_1D_LICENSE_INVALID",t[t.EC_PDF417_LICENSE_INVALID=-30019]="EC_PDF417_LICENSE_INVALID",t[t.EC_DATAMATRIX_LICENSE_INVALID=-30020]="EC_DATAMATRIX_LICENSE_INVALID",t[t.EC_CUSTOM_MODULESIZE_INVALID=-30025]="EC_CUSTOM_MODULESIZE_INVALID",t[t.EC_AZTEC_LICENSE_INVALID=-30041]="EC_AZTEC_LICENSE_INVALID",t[t.EC_PATCHCODE_LICENSE_INVALID=-30046]="EC_PATCHCODE_LICENSE_INVALID",t[t.EC_POSTALCODE_LICENSE_INVALID=-30047]="EC_POSTALCODE_LICENSE_INVALID",t[t.EC_DPM_LICENSE_INVALID=-30048]="EC_DPM_LICENSE_INVALID",t[t.EC_FRAME_DECODING_THREAD_EXISTS=-30049]="EC_FRAME_DECODING_THREAD_EXISTS",t[t.EC_STOP_DECODING_THREAD_FAILED=-30050]="EC_STOP_DECODING_THREAD_FAILED",t[t.EC_MAXICODE_LICENSE_INVALID=-30057]="EC_MAXICODE_LICENSE_INVALID",t[t.EC_GS1_DATABAR_LICENSE_INVALID=-30058]="EC_GS1_DATABAR_LICENSE_INVALID",t[t.EC_GS1_COMPOSITE_LICENSE_INVALID=-30059]="EC_GS1_COMPOSITE_LICENSE_INVALID",t[t.EC_DOTCODE_LICENSE_INVALID=-30061]="EC_DOTCODE_LICENSE_INVALID",t[t.EC_PHARMACODE_LICENSE_INVALID=-30062]="EC_PHARMACODE_LICENSE_INVALID",t[t.EC_CHARACTER_MODEL_FILE_NOT_FOUND=-40100]="EC_CHARACTER_MODEL_FILE_NOT_FOUND",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_ZA_DL_LICENSE_INVALID=-90006]="EC_ZA_DL_LICENSE_INVALID",t[t.EC_AAMVA_DL_ID_LICENSE_INVALID=-90007]="EC_AAMVA_DL_ID_LICENSE_INVALID",t[t.EC_AADHAAR_LICENSE_INVALID=-90008]="EC_AADHAAR_LICENSE_INVALID",t[t.EC_MRTD_LICENSE_INVALID=-90009]="EC_MRTD_LICENSE_INVALID",t[t.EC_VIN_LICENSE_INVALID=-90010]="EC_VIN_LICENSE_INVALID",t[t.EC_CUSTOMIZED_CODE_TYPE_LICENSE_INVALID=-90011]="EC_CUSTOMIZED_CODE_TYPE_LICENSE_INVALID",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"}(_t||(_t={})),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"}(vt||(vt={})),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"}(yt||(yt={})),function(t){t[t.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",t[t.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(wt||(wt={})),function(t){t[t.PDFRM_VECTOR=1]="PDFRM_VECTOR",t[t.PDFRM_RASTER=2]="PDFRM_RASTER",t[t.PDFRM_REV=-2147483648]="PDFRM_REV"}(Et||(Et={})),function(t){t[t.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",t[t.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(Ct||(Ct={})),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"}(St||(St={}));const Tt={IRUT_NULL:BigInt(0),IRUT_COLOUR_IMAGE:BigInt(1),IRUT_SCALED_DOWN_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_UP_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_NORMALIZED_IMAGES:BigInt(1<<26),IRUT_SHORT_LINES:BigInt(1<<27),IRUT_RAW_TEXT_LINES:BigInt(1<<28),IRUT_LOGIC_LINES:BigInt(1<<29),IRUT_ALL:BigInt("0xFFFFFFFFFFFFFFFF")};var bt,It;!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_NORMALIZED_IMAGE=6]="ROET_NORMALIZED_IMAGE",t[t.ROET_SOURCE_IMAGE=7]="ROET_SOURCE_IMAGE",t[t.ROET_TARGET_ROI=8]="ROET_TARGET_ROI"}(bt||(bt={})),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_NORMALIZATION=7]="ST_DOCUMENT_NORMALIZATION"}(It||(It={}));var xt=Object.freeze({__proto__:null,CoreModule:gt,get EnumBufferOverflowProtectionMode(){return a},get EnumCapturedResultItemType(){return mt},get EnumColourChannelUsageType(){return o},get EnumCornerType(){return pt},get EnumCrossVerificationStatus(){return St},get EnumErrorCode(){return _t},get EnumGrayscaleEnhancementMode(){return vt},get EnumGrayscaleTransformationMode(){return yt},get EnumImagePixelFormat(){return l},get EnumImageTagType(){return wt},EnumIntermediateResultUnitType:Tt,get EnumPDFReadingMode(){return Et},get EnumRasterDataSource(){return Ct},get EnumRegionObjectElementType(){return bt},get EnumSectionType(){return It},ImageSourceAdapter:X,_getNorImageData:M,_saveToFile:D,_toBlob:L,_toCanvas:A,_toImage:(t,e)=>{y(e)&&(e=M(e));const i=A(e);let n=new Image,r=i.toDataURL(t);return n.src=r,n},get bDebug(){return ot},checkIsLink:t=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(t),compareVersion:R,doOrWaitAsyncDependency:tt,getNextTaskID:nt,handleEngineResourcePaths:O,innerVersions:ht,isArc:t=>!(!_(t)||!p(t.x)||!p(t.y)||!p(t.radius)||t.radius<0||!p(t.startAngle)||!p(t.endAngle)),isContour:t=>!!_(t)&&!!g(t.points)&&0!=t.points.length&&!t.points.some((t=>!S(t))),isDSImageData:y,isDSRect:w,isImageTag:E,isLineSegment:C,isObject:_,isOriginalDsImageData:t=>!(!v(t)||!p(t.bytes.length)&&!p(t.bytes.ptr)),isPoint:S,isPolygon:T,isQuad:b,isRect:I,loadWasm:ft,mapAsyncDependency:$,mapPackageRegister:ct,mapTaskCallBack:rt,get onLog(){return st},requestResource:x,setBDebug:lt,setOnLog:at,waitAsyncDependency:Q,get worker(){return et},workerAutoResources:ut});const Rt="undefined"==typeof self,Ot=Rt?{}:self,Dt="function"==typeof importScripts,At=(()=>{if(!Dt){if(!Rt&&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"./"}})(),Lt=t=>t&&"object"==typeof t&&"function"==typeof t.then,Mt=(async()=>{})().constructor;let Ft=class extends Mt{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,Lt(t)?e=t:"function"==typeof t&&(e=new Mt(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&&(Lt(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}};const Pt=" is not allowed to change after `createInstance` or `loadWasm` is called.",kt=!Rt&&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"))||"",Nt=(t,e)=>{const i=t;if(i._license!==e){if(!i._pLoad.isEmpty)throw new Error("`license`"+Pt);i._license=e}};!Rt&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword");const Bt=t=>{if(null==t)t=[];else{t=t instanceof Array?[...t]:[t];for(let e=0;e{e=Bt(e);const i=t;if(i._licenseServer!==e){if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+Pt);i._licenseServer=e}},jt=(t,e)=>{e=e||"";const i=t;if(i._deviceFriendlyName!==e){if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+Pt);i._deviceFriendlyName=e}};let Ut,Gt,Wt,Yt,zt;"undefined"!=typeof navigator&&(Ut=navigator,Gt=Ut.userAgent,Wt=Ut.platform,Yt=Ut.mediaDevices),function(){if(!Rt){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:Ut.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:Wt,search:"Win"},Mac:{str:Wt},Linux:{str:Wt}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||Gt,a=r.search||e,o=r.verStr||Gt,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||Gt,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=Gt.indexOf("Windows NT")&&(r="HarmonyOS"),zt={browser:i,version:n,OS:r}}Rt&&(zt={browser:"ssr",version:0,OS:"ssr"})}(),Yt&&Yt.getUserMedia,"Chrome"===zt.browser&&zt.version>66||"Safari"===zt.browser&&zt.version>13||"OPR"===zt.browser&&zt.version>43||"Edge"===zt.browser&&zt.version;const Ht=()=>(ft("license"),tt("dynamsoft_inited",(async()=>{let{lt:t,l:e,ls:i,sp:n,rmk:r,cv:s}=((t,e=!1)=>{const i=t;if(i._pLoad.isEmpty){let n,r,s,a=i._license||"",o=JSON.parse(JSON.stringify(i._licenseServer)),l=i._sessionPassword,h=0;if(a.startsWith("t")||a.startsWith("f"))h=0;else if(0===a.length||a.startsWith("P")||a.startsWith("L")||a.startsWith("Y")||a.startsWith("A"))h=1;else{h=2;const e=a.indexOf(":");-1!=e&&(a=a.substring(e+1));const i=a.indexOf("?");if(-1!=i&&(r=a.substring(i+1),a=a.substring(0,i)),a.startsWith("DLC2"))h=0;else{if(a.startsWith("DLS2")){let e;try{let t=a.substring(4);t=atob(t),e=JSON.parse(t)}catch(t){throw new Error("Format Error: The license string you specified is invalid, please check to make sure it is correct.")}if(a=e.handshakeCode?e.handshakeCode:e.organizationID?e.organizationID:"","number"==typeof a&&(a=JSON.stringify(a)),0===o.length){let t=[];e.mainServerURL&&(t[0]=e.mainServerURL),e.standbyServerURL&&(t[1]=e.standbyServerURL),o=Bt(t)}!l&&e.sessionPassword&&(l=e.sessionPassword),n=e.remark}a&&"200001"!==a&&!a.startsWith("200001-")||(h=1)}}if(h&&(e||(Ot.crypto||(s="Please upgrade your browser to support online key."),Ot.crypto.subtle||(s="Require https to use online key in this browser."))),s)throw new Error(s);return 1===h&&(a="",console.warn("Applying for a public trial license ...")),{lt:h,l:a,ls:o,sp:l,rmk:n,cv:r}}throw new Error("Can't preprocess license again"+Pt)})(Zt),a=new Ft;Zt._pLoad.task=a,(async()=>{try{await Zt._pLoad}catch(t){}})();let o=nt();rt[o]=e=>{if(e.message&&Zt._onAuthMessage){let t=Zt._onAuthMessage(e.message);null!=t&&(e.message=t)}let i,n=!1;if(1===t&&(n=!0),e.success?(st&&st("init license success"),e.message&&console.warn(e.message),gt._bSupportIRTModule=e.bSupportIRTModule,gt._bSupportDce4Module=e.bSupportDce4Module,Zt.bPassValidation=!0,[0,-10076].includes(e.initLicenseInfo.errorCode)?[-10076].includes(e.initLicenseInfo.errorCode)&&console.warn(e.initLicenseInfo.errorString):a.reject(new Error(e.initLicenseInfo.errorString))):(i=Error(e.message),e.stack&&(i.stack=e.stack),e.ltsErrorCode&&(i.ltsErrorCode=e.ltsErrorCode),n||111==e.ltsErrorCode&&-1!=e.message.toLowerCase().indexOf("trial license")&&(n=!0)),n){const t=O(gt.engineResourcePaths);(async(t,e,i)=>{if(!t._bNeverShowDialog)try{let n=await fetch(t.engineResourcePath+"dls.license.dialog.html");if(!n.ok)throw Error("Get license dialog fail. Network Error: "+n.statusText);let r=await n.text();if(!r.trim().startsWith("<"))throw Error("Get license dialog fail. Can't get valid HTMLElement.");let s=document.createElement("div");s.innerHTML=r;let a=[];for(let t=0;t{if(t==e.target){o.remove();for(let t of a)t.remove()}}));else if(!h&&t.classList.contains("dls-license-icon-close"))h=t,t.addEventListener("click",(()=>{o.remove();for(let t of a)t.remove()}));else if(!c&&t.classList.contains("dls-license-icon-error"))c=t,"error"!=e&&t.remove();else if(!u&&t.classList.contains("dls-license-icon-warn"))u=t,"warn"!=e&&t.remove();else if(!d&&t.classList.contains("dls-license-msg-content")){d=t;let e=i;for(;e;){let i=e.indexOf("["),n=e.indexOf("]",i),r=e.indexOf("(",n),s=e.indexOf(")",r);if(-1==i||-1==n||-1==r||-1==s){t.appendChild(new Text(e));break}i>0&&t.appendChild(new Text(e.substring(0,i)));let a=document.createElement("a"),o=e.substring(i+1,n);a.innerText=o;let l=e.substring(r+1,s);a.setAttribute("href",l),a.setAttribute("target","_blank"),t.appendChild(a),e=e.substring(s+1)}}document.body.appendChild(o)}catch(e){t._onLog&&t._onLog(e.message||e)}})({_bNeverShowDialog:Zt._bNeverShowDialog,engineResourcePath:t.license,_onLog:st},e.success?"warn":"error",e.message)}e.success?a.resolve(void 0):a.reject(i)},await Q("core"),et.postMessage({type:"license_dynamsoft",body:{v:"3.4.31",brtk:!!t,bptk:1===t,l:e,os:zt,fn:Zt.deviceFriendlyName,ls:i,sp:n,rmk:r,cv:s},id:o}),Zt.bCallInitLicense=!0,await a})));let Xt;ct.license={},ct.license.dynamsoft=Ht,ct.license.getAR=async()=>{{let t=$.dynamsoft_inited;t&&t.isRejected&&await t}return et?new Promise(((t,e)=>{let i=nt();rt[i]=async i=>{if(i.success){delete i.success;{let t=Zt.license;t&&(t.startsWith("t")||t.startsWith("f"))&&(i.pk=t)}if(Object.keys(i).length){if(i.lem){let t=Error(i.lem);t.ltsErrorCode=i.lec,delete i.lem,delete i.lec,i.ae=t}t(i)}else t(null)}else{let t=Error(i.message);i.stack&&(t.stack=i.stack),e(t)}},et.postMessage({type:"license_getAR",id:i})})):null};let Zt=class t{static setLicenseServer(e){Vt(t,e)}static get license(){return this._license}static set license(e){Nt(t,e)}static get licenseServer(){return this._licenseServer}static set licenseServer(e){Vt(t,e)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(e){jt(t,e)}static initLicense(e,i){if(Nt(t,e),t.bCallInitLicense=!0,"boolean"==typeof i&&i||"object"==typeof i&&i.executeNow)return Ht()}static setDeviceFriendlyName(e){jt(t,e)}static getDeviceFriendlyName(){return t._deviceFriendlyName}static getDeviceUUID(){return(async()=>(await tt("dynamsoft_uuid",(async()=>{await ft();let t=new Ft,e=nt();rt[e]=e=>{if(e.success)t.resolve(e.uuid);else{const i=Error(e.message);e.stack&&(i.stack=e.stack),t.reject(i)}},et.postMessage({type:"license_getDeviceUUID",id:e}),Xt=await t})),Xt))()}};Zt._pLoad=new Ft,Zt.bPassValidation=!1,Zt.bCallInitLicense=!1,Zt._license=kt,Zt._licenseServer=[],Zt._deviceFriendlyName="",gt.engineResourcePaths.license={version:"3.4.31",path:At,isInternal:!0},ut.license={wasm:!0,js:!0},ct.license.LicenseManager=Zt;const qt="1.4.21";"string"!=typeof gt.engineResourcePaths.std&&R(gt.engineResourcePaths.std.version,qt)<0&&(gt.engineResourcePaths.std={version:qt,path:(t=>{if(null==t&&(t="./"),Rt||Dt);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(At+`../../dynamsoft-capture-vision-std@${qt}/dist/`),isInternal:!0});var Jt=Object.freeze({__proto__:null,LicenseManager:Zt,LicenseModule:class{static getVersion(){return`3.4.31(Worker: ${ht.license&&ht.license.worker||"Not Loaded"}, Wasm: ${ht.license&&ht.license.wasm||"Not Loaded"})`}}});function Kt(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 $t(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 Qt=t=>t&&"object"==typeof t&&"function"==typeof t.then,te=(async()=>{})().constructor;class ee extends te{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,Qt(t)?e=t:"function"==typeof t&&(e=new te(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&&(Qt(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}}class ie{constructor(t){this._cvr=t}async getMaxBufferedItems(){return await new Promise(((t,e)=>{let i=nt();rt[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)}},et.postMessage({type:"cvr_getMaxBufferedItems",id:i,instanceID:this._cvr._instanceID})}))}async setMaxBufferedItems(t){return await new Promise(((e,i)=>{let n=nt();rt[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},et.postMessage({type:"cvr_setMaxBufferedItems",id:n,instanceID:this._cvr._instanceID,body:{count:t}})}))}async getBufferedCharacterItemSet(){return await new Promise(((t,e)=>{let i=nt();rt[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)}},et.postMessage({type:"cvr_getBufferedCharacterItemSet",id:i,instanceID:this._cvr._instanceID})}))}}var ne={onTaskResultsReceived:!1,onTaskResultsReceivedForDce:!1,onPredetectedRegionsReceived:!1,onLocalizedBarcodesReceived:!1,onDecodedBarcodesReceived:!1,onLocalizedTextLinesReceived:!1,onRecognizedTextLinesReceived:!1,onDetectedQuadsReceived:!1,onNormalizedImagesReceived:!1,onColourImageUnitReceived:!1,onScaledDownColourImageUnitReceived:!1,onGrayscaleImageUnitReceived:!1,onTransformedGrayscaleImageUnitReceived:!1,onEnhancedGrayscaleImageUnitReceived:!1,onBinaryImageUnitReceived:!1,onTextureDetectionResultUnitReceived:!1,onTextureRemovedGrayscaleImageUnitReceived:!1,onTextureRemovedBinaryImageUnitReceived:!1,onContoursUnitReceived:!1,onLineSegmentsUnitReceived:!1,onTextZonesUnitReceived:!1,onTextRemovedBinaryImageUnitReceived:!1,onRawTextLinesReceived:!1,onLongLinesUnitReceived:!1,onCornersUnitReceived:!1,onCandidateQuadEdgesUnitReceived:!1,onCandidateBarcodeZonesUnitReceived:!1,onScaledUpBarcodeImageUnitReceived:!1,onDeformationResistedBarcodeImageUnitReceived:!1,onComplementedBarcodeImageUnitReceived:!1,onShortLinesUnitReceived:!1,onLogicLinesReceived:!1};const re=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 se{constructor(t){this._irrRegistryState=ne,this._intermediateResultReceiverSet=new Set,this._cvr=t}async addResultReceiver(t){if("object"!=typeof t)throw new Error("Invalid receiver.");this._intermediateResultReceiverSet.add(t),re(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=nt();rt[r]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,n(t)}},et.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),re(this),await new Promise(((t,e)=>{let i=nt();rt[i]=async i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},et.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})}))}getOriginalImage(){return this._cvr._dsImage}}const ae="undefined"==typeof self,oe="function"==typeof importScripts,le=(()=>{if(!oe){if(!ae&&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"./"}})(),he=t=>{if(null==t&&(t="./"),ae||oe);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};var ce;gt.engineResourcePaths.cvr={version:"2.4.33",path:le,isInternal:!0},ut.cvr={js:!0,wasm:!0,deps:["license","dip"]},ct.cvr={};const ue="1.4.21";"string"!=typeof gt.engineResourcePaths.std&&R(gt.engineResourcePaths.std.version,ue)<0&&(gt.engineResourcePaths.std={version:ue,path:he(le+`../../dynamsoft-capture-vision-std@${ue}/dist/`),isInternal:!0});const de="2.4.31";(!gt.engineResourcePaths.dip||"string"!=typeof gt.engineResourcePaths.dip&&R(gt.engineResourcePaths.dip.version,de)<0)&&(gt.engineResourcePaths.dip={version:de,path:he(le+`../../dynamsoft-image-processing@${de}/dist/`),isInternal:!0});class fe{static getVersion(){return this._version}}fe._version=`2.4.33(Worker: ${null===(ce=ht.cvr)||void 0===ce?void 0:ce.worker}, Wasm: loading...`;const ge={barcodeResultItems:{type:mt.CRIT_BARCODE,reveiver:"onDecodedBarcodesReceived",isNeedFilter:!0},textLineResultItems:{type:mt.CRIT_TEXT_LINE,reveiver:"onRecognizedTextLinesReceived",isNeedFilter:!0},detectedQuadResultItems:{type:mt.CRIT_DETECTED_QUAD,reveiver:"onDetectedQuadsReceived",isNeedFilter:!1},normalizedImageResultItems:{type:mt.CRIT_NORMALIZED_IMAGE,reveiver:"onNormalizedImagesReceived",isNeedFilter:!1},parsedResultItems:{type:mt.CRIT_PARSED_RESULT,reveiver:"onParsedResultsReceived",isNeedFilter:!1}};var me,pe,_e,ve,ye,we,Ee,Ce,Se,Te,be,Ie,xe;function Re(t,e){if(t&&t.location){const i=t.location.points;for(let t of i)t.x=t.x/e,t.y=t.y/e;Re(t.referencedItem,e)}}function Oe(t){if(t.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}!function(t){t[t.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",t[t.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}(me||(me={}));const De={onTaskResultsReceived:()=>{},isFilter:!0};class Ae{constructor(){this.maxImageSideLength=["iPhone","Android","HarmonyOS"].includes(gt.browserInfo.OS)?2048:4096,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,pe.set(this,null),_e.set(this,null),ve.set(this,null),ye.set(this,null),we.set(this,null),Ee.set(this,new Set),Ce.set(this,new Set),Se.set(this,new Set),Te.set(this,0),be.set(this,!1),Ie.set(this,!1),xe.set(this,!1),this._singleFrameModeCallbackBind=this._singleFrameModeCallback.bind(this)}get disposed(){return Kt(this,xe,"f")}static async createInstance(){if(!ct.license)throw Error("Module `license` is not existed.");await ct.license.dynamsoft(),await ft(["cvr"]);const t=new Ae,e=new ee;let i=nt();return rt[i]=async i=>{var n;if(i.success)t._instanceID=i.instanceID,t._currentSettings=JSON.parse(JSON.parse(i.outputSettings).data),fe._version=`2.4.33(Worker: ${null===(n=ht.cvr)||void 0===n?void 0:n.worker}, Wasm: ${i.version})`,$t(t,Ie,!0),$t(t,ye,t.getIntermediateResultManager()),$t(t,Ie,!1),e.resolve(t);else{const t=Error(i.message);i.stack&&(t.stack=i.stack),e.reject(t)}},et.postMessage({type:"cvr_createInstance",id:i}),e}async _singleFrameModeCallback(t){for(let e of Kt(this,Ee,"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;const n={originalImageHashId:i.originalImageHashId,originalImageTag:i.originalImageTag,errorCode:i.errorCode,errorString:i.errorString};for(let t of Kt(this,Ee,"f"))if(t.isDce)t.onCapturedResultReceived(i,{isDetectVerifyOpen:!1,isNormalizeVerifyOpen:!1,isBarcodeVerifyOpen:!1,isLabelVerifyOpen:!1});else{for(let e in ge){const r=e,s=ge[r];t[s.reveiver]&&i[r]&&t[s.reveiver](Object.assign(Object.assign({},n),{[r]:i[r]}))}t.onCapturedResultReceived&&t.onCapturedResultReceived(i)}}setInput(t){if(Oe(this),t){if($t(this,pe,t),t.isCameraEnhancer){Kt(this,ye,"f")&&(Kt(this,pe,"f")._intermediateResultReceiver.isDce=!0,Kt(this,ye,"f").addResultReceiver(Kt(this,pe,"f")._intermediateResultReceiver));const t=Kt(this,pe,"f").getCameraView();if(t){const e=t._capturedResultReceiver;e.isDce=!0,Kt(this,Ee,"f").add(e)}}}else $t(this,pe,null)}getInput(){return Kt(this,pe,"f")}addImageSourceStateListener(t){if(Oe(this),"object"!=typeof t)return console.warn("Invalid ISA state listener.");t&&Object.keys(t)&&Kt(this,Ce,"f").add(t)}removeImageSourceStateListener(t){return Oe(this),Kt(this,Ce,"f").delete(t)}addResultReceiver(t){if(Oe(this),"object"!=typeof t)throw new Error("Invalid receiver.");t&&Object.keys(t).length&&(Kt(this,Ee,"f").add(t),this._setCrrRegistry())}removeResultReceiver(t){Oe(this),Kt(this,Ee,"f").delete(t),this._setCrrRegistry()}async _setCrrRegistry(){const t={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onDetectedQuadsReceived:!1,onNormalizedImagesReceived:!1,onParsedResultsReceived:!1};for(let e of Kt(this,Ee,"f"))e.isDce||(t.onCapturedResultReceived=!!e.onCapturedResultReceived,t.onDecodedBarcodesReceived=!!e.onDecodedBarcodesReceived,t.onRecognizedTextLinesReceived=!!e.onRecognizedTextLinesReceived,t.onDetectedQuadsReceived=!!e.onDetectedQuadsReceived,t.onNormalizedImagesReceived=!!e.onNormalizedImagesReceived,t.onParsedResultsReceived=!!e.onParsedResultsReceived);const e=new ee;let i=nt();return rt[i]=async t=>{if(t.success)e.resolve();else{let i=new Error(t.message);i.stack=t.stack+"\n"+i.stack,e.reject()}},et.postMessage({type:"cvr_setCrrRegistry",id:i,instanceID:this._instanceID,body:{receiver:JSON.stringify(t)}}),e}async addResultFilter(t){if(Oe(this),!t||"object"!=typeof t||!Object.keys(t).length)return console.warn("Invalid filter.");Kt(this,Se,"f").add(t),t._dynamsoft(),await this._handleFilterUpdate()}async removeResultFilter(t){Oe(this),Kt(this,Se,"f").delete(t),await this._handleFilterUpdate()}async _handleFilterUpdate(){if(Kt(this,ye,"f").removeResultReceiver(De),0===Kt(this,Se,"f").size){this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1;const t={[mt.CRIT_BARCODE]:!1,[mt.CRIT_TEXT_LINE]:!1,[mt.CRIT_DETECTED_QUAD]:!1,[mt.CRIT_NORMALIZED_IMAGE]:!1},e={[mt.CRIT_BARCODE]:!1,[mt.CRIT_TEXT_LINE]:!1,[mt.CRIT_DETECTED_QUAD]:!1,[mt.CRIT_NORMALIZED_IMAGE]:!1};return await Le(this,t),void await Me(this,e)}for(let t of Kt(this,Se,"f")){if(this._isOpenBarcodeVerify=t.isResultCrossVerificationEnabled(mt.CRIT_BARCODE),this._isOpenLabelVerify=t.isResultCrossVerificationEnabled(mt.CRIT_TEXT_LINE),this._isOpenDetectVerify=t.isResultCrossVerificationEnabled(mt.CRIT_DETECTED_QUAD),this._isOpenNormalizeVerify=t.isResultCrossVerificationEnabled(mt.CRIT_NORMALIZED_IMAGE),t.isLatestOverlappingEnabled(mt.CRIT_BARCODE)){[...Kt(this,ye,"f")._intermediateResultReceiverSet.values()].find((t=>t.isFilter))||Kt(this,ye,"f").addResultReceiver(De)}await Le(this,t.verificationEnabled),await Me(this,t.duplicateFilterEnabled),await Fe(this,t.duplicateForgetTime)}}async startCapturing(t){var e,i;if(Oe(this),!this._isPauseScan)return;if(!Kt(this,pe,"f"))throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");t||(t=Ae._defaultTemplate);const n=await this.containsTask(t);await ft(n);for(let t of Kt(this,Se,"f"))await this.addResultFilter(t);if(n.includes("dlr")&&!(null===(e=ct.dlr)||void 0===e?void 0:e.bLoadConfusableCharsData)){const t=O(gt.engineResourcePaths);await(null===(i=ct.dlr)||void 0===i?void 0:i.loadRecognitionData("ConfusableChars",t.dlr))}if(Kt(this,pe,"f").isCameraEnhancer&&(n.includes("ddn")?Kt(this,pe,"f").setPixelFormat(l.IPF_ABGR_8888):Kt(this,pe,"f").setPixelFormat(l.IPF_GRAYSCALED)),void 0!==Kt(this,pe,"f").singleFrameMode&&"disabled"!==Kt(this,pe,"f").singleFrameMode)return this._templateName=t,void Kt(this,pe,"f").on("singleFrameAcquired",this._singleFrameModeCallbackBind);return Kt(this,pe,"f").getColourChannelUsageType()===o.CCUT_AUTO&&Kt(this,pe,"f").setColourChannelUsageType(n.includes("ddn")?o.CCUT_FULL_CHANNEL:o.CCUT_Y_CHANNEL_ONLY),Kt(this,ve,"f")&&Kt(this,ve,"f").isPending?Kt(this,ve,"f"):($t(this,ve,new ee(((e,i)=>{if(this.disposed)return;let n=nt();rt[n]=async n=>{if(Kt(this,ve,"f")&&!Kt(this,ve,"f").isFulfilled){if(!n.success){let t=new Error(n.message);return t.stack=n.stack+"\n"+t.stack,i(t)}this._isPauseScan=!1,this._isOutputOriginalImage=n.isOutputOriginalImage,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((async()=>{-1!==this._minImageCaptureInterval&&Kt(this,pe,"f").startFetching(),this._loopReadVideo(t),e()}),0)}},et.postMessage({type:"cvr_startCapturing",id:n,instanceID:this._instanceID,body:{templateName:t}})}))),await Kt(this,ve,"f"))}stopCapturing(){Oe(this),Kt(this,pe,"f")&&(Kt(this,pe,"f").isCameraEnhancer&&void 0!==Kt(this,pe,"f").singleFrameMode&&"disabled"!==Kt(this,pe,"f").singleFrameMode?Kt(this,pe,"f").off("singleFrameAcquired",this._singleFrameModeCallbackBind):(!async function(t){let e=nt();const i=new ee;rt[e]=async t=>{if(t.success)return i.resolve();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i.reject(e)}},et.postMessage({type:"cvr_clearVerifyList",id:e,instanceID:t._instanceID})}(this),Kt(this,pe,"f").stopFetching(),this._averageProcessintTimeArray=[],this._averageTime=999,this._isPauseScan=!0,$t(this,ve,null),Kt(this,pe,"f").setColourChannelUsageType(o.CCUT_AUTO)))}async containsTask(t){return Oe(this),await new Promise(((e,i)=>{let n=nt();rt[n]=async t=>{if(t.success)return e(JSON.parse(t.tasks));{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},et.postMessage({type:"cvr_containsTask",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async _loopReadVideo(t){if(this.disposed||this._isPauseScan)return;if($t(this,be,!0),Kt(this,pe,"f").isBufferEmpty())if(Kt(this,pe,"f").hasNextImageToFetch())for(let t of Kt(this,Ce,"f"))t.onImageSourceStateReceived&&t.onImageSourceStateReceived(me.ISS_BUFFER_EMPTY);else if(!Kt(this,pe,"f").hasNextImageToFetch())for(let t of Kt(this,Ce,"f"))t.onImageSourceStateReceived&&t.onImageSourceStateReceived(me.ISS_EXHAUSTED);if(-1===this._minImageCaptureInterval||Kt(this,pe,"f").isBufferEmpty())try{Kt(this,pe,"f").isBufferEmpty()&&Ae._onLog&&Ae._onLog("buffer is empty so fetch image"),Ae._onLog&&Ae._onLog(`DCE: start fetching a frame: ${Date.now()}`),this._dsImage=Kt(this,pe,"f").fetchImage(),Ae._onLog&&Ae._onLog(`DCE: finish fetching a frame: ${Date.now()}`),Kt(this,pe,"f").setImageFetchInterval(this._averageTime)}catch(e){return void this._reRunCurrnetFunc(t)}else if(Kt(this,pe,"f").setImageFetchInterval(this._averageTime-(this._dsImage&&this._dsImage.tag?this._dsImage.tag.timeSpent:0)),this._dsImage=Kt(this,pe,"f").getImage(),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 Kt(this,Ee,"f"))this._isOutputOriginalImage&&t.onOriginalImageResultReceived&&t.onOriginalImageResultReceived({imageData:this._dsImage});const e=Date.now();this._captureDsimage(this._dsImage,t).then((async i=>{if(Ae._onLog&&Ae._onLog("no js handle time: "+(Date.now()-e)),this._isPauseScan)return void this._reRunCurrnetFunc(t);i.originalImageTag=this._dsImage.tag?this._dsImage.tag:null;const n={originalImageHashId:i.originalImageHashId,originalImageTag:i.originalImageTag,errorCode:i.errorCode,errorString:i.errorString};for(let t of Kt(this,Ee,"f"))if(t.isDce){const e=Date.now();if(t.onCapturedResultReceived(i,{isDetectVerifyOpen:this._isOpenDetectVerify,isNormalizeVerifyOpen:this._isOpenNormalizeVerify,isBarcodeVerifyOpen:this._isOpenBarcodeVerify,isLabelVerifyOpen:this._isOpenLabelVerify}),Ae._onLog){const t=Date.now()-e;t>10&&Ae._onLog(`draw result time: ${t}`)}}else{for(let e in ge){const r=e,s=ge[r];t[s.reveiver],t[s.reveiver]&&i[r]&&t[s.reveiver](Object.assign(Object.assign({},n),{[r]:i[r].filter((t=>!s.isNeedFilter||!t.isFilter))})),i[r]&&(i[r]=i[r].filter((t=>!s.isNeedFilter||!t.isFilter)))}t.onCapturedResultReceived&&(i.items=i.items.filter((t=>[mt.CRIT_DETECTED_QUAD,mt.CRIT_NORMALIZED_IMAGE].includes(t.type)||!t.isFilter)),t.onCapturedResultReceived(i))}const r=Date.now();if(this._minImageCaptureInterval>-1&&(5===this._averageProcessintTimeArray.length&&this._averageProcessintTimeArray.shift(),5===this._averageFetchImageTimeArray.length&&this._averageFetchImageTimeArray.shift(),this._averageProcessintTimeArray.push(Date.now()-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,Ae._onLog&&(Ae._onLog(`minImageCaptureInterval: ${this._minImageCaptureInterval}`),Ae._onLog(`averageProcessintTimeArray: ${this._averageProcessintTimeArray}`),Ae._onLog(`averageFetchImageTimeArray: ${this._averageFetchImageTimeArray}`),Ae._onLog(`averageTime: ${this._averageTime}`))),Ae._onLog){const t=Date.now()-r;t>10&&Ae._onLog(`fetch image calculate time: ${t}`)}Ae._onLog&&Ae._onLog(`time finish decode: ${Date.now()}`),Ae._onLog&&Ae._onLog("main time: "+(Date.now()-e)),Ae._onLog&&Ae._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=>{Kt(this,pe,"f").stopFetching(),e.errorCode&&0===e.errorCode&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{Kt(this,pe,"f").startFetching(),this._loopReadVideo(t)}),Math.max(this._minImageCaptureInterval,1e3))),"platform error"!==e.message&&setTimeout((()=>{throw e}),0)}))}_reRunCurrnetFunc(t){this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo(t)}),0)}async capture(t,e){var i,n;Oe(this),e||(e=Ae._defaultTemplate);const r=await this.containsTask(e);if(await ft(r),r.includes("dlr")&&!(null===(i=ct.dlr)||void 0===i?void 0:i.bLoadConfusableCharsData)){const t=O(gt.engineResourcePaths);await(null===(n=ct.dlr)||void 0===n?void 0:n.loadRecognitionData("ConfusableChars",t.dlr))}let s;if($t(this,be,!1),y(t))s=await this._captureDsimage(t,e);else if("string"==typeof t)s="data:image/"==t.substring(0,11)?await this._captureBase64(t,e):await this._captureUrl(t,e);else if(t instanceof Blob)s=await this._captureBlob(t,e);else if(t instanceof HTMLImageElement)s=await this._captureImage(t,e);else if(t instanceof HTMLCanvasElement)s=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'.");s=await this._captureVideo(t,e)}return s}async _captureDsimage(t,e){return await this._captureInWorker(t,e)}async _captureUrl(t,e){let i=await x(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?($t(this,Te,this.maxImageSideLength/a),i=Math.round(r*Kt(this,Te,"f")),n=Math.round(s*Kt(this,Te,"f"))):(i=r,n=s),Kt(this,_e,"f")||$t(this,_e,document.createElement("canvas"));const o=Kt(this,_e,"f");o.width===i&&o.height===n||(o.width=i,o.height=n),o.ctx2d||(o.ctx2d=o.getContext("2d",{willReadFrequently:!0}));return 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:10};return await this._captureInWorker(n,e)}async _captureVideo(t,e){if(t.crossOrigin&&"anonymous"!=t.crossOrigin)throw"cors";let i,n,r=t.videoWidth,s=t.videoHeight,a=Math.max(r,s);a>this.maxImageSideLength?($t(this,Te,this.maxImageSideLength/a),i=Math.round(r*Kt(this,Te,"f")),n=Math.round(s*Kt(this,Te,"f"))):(i=r,n=s),Kt(this,_e,"f")||$t(this,_e,document.createElement("canvas"));const o=Kt(this,_e,"f");o.width===i&&o.height===n||(o.width=i,o.height=n),o.ctx2d||(o.ctx2d=o.getContext("2d",{willReadFrequently:!0}));return o.ctx2d.drawImage(t,0,0,r,s,0,0,i,n),await this._captureCanvas(o,e)}async _captureInWorker(t,e){const{bytes:i,width:n,height:r,stride:s,format:a}=t;let o=nt();const l=new ee;return rt[o]=async e=>{var i,n;if(!e.success){let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,l.reject(t)}{const r=Date.now();Ae._onLog&&(Ae._onLog(`get result time from worker: ${r}`),Ae._onLog("worker to main time consume: "+(r-e.workerReturnMsgTime)));try{const r=e.captureResult;if(0!==r.errorCode){let t=new Error(r.errorString);return t.errorCode=r.errorCode,l.reject(t)}t.bytes=e.bytes;for(let e of r.items)0!==Kt(this,Te,"f")&&Re(e,Kt(this,Te,"f")),e.type===mt.CRIT_ORIGINAL_IMAGE?e.imageData=t:e.type===mt.CRIT_NORMALIZED_IMAGE?null===(i=ct.ddn)||void 0===i||i.handleNormalizedImageResultItem(e):e.type===mt.CRIT_PARSED_RESULT&&(null===(n=ct.dcp)||void 0===n||n.handleParsedResultItem(e));if(Kt(this,be,"f"))for(let t of Kt(this,Se,"f"))t.onDecodedBarcodesReceived(r),t.onRecognizedTextLinesReceived(r),t.onDetectedQuadsReceived(r),t.onNormalizedImagesReceived(r);for(let t in ge){const e=t,i=r.items.filter((t=>t.type===ge[e].type));i.length&&(r[t]=i)}if(!this._isPauseScan||!Kt(this,be,"f")){const e=r.intermediateResult;if(e){let i=0;for(let n of Kt(this,ye,"f")._intermediateResultReceiverSet){i++;for(let r of e){if("onTaskResultsReceived"===r.info.callbackName){for(let e of r.intermediateResultUnits)e.originalImageTag=t.tag?t.tag:null;n[r.info.callbackName]&&n[r.info.callbackName]({intermediateResultUnits:r.intermediateResultUnits},r.info)}else n[r.info.callbackName]&&n[r.info.callbackName](r.result,r.info);i===Kt(this,ye,"f")._intermediateResultReceiverSet.size&&delete r.info.callbackName}}}}return r&&r.hasOwnProperty("intermediateResult")&&delete r.intermediateResult,$t(this,Te,0),l.resolve(r)}catch(t){return l.reject(t)}}},Ae._onLog&&Ae._onLog(`send buffer to worker: ${Date.now()}`),et.postMessage({type:"cvr_capture",id:o,instanceID:this._instanceID,body:{bytes:i,width:n,height:r,stride:s,format:a,templateName:e||"",isScanner:Kt(this,be,"f")}},[i.buffer]),l}async initSettings(t){return Oe(this),t&&["string","object"].includes(typeof t)?("string"==typeof t?t.trimStart().startsWith("{")||(t=await x(t,"text")):"object"==typeof t&&(t=JSON.stringify(t)),await new Promise(((e,i)=>{let n=nt();rt[n]=async n=>{if(n.success){const r=JSON.parse(n.response);if(0!==r.errorCode){let t=new Error(r.errorString?r.errorString:"Init Settings Failed.");return t.errorCode=r.errorCode,i(t)}const s=JSON.parse(t);this._currentSettings=s;let a=[],o=s.CaptureVisionTemplates;for(let t=0;t{let n=nt();rt[n]=async t=>{if(t.success){const n=JSON.parse(t.response);if(0!==n.errorCode){let t=new Error(n.errorString);return t.errorCode=n.errorCode,i(t)}return e(JSON.parse(n.data))}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},et.postMessage({type:"cvr_outputSettings",id:n,instanceID:this._instanceID,body:{templateName:t||"*"}})}))}async outputSettingsToFile(t,e,i){const n=await this.outputSettings(t),r=new Blob([JSON.stringify(n,null,2,(function(t,e){return e instanceof Array?JSON.stringify(e):e}),2)],{type:"application/json"});if(i){const t=document.createElement("a");t.href=URL.createObjectURL(r),e.endsWith(".json")&&(e=e.replace(".json","")),t.download=`${e}.json`,t.onclick=()=>{setTimeout((()=>{URL.revokeObjectURL(t.href)}),500)},t.click()}return r}async getTemplateNames(){return Oe(this),await new Promise(((t,e)=>{let i=nt();rt[i]=async i=>{if(i.success){const n=JSON.parse(i.response);if(0!==n.errorCode){let t=new Error(n.errorString);return t.errorCode=n.errorCode,e(t)}return t(JSON.parse(n.data))}{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},et.postMessage({type:"cvr_getTemplateNames",id:i,instanceID:this._instanceID})}))}async getSimplifiedSettings(t){Oe(this),t||(t=this._currentSettings.CaptureVisionTemplates[0].Name);const e=await this.containsTask(t);return await ft(e),await new Promise(((e,i)=>{let n=nt();rt[n]=async t=>{if(t.success){const n=JSON.parse(t.response);if(0!==n.errorCode){let t=new Error(n.errorString);return t.errorCode=n.errorCode,i(t)}const r=JSON.parse(n.data,((t,e)=>"barcodeFormatIds"===t?BigInt(e):e));return r.minImageCaptureInterval=this._minImageCaptureInterval,e(r)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},et.postMessage({type:"cvr_getSimplifiedSettings",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async updateSettings(t,e){Oe(this);const i=await this.containsTask(t);return await ft(i),await new Promise(((i,n)=>{let r=nt();rt[r]=async t=>{if(t.success){const r=JSON.parse(t.response);if(e.minImageCaptureInterval&&e.minImageCaptureInterval>=-1&&(this._minImageCaptureInterval=e.minImageCaptureInterval),this._isOutputOriginalImage=t.isOutputOriginalImage,0!==r.errorCode){let t=new Error(r.errorString?r.errorString:"Update Settings Failed.");return t.errorCode=r.errorCode,n(t)}return this._currentSettings=await this.outputSettings("*"),i(r)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},et.postMessage({type:"cvr_updateSettings",id:r,instanceID:this._instanceID,body:{settings:e,templateName:t}})}))}async resetSettings(){return Oe(this),await new Promise(((t,e)=>{let i=nt();rt[i]=async i=>{if(i.success){const n=JSON.parse(i.response);if(0!==n.errorCode){let t=new Error(n.errorString?n.errorString:"Reset Settings Failed.");return t.errorCode=n.errorCode,e(t)}return this._currentSettings=await this.outputSettings("*"),t(n)}{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},et.postMessage({type:"cvr_resetSettings",id:i,instanceID:this._instanceID})}))}getBufferedItemsManager(){return Kt(this,we,"f")||$t(this,we,new ie(this)),Kt(this,we,"f")}getIntermediateResultManager(){if(Oe(this),!Kt(this,Ie,"f")&&0!==gt.bSupportIRTModule)throw new Error("The current license does not support the use of intermediate results.");return Kt(this,ye,"f")||$t(this,ye,new se(this)),Kt(this,ye,"f")}async parseRequiredResources(t){return Oe(this),await new Promise(((e,i)=>{let n=nt();rt[n]=async t=>{if(t.success)return e(JSON.parse(t.resources));{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},et.postMessage({type:"cvr_parseRequiredResources",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async dispose(){Oe(this),Kt(this,ve,"f")&&this.stopCapturing(),$t(this,pe,null),Kt(this,Ee,"f").clear(),Kt(this,Ce,"f").clear(),Kt(this,Se,"f").clear(),Kt(this,ye,"f")._intermediateResultReceiverSet.clear(),$t(this,xe,!0);let t=nt();rt[t]=t=>{if(!t.success){let e=new Error(t.message);throw e.stack=t.stack+"\n"+e.stack,e}},et.postMessage({type:"cvr_dispose",id:t,instanceID:this._instanceID})}_getInternalData(){return{isa:Kt(this,pe,"f"),promiseStartScan:Kt(this,ve,"f"),intermediateResultManager:Kt(this,ye,"f"),bufferdItemsManager:Kt(this,we,"f"),resultReceiverSet:Kt(this,Ee,"f"),isaStateListenerSet:Kt(this,Ce,"f"),resultFilterSet:Kt(this,Se,"f"),compressRate:Kt(this,Te,"f"),canvas:Kt(this,_e,"f"),isScanner:Kt(this,be,"f"),innerUseTag:Kt(this,Ie,"f"),isDestroyed:Kt(this,xe,"f")}}async _getWasmFilterState(){return await new Promise(((t,e)=>{let i=nt();rt[i]=async i=>{if(i.success){const e=JSON.parse(i.response);return t(e)}{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},et.postMessage({type:"cvr_getWasmFilterState",id:i,instanceID:this._instanceID})}))}}async function Le(t,e){return Oe(t),await new Promise(((i,n)=>{let r=nt();rt[r]=async t=>{if(t.success)return i(t.result);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},et.postMessage({type:"cvr_enableResultCrossVerification",id:r,instanceID:t._instanceID,body:{verificationEnabled:e}})}))}async function Me(t,e){return Oe(t),await new Promise(((i,n)=>{let r=nt();rt[r]=async t=>{if(t.success)return i(t.result);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},et.postMessage({type:"cvr_enableResultDeduplication",id:r,instanceID:t._instanceID,body:{duplicateFilterEnabled:e}})}))}async function Fe(t,e){return Oe(t),await new Promise(((i,n)=>{let r=nt();rt[r]=async t=>{if(t.success)return i(t.result);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},et.postMessage({type:"cvr_setDuplicateForgetTime",id:r,instanceID:t._instanceID,body:{duplicateForgetTime:e}})}))}pe=new WeakMap,_e=new WeakMap,ve=new WeakMap,ye=new WeakMap,we=new WeakMap,Ee=new WeakMap,Ce=new WeakMap,Se=new WeakMap,Te=new WeakMap,be=new WeakMap,Ie=new WeakMap,xe=new WeakMap,Ae._defaultTemplate="Default";class Pe{constructor(){this.onCapturedResultReceived=null,this.onOriginalImageResultReceived=null}}var ke;!function(t){t.PT_DEFAULT="Default",t.PT_READ_BARCODES="ReadBarcodes_Default",t.PT_RECOGNIZE_TEXT_LINES="RecognizeTextLines_Default",t.PT_DETECT_DOCUMENT_BOUNDARIES="DetectDocumentBoundaries_Default",t.PT_DETECT_AND_NORMALIZE_DOCUMENT="DetectAndNormalizeDocument_Default",t.PT_NORMALIZE_DOCUMENT="NormalizeDocument_Default",t.PT_READ_BARCODES_SPEED_FIRST="ReadBarcodes_SpeedFirst",t.PT_READ_BARCODES_READ_RATE_FIRST="ReadBarcodes_ReadRateFirst",t.PT_READ_BARCODES_BALANCE="ReadBarcodes_Balance",t.PT_READ_SINGLE_BARCODE="ReadBarcodes_Balanced",t.PT_READ_DENSE_BARCODES="ReadDenseBarcodes",t.PT_READ_DISTANT_BARCODES="ReadDistantBarcodes",t.PT_RECOGNIZE_NUMBERS="RecognizeNumbers",t.PT_RECOGNIZE_LETTERS="RecognizeLetters",t.PT_RECOGNIZE_NUMBERS_AND_LETTERS="RecognizeNumbersAndLetters",t.PT_RECOGNIZE_NUMBERS_AND_UPPERCASE_LETTERS="RecognizeNumbersAndUppercaseLetters",t.PT_RECOGNIZE_UPPERCASE_LETTERS="RecognizeUppercaseLetters"}(ke||(ke={}));var Ne=Object.freeze({__proto__:null,CaptureVisionRouter:Ae,CaptureVisionRouterModule:fe,CapturedResultReceiver:Pe,get EnumImageSourceState(){return me},get EnumPresetTemplate(){return ke},IntermediateResultReceiver:class{constructor(){this._observedResultUnitTypes=Tt.IRUT_ALL,this._observedTaskMap=new Map,this._parameters={setObservedResultUnitTypes:t=>{this._observedResultUnitTypes=t},getObservedResultUnitTypes:()=>this._observedResultUnitTypes,isResultUnitTypeObserved:t=>!!(t&this._observedResultUnitTypes),addObservedTask:t=>{this._observedTaskMap.set(t,!0)},removeObservedTask:t=>{this._observedTaskMap.set(t,!1)},isTaskObserved:t=>0===this._observedTaskMap.size||!!this._observedTaskMap.get(t)},this.onTaskResultsReceived=null,this.onPredetectedRegionsReceived=null,this.onColourImageUnitReceived=null,this.onScaledDownColourImageUnitReceived=null,this.onGrayscaleImageUnitReceived=null,this.onTransformedGrayscaleImageUnitReceived=null,this.onEnhancedGrayscaleImageUnitReceived=null,this.onBinaryImageUnitReceived=null,this.onTextureDetectionResultUnitReceived=null,this.onTextureRemovedGrayscaleImageUnitReceived=null,this.onTextureRemovedBinaryImageUnitReceived=null,this.onContoursUnitReceived=null,this.onLineSegmentsUnitReceived=null,this.onTextZonesUnitReceived=null,this.onTextRemovedBinaryImageUnitReceived=null,this.onShortLinesUnitReceived=null}getObservationParameters(){return this._parameters}}});const Be="undefined"==typeof self,Ve="function"==typeof importScripts,je=(()=>{if(!Ve){if(!Be&&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"./"}})();gt.engineResourcePaths.dce={version:"4.1.1",path:je,isInternal:!0},ut.dce={wasm:!1,js:!1},ct.dce={};let Ue,Ge,We,Ye,ze;function He(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 Xe(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 r?r.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError,"undefined"!=typeof navigator&&(Ue=navigator,Ge=Ue.userAgent,We=Ue.platform,Ye=Ue.mediaDevices),function(){if(!Be){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:Ue.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:We,search:"Win"},Mac:{str:We},Linux:{str:We}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||Ge,a=r.search||e,o=r.verStr||Ge,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||Ge,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=Ge.indexOf("Windows NT")&&(r="HarmonyOS"),ze={browser:i,version:n,OS:r}}Be&&(ze={browser:"ssr",version:0,OS:"ssr"})}();const Ze="undefined"!=typeof WebAssembly&&Ge&&!(/Safari/.test(Ge)&&!/Chrome/.test(Ge)&&/\(.+\s11_2_([2-6]).*\)/.test(Ge)),qe=!("undefined"==typeof Worker),Je=!(!Ye||!Ye.getUserMedia),Ke=async()=>{let t=!1;if(Je)try{(await Ye.getUserMedia({video:!0})).getTracks().forEach((t=>{t.stop()})),t=!0}catch(t){}return t};"Chrome"===ze.browser&&ze.version>66||"Safari"===ze.browser&&ze.version>13||"OPR"===ze.browser&&ze.version>43||"Edge"===ze.browser&&ze.version;var $e={653:(t,e,i)=>{var n,r,s,a,o,l,h,c,u,d,f,g,m,p,_,v,y,w,E,C,S,T=T||{version:"5.2.1"};if(e.fabric=T,"undefined"!=typeof document&&"undefined"!=typeof window)document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?T.document=document:T.document=document.implementation.createHTMLDocument(""),T.window=window;else{var b=new(i(192).JSDOM)(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;T.document=b.document,T.jsdomImplForWrapper=i(898).implForWrapper,T.nodeCanvas=i(245).Canvas,T.window=b,DOMParser=T.window.DOMParser}function I(t,e){var i=t.canvas,n=e.targetCanvas,r=n.getContext("2d");r.translate(0,n.height),r.scale(1,-1);var s=i.height-n.height;r.drawImage(i,0,s,n.width,n.height,0,0,n.width,n.height)}function x(t,e){var i=e.targetCanvas.getContext("2d"),n=e.destinationWidth,r=e.destinationHeight,s=n*r*4,a=new Uint8Array(this.imageBuffer,0,s),o=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,n,r,t.RGBA,t.UNSIGNED_BYTE,a);var l=new ImageData(o,n,r);i.putImageData(l,0,0)}T.isTouchSupported="ontouchstart"in T.window||"ontouchstart"in T.document||T.window&&T.window.navigator&&T.window.navigator.maxTouchPoints>0,T.isLikelyNode="undefined"!=typeof Buffer&&"undefined"==typeof window,T.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],T.DPI=96,T.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",T.commaWsp="(?:\\s+,?\\s*|,\\s*)",T.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,T.reNonWord=/[ \n\.,;!\?\-]/,T.fontPaths={},T.iMatrix=[1,0,0,1,0,0],T.svgNS="http://www.w3.org/2000/svg",T.perfLimitSizeTotal=2097152,T.maxCacheSideLimit=4096,T.minCacheSideLimit=256,T.charWidthsCache={},T.textureSize=2048,T.disableStyleCopyPaste=!1,T.enableGLFiltering=!0,T.devicePixelRatio=T.window.devicePixelRatio||T.window.webkitDevicePixelRatio||T.window.mozDevicePixelRatio||1,T.browserShadowBlurConstant=1,T.arcToSegmentsCache={},T.boundsOfCurveCache={},T.cachesBoundsOfCurve=!0,T.forceGLPutImageData=!1,T.initFilterBackend=function(){return T.enableGLFiltering&&T.isWebglSupported&&T.isWebglSupported(T.textureSize)?(console.log("max texture size: "+T.maxTextureSize),new T.WebglFilterBackend({tileSize:T.textureSize})):T.Canvas2dFilterBackend?new T.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=T),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:T.util.array.fill(i,!1)}}function e(t,e){var i=function(){e.apply(this,arguments),this.off(t,i)}.bind(this);this.on(t,i)}T.Observable={fire:function(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;for(var n=0,r=i.length;n-1||!!e&&this._objects.some((function(e){return"function"==typeof e.contains&&e.contains(t,!0)}))},complexity:function(){return this._objects.reduce((function(t,e){return t+(e.complexity?e.complexity():0)}),0)}},T.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof T.Gradient||this.set(e,new T.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof T.Pattern?i&&i():this.set(e,new T.Pattern(t,i))},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},n=e,r=Math.sqrt,s=Math.atan2,a=Math.pow,o=Math.PI/180,l=Math.PI/2,T.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/l){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},sin:function(t){if(0===t)return 0;var e=1;switch(t<0&&(e=-1),t/l){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)},removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*o},radiansToDegrees:function(t){return t/o},rotatePoint:function(t,e,i){var n=new T.Point(t.x-e.x,t.y-e.y),r=T.util.rotateVector(n,i);return new T.Point(r.x,r.y).addEquals(e)},rotateVector:function(t,e){var i=T.util.sin(e),n=T.util.cos(e);return{x:t.x*n-t.y*i,y:t.x*i+t.y*n}},createVector:function(t,e){return new T.Point(e.x-t.x,e.y-t.y)},calcAngleBetweenVectors:function(t,e){return Math.acos((t.x*e.x+t.y*e.y)/(Math.hypot(t.x,t.y)*Math.hypot(e.x,e.y)))},getHatVector:function(t){return new T.Point(t.x,t.y).multiply(1/Math.hypot(t.x,t.y))},getBisector:function(t,e,i){var n=T.util.createVector(t,e),r=T.util.createVector(t,i),s=T.util.calcAngleBetweenVectors(n,r),a=s*(0===T.util.calcAngleBetweenVectors(T.util.rotateVector(n,s),r)?1:-1)/2;return{vector:T.util.getHatVector(T.util.rotateVector(n,a)),angle:s}},projectStrokeOnPoints:function(t,e,i){var n=[],r=e.strokeWidth/2,s=e.strokeUniform?new T.Point(1/e.scaleX,1/e.scaleY):new T.Point(1,1),a=function(t){var e=r/Math.hypot(t.x,t.y);return new T.Point(t.x*e*s.x,t.y*e*s.y)};return t.length<=1||t.forEach((function(o,l){var h,c,u=new T.Point(o.x,o.y);0===l?(c=t[l+1],h=i?a(T.util.createVector(c,u)).addEquals(u):t[t.length-1]):l===t.length-1?(h=t[l-1],c=i?a(T.util.createVector(h,u)).addEquals(u):t[0]):(h=t[l-1],c=t[l+1]);var d,f,g=T.util.getBisector(u,h,c),m=g.vector,p=g.angle;if("miter"===e.strokeLineJoin&&(d=-r/Math.sin(p/2),f=new T.Point(m.x*d*s.x,m.y*d*s.y),Math.hypot(f.x,f.y)/r<=e.strokeMiterLimit))return n.push(u.add(f)),void n.push(u.subtract(f));d=-r*Math.SQRT2,f=new T.Point(m.x*d*s.x,m.y*d*s.y),n.push(u.add(f)),n.push(u.subtract(f))})),n},transformPoint:function(t,e,i){return i?new T.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new T.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t,e){if(e)for(var i=0;i0&&(e>n?e-=n:e=0,i>n?i-=n:i=0);var r,s=!0,a=t.getImageData(e,i,2*n||1,2*n||1),o=a.data.length;for(r=3;r=r?s-r:2*Math.PI-(r-s)}function s(t,e,i){for(var s=i[1],a=i[2],o=i[3],l=i[4],h=i[5],c=function(t,e,i,s,a,o,l){var h=Math.PI,c=l*h/180,u=T.util.sin(c),d=T.util.cos(c),f=0,g=0,m=-d*t*.5-u*e*.5,p=-d*e*.5+u*t*.5,_=(i=Math.abs(i))*i,v=(s=Math.abs(s))*s,y=p*p,w=m*m,E=_*v-_*y-v*w,C=0;if(E<0){var S=Math.sqrt(1-E/(_*v));i*=S,s*=S}else C=(a===o?-1:1)*Math.sqrt(E/(_*y+v*w));var b=C*i*p/s,I=-C*s*m/i,x=d*b-u*I+.5*t,R=u*b+d*I+.5*e,O=r(1,0,(m-b)/i,(p-I)/s),D=r((m-b)/i,(p-I)/s,(-m-b)/i,(-p-I)/s);0===o&&D>0?D-=2*h:1===o&&D<0&&(D+=2*h);for(var A=Math.ceil(Math.abs(D/h*2)),L=[],M=D/A,F=8/3*Math.sin(M/4)*Math.sin(M/4)/Math.sin(M/2),P=O+M,k=0;kC)for(var b=1,I=m.length;b2;for(e=e||0,h&&(o=t[2].xt[i-2].x?1:r.x===t[i-2].x?0:-1,l=r.y>t[i-2].y?1:r.y===t[i-2].y?0:-1),n.push(["L",r.x+o*e,r.y+l*e]),n},T.util.getPathSegmentsInfo=d,T.util.getBoundsOfCurve=function(e,i,n,r,s,a,o,l){var h;if(T.cachesBoundsOfCurve&&(h=t.call(arguments),T.boundsOfCurveCache[h]))return T.boundsOfCurveCache[h];var c,u,d,f,g,m,p,_,v=Math.sqrt,y=Math.min,w=Math.max,E=Math.abs,C=[],S=[[],[]];u=6*e-12*n+6*s,c=-3*e+9*n-9*s+3*o,d=3*n-3*e;for(var b=0;b<2;++b)if(b>0&&(u=6*i-12*r+6*a,c=-3*i+9*r-9*a+3*l,d=3*r-3*i),E(c)<1e-12){if(E(u)<1e-12)continue;0<(f=-d/u)&&f<1&&C.push(f)}else(p=u*u-4*d*c)<0||(0<(g=(-u+(_=v(p)))/(2*c))&&g<1&&C.push(g),0<(m=(-u-_)/(2*c))&&m<1&&C.push(m));for(var I,x,R,O=C.length,D=O;O--;)I=(R=1-(f=C[O]))*R*R*e+3*R*R*f*n+3*R*f*f*s+f*f*f*o,S[0][O]=I,x=R*R*R*i+3*R*R*f*r+3*R*f*f*a+f*f*f*l,S[1][O]=x;S[0][D]=e,S[1][D]=i,S[0][D+1]=o,S[1][D+1]=l;var A=[{x:y.apply(null,S[0]),y:y.apply(null,S[1])},{x:w.apply(null,S[0]),y:w.apply(null,S[1])}];return T.cachesBoundsOfCurve&&(T.boundsOfCurveCache[h]=A),A},T.util.getPointOnPath=function(t,e,i){i||(i=d(t));for(var n=0;e-i[n].length>0&&n1e-4;)i=l(s),r=s,(n=a(h.x,h.y,i.x,i.y))+o>e?(s-=c,c/=2):(h=i,s+=c,o+=n);return i.angle=u(r),i}(s,e)}},T.util.transformPath=function(t,e,i){return i&&(e=T.util.multiplyTransformMatrices(e,[1,0,0,1,-i.x,-i.y])),t.map((function(t){for(var i=t.slice(0),n={},r=1;r=e}))}}}(),function(){function t(e,i,n){if(n)if(!T.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var r=0,s=i.length;r57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var n=t.charCodeAt(e+1);if(56320>n||n>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";var r=t.charCodeAt(e-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1}T.util.string={camelize:function(t){return t.replace(/-+(.)?/g,(function(t,e){return e?e.toUpperCase():""}))},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")},graphemeSplit:function(e){var i,n=0,r=[];for(n=0;n-1?t.prototype[r]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=n;var r=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return r}}(r):t.prototype[r]=e[r],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function r(){}function s(e){for(var i=null,n=this;n.constructor.superclass;){var r=n.constructor.superclass.prototype[e];if(n[e]!==r){i=r;break}n=n.constructor.superclass.prototype}return i?arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this):console.log("tried to callSuper "+e+", method not found in prototype chain",this)}T.util.createClass=function(){var i=null,a=t.call(arguments,0);function o(){this.initialize.apply(this,arguments)}"function"==typeof a[0]&&(i=a.shift()),o.superclass=i,o.subclasses=[],i&&(r.prototype=i.prototype,o.prototype=new r,i.subclasses.push(o));for(var l=0,h=a.length;l-1||"touch"===t.pointerType},d="string"==typeof(u=T.document.createElement("div")).style.opacity,f="string"==typeof u.style.filter,g=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,m=function(t){return t},d?m=function(t,e){return t.style.opacity=e,t}:f&&(m=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),g.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(g,e)):i.filter+=" alpha(opacity="+100*e+")",t}),T.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?m(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var n in e)"opacity"===n?m(t,e[n]):i["float"===n||"cssFloat"===n?void 0===i.styleFloat?"cssFloat":"styleFloat":n]=e[n];return t},function(){var t,e,i,n,r=Array.prototype.slice,s=function(t){return r.call(t,0)};try{t=s(T.document.childNodes)instanceof Array}catch(t){}function a(t,e){var i=T.document.createElement(t);for(var n in e)"class"===n?i.className=e[n]:"for"===n?i.htmlFor=e[n]:i.setAttribute(n,e[n]);return i}function o(t){for(var e=0,i=0,n=T.document.documentElement,r=T.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===T.document?(e=r.scrollLeft||n.scrollLeft||0,i=r.scrollTop||n.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}t||(s=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),e=T.document.defaultView&&T.document.defaultView.getComputedStyle?function(t,e){var i=T.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},i=T.document.documentElement.style,n="userSelect"in i?"userSelect":"MozUserSelect"in i?"MozUserSelect":"WebkitUserSelect"in i?"WebkitUserSelect":"KhtmlUserSelect"in i?"KhtmlUserSelect":"",T.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=T.util.falseFunction),n?t.style[n]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},T.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),n?t.style[n]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},T.util.setImageSmoothing=function(t,e){t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled,t.imageSmoothingEnabled=e},T.util.getById=function(t){return"string"==typeof t?T.document.getElementById(t):t},T.util.toArray=s,T.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},T.util.makeElement=a,T.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=a(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},T.util.getScrollLeftTop=o,T.util.getElementOffset=function(t){var i,n,r=t&&t.ownerDocument,s={left:0,top:0},a={left:0,top:0},l={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return a;for(var h in l)a[l[h]]+=parseInt(e(t,h),10)||0;return i=r.documentElement,void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect()),n=o(t),{left:s.left+n.left-(i.clientLeft||0)+a.left,top:s.top+n.top-(i.clientTop||0)+a.top}},T.util.getNodeCanvas=function(t){var e=T.jsdomImplForWrapper(t);return e._canvas||e._image},T.util.cleanUpJsdomNode=function(t){if(T.isLikelyNode){var e=T.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}T.util.request=function(e,i){i||(i={});var n=i.method?i.method.toUpperCase():"GET",r=i.onComplete||function(){},s=new T.window.XMLHttpRequest,a=i.body||i.parameters;return s.onreadystatechange=function(){4===s.readyState&&(r(s),s.onreadystatechange=t)},"GET"===n&&(a=null,"string"==typeof i.parameters&&(e=function(t,e){return t+(/\?/.test(t)?"&":"?")+e}(e,i.parameters))),s.open(n,e,!0),"POST"!==n&&"PUT"!==n||s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(a),s}}(),T.log=console.log,T.warn=console.warn,function(){var t=T.util.object.extend,e=T.util.object.clone,i=[];function n(){return!1}function r(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e}T.util.object.extend(i,{cancelAll:function(){var t=this.splice(0);return t.forEach((function(t){t.cancel()})),t},cancelByCanvas:function(t){if(!t)return[];var e=this.filter((function(e){return"object"==typeof e.target&&e.target.canvas===t}));return e.forEach((function(t){t.cancel()})),e},cancelByTarget:function(t){var e=this.findAnimationsByTarget(t);return e.forEach((function(t){t.cancel()})),e},findAnimationIndex:function(t){return this.indexOf(this.findAnimation(t))},findAnimation:function(t){return this.find((function(e){return e.cancel===t}))},findAnimationsByTarget:function(t){return t?this.filter((function(e){return e.target===t})):[]}});var s=T.window.requestAnimationFrame||T.window.webkitRequestAnimationFrame||T.window.mozRequestAnimationFrame||T.window.oRequestAnimationFrame||T.window.msRequestAnimationFrame||function(t){return T.window.setTimeout(t,1e3/60)},a=T.window.cancelAnimationFrame||T.window.clearTimeout;function o(){return s.apply(T.window,arguments)}T.util.animate=function(i){i||(i={});var s,a=!1,l=function(){var t=T.runningAnimations.indexOf(s);return t>-1&&T.runningAnimations.splice(t,1)[0]};return s=t(e(i),{cancel:function(){return a=!0,l()},currentValue:"startValue"in i?i.startValue:0,completionRate:0,durationRate:0}),T.runningAnimations.push(s),o((function(t){var e,h=t||+new Date,c=i.duration||500,u=h+c,d=i.onChange||n,f=i.abort||n,g=i.onComplete||n,m=i.easing||r,p="startValue"in i&&i.startValue.length>0,_="startValue"in i?i.startValue:0,v="endValue"in i?i.endValue:100,y=i.byValue||(p?_.map((function(t,e){return v[e]-_[e]})):v-_);i.onStart&&i.onStart(),function t(i){var n=(e=i||+new Date)>u?c:e-h,r=n/c,w=p?_.map((function(t,e){return m(n,_[e],y[e],c)})):m(n,_,y,c),E=p?Math.abs((w[0]-_[0])/y[0]):Math.abs((w-_)/y);if(s.currentValue=p?w.slice():w,s.completionRate=E,s.durationRate=r,!a){if(!f(w,E,r))return e>u?(s.currentValue=p?v.slice():v,s.completionRate=1,s.durationRate=1,d(p?v.slice():v,1,1),g(v,1,1),void l()):(d(w,E,r),void o(t));l()}}(h)})),s.cancel},T.util.requestAnimFrame=o,T.util.cancelAnimFrame=function(){return a.apply(T.window,arguments)},T.runningAnimations=i}(),function(){function t(t,e,i){var n="rgba("+parseInt(t[0]+i*(e[0]-t[0]),10)+","+parseInt(t[1]+i*(e[1]-t[1]),10)+","+parseInt(t[2]+i*(e[2]-t[2]),10);return(n+=","+(t&&e?parseFloat(t[3]+i*(e[3]-t[3])):1))+")"}T.util.animateColor=function(e,i,n,r){var s=new T.Color(e).getSource(),a=new T.Color(i).getSource(),o=r.onComplete,l=r.onChange;return r=r||{},T.util.animate(T.util.object.extend(r,{duration:n||500,startValue:s,endValue:a,byValue:a,easing:function(e,i,n,s){return t(i,n,r.colorEasing?r.colorEasing(e,s):1-Math.cos(e/s*(Math.PI/2)))},onComplete:function(e,i,n){if(o)return o(t(a,a,0),i,n)},onChange:function(e,i,n){if(l){if(Array.isArray(e))return l(t(e,e,0),i,n);l(e,i,n)}}}))}}(),function(){function t(t,e,i,n){return t-1&&c>-1&&c-1)&&(i="stroke")}else{if("href"===t||"xlink:href"===t||"font"===t)return i;if("imageSmoothing"===t)return"optimizeQuality"===i;o=l?i.map(s):s(i,r)}}else i="";return!l&&isNaN(o)?i:o}function f(t){return new RegExp("^("+t.join("|")+")\\b","i")}function g(t,e){var i,n,r,s,a=[];for(r=0,s=e.length;r1;)l.shift(),h=e.util.multiplyTransformMatrices(h,l[0]);return h}}();var v=new RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function y(t){if(!e.svgViewBoxElementsRegEx.test(t.nodeName))return{};var i,n,r,a,o,l,h=t.getAttribute("viewBox"),c=1,u=1,d=t.getAttribute("width"),f=t.getAttribute("height"),g=t.getAttribute("x")||0,m=t.getAttribute("y")||0,p=t.getAttribute("preserveAspectRatio")||"",_=!h||!(h=h.match(v)),y=!d||!f||"100%"===d||"100%"===f,w=_&&y,E={},C="",S=0,T=0;if(E.width=0,E.height=0,E.toBeParsed=w,_&&(g||m)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(C=" translate("+s(g)+" "+s(m)+") ",o=(t.getAttribute("transform")||"")+C,t.setAttribute("transform",o),t.removeAttribute("x"),t.removeAttribute("y")),w)return E;if(_)return E.width=s(d),E.height=s(f),E;if(i=-parseFloat(h[1]),n=-parseFloat(h[2]),r=parseFloat(h[3]),a=parseFloat(h[4]),E.minX=i,E.minY=n,E.viewBoxWidth=r,E.viewBoxHeight=a,y?(E.width=r,E.height=a):(E.width=s(d),E.height=s(f),c=E.width/r,u=E.height/a),"none"!==(p=e.util.parsePreserveAspectRatioAttribute(p)).alignX&&("meet"===p.meetOrSlice&&(u=c=c>u?u:c),"slice"===p.meetOrSlice&&(u=c=c>u?c:u),S=E.width-r*c,T=E.height-a*c,"Mid"===p.alignX&&(S/=2),"Mid"===p.alignY&&(T/=2),"Min"===p.alignX&&(S=0),"Min"===p.alignY&&(T=0)),1===c&&1===u&&0===i&&0===n&&0===g&&0===m)return E;if((g||m)&&"#document"!==t.parentNode.nodeName&&(C=" translate("+s(g)+" "+s(m)+") "),o=C+" matrix("+c+" 0 0 "+u+" "+(i*c+S)+" "+(n*u+T)+") ","svg"===t.nodeName){for(l=t.ownerDocument.createElementNS(e.svgNS,"g");t.firstChild;)l.appendChild(t.firstChild);t.appendChild(l)}else(l=t).removeAttribute("x"),l.removeAttribute("y"),o=l.getAttribute("transform")+o;return l.setAttribute("transform",o),E}function w(t,e){var i="xlink:href",n=_(t,e.getAttribute(i).slice(1));if(n&&n.getAttribute(i)&&w(t,n),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach((function(t){n&&!e.hasAttribute(t)&&n.hasAttribute(t)&&e.setAttribute(t,n.getAttribute(t))})),!e.children.length)for(var r=n.cloneNode(!0);r.firstChild;)e.appendChild(r.firstChild);e.removeAttribute(i)}e.parseSVGDocument=function(t,i,r,s){if(t){!function(t){for(var i=g(t,["use","svg:use"]),n=0;i.length&&nt.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return void 0===e&&(e=.5),e=Math.max(Math.min(1,e),0),new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new i(this.x,this.y)}})}(e),function(t){var e=t.fabric||(t.fabric={});function i(t){this.status=t,this.points=[]}e.Intersection?e.warn("fabric.Intersection is already defined"):(e.Intersection=i,e.Intersection.prototype={constructor:i,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},e.Intersection.intersectLineLine=function(t,n,r,s){var a,o=(s.x-r.x)*(t.y-r.y)-(s.y-r.y)*(t.x-r.x),l=(n.x-t.x)*(t.y-r.y)-(n.y-t.y)*(t.x-r.x),h=(s.y-r.y)*(n.x-t.x)-(s.x-r.x)*(n.y-t.y);if(0!==h){var c=o/h,u=l/h;0<=c&&c<=1&&0<=u&&u<=1?(a=new i("Intersection")).appendPoint(new e.Point(t.x+c*(n.x-t.x),t.y+c*(n.y-t.y))):a=new i}else a=new i(0===o||0===l?"Coincident":"Parallel");return a},e.Intersection.intersectLinePolygon=function(t,e,n){var r,s,a,o,l=new i,h=n.length;for(o=0;o0&&(l.status="Intersection"),l},e.Intersection.intersectPolygonPolygon=function(t,e){var n,r=new i,s=t.length;for(n=0;n0&&(r.status="Intersection"),r},e.Intersection.intersectPolygonRectangle=function(t,n,r){var s=n.min(r),a=n.max(r),o=new e.Point(a.x,s.y),l=new e.Point(s.x,a.y),h=i.intersectLinePolygon(s,o,t),c=i.intersectLinePolygon(o,a,t),u=i.intersectLinePolygon(a,l,t),d=i.intersectLinePolygon(l,s,t),f=new i;return f.appendPoints(h.points),f.appendPoints(c.points),f.appendPoints(u.points),f.appendPoints(d.points),f.points.length>0&&(f.status="Intersection"),f})}(e),function(t){var e=t.fabric||(t.fabric={});function i(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function n(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}e.Color?e.warn("fabric.Color is already defined."):(e.Color=i,e.Color.prototype={_tryParsingColor:function(t){var e;t in i.colorNameMap&&(t=i.colorNameMap[t]),"transparent"===t&&(e=[255,255,255,0]),e||(e=i.sourceFromHex(t)),e||(e=i.sourceFromRgb(t)),e||(e=i.sourceFromHsl(t)),e||(e=[0,0,0,1]),e&&this.setSource(e)},_rgbToHsl:function(t,i,n){t/=255,i/=255,n/=255;var r,s,a,o=e.util.array.max([t,i,n]),l=e.util.array.min([t,i,n]);if(a=(o+l)/2,o===l)r=s=0;else{var h=o-l;switch(s=a>.5?h/(2-o-l):h/(o+l),o){case t:r=(i-n)/h+(i0)-(t<0)||+t};function f(t,e){var i=t.angle+u(Math.atan2(e.y,e.x))+360;return Math.round(i%360/45)}function g(t,i){var n=i.transform.target,r=n.canvas,s=e.util.object.clone(i);s.target=n,r&&r.fire("object:"+t,s),n.fire(t,i)}function m(t,e){var i=e.canvas,n=t[i.uniScaleKey];return i.uniformScaling&&!n||!i.uniformScaling&&n}function p(t){return t.originX===h&&t.originY===h}function _(t,e,i){var n=t.lockScalingX,r=t.lockScalingY;return!((!n||!r)&&(e||!n&&!r||!i)&&(!n||"x"!==e)&&(!r||"y"!==e))}function v(t,e,i,n){return{e:t,transform:e,pointer:{x:i,y:n}}}function y(t){return function(e,i,n,r){var s=i.target,a=s.getCenterPoint(),o=s.translateToOriginPoint(a,i.originX,i.originY),l=t(e,i,n,r);return s.setPositionByOrigin(o,i.originX,i.originY),l}}function w(t,e){return function(i,n,r,s){var a=e(i,n,r,s);return a&&g(t,v(i,n,r,s)),a}}function E(t,i,n,r,s){var a=t.target,o=a.controls[t.corner],l=a.canvas.getZoom(),h=a.padding/l,c=a.toLocalPoint(new e.Point(r,s),i,n);return c.x>=h&&(c.x-=h),c.x<=-h&&(c.x+=h),c.y>=h&&(c.y-=h),c.y<=h&&(c.y+=h),c.x-=o.offsetX,c.y-=o.offsetY,c}function C(t){return t.flipX!==t.flipY}function S(t,e,i,n,r){if(0!==t[e]){var s=r/t._getTransformedDimensions()[n]*t[i];t.set(i,s)}}function T(t,e,i,n){var r,h=e.target,c=h._getTransformedDimensions(0,h.skewY),d=E(e,e.originX,e.originY,i,n),f=Math.abs(2*d.x)-c.x,g=h.skewX;f<2?r=0:(r=u(Math.atan2(f/h.scaleX,c.y/h.scaleY)),e.originX===s&&e.originY===l&&(r=-r),e.originX===o&&e.originY===a&&(r=-r),C(h)&&(r=-r));var m=g!==r;if(m){var p=h._getTransformedDimensions().y;h.set("skewX",r),S(h,"skewY","scaleY","y",p)}return m}function b(t,e,i,n){var r,h=e.target,c=h._getTransformedDimensions(h.skewX,0),d=E(e,e.originX,e.originY,i,n),f=Math.abs(2*d.y)-c.y,g=h.skewY;f<2?r=0:(r=u(Math.atan2(f/h.scaleY,c.x/h.scaleX)),e.originX===s&&e.originY===l&&(r=-r),e.originX===o&&e.originY===a&&(r=-r),C(h)&&(r=-r));var m=g!==r;if(m){var p=h._getTransformedDimensions().x;h.set("skewY",r),S(h,"skewX","scaleX","x",p)}return m}function I(t,e,i,n,r){r=r||{};var s,a,o,l,h,u,f=e.target,g=f.lockScalingX,v=f.lockScalingY,y=r.by,w=m(t,f),C=_(f,y,w),S=e.gestureScale;if(C)return!1;if(S)a=e.scaleX*S,o=e.scaleY*S;else{if(s=E(e,e.originX,e.originY,i,n),h="y"!==y?d(s.x):1,u="x"!==y?d(s.y):1,e.signX||(e.signX=h),e.signY||(e.signY=u),f.lockScalingFlip&&(e.signX!==h||e.signY!==u))return!1;if(l=f._getTransformedDimensions(),w&&!y){var T=Math.abs(s.x)+Math.abs(s.y),b=e.original,I=T/(Math.abs(l.x*b.scaleX/f.scaleX)+Math.abs(l.y*b.scaleY/f.scaleY));a=b.scaleX*I,o=b.scaleY*I}else a=Math.abs(s.x*f.scaleX/l.x),o=Math.abs(s.y*f.scaleY/l.y);p(e)&&(a*=2,o*=2),e.signX!==h&&"y"!==y&&(e.originX=c[e.originX],a*=-1,e.signX=h),e.signY!==u&&"x"!==y&&(e.originY=c[e.originY],o*=-1,e.signY=u)}var x=f.scaleX,R=f.scaleY;return y?("x"===y&&f.set("scaleX",a),"y"===y&&f.set("scaleY",o)):(!g&&f.set("scaleX",a),!v&&f.set("scaleY",o)),x!==f.scaleX||R!==f.scaleY}r.scaleCursorStyleHandler=function(t,e,n){var r=m(t,n),s="";if(0!==e.x&&0===e.y?s="x":0===e.x&&0!==e.y&&(s="y"),_(n,s,r))return"not-allowed";var a=f(n,e);return i[a]+"-resize"},r.skewCursorStyleHandler=function(t,e,i){var r="not-allowed";if(0!==e.x&&i.lockSkewingY)return r;if(0!==e.y&&i.lockSkewingX)return r;var s=f(i,e)%4;return n[s]+"-resize"},r.scaleSkewCursorStyleHandler=function(t,e,i){return t[i.canvas.altActionKey]?r.skewCursorStyleHandler(t,e,i):r.scaleCursorStyleHandler(t,e,i)},r.rotationWithSnapping=w("rotating",y((function(t,e,i,n){var r=e,s=r.target,a=s.translateToOriginPoint(s.getCenterPoint(),r.originX,r.originY);if(s.lockRotation)return!1;var o,l=Math.atan2(r.ey-a.y,r.ex-a.x),h=Math.atan2(n-a.y,i-a.x),c=u(h-l+r.theta);if(s.snapAngle>0){var d=s.snapAngle,f=s.snapThreshold||d,g=Math.ceil(c/d)*d,m=Math.floor(c/d)*d;Math.abs(c-m)0?s:o:(c>0&&(r=u===a?s:o),c<0&&(r=u===a?o:s),C(l)&&(r=r===s?o:s)),e.originX=r,w("skewing",y(T))(t,e,i,n))},r.skewHandlerY=function(t,e,i,n){var r,o=e.target,c=o.skewY,u=e.originX;return!o.lockSkewingY&&(0===c?r=E(e,h,h,i,n).y>0?a:l:(c>0&&(r=u===s?a:l),c<0&&(r=u===s?l:a),C(o)&&(r=r===a?l:a)),e.originY=r,w("skewing",y(b))(t,e,i,n))},r.dragHandler=function(t,e,i,n){var r=e.target,s=i-e.offsetX,a=n-e.offsetY,o=!r.get("lockMovementX")&&r.left!==s,l=!r.get("lockMovementY")&&r.top!==a;return o&&r.set("left",s),l&&r.set("top",a),(o||l)&&g("moving",v(t,e,i,n)),o||l},r.scaleOrSkewActionName=function(t,e,i){var n=t[i.canvas.altActionKey];return 0===e.x?n?"skewX":"scaleY":0===e.y?n?"skewY":"scaleX":void 0},r.rotationStyleHandler=function(t,e,i){return i.lockRotation?"not-allowed":e.cursorStyle},r.fireEvent=g,r.wrapWithFixedAnchor=y,r.wrapWithFireEvent=w,r.getLocalPoint=E,e.controlsUtils=r}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians,n=e.controlsUtils;n.renderCircleControl=function(t,e,i,n,r){n=n||{};var s,a=this.sizeX||n.cornerSize||r.cornerSize,o=this.sizeY||n.cornerSize||r.cornerSize,l=void 0!==n.transparentCorners?n.transparentCorners:r.transparentCorners,h=l?"stroke":"fill",c=!l&&(n.cornerStrokeColor||r.cornerStrokeColor),u=e,d=i;t.save(),t.fillStyle=n.cornerColor||r.cornerColor,t.strokeStyle=n.cornerStrokeColor||r.cornerStrokeColor,a>o?(s=a,t.scale(1,o/a),d=i*a/o):o>a?(s=o,t.scale(a/o,1),u=e*o/a):s=a,t.lineWidth=1,t.beginPath(),t.arc(u,d,s/2,0,2*Math.PI,!1),t[h](),c&&t.stroke(),t.restore()},n.renderSquareControl=function(t,e,n,r,s){r=r||{};var a=this.sizeX||r.cornerSize||s.cornerSize,o=this.sizeY||r.cornerSize||s.cornerSize,l=void 0!==r.transparentCorners?r.transparentCorners:s.transparentCorners,h=l?"stroke":"fill",c=!l&&(r.cornerStrokeColor||s.cornerStrokeColor),u=a/2,d=o/2;t.save(),t.fillStyle=r.cornerColor||s.cornerColor,t.strokeStyle=r.cornerStrokeColor||s.cornerStrokeColor,t.lineWidth=1,t.translate(e,n),t.rotate(i(s.angle)),t[h+"Rect"](-u,-d,a,o),c&&t.strokeRect(-u,-d,a,o),t.restore()}}(e),function(t){var e=t.fabric||(t.fabric={});e.Control=function(t){for(var e in t)this[e]=t[e]},e.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(t,e){return e.cursorStyle},getActionName:function(t,e){return e.actionName},getVisibility:function(t,e){var i=t._controlsVisibility;return i&&void 0!==i[e]?i[e]:this.visible},setVisibility:function(t){this.visible=t},positionHandler:function(t,i){return e.util.transformPoint({x:this.x*t.x+this.offsetX,y:this.y*t.y+this.offsetY},i)},calcCornerCoords:function(t,i,n,r,s){var a,o,l,h,c=s?this.touchSizeX:this.sizeX,u=s?this.touchSizeY:this.sizeY;if(c&&u&&c!==u){var d=Math.atan2(u,c),f=Math.sqrt(c*c+u*u)/2,g=d-e.util.degreesToRadians(t),m=Math.PI/2-d-e.util.degreesToRadians(t);a=f*e.util.cos(g),o=f*e.util.sin(g),l=f*e.util.cos(m),h=f*e.util.sin(m)}else f=.7071067812*(c&&u?c:i),g=e.util.degreesToRadians(45-t),a=l=f*e.util.cos(g),o=h=f*e.util.sin(g);return{tl:{x:n-h,y:r-l},tr:{x:n+a,y:r-o},bl:{x:n-a,y:r+o},br:{x:n+h,y:r+l}}},render:function(t,i,n,r,s){"circle"===((r=r||{}).cornerStyle||s.cornerStyle)?e.controlsUtils.renderCircleControl.call(this,t,i,n,r,s):e.controlsUtils.renderSquareControl.call(this,t,i,n,r,s)}}}(e),function(){function t(t,e){var i,n,r,s,a=t.getAttribute("style"),o=t.getAttribute("offset")||0;if(o=(o=parseFloat(o)/(/%$/.test(o)?100:1))<0?0:o>1?1:o,a){var l=a.split(/\s*;\s*/);for(""===l[l.length-1]&&l.pop(),s=l.length;s--;){var h=l[s].split(/\s*:\s*/),c=h[0].trim(),u=h[1].trim();"stop-color"===c?i=u:"stop-opacity"===c&&(r=u)}}return i||(i=t.getAttribute("stop-color")||"rgb(0,0,0)"),r||(r=t.getAttribute("stop-opacity")),n=(i=new T.Color(i)).getAlpha(),r=isNaN(parseFloat(r))?1:parseFloat(r),r*=n*e,{offset:o,color:i.toRgb(),opacity:r}}var e=T.util.object.clone;T.Gradient=T.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(t){t||(t={}),t.coords||(t.coords={});var e,i=this;Object.keys(t).forEach((function(e){i[e]=t[e]})),this.id?this.id+="_"+T.Object.__uid++:this.id=T.Object.__uid++,e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice()},addColorStop:function(t){for(var e in t){var i=new T.Color(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(t){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return T.util.populateWithProperties(this,e,t),e},toSVG:function(t,i){var n,r,s,a,o=e(this.coords,!0),l=(i=i||{},e(this.colorStops,!0)),h=o.r1>o.r2,c=this.gradientTransform?this.gradientTransform.concat():T.iMatrix.concat(),u=-this.offsetX,d=-this.offsetY,f=!!i.additionalTransform,g="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox";if(l.sort((function(t,e){return t.offset-e.offset})),"objectBoundingBox"===g?(u/=t.width,d/=t.height):(u+=t.width/2,d+=t.height/2),"path"===t.type&&"percentage"!==this.gradientUnits&&(u-=t.pathOffset.x,d-=t.pathOffset.y),c[4]-=u,c[5]-=d,a='id="SVGID_'+this.id+'" gradientUnits="'+g+'"',a+=' gradientTransform="'+(f?i.additionalTransform+" ":"")+T.util.matrixToSVG(c)+'" ',"linear"===this.type?s=["\n']:"radial"===this.type&&(s=["\n']),"radial"===this.type){if(h)for((l=l.concat()).reverse(),n=0,r=l.length;n0){var p=m/Math.max(o.r1,o.r2);for(n=0,r=l.length;n\n')}return s.push("linear"===this.type?"\n":"\n"),s.join("")},toLive:function(t){var e,i,n,r=T.util.object.clone(this.coords);if(this.type){for("linear"===this.type?e=t.createLinearGradient(r.x1,r.y1,r.x2,r.y2):"radial"===this.type&&(e=t.createRadialGradient(r.x1,r.y1,r.r1,r.x2,r.y2,r.r2)),i=0,n=this.colorStops.length;i1?1:s,isNaN(s)&&(s=1);var a,o,l,h,c=e.getElementsByTagName("stop"),u="userSpaceOnUse"===e.getAttribute("gradientUnits")?"pixels":"percentage",d=e.getAttribute("gradientTransform")||"",f=[],g=0,m=0;for("linearGradient"===e.nodeName||"LINEARGRADIENT"===e.nodeName?(a="linear",o=function(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}(e)):(a="radial",o=function(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}(e)),l=c.length;l--;)f.push(t(c[l],s));return h=T.parseTransformAttribute(d),function(t,e,i,n){var r,s;Object.keys(e).forEach((function(t){"Infinity"===(r=e[t])?s=1:"-Infinity"===r?s=0:(s=parseFloat(e[t],10),"string"==typeof r&&/^(\d+\.\d+)%|(\d+)%$/.test(r)&&(s*=.01,"pixels"===n&&("x1"!==t&&"x2"!==t&&"r2"!==t||(s*=i.viewBoxWidth||i.width),"y1"!==t&&"y2"!==t||(s*=i.viewBoxHeight||i.height)))),e[t]=s}))}(0,o,r,u),"pixels"===u&&(g=-i.left,m=-i.top),new T.Gradient({id:e.getAttribute("id"),type:a,coords:o,colorStops:f,gradientUnits:u,gradientTransform:h,offsetX:g,offsetY:m})}})}(),_=T.util.toFixed,T.Pattern=T.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(t,e){if(t||(t={}),this.id=T.Object.__uid++,this.setOptions(t),!t.source||t.source&&"string"!=typeof t.source)e&&e(this);else{var i=this;this.source=T.util.createImage(),T.util.loadImage(t.source,(function(t,n){i.source=t,e&&e(i,n)}),null,this.crossOrigin)}},toObject:function(t){var e,i,n=T.Object.NUM_FRACTION_DIGITS;return"string"==typeof this.source.src?e=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(e=this.source.toDataURL()),i={type:"pattern",source:e,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:_(this.offsetX,n),offsetY:_(this.offsetY,n),patternTransform:this.patternTransform?this.patternTransform.concat():null},T.util.populateWithProperties(this,i,t),i},toSVG:function(t){var e="function"==typeof this.source?this.source():this.source,i=e.width/t.width,n=e.height/t.height,r=this.offsetX/t.width,s=this.offsetY/t.height,a="";return"repeat-x"!==this.repeat&&"no-repeat"!==this.repeat||(n=1,s&&(n+=Math.abs(s))),"repeat-y"!==this.repeat&&"no-repeat"!==this.repeat||(i=1,r&&(i+=Math.abs(r))),e.src?a=e.src:e.toDataURL&&(a=e.toDataURL()),'\n\n\n'},setOptions:function(t){for(var e in t)this[e]=t[e]},toLive:function(t){var e=this.source;if(!e)return"";if(void 0!==e.src){if(!e.complete)return"";if(0===e.naturalWidth||0===e.naturalHeight)return""}return t.createPattern(e,this.repeat)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.toFixed;e.Shadow?e.warn("fabric.Shadow is already defined."):(e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(t){for(var i in"string"==typeof t&&(t=this._parseShadow(t)),t)this[i]=t[i];this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),n=e.Shadow.reOffsetsAndBlur.exec(i)||[];return{color:(i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseFloat(n[1],10)||0,offsetY:parseFloat(n[2],10)||0,blur:parseFloat(n[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var n=40,r=40,s=e.Object.NUM_FRACTION_DIGITS,a=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle)),o=new e.Color(this.color);return t.width&&t.height&&(n=100*i((Math.abs(a.x)+this.blur)/t.width,s)+20,r=100*i((Math.abs(a.y)+this.blur)/t.height,s)+20),t.flipX&&(a.x*=-1),t.flipY&&(a.y*=-1),'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var t={},i=e.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach((function(e){this[e]!==i[e]&&(t[e]=this[e])}),this),t}}),e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/)}(e),function(){if(T.StaticCanvas)T.warn("fabric.StaticCanvas is already defined.");else{var t=T.util.object.extend,e=T.util.getElementOffset,i=T.util.removeFromArray,n=T.util.toFixed,r=T.util.transformPoint,s=T.util.invertTransform,a=T.util.getNodeCanvas,o=T.util.createCanvasElement,l=new Error("Could not initialize `canvas` element");T.StaticCanvas=T.util.createClass(T.CommonMethods,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:T.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(t,e){var i=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(t),this._initOptions(e),this.interactive||this._initRetinaScaling(),e.overlayImage&&this.setOverlayImage(e.overlayImage,i),e.backgroundImage&&this.setBackgroundImage(e.backgroundImage,i),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor,i),e.overlayColor&&this.setOverlayColor(e.overlayColor,i),this.calcOffset()},_isRetinaScaling:function(){return T.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,T.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var t=T.devicePixelRatio;this.__initRetinaScaling(t,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(t,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(t,e,i){e.setAttribute("width",this.width*t),e.setAttribute("height",this.height*t),i.scale(t,t)},calcOffset:function(){return this._offset=e(this.lowerCanvasEl),this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},__setBgOverlayImage:function(t,e,i,n){return"string"==typeof e?T.util.loadImage(e,(function(e,r){if(e){var s=new T.Image(e,n);this[t]=s,s.canvas=this}i&&i(e,r)}),this,n&&n.crossOrigin):(n&&e.setOptions(n),this[t]=e,e&&(e.canvas=this),i&&i(e,!1)),this},__setBgOverlayColor:function(t,e,i){return this[t]=e,this._initGradient(e,t),this._initPattern(e,t,i),this},_createCanvasElement:function(){var t=o();if(!t)throw l;if(t.style||(t.style={}),void 0===t.getContext)throw l;return t},_initOptions:function(t){var e=this.lowerCanvasEl;this._setOptions(t),this.width=this.width||parseInt(e.width,10)||0,this.height=this.height||parseInt(e.height,10)||0,this.lowerCanvasEl.style&&(e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(t){t&&t.getContext?this.lowerCanvasEl=t:this.lowerCanvasEl=T.util.getById(t)||this._createCanvasElement(),T.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;for(var n in e=e||{},t)i=t[n],e.cssOnly||(this._setBackstoreDimension(n,t[n]),i+="px",this.hasLostContext=!0),e.backstoreOnly||this._setCssDimension(n,i);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),e.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(t,e){return this.lowerCanvasEl[t]=e,this.upperCanvasEl&&(this.upperCanvasEl[t]=e),this.cacheCanvasEl&&(this.cacheCanvasEl[t]=e),this[t]=e,this},_setCssDimension:function(t,e){return this.lowerCanvasEl.style[t]=e,this.upperCanvasEl&&(this.upperCanvasEl.style[t]=e),this.wrapperEl&&(this.wrapperEl.style[t]=e),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(t){var e,i,n,r=this._activeObject,s=this.backgroundImage,a=this.overlayImage;for(this.viewportTransform=t,i=0,n=this._objects.length;i\n'),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push("\n"),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push(""),i.join("")},_setSVGPreamble:function(t,e){e.suppressPreamble||t.push('\n','\n')},_setSVGHeader:function(t,e){var i,r=e.width||this.width,s=e.height||this.height,a='viewBox="0 0 '+this.width+" "+this.height+'" ',o=T.Object.NUM_FRACTION_DIGITS;e.viewBox?a='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" ':this.svgViewportTransformation&&(i=this.viewportTransform,a='viewBox="'+n(-i[4]/i[0],o)+" "+n(-i[5]/i[3],o)+" "+n(this.width/i[0],o)+" "+n(this.height/i[3],o)+'" '),t.push("\n',"Created with Fabric.js ",T.version,"\n","\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"\n")},createSVGClipPathMarkup:function(t){var e=this.clipPath;return e?(e.clipPathId="CLIPPATH_"+T.Object.__uid++,'\n'+this.clipPath.toClipPathSVG(t.reviver)+"\n"):""},createSVGRefElementsMarkup:function(){var t=this;return["background","overlay"].map((function(e){var i=t[e+"Color"];if(i&&i.toLive){var n=t[e+"Vpt"],r=t.viewportTransform,s={width:t.width/(n?r[0]:1),height:t.height/(n?r[3]:1)};return i.toSVG(s,{additionalTransform:n?T.util.matrixToSVG(r):""})}})).join("")},createSVGFontFacesMarkup:function(){var t,e,i,n,r,s,a,o,l="",h={},c=T.fontPaths,u=[];for(this._objects.forEach((function t(e){u.push(e),e._objects&&e._objects.forEach(t)})),a=0,o=u.length;a',"\n",l,"","\n"].join("")),l},_setSVGObjects:function(t,e){var i,n,r,s=this._objects;for(n=0,r=s.length;n\n")}else t.push('\n")},sendToBack:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(e=(r=s._objects).length;e--;)n=r[e],i(this._objects,n),this._objects.unshift(n);else i(this._objects,t),this._objects.unshift(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(r=s._objects,e=0;e0+h&&(a=s-1,i(this._objects,r),this._objects.splice(a,0,r)),h++;else 0!==(s=this._objects.indexOf(t))&&(a=this._findNewLowerIndex(t,s,e),i(this._objects,t),this._objects.splice(a,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(t,e,i){var n,r;if(i){for(n=e,r=e-1;r>=0;--r)if(t.intersectsWithObject(this._objects[r])||t.isContainedWithinObject(this._objects[r])||this._objects[r].isContainedWithinObject(t)){n=r;break}}else n=e-1;return n},bringForward:function(t,e){if(!t)return this;var n,r,s,a,o,l=this._activeObject,h=0;if(t===l&&"activeSelection"===t.type)for(n=(o=l._objects).length;n--;)r=o[n],(s=this._objects.indexOf(r))"}}),t(T.StaticCanvas.prototype,T.Observable),t(T.StaticCanvas.prototype,T.Collection),t(T.StaticCanvas.prototype,T.DataURLExporter),t(T.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=o();if(!e||!e.getContext)return null;var i=e.getContext("2d");return i&&"setLineDash"===t?void 0!==i.setLineDash:null}}),T.StaticCanvas.prototype.toJSON=T.StaticCanvas.prototype.toObject,T.isLikelyNode&&(T.StaticCanvas.prototype.createPNGStream=function(){var t=a(this.lowerCanvasEl);return t&&t.createPNGStream()},T.StaticCanvas.prototype.createJPEGStream=function(t){var e=a(this.lowerCanvasEl);return e&&e.createJPEGStream(t)})}}(),T.BaseBrush=T.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(t){var e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])},_setShadow:function(){if(this.shadow){var t=this.canvas,e=this.shadow,i=t.contextTop,n=t.getZoom();t&&t._isRetinaScaling()&&(n*=T.devicePixelRatio),i.shadowColor=e.color,i.shadowBlur=e.blur*n,i.shadowOffsetX=e.offsetX*n,i.shadowOffsetY=e.offsetY*n}},needsFullRender:function(){return new T.Color(this.color).getAlpha()<1||!!this.shadow},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0},_isOutSideCanvas:function(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}),T.PencilBrush=T.util.createClass(T.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(t){this.canvas=t,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(t,e,i){var n=e.midPointFrom(i);return t.quadraticCurveTo(e.x,e.y,n.x,n.y),n},onMouseDown:function(t,e){this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],this._prepareForDrawing(t),this._captureDrawingPath(t),this._render())},onMouseMove:function(t,e){if(this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._captureDrawingPath(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var i=this._points,n=i.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(r,i[n-2],i[n-1],!0),r.stroke(),r.restore()}},onMouseUp:function(t){return!this.canvas._isMainEvent(t.e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)},_prepareForDrawing:function(t){var e=new T.Point(t.x,t.y);this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1])||(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),0))},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(t){var e=new T.Point(t.x,t.y);return this._addPoint(e)},_render:function(t){var e,i,n=this._points[0],r=this._points[1];if(t=t||this.canvas.contextTop,this._saveAndTransform(t),t.beginPath(),2===this._points.length&&n.x===r.x&&n.y===r.y){var s=this.width/1e3;n=new T.Point(n.x,n.y),r=new T.Point(r.x,r.y),n.x-=s,r.x+=s}for(t.moveTo(n.x,n.y),e=1,i=this._points.length;e=r&&(a=t[i],o.push(a));return o.push(t[s]),o},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var t=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(t))this.canvas.requestRenderAll();else{var e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}}),T.CircleBrush=T.util.createClass(T.BaseBrush,{width:10,initialize:function(t){this.canvas=t,this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop;this._saveAndTransform(i),this.dot(i,e),i.restore()},dot:function(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()},onMouseDown:function(t){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)},_render:function(){var t,e,i=this.canvas.contextTop,n=this.points;for(this._saveAndTransform(i),t=0,e=n.length;t0&&!this.preserveObjectStacking){e=[],i=[];for(var r=0,s=this._objects.length;r1&&(this._activeObject._objects=i),e.push.apply(e,i)}else e=this._objects;return e},renderAll:function(){!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_normalizePointer:function(t,e){var i=t.calcTransformMatrix(),n=T.util.invertTransform(i),r=this.restorePointerVpt(e);return T.util.transformPoint(r,n)},isTargetTransparent:function(t,e,i){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var n=this._normalizePointer(t,{x:e,y:i}),r=Math.max(t.cacheTranslationX+n.x*t.zoomX,0),s=Math.max(t.cacheTranslationY+n.y*t.zoomY,0);return T.util.isTransparent(t._cacheContext,Math.round(r),Math.round(s),this.targetFindTolerance)}var a=this.contextCache,o=t.selectionBackgroundColor,l=this.viewportTransform;return t.selectionBackgroundColor="",this.clearContext(a),a.save(),a.transform(l[0],l[1],l[2],l[3],l[4],l[5]),t.render(a),a.restore(),t.selectionBackgroundColor=o,T.util.isTransparent(a,e,i,this.targetFindTolerance)},_isSelectionKeyPressed:function(t){return Array.isArray(this.selectionKey)?!!this.selectionKey.find((function(e){return!0===t[e]})):t[this.selectionKey]},_shouldClearSelection:function(t,e){var i=this.getActiveObjects(),n=this._activeObject;return!e||e&&n&&i.length>1&&-1===i.indexOf(e)&&n!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&n&&n!==e},_shouldCenterTransform:function(t,e,i){var n;if(t)return"scale"===e||"scaleX"===e||"scaleY"===e||"resizing"===e?n=this.centeredScaling||t.centeredScaling:"rotate"===e&&(n=this.centeredRotation||t.centeredRotation),n?!i:i},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};return"ml"===e||"tl"===e||"bl"===e?i.x="right":"mr"!==e&&"tr"!==e&&"br"!==e||(i.x="left"),"tl"===e||"mt"===e||"tr"===e?i.y="bottom":"bl"!==e&&"mb"!==e&&"br"!==e||(i.y="top"),i},_getActionFromCorner:function(t,e,i,n){if(!e||!t)return"drag";var r=n.controls[e];return r.getActionName(i,r,n)},_setupCurrentTransform:function(t,i,n){if(i){var r=this.getPointer(t),s=i.__corner,a=i.controls[s],o=n&&s?a.getActionHandler(t,i,a):T.controlsUtils.dragHandler,l=this._getActionFromCorner(n,s,t,i),h=this._getOriginFromCorner(i,s),c=t[this.centeredKey],u={target:i,action:l,actionHandler:o,corner:s,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:r.x-i.left,offsetY:r.y-i.top,originX:h.x,originY:h.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:e(i.angle),width:i.width*i.scaleX,shiftKey:t.shiftKey,altKey:c,original:T.util.saveObjectTransform(i)};this._shouldCenterTransform(i,l,c)&&(u.originX="center",u.originY="center"),u.original.originX=h.x,u.original.originY=h.y,this._currentTransform=u,this._beforeTransform(t)}},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_drawSelection:function(t){var e=this._groupSelector,i=new T.Point(e.ex,e.ey),n=T.util.transformPoint(i,this.viewportTransform),r=new T.Point(e.ex+e.left,e.ey+e.top),s=T.util.transformPoint(r,this.viewportTransform),a=Math.min(n.x,s.x),o=Math.min(n.y,s.y),l=Math.max(n.x,s.x),h=Math.max(n.y,s.y),c=this.selectionLineWidth/2;this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(a,o,l-a,h-o)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,a+=c,o+=c,l-=c,h-=c,T.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(a,o,l-a,h-o))},findTarget:function(t,e){if(!this.skipTargetFind){var n,r,s=this.getPointer(t,!0),a=this._activeObject,o=this.getActiveObjects(),l=i(t),h=o.length>1&&!e||1===o.length;if(this.targets=[],h&&a._findTargetCorner(s,l))return a;if(o.length>1&&!e&&a===this._searchPossibleTargets([a],s))return a;if(1===o.length&&a===this._searchPossibleTargets([a],s)){if(!this.preserveObjectStacking)return a;n=a,r=this.targets,this.targets=[]}var c=this._searchPossibleTargets(this._objects,s);return t[this.altSelectionKey]&&c&&n&&c!==n&&(c=n,this.targets=r),c}},_checkTarget:function(t,e,i){if(e&&e.visible&&e.evented&&e.containsPoint(t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;if(!this.isTargetTransparent(e,i.x,i.y))return!0}},_searchPossibleTargets:function(t,e){for(var i,n,r=t.length;r--;){var s=t[r],a=s.group?this._normalizePointer(s.group,e):e;if(this._checkTarget(a,s,e)){(i=t[r]).subTargetCheck&&i instanceof T.Group&&(n=this._searchPossibleTargets(i._objects,e))&&this.targets.push(n);break}}return i},restorePointerVpt:function(t){return T.util.transformPoint(t,T.util.invertTransform(this.viewportTransform))},getPointer:function(e,i){if(this._absolutePointer&&!i)return this._absolutePointer;if(this._pointer&&i)return this._pointer;var n,r=t(e),s=this.upperCanvasEl,a=s.getBoundingClientRect(),o=a.width||0,l=a.height||0;o&&l||("top"in a&&"bottom"in a&&(l=Math.abs(a.top-a.bottom)),"right"in a&&"left"in a&&(o=Math.abs(a.right-a.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,i||(r=this.restorePointerVpt(r));var h=this.getRetinaScaling();return 1!==h&&(r.x/=h,r.y/=h),n=0===o||0===l?{width:1,height:1}:{width:s.width/o,height:s.height/l},{x:r.x*n.width,y:r.y*n.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),e=this.lowerCanvasEl,i=this.upperCanvasEl;i?i.className="":(i=this._createCanvasElement(),this.upperCanvasEl=i),T.util.addClass(i,"upper-canvas "+t),this.wrapperEl.appendChild(i),this._copyCanvasStyle(e,i),this._applyCanvasStyle(i),this.contextTop=i.getContext("2d")},getTopContext:function(){return this.contextTop},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=T.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),T.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),T.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.width||t.width,i=this.height||t.height;T.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=e,t.height=i,T.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;return t?"activeSelection"===t.type&&t._objects?t._objects.slice(0):[t]:[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,e){var i=!1,n=this.getActiveObjects(),r=[],s=[];t.forEach((function(t){-1===n.indexOf(t)&&(i=!0,t.fire("deselected",{e:e,target:t}),s.push(t))})),n.forEach((function(n){-1===t.indexOf(n)&&(i=!0,n.fire("selected",{e:e,target:n}),r.push(n))})),t.length>0&&n.length>0?i&&this.fire("selection:updated",{e:e,selected:r,deselected:s}):n.length>0?this.fire("selection:created",{e:e,selected:r}):t.length>0&&this.fire("selection:cleared",{e:e,deselected:s})},setActiveObject:function(t,e){var i=this.getActiveObjects();return this._setActiveObject(t,e),this._fireSelectionEvents(i,e),this},_setActiveObject:function(t,e){return this._activeObject!==t&&!!this._discardActiveObject(e,t)&&!t.onSelect({e:e})&&(this._activeObject=t,!0)},_discardActiveObject:function(t,e){var i=this._activeObject;if(i){if(i.onDeselect({e:t,object:e}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var e=this.getActiveObjects(),i=this.getActiveObject();return e.length&&this.fire("before:selection:cleared",{target:i,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(e,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach(function(t){T.util.cleanUpJsdomNode(this[t]),this[t]=void 0}.bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,T.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var e=this._activeObject;e&&e._renderControls(t)},_toObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(t),r=this.callSuper("_toObject",t,e,i);return this._unwindGroupTransformOnObject(t,n),r},_realizeGroupTransformOnObject:function(t){if(t.group&&"activeSelection"===t.group.type&&this._activeObject===t.group){var e={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach((function(i){e[i]=t[i]})),T.util.addTransformToObject(t,this._activeObject.calcOwnMatrix()),e}return null},_unwindGroupTransformOnObject:function(t,e){e&&t.set(e)},_setSVGObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(e);this.callSuper("_setSVGObject",t,e,i),this._unwindGroupTransformOnObject(e,n)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),T.StaticCanvas.prototype.setViewportTransform.call(this,t)}}),T.StaticCanvas)"prototype"!==n&&(T.Canvas[n]=T.StaticCanvas[n])}(),function(){var t=T.util.addListener,e=T.util.removeListener,i={passive:!1};function n(t,e){return t.button&&t.button===e-1}T.util.object.extend(T.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(t,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(t,e){var n=this.upperCanvasEl,r=this._getEventPrefix();t(T.window,"resize",this._onResize),t(n,r+"down",this._onMouseDown),t(n,r+"move",this._onMouseMove,i),t(n,r+"out",this._onMouseOut),t(n,r+"enter",this._onMouseEnter),t(n,"wheel",this._onMouseWheel),t(n,"contextmenu",this._onContextMenu),t(n,"dblclick",this._onDoubleClick),t(n,"dragover",this._onDragOver),t(n,"dragenter",this._onDragEnter),t(n,"dragleave",this._onDragLeave),t(n,"drop",this._onDrop),this.enablePointerEvents||t(n,"touchstart",this._onTouchStart,i),"undefined"!=typeof eventjs&&e in eventjs&&(eventjs[e](n,"gesture",this._onGesture),eventjs[e](n,"drag",this._onDrag),eventjs[e](n,"orientation",this._onOrientationChange),eventjs[e](n,"shake",this._onShake),eventjs[e](n,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(e,"remove");var t=this._getEventPrefix();e(T.document,t+"up",this._onMouseUp),e(T.document,"touchend",this._onTouchEnd,i),e(T.document,t+"move",this._onMouseMove,i),e(T.document,"touchmove",this._onMouseMove,i)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t){this.__onMouseWheel(t)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t}),this._hoveredTarget=null,e&&e.fire("mouseout",{e:t});var i=this;this._hoveredTargets.forEach((function(n){i.fire("mouse:out",{target:e,e:t}),n&&e.fire("mouseout",{e:t})})),this._hoveredTargets=[],this._iTextInstances&&this._iTextInstances.forEach((function(t){t.isEditing&&t.hiddenTextarea.focus()}))},_onMouseEnter:function(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",{target:null,e:t}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onDragOver:function(t){t.preventDefault();var e=this._simpleEventHandler("dragover",t);this._fireEnterLeaveEvents(e,t)},_onDrop:function(t){return this._simpleEventHandler("drop:before",t),this._simpleEventHandler("drop",t)},_onContextMenu:function(t){return this.stopContextMenu&&(t.stopPropagation(),t.preventDefault()),!1},_onDoubleClick:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData(t)},getPointerId:function(t){var e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1},_isMainEvent:function(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)},_onTouchStart:function(n){n.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(n)),this.__onMouseDown(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();t(T.document,"touchend",this._onTouchEnd,i),t(T.document,"touchmove",this._onMouseMove,i),e(r,s+"down",this._onMouseDown)},_onMouseDown:function(n){this.__onMouseDown(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();e(r,s+"move",this._onMouseMove,i),t(T.document,s+"up",this._onMouseUp),t(T.document,s+"move",this._onMouseMove,i)},_onTouchEnd:function(n){if(!(n.touches.length>0)){this.__onMouseUp(n),this._resetTransformEventData(),this.mainTouchId=null;var r=this._getEventPrefix();e(T.document,"touchend",this._onTouchEnd,i),e(T.document,"touchmove",this._onMouseMove,i);var s=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((function(){t(s.upperCanvasEl,r+"down",s._onMouseDown),s._willAddMouseDown=0}),400)}},_onMouseUp:function(n){this.__onMouseUp(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();this._isMainEvent(n)&&(e(T.document,s+"up",this._onMouseUp),e(T.document,s+"move",this._onMouseMove,i),t(r,s+"move",this._onMouseMove,i))},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t){var e=this._activeObject;return!!(!!e!=!!t||e&&t&&e!==t)||(e&&e.isEditing,!1)},__onMouseUp:function(t){var e,i=this._currentTransform,r=this._groupSelector,s=!1,a=!r||0===r.left&&0===r.top;if(this._cacheTransformEventData(t),e=this._target,this._handleEvent(t,"up:before"),n(t,3))this.fireRightClick&&this._handleEvent(t,"up",3,a);else{if(n(t,2))return this.fireMiddleClick&&this._handleEvent(t,"up",2,a),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)this._onMouseUpInDrawingMode(t);else if(this._isMainEvent(t)){if(i&&(this._finalizeCurrentTransform(t),s=i.actionPerformed),!a){var o=e===this._activeObject;this._maybeGroupObjects(t),s||(s=this._shouldRender(e)||!o&&e===this._activeObject)}var l,h;if(e){if(l=e._findTargetCorner(this.getPointer(t,!0),T.util.isTouchEvent(t)),e.selectable&&e!==this._activeObject&&"up"===e.activeOn)this.setActiveObject(e,t),s=!0;else{var c=e.controls[l],u=c&&c.getMouseUpHandler(t,e,c);u&&u(t,i,(h=this.getPointer(t)).x,h.y)}e.isMoving=!1}if(i&&(i.target!==e||i.corner!==l)){var d=i.target&&i.target.controls[i.corner],f=d&&d.getMouseUpHandler(t,e,c);h=h||this.getPointer(t),f&&f(t,i,h.x,h.y)}this._setCursorFromEvent(t,e),this._handleEvent(t,"up",1,a),this._groupSelector=null,this._currentTransform=null,e&&(e.__corner=0),s?this.requestRenderAll():a||this.renderTop()}}},_simpleEventHandler:function(t,e){var i=this.findTarget(e),n=this.targets,r={e:e,target:i,subTargets:n};if(this.fire(t,r),i&&i.fire(t,r),!n)return i;for(var s=0;s1&&(e=new T.ActiveSelection(i.reverse(),{canvas:this}),this.setActiveObject(e,t))},_collectObjects:function(t){for(var e,i=[],n=this._groupSelector.ex,r=this._groupSelector.ey,s=n+this._groupSelector.left,a=r+this._groupSelector.top,o=new T.Point(v(n,s),v(r,a)),l=new T.Point(y(n,s),y(r,a)),h=!this.selectionFullyContained,c=n===s&&r===a,u=this._objects.length;u--&&!((e=this._objects[u])&&e.selectable&&e.visible&&(h&&e.intersectsWithRect(o,l,!0)||e.isContainedWithinRect(o,l,!0)||h&&e.containsPoint(o,null,!0)||h&&e.containsPoint(l,null,!0))&&(i.push(e),c)););return i.length>1&&(i=i.filter((function(e){return!e.onSelect({e:t})}))),i},_maybeGroupObjects:function(t){this.selection&&this._groupSelector&&this._groupSelectedObjects(t),this.setCursor(this.defaultCursor),this._groupSelector=null}}),T.util.object.extend(T.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,n=(t.multiplier||1)*(t.enableRetinaScaling?this.getRetinaScaling():1),r=this.toCanvasElement(n,t);return T.util.toDataURL(r,e,i)},toCanvasElement:function(t,e){t=t||1;var i=((e=e||{}).width||this.width)*t,n=(e.height||this.height)*t,r=this.getZoom(),s=this.width,a=this.height,o=r*t,l=this.viewportTransform,h=(l[4]-(e.left||0))*t,c=(l[5]-(e.top||0))*t,u=this.interactive,d=[o,0,0,o,h,c],f=this.enableRetinaScaling,g=T.util.createCanvasElement(),m=this.contextTop;return g.width=i,g.height=n,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=d,this.width=i,this.height=n,this.calcViewportBoundaries(),this.renderCanvas(g.getContext("2d"),this._objects),this.viewportTransform=l,this.width=s,this.height=a,this.calcViewportBoundaries(),this.interactive=u,this.enableRetinaScaling=f,this.contextTop=m,g}}),T.util.object.extend(T.StaticCanvas.prototype,{loadFromJSON:function(t,e,i){if(t){var n="string"==typeof t?JSON.parse(t):T.util.object.clone(t),r=this,s=n.clipPath,a=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete n.clipPath,this._enlivenObjects(n.objects,(function(t){r.clear(),r._setBgOverlay(n,(function(){s?r._enlivenObjects([s],(function(i){r.clipPath=i[0],r.__setupCanvas.call(r,n,t,a,e)})):r.__setupCanvas.call(r,n,t,a,e)}))}),i),this}},__setupCanvas:function(t,e,i,n){var r=this;e.forEach((function(t,e){r.insertAt(t,e)})),this.renderOnAddRemove=i,delete t.objects,delete t.backgroundImage,delete t.overlayImage,delete t.background,delete t.overlay,this._setOptions(t),this.renderAll(),n&&n()},_setBgOverlay:function(t,e){var i={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(t.backgroundImage||t.overlayImage||t.background||t.overlay){var n=function(){i.backgroundImage&&i.overlayImage&&i.backgroundColor&&i.overlayColor&&e&&e()};this.__setBgOverlay("backgroundImage",t.backgroundImage,i,n),this.__setBgOverlay("overlayImage",t.overlayImage,i,n),this.__setBgOverlay("backgroundColor",t.background,i,n),this.__setBgOverlay("overlayColor",t.overlay,i,n)}else e&&e()},__setBgOverlay:function(t,e,i,n){var r=this;if(!e)return i[t]=!0,void(n&&n());"backgroundImage"===t||"overlayImage"===t?T.util.enlivenObjects([e],(function(e){r[t]=e[0],i[t]=!0,n&&n()})):this["set"+T.util.string.capitalize(t,!0)](e,(function(){i[t]=!0,n&&n()}))},_enlivenObjects:function(t,e,i){t&&0!==t.length?T.util.enlivenObjects(t,(function(t){e&&e(t)}),null,i):e&&e([])},_toDataURL:function(t,e){this.clone((function(i){e(i.toDataURL(t))}))},_toDataURLWithMultiplier:function(t,e,i){this.clone((function(n){i(n.toDataURLWithMultiplier(t,e))}))},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData((function(e){e.loadFromJSON(i,(function(){t&&t(e)}))}))},cloneWithoutData:function(t){var e=T.util.createCanvasElement();e.width=this.width,e.height=this.height;var i=new T.Canvas(e);this.backgroundImage?(i.setBackgroundImage(this.backgroundImage.src,(function(){i.renderAll(),t&&t(i)})),i.backgroundImageOpacity=this.backgroundImageOpacity,i.backgroundImageStretch=this.backgroundImageStretch):t&&t(i)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,s=e.util.string.capitalize,a=e.util.degreesToRadians,o=!e.isLikelyNode;e.Object||(e.Object=e.util.createClass(e.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:o,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(t){t&&this.setOptions(t)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=e.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(t){var i=e.perfLimitSizeTotal,n=t.width,r=t.height,s=e.maxCacheSideLimit,a=e.minCacheSideLimit;if(n<=s&&r<=s&&n*r<=i)return nc&&(t.zoomX/=n/c,t.width=c,t.capped=!0),r>u&&(t.zoomY/=r/u,t.height=u,t.capped=!0),t},_getCacheCanvasDimensions:function(){var t=this.getTotalObjectScaling(),e=this._getTransformedDimensions(0,0),i=e.x*t.scaleX/this.scaleX,n=e.y*t.scaleY/this.scaleY;return{width:i+2,height:n+2,zoomX:t.scaleX,zoomY:t.scaleY,x:i,y:n}},_updateCacheCanvas:function(){var t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){var i=t._currentTransform.target,n=t._currentTransform.action;if(this===i&&n.slice&&"scale"===n.slice(0,5))return!1}var r,s,a=this._cacheCanvas,o=this._limitCacheSize(this._getCacheCanvasDimensions()),l=e.minCacheSideLimit,h=o.width,c=o.height,u=o.zoomX,d=o.zoomY,f=h!==this.cacheWidth||c!==this.cacheHeight,g=this.zoomX!==u||this.zoomY!==d,m=f||g,p=0,_=0,v=!1;if(f){var y=this._cacheCanvas.width,w=this._cacheCanvas.height,E=h>y||c>w;v=E||(h<.9*y||c<.9*w)&&y>l&&w>l,E&&!o.capped&&(h>l||c>l)&&(p=.1*h,_=.1*c)}return this instanceof e.Text&&this.path&&(m=!0,v=!0,p+=this.getHeightOfLine(0)*this.zoomX,_+=this.getHeightOfLine(0)*this.zoomY),!!m&&(v?(a.width=Math.ceil(h+p),a.height=Math.ceil(c+_)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,a.width,a.height)),r=o.x/2,s=o.y/2,this.cacheTranslationX=Math.round(a.width/2-r)+r,this.cacheTranslationY=Math.round(a.height/2-s)+s,this.cacheWidth=h,this.cacheHeight=c,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(u,d),this.zoomX=u,this.zoomY=d,!0)},setOptions:function(t){this._setOptions(t),this._initGradient(t.fill,"fill"),this._initGradient(t.stroke,"stroke"),this._initPattern(t.fill,"fill"),this._initPattern(t.stroke,"stroke")},transform:function(t){var e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,n={type:this.type,version:e.version,originX:this.originX,originY:this.originY,left:r(this.left,i),top:r(this.top,i),width:r(this.width,i),height:r(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:r(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:r(this.strokeMiterLimit,i),scaleX:r(this.scaleX,i),scaleY:r(this.scaleY,i),angle:r(this.angle,i),flipX:this.flipX,flipY:this.flipY,opacity:r(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:r(this.skewX,i),skewY:r(this.skewY,i)};return this.clipPath&&!this.clipPath.excludeFromExport&&(n.clipPath=this.clipPath.toObject(t),n.clipPath.inverted=this.clipPath.inverted,n.clipPath.absolutePositioned=this.clipPath.absolutePositioned),e.util.populateWithProperties(this,n,t),this.includeDefaultValues||(n=this._removeDefaultValues(n)),n},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype;return i.stateProperties.forEach((function(e){"left"!==e&&"top"!==e&&(t[e]===i[e]&&delete t[e],Array.isArray(t[e])&&Array.isArray(i[e])&&0===t[e].length&&0===i[e].length&&delete t[e])})),t},toString:function(){return"#"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var t=e.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(t.scaleX),scaleY:Math.abs(t.scaleY)}},getTotalObjectScaling:function(){var t=this.getObjectScaling(),e=t.scaleX,i=t.scaleY;if(this.canvas){var n=this.canvas.getZoom(),r=this.canvas.getRetinaScaling();e*=n*r,i*=n*r}return{scaleX:e,scaleY:i}},getObjectOpacity:function(){var t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t},_set:function(t,i){var n="scaleX"===t||"scaleY"===t,r=this[t]!==i,s=!1;return n&&(i=this._constrainScale(i)),"scaleX"===t&&i<0?(this.flipX=!this.flipX,i*=-1):"scaleY"===t&&i<0?(this.flipY=!this.flipY,i*=-1):"shadow"!==t||!i||i instanceof e.Shadow?"dirty"===t&&this.group&&this.group.set("dirty",i):i=new e.Shadow(i),this[t]=i,r&&(s=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(t)>-1?(this.dirty=!0,s&&this.group.set("dirty",!0)):s&&this.stateProperties.indexOf(t)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:e.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible},render:function(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(t),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),t.restore())},renderCache:function(t){t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,t.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this._cacheContext=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth},hasFill:function(){return this.fill&&"transparent"!==this.fill},needsItsOwnCache:function(){return!("stroke"!==this.paintFirst||!this.hasFill()||!this.hasStroke()||"object"!=typeof this.shadow)||!!this.clipPath},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawClipPathOnCache:function(t,i){if(t.save(),i.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",i.absolutePositioned){var n=e.util.invertTransform(this.calcTransformMatrix());t.transform(n[0],n[1],n[2],n[3],n[4],n[5])}i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},drawObject:function(t,e){var i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath),this.fill=i,this.stroke=n},_drawClipPath:function(t,e){e&&(e.canvas=this.canvas,e.shouldCache(),e._transformDone=!0,e.renderCache({forClipping:!0}),this.drawClipPathOnCache(t,e))},drawCacheOnCanvas:function(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(t){if(this.isNotVisible())return!1;if(this._cacheCanvas&&this._cacheContext&&!t&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&this._cacheContext&&!t){var e=this.cacheWidth/this.zoomX,i=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-e/2,-i/2,e,i)}return!0}return!1},_renderBackground:function(t){if(this.backgroundColor){var e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}},_setOpacity:function(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity},_setStrokeStyles:function(t,e){var i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,i.toLive?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)},_setFillStyles:function(t,e){var i=e.fill;i&&(i.toLive?(t.fillStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,e.fill)):t.fillStyle=i)},_setClippingProperties:function(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"},_setLineDash:function(t,e){e&&0!==e.length&&(1&e.length&&e.push.apply(e,e),t.setLineDash(e))},_renderControls:function(t,i){var n,r,s,o=this.getViewportTransform(),l=this.calcTransformMatrix();r=void 0!==(i=i||{}).hasBorders?i.hasBorders:this.hasBorders,s=void 0!==i.hasControls?i.hasControls:this.hasControls,l=e.util.multiplyTransformMatrices(o,l),n=e.util.qrDecompose(l),t.save(),t.translate(n.translateX,n.translateY),t.lineWidth=1*this.borderScaleFactor,this.group||(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(n.angle-=180),t.rotate(a(this.group?n.angle:this.angle)),i.forActiveSelection||this.group?r&&this.drawBordersInGroup(t,n,i):r&&this.drawBorders(t,i),s&&this.drawControls(t,i),t.restore()},_setShadow:function(t){if(this.shadow){var i,n=this.shadow,r=this.canvas,s=r&&r.viewportTransform[0]||1,a=r&&r.viewportTransform[3]||1;i=n.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),r&&r._isRetinaScaling()&&(s*=e.devicePixelRatio,a*=e.devicePixelRatio),t.shadowColor=n.color,t.shadowBlur=n.blur*e.browserShadowBlurConstant*(s+a)*(i.scaleX+i.scaleY)/4,t.shadowOffsetX=n.offsetX*s*i.scaleX,t.shadowOffsetY=n.offsetY*a*i.scaleY}},_removeShadow:function(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)},_applyPatternGradientTransform:function(t,e){if(!e||!e.toLive)return{offsetX:0,offsetY:0};var i=e.gradientTransform||e.patternTransform,n=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,n,r):t.transform(1,0,0,1,n,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:n,offsetY:r}},_renderPaintInOrder:function(t){"stroke"===this.paintFirst?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))},_render:function(){},_renderFill:function(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())},_renderStroke:function(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform&&this.group){var e=this.getObjectScaling();t.scale(1/e.scaleX,1/e.scaleY)}else this.strokeUniform&&t.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}},_applyPatternForTransformedGradient:function(t,i){var n,r=this._limitCacheSize(this._getCacheCanvasDimensions()),s=e.util.createCanvasElement(),a=this.canvas.getRetinaScaling(),o=r.x/this.scaleX/a,l=r.y/this.scaleY/a;s.width=o,s.height=l,(n=s.getContext("2d")).beginPath(),n.moveTo(0,0),n.lineTo(o,0),n.lineTo(o,l),n.lineTo(0,l),n.closePath(),n.translate(o/2,l/2),n.scale(r.zoomX/this.scaleX/a,r.zoomY/this.scaleY/a),this._applyPatternGradientTransform(n,i),n.fillStyle=i.toLive(t),n.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(a*this.scaleX/r.zoomX,a*this.scaleY/r.zoomY),t.strokeStyle=n.createPattern(s,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var t=e.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",t.scaleX),this.set("scaleY",t.scaleY),this.angle=t.angle,this.skewX=t.skewX,this.skewY=0}},_removeTransformMatrix:function(t){var i=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),i=e.util.transformPoint(i,this.transformMatrix)),this.transformMatrix=null,t&&(this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this.cropX=t.cropX,this.cropY=t.cropY,i.x+=t.offsetLeft,i.y+=t.offsetTop,this.width=t.width,this.height=t.height),this.setPositionByOrigin(i,"center","center")},clone:function(t,i){var n=this.toObject(i);this.constructor.fromObject?this.constructor.fromObject(n,t):e.Object._fromObject("Object",n,t)},cloneAsImage:function(t,i){var n=this.toCanvasElement(i);return t&&t(new e.Image(n)),this},toCanvasElement:function(t){t||(t={});var i=e.util,n=i.saveObjectTransform(this),r=this.group,s=this.shadow,a=Math.abs,o=(t.multiplier||1)*(t.enableRetinaScaling?e.devicePixelRatio:1);delete this.group,t.withoutTransform&&i.resetObjectTransform(this),t.withoutShadow&&(this.shadow=null);var l,h,c,u,d=e.util.createCanvasElement(),f=this.getBoundingRect(!0,!0),g=this.shadow,m={x:0,y:0};g&&(h=g.blur,l=g.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),m.x=2*Math.round(a(g.offsetX)+h)*a(l.scaleX),m.y=2*Math.round(a(g.offsetY)+h)*a(l.scaleY)),c=f.width+m.x,u=f.height+m.y,d.width=Math.ceil(c),d.height=Math.ceil(u);var p=new e.StaticCanvas(d,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});"jpeg"===t.format&&(p.backgroundColor="#fff"),this.setPositionByOrigin(new e.Point(p.width/2,p.height/2),"center","center");var _=this.canvas;p.add(this);var v=p.toCanvasElement(o||1,t);return this.shadow=s,this.set("canvas",_),r&&(this.group=r),this.set(n).setCoords(),p._objects=[],p.dispose(),p=null,v},toDataURL:function(t){return t||(t={}),e.util.toDataURL(this.toCanvasElement(t),t.format||"png",t.quality||1)},isType:function(t){return arguments.length>1?Array.from(arguments).includes(this.type):this.type===t},complexity:function(){return 1},toJSON:function(t){return this.toObject(t)},rotate:function(t){var e=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return e&&this._setOriginToCenter(),this.set("angle",t),e&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var n=new e.Point(i.x,i.y),r=this._getLeftTopCoords();return this.angle&&(n=e.util.rotatePoint(n,r,a(-this.angle))),{x:n.x-r.x,y:n.y-r.y}},_setupCompositeOperation:function(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){e.runningAnimations&&e.runningAnimations.cancelByTarget(this)}}),e.util.createAccessors&&e.util.createAccessors(e.Object),i(e.Object.prototype,e.Observable),e.Object.NUM_FRACTION_DIGITS=2,e.Object.ENLIVEN_PROPS=["clipPath"],e.Object._fromObject=function(t,i,r,s){var a=e[t];i=n(i,!0),e.util.enlivenPatterns([i.fill,i.stroke],(function(t){void 0!==t[0]&&(i.fill=t[0]),void 0!==t[1]&&(i.stroke=t[1]),e.util.enlivenObjectEnlivables(i,i,(function(){var t=s?new a(i[s],i):new a(i);r&&r(t)}))}))},e.Object.__uid=0)}(e),w=T.util.degreesToRadians,E={left:-.5,center:0,right:.5},C={top:-.5,center:0,bottom:.5},T.util.object.extend(T.Object.prototype,{translateToGivenOrigin:function(t,e,i,n,r){var s,a,o,l=t.x,h=t.y;return"string"==typeof e?e=E[e]:e-=.5,"string"==typeof n?n=E[n]:n-=.5,"string"==typeof i?i=C[i]:i-=.5,"string"==typeof r?r=C[r]:r-=.5,a=r-i,((s=n-e)||a)&&(o=this._getTransformedDimensions(),l=t.x+s*o.x,h=t.y+a*o.y),new T.Point(l,h)},translateToCenterPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,e,i,"center","center");return this.angle?T.util.rotatePoint(n,t,w(this.angle)):n},translateToOriginPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,"center","center",e,i);return this.angle?T.util.rotatePoint(n,t,w(this.angle)):n},getCenterPoint:function(){var t=new T.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(t,e,i){var n,r,s=this.getCenterPoint();return n=void 0!==e&&void 0!==i?this.translateToGivenOrigin(s,"center","center",e,i):new T.Point(this.left,this.top),r=new T.Point(t.x,t.y),this.angle&&(r=T.util.rotatePoint(r,s,-w(this.angle))),r.subtractEquals(n)},setPositionByOrigin:function(t,e,i){var n=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(n,this.originX,this.originY);this.set("left",r.x),this.set("top",r.y)},adjustPosition:function(t){var e,i,n=w(this.angle),r=this.getScaledWidth(),s=T.util.cos(n)*r,a=T.util.sin(n)*r;e="string"==typeof this.originX?E[this.originX]:this.originX-.5,i="string"==typeof t?E[t]:t-.5,this.left+=s*(i-e),this.top+=a*(i-e),this.setCoords(),this.originX=t},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center",this.originY="center",this.left=t.x,this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=t.x,this.top=t.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}}),function(){var t=T.util,e=t.degreesToRadians,i=t.multiplyTransformMatrices,n=t.transformPoint;t.object.extend(T.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(t,e){return e?t?this.calcACoords():this.calcLineCoords():(this.aCoords&&this.lineCoords||this.setCoords(!0),t?this.aCoords:this.lineCoords)},getCoords:function(t,e){return i=this._getCoords(t,e),[new T.Point(i.tl.x,i.tl.y),new T.Point(i.tr.x,i.tr.y),new T.Point(i.br.x,i.br.y),new T.Point(i.bl.x,i.bl.y)];var i},intersectsWithRect:function(t,e,i,n){var r=this.getCoords(i,n);return"Intersection"===T.Intersection.intersectPolygonRectangle(r,t,e).status},intersectsWithObject:function(t,e,i){return"Intersection"===T.Intersection.intersectPolygonPolygon(this.getCoords(e,i),t.getCoords(e,i)).status||t.isContainedWithinObject(this,e,i)||this.isContainedWithinObject(t,e,i)},isContainedWithinObject:function(t,e,i){for(var n=this.getCoords(e,i),r=e?t.aCoords:t.lineCoords,s=0,a=t._getImageLines(r);s<4;s++)if(!t.containsPoint(n[s],a))return!1;return!0},isContainedWithinRect:function(t,e,i,n){var r=this.getBoundingRect(i,n);return r.left>=t.x&&r.left+r.width<=e.x&&r.top>=t.y&&r.top+r.height<=e.y},containsPoint:function(t,e,i,n){var r=this._getCoords(i,n),s=(e=e||this._getImageLines(r),this._findCrossPoints(t,e));return 0!==s&&s%2==1},isOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.getCoords(!0,t).some((function(t){return t.x<=i.x&&t.x>=e.x&&t.y<=i.y&&t.y>=e.y}))||!!this.intersectsWithRect(e,i,!0,t)||this._containsCenterOfCanvas(e,i,t)},_containsCenterOfCanvas:function(t,e,i){var n={x:(t.x+e.x)/2,y:(t.y+e.y)/2};return!!this.containsPoint(n,null,!0,i)},isPartiallyOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.intersectsWithRect(e,i,!0,t)||this.getCoords(!0,t).every((function(t){return(t.x>=i.x||t.x<=e.x)&&(t.y>=i.y||t.y<=e.y)}))&&this._containsCenterOfCanvas(e,i,t)},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,n,r,s=0;for(var a in e)if(!((r=e[a]).o.y=t.y&&r.d.y>=t.y||(r.o.x===r.d.x&&r.o.x>=t.x?n=r.o.x:(i=(r.d.y-r.o.y)/(r.d.x-r.o.x),n=-(t.y-0*t.x-(r.o.y-i*r.o.x))/(0-i)),n>=t.x&&(s+=1),2!==s)))break;return s},getBoundingRect:function(e,i){var n=this.getCoords(e,i);return t.makeBoundingBoxFromPoints(n)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){return Math.abs(t)\n')}},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})},toClipPathSVG:function(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})},_createBaseClipPathSVGMarkup:function(t,e){var i=(e=e||{}).reviver,n=e.additionalTransform||"",r=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=r,i?i(t.join("")):t.join("")},_createBaseSVGMarkup:function(t,e){var i,n,r=(e=e||{}).noStyle,s=e.reviver,a=r?"":'style="'+this.getSvgStyles()+'" ',o=e.withShadow?'style="'+this.getSvgFilter()+'" ':"",l=this.clipPath,h=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",c=l&&l.absolutePositioned,u=this.stroke,d=this.fill,f=this.shadow,g=[],m=t.indexOf("COMMON_PARTS"),p=e.additionalTransform;return l&&(l.clipPathId="CLIPPATH_"+T.Object.__uid++,n='\n'+l.toClipPathSVG(s)+"\n"),c&&g.push("\n"),g.push("\n"),i=[a,h,r?"":this.addPaintOrder()," ",p?'transform="'+p+'" ':""].join(""),t[m]=i,d&&d.toLive&&g.push(d.toSVG(this)),u&&u.toLive&&g.push(u.toSVG(this)),f&&g.push(f.toSVG(this)),l&&g.push(n),g.push(t.join("")),g.push("\n"),c&&g.push("\n"),s?s(g.join("")):g.join("")},addPaintOrder:function(){return"fill"!==this.paintFirst?' paint-order="'+this.paintFirst+'" ':""}})}(),function(){var t=T.util.object.extend,e="stateProperties";function i(e,i,n){var r={};n.forEach((function(t){r[t]=e[t]})),t(e[i],r,!0)}function n(t,e,i){if(t===e)return!0;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(var r=0,s=t.length;r=0;l--)if(r=o[l],this.isControlVisible(r)&&(n=this._getImageLines(e?this.oCoords[r].touchCorner:this.oCoords[r].corner),0!==(i=this._findCrossPoints({x:s,y:a},n))&&i%2==1))return this.__corner=r,r;return!1},forEachControl:function(t){for(var e in this.controls)t(this.controls[e],e,this)},_setCornerCoords:function(){var t=this.oCoords;for(var e in t){var i=this.controls[e];t[e].corner=i.calcCornerCoords(this.angle,this.cornerSize,t[e].x,t[e].y,!1),t[e].touchCorner=i.calcCornerCoords(this.angle,this.touchCornerSize,t[e].x,t[e].y,!0)}},drawSelectionBackground:function(e){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;e.save();var i=this.getCenterPoint(),n=this._calculateCurrentDimensions(),r=this.canvas.viewportTransform;return e.translate(i.x,i.y),e.scale(1/r[0],1/r[3]),e.rotate(t(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-n.x/2,-n.y/2,n.x,n.y),e.restore(),this},drawBorders:function(t,e){e=e||{};var i=this._calculateCurrentDimensions(),n=this.borderScaleFactor,r=i.x+n,s=i.y+n,a=void 0!==e.hasControls?e.hasControls:this.hasControls,o=!1;return t.save(),t.strokeStyle=e.borderColor||this.borderColor,this._setLineDash(t,e.borderDashArray||this.borderDashArray),t.strokeRect(-r/2,-s/2,r,s),a&&(t.beginPath(),this.forEachControl((function(e,i,n){e.withConnection&&e.getVisibility(n,i)&&(o=!0,t.moveTo(e.x*r,e.y*s),t.lineTo(e.x*r+e.offsetX,e.y*s+e.offsetY))})),o&&t.stroke()),t.restore(),this},drawBordersInGroup:function(t,e,i){i=i||{};var n=T.util.sizeAfterTransform(this.width,this.height,e),r=this.strokeWidth,s=this.strokeUniform,a=this.borderScaleFactor,o=n.x+r*(s?this.canvas.getZoom():e.scaleX)+a,l=n.y+r*(s?this.canvas.getZoom():e.scaleY)+a;return t.save(),this._setLineDash(t,i.borderDashArray||this.borderDashArray),t.strokeStyle=i.borderColor||this.borderColor,t.strokeRect(-o/2,-l/2,o,l),t.restore(),this},drawControls:function(t,e){e=e||{},t.save();var i,n,r=this.canvas.getRetinaScaling();return t.setTransform(r,0,0,r,0,0),t.strokeStyle=t.fillStyle=e.cornerColor||this.cornerColor,this.transparentCorners||(t.strokeStyle=e.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(t,e.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(i=this.group.calcTransformMatrix()),this.forEachControl((function(r,s,a){n=a.oCoords[s],r.getVisibility(a,s)&&(i&&(n=T.util.transformPoint(n,i)),r.render(t,n.x,n.y,e,a))})),t.restore(),this},isControlVisible:function(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)},setControlVisible:function(t,e){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e,this},setControlsVisibility:function(t){for(var e in t||(t={}),t)this.setControlVisible(e,t[e]);return this},onDeselect:function(){},onSelect:function(){}})}(),T.util.object.extend(T.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.left,endValue:this.getCenterPoint().x,duration:this.FX_DURATION,onChange:function(e){t.set("left",e),s.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}})},fxCenterObjectV:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.top,endValue:this.getCenterPoint().y,duration:this.FX_DURATION,onChange:function(e){t.set("top",e),s.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}})},fxRemove:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(e){t.set("opacity",e),s.requestRenderAll(),r()},onComplete:function(){s.remove(t),n()}})}}),T.util.object.extend(T.Object.prototype,{animate:function(){if(arguments[0]&&"object"==typeof arguments[0]){var t,e,i=[],n=[];for(t in arguments[0])i.push(t);for(var r=0,s=i.length;r-1||r&&s.colorProperties.indexOf(r[1])>-1,o=r?this.get(r[0])[r[1]]:this.get(t);"from"in i||(i.from=o),a||(e=~e.indexOf("=")?o+parseFloat(e.replace("=","")):parseFloat(e));var l={target:this,startValue:i.from,endValue:e,byValue:i.by,easing:i.easing,duration:i.duration,abort:i.abort&&function(t,e,n){return i.abort.call(s,t,e,n)},onChange:function(e,a,o){r?s[r[0]][r[1]]=e:s.set(t,e),n||i.onChange&&i.onChange(e,a,o)},onComplete:function(t,e,r){n||(s.setCoords(),i.onComplete&&i.onComplete(t,e,r))}};return a?T.util.animateColor(l.startValue,l.endValue,l.duration,l):T.util.animate(l)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r={x1:1,x2:1,y1:1,y2:1};function s(t,e){var i=t.origin,n=t.axis1,r=t.axis2,s=t.dimension,a=e.nearest,o=e.center,l=e.farthest;return function(){switch(this.get(i)){case a:return Math.min(this.get(n),this.get(r));case o:return Math.min(this.get(n),this.get(r))+.5*this.get(s);case l:return Math.max(this.get(n),this.get(r))}}}e.Line?e.warn("fabric.Line is already defined"):(e.Line=e.util.createClass(e.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:e.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(t,e){t||(t=[0,0,0,0]),this.callSuper("initialize",e),this.set("x1",t[0]),this.set("y1",t[1]),this.set("x2",t[2]),this.set("y2",t[3]),this._setWidthHeight(e)},_setWidthHeight:function(t){t||(t={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in t?t.left:this._getLeftToOriginX(),this.top="top"in t?t.top:this._getTopToOriginY()},_set:function(t,e){return this.callSuper("_set",t,e),void 0!==r[t]&&this._setWidthHeight(),this},_getLeftToOriginX:s({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:s({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(t){t.beginPath();var e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;var i=t.strokeStyle;t.strokeStyle=this.stroke||t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(t){return i(this.callSuper("toObject",t),this.calcLinePoints())},_getNonTransformedDimensions:function(){var t=this.callSuper("_getNonTransformedDimensions");return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t},calcLinePoints:function(){var t=this.x1<=this.x2?-1:1,e=this.y1<=this.y2?-1:1,i=t*this.width*.5,n=e*this.height*.5;return{x1:i,x2:t*this.width*-.5,y1:n,y2:e*this.height*-.5}},_toSVG:function(){var t=this.calcLinePoints();return["\n']}}),e.Line.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),e.Line.fromElement=function(t,n,r){r=r||{};var s=e.parseAttributes(t,e.Line.ATTRIBUTE_NAMES),a=[s.x1||0,s.y1||0,s.x2||0,s.y2||0];n(new e.Line(a,i(s,r)))},e.Line.fromObject=function(t,i){var r=n(t,!0);r.points=[t.x1,t.y1,t.x2,t.y2],e.Object._fromObject("Line",r,(function(t){delete t.points,i&&i(t)}),"points")})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians;e.Circle?e.warn("fabric.Circle is already defined."):(e.Circle=e.util.createClass(e.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:e.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,e){return this.callSuper("_set",t,e),"radius"===t&&this.setRadius(e),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,n=(this.endAngle-this.startAngle)%360;if(0===n)t=["\n'];else{var r=i(this.startAngle),s=i(this.endAngle),a=this.radius;t=['180?"1":"0")+" 1"," "+e.util.cos(s)*a+" "+e.util.sin(s)*a,'" ',"COMMON_PARTS"," />\n"]}return t},_render:function(t){t.beginPath(),t.arc(0,0,this.radius,i(this.startAngle),i(this.endAngle),!1),this._renderPaintInOrder(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",2*t).set("height",2*t)}}),e.Circle.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),e.Circle.fromElement=function(t,i){var n,r=e.parseAttributes(t,e.Circle.ATTRIBUTE_NAMES);if(!("radius"in(n=r)&&n.radius>=0))throw new Error("value of `r` attribute is required and can not be negative");r.left=(r.left||0)-r.radius,r.top=(r.top||0)-r.radius,i(new e.Circle(r))},e.Circle.fromObject=function(t,i){e.Object._fromObject("Circle",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={});e.Triangle?e.warn("fabric.Triangle is already defined"):(e.Triangle=e.util.createClass(e.Object,{type:"triangle",width:100,height:100,_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)},_toSVG:function(){var t=this.width/2,e=this.height/2;return["']}}),e.Triangle.fromObject=function(t,i){return e.Object._fromObject("Triangle",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=2*Math.PI;e.Ellipse?e.warn("fabric.Ellipse is already defined."):(e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this.set("rx",t&&t.rx||0),this.set("ry",t&&t.ry||0)},_set:function(t,e){switch(this.callSuper("_set",t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']},_render:function(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,i,!1),t.restore(),this._renderPaintInOrder(t)}}),e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),e.Ellipse.fromElement=function(t,i){var n=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);n.left=(n.left||0)-n.rx,n.top=(n.top||0)-n.ry,i(new e.Ellipse(n))},e.Ellipse.fromObject=function(t,i){e.Object._fromObject("Ellipse",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Rect?e.warn("fabric.Rect is already defined"):(e.Rect=e.util.createClass(e.Object,{stateProperties:e.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(t){var e=this.rx?Math.min(this.rx,this.width/2):0,i=this.ry?Math.min(this.ry,this.height/2):0,n=this.width,r=this.height,s=-this.width/2,a=-this.height/2,o=0!==e||0!==i,l=.4477152502;t.beginPath(),t.moveTo(s+e,a),t.lineTo(s+n-e,a),o&&t.bezierCurveTo(s+n-l*e,a,s+n,a+l*i,s+n,a+i),t.lineTo(s+n,a+r-i),o&&t.bezierCurveTo(s+n,a+r-l*i,s+n-l*e,a+r,s+n-e,a+r),t.lineTo(s+e,a+r),o&&t.bezierCurveTo(s+l*e,a+r,s,a+r-l*i,s,a+r-i),t.lineTo(s,a+i),o&&t.bezierCurveTo(s,a+l*i,s+l*e,a,s+e,a),t.closePath(),this._renderPaintInOrder(t)},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']}}),e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),e.Rect.fromElement=function(t,n,r){if(!t)return n(null);r=r||{};var s=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);s.left=s.left||0,s.top=s.top||0,s.height=s.height||0,s.width=s.width||0;var a=new e.Rect(i(r?e.util.object.clone(r):{},s));a.visible=a.visible&&a.width>0&&a.height>0,n(a)},e.Rect.fromObject=function(t,i){return e.Object._fromObject("Rect",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.array.min,r=e.util.array.max,s=e.util.toFixed,a=e.util.projectStrokeOnPoints;e.Polyline?e.warn("fabric.Polyline is already defined"):(e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:e.Object.prototype.cacheProperties.concat("points"),initialize:function(t,e){e=e||{},this.points=t||[],this.callSuper("initialize",e),this._setPositionDimensions(e)},_projectStrokeOnPoints:function(){return a(this.points,this,!0)},_setPositionDimensions:function(t){var e,i=this._calcDimensions(t),n=this.exactBoundingBox?this.strokeWidth:0;this.width=i.width-n,this.height=i.height-n,t.fromSVG||(e=this.translateToGivenOrigin({x:i.left-this.strokeWidth/2+n/2,y:i.top-this.strokeWidth/2+n/2},"left","top",this.originX,this.originY)),void 0===t.left&&(this.left=t.fromSVG?i.left:e.x),void 0===t.top&&(this.top=t.fromSVG?i.top:e.y),this.pathOffset={x:i.left+this.width/2+n/2,y:i.top+this.height/2+n/2}},_calcDimensions:function(){var t=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,e=n(t,"x")||0,i=n(t,"y")||0;return{left:e,top:i,width:(r(t,"x")||0)-e,height:(r(t,"y")||0)-i}},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},_toSVG:function(){for(var t=[],i=this.pathOffset.x,n=this.pathOffset.y,r=e.Object.NUM_FRACTION_DIGITS,a=0,o=this.points.length;a\n']},commonRender:function(t){var e,i=this.points.length,n=this.pathOffset.x,r=this.pathOffset.y;if(!i||isNaN(this.points[i-1].y))return!1;t.beginPath(),t.moveTo(this.points[0].x-n,this.points[0].y-r);for(var s=0;s"},toObject:function(t){return r(this.callSuper("toObject",t),{path:this.path.map((function(t){return t.slice()}))})},toDatalessObject:function(t){var e=this.toObject(["sourcePath"].concat(t));return e.sourcePath&&delete e.path,e},_toSVG:function(){return["\n"]},_getOffsetTransform:function(){var t=e.Object.NUM_FRACTION_DIGITS;return" translate("+a(-this.pathOffset.x,t)+", "+a(-this.pathOffset.y,t)+")"},toClipPathSVG:function(t){var e=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},toSVG:function(t){var e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var t,r,s=[],a=[],o=0,l=0,h=0,c=0,u=0,d=this.path.length;u"},addWithUpdate:function(t){var i=!!this.group;return this._restoreObjectsState(),e.util.resetObjectTransform(this),t&&(i&&e.util.removeTransformFromObject(t,this.group.calcTransformMatrix()),this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,i?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,i){var n=this._objects.length;if(this.useSetOnGroup)for(;n--;)this._objects[n].setOnGroup(t,i);if("canvas"===t)for(;n--;)this._objects[n]._set(t,i);e.Object.prototype._set.call(this,t,i)},toObject:function(t){var i=this.includeDefaultValues,n=this._objects.filter((function(t){return!t.excludeFromExport})).map((function(e){var n=e.includeDefaultValues;e.includeDefaultValues=i;var r=e.toObject(t);return e.includeDefaultValues=n,r})),r=e.Object.prototype.toObject.call(this,t);return r.objects=n,r},toDatalessObject:function(t){var i,n=this.sourcePath;if(n)i=n;else{var r=this.includeDefaultValues;i=this._objects.map((function(e){var i=e.includeDefaultValues;e.includeDefaultValues=r;var n=e.toDatalessObject(t);return e.includeDefaultValues=i,n}))}var s=e.Object.prototype.toDatalessObject.call(this,t);return s.objects=i,s},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=e.Object.prototype.shouldCache.call(this);if(t)for(var i=0,n=this._objects.length;i\n"],i=0,n=this._objects.length;i\n"),e},getSvgStyles:function(){var t=void 0!==this.opacity&&1!==this.opacity?"opacity: "+this.opacity+";":"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")},toClipPathSVG:function(t){for(var e=[],i=0,n=this._objects.length;i"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",t,e),void 0===(i=i||{}).hasControls&&(i.hasControls=!1),i.forActiveSelection=!0;for(var n=0,r=this._objects.length;n\n','\t\n',"\n"),a=' clip-path="url(#imageCrop_'+l+')" '}if(this.imageSmoothing||(o='" image-rendering="optimizeSpeed'),i.push("\t\n"),this.stroke||this.strokeDashArray){var h=this.fill;this.fill=null,t=["\t\n'],this.fill=h}return"fill"!==this.paintFirst?e.concat(t,i):e.concat(i,t)},getSrc:function(t){var e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src"):e.src:this.src||""},setSrc:function(t,e,i){return T.util.loadImage(t,(function(t,n){this.setElement(t,i),this._setWidthHeight(),e&&e(this,n)}),this,i&&i.crossOrigin),this},toString:function(){return'#'},applyResizeFilters:function(){var t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),n=i.scaleX,r=i.scaleY,s=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||n>e&&r>e)return this._element=s,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=n,void(this._lastScaleY=r);T.filterBackend||(T.filterBackend=T.initFilterBackend());var a=T.util.createCanvasElement(),o=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,l=s.width,h=s.height;a.width=l,a.height=h,this._element=a,this._lastScaleX=t.scaleX=n,this._lastScaleY=t.scaleY=r,T.filterBackend.applyFilters([t],s,l,h,this._element,o),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height},applyFilters:function(t){if(t=(t=t||this.filters||[]).filter((function(t){return t&&!t.isNeutralState()})),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),0===t.length)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var e=this._originalElement,i=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(this._element===this._originalElement){var r=T.util.createCanvasElement();r.width=i,r.height=n,this._element=r,this._filteredEl=r}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,n),this._lastScaleX=1,this._lastScaleY=1;return T.filterBackend||(T.filterBackend=T.initFilterBackend()),T.filterBackend.applyFilters(t,this._originalElement,i,n,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(t){T.util.setImageSmoothing(t,this.imageSmoothing),!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)},drawCacheOnCanvas:function(t){T.util.setImageSmoothing(t,this.imageSmoothing),T.Object.prototype.drawCacheOnCanvas.call(this,t)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(t){var e=this._element;if(e){var i=this._filterScalingX,n=this._filterScalingY,r=this.width,s=this.height,a=Math.min,o=Math.max,l=o(this.cropX,0),h=o(this.cropY,0),c=e.naturalWidth||e.width,u=e.naturalHeight||e.height,d=l*i,f=h*n,g=a(r*i,c-d),m=a(s*n,u-f),p=-r/2,_=-s/2,v=a(r,c/i-l),y=a(s,u/n-h);e&&t.drawImage(e,d,f,g,m,p,_,v,y)}},_needsResize:function(){var t=this.getTotalObjectScaling();return t.scaleX!==this._lastScaleX||t.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(t,e){this.setElement(T.util.getById(t),e),T.util.addClass(this.getElement(),T.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={}),this.setOptions(t),this._setWidthHeight(t)},_initFilters:function(t,e){t&&t.length?T.util.enlivenObjects(t,(function(t){e&&e(t)}),"fabric.Image.filters"):e&&e()},_setWidthHeight:function(t){t||(t={});var e=this.getElement();this.width=t.width||e.naturalWidth||e.width||0,this.height=t.height||e.naturalHeight||e.height||0},parsePreserveAspectRatioAttribute:function(){var t,e=T.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),i=this._element.width,n=this._element.height,r=1,s=1,a=0,o=0,l=0,h=0,c=this.width,u=this.height,d={width:c,height:u};return!e||"none"===e.alignX&&"none"===e.alignY?(r=c/i,s=u/n):("meet"===e.meetOrSlice&&(t=(c-i*(r=s=T.util.findScaleToFit(this._element,d)))/2,"Min"===e.alignX&&(a=-t),"Max"===e.alignX&&(a=t),t=(u-n*s)/2,"Min"===e.alignY&&(o=-t),"Max"===e.alignY&&(o=t)),"slice"===e.meetOrSlice&&(t=i-c/(r=s=T.util.findScaleToCover(this._element,d)),"Mid"===e.alignX&&(l=t/2),"Max"===e.alignX&&(l=t),t=n-u/s,"Mid"===e.alignY&&(h=t/2),"Max"===e.alignY&&(h=t),i=c/r,n=u/s)),{width:i,height:n,scaleX:r,scaleY:s,offsetLeft:a,offsetTop:o,cropX:l,cropY:h}}}),T.Image.CSS_CANVAS="canvas-img",T.Image.prototype.getSvgSrc=T.Image.prototype.getSrc,T.Image.fromObject=function(t,e){var i=T.util.object.clone(t);T.util.loadImage(i.src,(function(t,n){n?e&&e(null,!0):T.Image.prototype._initFilters.call(i,i.filters,(function(n){i.filters=n||[],T.Image.prototype._initFilters.call(i,[i.resizeFilter],(function(n){i.resizeFilter=n[0],T.util.enlivenObjectEnlivables(i,i,(function(){var n=new T.Image(t,i);e(n,!1)}))}))}))}),null,i.crossOrigin)},T.Image.fromURL=function(t,e,i){T.util.loadImage(t,(function(t,n){e&&e(new T.Image(t,i),n)}),null,i&&i.crossOrigin)},T.Image.ATTRIBUTE_NAMES=T.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),T.Image.fromElement=function(t,i,n){var r=T.parseAttributes(t,T.Image.ATTRIBUTE_NAMES);T.Image.fromURL(r["xlink:href"],i,e(n?T.util.object.clone(n):{},r))})}(e),T.util.object.extend(T.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.angle%360;return t>0?90*Math.round((t-1)/90):90*Math.round(t/90)},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(t){var e=function(){},i=(t=t||{}).onComplete||e,n=t.onChange||e,r=this;return T.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){r.rotate(t),n()},onComplete:function(){r.setCoords(),i()}})}}),T.util.object.extend(T.StaticCanvas.prototype,{straightenObject:function(t){return t.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(t){return t.fxStraighten({onChange:this.requestRenderAllBound})}}),function(){function t(t,e){var i="precision "+e+" float;\nvoid main(){}",n=t.createShader(t.FRAGMENT_SHADER);return t.shaderSource(n,i),t.compileShader(n),!!t.getShaderParameter(n,t.COMPILE_STATUS)}function e(t){t&&t.tileSize&&(this.tileSize=t.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}T.isWebglSupported=function(e){if(T.isLikelyNode)return!1;e=e||T.WebglFilterBackend.prototype.tileSize;var i=document.createElement("canvas"),n=i.getContext("webgl")||i.getContext("experimental-webgl"),r=!1;if(n){T.maxTextureSize=n.getParameter(n.MAX_TEXTURE_SIZE),r=T.maxTextureSize>=e;for(var s=["highp","mediump","lowp"],a=0;a<3;a++)if(t(n,s[a])){T.webGlPrecision=s[a];break}}return this.isSupported=r,r},T.WebglFilterBackend=e,e.prototype={tileSize:2048,resources:{},setupGLContext:function(t,e){this.dispose(),this.createWebGLCanvas(t,e),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(t,e)},chooseFastestCopyGLTo2DMethod:function(t,e){var i,n=void 0!==window.performance;try{new ImageData(1,1),i=!0}catch(t){i=!1}var r="undefined"!=typeof ArrayBuffer,s="undefined"!=typeof Uint8ClampedArray;if(n&&i&&r&&s){var a=T.util.createCanvasElement(),o=new ArrayBuffer(t*e*4);if(T.forceGLPutImageData)return this.imageBuffer=o,void(this.copyGLTo2D=x);var l,h,c={imageBuffer:o,destinationWidth:t,destinationHeight:e,targetCanvas:a};a.width=t,a.height=e,l=window.performance.now(),I.call(c,this.gl,c),h=window.performance.now()-l,l=window.performance.now(),x.call(c,this.gl,c),h>window.performance.now()-l?(this.imageBuffer=o,this.copyGLTo2D=x):this.copyGLTo2D=I}},createWebGLCanvas:function(t,e){var i=T.util.createCanvasElement();i.width=t,i.height=e;var n={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},r=i.getContext("webgl",n);r||(r=i.getContext("experimental-webgl",n)),r&&(r.clearColor(0,0,0,0),this.canvas=i,this.gl=r)},applyFilters:function(t,e,i,n,r,s){var a,o=this.gl;s&&(a=this.getCachedTexture(s,e));var l={originalWidth:e.width||e.originalWidth,originalHeight:e.height||e.originalHeight,sourceWidth:i,sourceHeight:n,destinationWidth:i,destinationHeight:n,context:o,sourceTexture:this.createTexture(o,i,n,!a&&e),targetTexture:this.createTexture(o,i,n),originalTexture:a||this.createTexture(o,i,n,!a&&e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},h=o.createFramebuffer();return o.bindFramebuffer(o.FRAMEBUFFER,h),t.forEach((function(t){t&&t.applyTo(l)})),function(t){var e=t.targetCanvas,i=e.width,n=e.height,r=t.destinationWidth,s=t.destinationHeight;i===r&&n===s||(e.width=r,e.height=s)}(l),this.copyGLTo2D(o,l),o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(l.sourceTexture),o.deleteTexture(l.targetTexture),o.deleteFramebuffer(h),r.getContext("2d").setTransform(1,0,0,1,0,0),l},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(t,e,i,n){var r=t.createTexture();return t.bindTexture(t.TEXTURE_2D,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,i,0,t.RGBA,t.UNSIGNED_BYTE,null),r},getCachedTexture:function(t,e){if(this.textureCache[t])return this.textureCache[t];var i=this.createTexture(this.gl,e.width,e.height,e);return this.textureCache[t]=i,i},evictCachesForKey:function(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])},copyGLTo2D:I,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var t=this.gl,e={renderer:"",vendor:""};if(!t)return e;var i=t.getExtension("WEBGL_debug_renderer_info");if(i){var n=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);n&&(e.renderer=n.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}}(),function(){var t=function(){};function e(){}T.Canvas2dFilterBackend=e,e.prototype={evictCachesForKey:t,dispose:t,clearWebGLCaches:t,resources:{},applyFilters:function(t,e,i,n,r){var s=r.getContext("2d");s.drawImage(e,0,0,i,n);var a={sourceWidth:i,sourceHeight:n,imageData:s.getImageData(0,0,i,n),originalEl:e,originalImageData:s.getImageData(0,0,i,n),canvasEl:r,ctx:s,filterBackend:this};return t.forEach((function(t){t.applyTo(a)})),a.imageData.width===i&&a.imageData.height===n||(r.width=a.imageData.width,r.height=a.imageData.height),s.putImageData(a.imageData,0,0),a}}}(),T.Image=T.Image||{},T.Image.filters=T.Image.filters||{},T.Image.filters.BaseFilter=T.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(t){t&&this.setOptions(t)},setOptions:function(t){for(var e in t)this[e]=t[e]},createProgram:function(t,e,i){e=e||this.fragmentSource,i=i||this.vertexSource,"highp"!==T.webGlPrecision&&(e=e.replace(/precision highp float/g,"precision "+T.webGlPrecision+" float"));var n=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+t.getShaderInfoLog(n));var r=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+t.getShaderInfoLog(r));var s=t.createProgram();if(t.attachShader(s,n),t.attachShader(s,r),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+t.getProgramInfoLog(s));var a=this.getAttributeLocations(t,s),o=this.getUniformLocations(t,s)||{};return o.uStepW=t.getUniformLocation(s,"uStepW"),o.uStepH=t.getUniformLocation(s,"uStepH"),{program:s,attributeLocations:a,uniformLocations:o}},getAttributeLocations:function(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(t,e,i){var n=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)},_setupFrameBuffer:function(t){var e,i,n=t.context;t.passes>1?(e=t.destinationWidth,i=t.destinationHeight,t.sourceWidth===e&&t.sourceHeight===i||(n.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(n,e,i)),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t.targetTexture,0)):(n.bindFramebuffer(n.FRAMEBUFFER,null),n.finish())},_swapTextures:function(t){t.passes--,t.pass++;var e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e},isNeutralState:function(){var t=this.mainParameter,e=T.Image.filters[this.type].prototype;if(t){if(Array.isArray(e[t])){for(var i=e[t].length;i--;)if(this[t][i]!==e[t][i])return!1;return!0}return e[t]===this[t]}return!1},applyTo:function(t){t.webgl?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},retrieveShader:function(t){return t.programCache.hasOwnProperty(this.type)||(t.programCache[this.type]=this.createProgram(t.context)),t.programCache[this.type]},applyToWebGL:function(t){var e=t.context,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)},unbindAdditionalTexture:function(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(t){this[this.mainParameter]=t},sendUniformData:function(){},createHelpLayer:function(t){if(!t.helpLayer){var e=document.createElement("canvas");e.width=t.sourceWidth,e.height=t.sourceHeight,t.helpLayer=e}},toObject:function(){var t={type:this.type},e=this.mainParameter;return e&&(t[e]=this[e]),t},toJSON:function(){return this.toObject()}}),T.Image.filters.BaseFilter.fromObject=function(t,e){var i=new T.Image.filters[t.type](t);return e&&e(i),i},function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.ColorMatrix=n(i.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var e,i,n,r,s,a=t.imageData.data,o=a.length,l=this.matrix,h=this.colorsOnly;for(s=0;s=w||a<0||a>=y||(l=4*(o*y+a),h=p[f*_+d],e+=m[l]*h,i+=m[l+1]*h,n+=m[l+2]*h,S||(r+=m[l+3]*h));C[s]=e,C[s+1]=i,C[s+2]=n,C[s+3]=S?m[s+3]:r}t.imageData=E},getUniformLocations:function(t,e){return{uMatrix:t.getUniformLocation(e,"uMatrix"),uOpaque:t.getUniformLocation(e,"uOpaque"),uHalfSize:t.getUniformLocation(e,"uHalfSize"),uSize:t.getUniformLocation(e,"uSize")}},sendUniformData:function(t,e){t.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),e.Image.filters.Convolute.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Grayscale=n(i.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(t){var e,i,n=t.imageData.data,r=n.length,s=this.mode;for(e=0;eh[0]&&r>h[1]&&s>h[2]&&n 0.0) {\n"+this.fragmentSource[t]+"}\n}"},retrieveShader:function(t){var e,i=this.type+"_"+this.mode;return t.programCache.hasOwnProperty(i)||(e=this.buildSource(this.mode),t.programCache[i]=this.createProgram(t.context,e)),t.programCache[i]},applyTo2d:function(t){var i,n,r,s,a,o,l,h=t.imageData.data,c=h.length,u=1-this.alpha;i=(l=new e.Color(this.color).getSource())[0]*this.alpha,n=l[1]*this.alpha,r=l[2]*this.alpha;for(var d=0;d=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;var i=(e*=Math.PI)/t;return o(e)/e*o(i)/i}},applyTo2d:function(t){var e=t.imageData,i=this.scaleX,n=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/n;var r,s=e.width,o=e.height,l=a(s*i),h=a(o*n);"sliceHack"===this.resizeType?r=this.sliceByTwo(t,s,o,l,h):"hermite"===this.resizeType?r=this.hermiteFastResize(t,s,o,l,h):"bilinear"===this.resizeType?r=this.bilinearFiltering(t,s,o,l,h):"lanczos"===this.resizeType&&(r=this.lanczosResize(t,s,o,l,h)),t.imageData=r},sliceByTwo:function(t,i,r,s,a){var o,l,h=t.imageData,c=.5,u=!1,d=!1,f=i*c,g=r*c,m=e.filterBackend.resources,p=0,_=0,v=i,y=0;for(m.sliceByTwo||(m.sliceByTwo=document.createElement("canvas")),((o=m.sliceByTwo).width<1.5*i||o.height=e)){L=n(1e3*s(T-E.x)),w[L]||(w[L]={});for(var F=C.y-y;F<=C.y+y;F++)F<0||F>=a||(M=n(1e3*s(F-E.y)),w[L][M]||(w[L][M]=f(r(i(L*p,2)+i(M*_,2))/1e3)),(b=w[L][M])>0&&(x+=b,R+=b*c[I=4*(F*e+T)],O+=b*c[I+1],D+=b*c[I+2],A+=b*c[I+3]))}d[I=4*(S*o+l)]=R/x,d[I+1]=O/x,d[I+2]=D/x,d[I+3]=A/x}return++l1&&M<-1||(y=2*M*M*M-3*M*M+1)>0&&(b+=y*f[3+(L=4*(A+x*e))],E+=y,f[L+3]<255&&(y=y*f[L+3]/250),C+=y*f[L],S+=y*f[L+1],T+=y*f[L+2],w+=y)}m[v]=C/w,m[v+1]=S/w,m[v+2]=T/w,m[v+3]=b/E}return g},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),e.Image.filters.Resize.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Contrast=n(i.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(t){if(0!==this.contrast){var e,i=t.imageData.data,n=i.length,r=Math.floor(255*this.contrast),s=259*(r+255)/(255*(259-r));for(e=0;e1&&(e=1/this.aspectRatio):this.aspectRatio<1&&(e=this.aspectRatio),t=e*this.blur*.12,this.horizontal?i[0]=t:i[1]=t,i}}),i.Blur.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Gamma=n(i.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],i.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var e,i=t.imageData.data,n=this.gamma,r=i.length,s=1/n[0],a=1/n[1],o=1/n[2];for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),e=0,r=256;e'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t},_render:function(t){var e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){"stroke"===this.paintFirst?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,e,i){if(t.textBaseline="alphabetical",this.path)switch(this.pathAlign){case"center":t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline="bottom"}t.font=this._getFontDeclaration(e,i)},calcTextWidth:function(){for(var t=this.getLineWidth(0),e=1,i=this._textLines.length;et&&(t=n)}return t},_renderTextLine:function(t,e,i,n,r,s){this._renderChars(t,e,i,n,r,s)},_renderTextLinesBackground:function(t){if(this.textBackgroundColor||this.styleHas("textBackgroundColor")){for(var e,i,n,r,s,a,o,l=t.fillStyle,h=this._getLeftOffset(),c=this._getTopOffset(),u=0,d=0,f=this.path,g=0,m=this._textLines.length;g=0:io?u%=o:u<0&&(u+=o),this._setGraphemeOnPath(u,s,a),u+=s.kernedWidth}return{width:l,numOfSpaces:0}},_setGraphemeOnPath:function(t,i,n){var r=t+i.kernedWidth/2,s=this.path,a=e.util.getPointOnPath(s.path,r,s.segmentsInfo);i.renderLeft=a.x-n.x,i.renderTop=a.y-n.y,i.angle=a.angle+("right"===this.pathSide?Math.PI:0)},_getGraphemeBox:function(t,e,i,n,r){var s,a=this.getCompleteStyleDeclaration(e,i),o=n?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,a,n,o),h=l.kernedWidth,c=l.width;0!==this.charSpacing&&(c+=s=this._getWidthOfCharSpacing(),h+=s);var u={width:c,left:0,height:a.fontSize,kernedWidth:h,deltaY:a.deltaY};if(i>0&&!r){var d=this.__charBounds[e][i-1];u.left=d.left+d.width+l.kernedWidth-l.width}return u},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var e=this._textLines[t],i=this.getHeightOfChar(t,0),n=1,r=e.length;n0){var x=v+s+u;"rtl"===this.direction&&(x=this.width-x-d),h&&_&&(t.fillStyle=_,t.fillRect(x,c+C*n+a,d,this.fontSize/15)),u=f.left,d=f.width,h=g,_=p,n=r,a=o}else d+=f.kernedWidth;x=v+s+u,"rtl"===this.direction&&(x=this.width-x-d),t.fillStyle=p,g&&p&&t.fillRect(x,c+C*n+a,d-E,this.fontSize/15),y+=i}else y+=i;this._removeShadow(t)}},_getFontDeclaration:function(t,i){var n=t||this,r=this.fontFamily,s=e.Text.genericFonts.indexOf(r.toLowerCase())>-1,a=void 0===r||r.indexOf("'")>-1||r.indexOf(",")>-1||r.indexOf('"')>-1||s?n.fontFamily:'"'+n.fontFamily+'"';return[e.isLikelyNode?n.fontWeight:n.fontStyle,e.isLikelyNode?n.fontStyle:n.fontWeight,i?this.CACHE_FONT_SIZE+"px":n.fontSize+"px",a].join(" ")},render:function(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t)))},_splitTextIntoLines:function(t){for(var i=t.split(this._reNewline),n=new Array(i.length),r=["\n"],s=[],a=0;a-1&&(t.underline=!0),t.textDecoration.indexOf("line-through")>-1&&(t.linethrough=!0),t.textDecoration.indexOf("overline")>-1&&(t.overline=!0),delete t.textDecoration)}T.IText=T.util.createClass(T.Text,T.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(t,e){this.callSuper("initialize",t,e),this.initBehavior()},setSelectionStart:function(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)},setSelectionEnd:function(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)},_updateAndFire:function(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(t){this.clearContextTop(),this.callSuper("render",t),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(t){this.callSuper("_render",t)},clearContextTop:function(t){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var e=this.canvas.contextTop,i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e),this._clearTextArea(e),t||e.restore()}},renderCursorOrSelection:function(){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var t=this._getCursorBoundaries(),e=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(t,e):this.renderSelection(t,e),e.restore()}},_clearTextArea:function(t){var e=this.width+4,i=this.height+4;t.clearRect(-e/2,-i/2,e,i)},_getCursorBoundaries:function(t){void 0===t&&(t=this.selectionStart);var e=this._getLeftOffset(),i=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t);return{left:e,top:i,leftOffset:n.left,topOffset:n.top}},_getCursorBoundariesOffsets:function(t){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var e,i,n,r,s=0,a=0,o=this.get2DCursorLocation(t);n=o.charIndex,i=o.lineIndex;for(var l=0;l0?a:0)},"rtl"===this.direction&&(r.left*=-1),this.cursorOffsetCache=r,this.cursorOffsetCache},renderCursor:function(t,e){var i=this.get2DCursorLocation(),n=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,s=this.getValueOfPropertyAt(n,r,"fontSize"),a=this.scaleX*this.canvas.getZoom(),o=this.cursorWidth/a,l=t.topOffset,h=this.getValueOfPropertyAt(n,r,"deltaY");l+=(1-this._fontSizeFraction)*this.getHeightOfLine(n)/this.lineHeight-s*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(t,e),e.fillStyle=this.cursorColor||this.getValueOfPropertyAt(n,r,"fill"),e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,e.fillRect(t.left+t.leftOffset-o/2,l+t.top+h,o,s)},renderSelection:function(t,e){for(var i=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,n=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,r=-1!==this.textAlign.indexOf("justify"),s=this.get2DCursorLocation(i),a=this.get2DCursorLocation(n),o=s.lineIndex,l=a.lineIndex,h=s.charIndex<0?0:s.charIndex,c=a.charIndex<0?0:a.charIndex,u=o;u<=l;u++){var d,f=this._getLineLeftOffset(u)||0,g=this.getHeightOfLine(u),m=0,p=0;if(u===o&&(m=this.__charBounds[o][h].left),u>=o&&u1)&&(g/=this.lineHeight);var v=t.left+f+m,y=p-m,w=g,E=0;this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",w=1,E=g):e.fillStyle=this.selectionColor,"rtl"===this.direction&&(v=this.width-v-y),e.fillRect(v,t.top+t.topOffset+E,y,w),t.topOffset+=d}},getCurrentCharFontSize:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")},getCurrentCharColor:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fill")},_getCurrentCharIndex:function(){var t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}}),T.IText.fromObject=function(e,i){if(t(e),e.styles)for(var n in e.styles)for(var r in e.styles[n])t(e.styles[n][r]);T.Object._fromObject("IText",e,i,"text")}}(),S=T.util.object.clone,T.util.object.extend(T.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var t=this;this.on("added",(function(){var e=t.canvas;e&&(e._hasITextHandlers||(e._hasITextHandlers=!0,t._initCanvasHandlers(e)),e._iTextInstances=e._iTextInstances||[],e._iTextInstances.push(t))}))},initRemovedHandler:function(){var t=this;this.on("removed",(function(){var e=t.canvas;e&&(e._iTextInstances=e._iTextInstances||[],T.util.removeFromArray(e._iTextInstances,t),0===e._iTextInstances.length&&(e._hasITextHandlers=!1,t._removeCanvasHandlers(e)))}))},_initCanvasHandlers:function(t){t._mouseUpITextHandler=function(){t._iTextInstances&&t._iTextInstances.forEach((function(t){t.__isMousedown=!1}))},t.on("mouse:up",t._mouseUpITextHandler)},_removeCanvasHandlers:function(t){t.off("mouse:up",t._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,n){var r;return r={isAborted:!1,abort:function(){this.isAborted=!0}},t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){r.isAborted||t[n]()},onChange:function(){t.canvas&&t.selectionStart===t.selectionEnd&&t.renderCursorOrSelection()},abort:function(){return r.isAborted}}),r},_onTickComplete:function(){var t=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout((function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")}),100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout((function(){e._tick()}),i)},abortCursorAnimation:function(){var t=this._currentTickState||this._currentTickCompleteState,e=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,t&&e&&e.clearContext(e.contextTop||e.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i-1;)e++,i--;return t-e},findLineBoundaryRight:function(t){for(var e=0,i=t;!/\n/.test(this._text[i])&&i0&&nthis.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=e):(this.selectionStart=e,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===n||(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(t,e,i){var n=i.slice(0,t),r=T.util.string.graphemeSplit(n).length;if(t===e)return{selectionStart:r,selectionEnd:r};var s=i.slice(t,e);return{selectionStart:r,selectionEnd:r+T.util.string.graphemeSplit(s).length}},fromGraphemeToStringSelection:function(t,e,i){var n=i.slice(0,t).join("").length;return t===e?{selectionStart:n,selectionEnd:n}:{selectionStart:n,selectionEnd:n+i.slice(t,e).join("").length}},_updateTextarea:function(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){var t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var t=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=t.selectionEnd,this.inCompositionMode||(this.selectionStart=t.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),n=i.lineIndex,r=i.charIndex,s=this.getValueOfPropertyAt(n,r,"fontSize")*this.lineHeight,a=e.leftOffset,o=this.calcTransformMatrix(),l={x:e.left+a,y:e.top+e.topOffset+s},h=this.canvas.getRetinaScaling(),c=this.canvas.upperCanvasEl,u=c.width/h,d=c.height/h,f=u-s,g=d-s,m=c.clientWidth/u,p=c.clientHeight/d;return l=T.util.transformPoint(l,o),(l=T.util.transformPoint(l,this.canvas.viewportTransform)).x*=m,l.y*=p,l.x<0&&(l.x=0),l.x>f&&(l.x=f),l.y<0&&(l.y=0),l.y>g&&(l.y=g),l.x+=this.canvas._offset.left,l.y+=this.canvas._offset.top,{left:l.x+"px",top:l.y+"px",fontSize:s+"px",charHeight:s}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var t=this._textBeforeEdit!==this.text,e=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var t in this.styles)this._textLines[t]||delete this.styles[t]},removeStyleFromTo:function(t,e){var i,n,r=this.get2DCursorLocation(t,!0),s=this.get2DCursorLocation(e,!0),a=r.lineIndex,o=r.charIndex,l=s.lineIndex,h=s.charIndex;if(a!==l){if(this.styles[a])for(i=o;i=h&&(n[c-d]=n[u],delete n[u])}},shiftLineStyles:function(t,e){var i=S(this.styles);for(var n in this.styles){var r=parseInt(n,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}},restartCursorIfNeeded:function(){this._currentTickState&&!this._currentTickState.isAborted&&this._currentTickCompleteState&&!this._currentTickCompleteState.isAborted||this.initDelayedCursor()},insertNewlineStyleObject:function(t,e,i,n){var r,s={},a=!1,o=this._unwrappedTextLines[t].length===e;for(var l in i||(i=1),this.shiftLineStyles(t,i),this.styles[t]&&(r=this.styles[t][0===e?e:e-1]),this.styles[t]){var h=parseInt(l,10);h>=e&&(a=!0,s[h-e]=this.styles[t][l],o&&0===e||delete this.styles[t][l])}var c=!1;for(a&&!o&&(this.styles[t+i]=s,c=!0),c&&i--;i>0;)n&&n[i-1]?this.styles[t+i]={0:S(n[i-1])}:r?this.styles[t+i]={0:S(r)}:delete this.styles[t+i],i--;this._forceClearCache=!0},insertCharStyleObject:function(t,e,i,n){this.styles||(this.styles={});var r=this.styles[t],s=r?S(r):{};for(var a in i||(i=1),s){var o=parseInt(a,10);o>=e&&(r[o+i]=s[o],s[o-i]||delete r[o])}if(this._forceClearCache=!0,n)for(;i--;)Object.keys(n[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=S(n[i]));else if(r)for(var l=r[e?e-1:1];l&&i--;)this.styles[t][e+i]=S(l)},insertNewStyleBlock:function(t,e,i){for(var n=this.get2DCursorLocation(e,!0),r=[0],s=0,a=0;a0&&(this.insertCharStyleObject(n.lineIndex,n.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),s&&this.insertNewlineStyleObject(n.lineIndex,n.charIndex+r[0],s),a=1;a0?this.insertCharStyleObject(n.lineIndex+a,0,r[a],i):i&&this.styles[n.lineIndex+a]&&i[0]&&(this.styles[n.lineIndex+a][0]=i[0]),i=i&&i.slice(r[a]+1);r[a]>0&&this.insertCharStyleObject(n.lineIndex+a,0,r[a],i)},setSelectionStartEndWithShift:function(t,e,i){i<=t?(e===t?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=t),this.selectionStart=i):i>t&&it?this.selectionStart=t:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>t?this.selectionEnd=t:this.selectionEnd<0&&(this.selectionEnd=0)}}),T.util.object.extend(T.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(t){if(this.canvas){this.__newClickTime=+new Date;var e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),this._stopEvent(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))},tripleClickHandler:function(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(t.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(t){if(this.__isMousedown=!1,!(!this.editable||this.group||t.transform&&t.transform.actionPerformed||t.e.button&&1!==t.e.button)){if(this.canvas){var e=this.canvas._activeObject;if(e&&e!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(t.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t),i=this.selectionStart,n=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,n,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(t){for(var e,i=this.getLocalPointer(t),n=0,r=0,s=0,a=0,o=0,l=0,h=this._textLines.length;l0&&(a+=this._textLines[l-1].length+this.missingNewlineOffset(l-1));r=this._getLineLeftOffset(o)*this.scaleX,e=this._textLines[o],"rtl"===this.direction&&(i.x=this.width*this.scaleX-i.x+r);for(var c=0,u=e.length;cs||a<0?0:1);return this.flipX&&(o=r-o),o>this._text.length&&(o=this._text.length),o}}),T.util.object.extend(T.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=T.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var t=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+t.top+"; left: "+t.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; paddingーtop: "+t.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):T.document.body.appendChild(this.hiddenTextarea),T.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),T.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),T.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),T.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),T.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),T.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(T.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(this.isEditing){var e="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())},onInput:function(t){var e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),this.isEditing){var i,n,r,s,a,o=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,l=this._text.length,h=o.length,c=h-l,u=this.selectionStart,d=this.selectionEnd,f=u!==d;if(""===this.hiddenTextarea.value)return this.styles={},this.updateFromTextArea(),this.fire("changed"),void(this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll()));var g=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),m=u>g.selectionStart;f?(i=this._text.slice(u,d),c+=d-u):h0&&(n+=(i=this.__charBounds[t][e-1]).left+i.width),n},getDownCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(r===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;var s=n.charIndex,a=this._getWidthBeforeCursor(r,s),o=this._getIndexOnLine(r+1,a);return this._textLines[r].slice(s).length+o+1+this.missingNewlineOffset(r)},_getSelectionForOffset:function(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(0===r||t.metaKey||33===t.keyCode)return-i;var s=n.charIndex,a=this._getWidthBeforeCursor(r,s),o=this._getIndexOnLine(r-1,a),l=this._textLines[r].slice(0,s),h=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+o-l.length+(1-h)},_getIndexOnLine:function(t,e){for(var i,n,r=this._textLines[t],s=this._getLineLeftOffset(t),a=0,o=0,l=r.length;oe){n=!0;var h=s-i,c=s,u=Math.abs(h-e);a=Math.abs(c-e)=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)},moveCursorUp:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)},_moveCursorUpOrDown:function(t,e){var i=this["get"+t+"CursorOffset"](e,"right"===this._selectionDirection);e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(t){var e="left"===this._selectionDirection?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t},moveCursorWithoutShift:function(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t},moveCursorLeft:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)},_move:function(t,e,i){var n;if(t.altKey)n=this["findWordBoundary"+i](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;n=this["findLineBoundary"+i](this[e])}if(void 0!==typeof n&&this[e]!==n)return this[e]=n,!0},_moveLeft:function(t,e){return this._move(t,e,"Left")},_moveRight:function(t,e){return this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){var e=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e},moveCursorLeftWithShift:function(t){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(t,"selectionStart")):void 0},moveCursorRight:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)},_moveCursorLeftOrRight:function(t,e){var i="moveCursor"+t+"With";this._currentCursorOpacity=1,e.shiftKey?i+="Shift":i+="outShift",this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(t){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection="right",this._moveRight(t,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(t){var e=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e},removeChars:function(t,e){void 0===e&&(e=t+1),this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(t,e,i,n){void 0===n&&(n=i),n>i&&this.removeStyleFromTo(i,n);var r=T.util.string.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[].concat(this._text.slice(0,i),r,this._text.slice(n)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),function(){var t=T.util.toFixed,e=/ +/g;T.util.object.extend(T.Text.prototype,{_toSVG:function(){var t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(t){var e=this.getSvgTextDecoration(this);return[t.textBgRects.join(""),'\t\t",t.textSpans.join(""),"\n"]},_getSVGTextAndBg:function(t,e){var i,n=[],r=[],s=t;this._setSVGBg(r);for(var a=0,o=this._textLines.length;a",T.util.string.escapeXml(i),""].join("")},_setSVGTextLineText:function(t,e,i,n){var r,s,a,o,l,h=this.getHeightOfLine(e),c=-1!==this.textAlign.indexOf("justify"),u="",d=0,f=this._textLines[e];n+=h*(1-this._fontSizeFraction)/this.lineHeight;for(var g=0,m=f.length-1;g<=m;g++)l=g===m||this.charSpacing,u+=f[g],a=this.__charBounds[e][g],0===d?(i+=a.kernedWidth-a.width,d+=a.width):d+=a.kernedWidth,c&&!l&&this._reSpaceAndTab.test(f[g])&&(l=!0),l||(r=r||this.getCompleteStyleDeclaration(e,g),s=this.getCompleteStyleDeclaration(e,g+1),l=this._hasStyleChangedForSvg(r,s)),l&&(o=this._getStyleDeclaration(e,g)||{},t.push(this._createTextCharSpan(u,o,i,n)),u="",r=s,i+=d,d=0)},_pushTextBgRect:function(e,i,n,r,s,a){var o=T.Object.NUM_FRACTION_DIGITS;e.push("\t\t\n')},_setSVGTextLineBg:function(t,e,i,n){for(var r,s,a=this._textLines[e],o=this.getHeightOfLine(e)/this.lineHeight,l=0,h=0,c=this.getValueOfPropertyAt(e,0,"textBackgroundColor"),u=0,d=a.length;uthis.width&&this._set("width",this.dynamicMinWidth),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(t){for(var e=0,i=0,n=0,r={},s=0;s0?(i=0,n++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[n])&&s>0&&(i++,n++),r[s]={line:e,offset:i},n+=t.graphemeLines[s].length,i+=t.graphemeLines[s].length;return r},styleHas:function(t,i){if(this._styleMap&&!this.isWrapping){var n=this._styleMap[i];n&&(i=n.line)}return e.Text.prototype.styleHas.call(this,t,i)},isEmptyStyles:function(t){if(!this.styles)return!0;var e,i,n=0,r=!1,s=this._styleMap[t],a=this._styleMap[t+1];for(var o in s&&(t=s.line,n=s.offset),a&&(r=a.line===t,e=a.offset),i=void 0===t?this.styles:{line:this.styles[t]})for(var l in i[o])if(l>=n&&(!r||ln&&!p?(o.push(l),l=[],s=f,p=!0):s+=_,p||a||l.push(d),l=l.concat(c),g=a?0:this._measureWord([d],i,u),u++,p=!1,f>m&&(m=f);return v&&o.push(l),m+r>this.dynamicMinWidth&&(this.dynamicMinWidth=m-_+r),o},isEndOfWrapping:function(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line},missingNewlineOffset:function(t){return this.splitByGrapheme?this.isEndOfWrapping(t)?1:0:1},_splitTextIntoLines:function(t){for(var i=e.Text.prototype._splitTextIntoLines.call(this,t),n=this._wrapText(i.lines,this.width),r=new Array(n.length),s=0;s{},898:()=>{},245:()=>{}},Qe={};function ti(t){var e=Qe[t];if(void 0!==e)return e.exports;var i=Qe[t]={exports:{}};return $e[t](i,i.exports,ti),i.exports}ti.d=(t,e)=>{for(var i in e)ti.o(e,i)&&!ti.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},ti.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var ei={};(()=>{let t;ti.d(ei,{R:()=>t}),t="undefined"!=typeof document&&"undefined"!=typeof window?ti(653).fabric:{version:"5.2.1"}})();var ii,ni,ri,si,ai=ei.R;!function(t){t[t.DIMT_RECTANGLE=1]="DIMT_RECTANGLE",t[t.DIMT_QUADRILATERAL=2]="DIMT_QUADRILATERAL",t[t.DIMT_TEXT=4]="DIMT_TEXT",t[t.DIMT_ARC=8]="DIMT_ARC",t[t.DIMT_IMAGE=16]="DIMT_IMAGE",t[t.DIMT_POLYGON=32]="DIMT_POLYGON",t[t.DIMT_LINE=64]="DIMT_LINE",t[t.DIMT_GROUP=128]="DIMT_GROUP"}(ii||(ii={})),function(t){t[t.DIS_DEFAULT=1]="DIS_DEFAULT",t[t.DIS_SELECTED=2]="DIS_SELECTED"}(ni||(ni={})),function(t){t[t.EF_ENHANCED_FOCUS=4]="EF_ENHANCED_FOCUS",t[t.EF_AUTO_ZOOM=16]="EF_AUTO_ZOOM",t[t.EF_TAP_TO_FOCUS=64]="EF_TAP_TO_FOCUS"}(ri||(ri={})),function(t){t.GREY="grey",t.GREY32="grey32",t.RGBA="rgba",t.RBGA="rbga",t.GRBA="grba",t.GBRA="gbra",t.BRGA="brga",t.BGRA="bgra"}(si||(si={}));const oi=t=>"number"==typeof t&&!Number.isNaN(t),li=t=>"string"==typeof t;var hi,ci,ui,di,fi,gi,mi,pi,_i,vi,yi;!function(t){t[t.ARC=0]="ARC",t[t.IMAGE=1]="IMAGE",t[t.LINE=2]="LINE",t[t.POLYGON=3]="POLYGON",t[t.QUAD=4]="QUAD",t[t.RECT=5]="RECT",t[t.TEXT=6]="TEXT",t[t.GROUP=7]="GROUP"}(fi||(fi={})),function(t){t[t.DEFAULT=0]="DEFAULT",t[t.SELECTED=1]="SELECTED"}(gi||(gi={}));class wi{get mediaType(){return new Map([["rect",ii.DIMT_RECTANGLE],["quad",ii.DIMT_QUADRILATERAL],["text",ii.DIMT_TEXT],["arc",ii.DIMT_ARC],["image",ii.DIMT_IMAGE],["polygon",ii.DIMT_POLYGON],["line",ii.DIMT_LINE],["group",ii.DIMT_GROUP]]).get(this._mediaType)}get styleSelector(){switch(He(this,ci,"f")){case ni.DIS_DEFAULT:return"default";case ni.DIS_SELECTED:return"selected"}}set drawingStyleId(t){this.styleId=t}get drawingStyleId(){return this.styleId}set coordinateBase(t){if(!["view","image"].includes(t))throw new Error("Invalid 'coordinateBase'.");this._drawingLayer&&("image"===He(this,ui,"f")&&"view"===t?this.updateCoordinateBaseFromImageToView():"view"===He(this,ui,"f")&&"image"===t&&this.updateCoordinateBaseFromViewToImage()),Xe(this,ui,t)}get coordinateBase(){return He(this,ui,"f")}get drawingLayerId(){return this._drawingLayerId}constructor(t,e){if(hi.add(this),ci.set(this,void 0),ui.set(this,"image"),this._zIndex=null,this._drawingLayer=null,this._drawingLayerId=null,this._mapState_StyleId=new Map,this.mapEvent_Callbacks=new Map([["selected",new Map],["deselected",new Map],["mousedown",new Map],["mouseup",new Map],["dblclick",new Map],["mouseover",new Map],["mouseout",new Map]]),this.mapNoteName_Content=new Map([]),this.isDrawingItem=!0,null!=e&&!oi(e))throw new TypeError("Invalid 'drawingStyleId'.");t&&this._setFabricObject(t),this.setState(ni.DIS_DEFAULT),this.styleId=e}_setFabricObject(t){this._fabricObject=t,this._fabricObject.on("selected",(()=>{this.setState(ni.DIS_SELECTED)})),this._fabricObject.on("deselected",(()=>{this._fabricObject.canvas&&this._fabricObject.canvas.getActiveObjects().includes(this._fabricObject)?this.setState(ni.DIS_SELECTED):this.setState(ni.DIS_DEFAULT),"textbox"===this._fabricObject.type&&(this._fabricObject.isEditing&&this._fabricObject.exitEditing(),this._fabricObject.selected=!1)})),t.getDrawingItem=()=>this}_getFabricObject(){return this._fabricObject}setState(t){Xe(this,ci,t)}getState(){return He(this,ci,"f")}_on(t,e){if(!e)return;const i=t.toLowerCase(),n=this.mapEvent_Callbacks.get(i);if(!n)throw new Error(`Event '${t}' does not exist.`);let r=n.get(e);r||(r=t=>{const i=t.e;if(!i)return void(e&&e.apply(this,[{targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null}]));const n={targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null};if(this._drawingLayer){let t,e,r,s;const a=i.target.getBoundingClientRect();t=a.left,e=a.top,r=t+window.scrollX,s=e+window.scrollY;const{width:o,height:l}=this._drawingLayer.fabricCanvas.lowerCanvasEl.getBoundingClientRect(),h=this._drawingLayer.width,c=this._drawingLayer.height,u=o/l,d=h/c,f=this._drawingLayer._getObjectFit();let g,m,p,_,v=1;if("contain"===f)u0?i-1:n,Ti),actionName:"modifyPolygon",pointIndex:i}),t}),{}),Xe(this,pi,JSON.parse(JSON.stringify(t))),this._mediaType="polygon"}extendSet(t,e){if("vertices"===t){const t=this._fabricObject;if(t.group){const i=t.group;t.points=e.map((t=>({x:t.x-i.left-i.width/2,y:t.y-i.top-i.height/2}))),i.addWithUpdate()}else t.points=e;const i=t.points.length-1;return t.controls=t.points.reduce((function(t,e,n){return t["p"+n]=new ai.Control({positionHandler:Ci,actionHandler:bi(n>0?n-1:i,Ti),actionName:"modifyPolygon",pointIndex:n}),t}),{}),t._setPositionDimensions({}),!0}}extendGet(t){if("vertices"===t){const t=[],e=this._fabricObject;if(e.selectable&&!e.group)for(let i in e.oCoords)t.push({x:e.oCoords[i].x,y:e.oCoords[i].y});else for(let i of e.points){let n=i.x-e.pathOffset.x,r=i.y-e.pathOffset.y;const s=ai.util.transformPoint({x:n,y:r},e.calcTransformMatrix());t.push({x:s.x,y:s.y})}return t}}updateCoordinateBaseFromImageToView(){const t=this.get("vertices").map((t=>({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",t)}updateCoordinateBaseFromViewToImage(){const t=this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})));this.set("vertices",t)}setPosition(t){this.setPolygon(t)}getPosition(){return this.getPolygon()}updatePosition(){He(this,pi,"f")&&this.setPolygon(He(this,pi,"f"))}setPolygon(t){if(!T(t))throw new TypeError("Invalid 'polygon'.");if(this._drawingLayer){if("view"===this.coordinateBase){const e=t.points.map((t=>({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",e)}else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("vertices",t.points)}this._drawingLayer.renderAll()}else Xe(this,pi,JSON.parse(JSON.stringify(t)))}getPolygon(){if(this._drawingLayer){if("view"===this.coordinateBase)return{points:this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})))};if("image"===this.coordinateBase)return{points:this.get("vertices")};throw new Error("Invalid 'coordinateBase'.")}return He(this,pi,"f")?JSON.parse(JSON.stringify(He(this,pi,"f"))):null}}pi=new WeakMap;_i=new WeakMap,vi=new WeakMap;const xi=t=>{let e=(t=>t.split("\n").map((t=>t.split("\t"))))(t);return(t=>{for(let e=0;;e++){let i=-1;for(let n=0;ni&&(i=r.length)}if(-1===i)break;for(let n=0;n=t[n].length-1)continue;let r=" ".repeat(i+2-t[n][e].length);t[n][e]=t[n][e].concat(r)}}})(e),(t=>{let e="";for(let i=0;i({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",e)}else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("vertices",t.points)}this._drawingLayer.renderAll()}else Xe(this,Di,JSON.parse(JSON.stringify(t)))}getQuad(){if(this._drawingLayer){if("view"===this.coordinateBase)return{points:this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})))};if("image"===this.coordinateBase)return{points:this.get("vertices")};throw new Error("Invalid 'coordinateBase'.")}return He(this,Di,"f")?JSON.parse(JSON.stringify(He(this,Di,"f"))):null}}Di=new WeakMap;class Li extends wi{constructor(t){super(new ai.Group(t.map((t=>t._getFabricObject())))),this._fabricObject.on("selected",(()=>{this.setState(ni.DIS_SELECTED);const t=this._fabricObject._objects;for(let e of t)setTimeout((()=>{e&&e.fire("selected")}),0);setTimeout((()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())}),0)})),this._fabricObject.on("deselected",(()=>{this.setState(ni.DIS_DEFAULT);const t=this._fabricObject._objects;for(let e of t)setTimeout((()=>{e&&e.fire("deselected")}),0);setTimeout((()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())}),0)})),this._mediaType="group"}extendSet(t,e){return!1}extendGet(t){}updateCoordinateBaseFromImageToView(){}updateCoordinateBaseFromViewToImage(){}setPosition(){}getPosition(){}updatePosition(){}getChildDrawingItems(){return this._fabricObject._objects.map((t=>t.getDrawingItem()))}setChildDrawingItems(t){if(!t||!t.isDrawingItem)throw TypeError("Illegal drawing item.");this._drawingLayer?this._drawingLayer._updateGroupItem(this,t,"add"):this._fabricObject.addWithUpdate(t._getFabricObject())}removeChildItem(t){t&&t.isDrawingItem&&(this._drawingLayer?this._drawingLayer._updateGroupItem(this,t,"remove"):this._fabricObject.removeWithUpdate(t._getFabricObject()))}}const Mi=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),Fi=t=>!!li(t)&&""!==t,Pi=t=>!(!Mi(t)||"id"in t&&!oi(t.id)||"lineWidth"in t&&!oi(t.lineWidth)||"fillStyle"in t&&!Fi(t.fillStyle)||"strokeStyle"in t&&!Fi(t.strokeStyle)||"paintMode"in t&&!["fill","stroke","strokeAndFill"].includes(t.paintMode)||"fontFamily"in t&&!Fi(t.fontFamily)||"fontSize"in t&&!oi(t.fontSize));class ki{static convert(t,e,i){const n={x:0,y:0,width:e,height:i};if(!t)return n;if(I(t))t.isMeasuredInPercentage?(n.x=t.x/100*e,n.y=t.y/100*i,n.width=t.width/100*e,n.height=t.height/100*i):(n.x=t.x,n.y=t.y,n.width=t.width,n.height=t.height);else{if(!w(t))throw TypeError("Invalid region.");t.isMeasuredInPercentage?(n.x=t.left/100*e,n.y=t.top/100*i,n.width=(t.right-t.left)/100*e,n.height=(t.bottom-t.top)/100*i):(n.x=t.left,n.y=t.top,n.width=t.right-t.left,n.height=t.bottom-t.top)}return n.x=Math.round(n.x),n.y=Math.round(n.y),n.width=Math.round(n.width),n.height=Math.round(n.height),n}}var Ni,Bi;class Vi{constructor(){Ni.set(this,new Map),Bi.set(this,!1)}get disposed(){return He(this,Bi,"f")}on(t,e){t=t.toLowerCase();const i=He(this,Ni,"f").get(t);if(i){if(i.includes(e))return;i.push(e)}else He(this,Ni,"f").set(t,[e])}off(t,e){t=t.toLowerCase();const i=He(this,Ni,"f").get(t);if(!i)return;const n=i.indexOf(e);-1!==n&&i.splice(n,1)}offAll(t){t=t.toLowerCase();const e=He(this,Ni,"f").get(t);e&&(e.length=0)}fire(t,e=[],i={async:!1,copy:!0}){e||(e=[]),t=t.toLowerCase();const n=He(this,Ni,"f").get(t);if(n&&n.length){i=Object.assign({async:!1,copy:!0},i);for(let r of n){if(!r)continue;let s=[];if(i.copy)for(let i of e){try{i=JSON.parse(JSON.stringify(i))}catch(t){}s.push(i)}else s=e;let a=!1;if(i.async)setTimeout((()=>{this.disposed||n.includes(r)&&r.apply(i.target,s)}),0);else try{a=r.apply(i.target,s)}catch(t){}if(!0===a)break}}}dispose(){Xe(this,Bi,!0)}}function ji(t,e,i){return(i.x-t.x)*(e.y-t.y)==(e.x-t.x)*(i.y-t.y)&&Math.min(t.x,e.x)<=i.x&&i.x<=Math.max(t.x,e.x)&&Math.min(t.y,e.y)<=i.y&&i.y<=Math.max(t.y,e.y)}function Ui(t){return Math.abs(t)<1e-6?0:t<0?-1:1}function Gi(t,e,i,n){let r=t[0]*(i[1]-e[1])+e[0]*(t[1]-i[1])+i[0]*(e[1]-t[1]),s=t[0]*(n[1]-e[1])+e[0]*(t[1]-n[1])+n[0]*(e[1]-t[1]);return!((r^s)>=0&&0!==r&&0!==s||(r=i[0]*(t[1]-n[1])+n[0]*(i[1]-t[1])+t[0]*(n[1]-i[1]),s=i[0]*(e[1]-n[1])+n[0]*(i[1]-e[1])+e[0]*(n[1]-i[1]),(r^s)>=0&&0!==r&&0!==s))}Ni=new WeakMap,Bi=new WeakMap;const Wi=async t=>{if("string"!=typeof t)throw new TypeError("Invalid url.");const e=await fetch(t);if(!e.ok)throw Error("Network Error: "+e.statusText);const i=await e.text();if(!i.trim().startsWith("<"))throw Error("Unable to get valid HTMLElement.");const n=document.createElement("div");if(n.insertAdjacentHTML("beforeend",i),1===n.childElementCount&&n.firstChild instanceof HTMLTemplateElement)return n.firstChild.content;const r=new DocumentFragment;for(let t of n.children)r.append(t);return r};var Yi,zi,Hi,Xi,Zi,qi,Ji,Ki,$i,Qi,tn,en,nn,rn,sn,an,on,ln,hn,cn,un,dn,fn,gn,mn,pn,_n,vn,yn,wn,En,Cn,Sn,Tn;class bn{static createDrawingStyle(t){if(!Pi(t))throw new Error("Invalid style definition.");let e,i=bn.USER_START_STYLE_ID;for(;He(bn,Yi,"f",zi).has(i);)i++;e=i;const n=JSON.parse(JSON.stringify(t));n.id=e;for(let t in He(bn,Yi,"f",Hi))n.hasOwnProperty(t)||(n[t]=He(bn,Yi,"f",Hi)[t]);return He(bn,Yi,"f",zi).set(e,n),n.id}static _getDrawingStyle(t,e){if("number"!=typeof t)throw new Error("Invalid style id.");const i=He(bn,Yi,"f",zi).get(t);return i?e?JSON.parse(JSON.stringify(i)):i:null}static getDrawingStyle(t){return this._getDrawingStyle(t,!0)}static getAllDrawingStyles(){return JSON.parse(JSON.stringify(Array.from(He(bn,Yi,"f",zi).values())))}static _updateDrawingStyle(t,e){if(!Pi(e))throw new Error("Invalid style definition.");const i=He(bn,Yi,"f",zi).get(t);if(i)for(let t in e)i.hasOwnProperty(t)&&(i[t]=e[t])}static updateDrawingStyle(t,e){this._updateDrawingStyle(t,e)}}Yi=bn,bn.STYLE_BLUE_STROKE=1,bn.STYLE_GREEN_STROKE=2,bn.STYLE_ORANGE_STROKE=3,bn.STYLE_YELLOW_STROKE=4,bn.STYLE_BLUE_STROKE_FILL=5,bn.STYLE_GREEN_STROKE_FILL=6,bn.STYLE_ORANGE_STROKE_FILL=7,bn.STYLE_YELLOW_STROKE_FILL=8,bn.STYLE_BLUE_STROKE_TRANSPARENT=9,bn.STYLE_GREEN_STROKE_TRANSPARENT=10,bn.STYLE_ORANGE_STROKE_TRANSPARENT=11,bn.USER_START_STYLE_ID=1024,zi={value:new Map([[bn.STYLE_BLUE_STROKE,{id:bn.STYLE_BLUE_STROKE,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[bn.STYLE_GREEN_STROKE,{id:bn.STYLE_GREEN_STROKE,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[bn.STYLE_ORANGE_STROKE,{id:bn.STYLE_ORANGE_STROKE,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[bn.STYLE_YELLOW_STROKE,{id:bn.STYLE_YELLOW_STROKE,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[bn.STYLE_BLUE_STROKE_FILL,{id:bn.STYLE_BLUE_STROKE_FILL,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[bn.STYLE_GREEN_STROKE_FILL,{id:bn.STYLE_GREEN_STROKE_FILL,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[bn.STYLE_ORANGE_STROKE_FILL,{id:bn.STYLE_ORANGE_STROKE_FILL,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[bn.STYLE_YELLOW_STROKE_FILL,{id:bn.STYLE_YELLOW_STROKE_FILL,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[bn.STYLE_BLUE_STROKE_TRANSPARENT,{id:bn.STYLE_BLUE_STROKE_TRANSPARENT,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[bn.STYLE_GREEN_STROKE_TRANSPARENT,{id:bn.STYLE_GREEN_STROKE_TRANSPARENT,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[bn.STYLE_ORANGE_STROKE_TRANSPARENT,{id:bn.STYLE_ORANGE_STROKE_TRANSPARENT,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}]])},Hi={value:{lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}},"undefined"!=typeof document&&"undefined"!=typeof window&&(ai.StaticCanvas.prototype.dispose=function(){return this.isRendering&&(ai.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject((function(t){t.dispose&&t.dispose()})),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),ai.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},ai.Object.prototype.transparentCorners=!1,ai.Object.prototype.cornerSize=20,ai.Object.prototype.touchCornerSize=100,ai.Object.prototype.cornerColor="rgb(254,142,20)",ai.Object.prototype.cornerStyle="circle",ai.Object.prototype.strokeUniform=!0,ai.Object.prototype.hasBorders=!1,ai.Canvas.prototype.containerClass="",ai.Canvas.prototype.getPointer=function(t,e){if(this._absolutePointer&&!e)return this._absolutePointer;if(this._pointer&&e)return this._pointer;var i,n=this.upperCanvasEl,r=ai.util.getPointer(t,n),s=n.getBoundingClientRect(),a=s.width||0,o=s.height||0;a&&o||("top"in s&&"bottom"in s&&(o=Math.abs(s.top-s.bottom)),"right"in s&&"left"in s&&(a=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=this.restorePointerVpt(r));var l=this.getRetinaScaling();if(1!==l&&(r.x/=l,r.y/=l),0!==a&&0!==o){var h=window.getComputedStyle(n).objectFit,c=n.width,u=n.height,d=a,f=o;i={width:c/d,height:u/f};var g,m,p=c/u,_=d/f;return"contain"===h?p>_?(g=d,m=d/p,{x:r.x*i.width,y:(r.y-(f-m)/2)*i.width}):(g=f*p,m=f,{x:(r.x-(d-g)/2)*i.height,y:r.y*i.height}):"cover"===h?p>_?{x:(c-i.height*d)/2+r.x*i.height,y:r.y*i.height}:{x:r.x*i.width,y:(u-i.width*f)/2+r.y*i.width}:{x:r.x*i.width,y:r.y*i.height}}return i={width:1,height:1},{x:r.x*i.width,y:r.y*i.height}},ai.Canvas.prototype._onTouchStart=function(t){var e=this.findTarget(t);!this.allowTouchScrolling&&t.cancelable&&t.preventDefault&&t.preventDefault(),e&&t.cancelable&&t.preventDefault&&t.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),this._resetTransformEventData();var i=this.upperCanvasEl,n=this._getEventPrefix();ai.util.addListener(ai.document,"touchend",this._onTouchEnd,{passive:!1}),ai.util.addListener(ai.document,"touchmove",this._onMouseMove,{passive:!1}),ai.util.removeListener(i,n+"down",this._onMouseDown)},ai.Textbox.prototype._wrapLine=function(t,e,i,n){const r=t.match(/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f]/g),s=!(!r||!r.length);var a=0,o=this.splitByGrapheme||s,l=[],h=[],c=o?ai.util.string.graphemeSplit(t):t.split(this._wordJoiners),u="",d=0,f=o?"":" ",g=0,m=0,p=0,_=!0,v=this._getWidthOfCharSpacing();n=n||0,0===c.length&&c.push([]),i-=n;for(var y=0;yi&&!_?(l.push(h),h=[],a=g,_=!0):a+=v,_||o||h.push(f),h=h.concat(u),m=o?0:this._measureWord([f],e,d),d++,_=!1,g>p&&(p=g);return y&&l.push(h),p+n>this.dynamicMinWidth&&(this.dynamicMinWidth=p-v+n),l});class In{get width(){return this.fabricCanvas.width}get height(){return this.fabricCanvas.height}set _allowMultiSelect(t){this.fabricCanvas.selection=t,this.fabricCanvas.renderAll()}get _allowMultiSelect(){return this.fabricCanvas.selection}constructor(t,e,i){if(this.mapType_StateAndStyleId=new Map,this.mode="viewer",this.onSelectionChanged=null,this._arrDrwaingItem=[],this._arrFabricObject=[],this._visible=!0,t.hasOwnProperty("getFabricCanvas"))this.fabricCanvas=t.getFabricCanvas();else{let e=this.fabricCanvas=new ai.Canvas(t,Object.assign(i,{allowTouchScrolling:!0,selection:!1}));e.setDimensions({width:"100%",height:"100%"},{cssOnly:!0}),e.lowerCanvasEl.className="",e.upperCanvasEl.className="",e.on("selection:created",(function(t){const e=t.selected,i=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!i.includes(e)&&i.push(e)}for(let t of i){const i=[];for(let n of e){const e=n.getDrawingItem();e._drawingLayer===t&&i.push(e)}setTimeout((()=>{t.onSelectionChanged&&t.onSelectionChanged(i,[])}),0)}})),e.on("before:selection:cleared",(function(t){const e=this.getActiveObjects(),i=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!i.includes(e)&&i.push(e)}for(let t of i){const i=[];for(let n of e){const e=n.getDrawingItem();e._drawingLayer===t&&i.push(e)}setTimeout((()=>{const e=[];for(let n of i)t.hasDrawingItem(n)&&e.push(n);e.length>0&&t.onSelectionChanged&&t.onSelectionChanged([],e)}),0)}})),e.on("selection:updated",(function(t){const e=t.selected,i=t.deselected,n=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!n.includes(e)&&n.push(e)}for(let t of i){const e=t.getDrawingItem()._drawingLayer;e&&!n.includes(e)&&n.push(e)}for(let t of n){const n=[],r=[];for(let i of e){const e=i.getDrawingItem();e._drawingLayer===t&&n.push(e)}for(let e of i){const i=e.getDrawingItem();i._drawingLayer===t&&r.push(i)}setTimeout((()=>{t.onSelectionChanged&&t.onSelectionChanged(n,r)}),0)}})),e.wrapperEl.style.position="absolute",t.getFabricCanvas=()=>this.fabricCanvas}let n,r;switch(this.id=e,e){case In.DDN_LAYER_ID:n=bn.getDrawingStyle(bn.STYLE_BLUE_STROKE),r=bn.getDrawingStyle(bn.STYLE_BLUE_STROKE_FILL);break;case In.DBR_LAYER_ID:n=bn.getDrawingStyle(bn.STYLE_ORANGE_STROKE),r=bn.getDrawingStyle(bn.STYLE_ORANGE_STROKE_FILL);break;case In.DLR_LAYER_ID:n=bn.getDrawingStyle(bn.STYLE_GREEN_STROKE),r=bn.getDrawingStyle(bn.STYLE_GREEN_STROKE_FILL);break;default:n=bn.getDrawingStyle(bn.STYLE_YELLOW_STROKE),r=bn.getDrawingStyle(bn.STYLE_YELLOW_STROKE_FILL)}for(let t of wi.arrMediaTypes)this.mapType_StateAndStyleId.set(t,{default:n.id,selected:r.id})}getId(){return this.id}setVisible(t){if(t){for(let t of this._arrFabricObject)t.visible=!0,t.hasControls=!0;this._visible=!0}else{for(let t of this._arrFabricObject)t.visible=!1,t.hasControls=!1;this._visible=!1}this.fabricCanvas.renderAll()}isVisible(){return this._visible}_getItemCurrentStyle(t){if(t.styleId)return bn.getDrawingStyle(t.styleId);return bn.getDrawingStyle(t._mapState_StyleId.get(t.styleSelector))||null}_changeMediaTypeCurStyleInStyleSelector(t,e,i,n){const r=this.getDrawingItems((e=>e._mediaType===t));for(let t of r)t.styleSelector===e&&this._changeItemStyle(t,i,!0);n||this.fabricCanvas.renderAll()}_changeItemStyle(t,e,i){if(!t||!e)return;const n=t._getFabricObject();"number"==typeof t.styleId&&(e=bn.getDrawingStyle(t.styleId)),n.strokeWidth=e.lineWidth,"fill"===e.paintMode?(n.fill=e.fillStyle,n.stroke=e.fillStyle):"stroke"===e.paintMode?(n.fill="transparent",n.stroke=e.strokeStyle):"strokeAndFill"===e.paintMode&&(n.fill=e.fillStyle,n.stroke=e.strokeStyle),n.fontFamily&&(n.fontFamily=e.fontFamily),n.fontSize&&(n.fontSize=e.fontSize),n.group||(n.dirty=!0),i||this.fabricCanvas.renderAll()}_updateGroupItem(t,e,i){if(!t||!e)return;const n=t.getChildDrawingItems();if("add"===i){if(n.includes(e))return;const i=e._getFabricObject();if(this.fabricCanvas.getObjects().includes(i)){if(!this._arrFabricObject.includes(i))throw new Error("Existed in other drawing layers.");e._zIndex=null}else{let i;if(e.styleId)i=bn.getDrawingStyle(e.styleId);else{const n=this.mapType_StateAndStyleId.get(e._mediaType);i=bn.getDrawingStyle(n[t.styleSelector]);const r=()=>{this._changeItemStyle(e,bn.getDrawingStyle(this.mapType_StateAndStyleId.get(e._mediaType).selected),!0)},s=()=>{this._changeItemStyle(e,bn.getDrawingStyle(this.mapType_StateAndStyleId.get(e._mediaType).default),!0)};e._on("selected",r),e._on("deselected",s),e._funcChangeStyleToSelected=r,e._funcChangeStyleToDefault=s}e._drawingLayer=this,e._drawingLayerId=this.id,this._changeItemStyle(e,i,!0)}t._fabricObject.addWithUpdate(e._getFabricObject())}else{if("remove"!==i)return;if(!n.includes(e))return;e._zIndex=null,e._drawingLayer=null,e._drawingLayerId=null,e._off("selected",e._funcChangeStyleToSelected),e._off("deselected",e._funcChangeStyleToDefault),e._funcChangeStyleToSelected=null,e._funcChangeStyleToDefault=null,t._fabricObject.removeWithUpdate(e._getFabricObject())}this.fabricCanvas.renderAll()}_addDrawingItem(t,e){if(!(t instanceof wi))throw new TypeError("Invalid 'drawingItem'.");if(t._drawingLayer){if(t._drawingLayer==this)return;throw new Error("This drawing item has existed in other layer.")}let i=t._getFabricObject();const n=this.fabricCanvas.getObjects();let r,s;if(n.includes(i)){if(this._arrFabricObject.includes(i))return;throw new Error("Existed in other drawing layers.")}if("group"===t._mediaType){r=t.getChildDrawingItems();for(let t of r)if(t._drawingLayer&&t._drawingLayer!==this)throw new Error("The childItems of DT_Group have existed in other drawing layers.")}if(e&&"object"==typeof e&&!Array.isArray(e))for(let t in e)i.set(t,e[t]);if(r){for(let t of r){const e=this.mapType_StateAndStyleId.get(t._mediaType);for(let i of wi.arrStyleSelectors)t._mapState_StyleId.set(i,e[i]);if(t.styleId)s=bn.getDrawingStyle(t.styleId);else{s=bn.getDrawingStyle(e.default);const i=()=>{this._changeItemStyle(t,bn.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).selected),!0)},n=()=>{this._changeItemStyle(t,bn.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).default),!0)};t._on("selected",i),t._on("deselected",n),t._funcChangeStyleToSelected=i,t._funcChangeStyleToDefault=n}t._drawingLayer=this,t._drawingLayerId=this.id,this._changeItemStyle(t,s,!0)}i.dirty=!0,this.fabricCanvas.renderAll()}else{const e=this.mapType_StateAndStyleId.get(t._mediaType);for(let i of wi.arrStyleSelectors)t._mapState_StyleId.set(i,e[i]);if(t.styleId)s=bn.getDrawingStyle(t.styleId);else{s=bn.getDrawingStyle(e.default);const i=()=>{this._changeItemStyle(t,bn.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).selected))},n=()=>{this._changeItemStyle(t,bn.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).default))};t._on("selected",i),t._on("deselected",n),t._funcChangeStyleToSelected=i,t._funcChangeStyleToDefault=n}this._changeItemStyle(t,s)}t._zIndex=this.id,t._drawingLayer=this,t._drawingLayerId=this.id;const a=this._arrFabricObject.length;let o=n.length;if(a)o=n.indexOf(this._arrFabricObject[a-1])+1;else for(let e=0;et.toLowerCase())):e=wi.arrMediaTypes,i?i.forEach((t=>t.toLowerCase())):i=wi.arrStyleSelectors;const n=bn.getDrawingStyle(t);if(!n)throw new Error(`The 'drawingStyle' with id '${t}' doesn't exist.`);let r;for(let s of e)if(r=this.mapType_StateAndStyleId.get(s),r)for(let e of i){this._changeMediaTypeCurStyleInStyleSelector(s,e,n,!0),r[e]=t;for(let i of this._arrDrwaingItem)i._mediaType===s&&i._mapState_StyleId.set(e,t)}this.fabricCanvas.renderAll()}setDefaultStyle(t,e,i){const n=[];i&ii.DIMT_RECTANGLE&&n.push("rect"),i&ii.DIMT_QUADRILATERAL&&n.push("quad"),i&ii.DIMT_TEXT&&n.push("text"),i&ii.DIMT_ARC&&n.push("arc"),i&ii.DIMT_IMAGE&&n.push("image"),i&ii.DIMT_POLYGON&&n.push("polygon"),i&ii.DIMT_LINE&&n.push("line");const r=[];e&ni.DIS_DEFAULT&&r.push("default"),e&ni.DIS_SELECTED&&r.push("selected"),this._setDefaultStyle(t,n.length?n:null,r.length?r:null)}setMode(t){if("viewer"===(t=t.toLowerCase())){for(let t of this._arrDrwaingItem)t._setEditable(!1);this.fabricCanvas.discardActiveObject(),this.fabricCanvas.renderAll(),this.mode="viewer"}else{if("editor"!==t)throw new RangeError("Invalid value.");for(let t of this._arrDrwaingItem)t._setEditable(!0);this.mode="editor"}this._manager._switchPointerEvent()}getMode(){return this.mode}_setDimensions(t,e){this.fabricCanvas.setDimensions(t,e)}_setObjectFit(t){if(t=t.toLowerCase(),!["contain","cover"].includes(t))throw new Error(`Unsupported value '${t}'.`);this.fabricCanvas.lowerCanvasEl.style.objectFit=t,this.fabricCanvas.upperCanvasEl.style.objectFit=t}_getObjectFit(){return this.fabricCanvas.lowerCanvasEl.style.objectFit}renderAll(){for(let t of this._arrDrwaingItem){const e=this._getItemCurrentStyle(t);this._changeItemStyle(t,e,!0)}this.fabricCanvas.renderAll()}dispose(){this.clearDrawingItems(),1===this._manager._arrDrawingLayer.length&&(this.fabricCanvas.wrapperEl.style.pointerEvents="none",this.fabricCanvas.dispose(),this._arrDrwaingItem.length=0,this._arrFabricObject.length=0)}}In.DDN_LAYER_ID=1,In.DBR_LAYER_ID=2,In.DLR_LAYER_ID=3,In.USER_DEFINED_LAYER_BASE_ID=100,In.TIP_LAYER_ID=999;class xn{constructor(){this._arrDrawingLayer=[]}createDrawingLayer(t,e){if(this.getDrawingLayer(e))throw new Error("Existed drawing layer id.");const i=new In(t,e,{enableRetinaScaling:!1});return i._manager=this,this._arrDrawingLayer.push(i),this._switchPointerEvent(),i}deleteDrawingLayer(t){const e=this.getDrawingLayer(t);if(!e)return;const i=this._arrDrawingLayer;e.dispose(),i.splice(i.indexOf(e),1),this._switchPointerEvent()}clearDrawingLayers(){for(let t of this._arrDrawingLayer)t.dispose();this._arrDrawingLayer.length=0}getDrawingLayer(t){for(let e of this._arrDrawingLayer)if(e.getId()===t)return e;return null}getAllDrawingLayers(){return Array.from(this._arrDrawingLayer)}getSelectedDrawingItems(){if(!this._arrDrawingLayer.length)return;const t=this._getFabricCanvas().getActiveObjects(),e=[];for(let i of t)e.push(i.getDrawingItem());return e}setDimensions(t,e){this._arrDrawingLayer.length&&this._arrDrawingLayer[0]._setDimensions(t,e)}setObjectFit(t){for(let e of this._arrDrawingLayer)e&&e._setObjectFit(t)}getObjectFit(){return this._arrDrawingLayer.length?this._arrDrawingLayer[0]._getObjectFit():null}setVisible(t){if(!this._arrDrawingLayer.length)return;this._getFabricCanvas().wrapperEl.style.display=t?"block":"none"}_getFabricCanvas(){return this._arrDrawingLayer.length?this._arrDrawingLayer[0].fabricCanvas:null}_switchPointerEvent(){if(this._arrDrawingLayer.length)for(let t of this._arrDrawingLayer)t.getMode()}}class Rn extends Ri{constructor(t,e,i,n,r){super(t,{x:e,y:i,width:n,height:0},r),Xi.set(this,void 0),Zi.set(this,void 0),this._fabricObject.paddingTop=15,this._fabricObject.calcTextHeight=function(){for(var t=0,e=0,i=this._textLines.length;e=0&&Xe(this,Zi,setTimeout((()=>{this.set("visible",!1),this._drawingLayer&&this._drawingLayer.renderAll()}),He(this,Xi,"f")))}getDuration(){return He(this,Xi,"f")}}Xi=new WeakMap,Zi=new WeakMap;class On{constructor(){qi.add(this),Ji.set(this,void 0),Ki.set(this,void 0),$i.set(this,void 0),Qi.set(this,!0),this._drawingLayerManager=new xn}createDrawingLayerBaseCvs(t,e,i="contain"){if("number"!=typeof t||t<=1)throw new Error("Invalid 'width'.");if("number"!=typeof e||e<=1)throw new Error("Invalid 'height'.");if(!["contain","cover"].includes(i))throw new Error("Unsupported 'objectFit'.");const n=document.createElement("canvas");return n.width==t&&n.height==e||(n.width=t,n.height=e),n.style.objectFit=i,n}_createDrawingLayer(t,e,i,n){if(!this._layerBaseCvs){let r;try{r=this.getContentDimensions()}catch(t){if("Invalid content dimensions."!==(t.message||t))throw t}e||(e=(null==r?void 0:r.width)||1280),i||(i=(null==r?void 0:r.height)||720),n||(n=(null==r?void 0:r.objectFit)||"contain"),this._layerBaseCvs=this.createDrawingLayerBaseCvs(e,i,n)}const r=this._layerBaseCvs,s=this._drawingLayerManager.createDrawingLayer(r,t);return this._innerComponent.getElement("drawing-layer")||this._innerComponent.setElement("drawing-layer",r.parentElement),s}createDrawingLayer(){let t;for(let e=In.USER_DEFINED_LAYER_BASE_ID;;e++)if(!this._drawingLayerManager.getDrawingLayer(e)&&e!==In.TIP_LAYER_ID){t=e;break}return this._createDrawingLayer(t)}deleteDrawingLayer(t){var e;this._drawingLayerManager.deleteDrawingLayer(t),this._drawingLayerManager.getAllDrawingLayers().length||(null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null)}deleteUserDefinedDrawingLayer(t){if("number"!=typeof t)throw new TypeError("Invalid id.");if(tt.getId()>=0&&t.getId()!==In.TIP_LAYER_ID))}updateDrawingLayers(t){((t,e,i)=>{if(!(t<=1||e<=1)){if(!["contain","cover"].includes(i))throw new Error("Unsupported 'objectFit'.");this._drawingLayerManager.setDimensions({width:t,height:e},{backstoreOnly:!0}),this._drawingLayerManager.setObjectFit(i)}})(t.width,t.height,t.objectFit)}getSelectedDrawingItems(){return this._drawingLayerManager.getSelectedDrawingItems()}setTipConfig(t){if(!(Mi(e=t)&&S(e.topLeftPoint)&&oi(e.width))||e.width<=0||!oi(e.duration)||"coordinateBase"in e&&!["view","image"].includes(e.coordinateBase))throw new Error("Invalid tip config.");var e;Xe(this,Ji,JSON.parse(JSON.stringify(t))),He(this,Ji,"f").coordinateBase||(He(this,Ji,"f").coordinateBase="view"),Xe(this,$i,t.duration),He(this,qi,"m",rn).call(this)}getTipConfig(){return He(this,Ji,"f")?He(this,Ji,"f"):null}setTipVisible(t){if("boolean"!=typeof t)throw new TypeError("Invalid value.");this._tip&&(this._tip.set("visible",t),this._drawingLayerOfTip&&this._drawingLayerOfTip.renderAll()),Xe(this,Qi,t)}isTipVisible(){return He(this,Qi,"f")}updateTipMessage(t){if(!He(this,Ji,"f"))throw new Error("Tip config is not set.");this._tipStyleId||(this._tipStyleId=bn.createDrawingStyle({fillStyle:"#FFFFFF",paintMode:"fill",fontFamily:"Open Sans",fontSize:40})),this._drawingLayerOfTip||(this._drawingLayerOfTip=this._drawingLayerManager.getDrawingLayer(In.TIP_LAYER_ID)||this._createDrawingLayer(In.TIP_LAYER_ID)),this._tip?this._tip.set("text",t):this._tip=He(this,qi,"m",tn).call(this,t,He(this,Ji,"f").topLeftPoint.x,He(this,Ji,"f").topLeftPoint.y,He(this,Ji,"f").width,He(this,Ji,"f").coordinateBase,this._tipStyleId),He(this,qi,"m",en).call(this,this._tip,this._drawingLayerOfTip),this._tip.set("visible",He(this,Qi,"f")),this._drawingLayerOfTip&&this._drawingLayerOfTip.renderAll(),He(this,Ki,"f")&&clearTimeout(He(this,Ki,"f")),He(this,$i,"f")>=0&&Xe(this,Ki,setTimeout((()=>{He(this,qi,"m",nn).call(this)}),He(this,$i,"f")))}}Ji=new WeakMap,Ki=new WeakMap,$i=new WeakMap,Qi=new WeakMap,qi=new WeakSet,tn=function(t,e,i,n,r,s){const a=new Rn(t,e,i,n,s);return a.coordinateBase=r,a},en=function(t,e){e.hasDrawingItem(t)||e.addDrawingItems([t])},nn=function(){this._tip&&this._drawingLayerOfTip.removeDrawingItems([this._tip])},rn=function(){if(!this._tip)return;const t=He(this,Ji,"f");this._tip.coordinateBase=t.coordinateBase,this._tip.setTextRect({x:t.topLeftPoint.x,y:t.topLeftPoint.y,width:t.width,height:0}),this._tip.set("width",this._tip.get("width")),this._tip._drawingLayer&&this._tip._drawingLayer.renderAll()};class Dn extends HTMLElement{constructor(){super(),sn.set(this,void 0);const t=new DocumentFragment,e=document.createElement("div");e.setAttribute("class","wrapper"),t.appendChild(e),Xe(this,sn,e);const i=document.createElement("slot");i.setAttribute("name","single-frame-input-container"),e.append(i);const n=document.createElement("slot");n.setAttribute("name","content"),e.append(n);const r=document.createElement("slot");r.setAttribute("name","drawing-layer"),e.append(r);const s=document.createElement("style");s.textContent='\n.wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n}\n::slotted(canvas[slot="content"]) {\n object-fit: contain;\n pointer-events: none;\n}\n::slotted(div[slot="single-frame-input-container"]) {\n width: 1px;\n height: 1px;\n overflow: hidden;\n pointer-events: none;\n}\n::slotted(*) {\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n}\n ',t.appendChild(s),this.attachShadow({mode:"open"}).appendChild(t)}getWrapper(){return He(this,sn,"f")}setElement(t,e){if(!(e instanceof HTMLElement))throw new TypeError("Invalid 'el'.");if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");this.removeElement(t),e.setAttribute("slot",t),this.appendChild(e)}getElement(t){if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");return this.querySelector(`[slot="${t}"]`)}removeElement(t){var e;if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");null===(e=this.querySelectorAll(`[slot="${t}"]`))||void 0===e||e.forEach((t=>t.remove()))}}sn=new WeakMap,customElements.get("dce-component")||customElements.define("dce-component",Dn);class An extends On{static get engineResourcePath(){return O(gt.engineResourcePaths).dce}static set defaultUIElementURL(t){An._defaultUIElementURL=t}static get defaultUIElementURL(){var t;return null===(t=An._defaultUIElementURL)||void 0===t?void 0:t.replace("@engineResourcePath/",An.engineResourcePath)}static async createInstance(t){const e=new An;return"string"==typeof t&&(t=t.replace("@engineResourcePath/",An.engineResourcePath)),await e.setUIElement(t||An.defaultUIElementURL),e}static _transformCoordinates(t,e,i,n,r,s,a){const o=s/n,l=a/r;t.x=Math.round(t.x/o+e),t.y=Math.round(t.y/l+i)}set _singleFrameMode(t){if(!["disabled","image","camera"].includes(t))throw new Error("Invalid value.");if(t!==He(this,mn,"f")){if(Xe(this,mn,t),He(this,an,"m",vn).call(this))Xe(this,cn,null),this._videoContainer=null,this._innerComponent.removeElement("content"),this._innerComponent&&(this._innerComponent.addEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="block");else if(this._innerComponent&&(this._innerComponent.removeEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none"),!He(this,cn,"f")){const t=document.createElement("video");t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.width="100%",t.style.height="100%",t.style.objectFit=this.getVideoFit(),t.setAttribute("autoplay","true"),t.setAttribute("playsinline","true"),t.setAttribute("muted","true"),["iPhone","iPad","Mac"].includes(ze.OS)&&t.setAttribute("poster","data:image/gif;base64,R0lGODlhAQABAIEAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgEAAEEBAA7"),Xe(this,cn,t);const e=document.createElement("div");e.append(t),e.style.overflow="hidden",this._videoContainer=e,this._innerComponent.setElement("content",e)}He(this,an,"m",vn).call(this)||this._hideDefaultSelection?(this._selCam&&(this._selCam.style.display="none"),this._selRsl&&(this._selRsl.style.display="none"),this._selMinLtr&&(this._selMinLtr.style.display="none")):(this._selCam&&(this._selCam.style.display="block"),this._selRsl&&(this._selRsl.style.display="block"),this._selMinLtr&&(this._selMinLtr.style.display="block"),this._stopLoading())}}get _singleFrameMode(){return He(this,mn,"f")}get disposed(){return He(this,_n,"f")}constructor(){super(),an.add(this),on.set(this,void 0),ln.set(this,void 0),hn.set(this,void 0),this.containerClassName="dce-video-container",cn.set(this,void 0),this.videoFit="contain",this._hideDefaultSelection=!1,this._divScanArea=null,this._divScanLight=null,this._bgLoading=null,this._selCam=null,this._bgCamera=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,un.set(this,null),this.regionMaskFillStyle="rgba(0,0,0,0.5)",this.regionMaskStrokeStyle="rgb(254,142,20)",this.regionMaskLineWidth=6,dn.set(this,!1),fn.set(this,!1),gn.set(this,{width:0,height:0}),this._updateLayersTimeout=500,this._videoResizeListener=()=>{He(this,an,"m",Sn).call(this),this._updateLayersTimeoutId&&clearTimeout(this._updateLayersTimeoutId),this._updateLayersTimeoutId=setTimeout((()=>{this.disposed||(this.eventHandler.fire("videoEl:resized",null,{async:!1}),this.eventHandler.fire("content:updated",null,{async:!1}),this.isScanLaserVisible()&&He(this,an,"m",Cn).call(this))}),this._updateLayersTimeout)},this._windowResizeListener=()=>{An._onLog&&An._onLog("window resize event triggered."),He(this,gn,"f").width===document.documentElement.clientWidth&&He(this,gn,"f").height===document.documentElement.clientHeight||(He(this,gn,"f").width=document.documentElement.clientWidth,He(this,gn,"f").height=document.documentElement.clientHeight,this._videoResizeListener())},mn.set(this,"disabled"),this._clickIptSingleFrameMode=()=>{if(!He(this,an,"m",vn).call(this))return;let t;if(this._singleFrameInputContainer)t=this._singleFrameInputContainer.firstElementChild;else{t=document.createElement("input"),t.setAttribute("type","file"),"camera"===this._singleFrameMode?(t.setAttribute("capture",""),t.setAttribute("accept","image/*")):"image"===this._singleFrameMode&&(t.removeAttribute("capture"),t.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp")),t.addEventListener("change",(async()=>{const e=t.files[0];t.value="";{const t=async t=>{let e=null,i=null;if("undefined"!=typeof createImageBitmap)try{if(e=await createImageBitmap(t),e)return e}catch(t){}var n;return e||(i=await(n=t,new Promise(((t,e)=>{let i=URL.createObjectURL(n),r=new Image;r.src=i,r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=t=>{e(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}})))),i},i=(t,e,i,n)=>{t.width==i&&t.height==n||(t.width=i,t.height=n);const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height),r.drawImage(e,0,0)},n=await t(e),r=n instanceof HTMLImageElement?n.naturalWidth:n.width,s=n instanceof HTMLImageElement?n.naturalHeight:n.height;let a=this._cvsSingleFrameMode;const o=null==a?void 0:a.width,l=null==a?void 0:a.height;a||(a=document.createElement("canvas"),this._cvsSingleFrameMode=a),i(a,n,r,s),this._innerComponent.setElement("content",a),o===a.width&&l===a.height||this.eventHandler.fire("content:updated",null,{async:!1})}this._onSingleFrameAcquired&&setTimeout((()=>{this._onSingleFrameAcquired(this._cvsSingleFrameMode)}),0)})),t.style.position="absolute",t.style.top="-9999px",t.style.backgroundColor="transparent",t.style.color="transparent";const e=document.createElement("div");e.append(t),this._innerComponent.setElement("single-frame-input-container",e),this._singleFrameInputContainer=e}null==t||t.click()},pn.set(this,[]),this._capturedResultReceiver={onCapturedResultReceived:(t,e)=>{var i,n,r,s;if(this.disposed)return;if(this.clearAllInnerDrawingItems(),!t)return;const a=t.originalImageTag;if(!a)return;const o=t.items;if(!(null==o?void 0:o.length))return;const l=(null===(i=a.cropRegion)||void 0===i?void 0:i.left)||0,h=(null===(n=a.cropRegion)||void 0===n?void 0:n.top)||0,c=(null===(r=a.cropRegion)||void 0===r?void 0:r.right)?a.cropRegion.right-l:a.originalWidth,u=(null===(s=a.cropRegion)||void 0===s?void 0:s.bottom)?a.cropRegion.bottom-h:a.originalHeight,d=a.currentWidth,f=a.currentHeight,g=(t,e,i,n,r,s,a,o,l=[],h)=>{e.forEach((t=>An._transformCoordinates(t,i,n,r,s,a,o)));const c=new Ai({points:[{x:e[0].x,y:e[0].y},{x:e[1].x,y:e[1].y},{x:e[2].x,y:e[2].y},{x:e[3].x,y:e[3].y}]},h);for(let t of l)c.addNote(t);t.addDrawingItems([c]),He(this,pn,"f").push(c)};let m,p;for(let t of o)switch(t.type){case mt.CRIT_ORIGINAL_IMAGE:break;case mt.CRIT_BARCODE:m=this.getDrawingLayer(In.DBR_LAYER_ID),p=[{name:"format",content:t.formatString},{name:"text",content:t.text}],(null==e?void 0:e.isBarcodeVerifyOpen)?t.verified?g(m,t.location.points,l,h,c,u,d,f,p):g(m,t.location.points,l,h,c,u,d,f,p,bn.STYLE_ORANGE_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,u,d,f,p);break;case mt.CRIT_TEXT_LINE:m=this.getDrawingLayer(In.DLR_LAYER_ID),p=[{name:"text",content:t.text}],e.isLabelVerifyOpen?t.verified?g(m,t.location.points,l,h,c,u,d,f,p):g(m,t.location.points,l,h,c,u,d,f,p,bn.STYLE_GREEN_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,u,d,f,p);break;case mt.CRIT_DETECTED_QUAD:m=this.getDrawingLayer(In.DDN_LAYER_ID),(null==e?void 0:e.isDetectVerifyOpen)?t.crossVerificationStatus===St.CVS_PASSED?g(m,t.location.points,l,h,c,u,d,f,[]):g(m,t.location.points,l,h,c,u,d,f,[],bn.STYLE_BLUE_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,u,d,f,[]);break;case mt.CRIT_NORMALIZED_IMAGE:m=this.getDrawingLayer(In.DDN_LAYER_ID),(null==e?void 0:e.isNormalizeVerifyOpen)?t.crossVerificationStatus===St.CVS_PASSED?g(m,t.location.points,l,h,c,u,d,f,[]):g(m,t.location.points,l,h,c,u,d,f,[],bn.STYLE_BLUE_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,u,d,f,[]);break;case mt.CRIT_PARSED_RESULT:break;default:throw new Error("Illegal item type.")}}},_n.set(this,!1),this.eventHandler=new Vi,this.eventHandler.on("content:updated",(()=>{He(this,on,"f")&&clearTimeout(He(this,on,"f")),Xe(this,on,setTimeout((()=>{if(this.disposed)return;let t;this._updateVideoContainer();try{t=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}this.updateDrawingLayers(t),this.updateConvertedRegion(t)}),0))})),this.eventHandler.on("videoEl:resized",(()=>{He(this,ln,"f")&&clearTimeout(He(this,ln,"f")),Xe(this,ln,setTimeout((()=>{this.disposed||this._updateVideoContainer()}),0))}))}_setUIElement(t){this.UIElement=t,this._unbindUI(),this._bindUI()}async setUIElement(t){let e;if("string"==typeof t){let i=await Wi(t);e=document.createElement("div"),Object.assign(e.style,{width:"100%",height:"100%"}),e.attachShadow({mode:"open"}).appendChild(i.cloneNode(!0))}else e=t;this._setUIElement(e)}getUIElement(){return this.UIElement}_bindUI(){var t,e;if(!this.UIElement)throw new Error("Need to set 'UIElement'.");if(this._innerComponent)return;let i=this.UIElement;i=i.shadowRoot||i;let n=(null===(t=i.classList)||void 0===t?void 0:t.contains(this.containerClassName))?i:i.querySelector(`.${this.containerClassName}`);if(!n)throw Error(`Can not find the element with class '${this.containerClassName}'.`);if(this._innerComponent=document.createElement("dce-component"),n.appendChild(this._innerComponent),He(this,an,"m",vn).call(this));else{const t=document.createElement("video");Object.assign(t.style,{position:"absolute",left:"0",top:"0",width:"100%",height:"100%",objectFit:this.getVideoFit()}),t.setAttribute("autoplay","true"),t.setAttribute("playsinline","true"),t.setAttribute("muted","true"),["iPhone","iPad","Mac"].includes(ze.OS)&&t.setAttribute("poster","data:image/gif;base64,R0lGODlhAQABAIEAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgEAAEEBAA7"),Xe(this,cn,t);const e=document.createElement("div");e.append(t),e.style.overflow="hidden",this._videoContainer=e,this._innerComponent.setElement("content",e)}if(this._selRsl=i.querySelector(".dce-sel-resolution"),this._selMinLtr=i.querySelector(".dlr-sel-minletter"),this._divScanArea=i.querySelector(".dce-scanarea"),this._divScanLight=i.querySelector(".dce-scanlight"),this._bgLoading=i.querySelector(".dce-bg-loading"),this._bgCamera=i.querySelector(".dce-bg-camera"),this._selCam=i.querySelector(".dce-sel-camera"),this._optGotRsl=i.querySelector(".dce-opt-gotResolution"),this._btnClose=i.querySelector(".dce-btn-close"),this._optGotMinLtr=i.querySelector(".dlr-opt-gotMinLtr"),this._selRsl&&(this._hideDefaultSelection||He(this,an,"m",vn).call(this)||this._selRsl.options.length||(this._selRsl.innerHTML=['','','',''].join(""),this._optGotRsl=this._selRsl.options[0])),this._selMinLtr&&(this._hideDefaultSelection||He(this,an,"m",vn).call(this)||this._selMinLtr.options.length||(this._selMinLtr.innerHTML=['','','','','','','','','','',''].join(""),this._optGotMinLtr=this._selMinLtr.options[0])),this.isScanLaserVisible()||He(this,an,"m",Sn).call(this),He(this,an,"m",vn).call(this)&&(this._innerComponent&&(this._innerComponent.addEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="block")),He(this,an,"m",vn).call(this)||this._hideDefaultSelection?(this._selCam&&(this._selCam.style.display="none"),this._selRsl&&(this._selRsl.style.display="none"),this._selMinLtr&&(this._selMinLtr.style.display="none")):(this._selCam&&(this._selCam.style.display="block"),this._selRsl&&(this._selRsl.style.display="block"),this._selMinLtr&&(this._selMinLtr.style.display="block"),this._stopLoading()),window.ResizeObserver){this._resizeObserver||(this._resizeObserver=new ResizeObserver((t=>{var e;An._onLog&&An._onLog("resize observer triggered.");for(let i of t)i.target===(null===(e=this._innerComponent)||void 0===e?void 0:e.getWrapper())&&this._videoResizeListener()})));const t=null===(e=this._innerComponent)||void 0===e?void 0:e.getWrapper();t&&this._resizeObserver.observe(t)}He(this,gn,"f").width=document.documentElement.clientWidth,He(this,gn,"f").height=document.documentElement.clientHeight,window.addEventListener("resize",this._windowResizeListener)}_unbindUI(){var t,e,i,n;He(this,an,"m",vn).call(this)?(this._innerComponent&&(this._innerComponent.removeEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none")):this._stopLoading(),He(this,an,"m",Sn).call(this),null===(t=this._drawingLayerManager)||void 0===t||t.clearDrawingLayers(),null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null,this._drawingLayerOfMask=null,this._drawingLayerOfTip=null,null===(i=this._innerComponent)||void 0===i||i.remove(),this._innerComponent=null,Xe(this,cn,null),null===(n=this._videoContainer)||void 0===n||n.remove(),this._videoContainer=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,this._divScanArea=null,this._divScanLight=null,this._singleFrameInputContainer&&(this._singleFrameInputContainer.remove(),this._singleFrameInputContainer=null),window.ResizeObserver&&this._resizeObserver&&this._resizeObserver.disconnect(),window.removeEventListener("resize",this._windowResizeListener)}_startLoading(){this._bgLoading&&(this._bgLoading.style.display="",this._bgLoading.style.animationPlayState="")}_stopLoading(){this._bgLoading&&(this._bgLoading.style.display="none",this._bgLoading.style.animationPlayState="paused")}_renderCamerasInfo(t,e){if(this._selCam){let i;this._selCam.textContent="";for(let n of e){const e=document.createElement("option");e.value=n.deviceId,e.innerText=n.label,this._selCam.append(e),n.deviceId&&t&&t.deviceId==n.deviceId&&(i=e)}this._selCam.value=i?i.value:""}let i=this.UIElement;if(i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")){let t=i.querySelector(".dce-mn-cameras");if(t){t.textContent="";for(let i of e){const e=document.createElement("div");e.classList.add("dce-mn-camera-option"),e.setAttribute("data-davice-id",i.deviceId),e.textContent=i.label,t.append(e)}}}}_renderResolutionInfo(t){this._optGotRsl&&(this._optGotRsl.setAttribute("data-width",t.width),this._optGotRsl.setAttribute("data-height",t.height),this._optGotRsl.innerText="got "+t.width+"x"+t.height,this._selRsl&&this._optGotRsl.parentNode==this._selRsl&&(this._selRsl.value="got"));{let e=this.UIElement;e=(null==e?void 0:e.shadowRoot)||e;let i=null==e?void 0:e.querySelector(".dce-mn-resolution-box");if(i){let e="";if(t&&t.width&&t.height){let i=Math.max(t.width,t.height),n=Math.min(t.width,t.height);e=n<=1080?n+"P":i<3e3?"2K":Math.round(i/1e3)+"K"}i.textContent=e}}}getVideoElement(){return He(this,cn,"f")}isVideoLoaded(){return!(!He(this,cn,"f")||!this.cameraEnhancer)&&this.cameraEnhancer.isOpen()}setVideoFit(t){if(t=t.toLowerCase(),!["contain","cover"].includes(t))throw new Error(`Unsupported value '${t}'.`);if(this.videoFit=t,!He(this,cn,"f"))return;if(He(this,cn,"f").style.objectFit=t,He(this,an,"m",vn).call(this))return;let e;this._updateVideoContainer();try{e=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}He(this,an,"m",Tn).call(this,e,this.getConvertedRegion()),this.updateDrawingLayers(e)}getVideoFit(){return this.videoFit}getContentDimensions(){var t,e,i,n;let r,s,a;if(He(this,an,"m",vn).call(this)?(r=null===(i=this._cvsSingleFrameMode)||void 0===i?void 0:i.width,s=null===(n=this._cvsSingleFrameMode)||void 0===n?void 0:n.height,a="contain"):(r=null===(t=He(this,cn,"f"))||void 0===t?void 0:t.videoWidth,s=null===(e=He(this,cn,"f"))||void 0===e?void 0:e.videoHeight,a=this.getVideoFit()),!r||!s)throw new Error("Invalid content dimensions.");return{width:r,height:s,objectFit:a}}updateConvertedRegion(t){const e=ki.convert(this.scanRegion,t.width,t.height);Xe(this,un,e),He(this,hn,"f")&&clearTimeout(He(this,hn,"f")),Xe(this,hn,setTimeout((()=>{let t;try{t=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}He(this,an,"m",yn).call(this,t,e),He(this,an,"m",Tn).call(this,t,e)}),0))}getConvertedRegion(){return He(this,un,"f")}setScanRegion(t){if(null!=t&&!w(t)&&!I(t))throw TypeError("Invalid 'region'.");let e;this.scanRegion=t?JSON.parse(JSON.stringify(t)):null;try{e=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}this.updateConvertedRegion(e)}getScanRegion(){return JSON.parse(JSON.stringify(this.scanRegion))}getVisibleRegionOfVideo(t){if(!this.isVideoLoaded())throw new Error("The video is not loaded.");const e=He(this,cn,"f").videoWidth,i=He(this,cn,"f").videoHeight,n=this.getVideoFit(),{width:r,height:s}=this._innerComponent.getBoundingClientRect();if(r<=0||s<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");let a;const o={x:0,y:0,width:e,height:i,isMeasuredInPercentage:!1};if("cover"===n&&(r/s1){const t=He(this,cn,"f").videoWidth,e=He(this,cn,"f").videoHeight,{width:n,height:r}=this._innerComponent.getBoundingClientRect(),s=t/e;if(n/rt.remove())),He(this,pn,"f").length=0}dispose(){this._unbindUI(),Xe(this,_n,!0)}}function Ln(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 Mn(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}on=new WeakMap,ln=new WeakMap,hn=new WeakMap,cn=new WeakMap,un=new WeakMap,dn=new WeakMap,fn=new WeakMap,gn=new WeakMap,mn=new WeakMap,pn=new WeakMap,_n=new WeakMap,an=new WeakSet,vn=function(){return"disabled"!==this._singleFrameMode},yn=function(t,e){!e||0===e.x&&0===e.y&&e.width===t.width&&e.height===t.height?this.clearScanRegionMask():this.setScanRegionMask(e.x,e.y,e.width,e.height)},wn=function(){this._drawingLayerOfMask&&this._drawingLayerOfMask.setVisible(!0)},En=function(){this._drawingLayerOfMask&&this._drawingLayerOfMask.setVisible(!1)},Cn=function(){this._divScanLight&&"none"==this._divScanLight.style.display&&(this._divScanLight.style.display="block")},Sn=function(){this._divScanLight&&(this._divScanLight.style.display="none")},Tn=function(t,e){if(!this._divScanArea)return;if(!this._innerComponent.getElement("content"))return;const{width:i,height:n,objectFit:r}=t;e||(e={x:0,y:0,width:i,height:n});const{width:s,height:a}=this._innerComponent.getBoundingClientRect();if(s<=0||a<=0)return;const o=s/a,l=i/n;let h,c,u,d,f=1;if("contain"===r)o66||"Safari"===Vn.browser&&Vn.version>13||"OPR"===Vn.browser&&Vn.version>43||"Edge"===Vn.browser&&Vn.version,"function"==typeof SuppressedError&&SuppressedError;class Gn{static multiply(t,e){const i=[];for(let n=0;n<3;n++){const r=e.slice(3*n,3*n+3);for(let e=0;e<3;e++){const n=[t[e],t[e+3],t[e+6]].reduce(((t,e,i)=>t+e*r[i]),0);i.push(n)}}return i}static identity(){return[1,0,0,0,1,0,0,0,1]}static translate(t,e,i){return Gn.multiply(t,[1,0,0,0,1,0,e,i,1])}static rotate(t,e){var i=Math.cos(e),n=Math.sin(e);return Gn.multiply(t,[i,-n,0,n,i,0,0,0,1])}static scale(t,e,i){return Gn.multiply(t,[e,0,0,0,i,0,0,0,1])}}var Wn,Yn,zn,Hn,Xn,Zn,qn,Jn,Kn,$n,Qn,tr,er,ir,nr,rr,sr,ar,or,lr,hr,cr,ur,dr,fr,gr,mr,pr,_r,vr,yr,wr,Er,Cr,Sr,Tr,br,Ir,xr,Rr,Or,Dr,Ar,Lr,Mr,Fr,Pr,kr,Nr,Br;!function(t){t.GREY="grey",t.GREY32="grey32",t.RGBA="rgba",t.RBGA="rbga",t.GRBA="grba",t.GBRA="gbra",t.BRGA="brga",t.BGRA="bgra"}(Wn||(Wn={}));class Vr{static get version(){return"1.1.3"}static get webGLSupported(){return void 0===Vr._webGLSupported&&(Vr._webGLSupported=!!document.createElement("canvas").getContext("webgl")),Vr._webGLSupported}get disposed(){return jn(this,qn,"f")}constructor(){Yn.set(this,Wn.RGBA),zn.set(this,null),Hn.set(this,null),Xn.set(this,null),this.useWebGLByDefault=!0,this._reusedCvs=null,this._reusedWebGLCvs=null,Zn.set(this,null),qn.set(this,!1)}drawImage(t,e,i,n,r,s){if(this.disposed)throw Error("The 'ImageDataGetter' instance has been disposed.");if(!i||!n)throw new Error("Invalid 'sourceWidth' or 'sourceHeight'.");if((null==s?void 0:s.bUseWebGL)&&!Vr.webGLSupported)throw new Error("Your browser or machine may not support WebGL.");if(e instanceof HTMLVideoElement&&4!==e.readyState||e instanceof HTMLImageElement&&!e.complete)throw new Error("The source is not loaded.");let a;Vr._onLog&&(a=Date.now(),Vr._onLog("drawImage(), START: "+a));let o=0,l=0,h=i,c=n,u=0,d=0,f=i,g=n;r&&(r.sx&&(o=Math.round(r.sx)),r.sy&&(l=Math.round(r.sy)),r.sWidth&&(h=Math.round(r.sWidth)),r.sHeight&&(c=Math.round(r.sHeight)),r.dx&&(u=Math.round(r.dx)),r.dy&&(d=Math.round(r.dy)),r.dWidth&&(f=Math.round(r.dWidth)),r.dHeight&&(g=Math.round(r.dHeight)));let m,p=Wn.RGBA;if((null==s?void 0:s.pixelFormat)&&(p=s.pixelFormat),(null==s?void 0:s.bufferContainer)&&(m=s.bufferContainer,m.length<4*f*g))throw new Error("Unexpected size of the 'bufferContainer'.");const _=t;if(!Vr.webGLSupported||!(this.useWebGLByDefault&&null==(null==s?void 0:s.bUseWebGL)||(null==s?void 0:s.bUseWebGL))){Vr._onLog&&Vr._onLog("drawImage() in context2d."),_.ctx2d||(_.ctx2d=_.getContext("2d",{willReadFrequently:!0}));const t=_.ctx2d;if(!t)throw new Error("Unable to get 'CanvasRenderingContext2D' from canvas.");return(_.width{const e=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,e),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);const i=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),{positions:e,texCoords:i}},i=t=>{const e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e},n=(t,e)=>{const i=t.createProgram();if(e.forEach((e=>t.attachShader(i,e))),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS)){const e=new Error(`An error occured linking the program: ${t.getProgramInfoLog(i)}.`);throw e.name="WebGLError",e}return t.useProgram(i),i},r=(t,e,i)=>{const n=t.createShader(e);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){const e=new Error(`An error occured compiling the shader: ${t.getShaderInfoLog(n)}.`);throw e.name="WebGLError",e}return n},s="\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\n\nuniform mat3 u_matrix;\nuniform mat3 u_textureMatrix;\n\nvarying vec2 v_texCoord;\nvoid main(void) {\ngl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, 0, 1.0);\nv_texCoord = vec4((u_textureMatrix * vec3(a_texCoord, 1)).xy, 0, 1.0).xy;\n}";let a="rgb";["rgba","rbga","grba","gbra","brga","bgra"].includes(p)&&(a=p.slice(0,3));const o=`\nprecision mediump float;\nvarying vec2 v_texCoord;\nuniform sampler2D u_image;\nuniform float uColorFactor;\n\nvoid main() {\nvec4 sample = texture2D(u_image, v_texCoord);\nfloat grey = 0.3 * sample.r + 0.59 * sample.g + 0.11 * sample.b;\ngl_FragColor = vec4(sample.${a} * (1.0 - uColorFactor) + (grey * uColorFactor), sample.a);\n}`,l=n(t,[r(t,t.VERTEX_SHADER,s),r(t,t.FRAGMENT_SHADER,o)]);Un(this,Hn,{program:l,attribLocations:{vertexPosition:t.getAttribLocation(l,"a_position"),texPosition:t.getAttribLocation(l,"a_texCoord")},uniformLocations:{uSampler:t.getUniformLocation(l,"u_image"),uColorFactor:t.getUniformLocation(l,"uColorFactor"),uMatrix:t.getUniformLocation(l,"u_matrix"),uTextureMatrix:t.getUniformLocation(l,"u_textureMatrix")}}),Un(this,Xn,e(t)),Un(this,zn,i(t)),Un(this,Yn,p)}const r=(t,e,i)=>{t.bindBuffer(t.ARRAY_BUFFER,e),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0)},s=(t,e,i)=>{const n=t.RGBA,r=t.RGBA,s=t.UNSIGNED_BYTE;t.bindTexture(t.TEXTURE_2D,e),t.texImage2D(t.TEXTURE_2D,0,n,r,s,i)},v=(t,e,s,a)=>{t.clearColor(0,0,0,1),t.clearDepth(1),t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),r(t,s.positions,e.attribLocations.vertexPosition),r(t,s.texCoords,e.attribLocations.texPosition),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,a),t.uniform1i(e.uniformLocations.uSampler,0),t.uniform1f(e.uniformLocations.uColorFactor,[Wn.GREY,Wn.GREY32].includes(p)?1:0);let m,_,v=Gn.translate(Gn.identity(),-1,-1);v=Gn.scale(v,2,2),v=Gn.scale(v,1/t.canvas.width,1/t.canvas.height),m=Gn.translate(v,u,d),m=Gn.scale(m,f,g),t.uniformMatrix3fv(e.uniformLocations.uMatrix,!1,m),_=Gn.translate(Gn.identity(),o/i,l/n),_=Gn.scale(_,h/i,c/n),t.uniformMatrix3fv(e.uniformLocations.uTextureMatrix,!1,_),t.drawArrays(t.TRIANGLES,0,6)};s(t,jn(this,zn,"f"),e),v(t,jn(this,Hn,"f"),jn(this,Xn,"f"),jn(this,zn,"f"));const y=m||new Uint8Array(4*f*g);if(t.readPixels(u,d,f,g,t.RGBA,t.UNSIGNED_BYTE,y),255!==y[3]){Vr._onLog&&Vr._onLog("Incorrect WebGL drawing .");const t=new Error("WebGL error: incorrect drawing.");throw t.name="WebGLError",t}return Vr._onLog&&Vr._onLog("drawImage() in WebGL end. Costs: "+(Date.now()-a)),{context:t,pixelFormat:p===Wn.GREY?Wn.GREY32:p,bUseWebGL:!0}}catch(a){if(this.forceLoseContext(),null==(null==s?void 0:s.bUseWebGL))return Vr._onLog&&Vr._onLog("'drawImage()' in WebGL failed, try again in context2d."),this.useWebGLByDefault=!1,this.drawImage(t,e,i,n,r,Object.assign({},s,{bUseWebGL:!1}));throw a.name="WebGLError",a}}readCvsData(t,e,i){if(!(t instanceof CanvasRenderingContext2D||t instanceof WebGLRenderingContext))throw new Error("Invalid 'context'.");let n,r=0,s=0,a=t.canvas.width,o=t.canvas.height;if(e&&(e.x&&(r=e.x),e.y&&(s=e.y),e.width&&(a=e.width),e.height&&(o=e.height)),(null==i?void 0:i.length)<4*a*o)throw new Error("Unexpected size of the 'bufferContainer'.");if(t instanceof WebGLRenderingContext){const e=t;i?(e.readPixels(r,s,a,o,e.RGBA,e.UNSIGNED_BYTE,i),n=new Uint8Array(i.buffer,0,4*a*o)):(n=new Uint8Array(4*a*o),e.readPixels(r,s,a,o,e.RGBA,e.UNSIGNED_BYTE,n))}else if(t instanceof CanvasRenderingContext2D){let e;e=t.getImageData(r,s,a,o),n=new Uint8Array(e.data.buffer),null==i||i.set(n)}return n}transformPixelFormat(t,e,i,n){let r,s;if(Vr._onLog&&(r=Date.now(),Vr._onLog("transformPixelFormat(), START: "+r)),e===i)return Vr._onLog&&Vr._onLog("transformPixelFormat() end. Costs: "+(Date.now()-r)),n?new Uint8Array(t):t;const a=[Wn.RGBA,Wn.RBGA,Wn.GRBA,Wn.GBRA,Wn.BRGA,Wn.BGRA];if(a.includes(e))if(i===Wn.GREY){s=new Uint8Array(t.length/4);for(let e=0;el||e.sy+e.sHeight>h)throw new Error("Invalid position.");null===(n=Vr._onLog)||void 0===n||n.call(Vr,"getImageData(), START: "+(c=Date.now()));const d=Math.round(e.sx),f=Math.round(e.sy),g=Math.round(e.sWidth),m=Math.round(e.sHeight),p=Math.round(e.dWidth),_=Math.round(e.dHeight);let v,y=(null==i?void 0:i.pixelFormat)||Wn.RGBA,w=null==i?void 0:i.bufferContainer;if(w&&(Wn.GREY===y&&w.length{this.disposed||n.includes(r)&&r.apply(i.target,s)}),0);else try{a=r.apply(i.target,s)}catch(t){}if(!0===a)break}}}dispose(){Mn(this,Kn,!0)}}Jn=new WeakMap,Kn=new WeakMap;const Ur=(t,e,i,n)=>{if(!i)return t;let r=e+Math.round((t-e)/i)*i;return n&&(r=Math.min(r,n)),r};class Gr{static get version(){return"2.0.18"}static isStorageAvailable(t){let e;try{e=window[t];const i="__storage_test__";return e.setItem(i,i),e.removeItem(i),!0}catch(t){return t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name)&&e&&0!==e.length}}static findBestRearCameraInIOS(t,e){if(!t||!t.length)return null;let i=!1;if((null==e?void 0:e.getMainCamera)&&(i=!0),i){const e=["후면 카메라","背面カメラ","後置鏡頭","后置相机","กล้องด้านหลัง","बैक कैमरा","الكاميرا الخلفية","מצלמה אחורית","камера на задней панели","задня камера","задна камера","артқы камера","πίσω κάμερα","zadní fotoaparát","zadná kamera","tylny aparat","takakamera","stražnja kamera","rückkamera","kamera på baksidan","kamera belakang","kamera bak","hátsó kamera","fotocamera (posteriore)","câmera traseira","câmara traseira","cámara trasera","càmera posterior","caméra arrière","cameră spate","camera mặt sau","camera aan achterzijde","bagsidekamera","back camera","arka kamera"],i=t.find((t=>e.includes(t.label.toLowerCase())));return null==i?void 0:i.deviceId}{const e=["후면","背面","後置","后置","านหลัง","बैक","خلفية","אחורית","задняя","задней","задна","πίσω","zadní","zadná","tylny","trasera","traseira","taka","stražnja","spate","sau","rück","posteriore","posterior","hátsó","belakang","baksidan","bakre","bak","bagside","back","aртқы","arrière","arka","achterzijde"],i=["트리플","三镜头","三鏡頭","トリプル","สาม","ट्रिपल","ثلاثية","משולשת","үштік","тройная","тройна","потроєна","τριπλή","üçlü","trójobiektywowy","trostruka","trojný","trojitá","trippelt","trippel","triplă","triple","tripla","tiga","kolmois","ba camera"],n=["듀얼 와이드","雙廣角","双广角","デュアル広角","คู่ด้านหลังมุมกว้าง","ड्युअल वाइड","مزدوجة عريضة","כפולה רחבה","қос кең бұрышты","здвоєна ширококутна","двойная широкоугольная","двойна широкоъгълна","διπλή ευρεία","ç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"],r=t.filter((t=>{const i=t.label.toLowerCase();return e.some((t=>i.includes(t)))}));if(!r.length)return null;const s=r.find((t=>{const e=t.label.toLowerCase();return i.some((t=>e.includes(t)))}));if(s)return s.deviceId;const a=r.find((t=>{const e=t.label.toLowerCase();return n.some((t=>e.includes(t)))}));return a?a.deviceId:r[0].deviceId}}static findBestRearCamera(t,e){if(!t||!t.length)return null;if(["iPhone","iPad","Mac"].includes(Vn.OS))return Gr.findBestRearCameraInIOS(t,{getMainCamera:null==e?void 0:e.getMainCameraInIOS});const i=["후","背面","背置","後面","後置","后面","后置","านหลัง","หลัง","बैक","خلفية","אחורית","задняя","задня","задней","задна","πίσω","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"];for(let e of t){const t=e.label.toLowerCase();if(t&&i.some((e=>t.includes(e)))&&/\b0(\b)?/.test(t))return e.deviceId}return["Android","HarmonyOS"].includes(Vn.OS)?t[t.length-1].deviceId:null}static findBestCamera(t,e,i){return t&&t.length?"environment"===e?this.findBestRearCamera(t,i):"user"===e?null:e?void 0:null:null}static async playVideo(t,e,i){if(!t)throw new Error("Invalid 'videoEl'.");if(!e)throw new Error("Invalid 'source'.");return new Promise((async(n,r)=>{let s;const a=()=>{t.removeEventListener("loadstart",c),t.removeEventListener("abort",u),t.removeEventListener("play",d),t.removeEventListener("error",f),t.removeEventListener("loadedmetadata",p)};let o=!1;const l=()=>{o=!0,s&&clearTimeout(s),a(),n(t)},h=t=>{s&&clearTimeout(s),a(),r(t)},c=()=>{t.addEventListener("abort",u,{once:!0})},u=()=>{const t=new Error("Video playing was interrupted.");t.name="AbortError",h(t)},d=()=>{l()},f=()=>{h(new Error(`Video error ${t.error.code}: ${t.error.message}.`))};let g;const m=new Promise((t=>{g=t})),p=()=>{g()};if(t.addEventListener("loadstart",c,{once:!0}),t.addEventListener("play",d,{once:!0}),t.addEventListener("error",f,{once:!0}),t.addEventListener("loadedmetadata",p,{once:!0}),"string"==typeof e||e instanceof String?t.src=e:t.srcObject=e,t.autoplay&&await new Promise((t=>{setTimeout(t,1e3)})),!o){i&&(s=setTimeout((()=>{a(),r(new Error("Failed to play video. Timeout."))}),i)),await m;try{await t.play(),l()}catch(t){console.warn("1st play error: "+((null==t?void 0:t.message)||t))}if(!o)try{await t.play(),l()}catch(t){console.warn("2rd play error: "+((null==t?void 0:t.message)||t)),h(t)}}}))}static async testCameraAccess(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))return{ok:!1,errorName:"InsecureContext",errorMessage:"Insecure context."};let n;try{n=t?await navigator.mediaDevices.getUserMedia(t):await navigator.mediaDevices.getUserMedia({video:!0})}catch(t){return{ok:!1,errorName:t.name,errorMessage:t.message}}finally{null==n||n.getTracks().forEach((t=>{t.stop()}))}return{ok:!0}}get state(){if(!Ln(this,ur,"f"))return"closed";if("pending"===Ln(this,ur,"f"))return"opening";if("fulfilled"===Ln(this,ur,"f"))return"opened";throw new Error("Unknown state.")}set ifSaveLastUsedCamera(t){t?Gr.isStorageAvailable("localStorage")?Mn(this,or,!0):(Mn(this,or,!1),console.warn("Local storage is unavailable")):Mn(this,or,!1)}get ifSaveLastUsedCamera(){return Ln(this,or,"f")}get isVideoPlaying(){return!(!Ln(this,tr,"f")||Ln(this,tr,"f").paused)&&"opened"===this.state}set tapFocusEventBoundEl(t){var e,i,n;if(!(t instanceof HTMLElement)&&null!=t)throw new TypeError("Invalid 'element'.");null===(e=Ln(this,_r,"f"))||void 0===e||e.removeEventListener("click",Ln(this,pr,"f")),null===(i=Ln(this,_r,"f"))||void 0===i||i.removeEventListener("touchend",Ln(this,pr,"f")),null===(n=Ln(this,_r,"f"))||void 0===n||n.removeEventListener("touchmove",Ln(this,mr,"f")),Mn(this,_r,t),t&&(window.TouchEvent&&["Android","HarmonyOS","iPhone","iPad"].includes(Vn.OS)?(t.addEventListener("touchend",Ln(this,pr,"f")),t.addEventListener("touchmove",Ln(this,mr,"f"))):t.addEventListener("click",Ln(this,pr,"f")))}get tapFocusEventBoundEl(){return Ln(this,_r,"f")}get disposed(){return Ln(this,Ir,"f")}constructor(t){var e,i;Qn.add(this),tr.set(this,null),er.set(this,void 0),ir.set(this,(()=>{"opened"===this.state&&Ln(this,Er,"f").fire("resumed",null,{target:this,async:!1})})),nr.set(this,(()=>{Ln(this,Er,"f").fire("paused",null,{target:this,async:!1})})),rr.set(this,void 0),sr.set(this,void 0),this.cameraOpenTimeout=15e3,this._arrCameras=[],ar.set(this,void 0),or.set(this,!1),this.ifSkipCameraInspection=!1,this.selectIOSRearMainCameraAsDefault=!1,lr.set(this,void 0),hr.set(this,!0),cr.set(this,void 0),ur.set(this,void 0),dr.set(this,!1),this._focusParameters={maxTimeout:400,minTimeout:300,kTimeout:void 0,oldDistance:null,fds:null,isDoingFocus:0,taskBackToContinous:null,curFocusTaskId:0,focusCancelableTime:1500,defaultFocusAreaSizeRatio:6,focusBackToContinousTime:5e3,tapFocusMinDistance:null,tapFocusMaxDistance:null,focusArea:null,tempBufferContainer:null,defaultTempBufferContainerLenRatio:1/4},fr.set(this,!1),this._focusSupported=!0,this.calculateCoordInVideo=(t,e)=>{let i,n;const r=window.getComputedStyle(Ln(this,tr,"f")).objectFit,s=this.getResolution(),a=Ln(this,tr,"f").getBoundingClientRect(),o=a.left,l=a.top,{width:h,height:c}=Ln(this,tr,"f").getBoundingClientRect();if(h<=0||c<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const u=h/c,d=s.width/s.height;let f=1;if("contain"===r)d>u?(f=h/s.width,i=(t-o)/f,n=(e-l-(c-h/d)/2)/f):(f=c/s.height,n=(e-l)/f,i=(t-o-(h-c*d)/2)/f);else{if("cover"!==r)throw new Error("Unsupported object-fit.");d>u?(f=c/s.height,n=(e-l)/f,i=(t-o+(c*d-h)/2)/f):(f=h/s.width,i=(t-o)/f,n=(e-l+(h/d-c)/2)/f)}return{x:i,y:n}},gr.set(this,!1),mr.set(this,(()=>{Mn(this,gr,!0)})),pr.set(this,(async t=>{var e;if(Ln(this,gr,"f"))return void Mn(this,gr,!1);if(!Ln(this,fr,"f"))return;if(!this.isVideoPlaying)return;if(!Ln(this,er,"f"))return;if(!this._focusSupported)return;if(!this._focusParameters.fds&&(this._focusParameters.fds=null===(e=this.getCameraCapabilities())||void 0===e?void 0:e.focusDistance,!this._focusParameters.fds))return void(this._focusSupported=!1);if(null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),1==this._focusParameters.isDoingFocus)return;let i,n;if(this._focusParameters.taskBackToContinous&&(clearTimeout(this._focusParameters.taskBackToContinous),this._focusParameters.taskBackToContinous=null),t instanceof MouseEvent)i=t.clientX,n=t.clientY;else{if(!(t instanceof TouchEvent))throw new Error("Unknown event type.");if(!t.changedTouches.length)return;i=t.changedTouches[0].clientX,n=t.changedTouches[0].clientY}const r=this.getResolution(),s=2*Math.round(Math.min(r.width,r.height)/this._focusParameters.defaultFocusAreaSizeRatio/2);let a;try{a=this.calculateCoordInVideo(i,n)}catch(t){}if(a.x<0||a.x>r.width||a.y<0||a.y>r.height)return;const o={x:a.x+"px",y:a.y+"px"},l=s+"px",h=l;let c;Gr._onLog&&(c=Date.now());try{await Ln(this,Qn,"m",kr).call(this,o,l,h,this._focusParameters.tapFocusMinDistance,this._focusParameters.tapFocusMaxDistance)}catch(t){if(Gr._onLog)throw Gr._onLog(t),t}Gr._onLog&&Gr._onLog(`Tap focus costs: ${Date.now()-c} ms`),this._focusParameters.taskBackToContinous=setTimeout((()=>{var t;Gr._onLog&&Gr._onLog("Back to continuous focus."),null===(t=Ln(this,er,"f"))||void 0===t||t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch((()=>{}))}),this._focusParameters.focusBackToContinousTime),Ln(this,Er,"f").fire("tapfocus",null,{target:this,async:!1})})),_r.set(this,null),vr.set(this,1),yr.set(this,{x:0,y:0}),this.updateVideoElWhenSoftwareScaled=()=>{if(!Ln(this,tr,"f"))return;const t=Ln(this,vr,"f");if(t<1)throw new RangeError("Invalid scale value.");if(1===t)Ln(this,tr,"f").style.transform="";else{const e=window.getComputedStyle(Ln(this,tr,"f")).objectFit,i=Ln(this,tr,"f").videoWidth,n=Ln(this,tr,"f").videoHeight,{width:r,height:s}=Ln(this,tr,"f").getBoundingClientRect();if(r<=0||s<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const a=r/s,o=i/n;let l=1;"contain"===e?l=aa?s/(i/t):r/(n/t));const h=l*(1-1/t)*(i/2-Ln(this,yr,"f").x),c=l*(1-1/t)*(n/2-Ln(this,yr,"f").y);Ln(this,tr,"f").style.transform=`translate(${h}px, ${c}px) scale(${t})`}},wr.set(this,(function(){if(!(this.data instanceof Uint8Array||this.data instanceof Uint8ClampedArray))throw new TypeError("Invalid data.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const t=document.createElement("canvas");let e;if(t.width=this.width,t.height=this.height,this.pixelFormat===Wn.GREY){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t{var t,e;if("visible"===document.visibilityState){if(Gr._onLog&&Gr._onLog("document visible. video paused: "+(null===(t=Ln(this,tr,"f"))||void 0===t?void 0:t.paused)),"opening"==this.state||"opened"==this.state){let e=!1;if(!this.isVideoPlaying){Gr._onLog&&Gr._onLog("document visible. Not auto resume. 1st resume start.");try{await this.resume(),e=!0}catch(t){Gr._onLog&&Gr._onLog("document visible. 1st resume video failed, try open instead.")}e||await Ln(this,Qn,"m",Ar).call(this)}if(await new Promise((t=>setTimeout(t,300))),!this.isVideoPlaying){Gr._onLog&&Gr._onLog("document visible. 1st open failed. 2rd resume start."),e=!1;try{await this.resume(),e=!0}catch(t){Gr._onLog&&Gr._onLog("document visible. 2rd resume video failed, try open instead.")}e||await Ln(this,Qn,"m",Ar).call(this)}}}else"hidden"===document.visibilityState&&(Gr._onLog&&Gr._onLog("document hidden. video paused: "+(null===(e=Ln(this,tr,"f"))||void 0===e?void 0:e.paused)),"opening"==this.state||"opened"==this.state&&this.isVideoPlaying&&this.pause())})),Ir.set(this,!1),(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia)||setTimeout((()=>{Gr.onWarning&&Gr.onWarning("The browser is too old or the page is loaded from an insecure origin.")}),0),this.defaultConstraints={video:{facingMode:{ideal:"environment"}}},this.resetMediaStreamConstraints(),t instanceof HTMLVideoElement&&this.setVideoEl(t),Mn(this,Er,new jr),this.imageDataGetter=new Vr,document.addEventListener("visibilitychange",Ln(this,br,"f"))}setVideoEl(t){if(!(t&&t instanceof HTMLVideoElement))throw new Error("Invalid 'videoEl'.");t.addEventListener("play",Ln(this,ir,"f")),t.addEventListener("pause",Ln(this,nr,"f")),Mn(this,tr,t)}getVideoEl(){return Ln(this,tr,"f")}releaseVideoEl(){var t,e;null===(t=Ln(this,tr,"f"))||void 0===t||t.removeEventListener("play",Ln(this,ir,"f")),null===(e=Ln(this,tr,"f"))||void 0===e||e.removeEventListener("pause",Ln(this,nr,"f")),Mn(this,tr,null)}isVideoLoaded(){return!!Ln(this,tr,"f")&&4==Ln(this,tr,"f").readyState}async open(){if(Ln(this,cr,"f")&&!Ln(this,hr,"f")){if("pending"===Ln(this,ur,"f"))return Ln(this,cr,"f");if("fulfilled"===Ln(this,ur,"f"))return}Ln(this,Er,"f").fire("before:open",null,{target:this}),await Ln(this,Qn,"m",Ar).call(this),Ln(this,Er,"f").fire("played",null,{target:this,async:!1}),Ln(this,Er,"f").fire("opened",null,{target:this,async:!1})}async close(){if("closed"===this.state)return;Ln(this,Er,"f").fire("before:close",null,{target:this});const t=Ln(this,cr,"f");if(Ln(this,Qn,"m",Mr).call(this),t&&"pending"===Ln(this,ur,"f")){try{await t}catch(t){}if(!1===Ln(this,hr,"f")){const t=new Error("'close()' was interrupted.");throw t.name="AbortError",t}}Mn(this,cr,null),Mn(this,ur,null),Ln(this,Er,"f").fire("closed",null,{target:this,async:!1})}pause(){if(!this.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==this.state)throw new Error("Camera or video is not open.");Ln(this,tr,"f").pause()}async resume(){if(!this.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==this.state)throw new Error("Camera or video is not open.");await Ln(this,tr,"f").play()}async setCamera(t){if("string"!=typeof t)throw new TypeError("Invalid 'deviceId'.");if("object"!=typeof Ln(this,rr,"f").video&&(Ln(this,rr,"f").video={}),delete Ln(this,rr,"f").video.facingMode,Ln(this,rr,"f").video.deviceId={exact:t},!("closed"===this.state||this.videoSrc||"opening"===this.state&&Ln(this,hr,"f"))){Ln(this,Er,"f").fire("before:camera:change",[],{target:this,async:!1}),await Ln(this,Qn,"m",Lr).call(this);try{this.resetSoftwareScale()}catch(t){}return Ln(this,sr,"f")}}async switchToFrontCamera(t){if("object"!=typeof Ln(this,rr,"f").video&&(Ln(this,rr,"f").video={}),(null==t?void 0:t.resolution)&&(Ln(this,rr,"f").video.width={ideal:t.resolution.width},Ln(this,rr,"f").video.height={ideal:t.resolution.height}),delete Ln(this,rr,"f").video.deviceId,Ln(this,rr,"f").video.facingMode={exact:"user"},Mn(this,ar,null),!("closed"===this.state||this.videoSrc||"opening"===this.state&&Ln(this,hr,"f"))){Ln(this,Er,"f").fire("before:camera:change",[],{target:this,async:!1}),Ln(this,Qn,"m",Lr).call(this);try{this.resetSoftwareScale()}catch(t){}return Ln(this,sr,"f")}}getCamera(){var t;if(Ln(this,sr,"f"))return Ln(this,sr,"f");{let e=(null===(t=Ln(this,rr,"f").video)||void 0===t?void 0:t.deviceId)||"";if(e){e=e.exact||e.ideal||e;for(let t of this._arrCameras)if(t.deviceId===e)return JSON.parse(JSON.stringify(t))}return{deviceId:"",label:"",_checked:!1}}}async _getCameras(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let n;if(t){let t=await navigator.mediaDevices.getUserMedia({video:!0});n=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind)),t.getTracks().forEach((t=>{t.stop()}))}else n=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind));const r=[],s=[];if(this._arrCameras)for(let t of this._arrCameras)t._checked&&s.push(t);for(let t=0;t"videoinput"===t.kind));return i&&i.length&&!i[0].deviceId?this._getCameras(!0):this._getCameras(!1)}async getAllCameras(){return this.getCameras()}async setResolution(t,e,i){if("number"!=typeof t||t<=0)throw new TypeError("Invalid 'width'.");if("number"!=typeof e||e<=0)throw new TypeError("Invalid 'height'.");if("object"!=typeof Ln(this,rr,"f").video&&(Ln(this,rr,"f").video={}),i?(Ln(this,rr,"f").video.width={exact:t},Ln(this,rr,"f").video.height={exact:e}):(Ln(this,rr,"f").video.width={ideal:t},Ln(this,rr,"f").video.height={ideal:e}),"closed"===this.state||this.videoSrc||"opening"===this.state&&Ln(this,hr,"f"))return null;Ln(this,Er,"f").fire("before:resolution:change",[],{target:this,async:!1}),await Ln(this,Qn,"m",Lr).call(this);try{this.resetSoftwareScale()}catch(t){}const n=this.getResolution();return{width:n.width,height:n.height}}getResolution(){if("opened"===this.state&&this.videoSrc&&Ln(this,tr,"f"))return{width:Ln(this,tr,"f").videoWidth,height:Ln(this,tr,"f").videoHeight};if(Ln(this,er,"f")){const t=Ln(this,er,"f").getSettings();return{width:t.width,height:t.height}}if(this.isVideoLoaded())return{width:Ln(this,tr,"f").videoWidth,height:Ln(this,tr,"f").videoHeight};{const t={width:0,height:0};let e=Ln(this,rr,"f").video.width||0,i=Ln(this,rr,"f").video.height||0;return e&&(t.width=e.exact||e.ideal||e),i&&(t.height=i.exact||i.ideal||i),t}}async getResolutions(t){var e,i,n,r,s,a,o,l,h,c,u;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let d="";const f=(t,e)=>{const i=Ln(this,Sr,"f").get(t);if(!i||!i.length)return!1;for(let t of i)if(t.width===e.width&&t.height===e.height)return!0;return!1};if(this._mediaStream){d=null===(u=Ln(this,sr,"f"))||void 0===u?void 0:u.deviceId;let e=Ln(this,Sr,"f").get(d);if(e&&!t)return JSON.parse(JSON.stringify(e));e=[],Ln(this,Sr,"f").set(d,e),Mn(this,dr,!0);try{for(let t of this.detectedResolutions){await Ln(this,er,"f").applyConstraints({width:{ideal:t.width},height:{ideal:t.height}}),Ln(this,Qn,"m",Rr).call(this);const i=Ln(this,er,"f").getSettings(),n={width:i.width,height:i.height};f(d,n)||e.push({width:n.width,height:n.height})}}catch(t){throw Ln(this,Qn,"m",Mr).call(this),Mn(this,dr,!1),t}try{await Ln(this,Qn,"m",Ar).call(this)}catch(t){if("AbortError"===t.name)return e;throw t}finally{Mn(this,dr,!1)}return e}{const e=async(t,e,i)=>{const n={video:{deviceId:{exact:t},width:{ideal:e},height:{ideal:i}}};let r=null;try{r=await navigator.mediaDevices.getUserMedia(n)}catch(t){return null}if(!r)return null;const s=r.getVideoTracks();let a=null;try{const t=s[0].getSettings();a={width:t.width,height:t.height}}catch(t){const e=document.createElement("video");e.srcObject=r,a={width:e.videoWidth,height:e.videoHeight},e.srcObject=null}return s.forEach((t=>{t.stop()})),a};let i=(null===(s=null===(r=null===(n=Ln(this,rr,"f"))||void 0===n?void 0:n.video)||void 0===r?void 0:r.deviceId)||void 0===s?void 0:s.exact)||(null===(l=null===(o=null===(a=Ln(this,rr,"f"))||void 0===a?void 0:a.video)||void 0===o?void 0:o.deviceId)||void 0===l?void 0:l.ideal)||(null===(c=null===(h=Ln(this,rr,"f"))||void 0===h?void 0:h.video)||void 0===c?void 0:c.deviceId);if(!i)return[];let u=Ln(this,Sr,"f").get(i);if(u&&!t)return JSON.parse(JSON.stringify(u));u=[],Ln(this,Sr,"f").set(i,u);for(let t of this.detectedResolutions){const n=await e(i,t.width,t.height);n&&!f(i,n)&&u.push({width:n.width,height:n.height})}return u}}async setMediaStreamConstraints(t,e){if(!(t=>{return null!==t&&"[object Object]"===(e=t,Object.prototype.toString.call(e));var e})(t))throw new TypeError("Invalid 'mediaStreamConstraints'.");Mn(this,rr,JSON.parse(JSON.stringify(t))),Mn(this,ar,null),e&&Ln(this,Qn,"m",Lr).call(this)}getMediaStreamConstraints(){return JSON.parse(JSON.stringify(Ln(this,rr,"f")))}resetMediaStreamConstraints(){Mn(this,rr,this.defaultConstraints?JSON.parse(JSON.stringify(this.defaultConstraints)):null)}getCameraCapabilities(){if(!Ln(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return Ln(this,er,"f").getCapabilities?Ln(this,er,"f").getCapabilities():{}}getCameraSettings(){if(!Ln(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return Ln(this,er,"f").getSettings()}async turnOnTorch(){if(!Ln(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const t=this.getCameraCapabilities();if(!(null==t?void 0:t.torch))throw Error("Not supported.");await Ln(this,er,"f").applyConstraints({advanced:[{torch:!0}]})}async turnOffTorch(){if(!Ln(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const t=this.getCameraCapabilities();if(!(null==t?void 0:t.torch))throw Error("Not supported.");await Ln(this,er,"f").applyConstraints({advanced:[{torch:!1}]})}async setColorTemperature(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!Ln(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.colorTemperature;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Ur(t,n.min,n.step,n.max)),await Ln(this,er,"f").applyConstraints({advanced:[{colorTemperature:t,whiteBalanceMode:"manual"}]}),t}getColorTemperature(){return this.getCameraSettings().colorTemperature||0}async setExposureCompensation(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!Ln(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.exposureCompensation;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Ur(t,n.min,n.step,n.max)),await Ln(this,er,"f").applyConstraints({advanced:[{exposureCompensation:t}]}),t}getExposureCompensation(){return this.getCameraSettings().exposureCompensation||0}async setFrameRate(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!Ln(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");let n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.frameRate;if(!n)throw Error("Not supported.");e&&(tn.max&&(t=n.max));const r=this.getResolution();return await Ln(this,er,"f").applyConstraints({width:{ideal:Math.max(r.width,r.height)},frameRate:t}),t}getFrameRate(){return this.getCameraSettings().frameRate}async setFocus(t,e){if("object"!=typeof t||Array.isArray(t)||null==t)throw new TypeError("Invalid 'settings'.");if(!Ln(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const i=this.getCameraCapabilities(),n=null==i?void 0:i.focusMode,r=null==i?void 0:i.focusDistance;if(!n)throw Error("Not supported.");if("string"!=typeof t.mode)throw TypeError("Invalid 'mode'.");const s=t.mode.toLowerCase();if(!n.includes(s))throw Error("Unsupported focus mode.");if("manual"===s){if(!r)throw Error("Manual focus unsupported.");if(t.hasOwnProperty("distance")){let i=t.distance;e&&(ir.max&&(i=r.max),i=Ur(i,r.min,r.step,r.max)),this._focusParameters.focusArea=null,await Ln(this,er,"f").applyConstraints({advanced:[{focusMode:s,focusDistance:i}]})}else{if(!t.area)throw new Error("'distance' or 'area' should be specified in 'manual' mode.");{const e=t.area.centerPoint;let i=t.area.width,n=t.area.height;if(!i||!n){const t=this.getResolution();i||(i=2*Math.round(Math.min(t.width,t.height)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px"),n||(n=2*Math.round(Math.min(t.width,t.height)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px")}this._focusParameters.focusArea={centerPoint:{x:e.x,y:e.y},width:i,height:n},await Ln(this,Qn,"m",kr).call(this,e,i,n)}}}else this._focusParameters.focusArea=null,await Ln(this,er,"f").applyConstraints({advanced:[{focusMode:s}]})}getFocus(){const t=this.getCameraSettings(),e=t.focusMode;return e?"manual"===e?this._focusParameters.focusArea?{mode:"manual",area:JSON.parse(JSON.stringify(this._focusParameters.focusArea))}:{mode:"manual",distance:t.focusDistance}:{mode:e}:null}async enableTapToFocus(){Mn(this,fr,!0)}disableTapToFocus(){Mn(this,fr,!1)}isTapToFocusEnabled(){return Ln(this,fr,"f")}async setZoom(t){if("object"!=typeof t||Array.isArray(t)||null==t)throw new TypeError("Invalid 'settings'.");if("number"!=typeof t.factor)throw new TypeError("Illegal type of 'factor'.");if(t.factor<1)throw new RangeError("Invalid 'factor'.");if("opened"!==this.state)throw new Error("Video is not playing.");t.centerPoint?Ln(this,Qn,"m",Nr).call(this,t.centerPoint):this.resetScaleCenter();try{if(Ln(this,Qn,"m",Br).call(this,Ln(this,yr,"f"))){const e=await this.setHardwareScale(t.factor,!0);let i=this.getHardwareScale();1==i&&1!=e&&(i=e),t.factor>i?this.setSoftwareScale(t.factor/i):this.setSoftwareScale(1)}else await this.setHardwareScale(1),this.setSoftwareScale(t.factor)}catch(e){const i=e.message||e;if("Not supported."!==i&&"Camera is not open."!==i)throw e;this.setSoftwareScale(t.factor)}}getZoom(){if("opened"!==this.state)throw new Error("Video is not playing.");let t=1;try{t=this.getHardwareScale()}catch(t){if("Camera is not open."!==(t.message||t))throw t}return{factor:t*Ln(this,vr,"f")}}async resetZoom(){await this.setZoom({factor:1})}async setHardwareScale(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(t<1)throw new RangeError("Invalid 'value'.");if(!Ln(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.zoom;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Ur(t,n.min,n.step,n.max)),await Ln(this,er,"f").applyConstraints({advanced:[{zoom:t}]}),t}getHardwareScale(){return this.getCameraSettings().zoom||1}setSoftwareScale(t,e){if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(t<1)throw new RangeError("Invalid 'value'.");if("opened"!==this.state)throw new Error("Video is not playing.");e&&Ln(this,Qn,"m",Nr).call(this,e),Mn(this,vr,t),this.updateVideoElWhenSoftwareScaled()}getSoftwareScale(){return Ln(this,vr,"f")}resetScaleCenter(){if("opened"!==this.state)throw new Error("Video is not playing.");const t=this.getResolution();Mn(this,yr,{x:t.width/2,y:t.height/2})}resetSoftwareScale(){this.setSoftwareScale(1),this.resetScaleCenter()}getFrameData(t){if(this.disposed)throw Error("The 'Camera' instance has been disposed.");if(!this.isVideoLoaded())return null;if(Ln(this,dr,"f"))return null;const e=Date.now();Gr._onLog&&Gr._onLog("getFrameData() START: "+e);const i=Ln(this,tr,"f").videoWidth,n=Ln(this,tr,"f").videoHeight;let r={sx:0,sy:0,sWidth:i,sHeight:n,dWidth:i,dHeight:n};(null==t?void 0:t.position)&&(r=JSON.parse(JSON.stringify(t.position)));let s=Wn.RGBA;(null==t?void 0:t.pixelFormat)&&(s=t.pixelFormat);let a=Ln(this,vr,"f");(null==t?void 0:t.scale)&&(a=t.scale);let o=Ln(this,yr,"f");if(null==t?void 0:t.scaleCenter){if("string"!=typeof t.scaleCenter.x||"string"!=typeof t.scaleCenter.y)throw new Error("Invalid scale center.");let e=0,r=0;if(t.scaleCenter.x.endsWith("px"))e=parseFloat(t.scaleCenter.x);else{if(!t.scaleCenter.x.endsWith("%"))throw new Error("Invalid scale center.");e=parseFloat(t.scaleCenter.x)/100*i}if(t.scaleCenter.y.endsWith("px"))r=parseFloat(t.scaleCenter.y);else{if(!t.scaleCenter.y.endsWith("%"))throw new Error("Invalid scale center.");r=parseFloat(t.scaleCenter.y)/100*n}if(isNaN(e)||isNaN(r))throw new Error("Invalid scale center.");o.x=Math.round(e),o.y=Math.round(r)}let l=null;if((null==t?void 0:t.bufferContainer)&&(l=t.bufferContainer),0==i||0==n)return null;1!==a&&(r.sWidth=Math.round(r.sWidth/a),r.sHeight=Math.round(r.sHeight/a),r.sx=Math.round((1-1/a)*o.x+r.sx/a),r.sy=Math.round((1-1/a)*o.y+r.sy/a));const h=this.imageDataGetter.getImageData(Ln(this,tr,"f"),r,{pixelFormat:s,bufferContainer:l});if(!h)return null;const c=Date.now();return Gr._onLog&&Gr._onLog("getFrameData() END: "+c),{data:h.data,width:h.width,height:h.height,pixelFormat:h.pixelFormat,timeSpent:c-e,timeStamp:c,toCanvas:Ln(this,wr,"f")}}on(t,e){if(!Ln(this,Cr,"f").includes(t.toLowerCase()))throw new Error(`Event '${t}' does not exist.`);Ln(this,Er,"f").on(t,e)}off(t,e){Ln(this,Er,"f").off(t,e)}async dispose(){this.tapFocusEventBoundEl=null,await this.close(),this.releaseVideoEl(),Ln(this,Er,"f").dispose(),this.imageDataGetter.dispose(),document.removeEventListener("visibilitychange",Ln(this,br,"f")),Mn(this,Ir,!0)}}var Wr,Yr,zr,Hr,Xr,Zr,qr,Jr,Kr,$r,Qr,ts,es,is,ns,rs,ss,as,os,ls,hs,cs,us,ds,fs,gs,ms,ps,_s,vs,ys,ws,Es,Cs,Ss;tr=new WeakMap,er=new WeakMap,ir=new WeakMap,nr=new WeakMap,rr=new WeakMap,sr=new WeakMap,ar=new WeakMap,or=new WeakMap,lr=new WeakMap,hr=new WeakMap,cr=new WeakMap,ur=new WeakMap,dr=new WeakMap,fr=new WeakMap,gr=new WeakMap,mr=new WeakMap,pr=new WeakMap,_r=new WeakMap,vr=new WeakMap,yr=new WeakMap,wr=new WeakMap,Er=new WeakMap,Cr=new WeakMap,Sr=new WeakMap,Tr=new WeakMap,br=new WeakMap,Ir=new WeakMap,Qn=new WeakSet,xr=async function(){const t=this.getMediaStreamConstraints();if("boolean"==typeof t.video&&(t.video={}),t.video.deviceId);else if(Ln(this,ar,"f"))delete t.video.facingMode,t.video.deviceId={exact:Ln(this,ar,"f")};else if(this.ifSaveLastUsedCamera&&Gr.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")){delete t.video.facingMode,t.video.deviceId={ideal:window.localStorage.getItem("dce_last_camera_id")};const e=JSON.parse(window.localStorage.getItem("dce_last_apply_width")),i=JSON.parse(window.localStorage.getItem("dce_last_apply_height"));e&&i&&(t.video.width=e,t.video.height=i)}else if(this.ifSkipCameraInspection);else{const e=async t=>{let e=null;return"environment"===t&&["Android","HarmonyOS","iPhone","iPad"].includes(Vn.OS)?(await this._getCameras(!1),Ln(this,Qn,"m",Rr).call(this),e=Gr.findBestCamera(this._arrCameras,"environment",{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault})):t||["Android","HarmonyOS","iPhone","iPad"].includes(Vn.OS)||(await this._getCameras(!1),Ln(this,Qn,"m",Rr).call(this),e=Gr.findBestCamera(this._arrCameras,null,{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault})),e};let i=t.video.facingMode;i instanceof Array&&i.length&&(i=i[0]),"object"==typeof i&&(i=i.exact||i.ideal);const n=await e(i);n&&(delete t.video.facingMode,t.video.deviceId={exact:n})}return t},Rr=function(){if(Ln(this,hr,"f")){const t=new Error("The operation was interrupted.");throw t.name="AbortError",t}},Or=async function(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let n;try{Gr._onLog&&Gr._onLog("======try getUserMedia========");let e=[0,500,1e3,2e3],i=null;const r=async t=>{for(let r of e){r&&(await new Promise((t=>setTimeout(t,r))),Ln(this,Qn,"m",Rr).call(this));try{Gr._onLog&&Gr._onLog("ask "+JSON.stringify(t)),n=await navigator.mediaDevices.getUserMedia(t),Ln(this,Qn,"m",Rr).call(this);break}catch(t){if("NotFoundError"===t.name||"NotAllowedError"===t.name||"AbortError"===t.name||"OverconstrainedError"===t.name)throw t;i=t,Gr._onLog&&Gr._onLog(t.message||t)}}};if(await r(t),n||"object"!=typeof t.video||(t.video.deviceId&&(delete t.video.deviceId,await r(t)),!n&&t.video.facingMode&&(delete t.video.facingMode,await r(t)),n||!t.video.width&&!t.video.height||(delete t.video.width,delete t.video.height,await r(t))),!n)throw i;return n}catch(t){throw null==n||n.getTracks().forEach((t=>{t.stop()})),"NotFoundError"===t.name&&(DOMException?t=new DOMException("No camera available, please use a device with an accessible camera.",t.name):(t=new Error("No camera available, please use a device with an accessible camera.")).name="NotFoundError"),t}},Dr=function(){this._mediaStream&&(this._mediaStream.getTracks().forEach((t=>{t.stop()})),this._mediaStream=null),Mn(this,er,null)},Ar=async function(){Mn(this,hr,!1);const t=Mn(this,lr,Symbol());if(Ln(this,cr,"f")&&"pending"===Ln(this,ur,"f")){try{await Ln(this,cr,"f")}catch(t){}Ln(this,Qn,"m",Rr).call(this)}if(t!==Ln(this,lr,"f"))return;const e=Mn(this,cr,(async()=>{Mn(this,ur,"pending");try{if(this.videoSrc){if(!Ln(this,tr,"f"))throw new Error("'videoEl' should be set.");await Gr.playVideo(Ln(this,tr,"f"),this.videoSrc,this.cameraOpenTimeout),Ln(this,Qn,"m",Rr).call(this)}else{let t=await Ln(this,Qn,"m",xr).call(this);Ln(this,Qn,"m",Dr).call(this);let e=await Ln(this,Qn,"m",Or).call(this,t);await this._getCameras(!1),Ln(this,Qn,"m",Rr).call(this);const i=()=>{const t=e.getVideoTracks();let i,n;if(t.length&&(i=t[0]),i){const t=i.getSettings();if(t)for(let e of this._arrCameras)if(t.deviceId===e.deviceId){e._checked=!0,e.label=i.label,n=e;break}}return n},n=Ln(this,rr,"f");if("object"==typeof n.video){let r=n.video.facingMode;if(r instanceof Array&&r.length&&(r=r[0]),"object"==typeof r&&(r=r.exact||r.ideal),!(Ln(this,ar,"f")||this.ifSaveLastUsedCamera&&Gr.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")||this.ifSkipCameraInspection||n.video.deviceId)){const n=i(),s=Gr.findBestCamera(this._arrCameras,r,{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault});s&&s!=(null==n?void 0:n.deviceId)&&(e.getTracks().forEach((t=>{t.stop()})),t.video.deviceId={exact:s},e=await Ln(this,Qn,"m",Or).call(this,t),Ln(this,Qn,"m",Rr).call(this))}}const r=i();(null==r?void 0:r.deviceId)&&(Mn(this,ar,r&&r.deviceId),this.ifSaveLastUsedCamera&&Gr.isStorageAvailable&&(window.localStorage.setItem("dce_last_camera_id",Ln(this,ar,"f")),"object"==typeof t.video&&t.video.width&&t.video.height&&(window.localStorage.setItem("dce_last_apply_width",JSON.stringify(t.video.width)),window.localStorage.setItem("dce_last_apply_height",JSON.stringify(t.video.height))))),Ln(this,tr,"f")&&(await Gr.playVideo(Ln(this,tr,"f"),e,this.cameraOpenTimeout),Ln(this,Qn,"m",Rr).call(this)),this._mediaStream=e;const s=e.getVideoTracks();(null==s?void 0:s.length)&&Mn(this,er,s[0]),Mn(this,sr,r)}}catch(t){throw Ln(this,Qn,"m",Mr).call(this),Mn(this,ur,null),t}Mn(this,ur,"fulfilled")})());return e},Lr=async function(){var t;if("closed"===this.state||this.videoSrc)return;const e=null===(t=Ln(this,sr,"f"))||void 0===t?void 0:t.deviceId,i=this.getResolution();await Ln(this,Qn,"m",Ar).call(this);const n=this.getResolution();e&&e!==Ln(this,sr,"f").deviceId&&Ln(this,Er,"f").fire("camera:changed",[Ln(this,sr,"f").deviceId,e],{target:this,async:!1}),i.width==n.width&&i.height==n.height||Ln(this,Er,"f").fire("resolution:changed",[{width:n.width,height:n.height},{width:i.width,height:i.height}],{target:this,async:!1}),Ln(this,Er,"f").fire("played",null,{target:this,async:!1})},Mr=function(){Ln(this,Qn,"m",Dr).call(this),Mn(this,sr,null),Ln(this,tr,"f")&&(Ln(this,tr,"f").srcObject=null,this.videoSrc&&(Ln(this,tr,"f").pause(),Ln(this,tr,"f").currentTime=0)),Mn(this,hr,!0);try{this.resetSoftwareScale()}catch(t){}},Fr=async function t(e,i){const n=t=>{if(!Ln(this,er,"f")||!this.isVideoPlaying||t.focusTaskId!=this._focusParameters.curFocusTaskId){Ln(this,er,"f")&&this.isVideoPlaying||(this._focusParameters.isDoingFocus=0);const e=new Error(`Focus task ${t.focusTaskId} canceled.`);throw e.name="DeprecatedTaskError",e}1===this._focusParameters.isDoingFocus&&Date.now()-t.timeStart>this._focusParameters.focusCancelableTime&&(this._focusParameters.isDoingFocus=-1)};let r;i=Ur(i,this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),await Ln(this,er,"f").applyConstraints({advanced:[{focusMode:"manual",focusDistance:i}]}),n(e),r=null==this._focusParameters.oldDistance?this._focusParameters.kTimeout*Math.max(Math.abs(1/this._focusParameters.fds.min-1/i),Math.abs(1/this._focusParameters.fds.max-1/i))+this._focusParameters.minTimeout:this._focusParameters.kTimeout*Math.abs(1/this._focusParameters.oldDistance-1/i)+this._focusParameters.minTimeout,this._focusParameters.oldDistance=i,await new Promise((t=>{setTimeout(t,r)})),n(e);let s=e.focusL-e.focusW/2,a=e.focusT-e.focusH/2,o=e.focusW,l=e.focusH;const h=this.getResolution();s=Math.round(s),a=Math.round(a),o=Math.round(o),l=Math.round(l),o>h.width&&(o=h.width),l>h.height&&(l=h.height),s<0?s=0:s+o>h.width&&(s=h.width-o),a<0?a=0:a+l>h.height&&(a=h.height-l);const c=4*h.width*h.height*this._focusParameters.defaultTempBufferContainerLenRatio,u=4*o*l;let d=this._focusParameters.tempBufferContainer;if(d){const t=d.length;c>t&&c>=u?d=new Uint8Array(c):u>t&&u>=c&&(d=new Uint8Array(u))}else d=this._focusParameters.tempBufferContainer=new Uint8Array(Math.max(c,u));if(!this.imageDataGetter.getImageData(Ln(this,tr,"f"),{sx:s,sy:a,sWidth:o,sHeight:l,dWidth:o,dHeight:l},{pixelFormat:Wn.RGBA,bufferContainer:d}))return Ln(this,Qn,"m",t).call(this,e,i);const f=d;let g=0;for(let t=0,e=u-8;to&&ou)return await Ln(this,Qn,"m",t).call(this,e,a,o,r,s,c,u)}else{let l=await Ln(this,Qn,"m",Fr).call(this,e,c);if(o>l)return await Ln(this,Qn,"m",t).call(this,e,a,o,r,s,c,l);if(o==l)return await Ln(this,Qn,"m",t).call(this,e,a,o,c,l);let u=await Ln(this,Qn,"m",Fr).call(this,e,h);if(u>o&&oa.width||l<0||l>a.height)throw new Error("Invalid 'centerPoint'.");let h=0;if(e.endsWith("px"))h=parseFloat(e);else{if(!e.endsWith("%"))throw new Error("Invalid 'width'.");h=parseFloat(e)/100*a.width}if(isNaN(h)||h<0)throw new Error("Invalid 'width'.");let c=0;if(i.endsWith("px"))c=parseFloat(i);else{if(!i.endsWith("%"))throw new Error("Invalid 'height'.");c=parseFloat(i)/100*a.height}if(isNaN(c)||c<0)throw new Error("Invalid 'height'.");if(1!==Ln(this,vr,"f")){const t=Ln(this,vr,"f"),e=Ln(this,yr,"f");h/=t,c/=t,o=(1-1/t)*e.x+o/t,l=(1-1/t)*e.y+l/t}if(!this._focusSupported)throw new Error("Manual focus unsupported.");if(!this._focusParameters.fds&&(this._focusParameters.fds=null===(s=this.getCameraCapabilities())||void 0===s?void 0:s.focusDistance,!this._focusParameters.fds))throw this._focusSupported=!1,new Error("Manual focus unsupported.");null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),this._focusParameters.isDoingFocus=1;const u={focusL:o,focusT:l,focusW:h,focusH:c,focusTaskId:++this._focusParameters.curFocusTaskId,timeStart:Date.now()},d=async(t,e,i)=>{try{(null==e||ethis._focusParameters.fds.max)&&(i=this._focusParameters.fds.max),this._focusParameters.oldDistance=null;let n=Ur(Math.sqrt(i*(e||this._focusParameters.fds.step)),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),r=Ur(Math.sqrt((e||this._focusParameters.fds.step)*n),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),s=Ur(Math.sqrt(n*i),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),a=await Ln(this,Qn,"m",Fr).call(this,t,s),o=await Ln(this,Qn,"m",Fr).call(this,t,r),l=await Ln(this,Qn,"m",Fr).call(this,t,n);if(o>l&&la&&o>a){let e=await Ln(this,Qn,"m",Fr).call(this,t,i);const r=await Ln(this,Qn,"m",Pr).call(this,t,n,l,i,e,s,a);return this._focusParameters.isDoingFocus=0,r}if(o==l&&ll){const e=await Ln(this,Qn,"m",Pr).call(this,t,n,l,s,a);return this._focusParameters.isDoingFocus=0,e}return d(t,e,i)}catch(t){if("DeprecatedTaskError"!==t.name)throw t}};return d(u,n,r)},Nr=function(t){if("opened"!==this.state)throw new Error("Video is not playing.");if(!t||"string"!=typeof t.x||"string"!=typeof t.y)throw new Error("Invalid 'center'.");const e=this.getResolution();let i=0,n=0;if(t.x.endsWith("px"))i=parseFloat(t.x);else{if(!t.x.endsWith("%"))throw new Error("Invalid scale center.");i=parseFloat(t.x)/100*e.width}if(t.y.endsWith("px"))n=parseFloat(t.y);else{if(!t.y.endsWith("%"))throw new Error("Invalid scale center.");n=parseFloat(t.y)/100*e.height}if(isNaN(i)||isNaN(n))throw new Error("Invalid scale center.");Mn(this,yr,{x:i,y:n})},Br=function(t){if("opened"!==this.state)throw new Error("Video is not playing.");const e=this.getResolution();return t&&t.x==e.width/2&&t.y==e.height/2},Gr.browserInfo=Vn,Gr.onWarning=null===($n=null===window||void 0===window?void 0:window.console)||void 0===$n?void 0:$n.warn;class Ts{constructor(t){Wr.add(this),Yr.set(this,void 0),zr.set(this,0),Hr.set(this,void 0),Xr.set(this,0),Zr.set(this,!1),Xe(this,Yr,t)}startCharging(){He(this,Zr,"f")||(Ts._onLog&&Ts._onLog("start charging."),He(this,Wr,"m",Jr).call(this),Xe(this,Zr,!0))}stopCharging(){He(this,Hr,"f")&&clearTimeout(He(this,Hr,"f")),He(this,Zr,"f")&&(Ts._onLog&&Ts._onLog("stop charging."),Xe(this,zr,Date.now()-He(this,Xr,"f")),Xe(this,Zr,!1))}}Yr=new WeakMap,zr=new WeakMap,Hr=new WeakMap,Xr=new WeakMap,Zr=new WeakMap,Wr=new WeakSet,qr=function(){gt.cfd(1),Ts._onLog&&Ts._onLog("charge 1.")},Jr=function t(){0==He(this,zr,"f")&&He(this,Wr,"m",qr).call(this),Xe(this,Xr,Date.now()),He(this,Hr,"f")&&clearTimeout(He(this,Hr,"f")),Xe(this,Hr,setTimeout((()=>{Xe(this,zr,0),He(this,Wr,"m",t).call(this)}),He(this,Yr,"f")-He(this,zr,"f")))};class bs{static beep(){if(!this.allowBeep)return;if(!this.beepSoundSource)return;let t,e=Date.now();if(!(e-He(this,Kr,"f",ts)<100)){if(Xe(this,Kr,e,0,ts),He(this,Kr,"f",$r).size&&(t=He(this,Kr,"f",$r).values().next().value,this.beepSoundSource==t.src?(He(this,Kr,"f",$r).delete(t),t.play()):t=null),!t)if(He(this,Kr,"f",Qr).size<16){t=new Audio(this.beepSoundSource);let e=null,i=()=>{t.removeEventListener("loadedmetadata",i),t.play(),e=setTimeout((()=>{He(this,Kr,"f",Qr).delete(t)}),2e3*t.duration)};t.addEventListener("loadedmetadata",i),t.addEventListener("ended",(()=>{null!=e&&(clearTimeout(e),e=null),t.pause(),t.currentTime=0,He(this,Kr,"f",Qr).delete(t),He(this,Kr,"f",$r).add(t)}))}else He(this,Kr,"f",es)||(Xe(this,Kr,!0,0,es),console.warn("The requested audio tracks exceed 16 and will not be played."));t&&He(this,Kr,"f",Qr).add(t)}}static vibrate(){if(this.allowVibrate){if(!navigator||!navigator.vibrate)throw new Error("Not supported.");navigator.vibrate(bs.vibrateDuration)}}}Kr=bs,$r={value:new Set},Qr={value:new Set},ts={value:0},es={value:!1},bs.allowBeep=!0,bs.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",bs.allowVibrate=!0,bs.vibrateDuration=300;const Is=new Map([[Wn.GREY,l.IPF_GRAYSCALED],[Wn.RGBA,l.IPF_ABGR_8888]]),xs="function"==typeof BigInt?{BF_NULL:BigInt(0),BF_ALL:BigInt(0x10000000000000000),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_NULL:"0x00",BF_ALL:"0xFFFFFFFFFFFFFFFF",BF_DEFAULT:"0xFE3BFFFF",BF_ONED:"0x003007FF",BF_GS1_DATABAR:"0x0003F800",BF_CODE_39:"0x1",BF_CODE_128:"0x2",BF_CODE_93:"0x4",BF_CODABAR:"0x8",BF_ITF:"0x10",BF_EAN_13:"0x20",BF_EAN_8:"0x40",BF_UPC_A:"0x80",BF_UPC_E:"0x100",BF_INDUSTRIAL_25:"0x200",BF_CODE_39_EXTENDED:"0x400",BF_GS1_DATABAR_OMNIDIRECTIONAL:"0x800",BF_GS1_DATABAR_TRUNCATED:"0x1000",BF_GS1_DATABAR_STACKED:"0x2000",BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL:"0x4000",BF_GS1_DATABAR_EXPANDED:"0x8000",BF_GS1_DATABAR_EXPANDED_STACKED:"0x10000",BF_GS1_DATABAR_LIMITED:"0x20000",BF_PATCHCODE:"0x00040000",BF_CODE_32:"0x01000000",BF_PDF417:"0x02000000",BF_QR_CODE:"0x04000000",BF_DATAMATRIX:"0x08000000",BF_AZTEC:"0x10000000",BF_MAXICODE:"0x20000000",BF_MICRO_QR:"0x40000000",BF_MICRO_PDF417:"0x00080000",BF_GS1_COMPOSITE:"0x80000000",BF_MSI_CODE:"0x100000",BF_CODE_11:"0x200000",BF_TWO_DIGIT_ADD_ON:"0x400000",BF_FIVE_DIGIT_ADD_ON:"0x800000",BF_MATRIX_25:"0x1000000000",BF_POSTALCODE:"0x3F0000000000000",BF_NONSTANDARD_BARCODE:"0x100000000",BF_USPSINTELLIGENTMAIL:"0x10000000000000",BF_POSTNET:"0x20000000000000",BF_PLANET:"0x40000000000000",BF_AUSTRALIANPOST:"0x80000000000000",BF_RM4SCC:"0x100000000000000",BF_KIX:"0x200000000000000",BF_DOTCODE:"0x200000000",BF_PHARMACODE_ONE_TRACK:"0x400000000",BF_PHARMACODE_TWO_TRACK:"0x800000000",BF_PHARMACODE:"0xC00000000"};class Rs extends X{static set _onLog(t){Xe(Rs,ns,t,0,rs),Gr._onLog=t,Ts._onLog=t}static get _onLog(){return He(Rs,ns,"f",rs)}static async detectEnvironment(){return await(async()=>({wasm:Ze,worker:qe,getUserMedia:Je,camera:await Ke(),browser:ze.browser,version:ze.version,OS:ze.OS}))()}static async testCameraAccess(){const t=await Gr.testCameraAccess();return t.ok?{ok:!0,message:"Successfully accessed the camera."}:"InsecureContext"===t.errorName?{ok:!1,message:"Insecure context."}:"OverconstrainedError"===t.errorName||"NotFoundError"===t.errorName?{ok:!1,message:"No camera detected."}:"NotAllowedError"===t.errorName?{ok:!1,message:"No permission to access camera."}:"AbortError"===t.errorName?{ok:!1,message:"Some problem occurred which prevented the device from being used."}:"NotReadableError"===t.errorName?{ok:!1,message:"A hardware error occurred."}:"SecurityError"===t.errorName?{ok:!1,message:"User media support is disabled."}:{ok:!1,message:t.errorMessage}}static async createInstance(t){var e,i;if(t&&!(t instanceof An))throw new TypeError("Invalid view.");if(null===(e=ct.license)||void 0===e?void 0:e.LicenseManager){if(!(null===(i=ct.license)||void 0===i?void 0:i.LicenseManager.bCallInitLicense))throw new Error("License is not set.");await gt.loadWasm(["license"]),await ct.license.dynamsoft()}const n=new Rs(t);return Rs.onWarning&&(location&&"file:"===location.protocol?setTimeout((()=>{Rs.onWarning&&Rs.onWarning({id:1,message:"The page is opened over file:// and Dynamsoft Camera Enhancer may not work properly. Please open the page via https://."})}),0):!1!==window.isSecureContext&&navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia||setTimeout((()=>{Rs.onWarning&&Rs.onWarning({id:2,message:"Dynamsoft Camera Enhancer may not work properly in a non-secure context. Please open the page via https://."})}),0)),n}get video(){return this.cameraManager.getVideoEl()}set videoSrc(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraView&&(this.cameraView._hideDefaultSelection=!0),this.cameraManager.videoSrc=t}get videoSrc(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.videoSrc}set ifSaveLastUsedCamera(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.ifSaveLastUsedCamera=t}get ifSaveLastUsedCamera(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.ifSaveLastUsedCamera}set ifSkipCameraInspection(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.ifSkipCameraInspection=t}get ifSkipCameraInspection(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.ifSkipCameraInspection}set cameraOpenTimeout(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.cameraOpenTimeout=t}get cameraOpenTimeout(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.cameraOpenTimeout}set singleFrameMode(t){if(!["disabled","image","camera"].includes(t))throw new Error("Invalid value.");if(this.isOpen())throw new Error("It is not allowed to change `singleFrameMode` when the camera is open.");Xe(this,os,t)}get singleFrameMode(){return He(this,os,"f")}get _isFetchingStarted(){return He(this,fs,"f")}get disposed(){return He(this,vs,"f")}constructor(t){if(super(),is.add(this),ss.set(this,"closed"),as.set(this,void 0),this.isTorchOn=void 0,os.set(this,void 0),this._onCameraSelChange=async()=>{this.isOpen()&&this.cameraView&&!this.cameraView.disposed&&await this.selectCamera(this.cameraView._selCam.value)},this._onResolutionSelChange=async()=>{if(!this.isOpen())return;if(!this.cameraView||this.cameraView.disposed)return;let t,e;if(this.cameraView._selRsl&&-1!=this.cameraView._selRsl.selectedIndex){let i=this.cameraView._selRsl.options[this.cameraView._selRsl.selectedIndex];t=parseInt(i.getAttribute("data-width")),e=parseInt(i.getAttribute("data-height"))}await this.setResolution({width:t,height:e})},this._onCloseBtnClick=async()=>{this.isOpen()&&this.cameraView&&!this.cameraView.disposed&&this.close()},ls.set(this,((t,e,i,n)=>{const r=Date.now(),s={sx:n.x,sy:n.y,sWidth:n.width,sHeight:n.height,dWidth:n.width,dHeight:n.height},a=Math.max(s.dWidth,s.dHeight);if(this.canvasSizeLimit&&a>this.canvasSizeLimit){const t=this.canvasSizeLimit/a;s.dWidth>s.dHeight?(s.dWidth=this.canvasSizeLimit,s.dHeight=Math.round(s.dHeight*t)):(s.dWidth=Math.round(s.dWidth*t),s.dHeight=this.canvasSizeLimit)}const o=this.cameraManager.imageDataGetter.getImageData(t,s,{pixelFormat:this.getPixelFormat()===l.IPF_GRAYSCALED?Wn.GREY:Wn.RGBA});let h=null;if(o){const t=Date.now();let a;a=o.pixelFormat===Wn.GREY?o.width:4*o.width;let l=!0;0===s.sx&&0===s.sy&&s.sWidth===e&&s.sHeight===i&&(l=!1),h={bytes:o.data,width:o.width,height:o.height,stride:a,format:Is.get(o.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:wt.ITT_FILE_IMAGE,isCropped:l,cropRegion:{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height,isMeasuredInPercentage:!1},originalWidth:e,originalHeight:i,currentWidth:o.width,currentHeight:o.height,timeSpent:t-r,timeStamp:t},toCanvas:He(this,hs,"f"),isDCEFrame:!0}}return h})),this._onSingleFrameAcquired=t=>{let e;e=this.cameraView?this.cameraView.getConvertedRegion():ki.convert(He(this,us,"f"),t.width,t.height),e||(e={x:0,y:0,width:t.width,height:t.height});const i=He(this,ls,"f").call(this,t,t.width,t.height,e);He(this,as,"f").fire("singleFrameAcquired",[i],{async:!1,copy:!1})},hs.set(this,(function(){if(!(this.bytes instanceof Uint8Array||this.bytes instanceof Uint8ClampedArray))throw new TypeError("Invalid bytes.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const t=document.createElement("canvas");let e;if(t.width=this.width,t.height=this.height,this.format===l.IPF_GRAYSCALED){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t{if(!this.video)return;const t=this.cameraManager.getSoftwareScale();if(t<1)throw new RangeError("Invalid scale value.");this.cameraView&&!this.cameraView.disposed?(this.video.style.transform=1===t?"":`scale(${t})`,this.cameraView._updateVideoContainer()):this.video.style.transform=1===t?"":`scale(${t})`},["iPhone","iPad","Android","HarmonyOS"].includes(ze.OS)?this.cameraManager.setResolution(1280,720):this.cameraManager.setResolution(1920,1080),navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?this.singleFrameMode="disabled":this.singleFrameMode="image",t&&(this.setCameraView(t),t.cameraEnhancer=this),this._on("before:camera:change",(()=>{He(this,_s,"f").stopCharging();const t=this.cameraView;t&&!t.disposed&&(t._startLoading(),t.clearAllInnerDrawingItems())})),this._on("camera:changed",(()=>{this.clearBuffer()})),this._on("before:resolution:change",(()=>{const t=this.cameraView;t&&!t.disposed&&(t._startLoading(),t.clearAllInnerDrawingItems())})),this._on("resolution:changed",(()=>{this.clearBuffer(),t.eventHandler.fire("content:updated",null,{async:!1})})),this._on("paused",(()=>{He(this,_s,"f").stopCharging();const t=this.cameraView;t&&t.disposed})),this._on("resumed",(()=>{const t=this.cameraView;t&&t.disposed})),this._on("tapfocus",(()=>{He(this,ms,"f").tapToFocus&&He(this,_s,"f").startCharging()})),this._intermediateResultReceiver={},this._intermediateResultReceiver.onTaskResultsReceived=async(t,e)=>{var i,n,r,s;if(He(this,is,"m",ys).call(this)||!this.isOpen()||this.isPaused())return;const a=t.intermediateResultUnits;Rs._onLog&&(Rs._onLog("intermediateResultUnits:"),Rs._onLog(a));let o=!1,l=!1;for(let t of a){if(t.unitType===Tt.IRUT_DECODED_BARCODES&&t.decodedBarcodes.length){o=!0;break}t.unitType===Tt.IRUT_LOCALIZED_BARCODES&&t.localizedBarcodes.length&&(l=!0)}if(Rs._onLog&&(Rs._onLog("hasLocalizedBarcodes:"),Rs._onLog(l)),He(this,ms,"f").autoZoom||He(this,ms,"f").enhancedFocus)if(o)He(this,ps,"f").autoZoomInFrameArray.length=0,He(this,ps,"f").autoZoomOutFrameCount=0,He(this,ps,"f").frameArrayInIdealZoom.length=0,He(this,ps,"f").autoFocusFrameArray.length=0;else{const e=async t=>{await this.setZoom(t),He(this,ms,"f").autoZoom&&He(this,_s,"f").startCharging()},o=async t=>{await this.setFocus(t),He(this,ms,"f").enhancedFocus&&He(this,_s,"f").startCharging()};if(l){const l=a[0].originalImageTag,h=(null===(i=l.cropRegion)||void 0===i?void 0:i.left)||0,c=(null===(n=l.cropRegion)||void 0===n?void 0:n.top)||0,u=(null===(r=l.cropRegion)||void 0===r?void 0:r.right)?l.cropRegion.right-h:l.originalWidth,d=(null===(s=l.cropRegion)||void 0===s?void 0:s.bottom)?l.cropRegion.bottom-c:l.originalHeight,f=l.currentWidth,g=l.currentHeight;let m;{let t,e,i,n,r;{const t=this.video.videoWidth*(1-He(this,ps,"f").autoZoomDetectionArea)/2,e=this.video.videoWidth*(1+He(this,ps,"f").autoZoomDetectionArea)/2,i=e,n=t,s=this.video.videoHeight*(1-He(this,ps,"f").autoZoomDetectionArea)/2,a=s,o=this.video.videoHeight*(1+He(this,ps,"f").autoZoomDetectionArea)/2;r=[{x:t,y:s},{x:e,y:a},{x:i,y:o},{x:n,y:o}]}Rs._onLog&&(Rs._onLog("detectionArea:"),Rs._onLog(r));const s=[];{const t=(t,e)=>{const i=(t,e)=>{if(!t&&!e)throw new Error("Invalid arguments.");return function(t,e,i){let n=!1;const r=t.length;if(r<=2)return!1;for(let s=0;s0!=Ui(o.y-i)>0&&Ui(e-(i-a.y)*(a.x-o.x)/(a.y-o.y)-a.x)<0&&(n=!n)}return n}(e,t.x,t.y)},n=(t,e)=>!!(Gi([t[0],t[1]],[t[2],t[3]],[e[0].x,e[0].y],[e[1].x,e[1].y])||Gi([t[0],t[1]],[t[2],t[3]],[e[1].x,e[1].y],[e[2].x,e[2].y])||Gi([t[0],t[1]],[t[2],t[3]],[e[2].x,e[2].y],[e[3].x,e[3].y])||Gi([t[0],t[1]],[t[2],t[3]],[e[3].x,e[3].y],[e[0].x,e[0].y]));return!!(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))||!!(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))||!!(n([e[0].x,e[0].y,e[1].x,e[1].y],t)||n([e[1].x,e[1].y,e[2].x,e[2].y],t)||n([e[2].x,e[2].y,e[3].x,e[3].y],t)||n([e[3].x,e[3].y,e[0].x,e[0].y],t))};for(let e of a)if(e.unitType===Tt.IRUT_LOCALIZED_BARCODES)for(let i of e.localizedBarcodes){if(!i)continue;const e=i.location.points;e.forEach((t=>{An._transformCoordinates(t,h,c,u,d,f,g)})),t(r,e)&&s.push(i)}if(Rs._debug&&this.cameraView){const t=this.__layer||(this.__layer=this.cameraView._createDrawingLayer(99));t.clearDrawingItems();const e=this.__styleId2||(this.__styleId2=bn.createDrawingStyle({strokeStyle:"red"}));for(let i of a)if(i.unitType===Tt.IRUT_LOCALIZED_BARCODES)for(let n of i.localizedBarcodes){if(!n)continue;const i=n.location.points,r=new Ii({points:i},e);t.addDrawingItems([r])}}}if(Rs._onLog&&(Rs._onLog("intersectedResults:"),Rs._onLog(s)),!s.length)return;let o;if(s.length){let t=s.filter((t=>t.possibleFormats==xs.BF_QR_CODE||t.possibleFormats==xs.BF_DATAMATRIX));if(t.length||(t=s.filter((t=>t.possibleFormats==xs.BF_ONED)),t.length||(t=s)),t.length){const e=t=>{const e=t.location.points,i=(e[0].x+e[1].x+e[2].x+e[3].x)/4,n=(e[0].y+e[1].y+e[2].y+e[3].y)/4;return(i-f/2)*(i-f/2)+(n-g/2)*(n-g/2)};o=t[0];let i=e(o);if(1!=t.length)for(let n=1;n1.1*o.confidence||t[n].confidence>.9*o.confidence&&ri&&s>i&&a>i&&l>i&&m.result.moduleSize{})),He(this,ps,"f").autoZoomInFrameArray.filter((t=>!0===t)).length>=He(this,ps,"f").autoZoomInFrameLimit[1]){He(this,ps,"f").autoZoomInFrameArray.length=0;const i=[(.5-n)/(.5-r),(.5-n)/(.5-s),(.5-n)/(.5-a),(.5-n)/(.5-l)].filter((t=>t>0)),o=Math.min(...i,He(this,ps,"f").autoZoomInIdealModuleSize/m.result.moduleSize),h=this.getZoomSettings().factor;let c=Math.max(Math.pow(h*o,1/He(this,ps,"f").autoZoomInMaxTimes),He(this,ps,"f").autoZoomInMinStep);c=Math.min(c,o);let u=h*c;u=Math.max(He(this,ps,"f").minValue,u),u=Math.min(He(this,ps,"f").maxValue,u);try{await e({factor:u})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}else if(He(this,ps,"f").autoZoomInFrameArray.length=0,He(this,ps,"f").frameArrayInIdealZoom.push(!0),He(this,ps,"f").frameArrayInIdealZoom.splice(0,He(this,ps,"f").frameArrayInIdealZoom.length-He(this,ps,"f").frameLimitInIdealZoom[0]),He(this,ps,"f").frameArrayInIdealZoom.filter((t=>!0===t)).length>=He(this,ps,"f").frameLimitInIdealZoom[1]&&(He(this,ps,"f").frameArrayInIdealZoom.length=0,He(this,ms,"f").enhancedFocus)){const e=m.points;try{await o({mode:"manual",area:{centerPoint:{x:(e[0].x+e[2].x)/2+"px",y:(e[0].y+e[2].y)/2+"px"},width:e[2].x-e[0].x+"px",height:e[2].y-e[0].y+"px"}})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}if(!He(this,ms,"f").autoZoom&&He(this,ms,"f").enhancedFocus&&(He(this,ps,"f").autoFocusFrameArray.push(!0),He(this,ps,"f").autoFocusFrameArray.splice(0,He(this,ps,"f").autoFocusFrameArray.length-He(this,ps,"f").autoFocusFrameLimit[0]),He(this,ps,"f").autoFocusFrameArray.filter((t=>!0===t)).length>=He(this,ps,"f").autoFocusFrameLimit[1])){He(this,ps,"f").autoFocusFrameArray.length=0;try{const t=m.points;await o({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(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}else{if(He(this,ms,"f").autoZoom){if(He(this,ps,"f").autoZoomInFrameArray.push(!1),He(this,ps,"f").autoZoomInFrameArray.splice(0,He(this,ps,"f").autoZoomInFrameArray.length-He(this,ps,"f").autoZoomInFrameLimit[0]),He(this,ps,"f").autoZoomOutFrameCount++,He(this,ps,"f").frameArrayInIdealZoom.push(!1),He(this,ps,"f").frameArrayInIdealZoom.splice(0,He(this,ps,"f").frameArrayInIdealZoom.length-He(this,ps,"f").frameLimitInIdealZoom[0]),He(this,ps,"f").autoZoomOutFrameCount>=He(this,ps,"f").autoZoomOutFrameLimit){He(this,ps,"f").autoZoomOutFrameCount=0;const i=this.getZoomSettings().factor;let n=i-Math.max((i-1)*He(this,ps,"f").autoZoomOutStepRate,He(this,ps,"f").autoZoomOutMinStep);n=Math.max(He(this,ps,"f").minValue,n),n=Math.min(He(this,ps,"f").maxValue,n);try{await e({factor:n})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}He(this,ms,"f").enhancedFocus&&o({mode:"continuous"}).catch((()=>{}))}!He(this,ms,"f").autoZoom&&He(this,ms,"f").enhancedFocus&&(He(this,ps,"f").autoFocusFrameArray.length=0,o({mode:"continuous"}).catch((()=>{})))}}},Xe(this,_s,new Ts(1e4))}setCameraView(t){if(!(t instanceof An))throw new TypeError("Invalid view.");if(t.disposed)throw new Error("The camera view has been disposed.");if(this.isOpen())throw new Error("It is not allowed to change camera view when the camera is open.");this.releaseCameraView(),t._singleFrameMode=this.singleFrameMode,t._onSingleFrameAcquired=this._onSingleFrameAcquired,this.videoSrc&&(this.cameraView._hideDefaultSelection=!0),He(this,is,"m",ys).call(this)||this.cameraManager.setVideoEl(t.getVideoElement()),this.cameraView=t,this.addListenerToView()}getCameraView(){return this.cameraView}releaseCameraView(){this.cameraView&&(this.removeListenerFromView(),this.cameraView.disposed||(this.cameraView._singleFrameMode="disabled",this.cameraView._onSingleFrameAcquired=null,this.cameraView._hideDefaultSelection=!1),this.cameraManager.releaseVideoEl(),this.cameraView=null)}addListenerToView(){if(!this.cameraView)return;if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");const t=this.cameraView;He(this,is,"m",ys).call(this)||this.videoSrc||(t._innerComponent&&(this.cameraManager.tapFocusEventBoundEl=t._innerComponent),t._selCam&&t._selCam.addEventListener("change",this._onCameraSelChange),t._selRsl&&t._selRsl.addEventListener("change",this._onResolutionSelChange)),t._btnClose&&t._btnClose.addEventListener("click",this._onCloseBtnClick)}removeListenerFromView(){if(!this.cameraView||this.cameraView.disposed)return;const t=this.cameraView;this.cameraManager.tapFocusEventBoundEl=null,t._selCam&&t._selCam.removeEventListener("change",this._onCameraSelChange),t._selRsl&&t._selRsl.removeEventListener("change",this._onResolutionSelChange),t._btnClose&&t._btnClose.removeEventListener("click",this._onCloseBtnClick)}getCameraState(){return He(this,is,"m",ys).call(this)?He(this,ss,"f"):new Map([["closed","closed"],["opening","opening"],["opened","open"]]).get(this.cameraManager.state)}isOpen(){return"open"===this.getCameraState()}getVideoEl(){return this.video}async open(){const t=this.cameraView;if(null==t?void 0:t.disposed)throw new Error("'cameraView' has been disposed.");t&&(t._singleFrameMode=this.singleFrameMode,He(this,is,"m",ys).call(this)?t._clickIptSingleFrameMode():(this.cameraManager.setVideoEl(t.getVideoElement()),t._startLoading()));let e={width:0,height:0,deviceId:""};if(He(this,is,"m",ys).call(this));else{try{await this.cameraManager.open()}catch(e){throw t&&t._stopLoading(),"NotFoundError"===e.name?new Error(`No camera devices were detected. Please ensure a camera is connected and recognized by your system. ${null==e?void 0:e.name}: ${null==e?void 0:e.message}`):"NotAllowedError"===e.name?new Error(`Camera access is blocked. Please check your browser settings or grant permission to use the camera. ${null==e?void 0:e.name}: ${null==e?void 0:e.message}`):e}let i,n=t.getUIElement();if(n=n.shadowRoot||n,i=n.querySelector(".dce-macro-use-mobile-native-like-ui")){let t=n.elTorchAuto=n.querySelector(".dce-mn-torch-auto"),e=n.elTorchOn=n.querySelector(".dce-mn-torch-on"),r=n.elTorchOff=n.querySelector(".dce-mn-torch-off");t&&(e.style.display=null==this.isTorchOn?"":"none"),e&&(e.style.display=1==this.isTorchOn?"":"none"),r&&(r.style.display=0==this.isTorchOn?"":"none");let s=n.elBeepOn=n.querySelector(".dce-mn-beep-on"),a=n.elBeepOff=n.querySelector(".dce-mn-beep-off");s&&(s.style.display=bs.allowBeep?"":"none"),a&&(a.style.display=bs.allowBeep?"none":"");let o=n.elVibrateOn=n.querySelector(".dce-mn-vibrate-on"),l=n.elVibrateOff=n.querySelector(".dce-mn-vibrate-off");o&&(o.style.display=bs.allowVibrate?"":"none"),l&&(l.style.display=bs.allowVibrate?"none":""),n.elResolutionBox=n.querySelector(".dce-mn-resolution-box");let h,c=n.elZoom=n.querySelector(".dce-mn-zoom");c&&(c.style.display="none",h=n.elZoomSpan=c.querySelector("span"));let u=n.elToast=n.querySelector(".dce-mn-toast"),d=n.elCameraClose=n.querySelector(".dce-mn-camera-close"),f=n.elTakePhoto=n.querySelector(".dce-mn-take-photo"),g=n.elCameraSwitch=n.querySelector(".dce-mn-camera-switch"),m=n.elCameraAndResolutionSettings=n.querySelector(".dce-mn-camera-and-resolution-settings");m&&(m.style.display="none");const p=n.dceMnFs={},_=()=>{this.turnOnTorch()};null==t||t.addEventListener("pointerdown",_);const v=()=>{this.turnOffTorch()};null==e||e.addEventListener("pointerdown",v);const y=()=>{this.turnAutoTorch()};null==r||r.addEventListener("pointerdown",y);const w=()=>{bs.allowBeep=!bs.allowBeep,s&&(s.style.display=bs.allowBeep?"":"none"),a&&(a.style.display=bs.allowBeep?"none":"")};for(let t of[a,s])null==t||t.addEventListener("pointerdown",w);const E=()=>{bs.allowVibrate=!bs.allowVibrate,o&&(o.style.display=bs.allowVibrate?"":"none"),l&&(l.style.display=bs.allowVibrate?"none":"")};for(let t of[l,o])null==t||t.addEventListener("pointerdown",E);const C=async t=>{let e,i=t.target;if(e=i.closest(".dce-mn-camera-option"))this.selectCamera(e.getAttribute("data-davice-id"));else if(e=i.closest(".dce-mn-resolution-option")){let t,i=parseInt(e.getAttribute("data-width")),n=parseInt(e.getAttribute("data-height")),r=await this.setResolution({width:i,height:n});{let e=Math.max(r.width,r.height),i=Math.min(r.width,r.height);t=i<=1080?i+"P":e<3e3?"2K":Math.round(e/1e3)+"K"}t!=e.textContent&&b(`Fallback to ${t}`)}else i.closest(".dce-mn-camera-and-resolution-settings")||(i.closest(".dce-mn-resolution-box")?m&&(m.style.display=m.style.display?"":"none"):m&&""===m.style.display&&(m.style.display="none"))};n.addEventListener("click",C);let S=null;p.funcInfoZoomChange=(t,e=3e3)=>{c&&h&&(h.textContent=t.toFixed(1),c.style.display="",null!=S&&(clearTimeout(S),S=null),S=setTimeout((()=>{c.style.display="none",S=null}),e))};let T=null,b=p.funcShowToast=(t,e=3e3)=>{u&&(u.textContent=t,u.style.display="",null!=T&&(clearTimeout(T),T=null),T=setTimeout((()=>{u.style.display="none",T=null}),e))};const I=()=>{this.close()};null==d||d.addEventListener("click",I);const x=()=>{};null==f||f.addEventListener("pointerdown",x);const R=()=>{var t,e;let i,n=this.getVideoSettings(),r=n.video.facingMode,s=null===(e=null===(t=this.cameraManager.getCamera())||void 0===t?void 0:t.label)||void 0===e?void 0:e.toLowerCase(),a=null==s?void 0:s.indexOf("front");-1===a&&(a=null==s?void 0:s.indexOf("前"));let o=null==s?void 0:s.indexOf("back");-1===o&&(o=null==s?void 0:s.indexOf("后")),"number"==typeof a&&-1!==a?i=!0:"number"==typeof o&&-1!==o&&(i=!1),void 0===i&&(i="user"===((null==r?void 0:r.ideal)||(null==r?void 0:r.exact)||r)),n.video.facingMode={ideal:i?"environment":"user"},delete n.video.deviceId,this.updateVideoSettings(n)};null==g||g.addEventListener("pointerdown",R);let O=-1/0,D=1;const A=t=>{let e=Date.now();e-O>1e3&&(D=this.getZoomSettings().factor),D-=t.deltaY/200,D>20&&(D=20),D<1&&(D=1),this.setZoom({factor:D}),O=e};i.addEventListener("wheel",A);const L=new Map;let M=!1;const F=async t=>{var e;for(t.touches.length>=2&&"touchmove"==t.type&&t.preventDefault();t.changedTouches.length>1&&2==t.touches.length;){let i=t.touches[0],n=t.touches[1],r=L.get(i.identifier),s=L.get(n.identifier);if(!r||!s)break;let a=Math.pow(Math.pow(r.x-s.x,2)+Math.pow(r.y-s.y,2),.5),o=Math.pow(Math.pow(i.clientX-n.clientX,2)+Math.pow(i.clientY-n.clientY,2),.5),l=Date.now();if(M||l-O<100)return;l-O>1e3&&(D=this.getZoomSettings().factor),D*=o/a,D>20&&(D=20),D<1&&(D=1);let h=!1;"safari"==(null===(e=null==ze?void 0:ze.browser)||void 0===e?void 0:e.toLocaleLowerCase())&&(o/a>1&&D<2?(D=2,h=!0):o/a<1&&D<2&&(D=1,h=!0)),M=!0,h&&b("zooming..."),await this.setZoom({factor:D}),h&&(u.textContent=""),M=!1,O=Date.now();break}L.clear();for(let e of t.touches)L.set(e.identifier,{x:e.clientX,y:e.clientY})};n.addEventListener("touchstart",F),n.addEventListener("touchmove",F),n.addEventListener("touchend",F),n.addEventListener("touchcancel",F),p.unbind=()=>{null==t||t.removeEventListener("pointerdown",_),null==e||e.removeEventListener("pointerdown",v),null==r||r.removeEventListener("pointerdown",y);for(let t of[a,s])null==t||t.removeEventListener("pointerdown",w);for(let t of[l,o])null==t||t.removeEventListener("pointerdown",E);n.removeEventListener("click",C),null==d||d.removeEventListener("click",I),null==f||f.removeEventListener("pointerdown",x),null==g||g.removeEventListener("pointerdown",R),i.removeEventListener("wheel",A),n.removeEventListener("touchstart",F),n.removeEventListener("touchmove",F),n.removeEventListener("touchend",F),n.removeEventListener("touchcancel",F),delete n.dceMnFs,i.style.display="none"},i.style.display="",t&&null==this.isTorchOn&&setTimeout((()=>{this.turnAutoTorch(1e3)}),0)}this.isTorchOn&&this.turnOnTorch().catch((()=>{}));const r=this.getResolution();e.width=r.width,e.height=r.height,e.deviceId=this.getSelectedCamera().deviceId}return Xe(this,ss,"open"),t&&(t._innerComponent.style.display="",He(this,is,"m",ys).call(this)||(t._stopLoading(),t._renderCamerasInfo(this.getSelectedCamera(),this.cameraManager._arrCameras),t._renderResolutionInfo({width:e.width,height:e.height}),t.eventHandler.fire("content:updated",null,{async:!1}),t.eventHandler.fire("videoEl:resized",null,{async:!1}))),He(this,as,"f").fire("opened",null,{target:this,async:!1}),e}close(){var t;const e=this.cameraView;if(null==e?void 0:e.disposed)throw new Error("'cameraView' has been disposed.");if(this.stopFetching(),this.clearBuffer(),He(this,is,"m",ys).call(this));else{this.cameraManager.close();let i=e.getUIElement();i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")&&(null===(t=i.dceMnFs)||void 0===t||t.unbind())}Xe(this,ss,"closed"),He(this,_s,"f").stopCharging(),e&&(e._innerComponent.style.display="none",He(this,is,"m",ys).call(this)&&e._innerComponent.removeElement("content"),e._stopLoading()),He(this,as,"f").fire("closed",null,{target:this,async:!1})}pause(){if(He(this,is,"m",ys).call(this))throw new Error("'pause()' is invalid in 'singleFrameMode'.");this.cameraManager.pause()}isPaused(){var t;return!He(this,is,"m",ys).call(this)&&!0===(null===(t=this.video)||void 0===t?void 0:t.paused)}async resume(){if(He(this,is,"m",ys).call(this))throw new Error("'resume()' is invalid in 'singleFrameMode'.");await this.cameraManager.resume()}async selectCamera(t){if(!t)throw new Error("Invalid value.");let e;e="string"==typeof t?t:t.deviceId,await this.cameraManager.setCamera(e),this.isTorchOn=!1;const i=this.getResolution(),n=this.cameraView;return n&&!n.disposed&&(n._stopLoading(),n._renderCamerasInfo(this.getSelectedCamera(),this.cameraManager._arrCameras),n._renderResolutionInfo({width:i.width,height:i.height})),{width:i.width,height:i.height,deviceId:this.getSelectedCamera().deviceId}}getSelectedCamera(){return this.cameraManager.getCamera()}async getAllCameras(){return this.cameraManager.getCameras()}async setResolution(t){await this.cameraManager.setResolution(t.width,t.height),this.isTorchOn&&this.turnOnTorch().catch((()=>{}));const e=this.getResolution(),i=this.cameraView;return i&&!i.disposed&&(i._stopLoading(),i._renderResolutionInfo({width:e.width,height:e.height})),{width:e.width,height:e.height,deviceId:this.getSelectedCamera().deviceId}}getResolution(){return this.cameraManager.getResolution()}getAvailableResolutions(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getResolutions()}_on(t,e){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(t.toLowerCase())?He(this,as,"f").on(t,e):this.cameraManager.on(t,e)}_off(t,e){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(t.toLowerCase())?He(this,as,"f").off(t,e):this.cameraManager.off(t,e)}on(t,e){const i=t.toLowerCase(),n=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(i);if(!n)throw new Error("Invalid event.");this._on(n,e)}off(t,e){const i=t.toLowerCase(),n=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(i);if(!n)throw new Error("Invalid event.");this._off(n,e)}getVideoSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getMediaStreamConstraints()}async updateVideoSettings(t){var e;await(null===(e=this.cameraManager)||void 0===e?void 0:e.setMediaStreamConstraints(t,!0))}getCapabilities(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getCameraCapabilities()}getCameraSettings(){return this.cameraManager.getCameraSettings()}async turnOnTorch(){var t,e;if(He(this,is,"m",ys).call(this))throw new Error("'turnOnTorch()' is invalid in 'singleFrameMode'.");try{await(null===(t=this.cameraManager)||void 0===t?void 0:t.turnOnTorch())}catch(t){let i=this.cameraView.getUIElement();throw i=i.shadowRoot||i,null===(e=null==i?void 0:i.dceMnFs)||void 0===e||e.funcShowToast("Torch Not Supported"),t}this.isTorchOn=!0;let i=this.cameraView.getUIElement();i=i.shadowRoot||i,i.elTorchAuto&&(i.elTorchAuto.style.display="none"),i.elTorchOn&&(i.elTorchOn.style.display=""),i.elTorchOff&&(i.elTorchOff.style.display="none")}async turnOffTorch(){var t;if(He(this,is,"m",ys).call(this))throw new Error("'turnOffTorch()' is invalid in 'singleFrameMode'.");await(null===(t=this.cameraManager)||void 0===t?void 0:t.turnOffTorch()),this.isTorchOn=!1;let e=this.cameraView.getUIElement();e=e.shadowRoot||e,e.elTorchAuto&&(e.elTorchAuto.style.display="none"),e.elTorchOn&&(e.elTorchOn.style.display="none"),e.elTorchOff&&(e.elTorchOff.style.display="")}async turnAutoTorch(t=250){if(null!=this._taskid4AutoTorch){if(!(t{var t,r,s;if(this.disposed||e||null!=this.isTorchOn||!this.isOpen())return clearInterval(this._taskid4AutoTorch),void(this._taskid4AutoTorch=null);if(this.isPaused())return;if(++n>10&&this._delay4AutoTorch<1e3)return clearInterval(this._taskid4AutoTorch),this._taskid4AutoTorch=null,void this.turnAutoTorch(1e3);let a;try{a=this.fetchImage()}catch(t){}if(!a||!a.width||!a.height)return;let o=0;if(l.IPF_GRAYSCALED===a.format){for(let t=0;t=this.maxDarkCount4AutoTroch){null===(t=Rs._onLog)||void 0===t||t.call(Rs,`darkCount ${i}`);try{await this.turnOnTorch(),this.isTorchOn=!0;let t=this.cameraView.getUIElement();t=t.shadowRoot||t,null===(r=null==t?void 0:t.dceMnFs)||void 0===r||r.funcShowToast("Torch Auto On")}catch(t){console.warn(t),e=!0;let i=this.cameraView.getUIElement();i=i.shadowRoot||i,null===(s=null==i?void 0:i.dceMnFs)||void 0===s||s.funcShowToast("Torch Not Supported")}}}else i=0};this._taskid4AutoTorch=setInterval(r,t),this.isTorchOn=void 0,r();let s=this.cameraView.getUIElement();s=s.shadowRoot||s,s.elTorchAuto&&(s.elTorchAuto.style.display=""),s.elTorchOn&&(s.elTorchOn.style.display="none"),s.elTorchOff&&(s.elTorchOff.style.display="none")}async setColorTemperature(t){if(He(this,is,"m",ys).call(this))throw new Error("'setColorTemperature()' is invalid in 'singleFrameMode'.");await this.cameraManager.setColorTemperature(t,!0)}getColorTemperature(){return this.cameraManager.getColorTemperature()}async setExposureCompensation(t){var e;if(He(this,is,"m",ys).call(this))throw new Error("'setExposureCompensation()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setExposureCompensation(t,!0))}getExposureCompensation(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getExposureCompensation()}async _setZoom(t){var e,i,n;if(He(this,is,"m",ys).call(this))throw new Error("'setZoom()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setZoom(t));{let e=null===(i=this.cameraView)||void 0===i?void 0:i.getUIElement();e=(null==e?void 0:e.shadowRoot)||e,null===(n=null==e?void 0:e.dceMnFs)||void 0===n||n.funcInfoZoomChange(t.factor)}}async setZoom(t){await this._setZoom(t)}getZoomSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getZoom()}async resetZoom(){var t;if(He(this,is,"m",ys).call(this))throw new Error("'resetZoom()' is invalid in 'singleFrameMode'.");await(null===(t=this.cameraManager)||void 0===t?void 0:t.resetZoom())}async setFrameRate(t){var e;if(He(this,is,"m",ys).call(this))throw new Error("'setFrameRate()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setFrameRate(t,!0))}getFrameRate(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getFrameRate()}async setFocus(t){var e;if(He(this,is,"m",ys).call(this))throw new Error("'setFocus()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setFocus(t,!0))}getFocusSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getFocus()}setAutoZoomRange(t){He(this,ps,"f").minValue=t.min,He(this,ps,"f").maxValue=t.max}getAutoZoomRange(){return{min:He(this,ps,"f").minValue,max:He(this,ps,"f").maxValue}}async enableEnhancedFeatures(t){var e,i;if(!(null===(i=null===(e=ct.license)||void 0===e?void 0:e.LicenseManager)||void 0===i?void 0:i.bPassValidation))throw new Error("License is not verified, or license is invalid.");if(0!==gt.bSupportDce4Module)throw new Error("Please set a license containing the DCE module.");t&ri.EF_ENHANCED_FOCUS&&(He(this,ms,"f").enhancedFocus=!0),t&ri.EF_AUTO_ZOOM&&(He(this,ms,"f").autoZoom=!0),t&ri.EF_TAP_TO_FOCUS&&(He(this,ms,"f").tapToFocus=!0,this.cameraManager.enableTapToFocus())}disableEnhancedFeatures(t){t&ri.EF_ENHANCED_FOCUS&&(He(this,ms,"f").enhancedFocus=!1,this.setFocus({mode:"continuous"}).catch((()=>{}))),t&ri.EF_AUTO_ZOOM&&(He(this,ms,"f").autoZoom=!1,this.resetZoom().catch((()=>{}))),t&ri.EF_TAP_TO_FOCUS&&(He(this,ms,"f").tapToFocus=!1,this.cameraManager.disableTapToFocus()),He(this,is,"m",Es).call(this)&&He(this,is,"m",ws).call(this)||He(this,_s,"f").stopCharging()}_setScanRegion(t){if(null!=t&&!w(t)&&!I(t))throw TypeError("Invalid 'region'.");Xe(this,us,t?JSON.parse(JSON.stringify(t)):null),this.cameraView&&!this.cameraView.disposed&&this.cameraView.setScanRegion(t)}setScanRegion(t){this._setScanRegion(t),this.cameraView&&!this.cameraView.disposed&&(null===t?this.cameraView.setScanRegionMaskVisible(!1):this.cameraView.setScanRegionMaskVisible(!0))}getScanRegion(){return JSON.parse(JSON.stringify(He(this,us,"f")))}setErrorListener(t){if(!t)throw new TypeError("Invalid 'listener'");Xe(this,cs,t)}hasNextImageToFetch(){return!("open"!==this.getCameraState()||!this.cameraManager.isVideoLoaded()||He(this,is,"m",ys).call(this))}startFetching(){if(He(this,is,"m",ys).call(this))throw Error("'startFetching()' is unavailable in 'singleFrameMode'.");He(this,fs,"f")||(Xe(this,fs,!0),He(this,is,"m",Cs).call(this))}stopFetching(){He(this,fs,"f")&&(Rs._onLog&&Rs._onLog("DCE: stop fetching loop: "+Date.now()),He(this,gs,"f")&&clearTimeout(He(this,gs,"f")),Xe(this,fs,!1))}fetchImage(){if(He(this,is,"m",ys).call(this))throw new Error("'fetchImage()' is unavailable in 'singleFrameMode'.");if(!this.video)throw new Error("The video element does not exist.");if(4!==this.video.readyState)throw new Error("The video is not loaded.");const t=this.getResolution();if(!(null==t?void 0:t.width)||!(null==t?void 0:t.height))throw new Error("The video is not loaded.");let e;if(e=ki.convert(He(this,us,"f"),t.width,t.height),e||(e={x:0,y:0,width:t.width,height:t.height}),e.x>t.width||e.y>t.height)throw new Error("Invalid scan region.");e.x+e.width>t.width&&(e.width=t.width-e.x),e.y+e.height>t.height&&(e.height=t.height-e.y);const i={sx:e.x,sy:e.y,sWidth:e.width,sHeight:e.height,dWidth:e.width,dHeight:e.height},n=Math.max(i.dWidth,i.dHeight);if(this.canvasSizeLimit&&n>this.canvasSizeLimit){const t=this.canvasSizeLimit/n;i.dWidth>i.dHeight?(i.dWidth=this.canvasSizeLimit,i.dHeight=Math.round(i.dHeight*t)):(i.dWidth=Math.round(i.dWidth*t),i.dHeight=this.canvasSizeLimit)}const r=this.cameraManager.getFrameData({position:i,pixelFormat:this.getPixelFormat()===l.IPF_GRAYSCALED?Wn.GREY:Wn.RGBA});if(!r)return null;let s;s=r.pixelFormat===Wn.GREY?r.width:4*r.width;let a=!0;return 0===i.sx&&0===i.sy&&i.sWidth===t.width&&i.sHeight===t.height&&(a=!1),{bytes:r.data,width:r.width,height:r.height,stride:s,format:Is.get(r.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:wt.ITT_VIDEO_FRAME,isCropped:a,cropRegion:{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height,isMeasuredInPercentage:!1},originalWidth:t.width,originalHeight:t.height,currentWidth:r.width,currentHeight:r.height,timeSpent:r.timeSpent,timeStamp:r.timeStamp},toCanvas:He(this,hs,"f"),isDCEFrame:!0}}setImageFetchInterval(t){this.fetchInterval=t,He(this,fs,"f")&&(He(this,gs,"f")&&clearTimeout(He(this,gs,"f")),Xe(this,gs,setTimeout((()=>{this.disposed||He(this,is,"m",Cs).call(this)}),t)))}getImageFetchInterval(){return this.fetchInterval}setPixelFormat(t){Xe(this,ds,t)}getPixelFormat(){return He(this,ds,"f")}takePhoto(t){if(!this.isOpen())throw new Error("Not open.");if(He(this,is,"m",ys).call(this))throw new Error("'takePhoto()' is unavailable in 'singleFrameMode'.");const e=document.createElement("input");e.setAttribute("type","file"),e.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp"),e.setAttribute("capture",""),e.style.position="absolute",e.style.top="-9999px",e.style.backgroundColor="transparent",e.style.color="transparent",e.addEventListener("click",(()=>{const t=this.isOpen();this.close(),window.addEventListener("focus",(()=>{t&&this.open(),e.remove()}),{once:!0})})),e.addEventListener("change",(async()=>{const i=e.files[0],n=await(async t=>{let e=null,i=null;if("undefined"!=typeof createImageBitmap)try{if(e=await createImageBitmap(t),e)return e}catch(t){}var n;return e||(i=await(n=t,new Promise(((t,e)=>{let i=URL.createObjectURL(n),r=new Image;r.src=i,r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=t=>{e(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}})))),i})(i),r=n instanceof HTMLImageElement?n.naturalWidth:n.width,s=n instanceof HTMLImageElement?n.naturalHeight:n.height;let a=ki.convert(He(this,us,"f"),r,s);a||(a={x:0,y:0,width:r,height:s});const o=He(this,ls,"f").call(this,n,r,s,a);t&&t(o)})),document.body.appendChild(e),e.click()}convertToPageCoordinates(t){const e=He(this,is,"m",Ss).call(this,t);return{x:e.pageX,y:e.pageY}}convertToClientCoordinates(t){const e=He(this,is,"m",Ss).call(this,t);return{x:e.clientX,y:e.clientY}}convertToScanRegionCoordinates(t){if(!He(this,us,"f"))return JSON.parse(JSON.stringify(t));let e,i,n=He(this,us,"f").left||He(this,us,"f").x||0,r=He(this,us,"f").top||He(this,us,"f").y||0;if(!He(this,us,"f").isMeasuredInPercentage)return{x:t.x-n,y:t.y-r};if(!this.cameraView)throw new Error("Camera view is not set.");if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");if(!this.isOpen())throw new Error("Not open.");if(!He(this,is,"m",ys).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(He(this,is,"m",ys).call(this)&&!this.cameraView._cvsSingleFrameMode)throw new Error("No image is selected.");if(He(this,is,"m",ys).call(this)){const t=this.cameraView._innerComponent.getElement("content");e=t.width,i=t.height}else{const t=this.getVideoEl();e=t.videoWidth,i=t.videoHeight}return{x:t.x-Math.round(n*e/100),y:t.y-Math.round(r*i/100)}}dispose(){this.close(),this.cameraManager.dispose(),this.releaseCameraView(),Xe(this,vs,!0)}}var Os,Ds,As,Ls,Ms,Fs,Ps,ks;ns=Rs,ss=new WeakMap,as=new WeakMap,os=new WeakMap,ls=new WeakMap,hs=new WeakMap,cs=new WeakMap,us=new WeakMap,ds=new WeakMap,fs=new WeakMap,gs=new WeakMap,ms=new WeakMap,ps=new WeakMap,_s=new WeakMap,vs=new WeakMap,is=new WeakSet,ys=function(){return"disabled"!==this.singleFrameMode},ws=function(){return!this.videoSrc&&"opened"===this.cameraManager.state},Es=function(){for(let t in He(this,ms,"f"))if(1==He(this,ms,"f")[t])return!0;return!1},Cs=function t(){if(this.disposed)return;if("open"!==this.getCameraState()||!He(this,fs,"f"))return He(this,gs,"f")&&clearTimeout(He(this,gs,"f")),void Xe(this,gs,setTimeout((()=>{this.disposed||He(this,is,"m",t).call(this)}),this.fetchInterval));const e=()=>{var t;let e;Rs._onLog&&Rs._onLog("DCE: start fetching a frame into buffer: "+Date.now());try{e=this.fetchImage()}catch(e){const i=e.message||e;if("The video is not loaded."===i)return;if(null===(t=He(this,cs,"f"))||void 0===t?void 0:t.onErrorReceived)return void setTimeout((()=>{var t;null===(t=He(this,cs,"f"))||void 0===t||t.onErrorReceived(_t.EC_IMAGE_READ_FAILED,i)}),0);console.warn(e)}e?(this.addImageToBuffer(e),Rs._onLog&&Rs._onLog("DCE: finish fetching a frame into buffer: "+Date.now()),He(this,as,"f").fire("frameAddedToBuffer",null,{async:!1})):Rs._onLog&&Rs._onLog("DCE: get a invalid frame, abandon it: "+Date.now())};if(this.getImageCount()>=this.getMaxImageCount())switch(this.getBufferOverflowProtectionMode()){case a.BOPM_BLOCK:break;case a.BOPM_UPDATE:e()}else e();He(this,gs,"f")&&clearTimeout(He(this,gs,"f")),Xe(this,gs,setTimeout((()=>{this.disposed||He(this,is,"m",t).call(this)}),this.fetchInterval))},Ss=function(t){if(!this.cameraView)throw new Error("Camera view is not set.");if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");if(!this.isOpen())throw new Error("Not open.");if(!He(this,is,"m",ys).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(He(this,is,"m",ys).call(this)&&!this.cameraView._cvsSingleFrameMode)throw new Error("No image is selected.");const e=this.cameraView._innerComponent.getBoundingClientRect(),i=e.left,n=e.top,r=i+window.scrollX,s=n+window.scrollY,{width:a,height:o}=this.cameraView._innerComponent.getBoundingClientRect();if(a<=0||o<=0)throw new Error("Unable to get content dimensions. Camera view may not be rendered on the page.");let l,h,c;if(He(this,is,"m",ys).call(this)){const t=this.cameraView._innerComponent.getElement("content");l=t.width,h=t.height,c="contain"}else{const t=this.getVideoEl();l=t.videoWidth,h=t.videoHeight,c=this.cameraView.getVideoFit()}const u=a/o,d=l/h;let f,g,m,p,_=1;if("contain"===c)u{var e;if(!this.isUseMagnifier)return;if(He(this,Ls,"f")||Xe(this,Ls,new Ns),!He(this,Ls,"f").magnifierCanvas)return;document.body.contains(He(this,Ls,"f").magnifierCanvas)||(He(this,Ls,"f").magnifierCanvas.style.position="fixed",He(this,Ls,"f").magnifierCanvas.style.boxSizing="content-box",He(this,Ls,"f").magnifierCanvas.style.border="2px solid #FFFFFF",document.body.append(He(this,Ls,"f").magnifierCanvas));const i=this._innerComponent.getElement("content");if(!i)return;if(t.pointer.x<0||t.pointer.x>i.width||t.pointer.y<0||t.pointer.y>i.height)return void He(this,Fs,"f").call(this);const n=null===(e=this._drawingLayerManager._getFabricCanvas())||void 0===e?void 0:e.lowerCanvasEl;if(!n)return;const r=Math.max(i.clientWidth/5/1.5,i.clientHeight/4/1.5),s=1.5*r,a=[{image:i,width:i.width,height:i.height},{image:n,width:n.width,height:n.height}];He(this,Ls,"f").update(s,t.pointer,r,a);{let e=0,i=0;t.e instanceof MouseEvent?(e=t.e.clientX,i=t.e.clientY):t.e instanceof TouchEvent&&t.e.changedTouches.length&&(e=t.e.changedTouches[0].clientX,i=t.e.changedTouches[0].clientY),e<1.5*s&&i<1.5*s?(He(this,Ls,"f").magnifierCanvas.style.left="auto",He(this,Ls,"f").magnifierCanvas.style.top="0",He(this,Ls,"f").magnifierCanvas.style.right="0"):(He(this,Ls,"f").magnifierCanvas.style.left="0",He(this,Ls,"f").magnifierCanvas.style.top="0",He(this,Ls,"f").magnifierCanvas.style.right="auto")}He(this,Ls,"f").show()})),Fs.set(this,(()=>{He(this,Ls,"f")&&He(this,Ls,"f").hide()})),Ps.set(this,!1)}_setUIElement(t){this.UIElement=t,this._unbindUI(),this._bindUI()}async setUIElement(t){let e;if("string"==typeof t){let i=await Wi(t);e=document.createElement("div"),Object.assign(e.style,{width:"100%",height:"100%"}),e.attachShadow({mode:"open"}).appendChild(i)}else e=t;this._setUIElement(e)}getUIElement(){return this.UIElement}_bindUI(){if(!this.UIElement)throw new Error("Need to set 'UIElement'.");if(this._innerComponent)return;const t=this.UIElement;let e=t.classList.contains(this.containerClassName)?t:t.querySelector(`.${this.containerClassName}`);e||(e=document.createElement("div"),e.style.width="100%",e.style.height="100%",e.className=this.containerClassName,t.append(e)),this._innerComponent=document.createElement("dce-component"),e.appendChild(this._innerComponent)}_unbindUI(){var t,e,i;null===(t=this._drawingLayerManager)||void 0===t||t.clearDrawingLayers(),null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null,null===(i=this._innerComponent)||void 0===i||i.remove(),this._innerComponent=null}setImage(t,e,i){if(!this._innerComponent)throw new Error("Need to set 'UIElement'.");let n=this._innerComponent.getElement("content");n||(n=document.createElement("canvas"),n.style.objectFit="contain",this._innerComponent.setElement("content",n)),n.width===e&&n.height===i||(n.width=e,n.height=i);const r=n.getContext("2d");r.clearRect(0,0,n.width,n.height),t instanceof Uint8Array||t instanceof Uint8ClampedArray?(t instanceof Uint8Array&&(t=new Uint8ClampedArray(t.buffer)),r.putImageData(new ImageData(t,e,i),0,0)):(t instanceof HTMLCanvasElement||t instanceof HTMLImageElement)&&r.drawImage(t,0,0)}getImage(){return this._innerComponent.getElement("content")}clearImage(){if(!this._innerComponent)return;let t=this._innerComponent.getElement("content");t&&t.getContext("2d").clearRect(0,0,t.width,t.height)}removeImage(){this._innerComponent&&this._innerComponent.removeElement("content")}setOriginalImage(t){if(y(t)){Xe(this,As,t);const{width:e,height:i,bytes:n,format:r}=Object.assign({},t);let s;if(r===l.IPF_GRAYSCALED){s=new Uint8ClampedArray(e*i*4);for(let t=0;t({x:e.x-t.left-t.width/2,y:e.y-t.top-t.height/2}))),t.addWithUpdate()}else i.points=e;const n=i.points.length-1;return i.controls=i.points.reduce((function(t,e,i){return t["p"+i]=new ai.Control({positionHandler:Ci,actionHandler:bi(i>0?i-1:n,Ti),actionName:"modifyPolygon",pointIndex:i}),t}),{}),i._setPositionDimensions({}),!0}}extendGet(t){if("startPoint"===t||"endPoint"===t){const e=[],i=this._fabricObject;if(i.selectable&&!i.group)for(let t in i.oCoords)e.push({x:i.oCoords[t].x,y:i.oCoords[t].y});else for(let t of i.points){let n=t.x-i.pathOffset.x,r=t.y-i.pathOffset.y;const s=ai.util.transformPoint({x:n,y:r},i.calcTransformMatrix());e.push({x:s.x,y:s.y})}return"startPoint"===t?e[0]:e[1]}}updateCoordinateBaseFromImageToView(){const t=this.get("startPoint"),e=this.get("endPoint");this.set("startPoint",{x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)}),this.set("endPoint",{x:this.convertPropFromViewToImage(e.x),y:this.convertPropFromViewToImage(e.y)})}updateCoordinateBaseFromViewToImage(){const t=this.get("startPoint"),e=this.get("endPoint");this.set("startPoint",{x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)}),this.set("endPoint",{x:this.convertPropFromImageToView(e.x),y:this.convertPropFromImageToView(e.y)})}setPosition(t){this.setLine(t)}getPosition(){return this.getLine()}updatePosition(){He(this,Oi,"f")&&this.setLine(He(this,Oi,"f"))}setPolygon(){}getPolygon(){return null}setLine(t){if(!C(t))throw new TypeError("Invalid 'line'.");if(this._drawingLayer){if("view"===this.coordinateBase)this.set("startPoint",{x:this.convertPropFromViewToImage(t.startPoint.x),y:this.convertPropFromViewToImage(t.startPoint.y)}),this.set("endPoint",{x:this.convertPropFromViewToImage(t.endPoint.x),y:this.convertPropFromViewToImage(t.endPoint.y)});else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("startPoint",t.startPoint),this.set("endPoint",t.endPoint)}this._drawingLayer.renderAll()}else Xe(this,Oi,JSON.parse(JSON.stringify(t)))}getLine(){if(this._drawingLayer){if("view"===this.coordinateBase)return{startPoint:{x:this.convertPropFromImageToView(this.get("startPoint").x),y:this.convertPropFromImageToView(this.get("startPoint").y)},endPoint:{x:this.convertPropFromImageToView(this.get("endPoint").x),y:this.convertPropFromImageToView(this.get("endPoint").y)}};if("image"===this.coordinateBase)return{startPoint:this.get("startPoint"),endPoint:this.get("endPoint")};throw new Error("Invalid 'coordinateBase'.")}return He(this,Oi,"f")?JSON.parse(JSON.stringify(He(this,Oi,"f"))):null}},QuadDrawingItem:Ai,RectDrawingItem:Ei,TextDrawingItem:Ri});function Gs(t){delete t.moduleId;const e=JSON.parse(t.jsonString).ResultInfo,i=t.fullCodeString;t.getFieldValue=t=>"fullcodestring"===t.toLowerCase()?i:Ws(e,t,"map"),t.getFieldRawValue=t=>Ws(e,t,"raw"),t.getFieldMappingStatus=t=>Ys(e,t),t.getFieldValidationStatus=t=>zs(e,t),delete t.fullCodeString}function Ws(t,e,i){for(let n of t){if(n.FieldName===e)return"raw"===i&&n.RawValue?n.RawValue:n.Value;if(n.ChildFields&&n.ChildFields.length>0){let t;for(let r of n.ChildFields)t=Ws(r,e,i);if(void 0!==t)return t}}}function Ys(t,e){for(let i of t){if(i.FieldName===e)return i.MappingStatus?Number(Vs[i.MappingStatus]):Vs.MS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=Ys(n,e);if(void 0!==t)return t}}}function zs(t,e){for(let i of t){if(i.FieldName===e&&i.ValidationStatus)return i.ValidationStatus?Number(js[i.ValidationStatus]):js.VS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=zs(n,e);if(void 0!==t)return t}}}function Hs(t){if(t.disposed)throw new Error('"CodeParser" instance has been disposed')}!function(t){t[t.MS_NONE=0]="MS_NONE",t[t.MS_SUCCEEDED=1]="MS_SUCCEEDED",t[t.MS_FAILED=2]="MS_FAILED"}(Vs||(Vs={})),function(t){t[t.VS_NONE=0]="VS_NONE",t[t.VS_SUCCEEDED=1]="VS_SUCCEEDED",t[t.VS_FAILED=2]="VS_FAILED"}(js||(js={}));const Xs=t=>t&&"object"==typeof t&&"function"==typeof t.then,Zs=(async()=>{})().constructor;let qs=class extends Zs{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,Xs(t)?e=t:"function"==typeof t&&(e=new Zs(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&&(Xs(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}};const Js="undefined"==typeof self,Ks="function"==typeof importScripts,$s=(()=>{if(!Ks){if(!Js&&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"./"}})();gt.engineResourcePaths.dcp={version:"2.4.32",path:$s,isInternal:!0},ut.dcp={js:!0,wasm:!0,deps:["license"]},ct.dcp={handleParsedResultItem:Gs};const Qs="1.4.21";"string"!=typeof gt.engineResourcePaths.std&&R(gt.engineResourcePaths.std.version,Qs)<0&&(gt.engineResourcePaths.std={version:Qs,path:(t=>{if(null==t&&(t="./"),Js||Ks);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})($s+`../../dynamsoft-capture-vision-std@${Qs}/dist/`),isInternal:!0});let ta=class{static getVersion(){const t=ht.dcp&&ht.dcp.wasm;return`2.4.32(Worker: ${ht.dcp&&ht.dcp.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadSpec(t,e){return await ft("dcp"),await new Promise(((i,n)=>{let r=nt();rt[r]=async t=>{if(t.success)return i();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},e&&!e.endsWith("/")&&(e+="/");const s=t instanceof Array?t:[t],a=O(gt.engineResourcePaths);et.postMessage({type:"dcp_appendResourceBuffer",id:r,body:{specificationPath:e||a.dcp+"specification/",specificationNames:s}})}))}};var ea=Object.freeze({__proto__:null,CodeParser:class t{constructor(){this._instanceID=void 0,this.bDestroyed=!1}static async createInstance(){if(!ct.license)throw Error("Module `license` is not existed.");await ct.license.dynamsoft(),await ft("dcp");const e=new t,i=new qs;let n=nt();return rt[n]=async t=>{if(t.success)e._instanceID=t.instanceID,i.resolve(e);else{const e=Error(t.message);t.stack&&(e.stack=t.stack),i.reject(e)}},et.postMessage({type:"dcp_createInstance",id:n}),i}async dispose(){Hs(this);let t=nt();this.bDestroyed=!0,rt[t]=t=>{if(!t.success){let e=new Error(t.message);throw e.stack=t.stack+"\n"+e.stack,e}},et.postMessage({type:"dcp_dispose",id:t,instanceID:this._instanceID})}get disposed(){return this.bDestroyed}async initSettings(t){return Hs(this),t&&["string","object"].includes(typeof t)?("string"==typeof t?t.trimStart().startsWith("{")||(t=await x(t,"text")):"object"==typeof t&&(t=JSON.stringify(t)),await new Promise(((e,i)=>{let n=nt();rt[n]=async t=>{if(t.success){const n=JSON.parse(t.response);if(0!==n.errorCode){let t=new Error(n.errorString?n.errorString:"Init Settings Failed.");return t.errorCode=n.errorCode,i(t)}return e(n)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},et.postMessage({type:"dcp_initSettings",id:n,instanceID:this._instanceID,body:{settings:t}})}))):console.error("Invalid settings.")}async resetSettings(){return Hs(this),await new Promise(((t,e)=>{let i=nt();rt[i]=async i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},et.postMessage({type:"dcp_resetSettings",id:i,instanceID:this._instanceID})}))}async parse(t,e=""){if(Hs(this),!t||!(t instanceof Array||t instanceof Uint8Array||"string"==typeof t))throw new Error("`parse` must pass in an Array or Uint8Array or string");return await new Promise(((i,n)=>{let r=nt();t instanceof Array&&(t=Uint8Array.from(t)),"string"==typeof t&&(t=Uint8Array.from(function(t){let e=[];for(let i=0;i{if(t.success){let e=JSON.parse(t.parseResponse);return e.errorCode?n(new Error(e.errorString)):(Gs(e),i(e))}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},et.postMessage({type:"dcp_parse",id:r,instanceID:this._instanceID,body:{source:t,taskSettingName:e}})}))}},CodeParserModule:ta,get EnumMappingStatus(){return Vs},get EnumValidationStatus(){return js}});const ia="undefined"==typeof self,na="function"==typeof importScripts,ra=(()=>{if(!na){if(!ia&&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"./"}})(),sa=t=>{if(null==t&&(t="./"),ia||na);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};gt.engineResourcePaths.dlr={version:"3.4.32",path:ra,isInternal:!0},null==gt.engineResourcePaths.dlrData&&(gt.engineResourcePaths.dlrData={version:"1.0.11",path:sa(ra+"../../dynamsoft-label-recognizer-data@1.0.11/dist/"),isInternal:!0}),ut.dlr={js:!0,wasm:!0,deps:["license","dip","dnn"]},ut.dnn={wasm:!0,deps:["dip"]};const aa="1.4.21";"string"!=typeof gt.engineResourcePaths.std&&R(gt.engineResourcePaths.std.version,aa)<0&&(gt.engineResourcePaths.std={version:aa,path:sa(ra+`../../dynamsoft-capture-vision-std@${aa}/dist/`),isInternal:!0});const oa="2.4.31";(!gt.engineResourcePaths.dip||"string"!=typeof gt.engineResourcePaths.dip&&R(gt.engineResourcePaths.dip.version,oa)<0)&&(gt.engineResourcePaths.dip={version:oa,path:sa(ra+`../../dynamsoft-image-processing@${oa}/dist/`),isInternal:!0});const la="1.0.20";(!gt.engineResourcePaths.dnn||"string"!=typeof gt.engineResourcePaths.dnn&&R(gt.engineResourcePaths.dnn.version,la)<0)&&(gt.engineResourcePaths.dnn={version:la,path:sa(ra+`../../dynamsoft-capture-vision-dnn@${la}/dist/`),isInternal:!0});let ha=!1,ca=class{static getVersion(){const t=ht.dlr&&ht.dlr.wasm;return`3.4.32(Worker: ${ht.dlr&&ht.dlr.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadRecognitionData(t,e){return await ft("dlr"),await new Promise(((i,n)=>{let r=nt();rt[r]=async t=>{if(t.success){const e=t.result;if(0!==e.errorCode){let t=new Error(e.errorString);return t.errorCode=e.errorCode,n(t)}return e.isModel||(ha=!0),i(e)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},e&&!e.endsWith("/")&&(e+="/");const s=O(gt.engineResourcePaths);e||"ConfusableChars"!==t||(e=s.dlr),et.postMessage({type:"dlr_loadData",id:r,body:{dataName:t,dataPath:e||s.dlrData}})}))}};ct.dlr={loadRecognitionData:ca.loadRecognitionData,get bLoadConfusableCharsData(){return ha}};const ua={filterVINResult:function(t){let e="";if(18===t.characterResults.length){let e=t.characterResults[9].location.points[0].x-t.characterResults[8].location.points[1].x;e<2&&(e=2);let i=t.characterResults[1].location.points[0].x-t.characterResults[0].location.points[1].x,n=t.characterResults[17].location.points[0].x-t.characterResults[16].location.points[1].x,r=2===e?3:e;i-e>=r&&n-e=r&&i-et.characterResults[17].characterHConfidence?t.characterResults.pop():t.characterResults.shift()}else if(19===t.characterResults.length){let e=t.characterResults[10].location.points[0].x-t.characterResults[9].location.points[1].x;e<2&&(e=2);let i,n,r,s=t.characterResults[1].location.points[0].x-t.characterResults[0].location.points[1].x,a=t.characterResults[18].location.points[0].x-t.characterResults[17].location.points[1].x,o=t.characterResults[2].location.points[0].x-t.characterResults[1].location.points[1].x,l=t.characterResults[17].location.points[0].x-t.characterResults[16].location.points[1].x,h=2===e?3:e;if("1"===t.characterResults[1].characterH||"1"===t.characterResults[2].characterH||"1"===t.characterResults[16].characterH||"1"===t.characterResults[17].characterH){for(let e=9;e=(i||h)&&l-e<(n||h))t.characterResults.splice(0,2);else if(l-e>=(n||h)&&o-e<(i||h))t.characterResults.splice(17,2);else if(s>e&&a>e)t.characterResults.pop(),t.characterResults.shift();else{let e=t.characterResults[0].characterHConfidence+t.characterResults[1].characterHConfidence,i=t.characterResults[17].characterHConfidence+t.characterResults[18].characterHConfidence,n=t.characterResults[0].characterHConfidence+t.characterResults[18].characterHConfidence,r=Math.min(e,i,n);r===e?t.characterResults.splice(0,2):r===i?t.characterResults.splice(17,2):r===n&&(t.characterResults.pop(),t.characterResults.shift())}}for(let i of t.characterResults)e+=i.characterH;return e},checkValidVIN:function(t){return!(!t||17!=t.length)&&(t=>{const e=new Map([["A",1],["B",2],["C",3],["D",4],["E",5],["F",6],["G",7],["H",8],["J",1],["K",2],["L",3],["M",4],["N",5],["P",7],["R",9],["S",2],["T",3],["U",4],["V",5],["W",6],["X",7],["Y",8],["Z",9],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9]]),i=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2];let n=0;for(let r=0;r{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10},i=t.slice(0,10)+t.slice(13,20)+t.slice(21,43),n=e(t,0,8).toString(),r=e(t,13,18).toString(),s=e(t,21,26).toString(),a=e(t,28,41).toString(),o=e(i,0,i.length).toString();return n===t[9]&&r===t[19]&&s===t[27]&&a===t[42]&&o===t[43]},checkValidMRV:function(t){if(!t||44!=t.length&&36!=t.length)return!1;const e=(t,e,i)=>{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10},i=e(t,0,8).toString(),n=e(t,13,18).toString(),r=e(t,21,26).toString();return i===t[9]&&n===t[19]&&r===t[27]},checkValidIDCard:function(t,e){if(!t||30!=t.length&&36!=t.length)return!1;const i=(t,e,i)=>{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10};if(30===t.length){if(e&&t===e)return i(t,5,13).toString()===t[14];if(e&&t!==e){const n=`${e.substring(5,30)}${t.substring(0,7)}${t.substring(8,15)}${t.substring(18,29)}`;return i(n,0,n.length-1).toString()===t[29]}}else if(36===t.length){const e=i(t,0,8).toString(),n=i(t,13,18).toString(),r=i(t,21,26).toString(),s=`${t.substring(0,10)}${t.substring(13,20)}${t.substring(21,28)}`,a=i(s,0,s.length-1).toString();return e===t[9]&&n===t[19]&&r===t[27]&&a===t[35]}}};var da;!function(t){t[t.RTLS_LOCALIZED=0]="RTLS_LOCALIZED",t[t.RTLS_RECOGNITION_FAILED=1]="RTLS_RECOGNITION_FAILED",t[t.RTLS_RECOGNITION_SUCCEEDED=2]="RTLS_RECOGNITION_SUCCEEDED"}(da||(da={})),rt[-1]=async t=>{ca.onDataLoadProgressChanged&&ca.onDataLoadProgressChanged(t.resourcesPath,t.tag,{loaded:t.loaded,total:t.total})};var fa=Object.freeze({__proto__:null,get EnumRawTextLineStatus(){return da},LabelRecognizerModule:ca,utilsFuncs:ua});const ga=async t=>{let e;await new Promise(((i,n)=>{e=new Image,e.onload=()=>i(e),e.onerror=n,e.src=URL.createObjectURL(t)}));const i=document.createElement("canvas"),n=i.getContext("2d");return i.width=e.width,i.height=e.height,n.drawImage(e,0,0),{bytes:Uint8Array.from(n.getImageData(0,0,i.width,i.height).data),width:i.width,height:i.height,stride:4*i.width,format:10}};const ma="undefined"==typeof self,pa="function"==typeof importScripts,_a=(()=>{if(!pa){if(!ma&&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"./"}})(),va=t=>{if(null==t&&(t="./"),ma||pa);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};gt.engineResourcePaths.utility={version:"1.4.32",path:_a,isInternal:!0},ut.utility={js:!0,wasm:!0};const ya="1.4.21";"string"!=typeof gt.engineResourcePaths.std&&R(gt.engineResourcePaths.std.version,ya)<0&&(gt.engineResourcePaths.std={version:ya,path:va(_a+`../../dynamsoft-capture-vision-std@${ya}/dist/`),isInternal:!0});const wa="2.4.31";(!gt.engineResourcePaths.dip||"string"!=typeof gt.engineResourcePaths.dip&&R(gt.engineResourcePaths.dip.version,wa)<0)&&(gt.engineResourcePaths.dip={version:wa,path:va(_a+`../../dynamsoft-image-processing@${wa}/dist/`),isInternal:!0});function Ea(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)}var Ca,Sa,Ta,ba,Ia;function xa(t,e){let i=!0;for(let a=0;a1)return Math.sqrt((l-a)**2+(h-o)**2);{const t=r+u*(a-r),e=s+u*(o-s);return Math.sqrt((l-t)**2+(h-e)**2)}}function Da(t){const e=[];for(let i=0;i=0&&l<=1&&h>=0&&h<=1?{x:t.x+h*r,y:t.y+h*s}:null}function Ma(t){let e=0;for(let i=0;i0}function Pa(t,e){for(let i=0;i<4;i++)if(!Fa(t.points[i],t.points[(i+1)%4],e))return!1;return!0}"function"==typeof SuppressedError&&SuppressedError;function ka(t,e,i,n){const r=t.points,s=e.points;let a=8*i;a=Math.max(a,5);const o=Da(r)[3],l=Da(r)[1],h=Da(s)[3],c=Da(s)[1];let u,d=0;if(u=Math.max(Math.abs(Oa(o,e.points[0])),Math.abs(Oa(o,e.points[3]))),u>d&&(d=u),u=Math.max(Math.abs(Oa(l,e.points[1])),Math.abs(Oa(l,e.points[2]))),u>d&&(d=u),u=Math.max(Math.abs(Oa(h,t.points[0])),Math.abs(Oa(h,t.points[3]))),u>d&&(d=u),u=Math.max(Math.abs(Oa(c,t.points[1])),Math.abs(Oa(c,t.points[2]))),u>d&&(d=u),d>a)return!1;const f=Aa(Da(r)[0]),g=Aa(Da(r)[2]),m=Aa(Da(s)[0]),p=Aa(Da(s)[2]),_=Ra(f,p),v=Ra(m,g),y=_>v,w=Math.min(_,v),E=Ra(f,g),C=Ra(m,p);let S=12*i;return S=Math.max(S,5),S=Math.min(S,E),S=Math.min(S,C),!!(w{e.x+=t,e.y+=i})),e.x/=t.length,e.y/=t.length,e}isProbablySameLocationWithOffset(t,e){const i=this.item.location,n=t.location;if(i.area<=0)return!1;if(Math.abs(i.area-n.area)>.4*i.area)return!1;let r=new Array(4).fill(0),s=new Array(4).fill(0),a=0,o=0;for(let t=0;t<4;++t)r[t]=Math.round(100*(n.points[t].x-i.points[t].x))/100,a+=r[t],s[t]=Math.round(100*(n.points[t].y-i.points[t].y))/100,o+=s[t];a/=4,o/=4;for(let t=0;t<4;++t){if(Math.abs(r[t]-a)>this.strictLimit||Math.abs(a)>.8)return!1;if(Math.abs(s[t]-o)>this.strictLimit||Math.abs(o)>.8)return!1}return e.x=a,e.y=o,!0}isLocationOverlap(t,e){if(this.locationArea>e){for(let e=0;e<4;e++)if(Pa(this.location,t.points[e]))return!0;const e=this.getCenterPoint(t.points);if(Pa(this.location,e))return!0}else{for(let e=0;e<4;e++)if(Pa(t,this.location.points[e]))return!0;if(Pa(t,this.getCenterPoint(this.location.points)))return!0}return!1}isMatchedLocationWithOffset(t,e={x:0,y:0}){if(this.isOneD){const i=Object.assign({},t.location);for(let t=0;t<4;t++)i.points[t].x-=e.x,i.points[t].y-=e.y;if(!this.isLocationOverlap(i,t.locationArea))return!1;const n=[this.location.points[0],this.location.points[3]],r=[this.location.points[1],this.location.points[2]];for(let t=0;t<4;t++){const e=i.points[t],s=0===t||3===t?n:r;if(Math.abs(Oa(s,e))>this.locationThreshold)return!1}}else for(let i=0;i<4;i++){const n=t.location.points[i],r=this.location.points[i];if(!(Math.abs(r.x+e.x-n.x)=this.locationThreshold)return!1}return!0}isOverlappedLocationWithOffset(t,e,i=!0){const n=Object.assign({},t.location);for(let t=0;t<4;t++)n.points[t].x-=e.x,n.points[t].y-=e.y;if(!this.isLocationOverlap(n,t.location.area))return!1;if(i){const t=.75;return function(t,e){const i=[];for(let n=0;n<4;n++)for(let r=0;r<4;r++){const s=La(t[n],t[(n+1)%4],e[r],e[(r+1)%4]);s&&i.push(s)}return t.forEach((t=>{xa(e,t)&&i.push(t)})),e.forEach((e=>{xa(t,e)&&i.push(e)})),Ma(function(t){if(t.length<=1)return t;t.sort(((t,e)=>t.x-e.x||t.y-e.y));const e=t.shift();return t.sort(((t,i)=>Math.atan2(t.y-e.y,t.x-e.x)-Math.atan2(i.y-e.y,i.x-e.x))),[e,...t]}(i))}([...this.location.points],n.points)>this.locationArea*t}return!0}}const Ba={BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096)},Va={barcode:2,text_line:4,detected_quad:8,normalized_image:16},ja=t=>Object.values(Va).includes(t)||Va.hasOwnProperty(t),Ua=(t,e)=>"string"==typeof t?e[Va[t]]:e[t],Ga=(t,e,i)=>{"string"==typeof t?e[Va[t]]=i:e[t]=i},Wa=(t,e,i)=>{const n=[8,16].includes(i);if(!n&&t.isResultCrossVerificationEnabled(i))for(let t=0;t{Ga(e,this.verificationEnabled,t)})),Ea(this,Sa,"f").forEach(((t,e)=>{Ga(e,this.duplicateFilterEnabled,t)})),Ea(this,Ta,"f").forEach(((t,e)=>{Ga(e,this.duplicateForgetTime,t)})),Ea(this,ba,"f").forEach(((t,e)=>{Ga(e,this.latestOverlappingEnabled,t)})),Ea(this,Ia,"f").forEach(((t,e)=>{Ga(e,this.maxOverlappingFrames,t)}))}enableResultCrossVerification(t,e){ja(t)&&Ea(this,Ca,"f").set(t,e)}isResultCrossVerificationEnabled(t){return!!ja(t)&&Ua(t,this.verificationEnabled)}enableResultDeduplication(t,e){ja(t)&&(e&&this.enableLatestOverlapping(t,!1),Ea(this,Sa,"f").set(t,e))}isResultDeduplicationEnabled(t){return!!ja(t)&&Ua(t,this.duplicateFilterEnabled)}setDuplicateForgetTime(t,e){ja(t)&&(e>18e4&&(e=18e4),e<0&&(e=0),Ea(this,Ta,"f").set(t,e))}getDuplicateForgetTime(t){return ja(t)?Ua(t,this.duplicateForgetTime):-1}setMaxOverlappingFrames(t,e){ja(t)&&Ea(this,Ia,"f").set(t,e)}getMaxOverlappingFrames(t){return ja(t)?Ua(t,this.maxOverlappingFrames):-1}enableLatestOverlapping(t,e){ja(t)&&(e&&this.enableResultDeduplication(t,!1),Ea(this,ba,"f").set(t,e))}isLatestOverlappingEnabled(t){return!!ja(t)&&Ua(t,this.latestOverlappingEnabled)}getFilteredResultItemTypes(){let t=0;const e=[mt.CRIT_BARCODE,mt.CRIT_TEXT_LINE,mt.CRIT_DETECTED_QUAD,mt.CRIT_NORMALIZED_IMAGE];for(let i=0;i{if(1!==t.type){const e=(BigInt(t.format)&BigInt(Ba.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Ba.BF_GS1_DATABAR))!=BigInt(0);return new Na(l,e?1:2,e,t)}})).filter(Boolean);if(this.overlapSet.length>0){const t=new Array(h).fill(new Array(this.overlapSet.length).fill(1));let e=0;for(;e-1!==t)).length;r>p&&(p=r,m=n,g.x=i.x,g.y=i.y)}}if(0===p){for(let e=0;e-1!=t)).length}let i=this.overlapSet.length<=3?p>=1:p>=2;if(!i&&s&&u>0){let t=0;for(let e=0;e=1:t>=3}i||(this.overlapSet=[])}if(0===this.overlapSet.length)this.stabilityCount=0,t.items.forEach(((t,e)=>{if(1!==t.type){const i=Object.assign({},t),n=(BigInt(t.format)&BigInt(Ba.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Ba.BF_GS1_DATABAR))!=BigInt(0),s=t.confidence5||Math.abs(g.y)>5)&&(e=!1):e=!1;for(let i=0;i0){for(let t=0;t!(t.overlapCount+this.stabilityCount<=0&&t.crossVerificationFrame<=0)))}f.sort(((t,e)=>e-t)).forEach(((e,i)=>{t.items.splice(e,1)})),d.forEach((e=>{t.items.push(Object.assign(Object.assign({},e),{overlapped:!0}))}))}}onDecodedBarcodesReceived(t){this.latestOverlappingFilter(t),Wa(this,t.items,mt.CRIT_BARCODE)}onRecognizedTextLinesReceived(t){Wa(this,t.items,mt.CRIT_TEXT_LINE)}onDetectedQuadsReceived(t){Wa(this,t.items,mt.CRIT_DETECTED_QUAD)}onNormalizedImagesReceived(t){Wa(this,t.items,mt.CRIT_NORMALIZED_IMAGE)}}Ca=new WeakMap,Sa=new WeakMap,Ta=new WeakMap,ba=new WeakMap,Ia=new WeakMap;var za,Ha,Xa,Za=Object.freeze({__proto__:null,ImageManager:class{async saveToFile(t,e,i){if(!t||!e)return null;if("string"!=typeof e)throw new TypeError("FileName must be of type string.");const n=M(t);return D(n,e,i)}async drawOnImage(t,e,i,n=4294901760,r=1,s){let a;if(t instanceof Blob)a=await ga(t);else if("string"==typeof t){let e=await x(t,"blob");a=await ga(e)}return await new Promise(((t,o)=>{let l=nt();rt[l]=async e=>{if(e.success)return s&&this.saveToFile(e.image,"test.png",s),t(e.image);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},et.postMessage({type:"utility_drawOnImage",id:l,body:{dsImage:a,drawingItem:e instanceof Array?e:[e],color:n,thickness:r,type:i}})}))}},MultiFrameResultCrossFilter:Ya,UtilityModule:class{static getVersion(){return`1.4.32(Worker: ${ht.utility&&ht.utility.worker||"Not Loaded"}, Wasm: ${ht.utility&&ht.utility.wasm||"Not Loaded"})`}}});t.EnumMRZScanMode=void 0,(za=t.EnumMRZScanMode||(t.EnumMRZScanMode={})).Passport="passport",za.TD1="td1",za.TD2="td2",za.PassportAndTD1="passportAndTd1",za.PassportAndTD2="passportAndTd2",za.TD1AndTD2="td1AndTd2",za.All="all",t.EnumMRZDocumentType=void 0,(Ha=t.EnumMRZDocumentType||(t.EnumMRZDocumentType={})).Passport="passport",Ha.TD1="td1",Ha.TD2="td2",t.EnumMRZScannerViews=void 0,(Xa=t.EnumMRZScannerViews||(t.EnumMRZScannerViews={})).Scanner="scanner",Xa.Result="scan-result";const qa={[t.EnumMRZScanMode.Passport]:"ReadPassport",[t.EnumMRZScanMode.TD1]:"ReadId-TD1",[t.EnumMRZScanMode.TD2]:"ReadId-TD2",[t.EnumMRZScanMode.PassportAndTD1]:"ReadPassportAndId-TD1",[t.EnumMRZScanMode.PassportAndTD2]:"ReadPassportAndId-TD2",[t.EnumMRZScanMode.TD1AndTD2]:"ReadId",[t.EnumMRZScanMode.All]:"ReadPassportAndId"};var Ja;function Ka(t){if("string"==typeof t){const e=document.querySelector(t);if(!e)throw new Error("Element not found");return e}return t instanceof HTMLElement?t:null}t.EnumResultStatus=void 0,(Ja=t.EnumResultStatus||(t.EnumResultStatus={}))[Ja.RS_SUCCESS=0]="RS_SUCCESS",Ja[Ja.RS_CANCELLED=1]="RS_CANCELLED",Ja[Ja.RS_FAILED=2]="RS_FAILED";function $a(t,e){if(!document.getElementById(t)){const i=document.createElement("style");i.id=t,i.textContent=e,document.head.appendChild(i)}}const Qa=t=>!t||0===Object.keys(t).length;function to(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}const eo={"4k":{width:3840,height:2160},"2k":{width:2560,height:1440},"1080p":{width:1920,height:1080},"720p":{width:1280,height:720},"480p":{width:640,height:480}};function io(t,e={}){const{message:i,spinnerSize:n=32}=e,r=document.createElement("div");r.className="dynamsoft-mrz-loading-screen";const s=document.createElement("div");s.className="dynamsoft-mrz-loading";const a=document.createElement("div");a.className="dynamsoft-mrz-loading-content";const o=`\n \n \n \n `;if(a.innerHTML=o,i){const t=document.createElement("div");t.className="dynamsoft-mrz-loading-message",t.textContent=i,a.appendChild(t)}return s.appendChild(a),r.appendChild(s),t.appendChild(r),{element:r,updateMessage:t=>{let e=s.querySelector(".dynamsoft-mrz-loading-message");null!==t?e?e.textContent=t:(e=document.createElement("div"),e.className="dynamsoft-mrz-loading-message",e.textContent=t,a.appendChild(e)):null==e||e.remove()},hide:()=>{r&&r.parentNode&&(r.classList.add("fade-out"),setTimeout((()=>{var t;null===(t=r.parentNode)||void 0===t||t.removeChild(r)}),200))}}}const no='\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: "Verdana";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n';var ro;t.EnumMRZData=void 0,(ro=t.EnumMRZData||(t.EnumMRZData={})).InvalidFields="invalidFields",ro.DocumentType="documentType",ro.DocumentNumber="documentNumber",ro.MRZText="mrzText",ro.FirstName="firstName",ro.LastName="lastName",ro.Age="age",ro.Sex="sex",ro.IssuingState="issuingState",ro.IssuingStateRaw="issuingStateRaw",ro.Nationality="nationality",ro.NationalityRaw="nationalityRaw",ro.DateOfBirth="dateOfBirth",ro.DateOfExpiry="dateOfExpiry";const so={[t.EnumMRZData.InvalidFields]:"Invalid Fields",[t.EnumMRZData.DocumentType]:"Document Type",[t.EnumMRZData.DocumentNumber]:"Document Number",[t.EnumMRZData.MRZText]:"MRZ Text",[t.EnumMRZData.FirstName]:"Given Name(s)",[t.EnumMRZData.LastName]:"Surname",[t.EnumMRZData.Age]:"Age",[t.EnumMRZData.Sex]:"Sex",[t.EnumMRZData.IssuingState]:"Issuing State",[t.EnumMRZData.IssuingStateRaw]:"Issuing State (Raw Value)",[t.EnumMRZData.Nationality]:"Nationality",[t.EnumMRZData.NationalityRaw]:"Nationality State (Raw Value)",[t.EnumMRZData.DateOfBirth]:"Date Of Birth (YYYY-MM-DD)",[t.EnumMRZData.DateOfExpiry]:"Date Of Expiry (YYYY-MM-DD)"};function ao(t,e,i,n=!1){const r=parseInt(t,10);let s;if(n)s=r>=60?1900+r:2e3+r;else{s=r>(new Date).getFullYear()%100?1900+r:2e3+r}return{year:s,month:parseInt(e,10),day:parseInt(i,10)}}function oo(t){const e=t=>{var e;return 1===(null===(e=`${t}`)||void 0===e?void 0:e.length)?`0${t}`:t};return`${null==t?void 0:t.year}-${e(null==t?void 0:t.month)}${(null==t?void 0:t.day)&&`-${e(null==t?void 0:t.day)}`}`}function lo(t){return"D<<"===t?"D":t}function ho(e,i){const n=[],r=t=>i.getFieldValidationStatus(t)===js.VS_FAILED,s=i.codeType,a=function(e){switch(e){case"MRTD_TD1_ID":return t.EnumMRZDocumentType.TD1;case"MRTD_TD2_ID":case"MRTD_TD2_VISA":case"MRTD_TD2_FRENCH_ID":return t.EnumMRZDocumentType.TD2;case"MRTD_TD3_PASSPORT":case"MRTD_TD3_VISA":return t.EnumMRZDocumentType.Passport;default:throw new Error(`Unknown document type: ${e}`)}}(s),o=function(t){switch(t){case"MRTD_TD1_ID":return"ID (TD1)";case"MRTD_TD2_ID":return"ID (TD2)";case"MRTD_TD2_VISA":return"ID (VISA)";case"MRTD_TD2_FRENCH_ID":return"French ID (TD2)";case"MRTD_TD3_PASSPORT":return"Passport (TD3)";case"MRTD_TD3_VISA":return"Visa (TD3)";default:throw new Error(`Unknown document type: ${t}`)}}(s),l=a===t.EnumMRZDocumentType.Passport&&"MRTD_TD3_PASSPORT"===s?"passportNumber":"documentNumber",h=ao(i.getFieldValue("birthYear"),i.getFieldValue("birthMonth"),i.getFieldValue("birthDay")),c=ao(i.getFieldValue("expiryYear"),i.getFieldValue("expiryMonth"),i.getFieldValue("expiryDay"),!0);["birthYear","birthMonth","birthDay"].forEach((e=>{r(e)&&n.push(t.EnumMRZData.DateOfBirth)})),["expiryYear","expiryMonth","expiryDay"].forEach((e=>{r(e)&&n.push(t.EnumMRZData.DateOfExpiry)}));const u={[t.EnumMRZData.LastName]:i.getFieldValue("primaryIdentifier"),[t.EnumMRZData.FirstName]:i.getFieldValue("secondaryIdentifier"),[t.EnumMRZData.Nationality]:i.getFieldValue("nationality"),[t.EnumMRZData.NationalityRaw]:lo(i.getFieldRawValue("nationality")),[t.EnumMRZData.DocumentNumber]:i.getFieldValue(l)||i.getFieldValue("longDocumentNumber"),[t.EnumMRZData.IssuingState]:i.getFieldValue("issuingState"),[t.EnumMRZData.IssuingStateRaw]:lo(i.getFieldRawValue("issuingState")),[t.EnumMRZData.Sex]:to(i.getFieldValue("sex"))};Object.keys(u).forEach((e=>{let i=!1;switch(e){case t.EnumMRZData.FirstName:i=r("secondaryIdentifier");break;case t.EnumMRZData.LastName:i=r("primaryIdentifier");break;case t.EnumMRZData.DocumentNumber:i=r(l)||r("longDocumentNumber");break;default:i=r(e)}i&&n.push(e)}));const d=function(t){const e=new Date,i=e.getMonth()+1>t.month||e.getMonth()+1===t.month&&e.getDate()>=t.day;return e.getFullYear()-t.year-(i?0:1)}(h);d<1&&n.push(t.EnumMRZData.Age);return{[t.EnumMRZData.InvalidFields]:n,[t.EnumMRZData.FirstName]:u[t.EnumMRZData.FirstName],[t.EnumMRZData.LastName]:u[t.EnumMRZData.LastName],[t.EnumMRZData.Age]:d,[t.EnumMRZData.DateOfBirth]:h,[t.EnumMRZData.Sex]:u[t.EnumMRZData.Sex],[t.EnumMRZData.Nationality]:u[t.EnumMRZData.Nationality],[t.EnumMRZData.NationalityRaw]:u[t.EnumMRZData.NationalityRaw],[t.EnumMRZData.DocumentNumber]:u[t.EnumMRZData.DocumentNumber],[t.EnumMRZData.DateOfExpiry]:c,[t.EnumMRZData.IssuingState]:u[t.EnumMRZData.IssuingState],[t.EnumMRZData.IssuingStateRaw]:u[t.EnumMRZData.IssuingStateRaw],[t.EnumMRZData.DocumentType]:to(o),[t.EnumMRZData.MRZText]:e}}const co={[t.EnumMRZDocumentType.TD1]:{width:85.6,height:53.98},[t.EnumMRZDocumentType.TD2]:{width:105,height:74},[t.EnumMRZDocumentType.Passport]:{width:125,height:88}};class uo{showScannerLoadingOverlay(t){const e=Ka(this.config.container);this.loadingScreen=io(e,{message:t}),e.style.display="block",e.style.position="relative"}hideScannerLoadingOverlay(t=!1){this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,t&&(Ka(this.config.container).style.display="none"))}constructor(e,i){this.resources=e,this.config=i,this.isSoundFeedbackOn=!1,this.scanModeManager={[t.EnumMRZDocumentType.Passport]:!0,[t.EnumMRZDocumentType.TD1]:!0,[t.EnumMRZDocumentType.TD2]:!0},this.currentScanMode=t.EnumMRZScanMode.All,this.resizeTimer=null,this.capturedResultItems=[],this.originalImageData=null,this.initialized=!1,this.initializedDCE=!1,this.DCE_ELEMENTS={selectCameraBtn:null,uploadImageBtn:null,soundFeedbackBtn:null,closeScannerBtn:null,scanModeSelectContainer:null,passportModeOption:null,td1ModeOption:null,td2ModeOption:null,toast:null},this.loadingScreen=null,this.handleResize=()=>{this.toggleScanGuide(!1),this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((()=>{this.toggleScanGuide(!0)}),500)}}async initialize(){if(!this.initialized){this.initializeScanModeManager(),this.currentScanMode=this.getScanMode(),$a("dynamsoft-mrz-loading-screen-style",no);try{const{cameraView:t,cameraEnhancer:e,cvRouter:i}=this.resources;if(t.setScanRegionMaskStyle({strokeStyle:"transparent",fillStyle:"transparent",lineWidth:0}),t.setVideoFit("cover"),i.setInput(e),await i.initSettings(this.config.templateFilePath),!0===this.config.enableMultiFrameCrossFilter){const t=new Ya;t.enableResultCrossVerification(mt.CRIT_TEXT_LINE,!0),t.enableResultDeduplication(mt.CRIT_TEXT_LINE,!0),await i.addResultFilter(t)}const n=new Pe;n.onCapturedResultReceived=t=>this.handleMRZResult(t),await i.addResultReceiver(n),this.toggleSoundFeedback(!1),!1===this.config.showScanGuide&&this.toggleScanGuide(!1),this.initialized=!0}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"Dynamsoft MRZ Scanner initialize error"}};this.currentScanResolver(n)}}}initializeElements(){var t;const e=Ka(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))throw new Error("Shadow root not found");if(this.DCE_ELEMENTS={selectCameraBtn:i.shadowRoot.querySelector(".dce-mn-select-camera-icon"),uploadImageBtn:i.shadowRoot.querySelector(".dce-mn-upload-image-icon"),soundFeedbackBtn:i.shadowRoot.querySelector(".dce-mn-sound-feedback"),closeScannerBtn:i.shadowRoot.querySelector(".dce-mn-close"),scanModeSelectContainer:i.shadowRoot.querySelector(".dce-mn-scan-mode-select"),passportModeOption:i.shadowRoot.querySelector(".scan-mode-option-passport"),td1ModeOption:i.shadowRoot.querySelector(".scan-mode-option-td1"),td2ModeOption:i.shadowRoot.querySelector(".scan-mode-option-td2"),toast:i.shadowRoot.querySelector(".dce-mn-toast")},this.setupScanModeSelector(),this.assignDCEClickEvents(),this.DCE_ELEMENTS.toast.style.display="none",!1===this.config.showUploadImage&&(this.DCE_ELEMENTS.uploadImageBtn.style.visibility="hidden"),!1===this.config.showSoundToggle&&(this.DCE_ELEMENTS.soundFeedbackBtn.style.visibility="hidden"),!1===(null===(t=this.config)||void 0===t?void 0:t.showPoweredByDynamsoft)){i.shadowRoot.querySelector(".dce-mn-msg-poweredby").style.display="none"}this.initializedDCE=!0}setupScanModeSelector(){if(!1!==this.config.showFormatSelector)switch(this.currentScanMode){case t.EnumMRZScanMode.PassportAndTD1:this.DCE_ELEMENTS.td2ModeOption.style.display="none";break;case t.EnumMRZScanMode.PassportAndTD2:this.DCE_ELEMENTS.td1ModeOption.style.display="none";break;case t.EnumMRZScanMode.TD1AndTD2:this.DCE_ELEMENTS.passportModeOption.style.display="none";break;case t.EnumMRZScanMode.All:break;default:this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}else this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}assignDCEClickEvents(){if(!Object.values(this.DCE_ELEMENTS).every(Boolean))throw new Error("Camera control elements not found");this.closeCamera=this.closeCamera.bind(this),this.DCE_ELEMENTS.uploadImageBtn.onclick=()=>this.uploadFile(),this.DCE_ELEMENTS.soundFeedbackBtn.onclick=()=>this.toggleSoundFeedback(),this.DCE_ELEMENTS.closeScannerBtn.onclick=()=>this.handleCloseBtn(),this.DCE_ELEMENTS.selectCameraBtn.onclick=t=>{t.stopPropagation(),this.toggleSelectCameraBox()},this.DCE_ELEMENTS.passportModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.passportModeOption.style.display&&await this.toggleScanDocType(t.EnumMRZDocumentType.Passport)},this.DCE_ELEMENTS.td1ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td1ModeOption.style.display&&await this.toggleScanDocType(t.EnumMRZDocumentType.TD1)},this.DCE_ELEMENTS.td2ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td2ModeOption.style.display&&await this.toggleScanDocType(t.EnumMRZDocumentType.TD2)}}handleCloseBtn(){this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:t.EnumResultStatus.RS_CANCELLED,message:"Cancelled"}})}attachOptionClickListeners(){const t=Ka(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings");[...e.shadowRoot.querySelectorAll(".dce-mn-camera-option"),...e.shadowRoot.querySelectorAll(".dce-mn-resolution-option")].forEach((t=>{t.addEventListener("click",(async e=>{const n=t.getAttribute("data-davice-id"),r=t.getAttribute("data-height"),s=t.getAttribute("data-width");n?this.resources.cameraEnhancer.selectCamera(n).then((()=>{this.toggleScanGuide()})):r&&s&&this.resources.cameraEnhancer.setResolution({width:parseInt(s),height:parseInt(r)}).then((()=>{this.toggleScanGuide()})),"none"!==i.style.display&&this.toggleSelectCameraBox()}))}))}highlightCameraAndResolutionOption(){const t=Ka(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings"),n=i.querySelectorAll(".dce-mn-camera-option"),r=i.querySelectorAll(".dce-mn-resolution-option"),s=this.resources.cameraEnhancer.getSelectedCamera(),a=this.resources.cameraEnhancer.getResolution();n.forEach((t=>{const e=t;e.getAttribute("data-davice-id")===(null==s?void 0:s.deviceId)?e.style.border="2px solid #fe814a":e.style.border="none"}));const o={"480p":"480","720p":"720","1080p":"1080","2k":"1440","4k":"2160"},l=function(t){const e=t.width*t.height,i=t.width/t.height;let n="480p",r=Number.MAX_VALUE;for(const[t,s]of Object.entries(eo)){const a=s.width*s.height,o=s.width/s.height,l=.7*Math.abs(a-e)+Math.abs(o-i)*a*.3;l{const e=t,i=e.getAttribute("data-height");e.style.border=i===o[l]?"2px solid #fe814a":"none"}))}toggleSelectCameraBox(){const t=Ka(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-resolution-box");this.highlightCameraAndResolutionOption(),this.attachOptionClickListeners(),i.click()}async relaunch(){}async uploadFile(){var e,i,n,r;const{cvRouter:s}=this.resources,a=document.createElement("input");a.type="file",a.accept=null!==(e=this.config.uploadAcceptedTypes)&&void 0!==e?e:"image/*",a.style.display="none",document.body.appendChild(a);try{this.showScannerLoadingOverlay("Processing file..."),await this.closeCamera(!1);const e=await new Promise(((t,e)=>{a.onchange=i=>{var n;const r=null===(n=i.target.files)||void 0===n?void 0:n[0];r?t(r):e(new Error("No file selected"))},a.addEventListener("cancel",(async()=>{this.hideScannerLoadingOverlay(!1),await this.openCamera(),await this.startCapturing(),this.toggleScanGuide()})),a.click()}));if(!e)return;let o;if(this.config.uploadFileConverter&&!e.type.startsWith("image/"))try{o=await this.config.uploadFileConverter(e)}catch(t){throw new Error(`Error converting file: ${t.message}`)}else{if(!e.type.startsWith("image/"))throw new Error("Unsupported file type. Please provide a converter function for this file type.");o=e}const l=this.config.utilizedTemplateNames[this.currentScanMode];if(!1!==this.config.showScanGuide){const t=await s.getSimplifiedSettings(l);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await s.updateSettings(l,t)}const h=await s.capture(o,l);this.capturedResultItems=h.items;const c=this.capturedResultItems.filter((t=>t.type===mt.CRIT_ORIGINAL_IMAGE));if(0===c.length)throw new Error("No image data found in the captured result");const u=c[0].imageData;u.toCanvas=()=>A(u),u.toBlob=async()=>await L("image/png",u),this.originalImageData=u;const d=null==h?void 0:h.textLineResultItems,f=null==h?void 0:h.parsedResultItems;let g={};if(null==d?void 0:d.length){const t=(null===(i=d[0])||void 0===i?void 0:i.text)||"";g=ho(t,f[0])}const m={status:{code:t.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:g,imageData:!0,_imageData:this.originalImageData};null===(r=(n=this.resources).onResultUpdated)||void 0===r||r.call(n,m),this.currentScanResolver(m)}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:`Error processing file: ${i}`}};this.currentScanResolver(n)}finally{this.hideScannerLoadingOverlay(!0),document.body.removeChild(a)}}toggleSoundFeedback(t){this.isSoundFeedbackOn=void 0!==t?t:!this.isSoundFeedbackOn;const e=Ka(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))return;const n=i.shadowRoot.querySelector(".dce-mn-sound-feedback"),r=n.querySelector(".dce-mn-sound-feedback-on");n.querySelector(".dce-mn-sound-feedback-off").style.display=this.isSoundFeedbackOn?"none":"block",r.style.display=this.isSoundFeedbackOn?"block":"none"}calculateScanRegion(t){const{cameraEnhancer:e,cameraView:i}=this.resources;if(!e||!e.isOpen())return;const n=i.getVisibleRegionOfVideo({inPixels:!0});if(!n)return;const r=i.getVideoElement(),s=r.videoWidth,a=r.videoHeight,o=co[t];let l;const h=n.height-80;if(n.width>n.height){l=.75*h/o.height;l*o.width>.9*n.width&&(l=.9*n.width/o.width)}else{l=.9*n.width/o.width;l*o.height>.75*h&&(l=.75*h/o.height)}const c=l*o.width,u=l*o.height,d=(n.width-c)/2,f=(h-u)/2,g=d,m=d+c,p=f,_=f+u,v=(n.x+g)/s*100,y=(n.x+m)/s*100,w=(n.y+p)/a*100,E=(n.y+_)/a*100,C={left:Math.round(v),right:Math.round(y),top:Math.round(w),bottom:Math.round(E),isMeasuredInPercentage:!0};null==i||i.setScanRegionMaskVisible(!0),e.setScanRegion(C)}toggleScanGuide(e){const i=Ka(this.config.container),n=i.children[i.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const r=n.shadowRoot.querySelector(".dce-scanguide-passport"),s=n.shadowRoot.querySelector(".dce-scanguide-td1"),a=n.shadowRoot.querySelector(".dce-scanguide-td2");if(!1===e||!1===this.config.showScanGuide)return r.style.display="none",s.style.display="none",void(a.style.display="none");switch(this.currentScanMode){case t.EnumMRZScanMode.All:case t.EnumMRZScanMode.Passport:case t.EnumMRZScanMode.PassportAndTD1:case t.EnumMRZScanMode.PassportAndTD2:r.style.display="block",s.style.display="none",a.style.display="none",this.calculateScanRegion(t.EnumMRZDocumentType.Passport);break;case t.EnumMRZScanMode.TD1:case t.EnumMRZScanMode.TD1AndTD2:r.style.display="none",s.style.display="block",a.style.display="none",this.calculateScanRegion(t.EnumMRZDocumentType.TD1);break;case t.EnumMRZScanMode.TD2:r.style.display="none",s.style.display="none",a.style.display="block",this.calculateScanRegion(t.EnumMRZDocumentType.TD2)}}async openCamera(){try{this.showScannerLoadingOverlay("Initializing camera...");const{cameraEnhancer:t,cameraView:e}=this.resources,i=Ka(this.config.container);if(i.style.display="block",t.isOpen())t.isPaused()&&await t.resume();else{const n=e.getUIElement();n.parentElement||i.append(n),await t.open()}await t.setResolution({width:2560,height:1440}),!this.initializedDCE&&t.isOpen()&&await this.initializeElements(),window.addEventListener("resize",this.handleResize);const n=i.children[i.children.length-1];if(!(null==n?void 0:n.shadowRoot))throw new Error("Shadow root not found");n.shadowRoot.querySelector(".dce-mn-torch-off").style.display="none",n.shadowRoot.querySelector(".dce-mn-torch-on").style.display="none"}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"MRZ Scanner Open Camera Error"}};this.currentScanResolver(n)}finally{this.hideScannerLoadingOverlay()}}async closeCamera(t=!0){try{window.removeEventListener("resize",this.handleResize),this.resizeTimer&&(window.clearTimeout(this.resizeTimer),this.resizeTimer=null);const{cameraEnhancer:e,cameraView:i}=this.resources,n=Ka(this.config.container);n.style.display=t?"none":"block",(null==i?void 0:i.getUIElement().parentElement)&&n.removeChild(i.getUIElement()),e.close(),this.stopCapturing()}catch(t){let e=(null==t?void 0:t.message)||t;console.error(`Close Camera error: ${e}`)}}pauseCamera(){const{cameraEnhancer:t}=this.resources;t.pause()}stopCapturing(){const{cameraView:t,cvRouter:e}=this.resources;e.stopCapturing(),t.clearAllInnerDrawingItems()}async handleMRZResult(e){var i;if(this.capturedResultItems=e.items,!(e.items.length<=1))try{const{onResultUpdated:n}=this.resources,r=e.items.filter((t=>t.type===mt.CRIT_ORIGINAL_IMAGE))[0].imageData;r.toCanvas=()=>A(r),r.toBlob=async()=>await L("image/png",r),this.originalImageData=r;const s=null==e?void 0:e.textLineResultItems,a=null==e?void 0:e.parsedResultItems;if(s){this.isSoundFeedbackOn&&bs.beep();const e=(null===(i=null==s?void 0:s[0])||void 0===i?void 0:i.text)||"",r=ho(e,a[0]);this.closeCamera();const o={status:{code:t.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:r,imageData:!0,_imageData:this.originalImageData};null==n||n(o),this.currentScanResolver(o)}}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"Error capturing image"}};this.currentScanResolver(n)}}initializeScanModeManager(){const{mrzFormatType:e}=this.config;if(this.scanModeManager={[t.EnumMRZDocumentType.Passport]:!0,[t.EnumMRZDocumentType.TD1]:!0,[t.EnumMRZDocumentType.TD2]:!0},!e||Array.isArray(e)&&0===e.length)return;Object.keys(this.scanModeManager).forEach((t=>{this.scanModeManager[t]=!1}));(Array.isArray(e)?e:[e]).forEach((t=>{this.scanModeManager[t]=!0}))}getScanMode(){const e=Object.entries(this.scanModeManager).filter((([t,e])=>e)).map((([t])=>t)).sort().join(",");return{[t.EnumMRZDocumentType.Passport]:t.EnumMRZScanMode.Passport,[t.EnumMRZDocumentType.TD1]:t.EnumMRZScanMode.TD1,[t.EnumMRZDocumentType.TD2]:t.EnumMRZScanMode.TD2,[`${t.EnumMRZDocumentType.Passport},${t.EnumMRZDocumentType.TD1}`]:t.EnumMRZScanMode.PassportAndTD1,[`${t.EnumMRZDocumentType.Passport},${t.EnumMRZDocumentType.TD2}`]:t.EnumMRZScanMode.PassportAndTD2,[`${t.EnumMRZDocumentType.TD1},${t.EnumMRZDocumentType.TD2}`]:t.EnumMRZScanMode.TD1AndTD2,[`${t.EnumMRZDocumentType.Passport},${t.EnumMRZDocumentType.TD1},${t.EnumMRZDocumentType.TD2}`]:t.EnumMRZScanMode.All,"":t.EnumMRZScanMode.All}[e]}DCEShowToast(t,e=3e3){this.DCE_ELEMENTS.toast&&(this.DCE_ELEMENTS.toast.textContent=t,this.DCE_ELEMENTS.toast.style.display="",setTimeout((()=>{this.DCE_ELEMENTS.toast.style.display="none"}),e))}async startCapturing(){const{cvRouter:e,cameraEnhancer:i}=this.resources,n=this.config.utilizedTemplateNames[this.currentScanMode];try{if(!1!==this.config.showScanGuide){const t=await e.getSimplifiedSettings(n);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:50},{x:100,y:50},{x:100,y:100},{x:0,y:100}],await e.updateSettings(n,t)}await e.startCapturing(n),i.setPixelFormat(l.IPF_ABGR_8888)}catch(e){let i=(null==e?void 0:e.message)||e;console.error("Failed to start capturing:",i),this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:t.EnumResultStatus.RS_FAILED,message:"Failed to start capturing"}})}}async toggleScanDocType(e){try{if(this.scanModeManager[e]&&0===Object.entries(this.scanModeManager).filter((([t,i])=>i&&t!==e)).length)return console.warn("MRZ Scanner - At least one mode must be enabled"),void this.DCEShowToast("At least one mode must be enabled");this.scanModeManager[e]=!this.scanModeManager[e],this.currentScanMode=this.getScanMode(),this.stopCapturing(),await this.startCapturing(),this.toggleScanGuide(),this.DCE_ELEMENTS.td1ModeOption.classList.toggle("selected",this.scanModeManager[t.EnumMRZDocumentType.TD1]),this.DCE_ELEMENTS.td2ModeOption.classList.toggle("selected",this.scanModeManager[t.EnumMRZDocumentType.TD2]),this.DCE_ELEMENTS.passportModeOption.classList.toggle("selected",this.scanModeManager[t.EnumMRZDocumentType.Passport])}catch(e){let i=(null==e?void 0:e.message)||e;console.error("MRZ Scanner switch scan mode error: ",i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"MRZ Scanner switch scan mode error"}};this.currentScanResolver(n)}}async launch(){try{await this.initialize();const{cvRouter:t,cameraEnhancer:e}=this.resources;return new Promise((async t=>{this.currentScanResolver=t,await this.openCamera(),!this.initializedDCE&&e.isOpen()&&await this.initializeElements(),await this.startCapturing(),this.toggleScanGuide()}))}catch(e){let i=(null==e?void 0:e.message)||e;console.error("MRZ Scanner launch error: ",i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"MRZ Scanner launch error"}};this.currentScanResolver(n)}}}const fo={rescan:'\n\n\n \n\n\n\n\n\n\n\n',complete:'\n\n\n\n \n\n\n\n\n\n\n\n',failed:'\n \n \n \n\n',info:'\n\n \n \n \n\n'};class go{constructor(t,e,i){this.resources=t,this.config=e,this.scannerView=i,this.editedFields={}}async launch(){try{return Ka(this.config.container).textContent="",await this.initialize(),Ka(this.config.container).style.display="flex",new Promise((t=>{this.currentScanResultViewResolver=t}))}catch(t){let e=(null==t?void 0:t.message)||t;throw console.error(e),e}}async handleRescan(){var e;try{if(!this.scannerView)return void console.error("Scanner View not initialized");this.hideView();const i=await this.scannerView.launch();if((null===(e=null==i?void 0:i.status)||void 0===e?void 0:e.code)===t.EnumResultStatus.RS_FAILED)return void(this.currentScanResultViewResolver&&this.currentScanResultViewResolver(i));this.resources.onResultUpdated&&((null==i?void 0:i.status.code)===t.EnumResultStatus.RS_CANCELLED?this.resources.onResultUpdated(this.resources.result):(null==i?void 0:i.status.code)===t.EnumResultStatus.RS_SUCCESS&&this.resources.onResultUpdated(i)),this.dispose(!0),await this.initialize(),Ka(this.config.container).style.display="flex"}catch(e){throw console.error("Error in rescan handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:t.EnumResultStatus.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}async handleDone(){var e,i;try{(null===(e=this.resources.result)||void 0===e?void 0:e.data)&&!Qa(this.editedFields)&&(this.resources.result.data=Object.assign(Object.assign({},this.resources.result.data),this.editedFields),this.resources.onResultUpdated&&this.resources.onResultUpdated(this.resources.result)),(null===(i=this.config)||void 0===i?void 0:i.onDone)&&await this.config.onDone(this.resources.result),this.currentScanResultViewResolver&&this.resources.result&&this.currentScanResultViewResolver(this.resources.result),this.hideView(),this.dispose()}catch(e){throw console.error("Error in done handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:t.EnumResultStatus.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}createControls(){var t,e,i,n,r,s,a,o;const{toolbarButtonsConfig:l}=this.config;return function(t){$a("dynamsoft-mrz-controls-style","\n .dynamsoft-mrz-controls {\n display: flex;\n height: 6rem;\n background-color: #323234;\n align-items: center;\n font-size: 12px;\n font-family: Verdana;\n color: white;\n width: 100%;\n }\n\n .dynamsoft-mrz-control-btn {\n background-color: #323234;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n gap: 0.5rem;\n text-align: center;\n user-select: none;\n }\n\n .dynamsoft-mrz-control-btn.hide {\n display: none;\n }\n\n .dynamsoft-mrz-control-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n cursor: default;\n }\n\n .dynamsoft-mrz-control-icon-wrapper {\n flex: 0.75;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n min-height: 40px;\n }\n\n .dynamsoft-mrz-control-icon img,\n .dynamsoft-mrz-control-icon svg {\n width: 32px;\n height: 32px;\n fill: #fe8e14;\n }\n\n .dynamsoft-mrz-control-text {\n flex: 0.5;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-bottom: 0.5rem;\n }\n\n \n @media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-controls {\n flex-direction: column;\n height: 100%;\n width: 5rem;\n }\n\n .dynamsoft-mrz-control-text {\n padding: 0 0.5rem 0.5rem;\n }\n }\n");const e=document.createElement("div");return e.className="dynamsoft-mrz-controls",t.forEach((t=>{const i=document.createElement("div");i.className=`dynamsoft-mrz-control-btn ${null==t?void 0:t.className}`;const n=document.createElement("div");if(n.className="dynamsoft-mrz-control-icon-wrapper",(r=t.icon).trim().startsWith(""))n.innerHTML=t.icon;else{const e=document.createElement("img");e.src=t.icon,e.alt=t.label,e.width=24,e.height=24,n.appendChild(e)}var r;const s=document.createElement("div");s.className="dynamsoft-mrz-control-text",s.textContent=t.label,t.isDisabled&&i.classList.add("disabled"),t.isHidden&&i.classList.add("hide"),i.appendChild(n),i.appendChild(s),t.onClick&&!t.isDisabled&&i.addEventListener("click",t.onClick),e.appendChild(i)})),e}([{id:"dynamsoft-mrz-scanResult-rescan",icon:(null===(t=null==l?void 0:l.rescan)||void 0===t?void 0:t.icon)||fo.rescan,label:(null===(e=null==l?void 0:l.rescan)||void 0===e?void 0:e.label)||"Re-scan",onClick:()=>this.handleRescan(),className:`${(null===(i=null==l?void 0:l.rescan)||void 0===i?void 0:i.className)||""}`,isHidden:(null===(n=null==l?void 0:l.rescan)||void 0===n?void 0:n.isHidden)||!1,isDisabled:!this.scannerView},{id:"dynamsoft-mrz-scanResult-done",icon:(null===(r=null==l?void 0:l.done)||void 0===r?void 0:r.icon)||fo.complete,label:(null===(s=null==l?void 0:l.done)||void 0===s?void 0:s.label)||"Done",className:`${(null===(a=null==l?void 0:l.done)||void 0===a?void 0:a.className)||""}`,isHidden:(null===(o=null==l?void 0:l.done)||void 0===o?void 0:o.isHidden)||!1,onClick:()=>this.handleDone()}])}handleFieldEdit(e,i){if(e===t.EnumMRZData.DateOfBirth||e===t.EnumMRZData.DateOfExpiry)try{const[t,n,r]=i.split(/[\/\-\.]/);r&&n&&t&&(this.editedFields[e]={day:parseInt(r,10),month:parseInt(n,10),year:parseInt(t,10)})}catch(t){console.error("Error parsing date",t)}else this.editedFields[e]=i}createMRZDataDisplay(){var e;const i=(null===(e=this.resources.result)||void 0===e?void 0:e.data)||{},n=!!this.config.allowResultEditing,r=i.invalidFields||[],s=document.createElement("div");if(s.className="dynamsoft-mrz-data-container",Qa(i)){const t=document.createElement("div");return t.className="dynamsoft-mrz-data-row empty",t.innerText="No MRZ detected. Please try again.",s.appendChild(t),s}if(r.length>0){const t=document.createElement("div");t.className="dynamsoft-mrz-error-notification",t.innerHTML=`\n
${fo.failed}
\n
\n ${n?"Some fields require correction. Please review highlighted fields.":"Some fields contain invalid information. Please rescan the document."}\n
\n `,s.appendChild(t)}else if(0===r.length&&n){const t=document.createElement("div");t.className="dynamsoft-mrz-info-notification",t.innerHTML=`\n
${fo.info}
\n
\n Please review all fields to ensure the information is correct.\n
\n `,s.appendChild(t)}return Object.entries(i).forEach((([e,i])=>{var a;if(e===t.EnumMRZData.InvalidFields||!i)return;if(e===t.EnumMRZData.MRZText&&!1===(null===(a=this.config)||void 0===a?void 0:a.showMRZText))return;const o=document.createElement("div");o.className="dynamsoft-mrz-data-row";const l=r.includes(e);l&&o.classList.add("invalid-field");const h=[t.EnumMRZData.MRZText,t.EnumMRZData.DocumentType,t.EnumMRZData.IssuingStateRaw,t.EnumMRZData.NationalityRaw],c=document.createElement("span");if(c.className="dynamsoft-mrz-data-label",c.innerText=so[e]||e,l){const t=document.createElement("span");if(t.className="dynamsoft-mrz-error-icon",t.innerHTML=fo.failed,c.appendChild(t),n){const t=document.createElement("span");t.className="dynamsoft-mrz-error-hint",t.textContent="Please correct this field",c.appendChild(t)}}const u=document.createElement("div");if(u.className="dynamsoft-mrz-data-value",n&&!h.includes(e)){const n=document.createElement("input");n.className="dynamsoft-mrz-data-input",l&&n.classList.add("invalid"),e===t.EnumMRZData.DateOfBirth||e===t.EnumMRZData.DateOfExpiry?(n.value=oo(i),n.setAttribute("placeholder","YYYY-MM-DD")):n.value=i,n.addEventListener("input",(t=>{if(this.handleFieldEdit(e,t.target.value),l){n.classList.remove("invalid"),o.classList.remove("invalid-field"),this.editedFields.invalidFields||(this.editedFields.invalidFields=[...r]);const t=this.editedFields.invalidFields.indexOf(e);t>-1&&this.editedFields.invalidFields.splice(t,1)}})),u.appendChild(n)}else e===t.EnumMRZData.MRZText?(u.classList.add("code"),u.innerText=i):e===t.EnumMRZData.DateOfBirth||e===t.EnumMRZData.DateOfExpiry?u.innerText=oo(i):u.innerText=i,l&&u.classList.add("invalid-value");o.appendChild(c),o.appendChild(u),s.appendChild(o)})),s}async initialize(){try{if(!this.resources.result)throw Error("Captured image is missing. Please capture an image first!");if(!this.config.container)throw new Error("Please create a Scan Result View Container element");$a("dynamsoft-mrz-result-view-style",mo);const t=document.createElement("div");if(t.className="dynamsoft-mrz-result-view-container",!1!==this.config.showOriginalImage){const e=this.resources.result.originalImageResult,i=document.createElement("div");let n;i.className="dynamsoft-mrz-result-view-image-container",(null==e?void 0:e.toCanvas)&&(n=null==e?void 0:e.toCanvas()),Object.assign(n.style,{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}),i.appendChild(n),t.appendChild(i)}const e=this.createMRZDataDisplay();t.appendChild(e);const i=this.createControls();t.appendChild(i),Ka(this.config.container).appendChild(t)}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e)}}hideView(){Ka(this.config.container).style.display="none"}dispose(t=!1){Ka(this.config.container).textContent="",t||(this.currentScanResultViewResolver=void 0)}}const mo="\n .dynamsoft-mrz-result-view-container {\n display: flex;\n width: 100%;\n height: 100%;\n background-color:#575757;\n font-size: 12px;\n flex-direction: column;\n align-items: center;\n }\n\n .dynamsoft-mrz-result-view-image-container {\n width: 100%;\n height: 200px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #323234;\n }\n\n \n.dynamsoft-mrz-data-container {\n font-size: 16px;\n font-family: Verdana;\n color: white;\n overflow: auto;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 1rem 0;\n}\n\n.dynamsoft-mrz-data-row {\n padding: 0.5rem 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n transition: background-color 0.3s ease;\n}\n\n.dynamsoft-mrz-data-row.invalid-field {\n background-color: rgba(231, 76, 60, 0.1);\n border-left: 3px solid #e74c3c;\n padding-left: calc(2rem - 3px);\n}\n\n.dynamsoft-mrz-data-label {\n color: #aaa;\n display: flex;\n gap: 0.5rem;\n align-items: end;\n flex-wrap: wrap;\n}\n\n.dynamsoft-mrz-error-notification,\n.dynamsoft-mrz-info-notification {\n color: white;\n padding: 1rem;\n margin: 0.5rem 2rem;\n border-radius: 4px;\n display: flex;\n align-items: center;\n gap: 1rem;\n text-align: start;\n}\n\n.dynamsoft-mrz-error-notification {\n background-color: rgba(231, 76, 60, 0.2);\n}\n\n.dynamsoft-mrz-info-notification {\n background-color: rgba(196, 231, 60, 0.2);\n}\n\n.dynamsoft-mrz-edit-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #aaa;\n}\n\n.dynamsoft-mrz-error-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-info-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.dynamsoft-mrz-info-message,\n.dynamsoft-mrz-error-message {\n flex: 1;\n}\n\n.dynamsoft-mrz-error-hint {\n font-size: 0.8rem;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-value {\n word-wrap: break-word;\n text-align: start;\n}\n\n.dynamsoft-mrz-data-value.code {\n font-family: monospace;\n}\n\n.dynamsoft-mrz-data-value.invalid-value {\n color: #e74c3c;\n text-decoration: wavy underline #e74c3c;\n text-decoration-skip-ink: none;\n}\n\n.dynamsoft-mrz-data-input {\n width: 100%;\n padding: 5px;\n background-color: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.3);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n transition: all 0.3s ease;\n}\n\n.dynamsoft-mrz-data-input.invalid {\n background-color: rgba(231, 76, 60, 0.1);\n border-color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-input:focus {\n background-color: rgba(255, 255, 255, 0.2);\n border-color: #fe8e14;\n outline: none;\n}\n\n@media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-result-view-container {\n flex-direction: row;\n }\n\n .dynamsoft-mrz-result-view-image-container{\n flex: 1;\n height: 100%;\n }\n\n .dynamsoft-mrz-data-container{\n flex: 1;\n }\n\n .dynamsoft-mrz-data-row:first-of-type {\n padding-top: 2rem;\n }\n\n .dynamsoft-mrz-data-row:last-of-type {\n padding-bottom: 2rem;\n }\n\n .dynamsoft-mrz-data-row.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding-top: 0;\n padding-bottom: 0;\n }\n}\n",po={rootDirectory:"https://cdn.jsdelivr.net/npm/"};class _o{showLoadingOverlay(t){var e,i;const n=Ka(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||Ka(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container);this.loadingScreen=io(n,{message:t}),n.style.display="block",n.style.position="relative"}hideLoadingOverlay(t=!1){var e,i,n;const r=Ka(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||Ka(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container);this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,r.style.display="none",t&&(null===(n=this.config)||void 0===n?void 0:n.container)&&(Ka(this.config.container).style.display="none"))}constructor(t){this.config=t,this.resources={},this.isInitialized=!1,this.isCapturing=!1,this.loadingScreen=null}async initialize(){if(this.isInitialized)return{resources:this.resources,components:{scannerView:this.scannerView,resultView:this.resultView}};try{if(!this.initializeMRZScannerConfig())return console.error("Failed to initialize mrz scanner config"),{resources:this.resources,components:{}};$a("dynamsoft-mrz-loading-screen-style",no),this.showLoadingOverlay("Loading...");if(!await this.initializeDCVResources())return this.hideLoadingOverlay(!0),console.error("Failed to initialize DCV resources"),{resources:this.resources,components:{}};this.resources.onResultUpdated=t=>{this.resources.result=t};const t={};return this.config.scannerViewConfig&&(this.scannerView=new uo(this.resources,this.config.scannerViewConfig),t.scannerView=this.scannerView,await this.scannerView.initialize()),this.config.resultViewConfig&&(this.resultView=new go(this.resources,this.config.resultViewConfig,this.scannerView),t.resultView=this.resultView),this.isInitialized=!0,{resources:this.resources,components:t}}catch(t){this.isInitialized=!1;const e=`Initialization Failed: ${(null==t?void 0:t.message)||t}`;return console.error(e),{resources:this.resources,components:{}}}finally{this.hideLoadingOverlay(!0)}}async initializeDCVResources(){var t,e,i;try{return gt.engineResourcePaths=Qa(null===(t=this.config)||void 0===t?void 0:t.engineResourcePaths)?po:this.config.engineResourcePaths,Zt._onAuthMessage=t=>t.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=mrz&deploymenttype=web)"),await Zt.initLicense((null===(e=this.config)||void 0===e?void 0:e.license)||"",{executeNow:!0}),gt.loadWasm(["DLR","DCP"]),ta.loadSpec("MRTD_TD3_PASSPORT"),ta.loadSpec("MRTD_TD1_ID"),ta.loadSpec("MRTD_TD2_ID"),ca.loadRecognitionData("MRZ"),this.resources.cameraView=await An.createInstance(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.cameraEnhancerUIPath),this.resources.cameraEnhancer=await Rs.createInstance(this.resources.cameraView),this.resources.cvRouter=await Ae.createInstance(),!0}catch(t){let e=(null==t?void 0:t.message)||t;if(null==e?void 0:e.toLowerCase().includes("license")){const t="The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.";alert(t),console.error(t)}else{const t=`Resource Initialization Failed: ${e}`;alert(t),console.error(t)}return!1}}shouldCreateDefaultContainer(){var t,e;const i=!this.config.container,n=!((null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container));return i&&n}createDefaultMRZScannerContainer(){const t=document.createElement("div");return t.className="mrz-scanner-main-container",Object.assign(t.style,{height:"100dvh",width:"100%",position:"absolute",left:"0",top:"0",zIndex:"999"}),document.body.append(t),t}checkForTemporaryLicense(t){return!(null==t?void 0:t.length)||(null==t?void 0:t.startsWith("A"))||(null==t?void 0:t.startsWith("L"))||(null==t?void 0:t.startsWith("P"))||(null==t?void 0:t.startsWith("Y"))?"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9":t}validateViewConfigs(){var t,e,i,n,r,s,a,o;if(!this.config.container){if((null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)&&this.config.showResultView&&!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container)){const t="MRZResultView container is required when showResultView is true";return alert(t),console.error(t),!1}if(!(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.container)&&(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container)&&!this.resources.result){const t="Result is needed to create MRZResultView without a scanner view";return alert(t),console.error(t),!1}}try{if(this.config.container&&!Ka(this.config.container)){const t="Invalid main container reference";return alert(t),console.error(t),!1}if((null===(r=this.config.scannerViewConfig)||void 0===r?void 0:r.container)&&!Ka(null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.container)){const t="Invalid scanner view container reference";return alert(t),console.error(t),!1}if((null===(a=this.config.resultViewConfig)||void 0===a?void 0:a.container)&&!Ka(null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)){const t="Invalid result view container reference";return alert(t),console.error(t),!1}}catch(t){const e=`Error accessing container references: ${t.message}`;return alert(e),console.error(e),!1}return!0}showResultView(){var t,e;return!1!==this.config.showResultView&&(this.config.container?!(void 0!==this.config.showResultView||!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container)&&!this.config.container)||!!this.config.showResultView:this.config.showResultView&&!!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container))}initializeMRZScannerConfig(){var e,i,n,r,s,a,o;this.config=null!==(e=this.config)&&void 0!==e?e:{};if(!this.validateViewConfigs())return!1;this.shouldCreateDefaultContainer()?this.config.container=this.createDefaultMRZScannerContainer():this.config.container&&(this.config.container=Ka(this.config.container));const l=this.config.container?this.createViewContainers(Ka(this.config.container)):{},h={license:this.checkForTemporaryLicense(this.config.license),utilizedTemplateNames:Object.fromEntries(Object.values(t.EnumMRZScanMode).map((t=>{var e;return[t,(null===(e=this.config.utilizedTemplateNames)||void 0===e?void 0:e[t])||qa[t]]}))),templateFilePath:(null===(i=this.config)||void 0===i?void 0:i.templateFilePath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.template.json"},c=Object.assign(Object.assign({},this.config.scannerViewConfig),{container:l[t.EnumMRZScannerViews.Scanner]||Ka(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)||null,cameraEnhancerUIPath:(null===(r=this.config.scannerViewConfig)||void 0===r?void 0:r.cameraEnhancerUIPath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.ui.html",templateFilePath:h.templateFilePath,utilizedTemplateNames:h.utilizedTemplateNames,enableMultiFrameCrossFilter:null===(a=null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.enableMultiFrameCrossFilter)||void 0===a||a,mrzFormatType:this.config.mrzFormatType}),u=this.showResultView()?Object.assign(Object.assign({},this.config.resultViewConfig),{container:l[t.EnumMRZScannerViews.Result]||Ka(null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)||null}):void 0;return Object.assign(this.config,Object.assign(Object.assign({},h),{scannerViewConfig:c,resultViewConfig:u})),!0}createViewContainers(e){e.textContent="";const i=[t.EnumMRZScannerViews.Scanner];return this.showResultView()&&i.push(t.EnumMRZScannerViews.Result),i.reduce(((t,i)=>{const n=document.createElement("div");return n.className=`mrz-scanner-${i}-view-container`,Object.assign(n.style,{height:"100%",width:"100%",display:"none",position:"relative"}),e.append(n),t[i]=n,t}),{})}dispose(){var t,e;this.resultView&&(this.resultView.dispose(),this.resultView=null),this.scannerView=null,this.resources.cameraEnhancer&&(this.resources.cameraEnhancer.dispose(),this.resources.cameraEnhancer=null),this.resources.cameraView&&(this.resources.cameraView.dispose(),this.resources.cameraView=null),this.resources.cvRouter&&(this.resources.cvRouter.dispose(),this.resources.cvRouter=null),this.resources.result=null,this.resources.onResultUpdated=null;const i=t=>{const e=Ka(t);e&&(e.style.display="none",e.textContent="")};i(this.config.container),i(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container),i(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container),this.isInitialized=!1}async processUploadedFile(e){var i,n,r,s;try{this.showLoadingOverlay("Processing File...");const{cvRouter:a}=this.resources,o=null===(i=this.config.utilizedTemplateNames)||void 0===i?void 0:i.all,l=await a.getSimplifiedSettings(o);l.roiMeasuredInPercentage=!0,l.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await a.updateSettings(o,l);const h=await a.capture(e,o),c=h.items,u=c.filter((t=>t.type===mt.CRIT_ORIGINAL_IMAGE))[0].imageData;u.toCanvas=()=>A(u),u.toBlob=async()=>await L("image/png",u);const d=null==h?void 0:h.textLineResultItems,f=null==h?void 0:h.parsedResultItems;let g={};if(null==d?void 0:d.length){const t=(null===(n=d[0])||void 0===n?void 0:n.text)||"";g=ho(t,f[0])}const m={status:{code:t.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:u,data:g,imageData:!0,_imageData:u};null===(s=(r=this.resources).onResultUpdated)||void 0===s||s.call(r,m)}catch(e){return console.error("Failed to process uploaded file:",e),{status:{code:t.EnumResultStatus.RS_FAILED,message:`Failed to process image: ${e.message||e}`}}}finally{this.hideLoadingOverlay(!1)}}async launch(e){if(this.isCapturing)throw new Error("Capture session already in progress");try{this.isCapturing=!0;const{components:i}=await this.initialize();if(Qa(i))throw new Error("MRZ Scanner initialization failed.");if(this.config.container&&(Ka(this.config.container).style.display="block"),e&&(i.scannerView=null,await this.processUploadedFile(e)),!i.scannerView&&this.resources.result&&i.resultView)return await i.resultView.launch();if(!i.scannerView&&!this.resources.result)throw new Error("Scanner view is required when no previous result exists");if(i.scannerView){const e=await i.scannerView.launch();if((null==e?void 0:e.status.code)!==t.EnumResultStatus.RS_SUCCESS)return{status:{code:null==e?void 0:e.status.code,message:(null==e?void 0:e.status.message)||"Failed to capture image"}};if(i.resultView)return await i.resultView.launch()}return this.resources.result}catch(e){return alert((null==e?void 0:e.message)||e),console.error((null==e?void 0:e.message)||e),{status:{code:t.EnumResultStatus.RS_FAILED,message:(null==e?void 0:e.message)||e}}}finally{this.isCapturing=!1,this.dispose()}}}const vo={MRZScanner:_o,MRZScannerView:uo,MRZResultView:go};t.CVR=Ne,t.Core=xt,t.DCE=Us,t.DCP=ea,t.DEFAULT_TEMPLATE_NAMES=qa,t.DLR=fa,t.DynamsoftMRZScanner=vo,t.License=Jt,t.MRZDataLabel=so,t.MRZResultView=go,t.MRZScanner=_o,t.MRZScannerView=uo,t.Utility=Za,t.displayMRZDate=oo})); +!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{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=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=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;t0!==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:10};return await this._captureInWorker(n,e)}async _captureVideo(t,e){if(t.crossOrigin&&"anonymous"!=t.crossOrigin)throw"cors";let i,n,r=t.videoWidth,s=t.videoHeight,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),await this._captureCanvas(o,e)}async _captureInWorker(t,e){const{bytes:i,width:n,height:r,stride:s,format:a}=t;let o=wt();const l=R(Dt.engineResourcePaths),h=new Bt;return Et[o]=async e=>{if(e.success){const i=Date.now();Te._onLog&&(Te._onLog(`get result time from worker: ${i}`),Te._onLog("worker to main time consume: "+(i-e.workerReturnMsgTime)));try{const i=e.captureResult;0!==i.errorCode&&Ce({message:i.errorString,errorCode:i.errorCode,rj:h.reject}),t.bytes=e.bytes;for(let e of i.items)0!==Ft(this,le,"f")&&we(e,Ft(this,le,"f")),e.type===Q.CRIT_ORIGINAL_IMAGE?e.imageData=t:[Q.CRIT_DESKEWED_IMAGE,Q.CRIT_ENHANCED_IMAGE].includes(e.type)?xt.ddn&&xt.ddn.handleDeskewedAndEnhancedImageResultItem(e):e.type===Q.CRIT_PARSED_RESULT&&xt.dcp&&xt.dcp.handleParsedResultItem(e);const n=i.processedDocumentResult;if(n){if(n.deskewedImageResultItems)for(let t=0;t{let n=wt();Et[n]=async n=>{if(n.success){const r=JSON.parse(n.response);0!==r.errorCode&&Ce({message:r.errorString?r.errorString:"Init Settings Failed.",rj:i,errorCode:r.errorCode});const s=JSON.parse(t);return this._currentSettings=s,this._isOutputOriginalImage=1===this._currentSettings.CaptureVisionTemplates[0].OutputOriginalImage,Te._defaultTemplate=this._currentSettings.CaptureVisionTemplates[0].Name,e(r)}Ce({message:n.message,rj:i,stack:n.stack})},vt.postMessage({type:"cvr_initSettings",id:n,instanceID:this._instanceID,body:{settings:t}})}))):console.error("Invalid template.")}async outputSettings(t,e){return Ee(this),await new Promise(((i,n)=>{let r=wt();Et[r]=async t=>{if(t.success){const e=JSON.parse(t.response);return 0!==e.errorCode&&Ce({message:e.errorString,rj:n,errorCode:e.errorCode}),i(JSON.parse(e.data))}Ce({message:t.message,rj:n,stack:t.stack})},vt.postMessage({type:"cvr_outputSettings",id:r,instanceID:this._instanceID,body:{templateName:t||"*",includeDefaultValues:!!e}})}))}async outputSettingsToFile(t,e,i,n){const r=await this.outputSettings(t,n),s=new Blob([JSON.stringify(r,null,2,(function(t,e){return e instanceof Array?JSON.stringify(e):e}),2)],{type:"application/json"});if(i){const t=document.createElement("a");t.href=URL.createObjectURL(s),e.endsWith(".json")&&(e=e.replace(".json","")),t.download=`${e}.json`,t.onclick=()=>{setTimeout((()=>{URL.revokeObjectURL(t.href)}),500)},t.click()}return s}async getTemplateNames(){return Ee(this),await new Promise(((t,e)=>{let i=wt();Et[i]=async i=>{if(i.success){const n=JSON.parse(i.response);return 0!==n.errorCode&&Ce({message:n.errorString,rj:e,errorCode:n.errorCode}),t(JSON.parse(n.data))}Ce({message:i.message,rj:e,stack:i.stack})},vt.postMessage({type:"cvr_getTemplateNames",id:i,instanceID:this._instanceID})}))}async getSimplifiedSettings(t){return Ee(this),t||(t=this._currentSettings.CaptureVisionTemplates[0].Name),await new Promise(((e,i)=>{let n=wt();Et[n]=async t=>{if(t.success){const n=JSON.parse(t.response);0!==n.errorCode&&Ce({message:n.errorString,rj:i,errorCode:n.errorCode});const r=JSON.parse(n.data,((t,e)=>"barcodeFormatIds"===t?BigInt(e):e));return r.minImageCaptureInterval=this._minImageCaptureInterval,e(r)}Ce({message:t.message,rj:i,stack:t.stack})},vt.postMessage({type:"cvr_getSimplifiedSettings",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async updateSettings(t,e){return Ee(this),t||(t=this._currentSettings.CaptureVisionTemplates[0].Name),await new Promise(((i,n)=>{let r=wt();Et[r]=async t=>{if(t.success){const r=JSON.parse(t.response);return e.minImageCaptureInterval&&e.minImageCaptureInterval>=-1&&(this._minImageCaptureInterval=e.minImageCaptureInterval),this._isOutputOriginalImage=t.isOutputOriginalImage,0!==r.errorCode&&Ce({message:r.errorString?r.errorString:"Update Settings Failed.",rj:n,errorCode:r.errorCode}),this._currentSettings=await this.outputSettings("*"),i(r)}Ce({message:t.message,rj:n,stack:t.stack})},vt.postMessage({type:"cvr_updateSettings",id:r,instanceID:this._instanceID,body:{settings:e,templateName:t}})}))}async resetSettings(){return Ee(this),await new Promise(((t,e)=>{let i=wt();Et[i]=async i=>{if(i.success){const n=JSON.parse(i.response);return 0!==n.errorCode&&Ce({message:n.errorString?n.errorString:"Reset Settings Failed.",rj:e,errorCode:n.errorCode}),this._currentSettings=await this.outputSettings("*"),t(n)}Ce({message:i.message,rj:e,stack:i.stack})},vt.postMessage({type:"cvr_resetSettings",id:i,instanceID:this._instanceID})}))}getBufferedItemsManager(){return Ft(this,re,"f")||Pt(this,re,new jt(this)),Ft(this,re,"f")}getIntermediateResultManager(){if(Ee(this),!Ft(this,ce,"f")&&0!==Dt.bSupportIRTModule)throw new Error("The current license does not support the use of intermediate results.");return Ft(this,ne,"f")||Pt(this,ne,new Gt(this)),Ft(this,ne,"f")}async parseRequiredResources(t){return Ee(this),await new Promise(((e,i)=>{let n=wt();Et[n]=async t=>{if(t.success)return e(JSON.parse(t.resources));Ce({message:t.message,rj:i,stack:t.stack})},vt.postMessage({type:"cvr_parseRequiredResources",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async dispose(){Ee(this),Ft(this,ie,"f")&&this.stopCapturing(),Pt(this,te,null),Ft(this,se,"f").clear(),Ft(this,ae,"f").clear(),Ft(this,oe,"f").clear(),Ft(this,ne,"f")._intermediateResultReceiverSet.clear(),Pt(this,de,!0);let t=wt();Et[t]=t=>{t.success||Ce({message:t.message,stack:t.stack,isShouleThrow:!0})},vt.postMessage({type:"cvr_dispose",id:t,instanceID:this._instanceID})}_getInternalData(){return{isa:Ft(this,te,"f"),promiseStartScan:Ft(this,ie,"f"),intermediateResultManager:Ft(this,ne,"f"),bufferdItemsManager:Ft(this,re,"f"),resultReceiverSet:Ft(this,se,"f"),isaStateListenerSet:Ft(this,ae,"f"),resultFilterSet:Ft(this,oe,"f"),compressRate:Ft(this,le,"f"),canvas:Ft(this,ee,"f"),isScanner:Ft(this,he,"f"),innerUseTag:Ft(this,ce,"f"),isDestroyed:Ft(this,de,"f")}}async _getWasmFilterState(){return await new Promise(((t,e)=>{let i=wt();Et[i]=async i=>{if(i.success){const e=JSON.parse(i.response);return t(e)}Ce({message:i.message,rj:e,stack:i.stack})},vt.postMessage({type:"cvr_getWasmFilterState",id:i,instanceID:this._instanceID})}))}}te=new WeakMap,ee=new WeakMap,ie=new WeakMap,ne=new WeakMap,re=new WeakMap,se=new WeakMap,ae=new WeakMap,oe=new WeakMap,le=new WeakMap,he=new WeakMap,ce=new WeakMap,de=new WeakMap,ue=new WeakMap,fe=new WeakMap,Qt=new WeakSet,ge=function(t,e){const i=t.intermediateResult;if(i){let t=0;for(let n of Ft(this,ne,"f")._intermediateResultReceiverSet){t++;for(let r of i){if(["onTaskResultsReceived","onTargetROIResultsReceived"].includes(r.info.callbackName)){for(let t of r.intermediateResultUnits)t.originalImageTag=e.tag?e.tag:null;n[r.info.callbackName]&&n[r.info.callbackName]({intermediateResultUnits:r.intermediateResultUnits},r.info)}else n[r.info.callbackName]&&n[r.info.callbackName](r.result,r.info);t===Ft(this,ne,"f")._intermediateResultReceiverSet.size&&delete r.info.callbackName}}}t&&t.hasOwnProperty("intermediateResult")&&delete t.intermediateResult},me=function(t,e){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)},pe=async function(t){return Ee(this),await new Promise(((e,i)=>{let n=wt();Et[n]=async t=>{if(t.success)return e(t.result);Ce({message:t.message,rj:i,stack:t.stack})},vt.postMessage({type:"cvr_enableResultCrossVerification",id:n,instanceID:this._instanceID,body:{verificationEnabled:t}})}))},_e=async function(t){return Ee(this),await new Promise(((e,i)=>{let n=wt();Et[n]=async t=>{if(t.success)return e(t.result);Ce({message:t.message,rj:i,stack:t.stack})},vt.postMessage({type:"cvr_enableResultDeduplication",id:n,instanceID:this._instanceID,body:{duplicateFilterEnabled:t}})}))},ve=async function(t){return Ee(this),await new Promise(((e,i)=>{let n=wt();Et[n]=async t=>{if(t.success)return e(t.result);Ce({message:t.message,rj:i,stack:t.stack})},vt.postMessage({type:"cvr_setDuplicateForgetTime",id:n,instanceID:this._instanceID,body:{duplicateForgetTime:t}})}))},ye=async function(){let t=wt();const e=new Bt;return Et[t]=async t=>{if(t.success)return e.resolve();Ce({message:t.message,rj:e.reject,stack:t.stack})},vt.postMessage({type:"cvr_clearVerifyList",id:t,instanceID:this._instanceID}),e},Te._defaultTemplate="Default";class be{constructor(){this.onCapturedResultReceived=null,this.onOriginalImageResultReceived=null}}var Ie;!function(t){t.PT_DEFAULT="Default",t.PT_READ_BARCODES="ReadBarcodes_Default",t.PT_RECOGNIZE_TEXT_LINES="RecognizeTextLines_Default",t.PT_DETECT_DOCUMENT_BOUNDARIES="DetectDocumentBoundaries_Default",t.PT_DETECT_AND_NORMALIZE_DOCUMENT="DetectAndNormalizeDocument_Default",t.PT_NORMALIZE_DOCUMENT="NormalizeDocument_Default",t.PT_READ_BARCODES_SPEED_FIRST="ReadBarcodes_SpeedFirst",t.PT_READ_BARCODES_READ_RATE_FIRST="ReadBarcodes_ReadRateFirst",t.PT_READ_BARCODES_BALANCE="ReadBarcodes_Balance",t.PT_READ_SINGLE_BARCODE="ReadSingleBarcode",t.PT_READ_DENSE_BARCODES="ReadDenseBarcodes",t.PT_READ_DISTANT_BARCODES="ReadDistantBarcodes",t.PT_RECOGNIZE_NUMBERS="RecognizeNumbers",t.PT_RECOGNIZE_LETTERS="RecognizeLetters",t.PT_RECOGNIZE_NUMBERS_AND_LETTERS="RecognizeNumbersAndLetters",t.PT_RECOGNIZE_NUMBERS_AND_UPPERCASE_LETTERS="RecognizeNumbersAndUppercaseLetters",t.PT_RECOGNIZE_UPPERCASE_LETTERS="RecognizeUppercaseLetters"}(Ie||(Ie={}));const xe="undefined"==typeof self,Re=xe?{}:self,Oe="function"==typeof importScripts,De=(()=>{if(!Oe){if(!xe&&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"./"}})(),Ae=t=>t&&"object"==typeof t&&"function"==typeof t.then,Me=(async()=>{})().constructor;let Le=class extends Me{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,Ae(t)?e=t:"function"==typeof t&&(e=new Me(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&&(Ae(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}};const Fe=" is not allowed to change after `createInstance` or `loadWasm` is called.",Pe=!xe&&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"))||"",ke=(t,e)=>{const i=t;if(i._license!==e){if(!i._pLoad.isEmpty)throw new Error("`license`"+Fe);i._license=e}};!xe&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword");const Ne=t=>{if(null==t)t=[];else{t=t instanceof Array?[...t]:[t];for(let e=0;e{e=Ne(e);const i=t;if(i._licenseServer!==e){if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+Fe);i._licenseServer=e}},je=(t,e)=>{e=e||"";const i=t;if(i._deviceFriendlyName!==e){if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+Fe);i._deviceFriendlyName=e}};let Ve,Ue,Ge,We,Ye;"undefined"!=typeof navigator&&(Ve=navigator,Ue=Ve.userAgent,Ge=Ve.platform,We=Ve.mediaDevices),function(){if(!xe){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:Ve.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:Ge,search:"Win"},Mac:{str:Ge},Linux:{str:Ge}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||Ue,a=r.search||e,o=r.verStr||Ue,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||Ue,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=Ue.indexOf("Windows NT")&&(r="HarmonyOS"),Ye={browser:i,version:n,OS:r}}xe&&(Ye={browser:"ssr",version:0,OS:"ssr"})}(),We&&We.getUserMedia,"Chrome"===Ye.browser&&Ye.version>66||"Safari"===Ye.browser&&Ye.version>13||"OPR"===Ye.browser&&Ye.version>43||"Edge"===Ye.browser&&Ye.version;const He=()=>(Dt.loadWasm(),_t("dynamsoft_inited",(async()=>{let{lt:t,l:e,ls:i,sp:n,rmk:r,cv:s}=((t,e=!1)=>{const i=Xe;if(i._pLoad.isEmpty){let n,r,s,a=i._license||"",o=JSON.parse(JSON.stringify(i._licenseServer)),l=i._sessionPassword,h=0;if(a.startsWith("t")||a.startsWith("f"))h=0;else if(0===a.length||a.startsWith("P")||a.startsWith("L")||a.startsWith("Y")||a.startsWith("A"))h=1;else{h=2;const e=a.indexOf(":");-1!=e&&(a=a.substring(e+1));const i=a.indexOf("?");if(-1!=i&&(r=a.substring(i+1),a=a.substring(0,i)),a.startsWith("DLC2"))h=0;else{if(a.startsWith("DLS2")){let e;try{let t=a.substring(4);t=atob(t),e=JSON.parse(t)}catch(t){throw new Error("Format Error: The license string you specified is invalid, please check to make sure it is correct.")}if(a=e.handshakeCode?e.handshakeCode:e.organizationID?e.organizationID:"","number"==typeof a&&(a=JSON.stringify(a)),0===o.length){let t=[];e.mainServerURL&&(t[0]=e.mainServerURL),e.standbyServerURL&&(t[1]=e.standbyServerURL),o=Ne(t)}!l&&e.sessionPassword&&(l=e.sessionPassword),n=e.remark}a&&"200001"!==a&&!a.startsWith("200001-")||(h=1)}}if(h&&(e||(Re.crypto||(s="Please upgrade your browser to support online key."),Re.crypto.subtle||(s="Require https to use online key in this browser."))),s)throw new Error(s);return 1===h&&(a="",console.warn("Applying for a public trial license ...")),{lt:h,l:a,ls:o,sp:l,rmk:n,cv:r}}throw new Error("Can't preprocess license again"+Fe)})(),a=new Le;Xe._pLoad.task=a,(async()=>{try{await Xe._pLoad}catch(t){}})();let o=wt();Et[o]=e=>{if(e.message&&Xe._onAuthMessage){let t=Xe._onAuthMessage(e.message);null!=t&&(e.message=t)}let i,n=!1;if(1===t&&(n=!0),e.success?(Ct&&Ct("init license success"),e.message&&console.warn(e.message),Dt._bSupportIRTModule=e.bSupportIRTModule,Dt._bSupportDce4Module=e.bSupportDce4Module,Xe.bPassValidation=!0,[0,-10076].includes(e.initLicenseInfo.errorCode)?[-10076].includes(e.initLicenseInfo.errorCode)&&console.warn(e.initLicenseInfo.errorString):a.reject(new Error(e.initLicenseInfo.errorString))):(i=Error(e.message),e.stack&&(i.stack=e.stack),e.ltsErrorCode&&(i.ltsErrorCode=e.ltsErrorCode),n||111==e.ltsErrorCode&&-1!=e.message.toLowerCase().indexOf("trial license")&&(n=!0)),n){const t=R(Dt.engineResourcePaths);(async(t,e,i)=>{if(!t._bNeverShowDialog)try{let n=await fetch(t.engineResourcePath+"dls.license.dialog.html");if(!n.ok)throw Error("Get license dialog fail. Network Error: "+n.statusText);let r=await n.text();if(!r.trim().startsWith("<"))throw Error("Get license dialog fail. Can't get valid HTMLElement.");let s=document.createElement("div");s.insertAdjacentHTML("beforeend",r);let a=[];for(let t=0;t{if(t==e.target){o.remove();for(let t of a)t.remove()}}));else if(!h&&t.classList.contains("dls-license-icon-close"))h=t,t.addEventListener("click",(()=>{o.remove();for(let t of a)t.remove()}));else if(!c&&t.classList.contains("dls-license-icon-error"))c=t,"error"!=e&&t.remove();else if(!d&&t.classList.contains("dls-license-icon-warn"))d=t,"warn"!=e&&t.remove();else if(!u&&t.classList.contains("dls-license-msg-content")){u=t;let e=i;for(;e;){let i=e.indexOf("["),n=e.indexOf("]",i),r=e.indexOf("(",n),s=e.indexOf(")",r);if(-1==i||-1==n||-1==r||-1==s){t.appendChild(new Text(e));break}i>0&&t.appendChild(new Text(e.substring(0,i)));let a=document.createElement("a"),o=e.substring(i+1,n);a.innerText=o;let l=e.substring(r+1,s);a.setAttribute("href",l),a.setAttribute("target","_blank"),t.appendChild(a),e=e.substring(s+1)}}document.body.appendChild(o)}catch(e){t._onLog&&t._onLog(e.message||e)}})({_bNeverShowDialog:Xe._bNeverShowDialog,engineResourcePath:t.dcvData+"ui/",_onLog:Ct},e.success?"warn":"error",e.message)}e.success?a.resolve(void 0):a.reject(i)},await pt("core"),vt.postMessage({type:"license_dynamsoft",body:{v:"4.0.30-dev-20250604160433",brtk:!!t,bptk:1===t,l:e,os:Ye,fn:Xe.deviceFriendlyName,ls:i,sp:n,rmk:r,cv:s},id:o}),Xe.bCallInitLicense=!0,await a})));let ze;xt.license={},xt.license.dynamsoft=He,xt.license.getAR=async()=>{{let t=mt.dynamsoft_inited;t&&t.isRejected&&await t}return vt?new Promise(((t,e)=>{let i=wt();Et[i]=async i=>{if(i.success){delete i.success;{let t=Xe.license;t&&(t.startsWith("t")||t.startsWith("f"))&&(i.pk=t)}if(Object.keys(i).length){if(i.lem){let t=Error(i.lem);t.ltsErrorCode=i.lec,delete i.lem,delete i.lec,i.ae=t}t(i)}else t(null)}else{let t=Error(i.message);i.stack&&(t.stack=i.stack),e(t)}},vt.postMessage({type:"license_getAR",id:i})})):null};let Xe=class t{static setLicenseServer(e){Be(t,e)}static get license(){return this._license}static set license(e){ke(t,e)}static get licenseServer(){return this._licenseServer}static set licenseServer(e){Be(t,e)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(e){je(t,e)}static initLicense(e,i){if(ke(t,e),t.bCallInitLicense=!0,"boolean"==typeof i&&i||"object"==typeof i&&i.executeNow)return He()}static setDeviceFriendlyName(e){je(t,e)}static getDeviceFriendlyName(){return t._deviceFriendlyName}static getDeviceUUID(){return(async()=>(await _t("dynamsoft_uuid",(async()=>{await Dt.loadWasm();let t=new Le,e=wt();Et[e]=e=>{if(e.success)t.resolve(e.uuid);else{const i=Error(e.message);e.stack&&(i.stack=e.stack),t.reject(i)}},vt.postMessage({type:"license_getDeviceUUID",id:e}),ze=await t})),ze))()}};Xe._pLoad=new Le,Xe.bPassValidation=!1,Xe.bCallInitLicense=!1,Xe._license=Pe,Xe._licenseServer=[],Xe._deviceFriendlyName="",Dt.engineResourcePaths.license={version:"4.0.30-dev-20250604160433",path:De,isInternal:!0},Rt.license={wasm:!0,js:!0},xt.license.LicenseManager=Xe;const Ze="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Ze)<0&&(Dt.engineResourcePaths.std={version:Ze,path:(t=>{if(null==t&&(t="./"),xe||Oe);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(De+`../../dynamsoft-capture-vision-std@${Ze}/dist/`),isInternal:!0});const qe="undefined"==typeof self,Ke="function"==typeof importScripts,Je=(()=>{if(!Ke){if(!qe&&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"./"}})();Dt.engineResourcePaths.dce={version:"4.2.12-dev-20250609101854",path:Je,isInternal:!0},Rt.dce={wasm:!1,js:!1},xt.dce={};let $e,Qe,ti,ei,ii;function ni(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 ri(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 r?r.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError,"undefined"!=typeof navigator&&($e=navigator,Qe=$e.userAgent,ti=$e.platform,ei=$e.mediaDevices),function(){if(!qe){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:$e.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:ti,search:"Win"},Mac:{str:ti},Linux:{str:ti}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||Qe,a=r.search||e,o=r.verStr||Qe,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||Qe,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=Qe.indexOf("Windows NT")&&(r="HarmonyOS"),ii={browser:i,version:n,OS:r}}qe&&(ii={browser:"ssr",version:0,OS:"ssr"})}();const si="undefined"!=typeof WebAssembly&&Qe&&!(/Safari/.test(Qe)&&!/Chrome/.test(Qe)&&/\(.+\s11_2_([2-6]).*\)/.test(Qe)),ai=!("undefined"==typeof Worker),oi=!(!ei||!ei.getUserMedia),li=async()=>{let t=!1;if(oi)try{(await ei.getUserMedia({video:!0})).getTracks().forEach((t=>{t.stop()})),t=!0}catch(t){}return t};"Chrome"===ii.browser&&ii.version>66||"Safari"===ii.browser&&ii.version>13||"OPR"===ii.browser&&ii.version>43||"Edge"===ii.browser&&ii.version;var hi={653:(t,e,i)=>{var n,r,s,a,o,l,h,c,d,u,f,g,m,p,_,v,y,w,E,C,S,T=T||{version:"5.2.1"};if(e.fabric=T,"undefined"!=typeof document&&"undefined"!=typeof window)document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?T.document=document:T.document=document.implementation.createHTMLDocument(""),T.window=window;else{var b=new(i(192).JSDOM)(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;T.document=b.document,T.jsdomImplForWrapper=i(898).implForWrapper,T.nodeCanvas=i(245).Canvas,T.window=b,DOMParser=T.window.DOMParser}function I(t,e){var i=t.canvas,n=e.targetCanvas,r=n.getContext("2d");r.translate(0,n.height),r.scale(1,-1);var s=i.height-n.height;r.drawImage(i,0,s,n.width,n.height,0,0,n.width,n.height)}function x(t,e){var i=e.targetCanvas.getContext("2d"),n=e.destinationWidth,r=e.destinationHeight,s=n*r*4,a=new Uint8Array(this.imageBuffer,0,s),o=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,n,r,t.RGBA,t.UNSIGNED_BYTE,a);var l=new ImageData(o,n,r);i.putImageData(l,0,0)}T.isTouchSupported="ontouchstart"in T.window||"ontouchstart"in T.document||T.window&&T.window.navigator&&T.window.navigator.maxTouchPoints>0,T.isLikelyNode="undefined"!=typeof Buffer&&"undefined"==typeof window,T.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],T.DPI=96,T.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",T.commaWsp="(?:\\s+,?\\s*|,\\s*)",T.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,T.reNonWord=/[ \n\.,;!\?\-]/,T.fontPaths={},T.iMatrix=[1,0,0,1,0,0],T.svgNS="http://www.w3.org/2000/svg",T.perfLimitSizeTotal=2097152,T.maxCacheSideLimit=4096,T.minCacheSideLimit=256,T.charWidthsCache={},T.textureSize=2048,T.disableStyleCopyPaste=!1,T.enableGLFiltering=!0,T.devicePixelRatio=T.window.devicePixelRatio||T.window.webkitDevicePixelRatio||T.window.mozDevicePixelRatio||1,T.browserShadowBlurConstant=1,T.arcToSegmentsCache={},T.boundsOfCurveCache={},T.cachesBoundsOfCurve=!0,T.forceGLPutImageData=!1,T.initFilterBackend=function(){return T.enableGLFiltering&&T.isWebglSupported&&T.isWebglSupported(T.textureSize)?(console.log("max texture size: "+T.maxTextureSize),new T.WebglFilterBackend({tileSize:T.textureSize})):T.Canvas2dFilterBackend?new T.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=T),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:T.util.array.fill(i,!1)}}function e(t,e){var i=function(){e.apply(this,arguments),this.off(t,i)}.bind(this);this.on(t,i)}T.Observable={fire:function(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;for(var n=0,r=i.length;n-1||!!e&&this._objects.some((function(e){return"function"==typeof e.contains&&e.contains(t,!0)}))},complexity:function(){return this._objects.reduce((function(t,e){return t+(e.complexity?e.complexity():0)}),0)}},T.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof T.Gradient||this.set(e,new T.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof T.Pattern?i&&i():this.set(e,new T.Pattern(t,i))},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},n=e,r=Math.sqrt,s=Math.atan2,a=Math.pow,o=Math.PI/180,l=Math.PI/2,T.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/l){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},sin:function(t){if(0===t)return 0;var e=1;switch(t<0&&(e=-1),t/l){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)},removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*o},radiansToDegrees:function(t){return t/o},rotatePoint:function(t,e,i){var n=new T.Point(t.x-e.x,t.y-e.y),r=T.util.rotateVector(n,i);return new T.Point(r.x,r.y).addEquals(e)},rotateVector:function(t,e){var i=T.util.sin(e),n=T.util.cos(e);return{x:t.x*n-t.y*i,y:t.x*i+t.y*n}},createVector:function(t,e){return new T.Point(e.x-t.x,e.y-t.y)},calcAngleBetweenVectors:function(t,e){return Math.acos((t.x*e.x+t.y*e.y)/(Math.hypot(t.x,t.y)*Math.hypot(e.x,e.y)))},getHatVector:function(t){return new T.Point(t.x,t.y).multiply(1/Math.hypot(t.x,t.y))},getBisector:function(t,e,i){var n=T.util.createVector(t,e),r=T.util.createVector(t,i),s=T.util.calcAngleBetweenVectors(n,r),a=s*(0===T.util.calcAngleBetweenVectors(T.util.rotateVector(n,s),r)?1:-1)/2;return{vector:T.util.getHatVector(T.util.rotateVector(n,a)),angle:s}},projectStrokeOnPoints:function(t,e,i){var n=[],r=e.strokeWidth/2,s=e.strokeUniform?new T.Point(1/e.scaleX,1/e.scaleY):new T.Point(1,1),a=function(t){var e=r/Math.hypot(t.x,t.y);return new T.Point(t.x*e*s.x,t.y*e*s.y)};return t.length<=1||t.forEach((function(o,l){var h,c,d=new T.Point(o.x,o.y);0===l?(c=t[l+1],h=i?a(T.util.createVector(c,d)).addEquals(d):t[t.length-1]):l===t.length-1?(h=t[l-1],c=i?a(T.util.createVector(h,d)).addEquals(d):t[0]):(h=t[l-1],c=t[l+1]);var u,f,g=T.util.getBisector(d,h,c),m=g.vector,p=g.angle;if("miter"===e.strokeLineJoin&&(u=-r/Math.sin(p/2),f=new T.Point(m.x*u*s.x,m.y*u*s.y),Math.hypot(f.x,f.y)/r<=e.strokeMiterLimit))return n.push(d.add(f)),void n.push(d.subtract(f));u=-r*Math.SQRT2,f=new T.Point(m.x*u*s.x,m.y*u*s.y),n.push(d.add(f)),n.push(d.subtract(f))})),n},transformPoint:function(t,e,i){return i?new T.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new T.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t,e){if(e)for(var i=0;i0&&(e>n?e-=n:e=0,i>n?i-=n:i=0);var r,s=!0,a=t.getImageData(e,i,2*n||1,2*n||1),o=a.data.length;for(r=3;r=r?s-r:2*Math.PI-(r-s)}function s(t,e,i){for(var s=i[1],a=i[2],o=i[3],l=i[4],h=i[5],c=function(t,e,i,s,a,o,l){var h=Math.PI,c=l*h/180,d=T.util.sin(c),u=T.util.cos(c),f=0,g=0,m=-u*t*.5-d*e*.5,p=-u*e*.5+d*t*.5,_=(i=Math.abs(i))*i,v=(s=Math.abs(s))*s,y=p*p,w=m*m,E=_*v-_*y-v*w,C=0;if(E<0){var S=Math.sqrt(1-E/(_*v));i*=S,s*=S}else C=(a===o?-1:1)*Math.sqrt(E/(_*y+v*w));var b=C*i*p/s,I=-C*s*m/i,x=u*b-d*I+.5*t,R=d*b+u*I+.5*e,O=r(1,0,(m-b)/i,(p-I)/s),D=r((m-b)/i,(p-I)/s,(-m-b)/i,(-p-I)/s);0===o&&D>0?D-=2*h:1===o&&D<0&&(D+=2*h);for(var A=Math.ceil(Math.abs(D/h*2)),M=[],L=D/A,F=8/3*Math.sin(L/4)*Math.sin(L/4)/Math.sin(L/2),P=O+L,k=0;kC)for(var b=1,I=m.length;b2;for(e=e||0,h&&(o=t[2].xt[i-2].x?1:r.x===t[i-2].x?0:-1,l=r.y>t[i-2].y?1:r.y===t[i-2].y?0:-1),n.push(["L",r.x+o*e,r.y+l*e]),n},T.util.getPathSegmentsInfo=u,T.util.getBoundsOfCurve=function(e,i,n,r,s,a,o,l){var h;if(T.cachesBoundsOfCurve&&(h=t.call(arguments),T.boundsOfCurveCache[h]))return T.boundsOfCurveCache[h];var c,d,u,f,g,m,p,_,v=Math.sqrt,y=Math.min,w=Math.max,E=Math.abs,C=[],S=[[],[]];d=6*e-12*n+6*s,c=-3*e+9*n-9*s+3*o,u=3*n-3*e;for(var b=0;b<2;++b)if(b>0&&(d=6*i-12*r+6*a,c=-3*i+9*r-9*a+3*l,u=3*r-3*i),E(c)<1e-12){if(E(d)<1e-12)continue;0<(f=-u/d)&&f<1&&C.push(f)}else(p=d*d-4*u*c)<0||(0<(g=(-d+(_=v(p)))/(2*c))&&g<1&&C.push(g),0<(m=(-d-_)/(2*c))&&m<1&&C.push(m));for(var I,x,R,O=C.length,D=O;O--;)I=(R=1-(f=C[O]))*R*R*e+3*R*R*f*n+3*R*f*f*s+f*f*f*o,S[0][O]=I,x=R*R*R*i+3*R*R*f*r+3*R*f*f*a+f*f*f*l,S[1][O]=x;S[0][D]=e,S[1][D]=i,S[0][D+1]=o,S[1][D+1]=l;var A=[{x:y.apply(null,S[0]),y:y.apply(null,S[1])},{x:w.apply(null,S[0]),y:w.apply(null,S[1])}];return T.cachesBoundsOfCurve&&(T.boundsOfCurveCache[h]=A),A},T.util.getPointOnPath=function(t,e,i){i||(i=u(t));for(var n=0;e-i[n].length>0&&n1e-4;)i=l(s),r=s,(n=a(h.x,h.y,i.x,i.y))+o>e?(s-=c,c/=2):(h=i,s+=c,o+=n);return i.angle=d(r),i}(s,e)}},T.util.transformPath=function(t,e,i){return i&&(e=T.util.multiplyTransformMatrices(e,[1,0,0,1,-i.x,-i.y])),t.map((function(t){for(var i=t.slice(0),n={},r=1;r=e}))}}}(),function(){function t(e,i,n){if(n)if(!T.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var r=0,s=i.length;r57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var n=t.charCodeAt(e+1);if(56320>n||n>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";var r=t.charCodeAt(e-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1}T.util.string={camelize:function(t){return t.replace(/-+(.)?/g,(function(t,e){return e?e.toUpperCase():""}))},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")},graphemeSplit:function(e){var i,n=0,r=[];for(n=0;n-1?t.prototype[r]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=n;var r=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return r}}(r):t.prototype[r]=e[r],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function r(){}function s(e){for(var i=null,n=this;n.constructor.superclass;){var r=n.constructor.superclass.prototype[e];if(n[e]!==r){i=r;break}n=n.constructor.superclass.prototype}return i?arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this):console.log("tried to callSuper "+e+", method not found in prototype chain",this)}T.util.createClass=function(){var i=null,a=t.call(arguments,0);function o(){this.initialize.apply(this,arguments)}"function"==typeof a[0]&&(i=a.shift()),o.superclass=i,o.subclasses=[],i&&(r.prototype=i.prototype,o.prototype=new r,i.subclasses.push(o));for(var l=0,h=a.length;l-1||"touch"===t.pointerType},u="string"==typeof(d=T.document.createElement("div")).style.opacity,f="string"==typeof d.style.filter,g=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,m=function(t){return t},u?m=function(t,e){return t.style.opacity=e,t}:f&&(m=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),g.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(g,e)):i.filter+=" alpha(opacity="+100*e+")",t}),T.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?m(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var n in e)"opacity"===n?m(t,e[n]):i["float"===n||"cssFloat"===n?void 0===i.styleFloat?"cssFloat":"styleFloat":n]=e[n];return t},function(){var t,e,i,n,r=Array.prototype.slice,s=function(t){return r.call(t,0)};try{t=s(T.document.childNodes)instanceof Array}catch(t){}function a(t,e){var i=T.document.createElement(t);for(var n in e)"class"===n?i.className=e[n]:"for"===n?i.htmlFor=e[n]:i.setAttribute(n,e[n]);return i}function o(t){for(var e=0,i=0,n=T.document.documentElement,r=T.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===T.document?(e=r.scrollLeft||n.scrollLeft||0,i=r.scrollTop||n.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}t||(s=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),e=T.document.defaultView&&T.document.defaultView.getComputedStyle?function(t,e){var i=T.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},i=T.document.documentElement.style,n="userSelect"in i?"userSelect":"MozUserSelect"in i?"MozUserSelect":"WebkitUserSelect"in i?"WebkitUserSelect":"KhtmlUserSelect"in i?"KhtmlUserSelect":"",T.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=T.util.falseFunction),n?t.style[n]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},T.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),n?t.style[n]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},T.util.setImageSmoothing=function(t,e){t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled,t.imageSmoothingEnabled=e},T.util.getById=function(t){return"string"==typeof t?T.document.getElementById(t):t},T.util.toArray=s,T.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},T.util.makeElement=a,T.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=a(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},T.util.getScrollLeftTop=o,T.util.getElementOffset=function(t){var i,n,r=t&&t.ownerDocument,s={left:0,top:0},a={left:0,top:0},l={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return a;for(var h in l)a[l[h]]+=parseInt(e(t,h),10)||0;return i=r.documentElement,void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect()),n=o(t),{left:s.left+n.left-(i.clientLeft||0)+a.left,top:s.top+n.top-(i.clientTop||0)+a.top}},T.util.getNodeCanvas=function(t){var e=T.jsdomImplForWrapper(t);return e._canvas||e._image},T.util.cleanUpJsdomNode=function(t){if(T.isLikelyNode){var e=T.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}T.util.request=function(e,i){i||(i={});var n=i.method?i.method.toUpperCase():"GET",r=i.onComplete||function(){},s=new T.window.XMLHttpRequest,a=i.body||i.parameters;return s.onreadystatechange=function(){4===s.readyState&&(r(s),s.onreadystatechange=t)},"GET"===n&&(a=null,"string"==typeof i.parameters&&(e=function(t,e){return t+(/\?/.test(t)?"&":"?")+e}(e,i.parameters))),s.open(n,e,!0),"POST"!==n&&"PUT"!==n||s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(a),s}}(),T.log=console.log,T.warn=console.warn,function(){var t=T.util.object.extend,e=T.util.object.clone,i=[];function n(){return!1}function r(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e}T.util.object.extend(i,{cancelAll:function(){var t=this.splice(0);return t.forEach((function(t){t.cancel()})),t},cancelByCanvas:function(t){if(!t)return[];var e=this.filter((function(e){return"object"==typeof e.target&&e.target.canvas===t}));return e.forEach((function(t){t.cancel()})),e},cancelByTarget:function(t){var e=this.findAnimationsByTarget(t);return e.forEach((function(t){t.cancel()})),e},findAnimationIndex:function(t){return this.indexOf(this.findAnimation(t))},findAnimation:function(t){return this.find((function(e){return e.cancel===t}))},findAnimationsByTarget:function(t){return t?this.filter((function(e){return e.target===t})):[]}});var s=T.window.requestAnimationFrame||T.window.webkitRequestAnimationFrame||T.window.mozRequestAnimationFrame||T.window.oRequestAnimationFrame||T.window.msRequestAnimationFrame||function(t){return T.window.setTimeout(t,1e3/60)},a=T.window.cancelAnimationFrame||T.window.clearTimeout;function o(){return s.apply(T.window,arguments)}T.util.animate=function(i){i||(i={});var s,a=!1,l=function(){var t=T.runningAnimations.indexOf(s);return t>-1&&T.runningAnimations.splice(t,1)[0]};return s=t(e(i),{cancel:function(){return a=!0,l()},currentValue:"startValue"in i?i.startValue:0,completionRate:0,durationRate:0}),T.runningAnimations.push(s),o((function(t){var e,h=t||+new Date,c=i.duration||500,d=h+c,u=i.onChange||n,f=i.abort||n,g=i.onComplete||n,m=i.easing||r,p="startValue"in i&&i.startValue.length>0,_="startValue"in i?i.startValue:0,v="endValue"in i?i.endValue:100,y=i.byValue||(p?_.map((function(t,e){return v[e]-_[e]})):v-_);i.onStart&&i.onStart(),function t(i){var n=(e=i||+new Date)>d?c:e-h,r=n/c,w=p?_.map((function(t,e){return m(n,_[e],y[e],c)})):m(n,_,y,c),E=p?Math.abs((w[0]-_[0])/y[0]):Math.abs((w-_)/y);if(s.currentValue=p?w.slice():w,s.completionRate=E,s.durationRate=r,!a){if(!f(w,E,r))return e>d?(s.currentValue=p?v.slice():v,s.completionRate=1,s.durationRate=1,u(p?v.slice():v,1,1),g(v,1,1),void l()):(u(w,E,r),void o(t));l()}}(h)})),s.cancel},T.util.requestAnimFrame=o,T.util.cancelAnimFrame=function(){return a.apply(T.window,arguments)},T.runningAnimations=i}(),function(){function t(t,e,i){var n="rgba("+parseInt(t[0]+i*(e[0]-t[0]),10)+","+parseInt(t[1]+i*(e[1]-t[1]),10)+","+parseInt(t[2]+i*(e[2]-t[2]),10);return(n+=","+(t&&e?parseFloat(t[3]+i*(e[3]-t[3])):1))+")"}T.util.animateColor=function(e,i,n,r){var s=new T.Color(e).getSource(),a=new T.Color(i).getSource(),o=r.onComplete,l=r.onChange;return r=r||{},T.util.animate(T.util.object.extend(r,{duration:n||500,startValue:s,endValue:a,byValue:a,easing:function(e,i,n,s){return t(i,n,r.colorEasing?r.colorEasing(e,s):1-Math.cos(e/s*(Math.PI/2)))},onComplete:function(e,i,n){if(o)return o(t(a,a,0),i,n)},onChange:function(e,i,n){if(l){if(Array.isArray(e))return l(t(e,e,0),i,n);l(e,i,n)}}}))}}(),function(){function t(t,e,i,n){return t-1&&c>-1&&c-1)&&(i="stroke")}else{if("href"===t||"xlink:href"===t||"font"===t)return i;if("imageSmoothing"===t)return"optimizeQuality"===i;o=l?i.map(s):s(i,r)}}else i="";return!l&&isNaN(o)?i:o}function f(t){return new RegExp("^("+t.join("|")+")\\b","i")}function g(t,e){var i,n,r,s,a=[];for(r=0,s=e.length;r1;)l.shift(),h=e.util.multiplyTransformMatrices(h,l[0]);return h}}();var v=new RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function y(t){if(!e.svgViewBoxElementsRegEx.test(t.nodeName))return{};var i,n,r,a,o,l,h=t.getAttribute("viewBox"),c=1,d=1,u=t.getAttribute("width"),f=t.getAttribute("height"),g=t.getAttribute("x")||0,m=t.getAttribute("y")||0,p=t.getAttribute("preserveAspectRatio")||"",_=!h||!(h=h.match(v)),y=!u||!f||"100%"===u||"100%"===f,w=_&&y,E={},C="",S=0,T=0;if(E.width=0,E.height=0,E.toBeParsed=w,_&&(g||m)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(C=" translate("+s(g)+" "+s(m)+") ",o=(t.getAttribute("transform")||"")+C,t.setAttribute("transform",o),t.removeAttribute("x"),t.removeAttribute("y")),w)return E;if(_)return E.width=s(u),E.height=s(f),E;if(i=-parseFloat(h[1]),n=-parseFloat(h[2]),r=parseFloat(h[3]),a=parseFloat(h[4]),E.minX=i,E.minY=n,E.viewBoxWidth=r,E.viewBoxHeight=a,y?(E.width=r,E.height=a):(E.width=s(u),E.height=s(f),c=E.width/r,d=E.height/a),"none"!==(p=e.util.parsePreserveAspectRatioAttribute(p)).alignX&&("meet"===p.meetOrSlice&&(d=c=c>d?d:c),"slice"===p.meetOrSlice&&(d=c=c>d?c:d),S=E.width-r*c,T=E.height-a*c,"Mid"===p.alignX&&(S/=2),"Mid"===p.alignY&&(T/=2),"Min"===p.alignX&&(S=0),"Min"===p.alignY&&(T=0)),1===c&&1===d&&0===i&&0===n&&0===g&&0===m)return E;if((g||m)&&"#document"!==t.parentNode.nodeName&&(C=" translate("+s(g)+" "+s(m)+") "),o=C+" matrix("+c+" 0 0 "+d+" "+(i*c+S)+" "+(n*d+T)+") ","svg"===t.nodeName){for(l=t.ownerDocument.createElementNS(e.svgNS,"g");t.firstChild;)l.appendChild(t.firstChild);t.appendChild(l)}else(l=t).removeAttribute("x"),l.removeAttribute("y"),o=l.getAttribute("transform")+o;return l.setAttribute("transform",o),E}function w(t,e){var i="xlink:href",n=_(t,e.getAttribute(i).slice(1));if(n&&n.getAttribute(i)&&w(t,n),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach((function(t){n&&!e.hasAttribute(t)&&n.hasAttribute(t)&&e.setAttribute(t,n.getAttribute(t))})),!e.children.length)for(var r=n.cloneNode(!0);r.firstChild;)e.appendChild(r.firstChild);e.removeAttribute(i)}e.parseSVGDocument=function(t,i,r,s){if(t){!function(t){for(var i=g(t,["use","svg:use"]),n=0;i.length&&nt.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return void 0===e&&(e=.5),e=Math.max(Math.min(1,e),0),new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new i(this.x,this.y)}})}(e),function(t){var e=t.fabric||(t.fabric={});function i(t){this.status=t,this.points=[]}e.Intersection?e.warn("fabric.Intersection is already defined"):(e.Intersection=i,e.Intersection.prototype={constructor:i,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},e.Intersection.intersectLineLine=function(t,n,r,s){var a,o=(s.x-r.x)*(t.y-r.y)-(s.y-r.y)*(t.x-r.x),l=(n.x-t.x)*(t.y-r.y)-(n.y-t.y)*(t.x-r.x),h=(s.y-r.y)*(n.x-t.x)-(s.x-r.x)*(n.y-t.y);if(0!==h){var c=o/h,d=l/h;0<=c&&c<=1&&0<=d&&d<=1?(a=new i("Intersection")).appendPoint(new e.Point(t.x+c*(n.x-t.x),t.y+c*(n.y-t.y))):a=new i}else a=new i(0===o||0===l?"Coincident":"Parallel");return a},e.Intersection.intersectLinePolygon=function(t,e,n){var r,s,a,o,l=new i,h=n.length;for(o=0;o0&&(l.status="Intersection"),l},e.Intersection.intersectPolygonPolygon=function(t,e){var n,r=new i,s=t.length;for(n=0;n0&&(r.status="Intersection"),r},e.Intersection.intersectPolygonRectangle=function(t,n,r){var s=n.min(r),a=n.max(r),o=new e.Point(a.x,s.y),l=new e.Point(s.x,a.y),h=i.intersectLinePolygon(s,o,t),c=i.intersectLinePolygon(o,a,t),d=i.intersectLinePolygon(a,l,t),u=i.intersectLinePolygon(l,s,t),f=new i;return f.appendPoints(h.points),f.appendPoints(c.points),f.appendPoints(d.points),f.appendPoints(u.points),f.points.length>0&&(f.status="Intersection"),f})}(e),function(t){var e=t.fabric||(t.fabric={});function i(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function n(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}e.Color?e.warn("fabric.Color is already defined."):(e.Color=i,e.Color.prototype={_tryParsingColor:function(t){var e;t in i.colorNameMap&&(t=i.colorNameMap[t]),"transparent"===t&&(e=[255,255,255,0]),e||(e=i.sourceFromHex(t)),e||(e=i.sourceFromRgb(t)),e||(e=i.sourceFromHsl(t)),e||(e=[0,0,0,1]),e&&this.setSource(e)},_rgbToHsl:function(t,i,n){t/=255,i/=255,n/=255;var r,s,a,o=e.util.array.max([t,i,n]),l=e.util.array.min([t,i,n]);if(a=(o+l)/2,o===l)r=s=0;else{var h=o-l;switch(s=a>.5?h/(2-o-l):h/(o+l),o){case t:r=(i-n)/h+(i0)-(t<0)||+t};function f(t,e){var i=t.angle+d(Math.atan2(e.y,e.x))+360;return Math.round(i%360/45)}function g(t,i){var n=i.transform.target,r=n.canvas,s=e.util.object.clone(i);s.target=n,r&&r.fire("object:"+t,s),n.fire(t,i)}function m(t,e){var i=e.canvas,n=t[i.uniScaleKey];return i.uniformScaling&&!n||!i.uniformScaling&&n}function p(t){return t.originX===h&&t.originY===h}function _(t,e,i){var n=t.lockScalingX,r=t.lockScalingY;return!((!n||!r)&&(e||!n&&!r||!i)&&(!n||"x"!==e)&&(!r||"y"!==e))}function v(t,e,i,n){return{e:t,transform:e,pointer:{x:i,y:n}}}function y(t){return function(e,i,n,r){var s=i.target,a=s.getCenterPoint(),o=s.translateToOriginPoint(a,i.originX,i.originY),l=t(e,i,n,r);return s.setPositionByOrigin(o,i.originX,i.originY),l}}function w(t,e){return function(i,n,r,s){var a=e(i,n,r,s);return a&&g(t,v(i,n,r,s)),a}}function E(t,i,n,r,s){var a=t.target,o=a.controls[t.corner],l=a.canvas.getZoom(),h=a.padding/l,c=a.toLocalPoint(new e.Point(r,s),i,n);return c.x>=h&&(c.x-=h),c.x<=-h&&(c.x+=h),c.y>=h&&(c.y-=h),c.y<=h&&(c.y+=h),c.x-=o.offsetX,c.y-=o.offsetY,c}function C(t){return t.flipX!==t.flipY}function S(t,e,i,n,r){if(0!==t[e]){var s=r/t._getTransformedDimensions()[n]*t[i];t.set(i,s)}}function T(t,e,i,n){var r,h=e.target,c=h._getTransformedDimensions(0,h.skewY),u=E(e,e.originX,e.originY,i,n),f=Math.abs(2*u.x)-c.x,g=h.skewX;f<2?r=0:(r=d(Math.atan2(f/h.scaleX,c.y/h.scaleY)),e.originX===s&&e.originY===l&&(r=-r),e.originX===o&&e.originY===a&&(r=-r),C(h)&&(r=-r));var m=g!==r;if(m){var p=h._getTransformedDimensions().y;h.set("skewX",r),S(h,"skewY","scaleY","y",p)}return m}function b(t,e,i,n){var r,h=e.target,c=h._getTransformedDimensions(h.skewX,0),u=E(e,e.originX,e.originY,i,n),f=Math.abs(2*u.y)-c.y,g=h.skewY;f<2?r=0:(r=d(Math.atan2(f/h.scaleY,c.x/h.scaleX)),e.originX===s&&e.originY===l&&(r=-r),e.originX===o&&e.originY===a&&(r=-r),C(h)&&(r=-r));var m=g!==r;if(m){var p=h._getTransformedDimensions().x;h.set("skewY",r),S(h,"skewX","scaleX","x",p)}return m}function I(t,e,i,n,r){r=r||{};var s,a,o,l,h,d,f=e.target,g=f.lockScalingX,v=f.lockScalingY,y=r.by,w=m(t,f),C=_(f,y,w),S=e.gestureScale;if(C)return!1;if(S)a=e.scaleX*S,o=e.scaleY*S;else{if(s=E(e,e.originX,e.originY,i,n),h="y"!==y?u(s.x):1,d="x"!==y?u(s.y):1,e.signX||(e.signX=h),e.signY||(e.signY=d),f.lockScalingFlip&&(e.signX!==h||e.signY!==d))return!1;if(l=f._getTransformedDimensions(),w&&!y){var T=Math.abs(s.x)+Math.abs(s.y),b=e.original,I=T/(Math.abs(l.x*b.scaleX/f.scaleX)+Math.abs(l.y*b.scaleY/f.scaleY));a=b.scaleX*I,o=b.scaleY*I}else a=Math.abs(s.x*f.scaleX/l.x),o=Math.abs(s.y*f.scaleY/l.y);p(e)&&(a*=2,o*=2),e.signX!==h&&"y"!==y&&(e.originX=c[e.originX],a*=-1,e.signX=h),e.signY!==d&&"x"!==y&&(e.originY=c[e.originY],o*=-1,e.signY=d)}var x=f.scaleX,R=f.scaleY;return y?("x"===y&&f.set("scaleX",a),"y"===y&&f.set("scaleY",o)):(!g&&f.set("scaleX",a),!v&&f.set("scaleY",o)),x!==f.scaleX||R!==f.scaleY}r.scaleCursorStyleHandler=function(t,e,n){var r=m(t,n),s="";if(0!==e.x&&0===e.y?s="x":0===e.x&&0!==e.y&&(s="y"),_(n,s,r))return"not-allowed";var a=f(n,e);return i[a]+"-resize"},r.skewCursorStyleHandler=function(t,e,i){var r="not-allowed";if(0!==e.x&&i.lockSkewingY)return r;if(0!==e.y&&i.lockSkewingX)return r;var s=f(i,e)%4;return n[s]+"-resize"},r.scaleSkewCursorStyleHandler=function(t,e,i){return t[i.canvas.altActionKey]?r.skewCursorStyleHandler(t,e,i):r.scaleCursorStyleHandler(t,e,i)},r.rotationWithSnapping=w("rotating",y((function(t,e,i,n){var r=e,s=r.target,a=s.translateToOriginPoint(s.getCenterPoint(),r.originX,r.originY);if(s.lockRotation)return!1;var o,l=Math.atan2(r.ey-a.y,r.ex-a.x),h=Math.atan2(n-a.y,i-a.x),c=d(h-l+r.theta);if(s.snapAngle>0){var u=s.snapAngle,f=s.snapThreshold||u,g=Math.ceil(c/u)*u,m=Math.floor(c/u)*u;Math.abs(c-m)0?s:o:(c>0&&(r=d===a?s:o),c<0&&(r=d===a?o:s),C(l)&&(r=r===s?o:s)),e.originX=r,w("skewing",y(T))(t,e,i,n))},r.skewHandlerY=function(t,e,i,n){var r,o=e.target,c=o.skewY,d=e.originX;return!o.lockSkewingY&&(0===c?r=E(e,h,h,i,n).y>0?a:l:(c>0&&(r=d===s?a:l),c<0&&(r=d===s?l:a),C(o)&&(r=r===a?l:a)),e.originY=r,w("skewing",y(b))(t,e,i,n))},r.dragHandler=function(t,e,i,n){var r=e.target,s=i-e.offsetX,a=n-e.offsetY,o=!r.get("lockMovementX")&&r.left!==s,l=!r.get("lockMovementY")&&r.top!==a;return o&&r.set("left",s),l&&r.set("top",a),(o||l)&&g("moving",v(t,e,i,n)),o||l},r.scaleOrSkewActionName=function(t,e,i){var n=t[i.canvas.altActionKey];return 0===e.x?n?"skewX":"scaleY":0===e.y?n?"skewY":"scaleX":void 0},r.rotationStyleHandler=function(t,e,i){return i.lockRotation?"not-allowed":e.cursorStyle},r.fireEvent=g,r.wrapWithFixedAnchor=y,r.wrapWithFireEvent=w,r.getLocalPoint=E,e.controlsUtils=r}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians,n=e.controlsUtils;n.renderCircleControl=function(t,e,i,n,r){n=n||{};var s,a=this.sizeX||n.cornerSize||r.cornerSize,o=this.sizeY||n.cornerSize||r.cornerSize,l=void 0!==n.transparentCorners?n.transparentCorners:r.transparentCorners,h=l?"stroke":"fill",c=!l&&(n.cornerStrokeColor||r.cornerStrokeColor),d=e,u=i;t.save(),t.fillStyle=n.cornerColor||r.cornerColor,t.strokeStyle=n.cornerStrokeColor||r.cornerStrokeColor,a>o?(s=a,t.scale(1,o/a),u=i*a/o):o>a?(s=o,t.scale(a/o,1),d=e*o/a):s=a,t.lineWidth=1,t.beginPath(),t.arc(d,u,s/2,0,2*Math.PI,!1),t[h](),c&&t.stroke(),t.restore()},n.renderSquareControl=function(t,e,n,r,s){r=r||{};var a=this.sizeX||r.cornerSize||s.cornerSize,o=this.sizeY||r.cornerSize||s.cornerSize,l=void 0!==r.transparentCorners?r.transparentCorners:s.transparentCorners,h=l?"stroke":"fill",c=!l&&(r.cornerStrokeColor||s.cornerStrokeColor),d=a/2,u=o/2;t.save(),t.fillStyle=r.cornerColor||s.cornerColor,t.strokeStyle=r.cornerStrokeColor||s.cornerStrokeColor,t.lineWidth=1,t.translate(e,n),t.rotate(i(s.angle)),t[h+"Rect"](-d,-u,a,o),c&&t.strokeRect(-d,-u,a,o),t.restore()}}(e),function(t){var e=t.fabric||(t.fabric={});e.Control=function(t){for(var e in t)this[e]=t[e]},e.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(t,e){return e.cursorStyle},getActionName:function(t,e){return e.actionName},getVisibility:function(t,e){var i=t._controlsVisibility;return i&&void 0!==i[e]?i[e]:this.visible},setVisibility:function(t){this.visible=t},positionHandler:function(t,i){return e.util.transformPoint({x:this.x*t.x+this.offsetX,y:this.y*t.y+this.offsetY},i)},calcCornerCoords:function(t,i,n,r,s){var a,o,l,h,c=s?this.touchSizeX:this.sizeX,d=s?this.touchSizeY:this.sizeY;if(c&&d&&c!==d){var u=Math.atan2(d,c),f=Math.sqrt(c*c+d*d)/2,g=u-e.util.degreesToRadians(t),m=Math.PI/2-u-e.util.degreesToRadians(t);a=f*e.util.cos(g),o=f*e.util.sin(g),l=f*e.util.cos(m),h=f*e.util.sin(m)}else f=.7071067812*(c&&d?c:i),g=e.util.degreesToRadians(45-t),a=l=f*e.util.cos(g),o=h=f*e.util.sin(g);return{tl:{x:n-h,y:r-l},tr:{x:n+a,y:r-o},bl:{x:n-a,y:r+o},br:{x:n+h,y:r+l}}},render:function(t,i,n,r,s){"circle"===((r=r||{}).cornerStyle||s.cornerStyle)?e.controlsUtils.renderCircleControl.call(this,t,i,n,r,s):e.controlsUtils.renderSquareControl.call(this,t,i,n,r,s)}}}(e),function(){function t(t,e){var i,n,r,s,a=t.getAttribute("style"),o=t.getAttribute("offset")||0;if(o=(o=parseFloat(o)/(/%$/.test(o)?100:1))<0?0:o>1?1:o,a){var l=a.split(/\s*;\s*/);for(""===l[l.length-1]&&l.pop(),s=l.length;s--;){var h=l[s].split(/\s*:\s*/),c=h[0].trim(),d=h[1].trim();"stop-color"===c?i=d:"stop-opacity"===c&&(r=d)}}return i||(i=t.getAttribute("stop-color")||"rgb(0,0,0)"),r||(r=t.getAttribute("stop-opacity")),n=(i=new T.Color(i)).getAlpha(),r=isNaN(parseFloat(r))?1:parseFloat(r),r*=n*e,{offset:o,color:i.toRgb(),opacity:r}}var e=T.util.object.clone;T.Gradient=T.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(t){t||(t={}),t.coords||(t.coords={});var e,i=this;Object.keys(t).forEach((function(e){i[e]=t[e]})),this.id?this.id+="_"+T.Object.__uid++:this.id=T.Object.__uid++,e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice()},addColorStop:function(t){for(var e in t){var i=new T.Color(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(t){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return T.util.populateWithProperties(this,e,t),e},toSVG:function(t,i){var n,r,s,a,o=e(this.coords,!0),l=(i=i||{},e(this.colorStops,!0)),h=o.r1>o.r2,c=this.gradientTransform?this.gradientTransform.concat():T.iMatrix.concat(),d=-this.offsetX,u=-this.offsetY,f=!!i.additionalTransform,g="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox";if(l.sort((function(t,e){return t.offset-e.offset})),"objectBoundingBox"===g?(d/=t.width,u/=t.height):(d+=t.width/2,u+=t.height/2),"path"===t.type&&"percentage"!==this.gradientUnits&&(d-=t.pathOffset.x,u-=t.pathOffset.y),c[4]-=d,c[5]-=u,a='id="SVGID_'+this.id+'" gradientUnits="'+g+'"',a+=' gradientTransform="'+(f?i.additionalTransform+" ":"")+T.util.matrixToSVG(c)+'" ',"linear"===this.type?s=["\n']:"radial"===this.type&&(s=["\n']),"radial"===this.type){if(h)for((l=l.concat()).reverse(),n=0,r=l.length;n0){var p=m/Math.max(o.r1,o.r2);for(n=0,r=l.length;n\n')}return s.push("linear"===this.type?"\n":"\n"),s.join("")},toLive:function(t){var e,i,n,r=T.util.object.clone(this.coords);if(this.type){for("linear"===this.type?e=t.createLinearGradient(r.x1,r.y1,r.x2,r.y2):"radial"===this.type&&(e=t.createRadialGradient(r.x1,r.y1,r.r1,r.x2,r.y2,r.r2)),i=0,n=this.colorStops.length;i1?1:s,isNaN(s)&&(s=1);var a,o,l,h,c=e.getElementsByTagName("stop"),d="userSpaceOnUse"===e.getAttribute("gradientUnits")?"pixels":"percentage",u=e.getAttribute("gradientTransform")||"",f=[],g=0,m=0;for("linearGradient"===e.nodeName||"LINEARGRADIENT"===e.nodeName?(a="linear",o=function(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}(e)):(a="radial",o=function(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}(e)),l=c.length;l--;)f.push(t(c[l],s));return h=T.parseTransformAttribute(u),function(t,e,i,n){var r,s;Object.keys(e).forEach((function(t){"Infinity"===(r=e[t])?s=1:"-Infinity"===r?s=0:(s=parseFloat(e[t],10),"string"==typeof r&&/^(\d+\.\d+)%|(\d+)%$/.test(r)&&(s*=.01,"pixels"===n&&("x1"!==t&&"x2"!==t&&"r2"!==t||(s*=i.viewBoxWidth||i.width),"y1"!==t&&"y2"!==t||(s*=i.viewBoxHeight||i.height)))),e[t]=s}))}(0,o,r,d),"pixels"===d&&(g=-i.left,m=-i.top),new T.Gradient({id:e.getAttribute("id"),type:a,coords:o,colorStops:f,gradientUnits:d,gradientTransform:h,offsetX:g,offsetY:m})}})}(),_=T.util.toFixed,T.Pattern=T.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(t,e){if(t||(t={}),this.id=T.Object.__uid++,this.setOptions(t),!t.source||t.source&&"string"!=typeof t.source)e&&e(this);else{var i=this;this.source=T.util.createImage(),T.util.loadImage(t.source,(function(t,n){i.source=t,e&&e(i,n)}),null,this.crossOrigin)}},toObject:function(t){var e,i,n=T.Object.NUM_FRACTION_DIGITS;return"string"==typeof this.source.src?e=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(e=this.source.toDataURL()),i={type:"pattern",source:e,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:_(this.offsetX,n),offsetY:_(this.offsetY,n),patternTransform:this.patternTransform?this.patternTransform.concat():null},T.util.populateWithProperties(this,i,t),i},toSVG:function(t){var e="function"==typeof this.source?this.source():this.source,i=e.width/t.width,n=e.height/t.height,r=this.offsetX/t.width,s=this.offsetY/t.height,a="";return"repeat-x"!==this.repeat&&"no-repeat"!==this.repeat||(n=1,s&&(n+=Math.abs(s))),"repeat-y"!==this.repeat&&"no-repeat"!==this.repeat||(i=1,r&&(i+=Math.abs(r))),e.src?a=e.src:e.toDataURL&&(a=e.toDataURL()),'\n\n\n'},setOptions:function(t){for(var e in t)this[e]=t[e]},toLive:function(t){var e=this.source;if(!e)return"";if(void 0!==e.src){if(!e.complete)return"";if(0===e.naturalWidth||0===e.naturalHeight)return""}return t.createPattern(e,this.repeat)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.toFixed;e.Shadow?e.warn("fabric.Shadow is already defined."):(e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(t){for(var i in"string"==typeof t&&(t=this._parseShadow(t)),t)this[i]=t[i];this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),n=e.Shadow.reOffsetsAndBlur.exec(i)||[];return{color:(i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseFloat(n[1],10)||0,offsetY:parseFloat(n[2],10)||0,blur:parseFloat(n[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var n=40,r=40,s=e.Object.NUM_FRACTION_DIGITS,a=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle)),o=new e.Color(this.color);return t.width&&t.height&&(n=100*i((Math.abs(a.x)+this.blur)/t.width,s)+20,r=100*i((Math.abs(a.y)+this.blur)/t.height,s)+20),t.flipX&&(a.x*=-1),t.flipY&&(a.y*=-1),'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var t={},i=e.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach((function(e){this[e]!==i[e]&&(t[e]=this[e])}),this),t}}),e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/)}(e),function(){if(T.StaticCanvas)T.warn("fabric.StaticCanvas is already defined.");else{var t=T.util.object.extend,e=T.util.getElementOffset,i=T.util.removeFromArray,n=T.util.toFixed,r=T.util.transformPoint,s=T.util.invertTransform,a=T.util.getNodeCanvas,o=T.util.createCanvasElement,l=new Error("Could not initialize `canvas` element");T.StaticCanvas=T.util.createClass(T.CommonMethods,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:T.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(t,e){var i=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(t),this._initOptions(e),this.interactive||this._initRetinaScaling(),e.overlayImage&&this.setOverlayImage(e.overlayImage,i),e.backgroundImage&&this.setBackgroundImage(e.backgroundImage,i),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor,i),e.overlayColor&&this.setOverlayColor(e.overlayColor,i),this.calcOffset()},_isRetinaScaling:function(){return T.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,T.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var t=T.devicePixelRatio;this.__initRetinaScaling(t,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(t,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(t,e,i){e.setAttribute("width",this.width*t),e.setAttribute("height",this.height*t),i.scale(t,t)},calcOffset:function(){return this._offset=e(this.lowerCanvasEl),this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},__setBgOverlayImage:function(t,e,i,n){return"string"==typeof e?T.util.loadImage(e,(function(e,r){if(e){var s=new T.Image(e,n);this[t]=s,s.canvas=this}i&&i(e,r)}),this,n&&n.crossOrigin):(n&&e.setOptions(n),this[t]=e,e&&(e.canvas=this),i&&i(e,!1)),this},__setBgOverlayColor:function(t,e,i){return this[t]=e,this._initGradient(e,t),this._initPattern(e,t,i),this},_createCanvasElement:function(){var t=o();if(!t)throw l;if(t.style||(t.style={}),void 0===t.getContext)throw l;return t},_initOptions:function(t){var e=this.lowerCanvasEl;this._setOptions(t),this.width=this.width||parseInt(e.width,10)||0,this.height=this.height||parseInt(e.height,10)||0,this.lowerCanvasEl.style&&(e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(t){t&&t.getContext?this.lowerCanvasEl=t:this.lowerCanvasEl=T.util.getById(t)||this._createCanvasElement(),T.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;for(var n in e=e||{},t)i=t[n],e.cssOnly||(this._setBackstoreDimension(n,t[n]),i+="px",this.hasLostContext=!0),e.backstoreOnly||this._setCssDimension(n,i);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),e.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(t,e){return this.lowerCanvasEl[t]=e,this.upperCanvasEl&&(this.upperCanvasEl[t]=e),this.cacheCanvasEl&&(this.cacheCanvasEl[t]=e),this[t]=e,this},_setCssDimension:function(t,e){return this.lowerCanvasEl.style[t]=e,this.upperCanvasEl&&(this.upperCanvasEl.style[t]=e),this.wrapperEl&&(this.wrapperEl.style[t]=e),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(t){var e,i,n,r=this._activeObject,s=this.backgroundImage,a=this.overlayImage;for(this.viewportTransform=t,i=0,n=this._objects.length;i\n'),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push("\n"),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push(""),i.join("")},_setSVGPreamble:function(t,e){e.suppressPreamble||t.push('\n','\n')},_setSVGHeader:function(t,e){var i,r=e.width||this.width,s=e.height||this.height,a='viewBox="0 0 '+this.width+" "+this.height+'" ',o=T.Object.NUM_FRACTION_DIGITS;e.viewBox?a='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" ':this.svgViewportTransformation&&(i=this.viewportTransform,a='viewBox="'+n(-i[4]/i[0],o)+" "+n(-i[5]/i[3],o)+" "+n(this.width/i[0],o)+" "+n(this.height/i[3],o)+'" '),t.push("\n',"Created with Fabric.js ",T.version,"\n","\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"\n")},createSVGClipPathMarkup:function(t){var e=this.clipPath;return e?(e.clipPathId="CLIPPATH_"+T.Object.__uid++,'\n'+this.clipPath.toClipPathSVG(t.reviver)+"\n"):""},createSVGRefElementsMarkup:function(){var t=this;return["background","overlay"].map((function(e){var i=t[e+"Color"];if(i&&i.toLive){var n=t[e+"Vpt"],r=t.viewportTransform,s={width:t.width/(n?r[0]:1),height:t.height/(n?r[3]:1)};return i.toSVG(s,{additionalTransform:n?T.util.matrixToSVG(r):""})}})).join("")},createSVGFontFacesMarkup:function(){var t,e,i,n,r,s,a,o,l="",h={},c=T.fontPaths,d=[];for(this._objects.forEach((function t(e){d.push(e),e._objects&&e._objects.forEach(t)})),a=0,o=d.length;a',"\n",l,"","\n"].join("")),l},_setSVGObjects:function(t,e){var i,n,r,s=this._objects;for(n=0,r=s.length;n\n")}else t.push('\n")},sendToBack:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(e=(r=s._objects).length;e--;)n=r[e],i(this._objects,n),this._objects.unshift(n);else i(this._objects,t),this._objects.unshift(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(r=s._objects,e=0;e0+h&&(a=s-1,i(this._objects,r),this._objects.splice(a,0,r)),h++;else 0!==(s=this._objects.indexOf(t))&&(a=this._findNewLowerIndex(t,s,e),i(this._objects,t),this._objects.splice(a,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(t,e,i){var n,r;if(i){for(n=e,r=e-1;r>=0;--r)if(t.intersectsWithObject(this._objects[r])||t.isContainedWithinObject(this._objects[r])||this._objects[r].isContainedWithinObject(t)){n=r;break}}else n=e-1;return n},bringForward:function(t,e){if(!t)return this;var n,r,s,a,o,l=this._activeObject,h=0;if(t===l&&"activeSelection"===t.type)for(n=(o=l._objects).length;n--;)r=o[n],(s=this._objects.indexOf(r))"}}),t(T.StaticCanvas.prototype,T.Observable),t(T.StaticCanvas.prototype,T.Collection),t(T.StaticCanvas.prototype,T.DataURLExporter),t(T.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=o();if(!e||!e.getContext)return null;var i=e.getContext("2d");return i&&"setLineDash"===t?void 0!==i.setLineDash:null}}),T.StaticCanvas.prototype.toJSON=T.StaticCanvas.prototype.toObject,T.isLikelyNode&&(T.StaticCanvas.prototype.createPNGStream=function(){var t=a(this.lowerCanvasEl);return t&&t.createPNGStream()},T.StaticCanvas.prototype.createJPEGStream=function(t){var e=a(this.lowerCanvasEl);return e&&e.createJPEGStream(t)})}}(),T.BaseBrush=T.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(t){var e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])},_setShadow:function(){if(this.shadow){var t=this.canvas,e=this.shadow,i=t.contextTop,n=t.getZoom();t&&t._isRetinaScaling()&&(n*=T.devicePixelRatio),i.shadowColor=e.color,i.shadowBlur=e.blur*n,i.shadowOffsetX=e.offsetX*n,i.shadowOffsetY=e.offsetY*n}},needsFullRender:function(){return new T.Color(this.color).getAlpha()<1||!!this.shadow},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0},_isOutSideCanvas:function(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}),T.PencilBrush=T.util.createClass(T.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(t){this.canvas=t,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(t,e,i){var n=e.midPointFrom(i);return t.quadraticCurveTo(e.x,e.y,n.x,n.y),n},onMouseDown:function(t,e){this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],this._prepareForDrawing(t),this._captureDrawingPath(t),this._render())},onMouseMove:function(t,e){if(this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._captureDrawingPath(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var i=this._points,n=i.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(r,i[n-2],i[n-1],!0),r.stroke(),r.restore()}},onMouseUp:function(t){return!this.canvas._isMainEvent(t.e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)},_prepareForDrawing:function(t){var e=new T.Point(t.x,t.y);this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1])||(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),0))},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(t){var e=new T.Point(t.x,t.y);return this._addPoint(e)},_render:function(t){var e,i,n=this._points[0],r=this._points[1];if(t=t||this.canvas.contextTop,this._saveAndTransform(t),t.beginPath(),2===this._points.length&&n.x===r.x&&n.y===r.y){var s=this.width/1e3;n=new T.Point(n.x,n.y),r=new T.Point(r.x,r.y),n.x-=s,r.x+=s}for(t.moveTo(n.x,n.y),e=1,i=this._points.length;e=r&&(a=t[i],o.push(a));return o.push(t[s]),o},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var t=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(t))this.canvas.requestRenderAll();else{var e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}}),T.CircleBrush=T.util.createClass(T.BaseBrush,{width:10,initialize:function(t){this.canvas=t,this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop;this._saveAndTransform(i),this.dot(i,e),i.restore()},dot:function(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()},onMouseDown:function(t){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)},_render:function(){var t,e,i=this.canvas.contextTop,n=this.points;for(this._saveAndTransform(i),t=0,e=n.length;t0&&!this.preserveObjectStacking){e=[],i=[];for(var r=0,s=this._objects.length;r1&&(this._activeObject._objects=i),e.push.apply(e,i)}else e=this._objects;return e},renderAll:function(){!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_normalizePointer:function(t,e){var i=t.calcTransformMatrix(),n=T.util.invertTransform(i),r=this.restorePointerVpt(e);return T.util.transformPoint(r,n)},isTargetTransparent:function(t,e,i){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var n=this._normalizePointer(t,{x:e,y:i}),r=Math.max(t.cacheTranslationX+n.x*t.zoomX,0),s=Math.max(t.cacheTranslationY+n.y*t.zoomY,0);return T.util.isTransparent(t._cacheContext,Math.round(r),Math.round(s),this.targetFindTolerance)}var a=this.contextCache,o=t.selectionBackgroundColor,l=this.viewportTransform;return t.selectionBackgroundColor="",this.clearContext(a),a.save(),a.transform(l[0],l[1],l[2],l[3],l[4],l[5]),t.render(a),a.restore(),t.selectionBackgroundColor=o,T.util.isTransparent(a,e,i,this.targetFindTolerance)},_isSelectionKeyPressed:function(t){return Array.isArray(this.selectionKey)?!!this.selectionKey.find((function(e){return!0===t[e]})):t[this.selectionKey]},_shouldClearSelection:function(t,e){var i=this.getActiveObjects(),n=this._activeObject;return!e||e&&n&&i.length>1&&-1===i.indexOf(e)&&n!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&n&&n!==e},_shouldCenterTransform:function(t,e,i){var n;if(t)return"scale"===e||"scaleX"===e||"scaleY"===e||"resizing"===e?n=this.centeredScaling||t.centeredScaling:"rotate"===e&&(n=this.centeredRotation||t.centeredRotation),n?!i:i},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};return"ml"===e||"tl"===e||"bl"===e?i.x="right":"mr"!==e&&"tr"!==e&&"br"!==e||(i.x="left"),"tl"===e||"mt"===e||"tr"===e?i.y="bottom":"bl"!==e&&"mb"!==e&&"br"!==e||(i.y="top"),i},_getActionFromCorner:function(t,e,i,n){if(!e||!t)return"drag";var r=n.controls[e];return r.getActionName(i,r,n)},_setupCurrentTransform:function(t,i,n){if(i){var r=this.getPointer(t),s=i.__corner,a=i.controls[s],o=n&&s?a.getActionHandler(t,i,a):T.controlsUtils.dragHandler,l=this._getActionFromCorner(n,s,t,i),h=this._getOriginFromCorner(i,s),c=t[this.centeredKey],d={target:i,action:l,actionHandler:o,corner:s,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:r.x-i.left,offsetY:r.y-i.top,originX:h.x,originY:h.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:e(i.angle),width:i.width*i.scaleX,shiftKey:t.shiftKey,altKey:c,original:T.util.saveObjectTransform(i)};this._shouldCenterTransform(i,l,c)&&(d.originX="center",d.originY="center"),d.original.originX=h.x,d.original.originY=h.y,this._currentTransform=d,this._beforeTransform(t)}},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_drawSelection:function(t){var e=this._groupSelector,i=new T.Point(e.ex,e.ey),n=T.util.transformPoint(i,this.viewportTransform),r=new T.Point(e.ex+e.left,e.ey+e.top),s=T.util.transformPoint(r,this.viewportTransform),a=Math.min(n.x,s.x),o=Math.min(n.y,s.y),l=Math.max(n.x,s.x),h=Math.max(n.y,s.y),c=this.selectionLineWidth/2;this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(a,o,l-a,h-o)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,a+=c,o+=c,l-=c,h-=c,T.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(a,o,l-a,h-o))},findTarget:function(t,e){if(!this.skipTargetFind){var n,r,s=this.getPointer(t,!0),a=this._activeObject,o=this.getActiveObjects(),l=i(t),h=o.length>1&&!e||1===o.length;if(this.targets=[],h&&a._findTargetCorner(s,l))return a;if(o.length>1&&!e&&a===this._searchPossibleTargets([a],s))return a;if(1===o.length&&a===this._searchPossibleTargets([a],s)){if(!this.preserveObjectStacking)return a;n=a,r=this.targets,this.targets=[]}var c=this._searchPossibleTargets(this._objects,s);return t[this.altSelectionKey]&&c&&n&&c!==n&&(c=n,this.targets=r),c}},_checkTarget:function(t,e,i){if(e&&e.visible&&e.evented&&e.containsPoint(t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;if(!this.isTargetTransparent(e,i.x,i.y))return!0}},_searchPossibleTargets:function(t,e){for(var i,n,r=t.length;r--;){var s=t[r],a=s.group?this._normalizePointer(s.group,e):e;if(this._checkTarget(a,s,e)){(i=t[r]).subTargetCheck&&i instanceof T.Group&&(n=this._searchPossibleTargets(i._objects,e))&&this.targets.push(n);break}}return i},restorePointerVpt:function(t){return T.util.transformPoint(t,T.util.invertTransform(this.viewportTransform))},getPointer:function(e,i){if(this._absolutePointer&&!i)return this._absolutePointer;if(this._pointer&&i)return this._pointer;var n,r=t(e),s=this.upperCanvasEl,a=s.getBoundingClientRect(),o=a.width||0,l=a.height||0;o&&l||("top"in a&&"bottom"in a&&(l=Math.abs(a.top-a.bottom)),"right"in a&&"left"in a&&(o=Math.abs(a.right-a.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,i||(r=this.restorePointerVpt(r));var h=this.getRetinaScaling();return 1!==h&&(r.x/=h,r.y/=h),n=0===o||0===l?{width:1,height:1}:{width:s.width/o,height:s.height/l},{x:r.x*n.width,y:r.y*n.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),e=this.lowerCanvasEl,i=this.upperCanvasEl;i?i.className="":(i=this._createCanvasElement(),this.upperCanvasEl=i),T.util.addClass(i,"upper-canvas "+t),this.wrapperEl.appendChild(i),this._copyCanvasStyle(e,i),this._applyCanvasStyle(i),this.contextTop=i.getContext("2d")},getTopContext:function(){return this.contextTop},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=T.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),T.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),T.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.width||t.width,i=this.height||t.height;T.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=e,t.height=i,T.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;return t?"activeSelection"===t.type&&t._objects?t._objects.slice(0):[t]:[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,e){var i=!1,n=this.getActiveObjects(),r=[],s=[];t.forEach((function(t){-1===n.indexOf(t)&&(i=!0,t.fire("deselected",{e:e,target:t}),s.push(t))})),n.forEach((function(n){-1===t.indexOf(n)&&(i=!0,n.fire("selected",{e:e,target:n}),r.push(n))})),t.length>0&&n.length>0?i&&this.fire("selection:updated",{e:e,selected:r,deselected:s}):n.length>0?this.fire("selection:created",{e:e,selected:r}):t.length>0&&this.fire("selection:cleared",{e:e,deselected:s})},setActiveObject:function(t,e){var i=this.getActiveObjects();return this._setActiveObject(t,e),this._fireSelectionEvents(i,e),this},_setActiveObject:function(t,e){return this._activeObject!==t&&!!this._discardActiveObject(e,t)&&!t.onSelect({e:e})&&(this._activeObject=t,!0)},_discardActiveObject:function(t,e){var i=this._activeObject;if(i){if(i.onDeselect({e:t,object:e}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var e=this.getActiveObjects(),i=this.getActiveObject();return e.length&&this.fire("before:selection:cleared",{target:i,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(e,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach(function(t){T.util.cleanUpJsdomNode(this[t]),this[t]=void 0}.bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,T.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var e=this._activeObject;e&&e._renderControls(t)},_toObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(t),r=this.callSuper("_toObject",t,e,i);return this._unwindGroupTransformOnObject(t,n),r},_realizeGroupTransformOnObject:function(t){if(t.group&&"activeSelection"===t.group.type&&this._activeObject===t.group){var e={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach((function(i){e[i]=t[i]})),T.util.addTransformToObject(t,this._activeObject.calcOwnMatrix()),e}return null},_unwindGroupTransformOnObject:function(t,e){e&&t.set(e)},_setSVGObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(e);this.callSuper("_setSVGObject",t,e,i),this._unwindGroupTransformOnObject(e,n)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),T.StaticCanvas.prototype.setViewportTransform.call(this,t)}}),T.StaticCanvas)"prototype"!==n&&(T.Canvas[n]=T.StaticCanvas[n])}(),function(){var t=T.util.addListener,e=T.util.removeListener,i={passive:!1};function n(t,e){return t.button&&t.button===e-1}T.util.object.extend(T.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(t,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(t,e){var n=this.upperCanvasEl,r=this._getEventPrefix();t(T.window,"resize",this._onResize),t(n,r+"down",this._onMouseDown),t(n,r+"move",this._onMouseMove,i),t(n,r+"out",this._onMouseOut),t(n,r+"enter",this._onMouseEnter),t(n,"wheel",this._onMouseWheel),t(n,"contextmenu",this._onContextMenu),t(n,"dblclick",this._onDoubleClick),t(n,"dragover",this._onDragOver),t(n,"dragenter",this._onDragEnter),t(n,"dragleave",this._onDragLeave),t(n,"drop",this._onDrop),this.enablePointerEvents||t(n,"touchstart",this._onTouchStart,i),"undefined"!=typeof eventjs&&e in eventjs&&(eventjs[e](n,"gesture",this._onGesture),eventjs[e](n,"drag",this._onDrag),eventjs[e](n,"orientation",this._onOrientationChange),eventjs[e](n,"shake",this._onShake),eventjs[e](n,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(e,"remove");var t=this._getEventPrefix();e(T.document,t+"up",this._onMouseUp),e(T.document,"touchend",this._onTouchEnd,i),e(T.document,t+"move",this._onMouseMove,i),e(T.document,"touchmove",this._onMouseMove,i)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t){this.__onMouseWheel(t)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t}),this._hoveredTarget=null,e&&e.fire("mouseout",{e:t});var i=this;this._hoveredTargets.forEach((function(n){i.fire("mouse:out",{target:e,e:t}),n&&e.fire("mouseout",{e:t})})),this._hoveredTargets=[],this._iTextInstances&&this._iTextInstances.forEach((function(t){t.isEditing&&t.hiddenTextarea.focus()}))},_onMouseEnter:function(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",{target:null,e:t}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onDragOver:function(t){t.preventDefault();var e=this._simpleEventHandler("dragover",t);this._fireEnterLeaveEvents(e,t)},_onDrop:function(t){return this._simpleEventHandler("drop:before",t),this._simpleEventHandler("drop",t)},_onContextMenu:function(t){return this.stopContextMenu&&(t.stopPropagation(),t.preventDefault()),!1},_onDoubleClick:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData(t)},getPointerId:function(t){var e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1},_isMainEvent:function(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)},_onTouchStart:function(n){n.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(n)),this.__onMouseDown(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();t(T.document,"touchend",this._onTouchEnd,i),t(T.document,"touchmove",this._onMouseMove,i),e(r,s+"down",this._onMouseDown)},_onMouseDown:function(n){this.__onMouseDown(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();e(r,s+"move",this._onMouseMove,i),t(T.document,s+"up",this._onMouseUp),t(T.document,s+"move",this._onMouseMove,i)},_onTouchEnd:function(n){if(!(n.touches.length>0)){this.__onMouseUp(n),this._resetTransformEventData(),this.mainTouchId=null;var r=this._getEventPrefix();e(T.document,"touchend",this._onTouchEnd,i),e(T.document,"touchmove",this._onMouseMove,i);var s=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((function(){t(s.upperCanvasEl,r+"down",s._onMouseDown),s._willAddMouseDown=0}),400)}},_onMouseUp:function(n){this.__onMouseUp(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();this._isMainEvent(n)&&(e(T.document,s+"up",this._onMouseUp),e(T.document,s+"move",this._onMouseMove,i),t(r,s+"move",this._onMouseMove,i))},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t){var e=this._activeObject;return!!(!!e!=!!t||e&&t&&e!==t)||(e&&e.isEditing,!1)},__onMouseUp:function(t){var e,i=this._currentTransform,r=this._groupSelector,s=!1,a=!r||0===r.left&&0===r.top;if(this._cacheTransformEventData(t),e=this._target,this._handleEvent(t,"up:before"),n(t,3))this.fireRightClick&&this._handleEvent(t,"up",3,a);else{if(n(t,2))return this.fireMiddleClick&&this._handleEvent(t,"up",2,a),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)this._onMouseUpInDrawingMode(t);else if(this._isMainEvent(t)){if(i&&(this._finalizeCurrentTransform(t),s=i.actionPerformed),!a){var o=e===this._activeObject;this._maybeGroupObjects(t),s||(s=this._shouldRender(e)||!o&&e===this._activeObject)}var l,h;if(e){if(l=e._findTargetCorner(this.getPointer(t,!0),T.util.isTouchEvent(t)),e.selectable&&e!==this._activeObject&&"up"===e.activeOn)this.setActiveObject(e,t),s=!0;else{var c=e.controls[l],d=c&&c.getMouseUpHandler(t,e,c);d&&d(t,i,(h=this.getPointer(t)).x,h.y)}e.isMoving=!1}if(i&&(i.target!==e||i.corner!==l)){var u=i.target&&i.target.controls[i.corner],f=u&&u.getMouseUpHandler(t,e,c);h=h||this.getPointer(t),f&&f(t,i,h.x,h.y)}this._setCursorFromEvent(t,e),this._handleEvent(t,"up",1,a),this._groupSelector=null,this._currentTransform=null,e&&(e.__corner=0),s?this.requestRenderAll():a||this.renderTop()}}},_simpleEventHandler:function(t,e){var i=this.findTarget(e),n=this.targets,r={e:e,target:i,subTargets:n};if(this.fire(t,r),i&&i.fire(t,r),!n)return i;for(var s=0;s1&&(e=new T.ActiveSelection(i.reverse(),{canvas:this}),this.setActiveObject(e,t))},_collectObjects:function(t){for(var e,i=[],n=this._groupSelector.ex,r=this._groupSelector.ey,s=n+this._groupSelector.left,a=r+this._groupSelector.top,o=new T.Point(v(n,s),v(r,a)),l=new T.Point(y(n,s),y(r,a)),h=!this.selectionFullyContained,c=n===s&&r===a,d=this._objects.length;d--&&!((e=this._objects[d])&&e.selectable&&e.visible&&(h&&e.intersectsWithRect(o,l,!0)||e.isContainedWithinRect(o,l,!0)||h&&e.containsPoint(o,null,!0)||h&&e.containsPoint(l,null,!0))&&(i.push(e),c)););return i.length>1&&(i=i.filter((function(e){return!e.onSelect({e:t})}))),i},_maybeGroupObjects:function(t){this.selection&&this._groupSelector&&this._groupSelectedObjects(t),this.setCursor(this.defaultCursor),this._groupSelector=null}}),T.util.object.extend(T.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,n=(t.multiplier||1)*(t.enableRetinaScaling?this.getRetinaScaling():1),r=this.toCanvasElement(n,t);return T.util.toDataURL(r,e,i)},toCanvasElement:function(t,e){t=t||1;var i=((e=e||{}).width||this.width)*t,n=(e.height||this.height)*t,r=this.getZoom(),s=this.width,a=this.height,o=r*t,l=this.viewportTransform,h=(l[4]-(e.left||0))*t,c=(l[5]-(e.top||0))*t,d=this.interactive,u=[o,0,0,o,h,c],f=this.enableRetinaScaling,g=T.util.createCanvasElement(),m=this.contextTop;return g.width=i,g.height=n,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=u,this.width=i,this.height=n,this.calcViewportBoundaries(),this.renderCanvas(g.getContext("2d"),this._objects),this.viewportTransform=l,this.width=s,this.height=a,this.calcViewportBoundaries(),this.interactive=d,this.enableRetinaScaling=f,this.contextTop=m,g}}),T.util.object.extend(T.StaticCanvas.prototype,{loadFromJSON:function(t,e,i){if(t){var n="string"==typeof t?JSON.parse(t):T.util.object.clone(t),r=this,s=n.clipPath,a=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete n.clipPath,this._enlivenObjects(n.objects,(function(t){r.clear(),r._setBgOverlay(n,(function(){s?r._enlivenObjects([s],(function(i){r.clipPath=i[0],r.__setupCanvas.call(r,n,t,a,e)})):r.__setupCanvas.call(r,n,t,a,e)}))}),i),this}},__setupCanvas:function(t,e,i,n){var r=this;e.forEach((function(t,e){r.insertAt(t,e)})),this.renderOnAddRemove=i,delete t.objects,delete t.backgroundImage,delete t.overlayImage,delete t.background,delete t.overlay,this._setOptions(t),this.renderAll(),n&&n()},_setBgOverlay:function(t,e){var i={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(t.backgroundImage||t.overlayImage||t.background||t.overlay){var n=function(){i.backgroundImage&&i.overlayImage&&i.backgroundColor&&i.overlayColor&&e&&e()};this.__setBgOverlay("backgroundImage",t.backgroundImage,i,n),this.__setBgOverlay("overlayImage",t.overlayImage,i,n),this.__setBgOverlay("backgroundColor",t.background,i,n),this.__setBgOverlay("overlayColor",t.overlay,i,n)}else e&&e()},__setBgOverlay:function(t,e,i,n){var r=this;if(!e)return i[t]=!0,void(n&&n());"backgroundImage"===t||"overlayImage"===t?T.util.enlivenObjects([e],(function(e){r[t]=e[0],i[t]=!0,n&&n()})):this["set"+T.util.string.capitalize(t,!0)](e,(function(){i[t]=!0,n&&n()}))},_enlivenObjects:function(t,e,i){t&&0!==t.length?T.util.enlivenObjects(t,(function(t){e&&e(t)}),null,i):e&&e([])},_toDataURL:function(t,e){this.clone((function(i){e(i.toDataURL(t))}))},_toDataURLWithMultiplier:function(t,e,i){this.clone((function(n){i(n.toDataURLWithMultiplier(t,e))}))},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData((function(e){e.loadFromJSON(i,(function(){t&&t(e)}))}))},cloneWithoutData:function(t){var e=T.util.createCanvasElement();e.width=this.width,e.height=this.height;var i=new T.Canvas(e);this.backgroundImage?(i.setBackgroundImage(this.backgroundImage.src,(function(){i.renderAll(),t&&t(i)})),i.backgroundImageOpacity=this.backgroundImageOpacity,i.backgroundImageStretch=this.backgroundImageStretch):t&&t(i)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,s=e.util.string.capitalize,a=e.util.degreesToRadians,o=!e.isLikelyNode;e.Object||(e.Object=e.util.createClass(e.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:o,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(t){t&&this.setOptions(t)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=e.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(t){var i=e.perfLimitSizeTotal,n=t.width,r=t.height,s=e.maxCacheSideLimit,a=e.minCacheSideLimit;if(n<=s&&r<=s&&n*r<=i)return nc&&(t.zoomX/=n/c,t.width=c,t.capped=!0),r>d&&(t.zoomY/=r/d,t.height=d,t.capped=!0),t},_getCacheCanvasDimensions:function(){var t=this.getTotalObjectScaling(),e=this._getTransformedDimensions(0,0),i=e.x*t.scaleX/this.scaleX,n=e.y*t.scaleY/this.scaleY;return{width:i+2,height:n+2,zoomX:t.scaleX,zoomY:t.scaleY,x:i,y:n}},_updateCacheCanvas:function(){var t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){var i=t._currentTransform.target,n=t._currentTransform.action;if(this===i&&n.slice&&"scale"===n.slice(0,5))return!1}var r,s,a=this._cacheCanvas,o=this._limitCacheSize(this._getCacheCanvasDimensions()),l=e.minCacheSideLimit,h=o.width,c=o.height,d=o.zoomX,u=o.zoomY,f=h!==this.cacheWidth||c!==this.cacheHeight,g=this.zoomX!==d||this.zoomY!==u,m=f||g,p=0,_=0,v=!1;if(f){var y=this._cacheCanvas.width,w=this._cacheCanvas.height,E=h>y||c>w;v=E||(h<.9*y||c<.9*w)&&y>l&&w>l,E&&!o.capped&&(h>l||c>l)&&(p=.1*h,_=.1*c)}return this instanceof e.Text&&this.path&&(m=!0,v=!0,p+=this.getHeightOfLine(0)*this.zoomX,_+=this.getHeightOfLine(0)*this.zoomY),!!m&&(v?(a.width=Math.ceil(h+p),a.height=Math.ceil(c+_)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,a.width,a.height)),r=o.x/2,s=o.y/2,this.cacheTranslationX=Math.round(a.width/2-r)+r,this.cacheTranslationY=Math.round(a.height/2-s)+s,this.cacheWidth=h,this.cacheHeight=c,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(d,u),this.zoomX=d,this.zoomY=u,!0)},setOptions:function(t){this._setOptions(t),this._initGradient(t.fill,"fill"),this._initGradient(t.stroke,"stroke"),this._initPattern(t.fill,"fill"),this._initPattern(t.stroke,"stroke")},transform:function(t){var e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,n={type:this.type,version:e.version,originX:this.originX,originY:this.originY,left:r(this.left,i),top:r(this.top,i),width:r(this.width,i),height:r(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:r(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:r(this.strokeMiterLimit,i),scaleX:r(this.scaleX,i),scaleY:r(this.scaleY,i),angle:r(this.angle,i),flipX:this.flipX,flipY:this.flipY,opacity:r(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:r(this.skewX,i),skewY:r(this.skewY,i)};return this.clipPath&&!this.clipPath.excludeFromExport&&(n.clipPath=this.clipPath.toObject(t),n.clipPath.inverted=this.clipPath.inverted,n.clipPath.absolutePositioned=this.clipPath.absolutePositioned),e.util.populateWithProperties(this,n,t),this.includeDefaultValues||(n=this._removeDefaultValues(n)),n},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype;return i.stateProperties.forEach((function(e){"left"!==e&&"top"!==e&&(t[e]===i[e]&&delete t[e],Array.isArray(t[e])&&Array.isArray(i[e])&&0===t[e].length&&0===i[e].length&&delete t[e])})),t},toString:function(){return"#"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var t=e.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(t.scaleX),scaleY:Math.abs(t.scaleY)}},getTotalObjectScaling:function(){var t=this.getObjectScaling(),e=t.scaleX,i=t.scaleY;if(this.canvas){var n=this.canvas.getZoom(),r=this.canvas.getRetinaScaling();e*=n*r,i*=n*r}return{scaleX:e,scaleY:i}},getObjectOpacity:function(){var t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t},_set:function(t,i){var n="scaleX"===t||"scaleY"===t,r=this[t]!==i,s=!1;return n&&(i=this._constrainScale(i)),"scaleX"===t&&i<0?(this.flipX=!this.flipX,i*=-1):"scaleY"===t&&i<0?(this.flipY=!this.flipY,i*=-1):"shadow"!==t||!i||i instanceof e.Shadow?"dirty"===t&&this.group&&this.group.set("dirty",i):i=new e.Shadow(i),this[t]=i,r&&(s=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(t)>-1?(this.dirty=!0,s&&this.group.set("dirty",!0)):s&&this.stateProperties.indexOf(t)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:e.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible},render:function(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(t),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),t.restore())},renderCache:function(t){t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,t.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this._cacheContext=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth},hasFill:function(){return this.fill&&"transparent"!==this.fill},needsItsOwnCache:function(){return!("stroke"!==this.paintFirst||!this.hasFill()||!this.hasStroke()||"object"!=typeof this.shadow)||!!this.clipPath},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawClipPathOnCache:function(t,i){if(t.save(),i.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",i.absolutePositioned){var n=e.util.invertTransform(this.calcTransformMatrix());t.transform(n[0],n[1],n[2],n[3],n[4],n[5])}i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},drawObject:function(t,e){var i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath),this.fill=i,this.stroke=n},_drawClipPath:function(t,e){e&&(e.canvas=this.canvas,e.shouldCache(),e._transformDone=!0,e.renderCache({forClipping:!0}),this.drawClipPathOnCache(t,e))},drawCacheOnCanvas:function(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(t){if(this.isNotVisible())return!1;if(this._cacheCanvas&&this._cacheContext&&!t&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&this._cacheContext&&!t){var e=this.cacheWidth/this.zoomX,i=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-e/2,-i/2,e,i)}return!0}return!1},_renderBackground:function(t){if(this.backgroundColor){var e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}},_setOpacity:function(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity},_setStrokeStyles:function(t,e){var i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,i.toLive?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)},_setFillStyles:function(t,e){var i=e.fill;i&&(i.toLive?(t.fillStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,e.fill)):t.fillStyle=i)},_setClippingProperties:function(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"},_setLineDash:function(t,e){e&&0!==e.length&&(1&e.length&&e.push.apply(e,e),t.setLineDash(e))},_renderControls:function(t,i){var n,r,s,o=this.getViewportTransform(),l=this.calcTransformMatrix();r=void 0!==(i=i||{}).hasBorders?i.hasBorders:this.hasBorders,s=void 0!==i.hasControls?i.hasControls:this.hasControls,l=e.util.multiplyTransformMatrices(o,l),n=e.util.qrDecompose(l),t.save(),t.translate(n.translateX,n.translateY),t.lineWidth=1*this.borderScaleFactor,this.group||(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(n.angle-=180),t.rotate(a(this.group?n.angle:this.angle)),i.forActiveSelection||this.group?r&&this.drawBordersInGroup(t,n,i):r&&this.drawBorders(t,i),s&&this.drawControls(t,i),t.restore()},_setShadow:function(t){if(this.shadow){var i,n=this.shadow,r=this.canvas,s=r&&r.viewportTransform[0]||1,a=r&&r.viewportTransform[3]||1;i=n.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),r&&r._isRetinaScaling()&&(s*=e.devicePixelRatio,a*=e.devicePixelRatio),t.shadowColor=n.color,t.shadowBlur=n.blur*e.browserShadowBlurConstant*(s+a)*(i.scaleX+i.scaleY)/4,t.shadowOffsetX=n.offsetX*s*i.scaleX,t.shadowOffsetY=n.offsetY*a*i.scaleY}},_removeShadow:function(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)},_applyPatternGradientTransform:function(t,e){if(!e||!e.toLive)return{offsetX:0,offsetY:0};var i=e.gradientTransform||e.patternTransform,n=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,n,r):t.transform(1,0,0,1,n,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:n,offsetY:r}},_renderPaintInOrder:function(t){"stroke"===this.paintFirst?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))},_render:function(){},_renderFill:function(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())},_renderStroke:function(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform&&this.group){var e=this.getObjectScaling();t.scale(1/e.scaleX,1/e.scaleY)}else this.strokeUniform&&t.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}},_applyPatternForTransformedGradient:function(t,i){var n,r=this._limitCacheSize(this._getCacheCanvasDimensions()),s=e.util.createCanvasElement(),a=this.canvas.getRetinaScaling(),o=r.x/this.scaleX/a,l=r.y/this.scaleY/a;s.width=o,s.height=l,(n=s.getContext("2d")).beginPath(),n.moveTo(0,0),n.lineTo(o,0),n.lineTo(o,l),n.lineTo(0,l),n.closePath(),n.translate(o/2,l/2),n.scale(r.zoomX/this.scaleX/a,r.zoomY/this.scaleY/a),this._applyPatternGradientTransform(n,i),n.fillStyle=i.toLive(t),n.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(a*this.scaleX/r.zoomX,a*this.scaleY/r.zoomY),t.strokeStyle=n.createPattern(s,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var t=e.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",t.scaleX),this.set("scaleY",t.scaleY),this.angle=t.angle,this.skewX=t.skewX,this.skewY=0}},_removeTransformMatrix:function(t){var i=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),i=e.util.transformPoint(i,this.transformMatrix)),this.transformMatrix=null,t&&(this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this.cropX=t.cropX,this.cropY=t.cropY,i.x+=t.offsetLeft,i.y+=t.offsetTop,this.width=t.width,this.height=t.height),this.setPositionByOrigin(i,"center","center")},clone:function(t,i){var n=this.toObject(i);this.constructor.fromObject?this.constructor.fromObject(n,t):e.Object._fromObject("Object",n,t)},cloneAsImage:function(t,i){var n=this.toCanvasElement(i);return t&&t(new e.Image(n)),this},toCanvasElement:function(t){t||(t={});var i=e.util,n=i.saveObjectTransform(this),r=this.group,s=this.shadow,a=Math.abs,o=(t.multiplier||1)*(t.enableRetinaScaling?e.devicePixelRatio:1);delete this.group,t.withoutTransform&&i.resetObjectTransform(this),t.withoutShadow&&(this.shadow=null);var l,h,c,d,u=e.util.createCanvasElement(),f=this.getBoundingRect(!0,!0),g=this.shadow,m={x:0,y:0};g&&(h=g.blur,l=g.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),m.x=2*Math.round(a(g.offsetX)+h)*a(l.scaleX),m.y=2*Math.round(a(g.offsetY)+h)*a(l.scaleY)),c=f.width+m.x,d=f.height+m.y,u.width=Math.ceil(c),u.height=Math.ceil(d);var p=new e.StaticCanvas(u,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});"jpeg"===t.format&&(p.backgroundColor="#fff"),this.setPositionByOrigin(new e.Point(p.width/2,p.height/2),"center","center");var _=this.canvas;p.add(this);var v=p.toCanvasElement(o||1,t);return this.shadow=s,this.set("canvas",_),r&&(this.group=r),this.set(n).setCoords(),p._objects=[],p.dispose(),p=null,v},toDataURL:function(t){return t||(t={}),e.util.toDataURL(this.toCanvasElement(t),t.format||"png",t.quality||1)},isType:function(t){return arguments.length>1?Array.from(arguments).includes(this.type):this.type===t},complexity:function(){return 1},toJSON:function(t){return this.toObject(t)},rotate:function(t){var e=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return e&&this._setOriginToCenter(),this.set("angle",t),e&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var n=new e.Point(i.x,i.y),r=this._getLeftTopCoords();return this.angle&&(n=e.util.rotatePoint(n,r,a(-this.angle))),{x:n.x-r.x,y:n.y-r.y}},_setupCompositeOperation:function(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){e.runningAnimations&&e.runningAnimations.cancelByTarget(this)}}),e.util.createAccessors&&e.util.createAccessors(e.Object),i(e.Object.prototype,e.Observable),e.Object.NUM_FRACTION_DIGITS=2,e.Object.ENLIVEN_PROPS=["clipPath"],e.Object._fromObject=function(t,i,r,s){var a=e[t];i=n(i,!0),e.util.enlivenPatterns([i.fill,i.stroke],(function(t){void 0!==t[0]&&(i.fill=t[0]),void 0!==t[1]&&(i.stroke=t[1]),e.util.enlivenObjectEnlivables(i,i,(function(){var t=s?new a(i[s],i):new a(i);r&&r(t)}))}))},e.Object.__uid=0)}(e),w=T.util.degreesToRadians,E={left:-.5,center:0,right:.5},C={top:-.5,center:0,bottom:.5},T.util.object.extend(T.Object.prototype,{translateToGivenOrigin:function(t,e,i,n,r){var s,a,o,l=t.x,h=t.y;return"string"==typeof e?e=E[e]:e-=.5,"string"==typeof n?n=E[n]:n-=.5,"string"==typeof i?i=C[i]:i-=.5,"string"==typeof r?r=C[r]:r-=.5,a=r-i,((s=n-e)||a)&&(o=this._getTransformedDimensions(),l=t.x+s*o.x,h=t.y+a*o.y),new T.Point(l,h)},translateToCenterPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,e,i,"center","center");return this.angle?T.util.rotatePoint(n,t,w(this.angle)):n},translateToOriginPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,"center","center",e,i);return this.angle?T.util.rotatePoint(n,t,w(this.angle)):n},getCenterPoint:function(){var t=new T.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(t,e,i){var n,r,s=this.getCenterPoint();return n=void 0!==e&&void 0!==i?this.translateToGivenOrigin(s,"center","center",e,i):new T.Point(this.left,this.top),r=new T.Point(t.x,t.y),this.angle&&(r=T.util.rotatePoint(r,s,-w(this.angle))),r.subtractEquals(n)},setPositionByOrigin:function(t,e,i){var n=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(n,this.originX,this.originY);this.set("left",r.x),this.set("top",r.y)},adjustPosition:function(t){var e,i,n=w(this.angle),r=this.getScaledWidth(),s=T.util.cos(n)*r,a=T.util.sin(n)*r;e="string"==typeof this.originX?E[this.originX]:this.originX-.5,i="string"==typeof t?E[t]:t-.5,this.left+=s*(i-e),this.top+=a*(i-e),this.setCoords(),this.originX=t},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center",this.originY="center",this.left=t.x,this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=t.x,this.top=t.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}}),function(){var t=T.util,e=t.degreesToRadians,i=t.multiplyTransformMatrices,n=t.transformPoint;t.object.extend(T.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(t,e){return e?t?this.calcACoords():this.calcLineCoords():(this.aCoords&&this.lineCoords||this.setCoords(!0),t?this.aCoords:this.lineCoords)},getCoords:function(t,e){return i=this._getCoords(t,e),[new T.Point(i.tl.x,i.tl.y),new T.Point(i.tr.x,i.tr.y),new T.Point(i.br.x,i.br.y),new T.Point(i.bl.x,i.bl.y)];var i},intersectsWithRect:function(t,e,i,n){var r=this.getCoords(i,n);return"Intersection"===T.Intersection.intersectPolygonRectangle(r,t,e).status},intersectsWithObject:function(t,e,i){return"Intersection"===T.Intersection.intersectPolygonPolygon(this.getCoords(e,i),t.getCoords(e,i)).status||t.isContainedWithinObject(this,e,i)||this.isContainedWithinObject(t,e,i)},isContainedWithinObject:function(t,e,i){for(var n=this.getCoords(e,i),r=e?t.aCoords:t.lineCoords,s=0,a=t._getImageLines(r);s<4;s++)if(!t.containsPoint(n[s],a))return!1;return!0},isContainedWithinRect:function(t,e,i,n){var r=this.getBoundingRect(i,n);return r.left>=t.x&&r.left+r.width<=e.x&&r.top>=t.y&&r.top+r.height<=e.y},containsPoint:function(t,e,i,n){var r=this._getCoords(i,n),s=(e=e||this._getImageLines(r),this._findCrossPoints(t,e));return 0!==s&&s%2==1},isOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.getCoords(!0,t).some((function(t){return t.x<=i.x&&t.x>=e.x&&t.y<=i.y&&t.y>=e.y}))||!!this.intersectsWithRect(e,i,!0,t)||this._containsCenterOfCanvas(e,i,t)},_containsCenterOfCanvas:function(t,e,i){var n={x:(t.x+e.x)/2,y:(t.y+e.y)/2};return!!this.containsPoint(n,null,!0,i)},isPartiallyOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.intersectsWithRect(e,i,!0,t)||this.getCoords(!0,t).every((function(t){return(t.x>=i.x||t.x<=e.x)&&(t.y>=i.y||t.y<=e.y)}))&&this._containsCenterOfCanvas(e,i,t)},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,n,r,s=0;for(var a in e)if(!((r=e[a]).o.y=t.y&&r.d.y>=t.y||(r.o.x===r.d.x&&r.o.x>=t.x?n=r.o.x:(i=(r.d.y-r.o.y)/(r.d.x-r.o.x),n=-(t.y-0*t.x-(r.o.y-i*r.o.x))/(0-i)),n>=t.x&&(s+=1),2!==s)))break;return s},getBoundingRect:function(e,i){var n=this.getCoords(e,i);return t.makeBoundingBoxFromPoints(n)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){return Math.abs(t)\n')}},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})},toClipPathSVG:function(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})},_createBaseClipPathSVGMarkup:function(t,e){var i=(e=e||{}).reviver,n=e.additionalTransform||"",r=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=r,i?i(t.join("")):t.join("")},_createBaseSVGMarkup:function(t,e){var i,n,r=(e=e||{}).noStyle,s=e.reviver,a=r?"":'style="'+this.getSvgStyles()+'" ',o=e.withShadow?'style="'+this.getSvgFilter()+'" ':"",l=this.clipPath,h=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",c=l&&l.absolutePositioned,d=this.stroke,u=this.fill,f=this.shadow,g=[],m=t.indexOf("COMMON_PARTS"),p=e.additionalTransform;return l&&(l.clipPathId="CLIPPATH_"+T.Object.__uid++,n='\n'+l.toClipPathSVG(s)+"\n"),c&&g.push("\n"),g.push("\n"),i=[a,h,r?"":this.addPaintOrder()," ",p?'transform="'+p+'" ':""].join(""),t[m]=i,u&&u.toLive&&g.push(u.toSVG(this)),d&&d.toLive&&g.push(d.toSVG(this)),f&&g.push(f.toSVG(this)),l&&g.push(n),g.push(t.join("")),g.push("\n"),c&&g.push("\n"),s?s(g.join("")):g.join("")},addPaintOrder:function(){return"fill"!==this.paintFirst?' paint-order="'+this.paintFirst+'" ':""}})}(),function(){var t=T.util.object.extend,e="stateProperties";function i(e,i,n){var r={};n.forEach((function(t){r[t]=e[t]})),t(e[i],r,!0)}function n(t,e,i){if(t===e)return!0;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(var r=0,s=t.length;r=0;l--)if(r=o[l],this.isControlVisible(r)&&(n=this._getImageLines(e?this.oCoords[r].touchCorner:this.oCoords[r].corner),0!==(i=this._findCrossPoints({x:s,y:a},n))&&i%2==1))return this.__corner=r,r;return!1},forEachControl:function(t){for(var e in this.controls)t(this.controls[e],e,this)},_setCornerCoords:function(){var t=this.oCoords;for(var e in t){var i=this.controls[e];t[e].corner=i.calcCornerCoords(this.angle,this.cornerSize,t[e].x,t[e].y,!1),t[e].touchCorner=i.calcCornerCoords(this.angle,this.touchCornerSize,t[e].x,t[e].y,!0)}},drawSelectionBackground:function(e){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;e.save();var i=this.getCenterPoint(),n=this._calculateCurrentDimensions(),r=this.canvas.viewportTransform;return e.translate(i.x,i.y),e.scale(1/r[0],1/r[3]),e.rotate(t(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-n.x/2,-n.y/2,n.x,n.y),e.restore(),this},drawBorders:function(t,e){e=e||{};var i=this._calculateCurrentDimensions(),n=this.borderScaleFactor,r=i.x+n,s=i.y+n,a=void 0!==e.hasControls?e.hasControls:this.hasControls,o=!1;return t.save(),t.strokeStyle=e.borderColor||this.borderColor,this._setLineDash(t,e.borderDashArray||this.borderDashArray),t.strokeRect(-r/2,-s/2,r,s),a&&(t.beginPath(),this.forEachControl((function(e,i,n){e.withConnection&&e.getVisibility(n,i)&&(o=!0,t.moveTo(e.x*r,e.y*s),t.lineTo(e.x*r+e.offsetX,e.y*s+e.offsetY))})),o&&t.stroke()),t.restore(),this},drawBordersInGroup:function(t,e,i){i=i||{};var n=T.util.sizeAfterTransform(this.width,this.height,e),r=this.strokeWidth,s=this.strokeUniform,a=this.borderScaleFactor,o=n.x+r*(s?this.canvas.getZoom():e.scaleX)+a,l=n.y+r*(s?this.canvas.getZoom():e.scaleY)+a;return t.save(),this._setLineDash(t,i.borderDashArray||this.borderDashArray),t.strokeStyle=i.borderColor||this.borderColor,t.strokeRect(-o/2,-l/2,o,l),t.restore(),this},drawControls:function(t,e){e=e||{},t.save();var i,n,r=this.canvas.getRetinaScaling();return t.setTransform(r,0,0,r,0,0),t.strokeStyle=t.fillStyle=e.cornerColor||this.cornerColor,this.transparentCorners||(t.strokeStyle=e.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(t,e.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(i=this.group.calcTransformMatrix()),this.forEachControl((function(r,s,a){n=a.oCoords[s],r.getVisibility(a,s)&&(i&&(n=T.util.transformPoint(n,i)),r.render(t,n.x,n.y,e,a))})),t.restore(),this},isControlVisible:function(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)},setControlVisible:function(t,e){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e,this},setControlsVisibility:function(t){for(var e in t||(t={}),t)this.setControlVisible(e,t[e]);return this},onDeselect:function(){},onSelect:function(){}})}(),T.util.object.extend(T.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.left,endValue:this.getCenterPoint().x,duration:this.FX_DURATION,onChange:function(e){t.set("left",e),s.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}})},fxCenterObjectV:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.top,endValue:this.getCenterPoint().y,duration:this.FX_DURATION,onChange:function(e){t.set("top",e),s.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}})},fxRemove:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(e){t.set("opacity",e),s.requestRenderAll(),r()},onComplete:function(){s.remove(t),n()}})}}),T.util.object.extend(T.Object.prototype,{animate:function(){if(arguments[0]&&"object"==typeof arguments[0]){var t,e,i=[],n=[];for(t in arguments[0])i.push(t);for(var r=0,s=i.length;r-1||r&&s.colorProperties.indexOf(r[1])>-1,o=r?this.get(r[0])[r[1]]:this.get(t);"from"in i||(i.from=o),a||(e=~e.indexOf("=")?o+parseFloat(e.replace("=","")):parseFloat(e));var l={target:this,startValue:i.from,endValue:e,byValue:i.by,easing:i.easing,duration:i.duration,abort:i.abort&&function(t,e,n){return i.abort.call(s,t,e,n)},onChange:function(e,a,o){r?s[r[0]][r[1]]=e:s.set(t,e),n||i.onChange&&i.onChange(e,a,o)},onComplete:function(t,e,r){n||(s.setCoords(),i.onComplete&&i.onComplete(t,e,r))}};return a?T.util.animateColor(l.startValue,l.endValue,l.duration,l):T.util.animate(l)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r={x1:1,x2:1,y1:1,y2:1};function s(t,e){var i=t.origin,n=t.axis1,r=t.axis2,s=t.dimension,a=e.nearest,o=e.center,l=e.farthest;return function(){switch(this.get(i)){case a:return Math.min(this.get(n),this.get(r));case o:return Math.min(this.get(n),this.get(r))+.5*this.get(s);case l:return Math.max(this.get(n),this.get(r))}}}e.Line?e.warn("fabric.Line is already defined"):(e.Line=e.util.createClass(e.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:e.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(t,e){t||(t=[0,0,0,0]),this.callSuper("initialize",e),this.set("x1",t[0]),this.set("y1",t[1]),this.set("x2",t[2]),this.set("y2",t[3]),this._setWidthHeight(e)},_setWidthHeight:function(t){t||(t={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in t?t.left:this._getLeftToOriginX(),this.top="top"in t?t.top:this._getTopToOriginY()},_set:function(t,e){return this.callSuper("_set",t,e),void 0!==r[t]&&this._setWidthHeight(),this},_getLeftToOriginX:s({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:s({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(t){t.beginPath();var e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;var i=t.strokeStyle;t.strokeStyle=this.stroke||t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(t){return i(this.callSuper("toObject",t),this.calcLinePoints())},_getNonTransformedDimensions:function(){var t=this.callSuper("_getNonTransformedDimensions");return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t},calcLinePoints:function(){var t=this.x1<=this.x2?-1:1,e=this.y1<=this.y2?-1:1,i=t*this.width*.5,n=e*this.height*.5;return{x1:i,x2:t*this.width*-.5,y1:n,y2:e*this.height*-.5}},_toSVG:function(){var t=this.calcLinePoints();return["\n']}}),e.Line.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),e.Line.fromElement=function(t,n,r){r=r||{};var s=e.parseAttributes(t,e.Line.ATTRIBUTE_NAMES),a=[s.x1||0,s.y1||0,s.x2||0,s.y2||0];n(new e.Line(a,i(s,r)))},e.Line.fromObject=function(t,i){var r=n(t,!0);r.points=[t.x1,t.y1,t.x2,t.y2],e.Object._fromObject("Line",r,(function(t){delete t.points,i&&i(t)}),"points")})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians;e.Circle?e.warn("fabric.Circle is already defined."):(e.Circle=e.util.createClass(e.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:e.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,e){return this.callSuper("_set",t,e),"radius"===t&&this.setRadius(e),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,n=(this.endAngle-this.startAngle)%360;if(0===n)t=["\n'];else{var r=i(this.startAngle),s=i(this.endAngle),a=this.radius;t=['180?"1":"0")+" 1"," "+e.util.cos(s)*a+" "+e.util.sin(s)*a,'" ',"COMMON_PARTS"," />\n"]}return t},_render:function(t){t.beginPath(),t.arc(0,0,this.radius,i(this.startAngle),i(this.endAngle),!1),this._renderPaintInOrder(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",2*t).set("height",2*t)}}),e.Circle.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),e.Circle.fromElement=function(t,i){var n,r=e.parseAttributes(t,e.Circle.ATTRIBUTE_NAMES);if(!("radius"in(n=r)&&n.radius>=0))throw new Error("value of `r` attribute is required and can not be negative");r.left=(r.left||0)-r.radius,r.top=(r.top||0)-r.radius,i(new e.Circle(r))},e.Circle.fromObject=function(t,i){e.Object._fromObject("Circle",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={});e.Triangle?e.warn("fabric.Triangle is already defined"):(e.Triangle=e.util.createClass(e.Object,{type:"triangle",width:100,height:100,_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)},_toSVG:function(){var t=this.width/2,e=this.height/2;return["']}}),e.Triangle.fromObject=function(t,i){return e.Object._fromObject("Triangle",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=2*Math.PI;e.Ellipse?e.warn("fabric.Ellipse is already defined."):(e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this.set("rx",t&&t.rx||0),this.set("ry",t&&t.ry||0)},_set:function(t,e){switch(this.callSuper("_set",t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']},_render:function(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,i,!1),t.restore(),this._renderPaintInOrder(t)}}),e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),e.Ellipse.fromElement=function(t,i){var n=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);n.left=(n.left||0)-n.rx,n.top=(n.top||0)-n.ry,i(new e.Ellipse(n))},e.Ellipse.fromObject=function(t,i){e.Object._fromObject("Ellipse",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Rect?e.warn("fabric.Rect is already defined"):(e.Rect=e.util.createClass(e.Object,{stateProperties:e.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(t){var e=this.rx?Math.min(this.rx,this.width/2):0,i=this.ry?Math.min(this.ry,this.height/2):0,n=this.width,r=this.height,s=-this.width/2,a=-this.height/2,o=0!==e||0!==i,l=.4477152502;t.beginPath(),t.moveTo(s+e,a),t.lineTo(s+n-e,a),o&&t.bezierCurveTo(s+n-l*e,a,s+n,a+l*i,s+n,a+i),t.lineTo(s+n,a+r-i),o&&t.bezierCurveTo(s+n,a+r-l*i,s+n-l*e,a+r,s+n-e,a+r),t.lineTo(s+e,a+r),o&&t.bezierCurveTo(s+l*e,a+r,s,a+r-l*i,s,a+r-i),t.lineTo(s,a+i),o&&t.bezierCurveTo(s,a+l*i,s+l*e,a,s+e,a),t.closePath(),this._renderPaintInOrder(t)},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']}}),e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),e.Rect.fromElement=function(t,n,r){if(!t)return n(null);r=r||{};var s=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);s.left=s.left||0,s.top=s.top||0,s.height=s.height||0,s.width=s.width||0;var a=new e.Rect(i(r?e.util.object.clone(r):{},s));a.visible=a.visible&&a.width>0&&a.height>0,n(a)},e.Rect.fromObject=function(t,i){return e.Object._fromObject("Rect",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.array.min,r=e.util.array.max,s=e.util.toFixed,a=e.util.projectStrokeOnPoints;e.Polyline?e.warn("fabric.Polyline is already defined"):(e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:e.Object.prototype.cacheProperties.concat("points"),initialize:function(t,e){e=e||{},this.points=t||[],this.callSuper("initialize",e),this._setPositionDimensions(e)},_projectStrokeOnPoints:function(){return a(this.points,this,!0)},_setPositionDimensions:function(t){var e,i=this._calcDimensions(t),n=this.exactBoundingBox?this.strokeWidth:0;this.width=i.width-n,this.height=i.height-n,t.fromSVG||(e=this.translateToGivenOrigin({x:i.left-this.strokeWidth/2+n/2,y:i.top-this.strokeWidth/2+n/2},"left","top",this.originX,this.originY)),void 0===t.left&&(this.left=t.fromSVG?i.left:e.x),void 0===t.top&&(this.top=t.fromSVG?i.top:e.y),this.pathOffset={x:i.left+this.width/2+n/2,y:i.top+this.height/2+n/2}},_calcDimensions:function(){var t=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,e=n(t,"x")||0,i=n(t,"y")||0;return{left:e,top:i,width:(r(t,"x")||0)-e,height:(r(t,"y")||0)-i}},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},_toSVG:function(){for(var t=[],i=this.pathOffset.x,n=this.pathOffset.y,r=e.Object.NUM_FRACTION_DIGITS,a=0,o=this.points.length;a\n']},commonRender:function(t){var e,i=this.points.length,n=this.pathOffset.x,r=this.pathOffset.y;if(!i||isNaN(this.points[i-1].y))return!1;t.beginPath(),t.moveTo(this.points[0].x-n,this.points[0].y-r);for(var s=0;s"},toObject:function(t){return r(this.callSuper("toObject",t),{path:this.path.map((function(t){return t.slice()}))})},toDatalessObject:function(t){var e=this.toObject(["sourcePath"].concat(t));return e.sourcePath&&delete e.path,e},_toSVG:function(){return["\n"]},_getOffsetTransform:function(){var t=e.Object.NUM_FRACTION_DIGITS;return" translate("+a(-this.pathOffset.x,t)+", "+a(-this.pathOffset.y,t)+")"},toClipPathSVG:function(t){var e=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},toSVG:function(t){var e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var t,r,s=[],a=[],o=0,l=0,h=0,c=0,d=0,u=this.path.length;d"},addWithUpdate:function(t){var i=!!this.group;return this._restoreObjectsState(),e.util.resetObjectTransform(this),t&&(i&&e.util.removeTransformFromObject(t,this.group.calcTransformMatrix()),this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,i?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,i){var n=this._objects.length;if(this.useSetOnGroup)for(;n--;)this._objects[n].setOnGroup(t,i);if("canvas"===t)for(;n--;)this._objects[n]._set(t,i);e.Object.prototype._set.call(this,t,i)},toObject:function(t){var i=this.includeDefaultValues,n=this._objects.filter((function(t){return!t.excludeFromExport})).map((function(e){var n=e.includeDefaultValues;e.includeDefaultValues=i;var r=e.toObject(t);return e.includeDefaultValues=n,r})),r=e.Object.prototype.toObject.call(this,t);return r.objects=n,r},toDatalessObject:function(t){var i,n=this.sourcePath;if(n)i=n;else{var r=this.includeDefaultValues;i=this._objects.map((function(e){var i=e.includeDefaultValues;e.includeDefaultValues=r;var n=e.toDatalessObject(t);return e.includeDefaultValues=i,n}))}var s=e.Object.prototype.toDatalessObject.call(this,t);return s.objects=i,s},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=e.Object.prototype.shouldCache.call(this);if(t)for(var i=0,n=this._objects.length;i\n"],i=0,n=this._objects.length;i\n"),e},getSvgStyles:function(){var t=void 0!==this.opacity&&1!==this.opacity?"opacity: "+this.opacity+";":"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")},toClipPathSVG:function(t){for(var e=[],i=0,n=this._objects.length;i"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",t,e),void 0===(i=i||{}).hasControls&&(i.hasControls=!1),i.forActiveSelection=!0;for(var n=0,r=this._objects.length;n\n','\t\n',"\n"),a=' clip-path="url(#imageCrop_'+l+')" '}if(this.imageSmoothing||(o='" image-rendering="optimizeSpeed'),i.push("\t\n"),this.stroke||this.strokeDashArray){var h=this.fill;this.fill=null,t=["\t\n'],this.fill=h}return"fill"!==this.paintFirst?e.concat(t,i):e.concat(i,t)},getSrc:function(t){var e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src"):e.src:this.src||""},setSrc:function(t,e,i){return T.util.loadImage(t,(function(t,n){this.setElement(t,i),this._setWidthHeight(),e&&e(this,n)}),this,i&&i.crossOrigin),this},toString:function(){return'#'},applyResizeFilters:function(){var t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),n=i.scaleX,r=i.scaleY,s=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||n>e&&r>e)return this._element=s,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=n,void(this._lastScaleY=r);T.filterBackend||(T.filterBackend=T.initFilterBackend());var a=T.util.createCanvasElement(),o=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,l=s.width,h=s.height;a.width=l,a.height=h,this._element=a,this._lastScaleX=t.scaleX=n,this._lastScaleY=t.scaleY=r,T.filterBackend.applyFilters([t],s,l,h,this._element,o),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height},applyFilters:function(t){if(t=(t=t||this.filters||[]).filter((function(t){return t&&!t.isNeutralState()})),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),0===t.length)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var e=this._originalElement,i=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(this._element===this._originalElement){var r=T.util.createCanvasElement();r.width=i,r.height=n,this._element=r,this._filteredEl=r}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,n),this._lastScaleX=1,this._lastScaleY=1;return T.filterBackend||(T.filterBackend=T.initFilterBackend()),T.filterBackend.applyFilters(t,this._originalElement,i,n,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(t){T.util.setImageSmoothing(t,this.imageSmoothing),!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)},drawCacheOnCanvas:function(t){T.util.setImageSmoothing(t,this.imageSmoothing),T.Object.prototype.drawCacheOnCanvas.call(this,t)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(t){var e=this._element;if(e){var i=this._filterScalingX,n=this._filterScalingY,r=this.width,s=this.height,a=Math.min,o=Math.max,l=o(this.cropX,0),h=o(this.cropY,0),c=e.naturalWidth||e.width,d=e.naturalHeight||e.height,u=l*i,f=h*n,g=a(r*i,c-u),m=a(s*n,d-f),p=-r/2,_=-s/2,v=a(r,c/i-l),y=a(s,d/n-h);e&&t.drawImage(e,u,f,g,m,p,_,v,y)}},_needsResize:function(){var t=this.getTotalObjectScaling();return t.scaleX!==this._lastScaleX||t.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(t,e){this.setElement(T.util.getById(t),e),T.util.addClass(this.getElement(),T.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={}),this.setOptions(t),this._setWidthHeight(t)},_initFilters:function(t,e){t&&t.length?T.util.enlivenObjects(t,(function(t){e&&e(t)}),"fabric.Image.filters"):e&&e()},_setWidthHeight:function(t){t||(t={});var e=this.getElement();this.width=t.width||e.naturalWidth||e.width||0,this.height=t.height||e.naturalHeight||e.height||0},parsePreserveAspectRatioAttribute:function(){var t,e=T.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),i=this._element.width,n=this._element.height,r=1,s=1,a=0,o=0,l=0,h=0,c=this.width,d=this.height,u={width:c,height:d};return!e||"none"===e.alignX&&"none"===e.alignY?(r=c/i,s=d/n):("meet"===e.meetOrSlice&&(t=(c-i*(r=s=T.util.findScaleToFit(this._element,u)))/2,"Min"===e.alignX&&(a=-t),"Max"===e.alignX&&(a=t),t=(d-n*s)/2,"Min"===e.alignY&&(o=-t),"Max"===e.alignY&&(o=t)),"slice"===e.meetOrSlice&&(t=i-c/(r=s=T.util.findScaleToCover(this._element,u)),"Mid"===e.alignX&&(l=t/2),"Max"===e.alignX&&(l=t),t=n-d/s,"Mid"===e.alignY&&(h=t/2),"Max"===e.alignY&&(h=t),i=c/r,n=d/s)),{width:i,height:n,scaleX:r,scaleY:s,offsetLeft:a,offsetTop:o,cropX:l,cropY:h}}}),T.Image.CSS_CANVAS="canvas-img",T.Image.prototype.getSvgSrc=T.Image.prototype.getSrc,T.Image.fromObject=function(t,e){var i=T.util.object.clone(t);T.util.loadImage(i.src,(function(t,n){n?e&&e(null,!0):T.Image.prototype._initFilters.call(i,i.filters,(function(n){i.filters=n||[],T.Image.prototype._initFilters.call(i,[i.resizeFilter],(function(n){i.resizeFilter=n[0],T.util.enlivenObjectEnlivables(i,i,(function(){var n=new T.Image(t,i);e(n,!1)}))}))}))}),null,i.crossOrigin)},T.Image.fromURL=function(t,e,i){T.util.loadImage(t,(function(t,n){e&&e(new T.Image(t,i),n)}),null,i&&i.crossOrigin)},T.Image.ATTRIBUTE_NAMES=T.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),T.Image.fromElement=function(t,i,n){var r=T.parseAttributes(t,T.Image.ATTRIBUTE_NAMES);T.Image.fromURL(r["xlink:href"],i,e(n?T.util.object.clone(n):{},r))})}(e),T.util.object.extend(T.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.angle%360;return t>0?90*Math.round((t-1)/90):90*Math.round(t/90)},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(t){var e=function(){},i=(t=t||{}).onComplete||e,n=t.onChange||e,r=this;return T.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){r.rotate(t),n()},onComplete:function(){r.setCoords(),i()}})}}),T.util.object.extend(T.StaticCanvas.prototype,{straightenObject:function(t){return t.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(t){return t.fxStraighten({onChange:this.requestRenderAllBound})}}),function(){function t(t,e){var i="precision "+e+" float;\nvoid main(){}",n=t.createShader(t.FRAGMENT_SHADER);return t.shaderSource(n,i),t.compileShader(n),!!t.getShaderParameter(n,t.COMPILE_STATUS)}function e(t){t&&t.tileSize&&(this.tileSize=t.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}T.isWebglSupported=function(e){if(T.isLikelyNode)return!1;e=e||T.WebglFilterBackend.prototype.tileSize;var i=document.createElement("canvas"),n=i.getContext("webgl")||i.getContext("experimental-webgl"),r=!1;if(n){T.maxTextureSize=n.getParameter(n.MAX_TEXTURE_SIZE),r=T.maxTextureSize>=e;for(var s=["highp","mediump","lowp"],a=0;a<3;a++)if(t(n,s[a])){T.webGlPrecision=s[a];break}}return this.isSupported=r,r},T.WebglFilterBackend=e,e.prototype={tileSize:2048,resources:{},setupGLContext:function(t,e){this.dispose(),this.createWebGLCanvas(t,e),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(t,e)},chooseFastestCopyGLTo2DMethod:function(t,e){var i,n=void 0!==window.performance;try{new ImageData(1,1),i=!0}catch(t){i=!1}var r="undefined"!=typeof ArrayBuffer,s="undefined"!=typeof Uint8ClampedArray;if(n&&i&&r&&s){var a=T.util.createCanvasElement(),o=new ArrayBuffer(t*e*4);if(T.forceGLPutImageData)return this.imageBuffer=o,void(this.copyGLTo2D=x);var l,h,c={imageBuffer:o,destinationWidth:t,destinationHeight:e,targetCanvas:a};a.width=t,a.height=e,l=window.performance.now(),I.call(c,this.gl,c),h=window.performance.now()-l,l=window.performance.now(),x.call(c,this.gl,c),h>window.performance.now()-l?(this.imageBuffer=o,this.copyGLTo2D=x):this.copyGLTo2D=I}},createWebGLCanvas:function(t,e){var i=T.util.createCanvasElement();i.width=t,i.height=e;var n={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},r=i.getContext("webgl",n);r||(r=i.getContext("experimental-webgl",n)),r&&(r.clearColor(0,0,0,0),this.canvas=i,this.gl=r)},applyFilters:function(t,e,i,n,r,s){var a,o=this.gl;s&&(a=this.getCachedTexture(s,e));var l={originalWidth:e.width||e.originalWidth,originalHeight:e.height||e.originalHeight,sourceWidth:i,sourceHeight:n,destinationWidth:i,destinationHeight:n,context:o,sourceTexture:this.createTexture(o,i,n,!a&&e),targetTexture:this.createTexture(o,i,n),originalTexture:a||this.createTexture(o,i,n,!a&&e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},h=o.createFramebuffer();return o.bindFramebuffer(o.FRAMEBUFFER,h),t.forEach((function(t){t&&t.applyTo(l)})),function(t){var e=t.targetCanvas,i=e.width,n=e.height,r=t.destinationWidth,s=t.destinationHeight;i===r&&n===s||(e.width=r,e.height=s)}(l),this.copyGLTo2D(o,l),o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(l.sourceTexture),o.deleteTexture(l.targetTexture),o.deleteFramebuffer(h),r.getContext("2d").setTransform(1,0,0,1,0,0),l},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(t,e,i,n){var r=t.createTexture();return t.bindTexture(t.TEXTURE_2D,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,i,0,t.RGBA,t.UNSIGNED_BYTE,null),r},getCachedTexture:function(t,e){if(this.textureCache[t])return this.textureCache[t];var i=this.createTexture(this.gl,e.width,e.height,e);return this.textureCache[t]=i,i},evictCachesForKey:function(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])},copyGLTo2D:I,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var t=this.gl,e={renderer:"",vendor:""};if(!t)return e;var i=t.getExtension("WEBGL_debug_renderer_info");if(i){var n=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);n&&(e.renderer=n.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}}(),function(){var t=function(){};function e(){}T.Canvas2dFilterBackend=e,e.prototype={evictCachesForKey:t,dispose:t,clearWebGLCaches:t,resources:{},applyFilters:function(t,e,i,n,r){var s=r.getContext("2d");s.drawImage(e,0,0,i,n);var a={sourceWidth:i,sourceHeight:n,imageData:s.getImageData(0,0,i,n),originalEl:e,originalImageData:s.getImageData(0,0,i,n),canvasEl:r,ctx:s,filterBackend:this};return t.forEach((function(t){t.applyTo(a)})),a.imageData.width===i&&a.imageData.height===n||(r.width=a.imageData.width,r.height=a.imageData.height),s.putImageData(a.imageData,0,0),a}}}(),T.Image=T.Image||{},T.Image.filters=T.Image.filters||{},T.Image.filters.BaseFilter=T.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(t){t&&this.setOptions(t)},setOptions:function(t){for(var e in t)this[e]=t[e]},createProgram:function(t,e,i){e=e||this.fragmentSource,i=i||this.vertexSource,"highp"!==T.webGlPrecision&&(e=e.replace(/precision highp float/g,"precision "+T.webGlPrecision+" float"));var n=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+t.getShaderInfoLog(n));var r=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+t.getShaderInfoLog(r));var s=t.createProgram();if(t.attachShader(s,n),t.attachShader(s,r),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+t.getProgramInfoLog(s));var a=this.getAttributeLocations(t,s),o=this.getUniformLocations(t,s)||{};return o.uStepW=t.getUniformLocation(s,"uStepW"),o.uStepH=t.getUniformLocation(s,"uStepH"),{program:s,attributeLocations:a,uniformLocations:o}},getAttributeLocations:function(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(t,e,i){var n=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)},_setupFrameBuffer:function(t){var e,i,n=t.context;t.passes>1?(e=t.destinationWidth,i=t.destinationHeight,t.sourceWidth===e&&t.sourceHeight===i||(n.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(n,e,i)),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t.targetTexture,0)):(n.bindFramebuffer(n.FRAMEBUFFER,null),n.finish())},_swapTextures:function(t){t.passes--,t.pass++;var e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e},isNeutralState:function(){var t=this.mainParameter,e=T.Image.filters[this.type].prototype;if(t){if(Array.isArray(e[t])){for(var i=e[t].length;i--;)if(this[t][i]!==e[t][i])return!1;return!0}return e[t]===this[t]}return!1},applyTo:function(t){t.webgl?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},retrieveShader:function(t){return t.programCache.hasOwnProperty(this.type)||(t.programCache[this.type]=this.createProgram(t.context)),t.programCache[this.type]},applyToWebGL:function(t){var e=t.context,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)},unbindAdditionalTexture:function(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(t){this[this.mainParameter]=t},sendUniformData:function(){},createHelpLayer:function(t){if(!t.helpLayer){var e=document.createElement("canvas");e.width=t.sourceWidth,e.height=t.sourceHeight,t.helpLayer=e}},toObject:function(){var t={type:this.type},e=this.mainParameter;return e&&(t[e]=this[e]),t},toJSON:function(){return this.toObject()}}),T.Image.filters.BaseFilter.fromObject=function(t,e){var i=new T.Image.filters[t.type](t);return e&&e(i),i},function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.ColorMatrix=n(i.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var e,i,n,r,s,a=t.imageData.data,o=a.length,l=this.matrix,h=this.colorsOnly;for(s=0;s=w||a<0||a>=y||(l=4*(o*y+a),h=p[f*_+u],e+=m[l]*h,i+=m[l+1]*h,n+=m[l+2]*h,S||(r+=m[l+3]*h));C[s]=e,C[s+1]=i,C[s+2]=n,C[s+3]=S?m[s+3]:r}t.imageData=E},getUniformLocations:function(t,e){return{uMatrix:t.getUniformLocation(e,"uMatrix"),uOpaque:t.getUniformLocation(e,"uOpaque"),uHalfSize:t.getUniformLocation(e,"uHalfSize"),uSize:t.getUniformLocation(e,"uSize")}},sendUniformData:function(t,e){t.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),e.Image.filters.Convolute.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Grayscale=n(i.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(t){var e,i,n=t.imageData.data,r=n.length,s=this.mode;for(e=0;eh[0]&&r>h[1]&&s>h[2]&&n 0.0) {\n"+this.fragmentSource[t]+"}\n}"},retrieveShader:function(t){var e,i=this.type+"_"+this.mode;return t.programCache.hasOwnProperty(i)||(e=this.buildSource(this.mode),t.programCache[i]=this.createProgram(t.context,e)),t.programCache[i]},applyTo2d:function(t){var i,n,r,s,a,o,l,h=t.imageData.data,c=h.length,d=1-this.alpha;i=(l=new e.Color(this.color).getSource())[0]*this.alpha,n=l[1]*this.alpha,r=l[2]*this.alpha;for(var u=0;u=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;var i=(e*=Math.PI)/t;return o(e)/e*o(i)/i}},applyTo2d:function(t){var e=t.imageData,i=this.scaleX,n=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/n;var r,s=e.width,o=e.height,l=a(s*i),h=a(o*n);"sliceHack"===this.resizeType?r=this.sliceByTwo(t,s,o,l,h):"hermite"===this.resizeType?r=this.hermiteFastResize(t,s,o,l,h):"bilinear"===this.resizeType?r=this.bilinearFiltering(t,s,o,l,h):"lanczos"===this.resizeType&&(r=this.lanczosResize(t,s,o,l,h)),t.imageData=r},sliceByTwo:function(t,i,r,s,a){var o,l,h=t.imageData,c=.5,d=!1,u=!1,f=i*c,g=r*c,m=e.filterBackend.resources,p=0,_=0,v=i,y=0;for(m.sliceByTwo||(m.sliceByTwo=document.createElement("canvas")),((o=m.sliceByTwo).width<1.5*i||o.height=e)){M=n(1e3*s(T-E.x)),w[M]||(w[M]={});for(var F=C.y-y;F<=C.y+y;F++)F<0||F>=a||(L=n(1e3*s(F-E.y)),w[M][L]||(w[M][L]=f(r(i(M*p,2)+i(L*_,2))/1e3)),(b=w[M][L])>0&&(x+=b,R+=b*c[I=4*(F*e+T)],O+=b*c[I+1],D+=b*c[I+2],A+=b*c[I+3]))}u[I=4*(S*o+l)]=R/x,u[I+1]=O/x,u[I+2]=D/x,u[I+3]=A/x}return++l1&&L<-1||(y=2*L*L*L-3*L*L+1)>0&&(b+=y*f[3+(M=4*(A+x*e))],E+=y,f[M+3]<255&&(y=y*f[M+3]/250),C+=y*f[M],S+=y*f[M+1],T+=y*f[M+2],w+=y)}m[v]=C/w,m[v+1]=S/w,m[v+2]=T/w,m[v+3]=b/E}return g},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),e.Image.filters.Resize.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Contrast=n(i.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(t){if(0!==this.contrast){var e,i=t.imageData.data,n=i.length,r=Math.floor(255*this.contrast),s=259*(r+255)/(255*(259-r));for(e=0;e1&&(e=1/this.aspectRatio):this.aspectRatio<1&&(e=this.aspectRatio),t=e*this.blur*.12,this.horizontal?i[0]=t:i[1]=t,i}}),i.Blur.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Gamma=n(i.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],i.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var e,i=t.imageData.data,n=this.gamma,r=i.length,s=1/n[0],a=1/n[1],o=1/n[2];for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),e=0,r=256;e'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t},_render:function(t){var e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){"stroke"===this.paintFirst?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,e,i){if(t.textBaseline="alphabetical",this.path)switch(this.pathAlign){case"center":t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline="bottom"}t.font=this._getFontDeclaration(e,i)},calcTextWidth:function(){for(var t=this.getLineWidth(0),e=1,i=this._textLines.length;et&&(t=n)}return t},_renderTextLine:function(t,e,i,n,r,s){this._renderChars(t,e,i,n,r,s)},_renderTextLinesBackground:function(t){if(this.textBackgroundColor||this.styleHas("textBackgroundColor")){for(var e,i,n,r,s,a,o,l=t.fillStyle,h=this._getLeftOffset(),c=this._getTopOffset(),d=0,u=0,f=this.path,g=0,m=this._textLines.length;g=0:io?d%=o:d<0&&(d+=o),this._setGraphemeOnPath(d,s,a),d+=s.kernedWidth}return{width:l,numOfSpaces:0}},_setGraphemeOnPath:function(t,i,n){var r=t+i.kernedWidth/2,s=this.path,a=e.util.getPointOnPath(s.path,r,s.segmentsInfo);i.renderLeft=a.x-n.x,i.renderTop=a.y-n.y,i.angle=a.angle+("right"===this.pathSide?Math.PI:0)},_getGraphemeBox:function(t,e,i,n,r){var s,a=this.getCompleteStyleDeclaration(e,i),o=n?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,a,n,o),h=l.kernedWidth,c=l.width;0!==this.charSpacing&&(c+=s=this._getWidthOfCharSpacing(),h+=s);var d={width:c,left:0,height:a.fontSize,kernedWidth:h,deltaY:a.deltaY};if(i>0&&!r){var u=this.__charBounds[e][i-1];d.left=u.left+u.width+l.kernedWidth-l.width}return d},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var e=this._textLines[t],i=this.getHeightOfChar(t,0),n=1,r=e.length;n0){var x=v+s+d;"rtl"===this.direction&&(x=this.width-x-u),h&&_&&(t.fillStyle=_,t.fillRect(x,c+C*n+a,u,this.fontSize/15)),d=f.left,u=f.width,h=g,_=p,n=r,a=o}else u+=f.kernedWidth;x=v+s+d,"rtl"===this.direction&&(x=this.width-x-u),t.fillStyle=p,g&&p&&t.fillRect(x,c+C*n+a,u-E,this.fontSize/15),y+=i}else y+=i;this._removeShadow(t)}},_getFontDeclaration:function(t,i){var n=t||this,r=this.fontFamily,s=e.Text.genericFonts.indexOf(r.toLowerCase())>-1,a=void 0===r||r.indexOf("'")>-1||r.indexOf(",")>-1||r.indexOf('"')>-1||s?n.fontFamily:'"'+n.fontFamily+'"';return[e.isLikelyNode?n.fontWeight:n.fontStyle,e.isLikelyNode?n.fontStyle:n.fontWeight,i?this.CACHE_FONT_SIZE+"px":n.fontSize+"px",a].join(" ")},render:function(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t)))},_splitTextIntoLines:function(t){for(var i=t.split(this._reNewline),n=new Array(i.length),r=["\n"],s=[],a=0;a-1&&(t.underline=!0),t.textDecoration.indexOf("line-through")>-1&&(t.linethrough=!0),t.textDecoration.indexOf("overline")>-1&&(t.overline=!0),delete t.textDecoration)}T.IText=T.util.createClass(T.Text,T.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(t,e){this.callSuper("initialize",t,e),this.initBehavior()},setSelectionStart:function(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)},setSelectionEnd:function(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)},_updateAndFire:function(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(t){this.clearContextTop(),this.callSuper("render",t),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(t){this.callSuper("_render",t)},clearContextTop:function(t){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var e=this.canvas.contextTop,i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e),this._clearTextArea(e),t||e.restore()}},renderCursorOrSelection:function(){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var t=this._getCursorBoundaries(),e=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(t,e):this.renderSelection(t,e),e.restore()}},_clearTextArea:function(t){var e=this.width+4,i=this.height+4;t.clearRect(-e/2,-i/2,e,i)},_getCursorBoundaries:function(t){void 0===t&&(t=this.selectionStart);var e=this._getLeftOffset(),i=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t);return{left:e,top:i,leftOffset:n.left,topOffset:n.top}},_getCursorBoundariesOffsets:function(t){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var e,i,n,r,s=0,a=0,o=this.get2DCursorLocation(t);n=o.charIndex,i=o.lineIndex;for(var l=0;l0?a:0)},"rtl"===this.direction&&(r.left*=-1),this.cursorOffsetCache=r,this.cursorOffsetCache},renderCursor:function(t,e){var i=this.get2DCursorLocation(),n=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,s=this.getValueOfPropertyAt(n,r,"fontSize"),a=this.scaleX*this.canvas.getZoom(),o=this.cursorWidth/a,l=t.topOffset,h=this.getValueOfPropertyAt(n,r,"deltaY");l+=(1-this._fontSizeFraction)*this.getHeightOfLine(n)/this.lineHeight-s*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(t,e),e.fillStyle=this.cursorColor||this.getValueOfPropertyAt(n,r,"fill"),e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,e.fillRect(t.left+t.leftOffset-o/2,l+t.top+h,o,s)},renderSelection:function(t,e){for(var i=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,n=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,r=-1!==this.textAlign.indexOf("justify"),s=this.get2DCursorLocation(i),a=this.get2DCursorLocation(n),o=s.lineIndex,l=a.lineIndex,h=s.charIndex<0?0:s.charIndex,c=a.charIndex<0?0:a.charIndex,d=o;d<=l;d++){var u,f=this._getLineLeftOffset(d)||0,g=this.getHeightOfLine(d),m=0,p=0;if(d===o&&(m=this.__charBounds[o][h].left),d>=o&&d1)&&(g/=this.lineHeight);var v=t.left+f+m,y=p-m,w=g,E=0;this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",w=1,E=g):e.fillStyle=this.selectionColor,"rtl"===this.direction&&(v=this.width-v-y),e.fillRect(v,t.top+t.topOffset+E,y,w),t.topOffset+=u}},getCurrentCharFontSize:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")},getCurrentCharColor:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fill")},_getCurrentCharIndex:function(){var t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}}),T.IText.fromObject=function(e,i){if(t(e),e.styles)for(var n in e.styles)for(var r in e.styles[n])t(e.styles[n][r]);T.Object._fromObject("IText",e,i,"text")}}(),S=T.util.object.clone,T.util.object.extend(T.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var t=this;this.on("added",(function(){var e=t.canvas;e&&(e._hasITextHandlers||(e._hasITextHandlers=!0,t._initCanvasHandlers(e)),e._iTextInstances=e._iTextInstances||[],e._iTextInstances.push(t))}))},initRemovedHandler:function(){var t=this;this.on("removed",(function(){var e=t.canvas;e&&(e._iTextInstances=e._iTextInstances||[],T.util.removeFromArray(e._iTextInstances,t),0===e._iTextInstances.length&&(e._hasITextHandlers=!1,t._removeCanvasHandlers(e)))}))},_initCanvasHandlers:function(t){t._mouseUpITextHandler=function(){t._iTextInstances&&t._iTextInstances.forEach((function(t){t.__isMousedown=!1}))},t.on("mouse:up",t._mouseUpITextHandler)},_removeCanvasHandlers:function(t){t.off("mouse:up",t._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,n){var r;return r={isAborted:!1,abort:function(){this.isAborted=!0}},t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){r.isAborted||t[n]()},onChange:function(){t.canvas&&t.selectionStart===t.selectionEnd&&t.renderCursorOrSelection()},abort:function(){return r.isAborted}}),r},_onTickComplete:function(){var t=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout((function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")}),100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout((function(){e._tick()}),i)},abortCursorAnimation:function(){var t=this._currentTickState||this._currentTickCompleteState,e=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,t&&e&&e.clearContext(e.contextTop||e.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i-1;)e++,i--;return t-e},findLineBoundaryRight:function(t){for(var e=0,i=t;!/\n/.test(this._text[i])&&i0&&nthis.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=e):(this.selectionStart=e,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===n||(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(t,e,i){var n=i.slice(0,t),r=T.util.string.graphemeSplit(n).length;if(t===e)return{selectionStart:r,selectionEnd:r};var s=i.slice(t,e);return{selectionStart:r,selectionEnd:r+T.util.string.graphemeSplit(s).length}},fromGraphemeToStringSelection:function(t,e,i){var n=i.slice(0,t).join("").length;return t===e?{selectionStart:n,selectionEnd:n}:{selectionStart:n,selectionEnd:n+i.slice(t,e).join("").length}},_updateTextarea:function(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){var t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var t=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=t.selectionEnd,this.inCompositionMode||(this.selectionStart=t.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),n=i.lineIndex,r=i.charIndex,s=this.getValueOfPropertyAt(n,r,"fontSize")*this.lineHeight,a=e.leftOffset,o=this.calcTransformMatrix(),l={x:e.left+a,y:e.top+e.topOffset+s},h=this.canvas.getRetinaScaling(),c=this.canvas.upperCanvasEl,d=c.width/h,u=c.height/h,f=d-s,g=u-s,m=c.clientWidth/d,p=c.clientHeight/u;return l=T.util.transformPoint(l,o),(l=T.util.transformPoint(l,this.canvas.viewportTransform)).x*=m,l.y*=p,l.x<0&&(l.x=0),l.x>f&&(l.x=f),l.y<0&&(l.y=0),l.y>g&&(l.y=g),l.x+=this.canvas._offset.left,l.y+=this.canvas._offset.top,{left:l.x+"px",top:l.y+"px",fontSize:s+"px",charHeight:s}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var t=this._textBeforeEdit!==this.text,e=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var t in this.styles)this._textLines[t]||delete this.styles[t]},removeStyleFromTo:function(t,e){var i,n,r=this.get2DCursorLocation(t,!0),s=this.get2DCursorLocation(e,!0),a=r.lineIndex,o=r.charIndex,l=s.lineIndex,h=s.charIndex;if(a!==l){if(this.styles[a])for(i=o;i=h&&(n[c-u]=n[d],delete n[d])}},shiftLineStyles:function(t,e){var i=S(this.styles);for(var n in this.styles){var r=parseInt(n,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}},restartCursorIfNeeded:function(){this._currentTickState&&!this._currentTickState.isAborted&&this._currentTickCompleteState&&!this._currentTickCompleteState.isAborted||this.initDelayedCursor()},insertNewlineStyleObject:function(t,e,i,n){var r,s={},a=!1,o=this._unwrappedTextLines[t].length===e;for(var l in i||(i=1),this.shiftLineStyles(t,i),this.styles[t]&&(r=this.styles[t][0===e?e:e-1]),this.styles[t]){var h=parseInt(l,10);h>=e&&(a=!0,s[h-e]=this.styles[t][l],o&&0===e||delete this.styles[t][l])}var c=!1;for(a&&!o&&(this.styles[t+i]=s,c=!0),c&&i--;i>0;)n&&n[i-1]?this.styles[t+i]={0:S(n[i-1])}:r?this.styles[t+i]={0:S(r)}:delete this.styles[t+i],i--;this._forceClearCache=!0},insertCharStyleObject:function(t,e,i,n){this.styles||(this.styles={});var r=this.styles[t],s=r?S(r):{};for(var a in i||(i=1),s){var o=parseInt(a,10);o>=e&&(r[o+i]=s[o],s[o-i]||delete r[o])}if(this._forceClearCache=!0,n)for(;i--;)Object.keys(n[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=S(n[i]));else if(r)for(var l=r[e?e-1:1];l&&i--;)this.styles[t][e+i]=S(l)},insertNewStyleBlock:function(t,e,i){for(var n=this.get2DCursorLocation(e,!0),r=[0],s=0,a=0;a0&&(this.insertCharStyleObject(n.lineIndex,n.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),s&&this.insertNewlineStyleObject(n.lineIndex,n.charIndex+r[0],s),a=1;a0?this.insertCharStyleObject(n.lineIndex+a,0,r[a],i):i&&this.styles[n.lineIndex+a]&&i[0]&&(this.styles[n.lineIndex+a][0]=i[0]),i=i&&i.slice(r[a]+1);r[a]>0&&this.insertCharStyleObject(n.lineIndex+a,0,r[a],i)},setSelectionStartEndWithShift:function(t,e,i){i<=t?(e===t?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=t),this.selectionStart=i):i>t&&it?this.selectionStart=t:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>t?this.selectionEnd=t:this.selectionEnd<0&&(this.selectionEnd=0)}}),T.util.object.extend(T.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(t){if(this.canvas){this.__newClickTime=+new Date;var e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),this._stopEvent(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))},tripleClickHandler:function(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(t.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(t){if(this.__isMousedown=!1,!(!this.editable||this.group||t.transform&&t.transform.actionPerformed||t.e.button&&1!==t.e.button)){if(this.canvas){var e=this.canvas._activeObject;if(e&&e!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(t.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t),i=this.selectionStart,n=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,n,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(t){for(var e,i=this.getLocalPointer(t),n=0,r=0,s=0,a=0,o=0,l=0,h=this._textLines.length;l0&&(a+=this._textLines[l-1].length+this.missingNewlineOffset(l-1));r=this._getLineLeftOffset(o)*this.scaleX,e=this._textLines[o],"rtl"===this.direction&&(i.x=this.width*this.scaleX-i.x+r);for(var c=0,d=e.length;cs||a<0?0:1);return this.flipX&&(o=r-o),o>this._text.length&&(o=this._text.length),o}}),T.util.object.extend(T.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=T.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var t=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+t.top+"; left: "+t.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; paddingーtop: "+t.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):T.document.body.appendChild(this.hiddenTextarea),T.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),T.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),T.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),T.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),T.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),T.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(T.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(this.isEditing){var e="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())},onInput:function(t){var e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),this.isEditing){var i,n,r,s,a,o=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,l=this._text.length,h=o.length,c=h-l,d=this.selectionStart,u=this.selectionEnd,f=d!==u;if(""===this.hiddenTextarea.value)return this.styles={},this.updateFromTextArea(),this.fire("changed"),void(this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll()));var g=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),m=d>g.selectionStart;f?(i=this._text.slice(d,u),c+=u-d):h0&&(n+=(i=this.__charBounds[t][e-1]).left+i.width),n},getDownCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(r===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;var s=n.charIndex,a=this._getWidthBeforeCursor(r,s),o=this._getIndexOnLine(r+1,a);return this._textLines[r].slice(s).length+o+1+this.missingNewlineOffset(r)},_getSelectionForOffset:function(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(0===r||t.metaKey||33===t.keyCode)return-i;var s=n.charIndex,a=this._getWidthBeforeCursor(r,s),o=this._getIndexOnLine(r-1,a),l=this._textLines[r].slice(0,s),h=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+o-l.length+(1-h)},_getIndexOnLine:function(t,e){for(var i,n,r=this._textLines[t],s=this._getLineLeftOffset(t),a=0,o=0,l=r.length;oe){n=!0;var h=s-i,c=s,d=Math.abs(h-e);a=Math.abs(c-e)=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)},moveCursorUp:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)},_moveCursorUpOrDown:function(t,e){var i=this["get"+t+"CursorOffset"](e,"right"===this._selectionDirection);e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(t){var e="left"===this._selectionDirection?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t},moveCursorWithoutShift:function(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t},moveCursorLeft:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)},_move:function(t,e,i){var n;if(t.altKey)n=this["findWordBoundary"+i](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;n=this["findLineBoundary"+i](this[e])}if(void 0!==typeof n&&this[e]!==n)return this[e]=n,!0},_moveLeft:function(t,e){return this._move(t,e,"Left")},_moveRight:function(t,e){return this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){var e=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e},moveCursorLeftWithShift:function(t){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(t,"selectionStart")):void 0},moveCursorRight:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)},_moveCursorLeftOrRight:function(t,e){var i="moveCursor"+t+"With";this._currentCursorOpacity=1,e.shiftKey?i+="Shift":i+="outShift",this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(t){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection="right",this._moveRight(t,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(t){var e=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e},removeChars:function(t,e){void 0===e&&(e=t+1),this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(t,e,i,n){void 0===n&&(n=i),n>i&&this.removeStyleFromTo(i,n);var r=T.util.string.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[].concat(this._text.slice(0,i),r,this._text.slice(n)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),function(){var t=T.util.toFixed,e=/ +/g;T.util.object.extend(T.Text.prototype,{_toSVG:function(){var t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(t){var e=this.getSvgTextDecoration(this);return[t.textBgRects.join(""),'\t\t",t.textSpans.join(""),"\n"]},_getSVGTextAndBg:function(t,e){var i,n=[],r=[],s=t;this._setSVGBg(r);for(var a=0,o=this._textLines.length;a",T.util.string.escapeXml(i),""].join("")},_setSVGTextLineText:function(t,e,i,n){var r,s,a,o,l,h=this.getHeightOfLine(e),c=-1!==this.textAlign.indexOf("justify"),d="",u=0,f=this._textLines[e];n+=h*(1-this._fontSizeFraction)/this.lineHeight;for(var g=0,m=f.length-1;g<=m;g++)l=g===m||this.charSpacing,d+=f[g],a=this.__charBounds[e][g],0===u?(i+=a.kernedWidth-a.width,u+=a.width):u+=a.kernedWidth,c&&!l&&this._reSpaceAndTab.test(f[g])&&(l=!0),l||(r=r||this.getCompleteStyleDeclaration(e,g),s=this.getCompleteStyleDeclaration(e,g+1),l=this._hasStyleChangedForSvg(r,s)),l&&(o=this._getStyleDeclaration(e,g)||{},t.push(this._createTextCharSpan(d,o,i,n)),d="",r=s,i+=u,u=0)},_pushTextBgRect:function(e,i,n,r,s,a){var o=T.Object.NUM_FRACTION_DIGITS;e.push("\t\t\n')},_setSVGTextLineBg:function(t,e,i,n){for(var r,s,a=this._textLines[e],o=this.getHeightOfLine(e)/this.lineHeight,l=0,h=0,c=this.getValueOfPropertyAt(e,0,"textBackgroundColor"),d=0,u=a.length;dthis.width&&this._set("width",this.dynamicMinWidth),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(t){for(var e=0,i=0,n=0,r={},s=0;s0?(i=0,n++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[n])&&s>0&&(i++,n++),r[s]={line:e,offset:i},n+=t.graphemeLines[s].length,i+=t.graphemeLines[s].length;return r},styleHas:function(t,i){if(this._styleMap&&!this.isWrapping){var n=this._styleMap[i];n&&(i=n.line)}return e.Text.prototype.styleHas.call(this,t,i)},isEmptyStyles:function(t){if(!this.styles)return!0;var e,i,n=0,r=!1,s=this._styleMap[t],a=this._styleMap[t+1];for(var o in s&&(t=s.line,n=s.offset),a&&(r=a.line===t,e=a.offset),i=void 0===t?this.styles:{line:this.styles[t]})for(var l in i[o])if(l>=n&&(!r||ln&&!p?(o.push(l),l=[],s=f,p=!0):s+=_,p||a||l.push(u),l=l.concat(c),g=a?0:this._measureWord([u],i,d),d++,p=!1,f>m&&(m=f);return v&&o.push(l),m+r>this.dynamicMinWidth&&(this.dynamicMinWidth=m-_+r),o},isEndOfWrapping:function(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line},missingNewlineOffset:function(t){return this.splitByGrapheme?this.isEndOfWrapping(t)?1:0:1},_splitTextIntoLines:function(t){for(var i=e.Text.prototype._splitTextIntoLines.call(this,t),n=this._wrapText(i.lines,this.width),r=new Array(n.length),s=0;s{},898:()=>{},245:()=>{}},ci={};function di(t){var e=ci[t];if(void 0!==e)return e.exports;var i=ci[t]={exports:{}};return hi[t](i,i.exports,di),i.exports}di.d=(t,e)=>{for(var i in e)di.o(e,i)&&!di.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},di.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var ui={};(()=>{let t;di.d(ui,{R:()=>t}),t="undefined"!=typeof document&&"undefined"!=typeof window?di(653).fabric:{version:"5.2.1"}})();var fi,gi,mi,pi,_i=ui.R;!function(t){t[t.DIMT_RECTANGLE=1]="DIMT_RECTANGLE",t[t.DIMT_QUADRILATERAL=2]="DIMT_QUADRILATERAL",t[t.DIMT_TEXT=4]="DIMT_TEXT",t[t.DIMT_ARC=8]="DIMT_ARC",t[t.DIMT_IMAGE=16]="DIMT_IMAGE",t[t.DIMT_POLYGON=32]="DIMT_POLYGON",t[t.DIMT_LINE=64]="DIMT_LINE",t[t.DIMT_GROUP=128]="DIMT_GROUP"}(fi||(fi={})),function(t){t[t.DIS_DEFAULT=1]="DIS_DEFAULT",t[t.DIS_SELECTED=2]="DIS_SELECTED"}(gi||(gi={})),function(t){t[t.EF_ENHANCED_FOCUS=4]="EF_ENHANCED_FOCUS",t[t.EF_AUTO_ZOOM=16]="EF_AUTO_ZOOM",t[t.EF_TAP_TO_FOCUS=64]="EF_TAP_TO_FOCUS"}(mi||(mi={})),function(t){t.GREY="grey",t.GREY32="grey32",t.RGBA="rgba",t.RBGA="rbga",t.GRBA="grba",t.GBRA="gbra",t.BRGA="brga",t.BGRA="bgra"}(pi||(pi={}));const vi=t=>"number"==typeof t&&!Number.isNaN(t),yi=t=>"string"==typeof t;var wi,Ei,Ci,Si,Ti,bi,Ii,xi,Ri,Oi,Di;!function(t){t[t.ARC=0]="ARC",t[t.IMAGE=1]="IMAGE",t[t.LINE=2]="LINE",t[t.POLYGON=3]="POLYGON",t[t.QUAD=4]="QUAD",t[t.RECT=5]="RECT",t[t.TEXT=6]="TEXT",t[t.GROUP=7]="GROUP"}(Ti||(Ti={})),function(t){t[t.DEFAULT=0]="DEFAULT",t[t.SELECTED=1]="SELECTED"}(bi||(bi={}));let Ai=class{get mediaType(){return new Map([["rect",fi.DIMT_RECTANGLE],["quad",fi.DIMT_QUADRILATERAL],["text",fi.DIMT_TEXT],["arc",fi.DIMT_ARC],["image",fi.DIMT_IMAGE],["polygon",fi.DIMT_POLYGON],["line",fi.DIMT_LINE],["group",fi.DIMT_GROUP]]).get(this._mediaType)}get styleSelector(){switch(ni(this,Ei,"f")){case gi.DIS_DEFAULT:return"default";case gi.DIS_SELECTED:return"selected"}}set drawingStyleId(t){this.styleId=t}get drawingStyleId(){return this.styleId}set coordinateBase(t){if(!["view","image"].includes(t))throw new Error("Invalid 'coordinateBase'.");this._drawingLayer&&("image"===ni(this,Ci,"f")&&"view"===t?this.updateCoordinateBaseFromImageToView():"view"===ni(this,Ci,"f")&&"image"===t&&this.updateCoordinateBaseFromViewToImage()),ri(this,Ci,t)}get coordinateBase(){return ni(this,Ci,"f")}get drawingLayerId(){return this._drawingLayerId}constructor(t,e){if(wi.add(this),Ei.set(this,void 0),Ci.set(this,"image"),this._zIndex=null,this._drawingLayer=null,this._drawingLayerId=null,this._mapState_StyleId=new Map,this.mapEvent_Callbacks=new Map([["selected",new Map],["deselected",new Map],["mousedown",new Map],["mouseup",new Map],["dblclick",new Map],["mouseover",new Map],["mouseout",new Map]]),this.mapNoteName_Content=new Map([]),this.isDrawingItem=!0,null!=e&&!vi(e))throw new TypeError("Invalid 'drawingStyleId'.");t&&this._setFabricObject(t),this.setState(gi.DIS_DEFAULT),this.styleId=e}_setFabricObject(t){this._fabricObject=t,this._fabricObject.on("selected",(()=>{this.setState(gi.DIS_SELECTED)})),this._fabricObject.on("deselected",(()=>{this._fabricObject.canvas&&this._fabricObject.canvas.getActiveObjects().includes(this._fabricObject)?this.setState(gi.DIS_SELECTED):this.setState(gi.DIS_DEFAULT),"textbox"===this._fabricObject.type&&(this._fabricObject.isEditing&&this._fabricObject.exitEditing(),this._fabricObject.selected=!1)})),t.getDrawingItem=()=>this}_getFabricObject(){return this._fabricObject}setState(t){ri(this,Ei,t)}getState(){return ni(this,Ei,"f")}_on(t,e){if(!e)return;const i=t.toLowerCase(),n=this.mapEvent_Callbacks.get(i);if(!n)throw new Error(`Event '${t}' does not exist.`);let r=n.get(e);r||(r=t=>{const i=t.e;if(!i)return void(e&&e.apply(this,[{targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null}]));const n={targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null};if(this._drawingLayer){let t,e,r,s;const a=i.target.getBoundingClientRect();t=a.left,e=a.top,r=t+window.scrollX,s=e+window.scrollY;const{width:o,height:l}=this._drawingLayer.fabricCanvas.lowerCanvasEl.getBoundingClientRect(),h=this._drawingLayer.width,c=this._drawingLayer.height,d=o/l,u=h/c,f=this._drawingLayer._getObjectFit();let g,m,p,_,v=1;if("contain"===f)d0?i-1:n,Pi),actionName:"modifyPolygon",pointIndex:i}),t}),{}),ri(this,xi,JSON.parse(JSON.stringify(t))),this._mediaType="polygon"}extendSet(t,e){if("vertices"===t){const t=this._fabricObject;if(t.group){const i=t.group;t.points=e.map((t=>({x:t.x-i.left-i.width/2,y:t.y-i.top-i.height/2}))),i.addWithUpdate()}else t.points=e;const i=t.points.length-1;return t.controls=t.points.reduce((function(t,e,n){return t["p"+n]=new _i.Control({positionHandler:Li,actionHandler:ki(n>0?n-1:i,Pi),actionName:"modifyPolygon",pointIndex:n}),t}),{}),t._setPositionDimensions({}),!0}}extendGet(t){if("vertices"===t){const t=[],e=this._fabricObject;if(e.selectable&&!e.group)for(let i in e.oCoords)t.push({x:e.oCoords[i].x,y:e.oCoords[i].y});else for(let i of e.points){let n=i.x-e.pathOffset.x,r=i.y-e.pathOffset.y;const s=_i.util.transformPoint({x:n,y:r},e.calcTransformMatrix());t.push({x:s.x,y:s.y})}return t}}updateCoordinateBaseFromImageToView(){const t=this.get("vertices").map((t=>({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",t)}updateCoordinateBaseFromViewToImage(){const t=this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})));this.set("vertices",t)}setPosition(t){this.setPolygon(t)}getPosition(){return this.getPolygon()}updatePosition(){ni(this,xi,"f")&&this.setPolygon(ni(this,xi,"f"))}setPolygon(t){if(!S(t))throw new TypeError("Invalid 'polygon'.");if(this._drawingLayer){if("view"===this.coordinateBase){const e=t.points.map((t=>({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",e)}else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("vertices",t.points)}this._drawingLayer.renderAll()}else ri(this,xi,JSON.parse(JSON.stringify(t)))}getPolygon(){if(this._drawingLayer){if("view"===this.coordinateBase)return{points:this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})))};if("image"===this.coordinateBase)return{points:this.get("vertices")};throw new Error("Invalid 'coordinateBase'.")}return ni(this,xi,"f")?JSON.parse(JSON.stringify(ni(this,xi,"f"))):null}};xi=new WeakMap;Ri=new WeakMap,Oi=new WeakMap;const Bi=t=>{let e=(t=>t.split("\n").map((t=>t.split("\t"))))(t);return(t=>{for(let e=0;;e++){let i=-1;for(let n=0;ni&&(i=r.length)}if(-1===i)break;for(let n=0;n=t[n].length-1)continue;let r=" ".repeat(i+2-t[n][e].length);t[n][e]=t[n][e].concat(r)}}})(e),(t=>{let e="";for(let i=0;i({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",e)}else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("vertices",t.points)}this._drawingLayer.renderAll()}else ri(this,Ui,JSON.parse(JSON.stringify(t)))}getQuad(){if(this._drawingLayer){if("view"===this.coordinateBase)return{points:this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})))};if("image"===this.coordinateBase)return{points:this.get("vertices")};throw new Error("Invalid 'coordinateBase'.")}return ni(this,Ui,"f")?JSON.parse(JSON.stringify(ni(this,Ui,"f"))):null}};Ui=new WeakMap;class Wi extends Ai{constructor(t){super(new _i.Group(t.map((t=>t._getFabricObject())))),this._fabricObject.on("selected",(()=>{this.setState(gi.DIS_SELECTED);const t=this._fabricObject._objects;for(let e of t)setTimeout((()=>{e&&e.fire("selected")}),0);setTimeout((()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())}),0)})),this._fabricObject.on("deselected",(()=>{this.setState(gi.DIS_DEFAULT);const t=this._fabricObject._objects;for(let e of t)setTimeout((()=>{e&&e.fire("deselected")}),0);setTimeout((()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())}),0)})),this._mediaType="group"}extendSet(t,e){return!1}extendGet(t){}updateCoordinateBaseFromImageToView(){}updateCoordinateBaseFromViewToImage(){}setPosition(){}getPosition(){}updatePosition(){}getChildDrawingItems(){return this._fabricObject._objects.map((t=>t.getDrawingItem()))}setChildDrawingItems(t){if(!t||!t.isDrawingItem)throw TypeError("Illegal drawing item.");this._drawingLayer?this._drawingLayer._updateGroupItem(this,t,"add"):this._fabricObject.addWithUpdate(t._getFabricObject())}removeChildItem(t){t&&t.isDrawingItem&&(this._drawingLayer?this._drawingLayer._updateGroupItem(this,t,"remove"):this._fabricObject.removeWithUpdate(t._getFabricObject()))}}const Yi=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),Hi=t=>!!yi(t)&&""!==t,zi=t=>!(!Yi(t)||"id"in t&&!vi(t.id)||"lineWidth"in t&&!vi(t.lineWidth)||"fillStyle"in t&&!Hi(t.fillStyle)||"strokeStyle"in t&&!Hi(t.strokeStyle)||"paintMode"in t&&!["fill","stroke","strokeAndFill"].includes(t.paintMode)||"fontFamily"in t&&!Hi(t.fontFamily)||"fontSize"in t&&!vi(t.fontSize));class Xi{static convert(t,e,i,n){const r={x:0,y:0,width:e,height:i};if(!t)return r;const s=n.getVideoFit(),a=n.getVisibleRegionOfVideo({inPixels:!0});if(b(t))t.isMeasuredInPercentage?"contain"===s||null===a?(r.x=t.x/100*e,r.y=t.y/100*i,r.width=t.width/100*e,r.height=t.height/100*i):(r.x=a.x+t.x/100*a.width,r.y=a.y+t.y/100*a.height,r.width=t.width/100*a.width,r.height=t.height/100*a.height):"contain"===s||null===a?(r.x=t.x,r.y=t.y,r.width=t.width,r.height=t.height):(r.x=t.x+a.x,r.y=t.y+a.y,r.width=t.width>a.width?a.width:t.width,r.height=t.height>a.height?a.height:t.height);else{if(!y(t))throw TypeError("Invalid region.");t.isMeasuredInPercentage?"contain"===s||null===a?(r.x=t.left/100*e,r.y=t.top/100*i,r.width=(t.right-t.left)/100*e,r.height=(t.bottom-t.top)/100*i):(r.x=a.x+t.left/100*a.width,r.y=a.y+t.top/100*a.height,r.width=(t.right-t.left)/100*a.width,r.height=(t.bottom-t.top)/100*a.height):"contain"===s||null===a?(r.x=t.left,r.y=t.top,r.width=t.right-t.left,r.height=t.bottom-t.top):(r.x=t.left+a.x,r.y=t.top+a.y,r.width=t.right-t.left>a.width?a.width:t.right-t.left,r.height=t.bottom-t.top>a.height?a.height:t.bottom-t.top)}return r.x=Math.round(r.x),r.y=Math.round(r.y),r.width=Math.round(r.width),r.height=Math.round(r.height),r}}var Zi,qi;class Ki{constructor(){Zi.set(this,new Map),qi.set(this,!1)}get disposed(){return ni(this,qi,"f")}on(t,e){t=t.toLowerCase();const i=ni(this,Zi,"f").get(t);if(i){if(i.includes(e))return;i.push(e)}else ni(this,Zi,"f").set(t,[e])}off(t,e){t=t.toLowerCase();const i=ni(this,Zi,"f").get(t);if(!i)return;const n=i.indexOf(e);-1!==n&&i.splice(n,1)}offAll(t){t=t.toLowerCase();const e=ni(this,Zi,"f").get(t);e&&(e.length=0)}fire(t,e=[],i={async:!1,copy:!0}){e||(e=[]),t=t.toLowerCase();const n=ni(this,Zi,"f").get(t);if(n&&n.length){i=Object.assign({async:!1,copy:!0},i);for(let r of n){if(!r)continue;let s=[];if(i.copy)for(let i of e){try{i=JSON.parse(JSON.stringify(i))}catch(t){}s.push(i)}else s=e;let a=!1;if(i.async)setTimeout((()=>{this.disposed||n.includes(r)&&r.apply(i.target,s)}),0);else try{a=r.apply(i.target,s)}catch(t){}if(!0===a)break}}}dispose(){ri(this,qi,!0)}}function Ji(t,e,i){return(i.x-t.x)*(e.y-t.y)==(e.x-t.x)*(i.y-t.y)&&Math.min(t.x,e.x)<=i.x&&i.x<=Math.max(t.x,e.x)&&Math.min(t.y,e.y)<=i.y&&i.y<=Math.max(t.y,e.y)}function $i(t){return Math.abs(t)<1e-6?0:t<0?-1:1}function Qi(t,e,i,n){let r=t[0]*(i[1]-e[1])+e[0]*(t[1]-i[1])+i[0]*(e[1]-t[1]),s=t[0]*(n[1]-e[1])+e[0]*(t[1]-n[1])+n[0]*(e[1]-t[1]);return!((r^s)>=0&&0!==r&&0!==s||(r=i[0]*(t[1]-n[1])+n[0]*(i[1]-t[1])+t[0]*(n[1]-i[1]),s=i[0]*(e[1]-n[1])+n[0]*(i[1]-e[1])+e[0]*(n[1]-i[1]),(r^s)>=0&&0!==r&&0!==s))}Zi=new WeakMap,qi=new WeakMap;const tn=async t=>{if("string"!=typeof t)throw new TypeError("Invalid url.");const e=await fetch(t);if(!e.ok)throw Error("Network Error: "+e.statusText);const i=await e.text();if(!i.trim().startsWith("<"))throw Error("Unable to get valid HTMLElement.");const n=document.createElement("div");if(n.insertAdjacentHTML("beforeend",i),1===n.childElementCount&&n.firstChild instanceof HTMLTemplateElement)return n.firstChild.content;const r=new DocumentFragment;for(let t of n.children)r.append(t);return r};class en{static multiply(t,e){const i=[];for(let n=0;n<3;n++){const r=e.slice(3*n,3*n+3);for(let e=0;e<3;e++){const n=[t[e],t[e+3],t[e+6]].reduce(((t,e,i)=>t+e*r[i]),0);i.push(n)}}return i}static identity(){return[1,0,0,0,1,0,0,0,1]}static translate(t,e,i){return en.multiply(t,[1,0,0,0,1,0,e,i,1])}static rotate(t,e){var i=Math.cos(e),n=Math.sin(e);return en.multiply(t,[i,-n,0,n,i,0,0,0,1])}static scale(t,e,i){return en.multiply(t,[e,0,0,0,i,0,0,0,1])}}var nn,rn,sn,an,on,ln,hn,cn,dn,un,fn,gn,mn,pn,_n,vn,yn,wn,En,Cn,Sn,Tn,bn,In,xn,Rn,On,Dn,An,Mn,Ln,Fn,Pn,kn,Nn,Bn,jn,Vn,Un,Gn,Wn,Yn,Hn,zn,Xn,Zn,qn,Kn,Jn,$n,Qn,tr,er,ir,nr,rr,sr,ar,or,lr,hr,cr,dr,ur,fr,gr,mr,pr,_r,vr,yr,wr,Er,Cr,Sr,Tr,br,Ir,xr,Rr,Or;class Dr{static createDrawingStyle(t){if(!zi(t))throw new Error("Invalid style definition.");let e,i=Dr.USER_START_STYLE_ID;for(;ni(Dr,nn,"f",rn).has(i);)i++;e=i;const n=JSON.parse(JSON.stringify(t));n.id=e;for(let t in ni(Dr,nn,"f",sn))n.hasOwnProperty(t)||(n[t]=ni(Dr,nn,"f",sn)[t]);return ni(Dr,nn,"f",rn).set(e,n),n.id}static _getDrawingStyle(t,e){if("number"!=typeof t)throw new Error("Invalid style id.");const i=ni(Dr,nn,"f",rn).get(t);return i?e?JSON.parse(JSON.stringify(i)):i:null}static getDrawingStyle(t){return this._getDrawingStyle(t,!0)}static getAllDrawingStyles(){return JSON.parse(JSON.stringify(Array.from(ni(Dr,nn,"f",rn).values())))}static _updateDrawingStyle(t,e){if(!zi(e))throw new Error("Invalid style definition.");const i=ni(Dr,nn,"f",rn).get(t);if(i)for(let t in e)i.hasOwnProperty(t)&&(i[t]=e[t])}static updateDrawingStyle(t,e){this._updateDrawingStyle(t,e)}}nn=Dr,Dr.STYLE_BLUE_STROKE=1,Dr.STYLE_GREEN_STROKE=2,Dr.STYLE_ORANGE_STROKE=3,Dr.STYLE_YELLOW_STROKE=4,Dr.STYLE_BLUE_STROKE_FILL=5,Dr.STYLE_GREEN_STROKE_FILL=6,Dr.STYLE_ORANGE_STROKE_FILL=7,Dr.STYLE_YELLOW_STROKE_FILL=8,Dr.STYLE_BLUE_STROKE_TRANSPARENT=9,Dr.STYLE_GREEN_STROKE_TRANSPARENT=10,Dr.STYLE_ORANGE_STROKE_TRANSPARENT=11,Dr.USER_START_STYLE_ID=1024,rn={value:new Map([[Dr.STYLE_BLUE_STROKE,{id:Dr.STYLE_BLUE_STROKE,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[Dr.STYLE_GREEN_STROKE,{id:Dr.STYLE_GREEN_STROKE,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dr.STYLE_ORANGE_STROKE,{id:Dr.STYLE_ORANGE_STROKE,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dr.STYLE_YELLOW_STROKE,{id:Dr.STYLE_YELLOW_STROKE,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[Dr.STYLE_BLUE_STROKE_FILL,{id:Dr.STYLE_BLUE_STROKE_FILL,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dr.STYLE_GREEN_STROKE_FILL,{id:Dr.STYLE_GREEN_STROKE_FILL,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dr.STYLE_ORANGE_STROKE_FILL,{id:Dr.STYLE_ORANGE_STROKE_FILL,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dr.STYLE_YELLOW_STROKE_FILL,{id:Dr.STYLE_YELLOW_STROKE_FILL,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dr.STYLE_BLUE_STROKE_TRANSPARENT,{id:Dr.STYLE_BLUE_STROKE_TRANSPARENT,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dr.STYLE_GREEN_STROKE_TRANSPARENT,{id:Dr.STYLE_GREEN_STROKE_TRANSPARENT,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dr.STYLE_ORANGE_STROKE_TRANSPARENT,{id:Dr.STYLE_ORANGE_STROKE_TRANSPARENT,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}]])},sn={value:{lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}},"undefined"!=typeof document&&"undefined"!=typeof window&&(_i.StaticCanvas.prototype.dispose=function(){return this.isRendering&&(_i.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject((function(t){t.dispose&&t.dispose()})),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),_i.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},_i.Object.prototype.transparentCorners=!1,_i.Object.prototype.cornerSize=20,_i.Object.prototype.touchCornerSize=100,_i.Object.prototype.cornerColor="rgb(254,142,20)",_i.Object.prototype.cornerStyle="circle",_i.Object.prototype.strokeUniform=!0,_i.Object.prototype.hasBorders=!1,_i.Canvas.prototype.containerClass="",_i.Canvas.prototype.getPointer=function(t,e){if(this._absolutePointer&&!e)return this._absolutePointer;if(this._pointer&&e)return this._pointer;var i=this.upperCanvasEl;let n,r=_i.util.getPointer(t,i),s=i.getBoundingClientRect(),a=s.width||0,o=s.height||0;a&&o||("top"in s&&"bottom"in s&&(o=Math.abs(s.top-s.bottom)),"right"in s&&"left"in s&&(a=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=this.restorePointerVpt(r));var l=this.getRetinaScaling();if(1!==l&&(r.x/=l,r.y/=l),0!==a&&0!==o){var h=window.getComputedStyle(i).objectFit,c=i.width,d=i.height,u=a,f=o;n={width:c/u,height:d/f};var g,m,p=c/d,_=u/f;return"contain"===h?p>_?(g=u,m=u/p,{x:r.x*n.width,y:(r.y-(f-m)/2)*n.width}):(g=f*p,m=f,{x:(r.x-(u-g)/2)*n.height,y:r.y*n.height}):"cover"===h?p>_?{x:(c-n.height*u)/2+r.x*n.height,y:r.y*n.height}:{x:r.x*n.width,y:(d-n.width*f)/2+r.y*n.width}:{x:r.x*n.width,y:r.y*n.height}}return n={width:1,height:1},{x:r.x*n.width,y:r.y*n.height}},_i.Canvas.prototype._onTouchStart=function(t){let e;for(let i=0;ii&&!_?(l.push(h),h=[],a=g,_=!0):a+=v,_||o||h.push(f),h=h.concat(d),m=o?0:this._measureWord([f],e,u),u++,_=!1,g>p&&(p=g);return y&&l.push(h),p+n>this.dynamicMinWidth&&(this.dynamicMinWidth=p-v+n),l});class Ar{get width(){return this.fabricCanvas.width}get height(){return this.fabricCanvas.height}set _allowMultiSelect(t){this.fabricCanvas.selection=t,this.fabricCanvas.renderAll()}get _allowMultiSelect(){return this.fabricCanvas.selection}constructor(t,e,i){if(this.mapType_StateAndStyleId=new Map,this.mode="viewer",this.onSelectionChanged=null,this._arrDrwaingItem=[],this._arrFabricObject=[],this._visible=!0,t.hasOwnProperty("getFabricCanvas"))this.fabricCanvas=t.getFabricCanvas();else{let e=this.fabricCanvas=new _i.Canvas(t,Object.assign(i,{allowTouchScrolling:!0,selection:!1}));e.setDimensions({width:"100%",height:"100%"},{cssOnly:!0}),e.lowerCanvasEl.className="",e.upperCanvasEl.className="",e.on("selection:created",(function(t){const e=t.selected,i=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!i.includes(e)&&i.push(e)}for(let t of i){const i=[];for(let n of e){const e=n.getDrawingItem();e._drawingLayer===t&&i.push(e)}setTimeout((()=>{t.onSelectionChanged&&t.onSelectionChanged(i,[])}),0)}})),e.on("before:selection:cleared",(function(t){const e=this.getActiveObjects(),i=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!i.includes(e)&&i.push(e)}for(let t of i){const i=[];for(let n of e){const e=n.getDrawingItem();e._drawingLayer===t&&i.push(e)}setTimeout((()=>{const e=[];for(let n of i)t.hasDrawingItem(n)&&e.push(n);e.length>0&&t.onSelectionChanged&&t.onSelectionChanged([],e)}),0)}})),e.on("selection:updated",(function(t){const e=t.selected,i=t.deselected,n=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!n.includes(e)&&n.push(e)}for(let t of i){const e=t.getDrawingItem()._drawingLayer;e&&!n.includes(e)&&n.push(e)}for(let t of n){const n=[],r=[];for(let i of e){const e=i.getDrawingItem();e._drawingLayer===t&&n.push(e)}for(let e of i){const i=e.getDrawingItem();i._drawingLayer===t&&r.push(i)}setTimeout((()=>{t.onSelectionChanged&&t.onSelectionChanged(n,r)}),0)}})),e.wrapperEl.style.position="absolute",t.getFabricCanvas=()=>this.fabricCanvas}let n,r;switch(this.fabricCanvas.id=e,this.id=e,e){case Ar.DDN_LAYER_ID:n=Dr.getDrawingStyle(Dr.STYLE_BLUE_STROKE),r=Dr.getDrawingStyle(Dr.STYLE_BLUE_STROKE_FILL);break;case Ar.DBR_LAYER_ID:n=Dr.getDrawingStyle(Dr.STYLE_ORANGE_STROKE),r=Dr.getDrawingStyle(Dr.STYLE_ORANGE_STROKE_FILL);break;case Ar.DLR_LAYER_ID:n=Dr.getDrawingStyle(Dr.STYLE_GREEN_STROKE),r=Dr.getDrawingStyle(Dr.STYLE_GREEN_STROKE_FILL);break;default:n=Dr.getDrawingStyle(Dr.STYLE_YELLOW_STROKE),r=Dr.getDrawingStyle(Dr.STYLE_YELLOW_STROKE_FILL)}for(let t of Ai.arrMediaTypes)this.mapType_StateAndStyleId.set(t,{default:n.id,selected:r.id})}getId(){return this.id}setVisible(t){if(t){for(let t of this._arrFabricObject)t.visible=!0,t.hasControls=!0;this._visible=!0}else{for(let t of this._arrFabricObject)t.visible=!1,t.hasControls=!1;this._visible=!1}this.fabricCanvas.renderAll()}isVisible(){return this._visible}_getItemCurrentStyle(t){return t.styleId?Dr.getDrawingStyle(t.styleId):Dr.getDrawingStyle(t._mapState_StyleId.get(t.styleSelector))||null}_changeMediaTypeCurStyleInStyleSelector(t,e,i,n){const r=this.getDrawingItems((e=>e._mediaType===t));for(let t of r)t.styleSelector===e&&this._changeItemStyle(t,i,!0);n||this.fabricCanvas.renderAll()}_changeItemStyle(t,e,i){if(!t||!e)return;const n=t._getFabricObject();"number"==typeof t.styleId&&(e=Dr.getDrawingStyle(t.styleId)),n.strokeWidth=e.lineWidth,"fill"===e.paintMode?(n.fill=e.fillStyle,n.stroke=e.fillStyle):"stroke"===e.paintMode?(n.fill="transparent",n.stroke=e.strokeStyle):"strokeAndFill"===e.paintMode&&(n.fill=e.fillStyle,n.stroke=e.strokeStyle),n.fontFamily&&(n.fontFamily=e.fontFamily),n.fontSize&&(n.fontSize=e.fontSize),n.group||(n.dirty=!0),i||this.fabricCanvas.renderAll()}_updateGroupItem(t,e,i){if(!t||!e)return;const n=t.getChildDrawingItems();if("add"===i){if(n.includes(e))return;const i=e._getFabricObject();if(this.fabricCanvas.getObjects().includes(i)){if(!this._arrFabricObject.includes(i))throw new Error("Existed in other drawing layers.");e._zIndex=null}else{let i;if(e.styleId)i=Dr.getDrawingStyle(e.styleId);else{const n=this.mapType_StateAndStyleId.get(e._mediaType);i=Dr.getDrawingStyle(n[t.styleSelector]);const r=()=>{this._changeItemStyle(e,Dr.getDrawingStyle(this.mapType_StateAndStyleId.get(e._mediaType).selected),!0)},s=()=>{this._changeItemStyle(e,Dr.getDrawingStyle(this.mapType_StateAndStyleId.get(e._mediaType).default),!0)};e._on("selected",r),e._on("deselected",s),e._funcChangeStyleToSelected=r,e._funcChangeStyleToDefault=s}e._drawingLayer=this,e._drawingLayerId=this.id,this._changeItemStyle(e,i,!0)}t._fabricObject.addWithUpdate(e._getFabricObject())}else{if("remove"!==i)return;if(!n.includes(e))return;e._zIndex=null,e._drawingLayer=null,e._drawingLayerId=null,e._off("selected",e._funcChangeStyleToSelected),e._off("deselected",e._funcChangeStyleToDefault),e._funcChangeStyleToSelected=null,e._funcChangeStyleToDefault=null,t._fabricObject.removeWithUpdate(e._getFabricObject())}this.fabricCanvas.renderAll()}_addDrawingItem(t,e){if(!(t instanceof Ai))throw new TypeError("Invalid 'drawingItem'.");if(t._drawingLayer){if(t._drawingLayer==this)return;throw new Error("This drawing item has existed in other layer.")}let i=t._getFabricObject();const n=this.fabricCanvas.getObjects();let r,s;if(n.includes(i)){if(this._arrFabricObject.includes(i))return;throw new Error("Existed in other drawing layers.")}if("group"===t._mediaType){r=t.getChildDrawingItems();for(let t of r)if(t._drawingLayer&&t._drawingLayer!==this)throw new Error("The childItems of DT_Group have existed in other drawing layers.")}if(e&&"object"==typeof e&&!Array.isArray(e))for(let t in e)i.set(t,e[t]);if(r){for(let t of r){const e=this.mapType_StateAndStyleId.get(t._mediaType);for(let i of Ai.arrStyleSelectors)t._mapState_StyleId.set(i,e[i]);if(t.styleId)s=Dr.getDrawingStyle(t.styleId);else{s=Dr.getDrawingStyle(e.default);const i=()=>{this._changeItemStyle(t,Dr.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).selected),!0)},n=()=>{this._changeItemStyle(t,Dr.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).default),!0)};t._on("selected",i),t._on("deselected",n),t._funcChangeStyleToSelected=i,t._funcChangeStyleToDefault=n}t._drawingLayer=this,t._drawingLayerId=this.id,this._changeItemStyle(t,s,!0)}i.dirty=!0,this.fabricCanvas.renderAll()}else{const e=this.mapType_StateAndStyleId.get(t._mediaType);for(let i of Ai.arrStyleSelectors)t._mapState_StyleId.set(i,e[i]);if(t.styleId)s=Dr.getDrawingStyle(t.styleId);else{s=Dr.getDrawingStyle(e.default);const i=()=>{this._changeItemStyle(t,Dr.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).selected))},n=()=>{this._changeItemStyle(t,Dr.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).default))};t._on("selected",i),t._on("deselected",n),t._funcChangeStyleToSelected=i,t._funcChangeStyleToDefault=n}this._changeItemStyle(t,s)}t._zIndex=this.id,t._drawingLayer=this,t._drawingLayerId=this.id;const a=this._arrFabricObject.length;let o=n.length;if(a)o=n.indexOf(this._arrFabricObject[a-1])+1;else for(let e=0;et.toLowerCase())):e=Ai.arrMediaTypes,i?i.forEach((t=>t.toLowerCase())):i=Ai.arrStyleSelectors;const n=Dr.getDrawingStyle(t);if(!n)throw new Error(`The 'drawingStyle' with id '${t}' doesn't exist.`);let r;for(let s of e)if(r=this.mapType_StateAndStyleId.get(s),r)for(let e of i){this._changeMediaTypeCurStyleInStyleSelector(s,e,n,!0),r[e]=t;for(let i of this._arrDrwaingItem)i._mediaType===s&&i._mapState_StyleId.set(e,t)}this.fabricCanvas.renderAll()}setDefaultStyle(t,e,i){const n=[];i&fi.DIMT_RECTANGLE&&n.push("rect"),i&fi.DIMT_QUADRILATERAL&&n.push("quad"),i&fi.DIMT_TEXT&&n.push("text"),i&fi.DIMT_ARC&&n.push("arc"),i&fi.DIMT_IMAGE&&n.push("image"),i&fi.DIMT_POLYGON&&n.push("polygon"),i&fi.DIMT_LINE&&n.push("line");const r=[];e&gi.DIS_DEFAULT&&r.push("default"),e&gi.DIS_SELECTED&&r.push("selected"),this._setDefaultStyle(t,n.length?n:null,r.length?r:null)}setMode(t){if("viewer"===(t=t.toLowerCase())){for(let t of this._arrDrwaingItem)t._setEditable(!1);this.fabricCanvas.discardActiveObject(),this.fabricCanvas.renderAll(),this.mode="viewer"}else{if("editor"!==t)throw new RangeError("Invalid value.");for(let t of this._arrDrwaingItem)t._setEditable(!0);this.mode="editor"}this._manager._switchPointerEvent()}getMode(){return this.mode}_setDimensions(t,e){this.fabricCanvas.setDimensions(t,e)}_setObjectFit(t){if(t=t.toLowerCase(),!["contain","cover"].includes(t))throw new Error(`Unsupported value '${t}'.`);this.fabricCanvas.lowerCanvasEl.style.objectFit=t,this.fabricCanvas.upperCanvasEl.style.objectFit=t}_getObjectFit(){return this.fabricCanvas.lowerCanvasEl.style.objectFit}renderAll(){for(let t of this._arrDrwaingItem){const e=this._getItemCurrentStyle(t);this._changeItemStyle(t,e,!0)}this.fabricCanvas.renderAll()}dispose(){this.clearDrawingItems(),1===this._manager._arrDrawingLayer.length&&(this.fabricCanvas.wrapperEl.style.pointerEvents="none",this.fabricCanvas.dispose(),this._arrDrwaingItem.length=0,this._arrFabricObject.length=0)}}Ar.DDN_LAYER_ID=1,Ar.DBR_LAYER_ID=2,Ar.DLR_LAYER_ID=3,Ar.USER_DEFINED_LAYER_BASE_ID=100,Ar.TIP_LAYER_ID=999;class Mr{constructor(){this._arrDrawingLayer=[]}createDrawingLayer(t,e){if(this.getDrawingLayer(e))throw new Error("Existed drawing layer id.");const i=new Ar(t,e,{enableRetinaScaling:!1});return i._manager=this,this._arrDrawingLayer.push(i),this._switchPointerEvent(),i}deleteDrawingLayer(t){const e=this.getDrawingLayer(t);if(!e)return;const i=this._arrDrawingLayer;e.dispose(),i.splice(i.indexOf(e),1),this._switchPointerEvent()}clearDrawingLayers(){for(let t of this._arrDrawingLayer)t.dispose();this._arrDrawingLayer.length=0}getDrawingLayer(t){for(let e of this._arrDrawingLayer)if(e.getId()===t)return e;return null}getAllDrawingLayers(){return Array.from(this._arrDrawingLayer)}getSelectedDrawingItems(){if(!this._arrDrawingLayer.length)return;const t=this._getFabricCanvas().getActiveObjects(),e=[];for(let i of t)e.push(i.getDrawingItem());return e}setDimensions(t,e){this._arrDrawingLayer.length&&this._arrDrawingLayer[0]._setDimensions(t,e)}setObjectFit(t){for(let e of this._arrDrawingLayer)e&&e._setObjectFit(t)}getObjectFit(){return this._arrDrawingLayer.length?this._arrDrawingLayer[0]._getObjectFit():null}setVisible(t){this._arrDrawingLayer.length&&(this._getFabricCanvas().wrapperEl.style.display=t?"block":"none")}_getFabricCanvas(){return this._arrDrawingLayer.length?this._arrDrawingLayer[0].fabricCanvas:null}_switchPointerEvent(){if(this._arrDrawingLayer.length)for(let t of this._arrDrawingLayer)t.getMode()}}class Lr extends ji{constructor(t,e,i,n,r){super(t,{x:e,y:i,width:n,height:0},r),an.set(this,void 0),on.set(this,void 0),this._fabricObject.paddingTop=15,this._fabricObject.calcTextHeight=function(){for(var t=0,e=0,i=this._textLines.length;e=0&&ri(this,on,setTimeout((()=>{this.set("visible",!1),this._drawingLayer&&this._drawingLayer.renderAll()}),ni(this,an,"f")))}getDuration(){return ni(this,an,"f")}}an=new WeakMap,on=new WeakMap;class Fr{constructor(){ln.add(this),hn.set(this,void 0),cn.set(this,void 0),dn.set(this,void 0),un.set(this,!0),this._drawingLayerManager=new Mr}createDrawingLayerBaseCvs(t,e,i="contain"){if("number"!=typeof t||t<=1)throw new Error("Invalid 'width'.");if("number"!=typeof e||e<=1)throw new Error("Invalid 'height'.");if(!["contain","cover"].includes(i))throw new Error("Unsupported 'objectFit'.");const n=document.createElement("canvas");return n.width==t&&n.height==e||(n.width=t,n.height=e),n.style.objectFit=i,n}_createDrawingLayer(t,e,i,n){if(!this._layerBaseCvs){let r;try{r=this.getContentDimensions()}catch(t){if("Invalid content dimensions."!==(t.message||t))throw t}e||(e=(null==r?void 0:r.width)||1280),i||(i=(null==r?void 0:r.height)||720),n||(n=(null==r?void 0:r.objectFit)||"contain"),this._layerBaseCvs=this.createDrawingLayerBaseCvs(e,i,n)}const r=this._layerBaseCvs,s=this._drawingLayerManager.createDrawingLayer(r,t);return this._innerComponent.getElement("drawing-layer")||this._innerComponent.setElement("drawing-layer",r.parentElement),s}createDrawingLayer(){let t;for(let e=Ar.USER_DEFINED_LAYER_BASE_ID;;e++)if(!this._drawingLayerManager.getDrawingLayer(e)&&e!==Ar.TIP_LAYER_ID){t=e;break}return this._createDrawingLayer(t)}deleteDrawingLayer(t){var e;this._drawingLayerManager.deleteDrawingLayer(t),this._drawingLayerManager.getAllDrawingLayers().length||(null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null)}deleteUserDefinedDrawingLayer(t){if("number"!=typeof t)throw new TypeError("Invalid id.");if(tt.getId()>=0&&t.getId()!==Ar.TIP_LAYER_ID))}updateDrawingLayers(t){((t,e,i)=>{if(!(t<=1||e<=1)){if(!["contain","cover"].includes(i))throw new Error("Unsupported 'objectFit'.");this._drawingLayerManager.setDimensions({width:t,height:e},{backstoreOnly:!0}),this._drawingLayerManager.setObjectFit(i)}})(t.width,t.height,t.objectFit)}getSelectedDrawingItems(){return this._drawingLayerManager.getSelectedDrawingItems()}setTipConfig(t){if(!(Yi(e=t)&&C(e.topLeftPoint)&&vi(e.width))||e.width<=0||!vi(e.duration)||"coordinateBase"in e&&!["view","image"].includes(e.coordinateBase))throw new Error("Invalid tip config.");var e;ri(this,hn,JSON.parse(JSON.stringify(t))),ni(this,hn,"f").coordinateBase||(ni(this,hn,"f").coordinateBase="view"),ri(this,dn,t.duration),ni(this,ln,"m",pn).call(this)}getTipConfig(){return ni(this,hn,"f")?ni(this,hn,"f"):null}setTipVisible(t){if("boolean"!=typeof t)throw new TypeError("Invalid value.");this._tip&&(this._tip.set("visible",t),this._drawingLayerOfTip&&this._drawingLayerOfTip.renderAll()),ri(this,un,t)}isTipVisible(){return ni(this,un,"f")}updateTipMessage(t){if(!ni(this,hn,"f"))throw new Error("Tip config is not set.");this._tipStyleId||(this._tipStyleId=Dr.createDrawingStyle({fillStyle:"#FFFFFF",paintMode:"fill",fontFamily:"Open Sans",fontSize:40})),this._drawingLayerOfTip||(this._drawingLayerOfTip=this._drawingLayerManager.getDrawingLayer(Ar.TIP_LAYER_ID)||this._createDrawingLayer(Ar.TIP_LAYER_ID)),this._tip?this._tip.set("text",t):this._tip=ni(this,ln,"m",fn).call(this,t,ni(this,hn,"f").topLeftPoint.x,ni(this,hn,"f").topLeftPoint.y,ni(this,hn,"f").width,ni(this,hn,"f").coordinateBase,this._tipStyleId),ni(this,ln,"m",gn).call(this,this._tip,this._drawingLayerOfTip),this._tip.set("visible",ni(this,un,"f")),this._drawingLayerOfTip&&this._drawingLayerOfTip.renderAll(),ni(this,cn,"f")&&clearTimeout(ni(this,cn,"f")),ni(this,dn,"f")>=0&&ri(this,cn,setTimeout((()=>{ni(this,ln,"m",mn).call(this)}),ni(this,dn,"f")))}}hn=new WeakMap,cn=new WeakMap,dn=new WeakMap,un=new WeakMap,ln=new WeakSet,fn=function(t,e,i,n,r,s){const a=new Lr(t,e,i,n,s);return a.coordinateBase=r,a},gn=function(t,e){e.hasDrawingItem(t)||e.addDrawingItems([t])},mn=function(){this._tip&&this._drawingLayerOfTip.removeDrawingItems([this._tip])},pn=function(){if(!this._tip)return;const t=ni(this,hn,"f");this._tip.coordinateBase=t.coordinateBase,this._tip.setTextRect({x:t.topLeftPoint.x,y:t.topLeftPoint.y,width:t.width,height:0}),this._tip.set("width",this._tip.get("width")),this._tip._drawingLayer&&this._tip._drawingLayer.renderAll()};class Pr extends HTMLElement{constructor(){super(),_n.set(this,void 0);const t=new DocumentFragment,e=document.createElement("div");e.setAttribute("class","wrapper"),t.appendChild(e),ri(this,_n,e);const i=document.createElement("slot");i.setAttribute("name","single-frame-input-container"),e.append(i);const n=document.createElement("slot");n.setAttribute("name","content"),e.append(n);const r=document.createElement("slot");r.setAttribute("name","drawing-layer"),e.append(r);const s=document.createElement("style");s.textContent='\n.wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n}\n::slotted(canvas[slot="content"]) {\n object-fit: contain;\n pointer-events: none;\n}\n::slotted(div[slot="single-frame-input-container"]) {\n width: 1px;\n height: 1px;\n overflow: hidden;\n pointer-events: none;\n}\n::slotted(*) {\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n}\n ',t.appendChild(s),this.attachShadow({mode:"open"}).appendChild(t)}getWrapper(){return ni(this,_n,"f")}setElement(t,e){if(!(e instanceof HTMLElement))throw new TypeError("Invalid 'el'.");if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");this.removeElement(t),e.setAttribute("slot",t),this.appendChild(e)}getElement(t){if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");return this.querySelector(`[slot="${t}"]`)}removeElement(t){var e;if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");null===(e=this.querySelectorAll(`[slot="${t}"]`))||void 0===e||e.forEach((t=>t.remove()))}}_n=new WeakMap,customElements.get("dce-component")||customElements.define("dce-component",Pr);class kr extends Fr{static get engineResourcePath(){return R(Dt.engineResourcePaths).dcvData+"ui/"}static set defaultUIElementURL(t){kr._defaultUIElementURL=t}static get defaultUIElementURL(){var t;return null===(t=kr._defaultUIElementURL)||void 0===t?void 0:t.replace("@engineResourcePath/",kr.engineResourcePath)}static async createInstance(t){const e=new kr;return"string"==typeof t&&(t=t.replace("@engineResourcePath/",kr.engineResourcePath)),await e.setUIElement(t||kr.defaultUIElementURL),e}static _transformCoordinates(t,e,i,n,r,s,a){const o=s/n,l=a/r;t.x=Math.round(t.x/o+e),t.y=Math.round(t.y/l+i)}set _singleFrameMode(t){if(!["disabled","image","camera"].includes(t))throw new Error("Invalid value.");if(t!==ni(this,xn,"f")){if(ri(this,xn,t),ni(this,vn,"m",Dn).call(this))ri(this,Cn,null),this._videoContainer=null,this._innerComponent.removeElement("content"),this._innerComponent&&(this._innerComponent.addEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="block");else if(this._innerComponent&&(this._innerComponent.removeEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none"),!ni(this,Cn,"f")){const t=document.createElement("video");t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.width="100%",t.style.height="100%",t.style.objectFit=this.getVideoFit(),t.setAttribute("autoplay","true"),t.setAttribute("playsinline","true"),t.setAttribute("crossOrigin","anonymous"),t.setAttribute("muted","true"),["iPhone","iPad","Mac"].includes(ii.OS)&&t.setAttribute("poster","data:image/gif;base64,R0lGODlhAQABAIEAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgEAAEEBAA7"),ri(this,Cn,t);const e=document.createElement("div");e.append(t),e.style.overflow="hidden",this._videoContainer=e,this._innerComponent.setElement("content",e)}ni(this,vn,"m",Dn).call(this)||this._hideDefaultSelection?(this._selCam&&(this._selCam.style.display="none"),this._selRsl&&(this._selRsl.style.display="none"),this._selMinLtr&&(this._selMinLtr.style.display="none")):(this._selCam&&(this._selCam.style.display="block"),this._selRsl&&(this._selRsl.style.display="block"),this._selMinLtr&&(this._selMinLtr.style.display="block"),this._stopLoading())}}get _singleFrameMode(){return ni(this,xn,"f")}get disposed(){return ni(this,On,"f")}constructor(){super(),vn.add(this),yn.set(this,void 0),wn.set(this,void 0),En.set(this,void 0),this._poweredByVisible=!0,this.containerClassName="dce-video-container",Cn.set(this,void 0),this.videoFit="contain",this._hideDefaultSelection=!1,this._divScanArea=null,this._divScanLight=null,this._bgLoading=null,this._selCam=null,this._bgCamera=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,this._poweredBy=null,Sn.set(this,null),this.regionMaskFillStyle="rgba(0,0,0,0.5)",this.regionMaskStrokeStyle="rgb(254,142,20)",this.regionMaskLineWidth=6,Tn.set(this,!1),bn.set(this,!1),In.set(this,{width:0,height:0}),this._updateLayersTimeout=500,this._videoResizeListener=()=>{ni(this,vn,"m",Pn).call(this),this._updateLayersTimeoutId&&clearTimeout(this._updateLayersTimeoutId),this._updateLayersTimeoutId=setTimeout((()=>{this.disposed||(this.eventHandler.fire("videoEl:resized",null,{async:!1}),this.eventHandler.fire("content:updated",null,{async:!1}),this.isScanLaserVisible()&&ni(this,vn,"m",Fn).call(this))}),this._updateLayersTimeout)},this._windowResizeListener=()=>{kr._onLog&&kr._onLog("window resize event triggered."),ni(this,In,"f").width===document.documentElement.clientWidth&&ni(this,In,"f").height===document.documentElement.clientHeight||(ni(this,In,"f").width=document.documentElement.clientWidth,ni(this,In,"f").height=document.documentElement.clientHeight,this._videoResizeListener())},xn.set(this,"disabled"),this._clickIptSingleFrameMode=()=>{if(!ni(this,vn,"m",Dn).call(this))return;let t;if(this._singleFrameInputContainer)t=this._singleFrameInputContainer.firstElementChild;else{t=document.createElement("input"),t.setAttribute("type","file"),"camera"===this._singleFrameMode?(t.setAttribute("capture",""),t.setAttribute("accept","image/*")):"image"===this._singleFrameMode&&(t.removeAttribute("capture"),t.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp")),t.addEventListener("change",(async()=>{const e=t.files[0];t.value="";{const t=async t=>{let e=null,i=null;if("undefined"!=typeof createImageBitmap)try{if(e=await createImageBitmap(t),e)return e}catch(t){}var n;return e||(i=await(n=t,new Promise(((t,e)=>{let i=URL.createObjectURL(n),r=new Image;r.src=i,r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=t=>{e(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}})))),i},i=(t,e,i,n)=>{t.width==i&&t.height==n||(t.width=i,t.height=n);const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height),r.drawImage(e,0,0)},n=await t(e),r=n instanceof HTMLImageElement?n.naturalWidth:n.width,s=n instanceof HTMLImageElement?n.naturalHeight:n.height;let a=this._cvsSingleFrameMode;const o=null==a?void 0:a.width,l=null==a?void 0:a.height;a||(a=document.createElement("canvas"),this._cvsSingleFrameMode=a),i(a,n,r,s),this._innerComponent.setElement("content",a),o===a.width&&l===a.height||this.eventHandler.fire("content:updated",null,{async:!1})}this._onSingleFrameAcquired&&setTimeout((()=>{this._onSingleFrameAcquired(this._cvsSingleFrameMode)}),0)})),t.style.position="absolute",t.style.top="-9999px",t.style.backgroundColor="transparent",t.style.color="transparent";const e=document.createElement("div");e.append(t),this._innerComponent.setElement("single-frame-input-container",e),this._singleFrameInputContainer=e}null==t||t.click()},Rn.set(this,[]),this._capturedResultReceiver={onCapturedResultReceived:(t,e)=>{var i,n,r,s;if(this.disposed||e&&e._isPauseScan)return;if(this.clearAllInnerDrawingItems(),!t)return;const a=t.originalImageTag;if(!a)return;const o=t.items;if(!(null==o?void 0:o.length))return;const l=(null===(i=a.cropRegion)||void 0===i?void 0:i.left)||0,h=(null===(n=a.cropRegion)||void 0===n?void 0:n.top)||0,c=(null===(r=a.cropRegion)||void 0===r?void 0:r.right)?a.cropRegion.right-l:a.originalWidth,d=(null===(s=a.cropRegion)||void 0===s?void 0:s.bottom)?a.cropRegion.bottom-h:a.originalHeight,u=a.currentWidth,f=a.currentHeight,g=(t,e,i,n,r,s,a,o,l=[],h)=>{e.forEach((t=>kr._transformCoordinates(t,i,n,r,s,a,o)));const c=new Gi({points:[{x:e[0].x,y:e[0].y},{x:e[1].x,y:e[1].y},{x:e[2].x,y:e[2].y},{x:e[3].x,y:e[3].y}]},h);for(let t of l)c.addNote(t);t.addDrawingItems([c]),ni(this,Rn,"f").push(c)};let m,p;for(let t of o)switch(t.type){case Q.CRIT_ORIGINAL_IMAGE:break;case Q.CRIT_BARCODE:m=this.getDrawingLayer(Ar.DBR_LAYER_ID),p=[{name:"format",content:t.formatString},{name:"text",content:t.text}],(null==e?void 0:e.isBarcodeVerifyOpen)?t.verified?g(m,t.location.points,l,h,c,d,u,f,p):g(m,t.location.points,l,h,c,d,u,f,p,Dr.STYLE_ORANGE_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,d,u,f,p);break;case Q.CRIT_TEXT_LINE:m=this.getDrawingLayer(Ar.DLR_LAYER_ID),p=[{name:"text",content:t.text}],e.isLabelVerifyOpen?t.verified?g(m,t.location.points,l,h,c,d,u,f,p):g(m,t.location.points,l,h,c,d,u,f,p,Dr.STYLE_GREEN_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,d,u,f,p);break;case Q.CRIT_DETECTED_QUAD:m=this.getDrawingLayer(Ar.DDN_LAYER_ID),(null==e?void 0:e.isDetectVerifyOpen)?t.crossVerificationStatus===ot.CVS_PASSED?g(m,t.location.points,l,h,c,d,u,f,[]):g(m,t.location.points,l,h,c,d,u,f,[],Dr.STYLE_BLUE_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,d,u,f,[]);break;case Q.CRIT_DESKEWED_IMAGE:m=this.getDrawingLayer(Ar.DDN_LAYER_ID),(null==e?void 0:e.isNormalizeVerifyOpen)?t.crossVerificationStatus===ot.CVS_PASSED?g(m,t.sourceLocation.points,l,h,c,d,u,f,[]):g(m,t.sourceLocation.points,l,h,c,d,u,f,[],Dr.STYLE_BLUE_STROKE_TRANSPARENT):g(m,t.sourceLocation.points,l,h,c,d,u,f,[]);break;case Q.CRIT_PARSED_RESULT:case Q.CRIT_ENHANCED_IMAGE:break;default:throw new Error("Illegal item type.")}if(t.decodedBarcodesResult)for(let e=0;ekr._transformCoordinates(t,l,h,c,d,u,f)));if(t.recognizedTextLinesResult)for(let e=0;ekr._transformCoordinates(t,l,h,c,d,u,f)));if(t.processedDocumentResult){if(t.processedDocumentResult.detectedQuadResultItems)for(let e=0;ekr._transformCoordinates(t,l,h,c,d,u,f)));if(t.processedDocumentResult.deskewedImageResultItems)for(let e=0;ekr._transformCoordinates(t,l,h,c,d,u,f)))}}},On.set(this,!1),this.eventHandler=new Ki,this.eventHandler.on("content:updated",(()=>{ni(this,yn,"f")&&clearTimeout(ni(this,yn,"f")),ri(this,yn,setTimeout((()=>{if(this.disposed)return;let t;this._updateVideoContainer();try{t=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}this.updateDrawingLayers(t),this.updateConvertedRegion(t)}),0))})),this.eventHandler.on("videoEl:resized",(()=>{ni(this,wn,"f")&&clearTimeout(ni(this,wn,"f")),ri(this,wn,setTimeout((()=>{this.disposed||this._updateVideoContainer()}),0))}))}_setUIElement(t){this.UIElement=t,this._unbindUI(),this._bindUI()}async setUIElement(t){let e;if("string"==typeof t){let i=await tn(t);e=document.createElement("div"),Object.assign(e.style,{width:"100%",height:"100%"}),e.attachShadow({mode:"open"}).appendChild(i.cloneNode(!0))}else e=t;this._setUIElement(e)}getUIElement(){return this.UIElement}_bindUI(){var t,e;if(!this.UIElement)throw new Error("Need to set 'UIElement'.");if(this._innerComponent)return;let i=this.UIElement;i=i.shadowRoot||i;let n=(null===(t=i.classList)||void 0===t?void 0:t.contains(this.containerClassName))?i:i.querySelector(`.${this.containerClassName}`);if(!n)throw Error(`Can not find the element with class '${this.containerClassName}'.`);if(this._innerComponent=document.createElement("dce-component"),n.appendChild(this._innerComponent),ni(this,vn,"m",Dn).call(this));else{const t=document.createElement("video");Object.assign(t.style,{position:"absolute",left:"0",top:"0",width:"100%",height:"100%",objectFit:this.getVideoFit()}),t.setAttribute("autoplay","true"),t.setAttribute("playsinline","true"),t.setAttribute("crossOrigin","anonymous"),t.setAttribute("muted","true"),["iPhone","iPad","Mac"].includes(ii.OS)&&t.setAttribute("poster","data:image/gif;base64,R0lGODlhAQABAIEAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgEAAEEBAA7"),ri(this,Cn,t);const e=document.createElement("div");e.append(t),e.style.overflow="hidden",this._videoContainer=e,this._innerComponent.setElement("content",e)}if(this._selRsl=i.querySelector(".dce-sel-resolution"),this._selMinLtr=i.querySelector(".dlr-sel-minletter"),this._divScanArea=i.querySelector(".dce-scanarea"),this._divScanLight=i.querySelector(".dce-scanlight"),this._bgLoading=i.querySelector(".dce-bg-loading"),this._bgCamera=i.querySelector(".dce-bg-camera"),this._selCam=i.querySelector(".dce-sel-camera"),this._optGotRsl=i.querySelector(".dce-opt-gotResolution"),this._btnClose=i.querySelector(".dce-btn-close"),this._optGotMinLtr=i.querySelector(".dlr-opt-gotMinLtr"),this._poweredBy=i.querySelector(".dce-msg-poweredby"),this._selRsl&&(this._hideDefaultSelection||ni(this,vn,"m",Dn).call(this)||this._selRsl.options.length||(this._selRsl.innerHTML=['','','',''].join(""),this._optGotRsl=this._selRsl.options[0])),this._selMinLtr&&(this._hideDefaultSelection||ni(this,vn,"m",Dn).call(this)||this._selMinLtr.options.length||(this._selMinLtr.innerHTML=['','','','','','','','','','',''].join(""),this._optGotMinLtr=this._selMinLtr.options[0])),this.isScanLaserVisible()||ni(this,vn,"m",Pn).call(this),ni(this,vn,"m",Dn).call(this)&&(this._innerComponent&&(this._innerComponent.addEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="block")),ni(this,vn,"m",Dn).call(this)||this._hideDefaultSelection?(this._selCam&&(this._selCam.style.display="none"),this._selRsl&&(this._selRsl.style.display="none"),this._selMinLtr&&(this._selMinLtr.style.display="none")):(this._selCam&&(this._selCam.style.display="block"),this._selRsl&&(this._selRsl.style.display="block"),this._selMinLtr&&(this._selMinLtr.style.display="block"),this._stopLoading()),window.ResizeObserver){this._resizeObserver||(this._resizeObserver=new ResizeObserver((t=>{var e;kr._onLog&&kr._onLog("resize observer triggered.");for(let i of t)i.target===(null===(e=this._innerComponent)||void 0===e?void 0:e.getWrapper())&&this._videoResizeListener()})));const t=null===(e=this._innerComponent)||void 0===e?void 0:e.getWrapper();t&&this._resizeObserver.observe(t)}ni(this,In,"f").width=document.documentElement.clientWidth,ni(this,In,"f").height=document.documentElement.clientHeight,window.addEventListener("resize",this._windowResizeListener)}_unbindUI(){var t,e,i,n;ni(this,vn,"m",Dn).call(this)?(this._innerComponent&&(this._innerComponent.removeEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none")):this._stopLoading(),ni(this,vn,"m",Pn).call(this),null===(t=this._drawingLayerManager)||void 0===t||t.clearDrawingLayers(),null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null,this._drawingLayerOfMask=null,this._drawingLayerOfTip=null,null===(i=this._innerComponent)||void 0===i||i.remove(),this._innerComponent=null,ri(this,Cn,null),null===(n=this._videoContainer)||void 0===n||n.remove(),this._videoContainer=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,this._divScanArea=null,this._divScanLight=null,this._singleFrameInputContainer&&(this._singleFrameInputContainer.remove(),this._singleFrameInputContainer=null),window.ResizeObserver&&this._resizeObserver&&this._resizeObserver.disconnect(),window.removeEventListener("resize",this._windowResizeListener)}_startLoading(){this._bgLoading&&(this._bgLoading.style.display="",this._bgLoading.style.animationPlayState="")}_stopLoading(){this._bgLoading&&(this._bgLoading.style.display="none",this._bgLoading.style.animationPlayState="paused")}_renderCamerasInfo(t,e){if(this._selCam){let i;this._selCam.textContent="";for(let n of e){const e=document.createElement("option");e.value=n.deviceId,e.innerText=n.label,this._selCam.append(e),n.deviceId&&t&&t.deviceId==n.deviceId&&(i=e)}this._selCam.value=i?i.value:""}let i=this.UIElement;if(i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")){let t=i.querySelector(".dce-mn-cameras");if(t){t.textContent="";for(let i of e){const e=document.createElement("div");e.classList.add("dce-mn-camera-option"),e.setAttribute("data-davice-id",i.deviceId),e.textContent=i.label,t.append(e)}}}}_renderResolutionInfo(t){this._optGotRsl&&(this._optGotRsl.setAttribute("data-width",t.width),this._optGotRsl.setAttribute("data-height",t.height),this._optGotRsl.innerText="got "+t.width+"x"+t.height,this._selRsl&&this._optGotRsl.parentNode==this._selRsl&&(this._selRsl.value="got"));{let e=this.UIElement;e=(null==e?void 0:e.shadowRoot)||e;let i=null==e?void 0:e.querySelector(".dce-mn-resolution-box");if(i){let e="";if(t&&t.width&&t.height){let i=Math.max(t.width,t.height),n=Math.min(t.width,t.height);e=n<=1080?n+"P":i<3e3?"2K":Math.round(i/1e3)+"K"}i.textContent=e}}}getVideoElement(){return ni(this,Cn,"f")}isVideoLoaded(){return!(!ni(this,Cn,"f")||!this.cameraEnhancer)&&4==ni(this,Cn,"f").readyState}setVideoFit(t){if(t=t.toLowerCase(),!["contain","cover"].includes(t))throw new Error(`Unsupported value '${t}'.`);if(this.videoFit=t,!ni(this,Cn,"f"))return;if(ni(this,Cn,"f").style.objectFit=t,ni(this,vn,"m",Dn).call(this))return;let e;this._updateVideoContainer();try{e=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}this.updateConvertedRegion(e);const i=this.getConvertedRegion();ni(this,vn,"m",kn).call(this,e,i),ni(this,vn,"m",An).call(this,e,i),this.updateDrawingLayers(e)}getVideoFit(){return this.videoFit}getContentDimensions(){var t,e,i,n;let r,s,a;if(ni(this,vn,"m",Dn).call(this)?(r=null===(i=this._cvsSingleFrameMode)||void 0===i?void 0:i.width,s=null===(n=this._cvsSingleFrameMode)||void 0===n?void 0:n.height,a="contain"):(r=null===(t=ni(this,Cn,"f"))||void 0===t?void 0:t.videoWidth,s=null===(e=ni(this,Cn,"f"))||void 0===e?void 0:e.videoHeight,a=this.getVideoFit()),!r||!s)throw new Error("Invalid content dimensions.");return{width:r,height:s,objectFit:a}}updateConvertedRegion(t){y(this.scanRegion)?this.scanRegion.isMeasuredInPercentage?0===this.scanRegion.top&&100===this.scanRegion.bottom&&0===this.scanRegion.left&&100===this.scanRegion.right&&(this.scanRegion=null):0===this.scanRegion.top&&this.scanRegion.bottom===t.height&&0===this.scanRegion.left&&this.scanRegion.right===t.width&&(this.scanRegion=null):b(this.scanRegion)&&(this.scanRegion.isMeasuredInPercentage?0===this.scanRegion.x&&0===this.scanRegion.y&&100===this.scanRegion.width&&100===this.scanRegion.height&&(this.scanRegion=null):0===this.scanRegion.x&&0===this.scanRegion.y&&this.scanRegion.width===t.width&&this.scanRegion.height===t.height&&(this.scanRegion=null));const e=Xi.convert(this.scanRegion,t.width,t.height,this);ri(this,Sn,e),ni(this,En,"f")&&clearTimeout(ni(this,En,"f")),ri(this,En,setTimeout((()=>{let t;try{t=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}ni(this,vn,"m",An).call(this,t,e),ni(this,vn,"m",kn).call(this,t,e)}),0))}getConvertedRegion(){return ni(this,Sn,"f")}setScanRegion(t){if(null!=t&&!y(t)&&!b(t))throw TypeError("Invalid 'region'.");let e;this.scanRegion=t?JSON.parse(JSON.stringify(t)):null;try{e=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}this.updateConvertedRegion(e)}getScanRegion(){return JSON.parse(JSON.stringify(this.scanRegion))}getVisibleRegionOfVideo(t){if("disabled"!==this.cameraEnhancer.singleFrameMode)return null;if(!this.isVideoLoaded())throw new Error("The video is not loaded.");const e=ni(this,Cn,"f").videoWidth,i=ni(this,Cn,"f").videoHeight,n=this.getVideoFit(),{width:r,height:s}=this._innerComponent.getBoundingClientRect();if(r<=0||s<=0)return null;let a;const o={x:0,y:0,width:e,height:i,isMeasuredInPercentage:!1};if("cover"===n&&(r/s1){const t=ni(this,Cn,"f").videoWidth,e=ni(this,Cn,"f").videoHeight,{width:n,height:r}=this._innerComponent.getBoundingClientRect(),s=t/e;if(n/rt.remove())),ni(this,Rn,"f").length=0}dispose(){this._unbindUI(),ri(this,On,!0)}}yn=new WeakMap,wn=new WeakMap,En=new WeakMap,Cn=new WeakMap,Sn=new WeakMap,Tn=new WeakMap,bn=new WeakMap,In=new WeakMap,xn=new WeakMap,Rn=new WeakMap,On=new WeakMap,vn=new WeakSet,Dn=function(){return"disabled"!==this._singleFrameMode},An=function(t,e){!e||0===e.x&&0===e.y&&e.width===t.width&&e.height===t.height?this.clearScanRegionMask():this.setScanRegionMask(e.x,e.y,e.width,e.height)},Mn=function(){this._drawingLayerOfMask&&this._drawingLayerOfMask.setVisible(!0)},Ln=function(){this._drawingLayerOfMask&&this._drawingLayerOfMask.setVisible(!1)},Fn=function(){this._divScanLight&&"none"==this._divScanLight.style.display&&(this._divScanLight.style.display="block")},Pn=function(){this._divScanLight&&(this._divScanLight.style.display="none")},kn=function(t,e){if(!this._divScanArea)return;if(!this._innerComponent.getElement("content"))return;const{width:i,height:n,objectFit:r}=t;e||(e={x:0,y:0,width:i,height:n});const{width:s,height:a}=this._innerComponent.getBoundingClientRect();if(s<=0||a<=0)return;const o=s/a,l=i/n;let h,c,d,u,f=1;if("contain"===r)o{const e=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,e),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);const i=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),{positions:e,texCoords:i}},i=t=>{const e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e},n=(t,e)=>{const i=t.createProgram();if(e.forEach((e=>t.attachShader(i,e))),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS)){const e=new Error(`An error occured linking the program: ${t.getProgramInfoLog(i)}.`);throw e.name="WebGLError",e}return t.useProgram(i),i},r=(t,e,i)=>{const n=t.createShader(e);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){const e=new Error(`An error occured compiling the shader: ${t.getShaderInfoLog(n)}.`);throw e.name="WebGLError",e}return n},s="\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n\n uniform mat3 u_matrix;\n uniform mat3 u_textureMatrix;\n\n varying vec2 v_texCoord;\n void main(void) {\n gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, 0, 1.0);\n v_texCoord = vec4((u_textureMatrix * vec3(a_texCoord, 1)).xy, 0, 1.0).xy;\n }\n ";let a="rgb";["rgba","rbga","grba","gbra","brga","bgra"].includes(p)&&(a=p.slice(0,3));const o=`\n precision mediump float;\n varying vec2 v_texCoord;\n uniform sampler2D u_image;\n uniform float uColorFactor;\n\n void main() {\n vec4 sample = texture2D(u_image, v_texCoord);\n float grey = 0.3 * sample.r + 0.59 * sample.g + 0.11 * sample.b;\n gl_FragColor = vec4(sample.${a} * (1.0 - uColorFactor) + (grey * uColorFactor), sample.a);\n }\n `,l=n(t,[r(t,t.VERTEX_SHADER,s),r(t,t.FRAGMENT_SHADER,o)]);ri(this,jn,{program:l,attribLocations:{vertexPosition:t.getAttribLocation(l,"a_position"),texPosition:t.getAttribLocation(l,"a_texCoord")},uniformLocations:{uSampler:t.getUniformLocation(l,"u_image"),uColorFactor:t.getUniformLocation(l,"uColorFactor"),uMatrix:t.getUniformLocation(l,"u_matrix"),uTextureMatrix:t.getUniformLocation(l,"u_textureMatrix")}}),ri(this,Vn,e(t)),ri(this,Bn,i(t)),ri(this,Nn,p)}const r=(t,e,i)=>{t.bindBuffer(t.ARRAY_BUFFER,e),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0)},v=(t,e,i)=>{const n=t.RGBA,r=t.RGBA,s=t.UNSIGNED_BYTE;t.bindTexture(t.TEXTURE_2D,e),t.texImage2D(t.TEXTURE_2D,0,n,r,s,i)},y=(t,e,a,m)=>{t.clearColor(0,0,0,1),t.clearDepth(1),t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),r(t,a.positions,e.attribLocations.vertexPosition),r(t,a.texCoords,e.attribLocations.texPosition),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,m),t.uniform1i(e.uniformLocations.uSampler,0),t.uniform1f(e.uniformLocations.uColorFactor,[pi.GREY,pi.GREY32].includes(p)?1:0);let _,v,y=en.translate(en.identity(),-1,-1);y=en.scale(y,2,2),y=en.scale(y,1/t.canvas.width,1/t.canvas.height),_=en.translate(y,d,u),_=en.scale(_,f,g),t.uniformMatrix3fv(e.uniformLocations.uMatrix,!1,_),s.isEnableMirroring?(v=en.translate(en.identity(),1,0),v=en.scale(v,-1,1),v=en.translate(v,o/i,l/n),v=en.scale(v,h/i,c/n)):(v=en.translate(en.identity(),o/i,l/n),v=en.scale(v,h/i,c/n)),t.uniformMatrix3fv(e.uniformLocations.uTextureMatrix,!1,v),t.drawArrays(t.TRIANGLES,0,6)};v(t,ni(this,Bn,"f"),e),y(t,ni(this,jn,"f"),ni(this,Vn,"f"),ni(this,Bn,"f"));const w=m||new Uint8Array(4*f*g);if(t.readPixels(d,u,f,g,t.RGBA,t.UNSIGNED_BYTE,w),255!==w[3]){Nr._onLog&&Nr._onLog("Incorrect WebGL drawing .");const t=new Error("WebGL error: incorrect drawing.");throw t.name="WebGLError",t}return Nr._onLog&&Nr._onLog("drawImage() in WebGL end. Costs: "+(Date.now()-a)),{context:t,pixelFormat:p===pi.GREY?pi.GREY32:p,bUseWebGL:!0}}catch(a){if(this.forceLoseContext(),null==(null==s?void 0:s.bUseWebGL))return Nr._onLog&&Nr._onLog("'drawImage()' in WebGL failed, try again in context2d."),this.useWebGLByDefault=!1,this.drawImage(t,e,i,n,r,Object.assign({},s,{bUseWebGL:!1}));throw a.name="WebGLError",a}}readCvsData(t,e,i){if(!(t instanceof CanvasRenderingContext2D||t instanceof WebGLRenderingContext))throw new Error("Invalid 'context'.");let n,r=0,s=0,a=t.canvas.width,o=t.canvas.height;if(e&&(e.x&&(r=e.x),e.y&&(s=e.y),e.width&&(a=e.width),e.height&&(o=e.height)),(null==i?void 0:i.length)<4*a*o)throw new Error("Unexpected size of the 'bufferContainer'.");if(t instanceof WebGLRenderingContext){const e=t;i?(e.readPixels(r,s,a,o,e.RGBA,e.UNSIGNED_BYTE,i),n=new Uint8Array(i.buffer,0,4*a*o)):(n=new Uint8Array(4*a*o),e.readPixels(r,s,a,o,e.RGBA,e.UNSIGNED_BYTE,n))}else if(t instanceof CanvasRenderingContext2D){let e;e=t.getImageData(r,s,a,o),n=new Uint8Array(e.data.buffer),null==i||i.set(n)}return n}transformPixelFormat(t,e,i,n){let r,s;if(Nr._onLog&&(r=Date.now(),Nr._onLog("transformPixelFormat(), START: "+r)),e===i)return Nr._onLog&&Nr._onLog("transformPixelFormat() end. Costs: "+(Date.now()-r)),n?new Uint8Array(t):t;const a=[pi.RGBA,pi.RBGA,pi.GRBA,pi.GBRA,pi.BRGA,pi.BGRA];if(a.includes(e))if(i===pi.GREY){s=new Uint8Array(t.length/4);for(let e=0;el||e.sy+e.sHeight>h)throw new Error("Invalid position.");null===(n=Nr._onLog)||void 0===n||n.call(Nr,"getImageData(), START: "+(c=Date.now()));const u=Math.round(e.sx),f=Math.round(e.sy),g=Math.round(e.sWidth),m=Math.round(e.sHeight),p=Math.round(e.dWidth),_=Math.round(e.dHeight);let v,y=(null==i?void 0:i.pixelFormat)||pi.RGBA,w=null==i?void 0:i.bufferContainer;if(w&&(pi.GREY===y&&w.length{if(!i)return t;let r=e+Math.round((t-e)/i)*i;return n&&(r=Math.min(r,n)),r};class jr{static get version(){return"4.2.12-dev-20250609101854"}static isStorageAvailable(t){let e;try{e=window[t];const i="__storage_test__";return e.setItem(i,i),e.removeItem(i),!0}catch(t){return t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name)&&e&&0!==e.length}}static findBestRearCameraInIOS(t,e){if(!t||!t.length)return null;let i=!1;if((null==e?void 0:e.getMainCamera)&&(i=!0),i){const e=["후면 카메라","背面カメラ","後置鏡頭","后置相机","กล้องด้านหลัง","बैक कैमरा","الكاميرا الخلفية","מצלמה אחורית","камера на задней панели","задня камера","задна камера","артқы камера","πίσω κάμερα","zadní fotoaparát","zadná kamera","tylny aparat","takakamera","stražnja kamera","rückkamera","kamera på baksidan","kamera belakang","kamera bak","hátsó kamera","fotocamera (posteriore)","câmera traseira","câmara traseira","cámara trasera","càmera posterior","caméra arrière","cameră spate","camera mặt sau","camera aan achterzijde","bagsidekamera","back camera","arka kamera"],i=t.find((t=>e.includes(t.label.toLowerCase())));return null==i?void 0:i.deviceId}{const e=["후면","背面","後置","后置","านหลัง","बैक","خلفية","אחורית","задняя","задней","задна","πίσω","zadní","zadná","tylny","trasera","traseira","taka","stražnja","spate","sau","rück","posteriore","posterior","hátsó","belakang","baksidan","bakre","bak","bagside","back","aртқы","arrière","arka","achterzijde"],i=["트리플","三镜头","三鏡頭","トリプル","สาม","ट्रिपल","ثلاثية","משולשת","үштік","тройная","тройна","потроєна","τριπλή","üçlü","trójobiektywowy","trostruka","trojný","trojitá","trippelt","trippel","triplă","triple","tripla","tiga","kolmois","ba camera"],n=["듀얼 와이드","雙廣角","双广角","デュアル広角","คู่ด้านหลังมุมกว้าง","ड्युअल वाइड","مزدوجة عريضة","כפולה רחבה","қос кең бұрышты","здвоєна ширококутна","двойная широкоугольная","двойна широкоъгълна","διπλή ευρεία","ç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"],r=t.filter((t=>{const i=t.label.toLowerCase();return e.some((t=>i.includes(t)))}));if(!r.length)return null;const s=r.find((t=>{const e=t.label.toLowerCase();return i.some((t=>e.includes(t)))}));if(s)return s.deviceId;const a=r.find((t=>{const e=t.label.toLowerCase();return n.some((t=>e.includes(t)))}));return a?a.deviceId:r[0].deviceId}}static findBestRearCamera(t,e){if(!t||!t.length)return null;if(["iPhone","iPad","Mac"].includes(ii.OS))return jr.findBestRearCameraInIOS(t,{getMainCamera:null==e?void 0:e.getMainCameraInIOS});const i=["후","背面","背置","後面","後置","后面","后置","านหลัง","หลัง","बैक","خلفية","אחורית","задняя","задня","задней","задна","πίσω","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"];for(let e of t){const t=e.label.toLowerCase();if(t&&i.some((e=>t.includes(e)))&&/\b0(\b)?/.test(t))return e.deviceId}return["Android","HarmonyOS"].includes(ii.OS)?t[t.length-1].deviceId:null}static findBestCamera(t,e,i){return t&&t.length?"environment"===e?this.findBestRearCamera(t,i):"user"===e?null:e?void 0:null:null}static async playVideo(t,e,i){if(!t)throw new Error("Invalid 'videoEl'.");if(!e)throw new Error("Invalid 'source'.");return new Promise((async(n,r)=>{let s;const a=()=>{t.removeEventListener("loadstart",c),t.removeEventListener("abort",d),t.removeEventListener("play",u),t.removeEventListener("error",f),t.removeEventListener("loadedmetadata",p)};let o=!1;const l=()=>{o=!0,s&&clearTimeout(s),a(),n(t)},h=t=>{s&&clearTimeout(s),a(),r(t)},c=()=>{t.addEventListener("abort",d,{once:!0})},d=()=>{const t=new Error("Video playing was interrupted.");t.name="AbortError",h(t)},u=()=>{l()},f=()=>{h(new Error(`Video error ${t.error.code}: ${t.error.message}.`))};let g;const m=new Promise((t=>{g=t})),p=()=>{g()};if(t.addEventListener("loadstart",c,{once:!0}),t.addEventListener("play",u,{once:!0}),t.addEventListener("error",f,{once:!0}),t.addEventListener("loadedmetadata",p,{once:!0}),"string"==typeof e||e instanceof String?t.src=e:t.srcObject=e,t.autoplay&&await new Promise((t=>{setTimeout(t,1e3)})),!o){i&&(s=setTimeout((()=>{a(),r(new Error("Failed to play video. Timeout."))}),i)),await m;try{await t.play(),l()}catch(t){console.warn("1st play error: "+((null==t?void 0:t.message)||t))}if(!o)try{await t.play(),l()}catch(t){console.warn("2rd play error: "+((null==t?void 0:t.message)||t)),h(t)}}}))}static async testCameraAccess(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))return{ok:!1,errorName:"InsecureContext",errorMessage:"Insecure context."};let n;try{n=t?await navigator.mediaDevices.getUserMedia(t):await navigator.mediaDevices.getUserMedia({video:!0})}catch(t){return{ok:!1,errorName:t.name,errorMessage:t.message}}finally{null==n||n.getTracks().forEach((t=>{t.stop()}))}return{ok:!0}}get state(){if(!ni(this,ir,"f"))return"closed";if("pending"===ni(this,ir,"f"))return"opening";if("fulfilled"===ni(this,ir,"f"))return"opened";throw new Error("Unknown state.")}set ifSaveLastUsedCamera(t){t?jr.isStorageAvailable("localStorage")?ri(this,$n,!0):(ri(this,$n,!1),console.warn("Local storage is unavailable")):ri(this,$n,!1)}get ifSaveLastUsedCamera(){return ni(this,$n,"f")}get isVideoPlaying(){return!(!ni(this,Hn,"f")||ni(this,Hn,"f").paused)&&"opened"===this.state}set tapFocusEventBoundEl(t){var e,i,n;if(!(t instanceof HTMLElement)&&null!=t)throw new TypeError("Invalid 'element'.");null===(e=ni(this,lr,"f"))||void 0===e||e.removeEventListener("click",ni(this,or,"f")),null===(i=ni(this,lr,"f"))||void 0===i||i.removeEventListener("touchend",ni(this,or,"f")),null===(n=ni(this,lr,"f"))||void 0===n||n.removeEventListener("touchmove",ni(this,ar,"f")),ri(this,lr,t),t&&(window.TouchEvent&&["Android","HarmonyOS","iPhone","iPad"].includes(ii.OS)?(t.addEventListener("touchend",ni(this,or,"f")),t.addEventListener("touchmove",ni(this,ar,"f"))):t.addEventListener("click",ni(this,or,"f")))}get tapFocusEventBoundEl(){return ni(this,lr,"f")}get disposed(){return ni(this,_r,"f")}constructor(t){var e,i;Yn.add(this),Hn.set(this,null),zn.set(this,void 0),this._zoomPreSetting=null,Xn.set(this,(()=>{"opened"===this.state&&ni(this,ur,"f").fire("resumed",null,{target:this,async:!1})})),Zn.set(this,(()=>{ni(this,ur,"f").fire("paused",null,{target:this,async:!1})})),qn.set(this,void 0),Kn.set(this,void 0),this.cameraOpenTimeout=15e3,this._arrCameras=[],Jn.set(this,void 0),$n.set(this,!1),this.ifSkipCameraInspection=!1,this.selectIOSRearMainCameraAsDefault=!1,Qn.set(this,void 0),tr.set(this,!0),er.set(this,void 0),ir.set(this,void 0),nr.set(this,!1),this._focusParameters={maxTimeout:400,minTimeout:300,kTimeout:void 0,oldDistance:null,fds:null,isDoingFocus:0,taskBackToContinous:null,curFocusTaskId:0,focusCancelableTime:1500,defaultFocusAreaSizeRatio:6,focusBackToContinousTime:5e3,tapFocusMinDistance:null,tapFocusMaxDistance:null,focusArea:null,tempBufferContainer:null,defaultTempBufferContainerLenRatio:1/4},rr.set(this,!1),this._focusSupported=!0,this.calculateCoordInVideo=(t,e)=>{let i,n;const r=window.getComputedStyle(ni(this,Hn,"f")).objectFit,s=this.getResolution(),a=ni(this,Hn,"f").getBoundingClientRect(),o=a.left,l=a.top,{width:h,height:c}=ni(this,Hn,"f").getBoundingClientRect();if(h<=0||c<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const d=h/c,u=s.width/s.height;let f=1;if("contain"===r)u>d?(f=h/s.width,i=(t-o)/f,n=(e-l-(c-h/u)/2)/f):(f=c/s.height,n=(e-l)/f,i=(t-o-(h-c*u)/2)/f);else{if("cover"!==r)throw new Error("Unsupported object-fit.");u>d?(f=c/s.height,n=(e-l)/f,i=(t-o+(c*u-h)/2)/f):(f=h/s.width,i=(t-o)/f,n=(e-l+(h/u-c)/2)/f)}return{x:i,y:n}},sr.set(this,!1),ar.set(this,(()=>{ri(this,sr,!0)})),or.set(this,(async t=>{var e;if(ni(this,sr,"f"))return void ri(this,sr,!1);if(!ni(this,rr,"f"))return;if(!this.isVideoPlaying)return;if(!ni(this,zn,"f"))return;if(!this._focusSupported)return;if(!this._focusParameters.fds&&(this._focusParameters.fds=null===(e=this.getCameraCapabilities())||void 0===e?void 0:e.focusDistance,!this._focusParameters.fds))return void(this._focusSupported=!1);if(null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),1==this._focusParameters.isDoingFocus)return;let i,n;if(this._focusParameters.taskBackToContinous&&(clearTimeout(this._focusParameters.taskBackToContinous),this._focusParameters.taskBackToContinous=null),t instanceof MouseEvent)i=t.clientX,n=t.clientY;else{if(!(t instanceof TouchEvent))throw new Error("Unknown event type.");if(!t.changedTouches.length)return;i=t.changedTouches[0].clientX,n=t.changedTouches[0].clientY}const r=this.getResolution(),s=2*Math.round(Math.min(r.width,r.height)/this._focusParameters.defaultFocusAreaSizeRatio/2);let a;try{a=this.calculateCoordInVideo(i,n)}catch(t){}if(a.x<0||a.x>r.width||a.y<0||a.y>r.height)return;const o={x:a.x+"px",y:a.y+"px"},l=s+"px",h=l;let c;jr._onLog&&(c=Date.now());try{await ni(this,Yn,"m",xr).call(this,o,l,h,this._focusParameters.tapFocusMinDistance,this._focusParameters.tapFocusMaxDistance)}catch(t){if(jr._onLog)throw jr._onLog(t),t}jr._onLog&&jr._onLog(`Tap focus costs: ${Date.now()-c} ms`),this._focusParameters.taskBackToContinous=setTimeout((()=>{var t;jr._onLog&&jr._onLog("Back to continuous focus."),null===(t=ni(this,zn,"f"))||void 0===t||t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch((()=>{}))}),this._focusParameters.focusBackToContinousTime),ni(this,ur,"f").fire("tapfocus",null,{target:this,async:!1})})),lr.set(this,null),hr.set(this,1),cr.set(this,{x:0,y:0}),this.updateVideoElWhenSoftwareScaled=()=>{if(!ni(this,Hn,"f"))return;const t=ni(this,hr,"f");if(t<1)throw new RangeError("Invalid scale value.");if(1===t)ni(this,Hn,"f").style.transform="";else{const e=window.getComputedStyle(ni(this,Hn,"f")).objectFit,i=ni(this,Hn,"f").videoWidth,n=ni(this,Hn,"f").videoHeight,{width:r,height:s}=ni(this,Hn,"f").getBoundingClientRect();if(r<=0||s<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const a=r/s,o=i/n;let l=1;"contain"===e?l=aa?s/(i/t):r/(n/t));const h=l*(1-1/t)*(i/2-ni(this,cr,"f").x),c=l*(1-1/t)*(n/2-ni(this,cr,"f").y);ni(this,Hn,"f").style.transform=`translate(${h}px, ${c}px) scale(${t})`}},dr.set(this,(function(){if(!(this.data instanceof Uint8Array||this.data instanceof Uint8ClampedArray))throw new TypeError("Invalid data.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const t=document.createElement("canvas");let e;if(t.width=this.width,t.height=this.height,this.pixelFormat===pi.GREY){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t{var t,e;if("visible"===document.visibilityState){if(jr._onLog&&jr._onLog("document visible. video paused: "+(null===(t=ni(this,Hn,"f"))||void 0===t?void 0:t.paused)),"opening"==this.state||"opened"==this.state){let e=!1;if(!this.isVideoPlaying){jr._onLog&&jr._onLog("document visible. Not auto resume. 1st resume start.");try{await this.resume(),e=!0}catch(t){jr._onLog&&jr._onLog("document visible. 1st resume video failed, try open instead.")}e||await ni(this,Yn,"m",Cr).call(this)}if(await new Promise((t=>setTimeout(t,300))),!this.isVideoPlaying){jr._onLog&&jr._onLog("document visible. 1st open failed. 2rd resume start."),e=!1;try{await this.resume(),e=!0}catch(t){jr._onLog&&jr._onLog("document visible. 2rd resume video failed, try open instead.")}e||await ni(this,Yn,"m",Cr).call(this)}}}else"hidden"===document.visibilityState&&(jr._onLog&&jr._onLog("document hidden. video paused: "+(null===(e=ni(this,Hn,"f"))||void 0===e?void 0:e.paused)),"opening"==this.state||"opened"==this.state&&this.isVideoPlaying&&this.pause())})),_r.set(this,!1),(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia)||setTimeout((()=>{jr.onWarning&&jr.onWarning("The browser is too old or the page is loaded from an insecure origin.")}),0),this.defaultConstraints={video:{facingMode:{ideal:"environment"}}},this.resetMediaStreamConstraints(),t instanceof HTMLVideoElement&&this.setVideoEl(t),ri(this,ur,new Ki),this.imageDataGetter=new Nr,document.addEventListener("visibilitychange",ni(this,pr,"f"))}setVideoEl(t){if(!(t&&t instanceof HTMLVideoElement))throw new Error("Invalid 'videoEl'.");t.addEventListener("play",ni(this,Xn,"f")),t.addEventListener("pause",ni(this,Zn,"f")),ri(this,Hn,t)}getVideoEl(){return ni(this,Hn,"f")}releaseVideoEl(){var t,e;null===(t=ni(this,Hn,"f"))||void 0===t||t.removeEventListener("play",ni(this,Xn,"f")),null===(e=ni(this,Hn,"f"))||void 0===e||e.removeEventListener("pause",ni(this,Zn,"f")),ri(this,Hn,null)}isVideoLoaded(){return!!ni(this,Hn,"f")&&4==ni(this,Hn,"f").readyState}async open(){if(ni(this,er,"f")&&!ni(this,tr,"f")){if("pending"===ni(this,ir,"f"))return ni(this,er,"f");if("fulfilled"===ni(this,ir,"f"))return}ni(this,ur,"f").fire("before:open",null,{target:this}),await ni(this,Yn,"m",Cr).call(this),ni(this,ur,"f").fire("played",null,{target:this,async:!1}),ni(this,ur,"f").fire("opened",null,{target:this,async:!1})}async close(){if("closed"===this.state)return;ni(this,ur,"f").fire("before:close",null,{target:this});const t=ni(this,er,"f");if(ni(this,Yn,"m",Tr).call(this),t&&"pending"===ni(this,ir,"f")){try{await t}catch(t){}if(!1===ni(this,tr,"f")){const t=new Error("'close()' was interrupted.");throw t.name="AbortError",t}}ri(this,er,null),ri(this,ir,null),ni(this,ur,"f").fire("closed",null,{target:this,async:!1})}pause(){if(!this.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==this.state)throw new Error("Camera or video is not open.");ni(this,Hn,"f").pause()}async resume(){if(!this.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==this.state)throw new Error("Camera or video is not open.");await ni(this,Hn,"f").play()}async setCamera(t){if("string"!=typeof t)throw new TypeError("Invalid 'deviceId'.");if("object"!=typeof ni(this,qn,"f").video&&(ni(this,qn,"f").video={}),delete ni(this,qn,"f").video.facingMode,ni(this,qn,"f").video.deviceId={exact:t},!("closed"===this.state||this.videoSrc||"opening"===this.state&&ni(this,tr,"f"))){ni(this,ur,"f").fire("before:camera:change",[],{target:this,async:!1}),await ni(this,Yn,"m",Sr).call(this);try{this.resetSoftwareScale()}catch(t){}return ni(this,Kn,"f")}}async switchToFrontCamera(t){if("object"!=typeof ni(this,qn,"f").video&&(ni(this,qn,"f").video={}),(null==t?void 0:t.resolution)&&(ni(this,qn,"f").video.width={ideal:t.resolution.width},ni(this,qn,"f").video.height={ideal:t.resolution.height}),delete ni(this,qn,"f").video.deviceId,ni(this,qn,"f").video.facingMode={exact:"user"},ri(this,Jn,null),!("closed"===this.state||this.videoSrc||"opening"===this.state&&ni(this,tr,"f"))){ni(this,ur,"f").fire("before:camera:change",[],{target:this,async:!1}),ni(this,Yn,"m",Sr).call(this);try{this.resetSoftwareScale()}catch(t){}return ni(this,Kn,"f")}}getCamera(){var t;if(ni(this,Kn,"f"))return ni(this,Kn,"f");{let e=(null===(t=ni(this,qn,"f").video)||void 0===t?void 0:t.deviceId)||"";if(e){e=e.exact||e.ideal||e;for(let t of this._arrCameras)if(t.deviceId===e)return JSON.parse(JSON.stringify(t))}return{deviceId:"",label:"",_checked:!1}}}async _getCameras(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let n=[];if(t)try{let t=await navigator.mediaDevices.getUserMedia({video:!0});n=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind)),t.getTracks().forEach((t=>{t.stop()}))}catch(t){console.error(t.message||t)}else n=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind));const r=[],s=[];if(this._arrCameras)for(let t of this._arrCameras)t._checked&&s.push(t);for(let t=0;t"videoinput"===t.kind));return i&&i.length&&!i[0].deviceId?this._getCameras(!0):this._getCameras(!1)}async getAllCameras(){return this.getCameras()}async setResolution(t,e,i){if("number"!=typeof t||t<=0)throw new TypeError("Invalid 'width'.");if("number"!=typeof e||e<=0)throw new TypeError("Invalid 'height'.");if("object"!=typeof ni(this,qn,"f").video&&(ni(this,qn,"f").video={}),i?(ni(this,qn,"f").video.width={exact:t},ni(this,qn,"f").video.height={exact:e}):(ni(this,qn,"f").video.width={ideal:t},ni(this,qn,"f").video.height={ideal:e}),"closed"===this.state||this.videoSrc||"opening"===this.state&&ni(this,tr,"f"))return null;ni(this,ur,"f").fire("before:resolution:change",[],{target:this,async:!1}),await ni(this,Yn,"m",Sr).call(this);try{this.resetSoftwareScale()}catch(t){}const n=this.getResolution();return{width:n.width,height:n.height}}getResolution(){if("opened"===this.state&&this.videoSrc&&ni(this,Hn,"f"))return{width:ni(this,Hn,"f").videoWidth,height:ni(this,Hn,"f").videoHeight};if(ni(this,zn,"f")){const t=ni(this,zn,"f").getSettings();return{width:t.width,height:t.height}}if(this.isVideoLoaded())return{width:ni(this,Hn,"f").videoWidth,height:ni(this,Hn,"f").videoHeight};{const t={width:0,height:0};let e=ni(this,qn,"f").video.width||0,i=ni(this,qn,"f").video.height||0;return e&&(t.width=e.exact||e.ideal||e),i&&(t.height=i.exact||i.ideal||i),t}}async getResolutions(t){var e,i,n,r,s,a,o,l,h,c,d;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let u="";const f=(t,e)=>{const i=ni(this,gr,"f").get(t);if(!i||!i.length)return!1;for(let t of i)if(t.width===e.width&&t.height===e.height)return!0;return!1};if(this._mediaStream){u=null===(d=ni(this,Kn,"f"))||void 0===d?void 0:d.deviceId;let e=ni(this,gr,"f").get(u);if(e&&!t)return JSON.parse(JSON.stringify(e));e=[],ni(this,gr,"f").set(u,e),ri(this,nr,!0);try{for(let t of this.detectedResolutions){await ni(this,zn,"f").applyConstraints({width:{ideal:t.width},height:{ideal:t.height}}),ni(this,Yn,"m",yr).call(this);const i=ni(this,zn,"f").getSettings(),n={width:i.width,height:i.height};f(u,n)||e.push({width:n.width,height:n.height})}}catch(t){throw ni(this,Yn,"m",Tr).call(this),ri(this,nr,!1),t}try{await ni(this,Yn,"m",Cr).call(this)}catch(t){if("AbortError"===t.name)return e;throw t}finally{ri(this,nr,!1)}return e}{const e=async(t,e,i)=>{const n={video:{deviceId:{exact:t},width:{ideal:e},height:{ideal:i}}};let r=null;try{r=await navigator.mediaDevices.getUserMedia(n)}catch(t){return null}if(!r)return null;const s=r.getVideoTracks();let a=null;try{const t=s[0].getSettings();a={width:t.width,height:t.height}}catch(t){const e=document.createElement("video");e.srcObject=r,a={width:e.videoWidth,height:e.videoHeight},e.srcObject=null}return s.forEach((t=>{t.stop()})),a};let i=(null===(s=null===(r=null===(n=ni(this,qn,"f"))||void 0===n?void 0:n.video)||void 0===r?void 0:r.deviceId)||void 0===s?void 0:s.exact)||(null===(l=null===(o=null===(a=ni(this,qn,"f"))||void 0===a?void 0:a.video)||void 0===o?void 0:o.deviceId)||void 0===l?void 0:l.ideal)||(null===(c=null===(h=ni(this,qn,"f"))||void 0===h?void 0:h.video)||void 0===c?void 0:c.deviceId);if(!i)return[];let d=ni(this,gr,"f").get(i);if(d&&!t)return JSON.parse(JSON.stringify(d));d=[],ni(this,gr,"f").set(i,d);for(let t of this.detectedResolutions){const n=await e(i,t.width,t.height);n&&!f(i,n)&&d.push({width:n.width,height:n.height})}return d}}async setMediaStreamConstraints(t,e){if(!(t=>{return null!==t&&"[object Object]"===(e=t,Object.prototype.toString.call(e));var e})(t))throw new TypeError("Invalid 'mediaStreamConstraints'.");ri(this,qn,JSON.parse(JSON.stringify(t))),ri(this,Jn,null),e&&ni(this,Yn,"m",Sr).call(this)}getMediaStreamConstraints(){return JSON.parse(JSON.stringify(ni(this,qn,"f")))}resetMediaStreamConstraints(){ri(this,qn,this.defaultConstraints?JSON.parse(JSON.stringify(this.defaultConstraints)):null)}getCameraCapabilities(){if(!ni(this,zn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return ni(this,zn,"f").getCapabilities?ni(this,zn,"f").getCapabilities():{}}getCameraSettings(){if(!ni(this,zn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return ni(this,zn,"f").getSettings()}async turnOnTorch(){if(!ni(this,zn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const t=this.getCameraCapabilities();if(!(null==t?void 0:t.torch))throw Error("Not supported.");await ni(this,zn,"f").applyConstraints({advanced:[{torch:!0}]})}async turnOffTorch(){if(!ni(this,zn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const t=this.getCameraCapabilities();if(!(null==t?void 0:t.torch))throw Error("Not supported.");await ni(this,zn,"f").applyConstraints({advanced:[{torch:!1}]})}async setColorTemperature(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!ni(this,zn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.colorTemperature;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Br(t,n.min,n.step,n.max)),await ni(this,zn,"f").applyConstraints({advanced:[{colorTemperature:t,whiteBalanceMode:"manual"}]}),t}getColorTemperature(){return this.getCameraSettings().colorTemperature||0}async setExposureCompensation(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!ni(this,zn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.exposureCompensation;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Br(t,n.min,n.step,n.max)),await ni(this,zn,"f").applyConstraints({advanced:[{exposureCompensation:t}]}),t}getExposureCompensation(){return this.getCameraSettings().exposureCompensation||0}async setFrameRate(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!ni(this,zn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");let n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.frameRate;if(!n)throw Error("Not supported.");e&&(tn.max&&(t=n.max));const r=this.getResolution();return await ni(this,zn,"f").applyConstraints({width:{ideal:Math.max(r.width,r.height)},frameRate:t}),t}getFrameRate(){return this.getCameraSettings().frameRate}async setFocus(t,e){if("object"!=typeof t||Array.isArray(t)||null==t)throw new TypeError("Invalid 'settings'.");if(!ni(this,zn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const i=this.getCameraCapabilities(),n=null==i?void 0:i.focusMode,r=null==i?void 0:i.focusDistance;if(!n)throw Error("Not supported.");if("string"!=typeof t.mode)throw TypeError("Invalid 'mode'.");const s=t.mode.toLowerCase();if(!n.includes(s))throw Error("Unsupported focus mode.");if("manual"===s){if(!r)throw Error("Manual focus unsupported.");if(t.hasOwnProperty("distance")){let i=t.distance;e&&(ir.max&&(i=r.max),i=Br(i,r.min,r.step,r.max)),this._focusParameters.focusArea=null,await ni(this,zn,"f").applyConstraints({advanced:[{focusMode:s,focusDistance:i}]})}else{if(!t.area)throw new Error("'distance' or 'area' should be specified in 'manual' mode.");{const e=t.area.centerPoint;let i=t.area.width,n=t.area.height;if(!i||!n){const t=this.getResolution();i||(i=2*Math.round(Math.min(t.width,t.height)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px"),n||(n=2*Math.round(Math.min(t.width,t.height)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px")}this._focusParameters.focusArea={centerPoint:{x:e.x,y:e.y},width:i,height:n},await ni(this,Yn,"m",xr).call(this,e,i,n)}}}else this._focusParameters.focusArea=null,await ni(this,zn,"f").applyConstraints({advanced:[{focusMode:s}]})}getFocus(){const t=this.getCameraSettings(),e=t.focusMode;return e?"manual"===e?this._focusParameters.focusArea?{mode:"manual",area:JSON.parse(JSON.stringify(this._focusParameters.focusArea))}:{mode:"manual",distance:t.focusDistance}:{mode:e}:null}enableTapToFocus(){ri(this,rr,!0)}disableTapToFocus(){ri(this,rr,!1)}isTapToFocusEnabled(){return ni(this,rr,"f")}async setZoom(t){if("object"!=typeof t||Array.isArray(t)||null==t)throw new TypeError("Invalid 'settings'.");if("number"!=typeof t.factor)throw new TypeError("Illegal type of 'factor'.");if(t.factor<1)throw new RangeError("Invalid 'factor'.");if("opened"===this.state){t.centerPoint?ni(this,Yn,"m",Rr).call(this,t.centerPoint):this.resetScaleCenter();try{if(ni(this,Yn,"m",Or).call(this,ni(this,cr,"f"))){const e=await this.setHardwareScale(t.factor,!0);let i=this.getHardwareScale();1==i&&1!=e&&(i=e),t.factor>i?this.setSoftwareScale(t.factor/i):this.setSoftwareScale(1)}else await this.setHardwareScale(1),this.setSoftwareScale(t.factor)}catch(e){const i=e.message||e;if("Not supported."!==i&&"Camera is not open."!==i)throw e;this.setSoftwareScale(t.factor)}}else this._zoomPreSetting=t}getZoom(){if("opened"!==this.state)throw new Error("Video is not playing.");let t=1;try{t=this.getHardwareScale()}catch(t){if("Camera is not open."!==(t.message||t))throw t}return{factor:t*ni(this,hr,"f")}}async resetZoom(){await this.setZoom({factor:1})}async setHardwareScale(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(t<1)throw new RangeError("Invalid 'value'.");if(!ni(this,zn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.zoom;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Br(t,n.min,n.step,n.max)),await ni(this,zn,"f").applyConstraints({advanced:[{zoom:t}]}),t}getHardwareScale(){return this.getCameraSettings().zoom||1}setSoftwareScale(t,e){if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(t<1)throw new RangeError("Invalid 'value'.");if("opened"!==this.state)throw new Error("Video is not playing.");e&&ni(this,Yn,"m",Rr).call(this,e),ri(this,hr,t),this.updateVideoElWhenSoftwareScaled()}getSoftwareScale(){return ni(this,hr,"f")}resetScaleCenter(){if("opened"!==this.state)throw new Error("Video is not playing.");const t=this.getResolution();ri(this,cr,{x:t.width/2,y:t.height/2})}resetSoftwareScale(){this.setSoftwareScale(1),this.resetScaleCenter()}getFrameData(t){if(this.disposed)throw Error("The 'Camera' instance has been disposed.");if(!this.isVideoLoaded())return null;if(ni(this,nr,"f"))return null;const e=Date.now();jr._onLog&&jr._onLog("getFrameData() START: "+e);const i=ni(this,Hn,"f").videoWidth,n=ni(this,Hn,"f").videoHeight;let r={sx:0,sy:0,sWidth:i,sHeight:n,dWidth:i,dHeight:n};(null==t?void 0:t.position)&&(r=JSON.parse(JSON.stringify(t.position)));let s=pi.RGBA;(null==t?void 0:t.pixelFormat)&&(s=t.pixelFormat);let a=ni(this,hr,"f");(null==t?void 0:t.scale)&&(a=t.scale);let o=ni(this,cr,"f");if(null==t?void 0:t.scaleCenter){if("string"!=typeof t.scaleCenter.x||"string"!=typeof t.scaleCenter.y)throw new Error("Invalid scale center.");let e=0,r=0;if(t.scaleCenter.x.endsWith("px"))e=parseFloat(t.scaleCenter.x);else{if(!t.scaleCenter.x.endsWith("%"))throw new Error("Invalid scale center.");e=parseFloat(t.scaleCenter.x)/100*i}if(t.scaleCenter.y.endsWith("px"))r=parseFloat(t.scaleCenter.y);else{if(!t.scaleCenter.y.endsWith("%"))throw new Error("Invalid scale center.");r=parseFloat(t.scaleCenter.y)/100*n}if(isNaN(e)||isNaN(r))throw new Error("Invalid scale center.");o.x=Math.round(e),o.y=Math.round(r)}let l=null;if((null==t?void 0:t.bufferContainer)&&(l=t.bufferContainer),0==i||0==n)return null;1!==a&&(r.sWidth=Math.round(r.sWidth/a),r.sHeight=Math.round(r.sHeight/a),r.sx=Math.round((1-1/a)*o.x+r.sx/a),r.sy=Math.round((1-1/a)*o.y+r.sy/a));const h=this.imageDataGetter.getImageData(ni(this,Hn,"f"),r,{pixelFormat:s,bufferContainer:l,isEnableMirroring:null==t?void 0:t.isEnableMirroring});if(!h)return null;const c=Date.now();return jr._onLog&&jr._onLog("getFrameData() END: "+c),{data:h.data,width:h.width,height:h.height,pixelFormat:h.pixelFormat,timeSpent:c-e,timeStamp:c,toCanvas:ni(this,dr,"f")}}on(t,e){if(!ni(this,fr,"f").includes(t.toLowerCase()))throw new Error(`Event '${t}' does not exist.`);ni(this,ur,"f").on(t,e)}off(t,e){ni(this,ur,"f").off(t,e)}async dispose(){this.tapFocusEventBoundEl=null,await this.close(),this.releaseVideoEl(),ni(this,ur,"f").dispose(),this.imageDataGetter.dispose(),document.removeEventListener("visibilitychange",ni(this,pr,"f")),ri(this,_r,!0)}}var Vr,Ur,Gr,Wr,Yr,Hr,zr,Xr,Zr,qr,Kr,Jr,$r,Qr,ts,es,is,ns,rs,ss,as,os,ls,hs,cs,ds,us,fs,gs,ms,ps,_s,vs,ys,ws,Es;Hn=new WeakMap,zn=new WeakMap,Xn=new WeakMap,Zn=new WeakMap,qn=new WeakMap,Kn=new WeakMap,Jn=new WeakMap,$n=new WeakMap,Qn=new WeakMap,tr=new WeakMap,er=new WeakMap,ir=new WeakMap,nr=new WeakMap,rr=new WeakMap,sr=new WeakMap,ar=new WeakMap,or=new WeakMap,lr=new WeakMap,hr=new WeakMap,cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,fr=new WeakMap,gr=new WeakMap,mr=new WeakMap,pr=new WeakMap,_r=new WeakMap,Yn=new WeakSet,vr=async function(){const t=this.getMediaStreamConstraints();if("boolean"==typeof t.video&&(t.video={}),t.video.deviceId);else if(ni(this,Jn,"f"))delete t.video.facingMode,t.video.deviceId={exact:ni(this,Jn,"f")};else if(this.ifSaveLastUsedCamera&&jr.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")){delete t.video.facingMode,t.video.deviceId={ideal:window.localStorage.getItem("dce_last_camera_id")};const e=JSON.parse(window.localStorage.getItem("dce_last_apply_width")),i=JSON.parse(window.localStorage.getItem("dce_last_apply_height"));e&&i&&(t.video.width=e,t.video.height=i)}else if(this.ifSkipCameraInspection);else{const e=async t=>{let e=null;return"environment"===t&&["Android","HarmonyOS","iPhone","iPad"].includes(ii.OS)?(await this._getCameras(!1),ni(this,Yn,"m",yr).call(this),e=jr.findBestCamera(this._arrCameras,"environment",{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault})):t||["Android","HarmonyOS","iPhone","iPad"].includes(ii.OS)||(await this._getCameras(!1),ni(this,Yn,"m",yr).call(this),e=jr.findBestCamera(this._arrCameras,null,{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault})),e};let i=t.video.facingMode;i instanceof Array&&i.length&&(i=i[0]),"object"==typeof i&&(i=i.exact||i.ideal);const n=await e(i);n&&(delete t.video.facingMode,t.video.deviceId={exact:n})}return t},yr=function(){if(ni(this,tr,"f")){const t=new Error("The operation was interrupted.");throw t.name="AbortError",t}},wr=async function(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let n;try{jr._onLog&&jr._onLog("======try getUserMedia========");let e=[0,500,1e3,2e3],i=null;const r=async t=>{for(let r of e){r&&(await new Promise((t=>setTimeout(t,r))),ni(this,Yn,"m",yr).call(this));try{jr._onLog&&jr._onLog("ask "+JSON.stringify(t)),n=await navigator.mediaDevices.getUserMedia(t),ni(this,Yn,"m",yr).call(this);break}catch(t){if("NotFoundError"===t.name||"NotAllowedError"===t.name||"AbortError"===t.name||"OverconstrainedError"===t.name)throw t;i=t,jr._onLog&&jr._onLog(t.message||t)}}};if(await r(t),!n&&"object"==typeof t.video&&(t.video.deviceId&&(delete t.video.deviceId,await r(t)),!n&&t.video.facingMode&&(delete t.video.facingMode,await r(t)),n||!t.video.width&&!t.video.height||(delete t.video.width,delete t.video.height,await r(t)),!n)){const t=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind));for(let e of t){const t={video:{deviceId:{ideal:e.deviceId},facingMode:{ideal:"environment"},width:{ideal:1920},height:{ideal:1080}}};if(await r(t),n)break}}if(!n)throw i;return n}catch(t){throw null==n||n.getTracks().forEach((t=>{t.stop()})),"NotFoundError"===t.name&&(DOMException?t=new DOMException("No camera available, please use a device with an accessible camera.",t.name):(t=new Error("No camera available, please use a device with an accessible camera.")).name="NotFoundError"),t}},Er=function(){this._mediaStream&&(this._mediaStream.getTracks().forEach((t=>{t.stop()})),this._mediaStream=null),ri(this,zn,null)},Cr=async function(){ri(this,tr,!1);const t=ri(this,Qn,Symbol());if(ni(this,er,"f")&&"pending"===ni(this,ir,"f")){try{await ni(this,er,"f")}catch(t){}ni(this,Yn,"m",yr).call(this)}if(t!==ni(this,Qn,"f"))return;const e=ri(this,er,(async()=>{ri(this,ir,"pending");try{if(this.videoSrc){if(!ni(this,Hn,"f"))throw new Error("'videoEl' should be set.");await jr.playVideo(ni(this,Hn,"f"),this.videoSrc,this.cameraOpenTimeout),ni(this,Yn,"m",yr).call(this)}else{let t=await ni(this,Yn,"m",vr).call(this);ni(this,Yn,"m",Er).call(this);let e=await ni(this,Yn,"m",wr).call(this,t);await this._getCameras(!1),ni(this,Yn,"m",yr).call(this);const i=()=>{const t=e.getVideoTracks();let i,n;if(t.length&&(i=t[0]),i){const t=i.getSettings();if(t)for(let e of this._arrCameras)if(t.deviceId===e.deviceId){e._checked=!0,e.label=i.label,n=e;break}}return n},n=ni(this,qn,"f");if("object"==typeof n.video){let r=n.video.facingMode;if(r instanceof Array&&r.length&&(r=r[0]),"object"==typeof r&&(r=r.exact||r.ideal),!(ni(this,Jn,"f")||this.ifSaveLastUsedCamera&&jr.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")||this.ifSkipCameraInspection||n.video.deviceId)){const n=i(),s=jr.findBestCamera(this._arrCameras,r,{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault});s&&s!=(null==n?void 0:n.deviceId)&&(e.getTracks().forEach((t=>{t.stop()})),t.video.deviceId={exact:s},e=await ni(this,Yn,"m",wr).call(this,t),ni(this,Yn,"m",yr).call(this))}}const r=i();(null==r?void 0:r.deviceId)&&(ri(this,Jn,r&&r.deviceId),this.ifSaveLastUsedCamera&&jr.isStorageAvailable&&(window.localStorage.setItem("dce_last_camera_id",ni(this,Jn,"f")),"object"==typeof t.video&&t.video.width&&t.video.height&&(window.localStorage.setItem("dce_last_apply_width",JSON.stringify(t.video.width)),window.localStorage.setItem("dce_last_apply_height",JSON.stringify(t.video.height))))),ni(this,Hn,"f")&&(await jr.playVideo(ni(this,Hn,"f"),e,this.cameraOpenTimeout),ni(this,Yn,"m",yr).call(this)),this._mediaStream=e;const s=e.getVideoTracks();(null==s?void 0:s.length)&&ri(this,zn,s[0]),ri(this,Kn,r)}}catch(t){throw ni(this,Yn,"m",Tr).call(this),ri(this,ir,null),t}ri(this,ir,"fulfilled")})());return e},Sr=async function(){var t;if("closed"===this.state||this.videoSrc)return;const e=null===(t=ni(this,Kn,"f"))||void 0===t?void 0:t.deviceId,i=this.getResolution();await ni(this,Yn,"m",Cr).call(this);const n=this.getResolution();e&&e!==ni(this,Kn,"f").deviceId&&ni(this,ur,"f").fire("camera:changed",[ni(this,Kn,"f").deviceId,e],{target:this,async:!1}),i.width==n.width&&i.height==n.height||ni(this,ur,"f").fire("resolution:changed",[{width:n.width,height:n.height},{width:i.width,height:i.height}],{target:this,async:!1}),ni(this,ur,"f").fire("played",null,{target:this,async:!1})},Tr=function(){ni(this,Yn,"m",Er).call(this),ri(this,Kn,null),ni(this,Hn,"f")&&(ni(this,Hn,"f").srcObject=null,this.videoSrc&&(ni(this,Hn,"f").pause(),ni(this,Hn,"f").currentTime=0)),ri(this,tr,!0);try{this.resetSoftwareScale()}catch(t){}},br=async function t(e,i){const n=t=>{if(!ni(this,zn,"f")||!this.isVideoPlaying||t.focusTaskId!=this._focusParameters.curFocusTaskId){ni(this,zn,"f")&&this.isVideoPlaying||(this._focusParameters.isDoingFocus=0);const e=new Error(`Focus task ${t.focusTaskId} canceled.`);throw e.name="DeprecatedTaskError",e}1===this._focusParameters.isDoingFocus&&Date.now()-t.timeStart>this._focusParameters.focusCancelableTime&&(this._focusParameters.isDoingFocus=-1)};let r;i=Br(i,this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),await ni(this,zn,"f").applyConstraints({advanced:[{focusMode:"manual",focusDistance:i}]}),n(e),r=null==this._focusParameters.oldDistance?this._focusParameters.kTimeout*Math.max(Math.abs(1/this._focusParameters.fds.min-1/i),Math.abs(1/this._focusParameters.fds.max-1/i))+this._focusParameters.minTimeout:this._focusParameters.kTimeout*Math.abs(1/this._focusParameters.oldDistance-1/i)+this._focusParameters.minTimeout,this._focusParameters.oldDistance=i,await new Promise((t=>{setTimeout(t,r)})),n(e);let s=e.focusL-e.focusW/2,a=e.focusT-e.focusH/2,o=e.focusW,l=e.focusH;const h=this.getResolution();s=Math.round(s),a=Math.round(a),o=Math.round(o),l=Math.round(l),o>h.width&&(o=h.width),l>h.height&&(l=h.height),s<0?s=0:s+o>h.width&&(s=h.width-o),a<0?a=0:a+l>h.height&&(a=h.height-l);const c=4*h.width*h.height*this._focusParameters.defaultTempBufferContainerLenRatio,d=4*o*l;let u=this._focusParameters.tempBufferContainer;if(u){const t=u.length;c>t&&c>=d?u=new Uint8Array(c):d>t&&d>=c&&(u=new Uint8Array(d))}else u=this._focusParameters.tempBufferContainer=new Uint8Array(Math.max(c,d));if(!this.imageDataGetter.getImageData(ni(this,Hn,"f"),{sx:s,sy:a,sWidth:o,sHeight:l,dWidth:o,dHeight:l},{pixelFormat:pi.RGBA,bufferContainer:u}))return ni(this,Yn,"m",t).call(this,e,i);const f=u;let g=0;for(let t=0,e=d-8;to&&od)return await ni(this,Yn,"m",t).call(this,e,a,o,r,s,c,d)}else{let l=await ni(this,Yn,"m",br).call(this,e,c);if(o>l)return await ni(this,Yn,"m",t).call(this,e,a,o,r,s,c,l);if(o==l)return await ni(this,Yn,"m",t).call(this,e,a,o,c,l);let d=await ni(this,Yn,"m",br).call(this,e,h);if(d>o&&oa.width||l<0||l>a.height)throw new Error("Invalid 'centerPoint'.");let h=0;if(e.endsWith("px"))h=parseFloat(e);else{if(!e.endsWith("%"))throw new Error("Invalid 'width'.");h=parseFloat(e)/100*a.width}if(isNaN(h)||h<0)throw new Error("Invalid 'width'.");let c=0;if(i.endsWith("px"))c=parseFloat(i);else{if(!i.endsWith("%"))throw new Error("Invalid 'height'.");c=parseFloat(i)/100*a.height}if(isNaN(c)||c<0)throw new Error("Invalid 'height'.");if(1!==ni(this,hr,"f")){const t=ni(this,hr,"f"),e=ni(this,cr,"f");h/=t,c/=t,o=(1-1/t)*e.x+o/t,l=(1-1/t)*e.y+l/t}if(!this._focusSupported)throw new Error("Manual focus unsupported.");if(!this._focusParameters.fds&&(this._focusParameters.fds=null===(s=this.getCameraCapabilities())||void 0===s?void 0:s.focusDistance,!this._focusParameters.fds))throw this._focusSupported=!1,new Error("Manual focus unsupported.");null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),this._focusParameters.isDoingFocus=1;const d={focusL:o,focusT:l,focusW:h,focusH:c,focusTaskId:++this._focusParameters.curFocusTaskId,timeStart:Date.now()},u=async(t,e,i)=>{try{(null==e||ethis._focusParameters.fds.max)&&(i=this._focusParameters.fds.max),this._focusParameters.oldDistance=null;let n=Br(Math.sqrt(i*(e||this._focusParameters.fds.step)),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),r=Br(Math.sqrt((e||this._focusParameters.fds.step)*n),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),s=Br(Math.sqrt(n*i),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),a=await ni(this,Yn,"m",br).call(this,t,s),o=await ni(this,Yn,"m",br).call(this,t,r),l=await ni(this,Yn,"m",br).call(this,t,n);if(o>l&&la&&o>a){let e=await ni(this,Yn,"m",br).call(this,t,i);const r=await ni(this,Yn,"m",Ir).call(this,t,n,l,i,e,s,a);return this._focusParameters.isDoingFocus=0,r}if(o==l&&ll){const e=await ni(this,Yn,"m",Ir).call(this,t,n,l,s,a);return this._focusParameters.isDoingFocus=0,e}return u(t,e,i)}catch(t){if("DeprecatedTaskError"!==t.name)throw t}};return u(d,n,r)},Rr=function(t){if("opened"!==this.state)throw new Error("Video is not playing.");if(!t||"string"!=typeof t.x||"string"!=typeof t.y)throw new Error("Invalid 'center'.");const e=this.getResolution();let i=0,n=0;if(t.x.endsWith("px"))i=parseFloat(t.x);else{if(!t.x.endsWith("%"))throw new Error("Invalid scale center.");i=parseFloat(t.x)/100*e.width}if(t.y.endsWith("px"))n=parseFloat(t.y);else{if(!t.y.endsWith("%"))throw new Error("Invalid scale center.");n=parseFloat(t.y)/100*e.height}if(isNaN(i)||isNaN(n))throw new Error("Invalid scale center.");ri(this,cr,{x:i,y:n})},Or=function(t){if("opened"!==this.state)throw new Error("Video is not playing.");const e=this.getResolution();return t&&t.x==e.width/2&&t.y==e.height/2},jr.browserInfo=ii,jr.onWarning=null===(Wn=null===window||void 0===window?void 0:window.console)||void 0===Wn?void 0:Wn.warn;class Cs{constructor(t){Vr.add(this),Ur.set(this,void 0),Gr.set(this,0),Wr.set(this,void 0),Yr.set(this,0),Hr.set(this,!1),ri(this,Ur,t)}startCharging(){ni(this,Hr,"f")||(Cs._onLog&&Cs._onLog("start charging."),ni(this,Vr,"m",Xr).call(this),ri(this,Hr,!0))}stopCharging(){ni(this,Wr,"f")&&clearTimeout(ni(this,Wr,"f")),ni(this,Hr,"f")&&(Cs._onLog&&Cs._onLog("stop charging."),ri(this,Gr,Date.now()-ni(this,Yr,"f")),ri(this,Hr,!1))}}Ur=new WeakMap,Gr=new WeakMap,Wr=new WeakMap,Yr=new WeakMap,Hr=new WeakMap,Vr=new WeakSet,zr=function(){Dt.cfd(1),Cs._onLog&&Cs._onLog("charge 1.")},Xr=function t(){0==ni(this,Gr,"f")&&ni(this,Vr,"m",zr).call(this),ri(this,Yr,Date.now()),ni(this,Wr,"f")&&clearTimeout(ni(this,Wr,"f")),ri(this,Wr,setTimeout((()=>{ri(this,Gr,0),ni(this,Vr,"m",t).call(this)}),ni(this,Ur,"f")-ni(this,Gr,"f")))};class Ss{static beep(){if(!this.allowBeep)return;if(!this.beepSoundSource)return;let t,e=Date.now();if(!(e-ni(this,Zr,"f",Jr)<100)){if(ri(this,Zr,e,0,Jr),ni(this,Zr,"f",qr).size&&(t=ni(this,Zr,"f",qr).values().next().value,this.beepSoundSource==t.src?(ni(this,Zr,"f",qr).delete(t),t.play()):t=null),!t)if(ni(this,Zr,"f",Kr).size<16){t=new Audio(this.beepSoundSource);let e=null,i=()=>{t.removeEventListener("loadedmetadata",i),t.play(),e=setTimeout((()=>{ni(this,Zr,"f",Kr).delete(t)}),2e3*t.duration)};t.addEventListener("loadedmetadata",i),t.addEventListener("ended",(()=>{null!=e&&(clearTimeout(e),e=null),t.pause(),t.currentTime=0,ni(this,Zr,"f",Kr).delete(t),ni(this,Zr,"f",qr).add(t)}))}else ni(this,Zr,"f",$r)||(ri(this,Zr,!0,0,$r),console.warn("The requested audio tracks exceed 16 and will not be played."));t&&ni(this,Zr,"f",Kr).add(t)}}static vibrate(){if(this.allowVibrate){if(!navigator||!navigator.vibrate)throw new Error("Not supported.");navigator.vibrate(Ss.vibrateDuration)}}}Zr=Ss,qr={value:new Set},Kr={value:new Set},Jr={value:0},$r={value:!1},Ss.allowBeep=!0,Ss.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",Ss.allowVibrate=!0,Ss.vibrateDuration=300;const Ts=new Map([[pi.GREY,l.IPF_GRAYSCALED],[pi.RGBA,l.IPF_ABGR_8888]]),bs="function"==typeof BigInt?t=>BigInt(t):t=>t,Is=(bs("0x00"),bs("0xFFFFFFFFFFFFFFFF"),bs("0xFE3BFFFF"),bs("0x003007FF")),xs=(bs("0x0003F800"),bs("0x1"),bs("0x2"),bs("0x4"),bs("0x8"),bs("0x10"),bs("0x20"),bs("0x40"),bs("0x80"),bs("0x100"),bs("0x200"),bs("0x400"),bs("0x800"),bs("0x1000"),bs("0x2000"),bs("0x4000"),bs("0x8000"),bs("0x10000"),bs("0x20000"),bs("0x00040000"),bs("0x01000000"),bs("0x02000000"),bs("0x04000000")),Rs=bs("0x08000000");bs("0x10000000"),bs("0x20000000"),bs("0x40000000"),bs("0x00080000"),bs("0x80000000"),bs("0x100000"),bs("0x200000"),bs("0x400000"),bs("0x800000"),bs("0x1000000000"),bs("0x3F0000000000000"),bs("0x100000000"),bs("0x10000000000000"),bs("0x20000000000000"),bs("0x40000000000000"),bs("0x80000000000000"),bs("0x100000000000000"),bs("0x200000000000000"),bs("0x200000000"),bs("0x400000000"),bs("0x800000000"),bs("0xC00000000"),bs("0x2000000000"),bs("0x4000000000");class Os extends Z{static set _onLog(t){ri(Os,ts,t,0,es),jr._onLog=t,Cs._onLog=t}static get _onLog(){return ni(Os,ts,"f",es)}static async detectEnvironment(){return await(async()=>({wasm:si,worker:ai,getUserMedia:oi,camera:await li(),browser:ii.browser,version:ii.version,OS:ii.OS}))()}static async testCameraAccess(){const t=await jr.testCameraAccess();return t.ok?{ok:!0,message:"Successfully accessed the camera."}:"InsecureContext"===t.errorName?{ok:!1,message:"Insecure context."}:"OverconstrainedError"===t.errorName||"NotFoundError"===t.errorName?{ok:!1,message:"No camera detected."}:"NotAllowedError"===t.errorName?{ok:!1,message:"No permission to access camera."}:"AbortError"===t.errorName?{ok:!1,message:"Some problem occurred which prevented the device from being used."}:"NotReadableError"===t.errorName?{ok:!1,message:"A hardware error occurred."}:"SecurityError"===t.errorName?{ok:!1,message:"User media support is disabled."}:{ok:!1,message:t.errorMessage}}static async createInstance(t){var e,i;if(t&&!(t instanceof kr))throw new TypeError("Invalid view.");if(null===(e=xt.license)||void 0===e?void 0:e.LicenseManager){if(!(null===(i=xt.license)||void 0===i?void 0:i.LicenseManager.bCallInitLicense))throw new Error("License is not set.");await Dt.loadWasm(),await xt.license.dynamsoft()}const n=new Os(t);return Os.onWarning&&(location&&"file:"===location.protocol?setTimeout((()=>{Os.onWarning&&Os.onWarning({id:1,message:"The page is opened over file:// and Dynamsoft Camera Enhancer may not work properly. Please open the page via https://."})}),0):!1!==window.isSecureContext&&navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia||setTimeout((()=>{Os.onWarning&&Os.onWarning({id:2,message:"Dynamsoft Camera Enhancer may not work properly in a non-secure context. Please open the page via https://."})}),0)),n}get isEnableMirroring(){return this._isEnableMirroring}get video(){return this.cameraManager.getVideoEl()}set videoSrc(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraView&&(this.cameraView._hideDefaultSelection=!0),this.cameraManager.videoSrc=t}get videoSrc(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.videoSrc}set ifSaveLastUsedCamera(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.ifSaveLastUsedCamera=t}get ifSaveLastUsedCamera(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.ifSaveLastUsedCamera}set ifSkipCameraInspection(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.ifSkipCameraInspection=t}get ifSkipCameraInspection(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.ifSkipCameraInspection}set cameraOpenTimeout(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.cameraOpenTimeout=t}get cameraOpenTimeout(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.cameraOpenTimeout}set singleFrameMode(t){if(!["disabled","image","camera"].includes(t))throw new Error("Invalid value.");if(this.isOpen())throw new Error("It is not allowed to change `singleFrameMode` when the camera is open.");ri(this,ss,t)}get singleFrameMode(){return ni(this,ss,"f")}get _isFetchingStarted(){return ni(this,ds,"f")}get disposed(){return ni(this,ps,"f")}constructor(t){if(super(),Qr.add(this),is.set(this,"closed"),ns.set(this,void 0),rs.set(this,void 0),this._isEnableMirroring=!1,this.isTorchOn=void 0,ss.set(this,void 0),this._onCameraSelChange=async()=>{this.isOpen()&&this.cameraView&&!this.cameraView.disposed&&await this.selectCamera(this.cameraView._selCam.value)},this._onResolutionSelChange=async()=>{if(!this.isOpen())return;if(!this.cameraView||this.cameraView.disposed)return;let t,e;if(this.cameraView._selRsl&&-1!=this.cameraView._selRsl.selectedIndex){let i=this.cameraView._selRsl.options[this.cameraView._selRsl.selectedIndex];t=parseInt(i.getAttribute("data-width")),e=parseInt(i.getAttribute("data-height"))}await this.setResolution({width:t,height:e})},this._onCloseBtnClick=async()=>{this.isOpen()&&this.cameraView&&!this.cameraView.disposed&&this.close()},as.set(this,((t,e,i,n)=>{const r=Date.now(),s={sx:n.x,sy:n.y,sWidth:n.width,sHeight:n.height,dWidth:n.width,dHeight:n.height},a=Math.max(s.dWidth,s.dHeight);if(this.canvasSizeLimit&&a>this.canvasSizeLimit){const t=this.canvasSizeLimit/a;s.dWidth>s.dHeight?(s.dWidth=this.canvasSizeLimit,s.dHeight=Math.round(s.dHeight*t)):(s.dWidth=Math.round(s.dWidth*t),s.dHeight=this.canvasSizeLimit)}const o=this.cameraManager.imageDataGetter.getImageData(t,s,{pixelFormat:this.getPixelFormat()===l.IPF_GRAYSCALED?pi.GREY:pi.RGBA});let h=null;if(o){const t=Date.now();let a;a=o.pixelFormat===pi.GREY?o.width:4*o.width;let l=!0;0===s.sx&&0===s.sy&&s.sWidth===e&&s.sHeight===i&&(l=!1),h={bytes:o.data,width:o.width,height:o.height,stride:a,format:Ts.get(o.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:rt.ITT_FILE_IMAGE,isCropped:l,cropRegion:{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height,isMeasuredInPercentage:!1},originalWidth:e,originalHeight:i,currentWidth:o.width,currentHeight:o.height,timeSpent:t-r,timeStamp:t},toCanvas:ni(this,os,"f"),isDCEFrame:!0}}return h})),this._onSingleFrameAcquired=t=>{let e;e=this.cameraView?this.cameraView.getConvertedRegion():Xi.convert(ni(this,hs,"f"),t.width,t.height,this.cameraView),e||(e={x:0,y:0,width:t.width,height:t.height});const i=ni(this,as,"f").call(this,t,t.width,t.height,e);ni(this,ns,"f").fire("singleFrameAcquired",[i],{async:!1,copy:!1})},os.set(this,(function(){if(!(this.bytes instanceof Uint8Array||this.bytes instanceof Uint8ClampedArray))throw new TypeError("Invalid bytes.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const t=document.createElement("canvas");let e;if(t.width=this.width,t.height=this.height,this.format===l.IPF_GRAYSCALED){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t{if(!this.video)return;const t=this.cameraManager.getSoftwareScale();if(t<1)throw new RangeError("Invalid scale value.");this.cameraView&&!this.cameraView.disposed?(this.video.style.transform=1===t?"":`scale(${t})`,this.cameraView._updateVideoContainer()):this.video.style.transform=1===t?"":`scale(${t})`},["iPhone","iPad","Android","HarmonyOS"].includes(ii.OS)?this.cameraManager.setResolution(1280,720):this.cameraManager.setResolution(1920,1080),navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?this.singleFrameMode="disabled":this.singleFrameMode="image",t&&(this.setCameraView(t),t.cameraEnhancer=this),this._on("before:camera:change",(()=>{ni(this,ms,"f").stopCharging();const t=this.cameraView;t&&!t.disposed&&(t._startLoading(),t.clearAllInnerDrawingItems())})),this._on("camera:changed",(()=>{this.clearBuffer()})),this._on("before:resolution:change",(()=>{const t=this.cameraView;t&&!t.disposed&&(t._startLoading(),t.clearAllInnerDrawingItems())})),this._on("resolution:changed",(()=>{this.clearBuffer(),t.eventHandler.fire("content:updated",null,{async:!1})})),this._on("paused",(()=>{ni(this,ms,"f").stopCharging();const t=this.cameraView;t&&t.disposed})),this._on("resumed",(()=>{const t=this.cameraView;t&&t.disposed})),this._on("tapfocus",(()=>{ni(this,fs,"f").tapToFocus&&ni(this,ms,"f").startCharging()})),this._intermediateResultReceiver={},this._intermediateResultReceiver.onTaskResultsReceived=async(t,e)=>{var i,n,r,s;const a=t.intermediateResultUnits;if(ni(this,Qr,"m",_s).call(this)||!this.isOpen()||this.isPaused()||a[0]&&!a[0].originalImageTag)return;Os._onLog&&(Os._onLog("intermediateResultUnits:"),Os._onLog(a));let o=!1,l=!1;for(let t of a){if(t.unitType===lt.IRUT_DECODED_BARCODES&&t.decodedBarcodes.length){o=!0;break}t.unitType===lt.IRUT_LOCALIZED_BARCODES&&t.localizedBarcodes.length&&(l=!0)}if(Os._onLog&&(Os._onLog("hasLocalizedBarcodes:"),Os._onLog(l)),ni(this,fs,"f").autoZoom||ni(this,fs,"f").enhancedFocus)if(o)ni(this,gs,"f").autoZoomInFrameArray.length=0,ni(this,gs,"f").autoZoomOutFrameCount=0,ni(this,gs,"f").frameArrayInIdealZoom.length=0,ni(this,gs,"f").autoFocusFrameArray.length=0;else{const e=async t=>{await this.setZoom(t),ni(this,fs,"f").autoZoom&&ni(this,ms,"f").startCharging()},o=async t=>{await this.setFocus(t),ni(this,fs,"f").enhancedFocus&&ni(this,ms,"f").startCharging()};if(l){const l=a[0].originalImageTag,h=(null===(i=l.cropRegion)||void 0===i?void 0:i.left)||0,c=(null===(n=l.cropRegion)||void 0===n?void 0:n.top)||0,d=(null===(r=l.cropRegion)||void 0===r?void 0:r.right)?l.cropRegion.right-h:l.originalWidth,u=(null===(s=l.cropRegion)||void 0===s?void 0:s.bottom)?l.cropRegion.bottom-c:l.originalHeight,f=l.currentWidth,g=l.currentHeight;let m;{let t,e,i,n,r;{const t=this.video.videoWidth*(1-ni(this,gs,"f").autoZoomDetectionArea)/2,e=this.video.videoWidth*(1+ni(this,gs,"f").autoZoomDetectionArea)/2,i=e,n=t,s=this.video.videoHeight*(1-ni(this,gs,"f").autoZoomDetectionArea)/2,a=s,o=this.video.videoHeight*(1+ni(this,gs,"f").autoZoomDetectionArea)/2;r=[{x:t,y:s},{x:e,y:a},{x:i,y:o},{x:n,y:o}]}Os._onLog&&(Os._onLog("detectionArea:"),Os._onLog(r));const s=[];{const t=(t,e)=>{const i=(t,e)=>{if(!t&&!e)throw new Error("Invalid arguments.");return function(t,e,i){let n=!1;const r=t.length;if(r<=2)return!1;for(let s=0;s0!=$i(o.y-i)>0&&$i(e-(i-a.y)*(a.x-o.x)/(a.y-o.y)-a.x)<0&&(n=!n)}return n}(e,t.x,t.y)},n=(t,e)=>!!(Qi([t[0],t[1]],[t[2],t[3]],[e[0].x,e[0].y],[e[1].x,e[1].y])||Qi([t[0],t[1]],[t[2],t[3]],[e[1].x,e[1].y],[e[2].x,e[2].y])||Qi([t[0],t[1]],[t[2],t[3]],[e[2].x,e[2].y],[e[3].x,e[3].y])||Qi([t[0],t[1]],[t[2],t[3]],[e[3].x,e[3].y],[e[0].x,e[0].y]));return!!(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))||!!(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))||!!(n([e[0].x,e[0].y,e[1].x,e[1].y],t)||n([e[1].x,e[1].y,e[2].x,e[2].y],t)||n([e[2].x,e[2].y,e[3].x,e[3].y],t)||n([e[3].x,e[3].y,e[0].x,e[0].y],t))};for(let e of a)if(e.unitType===lt.IRUT_LOCALIZED_BARCODES)for(let i of e.localizedBarcodes){if(!i)continue;const e=i.location.points;e.forEach((t=>{kr._transformCoordinates(t,h,c,d,u,f,g)})),t(r,e)&&s.push(i)}if(Os._debug&&this.cameraView){const t=this.__layer||(this.__layer=this.cameraView._createDrawingLayer(99));t.clearDrawingItems();const e=this.__styleId2||(this.__styleId2=Dr.createDrawingStyle({strokeStyle:"red"}));for(let i of a)if(i.unitType===lt.IRUT_LOCALIZED_BARCODES)for(let n of i.localizedBarcodes){if(!n)continue;const i=n.location.points,r=new Ni({points:i},e);t.addDrawingItems([r])}}}if(Os._onLog&&(Os._onLog("intersectedResults:"),Os._onLog(s)),!s.length)return;let o;if(s.length){let t=s.filter((t=>t.possibleFormats==xs||t.possibleFormats==Rs));if(t.length||(t=s.filter((t=>t.possibleFormats==Is)),t.length||(t=s)),t.length){const e=t=>{const e=t.location.points,i=(e[0].x+e[1].x+e[2].x+e[3].x)/4,n=(e[0].y+e[1].y+e[2].y+e[3].y)/4;return(i-f/2)*(i-f/2)+(n-g/2)*(n-g/2)};o=t[0];let i=e(o);if(1!=t.length)for(let n=1;n1.1*o.confidence||t[n].confidence>.9*o.confidence&&ri&&s>i&&a>i&&l>i&&m.result.moduleSize{})),ni(this,gs,"f").autoZoomInFrameArray.filter((t=>!0===t)).length>=ni(this,gs,"f").autoZoomInFrameLimit[1]){ni(this,gs,"f").autoZoomInFrameArray.length=0;const i=[(.5-n)/(.5-r),(.5-n)/(.5-s),(.5-n)/(.5-a),(.5-n)/(.5-l)].filter((t=>t>0)),o=Math.min(...i,ni(this,gs,"f").autoZoomInIdealModuleSize/m.result.moduleSize),h=this.getZoomSettings().factor;let c=Math.max(Math.pow(h*o,1/ni(this,gs,"f").autoZoomInMaxTimes),ni(this,gs,"f").autoZoomInMinStep);c=Math.min(c,o);let d=h*c;d=Math.max(ni(this,gs,"f").minValue,d),d=Math.min(ni(this,gs,"f").maxValue,d);try{await e({factor:d})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}else if(ni(this,gs,"f").autoZoomInFrameArray.length=0,ni(this,gs,"f").frameArrayInIdealZoom.push(!0),ni(this,gs,"f").frameArrayInIdealZoom.splice(0,ni(this,gs,"f").frameArrayInIdealZoom.length-ni(this,gs,"f").frameLimitInIdealZoom[0]),ni(this,gs,"f").frameArrayInIdealZoom.filter((t=>!0===t)).length>=ni(this,gs,"f").frameLimitInIdealZoom[1]&&(ni(this,gs,"f").frameArrayInIdealZoom.length=0,ni(this,fs,"f").enhancedFocus)){const e=m.points;try{await o({mode:"manual",area:{centerPoint:{x:(e[0].x+e[2].x)/2+"px",y:(e[0].y+e[2].y)/2+"px"},width:e[2].x-e[0].x+"px",height:e[2].y-e[0].y+"px"}})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}if(!ni(this,fs,"f").autoZoom&&ni(this,fs,"f").enhancedFocus&&(ni(this,gs,"f").autoFocusFrameArray.push(!0),ni(this,gs,"f").autoFocusFrameArray.splice(0,ni(this,gs,"f").autoFocusFrameArray.length-ni(this,gs,"f").autoFocusFrameLimit[0]),ni(this,gs,"f").autoFocusFrameArray.filter((t=>!0===t)).length>=ni(this,gs,"f").autoFocusFrameLimit[1])){ni(this,gs,"f").autoFocusFrameArray.length=0;try{const t=m.points;await o({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(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}else{if(ni(this,fs,"f").autoZoom){if(ni(this,gs,"f").autoZoomInFrameArray.push(!1),ni(this,gs,"f").autoZoomInFrameArray.splice(0,ni(this,gs,"f").autoZoomInFrameArray.length-ni(this,gs,"f").autoZoomInFrameLimit[0]),ni(this,gs,"f").autoZoomOutFrameCount++,ni(this,gs,"f").frameArrayInIdealZoom.push(!1),ni(this,gs,"f").frameArrayInIdealZoom.splice(0,ni(this,gs,"f").frameArrayInIdealZoom.length-ni(this,gs,"f").frameLimitInIdealZoom[0]),ni(this,gs,"f").autoZoomOutFrameCount>=ni(this,gs,"f").autoZoomOutFrameLimit){ni(this,gs,"f").autoZoomOutFrameCount=0;const i=this.getZoomSettings().factor;let n=i-Math.max((i-1)*ni(this,gs,"f").autoZoomOutStepRate,ni(this,gs,"f").autoZoomOutMinStep);n=Math.max(ni(this,gs,"f").minValue,n),n=Math.min(ni(this,gs,"f").maxValue,n);try{await e({factor:n})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}ni(this,fs,"f").enhancedFocus&&o({mode:"continuous"}).catch((()=>{}))}!ni(this,fs,"f").autoZoom&&ni(this,fs,"f").enhancedFocus&&(ni(this,gs,"f").autoFocusFrameArray.length=0,o({mode:"continuous"}).catch((()=>{})))}}},ri(this,ms,new Cs(1e4))}setCameraView(t){if(!(t instanceof kr))throw new TypeError("Invalid view.");if(t.disposed)throw new Error("The camera view has been disposed.");if(this.isOpen())throw new Error("It is not allowed to change camera view when the camera is open.");this.releaseCameraView(),t._singleFrameMode=this.singleFrameMode,t._onSingleFrameAcquired=this._onSingleFrameAcquired,this.videoSrc&&(this.cameraView._hideDefaultSelection=!0),ni(this,Qr,"m",_s).call(this)||this.cameraManager.setVideoEl(t.getVideoElement()),this.cameraView=t,this.addListenerToView()}getCameraView(){return this.cameraView}releaseCameraView(){this.cameraView&&(this.removeListenerFromView(),this.cameraView.disposed||(this.cameraView._singleFrameMode="disabled",this.cameraView._onSingleFrameAcquired=null,this.cameraView._hideDefaultSelection=!1),this.cameraManager.releaseVideoEl(),this.cameraView=null)}addListenerToView(){if(!this.cameraView)return;if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");const t=this.cameraView;ni(this,Qr,"m",_s).call(this)||this.videoSrc||(t._innerComponent&&(this.cameraManager.tapFocusEventBoundEl=t._innerComponent),t._selCam&&t._selCam.addEventListener("change",this._onCameraSelChange),t._selRsl&&t._selRsl.addEventListener("change",this._onResolutionSelChange)),t._btnClose&&t._btnClose.addEventListener("click",this._onCloseBtnClick)}removeListenerFromView(){if(!this.cameraView||this.cameraView.disposed)return;const t=this.cameraView;this.cameraManager.tapFocusEventBoundEl=null,t._selCam&&t._selCam.removeEventListener("change",this._onCameraSelChange),t._selRsl&&t._selRsl.removeEventListener("change",this._onResolutionSelChange),t._btnClose&&t._btnClose.removeEventListener("click",this._onCloseBtnClick)}getCameraState(){return ni(this,Qr,"m",_s).call(this)?ni(this,is,"f"):new Map([["closed","closed"],["opening","opening"],["opened","open"]]).get(this.cameraManager.state)}isOpen(){return"open"===this.getCameraState()}getVideoEl(){return this.video}async open(){var t;const e=this.cameraView;if(null==e?void 0:e.disposed)throw new Error("'cameraView' has been disposed.");e&&(e._singleFrameMode=this.singleFrameMode,ni(this,Qr,"m",_s).call(this)?e._clickIptSingleFrameMode():(this.cameraManager.setVideoEl(e.getVideoElement()),e._startLoading()));let i={width:0,height:0,deviceId:""};if(ni(this,Qr,"m",_s).call(this));else{try{await this.cameraManager.open(),ri(this,rs,this.cameraView.getVisibleRegionOfVideo({inPixels:!0}))}catch(t){throw e&&e._stopLoading(),"NotFoundError"===t.name?new Error("No Camera Found: No camera devices were detected. Please ensure a camera is connected and recognized by your system."):"NotAllowedError"===t.name?new Error("No Camera Access: Camera access is blocked. Please check your browser settings or grant permission to use the camera."):t}const n=!this.cameraManager.videoSrc&&!!(null===(t=this.cameraManager.getCameraCapabilities())||void 0===t?void 0:t.torch);let r,s=e.getUIElement();if(s=s.shadowRoot||s,r=s.querySelector(".dce-macro-use-mobile-native-like-ui")){let t=s.elTorchAuto=s.querySelector(".dce-mn-torch-auto"),e=s.elTorchOn=s.querySelector(".dce-mn-torch-on"),i=s.elTorchOff=s.querySelector(".dce-mn-torch-off");t&&(t.style.display=null==this.isTorchOn?"":"none",n||(t.style.filter="invert(1)",t.style.cursor="not-allowed")),e&&(e.style.display=1==this.isTorchOn?"":"none"),i&&(i.style.display=0==this.isTorchOn?"":"none");let a=s.elBeepOn=s.querySelector(".dce-mn-beep-on"),o=s.elBeepOff=s.querySelector(".dce-mn-beep-off");a&&(a.style.display=Ss.allowBeep?"":"none"),o&&(o.style.display=Ss.allowBeep?"none":"");let l=s.elVibrateOn=s.querySelector(".dce-mn-vibrate-on"),h=s.elVibrateOff=s.querySelector(".dce-mn-vibrate-off");l&&(l.style.display=Ss.allowVibrate?"":"none"),h&&(h.style.display=Ss.allowVibrate?"none":""),s.elResolutionBox=s.querySelector(".dce-mn-resolution-box");let c,d=s.elZoom=s.querySelector(".dce-mn-zoom");d&&(d.style.display="none",c=s.elZoomSpan=d.querySelector("span"));let u=s.elToast=s.querySelector(".dce-mn-toast"),f=s.elCameraClose=s.querySelector(".dce-mn-camera-close"),g=s.elTakePhoto=s.querySelector(".dce-mn-take-photo"),m=s.elCameraSwitch=s.querySelector(".dce-mn-camera-switch"),p=s.elCameraAndResolutionSettings=s.querySelector(".dce-mn-camera-and-resolution-settings");p&&(p.style.display="none");const _=s.dceMnFs={},v=()=>{this.turnOnTorch()};null==t||t.addEventListener("pointerdown",v);const y=()=>{this.turnOffTorch()};null==e||e.addEventListener("pointerdown",y);const w=()=>{this.turnAutoTorch()};null==i||i.addEventListener("pointerdown",w);const E=()=>{Ss.allowBeep=!Ss.allowBeep,a&&(a.style.display=Ss.allowBeep?"":"none"),o&&(o.style.display=Ss.allowBeep?"none":"")};for(let t of[o,a])null==t||t.addEventListener("pointerdown",E);const C=()=>{Ss.allowVibrate=!Ss.allowVibrate,l&&(l.style.display=Ss.allowVibrate?"":"none"),h&&(h.style.display=Ss.allowVibrate?"none":"")};for(let t of[h,l])null==t||t.addEventListener("pointerdown",C);const S=async t=>{let e,i=t.target;if(e=i.closest(".dce-mn-camera-option"))this.selectCamera(e.getAttribute("data-davice-id"));else if(e=i.closest(".dce-mn-resolution-option")){let t,i=parseInt(e.getAttribute("data-width")),n=parseInt(e.getAttribute("data-height")),r=await this.setResolution({width:i,height:n});{let e=Math.max(r.width,r.height),i=Math.min(r.width,r.height);t=i<=1080?i+"P":e<3e3?"2K":Math.round(e/1e3)+"K"}t!=e.textContent&&I(`Fallback to ${t}`)}else i.closest(".dce-mn-camera-and-resolution-settings")||(i.closest(".dce-mn-resolution-box")?p&&(p.style.display=p.style.display?"":"none"):p&&""===p.style.display&&(p.style.display="none"))};s.addEventListener("click",S);let T=null;_.funcInfoZoomChange=(t,e=3e3)=>{d&&c&&(c.textContent=t.toFixed(1),d.style.display="",null!=T&&(clearTimeout(T),T=null),T=setTimeout((()=>{d.style.display="none",T=null}),e))};let b=null,I=_.funcShowToast=(t,e=3e3)=>{u&&(u.textContent=t,u.style.display="",null!=b&&(clearTimeout(b),b=null),b=setTimeout((()=>{u.style.display="none",b=null}),e))};const x=()=>{this.close()};null==f||f.addEventListener("click",x);const R=()=>{};null==g||g.addEventListener("pointerdown",R);const O=()=>{var t,e;let i,n=this.getVideoSettings(),r=n.video.facingMode,s=null===(e=null===(t=this.cameraManager.getCamera())||void 0===t?void 0:t.label)||void 0===e?void 0:e.toLowerCase(),a=null==s?void 0:s.indexOf("front");-1===a&&(a=null==s?void 0:s.indexOf("前"));let o=null==s?void 0:s.indexOf("back");if(-1===o&&(o=null==s?void 0:s.indexOf("后")),"number"==typeof a&&-1!==a?i=!0:"number"==typeof o&&-1!==o&&(i=!1),void 0===i&&(i="user"===((null==r?void 0:r.ideal)||(null==r?void 0:r.exact)||r)),!i){let t=this.cameraView.getUIElement();t=t.shadowRoot||t,t.elTorchAuto&&(t.elTorchAuto.style.display="none"),t.elTorchOn&&(t.elTorchOn.style.display="none"),t.elTorchOff&&(t.elTorchOff.style.display="")}n.video.facingMode={ideal:i?"environment":"user"},delete n.video.deviceId,this.updateVideoSettings(n)};null==m||m.addEventListener("pointerdown",O);let D=-1/0,A=1;const M=t=>{let e=Date.now();e-D>1e3&&(A=this.getZoomSettings().factor),A-=t.deltaY/200,A>20&&(A=20),A<1&&(A=1),this.setZoom({factor:A}),D=e};r.addEventListener("wheel",M);const L=new Map;let F=!1;const P=async t=>{var e;for(t.touches.length>=2&&"touchmove"==t.type&&t.preventDefault();t.changedTouches.length>1&&2==t.touches.length;){let i=t.touches[0],n=t.touches[1],r=L.get(i.identifier),s=L.get(n.identifier);if(!r||!s)break;let a=Math.pow(Math.pow(r.x-s.x,2)+Math.pow(r.y-s.y,2),.5),o=Math.pow(Math.pow(i.clientX-n.clientX,2)+Math.pow(i.clientY-n.clientY,2),.5),l=Date.now();if(F||l-D<100)return;l-D>1e3&&(A=this.getZoomSettings().factor),A*=o/a,A>20&&(A=20),A<1&&(A=1);let h=!1;"safari"==(null===(e=null==ii?void 0:ii.browser)||void 0===e?void 0:e.toLocaleLowerCase())&&(o/a>1&&A<2?(A=2,h=!0):o/a<1&&A<2&&(A=1,h=!0)),F=!0,h&&I("zooming..."),await this.setZoom({factor:A}),h&&(u.textContent=""),F=!1,D=Date.now();break}L.clear();for(let e of t.touches)L.set(e.identifier,{x:e.clientX,y:e.clientY})};s.addEventListener("touchstart",P),s.addEventListener("touchmove",P),s.addEventListener("touchend",P),s.addEventListener("touchcancel",P),_.unbind=()=>{null==t||t.removeEventListener("pointerdown",v),null==e||e.removeEventListener("pointerdown",y),null==i||i.removeEventListener("pointerdown",w);for(let t of[o,a])null==t||t.removeEventListener("pointerdown",E);for(let t of[h,l])null==t||t.removeEventListener("pointerdown",C);s.removeEventListener("click",S),null==f||f.removeEventListener("click",x),null==g||g.removeEventListener("pointerdown",R),null==m||m.removeEventListener("pointerdown",O),r.removeEventListener("wheel",M),s.removeEventListener("touchstart",P),s.removeEventListener("touchmove",P),s.removeEventListener("touchend",P),s.removeEventListener("touchcancel",P),delete s.dceMnFs,r.style.display="none"},r.style.display="",t&&null==this.isTorchOn&&setTimeout((()=>{this.turnAutoTorch(1e3)}),0)}this.isTorchOn&&this.turnOnTorch().catch((()=>{}));const a=this.getResolution();i.width=a.width,i.height=a.height,i.deviceId=this.getSelectedCamera().deviceId}return ri(this,is,"open"),e&&(e._innerComponent.style.display="",ni(this,Qr,"m",_s).call(this)||(e._stopLoading(),e._renderCamerasInfo(this.getSelectedCamera(),this.cameraManager._arrCameras),e._renderResolutionInfo({width:i.width,height:i.height}),e.eventHandler.fire("content:updated",null,{async:!1}),e.eventHandler.fire("videoEl:resized",null,{async:!1}))),this.toggleMirroring(this._isEnableMirroring),ni(this,ns,"f").fire("opened",null,{target:this,async:!1}),this.cameraManager._zoomPreSetting&&(await this.setZoom(this.cameraManager._zoomPreSetting),this.cameraManager._zoomPreSetting=null),i}close(){var t;const e=this.cameraView;if(null==e?void 0:e.disposed)throw new Error("'cameraView' has been disposed.");if(this.stopFetching(),this.clearBuffer(),ni(this,Qr,"m",_s).call(this));else{this.cameraManager.close();let i=e.getUIElement();i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")&&(null===(t=i.dceMnFs)||void 0===t||t.unbind())}ri(this,is,"closed"),ni(this,ms,"f").stopCharging(),e&&(e._innerComponent.style.display="none",ni(this,Qr,"m",_s).call(this)&&e._innerComponent.removeElement("content"),e._stopLoading()),ni(this,ns,"f").fire("closed",null,{target:this,async:!1})}pause(){if(ni(this,Qr,"m",_s).call(this))throw new Error("'pause()' is invalid in 'singleFrameMode'.");this.cameraManager.pause()}isPaused(){var t;return!ni(this,Qr,"m",_s).call(this)&&!0===(null===(t=this.video)||void 0===t?void 0:t.paused)}async resume(){if(ni(this,Qr,"m",_s).call(this))throw new Error("'resume()' is invalid in 'singleFrameMode'.");await this.cameraManager.resume()}async selectCamera(t){var e;if(!t)throw new Error("Invalid value.");let i;i="string"==typeof t?t:t.deviceId,await this.cameraManager.setCamera(i),this.isTorchOn=!1;const n=this.getResolution(),r=this.cameraView;if(r&&!r.disposed&&(r._stopLoading(),r._renderCamerasInfo(this.getSelectedCamera(),this.cameraManager._arrCameras),r._renderResolutionInfo({width:n.width,height:n.height})),this.isOpen()){const t=!!(null===(e=this.cameraManager.getCameraCapabilities())||void 0===e?void 0:e.torch);let i=r.getUIElement();if(i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")){let e=i.elTorchAuto=i.querySelector(".dce-mn-torch-auto");e&&(t?(e.style.filter="none",e.style.cursor="pointer"):(e.style.filter="invert(1)",e.style.cursor="not-allowed"))}}return this.toggleMirroring(this._isEnableMirroring),{width:n.width,height:n.height,deviceId:this.getSelectedCamera().deviceId}}getSelectedCamera(){return this.cameraManager.getCamera()}async getAllCameras(){return this.cameraManager.getCameras()}async setResolution(t){await this.cameraManager.setResolution(t.width,t.height),this.isTorchOn&&this.turnOnTorch().catch((()=>{}));const e=this.getResolution(),i=this.cameraView;return i&&!i.disposed&&(i._stopLoading(),i._renderResolutionInfo({width:e.width,height:e.height})),this.toggleMirroring(this._isEnableMirroring),{width:e.width,height:e.height,deviceId:this.getSelectedCamera().deviceId}}getResolution(){return this.cameraManager.getResolution()}getAvailableResolutions(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getResolutions()}_on(t,e){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(t.toLowerCase())?ni(this,ns,"f").on(t,e):this.cameraManager.on(t,e)}_off(t,e){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(t.toLowerCase())?ni(this,ns,"f").off(t,e):this.cameraManager.off(t,e)}on(t,e){const i=t.toLowerCase(),n=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(i);if(!n)throw new Error("Invalid event.");this._on(n,e)}off(t,e){const i=t.toLowerCase(),n=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(i);if(!n)throw new Error("Invalid event.");this._off(n,e)}getVideoSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getMediaStreamConstraints()}async updateVideoSettings(t){var e;await(null===(e=this.cameraManager)||void 0===e?void 0:e.setMediaStreamConstraints(t,!0))}getCapabilities(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getCameraCapabilities()}getCameraSettings(){return this.cameraManager.getCameraSettings()}async turnOnTorch(){var t,e;if(ni(this,Qr,"m",_s).call(this))throw new Error("'turnOnTorch()' is invalid in 'singleFrameMode'.");try{await(null===(t=this.cameraManager)||void 0===t?void 0:t.turnOnTorch())}catch(t){let i=this.cameraView.getUIElement();throw i=i.shadowRoot||i,null===(e=null==i?void 0:i.dceMnFs)||void 0===e||e.funcShowToast("Torch Not Supported"),t}this.isTorchOn=!0;let i=this.cameraView.getUIElement();i=i.shadowRoot||i,i.elTorchAuto&&(i.elTorchAuto.style.display="none"),i.elTorchOn&&(i.elTorchOn.style.display=""),i.elTorchOff&&(i.elTorchOff.style.display="none")}async turnOffTorch(){var t;if(ni(this,Qr,"m",_s).call(this))throw new Error("'turnOffTorch()' is invalid in 'singleFrameMode'.");await(null===(t=this.cameraManager)||void 0===t?void 0:t.turnOffTorch()),this.isTorchOn=!1;let e=this.cameraView.getUIElement();e=e.shadowRoot||e,e.elTorchAuto&&(e.elTorchAuto.style.display="none"),e.elTorchOn&&(e.elTorchOn.style.display="none"),e.elTorchOff&&(e.elTorchOff.style.display="")}async turnAutoTorch(t=250){var e;const i=this.isOpen()?this.cameraManager.getCameraCapabilities():{};if(!(null==i?void 0:i.torch)){let t=this.cameraView.getUIElement();return t=t.shadowRoot||t,void(null===(e=null==t?void 0:t.dceMnFs)||void 0===e||e.funcShowToast("Torch Not Supported"))}if(null!=this._taskid4AutoTorch){if(!(t{var t,e,i;if(this.disposed||n||null!=this.isTorchOn||!this.isOpen())return clearInterval(this._taskid4AutoTorch),void(this._taskid4AutoTorch=null);if(this.isPaused())return;if(++s>10&&this._delay4AutoTorch<1e3)return clearInterval(this._taskid4AutoTorch),this._taskid4AutoTorch=null,void this.turnAutoTorch(1e3);let a;try{a=this.fetchImage()}catch(t){}if(!a||!a.width||!a.height)return;let o=0;if(l.IPF_GRAYSCALED===a.format){for(let t=0;t=this.maxDarkCount4AutoTroch){null===(t=Os._onLog)||void 0===t||t.call(Os,`darkCount ${r}`);try{await this.turnOnTorch(),this.isTorchOn=!0;let t=this.cameraView.getUIElement();t=t.shadowRoot||t,null===(e=null==t?void 0:t.dceMnFs)||void 0===e||e.funcShowToast("Torch Auto On")}catch(t){console.warn(t),n=!0;let e=this.cameraView.getUIElement();e=e.shadowRoot||e,null===(i=null==e?void 0:e.dceMnFs)||void 0===i||i.funcShowToast("Torch Not Supported")}}}else r=0};this._taskid4AutoTorch=setInterval(a,t),this.isTorchOn=void 0,a();let o=this.cameraView.getUIElement();o=o.shadowRoot||o,o.elTorchAuto&&(o.elTorchAuto.style.display=""),o.elTorchOn&&(o.elTorchOn.style.display="none"),o.elTorchOff&&(o.elTorchOff.style.display="none")}async setColorTemperature(t){if(ni(this,Qr,"m",_s).call(this))throw new Error("'setColorTemperature()' is invalid in 'singleFrameMode'.");await this.cameraManager.setColorTemperature(t,!0)}getColorTemperature(){return this.cameraManager.getColorTemperature()}async setExposureCompensation(t){var e;if(ni(this,Qr,"m",_s).call(this))throw new Error("'setExposureCompensation()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setExposureCompensation(t,!0))}getExposureCompensation(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getExposureCompensation()}async _setZoom(t){var e,i,n;if(ni(this,Qr,"m",_s).call(this))throw new Error("'setZoom()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setZoom(t));{let e=null===(i=this.cameraView)||void 0===i?void 0:i.getUIElement();e=(null==e?void 0:e.shadowRoot)||e,null===(n=null==e?void 0:e.dceMnFs)||void 0===n||n.funcInfoZoomChange(t.factor)}}async setZoom(t){await this._setZoom(t)}getZoomSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getZoom()}async resetZoom(){var t;if(ni(this,Qr,"m",_s).call(this))throw new Error("'resetZoom()' is invalid in 'singleFrameMode'.");await(null===(t=this.cameraManager)||void 0===t?void 0:t.resetZoom())}async setFrameRate(t){var e;if(ni(this,Qr,"m",_s).call(this))throw new Error("'setFrameRate()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setFrameRate(t,!0))}getFrameRate(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getFrameRate()}async setFocus(t){var e;if(ni(this,Qr,"m",_s).call(this))throw new Error("'setFocus()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setFocus(t,!0))}getFocusSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getFocus()}setAutoZoomRange(t){ni(this,gs,"f").minValue=t.min,ni(this,gs,"f").maxValue=t.max}getAutoZoomRange(){return{min:ni(this,gs,"f").minValue,max:ni(this,gs,"f").maxValue}}enableEnhancedFeatures(t){var e,i;if(!(null===(i=null===(e=xt.license)||void 0===e?void 0:e.LicenseManager)||void 0===i?void 0:i.bPassValidation))throw new Error("License is not verified, or license is invalid.");if(0!==Dt.bSupportDce4Module)throw new Error("Please set a license containing the DCE module.");t&mi.EF_ENHANCED_FOCUS&&(ni(this,fs,"f").enhancedFocus=!0),t&mi.EF_AUTO_ZOOM&&(ni(this,fs,"f").autoZoom=!0),t&mi.EF_TAP_TO_FOCUS&&(ni(this,fs,"f").tapToFocus=!0,this.cameraManager.enableTapToFocus())}disableEnhancedFeatures(t){t&mi.EF_ENHANCED_FOCUS&&(ni(this,fs,"f").enhancedFocus=!1,this.setFocus({mode:"continuous"}).catch((()=>{}))),t&mi.EF_AUTO_ZOOM&&(ni(this,fs,"f").autoZoom=!1,this.resetZoom().catch((()=>{}))),t&mi.EF_TAP_TO_FOCUS&&(ni(this,fs,"f").tapToFocus=!1,this.cameraManager.disableTapToFocus()),ni(this,Qr,"m",ys).call(this)&&ni(this,Qr,"m",vs).call(this)||ni(this,ms,"f").stopCharging()}_setScanRegion(t){if(null!=t&&!y(t)&&!b(t))throw TypeError("Invalid 'region'.");ri(this,hs,t?JSON.parse(JSON.stringify(t)):null),this.cameraView&&!this.cameraView.disposed&&this.cameraView.setScanRegion(t)}setScanRegion(t){this._setScanRegion(t),this.cameraView&&!this.cameraView.disposed&&(null===t?this.cameraView.setScanRegionMaskVisible(!1):this.cameraView.setScanRegionMaskVisible(!0))}getScanRegion(){return JSON.parse(JSON.stringify(ni(this,hs,"f")))}setErrorListener(t){if(!t)throw new TypeError("Invalid 'listener'");ri(this,ls,t)}hasNextImageToFetch(){return!("open"!==this.getCameraState()||!this.cameraManager.isVideoLoaded()||ni(this,Qr,"m",_s).call(this))}startFetching(){if(ni(this,Qr,"m",_s).call(this))throw Error("'startFetching()' is unavailable in 'singleFrameMode'.");ni(this,ds,"f")||(ri(this,ds,!0),ni(this,Qr,"m",ws).call(this))}stopFetching(){ni(this,ds,"f")&&(Os._onLog&&Os._onLog("DCE: stop fetching loop: "+Date.now()),ni(this,us,"f")&&clearTimeout(ni(this,us,"f")),ri(this,ds,!1))}toggleMirroring(t){this.isOpen()&&(this.video.style.transform=`scaleX(${t?"-1":"1"})`),this._isEnableMirroring=t}fetchImage(t=!1){if(ni(this,Qr,"m",_s).call(this))throw new Error("'fetchImage()' is unavailable in 'singleFrameMode'.");if(!this.video)throw new Error("The video element does not exist.");if(4!==this.video.readyState)throw new Error("The video is not loaded.");const e=this.getResolution();if(!(null==e?void 0:e.width)||!(null==e?void 0:e.height))throw new Error("The video is not loaded.");let i;if(i=Xi.convert(ni(this,hs,"f"),e.width,e.height,this.cameraView),i||(i={x:0,y:0,width:e.width,height:e.height}),i.x>e.width||i.y>e.height)throw new Error("Invalid scan region.");i.x+i.width>e.width&&(i.width=e.width-i.x),i.y+i.height>e.height&&(i.height=e.height-i.y);const n=this.cameraView.regionMaskLineWidth;let r;r=ni(this,hs,"f")&&!t?{sx:i.x+n,sy:i.y+n,sWidth:i.width-2*n,sHeight:i.height-2*n,dWidth:i.width-2*n,dHeight:i.height-2*n}:{sx:i.x,sy:i.y,sWidth:i.width,sHeight:i.height,dWidth:i.width,dHeight:i.height};const s=Math.max(r.dWidth,r.dHeight);if(this.canvasSizeLimit&&s>this.canvasSizeLimit){const t=this.canvasSizeLimit/s;r.dWidth>r.dHeight?(r.dWidth=this.canvasSizeLimit,r.dHeight=Math.round(r.dHeight*t)):(r.dWidth=Math.round(r.dWidth*t),r.dHeight=this.canvasSizeLimit)}const a=this.cameraManager.getFrameData({position:r,pixelFormat:this.getPixelFormat()===l.IPF_GRAYSCALED?pi.GREY:pi.RGBA,isEnableMirroring:this._isEnableMirroring});if(!a)return null;let o;o=a.pixelFormat===pi.GREY?a.width:4*a.width;let h=!0;return 0===r.sx&&0===r.sy&&r.sWidth===e.width&&r.sHeight===e.height&&(h=!1),{bytes:a.data,width:a.width,height:a.height,stride:o,format:Ts.get(a.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:rt.ITT_VIDEO_FRAME,isCropped:h,cropRegion:{left:r.sx,top:r.sy,right:r.sx+r.sWidth,bottom:r.sy+r.sHeight,isMeasuredInPercentage:!1},originalWidth:e.width,originalHeight:e.height,currentWidth:a.width,currentHeight:a.height,timeSpent:a.timeSpent,timeStamp:a.timeStamp},toCanvas:ni(this,os,"f"),isDCEFrame:!0}}setImageFetchInterval(t){this.fetchInterval=t,ni(this,ds,"f")&&(ni(this,us,"f")&&clearTimeout(ni(this,us,"f")),ri(this,us,setTimeout((()=>{this.disposed||ni(this,Qr,"m",ws).call(this)}),t)))}getImageFetchInterval(){return this.fetchInterval}setPixelFormat(t){ri(this,cs,t)}getPixelFormat(){return ni(this,cs,"f")}takePhoto(t){if(!this.isOpen())throw new Error("Not open.");if(ni(this,Qr,"m",_s).call(this))throw new Error("'takePhoto()' is unavailable in 'singleFrameMode'.");const e=document.createElement("input");e.setAttribute("type","file"),e.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp"),e.setAttribute("capture",""),e.style.position="absolute",e.style.top="-9999px",e.style.backgroundColor="transparent",e.style.color="transparent",e.addEventListener("click",(()=>{const t=this.isOpen();this.close(),window.addEventListener("focus",(()=>{t&&this.open(),e.remove()}),{once:!0})})),e.addEventListener("change",(async()=>{const i=e.files[0],n=await(async t=>{let e=null,i=null;if("undefined"!=typeof createImageBitmap)try{if(e=await createImageBitmap(t),e)return e}catch(t){}var n;return e||(i=await(n=t,new Promise(((t,e)=>{let i=URL.createObjectURL(n),r=new Image;r.src=i,r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=t=>{e(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}})))),i})(i),r=n instanceof HTMLImageElement?n.naturalWidth:n.width,s=n instanceof HTMLImageElement?n.naturalHeight:n.height;let a=Xi.convert(ni(this,hs,"f"),r,s,this.cameraView);a||(a={x:0,y:0,width:r,height:s});const o=ni(this,as,"f").call(this,n,r,s,a);t&&t(o)})),document.body.appendChild(e),e.click()}convertToPageCoordinates(t){const e=ni(this,Qr,"m",Es).call(this,t);return{x:e.pageX,y:e.pageY}}convertToClientCoordinates(t){const e=ni(this,Qr,"m",Es).call(this,t);return{x:e.clientX,y:e.clientY}}convertToScanRegionCoordinates(t){if(!ni(this,hs,"f"))return JSON.parse(JSON.stringify(t));if(this.isOpen()){const t=this.cameraView.getVisibleRegionOfVideo({inPixels:!0});ri(this,rs,t||ni(this,rs,"f"))}let e,i,n=ni(this,hs,"f").left||ni(this,hs,"f").x||0,r=ni(this,hs,"f").top||ni(this,hs,"f").y||0;if(!ni(this,hs,"f").isMeasuredInPercentage)return{x:t.x-(n+this.cameraView.regionMaskLineWidth+ni(this,rs,"f").x),y:t.y-(r+this.cameraView.regionMaskLineWidth+ni(this,rs,"f").y)};if(!this.cameraView)throw new Error("Camera view is not set.");if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");if(!this.isOpen())throw new Error("Not open.");if(!ni(this,Qr,"m",_s).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(ni(this,Qr,"m",_s).call(this)&&!this.cameraView._cvsSingleFrameMode)throw new Error("No image is selected.");if(ni(this,Qr,"m",_s).call(this)){const t=this.cameraView._innerComponent.getElement("content");e=t.width,i=t.height}else e=ni(this,rs,"f").width,i=ni(this,rs,"f").height;return{x:t.x-(Math.round(n*e/100)+this.cameraView.regionMaskLineWidth+ni(this,rs,"f").x),y:t.y-(Math.round(r*i/100)+this.cameraView.regionMaskLineWidth+ni(this,rs,"f").y)}}dispose(){this.close(),this.cameraManager.dispose(),this.releaseCameraView(),ri(this,ps,!0)}}var Ds,As,Ms,Ls,Fs,Ps,ks,Ns;ts=Os,is=new WeakMap,ns=new WeakMap,rs=new WeakMap,ss=new WeakMap,as=new WeakMap,os=new WeakMap,ls=new WeakMap,hs=new WeakMap,cs=new WeakMap,ds=new WeakMap,us=new WeakMap,fs=new WeakMap,gs=new WeakMap,ms=new WeakMap,ps=new WeakMap,Qr=new WeakSet,_s=function(){return"disabled"!==this.singleFrameMode},vs=function(){return!this.videoSrc&&"opened"===this.cameraManager.state},ys=function(){for(let t in ni(this,fs,"f"))if(1==ni(this,fs,"f")[t])return!0;return!1},ws=function t(){if(this.disposed)return;if("open"!==this.getCameraState()||!ni(this,ds,"f"))return ni(this,us,"f")&&clearTimeout(ni(this,us,"f")),void ri(this,us,setTimeout((()=>{this.disposed||ni(this,Qr,"m",t).call(this)}),this.fetchInterval));const e=()=>{var t;let e;Os._onLog&&Os._onLog("DCE: start fetching a frame into buffer: "+Date.now());try{e=this.fetchImage()}catch(e){const i=e.message||e;if("The video is not loaded."===i)return;if(null===(t=ni(this,ls,"f"))||void 0===t?void 0:t.onErrorReceived)return void setTimeout((()=>{var t;null===(t=ni(this,ls,"f"))||void 0===t||t.onErrorReceived(et.EC_IMAGE_READ_FAILED,i)}),0);console.warn(e)}e?(this.addImageToBuffer(e),Os._onLog&&Os._onLog("DCE: finish fetching a frame into buffer: "+Date.now()),ni(this,ns,"f").fire("frameAddedToBuffer",null,{async:!1})):Os._onLog&&Os._onLog("DCE: get a invalid frame, abandon it: "+Date.now())};if(this.getImageCount()>=this.getMaxImageCount())switch(this.getBufferOverflowProtectionMode()){case a.BOPM_BLOCK:break;case a.BOPM_UPDATE:e()}else e();ni(this,us,"f")&&clearTimeout(ni(this,us,"f")),ri(this,us,setTimeout((()=>{this.disposed||ni(this,Qr,"m",t).call(this)}),this.fetchInterval))},Es=function(t){if(!this.cameraView)throw new Error("Camera view is not set.");if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");if(!this.isOpen())throw new Error("Not open.");if(!ni(this,Qr,"m",_s).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(ni(this,Qr,"m",_s).call(this)&&!this.cameraView._cvsSingleFrameMode)throw new Error("No image is selected.");const e=this.cameraView._innerComponent.getBoundingClientRect(),i=e.left,n=e.top,r=i+window.scrollX,s=n+window.scrollY,{width:a,height:o}=this.cameraView._innerComponent.getBoundingClientRect();if(a<=0||o<=0)throw new Error("Unable to get content dimensions. Camera view may not be rendered on the page.");let l,h,c;if(ni(this,Qr,"m",_s).call(this)){const t=this.cameraView._innerComponent.getElement("content");l=t.width,h=t.height,c="contain"}else{const t=this.getVideoEl();l=t.videoWidth,h=t.videoHeight,c=this.cameraView.getVideoFit()}const d=a/o,u=l/h;let f,g,m,p,_=1;if("contain"===c)d{var e;if(!this.isUseMagnifier)return;if(ni(this,Ls,"f")||ri(this,Ls,new Bs),!ni(this,Ls,"f").magnifierCanvas)return;document.body.contains(ni(this,Ls,"f").magnifierCanvas)||(ni(this,Ls,"f").magnifierCanvas.style.position="fixed",ni(this,Ls,"f").magnifierCanvas.style.boxSizing="content-box",ni(this,Ls,"f").magnifierCanvas.style.border="2px solid #FFFFFF",document.body.append(ni(this,Ls,"f").magnifierCanvas));const i=this._innerComponent.getElement("content");if(!i)return;if(t.pointer.x<0||t.pointer.x>i.width||t.pointer.y<0||t.pointer.y>i.height)return void ni(this,Ps,"f").call(this);const n=null===(e=this._drawingLayerManager._getFabricCanvas())||void 0===e?void 0:e.lowerCanvasEl;if(!n)return;const r=Math.max(i.clientWidth/5/1.5,i.clientHeight/4/1.5),s=1.5*r,a=[{image:i,width:i.width,height:i.height},{image:n,width:n.width,height:n.height}];ni(this,Ls,"f").update(s,t.pointer,r,a);{let e=0,i=0;t.e instanceof MouseEvent?(e=t.e.clientX,i=t.e.clientY):t.e instanceof TouchEvent&&t.e.changedTouches.length&&(e=t.e.changedTouches[0].clientX,i=t.e.changedTouches[0].clientY),e<1.5*s&&i<1.5*s?(ni(this,Ls,"f").magnifierCanvas.style.left="auto",ni(this,Ls,"f").magnifierCanvas.style.top="0",ni(this,Ls,"f").magnifierCanvas.style.right="0"):(ni(this,Ls,"f").magnifierCanvas.style.left="0",ni(this,Ls,"f").magnifierCanvas.style.top="0",ni(this,Ls,"f").magnifierCanvas.style.right="auto")}ni(this,Ls,"f").show()})),Ps.set(this,(()=>{ni(this,Ls,"f")&&ni(this,Ls,"f").hide()})),ks.set(this,!1)}_setUIElement(t){this.UIElement=t,this._unbindUI(),this._bindUI()}async setUIElement(t){let e;if("string"==typeof t){let i=await tn(t);e=document.createElement("div"),Object.assign(e.style,{width:"100%",height:"100%"}),e.attachShadow({mode:"open"}).appendChild(i)}else e=t;this._setUIElement(e)}getUIElement(){return this.UIElement}_bindUI(){if(!this.UIElement)throw new Error("Need to set 'UIElement'.");if(this._innerComponent)return;const t=this.UIElement;let e=t.classList.contains(this.containerClassName)?t:t.querySelector(`.${this.containerClassName}`);e||(e=document.createElement("div"),e.style.width="100%",e.style.height="100%",e.className=this.containerClassName,t.append(e)),this._innerComponent=document.createElement("dce-component"),e.appendChild(this._innerComponent)}_unbindUI(){var t,e,i;null===(t=this._drawingLayerManager)||void 0===t||t.clearDrawingLayers(),null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null,null===(i=this._innerComponent)||void 0===i||i.remove(),this._innerComponent=null}setImage(t,e,i){if(!this._innerComponent)throw new Error("Need to set 'UIElement'.");let n=this._innerComponent.getElement("content");n||(n=document.createElement("canvas"),n.style.objectFit="contain",this._innerComponent.setElement("content",n)),n.width===e&&n.height===i||(n.width=e,n.height=i);const r=n.getContext("2d");r.clearRect(0,0,n.width,n.height),t instanceof Uint8Array||t instanceof Uint8ClampedArray?(t instanceof Uint8Array&&(t=new Uint8ClampedArray(t.buffer)),r.putImageData(new ImageData(t,e,i),0,0)):(t instanceof HTMLCanvasElement||t instanceof HTMLImageElement)&&r.drawImage(t,0,0)}getImage(){return this._innerComponent.getElement("content")}clearImage(){if(!this._innerComponent)return;let t=this._innerComponent.getElement("content");t&&t.getContext("2d").clearRect(0,0,t.width,t.height)}removeImage(){this._innerComponent&&this._innerComponent.removeElement("content")}setOriginalImage(t){if(v(t)){ri(this,Ms,t);const{width:e,height:i,bytes:n,format:r}=Object.assign({},t);let s;if(r===l.IPF_GRAYSCALED){s=new Uint8ClampedArray(e*i*4);for(let t=0;t{if(!Us){if(!Vs&&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"./"}})(),Ws=t=>{if(null==t&&(t="./"),Vs||Us);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Dt.engineResourcePaths.dbr={version:"11.0.30-dev-20250604160153",path:Gs,isInternal:!0},Rt.dbr={js:!1,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING]},xt.dbr={};const Ys="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Ys)<0&&(Dt.engineResourcePaths.std={version:Ys,path:Ws(Gs+`../../dynamsoft-capture-vision-std@${Ys}/dist/`),isInternal:!0});const Hs="3.0.10";(!Dt.engineResourcePaths.dip||"string"!=typeof Dt.engineResourcePaths.dip&&x(Dt.engineResourcePaths.dip.version,Hs)<0)&&(Dt.engineResourcePaths.dip={version:Hs,path:Ws(Gs+`../../dynamsoft-image-processing@${Hs}/dist/`),isInternal:!0});const zs={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 Xs,Zs,qs,Ks;function Js(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(t){t[t.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",t[t.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",t[t.EBRT_PARTIAL_RESULT=2]="EBRT_PARTIAL_RESULT"}(Xs||(Xs={})),function(t){t[t.QRECL_ERROR_CORRECTION_H=0]="QRECL_ERROR_CORRECTION_H",t[t.QRECL_ERROR_CORRECTION_L=1]="QRECL_ERROR_CORRECTION_L",t[t.QRECL_ERROR_CORRECTION_M=2]="QRECL_ERROR_CORRECTION_M",t[t.QRECL_ERROR_CORRECTION_Q=3]="QRECL_ERROR_CORRECTION_Q"}(Zs||(Zs={})),function(t){t[t.LM_AUTO=1]="LM_AUTO",t[t.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",t[t.LM_STATISTICS=4]="LM_STATISTICS",t[t.LM_LINES=8]="LM_LINES",t[t.LM_SCAN_DIRECTLY=16]="LM_SCAN_DIRECTLY",t[t.LM_STATISTICS_MARKS=32]="LM_STATISTICS_MARKS",t[t.LM_STATISTICS_POSTAL_CODE=64]="LM_STATISTICS_POSTAL_CODE",t[t.LM_CENTRE=128]="LM_CENTRE",t[t.LM_ONED_FAST_SCAN=256]="LM_ONED_FAST_SCAN",t[t.LM_REV=-2147483648]="LM_REV",t[t.LM_SKIP=0]="LM_SKIP",t[t.LM_END=-1]="LM_END"}(qs||(qs={})),function(t){t[t.DM_DIRECT_BINARIZATION=1]="DM_DIRECT_BINARIZATION",t[t.DM_THRESHOLD_BINARIZATION=2]="DM_THRESHOLD_BINARIZATION",t[t.DM_GRAY_EQUALIZATION=4]="DM_GRAY_EQUALIZATION",t[t.DM_SMOOTHING=8]="DM_SMOOTHING",t[t.DM_MORPHING=16]="DM_MORPHING",t[t.DM_DEEP_ANALYSIS=32]="DM_DEEP_ANALYSIS",t[t.DM_SHARPENING=64]="DM_SHARPENING",t[t.DM_BASED_ON_LOC_BIN=128]="DM_BASED_ON_LOC_BIN",t[t.DM_SHARPENING_SMOOTHING=256]="DM_SHARPENING_SMOOTHING",t[t.DM_NEURAL_NETWORK=512]="DM_NEURAL_NETWORK",t[t.DM_REV=-2147483648]="DM_REV",t[t.DM_SKIP=0]="DM_SKIP",t[t.DM_END=-1]="DM_END"}(Ks||(Ks={})),"function"==typeof SuppressedError&&SuppressedError;const $s="undefined"==typeof self,Qs=(()=>{if(!$s&&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"./"})(),ta=t=>{if(null==t&&(t="./"),$s);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};var ea,ia;Dt.engineResourcePaths.dlr={version:"4.0.30-dev-20250604160409",path:Qs,isInternal:!0},Rt.dlr={js:!0,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING]};const na="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,na)<0&&(Dt.engineResourcePaths.std={version:na,path:ta(Qs+`../../dynamsoft-capture-vision-std@${na}/dist/`),isInternal:!0});const ra="3.0.10";(!Dt.engineResourcePaths.dip||"string"!=typeof Dt.engineResourcePaths.dip&&x(Dt.engineResourcePaths.dip.version,ra)<0)&&(Dt.engineResourcePaths.dip={version:ra,path:ta(Qs+`../../dynamsoft-image-processing@${ra}/dist/`),isInternal:!0});let sa=class t{static getVersion(){const t=It.dlr&&It.dlr.wasm;return`4.0.30-dev-20250604160409(Worker: ${It.dlr&&It.dlr.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadConfusableCharsData(e,i){return Js(t,ea,"m",ia).call(t,"confusable",e,i)}static async loadOverlappingCharsData(e,i){return Js(t,ea,"m",ia).call(t,"overlapping",e,i)}};ea=sa,ia=async function(t,e,i){return await Dt.loadWasm(),await new Promise(((n,r)=>{let s=wt();Et[s]=async t=>{if(t.success){const e=JSON.parse(t.result);if(0!==e.errorCode){let t=new Error(e.errorString);return t.errorCode=e.errorCode,r(t)}return n(e)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,r(e)}},i&&!i.endsWith("/")&&(i+="/");const a=R(Dt.engineResourcePaths);vt.postMessage({type:"dlr_loadData",id:s,body:{type:t,dataName:e,dataPath:i||a.dcvData+"char-resources/"}})}))},xt.dlr={loadConfusableCharsData:sa.loadConfusableCharsData,loadOverlappingCharsData:sa.loadOverlappingCharsData};const aa={filterVINResult:function(t){let e="";if(18===t.characterResults.length){let e=t.characterResults[9].location.points[0].x-t.characterResults[8].location.points[1].x;e<2&&(e=2);let i=t.characterResults[1].location.points[0].x-t.characterResults[0].location.points[1].x,n=t.characterResults[17].location.points[0].x-t.characterResults[16].location.points[1].x,r=2===e?3:e;i-e>=r&&n-e=r&&i-et.characterResults[17].characterHConfidence?t.characterResults.pop():t.characterResults.shift()}else if(19===t.characterResults.length){let e=t.characterResults[10].location.points[0].x-t.characterResults[9].location.points[1].x;e<2&&(e=2);let i,n,r,s=t.characterResults[1].location.points[0].x-t.characterResults[0].location.points[1].x,a=t.characterResults[18].location.points[0].x-t.characterResults[17].location.points[1].x,o=t.characterResults[2].location.points[0].x-t.characterResults[1].location.points[1].x,l=t.characterResults[17].location.points[0].x-t.characterResults[16].location.points[1].x,h=2===e?3:e;if("1"===t.characterResults[1].characterH||"1"===t.characterResults[2].characterH||"1"===t.characterResults[16].characterH||"1"===t.characterResults[17].characterH){for(let e=9;e=(i||h)&&l-e<(n||h))t.characterResults.splice(0,2);else if(l-e>=(n||h)&&o-e<(i||h))t.characterResults.splice(17,2);else if(s>e&&a>e)t.characterResults.pop(),t.characterResults.shift();else{let e=t.characterResults[0].characterHConfidence+t.characterResults[1].characterHConfidence,i=t.characterResults[17].characterHConfidence+t.characterResults[18].characterHConfidence,n=t.characterResults[0].characterHConfidence+t.characterResults[18].characterHConfidence,r=Math.min(e,i,n);r===e?t.characterResults.splice(0,2):r===i?t.characterResults.splice(17,2):r===n&&(t.characterResults.pop(),t.characterResults.shift())}}for(let i of t.characterResults)e+=i.characterH;return e},checkValidVIN:function(t){return!(!t||17!=t.length)&&(t=>{const e=new Map([["A",1],["B",2],["C",3],["D",4],["E",5],["F",6],["G",7],["H",8],["J",1],["K",2],["L",3],["M",4],["N",5],["P",7],["R",9],["S",2],["T",3],["U",4],["V",5],["W",6],["X",7],["Y",8],["Z",9],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9]]),i=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2];let n=0;for(let r=0;r{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10},i=t.slice(0,10)+t.slice(13,20)+t.slice(21,43),n=e(t,0,8).toString(),r=e(t,13,18).toString(),s=e(t,21,26).toString(),a=e(t,28,41).toString(),o=e(i,0,i.length).toString();return n===t[9]&&r===t[19]&&s===t[27]&&a===t[42]&&o===t[43]},checkValidMRV:function(t){if(!t||44!=t.length&&36!=t.length)return!1;const e=(t,e,i)=>{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10},i=e(t,0,8).toString(),n=e(t,13,18).toString(),r=e(t,21,26).toString();return i===t[9]&&n===t[19]&&r===t[27]},checkValidIDCard:function(t,e){if(!t||30!=t.length&&36!=t.length)return!1;const i=(t,e,i)=>{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10};if(30===t.length){if(e&&t===e)return i(t,5,13).toString()===t[14];if(e&&t!==e){const n=`${e.substring(5,30)}${t.substring(0,7)}${t.substring(8,15)}${t.substring(18,29)}`;return i(n,0,n.length-1).toString()===t[29]}}else if(36===t.length){const e=i(t,0,8).toString(),n=i(t,13,18).toString(),r=i(t,21,26).toString(),s=`${t.substring(0,10)}${t.substring(13,20)}${t.substring(21,28)}`,a=i(s,0,s.length-1).toString();return e===t[9]&&n===t[19]&&r===t[27]&&a===t[35]}}};var oa,la,ha;function ca(t){delete t.moduleId;const e=JSON.parse(t.jsonString).ResultInfo,i=t.fullCodeString;t.getFieldValue=t=>"fullcodestring"===t.toLowerCase()?i:da(e,t,"map"),t.getFieldRawValue=t=>da(e,t,"raw"),t.getFieldMappingStatus=t=>ua(e,t),t.getFieldValidationStatus=t=>fa(e,t),delete t.fullCodeString}function da(t,e,i){for(let n of t){if(n.FieldName===e)return"raw"===i&&n.RawValue?n.RawValue:n.Value;if(n.ChildFields&&n.ChildFields.length>0){let t;for(let r of n.ChildFields)t=da(r,e,i);if(void 0!==t)return t}}}function ua(t,e){for(let i of t){if(i.FieldName===e)return i.MappingStatus?Number(la[i.MappingStatus]):la.MS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=ua(n,e);if(void 0!==t)return t}}}function fa(t,e){for(let i of t){if(i.FieldName===e&&i.ValidationStatus)return i.ValidationStatus?Number(ha[i.ValidationStatus]):ha.VS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=fa(n,e);if(void 0!==t)return t}}}function ga(t){if(t.disposed)throw new Error('"CodeParser" instance has been disposed')}!function(t){t[t.RTLS_LOCALIZED=0]="RTLS_LOCALIZED",t[t.RTLS_RECOGNITION_FAILED=1]="RTLS_RECOGNITION_FAILED",t[t.RTLS_RECOGNITION_SUCCEEDED=2]="RTLS_RECOGNITION_SUCCEEDED"}(oa||(oa={})),Et[-1]=async t=>{sa.onDataLoadProgressChanged&&sa.onDataLoadProgressChanged(t.resourcesPath,t.tag,{loaded:t.loaded,total:t.total})},function(t){t[t.MS_NONE=0]="MS_NONE",t[t.MS_SUCCEEDED=1]="MS_SUCCEEDED",t[t.MS_FAILED=2]="MS_FAILED"}(la||(la={})),function(t){t[t.VS_NONE=0]="VS_NONE",t[t.VS_SUCCEEDED=1]="VS_SUCCEEDED",t[t.VS_FAILED=2]="VS_FAILED"}(ha||(ha={}));const ma=t=>t&&"object"==typeof t&&"function"==typeof t.then,pa=(async()=>{})().constructor;let _a=class extends pa{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,ma(t)?e=t:"function"==typeof t&&(e=new pa(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&&(ma(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}};class va{constructor(){this._instanceID=void 0,this.bDestroyed=!1}static async createInstance(){if(!xt.license)throw Error("Module `license` is not existed.");await xt.license.dynamsoft(),await Dt.loadWasm();const t=new va,e=new _a;let i=wt();return Et[i]=async i=>{if(i.success)t._instanceID=i.instanceID,e.resolve(t);else{const t=Error(i.message);i.stack&&(t.stack=i.stack),e.reject(t)}},vt.postMessage({type:"dcp_createInstance",id:i}),e}async dispose(){ga(this);let t=wt();this.bDestroyed=!0,Et[t]=t=>{if(!t.success){let e=new Error(t.message);throw e.stack=t.stack+"\n"+e.stack,e}},vt.postMessage({type:"dcp_dispose",id:t,instanceID:this._instanceID})}get disposed(){return this.bDestroyed}async initSettings(t){return ga(this),t&&["string","object"].includes(typeof t)?("string"==typeof t?t.trimStart().startsWith("{")||(t=await I(t,"text")):"object"==typeof t&&(t=JSON.stringify(t)),await new Promise(((e,i)=>{let n=wt();Et[n]=async t=>{if(t.success){const n=JSON.parse(t.response);if(0!==n.errorCode){let t=new Error(n.errorString?n.errorString:"Init Settings Failed.");return t.errorCode=n.errorCode,i(t)}return e(n)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},vt.postMessage({type:"dcp_initSettings",id:n,instanceID:this._instanceID,body:{settings:t}})}))):console.error("Invalid settings.")}async resetSettings(){return ga(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:"dcp_resetSettings",id:i,instanceID:this._instanceID})}))}async parse(t,e=""){if(ga(this),!t||!(t instanceof Array||t instanceof Uint8Array||"string"==typeof t))throw new Error("`parse` must pass in an Array or Uint8Array or string");return await new Promise(((i,n)=>{let r=wt();t instanceof Array&&(t=Uint8Array.from(t)),"string"==typeof t&&(t=Uint8Array.from(function(t){let e=[];for(let i=0;i{if(t.success){let e=JSON.parse(t.parseResponse);return e.errorCode?n(new Error(e.errorString)):(ca(e),i(e))}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},vt.postMessage({type:"dcp_parse",id:r,instanceID:this._instanceID,body:{source:t,taskSettingName:e}})}))}}const ya="undefined"==typeof self,wa="function"==typeof importScripts,Ea=(()=>{if(!wa){if(!ya&&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"./"}})();Dt.engineResourcePaths.dcp={version:"3.0.30-dev-20250604160317",path:Ea,isInternal:!0},Rt.dcp={js:!0,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE]},xt.dcp={handleParsedResultItem:ca};const Ca="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Ca)<0&&(Dt.engineResourcePaths.std={version:Ca,path:(t=>{if(null==t&&(t="./"),ya||wa);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(Ea+`../../dynamsoft-capture-vision-std@${Ca}/dist/`),isInternal:!0});let Sa=class{static getVersion(){const t=It.dcp&&It.dcp.wasm;return`3.0.30-dev-20250604160317(Worker: ${It.dcp&&It.dcp.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadSpec(t,e){return await Dt.loadWasm(),await new Promise(((i,n)=>{let r=wt();Et[r]=async t=>{if(t.success)return i();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},e&&!e.endsWith("/")&&(e+="/");const s=t instanceof Array?t:[t],a=R(Dt.engineResourcePaths);vt.postMessage({type:"dcp_appendResourceBuffer",id:r,body:{specificationPath:e||a.dcvData+"parser-resources/",specificationNames:s}})}))}};const Ta="undefined"==typeof self,ba="function"==typeof importScripts,Ia=(()=>{if(!ba){if(!Ta&&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"./"}})(),xa=t=>{if(null==t&&(t="./"),Ta||ba);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Dt.engineResourcePaths.ddn={version:"3.0.30-dev-20250604160349",path:Ia,isInternal:!0},Rt.ddn={js:!0,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING]},xt.ddn={handleDeskewedAndEnhancedImageResultItem:function(t){let e=t,i=L(e.imageData);e.toCanvas=()=>D(i),e.toImage=t=>A(t,i),e.toBlob=t=>M(t,i)}};const Ra="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Ra)<0&&(Dt.engineResourcePaths.std={version:Ra,path:xa(Ia+`../../dynamsoft-capture-vision-std@${Ra}/dist/`),isInternal:!0});const Oa="3.0.10";(!Dt.engineResourcePaths.dip||"string"!=typeof Dt.engineResourcePaths.dip&&x(Dt.engineResourcePaths.dip.version,Oa)<0)&&(Dt.engineResourcePaths.dip={version:Oa,path:xa(Ia+`../../dynamsoft-image-processing@${Oa}/dist/`),isInternal:!0});var Da;!function(t){t[t.ICM_COLOUR=0]="ICM_COLOUR",t[t.ICM_GRAYSCALE=1]="ICM_GRAYSCALE",t[t.ICM_BINARY=2]="ICM_BINARY"}(Da||(Da={}));const Aa="undefined"==typeof self,Ma="function"==typeof importScripts,La=(()=>{if(!Ma){if(!Aa&&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"./"}})(),Fa=t=>{if(null==t&&(t="./"),Aa||Ma);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Dt.engineResourcePaths.utility={version:"2.0.30-dev-20250604160458",path:La,isInternal:!0},Rt.utility={js:!0,wasm:!0};const Pa="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Pa)<0&&(Dt.engineResourcePaths.std={version:Pa,path:Fa(La+`../../dynamsoft-capture-vision-std@${Pa}/dist/`),isInternal:!0});const ka="3.0.10";(!Dt.engineResourcePaths.dip||"string"!=typeof Dt.engineResourcePaths.dip&&x(Dt.engineResourcePaths.dip.version,ka)<0)&&(Dt.engineResourcePaths.dip={version:ka,path:Fa(La+`../../dynamsoft-image-processing@${ka}/dist/`),isInternal:!0});function Na(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"==typeof SuppressedError&&SuppressedError;const Ba="undefined"==typeof self,ja="function"==typeof importScripts,Va=(()=>{if(!ja){if(!Ba&&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"./"}})(),Ua=t=>{if(null==t&&(t="./"),Ba||ja);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Dt.engineResourcePaths.dbr={version:"11.0.30-dev-20250522174049",path:Va,isInternal:!0},Rt.dbr={js:!1,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING]},xt.dbr={};const Ga="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Ga)<0&&(Dt.engineResourcePaths.std={version:Ga,path:Ua(Va+`../../dynamsoft-capture-vision-std@${Ga}/dist/`),isInternal:!0});const Wa="3.0.10";(!Dt.engineResourcePaths.dip||"string"!=typeof Dt.engineResourcePaths.dip&&x(Dt.engineResourcePaths.dip.version,Wa)<0)&&(Dt.engineResourcePaths.dip={version:Wa,path:Ua(Va+`../../dynamsoft-image-processing@${Wa}/dist/`),isInternal:!0});const Ya={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 Ha,za,Xa,Za,qa,Ka,Ja,$a,Qa,to;function eo(t,e){let i=!0;for(let a=0;a1)return Math.sqrt((l-a)**2+(h-o)**2);{const t=r+d*(a-r),e=s+d*(o-s);return Math.sqrt((l-t)**2+(h-e)**2)}}function ro(t){const e=[];for(let i=0;i=0&&l<=1&&h>=0&&h<=1?{x:t.x+h*r,y:t.y+h*s}:null}function oo(t){let e=0;for(let i=0;i0}function ho(t,e){for(let i=0;i<4;i++)if(!lo(t.points[i],t.points[(i+1)%4],e))return!1;return!0}function co(t,e,i,n){const r=t.points,s=e.points;let a=8*i;a=Math.max(a,5);const o=ro(r)[3],l=ro(r)[1],h=ro(s)[3],c=ro(s)[1];let d,u=0;if(d=Math.max(Math.abs(no(o,e.points[0])),Math.abs(no(o,e.points[3]))),d>u&&(u=d),d=Math.max(Math.abs(no(l,e.points[1])),Math.abs(no(l,e.points[2]))),d>u&&(u=d),d=Math.max(Math.abs(no(h,t.points[0])),Math.abs(no(h,t.points[3]))),d>u&&(u=d),d=Math.max(Math.abs(no(c,t.points[1])),Math.abs(no(c,t.points[2]))),d>u&&(u=d),u>a)return!1;const f=so(ro(r)[0]),g=so(ro(r)[2]),m=so(ro(s)[0]),p=so(ro(s)[2]),_=io(f,p),v=io(m,g),y=_>v,w=Math.min(_,v),E=io(f,g),C=io(m,p);let S=12*i;return S=Math.max(S,5),S=Math.min(S,E),S=Math.min(S,C),!!(w{e.x+=t,e.y+=i})),e.x/=t.length,e.y/=t.length,e}isProbablySameLocationWithOffset(t,e){const i=this.item.location,n=t.location;if(i.area<=0)return!1;if(Math.abs(i.area-n.area)>.4*i.area)return!1;let r=new Array(4).fill(0),s=new Array(4).fill(0),a=0,o=0;for(let t=0;t<4;++t)r[t]=Math.round(100*(n.points[t].x-i.points[t].x))/100,a+=r[t],s[t]=Math.round(100*(n.points[t].y-i.points[t].y))/100,o+=s[t];a/=4,o/=4;for(let t=0;t<4;++t){if(Math.abs(r[t]-a)>this.strictLimit||Math.abs(a)>.8)return!1;if(Math.abs(s[t]-o)>this.strictLimit||Math.abs(o)>.8)return!1}return e.x=a,e.y=o,!0}isLocationOverlap(t,e){if(this.locationArea>e){for(let e=0;e<4;e++)if(ho(this.location,t.points[e]))return!0;const e=this.getCenterPoint(t.points);if(ho(this.location,e))return!0}else{for(let e=0;e<4;e++)if(ho(t,this.location.points[e]))return!0;if(ho(t,this.getCenterPoint(this.location.points)))return!0}return!1}isMatchedLocationWithOffset(t,e={x:0,y:0}){if(this.isOneD){const i=Object.assign({},t.location);for(let t=0;t<4;t++)i.points[t].x-=e.x,i.points[t].y-=e.y;if(!this.isLocationOverlap(i,t.locationArea))return!1;const n=[this.location.points[0],this.location.points[3]],r=[this.location.points[1],this.location.points[2]];for(let t=0;t<4;t++){const e=i.points[t],s=0===t||3===t?n:r;if(Math.abs(no(s,e))>this.locationThreshold)return!1}}else for(let i=0;i<4;i++){const n=t.location.points[i],r=this.location.points[i];if(!(Math.abs(r.x+e.x-n.x)=this.locationThreshold)return!1}return!0}isOverlappedLocationWithOffset(t,e,i=!0){const n=Object.assign({},t.location);for(let t=0;t<4;t++)n.points[t].x-=e.x,n.points[t].y-=e.y;if(!this.isLocationOverlap(n,t.location.area))return!1;if(i){const t=.75;return function(t,e){const i=[];for(let n=0;n<4;n++)for(let r=0;r<4;r++){const s=ao(t[n],t[(n+1)%4],e[r],e[(r+1)%4]);s&&i.push(s)}return t.forEach((t=>{eo(e,t)&&i.push(t)})),e.forEach((e=>{eo(t,e)&&i.push(e)})),oo(function(t){if(t.length<=1)return t;t.sort(((t,e)=>t.x-e.x||t.y-e.y));const e=t.shift();return t.sort(((t,i)=>Math.atan2(t.y-e.y,t.x-e.x)-Math.atan2(i.y-e.y,i.x-e.x))),[e,...t]}(i))}([...this.location.points],n.points)>this.locationArea*t}return!0}}const fo={barcode:2,text_line:4,detected_quad:8,normalized_image:16},go=t=>Object.values(fo).includes(t)||fo.hasOwnProperty(t),mo=(t,e)=>"string"==typeof t?e[fo[t]]:e[t],po=(t,e,i)=>{"string"==typeof t?e[fo[t]]=i:e[t]=i},_o=(t,e,i)=>{const n=[{type:Q.CRIT_BARCODE,resultName:"decodedBarcodesResult",itemNames:["barcodeResultItems"]},{type:Q.CRIT_TEXT_LINE,resultName:"recognizedTextLinesResult",itemNames:["textLineResultItems"]}],r=e.items;if(t.isResultCrossVerificationEnabled(i)){for(let t=r.length-1;t>=0;t--)r[t].type!==i||r[t].verified||r.splice(t,1);const t=n.filter((t=>t.type===i))[0];e[t.resultName]&&t.itemNames.forEach((n=>{const r=e[t.resultName][n];e[t.resultName][n]=r.filter((t=>t.type===i&&t.verified))}))}if(t.isResultDeduplicationEnabled(i)){for(let t=r.length-1;t>=0;t--)r[t].type===i&&r[t].duplicate&&r.splice(t,1);const t=n.filter((t=>t.type===i))[0];e[t.resultName]&&t.itemNames.forEach((n=>{const r=e[t.resultName][n];e[t.resultName][n]=r.filter((t=>t.type===i&&!t.duplicate))}))}};class vo{constructor(){this.verificationEnabled={[Q.CRIT_BARCODE]:!1,[Q.CRIT_TEXT_LINE]:!0,[Q.CRIT_DETECTED_QUAD]:!0,[Q.CRIT_DESKEWED_IMAGE]:!1},this.duplicateFilterEnabled={[Q.CRIT_BARCODE]:!1,[Q.CRIT_TEXT_LINE]:!1,[Q.CRIT_DETECTED_QUAD]:!1,[Q.CRIT_DESKEWED_IMAGE]:!1},this.duplicateForgetTime={[Q.CRIT_BARCODE]:3e3,[Q.CRIT_TEXT_LINE]:3e3,[Q.CRIT_DETECTED_QUAD]:3e3,[Q.CRIT_DESKEWED_IMAGE]:3e3},this.latestOverlappingEnabled={[Q.CRIT_BARCODE]:!1,[Q.CRIT_TEXT_LINE]:!1,[Q.CRIT_DETECTED_QUAD]:!1,[Q.CRIT_DESKEWED_IMAGE]:!1},this.maxOverlappingFrames={[Q.CRIT_BARCODE]:5,[Q.CRIT_TEXT_LINE]:5,[Q.CRIT_DETECTED_QUAD]:5,[Q.CRIT_DESKEWED_IMAGE]:5},this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,Ka.set(this,new Map),Ja.set(this,new Map),$a.set(this,new Map),Qa.set(this,new Map),to.set(this,new Map),Object.defineProperties(this,{onOriginalImageResultReceived:{value:t=>{},writable:!1},onDecodedBarcodesReceived:{value:t=>{this.latestOverlappingFilter(t),_o(this,t,Q.CRIT_BARCODE)},writable:!1},onRecognizedTextLinesReceived:{value:t=>{_o(this,t,Q.CRIT_TEXT_LINE)},writable:!1},onProcessedDocumentResultReceived:{value:t=>{},writable:!1},onParsedResultsReceived:{value:t=>{},writable:!1}})}_dynamsoft(){Na(this,Ka,"f").forEach(((t,e)=>{po(e,this.verificationEnabled,t)})),Na(this,Ja,"f").forEach(((t,e)=>{po(e,this.duplicateFilterEnabled,t)})),Na(this,$a,"f").forEach(((t,e)=>{po(e,this.duplicateForgetTime,t)})),Na(this,Qa,"f").forEach(((t,e)=>{po(e,this.latestOverlappingEnabled,t)})),Na(this,to,"f").forEach(((t,e)=>{po(e,this.maxOverlappingFrames,t)}))}enableResultCrossVerification(t,e){go(t)&&Na(this,Ka,"f").set(t,e)}isResultCrossVerificationEnabled(t){return!!go(t)&&mo(t,this.verificationEnabled)}enableResultDeduplication(t,e){go(t)&&(e&&this.enableLatestOverlapping(t,!1),Na(this,Ja,"f").set(t,e))}isResultDeduplicationEnabled(t){return!!go(t)&&mo(t,this.duplicateFilterEnabled)}setDuplicateForgetTime(t,e){go(t)&&(e>18e4&&(e=18e4),e<0&&(e=0),Na(this,$a,"f").set(t,e))}getDuplicateForgetTime(t){return go(t)?mo(t,this.duplicateForgetTime):-1}setMaxOverlappingFrames(t,e){go(t)&&Na(this,to,"f").set(t,e)}getMaxOverlappingFrames(t){return go(t)?mo(t,this.maxOverlappingFrames):-1}enableLatestOverlapping(t,e){go(t)&&(e&&this.enableResultDeduplication(t,!1),Na(this,Qa,"f").set(t,e))}isLatestOverlappingEnabled(t){return!!go(t)&&mo(t,this.latestOverlappingEnabled)}getFilteredResultItemTypes(){let t=0;const e=[Q.CRIT_BARCODE,Q.CRIT_TEXT_LINE,Q.CRIT_DETECTED_QUAD,Q.CRIT_DESKEWED_IMAGE];for(let i=0;i{if(1!==t.type){const e=(BigInt(t.format)&BigInt(Ya.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Ya.BF_GS1_DATABAR))!=BigInt(0);return new uo(l,e?1:2,e,t)}})).filter(Boolean);if(this.overlapSet.length>0){const t=new Array(h).fill(new Array(this.overlapSet.length).fill(1));let e=0;for(;e-1!==t)).length;r>p&&(p=r,m=n,g.x=i.x,g.y=i.y)}}if(0===p){for(let e=0;e-1!=t)).length}let i=this.overlapSet.length<=3?p>=1:p>=2;if(!i&&s&&d>0){let t=0;for(let e=0;e=1:t>=3}i||(this.overlapSet=[])}if(0===this.overlapSet.length)this.stabilityCount=0,t.items.forEach(((t,e)=>{if(1!==t.type){const i=Object.assign({},t),n=(BigInt(t.format)&BigInt(Ya.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Ya.BF_GS1_DATABAR))!=BigInt(0),s=t.confidence5||Math.abs(g.y)>5)&&(e=!1):e=!1;for(let i=0;i0){for(let t=0;t!(t.overlapCount+this.stabilityCount<=0&&t.crossVerificationFrame<=0)))}f.sort(((t,e)=>e-t)).forEach(((e,i)=>{t.items.splice(e,1)})),u.forEach((e=>{t.items.push(Object.assign(Object.assign({},e),{overlapped:!0}))}))}}}Ka=new WeakMap,Ja=new WeakMap,$a=new WeakMap,Qa=new WeakMap,to=new WeakMap;const yo=async t=>{let e;await new Promise(((i,n)=>{e=new Image,e.onload=()=>i(e),e.onerror=n,e.src=URL.createObjectURL(t)}));const i=document.createElement("canvas"),n=i.getContext("2d");return i.width=e.width,i.height=e.height,n.drawImage(e,0,0),{bytes:Uint8Array.from(n.getImageData(0,0,i.width,i.height).data),width:i.width,height:i.height,stride:4*i.width,format:l.IPF_ABGR_8888}};var wo,Eo,Co,So;class To{async readFromFile(t){return await yo(t)}async saveToFile(t,e,i){if(!t||!e)return null;if("string"!=typeof e)throw new TypeError("FileName must be of type string.");const n=L(t);return O(n,e,i)}async readFromMemory(t){if(!Na(To,wo,"f",Eo).has(t))throw new Error("Image data ID does not exist.");const{ptr:e,length:i}=Na(To,wo,"f",Eo).get(t);return await new Promise(((t,n)=>{let r=wt();Et[r]=async e=>{if(e.success)return 0!==e.imageData.errorCode&&n(new Error(`[${e.imageData.errorCode}] ${e.imageData.errorString}`)),t(e.imageData);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,n(t)}},vt.postMessage({type:"utility_readFromMemory",id:r,body:{ptr:e,length:i}})}))}async saveToMemory(t,e){const{bytes:i,width:n,height:r,stride:s,format:a}=await yo(t);return await new Promise(((t,o)=>{let l=wt();Et[l]=async e=>{var i,n;if(e.success)return function(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");r?r.value=i:e.set(t,i)}(i=To,wo,(n=Na(i,wo,"f",Co),++n),0,Co),Na(To,wo,"f",Eo).set(Na(To,wo,"f",Co),JSON.parse(e.memery)),t(Na(To,wo,"f",Co));{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_saveToMemory",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,fileFormat:e}})}))}}wo=To,Eo={value:new Map},Co={value:0};!function(t){t[t.FT_HIGH_PASS=0]="FT_HIGH_PASS",t[t.FT_SHARPEN=1]="FT_SHARPEN",t[t.FT_SMOOTH=2]="FT_SMOOTH"}(So||(So={})),Dt.engineResourcePaths.rootDirectory=(t=>{if(null==t&&(t="./"),At||Mt);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(Lt+"../../"),Dt.engineResourcePaths.dcvBundle={version:"3.0.3001",path:Lt,isInternal:!0},Dt.engineResourcePaths.dcvData={version:"1.0.1",path:Lt,isInternal:!0};var bo,Io,xo,Ro=Object.freeze({__proto__:null,BarcodeReaderModule:class{static getVersion(){const t=It.dbr&&It.dbr.wasm;return`11.0.30-dev-20250604160153(Worker: ${It.dbr&&It.dbr.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}},CameraEnhancer:Os,CameraEnhancerModule:class{static getVersion(){return"4.2.12-dev-20250609101854"}},CameraManager:jr,CameraView:kr,CaptureVisionRouter:Te,CaptureVisionRouterModule:Jt,CapturedResultReceiver:be,CodeParser:va,CodeParserModule:Sa,CoreModule:Dt,DocumentNormalizerModule:class{static getVersion(){const t=It.ddn&&It.ddn.wasm;return`3.0.30-dev-20250604160349(Worker: ${It.ddn&&It.ddn.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}async setThresholdValue(t,e,i,n){return await Dt.loadWasm(),await new Promise(((r,s)=>{let a=wt();Et[a]=async t=>{if(t.success)return r();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,s(e)}},vt.postMessage({type:"ddn_setThresholdValue",id:a,instanceID:t._instanceID,body:{threshold:e,leftLimit:i,rightLimit:n}})}))}},DrawingItem:Ai,DrawingStyleManager:Dr,EnumBarcodeFormat:zs,get EnumBufferOverflowProtectionMode(){return a},get EnumCapturedResultItemType(){return Q},get EnumColourChannelUsageType(){return o},get EnumCornerType(){return tt},get EnumCrossVerificationStatus(){return ot},get EnumDeblurMode(){return Ks},get EnumDrawingItemMediaType(){return fi},get EnumDrawingItemState(){return gi},get EnumEnhancedFeatures(){return mi},get EnumErrorCode(){return et},get EnumExtendedBarcodeResultType(){return Xs},get EnumFilterType(){return So},get EnumGrayscaleEnhancementMode(){return it},get EnumGrayscaleTransformationMode(){return nt},get EnumImageCaptureDistanceMode(){return ut},get EnumImageColourMode(){return Da},get EnumImageFileFormat(){return dt},get EnumImagePixelFormat(){return l},get EnumImageSourceState(){return $t},get EnumImageTagType(){return rt},EnumIntermediateResultUnitType:lt,get EnumLocalizationMode(){return qs},get EnumMappingStatus(){return la},get EnumModuleName(){return ft},get EnumPDFReadingMode(){return st},get EnumPresetTemplate(){return Ie},get EnumQRCodeErrorCorrectionLevel(){return Zs},get EnumRasterDataSource(){return at},get EnumRawTextLineStatus(){return oa},get EnumRegionObjectElementType(){return ht},get EnumSectionType(){return ct},get EnumTransformMatrixType(){return gt},get EnumValidationStatus(){return ha},Feedback:Ss,GroupDrawingItem:Wi,ImageDataGetter:Nr,ImageDrawer:class{async drawOnImage(t,e,i,n=4294901760,r=1,s){if(!t)throw new Error("Invalid image.");if(!e)throw new Error("Invalid drawingItem.");if(!i)throw new Error("Invalid type.");let a;if(t instanceof Blob)a=await yo(t);else if("string"==typeof t){let e=await I(t,"blob");a=await yo(e)}else v(t)&&(a=t,"bigint"==typeof a.format&&(a.format=Number(a.format)));return await new Promise(((t,o)=>{let l=wt();Et[l]=async e=>{if(e.success)return s&&(new To).saveToFile(e.image,"test.png",s),t(e.image);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_drawOnImage",id:l,body:{dsImage:a,drawingItem:Array.isArray(e)?e:[e],color:n,thickness:r,type:i}})}))}},ImageDrawingItem:class extends Ai{set maintainAspectRatio(t){t&&this.set("scaleY",this.get("scaleX"))}get maintainAspectRatio(){return ni(this,Oi,"f")}constructor(t,e,i,n){if(super(null,n),Ri.set(this,void 0),Oi.set(this,void 0),!b(e))throw new TypeError("Invalid 'rect'.");if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement)this._setFabricObject(new _i.Image(t,{left:e.x,top:e.y}));else{if(!v(t))throw new TypeError("Invalid 'image'.");{const i=document.createElement("canvas");let n;if(i.width=t.width,i.height=t.height,t.format===l.IPF_GRAYSCALED){n=new Uint8ClampedArray(t.width*t.height*4);for(let e=0;e{let h=wt();Et[h]=async e=>{if(e.success)return t(e.cropImage);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,l(t)}},vt.postMessage({type:"utility_cropImage",id:h,body:{type:i,bytes:n,width:r,height:s,stride:a,format:o,roi:e}})}))}async adjustBrightness(t,e){if(e>100||e<-100)throw new Error("Invalid brightness, range: [-100, 100].");const{bytes:i,width:n,height:r,stride:s,format:a}=await yo(t);return await new Promise(((t,o)=>{let l=wt();Et[l]=async e=>{if(e.success)return t(e.adjustBrightness);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_adjustBrightness",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,brightness:e}})}))}async adjustContrast(t,e){if(e>100||e<-100)throw new Error("Invalid contrast, range: [-100, 100].");const{bytes:i,width:n,height:r,stride:s,format:a}=await yo(t);return await new Promise(((t,o)=>{let l=wt();Et[l]=async e=>{if(e.success)return t(e.adjustContrast);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_adjustContrast",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,contrast:e}})}))}async filterImage(t,e){if(![0,1,2].includes(e))throw new Error("Invalid filterType.");const{bytes:i,width:n,height:r,stride:s,format:a}=await yo(t);return await new Promise(((t,o)=>{let l=wt();Et[l]=async e=>{if(e.success)return t(e.filterImage);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_filterImage",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,filterType:e}})}))}async convertToGray(t,e,i,n){const{bytes:r,width:s,height:a,stride:o,format:l}=await yo(t);return await new Promise(((t,h)=>{let c=wt();Et[c]=async e=>{if(e.success)return t(e.convertToGray);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,h(t)}},vt.postMessage({type:"utility_convertToGray",id:c,body:{bytes:r,width:s,height:a,stride:o,format:l,R:e,G:i,B:n}})}))}async convertToBinaryGlobal(t,e=-1,i=!1){const{bytes:n,width:r,height:s,stride:a,format:o}=await yo(t);return await new Promise(((t,l)=>{let h=wt();Et[h]=async e=>{if(e.success)return t(e.convertToBinaryGlobal);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,l(t)}},vt.postMessage({type:"utility_convertToBinaryGlobal",id:h,body:{bytes:n,width:r,height:s,stride:a,format:o,threshold:e,invert:i}})}))}async convertToBinaryLocal(t,e=0,i=0,n=!1){const{bytes:r,width:s,height:a,stride:o,format:l}=await yo(t);return await new Promise(((t,h)=>{let c=wt();Et[c]=async e=>{if(e.success)return t(e.convertToBinaryLocal);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,h(t)}},vt.postMessage({type:"utility_convertToBinaryLocal",id:c,body:{bytes:r,width:s,height:a,stride:o,format:l,blockSize:e,compensation:i,invert:n}})}))}},ImageSourceAdapter:Z,IntermediateResultReceiver:class{constructor(){this._observedResultUnitTypes=lt.IRUT_ALL,this._observedTaskMap=new Map,this._parameters={setObservedResultUnitTypes:t=>{this._observedResultUnitTypes=t},getObservedResultUnitTypes:()=>this._observedResultUnitTypes,isResultUnitTypeObserved:t=>!!(t&this._observedResultUnitTypes),addObservedTask:t=>{this._observedTaskMap.set(t,!0)},removeObservedTask:t=>{this._observedTaskMap.set(t,!1)},isTaskObserved:t=>0===this._observedTaskMap.size||!!this._observedTaskMap.get(t)},this.onTaskResultsReceived=null,this.onPredetectedRegionsReceived=null,this.onColourImageUnitReceived=null,this.onScaledColourImageUnitReceived=null,this.onGrayscaleImageUnitReceived=null,this.onTransformedGrayscaleImageUnitReceived=null,this.onEnhancedGrayscaleImageUnitReceived=null,this.onBinaryImageUnitReceived=null,this.onTextureDetectionResultUnitReceived=null,this.onTextureRemovedGrayscaleImageUnitReceived=null,this.onTextureRemovedBinaryImageUnitReceived=null,this.onContoursUnitReceived=null,this.onLineSegmentsUnitReceived=null,this.onTextZonesUnitReceived=null,this.onTextRemovedBinaryImageUnitReceived=null,this.onShortLinesUnitReceived=null}getObservationParameters(){return this._parameters}},LabelRecognizerModule:sa,LicenseManager:Xe,LicenseModule:class{static getVersion(){return`4.0.30-dev-20250604160433(Worker: ${It.license&&It.license.worker||"Not Loaded"}, Wasm: ${It.license&&It.license.wasm||"Not Loaded"})`}},LineDrawingItem:class extends Ni{constructor(t,e){if(super({points:[null==t?void 0:t.startPoint,null==t?void 0:t.endPoint]},e),Vi.set(this,void 0),!E(t))throw new TypeError("Invalid 'line'.");ri(this,Vi,JSON.parse(JSON.stringify(t))),this._mediaType="line"}extendSet(t,e){if("startPoint"===t||"endPoint"===t){e="startPoint"===t?[e,this.get("endPoint")]:[this.get("startPoint"),e];const i=this._fabricObject;if(i.group){const t=i.group;i.points=e.map((e=>({x:e.x-t.left-t.width/2,y:e.y-t.top-t.height/2}))),t.addWithUpdate()}else i.points=e;const n=i.points.length-1;return i.controls=i.points.reduce((function(t,e,i){return t["p"+i]=new _i.Control({positionHandler:Li,actionHandler:ki(i>0?i-1:n,Pi),actionName:"modifyPolygon",pointIndex:i}),t}),{}),i._setPositionDimensions({}),!0}}extendGet(t){if("startPoint"===t||"endPoint"===t){const e=[],i=this._fabricObject;if(i.selectable&&!i.group)for(let t in i.oCoords)e.push({x:i.oCoords[t].x,y:i.oCoords[t].y});else for(let t of i.points){let n=t.x-i.pathOffset.x,r=t.y-i.pathOffset.y;const s=_i.util.transformPoint({x:n,y:r},i.calcTransformMatrix());e.push({x:s.x,y:s.y})}return"startPoint"===t?e[0]:e[1]}}updateCoordinateBaseFromImageToView(){const t=this.get("startPoint"),e=this.get("endPoint");this.set("startPoint",{x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)}),this.set("endPoint",{x:this.convertPropFromViewToImage(e.x),y:this.convertPropFromViewToImage(e.y)})}updateCoordinateBaseFromViewToImage(){const t=this.get("startPoint"),e=this.get("endPoint");this.set("startPoint",{x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)}),this.set("endPoint",{x:this.convertPropFromImageToView(e.x),y:this.convertPropFromImageToView(e.y)})}setPosition(t){this.setLine(t)}getPosition(){return this.getLine()}updatePosition(){ni(this,Vi,"f")&&this.setLine(ni(this,Vi,"f"))}setPolygon(){}getPolygon(){return null}setLine(t){if(!E(t))throw new TypeError("Invalid 'line'.");if(this._drawingLayer){if("view"===this.coordinateBase)this.set("startPoint",{x:this.convertPropFromViewToImage(t.startPoint.x),y:this.convertPropFromViewToImage(t.startPoint.y)}),this.set("endPoint",{x:this.convertPropFromViewToImage(t.endPoint.x),y:this.convertPropFromViewToImage(t.endPoint.y)});else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("startPoint",t.startPoint),this.set("endPoint",t.endPoint)}this._drawingLayer.renderAll()}else ri(this,Vi,JSON.parse(JSON.stringify(t)))}getLine(){if(this._drawingLayer){if("view"===this.coordinateBase)return{startPoint:{x:this.convertPropFromImageToView(this.get("startPoint").x),y:this.convertPropFromImageToView(this.get("startPoint").y)},endPoint:{x:this.convertPropFromImageToView(this.get("endPoint").x),y:this.convertPropFromImageToView(this.get("endPoint").y)}};if("image"===this.coordinateBase)return{startPoint:this.get("startPoint"),endPoint:this.get("endPoint")};throw new Error("Invalid 'coordinateBase'.")}return ni(this,Vi,"f")?JSON.parse(JSON.stringify(ni(this,Vi,"f"))):null}},MultiFrameResultCrossFilter:vo,QuadDrawingItem:Gi,RectDrawingItem:Mi,TextDrawingItem:ji,UtilityModule:class{static getVersion(){return`2.0.30-dev-20250604160458(Worker: ${It.utility&&It.utility.worker||"Not Loaded"}, Wasm: ${It.utility&&It.utility.wasm||"Not Loaded"})`}},_getNorImageData:L,_saveToFile:O,_toBlob:M,_toCanvas:D,_toImage:A,get bDebug(){return Tt},checkIsLink:t=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(t),compareVersion:x,doOrWaitAsyncDependency:_t,getNextTaskID:wt,handleEngineResourcePaths:R,innerVersions:It,isArc:t=>!(!p(t)||!m(t.x)||!m(t.y)||!m(t.radius)||t.radius<0||!m(t.startAngle)||!m(t.endAngle)),isContour:t=>!!p(t)&&!!g(t.points)&&0!=t.points.length&&!t.points.some((t=>!C(t))),isDSImageData:v,isDSRect:y,isImageTag:w,isLineSegment:E,isObject:p,isOriginalDsImageData:t=>!(!_(t)||!m(t.bytes.length)&&!m(t.bytes.ptr)),isPoint:C,isPolygon:S,isQuad:T,isRect:b,isSimdSupported:async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),mapAsyncDependency:mt,mapPackageRegister:xt,mapTaskCallBack:Et,get onLog(){return Ct},productNameMap:F,requestResource:I,setBDebug:bt,setOnLog:St,utilsFuncs:aa,waitAsyncDependency:pt,get worker(){return vt},workerAutoResources:Rt});t.EnumMRZScanMode=void 0,(bo=t.EnumMRZScanMode||(t.EnumMRZScanMode={})).Passport="passport",bo.TD1="td1",bo.TD2="td2",bo.PassportAndTD1="passportAndTd1",bo.PassportAndTD2="passportAndTd2",bo.TD1AndTD2="td1AndTd2",bo.All="all",t.EnumMRZDocumentType=void 0,(Io=t.EnumMRZDocumentType||(t.EnumMRZDocumentType={})).Passport="passport",Io.TD1="td1",Io.TD2="td2",t.EnumMRZScannerViews=void 0,(xo=t.EnumMRZScannerViews||(t.EnumMRZScannerViews={})).Scanner="scanner",xo.Result="scan-result";const Oo={[t.EnumMRZScanMode.Passport]:"ReadPassport",[t.EnumMRZScanMode.TD1]:"ReadId-TD1",[t.EnumMRZScanMode.TD2]:"ReadId-TD2",[t.EnumMRZScanMode.PassportAndTD1]:"ReadPassportAndId-TD1",[t.EnumMRZScanMode.PassportAndTD2]:"ReadPassportAndId-TD2",[t.EnumMRZScanMode.TD1AndTD2]:"ReadId",[t.EnumMRZScanMode.All]:"ReadPassportAndId"};var Do;function Ao(t){if("string"==typeof t){const e=document.querySelector(t);if(!e)throw new Error("Element not found");return e}return t instanceof HTMLElement?t:null}t.EnumResultStatus=void 0,(Do=t.EnumResultStatus||(t.EnumResultStatus={}))[Do.RS_SUCCESS=0]="RS_SUCCESS",Do[Do.RS_CANCELLED=1]="RS_CANCELLED",Do[Do.RS_FAILED=2]="RS_FAILED";function Mo(t,e){if(!document.getElementById(t)){const i=document.createElement("style");i.id=t,i.textContent=e,document.head.appendChild(i)}}const Lo=t=>!t||0===Object.keys(t).length;function Fo(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}const Po={"4k":{width:3840,height:2160},"2k":{width:2560,height:1440},"1080p":{width:1920,height:1080},"720p":{width:1280,height:720},"480p":{width:640,height:480}};function ko(t,e={}){const{message:i,spinnerSize:n=32}=e,r=document.createElement("div");r.className="dynamsoft-mrz-loading-screen";const s=document.createElement("div");s.className="dynamsoft-mrz-loading";const a=document.createElement("div");a.className="dynamsoft-mrz-loading-content";const o=`\n \n \n \n `;if(a.innerHTML=o,i){const t=document.createElement("div");t.className="dynamsoft-mrz-loading-message",t.textContent=i,a.appendChild(t)}return s.appendChild(a),r.appendChild(s),t.appendChild(r),{element:r,updateMessage:t=>{let e=s.querySelector(".dynamsoft-mrz-loading-message");null!==t?e?e.textContent=t:(e=document.createElement("div"),e.className="dynamsoft-mrz-loading-message",e.textContent=t,a.appendChild(e)):null==e||e.remove()},hide:()=>{r&&r.parentNode&&(r.classList.add("fade-out"),setTimeout((()=>{var t;null===(t=r.parentNode)||void 0===t||t.removeChild(r)}),200))}}}const No='\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: "Verdana";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n';var Bo;t.EnumMRZData=void 0,(Bo=t.EnumMRZData||(t.EnumMRZData={})).InvalidFields="invalidFields",Bo.DocumentType="documentType",Bo.DocumentNumber="documentNumber",Bo.MRZText="mrzText",Bo.FirstName="firstName",Bo.LastName="lastName",Bo.Age="age",Bo.Sex="sex",Bo.IssuingState="issuingState",Bo.IssuingStateRaw="issuingStateRaw",Bo.Nationality="nationality",Bo.NationalityRaw="nationalityRaw",Bo.DateOfBirth="dateOfBirth",Bo.DateOfExpiry="dateOfExpiry";const jo={[t.EnumMRZData.InvalidFields]:"Invalid Fields",[t.EnumMRZData.DocumentType]:"Document Type",[t.EnumMRZData.DocumentNumber]:"Document Number",[t.EnumMRZData.MRZText]:"MRZ Text",[t.EnumMRZData.FirstName]:"Given Name(s)",[t.EnumMRZData.LastName]:"Surname",[t.EnumMRZData.Age]:"Age",[t.EnumMRZData.Sex]:"Sex",[t.EnumMRZData.IssuingState]:"Issuing State",[t.EnumMRZData.IssuingStateRaw]:"Issuing State (Raw Value)",[t.EnumMRZData.Nationality]:"Nationality",[t.EnumMRZData.NationalityRaw]:"Nationality State (Raw Value)",[t.EnumMRZData.DateOfBirth]:"Date Of Birth (YYYY-MM-DD)",[t.EnumMRZData.DateOfExpiry]:"Date Of Expiry (YYYY-MM-DD)"};function Vo(t,e,i,n=!1){const r=parseInt(t,10);let s;if(n)s=r>=60?1900+r:2e3+r;else{s=r>(new Date).getFullYear()%100?1900+r:2e3+r}return{year:s,month:parseInt(e,10),day:parseInt(i,10)}}function Uo(t){const e=t=>{var e;return 1===(null===(e=`${t}`)||void 0===e?void 0:e.length)?`0${t}`:t};return`${null==t?void 0:t.year}-${e(null==t?void 0:t.month)}${(null==t?void 0:t.day)&&`-${e(null==t?void 0:t.day)}`}`}function Go(t){return"D<<"===t?"D":t}function Wo(e,i){const n=[],r=t=>i.getFieldValidationStatus(t)===ha.VS_FAILED,s=i.codeType,a=function(e){switch(e){case"MRTD_TD1_ID":return t.EnumMRZDocumentType.TD1;case"MRTD_TD2_ID":case"MRTD_TD2_VISA":case"MRTD_TD2_FRENCH_ID":return t.EnumMRZDocumentType.TD2;case"MRTD_TD3_PASSPORT":case"MRTD_TD3_VISA":return t.EnumMRZDocumentType.Passport;default:throw new Error(`Unknown document type: ${e}`)}}(s),o=function(t){switch(t){case"MRTD_TD1_ID":return"ID (TD1)";case"MRTD_TD2_ID":return"ID (TD2)";case"MRTD_TD2_VISA":return"ID (VISA)";case"MRTD_TD2_FRENCH_ID":return"French ID (TD2)";case"MRTD_TD3_PASSPORT":return"Passport (TD3)";case"MRTD_TD3_VISA":return"Visa (TD3)";default:throw new Error(`Unknown document type: ${t}`)}}(s),l=a===t.EnumMRZDocumentType.Passport&&"MRTD_TD3_PASSPORT"===s?"passportNumber":"documentNumber",h=Vo(i.getFieldValue("birthYear"),i.getFieldValue("birthMonth"),i.getFieldValue("birthDay")),c=Vo(i.getFieldValue("expiryYear"),i.getFieldValue("expiryMonth"),i.getFieldValue("expiryDay"),!0);["birthYear","birthMonth","birthDay"].forEach((e=>{r(e)&&n.push(t.EnumMRZData.DateOfBirth)})),["expiryYear","expiryMonth","expiryDay"].forEach((e=>{r(e)&&n.push(t.EnumMRZData.DateOfExpiry)}));const d={[t.EnumMRZData.LastName]:i.getFieldValue("primaryIdentifier"),[t.EnumMRZData.FirstName]:i.getFieldValue("secondaryIdentifier"),[t.EnumMRZData.Nationality]:i.getFieldValue("nationality"),[t.EnumMRZData.NationalityRaw]:Go(i.getFieldRawValue("nationality")),[t.EnumMRZData.DocumentNumber]:i.getFieldValue(l)||i.getFieldValue("longDocumentNumber"),[t.EnumMRZData.IssuingState]:i.getFieldValue("issuingState"),[t.EnumMRZData.IssuingStateRaw]:Go(i.getFieldRawValue("issuingState")),[t.EnumMRZData.Sex]:Fo(i.getFieldValue("sex"))};Object.keys(d).forEach((e=>{let i=!1;switch(e){case t.EnumMRZData.FirstName:i=r("secondaryIdentifier");break;case t.EnumMRZData.LastName:i=r("primaryIdentifier");break;case t.EnumMRZData.DocumentNumber:i=r(l)||r("longDocumentNumber");break;default:i=r(e)}i&&n.push(e)}));const u=function(t){const e=new Date,i=e.getMonth()+1>t.month||e.getMonth()+1===t.month&&e.getDate()>=t.day;return e.getFullYear()-t.year-(i?0:1)}(h);u<1&&n.push(t.EnumMRZData.Age);return{[t.EnumMRZData.InvalidFields]:n,[t.EnumMRZData.FirstName]:d[t.EnumMRZData.FirstName],[t.EnumMRZData.LastName]:d[t.EnumMRZData.LastName],[t.EnumMRZData.Age]:u,[t.EnumMRZData.DateOfBirth]:h,[t.EnumMRZData.Sex]:d[t.EnumMRZData.Sex],[t.EnumMRZData.Nationality]:d[t.EnumMRZData.Nationality],[t.EnumMRZData.NationalityRaw]:d[t.EnumMRZData.NationalityRaw],[t.EnumMRZData.DocumentNumber]:d[t.EnumMRZData.DocumentNumber],[t.EnumMRZData.DateOfExpiry]:c,[t.EnumMRZData.IssuingState]:d[t.EnumMRZData.IssuingState],[t.EnumMRZData.IssuingStateRaw]:d[t.EnumMRZData.IssuingStateRaw],[t.EnumMRZData.DocumentType]:Fo(o),[t.EnumMRZData.MRZText]:e}}const Yo={[t.EnumMRZDocumentType.TD1]:{width:85.6,height:53.98},[t.EnumMRZDocumentType.TD2]:{width:105,height:74},[t.EnumMRZDocumentType.Passport]:{width:125,height:88}};class Ho{showScannerLoadingOverlay(t){const e=Ao(this.config.container);this.loadingScreen=ko(e,{message:t}),e.style.display="block",e.style.position="relative"}hideScannerLoadingOverlay(t=!1){this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,t&&(Ao(this.config.container).style.display="none"))}constructor(e,i){this.resources=e,this.config=i,this.isSoundFeedbackOn=!1,this.scanModeManager={[t.EnumMRZDocumentType.Passport]:!0,[t.EnumMRZDocumentType.TD1]:!0,[t.EnumMRZDocumentType.TD2]:!0},this.currentScanMode=t.EnumMRZScanMode.All,this.resizeTimer=null,this.capturedResultItems=[],this.originalImageData=null,this.initialized=!1,this.initializedDCE=!1,this.DCE_ELEMENTS={selectCameraBtn:null,uploadImageBtn:null,soundFeedbackBtn:null,closeScannerBtn:null,scanModeSelectContainer:null,passportModeOption:null,td1ModeOption:null,td2ModeOption:null,toast:null},this.loadingScreen=null,this.handleResize=()=>{this.toggleScanGuide(!1),this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((()=>{this.toggleScanGuide(!0)}),500)},this.firstFrame=!0}async initialize(){if(!this.initialized){this.initializeScanModeManager(),this.currentScanMode=this.getScanMode(),Mo("dynamsoft-mrz-loading-screen-style",No);try{const{cameraView:t,cameraEnhancer:e,cvRouter:i}=this.resources;if(t.setScanRegionMaskStyle({strokeStyle:"transparent",fillStyle:"transparent",lineWidth:0}),t.setVideoFit("cover"),i.setInput(e),!0===this.config.enableMultiFrameCrossFilter){const t=new vo;t.enableResultCrossVerification(Q.CRIT_TEXT_LINE,!0),await i.addResultFilter(t)}const n=new be;n.onCapturedResultReceived=t=>this.handleMRZResult(t),await i.addResultReceiver(n),this.toggleSoundFeedback(!1),!1===this.config.showScanGuide&&this.toggleScanGuide(!1),this.initialized=!0}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"Dynamsoft MRZ Scanner initialize error"}};this.currentScanResolver(n)}}}initializeElements(){var t;const e=Ao(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))throw new Error("Shadow root not found");if(this.DCE_ELEMENTS={selectCameraBtn:i.shadowRoot.querySelector(".dce-mn-select-camera-icon"),uploadImageBtn:i.shadowRoot.querySelector(".dce-mn-upload-image-icon"),soundFeedbackBtn:i.shadowRoot.querySelector(".dce-mn-sound-feedback"),closeScannerBtn:i.shadowRoot.querySelector(".dce-mn-close"),scanModeSelectContainer:i.shadowRoot.querySelector(".dce-mn-scan-mode-select"),passportModeOption:i.shadowRoot.querySelector(".scan-mode-option-passport"),td1ModeOption:i.shadowRoot.querySelector(".scan-mode-option-td1"),td2ModeOption:i.shadowRoot.querySelector(".scan-mode-option-td2"),toast:i.shadowRoot.querySelector(".dce-mn-toast")},this.setupScanModeSelector(),this.assignDCEClickEvents(),this.DCE_ELEMENTS.toast.style.display="none",!1===this.config.showUploadImage&&(this.DCE_ELEMENTS.uploadImageBtn.style.visibility="hidden"),!1===this.config.showSoundToggle&&(this.DCE_ELEMENTS.soundFeedbackBtn.style.visibility="hidden"),!1===(null===(t=this.config)||void 0===t?void 0:t.showPoweredByDynamsoft)){i.shadowRoot.querySelector(".dce-mn-msg-poweredby").style.display="none"}this.initializedDCE=!0}setupScanModeSelector(){if(!1!==this.config.showFormatSelector)switch(this.currentScanMode){case t.EnumMRZScanMode.PassportAndTD1:this.DCE_ELEMENTS.td2ModeOption.style.display="none";break;case t.EnumMRZScanMode.PassportAndTD2:this.DCE_ELEMENTS.td1ModeOption.style.display="none";break;case t.EnumMRZScanMode.TD1AndTD2:this.DCE_ELEMENTS.passportModeOption.style.display="none";break;case t.EnumMRZScanMode.All:break;default:this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}else this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}assignDCEClickEvents(){if(!Object.values(this.DCE_ELEMENTS).every(Boolean))throw new Error("Camera control elements not found");this.closeCamera=this.closeCamera.bind(this),this.DCE_ELEMENTS.uploadImageBtn.onclick=()=>this.uploadFile(),this.DCE_ELEMENTS.soundFeedbackBtn.onclick=()=>this.toggleSoundFeedback(),this.DCE_ELEMENTS.closeScannerBtn.onclick=()=>this.handleCloseBtn(),this.DCE_ELEMENTS.selectCameraBtn.onclick=t=>{t.stopPropagation(),this.toggleSelectCameraBox()},this.DCE_ELEMENTS.passportModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.passportModeOption.style.display&&await this.toggleScanDocType(t.EnumMRZDocumentType.Passport)},this.DCE_ELEMENTS.td1ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td1ModeOption.style.display&&await this.toggleScanDocType(t.EnumMRZDocumentType.TD1)},this.DCE_ELEMENTS.td2ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td2ModeOption.style.display&&await this.toggleScanDocType(t.EnumMRZDocumentType.TD2)}}handleCloseBtn(){this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:t.EnumResultStatus.RS_CANCELLED,message:"Cancelled"}})}attachOptionClickListeners(){const t=Ao(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings");[...e.shadowRoot.querySelectorAll(".dce-mn-camera-option"),...e.shadowRoot.querySelectorAll(".dce-mn-resolution-option")].forEach((t=>{t.addEventListener("click",(async e=>{const n=t.getAttribute("data-davice-id"),r=t.getAttribute("data-height"),s=t.getAttribute("data-width");n?this.resources.cameraEnhancer.selectCamera(n).then((()=>{this.toggleScanGuide()})):r&&s&&this.resources.cameraEnhancer.setResolution({width:parseInt(s),height:parseInt(r)}).then((()=>{this.toggleScanGuide()})),"none"!==i.style.display&&this.toggleSelectCameraBox()}))}))}highlightCameraAndResolutionOption(){const t=Ao(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings"),n=i.querySelectorAll(".dce-mn-camera-option"),r=i.querySelectorAll(".dce-mn-resolution-option"),s=this.resources.cameraEnhancer.getSelectedCamera(),a=this.resources.cameraEnhancer.getResolution();n.forEach((t=>{const e=t;e.getAttribute("data-davice-id")===(null==s?void 0:s.deviceId)?e.style.border="2px solid #fe814a":e.style.border="none"}));const o={"480p":"480","720p":"720","1080p":"1080","2k":"1440","4k":"2160"},l=function(t){const e=t.width*t.height,i=t.width/t.height;let n="480p",r=Number.MAX_VALUE;for(const[t,s]of Object.entries(Po)){const a=s.width*s.height,o=s.width/s.height,l=.7*Math.abs(a-e)+Math.abs(o-i)*a*.3;l{const e=t,i=e.getAttribute("data-height");e.style.border=i===o[l]?"2px solid #fe814a":"none"}))}toggleSelectCameraBox(){const t=Ao(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-resolution-box");this.highlightCameraAndResolutionOption(),this.attachOptionClickListeners(),i.click()}async relaunch(){}async uploadFile(){var e,i,n,r,s,a;const{cvRouter:o}=this.resources,l=document.createElement("input");l.type="file",l.accept=null!==(e=this.config.uploadAcceptedTypes)&&void 0!==e?e:"image/*",l.style.display="none",document.body.appendChild(l);try{this.showScannerLoadingOverlay("Processing file..."),await this.closeCamera(!1);const e=await new Promise(((t,e)=>{l.onchange=i=>{var n;const r=null===(n=i.target.files)||void 0===n?void 0:n[0];r?t(r):e(new Error("No file selected"))},l.addEventListener("cancel",(async()=>{this.hideScannerLoadingOverlay(!1),this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()})),l.click()}));if(!e)return;let h;if(this.config.uploadFileConverter&&!e.type.startsWith("image/"))try{h=await this.config.uploadFileConverter(e)}catch(t){throw new Error(`Error converting file: ${t.message}`)}else{if(!e.type.startsWith("image/"))throw new Error("Unsupported file type. Please provide a converter function for this file type.");h=e}const c=this.config.utilizedTemplateNames[this.currentScanMode];if(!1!==this.config.showScanGuide){const t=await o.getSimplifiedSettings(c);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await o.updateSettings(c,t)}const d=await o.capture(h,c);this.capturedResultItems=d.items;const u=this.capturedResultItems.filter((t=>t.type===Q.CRIT_ORIGINAL_IMAGE));if(0===u.length)throw new Error("No image data found in the captured result");const f=u[0].imageData;f.toCanvas=()=>D(f),f.toBlob=async()=>await M("image/png",f),this.originalImageData=f;const g=null===(i=null==d?void 0:d.parsedResult)||void 0===i?void 0:i.parsedResultItems;let m={};if(null==g?void 0:g.length){const t=(null===(r=null===(n=g[0])||void 0===n?void 0:n.referencedItem)||void 0===r?void 0:r.text)||"";m=Wo(t,g[0])}const p={status:{code:t.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:m,imageData:!0,_imageData:this.originalImageData};null===(a=(s=this.resources).onResultUpdated)||void 0===a||a.call(s,p),this.currentScanResolver(p)}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:`Error processing file: ${i}`}};this.currentScanResolver(n)}finally{this.hideScannerLoadingOverlay(!0),document.body.removeChild(l)}}toggleSoundFeedback(t){this.isSoundFeedbackOn=void 0!==t?t:!this.isSoundFeedbackOn;const e=Ao(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))return;const n=i.shadowRoot.querySelector(".dce-mn-sound-feedback"),r=n.querySelector(".dce-mn-sound-feedback-on");n.querySelector(".dce-mn-sound-feedback-off").style.display=this.isSoundFeedbackOn?"none":"block",r.style.display=this.isSoundFeedbackOn?"block":"none"}calculateScanRegion(t){const{cameraEnhancer:e,cameraView:i}=this.resources;if(!e||!e.isOpen())return;const n=Yo[t].width/Yo[t].height;let r;const s=i.getVisibleRegionOfVideo({inPixels:!0}),{width:a,height:o}=s;if(s){if(s.width>s.height){const t=.5*o*n,e=Math.round(t/a*100),i=(100-e)/2;r={left:i,right:i+e,top:25,bottom:75,isMeasuredInPercentage:!0}}else{const t=.9*a/n,e=Math.round(t/o*100),i=(100-e)/2;r={left:5,right:95,top:i,bottom:i+e,isMeasuredInPercentage:!0}}null==i||i.setScanRegionMaskVisible(!0),e.setScanRegion(r)}}toggleScanGuide(e){const i=Ao(this.config.container),n=i.children[i.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const r=n.shadowRoot.querySelector(".dce-scanguide-passport"),s=n.shadowRoot.querySelector(".dce-scanguide-td1"),a=n.shadowRoot.querySelector(".dce-scanguide-td2");if(!1===e||!1===this.config.showScanGuide)return r.style.display="none",s.style.display="none",void(a.style.display="none");switch(this.currentScanMode){case t.EnumMRZScanMode.All:case t.EnumMRZScanMode.Passport:case t.EnumMRZScanMode.PassportAndTD1:case t.EnumMRZScanMode.PassportAndTD2:r.style.display="block",s.style.display="none",a.style.display="none",this.calculateScanRegion(t.EnumMRZDocumentType.Passport);break;case t.EnumMRZScanMode.TD1:case t.EnumMRZScanMode.TD1AndTD2:r.style.display="none",s.style.display="block",a.style.display="none",this.calculateScanRegion(t.EnumMRZDocumentType.TD1);break;case t.EnumMRZScanMode.TD2:r.style.display="none",s.style.display="none",a.style.display="block",this.calculateScanRegion(t.EnumMRZDocumentType.TD2)}}async openCamera(){try{const{cameraEnhancer:t,cameraView:e}=this.resources,i=Ao(this.config.container);if(i.style.display="block",t.isOpen())t.isPaused()&&await t.resume();else{const n=e.getUIElement();n.parentElement||i.append(n),await t.open()}await t.setResolution({width:2560,height:1440}),!this.initializedDCE&&t.isOpen()&&await this.initializeElements(),window.addEventListener("resize",this.handleResize);const n=i.children[i.children.length-1];if(!(null==n?void 0:n.shadowRoot))throw new Error("Shadow root not found");n.shadowRoot.querySelector(".dce-mn-torch-off").style.display="none",n.shadowRoot.querySelector(".dce-mn-torch-on").style.display="none"}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"MRZ Scanner Open Camera Error"}};this.currentScanResolver(n)}}async closeCamera(t=!0){try{window.removeEventListener("resize",this.handleResize),this.resizeTimer&&(window.clearTimeout(this.resizeTimer),this.resizeTimer=null);const{cameraEnhancer:e,cameraView:i}=this.resources,n=Ao(this.config.container);n.style.display=t?"none":"block",(null==i?void 0:i.getUIElement().parentElement)&&n.removeChild(i.getUIElement()),e.close(),this.stopCapturing()}catch(t){let e=(null==t?void 0:t.message)||t;console.error(`Close Camera error: ${e}`)}}pauseCamera(){const{cameraEnhancer:t}=this.resources;t.pause()}stopCapturing(){const{cameraView:t,cvRouter:e}=this.resources;e.stopCapturing(),t.clearAllInnerDrawingItems()}async handleMRZResult(e){var i,n,r;if(this.firstFrame)this.firstFrame=!1;else if(!(e.items.length<=1)){this.capturedResultItems=e.items;try{const{onResultUpdated:s}=this.resources,a=e.items.filter((t=>t.type===Q.CRIT_ORIGINAL_IMAGE))[0].imageData;a.toCanvas=()=>D(a),a.toBlob=async()=>await M("image/png",a),this.originalImageData=a;const o=null===(i=null==e?void 0:e.parsedResult)||void 0===i?void 0:i.parsedResultItems;if(null==o?void 0:o.length){this.isSoundFeedbackOn&&Ss.beep();const e=(null===(r=null===(n=o[0])||void 0===n?void 0:n.referencedItem)||void 0===r?void 0:r.text)||"",i=Wo(e,o[0]);this.closeCamera();const a={status:{code:t.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:i,imageData:!0,_imageData:this.originalImageData};null==s||s(a),this.currentScanResolver(a)}}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"Error capturing image"}};this.currentScanResolver(n)}}}initializeScanModeManager(){const{mrzFormatType:e}=this.config;if(this.scanModeManager={[t.EnumMRZDocumentType.Passport]:!0,[t.EnumMRZDocumentType.TD1]:!0,[t.EnumMRZDocumentType.TD2]:!0},!e||Array.isArray(e)&&0===e.length)return;Object.keys(this.scanModeManager).forEach((t=>{this.scanModeManager[t]=!1}));(Array.isArray(e)?e:[e]).forEach((t=>{this.scanModeManager[t]=!0}))}getScanMode(){const e=Object.entries(this.scanModeManager).filter((([t,e])=>e)).map((([t])=>t)).sort().join(",");return{[t.EnumMRZDocumentType.Passport]:t.EnumMRZScanMode.Passport,[t.EnumMRZDocumentType.TD1]:t.EnumMRZScanMode.TD1,[t.EnumMRZDocumentType.TD2]:t.EnumMRZScanMode.TD2,[`${t.EnumMRZDocumentType.Passport},${t.EnumMRZDocumentType.TD1}`]:t.EnumMRZScanMode.PassportAndTD1,[`${t.EnumMRZDocumentType.Passport},${t.EnumMRZDocumentType.TD2}`]:t.EnumMRZScanMode.PassportAndTD2,[`${t.EnumMRZDocumentType.TD1},${t.EnumMRZDocumentType.TD2}`]:t.EnumMRZScanMode.TD1AndTD2,[`${t.EnumMRZDocumentType.Passport},${t.EnumMRZDocumentType.TD1},${t.EnumMRZDocumentType.TD2}`]:t.EnumMRZScanMode.All,"":t.EnumMRZScanMode.All}[e]}DCEShowToast(t,e=3e3){this.DCE_ELEMENTS.toast&&(this.DCE_ELEMENTS.toast.textContent=t,this.DCE_ELEMENTS.toast.style.display="",setTimeout((()=>{this.DCE_ELEMENTS.toast.style.display="none"}),e))}async startCapturing(){const{cvRouter:e,cameraEnhancer:i}=this.resources,n=this.config.utilizedTemplateNames[this.currentScanMode];try{if(!1!==this.config.showScanGuide){const t=await e.getSimplifiedSettings(n);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:50},{x:100,y:50},{x:100,y:100},{x:0,y:100}],await e.updateSettings(n,t)}this.firstFrame=!0,await e.startCapturing(n),i.setPixelFormat(l.IPF_ABGR_8888)}catch(e){let i=(null==e?void 0:e.message)||e;console.error("Failed to start capturing:",i),this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:t.EnumResultStatus.RS_FAILED,message:"Failed to start capturing"}})}}async toggleScanDocType(e){try{if(this.scanModeManager[e]&&0===Object.entries(this.scanModeManager).filter((([t,i])=>i&&t!==e)).length)return console.warn("MRZ Scanner - At least one mode must be enabled"),void this.DCEShowToast("At least one mode must be enabled");this.scanModeManager[e]=!this.scanModeManager[e],this.currentScanMode=this.getScanMode(),this.stopCapturing(),this.toggleScanGuide(),await this.startCapturing(),this.DCE_ELEMENTS.td1ModeOption.classList.toggle("selected",this.scanModeManager[t.EnumMRZDocumentType.TD1]),this.DCE_ELEMENTS.td2ModeOption.classList.toggle("selected",this.scanModeManager[t.EnumMRZDocumentType.TD2]),this.DCE_ELEMENTS.passportModeOption.classList.toggle("selected",this.scanModeManager[t.EnumMRZDocumentType.Passport])}catch(e){let i=(null==e?void 0:e.message)||e;console.error("MRZ Scanner switch scan mode error: ",i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"MRZ Scanner switch scan mode error"}};this.currentScanResolver(n)}}async launch(){try{await this.initialize();const{cvRouter:t,cameraEnhancer:e}=this.resources;return new Promise((async t=>{this.currentScanResolver=t,this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),!this.initializedDCE&&e.isOpen()&&await this.initializeElements(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()}))}catch(e){let i=(null==e?void 0:e.message)||e;console.error("MRZ Scanner launch error: ",i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"MRZ Scanner launch error"}};this.currentScanResolver(n)}}}const zo={cancel:'\n\n \n \n \n \n \n \n \n \n \n \n ',rescan:'\n\n\n \n\n\n\n\n\n\n\n',complete:'\n\n\n\n \n\n\n\n\n\n\n\n',failed:'\n \n \n \n\n',info:'\n\n \n \n \n\n'};class Xo{constructor(t,e,i){this.resources=t,this.config=e,this.scannerView=i,this.editedFields={}}async launch(){try{return Ao(this.config.container).textContent="",await this.initialize(),Ao(this.config.container).style.display="flex",new Promise((t=>{this.currentScanResultViewResolver=t}))}catch(t){let e=(null==t?void 0:t.message)||t;throw console.error(e),e}}async handleRescan(){var e;try{if(!this.scannerView)return void console.error("Scanner View not initialized");this.hideView();const i=await this.scannerView.launch();if((null===(e=null==i?void 0:i.status)||void 0===e?void 0:e.code)===t.EnumResultStatus.RS_FAILED)return void(this.currentScanResultViewResolver&&this.currentScanResultViewResolver(i));this.resources.onResultUpdated&&((null==i?void 0:i.status.code)===t.EnumResultStatus.RS_CANCELLED?this.resources.onResultUpdated(this.resources.result):(null==i?void 0:i.status.code)===t.EnumResultStatus.RS_SUCCESS&&this.resources.onResultUpdated(i)),this.dispose(!0),await this.initialize(),Ao(this.config.container).style.display="flex"}catch(e){throw console.error("Error in rescan handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:t.EnumResultStatus.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}async handleCancel(){var e;try{(null===(e=this.config)||void 0===e?void 0:e.onCancel)&&await this.config.onCancel(this.resources.result),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:t.EnumResultStatus.RS_CANCELLED,message:"Upload file cancelled"}}),this.hideView(),this.dispose()}catch(e){throw console.error("Error in cancel handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:t.EnumResultStatus.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}async handleDone(){var e,i;try{(null===(e=this.resources.result)||void 0===e?void 0:e.data)&&!Lo(this.editedFields)&&(this.resources.result.data=Object.assign(Object.assign({},this.resources.result.data),this.editedFields),this.resources.onResultUpdated&&this.resources.onResultUpdated(this.resources.result)),(null===(i=this.config)||void 0===i?void 0:i.onDone)&&await this.config.onDone(this.resources.result),this.currentScanResultViewResolver&&this.resources.result&&this.currentScanResultViewResolver(this.resources.result),this.hideView(),this.dispose()}catch(e){throw console.error("Error in done handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:t.EnumResultStatus.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}createControls(){var t,e,i,n,r,s,a,o,l,h,c,d;const{toolbarButtonsConfig:u}=this.config;return function(t){Mo("dynamsoft-mrz-controls-style","\n .dynamsoft-mrz-controls {\n display: flex;\n height: 6rem;\n background-color: #323234;\n align-items: center;\n font-size: 12px;\n font-family: Verdana;\n color: white;\n width: 100%;\n }\n\n .dynamsoft-mrz-control-btn {\n background-color: #323234;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n gap: 0.5rem;\n text-align: center;\n user-select: none;\n }\n\n .dynamsoft-mrz-control-btn.hide {\n display: none;\n }\n\n .dynamsoft-mrz-control-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n cursor: default;\n }\n\n .dynamsoft-mrz-control-icon-wrapper {\n flex: 0.75;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n min-height: 40px;\n }\n\n .dynamsoft-mrz-control-icon img,\n .dynamsoft-mrz-control-icon svg {\n width: 32px;\n height: 32px;\n fill: #fe8e14;\n }\n\n .dynamsoft-mrz-control-text {\n flex: 0.5;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-bottom: 0.5rem;\n }\n\n \n @media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-controls {\n flex-direction: column;\n height: 100%;\n width: 5rem;\n }\n\n .dynamsoft-mrz-control-text {\n padding: 0 0.5rem 0.5rem;\n }\n }\n");const e=document.createElement("div");return e.className="dynamsoft-mrz-controls",t.forEach((t=>{const i=document.createElement("div");i.className=`dynamsoft-mrz-control-btn ${null==t?void 0:t.className}`;const n=document.createElement("div");if(n.className="dynamsoft-mrz-control-icon-wrapper",(r=t.icon).trim().startsWith(""))n.innerHTML=t.icon;else{const e=document.createElement("img");e.src=t.icon,e.alt=t.label,e.width=24,e.height=24,n.appendChild(e)}var r;const s=document.createElement("div");s.className="dynamsoft-mrz-control-text",s.textContent=t.label,t.isDisabled&&i.classList.add("disabled"),t.isHidden&&i.classList.add("hide"),i.appendChild(n),i.appendChild(s),t.onClick&&!t.isDisabled&&i.addEventListener("click",t.onClick),e.appendChild(i)})),e}([this.config._isFileMode?{id:"dynamsoft-mrz-scanResult-cancel",icon:(null===(t=null==u?void 0:u.cancel)||void 0===t?void 0:t.icon)||zo.cancel,label:(null===(e=null==u?void 0:u.cancel)||void 0===e?void 0:e.label)||"Cancel",onClick:()=>this.handleCancel(),className:`${(null===(i=null==u?void 0:u.cancel)||void 0===i?void 0:i.className)||""}`,isHidden:(null===(n=null==u?void 0:u.cancel)||void 0===n?void 0:n.isHidden)||!1}:{id:"dynamsoft-mrz-scanResult-rescan",icon:(null===(r=null==u?void 0:u.rescan)||void 0===r?void 0:r.icon)||zo.rescan,label:(null===(s=null==u?void 0:u.rescan)||void 0===s?void 0:s.label)||"Re-scan",onClick:()=>this.handleRescan(),className:`${(null===(a=null==u?void 0:u.rescan)||void 0===a?void 0:a.className)||""}`,isHidden:(null===(o=null==u?void 0:u.rescan)||void 0===o?void 0:o.isHidden)||!1,isDisabled:!this.scannerView},{id:"dynamsoft-mrz-scanResult-done",icon:(null===(l=null==u?void 0:u.done)||void 0===l?void 0:l.icon)||zo.complete,label:(null===(h=null==u?void 0:u.done)||void 0===h?void 0:h.label)||"Done",className:`${(null===(c=null==u?void 0:u.done)||void 0===c?void 0:c.className)||""}`,isHidden:(null===(d=null==u?void 0:u.done)||void 0===d?void 0:d.isHidden)||!1,onClick:()=>this.handleDone()}])}handleFieldEdit(e,i){if(e===t.EnumMRZData.DateOfBirth||e===t.EnumMRZData.DateOfExpiry)try{const[t,n,r]=i.split(/[\/\-\.]/);r&&n&&t&&(this.editedFields[e]={day:parseInt(r,10),month:parseInt(n,10),year:parseInt(t,10)})}catch(t){console.error("Error parsing date",t)}else this.editedFields[e]=i}createMRZDataDisplay(){var e,i,n,r;const s=(null===(e=this.resources.result)||void 0===e?void 0:e.data)||{},a=!!this.config.allowResultEditing,o=s.invalidFields||[],l=[t.EnumMRZData.InvalidFields,t.EnumMRZData.IssuingStateRaw,t.EnumMRZData.NationalityRaw];!1===(null===(i=this.config)||void 0===i?void 0:i.showMRZText)&&l.push(t.EnumMRZData.MRZText);const h=document.createElement("div");if(h.className="dynamsoft-mrz-data-container",Lo(s)){const t=document.createElement("div");return t.className="dynamsoft-mrz-data-row empty",t.innerText=null!==(r=null===(n=this.config)||void 0===n?void 0:n.emptyResultMessage)&&void 0!==r?r:"The necessary information couldn't be detected. Please try again.",h.appendChild(t),h}if(o.length>0){const t=document.createElement("div");t.className="dynamsoft-mrz-error-notification",t.innerHTML=`\n
${zo.failed}
\n
\n ${a?"Some fields require correction. Please review highlighted fields.":"Some fields contain invalid information. Please rescan the document."}\n
\n `,h.appendChild(t)}else if(0===o.length&&a){const t=document.createElement("div");t.className="dynamsoft-mrz-info-notification",t.innerHTML=`\n
${zo.info}
\n
\n Please review all fields to ensure the information is correct.\n
\n `,h.appendChild(t)}return Object.entries(s).forEach((([e,i])=>{if(l.includes(e)||!i)return;const n=document.createElement("div");n.className="dynamsoft-mrz-data-row";const r=o.includes(e);r&&n.classList.add("invalid-field");const s=[t.EnumMRZData.MRZText,t.EnumMRZData.DocumentType,t.EnumMRZData.IssuingStateRaw,t.EnumMRZData.NationalityRaw],c=document.createElement("span");if(c.className="dynamsoft-mrz-data-label",c.innerText=jo[e]||e,r){const t=document.createElement("span");if(t.className="dynamsoft-mrz-error-icon",t.innerHTML=zo.failed,c.appendChild(t),a){const t=document.createElement("span");t.className="dynamsoft-mrz-error-hint",t.textContent="Please correct this field",c.appendChild(t)}}const d=document.createElement("div");if(d.className="dynamsoft-mrz-data-value",a&&!s.includes(e)){const s=document.createElement("input");s.className="dynamsoft-mrz-data-input",r&&s.classList.add("invalid"),e===t.EnumMRZData.DateOfBirth||e===t.EnumMRZData.DateOfExpiry?(s.value=Uo(i),s.setAttribute("placeholder","YYYY-MM-DD")):s.value=i,s.addEventListener("input",(t=>{if(this.handleFieldEdit(e,t.target.value),r){s.classList.remove("invalid"),n.classList.remove("invalid-field"),this.editedFields.invalidFields||(this.editedFields.invalidFields=[...o]);const t=this.editedFields.invalidFields.indexOf(e);t>-1&&this.editedFields.invalidFields.splice(t,1)}})),d.appendChild(s)}else e===t.EnumMRZData.MRZText?(d.classList.add("code"),d.innerText=i):e===t.EnumMRZData.DateOfBirth||e===t.EnumMRZData.DateOfExpiry?d.innerText=Uo(i):d.innerText=i,r&&d.classList.add("invalid-value");n.appendChild(c),n.appendChild(d),h.appendChild(n)})),h}async initialize(){try{if(!this.resources.result)throw Error("Captured image is missing. Please capture an image first!");if(!this.config.container)throw new Error("Please create a Scan Result View Container element");Mo("dynamsoft-mrz-result-view-style",Zo);const t=document.createElement("div");if(t.className="dynamsoft-mrz-result-view-container",!1!==this.config.showOriginalImage){const e=this.resources.result.originalImageResult,i=document.createElement("div");let n;i.className="dynamsoft-mrz-result-view-image-container",(null==e?void 0:e.toCanvas)&&(n=null==e?void 0:e.toCanvas()),Object.assign(n.style,{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}),i.appendChild(n),t.appendChild(i)}const e=this.createMRZDataDisplay();t.appendChild(e);const i=this.createControls();t.appendChild(i),Ao(this.config.container).appendChild(t)}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e)}}hideView(){Ao(this.config.container).style.display="none"}dispose(t=!1){Ao(this.config.container).textContent="",t||(this.currentScanResultViewResolver=void 0)}}const Zo="\n .dynamsoft-mrz-result-view-container {\n display: flex;\n width: 100%;\n height: 100%;\n background-color:#575757;\n font-size: 12px;\n flex-direction: column;\n align-items: center;\n }\n\n .dynamsoft-mrz-result-view-image-container {\n width: 100%;\n height: 200px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #323234;\n }\n\n \n.dynamsoft-mrz-data-container {\n font-size: 16px;\n font-family: Verdana;\n color: white;\n overflow: auto;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 1rem 0;\n}\n\n.dynamsoft-mrz-data-row {\n padding: 0.5rem 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n transition: background-color 0.3s ease;\n}\n\n.dynamsoft-mrz-data-row.invalid-field {\n background-color: rgba(231, 76, 60, 0.1);\n border-left: 3px solid #e74c3c;\n padding-left: calc(2rem - 3px);\n}\n\n.dynamsoft-mrz-data-label {\n color: #aaa;\n display: flex;\n gap: 0.5rem;\n align-items: end;\n flex-wrap: wrap;\n}\n\n.dynamsoft-mrz-error-notification,\n.dynamsoft-mrz-info-notification {\n color: white;\n padding: 1rem;\n margin: 0.5rem 2rem;\n border-radius: 4px;\n display: flex;\n align-items: center;\n gap: 1rem;\n text-align: start;\n}\n\n.dynamsoft-mrz-error-notification {\n background-color: rgba(231, 76, 60, 0.2);\n}\n\n.dynamsoft-mrz-info-notification {\n background-color: #fe8e14;\n}\n\n.dynamsoft-mrz-edit-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #aaa;\n}\n\n.dynamsoft-mrz-error-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-info-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.dynamsoft-mrz-info-message,\n.dynamsoft-mrz-error-message {\n flex: 1;\n}\n\n.dynamsoft-mrz-error-hint {\n font-size: 0.8rem;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-value {\n word-wrap: break-word;\n text-align: start;\n}\n\n.dynamsoft-mrz-data-value.code {\n font-family: monospace;\n}\n\n.dynamsoft-mrz-data-value.invalid-value {\n color: #e74c3c;\n text-decoration: wavy underline #e74c3c;\n text-decoration-skip-ink: none;\n}\n\n.dynamsoft-mrz-data-input {\n width: 100%;\n padding: 5px;\n background-color: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.3);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n transition: all 0.3s ease;\n}\n\n.dynamsoft-mrz-data-input.invalid {\n background-color: rgba(231, 76, 60, 0.1);\n border-color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-input:focus {\n background-color: rgba(255, 255, 255, 0.2);\n border-color: #fe8e14;\n outline: none;\n}\n\n@media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-result-view-container {\n flex-direction: row;\n }\n\n .dynamsoft-mrz-result-view-image-container{\n flex: 1;\n height: 100%;\n }\n\n .dynamsoft-mrz-data-container{\n flex: 1;\n }\n\n .dynamsoft-mrz-data-row:first-of-type {\n padding-top: 2rem;\n }\n\n .dynamsoft-mrz-data-row:last-of-type {\n padding-bottom: 2rem;\n }\n\n .dynamsoft-mrz-data-row.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding-top: 0;\n padding-bottom: 0;\n }\n}\n",qo={rootDirectory:"https://cdn.jsdelivr.net/npm/"};class Ko{showLoadingOverlay(t){var e,i;const n=Ao(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||Ao(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container);this.loadingScreen=ko(n,{message:t}),n.style.display="block",n.style.position="relative"}hideLoadingOverlay(t=!1){var e,i,n;const r=Ao(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||Ao(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container);this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,r.style.display="none",t&&(null===(n=this.config)||void 0===n?void 0:n.container)&&(Ao(this.config.container).style.display="none"))}constructor(t){this.config=t,this.resources={},this.isInitialized=!1,this.isCapturing=!1,this.loadingScreen=null,this.isDynamsoftResourcesLoaded=!1,this.isFileMode=!1,this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources()}async initialize(){if(this.isInitialized)return{resources:this.resources,components:{scannerView:this.scannerView,resultView:this.resultView}};try{if(!this.initializeMRZScannerConfig())return console.error("Failed to initialize mrz scanner config"),{resources:this.resources,components:{}};Mo("dynamsoft-mrz-loading-screen-style",No),this.showLoadingOverlay("Loading..."),await this.initializeDCVResources(),this.resources.onResultUpdated=t=>{this.resources.result=t};const t={};return this.config.scannerViewConfig&&!this.isFileMode&&(this.scannerView=new Ho(this.resources,this.config.scannerViewConfig),t.scannerView=this.scannerView,await this.scannerView.initialize()),this.config.resultViewConfig&&(this.resultView=new Xo(this.resources,this.config.resultViewConfig,this.scannerView),t.resultView=this.resultView),this.isInitialized=!0,{resources:this.resources,components:t}}catch(t){this.isInitialized=!1;const e=`Initialization Failed: ${(null==t?void 0:t.message)||t}`;throw console.error(e),new Error(e)}finally{this.hideLoadingOverlay(!0)}}initializeDynamsoftResources(){var t;Dt.engineResourcePaths=Lo(null===(t=this.config)||void 0===t?void 0:t.engineResourcePaths)?qo:this.config.engineResourcePaths,Dt.loadWasm(),Sa.loadSpec("MRTD_TD3_PASSPORT"),Sa.loadSpec("MRTD_TD3_VISA"),Sa.loadSpec("MRTD_TD1_ID"),Sa.loadSpec("MRTD_TD2_ID"),Sa.loadSpec("MRTD_TD2_VISA"),this.isDynamsoftResourcesLoaded=!0}async initializeDCVResources(){var t,e;try{this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources(),Xe._onAuthMessage=t=>t.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=mrz&deploymenttype=web)"),await Xe.initLicense((null===(t=this.config)||void 0===t?void 0:t.license)||"",{executeNow:!0}),this.isFileMode||(this.resources.cameraView=await kr.createInstance(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.cameraEnhancerUIPath),this.resources.cameraEnhancer=await Os.createInstance(this.resources.cameraView)),this.resources.cvRouter=await Te.createInstance(),await this.resources.cvRouter.initSettings(this.config.templateFilePath)}catch(t){let e=(null==t?void 0:t.message)||t;const i=(null==e?void 0:e.toLowerCase().includes("license"))?"The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.":`Resource Initialization Failed: ${e}`;throw console.error(i),new Error(i)}}shouldCreateDefaultContainer(){var t,e;const i=!this.config.container,n=!((null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container));return i&&n}createDefaultMRZScannerContainer(){const t=document.createElement("div");return t.className="mrz-scanner-main-container",Object.assign(t.style,{height:"100dvh",width:"100%",position:"absolute",left:"0",top:"0",zIndex:"999"}),document.body.append(t),t}checkForTemporaryLicense(t){return!(null==t?void 0:t.length)||(null==t?void 0:t.startsWith("A"))||(null==t?void 0:t.startsWith("L"))||(null==t?void 0:t.startsWith("P"))||(null==t?void 0:t.startsWith("Y"))?"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9":t}validateViewConfigs(){var t,e,i,n,r,s,a,o;if(!this.config.container){if((null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)&&this.config.showResultView&&!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container)){const t="MRZResultView container is required when showResultView is true";return alert(t),console.error(t),!1}if(!(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.container)&&(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container)&&!this.resources.result){const t="Result is needed to create MRZResultView without a scanner view";return alert(t),console.error(t),!1}}try{if(this.config.container&&!Ao(this.config.container)){const t="Invalid main container reference";return alert(t),console.error(t),!1}if((null===(r=this.config.scannerViewConfig)||void 0===r?void 0:r.container)&&!Ao(null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.container)){const t="Invalid scanner view container reference";return alert(t),console.error(t),!1}if((null===(a=this.config.resultViewConfig)||void 0===a?void 0:a.container)&&!Ao(null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)){const t="Invalid result view container reference";return alert(t),console.error(t),!1}}catch(t){const e=`Error accessing container references: ${t.message}`;return alert(e),console.error(e),!1}return!0}showResultView(){var t,e;return!1!==this.config.showResultView&&(this.config.container?!(void 0!==this.config.showResultView||!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container)&&!this.config.container)||!!this.config.showResultView:this.config.showResultView&&!!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container))}initializeMRZScannerConfig(){var e,i,n,r,s,a,o;this.config=null!==(e=this.config)&&void 0!==e?e:{};if(!this.validateViewConfigs())return!1;this.shouldCreateDefaultContainer()?this.config.container=this.createDefaultMRZScannerContainer():this.config.container&&(this.config.container=Ao(this.config.container));const l=this.config.container?this.createViewContainers(Ao(this.config.container)):{},h={license:this.checkForTemporaryLicense(this.config.license),utilizedTemplateNames:Object.fromEntries(Object.values(t.EnumMRZScanMode).map((t=>{var e;return[t,(null===(e=this.config.utilizedTemplateNames)||void 0===e?void 0:e[t])||Oo[t]]}))),templateFilePath:(null===(i=this.config)||void 0===i?void 0:i.templateFilePath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.template.json"},c=Object.assign(Object.assign({},this.config.scannerViewConfig),{container:l[t.EnumMRZScannerViews.Scanner]||Ao(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)||null,cameraEnhancerUIPath:(null===(r=this.config.scannerViewConfig)||void 0===r?void 0:r.cameraEnhancerUIPath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.ui.html",templateFilePath:h.templateFilePath,utilizedTemplateNames:h.utilizedTemplateNames,enableMultiFrameCrossFilter:null===(a=null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.enableMultiFrameCrossFilter)||void 0===a||a,mrzFormatType:this.config.mrzFormatType}),d=this.showResultView()?Object.assign(Object.assign({},this.config.resultViewConfig),{_isFileMode:this.isFileMode,container:l[t.EnumMRZScannerViews.Result]||Ao(null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)||null}):void 0;return Object.assign(this.config,Object.assign(Object.assign({},h),{scannerViewConfig:c,resultViewConfig:d})),!0}createViewContainers(e){e.textContent="";const i=[t.EnumMRZScannerViews.Scanner];return this.showResultView()&&i.push(t.EnumMRZScannerViews.Result),i.reduce(((t,i)=>{const n=document.createElement("div");return n.className=`mrz-scanner-${i}-view-container`,Object.assign(n.style,{height:"100%",width:"100%",display:"none",position:"relative"}),e.append(n),t[i]=n,t}),{})}dispose(){var t,e;this.resultView&&(this.resultView.dispose(),this.resultView=null),this.scannerView=null,this.resources.cameraEnhancer&&(this.resources.cameraEnhancer.dispose(),this.resources.cameraEnhancer=null),this.resources.cameraView&&(this.resources.cameraView.dispose(),this.resources.cameraView=null),this.resources.cvRouter&&(this.resources.cvRouter.dispose(),this.resources.cvRouter=null),this.resources.result=null,this.resources.onResultUpdated=null;const i=t=>{const e=Ao(t);e&&(e.style.display="none",e.textContent="")};i(this.config.container),i(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container),i(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container),this.isInitialized=!1}async processUploadedFile(e){var i,n,r,s,a,o;try{this.showLoadingOverlay("Processing File...");const{cvRouter:l}=this.resources,h=null===(i=this.config.utilizedTemplateNames)||void 0===i?void 0:i.all,c=await l.getSimplifiedSettings(h);c.roiMeasuredInPercentage=!0,c.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await l.updateSettings(h,c);const d=await l.capture(e,h),u=d.items,f=u.filter((t=>t.type===Q.CRIT_ORIGINAL_IMAGE))[0].imageData;f.toCanvas=()=>D(f),f.toBlob=async()=>await M("image/png",f);const g=null===(n=null==d?void 0:d.parsedResult)||void 0===n?void 0:n.parsedResultItems;let m={};if(null==g?void 0:g.length){const t=(null===(s=null===(r=g[0])||void 0===r?void 0:r.referencedItem)||void 0===s?void 0:s.text)||"";m=Wo(t,g[0])}const p={status:{code:t.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:f,data:m,imageData:!0,_imageData:f};null===(o=(a=this.resources).onResultUpdated)||void 0===o||o.call(a,p)}catch(e){return console.error("Failed to process uploaded file:",e),{status:{code:t.EnumResultStatus.RS_FAILED,message:`Failed to process image: ${e.message||e}`}}}finally{this.hideLoadingOverlay(!1)}}async launch(e){if(this.isCapturing)throw new Error("Capture session already in progress");try{this.isCapturing=!0,this.isFileMode=!!e;const{components:i}=await this.initialize();if(Lo(i))throw new Error("MRZ Scanner initialization failed ");if(this.config.container&&(Ao(this.config.container).style.display="block"),this.isFileMode&&await this.processUploadedFile(e),!i.scannerView&&this.resources.result&&i.resultView)return await i.resultView.launch();if(!i.scannerView&&!this.resources.result&&!this.isFileMode)throw new Error("Scanner view is required when no previous result exists");if(i.scannerView){const e=await i.scannerView.launch();if((null==e?void 0:e.status.code)!==t.EnumResultStatus.RS_SUCCESS)return{status:{code:null==e?void 0:e.status.code,message:(null==e?void 0:e.status.message)||"Failed to capture image"}};if(i.resultView)return await i.resultView.launch()}return this.resources.result}catch(e){return alert((null==e?void 0:e.message)||e),console.error((null==e?void 0:e.message)||e),{status:{code:t.EnumResultStatus.RS_FAILED,message:(null==e?void 0:e.message)||e}}}finally{this.isCapturing=!1,this.dispose()}}}const Jo={MRZScanner:Ko,MRZScannerView:Ho,MRZResultView:Xo};t.DEFAULT_TEMPLATE_NAMES=Oo,t.Dynamsoft=Ro,t.DynamsoftMRZScanner=Jo,t.MRZDataLabel=jo,t.MRZResultView=Xo,t.MRZScanner=Ko,t.MRZScannerView=Ho,t.displayMRZDate=Uo})); diff --git a/dist/mrz-scanner.bundle.mjs b/dist/mrz-scanner.bundle.mjs index fdd8684..2e37e7a 100644 --- a/dist/mrz-scanner.bundle.mjs +++ b/dist/mrz-scanner.bundle.mjs @@ -1 +1 @@ -const t=t=>t&&"object"==typeof t&&"function"==typeof t.then,e=(async()=>{})().constructor;class i extends e{get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(i){let n;this._task=i,t(i)?n=i:"function"==typeof i&&(n=new e(i)),n&&(async()=>{try{const t=await n;i===this._task&&this.resolve(t)}catch(t){i===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let i,n;super(((t,e)=>{i=t,n=e})),this._s="pending",this.resolve=e=>{this.isPending&&(t(e)?this.task=e:(this._s="fulfilled",i(e)))},this.reject=t=>{this.isPending&&(this._s="rejected",n(t))},this.task=e}}function n(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 r(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 s,a,o;"function"==typeof SuppressedError&&SuppressedError,function(t){t[t.BOPM_BLOCK=0]="BOPM_BLOCK",t[t.BOPM_UPDATE=1]="BOPM_UPDATE"}(s||(s={})),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"}(a||(a={})),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"}(o||(o={}));const l="undefined"==typeof self,h="function"==typeof importScripts,c=(()=>{if(!h){if(!l&&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"./"}})(),d=t=>{if(null==t&&(t="./"),l||h);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t},u=t=>Object.prototype.toString.call(t),f=t=>Array.isArray?Array.isArray(t):"[object Array]"===u(t),g=t=>"[object Boolean]"===u(t),m=t=>"number"==typeof t&&!Number.isNaN(t),p=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),_=t=>!(!p(t)||!m(t.x)||!m(t.y)||!m(t.radius)||t.radius<0||!m(t.startAngle)||!m(t.endAngle)),v=t=>!!p(t)&&!!f(t.points)&&0!=t.points.length&&!t.points.some((t=>!T(t))),y=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&&!S(t.tag)),w=t=>!(!y(t)||!m(t.bytes.length)&&!m(t.bytes.ptr)),C=t=>!!y(t)&&t.bytes instanceof Uint8Array,E=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||!g(t.isMeasuredInPercentage)),S=t=>null===t||!!p(t)&&!!m(t.imageId)&&"type"in t,b=t=>!(!p(t)||!T(t.startPoint)||!T(t.endPoint)||t.startPoint.x==t.endPoint.x&&t.startPoint.y==t.endPoint.y),T=t=>!!p(t)&&!!m(t.x)&&!!m(t.y),I=t=>!!p(t)&&!!f(t.points)&&0!=t.points.length&&!t.points.some((t=>!T(t))),x=t=>!!p(t)&&!!f(t.points)&&0!=t.points.length&&4==t.points.length&&!t.points.some((t=>!T(t))),O=t=>!(!p(t)||!m(t.x)||!m(t.y)||!m(t.width)||t.width<0||!m(t.height)||t.height<0||"isMeasuredInPercentage"in t&&!g(t.isMeasuredInPercentage)),A=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))}})),R=t=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(t),D=(t,e)=>{let i=t.split("."),n=e.split(".");for(let t=0;t{const e={},i={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",dcpd:"dynamsoft-code-parser",dlrData:"dynamsoft-label-recognizer-data",dce:"dynamsoft-camera-enhancer",ddv:"dynamsoft-document-viewer"};for(let n in t){if("rootDirectory"===n)continue;let r=n,s=t[r],a=s&&"object"==typeof s&&s.path?s.path:s,o=t.rootDirectory;if(o&&!o.endsWith("/")&&(o+="/"),"object"==typeof s&&s.isInternal)o&&(a=t[r].version?`${o}${i[r]}@${t[r].version}/dist/${"ddv"===r?"engine":""}`:`${o}${i[r]}/dist/${"ddv"===r?"engine":""}`);else{const i=/^@engineRootDirectory(\/?)/;if("string"==typeof a&&(a=a.replace(i,o||"")),"object"==typeof a&&"dwt"===r){const n=t[r].resourcesPath,s=t[r].serviceInstallerLocation;e[r]={resourcesPath:n.replace(i,o||""),serviceInstallerLocation:s.replace(i,o||"")};continue}}e[r]=d(a)}return e},M=async(t,e,i)=>await new Promise((async(n,r)=>{try{const r=e.split(".");let s=r[r.length-1];const a=await k(`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()}})),F=t=>{C(t)&&(t=N(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},P=(t,e)=>{C(e)&&(e=N(e));const i=F(e);let n=new Image,r=i.toDataURL(t);return n.src=r,n},k=async(t,e)=>{C(e)&&(e=N(e));const i=F(e);return new Promise(((e,n)=>{i.toBlob((t=>e(t)),t)}))},N=t=>{let e,i=t.bytes;if(!(i&&i instanceof Uint8Array))throw Error("Parameter type error");if(Number(t.format)===o.IPF_BGR_888){const t=i.length/3;e=new Uint8ClampedArray(4*t);for(let n=0;n=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)===o.IPF_ABGR_8888){const t=i.length/4;e=new Uint8ClampedArray(i.length);for(let n=0;n=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)};var B,j,V,U,G,W,Y,z;let H,X,Z,q,J,K=class t{get _isFetchingStarted(){return n(this,G,"f")}constructor(){B.add(this),j.set(this,[]),V.set(this,1),U.set(this,s.BOPM_BLOCK),G.set(this,!1),W.set(this,void 0),Y.set(this,a.CCUT_AUTO)}setErrorListener(t){}addImageToBuffer(t){var e;if(!C(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(n(this,j,"f").length>=n(this,V,"f"))switch(n(this,U,"f")){case s.BOPM_BLOCK:break;case s.BOPM_UPDATE:if(n(this,j,"f").push(t),p(n(this,W,"f"))&&m(n(this,W,"f").imageId)&&1==n(this,W,"f").keepInBuffer)for(;n(this,j,"f").length>n(this,V,"f");){const t=n(this,j,"f").findIndex((t=>{var e;return(null===(e=t.tag)||void 0===e?void 0:e.imageId)!==n(this,W,"f").imageId}));n(this,j,"f").splice(t,1)}else n(this,j,"f").splice(0,n(this,j,"f").length-n(this,V,"f"))}else n(this,j,"f").push(t)}getImage(){if(0===n(this,j,"f").length)return null;let e;if(n(this,W,"f")&&m(n(this,W,"f").imageId)){const t=n(this,B,"m",z).call(this,n(this,W,"f").imageId);if(t<0)throw new Error(`Image with id ${n(this,W,"f").imageId} doesn't exist.`);e=n(this,j,"f").slice(t,t+1)[0]}else e=n(this,j,"f").pop();if([o.IPF_RGB_565,o.IPF_RGB_555,o.IPF_RGB_888,o.IPF_ARGB_8888,o.IPF_RGB_161616,o.IPF_ARGB_16161616,o.IPF_ABGR_8888,o.IPF_ABGR_16161616,o.IPF_BGR_888].includes(e.format)){if(n(this,Y,"f")===a.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;t0!==t.length&&t.every((t=>m(t))))(t))throw new TypeError("Invalid 'imageId'.");if(void 0!==e&&!g(e))throw new TypeError("Invalid 'keepInBuffer'.");r(this,W,{imageId:t,keepInBuffer:e})}_resetNextReturnedImage(){r(this,W,null)}hasImage(t){return n(this,B,"m",z).call(this,t)>=0}startFetching(){r(this,G,!0)}stopFetching(){r(this,G,!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(r(this,V,t);n(this,j,"f")&&n(this,j,"f").length>t;)n(this,j,"f").shift()}getMaxImageCount(){return n(this,V,"f")}getImageCount(){return n(this,j,"f").length}clearBuffer(){n(this,j,"f").length=0}isBufferEmpty(){return 0===n(this,j,"f").length}setBufferOverflowProtectionMode(t){r(this,U,t)}getBufferOverflowProtectionMode(){return n(this,U,"f")}setColourChannelUsageType(t){r(this,Y,t)}getColourChannelUsageType(){return n(this,Y,"f")}};j=new WeakMap,V=new WeakMap,U=new WeakMap,G=new WeakMap,W=new WeakMap,Y=new WeakMap,B=new WeakSet,z=function(t){if("number"!=typeof t)throw new TypeError("Invalid 'imageId'.");return n(this,j,"f").findIndex((e=>{var i;return(null===(i=e.tag)||void 0===i?void 0:i.imageId)===t}))},"undefined"!=typeof navigator&&(H=navigator,X=H.userAgent,Z=H.platform,q=H.mediaDevices),function(){if(!l){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:H.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:Z,search:"Win"},Mac:{str:Z},Linux:{str:Z}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||X,a=r.search||e,o=r.verStr||X,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||X,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=X.indexOf("Windows NT")&&(r="HarmonyOS"),J={browser:i,version:n,OS:r}}l&&(J={browser:"ssr",version:0,OS:"ssr"})}();const $="undefined"!=typeof WebAssembly&&X&&!(/Safari/.test(X)&&!/Chrome/.test(X)&&/\(.+\s11_2_([2-6]).*\)/.test(X)),Q=!("undefined"==typeof Worker),tt=!(!q||!q.getUserMedia),et=async()=>{let t=!1;if(tt)try{(await q.getUserMedia({video:!0})).getTracks().forEach((t=>{t.stop()})),t=!0}catch(t){}return t};"Chrome"===J.browser&&J.version>66||"Safari"===J.browser&&J.version>13||"OPR"===J.browser&&J.version>43||"Edge"===J.browser&&J.version;const it={},nt=async t=>{let e="string"==typeof t?[t]:t,n=[];for(let t of e)n.push(it[t]=it[t]||new i);await Promise.all(n)},rt=async(t,e)=>{let n,r="string"==typeof t?[t]:t,s=[];for(let t of r){let r;s.push(r=it[t]=it[t]||new i(n=n||e())),r.isEmpty&&(r.task=n=n||e())}await Promise.all(s)};let st,at=0;const ot=()=>at++,lt={};let ht;const ct=t=>{ht=t,st&&st.postMessage({type:"setBLog",body:{value:!!t}})};let dt=!1;const ut=t=>{dt=t,st&&st.postMessage({type:"setBDebug",body:{value:!!t}})},ft={},gt={},mt={dip:{wasm:!0}},pt={std:{version:"1.4.21",path:d(c+"../../dynamsoft-capture-vision-std@1.4.21/dist/"),isInternal:!0},core:{version:"3.4.31",path:c,isInternal:!0}},_t=async t=>{let e;t instanceof Array||(t=t?[t]:[]);let n=it.core;e=!n||n.isEmpty;let r=new Map;const s=t=>{if("std"==(t=t.toLowerCase())||"core"==t)return;if(!mt[t])throw Error("The '"+t+"' module cannot be found.");let e=mt[t].deps;if(null==e?void 0:e.length)for(let t of e)s(t);let i=it[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 rt(a,(async()=>{const t=[...r.entries()].filter((t=>t[1])).map((t=>t[0]));await nt(o);const n=L(pt),s={};for(let e of t)s[e]=mt[e];const a={engineResourcePaths:n,autoResources:s,names:t};let l=new i;if(e){a.needLoadCore=!0;let t=n.core+vt._workerName;t.startsWith(location.origin)||(t=await fetch(t).then((t=>t.blob())).then((t=>URL.createObjectURL(t)))),st=new Worker(t),st.onerror=t=>{let e=new Error(t.message);l.reject(e)},st.addEventListener("message",(t=>{let e=t.data?t.data:t,i=e.type,n=e.id,r=e.body;switch(i){case"log":ht&&ht(e.message);break;case"task":try{lt[n](r),delete lt[n]}catch(t){throw delete lt[n],t}break;case"event":try{lt[n](r)}catch(t){throw t}break;default:console.log(t)}})),a.bLog=!!ht,a.bd=dt,a.dm=location.origin.startsWith("http")?location.origin:"https://localhost"}else await nt("core");let h=at++;lt[h]=t=>{if(t.success)Object.assign(ft,t.versions),"{}"!==JSON.stringify(t.versions)&&(vt._versions=t.versions),l.resolve(void 0);else{const e=Error(t.message);t.stack&&(e.stack=t.stack),l.reject(e)}},st.postMessage({type:"loadWasm",body:a,id:h}),await l}))};class vt{static get engineResourcePaths(){return pt}static set engineResourcePaths(t){Object.assign(pt,t)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _onLog(){return ht}static set _onLog(t){ct(t)}static get _bDebug(){return dt}static set _bDebug(t){ut(t)}static isModuleLoaded(t){return t=(t=t||"core").toLowerCase(),!!it[t]&&it[t].isFulfilled}static async loadWasm(t){return await _t(t)}static async detectEnvironment(){return await(async()=>({wasm:$,worker:Q,getUserMedia:tt,camera:await et(),browser:J.browser,version:J.version,OS:J.OS}))()}static async getModuleVersion(){return await new Promise(((t,e)=>{let i=ot();lt[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)}},st.postMessage({type:"getModuleVersion",id:i})}))}static getVersion(){return`3.4.31(Worker: ${ft.core&&ft.core.worker||"Not Loaded"}, Wasm: ${ft.core&&ft.core.wasm||"Not Loaded"})`}static enableLogging(){K._onLog=console.log,vt._onLog=console.log}static disableLogging(){K._onLog=null,vt._onLog=null}static async cfd(t){return await new Promise(((e,i)=>{let n=ot();lt[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},st.postMessage({type:"cfd",id:n,body:{count:t}})}))}}var yt,wt,Ct,Et,St,bt,Tt,It,xt;vt._bSupportDce4Module=-1,vt._bSupportIRTModule=-1,vt._versions=null,vt._workerName="core.worker.js",vt.browserInfo=J,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_NORMALIZED_IMAGE=16]="CRIT_NORMALIZED_IMAGE",t[t.CRIT_PARSED_RESULT=32]="CRIT_PARSED_RESULT"}(yt||(yt={})),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"}(wt||(wt={})),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_RESERVED_INFO_NOT_MATCH=-10040]="EC_RESERVED_INFO_NOT_MATCH",t[t.EC_LICENSE_KEY_NOT_MATCH=-10043]="EC_LICENSE_KEY_NOT_MATCH",t[t.EC_REQUEST_FAILED=-10044]="EC_REQUEST_FAILED",t[t.EC_LICENSE_INIT_FAILED=-10045]="EC_LICENSE_INIT_FAILED",t[t.EC_SET_MODE_ARGUMENT_ERROR=-10051]="EC_SET_MODE_ARGUMENT_ERROR",t[t.EC_LICENSE_CONTENT_INVALID=-10052]="EC_LICENSE_CONTENT_INVALID",t[t.EC_LICENSE_KEY_INVALID=-10053]="EC_LICENSE_KEY_INVALID",t[t.EC_LICENSE_DEVICE_RUNS_OUT=-10054]="EC_LICENSE_DEVICE_RUNS_OUT",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_NO_LICENSE=-2e4]="EC_NO_LICENSE",t[t.EC_HANDSHAKE_CODE_INVALID=-20001]="EC_HANDSHAKE_CODE_INVALID",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_LICENSE_INIT_SEQUENCE_FAILED=-20009]="EC_LICENSE_INIT_SEQUENCE_FAILED",t[t.EC_TRIAL_LICENSE=-20010]="EC_TRIAL_LICENSE",t[t.EC_FAILED_TO_REACH_DLS=-20200]="EC_FAILED_TO_REACH_DLS",t[t.EC_LICENSE_CACHE_USED=-20012]="EC_LICENSE_CACHE_USED",t[t.EC_BARCODE_FORMAT_INVALID=-30009]="EC_BARCODE_FORMAT_INVALID",t[t.EC_QR_LICENSE_INVALID=-30016]="EC_QR_LICENSE_INVALID",t[t.EC_1D_LICENSE_INVALID=-30017]="EC_1D_LICENSE_INVALID",t[t.EC_PDF417_LICENSE_INVALID=-30019]="EC_PDF417_LICENSE_INVALID",t[t.EC_DATAMATRIX_LICENSE_INVALID=-30020]="EC_DATAMATRIX_LICENSE_INVALID",t[t.EC_CUSTOM_MODULESIZE_INVALID=-30025]="EC_CUSTOM_MODULESIZE_INVALID",t[t.EC_AZTEC_LICENSE_INVALID=-30041]="EC_AZTEC_LICENSE_INVALID",t[t.EC_PATCHCODE_LICENSE_INVALID=-30046]="EC_PATCHCODE_LICENSE_INVALID",t[t.EC_POSTALCODE_LICENSE_INVALID=-30047]="EC_POSTALCODE_LICENSE_INVALID",t[t.EC_DPM_LICENSE_INVALID=-30048]="EC_DPM_LICENSE_INVALID",t[t.EC_FRAME_DECODING_THREAD_EXISTS=-30049]="EC_FRAME_DECODING_THREAD_EXISTS",t[t.EC_STOP_DECODING_THREAD_FAILED=-30050]="EC_STOP_DECODING_THREAD_FAILED",t[t.EC_MAXICODE_LICENSE_INVALID=-30057]="EC_MAXICODE_LICENSE_INVALID",t[t.EC_GS1_DATABAR_LICENSE_INVALID=-30058]="EC_GS1_DATABAR_LICENSE_INVALID",t[t.EC_GS1_COMPOSITE_LICENSE_INVALID=-30059]="EC_GS1_COMPOSITE_LICENSE_INVALID",t[t.EC_DOTCODE_LICENSE_INVALID=-30061]="EC_DOTCODE_LICENSE_INVALID",t[t.EC_PHARMACODE_LICENSE_INVALID=-30062]="EC_PHARMACODE_LICENSE_INVALID",t[t.EC_CHARACTER_MODEL_FILE_NOT_FOUND=-40100]="EC_CHARACTER_MODEL_FILE_NOT_FOUND",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_ZA_DL_LICENSE_INVALID=-90006]="EC_ZA_DL_LICENSE_INVALID",t[t.EC_AAMVA_DL_ID_LICENSE_INVALID=-90007]="EC_AAMVA_DL_ID_LICENSE_INVALID",t[t.EC_AADHAAR_LICENSE_INVALID=-90008]="EC_AADHAAR_LICENSE_INVALID",t[t.EC_MRTD_LICENSE_INVALID=-90009]="EC_MRTD_LICENSE_INVALID",t[t.EC_VIN_LICENSE_INVALID=-90010]="EC_VIN_LICENSE_INVALID",t[t.EC_CUSTOMIZED_CODE_TYPE_LICENSE_INVALID=-90011]="EC_CUSTOMIZED_CODE_TYPE_LICENSE_INVALID",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"}(Ct||(Ct={})),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"}(Et||(Et={})),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"}(St||(St={})),function(t){t[t.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",t[t.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(bt||(bt={})),function(t){t[t.PDFRM_VECTOR=1]="PDFRM_VECTOR",t[t.PDFRM_RASTER=2]="PDFRM_RASTER",t[t.PDFRM_REV=-2147483648]="PDFRM_REV"}(Tt||(Tt={})),function(t){t[t.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",t[t.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(It||(It={})),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"}(xt||(xt={}));const Ot={IRUT_NULL:BigInt(0),IRUT_COLOUR_IMAGE:BigInt(1),IRUT_SCALED_DOWN_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_UP_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_NORMALIZED_IMAGES:BigInt(1<<26),IRUT_SHORT_LINES:BigInt(1<<27),IRUT_RAW_TEXT_LINES:BigInt(1<<28),IRUT_LOGIC_LINES:BigInt(1<<29),IRUT_ALL:BigInt("0xFFFFFFFFFFFFFFFF")};var At,Rt;!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_NORMALIZED_IMAGE=6]="ROET_NORMALIZED_IMAGE",t[t.ROET_SOURCE_IMAGE=7]="ROET_SOURCE_IMAGE",t[t.ROET_TARGET_ROI=8]="ROET_TARGET_ROI"}(At||(At={})),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_NORMALIZATION=7]="ST_DOCUMENT_NORMALIZATION"}(Rt||(Rt={}));const Dt="undefined"==typeof self,Lt=Dt?{}:self,Mt="function"==typeof importScripts,Ft=(()=>{if(!Mt){if(!Dt&&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"./"}})(),Pt=t=>t&&"object"==typeof t&&"function"==typeof t.then,kt=(async()=>{})().constructor;let Nt=class extends kt{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,Pt(t)?e=t:"function"==typeof t&&(e=new kt(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&&(Pt(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}};const Bt=" is not allowed to change after `createInstance` or `loadWasm` is called.",jt=!Dt&&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"))||"",Vt=(t,e)=>{const i=t;if(i._license!==e){if(!i._pLoad.isEmpty)throw new Error("`license`"+Bt);i._license=e}};!Dt&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword");const Ut=t=>{if(null==t)t=[];else{t=t instanceof Array?[...t]:[t];for(let e=0;e{e=Ut(e);const i=t;if(i._licenseServer!==e){if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+Bt);i._licenseServer=e}},Wt=(t,e)=>{e=e||"";const i=t;if(i._deviceFriendlyName!==e){if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+Bt);i._deviceFriendlyName=e}};let Yt,zt,Ht,Xt,Zt;"undefined"!=typeof navigator&&(Yt=navigator,zt=Yt.userAgent,Ht=Yt.platform,Xt=Yt.mediaDevices),function(){if(!Dt){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:Yt.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:Ht,search:"Win"},Mac:{str:Ht},Linux:{str:Ht}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||zt,a=r.search||e,o=r.verStr||zt,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||zt,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=zt.indexOf("Windows NT")&&(r="HarmonyOS"),Zt={browser:i,version:n,OS:r}}Dt&&(Zt={browser:"ssr",version:0,OS:"ssr"})}(),Xt&&Xt.getUserMedia,"Chrome"===Zt.browser&&Zt.version>66||"Safari"===Zt.browser&&Zt.version>13||"OPR"===Zt.browser&&Zt.version>43||"Edge"===Zt.browser&&Zt.version;const qt=()=>(_t("license"),rt("dynamsoft_inited",(async()=>{let{lt:t,l:e,ls:i,sp:n,rmk:r,cv:s}=((t,e=!1)=>{const i=Kt;if(i._pLoad.isEmpty){let n,r,s,a=i._license||"",o=JSON.parse(JSON.stringify(i._licenseServer)),l=i._sessionPassword,h=0;if(a.startsWith("t")||a.startsWith("f"))h=0;else if(0===a.length||a.startsWith("P")||a.startsWith("L")||a.startsWith("Y")||a.startsWith("A"))h=1;else{h=2;const e=a.indexOf(":");-1!=e&&(a=a.substring(e+1));const i=a.indexOf("?");if(-1!=i&&(r=a.substring(i+1),a=a.substring(0,i)),a.startsWith("DLC2"))h=0;else{if(a.startsWith("DLS2")){let e;try{let t=a.substring(4);t=atob(t),e=JSON.parse(t)}catch(t){throw new Error("Format Error: The license string you specified is invalid, please check to make sure it is correct.")}if(a=e.handshakeCode?e.handshakeCode:e.organizationID?e.organizationID:"","number"==typeof a&&(a=JSON.stringify(a)),0===o.length){let t=[];e.mainServerURL&&(t[0]=e.mainServerURL),e.standbyServerURL&&(t[1]=e.standbyServerURL),o=Ut(t)}!l&&e.sessionPassword&&(l=e.sessionPassword),n=e.remark}a&&"200001"!==a&&!a.startsWith("200001-")||(h=1)}}if(h&&(e||(Lt.crypto||(s="Please upgrade your browser to support online key."),Lt.crypto.subtle||(s="Require https to use online key in this browser."))),s)throw new Error(s);return 1===h&&(a="",console.warn("Applying for a public trial license ...")),{lt:h,l:a,ls:o,sp:l,rmk:n,cv:r}}throw new Error("Can't preprocess license again"+Bt)})(),a=new Nt;Kt._pLoad.task=a,(async()=>{try{await Kt._pLoad}catch(t){}})();let o=ot();lt[o]=e=>{if(e.message&&Kt._onAuthMessage){let t=Kt._onAuthMessage(e.message);null!=t&&(e.message=t)}let i,n=!1;if(1===t&&(n=!0),e.success?(ht&&ht("init license success"),e.message&&console.warn(e.message),vt._bSupportIRTModule=e.bSupportIRTModule,vt._bSupportDce4Module=e.bSupportDce4Module,Kt.bPassValidation=!0,[0,-10076].includes(e.initLicenseInfo.errorCode)?[-10076].includes(e.initLicenseInfo.errorCode)&&console.warn(e.initLicenseInfo.errorString):a.reject(new Error(e.initLicenseInfo.errorString))):(i=Error(e.message),e.stack&&(i.stack=e.stack),e.ltsErrorCode&&(i.ltsErrorCode=e.ltsErrorCode),n||111==e.ltsErrorCode&&-1!=e.message.toLowerCase().indexOf("trial license")&&(n=!0)),n){const t=L(vt.engineResourcePaths);(async(t,e,i)=>{if(!t._bNeverShowDialog)try{let n=await fetch(t.engineResourcePath+"dls.license.dialog.html");if(!n.ok)throw Error("Get license dialog fail. Network Error: "+n.statusText);let r=await n.text();if(!r.trim().startsWith("<"))throw Error("Get license dialog fail. Can't get valid HTMLElement.");let s=document.createElement("div");s.innerHTML=r;let a=[];for(let t=0;t{if(t==e.target){o.remove();for(let t of a)t.remove()}}));else if(!h&&t.classList.contains("dls-license-icon-close"))h=t,t.addEventListener("click",(()=>{o.remove();for(let t of a)t.remove()}));else if(!c&&t.classList.contains("dls-license-icon-error"))c=t,"error"!=e&&t.remove();else if(!d&&t.classList.contains("dls-license-icon-warn"))d=t,"warn"!=e&&t.remove();else if(!u&&t.classList.contains("dls-license-msg-content")){u=t;let e=i;for(;e;){let i=e.indexOf("["),n=e.indexOf("]",i),r=e.indexOf("(",n),s=e.indexOf(")",r);if(-1==i||-1==n||-1==r||-1==s){t.appendChild(new Text(e));break}i>0&&t.appendChild(new Text(e.substring(0,i)));let a=document.createElement("a"),o=e.substring(i+1,n);a.innerText=o;let l=e.substring(r+1,s);a.setAttribute("href",l),a.setAttribute("target","_blank"),t.appendChild(a),e=e.substring(s+1)}}document.body.appendChild(o)}catch(e){t._onLog&&t._onLog(e.message||e)}})({_bNeverShowDialog:Kt._bNeverShowDialog,engineResourcePath:t.license,_onLog:ht},e.success?"warn":"error",e.message)}e.success?a.resolve(void 0):a.reject(i)},await nt("core"),st.postMessage({type:"license_dynamsoft",body:{v:"3.4.31",brtk:!!t,bptk:1===t,l:e,os:Zt,fn:Kt.deviceFriendlyName,ls:i,sp:n,rmk:r,cv:s},id:o}),Kt.bCallInitLicense=!0,await a})));let Jt;gt.license={},gt.license.dynamsoft=qt,gt.license.getAR=async()=>{{let t=it.dynamsoft_inited;t&&t.isRejected&&await t}return st?new Promise(((t,e)=>{let i=ot();lt[i]=async i=>{if(i.success){delete i.success;{let t=Kt.license;t&&(t.startsWith("t")||t.startsWith("f"))&&(i.pk=t)}if(Object.keys(i).length){if(i.lem){let t=Error(i.lem);t.ltsErrorCode=i.lec,delete i.lem,delete i.lec,i.ae=t}t(i)}else t(null)}else{let t=Error(i.message);i.stack&&(t.stack=i.stack),e(t)}},st.postMessage({type:"license_getAR",id:i})})):null};let Kt=class t{static setLicenseServer(e){Gt(t,e)}static get license(){return this._license}static set license(e){Vt(t,e)}static get licenseServer(){return this._licenseServer}static set licenseServer(e){Gt(t,e)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(e){Wt(t,e)}static initLicense(e,i){if(Vt(t,e),t.bCallInitLicense=!0,"boolean"==typeof i&&i||"object"==typeof i&&i.executeNow)return qt()}static setDeviceFriendlyName(e){Wt(t,e)}static getDeviceFriendlyName(){return t._deviceFriendlyName}static getDeviceUUID(){return(async()=>(await rt("dynamsoft_uuid",(async()=>{await _t();let t=new Nt,e=ot();lt[e]=e=>{if(e.success)t.resolve(e.uuid);else{const i=Error(e.message);e.stack&&(i.stack=e.stack),t.reject(i)}},st.postMessage({type:"license_getDeviceUUID",id:e}),Jt=await t})),Jt))()}};Kt._pLoad=new Nt,Kt.bPassValidation=!1,Kt.bCallInitLicense=!1,Kt._license=jt,Kt._licenseServer=[],Kt._deviceFriendlyName="",vt.engineResourcePaths.license={version:"3.4.31",path:Ft,isInternal:!0},mt.license={wasm:!0,js:!0},gt.license.LicenseManager=Kt;const $t="1.4.21";"string"!=typeof vt.engineResourcePaths.std&&D(vt.engineResourcePaths.std.version,$t)<0&&(vt.engineResourcePaths.std={version:$t,path:(t=>{if(null==t&&(t="./"),Dt||Mt);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(Ft+`../../dynamsoft-capture-vision-std@${$t}/dist/`),isInternal:!0});let Qt=class{static getVersion(){return`3.4.31(Worker: ${ft.license&&ft.license.worker||"Not Loaded"}, Wasm: ${ft.license&&ft.license.wasm||"Not Loaded"})`}};function te(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 ee(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 ie=t=>t&&"object"==typeof t&&"function"==typeof t.then,ne=(async()=>{})().constructor;class re extends ne{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,ie(t)?e=t:"function"==typeof t&&(e=new ne(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&&(ie(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}}class se{constructor(t){this._cvr=t}async getMaxBufferedItems(){return await new Promise(((t,e)=>{let i=ot();lt[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)}},st.postMessage({type:"cvr_getMaxBufferedItems",id:i,instanceID:this._cvr._instanceID})}))}async setMaxBufferedItems(t){return await new Promise(((e,i)=>{let n=ot();lt[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},st.postMessage({type:"cvr_setMaxBufferedItems",id:n,instanceID:this._cvr._instanceID,body:{count:t}})}))}async getBufferedCharacterItemSet(){return await new Promise(((t,e)=>{let i=ot();lt[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)}},st.postMessage({type:"cvr_getBufferedCharacterItemSet",id:i,instanceID:this._cvr._instanceID})}))}}var ae={onTaskResultsReceived:!1,onTaskResultsReceivedForDce:!1,onPredetectedRegionsReceived:!1,onLocalizedBarcodesReceived:!1,onDecodedBarcodesReceived:!1,onLocalizedTextLinesReceived:!1,onRecognizedTextLinesReceived:!1,onDetectedQuadsReceived:!1,onNormalizedImagesReceived:!1,onColourImageUnitReceived:!1,onScaledDownColourImageUnitReceived:!1,onGrayscaleImageUnitReceived:!1,onTransformedGrayscaleImageUnitReceived:!1,onEnhancedGrayscaleImageUnitReceived:!1,onBinaryImageUnitReceived:!1,onTextureDetectionResultUnitReceived:!1,onTextureRemovedGrayscaleImageUnitReceived:!1,onTextureRemovedBinaryImageUnitReceived:!1,onContoursUnitReceived:!1,onLineSegmentsUnitReceived:!1,onTextZonesUnitReceived:!1,onTextRemovedBinaryImageUnitReceived:!1,onRawTextLinesReceived:!1,onLongLinesUnitReceived:!1,onCornersUnitReceived:!1,onCandidateQuadEdgesUnitReceived:!1,onCandidateBarcodeZonesUnitReceived:!1,onScaledUpBarcodeImageUnitReceived:!1,onDeformationResistedBarcodeImageUnitReceived:!1,onComplementedBarcodeImageUnitReceived:!1,onShortLinesUnitReceived:!1,onLogicLinesReceived:!1};const oe=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 le{constructor(t){this._irrRegistryState=ae,this._intermediateResultReceiverSet=new Set,this._cvr=t}async addResultReceiver(t){if("object"!=typeof t)throw new Error("Invalid receiver.");this._intermediateResultReceiverSet.add(t),oe(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=ot();lt[r]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,n(t)}},st.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),oe(this),await new Promise(((t,e)=>{let i=ot();lt[i]=async i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},st.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})}))}getOriginalImage(){return this._cvr._dsImage}}const he="undefined"==typeof self,ce="function"==typeof importScripts,de=(()=>{if(!ce){if(!he&&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"./"}})(),ue=t=>{if(null==t&&(t="./"),he||ce);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};var fe;vt.engineResourcePaths.cvr={version:"2.4.33",path:de,isInternal:!0},mt.cvr={js:!0,wasm:!0,deps:["license","dip"]},gt.cvr={};const ge="1.4.21";"string"!=typeof vt.engineResourcePaths.std&&D(vt.engineResourcePaths.std.version,ge)<0&&(vt.engineResourcePaths.std={version:ge,path:ue(de+`../../dynamsoft-capture-vision-std@${ge}/dist/`),isInternal:!0});const me="2.4.31";(!vt.engineResourcePaths.dip||"string"!=typeof vt.engineResourcePaths.dip&&D(vt.engineResourcePaths.dip.version,me)<0)&&(vt.engineResourcePaths.dip={version:me,path:ue(de+`../../dynamsoft-image-processing@${me}/dist/`),isInternal:!0});class pe{static getVersion(){return this._version}}pe._version=`2.4.33(Worker: ${null===(fe=ft.cvr)||void 0===fe?void 0:fe.worker}, Wasm: loading...`;const _e={barcodeResultItems:{type:yt.CRIT_BARCODE,reveiver:"onDecodedBarcodesReceived",isNeedFilter:!0},textLineResultItems:{type:yt.CRIT_TEXT_LINE,reveiver:"onRecognizedTextLinesReceived",isNeedFilter:!0},detectedQuadResultItems:{type:yt.CRIT_DETECTED_QUAD,reveiver:"onDetectedQuadsReceived",isNeedFilter:!1},normalizedImageResultItems:{type:yt.CRIT_NORMALIZED_IMAGE,reveiver:"onNormalizedImagesReceived",isNeedFilter:!1},parsedResultItems:{type:yt.CRIT_PARSED_RESULT,reveiver:"onParsedResultsReceived",isNeedFilter:!1}};var ve,ye,we,Ce,Ee,Se,be,Te,Ie,xe,Oe,Ae,Re;function De(t,e){if(t&&t.location){const i=t.location.points;for(let t of i)t.x=t.x/e,t.y=t.y/e;De(t.referencedItem,e)}}function Le(t){if(t.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}!function(t){t[t.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",t[t.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}(ve||(ve={}));const Me={onTaskResultsReceived:()=>{},isFilter:!0};class Fe{constructor(){this.maxImageSideLength=["iPhone","Android","HarmonyOS"].includes(vt.browserInfo.OS)?2048:4096,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,ye.set(this,null),we.set(this,null),Ce.set(this,null),Ee.set(this,null),Se.set(this,null),be.set(this,new Set),Te.set(this,new Set),Ie.set(this,new Set),xe.set(this,0),Oe.set(this,!1),Ae.set(this,!1),Re.set(this,!1),this._singleFrameModeCallbackBind=this._singleFrameModeCallback.bind(this)}get disposed(){return te(this,Re,"f")}static async createInstance(){if(!gt.license)throw Error("Module `license` is not existed.");await gt.license.dynamsoft(),await _t(["cvr"]);const t=new Fe,e=new re;let i=ot();return lt[i]=async i=>{var n;if(i.success)t._instanceID=i.instanceID,t._currentSettings=JSON.parse(JSON.parse(i.outputSettings).data),pe._version=`2.4.33(Worker: ${null===(n=ft.cvr)||void 0===n?void 0:n.worker}, Wasm: ${i.version})`,ee(t,Ae,!0),ee(t,Ee,t.getIntermediateResultManager()),ee(t,Ae,!1),e.resolve(t);else{const t=Error(i.message);i.stack&&(t.stack=i.stack),e.reject(t)}},st.postMessage({type:"cvr_createInstance",id:i}),e}async _singleFrameModeCallback(t){for(let e of te(this,be,"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;const n={originalImageHashId:i.originalImageHashId,originalImageTag:i.originalImageTag,errorCode:i.errorCode,errorString:i.errorString};for(let t of te(this,be,"f"))if(t.isDce)t.onCapturedResultReceived(i,{isDetectVerifyOpen:!1,isNormalizeVerifyOpen:!1,isBarcodeVerifyOpen:!1,isLabelVerifyOpen:!1});else{for(let e in _e){const r=e,s=_e[r];t[s.reveiver]&&i[r]&&t[s.reveiver](Object.assign(Object.assign({},n),{[r]:i[r]}))}t.onCapturedResultReceived&&t.onCapturedResultReceived(i)}}setInput(t){if(Le(this),t){if(ee(this,ye,t),t.isCameraEnhancer){te(this,Ee,"f")&&(te(this,ye,"f")._intermediateResultReceiver.isDce=!0,te(this,Ee,"f").addResultReceiver(te(this,ye,"f")._intermediateResultReceiver));const t=te(this,ye,"f").getCameraView();if(t){const e=t._capturedResultReceiver;e.isDce=!0,te(this,be,"f").add(e)}}}else ee(this,ye,null)}getInput(){return te(this,ye,"f")}addImageSourceStateListener(t){if(Le(this),"object"!=typeof t)return console.warn("Invalid ISA state listener.");t&&Object.keys(t)&&te(this,Te,"f").add(t)}removeImageSourceStateListener(t){return Le(this),te(this,Te,"f").delete(t)}addResultReceiver(t){if(Le(this),"object"!=typeof t)throw new Error("Invalid receiver.");t&&Object.keys(t).length&&(te(this,be,"f").add(t),this._setCrrRegistry())}removeResultReceiver(t){Le(this),te(this,be,"f").delete(t),this._setCrrRegistry()}async _setCrrRegistry(){const t={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onDetectedQuadsReceived:!1,onNormalizedImagesReceived:!1,onParsedResultsReceived:!1};for(let e of te(this,be,"f"))e.isDce||(t.onCapturedResultReceived=!!e.onCapturedResultReceived,t.onDecodedBarcodesReceived=!!e.onDecodedBarcodesReceived,t.onRecognizedTextLinesReceived=!!e.onRecognizedTextLinesReceived,t.onDetectedQuadsReceived=!!e.onDetectedQuadsReceived,t.onNormalizedImagesReceived=!!e.onNormalizedImagesReceived,t.onParsedResultsReceived=!!e.onParsedResultsReceived);const e=new re;let i=ot();return lt[i]=async t=>{if(t.success)e.resolve();else{let i=new Error(t.message);i.stack=t.stack+"\n"+i.stack,e.reject()}},st.postMessage({type:"cvr_setCrrRegistry",id:i,instanceID:this._instanceID,body:{receiver:JSON.stringify(t)}}),e}async addResultFilter(t){if(Le(this),!t||"object"!=typeof t||!Object.keys(t).length)return console.warn("Invalid filter.");te(this,Ie,"f").add(t),t._dynamsoft(),await this._handleFilterUpdate()}async removeResultFilter(t){Le(this),te(this,Ie,"f").delete(t),await this._handleFilterUpdate()}async _handleFilterUpdate(){if(te(this,Ee,"f").removeResultReceiver(Me),0===te(this,Ie,"f").size){this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1;const t={[yt.CRIT_BARCODE]:!1,[yt.CRIT_TEXT_LINE]:!1,[yt.CRIT_DETECTED_QUAD]:!1,[yt.CRIT_NORMALIZED_IMAGE]:!1},e={[yt.CRIT_BARCODE]:!1,[yt.CRIT_TEXT_LINE]:!1,[yt.CRIT_DETECTED_QUAD]:!1,[yt.CRIT_NORMALIZED_IMAGE]:!1};return await Pe(this,t),void await ke(this,e)}for(let t of te(this,Ie,"f")){if(this._isOpenBarcodeVerify=t.isResultCrossVerificationEnabled(yt.CRIT_BARCODE),this._isOpenLabelVerify=t.isResultCrossVerificationEnabled(yt.CRIT_TEXT_LINE),this._isOpenDetectVerify=t.isResultCrossVerificationEnabled(yt.CRIT_DETECTED_QUAD),this._isOpenNormalizeVerify=t.isResultCrossVerificationEnabled(yt.CRIT_NORMALIZED_IMAGE),t.isLatestOverlappingEnabled(yt.CRIT_BARCODE)){[...te(this,Ee,"f")._intermediateResultReceiverSet.values()].find((t=>t.isFilter))||te(this,Ee,"f").addResultReceiver(Me)}await Pe(this,t.verificationEnabled),await ke(this,t.duplicateFilterEnabled),await Ne(this,t.duplicateForgetTime)}}async startCapturing(t){var e,i;if(Le(this),!this._isPauseScan)return;if(!te(this,ye,"f"))throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");t||(t=Fe._defaultTemplate);const n=await this.containsTask(t);await _t(n);for(let t of te(this,Ie,"f"))await this.addResultFilter(t);if(n.includes("dlr")&&!(null===(e=gt.dlr)||void 0===e?void 0:e.bLoadConfusableCharsData)){const t=L(vt.engineResourcePaths);await(null===(i=gt.dlr)||void 0===i?void 0:i.loadRecognitionData("ConfusableChars",t.dlr))}if(te(this,ye,"f").isCameraEnhancer&&(n.includes("ddn")?te(this,ye,"f").setPixelFormat(o.IPF_ABGR_8888):te(this,ye,"f").setPixelFormat(o.IPF_GRAYSCALED)),void 0!==te(this,ye,"f").singleFrameMode&&"disabled"!==te(this,ye,"f").singleFrameMode)return this._templateName=t,void te(this,ye,"f").on("singleFrameAcquired",this._singleFrameModeCallbackBind);return te(this,ye,"f").getColourChannelUsageType()===a.CCUT_AUTO&&te(this,ye,"f").setColourChannelUsageType(n.includes("ddn")?a.CCUT_FULL_CHANNEL:a.CCUT_Y_CHANNEL_ONLY),te(this,Ce,"f")&&te(this,Ce,"f").isPending?te(this,Ce,"f"):(ee(this,Ce,new re(((e,i)=>{if(this.disposed)return;let n=ot();lt[n]=async n=>{if(te(this,Ce,"f")&&!te(this,Ce,"f").isFulfilled){if(!n.success){let t=new Error(n.message);return t.stack=n.stack+"\n"+t.stack,i(t)}this._isPauseScan=!1,this._isOutputOriginalImage=n.isOutputOriginalImage,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((async()=>{-1!==this._minImageCaptureInterval&&te(this,ye,"f").startFetching(),this._loopReadVideo(t),e()}),0)}},st.postMessage({type:"cvr_startCapturing",id:n,instanceID:this._instanceID,body:{templateName:t}})}))),await te(this,Ce,"f"))}stopCapturing(){Le(this),te(this,ye,"f")&&(te(this,ye,"f").isCameraEnhancer&&void 0!==te(this,ye,"f").singleFrameMode&&"disabled"!==te(this,ye,"f").singleFrameMode?te(this,ye,"f").off("singleFrameAcquired",this._singleFrameModeCallbackBind):(!async function(t){let e=ot();const i=new re;lt[e]=async t=>{if(t.success)return i.resolve();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i.reject(e)}},st.postMessage({type:"cvr_clearVerifyList",id:e,instanceID:t._instanceID})}(this),te(this,ye,"f").stopFetching(),this._averageProcessintTimeArray=[],this._averageTime=999,this._isPauseScan=!0,ee(this,Ce,null),te(this,ye,"f").setColourChannelUsageType(a.CCUT_AUTO)))}async containsTask(t){return Le(this),await new Promise(((e,i)=>{let n=ot();lt[n]=async t=>{if(t.success)return e(JSON.parse(t.tasks));{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},st.postMessage({type:"cvr_containsTask",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async _loopReadVideo(t){if(this.disposed||this._isPauseScan)return;if(ee(this,Oe,!0),te(this,ye,"f").isBufferEmpty())if(te(this,ye,"f").hasNextImageToFetch())for(let t of te(this,Te,"f"))t.onImageSourceStateReceived&&t.onImageSourceStateReceived(ve.ISS_BUFFER_EMPTY);else if(!te(this,ye,"f").hasNextImageToFetch())for(let t of te(this,Te,"f"))t.onImageSourceStateReceived&&t.onImageSourceStateReceived(ve.ISS_EXHAUSTED);if(-1===this._minImageCaptureInterval||te(this,ye,"f").isBufferEmpty())try{te(this,ye,"f").isBufferEmpty()&&Fe._onLog&&Fe._onLog("buffer is empty so fetch image"),Fe._onLog&&Fe._onLog(`DCE: start fetching a frame: ${Date.now()}`),this._dsImage=te(this,ye,"f").fetchImage(),Fe._onLog&&Fe._onLog(`DCE: finish fetching a frame: ${Date.now()}`),te(this,ye,"f").setImageFetchInterval(this._averageTime)}catch(e){return void this._reRunCurrnetFunc(t)}else if(te(this,ye,"f").setImageFetchInterval(this._averageTime-(this._dsImage&&this._dsImage.tag?this._dsImage.tag.timeSpent:0)),this._dsImage=te(this,ye,"f").getImage(),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 te(this,be,"f"))this._isOutputOriginalImage&&t.onOriginalImageResultReceived&&t.onOriginalImageResultReceived({imageData:this._dsImage});const e=Date.now();this._captureDsimage(this._dsImage,t).then((async i=>{if(Fe._onLog&&Fe._onLog("no js handle time: "+(Date.now()-e)),this._isPauseScan)return void this._reRunCurrnetFunc(t);i.originalImageTag=this._dsImage.tag?this._dsImage.tag:null;const n={originalImageHashId:i.originalImageHashId,originalImageTag:i.originalImageTag,errorCode:i.errorCode,errorString:i.errorString};for(let t of te(this,be,"f"))if(t.isDce){const e=Date.now();if(t.onCapturedResultReceived(i,{isDetectVerifyOpen:this._isOpenDetectVerify,isNormalizeVerifyOpen:this._isOpenNormalizeVerify,isBarcodeVerifyOpen:this._isOpenBarcodeVerify,isLabelVerifyOpen:this._isOpenLabelVerify}),Fe._onLog){const t=Date.now()-e;t>10&&Fe._onLog(`draw result time: ${t}`)}}else{for(let e in _e){const r=e,s=_e[r];t[s.reveiver],t[s.reveiver]&&i[r]&&t[s.reveiver](Object.assign(Object.assign({},n),{[r]:i[r].filter((t=>!s.isNeedFilter||!t.isFilter))})),i[r]&&(i[r]=i[r].filter((t=>!s.isNeedFilter||!t.isFilter)))}t.onCapturedResultReceived&&(i.items=i.items.filter((t=>[yt.CRIT_DETECTED_QUAD,yt.CRIT_NORMALIZED_IMAGE].includes(t.type)||!t.isFilter)),t.onCapturedResultReceived(i))}const r=Date.now();if(this._minImageCaptureInterval>-1&&(5===this._averageProcessintTimeArray.length&&this._averageProcessintTimeArray.shift(),5===this._averageFetchImageTimeArray.length&&this._averageFetchImageTimeArray.shift(),this._averageProcessintTimeArray.push(Date.now()-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,Fe._onLog&&(Fe._onLog(`minImageCaptureInterval: ${this._minImageCaptureInterval}`),Fe._onLog(`averageProcessintTimeArray: ${this._averageProcessintTimeArray}`),Fe._onLog(`averageFetchImageTimeArray: ${this._averageFetchImageTimeArray}`),Fe._onLog(`averageTime: ${this._averageTime}`))),Fe._onLog){const t=Date.now()-r;t>10&&Fe._onLog(`fetch image calculate time: ${t}`)}Fe._onLog&&Fe._onLog(`time finish decode: ${Date.now()}`),Fe._onLog&&Fe._onLog("main time: "+(Date.now()-e)),Fe._onLog&&Fe._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=>{te(this,ye,"f").stopFetching(),e.errorCode&&0===e.errorCode&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{te(this,ye,"f").startFetching(),this._loopReadVideo(t)}),Math.max(this._minImageCaptureInterval,1e3))),"platform error"!==e.message&&setTimeout((()=>{throw e}),0)}))}_reRunCurrnetFunc(t){this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo(t)}),0)}async capture(t,e){var i,n;Le(this),e||(e=Fe._defaultTemplate);const r=await this.containsTask(e);if(await _t(r),r.includes("dlr")&&!(null===(i=gt.dlr)||void 0===i?void 0:i.bLoadConfusableCharsData)){const t=L(vt.engineResourcePaths);await(null===(n=gt.dlr)||void 0===n?void 0:n.loadRecognitionData("ConfusableChars",t.dlr))}let s;if(ee(this,Oe,!1),C(t))s=await this._captureDsimage(t,e);else if("string"==typeof t)s="data:image/"==t.substring(0,11)?await this._captureBase64(t,e):await this._captureUrl(t,e);else if(t instanceof Blob)s=await this._captureBlob(t,e);else if(t instanceof HTMLImageElement)s=await this._captureImage(t,e);else if(t instanceof HTMLCanvasElement)s=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'.");s=await this._captureVideo(t,e)}return s}async _captureDsimage(t,e){return await this._captureInWorker(t,e)}async _captureUrl(t,e){let i=await A(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?(ee(this,xe,this.maxImageSideLength/a),i=Math.round(r*te(this,xe,"f")),n=Math.round(s*te(this,xe,"f"))):(i=r,n=s),te(this,we,"f")||ee(this,we,document.createElement("canvas"));const o=te(this,we,"f");o.width===i&&o.height===n||(o.width=i,o.height=n),o.ctx2d||(o.ctx2d=o.getContext("2d",{willReadFrequently:!0}));return 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:10};return await this._captureInWorker(n,e)}async _captureVideo(t,e){if(t.crossOrigin&&"anonymous"!=t.crossOrigin)throw"cors";let i,n,r=t.videoWidth,s=t.videoHeight,a=Math.max(r,s);a>this.maxImageSideLength?(ee(this,xe,this.maxImageSideLength/a),i=Math.round(r*te(this,xe,"f")),n=Math.round(s*te(this,xe,"f"))):(i=r,n=s),te(this,we,"f")||ee(this,we,document.createElement("canvas"));const o=te(this,we,"f");o.width===i&&o.height===n||(o.width=i,o.height=n),o.ctx2d||(o.ctx2d=o.getContext("2d",{willReadFrequently:!0}));return o.ctx2d.drawImage(t,0,0,r,s,0,0,i,n),await this._captureCanvas(o,e)}async _captureInWorker(t,e){const{bytes:i,width:n,height:r,stride:s,format:a}=t;let o=ot();const l=new re;return lt[o]=async e=>{var i,n;if(!e.success){let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,l.reject(t)}{const r=Date.now();Fe._onLog&&(Fe._onLog(`get result time from worker: ${r}`),Fe._onLog("worker to main time consume: "+(r-e.workerReturnMsgTime)));try{const r=e.captureResult;if(0!==r.errorCode){let t=new Error(r.errorString);return t.errorCode=r.errorCode,l.reject(t)}t.bytes=e.bytes;for(let e of r.items)0!==te(this,xe,"f")&&De(e,te(this,xe,"f")),e.type===yt.CRIT_ORIGINAL_IMAGE?e.imageData=t:e.type===yt.CRIT_NORMALIZED_IMAGE?null===(i=gt.ddn)||void 0===i||i.handleNormalizedImageResultItem(e):e.type===yt.CRIT_PARSED_RESULT&&(null===(n=gt.dcp)||void 0===n||n.handleParsedResultItem(e));if(te(this,Oe,"f"))for(let t of te(this,Ie,"f"))t.onDecodedBarcodesReceived(r),t.onRecognizedTextLinesReceived(r),t.onDetectedQuadsReceived(r),t.onNormalizedImagesReceived(r);for(let t in _e){const e=t,i=r.items.filter((t=>t.type===_e[e].type));i.length&&(r[t]=i)}if(!this._isPauseScan||!te(this,Oe,"f")){const e=r.intermediateResult;if(e){let i=0;for(let n of te(this,Ee,"f")._intermediateResultReceiverSet){i++;for(let r of e){if("onTaskResultsReceived"===r.info.callbackName){for(let e of r.intermediateResultUnits)e.originalImageTag=t.tag?t.tag:null;n[r.info.callbackName]&&n[r.info.callbackName]({intermediateResultUnits:r.intermediateResultUnits},r.info)}else n[r.info.callbackName]&&n[r.info.callbackName](r.result,r.info);i===te(this,Ee,"f")._intermediateResultReceiverSet.size&&delete r.info.callbackName}}}}return r&&r.hasOwnProperty("intermediateResult")&&delete r.intermediateResult,ee(this,xe,0),l.resolve(r)}catch(t){return l.reject(t)}}},Fe._onLog&&Fe._onLog(`send buffer to worker: ${Date.now()}`),st.postMessage({type:"cvr_capture",id:o,instanceID:this._instanceID,body:{bytes:i,width:n,height:r,stride:s,format:a,templateName:e||"",isScanner:te(this,Oe,"f")}},[i.buffer]),l}async initSettings(t){return Le(this),t&&["string","object"].includes(typeof t)?("string"==typeof t?t.trimStart().startsWith("{")||(t=await A(t,"text")):"object"==typeof t&&(t=JSON.stringify(t)),await new Promise(((e,i)=>{let n=ot();lt[n]=async n=>{if(n.success){const r=JSON.parse(n.response);if(0!==r.errorCode){let t=new Error(r.errorString?r.errorString:"Init Settings Failed.");return t.errorCode=r.errorCode,i(t)}const s=JSON.parse(t);this._currentSettings=s;let a=[],o=s.CaptureVisionTemplates;for(let t=0;t{let n=ot();lt[n]=async t=>{if(t.success){const n=JSON.parse(t.response);if(0!==n.errorCode){let t=new Error(n.errorString);return t.errorCode=n.errorCode,i(t)}return e(JSON.parse(n.data))}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},st.postMessage({type:"cvr_outputSettings",id:n,instanceID:this._instanceID,body:{templateName:t||"*"}})}))}async outputSettingsToFile(t,e,i){const n=await this.outputSettings(t),r=new Blob([JSON.stringify(n,null,2,(function(t,e){return e instanceof Array?JSON.stringify(e):e}),2)],{type:"application/json"});if(i){const t=document.createElement("a");t.href=URL.createObjectURL(r),e.endsWith(".json")&&(e=e.replace(".json","")),t.download=`${e}.json`,t.onclick=()=>{setTimeout((()=>{URL.revokeObjectURL(t.href)}),500)},t.click()}return r}async getTemplateNames(){return Le(this),await new Promise(((t,e)=>{let i=ot();lt[i]=async i=>{if(i.success){const n=JSON.parse(i.response);if(0!==n.errorCode){let t=new Error(n.errorString);return t.errorCode=n.errorCode,e(t)}return t(JSON.parse(n.data))}{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},st.postMessage({type:"cvr_getTemplateNames",id:i,instanceID:this._instanceID})}))}async getSimplifiedSettings(t){Le(this),t||(t=this._currentSettings.CaptureVisionTemplates[0].Name);const e=await this.containsTask(t);return await _t(e),await new Promise(((e,i)=>{let n=ot();lt[n]=async t=>{if(t.success){const n=JSON.parse(t.response);if(0!==n.errorCode){let t=new Error(n.errorString);return t.errorCode=n.errorCode,i(t)}const r=JSON.parse(n.data,((t,e)=>"barcodeFormatIds"===t?BigInt(e):e));return r.minImageCaptureInterval=this._minImageCaptureInterval,e(r)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},st.postMessage({type:"cvr_getSimplifiedSettings",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async updateSettings(t,e){Le(this);const i=await this.containsTask(t);return await _t(i),await new Promise(((i,n)=>{let r=ot();lt[r]=async t=>{if(t.success){const r=JSON.parse(t.response);if(e.minImageCaptureInterval&&e.minImageCaptureInterval>=-1&&(this._minImageCaptureInterval=e.minImageCaptureInterval),this._isOutputOriginalImage=t.isOutputOriginalImage,0!==r.errorCode){let t=new Error(r.errorString?r.errorString:"Update Settings Failed.");return t.errorCode=r.errorCode,n(t)}return this._currentSettings=await this.outputSettings("*"),i(r)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},st.postMessage({type:"cvr_updateSettings",id:r,instanceID:this._instanceID,body:{settings:e,templateName:t}})}))}async resetSettings(){return Le(this),await new Promise(((t,e)=>{let i=ot();lt[i]=async i=>{if(i.success){const n=JSON.parse(i.response);if(0!==n.errorCode){let t=new Error(n.errorString?n.errorString:"Reset Settings Failed.");return t.errorCode=n.errorCode,e(t)}return this._currentSettings=await this.outputSettings("*"),t(n)}{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},st.postMessage({type:"cvr_resetSettings",id:i,instanceID:this._instanceID})}))}getBufferedItemsManager(){return te(this,Se,"f")||ee(this,Se,new se(this)),te(this,Se,"f")}getIntermediateResultManager(){if(Le(this),!te(this,Ae,"f")&&0!==vt.bSupportIRTModule)throw new Error("The current license does not support the use of intermediate results.");return te(this,Ee,"f")||ee(this,Ee,new le(this)),te(this,Ee,"f")}async parseRequiredResources(t){return Le(this),await new Promise(((e,i)=>{let n=ot();lt[n]=async t=>{if(t.success)return e(JSON.parse(t.resources));{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},st.postMessage({type:"cvr_parseRequiredResources",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async dispose(){Le(this),te(this,Ce,"f")&&this.stopCapturing(),ee(this,ye,null),te(this,be,"f").clear(),te(this,Te,"f").clear(),te(this,Ie,"f").clear(),te(this,Ee,"f")._intermediateResultReceiverSet.clear(),ee(this,Re,!0);let t=ot();lt[t]=t=>{if(!t.success){let e=new Error(t.message);throw e.stack=t.stack+"\n"+e.stack,e}},st.postMessage({type:"cvr_dispose",id:t,instanceID:this._instanceID})}_getInternalData(){return{isa:te(this,ye,"f"),promiseStartScan:te(this,Ce,"f"),intermediateResultManager:te(this,Ee,"f"),bufferdItemsManager:te(this,Se,"f"),resultReceiverSet:te(this,be,"f"),isaStateListenerSet:te(this,Te,"f"),resultFilterSet:te(this,Ie,"f"),compressRate:te(this,xe,"f"),canvas:te(this,we,"f"),isScanner:te(this,Oe,"f"),innerUseTag:te(this,Ae,"f"),isDestroyed:te(this,Re,"f")}}async _getWasmFilterState(){return await new Promise(((t,e)=>{let i=ot();lt[i]=async i=>{if(i.success){const e=JSON.parse(i.response);return t(e)}{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},st.postMessage({type:"cvr_getWasmFilterState",id:i,instanceID:this._instanceID})}))}}async function Pe(t,e){return Le(t),await new Promise(((i,n)=>{let r=ot();lt[r]=async t=>{if(t.success)return i(t.result);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},st.postMessage({type:"cvr_enableResultCrossVerification",id:r,instanceID:t._instanceID,body:{verificationEnabled:e}})}))}async function ke(t,e){return Le(t),await new Promise(((i,n)=>{let r=ot();lt[r]=async t=>{if(t.success)return i(t.result);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},st.postMessage({type:"cvr_enableResultDeduplication",id:r,instanceID:t._instanceID,body:{duplicateFilterEnabled:e}})}))}async function Ne(t,e){return Le(t),await new Promise(((i,n)=>{let r=ot();lt[r]=async t=>{if(t.success)return i(t.result);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},st.postMessage({type:"cvr_setDuplicateForgetTime",id:r,instanceID:t._instanceID,body:{duplicateForgetTime:e}})}))}ye=new WeakMap,we=new WeakMap,Ce=new WeakMap,Ee=new WeakMap,Se=new WeakMap,be=new WeakMap,Te=new WeakMap,Ie=new WeakMap,xe=new WeakMap,Oe=new WeakMap,Ae=new WeakMap,Re=new WeakMap,Fe._defaultTemplate="Default";class Be{constructor(){this.onCapturedResultReceived=null,this.onOriginalImageResultReceived=null}}class je{constructor(){this._observedResultUnitTypes=Ot.IRUT_ALL,this._observedTaskMap=new Map,this._parameters={setObservedResultUnitTypes:t=>{this._observedResultUnitTypes=t},getObservedResultUnitTypes:()=>this._observedResultUnitTypes,isResultUnitTypeObserved:t=>!!(t&this._observedResultUnitTypes),addObservedTask:t=>{this._observedTaskMap.set(t,!0)},removeObservedTask:t=>{this._observedTaskMap.set(t,!1)},isTaskObserved:t=>0===this._observedTaskMap.size||!!this._observedTaskMap.get(t)},this.onTaskResultsReceived=null,this.onPredetectedRegionsReceived=null,this.onColourImageUnitReceived=null,this.onScaledDownColourImageUnitReceived=null,this.onGrayscaleImageUnitReceived=null,this.onTransformedGrayscaleImageUnitReceived=null,this.onEnhancedGrayscaleImageUnitReceived=null,this.onBinaryImageUnitReceived=null,this.onTextureDetectionResultUnitReceived=null,this.onTextureRemovedGrayscaleImageUnitReceived=null,this.onTextureRemovedBinaryImageUnitReceived=null,this.onContoursUnitReceived=null,this.onLineSegmentsUnitReceived=null,this.onTextZonesUnitReceived=null,this.onTextRemovedBinaryImageUnitReceived=null,this.onShortLinesUnitReceived=null}getObservationParameters(){return this._parameters}}var Ve;!function(t){t.PT_DEFAULT="Default",t.PT_READ_BARCODES="ReadBarcodes_Default",t.PT_RECOGNIZE_TEXT_LINES="RecognizeTextLines_Default",t.PT_DETECT_DOCUMENT_BOUNDARIES="DetectDocumentBoundaries_Default",t.PT_DETECT_AND_NORMALIZE_DOCUMENT="DetectAndNormalizeDocument_Default",t.PT_NORMALIZE_DOCUMENT="NormalizeDocument_Default",t.PT_READ_BARCODES_SPEED_FIRST="ReadBarcodes_SpeedFirst",t.PT_READ_BARCODES_READ_RATE_FIRST="ReadBarcodes_ReadRateFirst",t.PT_READ_BARCODES_BALANCE="ReadBarcodes_Balance",t.PT_READ_SINGLE_BARCODE="ReadBarcodes_Balanced",t.PT_READ_DENSE_BARCODES="ReadDenseBarcodes",t.PT_READ_DISTANT_BARCODES="ReadDistantBarcodes",t.PT_RECOGNIZE_NUMBERS="RecognizeNumbers",t.PT_RECOGNIZE_LETTERS="RecognizeLetters",t.PT_RECOGNIZE_NUMBERS_AND_LETTERS="RecognizeNumbersAndLetters",t.PT_RECOGNIZE_NUMBERS_AND_UPPERCASE_LETTERS="RecognizeNumbersAndUppercaseLetters",t.PT_RECOGNIZE_UPPERCASE_LETTERS="RecognizeUppercaseLetters"}(Ve||(Ve={}));const Ue="undefined"==typeof self,Ge="function"==typeof importScripts,We=(()=>{if(!Ge){if(!Ue&&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"./"}})();vt.engineResourcePaths.dce={version:"4.1.1",path:We,isInternal:!0},mt.dce={wasm:!1,js:!1},gt.dce={};let Ye,ze,He,Xe,Ze,qe=class{static getVersion(){return"4.1.1"}};function Je(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 Ke(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 r?r.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError,"undefined"!=typeof navigator&&(Ye=navigator,ze=Ye.userAgent,He=Ye.platform,Xe=Ye.mediaDevices),function(){if(!Ue){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:Ye.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:He,search:"Win"},Mac:{str:He},Linux:{str:He}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||ze,a=r.search||e,o=r.verStr||ze,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||ze,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=ze.indexOf("Windows NT")&&(r="HarmonyOS"),Ze={browser:i,version:n,OS:r}}Ue&&(Ze={browser:"ssr",version:0,OS:"ssr"})}();const $e="undefined"!=typeof WebAssembly&&ze&&!(/Safari/.test(ze)&&!/Chrome/.test(ze)&&/\(.+\s11_2_([2-6]).*\)/.test(ze)),Qe=!("undefined"==typeof Worker),ti=!(!Xe||!Xe.getUserMedia),ei=async()=>{let t=!1;if(ti)try{(await Xe.getUserMedia({video:!0})).getTracks().forEach((t=>{t.stop()})),t=!0}catch(t){}return t};"Chrome"===Ze.browser&&Ze.version>66||"Safari"===Ze.browser&&Ze.version>13||"OPR"===Ze.browser&&Ze.version>43||"Edge"===Ze.browser&&Ze.version;var ii={653:(t,e,i)=>{var n,r,s,a,o,l,h,c,d,u,f,g,m,p,_,v,y,w,C,E,S,b=b||{version:"5.2.1"};if(e.fabric=b,"undefined"!=typeof document&&"undefined"!=typeof window)document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?b.document=document:b.document=document.implementation.createHTMLDocument(""),b.window=window;else{var T=new(i(192).JSDOM)(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;b.document=T.document,b.jsdomImplForWrapper=i(898).implForWrapper,b.nodeCanvas=i(245).Canvas,b.window=T,DOMParser=b.window.DOMParser}function I(t,e){var i=t.canvas,n=e.targetCanvas,r=n.getContext("2d");r.translate(0,n.height),r.scale(1,-1);var s=i.height-n.height;r.drawImage(i,0,s,n.width,n.height,0,0,n.width,n.height)}function x(t,e){var i=e.targetCanvas.getContext("2d"),n=e.destinationWidth,r=e.destinationHeight,s=n*r*4,a=new Uint8Array(this.imageBuffer,0,s),o=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,n,r,t.RGBA,t.UNSIGNED_BYTE,a);var l=new ImageData(o,n,r);i.putImageData(l,0,0)}b.isTouchSupported="ontouchstart"in b.window||"ontouchstart"in b.document||b.window&&b.window.navigator&&b.window.navigator.maxTouchPoints>0,b.isLikelyNode="undefined"!=typeof Buffer&&"undefined"==typeof window,b.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],b.DPI=96,b.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",b.commaWsp="(?:\\s+,?\\s*|,\\s*)",b.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,b.reNonWord=/[ \n\.,;!\?\-]/,b.fontPaths={},b.iMatrix=[1,0,0,1,0,0],b.svgNS="http://www.w3.org/2000/svg",b.perfLimitSizeTotal=2097152,b.maxCacheSideLimit=4096,b.minCacheSideLimit=256,b.charWidthsCache={},b.textureSize=2048,b.disableStyleCopyPaste=!1,b.enableGLFiltering=!0,b.devicePixelRatio=b.window.devicePixelRatio||b.window.webkitDevicePixelRatio||b.window.mozDevicePixelRatio||1,b.browserShadowBlurConstant=1,b.arcToSegmentsCache={},b.boundsOfCurveCache={},b.cachesBoundsOfCurve=!0,b.forceGLPutImageData=!1,b.initFilterBackend=function(){return b.enableGLFiltering&&b.isWebglSupported&&b.isWebglSupported(b.textureSize)?(console.log("max texture size: "+b.maxTextureSize),new b.WebglFilterBackend({tileSize:b.textureSize})):b.Canvas2dFilterBackend?new b.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=b),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:b.util.array.fill(i,!1)}}function e(t,e){var i=function(){e.apply(this,arguments),this.off(t,i)}.bind(this);this.on(t,i)}b.Observable={fire:function(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;for(var n=0,r=i.length;n-1||!!e&&this._objects.some((function(e){return"function"==typeof e.contains&&e.contains(t,!0)}))},complexity:function(){return this._objects.reduce((function(t,e){return t+(e.complexity?e.complexity():0)}),0)}},b.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof b.Gradient||this.set(e,new b.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof b.Pattern?i&&i():this.set(e,new b.Pattern(t,i))},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},n=e,r=Math.sqrt,s=Math.atan2,a=Math.pow,o=Math.PI/180,l=Math.PI/2,b.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/l){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},sin:function(t){if(0===t)return 0;var e=1;switch(t<0&&(e=-1),t/l){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)},removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*o},radiansToDegrees:function(t){return t/o},rotatePoint:function(t,e,i){var n=new b.Point(t.x-e.x,t.y-e.y),r=b.util.rotateVector(n,i);return new b.Point(r.x,r.y).addEquals(e)},rotateVector:function(t,e){var i=b.util.sin(e),n=b.util.cos(e);return{x:t.x*n-t.y*i,y:t.x*i+t.y*n}},createVector:function(t,e){return new b.Point(e.x-t.x,e.y-t.y)},calcAngleBetweenVectors:function(t,e){return Math.acos((t.x*e.x+t.y*e.y)/(Math.hypot(t.x,t.y)*Math.hypot(e.x,e.y)))},getHatVector:function(t){return new b.Point(t.x,t.y).multiply(1/Math.hypot(t.x,t.y))},getBisector:function(t,e,i){var n=b.util.createVector(t,e),r=b.util.createVector(t,i),s=b.util.calcAngleBetweenVectors(n,r),a=s*(0===b.util.calcAngleBetweenVectors(b.util.rotateVector(n,s),r)?1:-1)/2;return{vector:b.util.getHatVector(b.util.rotateVector(n,a)),angle:s}},projectStrokeOnPoints:function(t,e,i){var n=[],r=e.strokeWidth/2,s=e.strokeUniform?new b.Point(1/e.scaleX,1/e.scaleY):new b.Point(1,1),a=function(t){var e=r/Math.hypot(t.x,t.y);return new b.Point(t.x*e*s.x,t.y*e*s.y)};return t.length<=1||t.forEach((function(o,l){var h,c,d=new b.Point(o.x,o.y);0===l?(c=t[l+1],h=i?a(b.util.createVector(c,d)).addEquals(d):t[t.length-1]):l===t.length-1?(h=t[l-1],c=i?a(b.util.createVector(h,d)).addEquals(d):t[0]):(h=t[l-1],c=t[l+1]);var u,f,g=b.util.getBisector(d,h,c),m=g.vector,p=g.angle;if("miter"===e.strokeLineJoin&&(u=-r/Math.sin(p/2),f=new b.Point(m.x*u*s.x,m.y*u*s.y),Math.hypot(f.x,f.y)/r<=e.strokeMiterLimit))return n.push(d.add(f)),void n.push(d.subtract(f));u=-r*Math.SQRT2,f=new b.Point(m.x*u*s.x,m.y*u*s.y),n.push(d.add(f)),n.push(d.subtract(f))})),n},transformPoint:function(t,e,i){return i?new b.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new b.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t,e){if(e)for(var i=0;i0&&(e>n?e-=n:e=0,i>n?i-=n:i=0);var r,s=!0,a=t.getImageData(e,i,2*n||1,2*n||1),o=a.data.length;for(r=3;r=r?s-r:2*Math.PI-(r-s)}function s(t,e,i){for(var s=i[1],a=i[2],o=i[3],l=i[4],h=i[5],c=function(t,e,i,s,a,o,l){var h=Math.PI,c=l*h/180,d=b.util.sin(c),u=b.util.cos(c),f=0,g=0,m=-u*t*.5-d*e*.5,p=-u*e*.5+d*t*.5,_=(i=Math.abs(i))*i,v=(s=Math.abs(s))*s,y=p*p,w=m*m,C=_*v-_*y-v*w,E=0;if(C<0){var S=Math.sqrt(1-C/(_*v));i*=S,s*=S}else E=(a===o?-1:1)*Math.sqrt(C/(_*y+v*w));var T=E*i*p/s,I=-E*s*m/i,x=u*T-d*I+.5*t,O=d*T+u*I+.5*e,A=r(1,0,(m-T)/i,(p-I)/s),R=r((m-T)/i,(p-I)/s,(-m-T)/i,(-p-I)/s);0===o&&R>0?R-=2*h:1===o&&R<0&&(R+=2*h);for(var D=Math.ceil(Math.abs(R/h*2)),L=[],M=R/D,F=8/3*Math.sin(M/4)*Math.sin(M/4)/Math.sin(M/2),P=A+M,k=0;kE)for(var T=1,I=m.length;T2;for(e=e||0,h&&(o=t[2].xt[i-2].x?1:r.x===t[i-2].x?0:-1,l=r.y>t[i-2].y?1:r.y===t[i-2].y?0:-1),n.push(["L",r.x+o*e,r.y+l*e]),n},b.util.getPathSegmentsInfo=u,b.util.getBoundsOfCurve=function(e,i,n,r,s,a,o,l){var h;if(b.cachesBoundsOfCurve&&(h=t.call(arguments),b.boundsOfCurveCache[h]))return b.boundsOfCurveCache[h];var c,d,u,f,g,m,p,_,v=Math.sqrt,y=Math.min,w=Math.max,C=Math.abs,E=[],S=[[],[]];d=6*e-12*n+6*s,c=-3*e+9*n-9*s+3*o,u=3*n-3*e;for(var T=0;T<2;++T)if(T>0&&(d=6*i-12*r+6*a,c=-3*i+9*r-9*a+3*l,u=3*r-3*i),C(c)<1e-12){if(C(d)<1e-12)continue;0<(f=-u/d)&&f<1&&E.push(f)}else(p=d*d-4*u*c)<0||(0<(g=(-d+(_=v(p)))/(2*c))&&g<1&&E.push(g),0<(m=(-d-_)/(2*c))&&m<1&&E.push(m));for(var I,x,O,A=E.length,R=A;A--;)I=(O=1-(f=E[A]))*O*O*e+3*O*O*f*n+3*O*f*f*s+f*f*f*o,S[0][A]=I,x=O*O*O*i+3*O*O*f*r+3*O*f*f*a+f*f*f*l,S[1][A]=x;S[0][R]=e,S[1][R]=i,S[0][R+1]=o,S[1][R+1]=l;var D=[{x:y.apply(null,S[0]),y:y.apply(null,S[1])},{x:w.apply(null,S[0]),y:w.apply(null,S[1])}];return b.cachesBoundsOfCurve&&(b.boundsOfCurveCache[h]=D),D},b.util.getPointOnPath=function(t,e,i){i||(i=u(t));for(var n=0;e-i[n].length>0&&n1e-4;)i=l(s),r=s,(n=a(h.x,h.y,i.x,i.y))+o>e?(s-=c,c/=2):(h=i,s+=c,o+=n);return i.angle=d(r),i}(s,e)}},b.util.transformPath=function(t,e,i){return i&&(e=b.util.multiplyTransformMatrices(e,[1,0,0,1,-i.x,-i.y])),t.map((function(t){for(var i=t.slice(0),n={},r=1;r=e}))}}}(),function(){function t(e,i,n){if(n)if(!b.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var r=0,s=i.length;r57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var n=t.charCodeAt(e+1);if(56320>n||n>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";var r=t.charCodeAt(e-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1}b.util.string={camelize:function(t){return t.replace(/-+(.)?/g,(function(t,e){return e?e.toUpperCase():""}))},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")},graphemeSplit:function(e){var i,n=0,r=[];for(n=0;n-1?t.prototype[r]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=n;var r=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return r}}(r):t.prototype[r]=e[r],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function r(){}function s(e){for(var i=null,n=this;n.constructor.superclass;){var r=n.constructor.superclass.prototype[e];if(n[e]!==r){i=r;break}n=n.constructor.superclass.prototype}return i?arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this):console.log("tried to callSuper "+e+", method not found in prototype chain",this)}b.util.createClass=function(){var i=null,a=t.call(arguments,0);function o(){this.initialize.apply(this,arguments)}"function"==typeof a[0]&&(i=a.shift()),o.superclass=i,o.subclasses=[],i&&(r.prototype=i.prototype,o.prototype=new r,i.subclasses.push(o));for(var l=0,h=a.length;l-1||"touch"===t.pointerType},u="string"==typeof(d=b.document.createElement("div")).style.opacity,f="string"==typeof d.style.filter,g=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,m=function(t){return t},u?m=function(t,e){return t.style.opacity=e,t}:f&&(m=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),g.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(g,e)):i.filter+=" alpha(opacity="+100*e+")",t}),b.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?m(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var n in e)"opacity"===n?m(t,e[n]):i["float"===n||"cssFloat"===n?void 0===i.styleFloat?"cssFloat":"styleFloat":n]=e[n];return t},function(){var t,e,i,n,r=Array.prototype.slice,s=function(t){return r.call(t,0)};try{t=s(b.document.childNodes)instanceof Array}catch(t){}function a(t,e){var i=b.document.createElement(t);for(var n in e)"class"===n?i.className=e[n]:"for"===n?i.htmlFor=e[n]:i.setAttribute(n,e[n]);return i}function o(t){for(var e=0,i=0,n=b.document.documentElement,r=b.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===b.document?(e=r.scrollLeft||n.scrollLeft||0,i=r.scrollTop||n.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}t||(s=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),e=b.document.defaultView&&b.document.defaultView.getComputedStyle?function(t,e){var i=b.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},i=b.document.documentElement.style,n="userSelect"in i?"userSelect":"MozUserSelect"in i?"MozUserSelect":"WebkitUserSelect"in i?"WebkitUserSelect":"KhtmlUserSelect"in i?"KhtmlUserSelect":"",b.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=b.util.falseFunction),n?t.style[n]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},b.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),n?t.style[n]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},b.util.setImageSmoothing=function(t,e){t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled,t.imageSmoothingEnabled=e},b.util.getById=function(t){return"string"==typeof t?b.document.getElementById(t):t},b.util.toArray=s,b.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},b.util.makeElement=a,b.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=a(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},b.util.getScrollLeftTop=o,b.util.getElementOffset=function(t){var i,n,r=t&&t.ownerDocument,s={left:0,top:0},a={left:0,top:0},l={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return a;for(var h in l)a[l[h]]+=parseInt(e(t,h),10)||0;return i=r.documentElement,void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect()),n=o(t),{left:s.left+n.left-(i.clientLeft||0)+a.left,top:s.top+n.top-(i.clientTop||0)+a.top}},b.util.getNodeCanvas=function(t){var e=b.jsdomImplForWrapper(t);return e._canvas||e._image},b.util.cleanUpJsdomNode=function(t){if(b.isLikelyNode){var e=b.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}b.util.request=function(e,i){i||(i={});var n=i.method?i.method.toUpperCase():"GET",r=i.onComplete||function(){},s=new b.window.XMLHttpRequest,a=i.body||i.parameters;return s.onreadystatechange=function(){4===s.readyState&&(r(s),s.onreadystatechange=t)},"GET"===n&&(a=null,"string"==typeof i.parameters&&(e=function(t,e){return t+(/\?/.test(t)?"&":"?")+e}(e,i.parameters))),s.open(n,e,!0),"POST"!==n&&"PUT"!==n||s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(a),s}}(),b.log=console.log,b.warn=console.warn,function(){var t=b.util.object.extend,e=b.util.object.clone,i=[];function n(){return!1}function r(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e}b.util.object.extend(i,{cancelAll:function(){var t=this.splice(0);return t.forEach((function(t){t.cancel()})),t},cancelByCanvas:function(t){if(!t)return[];var e=this.filter((function(e){return"object"==typeof e.target&&e.target.canvas===t}));return e.forEach((function(t){t.cancel()})),e},cancelByTarget:function(t){var e=this.findAnimationsByTarget(t);return e.forEach((function(t){t.cancel()})),e},findAnimationIndex:function(t){return this.indexOf(this.findAnimation(t))},findAnimation:function(t){return this.find((function(e){return e.cancel===t}))},findAnimationsByTarget:function(t){return t?this.filter((function(e){return e.target===t})):[]}});var s=b.window.requestAnimationFrame||b.window.webkitRequestAnimationFrame||b.window.mozRequestAnimationFrame||b.window.oRequestAnimationFrame||b.window.msRequestAnimationFrame||function(t){return b.window.setTimeout(t,1e3/60)},a=b.window.cancelAnimationFrame||b.window.clearTimeout;function o(){return s.apply(b.window,arguments)}b.util.animate=function(i){i||(i={});var s,a=!1,l=function(){var t=b.runningAnimations.indexOf(s);return t>-1&&b.runningAnimations.splice(t,1)[0]};return s=t(e(i),{cancel:function(){return a=!0,l()},currentValue:"startValue"in i?i.startValue:0,completionRate:0,durationRate:0}),b.runningAnimations.push(s),o((function(t){var e,h=t||+new Date,c=i.duration||500,d=h+c,u=i.onChange||n,f=i.abort||n,g=i.onComplete||n,m=i.easing||r,p="startValue"in i&&i.startValue.length>0,_="startValue"in i?i.startValue:0,v="endValue"in i?i.endValue:100,y=i.byValue||(p?_.map((function(t,e){return v[e]-_[e]})):v-_);i.onStart&&i.onStart(),function t(i){var n=(e=i||+new Date)>d?c:e-h,r=n/c,w=p?_.map((function(t,e){return m(n,_[e],y[e],c)})):m(n,_,y,c),C=p?Math.abs((w[0]-_[0])/y[0]):Math.abs((w-_)/y);if(s.currentValue=p?w.slice():w,s.completionRate=C,s.durationRate=r,!a){if(!f(w,C,r))return e>d?(s.currentValue=p?v.slice():v,s.completionRate=1,s.durationRate=1,u(p?v.slice():v,1,1),g(v,1,1),void l()):(u(w,C,r),void o(t));l()}}(h)})),s.cancel},b.util.requestAnimFrame=o,b.util.cancelAnimFrame=function(){return a.apply(b.window,arguments)},b.runningAnimations=i}(),function(){function t(t,e,i){var n="rgba("+parseInt(t[0]+i*(e[0]-t[0]),10)+","+parseInt(t[1]+i*(e[1]-t[1]),10)+","+parseInt(t[2]+i*(e[2]-t[2]),10);return(n+=","+(t&&e?parseFloat(t[3]+i*(e[3]-t[3])):1))+")"}b.util.animateColor=function(e,i,n,r){var s=new b.Color(e).getSource(),a=new b.Color(i).getSource(),o=r.onComplete,l=r.onChange;return r=r||{},b.util.animate(b.util.object.extend(r,{duration:n||500,startValue:s,endValue:a,byValue:a,easing:function(e,i,n,s){return t(i,n,r.colorEasing?r.colorEasing(e,s):1-Math.cos(e/s*(Math.PI/2)))},onComplete:function(e,i,n){if(o)return o(t(a,a,0),i,n)},onChange:function(e,i,n){if(l){if(Array.isArray(e))return l(t(e,e,0),i,n);l(e,i,n)}}}))}}(),function(){function t(t,e,i,n){return t-1&&c>-1&&c-1)&&(i="stroke")}else{if("href"===t||"xlink:href"===t||"font"===t)return i;if("imageSmoothing"===t)return"optimizeQuality"===i;o=l?i.map(s):s(i,r)}}else i="";return!l&&isNaN(o)?i:o}function f(t){return new RegExp("^("+t.join("|")+")\\b","i")}function g(t,e){var i,n,r,s,a=[];for(r=0,s=e.length;r1;)l.shift(),h=e.util.multiplyTransformMatrices(h,l[0]);return h}}();var v=new RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function y(t){if(!e.svgViewBoxElementsRegEx.test(t.nodeName))return{};var i,n,r,a,o,l,h=t.getAttribute("viewBox"),c=1,d=1,u=t.getAttribute("width"),f=t.getAttribute("height"),g=t.getAttribute("x")||0,m=t.getAttribute("y")||0,p=t.getAttribute("preserveAspectRatio")||"",_=!h||!(h=h.match(v)),y=!u||!f||"100%"===u||"100%"===f,w=_&&y,C={},E="",S=0,b=0;if(C.width=0,C.height=0,C.toBeParsed=w,_&&(g||m)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(E=" translate("+s(g)+" "+s(m)+") ",o=(t.getAttribute("transform")||"")+E,t.setAttribute("transform",o),t.removeAttribute("x"),t.removeAttribute("y")),w)return C;if(_)return C.width=s(u),C.height=s(f),C;if(i=-parseFloat(h[1]),n=-parseFloat(h[2]),r=parseFloat(h[3]),a=parseFloat(h[4]),C.minX=i,C.minY=n,C.viewBoxWidth=r,C.viewBoxHeight=a,y?(C.width=r,C.height=a):(C.width=s(u),C.height=s(f),c=C.width/r,d=C.height/a),"none"!==(p=e.util.parsePreserveAspectRatioAttribute(p)).alignX&&("meet"===p.meetOrSlice&&(d=c=c>d?d:c),"slice"===p.meetOrSlice&&(d=c=c>d?c:d),S=C.width-r*c,b=C.height-a*c,"Mid"===p.alignX&&(S/=2),"Mid"===p.alignY&&(b/=2),"Min"===p.alignX&&(S=0),"Min"===p.alignY&&(b=0)),1===c&&1===d&&0===i&&0===n&&0===g&&0===m)return C;if((g||m)&&"#document"!==t.parentNode.nodeName&&(E=" translate("+s(g)+" "+s(m)+") "),o=E+" matrix("+c+" 0 0 "+d+" "+(i*c+S)+" "+(n*d+b)+") ","svg"===t.nodeName){for(l=t.ownerDocument.createElementNS(e.svgNS,"g");t.firstChild;)l.appendChild(t.firstChild);t.appendChild(l)}else(l=t).removeAttribute("x"),l.removeAttribute("y"),o=l.getAttribute("transform")+o;return l.setAttribute("transform",o),C}function w(t,e){var i="xlink:href",n=_(t,e.getAttribute(i).slice(1));if(n&&n.getAttribute(i)&&w(t,n),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach((function(t){n&&!e.hasAttribute(t)&&n.hasAttribute(t)&&e.setAttribute(t,n.getAttribute(t))})),!e.children.length)for(var r=n.cloneNode(!0);r.firstChild;)e.appendChild(r.firstChild);e.removeAttribute(i)}e.parseSVGDocument=function(t,i,r,s){if(t){!function(t){for(var i=g(t,["use","svg:use"]),n=0;i.length&&nt.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return void 0===e&&(e=.5),e=Math.max(Math.min(1,e),0),new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new i(this.x,this.y)}})}(e),function(t){var e=t.fabric||(t.fabric={});function i(t){this.status=t,this.points=[]}e.Intersection?e.warn("fabric.Intersection is already defined"):(e.Intersection=i,e.Intersection.prototype={constructor:i,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},e.Intersection.intersectLineLine=function(t,n,r,s){var a,o=(s.x-r.x)*(t.y-r.y)-(s.y-r.y)*(t.x-r.x),l=(n.x-t.x)*(t.y-r.y)-(n.y-t.y)*(t.x-r.x),h=(s.y-r.y)*(n.x-t.x)-(s.x-r.x)*(n.y-t.y);if(0!==h){var c=o/h,d=l/h;0<=c&&c<=1&&0<=d&&d<=1?(a=new i("Intersection")).appendPoint(new e.Point(t.x+c*(n.x-t.x),t.y+c*(n.y-t.y))):a=new i}else a=new i(0===o||0===l?"Coincident":"Parallel");return a},e.Intersection.intersectLinePolygon=function(t,e,n){var r,s,a,o,l=new i,h=n.length;for(o=0;o0&&(l.status="Intersection"),l},e.Intersection.intersectPolygonPolygon=function(t,e){var n,r=new i,s=t.length;for(n=0;n0&&(r.status="Intersection"),r},e.Intersection.intersectPolygonRectangle=function(t,n,r){var s=n.min(r),a=n.max(r),o=new e.Point(a.x,s.y),l=new e.Point(s.x,a.y),h=i.intersectLinePolygon(s,o,t),c=i.intersectLinePolygon(o,a,t),d=i.intersectLinePolygon(a,l,t),u=i.intersectLinePolygon(l,s,t),f=new i;return f.appendPoints(h.points),f.appendPoints(c.points),f.appendPoints(d.points),f.appendPoints(u.points),f.points.length>0&&(f.status="Intersection"),f})}(e),function(t){var e=t.fabric||(t.fabric={});function i(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function n(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}e.Color?e.warn("fabric.Color is already defined."):(e.Color=i,e.Color.prototype={_tryParsingColor:function(t){var e;t in i.colorNameMap&&(t=i.colorNameMap[t]),"transparent"===t&&(e=[255,255,255,0]),e||(e=i.sourceFromHex(t)),e||(e=i.sourceFromRgb(t)),e||(e=i.sourceFromHsl(t)),e||(e=[0,0,0,1]),e&&this.setSource(e)},_rgbToHsl:function(t,i,n){t/=255,i/=255,n/=255;var r,s,a,o=e.util.array.max([t,i,n]),l=e.util.array.min([t,i,n]);if(a=(o+l)/2,o===l)r=s=0;else{var h=o-l;switch(s=a>.5?h/(2-o-l):h/(o+l),o){case t:r=(i-n)/h+(i0)-(t<0)||+t};function f(t,e){var i=t.angle+d(Math.atan2(e.y,e.x))+360;return Math.round(i%360/45)}function g(t,i){var n=i.transform.target,r=n.canvas,s=e.util.object.clone(i);s.target=n,r&&r.fire("object:"+t,s),n.fire(t,i)}function m(t,e){var i=e.canvas,n=t[i.uniScaleKey];return i.uniformScaling&&!n||!i.uniformScaling&&n}function p(t){return t.originX===h&&t.originY===h}function _(t,e,i){var n=t.lockScalingX,r=t.lockScalingY;return!((!n||!r)&&(e||!n&&!r||!i)&&(!n||"x"!==e)&&(!r||"y"!==e))}function v(t,e,i,n){return{e:t,transform:e,pointer:{x:i,y:n}}}function y(t){return function(e,i,n,r){var s=i.target,a=s.getCenterPoint(),o=s.translateToOriginPoint(a,i.originX,i.originY),l=t(e,i,n,r);return s.setPositionByOrigin(o,i.originX,i.originY),l}}function w(t,e){return function(i,n,r,s){var a=e(i,n,r,s);return a&&g(t,v(i,n,r,s)),a}}function C(t,i,n,r,s){var a=t.target,o=a.controls[t.corner],l=a.canvas.getZoom(),h=a.padding/l,c=a.toLocalPoint(new e.Point(r,s),i,n);return c.x>=h&&(c.x-=h),c.x<=-h&&(c.x+=h),c.y>=h&&(c.y-=h),c.y<=h&&(c.y+=h),c.x-=o.offsetX,c.y-=o.offsetY,c}function E(t){return t.flipX!==t.flipY}function S(t,e,i,n,r){if(0!==t[e]){var s=r/t._getTransformedDimensions()[n]*t[i];t.set(i,s)}}function b(t,e,i,n){var r,h=e.target,c=h._getTransformedDimensions(0,h.skewY),u=C(e,e.originX,e.originY,i,n),f=Math.abs(2*u.x)-c.x,g=h.skewX;f<2?r=0:(r=d(Math.atan2(f/h.scaleX,c.y/h.scaleY)),e.originX===s&&e.originY===l&&(r=-r),e.originX===o&&e.originY===a&&(r=-r),E(h)&&(r=-r));var m=g!==r;if(m){var p=h._getTransformedDimensions().y;h.set("skewX",r),S(h,"skewY","scaleY","y",p)}return m}function T(t,e,i,n){var r,h=e.target,c=h._getTransformedDimensions(h.skewX,0),u=C(e,e.originX,e.originY,i,n),f=Math.abs(2*u.y)-c.y,g=h.skewY;f<2?r=0:(r=d(Math.atan2(f/h.scaleY,c.x/h.scaleX)),e.originX===s&&e.originY===l&&(r=-r),e.originX===o&&e.originY===a&&(r=-r),E(h)&&(r=-r));var m=g!==r;if(m){var p=h._getTransformedDimensions().x;h.set("skewY",r),S(h,"skewX","scaleX","x",p)}return m}function I(t,e,i,n,r){r=r||{};var s,a,o,l,h,d,f=e.target,g=f.lockScalingX,v=f.lockScalingY,y=r.by,w=m(t,f),E=_(f,y,w),S=e.gestureScale;if(E)return!1;if(S)a=e.scaleX*S,o=e.scaleY*S;else{if(s=C(e,e.originX,e.originY,i,n),h="y"!==y?u(s.x):1,d="x"!==y?u(s.y):1,e.signX||(e.signX=h),e.signY||(e.signY=d),f.lockScalingFlip&&(e.signX!==h||e.signY!==d))return!1;if(l=f._getTransformedDimensions(),w&&!y){var b=Math.abs(s.x)+Math.abs(s.y),T=e.original,I=b/(Math.abs(l.x*T.scaleX/f.scaleX)+Math.abs(l.y*T.scaleY/f.scaleY));a=T.scaleX*I,o=T.scaleY*I}else a=Math.abs(s.x*f.scaleX/l.x),o=Math.abs(s.y*f.scaleY/l.y);p(e)&&(a*=2,o*=2),e.signX!==h&&"y"!==y&&(e.originX=c[e.originX],a*=-1,e.signX=h),e.signY!==d&&"x"!==y&&(e.originY=c[e.originY],o*=-1,e.signY=d)}var x=f.scaleX,O=f.scaleY;return y?("x"===y&&f.set("scaleX",a),"y"===y&&f.set("scaleY",o)):(!g&&f.set("scaleX",a),!v&&f.set("scaleY",o)),x!==f.scaleX||O!==f.scaleY}r.scaleCursorStyleHandler=function(t,e,n){var r=m(t,n),s="";if(0!==e.x&&0===e.y?s="x":0===e.x&&0!==e.y&&(s="y"),_(n,s,r))return"not-allowed";var a=f(n,e);return i[a]+"-resize"},r.skewCursorStyleHandler=function(t,e,i){var r="not-allowed";if(0!==e.x&&i.lockSkewingY)return r;if(0!==e.y&&i.lockSkewingX)return r;var s=f(i,e)%4;return n[s]+"-resize"},r.scaleSkewCursorStyleHandler=function(t,e,i){return t[i.canvas.altActionKey]?r.skewCursorStyleHandler(t,e,i):r.scaleCursorStyleHandler(t,e,i)},r.rotationWithSnapping=w("rotating",y((function(t,e,i,n){var r=e,s=r.target,a=s.translateToOriginPoint(s.getCenterPoint(),r.originX,r.originY);if(s.lockRotation)return!1;var o,l=Math.atan2(r.ey-a.y,r.ex-a.x),h=Math.atan2(n-a.y,i-a.x),c=d(h-l+r.theta);if(s.snapAngle>0){var u=s.snapAngle,f=s.snapThreshold||u,g=Math.ceil(c/u)*u,m=Math.floor(c/u)*u;Math.abs(c-m)0?s:o:(c>0&&(r=d===a?s:o),c<0&&(r=d===a?o:s),E(l)&&(r=r===s?o:s)),e.originX=r,w("skewing",y(b))(t,e,i,n))},r.skewHandlerY=function(t,e,i,n){var r,o=e.target,c=o.skewY,d=e.originX;return!o.lockSkewingY&&(0===c?r=C(e,h,h,i,n).y>0?a:l:(c>0&&(r=d===s?a:l),c<0&&(r=d===s?l:a),E(o)&&(r=r===a?l:a)),e.originY=r,w("skewing",y(T))(t,e,i,n))},r.dragHandler=function(t,e,i,n){var r=e.target,s=i-e.offsetX,a=n-e.offsetY,o=!r.get("lockMovementX")&&r.left!==s,l=!r.get("lockMovementY")&&r.top!==a;return o&&r.set("left",s),l&&r.set("top",a),(o||l)&&g("moving",v(t,e,i,n)),o||l},r.scaleOrSkewActionName=function(t,e,i){var n=t[i.canvas.altActionKey];return 0===e.x?n?"skewX":"scaleY":0===e.y?n?"skewY":"scaleX":void 0},r.rotationStyleHandler=function(t,e,i){return i.lockRotation?"not-allowed":e.cursorStyle},r.fireEvent=g,r.wrapWithFixedAnchor=y,r.wrapWithFireEvent=w,r.getLocalPoint=C,e.controlsUtils=r}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians,n=e.controlsUtils;n.renderCircleControl=function(t,e,i,n,r){n=n||{};var s,a=this.sizeX||n.cornerSize||r.cornerSize,o=this.sizeY||n.cornerSize||r.cornerSize,l=void 0!==n.transparentCorners?n.transparentCorners:r.transparentCorners,h=l?"stroke":"fill",c=!l&&(n.cornerStrokeColor||r.cornerStrokeColor),d=e,u=i;t.save(),t.fillStyle=n.cornerColor||r.cornerColor,t.strokeStyle=n.cornerStrokeColor||r.cornerStrokeColor,a>o?(s=a,t.scale(1,o/a),u=i*a/o):o>a?(s=o,t.scale(a/o,1),d=e*o/a):s=a,t.lineWidth=1,t.beginPath(),t.arc(d,u,s/2,0,2*Math.PI,!1),t[h](),c&&t.stroke(),t.restore()},n.renderSquareControl=function(t,e,n,r,s){r=r||{};var a=this.sizeX||r.cornerSize||s.cornerSize,o=this.sizeY||r.cornerSize||s.cornerSize,l=void 0!==r.transparentCorners?r.transparentCorners:s.transparentCorners,h=l?"stroke":"fill",c=!l&&(r.cornerStrokeColor||s.cornerStrokeColor),d=a/2,u=o/2;t.save(),t.fillStyle=r.cornerColor||s.cornerColor,t.strokeStyle=r.cornerStrokeColor||s.cornerStrokeColor,t.lineWidth=1,t.translate(e,n),t.rotate(i(s.angle)),t[h+"Rect"](-d,-u,a,o),c&&t.strokeRect(-d,-u,a,o),t.restore()}}(e),function(t){var e=t.fabric||(t.fabric={});e.Control=function(t){for(var e in t)this[e]=t[e]},e.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(t,e){return e.cursorStyle},getActionName:function(t,e){return e.actionName},getVisibility:function(t,e){var i=t._controlsVisibility;return i&&void 0!==i[e]?i[e]:this.visible},setVisibility:function(t){this.visible=t},positionHandler:function(t,i){return e.util.transformPoint({x:this.x*t.x+this.offsetX,y:this.y*t.y+this.offsetY},i)},calcCornerCoords:function(t,i,n,r,s){var a,o,l,h,c=s?this.touchSizeX:this.sizeX,d=s?this.touchSizeY:this.sizeY;if(c&&d&&c!==d){var u=Math.atan2(d,c),f=Math.sqrt(c*c+d*d)/2,g=u-e.util.degreesToRadians(t),m=Math.PI/2-u-e.util.degreesToRadians(t);a=f*e.util.cos(g),o=f*e.util.sin(g),l=f*e.util.cos(m),h=f*e.util.sin(m)}else f=.7071067812*(c&&d?c:i),g=e.util.degreesToRadians(45-t),a=l=f*e.util.cos(g),o=h=f*e.util.sin(g);return{tl:{x:n-h,y:r-l},tr:{x:n+a,y:r-o},bl:{x:n-a,y:r+o},br:{x:n+h,y:r+l}}},render:function(t,i,n,r,s){"circle"===((r=r||{}).cornerStyle||s.cornerStyle)?e.controlsUtils.renderCircleControl.call(this,t,i,n,r,s):e.controlsUtils.renderSquareControl.call(this,t,i,n,r,s)}}}(e),function(){function t(t,e){var i,n,r,s,a=t.getAttribute("style"),o=t.getAttribute("offset")||0;if(o=(o=parseFloat(o)/(/%$/.test(o)?100:1))<0?0:o>1?1:o,a){var l=a.split(/\s*;\s*/);for(""===l[l.length-1]&&l.pop(),s=l.length;s--;){var h=l[s].split(/\s*:\s*/),c=h[0].trim(),d=h[1].trim();"stop-color"===c?i=d:"stop-opacity"===c&&(r=d)}}return i||(i=t.getAttribute("stop-color")||"rgb(0,0,0)"),r||(r=t.getAttribute("stop-opacity")),n=(i=new b.Color(i)).getAlpha(),r=isNaN(parseFloat(r))?1:parseFloat(r),r*=n*e,{offset:o,color:i.toRgb(),opacity:r}}var e=b.util.object.clone;b.Gradient=b.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(t){t||(t={}),t.coords||(t.coords={});var e,i=this;Object.keys(t).forEach((function(e){i[e]=t[e]})),this.id?this.id+="_"+b.Object.__uid++:this.id=b.Object.__uid++,e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice()},addColorStop:function(t){for(var e in t){var i=new b.Color(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(t){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return b.util.populateWithProperties(this,e,t),e},toSVG:function(t,i){var n,r,s,a,o=e(this.coords,!0),l=(i=i||{},e(this.colorStops,!0)),h=o.r1>o.r2,c=this.gradientTransform?this.gradientTransform.concat():b.iMatrix.concat(),d=-this.offsetX,u=-this.offsetY,f=!!i.additionalTransform,g="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox";if(l.sort((function(t,e){return t.offset-e.offset})),"objectBoundingBox"===g?(d/=t.width,u/=t.height):(d+=t.width/2,u+=t.height/2),"path"===t.type&&"percentage"!==this.gradientUnits&&(d-=t.pathOffset.x,u-=t.pathOffset.y),c[4]-=d,c[5]-=u,a='id="SVGID_'+this.id+'" gradientUnits="'+g+'"',a+=' gradientTransform="'+(f?i.additionalTransform+" ":"")+b.util.matrixToSVG(c)+'" ',"linear"===this.type?s=["\n']:"radial"===this.type&&(s=["\n']),"radial"===this.type){if(h)for((l=l.concat()).reverse(),n=0,r=l.length;n0){var p=m/Math.max(o.r1,o.r2);for(n=0,r=l.length;n\n')}return s.push("linear"===this.type?"\n":"\n"),s.join("")},toLive:function(t){var e,i,n,r=b.util.object.clone(this.coords);if(this.type){for("linear"===this.type?e=t.createLinearGradient(r.x1,r.y1,r.x2,r.y2):"radial"===this.type&&(e=t.createRadialGradient(r.x1,r.y1,r.r1,r.x2,r.y2,r.r2)),i=0,n=this.colorStops.length;i1?1:s,isNaN(s)&&(s=1);var a,o,l,h,c=e.getElementsByTagName("stop"),d="userSpaceOnUse"===e.getAttribute("gradientUnits")?"pixels":"percentage",u=e.getAttribute("gradientTransform")||"",f=[],g=0,m=0;for("linearGradient"===e.nodeName||"LINEARGRADIENT"===e.nodeName?(a="linear",o=function(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}(e)):(a="radial",o=function(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}(e)),l=c.length;l--;)f.push(t(c[l],s));return h=b.parseTransformAttribute(u),function(t,e,i,n){var r,s;Object.keys(e).forEach((function(t){"Infinity"===(r=e[t])?s=1:"-Infinity"===r?s=0:(s=parseFloat(e[t],10),"string"==typeof r&&/^(\d+\.\d+)%|(\d+)%$/.test(r)&&(s*=.01,"pixels"===n&&("x1"!==t&&"x2"!==t&&"r2"!==t||(s*=i.viewBoxWidth||i.width),"y1"!==t&&"y2"!==t||(s*=i.viewBoxHeight||i.height)))),e[t]=s}))}(0,o,r,d),"pixels"===d&&(g=-i.left,m=-i.top),new b.Gradient({id:e.getAttribute("id"),type:a,coords:o,colorStops:f,gradientUnits:d,gradientTransform:h,offsetX:g,offsetY:m})}})}(),_=b.util.toFixed,b.Pattern=b.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(t,e){if(t||(t={}),this.id=b.Object.__uid++,this.setOptions(t),!t.source||t.source&&"string"!=typeof t.source)e&&e(this);else{var i=this;this.source=b.util.createImage(),b.util.loadImage(t.source,(function(t,n){i.source=t,e&&e(i,n)}),null,this.crossOrigin)}},toObject:function(t){var e,i,n=b.Object.NUM_FRACTION_DIGITS;return"string"==typeof this.source.src?e=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(e=this.source.toDataURL()),i={type:"pattern",source:e,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:_(this.offsetX,n),offsetY:_(this.offsetY,n),patternTransform:this.patternTransform?this.patternTransform.concat():null},b.util.populateWithProperties(this,i,t),i},toSVG:function(t){var e="function"==typeof this.source?this.source():this.source,i=e.width/t.width,n=e.height/t.height,r=this.offsetX/t.width,s=this.offsetY/t.height,a="";return"repeat-x"!==this.repeat&&"no-repeat"!==this.repeat||(n=1,s&&(n+=Math.abs(s))),"repeat-y"!==this.repeat&&"no-repeat"!==this.repeat||(i=1,r&&(i+=Math.abs(r))),e.src?a=e.src:e.toDataURL&&(a=e.toDataURL()),'\n\n\n'},setOptions:function(t){for(var e in t)this[e]=t[e]},toLive:function(t){var e=this.source;if(!e)return"";if(void 0!==e.src){if(!e.complete)return"";if(0===e.naturalWidth||0===e.naturalHeight)return""}return t.createPattern(e,this.repeat)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.toFixed;e.Shadow?e.warn("fabric.Shadow is already defined."):(e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(t){for(var i in"string"==typeof t&&(t=this._parseShadow(t)),t)this[i]=t[i];this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),n=e.Shadow.reOffsetsAndBlur.exec(i)||[];return{color:(i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseFloat(n[1],10)||0,offsetY:parseFloat(n[2],10)||0,blur:parseFloat(n[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var n=40,r=40,s=e.Object.NUM_FRACTION_DIGITS,a=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle)),o=new e.Color(this.color);return t.width&&t.height&&(n=100*i((Math.abs(a.x)+this.blur)/t.width,s)+20,r=100*i((Math.abs(a.y)+this.blur)/t.height,s)+20),t.flipX&&(a.x*=-1),t.flipY&&(a.y*=-1),'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var t={},i=e.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach((function(e){this[e]!==i[e]&&(t[e]=this[e])}),this),t}}),e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/)}(e),function(){if(b.StaticCanvas)b.warn("fabric.StaticCanvas is already defined.");else{var t=b.util.object.extend,e=b.util.getElementOffset,i=b.util.removeFromArray,n=b.util.toFixed,r=b.util.transformPoint,s=b.util.invertTransform,a=b.util.getNodeCanvas,o=b.util.createCanvasElement,l=new Error("Could not initialize `canvas` element");b.StaticCanvas=b.util.createClass(b.CommonMethods,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:b.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(t,e){var i=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(t),this._initOptions(e),this.interactive||this._initRetinaScaling(),e.overlayImage&&this.setOverlayImage(e.overlayImage,i),e.backgroundImage&&this.setBackgroundImage(e.backgroundImage,i),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor,i),e.overlayColor&&this.setOverlayColor(e.overlayColor,i),this.calcOffset()},_isRetinaScaling:function(){return b.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,b.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var t=b.devicePixelRatio;this.__initRetinaScaling(t,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(t,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(t,e,i){e.setAttribute("width",this.width*t),e.setAttribute("height",this.height*t),i.scale(t,t)},calcOffset:function(){return this._offset=e(this.lowerCanvasEl),this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},__setBgOverlayImage:function(t,e,i,n){return"string"==typeof e?b.util.loadImage(e,(function(e,r){if(e){var s=new b.Image(e,n);this[t]=s,s.canvas=this}i&&i(e,r)}),this,n&&n.crossOrigin):(n&&e.setOptions(n),this[t]=e,e&&(e.canvas=this),i&&i(e,!1)),this},__setBgOverlayColor:function(t,e,i){return this[t]=e,this._initGradient(e,t),this._initPattern(e,t,i),this},_createCanvasElement:function(){var t=o();if(!t)throw l;if(t.style||(t.style={}),void 0===t.getContext)throw l;return t},_initOptions:function(t){var e=this.lowerCanvasEl;this._setOptions(t),this.width=this.width||parseInt(e.width,10)||0,this.height=this.height||parseInt(e.height,10)||0,this.lowerCanvasEl.style&&(e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(t){t&&t.getContext?this.lowerCanvasEl=t:this.lowerCanvasEl=b.util.getById(t)||this._createCanvasElement(),b.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;for(var n in e=e||{},t)i=t[n],e.cssOnly||(this._setBackstoreDimension(n,t[n]),i+="px",this.hasLostContext=!0),e.backstoreOnly||this._setCssDimension(n,i);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),e.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(t,e){return this.lowerCanvasEl[t]=e,this.upperCanvasEl&&(this.upperCanvasEl[t]=e),this.cacheCanvasEl&&(this.cacheCanvasEl[t]=e),this[t]=e,this},_setCssDimension:function(t,e){return this.lowerCanvasEl.style[t]=e,this.upperCanvasEl&&(this.upperCanvasEl.style[t]=e),this.wrapperEl&&(this.wrapperEl.style[t]=e),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(t){var e,i,n,r=this._activeObject,s=this.backgroundImage,a=this.overlayImage;for(this.viewportTransform=t,i=0,n=this._objects.length;i\n'),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push("\n"),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push(""),i.join("")},_setSVGPreamble:function(t,e){e.suppressPreamble||t.push('\n','\n')},_setSVGHeader:function(t,e){var i,r=e.width||this.width,s=e.height||this.height,a='viewBox="0 0 '+this.width+" "+this.height+'" ',o=b.Object.NUM_FRACTION_DIGITS;e.viewBox?a='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" ':this.svgViewportTransformation&&(i=this.viewportTransform,a='viewBox="'+n(-i[4]/i[0],o)+" "+n(-i[5]/i[3],o)+" "+n(this.width/i[0],o)+" "+n(this.height/i[3],o)+'" '),t.push("\n',"Created with Fabric.js ",b.version,"\n","\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"\n")},createSVGClipPathMarkup:function(t){var e=this.clipPath;return e?(e.clipPathId="CLIPPATH_"+b.Object.__uid++,'\n'+this.clipPath.toClipPathSVG(t.reviver)+"\n"):""},createSVGRefElementsMarkup:function(){var t=this;return["background","overlay"].map((function(e){var i=t[e+"Color"];if(i&&i.toLive){var n=t[e+"Vpt"],r=t.viewportTransform,s={width:t.width/(n?r[0]:1),height:t.height/(n?r[3]:1)};return i.toSVG(s,{additionalTransform:n?b.util.matrixToSVG(r):""})}})).join("")},createSVGFontFacesMarkup:function(){var t,e,i,n,r,s,a,o,l="",h={},c=b.fontPaths,d=[];for(this._objects.forEach((function t(e){d.push(e),e._objects&&e._objects.forEach(t)})),a=0,o=d.length;a',"\n",l,"","\n"].join("")),l},_setSVGObjects:function(t,e){var i,n,r,s=this._objects;for(n=0,r=s.length;n\n")}else t.push('\n")},sendToBack:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(e=(r=s._objects).length;e--;)n=r[e],i(this._objects,n),this._objects.unshift(n);else i(this._objects,t),this._objects.unshift(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(r=s._objects,e=0;e0+h&&(a=s-1,i(this._objects,r),this._objects.splice(a,0,r)),h++;else 0!==(s=this._objects.indexOf(t))&&(a=this._findNewLowerIndex(t,s,e),i(this._objects,t),this._objects.splice(a,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(t,e,i){var n,r;if(i){for(n=e,r=e-1;r>=0;--r)if(t.intersectsWithObject(this._objects[r])||t.isContainedWithinObject(this._objects[r])||this._objects[r].isContainedWithinObject(t)){n=r;break}}else n=e-1;return n},bringForward:function(t,e){if(!t)return this;var n,r,s,a,o,l=this._activeObject,h=0;if(t===l&&"activeSelection"===t.type)for(n=(o=l._objects).length;n--;)r=o[n],(s=this._objects.indexOf(r))"}}),t(b.StaticCanvas.prototype,b.Observable),t(b.StaticCanvas.prototype,b.Collection),t(b.StaticCanvas.prototype,b.DataURLExporter),t(b.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=o();if(!e||!e.getContext)return null;var i=e.getContext("2d");return i&&"setLineDash"===t?void 0!==i.setLineDash:null}}),b.StaticCanvas.prototype.toJSON=b.StaticCanvas.prototype.toObject,b.isLikelyNode&&(b.StaticCanvas.prototype.createPNGStream=function(){var t=a(this.lowerCanvasEl);return t&&t.createPNGStream()},b.StaticCanvas.prototype.createJPEGStream=function(t){var e=a(this.lowerCanvasEl);return e&&e.createJPEGStream(t)})}}(),b.BaseBrush=b.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(t){var e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])},_setShadow:function(){if(this.shadow){var t=this.canvas,e=this.shadow,i=t.contextTop,n=t.getZoom();t&&t._isRetinaScaling()&&(n*=b.devicePixelRatio),i.shadowColor=e.color,i.shadowBlur=e.blur*n,i.shadowOffsetX=e.offsetX*n,i.shadowOffsetY=e.offsetY*n}},needsFullRender:function(){return new b.Color(this.color).getAlpha()<1||!!this.shadow},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0},_isOutSideCanvas:function(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}),b.PencilBrush=b.util.createClass(b.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(t){this.canvas=t,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(t,e,i){var n=e.midPointFrom(i);return t.quadraticCurveTo(e.x,e.y,n.x,n.y),n},onMouseDown:function(t,e){this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],this._prepareForDrawing(t),this._captureDrawingPath(t),this._render())},onMouseMove:function(t,e){if(this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._captureDrawingPath(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var i=this._points,n=i.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(r,i[n-2],i[n-1],!0),r.stroke(),r.restore()}},onMouseUp:function(t){return!this.canvas._isMainEvent(t.e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)},_prepareForDrawing:function(t){var e=new b.Point(t.x,t.y);this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1])||(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),0))},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(t){var e=new b.Point(t.x,t.y);return this._addPoint(e)},_render:function(t){var e,i,n=this._points[0],r=this._points[1];if(t=t||this.canvas.contextTop,this._saveAndTransform(t),t.beginPath(),2===this._points.length&&n.x===r.x&&n.y===r.y){var s=this.width/1e3;n=new b.Point(n.x,n.y),r=new b.Point(r.x,r.y),n.x-=s,r.x+=s}for(t.moveTo(n.x,n.y),e=1,i=this._points.length;e=r&&(a=t[i],o.push(a));return o.push(t[s]),o},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var t=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(t))this.canvas.requestRenderAll();else{var e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}}),b.CircleBrush=b.util.createClass(b.BaseBrush,{width:10,initialize:function(t){this.canvas=t,this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop;this._saveAndTransform(i),this.dot(i,e),i.restore()},dot:function(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()},onMouseDown:function(t){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)},_render:function(){var t,e,i=this.canvas.contextTop,n=this.points;for(this._saveAndTransform(i),t=0,e=n.length;t0&&!this.preserveObjectStacking){e=[],i=[];for(var r=0,s=this._objects.length;r1&&(this._activeObject._objects=i),e.push.apply(e,i)}else e=this._objects;return e},renderAll:function(){!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_normalizePointer:function(t,e){var i=t.calcTransformMatrix(),n=b.util.invertTransform(i),r=this.restorePointerVpt(e);return b.util.transformPoint(r,n)},isTargetTransparent:function(t,e,i){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var n=this._normalizePointer(t,{x:e,y:i}),r=Math.max(t.cacheTranslationX+n.x*t.zoomX,0),s=Math.max(t.cacheTranslationY+n.y*t.zoomY,0);return b.util.isTransparent(t._cacheContext,Math.round(r),Math.round(s),this.targetFindTolerance)}var a=this.contextCache,o=t.selectionBackgroundColor,l=this.viewportTransform;return t.selectionBackgroundColor="",this.clearContext(a),a.save(),a.transform(l[0],l[1],l[2],l[3],l[4],l[5]),t.render(a),a.restore(),t.selectionBackgroundColor=o,b.util.isTransparent(a,e,i,this.targetFindTolerance)},_isSelectionKeyPressed:function(t){return Array.isArray(this.selectionKey)?!!this.selectionKey.find((function(e){return!0===t[e]})):t[this.selectionKey]},_shouldClearSelection:function(t,e){var i=this.getActiveObjects(),n=this._activeObject;return!e||e&&n&&i.length>1&&-1===i.indexOf(e)&&n!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&n&&n!==e},_shouldCenterTransform:function(t,e,i){var n;if(t)return"scale"===e||"scaleX"===e||"scaleY"===e||"resizing"===e?n=this.centeredScaling||t.centeredScaling:"rotate"===e&&(n=this.centeredRotation||t.centeredRotation),n?!i:i},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};return"ml"===e||"tl"===e||"bl"===e?i.x="right":"mr"!==e&&"tr"!==e&&"br"!==e||(i.x="left"),"tl"===e||"mt"===e||"tr"===e?i.y="bottom":"bl"!==e&&"mb"!==e&&"br"!==e||(i.y="top"),i},_getActionFromCorner:function(t,e,i,n){if(!e||!t)return"drag";var r=n.controls[e];return r.getActionName(i,r,n)},_setupCurrentTransform:function(t,i,n){if(i){var r=this.getPointer(t),s=i.__corner,a=i.controls[s],o=n&&s?a.getActionHandler(t,i,a):b.controlsUtils.dragHandler,l=this._getActionFromCorner(n,s,t,i),h=this._getOriginFromCorner(i,s),c=t[this.centeredKey],d={target:i,action:l,actionHandler:o,corner:s,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:r.x-i.left,offsetY:r.y-i.top,originX:h.x,originY:h.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:e(i.angle),width:i.width*i.scaleX,shiftKey:t.shiftKey,altKey:c,original:b.util.saveObjectTransform(i)};this._shouldCenterTransform(i,l,c)&&(d.originX="center",d.originY="center"),d.original.originX=h.x,d.original.originY=h.y,this._currentTransform=d,this._beforeTransform(t)}},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_drawSelection:function(t){var e=this._groupSelector,i=new b.Point(e.ex,e.ey),n=b.util.transformPoint(i,this.viewportTransform),r=new b.Point(e.ex+e.left,e.ey+e.top),s=b.util.transformPoint(r,this.viewportTransform),a=Math.min(n.x,s.x),o=Math.min(n.y,s.y),l=Math.max(n.x,s.x),h=Math.max(n.y,s.y),c=this.selectionLineWidth/2;this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(a,o,l-a,h-o)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,a+=c,o+=c,l-=c,h-=c,b.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(a,o,l-a,h-o))},findTarget:function(t,e){if(!this.skipTargetFind){var n,r,s=this.getPointer(t,!0),a=this._activeObject,o=this.getActiveObjects(),l=i(t),h=o.length>1&&!e||1===o.length;if(this.targets=[],h&&a._findTargetCorner(s,l))return a;if(o.length>1&&!e&&a===this._searchPossibleTargets([a],s))return a;if(1===o.length&&a===this._searchPossibleTargets([a],s)){if(!this.preserveObjectStacking)return a;n=a,r=this.targets,this.targets=[]}var c=this._searchPossibleTargets(this._objects,s);return t[this.altSelectionKey]&&c&&n&&c!==n&&(c=n,this.targets=r),c}},_checkTarget:function(t,e,i){if(e&&e.visible&&e.evented&&e.containsPoint(t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;if(!this.isTargetTransparent(e,i.x,i.y))return!0}},_searchPossibleTargets:function(t,e){for(var i,n,r=t.length;r--;){var s=t[r],a=s.group?this._normalizePointer(s.group,e):e;if(this._checkTarget(a,s,e)){(i=t[r]).subTargetCheck&&i instanceof b.Group&&(n=this._searchPossibleTargets(i._objects,e))&&this.targets.push(n);break}}return i},restorePointerVpt:function(t){return b.util.transformPoint(t,b.util.invertTransform(this.viewportTransform))},getPointer:function(e,i){if(this._absolutePointer&&!i)return this._absolutePointer;if(this._pointer&&i)return this._pointer;var n,r=t(e),s=this.upperCanvasEl,a=s.getBoundingClientRect(),o=a.width||0,l=a.height||0;o&&l||("top"in a&&"bottom"in a&&(l=Math.abs(a.top-a.bottom)),"right"in a&&"left"in a&&(o=Math.abs(a.right-a.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,i||(r=this.restorePointerVpt(r));var h=this.getRetinaScaling();return 1!==h&&(r.x/=h,r.y/=h),n=0===o||0===l?{width:1,height:1}:{width:s.width/o,height:s.height/l},{x:r.x*n.width,y:r.y*n.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),e=this.lowerCanvasEl,i=this.upperCanvasEl;i?i.className="":(i=this._createCanvasElement(),this.upperCanvasEl=i),b.util.addClass(i,"upper-canvas "+t),this.wrapperEl.appendChild(i),this._copyCanvasStyle(e,i),this._applyCanvasStyle(i),this.contextTop=i.getContext("2d")},getTopContext:function(){return this.contextTop},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=b.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),b.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),b.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.width||t.width,i=this.height||t.height;b.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=e,t.height=i,b.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;return t?"activeSelection"===t.type&&t._objects?t._objects.slice(0):[t]:[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,e){var i=!1,n=this.getActiveObjects(),r=[],s=[];t.forEach((function(t){-1===n.indexOf(t)&&(i=!0,t.fire("deselected",{e,target:t}),s.push(t))})),n.forEach((function(n){-1===t.indexOf(n)&&(i=!0,n.fire("selected",{e,target:n}),r.push(n))})),t.length>0&&n.length>0?i&&this.fire("selection:updated",{e,selected:r,deselected:s}):n.length>0?this.fire("selection:created",{e,selected:r}):t.length>0&&this.fire("selection:cleared",{e,deselected:s})},setActiveObject:function(t,e){var i=this.getActiveObjects();return this._setActiveObject(t,e),this._fireSelectionEvents(i,e),this},_setActiveObject:function(t,e){return this._activeObject!==t&&!!this._discardActiveObject(e,t)&&!t.onSelect({e})&&(this._activeObject=t,!0)},_discardActiveObject:function(t,e){var i=this._activeObject;if(i){if(i.onDeselect({e:t,object:e}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var e=this.getActiveObjects(),i=this.getActiveObject();return e.length&&this.fire("before:selection:cleared",{target:i,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(e,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach(function(t){b.util.cleanUpJsdomNode(this[t]),this[t]=void 0}.bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,b.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var e=this._activeObject;e&&e._renderControls(t)},_toObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(t),r=this.callSuper("_toObject",t,e,i);return this._unwindGroupTransformOnObject(t,n),r},_realizeGroupTransformOnObject:function(t){if(t.group&&"activeSelection"===t.group.type&&this._activeObject===t.group){var e={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach((function(i){e[i]=t[i]})),b.util.addTransformToObject(t,this._activeObject.calcOwnMatrix()),e}return null},_unwindGroupTransformOnObject:function(t,e){e&&t.set(e)},_setSVGObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(e);this.callSuper("_setSVGObject",t,e,i),this._unwindGroupTransformOnObject(e,n)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),b.StaticCanvas.prototype.setViewportTransform.call(this,t)}}),b.StaticCanvas)"prototype"!==n&&(b.Canvas[n]=b.StaticCanvas[n])}(),function(){var t=b.util.addListener,e=b.util.removeListener,i={passive:!1};function n(t,e){return t.button&&t.button===e-1}b.util.object.extend(b.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(t,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(t,e){var n=this.upperCanvasEl,r=this._getEventPrefix();t(b.window,"resize",this._onResize),t(n,r+"down",this._onMouseDown),t(n,r+"move",this._onMouseMove,i),t(n,r+"out",this._onMouseOut),t(n,r+"enter",this._onMouseEnter),t(n,"wheel",this._onMouseWheel),t(n,"contextmenu",this._onContextMenu),t(n,"dblclick",this._onDoubleClick),t(n,"dragover",this._onDragOver),t(n,"dragenter",this._onDragEnter),t(n,"dragleave",this._onDragLeave),t(n,"drop",this._onDrop),this.enablePointerEvents||t(n,"touchstart",this._onTouchStart,i),"undefined"!=typeof eventjs&&e in eventjs&&(eventjs[e](n,"gesture",this._onGesture),eventjs[e](n,"drag",this._onDrag),eventjs[e](n,"orientation",this._onOrientationChange),eventjs[e](n,"shake",this._onShake),eventjs[e](n,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(e,"remove");var t=this._getEventPrefix();e(b.document,t+"up",this._onMouseUp),e(b.document,"touchend",this._onTouchEnd,i),e(b.document,t+"move",this._onMouseMove,i),e(b.document,"touchmove",this._onMouseMove,i)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t){this.__onMouseWheel(t)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t}),this._hoveredTarget=null,e&&e.fire("mouseout",{e:t});var i=this;this._hoveredTargets.forEach((function(n){i.fire("mouse:out",{target:e,e:t}),n&&e.fire("mouseout",{e:t})})),this._hoveredTargets=[],this._iTextInstances&&this._iTextInstances.forEach((function(t){t.isEditing&&t.hiddenTextarea.focus()}))},_onMouseEnter:function(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",{target:null,e:t}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onDragOver:function(t){t.preventDefault();var e=this._simpleEventHandler("dragover",t);this._fireEnterLeaveEvents(e,t)},_onDrop:function(t){return this._simpleEventHandler("drop:before",t),this._simpleEventHandler("drop",t)},_onContextMenu:function(t){return this.stopContextMenu&&(t.stopPropagation(),t.preventDefault()),!1},_onDoubleClick:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData(t)},getPointerId:function(t){var e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1},_isMainEvent:function(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)},_onTouchStart:function(n){n.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(n)),this.__onMouseDown(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();t(b.document,"touchend",this._onTouchEnd,i),t(b.document,"touchmove",this._onMouseMove,i),e(r,s+"down",this._onMouseDown)},_onMouseDown:function(n){this.__onMouseDown(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();e(r,s+"move",this._onMouseMove,i),t(b.document,s+"up",this._onMouseUp),t(b.document,s+"move",this._onMouseMove,i)},_onTouchEnd:function(n){if(!(n.touches.length>0)){this.__onMouseUp(n),this._resetTransformEventData(),this.mainTouchId=null;var r=this._getEventPrefix();e(b.document,"touchend",this._onTouchEnd,i),e(b.document,"touchmove",this._onMouseMove,i);var s=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((function(){t(s.upperCanvasEl,r+"down",s._onMouseDown),s._willAddMouseDown=0}),400)}},_onMouseUp:function(n){this.__onMouseUp(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();this._isMainEvent(n)&&(e(b.document,s+"up",this._onMouseUp),e(b.document,s+"move",this._onMouseMove,i),t(r,s+"move",this._onMouseMove,i))},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t){var e=this._activeObject;return!!(!!e!=!!t||e&&t&&e!==t)||(e&&e.isEditing,!1)},__onMouseUp:function(t){var e,i=this._currentTransform,r=this._groupSelector,s=!1,a=!r||0===r.left&&0===r.top;if(this._cacheTransformEventData(t),e=this._target,this._handleEvent(t,"up:before"),n(t,3))this.fireRightClick&&this._handleEvent(t,"up",3,a);else{if(n(t,2))return this.fireMiddleClick&&this._handleEvent(t,"up",2,a),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)this._onMouseUpInDrawingMode(t);else if(this._isMainEvent(t)){if(i&&(this._finalizeCurrentTransform(t),s=i.actionPerformed),!a){var o=e===this._activeObject;this._maybeGroupObjects(t),s||(s=this._shouldRender(e)||!o&&e===this._activeObject)}var l,h;if(e){if(l=e._findTargetCorner(this.getPointer(t,!0),b.util.isTouchEvent(t)),e.selectable&&e!==this._activeObject&&"up"===e.activeOn)this.setActiveObject(e,t),s=!0;else{var c=e.controls[l],d=c&&c.getMouseUpHandler(t,e,c);d&&d(t,i,(h=this.getPointer(t)).x,h.y)}e.isMoving=!1}if(i&&(i.target!==e||i.corner!==l)){var u=i.target&&i.target.controls[i.corner],f=u&&u.getMouseUpHandler(t,e,c);h=h||this.getPointer(t),f&&f(t,i,h.x,h.y)}this._setCursorFromEvent(t,e),this._handleEvent(t,"up",1,a),this._groupSelector=null,this._currentTransform=null,e&&(e.__corner=0),s?this.requestRenderAll():a||this.renderTop()}}},_simpleEventHandler:function(t,e){var i=this.findTarget(e),n=this.targets,r={e,target:i,subTargets:n};if(this.fire(t,r),i&&i.fire(t,r),!n)return i;for(var s=0;s1&&(e=new b.ActiveSelection(i.reverse(),{canvas:this}),this.setActiveObject(e,t))},_collectObjects:function(t){for(var e,i=[],n=this._groupSelector.ex,r=this._groupSelector.ey,s=n+this._groupSelector.left,a=r+this._groupSelector.top,o=new b.Point(v(n,s),v(r,a)),l=new b.Point(y(n,s),y(r,a)),h=!this.selectionFullyContained,c=n===s&&r===a,d=this._objects.length;d--&&!((e=this._objects[d])&&e.selectable&&e.visible&&(h&&e.intersectsWithRect(o,l,!0)||e.isContainedWithinRect(o,l,!0)||h&&e.containsPoint(o,null,!0)||h&&e.containsPoint(l,null,!0))&&(i.push(e),c)););return i.length>1&&(i=i.filter((function(e){return!e.onSelect({e:t})}))),i},_maybeGroupObjects:function(t){this.selection&&this._groupSelector&&this._groupSelectedObjects(t),this.setCursor(this.defaultCursor),this._groupSelector=null}}),b.util.object.extend(b.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,n=(t.multiplier||1)*(t.enableRetinaScaling?this.getRetinaScaling():1),r=this.toCanvasElement(n,t);return b.util.toDataURL(r,e,i)},toCanvasElement:function(t,e){t=t||1;var i=((e=e||{}).width||this.width)*t,n=(e.height||this.height)*t,r=this.getZoom(),s=this.width,a=this.height,o=r*t,l=this.viewportTransform,h=(l[4]-(e.left||0))*t,c=(l[5]-(e.top||0))*t,d=this.interactive,u=[o,0,0,o,h,c],f=this.enableRetinaScaling,g=b.util.createCanvasElement(),m=this.contextTop;return g.width=i,g.height=n,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=u,this.width=i,this.height=n,this.calcViewportBoundaries(),this.renderCanvas(g.getContext("2d"),this._objects),this.viewportTransform=l,this.width=s,this.height=a,this.calcViewportBoundaries(),this.interactive=d,this.enableRetinaScaling=f,this.contextTop=m,g}}),b.util.object.extend(b.StaticCanvas.prototype,{loadFromJSON:function(t,e,i){if(t){var n="string"==typeof t?JSON.parse(t):b.util.object.clone(t),r=this,s=n.clipPath,a=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete n.clipPath,this._enlivenObjects(n.objects,(function(t){r.clear(),r._setBgOverlay(n,(function(){s?r._enlivenObjects([s],(function(i){r.clipPath=i[0],r.__setupCanvas.call(r,n,t,a,e)})):r.__setupCanvas.call(r,n,t,a,e)}))}),i),this}},__setupCanvas:function(t,e,i,n){var r=this;e.forEach((function(t,e){r.insertAt(t,e)})),this.renderOnAddRemove=i,delete t.objects,delete t.backgroundImage,delete t.overlayImage,delete t.background,delete t.overlay,this._setOptions(t),this.renderAll(),n&&n()},_setBgOverlay:function(t,e){var i={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(t.backgroundImage||t.overlayImage||t.background||t.overlay){var n=function(){i.backgroundImage&&i.overlayImage&&i.backgroundColor&&i.overlayColor&&e&&e()};this.__setBgOverlay("backgroundImage",t.backgroundImage,i,n),this.__setBgOverlay("overlayImage",t.overlayImage,i,n),this.__setBgOverlay("backgroundColor",t.background,i,n),this.__setBgOverlay("overlayColor",t.overlay,i,n)}else e&&e()},__setBgOverlay:function(t,e,i,n){var r=this;if(!e)return i[t]=!0,void(n&&n());"backgroundImage"===t||"overlayImage"===t?b.util.enlivenObjects([e],(function(e){r[t]=e[0],i[t]=!0,n&&n()})):this["set"+b.util.string.capitalize(t,!0)](e,(function(){i[t]=!0,n&&n()}))},_enlivenObjects:function(t,e,i){t&&0!==t.length?b.util.enlivenObjects(t,(function(t){e&&e(t)}),null,i):e&&e([])},_toDataURL:function(t,e){this.clone((function(i){e(i.toDataURL(t))}))},_toDataURLWithMultiplier:function(t,e,i){this.clone((function(n){i(n.toDataURLWithMultiplier(t,e))}))},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData((function(e){e.loadFromJSON(i,(function(){t&&t(e)}))}))},cloneWithoutData:function(t){var e=b.util.createCanvasElement();e.width=this.width,e.height=this.height;var i=new b.Canvas(e);this.backgroundImage?(i.setBackgroundImage(this.backgroundImage.src,(function(){i.renderAll(),t&&t(i)})),i.backgroundImageOpacity=this.backgroundImageOpacity,i.backgroundImageStretch=this.backgroundImageStretch):t&&t(i)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,s=e.util.string.capitalize,a=e.util.degreesToRadians,o=!e.isLikelyNode;e.Object||(e.Object=e.util.createClass(e.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:o,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(t){t&&this.setOptions(t)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=e.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(t){var i=e.perfLimitSizeTotal,n=t.width,r=t.height,s=e.maxCacheSideLimit,a=e.minCacheSideLimit;if(n<=s&&r<=s&&n*r<=i)return nc&&(t.zoomX/=n/c,t.width=c,t.capped=!0),r>d&&(t.zoomY/=r/d,t.height=d,t.capped=!0),t},_getCacheCanvasDimensions:function(){var t=this.getTotalObjectScaling(),e=this._getTransformedDimensions(0,0),i=e.x*t.scaleX/this.scaleX,n=e.y*t.scaleY/this.scaleY;return{width:i+2,height:n+2,zoomX:t.scaleX,zoomY:t.scaleY,x:i,y:n}},_updateCacheCanvas:function(){var t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){var i=t._currentTransform.target,n=t._currentTransform.action;if(this===i&&n.slice&&"scale"===n.slice(0,5))return!1}var r,s,a=this._cacheCanvas,o=this._limitCacheSize(this._getCacheCanvasDimensions()),l=e.minCacheSideLimit,h=o.width,c=o.height,d=o.zoomX,u=o.zoomY,f=h!==this.cacheWidth||c!==this.cacheHeight,g=this.zoomX!==d||this.zoomY!==u,m=f||g,p=0,_=0,v=!1;if(f){var y=this._cacheCanvas.width,w=this._cacheCanvas.height,C=h>y||c>w;v=C||(h<.9*y||c<.9*w)&&y>l&&w>l,C&&!o.capped&&(h>l||c>l)&&(p=.1*h,_=.1*c)}return this instanceof e.Text&&this.path&&(m=!0,v=!0,p+=this.getHeightOfLine(0)*this.zoomX,_+=this.getHeightOfLine(0)*this.zoomY),!!m&&(v?(a.width=Math.ceil(h+p),a.height=Math.ceil(c+_)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,a.width,a.height)),r=o.x/2,s=o.y/2,this.cacheTranslationX=Math.round(a.width/2-r)+r,this.cacheTranslationY=Math.round(a.height/2-s)+s,this.cacheWidth=h,this.cacheHeight=c,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(d,u),this.zoomX=d,this.zoomY=u,!0)},setOptions:function(t){this._setOptions(t),this._initGradient(t.fill,"fill"),this._initGradient(t.stroke,"stroke"),this._initPattern(t.fill,"fill"),this._initPattern(t.stroke,"stroke")},transform:function(t){var e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,n={type:this.type,version:e.version,originX:this.originX,originY:this.originY,left:r(this.left,i),top:r(this.top,i),width:r(this.width,i),height:r(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:r(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:r(this.strokeMiterLimit,i),scaleX:r(this.scaleX,i),scaleY:r(this.scaleY,i),angle:r(this.angle,i),flipX:this.flipX,flipY:this.flipY,opacity:r(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:r(this.skewX,i),skewY:r(this.skewY,i)};return this.clipPath&&!this.clipPath.excludeFromExport&&(n.clipPath=this.clipPath.toObject(t),n.clipPath.inverted=this.clipPath.inverted,n.clipPath.absolutePositioned=this.clipPath.absolutePositioned),e.util.populateWithProperties(this,n,t),this.includeDefaultValues||(n=this._removeDefaultValues(n)),n},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype;return i.stateProperties.forEach((function(e){"left"!==e&&"top"!==e&&(t[e]===i[e]&&delete t[e],Array.isArray(t[e])&&Array.isArray(i[e])&&0===t[e].length&&0===i[e].length&&delete t[e])})),t},toString:function(){return"#"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var t=e.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(t.scaleX),scaleY:Math.abs(t.scaleY)}},getTotalObjectScaling:function(){var t=this.getObjectScaling(),e=t.scaleX,i=t.scaleY;if(this.canvas){var n=this.canvas.getZoom(),r=this.canvas.getRetinaScaling();e*=n*r,i*=n*r}return{scaleX:e,scaleY:i}},getObjectOpacity:function(){var t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t},_set:function(t,i){var n="scaleX"===t||"scaleY"===t,r=this[t]!==i,s=!1;return n&&(i=this._constrainScale(i)),"scaleX"===t&&i<0?(this.flipX=!this.flipX,i*=-1):"scaleY"===t&&i<0?(this.flipY=!this.flipY,i*=-1):"shadow"!==t||!i||i instanceof e.Shadow?"dirty"===t&&this.group&&this.group.set("dirty",i):i=new e.Shadow(i),this[t]=i,r&&(s=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(t)>-1?(this.dirty=!0,s&&this.group.set("dirty",!0)):s&&this.stateProperties.indexOf(t)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:e.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible},render:function(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(t),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),t.restore())},renderCache:function(t){t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,t.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this._cacheContext=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth},hasFill:function(){return this.fill&&"transparent"!==this.fill},needsItsOwnCache:function(){return!("stroke"!==this.paintFirst||!this.hasFill()||!this.hasStroke()||"object"!=typeof this.shadow)||!!this.clipPath},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawClipPathOnCache:function(t,i){if(t.save(),i.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",i.absolutePositioned){var n=e.util.invertTransform(this.calcTransformMatrix());t.transform(n[0],n[1],n[2],n[3],n[4],n[5])}i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},drawObject:function(t,e){var i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath),this.fill=i,this.stroke=n},_drawClipPath:function(t,e){e&&(e.canvas=this.canvas,e.shouldCache(),e._transformDone=!0,e.renderCache({forClipping:!0}),this.drawClipPathOnCache(t,e))},drawCacheOnCanvas:function(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(t){if(this.isNotVisible())return!1;if(this._cacheCanvas&&this._cacheContext&&!t&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&this._cacheContext&&!t){var e=this.cacheWidth/this.zoomX,i=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-e/2,-i/2,e,i)}return!0}return!1},_renderBackground:function(t){if(this.backgroundColor){var e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}},_setOpacity:function(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity},_setStrokeStyles:function(t,e){var i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,i.toLive?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)},_setFillStyles:function(t,e){var i=e.fill;i&&(i.toLive?(t.fillStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,e.fill)):t.fillStyle=i)},_setClippingProperties:function(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"},_setLineDash:function(t,e){e&&0!==e.length&&(1&e.length&&e.push.apply(e,e),t.setLineDash(e))},_renderControls:function(t,i){var n,r,s,o=this.getViewportTransform(),l=this.calcTransformMatrix();r=void 0!==(i=i||{}).hasBorders?i.hasBorders:this.hasBorders,s=void 0!==i.hasControls?i.hasControls:this.hasControls,l=e.util.multiplyTransformMatrices(o,l),n=e.util.qrDecompose(l),t.save(),t.translate(n.translateX,n.translateY),t.lineWidth=1*this.borderScaleFactor,this.group||(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(n.angle-=180),t.rotate(a(this.group?n.angle:this.angle)),i.forActiveSelection||this.group?r&&this.drawBordersInGroup(t,n,i):r&&this.drawBorders(t,i),s&&this.drawControls(t,i),t.restore()},_setShadow:function(t){if(this.shadow){var i,n=this.shadow,r=this.canvas,s=r&&r.viewportTransform[0]||1,a=r&&r.viewportTransform[3]||1;i=n.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),r&&r._isRetinaScaling()&&(s*=e.devicePixelRatio,a*=e.devicePixelRatio),t.shadowColor=n.color,t.shadowBlur=n.blur*e.browserShadowBlurConstant*(s+a)*(i.scaleX+i.scaleY)/4,t.shadowOffsetX=n.offsetX*s*i.scaleX,t.shadowOffsetY=n.offsetY*a*i.scaleY}},_removeShadow:function(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)},_applyPatternGradientTransform:function(t,e){if(!e||!e.toLive)return{offsetX:0,offsetY:0};var i=e.gradientTransform||e.patternTransform,n=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,n,r):t.transform(1,0,0,1,n,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:n,offsetY:r}},_renderPaintInOrder:function(t){"stroke"===this.paintFirst?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))},_render:function(){},_renderFill:function(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())},_renderStroke:function(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform&&this.group){var e=this.getObjectScaling();t.scale(1/e.scaleX,1/e.scaleY)}else this.strokeUniform&&t.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}},_applyPatternForTransformedGradient:function(t,i){var n,r=this._limitCacheSize(this._getCacheCanvasDimensions()),s=e.util.createCanvasElement(),a=this.canvas.getRetinaScaling(),o=r.x/this.scaleX/a,l=r.y/this.scaleY/a;s.width=o,s.height=l,(n=s.getContext("2d")).beginPath(),n.moveTo(0,0),n.lineTo(o,0),n.lineTo(o,l),n.lineTo(0,l),n.closePath(),n.translate(o/2,l/2),n.scale(r.zoomX/this.scaleX/a,r.zoomY/this.scaleY/a),this._applyPatternGradientTransform(n,i),n.fillStyle=i.toLive(t),n.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(a*this.scaleX/r.zoomX,a*this.scaleY/r.zoomY),t.strokeStyle=n.createPattern(s,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var t=e.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",t.scaleX),this.set("scaleY",t.scaleY),this.angle=t.angle,this.skewX=t.skewX,this.skewY=0}},_removeTransformMatrix:function(t){var i=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),i=e.util.transformPoint(i,this.transformMatrix)),this.transformMatrix=null,t&&(this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this.cropX=t.cropX,this.cropY=t.cropY,i.x+=t.offsetLeft,i.y+=t.offsetTop,this.width=t.width,this.height=t.height),this.setPositionByOrigin(i,"center","center")},clone:function(t,i){var n=this.toObject(i);this.constructor.fromObject?this.constructor.fromObject(n,t):e.Object._fromObject("Object",n,t)},cloneAsImage:function(t,i){var n=this.toCanvasElement(i);return t&&t(new e.Image(n)),this},toCanvasElement:function(t){t||(t={});var i=e.util,n=i.saveObjectTransform(this),r=this.group,s=this.shadow,a=Math.abs,o=(t.multiplier||1)*(t.enableRetinaScaling?e.devicePixelRatio:1);delete this.group,t.withoutTransform&&i.resetObjectTransform(this),t.withoutShadow&&(this.shadow=null);var l,h,c,d,u=e.util.createCanvasElement(),f=this.getBoundingRect(!0,!0),g=this.shadow,m={x:0,y:0};g&&(h=g.blur,l=g.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),m.x=2*Math.round(a(g.offsetX)+h)*a(l.scaleX),m.y=2*Math.round(a(g.offsetY)+h)*a(l.scaleY)),c=f.width+m.x,d=f.height+m.y,u.width=Math.ceil(c),u.height=Math.ceil(d);var p=new e.StaticCanvas(u,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});"jpeg"===t.format&&(p.backgroundColor="#fff"),this.setPositionByOrigin(new e.Point(p.width/2,p.height/2),"center","center");var _=this.canvas;p.add(this);var v=p.toCanvasElement(o||1,t);return this.shadow=s,this.set("canvas",_),r&&(this.group=r),this.set(n).setCoords(),p._objects=[],p.dispose(),p=null,v},toDataURL:function(t){return t||(t={}),e.util.toDataURL(this.toCanvasElement(t),t.format||"png",t.quality||1)},isType:function(t){return arguments.length>1?Array.from(arguments).includes(this.type):this.type===t},complexity:function(){return 1},toJSON:function(t){return this.toObject(t)},rotate:function(t){var e=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return e&&this._setOriginToCenter(),this.set("angle",t),e&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var n=new e.Point(i.x,i.y),r=this._getLeftTopCoords();return this.angle&&(n=e.util.rotatePoint(n,r,a(-this.angle))),{x:n.x-r.x,y:n.y-r.y}},_setupCompositeOperation:function(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){e.runningAnimations&&e.runningAnimations.cancelByTarget(this)}}),e.util.createAccessors&&e.util.createAccessors(e.Object),i(e.Object.prototype,e.Observable),e.Object.NUM_FRACTION_DIGITS=2,e.Object.ENLIVEN_PROPS=["clipPath"],e.Object._fromObject=function(t,i,r,s){var a=e[t];i=n(i,!0),e.util.enlivenPatterns([i.fill,i.stroke],(function(t){void 0!==t[0]&&(i.fill=t[0]),void 0!==t[1]&&(i.stroke=t[1]),e.util.enlivenObjectEnlivables(i,i,(function(){var t=s?new a(i[s],i):new a(i);r&&r(t)}))}))},e.Object.__uid=0)}(e),w=b.util.degreesToRadians,C={left:-.5,center:0,right:.5},E={top:-.5,center:0,bottom:.5},b.util.object.extend(b.Object.prototype,{translateToGivenOrigin:function(t,e,i,n,r){var s,a,o,l=t.x,h=t.y;return"string"==typeof e?e=C[e]:e-=.5,"string"==typeof n?n=C[n]:n-=.5,"string"==typeof i?i=E[i]:i-=.5,"string"==typeof r?r=E[r]:r-=.5,a=r-i,((s=n-e)||a)&&(o=this._getTransformedDimensions(),l=t.x+s*o.x,h=t.y+a*o.y),new b.Point(l,h)},translateToCenterPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,e,i,"center","center");return this.angle?b.util.rotatePoint(n,t,w(this.angle)):n},translateToOriginPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,"center","center",e,i);return this.angle?b.util.rotatePoint(n,t,w(this.angle)):n},getCenterPoint:function(){var t=new b.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(t,e,i){var n,r,s=this.getCenterPoint();return n=void 0!==e&&void 0!==i?this.translateToGivenOrigin(s,"center","center",e,i):new b.Point(this.left,this.top),r=new b.Point(t.x,t.y),this.angle&&(r=b.util.rotatePoint(r,s,-w(this.angle))),r.subtractEquals(n)},setPositionByOrigin:function(t,e,i){var n=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(n,this.originX,this.originY);this.set("left",r.x),this.set("top",r.y)},adjustPosition:function(t){var e,i,n=w(this.angle),r=this.getScaledWidth(),s=b.util.cos(n)*r,a=b.util.sin(n)*r;e="string"==typeof this.originX?C[this.originX]:this.originX-.5,i="string"==typeof t?C[t]:t-.5,this.left+=s*(i-e),this.top+=a*(i-e),this.setCoords(),this.originX=t},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center",this.originY="center",this.left=t.x,this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=t.x,this.top=t.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}}),function(){var t=b.util,e=t.degreesToRadians,i=t.multiplyTransformMatrices,n=t.transformPoint;t.object.extend(b.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(t,e){return e?t?this.calcACoords():this.calcLineCoords():(this.aCoords&&this.lineCoords||this.setCoords(!0),t?this.aCoords:this.lineCoords)},getCoords:function(t,e){return i=this._getCoords(t,e),[new b.Point(i.tl.x,i.tl.y),new b.Point(i.tr.x,i.tr.y),new b.Point(i.br.x,i.br.y),new b.Point(i.bl.x,i.bl.y)];var i},intersectsWithRect:function(t,e,i,n){var r=this.getCoords(i,n);return"Intersection"===b.Intersection.intersectPolygonRectangle(r,t,e).status},intersectsWithObject:function(t,e,i){return"Intersection"===b.Intersection.intersectPolygonPolygon(this.getCoords(e,i),t.getCoords(e,i)).status||t.isContainedWithinObject(this,e,i)||this.isContainedWithinObject(t,e,i)},isContainedWithinObject:function(t,e,i){for(var n=this.getCoords(e,i),r=e?t.aCoords:t.lineCoords,s=0,a=t._getImageLines(r);s<4;s++)if(!t.containsPoint(n[s],a))return!1;return!0},isContainedWithinRect:function(t,e,i,n){var r=this.getBoundingRect(i,n);return r.left>=t.x&&r.left+r.width<=e.x&&r.top>=t.y&&r.top+r.height<=e.y},containsPoint:function(t,e,i,n){var r=this._getCoords(i,n),s=(e=e||this._getImageLines(r),this._findCrossPoints(t,e));return 0!==s&&s%2==1},isOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.getCoords(!0,t).some((function(t){return t.x<=i.x&&t.x>=e.x&&t.y<=i.y&&t.y>=e.y}))||!!this.intersectsWithRect(e,i,!0,t)||this._containsCenterOfCanvas(e,i,t)},_containsCenterOfCanvas:function(t,e,i){var n={x:(t.x+e.x)/2,y:(t.y+e.y)/2};return!!this.containsPoint(n,null,!0,i)},isPartiallyOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.intersectsWithRect(e,i,!0,t)||this.getCoords(!0,t).every((function(t){return(t.x>=i.x||t.x<=e.x)&&(t.y>=i.y||t.y<=e.y)}))&&this._containsCenterOfCanvas(e,i,t)},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,n,r,s=0;for(var a in e)if(!((r=e[a]).o.y=t.y&&r.d.y>=t.y||(r.o.x===r.d.x&&r.o.x>=t.x?n=r.o.x:(i=(r.d.y-r.o.y)/(r.d.x-r.o.x),n=-(t.y-0*t.x-(r.o.y-i*r.o.x))/(0-i)),n>=t.x&&(s+=1),2!==s)))break;return s},getBoundingRect:function(e,i){var n=this.getCoords(e,i);return t.makeBoundingBoxFromPoints(n)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){return Math.abs(t)\n')}},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})},toClipPathSVG:function(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})},_createBaseClipPathSVGMarkup:function(t,e){var i=(e=e||{}).reviver,n=e.additionalTransform||"",r=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=r,i?i(t.join("")):t.join("")},_createBaseSVGMarkup:function(t,e){var i,n,r=(e=e||{}).noStyle,s=e.reviver,a=r?"":'style="'+this.getSvgStyles()+'" ',o=e.withShadow?'style="'+this.getSvgFilter()+'" ':"",l=this.clipPath,h=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",c=l&&l.absolutePositioned,d=this.stroke,u=this.fill,f=this.shadow,g=[],m=t.indexOf("COMMON_PARTS"),p=e.additionalTransform;return l&&(l.clipPathId="CLIPPATH_"+b.Object.__uid++,n='\n'+l.toClipPathSVG(s)+"\n"),c&&g.push("\n"),g.push("\n"),i=[a,h,r?"":this.addPaintOrder()," ",p?'transform="'+p+'" ':""].join(""),t[m]=i,u&&u.toLive&&g.push(u.toSVG(this)),d&&d.toLive&&g.push(d.toSVG(this)),f&&g.push(f.toSVG(this)),l&&g.push(n),g.push(t.join("")),g.push("\n"),c&&g.push("\n"),s?s(g.join("")):g.join("")},addPaintOrder:function(){return"fill"!==this.paintFirst?' paint-order="'+this.paintFirst+'" ':""}})}(),function(){var t=b.util.object.extend,e="stateProperties";function i(e,i,n){var r={};n.forEach((function(t){r[t]=e[t]})),t(e[i],r,!0)}function n(t,e,i){if(t===e)return!0;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(var r=0,s=t.length;r=0;l--)if(r=o[l],this.isControlVisible(r)&&(n=this._getImageLines(e?this.oCoords[r].touchCorner:this.oCoords[r].corner),0!==(i=this._findCrossPoints({x:s,y:a},n))&&i%2==1))return this.__corner=r,r;return!1},forEachControl:function(t){for(var e in this.controls)t(this.controls[e],e,this)},_setCornerCoords:function(){var t=this.oCoords;for(var e in t){var i=this.controls[e];t[e].corner=i.calcCornerCoords(this.angle,this.cornerSize,t[e].x,t[e].y,!1),t[e].touchCorner=i.calcCornerCoords(this.angle,this.touchCornerSize,t[e].x,t[e].y,!0)}},drawSelectionBackground:function(e){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;e.save();var i=this.getCenterPoint(),n=this._calculateCurrentDimensions(),r=this.canvas.viewportTransform;return e.translate(i.x,i.y),e.scale(1/r[0],1/r[3]),e.rotate(t(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-n.x/2,-n.y/2,n.x,n.y),e.restore(),this},drawBorders:function(t,e){e=e||{};var i=this._calculateCurrentDimensions(),n=this.borderScaleFactor,r=i.x+n,s=i.y+n,a=void 0!==e.hasControls?e.hasControls:this.hasControls,o=!1;return t.save(),t.strokeStyle=e.borderColor||this.borderColor,this._setLineDash(t,e.borderDashArray||this.borderDashArray),t.strokeRect(-r/2,-s/2,r,s),a&&(t.beginPath(),this.forEachControl((function(e,i,n){e.withConnection&&e.getVisibility(n,i)&&(o=!0,t.moveTo(e.x*r,e.y*s),t.lineTo(e.x*r+e.offsetX,e.y*s+e.offsetY))})),o&&t.stroke()),t.restore(),this},drawBordersInGroup:function(t,e,i){i=i||{};var n=b.util.sizeAfterTransform(this.width,this.height,e),r=this.strokeWidth,s=this.strokeUniform,a=this.borderScaleFactor,o=n.x+r*(s?this.canvas.getZoom():e.scaleX)+a,l=n.y+r*(s?this.canvas.getZoom():e.scaleY)+a;return t.save(),this._setLineDash(t,i.borderDashArray||this.borderDashArray),t.strokeStyle=i.borderColor||this.borderColor,t.strokeRect(-o/2,-l/2,o,l),t.restore(),this},drawControls:function(t,e){e=e||{},t.save();var i,n,r=this.canvas.getRetinaScaling();return t.setTransform(r,0,0,r,0,0),t.strokeStyle=t.fillStyle=e.cornerColor||this.cornerColor,this.transparentCorners||(t.strokeStyle=e.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(t,e.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(i=this.group.calcTransformMatrix()),this.forEachControl((function(r,s,a){n=a.oCoords[s],r.getVisibility(a,s)&&(i&&(n=b.util.transformPoint(n,i)),r.render(t,n.x,n.y,e,a))})),t.restore(),this},isControlVisible:function(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)},setControlVisible:function(t,e){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e,this},setControlsVisibility:function(t){for(var e in t||(t={}),t)this.setControlVisible(e,t[e]);return this},onDeselect:function(){},onSelect:function(){}})}(),b.util.object.extend(b.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return b.util.animate({target:this,startValue:t.left,endValue:this.getCenterPoint().x,duration:this.FX_DURATION,onChange:function(e){t.set("left",e),s.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}})},fxCenterObjectV:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return b.util.animate({target:this,startValue:t.top,endValue:this.getCenterPoint().y,duration:this.FX_DURATION,onChange:function(e){t.set("top",e),s.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}})},fxRemove:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return b.util.animate({target:this,startValue:t.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(e){t.set("opacity",e),s.requestRenderAll(),r()},onComplete:function(){s.remove(t),n()}})}}),b.util.object.extend(b.Object.prototype,{animate:function(){if(arguments[0]&&"object"==typeof arguments[0]){var t,e,i=[],n=[];for(t in arguments[0])i.push(t);for(var r=0,s=i.length;r-1||r&&s.colorProperties.indexOf(r[1])>-1,o=r?this.get(r[0])[r[1]]:this.get(t);"from"in i||(i.from=o),a||(e=~e.indexOf("=")?o+parseFloat(e.replace("=","")):parseFloat(e));var l={target:this,startValue:i.from,endValue:e,byValue:i.by,easing:i.easing,duration:i.duration,abort:i.abort&&function(t,e,n){return i.abort.call(s,t,e,n)},onChange:function(e,a,o){r?s[r[0]][r[1]]=e:s.set(t,e),n||i.onChange&&i.onChange(e,a,o)},onComplete:function(t,e,r){n||(s.setCoords(),i.onComplete&&i.onComplete(t,e,r))}};return a?b.util.animateColor(l.startValue,l.endValue,l.duration,l):b.util.animate(l)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r={x1:1,x2:1,y1:1,y2:1};function s(t,e){var i=t.origin,n=t.axis1,r=t.axis2,s=t.dimension,a=e.nearest,o=e.center,l=e.farthest;return function(){switch(this.get(i)){case a:return Math.min(this.get(n),this.get(r));case o:return Math.min(this.get(n),this.get(r))+.5*this.get(s);case l:return Math.max(this.get(n),this.get(r))}}}e.Line?e.warn("fabric.Line is already defined"):(e.Line=e.util.createClass(e.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:e.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(t,e){t||(t=[0,0,0,0]),this.callSuper("initialize",e),this.set("x1",t[0]),this.set("y1",t[1]),this.set("x2",t[2]),this.set("y2",t[3]),this._setWidthHeight(e)},_setWidthHeight:function(t){t||(t={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in t?t.left:this._getLeftToOriginX(),this.top="top"in t?t.top:this._getTopToOriginY()},_set:function(t,e){return this.callSuper("_set",t,e),void 0!==r[t]&&this._setWidthHeight(),this},_getLeftToOriginX:s({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:s({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(t){t.beginPath();var e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;var i=t.strokeStyle;t.strokeStyle=this.stroke||t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(t){return i(this.callSuper("toObject",t),this.calcLinePoints())},_getNonTransformedDimensions:function(){var t=this.callSuper("_getNonTransformedDimensions");return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t},calcLinePoints:function(){var t=this.x1<=this.x2?-1:1,e=this.y1<=this.y2?-1:1,i=t*this.width*.5,n=e*this.height*.5;return{x1:i,x2:t*this.width*-.5,y1:n,y2:e*this.height*-.5}},_toSVG:function(){var t=this.calcLinePoints();return["\n']}}),e.Line.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),e.Line.fromElement=function(t,n,r){r=r||{};var s=e.parseAttributes(t,e.Line.ATTRIBUTE_NAMES),a=[s.x1||0,s.y1||0,s.x2||0,s.y2||0];n(new e.Line(a,i(s,r)))},e.Line.fromObject=function(t,i){var r=n(t,!0);r.points=[t.x1,t.y1,t.x2,t.y2],e.Object._fromObject("Line",r,(function(t){delete t.points,i&&i(t)}),"points")})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians;e.Circle?e.warn("fabric.Circle is already defined."):(e.Circle=e.util.createClass(e.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:e.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,e){return this.callSuper("_set",t,e),"radius"===t&&this.setRadius(e),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,n=(this.endAngle-this.startAngle)%360;if(0===n)t=["\n'];else{var r=i(this.startAngle),s=i(this.endAngle),a=this.radius;t=['180?"1":"0")+" 1"," "+e.util.cos(s)*a+" "+e.util.sin(s)*a,'" ',"COMMON_PARTS"," />\n"]}return t},_render:function(t){t.beginPath(),t.arc(0,0,this.radius,i(this.startAngle),i(this.endAngle),!1),this._renderPaintInOrder(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",2*t).set("height",2*t)}}),e.Circle.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),e.Circle.fromElement=function(t,i){var n,r=e.parseAttributes(t,e.Circle.ATTRIBUTE_NAMES);if(!("radius"in(n=r)&&n.radius>=0))throw new Error("value of `r` attribute is required and can not be negative");r.left=(r.left||0)-r.radius,r.top=(r.top||0)-r.radius,i(new e.Circle(r))},e.Circle.fromObject=function(t,i){e.Object._fromObject("Circle",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={});e.Triangle?e.warn("fabric.Triangle is already defined"):(e.Triangle=e.util.createClass(e.Object,{type:"triangle",width:100,height:100,_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)},_toSVG:function(){var t=this.width/2,e=this.height/2;return["']}}),e.Triangle.fromObject=function(t,i){return e.Object._fromObject("Triangle",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=2*Math.PI;e.Ellipse?e.warn("fabric.Ellipse is already defined."):(e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this.set("rx",t&&t.rx||0),this.set("ry",t&&t.ry||0)},_set:function(t,e){switch(this.callSuper("_set",t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']},_render:function(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,i,!1),t.restore(),this._renderPaintInOrder(t)}}),e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),e.Ellipse.fromElement=function(t,i){var n=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);n.left=(n.left||0)-n.rx,n.top=(n.top||0)-n.ry,i(new e.Ellipse(n))},e.Ellipse.fromObject=function(t,i){e.Object._fromObject("Ellipse",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Rect?e.warn("fabric.Rect is already defined"):(e.Rect=e.util.createClass(e.Object,{stateProperties:e.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(t){var e=this.rx?Math.min(this.rx,this.width/2):0,i=this.ry?Math.min(this.ry,this.height/2):0,n=this.width,r=this.height,s=-this.width/2,a=-this.height/2,o=0!==e||0!==i,l=.4477152502;t.beginPath(),t.moveTo(s+e,a),t.lineTo(s+n-e,a),o&&t.bezierCurveTo(s+n-l*e,a,s+n,a+l*i,s+n,a+i),t.lineTo(s+n,a+r-i),o&&t.bezierCurveTo(s+n,a+r-l*i,s+n-l*e,a+r,s+n-e,a+r),t.lineTo(s+e,a+r),o&&t.bezierCurveTo(s+l*e,a+r,s,a+r-l*i,s,a+r-i),t.lineTo(s,a+i),o&&t.bezierCurveTo(s,a+l*i,s+l*e,a,s+e,a),t.closePath(),this._renderPaintInOrder(t)},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']}}),e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),e.Rect.fromElement=function(t,n,r){if(!t)return n(null);r=r||{};var s=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);s.left=s.left||0,s.top=s.top||0,s.height=s.height||0,s.width=s.width||0;var a=new e.Rect(i(r?e.util.object.clone(r):{},s));a.visible=a.visible&&a.width>0&&a.height>0,n(a)},e.Rect.fromObject=function(t,i){return e.Object._fromObject("Rect",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.array.min,r=e.util.array.max,s=e.util.toFixed,a=e.util.projectStrokeOnPoints;e.Polyline?e.warn("fabric.Polyline is already defined"):(e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:e.Object.prototype.cacheProperties.concat("points"),initialize:function(t,e){e=e||{},this.points=t||[],this.callSuper("initialize",e),this._setPositionDimensions(e)},_projectStrokeOnPoints:function(){return a(this.points,this,!0)},_setPositionDimensions:function(t){var e,i=this._calcDimensions(t),n=this.exactBoundingBox?this.strokeWidth:0;this.width=i.width-n,this.height=i.height-n,t.fromSVG||(e=this.translateToGivenOrigin({x:i.left-this.strokeWidth/2+n/2,y:i.top-this.strokeWidth/2+n/2},"left","top",this.originX,this.originY)),void 0===t.left&&(this.left=t.fromSVG?i.left:e.x),void 0===t.top&&(this.top=t.fromSVG?i.top:e.y),this.pathOffset={x:i.left+this.width/2+n/2,y:i.top+this.height/2+n/2}},_calcDimensions:function(){var t=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,e=n(t,"x")||0,i=n(t,"y")||0;return{left:e,top:i,width:(r(t,"x")||0)-e,height:(r(t,"y")||0)-i}},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},_toSVG:function(){for(var t=[],i=this.pathOffset.x,n=this.pathOffset.y,r=e.Object.NUM_FRACTION_DIGITS,a=0,o=this.points.length;a\n']},commonRender:function(t){var e,i=this.points.length,n=this.pathOffset.x,r=this.pathOffset.y;if(!i||isNaN(this.points[i-1].y))return!1;t.beginPath(),t.moveTo(this.points[0].x-n,this.points[0].y-r);for(var s=0;s"},toObject:function(t){return r(this.callSuper("toObject",t),{path:this.path.map((function(t){return t.slice()}))})},toDatalessObject:function(t){var e=this.toObject(["sourcePath"].concat(t));return e.sourcePath&&delete e.path,e},_toSVG:function(){return["\n"]},_getOffsetTransform:function(){var t=e.Object.NUM_FRACTION_DIGITS;return" translate("+a(-this.pathOffset.x,t)+", "+a(-this.pathOffset.y,t)+")"},toClipPathSVG:function(t){var e=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},toSVG:function(t){var e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var t,r,s=[],a=[],o=0,l=0,h=0,c=0,d=0,u=this.path.length;d"},addWithUpdate:function(t){var i=!!this.group;return this._restoreObjectsState(),e.util.resetObjectTransform(this),t&&(i&&e.util.removeTransformFromObject(t,this.group.calcTransformMatrix()),this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,i?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,i){var n=this._objects.length;if(this.useSetOnGroup)for(;n--;)this._objects[n].setOnGroup(t,i);if("canvas"===t)for(;n--;)this._objects[n]._set(t,i);e.Object.prototype._set.call(this,t,i)},toObject:function(t){var i=this.includeDefaultValues,n=this._objects.filter((function(t){return!t.excludeFromExport})).map((function(e){var n=e.includeDefaultValues;e.includeDefaultValues=i;var r=e.toObject(t);return e.includeDefaultValues=n,r})),r=e.Object.prototype.toObject.call(this,t);return r.objects=n,r},toDatalessObject:function(t){var i,n=this.sourcePath;if(n)i=n;else{var r=this.includeDefaultValues;i=this._objects.map((function(e){var i=e.includeDefaultValues;e.includeDefaultValues=r;var n=e.toDatalessObject(t);return e.includeDefaultValues=i,n}))}var s=e.Object.prototype.toDatalessObject.call(this,t);return s.objects=i,s},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=e.Object.prototype.shouldCache.call(this);if(t)for(var i=0,n=this._objects.length;i\n"],i=0,n=this._objects.length;i\n"),e},getSvgStyles:function(){var t=void 0!==this.opacity&&1!==this.opacity?"opacity: "+this.opacity+";":"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")},toClipPathSVG:function(t){for(var e=[],i=0,n=this._objects.length;i"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",t,e),void 0===(i=i||{}).hasControls&&(i.hasControls=!1),i.forActiveSelection=!0;for(var n=0,r=this._objects.length;n\n','\t\n',"\n"),a=' clip-path="url(#imageCrop_'+l+')" '}if(this.imageSmoothing||(o='" image-rendering="optimizeSpeed'),i.push("\t\n"),this.stroke||this.strokeDashArray){var h=this.fill;this.fill=null,t=["\t\n'],this.fill=h}return"fill"!==this.paintFirst?e.concat(t,i):e.concat(i,t)},getSrc:function(t){var e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src"):e.src:this.src||""},setSrc:function(t,e,i){return b.util.loadImage(t,(function(t,n){this.setElement(t,i),this._setWidthHeight(),e&&e(this,n)}),this,i&&i.crossOrigin),this},toString:function(){return'#'},applyResizeFilters:function(){var t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),n=i.scaleX,r=i.scaleY,s=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||n>e&&r>e)return this._element=s,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=n,void(this._lastScaleY=r);b.filterBackend||(b.filterBackend=b.initFilterBackend());var a=b.util.createCanvasElement(),o=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,l=s.width,h=s.height;a.width=l,a.height=h,this._element=a,this._lastScaleX=t.scaleX=n,this._lastScaleY=t.scaleY=r,b.filterBackend.applyFilters([t],s,l,h,this._element,o),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height},applyFilters:function(t){if(t=(t=t||this.filters||[]).filter((function(t){return t&&!t.isNeutralState()})),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),0===t.length)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var e=this._originalElement,i=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(this._element===this._originalElement){var r=b.util.createCanvasElement();r.width=i,r.height=n,this._element=r,this._filteredEl=r}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,n),this._lastScaleX=1,this._lastScaleY=1;return b.filterBackend||(b.filterBackend=b.initFilterBackend()),b.filterBackend.applyFilters(t,this._originalElement,i,n,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(t){b.util.setImageSmoothing(t,this.imageSmoothing),!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)},drawCacheOnCanvas:function(t){b.util.setImageSmoothing(t,this.imageSmoothing),b.Object.prototype.drawCacheOnCanvas.call(this,t)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(t){var e=this._element;if(e){var i=this._filterScalingX,n=this._filterScalingY,r=this.width,s=this.height,a=Math.min,o=Math.max,l=o(this.cropX,0),h=o(this.cropY,0),c=e.naturalWidth||e.width,d=e.naturalHeight||e.height,u=l*i,f=h*n,g=a(r*i,c-u),m=a(s*n,d-f),p=-r/2,_=-s/2,v=a(r,c/i-l),y=a(s,d/n-h);e&&t.drawImage(e,u,f,g,m,p,_,v,y)}},_needsResize:function(){var t=this.getTotalObjectScaling();return t.scaleX!==this._lastScaleX||t.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(t,e){this.setElement(b.util.getById(t),e),b.util.addClass(this.getElement(),b.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={}),this.setOptions(t),this._setWidthHeight(t)},_initFilters:function(t,e){t&&t.length?b.util.enlivenObjects(t,(function(t){e&&e(t)}),"fabric.Image.filters"):e&&e()},_setWidthHeight:function(t){t||(t={});var e=this.getElement();this.width=t.width||e.naturalWidth||e.width||0,this.height=t.height||e.naturalHeight||e.height||0},parsePreserveAspectRatioAttribute:function(){var t,e=b.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),i=this._element.width,n=this._element.height,r=1,s=1,a=0,o=0,l=0,h=0,c=this.width,d=this.height,u={width:c,height:d};return!e||"none"===e.alignX&&"none"===e.alignY?(r=c/i,s=d/n):("meet"===e.meetOrSlice&&(t=(c-i*(r=s=b.util.findScaleToFit(this._element,u)))/2,"Min"===e.alignX&&(a=-t),"Max"===e.alignX&&(a=t),t=(d-n*s)/2,"Min"===e.alignY&&(o=-t),"Max"===e.alignY&&(o=t)),"slice"===e.meetOrSlice&&(t=i-c/(r=s=b.util.findScaleToCover(this._element,u)),"Mid"===e.alignX&&(l=t/2),"Max"===e.alignX&&(l=t),t=n-d/s,"Mid"===e.alignY&&(h=t/2),"Max"===e.alignY&&(h=t),i=c/r,n=d/s)),{width:i,height:n,scaleX:r,scaleY:s,offsetLeft:a,offsetTop:o,cropX:l,cropY:h}}}),b.Image.CSS_CANVAS="canvas-img",b.Image.prototype.getSvgSrc=b.Image.prototype.getSrc,b.Image.fromObject=function(t,e){var i=b.util.object.clone(t);b.util.loadImage(i.src,(function(t,n){n?e&&e(null,!0):b.Image.prototype._initFilters.call(i,i.filters,(function(n){i.filters=n||[],b.Image.prototype._initFilters.call(i,[i.resizeFilter],(function(n){i.resizeFilter=n[0],b.util.enlivenObjectEnlivables(i,i,(function(){var n=new b.Image(t,i);e(n,!1)}))}))}))}),null,i.crossOrigin)},b.Image.fromURL=function(t,e,i){b.util.loadImage(t,(function(t,n){e&&e(new b.Image(t,i),n)}),null,i&&i.crossOrigin)},b.Image.ATTRIBUTE_NAMES=b.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),b.Image.fromElement=function(t,i,n){var r=b.parseAttributes(t,b.Image.ATTRIBUTE_NAMES);b.Image.fromURL(r["xlink:href"],i,e(n?b.util.object.clone(n):{},r))})}(e),b.util.object.extend(b.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.angle%360;return t>0?90*Math.round((t-1)/90):90*Math.round(t/90)},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(t){var e=function(){},i=(t=t||{}).onComplete||e,n=t.onChange||e,r=this;return b.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){r.rotate(t),n()},onComplete:function(){r.setCoords(),i()}})}}),b.util.object.extend(b.StaticCanvas.prototype,{straightenObject:function(t){return t.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(t){return t.fxStraighten({onChange:this.requestRenderAllBound})}}),function(){function t(t,e){var i="precision "+e+" float;\nvoid main(){}",n=t.createShader(t.FRAGMENT_SHADER);return t.shaderSource(n,i),t.compileShader(n),!!t.getShaderParameter(n,t.COMPILE_STATUS)}function e(t){t&&t.tileSize&&(this.tileSize=t.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}b.isWebglSupported=function(e){if(b.isLikelyNode)return!1;e=e||b.WebglFilterBackend.prototype.tileSize;var i=document.createElement("canvas"),n=i.getContext("webgl")||i.getContext("experimental-webgl"),r=!1;if(n){b.maxTextureSize=n.getParameter(n.MAX_TEXTURE_SIZE),r=b.maxTextureSize>=e;for(var s=["highp","mediump","lowp"],a=0;a<3;a++)if(t(n,s[a])){b.webGlPrecision=s[a];break}}return this.isSupported=r,r},b.WebglFilterBackend=e,e.prototype={tileSize:2048,resources:{},setupGLContext:function(t,e){this.dispose(),this.createWebGLCanvas(t,e),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(t,e)},chooseFastestCopyGLTo2DMethod:function(t,e){var i,n=void 0!==window.performance;try{new ImageData(1,1),i=!0}catch(t){i=!1}var r="undefined"!=typeof ArrayBuffer,s="undefined"!=typeof Uint8ClampedArray;if(n&&i&&r&&s){var a=b.util.createCanvasElement(),o=new ArrayBuffer(t*e*4);if(b.forceGLPutImageData)return this.imageBuffer=o,void(this.copyGLTo2D=x);var l,h,c={imageBuffer:o,destinationWidth:t,destinationHeight:e,targetCanvas:a};a.width=t,a.height=e,l=window.performance.now(),I.call(c,this.gl,c),h=window.performance.now()-l,l=window.performance.now(),x.call(c,this.gl,c),h>window.performance.now()-l?(this.imageBuffer=o,this.copyGLTo2D=x):this.copyGLTo2D=I}},createWebGLCanvas:function(t,e){var i=b.util.createCanvasElement();i.width=t,i.height=e;var n={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},r=i.getContext("webgl",n);r||(r=i.getContext("experimental-webgl",n)),r&&(r.clearColor(0,0,0,0),this.canvas=i,this.gl=r)},applyFilters:function(t,e,i,n,r,s){var a,o=this.gl;s&&(a=this.getCachedTexture(s,e));var l={originalWidth:e.width||e.originalWidth,originalHeight:e.height||e.originalHeight,sourceWidth:i,sourceHeight:n,destinationWidth:i,destinationHeight:n,context:o,sourceTexture:this.createTexture(o,i,n,!a&&e),targetTexture:this.createTexture(o,i,n),originalTexture:a||this.createTexture(o,i,n,!a&&e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},h=o.createFramebuffer();return o.bindFramebuffer(o.FRAMEBUFFER,h),t.forEach((function(t){t&&t.applyTo(l)})),function(t){var e=t.targetCanvas,i=e.width,n=e.height,r=t.destinationWidth,s=t.destinationHeight;i===r&&n===s||(e.width=r,e.height=s)}(l),this.copyGLTo2D(o,l),o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(l.sourceTexture),o.deleteTexture(l.targetTexture),o.deleteFramebuffer(h),r.getContext("2d").setTransform(1,0,0,1,0,0),l},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(t,e,i,n){var r=t.createTexture();return t.bindTexture(t.TEXTURE_2D,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,i,0,t.RGBA,t.UNSIGNED_BYTE,null),r},getCachedTexture:function(t,e){if(this.textureCache[t])return this.textureCache[t];var i=this.createTexture(this.gl,e.width,e.height,e);return this.textureCache[t]=i,i},evictCachesForKey:function(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])},copyGLTo2D:I,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var t=this.gl,e={renderer:"",vendor:""};if(!t)return e;var i=t.getExtension("WEBGL_debug_renderer_info");if(i){var n=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);n&&(e.renderer=n.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}}(),function(){var t=function(){};function e(){}b.Canvas2dFilterBackend=e,e.prototype={evictCachesForKey:t,dispose:t,clearWebGLCaches:t,resources:{},applyFilters:function(t,e,i,n,r){var s=r.getContext("2d");s.drawImage(e,0,0,i,n);var a={sourceWidth:i,sourceHeight:n,imageData:s.getImageData(0,0,i,n),originalEl:e,originalImageData:s.getImageData(0,0,i,n),canvasEl:r,ctx:s,filterBackend:this};return t.forEach((function(t){t.applyTo(a)})),a.imageData.width===i&&a.imageData.height===n||(r.width=a.imageData.width,r.height=a.imageData.height),s.putImageData(a.imageData,0,0),a}}}(),b.Image=b.Image||{},b.Image.filters=b.Image.filters||{},b.Image.filters.BaseFilter=b.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(t){t&&this.setOptions(t)},setOptions:function(t){for(var e in t)this[e]=t[e]},createProgram:function(t,e,i){e=e||this.fragmentSource,i=i||this.vertexSource,"highp"!==b.webGlPrecision&&(e=e.replace(/precision highp float/g,"precision "+b.webGlPrecision+" float"));var n=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+t.getShaderInfoLog(n));var r=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+t.getShaderInfoLog(r));var s=t.createProgram();if(t.attachShader(s,n),t.attachShader(s,r),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+t.getProgramInfoLog(s));var a=this.getAttributeLocations(t,s),o=this.getUniformLocations(t,s)||{};return o.uStepW=t.getUniformLocation(s,"uStepW"),o.uStepH=t.getUniformLocation(s,"uStepH"),{program:s,attributeLocations:a,uniformLocations:o}},getAttributeLocations:function(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(t,e,i){var n=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)},_setupFrameBuffer:function(t){var e,i,n=t.context;t.passes>1?(e=t.destinationWidth,i=t.destinationHeight,t.sourceWidth===e&&t.sourceHeight===i||(n.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(n,e,i)),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t.targetTexture,0)):(n.bindFramebuffer(n.FRAMEBUFFER,null),n.finish())},_swapTextures:function(t){t.passes--,t.pass++;var e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e},isNeutralState:function(){var t=this.mainParameter,e=b.Image.filters[this.type].prototype;if(t){if(Array.isArray(e[t])){for(var i=e[t].length;i--;)if(this[t][i]!==e[t][i])return!1;return!0}return e[t]===this[t]}return!1},applyTo:function(t){t.webgl?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},retrieveShader:function(t){return t.programCache.hasOwnProperty(this.type)||(t.programCache[this.type]=this.createProgram(t.context)),t.programCache[this.type]},applyToWebGL:function(t){var e=t.context,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)},unbindAdditionalTexture:function(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(t){this[this.mainParameter]=t},sendUniformData:function(){},createHelpLayer:function(t){if(!t.helpLayer){var e=document.createElement("canvas");e.width=t.sourceWidth,e.height=t.sourceHeight,t.helpLayer=e}},toObject:function(){var t={type:this.type},e=this.mainParameter;return e&&(t[e]=this[e]),t},toJSON:function(){return this.toObject()}}),b.Image.filters.BaseFilter.fromObject=function(t,e){var i=new b.Image.filters[t.type](t);return e&&e(i),i},function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.ColorMatrix=n(i.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var e,i,n,r,s,a=t.imageData.data,o=a.length,l=this.matrix,h=this.colorsOnly;for(s=0;s=w||a<0||a>=y||(l=4*(o*y+a),h=p[f*_+u],e+=m[l]*h,i+=m[l+1]*h,n+=m[l+2]*h,S||(r+=m[l+3]*h));E[s]=e,E[s+1]=i,E[s+2]=n,E[s+3]=S?m[s+3]:r}t.imageData=C},getUniformLocations:function(t,e){return{uMatrix:t.getUniformLocation(e,"uMatrix"),uOpaque:t.getUniformLocation(e,"uOpaque"),uHalfSize:t.getUniformLocation(e,"uHalfSize"),uSize:t.getUniformLocation(e,"uSize")}},sendUniformData:function(t,e){t.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),e.Image.filters.Convolute.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Grayscale=n(i.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(t){var e,i,n=t.imageData.data,r=n.length,s=this.mode;for(e=0;eh[0]&&r>h[1]&&s>h[2]&&n 0.0) {\n"+this.fragmentSource[t]+"}\n}"},retrieveShader:function(t){var e,i=this.type+"_"+this.mode;return t.programCache.hasOwnProperty(i)||(e=this.buildSource(this.mode),t.programCache[i]=this.createProgram(t.context,e)),t.programCache[i]},applyTo2d:function(t){var i,n,r,s,a,o,l,h=t.imageData.data,c=h.length,d=1-this.alpha;i=(l=new e.Color(this.color).getSource())[0]*this.alpha,n=l[1]*this.alpha,r=l[2]*this.alpha;for(var u=0;u=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;var i=(e*=Math.PI)/t;return o(e)/e*o(i)/i}},applyTo2d:function(t){var e=t.imageData,i=this.scaleX,n=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/n;var r,s=e.width,o=e.height,l=a(s*i),h=a(o*n);"sliceHack"===this.resizeType?r=this.sliceByTwo(t,s,o,l,h):"hermite"===this.resizeType?r=this.hermiteFastResize(t,s,o,l,h):"bilinear"===this.resizeType?r=this.bilinearFiltering(t,s,o,l,h):"lanczos"===this.resizeType&&(r=this.lanczosResize(t,s,o,l,h)),t.imageData=r},sliceByTwo:function(t,i,r,s,a){var o,l,h=t.imageData,c=.5,d=!1,u=!1,f=i*c,g=r*c,m=e.filterBackend.resources,p=0,_=0,v=i,y=0;for(m.sliceByTwo||(m.sliceByTwo=document.createElement("canvas")),((o=m.sliceByTwo).width<1.5*i||o.height=e)){L=n(1e3*s(b-C.x)),w[L]||(w[L]={});for(var F=E.y-y;F<=E.y+y;F++)F<0||F>=a||(M=n(1e3*s(F-C.y)),w[L][M]||(w[L][M]=f(r(i(L*p,2)+i(M*_,2))/1e3)),(T=w[L][M])>0&&(x+=T,O+=T*c[I=4*(F*e+b)],A+=T*c[I+1],R+=T*c[I+2],D+=T*c[I+3]))}u[I=4*(S*o+l)]=O/x,u[I+1]=A/x,u[I+2]=R/x,u[I+3]=D/x}return++l1&&M<-1||(y=2*M*M*M-3*M*M+1)>0&&(T+=y*f[3+(L=4*(D+x*e))],C+=y,f[L+3]<255&&(y=y*f[L+3]/250),E+=y*f[L],S+=y*f[L+1],b+=y*f[L+2],w+=y)}m[v]=E/w,m[v+1]=S/w,m[v+2]=b/w,m[v+3]=T/C}return g},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),e.Image.filters.Resize.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Contrast=n(i.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(t){if(0!==this.contrast){var e,i=t.imageData.data,n=i.length,r=Math.floor(255*this.contrast),s=259*(r+255)/(255*(259-r));for(e=0;e1&&(e=1/this.aspectRatio):this.aspectRatio<1&&(e=this.aspectRatio),t=e*this.blur*.12,this.horizontal?i[0]=t:i[1]=t,i}}),i.Blur.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Gamma=n(i.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],i.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var e,i=t.imageData.data,n=this.gamma,r=i.length,s=1/n[0],a=1/n[1],o=1/n[2];for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),e=0,r=256;e'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t},_render:function(t){var e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){"stroke"===this.paintFirst?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,e,i){if(t.textBaseline="alphabetical",this.path)switch(this.pathAlign){case"center":t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline="bottom"}t.font=this._getFontDeclaration(e,i)},calcTextWidth:function(){for(var t=this.getLineWidth(0),e=1,i=this._textLines.length;et&&(t=n)}return t},_renderTextLine:function(t,e,i,n,r,s){this._renderChars(t,e,i,n,r,s)},_renderTextLinesBackground:function(t){if(this.textBackgroundColor||this.styleHas("textBackgroundColor")){for(var e,i,n,r,s,a,o,l=t.fillStyle,h=this._getLeftOffset(),c=this._getTopOffset(),d=0,u=0,f=this.path,g=0,m=this._textLines.length;g=0:io?d%=o:d<0&&(d+=o),this._setGraphemeOnPath(d,s,a),d+=s.kernedWidth}return{width:l,numOfSpaces:0}},_setGraphemeOnPath:function(t,i,n){var r=t+i.kernedWidth/2,s=this.path,a=e.util.getPointOnPath(s.path,r,s.segmentsInfo);i.renderLeft=a.x-n.x,i.renderTop=a.y-n.y,i.angle=a.angle+("right"===this.pathSide?Math.PI:0)},_getGraphemeBox:function(t,e,i,n,r){var s,a=this.getCompleteStyleDeclaration(e,i),o=n?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,a,n,o),h=l.kernedWidth,c=l.width;0!==this.charSpacing&&(c+=s=this._getWidthOfCharSpacing(),h+=s);var d={width:c,left:0,height:a.fontSize,kernedWidth:h,deltaY:a.deltaY};if(i>0&&!r){var u=this.__charBounds[e][i-1];d.left=u.left+u.width+l.kernedWidth-l.width}return d},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var e=this._textLines[t],i=this.getHeightOfChar(t,0),n=1,r=e.length;n0){var x=v+s+d;"rtl"===this.direction&&(x=this.width-x-u),h&&_&&(t.fillStyle=_,t.fillRect(x,c+E*n+a,u,this.fontSize/15)),d=f.left,u=f.width,h=g,_=p,n=r,a=o}else u+=f.kernedWidth;x=v+s+d,"rtl"===this.direction&&(x=this.width-x-u),t.fillStyle=p,g&&p&&t.fillRect(x,c+E*n+a,u-C,this.fontSize/15),y+=i}else y+=i;this._removeShadow(t)}},_getFontDeclaration:function(t,i){var n=t||this,r=this.fontFamily,s=e.Text.genericFonts.indexOf(r.toLowerCase())>-1,a=void 0===r||r.indexOf("'")>-1||r.indexOf(",")>-1||r.indexOf('"')>-1||s?n.fontFamily:'"'+n.fontFamily+'"';return[e.isLikelyNode?n.fontWeight:n.fontStyle,e.isLikelyNode?n.fontStyle:n.fontWeight,i?this.CACHE_FONT_SIZE+"px":n.fontSize+"px",a].join(" ")},render:function(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t)))},_splitTextIntoLines:function(t){for(var i=t.split(this._reNewline),n=new Array(i.length),r=["\n"],s=[],a=0;a-1&&(t.underline=!0),t.textDecoration.indexOf("line-through")>-1&&(t.linethrough=!0),t.textDecoration.indexOf("overline")>-1&&(t.overline=!0),delete t.textDecoration)}b.IText=b.util.createClass(b.Text,b.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(t,e){this.callSuper("initialize",t,e),this.initBehavior()},setSelectionStart:function(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)},setSelectionEnd:function(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)},_updateAndFire:function(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(t){this.clearContextTop(),this.callSuper("render",t),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(t){this.callSuper("_render",t)},clearContextTop:function(t){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var e=this.canvas.contextTop,i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e),this._clearTextArea(e),t||e.restore()}},renderCursorOrSelection:function(){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var t=this._getCursorBoundaries(),e=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(t,e):this.renderSelection(t,e),e.restore()}},_clearTextArea:function(t){var e=this.width+4,i=this.height+4;t.clearRect(-e/2,-i/2,e,i)},_getCursorBoundaries:function(t){void 0===t&&(t=this.selectionStart);var e=this._getLeftOffset(),i=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t);return{left:e,top:i,leftOffset:n.left,topOffset:n.top}},_getCursorBoundariesOffsets:function(t){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var e,i,n,r,s=0,a=0,o=this.get2DCursorLocation(t);n=o.charIndex,i=o.lineIndex;for(var l=0;l0?a:0)},"rtl"===this.direction&&(r.left*=-1),this.cursorOffsetCache=r,this.cursorOffsetCache},renderCursor:function(t,e){var i=this.get2DCursorLocation(),n=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,s=this.getValueOfPropertyAt(n,r,"fontSize"),a=this.scaleX*this.canvas.getZoom(),o=this.cursorWidth/a,l=t.topOffset,h=this.getValueOfPropertyAt(n,r,"deltaY");l+=(1-this._fontSizeFraction)*this.getHeightOfLine(n)/this.lineHeight-s*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(t,e),e.fillStyle=this.cursorColor||this.getValueOfPropertyAt(n,r,"fill"),e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,e.fillRect(t.left+t.leftOffset-o/2,l+t.top+h,o,s)},renderSelection:function(t,e){for(var i=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,n=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,r=-1!==this.textAlign.indexOf("justify"),s=this.get2DCursorLocation(i),a=this.get2DCursorLocation(n),o=s.lineIndex,l=a.lineIndex,h=s.charIndex<0?0:s.charIndex,c=a.charIndex<0?0:a.charIndex,d=o;d<=l;d++){var u,f=this._getLineLeftOffset(d)||0,g=this.getHeightOfLine(d),m=0,p=0;if(d===o&&(m=this.__charBounds[o][h].left),d>=o&&d1)&&(g/=this.lineHeight);var v=t.left+f+m,y=p-m,w=g,C=0;this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",w=1,C=g):e.fillStyle=this.selectionColor,"rtl"===this.direction&&(v=this.width-v-y),e.fillRect(v,t.top+t.topOffset+C,y,w),t.topOffset+=u}},getCurrentCharFontSize:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")},getCurrentCharColor:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fill")},_getCurrentCharIndex:function(){var t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}}),b.IText.fromObject=function(e,i){if(t(e),e.styles)for(var n in e.styles)for(var r in e.styles[n])t(e.styles[n][r]);b.Object._fromObject("IText",e,i,"text")}}(),S=b.util.object.clone,b.util.object.extend(b.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var t=this;this.on("added",(function(){var e=t.canvas;e&&(e._hasITextHandlers||(e._hasITextHandlers=!0,t._initCanvasHandlers(e)),e._iTextInstances=e._iTextInstances||[],e._iTextInstances.push(t))}))},initRemovedHandler:function(){var t=this;this.on("removed",(function(){var e=t.canvas;e&&(e._iTextInstances=e._iTextInstances||[],b.util.removeFromArray(e._iTextInstances,t),0===e._iTextInstances.length&&(e._hasITextHandlers=!1,t._removeCanvasHandlers(e)))}))},_initCanvasHandlers:function(t){t._mouseUpITextHandler=function(){t._iTextInstances&&t._iTextInstances.forEach((function(t){t.__isMousedown=!1}))},t.on("mouse:up",t._mouseUpITextHandler)},_removeCanvasHandlers:function(t){t.off("mouse:up",t._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,n){var r;return r={isAborted:!1,abort:function(){this.isAborted=!0}},t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){r.isAborted||t[n]()},onChange:function(){t.canvas&&t.selectionStart===t.selectionEnd&&t.renderCursorOrSelection()},abort:function(){return r.isAborted}}),r},_onTickComplete:function(){var t=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout((function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")}),100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout((function(){e._tick()}),i)},abortCursorAnimation:function(){var t=this._currentTickState||this._currentTickCompleteState,e=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,t&&e&&e.clearContext(e.contextTop||e.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i-1;)e++,i--;return t-e},findLineBoundaryRight:function(t){for(var e=0,i=t;!/\n/.test(this._text[i])&&i0&&nthis.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=e):(this.selectionStart=e,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===n||(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(t,e,i){var n=i.slice(0,t),r=b.util.string.graphemeSplit(n).length;if(t===e)return{selectionStart:r,selectionEnd:r};var s=i.slice(t,e);return{selectionStart:r,selectionEnd:r+b.util.string.graphemeSplit(s).length}},fromGraphemeToStringSelection:function(t,e,i){var n=i.slice(0,t).join("").length;return t===e?{selectionStart:n,selectionEnd:n}:{selectionStart:n,selectionEnd:n+i.slice(t,e).join("").length}},_updateTextarea:function(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){var t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var t=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=t.selectionEnd,this.inCompositionMode||(this.selectionStart=t.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),n=i.lineIndex,r=i.charIndex,s=this.getValueOfPropertyAt(n,r,"fontSize")*this.lineHeight,a=e.leftOffset,o=this.calcTransformMatrix(),l={x:e.left+a,y:e.top+e.topOffset+s},h=this.canvas.getRetinaScaling(),c=this.canvas.upperCanvasEl,d=c.width/h,u=c.height/h,f=d-s,g=u-s,m=c.clientWidth/d,p=c.clientHeight/u;return l=b.util.transformPoint(l,o),(l=b.util.transformPoint(l,this.canvas.viewportTransform)).x*=m,l.y*=p,l.x<0&&(l.x=0),l.x>f&&(l.x=f),l.y<0&&(l.y=0),l.y>g&&(l.y=g),l.x+=this.canvas._offset.left,l.y+=this.canvas._offset.top,{left:l.x+"px",top:l.y+"px",fontSize:s+"px",charHeight:s}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var t=this._textBeforeEdit!==this.text,e=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var t in this.styles)this._textLines[t]||delete this.styles[t]},removeStyleFromTo:function(t,e){var i,n,r=this.get2DCursorLocation(t,!0),s=this.get2DCursorLocation(e,!0),a=r.lineIndex,o=r.charIndex,l=s.lineIndex,h=s.charIndex;if(a!==l){if(this.styles[a])for(i=o;i=h&&(n[c-u]=n[d],delete n[d])}},shiftLineStyles:function(t,e){var i=S(this.styles);for(var n in this.styles){var r=parseInt(n,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}},restartCursorIfNeeded:function(){this._currentTickState&&!this._currentTickState.isAborted&&this._currentTickCompleteState&&!this._currentTickCompleteState.isAborted||this.initDelayedCursor()},insertNewlineStyleObject:function(t,e,i,n){var r,s={},a=!1,o=this._unwrappedTextLines[t].length===e;for(var l in i||(i=1),this.shiftLineStyles(t,i),this.styles[t]&&(r=this.styles[t][0===e?e:e-1]),this.styles[t]){var h=parseInt(l,10);h>=e&&(a=!0,s[h-e]=this.styles[t][l],o&&0===e||delete this.styles[t][l])}var c=!1;for(a&&!o&&(this.styles[t+i]=s,c=!0),c&&i--;i>0;)n&&n[i-1]?this.styles[t+i]={0:S(n[i-1])}:r?this.styles[t+i]={0:S(r)}:delete this.styles[t+i],i--;this._forceClearCache=!0},insertCharStyleObject:function(t,e,i,n){this.styles||(this.styles={});var r=this.styles[t],s=r?S(r):{};for(var a in i||(i=1),s){var o=parseInt(a,10);o>=e&&(r[o+i]=s[o],s[o-i]||delete r[o])}if(this._forceClearCache=!0,n)for(;i--;)Object.keys(n[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=S(n[i]));else if(r)for(var l=r[e?e-1:1];l&&i--;)this.styles[t][e+i]=S(l)},insertNewStyleBlock:function(t,e,i){for(var n=this.get2DCursorLocation(e,!0),r=[0],s=0,a=0;a0&&(this.insertCharStyleObject(n.lineIndex,n.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),s&&this.insertNewlineStyleObject(n.lineIndex,n.charIndex+r[0],s),a=1;a0?this.insertCharStyleObject(n.lineIndex+a,0,r[a],i):i&&this.styles[n.lineIndex+a]&&i[0]&&(this.styles[n.lineIndex+a][0]=i[0]),i=i&&i.slice(r[a]+1);r[a]>0&&this.insertCharStyleObject(n.lineIndex+a,0,r[a],i)},setSelectionStartEndWithShift:function(t,e,i){i<=t?(e===t?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=t),this.selectionStart=i):i>t&&it?this.selectionStart=t:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>t?this.selectionEnd=t:this.selectionEnd<0&&(this.selectionEnd=0)}}),b.util.object.extend(b.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(t){if(this.canvas){this.__newClickTime=+new Date;var e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),this._stopEvent(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))},tripleClickHandler:function(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(t.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(t){if(this.__isMousedown=!1,!(!this.editable||this.group||t.transform&&t.transform.actionPerformed||t.e.button&&1!==t.e.button)){if(this.canvas){var e=this.canvas._activeObject;if(e&&e!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(t.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t),i=this.selectionStart,n=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,n,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(t){for(var e,i=this.getLocalPointer(t),n=0,r=0,s=0,a=0,o=0,l=0,h=this._textLines.length;l0&&(a+=this._textLines[l-1].length+this.missingNewlineOffset(l-1));r=this._getLineLeftOffset(o)*this.scaleX,e=this._textLines[o],"rtl"===this.direction&&(i.x=this.width*this.scaleX-i.x+r);for(var c=0,d=e.length;cs||a<0?0:1);return this.flipX&&(o=r-o),o>this._text.length&&(o=this._text.length),o}}),b.util.object.extend(b.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=b.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var t=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+t.top+"; left: "+t.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; paddingーtop: "+t.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):b.document.body.appendChild(this.hiddenTextarea),b.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),b.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),b.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),b.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),b.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),b.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),b.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),b.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),b.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(b.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(this.isEditing){var e="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())},onInput:function(t){var e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),this.isEditing){var i,n,r,s,a,o=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,l=this._text.length,h=o.length,c=h-l,d=this.selectionStart,u=this.selectionEnd,f=d!==u;if(""===this.hiddenTextarea.value)return this.styles={},this.updateFromTextArea(),this.fire("changed"),void(this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll()));var g=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),m=d>g.selectionStart;f?(i=this._text.slice(d,u),c+=u-d):h0&&(n+=(i=this.__charBounds[t][e-1]).left+i.width),n},getDownCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(r===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;var s=n.charIndex,a=this._getWidthBeforeCursor(r,s),o=this._getIndexOnLine(r+1,a);return this._textLines[r].slice(s).length+o+1+this.missingNewlineOffset(r)},_getSelectionForOffset:function(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(0===r||t.metaKey||33===t.keyCode)return-i;var s=n.charIndex,a=this._getWidthBeforeCursor(r,s),o=this._getIndexOnLine(r-1,a),l=this._textLines[r].slice(0,s),h=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+o-l.length+(1-h)},_getIndexOnLine:function(t,e){for(var i,n,r=this._textLines[t],s=this._getLineLeftOffset(t),a=0,o=0,l=r.length;oe){n=!0;var h=s-i,c=s,d=Math.abs(h-e);a=Math.abs(c-e)=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)},moveCursorUp:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)},_moveCursorUpOrDown:function(t,e){var i=this["get"+t+"CursorOffset"](e,"right"===this._selectionDirection);e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(t){var e="left"===this._selectionDirection?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t},moveCursorWithoutShift:function(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t},moveCursorLeft:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)},_move:function(t,e,i){var n;if(t.altKey)n=this["findWordBoundary"+i](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;n=this["findLineBoundary"+i](this[e])}if(void 0!==typeof n&&this[e]!==n)return this[e]=n,!0},_moveLeft:function(t,e){return this._move(t,e,"Left")},_moveRight:function(t,e){return this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){var e=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e},moveCursorLeftWithShift:function(t){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(t,"selectionStart")):void 0},moveCursorRight:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)},_moveCursorLeftOrRight:function(t,e){var i="moveCursor"+t+"With";this._currentCursorOpacity=1,e.shiftKey?i+="Shift":i+="outShift",this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(t){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection="right",this._moveRight(t,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(t){var e=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e},removeChars:function(t,e){void 0===e&&(e=t+1),this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(t,e,i,n){void 0===n&&(n=i),n>i&&this.removeStyleFromTo(i,n);var r=b.util.string.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[].concat(this._text.slice(0,i),r,this._text.slice(n)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),function(){var t=b.util.toFixed,e=/ +/g;b.util.object.extend(b.Text.prototype,{_toSVG:function(){var t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(t){var e=this.getSvgTextDecoration(this);return[t.textBgRects.join(""),'\t\t",t.textSpans.join(""),"\n"]},_getSVGTextAndBg:function(t,e){var i,n=[],r=[],s=t;this._setSVGBg(r);for(var a=0,o=this._textLines.length;a",b.util.string.escapeXml(i),""].join("")},_setSVGTextLineText:function(t,e,i,n){var r,s,a,o,l,h=this.getHeightOfLine(e),c=-1!==this.textAlign.indexOf("justify"),d="",u=0,f=this._textLines[e];n+=h*(1-this._fontSizeFraction)/this.lineHeight;for(var g=0,m=f.length-1;g<=m;g++)l=g===m||this.charSpacing,d+=f[g],a=this.__charBounds[e][g],0===u?(i+=a.kernedWidth-a.width,u+=a.width):u+=a.kernedWidth,c&&!l&&this._reSpaceAndTab.test(f[g])&&(l=!0),l||(r=r||this.getCompleteStyleDeclaration(e,g),s=this.getCompleteStyleDeclaration(e,g+1),l=this._hasStyleChangedForSvg(r,s)),l&&(o=this._getStyleDeclaration(e,g)||{},t.push(this._createTextCharSpan(d,o,i,n)),d="",r=s,i+=u,u=0)},_pushTextBgRect:function(e,i,n,r,s,a){var o=b.Object.NUM_FRACTION_DIGITS;e.push("\t\t\n')},_setSVGTextLineBg:function(t,e,i,n){for(var r,s,a=this._textLines[e],o=this.getHeightOfLine(e)/this.lineHeight,l=0,h=0,c=this.getValueOfPropertyAt(e,0,"textBackgroundColor"),d=0,u=a.length;dthis.width&&this._set("width",this.dynamicMinWidth),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(t){for(var e=0,i=0,n=0,r={},s=0;s0?(i=0,n++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[n])&&s>0&&(i++,n++),r[s]={line:e,offset:i},n+=t.graphemeLines[s].length,i+=t.graphemeLines[s].length;return r},styleHas:function(t,i){if(this._styleMap&&!this.isWrapping){var n=this._styleMap[i];n&&(i=n.line)}return e.Text.prototype.styleHas.call(this,t,i)},isEmptyStyles:function(t){if(!this.styles)return!0;var e,i,n=0,r=!1,s=this._styleMap[t],a=this._styleMap[t+1];for(var o in s&&(t=s.line,n=s.offset),a&&(r=a.line===t,e=a.offset),i=void 0===t?this.styles:{line:this.styles[t]})for(var l in i[o])if(l>=n&&(!r||ln&&!p?(o.push(l),l=[],s=f,p=!0):s+=_,p||a||l.push(u),l=l.concat(c),g=a?0:this._measureWord([u],i,d),d++,p=!1,f>m&&(m=f);return v&&o.push(l),m+r>this.dynamicMinWidth&&(this.dynamicMinWidth=m-_+r),o},isEndOfWrapping:function(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line},missingNewlineOffset:function(t){return this.splitByGrapheme?this.isEndOfWrapping(t)?1:0:1},_splitTextIntoLines:function(t){for(var i=e.Text.prototype._splitTextIntoLines.call(this,t),n=this._wrapText(i.lines,this.width),r=new Array(n.length),s=0;s{},898:()=>{},245:()=>{}},ni={};function ri(t){var e=ni[t];if(void 0!==e)return e.exports;var i=ni[t]={exports:{}};return ii[t](i,i.exports,ri),i.exports}ri.d=(t,e)=>{for(var i in e)ri.o(e,i)&&!ri.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},ri.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var si={};(()=>{let t;ri.d(si,{R:()=>t}),t="undefined"!=typeof document&&"undefined"!=typeof window?ri(653).fabric:{version:"5.2.1"}})();var ai,oi,li,hi,ci=si.R;!function(t){t[t.DIMT_RECTANGLE=1]="DIMT_RECTANGLE",t[t.DIMT_QUADRILATERAL=2]="DIMT_QUADRILATERAL",t[t.DIMT_TEXT=4]="DIMT_TEXT",t[t.DIMT_ARC=8]="DIMT_ARC",t[t.DIMT_IMAGE=16]="DIMT_IMAGE",t[t.DIMT_POLYGON=32]="DIMT_POLYGON",t[t.DIMT_LINE=64]="DIMT_LINE",t[t.DIMT_GROUP=128]="DIMT_GROUP"}(ai||(ai={})),function(t){t[t.DIS_DEFAULT=1]="DIS_DEFAULT",t[t.DIS_SELECTED=2]="DIS_SELECTED"}(oi||(oi={})),function(t){t[t.EF_ENHANCED_FOCUS=4]="EF_ENHANCED_FOCUS",t[t.EF_AUTO_ZOOM=16]="EF_AUTO_ZOOM",t[t.EF_TAP_TO_FOCUS=64]="EF_TAP_TO_FOCUS"}(li||(li={})),function(t){t.GREY="grey",t.GREY32="grey32",t.RGBA="rgba",t.RBGA="rbga",t.GRBA="grba",t.GBRA="gbra",t.BRGA="brga",t.BGRA="bgra"}(hi||(hi={}));const di=t=>"number"==typeof t&&!Number.isNaN(t),ui=t=>"string"==typeof t;var fi,gi,mi,pi,_i,vi,yi,wi,Ci,Ei,Si;!function(t){t[t.ARC=0]="ARC",t[t.IMAGE=1]="IMAGE",t[t.LINE=2]="LINE",t[t.POLYGON=3]="POLYGON",t[t.QUAD=4]="QUAD",t[t.RECT=5]="RECT",t[t.TEXT=6]="TEXT",t[t.GROUP=7]="GROUP"}(_i||(_i={})),function(t){t[t.DEFAULT=0]="DEFAULT",t[t.SELECTED=1]="SELECTED"}(vi||(vi={}));class bi{get mediaType(){return new Map([["rect",ai.DIMT_RECTANGLE],["quad",ai.DIMT_QUADRILATERAL],["text",ai.DIMT_TEXT],["arc",ai.DIMT_ARC],["image",ai.DIMT_IMAGE],["polygon",ai.DIMT_POLYGON],["line",ai.DIMT_LINE],["group",ai.DIMT_GROUP]]).get(this._mediaType)}get styleSelector(){switch(Je(this,gi,"f")){case oi.DIS_DEFAULT:return"default";case oi.DIS_SELECTED:return"selected"}}set drawingStyleId(t){this.styleId=t}get drawingStyleId(){return this.styleId}set coordinateBase(t){if(!["view","image"].includes(t))throw new Error("Invalid 'coordinateBase'.");this._drawingLayer&&("image"===Je(this,mi,"f")&&"view"===t?this.updateCoordinateBaseFromImageToView():"view"===Je(this,mi,"f")&&"image"===t&&this.updateCoordinateBaseFromViewToImage()),Ke(this,mi,t)}get coordinateBase(){return Je(this,mi,"f")}get drawingLayerId(){return this._drawingLayerId}constructor(t,e){if(fi.add(this),gi.set(this,void 0),mi.set(this,"image"),this._zIndex=null,this._drawingLayer=null,this._drawingLayerId=null,this._mapState_StyleId=new Map,this.mapEvent_Callbacks=new Map([["selected",new Map],["deselected",new Map],["mousedown",new Map],["mouseup",new Map],["dblclick",new Map],["mouseover",new Map],["mouseout",new Map]]),this.mapNoteName_Content=new Map([]),this.isDrawingItem=!0,null!=e&&!di(e))throw new TypeError("Invalid 'drawingStyleId'.");t&&this._setFabricObject(t),this.setState(oi.DIS_DEFAULT),this.styleId=e}_setFabricObject(t){this._fabricObject=t,this._fabricObject.on("selected",(()=>{this.setState(oi.DIS_SELECTED)})),this._fabricObject.on("deselected",(()=>{this._fabricObject.canvas&&this._fabricObject.canvas.getActiveObjects().includes(this._fabricObject)?this.setState(oi.DIS_SELECTED):this.setState(oi.DIS_DEFAULT),"textbox"===this._fabricObject.type&&(this._fabricObject.isEditing&&this._fabricObject.exitEditing(),this._fabricObject.selected=!1)})),t.getDrawingItem=()=>this}_getFabricObject(){return this._fabricObject}setState(t){Ke(this,gi,t)}getState(){return Je(this,gi,"f")}_on(t,e){if(!e)return;const i=t.toLowerCase(),n=this.mapEvent_Callbacks.get(i);if(!n)throw new Error(`Event '${t}' does not exist.`);let r=n.get(e);r||(r=t=>{const i=t.e;if(!i)return void(e&&e.apply(this,[{targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null}]));const n={targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null};if(this._drawingLayer){let t,e,r,s;const a=i.target.getBoundingClientRect();t=a.left,e=a.top,r=t+window.scrollX,s=e+window.scrollY;const{width:o,height:l}=this._drawingLayer.fabricCanvas.lowerCanvasEl.getBoundingClientRect(),h=this._drawingLayer.width,c=this._drawingLayer.height,d=o/l,u=h/c,f=this._drawingLayer._getObjectFit();let g,m,p,_,v=1;if("contain"===f)d0?i-1:n,Oi),actionName:"modifyPolygon",pointIndex:i}),t}),{}),Ke(this,wi,JSON.parse(JSON.stringify(t))),this._mediaType="polygon"}extendSet(t,e){if("vertices"===t){const t=this._fabricObject;if(t.group){const i=t.group;t.points=e.map((t=>({x:t.x-i.left-i.width/2,y:t.y-i.top-i.height/2}))),i.addWithUpdate()}else t.points=e;const i=t.points.length-1;return t.controls=t.points.reduce((function(t,e,n){return t["p"+n]=new ci.Control({positionHandler:Ii,actionHandler:Ai(n>0?n-1:i,Oi),actionName:"modifyPolygon",pointIndex:n}),t}),{}),t._setPositionDimensions({}),!0}}extendGet(t){if("vertices"===t){const t=[],e=this._fabricObject;if(e.selectable&&!e.group)for(let i in e.oCoords)t.push({x:e.oCoords[i].x,y:e.oCoords[i].y});else for(let i of e.points){let n=i.x-e.pathOffset.x,r=i.y-e.pathOffset.y;const s=ci.util.transformPoint({x:n,y:r},e.calcTransformMatrix());t.push({x:s.x,y:s.y})}return t}}updateCoordinateBaseFromImageToView(){const t=this.get("vertices").map((t=>({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",t)}updateCoordinateBaseFromViewToImage(){const t=this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})));this.set("vertices",t)}setPosition(t){this.setPolygon(t)}getPosition(){return this.getPolygon()}updatePosition(){Je(this,wi,"f")&&this.setPolygon(Je(this,wi,"f"))}setPolygon(t){if(!I(t))throw new TypeError("Invalid 'polygon'.");if(this._drawingLayer){if("view"===this.coordinateBase){const e=t.points.map((t=>({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",e)}else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("vertices",t.points)}this._drawingLayer.renderAll()}else Ke(this,wi,JSON.parse(JSON.stringify(t)))}getPolygon(){if(this._drawingLayer){if("view"===this.coordinateBase)return{points:this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})))};if("image"===this.coordinateBase)return{points:this.get("vertices")};throw new Error("Invalid 'coordinateBase'.")}return Je(this,wi,"f")?JSON.parse(JSON.stringify(Je(this,wi,"f"))):null}}wi=new WeakMap;class Di extends bi{set maintainAspectRatio(t){t&&this.set("scaleY",this.get("scaleX"))}get maintainAspectRatio(){return Je(this,Ei,"f")}constructor(t,e,i,n){if(super(null,n),Ci.set(this,void 0),Ei.set(this,void 0),!O(e))throw new TypeError("Invalid 'rect'.");if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement)this._setFabricObject(new ci.Image(t,{left:e.x,top:e.y}));else{if(!C(t))throw new TypeError("Invalid 'image'.");{const i=document.createElement("canvas");let n;if(i.width=t.width,i.height=t.height,t.format===o.IPF_GRAYSCALED){n=new Uint8ClampedArray(t.width*t.height*4);for(let e=0;e{let e=(t=>t.split("\n").map((t=>t.split("\t"))))(t);return(t=>{for(let e=0;;e++){let i=-1;for(let n=0;ni&&(i=r.length)}if(-1===i)break;for(let n=0;n=t[n].length-1)continue;let r=" ".repeat(i+2-t[n][e].length);t[n][e]=t[n][e].concat(r)}}})(e),(t=>{let e="";for(let i=0;i({x:e.x-t.left-t.width/2,y:e.y-t.top-t.height/2}))),t.addWithUpdate()}else i.points=e;const n=i.points.length-1;return i.controls=i.points.reduce((function(t,e,i){return t["p"+i]=new ci.Control({positionHandler:Ii,actionHandler:Ai(i>0?i-1:n,Oi),actionName:"modifyPolygon",pointIndex:i}),t}),{}),i._setPositionDimensions({}),!0}}extendGet(t){if("startPoint"===t||"endPoint"===t){const e=[],i=this._fabricObject;if(i.selectable&&!i.group)for(let t in i.oCoords)e.push({x:i.oCoords[t].x,y:i.oCoords[t].y});else for(let t of i.points){let n=t.x-i.pathOffset.x,r=t.y-i.pathOffset.y;const s=ci.util.transformPoint({x:n,y:r},i.calcTransformMatrix());e.push({x:s.x,y:s.y})}return"startPoint"===t?e[0]:e[1]}}updateCoordinateBaseFromImageToView(){const t=this.get("startPoint"),e=this.get("endPoint");this.set("startPoint",{x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)}),this.set("endPoint",{x:this.convertPropFromViewToImage(e.x),y:this.convertPropFromViewToImage(e.y)})}updateCoordinateBaseFromViewToImage(){const t=this.get("startPoint"),e=this.get("endPoint");this.set("startPoint",{x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)}),this.set("endPoint",{x:this.convertPropFromImageToView(e.x),y:this.convertPropFromImageToView(e.y)})}setPosition(t){this.setLine(t)}getPosition(){return this.getLine()}updatePosition(){Je(this,Fi,"f")&&this.setLine(Je(this,Fi,"f"))}setPolygon(){}getPolygon(){return null}setLine(t){if(!b(t))throw new TypeError("Invalid 'line'.");if(this._drawingLayer){if("view"===this.coordinateBase)this.set("startPoint",{x:this.convertPropFromViewToImage(t.startPoint.x),y:this.convertPropFromViewToImage(t.startPoint.y)}),this.set("endPoint",{x:this.convertPropFromViewToImage(t.endPoint.x),y:this.convertPropFromViewToImage(t.endPoint.y)});else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("startPoint",t.startPoint),this.set("endPoint",t.endPoint)}this._drawingLayer.renderAll()}else Ke(this,Fi,JSON.parse(JSON.stringify(t)))}getLine(){if(this._drawingLayer){if("view"===this.coordinateBase)return{startPoint:{x:this.convertPropFromImageToView(this.get("startPoint").x),y:this.convertPropFromImageToView(this.get("startPoint").y)},endPoint:{x:this.convertPropFromImageToView(this.get("endPoint").x),y:this.convertPropFromImageToView(this.get("endPoint").y)}};if("image"===this.coordinateBase)return{startPoint:this.get("startPoint"),endPoint:this.get("endPoint")};throw new Error("Invalid 'coordinateBase'.")}return Je(this,Fi,"f")?JSON.parse(JSON.stringify(Je(this,Fi,"f"))):null}}Fi=new WeakMap;class Ni extends Ri{constructor(t,e){if(super({points:null==t?void 0:t.points},e),Pi.set(this,void 0),!x(t))throw new TypeError("Invalid 'quad'.");Ke(this,Pi,JSON.parse(JSON.stringify(t))),this._mediaType="quad"}setPosition(t){this.setQuad(t)}getPosition(){return this.getQuad()}updatePosition(){Je(this,Pi,"f")&&this.setQuad(Je(this,Pi,"f"))}setPolygon(){}getPolygon(){return null}setQuad(t){if(!x(t))throw new TypeError("Invalid 'quad'.");if(this._drawingLayer){if("view"===this.coordinateBase){const e=t.points.map((t=>({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",e)}else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("vertices",t.points)}this._drawingLayer.renderAll()}else Ke(this,Pi,JSON.parse(JSON.stringify(t)))}getQuad(){if(this._drawingLayer){if("view"===this.coordinateBase)return{points:this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})))};if("image"===this.coordinateBase)return{points:this.get("vertices")};throw new Error("Invalid 'coordinateBase'.")}return Je(this,Pi,"f")?JSON.parse(JSON.stringify(Je(this,Pi,"f"))):null}}Pi=new WeakMap;class Bi extends bi{constructor(t){super(new ci.Group(t.map((t=>t._getFabricObject())))),this._fabricObject.on("selected",(()=>{this.setState(oi.DIS_SELECTED);const t=this._fabricObject._objects;for(let e of t)setTimeout((()=>{e&&e.fire("selected")}),0);setTimeout((()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())}),0)})),this._fabricObject.on("deselected",(()=>{this.setState(oi.DIS_DEFAULT);const t=this._fabricObject._objects;for(let e of t)setTimeout((()=>{e&&e.fire("deselected")}),0);setTimeout((()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())}),0)})),this._mediaType="group"}extendSet(t,e){return!1}extendGet(t){}updateCoordinateBaseFromImageToView(){}updateCoordinateBaseFromViewToImage(){}setPosition(){}getPosition(){}updatePosition(){}getChildDrawingItems(){return this._fabricObject._objects.map((t=>t.getDrawingItem()))}setChildDrawingItems(t){if(!t||!t.isDrawingItem)throw TypeError("Illegal drawing item.");this._drawingLayer?this._drawingLayer._updateGroupItem(this,t,"add"):this._fabricObject.addWithUpdate(t._getFabricObject())}removeChildItem(t){t&&t.isDrawingItem&&(this._drawingLayer?this._drawingLayer._updateGroupItem(this,t,"remove"):this._fabricObject.removeWithUpdate(t._getFabricObject()))}}const ji=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),Vi=t=>!!ui(t)&&""!==t,Ui=t=>!(!ji(t)||"id"in t&&!di(t.id)||"lineWidth"in t&&!di(t.lineWidth)||"fillStyle"in t&&!Vi(t.fillStyle)||"strokeStyle"in t&&!Vi(t.strokeStyle)||"paintMode"in t&&!["fill","stroke","strokeAndFill"].includes(t.paintMode)||"fontFamily"in t&&!Vi(t.fontFamily)||"fontSize"in t&&!di(t.fontSize));class Gi{static convert(t,e,i){const n={x:0,y:0,width:e,height:i};if(!t)return n;if(O(t))t.isMeasuredInPercentage?(n.x=t.x/100*e,n.y=t.y/100*i,n.width=t.width/100*e,n.height=t.height/100*i):(n.x=t.x,n.y=t.y,n.width=t.width,n.height=t.height);else{if(!E(t))throw TypeError("Invalid region.");t.isMeasuredInPercentage?(n.x=t.left/100*e,n.y=t.top/100*i,n.width=(t.right-t.left)/100*e,n.height=(t.bottom-t.top)/100*i):(n.x=t.left,n.y=t.top,n.width=t.right-t.left,n.height=t.bottom-t.top)}return n.x=Math.round(n.x),n.y=Math.round(n.y),n.width=Math.round(n.width),n.height=Math.round(n.height),n}}var Wi,Yi;class zi{constructor(){Wi.set(this,new Map),Yi.set(this,!1)}get disposed(){return Je(this,Yi,"f")}on(t,e){t=t.toLowerCase();const i=Je(this,Wi,"f").get(t);if(i){if(i.includes(e))return;i.push(e)}else Je(this,Wi,"f").set(t,[e])}off(t,e){t=t.toLowerCase();const i=Je(this,Wi,"f").get(t);if(!i)return;const n=i.indexOf(e);-1!==n&&i.splice(n,1)}offAll(t){t=t.toLowerCase();const e=Je(this,Wi,"f").get(t);e&&(e.length=0)}fire(t,e=[],i={async:!1,copy:!0}){e||(e=[]),t=t.toLowerCase();const n=Je(this,Wi,"f").get(t);if(n&&n.length){i=Object.assign({async:!1,copy:!0},i);for(let r of n){if(!r)continue;let s=[];if(i.copy)for(let i of e){try{i=JSON.parse(JSON.stringify(i))}catch(t){}s.push(i)}else s=e;let a=!1;if(i.async)setTimeout((()=>{this.disposed||n.includes(r)&&r.apply(i.target,s)}),0);else try{a=r.apply(i.target,s)}catch(t){}if(!0===a)break}}}dispose(){Ke(this,Yi,!0)}}function Hi(t,e,i){return(i.x-t.x)*(e.y-t.y)==(e.x-t.x)*(i.y-t.y)&&Math.min(t.x,e.x)<=i.x&&i.x<=Math.max(t.x,e.x)&&Math.min(t.y,e.y)<=i.y&&i.y<=Math.max(t.y,e.y)}function Xi(t){return Math.abs(t)<1e-6?0:t<0?-1:1}function Zi(t,e,i,n){let r=t[0]*(i[1]-e[1])+e[0]*(t[1]-i[1])+i[0]*(e[1]-t[1]),s=t[0]*(n[1]-e[1])+e[0]*(t[1]-n[1])+n[0]*(e[1]-t[1]);return!((r^s)>=0&&0!==r&&0!==s||(r=i[0]*(t[1]-n[1])+n[0]*(i[1]-t[1])+t[0]*(n[1]-i[1]),s=i[0]*(e[1]-n[1])+n[0]*(i[1]-e[1])+e[0]*(n[1]-i[1]),(r^s)>=0&&0!==r&&0!==s))}Wi=new WeakMap,Yi=new WeakMap;const qi=async t=>{if("string"!=typeof t)throw new TypeError("Invalid url.");const e=await fetch(t);if(!e.ok)throw Error("Network Error: "+e.statusText);const i=await e.text();if(!i.trim().startsWith("<"))throw Error("Unable to get valid HTMLElement.");const n=document.createElement("div");if(n.insertAdjacentHTML("beforeend",i),1===n.childElementCount&&n.firstChild instanceof HTMLTemplateElement)return n.firstChild.content;const r=new DocumentFragment;for(let t of n.children)r.append(t);return r};var Ji,Ki,$i,Qi,tn,en,nn,rn,sn,an,on,ln,hn,cn,dn,un,fn,gn,mn,pn,_n,vn,yn,wn,Cn,En,Sn,bn,Tn,In,xn,On,An,Rn;class Dn{static createDrawingStyle(t){if(!Ui(t))throw new Error("Invalid style definition.");let e,i=Dn.USER_START_STYLE_ID;for(;Je(Dn,Ji,"f",Ki).has(i);)i++;e=i;const n=JSON.parse(JSON.stringify(t));n.id=e;for(let t in Je(Dn,Ji,"f",$i))n.hasOwnProperty(t)||(n[t]=Je(Dn,Ji,"f",$i)[t]);return Je(Dn,Ji,"f",Ki).set(e,n),n.id}static _getDrawingStyle(t,e){if("number"!=typeof t)throw new Error("Invalid style id.");const i=Je(Dn,Ji,"f",Ki).get(t);return i?e?JSON.parse(JSON.stringify(i)):i:null}static getDrawingStyle(t){return this._getDrawingStyle(t,!0)}static getAllDrawingStyles(){return JSON.parse(JSON.stringify(Array.from(Je(Dn,Ji,"f",Ki).values())))}static _updateDrawingStyle(t,e){if(!Ui(e))throw new Error("Invalid style definition.");const i=Je(Dn,Ji,"f",Ki).get(t);if(i)for(let t in e)i.hasOwnProperty(t)&&(i[t]=e[t])}static updateDrawingStyle(t,e){this._updateDrawingStyle(t,e)}}Ji=Dn,Dn.STYLE_BLUE_STROKE=1,Dn.STYLE_GREEN_STROKE=2,Dn.STYLE_ORANGE_STROKE=3,Dn.STYLE_YELLOW_STROKE=4,Dn.STYLE_BLUE_STROKE_FILL=5,Dn.STYLE_GREEN_STROKE_FILL=6,Dn.STYLE_ORANGE_STROKE_FILL=7,Dn.STYLE_YELLOW_STROKE_FILL=8,Dn.STYLE_BLUE_STROKE_TRANSPARENT=9,Dn.STYLE_GREEN_STROKE_TRANSPARENT=10,Dn.STYLE_ORANGE_STROKE_TRANSPARENT=11,Dn.USER_START_STYLE_ID=1024,Ki={value:new Map([[Dn.STYLE_BLUE_STROKE,{id:Dn.STYLE_BLUE_STROKE,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[Dn.STYLE_GREEN_STROKE,{id:Dn.STYLE_GREEN_STROKE,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dn.STYLE_ORANGE_STROKE,{id:Dn.STYLE_ORANGE_STROKE,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dn.STYLE_YELLOW_STROKE,{id:Dn.STYLE_YELLOW_STROKE,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[Dn.STYLE_BLUE_STROKE_FILL,{id:Dn.STYLE_BLUE_STROKE_FILL,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dn.STYLE_GREEN_STROKE_FILL,{id:Dn.STYLE_GREEN_STROKE_FILL,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dn.STYLE_ORANGE_STROKE_FILL,{id:Dn.STYLE_ORANGE_STROKE_FILL,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dn.STYLE_YELLOW_STROKE_FILL,{id:Dn.STYLE_YELLOW_STROKE_FILL,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dn.STYLE_BLUE_STROKE_TRANSPARENT,{id:Dn.STYLE_BLUE_STROKE_TRANSPARENT,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dn.STYLE_GREEN_STROKE_TRANSPARENT,{id:Dn.STYLE_GREEN_STROKE_TRANSPARENT,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[Dn.STYLE_ORANGE_STROKE_TRANSPARENT,{id:Dn.STYLE_ORANGE_STROKE_TRANSPARENT,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}]])},$i={value:{lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}},"undefined"!=typeof document&&"undefined"!=typeof window&&(ci.StaticCanvas.prototype.dispose=function(){return this.isRendering&&(ci.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject((function(t){t.dispose&&t.dispose()})),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),ci.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},ci.Object.prototype.transparentCorners=!1,ci.Object.prototype.cornerSize=20,ci.Object.prototype.touchCornerSize=100,ci.Object.prototype.cornerColor="rgb(254,142,20)",ci.Object.prototype.cornerStyle="circle",ci.Object.prototype.strokeUniform=!0,ci.Object.prototype.hasBorders=!1,ci.Canvas.prototype.containerClass="",ci.Canvas.prototype.getPointer=function(t,e){if(this._absolutePointer&&!e)return this._absolutePointer;if(this._pointer&&e)return this._pointer;var i,n=this.upperCanvasEl,r=ci.util.getPointer(t,n),s=n.getBoundingClientRect(),a=s.width||0,o=s.height||0;a&&o||("top"in s&&"bottom"in s&&(o=Math.abs(s.top-s.bottom)),"right"in s&&"left"in s&&(a=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=this.restorePointerVpt(r));var l=this.getRetinaScaling();if(1!==l&&(r.x/=l,r.y/=l),0!==a&&0!==o){var h=window.getComputedStyle(n).objectFit,c=n.width,d=n.height,u=a,f=o;i={width:c/u,height:d/f};var g,m,p=c/d,_=u/f;return"contain"===h?p>_?(g=u,m=u/p,{x:r.x*i.width,y:(r.y-(f-m)/2)*i.width}):(g=f*p,m=f,{x:(r.x-(u-g)/2)*i.height,y:r.y*i.height}):"cover"===h?p>_?{x:(c-i.height*u)/2+r.x*i.height,y:r.y*i.height}:{x:r.x*i.width,y:(d-i.width*f)/2+r.y*i.width}:{x:r.x*i.width,y:r.y*i.height}}return i={width:1,height:1},{x:r.x*i.width,y:r.y*i.height}},ci.Canvas.prototype._onTouchStart=function(t){var e=this.findTarget(t);!this.allowTouchScrolling&&t.cancelable&&t.preventDefault&&t.preventDefault(),e&&t.cancelable&&t.preventDefault&&t.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),this._resetTransformEventData();var i=this.upperCanvasEl,n=this._getEventPrefix();ci.util.addListener(ci.document,"touchend",this._onTouchEnd,{passive:!1}),ci.util.addListener(ci.document,"touchmove",this._onMouseMove,{passive:!1}),ci.util.removeListener(i,n+"down",this._onMouseDown)},ci.Textbox.prototype._wrapLine=function(t,e,i,n){const r=t.match(/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f]/g),s=!(!r||!r.length);var a=0,o=this.splitByGrapheme||s,l=[],h=[],c=o?ci.util.string.graphemeSplit(t):t.split(this._wordJoiners),d="",u=0,f=o?"":" ",g=0,m=0,p=0,_=!0,v=this._getWidthOfCharSpacing();n=n||0,0===c.length&&c.push([]),i-=n;for(var y=0;yi&&!_?(l.push(h),h=[],a=g,_=!0):a+=v,_||o||h.push(f),h=h.concat(d),m=o?0:this._measureWord([f],e,u),u++,_=!1,g>p&&(p=g);return y&&l.push(h),p+n>this.dynamicMinWidth&&(this.dynamicMinWidth=p-v+n),l});class Ln{get width(){return this.fabricCanvas.width}get height(){return this.fabricCanvas.height}set _allowMultiSelect(t){this.fabricCanvas.selection=t,this.fabricCanvas.renderAll()}get _allowMultiSelect(){return this.fabricCanvas.selection}constructor(t,e,i){if(this.mapType_StateAndStyleId=new Map,this.mode="viewer",this.onSelectionChanged=null,this._arrDrwaingItem=[],this._arrFabricObject=[],this._visible=!0,t.hasOwnProperty("getFabricCanvas"))this.fabricCanvas=t.getFabricCanvas();else{let e=this.fabricCanvas=new ci.Canvas(t,Object.assign(i,{allowTouchScrolling:!0,selection:!1}));e.setDimensions({width:"100%",height:"100%"},{cssOnly:!0}),e.lowerCanvasEl.className="",e.upperCanvasEl.className="",e.on("selection:created",(function(t){const e=t.selected,i=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!i.includes(e)&&i.push(e)}for(let t of i){const i=[];for(let n of e){const e=n.getDrawingItem();e._drawingLayer===t&&i.push(e)}setTimeout((()=>{t.onSelectionChanged&&t.onSelectionChanged(i,[])}),0)}})),e.on("before:selection:cleared",(function(t){const e=this.getActiveObjects(),i=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!i.includes(e)&&i.push(e)}for(let t of i){const i=[];for(let n of e){const e=n.getDrawingItem();e._drawingLayer===t&&i.push(e)}setTimeout((()=>{const e=[];for(let n of i)t.hasDrawingItem(n)&&e.push(n);e.length>0&&t.onSelectionChanged&&t.onSelectionChanged([],e)}),0)}})),e.on("selection:updated",(function(t){const e=t.selected,i=t.deselected,n=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!n.includes(e)&&n.push(e)}for(let t of i){const e=t.getDrawingItem()._drawingLayer;e&&!n.includes(e)&&n.push(e)}for(let t of n){const n=[],r=[];for(let i of e){const e=i.getDrawingItem();e._drawingLayer===t&&n.push(e)}for(let e of i){const i=e.getDrawingItem();i._drawingLayer===t&&r.push(i)}setTimeout((()=>{t.onSelectionChanged&&t.onSelectionChanged(n,r)}),0)}})),e.wrapperEl.style.position="absolute",t.getFabricCanvas=()=>this.fabricCanvas}let n,r;switch(this.id=e,e){case Ln.DDN_LAYER_ID:n=Dn.getDrawingStyle(Dn.STYLE_BLUE_STROKE),r=Dn.getDrawingStyle(Dn.STYLE_BLUE_STROKE_FILL);break;case Ln.DBR_LAYER_ID:n=Dn.getDrawingStyle(Dn.STYLE_ORANGE_STROKE),r=Dn.getDrawingStyle(Dn.STYLE_ORANGE_STROKE_FILL);break;case Ln.DLR_LAYER_ID:n=Dn.getDrawingStyle(Dn.STYLE_GREEN_STROKE),r=Dn.getDrawingStyle(Dn.STYLE_GREEN_STROKE_FILL);break;default:n=Dn.getDrawingStyle(Dn.STYLE_YELLOW_STROKE),r=Dn.getDrawingStyle(Dn.STYLE_YELLOW_STROKE_FILL)}for(let t of bi.arrMediaTypes)this.mapType_StateAndStyleId.set(t,{default:n.id,selected:r.id})}getId(){return this.id}setVisible(t){if(t){for(let t of this._arrFabricObject)t.visible=!0,t.hasControls=!0;this._visible=!0}else{for(let t of this._arrFabricObject)t.visible=!1,t.hasControls=!1;this._visible=!1}this.fabricCanvas.renderAll()}isVisible(){return this._visible}_getItemCurrentStyle(t){if(t.styleId)return Dn.getDrawingStyle(t.styleId);return Dn.getDrawingStyle(t._mapState_StyleId.get(t.styleSelector))||null}_changeMediaTypeCurStyleInStyleSelector(t,e,i,n){const r=this.getDrawingItems((e=>e._mediaType===t));for(let t of r)t.styleSelector===e&&this._changeItemStyle(t,i,!0);n||this.fabricCanvas.renderAll()}_changeItemStyle(t,e,i){if(!t||!e)return;const n=t._getFabricObject();"number"==typeof t.styleId&&(e=Dn.getDrawingStyle(t.styleId)),n.strokeWidth=e.lineWidth,"fill"===e.paintMode?(n.fill=e.fillStyle,n.stroke=e.fillStyle):"stroke"===e.paintMode?(n.fill="transparent",n.stroke=e.strokeStyle):"strokeAndFill"===e.paintMode&&(n.fill=e.fillStyle,n.stroke=e.strokeStyle),n.fontFamily&&(n.fontFamily=e.fontFamily),n.fontSize&&(n.fontSize=e.fontSize),n.group||(n.dirty=!0),i||this.fabricCanvas.renderAll()}_updateGroupItem(t,e,i){if(!t||!e)return;const n=t.getChildDrawingItems();if("add"===i){if(n.includes(e))return;const i=e._getFabricObject();if(this.fabricCanvas.getObjects().includes(i)){if(!this._arrFabricObject.includes(i))throw new Error("Existed in other drawing layers.");e._zIndex=null}else{let i;if(e.styleId)i=Dn.getDrawingStyle(e.styleId);else{const n=this.mapType_StateAndStyleId.get(e._mediaType);i=Dn.getDrawingStyle(n[t.styleSelector]);const r=()=>{this._changeItemStyle(e,Dn.getDrawingStyle(this.mapType_StateAndStyleId.get(e._mediaType).selected),!0)},s=()=>{this._changeItemStyle(e,Dn.getDrawingStyle(this.mapType_StateAndStyleId.get(e._mediaType).default),!0)};e._on("selected",r),e._on("deselected",s),e._funcChangeStyleToSelected=r,e._funcChangeStyleToDefault=s}e._drawingLayer=this,e._drawingLayerId=this.id,this._changeItemStyle(e,i,!0)}t._fabricObject.addWithUpdate(e._getFabricObject())}else{if("remove"!==i)return;if(!n.includes(e))return;e._zIndex=null,e._drawingLayer=null,e._drawingLayerId=null,e._off("selected",e._funcChangeStyleToSelected),e._off("deselected",e._funcChangeStyleToDefault),e._funcChangeStyleToSelected=null,e._funcChangeStyleToDefault=null,t._fabricObject.removeWithUpdate(e._getFabricObject())}this.fabricCanvas.renderAll()}_addDrawingItem(t,e){if(!(t instanceof bi))throw new TypeError("Invalid 'drawingItem'.");if(t._drawingLayer){if(t._drawingLayer==this)return;throw new Error("This drawing item has existed in other layer.")}let i=t._getFabricObject();const n=this.fabricCanvas.getObjects();let r,s;if(n.includes(i)){if(this._arrFabricObject.includes(i))return;throw new Error("Existed in other drawing layers.")}if("group"===t._mediaType){r=t.getChildDrawingItems();for(let t of r)if(t._drawingLayer&&t._drawingLayer!==this)throw new Error("The childItems of DT_Group have existed in other drawing layers.")}if(e&&"object"==typeof e&&!Array.isArray(e))for(let t in e)i.set(t,e[t]);if(r){for(let t of r){const e=this.mapType_StateAndStyleId.get(t._mediaType);for(let i of bi.arrStyleSelectors)t._mapState_StyleId.set(i,e[i]);if(t.styleId)s=Dn.getDrawingStyle(t.styleId);else{s=Dn.getDrawingStyle(e.default);const i=()=>{this._changeItemStyle(t,Dn.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).selected),!0)},n=()=>{this._changeItemStyle(t,Dn.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).default),!0)};t._on("selected",i),t._on("deselected",n),t._funcChangeStyleToSelected=i,t._funcChangeStyleToDefault=n}t._drawingLayer=this,t._drawingLayerId=this.id,this._changeItemStyle(t,s,!0)}i.dirty=!0,this.fabricCanvas.renderAll()}else{const e=this.mapType_StateAndStyleId.get(t._mediaType);for(let i of bi.arrStyleSelectors)t._mapState_StyleId.set(i,e[i]);if(t.styleId)s=Dn.getDrawingStyle(t.styleId);else{s=Dn.getDrawingStyle(e.default);const i=()=>{this._changeItemStyle(t,Dn.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).selected))},n=()=>{this._changeItemStyle(t,Dn.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).default))};t._on("selected",i),t._on("deselected",n),t._funcChangeStyleToSelected=i,t._funcChangeStyleToDefault=n}this._changeItemStyle(t,s)}t._zIndex=this.id,t._drawingLayer=this,t._drawingLayerId=this.id;const a=this._arrFabricObject.length;let o=n.length;if(a)o=n.indexOf(this._arrFabricObject[a-1])+1;else for(let e=0;et.toLowerCase())):e=bi.arrMediaTypes,i?i.forEach((t=>t.toLowerCase())):i=bi.arrStyleSelectors;const n=Dn.getDrawingStyle(t);if(!n)throw new Error(`The 'drawingStyle' with id '${t}' doesn't exist.`);let r;for(let s of e)if(r=this.mapType_StateAndStyleId.get(s),r)for(let e of i){this._changeMediaTypeCurStyleInStyleSelector(s,e,n,!0),r[e]=t;for(let i of this._arrDrwaingItem)i._mediaType===s&&i._mapState_StyleId.set(e,t)}this.fabricCanvas.renderAll()}setDefaultStyle(t,e,i){const n=[];i&ai.DIMT_RECTANGLE&&n.push("rect"),i&ai.DIMT_QUADRILATERAL&&n.push("quad"),i&ai.DIMT_TEXT&&n.push("text"),i&ai.DIMT_ARC&&n.push("arc"),i&ai.DIMT_IMAGE&&n.push("image"),i&ai.DIMT_POLYGON&&n.push("polygon"),i&ai.DIMT_LINE&&n.push("line");const r=[];e&oi.DIS_DEFAULT&&r.push("default"),e&oi.DIS_SELECTED&&r.push("selected"),this._setDefaultStyle(t,n.length?n:null,r.length?r:null)}setMode(t){if("viewer"===(t=t.toLowerCase())){for(let t of this._arrDrwaingItem)t._setEditable(!1);this.fabricCanvas.discardActiveObject(),this.fabricCanvas.renderAll(),this.mode="viewer"}else{if("editor"!==t)throw new RangeError("Invalid value.");for(let t of this._arrDrwaingItem)t._setEditable(!0);this.mode="editor"}this._manager._switchPointerEvent()}getMode(){return this.mode}_setDimensions(t,e){this.fabricCanvas.setDimensions(t,e)}_setObjectFit(t){if(t=t.toLowerCase(),!["contain","cover"].includes(t))throw new Error(`Unsupported value '${t}'.`);this.fabricCanvas.lowerCanvasEl.style.objectFit=t,this.fabricCanvas.upperCanvasEl.style.objectFit=t}_getObjectFit(){return this.fabricCanvas.lowerCanvasEl.style.objectFit}renderAll(){for(let t of this._arrDrwaingItem){const e=this._getItemCurrentStyle(t);this._changeItemStyle(t,e,!0)}this.fabricCanvas.renderAll()}dispose(){this.clearDrawingItems(),1===this._manager._arrDrawingLayer.length&&(this.fabricCanvas.wrapperEl.style.pointerEvents="none",this.fabricCanvas.dispose(),this._arrDrwaingItem.length=0,this._arrFabricObject.length=0)}}Ln.DDN_LAYER_ID=1,Ln.DBR_LAYER_ID=2,Ln.DLR_LAYER_ID=3,Ln.USER_DEFINED_LAYER_BASE_ID=100,Ln.TIP_LAYER_ID=999;class Mn{constructor(){this._arrDrawingLayer=[]}createDrawingLayer(t,e){if(this.getDrawingLayer(e))throw new Error("Existed drawing layer id.");const i=new Ln(t,e,{enableRetinaScaling:!1});return i._manager=this,this._arrDrawingLayer.push(i),this._switchPointerEvent(),i}deleteDrawingLayer(t){const e=this.getDrawingLayer(t);if(!e)return;const i=this._arrDrawingLayer;e.dispose(),i.splice(i.indexOf(e),1),this._switchPointerEvent()}clearDrawingLayers(){for(let t of this._arrDrawingLayer)t.dispose();this._arrDrawingLayer.length=0}getDrawingLayer(t){for(let e of this._arrDrawingLayer)if(e.getId()===t)return e;return null}getAllDrawingLayers(){return Array.from(this._arrDrawingLayer)}getSelectedDrawingItems(){if(!this._arrDrawingLayer.length)return;const t=this._getFabricCanvas().getActiveObjects(),e=[];for(let i of t)e.push(i.getDrawingItem());return e}setDimensions(t,e){this._arrDrawingLayer.length&&this._arrDrawingLayer[0]._setDimensions(t,e)}setObjectFit(t){for(let e of this._arrDrawingLayer)e&&e._setObjectFit(t)}getObjectFit(){return this._arrDrawingLayer.length?this._arrDrawingLayer[0]._getObjectFit():null}setVisible(t){if(!this._arrDrawingLayer.length)return;this._getFabricCanvas().wrapperEl.style.display=t?"block":"none"}_getFabricCanvas(){return this._arrDrawingLayer.length?this._arrDrawingLayer[0].fabricCanvas:null}_switchPointerEvent(){if(this._arrDrawingLayer.length)for(let t of this._arrDrawingLayer)t.getMode()}}class Fn extends Mi{constructor(t,e,i,n,r){super(t,{x:e,y:i,width:n,height:0},r),Qi.set(this,void 0),tn.set(this,void 0),this._fabricObject.paddingTop=15,this._fabricObject.calcTextHeight=function(){for(var t=0,e=0,i=this._textLines.length;e=0&&Ke(this,tn,setTimeout((()=>{this.set("visible",!1),this._drawingLayer&&this._drawingLayer.renderAll()}),Je(this,Qi,"f")))}getDuration(){return Je(this,Qi,"f")}}Qi=new WeakMap,tn=new WeakMap;class Pn{constructor(){en.add(this),nn.set(this,void 0),rn.set(this,void 0),sn.set(this,void 0),an.set(this,!0),this._drawingLayerManager=new Mn}createDrawingLayerBaseCvs(t,e,i="contain"){if("number"!=typeof t||t<=1)throw new Error("Invalid 'width'.");if("number"!=typeof e||e<=1)throw new Error("Invalid 'height'.");if(!["contain","cover"].includes(i))throw new Error("Unsupported 'objectFit'.");const n=document.createElement("canvas");return n.width==t&&n.height==e||(n.width=t,n.height=e),n.style.objectFit=i,n}_createDrawingLayer(t,e,i,n){if(!this._layerBaseCvs){let r;try{r=this.getContentDimensions()}catch(t){if("Invalid content dimensions."!==(t.message||t))throw t}e||(e=(null==r?void 0:r.width)||1280),i||(i=(null==r?void 0:r.height)||720),n||(n=(null==r?void 0:r.objectFit)||"contain"),this._layerBaseCvs=this.createDrawingLayerBaseCvs(e,i,n)}const r=this._layerBaseCvs,s=this._drawingLayerManager.createDrawingLayer(r,t);return this._innerComponent.getElement("drawing-layer")||this._innerComponent.setElement("drawing-layer",r.parentElement),s}createDrawingLayer(){let t;for(let e=Ln.USER_DEFINED_LAYER_BASE_ID;;e++)if(!this._drawingLayerManager.getDrawingLayer(e)&&e!==Ln.TIP_LAYER_ID){t=e;break}return this._createDrawingLayer(t)}deleteDrawingLayer(t){var e;this._drawingLayerManager.deleteDrawingLayer(t),this._drawingLayerManager.getAllDrawingLayers().length||(null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null)}deleteUserDefinedDrawingLayer(t){if("number"!=typeof t)throw new TypeError("Invalid id.");if(tt.getId()>=0&&t.getId()!==Ln.TIP_LAYER_ID))}updateDrawingLayers(t){((t,e,i)=>{if(!(t<=1||e<=1)){if(!["contain","cover"].includes(i))throw new Error("Unsupported 'objectFit'.");this._drawingLayerManager.setDimensions({width:t,height:e},{backstoreOnly:!0}),this._drawingLayerManager.setObjectFit(i)}})(t.width,t.height,t.objectFit)}getSelectedDrawingItems(){return this._drawingLayerManager.getSelectedDrawingItems()}setTipConfig(t){if(!(ji(e=t)&&T(e.topLeftPoint)&&di(e.width))||e.width<=0||!di(e.duration)||"coordinateBase"in e&&!["view","image"].includes(e.coordinateBase))throw new Error("Invalid tip config.");var e;Ke(this,nn,JSON.parse(JSON.stringify(t))),Je(this,nn,"f").coordinateBase||(Je(this,nn,"f").coordinateBase="view"),Ke(this,sn,t.duration),Je(this,en,"m",cn).call(this)}getTipConfig(){return Je(this,nn,"f")?Je(this,nn,"f"):null}setTipVisible(t){if("boolean"!=typeof t)throw new TypeError("Invalid value.");this._tip&&(this._tip.set("visible",t),this._drawingLayerOfTip&&this._drawingLayerOfTip.renderAll()),Ke(this,an,t)}isTipVisible(){return Je(this,an,"f")}updateTipMessage(t){if(!Je(this,nn,"f"))throw new Error("Tip config is not set.");this._tipStyleId||(this._tipStyleId=Dn.createDrawingStyle({fillStyle:"#FFFFFF",paintMode:"fill",fontFamily:"Open Sans",fontSize:40})),this._drawingLayerOfTip||(this._drawingLayerOfTip=this._drawingLayerManager.getDrawingLayer(Ln.TIP_LAYER_ID)||this._createDrawingLayer(Ln.TIP_LAYER_ID)),this._tip?this._tip.set("text",t):this._tip=Je(this,en,"m",on).call(this,t,Je(this,nn,"f").topLeftPoint.x,Je(this,nn,"f").topLeftPoint.y,Je(this,nn,"f").width,Je(this,nn,"f").coordinateBase,this._tipStyleId),Je(this,en,"m",ln).call(this,this._tip,this._drawingLayerOfTip),this._tip.set("visible",Je(this,an,"f")),this._drawingLayerOfTip&&this._drawingLayerOfTip.renderAll(),Je(this,rn,"f")&&clearTimeout(Je(this,rn,"f")),Je(this,sn,"f")>=0&&Ke(this,rn,setTimeout((()=>{Je(this,en,"m",hn).call(this)}),Je(this,sn,"f")))}}nn=new WeakMap,rn=new WeakMap,sn=new WeakMap,an=new WeakMap,en=new WeakSet,on=function(t,e,i,n,r,s){const a=new Fn(t,e,i,n,s);return a.coordinateBase=r,a},ln=function(t,e){e.hasDrawingItem(t)||e.addDrawingItems([t])},hn=function(){this._tip&&this._drawingLayerOfTip.removeDrawingItems([this._tip])},cn=function(){if(!this._tip)return;const t=Je(this,nn,"f");this._tip.coordinateBase=t.coordinateBase,this._tip.setTextRect({x:t.topLeftPoint.x,y:t.topLeftPoint.y,width:t.width,height:0}),this._tip.set("width",this._tip.get("width")),this._tip._drawingLayer&&this._tip._drawingLayer.renderAll()};class kn extends HTMLElement{constructor(){super(),dn.set(this,void 0);const t=new DocumentFragment,e=document.createElement("div");e.setAttribute("class","wrapper"),t.appendChild(e),Ke(this,dn,e);const i=document.createElement("slot");i.setAttribute("name","single-frame-input-container"),e.append(i);const n=document.createElement("slot");n.setAttribute("name","content"),e.append(n);const r=document.createElement("slot");r.setAttribute("name","drawing-layer"),e.append(r);const s=document.createElement("style");s.textContent='\n.wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n}\n::slotted(canvas[slot="content"]) {\n object-fit: contain;\n pointer-events: none;\n}\n::slotted(div[slot="single-frame-input-container"]) {\n width: 1px;\n height: 1px;\n overflow: hidden;\n pointer-events: none;\n}\n::slotted(*) {\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n}\n ',t.appendChild(s),this.attachShadow({mode:"open"}).appendChild(t)}getWrapper(){return Je(this,dn,"f")}setElement(t,e){if(!(e instanceof HTMLElement))throw new TypeError("Invalid 'el'.");if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");this.removeElement(t),e.setAttribute("slot",t),this.appendChild(e)}getElement(t){if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");return this.querySelector(`[slot="${t}"]`)}removeElement(t){var e;if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");null===(e=this.querySelectorAll(`[slot="${t}"]`))||void 0===e||e.forEach((t=>t.remove()))}}dn=new WeakMap,customElements.get("dce-component")||customElements.define("dce-component",kn);class Nn extends Pn{static get engineResourcePath(){return L(vt.engineResourcePaths).dce}static set defaultUIElementURL(t){Nn._defaultUIElementURL=t}static get defaultUIElementURL(){var t;return null===(t=Nn._defaultUIElementURL)||void 0===t?void 0:t.replace("@engineResourcePath/",Nn.engineResourcePath)}static async createInstance(t){const e=new Nn;return"string"==typeof t&&(t=t.replace("@engineResourcePath/",Nn.engineResourcePath)),await e.setUIElement(t||Nn.defaultUIElementURL),e}static _transformCoordinates(t,e,i,n,r,s,a){const o=s/n,l=a/r;t.x=Math.round(t.x/o+e),t.y=Math.round(t.y/l+i)}set _singleFrameMode(t){if(!["disabled","image","camera"].includes(t))throw new Error("Invalid value.");if(t!==Je(this,Cn,"f")){if(Ke(this,Cn,t),Je(this,un,"m",bn).call(this))Ke(this,pn,null),this._videoContainer=null,this._innerComponent.removeElement("content"),this._innerComponent&&(this._innerComponent.addEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="block");else if(this._innerComponent&&(this._innerComponent.removeEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none"),!Je(this,pn,"f")){const t=document.createElement("video");t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.width="100%",t.style.height="100%",t.style.objectFit=this.getVideoFit(),t.setAttribute("autoplay","true"),t.setAttribute("playsinline","true"),t.setAttribute("muted","true"),["iPhone","iPad","Mac"].includes(Ze.OS)&&t.setAttribute("poster","data:image/gif;base64,R0lGODlhAQABAIEAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgEAAEEBAA7"),Ke(this,pn,t);const e=document.createElement("div");e.append(t),e.style.overflow="hidden",this._videoContainer=e,this._innerComponent.setElement("content",e)}Je(this,un,"m",bn).call(this)||this._hideDefaultSelection?(this._selCam&&(this._selCam.style.display="none"),this._selRsl&&(this._selRsl.style.display="none"),this._selMinLtr&&(this._selMinLtr.style.display="none")):(this._selCam&&(this._selCam.style.display="block"),this._selRsl&&(this._selRsl.style.display="block"),this._selMinLtr&&(this._selMinLtr.style.display="block"),this._stopLoading())}}get _singleFrameMode(){return Je(this,Cn,"f")}get disposed(){return Je(this,Sn,"f")}constructor(){super(),un.add(this),fn.set(this,void 0),gn.set(this,void 0),mn.set(this,void 0),this.containerClassName="dce-video-container",pn.set(this,void 0),this.videoFit="contain",this._hideDefaultSelection=!1,this._divScanArea=null,this._divScanLight=null,this._bgLoading=null,this._selCam=null,this._bgCamera=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,_n.set(this,null),this.regionMaskFillStyle="rgba(0,0,0,0.5)",this.regionMaskStrokeStyle="rgb(254,142,20)",this.regionMaskLineWidth=6,vn.set(this,!1),yn.set(this,!1),wn.set(this,{width:0,height:0}),this._updateLayersTimeout=500,this._videoResizeListener=()=>{Je(this,un,"m",An).call(this),this._updateLayersTimeoutId&&clearTimeout(this._updateLayersTimeoutId),this._updateLayersTimeoutId=setTimeout((()=>{this.disposed||(this.eventHandler.fire("videoEl:resized",null,{async:!1}),this.eventHandler.fire("content:updated",null,{async:!1}),this.isScanLaserVisible()&&Je(this,un,"m",On).call(this))}),this._updateLayersTimeout)},this._windowResizeListener=()=>{Nn._onLog&&Nn._onLog("window resize event triggered."),Je(this,wn,"f").width===document.documentElement.clientWidth&&Je(this,wn,"f").height===document.documentElement.clientHeight||(Je(this,wn,"f").width=document.documentElement.clientWidth,Je(this,wn,"f").height=document.documentElement.clientHeight,this._videoResizeListener())},Cn.set(this,"disabled"),this._clickIptSingleFrameMode=()=>{if(!Je(this,un,"m",bn).call(this))return;let t;if(this._singleFrameInputContainer)t=this._singleFrameInputContainer.firstElementChild;else{t=document.createElement("input"),t.setAttribute("type","file"),"camera"===this._singleFrameMode?(t.setAttribute("capture",""),t.setAttribute("accept","image/*")):"image"===this._singleFrameMode&&(t.removeAttribute("capture"),t.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp")),t.addEventListener("change",(async()=>{const e=t.files[0];t.value="";{const t=async t=>{let e=null,i=null;if("undefined"!=typeof createImageBitmap)try{if(e=await createImageBitmap(t),e)return e}catch(t){}var n;return e||(i=await(n=t,new Promise(((t,e)=>{let i=URL.createObjectURL(n),r=new Image;r.src=i,r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=t=>{e(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}})))),i},i=(t,e,i,n)=>{t.width==i&&t.height==n||(t.width=i,t.height=n);const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height),r.drawImage(e,0,0)},n=await t(e),r=n instanceof HTMLImageElement?n.naturalWidth:n.width,s=n instanceof HTMLImageElement?n.naturalHeight:n.height;let a=this._cvsSingleFrameMode;const o=null==a?void 0:a.width,l=null==a?void 0:a.height;a||(a=document.createElement("canvas"),this._cvsSingleFrameMode=a),i(a,n,r,s),this._innerComponent.setElement("content",a),o===a.width&&l===a.height||this.eventHandler.fire("content:updated",null,{async:!1})}this._onSingleFrameAcquired&&setTimeout((()=>{this._onSingleFrameAcquired(this._cvsSingleFrameMode)}),0)})),t.style.position="absolute",t.style.top="-9999px",t.style.backgroundColor="transparent",t.style.color="transparent";const e=document.createElement("div");e.append(t),this._innerComponent.setElement("single-frame-input-container",e),this._singleFrameInputContainer=e}null==t||t.click()},En.set(this,[]),this._capturedResultReceiver={onCapturedResultReceived:(t,e)=>{var i,n,r,s;if(this.disposed)return;if(this.clearAllInnerDrawingItems(),!t)return;const a=t.originalImageTag;if(!a)return;const o=t.items;if(!(null==o?void 0:o.length))return;const l=(null===(i=a.cropRegion)||void 0===i?void 0:i.left)||0,h=(null===(n=a.cropRegion)||void 0===n?void 0:n.top)||0,c=(null===(r=a.cropRegion)||void 0===r?void 0:r.right)?a.cropRegion.right-l:a.originalWidth,d=(null===(s=a.cropRegion)||void 0===s?void 0:s.bottom)?a.cropRegion.bottom-h:a.originalHeight,u=a.currentWidth,f=a.currentHeight,g=(t,e,i,n,r,s,a,o,l=[],h)=>{e.forEach((t=>Nn._transformCoordinates(t,i,n,r,s,a,o)));const c=new Ni({points:[{x:e[0].x,y:e[0].y},{x:e[1].x,y:e[1].y},{x:e[2].x,y:e[2].y},{x:e[3].x,y:e[3].y}]},h);for(let t of l)c.addNote(t);t.addDrawingItems([c]),Je(this,En,"f").push(c)};let m,p;for(let t of o)switch(t.type){case yt.CRIT_ORIGINAL_IMAGE:break;case yt.CRIT_BARCODE:m=this.getDrawingLayer(Ln.DBR_LAYER_ID),p=[{name:"format",content:t.formatString},{name:"text",content:t.text}],(null==e?void 0:e.isBarcodeVerifyOpen)?t.verified?g(m,t.location.points,l,h,c,d,u,f,p):g(m,t.location.points,l,h,c,d,u,f,p,Dn.STYLE_ORANGE_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,d,u,f,p);break;case yt.CRIT_TEXT_LINE:m=this.getDrawingLayer(Ln.DLR_LAYER_ID),p=[{name:"text",content:t.text}],e.isLabelVerifyOpen?t.verified?g(m,t.location.points,l,h,c,d,u,f,p):g(m,t.location.points,l,h,c,d,u,f,p,Dn.STYLE_GREEN_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,d,u,f,p);break;case yt.CRIT_DETECTED_QUAD:m=this.getDrawingLayer(Ln.DDN_LAYER_ID),(null==e?void 0:e.isDetectVerifyOpen)?t.crossVerificationStatus===xt.CVS_PASSED?g(m,t.location.points,l,h,c,d,u,f,[]):g(m,t.location.points,l,h,c,d,u,f,[],Dn.STYLE_BLUE_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,d,u,f,[]);break;case yt.CRIT_NORMALIZED_IMAGE:m=this.getDrawingLayer(Ln.DDN_LAYER_ID),(null==e?void 0:e.isNormalizeVerifyOpen)?t.crossVerificationStatus===xt.CVS_PASSED?g(m,t.location.points,l,h,c,d,u,f,[]):g(m,t.location.points,l,h,c,d,u,f,[],Dn.STYLE_BLUE_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,d,u,f,[]);break;case yt.CRIT_PARSED_RESULT:break;default:throw new Error("Illegal item type.")}}},Sn.set(this,!1),this.eventHandler=new zi,this.eventHandler.on("content:updated",(()=>{Je(this,fn,"f")&&clearTimeout(Je(this,fn,"f")),Ke(this,fn,setTimeout((()=>{if(this.disposed)return;let t;this._updateVideoContainer();try{t=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}this.updateDrawingLayers(t),this.updateConvertedRegion(t)}),0))})),this.eventHandler.on("videoEl:resized",(()=>{Je(this,gn,"f")&&clearTimeout(Je(this,gn,"f")),Ke(this,gn,setTimeout((()=>{this.disposed||this._updateVideoContainer()}),0))}))}_setUIElement(t){this.UIElement=t,this._unbindUI(),this._bindUI()}async setUIElement(t){let e;if("string"==typeof t){let i=await qi(t);e=document.createElement("div"),Object.assign(e.style,{width:"100%",height:"100%"}),e.attachShadow({mode:"open"}).appendChild(i.cloneNode(!0))}else e=t;this._setUIElement(e)}getUIElement(){return this.UIElement}_bindUI(){var t,e;if(!this.UIElement)throw new Error("Need to set 'UIElement'.");if(this._innerComponent)return;let i=this.UIElement;i=i.shadowRoot||i;let n=(null===(t=i.classList)||void 0===t?void 0:t.contains(this.containerClassName))?i:i.querySelector(`.${this.containerClassName}`);if(!n)throw Error(`Can not find the element with class '${this.containerClassName}'.`);if(this._innerComponent=document.createElement("dce-component"),n.appendChild(this._innerComponent),Je(this,un,"m",bn).call(this));else{const t=document.createElement("video");Object.assign(t.style,{position:"absolute",left:"0",top:"0",width:"100%",height:"100%",objectFit:this.getVideoFit()}),t.setAttribute("autoplay","true"),t.setAttribute("playsinline","true"),t.setAttribute("muted","true"),["iPhone","iPad","Mac"].includes(Ze.OS)&&t.setAttribute("poster","data:image/gif;base64,R0lGODlhAQABAIEAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgEAAEEBAA7"),Ke(this,pn,t);const e=document.createElement("div");e.append(t),e.style.overflow="hidden",this._videoContainer=e,this._innerComponent.setElement("content",e)}if(this._selRsl=i.querySelector(".dce-sel-resolution"),this._selMinLtr=i.querySelector(".dlr-sel-minletter"),this._divScanArea=i.querySelector(".dce-scanarea"),this._divScanLight=i.querySelector(".dce-scanlight"),this._bgLoading=i.querySelector(".dce-bg-loading"),this._bgCamera=i.querySelector(".dce-bg-camera"),this._selCam=i.querySelector(".dce-sel-camera"),this._optGotRsl=i.querySelector(".dce-opt-gotResolution"),this._btnClose=i.querySelector(".dce-btn-close"),this._optGotMinLtr=i.querySelector(".dlr-opt-gotMinLtr"),this._selRsl&&(this._hideDefaultSelection||Je(this,un,"m",bn).call(this)||this._selRsl.options.length||(this._selRsl.innerHTML=['','','',''].join(""),this._optGotRsl=this._selRsl.options[0])),this._selMinLtr&&(this._hideDefaultSelection||Je(this,un,"m",bn).call(this)||this._selMinLtr.options.length||(this._selMinLtr.innerHTML=['','','','','','','','','','',''].join(""),this._optGotMinLtr=this._selMinLtr.options[0])),this.isScanLaserVisible()||Je(this,un,"m",An).call(this),Je(this,un,"m",bn).call(this)&&(this._innerComponent&&(this._innerComponent.addEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="block")),Je(this,un,"m",bn).call(this)||this._hideDefaultSelection?(this._selCam&&(this._selCam.style.display="none"),this._selRsl&&(this._selRsl.style.display="none"),this._selMinLtr&&(this._selMinLtr.style.display="none")):(this._selCam&&(this._selCam.style.display="block"),this._selRsl&&(this._selRsl.style.display="block"),this._selMinLtr&&(this._selMinLtr.style.display="block"),this._stopLoading()),window.ResizeObserver){this._resizeObserver||(this._resizeObserver=new ResizeObserver((t=>{var e;Nn._onLog&&Nn._onLog("resize observer triggered.");for(let i of t)i.target===(null===(e=this._innerComponent)||void 0===e?void 0:e.getWrapper())&&this._videoResizeListener()})));const t=null===(e=this._innerComponent)||void 0===e?void 0:e.getWrapper();t&&this._resizeObserver.observe(t)}Je(this,wn,"f").width=document.documentElement.clientWidth,Je(this,wn,"f").height=document.documentElement.clientHeight,window.addEventListener("resize",this._windowResizeListener)}_unbindUI(){var t,e,i,n;Je(this,un,"m",bn).call(this)?(this._innerComponent&&(this._innerComponent.removeEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none")):this._stopLoading(),Je(this,un,"m",An).call(this),null===(t=this._drawingLayerManager)||void 0===t||t.clearDrawingLayers(),null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null,this._drawingLayerOfMask=null,this._drawingLayerOfTip=null,null===(i=this._innerComponent)||void 0===i||i.remove(),this._innerComponent=null,Ke(this,pn,null),null===(n=this._videoContainer)||void 0===n||n.remove(),this._videoContainer=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,this._divScanArea=null,this._divScanLight=null,this._singleFrameInputContainer&&(this._singleFrameInputContainer.remove(),this._singleFrameInputContainer=null),window.ResizeObserver&&this._resizeObserver&&this._resizeObserver.disconnect(),window.removeEventListener("resize",this._windowResizeListener)}_startLoading(){this._bgLoading&&(this._bgLoading.style.display="",this._bgLoading.style.animationPlayState="")}_stopLoading(){this._bgLoading&&(this._bgLoading.style.display="none",this._bgLoading.style.animationPlayState="paused")}_renderCamerasInfo(t,e){if(this._selCam){let i;this._selCam.textContent="";for(let n of e){const e=document.createElement("option");e.value=n.deviceId,e.innerText=n.label,this._selCam.append(e),n.deviceId&&t&&t.deviceId==n.deviceId&&(i=e)}this._selCam.value=i?i.value:""}let i=this.UIElement;if(i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")){let t=i.querySelector(".dce-mn-cameras");if(t){t.textContent="";for(let i of e){const e=document.createElement("div");e.classList.add("dce-mn-camera-option"),e.setAttribute("data-davice-id",i.deviceId),e.textContent=i.label,t.append(e)}}}}_renderResolutionInfo(t){this._optGotRsl&&(this._optGotRsl.setAttribute("data-width",t.width),this._optGotRsl.setAttribute("data-height",t.height),this._optGotRsl.innerText="got "+t.width+"x"+t.height,this._selRsl&&this._optGotRsl.parentNode==this._selRsl&&(this._selRsl.value="got"));{let e=this.UIElement;e=(null==e?void 0:e.shadowRoot)||e;let i=null==e?void 0:e.querySelector(".dce-mn-resolution-box");if(i){let e="";if(t&&t.width&&t.height){let i=Math.max(t.width,t.height),n=Math.min(t.width,t.height);e=n<=1080?n+"P":i<3e3?"2K":Math.round(i/1e3)+"K"}i.textContent=e}}}getVideoElement(){return Je(this,pn,"f")}isVideoLoaded(){return!(!Je(this,pn,"f")||!this.cameraEnhancer)&&this.cameraEnhancer.isOpen()}setVideoFit(t){if(t=t.toLowerCase(),!["contain","cover"].includes(t))throw new Error(`Unsupported value '${t}'.`);if(this.videoFit=t,!Je(this,pn,"f"))return;if(Je(this,pn,"f").style.objectFit=t,Je(this,un,"m",bn).call(this))return;let e;this._updateVideoContainer();try{e=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}Je(this,un,"m",Rn).call(this,e,this.getConvertedRegion()),this.updateDrawingLayers(e)}getVideoFit(){return this.videoFit}getContentDimensions(){var t,e,i,n;let r,s,a;if(Je(this,un,"m",bn).call(this)?(r=null===(i=this._cvsSingleFrameMode)||void 0===i?void 0:i.width,s=null===(n=this._cvsSingleFrameMode)||void 0===n?void 0:n.height,a="contain"):(r=null===(t=Je(this,pn,"f"))||void 0===t?void 0:t.videoWidth,s=null===(e=Je(this,pn,"f"))||void 0===e?void 0:e.videoHeight,a=this.getVideoFit()),!r||!s)throw new Error("Invalid content dimensions.");return{width:r,height:s,objectFit:a}}updateConvertedRegion(t){const e=Gi.convert(this.scanRegion,t.width,t.height);Ke(this,_n,e),Je(this,mn,"f")&&clearTimeout(Je(this,mn,"f")),Ke(this,mn,setTimeout((()=>{let t;try{t=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}Je(this,un,"m",Tn).call(this,t,e),Je(this,un,"m",Rn).call(this,t,e)}),0))}getConvertedRegion(){return Je(this,_n,"f")}setScanRegion(t){if(null!=t&&!E(t)&&!O(t))throw TypeError("Invalid 'region'.");let e;this.scanRegion=t?JSON.parse(JSON.stringify(t)):null;try{e=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}this.updateConvertedRegion(e)}getScanRegion(){return JSON.parse(JSON.stringify(this.scanRegion))}getVisibleRegionOfVideo(t){if(!this.isVideoLoaded())throw new Error("The video is not loaded.");const e=Je(this,pn,"f").videoWidth,i=Je(this,pn,"f").videoHeight,n=this.getVideoFit(),{width:r,height:s}=this._innerComponent.getBoundingClientRect();if(r<=0||s<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");let a;const o={x:0,y:0,width:e,height:i,isMeasuredInPercentage:!1};if("cover"===n&&(r/s1){const t=Je(this,pn,"f").videoWidth,e=Je(this,pn,"f").videoHeight,{width:n,height:r}=this._innerComponent.getBoundingClientRect(),s=t/e;if(n/rt.remove())),Je(this,En,"f").length=0}dispose(){this._unbindUI(),Ke(this,Sn,!0)}}function Bn(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 jn(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}fn=new WeakMap,gn=new WeakMap,mn=new WeakMap,pn=new WeakMap,_n=new WeakMap,vn=new WeakMap,yn=new WeakMap,wn=new WeakMap,Cn=new WeakMap,En=new WeakMap,Sn=new WeakMap,un=new WeakSet,bn=function(){return"disabled"!==this._singleFrameMode},Tn=function(t,e){!e||0===e.x&&0===e.y&&e.width===t.width&&e.height===t.height?this.clearScanRegionMask():this.setScanRegionMask(e.x,e.y,e.width,e.height)},In=function(){this._drawingLayerOfMask&&this._drawingLayerOfMask.setVisible(!0)},xn=function(){this._drawingLayerOfMask&&this._drawingLayerOfMask.setVisible(!1)},On=function(){this._divScanLight&&"none"==this._divScanLight.style.display&&(this._divScanLight.style.display="block")},An=function(){this._divScanLight&&(this._divScanLight.style.display="none")},Rn=function(t,e){if(!this._divScanArea)return;if(!this._innerComponent.getElement("content"))return;const{width:i,height:n,objectFit:r}=t;e||(e={x:0,y:0,width:i,height:n});const{width:s,height:a}=this._innerComponent.getBoundingClientRect();if(s<=0||a<=0)return;const o=s/a,l=i/n;let h,c,d,u,f=1;if("contain"===r)o66||"Safari"===zn.browser&&zn.version>13||"OPR"===zn.browser&&zn.version>43||"Edge"===zn.browser&&zn.version,"function"==typeof SuppressedError&&SuppressedError;class Zn{static multiply(t,e){const i=[];for(let n=0;n<3;n++){const r=e.slice(3*n,3*n+3);for(let e=0;e<3;e++){const n=[t[e],t[e+3],t[e+6]].reduce(((t,e,i)=>t+e*r[i]),0);i.push(n)}}return i}static identity(){return[1,0,0,0,1,0,0,0,1]}static translate(t,e,i){return Zn.multiply(t,[1,0,0,0,1,0,e,i,1])}static rotate(t,e){var i=Math.cos(e),n=Math.sin(e);return Zn.multiply(t,[i,-n,0,n,i,0,0,0,1])}static scale(t,e,i){return Zn.multiply(t,[e,0,0,0,i,0,0,0,1])}}var qn,Jn,Kn,$n,Qn,tr,er,ir,nr,rr,sr,ar,or,lr,hr,cr,dr,ur,fr,gr,mr,pr,_r,vr,yr,wr,Cr,Er,Sr,br,Tr,Ir,xr,Or,Ar,Rr,Dr,Lr,Mr,Fr,Pr,kr,Nr,Br,jr,Vr,Ur,Gr,Wr,Yr;!function(t){t.GREY="grey",t.GREY32="grey32",t.RGBA="rgba",t.RBGA="rbga",t.GRBA="grba",t.GBRA="gbra",t.BRGA="brga",t.BGRA="bgra"}(qn||(qn={}));class zr{static get version(){return"1.1.3"}static get webGLSupported(){return void 0===zr._webGLSupported&&(zr._webGLSupported=!!document.createElement("canvas").getContext("webgl")),zr._webGLSupported}get disposed(){return Hn(this,er,"f")}constructor(){Jn.set(this,qn.RGBA),Kn.set(this,null),$n.set(this,null),Qn.set(this,null),this.useWebGLByDefault=!0,this._reusedCvs=null,this._reusedWebGLCvs=null,tr.set(this,null),er.set(this,!1)}drawImage(t,e,i,n,r,s){if(this.disposed)throw Error("The 'ImageDataGetter' instance has been disposed.");if(!i||!n)throw new Error("Invalid 'sourceWidth' or 'sourceHeight'.");if((null==s?void 0:s.bUseWebGL)&&!zr.webGLSupported)throw new Error("Your browser or machine may not support WebGL.");if(e instanceof HTMLVideoElement&&4!==e.readyState||e instanceof HTMLImageElement&&!e.complete)throw new Error("The source is not loaded.");let a;zr._onLog&&(a=Date.now(),zr._onLog("drawImage(), START: "+a));let o=0,l=0,h=i,c=n,d=0,u=0,f=i,g=n;r&&(r.sx&&(o=Math.round(r.sx)),r.sy&&(l=Math.round(r.sy)),r.sWidth&&(h=Math.round(r.sWidth)),r.sHeight&&(c=Math.round(r.sHeight)),r.dx&&(d=Math.round(r.dx)),r.dy&&(u=Math.round(r.dy)),r.dWidth&&(f=Math.round(r.dWidth)),r.dHeight&&(g=Math.round(r.dHeight)));let m,p=qn.RGBA;if((null==s?void 0:s.pixelFormat)&&(p=s.pixelFormat),(null==s?void 0:s.bufferContainer)&&(m=s.bufferContainer,m.length<4*f*g))throw new Error("Unexpected size of the 'bufferContainer'.");const _=t;if(!zr.webGLSupported||!(this.useWebGLByDefault&&null==(null==s?void 0:s.bUseWebGL)||(null==s?void 0:s.bUseWebGL))){zr._onLog&&zr._onLog("drawImage() in context2d."),_.ctx2d||(_.ctx2d=_.getContext("2d",{willReadFrequently:!0}));const t=_.ctx2d;if(!t)throw new Error("Unable to get 'CanvasRenderingContext2D' from canvas.");return(_.width{const e=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,e),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);const i=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),{positions:e,texCoords:i}},i=t=>{const e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e},n=(t,e)=>{const i=t.createProgram();if(e.forEach((e=>t.attachShader(i,e))),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS)){const e=new Error(`An error occured linking the program: ${t.getProgramInfoLog(i)}.`);throw e.name="WebGLError",e}return t.useProgram(i),i},r=(t,e,i)=>{const n=t.createShader(e);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){const e=new Error(`An error occured compiling the shader: ${t.getShaderInfoLog(n)}.`);throw e.name="WebGLError",e}return n},s="\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\n\nuniform mat3 u_matrix;\nuniform mat3 u_textureMatrix;\n\nvarying vec2 v_texCoord;\nvoid main(void) {\ngl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, 0, 1.0);\nv_texCoord = vec4((u_textureMatrix * vec3(a_texCoord, 1)).xy, 0, 1.0).xy;\n}";let a="rgb";["rgba","rbga","grba","gbra","brga","bgra"].includes(p)&&(a=p.slice(0,3));const o=`\nprecision mediump float;\nvarying vec2 v_texCoord;\nuniform sampler2D u_image;\nuniform float uColorFactor;\n\nvoid main() {\nvec4 sample = texture2D(u_image, v_texCoord);\nfloat grey = 0.3 * sample.r + 0.59 * sample.g + 0.11 * sample.b;\ngl_FragColor = vec4(sample.${a} * (1.0 - uColorFactor) + (grey * uColorFactor), sample.a);\n}`,l=n(t,[r(t,t.VERTEX_SHADER,s),r(t,t.FRAGMENT_SHADER,o)]);Xn(this,$n,{program:l,attribLocations:{vertexPosition:t.getAttribLocation(l,"a_position"),texPosition:t.getAttribLocation(l,"a_texCoord")},uniformLocations:{uSampler:t.getUniformLocation(l,"u_image"),uColorFactor:t.getUniformLocation(l,"uColorFactor"),uMatrix:t.getUniformLocation(l,"u_matrix"),uTextureMatrix:t.getUniformLocation(l,"u_textureMatrix")}}),Xn(this,Qn,e(t)),Xn(this,Kn,i(t)),Xn(this,Jn,p)}const r=(t,e,i)=>{t.bindBuffer(t.ARRAY_BUFFER,e),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0)},s=(t,e,i)=>{const n=t.RGBA,r=t.RGBA,s=t.UNSIGNED_BYTE;t.bindTexture(t.TEXTURE_2D,e),t.texImage2D(t.TEXTURE_2D,0,n,r,s,i)},v=(t,e,s,a)=>{t.clearColor(0,0,0,1),t.clearDepth(1),t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),r(t,s.positions,e.attribLocations.vertexPosition),r(t,s.texCoords,e.attribLocations.texPosition),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,a),t.uniform1i(e.uniformLocations.uSampler,0),t.uniform1f(e.uniformLocations.uColorFactor,[qn.GREY,qn.GREY32].includes(p)?1:0);let m,_,v=Zn.translate(Zn.identity(),-1,-1);v=Zn.scale(v,2,2),v=Zn.scale(v,1/t.canvas.width,1/t.canvas.height),m=Zn.translate(v,d,u),m=Zn.scale(m,f,g),t.uniformMatrix3fv(e.uniformLocations.uMatrix,!1,m),_=Zn.translate(Zn.identity(),o/i,l/n),_=Zn.scale(_,h/i,c/n),t.uniformMatrix3fv(e.uniformLocations.uTextureMatrix,!1,_),t.drawArrays(t.TRIANGLES,0,6)};s(t,Hn(this,Kn,"f"),e),v(t,Hn(this,$n,"f"),Hn(this,Qn,"f"),Hn(this,Kn,"f"));const y=m||new Uint8Array(4*f*g);if(t.readPixels(d,u,f,g,t.RGBA,t.UNSIGNED_BYTE,y),255!==y[3]){zr._onLog&&zr._onLog("Incorrect WebGL drawing .");const t=new Error("WebGL error: incorrect drawing.");throw t.name="WebGLError",t}return zr._onLog&&zr._onLog("drawImage() in WebGL end. Costs: "+(Date.now()-a)),{context:t,pixelFormat:p===qn.GREY?qn.GREY32:p,bUseWebGL:!0}}catch(a){if(this.forceLoseContext(),null==(null==s?void 0:s.bUseWebGL))return zr._onLog&&zr._onLog("'drawImage()' in WebGL failed, try again in context2d."),this.useWebGLByDefault=!1,this.drawImage(t,e,i,n,r,Object.assign({},s,{bUseWebGL:!1}));throw a.name="WebGLError",a}}readCvsData(t,e,i){if(!(t instanceof CanvasRenderingContext2D||t instanceof WebGLRenderingContext))throw new Error("Invalid 'context'.");let n,r=0,s=0,a=t.canvas.width,o=t.canvas.height;if(e&&(e.x&&(r=e.x),e.y&&(s=e.y),e.width&&(a=e.width),e.height&&(o=e.height)),(null==i?void 0:i.length)<4*a*o)throw new Error("Unexpected size of the 'bufferContainer'.");if(t instanceof WebGLRenderingContext){const e=t;i?(e.readPixels(r,s,a,o,e.RGBA,e.UNSIGNED_BYTE,i),n=new Uint8Array(i.buffer,0,4*a*o)):(n=new Uint8Array(4*a*o),e.readPixels(r,s,a,o,e.RGBA,e.UNSIGNED_BYTE,n))}else if(t instanceof CanvasRenderingContext2D){let e;e=t.getImageData(r,s,a,o),n=new Uint8Array(e.data.buffer),null==i||i.set(n)}return n}transformPixelFormat(t,e,i,n){let r,s;if(zr._onLog&&(r=Date.now(),zr._onLog("transformPixelFormat(), START: "+r)),e===i)return zr._onLog&&zr._onLog("transformPixelFormat() end. Costs: "+(Date.now()-r)),n?new Uint8Array(t):t;const a=[qn.RGBA,qn.RBGA,qn.GRBA,qn.GBRA,qn.BRGA,qn.BGRA];if(a.includes(e))if(i===qn.GREY){s=new Uint8Array(t.length/4);for(let e=0;el||e.sy+e.sHeight>h)throw new Error("Invalid position.");null===(n=zr._onLog)||void 0===n||n.call(zr,"getImageData(), START: "+(c=Date.now()));const u=Math.round(e.sx),f=Math.round(e.sy),g=Math.round(e.sWidth),m=Math.round(e.sHeight),p=Math.round(e.dWidth),_=Math.round(e.dHeight);let v,y=(null==i?void 0:i.pixelFormat)||qn.RGBA,w=null==i?void 0:i.bufferContainer;if(w&&(qn.GREY===y&&w.length{this.disposed||n.includes(r)&&r.apply(i.target,s)}),0);else try{a=r.apply(i.target,s)}catch(t){}if(!0===a)break}}}dispose(){jn(this,nr,!0)}}ir=new WeakMap,nr=new WeakMap;const Xr=(t,e,i,n)=>{if(!i)return t;let r=e+Math.round((t-e)/i)*i;return n&&(r=Math.min(r,n)),r};class Zr{static get version(){return"2.0.18"}static isStorageAvailable(t){let e;try{e=window[t];const i="__storage_test__";return e.setItem(i,i),e.removeItem(i),!0}catch(t){return t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name)&&e&&0!==e.length}}static findBestRearCameraInIOS(t,e){if(!t||!t.length)return null;let i=!1;if((null==e?void 0:e.getMainCamera)&&(i=!0),i){const e=["후면 카메라","背面カメラ","後置鏡頭","后置相机","กล้องด้านหลัง","बैक कैमरा","الكاميرا الخلفية","מצלמה אחורית","камера на задней панели","задня камера","задна камера","артқы камера","πίσω κάμερα","zadní fotoaparát","zadná kamera","tylny aparat","takakamera","stražnja kamera","rückkamera","kamera på baksidan","kamera belakang","kamera bak","hátsó kamera","fotocamera (posteriore)","câmera traseira","câmara traseira","cámara trasera","càmera posterior","caméra arrière","cameră spate","camera mặt sau","camera aan achterzijde","bagsidekamera","back camera","arka kamera"],i=t.find((t=>e.includes(t.label.toLowerCase())));return null==i?void 0:i.deviceId}{const e=["후면","背面","後置","后置","านหลัง","बैक","خلفية","אחורית","задняя","задней","задна","πίσω","zadní","zadná","tylny","trasera","traseira","taka","stražnja","spate","sau","rück","posteriore","posterior","hátsó","belakang","baksidan","bakre","bak","bagside","back","aртқы","arrière","arka","achterzijde"],i=["트리플","三镜头","三鏡頭","トリプル","สาม","ट्रिपल","ثلاثية","משולשת","үштік","тройная","тройна","потроєна","τριπλή","üçlü","trójobiektywowy","trostruka","trojný","trojitá","trippelt","trippel","triplă","triple","tripla","tiga","kolmois","ba camera"],n=["듀얼 와이드","雙廣角","双广角","デュアル広角","คู่ด้านหลังมุมกว้าง","ड्युअल वाइड","مزدوجة عريضة","כפולה רחבה","қос кең бұрышты","здвоєна ширококутна","двойная широкоугольная","двойна широкоъгълна","διπλή ευρεία","ç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"],r=t.filter((t=>{const i=t.label.toLowerCase();return e.some((t=>i.includes(t)))}));if(!r.length)return null;const s=r.find((t=>{const e=t.label.toLowerCase();return i.some((t=>e.includes(t)))}));if(s)return s.deviceId;const a=r.find((t=>{const e=t.label.toLowerCase();return n.some((t=>e.includes(t)))}));return a?a.deviceId:r[0].deviceId}}static findBestRearCamera(t,e){if(!t||!t.length)return null;if(["iPhone","iPad","Mac"].includes(zn.OS))return Zr.findBestRearCameraInIOS(t,{getMainCamera:null==e?void 0:e.getMainCameraInIOS});const i=["후","背面","背置","後面","後置","后面","后置","านหลัง","หลัง","बैक","خلفية","אחורית","задняя","задня","задней","задна","πίσω","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"];for(let e of t){const t=e.label.toLowerCase();if(t&&i.some((e=>t.includes(e)))&&/\b0(\b)?/.test(t))return e.deviceId}return["Android","HarmonyOS"].includes(zn.OS)?t[t.length-1].deviceId:null}static findBestCamera(t,e,i){return t&&t.length?"environment"===e?this.findBestRearCamera(t,i):"user"===e?null:e?void 0:null:null}static async playVideo(t,e,i){if(!t)throw new Error("Invalid 'videoEl'.");if(!e)throw new Error("Invalid 'source'.");return new Promise((async(n,r)=>{let s;const a=()=>{t.removeEventListener("loadstart",c),t.removeEventListener("abort",d),t.removeEventListener("play",u),t.removeEventListener("error",f),t.removeEventListener("loadedmetadata",p)};let o=!1;const l=()=>{o=!0,s&&clearTimeout(s),a(),n(t)},h=t=>{s&&clearTimeout(s),a(),r(t)},c=()=>{t.addEventListener("abort",d,{once:!0})},d=()=>{const t=new Error("Video playing was interrupted.");t.name="AbortError",h(t)},u=()=>{l()},f=()=>{h(new Error(`Video error ${t.error.code}: ${t.error.message}.`))};let g;const m=new Promise((t=>{g=t})),p=()=>{g()};if(t.addEventListener("loadstart",c,{once:!0}),t.addEventListener("play",u,{once:!0}),t.addEventListener("error",f,{once:!0}),t.addEventListener("loadedmetadata",p,{once:!0}),"string"==typeof e||e instanceof String?t.src=e:t.srcObject=e,t.autoplay&&await new Promise((t=>{setTimeout(t,1e3)})),!o){i&&(s=setTimeout((()=>{a(),r(new Error("Failed to play video. Timeout."))}),i)),await m;try{await t.play(),l()}catch(t){console.warn("1st play error: "+((null==t?void 0:t.message)||t))}if(!o)try{await t.play(),l()}catch(t){console.warn("2rd play error: "+((null==t?void 0:t.message)||t)),h(t)}}}))}static async testCameraAccess(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))return{ok:!1,errorName:"InsecureContext",errorMessage:"Insecure context."};let n;try{n=t?await navigator.mediaDevices.getUserMedia(t):await navigator.mediaDevices.getUserMedia({video:!0})}catch(t){return{ok:!1,errorName:t.name,errorMessage:t.message}}finally{null==n||n.getTracks().forEach((t=>{t.stop()}))}return{ok:!0}}get state(){if(!Bn(this,_r,"f"))return"closed";if("pending"===Bn(this,_r,"f"))return"opening";if("fulfilled"===Bn(this,_r,"f"))return"opened";throw new Error("Unknown state.")}set ifSaveLastUsedCamera(t){t?Zr.isStorageAvailable("localStorage")?jn(this,fr,!0):(jn(this,fr,!1),console.warn("Local storage is unavailable")):jn(this,fr,!1)}get ifSaveLastUsedCamera(){return Bn(this,fr,"f")}get isVideoPlaying(){return!(!Bn(this,ar,"f")||Bn(this,ar,"f").paused)&&"opened"===this.state}set tapFocusEventBoundEl(t){var e,i,n;if(!(t instanceof HTMLElement)&&null!=t)throw new TypeError("Invalid 'element'.");null===(e=Bn(this,Sr,"f"))||void 0===e||e.removeEventListener("click",Bn(this,Er,"f")),null===(i=Bn(this,Sr,"f"))||void 0===i||i.removeEventListener("touchend",Bn(this,Er,"f")),null===(n=Bn(this,Sr,"f"))||void 0===n||n.removeEventListener("touchmove",Bn(this,Cr,"f")),jn(this,Sr,t),t&&(window.TouchEvent&&["Android","HarmonyOS","iPhone","iPad"].includes(zn.OS)?(t.addEventListener("touchend",Bn(this,Er,"f")),t.addEventListener("touchmove",Bn(this,Cr,"f"))):t.addEventListener("click",Bn(this,Er,"f")))}get tapFocusEventBoundEl(){return Bn(this,Sr,"f")}get disposed(){return Bn(this,Lr,"f")}constructor(t){var e,i;sr.add(this),ar.set(this,null),or.set(this,void 0),lr.set(this,(()=>{"opened"===this.state&&Bn(this,xr,"f").fire("resumed",null,{target:this,async:!1})})),hr.set(this,(()=>{Bn(this,xr,"f").fire("paused",null,{target:this,async:!1})})),cr.set(this,void 0),dr.set(this,void 0),this.cameraOpenTimeout=15e3,this._arrCameras=[],ur.set(this,void 0),fr.set(this,!1),this.ifSkipCameraInspection=!1,this.selectIOSRearMainCameraAsDefault=!1,gr.set(this,void 0),mr.set(this,!0),pr.set(this,void 0),_r.set(this,void 0),vr.set(this,!1),this._focusParameters={maxTimeout:400,minTimeout:300,kTimeout:void 0,oldDistance:null,fds:null,isDoingFocus:0,taskBackToContinous:null,curFocusTaskId:0,focusCancelableTime:1500,defaultFocusAreaSizeRatio:6,focusBackToContinousTime:5e3,tapFocusMinDistance:null,tapFocusMaxDistance:null,focusArea:null,tempBufferContainer:null,defaultTempBufferContainerLenRatio:1/4},yr.set(this,!1),this._focusSupported=!0,this.calculateCoordInVideo=(t,e)=>{let i,n;const r=window.getComputedStyle(Bn(this,ar,"f")).objectFit,s=this.getResolution(),a=Bn(this,ar,"f").getBoundingClientRect(),o=a.left,l=a.top,{width:h,height:c}=Bn(this,ar,"f").getBoundingClientRect();if(h<=0||c<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const d=h/c,u=s.width/s.height;let f=1;if("contain"===r)u>d?(f=h/s.width,i=(t-o)/f,n=(e-l-(c-h/u)/2)/f):(f=c/s.height,n=(e-l)/f,i=(t-o-(h-c*u)/2)/f);else{if("cover"!==r)throw new Error("Unsupported object-fit.");u>d?(f=c/s.height,n=(e-l)/f,i=(t-o+(c*u-h)/2)/f):(f=h/s.width,i=(t-o)/f,n=(e-l+(h/u-c)/2)/f)}return{x:i,y:n}},wr.set(this,!1),Cr.set(this,(()=>{jn(this,wr,!0)})),Er.set(this,(async t=>{var e;if(Bn(this,wr,"f"))return void jn(this,wr,!1);if(!Bn(this,yr,"f"))return;if(!this.isVideoPlaying)return;if(!Bn(this,or,"f"))return;if(!this._focusSupported)return;if(!this._focusParameters.fds&&(this._focusParameters.fds=null===(e=this.getCameraCapabilities())||void 0===e?void 0:e.focusDistance,!this._focusParameters.fds))return void(this._focusSupported=!1);if(null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),1==this._focusParameters.isDoingFocus)return;let i,n;if(this._focusParameters.taskBackToContinous&&(clearTimeout(this._focusParameters.taskBackToContinous),this._focusParameters.taskBackToContinous=null),t instanceof MouseEvent)i=t.clientX,n=t.clientY;else{if(!(t instanceof TouchEvent))throw new Error("Unknown event type.");if(!t.changedTouches.length)return;i=t.changedTouches[0].clientX,n=t.changedTouches[0].clientY}const r=this.getResolution(),s=2*Math.round(Math.min(r.width,r.height)/this._focusParameters.defaultFocusAreaSizeRatio/2);let a;try{a=this.calculateCoordInVideo(i,n)}catch(t){}if(a.x<0||a.x>r.width||a.y<0||a.y>r.height)return;const o={x:a.x+"px",y:a.y+"px"},l=s+"px",h=l;let c;Zr._onLog&&(c=Date.now());try{await Bn(this,sr,"m",Gr).call(this,o,l,h,this._focusParameters.tapFocusMinDistance,this._focusParameters.tapFocusMaxDistance)}catch(t){if(Zr._onLog)throw Zr._onLog(t),t}Zr._onLog&&Zr._onLog(`Tap focus costs: ${Date.now()-c} ms`),this._focusParameters.taskBackToContinous=setTimeout((()=>{var t;Zr._onLog&&Zr._onLog("Back to continuous focus."),null===(t=Bn(this,or,"f"))||void 0===t||t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch((()=>{}))}),this._focusParameters.focusBackToContinousTime),Bn(this,xr,"f").fire("tapfocus",null,{target:this,async:!1})})),Sr.set(this,null),br.set(this,1),Tr.set(this,{x:0,y:0}),this.updateVideoElWhenSoftwareScaled=()=>{if(!Bn(this,ar,"f"))return;const t=Bn(this,br,"f");if(t<1)throw new RangeError("Invalid scale value.");if(1===t)Bn(this,ar,"f").style.transform="";else{const e=window.getComputedStyle(Bn(this,ar,"f")).objectFit,i=Bn(this,ar,"f").videoWidth,n=Bn(this,ar,"f").videoHeight,{width:r,height:s}=Bn(this,ar,"f").getBoundingClientRect();if(r<=0||s<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const a=r/s,o=i/n;let l=1;"contain"===e?l=aa?s/(i/t):r/(n/t));const h=l*(1-1/t)*(i/2-Bn(this,Tr,"f").x),c=l*(1-1/t)*(n/2-Bn(this,Tr,"f").y);Bn(this,ar,"f").style.transform=`translate(${h}px, ${c}px) scale(${t})`}},Ir.set(this,(function(){if(!(this.data instanceof Uint8Array||this.data instanceof Uint8ClampedArray))throw new TypeError("Invalid data.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const t=document.createElement("canvas");let e;if(t.width=this.width,t.height=this.height,this.pixelFormat===qn.GREY){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t{var t,e;if("visible"===document.visibilityState){if(Zr._onLog&&Zr._onLog("document visible. video paused: "+(null===(t=Bn(this,ar,"f"))||void 0===t?void 0:t.paused)),"opening"==this.state||"opened"==this.state){let e=!1;if(!this.isVideoPlaying){Zr._onLog&&Zr._onLog("document visible. Not auto resume. 1st resume start.");try{await this.resume(),e=!0}catch(t){Zr._onLog&&Zr._onLog("document visible. 1st resume video failed, try open instead.")}e||await Bn(this,sr,"m",Nr).call(this)}if(await new Promise((t=>setTimeout(t,300))),!this.isVideoPlaying){Zr._onLog&&Zr._onLog("document visible. 1st open failed. 2rd resume start."),e=!1;try{await this.resume(),e=!0}catch(t){Zr._onLog&&Zr._onLog("document visible. 2rd resume video failed, try open instead.")}e||await Bn(this,sr,"m",Nr).call(this)}}}else"hidden"===document.visibilityState&&(Zr._onLog&&Zr._onLog("document hidden. video paused: "+(null===(e=Bn(this,ar,"f"))||void 0===e?void 0:e.paused)),"opening"==this.state||"opened"==this.state&&this.isVideoPlaying&&this.pause())})),Lr.set(this,!1),(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia)||setTimeout((()=>{Zr.onWarning&&Zr.onWarning("The browser is too old or the page is loaded from an insecure origin.")}),0),this.defaultConstraints={video:{facingMode:{ideal:"environment"}}},this.resetMediaStreamConstraints(),t instanceof HTMLVideoElement&&this.setVideoEl(t),jn(this,xr,new Hr),this.imageDataGetter=new zr,document.addEventListener("visibilitychange",Bn(this,Dr,"f"))}setVideoEl(t){if(!(t&&t instanceof HTMLVideoElement))throw new Error("Invalid 'videoEl'.");t.addEventListener("play",Bn(this,lr,"f")),t.addEventListener("pause",Bn(this,hr,"f")),jn(this,ar,t)}getVideoEl(){return Bn(this,ar,"f")}releaseVideoEl(){var t,e;null===(t=Bn(this,ar,"f"))||void 0===t||t.removeEventListener("play",Bn(this,lr,"f")),null===(e=Bn(this,ar,"f"))||void 0===e||e.removeEventListener("pause",Bn(this,hr,"f")),jn(this,ar,null)}isVideoLoaded(){return!!Bn(this,ar,"f")&&4==Bn(this,ar,"f").readyState}async open(){if(Bn(this,pr,"f")&&!Bn(this,mr,"f")){if("pending"===Bn(this,_r,"f"))return Bn(this,pr,"f");if("fulfilled"===Bn(this,_r,"f"))return}Bn(this,xr,"f").fire("before:open",null,{target:this}),await Bn(this,sr,"m",Nr).call(this),Bn(this,xr,"f").fire("played",null,{target:this,async:!1}),Bn(this,xr,"f").fire("opened",null,{target:this,async:!1})}async close(){if("closed"===this.state)return;Bn(this,xr,"f").fire("before:close",null,{target:this});const t=Bn(this,pr,"f");if(Bn(this,sr,"m",jr).call(this),t&&"pending"===Bn(this,_r,"f")){try{await t}catch(t){}if(!1===Bn(this,mr,"f")){const t=new Error("'close()' was interrupted.");throw t.name="AbortError",t}}jn(this,pr,null),jn(this,_r,null),Bn(this,xr,"f").fire("closed",null,{target:this,async:!1})}pause(){if(!this.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==this.state)throw new Error("Camera or video is not open.");Bn(this,ar,"f").pause()}async resume(){if(!this.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==this.state)throw new Error("Camera or video is not open.");await Bn(this,ar,"f").play()}async setCamera(t){if("string"!=typeof t)throw new TypeError("Invalid 'deviceId'.");if("object"!=typeof Bn(this,cr,"f").video&&(Bn(this,cr,"f").video={}),delete Bn(this,cr,"f").video.facingMode,Bn(this,cr,"f").video.deviceId={exact:t},!("closed"===this.state||this.videoSrc||"opening"===this.state&&Bn(this,mr,"f"))){Bn(this,xr,"f").fire("before:camera:change",[],{target:this,async:!1}),await Bn(this,sr,"m",Br).call(this);try{this.resetSoftwareScale()}catch(t){}return Bn(this,dr,"f")}}async switchToFrontCamera(t){if("object"!=typeof Bn(this,cr,"f").video&&(Bn(this,cr,"f").video={}),(null==t?void 0:t.resolution)&&(Bn(this,cr,"f").video.width={ideal:t.resolution.width},Bn(this,cr,"f").video.height={ideal:t.resolution.height}),delete Bn(this,cr,"f").video.deviceId,Bn(this,cr,"f").video.facingMode={exact:"user"},jn(this,ur,null),!("closed"===this.state||this.videoSrc||"opening"===this.state&&Bn(this,mr,"f"))){Bn(this,xr,"f").fire("before:camera:change",[],{target:this,async:!1}),Bn(this,sr,"m",Br).call(this);try{this.resetSoftwareScale()}catch(t){}return Bn(this,dr,"f")}}getCamera(){var t;if(Bn(this,dr,"f"))return Bn(this,dr,"f");{let e=(null===(t=Bn(this,cr,"f").video)||void 0===t?void 0:t.deviceId)||"";if(e){e=e.exact||e.ideal||e;for(let t of this._arrCameras)if(t.deviceId===e)return JSON.parse(JSON.stringify(t))}return{deviceId:"",label:"",_checked:!1}}}async _getCameras(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let n;if(t){let t=await navigator.mediaDevices.getUserMedia({video:!0});n=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind)),t.getTracks().forEach((t=>{t.stop()}))}else n=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind));const r=[],s=[];if(this._arrCameras)for(let t of this._arrCameras)t._checked&&s.push(t);for(let t=0;t"videoinput"===t.kind));return i&&i.length&&!i[0].deviceId?this._getCameras(!0):this._getCameras(!1)}async getAllCameras(){return this.getCameras()}async setResolution(t,e,i){if("number"!=typeof t||t<=0)throw new TypeError("Invalid 'width'.");if("number"!=typeof e||e<=0)throw new TypeError("Invalid 'height'.");if("object"!=typeof Bn(this,cr,"f").video&&(Bn(this,cr,"f").video={}),i?(Bn(this,cr,"f").video.width={exact:t},Bn(this,cr,"f").video.height={exact:e}):(Bn(this,cr,"f").video.width={ideal:t},Bn(this,cr,"f").video.height={ideal:e}),"closed"===this.state||this.videoSrc||"opening"===this.state&&Bn(this,mr,"f"))return null;Bn(this,xr,"f").fire("before:resolution:change",[],{target:this,async:!1}),await Bn(this,sr,"m",Br).call(this);try{this.resetSoftwareScale()}catch(t){}const n=this.getResolution();return{width:n.width,height:n.height}}getResolution(){if("opened"===this.state&&this.videoSrc&&Bn(this,ar,"f"))return{width:Bn(this,ar,"f").videoWidth,height:Bn(this,ar,"f").videoHeight};if(Bn(this,or,"f")){const t=Bn(this,or,"f").getSettings();return{width:t.width,height:t.height}}if(this.isVideoLoaded())return{width:Bn(this,ar,"f").videoWidth,height:Bn(this,ar,"f").videoHeight};{const t={width:0,height:0};let e=Bn(this,cr,"f").video.width||0,i=Bn(this,cr,"f").video.height||0;return e&&(t.width=e.exact||e.ideal||e),i&&(t.height=i.exact||i.ideal||i),t}}async getResolutions(t){var e,i,n,r,s,a,o,l,h,c,d;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let u="";const f=(t,e)=>{const i=Bn(this,Ar,"f").get(t);if(!i||!i.length)return!1;for(let t of i)if(t.width===e.width&&t.height===e.height)return!0;return!1};if(this._mediaStream){u=null===(d=Bn(this,dr,"f"))||void 0===d?void 0:d.deviceId;let e=Bn(this,Ar,"f").get(u);if(e&&!t)return JSON.parse(JSON.stringify(e));e=[],Bn(this,Ar,"f").set(u,e),jn(this,vr,!0);try{for(let t of this.detectedResolutions){await Bn(this,or,"f").applyConstraints({width:{ideal:t.width},height:{ideal:t.height}}),Bn(this,sr,"m",Fr).call(this);const i=Bn(this,or,"f").getSettings(),n={width:i.width,height:i.height};f(u,n)||e.push({width:n.width,height:n.height})}}catch(t){throw Bn(this,sr,"m",jr).call(this),jn(this,vr,!1),t}try{await Bn(this,sr,"m",Nr).call(this)}catch(t){if("AbortError"===t.name)return e;throw t}finally{jn(this,vr,!1)}return e}{const e=async(t,e,i)=>{const n={video:{deviceId:{exact:t},width:{ideal:e},height:{ideal:i}}};let r=null;try{r=await navigator.mediaDevices.getUserMedia(n)}catch(t){return null}if(!r)return null;const s=r.getVideoTracks();let a=null;try{const t=s[0].getSettings();a={width:t.width,height:t.height}}catch(t){const e=document.createElement("video");e.srcObject=r,a={width:e.videoWidth,height:e.videoHeight},e.srcObject=null}return s.forEach((t=>{t.stop()})),a};let i=(null===(s=null===(r=null===(n=Bn(this,cr,"f"))||void 0===n?void 0:n.video)||void 0===r?void 0:r.deviceId)||void 0===s?void 0:s.exact)||(null===(l=null===(o=null===(a=Bn(this,cr,"f"))||void 0===a?void 0:a.video)||void 0===o?void 0:o.deviceId)||void 0===l?void 0:l.ideal)||(null===(c=null===(h=Bn(this,cr,"f"))||void 0===h?void 0:h.video)||void 0===c?void 0:c.deviceId);if(!i)return[];let d=Bn(this,Ar,"f").get(i);if(d&&!t)return JSON.parse(JSON.stringify(d));d=[],Bn(this,Ar,"f").set(i,d);for(let t of this.detectedResolutions){const n=await e(i,t.width,t.height);n&&!f(i,n)&&d.push({width:n.width,height:n.height})}return d}}async setMediaStreamConstraints(t,e){if(!(t=>{return null!==t&&"[object Object]"===(e=t,Object.prototype.toString.call(e));var e})(t))throw new TypeError("Invalid 'mediaStreamConstraints'.");jn(this,cr,JSON.parse(JSON.stringify(t))),jn(this,ur,null),e&&Bn(this,sr,"m",Br).call(this)}getMediaStreamConstraints(){return JSON.parse(JSON.stringify(Bn(this,cr,"f")))}resetMediaStreamConstraints(){jn(this,cr,this.defaultConstraints?JSON.parse(JSON.stringify(this.defaultConstraints)):null)}getCameraCapabilities(){if(!Bn(this,or,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return Bn(this,or,"f").getCapabilities?Bn(this,or,"f").getCapabilities():{}}getCameraSettings(){if(!Bn(this,or,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return Bn(this,or,"f").getSettings()}async turnOnTorch(){if(!Bn(this,or,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const t=this.getCameraCapabilities();if(!(null==t?void 0:t.torch))throw Error("Not supported.");await Bn(this,or,"f").applyConstraints({advanced:[{torch:!0}]})}async turnOffTorch(){if(!Bn(this,or,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const t=this.getCameraCapabilities();if(!(null==t?void 0:t.torch))throw Error("Not supported.");await Bn(this,or,"f").applyConstraints({advanced:[{torch:!1}]})}async setColorTemperature(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!Bn(this,or,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.colorTemperature;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Xr(t,n.min,n.step,n.max)),await Bn(this,or,"f").applyConstraints({advanced:[{colorTemperature:t,whiteBalanceMode:"manual"}]}),t}getColorTemperature(){return this.getCameraSettings().colorTemperature||0}async setExposureCompensation(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!Bn(this,or,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.exposureCompensation;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Xr(t,n.min,n.step,n.max)),await Bn(this,or,"f").applyConstraints({advanced:[{exposureCompensation:t}]}),t}getExposureCompensation(){return this.getCameraSettings().exposureCompensation||0}async setFrameRate(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!Bn(this,or,"f")||"opened"!==this.state)throw new Error("Camera is not open.");let n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.frameRate;if(!n)throw Error("Not supported.");e&&(tn.max&&(t=n.max));const r=this.getResolution();return await Bn(this,or,"f").applyConstraints({width:{ideal:Math.max(r.width,r.height)},frameRate:t}),t}getFrameRate(){return this.getCameraSettings().frameRate}async setFocus(t,e){if("object"!=typeof t||Array.isArray(t)||null==t)throw new TypeError("Invalid 'settings'.");if(!Bn(this,or,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const i=this.getCameraCapabilities(),n=null==i?void 0:i.focusMode,r=null==i?void 0:i.focusDistance;if(!n)throw Error("Not supported.");if("string"!=typeof t.mode)throw TypeError("Invalid 'mode'.");const s=t.mode.toLowerCase();if(!n.includes(s))throw Error("Unsupported focus mode.");if("manual"===s){if(!r)throw Error("Manual focus unsupported.");if(t.hasOwnProperty("distance")){let i=t.distance;e&&(ir.max&&(i=r.max),i=Xr(i,r.min,r.step,r.max)),this._focusParameters.focusArea=null,await Bn(this,or,"f").applyConstraints({advanced:[{focusMode:s,focusDistance:i}]})}else{if(!t.area)throw new Error("'distance' or 'area' should be specified in 'manual' mode.");{const e=t.area.centerPoint;let i=t.area.width,n=t.area.height;if(!i||!n){const t=this.getResolution();i||(i=2*Math.round(Math.min(t.width,t.height)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px"),n||(n=2*Math.round(Math.min(t.width,t.height)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px")}this._focusParameters.focusArea={centerPoint:{x:e.x,y:e.y},width:i,height:n},await Bn(this,sr,"m",Gr).call(this,e,i,n)}}}else this._focusParameters.focusArea=null,await Bn(this,or,"f").applyConstraints({advanced:[{focusMode:s}]})}getFocus(){const t=this.getCameraSettings(),e=t.focusMode;return e?"manual"===e?this._focusParameters.focusArea?{mode:"manual",area:JSON.parse(JSON.stringify(this._focusParameters.focusArea))}:{mode:"manual",distance:t.focusDistance}:{mode:e}:null}async enableTapToFocus(){jn(this,yr,!0)}disableTapToFocus(){jn(this,yr,!1)}isTapToFocusEnabled(){return Bn(this,yr,"f")}async setZoom(t){if("object"!=typeof t||Array.isArray(t)||null==t)throw new TypeError("Invalid 'settings'.");if("number"!=typeof t.factor)throw new TypeError("Illegal type of 'factor'.");if(t.factor<1)throw new RangeError("Invalid 'factor'.");if("opened"!==this.state)throw new Error("Video is not playing.");t.centerPoint?Bn(this,sr,"m",Wr).call(this,t.centerPoint):this.resetScaleCenter();try{if(Bn(this,sr,"m",Yr).call(this,Bn(this,Tr,"f"))){const e=await this.setHardwareScale(t.factor,!0);let i=this.getHardwareScale();1==i&&1!=e&&(i=e),t.factor>i?this.setSoftwareScale(t.factor/i):this.setSoftwareScale(1)}else await this.setHardwareScale(1),this.setSoftwareScale(t.factor)}catch(e){const i=e.message||e;if("Not supported."!==i&&"Camera is not open."!==i)throw e;this.setSoftwareScale(t.factor)}}getZoom(){if("opened"!==this.state)throw new Error("Video is not playing.");let t=1;try{t=this.getHardwareScale()}catch(t){if("Camera is not open."!==(t.message||t))throw t}return{factor:t*Bn(this,br,"f")}}async resetZoom(){await this.setZoom({factor:1})}async setHardwareScale(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(t<1)throw new RangeError("Invalid 'value'.");if(!Bn(this,or,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.zoom;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Xr(t,n.min,n.step,n.max)),await Bn(this,or,"f").applyConstraints({advanced:[{zoom:t}]}),t}getHardwareScale(){return this.getCameraSettings().zoom||1}setSoftwareScale(t,e){if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(t<1)throw new RangeError("Invalid 'value'.");if("opened"!==this.state)throw new Error("Video is not playing.");e&&Bn(this,sr,"m",Wr).call(this,e),jn(this,br,t),this.updateVideoElWhenSoftwareScaled()}getSoftwareScale(){return Bn(this,br,"f")}resetScaleCenter(){if("opened"!==this.state)throw new Error("Video is not playing.");const t=this.getResolution();jn(this,Tr,{x:t.width/2,y:t.height/2})}resetSoftwareScale(){this.setSoftwareScale(1),this.resetScaleCenter()}getFrameData(t){if(this.disposed)throw Error("The 'Camera' instance has been disposed.");if(!this.isVideoLoaded())return null;if(Bn(this,vr,"f"))return null;const e=Date.now();Zr._onLog&&Zr._onLog("getFrameData() START: "+e);const i=Bn(this,ar,"f").videoWidth,n=Bn(this,ar,"f").videoHeight;let r={sx:0,sy:0,sWidth:i,sHeight:n,dWidth:i,dHeight:n};(null==t?void 0:t.position)&&(r=JSON.parse(JSON.stringify(t.position)));let s=qn.RGBA;(null==t?void 0:t.pixelFormat)&&(s=t.pixelFormat);let a=Bn(this,br,"f");(null==t?void 0:t.scale)&&(a=t.scale);let o=Bn(this,Tr,"f");if(null==t?void 0:t.scaleCenter){if("string"!=typeof t.scaleCenter.x||"string"!=typeof t.scaleCenter.y)throw new Error("Invalid scale center.");let e=0,r=0;if(t.scaleCenter.x.endsWith("px"))e=parseFloat(t.scaleCenter.x);else{if(!t.scaleCenter.x.endsWith("%"))throw new Error("Invalid scale center.");e=parseFloat(t.scaleCenter.x)/100*i}if(t.scaleCenter.y.endsWith("px"))r=parseFloat(t.scaleCenter.y);else{if(!t.scaleCenter.y.endsWith("%"))throw new Error("Invalid scale center.");r=parseFloat(t.scaleCenter.y)/100*n}if(isNaN(e)||isNaN(r))throw new Error("Invalid scale center.");o.x=Math.round(e),o.y=Math.round(r)}let l=null;if((null==t?void 0:t.bufferContainer)&&(l=t.bufferContainer),0==i||0==n)return null;1!==a&&(r.sWidth=Math.round(r.sWidth/a),r.sHeight=Math.round(r.sHeight/a),r.sx=Math.round((1-1/a)*o.x+r.sx/a),r.sy=Math.round((1-1/a)*o.y+r.sy/a));const h=this.imageDataGetter.getImageData(Bn(this,ar,"f"),r,{pixelFormat:s,bufferContainer:l});if(!h)return null;const c=Date.now();return Zr._onLog&&Zr._onLog("getFrameData() END: "+c),{data:h.data,width:h.width,height:h.height,pixelFormat:h.pixelFormat,timeSpent:c-e,timeStamp:c,toCanvas:Bn(this,Ir,"f")}}on(t,e){if(!Bn(this,Or,"f").includes(t.toLowerCase()))throw new Error(`Event '${t}' does not exist.`);Bn(this,xr,"f").on(t,e)}off(t,e){Bn(this,xr,"f").off(t,e)}async dispose(){this.tapFocusEventBoundEl=null,await this.close(),this.releaseVideoEl(),Bn(this,xr,"f").dispose(),this.imageDataGetter.dispose(),document.removeEventListener("visibilitychange",Bn(this,Dr,"f")),jn(this,Lr,!0)}}var qr,Jr,Kr,$r,Qr,ts,es,is,ns,rs,ss,as,os,ls,hs,cs,ds,us,fs,gs,ms,ps,_s,vs,ys,ws,Cs,Es,Ss,bs,Ts,Is,xs,Os,As;ar=new WeakMap,or=new WeakMap,lr=new WeakMap,hr=new WeakMap,cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,fr=new WeakMap,gr=new WeakMap,mr=new WeakMap,pr=new WeakMap,_r=new WeakMap,vr=new WeakMap,yr=new WeakMap,wr=new WeakMap,Cr=new WeakMap,Er=new WeakMap,Sr=new WeakMap,br=new WeakMap,Tr=new WeakMap,Ir=new WeakMap,xr=new WeakMap,Or=new WeakMap,Ar=new WeakMap,Rr=new WeakMap,Dr=new WeakMap,Lr=new WeakMap,sr=new WeakSet,Mr=async function(){const t=this.getMediaStreamConstraints();if("boolean"==typeof t.video&&(t.video={}),t.video.deviceId);else if(Bn(this,ur,"f"))delete t.video.facingMode,t.video.deviceId={exact:Bn(this,ur,"f")};else if(this.ifSaveLastUsedCamera&&Zr.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")){delete t.video.facingMode,t.video.deviceId={ideal:window.localStorage.getItem("dce_last_camera_id")};const e=JSON.parse(window.localStorage.getItem("dce_last_apply_width")),i=JSON.parse(window.localStorage.getItem("dce_last_apply_height"));e&&i&&(t.video.width=e,t.video.height=i)}else if(this.ifSkipCameraInspection);else{const e=async t=>{let e=null;return"environment"===t&&["Android","HarmonyOS","iPhone","iPad"].includes(zn.OS)?(await this._getCameras(!1),Bn(this,sr,"m",Fr).call(this),e=Zr.findBestCamera(this._arrCameras,"environment",{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault})):t||["Android","HarmonyOS","iPhone","iPad"].includes(zn.OS)||(await this._getCameras(!1),Bn(this,sr,"m",Fr).call(this),e=Zr.findBestCamera(this._arrCameras,null,{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault})),e};let i=t.video.facingMode;i instanceof Array&&i.length&&(i=i[0]),"object"==typeof i&&(i=i.exact||i.ideal);const n=await e(i);n&&(delete t.video.facingMode,t.video.deviceId={exact:n})}return t},Fr=function(){if(Bn(this,mr,"f")){const t=new Error("The operation was interrupted.");throw t.name="AbortError",t}},Pr=async function(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let n;try{Zr._onLog&&Zr._onLog("======try getUserMedia========");let e=[0,500,1e3,2e3],i=null;const r=async t=>{for(let r of e){r&&(await new Promise((t=>setTimeout(t,r))),Bn(this,sr,"m",Fr).call(this));try{Zr._onLog&&Zr._onLog("ask "+JSON.stringify(t)),n=await navigator.mediaDevices.getUserMedia(t),Bn(this,sr,"m",Fr).call(this);break}catch(t){if("NotFoundError"===t.name||"NotAllowedError"===t.name||"AbortError"===t.name||"OverconstrainedError"===t.name)throw t;i=t,Zr._onLog&&Zr._onLog(t.message||t)}}};if(await r(t),n||"object"!=typeof t.video||(t.video.deviceId&&(delete t.video.deviceId,await r(t)),!n&&t.video.facingMode&&(delete t.video.facingMode,await r(t)),n||!t.video.width&&!t.video.height||(delete t.video.width,delete t.video.height,await r(t))),!n)throw i;return n}catch(t){throw null==n||n.getTracks().forEach((t=>{t.stop()})),"NotFoundError"===t.name&&(DOMException?t=new DOMException("No camera available, please use a device with an accessible camera.",t.name):(t=new Error("No camera available, please use a device with an accessible camera.")).name="NotFoundError"),t}},kr=function(){this._mediaStream&&(this._mediaStream.getTracks().forEach((t=>{t.stop()})),this._mediaStream=null),jn(this,or,null)},Nr=async function(){jn(this,mr,!1);const t=jn(this,gr,Symbol());if(Bn(this,pr,"f")&&"pending"===Bn(this,_r,"f")){try{await Bn(this,pr,"f")}catch(t){}Bn(this,sr,"m",Fr).call(this)}if(t!==Bn(this,gr,"f"))return;const e=jn(this,pr,(async()=>{jn(this,_r,"pending");try{if(this.videoSrc){if(!Bn(this,ar,"f"))throw new Error("'videoEl' should be set.");await Zr.playVideo(Bn(this,ar,"f"),this.videoSrc,this.cameraOpenTimeout),Bn(this,sr,"m",Fr).call(this)}else{let t=await Bn(this,sr,"m",Mr).call(this);Bn(this,sr,"m",kr).call(this);let e=await Bn(this,sr,"m",Pr).call(this,t);await this._getCameras(!1),Bn(this,sr,"m",Fr).call(this);const i=()=>{const t=e.getVideoTracks();let i,n;if(t.length&&(i=t[0]),i){const t=i.getSettings();if(t)for(let e of this._arrCameras)if(t.deviceId===e.deviceId){e._checked=!0,e.label=i.label,n=e;break}}return n},n=Bn(this,cr,"f");if("object"==typeof n.video){let r=n.video.facingMode;if(r instanceof Array&&r.length&&(r=r[0]),"object"==typeof r&&(r=r.exact||r.ideal),!(Bn(this,ur,"f")||this.ifSaveLastUsedCamera&&Zr.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")||this.ifSkipCameraInspection||n.video.deviceId)){const n=i(),s=Zr.findBestCamera(this._arrCameras,r,{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault});s&&s!=(null==n?void 0:n.deviceId)&&(e.getTracks().forEach((t=>{t.stop()})),t.video.deviceId={exact:s},e=await Bn(this,sr,"m",Pr).call(this,t),Bn(this,sr,"m",Fr).call(this))}}const r=i();(null==r?void 0:r.deviceId)&&(jn(this,ur,r&&r.deviceId),this.ifSaveLastUsedCamera&&Zr.isStorageAvailable&&(window.localStorage.setItem("dce_last_camera_id",Bn(this,ur,"f")),"object"==typeof t.video&&t.video.width&&t.video.height&&(window.localStorage.setItem("dce_last_apply_width",JSON.stringify(t.video.width)),window.localStorage.setItem("dce_last_apply_height",JSON.stringify(t.video.height))))),Bn(this,ar,"f")&&(await Zr.playVideo(Bn(this,ar,"f"),e,this.cameraOpenTimeout),Bn(this,sr,"m",Fr).call(this)),this._mediaStream=e;const s=e.getVideoTracks();(null==s?void 0:s.length)&&jn(this,or,s[0]),jn(this,dr,r)}}catch(t){throw Bn(this,sr,"m",jr).call(this),jn(this,_r,null),t}jn(this,_r,"fulfilled")})());return e},Br=async function(){var t;if("closed"===this.state||this.videoSrc)return;const e=null===(t=Bn(this,dr,"f"))||void 0===t?void 0:t.deviceId,i=this.getResolution();await Bn(this,sr,"m",Nr).call(this);const n=this.getResolution();e&&e!==Bn(this,dr,"f").deviceId&&Bn(this,xr,"f").fire("camera:changed",[Bn(this,dr,"f").deviceId,e],{target:this,async:!1}),i.width==n.width&&i.height==n.height||Bn(this,xr,"f").fire("resolution:changed",[{width:n.width,height:n.height},{width:i.width,height:i.height}],{target:this,async:!1}),Bn(this,xr,"f").fire("played",null,{target:this,async:!1})},jr=function(){Bn(this,sr,"m",kr).call(this),jn(this,dr,null),Bn(this,ar,"f")&&(Bn(this,ar,"f").srcObject=null,this.videoSrc&&(Bn(this,ar,"f").pause(),Bn(this,ar,"f").currentTime=0)),jn(this,mr,!0);try{this.resetSoftwareScale()}catch(t){}},Vr=async function t(e,i){const n=t=>{if(!Bn(this,or,"f")||!this.isVideoPlaying||t.focusTaskId!=this._focusParameters.curFocusTaskId){Bn(this,or,"f")&&this.isVideoPlaying||(this._focusParameters.isDoingFocus=0);const e=new Error(`Focus task ${t.focusTaskId} canceled.`);throw e.name="DeprecatedTaskError",e}1===this._focusParameters.isDoingFocus&&Date.now()-t.timeStart>this._focusParameters.focusCancelableTime&&(this._focusParameters.isDoingFocus=-1)};let r;i=Xr(i,this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),await Bn(this,or,"f").applyConstraints({advanced:[{focusMode:"manual",focusDistance:i}]}),n(e),r=null==this._focusParameters.oldDistance?this._focusParameters.kTimeout*Math.max(Math.abs(1/this._focusParameters.fds.min-1/i),Math.abs(1/this._focusParameters.fds.max-1/i))+this._focusParameters.minTimeout:this._focusParameters.kTimeout*Math.abs(1/this._focusParameters.oldDistance-1/i)+this._focusParameters.minTimeout,this._focusParameters.oldDistance=i,await new Promise((t=>{setTimeout(t,r)})),n(e);let s=e.focusL-e.focusW/2,a=e.focusT-e.focusH/2,o=e.focusW,l=e.focusH;const h=this.getResolution();s=Math.round(s),a=Math.round(a),o=Math.round(o),l=Math.round(l),o>h.width&&(o=h.width),l>h.height&&(l=h.height),s<0?s=0:s+o>h.width&&(s=h.width-o),a<0?a=0:a+l>h.height&&(a=h.height-l);const c=4*h.width*h.height*this._focusParameters.defaultTempBufferContainerLenRatio,d=4*o*l;let u=this._focusParameters.tempBufferContainer;if(u){const t=u.length;c>t&&c>=d?u=new Uint8Array(c):d>t&&d>=c&&(u=new Uint8Array(d))}else u=this._focusParameters.tempBufferContainer=new Uint8Array(Math.max(c,d));if(!this.imageDataGetter.getImageData(Bn(this,ar,"f"),{sx:s,sy:a,sWidth:o,sHeight:l,dWidth:o,dHeight:l},{pixelFormat:qn.RGBA,bufferContainer:u}))return Bn(this,sr,"m",t).call(this,e,i);const f=u;let g=0;for(let t=0,e=d-8;to&&od)return await Bn(this,sr,"m",t).call(this,e,a,o,r,s,c,d)}else{let l=await Bn(this,sr,"m",Vr).call(this,e,c);if(o>l)return await Bn(this,sr,"m",t).call(this,e,a,o,r,s,c,l);if(o==l)return await Bn(this,sr,"m",t).call(this,e,a,o,c,l);let d=await Bn(this,sr,"m",Vr).call(this,e,h);if(d>o&&oa.width||l<0||l>a.height)throw new Error("Invalid 'centerPoint'.");let h=0;if(e.endsWith("px"))h=parseFloat(e);else{if(!e.endsWith("%"))throw new Error("Invalid 'width'.");h=parseFloat(e)/100*a.width}if(isNaN(h)||h<0)throw new Error("Invalid 'width'.");let c=0;if(i.endsWith("px"))c=parseFloat(i);else{if(!i.endsWith("%"))throw new Error("Invalid 'height'.");c=parseFloat(i)/100*a.height}if(isNaN(c)||c<0)throw new Error("Invalid 'height'.");if(1!==Bn(this,br,"f")){const t=Bn(this,br,"f"),e=Bn(this,Tr,"f");h/=t,c/=t,o=(1-1/t)*e.x+o/t,l=(1-1/t)*e.y+l/t}if(!this._focusSupported)throw new Error("Manual focus unsupported.");if(!this._focusParameters.fds&&(this._focusParameters.fds=null===(s=this.getCameraCapabilities())||void 0===s?void 0:s.focusDistance,!this._focusParameters.fds))throw this._focusSupported=!1,new Error("Manual focus unsupported.");null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),this._focusParameters.isDoingFocus=1;const d={focusL:o,focusT:l,focusW:h,focusH:c,focusTaskId:++this._focusParameters.curFocusTaskId,timeStart:Date.now()},u=async(t,e,i)=>{try{(null==e||ethis._focusParameters.fds.max)&&(i=this._focusParameters.fds.max),this._focusParameters.oldDistance=null;let n=Xr(Math.sqrt(i*(e||this._focusParameters.fds.step)),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),r=Xr(Math.sqrt((e||this._focusParameters.fds.step)*n),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),s=Xr(Math.sqrt(n*i),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),a=await Bn(this,sr,"m",Vr).call(this,t,s),o=await Bn(this,sr,"m",Vr).call(this,t,r),l=await Bn(this,sr,"m",Vr).call(this,t,n);if(o>l&&la&&o>a){let e=await Bn(this,sr,"m",Vr).call(this,t,i);const r=await Bn(this,sr,"m",Ur).call(this,t,n,l,i,e,s,a);return this._focusParameters.isDoingFocus=0,r}if(o==l&&ll){const e=await Bn(this,sr,"m",Ur).call(this,t,n,l,s,a);return this._focusParameters.isDoingFocus=0,e}return u(t,e,i)}catch(t){if("DeprecatedTaskError"!==t.name)throw t}};return u(d,n,r)},Wr=function(t){if("opened"!==this.state)throw new Error("Video is not playing.");if(!t||"string"!=typeof t.x||"string"!=typeof t.y)throw new Error("Invalid 'center'.");const e=this.getResolution();let i=0,n=0;if(t.x.endsWith("px"))i=parseFloat(t.x);else{if(!t.x.endsWith("%"))throw new Error("Invalid scale center.");i=parseFloat(t.x)/100*e.width}if(t.y.endsWith("px"))n=parseFloat(t.y);else{if(!t.y.endsWith("%"))throw new Error("Invalid scale center.");n=parseFloat(t.y)/100*e.height}if(isNaN(i)||isNaN(n))throw new Error("Invalid scale center.");jn(this,Tr,{x:i,y:n})},Yr=function(t){if("opened"!==this.state)throw new Error("Video is not playing.");const e=this.getResolution();return t&&t.x==e.width/2&&t.y==e.height/2},Zr.browserInfo=zn,Zr.onWarning=null===(rr=null===window||void 0===window?void 0:window.console)||void 0===rr?void 0:rr.warn;class Rs{constructor(t){qr.add(this),Jr.set(this,void 0),Kr.set(this,0),$r.set(this,void 0),Qr.set(this,0),ts.set(this,!1),Ke(this,Jr,t)}startCharging(){Je(this,ts,"f")||(Rs._onLog&&Rs._onLog("start charging."),Je(this,qr,"m",is).call(this),Ke(this,ts,!0))}stopCharging(){Je(this,$r,"f")&&clearTimeout(Je(this,$r,"f")),Je(this,ts,"f")&&(Rs._onLog&&Rs._onLog("stop charging."),Ke(this,Kr,Date.now()-Je(this,Qr,"f")),Ke(this,ts,!1))}}Jr=new WeakMap,Kr=new WeakMap,$r=new WeakMap,Qr=new WeakMap,ts=new WeakMap,qr=new WeakSet,es=function(){vt.cfd(1),Rs._onLog&&Rs._onLog("charge 1.")},is=function t(){0==Je(this,Kr,"f")&&Je(this,qr,"m",es).call(this),Ke(this,Qr,Date.now()),Je(this,$r,"f")&&clearTimeout(Je(this,$r,"f")),Ke(this,$r,setTimeout((()=>{Ke(this,Kr,0),Je(this,qr,"m",t).call(this)}),Je(this,Jr,"f")-Je(this,Kr,"f")))};class Ds{static beep(){if(!this.allowBeep)return;if(!this.beepSoundSource)return;let t,e=Date.now();if(!(e-Je(this,ns,"f",as)<100)){if(Ke(this,ns,e,0,as),Je(this,ns,"f",rs).size&&(t=Je(this,ns,"f",rs).values().next().value,this.beepSoundSource==t.src?(Je(this,ns,"f",rs).delete(t),t.play()):t=null),!t)if(Je(this,ns,"f",ss).size<16){t=new Audio(this.beepSoundSource);let e=null,i=()=>{t.removeEventListener("loadedmetadata",i),t.play(),e=setTimeout((()=>{Je(this,ns,"f",ss).delete(t)}),2e3*t.duration)};t.addEventListener("loadedmetadata",i),t.addEventListener("ended",(()=>{null!=e&&(clearTimeout(e),e=null),t.pause(),t.currentTime=0,Je(this,ns,"f",ss).delete(t),Je(this,ns,"f",rs).add(t)}))}else Je(this,ns,"f",os)||(Ke(this,ns,!0,0,os),console.warn("The requested audio tracks exceed 16 and will not be played."));t&&Je(this,ns,"f",ss).add(t)}}static vibrate(){if(this.allowVibrate){if(!navigator||!navigator.vibrate)throw new Error("Not supported.");navigator.vibrate(Ds.vibrateDuration)}}}ns=Ds,rs={value:new Set},ss={value:new Set},as={value:0},os={value:!1},Ds.allowBeep=!0,Ds.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",Ds.allowVibrate=!0,Ds.vibrateDuration=300;const Ls=new Map([[qn.GREY,o.IPF_GRAYSCALED],[qn.RGBA,o.IPF_ABGR_8888]]),Ms="function"==typeof BigInt?{BF_NULL:BigInt(0),BF_ALL:BigInt(0x10000000000000000),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_NULL:"0x00",BF_ALL:"0xFFFFFFFFFFFFFFFF",BF_DEFAULT:"0xFE3BFFFF",BF_ONED:"0x003007FF",BF_GS1_DATABAR:"0x0003F800",BF_CODE_39:"0x1",BF_CODE_128:"0x2",BF_CODE_93:"0x4",BF_CODABAR:"0x8",BF_ITF:"0x10",BF_EAN_13:"0x20",BF_EAN_8:"0x40",BF_UPC_A:"0x80",BF_UPC_E:"0x100",BF_INDUSTRIAL_25:"0x200",BF_CODE_39_EXTENDED:"0x400",BF_GS1_DATABAR_OMNIDIRECTIONAL:"0x800",BF_GS1_DATABAR_TRUNCATED:"0x1000",BF_GS1_DATABAR_STACKED:"0x2000",BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL:"0x4000",BF_GS1_DATABAR_EXPANDED:"0x8000",BF_GS1_DATABAR_EXPANDED_STACKED:"0x10000",BF_GS1_DATABAR_LIMITED:"0x20000",BF_PATCHCODE:"0x00040000",BF_CODE_32:"0x01000000",BF_PDF417:"0x02000000",BF_QR_CODE:"0x04000000",BF_DATAMATRIX:"0x08000000",BF_AZTEC:"0x10000000",BF_MAXICODE:"0x20000000",BF_MICRO_QR:"0x40000000",BF_MICRO_PDF417:"0x00080000",BF_GS1_COMPOSITE:"0x80000000",BF_MSI_CODE:"0x100000",BF_CODE_11:"0x200000",BF_TWO_DIGIT_ADD_ON:"0x400000",BF_FIVE_DIGIT_ADD_ON:"0x800000",BF_MATRIX_25:"0x1000000000",BF_POSTALCODE:"0x3F0000000000000",BF_NONSTANDARD_BARCODE:"0x100000000",BF_USPSINTELLIGENTMAIL:"0x10000000000000",BF_POSTNET:"0x20000000000000",BF_PLANET:"0x40000000000000",BF_AUSTRALIANPOST:"0x80000000000000",BF_RM4SCC:"0x100000000000000",BF_KIX:"0x200000000000000",BF_DOTCODE:"0x200000000",BF_PHARMACODE_ONE_TRACK:"0x400000000",BF_PHARMACODE_TWO_TRACK:"0x800000000",BF_PHARMACODE:"0xC00000000"};class Fs extends K{static set _onLog(t){Ke(Fs,hs,t,0,cs),Zr._onLog=t,Rs._onLog=t}static get _onLog(){return Je(Fs,hs,"f",cs)}static async detectEnvironment(){return await(async()=>({wasm:$e,worker:Qe,getUserMedia:ti,camera:await ei(),browser:Ze.browser,version:Ze.version,OS:Ze.OS}))()}static async testCameraAccess(){const t=await Zr.testCameraAccess();return t.ok?{ok:!0,message:"Successfully accessed the camera."}:"InsecureContext"===t.errorName?{ok:!1,message:"Insecure context."}:"OverconstrainedError"===t.errorName||"NotFoundError"===t.errorName?{ok:!1,message:"No camera detected."}:"NotAllowedError"===t.errorName?{ok:!1,message:"No permission to access camera."}:"AbortError"===t.errorName?{ok:!1,message:"Some problem occurred which prevented the device from being used."}:"NotReadableError"===t.errorName?{ok:!1,message:"A hardware error occurred."}:"SecurityError"===t.errorName?{ok:!1,message:"User media support is disabled."}:{ok:!1,message:t.errorMessage}}static async createInstance(t){var e,i;if(t&&!(t instanceof Nn))throw new TypeError("Invalid view.");if(null===(e=gt.license)||void 0===e?void 0:e.LicenseManager){if(!(null===(i=gt.license)||void 0===i?void 0:i.LicenseManager.bCallInitLicense))throw new Error("License is not set.");await vt.loadWasm(["license"]),await gt.license.dynamsoft()}const n=new Fs(t);return Fs.onWarning&&(location&&"file:"===location.protocol?setTimeout((()=>{Fs.onWarning&&Fs.onWarning({id:1,message:"The page is opened over file:// and Dynamsoft Camera Enhancer may not work properly. Please open the page via https://."})}),0):!1!==window.isSecureContext&&navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia||setTimeout((()=>{Fs.onWarning&&Fs.onWarning({id:2,message:"Dynamsoft Camera Enhancer may not work properly in a non-secure context. Please open the page via https://."})}),0)),n}get video(){return this.cameraManager.getVideoEl()}set videoSrc(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraView&&(this.cameraView._hideDefaultSelection=!0),this.cameraManager.videoSrc=t}get videoSrc(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.videoSrc}set ifSaveLastUsedCamera(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.ifSaveLastUsedCamera=t}get ifSaveLastUsedCamera(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.ifSaveLastUsedCamera}set ifSkipCameraInspection(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.ifSkipCameraInspection=t}get ifSkipCameraInspection(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.ifSkipCameraInspection}set cameraOpenTimeout(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.cameraOpenTimeout=t}get cameraOpenTimeout(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.cameraOpenTimeout}set singleFrameMode(t){if(!["disabled","image","camera"].includes(t))throw new Error("Invalid value.");if(this.isOpen())throw new Error("It is not allowed to change `singleFrameMode` when the camera is open.");Ke(this,fs,t)}get singleFrameMode(){return Je(this,fs,"f")}get _isFetchingStarted(){return Je(this,ys,"f")}get disposed(){return Je(this,bs,"f")}constructor(t){if(super(),ls.add(this),ds.set(this,"closed"),us.set(this,void 0),this.isTorchOn=void 0,fs.set(this,void 0),this._onCameraSelChange=async()=>{this.isOpen()&&this.cameraView&&!this.cameraView.disposed&&await this.selectCamera(this.cameraView._selCam.value)},this._onResolutionSelChange=async()=>{if(!this.isOpen())return;if(!this.cameraView||this.cameraView.disposed)return;let t,e;if(this.cameraView._selRsl&&-1!=this.cameraView._selRsl.selectedIndex){let i=this.cameraView._selRsl.options[this.cameraView._selRsl.selectedIndex];t=parseInt(i.getAttribute("data-width")),e=parseInt(i.getAttribute("data-height"))}await this.setResolution({width:t,height:e})},this._onCloseBtnClick=async()=>{this.isOpen()&&this.cameraView&&!this.cameraView.disposed&&this.close()},gs.set(this,((t,e,i,n)=>{const r=Date.now(),s={sx:n.x,sy:n.y,sWidth:n.width,sHeight:n.height,dWidth:n.width,dHeight:n.height},a=Math.max(s.dWidth,s.dHeight);if(this.canvasSizeLimit&&a>this.canvasSizeLimit){const t=this.canvasSizeLimit/a;s.dWidth>s.dHeight?(s.dWidth=this.canvasSizeLimit,s.dHeight=Math.round(s.dHeight*t)):(s.dWidth=Math.round(s.dWidth*t),s.dHeight=this.canvasSizeLimit)}const l=this.cameraManager.imageDataGetter.getImageData(t,s,{pixelFormat:this.getPixelFormat()===o.IPF_GRAYSCALED?qn.GREY:qn.RGBA});let h=null;if(l){const t=Date.now();let a;a=l.pixelFormat===qn.GREY?l.width:4*l.width;let o=!0;0===s.sx&&0===s.sy&&s.sWidth===e&&s.sHeight===i&&(o=!1),h={bytes:l.data,width:l.width,height:l.height,stride:a,format:Ls.get(l.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:bt.ITT_FILE_IMAGE,isCropped:o,cropRegion:{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height,isMeasuredInPercentage:!1},originalWidth:e,originalHeight:i,currentWidth:l.width,currentHeight:l.height,timeSpent:t-r,timeStamp:t},toCanvas:Je(this,ms,"f"),isDCEFrame:!0}}return h})),this._onSingleFrameAcquired=t=>{let e;e=this.cameraView?this.cameraView.getConvertedRegion():Gi.convert(Je(this,_s,"f"),t.width,t.height),e||(e={x:0,y:0,width:t.width,height:t.height});const i=Je(this,gs,"f").call(this,t,t.width,t.height,e);Je(this,us,"f").fire("singleFrameAcquired",[i],{async:!1,copy:!1})},ms.set(this,(function(){if(!(this.bytes instanceof Uint8Array||this.bytes instanceof Uint8ClampedArray))throw new TypeError("Invalid bytes.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const t=document.createElement("canvas");let e;if(t.width=this.width,t.height=this.height,this.format===o.IPF_GRAYSCALED){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t{if(!this.video)return;const t=this.cameraManager.getSoftwareScale();if(t<1)throw new RangeError("Invalid scale value.");this.cameraView&&!this.cameraView.disposed?(this.video.style.transform=1===t?"":`scale(${t})`,this.cameraView._updateVideoContainer()):this.video.style.transform=1===t?"":`scale(${t})`},["iPhone","iPad","Android","HarmonyOS"].includes(Ze.OS)?this.cameraManager.setResolution(1280,720):this.cameraManager.setResolution(1920,1080),navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?this.singleFrameMode="disabled":this.singleFrameMode="image",t&&(this.setCameraView(t),t.cameraEnhancer=this),this._on("before:camera:change",(()=>{Je(this,Ss,"f").stopCharging();const t=this.cameraView;t&&!t.disposed&&(t._startLoading(),t.clearAllInnerDrawingItems())})),this._on("camera:changed",(()=>{this.clearBuffer()})),this._on("before:resolution:change",(()=>{const t=this.cameraView;t&&!t.disposed&&(t._startLoading(),t.clearAllInnerDrawingItems())})),this._on("resolution:changed",(()=>{this.clearBuffer(),t.eventHandler.fire("content:updated",null,{async:!1})})),this._on("paused",(()=>{Je(this,Ss,"f").stopCharging();const t=this.cameraView;t&&t.disposed})),this._on("resumed",(()=>{const t=this.cameraView;t&&t.disposed})),this._on("tapfocus",(()=>{Je(this,Cs,"f").tapToFocus&&Je(this,Ss,"f").startCharging()})),this._intermediateResultReceiver={},this._intermediateResultReceiver.onTaskResultsReceived=async(t,e)=>{var i,n,r,s;if(Je(this,ls,"m",Ts).call(this)||!this.isOpen()||this.isPaused())return;const a=t.intermediateResultUnits;Fs._onLog&&(Fs._onLog("intermediateResultUnits:"),Fs._onLog(a));let o=!1,l=!1;for(let t of a){if(t.unitType===Ot.IRUT_DECODED_BARCODES&&t.decodedBarcodes.length){o=!0;break}t.unitType===Ot.IRUT_LOCALIZED_BARCODES&&t.localizedBarcodes.length&&(l=!0)}if(Fs._onLog&&(Fs._onLog("hasLocalizedBarcodes:"),Fs._onLog(l)),Je(this,Cs,"f").autoZoom||Je(this,Cs,"f").enhancedFocus)if(o)Je(this,Es,"f").autoZoomInFrameArray.length=0,Je(this,Es,"f").autoZoomOutFrameCount=0,Je(this,Es,"f").frameArrayInIdealZoom.length=0,Je(this,Es,"f").autoFocusFrameArray.length=0;else{const e=async t=>{await this.setZoom(t),Je(this,Cs,"f").autoZoom&&Je(this,Ss,"f").startCharging()},o=async t=>{await this.setFocus(t),Je(this,Cs,"f").enhancedFocus&&Je(this,Ss,"f").startCharging()};if(l){const l=a[0].originalImageTag,h=(null===(i=l.cropRegion)||void 0===i?void 0:i.left)||0,c=(null===(n=l.cropRegion)||void 0===n?void 0:n.top)||0,d=(null===(r=l.cropRegion)||void 0===r?void 0:r.right)?l.cropRegion.right-h:l.originalWidth,u=(null===(s=l.cropRegion)||void 0===s?void 0:s.bottom)?l.cropRegion.bottom-c:l.originalHeight,f=l.currentWidth,g=l.currentHeight;let m;{let t,e,i,n,r;{const t=this.video.videoWidth*(1-Je(this,Es,"f").autoZoomDetectionArea)/2,e=this.video.videoWidth*(1+Je(this,Es,"f").autoZoomDetectionArea)/2,i=e,n=t,s=this.video.videoHeight*(1-Je(this,Es,"f").autoZoomDetectionArea)/2,a=s,o=this.video.videoHeight*(1+Je(this,Es,"f").autoZoomDetectionArea)/2;r=[{x:t,y:s},{x:e,y:a},{x:i,y:o},{x:n,y:o}]}Fs._onLog&&(Fs._onLog("detectionArea:"),Fs._onLog(r));const s=[];{const t=(t,e)=>{const i=(t,e)=>{if(!t&&!e)throw new Error("Invalid arguments.");return function(t,e,i){let n=!1;const r=t.length;if(r<=2)return!1;for(let s=0;s0!=Xi(o.y-i)>0&&Xi(e-(i-a.y)*(a.x-o.x)/(a.y-o.y)-a.x)<0&&(n=!n)}return n}(e,t.x,t.y)},n=(t,e)=>!!(Zi([t[0],t[1]],[t[2],t[3]],[e[0].x,e[0].y],[e[1].x,e[1].y])||Zi([t[0],t[1]],[t[2],t[3]],[e[1].x,e[1].y],[e[2].x,e[2].y])||Zi([t[0],t[1]],[t[2],t[3]],[e[2].x,e[2].y],[e[3].x,e[3].y])||Zi([t[0],t[1]],[t[2],t[3]],[e[3].x,e[3].y],[e[0].x,e[0].y]));return!!(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))||!!(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))||!!(n([e[0].x,e[0].y,e[1].x,e[1].y],t)||n([e[1].x,e[1].y,e[2].x,e[2].y],t)||n([e[2].x,e[2].y,e[3].x,e[3].y],t)||n([e[3].x,e[3].y,e[0].x,e[0].y],t))};for(let e of a)if(e.unitType===Ot.IRUT_LOCALIZED_BARCODES)for(let i of e.localizedBarcodes){if(!i)continue;const e=i.location.points;e.forEach((t=>{Nn._transformCoordinates(t,h,c,d,u,f,g)})),t(r,e)&&s.push(i)}if(Fs._debug&&this.cameraView){const t=this.__layer||(this.__layer=this.cameraView._createDrawingLayer(99));t.clearDrawingItems();const e=this.__styleId2||(this.__styleId2=Dn.createDrawingStyle({strokeStyle:"red"}));for(let i of a)if(i.unitType===Ot.IRUT_LOCALIZED_BARCODES)for(let n of i.localizedBarcodes){if(!n)continue;const i=n.location.points,r=new Ri({points:i},e);t.addDrawingItems([r])}}}if(Fs._onLog&&(Fs._onLog("intersectedResults:"),Fs._onLog(s)),!s.length)return;let o;if(s.length){let t=s.filter((t=>t.possibleFormats==Ms.BF_QR_CODE||t.possibleFormats==Ms.BF_DATAMATRIX));if(t.length||(t=s.filter((t=>t.possibleFormats==Ms.BF_ONED)),t.length||(t=s)),t.length){const e=t=>{const e=t.location.points,i=(e[0].x+e[1].x+e[2].x+e[3].x)/4,n=(e[0].y+e[1].y+e[2].y+e[3].y)/4;return(i-f/2)*(i-f/2)+(n-g/2)*(n-g/2)};o=t[0];let i=e(o);if(1!=t.length)for(let n=1;n1.1*o.confidence||t[n].confidence>.9*o.confidence&&ri&&s>i&&a>i&&l>i&&m.result.moduleSize{})),Je(this,Es,"f").autoZoomInFrameArray.filter((t=>!0===t)).length>=Je(this,Es,"f").autoZoomInFrameLimit[1]){Je(this,Es,"f").autoZoomInFrameArray.length=0;const i=[(.5-n)/(.5-r),(.5-n)/(.5-s),(.5-n)/(.5-a),(.5-n)/(.5-l)].filter((t=>t>0)),o=Math.min(...i,Je(this,Es,"f").autoZoomInIdealModuleSize/m.result.moduleSize),h=this.getZoomSettings().factor;let c=Math.max(Math.pow(h*o,1/Je(this,Es,"f").autoZoomInMaxTimes),Je(this,Es,"f").autoZoomInMinStep);c=Math.min(c,o);let d=h*c;d=Math.max(Je(this,Es,"f").minValue,d),d=Math.min(Je(this,Es,"f").maxValue,d);try{await e({factor:d})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}else if(Je(this,Es,"f").autoZoomInFrameArray.length=0,Je(this,Es,"f").frameArrayInIdealZoom.push(!0),Je(this,Es,"f").frameArrayInIdealZoom.splice(0,Je(this,Es,"f").frameArrayInIdealZoom.length-Je(this,Es,"f").frameLimitInIdealZoom[0]),Je(this,Es,"f").frameArrayInIdealZoom.filter((t=>!0===t)).length>=Je(this,Es,"f").frameLimitInIdealZoom[1]&&(Je(this,Es,"f").frameArrayInIdealZoom.length=0,Je(this,Cs,"f").enhancedFocus)){const e=m.points;try{await o({mode:"manual",area:{centerPoint:{x:(e[0].x+e[2].x)/2+"px",y:(e[0].y+e[2].y)/2+"px"},width:e[2].x-e[0].x+"px",height:e[2].y-e[0].y+"px"}})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}if(!Je(this,Cs,"f").autoZoom&&Je(this,Cs,"f").enhancedFocus&&(Je(this,Es,"f").autoFocusFrameArray.push(!0),Je(this,Es,"f").autoFocusFrameArray.splice(0,Je(this,Es,"f").autoFocusFrameArray.length-Je(this,Es,"f").autoFocusFrameLimit[0]),Je(this,Es,"f").autoFocusFrameArray.filter((t=>!0===t)).length>=Je(this,Es,"f").autoFocusFrameLimit[1])){Je(this,Es,"f").autoFocusFrameArray.length=0;try{const t=m.points;await o({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(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}else{if(Je(this,Cs,"f").autoZoom){if(Je(this,Es,"f").autoZoomInFrameArray.push(!1),Je(this,Es,"f").autoZoomInFrameArray.splice(0,Je(this,Es,"f").autoZoomInFrameArray.length-Je(this,Es,"f").autoZoomInFrameLimit[0]),Je(this,Es,"f").autoZoomOutFrameCount++,Je(this,Es,"f").frameArrayInIdealZoom.push(!1),Je(this,Es,"f").frameArrayInIdealZoom.splice(0,Je(this,Es,"f").frameArrayInIdealZoom.length-Je(this,Es,"f").frameLimitInIdealZoom[0]),Je(this,Es,"f").autoZoomOutFrameCount>=Je(this,Es,"f").autoZoomOutFrameLimit){Je(this,Es,"f").autoZoomOutFrameCount=0;const i=this.getZoomSettings().factor;let n=i-Math.max((i-1)*Je(this,Es,"f").autoZoomOutStepRate,Je(this,Es,"f").autoZoomOutMinStep);n=Math.max(Je(this,Es,"f").minValue,n),n=Math.min(Je(this,Es,"f").maxValue,n);try{await e({factor:n})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}Je(this,Cs,"f").enhancedFocus&&o({mode:"continuous"}).catch((()=>{}))}!Je(this,Cs,"f").autoZoom&&Je(this,Cs,"f").enhancedFocus&&(Je(this,Es,"f").autoFocusFrameArray.length=0,o({mode:"continuous"}).catch((()=>{})))}}},Ke(this,Ss,new Rs(1e4))}setCameraView(t){if(!(t instanceof Nn))throw new TypeError("Invalid view.");if(t.disposed)throw new Error("The camera view has been disposed.");if(this.isOpen())throw new Error("It is not allowed to change camera view when the camera is open.");this.releaseCameraView(),t._singleFrameMode=this.singleFrameMode,t._onSingleFrameAcquired=this._onSingleFrameAcquired,this.videoSrc&&(this.cameraView._hideDefaultSelection=!0),Je(this,ls,"m",Ts).call(this)||this.cameraManager.setVideoEl(t.getVideoElement()),this.cameraView=t,this.addListenerToView()}getCameraView(){return this.cameraView}releaseCameraView(){this.cameraView&&(this.removeListenerFromView(),this.cameraView.disposed||(this.cameraView._singleFrameMode="disabled",this.cameraView._onSingleFrameAcquired=null,this.cameraView._hideDefaultSelection=!1),this.cameraManager.releaseVideoEl(),this.cameraView=null)}addListenerToView(){if(!this.cameraView)return;if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");const t=this.cameraView;Je(this,ls,"m",Ts).call(this)||this.videoSrc||(t._innerComponent&&(this.cameraManager.tapFocusEventBoundEl=t._innerComponent),t._selCam&&t._selCam.addEventListener("change",this._onCameraSelChange),t._selRsl&&t._selRsl.addEventListener("change",this._onResolutionSelChange)),t._btnClose&&t._btnClose.addEventListener("click",this._onCloseBtnClick)}removeListenerFromView(){if(!this.cameraView||this.cameraView.disposed)return;const t=this.cameraView;this.cameraManager.tapFocusEventBoundEl=null,t._selCam&&t._selCam.removeEventListener("change",this._onCameraSelChange),t._selRsl&&t._selRsl.removeEventListener("change",this._onResolutionSelChange),t._btnClose&&t._btnClose.removeEventListener("click",this._onCloseBtnClick)}getCameraState(){return Je(this,ls,"m",Ts).call(this)?Je(this,ds,"f"):new Map([["closed","closed"],["opening","opening"],["opened","open"]]).get(this.cameraManager.state)}isOpen(){return"open"===this.getCameraState()}getVideoEl(){return this.video}async open(){const t=this.cameraView;if(null==t?void 0:t.disposed)throw new Error("'cameraView' has been disposed.");t&&(t._singleFrameMode=this.singleFrameMode,Je(this,ls,"m",Ts).call(this)?t._clickIptSingleFrameMode():(this.cameraManager.setVideoEl(t.getVideoElement()),t._startLoading()));let e={width:0,height:0,deviceId:""};if(Je(this,ls,"m",Ts).call(this));else{try{await this.cameraManager.open()}catch(e){throw t&&t._stopLoading(),"NotFoundError"===e.name?new Error(`No camera devices were detected. Please ensure a camera is connected and recognized by your system. ${null==e?void 0:e.name}: ${null==e?void 0:e.message}`):"NotAllowedError"===e.name?new Error(`Camera access is blocked. Please check your browser settings or grant permission to use the camera. ${null==e?void 0:e.name}: ${null==e?void 0:e.message}`):e}let i,n=t.getUIElement();if(n=n.shadowRoot||n,i=n.querySelector(".dce-macro-use-mobile-native-like-ui")){let t=n.elTorchAuto=n.querySelector(".dce-mn-torch-auto"),e=n.elTorchOn=n.querySelector(".dce-mn-torch-on"),r=n.elTorchOff=n.querySelector(".dce-mn-torch-off");t&&(e.style.display=null==this.isTorchOn?"":"none"),e&&(e.style.display=1==this.isTorchOn?"":"none"),r&&(r.style.display=0==this.isTorchOn?"":"none");let s=n.elBeepOn=n.querySelector(".dce-mn-beep-on"),a=n.elBeepOff=n.querySelector(".dce-mn-beep-off");s&&(s.style.display=Ds.allowBeep?"":"none"),a&&(a.style.display=Ds.allowBeep?"none":"");let o=n.elVibrateOn=n.querySelector(".dce-mn-vibrate-on"),l=n.elVibrateOff=n.querySelector(".dce-mn-vibrate-off");o&&(o.style.display=Ds.allowVibrate?"":"none"),l&&(l.style.display=Ds.allowVibrate?"none":""),n.elResolutionBox=n.querySelector(".dce-mn-resolution-box");let h,c=n.elZoom=n.querySelector(".dce-mn-zoom");c&&(c.style.display="none",h=n.elZoomSpan=c.querySelector("span"));let d=n.elToast=n.querySelector(".dce-mn-toast"),u=n.elCameraClose=n.querySelector(".dce-mn-camera-close"),f=n.elTakePhoto=n.querySelector(".dce-mn-take-photo"),g=n.elCameraSwitch=n.querySelector(".dce-mn-camera-switch"),m=n.elCameraAndResolutionSettings=n.querySelector(".dce-mn-camera-and-resolution-settings");m&&(m.style.display="none");const p=n.dceMnFs={},_=()=>{this.turnOnTorch()};null==t||t.addEventListener("pointerdown",_);const v=()=>{this.turnOffTorch()};null==e||e.addEventListener("pointerdown",v);const y=()=>{this.turnAutoTorch()};null==r||r.addEventListener("pointerdown",y);const w=()=>{Ds.allowBeep=!Ds.allowBeep,s&&(s.style.display=Ds.allowBeep?"":"none"),a&&(a.style.display=Ds.allowBeep?"none":"")};for(let t of[a,s])null==t||t.addEventListener("pointerdown",w);const C=()=>{Ds.allowVibrate=!Ds.allowVibrate,o&&(o.style.display=Ds.allowVibrate?"":"none"),l&&(l.style.display=Ds.allowVibrate?"none":"")};for(let t of[l,o])null==t||t.addEventListener("pointerdown",C);const E=async t=>{let e,i=t.target;if(e=i.closest(".dce-mn-camera-option"))this.selectCamera(e.getAttribute("data-davice-id"));else if(e=i.closest(".dce-mn-resolution-option")){let t,i=parseInt(e.getAttribute("data-width")),n=parseInt(e.getAttribute("data-height")),r=await this.setResolution({width:i,height:n});{let e=Math.max(r.width,r.height),i=Math.min(r.width,r.height);t=i<=1080?i+"P":e<3e3?"2K":Math.round(e/1e3)+"K"}t!=e.textContent&&T(`Fallback to ${t}`)}else i.closest(".dce-mn-camera-and-resolution-settings")||(i.closest(".dce-mn-resolution-box")?m&&(m.style.display=m.style.display?"":"none"):m&&""===m.style.display&&(m.style.display="none"))};n.addEventListener("click",E);let S=null;p.funcInfoZoomChange=(t,e=3e3)=>{c&&h&&(h.textContent=t.toFixed(1),c.style.display="",null!=S&&(clearTimeout(S),S=null),S=setTimeout((()=>{c.style.display="none",S=null}),e))};let b=null,T=p.funcShowToast=(t,e=3e3)=>{d&&(d.textContent=t,d.style.display="",null!=b&&(clearTimeout(b),b=null),b=setTimeout((()=>{d.style.display="none",b=null}),e))};const I=()=>{this.close()};null==u||u.addEventListener("click",I);const x=()=>{};null==f||f.addEventListener("pointerdown",x);const O=()=>{var t,e;let i,n=this.getVideoSettings(),r=n.video.facingMode,s=null===(e=null===(t=this.cameraManager.getCamera())||void 0===t?void 0:t.label)||void 0===e?void 0:e.toLowerCase(),a=null==s?void 0:s.indexOf("front");-1===a&&(a=null==s?void 0:s.indexOf("前"));let o=null==s?void 0:s.indexOf("back");-1===o&&(o=null==s?void 0:s.indexOf("后")),"number"==typeof a&&-1!==a?i=!0:"number"==typeof o&&-1!==o&&(i=!1),void 0===i&&(i="user"===((null==r?void 0:r.ideal)||(null==r?void 0:r.exact)||r)),n.video.facingMode={ideal:i?"environment":"user"},delete n.video.deviceId,this.updateVideoSettings(n)};null==g||g.addEventListener("pointerdown",O);let A=-1/0,R=1;const D=t=>{let e=Date.now();e-A>1e3&&(R=this.getZoomSettings().factor),R-=t.deltaY/200,R>20&&(R=20),R<1&&(R=1),this.setZoom({factor:R}),A=e};i.addEventListener("wheel",D);const L=new Map;let M=!1;const F=async t=>{var e;for(t.touches.length>=2&&"touchmove"==t.type&&t.preventDefault();t.changedTouches.length>1&&2==t.touches.length;){let i=t.touches[0],n=t.touches[1],r=L.get(i.identifier),s=L.get(n.identifier);if(!r||!s)break;let a=Math.pow(Math.pow(r.x-s.x,2)+Math.pow(r.y-s.y,2),.5),o=Math.pow(Math.pow(i.clientX-n.clientX,2)+Math.pow(i.clientY-n.clientY,2),.5),l=Date.now();if(M||l-A<100)return;l-A>1e3&&(R=this.getZoomSettings().factor),R*=o/a,R>20&&(R=20),R<1&&(R=1);let h=!1;"safari"==(null===(e=null==Ze?void 0:Ze.browser)||void 0===e?void 0:e.toLocaleLowerCase())&&(o/a>1&&R<2?(R=2,h=!0):o/a<1&&R<2&&(R=1,h=!0)),M=!0,h&&T("zooming..."),await this.setZoom({factor:R}),h&&(d.textContent=""),M=!1,A=Date.now();break}L.clear();for(let e of t.touches)L.set(e.identifier,{x:e.clientX,y:e.clientY})};n.addEventListener("touchstart",F),n.addEventListener("touchmove",F),n.addEventListener("touchend",F),n.addEventListener("touchcancel",F),p.unbind=()=>{null==t||t.removeEventListener("pointerdown",_),null==e||e.removeEventListener("pointerdown",v),null==r||r.removeEventListener("pointerdown",y);for(let t of[a,s])null==t||t.removeEventListener("pointerdown",w);for(let t of[l,o])null==t||t.removeEventListener("pointerdown",C);n.removeEventListener("click",E),null==u||u.removeEventListener("click",I),null==f||f.removeEventListener("pointerdown",x),null==g||g.removeEventListener("pointerdown",O),i.removeEventListener("wheel",D),n.removeEventListener("touchstart",F),n.removeEventListener("touchmove",F),n.removeEventListener("touchend",F),n.removeEventListener("touchcancel",F),delete n.dceMnFs,i.style.display="none"},i.style.display="",t&&null==this.isTorchOn&&setTimeout((()=>{this.turnAutoTorch(1e3)}),0)}this.isTorchOn&&this.turnOnTorch().catch((()=>{}));const r=this.getResolution();e.width=r.width,e.height=r.height,e.deviceId=this.getSelectedCamera().deviceId}return Ke(this,ds,"open"),t&&(t._innerComponent.style.display="",Je(this,ls,"m",Ts).call(this)||(t._stopLoading(),t._renderCamerasInfo(this.getSelectedCamera(),this.cameraManager._arrCameras),t._renderResolutionInfo({width:e.width,height:e.height}),t.eventHandler.fire("content:updated",null,{async:!1}),t.eventHandler.fire("videoEl:resized",null,{async:!1}))),Je(this,us,"f").fire("opened",null,{target:this,async:!1}),e}close(){var t;const e=this.cameraView;if(null==e?void 0:e.disposed)throw new Error("'cameraView' has been disposed.");if(this.stopFetching(),this.clearBuffer(),Je(this,ls,"m",Ts).call(this));else{this.cameraManager.close();let i=e.getUIElement();i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")&&(null===(t=i.dceMnFs)||void 0===t||t.unbind())}Ke(this,ds,"closed"),Je(this,Ss,"f").stopCharging(),e&&(e._innerComponent.style.display="none",Je(this,ls,"m",Ts).call(this)&&e._innerComponent.removeElement("content"),e._stopLoading()),Je(this,us,"f").fire("closed",null,{target:this,async:!1})}pause(){if(Je(this,ls,"m",Ts).call(this))throw new Error("'pause()' is invalid in 'singleFrameMode'.");this.cameraManager.pause()}isPaused(){var t;return!Je(this,ls,"m",Ts).call(this)&&!0===(null===(t=this.video)||void 0===t?void 0:t.paused)}async resume(){if(Je(this,ls,"m",Ts).call(this))throw new Error("'resume()' is invalid in 'singleFrameMode'.");await this.cameraManager.resume()}async selectCamera(t){if(!t)throw new Error("Invalid value.");let e;e="string"==typeof t?t:t.deviceId,await this.cameraManager.setCamera(e),this.isTorchOn=!1;const i=this.getResolution(),n=this.cameraView;return n&&!n.disposed&&(n._stopLoading(),n._renderCamerasInfo(this.getSelectedCamera(),this.cameraManager._arrCameras),n._renderResolutionInfo({width:i.width,height:i.height})),{width:i.width,height:i.height,deviceId:this.getSelectedCamera().deviceId}}getSelectedCamera(){return this.cameraManager.getCamera()}async getAllCameras(){return this.cameraManager.getCameras()}async setResolution(t){await this.cameraManager.setResolution(t.width,t.height),this.isTorchOn&&this.turnOnTorch().catch((()=>{}));const e=this.getResolution(),i=this.cameraView;return i&&!i.disposed&&(i._stopLoading(),i._renderResolutionInfo({width:e.width,height:e.height})),{width:e.width,height:e.height,deviceId:this.getSelectedCamera().deviceId}}getResolution(){return this.cameraManager.getResolution()}getAvailableResolutions(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getResolutions()}_on(t,e){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(t.toLowerCase())?Je(this,us,"f").on(t,e):this.cameraManager.on(t,e)}_off(t,e){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(t.toLowerCase())?Je(this,us,"f").off(t,e):this.cameraManager.off(t,e)}on(t,e){const i=t.toLowerCase(),n=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(i);if(!n)throw new Error("Invalid event.");this._on(n,e)}off(t,e){const i=t.toLowerCase(),n=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(i);if(!n)throw new Error("Invalid event.");this._off(n,e)}getVideoSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getMediaStreamConstraints()}async updateVideoSettings(t){var e;await(null===(e=this.cameraManager)||void 0===e?void 0:e.setMediaStreamConstraints(t,!0))}getCapabilities(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getCameraCapabilities()}getCameraSettings(){return this.cameraManager.getCameraSettings()}async turnOnTorch(){var t,e;if(Je(this,ls,"m",Ts).call(this))throw new Error("'turnOnTorch()' is invalid in 'singleFrameMode'.");try{await(null===(t=this.cameraManager)||void 0===t?void 0:t.turnOnTorch())}catch(t){let i=this.cameraView.getUIElement();throw i=i.shadowRoot||i,null===(e=null==i?void 0:i.dceMnFs)||void 0===e||e.funcShowToast("Torch Not Supported"),t}this.isTorchOn=!0;let i=this.cameraView.getUIElement();i=i.shadowRoot||i,i.elTorchAuto&&(i.elTorchAuto.style.display="none"),i.elTorchOn&&(i.elTorchOn.style.display=""),i.elTorchOff&&(i.elTorchOff.style.display="none")}async turnOffTorch(){var t;if(Je(this,ls,"m",Ts).call(this))throw new Error("'turnOffTorch()' is invalid in 'singleFrameMode'.");await(null===(t=this.cameraManager)||void 0===t?void 0:t.turnOffTorch()),this.isTorchOn=!1;let e=this.cameraView.getUIElement();e=e.shadowRoot||e,e.elTorchAuto&&(e.elTorchAuto.style.display="none"),e.elTorchOn&&(e.elTorchOn.style.display="none"),e.elTorchOff&&(e.elTorchOff.style.display="")}async turnAutoTorch(t=250){if(null!=this._taskid4AutoTorch){if(!(t{var t,r,s;if(this.disposed||e||null!=this.isTorchOn||!this.isOpen())return clearInterval(this._taskid4AutoTorch),void(this._taskid4AutoTorch=null);if(this.isPaused())return;if(++n>10&&this._delay4AutoTorch<1e3)return clearInterval(this._taskid4AutoTorch),this._taskid4AutoTorch=null,void this.turnAutoTorch(1e3);let a;try{a=this.fetchImage()}catch(t){}if(!a||!a.width||!a.height)return;let l=0;if(o.IPF_GRAYSCALED===a.format){for(let t=0;t=this.maxDarkCount4AutoTroch){null===(t=Fs._onLog)||void 0===t||t.call(Fs,`darkCount ${i}`);try{await this.turnOnTorch(),this.isTorchOn=!0;let t=this.cameraView.getUIElement();t=t.shadowRoot||t,null===(r=null==t?void 0:t.dceMnFs)||void 0===r||r.funcShowToast("Torch Auto On")}catch(t){console.warn(t),e=!0;let i=this.cameraView.getUIElement();i=i.shadowRoot||i,null===(s=null==i?void 0:i.dceMnFs)||void 0===s||s.funcShowToast("Torch Not Supported")}}}else i=0};this._taskid4AutoTorch=setInterval(r,t),this.isTorchOn=void 0,r();let s=this.cameraView.getUIElement();s=s.shadowRoot||s,s.elTorchAuto&&(s.elTorchAuto.style.display=""),s.elTorchOn&&(s.elTorchOn.style.display="none"),s.elTorchOff&&(s.elTorchOff.style.display="none")}async setColorTemperature(t){if(Je(this,ls,"m",Ts).call(this))throw new Error("'setColorTemperature()' is invalid in 'singleFrameMode'.");await this.cameraManager.setColorTemperature(t,!0)}getColorTemperature(){return this.cameraManager.getColorTemperature()}async setExposureCompensation(t){var e;if(Je(this,ls,"m",Ts).call(this))throw new Error("'setExposureCompensation()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setExposureCompensation(t,!0))}getExposureCompensation(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getExposureCompensation()}async _setZoom(t){var e,i,n;if(Je(this,ls,"m",Ts).call(this))throw new Error("'setZoom()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setZoom(t));{let e=null===(i=this.cameraView)||void 0===i?void 0:i.getUIElement();e=(null==e?void 0:e.shadowRoot)||e,null===(n=null==e?void 0:e.dceMnFs)||void 0===n||n.funcInfoZoomChange(t.factor)}}async setZoom(t){await this._setZoom(t)}getZoomSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getZoom()}async resetZoom(){var t;if(Je(this,ls,"m",Ts).call(this))throw new Error("'resetZoom()' is invalid in 'singleFrameMode'.");await(null===(t=this.cameraManager)||void 0===t?void 0:t.resetZoom())}async setFrameRate(t){var e;if(Je(this,ls,"m",Ts).call(this))throw new Error("'setFrameRate()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setFrameRate(t,!0))}getFrameRate(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getFrameRate()}async setFocus(t){var e;if(Je(this,ls,"m",Ts).call(this))throw new Error("'setFocus()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setFocus(t,!0))}getFocusSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getFocus()}setAutoZoomRange(t){Je(this,Es,"f").minValue=t.min,Je(this,Es,"f").maxValue=t.max}getAutoZoomRange(){return{min:Je(this,Es,"f").minValue,max:Je(this,Es,"f").maxValue}}async enableEnhancedFeatures(t){var e,i;if(!(null===(i=null===(e=gt.license)||void 0===e?void 0:e.LicenseManager)||void 0===i?void 0:i.bPassValidation))throw new Error("License is not verified, or license is invalid.");if(0!==vt.bSupportDce4Module)throw new Error("Please set a license containing the DCE module.");t&li.EF_ENHANCED_FOCUS&&(Je(this,Cs,"f").enhancedFocus=!0),t&li.EF_AUTO_ZOOM&&(Je(this,Cs,"f").autoZoom=!0),t&li.EF_TAP_TO_FOCUS&&(Je(this,Cs,"f").tapToFocus=!0,this.cameraManager.enableTapToFocus())}disableEnhancedFeatures(t){t&li.EF_ENHANCED_FOCUS&&(Je(this,Cs,"f").enhancedFocus=!1,this.setFocus({mode:"continuous"}).catch((()=>{}))),t&li.EF_AUTO_ZOOM&&(Je(this,Cs,"f").autoZoom=!1,this.resetZoom().catch((()=>{}))),t&li.EF_TAP_TO_FOCUS&&(Je(this,Cs,"f").tapToFocus=!1,this.cameraManager.disableTapToFocus()),Je(this,ls,"m",xs).call(this)&&Je(this,ls,"m",Is).call(this)||Je(this,Ss,"f").stopCharging()}_setScanRegion(t){if(null!=t&&!E(t)&&!O(t))throw TypeError("Invalid 'region'.");Ke(this,_s,t?JSON.parse(JSON.stringify(t)):null),this.cameraView&&!this.cameraView.disposed&&this.cameraView.setScanRegion(t)}setScanRegion(t){this._setScanRegion(t),this.cameraView&&!this.cameraView.disposed&&(null===t?this.cameraView.setScanRegionMaskVisible(!1):this.cameraView.setScanRegionMaskVisible(!0))}getScanRegion(){return JSON.parse(JSON.stringify(Je(this,_s,"f")))}setErrorListener(t){if(!t)throw new TypeError("Invalid 'listener'");Ke(this,ps,t)}hasNextImageToFetch(){return!("open"!==this.getCameraState()||!this.cameraManager.isVideoLoaded()||Je(this,ls,"m",Ts).call(this))}startFetching(){if(Je(this,ls,"m",Ts).call(this))throw Error("'startFetching()' is unavailable in 'singleFrameMode'.");Je(this,ys,"f")||(Ke(this,ys,!0),Je(this,ls,"m",Os).call(this))}stopFetching(){Je(this,ys,"f")&&(Fs._onLog&&Fs._onLog("DCE: stop fetching loop: "+Date.now()),Je(this,ws,"f")&&clearTimeout(Je(this,ws,"f")),Ke(this,ys,!1))}fetchImage(){if(Je(this,ls,"m",Ts).call(this))throw new Error("'fetchImage()' is unavailable in 'singleFrameMode'.");if(!this.video)throw new Error("The video element does not exist.");if(4!==this.video.readyState)throw new Error("The video is not loaded.");const t=this.getResolution();if(!(null==t?void 0:t.width)||!(null==t?void 0:t.height))throw new Error("The video is not loaded.");let e;if(e=Gi.convert(Je(this,_s,"f"),t.width,t.height),e||(e={x:0,y:0,width:t.width,height:t.height}),e.x>t.width||e.y>t.height)throw new Error("Invalid scan region.");e.x+e.width>t.width&&(e.width=t.width-e.x),e.y+e.height>t.height&&(e.height=t.height-e.y);const i={sx:e.x,sy:e.y,sWidth:e.width,sHeight:e.height,dWidth:e.width,dHeight:e.height},n=Math.max(i.dWidth,i.dHeight);if(this.canvasSizeLimit&&n>this.canvasSizeLimit){const t=this.canvasSizeLimit/n;i.dWidth>i.dHeight?(i.dWidth=this.canvasSizeLimit,i.dHeight=Math.round(i.dHeight*t)):(i.dWidth=Math.round(i.dWidth*t),i.dHeight=this.canvasSizeLimit)}const r=this.cameraManager.getFrameData({position:i,pixelFormat:this.getPixelFormat()===o.IPF_GRAYSCALED?qn.GREY:qn.RGBA});if(!r)return null;let s;s=r.pixelFormat===qn.GREY?r.width:4*r.width;let a=!0;return 0===i.sx&&0===i.sy&&i.sWidth===t.width&&i.sHeight===t.height&&(a=!1),{bytes:r.data,width:r.width,height:r.height,stride:s,format:Ls.get(r.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:bt.ITT_VIDEO_FRAME,isCropped:a,cropRegion:{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height,isMeasuredInPercentage:!1},originalWidth:t.width,originalHeight:t.height,currentWidth:r.width,currentHeight:r.height,timeSpent:r.timeSpent,timeStamp:r.timeStamp},toCanvas:Je(this,ms,"f"),isDCEFrame:!0}}setImageFetchInterval(t){this.fetchInterval=t,Je(this,ys,"f")&&(Je(this,ws,"f")&&clearTimeout(Je(this,ws,"f")),Ke(this,ws,setTimeout((()=>{this.disposed||Je(this,ls,"m",Os).call(this)}),t)))}getImageFetchInterval(){return this.fetchInterval}setPixelFormat(t){Ke(this,vs,t)}getPixelFormat(){return Je(this,vs,"f")}takePhoto(t){if(!this.isOpen())throw new Error("Not open.");if(Je(this,ls,"m",Ts).call(this))throw new Error("'takePhoto()' is unavailable in 'singleFrameMode'.");const e=document.createElement("input");e.setAttribute("type","file"),e.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp"),e.setAttribute("capture",""),e.style.position="absolute",e.style.top="-9999px",e.style.backgroundColor="transparent",e.style.color="transparent",e.addEventListener("click",(()=>{const t=this.isOpen();this.close(),window.addEventListener("focus",(()=>{t&&this.open(),e.remove()}),{once:!0})})),e.addEventListener("change",(async()=>{const i=e.files[0],n=await(async t=>{let e=null,i=null;if("undefined"!=typeof createImageBitmap)try{if(e=await createImageBitmap(t),e)return e}catch(t){}var n;return e||(i=await(n=t,new Promise(((t,e)=>{let i=URL.createObjectURL(n),r=new Image;r.src=i,r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=t=>{e(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}})))),i})(i),r=n instanceof HTMLImageElement?n.naturalWidth:n.width,s=n instanceof HTMLImageElement?n.naturalHeight:n.height;let a=Gi.convert(Je(this,_s,"f"),r,s);a||(a={x:0,y:0,width:r,height:s});const o=Je(this,gs,"f").call(this,n,r,s,a);t&&t(o)})),document.body.appendChild(e),e.click()}convertToPageCoordinates(t){const e=Je(this,ls,"m",As).call(this,t);return{x:e.pageX,y:e.pageY}}convertToClientCoordinates(t){const e=Je(this,ls,"m",As).call(this,t);return{x:e.clientX,y:e.clientY}}convertToScanRegionCoordinates(t){if(!Je(this,_s,"f"))return JSON.parse(JSON.stringify(t));let e,i,n=Je(this,_s,"f").left||Je(this,_s,"f").x||0,r=Je(this,_s,"f").top||Je(this,_s,"f").y||0;if(!Je(this,_s,"f").isMeasuredInPercentage)return{x:t.x-n,y:t.y-r};if(!this.cameraView)throw new Error("Camera view is not set.");if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");if(!this.isOpen())throw new Error("Not open.");if(!Je(this,ls,"m",Ts).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(Je(this,ls,"m",Ts).call(this)&&!this.cameraView._cvsSingleFrameMode)throw new Error("No image is selected.");if(Je(this,ls,"m",Ts).call(this)){const t=this.cameraView._innerComponent.getElement("content");e=t.width,i=t.height}else{const t=this.getVideoEl();e=t.videoWidth,i=t.videoHeight}return{x:t.x-Math.round(n*e/100),y:t.y-Math.round(r*i/100)}}dispose(){this.close(),this.cameraManager.dispose(),this.releaseCameraView(),Ke(this,bs,!0)}}var Ps,ks,Ns,Bs,js,Vs,Us,Gs;hs=Fs,ds=new WeakMap,us=new WeakMap,fs=new WeakMap,gs=new WeakMap,ms=new WeakMap,ps=new WeakMap,_s=new WeakMap,vs=new WeakMap,ys=new WeakMap,ws=new WeakMap,Cs=new WeakMap,Es=new WeakMap,Ss=new WeakMap,bs=new WeakMap,ls=new WeakSet,Ts=function(){return"disabled"!==this.singleFrameMode},Is=function(){return!this.videoSrc&&"opened"===this.cameraManager.state},xs=function(){for(let t in Je(this,Cs,"f"))if(1==Je(this,Cs,"f")[t])return!0;return!1},Os=function t(){if(this.disposed)return;if("open"!==this.getCameraState()||!Je(this,ys,"f"))return Je(this,ws,"f")&&clearTimeout(Je(this,ws,"f")),void Ke(this,ws,setTimeout((()=>{this.disposed||Je(this,ls,"m",t).call(this)}),this.fetchInterval));const e=()=>{var t;let e;Fs._onLog&&Fs._onLog("DCE: start fetching a frame into buffer: "+Date.now());try{e=this.fetchImage()}catch(e){const i=e.message||e;if("The video is not loaded."===i)return;if(null===(t=Je(this,ps,"f"))||void 0===t?void 0:t.onErrorReceived)return void setTimeout((()=>{var t;null===(t=Je(this,ps,"f"))||void 0===t||t.onErrorReceived(Ct.EC_IMAGE_READ_FAILED,i)}),0);console.warn(e)}e?(this.addImageToBuffer(e),Fs._onLog&&Fs._onLog("DCE: finish fetching a frame into buffer: "+Date.now()),Je(this,us,"f").fire("frameAddedToBuffer",null,{async:!1})):Fs._onLog&&Fs._onLog("DCE: get a invalid frame, abandon it: "+Date.now())};if(this.getImageCount()>=this.getMaxImageCount())switch(this.getBufferOverflowProtectionMode()){case s.BOPM_BLOCK:break;case s.BOPM_UPDATE:e()}else e();Je(this,ws,"f")&&clearTimeout(Je(this,ws,"f")),Ke(this,ws,setTimeout((()=>{this.disposed||Je(this,ls,"m",t).call(this)}),this.fetchInterval))},As=function(t){if(!this.cameraView)throw new Error("Camera view is not set.");if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");if(!this.isOpen())throw new Error("Not open.");if(!Je(this,ls,"m",Ts).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(Je(this,ls,"m",Ts).call(this)&&!this.cameraView._cvsSingleFrameMode)throw new Error("No image is selected.");const e=this.cameraView._innerComponent.getBoundingClientRect(),i=e.left,n=e.top,r=i+window.scrollX,s=n+window.scrollY,{width:a,height:o}=this.cameraView._innerComponent.getBoundingClientRect();if(a<=0||o<=0)throw new Error("Unable to get content dimensions. Camera view may not be rendered on the page.");let l,h,c;if(Je(this,ls,"m",Ts).call(this)){const t=this.cameraView._innerComponent.getElement("content");l=t.width,h=t.height,c="contain"}else{const t=this.getVideoEl();l=t.videoWidth,h=t.videoHeight,c=this.cameraView.getVideoFit()}const d=a/o,u=l/h;let f,g,m,p,_=1;if("contain"===c)d{var e;if(!this.isUseMagnifier)return;if(Je(this,Bs,"f")||Ke(this,Bs,new Ws),!Je(this,Bs,"f").magnifierCanvas)return;document.body.contains(Je(this,Bs,"f").magnifierCanvas)||(Je(this,Bs,"f").magnifierCanvas.style.position="fixed",Je(this,Bs,"f").magnifierCanvas.style.boxSizing="content-box",Je(this,Bs,"f").magnifierCanvas.style.border="2px solid #FFFFFF",document.body.append(Je(this,Bs,"f").magnifierCanvas));const i=this._innerComponent.getElement("content");if(!i)return;if(t.pointer.x<0||t.pointer.x>i.width||t.pointer.y<0||t.pointer.y>i.height)return void Je(this,Vs,"f").call(this);const n=null===(e=this._drawingLayerManager._getFabricCanvas())||void 0===e?void 0:e.lowerCanvasEl;if(!n)return;const r=Math.max(i.clientWidth/5/1.5,i.clientHeight/4/1.5),s=1.5*r,a=[{image:i,width:i.width,height:i.height},{image:n,width:n.width,height:n.height}];Je(this,Bs,"f").update(s,t.pointer,r,a);{let e=0,i=0;t.e instanceof MouseEvent?(e=t.e.clientX,i=t.e.clientY):t.e instanceof TouchEvent&&t.e.changedTouches.length&&(e=t.e.changedTouches[0].clientX,i=t.e.changedTouches[0].clientY),e<1.5*s&&i<1.5*s?(Je(this,Bs,"f").magnifierCanvas.style.left="auto",Je(this,Bs,"f").magnifierCanvas.style.top="0",Je(this,Bs,"f").magnifierCanvas.style.right="0"):(Je(this,Bs,"f").magnifierCanvas.style.left="0",Je(this,Bs,"f").magnifierCanvas.style.top="0",Je(this,Bs,"f").magnifierCanvas.style.right="auto")}Je(this,Bs,"f").show()})),Vs.set(this,(()=>{Je(this,Bs,"f")&&Je(this,Bs,"f").hide()})),Us.set(this,!1)}_setUIElement(t){this.UIElement=t,this._unbindUI(),this._bindUI()}async setUIElement(t){let e;if("string"==typeof t){let i=await qi(t);e=document.createElement("div"),Object.assign(e.style,{width:"100%",height:"100%"}),e.attachShadow({mode:"open"}).appendChild(i)}else e=t;this._setUIElement(e)}getUIElement(){return this.UIElement}_bindUI(){if(!this.UIElement)throw new Error("Need to set 'UIElement'.");if(this._innerComponent)return;const t=this.UIElement;let e=t.classList.contains(this.containerClassName)?t:t.querySelector(`.${this.containerClassName}`);e||(e=document.createElement("div"),e.style.width="100%",e.style.height="100%",e.className=this.containerClassName,t.append(e)),this._innerComponent=document.createElement("dce-component"),e.appendChild(this._innerComponent)}_unbindUI(){var t,e,i;null===(t=this._drawingLayerManager)||void 0===t||t.clearDrawingLayers(),null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null,null===(i=this._innerComponent)||void 0===i||i.remove(),this._innerComponent=null}setImage(t,e,i){if(!this._innerComponent)throw new Error("Need to set 'UIElement'.");let n=this._innerComponent.getElement("content");n||(n=document.createElement("canvas"),n.style.objectFit="contain",this._innerComponent.setElement("content",n)),n.width===e&&n.height===i||(n.width=e,n.height=i);const r=n.getContext("2d");r.clearRect(0,0,n.width,n.height),t instanceof Uint8Array||t instanceof Uint8ClampedArray?(t instanceof Uint8Array&&(t=new Uint8ClampedArray(t.buffer)),r.putImageData(new ImageData(t,e,i),0,0)):(t instanceof HTMLCanvasElement||t instanceof HTMLImageElement)&&r.drawImage(t,0,0)}getImage(){return this._innerComponent.getElement("content")}clearImage(){if(!this._innerComponent)return;let t=this._innerComponent.getElement("content");t&&t.getContext("2d").clearRect(0,0,t.width,t.height)}removeImage(){this._innerComponent&&this._innerComponent.removeElement("content")}setOriginalImage(t){if(C(t)){Ke(this,Ns,t);const{width:e,height:i,bytes:n,format:r}=Object.assign({},t);let s;if(r===o.IPF_GRAYSCALED){s=new Uint8ClampedArray(e*i*4);for(let t=0;t{if(!Hs){if(!zs&&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"./"}})(),Zs=t=>{if(null==t&&(t="./"),zs||Hs);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};vt.engineResourcePaths.dlr={version:"3.4.32",path:Xs,isInternal:!0},null==vt.engineResourcePaths.dlrData&&(vt.engineResourcePaths.dlrData={version:"1.0.11",path:Zs(Xs+"../../dynamsoft-label-recognizer-data@1.0.11/dist/"),isInternal:!0}),mt.dlr={js:!0,wasm:!0,deps:["license","dip","dnn"]},mt.dnn={wasm:!0,deps:["dip"]};const qs="1.4.21";"string"!=typeof vt.engineResourcePaths.std&&D(vt.engineResourcePaths.std.version,qs)<0&&(vt.engineResourcePaths.std={version:qs,path:Zs(Xs+`../../dynamsoft-capture-vision-std@${qs}/dist/`),isInternal:!0});const Js="2.4.31";(!vt.engineResourcePaths.dip||"string"!=typeof vt.engineResourcePaths.dip&&D(vt.engineResourcePaths.dip.version,Js)<0)&&(vt.engineResourcePaths.dip={version:Js,path:Zs(Xs+`../../dynamsoft-image-processing@${Js}/dist/`),isInternal:!0});const Ks="1.0.20";(!vt.engineResourcePaths.dnn||"string"!=typeof vt.engineResourcePaths.dnn&&D(vt.engineResourcePaths.dnn.version,Ks)<0)&&(vt.engineResourcePaths.dnn={version:Ks,path:Zs(Xs+`../../dynamsoft-capture-vision-dnn@${Ks}/dist/`),isInternal:!0});let $s=!1,Qs=class{static getVersion(){const t=ft.dlr&&ft.dlr.wasm;return`3.4.32(Worker: ${ft.dlr&&ft.dlr.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadRecognitionData(t,e){return await _t("dlr"),await new Promise(((i,n)=>{let r=ot();lt[r]=async t=>{if(t.success){const e=t.result;if(0!==e.errorCode){let t=new Error(e.errorString);return t.errorCode=e.errorCode,n(t)}return e.isModel||($s=!0),i(e)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},e&&!e.endsWith("/")&&(e+="/");const s=L(vt.engineResourcePaths);e||"ConfusableChars"!==t||(e=s.dlr),st.postMessage({type:"dlr_loadData",id:r,body:{dataName:t,dataPath:e||s.dlrData}})}))}};gt.dlr={loadRecognitionData:Qs.loadRecognitionData,get bLoadConfusableCharsData(){return $s}};const ta={filterVINResult:function(t){let e="";if(18===t.characterResults.length){let e=t.characterResults[9].location.points[0].x-t.characterResults[8].location.points[1].x;e<2&&(e=2);let i=t.characterResults[1].location.points[0].x-t.characterResults[0].location.points[1].x,n=t.characterResults[17].location.points[0].x-t.characterResults[16].location.points[1].x,r=2===e?3:e;i-e>=r&&n-e=r&&i-et.characterResults[17].characterHConfidence?t.characterResults.pop():t.characterResults.shift()}else if(19===t.characterResults.length){let e=t.characterResults[10].location.points[0].x-t.characterResults[9].location.points[1].x;e<2&&(e=2);let i,n,r,s=t.characterResults[1].location.points[0].x-t.characterResults[0].location.points[1].x,a=t.characterResults[18].location.points[0].x-t.characterResults[17].location.points[1].x,o=t.characterResults[2].location.points[0].x-t.characterResults[1].location.points[1].x,l=t.characterResults[17].location.points[0].x-t.characterResults[16].location.points[1].x,h=2===e?3:e;if("1"===t.characterResults[1].characterH||"1"===t.characterResults[2].characterH||"1"===t.characterResults[16].characterH||"1"===t.characterResults[17].characterH){for(let e=9;e=(i||h)&&l-e<(n||h))t.characterResults.splice(0,2);else if(l-e>=(n||h)&&o-e<(i||h))t.characterResults.splice(17,2);else if(s>e&&a>e)t.characterResults.pop(),t.characterResults.shift();else{let e=t.characterResults[0].characterHConfidence+t.characterResults[1].characterHConfidence,i=t.characterResults[17].characterHConfidence+t.characterResults[18].characterHConfidence,n=t.characterResults[0].characterHConfidence+t.characterResults[18].characterHConfidence,r=Math.min(e,i,n);r===e?t.characterResults.splice(0,2):r===i?t.characterResults.splice(17,2):r===n&&(t.characterResults.pop(),t.characterResults.shift())}}for(let i of t.characterResults)e+=i.characterH;return e},checkValidVIN:function(t){return!(!t||17!=t.length)&&(t=>{const e=new Map([["A",1],["B",2],["C",3],["D",4],["E",5],["F",6],["G",7],["H",8],["J",1],["K",2],["L",3],["M",4],["N",5],["P",7],["R",9],["S",2],["T",3],["U",4],["V",5],["W",6],["X",7],["Y",8],["Z",9],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9]]),i=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2];let n=0;for(let r=0;r{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10},i=t.slice(0,10)+t.slice(13,20)+t.slice(21,43),n=e(t,0,8).toString(),r=e(t,13,18).toString(),s=e(t,21,26).toString(),a=e(t,28,41).toString(),o=e(i,0,i.length).toString();return n===t[9]&&r===t[19]&&s===t[27]&&a===t[42]&&o===t[43]},checkValidMRV:function(t){if(!t||44!=t.length&&36!=t.length)return!1;const e=(t,e,i)=>{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10},i=e(t,0,8).toString(),n=e(t,13,18).toString(),r=e(t,21,26).toString();return i===t[9]&&n===t[19]&&r===t[27]},checkValidIDCard:function(t,e){if(!t||30!=t.length&&36!=t.length)return!1;const i=(t,e,i)=>{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10};if(30===t.length){if(e&&t===e)return i(t,5,13).toString()===t[14];if(e&&t!==e){const n=`${e.substring(5,30)}${t.substring(0,7)}${t.substring(8,15)}${t.substring(18,29)}`;return i(n,0,n.length-1).toString()===t[29]}}else if(36===t.length){const e=i(t,0,8).toString(),n=i(t,13,18).toString(),r=i(t,21,26).toString(),s=`${t.substring(0,10)}${t.substring(13,20)}${t.substring(21,28)}`,a=i(s,0,s.length-1).toString();return e===t[9]&&n===t[19]&&r===t[27]&&a===t[35]}}};var ea,ia,na;function ra(t){delete t.moduleId;const e=JSON.parse(t.jsonString).ResultInfo,i=t.fullCodeString;t.getFieldValue=t=>"fullcodestring"===t.toLowerCase()?i:sa(e,t,"map"),t.getFieldRawValue=t=>sa(e,t,"raw"),t.getFieldMappingStatus=t=>aa(e,t),t.getFieldValidationStatus=t=>oa(e,t),delete t.fullCodeString}function sa(t,e,i){for(let n of t){if(n.FieldName===e)return"raw"===i&&n.RawValue?n.RawValue:n.Value;if(n.ChildFields&&n.ChildFields.length>0){let t;for(let r of n.ChildFields)t=sa(r,e,i);if(void 0!==t)return t}}}function aa(t,e){for(let i of t){if(i.FieldName===e)return i.MappingStatus?Number(ia[i.MappingStatus]):ia.MS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=aa(n,e);if(void 0!==t)return t}}}function oa(t,e){for(let i of t){if(i.FieldName===e&&i.ValidationStatus)return i.ValidationStatus?Number(na[i.ValidationStatus]):na.VS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=oa(n,e);if(void 0!==t)return t}}}function la(t){if(t.disposed)throw new Error('"CodeParser" instance has been disposed')}!function(t){t[t.RTLS_LOCALIZED=0]="RTLS_LOCALIZED",t[t.RTLS_RECOGNITION_FAILED=1]="RTLS_RECOGNITION_FAILED",t[t.RTLS_RECOGNITION_SUCCEEDED=2]="RTLS_RECOGNITION_SUCCEEDED"}(ea||(ea={})),lt[-1]=async t=>{Qs.onDataLoadProgressChanged&&Qs.onDataLoadProgressChanged(t.resourcesPath,t.tag,{loaded:t.loaded,total:t.total})},function(t){t[t.MS_NONE=0]="MS_NONE",t[t.MS_SUCCEEDED=1]="MS_SUCCEEDED",t[t.MS_FAILED=2]="MS_FAILED"}(ia||(ia={})),function(t){t[t.VS_NONE=0]="VS_NONE",t[t.VS_SUCCEEDED=1]="VS_SUCCEEDED",t[t.VS_FAILED=2]="VS_FAILED"}(na||(na={}));const ha=t=>t&&"object"==typeof t&&"function"==typeof t.then,ca=(async()=>{})().constructor;let da=class extends ca{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,ha(t)?e=t:"function"==typeof t&&(e=new ca(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&&(ha(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}},ua=class t{constructor(){this._instanceID=void 0,this.bDestroyed=!1}static async createInstance(){if(!gt.license)throw Error("Module `license` is not existed.");await gt.license.dynamsoft(),await _t("dcp");const e=new t,i=new da;let n=ot();return lt[n]=async t=>{if(t.success)e._instanceID=t.instanceID,i.resolve(e);else{const e=Error(t.message);t.stack&&(e.stack=t.stack),i.reject(e)}},st.postMessage({type:"dcp_createInstance",id:n}),i}async dispose(){la(this);let t=ot();this.bDestroyed=!0,lt[t]=t=>{if(!t.success){let e=new Error(t.message);throw e.stack=t.stack+"\n"+e.stack,e}},st.postMessage({type:"dcp_dispose",id:t,instanceID:this._instanceID})}get disposed(){return this.bDestroyed}async initSettings(t){return la(this),t&&["string","object"].includes(typeof t)?("string"==typeof t?t.trimStart().startsWith("{")||(t=await A(t,"text")):"object"==typeof t&&(t=JSON.stringify(t)),await new Promise(((e,i)=>{let n=ot();lt[n]=async t=>{if(t.success){const n=JSON.parse(t.response);if(0!==n.errorCode){let t=new Error(n.errorString?n.errorString:"Init Settings Failed.");return t.errorCode=n.errorCode,i(t)}return e(n)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},st.postMessage({type:"dcp_initSettings",id:n,instanceID:this._instanceID,body:{settings:t}})}))):console.error("Invalid settings.")}async resetSettings(){return la(this),await new Promise(((t,e)=>{let i=ot();lt[i]=async i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},st.postMessage({type:"dcp_resetSettings",id:i,instanceID:this._instanceID})}))}async parse(t,e=""){if(la(this),!t||!(t instanceof Array||t instanceof Uint8Array||"string"==typeof t))throw new Error("`parse` must pass in an Array or Uint8Array or string");return await new Promise(((i,n)=>{let r=ot();t instanceof Array&&(t=Uint8Array.from(t)),"string"==typeof t&&(t=Uint8Array.from(function(t){let e=[];for(let i=0;i{if(t.success){let e=JSON.parse(t.parseResponse);return e.errorCode?n(new Error(e.errorString)):(ra(e),i(e))}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},st.postMessage({type:"dcp_parse",id:r,instanceID:this._instanceID,body:{source:t,taskSettingName:e}})}))}};const fa="undefined"==typeof self,ga="function"==typeof importScripts,ma=(()=>{if(!ga){if(!fa&&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"./"}})();vt.engineResourcePaths.dcp={version:"2.4.32",path:ma,isInternal:!0},mt.dcp={js:!0,wasm:!0,deps:["license"]},gt.dcp={handleParsedResultItem:ra};const pa="1.4.21";"string"!=typeof vt.engineResourcePaths.std&&D(vt.engineResourcePaths.std.version,pa)<0&&(vt.engineResourcePaths.std={version:pa,path:(t=>{if(null==t&&(t="./"),fa||ga);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(ma+`../../dynamsoft-capture-vision-std@${pa}/dist/`),isInternal:!0});let _a=class{static getVersion(){const t=ft.dcp&&ft.dcp.wasm;return`2.4.32(Worker: ${ft.dcp&&ft.dcp.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadSpec(t,e){return await _t("dcp"),await new Promise(((i,n)=>{let r=ot();lt[r]=async t=>{if(t.success)return i();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},e&&!e.endsWith("/")&&(e+="/");const s=t instanceof Array?t:[t],a=L(vt.engineResourcePaths);st.postMessage({type:"dcp_appendResourceBuffer",id:r,body:{specificationPath:e||a.dcp+"specification/",specificationNames:s}})}))}};const va=async t=>{let e;await new Promise(((i,n)=>{e=new Image,e.onload=()=>i(e),e.onerror=n,e.src=URL.createObjectURL(t)}));const i=document.createElement("canvas"),n=i.getContext("2d");return i.width=e.width,i.height=e.height,n.drawImage(e,0,0),{bytes:Uint8Array.from(n.getImageData(0,0,i.width,i.height).data),width:i.width,height:i.height,stride:4*i.width,format:10}};class ya{async saveToFile(t,e,i){if(!t||!e)return null;if("string"!=typeof e)throw new TypeError("FileName must be of type string.");const n=N(t);return M(n,e,i)}async drawOnImage(t,e,i,n=4294901760,r=1,s){let a;if(t instanceof Blob)a=await va(t);else if("string"==typeof t){let e=await A(t,"blob");a=await va(e)}return await new Promise(((t,o)=>{let l=ot();lt[l]=async e=>{if(e.success)return s&&this.saveToFile(e.image,"test.png",s),t(e.image);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},st.postMessage({type:"utility_drawOnImage",id:l,body:{dsImage:a,drawingItem:e instanceof Array?e:[e],color:n,thickness:r,type:i}})}))}}const wa="undefined"==typeof self,Ca="function"==typeof importScripts,Ea=(()=>{if(!Ca){if(!wa&&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"./"}})(),Sa=t=>{if(null==t&&(t="./"),wa||Ca);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};vt.engineResourcePaths.utility={version:"1.4.32",path:Ea,isInternal:!0},mt.utility={js:!0,wasm:!0};const ba="1.4.21";"string"!=typeof vt.engineResourcePaths.std&&D(vt.engineResourcePaths.std.version,ba)<0&&(vt.engineResourcePaths.std={version:ba,path:Sa(Ea+`../../dynamsoft-capture-vision-std@${ba}/dist/`),isInternal:!0});const Ta="2.4.31";(!vt.engineResourcePaths.dip||"string"!=typeof vt.engineResourcePaths.dip&&D(vt.engineResourcePaths.dip.version,Ta)<0)&&(vt.engineResourcePaths.dip={version:Ta,path:Sa(Ea+`../../dynamsoft-image-processing@${Ta}/dist/`),isInternal:!0});class Ia{static getVersion(){return`1.4.32(Worker: ${ft.utility&&ft.utility.worker||"Not Loaded"}, Wasm: ${ft.utility&&ft.utility.wasm||"Not Loaded"})`}}function xa(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)}var Oa,Aa,Ra,Da,La;function Ma(t,e){let i=!0;for(let a=0;a1)return Math.sqrt((l-a)**2+(h-o)**2);{const t=r+d*(a-r),e=s+d*(o-s);return Math.sqrt((l-t)**2+(h-e)**2)}}function ka(t){const e=[];for(let i=0;i=0&&l<=1&&h>=0&&h<=1?{x:t.x+h*r,y:t.y+h*s}:null}function ja(t){let e=0;for(let i=0;i0}function Ua(t,e){for(let i=0;i<4;i++)if(!Va(t.points[i],t.points[(i+1)%4],e))return!1;return!0}"function"==typeof SuppressedError&&SuppressedError;function Ga(t,e,i,n){const r=t.points,s=e.points;let a=8*i;a=Math.max(a,5);const o=ka(r)[3],l=ka(r)[1],h=ka(s)[3],c=ka(s)[1];let d,u=0;if(d=Math.max(Math.abs(Pa(o,e.points[0])),Math.abs(Pa(o,e.points[3]))),d>u&&(u=d),d=Math.max(Math.abs(Pa(l,e.points[1])),Math.abs(Pa(l,e.points[2]))),d>u&&(u=d),d=Math.max(Math.abs(Pa(h,t.points[0])),Math.abs(Pa(h,t.points[3]))),d>u&&(u=d),d=Math.max(Math.abs(Pa(c,t.points[1])),Math.abs(Pa(c,t.points[2]))),d>u&&(u=d),u>a)return!1;const f=Na(ka(r)[0]),g=Na(ka(r)[2]),m=Na(ka(s)[0]),p=Na(ka(s)[2]),_=Fa(f,p),v=Fa(m,g),y=_>v,w=Math.min(_,v),C=Fa(f,g),E=Fa(m,p);let S=12*i;return S=Math.max(S,5),S=Math.min(S,C),S=Math.min(S,E),!!(w{e.x+=t,e.y+=i})),e.x/=t.length,e.y/=t.length,e}isProbablySameLocationWithOffset(t,e){const i=this.item.location,n=t.location;if(i.area<=0)return!1;if(Math.abs(i.area-n.area)>.4*i.area)return!1;let r=new Array(4).fill(0),s=new Array(4).fill(0),a=0,o=0;for(let t=0;t<4;++t)r[t]=Math.round(100*(n.points[t].x-i.points[t].x))/100,a+=r[t],s[t]=Math.round(100*(n.points[t].y-i.points[t].y))/100,o+=s[t];a/=4,o/=4;for(let t=0;t<4;++t){if(Math.abs(r[t]-a)>this.strictLimit||Math.abs(a)>.8)return!1;if(Math.abs(s[t]-o)>this.strictLimit||Math.abs(o)>.8)return!1}return e.x=a,e.y=o,!0}isLocationOverlap(t,e){if(this.locationArea>e){for(let e=0;e<4;e++)if(Ua(this.location,t.points[e]))return!0;const e=this.getCenterPoint(t.points);if(Ua(this.location,e))return!0}else{for(let e=0;e<4;e++)if(Ua(t,this.location.points[e]))return!0;if(Ua(t,this.getCenterPoint(this.location.points)))return!0}return!1}isMatchedLocationWithOffset(t,e={x:0,y:0}){if(this.isOneD){const i=Object.assign({},t.location);for(let t=0;t<4;t++)i.points[t].x-=e.x,i.points[t].y-=e.y;if(!this.isLocationOverlap(i,t.locationArea))return!1;const n=[this.location.points[0],this.location.points[3]],r=[this.location.points[1],this.location.points[2]];for(let t=0;t<4;t++){const e=i.points[t],s=0===t||3===t?n:r;if(Math.abs(Pa(s,e))>this.locationThreshold)return!1}}else for(let i=0;i<4;i++){const n=t.location.points[i],r=this.location.points[i];if(!(Math.abs(r.x+e.x-n.x)=this.locationThreshold)return!1}return!0}isOverlappedLocationWithOffset(t,e,i=!0){const n=Object.assign({},t.location);for(let t=0;t<4;t++)n.points[t].x-=e.x,n.points[t].y-=e.y;if(!this.isLocationOverlap(n,t.location.area))return!1;if(i){const t=.75;return function(t,e){const i=[];for(let n=0;n<4;n++)for(let r=0;r<4;r++){const s=Ba(t[n],t[(n+1)%4],e[r],e[(r+1)%4]);s&&i.push(s)}return t.forEach((t=>{Ma(e,t)&&i.push(t)})),e.forEach((e=>{Ma(t,e)&&i.push(e)})),ja(function(t){if(t.length<=1)return t;t.sort(((t,e)=>t.x-e.x||t.y-e.y));const e=t.shift();return t.sort(((t,i)=>Math.atan2(t.y-e.y,t.x-e.x)-Math.atan2(i.y-e.y,i.x-e.x))),[e,...t]}(i))}([...this.location.points],n.points)>this.locationArea*t}return!0}}const Ya={BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096)},za={barcode:2,text_line:4,detected_quad:8,normalized_image:16},Ha=t=>Object.values(za).includes(t)||za.hasOwnProperty(t),Xa=(t,e)=>"string"==typeof t?e[za[t]]:e[t],Za=(t,e,i)=>{"string"==typeof t?e[za[t]]=i:e[t]=i},qa=(t,e,i)=>{const n=[8,16].includes(i);if(!n&&t.isResultCrossVerificationEnabled(i))for(let t=0;t{Za(e,this.verificationEnabled,t)})),xa(this,Aa,"f").forEach(((t,e)=>{Za(e,this.duplicateFilterEnabled,t)})),xa(this,Ra,"f").forEach(((t,e)=>{Za(e,this.duplicateForgetTime,t)})),xa(this,Da,"f").forEach(((t,e)=>{Za(e,this.latestOverlappingEnabled,t)})),xa(this,La,"f").forEach(((t,e)=>{Za(e,this.maxOverlappingFrames,t)}))}enableResultCrossVerification(t,e){Ha(t)&&xa(this,Oa,"f").set(t,e)}isResultCrossVerificationEnabled(t){return!!Ha(t)&&Xa(t,this.verificationEnabled)}enableResultDeduplication(t,e){Ha(t)&&(e&&this.enableLatestOverlapping(t,!1),xa(this,Aa,"f").set(t,e))}isResultDeduplicationEnabled(t){return!!Ha(t)&&Xa(t,this.duplicateFilterEnabled)}setDuplicateForgetTime(t,e){Ha(t)&&(e>18e4&&(e=18e4),e<0&&(e=0),xa(this,Ra,"f").set(t,e))}getDuplicateForgetTime(t){return Ha(t)?Xa(t,this.duplicateForgetTime):-1}setMaxOverlappingFrames(t,e){Ha(t)&&xa(this,La,"f").set(t,e)}getMaxOverlappingFrames(t){return Ha(t)?Xa(t,this.maxOverlappingFrames):-1}enableLatestOverlapping(t,e){Ha(t)&&(e&&this.enableResultDeduplication(t,!1),xa(this,Da,"f").set(t,e))}isLatestOverlappingEnabled(t){return!!Ha(t)&&Xa(t,this.latestOverlappingEnabled)}getFilteredResultItemTypes(){let t=0;const e=[yt.CRIT_BARCODE,yt.CRIT_TEXT_LINE,yt.CRIT_DETECTED_QUAD,yt.CRIT_NORMALIZED_IMAGE];for(let i=0;i{if(1!==t.type){const e=(BigInt(t.format)&BigInt(Ya.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Ya.BF_GS1_DATABAR))!=BigInt(0);return new Wa(l,e?1:2,e,t)}})).filter(Boolean);if(this.overlapSet.length>0){const t=new Array(h).fill(new Array(this.overlapSet.length).fill(1));let e=0;for(;e-1!==t)).length;r>p&&(p=r,m=n,g.x=i.x,g.y=i.y)}}if(0===p){for(let e=0;e-1!=t)).length}let i=this.overlapSet.length<=3?p>=1:p>=2;if(!i&&s&&d>0){let t=0;for(let e=0;e=1:t>=3}i||(this.overlapSet=[])}if(0===this.overlapSet.length)this.stabilityCount=0,t.items.forEach(((t,e)=>{if(1!==t.type){const i=Object.assign({},t),n=(BigInt(t.format)&BigInt(Ya.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Ya.BF_GS1_DATABAR))!=BigInt(0),s=t.confidence5||Math.abs(g.y)>5)&&(e=!1):e=!1;for(let i=0;i0){for(let t=0;t!(t.overlapCount+this.stabilityCount<=0&&t.crossVerificationFrame<=0)))}f.sort(((t,e)=>e-t)).forEach(((e,i)=>{t.items.splice(e,1)})),u.forEach((e=>{t.items.push(Object.assign(Object.assign({},e),{overlapped:!0}))}))}}onDecodedBarcodesReceived(t){this.latestOverlappingFilter(t),qa(this,t.items,yt.CRIT_BARCODE)}onRecognizedTextLinesReceived(t){qa(this,t.items,yt.CRIT_TEXT_LINE)}onDetectedQuadsReceived(t){qa(this,t.items,yt.CRIT_DETECTED_QUAD)}onNormalizedImagesReceived(t){qa(this,t.items,yt.CRIT_NORMALIZED_IMAGE)}}var Ka,$a,Qa;Oa=new WeakMap,Aa=new WeakMap,Ra=new WeakMap,Da=new WeakMap,La=new WeakMap,function(t){t.Passport="passport",t.TD1="td1",t.TD2="td2",t.PassportAndTD1="passportAndTd1",t.PassportAndTD2="passportAndTd2",t.TD1AndTD2="td1AndTd2",t.All="all"}(Ka||(Ka={})),function(t){t.Passport="passport",t.TD1="td1",t.TD2="td2"}($a||($a={})),function(t){t.Scanner="scanner",t.Result="scan-result"}(Qa||(Qa={}));const to={[Ka.Passport]:"ReadPassport",[Ka.TD1]:"ReadId-TD1",[Ka.TD2]:"ReadId-TD2",[Ka.PassportAndTD1]:"ReadPassportAndId-TD1",[Ka.PassportAndTD2]:"ReadPassportAndId-TD2",[Ka.TD1AndTD2]:"ReadId",[Ka.All]:"ReadPassportAndId"};var eo;function io(t){if("string"==typeof t){const e=document.querySelector(t);if(!e)throw new Error("Element not found");return e}return t instanceof HTMLElement?t:null}!function(t){t[t.RS_SUCCESS=0]="RS_SUCCESS",t[t.RS_CANCELLED=1]="RS_CANCELLED",t[t.RS_FAILED=2]="RS_FAILED"}(eo||(eo={}));function no(t,e){if(!document.getElementById(t)){const i=document.createElement("style");i.id=t,i.textContent=e,document.head.appendChild(i)}}const ro=t=>!t||0===Object.keys(t).length;function so(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}const ao={"4k":{width:3840,height:2160},"2k":{width:2560,height:1440},"1080p":{width:1920,height:1080},"720p":{width:1280,height:720},"480p":{width:640,height:480}};function oo(t,e={}){const{message:i,spinnerSize:n=32}=e,r=document.createElement("div");r.className="dynamsoft-mrz-loading-screen";const s=document.createElement("div");s.className="dynamsoft-mrz-loading";const a=document.createElement("div");a.className="dynamsoft-mrz-loading-content";const o=`\n \n \n \n `;if(a.innerHTML=o,i){const t=document.createElement("div");t.className="dynamsoft-mrz-loading-message",t.textContent=i,a.appendChild(t)}return s.appendChild(a),r.appendChild(s),t.appendChild(r),{element:r,updateMessage:t=>{let e=s.querySelector(".dynamsoft-mrz-loading-message");null!==t?e?e.textContent=t:(e=document.createElement("div"),e.className="dynamsoft-mrz-loading-message",e.textContent=t,a.appendChild(e)):null==e||e.remove()},hide:()=>{r&&r.parentNode&&(r.classList.add("fade-out"),setTimeout((()=>{var t;null===(t=r.parentNode)||void 0===t||t.removeChild(r)}),200))}}}const lo='\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: "Verdana";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n';var ho;!function(t){t.InvalidFields="invalidFields",t.DocumentType="documentType",t.DocumentNumber="documentNumber",t.MRZText="mrzText",t.FirstName="firstName",t.LastName="lastName",t.Age="age",t.Sex="sex",t.IssuingState="issuingState",t.IssuingStateRaw="issuingStateRaw",t.Nationality="nationality",t.NationalityRaw="nationalityRaw",t.DateOfBirth="dateOfBirth",t.DateOfExpiry="dateOfExpiry"}(ho||(ho={}));const co={[ho.InvalidFields]:"Invalid Fields",[ho.DocumentType]:"Document Type",[ho.DocumentNumber]:"Document Number",[ho.MRZText]:"MRZ Text",[ho.FirstName]:"Given Name(s)",[ho.LastName]:"Surname",[ho.Age]:"Age",[ho.Sex]:"Sex",[ho.IssuingState]:"Issuing State",[ho.IssuingStateRaw]:"Issuing State (Raw Value)",[ho.Nationality]:"Nationality",[ho.NationalityRaw]:"Nationality State (Raw Value)",[ho.DateOfBirth]:"Date Of Birth (YYYY-MM-DD)",[ho.DateOfExpiry]:"Date Of Expiry (YYYY-MM-DD)"};function uo(t,e,i,n=!1){const r=parseInt(t,10);let s;if(n)s=r>=60?1900+r:2e3+r;else{s=r>(new Date).getFullYear()%100?1900+r:2e3+r}return{year:s,month:parseInt(e,10),day:parseInt(i,10)}}function fo(t){const e=t=>{var e;return 1===(null===(e=`${t}`)||void 0===e?void 0:e.length)?`0${t}`:t};return`${null==t?void 0:t.year}-${e(null==t?void 0:t.month)}${(null==t?void 0:t.day)&&`-${e(null==t?void 0:t.day)}`}`}function go(t){return"D<<"===t?"D":t}function mo(t,e){const i=[],n=t=>e.getFieldValidationStatus(t)===na.VS_FAILED,r=e.codeType,s=function(t){switch(t){case"MRTD_TD1_ID":return $a.TD1;case"MRTD_TD2_ID":case"MRTD_TD2_VISA":case"MRTD_TD2_FRENCH_ID":return $a.TD2;case"MRTD_TD3_PASSPORT":case"MRTD_TD3_VISA":return $a.Passport;default:throw new Error(`Unknown document type: ${t}`)}}(r),a=function(t){switch(t){case"MRTD_TD1_ID":return"ID (TD1)";case"MRTD_TD2_ID":return"ID (TD2)";case"MRTD_TD2_VISA":return"ID (VISA)";case"MRTD_TD2_FRENCH_ID":return"French ID (TD2)";case"MRTD_TD3_PASSPORT":return"Passport (TD3)";case"MRTD_TD3_VISA":return"Visa (TD3)";default:throw new Error(`Unknown document type: ${t}`)}}(r),o=s===$a.Passport&&"MRTD_TD3_PASSPORT"===r?"passportNumber":"documentNumber",l=uo(e.getFieldValue("birthYear"),e.getFieldValue("birthMonth"),e.getFieldValue("birthDay")),h=uo(e.getFieldValue("expiryYear"),e.getFieldValue("expiryMonth"),e.getFieldValue("expiryDay"),!0);["birthYear","birthMonth","birthDay"].forEach((t=>{n(t)&&i.push(ho.DateOfBirth)})),["expiryYear","expiryMonth","expiryDay"].forEach((t=>{n(t)&&i.push(ho.DateOfExpiry)}));const c={[ho.LastName]:e.getFieldValue("primaryIdentifier"),[ho.FirstName]:e.getFieldValue("secondaryIdentifier"),[ho.Nationality]:e.getFieldValue("nationality"),[ho.NationalityRaw]:go(e.getFieldRawValue("nationality")),[ho.DocumentNumber]:e.getFieldValue(o)||e.getFieldValue("longDocumentNumber"),[ho.IssuingState]:e.getFieldValue("issuingState"),[ho.IssuingStateRaw]:go(e.getFieldRawValue("issuingState")),[ho.Sex]:so(e.getFieldValue("sex"))};Object.keys(c).forEach((t=>{let e=!1;switch(t){case ho.FirstName:e=n("secondaryIdentifier");break;case ho.LastName:e=n("primaryIdentifier");break;case ho.DocumentNumber:e=n(o)||n("longDocumentNumber");break;default:e=n(t)}e&&i.push(t)}));const d=function(t){const e=new Date,i=e.getMonth()+1>t.month||e.getMonth()+1===t.month&&e.getDate()>=t.day;return e.getFullYear()-t.year-(i?0:1)}(l);d<1&&i.push(ho.Age);return{[ho.InvalidFields]:i,[ho.FirstName]:c[ho.FirstName],[ho.LastName]:c[ho.LastName],[ho.Age]:d,[ho.DateOfBirth]:l,[ho.Sex]:c[ho.Sex],[ho.Nationality]:c[ho.Nationality],[ho.NationalityRaw]:c[ho.NationalityRaw],[ho.DocumentNumber]:c[ho.DocumentNumber],[ho.DateOfExpiry]:h,[ho.IssuingState]:c[ho.IssuingState],[ho.IssuingStateRaw]:c[ho.IssuingStateRaw],[ho.DocumentType]:so(a),[ho.MRZText]:t}}const po={[$a.TD1]:{width:85.6,height:53.98},[$a.TD2]:{width:105,height:74},[$a.Passport]:{width:125,height:88}};class _o{showScannerLoadingOverlay(t){const e=io(this.config.container);this.loadingScreen=oo(e,{message:t}),e.style.display="block",e.style.position="relative"}hideScannerLoadingOverlay(t=!1){this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,t&&(io(this.config.container).style.display="none"))}constructor(t,e){this.resources=t,this.config=e,this.isSoundFeedbackOn=!1,this.scanModeManager={[$a.Passport]:!0,[$a.TD1]:!0,[$a.TD2]:!0},this.currentScanMode=Ka.All,this.resizeTimer=null,this.capturedResultItems=[],this.originalImageData=null,this.initialized=!1,this.initializedDCE=!1,this.DCE_ELEMENTS={selectCameraBtn:null,uploadImageBtn:null,soundFeedbackBtn:null,closeScannerBtn:null,scanModeSelectContainer:null,passportModeOption:null,td1ModeOption:null,td2ModeOption:null,toast:null},this.loadingScreen=null,this.handleResize=()=>{this.toggleScanGuide(!1),this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((()=>{this.toggleScanGuide(!0)}),500)}}async initialize(){if(!this.initialized){this.initializeScanModeManager(),this.currentScanMode=this.getScanMode(),no("dynamsoft-mrz-loading-screen-style",lo);try{const{cameraView:t,cameraEnhancer:e,cvRouter:i}=this.resources;if(t.setScanRegionMaskStyle({strokeStyle:"transparent",fillStyle:"transparent",lineWidth:0}),t.setVideoFit("cover"),i.setInput(e),await i.initSettings(this.config.templateFilePath),!0===this.config.enableMultiFrameCrossFilter){const t=new Ja;t.enableResultCrossVerification(yt.CRIT_TEXT_LINE,!0),t.enableResultDeduplication(yt.CRIT_TEXT_LINE,!0),await i.addResultFilter(t)}const n=new Be;n.onCapturedResultReceived=t=>this.handleMRZResult(t),await i.addResultReceiver(n),this.toggleSoundFeedback(!1),!1===this.config.showScanGuide&&this.toggleScanGuide(!1),this.initialized=!0}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e),this.closeCamera();const i={status:{code:eo.RS_FAILED,message:"Dynamsoft MRZ Scanner initialize error"}};this.currentScanResolver(i)}}}initializeElements(){var t;const e=io(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))throw new Error("Shadow root not found");if(this.DCE_ELEMENTS={selectCameraBtn:i.shadowRoot.querySelector(".dce-mn-select-camera-icon"),uploadImageBtn:i.shadowRoot.querySelector(".dce-mn-upload-image-icon"),soundFeedbackBtn:i.shadowRoot.querySelector(".dce-mn-sound-feedback"),closeScannerBtn:i.shadowRoot.querySelector(".dce-mn-close"),scanModeSelectContainer:i.shadowRoot.querySelector(".dce-mn-scan-mode-select"),passportModeOption:i.shadowRoot.querySelector(".scan-mode-option-passport"),td1ModeOption:i.shadowRoot.querySelector(".scan-mode-option-td1"),td2ModeOption:i.shadowRoot.querySelector(".scan-mode-option-td2"),toast:i.shadowRoot.querySelector(".dce-mn-toast")},this.setupScanModeSelector(),this.assignDCEClickEvents(),this.DCE_ELEMENTS.toast.style.display="none",!1===this.config.showUploadImage&&(this.DCE_ELEMENTS.uploadImageBtn.style.visibility="hidden"),!1===this.config.showSoundToggle&&(this.DCE_ELEMENTS.soundFeedbackBtn.style.visibility="hidden"),!1===(null===(t=this.config)||void 0===t?void 0:t.showPoweredByDynamsoft)){i.shadowRoot.querySelector(".dce-mn-msg-poweredby").style.display="none"}this.initializedDCE=!0}setupScanModeSelector(){if(!1!==this.config.showFormatSelector)switch(this.currentScanMode){case Ka.PassportAndTD1:this.DCE_ELEMENTS.td2ModeOption.style.display="none";break;case Ka.PassportAndTD2:this.DCE_ELEMENTS.td1ModeOption.style.display="none";break;case Ka.TD1AndTD2:this.DCE_ELEMENTS.passportModeOption.style.display="none";break;case Ka.All:break;default:this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}else this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}assignDCEClickEvents(){if(!Object.values(this.DCE_ELEMENTS).every(Boolean))throw new Error("Camera control elements not found");this.closeCamera=this.closeCamera.bind(this),this.DCE_ELEMENTS.uploadImageBtn.onclick=()=>this.uploadFile(),this.DCE_ELEMENTS.soundFeedbackBtn.onclick=()=>this.toggleSoundFeedback(),this.DCE_ELEMENTS.closeScannerBtn.onclick=()=>this.handleCloseBtn(),this.DCE_ELEMENTS.selectCameraBtn.onclick=t=>{t.stopPropagation(),this.toggleSelectCameraBox()},this.DCE_ELEMENTS.passportModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.passportModeOption.style.display&&await this.toggleScanDocType($a.Passport)},this.DCE_ELEMENTS.td1ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td1ModeOption.style.display&&await this.toggleScanDocType($a.TD1)},this.DCE_ELEMENTS.td2ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td2ModeOption.style.display&&await this.toggleScanDocType($a.TD2)}}handleCloseBtn(){this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:eo.RS_CANCELLED,message:"Cancelled"}})}attachOptionClickListeners(){const t=io(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings");[...e.shadowRoot.querySelectorAll(".dce-mn-camera-option"),...e.shadowRoot.querySelectorAll(".dce-mn-resolution-option")].forEach((t=>{t.addEventListener("click",(async e=>{const n=t.getAttribute("data-davice-id"),r=t.getAttribute("data-height"),s=t.getAttribute("data-width");n?this.resources.cameraEnhancer.selectCamera(n).then((()=>{this.toggleScanGuide()})):r&&s&&this.resources.cameraEnhancer.setResolution({width:parseInt(s),height:parseInt(r)}).then((()=>{this.toggleScanGuide()})),"none"!==i.style.display&&this.toggleSelectCameraBox()}))}))}highlightCameraAndResolutionOption(){const t=io(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings"),n=i.querySelectorAll(".dce-mn-camera-option"),r=i.querySelectorAll(".dce-mn-resolution-option"),s=this.resources.cameraEnhancer.getSelectedCamera(),a=this.resources.cameraEnhancer.getResolution();n.forEach((t=>{const e=t;e.getAttribute("data-davice-id")===(null==s?void 0:s.deviceId)?e.style.border="2px solid #fe814a":e.style.border="none"}));const o={"480p":"480","720p":"720","1080p":"1080","2k":"1440","4k":"2160"},l=function(t){const e=t.width*t.height,i=t.width/t.height;let n="480p",r=Number.MAX_VALUE;for(const[t,s]of Object.entries(ao)){const a=s.width*s.height,o=s.width/s.height,l=.7*Math.abs(a-e)+Math.abs(o-i)*a*.3;l{const e=t,i=e.getAttribute("data-height");e.style.border=i===o[l]?"2px solid #fe814a":"none"}))}toggleSelectCameraBox(){const t=io(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-resolution-box");this.highlightCameraAndResolutionOption(),this.attachOptionClickListeners(),i.click()}async relaunch(){}async uploadFile(){var t,e,i,n;const{cvRouter:r}=this.resources,s=document.createElement("input");s.type="file",s.accept=null!==(t=this.config.uploadAcceptedTypes)&&void 0!==t?t:"image/*",s.style.display="none",document.body.appendChild(s);try{this.showScannerLoadingOverlay("Processing file..."),await this.closeCamera(!1);const t=await new Promise(((t,e)=>{s.onchange=i=>{var n;const r=null===(n=i.target.files)||void 0===n?void 0:n[0];r?t(r):e(new Error("No file selected"))},s.addEventListener("cancel",(async()=>{this.hideScannerLoadingOverlay(!1),await this.openCamera(),await this.startCapturing(),this.toggleScanGuide()})),s.click()}));if(!t)return;let a;if(this.config.uploadFileConverter&&!t.type.startsWith("image/"))try{a=await this.config.uploadFileConverter(t)}catch(t){throw new Error(`Error converting file: ${t.message}`)}else{if(!t.type.startsWith("image/"))throw new Error("Unsupported file type. Please provide a converter function for this file type.");a=t}const o=this.config.utilizedTemplateNames[this.currentScanMode];if(!1!==this.config.showScanGuide){const t=await r.getSimplifiedSettings(o);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await r.updateSettings(o,t)}const l=await r.capture(a,o);this.capturedResultItems=l.items;const h=this.capturedResultItems.filter((t=>t.type===yt.CRIT_ORIGINAL_IMAGE));if(0===h.length)throw new Error("No image data found in the captured result");const c=h[0].imageData;c.toCanvas=()=>F(c),c.toBlob=async()=>await k("image/png",c),this.originalImageData=c;const d=null==l?void 0:l.textLineResultItems,u=null==l?void 0:l.parsedResultItems;let f={};if(null==d?void 0:d.length){const t=(null===(e=d[0])||void 0===e?void 0:e.text)||"";f=mo(t,u[0])}const g={status:{code:eo.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:f,imageData:!0,_imageData:this.originalImageData};null===(n=(i=this.resources).onResultUpdated)||void 0===n||n.call(i,g),this.currentScanResolver(g)}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e),this.closeCamera();const i={status:{code:eo.RS_FAILED,message:`Error processing file: ${e}`}};this.currentScanResolver(i)}finally{this.hideScannerLoadingOverlay(!0),document.body.removeChild(s)}}toggleSoundFeedback(t){this.isSoundFeedbackOn=void 0!==t?t:!this.isSoundFeedbackOn;const e=io(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))return;const n=i.shadowRoot.querySelector(".dce-mn-sound-feedback"),r=n.querySelector(".dce-mn-sound-feedback-on");n.querySelector(".dce-mn-sound-feedback-off").style.display=this.isSoundFeedbackOn?"none":"block",r.style.display=this.isSoundFeedbackOn?"block":"none"}calculateScanRegion(t){const{cameraEnhancer:e,cameraView:i}=this.resources;if(!e||!e.isOpen())return;const n=i.getVisibleRegionOfVideo({inPixels:!0});if(!n)return;const r=i.getVideoElement(),s=r.videoWidth,a=r.videoHeight,o=po[t];let l;const h=n.height-80;if(n.width>n.height){l=.75*h/o.height;l*o.width>.9*n.width&&(l=.9*n.width/o.width)}else{l=.9*n.width/o.width;l*o.height>.75*h&&(l=.75*h/o.height)}const c=l*o.width,d=l*o.height,u=(n.width-c)/2,f=(h-d)/2,g=u,m=u+c,p=f,_=f+d,v=(n.x+g)/s*100,y=(n.x+m)/s*100,w=(n.y+p)/a*100,C=(n.y+_)/a*100,E={left:Math.round(v),right:Math.round(y),top:Math.round(w),bottom:Math.round(C),isMeasuredInPercentage:!0};null==i||i.setScanRegionMaskVisible(!0),e.setScanRegion(E)}toggleScanGuide(t){const e=io(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))return;const n=i.shadowRoot.querySelector(".dce-scanguide-passport"),r=i.shadowRoot.querySelector(".dce-scanguide-td1"),s=i.shadowRoot.querySelector(".dce-scanguide-td2");if(!1===t||!1===this.config.showScanGuide)return n.style.display="none",r.style.display="none",void(s.style.display="none");switch(this.currentScanMode){case Ka.All:case Ka.Passport:case Ka.PassportAndTD1:case Ka.PassportAndTD2:n.style.display="block",r.style.display="none",s.style.display="none",this.calculateScanRegion($a.Passport);break;case Ka.TD1:case Ka.TD1AndTD2:n.style.display="none",r.style.display="block",s.style.display="none",this.calculateScanRegion($a.TD1);break;case Ka.TD2:n.style.display="none",r.style.display="none",s.style.display="block",this.calculateScanRegion($a.TD2)}}async openCamera(){try{this.showScannerLoadingOverlay("Initializing camera...");const{cameraEnhancer:t,cameraView:e}=this.resources,i=io(this.config.container);if(i.style.display="block",t.isOpen())t.isPaused()&&await t.resume();else{const n=e.getUIElement();n.parentElement||i.append(n),await t.open()}await t.setResolution({width:2560,height:1440}),!this.initializedDCE&&t.isOpen()&&await this.initializeElements(),window.addEventListener("resize",this.handleResize);const n=i.children[i.children.length-1];if(!(null==n?void 0:n.shadowRoot))throw new Error("Shadow root not found");n.shadowRoot.querySelector(".dce-mn-torch-off").style.display="none",n.shadowRoot.querySelector(".dce-mn-torch-on").style.display="none"}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e),this.closeCamera();const i={status:{code:eo.RS_FAILED,message:"MRZ Scanner Open Camera Error"}};this.currentScanResolver(i)}finally{this.hideScannerLoadingOverlay()}}async closeCamera(t=!0){try{window.removeEventListener("resize",this.handleResize),this.resizeTimer&&(window.clearTimeout(this.resizeTimer),this.resizeTimer=null);const{cameraEnhancer:e,cameraView:i}=this.resources,n=io(this.config.container);n.style.display=t?"none":"block",(null==i?void 0:i.getUIElement().parentElement)&&n.removeChild(i.getUIElement()),e.close(),this.stopCapturing()}catch(t){let e=(null==t?void 0:t.message)||t;console.error(`Close Camera error: ${e}`)}}pauseCamera(){const{cameraEnhancer:t}=this.resources;t.pause()}stopCapturing(){const{cameraView:t,cvRouter:e}=this.resources;e.stopCapturing(),t.clearAllInnerDrawingItems()}async handleMRZResult(t){var e;if(this.capturedResultItems=t.items,!(t.items.length<=1))try{const{onResultUpdated:i}=this.resources,n=t.items.filter((t=>t.type===yt.CRIT_ORIGINAL_IMAGE))[0].imageData;n.toCanvas=()=>F(n),n.toBlob=async()=>await k("image/png",n),this.originalImageData=n;const r=null==t?void 0:t.textLineResultItems,s=null==t?void 0:t.parsedResultItems;if(r){this.isSoundFeedbackOn&&Ds.beep();const t=(null===(e=null==r?void 0:r[0])||void 0===e?void 0:e.text)||"",n=mo(t,s[0]);this.closeCamera();const a={status:{code:eo.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:n,imageData:!0,_imageData:this.originalImageData};null==i||i(a),this.currentScanResolver(a)}}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e),this.closeCamera();const i={status:{code:eo.RS_FAILED,message:"Error capturing image"}};this.currentScanResolver(i)}}initializeScanModeManager(){const{mrzFormatType:t}=this.config;if(this.scanModeManager={[$a.Passport]:!0,[$a.TD1]:!0,[$a.TD2]:!0},!t||Array.isArray(t)&&0===t.length)return;Object.keys(this.scanModeManager).forEach((t=>{this.scanModeManager[t]=!1}));(Array.isArray(t)?t:[t]).forEach((t=>{this.scanModeManager[t]=!0}))}getScanMode(){const t=Object.entries(this.scanModeManager).filter((([t,e])=>e)).map((([t])=>t)).sort().join(",");return{[$a.Passport]:Ka.Passport,[$a.TD1]:Ka.TD1,[$a.TD2]:Ka.TD2,[`${$a.Passport},${$a.TD1}`]:Ka.PassportAndTD1,[`${$a.Passport},${$a.TD2}`]:Ka.PassportAndTD2,[`${$a.TD1},${$a.TD2}`]:Ka.TD1AndTD2,[`${$a.Passport},${$a.TD1},${$a.TD2}`]:Ka.All,"":Ka.All}[t]}DCEShowToast(t,e=3e3){this.DCE_ELEMENTS.toast&&(this.DCE_ELEMENTS.toast.textContent=t,this.DCE_ELEMENTS.toast.style.display="",setTimeout((()=>{this.DCE_ELEMENTS.toast.style.display="none"}),e))}async startCapturing(){const{cvRouter:t,cameraEnhancer:e}=this.resources,i=this.config.utilizedTemplateNames[this.currentScanMode];try{if(!1!==this.config.showScanGuide){const e=await t.getSimplifiedSettings(i);e.roiMeasuredInPercentage=!0,e.roi.points=[{x:0,y:50},{x:100,y:50},{x:100,y:100},{x:0,y:100}],await t.updateSettings(i,e)}await t.startCapturing(i),e.setPixelFormat(o.IPF_ABGR_8888)}catch(t){let e=(null==t?void 0:t.message)||t;console.error("Failed to start capturing:",e),this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:eo.RS_FAILED,message:"Failed to start capturing"}})}}async toggleScanDocType(t){try{if(this.scanModeManager[t]&&0===Object.entries(this.scanModeManager).filter((([e,i])=>i&&e!==t)).length)return console.warn("MRZ Scanner - At least one mode must be enabled"),void this.DCEShowToast("At least one mode must be enabled");this.scanModeManager[t]=!this.scanModeManager[t],this.currentScanMode=this.getScanMode(),this.stopCapturing(),await this.startCapturing(),this.toggleScanGuide(),this.DCE_ELEMENTS.td1ModeOption.classList.toggle("selected",this.scanModeManager[$a.TD1]),this.DCE_ELEMENTS.td2ModeOption.classList.toggle("selected",this.scanModeManager[$a.TD2]),this.DCE_ELEMENTS.passportModeOption.classList.toggle("selected",this.scanModeManager[$a.Passport])}catch(t){let e=(null==t?void 0:t.message)||t;console.error("MRZ Scanner switch scan mode error: ",e),this.closeCamera();const i={status:{code:eo.RS_FAILED,message:"MRZ Scanner switch scan mode error"}};this.currentScanResolver(i)}}async launch(){try{await this.initialize();const{cvRouter:t,cameraEnhancer:e}=this.resources;return new Promise((async t=>{this.currentScanResolver=t,await this.openCamera(),!this.initializedDCE&&e.isOpen()&&await this.initializeElements(),await this.startCapturing(),this.toggleScanGuide()}))}catch(t){let e=(null==t?void 0:t.message)||t;console.error("MRZ Scanner launch error: ",e),this.closeCamera();const i={status:{code:eo.RS_FAILED,message:"MRZ Scanner launch error"}};this.currentScanResolver(i)}}}const vo={rescan:'\n\n\n \n\n\n\n\n\n\n\n',complete:'\n\n\n\n \n\n\n\n\n\n\n\n',failed:'\n \n \n \n\n',info:'\n\n \n \n \n\n'};class yo{constructor(t,e,i){this.resources=t,this.config=e,this.scannerView=i,this.editedFields={}}async launch(){try{return io(this.config.container).textContent="",await this.initialize(),io(this.config.container).style.display="flex",new Promise((t=>{this.currentScanResultViewResolver=t}))}catch(t){let e=(null==t?void 0:t.message)||t;throw console.error(e),e}}async handleRescan(){var t;try{if(!this.scannerView)return void console.error("Scanner View not initialized");this.hideView();const e=await this.scannerView.launch();if((null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.code)===eo.RS_FAILED)return void(this.currentScanResultViewResolver&&this.currentScanResultViewResolver(e));this.resources.onResultUpdated&&((null==e?void 0:e.status.code)===eo.RS_CANCELLED?this.resources.onResultUpdated(this.resources.result):(null==e?void 0:e.status.code)===eo.RS_SUCCESS&&this.resources.onResultUpdated(e)),this.dispose(!0),await this.initialize(),io(this.config.container).style.display="flex"}catch(t){throw console.error("Error in rescan handler:",t),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:eo.RS_FAILED,message:(null==t?void 0:t.message)||t}}),t}}async handleDone(){var t,e;try{(null===(t=this.resources.result)||void 0===t?void 0:t.data)&&!ro(this.editedFields)&&(this.resources.result.data=Object.assign(Object.assign({},this.resources.result.data),this.editedFields),this.resources.onResultUpdated&&this.resources.onResultUpdated(this.resources.result)),(null===(e=this.config)||void 0===e?void 0:e.onDone)&&await this.config.onDone(this.resources.result),this.currentScanResultViewResolver&&this.resources.result&&this.currentScanResultViewResolver(this.resources.result),this.hideView(),this.dispose()}catch(t){throw console.error("Error in done handler:",t),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:eo.RS_FAILED,message:(null==t?void 0:t.message)||t}}),t}}createControls(){var t,e,i,n,r,s,a,o;const{toolbarButtonsConfig:l}=this.config;return function(t){no("dynamsoft-mrz-controls-style","\n .dynamsoft-mrz-controls {\n display: flex;\n height: 6rem;\n background-color: #323234;\n align-items: center;\n font-size: 12px;\n font-family: Verdana;\n color: white;\n width: 100%;\n }\n\n .dynamsoft-mrz-control-btn {\n background-color: #323234;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n gap: 0.5rem;\n text-align: center;\n user-select: none;\n }\n\n .dynamsoft-mrz-control-btn.hide {\n display: none;\n }\n\n .dynamsoft-mrz-control-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n cursor: default;\n }\n\n .dynamsoft-mrz-control-icon-wrapper {\n flex: 0.75;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n min-height: 40px;\n }\n\n .dynamsoft-mrz-control-icon img,\n .dynamsoft-mrz-control-icon svg {\n width: 32px;\n height: 32px;\n fill: #fe8e14;\n }\n\n .dynamsoft-mrz-control-text {\n flex: 0.5;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-bottom: 0.5rem;\n }\n\n \n @media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-controls {\n flex-direction: column;\n height: 100%;\n width: 5rem;\n }\n\n .dynamsoft-mrz-control-text {\n padding: 0 0.5rem 0.5rem;\n }\n }\n");const e=document.createElement("div");return e.className="dynamsoft-mrz-controls",t.forEach((t=>{const i=document.createElement("div");i.className=`dynamsoft-mrz-control-btn ${null==t?void 0:t.className}`;const n=document.createElement("div");if(n.className="dynamsoft-mrz-control-icon-wrapper",(r=t.icon).trim().startsWith(""))n.innerHTML=t.icon;else{const e=document.createElement("img");e.src=t.icon,e.alt=t.label,e.width=24,e.height=24,n.appendChild(e)}var r;const s=document.createElement("div");s.className="dynamsoft-mrz-control-text",s.textContent=t.label,t.isDisabled&&i.classList.add("disabled"),t.isHidden&&i.classList.add("hide"),i.appendChild(n),i.appendChild(s),t.onClick&&!t.isDisabled&&i.addEventListener("click",t.onClick),e.appendChild(i)})),e}([{id:"dynamsoft-mrz-scanResult-rescan",icon:(null===(t=null==l?void 0:l.rescan)||void 0===t?void 0:t.icon)||vo.rescan,label:(null===(e=null==l?void 0:l.rescan)||void 0===e?void 0:e.label)||"Re-scan",onClick:()=>this.handleRescan(),className:`${(null===(i=null==l?void 0:l.rescan)||void 0===i?void 0:i.className)||""}`,isHidden:(null===(n=null==l?void 0:l.rescan)||void 0===n?void 0:n.isHidden)||!1,isDisabled:!this.scannerView},{id:"dynamsoft-mrz-scanResult-done",icon:(null===(r=null==l?void 0:l.done)||void 0===r?void 0:r.icon)||vo.complete,label:(null===(s=null==l?void 0:l.done)||void 0===s?void 0:s.label)||"Done",className:`${(null===(a=null==l?void 0:l.done)||void 0===a?void 0:a.className)||""}`,isHidden:(null===(o=null==l?void 0:l.done)||void 0===o?void 0:o.isHidden)||!1,onClick:()=>this.handleDone()}])}handleFieldEdit(t,e){if(t===ho.DateOfBirth||t===ho.DateOfExpiry)try{const[i,n,r]=e.split(/[\/\-\.]/);r&&n&&i&&(this.editedFields[t]={day:parseInt(r,10),month:parseInt(n,10),year:parseInt(i,10)})}catch(t){console.error("Error parsing date",t)}else this.editedFields[t]=e}createMRZDataDisplay(){var t;const e=(null===(t=this.resources.result)||void 0===t?void 0:t.data)||{},i=!!this.config.allowResultEditing,n=e.invalidFields||[],r=document.createElement("div");if(r.className="dynamsoft-mrz-data-container",ro(e)){const t=document.createElement("div");return t.className="dynamsoft-mrz-data-row empty",t.innerText="No MRZ detected. Please try again.",r.appendChild(t),r}if(n.length>0){const t=document.createElement("div");t.className="dynamsoft-mrz-error-notification",t.innerHTML=`\n
${vo.failed}
\n
\n ${i?"Some fields require correction. Please review highlighted fields.":"Some fields contain invalid information. Please rescan the document."}\n
\n `,r.appendChild(t)}else if(0===n.length&&i){const t=document.createElement("div");t.className="dynamsoft-mrz-info-notification",t.innerHTML=`\n
${vo.info}
\n
\n Please review all fields to ensure the information is correct.\n
\n `,r.appendChild(t)}return Object.entries(e).forEach((([t,e])=>{var s;if(t===ho.InvalidFields||!e)return;if(t===ho.MRZText&&!1===(null===(s=this.config)||void 0===s?void 0:s.showMRZText))return;const a=document.createElement("div");a.className="dynamsoft-mrz-data-row";const o=n.includes(t);o&&a.classList.add("invalid-field");const l=[ho.MRZText,ho.DocumentType,ho.IssuingStateRaw,ho.NationalityRaw],h=document.createElement("span");if(h.className="dynamsoft-mrz-data-label",h.innerText=co[t]||t,o){const t=document.createElement("span");if(t.className="dynamsoft-mrz-error-icon",t.innerHTML=vo.failed,h.appendChild(t),i){const t=document.createElement("span");t.className="dynamsoft-mrz-error-hint",t.textContent="Please correct this field",h.appendChild(t)}}const c=document.createElement("div");if(c.className="dynamsoft-mrz-data-value",i&&!l.includes(t)){const i=document.createElement("input");i.className="dynamsoft-mrz-data-input",o&&i.classList.add("invalid"),t===ho.DateOfBirth||t===ho.DateOfExpiry?(i.value=fo(e),i.setAttribute("placeholder","YYYY-MM-DD")):i.value=e,i.addEventListener("input",(e=>{if(this.handleFieldEdit(t,e.target.value),o){i.classList.remove("invalid"),a.classList.remove("invalid-field"),this.editedFields.invalidFields||(this.editedFields.invalidFields=[...n]);const e=this.editedFields.invalidFields.indexOf(t);e>-1&&this.editedFields.invalidFields.splice(e,1)}})),c.appendChild(i)}else t===ho.MRZText?(c.classList.add("code"),c.innerText=e):t===ho.DateOfBirth||t===ho.DateOfExpiry?c.innerText=fo(e):c.innerText=e,o&&c.classList.add("invalid-value");a.appendChild(h),a.appendChild(c),r.appendChild(a)})),r}async initialize(){try{if(!this.resources.result)throw Error("Captured image is missing. Please capture an image first!");if(!this.config.container)throw new Error("Please create a Scan Result View Container element");no("dynamsoft-mrz-result-view-style",wo);const t=document.createElement("div");if(t.className="dynamsoft-mrz-result-view-container",!1!==this.config.showOriginalImage){const e=this.resources.result.originalImageResult,i=document.createElement("div");let n;i.className="dynamsoft-mrz-result-view-image-container",(null==e?void 0:e.toCanvas)&&(n=null==e?void 0:e.toCanvas()),Object.assign(n.style,{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}),i.appendChild(n),t.appendChild(i)}const e=this.createMRZDataDisplay();t.appendChild(e);const i=this.createControls();t.appendChild(i),io(this.config.container).appendChild(t)}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e)}}hideView(){io(this.config.container).style.display="none"}dispose(t=!1){io(this.config.container).textContent="",t||(this.currentScanResultViewResolver=void 0)}}const wo="\n .dynamsoft-mrz-result-view-container {\n display: flex;\n width: 100%;\n height: 100%;\n background-color:#575757;\n font-size: 12px;\n flex-direction: column;\n align-items: center;\n }\n\n .dynamsoft-mrz-result-view-image-container {\n width: 100%;\n height: 200px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #323234;\n }\n\n \n.dynamsoft-mrz-data-container {\n font-size: 16px;\n font-family: Verdana;\n color: white;\n overflow: auto;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 1rem 0;\n}\n\n.dynamsoft-mrz-data-row {\n padding: 0.5rem 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n transition: background-color 0.3s ease;\n}\n\n.dynamsoft-mrz-data-row.invalid-field {\n background-color: rgba(231, 76, 60, 0.1);\n border-left: 3px solid #e74c3c;\n padding-left: calc(2rem - 3px);\n}\n\n.dynamsoft-mrz-data-label {\n color: #aaa;\n display: flex;\n gap: 0.5rem;\n align-items: end;\n flex-wrap: wrap;\n}\n\n.dynamsoft-mrz-error-notification,\n.dynamsoft-mrz-info-notification {\n color: white;\n padding: 1rem;\n margin: 0.5rem 2rem;\n border-radius: 4px;\n display: flex;\n align-items: center;\n gap: 1rem;\n text-align: start;\n}\n\n.dynamsoft-mrz-error-notification {\n background-color: rgba(231, 76, 60, 0.2);\n}\n\n.dynamsoft-mrz-info-notification {\n background-color: rgba(196, 231, 60, 0.2);\n}\n\n.dynamsoft-mrz-edit-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #aaa;\n}\n\n.dynamsoft-mrz-error-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-info-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.dynamsoft-mrz-info-message,\n.dynamsoft-mrz-error-message {\n flex: 1;\n}\n\n.dynamsoft-mrz-error-hint {\n font-size: 0.8rem;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-value {\n word-wrap: break-word;\n text-align: start;\n}\n\n.dynamsoft-mrz-data-value.code {\n font-family: monospace;\n}\n\n.dynamsoft-mrz-data-value.invalid-value {\n color: #e74c3c;\n text-decoration: wavy underline #e74c3c;\n text-decoration-skip-ink: none;\n}\n\n.dynamsoft-mrz-data-input {\n width: 100%;\n padding: 5px;\n background-color: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.3);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n transition: all 0.3s ease;\n}\n\n.dynamsoft-mrz-data-input.invalid {\n background-color: rgba(231, 76, 60, 0.1);\n border-color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-input:focus {\n background-color: rgba(255, 255, 255, 0.2);\n border-color: #fe8e14;\n outline: none;\n}\n\n@media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-result-view-container {\n flex-direction: row;\n }\n\n .dynamsoft-mrz-result-view-image-container{\n flex: 1;\n height: 100%;\n }\n\n .dynamsoft-mrz-data-container{\n flex: 1;\n }\n\n .dynamsoft-mrz-data-row:first-of-type {\n padding-top: 2rem;\n }\n\n .dynamsoft-mrz-data-row:last-of-type {\n padding-bottom: 2rem;\n }\n\n .dynamsoft-mrz-data-row.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding-top: 0;\n padding-bottom: 0;\n }\n}\n",Co={rootDirectory:"https://cdn.jsdelivr.net/npm/"};class Eo{showLoadingOverlay(t){var e,i;const n=io(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||io(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container);this.loadingScreen=oo(n,{message:t}),n.style.display="block",n.style.position="relative"}hideLoadingOverlay(t=!1){var e,i,n;const r=io(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||io(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container);this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,r.style.display="none",t&&(null===(n=this.config)||void 0===n?void 0:n.container)&&(io(this.config.container).style.display="none"))}constructor(t){this.config=t,this.resources={},this.isInitialized=!1,this.isCapturing=!1,this.loadingScreen=null}async initialize(){if(this.isInitialized)return{resources:this.resources,components:{scannerView:this.scannerView,resultView:this.resultView}};try{if(!this.initializeMRZScannerConfig())return console.error("Failed to initialize mrz scanner config"),{resources:this.resources,components:{}};no("dynamsoft-mrz-loading-screen-style",lo),this.showLoadingOverlay("Loading...");if(!await this.initializeDCVResources())return this.hideLoadingOverlay(!0),console.error("Failed to initialize DCV resources"),{resources:this.resources,components:{}};this.resources.onResultUpdated=t=>{this.resources.result=t};const t={};return this.config.scannerViewConfig&&(this.scannerView=new _o(this.resources,this.config.scannerViewConfig),t.scannerView=this.scannerView,await this.scannerView.initialize()),this.config.resultViewConfig&&(this.resultView=new yo(this.resources,this.config.resultViewConfig,this.scannerView),t.resultView=this.resultView),this.isInitialized=!0,{resources:this.resources,components:t}}catch(t){this.isInitialized=!1;const e=`Initialization Failed: ${(null==t?void 0:t.message)||t}`;return console.error(e),{resources:this.resources,components:{}}}finally{this.hideLoadingOverlay(!0)}}async initializeDCVResources(){var t,e,i;try{return vt.engineResourcePaths=ro(null===(t=this.config)||void 0===t?void 0:t.engineResourcePaths)?Co:this.config.engineResourcePaths,Kt._onAuthMessage=t=>t.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=mrz&deploymenttype=web)"),await Kt.initLicense((null===(e=this.config)||void 0===e?void 0:e.license)||"",{executeNow:!0}),vt.loadWasm(["DLR","DCP"]),_a.loadSpec("MRTD_TD3_PASSPORT"),_a.loadSpec("MRTD_TD1_ID"),_a.loadSpec("MRTD_TD2_ID"),Qs.loadRecognitionData("MRZ"),this.resources.cameraView=await Nn.createInstance(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.cameraEnhancerUIPath),this.resources.cameraEnhancer=await Fs.createInstance(this.resources.cameraView),this.resources.cvRouter=await Fe.createInstance(),!0}catch(t){let e=(null==t?void 0:t.message)||t;if(null==e?void 0:e.toLowerCase().includes("license")){const t="The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.";alert(t),console.error(t)}else{const t=`Resource Initialization Failed: ${e}`;alert(t),console.error(t)}return!1}}shouldCreateDefaultContainer(){var t,e;const i=!this.config.container,n=!((null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container));return i&&n}createDefaultMRZScannerContainer(){const t=document.createElement("div");return t.className="mrz-scanner-main-container",Object.assign(t.style,{height:"100dvh",width:"100%",position:"absolute",left:"0",top:"0",zIndex:"999"}),document.body.append(t),t}checkForTemporaryLicense(t){return!(null==t?void 0:t.length)||(null==t?void 0:t.startsWith("A"))||(null==t?void 0:t.startsWith("L"))||(null==t?void 0:t.startsWith("P"))||(null==t?void 0:t.startsWith("Y"))?"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9":t}validateViewConfigs(){var t,e,i,n,r,s,a,o;if(!this.config.container){if((null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)&&this.config.showResultView&&!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container)){const t="MRZResultView container is required when showResultView is true";return alert(t),console.error(t),!1}if(!(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.container)&&(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container)&&!this.resources.result){const t="Result is needed to create MRZResultView without a scanner view";return alert(t),console.error(t),!1}}try{if(this.config.container&&!io(this.config.container)){const t="Invalid main container reference";return alert(t),console.error(t),!1}if((null===(r=this.config.scannerViewConfig)||void 0===r?void 0:r.container)&&!io(null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.container)){const t="Invalid scanner view container reference";return alert(t),console.error(t),!1}if((null===(a=this.config.resultViewConfig)||void 0===a?void 0:a.container)&&!io(null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)){const t="Invalid result view container reference";return alert(t),console.error(t),!1}}catch(t){const e=`Error accessing container references: ${t.message}`;return alert(e),console.error(e),!1}return!0}showResultView(){var t,e;return!1!==this.config.showResultView&&(this.config.container?!(void 0!==this.config.showResultView||!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container)&&!this.config.container)||!!this.config.showResultView:this.config.showResultView&&!!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container))}initializeMRZScannerConfig(){var t,e,i,n,r,s,a;this.config=null!==(t=this.config)&&void 0!==t?t:{};if(!this.validateViewConfigs())return!1;this.shouldCreateDefaultContainer()?this.config.container=this.createDefaultMRZScannerContainer():this.config.container&&(this.config.container=io(this.config.container));const o=this.config.container?this.createViewContainers(io(this.config.container)):{},l={license:this.checkForTemporaryLicense(this.config.license),utilizedTemplateNames:Object.fromEntries(Object.values(Ka).map((t=>{var e;return[t,(null===(e=this.config.utilizedTemplateNames)||void 0===e?void 0:e[t])||to[t]]}))),templateFilePath:(null===(e=this.config)||void 0===e?void 0:e.templateFilePath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.template.json"},h=Object.assign(Object.assign({},this.config.scannerViewConfig),{container:o[Qa.Scanner]||io(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.container)||null,cameraEnhancerUIPath:(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.cameraEnhancerUIPath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.ui.html",templateFilePath:l.templateFilePath,utilizedTemplateNames:l.utilizedTemplateNames,enableMultiFrameCrossFilter:null===(s=null===(r=this.config.scannerViewConfig)||void 0===r?void 0:r.enableMultiFrameCrossFilter)||void 0===s||s,mrzFormatType:this.config.mrzFormatType}),c=this.showResultView()?Object.assign(Object.assign({},this.config.resultViewConfig),{container:o[Qa.Result]||io(null===(a=this.config.resultViewConfig)||void 0===a?void 0:a.container)||null}):void 0;return Object.assign(this.config,Object.assign(Object.assign({},l),{scannerViewConfig:h,resultViewConfig:c})),!0}createViewContainers(t){t.textContent="";const e=[Qa.Scanner];return this.showResultView()&&e.push(Qa.Result),e.reduce(((e,i)=>{const n=document.createElement("div");return n.className=`mrz-scanner-${i}-view-container`,Object.assign(n.style,{height:"100%",width:"100%",display:"none",position:"relative"}),t.append(n),e[i]=n,e}),{})}dispose(){var t,e;this.resultView&&(this.resultView.dispose(),this.resultView=null),this.scannerView=null,this.resources.cameraEnhancer&&(this.resources.cameraEnhancer.dispose(),this.resources.cameraEnhancer=null),this.resources.cameraView&&(this.resources.cameraView.dispose(),this.resources.cameraView=null),this.resources.cvRouter&&(this.resources.cvRouter.dispose(),this.resources.cvRouter=null),this.resources.result=null,this.resources.onResultUpdated=null;const i=t=>{const e=io(t);e&&(e.style.display="none",e.textContent="")};i(this.config.container),i(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container),i(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container),this.isInitialized=!1}async processUploadedFile(t){var e,i,n,r;try{this.showLoadingOverlay("Processing File...");const{cvRouter:s}=this.resources,a=null===(e=this.config.utilizedTemplateNames)||void 0===e?void 0:e.all,o=await s.getSimplifiedSettings(a);o.roiMeasuredInPercentage=!0,o.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await s.updateSettings(a,o);const l=await s.capture(t,a),h=l.items,c=h.filter((t=>t.type===yt.CRIT_ORIGINAL_IMAGE))[0].imageData;c.toCanvas=()=>F(c),c.toBlob=async()=>await k("image/png",c);const d=null==l?void 0:l.textLineResultItems,u=null==l?void 0:l.parsedResultItems;let f={};if(null==d?void 0:d.length){const t=(null===(i=d[0])||void 0===i?void 0:i.text)||"";f=mo(t,u[0])}const g={status:{code:eo.RS_SUCCESS,message:"Success"},originalImageResult:c,data:f,imageData:!0,_imageData:c};null===(r=(n=this.resources).onResultUpdated)||void 0===r||r.call(n,g)}catch(t){return console.error("Failed to process uploaded file:",t),{status:{code:eo.RS_FAILED,message:`Failed to process image: ${t.message||t}`}}}finally{this.hideLoadingOverlay(!1)}}async launch(t){if(this.isCapturing)throw new Error("Capture session already in progress");try{this.isCapturing=!0;const{components:e}=await this.initialize();if(ro(e))throw new Error("MRZ Scanner initialization failed.");if(this.config.container&&(io(this.config.container).style.display="block"),t&&(e.scannerView=null,await this.processUploadedFile(t)),!e.scannerView&&this.resources.result&&e.resultView)return await e.resultView.launch();if(!e.scannerView&&!this.resources.result)throw new Error("Scanner view is required when no previous result exists");if(e.scannerView){const t=await e.scannerView.launch();if((null==t?void 0:t.status.code)!==eo.RS_SUCCESS)return{status:{code:null==t?void 0:t.status.code,message:(null==t?void 0:t.status.message)||"Failed to capture image"}};if(e.resultView)return await e.resultView.launch()}return this.resources.result}catch(t){return alert((null==t?void 0:t.message)||t),console.error((null==t?void 0:t.message)||t),{status:{code:eo.RS_FAILED,message:(null==t?void 0:t.message)||t}}}finally{this.isCapturing=!1,this.dispose()}}}const So={MRZScanner:Eo,MRZScannerView:_o,MRZResultView:yo};export{Fs as CameraEnhancer,qe as CameraEnhancerModule,Nn as CameraView,Fe as CaptureVisionRouter,pe as CaptureVisionRouterModule,Be as CapturedResultReceiver,ua as CodeParser,_a as CodeParserModule,vt as CoreModule,to as DEFAULT_TEMPLATE_NAMES,bi as DrawingItem,Dn as DrawingStyleManager,So as DynamsoftMRZScanner,s as EnumBufferOverflowProtectionMode,yt as EnumCapturedResultItemType,a as EnumColourChannelUsageType,wt as EnumCornerType,xt as EnumCrossVerificationStatus,ai as EnumDrawingItemMediaType,oi as EnumDrawingItemState,li as EnumEnhancedFeatures,Ct as EnumErrorCode,Et as EnumGrayscaleEnhancementMode,St as EnumGrayscaleTransformationMode,o as EnumImagePixelFormat,ve as EnumImageSourceState,bt as EnumImageTagType,Ot as EnumIntermediateResultUnitType,ho as EnumMRZData,$a as EnumMRZDocumentType,Ka as EnumMRZScanMode,Qa as EnumMRZScannerViews,ia as EnumMappingStatus,Tt as EnumPDFReadingMode,Ve as EnumPresetTemplate,It as EnumRasterDataSource,ea as EnumRawTextLineStatus,At as EnumRegionObjectElementType,eo as EnumResultStatus,Rt as EnumSectionType,na as EnumValidationStatus,Ds as Feedback,Bi as GroupDrawingItem,Di as ImageDrawingItem,Ys as ImageEditorView,ya as ImageManager,K as ImageSourceAdapter,je as IntermediateResultReceiver,Qs as LabelRecognizerModule,Kt as LicenseManager,Qt as LicenseModule,ki as LineDrawingItem,co as MRZDataLabel,yo as MRZResultView,Eo as MRZScanner,_o as MRZScannerView,Ja as MultiFrameResultCrossFilter,Ni as QuadDrawingItem,Ti as RectDrawingItem,Mi as TextDrawingItem,Ia as UtilityModule,N as _getNorImageData,M as _saveToFile,k as _toBlob,F as _toCanvas,P as _toImage,dt as bDebug,R as checkIsLink,D as compareVersion,fo as displayMRZDate,rt as doOrWaitAsyncDependency,ot as getNextTaskID,L as handleEngineResourcePaths,ft as innerVersions,_ as isArc,v as isContour,C as isDSImageData,E as isDSRect,S as isImageTag,b as isLineSegment,p as isObject,w as isOriginalDsImageData,T as isPoint,I as isPolygon,x as isQuad,O as isRect,_t as loadWasm,it as mapAsyncDependency,gt as mapPackageRegister,lt as mapTaskCallBack,ht as onLog,A as requestResource,ut as setBDebug,ct as setOnLog,ta as utilsFuncs,nt as waitAsyncDependency,st as worker,mt as workerAutoResources}; +const t=t=>t&&"object"==typeof t&&"function"==typeof t.then,e=(async()=>{})().constructor;let i=class extends e{get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(i){let n;this._task=i,t(i)?n=i:"function"==typeof i&&(n=new e(i)),n&&(async()=>{try{const t=await n;i===this._task&&this.resolve(t)}catch(t){i===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let i,n;super(((t,e)=>{i=t,n=e})),this._s="pending",this.resolve=e=>{this.isPending&&(t(e)?this.task=e:(this._s="fulfilled",i(e)))},this.reject=t=>{this.isPending&&(this._s="rejected",n(t))},this.task=e}};function n(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 r(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 s,a,o;"function"==typeof SuppressedError&&SuppressedError,function(t){t[t.BOPM_BLOCK=0]="BOPM_BLOCK",t[t.BOPM_UPDATE=1]="BOPM_UPDATE"}(s||(s={})),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"}(a||(a={})),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"}(o||(o={}));const l="undefined"==typeof self,h="function"==typeof importScripts,c=(()=>{if(!h){if(!l&&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"./"}})(),d=t=>{if(null==t&&(t="./"),l||h);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t},u=t=>Object.prototype.toString.call(t),f=t=>Array.isArray?Array.isArray(t):"[object Array]"===u(t),g=t=>"number"==typeof t&&!Number.isNaN(t),m=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),p=t=>!(!m(t)||!g(t.x)||!g(t.y)||!g(t.radius)||t.radius<0||!g(t.startAngle)||!g(t.endAngle)),_=t=>!!m(t)&&!!f(t.points)&&0!=t.points.length&&!t.points.some((t=>!T(t))),v=t=>!(!m(t)||!g(t.width)||t.width<=0||!g(t.height)||t.height<=0||!g(t.stride)||t.stride<=0||!("format"in t)||"tag"in t&&!E(t.tag)),y=t=>!(!v(t)||!g(t.bytes.length)&&!g(t.bytes.ptr)),w=t=>!!v(t)&&t.bytes instanceof Uint8Array,C=t=>!(!m(t)||!g(t.left)||t.left<0||!g(t.top)||t.top<0||!g(t.right)||t.right<0||!g(t.bottom)||t.bottom<0||t.left>=t.right||t.top>=t.bottom),E=t=>null===t||!!m(t)&&!!g(t.imageId)&&"type"in t,S=t=>!(!m(t)||!T(t.startPoint)||!T(t.endPoint)||t.startPoint.x==t.endPoint.x&&t.startPoint.y==t.endPoint.y),T=t=>!!m(t)&&!!g(t.x)&&!!g(t.y),b=t=>!!m(t)&&!!f(t.points)&&0!=t.points.length&&!t.points.some((t=>!T(t))),I=t=>!!m(t)&&!!f(t.points)&&0!=t.points.length&&4==t.points.length&&!t.points.some((t=>!T(t))),x=t=>!(!m(t)||!g(t.x)||!g(t.y)||!g(t.width)||t.width<0||!g(t.height)||t.height<0),R=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))}})),O=t=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(t),A=(t,e)=>{let i=t.split("."),n=e.split(".");for(let t=0;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}${B[n]}@${t[n].version}/${"dcvData"===n?"":"dist/"}${"ddv"===n?"engine":""}`:`${a}${B[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]=d(s)}return e},M=async(t,e,i)=>await new Promise((async(n,r)=>{try{const r=e.split(".");let s=r[r.length-1];const a=await P(`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()}})),L=t=>{w(t)&&(t=k(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},F=(t,e)=>{w(e)&&(e=k(e));const i=L(e);let n=new Image,r=i.toDataURL(t);return n.src=r,n},P=async(t,e)=>{w(e)&&(e=k(e));const i=L(e);return new Promise(((e,n)=>{i.toBlob((t=>e(t)),t)}))},k=t=>{let e,i=t.bytes;if(!(i&&i instanceof Uint8Array))throw Error("Parameter type error");if(Number(t.format)===o.IPF_BGR_888){const t=i.length/3;e=new Uint8ClampedArray(4*t);for(let n=0;n=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)===o.IPF_ABGR_8888){const t=i.length/4;e=new Uint8ClampedArray(i.length);for(let n=0;n=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)},N=async()=>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])),B={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 j,V,U,G,W,Y,H,z;let X,q,Z,K,J,$=class t{get _isFetchingStarted(){return n(this,W,"f")}constructor(){j.add(this),V.set(this,[]),U.set(this,1),G.set(this,s.BOPM_BLOCK),W.set(this,!1),Y.set(this,void 0),H.set(this,a.CCUT_AUTO)}setErrorListener(t){}addImageToBuffer(t){var e;if(!w(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(n(this,V,"f").length>=n(this,U,"f"))switch(n(this,G,"f")){case s.BOPM_BLOCK:break;case s.BOPM_UPDATE:if(n(this,V,"f").push(t),m(n(this,Y,"f"))&&g(n(this,Y,"f").imageId)&&1==n(this,Y,"f").keepInBuffer)for(;n(this,V,"f").length>n(this,U,"f");){const t=n(this,V,"f").findIndex((t=>{var e;return(null===(e=t.tag)||void 0===e?void 0:e.imageId)!==n(this,Y,"f").imageId}));n(this,V,"f").splice(t,1)}else n(this,V,"f").splice(0,n(this,V,"f").length-n(this,U,"f"))}else n(this,V,"f").push(t)}getImage(){if(0===n(this,V,"f").length)return null;let e;if(n(this,Y,"f")&&g(n(this,Y,"f").imageId)){const t=n(this,j,"m",z).call(this,n(this,Y,"f").imageId);if(t<0)throw new Error(`Image with id ${n(this,Y,"f").imageId} doesn't exist.`);e=n(this,V,"f").slice(t,t+1)[0]}else e=n(this,V,"f").pop();if([o.IPF_RGB_565,o.IPF_RGB_555,o.IPF_RGB_888,o.IPF_ARGB_8888,o.IPF_RGB_161616,o.IPF_ARGB_16161616,o.IPF_ABGR_8888,o.IPF_ABGR_16161616,o.IPF_BGR_888].includes(e.format)){if(n(this,H,"f")===a.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;t0!==t.length&&t.every((t=>g(t))))(t))throw new TypeError("Invalid 'imageId'.");if(void 0!==e&&"[object Boolean]"!==u(e))throw new TypeError("Invalid 'keepInBuffer'.");r(this,Y,{imageId:t,keepInBuffer:e})}_resetNextReturnedImage(){r(this,Y,null)}hasImage(t){return n(this,j,"m",z).call(this,t)>=0}startFetching(){r(this,W,!0)}stopFetching(){r(this,W,!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(r(this,U,t);n(this,V,"f")&&n(this,V,"f").length>t;)n(this,V,"f").shift()}getMaxImageCount(){return n(this,U,"f")}getImageCount(){return n(this,V,"f").length}clearBuffer(){n(this,V,"f").length=0}isBufferEmpty(){return 0===n(this,V,"f").length}setBufferOverflowProtectionMode(t){r(this,G,t)}getBufferOverflowProtectionMode(){return n(this,G,"f")}setColourChannelUsageType(t){r(this,H,t)}getColourChannelUsageType(){return n(this,H,"f")}};V=new WeakMap,U=new WeakMap,G=new WeakMap,W=new WeakMap,Y=new WeakMap,H=new WeakMap,j=new WeakSet,z=function(t){if("number"!=typeof t)throw new TypeError("Invalid 'imageId'.");return n(this,V,"f").findIndex((e=>{var i;return(null===(i=e.tag)||void 0===i?void 0:i.imageId)===t}))},"undefined"!=typeof navigator&&(X=navigator,q=X.userAgent,Z=X.platform,K=X.mediaDevices),function(){if(!l){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:X.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:Z,search:"Win"},Mac:{str:Z},Linux:{str:Z}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||q,a=r.search||e,o=r.verStr||q,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||q,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=q.indexOf("Windows NT")&&(r="HarmonyOS"),J={browser:i,version:n,OS:r}}l&&(J={browser:"ssr",version:0,OS:"ssr"})}();const Q="undefined"!=typeof WebAssembly&&q&&!(/Safari/.test(q)&&!/Chrome/.test(q)&&/\(.+\s11_2_([2-6]).*\)/.test(q)),tt=!("undefined"==typeof Worker),et=!(!K||!K.getUserMedia),it=async()=>{let t=!1;if(et)try{(await K.getUserMedia({video:!0})).getTracks().forEach((t=>{t.stop()})),t=!0}catch(t){}return t};var nt,rt,st,at,ot,lt,ht,ct,dt;"Chrome"===J.browser&&J.version>66||"Safari"===J.browser&&J.version>13||"OPR"===J.browser&&J.version>43||"Edge"===J.browser&&J.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"}(nt||(nt={})),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"}(rt||(rt={})),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"}(st||(st={})),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"}(at||(at={})),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"}(ot||(ot={})),function(t){t[t.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",t[t.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(lt||(lt={})),function(t){t[t.PDFRM_VECTOR=1]="PDFRM_VECTOR",t[t.PDFRM_RASTER=2]="PDFRM_RASTER",t[t.PDFRM_REV=-2147483648]="PDFRM_REV"}(ht||(ht={})),function(t){t[t.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",t[t.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(ct||(ct={})),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"}(dt||(dt={}));const ut={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 ft,gt,mt,pt,_t,vt;!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"}(ft||(ft={})),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"}(gt||(gt={})),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"}(mt||(mt={})),function(t){t[t.ICDM_NEAR=0]="ICDM_NEAR",t[t.ICDM_FAR=1]="ICDM_FAR"}(pt||(pt={})),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"}(_t||(_t={})),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"}(vt||(vt={}));const yt={},wt=async t=>{let e="string"==typeof t?[t]:t,n=[];for(let t of e)n.push(yt[t]=yt[t]||new i);await Promise.all(n)},Ct=async(t,e)=>{let n,r="string"==typeof t?[t]:t,s=[];for(let t of r){let r;s.push(r=yt[t]=yt[t]||new i(n=n||e())),r.isEmpty&&(r.task=n=n||e())}await Promise.all(s)};let Et,St=0;const Tt=()=>St++,bt={};let It;const xt=t=>{It=t,Et&&Et.postMessage({type:"setBLog",body:{value:!!t}})};let Rt=!1;const Ot=t=>{Rt=t,Et&&Et.postMessage({type:"setBDebug",body:{value:!!t}})},At={},Dt={},Mt={dip:{wasm:!0}},Lt={std:{version:"2.0.0",path:d(c+"../../dynamsoft-capture-vision-std@2.0.0/dist/"),isInternal:!0},core:{version:"4.0.30-dev-20250604160028",path:c,isInternal:!0}};class Ft{static get engineResourcePaths(){return Lt}static set engineResourcePaths(t){Object.assign(Lt,t)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _onLog(){return It}static set _onLog(t){xt(t)}static get _bDebug(){return Rt}static set _bDebug(t){Ot(t)}static isModuleLoaded(t){return t=(t=t||"core").toLowerCase(),!!yt[t]&&yt[t].isFulfilled}static async loadWasm(){return await(async()=>{let t,e;t instanceof Array||(t=t?[t]:[]);let n=yt.core;e=!n||n.isEmpty,e||await wt("core");let r=new Map;const s=t=>{if(t=t.toLowerCase(),_t.MN_DYNAMSOFT_CAPTURE_VISION_STD==t||_t.MN_DYNAMSOFT_CORE==t)return;let e=Mt[t].deps;if(null==e?void 0:e.length)for(let t of e)s(t);let i=yt[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 Ct(a,(async()=>{const t=[...r.entries()].filter((t=>t[1])).map((t=>t[0]));await wt(o);const n=D(Lt),s={};for(let e of t)s[e]=Mt[e];const a={engineResourcePaths:n,autoResources:s,names:t,_bundleEnv:Ft._bundleEnv,_useSimd:Ft._useSimd};let l=new i;if(e){a.needLoadCore=!0;let t=n[`${Ft._bundleEnv.toLowerCase()}Bundle`]+Ft._workerName;t.startsWith(location.origin)||(t=await fetch(t).then((t=>t.blob())).then((t=>URL.createObjectURL(t)))),Et=new Worker(t),Et.onerror=t=>{let e=new Error(t.message);l.reject(e)},Et.addEventListener("message",(t=>{let e=t.data?t.data:t,i=e.type,n=e.id,r=e.body;switch(i){case"log":It&&It(e.message);break;case"task":try{bt[n](r),delete bt[n]}catch(t){throw delete bt[n],t}break;case"event":try{bt[n](r)}catch(t){throw t}break;default:console.log(t)}})),a.bLog=!!It,a.bd=Rt,a.dm=location.origin.startsWith("http")?location.origin:"https://localhost"}else await wt("core");let h=St++;bt[h]=t=>{if(t.success)Object.assign(At,t.versions),"{}"!==JSON.stringify(t.versions)&&(Ft._versions=t.versions),l.resolve(void 0);else{const e=Error(t.message);t.stack&&(e.stack=t.stack),l.reject(e)}},Et.postMessage({type:"loadWasm",id:h,body:a}),await l}))})()}static async detectEnvironment(){return await(async()=>({wasm:Q,worker:tt,getUserMedia:et,camera:await it(),browser:J.browser,version:J.version,OS:J.OS}))()}static async getModuleVersion(){return await new Promise(((t,e)=>{let i=Tt();bt[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)}},Et.postMessage({type:"getModuleVersion",id:i})}))}static getVersion(){return`4.0.30-dev-20250604160028(Worker: ${At.core&&At.core.worker||"Not Loaded"}, Wasm: ${At.core&&At.core.wasm||"Not Loaded"})`}static enableLogging(){$._onLog=console.log,Ft._onLog=console.log}static disableLogging(){$._onLog=null,Ft._onLog=null}static async cfd(t){return await new Promise(((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},Et.postMessage({type:"cfd",id:n,body:{count:t}})}))}}Ft._bSupportDce4Module=-1,Ft._bSupportIRTModule=-1,Ft._versions=null,Ft._bundleEnv="DCV",Ft._workerName="dcv.bundle.worker.js",Ft._useSimd=!0,Ft.browserInfo=J;const Pt="undefined"==typeof self,kt="function"==typeof importScripts,Nt=(()=>{if(!kt){if(!Pt&&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 Bt(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 jt(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 Vt=t=>t&&"object"==typeof t&&"function"==typeof t.then,Ut=(async()=>{})().constructor;class Gt extends Ut{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,Vt(t)?e=t:"function"==typeof t&&(e=new Ut(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&&(Vt(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}}class Wt{constructor(t){this._cvr=t}async getMaxBufferedItems(){return await new Promise(((t,e)=>{let i=Tt();bt[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)}},Et.postMessage({type:"cvr_getMaxBufferedItems",id:i,instanceID:this._cvr._instanceID})}))}async setMaxBufferedItems(t){return await new Promise(((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},Et.postMessage({type:"cvr_setMaxBufferedItems",id:n,instanceID:this._cvr._instanceID,body:{count:t}})}))}async getBufferedCharacterItemSet(){return await new Promise(((t,e)=>{let i=Tt();bt[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)}},Et.postMessage({type:"cvr_getBufferedCharacterItemSet",id:i,instanceID:this._cvr._instanceID})}))}}var Yt={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 Ht=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 zt{constructor(t){this._irrRegistryState=Yt,this._intermediateResultReceiverSet=new Set,this._cvr=t}async addResultReceiver(t){if("object"!=typeof t)throw new Error("Invalid receiver.");this._intermediateResultReceiverSet.add(t),Ht(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=Tt();bt[r]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,n(t)}},Et.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),Ht(this),await new Promise(((t,e)=>{let i=Tt();bt[i]=async i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},Et.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})}))}getOriginalImage(){return this._cvr._dsImage}}const Xt="undefined"==typeof self,qt="function"==typeof importScripts,Zt=(()=>{if(!qt){if(!Xt&&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"./"}})(),Kt=t=>{if(null==t&&(t="./"),Xt||qt);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};var Jt;Ft.engineResourcePaths.cvr={version:"3.0.30-dev-20250609101939",path:Zt,isInternal:!0},Mt.cvr={js:!0,wasm:!0,deps:[_t.MN_DYNAMSOFT_LICENSE,_t.MN_DYNAMSOFT_IMAGE_PROCESSING,_t.MN_DYNAMSOFT_NEURAL_NETWORK]},Mt.dnn={wasm:!0,deps:[_t.MN_DYNAMSOFT_IMAGE_PROCESSING]},Dt.cvr={};const $t="2.0.0";"string"!=typeof Ft.engineResourcePaths.std&&A(Ft.engineResourcePaths.std.version,$t)<0&&(Ft.engineResourcePaths.std={version:$t,path:Kt(Zt+`../../dynamsoft-capture-vision-std@${$t}/dist/`),isInternal:!0});const Qt="3.0.10";(!Ft.engineResourcePaths.dip||"string"!=typeof Ft.engineResourcePaths.dip&&A(Ft.engineResourcePaths.dip.version,Qt)<0)&&(Ft.engineResourcePaths.dip={version:Qt,path:Kt(Zt+`../../dynamsoft-image-processing@${Qt}/dist/`),isInternal:!0});const te="2.0.10";(!Ft.engineResourcePaths.dnn||"string"!=typeof Ft.engineResourcePaths.dnn&&A(Ft.engineResourcePaths.dnn.version,te)<0)&&(Ft.engineResourcePaths.dnn={version:te,path:Kt(Zt+`../../dynamsoft-capture-vision-dnn@${te}/dist/`),isInternal:!0});class ee{static getVersion(){return this._version}}var ie,ne,re,se,ae,oe,le,he,ce,de,ue,fe,ge,me,pe,_e,ve,ye,we,Ce,Ee,Se;function Te(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;Te(t.referencedItem,e)}}function be(t){if(t.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}function Ie(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)}ee._version=`3.0.30-dev-20250609101939(Worker: ${null===(Jt=At.cvr)||void 0===Jt?void 0:Jt.worker}, Wasm: loading...`,function(t){t[t.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",t[t.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}(ie||(ie={}));const xe={onTaskResultsReceived:()=>{},isFilter:!0};bt[-2]=async t=>{Re.onDataLoadProgressChanged&&Re.onDataLoadProgressChanged(t.resourcesPath,t.tag,{loaded:t.loaded,total:t.total})};class Re{constructor(){ne.add(this),this.maxImageSideLength=["iPhone","Android","HarmonyOS"].includes(Ft.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,re.set(this,null),se.set(this,null),ae.set(this,null),oe.set(this,null),le.set(this,null),he.set(this,new Set),ce.set(this,new Set),de.set(this,new Set),ue.set(this,0),fe.set(this,!1),ge.set(this,!1),me.set(this,!1),pe.set(this,null),_e.set(this,null),this._singleFrameModeCallbackBind=this._singleFrameModeCallback.bind(this)}get disposed(){return Bt(this,me,"f")}static async createInstance(t=!0){if(!Dt.license)throw Error("The `license` module cannot be found.");await Dt.license.dynamsoft(),await Ft.loadWasm();const e=new Re,i=new Gt;let n=Tt();return bt[n]=async t=>{t.success?(e._instanceID=t.instanceID,e._currentSettings=JSON.parse(JSON.parse(t.outputSettings).data),ee._version=`3.0.30-dev-20250609101939(Worker: ${At.cvr.worker}, Wasm: ${t.version})`,jt(e,ge,!0),jt(e,oe,e.getIntermediateResultManager()),jt(e,ge,!1),i.resolve(e)):Ie({message:t.message,rj:i.reject,stack:t.stack})},Et.postMessage({type:"cvr_createInstance",id:n,body:{loadPresetTemplates:t}}),i}static async appendModelBuffer(t,e){return await Ft.loadWasm(),await new Promise(((i,n)=>{let r=Tt();const s=D(Ft.engineResourcePaths);bt[r]=async t=>{if(t.success){const e=JSON.parse(t.response);return 0!==e.errorCode&&Ie({message:e.errorString?e.errorString:"Append Model Buffer Failed.",rj:n,errorCode:e.errorCode}),i(e)}Ie({message:t.message,rj:n,stack:t.stack})},Et.postMessage({type:"cvr_appendModelBuffer",id:r,body:{modelName:t,path:e||s.dcvData+"models/"}})}))}async _singleFrameModeCallback(t){for(let e of Bt(this,he,"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 Bt(this,he,"f"))t.isDce?t.onCapturedResultReceived(i,{isDetectVerifyOpen:!1,isNormalizeVerifyOpen:!1,isBarcodeVerifyOpen:!1,isLabelVerifyOpen:!1}):Bt(this,ne,"m",ye).call(this,t,i)}setInput(t){if(be(this),!t)return Bt(this,pe,"f")&&(Bt(this,oe,"f").removeResultReceiver(Bt(this,pe,"f")),jt(this,pe,null)),Bt(this,_e,"f")&&(Bt(this,he,"f").delete(Bt(this,_e,"f")),jt(this,_e,null)),void jt(this,re,null);if(jt(this,re,t),t.isCameraEnhancer){Bt(this,oe,"f")&&(Bt(this,re,"f")._intermediateResultReceiver.isDce=!0,Bt(this,oe,"f").addResultReceiver(Bt(this,re,"f")._intermediateResultReceiver),jt(this,pe,Bt(this,re,"f")._intermediateResultReceiver));const t=Bt(this,re,"f").getCameraView();if(t){const e=t._capturedResultReceiver;e.isDce=!0,Bt(this,he,"f").add(e),jt(this,_e,e)}}}getInput(){return Bt(this,re,"f")}addImageSourceStateListener(t){if(be(this),"object"!=typeof t)return console.warn("Invalid ISA state listener.");t&&Object.keys(t)&&Bt(this,ce,"f").add(t)}removeImageSourceStateListener(t){return be(this),Bt(this,ce,"f").delete(t)}addResultReceiver(t){if(be(this),"object"!=typeof t)throw new Error("Invalid receiver.");t&&Object.keys(t).length&&(Bt(this,he,"f").add(t),this._setCrrRegistry())}removeResultReceiver(t){be(this),Bt(this,he,"f").delete(t),this._setCrrRegistry()}async _setCrrRegistry(){const t={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onProcessedDocumentResultReceived:!1,onParsedResultsReceived:!1};for(let e of Bt(this,he,"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 Gt;let i=Tt();return bt[i]=async t=>{t.success?e.resolve():Ie({message:t.message,rj:e.reject,stack:t.stack})},Et.postMessage({type:"cvr_setCrrRegistry",id:i,instanceID:this._instanceID,body:{receiver:JSON.stringify(t)}}),e}async addResultFilter(t){if(be(this),!t||"object"!=typeof t||!Object.keys(t).length)return console.warn("Invalid filter.");Bt(this,de,"f").add(t),t._dynamsoft(),await this._handleFilterUpdate()}async removeResultFilter(t){be(this),Bt(this,de,"f").delete(t),await this._handleFilterUpdate()}async _handleFilterUpdate(){if(Bt(this,oe,"f").removeResultReceiver(xe),0===Bt(this,de,"f").size){this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1;const t={[nt.CRIT_BARCODE]:!1,[nt.CRIT_TEXT_LINE]:!1,[nt.CRIT_DETECTED_QUAD]:!1,[nt.CRIT_DESKEWED_IMAGE]:!1},e={[nt.CRIT_BARCODE]:!1,[nt.CRIT_TEXT_LINE]:!1,[nt.CRIT_DETECTED_QUAD]:!1,[nt.CRIT_DESKEWED_IMAGE]:!1};return await Bt(this,ne,"m",we).call(this,t),void await Bt(this,ne,"m",Ce).call(this,e)}for(let t of Bt(this,de,"f"))this._isOpenBarcodeVerify=t.isResultCrossVerificationEnabled(nt.CRIT_BARCODE),this._isOpenLabelVerify=t.isResultCrossVerificationEnabled(nt.CRIT_TEXT_LINE),this._isOpenDetectVerify=t.isResultCrossVerificationEnabled(nt.CRIT_DETECTED_QUAD),this._isOpenNormalizeVerify=t.isResultCrossVerificationEnabled(nt.CRIT_DESKEWED_IMAGE),t.isLatestOverlappingEnabled(nt.CRIT_BARCODE)&&([...Bt(this,oe,"f")._intermediateResultReceiverSet.values()].find((t=>t.isFilter))||Bt(this,oe,"f").addResultReceiver(xe)),await Bt(this,ne,"m",we).call(this,t.verificationEnabled),await Bt(this,ne,"m",Ce).call(this,t.duplicateFilterEnabled),await Bt(this,ne,"m",Ee).call(this,t.duplicateForgetTime)}async startCapturing(t){if(be(this),!this._isPauseScan)return;if(!Bt(this,re,"f"))throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");t||(t=Re._defaultTemplate);const e=await this.containsTask(t);for(let t of Bt(this,de,"f"))await this.addResultFilter(t);const i=D(Ft.engineResourcePaths);return Bt(this,re,"f").isCameraEnhancer&&(e.includes("ddn")?Bt(this,re,"f").setPixelFormat(o.IPF_ABGR_8888):Bt(this,re,"f").setPixelFormat(o.IPF_GRAYSCALED)),void 0!==Bt(this,re,"f").singleFrameMode&&"disabled"!==Bt(this,re,"f").singleFrameMode?(this._templateName=t,void Bt(this,re,"f").on("singleFrameAcquired",this._singleFrameModeCallbackBind)):(Bt(this,re,"f").getColourChannelUsageType()===a.CCUT_AUTO&&Bt(this,re,"f").setColourChannelUsageType(e.includes("ddn")?a.CCUT_FULL_CHANNEL:a.CCUT_Y_CHANNEL_ONLY),Bt(this,ae,"f")&&Bt(this,ae,"f").isPending?Bt(this,ae,"f"):(jt(this,ae,new Gt(((e,n)=>{if(this.disposed)return;let r=Tt();bt[r]=async i=>{Bt(this,ae,"f")&&!Bt(this,ae,"f").isFulfilled&&(i.success?(this._isPauseScan=!1,this._isOutputOriginalImage=i.isOutputOriginalImage,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((async()=>{-1!==this._minImageCaptureInterval&&Bt(this,re,"f").startFetching(),this._loopReadVideo(t),e()}),0)):Ie({message:i.message,rj:n,stack:i.stack}))},Et.postMessage({type:"cvr_startCapturing",id:r,instanceID:this._instanceID,body:{templateName:t,engineResourcePaths:i}})}))),await Bt(this,ae,"f")))}stopCapturing(){be(this),Bt(this,re,"f")&&(Bt(this,re,"f").isCameraEnhancer&&void 0!==Bt(this,re,"f").singleFrameMode&&"disabled"!==Bt(this,re,"f").singleFrameMode?Bt(this,re,"f").off("singleFrameAcquired",this._singleFrameModeCallbackBind):(Bt(this,ne,"m",Se).call(this),Bt(this,re,"f").stopFetching(),this._averageProcessintTimeArray=[],this._averageTime=999,this._isPauseScan=!0,jt(this,ae,null),Bt(this,re,"f").setColourChannelUsageType(a.CCUT_AUTO)))}async containsTask(t){return be(this),await new Promise(((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success)return e(JSON.parse(t.tasks));Ie({message:t.message,rj:i,stack:t.stack})},Et.postMessage({type:"cvr_containsTask",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async _loopReadVideo(t){if(this.disposed||this._isPauseScan)return;if(jt(this,fe,!0),Bt(this,re,"f").isBufferEmpty())if(Bt(this,re,"f").hasNextImageToFetch())for(let t of Bt(this,ce,"f"))t.onImageSourceStateReceived&&t.onImageSourceStateReceived(ie.ISS_BUFFER_EMPTY);else if(!Bt(this,re,"f").hasNextImageToFetch())for(let t of Bt(this,ce,"f"))t.onImageSourceStateReceived&&t.onImageSourceStateReceived(ie.ISS_EXHAUSTED);if(-1===this._minImageCaptureInterval||Bt(this,re,"f").isBufferEmpty()&&Bt(this,re,"f").isCameraEnhancer)try{Bt(this,re,"f").isBufferEmpty()&&Re._onLog&&Re._onLog("buffer is empty so fetch image"),Re._onLog&&Re._onLog(`DCE: start fetching a frame: ${Date.now()}`),this._dsImage=Bt(this,re,"f").fetchImage(),Re._onLog&&Re._onLog(`DCE: finish fetching a frame: ${Date.now()}`),Bt(this,re,"f").setImageFetchInterval(this._averageTime)}catch(e){return void this._reRunCurrnetFunc(t)}else if(Bt(this,re,"f").isCameraEnhancer&&Bt(this,re,"f").setImageFetchInterval(this._averageTime-(this._dsImage&&this._dsImage.tag?this._dsImage.tag.timeSpent:0)),this._dsImage=Bt(this,re,"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 Bt(this,he,"f"))this._isOutputOriginalImage&&t.onOriginalImageResultReceived&&t.onOriginalImageResultReceived({imageData:this._dsImage});const e=Date.now();this._captureDsimage(this._dsImage,t).then((async i=>{Re._onLog&&Re._onLog("no js handle time: "+(Date.now()-e)),i.originalImageTag=this._dsImage.tag?this._dsImage.tag:null;for(let t of Bt(this,he,"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}),Re._onLog){const t=Date.now()-e;t>10&&Re._onLog(`draw result time: ${t}`)}}else{for(let t of Bt(this,de,"f"))t.onDecodedBarcodesReceived(i),t.onRecognizedTextLinesReceived(i),t.onProcessedDocumentResultReceived(i);Bt(this,ne,"m",ye).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,Re._onLog&&(Re._onLog(`minImageCaptureInterval: ${this._minImageCaptureInterval}`),Re._onLog(`averageProcessintTimeArray: ${this._averageProcessintTimeArray}`),Re._onLog(`averageFetchImageTimeArray: ${this._averageFetchImageTimeArray}`),Re._onLog(`averageTime: ${this._averageTime}`))),Re._onLog){const t=Date.now()-n;t>10&&Re._onLog(`fetch image calculate time: ${t}`)}Re._onLog&&Re._onLog(`time finish decode: ${Date.now()}`),Re._onLog&&Re._onLog("main time: "+(Date.now()-e)),Re._onLog&&Re._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=>{Bt(this,re,"f").stopFetching(),"platform error"!==e.message&&(e.errorCode&&0===e.errorCode&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{Bt(this,re,"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(be(this),e||(e=Re._defaultTemplate),jt(this,fe,!1),w(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 R(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?(jt(this,ue,this.maxImageSideLength/a),i=Math.round(r*Bt(this,ue,"f")),n=Math.round(s*Bt(this,ue,"f"))):(i=r,n=s),Bt(this,se,"f")||jt(this,se,document.createElement("canvas"));const o=Bt(this,se,"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:10};return await this._captureInWorker(n,e)}async _captureVideo(t,e){if(t.crossOrigin&&"anonymous"!=t.crossOrigin)throw"cors";let i,n,r=t.videoWidth,s=t.videoHeight,a=Math.max(r,s);a>this.maxImageSideLength?(jt(this,ue,this.maxImageSideLength/a),i=Math.round(r*Bt(this,ue,"f")),n=Math.round(s*Bt(this,ue,"f"))):(i=r,n=s),Bt(this,se,"f")||jt(this,se,document.createElement("canvas"));const o=Bt(this,se,"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),await this._captureCanvas(o,e)}async _captureInWorker(t,e){const{bytes:i,width:n,height:r,stride:s,format:a}=t;let o=Tt();const l=D(Ft.engineResourcePaths),h=new Gt;return bt[o]=async e=>{if(e.success){const i=Date.now();Re._onLog&&(Re._onLog(`get result time from worker: ${i}`),Re._onLog("worker to main time consume: "+(i-e.workerReturnMsgTime)));try{const i=e.captureResult;0!==i.errorCode&&Ie({message:i.errorString,errorCode:i.errorCode,rj:h.reject}),t.bytes=e.bytes;for(let e of i.items)0!==Bt(this,ue,"f")&&Te(e,Bt(this,ue,"f")),e.type===nt.CRIT_ORIGINAL_IMAGE?e.imageData=t:[nt.CRIT_DESKEWED_IMAGE,nt.CRIT_ENHANCED_IMAGE].includes(e.type)?Dt.ddn&&Dt.ddn.handleDeskewedAndEnhancedImageResultItem(e):e.type===nt.CRIT_PARSED_RESULT&&Dt.dcp&&Dt.dcp.handleParsedResultItem(e);const n=i.processedDocumentResult;if(n){if(n.deskewedImageResultItems)for(let t=0;t{let n=Tt();bt[n]=async n=>{if(n.success){const r=JSON.parse(n.response);0!==r.errorCode&&Ie({message:r.errorString?r.errorString:"Init Settings Failed.",rj:i,errorCode:r.errorCode});const s=JSON.parse(t);return this._currentSettings=s,this._isOutputOriginalImage=1===this._currentSettings.CaptureVisionTemplates[0].OutputOriginalImage,Re._defaultTemplate=this._currentSettings.CaptureVisionTemplates[0].Name,e(r)}Ie({message:n.message,rj:i,stack:n.stack})},Et.postMessage({type:"cvr_initSettings",id:n,instanceID:this._instanceID,body:{settings:t}})}))):console.error("Invalid template.")}async outputSettings(t,e){return be(this),await new Promise(((i,n)=>{let r=Tt();bt[r]=async t=>{if(t.success){const e=JSON.parse(t.response);return 0!==e.errorCode&&Ie({message:e.errorString,rj:n,errorCode:e.errorCode}),i(JSON.parse(e.data))}Ie({message:t.message,rj:n,stack:t.stack})},Et.postMessage({type:"cvr_outputSettings",id:r,instanceID:this._instanceID,body:{templateName:t||"*",includeDefaultValues:!!e}})}))}async outputSettingsToFile(t,e,i,n){const r=await this.outputSettings(t,n),s=new Blob([JSON.stringify(r,null,2,(function(t,e){return e instanceof Array?JSON.stringify(e):e}),2)],{type:"application/json"});if(i){const t=document.createElement("a");t.href=URL.createObjectURL(s),e.endsWith(".json")&&(e=e.replace(".json","")),t.download=`${e}.json`,t.onclick=()=>{setTimeout((()=>{URL.revokeObjectURL(t.href)}),500)},t.click()}return s}async getTemplateNames(){return be(this),await new Promise(((t,e)=>{let i=Tt();bt[i]=async i=>{if(i.success){const n=JSON.parse(i.response);return 0!==n.errorCode&&Ie({message:n.errorString,rj:e,errorCode:n.errorCode}),t(JSON.parse(n.data))}Ie({message:i.message,rj:e,stack:i.stack})},Et.postMessage({type:"cvr_getTemplateNames",id:i,instanceID:this._instanceID})}))}async getSimplifiedSettings(t){return be(this),t||(t=this._currentSettings.CaptureVisionTemplates[0].Name),await new Promise(((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success){const n=JSON.parse(t.response);0!==n.errorCode&&Ie({message:n.errorString,rj:i,errorCode:n.errorCode});const r=JSON.parse(n.data,((t,e)=>"barcodeFormatIds"===t?BigInt(e):e));return r.minImageCaptureInterval=this._minImageCaptureInterval,e(r)}Ie({message:t.message,rj:i,stack:t.stack})},Et.postMessage({type:"cvr_getSimplifiedSettings",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async updateSettings(t,e){return be(this),t||(t=this._currentSettings.CaptureVisionTemplates[0].Name),await new Promise(((i,n)=>{let r=Tt();bt[r]=async t=>{if(t.success){const r=JSON.parse(t.response);return e.minImageCaptureInterval&&e.minImageCaptureInterval>=-1&&(this._minImageCaptureInterval=e.minImageCaptureInterval),this._isOutputOriginalImage=t.isOutputOriginalImage,0!==r.errorCode&&Ie({message:r.errorString?r.errorString:"Update Settings Failed.",rj:n,errorCode:r.errorCode}),this._currentSettings=await this.outputSettings("*"),i(r)}Ie({message:t.message,rj:n,stack:t.stack})},Et.postMessage({type:"cvr_updateSettings",id:r,instanceID:this._instanceID,body:{settings:e,templateName:t}})}))}async resetSettings(){return be(this),await new Promise(((t,e)=>{let i=Tt();bt[i]=async i=>{if(i.success){const n=JSON.parse(i.response);return 0!==n.errorCode&&Ie({message:n.errorString?n.errorString:"Reset Settings Failed.",rj:e,errorCode:n.errorCode}),this._currentSettings=await this.outputSettings("*"),t(n)}Ie({message:i.message,rj:e,stack:i.stack})},Et.postMessage({type:"cvr_resetSettings",id:i,instanceID:this._instanceID})}))}getBufferedItemsManager(){return Bt(this,le,"f")||jt(this,le,new Wt(this)),Bt(this,le,"f")}getIntermediateResultManager(){if(be(this),!Bt(this,ge,"f")&&0!==Ft.bSupportIRTModule)throw new Error("The current license does not support the use of intermediate results.");return Bt(this,oe,"f")||jt(this,oe,new zt(this)),Bt(this,oe,"f")}async parseRequiredResources(t){return be(this),await new Promise(((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success)return e(JSON.parse(t.resources));Ie({message:t.message,rj:i,stack:t.stack})},Et.postMessage({type:"cvr_parseRequiredResources",id:n,instanceID:this._instanceID,body:{templateName:t}})}))}async dispose(){be(this),Bt(this,ae,"f")&&this.stopCapturing(),jt(this,re,null),Bt(this,he,"f").clear(),Bt(this,ce,"f").clear(),Bt(this,de,"f").clear(),Bt(this,oe,"f")._intermediateResultReceiverSet.clear(),jt(this,me,!0);let t=Tt();bt[t]=t=>{t.success||Ie({message:t.message,stack:t.stack,isShouleThrow:!0})},Et.postMessage({type:"cvr_dispose",id:t,instanceID:this._instanceID})}_getInternalData(){return{isa:Bt(this,re,"f"),promiseStartScan:Bt(this,ae,"f"),intermediateResultManager:Bt(this,oe,"f"),bufferdItemsManager:Bt(this,le,"f"),resultReceiverSet:Bt(this,he,"f"),isaStateListenerSet:Bt(this,ce,"f"),resultFilterSet:Bt(this,de,"f"),compressRate:Bt(this,ue,"f"),canvas:Bt(this,se,"f"),isScanner:Bt(this,fe,"f"),innerUseTag:Bt(this,ge,"f"),isDestroyed:Bt(this,me,"f")}}async _getWasmFilterState(){return await new Promise(((t,e)=>{let i=Tt();bt[i]=async i=>{if(i.success){const e=JSON.parse(i.response);return t(e)}Ie({message:i.message,rj:e,stack:i.stack})},Et.postMessage({type:"cvr_getWasmFilterState",id:i,instanceID:this._instanceID})}))}}re=new WeakMap,se=new WeakMap,ae=new WeakMap,oe=new WeakMap,le=new WeakMap,he=new WeakMap,ce=new WeakMap,de=new WeakMap,ue=new WeakMap,fe=new WeakMap,ge=new WeakMap,me=new WeakMap,pe=new WeakMap,_e=new WeakMap,ne=new WeakSet,ve=function(t,e){const i=t.intermediateResult;if(i){let t=0;for(let n of Bt(this,oe,"f")._intermediateResultReceiverSet){t++;for(let r of i){if(["onTaskResultsReceived","onTargetROIResultsReceived"].includes(r.info.callbackName)){for(let t of r.intermediateResultUnits)t.originalImageTag=e.tag?e.tag:null;n[r.info.callbackName]&&n[r.info.callbackName]({intermediateResultUnits:r.intermediateResultUnits},r.info)}else n[r.info.callbackName]&&n[r.info.callbackName](r.result,r.info);t===Bt(this,oe,"f")._intermediateResultReceiverSet.size&&delete r.info.callbackName}}}t&&t.hasOwnProperty("intermediateResult")&&delete t.intermediateResult},ye=function(t,e){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)},we=async function(t){return be(this),await new Promise(((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success)return e(t.result);Ie({message:t.message,rj:i,stack:t.stack})},Et.postMessage({type:"cvr_enableResultCrossVerification",id:n,instanceID:this._instanceID,body:{verificationEnabled:t}})}))},Ce=async function(t){return be(this),await new Promise(((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success)return e(t.result);Ie({message:t.message,rj:i,stack:t.stack})},Et.postMessage({type:"cvr_enableResultDeduplication",id:n,instanceID:this._instanceID,body:{duplicateFilterEnabled:t}})}))},Ee=async function(t){return be(this),await new Promise(((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success)return e(t.result);Ie({message:t.message,rj:i,stack:t.stack})},Et.postMessage({type:"cvr_setDuplicateForgetTime",id:n,instanceID:this._instanceID,body:{duplicateForgetTime:t}})}))},Se=async function(){let t=Tt();const e=new Gt;return bt[t]=async t=>{if(t.success)return e.resolve();Ie({message:t.message,rj:e.reject,stack:t.stack})},Et.postMessage({type:"cvr_clearVerifyList",id:t,instanceID:this._instanceID}),e},Re._defaultTemplate="Default";class Oe{constructor(){this.onCapturedResultReceived=null,this.onOriginalImageResultReceived=null}}class Ae{constructor(){this._observedResultUnitTypes=ut.IRUT_ALL,this._observedTaskMap=new Map,this._parameters={setObservedResultUnitTypes:t=>{this._observedResultUnitTypes=t},getObservedResultUnitTypes:()=>this._observedResultUnitTypes,isResultUnitTypeObserved:t=>!!(t&this._observedResultUnitTypes),addObservedTask:t=>{this._observedTaskMap.set(t,!0)},removeObservedTask:t=>{this._observedTaskMap.set(t,!1)},isTaskObserved:t=>0===this._observedTaskMap.size||!!this._observedTaskMap.get(t)},this.onTaskResultsReceived=null,this.onPredetectedRegionsReceived=null,this.onColourImageUnitReceived=null,this.onScaledColourImageUnitReceived=null,this.onGrayscaleImageUnitReceived=null,this.onTransformedGrayscaleImageUnitReceived=null,this.onEnhancedGrayscaleImageUnitReceived=null,this.onBinaryImageUnitReceived=null,this.onTextureDetectionResultUnitReceived=null,this.onTextureRemovedGrayscaleImageUnitReceived=null,this.onTextureRemovedBinaryImageUnitReceived=null,this.onContoursUnitReceived=null,this.onLineSegmentsUnitReceived=null,this.onTextZonesUnitReceived=null,this.onTextRemovedBinaryImageUnitReceived=null,this.onShortLinesUnitReceived=null}getObservationParameters(){return this._parameters}}var De;!function(t){t.PT_DEFAULT="Default",t.PT_READ_BARCODES="ReadBarcodes_Default",t.PT_RECOGNIZE_TEXT_LINES="RecognizeTextLines_Default",t.PT_DETECT_DOCUMENT_BOUNDARIES="DetectDocumentBoundaries_Default",t.PT_DETECT_AND_NORMALIZE_DOCUMENT="DetectAndNormalizeDocument_Default",t.PT_NORMALIZE_DOCUMENT="NormalizeDocument_Default",t.PT_READ_BARCODES_SPEED_FIRST="ReadBarcodes_SpeedFirst",t.PT_READ_BARCODES_READ_RATE_FIRST="ReadBarcodes_ReadRateFirst",t.PT_READ_BARCODES_BALANCE="ReadBarcodes_Balance",t.PT_READ_SINGLE_BARCODE="ReadSingleBarcode",t.PT_READ_DENSE_BARCODES="ReadDenseBarcodes",t.PT_READ_DISTANT_BARCODES="ReadDistantBarcodes",t.PT_RECOGNIZE_NUMBERS="RecognizeNumbers",t.PT_RECOGNIZE_LETTERS="RecognizeLetters",t.PT_RECOGNIZE_NUMBERS_AND_LETTERS="RecognizeNumbersAndLetters",t.PT_RECOGNIZE_NUMBERS_AND_UPPERCASE_LETTERS="RecognizeNumbersAndUppercaseLetters",t.PT_RECOGNIZE_UPPERCASE_LETTERS="RecognizeUppercaseLetters"}(De||(De={}));const Me="undefined"==typeof self,Le=Me?{}:self,Fe="function"==typeof importScripts,Pe=(()=>{if(!Fe){if(!Me&&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"./"}})(),ke=t=>t&&"object"==typeof t&&"function"==typeof t.then,Ne=(async()=>{})().constructor;let Be=class extends Ne{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,ke(t)?e=t:"function"==typeof t&&(e=new Ne(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&&(ke(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}};const je=" is not allowed to change after `createInstance` or `loadWasm` is called.",Ve=!Me&&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"))||"",Ue=(t,e)=>{const i=t;if(i._license!==e){if(!i._pLoad.isEmpty)throw new Error("`license`"+je);i._license=e}};!Me&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword");const Ge=t=>{if(null==t)t=[];else{t=t instanceof Array?[...t]:[t];for(let e=0;e{e=Ge(e);const i=t;if(i._licenseServer!==e){if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+je);i._licenseServer=e}},Ye=(t,e)=>{e=e||"";const i=t;if(i._deviceFriendlyName!==e){if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+je);i._deviceFriendlyName=e}};let He,ze,Xe,qe,Ze;"undefined"!=typeof navigator&&(He=navigator,ze=He.userAgent,Xe=He.platform,qe=He.mediaDevices),function(){if(!Me){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:He.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:Xe,search:"Win"},Mac:{str:Xe},Linux:{str:Xe}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||ze,a=r.search||e,o=r.verStr||ze,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||ze,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=ze.indexOf("Windows NT")&&(r="HarmonyOS"),Ze={browser:i,version:n,OS:r}}Me&&(Ze={browser:"ssr",version:0,OS:"ssr"})}(),qe&&qe.getUserMedia,"Chrome"===Ze.browser&&Ze.version>66||"Safari"===Ze.browser&&Ze.version>13||"OPR"===Ze.browser&&Ze.version>43||"Edge"===Ze.browser&&Ze.version;const Ke=()=>(Ft.loadWasm(),Ct("dynamsoft_inited",(async()=>{let{lt:t,l:e,ls:i,sp:n,rmk:r,cv:s}=((t,e=!1)=>{const i=$e;if(i._pLoad.isEmpty){let n,r,s,a=i._license||"",o=JSON.parse(JSON.stringify(i._licenseServer)),l=i._sessionPassword,h=0;if(a.startsWith("t")||a.startsWith("f"))h=0;else if(0===a.length||a.startsWith("P")||a.startsWith("L")||a.startsWith("Y")||a.startsWith("A"))h=1;else{h=2;const e=a.indexOf(":");-1!=e&&(a=a.substring(e+1));const i=a.indexOf("?");if(-1!=i&&(r=a.substring(i+1),a=a.substring(0,i)),a.startsWith("DLC2"))h=0;else{if(a.startsWith("DLS2")){let e;try{let t=a.substring(4);t=atob(t),e=JSON.parse(t)}catch(t){throw new Error("Format Error: The license string you specified is invalid, please check to make sure it is correct.")}if(a=e.handshakeCode?e.handshakeCode:e.organizationID?e.organizationID:"","number"==typeof a&&(a=JSON.stringify(a)),0===o.length){let t=[];e.mainServerURL&&(t[0]=e.mainServerURL),e.standbyServerURL&&(t[1]=e.standbyServerURL),o=Ge(t)}!l&&e.sessionPassword&&(l=e.sessionPassword),n=e.remark}a&&"200001"!==a&&!a.startsWith("200001-")||(h=1)}}if(h&&(e||(Le.crypto||(s="Please upgrade your browser to support online key."),Le.crypto.subtle||(s="Require https to use online key in this browser."))),s)throw new Error(s);return 1===h&&(a="",console.warn("Applying for a public trial license ...")),{lt:h,l:a,ls:o,sp:l,rmk:n,cv:r}}throw new Error("Can't preprocess license again"+je)})(),a=new Be;$e._pLoad.task=a,(async()=>{try{await $e._pLoad}catch(t){}})();let o=Tt();bt[o]=e=>{if(e.message&&$e._onAuthMessage){let t=$e._onAuthMessage(e.message);null!=t&&(e.message=t)}let i,n=!1;if(1===t&&(n=!0),e.success?(It&&It("init license success"),e.message&&console.warn(e.message),Ft._bSupportIRTModule=e.bSupportIRTModule,Ft._bSupportDce4Module=e.bSupportDce4Module,$e.bPassValidation=!0,[0,-10076].includes(e.initLicenseInfo.errorCode)?[-10076].includes(e.initLicenseInfo.errorCode)&&console.warn(e.initLicenseInfo.errorString):a.reject(new Error(e.initLicenseInfo.errorString))):(i=Error(e.message),e.stack&&(i.stack=e.stack),e.ltsErrorCode&&(i.ltsErrorCode=e.ltsErrorCode),n||111==e.ltsErrorCode&&-1!=e.message.toLowerCase().indexOf("trial license")&&(n=!0)),n){const t=D(Ft.engineResourcePaths);(async(t,e,i)=>{if(!t._bNeverShowDialog)try{let n=await fetch(t.engineResourcePath+"dls.license.dialog.html");if(!n.ok)throw Error("Get license dialog fail. Network Error: "+n.statusText);let r=await n.text();if(!r.trim().startsWith("<"))throw Error("Get license dialog fail. Can't get valid HTMLElement.");let s=document.createElement("div");s.insertAdjacentHTML("beforeend",r);let a=[];for(let t=0;t{if(t==e.target){o.remove();for(let t of a)t.remove()}}));else if(!h&&t.classList.contains("dls-license-icon-close"))h=t,t.addEventListener("click",(()=>{o.remove();for(let t of a)t.remove()}));else if(!c&&t.classList.contains("dls-license-icon-error"))c=t,"error"!=e&&t.remove();else if(!d&&t.classList.contains("dls-license-icon-warn"))d=t,"warn"!=e&&t.remove();else if(!u&&t.classList.contains("dls-license-msg-content")){u=t;let e=i;for(;e;){let i=e.indexOf("["),n=e.indexOf("]",i),r=e.indexOf("(",n),s=e.indexOf(")",r);if(-1==i||-1==n||-1==r||-1==s){t.appendChild(new Text(e));break}i>0&&t.appendChild(new Text(e.substring(0,i)));let a=document.createElement("a"),o=e.substring(i+1,n);a.innerText=o;let l=e.substring(r+1,s);a.setAttribute("href",l),a.setAttribute("target","_blank"),t.appendChild(a),e=e.substring(s+1)}}document.body.appendChild(o)}catch(e){t._onLog&&t._onLog(e.message||e)}})({_bNeverShowDialog:$e._bNeverShowDialog,engineResourcePath:t.dcvData+"ui/",_onLog:It},e.success?"warn":"error",e.message)}e.success?a.resolve(void 0):a.reject(i)},await wt("core"),Et.postMessage({type:"license_dynamsoft",body:{v:"4.0.30-dev-20250604160433",brtk:!!t,bptk:1===t,l:e,os:Ze,fn:$e.deviceFriendlyName,ls:i,sp:n,rmk:r,cv:s},id:o}),$e.bCallInitLicense=!0,await a})));let Je;Dt.license={},Dt.license.dynamsoft=Ke,Dt.license.getAR=async()=>{{let t=yt.dynamsoft_inited;t&&t.isRejected&&await t}return Et?new Promise(((t,e)=>{let i=Tt();bt[i]=async i=>{if(i.success){delete i.success;{let t=$e.license;t&&(t.startsWith("t")||t.startsWith("f"))&&(i.pk=t)}if(Object.keys(i).length){if(i.lem){let t=Error(i.lem);t.ltsErrorCode=i.lec,delete i.lem,delete i.lec,i.ae=t}t(i)}else t(null)}else{let t=Error(i.message);i.stack&&(t.stack=i.stack),e(t)}},Et.postMessage({type:"license_getAR",id:i})})):null};let $e=class t{static setLicenseServer(e){We(t,e)}static get license(){return this._license}static set license(e){Ue(t,e)}static get licenseServer(){return this._licenseServer}static set licenseServer(e){We(t,e)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(e){Ye(t,e)}static initLicense(e,i){if(Ue(t,e),t.bCallInitLicense=!0,"boolean"==typeof i&&i||"object"==typeof i&&i.executeNow)return Ke()}static setDeviceFriendlyName(e){Ye(t,e)}static getDeviceFriendlyName(){return t._deviceFriendlyName}static getDeviceUUID(){return(async()=>(await Ct("dynamsoft_uuid",(async()=>{await Ft.loadWasm();let t=new Be,e=Tt();bt[e]=e=>{if(e.success)t.resolve(e.uuid);else{const i=Error(e.message);e.stack&&(i.stack=e.stack),t.reject(i)}},Et.postMessage({type:"license_getDeviceUUID",id:e}),Je=await t})),Je))()}};$e._pLoad=new Be,$e.bPassValidation=!1,$e.bCallInitLicense=!1,$e._license=Ve,$e._licenseServer=[],$e._deviceFriendlyName="",Ft.engineResourcePaths.license={version:"4.0.30-dev-20250604160433",path:Pe,isInternal:!0},Mt.license={wasm:!0,js:!0},Dt.license.LicenseManager=$e;const Qe="2.0.0";"string"!=typeof Ft.engineResourcePaths.std&&A(Ft.engineResourcePaths.std.version,Qe)<0&&(Ft.engineResourcePaths.std={version:Qe,path:(t=>{if(null==t&&(t="./"),Me||Fe);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(Pe+`../../dynamsoft-capture-vision-std@${Qe}/dist/`),isInternal:!0});let ti=class{static getVersion(){return`4.0.30-dev-20250604160433(Worker: ${At.license&&At.license.worker||"Not Loaded"}, Wasm: ${At.license&&At.license.wasm||"Not Loaded"})`}};const ei="undefined"==typeof self,ii="function"==typeof importScripts,ni=(()=>{if(!ii){if(!ei&&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"./"}})();Ft.engineResourcePaths.dce={version:"4.2.12-dev-20250609101854",path:ni,isInternal:!0},Mt.dce={wasm:!1,js:!1},Dt.dce={};let ri,si,ai,oi,li,hi=class{static getVersion(){return"4.2.12-dev-20250609101854"}};function ci(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 di(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 r?r.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError,"undefined"!=typeof navigator&&(ri=navigator,si=ri.userAgent,ai=ri.platform,oi=ri.mediaDevices),function(){if(!ei){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:ri.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:ai,search:"Win"},Mac:{str:ai},Linux:{str:ai}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||si,a=r.search||e,o=r.verStr||si,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||si,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=si.indexOf("Windows NT")&&(r="HarmonyOS"),li={browser:i,version:n,OS:r}}ei&&(li={browser:"ssr",version:0,OS:"ssr"})}();const ui="undefined"!=typeof WebAssembly&&si&&!(/Safari/.test(si)&&!/Chrome/.test(si)&&/\(.+\s11_2_([2-6]).*\)/.test(si)),fi=!("undefined"==typeof Worker),gi=!(!oi||!oi.getUserMedia),mi=async()=>{let t=!1;if(gi)try{(await oi.getUserMedia({video:!0})).getTracks().forEach((t=>{t.stop()})),t=!0}catch(t){}return t};"Chrome"===li.browser&&li.version>66||"Safari"===li.browser&&li.version>13||"OPR"===li.browser&&li.version>43||"Edge"===li.browser&&li.version;var pi={653:(t,e,i)=>{var n,r,s,a,o,l,h,c,d,u,f,g,m,p,_,v,y,w,C,E,S,T=T||{version:"5.2.1"};if(e.fabric=T,"undefined"!=typeof document&&"undefined"!=typeof window)document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?T.document=document:T.document=document.implementation.createHTMLDocument(""),T.window=window;else{var b=new(i(192).JSDOM)(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;T.document=b.document,T.jsdomImplForWrapper=i(898).implForWrapper,T.nodeCanvas=i(245).Canvas,T.window=b,DOMParser=T.window.DOMParser}function I(t,e){var i=t.canvas,n=e.targetCanvas,r=n.getContext("2d");r.translate(0,n.height),r.scale(1,-1);var s=i.height-n.height;r.drawImage(i,0,s,n.width,n.height,0,0,n.width,n.height)}function x(t,e){var i=e.targetCanvas.getContext("2d"),n=e.destinationWidth,r=e.destinationHeight,s=n*r*4,a=new Uint8Array(this.imageBuffer,0,s),o=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,n,r,t.RGBA,t.UNSIGNED_BYTE,a);var l=new ImageData(o,n,r);i.putImageData(l,0,0)}T.isTouchSupported="ontouchstart"in T.window||"ontouchstart"in T.document||T.window&&T.window.navigator&&T.window.navigator.maxTouchPoints>0,T.isLikelyNode="undefined"!=typeof Buffer&&"undefined"==typeof window,T.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],T.DPI=96,T.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",T.commaWsp="(?:\\s+,?\\s*|,\\s*)",T.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,T.reNonWord=/[ \n\.,;!\?\-]/,T.fontPaths={},T.iMatrix=[1,0,0,1,0,0],T.svgNS="http://www.w3.org/2000/svg",T.perfLimitSizeTotal=2097152,T.maxCacheSideLimit=4096,T.minCacheSideLimit=256,T.charWidthsCache={},T.textureSize=2048,T.disableStyleCopyPaste=!1,T.enableGLFiltering=!0,T.devicePixelRatio=T.window.devicePixelRatio||T.window.webkitDevicePixelRatio||T.window.mozDevicePixelRatio||1,T.browserShadowBlurConstant=1,T.arcToSegmentsCache={},T.boundsOfCurveCache={},T.cachesBoundsOfCurve=!0,T.forceGLPutImageData=!1,T.initFilterBackend=function(){return T.enableGLFiltering&&T.isWebglSupported&&T.isWebglSupported(T.textureSize)?(console.log("max texture size: "+T.maxTextureSize),new T.WebglFilterBackend({tileSize:T.textureSize})):T.Canvas2dFilterBackend?new T.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=T),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:T.util.array.fill(i,!1)}}function e(t,e){var i=function(){e.apply(this,arguments),this.off(t,i)}.bind(this);this.on(t,i)}T.Observable={fire:function(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;for(var n=0,r=i.length;n-1||!!e&&this._objects.some((function(e){return"function"==typeof e.contains&&e.contains(t,!0)}))},complexity:function(){return this._objects.reduce((function(t,e){return t+(e.complexity?e.complexity():0)}),0)}},T.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof T.Gradient||this.set(e,new T.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof T.Pattern?i&&i():this.set(e,new T.Pattern(t,i))},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},n=e,r=Math.sqrt,s=Math.atan2,a=Math.pow,o=Math.PI/180,l=Math.PI/2,T.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/l){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},sin:function(t){if(0===t)return 0;var e=1;switch(t<0&&(e=-1),t/l){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)},removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*o},radiansToDegrees:function(t){return t/o},rotatePoint:function(t,e,i){var n=new T.Point(t.x-e.x,t.y-e.y),r=T.util.rotateVector(n,i);return new T.Point(r.x,r.y).addEquals(e)},rotateVector:function(t,e){var i=T.util.sin(e),n=T.util.cos(e);return{x:t.x*n-t.y*i,y:t.x*i+t.y*n}},createVector:function(t,e){return new T.Point(e.x-t.x,e.y-t.y)},calcAngleBetweenVectors:function(t,e){return Math.acos((t.x*e.x+t.y*e.y)/(Math.hypot(t.x,t.y)*Math.hypot(e.x,e.y)))},getHatVector:function(t){return new T.Point(t.x,t.y).multiply(1/Math.hypot(t.x,t.y))},getBisector:function(t,e,i){var n=T.util.createVector(t,e),r=T.util.createVector(t,i),s=T.util.calcAngleBetweenVectors(n,r),a=s*(0===T.util.calcAngleBetweenVectors(T.util.rotateVector(n,s),r)?1:-1)/2;return{vector:T.util.getHatVector(T.util.rotateVector(n,a)),angle:s}},projectStrokeOnPoints:function(t,e,i){var n=[],r=e.strokeWidth/2,s=e.strokeUniform?new T.Point(1/e.scaleX,1/e.scaleY):new T.Point(1,1),a=function(t){var e=r/Math.hypot(t.x,t.y);return new T.Point(t.x*e*s.x,t.y*e*s.y)};return t.length<=1||t.forEach((function(o,l){var h,c,d=new T.Point(o.x,o.y);0===l?(c=t[l+1],h=i?a(T.util.createVector(c,d)).addEquals(d):t[t.length-1]):l===t.length-1?(h=t[l-1],c=i?a(T.util.createVector(h,d)).addEquals(d):t[0]):(h=t[l-1],c=t[l+1]);var u,f,g=T.util.getBisector(d,h,c),m=g.vector,p=g.angle;if("miter"===e.strokeLineJoin&&(u=-r/Math.sin(p/2),f=new T.Point(m.x*u*s.x,m.y*u*s.y),Math.hypot(f.x,f.y)/r<=e.strokeMiterLimit))return n.push(d.add(f)),void n.push(d.subtract(f));u=-r*Math.SQRT2,f=new T.Point(m.x*u*s.x,m.y*u*s.y),n.push(d.add(f)),n.push(d.subtract(f))})),n},transformPoint:function(t,e,i){return i?new T.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new T.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t,e){if(e)for(var i=0;i0&&(e>n?e-=n:e=0,i>n?i-=n:i=0);var r,s=!0,a=t.getImageData(e,i,2*n||1,2*n||1),o=a.data.length;for(r=3;r=r?s-r:2*Math.PI-(r-s)}function s(t,e,i){for(var s=i[1],a=i[2],o=i[3],l=i[4],h=i[5],c=function(t,e,i,s,a,o,l){var h=Math.PI,c=l*h/180,d=T.util.sin(c),u=T.util.cos(c),f=0,g=0,m=-u*t*.5-d*e*.5,p=-u*e*.5+d*t*.5,_=(i=Math.abs(i))*i,v=(s=Math.abs(s))*s,y=p*p,w=m*m,C=_*v-_*y-v*w,E=0;if(C<0){var S=Math.sqrt(1-C/(_*v));i*=S,s*=S}else E=(a===o?-1:1)*Math.sqrt(C/(_*y+v*w));var b=E*i*p/s,I=-E*s*m/i,x=u*b-d*I+.5*t,R=d*b+u*I+.5*e,O=r(1,0,(m-b)/i,(p-I)/s),A=r((m-b)/i,(p-I)/s,(-m-b)/i,(-p-I)/s);0===o&&A>0?A-=2*h:1===o&&A<0&&(A+=2*h);for(var D=Math.ceil(Math.abs(A/h*2)),M=[],L=A/D,F=8/3*Math.sin(L/4)*Math.sin(L/4)/Math.sin(L/2),P=O+L,k=0;kE)for(var b=1,I=m.length;b2;for(e=e||0,h&&(o=t[2].xt[i-2].x?1:r.x===t[i-2].x?0:-1,l=r.y>t[i-2].y?1:r.y===t[i-2].y?0:-1),n.push(["L",r.x+o*e,r.y+l*e]),n},T.util.getPathSegmentsInfo=u,T.util.getBoundsOfCurve=function(e,i,n,r,s,a,o,l){var h;if(T.cachesBoundsOfCurve&&(h=t.call(arguments),T.boundsOfCurveCache[h]))return T.boundsOfCurveCache[h];var c,d,u,f,g,m,p,_,v=Math.sqrt,y=Math.min,w=Math.max,C=Math.abs,E=[],S=[[],[]];d=6*e-12*n+6*s,c=-3*e+9*n-9*s+3*o,u=3*n-3*e;for(var b=0;b<2;++b)if(b>0&&(d=6*i-12*r+6*a,c=-3*i+9*r-9*a+3*l,u=3*r-3*i),C(c)<1e-12){if(C(d)<1e-12)continue;0<(f=-u/d)&&f<1&&E.push(f)}else(p=d*d-4*u*c)<0||(0<(g=(-d+(_=v(p)))/(2*c))&&g<1&&E.push(g),0<(m=(-d-_)/(2*c))&&m<1&&E.push(m));for(var I,x,R,O=E.length,A=O;O--;)I=(R=1-(f=E[O]))*R*R*e+3*R*R*f*n+3*R*f*f*s+f*f*f*o,S[0][O]=I,x=R*R*R*i+3*R*R*f*r+3*R*f*f*a+f*f*f*l,S[1][O]=x;S[0][A]=e,S[1][A]=i,S[0][A+1]=o,S[1][A+1]=l;var D=[{x:y.apply(null,S[0]),y:y.apply(null,S[1])},{x:w.apply(null,S[0]),y:w.apply(null,S[1])}];return T.cachesBoundsOfCurve&&(T.boundsOfCurveCache[h]=D),D},T.util.getPointOnPath=function(t,e,i){i||(i=u(t));for(var n=0;e-i[n].length>0&&n1e-4;)i=l(s),r=s,(n=a(h.x,h.y,i.x,i.y))+o>e?(s-=c,c/=2):(h=i,s+=c,o+=n);return i.angle=d(r),i}(s,e)}},T.util.transformPath=function(t,e,i){return i&&(e=T.util.multiplyTransformMatrices(e,[1,0,0,1,-i.x,-i.y])),t.map((function(t){for(var i=t.slice(0),n={},r=1;r=e}))}}}(),function(){function t(e,i,n){if(n)if(!T.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var r=0,s=i.length;r57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var n=t.charCodeAt(e+1);if(56320>n||n>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";var r=t.charCodeAt(e-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1}T.util.string={camelize:function(t){return t.replace(/-+(.)?/g,(function(t,e){return e?e.toUpperCase():""}))},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")},graphemeSplit:function(e){var i,n=0,r=[];for(n=0;n-1?t.prototype[r]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=n;var r=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return r}}(r):t.prototype[r]=e[r],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function r(){}function s(e){for(var i=null,n=this;n.constructor.superclass;){var r=n.constructor.superclass.prototype[e];if(n[e]!==r){i=r;break}n=n.constructor.superclass.prototype}return i?arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this):console.log("tried to callSuper "+e+", method not found in prototype chain",this)}T.util.createClass=function(){var i=null,a=t.call(arguments,0);function o(){this.initialize.apply(this,arguments)}"function"==typeof a[0]&&(i=a.shift()),o.superclass=i,o.subclasses=[],i&&(r.prototype=i.prototype,o.prototype=new r,i.subclasses.push(o));for(var l=0,h=a.length;l-1||"touch"===t.pointerType},u="string"==typeof(d=T.document.createElement("div")).style.opacity,f="string"==typeof d.style.filter,g=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,m=function(t){return t},u?m=function(t,e){return t.style.opacity=e,t}:f&&(m=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),g.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(g,e)):i.filter+=" alpha(opacity="+100*e+")",t}),T.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?m(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var n in e)"opacity"===n?m(t,e[n]):i["float"===n||"cssFloat"===n?void 0===i.styleFloat?"cssFloat":"styleFloat":n]=e[n];return t},function(){var t,e,i,n,r=Array.prototype.slice,s=function(t){return r.call(t,0)};try{t=s(T.document.childNodes)instanceof Array}catch(t){}function a(t,e){var i=T.document.createElement(t);for(var n in e)"class"===n?i.className=e[n]:"for"===n?i.htmlFor=e[n]:i.setAttribute(n,e[n]);return i}function o(t){for(var e=0,i=0,n=T.document.documentElement,r=T.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===T.document?(e=r.scrollLeft||n.scrollLeft||0,i=r.scrollTop||n.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}t||(s=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),e=T.document.defaultView&&T.document.defaultView.getComputedStyle?function(t,e){var i=T.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},i=T.document.documentElement.style,n="userSelect"in i?"userSelect":"MozUserSelect"in i?"MozUserSelect":"WebkitUserSelect"in i?"WebkitUserSelect":"KhtmlUserSelect"in i?"KhtmlUserSelect":"",T.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=T.util.falseFunction),n?t.style[n]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},T.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),n?t.style[n]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},T.util.setImageSmoothing=function(t,e){t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled,t.imageSmoothingEnabled=e},T.util.getById=function(t){return"string"==typeof t?T.document.getElementById(t):t},T.util.toArray=s,T.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},T.util.makeElement=a,T.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=a(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},T.util.getScrollLeftTop=o,T.util.getElementOffset=function(t){var i,n,r=t&&t.ownerDocument,s={left:0,top:0},a={left:0,top:0},l={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return a;for(var h in l)a[l[h]]+=parseInt(e(t,h),10)||0;return i=r.documentElement,void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect()),n=o(t),{left:s.left+n.left-(i.clientLeft||0)+a.left,top:s.top+n.top-(i.clientTop||0)+a.top}},T.util.getNodeCanvas=function(t){var e=T.jsdomImplForWrapper(t);return e._canvas||e._image},T.util.cleanUpJsdomNode=function(t){if(T.isLikelyNode){var e=T.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}T.util.request=function(e,i){i||(i={});var n=i.method?i.method.toUpperCase():"GET",r=i.onComplete||function(){},s=new T.window.XMLHttpRequest,a=i.body||i.parameters;return s.onreadystatechange=function(){4===s.readyState&&(r(s),s.onreadystatechange=t)},"GET"===n&&(a=null,"string"==typeof i.parameters&&(e=function(t,e){return t+(/\?/.test(t)?"&":"?")+e}(e,i.parameters))),s.open(n,e,!0),"POST"!==n&&"PUT"!==n||s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(a),s}}(),T.log=console.log,T.warn=console.warn,function(){var t=T.util.object.extend,e=T.util.object.clone,i=[];function n(){return!1}function r(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e}T.util.object.extend(i,{cancelAll:function(){var t=this.splice(0);return t.forEach((function(t){t.cancel()})),t},cancelByCanvas:function(t){if(!t)return[];var e=this.filter((function(e){return"object"==typeof e.target&&e.target.canvas===t}));return e.forEach((function(t){t.cancel()})),e},cancelByTarget:function(t){var e=this.findAnimationsByTarget(t);return e.forEach((function(t){t.cancel()})),e},findAnimationIndex:function(t){return this.indexOf(this.findAnimation(t))},findAnimation:function(t){return this.find((function(e){return e.cancel===t}))},findAnimationsByTarget:function(t){return t?this.filter((function(e){return e.target===t})):[]}});var s=T.window.requestAnimationFrame||T.window.webkitRequestAnimationFrame||T.window.mozRequestAnimationFrame||T.window.oRequestAnimationFrame||T.window.msRequestAnimationFrame||function(t){return T.window.setTimeout(t,1e3/60)},a=T.window.cancelAnimationFrame||T.window.clearTimeout;function o(){return s.apply(T.window,arguments)}T.util.animate=function(i){i||(i={});var s,a=!1,l=function(){var t=T.runningAnimations.indexOf(s);return t>-1&&T.runningAnimations.splice(t,1)[0]};return s=t(e(i),{cancel:function(){return a=!0,l()},currentValue:"startValue"in i?i.startValue:0,completionRate:0,durationRate:0}),T.runningAnimations.push(s),o((function(t){var e,h=t||+new Date,c=i.duration||500,d=h+c,u=i.onChange||n,f=i.abort||n,g=i.onComplete||n,m=i.easing||r,p="startValue"in i&&i.startValue.length>0,_="startValue"in i?i.startValue:0,v="endValue"in i?i.endValue:100,y=i.byValue||(p?_.map((function(t,e){return v[e]-_[e]})):v-_);i.onStart&&i.onStart(),function t(i){var n=(e=i||+new Date)>d?c:e-h,r=n/c,w=p?_.map((function(t,e){return m(n,_[e],y[e],c)})):m(n,_,y,c),C=p?Math.abs((w[0]-_[0])/y[0]):Math.abs((w-_)/y);if(s.currentValue=p?w.slice():w,s.completionRate=C,s.durationRate=r,!a){if(!f(w,C,r))return e>d?(s.currentValue=p?v.slice():v,s.completionRate=1,s.durationRate=1,u(p?v.slice():v,1,1),g(v,1,1),void l()):(u(w,C,r),void o(t));l()}}(h)})),s.cancel},T.util.requestAnimFrame=o,T.util.cancelAnimFrame=function(){return a.apply(T.window,arguments)},T.runningAnimations=i}(),function(){function t(t,e,i){var n="rgba("+parseInt(t[0]+i*(e[0]-t[0]),10)+","+parseInt(t[1]+i*(e[1]-t[1]),10)+","+parseInt(t[2]+i*(e[2]-t[2]),10);return(n+=","+(t&&e?parseFloat(t[3]+i*(e[3]-t[3])):1))+")"}T.util.animateColor=function(e,i,n,r){var s=new T.Color(e).getSource(),a=new T.Color(i).getSource(),o=r.onComplete,l=r.onChange;return r=r||{},T.util.animate(T.util.object.extend(r,{duration:n||500,startValue:s,endValue:a,byValue:a,easing:function(e,i,n,s){return t(i,n,r.colorEasing?r.colorEasing(e,s):1-Math.cos(e/s*(Math.PI/2)))},onComplete:function(e,i,n){if(o)return o(t(a,a,0),i,n)},onChange:function(e,i,n){if(l){if(Array.isArray(e))return l(t(e,e,0),i,n);l(e,i,n)}}}))}}(),function(){function t(t,e,i,n){return t-1&&c>-1&&c-1)&&(i="stroke")}else{if("href"===t||"xlink:href"===t||"font"===t)return i;if("imageSmoothing"===t)return"optimizeQuality"===i;o=l?i.map(s):s(i,r)}}else i="";return!l&&isNaN(o)?i:o}function f(t){return new RegExp("^("+t.join("|")+")\\b","i")}function g(t,e){var i,n,r,s,a=[];for(r=0,s=e.length;r1;)l.shift(),h=e.util.multiplyTransformMatrices(h,l[0]);return h}}();var v=new RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function y(t){if(!e.svgViewBoxElementsRegEx.test(t.nodeName))return{};var i,n,r,a,o,l,h=t.getAttribute("viewBox"),c=1,d=1,u=t.getAttribute("width"),f=t.getAttribute("height"),g=t.getAttribute("x")||0,m=t.getAttribute("y")||0,p=t.getAttribute("preserveAspectRatio")||"",_=!h||!(h=h.match(v)),y=!u||!f||"100%"===u||"100%"===f,w=_&&y,C={},E="",S=0,T=0;if(C.width=0,C.height=0,C.toBeParsed=w,_&&(g||m)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(E=" translate("+s(g)+" "+s(m)+") ",o=(t.getAttribute("transform")||"")+E,t.setAttribute("transform",o),t.removeAttribute("x"),t.removeAttribute("y")),w)return C;if(_)return C.width=s(u),C.height=s(f),C;if(i=-parseFloat(h[1]),n=-parseFloat(h[2]),r=parseFloat(h[3]),a=parseFloat(h[4]),C.minX=i,C.minY=n,C.viewBoxWidth=r,C.viewBoxHeight=a,y?(C.width=r,C.height=a):(C.width=s(u),C.height=s(f),c=C.width/r,d=C.height/a),"none"!==(p=e.util.parsePreserveAspectRatioAttribute(p)).alignX&&("meet"===p.meetOrSlice&&(d=c=c>d?d:c),"slice"===p.meetOrSlice&&(d=c=c>d?c:d),S=C.width-r*c,T=C.height-a*c,"Mid"===p.alignX&&(S/=2),"Mid"===p.alignY&&(T/=2),"Min"===p.alignX&&(S=0),"Min"===p.alignY&&(T=0)),1===c&&1===d&&0===i&&0===n&&0===g&&0===m)return C;if((g||m)&&"#document"!==t.parentNode.nodeName&&(E=" translate("+s(g)+" "+s(m)+") "),o=E+" matrix("+c+" 0 0 "+d+" "+(i*c+S)+" "+(n*d+T)+") ","svg"===t.nodeName){for(l=t.ownerDocument.createElementNS(e.svgNS,"g");t.firstChild;)l.appendChild(t.firstChild);t.appendChild(l)}else(l=t).removeAttribute("x"),l.removeAttribute("y"),o=l.getAttribute("transform")+o;return l.setAttribute("transform",o),C}function w(t,e){var i="xlink:href",n=_(t,e.getAttribute(i).slice(1));if(n&&n.getAttribute(i)&&w(t,n),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach((function(t){n&&!e.hasAttribute(t)&&n.hasAttribute(t)&&e.setAttribute(t,n.getAttribute(t))})),!e.children.length)for(var r=n.cloneNode(!0);r.firstChild;)e.appendChild(r.firstChild);e.removeAttribute(i)}e.parseSVGDocument=function(t,i,r,s){if(t){!function(t){for(var i=g(t,["use","svg:use"]),n=0;i.length&&nt.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return void 0===e&&(e=.5),e=Math.max(Math.min(1,e),0),new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new i(this.x,this.y)}})}(e),function(t){var e=t.fabric||(t.fabric={});function i(t){this.status=t,this.points=[]}e.Intersection?e.warn("fabric.Intersection is already defined"):(e.Intersection=i,e.Intersection.prototype={constructor:i,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},e.Intersection.intersectLineLine=function(t,n,r,s){var a,o=(s.x-r.x)*(t.y-r.y)-(s.y-r.y)*(t.x-r.x),l=(n.x-t.x)*(t.y-r.y)-(n.y-t.y)*(t.x-r.x),h=(s.y-r.y)*(n.x-t.x)-(s.x-r.x)*(n.y-t.y);if(0!==h){var c=o/h,d=l/h;0<=c&&c<=1&&0<=d&&d<=1?(a=new i("Intersection")).appendPoint(new e.Point(t.x+c*(n.x-t.x),t.y+c*(n.y-t.y))):a=new i}else a=new i(0===o||0===l?"Coincident":"Parallel");return a},e.Intersection.intersectLinePolygon=function(t,e,n){var r,s,a,o,l=new i,h=n.length;for(o=0;o0&&(l.status="Intersection"),l},e.Intersection.intersectPolygonPolygon=function(t,e){var n,r=new i,s=t.length;for(n=0;n0&&(r.status="Intersection"),r},e.Intersection.intersectPolygonRectangle=function(t,n,r){var s=n.min(r),a=n.max(r),o=new e.Point(a.x,s.y),l=new e.Point(s.x,a.y),h=i.intersectLinePolygon(s,o,t),c=i.intersectLinePolygon(o,a,t),d=i.intersectLinePolygon(a,l,t),u=i.intersectLinePolygon(l,s,t),f=new i;return f.appendPoints(h.points),f.appendPoints(c.points),f.appendPoints(d.points),f.appendPoints(u.points),f.points.length>0&&(f.status="Intersection"),f})}(e),function(t){var e=t.fabric||(t.fabric={});function i(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function n(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}e.Color?e.warn("fabric.Color is already defined."):(e.Color=i,e.Color.prototype={_tryParsingColor:function(t){var e;t in i.colorNameMap&&(t=i.colorNameMap[t]),"transparent"===t&&(e=[255,255,255,0]),e||(e=i.sourceFromHex(t)),e||(e=i.sourceFromRgb(t)),e||(e=i.sourceFromHsl(t)),e||(e=[0,0,0,1]),e&&this.setSource(e)},_rgbToHsl:function(t,i,n){t/=255,i/=255,n/=255;var r,s,a,o=e.util.array.max([t,i,n]),l=e.util.array.min([t,i,n]);if(a=(o+l)/2,o===l)r=s=0;else{var h=o-l;switch(s=a>.5?h/(2-o-l):h/(o+l),o){case t:r=(i-n)/h+(i0)-(t<0)||+t};function f(t,e){var i=t.angle+d(Math.atan2(e.y,e.x))+360;return Math.round(i%360/45)}function g(t,i){var n=i.transform.target,r=n.canvas,s=e.util.object.clone(i);s.target=n,r&&r.fire("object:"+t,s),n.fire(t,i)}function m(t,e){var i=e.canvas,n=t[i.uniScaleKey];return i.uniformScaling&&!n||!i.uniformScaling&&n}function p(t){return t.originX===h&&t.originY===h}function _(t,e,i){var n=t.lockScalingX,r=t.lockScalingY;return!((!n||!r)&&(e||!n&&!r||!i)&&(!n||"x"!==e)&&(!r||"y"!==e))}function v(t,e,i,n){return{e:t,transform:e,pointer:{x:i,y:n}}}function y(t){return function(e,i,n,r){var s=i.target,a=s.getCenterPoint(),o=s.translateToOriginPoint(a,i.originX,i.originY),l=t(e,i,n,r);return s.setPositionByOrigin(o,i.originX,i.originY),l}}function w(t,e){return function(i,n,r,s){var a=e(i,n,r,s);return a&&g(t,v(i,n,r,s)),a}}function C(t,i,n,r,s){var a=t.target,o=a.controls[t.corner],l=a.canvas.getZoom(),h=a.padding/l,c=a.toLocalPoint(new e.Point(r,s),i,n);return c.x>=h&&(c.x-=h),c.x<=-h&&(c.x+=h),c.y>=h&&(c.y-=h),c.y<=h&&(c.y+=h),c.x-=o.offsetX,c.y-=o.offsetY,c}function E(t){return t.flipX!==t.flipY}function S(t,e,i,n,r){if(0!==t[e]){var s=r/t._getTransformedDimensions()[n]*t[i];t.set(i,s)}}function T(t,e,i,n){var r,h=e.target,c=h._getTransformedDimensions(0,h.skewY),u=C(e,e.originX,e.originY,i,n),f=Math.abs(2*u.x)-c.x,g=h.skewX;f<2?r=0:(r=d(Math.atan2(f/h.scaleX,c.y/h.scaleY)),e.originX===s&&e.originY===l&&(r=-r),e.originX===o&&e.originY===a&&(r=-r),E(h)&&(r=-r));var m=g!==r;if(m){var p=h._getTransformedDimensions().y;h.set("skewX",r),S(h,"skewY","scaleY","y",p)}return m}function b(t,e,i,n){var r,h=e.target,c=h._getTransformedDimensions(h.skewX,0),u=C(e,e.originX,e.originY,i,n),f=Math.abs(2*u.y)-c.y,g=h.skewY;f<2?r=0:(r=d(Math.atan2(f/h.scaleY,c.x/h.scaleX)),e.originX===s&&e.originY===l&&(r=-r),e.originX===o&&e.originY===a&&(r=-r),E(h)&&(r=-r));var m=g!==r;if(m){var p=h._getTransformedDimensions().x;h.set("skewY",r),S(h,"skewX","scaleX","x",p)}return m}function I(t,e,i,n,r){r=r||{};var s,a,o,l,h,d,f=e.target,g=f.lockScalingX,v=f.lockScalingY,y=r.by,w=m(t,f),E=_(f,y,w),S=e.gestureScale;if(E)return!1;if(S)a=e.scaleX*S,o=e.scaleY*S;else{if(s=C(e,e.originX,e.originY,i,n),h="y"!==y?u(s.x):1,d="x"!==y?u(s.y):1,e.signX||(e.signX=h),e.signY||(e.signY=d),f.lockScalingFlip&&(e.signX!==h||e.signY!==d))return!1;if(l=f._getTransformedDimensions(),w&&!y){var T=Math.abs(s.x)+Math.abs(s.y),b=e.original,I=T/(Math.abs(l.x*b.scaleX/f.scaleX)+Math.abs(l.y*b.scaleY/f.scaleY));a=b.scaleX*I,o=b.scaleY*I}else a=Math.abs(s.x*f.scaleX/l.x),o=Math.abs(s.y*f.scaleY/l.y);p(e)&&(a*=2,o*=2),e.signX!==h&&"y"!==y&&(e.originX=c[e.originX],a*=-1,e.signX=h),e.signY!==d&&"x"!==y&&(e.originY=c[e.originY],o*=-1,e.signY=d)}var x=f.scaleX,R=f.scaleY;return y?("x"===y&&f.set("scaleX",a),"y"===y&&f.set("scaleY",o)):(!g&&f.set("scaleX",a),!v&&f.set("scaleY",o)),x!==f.scaleX||R!==f.scaleY}r.scaleCursorStyleHandler=function(t,e,n){var r=m(t,n),s="";if(0!==e.x&&0===e.y?s="x":0===e.x&&0!==e.y&&(s="y"),_(n,s,r))return"not-allowed";var a=f(n,e);return i[a]+"-resize"},r.skewCursorStyleHandler=function(t,e,i){var r="not-allowed";if(0!==e.x&&i.lockSkewingY)return r;if(0!==e.y&&i.lockSkewingX)return r;var s=f(i,e)%4;return n[s]+"-resize"},r.scaleSkewCursorStyleHandler=function(t,e,i){return t[i.canvas.altActionKey]?r.skewCursorStyleHandler(t,e,i):r.scaleCursorStyleHandler(t,e,i)},r.rotationWithSnapping=w("rotating",y((function(t,e,i,n){var r=e,s=r.target,a=s.translateToOriginPoint(s.getCenterPoint(),r.originX,r.originY);if(s.lockRotation)return!1;var o,l=Math.atan2(r.ey-a.y,r.ex-a.x),h=Math.atan2(n-a.y,i-a.x),c=d(h-l+r.theta);if(s.snapAngle>0){var u=s.snapAngle,f=s.snapThreshold||u,g=Math.ceil(c/u)*u,m=Math.floor(c/u)*u;Math.abs(c-m)0?s:o:(c>0&&(r=d===a?s:o),c<0&&(r=d===a?o:s),E(l)&&(r=r===s?o:s)),e.originX=r,w("skewing",y(T))(t,e,i,n))},r.skewHandlerY=function(t,e,i,n){var r,o=e.target,c=o.skewY,d=e.originX;return!o.lockSkewingY&&(0===c?r=C(e,h,h,i,n).y>0?a:l:(c>0&&(r=d===s?a:l),c<0&&(r=d===s?l:a),E(o)&&(r=r===a?l:a)),e.originY=r,w("skewing",y(b))(t,e,i,n))},r.dragHandler=function(t,e,i,n){var r=e.target,s=i-e.offsetX,a=n-e.offsetY,o=!r.get("lockMovementX")&&r.left!==s,l=!r.get("lockMovementY")&&r.top!==a;return o&&r.set("left",s),l&&r.set("top",a),(o||l)&&g("moving",v(t,e,i,n)),o||l},r.scaleOrSkewActionName=function(t,e,i){var n=t[i.canvas.altActionKey];return 0===e.x?n?"skewX":"scaleY":0===e.y?n?"skewY":"scaleX":void 0},r.rotationStyleHandler=function(t,e,i){return i.lockRotation?"not-allowed":e.cursorStyle},r.fireEvent=g,r.wrapWithFixedAnchor=y,r.wrapWithFireEvent=w,r.getLocalPoint=C,e.controlsUtils=r}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians,n=e.controlsUtils;n.renderCircleControl=function(t,e,i,n,r){n=n||{};var s,a=this.sizeX||n.cornerSize||r.cornerSize,o=this.sizeY||n.cornerSize||r.cornerSize,l=void 0!==n.transparentCorners?n.transparentCorners:r.transparentCorners,h=l?"stroke":"fill",c=!l&&(n.cornerStrokeColor||r.cornerStrokeColor),d=e,u=i;t.save(),t.fillStyle=n.cornerColor||r.cornerColor,t.strokeStyle=n.cornerStrokeColor||r.cornerStrokeColor,a>o?(s=a,t.scale(1,o/a),u=i*a/o):o>a?(s=o,t.scale(a/o,1),d=e*o/a):s=a,t.lineWidth=1,t.beginPath(),t.arc(d,u,s/2,0,2*Math.PI,!1),t[h](),c&&t.stroke(),t.restore()},n.renderSquareControl=function(t,e,n,r,s){r=r||{};var a=this.sizeX||r.cornerSize||s.cornerSize,o=this.sizeY||r.cornerSize||s.cornerSize,l=void 0!==r.transparentCorners?r.transparentCorners:s.transparentCorners,h=l?"stroke":"fill",c=!l&&(r.cornerStrokeColor||s.cornerStrokeColor),d=a/2,u=o/2;t.save(),t.fillStyle=r.cornerColor||s.cornerColor,t.strokeStyle=r.cornerStrokeColor||s.cornerStrokeColor,t.lineWidth=1,t.translate(e,n),t.rotate(i(s.angle)),t[h+"Rect"](-d,-u,a,o),c&&t.strokeRect(-d,-u,a,o),t.restore()}}(e),function(t){var e=t.fabric||(t.fabric={});e.Control=function(t){for(var e in t)this[e]=t[e]},e.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(t,e){return e.cursorStyle},getActionName:function(t,e){return e.actionName},getVisibility:function(t,e){var i=t._controlsVisibility;return i&&void 0!==i[e]?i[e]:this.visible},setVisibility:function(t){this.visible=t},positionHandler:function(t,i){return e.util.transformPoint({x:this.x*t.x+this.offsetX,y:this.y*t.y+this.offsetY},i)},calcCornerCoords:function(t,i,n,r,s){var a,o,l,h,c=s?this.touchSizeX:this.sizeX,d=s?this.touchSizeY:this.sizeY;if(c&&d&&c!==d){var u=Math.atan2(d,c),f=Math.sqrt(c*c+d*d)/2,g=u-e.util.degreesToRadians(t),m=Math.PI/2-u-e.util.degreesToRadians(t);a=f*e.util.cos(g),o=f*e.util.sin(g),l=f*e.util.cos(m),h=f*e.util.sin(m)}else f=.7071067812*(c&&d?c:i),g=e.util.degreesToRadians(45-t),a=l=f*e.util.cos(g),o=h=f*e.util.sin(g);return{tl:{x:n-h,y:r-l},tr:{x:n+a,y:r-o},bl:{x:n-a,y:r+o},br:{x:n+h,y:r+l}}},render:function(t,i,n,r,s){"circle"===((r=r||{}).cornerStyle||s.cornerStyle)?e.controlsUtils.renderCircleControl.call(this,t,i,n,r,s):e.controlsUtils.renderSquareControl.call(this,t,i,n,r,s)}}}(e),function(){function t(t,e){var i,n,r,s,a=t.getAttribute("style"),o=t.getAttribute("offset")||0;if(o=(o=parseFloat(o)/(/%$/.test(o)?100:1))<0?0:o>1?1:o,a){var l=a.split(/\s*;\s*/);for(""===l[l.length-1]&&l.pop(),s=l.length;s--;){var h=l[s].split(/\s*:\s*/),c=h[0].trim(),d=h[1].trim();"stop-color"===c?i=d:"stop-opacity"===c&&(r=d)}}return i||(i=t.getAttribute("stop-color")||"rgb(0,0,0)"),r||(r=t.getAttribute("stop-opacity")),n=(i=new T.Color(i)).getAlpha(),r=isNaN(parseFloat(r))?1:parseFloat(r),r*=n*e,{offset:o,color:i.toRgb(),opacity:r}}var e=T.util.object.clone;T.Gradient=T.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(t){t||(t={}),t.coords||(t.coords={});var e,i=this;Object.keys(t).forEach((function(e){i[e]=t[e]})),this.id?this.id+="_"+T.Object.__uid++:this.id=T.Object.__uid++,e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice()},addColorStop:function(t){for(var e in t){var i=new T.Color(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(t){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return T.util.populateWithProperties(this,e,t),e},toSVG:function(t,i){var n,r,s,a,o=e(this.coords,!0),l=(i=i||{},e(this.colorStops,!0)),h=o.r1>o.r2,c=this.gradientTransform?this.gradientTransform.concat():T.iMatrix.concat(),d=-this.offsetX,u=-this.offsetY,f=!!i.additionalTransform,g="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox";if(l.sort((function(t,e){return t.offset-e.offset})),"objectBoundingBox"===g?(d/=t.width,u/=t.height):(d+=t.width/2,u+=t.height/2),"path"===t.type&&"percentage"!==this.gradientUnits&&(d-=t.pathOffset.x,u-=t.pathOffset.y),c[4]-=d,c[5]-=u,a='id="SVGID_'+this.id+'" gradientUnits="'+g+'"',a+=' gradientTransform="'+(f?i.additionalTransform+" ":"")+T.util.matrixToSVG(c)+'" ',"linear"===this.type?s=["\n']:"radial"===this.type&&(s=["\n']),"radial"===this.type){if(h)for((l=l.concat()).reverse(),n=0,r=l.length;n0){var p=m/Math.max(o.r1,o.r2);for(n=0,r=l.length;n\n')}return s.push("linear"===this.type?"\n":"\n"),s.join("")},toLive:function(t){var e,i,n,r=T.util.object.clone(this.coords);if(this.type){for("linear"===this.type?e=t.createLinearGradient(r.x1,r.y1,r.x2,r.y2):"radial"===this.type&&(e=t.createRadialGradient(r.x1,r.y1,r.r1,r.x2,r.y2,r.r2)),i=0,n=this.colorStops.length;i1?1:s,isNaN(s)&&(s=1);var a,o,l,h,c=e.getElementsByTagName("stop"),d="userSpaceOnUse"===e.getAttribute("gradientUnits")?"pixels":"percentage",u=e.getAttribute("gradientTransform")||"",f=[],g=0,m=0;for("linearGradient"===e.nodeName||"LINEARGRADIENT"===e.nodeName?(a="linear",o=function(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}(e)):(a="radial",o=function(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}(e)),l=c.length;l--;)f.push(t(c[l],s));return h=T.parseTransformAttribute(u),function(t,e,i,n){var r,s;Object.keys(e).forEach((function(t){"Infinity"===(r=e[t])?s=1:"-Infinity"===r?s=0:(s=parseFloat(e[t],10),"string"==typeof r&&/^(\d+\.\d+)%|(\d+)%$/.test(r)&&(s*=.01,"pixels"===n&&("x1"!==t&&"x2"!==t&&"r2"!==t||(s*=i.viewBoxWidth||i.width),"y1"!==t&&"y2"!==t||(s*=i.viewBoxHeight||i.height)))),e[t]=s}))}(0,o,r,d),"pixels"===d&&(g=-i.left,m=-i.top),new T.Gradient({id:e.getAttribute("id"),type:a,coords:o,colorStops:f,gradientUnits:d,gradientTransform:h,offsetX:g,offsetY:m})}})}(),_=T.util.toFixed,T.Pattern=T.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(t,e){if(t||(t={}),this.id=T.Object.__uid++,this.setOptions(t),!t.source||t.source&&"string"!=typeof t.source)e&&e(this);else{var i=this;this.source=T.util.createImage(),T.util.loadImage(t.source,(function(t,n){i.source=t,e&&e(i,n)}),null,this.crossOrigin)}},toObject:function(t){var e,i,n=T.Object.NUM_FRACTION_DIGITS;return"string"==typeof this.source.src?e=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(e=this.source.toDataURL()),i={type:"pattern",source:e,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:_(this.offsetX,n),offsetY:_(this.offsetY,n),patternTransform:this.patternTransform?this.patternTransform.concat():null},T.util.populateWithProperties(this,i,t),i},toSVG:function(t){var e="function"==typeof this.source?this.source():this.source,i=e.width/t.width,n=e.height/t.height,r=this.offsetX/t.width,s=this.offsetY/t.height,a="";return"repeat-x"!==this.repeat&&"no-repeat"!==this.repeat||(n=1,s&&(n+=Math.abs(s))),"repeat-y"!==this.repeat&&"no-repeat"!==this.repeat||(i=1,r&&(i+=Math.abs(r))),e.src?a=e.src:e.toDataURL&&(a=e.toDataURL()),'\n\n\n'},setOptions:function(t){for(var e in t)this[e]=t[e]},toLive:function(t){var e=this.source;if(!e)return"";if(void 0!==e.src){if(!e.complete)return"";if(0===e.naturalWidth||0===e.naturalHeight)return""}return t.createPattern(e,this.repeat)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.toFixed;e.Shadow?e.warn("fabric.Shadow is already defined."):(e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(t){for(var i in"string"==typeof t&&(t=this._parseShadow(t)),t)this[i]=t[i];this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),n=e.Shadow.reOffsetsAndBlur.exec(i)||[];return{color:(i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseFloat(n[1],10)||0,offsetY:parseFloat(n[2],10)||0,blur:parseFloat(n[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var n=40,r=40,s=e.Object.NUM_FRACTION_DIGITS,a=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle)),o=new e.Color(this.color);return t.width&&t.height&&(n=100*i((Math.abs(a.x)+this.blur)/t.width,s)+20,r=100*i((Math.abs(a.y)+this.blur)/t.height,s)+20),t.flipX&&(a.x*=-1),t.flipY&&(a.y*=-1),'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var t={},i=e.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach((function(e){this[e]!==i[e]&&(t[e]=this[e])}),this),t}}),e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/)}(e),function(){if(T.StaticCanvas)T.warn("fabric.StaticCanvas is already defined.");else{var t=T.util.object.extend,e=T.util.getElementOffset,i=T.util.removeFromArray,n=T.util.toFixed,r=T.util.transformPoint,s=T.util.invertTransform,a=T.util.getNodeCanvas,o=T.util.createCanvasElement,l=new Error("Could not initialize `canvas` element");T.StaticCanvas=T.util.createClass(T.CommonMethods,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:T.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(t,e){var i=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(t),this._initOptions(e),this.interactive||this._initRetinaScaling(),e.overlayImage&&this.setOverlayImage(e.overlayImage,i),e.backgroundImage&&this.setBackgroundImage(e.backgroundImage,i),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor,i),e.overlayColor&&this.setOverlayColor(e.overlayColor,i),this.calcOffset()},_isRetinaScaling:function(){return T.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,T.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var t=T.devicePixelRatio;this.__initRetinaScaling(t,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(t,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(t,e,i){e.setAttribute("width",this.width*t),e.setAttribute("height",this.height*t),i.scale(t,t)},calcOffset:function(){return this._offset=e(this.lowerCanvasEl),this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},__setBgOverlayImage:function(t,e,i,n){return"string"==typeof e?T.util.loadImage(e,(function(e,r){if(e){var s=new T.Image(e,n);this[t]=s,s.canvas=this}i&&i(e,r)}),this,n&&n.crossOrigin):(n&&e.setOptions(n),this[t]=e,e&&(e.canvas=this),i&&i(e,!1)),this},__setBgOverlayColor:function(t,e,i){return this[t]=e,this._initGradient(e,t),this._initPattern(e,t,i),this},_createCanvasElement:function(){var t=o();if(!t)throw l;if(t.style||(t.style={}),void 0===t.getContext)throw l;return t},_initOptions:function(t){var e=this.lowerCanvasEl;this._setOptions(t),this.width=this.width||parseInt(e.width,10)||0,this.height=this.height||parseInt(e.height,10)||0,this.lowerCanvasEl.style&&(e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(t){t&&t.getContext?this.lowerCanvasEl=t:this.lowerCanvasEl=T.util.getById(t)||this._createCanvasElement(),T.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;for(var n in e=e||{},t)i=t[n],e.cssOnly||(this._setBackstoreDimension(n,t[n]),i+="px",this.hasLostContext=!0),e.backstoreOnly||this._setCssDimension(n,i);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),e.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(t,e){return this.lowerCanvasEl[t]=e,this.upperCanvasEl&&(this.upperCanvasEl[t]=e),this.cacheCanvasEl&&(this.cacheCanvasEl[t]=e),this[t]=e,this},_setCssDimension:function(t,e){return this.lowerCanvasEl.style[t]=e,this.upperCanvasEl&&(this.upperCanvasEl.style[t]=e),this.wrapperEl&&(this.wrapperEl.style[t]=e),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(t){var e,i,n,r=this._activeObject,s=this.backgroundImage,a=this.overlayImage;for(this.viewportTransform=t,i=0,n=this._objects.length;i\n'),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push("\n"),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push(""),i.join("")},_setSVGPreamble:function(t,e){e.suppressPreamble||t.push('\n','\n')},_setSVGHeader:function(t,e){var i,r=e.width||this.width,s=e.height||this.height,a='viewBox="0 0 '+this.width+" "+this.height+'" ',o=T.Object.NUM_FRACTION_DIGITS;e.viewBox?a='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" ':this.svgViewportTransformation&&(i=this.viewportTransform,a='viewBox="'+n(-i[4]/i[0],o)+" "+n(-i[5]/i[3],o)+" "+n(this.width/i[0],o)+" "+n(this.height/i[3],o)+'" '),t.push("\n',"Created with Fabric.js ",T.version,"\n","\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"\n")},createSVGClipPathMarkup:function(t){var e=this.clipPath;return e?(e.clipPathId="CLIPPATH_"+T.Object.__uid++,'\n'+this.clipPath.toClipPathSVG(t.reviver)+"\n"):""},createSVGRefElementsMarkup:function(){var t=this;return["background","overlay"].map((function(e){var i=t[e+"Color"];if(i&&i.toLive){var n=t[e+"Vpt"],r=t.viewportTransform,s={width:t.width/(n?r[0]:1),height:t.height/(n?r[3]:1)};return i.toSVG(s,{additionalTransform:n?T.util.matrixToSVG(r):""})}})).join("")},createSVGFontFacesMarkup:function(){var t,e,i,n,r,s,a,o,l="",h={},c=T.fontPaths,d=[];for(this._objects.forEach((function t(e){d.push(e),e._objects&&e._objects.forEach(t)})),a=0,o=d.length;a',"\n",l,"","\n"].join("")),l},_setSVGObjects:function(t,e){var i,n,r,s=this._objects;for(n=0,r=s.length;n\n")}else t.push('\n")},sendToBack:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(e=(r=s._objects).length;e--;)n=r[e],i(this._objects,n),this._objects.unshift(n);else i(this._objects,t),this._objects.unshift(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(r=s._objects,e=0;e0+h&&(a=s-1,i(this._objects,r),this._objects.splice(a,0,r)),h++;else 0!==(s=this._objects.indexOf(t))&&(a=this._findNewLowerIndex(t,s,e),i(this._objects,t),this._objects.splice(a,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(t,e,i){var n,r;if(i){for(n=e,r=e-1;r>=0;--r)if(t.intersectsWithObject(this._objects[r])||t.isContainedWithinObject(this._objects[r])||this._objects[r].isContainedWithinObject(t)){n=r;break}}else n=e-1;return n},bringForward:function(t,e){if(!t)return this;var n,r,s,a,o,l=this._activeObject,h=0;if(t===l&&"activeSelection"===t.type)for(n=(o=l._objects).length;n--;)r=o[n],(s=this._objects.indexOf(r))"}}),t(T.StaticCanvas.prototype,T.Observable),t(T.StaticCanvas.prototype,T.Collection),t(T.StaticCanvas.prototype,T.DataURLExporter),t(T.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=o();if(!e||!e.getContext)return null;var i=e.getContext("2d");return i&&"setLineDash"===t?void 0!==i.setLineDash:null}}),T.StaticCanvas.prototype.toJSON=T.StaticCanvas.prototype.toObject,T.isLikelyNode&&(T.StaticCanvas.prototype.createPNGStream=function(){var t=a(this.lowerCanvasEl);return t&&t.createPNGStream()},T.StaticCanvas.prototype.createJPEGStream=function(t){var e=a(this.lowerCanvasEl);return e&&e.createJPEGStream(t)})}}(),T.BaseBrush=T.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(t){var e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])},_setShadow:function(){if(this.shadow){var t=this.canvas,e=this.shadow,i=t.contextTop,n=t.getZoom();t&&t._isRetinaScaling()&&(n*=T.devicePixelRatio),i.shadowColor=e.color,i.shadowBlur=e.blur*n,i.shadowOffsetX=e.offsetX*n,i.shadowOffsetY=e.offsetY*n}},needsFullRender:function(){return new T.Color(this.color).getAlpha()<1||!!this.shadow},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0},_isOutSideCanvas:function(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}),T.PencilBrush=T.util.createClass(T.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(t){this.canvas=t,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(t,e,i){var n=e.midPointFrom(i);return t.quadraticCurveTo(e.x,e.y,n.x,n.y),n},onMouseDown:function(t,e){this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],this._prepareForDrawing(t),this._captureDrawingPath(t),this._render())},onMouseMove:function(t,e){if(this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._captureDrawingPath(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var i=this._points,n=i.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(r,i[n-2],i[n-1],!0),r.stroke(),r.restore()}},onMouseUp:function(t){return!this.canvas._isMainEvent(t.e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)},_prepareForDrawing:function(t){var e=new T.Point(t.x,t.y);this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1])||(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),0))},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(t){var e=new T.Point(t.x,t.y);return this._addPoint(e)},_render:function(t){var e,i,n=this._points[0],r=this._points[1];if(t=t||this.canvas.contextTop,this._saveAndTransform(t),t.beginPath(),2===this._points.length&&n.x===r.x&&n.y===r.y){var s=this.width/1e3;n=new T.Point(n.x,n.y),r=new T.Point(r.x,r.y),n.x-=s,r.x+=s}for(t.moveTo(n.x,n.y),e=1,i=this._points.length;e=r&&(a=t[i],o.push(a));return o.push(t[s]),o},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var t=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(t))this.canvas.requestRenderAll();else{var e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}}),T.CircleBrush=T.util.createClass(T.BaseBrush,{width:10,initialize:function(t){this.canvas=t,this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop;this._saveAndTransform(i),this.dot(i,e),i.restore()},dot:function(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()},onMouseDown:function(t){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)},_render:function(){var t,e,i=this.canvas.contextTop,n=this.points;for(this._saveAndTransform(i),t=0,e=n.length;t0&&!this.preserveObjectStacking){e=[],i=[];for(var r=0,s=this._objects.length;r1&&(this._activeObject._objects=i),e.push.apply(e,i)}else e=this._objects;return e},renderAll:function(){!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_normalizePointer:function(t,e){var i=t.calcTransformMatrix(),n=T.util.invertTransform(i),r=this.restorePointerVpt(e);return T.util.transformPoint(r,n)},isTargetTransparent:function(t,e,i){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var n=this._normalizePointer(t,{x:e,y:i}),r=Math.max(t.cacheTranslationX+n.x*t.zoomX,0),s=Math.max(t.cacheTranslationY+n.y*t.zoomY,0);return T.util.isTransparent(t._cacheContext,Math.round(r),Math.round(s),this.targetFindTolerance)}var a=this.contextCache,o=t.selectionBackgroundColor,l=this.viewportTransform;return t.selectionBackgroundColor="",this.clearContext(a),a.save(),a.transform(l[0],l[1],l[2],l[3],l[4],l[5]),t.render(a),a.restore(),t.selectionBackgroundColor=o,T.util.isTransparent(a,e,i,this.targetFindTolerance)},_isSelectionKeyPressed:function(t){return Array.isArray(this.selectionKey)?!!this.selectionKey.find((function(e){return!0===t[e]})):t[this.selectionKey]},_shouldClearSelection:function(t,e){var i=this.getActiveObjects(),n=this._activeObject;return!e||e&&n&&i.length>1&&-1===i.indexOf(e)&&n!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&n&&n!==e},_shouldCenterTransform:function(t,e,i){var n;if(t)return"scale"===e||"scaleX"===e||"scaleY"===e||"resizing"===e?n=this.centeredScaling||t.centeredScaling:"rotate"===e&&(n=this.centeredRotation||t.centeredRotation),n?!i:i},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};return"ml"===e||"tl"===e||"bl"===e?i.x="right":"mr"!==e&&"tr"!==e&&"br"!==e||(i.x="left"),"tl"===e||"mt"===e||"tr"===e?i.y="bottom":"bl"!==e&&"mb"!==e&&"br"!==e||(i.y="top"),i},_getActionFromCorner:function(t,e,i,n){if(!e||!t)return"drag";var r=n.controls[e];return r.getActionName(i,r,n)},_setupCurrentTransform:function(t,i,n){if(i){var r=this.getPointer(t),s=i.__corner,a=i.controls[s],o=n&&s?a.getActionHandler(t,i,a):T.controlsUtils.dragHandler,l=this._getActionFromCorner(n,s,t,i),h=this._getOriginFromCorner(i,s),c=t[this.centeredKey],d={target:i,action:l,actionHandler:o,corner:s,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:r.x-i.left,offsetY:r.y-i.top,originX:h.x,originY:h.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:e(i.angle),width:i.width*i.scaleX,shiftKey:t.shiftKey,altKey:c,original:T.util.saveObjectTransform(i)};this._shouldCenterTransform(i,l,c)&&(d.originX="center",d.originY="center"),d.original.originX=h.x,d.original.originY=h.y,this._currentTransform=d,this._beforeTransform(t)}},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_drawSelection:function(t){var e=this._groupSelector,i=new T.Point(e.ex,e.ey),n=T.util.transformPoint(i,this.viewportTransform),r=new T.Point(e.ex+e.left,e.ey+e.top),s=T.util.transformPoint(r,this.viewportTransform),a=Math.min(n.x,s.x),o=Math.min(n.y,s.y),l=Math.max(n.x,s.x),h=Math.max(n.y,s.y),c=this.selectionLineWidth/2;this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(a,o,l-a,h-o)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,a+=c,o+=c,l-=c,h-=c,T.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(a,o,l-a,h-o))},findTarget:function(t,e){if(!this.skipTargetFind){var n,r,s=this.getPointer(t,!0),a=this._activeObject,o=this.getActiveObjects(),l=i(t),h=o.length>1&&!e||1===o.length;if(this.targets=[],h&&a._findTargetCorner(s,l))return a;if(o.length>1&&!e&&a===this._searchPossibleTargets([a],s))return a;if(1===o.length&&a===this._searchPossibleTargets([a],s)){if(!this.preserveObjectStacking)return a;n=a,r=this.targets,this.targets=[]}var c=this._searchPossibleTargets(this._objects,s);return t[this.altSelectionKey]&&c&&n&&c!==n&&(c=n,this.targets=r),c}},_checkTarget:function(t,e,i){if(e&&e.visible&&e.evented&&e.containsPoint(t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;if(!this.isTargetTransparent(e,i.x,i.y))return!0}},_searchPossibleTargets:function(t,e){for(var i,n,r=t.length;r--;){var s=t[r],a=s.group?this._normalizePointer(s.group,e):e;if(this._checkTarget(a,s,e)){(i=t[r]).subTargetCheck&&i instanceof T.Group&&(n=this._searchPossibleTargets(i._objects,e))&&this.targets.push(n);break}}return i},restorePointerVpt:function(t){return T.util.transformPoint(t,T.util.invertTransform(this.viewportTransform))},getPointer:function(e,i){if(this._absolutePointer&&!i)return this._absolutePointer;if(this._pointer&&i)return this._pointer;var n,r=t(e),s=this.upperCanvasEl,a=s.getBoundingClientRect(),o=a.width||0,l=a.height||0;o&&l||("top"in a&&"bottom"in a&&(l=Math.abs(a.top-a.bottom)),"right"in a&&"left"in a&&(o=Math.abs(a.right-a.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,i||(r=this.restorePointerVpt(r));var h=this.getRetinaScaling();return 1!==h&&(r.x/=h,r.y/=h),n=0===o||0===l?{width:1,height:1}:{width:s.width/o,height:s.height/l},{x:r.x*n.width,y:r.y*n.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),e=this.lowerCanvasEl,i=this.upperCanvasEl;i?i.className="":(i=this._createCanvasElement(),this.upperCanvasEl=i),T.util.addClass(i,"upper-canvas "+t),this.wrapperEl.appendChild(i),this._copyCanvasStyle(e,i),this._applyCanvasStyle(i),this.contextTop=i.getContext("2d")},getTopContext:function(){return this.contextTop},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=T.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),T.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),T.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.width||t.width,i=this.height||t.height;T.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=e,t.height=i,T.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;return t?"activeSelection"===t.type&&t._objects?t._objects.slice(0):[t]:[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,e){var i=!1,n=this.getActiveObjects(),r=[],s=[];t.forEach((function(t){-1===n.indexOf(t)&&(i=!0,t.fire("deselected",{e,target:t}),s.push(t))})),n.forEach((function(n){-1===t.indexOf(n)&&(i=!0,n.fire("selected",{e,target:n}),r.push(n))})),t.length>0&&n.length>0?i&&this.fire("selection:updated",{e,selected:r,deselected:s}):n.length>0?this.fire("selection:created",{e,selected:r}):t.length>0&&this.fire("selection:cleared",{e,deselected:s})},setActiveObject:function(t,e){var i=this.getActiveObjects();return this._setActiveObject(t,e),this._fireSelectionEvents(i,e),this},_setActiveObject:function(t,e){return this._activeObject!==t&&!!this._discardActiveObject(e,t)&&!t.onSelect({e})&&(this._activeObject=t,!0)},_discardActiveObject:function(t,e){var i=this._activeObject;if(i){if(i.onDeselect({e:t,object:e}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var e=this.getActiveObjects(),i=this.getActiveObject();return e.length&&this.fire("before:selection:cleared",{target:i,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(e,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach(function(t){T.util.cleanUpJsdomNode(this[t]),this[t]=void 0}.bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,T.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var e=this._activeObject;e&&e._renderControls(t)},_toObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(t),r=this.callSuper("_toObject",t,e,i);return this._unwindGroupTransformOnObject(t,n),r},_realizeGroupTransformOnObject:function(t){if(t.group&&"activeSelection"===t.group.type&&this._activeObject===t.group){var e={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach((function(i){e[i]=t[i]})),T.util.addTransformToObject(t,this._activeObject.calcOwnMatrix()),e}return null},_unwindGroupTransformOnObject:function(t,e){e&&t.set(e)},_setSVGObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(e);this.callSuper("_setSVGObject",t,e,i),this._unwindGroupTransformOnObject(e,n)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),T.StaticCanvas.prototype.setViewportTransform.call(this,t)}}),T.StaticCanvas)"prototype"!==n&&(T.Canvas[n]=T.StaticCanvas[n])}(),function(){var t=T.util.addListener,e=T.util.removeListener,i={passive:!1};function n(t,e){return t.button&&t.button===e-1}T.util.object.extend(T.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(t,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(t,e){var n=this.upperCanvasEl,r=this._getEventPrefix();t(T.window,"resize",this._onResize),t(n,r+"down",this._onMouseDown),t(n,r+"move",this._onMouseMove,i),t(n,r+"out",this._onMouseOut),t(n,r+"enter",this._onMouseEnter),t(n,"wheel",this._onMouseWheel),t(n,"contextmenu",this._onContextMenu),t(n,"dblclick",this._onDoubleClick),t(n,"dragover",this._onDragOver),t(n,"dragenter",this._onDragEnter),t(n,"dragleave",this._onDragLeave),t(n,"drop",this._onDrop),this.enablePointerEvents||t(n,"touchstart",this._onTouchStart,i),"undefined"!=typeof eventjs&&e in eventjs&&(eventjs[e](n,"gesture",this._onGesture),eventjs[e](n,"drag",this._onDrag),eventjs[e](n,"orientation",this._onOrientationChange),eventjs[e](n,"shake",this._onShake),eventjs[e](n,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(e,"remove");var t=this._getEventPrefix();e(T.document,t+"up",this._onMouseUp),e(T.document,"touchend",this._onTouchEnd,i),e(T.document,t+"move",this._onMouseMove,i),e(T.document,"touchmove",this._onMouseMove,i)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t){this.__onMouseWheel(t)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t}),this._hoveredTarget=null,e&&e.fire("mouseout",{e:t});var i=this;this._hoveredTargets.forEach((function(n){i.fire("mouse:out",{target:e,e:t}),n&&e.fire("mouseout",{e:t})})),this._hoveredTargets=[],this._iTextInstances&&this._iTextInstances.forEach((function(t){t.isEditing&&t.hiddenTextarea.focus()}))},_onMouseEnter:function(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",{target:null,e:t}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onDragOver:function(t){t.preventDefault();var e=this._simpleEventHandler("dragover",t);this._fireEnterLeaveEvents(e,t)},_onDrop:function(t){return this._simpleEventHandler("drop:before",t),this._simpleEventHandler("drop",t)},_onContextMenu:function(t){return this.stopContextMenu&&(t.stopPropagation(),t.preventDefault()),!1},_onDoubleClick:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData(t)},getPointerId:function(t){var e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1},_isMainEvent:function(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)},_onTouchStart:function(n){n.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(n)),this.__onMouseDown(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();t(T.document,"touchend",this._onTouchEnd,i),t(T.document,"touchmove",this._onMouseMove,i),e(r,s+"down",this._onMouseDown)},_onMouseDown:function(n){this.__onMouseDown(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();e(r,s+"move",this._onMouseMove,i),t(T.document,s+"up",this._onMouseUp),t(T.document,s+"move",this._onMouseMove,i)},_onTouchEnd:function(n){if(!(n.touches.length>0)){this.__onMouseUp(n),this._resetTransformEventData(),this.mainTouchId=null;var r=this._getEventPrefix();e(T.document,"touchend",this._onTouchEnd,i),e(T.document,"touchmove",this._onMouseMove,i);var s=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((function(){t(s.upperCanvasEl,r+"down",s._onMouseDown),s._willAddMouseDown=0}),400)}},_onMouseUp:function(n){this.__onMouseUp(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();this._isMainEvent(n)&&(e(T.document,s+"up",this._onMouseUp),e(T.document,s+"move",this._onMouseMove,i),t(r,s+"move",this._onMouseMove,i))},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t){var e=this._activeObject;return!!(!!e!=!!t||e&&t&&e!==t)||(e&&e.isEditing,!1)},__onMouseUp:function(t){var e,i=this._currentTransform,r=this._groupSelector,s=!1,a=!r||0===r.left&&0===r.top;if(this._cacheTransformEventData(t),e=this._target,this._handleEvent(t,"up:before"),n(t,3))this.fireRightClick&&this._handleEvent(t,"up",3,a);else{if(n(t,2))return this.fireMiddleClick&&this._handleEvent(t,"up",2,a),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)this._onMouseUpInDrawingMode(t);else if(this._isMainEvent(t)){if(i&&(this._finalizeCurrentTransform(t),s=i.actionPerformed),!a){var o=e===this._activeObject;this._maybeGroupObjects(t),s||(s=this._shouldRender(e)||!o&&e===this._activeObject)}var l,h;if(e){if(l=e._findTargetCorner(this.getPointer(t,!0),T.util.isTouchEvent(t)),e.selectable&&e!==this._activeObject&&"up"===e.activeOn)this.setActiveObject(e,t),s=!0;else{var c=e.controls[l],d=c&&c.getMouseUpHandler(t,e,c);d&&d(t,i,(h=this.getPointer(t)).x,h.y)}e.isMoving=!1}if(i&&(i.target!==e||i.corner!==l)){var u=i.target&&i.target.controls[i.corner],f=u&&u.getMouseUpHandler(t,e,c);h=h||this.getPointer(t),f&&f(t,i,h.x,h.y)}this._setCursorFromEvent(t,e),this._handleEvent(t,"up",1,a),this._groupSelector=null,this._currentTransform=null,e&&(e.__corner=0),s?this.requestRenderAll():a||this.renderTop()}}},_simpleEventHandler:function(t,e){var i=this.findTarget(e),n=this.targets,r={e,target:i,subTargets:n};if(this.fire(t,r),i&&i.fire(t,r),!n)return i;for(var s=0;s1&&(e=new T.ActiveSelection(i.reverse(),{canvas:this}),this.setActiveObject(e,t))},_collectObjects:function(t){for(var e,i=[],n=this._groupSelector.ex,r=this._groupSelector.ey,s=n+this._groupSelector.left,a=r+this._groupSelector.top,o=new T.Point(v(n,s),v(r,a)),l=new T.Point(y(n,s),y(r,a)),h=!this.selectionFullyContained,c=n===s&&r===a,d=this._objects.length;d--&&!((e=this._objects[d])&&e.selectable&&e.visible&&(h&&e.intersectsWithRect(o,l,!0)||e.isContainedWithinRect(o,l,!0)||h&&e.containsPoint(o,null,!0)||h&&e.containsPoint(l,null,!0))&&(i.push(e),c)););return i.length>1&&(i=i.filter((function(e){return!e.onSelect({e:t})}))),i},_maybeGroupObjects:function(t){this.selection&&this._groupSelector&&this._groupSelectedObjects(t),this.setCursor(this.defaultCursor),this._groupSelector=null}}),T.util.object.extend(T.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,n=(t.multiplier||1)*(t.enableRetinaScaling?this.getRetinaScaling():1),r=this.toCanvasElement(n,t);return T.util.toDataURL(r,e,i)},toCanvasElement:function(t,e){t=t||1;var i=((e=e||{}).width||this.width)*t,n=(e.height||this.height)*t,r=this.getZoom(),s=this.width,a=this.height,o=r*t,l=this.viewportTransform,h=(l[4]-(e.left||0))*t,c=(l[5]-(e.top||0))*t,d=this.interactive,u=[o,0,0,o,h,c],f=this.enableRetinaScaling,g=T.util.createCanvasElement(),m=this.contextTop;return g.width=i,g.height=n,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=u,this.width=i,this.height=n,this.calcViewportBoundaries(),this.renderCanvas(g.getContext("2d"),this._objects),this.viewportTransform=l,this.width=s,this.height=a,this.calcViewportBoundaries(),this.interactive=d,this.enableRetinaScaling=f,this.contextTop=m,g}}),T.util.object.extend(T.StaticCanvas.prototype,{loadFromJSON:function(t,e,i){if(t){var n="string"==typeof t?JSON.parse(t):T.util.object.clone(t),r=this,s=n.clipPath,a=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete n.clipPath,this._enlivenObjects(n.objects,(function(t){r.clear(),r._setBgOverlay(n,(function(){s?r._enlivenObjects([s],(function(i){r.clipPath=i[0],r.__setupCanvas.call(r,n,t,a,e)})):r.__setupCanvas.call(r,n,t,a,e)}))}),i),this}},__setupCanvas:function(t,e,i,n){var r=this;e.forEach((function(t,e){r.insertAt(t,e)})),this.renderOnAddRemove=i,delete t.objects,delete t.backgroundImage,delete t.overlayImage,delete t.background,delete t.overlay,this._setOptions(t),this.renderAll(),n&&n()},_setBgOverlay:function(t,e){var i={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(t.backgroundImage||t.overlayImage||t.background||t.overlay){var n=function(){i.backgroundImage&&i.overlayImage&&i.backgroundColor&&i.overlayColor&&e&&e()};this.__setBgOverlay("backgroundImage",t.backgroundImage,i,n),this.__setBgOverlay("overlayImage",t.overlayImage,i,n),this.__setBgOverlay("backgroundColor",t.background,i,n),this.__setBgOverlay("overlayColor",t.overlay,i,n)}else e&&e()},__setBgOverlay:function(t,e,i,n){var r=this;if(!e)return i[t]=!0,void(n&&n());"backgroundImage"===t||"overlayImage"===t?T.util.enlivenObjects([e],(function(e){r[t]=e[0],i[t]=!0,n&&n()})):this["set"+T.util.string.capitalize(t,!0)](e,(function(){i[t]=!0,n&&n()}))},_enlivenObjects:function(t,e,i){t&&0!==t.length?T.util.enlivenObjects(t,(function(t){e&&e(t)}),null,i):e&&e([])},_toDataURL:function(t,e){this.clone((function(i){e(i.toDataURL(t))}))},_toDataURLWithMultiplier:function(t,e,i){this.clone((function(n){i(n.toDataURLWithMultiplier(t,e))}))},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData((function(e){e.loadFromJSON(i,(function(){t&&t(e)}))}))},cloneWithoutData:function(t){var e=T.util.createCanvasElement();e.width=this.width,e.height=this.height;var i=new T.Canvas(e);this.backgroundImage?(i.setBackgroundImage(this.backgroundImage.src,(function(){i.renderAll(),t&&t(i)})),i.backgroundImageOpacity=this.backgroundImageOpacity,i.backgroundImageStretch=this.backgroundImageStretch):t&&t(i)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,s=e.util.string.capitalize,a=e.util.degreesToRadians,o=!e.isLikelyNode;e.Object||(e.Object=e.util.createClass(e.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:o,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(t){t&&this.setOptions(t)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=e.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(t){var i=e.perfLimitSizeTotal,n=t.width,r=t.height,s=e.maxCacheSideLimit,a=e.minCacheSideLimit;if(n<=s&&r<=s&&n*r<=i)return nc&&(t.zoomX/=n/c,t.width=c,t.capped=!0),r>d&&(t.zoomY/=r/d,t.height=d,t.capped=!0),t},_getCacheCanvasDimensions:function(){var t=this.getTotalObjectScaling(),e=this._getTransformedDimensions(0,0),i=e.x*t.scaleX/this.scaleX,n=e.y*t.scaleY/this.scaleY;return{width:i+2,height:n+2,zoomX:t.scaleX,zoomY:t.scaleY,x:i,y:n}},_updateCacheCanvas:function(){var t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){var i=t._currentTransform.target,n=t._currentTransform.action;if(this===i&&n.slice&&"scale"===n.slice(0,5))return!1}var r,s,a=this._cacheCanvas,o=this._limitCacheSize(this._getCacheCanvasDimensions()),l=e.minCacheSideLimit,h=o.width,c=o.height,d=o.zoomX,u=o.zoomY,f=h!==this.cacheWidth||c!==this.cacheHeight,g=this.zoomX!==d||this.zoomY!==u,m=f||g,p=0,_=0,v=!1;if(f){var y=this._cacheCanvas.width,w=this._cacheCanvas.height,C=h>y||c>w;v=C||(h<.9*y||c<.9*w)&&y>l&&w>l,C&&!o.capped&&(h>l||c>l)&&(p=.1*h,_=.1*c)}return this instanceof e.Text&&this.path&&(m=!0,v=!0,p+=this.getHeightOfLine(0)*this.zoomX,_+=this.getHeightOfLine(0)*this.zoomY),!!m&&(v?(a.width=Math.ceil(h+p),a.height=Math.ceil(c+_)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,a.width,a.height)),r=o.x/2,s=o.y/2,this.cacheTranslationX=Math.round(a.width/2-r)+r,this.cacheTranslationY=Math.round(a.height/2-s)+s,this.cacheWidth=h,this.cacheHeight=c,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(d,u),this.zoomX=d,this.zoomY=u,!0)},setOptions:function(t){this._setOptions(t),this._initGradient(t.fill,"fill"),this._initGradient(t.stroke,"stroke"),this._initPattern(t.fill,"fill"),this._initPattern(t.stroke,"stroke")},transform:function(t){var e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,n={type:this.type,version:e.version,originX:this.originX,originY:this.originY,left:r(this.left,i),top:r(this.top,i),width:r(this.width,i),height:r(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:r(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:r(this.strokeMiterLimit,i),scaleX:r(this.scaleX,i),scaleY:r(this.scaleY,i),angle:r(this.angle,i),flipX:this.flipX,flipY:this.flipY,opacity:r(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:r(this.skewX,i),skewY:r(this.skewY,i)};return this.clipPath&&!this.clipPath.excludeFromExport&&(n.clipPath=this.clipPath.toObject(t),n.clipPath.inverted=this.clipPath.inverted,n.clipPath.absolutePositioned=this.clipPath.absolutePositioned),e.util.populateWithProperties(this,n,t),this.includeDefaultValues||(n=this._removeDefaultValues(n)),n},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype;return i.stateProperties.forEach((function(e){"left"!==e&&"top"!==e&&(t[e]===i[e]&&delete t[e],Array.isArray(t[e])&&Array.isArray(i[e])&&0===t[e].length&&0===i[e].length&&delete t[e])})),t},toString:function(){return"#"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var t=e.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(t.scaleX),scaleY:Math.abs(t.scaleY)}},getTotalObjectScaling:function(){var t=this.getObjectScaling(),e=t.scaleX,i=t.scaleY;if(this.canvas){var n=this.canvas.getZoom(),r=this.canvas.getRetinaScaling();e*=n*r,i*=n*r}return{scaleX:e,scaleY:i}},getObjectOpacity:function(){var t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t},_set:function(t,i){var n="scaleX"===t||"scaleY"===t,r=this[t]!==i,s=!1;return n&&(i=this._constrainScale(i)),"scaleX"===t&&i<0?(this.flipX=!this.flipX,i*=-1):"scaleY"===t&&i<0?(this.flipY=!this.flipY,i*=-1):"shadow"!==t||!i||i instanceof e.Shadow?"dirty"===t&&this.group&&this.group.set("dirty",i):i=new e.Shadow(i),this[t]=i,r&&(s=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(t)>-1?(this.dirty=!0,s&&this.group.set("dirty",!0)):s&&this.stateProperties.indexOf(t)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:e.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible},render:function(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(t),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),t.restore())},renderCache:function(t){t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,t.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this._cacheContext=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth},hasFill:function(){return this.fill&&"transparent"!==this.fill},needsItsOwnCache:function(){return!("stroke"!==this.paintFirst||!this.hasFill()||!this.hasStroke()||"object"!=typeof this.shadow)||!!this.clipPath},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawClipPathOnCache:function(t,i){if(t.save(),i.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",i.absolutePositioned){var n=e.util.invertTransform(this.calcTransformMatrix());t.transform(n[0],n[1],n[2],n[3],n[4],n[5])}i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},drawObject:function(t,e){var i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath),this.fill=i,this.stroke=n},_drawClipPath:function(t,e){e&&(e.canvas=this.canvas,e.shouldCache(),e._transformDone=!0,e.renderCache({forClipping:!0}),this.drawClipPathOnCache(t,e))},drawCacheOnCanvas:function(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(t){if(this.isNotVisible())return!1;if(this._cacheCanvas&&this._cacheContext&&!t&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&this._cacheContext&&!t){var e=this.cacheWidth/this.zoomX,i=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-e/2,-i/2,e,i)}return!0}return!1},_renderBackground:function(t){if(this.backgroundColor){var e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}},_setOpacity:function(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity},_setStrokeStyles:function(t,e){var i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,i.toLive?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)},_setFillStyles:function(t,e){var i=e.fill;i&&(i.toLive?(t.fillStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,e.fill)):t.fillStyle=i)},_setClippingProperties:function(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"},_setLineDash:function(t,e){e&&0!==e.length&&(1&e.length&&e.push.apply(e,e),t.setLineDash(e))},_renderControls:function(t,i){var n,r,s,o=this.getViewportTransform(),l=this.calcTransformMatrix();r=void 0!==(i=i||{}).hasBorders?i.hasBorders:this.hasBorders,s=void 0!==i.hasControls?i.hasControls:this.hasControls,l=e.util.multiplyTransformMatrices(o,l),n=e.util.qrDecompose(l),t.save(),t.translate(n.translateX,n.translateY),t.lineWidth=1*this.borderScaleFactor,this.group||(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(n.angle-=180),t.rotate(a(this.group?n.angle:this.angle)),i.forActiveSelection||this.group?r&&this.drawBordersInGroup(t,n,i):r&&this.drawBorders(t,i),s&&this.drawControls(t,i),t.restore()},_setShadow:function(t){if(this.shadow){var i,n=this.shadow,r=this.canvas,s=r&&r.viewportTransform[0]||1,a=r&&r.viewportTransform[3]||1;i=n.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),r&&r._isRetinaScaling()&&(s*=e.devicePixelRatio,a*=e.devicePixelRatio),t.shadowColor=n.color,t.shadowBlur=n.blur*e.browserShadowBlurConstant*(s+a)*(i.scaleX+i.scaleY)/4,t.shadowOffsetX=n.offsetX*s*i.scaleX,t.shadowOffsetY=n.offsetY*a*i.scaleY}},_removeShadow:function(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)},_applyPatternGradientTransform:function(t,e){if(!e||!e.toLive)return{offsetX:0,offsetY:0};var i=e.gradientTransform||e.patternTransform,n=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,n,r):t.transform(1,0,0,1,n,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:n,offsetY:r}},_renderPaintInOrder:function(t){"stroke"===this.paintFirst?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))},_render:function(){},_renderFill:function(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())},_renderStroke:function(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform&&this.group){var e=this.getObjectScaling();t.scale(1/e.scaleX,1/e.scaleY)}else this.strokeUniform&&t.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}},_applyPatternForTransformedGradient:function(t,i){var n,r=this._limitCacheSize(this._getCacheCanvasDimensions()),s=e.util.createCanvasElement(),a=this.canvas.getRetinaScaling(),o=r.x/this.scaleX/a,l=r.y/this.scaleY/a;s.width=o,s.height=l,(n=s.getContext("2d")).beginPath(),n.moveTo(0,0),n.lineTo(o,0),n.lineTo(o,l),n.lineTo(0,l),n.closePath(),n.translate(o/2,l/2),n.scale(r.zoomX/this.scaleX/a,r.zoomY/this.scaleY/a),this._applyPatternGradientTransform(n,i),n.fillStyle=i.toLive(t),n.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(a*this.scaleX/r.zoomX,a*this.scaleY/r.zoomY),t.strokeStyle=n.createPattern(s,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var t=e.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",t.scaleX),this.set("scaleY",t.scaleY),this.angle=t.angle,this.skewX=t.skewX,this.skewY=0}},_removeTransformMatrix:function(t){var i=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),i=e.util.transformPoint(i,this.transformMatrix)),this.transformMatrix=null,t&&(this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this.cropX=t.cropX,this.cropY=t.cropY,i.x+=t.offsetLeft,i.y+=t.offsetTop,this.width=t.width,this.height=t.height),this.setPositionByOrigin(i,"center","center")},clone:function(t,i){var n=this.toObject(i);this.constructor.fromObject?this.constructor.fromObject(n,t):e.Object._fromObject("Object",n,t)},cloneAsImage:function(t,i){var n=this.toCanvasElement(i);return t&&t(new e.Image(n)),this},toCanvasElement:function(t){t||(t={});var i=e.util,n=i.saveObjectTransform(this),r=this.group,s=this.shadow,a=Math.abs,o=(t.multiplier||1)*(t.enableRetinaScaling?e.devicePixelRatio:1);delete this.group,t.withoutTransform&&i.resetObjectTransform(this),t.withoutShadow&&(this.shadow=null);var l,h,c,d,u=e.util.createCanvasElement(),f=this.getBoundingRect(!0,!0),g=this.shadow,m={x:0,y:0};g&&(h=g.blur,l=g.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),m.x=2*Math.round(a(g.offsetX)+h)*a(l.scaleX),m.y=2*Math.round(a(g.offsetY)+h)*a(l.scaleY)),c=f.width+m.x,d=f.height+m.y,u.width=Math.ceil(c),u.height=Math.ceil(d);var p=new e.StaticCanvas(u,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});"jpeg"===t.format&&(p.backgroundColor="#fff"),this.setPositionByOrigin(new e.Point(p.width/2,p.height/2),"center","center");var _=this.canvas;p.add(this);var v=p.toCanvasElement(o||1,t);return this.shadow=s,this.set("canvas",_),r&&(this.group=r),this.set(n).setCoords(),p._objects=[],p.dispose(),p=null,v},toDataURL:function(t){return t||(t={}),e.util.toDataURL(this.toCanvasElement(t),t.format||"png",t.quality||1)},isType:function(t){return arguments.length>1?Array.from(arguments).includes(this.type):this.type===t},complexity:function(){return 1},toJSON:function(t){return this.toObject(t)},rotate:function(t){var e=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return e&&this._setOriginToCenter(),this.set("angle",t),e&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var n=new e.Point(i.x,i.y),r=this._getLeftTopCoords();return this.angle&&(n=e.util.rotatePoint(n,r,a(-this.angle))),{x:n.x-r.x,y:n.y-r.y}},_setupCompositeOperation:function(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){e.runningAnimations&&e.runningAnimations.cancelByTarget(this)}}),e.util.createAccessors&&e.util.createAccessors(e.Object),i(e.Object.prototype,e.Observable),e.Object.NUM_FRACTION_DIGITS=2,e.Object.ENLIVEN_PROPS=["clipPath"],e.Object._fromObject=function(t,i,r,s){var a=e[t];i=n(i,!0),e.util.enlivenPatterns([i.fill,i.stroke],(function(t){void 0!==t[0]&&(i.fill=t[0]),void 0!==t[1]&&(i.stroke=t[1]),e.util.enlivenObjectEnlivables(i,i,(function(){var t=s?new a(i[s],i):new a(i);r&&r(t)}))}))},e.Object.__uid=0)}(e),w=T.util.degreesToRadians,C={left:-.5,center:0,right:.5},E={top:-.5,center:0,bottom:.5},T.util.object.extend(T.Object.prototype,{translateToGivenOrigin:function(t,e,i,n,r){var s,a,o,l=t.x,h=t.y;return"string"==typeof e?e=C[e]:e-=.5,"string"==typeof n?n=C[n]:n-=.5,"string"==typeof i?i=E[i]:i-=.5,"string"==typeof r?r=E[r]:r-=.5,a=r-i,((s=n-e)||a)&&(o=this._getTransformedDimensions(),l=t.x+s*o.x,h=t.y+a*o.y),new T.Point(l,h)},translateToCenterPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,e,i,"center","center");return this.angle?T.util.rotatePoint(n,t,w(this.angle)):n},translateToOriginPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,"center","center",e,i);return this.angle?T.util.rotatePoint(n,t,w(this.angle)):n},getCenterPoint:function(){var t=new T.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(t,e,i){var n,r,s=this.getCenterPoint();return n=void 0!==e&&void 0!==i?this.translateToGivenOrigin(s,"center","center",e,i):new T.Point(this.left,this.top),r=new T.Point(t.x,t.y),this.angle&&(r=T.util.rotatePoint(r,s,-w(this.angle))),r.subtractEquals(n)},setPositionByOrigin:function(t,e,i){var n=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(n,this.originX,this.originY);this.set("left",r.x),this.set("top",r.y)},adjustPosition:function(t){var e,i,n=w(this.angle),r=this.getScaledWidth(),s=T.util.cos(n)*r,a=T.util.sin(n)*r;e="string"==typeof this.originX?C[this.originX]:this.originX-.5,i="string"==typeof t?C[t]:t-.5,this.left+=s*(i-e),this.top+=a*(i-e),this.setCoords(),this.originX=t},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center",this.originY="center",this.left=t.x,this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=t.x,this.top=t.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}}),function(){var t=T.util,e=t.degreesToRadians,i=t.multiplyTransformMatrices,n=t.transformPoint;t.object.extend(T.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(t,e){return e?t?this.calcACoords():this.calcLineCoords():(this.aCoords&&this.lineCoords||this.setCoords(!0),t?this.aCoords:this.lineCoords)},getCoords:function(t,e){return i=this._getCoords(t,e),[new T.Point(i.tl.x,i.tl.y),new T.Point(i.tr.x,i.tr.y),new T.Point(i.br.x,i.br.y),new T.Point(i.bl.x,i.bl.y)];var i},intersectsWithRect:function(t,e,i,n){var r=this.getCoords(i,n);return"Intersection"===T.Intersection.intersectPolygonRectangle(r,t,e).status},intersectsWithObject:function(t,e,i){return"Intersection"===T.Intersection.intersectPolygonPolygon(this.getCoords(e,i),t.getCoords(e,i)).status||t.isContainedWithinObject(this,e,i)||this.isContainedWithinObject(t,e,i)},isContainedWithinObject:function(t,e,i){for(var n=this.getCoords(e,i),r=e?t.aCoords:t.lineCoords,s=0,a=t._getImageLines(r);s<4;s++)if(!t.containsPoint(n[s],a))return!1;return!0},isContainedWithinRect:function(t,e,i,n){var r=this.getBoundingRect(i,n);return r.left>=t.x&&r.left+r.width<=e.x&&r.top>=t.y&&r.top+r.height<=e.y},containsPoint:function(t,e,i,n){var r=this._getCoords(i,n),s=(e=e||this._getImageLines(r),this._findCrossPoints(t,e));return 0!==s&&s%2==1},isOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.getCoords(!0,t).some((function(t){return t.x<=i.x&&t.x>=e.x&&t.y<=i.y&&t.y>=e.y}))||!!this.intersectsWithRect(e,i,!0,t)||this._containsCenterOfCanvas(e,i,t)},_containsCenterOfCanvas:function(t,e,i){var n={x:(t.x+e.x)/2,y:(t.y+e.y)/2};return!!this.containsPoint(n,null,!0,i)},isPartiallyOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.intersectsWithRect(e,i,!0,t)||this.getCoords(!0,t).every((function(t){return(t.x>=i.x||t.x<=e.x)&&(t.y>=i.y||t.y<=e.y)}))&&this._containsCenterOfCanvas(e,i,t)},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,n,r,s=0;for(var a in e)if(!((r=e[a]).o.y=t.y&&r.d.y>=t.y||(r.o.x===r.d.x&&r.o.x>=t.x?n=r.o.x:(i=(r.d.y-r.o.y)/(r.d.x-r.o.x),n=-(t.y-0*t.x-(r.o.y-i*r.o.x))/(0-i)),n>=t.x&&(s+=1),2!==s)))break;return s},getBoundingRect:function(e,i){var n=this.getCoords(e,i);return t.makeBoundingBoxFromPoints(n)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){return Math.abs(t)\n')}},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})},toClipPathSVG:function(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})},_createBaseClipPathSVGMarkup:function(t,e){var i=(e=e||{}).reviver,n=e.additionalTransform||"",r=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=r,i?i(t.join("")):t.join("")},_createBaseSVGMarkup:function(t,e){var i,n,r=(e=e||{}).noStyle,s=e.reviver,a=r?"":'style="'+this.getSvgStyles()+'" ',o=e.withShadow?'style="'+this.getSvgFilter()+'" ':"",l=this.clipPath,h=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",c=l&&l.absolutePositioned,d=this.stroke,u=this.fill,f=this.shadow,g=[],m=t.indexOf("COMMON_PARTS"),p=e.additionalTransform;return l&&(l.clipPathId="CLIPPATH_"+T.Object.__uid++,n='\n'+l.toClipPathSVG(s)+"\n"),c&&g.push("\n"),g.push("\n"),i=[a,h,r?"":this.addPaintOrder()," ",p?'transform="'+p+'" ':""].join(""),t[m]=i,u&&u.toLive&&g.push(u.toSVG(this)),d&&d.toLive&&g.push(d.toSVG(this)),f&&g.push(f.toSVG(this)),l&&g.push(n),g.push(t.join("")),g.push("\n"),c&&g.push("\n"),s?s(g.join("")):g.join("")},addPaintOrder:function(){return"fill"!==this.paintFirst?' paint-order="'+this.paintFirst+'" ':""}})}(),function(){var t=T.util.object.extend,e="stateProperties";function i(e,i,n){var r={};n.forEach((function(t){r[t]=e[t]})),t(e[i],r,!0)}function n(t,e,i){if(t===e)return!0;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(var r=0,s=t.length;r=0;l--)if(r=o[l],this.isControlVisible(r)&&(n=this._getImageLines(e?this.oCoords[r].touchCorner:this.oCoords[r].corner),0!==(i=this._findCrossPoints({x:s,y:a},n))&&i%2==1))return this.__corner=r,r;return!1},forEachControl:function(t){for(var e in this.controls)t(this.controls[e],e,this)},_setCornerCoords:function(){var t=this.oCoords;for(var e in t){var i=this.controls[e];t[e].corner=i.calcCornerCoords(this.angle,this.cornerSize,t[e].x,t[e].y,!1),t[e].touchCorner=i.calcCornerCoords(this.angle,this.touchCornerSize,t[e].x,t[e].y,!0)}},drawSelectionBackground:function(e){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;e.save();var i=this.getCenterPoint(),n=this._calculateCurrentDimensions(),r=this.canvas.viewportTransform;return e.translate(i.x,i.y),e.scale(1/r[0],1/r[3]),e.rotate(t(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-n.x/2,-n.y/2,n.x,n.y),e.restore(),this},drawBorders:function(t,e){e=e||{};var i=this._calculateCurrentDimensions(),n=this.borderScaleFactor,r=i.x+n,s=i.y+n,a=void 0!==e.hasControls?e.hasControls:this.hasControls,o=!1;return t.save(),t.strokeStyle=e.borderColor||this.borderColor,this._setLineDash(t,e.borderDashArray||this.borderDashArray),t.strokeRect(-r/2,-s/2,r,s),a&&(t.beginPath(),this.forEachControl((function(e,i,n){e.withConnection&&e.getVisibility(n,i)&&(o=!0,t.moveTo(e.x*r,e.y*s),t.lineTo(e.x*r+e.offsetX,e.y*s+e.offsetY))})),o&&t.stroke()),t.restore(),this},drawBordersInGroup:function(t,e,i){i=i||{};var n=T.util.sizeAfterTransform(this.width,this.height,e),r=this.strokeWidth,s=this.strokeUniform,a=this.borderScaleFactor,o=n.x+r*(s?this.canvas.getZoom():e.scaleX)+a,l=n.y+r*(s?this.canvas.getZoom():e.scaleY)+a;return t.save(),this._setLineDash(t,i.borderDashArray||this.borderDashArray),t.strokeStyle=i.borderColor||this.borderColor,t.strokeRect(-o/2,-l/2,o,l),t.restore(),this},drawControls:function(t,e){e=e||{},t.save();var i,n,r=this.canvas.getRetinaScaling();return t.setTransform(r,0,0,r,0,0),t.strokeStyle=t.fillStyle=e.cornerColor||this.cornerColor,this.transparentCorners||(t.strokeStyle=e.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(t,e.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(i=this.group.calcTransformMatrix()),this.forEachControl((function(r,s,a){n=a.oCoords[s],r.getVisibility(a,s)&&(i&&(n=T.util.transformPoint(n,i)),r.render(t,n.x,n.y,e,a))})),t.restore(),this},isControlVisible:function(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)},setControlVisible:function(t,e){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e,this},setControlsVisibility:function(t){for(var e in t||(t={}),t)this.setControlVisible(e,t[e]);return this},onDeselect:function(){},onSelect:function(){}})}(),T.util.object.extend(T.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.left,endValue:this.getCenterPoint().x,duration:this.FX_DURATION,onChange:function(e){t.set("left",e),s.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}})},fxCenterObjectV:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.top,endValue:this.getCenterPoint().y,duration:this.FX_DURATION,onChange:function(e){t.set("top",e),s.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}})},fxRemove:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(e){t.set("opacity",e),s.requestRenderAll(),r()},onComplete:function(){s.remove(t),n()}})}}),T.util.object.extend(T.Object.prototype,{animate:function(){if(arguments[0]&&"object"==typeof arguments[0]){var t,e,i=[],n=[];for(t in arguments[0])i.push(t);for(var r=0,s=i.length;r-1||r&&s.colorProperties.indexOf(r[1])>-1,o=r?this.get(r[0])[r[1]]:this.get(t);"from"in i||(i.from=o),a||(e=~e.indexOf("=")?o+parseFloat(e.replace("=","")):parseFloat(e));var l={target:this,startValue:i.from,endValue:e,byValue:i.by,easing:i.easing,duration:i.duration,abort:i.abort&&function(t,e,n){return i.abort.call(s,t,e,n)},onChange:function(e,a,o){r?s[r[0]][r[1]]=e:s.set(t,e),n||i.onChange&&i.onChange(e,a,o)},onComplete:function(t,e,r){n||(s.setCoords(),i.onComplete&&i.onComplete(t,e,r))}};return a?T.util.animateColor(l.startValue,l.endValue,l.duration,l):T.util.animate(l)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r={x1:1,x2:1,y1:1,y2:1};function s(t,e){var i=t.origin,n=t.axis1,r=t.axis2,s=t.dimension,a=e.nearest,o=e.center,l=e.farthest;return function(){switch(this.get(i)){case a:return Math.min(this.get(n),this.get(r));case o:return Math.min(this.get(n),this.get(r))+.5*this.get(s);case l:return Math.max(this.get(n),this.get(r))}}}e.Line?e.warn("fabric.Line is already defined"):(e.Line=e.util.createClass(e.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:e.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(t,e){t||(t=[0,0,0,0]),this.callSuper("initialize",e),this.set("x1",t[0]),this.set("y1",t[1]),this.set("x2",t[2]),this.set("y2",t[3]),this._setWidthHeight(e)},_setWidthHeight:function(t){t||(t={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in t?t.left:this._getLeftToOriginX(),this.top="top"in t?t.top:this._getTopToOriginY()},_set:function(t,e){return this.callSuper("_set",t,e),void 0!==r[t]&&this._setWidthHeight(),this},_getLeftToOriginX:s({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:s({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(t){t.beginPath();var e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;var i=t.strokeStyle;t.strokeStyle=this.stroke||t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(t){return i(this.callSuper("toObject",t),this.calcLinePoints())},_getNonTransformedDimensions:function(){var t=this.callSuper("_getNonTransformedDimensions");return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t},calcLinePoints:function(){var t=this.x1<=this.x2?-1:1,e=this.y1<=this.y2?-1:1,i=t*this.width*.5,n=e*this.height*.5;return{x1:i,x2:t*this.width*-.5,y1:n,y2:e*this.height*-.5}},_toSVG:function(){var t=this.calcLinePoints();return["\n']}}),e.Line.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),e.Line.fromElement=function(t,n,r){r=r||{};var s=e.parseAttributes(t,e.Line.ATTRIBUTE_NAMES),a=[s.x1||0,s.y1||0,s.x2||0,s.y2||0];n(new e.Line(a,i(s,r)))},e.Line.fromObject=function(t,i){var r=n(t,!0);r.points=[t.x1,t.y1,t.x2,t.y2],e.Object._fromObject("Line",r,(function(t){delete t.points,i&&i(t)}),"points")})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians;e.Circle?e.warn("fabric.Circle is already defined."):(e.Circle=e.util.createClass(e.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:e.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,e){return this.callSuper("_set",t,e),"radius"===t&&this.setRadius(e),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,n=(this.endAngle-this.startAngle)%360;if(0===n)t=["\n'];else{var r=i(this.startAngle),s=i(this.endAngle),a=this.radius;t=['180?"1":"0")+" 1"," "+e.util.cos(s)*a+" "+e.util.sin(s)*a,'" ',"COMMON_PARTS"," />\n"]}return t},_render:function(t){t.beginPath(),t.arc(0,0,this.radius,i(this.startAngle),i(this.endAngle),!1),this._renderPaintInOrder(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",2*t).set("height",2*t)}}),e.Circle.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),e.Circle.fromElement=function(t,i){var n,r=e.parseAttributes(t,e.Circle.ATTRIBUTE_NAMES);if(!("radius"in(n=r)&&n.radius>=0))throw new Error("value of `r` attribute is required and can not be negative");r.left=(r.left||0)-r.radius,r.top=(r.top||0)-r.radius,i(new e.Circle(r))},e.Circle.fromObject=function(t,i){e.Object._fromObject("Circle",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={});e.Triangle?e.warn("fabric.Triangle is already defined"):(e.Triangle=e.util.createClass(e.Object,{type:"triangle",width:100,height:100,_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)},_toSVG:function(){var t=this.width/2,e=this.height/2;return["']}}),e.Triangle.fromObject=function(t,i){return e.Object._fromObject("Triangle",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=2*Math.PI;e.Ellipse?e.warn("fabric.Ellipse is already defined."):(e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this.set("rx",t&&t.rx||0),this.set("ry",t&&t.ry||0)},_set:function(t,e){switch(this.callSuper("_set",t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']},_render:function(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,i,!1),t.restore(),this._renderPaintInOrder(t)}}),e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),e.Ellipse.fromElement=function(t,i){var n=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);n.left=(n.left||0)-n.rx,n.top=(n.top||0)-n.ry,i(new e.Ellipse(n))},e.Ellipse.fromObject=function(t,i){e.Object._fromObject("Ellipse",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Rect?e.warn("fabric.Rect is already defined"):(e.Rect=e.util.createClass(e.Object,{stateProperties:e.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(t){var e=this.rx?Math.min(this.rx,this.width/2):0,i=this.ry?Math.min(this.ry,this.height/2):0,n=this.width,r=this.height,s=-this.width/2,a=-this.height/2,o=0!==e||0!==i,l=.4477152502;t.beginPath(),t.moveTo(s+e,a),t.lineTo(s+n-e,a),o&&t.bezierCurveTo(s+n-l*e,a,s+n,a+l*i,s+n,a+i),t.lineTo(s+n,a+r-i),o&&t.bezierCurveTo(s+n,a+r-l*i,s+n-l*e,a+r,s+n-e,a+r),t.lineTo(s+e,a+r),o&&t.bezierCurveTo(s+l*e,a+r,s,a+r-l*i,s,a+r-i),t.lineTo(s,a+i),o&&t.bezierCurveTo(s,a+l*i,s+l*e,a,s+e,a),t.closePath(),this._renderPaintInOrder(t)},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']}}),e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),e.Rect.fromElement=function(t,n,r){if(!t)return n(null);r=r||{};var s=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);s.left=s.left||0,s.top=s.top||0,s.height=s.height||0,s.width=s.width||0;var a=new e.Rect(i(r?e.util.object.clone(r):{},s));a.visible=a.visible&&a.width>0&&a.height>0,n(a)},e.Rect.fromObject=function(t,i){return e.Object._fromObject("Rect",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.array.min,r=e.util.array.max,s=e.util.toFixed,a=e.util.projectStrokeOnPoints;e.Polyline?e.warn("fabric.Polyline is already defined"):(e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:e.Object.prototype.cacheProperties.concat("points"),initialize:function(t,e){e=e||{},this.points=t||[],this.callSuper("initialize",e),this._setPositionDimensions(e)},_projectStrokeOnPoints:function(){return a(this.points,this,!0)},_setPositionDimensions:function(t){var e,i=this._calcDimensions(t),n=this.exactBoundingBox?this.strokeWidth:0;this.width=i.width-n,this.height=i.height-n,t.fromSVG||(e=this.translateToGivenOrigin({x:i.left-this.strokeWidth/2+n/2,y:i.top-this.strokeWidth/2+n/2},"left","top",this.originX,this.originY)),void 0===t.left&&(this.left=t.fromSVG?i.left:e.x),void 0===t.top&&(this.top=t.fromSVG?i.top:e.y),this.pathOffset={x:i.left+this.width/2+n/2,y:i.top+this.height/2+n/2}},_calcDimensions:function(){var t=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,e=n(t,"x")||0,i=n(t,"y")||0;return{left:e,top:i,width:(r(t,"x")||0)-e,height:(r(t,"y")||0)-i}},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},_toSVG:function(){for(var t=[],i=this.pathOffset.x,n=this.pathOffset.y,r=e.Object.NUM_FRACTION_DIGITS,a=0,o=this.points.length;a\n']},commonRender:function(t){var e,i=this.points.length,n=this.pathOffset.x,r=this.pathOffset.y;if(!i||isNaN(this.points[i-1].y))return!1;t.beginPath(),t.moveTo(this.points[0].x-n,this.points[0].y-r);for(var s=0;s"},toObject:function(t){return r(this.callSuper("toObject",t),{path:this.path.map((function(t){return t.slice()}))})},toDatalessObject:function(t){var e=this.toObject(["sourcePath"].concat(t));return e.sourcePath&&delete e.path,e},_toSVG:function(){return["\n"]},_getOffsetTransform:function(){var t=e.Object.NUM_FRACTION_DIGITS;return" translate("+a(-this.pathOffset.x,t)+", "+a(-this.pathOffset.y,t)+")"},toClipPathSVG:function(t){var e=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},toSVG:function(t){var e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var t,r,s=[],a=[],o=0,l=0,h=0,c=0,d=0,u=this.path.length;d"},addWithUpdate:function(t){var i=!!this.group;return this._restoreObjectsState(),e.util.resetObjectTransform(this),t&&(i&&e.util.removeTransformFromObject(t,this.group.calcTransformMatrix()),this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,i?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,i){var n=this._objects.length;if(this.useSetOnGroup)for(;n--;)this._objects[n].setOnGroup(t,i);if("canvas"===t)for(;n--;)this._objects[n]._set(t,i);e.Object.prototype._set.call(this,t,i)},toObject:function(t){var i=this.includeDefaultValues,n=this._objects.filter((function(t){return!t.excludeFromExport})).map((function(e){var n=e.includeDefaultValues;e.includeDefaultValues=i;var r=e.toObject(t);return e.includeDefaultValues=n,r})),r=e.Object.prototype.toObject.call(this,t);return r.objects=n,r},toDatalessObject:function(t){var i,n=this.sourcePath;if(n)i=n;else{var r=this.includeDefaultValues;i=this._objects.map((function(e){var i=e.includeDefaultValues;e.includeDefaultValues=r;var n=e.toDatalessObject(t);return e.includeDefaultValues=i,n}))}var s=e.Object.prototype.toDatalessObject.call(this,t);return s.objects=i,s},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=e.Object.prototype.shouldCache.call(this);if(t)for(var i=0,n=this._objects.length;i\n"],i=0,n=this._objects.length;i\n"),e},getSvgStyles:function(){var t=void 0!==this.opacity&&1!==this.opacity?"opacity: "+this.opacity+";":"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")},toClipPathSVG:function(t){for(var e=[],i=0,n=this._objects.length;i"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",t,e),void 0===(i=i||{}).hasControls&&(i.hasControls=!1),i.forActiveSelection=!0;for(var n=0,r=this._objects.length;n\n','\t\n',"\n"),a=' clip-path="url(#imageCrop_'+l+')" '}if(this.imageSmoothing||(o='" image-rendering="optimizeSpeed'),i.push("\t\n"),this.stroke||this.strokeDashArray){var h=this.fill;this.fill=null,t=["\t\n'],this.fill=h}return"fill"!==this.paintFirst?e.concat(t,i):e.concat(i,t)},getSrc:function(t){var e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src"):e.src:this.src||""},setSrc:function(t,e,i){return T.util.loadImage(t,(function(t,n){this.setElement(t,i),this._setWidthHeight(),e&&e(this,n)}),this,i&&i.crossOrigin),this},toString:function(){return'#'},applyResizeFilters:function(){var t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),n=i.scaleX,r=i.scaleY,s=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||n>e&&r>e)return this._element=s,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=n,void(this._lastScaleY=r);T.filterBackend||(T.filterBackend=T.initFilterBackend());var a=T.util.createCanvasElement(),o=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,l=s.width,h=s.height;a.width=l,a.height=h,this._element=a,this._lastScaleX=t.scaleX=n,this._lastScaleY=t.scaleY=r,T.filterBackend.applyFilters([t],s,l,h,this._element,o),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height},applyFilters:function(t){if(t=(t=t||this.filters||[]).filter((function(t){return t&&!t.isNeutralState()})),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),0===t.length)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var e=this._originalElement,i=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(this._element===this._originalElement){var r=T.util.createCanvasElement();r.width=i,r.height=n,this._element=r,this._filteredEl=r}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,n),this._lastScaleX=1,this._lastScaleY=1;return T.filterBackend||(T.filterBackend=T.initFilterBackend()),T.filterBackend.applyFilters(t,this._originalElement,i,n,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(t){T.util.setImageSmoothing(t,this.imageSmoothing),!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)},drawCacheOnCanvas:function(t){T.util.setImageSmoothing(t,this.imageSmoothing),T.Object.prototype.drawCacheOnCanvas.call(this,t)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(t){var e=this._element;if(e){var i=this._filterScalingX,n=this._filterScalingY,r=this.width,s=this.height,a=Math.min,o=Math.max,l=o(this.cropX,0),h=o(this.cropY,0),c=e.naturalWidth||e.width,d=e.naturalHeight||e.height,u=l*i,f=h*n,g=a(r*i,c-u),m=a(s*n,d-f),p=-r/2,_=-s/2,v=a(r,c/i-l),y=a(s,d/n-h);e&&t.drawImage(e,u,f,g,m,p,_,v,y)}},_needsResize:function(){var t=this.getTotalObjectScaling();return t.scaleX!==this._lastScaleX||t.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(t,e){this.setElement(T.util.getById(t),e),T.util.addClass(this.getElement(),T.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={}),this.setOptions(t),this._setWidthHeight(t)},_initFilters:function(t,e){t&&t.length?T.util.enlivenObjects(t,(function(t){e&&e(t)}),"fabric.Image.filters"):e&&e()},_setWidthHeight:function(t){t||(t={});var e=this.getElement();this.width=t.width||e.naturalWidth||e.width||0,this.height=t.height||e.naturalHeight||e.height||0},parsePreserveAspectRatioAttribute:function(){var t,e=T.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),i=this._element.width,n=this._element.height,r=1,s=1,a=0,o=0,l=0,h=0,c=this.width,d=this.height,u={width:c,height:d};return!e||"none"===e.alignX&&"none"===e.alignY?(r=c/i,s=d/n):("meet"===e.meetOrSlice&&(t=(c-i*(r=s=T.util.findScaleToFit(this._element,u)))/2,"Min"===e.alignX&&(a=-t),"Max"===e.alignX&&(a=t),t=(d-n*s)/2,"Min"===e.alignY&&(o=-t),"Max"===e.alignY&&(o=t)),"slice"===e.meetOrSlice&&(t=i-c/(r=s=T.util.findScaleToCover(this._element,u)),"Mid"===e.alignX&&(l=t/2),"Max"===e.alignX&&(l=t),t=n-d/s,"Mid"===e.alignY&&(h=t/2),"Max"===e.alignY&&(h=t),i=c/r,n=d/s)),{width:i,height:n,scaleX:r,scaleY:s,offsetLeft:a,offsetTop:o,cropX:l,cropY:h}}}),T.Image.CSS_CANVAS="canvas-img",T.Image.prototype.getSvgSrc=T.Image.prototype.getSrc,T.Image.fromObject=function(t,e){var i=T.util.object.clone(t);T.util.loadImage(i.src,(function(t,n){n?e&&e(null,!0):T.Image.prototype._initFilters.call(i,i.filters,(function(n){i.filters=n||[],T.Image.prototype._initFilters.call(i,[i.resizeFilter],(function(n){i.resizeFilter=n[0],T.util.enlivenObjectEnlivables(i,i,(function(){var n=new T.Image(t,i);e(n,!1)}))}))}))}),null,i.crossOrigin)},T.Image.fromURL=function(t,e,i){T.util.loadImage(t,(function(t,n){e&&e(new T.Image(t,i),n)}),null,i&&i.crossOrigin)},T.Image.ATTRIBUTE_NAMES=T.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),T.Image.fromElement=function(t,i,n){var r=T.parseAttributes(t,T.Image.ATTRIBUTE_NAMES);T.Image.fromURL(r["xlink:href"],i,e(n?T.util.object.clone(n):{},r))})}(e),T.util.object.extend(T.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.angle%360;return t>0?90*Math.round((t-1)/90):90*Math.round(t/90)},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(t){var e=function(){},i=(t=t||{}).onComplete||e,n=t.onChange||e,r=this;return T.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){r.rotate(t),n()},onComplete:function(){r.setCoords(),i()}})}}),T.util.object.extend(T.StaticCanvas.prototype,{straightenObject:function(t){return t.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(t){return t.fxStraighten({onChange:this.requestRenderAllBound})}}),function(){function t(t,e){var i="precision "+e+" float;\nvoid main(){}",n=t.createShader(t.FRAGMENT_SHADER);return t.shaderSource(n,i),t.compileShader(n),!!t.getShaderParameter(n,t.COMPILE_STATUS)}function e(t){t&&t.tileSize&&(this.tileSize=t.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}T.isWebglSupported=function(e){if(T.isLikelyNode)return!1;e=e||T.WebglFilterBackend.prototype.tileSize;var i=document.createElement("canvas"),n=i.getContext("webgl")||i.getContext("experimental-webgl"),r=!1;if(n){T.maxTextureSize=n.getParameter(n.MAX_TEXTURE_SIZE),r=T.maxTextureSize>=e;for(var s=["highp","mediump","lowp"],a=0;a<3;a++)if(t(n,s[a])){T.webGlPrecision=s[a];break}}return this.isSupported=r,r},T.WebglFilterBackend=e,e.prototype={tileSize:2048,resources:{},setupGLContext:function(t,e){this.dispose(),this.createWebGLCanvas(t,e),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(t,e)},chooseFastestCopyGLTo2DMethod:function(t,e){var i,n=void 0!==window.performance;try{new ImageData(1,1),i=!0}catch(t){i=!1}var r="undefined"!=typeof ArrayBuffer,s="undefined"!=typeof Uint8ClampedArray;if(n&&i&&r&&s){var a=T.util.createCanvasElement(),o=new ArrayBuffer(t*e*4);if(T.forceGLPutImageData)return this.imageBuffer=o,void(this.copyGLTo2D=x);var l,h,c={imageBuffer:o,destinationWidth:t,destinationHeight:e,targetCanvas:a};a.width=t,a.height=e,l=window.performance.now(),I.call(c,this.gl,c),h=window.performance.now()-l,l=window.performance.now(),x.call(c,this.gl,c),h>window.performance.now()-l?(this.imageBuffer=o,this.copyGLTo2D=x):this.copyGLTo2D=I}},createWebGLCanvas:function(t,e){var i=T.util.createCanvasElement();i.width=t,i.height=e;var n={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},r=i.getContext("webgl",n);r||(r=i.getContext("experimental-webgl",n)),r&&(r.clearColor(0,0,0,0),this.canvas=i,this.gl=r)},applyFilters:function(t,e,i,n,r,s){var a,o=this.gl;s&&(a=this.getCachedTexture(s,e));var l={originalWidth:e.width||e.originalWidth,originalHeight:e.height||e.originalHeight,sourceWidth:i,sourceHeight:n,destinationWidth:i,destinationHeight:n,context:o,sourceTexture:this.createTexture(o,i,n,!a&&e),targetTexture:this.createTexture(o,i,n),originalTexture:a||this.createTexture(o,i,n,!a&&e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},h=o.createFramebuffer();return o.bindFramebuffer(o.FRAMEBUFFER,h),t.forEach((function(t){t&&t.applyTo(l)})),function(t){var e=t.targetCanvas,i=e.width,n=e.height,r=t.destinationWidth,s=t.destinationHeight;i===r&&n===s||(e.width=r,e.height=s)}(l),this.copyGLTo2D(o,l),o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(l.sourceTexture),o.deleteTexture(l.targetTexture),o.deleteFramebuffer(h),r.getContext("2d").setTransform(1,0,0,1,0,0),l},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(t,e,i,n){var r=t.createTexture();return t.bindTexture(t.TEXTURE_2D,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,i,0,t.RGBA,t.UNSIGNED_BYTE,null),r},getCachedTexture:function(t,e){if(this.textureCache[t])return this.textureCache[t];var i=this.createTexture(this.gl,e.width,e.height,e);return this.textureCache[t]=i,i},evictCachesForKey:function(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])},copyGLTo2D:I,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var t=this.gl,e={renderer:"",vendor:""};if(!t)return e;var i=t.getExtension("WEBGL_debug_renderer_info");if(i){var n=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);n&&(e.renderer=n.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}}(),function(){var t=function(){};function e(){}T.Canvas2dFilterBackend=e,e.prototype={evictCachesForKey:t,dispose:t,clearWebGLCaches:t,resources:{},applyFilters:function(t,e,i,n,r){var s=r.getContext("2d");s.drawImage(e,0,0,i,n);var a={sourceWidth:i,sourceHeight:n,imageData:s.getImageData(0,0,i,n),originalEl:e,originalImageData:s.getImageData(0,0,i,n),canvasEl:r,ctx:s,filterBackend:this};return t.forEach((function(t){t.applyTo(a)})),a.imageData.width===i&&a.imageData.height===n||(r.width=a.imageData.width,r.height=a.imageData.height),s.putImageData(a.imageData,0,0),a}}}(),T.Image=T.Image||{},T.Image.filters=T.Image.filters||{},T.Image.filters.BaseFilter=T.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(t){t&&this.setOptions(t)},setOptions:function(t){for(var e in t)this[e]=t[e]},createProgram:function(t,e,i){e=e||this.fragmentSource,i=i||this.vertexSource,"highp"!==T.webGlPrecision&&(e=e.replace(/precision highp float/g,"precision "+T.webGlPrecision+" float"));var n=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+t.getShaderInfoLog(n));var r=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+t.getShaderInfoLog(r));var s=t.createProgram();if(t.attachShader(s,n),t.attachShader(s,r),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+t.getProgramInfoLog(s));var a=this.getAttributeLocations(t,s),o=this.getUniformLocations(t,s)||{};return o.uStepW=t.getUniformLocation(s,"uStepW"),o.uStepH=t.getUniformLocation(s,"uStepH"),{program:s,attributeLocations:a,uniformLocations:o}},getAttributeLocations:function(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(t,e,i){var n=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)},_setupFrameBuffer:function(t){var e,i,n=t.context;t.passes>1?(e=t.destinationWidth,i=t.destinationHeight,t.sourceWidth===e&&t.sourceHeight===i||(n.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(n,e,i)),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t.targetTexture,0)):(n.bindFramebuffer(n.FRAMEBUFFER,null),n.finish())},_swapTextures:function(t){t.passes--,t.pass++;var e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e},isNeutralState:function(){var t=this.mainParameter,e=T.Image.filters[this.type].prototype;if(t){if(Array.isArray(e[t])){for(var i=e[t].length;i--;)if(this[t][i]!==e[t][i])return!1;return!0}return e[t]===this[t]}return!1},applyTo:function(t){t.webgl?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},retrieveShader:function(t){return t.programCache.hasOwnProperty(this.type)||(t.programCache[this.type]=this.createProgram(t.context)),t.programCache[this.type]},applyToWebGL:function(t){var e=t.context,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)},unbindAdditionalTexture:function(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(t){this[this.mainParameter]=t},sendUniformData:function(){},createHelpLayer:function(t){if(!t.helpLayer){var e=document.createElement("canvas");e.width=t.sourceWidth,e.height=t.sourceHeight,t.helpLayer=e}},toObject:function(){var t={type:this.type},e=this.mainParameter;return e&&(t[e]=this[e]),t},toJSON:function(){return this.toObject()}}),T.Image.filters.BaseFilter.fromObject=function(t,e){var i=new T.Image.filters[t.type](t);return e&&e(i),i},function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.ColorMatrix=n(i.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var e,i,n,r,s,a=t.imageData.data,o=a.length,l=this.matrix,h=this.colorsOnly;for(s=0;s=w||a<0||a>=y||(l=4*(o*y+a),h=p[f*_+u],e+=m[l]*h,i+=m[l+1]*h,n+=m[l+2]*h,S||(r+=m[l+3]*h));E[s]=e,E[s+1]=i,E[s+2]=n,E[s+3]=S?m[s+3]:r}t.imageData=C},getUniformLocations:function(t,e){return{uMatrix:t.getUniformLocation(e,"uMatrix"),uOpaque:t.getUniformLocation(e,"uOpaque"),uHalfSize:t.getUniformLocation(e,"uHalfSize"),uSize:t.getUniformLocation(e,"uSize")}},sendUniformData:function(t,e){t.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),e.Image.filters.Convolute.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Grayscale=n(i.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(t){var e,i,n=t.imageData.data,r=n.length,s=this.mode;for(e=0;eh[0]&&r>h[1]&&s>h[2]&&n 0.0) {\n"+this.fragmentSource[t]+"}\n}"},retrieveShader:function(t){var e,i=this.type+"_"+this.mode;return t.programCache.hasOwnProperty(i)||(e=this.buildSource(this.mode),t.programCache[i]=this.createProgram(t.context,e)),t.programCache[i]},applyTo2d:function(t){var i,n,r,s,a,o,l,h=t.imageData.data,c=h.length,d=1-this.alpha;i=(l=new e.Color(this.color).getSource())[0]*this.alpha,n=l[1]*this.alpha,r=l[2]*this.alpha;for(var u=0;u=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;var i=(e*=Math.PI)/t;return o(e)/e*o(i)/i}},applyTo2d:function(t){var e=t.imageData,i=this.scaleX,n=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/n;var r,s=e.width,o=e.height,l=a(s*i),h=a(o*n);"sliceHack"===this.resizeType?r=this.sliceByTwo(t,s,o,l,h):"hermite"===this.resizeType?r=this.hermiteFastResize(t,s,o,l,h):"bilinear"===this.resizeType?r=this.bilinearFiltering(t,s,o,l,h):"lanczos"===this.resizeType&&(r=this.lanczosResize(t,s,o,l,h)),t.imageData=r},sliceByTwo:function(t,i,r,s,a){var o,l,h=t.imageData,c=.5,d=!1,u=!1,f=i*c,g=r*c,m=e.filterBackend.resources,p=0,_=0,v=i,y=0;for(m.sliceByTwo||(m.sliceByTwo=document.createElement("canvas")),((o=m.sliceByTwo).width<1.5*i||o.height=e)){M=n(1e3*s(T-C.x)),w[M]||(w[M]={});for(var F=E.y-y;F<=E.y+y;F++)F<0||F>=a||(L=n(1e3*s(F-C.y)),w[M][L]||(w[M][L]=f(r(i(M*p,2)+i(L*_,2))/1e3)),(b=w[M][L])>0&&(x+=b,R+=b*c[I=4*(F*e+T)],O+=b*c[I+1],A+=b*c[I+2],D+=b*c[I+3]))}u[I=4*(S*o+l)]=R/x,u[I+1]=O/x,u[I+2]=A/x,u[I+3]=D/x}return++l1&&L<-1||(y=2*L*L*L-3*L*L+1)>0&&(b+=y*f[3+(M=4*(D+x*e))],C+=y,f[M+3]<255&&(y=y*f[M+3]/250),E+=y*f[M],S+=y*f[M+1],T+=y*f[M+2],w+=y)}m[v]=E/w,m[v+1]=S/w,m[v+2]=T/w,m[v+3]=b/C}return g},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),e.Image.filters.Resize.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Contrast=n(i.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(t){if(0!==this.contrast){var e,i=t.imageData.data,n=i.length,r=Math.floor(255*this.contrast),s=259*(r+255)/(255*(259-r));for(e=0;e1&&(e=1/this.aspectRatio):this.aspectRatio<1&&(e=this.aspectRatio),t=e*this.blur*.12,this.horizontal?i[0]=t:i[1]=t,i}}),i.Blur.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Gamma=n(i.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],i.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var e,i=t.imageData.data,n=this.gamma,r=i.length,s=1/n[0],a=1/n[1],o=1/n[2];for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),e=0,r=256;e'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t},_render:function(t){var e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){"stroke"===this.paintFirst?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,e,i){if(t.textBaseline="alphabetical",this.path)switch(this.pathAlign){case"center":t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline="bottom"}t.font=this._getFontDeclaration(e,i)},calcTextWidth:function(){for(var t=this.getLineWidth(0),e=1,i=this._textLines.length;et&&(t=n)}return t},_renderTextLine:function(t,e,i,n,r,s){this._renderChars(t,e,i,n,r,s)},_renderTextLinesBackground:function(t){if(this.textBackgroundColor||this.styleHas("textBackgroundColor")){for(var e,i,n,r,s,a,o,l=t.fillStyle,h=this._getLeftOffset(),c=this._getTopOffset(),d=0,u=0,f=this.path,g=0,m=this._textLines.length;g=0:io?d%=o:d<0&&(d+=o),this._setGraphemeOnPath(d,s,a),d+=s.kernedWidth}return{width:l,numOfSpaces:0}},_setGraphemeOnPath:function(t,i,n){var r=t+i.kernedWidth/2,s=this.path,a=e.util.getPointOnPath(s.path,r,s.segmentsInfo);i.renderLeft=a.x-n.x,i.renderTop=a.y-n.y,i.angle=a.angle+("right"===this.pathSide?Math.PI:0)},_getGraphemeBox:function(t,e,i,n,r){var s,a=this.getCompleteStyleDeclaration(e,i),o=n?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,a,n,o),h=l.kernedWidth,c=l.width;0!==this.charSpacing&&(c+=s=this._getWidthOfCharSpacing(),h+=s);var d={width:c,left:0,height:a.fontSize,kernedWidth:h,deltaY:a.deltaY};if(i>0&&!r){var u=this.__charBounds[e][i-1];d.left=u.left+u.width+l.kernedWidth-l.width}return d},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var e=this._textLines[t],i=this.getHeightOfChar(t,0),n=1,r=e.length;n0){var x=v+s+d;"rtl"===this.direction&&(x=this.width-x-u),h&&_&&(t.fillStyle=_,t.fillRect(x,c+E*n+a,u,this.fontSize/15)),d=f.left,u=f.width,h=g,_=p,n=r,a=o}else u+=f.kernedWidth;x=v+s+d,"rtl"===this.direction&&(x=this.width-x-u),t.fillStyle=p,g&&p&&t.fillRect(x,c+E*n+a,u-C,this.fontSize/15),y+=i}else y+=i;this._removeShadow(t)}},_getFontDeclaration:function(t,i){var n=t||this,r=this.fontFamily,s=e.Text.genericFonts.indexOf(r.toLowerCase())>-1,a=void 0===r||r.indexOf("'")>-1||r.indexOf(",")>-1||r.indexOf('"')>-1||s?n.fontFamily:'"'+n.fontFamily+'"';return[e.isLikelyNode?n.fontWeight:n.fontStyle,e.isLikelyNode?n.fontStyle:n.fontWeight,i?this.CACHE_FONT_SIZE+"px":n.fontSize+"px",a].join(" ")},render:function(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t)))},_splitTextIntoLines:function(t){for(var i=t.split(this._reNewline),n=new Array(i.length),r=["\n"],s=[],a=0;a-1&&(t.underline=!0),t.textDecoration.indexOf("line-through")>-1&&(t.linethrough=!0),t.textDecoration.indexOf("overline")>-1&&(t.overline=!0),delete t.textDecoration)}T.IText=T.util.createClass(T.Text,T.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(t,e){this.callSuper("initialize",t,e),this.initBehavior()},setSelectionStart:function(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)},setSelectionEnd:function(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)},_updateAndFire:function(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(t){this.clearContextTop(),this.callSuper("render",t),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(t){this.callSuper("_render",t)},clearContextTop:function(t){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var e=this.canvas.contextTop,i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e),this._clearTextArea(e),t||e.restore()}},renderCursorOrSelection:function(){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var t=this._getCursorBoundaries(),e=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(t,e):this.renderSelection(t,e),e.restore()}},_clearTextArea:function(t){var e=this.width+4,i=this.height+4;t.clearRect(-e/2,-i/2,e,i)},_getCursorBoundaries:function(t){void 0===t&&(t=this.selectionStart);var e=this._getLeftOffset(),i=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t);return{left:e,top:i,leftOffset:n.left,topOffset:n.top}},_getCursorBoundariesOffsets:function(t){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var e,i,n,r,s=0,a=0,o=this.get2DCursorLocation(t);n=o.charIndex,i=o.lineIndex;for(var l=0;l0?a:0)},"rtl"===this.direction&&(r.left*=-1),this.cursorOffsetCache=r,this.cursorOffsetCache},renderCursor:function(t,e){var i=this.get2DCursorLocation(),n=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,s=this.getValueOfPropertyAt(n,r,"fontSize"),a=this.scaleX*this.canvas.getZoom(),o=this.cursorWidth/a,l=t.topOffset,h=this.getValueOfPropertyAt(n,r,"deltaY");l+=(1-this._fontSizeFraction)*this.getHeightOfLine(n)/this.lineHeight-s*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(t,e),e.fillStyle=this.cursorColor||this.getValueOfPropertyAt(n,r,"fill"),e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,e.fillRect(t.left+t.leftOffset-o/2,l+t.top+h,o,s)},renderSelection:function(t,e){for(var i=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,n=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,r=-1!==this.textAlign.indexOf("justify"),s=this.get2DCursorLocation(i),a=this.get2DCursorLocation(n),o=s.lineIndex,l=a.lineIndex,h=s.charIndex<0?0:s.charIndex,c=a.charIndex<0?0:a.charIndex,d=o;d<=l;d++){var u,f=this._getLineLeftOffset(d)||0,g=this.getHeightOfLine(d),m=0,p=0;if(d===o&&(m=this.__charBounds[o][h].left),d>=o&&d1)&&(g/=this.lineHeight);var v=t.left+f+m,y=p-m,w=g,C=0;this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",w=1,C=g):e.fillStyle=this.selectionColor,"rtl"===this.direction&&(v=this.width-v-y),e.fillRect(v,t.top+t.topOffset+C,y,w),t.topOffset+=u}},getCurrentCharFontSize:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")},getCurrentCharColor:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fill")},_getCurrentCharIndex:function(){var t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}}),T.IText.fromObject=function(e,i){if(t(e),e.styles)for(var n in e.styles)for(var r in e.styles[n])t(e.styles[n][r]);T.Object._fromObject("IText",e,i,"text")}}(),S=T.util.object.clone,T.util.object.extend(T.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var t=this;this.on("added",(function(){var e=t.canvas;e&&(e._hasITextHandlers||(e._hasITextHandlers=!0,t._initCanvasHandlers(e)),e._iTextInstances=e._iTextInstances||[],e._iTextInstances.push(t))}))},initRemovedHandler:function(){var t=this;this.on("removed",(function(){var e=t.canvas;e&&(e._iTextInstances=e._iTextInstances||[],T.util.removeFromArray(e._iTextInstances,t),0===e._iTextInstances.length&&(e._hasITextHandlers=!1,t._removeCanvasHandlers(e)))}))},_initCanvasHandlers:function(t){t._mouseUpITextHandler=function(){t._iTextInstances&&t._iTextInstances.forEach((function(t){t.__isMousedown=!1}))},t.on("mouse:up",t._mouseUpITextHandler)},_removeCanvasHandlers:function(t){t.off("mouse:up",t._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,n){var r;return r={isAborted:!1,abort:function(){this.isAborted=!0}},t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){r.isAborted||t[n]()},onChange:function(){t.canvas&&t.selectionStart===t.selectionEnd&&t.renderCursorOrSelection()},abort:function(){return r.isAborted}}),r},_onTickComplete:function(){var t=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout((function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")}),100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout((function(){e._tick()}),i)},abortCursorAnimation:function(){var t=this._currentTickState||this._currentTickCompleteState,e=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,t&&e&&e.clearContext(e.contextTop||e.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i-1;)e++,i--;return t-e},findLineBoundaryRight:function(t){for(var e=0,i=t;!/\n/.test(this._text[i])&&i0&&nthis.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=e):(this.selectionStart=e,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===n||(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(t,e,i){var n=i.slice(0,t),r=T.util.string.graphemeSplit(n).length;if(t===e)return{selectionStart:r,selectionEnd:r};var s=i.slice(t,e);return{selectionStart:r,selectionEnd:r+T.util.string.graphemeSplit(s).length}},fromGraphemeToStringSelection:function(t,e,i){var n=i.slice(0,t).join("").length;return t===e?{selectionStart:n,selectionEnd:n}:{selectionStart:n,selectionEnd:n+i.slice(t,e).join("").length}},_updateTextarea:function(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){var t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var t=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=t.selectionEnd,this.inCompositionMode||(this.selectionStart=t.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),n=i.lineIndex,r=i.charIndex,s=this.getValueOfPropertyAt(n,r,"fontSize")*this.lineHeight,a=e.leftOffset,o=this.calcTransformMatrix(),l={x:e.left+a,y:e.top+e.topOffset+s},h=this.canvas.getRetinaScaling(),c=this.canvas.upperCanvasEl,d=c.width/h,u=c.height/h,f=d-s,g=u-s,m=c.clientWidth/d,p=c.clientHeight/u;return l=T.util.transformPoint(l,o),(l=T.util.transformPoint(l,this.canvas.viewportTransform)).x*=m,l.y*=p,l.x<0&&(l.x=0),l.x>f&&(l.x=f),l.y<0&&(l.y=0),l.y>g&&(l.y=g),l.x+=this.canvas._offset.left,l.y+=this.canvas._offset.top,{left:l.x+"px",top:l.y+"px",fontSize:s+"px",charHeight:s}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var t=this._textBeforeEdit!==this.text,e=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var t in this.styles)this._textLines[t]||delete this.styles[t]},removeStyleFromTo:function(t,e){var i,n,r=this.get2DCursorLocation(t,!0),s=this.get2DCursorLocation(e,!0),a=r.lineIndex,o=r.charIndex,l=s.lineIndex,h=s.charIndex;if(a!==l){if(this.styles[a])for(i=o;i=h&&(n[c-u]=n[d],delete n[d])}},shiftLineStyles:function(t,e){var i=S(this.styles);for(var n in this.styles){var r=parseInt(n,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}},restartCursorIfNeeded:function(){this._currentTickState&&!this._currentTickState.isAborted&&this._currentTickCompleteState&&!this._currentTickCompleteState.isAborted||this.initDelayedCursor()},insertNewlineStyleObject:function(t,e,i,n){var r,s={},a=!1,o=this._unwrappedTextLines[t].length===e;for(var l in i||(i=1),this.shiftLineStyles(t,i),this.styles[t]&&(r=this.styles[t][0===e?e:e-1]),this.styles[t]){var h=parseInt(l,10);h>=e&&(a=!0,s[h-e]=this.styles[t][l],o&&0===e||delete this.styles[t][l])}var c=!1;for(a&&!o&&(this.styles[t+i]=s,c=!0),c&&i--;i>0;)n&&n[i-1]?this.styles[t+i]={0:S(n[i-1])}:r?this.styles[t+i]={0:S(r)}:delete this.styles[t+i],i--;this._forceClearCache=!0},insertCharStyleObject:function(t,e,i,n){this.styles||(this.styles={});var r=this.styles[t],s=r?S(r):{};for(var a in i||(i=1),s){var o=parseInt(a,10);o>=e&&(r[o+i]=s[o],s[o-i]||delete r[o])}if(this._forceClearCache=!0,n)for(;i--;)Object.keys(n[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=S(n[i]));else if(r)for(var l=r[e?e-1:1];l&&i--;)this.styles[t][e+i]=S(l)},insertNewStyleBlock:function(t,e,i){for(var n=this.get2DCursorLocation(e,!0),r=[0],s=0,a=0;a0&&(this.insertCharStyleObject(n.lineIndex,n.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),s&&this.insertNewlineStyleObject(n.lineIndex,n.charIndex+r[0],s),a=1;a0?this.insertCharStyleObject(n.lineIndex+a,0,r[a],i):i&&this.styles[n.lineIndex+a]&&i[0]&&(this.styles[n.lineIndex+a][0]=i[0]),i=i&&i.slice(r[a]+1);r[a]>0&&this.insertCharStyleObject(n.lineIndex+a,0,r[a],i)},setSelectionStartEndWithShift:function(t,e,i){i<=t?(e===t?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=t),this.selectionStart=i):i>t&&it?this.selectionStart=t:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>t?this.selectionEnd=t:this.selectionEnd<0&&(this.selectionEnd=0)}}),T.util.object.extend(T.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(t){if(this.canvas){this.__newClickTime=+new Date;var e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),this._stopEvent(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))},tripleClickHandler:function(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(t.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(t){if(this.__isMousedown=!1,!(!this.editable||this.group||t.transform&&t.transform.actionPerformed||t.e.button&&1!==t.e.button)){if(this.canvas){var e=this.canvas._activeObject;if(e&&e!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(t.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t),i=this.selectionStart,n=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,n,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(t){for(var e,i=this.getLocalPointer(t),n=0,r=0,s=0,a=0,o=0,l=0,h=this._textLines.length;l0&&(a+=this._textLines[l-1].length+this.missingNewlineOffset(l-1));r=this._getLineLeftOffset(o)*this.scaleX,e=this._textLines[o],"rtl"===this.direction&&(i.x=this.width*this.scaleX-i.x+r);for(var c=0,d=e.length;cs||a<0?0:1);return this.flipX&&(o=r-o),o>this._text.length&&(o=this._text.length),o}}),T.util.object.extend(T.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=T.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var t=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+t.top+"; left: "+t.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; paddingーtop: "+t.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):T.document.body.appendChild(this.hiddenTextarea),T.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),T.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),T.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),T.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),T.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),T.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(T.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(this.isEditing){var e="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())},onInput:function(t){var e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),this.isEditing){var i,n,r,s,a,o=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,l=this._text.length,h=o.length,c=h-l,d=this.selectionStart,u=this.selectionEnd,f=d!==u;if(""===this.hiddenTextarea.value)return this.styles={},this.updateFromTextArea(),this.fire("changed"),void(this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll()));var g=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),m=d>g.selectionStart;f?(i=this._text.slice(d,u),c+=u-d):h0&&(n+=(i=this.__charBounds[t][e-1]).left+i.width),n},getDownCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(r===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;var s=n.charIndex,a=this._getWidthBeforeCursor(r,s),o=this._getIndexOnLine(r+1,a);return this._textLines[r].slice(s).length+o+1+this.missingNewlineOffset(r)},_getSelectionForOffset:function(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(0===r||t.metaKey||33===t.keyCode)return-i;var s=n.charIndex,a=this._getWidthBeforeCursor(r,s),o=this._getIndexOnLine(r-1,a),l=this._textLines[r].slice(0,s),h=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+o-l.length+(1-h)},_getIndexOnLine:function(t,e){for(var i,n,r=this._textLines[t],s=this._getLineLeftOffset(t),a=0,o=0,l=r.length;oe){n=!0;var h=s-i,c=s,d=Math.abs(h-e);a=Math.abs(c-e)=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)},moveCursorUp:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)},_moveCursorUpOrDown:function(t,e){var i=this["get"+t+"CursorOffset"](e,"right"===this._selectionDirection);e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(t){var e="left"===this._selectionDirection?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t},moveCursorWithoutShift:function(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t},moveCursorLeft:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)},_move:function(t,e,i){var n;if(t.altKey)n=this["findWordBoundary"+i](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;n=this["findLineBoundary"+i](this[e])}if(void 0!==typeof n&&this[e]!==n)return this[e]=n,!0},_moveLeft:function(t,e){return this._move(t,e,"Left")},_moveRight:function(t,e){return this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){var e=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e},moveCursorLeftWithShift:function(t){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(t,"selectionStart")):void 0},moveCursorRight:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)},_moveCursorLeftOrRight:function(t,e){var i="moveCursor"+t+"With";this._currentCursorOpacity=1,e.shiftKey?i+="Shift":i+="outShift",this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(t){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection="right",this._moveRight(t,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(t){var e=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e},removeChars:function(t,e){void 0===e&&(e=t+1),this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(t,e,i,n){void 0===n&&(n=i),n>i&&this.removeStyleFromTo(i,n);var r=T.util.string.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[].concat(this._text.slice(0,i),r,this._text.slice(n)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),function(){var t=T.util.toFixed,e=/ +/g;T.util.object.extend(T.Text.prototype,{_toSVG:function(){var t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(t){var e=this.getSvgTextDecoration(this);return[t.textBgRects.join(""),'\t\t",t.textSpans.join(""),"\n"]},_getSVGTextAndBg:function(t,e){var i,n=[],r=[],s=t;this._setSVGBg(r);for(var a=0,o=this._textLines.length;a",T.util.string.escapeXml(i),""].join("")},_setSVGTextLineText:function(t,e,i,n){var r,s,a,o,l,h=this.getHeightOfLine(e),c=-1!==this.textAlign.indexOf("justify"),d="",u=0,f=this._textLines[e];n+=h*(1-this._fontSizeFraction)/this.lineHeight;for(var g=0,m=f.length-1;g<=m;g++)l=g===m||this.charSpacing,d+=f[g],a=this.__charBounds[e][g],0===u?(i+=a.kernedWidth-a.width,u+=a.width):u+=a.kernedWidth,c&&!l&&this._reSpaceAndTab.test(f[g])&&(l=!0),l||(r=r||this.getCompleteStyleDeclaration(e,g),s=this.getCompleteStyleDeclaration(e,g+1),l=this._hasStyleChangedForSvg(r,s)),l&&(o=this._getStyleDeclaration(e,g)||{},t.push(this._createTextCharSpan(d,o,i,n)),d="",r=s,i+=u,u=0)},_pushTextBgRect:function(e,i,n,r,s,a){var o=T.Object.NUM_FRACTION_DIGITS;e.push("\t\t\n')},_setSVGTextLineBg:function(t,e,i,n){for(var r,s,a=this._textLines[e],o=this.getHeightOfLine(e)/this.lineHeight,l=0,h=0,c=this.getValueOfPropertyAt(e,0,"textBackgroundColor"),d=0,u=a.length;dthis.width&&this._set("width",this.dynamicMinWidth),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(t){for(var e=0,i=0,n=0,r={},s=0;s0?(i=0,n++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[n])&&s>0&&(i++,n++),r[s]={line:e,offset:i},n+=t.graphemeLines[s].length,i+=t.graphemeLines[s].length;return r},styleHas:function(t,i){if(this._styleMap&&!this.isWrapping){var n=this._styleMap[i];n&&(i=n.line)}return e.Text.prototype.styleHas.call(this,t,i)},isEmptyStyles:function(t){if(!this.styles)return!0;var e,i,n=0,r=!1,s=this._styleMap[t],a=this._styleMap[t+1];for(var o in s&&(t=s.line,n=s.offset),a&&(r=a.line===t,e=a.offset),i=void 0===t?this.styles:{line:this.styles[t]})for(var l in i[o])if(l>=n&&(!r||ln&&!p?(o.push(l),l=[],s=f,p=!0):s+=_,p||a||l.push(u),l=l.concat(c),g=a?0:this._measureWord([u],i,d),d++,p=!1,f>m&&(m=f);return v&&o.push(l),m+r>this.dynamicMinWidth&&(this.dynamicMinWidth=m-_+r),o},isEndOfWrapping:function(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line},missingNewlineOffset:function(t){return this.splitByGrapheme?this.isEndOfWrapping(t)?1:0:1},_splitTextIntoLines:function(t){for(var i=e.Text.prototype._splitTextIntoLines.call(this,t),n=this._wrapText(i.lines,this.width),r=new Array(n.length),s=0;s{},898:()=>{},245:()=>{}},_i={};function vi(t){var e=_i[t];if(void 0!==e)return e.exports;var i=_i[t]={exports:{}};return pi[t](i,i.exports,vi),i.exports}vi.d=(t,e)=>{for(var i in e)vi.o(e,i)&&!vi.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},vi.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var yi={};(()=>{let t;vi.d(yi,{R:()=>t}),t="undefined"!=typeof document&&"undefined"!=typeof window?vi(653).fabric:{version:"5.2.1"}})();var wi,Ci,Ei,Si,Ti=yi.R;!function(t){t[t.DIMT_RECTANGLE=1]="DIMT_RECTANGLE",t[t.DIMT_QUADRILATERAL=2]="DIMT_QUADRILATERAL",t[t.DIMT_TEXT=4]="DIMT_TEXT",t[t.DIMT_ARC=8]="DIMT_ARC",t[t.DIMT_IMAGE=16]="DIMT_IMAGE",t[t.DIMT_POLYGON=32]="DIMT_POLYGON",t[t.DIMT_LINE=64]="DIMT_LINE",t[t.DIMT_GROUP=128]="DIMT_GROUP"}(wi||(wi={})),function(t){t[t.DIS_DEFAULT=1]="DIS_DEFAULT",t[t.DIS_SELECTED=2]="DIS_SELECTED"}(Ci||(Ci={})),function(t){t[t.EF_ENHANCED_FOCUS=4]="EF_ENHANCED_FOCUS",t[t.EF_AUTO_ZOOM=16]="EF_AUTO_ZOOM",t[t.EF_TAP_TO_FOCUS=64]="EF_TAP_TO_FOCUS"}(Ei||(Ei={})),function(t){t.GREY="grey",t.GREY32="grey32",t.RGBA="rgba",t.RBGA="rbga",t.GRBA="grba",t.GBRA="gbra",t.BRGA="brga",t.BGRA="bgra"}(Si||(Si={}));const bi=t=>"number"==typeof t&&!Number.isNaN(t),Ii=t=>"string"==typeof t;var xi,Ri,Oi,Ai,Di,Mi,Li,Fi,Pi,ki,Ni;!function(t){t[t.ARC=0]="ARC",t[t.IMAGE=1]="IMAGE",t[t.LINE=2]="LINE",t[t.POLYGON=3]="POLYGON",t[t.QUAD=4]="QUAD",t[t.RECT=5]="RECT",t[t.TEXT=6]="TEXT",t[t.GROUP=7]="GROUP"}(Di||(Di={})),function(t){t[t.DEFAULT=0]="DEFAULT",t[t.SELECTED=1]="SELECTED"}(Mi||(Mi={}));let Bi=class{get mediaType(){return new Map([["rect",wi.DIMT_RECTANGLE],["quad",wi.DIMT_QUADRILATERAL],["text",wi.DIMT_TEXT],["arc",wi.DIMT_ARC],["image",wi.DIMT_IMAGE],["polygon",wi.DIMT_POLYGON],["line",wi.DIMT_LINE],["group",wi.DIMT_GROUP]]).get(this._mediaType)}get styleSelector(){switch(ci(this,Ri,"f")){case Ci.DIS_DEFAULT:return"default";case Ci.DIS_SELECTED:return"selected"}}set drawingStyleId(t){this.styleId=t}get drawingStyleId(){return this.styleId}set coordinateBase(t){if(!["view","image"].includes(t))throw new Error("Invalid 'coordinateBase'.");this._drawingLayer&&("image"===ci(this,Oi,"f")&&"view"===t?this.updateCoordinateBaseFromImageToView():"view"===ci(this,Oi,"f")&&"image"===t&&this.updateCoordinateBaseFromViewToImage()),di(this,Oi,t)}get coordinateBase(){return ci(this,Oi,"f")}get drawingLayerId(){return this._drawingLayerId}constructor(t,e){if(xi.add(this),Ri.set(this,void 0),Oi.set(this,"image"),this._zIndex=null,this._drawingLayer=null,this._drawingLayerId=null,this._mapState_StyleId=new Map,this.mapEvent_Callbacks=new Map([["selected",new Map],["deselected",new Map],["mousedown",new Map],["mouseup",new Map],["dblclick",new Map],["mouseover",new Map],["mouseout",new Map]]),this.mapNoteName_Content=new Map([]),this.isDrawingItem=!0,null!=e&&!bi(e))throw new TypeError("Invalid 'drawingStyleId'.");t&&this._setFabricObject(t),this.setState(Ci.DIS_DEFAULT),this.styleId=e}_setFabricObject(t){this._fabricObject=t,this._fabricObject.on("selected",(()=>{this.setState(Ci.DIS_SELECTED)})),this._fabricObject.on("deselected",(()=>{this._fabricObject.canvas&&this._fabricObject.canvas.getActiveObjects().includes(this._fabricObject)?this.setState(Ci.DIS_SELECTED):this.setState(Ci.DIS_DEFAULT),"textbox"===this._fabricObject.type&&(this._fabricObject.isEditing&&this._fabricObject.exitEditing(),this._fabricObject.selected=!1)})),t.getDrawingItem=()=>this}_getFabricObject(){return this._fabricObject}setState(t){di(this,Ri,t)}getState(){return ci(this,Ri,"f")}_on(t,e){if(!e)return;const i=t.toLowerCase(),n=this.mapEvent_Callbacks.get(i);if(!n)throw new Error(`Event '${t}' does not exist.`);let r=n.get(e);r||(r=t=>{const i=t.e;if(!i)return void(e&&e.apply(this,[{targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null}]));const n={targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null};if(this._drawingLayer){let t,e,r,s;const a=i.target.getBoundingClientRect();t=a.left,e=a.top,r=t+window.scrollX,s=e+window.scrollY;const{width:o,height:l}=this._drawingLayer.fabricCanvas.lowerCanvasEl.getBoundingClientRect(),h=this._drawingLayer.width,c=this._drawingLayer.height,d=o/l,u=h/c,f=this._drawingLayer._getObjectFit();let g,m,p,_,v=1;if("contain"===f)d0?i-1:n,Gi),actionName:"modifyPolygon",pointIndex:i}),t}),{}),di(this,Fi,JSON.parse(JSON.stringify(t))),this._mediaType="polygon"}extendSet(t,e){if("vertices"===t){const t=this._fabricObject;if(t.group){const i=t.group;t.points=e.map((t=>({x:t.x-i.left-i.width/2,y:t.y-i.top-i.height/2}))),i.addWithUpdate()}else t.points=e;const i=t.points.length-1;return t.controls=t.points.reduce((function(t,e,n){return t["p"+n]=new Ti.Control({positionHandler:Vi,actionHandler:Wi(n>0?n-1:i,Gi),actionName:"modifyPolygon",pointIndex:n}),t}),{}),t._setPositionDimensions({}),!0}}extendGet(t){if("vertices"===t){const t=[],e=this._fabricObject;if(e.selectable&&!e.group)for(let i in e.oCoords)t.push({x:e.oCoords[i].x,y:e.oCoords[i].y});else for(let i of e.points){let n=i.x-e.pathOffset.x,r=i.y-e.pathOffset.y;const s=Ti.util.transformPoint({x:n,y:r},e.calcTransformMatrix());t.push({x:s.x,y:s.y})}return t}}updateCoordinateBaseFromImageToView(){const t=this.get("vertices").map((t=>({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",t)}updateCoordinateBaseFromViewToImage(){const t=this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})));this.set("vertices",t)}setPosition(t){this.setPolygon(t)}getPosition(){return this.getPolygon()}updatePosition(){ci(this,Fi,"f")&&this.setPolygon(ci(this,Fi,"f"))}setPolygon(t){if(!b(t))throw new TypeError("Invalid 'polygon'.");if(this._drawingLayer){if("view"===this.coordinateBase){const e=t.points.map((t=>({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",e)}else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("vertices",t.points)}this._drawingLayer.renderAll()}else di(this,Fi,JSON.parse(JSON.stringify(t)))}getPolygon(){if(this._drawingLayer){if("view"===this.coordinateBase)return{points:this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})))};if("image"===this.coordinateBase)return{points:this.get("vertices")};throw new Error("Invalid 'coordinateBase'.")}return ci(this,Fi,"f")?JSON.parse(JSON.stringify(ci(this,Fi,"f"))):null}};Fi=new WeakMap;let Hi=class extends Bi{set maintainAspectRatio(t){t&&this.set("scaleY",this.get("scaleX"))}get maintainAspectRatio(){return ci(this,ki,"f")}constructor(t,e,i,n){if(super(null,n),Pi.set(this,void 0),ki.set(this,void 0),!x(e))throw new TypeError("Invalid 'rect'.");if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement)this._setFabricObject(new Ti.Image(t,{left:e.x,top:e.y}));else{if(!w(t))throw new TypeError("Invalid 'image'.");{const i=document.createElement("canvas");let n;if(i.width=t.width,i.height=t.height,t.format===o.IPF_GRAYSCALED){n=new Uint8ClampedArray(t.width*t.height*4);for(let e=0;e{let e=(t=>t.split("\n").map((t=>t.split("\t"))))(t);return(t=>{for(let e=0;;e++){let i=-1;for(let n=0;ni&&(i=r.length)}if(-1===i)break;for(let n=0;n=t[n].length-1)continue;let r=" ".repeat(i+2-t[n][e].length);t[n][e]=t[n][e].concat(r)}}})(e),(t=>{let e="";for(let i=0;i({x:e.x-t.left-t.width/2,y:e.y-t.top-t.height/2}))),t.addWithUpdate()}else i.points=e;const n=i.points.length-1;return i.controls=i.points.reduce((function(t,e,i){return t["p"+i]=new Ti.Control({positionHandler:Vi,actionHandler:Wi(i>0?i-1:n,Gi),actionName:"modifyPolygon",pointIndex:i}),t}),{}),i._setPositionDimensions({}),!0}}extendGet(t){if("startPoint"===t||"endPoint"===t){const e=[],i=this._fabricObject;if(i.selectable&&!i.group)for(let t in i.oCoords)e.push({x:i.oCoords[t].x,y:i.oCoords[t].y});else for(let t of i.points){let n=t.x-i.pathOffset.x,r=t.y-i.pathOffset.y;const s=Ti.util.transformPoint({x:n,y:r},i.calcTransformMatrix());e.push({x:s.x,y:s.y})}return"startPoint"===t?e[0]:e[1]}}updateCoordinateBaseFromImageToView(){const t=this.get("startPoint"),e=this.get("endPoint");this.set("startPoint",{x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)}),this.set("endPoint",{x:this.convertPropFromViewToImage(e.x),y:this.convertPropFromViewToImage(e.y)})}updateCoordinateBaseFromViewToImage(){const t=this.get("startPoint"),e=this.get("endPoint");this.set("startPoint",{x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)}),this.set("endPoint",{x:this.convertPropFromImageToView(e.x),y:this.convertPropFromImageToView(e.y)})}setPosition(t){this.setLine(t)}getPosition(){return this.getLine()}updatePosition(){ci(this,qi,"f")&&this.setLine(ci(this,qi,"f"))}setPolygon(){}getPolygon(){return null}setLine(t){if(!S(t))throw new TypeError("Invalid 'line'.");if(this._drawingLayer){if("view"===this.coordinateBase)this.set("startPoint",{x:this.convertPropFromViewToImage(t.startPoint.x),y:this.convertPropFromViewToImage(t.startPoint.y)}),this.set("endPoint",{x:this.convertPropFromViewToImage(t.endPoint.x),y:this.convertPropFromViewToImage(t.endPoint.y)});else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("startPoint",t.startPoint),this.set("endPoint",t.endPoint)}this._drawingLayer.renderAll()}else di(this,qi,JSON.parse(JSON.stringify(t)))}getLine(){if(this._drawingLayer){if("view"===this.coordinateBase)return{startPoint:{x:this.convertPropFromImageToView(this.get("startPoint").x),y:this.convertPropFromImageToView(this.get("startPoint").y)},endPoint:{x:this.convertPropFromImageToView(this.get("endPoint").x),y:this.convertPropFromImageToView(this.get("endPoint").y)}};if("image"===this.coordinateBase)return{startPoint:this.get("startPoint"),endPoint:this.get("endPoint")};throw new Error("Invalid 'coordinateBase'.")}return ci(this,qi,"f")?JSON.parse(JSON.stringify(ci(this,qi,"f"))):null}};qi=new WeakMap;let Ji=class extends Yi{constructor(t,e){if(super({points:null==t?void 0:t.points},e),Zi.set(this,void 0),!I(t))throw new TypeError("Invalid 'quad'.");di(this,Zi,JSON.parse(JSON.stringify(t))),this._mediaType="quad"}setPosition(t){this.setQuad(t)}getPosition(){return this.getQuad()}updatePosition(){ci(this,Zi,"f")&&this.setQuad(ci(this,Zi,"f"))}setPolygon(){}getPolygon(){return null}setQuad(t){if(!I(t))throw new TypeError("Invalid 'quad'.");if(this._drawingLayer){if("view"===this.coordinateBase){const e=t.points.map((t=>({x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)})));this.set("vertices",e)}else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("vertices",t.points)}this._drawingLayer.renderAll()}else di(this,Zi,JSON.parse(JSON.stringify(t)))}getQuad(){if(this._drawingLayer){if("view"===this.coordinateBase)return{points:this.get("vertices").map((t=>({x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)})))};if("image"===this.coordinateBase)return{points:this.get("vertices")};throw new Error("Invalid 'coordinateBase'.")}return ci(this,Zi,"f")?JSON.parse(JSON.stringify(ci(this,Zi,"f"))):null}};Zi=new WeakMap;class $i extends Bi{constructor(t){super(new Ti.Group(t.map((t=>t._getFabricObject())))),this._fabricObject.on("selected",(()=>{this.setState(Ci.DIS_SELECTED);const t=this._fabricObject._objects;for(let e of t)setTimeout((()=>{e&&e.fire("selected")}),0);setTimeout((()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())}),0)})),this._fabricObject.on("deselected",(()=>{this.setState(Ci.DIS_DEFAULT);const t=this._fabricObject._objects;for(let e of t)setTimeout((()=>{e&&e.fire("deselected")}),0);setTimeout((()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())}),0)})),this._mediaType="group"}extendSet(t,e){return!1}extendGet(t){}updateCoordinateBaseFromImageToView(){}updateCoordinateBaseFromViewToImage(){}setPosition(){}getPosition(){}updatePosition(){}getChildDrawingItems(){return this._fabricObject._objects.map((t=>t.getDrawingItem()))}setChildDrawingItems(t){if(!t||!t.isDrawingItem)throw TypeError("Illegal drawing item.");this._drawingLayer?this._drawingLayer._updateGroupItem(this,t,"add"):this._fabricObject.addWithUpdate(t._getFabricObject())}removeChildItem(t){t&&t.isDrawingItem&&(this._drawingLayer?this._drawingLayer._updateGroupItem(this,t,"remove"):this._fabricObject.removeWithUpdate(t._getFabricObject()))}}const Qi=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),tn=t=>!!Ii(t)&&""!==t,en=t=>!(!Qi(t)||"id"in t&&!bi(t.id)||"lineWidth"in t&&!bi(t.lineWidth)||"fillStyle"in t&&!tn(t.fillStyle)||"strokeStyle"in t&&!tn(t.strokeStyle)||"paintMode"in t&&!["fill","stroke","strokeAndFill"].includes(t.paintMode)||"fontFamily"in t&&!tn(t.fontFamily)||"fontSize"in t&&!bi(t.fontSize));class nn{static convert(t,e,i,n){const r={x:0,y:0,width:e,height:i};if(!t)return r;const s=n.getVideoFit(),a=n.getVisibleRegionOfVideo({inPixels:!0});if(x(t))t.isMeasuredInPercentage?"contain"===s||null===a?(r.x=t.x/100*e,r.y=t.y/100*i,r.width=t.width/100*e,r.height=t.height/100*i):(r.x=a.x+t.x/100*a.width,r.y=a.y+t.y/100*a.height,r.width=t.width/100*a.width,r.height=t.height/100*a.height):"contain"===s||null===a?(r.x=t.x,r.y=t.y,r.width=t.width,r.height=t.height):(r.x=t.x+a.x,r.y=t.y+a.y,r.width=t.width>a.width?a.width:t.width,r.height=t.height>a.height?a.height:t.height);else{if(!C(t))throw TypeError("Invalid region.");t.isMeasuredInPercentage?"contain"===s||null===a?(r.x=t.left/100*e,r.y=t.top/100*i,r.width=(t.right-t.left)/100*e,r.height=(t.bottom-t.top)/100*i):(r.x=a.x+t.left/100*a.width,r.y=a.y+t.top/100*a.height,r.width=(t.right-t.left)/100*a.width,r.height=(t.bottom-t.top)/100*a.height):"contain"===s||null===a?(r.x=t.left,r.y=t.top,r.width=t.right-t.left,r.height=t.bottom-t.top):(r.x=t.left+a.x,r.y=t.top+a.y,r.width=t.right-t.left>a.width?a.width:t.right-t.left,r.height=t.bottom-t.top>a.height?a.height:t.bottom-t.top)}return r.x=Math.round(r.x),r.y=Math.round(r.y),r.width=Math.round(r.width),r.height=Math.round(r.height),r}}var rn,sn;class an{constructor(){rn.set(this,new Map),sn.set(this,!1)}get disposed(){return ci(this,sn,"f")}on(t,e){t=t.toLowerCase();const i=ci(this,rn,"f").get(t);if(i){if(i.includes(e))return;i.push(e)}else ci(this,rn,"f").set(t,[e])}off(t,e){t=t.toLowerCase();const i=ci(this,rn,"f").get(t);if(!i)return;const n=i.indexOf(e);-1!==n&&i.splice(n,1)}offAll(t){t=t.toLowerCase();const e=ci(this,rn,"f").get(t);e&&(e.length=0)}fire(t,e=[],i={async:!1,copy:!0}){e||(e=[]),t=t.toLowerCase();const n=ci(this,rn,"f").get(t);if(n&&n.length){i=Object.assign({async:!1,copy:!0},i);for(let r of n){if(!r)continue;let s=[];if(i.copy)for(let i of e){try{i=JSON.parse(JSON.stringify(i))}catch(t){}s.push(i)}else s=e;let a=!1;if(i.async)setTimeout((()=>{this.disposed||n.includes(r)&&r.apply(i.target,s)}),0);else try{a=r.apply(i.target,s)}catch(t){}if(!0===a)break}}}dispose(){di(this,sn,!0)}}function on(t,e,i){return(i.x-t.x)*(e.y-t.y)==(e.x-t.x)*(i.y-t.y)&&Math.min(t.x,e.x)<=i.x&&i.x<=Math.max(t.x,e.x)&&Math.min(t.y,e.y)<=i.y&&i.y<=Math.max(t.y,e.y)}function ln(t){return Math.abs(t)<1e-6?0:t<0?-1:1}function hn(t,e,i,n){let r=t[0]*(i[1]-e[1])+e[0]*(t[1]-i[1])+i[0]*(e[1]-t[1]),s=t[0]*(n[1]-e[1])+e[0]*(t[1]-n[1])+n[0]*(e[1]-t[1]);return!((r^s)>=0&&0!==r&&0!==s||(r=i[0]*(t[1]-n[1])+n[0]*(i[1]-t[1])+t[0]*(n[1]-i[1]),s=i[0]*(e[1]-n[1])+n[0]*(i[1]-e[1])+e[0]*(n[1]-i[1]),(r^s)>=0&&0!==r&&0!==s))}rn=new WeakMap,sn=new WeakMap;const cn=async t=>{if("string"!=typeof t)throw new TypeError("Invalid url.");const e=await fetch(t);if(!e.ok)throw Error("Network Error: "+e.statusText);const i=await e.text();if(!i.trim().startsWith("<"))throw Error("Unable to get valid HTMLElement.");const n=document.createElement("div");if(n.insertAdjacentHTML("beforeend",i),1===n.childElementCount&&n.firstChild instanceof HTMLTemplateElement)return n.firstChild.content;const r=new DocumentFragment;for(let t of n.children)r.append(t);return r};class dn{static multiply(t,e){const i=[];for(let n=0;n<3;n++){const r=e.slice(3*n,3*n+3);for(let e=0;e<3;e++){const n=[t[e],t[e+3],t[e+6]].reduce(((t,e,i)=>t+e*r[i]),0);i.push(n)}}return i}static identity(){return[1,0,0,0,1,0,0,0,1]}static translate(t,e,i){return dn.multiply(t,[1,0,0,0,1,0,e,i,1])}static rotate(t,e){var i=Math.cos(e),n=Math.sin(e);return dn.multiply(t,[i,-n,0,n,i,0,0,0,1])}static scale(t,e,i){return dn.multiply(t,[e,0,0,0,i,0,0,0,1])}}var un,fn,gn,mn,pn,_n,vn,yn,wn,Cn,En,Sn,Tn,bn,In,xn,Rn,On,An,Dn,Mn,Ln,Fn,Pn,kn,Nn,Bn,jn,Vn,Un,Gn,Wn,Yn,Hn,zn,Xn,qn,Zn,Kn,Jn,$n,Qn,tr,er,ir,nr,rr,sr,ar,or,lr,hr,cr,dr,ur,fr,gr,mr,pr,_r,vr,yr,wr,Cr,Er,Sr,Tr,br,Ir,xr,Rr,Or,Ar,Dr,Mr,Lr,Fr,Pr,kr,Nr,Br;class jr{static createDrawingStyle(t){if(!en(t))throw new Error("Invalid style definition.");let e,i=jr.USER_START_STYLE_ID;for(;ci(jr,un,"f",fn).has(i);)i++;e=i;const n=JSON.parse(JSON.stringify(t));n.id=e;for(let t in ci(jr,un,"f",gn))n.hasOwnProperty(t)||(n[t]=ci(jr,un,"f",gn)[t]);return ci(jr,un,"f",fn).set(e,n),n.id}static _getDrawingStyle(t,e){if("number"!=typeof t)throw new Error("Invalid style id.");const i=ci(jr,un,"f",fn).get(t);return i?e?JSON.parse(JSON.stringify(i)):i:null}static getDrawingStyle(t){return this._getDrawingStyle(t,!0)}static getAllDrawingStyles(){return JSON.parse(JSON.stringify(Array.from(ci(jr,un,"f",fn).values())))}static _updateDrawingStyle(t,e){if(!en(e))throw new Error("Invalid style definition.");const i=ci(jr,un,"f",fn).get(t);if(i)for(let t in e)i.hasOwnProperty(t)&&(i[t]=e[t])}static updateDrawingStyle(t,e){this._updateDrawingStyle(t,e)}}un=jr,jr.STYLE_BLUE_STROKE=1,jr.STYLE_GREEN_STROKE=2,jr.STYLE_ORANGE_STROKE=3,jr.STYLE_YELLOW_STROKE=4,jr.STYLE_BLUE_STROKE_FILL=5,jr.STYLE_GREEN_STROKE_FILL=6,jr.STYLE_ORANGE_STROKE_FILL=7,jr.STYLE_YELLOW_STROKE_FILL=8,jr.STYLE_BLUE_STROKE_TRANSPARENT=9,jr.STYLE_GREEN_STROKE_TRANSPARENT=10,jr.STYLE_ORANGE_STROKE_TRANSPARENT=11,jr.USER_START_STYLE_ID=1024,fn={value:new Map([[jr.STYLE_BLUE_STROKE,{id:jr.STYLE_BLUE_STROKE,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[jr.STYLE_GREEN_STROKE,{id:jr.STYLE_GREEN_STROKE,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[jr.STYLE_ORANGE_STROKE,{id:jr.STYLE_ORANGE_STROKE,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[jr.STYLE_YELLOW_STROKE,{id:jr.STYLE_YELLOW_STROKE,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[jr.STYLE_BLUE_STROKE_FILL,{id:jr.STYLE_BLUE_STROKE_FILL,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[jr.STYLE_GREEN_STROKE_FILL,{id:jr.STYLE_GREEN_STROKE_FILL,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[jr.STYLE_ORANGE_STROKE_FILL,{id:jr.STYLE_ORANGE_STROKE_FILL,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[jr.STYLE_YELLOW_STROKE_FILL,{id:jr.STYLE_YELLOW_STROKE_FILL,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[jr.STYLE_BLUE_STROKE_TRANSPARENT,{id:jr.STYLE_BLUE_STROKE_TRANSPARENT,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[jr.STYLE_GREEN_STROKE_TRANSPARENT,{id:jr.STYLE_GREEN_STROKE_TRANSPARENT,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[jr.STYLE_ORANGE_STROKE_TRANSPARENT,{id:jr.STYLE_ORANGE_STROKE_TRANSPARENT,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}]])},gn={value:{lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}},"undefined"!=typeof document&&"undefined"!=typeof window&&(Ti.StaticCanvas.prototype.dispose=function(){return this.isRendering&&(Ti.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject((function(t){t.dispose&&t.dispose()})),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),Ti.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},Ti.Object.prototype.transparentCorners=!1,Ti.Object.prototype.cornerSize=20,Ti.Object.prototype.touchCornerSize=100,Ti.Object.prototype.cornerColor="rgb(254,142,20)",Ti.Object.prototype.cornerStyle="circle",Ti.Object.prototype.strokeUniform=!0,Ti.Object.prototype.hasBorders=!1,Ti.Canvas.prototype.containerClass="",Ti.Canvas.prototype.getPointer=function(t,e){if(this._absolutePointer&&!e)return this._absolutePointer;if(this._pointer&&e)return this._pointer;var i=this.upperCanvasEl;let n,r=Ti.util.getPointer(t,i),s=i.getBoundingClientRect(),a=s.width||0,o=s.height||0;a&&o||("top"in s&&"bottom"in s&&(o=Math.abs(s.top-s.bottom)),"right"in s&&"left"in s&&(a=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=this.restorePointerVpt(r));var l=this.getRetinaScaling();if(1!==l&&(r.x/=l,r.y/=l),0!==a&&0!==o){var h=window.getComputedStyle(i).objectFit,c=i.width,d=i.height,u=a,f=o;n={width:c/u,height:d/f};var g,m,p=c/d,_=u/f;return"contain"===h?p>_?(g=u,m=u/p,{x:r.x*n.width,y:(r.y-(f-m)/2)*n.width}):(g=f*p,m=f,{x:(r.x-(u-g)/2)*n.height,y:r.y*n.height}):"cover"===h?p>_?{x:(c-n.height*u)/2+r.x*n.height,y:r.y*n.height}:{x:r.x*n.width,y:(d-n.width*f)/2+r.y*n.width}:{x:r.x*n.width,y:r.y*n.height}}return n={width:1,height:1},{x:r.x*n.width,y:r.y*n.height}},Ti.Canvas.prototype._onTouchStart=function(t){let e;for(let i=0;ii&&!_?(l.push(h),h=[],a=g,_=!0):a+=v,_||o||h.push(f),h=h.concat(d),m=o?0:this._measureWord([f],e,u),u++,_=!1,g>p&&(p=g);return y&&l.push(h),p+n>this.dynamicMinWidth&&(this.dynamicMinWidth=p-v+n),l});class Vr{get width(){return this.fabricCanvas.width}get height(){return this.fabricCanvas.height}set _allowMultiSelect(t){this.fabricCanvas.selection=t,this.fabricCanvas.renderAll()}get _allowMultiSelect(){return this.fabricCanvas.selection}constructor(t,e,i){if(this.mapType_StateAndStyleId=new Map,this.mode="viewer",this.onSelectionChanged=null,this._arrDrwaingItem=[],this._arrFabricObject=[],this._visible=!0,t.hasOwnProperty("getFabricCanvas"))this.fabricCanvas=t.getFabricCanvas();else{let e=this.fabricCanvas=new Ti.Canvas(t,Object.assign(i,{allowTouchScrolling:!0,selection:!1}));e.setDimensions({width:"100%",height:"100%"},{cssOnly:!0}),e.lowerCanvasEl.className="",e.upperCanvasEl.className="",e.on("selection:created",(function(t){const e=t.selected,i=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!i.includes(e)&&i.push(e)}for(let t of i){const i=[];for(let n of e){const e=n.getDrawingItem();e._drawingLayer===t&&i.push(e)}setTimeout((()=>{t.onSelectionChanged&&t.onSelectionChanged(i,[])}),0)}})),e.on("before:selection:cleared",(function(t){const e=this.getActiveObjects(),i=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!i.includes(e)&&i.push(e)}for(let t of i){const i=[];for(let n of e){const e=n.getDrawingItem();e._drawingLayer===t&&i.push(e)}setTimeout((()=>{const e=[];for(let n of i)t.hasDrawingItem(n)&&e.push(n);e.length>0&&t.onSelectionChanged&&t.onSelectionChanged([],e)}),0)}})),e.on("selection:updated",(function(t){const e=t.selected,i=t.deselected,n=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!n.includes(e)&&n.push(e)}for(let t of i){const e=t.getDrawingItem()._drawingLayer;e&&!n.includes(e)&&n.push(e)}for(let t of n){const n=[],r=[];for(let i of e){const e=i.getDrawingItem();e._drawingLayer===t&&n.push(e)}for(let e of i){const i=e.getDrawingItem();i._drawingLayer===t&&r.push(i)}setTimeout((()=>{t.onSelectionChanged&&t.onSelectionChanged(n,r)}),0)}})),e.wrapperEl.style.position="absolute",t.getFabricCanvas=()=>this.fabricCanvas}let n,r;switch(this.fabricCanvas.id=e,this.id=e,e){case Vr.DDN_LAYER_ID:n=jr.getDrawingStyle(jr.STYLE_BLUE_STROKE),r=jr.getDrawingStyle(jr.STYLE_BLUE_STROKE_FILL);break;case Vr.DBR_LAYER_ID:n=jr.getDrawingStyle(jr.STYLE_ORANGE_STROKE),r=jr.getDrawingStyle(jr.STYLE_ORANGE_STROKE_FILL);break;case Vr.DLR_LAYER_ID:n=jr.getDrawingStyle(jr.STYLE_GREEN_STROKE),r=jr.getDrawingStyle(jr.STYLE_GREEN_STROKE_FILL);break;default:n=jr.getDrawingStyle(jr.STYLE_YELLOW_STROKE),r=jr.getDrawingStyle(jr.STYLE_YELLOW_STROKE_FILL)}for(let t of Bi.arrMediaTypes)this.mapType_StateAndStyleId.set(t,{default:n.id,selected:r.id})}getId(){return this.id}setVisible(t){if(t){for(let t of this._arrFabricObject)t.visible=!0,t.hasControls=!0;this._visible=!0}else{for(let t of this._arrFabricObject)t.visible=!1,t.hasControls=!1;this._visible=!1}this.fabricCanvas.renderAll()}isVisible(){return this._visible}_getItemCurrentStyle(t){return t.styleId?jr.getDrawingStyle(t.styleId):jr.getDrawingStyle(t._mapState_StyleId.get(t.styleSelector))||null}_changeMediaTypeCurStyleInStyleSelector(t,e,i,n){const r=this.getDrawingItems((e=>e._mediaType===t));for(let t of r)t.styleSelector===e&&this._changeItemStyle(t,i,!0);n||this.fabricCanvas.renderAll()}_changeItemStyle(t,e,i){if(!t||!e)return;const n=t._getFabricObject();"number"==typeof t.styleId&&(e=jr.getDrawingStyle(t.styleId)),n.strokeWidth=e.lineWidth,"fill"===e.paintMode?(n.fill=e.fillStyle,n.stroke=e.fillStyle):"stroke"===e.paintMode?(n.fill="transparent",n.stroke=e.strokeStyle):"strokeAndFill"===e.paintMode&&(n.fill=e.fillStyle,n.stroke=e.strokeStyle),n.fontFamily&&(n.fontFamily=e.fontFamily),n.fontSize&&(n.fontSize=e.fontSize),n.group||(n.dirty=!0),i||this.fabricCanvas.renderAll()}_updateGroupItem(t,e,i){if(!t||!e)return;const n=t.getChildDrawingItems();if("add"===i){if(n.includes(e))return;const i=e._getFabricObject();if(this.fabricCanvas.getObjects().includes(i)){if(!this._arrFabricObject.includes(i))throw new Error("Existed in other drawing layers.");e._zIndex=null}else{let i;if(e.styleId)i=jr.getDrawingStyle(e.styleId);else{const n=this.mapType_StateAndStyleId.get(e._mediaType);i=jr.getDrawingStyle(n[t.styleSelector]);const r=()=>{this._changeItemStyle(e,jr.getDrawingStyle(this.mapType_StateAndStyleId.get(e._mediaType).selected),!0)},s=()=>{this._changeItemStyle(e,jr.getDrawingStyle(this.mapType_StateAndStyleId.get(e._mediaType).default),!0)};e._on("selected",r),e._on("deselected",s),e._funcChangeStyleToSelected=r,e._funcChangeStyleToDefault=s}e._drawingLayer=this,e._drawingLayerId=this.id,this._changeItemStyle(e,i,!0)}t._fabricObject.addWithUpdate(e._getFabricObject())}else{if("remove"!==i)return;if(!n.includes(e))return;e._zIndex=null,e._drawingLayer=null,e._drawingLayerId=null,e._off("selected",e._funcChangeStyleToSelected),e._off("deselected",e._funcChangeStyleToDefault),e._funcChangeStyleToSelected=null,e._funcChangeStyleToDefault=null,t._fabricObject.removeWithUpdate(e._getFabricObject())}this.fabricCanvas.renderAll()}_addDrawingItem(t,e){if(!(t instanceof Bi))throw new TypeError("Invalid 'drawingItem'.");if(t._drawingLayer){if(t._drawingLayer==this)return;throw new Error("This drawing item has existed in other layer.")}let i=t._getFabricObject();const n=this.fabricCanvas.getObjects();let r,s;if(n.includes(i)){if(this._arrFabricObject.includes(i))return;throw new Error("Existed in other drawing layers.")}if("group"===t._mediaType){r=t.getChildDrawingItems();for(let t of r)if(t._drawingLayer&&t._drawingLayer!==this)throw new Error("The childItems of DT_Group have existed in other drawing layers.")}if(e&&"object"==typeof e&&!Array.isArray(e))for(let t in e)i.set(t,e[t]);if(r){for(let t of r){const e=this.mapType_StateAndStyleId.get(t._mediaType);for(let i of Bi.arrStyleSelectors)t._mapState_StyleId.set(i,e[i]);if(t.styleId)s=jr.getDrawingStyle(t.styleId);else{s=jr.getDrawingStyle(e.default);const i=()=>{this._changeItemStyle(t,jr.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).selected),!0)},n=()=>{this._changeItemStyle(t,jr.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).default),!0)};t._on("selected",i),t._on("deselected",n),t._funcChangeStyleToSelected=i,t._funcChangeStyleToDefault=n}t._drawingLayer=this,t._drawingLayerId=this.id,this._changeItemStyle(t,s,!0)}i.dirty=!0,this.fabricCanvas.renderAll()}else{const e=this.mapType_StateAndStyleId.get(t._mediaType);for(let i of Bi.arrStyleSelectors)t._mapState_StyleId.set(i,e[i]);if(t.styleId)s=jr.getDrawingStyle(t.styleId);else{s=jr.getDrawingStyle(e.default);const i=()=>{this._changeItemStyle(t,jr.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).selected))},n=()=>{this._changeItemStyle(t,jr.getDrawingStyle(this.mapType_StateAndStyleId.get(t._mediaType).default))};t._on("selected",i),t._on("deselected",n),t._funcChangeStyleToSelected=i,t._funcChangeStyleToDefault=n}this._changeItemStyle(t,s)}t._zIndex=this.id,t._drawingLayer=this,t._drawingLayerId=this.id;const a=this._arrFabricObject.length;let o=n.length;if(a)o=n.indexOf(this._arrFabricObject[a-1])+1;else for(let e=0;et.toLowerCase())):e=Bi.arrMediaTypes,i?i.forEach((t=>t.toLowerCase())):i=Bi.arrStyleSelectors;const n=jr.getDrawingStyle(t);if(!n)throw new Error(`The 'drawingStyle' with id '${t}' doesn't exist.`);let r;for(let s of e)if(r=this.mapType_StateAndStyleId.get(s),r)for(let e of i){this._changeMediaTypeCurStyleInStyleSelector(s,e,n,!0),r[e]=t;for(let i of this._arrDrwaingItem)i._mediaType===s&&i._mapState_StyleId.set(e,t)}this.fabricCanvas.renderAll()}setDefaultStyle(t,e,i){const n=[];i&wi.DIMT_RECTANGLE&&n.push("rect"),i&wi.DIMT_QUADRILATERAL&&n.push("quad"),i&wi.DIMT_TEXT&&n.push("text"),i&wi.DIMT_ARC&&n.push("arc"),i&wi.DIMT_IMAGE&&n.push("image"),i&wi.DIMT_POLYGON&&n.push("polygon"),i&wi.DIMT_LINE&&n.push("line");const r=[];e&Ci.DIS_DEFAULT&&r.push("default"),e&Ci.DIS_SELECTED&&r.push("selected"),this._setDefaultStyle(t,n.length?n:null,r.length?r:null)}setMode(t){if("viewer"===(t=t.toLowerCase())){for(let t of this._arrDrwaingItem)t._setEditable(!1);this.fabricCanvas.discardActiveObject(),this.fabricCanvas.renderAll(),this.mode="viewer"}else{if("editor"!==t)throw new RangeError("Invalid value.");for(let t of this._arrDrwaingItem)t._setEditable(!0);this.mode="editor"}this._manager._switchPointerEvent()}getMode(){return this.mode}_setDimensions(t,e){this.fabricCanvas.setDimensions(t,e)}_setObjectFit(t){if(t=t.toLowerCase(),!["contain","cover"].includes(t))throw new Error(`Unsupported value '${t}'.`);this.fabricCanvas.lowerCanvasEl.style.objectFit=t,this.fabricCanvas.upperCanvasEl.style.objectFit=t}_getObjectFit(){return this.fabricCanvas.lowerCanvasEl.style.objectFit}renderAll(){for(let t of this._arrDrwaingItem){const e=this._getItemCurrentStyle(t);this._changeItemStyle(t,e,!0)}this.fabricCanvas.renderAll()}dispose(){this.clearDrawingItems(),1===this._manager._arrDrawingLayer.length&&(this.fabricCanvas.wrapperEl.style.pointerEvents="none",this.fabricCanvas.dispose(),this._arrDrwaingItem.length=0,this._arrFabricObject.length=0)}}Vr.DDN_LAYER_ID=1,Vr.DBR_LAYER_ID=2,Vr.DLR_LAYER_ID=3,Vr.USER_DEFINED_LAYER_BASE_ID=100,Vr.TIP_LAYER_ID=999;class Ur{constructor(){this._arrDrawingLayer=[]}createDrawingLayer(t,e){if(this.getDrawingLayer(e))throw new Error("Existed drawing layer id.");const i=new Vr(t,e,{enableRetinaScaling:!1});return i._manager=this,this._arrDrawingLayer.push(i),this._switchPointerEvent(),i}deleteDrawingLayer(t){const e=this.getDrawingLayer(t);if(!e)return;const i=this._arrDrawingLayer;e.dispose(),i.splice(i.indexOf(e),1),this._switchPointerEvent()}clearDrawingLayers(){for(let t of this._arrDrawingLayer)t.dispose();this._arrDrawingLayer.length=0}getDrawingLayer(t){for(let e of this._arrDrawingLayer)if(e.getId()===t)return e;return null}getAllDrawingLayers(){return Array.from(this._arrDrawingLayer)}getSelectedDrawingItems(){if(!this._arrDrawingLayer.length)return;const t=this._getFabricCanvas().getActiveObjects(),e=[];for(let i of t)e.push(i.getDrawingItem());return e}setDimensions(t,e){this._arrDrawingLayer.length&&this._arrDrawingLayer[0]._setDimensions(t,e)}setObjectFit(t){for(let e of this._arrDrawingLayer)e&&e._setObjectFit(t)}getObjectFit(){return this._arrDrawingLayer.length?this._arrDrawingLayer[0]._getObjectFit():null}setVisible(t){this._arrDrawingLayer.length&&(this._getFabricCanvas().wrapperEl.style.display=t?"block":"none")}_getFabricCanvas(){return this._arrDrawingLayer.length?this._arrDrawingLayer[0].fabricCanvas:null}_switchPointerEvent(){if(this._arrDrawingLayer.length)for(let t of this._arrDrawingLayer)t.getMode()}}class Gr extends Xi{constructor(t,e,i,n,r){super(t,{x:e,y:i,width:n,height:0},r),mn.set(this,void 0),pn.set(this,void 0),this._fabricObject.paddingTop=15,this._fabricObject.calcTextHeight=function(){for(var t=0,e=0,i=this._textLines.length;e=0&&di(this,pn,setTimeout((()=>{this.set("visible",!1),this._drawingLayer&&this._drawingLayer.renderAll()}),ci(this,mn,"f")))}getDuration(){return ci(this,mn,"f")}}mn=new WeakMap,pn=new WeakMap;class Wr{constructor(){_n.add(this),vn.set(this,void 0),yn.set(this,void 0),wn.set(this,void 0),Cn.set(this,!0),this._drawingLayerManager=new Ur}createDrawingLayerBaseCvs(t,e,i="contain"){if("number"!=typeof t||t<=1)throw new Error("Invalid 'width'.");if("number"!=typeof e||e<=1)throw new Error("Invalid 'height'.");if(!["contain","cover"].includes(i))throw new Error("Unsupported 'objectFit'.");const n=document.createElement("canvas");return n.width==t&&n.height==e||(n.width=t,n.height=e),n.style.objectFit=i,n}_createDrawingLayer(t,e,i,n){if(!this._layerBaseCvs){let r;try{r=this.getContentDimensions()}catch(t){if("Invalid content dimensions."!==(t.message||t))throw t}e||(e=(null==r?void 0:r.width)||1280),i||(i=(null==r?void 0:r.height)||720),n||(n=(null==r?void 0:r.objectFit)||"contain"),this._layerBaseCvs=this.createDrawingLayerBaseCvs(e,i,n)}const r=this._layerBaseCvs,s=this._drawingLayerManager.createDrawingLayer(r,t);return this._innerComponent.getElement("drawing-layer")||this._innerComponent.setElement("drawing-layer",r.parentElement),s}createDrawingLayer(){let t;for(let e=Vr.USER_DEFINED_LAYER_BASE_ID;;e++)if(!this._drawingLayerManager.getDrawingLayer(e)&&e!==Vr.TIP_LAYER_ID){t=e;break}return this._createDrawingLayer(t)}deleteDrawingLayer(t){var e;this._drawingLayerManager.deleteDrawingLayer(t),this._drawingLayerManager.getAllDrawingLayers().length||(null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null)}deleteUserDefinedDrawingLayer(t){if("number"!=typeof t)throw new TypeError("Invalid id.");if(tt.getId()>=0&&t.getId()!==Vr.TIP_LAYER_ID))}updateDrawingLayers(t){((t,e,i)=>{if(!(t<=1||e<=1)){if(!["contain","cover"].includes(i))throw new Error("Unsupported 'objectFit'.");this._drawingLayerManager.setDimensions({width:t,height:e},{backstoreOnly:!0}),this._drawingLayerManager.setObjectFit(i)}})(t.width,t.height,t.objectFit)}getSelectedDrawingItems(){return this._drawingLayerManager.getSelectedDrawingItems()}setTipConfig(t){if(!(Qi(e=t)&&T(e.topLeftPoint)&&bi(e.width))||e.width<=0||!bi(e.duration)||"coordinateBase"in e&&!["view","image"].includes(e.coordinateBase))throw new Error("Invalid tip config.");var e;di(this,vn,JSON.parse(JSON.stringify(t))),ci(this,vn,"f").coordinateBase||(ci(this,vn,"f").coordinateBase="view"),di(this,wn,t.duration),ci(this,_n,"m",bn).call(this)}getTipConfig(){return ci(this,vn,"f")?ci(this,vn,"f"):null}setTipVisible(t){if("boolean"!=typeof t)throw new TypeError("Invalid value.");this._tip&&(this._tip.set("visible",t),this._drawingLayerOfTip&&this._drawingLayerOfTip.renderAll()),di(this,Cn,t)}isTipVisible(){return ci(this,Cn,"f")}updateTipMessage(t){if(!ci(this,vn,"f"))throw new Error("Tip config is not set.");this._tipStyleId||(this._tipStyleId=jr.createDrawingStyle({fillStyle:"#FFFFFF",paintMode:"fill",fontFamily:"Open Sans",fontSize:40})),this._drawingLayerOfTip||(this._drawingLayerOfTip=this._drawingLayerManager.getDrawingLayer(Vr.TIP_LAYER_ID)||this._createDrawingLayer(Vr.TIP_LAYER_ID)),this._tip?this._tip.set("text",t):this._tip=ci(this,_n,"m",En).call(this,t,ci(this,vn,"f").topLeftPoint.x,ci(this,vn,"f").topLeftPoint.y,ci(this,vn,"f").width,ci(this,vn,"f").coordinateBase,this._tipStyleId),ci(this,_n,"m",Sn).call(this,this._tip,this._drawingLayerOfTip),this._tip.set("visible",ci(this,Cn,"f")),this._drawingLayerOfTip&&this._drawingLayerOfTip.renderAll(),ci(this,yn,"f")&&clearTimeout(ci(this,yn,"f")),ci(this,wn,"f")>=0&&di(this,yn,setTimeout((()=>{ci(this,_n,"m",Tn).call(this)}),ci(this,wn,"f")))}}vn=new WeakMap,yn=new WeakMap,wn=new WeakMap,Cn=new WeakMap,_n=new WeakSet,En=function(t,e,i,n,r,s){const a=new Gr(t,e,i,n,s);return a.coordinateBase=r,a},Sn=function(t,e){e.hasDrawingItem(t)||e.addDrawingItems([t])},Tn=function(){this._tip&&this._drawingLayerOfTip.removeDrawingItems([this._tip])},bn=function(){if(!this._tip)return;const t=ci(this,vn,"f");this._tip.coordinateBase=t.coordinateBase,this._tip.setTextRect({x:t.topLeftPoint.x,y:t.topLeftPoint.y,width:t.width,height:0}),this._tip.set("width",this._tip.get("width")),this._tip._drawingLayer&&this._tip._drawingLayer.renderAll()};class Yr extends HTMLElement{constructor(){super(),In.set(this,void 0);const t=new DocumentFragment,e=document.createElement("div");e.setAttribute("class","wrapper"),t.appendChild(e),di(this,In,e);const i=document.createElement("slot");i.setAttribute("name","single-frame-input-container"),e.append(i);const n=document.createElement("slot");n.setAttribute("name","content"),e.append(n);const r=document.createElement("slot");r.setAttribute("name","drawing-layer"),e.append(r);const s=document.createElement("style");s.textContent='\n.wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n}\n::slotted(canvas[slot="content"]) {\n object-fit: contain;\n pointer-events: none;\n}\n::slotted(div[slot="single-frame-input-container"]) {\n width: 1px;\n height: 1px;\n overflow: hidden;\n pointer-events: none;\n}\n::slotted(*) {\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n}\n ',t.appendChild(s),this.attachShadow({mode:"open"}).appendChild(t)}getWrapper(){return ci(this,In,"f")}setElement(t,e){if(!(e instanceof HTMLElement))throw new TypeError("Invalid 'el'.");if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");this.removeElement(t),e.setAttribute("slot",t),this.appendChild(e)}getElement(t){if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");return this.querySelector(`[slot="${t}"]`)}removeElement(t){var e;if(!["content","single-frame-input-container","drawing-layer"].includes(t))throw new TypeError("Invalid 'slot'.");null===(e=this.querySelectorAll(`[slot="${t}"]`))||void 0===e||e.forEach((t=>t.remove()))}}In=new WeakMap,customElements.get("dce-component")||customElements.define("dce-component",Yr);class Hr extends Wr{static get engineResourcePath(){return D(Ft.engineResourcePaths).dcvData+"ui/"}static set defaultUIElementURL(t){Hr._defaultUIElementURL=t}static get defaultUIElementURL(){var t;return null===(t=Hr._defaultUIElementURL)||void 0===t?void 0:t.replace("@engineResourcePath/",Hr.engineResourcePath)}static async createInstance(t){const e=new Hr;return"string"==typeof t&&(t=t.replace("@engineResourcePath/",Hr.engineResourcePath)),await e.setUIElement(t||Hr.defaultUIElementURL),e}static _transformCoordinates(t,e,i,n,r,s,a){const o=s/n,l=a/r;t.x=Math.round(t.x/o+e),t.y=Math.round(t.y/l+i)}set _singleFrameMode(t){if(!["disabled","image","camera"].includes(t))throw new Error("Invalid value.");if(t!==ci(this,kn,"f")){if(di(this,kn,t),ci(this,xn,"m",jn).call(this))di(this,Dn,null),this._videoContainer=null,this._innerComponent.removeElement("content"),this._innerComponent&&(this._innerComponent.addEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="block");else if(this._innerComponent&&(this._innerComponent.removeEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none"),!ci(this,Dn,"f")){const t=document.createElement("video");t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.width="100%",t.style.height="100%",t.style.objectFit=this.getVideoFit(),t.setAttribute("autoplay","true"),t.setAttribute("playsinline","true"),t.setAttribute("crossOrigin","anonymous"),t.setAttribute("muted","true"),["iPhone","iPad","Mac"].includes(li.OS)&&t.setAttribute("poster","data:image/gif;base64,R0lGODlhAQABAIEAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgEAAEEBAA7"),di(this,Dn,t);const e=document.createElement("div");e.append(t),e.style.overflow="hidden",this._videoContainer=e,this._innerComponent.setElement("content",e)}ci(this,xn,"m",jn).call(this)||this._hideDefaultSelection?(this._selCam&&(this._selCam.style.display="none"),this._selRsl&&(this._selRsl.style.display="none"),this._selMinLtr&&(this._selMinLtr.style.display="none")):(this._selCam&&(this._selCam.style.display="block"),this._selRsl&&(this._selRsl.style.display="block"),this._selMinLtr&&(this._selMinLtr.style.display="block"),this._stopLoading())}}get _singleFrameMode(){return ci(this,kn,"f")}get disposed(){return ci(this,Bn,"f")}constructor(){super(),xn.add(this),Rn.set(this,void 0),On.set(this,void 0),An.set(this,void 0),this._poweredByVisible=!0,this.containerClassName="dce-video-container",Dn.set(this,void 0),this.videoFit="contain",this._hideDefaultSelection=!1,this._divScanArea=null,this._divScanLight=null,this._bgLoading=null,this._selCam=null,this._bgCamera=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,this._poweredBy=null,Mn.set(this,null),this.regionMaskFillStyle="rgba(0,0,0,0.5)",this.regionMaskStrokeStyle="rgb(254,142,20)",this.regionMaskLineWidth=6,Ln.set(this,!1),Fn.set(this,!1),Pn.set(this,{width:0,height:0}),this._updateLayersTimeout=500,this._videoResizeListener=()=>{ci(this,xn,"m",Yn).call(this),this._updateLayersTimeoutId&&clearTimeout(this._updateLayersTimeoutId),this._updateLayersTimeoutId=setTimeout((()=>{this.disposed||(this.eventHandler.fire("videoEl:resized",null,{async:!1}),this.eventHandler.fire("content:updated",null,{async:!1}),this.isScanLaserVisible()&&ci(this,xn,"m",Wn).call(this))}),this._updateLayersTimeout)},this._windowResizeListener=()=>{Hr._onLog&&Hr._onLog("window resize event triggered."),ci(this,Pn,"f").width===document.documentElement.clientWidth&&ci(this,Pn,"f").height===document.documentElement.clientHeight||(ci(this,Pn,"f").width=document.documentElement.clientWidth,ci(this,Pn,"f").height=document.documentElement.clientHeight,this._videoResizeListener())},kn.set(this,"disabled"),this._clickIptSingleFrameMode=()=>{if(!ci(this,xn,"m",jn).call(this))return;let t;if(this._singleFrameInputContainer)t=this._singleFrameInputContainer.firstElementChild;else{t=document.createElement("input"),t.setAttribute("type","file"),"camera"===this._singleFrameMode?(t.setAttribute("capture",""),t.setAttribute("accept","image/*")):"image"===this._singleFrameMode&&(t.removeAttribute("capture"),t.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp")),t.addEventListener("change",(async()=>{const e=t.files[0];t.value="";{const t=async t=>{let e=null,i=null;if("undefined"!=typeof createImageBitmap)try{if(e=await createImageBitmap(t),e)return e}catch(t){}var n;return e||(i=await(n=t,new Promise(((t,e)=>{let i=URL.createObjectURL(n),r=new Image;r.src=i,r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=t=>{e(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}})))),i},i=(t,e,i,n)=>{t.width==i&&t.height==n||(t.width=i,t.height=n);const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height),r.drawImage(e,0,0)},n=await t(e),r=n instanceof HTMLImageElement?n.naturalWidth:n.width,s=n instanceof HTMLImageElement?n.naturalHeight:n.height;let a=this._cvsSingleFrameMode;const o=null==a?void 0:a.width,l=null==a?void 0:a.height;a||(a=document.createElement("canvas"),this._cvsSingleFrameMode=a),i(a,n,r,s),this._innerComponent.setElement("content",a),o===a.width&&l===a.height||this.eventHandler.fire("content:updated",null,{async:!1})}this._onSingleFrameAcquired&&setTimeout((()=>{this._onSingleFrameAcquired(this._cvsSingleFrameMode)}),0)})),t.style.position="absolute",t.style.top="-9999px",t.style.backgroundColor="transparent",t.style.color="transparent";const e=document.createElement("div");e.append(t),this._innerComponent.setElement("single-frame-input-container",e),this._singleFrameInputContainer=e}null==t||t.click()},Nn.set(this,[]),this._capturedResultReceiver={onCapturedResultReceived:(t,e)=>{var i,n,r,s;if(this.disposed||e&&e._isPauseScan)return;if(this.clearAllInnerDrawingItems(),!t)return;const a=t.originalImageTag;if(!a)return;const o=t.items;if(!(null==o?void 0:o.length))return;const l=(null===(i=a.cropRegion)||void 0===i?void 0:i.left)||0,h=(null===(n=a.cropRegion)||void 0===n?void 0:n.top)||0,c=(null===(r=a.cropRegion)||void 0===r?void 0:r.right)?a.cropRegion.right-l:a.originalWidth,d=(null===(s=a.cropRegion)||void 0===s?void 0:s.bottom)?a.cropRegion.bottom-h:a.originalHeight,u=a.currentWidth,f=a.currentHeight,g=(t,e,i,n,r,s,a,o,l=[],h)=>{e.forEach((t=>Hr._transformCoordinates(t,i,n,r,s,a,o)));const c=new Ji({points:[{x:e[0].x,y:e[0].y},{x:e[1].x,y:e[1].y},{x:e[2].x,y:e[2].y},{x:e[3].x,y:e[3].y}]},h);for(let t of l)c.addNote(t);t.addDrawingItems([c]),ci(this,Nn,"f").push(c)};let m,p;for(let t of o)switch(t.type){case nt.CRIT_ORIGINAL_IMAGE:break;case nt.CRIT_BARCODE:m=this.getDrawingLayer(Vr.DBR_LAYER_ID),p=[{name:"format",content:t.formatString},{name:"text",content:t.text}],(null==e?void 0:e.isBarcodeVerifyOpen)?t.verified?g(m,t.location.points,l,h,c,d,u,f,p):g(m,t.location.points,l,h,c,d,u,f,p,jr.STYLE_ORANGE_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,d,u,f,p);break;case nt.CRIT_TEXT_LINE:m=this.getDrawingLayer(Vr.DLR_LAYER_ID),p=[{name:"text",content:t.text}],e.isLabelVerifyOpen?t.verified?g(m,t.location.points,l,h,c,d,u,f,p):g(m,t.location.points,l,h,c,d,u,f,p,jr.STYLE_GREEN_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,d,u,f,p);break;case nt.CRIT_DETECTED_QUAD:m=this.getDrawingLayer(Vr.DDN_LAYER_ID),(null==e?void 0:e.isDetectVerifyOpen)?t.crossVerificationStatus===dt.CVS_PASSED?g(m,t.location.points,l,h,c,d,u,f,[]):g(m,t.location.points,l,h,c,d,u,f,[],jr.STYLE_BLUE_STROKE_TRANSPARENT):g(m,t.location.points,l,h,c,d,u,f,[]);break;case nt.CRIT_DESKEWED_IMAGE:m=this.getDrawingLayer(Vr.DDN_LAYER_ID),(null==e?void 0:e.isNormalizeVerifyOpen)?t.crossVerificationStatus===dt.CVS_PASSED?g(m,t.sourceLocation.points,l,h,c,d,u,f,[]):g(m,t.sourceLocation.points,l,h,c,d,u,f,[],jr.STYLE_BLUE_STROKE_TRANSPARENT):g(m,t.sourceLocation.points,l,h,c,d,u,f,[]);break;case nt.CRIT_PARSED_RESULT:case nt.CRIT_ENHANCED_IMAGE:break;default:throw new Error("Illegal item type.")}if(t.decodedBarcodesResult)for(let e=0;eHr._transformCoordinates(t,l,h,c,d,u,f)));if(t.recognizedTextLinesResult)for(let e=0;eHr._transformCoordinates(t,l,h,c,d,u,f)));if(t.processedDocumentResult){if(t.processedDocumentResult.detectedQuadResultItems)for(let e=0;eHr._transformCoordinates(t,l,h,c,d,u,f)));if(t.processedDocumentResult.deskewedImageResultItems)for(let e=0;eHr._transformCoordinates(t,l,h,c,d,u,f)))}}},Bn.set(this,!1),this.eventHandler=new an,this.eventHandler.on("content:updated",(()=>{ci(this,Rn,"f")&&clearTimeout(ci(this,Rn,"f")),di(this,Rn,setTimeout((()=>{if(this.disposed)return;let t;this._updateVideoContainer();try{t=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}this.updateDrawingLayers(t),this.updateConvertedRegion(t)}),0))})),this.eventHandler.on("videoEl:resized",(()=>{ci(this,On,"f")&&clearTimeout(ci(this,On,"f")),di(this,On,setTimeout((()=>{this.disposed||this._updateVideoContainer()}),0))}))}_setUIElement(t){this.UIElement=t,this._unbindUI(),this._bindUI()}async setUIElement(t){let e;if("string"==typeof t){let i=await cn(t);e=document.createElement("div"),Object.assign(e.style,{width:"100%",height:"100%"}),e.attachShadow({mode:"open"}).appendChild(i.cloneNode(!0))}else e=t;this._setUIElement(e)}getUIElement(){return this.UIElement}_bindUI(){var t,e;if(!this.UIElement)throw new Error("Need to set 'UIElement'.");if(this._innerComponent)return;let i=this.UIElement;i=i.shadowRoot||i;let n=(null===(t=i.classList)||void 0===t?void 0:t.contains(this.containerClassName))?i:i.querySelector(`.${this.containerClassName}`);if(!n)throw Error(`Can not find the element with class '${this.containerClassName}'.`);if(this._innerComponent=document.createElement("dce-component"),n.appendChild(this._innerComponent),ci(this,xn,"m",jn).call(this));else{const t=document.createElement("video");Object.assign(t.style,{position:"absolute",left:"0",top:"0",width:"100%",height:"100%",objectFit:this.getVideoFit()}),t.setAttribute("autoplay","true"),t.setAttribute("playsinline","true"),t.setAttribute("crossOrigin","anonymous"),t.setAttribute("muted","true"),["iPhone","iPad","Mac"].includes(li.OS)&&t.setAttribute("poster","data:image/gif;base64,R0lGODlhAQABAIEAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgEAAEEBAA7"),di(this,Dn,t);const e=document.createElement("div");e.append(t),e.style.overflow="hidden",this._videoContainer=e,this._innerComponent.setElement("content",e)}if(this._selRsl=i.querySelector(".dce-sel-resolution"),this._selMinLtr=i.querySelector(".dlr-sel-minletter"),this._divScanArea=i.querySelector(".dce-scanarea"),this._divScanLight=i.querySelector(".dce-scanlight"),this._bgLoading=i.querySelector(".dce-bg-loading"),this._bgCamera=i.querySelector(".dce-bg-camera"),this._selCam=i.querySelector(".dce-sel-camera"),this._optGotRsl=i.querySelector(".dce-opt-gotResolution"),this._btnClose=i.querySelector(".dce-btn-close"),this._optGotMinLtr=i.querySelector(".dlr-opt-gotMinLtr"),this._poweredBy=i.querySelector(".dce-msg-poweredby"),this._selRsl&&(this._hideDefaultSelection||ci(this,xn,"m",jn).call(this)||this._selRsl.options.length||(this._selRsl.innerHTML=['','','',''].join(""),this._optGotRsl=this._selRsl.options[0])),this._selMinLtr&&(this._hideDefaultSelection||ci(this,xn,"m",jn).call(this)||this._selMinLtr.options.length||(this._selMinLtr.innerHTML=['','','','','','','','','','',''].join(""),this._optGotMinLtr=this._selMinLtr.options[0])),this.isScanLaserVisible()||ci(this,xn,"m",Yn).call(this),ci(this,xn,"m",jn).call(this)&&(this._innerComponent&&(this._innerComponent.addEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="block")),ci(this,xn,"m",jn).call(this)||this._hideDefaultSelection?(this._selCam&&(this._selCam.style.display="none"),this._selRsl&&(this._selRsl.style.display="none"),this._selMinLtr&&(this._selMinLtr.style.display="none")):(this._selCam&&(this._selCam.style.display="block"),this._selRsl&&(this._selRsl.style.display="block"),this._selMinLtr&&(this._selMinLtr.style.display="block"),this._stopLoading()),window.ResizeObserver){this._resizeObserver||(this._resizeObserver=new ResizeObserver((t=>{var e;Hr._onLog&&Hr._onLog("resize observer triggered.");for(let i of t)i.target===(null===(e=this._innerComponent)||void 0===e?void 0:e.getWrapper())&&this._videoResizeListener()})));const t=null===(e=this._innerComponent)||void 0===e?void 0:e.getWrapper();t&&this._resizeObserver.observe(t)}ci(this,Pn,"f").width=document.documentElement.clientWidth,ci(this,Pn,"f").height=document.documentElement.clientHeight,window.addEventListener("resize",this._windowResizeListener)}_unbindUI(){var t,e,i,n;ci(this,xn,"m",jn).call(this)?(this._innerComponent&&(this._innerComponent.removeEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none")):this._stopLoading(),ci(this,xn,"m",Yn).call(this),null===(t=this._drawingLayerManager)||void 0===t||t.clearDrawingLayers(),null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null,this._drawingLayerOfMask=null,this._drawingLayerOfTip=null,null===(i=this._innerComponent)||void 0===i||i.remove(),this._innerComponent=null,di(this,Dn,null),null===(n=this._videoContainer)||void 0===n||n.remove(),this._videoContainer=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,this._divScanArea=null,this._divScanLight=null,this._singleFrameInputContainer&&(this._singleFrameInputContainer.remove(),this._singleFrameInputContainer=null),window.ResizeObserver&&this._resizeObserver&&this._resizeObserver.disconnect(),window.removeEventListener("resize",this._windowResizeListener)}_startLoading(){this._bgLoading&&(this._bgLoading.style.display="",this._bgLoading.style.animationPlayState="")}_stopLoading(){this._bgLoading&&(this._bgLoading.style.display="none",this._bgLoading.style.animationPlayState="paused")}_renderCamerasInfo(t,e){if(this._selCam){let i;this._selCam.textContent="";for(let n of e){const e=document.createElement("option");e.value=n.deviceId,e.innerText=n.label,this._selCam.append(e),n.deviceId&&t&&t.deviceId==n.deviceId&&(i=e)}this._selCam.value=i?i.value:""}let i=this.UIElement;if(i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")){let t=i.querySelector(".dce-mn-cameras");if(t){t.textContent="";for(let i of e){const e=document.createElement("div");e.classList.add("dce-mn-camera-option"),e.setAttribute("data-davice-id",i.deviceId),e.textContent=i.label,t.append(e)}}}}_renderResolutionInfo(t){this._optGotRsl&&(this._optGotRsl.setAttribute("data-width",t.width),this._optGotRsl.setAttribute("data-height",t.height),this._optGotRsl.innerText="got "+t.width+"x"+t.height,this._selRsl&&this._optGotRsl.parentNode==this._selRsl&&(this._selRsl.value="got"));{let e=this.UIElement;e=(null==e?void 0:e.shadowRoot)||e;let i=null==e?void 0:e.querySelector(".dce-mn-resolution-box");if(i){let e="";if(t&&t.width&&t.height){let i=Math.max(t.width,t.height),n=Math.min(t.width,t.height);e=n<=1080?n+"P":i<3e3?"2K":Math.round(i/1e3)+"K"}i.textContent=e}}}getVideoElement(){return ci(this,Dn,"f")}isVideoLoaded(){return!(!ci(this,Dn,"f")||!this.cameraEnhancer)&&4==ci(this,Dn,"f").readyState}setVideoFit(t){if(t=t.toLowerCase(),!["contain","cover"].includes(t))throw new Error(`Unsupported value '${t}'.`);if(this.videoFit=t,!ci(this,Dn,"f"))return;if(ci(this,Dn,"f").style.objectFit=t,ci(this,xn,"m",jn).call(this))return;let e;this._updateVideoContainer();try{e=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}this.updateConvertedRegion(e);const i=this.getConvertedRegion();ci(this,xn,"m",Hn).call(this,e,i),ci(this,xn,"m",Vn).call(this,e,i),this.updateDrawingLayers(e)}getVideoFit(){return this.videoFit}getContentDimensions(){var t,e,i,n;let r,s,a;if(ci(this,xn,"m",jn).call(this)?(r=null===(i=this._cvsSingleFrameMode)||void 0===i?void 0:i.width,s=null===(n=this._cvsSingleFrameMode)||void 0===n?void 0:n.height,a="contain"):(r=null===(t=ci(this,Dn,"f"))||void 0===t?void 0:t.videoWidth,s=null===(e=ci(this,Dn,"f"))||void 0===e?void 0:e.videoHeight,a=this.getVideoFit()),!r||!s)throw new Error("Invalid content dimensions.");return{width:r,height:s,objectFit:a}}updateConvertedRegion(t){C(this.scanRegion)?this.scanRegion.isMeasuredInPercentage?0===this.scanRegion.top&&100===this.scanRegion.bottom&&0===this.scanRegion.left&&100===this.scanRegion.right&&(this.scanRegion=null):0===this.scanRegion.top&&this.scanRegion.bottom===t.height&&0===this.scanRegion.left&&this.scanRegion.right===t.width&&(this.scanRegion=null):x(this.scanRegion)&&(this.scanRegion.isMeasuredInPercentage?0===this.scanRegion.x&&0===this.scanRegion.y&&100===this.scanRegion.width&&100===this.scanRegion.height&&(this.scanRegion=null):0===this.scanRegion.x&&0===this.scanRegion.y&&this.scanRegion.width===t.width&&this.scanRegion.height===t.height&&(this.scanRegion=null));const e=nn.convert(this.scanRegion,t.width,t.height,this);di(this,Mn,e),ci(this,An,"f")&&clearTimeout(ci(this,An,"f")),di(this,An,setTimeout((()=>{let t;try{t=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}ci(this,xn,"m",Vn).call(this,t,e),ci(this,xn,"m",Hn).call(this,t,e)}),0))}getConvertedRegion(){return ci(this,Mn,"f")}setScanRegion(t){if(null!=t&&!C(t)&&!x(t))throw TypeError("Invalid 'region'.");let e;this.scanRegion=t?JSON.parse(JSON.stringify(t)):null;try{e=this.getContentDimensions()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}this.updateConvertedRegion(e)}getScanRegion(){return JSON.parse(JSON.stringify(this.scanRegion))}getVisibleRegionOfVideo(t){if("disabled"!==this.cameraEnhancer.singleFrameMode)return null;if(!this.isVideoLoaded())throw new Error("The video is not loaded.");const e=ci(this,Dn,"f").videoWidth,i=ci(this,Dn,"f").videoHeight,n=this.getVideoFit(),{width:r,height:s}=this._innerComponent.getBoundingClientRect();if(r<=0||s<=0)return null;let a;const o={x:0,y:0,width:e,height:i,isMeasuredInPercentage:!1};if("cover"===n&&(r/s1){const t=ci(this,Dn,"f").videoWidth,e=ci(this,Dn,"f").videoHeight,{width:n,height:r}=this._innerComponent.getBoundingClientRect(),s=t/e;if(n/rt.remove())),ci(this,Nn,"f").length=0}dispose(){this._unbindUI(),di(this,Bn,!0)}}Rn=new WeakMap,On=new WeakMap,An=new WeakMap,Dn=new WeakMap,Mn=new WeakMap,Ln=new WeakMap,Fn=new WeakMap,Pn=new WeakMap,kn=new WeakMap,Nn=new WeakMap,Bn=new WeakMap,xn=new WeakSet,jn=function(){return"disabled"!==this._singleFrameMode},Vn=function(t,e){!e||0===e.x&&0===e.y&&e.width===t.width&&e.height===t.height?this.clearScanRegionMask():this.setScanRegionMask(e.x,e.y,e.width,e.height)},Un=function(){this._drawingLayerOfMask&&this._drawingLayerOfMask.setVisible(!0)},Gn=function(){this._drawingLayerOfMask&&this._drawingLayerOfMask.setVisible(!1)},Wn=function(){this._divScanLight&&"none"==this._divScanLight.style.display&&(this._divScanLight.style.display="block")},Yn=function(){this._divScanLight&&(this._divScanLight.style.display="none")},Hn=function(t,e){if(!this._divScanArea)return;if(!this._innerComponent.getElement("content"))return;const{width:i,height:n,objectFit:r}=t;e||(e={x:0,y:0,width:i,height:n});const{width:s,height:a}=this._innerComponent.getBoundingClientRect();if(s<=0||a<=0)return;const o=s/a,l=i/n;let h,c,d,u,f=1;if("contain"===r)o{const e=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,e),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);const i=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),{positions:e,texCoords:i}},i=t=>{const e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e},n=(t,e)=>{const i=t.createProgram();if(e.forEach((e=>t.attachShader(i,e))),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS)){const e=new Error(`An error occured linking the program: ${t.getProgramInfoLog(i)}.`);throw e.name="WebGLError",e}return t.useProgram(i),i},r=(t,e,i)=>{const n=t.createShader(e);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){const e=new Error(`An error occured compiling the shader: ${t.getShaderInfoLog(n)}.`);throw e.name="WebGLError",e}return n},s="\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n\n uniform mat3 u_matrix;\n uniform mat3 u_textureMatrix;\n\n varying vec2 v_texCoord;\n void main(void) {\n gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, 0, 1.0);\n v_texCoord = vec4((u_textureMatrix * vec3(a_texCoord, 1)).xy, 0, 1.0).xy;\n }\n ";let a="rgb";["rgba","rbga","grba","gbra","brga","bgra"].includes(p)&&(a=p.slice(0,3));const o=`\n precision mediump float;\n varying vec2 v_texCoord;\n uniform sampler2D u_image;\n uniform float uColorFactor;\n\n void main() {\n vec4 sample = texture2D(u_image, v_texCoord);\n float grey = 0.3 * sample.r + 0.59 * sample.g + 0.11 * sample.b;\n gl_FragColor = vec4(sample.${a} * (1.0 - uColorFactor) + (grey * uColorFactor), sample.a);\n }\n `,l=n(t,[r(t,t.VERTEX_SHADER,s),r(t,t.FRAGMENT_SHADER,o)]);di(this,qn,{program:l,attribLocations:{vertexPosition:t.getAttribLocation(l,"a_position"),texPosition:t.getAttribLocation(l,"a_texCoord")},uniformLocations:{uSampler:t.getUniformLocation(l,"u_image"),uColorFactor:t.getUniformLocation(l,"uColorFactor"),uMatrix:t.getUniformLocation(l,"u_matrix"),uTextureMatrix:t.getUniformLocation(l,"u_textureMatrix")}}),di(this,Zn,e(t)),di(this,Xn,i(t)),di(this,zn,p)}const r=(t,e,i)=>{t.bindBuffer(t.ARRAY_BUFFER,e),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0)},v=(t,e,i)=>{const n=t.RGBA,r=t.RGBA,s=t.UNSIGNED_BYTE;t.bindTexture(t.TEXTURE_2D,e),t.texImage2D(t.TEXTURE_2D,0,n,r,s,i)},y=(t,e,a,m)=>{t.clearColor(0,0,0,1),t.clearDepth(1),t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),r(t,a.positions,e.attribLocations.vertexPosition),r(t,a.texCoords,e.attribLocations.texPosition),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,m),t.uniform1i(e.uniformLocations.uSampler,0),t.uniform1f(e.uniformLocations.uColorFactor,[Si.GREY,Si.GREY32].includes(p)?1:0);let _,v,y=dn.translate(dn.identity(),-1,-1);y=dn.scale(y,2,2),y=dn.scale(y,1/t.canvas.width,1/t.canvas.height),_=dn.translate(y,d,u),_=dn.scale(_,f,g),t.uniformMatrix3fv(e.uniformLocations.uMatrix,!1,_),s.isEnableMirroring?(v=dn.translate(dn.identity(),1,0),v=dn.scale(v,-1,1),v=dn.translate(v,o/i,l/n),v=dn.scale(v,h/i,c/n)):(v=dn.translate(dn.identity(),o/i,l/n),v=dn.scale(v,h/i,c/n)),t.uniformMatrix3fv(e.uniformLocations.uTextureMatrix,!1,v),t.drawArrays(t.TRIANGLES,0,6)};v(t,ci(this,Xn,"f"),e),y(t,ci(this,qn,"f"),ci(this,Zn,"f"),ci(this,Xn,"f"));const w=m||new Uint8Array(4*f*g);if(t.readPixels(d,u,f,g,t.RGBA,t.UNSIGNED_BYTE,w),255!==w[3]){zr._onLog&&zr._onLog("Incorrect WebGL drawing .");const t=new Error("WebGL error: incorrect drawing.");throw t.name="WebGLError",t}return zr._onLog&&zr._onLog("drawImage() in WebGL end. Costs: "+(Date.now()-a)),{context:t,pixelFormat:p===Si.GREY?Si.GREY32:p,bUseWebGL:!0}}catch(a){if(this.forceLoseContext(),null==(null==s?void 0:s.bUseWebGL))return zr._onLog&&zr._onLog("'drawImage()' in WebGL failed, try again in context2d."),this.useWebGLByDefault=!1,this.drawImage(t,e,i,n,r,Object.assign({},s,{bUseWebGL:!1}));throw a.name="WebGLError",a}}readCvsData(t,e,i){if(!(t instanceof CanvasRenderingContext2D||t instanceof WebGLRenderingContext))throw new Error("Invalid 'context'.");let n,r=0,s=0,a=t.canvas.width,o=t.canvas.height;if(e&&(e.x&&(r=e.x),e.y&&(s=e.y),e.width&&(a=e.width),e.height&&(o=e.height)),(null==i?void 0:i.length)<4*a*o)throw new Error("Unexpected size of the 'bufferContainer'.");if(t instanceof WebGLRenderingContext){const e=t;i?(e.readPixels(r,s,a,o,e.RGBA,e.UNSIGNED_BYTE,i),n=new Uint8Array(i.buffer,0,4*a*o)):(n=new Uint8Array(4*a*o),e.readPixels(r,s,a,o,e.RGBA,e.UNSIGNED_BYTE,n))}else if(t instanceof CanvasRenderingContext2D){let e;e=t.getImageData(r,s,a,o),n=new Uint8Array(e.data.buffer),null==i||i.set(n)}return n}transformPixelFormat(t,e,i,n){let r,s;if(zr._onLog&&(r=Date.now(),zr._onLog("transformPixelFormat(), START: "+r)),e===i)return zr._onLog&&zr._onLog("transformPixelFormat() end. Costs: "+(Date.now()-r)),n?new Uint8Array(t):t;const a=[Si.RGBA,Si.RBGA,Si.GRBA,Si.GBRA,Si.BRGA,Si.BGRA];if(a.includes(e))if(i===Si.GREY){s=new Uint8Array(t.length/4);for(let e=0;el||e.sy+e.sHeight>h)throw new Error("Invalid position.");null===(n=zr._onLog)||void 0===n||n.call(zr,"getImageData(), START: "+(c=Date.now()));const u=Math.round(e.sx),f=Math.round(e.sy),g=Math.round(e.sWidth),m=Math.round(e.sHeight),p=Math.round(e.dWidth),_=Math.round(e.dHeight);let v,y=(null==i?void 0:i.pixelFormat)||Si.RGBA,w=null==i?void 0:i.bufferContainer;if(w&&(Si.GREY===y&&w.length{if(!i)return t;let r=e+Math.round((t-e)/i)*i;return n&&(r=Math.min(r,n)),r};class qr{static get version(){return"4.2.12-dev-20250609101854"}static isStorageAvailable(t){let e;try{e=window[t];const i="__storage_test__";return e.setItem(i,i),e.removeItem(i),!0}catch(t){return t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name)&&e&&0!==e.length}}static findBestRearCameraInIOS(t,e){if(!t||!t.length)return null;let i=!1;if((null==e?void 0:e.getMainCamera)&&(i=!0),i){const e=["후면 카메라","背面カメラ","後置鏡頭","后置相机","กล้องด้านหลัง","बैक कैमरा","الكاميرا الخلفية","מצלמה אחורית","камера на задней панели","задня камера","задна камера","артқы камера","πίσω κάμερα","zadní fotoaparát","zadná kamera","tylny aparat","takakamera","stražnja kamera","rückkamera","kamera på baksidan","kamera belakang","kamera bak","hátsó kamera","fotocamera (posteriore)","câmera traseira","câmara traseira","cámara trasera","càmera posterior","caméra arrière","cameră spate","camera mặt sau","camera aan achterzijde","bagsidekamera","back camera","arka kamera"],i=t.find((t=>e.includes(t.label.toLowerCase())));return null==i?void 0:i.deviceId}{const e=["후면","背面","後置","后置","านหลัง","बैक","خلفية","אחורית","задняя","задней","задна","πίσω","zadní","zadná","tylny","trasera","traseira","taka","stražnja","spate","sau","rück","posteriore","posterior","hátsó","belakang","baksidan","bakre","bak","bagside","back","aртқы","arrière","arka","achterzijde"],i=["트리플","三镜头","三鏡頭","トリプル","สาม","ट्रिपल","ثلاثية","משולשת","үштік","тройная","тройна","потроєна","τριπλή","üçlü","trójobiektywowy","trostruka","trojný","trojitá","trippelt","trippel","triplă","triple","tripla","tiga","kolmois","ba camera"],n=["듀얼 와이드","雙廣角","双广角","デュアル広角","คู่ด้านหลังมุมกว้าง","ड्युअल वाइड","مزدوجة عريضة","כפולה רחבה","қос кең бұрышты","здвоєна ширококутна","двойная широкоугольная","двойна широкоъгълна","διπλή ευρεία","ç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"],r=t.filter((t=>{const i=t.label.toLowerCase();return e.some((t=>i.includes(t)))}));if(!r.length)return null;const s=r.find((t=>{const e=t.label.toLowerCase();return i.some((t=>e.includes(t)))}));if(s)return s.deviceId;const a=r.find((t=>{const e=t.label.toLowerCase();return n.some((t=>e.includes(t)))}));return a?a.deviceId:r[0].deviceId}}static findBestRearCamera(t,e){if(!t||!t.length)return null;if(["iPhone","iPad","Mac"].includes(li.OS))return qr.findBestRearCameraInIOS(t,{getMainCamera:null==e?void 0:e.getMainCameraInIOS});const i=["후","背面","背置","後面","後置","后面","后置","านหลัง","หลัง","बैक","خلفية","אחורית","задняя","задня","задней","задна","πίσω","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"];for(let e of t){const t=e.label.toLowerCase();if(t&&i.some((e=>t.includes(e)))&&/\b0(\b)?/.test(t))return e.deviceId}return["Android","HarmonyOS"].includes(li.OS)?t[t.length-1].deviceId:null}static findBestCamera(t,e,i){return t&&t.length?"environment"===e?this.findBestRearCamera(t,i):"user"===e?null:e?void 0:null:null}static async playVideo(t,e,i){if(!t)throw new Error("Invalid 'videoEl'.");if(!e)throw new Error("Invalid 'source'.");return new Promise((async(n,r)=>{let s;const a=()=>{t.removeEventListener("loadstart",c),t.removeEventListener("abort",d),t.removeEventListener("play",u),t.removeEventListener("error",f),t.removeEventListener("loadedmetadata",p)};let o=!1;const l=()=>{o=!0,s&&clearTimeout(s),a(),n(t)},h=t=>{s&&clearTimeout(s),a(),r(t)},c=()=>{t.addEventListener("abort",d,{once:!0})},d=()=>{const t=new Error("Video playing was interrupted.");t.name="AbortError",h(t)},u=()=>{l()},f=()=>{h(new Error(`Video error ${t.error.code}: ${t.error.message}.`))};let g;const m=new Promise((t=>{g=t})),p=()=>{g()};if(t.addEventListener("loadstart",c,{once:!0}),t.addEventListener("play",u,{once:!0}),t.addEventListener("error",f,{once:!0}),t.addEventListener("loadedmetadata",p,{once:!0}),"string"==typeof e||e instanceof String?t.src=e:t.srcObject=e,t.autoplay&&await new Promise((t=>{setTimeout(t,1e3)})),!o){i&&(s=setTimeout((()=>{a(),r(new Error("Failed to play video. Timeout."))}),i)),await m;try{await t.play(),l()}catch(t){console.warn("1st play error: "+((null==t?void 0:t.message)||t))}if(!o)try{await t.play(),l()}catch(t){console.warn("2rd play error: "+((null==t?void 0:t.message)||t)),h(t)}}}))}static async testCameraAccess(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))return{ok:!1,errorName:"InsecureContext",errorMessage:"Insecure context."};let n;try{n=t?await navigator.mediaDevices.getUserMedia(t):await navigator.mediaDevices.getUserMedia({video:!0})}catch(t){return{ok:!1,errorName:t.name,errorMessage:t.message}}finally{null==n||n.getTracks().forEach((t=>{t.stop()}))}return{ok:!0}}get state(){if(!ci(this,dr,"f"))return"closed";if("pending"===ci(this,dr,"f"))return"opening";if("fulfilled"===ci(this,dr,"f"))return"opened";throw new Error("Unknown state.")}set ifSaveLastUsedCamera(t){t?qr.isStorageAvailable("localStorage")?di(this,or,!0):(di(this,or,!1),console.warn("Local storage is unavailable")):di(this,or,!1)}get ifSaveLastUsedCamera(){return ci(this,or,"f")}get isVideoPlaying(){return!(!ci(this,tr,"f")||ci(this,tr,"f").paused)&&"opened"===this.state}set tapFocusEventBoundEl(t){var e,i,n;if(!(t instanceof HTMLElement)&&null!=t)throw new TypeError("Invalid 'element'.");null===(e=ci(this,_r,"f"))||void 0===e||e.removeEventListener("click",ci(this,pr,"f")),null===(i=ci(this,_r,"f"))||void 0===i||i.removeEventListener("touchend",ci(this,pr,"f")),null===(n=ci(this,_r,"f"))||void 0===n||n.removeEventListener("touchmove",ci(this,mr,"f")),di(this,_r,t),t&&(window.TouchEvent&&["Android","HarmonyOS","iPhone","iPad"].includes(li.OS)?(t.addEventListener("touchend",ci(this,pr,"f")),t.addEventListener("touchmove",ci(this,mr,"f"))):t.addEventListener("click",ci(this,pr,"f")))}get tapFocusEventBoundEl(){return ci(this,_r,"f")}get disposed(){return ci(this,Ir,"f")}constructor(t){var e,i;Qn.add(this),tr.set(this,null),er.set(this,void 0),this._zoomPreSetting=null,ir.set(this,(()=>{"opened"===this.state&&ci(this,Cr,"f").fire("resumed",null,{target:this,async:!1})})),nr.set(this,(()=>{ci(this,Cr,"f").fire("paused",null,{target:this,async:!1})})),rr.set(this,void 0),sr.set(this,void 0),this.cameraOpenTimeout=15e3,this._arrCameras=[],ar.set(this,void 0),or.set(this,!1),this.ifSkipCameraInspection=!1,this.selectIOSRearMainCameraAsDefault=!1,lr.set(this,void 0),hr.set(this,!0),cr.set(this,void 0),dr.set(this,void 0),ur.set(this,!1),this._focusParameters={maxTimeout:400,minTimeout:300,kTimeout:void 0,oldDistance:null,fds:null,isDoingFocus:0,taskBackToContinous:null,curFocusTaskId:0,focusCancelableTime:1500,defaultFocusAreaSizeRatio:6,focusBackToContinousTime:5e3,tapFocusMinDistance:null,tapFocusMaxDistance:null,focusArea:null,tempBufferContainer:null,defaultTempBufferContainerLenRatio:1/4},fr.set(this,!1),this._focusSupported=!0,this.calculateCoordInVideo=(t,e)=>{let i,n;const r=window.getComputedStyle(ci(this,tr,"f")).objectFit,s=this.getResolution(),a=ci(this,tr,"f").getBoundingClientRect(),o=a.left,l=a.top,{width:h,height:c}=ci(this,tr,"f").getBoundingClientRect();if(h<=0||c<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const d=h/c,u=s.width/s.height;let f=1;if("contain"===r)u>d?(f=h/s.width,i=(t-o)/f,n=(e-l-(c-h/u)/2)/f):(f=c/s.height,n=(e-l)/f,i=(t-o-(h-c*u)/2)/f);else{if("cover"!==r)throw new Error("Unsupported object-fit.");u>d?(f=c/s.height,n=(e-l)/f,i=(t-o+(c*u-h)/2)/f):(f=h/s.width,i=(t-o)/f,n=(e-l+(h/u-c)/2)/f)}return{x:i,y:n}},gr.set(this,!1),mr.set(this,(()=>{di(this,gr,!0)})),pr.set(this,(async t=>{var e;if(ci(this,gr,"f"))return void di(this,gr,!1);if(!ci(this,fr,"f"))return;if(!this.isVideoPlaying)return;if(!ci(this,er,"f"))return;if(!this._focusSupported)return;if(!this._focusParameters.fds&&(this._focusParameters.fds=null===(e=this.getCameraCapabilities())||void 0===e?void 0:e.focusDistance,!this._focusParameters.fds))return void(this._focusSupported=!1);if(null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),1==this._focusParameters.isDoingFocus)return;let i,n;if(this._focusParameters.taskBackToContinous&&(clearTimeout(this._focusParameters.taskBackToContinous),this._focusParameters.taskBackToContinous=null),t instanceof MouseEvent)i=t.clientX,n=t.clientY;else{if(!(t instanceof TouchEvent))throw new Error("Unknown event type.");if(!t.changedTouches.length)return;i=t.changedTouches[0].clientX,n=t.changedTouches[0].clientY}const r=this.getResolution(),s=2*Math.round(Math.min(r.width,r.height)/this._focusParameters.defaultFocusAreaSizeRatio/2);let a;try{a=this.calculateCoordInVideo(i,n)}catch(t){}if(a.x<0||a.x>r.width||a.y<0||a.y>r.height)return;const o={x:a.x+"px",y:a.y+"px"},l=s+"px",h=l;let c;qr._onLog&&(c=Date.now());try{await ci(this,Qn,"m",kr).call(this,o,l,h,this._focusParameters.tapFocusMinDistance,this._focusParameters.tapFocusMaxDistance)}catch(t){if(qr._onLog)throw qr._onLog(t),t}qr._onLog&&qr._onLog(`Tap focus costs: ${Date.now()-c} ms`),this._focusParameters.taskBackToContinous=setTimeout((()=>{var t;qr._onLog&&qr._onLog("Back to continuous focus."),null===(t=ci(this,er,"f"))||void 0===t||t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch((()=>{}))}),this._focusParameters.focusBackToContinousTime),ci(this,Cr,"f").fire("tapfocus",null,{target:this,async:!1})})),_r.set(this,null),vr.set(this,1),yr.set(this,{x:0,y:0}),this.updateVideoElWhenSoftwareScaled=()=>{if(!ci(this,tr,"f"))return;const t=ci(this,vr,"f");if(t<1)throw new RangeError("Invalid scale value.");if(1===t)ci(this,tr,"f").style.transform="";else{const e=window.getComputedStyle(ci(this,tr,"f")).objectFit,i=ci(this,tr,"f").videoWidth,n=ci(this,tr,"f").videoHeight,{width:r,height:s}=ci(this,tr,"f").getBoundingClientRect();if(r<=0||s<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const a=r/s,o=i/n;let l=1;"contain"===e?l=aa?s/(i/t):r/(n/t));const h=l*(1-1/t)*(i/2-ci(this,yr,"f").x),c=l*(1-1/t)*(n/2-ci(this,yr,"f").y);ci(this,tr,"f").style.transform=`translate(${h}px, ${c}px) scale(${t})`}},wr.set(this,(function(){if(!(this.data instanceof Uint8Array||this.data instanceof Uint8ClampedArray))throw new TypeError("Invalid data.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const t=document.createElement("canvas");let e;if(t.width=this.width,t.height=this.height,this.pixelFormat===Si.GREY){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t{var t,e;if("visible"===document.visibilityState){if(qr._onLog&&qr._onLog("document visible. video paused: "+(null===(t=ci(this,tr,"f"))||void 0===t?void 0:t.paused)),"opening"==this.state||"opened"==this.state){let e=!1;if(!this.isVideoPlaying){qr._onLog&&qr._onLog("document visible. Not auto resume. 1st resume start.");try{await this.resume(),e=!0}catch(t){qr._onLog&&qr._onLog("document visible. 1st resume video failed, try open instead.")}e||await ci(this,Qn,"m",Dr).call(this)}if(await new Promise((t=>setTimeout(t,300))),!this.isVideoPlaying){qr._onLog&&qr._onLog("document visible. 1st open failed. 2rd resume start."),e=!1;try{await this.resume(),e=!0}catch(t){qr._onLog&&qr._onLog("document visible. 2rd resume video failed, try open instead.")}e||await ci(this,Qn,"m",Dr).call(this)}}}else"hidden"===document.visibilityState&&(qr._onLog&&qr._onLog("document hidden. video paused: "+(null===(e=ci(this,tr,"f"))||void 0===e?void 0:e.paused)),"opening"==this.state||"opened"==this.state&&this.isVideoPlaying&&this.pause())})),Ir.set(this,!1),(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia)||setTimeout((()=>{qr.onWarning&&qr.onWarning("The browser is too old or the page is loaded from an insecure origin.")}),0),this.defaultConstraints={video:{facingMode:{ideal:"environment"}}},this.resetMediaStreamConstraints(),t instanceof HTMLVideoElement&&this.setVideoEl(t),di(this,Cr,new an),this.imageDataGetter=new zr,document.addEventListener("visibilitychange",ci(this,br,"f"))}setVideoEl(t){if(!(t&&t instanceof HTMLVideoElement))throw new Error("Invalid 'videoEl'.");t.addEventListener("play",ci(this,ir,"f")),t.addEventListener("pause",ci(this,nr,"f")),di(this,tr,t)}getVideoEl(){return ci(this,tr,"f")}releaseVideoEl(){var t,e;null===(t=ci(this,tr,"f"))||void 0===t||t.removeEventListener("play",ci(this,ir,"f")),null===(e=ci(this,tr,"f"))||void 0===e||e.removeEventListener("pause",ci(this,nr,"f")),di(this,tr,null)}isVideoLoaded(){return!!ci(this,tr,"f")&&4==ci(this,tr,"f").readyState}async open(){if(ci(this,cr,"f")&&!ci(this,hr,"f")){if("pending"===ci(this,dr,"f"))return ci(this,cr,"f");if("fulfilled"===ci(this,dr,"f"))return}ci(this,Cr,"f").fire("before:open",null,{target:this}),await ci(this,Qn,"m",Dr).call(this),ci(this,Cr,"f").fire("played",null,{target:this,async:!1}),ci(this,Cr,"f").fire("opened",null,{target:this,async:!1})}async close(){if("closed"===this.state)return;ci(this,Cr,"f").fire("before:close",null,{target:this});const t=ci(this,cr,"f");if(ci(this,Qn,"m",Lr).call(this),t&&"pending"===ci(this,dr,"f")){try{await t}catch(t){}if(!1===ci(this,hr,"f")){const t=new Error("'close()' was interrupted.");throw t.name="AbortError",t}}di(this,cr,null),di(this,dr,null),ci(this,Cr,"f").fire("closed",null,{target:this,async:!1})}pause(){if(!this.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==this.state)throw new Error("Camera or video is not open.");ci(this,tr,"f").pause()}async resume(){if(!this.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==this.state)throw new Error("Camera or video is not open.");await ci(this,tr,"f").play()}async setCamera(t){if("string"!=typeof t)throw new TypeError("Invalid 'deviceId'.");if("object"!=typeof ci(this,rr,"f").video&&(ci(this,rr,"f").video={}),delete ci(this,rr,"f").video.facingMode,ci(this,rr,"f").video.deviceId={exact:t},!("closed"===this.state||this.videoSrc||"opening"===this.state&&ci(this,hr,"f"))){ci(this,Cr,"f").fire("before:camera:change",[],{target:this,async:!1}),await ci(this,Qn,"m",Mr).call(this);try{this.resetSoftwareScale()}catch(t){}return ci(this,sr,"f")}}async switchToFrontCamera(t){if("object"!=typeof ci(this,rr,"f").video&&(ci(this,rr,"f").video={}),(null==t?void 0:t.resolution)&&(ci(this,rr,"f").video.width={ideal:t.resolution.width},ci(this,rr,"f").video.height={ideal:t.resolution.height}),delete ci(this,rr,"f").video.deviceId,ci(this,rr,"f").video.facingMode={exact:"user"},di(this,ar,null),!("closed"===this.state||this.videoSrc||"opening"===this.state&&ci(this,hr,"f"))){ci(this,Cr,"f").fire("before:camera:change",[],{target:this,async:!1}),ci(this,Qn,"m",Mr).call(this);try{this.resetSoftwareScale()}catch(t){}return ci(this,sr,"f")}}getCamera(){var t;if(ci(this,sr,"f"))return ci(this,sr,"f");{let e=(null===(t=ci(this,rr,"f").video)||void 0===t?void 0:t.deviceId)||"";if(e){e=e.exact||e.ideal||e;for(let t of this._arrCameras)if(t.deviceId===e)return JSON.parse(JSON.stringify(t))}return{deviceId:"",label:"",_checked:!1}}}async _getCameras(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let n=[];if(t)try{let t=await navigator.mediaDevices.getUserMedia({video:!0});n=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind)),t.getTracks().forEach((t=>{t.stop()}))}catch(t){console.error(t.message||t)}else n=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind));const r=[],s=[];if(this._arrCameras)for(let t of this._arrCameras)t._checked&&s.push(t);for(let t=0;t"videoinput"===t.kind));return i&&i.length&&!i[0].deviceId?this._getCameras(!0):this._getCameras(!1)}async getAllCameras(){return this.getCameras()}async setResolution(t,e,i){if("number"!=typeof t||t<=0)throw new TypeError("Invalid 'width'.");if("number"!=typeof e||e<=0)throw new TypeError("Invalid 'height'.");if("object"!=typeof ci(this,rr,"f").video&&(ci(this,rr,"f").video={}),i?(ci(this,rr,"f").video.width={exact:t},ci(this,rr,"f").video.height={exact:e}):(ci(this,rr,"f").video.width={ideal:t},ci(this,rr,"f").video.height={ideal:e}),"closed"===this.state||this.videoSrc||"opening"===this.state&&ci(this,hr,"f"))return null;ci(this,Cr,"f").fire("before:resolution:change",[],{target:this,async:!1}),await ci(this,Qn,"m",Mr).call(this);try{this.resetSoftwareScale()}catch(t){}const n=this.getResolution();return{width:n.width,height:n.height}}getResolution(){if("opened"===this.state&&this.videoSrc&&ci(this,tr,"f"))return{width:ci(this,tr,"f").videoWidth,height:ci(this,tr,"f").videoHeight};if(ci(this,er,"f")){const t=ci(this,er,"f").getSettings();return{width:t.width,height:t.height}}if(this.isVideoLoaded())return{width:ci(this,tr,"f").videoWidth,height:ci(this,tr,"f").videoHeight};{const t={width:0,height:0};let e=ci(this,rr,"f").video.width||0,i=ci(this,rr,"f").video.height||0;return e&&(t.width=e.exact||e.ideal||e),i&&(t.height=i.exact||i.ideal||i),t}}async getResolutions(t){var e,i,n,r,s,a,o,l,h,c,d;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let u="";const f=(t,e)=>{const i=ci(this,Sr,"f").get(t);if(!i||!i.length)return!1;for(let t of i)if(t.width===e.width&&t.height===e.height)return!0;return!1};if(this._mediaStream){u=null===(d=ci(this,sr,"f"))||void 0===d?void 0:d.deviceId;let e=ci(this,Sr,"f").get(u);if(e&&!t)return JSON.parse(JSON.stringify(e));e=[],ci(this,Sr,"f").set(u,e),di(this,ur,!0);try{for(let t of this.detectedResolutions){await ci(this,er,"f").applyConstraints({width:{ideal:t.width},height:{ideal:t.height}}),ci(this,Qn,"m",Rr).call(this);const i=ci(this,er,"f").getSettings(),n={width:i.width,height:i.height};f(u,n)||e.push({width:n.width,height:n.height})}}catch(t){throw ci(this,Qn,"m",Lr).call(this),di(this,ur,!1),t}try{await ci(this,Qn,"m",Dr).call(this)}catch(t){if("AbortError"===t.name)return e;throw t}finally{di(this,ur,!1)}return e}{const e=async(t,e,i)=>{const n={video:{deviceId:{exact:t},width:{ideal:e},height:{ideal:i}}};let r=null;try{r=await navigator.mediaDevices.getUserMedia(n)}catch(t){return null}if(!r)return null;const s=r.getVideoTracks();let a=null;try{const t=s[0].getSettings();a={width:t.width,height:t.height}}catch(t){const e=document.createElement("video");e.srcObject=r,a={width:e.videoWidth,height:e.videoHeight},e.srcObject=null}return s.forEach((t=>{t.stop()})),a};let i=(null===(s=null===(r=null===(n=ci(this,rr,"f"))||void 0===n?void 0:n.video)||void 0===r?void 0:r.deviceId)||void 0===s?void 0:s.exact)||(null===(l=null===(o=null===(a=ci(this,rr,"f"))||void 0===a?void 0:a.video)||void 0===o?void 0:o.deviceId)||void 0===l?void 0:l.ideal)||(null===(c=null===(h=ci(this,rr,"f"))||void 0===h?void 0:h.video)||void 0===c?void 0:c.deviceId);if(!i)return[];let d=ci(this,Sr,"f").get(i);if(d&&!t)return JSON.parse(JSON.stringify(d));d=[],ci(this,Sr,"f").set(i,d);for(let t of this.detectedResolutions){const n=await e(i,t.width,t.height);n&&!f(i,n)&&d.push({width:n.width,height:n.height})}return d}}async setMediaStreamConstraints(t,e){if(!(t=>{return null!==t&&"[object Object]"===(e=t,Object.prototype.toString.call(e));var e})(t))throw new TypeError("Invalid 'mediaStreamConstraints'.");di(this,rr,JSON.parse(JSON.stringify(t))),di(this,ar,null),e&&ci(this,Qn,"m",Mr).call(this)}getMediaStreamConstraints(){return JSON.parse(JSON.stringify(ci(this,rr,"f")))}resetMediaStreamConstraints(){di(this,rr,this.defaultConstraints?JSON.parse(JSON.stringify(this.defaultConstraints)):null)}getCameraCapabilities(){if(!ci(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return ci(this,er,"f").getCapabilities?ci(this,er,"f").getCapabilities():{}}getCameraSettings(){if(!ci(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return ci(this,er,"f").getSettings()}async turnOnTorch(){if(!ci(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const t=this.getCameraCapabilities();if(!(null==t?void 0:t.torch))throw Error("Not supported.");await ci(this,er,"f").applyConstraints({advanced:[{torch:!0}]})}async turnOffTorch(){if(!ci(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const t=this.getCameraCapabilities();if(!(null==t?void 0:t.torch))throw Error("Not supported.");await ci(this,er,"f").applyConstraints({advanced:[{torch:!1}]})}async setColorTemperature(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!ci(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.colorTemperature;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Xr(t,n.min,n.step,n.max)),await ci(this,er,"f").applyConstraints({advanced:[{colorTemperature:t,whiteBalanceMode:"manual"}]}),t}getColorTemperature(){return this.getCameraSettings().colorTemperature||0}async setExposureCompensation(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!ci(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.exposureCompensation;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Xr(t,n.min,n.step,n.max)),await ci(this,er,"f").applyConstraints({advanced:[{exposureCompensation:t}]}),t}getExposureCompensation(){return this.getCameraSettings().exposureCompensation||0}async setFrameRate(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!ci(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");let n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.frameRate;if(!n)throw Error("Not supported.");e&&(tn.max&&(t=n.max));const r=this.getResolution();return await ci(this,er,"f").applyConstraints({width:{ideal:Math.max(r.width,r.height)},frameRate:t}),t}getFrameRate(){return this.getCameraSettings().frameRate}async setFocus(t,e){if("object"!=typeof t||Array.isArray(t)||null==t)throw new TypeError("Invalid 'settings'.");if(!ci(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const i=this.getCameraCapabilities(),n=null==i?void 0:i.focusMode,r=null==i?void 0:i.focusDistance;if(!n)throw Error("Not supported.");if("string"!=typeof t.mode)throw TypeError("Invalid 'mode'.");const s=t.mode.toLowerCase();if(!n.includes(s))throw Error("Unsupported focus mode.");if("manual"===s){if(!r)throw Error("Manual focus unsupported.");if(t.hasOwnProperty("distance")){let i=t.distance;e&&(ir.max&&(i=r.max),i=Xr(i,r.min,r.step,r.max)),this._focusParameters.focusArea=null,await ci(this,er,"f").applyConstraints({advanced:[{focusMode:s,focusDistance:i}]})}else{if(!t.area)throw new Error("'distance' or 'area' should be specified in 'manual' mode.");{const e=t.area.centerPoint;let i=t.area.width,n=t.area.height;if(!i||!n){const t=this.getResolution();i||(i=2*Math.round(Math.min(t.width,t.height)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px"),n||(n=2*Math.round(Math.min(t.width,t.height)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px")}this._focusParameters.focusArea={centerPoint:{x:e.x,y:e.y},width:i,height:n},await ci(this,Qn,"m",kr).call(this,e,i,n)}}}else this._focusParameters.focusArea=null,await ci(this,er,"f").applyConstraints({advanced:[{focusMode:s}]})}getFocus(){const t=this.getCameraSettings(),e=t.focusMode;return e?"manual"===e?this._focusParameters.focusArea?{mode:"manual",area:JSON.parse(JSON.stringify(this._focusParameters.focusArea))}:{mode:"manual",distance:t.focusDistance}:{mode:e}:null}enableTapToFocus(){di(this,fr,!0)}disableTapToFocus(){di(this,fr,!1)}isTapToFocusEnabled(){return ci(this,fr,"f")}async setZoom(t){if("object"!=typeof t||Array.isArray(t)||null==t)throw new TypeError("Invalid 'settings'.");if("number"!=typeof t.factor)throw new TypeError("Illegal type of 'factor'.");if(t.factor<1)throw new RangeError("Invalid 'factor'.");if("opened"===this.state){t.centerPoint?ci(this,Qn,"m",Nr).call(this,t.centerPoint):this.resetScaleCenter();try{if(ci(this,Qn,"m",Br).call(this,ci(this,yr,"f"))){const e=await this.setHardwareScale(t.factor,!0);let i=this.getHardwareScale();1==i&&1!=e&&(i=e),t.factor>i?this.setSoftwareScale(t.factor/i):this.setSoftwareScale(1)}else await this.setHardwareScale(1),this.setSoftwareScale(t.factor)}catch(e){const i=e.message||e;if("Not supported."!==i&&"Camera is not open."!==i)throw e;this.setSoftwareScale(t.factor)}}else this._zoomPreSetting=t}getZoom(){if("opened"!==this.state)throw new Error("Video is not playing.");let t=1;try{t=this.getHardwareScale()}catch(t){if("Camera is not open."!==(t.message||t))throw t}return{factor:t*ci(this,vr,"f")}}async resetZoom(){await this.setZoom({factor:1})}async setHardwareScale(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(t<1)throw new RangeError("Invalid 'value'.");if(!ci(this,er,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.zoom;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Xr(t,n.min,n.step,n.max)),await ci(this,er,"f").applyConstraints({advanced:[{zoom:t}]}),t}getHardwareScale(){return this.getCameraSettings().zoom||1}setSoftwareScale(t,e){if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(t<1)throw new RangeError("Invalid 'value'.");if("opened"!==this.state)throw new Error("Video is not playing.");e&&ci(this,Qn,"m",Nr).call(this,e),di(this,vr,t),this.updateVideoElWhenSoftwareScaled()}getSoftwareScale(){return ci(this,vr,"f")}resetScaleCenter(){if("opened"!==this.state)throw new Error("Video is not playing.");const t=this.getResolution();di(this,yr,{x:t.width/2,y:t.height/2})}resetSoftwareScale(){this.setSoftwareScale(1),this.resetScaleCenter()}getFrameData(t){if(this.disposed)throw Error("The 'Camera' instance has been disposed.");if(!this.isVideoLoaded())return null;if(ci(this,ur,"f"))return null;const e=Date.now();qr._onLog&&qr._onLog("getFrameData() START: "+e);const i=ci(this,tr,"f").videoWidth,n=ci(this,tr,"f").videoHeight;let r={sx:0,sy:0,sWidth:i,sHeight:n,dWidth:i,dHeight:n};(null==t?void 0:t.position)&&(r=JSON.parse(JSON.stringify(t.position)));let s=Si.RGBA;(null==t?void 0:t.pixelFormat)&&(s=t.pixelFormat);let a=ci(this,vr,"f");(null==t?void 0:t.scale)&&(a=t.scale);let o=ci(this,yr,"f");if(null==t?void 0:t.scaleCenter){if("string"!=typeof t.scaleCenter.x||"string"!=typeof t.scaleCenter.y)throw new Error("Invalid scale center.");let e=0,r=0;if(t.scaleCenter.x.endsWith("px"))e=parseFloat(t.scaleCenter.x);else{if(!t.scaleCenter.x.endsWith("%"))throw new Error("Invalid scale center.");e=parseFloat(t.scaleCenter.x)/100*i}if(t.scaleCenter.y.endsWith("px"))r=parseFloat(t.scaleCenter.y);else{if(!t.scaleCenter.y.endsWith("%"))throw new Error("Invalid scale center.");r=parseFloat(t.scaleCenter.y)/100*n}if(isNaN(e)||isNaN(r))throw new Error("Invalid scale center.");o.x=Math.round(e),o.y=Math.round(r)}let l=null;if((null==t?void 0:t.bufferContainer)&&(l=t.bufferContainer),0==i||0==n)return null;1!==a&&(r.sWidth=Math.round(r.sWidth/a),r.sHeight=Math.round(r.sHeight/a),r.sx=Math.round((1-1/a)*o.x+r.sx/a),r.sy=Math.round((1-1/a)*o.y+r.sy/a));const h=this.imageDataGetter.getImageData(ci(this,tr,"f"),r,{pixelFormat:s,bufferContainer:l,isEnableMirroring:null==t?void 0:t.isEnableMirroring});if(!h)return null;const c=Date.now();return qr._onLog&&qr._onLog("getFrameData() END: "+c),{data:h.data,width:h.width,height:h.height,pixelFormat:h.pixelFormat,timeSpent:c-e,timeStamp:c,toCanvas:ci(this,wr,"f")}}on(t,e){if(!ci(this,Er,"f").includes(t.toLowerCase()))throw new Error(`Event '${t}' does not exist.`);ci(this,Cr,"f").on(t,e)}off(t,e){ci(this,Cr,"f").off(t,e)}async dispose(){this.tapFocusEventBoundEl=null,await this.close(),this.releaseVideoEl(),ci(this,Cr,"f").dispose(),this.imageDataGetter.dispose(),document.removeEventListener("visibilitychange",ci(this,br,"f")),di(this,Ir,!0)}}var Zr,Kr,Jr,$r,Qr,ts,es,is,ns,rs,ss,as,os,ls,hs,cs,ds,us,fs,gs,ms,ps,_s,vs,ys,ws,Cs,Es,Ss,Ts,bs,Is,xs,Rs,Os,As;tr=new WeakMap,er=new WeakMap,ir=new WeakMap,nr=new WeakMap,rr=new WeakMap,sr=new WeakMap,ar=new WeakMap,or=new WeakMap,lr=new WeakMap,hr=new WeakMap,cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,fr=new WeakMap,gr=new WeakMap,mr=new WeakMap,pr=new WeakMap,_r=new WeakMap,vr=new WeakMap,yr=new WeakMap,wr=new WeakMap,Cr=new WeakMap,Er=new WeakMap,Sr=new WeakMap,Tr=new WeakMap,br=new WeakMap,Ir=new WeakMap,Qn=new WeakSet,xr=async function(){const t=this.getMediaStreamConstraints();if("boolean"==typeof t.video&&(t.video={}),t.video.deviceId);else if(ci(this,ar,"f"))delete t.video.facingMode,t.video.deviceId={exact:ci(this,ar,"f")};else if(this.ifSaveLastUsedCamera&&qr.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")){delete t.video.facingMode,t.video.deviceId={ideal:window.localStorage.getItem("dce_last_camera_id")};const e=JSON.parse(window.localStorage.getItem("dce_last_apply_width")),i=JSON.parse(window.localStorage.getItem("dce_last_apply_height"));e&&i&&(t.video.width=e,t.video.height=i)}else if(this.ifSkipCameraInspection);else{const e=async t=>{let e=null;return"environment"===t&&["Android","HarmonyOS","iPhone","iPad"].includes(li.OS)?(await this._getCameras(!1),ci(this,Qn,"m",Rr).call(this),e=qr.findBestCamera(this._arrCameras,"environment",{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault})):t||["Android","HarmonyOS","iPhone","iPad"].includes(li.OS)||(await this._getCameras(!1),ci(this,Qn,"m",Rr).call(this),e=qr.findBestCamera(this._arrCameras,null,{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault})),e};let i=t.video.facingMode;i instanceof Array&&i.length&&(i=i[0]),"object"==typeof i&&(i=i.exact||i.ideal);const n=await e(i);n&&(delete t.video.facingMode,t.video.deviceId={exact:n})}return t},Rr=function(){if(ci(this,hr,"f")){const t=new Error("The operation was interrupted.");throw t.name="AbortError",t}},Or=async function(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let n;try{qr._onLog&&qr._onLog("======try getUserMedia========");let e=[0,500,1e3,2e3],i=null;const r=async t=>{for(let r of e){r&&(await new Promise((t=>setTimeout(t,r))),ci(this,Qn,"m",Rr).call(this));try{qr._onLog&&qr._onLog("ask "+JSON.stringify(t)),n=await navigator.mediaDevices.getUserMedia(t),ci(this,Qn,"m",Rr).call(this);break}catch(t){if("NotFoundError"===t.name||"NotAllowedError"===t.name||"AbortError"===t.name||"OverconstrainedError"===t.name)throw t;i=t,qr._onLog&&qr._onLog(t.message||t)}}};if(await r(t),!n&&"object"==typeof t.video&&(t.video.deviceId&&(delete t.video.deviceId,await r(t)),!n&&t.video.facingMode&&(delete t.video.facingMode,await r(t)),n||!t.video.width&&!t.video.height||(delete t.video.width,delete t.video.height,await r(t)),!n)){const t=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind));for(let e of t){const t={video:{deviceId:{ideal:e.deviceId},facingMode:{ideal:"environment"},width:{ideal:1920},height:{ideal:1080}}};if(await r(t),n)break}}if(!n)throw i;return n}catch(t){throw null==n||n.getTracks().forEach((t=>{t.stop()})),"NotFoundError"===t.name&&(DOMException?t=new DOMException("No camera available, please use a device with an accessible camera.",t.name):(t=new Error("No camera available, please use a device with an accessible camera.")).name="NotFoundError"),t}},Ar=function(){this._mediaStream&&(this._mediaStream.getTracks().forEach((t=>{t.stop()})),this._mediaStream=null),di(this,er,null)},Dr=async function(){di(this,hr,!1);const t=di(this,lr,Symbol());if(ci(this,cr,"f")&&"pending"===ci(this,dr,"f")){try{await ci(this,cr,"f")}catch(t){}ci(this,Qn,"m",Rr).call(this)}if(t!==ci(this,lr,"f"))return;const e=di(this,cr,(async()=>{di(this,dr,"pending");try{if(this.videoSrc){if(!ci(this,tr,"f"))throw new Error("'videoEl' should be set.");await qr.playVideo(ci(this,tr,"f"),this.videoSrc,this.cameraOpenTimeout),ci(this,Qn,"m",Rr).call(this)}else{let t=await ci(this,Qn,"m",xr).call(this);ci(this,Qn,"m",Ar).call(this);let e=await ci(this,Qn,"m",Or).call(this,t);await this._getCameras(!1),ci(this,Qn,"m",Rr).call(this);const i=()=>{const t=e.getVideoTracks();let i,n;if(t.length&&(i=t[0]),i){const t=i.getSettings();if(t)for(let e of this._arrCameras)if(t.deviceId===e.deviceId){e._checked=!0,e.label=i.label,n=e;break}}return n},n=ci(this,rr,"f");if("object"==typeof n.video){let r=n.video.facingMode;if(r instanceof Array&&r.length&&(r=r[0]),"object"==typeof r&&(r=r.exact||r.ideal),!(ci(this,ar,"f")||this.ifSaveLastUsedCamera&&qr.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")||this.ifSkipCameraInspection||n.video.deviceId)){const n=i(),s=qr.findBestCamera(this._arrCameras,r,{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault});s&&s!=(null==n?void 0:n.deviceId)&&(e.getTracks().forEach((t=>{t.stop()})),t.video.deviceId={exact:s},e=await ci(this,Qn,"m",Or).call(this,t),ci(this,Qn,"m",Rr).call(this))}}const r=i();(null==r?void 0:r.deviceId)&&(di(this,ar,r&&r.deviceId),this.ifSaveLastUsedCamera&&qr.isStorageAvailable&&(window.localStorage.setItem("dce_last_camera_id",ci(this,ar,"f")),"object"==typeof t.video&&t.video.width&&t.video.height&&(window.localStorage.setItem("dce_last_apply_width",JSON.stringify(t.video.width)),window.localStorage.setItem("dce_last_apply_height",JSON.stringify(t.video.height))))),ci(this,tr,"f")&&(await qr.playVideo(ci(this,tr,"f"),e,this.cameraOpenTimeout),ci(this,Qn,"m",Rr).call(this)),this._mediaStream=e;const s=e.getVideoTracks();(null==s?void 0:s.length)&&di(this,er,s[0]),di(this,sr,r)}}catch(t){throw ci(this,Qn,"m",Lr).call(this),di(this,dr,null),t}di(this,dr,"fulfilled")})());return e},Mr=async function(){var t;if("closed"===this.state||this.videoSrc)return;const e=null===(t=ci(this,sr,"f"))||void 0===t?void 0:t.deviceId,i=this.getResolution();await ci(this,Qn,"m",Dr).call(this);const n=this.getResolution();e&&e!==ci(this,sr,"f").deviceId&&ci(this,Cr,"f").fire("camera:changed",[ci(this,sr,"f").deviceId,e],{target:this,async:!1}),i.width==n.width&&i.height==n.height||ci(this,Cr,"f").fire("resolution:changed",[{width:n.width,height:n.height},{width:i.width,height:i.height}],{target:this,async:!1}),ci(this,Cr,"f").fire("played",null,{target:this,async:!1})},Lr=function(){ci(this,Qn,"m",Ar).call(this),di(this,sr,null),ci(this,tr,"f")&&(ci(this,tr,"f").srcObject=null,this.videoSrc&&(ci(this,tr,"f").pause(),ci(this,tr,"f").currentTime=0)),di(this,hr,!0);try{this.resetSoftwareScale()}catch(t){}},Fr=async function t(e,i){const n=t=>{if(!ci(this,er,"f")||!this.isVideoPlaying||t.focusTaskId!=this._focusParameters.curFocusTaskId){ci(this,er,"f")&&this.isVideoPlaying||(this._focusParameters.isDoingFocus=0);const e=new Error(`Focus task ${t.focusTaskId} canceled.`);throw e.name="DeprecatedTaskError",e}1===this._focusParameters.isDoingFocus&&Date.now()-t.timeStart>this._focusParameters.focusCancelableTime&&(this._focusParameters.isDoingFocus=-1)};let r;i=Xr(i,this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),await ci(this,er,"f").applyConstraints({advanced:[{focusMode:"manual",focusDistance:i}]}),n(e),r=null==this._focusParameters.oldDistance?this._focusParameters.kTimeout*Math.max(Math.abs(1/this._focusParameters.fds.min-1/i),Math.abs(1/this._focusParameters.fds.max-1/i))+this._focusParameters.minTimeout:this._focusParameters.kTimeout*Math.abs(1/this._focusParameters.oldDistance-1/i)+this._focusParameters.minTimeout,this._focusParameters.oldDistance=i,await new Promise((t=>{setTimeout(t,r)})),n(e);let s=e.focusL-e.focusW/2,a=e.focusT-e.focusH/2,o=e.focusW,l=e.focusH;const h=this.getResolution();s=Math.round(s),a=Math.round(a),o=Math.round(o),l=Math.round(l),o>h.width&&(o=h.width),l>h.height&&(l=h.height),s<0?s=0:s+o>h.width&&(s=h.width-o),a<0?a=0:a+l>h.height&&(a=h.height-l);const c=4*h.width*h.height*this._focusParameters.defaultTempBufferContainerLenRatio,d=4*o*l;let u=this._focusParameters.tempBufferContainer;if(u){const t=u.length;c>t&&c>=d?u=new Uint8Array(c):d>t&&d>=c&&(u=new Uint8Array(d))}else u=this._focusParameters.tempBufferContainer=new Uint8Array(Math.max(c,d));if(!this.imageDataGetter.getImageData(ci(this,tr,"f"),{sx:s,sy:a,sWidth:o,sHeight:l,dWidth:o,dHeight:l},{pixelFormat:Si.RGBA,bufferContainer:u}))return ci(this,Qn,"m",t).call(this,e,i);const f=u;let g=0;for(let t=0,e=d-8;to&&od)return await ci(this,Qn,"m",t).call(this,e,a,o,r,s,c,d)}else{let l=await ci(this,Qn,"m",Fr).call(this,e,c);if(o>l)return await ci(this,Qn,"m",t).call(this,e,a,o,r,s,c,l);if(o==l)return await ci(this,Qn,"m",t).call(this,e,a,o,c,l);let d=await ci(this,Qn,"m",Fr).call(this,e,h);if(d>o&&oa.width||l<0||l>a.height)throw new Error("Invalid 'centerPoint'.");let h=0;if(e.endsWith("px"))h=parseFloat(e);else{if(!e.endsWith("%"))throw new Error("Invalid 'width'.");h=parseFloat(e)/100*a.width}if(isNaN(h)||h<0)throw new Error("Invalid 'width'.");let c=0;if(i.endsWith("px"))c=parseFloat(i);else{if(!i.endsWith("%"))throw new Error("Invalid 'height'.");c=parseFloat(i)/100*a.height}if(isNaN(c)||c<0)throw new Error("Invalid 'height'.");if(1!==ci(this,vr,"f")){const t=ci(this,vr,"f"),e=ci(this,yr,"f");h/=t,c/=t,o=(1-1/t)*e.x+o/t,l=(1-1/t)*e.y+l/t}if(!this._focusSupported)throw new Error("Manual focus unsupported.");if(!this._focusParameters.fds&&(this._focusParameters.fds=null===(s=this.getCameraCapabilities())||void 0===s?void 0:s.focusDistance,!this._focusParameters.fds))throw this._focusSupported=!1,new Error("Manual focus unsupported.");null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),this._focusParameters.isDoingFocus=1;const d={focusL:o,focusT:l,focusW:h,focusH:c,focusTaskId:++this._focusParameters.curFocusTaskId,timeStart:Date.now()},u=async(t,e,i)=>{try{(null==e||ethis._focusParameters.fds.max)&&(i=this._focusParameters.fds.max),this._focusParameters.oldDistance=null;let n=Xr(Math.sqrt(i*(e||this._focusParameters.fds.step)),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),r=Xr(Math.sqrt((e||this._focusParameters.fds.step)*n),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),s=Xr(Math.sqrt(n*i),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),a=await ci(this,Qn,"m",Fr).call(this,t,s),o=await ci(this,Qn,"m",Fr).call(this,t,r),l=await ci(this,Qn,"m",Fr).call(this,t,n);if(o>l&&la&&o>a){let e=await ci(this,Qn,"m",Fr).call(this,t,i);const r=await ci(this,Qn,"m",Pr).call(this,t,n,l,i,e,s,a);return this._focusParameters.isDoingFocus=0,r}if(o==l&&ll){const e=await ci(this,Qn,"m",Pr).call(this,t,n,l,s,a);return this._focusParameters.isDoingFocus=0,e}return u(t,e,i)}catch(t){if("DeprecatedTaskError"!==t.name)throw t}};return u(d,n,r)},Nr=function(t){if("opened"!==this.state)throw new Error("Video is not playing.");if(!t||"string"!=typeof t.x||"string"!=typeof t.y)throw new Error("Invalid 'center'.");const e=this.getResolution();let i=0,n=0;if(t.x.endsWith("px"))i=parseFloat(t.x);else{if(!t.x.endsWith("%"))throw new Error("Invalid scale center.");i=parseFloat(t.x)/100*e.width}if(t.y.endsWith("px"))n=parseFloat(t.y);else{if(!t.y.endsWith("%"))throw new Error("Invalid scale center.");n=parseFloat(t.y)/100*e.height}if(isNaN(i)||isNaN(n))throw new Error("Invalid scale center.");di(this,yr,{x:i,y:n})},Br=function(t){if("opened"!==this.state)throw new Error("Video is not playing.");const e=this.getResolution();return t&&t.x==e.width/2&&t.y==e.height/2},qr.browserInfo=li,qr.onWarning=null===($n=null===window||void 0===window?void 0:window.console)||void 0===$n?void 0:$n.warn;class Ds{constructor(t){Zr.add(this),Kr.set(this,void 0),Jr.set(this,0),$r.set(this,void 0),Qr.set(this,0),ts.set(this,!1),di(this,Kr,t)}startCharging(){ci(this,ts,"f")||(Ds._onLog&&Ds._onLog("start charging."),ci(this,Zr,"m",is).call(this),di(this,ts,!0))}stopCharging(){ci(this,$r,"f")&&clearTimeout(ci(this,$r,"f")),ci(this,ts,"f")&&(Ds._onLog&&Ds._onLog("stop charging."),di(this,Jr,Date.now()-ci(this,Qr,"f")),di(this,ts,!1))}}Kr=new WeakMap,Jr=new WeakMap,$r=new WeakMap,Qr=new WeakMap,ts=new WeakMap,Zr=new WeakSet,es=function(){Ft.cfd(1),Ds._onLog&&Ds._onLog("charge 1.")},is=function t(){0==ci(this,Jr,"f")&&ci(this,Zr,"m",es).call(this),di(this,Qr,Date.now()),ci(this,$r,"f")&&clearTimeout(ci(this,$r,"f")),di(this,$r,setTimeout((()=>{di(this,Jr,0),ci(this,Zr,"m",t).call(this)}),ci(this,Kr,"f")-ci(this,Jr,"f")))};class Ms{static beep(){if(!this.allowBeep)return;if(!this.beepSoundSource)return;let t,e=Date.now();if(!(e-ci(this,ns,"f",as)<100)){if(di(this,ns,e,0,as),ci(this,ns,"f",rs).size&&(t=ci(this,ns,"f",rs).values().next().value,this.beepSoundSource==t.src?(ci(this,ns,"f",rs).delete(t),t.play()):t=null),!t)if(ci(this,ns,"f",ss).size<16){t=new Audio(this.beepSoundSource);let e=null,i=()=>{t.removeEventListener("loadedmetadata",i),t.play(),e=setTimeout((()=>{ci(this,ns,"f",ss).delete(t)}),2e3*t.duration)};t.addEventListener("loadedmetadata",i),t.addEventListener("ended",(()=>{null!=e&&(clearTimeout(e),e=null),t.pause(),t.currentTime=0,ci(this,ns,"f",ss).delete(t),ci(this,ns,"f",rs).add(t)}))}else ci(this,ns,"f",os)||(di(this,ns,!0,0,os),console.warn("The requested audio tracks exceed 16 and will not be played."));t&&ci(this,ns,"f",ss).add(t)}}static vibrate(){if(this.allowVibrate){if(!navigator||!navigator.vibrate)throw new Error("Not supported.");navigator.vibrate(Ms.vibrateDuration)}}}ns=Ms,rs={value:new Set},ss={value:new Set},as={value:0},os={value:!1},Ms.allowBeep=!0,Ms.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",Ms.allowVibrate=!0,Ms.vibrateDuration=300;const Ls=new Map([[Si.GREY,o.IPF_GRAYSCALED],[Si.RGBA,o.IPF_ABGR_8888]]),Fs="function"==typeof BigInt?t=>BigInt(t):t=>t,Ps=(Fs("0x00"),Fs("0xFFFFFFFFFFFFFFFF"),Fs("0xFE3BFFFF"),Fs("0x003007FF")),ks=(Fs("0x0003F800"),Fs("0x1"),Fs("0x2"),Fs("0x4"),Fs("0x8"),Fs("0x10"),Fs("0x20"),Fs("0x40"),Fs("0x80"),Fs("0x100"),Fs("0x200"),Fs("0x400"),Fs("0x800"),Fs("0x1000"),Fs("0x2000"),Fs("0x4000"),Fs("0x8000"),Fs("0x10000"),Fs("0x20000"),Fs("0x00040000"),Fs("0x01000000"),Fs("0x02000000"),Fs("0x04000000")),Ns=Fs("0x08000000");Fs("0x10000000"),Fs("0x20000000"),Fs("0x40000000"),Fs("0x00080000"),Fs("0x80000000"),Fs("0x100000"),Fs("0x200000"),Fs("0x400000"),Fs("0x800000"),Fs("0x1000000000"),Fs("0x3F0000000000000"),Fs("0x100000000"),Fs("0x10000000000000"),Fs("0x20000000000000"),Fs("0x40000000000000"),Fs("0x80000000000000"),Fs("0x100000000000000"),Fs("0x200000000000000"),Fs("0x200000000"),Fs("0x400000000"),Fs("0x800000000"),Fs("0xC00000000"),Fs("0x2000000000"),Fs("0x4000000000");class Bs extends ${static set _onLog(t){di(Bs,hs,t,0,cs),qr._onLog=t,Ds._onLog=t}static get _onLog(){return ci(Bs,hs,"f",cs)}static async detectEnvironment(){return await(async()=>({wasm:ui,worker:fi,getUserMedia:gi,camera:await mi(),browser:li.browser,version:li.version,OS:li.OS}))()}static async testCameraAccess(){const t=await qr.testCameraAccess();return t.ok?{ok:!0,message:"Successfully accessed the camera."}:"InsecureContext"===t.errorName?{ok:!1,message:"Insecure context."}:"OverconstrainedError"===t.errorName||"NotFoundError"===t.errorName?{ok:!1,message:"No camera detected."}:"NotAllowedError"===t.errorName?{ok:!1,message:"No permission to access camera."}:"AbortError"===t.errorName?{ok:!1,message:"Some problem occurred which prevented the device from being used."}:"NotReadableError"===t.errorName?{ok:!1,message:"A hardware error occurred."}:"SecurityError"===t.errorName?{ok:!1,message:"User media support is disabled."}:{ok:!1,message:t.errorMessage}}static async createInstance(t){var e,i;if(t&&!(t instanceof Hr))throw new TypeError("Invalid view.");if(null===(e=Dt.license)||void 0===e?void 0:e.LicenseManager){if(!(null===(i=Dt.license)||void 0===i?void 0:i.LicenseManager.bCallInitLicense))throw new Error("License is not set.");await Ft.loadWasm(),await Dt.license.dynamsoft()}const n=new Bs(t);return Bs.onWarning&&(location&&"file:"===location.protocol?setTimeout((()=>{Bs.onWarning&&Bs.onWarning({id:1,message:"The page is opened over file:// and Dynamsoft Camera Enhancer may not work properly. Please open the page via https://."})}),0):!1!==window.isSecureContext&&navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia||setTimeout((()=>{Bs.onWarning&&Bs.onWarning({id:2,message:"Dynamsoft Camera Enhancer may not work properly in a non-secure context. Please open the page via https://."})}),0)),n}get isEnableMirroring(){return this._isEnableMirroring}get video(){return this.cameraManager.getVideoEl()}set videoSrc(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraView&&(this.cameraView._hideDefaultSelection=!0),this.cameraManager.videoSrc=t}get videoSrc(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.videoSrc}set ifSaveLastUsedCamera(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.ifSaveLastUsedCamera=t}get ifSaveLastUsedCamera(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.ifSaveLastUsedCamera}set ifSkipCameraInspection(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.ifSkipCameraInspection=t}get ifSkipCameraInspection(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.ifSkipCameraInspection}set cameraOpenTimeout(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.cameraOpenTimeout=t}get cameraOpenTimeout(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.cameraOpenTimeout}set singleFrameMode(t){if(!["disabled","image","camera"].includes(t))throw new Error("Invalid value.");if(this.isOpen())throw new Error("It is not allowed to change `singleFrameMode` when the camera is open.");di(this,gs,t)}get singleFrameMode(){return ci(this,gs,"f")}get _isFetchingStarted(){return ci(this,ws,"f")}get disposed(){return ci(this,bs,"f")}constructor(t){if(super(),ls.add(this),ds.set(this,"closed"),us.set(this,void 0),fs.set(this,void 0),this._isEnableMirroring=!1,this.isTorchOn=void 0,gs.set(this,void 0),this._onCameraSelChange=async()=>{this.isOpen()&&this.cameraView&&!this.cameraView.disposed&&await this.selectCamera(this.cameraView._selCam.value)},this._onResolutionSelChange=async()=>{if(!this.isOpen())return;if(!this.cameraView||this.cameraView.disposed)return;let t,e;if(this.cameraView._selRsl&&-1!=this.cameraView._selRsl.selectedIndex){let i=this.cameraView._selRsl.options[this.cameraView._selRsl.selectedIndex];t=parseInt(i.getAttribute("data-width")),e=parseInt(i.getAttribute("data-height"))}await this.setResolution({width:t,height:e})},this._onCloseBtnClick=async()=>{this.isOpen()&&this.cameraView&&!this.cameraView.disposed&&this.close()},ms.set(this,((t,e,i,n)=>{const r=Date.now(),s={sx:n.x,sy:n.y,sWidth:n.width,sHeight:n.height,dWidth:n.width,dHeight:n.height},a=Math.max(s.dWidth,s.dHeight);if(this.canvasSizeLimit&&a>this.canvasSizeLimit){const t=this.canvasSizeLimit/a;s.dWidth>s.dHeight?(s.dWidth=this.canvasSizeLimit,s.dHeight=Math.round(s.dHeight*t)):(s.dWidth=Math.round(s.dWidth*t),s.dHeight=this.canvasSizeLimit)}const l=this.cameraManager.imageDataGetter.getImageData(t,s,{pixelFormat:this.getPixelFormat()===o.IPF_GRAYSCALED?Si.GREY:Si.RGBA});let h=null;if(l){const t=Date.now();let a;a=l.pixelFormat===Si.GREY?l.width:4*l.width;let o=!0;0===s.sx&&0===s.sy&&s.sWidth===e&&s.sHeight===i&&(o=!1),h={bytes:l.data,width:l.width,height:l.height,stride:a,format:Ls.get(l.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:lt.ITT_FILE_IMAGE,isCropped:o,cropRegion:{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height,isMeasuredInPercentage:!1},originalWidth:e,originalHeight:i,currentWidth:l.width,currentHeight:l.height,timeSpent:t-r,timeStamp:t},toCanvas:ci(this,ps,"f"),isDCEFrame:!0}}return h})),this._onSingleFrameAcquired=t=>{let e;e=this.cameraView?this.cameraView.getConvertedRegion():nn.convert(ci(this,vs,"f"),t.width,t.height,this.cameraView),e||(e={x:0,y:0,width:t.width,height:t.height});const i=ci(this,ms,"f").call(this,t,t.width,t.height,e);ci(this,us,"f").fire("singleFrameAcquired",[i],{async:!1,copy:!1})},ps.set(this,(function(){if(!(this.bytes instanceof Uint8Array||this.bytes instanceof Uint8ClampedArray))throw new TypeError("Invalid bytes.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const t=document.createElement("canvas");let e;if(t.width=this.width,t.height=this.height,this.format===o.IPF_GRAYSCALED){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t{if(!this.video)return;const t=this.cameraManager.getSoftwareScale();if(t<1)throw new RangeError("Invalid scale value.");this.cameraView&&!this.cameraView.disposed?(this.video.style.transform=1===t?"":`scale(${t})`,this.cameraView._updateVideoContainer()):this.video.style.transform=1===t?"":`scale(${t})`},["iPhone","iPad","Android","HarmonyOS"].includes(li.OS)?this.cameraManager.setResolution(1280,720):this.cameraManager.setResolution(1920,1080),navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?this.singleFrameMode="disabled":this.singleFrameMode="image",t&&(this.setCameraView(t),t.cameraEnhancer=this),this._on("before:camera:change",(()=>{ci(this,Ts,"f").stopCharging();const t=this.cameraView;t&&!t.disposed&&(t._startLoading(),t.clearAllInnerDrawingItems())})),this._on("camera:changed",(()=>{this.clearBuffer()})),this._on("before:resolution:change",(()=>{const t=this.cameraView;t&&!t.disposed&&(t._startLoading(),t.clearAllInnerDrawingItems())})),this._on("resolution:changed",(()=>{this.clearBuffer(),t.eventHandler.fire("content:updated",null,{async:!1})})),this._on("paused",(()=>{ci(this,Ts,"f").stopCharging();const t=this.cameraView;t&&t.disposed})),this._on("resumed",(()=>{const t=this.cameraView;t&&t.disposed})),this._on("tapfocus",(()=>{ci(this,Es,"f").tapToFocus&&ci(this,Ts,"f").startCharging()})),this._intermediateResultReceiver={},this._intermediateResultReceiver.onTaskResultsReceived=async(t,e)=>{var i,n,r,s;const a=t.intermediateResultUnits;if(ci(this,ls,"m",Is).call(this)||!this.isOpen()||this.isPaused()||a[0]&&!a[0].originalImageTag)return;Bs._onLog&&(Bs._onLog("intermediateResultUnits:"),Bs._onLog(a));let o=!1,l=!1;for(let t of a){if(t.unitType===ut.IRUT_DECODED_BARCODES&&t.decodedBarcodes.length){o=!0;break}t.unitType===ut.IRUT_LOCALIZED_BARCODES&&t.localizedBarcodes.length&&(l=!0)}if(Bs._onLog&&(Bs._onLog("hasLocalizedBarcodes:"),Bs._onLog(l)),ci(this,Es,"f").autoZoom||ci(this,Es,"f").enhancedFocus)if(o)ci(this,Ss,"f").autoZoomInFrameArray.length=0,ci(this,Ss,"f").autoZoomOutFrameCount=0,ci(this,Ss,"f").frameArrayInIdealZoom.length=0,ci(this,Ss,"f").autoFocusFrameArray.length=0;else{const e=async t=>{await this.setZoom(t),ci(this,Es,"f").autoZoom&&ci(this,Ts,"f").startCharging()},o=async t=>{await this.setFocus(t),ci(this,Es,"f").enhancedFocus&&ci(this,Ts,"f").startCharging()};if(l){const l=a[0].originalImageTag,h=(null===(i=l.cropRegion)||void 0===i?void 0:i.left)||0,c=(null===(n=l.cropRegion)||void 0===n?void 0:n.top)||0,d=(null===(r=l.cropRegion)||void 0===r?void 0:r.right)?l.cropRegion.right-h:l.originalWidth,u=(null===(s=l.cropRegion)||void 0===s?void 0:s.bottom)?l.cropRegion.bottom-c:l.originalHeight,f=l.currentWidth,g=l.currentHeight;let m;{let t,e,i,n,r;{const t=this.video.videoWidth*(1-ci(this,Ss,"f").autoZoomDetectionArea)/2,e=this.video.videoWidth*(1+ci(this,Ss,"f").autoZoomDetectionArea)/2,i=e,n=t,s=this.video.videoHeight*(1-ci(this,Ss,"f").autoZoomDetectionArea)/2,a=s,o=this.video.videoHeight*(1+ci(this,Ss,"f").autoZoomDetectionArea)/2;r=[{x:t,y:s},{x:e,y:a},{x:i,y:o},{x:n,y:o}]}Bs._onLog&&(Bs._onLog("detectionArea:"),Bs._onLog(r));const s=[];{const t=(t,e)=>{const i=(t,e)=>{if(!t&&!e)throw new Error("Invalid arguments.");return function(t,e,i){let n=!1;const r=t.length;if(r<=2)return!1;for(let s=0;s0!=ln(o.y-i)>0&&ln(e-(i-a.y)*(a.x-o.x)/(a.y-o.y)-a.x)<0&&(n=!n)}return n}(e,t.x,t.y)},n=(t,e)=>!!(hn([t[0],t[1]],[t[2],t[3]],[e[0].x,e[0].y],[e[1].x,e[1].y])||hn([t[0],t[1]],[t[2],t[3]],[e[1].x,e[1].y],[e[2].x,e[2].y])||hn([t[0],t[1]],[t[2],t[3]],[e[2].x,e[2].y],[e[3].x,e[3].y])||hn([t[0],t[1]],[t[2],t[3]],[e[3].x,e[3].y],[e[0].x,e[0].y]));return!!(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))||!!(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))||!!(n([e[0].x,e[0].y,e[1].x,e[1].y],t)||n([e[1].x,e[1].y,e[2].x,e[2].y],t)||n([e[2].x,e[2].y,e[3].x,e[3].y],t)||n([e[3].x,e[3].y,e[0].x,e[0].y],t))};for(let e of a)if(e.unitType===ut.IRUT_LOCALIZED_BARCODES)for(let i of e.localizedBarcodes){if(!i)continue;const e=i.location.points;e.forEach((t=>{Hr._transformCoordinates(t,h,c,d,u,f,g)})),t(r,e)&&s.push(i)}if(Bs._debug&&this.cameraView){const t=this.__layer||(this.__layer=this.cameraView._createDrawingLayer(99));t.clearDrawingItems();const e=this.__styleId2||(this.__styleId2=jr.createDrawingStyle({strokeStyle:"red"}));for(let i of a)if(i.unitType===ut.IRUT_LOCALIZED_BARCODES)for(let n of i.localizedBarcodes){if(!n)continue;const i=n.location.points,r=new Yi({points:i},e);t.addDrawingItems([r])}}}if(Bs._onLog&&(Bs._onLog("intersectedResults:"),Bs._onLog(s)),!s.length)return;let o;if(s.length){let t=s.filter((t=>t.possibleFormats==ks||t.possibleFormats==Ns));if(t.length||(t=s.filter((t=>t.possibleFormats==Ps)),t.length||(t=s)),t.length){const e=t=>{const e=t.location.points,i=(e[0].x+e[1].x+e[2].x+e[3].x)/4,n=(e[0].y+e[1].y+e[2].y+e[3].y)/4;return(i-f/2)*(i-f/2)+(n-g/2)*(n-g/2)};o=t[0];let i=e(o);if(1!=t.length)for(let n=1;n1.1*o.confidence||t[n].confidence>.9*o.confidence&&ri&&s>i&&a>i&&l>i&&m.result.moduleSize{})),ci(this,Ss,"f").autoZoomInFrameArray.filter((t=>!0===t)).length>=ci(this,Ss,"f").autoZoomInFrameLimit[1]){ci(this,Ss,"f").autoZoomInFrameArray.length=0;const i=[(.5-n)/(.5-r),(.5-n)/(.5-s),(.5-n)/(.5-a),(.5-n)/(.5-l)].filter((t=>t>0)),o=Math.min(...i,ci(this,Ss,"f").autoZoomInIdealModuleSize/m.result.moduleSize),h=this.getZoomSettings().factor;let c=Math.max(Math.pow(h*o,1/ci(this,Ss,"f").autoZoomInMaxTimes),ci(this,Ss,"f").autoZoomInMinStep);c=Math.min(c,o);let d=h*c;d=Math.max(ci(this,Ss,"f").minValue,d),d=Math.min(ci(this,Ss,"f").maxValue,d);try{await e({factor:d})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}else if(ci(this,Ss,"f").autoZoomInFrameArray.length=0,ci(this,Ss,"f").frameArrayInIdealZoom.push(!0),ci(this,Ss,"f").frameArrayInIdealZoom.splice(0,ci(this,Ss,"f").frameArrayInIdealZoom.length-ci(this,Ss,"f").frameLimitInIdealZoom[0]),ci(this,Ss,"f").frameArrayInIdealZoom.filter((t=>!0===t)).length>=ci(this,Ss,"f").frameLimitInIdealZoom[1]&&(ci(this,Ss,"f").frameArrayInIdealZoom.length=0,ci(this,Es,"f").enhancedFocus)){const e=m.points;try{await o({mode:"manual",area:{centerPoint:{x:(e[0].x+e[2].x)/2+"px",y:(e[0].y+e[2].y)/2+"px"},width:e[2].x-e[0].x+"px",height:e[2].y-e[0].y+"px"}})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}if(!ci(this,Es,"f").autoZoom&&ci(this,Es,"f").enhancedFocus&&(ci(this,Ss,"f").autoFocusFrameArray.push(!0),ci(this,Ss,"f").autoFocusFrameArray.splice(0,ci(this,Ss,"f").autoFocusFrameArray.length-ci(this,Ss,"f").autoFocusFrameLimit[0]),ci(this,Ss,"f").autoFocusFrameArray.filter((t=>!0===t)).length>=ci(this,Ss,"f").autoFocusFrameLimit[1])){ci(this,Ss,"f").autoFocusFrameArray.length=0;try{const t=m.points;await o({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(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}else{if(ci(this,Es,"f").autoZoom){if(ci(this,Ss,"f").autoZoomInFrameArray.push(!1),ci(this,Ss,"f").autoZoomInFrameArray.splice(0,ci(this,Ss,"f").autoZoomInFrameArray.length-ci(this,Ss,"f").autoZoomInFrameLimit[0]),ci(this,Ss,"f").autoZoomOutFrameCount++,ci(this,Ss,"f").frameArrayInIdealZoom.push(!1),ci(this,Ss,"f").frameArrayInIdealZoom.splice(0,ci(this,Ss,"f").frameArrayInIdealZoom.length-ci(this,Ss,"f").frameLimitInIdealZoom[0]),ci(this,Ss,"f").autoZoomOutFrameCount>=ci(this,Ss,"f").autoZoomOutFrameLimit){ci(this,Ss,"f").autoZoomOutFrameCount=0;const i=this.getZoomSettings().factor;let n=i-Math.max((i-1)*ci(this,Ss,"f").autoZoomOutStepRate,ci(this,Ss,"f").autoZoomOutMinStep);n=Math.max(ci(this,Ss,"f").minValue,n),n=Math.min(ci(this,Ss,"f").maxValue,n);try{await e({factor:n})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}ci(this,Es,"f").enhancedFocus&&o({mode:"continuous"}).catch((()=>{}))}!ci(this,Es,"f").autoZoom&&ci(this,Es,"f").enhancedFocus&&(ci(this,Ss,"f").autoFocusFrameArray.length=0,o({mode:"continuous"}).catch((()=>{})))}}},di(this,Ts,new Ds(1e4))}setCameraView(t){if(!(t instanceof Hr))throw new TypeError("Invalid view.");if(t.disposed)throw new Error("The camera view has been disposed.");if(this.isOpen())throw new Error("It is not allowed to change camera view when the camera is open.");this.releaseCameraView(),t._singleFrameMode=this.singleFrameMode,t._onSingleFrameAcquired=this._onSingleFrameAcquired,this.videoSrc&&(this.cameraView._hideDefaultSelection=!0),ci(this,ls,"m",Is).call(this)||this.cameraManager.setVideoEl(t.getVideoElement()),this.cameraView=t,this.addListenerToView()}getCameraView(){return this.cameraView}releaseCameraView(){this.cameraView&&(this.removeListenerFromView(),this.cameraView.disposed||(this.cameraView._singleFrameMode="disabled",this.cameraView._onSingleFrameAcquired=null,this.cameraView._hideDefaultSelection=!1),this.cameraManager.releaseVideoEl(),this.cameraView=null)}addListenerToView(){if(!this.cameraView)return;if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");const t=this.cameraView;ci(this,ls,"m",Is).call(this)||this.videoSrc||(t._innerComponent&&(this.cameraManager.tapFocusEventBoundEl=t._innerComponent),t._selCam&&t._selCam.addEventListener("change",this._onCameraSelChange),t._selRsl&&t._selRsl.addEventListener("change",this._onResolutionSelChange)),t._btnClose&&t._btnClose.addEventListener("click",this._onCloseBtnClick)}removeListenerFromView(){if(!this.cameraView||this.cameraView.disposed)return;const t=this.cameraView;this.cameraManager.tapFocusEventBoundEl=null,t._selCam&&t._selCam.removeEventListener("change",this._onCameraSelChange),t._selRsl&&t._selRsl.removeEventListener("change",this._onResolutionSelChange),t._btnClose&&t._btnClose.removeEventListener("click",this._onCloseBtnClick)}getCameraState(){return ci(this,ls,"m",Is).call(this)?ci(this,ds,"f"):new Map([["closed","closed"],["opening","opening"],["opened","open"]]).get(this.cameraManager.state)}isOpen(){return"open"===this.getCameraState()}getVideoEl(){return this.video}async open(){var t;const e=this.cameraView;if(null==e?void 0:e.disposed)throw new Error("'cameraView' has been disposed.");e&&(e._singleFrameMode=this.singleFrameMode,ci(this,ls,"m",Is).call(this)?e._clickIptSingleFrameMode():(this.cameraManager.setVideoEl(e.getVideoElement()),e._startLoading()));let i={width:0,height:0,deviceId:""};if(ci(this,ls,"m",Is).call(this));else{try{await this.cameraManager.open(),di(this,fs,this.cameraView.getVisibleRegionOfVideo({inPixels:!0}))}catch(t){throw e&&e._stopLoading(),"NotFoundError"===t.name?new Error("No Camera Found: No camera devices were detected. Please ensure a camera is connected and recognized by your system."):"NotAllowedError"===t.name?new Error("No Camera Access: Camera access is blocked. Please check your browser settings or grant permission to use the camera."):t}const n=!this.cameraManager.videoSrc&&!!(null===(t=this.cameraManager.getCameraCapabilities())||void 0===t?void 0:t.torch);let r,s=e.getUIElement();if(s=s.shadowRoot||s,r=s.querySelector(".dce-macro-use-mobile-native-like-ui")){let t=s.elTorchAuto=s.querySelector(".dce-mn-torch-auto"),e=s.elTorchOn=s.querySelector(".dce-mn-torch-on"),i=s.elTorchOff=s.querySelector(".dce-mn-torch-off");t&&(t.style.display=null==this.isTorchOn?"":"none",n||(t.style.filter="invert(1)",t.style.cursor="not-allowed")),e&&(e.style.display=1==this.isTorchOn?"":"none"),i&&(i.style.display=0==this.isTorchOn?"":"none");let a=s.elBeepOn=s.querySelector(".dce-mn-beep-on"),o=s.elBeepOff=s.querySelector(".dce-mn-beep-off");a&&(a.style.display=Ms.allowBeep?"":"none"),o&&(o.style.display=Ms.allowBeep?"none":"");let l=s.elVibrateOn=s.querySelector(".dce-mn-vibrate-on"),h=s.elVibrateOff=s.querySelector(".dce-mn-vibrate-off");l&&(l.style.display=Ms.allowVibrate?"":"none"),h&&(h.style.display=Ms.allowVibrate?"none":""),s.elResolutionBox=s.querySelector(".dce-mn-resolution-box");let c,d=s.elZoom=s.querySelector(".dce-mn-zoom");d&&(d.style.display="none",c=s.elZoomSpan=d.querySelector("span"));let u=s.elToast=s.querySelector(".dce-mn-toast"),f=s.elCameraClose=s.querySelector(".dce-mn-camera-close"),g=s.elTakePhoto=s.querySelector(".dce-mn-take-photo"),m=s.elCameraSwitch=s.querySelector(".dce-mn-camera-switch"),p=s.elCameraAndResolutionSettings=s.querySelector(".dce-mn-camera-and-resolution-settings");p&&(p.style.display="none");const _=s.dceMnFs={},v=()=>{this.turnOnTorch()};null==t||t.addEventListener("pointerdown",v);const y=()=>{this.turnOffTorch()};null==e||e.addEventListener("pointerdown",y);const w=()=>{this.turnAutoTorch()};null==i||i.addEventListener("pointerdown",w);const C=()=>{Ms.allowBeep=!Ms.allowBeep,a&&(a.style.display=Ms.allowBeep?"":"none"),o&&(o.style.display=Ms.allowBeep?"none":"")};for(let t of[o,a])null==t||t.addEventListener("pointerdown",C);const E=()=>{Ms.allowVibrate=!Ms.allowVibrate,l&&(l.style.display=Ms.allowVibrate?"":"none"),h&&(h.style.display=Ms.allowVibrate?"none":"")};for(let t of[h,l])null==t||t.addEventListener("pointerdown",E);const S=async t=>{let e,i=t.target;if(e=i.closest(".dce-mn-camera-option"))this.selectCamera(e.getAttribute("data-davice-id"));else if(e=i.closest(".dce-mn-resolution-option")){let t,i=parseInt(e.getAttribute("data-width")),n=parseInt(e.getAttribute("data-height")),r=await this.setResolution({width:i,height:n});{let e=Math.max(r.width,r.height),i=Math.min(r.width,r.height);t=i<=1080?i+"P":e<3e3?"2K":Math.round(e/1e3)+"K"}t!=e.textContent&&I(`Fallback to ${t}`)}else i.closest(".dce-mn-camera-and-resolution-settings")||(i.closest(".dce-mn-resolution-box")?p&&(p.style.display=p.style.display?"":"none"):p&&""===p.style.display&&(p.style.display="none"))};s.addEventListener("click",S);let T=null;_.funcInfoZoomChange=(t,e=3e3)=>{d&&c&&(c.textContent=t.toFixed(1),d.style.display="",null!=T&&(clearTimeout(T),T=null),T=setTimeout((()=>{d.style.display="none",T=null}),e))};let b=null,I=_.funcShowToast=(t,e=3e3)=>{u&&(u.textContent=t,u.style.display="",null!=b&&(clearTimeout(b),b=null),b=setTimeout((()=>{u.style.display="none",b=null}),e))};const x=()=>{this.close()};null==f||f.addEventListener("click",x);const R=()=>{};null==g||g.addEventListener("pointerdown",R);const O=()=>{var t,e;let i,n=this.getVideoSettings(),r=n.video.facingMode,s=null===(e=null===(t=this.cameraManager.getCamera())||void 0===t?void 0:t.label)||void 0===e?void 0:e.toLowerCase(),a=null==s?void 0:s.indexOf("front");-1===a&&(a=null==s?void 0:s.indexOf("前"));let o=null==s?void 0:s.indexOf("back");if(-1===o&&(o=null==s?void 0:s.indexOf("后")),"number"==typeof a&&-1!==a?i=!0:"number"==typeof o&&-1!==o&&(i=!1),void 0===i&&(i="user"===((null==r?void 0:r.ideal)||(null==r?void 0:r.exact)||r)),!i){let t=this.cameraView.getUIElement();t=t.shadowRoot||t,t.elTorchAuto&&(t.elTorchAuto.style.display="none"),t.elTorchOn&&(t.elTorchOn.style.display="none"),t.elTorchOff&&(t.elTorchOff.style.display="")}n.video.facingMode={ideal:i?"environment":"user"},delete n.video.deviceId,this.updateVideoSettings(n)};null==m||m.addEventListener("pointerdown",O);let A=-1/0,D=1;const M=t=>{let e=Date.now();e-A>1e3&&(D=this.getZoomSettings().factor),D-=t.deltaY/200,D>20&&(D=20),D<1&&(D=1),this.setZoom({factor:D}),A=e};r.addEventListener("wheel",M);const L=new Map;let F=!1;const P=async t=>{var e;for(t.touches.length>=2&&"touchmove"==t.type&&t.preventDefault();t.changedTouches.length>1&&2==t.touches.length;){let i=t.touches[0],n=t.touches[1],r=L.get(i.identifier),s=L.get(n.identifier);if(!r||!s)break;let a=Math.pow(Math.pow(r.x-s.x,2)+Math.pow(r.y-s.y,2),.5),o=Math.pow(Math.pow(i.clientX-n.clientX,2)+Math.pow(i.clientY-n.clientY,2),.5),l=Date.now();if(F||l-A<100)return;l-A>1e3&&(D=this.getZoomSettings().factor),D*=o/a,D>20&&(D=20),D<1&&(D=1);let h=!1;"safari"==(null===(e=null==li?void 0:li.browser)||void 0===e?void 0:e.toLocaleLowerCase())&&(o/a>1&&D<2?(D=2,h=!0):o/a<1&&D<2&&(D=1,h=!0)),F=!0,h&&I("zooming..."),await this.setZoom({factor:D}),h&&(u.textContent=""),F=!1,A=Date.now();break}L.clear();for(let e of t.touches)L.set(e.identifier,{x:e.clientX,y:e.clientY})};s.addEventListener("touchstart",P),s.addEventListener("touchmove",P),s.addEventListener("touchend",P),s.addEventListener("touchcancel",P),_.unbind=()=>{null==t||t.removeEventListener("pointerdown",v),null==e||e.removeEventListener("pointerdown",y),null==i||i.removeEventListener("pointerdown",w);for(let t of[o,a])null==t||t.removeEventListener("pointerdown",C);for(let t of[h,l])null==t||t.removeEventListener("pointerdown",E);s.removeEventListener("click",S),null==f||f.removeEventListener("click",x),null==g||g.removeEventListener("pointerdown",R),null==m||m.removeEventListener("pointerdown",O),r.removeEventListener("wheel",M),s.removeEventListener("touchstart",P),s.removeEventListener("touchmove",P),s.removeEventListener("touchend",P),s.removeEventListener("touchcancel",P),delete s.dceMnFs,r.style.display="none"},r.style.display="",t&&null==this.isTorchOn&&setTimeout((()=>{this.turnAutoTorch(1e3)}),0)}this.isTorchOn&&this.turnOnTorch().catch((()=>{}));const a=this.getResolution();i.width=a.width,i.height=a.height,i.deviceId=this.getSelectedCamera().deviceId}return di(this,ds,"open"),e&&(e._innerComponent.style.display="",ci(this,ls,"m",Is).call(this)||(e._stopLoading(),e._renderCamerasInfo(this.getSelectedCamera(),this.cameraManager._arrCameras),e._renderResolutionInfo({width:i.width,height:i.height}),e.eventHandler.fire("content:updated",null,{async:!1}),e.eventHandler.fire("videoEl:resized",null,{async:!1}))),this.toggleMirroring(this._isEnableMirroring),ci(this,us,"f").fire("opened",null,{target:this,async:!1}),this.cameraManager._zoomPreSetting&&(await this.setZoom(this.cameraManager._zoomPreSetting),this.cameraManager._zoomPreSetting=null),i}close(){var t;const e=this.cameraView;if(null==e?void 0:e.disposed)throw new Error("'cameraView' has been disposed.");if(this.stopFetching(),this.clearBuffer(),ci(this,ls,"m",Is).call(this));else{this.cameraManager.close();let i=e.getUIElement();i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")&&(null===(t=i.dceMnFs)||void 0===t||t.unbind())}di(this,ds,"closed"),ci(this,Ts,"f").stopCharging(),e&&(e._innerComponent.style.display="none",ci(this,ls,"m",Is).call(this)&&e._innerComponent.removeElement("content"),e._stopLoading()),ci(this,us,"f").fire("closed",null,{target:this,async:!1})}pause(){if(ci(this,ls,"m",Is).call(this))throw new Error("'pause()' is invalid in 'singleFrameMode'.");this.cameraManager.pause()}isPaused(){var t;return!ci(this,ls,"m",Is).call(this)&&!0===(null===(t=this.video)||void 0===t?void 0:t.paused)}async resume(){if(ci(this,ls,"m",Is).call(this))throw new Error("'resume()' is invalid in 'singleFrameMode'.");await this.cameraManager.resume()}async selectCamera(t){var e;if(!t)throw new Error("Invalid value.");let i;i="string"==typeof t?t:t.deviceId,await this.cameraManager.setCamera(i),this.isTorchOn=!1;const n=this.getResolution(),r=this.cameraView;if(r&&!r.disposed&&(r._stopLoading(),r._renderCamerasInfo(this.getSelectedCamera(),this.cameraManager._arrCameras),r._renderResolutionInfo({width:n.width,height:n.height})),this.isOpen()){const t=!!(null===(e=this.cameraManager.getCameraCapabilities())||void 0===e?void 0:e.torch);let i=r.getUIElement();if(i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")){let e=i.elTorchAuto=i.querySelector(".dce-mn-torch-auto");e&&(t?(e.style.filter="none",e.style.cursor="pointer"):(e.style.filter="invert(1)",e.style.cursor="not-allowed"))}}return this.toggleMirroring(this._isEnableMirroring),{width:n.width,height:n.height,deviceId:this.getSelectedCamera().deviceId}}getSelectedCamera(){return this.cameraManager.getCamera()}async getAllCameras(){return this.cameraManager.getCameras()}async setResolution(t){await this.cameraManager.setResolution(t.width,t.height),this.isTorchOn&&this.turnOnTorch().catch((()=>{}));const e=this.getResolution(),i=this.cameraView;return i&&!i.disposed&&(i._stopLoading(),i._renderResolutionInfo({width:e.width,height:e.height})),this.toggleMirroring(this._isEnableMirroring),{width:e.width,height:e.height,deviceId:this.getSelectedCamera().deviceId}}getResolution(){return this.cameraManager.getResolution()}getAvailableResolutions(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getResolutions()}_on(t,e){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(t.toLowerCase())?ci(this,us,"f").on(t,e):this.cameraManager.on(t,e)}_off(t,e){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(t.toLowerCase())?ci(this,us,"f").off(t,e):this.cameraManager.off(t,e)}on(t,e){const i=t.toLowerCase(),n=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(i);if(!n)throw new Error("Invalid event.");this._on(n,e)}off(t,e){const i=t.toLowerCase(),n=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(i);if(!n)throw new Error("Invalid event.");this._off(n,e)}getVideoSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getMediaStreamConstraints()}async updateVideoSettings(t){var e;await(null===(e=this.cameraManager)||void 0===e?void 0:e.setMediaStreamConstraints(t,!0))}getCapabilities(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getCameraCapabilities()}getCameraSettings(){return this.cameraManager.getCameraSettings()}async turnOnTorch(){var t,e;if(ci(this,ls,"m",Is).call(this))throw new Error("'turnOnTorch()' is invalid in 'singleFrameMode'.");try{await(null===(t=this.cameraManager)||void 0===t?void 0:t.turnOnTorch())}catch(t){let i=this.cameraView.getUIElement();throw i=i.shadowRoot||i,null===(e=null==i?void 0:i.dceMnFs)||void 0===e||e.funcShowToast("Torch Not Supported"),t}this.isTorchOn=!0;let i=this.cameraView.getUIElement();i=i.shadowRoot||i,i.elTorchAuto&&(i.elTorchAuto.style.display="none"),i.elTorchOn&&(i.elTorchOn.style.display=""),i.elTorchOff&&(i.elTorchOff.style.display="none")}async turnOffTorch(){var t;if(ci(this,ls,"m",Is).call(this))throw new Error("'turnOffTorch()' is invalid in 'singleFrameMode'.");await(null===(t=this.cameraManager)||void 0===t?void 0:t.turnOffTorch()),this.isTorchOn=!1;let e=this.cameraView.getUIElement();e=e.shadowRoot||e,e.elTorchAuto&&(e.elTorchAuto.style.display="none"),e.elTorchOn&&(e.elTorchOn.style.display="none"),e.elTorchOff&&(e.elTorchOff.style.display="")}async turnAutoTorch(t=250){var e;const i=this.isOpen()?this.cameraManager.getCameraCapabilities():{};if(!(null==i?void 0:i.torch)){let t=this.cameraView.getUIElement();return t=t.shadowRoot||t,void(null===(e=null==t?void 0:t.dceMnFs)||void 0===e||e.funcShowToast("Torch Not Supported"))}if(null!=this._taskid4AutoTorch){if(!(t{var t,e,i;if(this.disposed||n||null!=this.isTorchOn||!this.isOpen())return clearInterval(this._taskid4AutoTorch),void(this._taskid4AutoTorch=null);if(this.isPaused())return;if(++s>10&&this._delay4AutoTorch<1e3)return clearInterval(this._taskid4AutoTorch),this._taskid4AutoTorch=null,void this.turnAutoTorch(1e3);let a;try{a=this.fetchImage()}catch(t){}if(!a||!a.width||!a.height)return;let l=0;if(o.IPF_GRAYSCALED===a.format){for(let t=0;t=this.maxDarkCount4AutoTroch){null===(t=Bs._onLog)||void 0===t||t.call(Bs,`darkCount ${r}`);try{await this.turnOnTorch(),this.isTorchOn=!0;let t=this.cameraView.getUIElement();t=t.shadowRoot||t,null===(e=null==t?void 0:t.dceMnFs)||void 0===e||e.funcShowToast("Torch Auto On")}catch(t){console.warn(t),n=!0;let e=this.cameraView.getUIElement();e=e.shadowRoot||e,null===(i=null==e?void 0:e.dceMnFs)||void 0===i||i.funcShowToast("Torch Not Supported")}}}else r=0};this._taskid4AutoTorch=setInterval(a,t),this.isTorchOn=void 0,a();let l=this.cameraView.getUIElement();l=l.shadowRoot||l,l.elTorchAuto&&(l.elTorchAuto.style.display=""),l.elTorchOn&&(l.elTorchOn.style.display="none"),l.elTorchOff&&(l.elTorchOff.style.display="none")}async setColorTemperature(t){if(ci(this,ls,"m",Is).call(this))throw new Error("'setColorTemperature()' is invalid in 'singleFrameMode'.");await this.cameraManager.setColorTemperature(t,!0)}getColorTemperature(){return this.cameraManager.getColorTemperature()}async setExposureCompensation(t){var e;if(ci(this,ls,"m",Is).call(this))throw new Error("'setExposureCompensation()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setExposureCompensation(t,!0))}getExposureCompensation(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getExposureCompensation()}async _setZoom(t){var e,i,n;if(ci(this,ls,"m",Is).call(this))throw new Error("'setZoom()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setZoom(t));{let e=null===(i=this.cameraView)||void 0===i?void 0:i.getUIElement();e=(null==e?void 0:e.shadowRoot)||e,null===(n=null==e?void 0:e.dceMnFs)||void 0===n||n.funcInfoZoomChange(t.factor)}}async setZoom(t){await this._setZoom(t)}getZoomSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getZoom()}async resetZoom(){var t;if(ci(this,ls,"m",Is).call(this))throw new Error("'resetZoom()' is invalid in 'singleFrameMode'.");await(null===(t=this.cameraManager)||void 0===t?void 0:t.resetZoom())}async setFrameRate(t){var e;if(ci(this,ls,"m",Is).call(this))throw new Error("'setFrameRate()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setFrameRate(t,!0))}getFrameRate(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getFrameRate()}async setFocus(t){var e;if(ci(this,ls,"m",Is).call(this))throw new Error("'setFocus()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setFocus(t,!0))}getFocusSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getFocus()}setAutoZoomRange(t){ci(this,Ss,"f").minValue=t.min,ci(this,Ss,"f").maxValue=t.max}getAutoZoomRange(){return{min:ci(this,Ss,"f").minValue,max:ci(this,Ss,"f").maxValue}}enableEnhancedFeatures(t){var e,i;if(!(null===(i=null===(e=Dt.license)||void 0===e?void 0:e.LicenseManager)||void 0===i?void 0:i.bPassValidation))throw new Error("License is not verified, or license is invalid.");if(0!==Ft.bSupportDce4Module)throw new Error("Please set a license containing the DCE module.");t&Ei.EF_ENHANCED_FOCUS&&(ci(this,Es,"f").enhancedFocus=!0),t&Ei.EF_AUTO_ZOOM&&(ci(this,Es,"f").autoZoom=!0),t&Ei.EF_TAP_TO_FOCUS&&(ci(this,Es,"f").tapToFocus=!0,this.cameraManager.enableTapToFocus())}disableEnhancedFeatures(t){t&Ei.EF_ENHANCED_FOCUS&&(ci(this,Es,"f").enhancedFocus=!1,this.setFocus({mode:"continuous"}).catch((()=>{}))),t&Ei.EF_AUTO_ZOOM&&(ci(this,Es,"f").autoZoom=!1,this.resetZoom().catch((()=>{}))),t&Ei.EF_TAP_TO_FOCUS&&(ci(this,Es,"f").tapToFocus=!1,this.cameraManager.disableTapToFocus()),ci(this,ls,"m",Rs).call(this)&&ci(this,ls,"m",xs).call(this)||ci(this,Ts,"f").stopCharging()}_setScanRegion(t){if(null!=t&&!C(t)&&!x(t))throw TypeError("Invalid 'region'.");di(this,vs,t?JSON.parse(JSON.stringify(t)):null),this.cameraView&&!this.cameraView.disposed&&this.cameraView.setScanRegion(t)}setScanRegion(t){this._setScanRegion(t),this.cameraView&&!this.cameraView.disposed&&(null===t?this.cameraView.setScanRegionMaskVisible(!1):this.cameraView.setScanRegionMaskVisible(!0))}getScanRegion(){return JSON.parse(JSON.stringify(ci(this,vs,"f")))}setErrorListener(t){if(!t)throw new TypeError("Invalid 'listener'");di(this,_s,t)}hasNextImageToFetch(){return!("open"!==this.getCameraState()||!this.cameraManager.isVideoLoaded()||ci(this,ls,"m",Is).call(this))}startFetching(){if(ci(this,ls,"m",Is).call(this))throw Error("'startFetching()' is unavailable in 'singleFrameMode'.");ci(this,ws,"f")||(di(this,ws,!0),ci(this,ls,"m",Os).call(this))}stopFetching(){ci(this,ws,"f")&&(Bs._onLog&&Bs._onLog("DCE: stop fetching loop: "+Date.now()),ci(this,Cs,"f")&&clearTimeout(ci(this,Cs,"f")),di(this,ws,!1))}toggleMirroring(t){this.isOpen()&&(this.video.style.transform=`scaleX(${t?"-1":"1"})`),this._isEnableMirroring=t}fetchImage(t=!1){if(ci(this,ls,"m",Is).call(this))throw new Error("'fetchImage()' is unavailable in 'singleFrameMode'.");if(!this.video)throw new Error("The video element does not exist.");if(4!==this.video.readyState)throw new Error("The video is not loaded.");const e=this.getResolution();if(!(null==e?void 0:e.width)||!(null==e?void 0:e.height))throw new Error("The video is not loaded.");let i;if(i=nn.convert(ci(this,vs,"f"),e.width,e.height,this.cameraView),i||(i={x:0,y:0,width:e.width,height:e.height}),i.x>e.width||i.y>e.height)throw new Error("Invalid scan region.");i.x+i.width>e.width&&(i.width=e.width-i.x),i.y+i.height>e.height&&(i.height=e.height-i.y);const n=this.cameraView.regionMaskLineWidth;let r;r=ci(this,vs,"f")&&!t?{sx:i.x+n,sy:i.y+n,sWidth:i.width-2*n,sHeight:i.height-2*n,dWidth:i.width-2*n,dHeight:i.height-2*n}:{sx:i.x,sy:i.y,sWidth:i.width,sHeight:i.height,dWidth:i.width,dHeight:i.height};const s=Math.max(r.dWidth,r.dHeight);if(this.canvasSizeLimit&&s>this.canvasSizeLimit){const t=this.canvasSizeLimit/s;r.dWidth>r.dHeight?(r.dWidth=this.canvasSizeLimit,r.dHeight=Math.round(r.dHeight*t)):(r.dWidth=Math.round(r.dWidth*t),r.dHeight=this.canvasSizeLimit)}const a=this.cameraManager.getFrameData({position:r,pixelFormat:this.getPixelFormat()===o.IPF_GRAYSCALED?Si.GREY:Si.RGBA,isEnableMirroring:this._isEnableMirroring});if(!a)return null;let l;l=a.pixelFormat===Si.GREY?a.width:4*a.width;let h=!0;return 0===r.sx&&0===r.sy&&r.sWidth===e.width&&r.sHeight===e.height&&(h=!1),{bytes:a.data,width:a.width,height:a.height,stride:l,format:Ls.get(a.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:lt.ITT_VIDEO_FRAME,isCropped:h,cropRegion:{left:r.sx,top:r.sy,right:r.sx+r.sWidth,bottom:r.sy+r.sHeight,isMeasuredInPercentage:!1},originalWidth:e.width,originalHeight:e.height,currentWidth:a.width,currentHeight:a.height,timeSpent:a.timeSpent,timeStamp:a.timeStamp},toCanvas:ci(this,ps,"f"),isDCEFrame:!0}}setImageFetchInterval(t){this.fetchInterval=t,ci(this,ws,"f")&&(ci(this,Cs,"f")&&clearTimeout(ci(this,Cs,"f")),di(this,Cs,setTimeout((()=>{this.disposed||ci(this,ls,"m",Os).call(this)}),t)))}getImageFetchInterval(){return this.fetchInterval}setPixelFormat(t){di(this,ys,t)}getPixelFormat(){return ci(this,ys,"f")}takePhoto(t){if(!this.isOpen())throw new Error("Not open.");if(ci(this,ls,"m",Is).call(this))throw new Error("'takePhoto()' is unavailable in 'singleFrameMode'.");const e=document.createElement("input");e.setAttribute("type","file"),e.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp"),e.setAttribute("capture",""),e.style.position="absolute",e.style.top="-9999px",e.style.backgroundColor="transparent",e.style.color="transparent",e.addEventListener("click",(()=>{const t=this.isOpen();this.close(),window.addEventListener("focus",(()=>{t&&this.open(),e.remove()}),{once:!0})})),e.addEventListener("change",(async()=>{const i=e.files[0],n=await(async t=>{let e=null,i=null;if("undefined"!=typeof createImageBitmap)try{if(e=await createImageBitmap(t),e)return e}catch(t){}var n;return e||(i=await(n=t,new Promise(((t,e)=>{let i=URL.createObjectURL(n),r=new Image;r.src=i,r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=t=>{e(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}})))),i})(i),r=n instanceof HTMLImageElement?n.naturalWidth:n.width,s=n instanceof HTMLImageElement?n.naturalHeight:n.height;let a=nn.convert(ci(this,vs,"f"),r,s,this.cameraView);a||(a={x:0,y:0,width:r,height:s});const o=ci(this,ms,"f").call(this,n,r,s,a);t&&t(o)})),document.body.appendChild(e),e.click()}convertToPageCoordinates(t){const e=ci(this,ls,"m",As).call(this,t);return{x:e.pageX,y:e.pageY}}convertToClientCoordinates(t){const e=ci(this,ls,"m",As).call(this,t);return{x:e.clientX,y:e.clientY}}convertToScanRegionCoordinates(t){if(!ci(this,vs,"f"))return JSON.parse(JSON.stringify(t));if(this.isOpen()){const t=this.cameraView.getVisibleRegionOfVideo({inPixels:!0});di(this,fs,t||ci(this,fs,"f"))}let e,i,n=ci(this,vs,"f").left||ci(this,vs,"f").x||0,r=ci(this,vs,"f").top||ci(this,vs,"f").y||0;if(!ci(this,vs,"f").isMeasuredInPercentage)return{x:t.x-(n+this.cameraView.regionMaskLineWidth+ci(this,fs,"f").x),y:t.y-(r+this.cameraView.regionMaskLineWidth+ci(this,fs,"f").y)};if(!this.cameraView)throw new Error("Camera view is not set.");if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");if(!this.isOpen())throw new Error("Not open.");if(!ci(this,ls,"m",Is).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(ci(this,ls,"m",Is).call(this)&&!this.cameraView._cvsSingleFrameMode)throw new Error("No image is selected.");if(ci(this,ls,"m",Is).call(this)){const t=this.cameraView._innerComponent.getElement("content");e=t.width,i=t.height}else e=ci(this,fs,"f").width,i=ci(this,fs,"f").height;return{x:t.x-(Math.round(n*e/100)+this.cameraView.regionMaskLineWidth+ci(this,fs,"f").x),y:t.y-(Math.round(r*i/100)+this.cameraView.regionMaskLineWidth+ci(this,fs,"f").y)}}dispose(){this.close(),this.cameraManager.dispose(),this.releaseCameraView(),di(this,bs,!0)}}var js,Vs,Us,Gs,Ws,Ys,Hs,zs;hs=Bs,ds=new WeakMap,us=new WeakMap,fs=new WeakMap,gs=new WeakMap,ms=new WeakMap,ps=new WeakMap,_s=new WeakMap,vs=new WeakMap,ys=new WeakMap,ws=new WeakMap,Cs=new WeakMap,Es=new WeakMap,Ss=new WeakMap,Ts=new WeakMap,bs=new WeakMap,ls=new WeakSet,Is=function(){return"disabled"!==this.singleFrameMode},xs=function(){return!this.videoSrc&&"opened"===this.cameraManager.state},Rs=function(){for(let t in ci(this,Es,"f"))if(1==ci(this,Es,"f")[t])return!0;return!1},Os=function t(){if(this.disposed)return;if("open"!==this.getCameraState()||!ci(this,ws,"f"))return ci(this,Cs,"f")&&clearTimeout(ci(this,Cs,"f")),void di(this,Cs,setTimeout((()=>{this.disposed||ci(this,ls,"m",t).call(this)}),this.fetchInterval));const e=()=>{var t;let e;Bs._onLog&&Bs._onLog("DCE: start fetching a frame into buffer: "+Date.now());try{e=this.fetchImage()}catch(e){const i=e.message||e;if("The video is not loaded."===i)return;if(null===(t=ci(this,_s,"f"))||void 0===t?void 0:t.onErrorReceived)return void setTimeout((()=>{var t;null===(t=ci(this,_s,"f"))||void 0===t||t.onErrorReceived(st.EC_IMAGE_READ_FAILED,i)}),0);console.warn(e)}e?(this.addImageToBuffer(e),Bs._onLog&&Bs._onLog("DCE: finish fetching a frame into buffer: "+Date.now()),ci(this,us,"f").fire("frameAddedToBuffer",null,{async:!1})):Bs._onLog&&Bs._onLog("DCE: get a invalid frame, abandon it: "+Date.now())};if(this.getImageCount()>=this.getMaxImageCount())switch(this.getBufferOverflowProtectionMode()){case s.BOPM_BLOCK:break;case s.BOPM_UPDATE:e()}else e();ci(this,Cs,"f")&&clearTimeout(ci(this,Cs,"f")),di(this,Cs,setTimeout((()=>{this.disposed||ci(this,ls,"m",t).call(this)}),this.fetchInterval))},As=function(t){if(!this.cameraView)throw new Error("Camera view is not set.");if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");if(!this.isOpen())throw new Error("Not open.");if(!ci(this,ls,"m",Is).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(ci(this,ls,"m",Is).call(this)&&!this.cameraView._cvsSingleFrameMode)throw new Error("No image is selected.");const e=this.cameraView._innerComponent.getBoundingClientRect(),i=e.left,n=e.top,r=i+window.scrollX,s=n+window.scrollY,{width:a,height:o}=this.cameraView._innerComponent.getBoundingClientRect();if(a<=0||o<=0)throw new Error("Unable to get content dimensions. Camera view may not be rendered on the page.");let l,h,c;if(ci(this,ls,"m",Is).call(this)){const t=this.cameraView._innerComponent.getElement("content");l=t.width,h=t.height,c="contain"}else{const t=this.getVideoEl();l=t.videoWidth,h=t.videoHeight,c=this.cameraView.getVideoFit()}const d=a/o,u=l/h;let f,g,m,p,_=1;if("contain"===c)d{var e;if(!this.isUseMagnifier)return;if(ci(this,Gs,"f")||di(this,Gs,new Xs),!ci(this,Gs,"f").magnifierCanvas)return;document.body.contains(ci(this,Gs,"f").magnifierCanvas)||(ci(this,Gs,"f").magnifierCanvas.style.position="fixed",ci(this,Gs,"f").magnifierCanvas.style.boxSizing="content-box",ci(this,Gs,"f").magnifierCanvas.style.border="2px solid #FFFFFF",document.body.append(ci(this,Gs,"f").magnifierCanvas));const i=this._innerComponent.getElement("content");if(!i)return;if(t.pointer.x<0||t.pointer.x>i.width||t.pointer.y<0||t.pointer.y>i.height)return void ci(this,Ys,"f").call(this);const n=null===(e=this._drawingLayerManager._getFabricCanvas())||void 0===e?void 0:e.lowerCanvasEl;if(!n)return;const r=Math.max(i.clientWidth/5/1.5,i.clientHeight/4/1.5),s=1.5*r,a=[{image:i,width:i.width,height:i.height},{image:n,width:n.width,height:n.height}];ci(this,Gs,"f").update(s,t.pointer,r,a);{let e=0,i=0;t.e instanceof MouseEvent?(e=t.e.clientX,i=t.e.clientY):t.e instanceof TouchEvent&&t.e.changedTouches.length&&(e=t.e.changedTouches[0].clientX,i=t.e.changedTouches[0].clientY),e<1.5*s&&i<1.5*s?(ci(this,Gs,"f").magnifierCanvas.style.left="auto",ci(this,Gs,"f").magnifierCanvas.style.top="0",ci(this,Gs,"f").magnifierCanvas.style.right="0"):(ci(this,Gs,"f").magnifierCanvas.style.left="0",ci(this,Gs,"f").magnifierCanvas.style.top="0",ci(this,Gs,"f").magnifierCanvas.style.right="auto")}ci(this,Gs,"f").show()})),Ys.set(this,(()=>{ci(this,Gs,"f")&&ci(this,Gs,"f").hide()})),Hs.set(this,!1)}_setUIElement(t){this.UIElement=t,this._unbindUI(),this._bindUI()}async setUIElement(t){let e;if("string"==typeof t){let i=await cn(t);e=document.createElement("div"),Object.assign(e.style,{width:"100%",height:"100%"}),e.attachShadow({mode:"open"}).appendChild(i)}else e=t;this._setUIElement(e)}getUIElement(){return this.UIElement}_bindUI(){if(!this.UIElement)throw new Error("Need to set 'UIElement'.");if(this._innerComponent)return;const t=this.UIElement;let e=t.classList.contains(this.containerClassName)?t:t.querySelector(`.${this.containerClassName}`);e||(e=document.createElement("div"),e.style.width="100%",e.style.height="100%",e.className=this.containerClassName,t.append(e)),this._innerComponent=document.createElement("dce-component"),e.appendChild(this._innerComponent)}_unbindUI(){var t,e,i;null===(t=this._drawingLayerManager)||void 0===t||t.clearDrawingLayers(),null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null,null===(i=this._innerComponent)||void 0===i||i.remove(),this._innerComponent=null}setImage(t,e,i){if(!this._innerComponent)throw new Error("Need to set 'UIElement'.");let n=this._innerComponent.getElement("content");n||(n=document.createElement("canvas"),n.style.objectFit="contain",this._innerComponent.setElement("content",n)),n.width===e&&n.height===i||(n.width=e,n.height=i);const r=n.getContext("2d");r.clearRect(0,0,n.width,n.height),t instanceof Uint8Array||t instanceof Uint8ClampedArray?(t instanceof Uint8Array&&(t=new Uint8ClampedArray(t.buffer)),r.putImageData(new ImageData(t,e,i),0,0)):(t instanceof HTMLCanvasElement||t instanceof HTMLImageElement)&&r.drawImage(t,0,0)}getImage(){return this._innerComponent.getElement("content")}clearImage(){if(!this._innerComponent)return;let t=this._innerComponent.getElement("content");t&&t.getContext("2d").clearRect(0,0,t.width,t.height)}removeImage(){this._innerComponent&&this._innerComponent.removeElement("content")}setOriginalImage(t){if(w(t)){di(this,Us,t);const{width:e,height:i,bytes:n,format:r}=Object.assign({},t);let s;if(r===o.IPF_GRAYSCALED){s=new Uint8ClampedArray(e*i*4);for(let t=0;t{if(!Ks){if(!Zs&&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"./"}})(),$s=t=>{if(null==t&&(t="./"),Zs||Ks);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Ft.engineResourcePaths.dbr={version:"11.0.30-dev-20250604160153",path:Js,isInternal:!0},Mt.dbr={js:!1,wasm:!0,deps:[_t.MN_DYNAMSOFT_LICENSE,_t.MN_DYNAMSOFT_IMAGE_PROCESSING]},Dt.dbr={};const Qs="2.0.0";"string"!=typeof Ft.engineResourcePaths.std&&A(Ft.engineResourcePaths.std.version,Qs)<0&&(Ft.engineResourcePaths.std={version:Qs,path:$s(Js+`../../dynamsoft-capture-vision-std@${Qs}/dist/`),isInternal:!0});const ta="3.0.10";(!Ft.engineResourcePaths.dip||"string"!=typeof Ft.engineResourcePaths.dip&&A(Ft.engineResourcePaths.dip.version,ta)<0)&&(Ft.engineResourcePaths.dip={version:ta,path:$s(Js+`../../dynamsoft-image-processing@${ta}/dist/`),isInternal:!0});let ea=class{static getVersion(){const t=At.dbr&&At.dbr.wasm;return`11.0.30-dev-20250604160153(Worker: ${At.dbr&&At.dbr.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}};const ia={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 na,ra,sa,aa;function oa(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(t){t[t.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",t[t.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",t[t.EBRT_PARTIAL_RESULT=2]="EBRT_PARTIAL_RESULT"}(na||(na={})),function(t){t[t.QRECL_ERROR_CORRECTION_H=0]="QRECL_ERROR_CORRECTION_H",t[t.QRECL_ERROR_CORRECTION_L=1]="QRECL_ERROR_CORRECTION_L",t[t.QRECL_ERROR_CORRECTION_M=2]="QRECL_ERROR_CORRECTION_M",t[t.QRECL_ERROR_CORRECTION_Q=3]="QRECL_ERROR_CORRECTION_Q"}(ra||(ra={})),function(t){t[t.LM_AUTO=1]="LM_AUTO",t[t.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",t[t.LM_STATISTICS=4]="LM_STATISTICS",t[t.LM_LINES=8]="LM_LINES",t[t.LM_SCAN_DIRECTLY=16]="LM_SCAN_DIRECTLY",t[t.LM_STATISTICS_MARKS=32]="LM_STATISTICS_MARKS",t[t.LM_STATISTICS_POSTAL_CODE=64]="LM_STATISTICS_POSTAL_CODE",t[t.LM_CENTRE=128]="LM_CENTRE",t[t.LM_ONED_FAST_SCAN=256]="LM_ONED_FAST_SCAN",t[t.LM_REV=-2147483648]="LM_REV",t[t.LM_SKIP=0]="LM_SKIP",t[t.LM_END=-1]="LM_END"}(sa||(sa={})),function(t){t[t.DM_DIRECT_BINARIZATION=1]="DM_DIRECT_BINARIZATION",t[t.DM_THRESHOLD_BINARIZATION=2]="DM_THRESHOLD_BINARIZATION",t[t.DM_GRAY_EQUALIZATION=4]="DM_GRAY_EQUALIZATION",t[t.DM_SMOOTHING=8]="DM_SMOOTHING",t[t.DM_MORPHING=16]="DM_MORPHING",t[t.DM_DEEP_ANALYSIS=32]="DM_DEEP_ANALYSIS",t[t.DM_SHARPENING=64]="DM_SHARPENING",t[t.DM_BASED_ON_LOC_BIN=128]="DM_BASED_ON_LOC_BIN",t[t.DM_SHARPENING_SMOOTHING=256]="DM_SHARPENING_SMOOTHING",t[t.DM_NEURAL_NETWORK=512]="DM_NEURAL_NETWORK",t[t.DM_REV=-2147483648]="DM_REV",t[t.DM_SKIP=0]="DM_SKIP",t[t.DM_END=-1]="DM_END"}(aa||(aa={})),"function"==typeof SuppressedError&&SuppressedError;const la="undefined"==typeof self,ha=(()=>{if(!la&&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"./"})(),ca=t=>{if(null==t&&(t="./"),la);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};var da,ua;Ft.engineResourcePaths.dlr={version:"4.0.30-dev-20250604160409",path:ha,isInternal:!0},Mt.dlr={js:!0,wasm:!0,deps:[_t.MN_DYNAMSOFT_LICENSE,_t.MN_DYNAMSOFT_IMAGE_PROCESSING]};const fa="2.0.0";"string"!=typeof Ft.engineResourcePaths.std&&A(Ft.engineResourcePaths.std.version,fa)<0&&(Ft.engineResourcePaths.std={version:fa,path:ca(ha+`../../dynamsoft-capture-vision-std@${fa}/dist/`),isInternal:!0});const ga="3.0.10";(!Ft.engineResourcePaths.dip||"string"!=typeof Ft.engineResourcePaths.dip&&A(Ft.engineResourcePaths.dip.version,ga)<0)&&(Ft.engineResourcePaths.dip={version:ga,path:ca(ha+`../../dynamsoft-image-processing@${ga}/dist/`),isInternal:!0});let ma=class t{static getVersion(){const t=At.dlr&&At.dlr.wasm;return`4.0.30-dev-20250604160409(Worker: ${At.dlr&&At.dlr.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadConfusableCharsData(e,i){return oa(t,da,"m",ua).call(t,"confusable",e,i)}static async loadOverlappingCharsData(e,i){return oa(t,da,"m",ua).call(t,"overlapping",e,i)}};da=ma,ua=async function(t,e,i){return await Ft.loadWasm(),await new Promise(((n,r)=>{let s=Tt();bt[s]=async t=>{if(t.success){const e=JSON.parse(t.result);if(0!==e.errorCode){let t=new Error(e.errorString);return t.errorCode=e.errorCode,r(t)}return n(e)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,r(e)}},i&&!i.endsWith("/")&&(i+="/");const a=D(Ft.engineResourcePaths);Et.postMessage({type:"dlr_loadData",id:s,body:{type:t,dataName:e,dataPath:i||a.dcvData+"char-resources/"}})}))},Dt.dlr={loadConfusableCharsData:ma.loadConfusableCharsData,loadOverlappingCharsData:ma.loadOverlappingCharsData};const pa={filterVINResult:function(t){let e="";if(18===t.characterResults.length){let e=t.characterResults[9].location.points[0].x-t.characterResults[8].location.points[1].x;e<2&&(e=2);let i=t.characterResults[1].location.points[0].x-t.characterResults[0].location.points[1].x,n=t.characterResults[17].location.points[0].x-t.characterResults[16].location.points[1].x,r=2===e?3:e;i-e>=r&&n-e=r&&i-et.characterResults[17].characterHConfidence?t.characterResults.pop():t.characterResults.shift()}else if(19===t.characterResults.length){let e=t.characterResults[10].location.points[0].x-t.characterResults[9].location.points[1].x;e<2&&(e=2);let i,n,r,s=t.characterResults[1].location.points[0].x-t.characterResults[0].location.points[1].x,a=t.characterResults[18].location.points[0].x-t.characterResults[17].location.points[1].x,o=t.characterResults[2].location.points[0].x-t.characterResults[1].location.points[1].x,l=t.characterResults[17].location.points[0].x-t.characterResults[16].location.points[1].x,h=2===e?3:e;if("1"===t.characterResults[1].characterH||"1"===t.characterResults[2].characterH||"1"===t.characterResults[16].characterH||"1"===t.characterResults[17].characterH){for(let e=9;e=(i||h)&&l-e<(n||h))t.characterResults.splice(0,2);else if(l-e>=(n||h)&&o-e<(i||h))t.characterResults.splice(17,2);else if(s>e&&a>e)t.characterResults.pop(),t.characterResults.shift();else{let e=t.characterResults[0].characterHConfidence+t.characterResults[1].characterHConfidence,i=t.characterResults[17].characterHConfidence+t.characterResults[18].characterHConfidence,n=t.characterResults[0].characterHConfidence+t.characterResults[18].characterHConfidence,r=Math.min(e,i,n);r===e?t.characterResults.splice(0,2):r===i?t.characterResults.splice(17,2):r===n&&(t.characterResults.pop(),t.characterResults.shift())}}for(let i of t.characterResults)e+=i.characterH;return e},checkValidVIN:function(t){return!(!t||17!=t.length)&&(t=>{const e=new Map([["A",1],["B",2],["C",3],["D",4],["E",5],["F",6],["G",7],["H",8],["J",1],["K",2],["L",3],["M",4],["N",5],["P",7],["R",9],["S",2],["T",3],["U",4],["V",5],["W",6],["X",7],["Y",8],["Z",9],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9]]),i=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2];let n=0;for(let r=0;r{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10},i=t.slice(0,10)+t.slice(13,20)+t.slice(21,43),n=e(t,0,8).toString(),r=e(t,13,18).toString(),s=e(t,21,26).toString(),a=e(t,28,41).toString(),o=e(i,0,i.length).toString();return n===t[9]&&r===t[19]&&s===t[27]&&a===t[42]&&o===t[43]},checkValidMRV:function(t){if(!t||44!=t.length&&36!=t.length)return!1;const e=(t,e,i)=>{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10},i=e(t,0,8).toString(),n=e(t,13,18).toString(),r=e(t,21,26).toString();return i===t[9]&&n===t[19]&&r===t[27]},checkValidIDCard:function(t,e){if(!t||30!=t.length&&36!=t.length)return!1;const i=(t,e,i)=>{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10};if(30===t.length){if(e&&t===e)return i(t,5,13).toString()===t[14];if(e&&t!==e){const n=`${e.substring(5,30)}${t.substring(0,7)}${t.substring(8,15)}${t.substring(18,29)}`;return i(n,0,n.length-1).toString()===t[29]}}else if(36===t.length){const e=i(t,0,8).toString(),n=i(t,13,18).toString(),r=i(t,21,26).toString(),s=`${t.substring(0,10)}${t.substring(13,20)}${t.substring(21,28)}`,a=i(s,0,s.length-1).toString();return e===t[9]&&n===t[19]&&r===t[27]&&a===t[35]}}};var _a,va,ya;function wa(t){delete t.moduleId;const e=JSON.parse(t.jsonString).ResultInfo,i=t.fullCodeString;t.getFieldValue=t=>"fullcodestring"===t.toLowerCase()?i:Ca(e,t,"map"),t.getFieldRawValue=t=>Ca(e,t,"raw"),t.getFieldMappingStatus=t=>Ea(e,t),t.getFieldValidationStatus=t=>Sa(e,t),delete t.fullCodeString}function Ca(t,e,i){for(let n of t){if(n.FieldName===e)return"raw"===i&&n.RawValue?n.RawValue:n.Value;if(n.ChildFields&&n.ChildFields.length>0){let t;for(let r of n.ChildFields)t=Ca(r,e,i);if(void 0!==t)return t}}}function Ea(t,e){for(let i of t){if(i.FieldName===e)return i.MappingStatus?Number(va[i.MappingStatus]):va.MS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=Ea(n,e);if(void 0!==t)return t}}}function Sa(t,e){for(let i of t){if(i.FieldName===e&&i.ValidationStatus)return i.ValidationStatus?Number(ya[i.ValidationStatus]):ya.VS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=Sa(n,e);if(void 0!==t)return t}}}function Ta(t){if(t.disposed)throw new Error('"CodeParser" instance has been disposed')}!function(t){t[t.RTLS_LOCALIZED=0]="RTLS_LOCALIZED",t[t.RTLS_RECOGNITION_FAILED=1]="RTLS_RECOGNITION_FAILED",t[t.RTLS_RECOGNITION_SUCCEEDED=2]="RTLS_RECOGNITION_SUCCEEDED"}(_a||(_a={})),bt[-1]=async t=>{ma.onDataLoadProgressChanged&&ma.onDataLoadProgressChanged(t.resourcesPath,t.tag,{loaded:t.loaded,total:t.total})},function(t){t[t.MS_NONE=0]="MS_NONE",t[t.MS_SUCCEEDED=1]="MS_SUCCEEDED",t[t.MS_FAILED=2]="MS_FAILED"}(va||(va={})),function(t){t[t.VS_NONE=0]="VS_NONE",t[t.VS_SUCCEEDED=1]="VS_SUCCEEDED",t[t.VS_FAILED=2]="VS_FAILED"}(ya||(ya={}));const ba=t=>t&&"object"==typeof t&&"function"==typeof t.then,Ia=(async()=>{})().constructor;let xa=class extends Ia{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,ba(t)?e=t:"function"==typeof t&&(e=new Ia(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&&(ba(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}};class Ra{constructor(){this._instanceID=void 0,this.bDestroyed=!1}static async createInstance(){if(!Dt.license)throw Error("Module `license` is not existed.");await Dt.license.dynamsoft(),await Ft.loadWasm();const t=new Ra,e=new xa;let i=Tt();return bt[i]=async i=>{if(i.success)t._instanceID=i.instanceID,e.resolve(t);else{const t=Error(i.message);i.stack&&(t.stack=i.stack),e.reject(t)}},Et.postMessage({type:"dcp_createInstance",id:i}),e}async dispose(){Ta(this);let t=Tt();this.bDestroyed=!0,bt[t]=t=>{if(!t.success){let e=new Error(t.message);throw e.stack=t.stack+"\n"+e.stack,e}},Et.postMessage({type:"dcp_dispose",id:t,instanceID:this._instanceID})}get disposed(){return this.bDestroyed}async initSettings(t){return Ta(this),t&&["string","object"].includes(typeof t)?("string"==typeof t?t.trimStart().startsWith("{")||(t=await R(t,"text")):"object"==typeof t&&(t=JSON.stringify(t)),await new Promise(((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success){const n=JSON.parse(t.response);if(0!==n.errorCode){let t=new Error(n.errorString?n.errorString:"Init Settings Failed.");return t.errorCode=n.errorCode,i(t)}return e(n)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},Et.postMessage({type:"dcp_initSettings",id:n,instanceID:this._instanceID,body:{settings:t}})}))):console.error("Invalid settings.")}async resetSettings(){return Ta(this),await new Promise(((t,e)=>{let i=Tt();bt[i]=async i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},Et.postMessage({type:"dcp_resetSettings",id:i,instanceID:this._instanceID})}))}async parse(t,e=""){if(Ta(this),!t||!(t instanceof Array||t instanceof Uint8Array||"string"==typeof t))throw new Error("`parse` must pass in an Array or Uint8Array or string");return await new Promise(((i,n)=>{let r=Tt();t instanceof Array&&(t=Uint8Array.from(t)),"string"==typeof t&&(t=Uint8Array.from(function(t){let e=[];for(let i=0;i{if(t.success){let e=JSON.parse(t.parseResponse);return e.errorCode?n(new Error(e.errorString)):(wa(e),i(e))}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},Et.postMessage({type:"dcp_parse",id:r,instanceID:this._instanceID,body:{source:t,taskSettingName:e}})}))}}const Oa="undefined"==typeof self,Aa="function"==typeof importScripts,Da=(()=>{if(!Aa){if(!Oa&&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"./"}})();Ft.engineResourcePaths.dcp={version:"3.0.30-dev-20250604160317",path:Da,isInternal:!0},Mt.dcp={js:!0,wasm:!0,deps:[_t.MN_DYNAMSOFT_LICENSE]},Dt.dcp={handleParsedResultItem:wa};const Ma="2.0.0";"string"!=typeof Ft.engineResourcePaths.std&&A(Ft.engineResourcePaths.std.version,Ma)<0&&(Ft.engineResourcePaths.std={version:Ma,path:(t=>{if(null==t&&(t="./"),Oa||Aa);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(Da+`../../dynamsoft-capture-vision-std@${Ma}/dist/`),isInternal:!0});let La=class{static getVersion(){const t=At.dcp&&At.dcp.wasm;return`3.0.30-dev-20250604160317(Worker: ${At.dcp&&At.dcp.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadSpec(t,e){return await Ft.loadWasm(),await new Promise(((i,n)=>{let r=Tt();bt[r]=async t=>{if(t.success)return i();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},e&&!e.endsWith("/")&&(e+="/");const s=t instanceof Array?t:[t],a=D(Ft.engineResourcePaths);Et.postMessage({type:"dcp_appendResourceBuffer",id:r,body:{specificationPath:e||a.dcvData+"parser-resources/",specificationNames:s}})}))}};const Fa="undefined"==typeof self,Pa="function"==typeof importScripts,ka=(()=>{if(!Pa){if(!Fa&&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"./"}})(),Na=t=>{if(null==t&&(t="./"),Fa||Pa);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Ft.engineResourcePaths.ddn={version:"3.0.30-dev-20250604160349",path:ka,isInternal:!0},Mt.ddn={js:!0,wasm:!0,deps:[_t.MN_DYNAMSOFT_LICENSE,_t.MN_DYNAMSOFT_IMAGE_PROCESSING]},Dt.ddn={handleDeskewedAndEnhancedImageResultItem:function(t){let e=t,i=k(e.imageData);e.toCanvas=()=>L(i),e.toImage=t=>F(t,i),e.toBlob=t=>P(t,i)}};const Ba="2.0.0";"string"!=typeof Ft.engineResourcePaths.std&&A(Ft.engineResourcePaths.std.version,Ba)<0&&(Ft.engineResourcePaths.std={version:Ba,path:Na(ka+`../../dynamsoft-capture-vision-std@${Ba}/dist/`),isInternal:!0});const ja="3.0.10";(!Ft.engineResourcePaths.dip||"string"!=typeof Ft.engineResourcePaths.dip&&A(Ft.engineResourcePaths.dip.version,ja)<0)&&(Ft.engineResourcePaths.dip={version:ja,path:Na(ka+`../../dynamsoft-image-processing@${ja}/dist/`),isInternal:!0});let Va=class{static getVersion(){const t=At.ddn&&At.ddn.wasm;return`3.0.30-dev-20250604160349(Worker: ${At.ddn&&At.ddn.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}async setThresholdValue(t,e,i,n){return await Ft.loadWasm(),await new Promise(((r,s)=>{let a=Tt();bt[a]=async t=>{if(t.success)return r();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,s(e)}},Et.postMessage({type:"ddn_setThresholdValue",id:a,instanceID:t._instanceID,body:{threshold:e,leftLimit:i,rightLimit:n}})}))}};var Ua;!function(t){t[t.ICM_COLOUR=0]="ICM_COLOUR",t[t.ICM_GRAYSCALE=1]="ICM_GRAYSCALE",t[t.ICM_BINARY=2]="ICM_BINARY"}(Ua||(Ua={}));const Ga="undefined"==typeof self,Wa="function"==typeof importScripts,Ya=(()=>{if(!Wa){if(!Ga&&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"./"}})(),Ha=t=>{if(null==t&&(t="./"),Ga||Wa);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Ft.engineResourcePaths.utility={version:"2.0.30-dev-20250604160458",path:Ya,isInternal:!0},Mt.utility={js:!0,wasm:!0};const za="2.0.0";"string"!=typeof Ft.engineResourcePaths.std&&A(Ft.engineResourcePaths.std.version,za)<0&&(Ft.engineResourcePaths.std={version:za,path:Ha(Ya+`../../dynamsoft-capture-vision-std@${za}/dist/`),isInternal:!0});const Xa="3.0.10";(!Ft.engineResourcePaths.dip||"string"!=typeof Ft.engineResourcePaths.dip&&A(Ft.engineResourcePaths.dip.version,Xa)<0)&&(Ft.engineResourcePaths.dip={version:Xa,path:Ha(Ya+`../../dynamsoft-image-processing@${Xa}/dist/`),isInternal:!0});class qa{static getVersion(){return`2.0.30-dev-20250604160458(Worker: ${At.utility&&At.utility.worker||"Not Loaded"}, Wasm: ${At.utility&&At.utility.wasm||"Not Loaded"})`}}function Za(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"==typeof SuppressedError&&SuppressedError;const Ka="undefined"==typeof self,Ja="function"==typeof importScripts,$a=(()=>{if(!Ja){if(!Ka&&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"./"}})(),Qa=t=>{if(null==t&&(t="./"),Ka||Ja);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Ft.engineResourcePaths.dbr={version:"11.0.30-dev-20250522174049",path:$a,isInternal:!0},Mt.dbr={js:!1,wasm:!0,deps:[_t.MN_DYNAMSOFT_LICENSE,_t.MN_DYNAMSOFT_IMAGE_PROCESSING]},Dt.dbr={};const to="2.0.0";"string"!=typeof Ft.engineResourcePaths.std&&A(Ft.engineResourcePaths.std.version,to)<0&&(Ft.engineResourcePaths.std={version:to,path:Qa($a+`../../dynamsoft-capture-vision-std@${to}/dist/`),isInternal:!0});const eo="3.0.10";(!Ft.engineResourcePaths.dip||"string"!=typeof Ft.engineResourcePaths.dip&&A(Ft.engineResourcePaths.dip.version,eo)<0)&&(Ft.engineResourcePaths.dip={version:eo,path:Qa($a+`../../dynamsoft-image-processing@${eo}/dist/`),isInternal:!0});const io={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 no,ro,so,ao,oo,lo,ho,co,uo,fo;function go(t,e){let i=!0;for(let a=0;a1)return Math.sqrt((l-a)**2+(h-o)**2);{const t=r+d*(a-r),e=s+d*(o-s);return Math.sqrt((l-t)**2+(h-e)**2)}}function _o(t){const e=[];for(let i=0;i=0&&l<=1&&h>=0&&h<=1?{x:t.x+h*r,y:t.y+h*s}:null}function wo(t){let e=0;for(let i=0;i0}function Eo(t,e){for(let i=0;i<4;i++)if(!Co(t.points[i],t.points[(i+1)%4],e))return!1;return!0}function So(t,e,i,n){const r=t.points,s=e.points;let a=8*i;a=Math.max(a,5);const o=_o(r)[3],l=_o(r)[1],h=_o(s)[3],c=_o(s)[1];let d,u=0;if(d=Math.max(Math.abs(po(o,e.points[0])),Math.abs(po(o,e.points[3]))),d>u&&(u=d),d=Math.max(Math.abs(po(l,e.points[1])),Math.abs(po(l,e.points[2]))),d>u&&(u=d),d=Math.max(Math.abs(po(h,t.points[0])),Math.abs(po(h,t.points[3]))),d>u&&(u=d),d=Math.max(Math.abs(po(c,t.points[1])),Math.abs(po(c,t.points[2]))),d>u&&(u=d),u>a)return!1;const f=vo(_o(r)[0]),g=vo(_o(r)[2]),m=vo(_o(s)[0]),p=vo(_o(s)[2]),_=mo(f,p),v=mo(m,g),y=_>v,w=Math.min(_,v),C=mo(f,g),E=mo(m,p);let S=12*i;return S=Math.max(S,5),S=Math.min(S,C),S=Math.min(S,E),!!(w{e.x+=t,e.y+=i})),e.x/=t.length,e.y/=t.length,e}isProbablySameLocationWithOffset(t,e){const i=this.item.location,n=t.location;if(i.area<=0)return!1;if(Math.abs(i.area-n.area)>.4*i.area)return!1;let r=new Array(4).fill(0),s=new Array(4).fill(0),a=0,o=0;for(let t=0;t<4;++t)r[t]=Math.round(100*(n.points[t].x-i.points[t].x))/100,a+=r[t],s[t]=Math.round(100*(n.points[t].y-i.points[t].y))/100,o+=s[t];a/=4,o/=4;for(let t=0;t<4;++t){if(Math.abs(r[t]-a)>this.strictLimit||Math.abs(a)>.8)return!1;if(Math.abs(s[t]-o)>this.strictLimit||Math.abs(o)>.8)return!1}return e.x=a,e.y=o,!0}isLocationOverlap(t,e){if(this.locationArea>e){for(let e=0;e<4;e++)if(Eo(this.location,t.points[e]))return!0;const e=this.getCenterPoint(t.points);if(Eo(this.location,e))return!0}else{for(let e=0;e<4;e++)if(Eo(t,this.location.points[e]))return!0;if(Eo(t,this.getCenterPoint(this.location.points)))return!0}return!1}isMatchedLocationWithOffset(t,e={x:0,y:0}){if(this.isOneD){const i=Object.assign({},t.location);for(let t=0;t<4;t++)i.points[t].x-=e.x,i.points[t].y-=e.y;if(!this.isLocationOverlap(i,t.locationArea))return!1;const n=[this.location.points[0],this.location.points[3]],r=[this.location.points[1],this.location.points[2]];for(let t=0;t<4;t++){const e=i.points[t],s=0===t||3===t?n:r;if(Math.abs(po(s,e))>this.locationThreshold)return!1}}else for(let i=0;i<4;i++){const n=t.location.points[i],r=this.location.points[i];if(!(Math.abs(r.x+e.x-n.x)=this.locationThreshold)return!1}return!0}isOverlappedLocationWithOffset(t,e,i=!0){const n=Object.assign({},t.location);for(let t=0;t<4;t++)n.points[t].x-=e.x,n.points[t].y-=e.y;if(!this.isLocationOverlap(n,t.location.area))return!1;if(i){const t=.75;return function(t,e){const i=[];for(let n=0;n<4;n++)for(let r=0;r<4;r++){const s=yo(t[n],t[(n+1)%4],e[r],e[(r+1)%4]);s&&i.push(s)}return t.forEach((t=>{go(e,t)&&i.push(t)})),e.forEach((e=>{go(t,e)&&i.push(e)})),wo(function(t){if(t.length<=1)return t;t.sort(((t,e)=>t.x-e.x||t.y-e.y));const e=t.shift();return t.sort(((t,i)=>Math.atan2(t.y-e.y,t.x-e.x)-Math.atan2(i.y-e.y,i.x-e.x))),[e,...t]}(i))}([...this.location.points],n.points)>this.locationArea*t}return!0}}const bo={barcode:2,text_line:4,detected_quad:8,normalized_image:16},Io=t=>Object.values(bo).includes(t)||bo.hasOwnProperty(t),xo=(t,e)=>"string"==typeof t?e[bo[t]]:e[t],Ro=(t,e,i)=>{"string"==typeof t?e[bo[t]]=i:e[t]=i},Oo=(t,e,i)=>{const n=[{type:nt.CRIT_BARCODE,resultName:"decodedBarcodesResult",itemNames:["barcodeResultItems"]},{type:nt.CRIT_TEXT_LINE,resultName:"recognizedTextLinesResult",itemNames:["textLineResultItems"]}],r=e.items;if(t.isResultCrossVerificationEnabled(i)){for(let t=r.length-1;t>=0;t--)r[t].type!==i||r[t].verified||r.splice(t,1);const t=n.filter((t=>t.type===i))[0];e[t.resultName]&&t.itemNames.forEach((n=>{const r=e[t.resultName][n];e[t.resultName][n]=r.filter((t=>t.type===i&&t.verified))}))}if(t.isResultDeduplicationEnabled(i)){for(let t=r.length-1;t>=0;t--)r[t].type===i&&r[t].duplicate&&r.splice(t,1);const t=n.filter((t=>t.type===i))[0];e[t.resultName]&&t.itemNames.forEach((n=>{const r=e[t.resultName][n];e[t.resultName][n]=r.filter((t=>t.type===i&&!t.duplicate))}))}};class Ao{constructor(){this.verificationEnabled={[nt.CRIT_BARCODE]:!1,[nt.CRIT_TEXT_LINE]:!0,[nt.CRIT_DETECTED_QUAD]:!0,[nt.CRIT_DESKEWED_IMAGE]:!1},this.duplicateFilterEnabled={[nt.CRIT_BARCODE]:!1,[nt.CRIT_TEXT_LINE]:!1,[nt.CRIT_DETECTED_QUAD]:!1,[nt.CRIT_DESKEWED_IMAGE]:!1},this.duplicateForgetTime={[nt.CRIT_BARCODE]:3e3,[nt.CRIT_TEXT_LINE]:3e3,[nt.CRIT_DETECTED_QUAD]:3e3,[nt.CRIT_DESKEWED_IMAGE]:3e3},this.latestOverlappingEnabled={[nt.CRIT_BARCODE]:!1,[nt.CRIT_TEXT_LINE]:!1,[nt.CRIT_DETECTED_QUAD]:!1,[nt.CRIT_DESKEWED_IMAGE]:!1},this.maxOverlappingFrames={[nt.CRIT_BARCODE]:5,[nt.CRIT_TEXT_LINE]:5,[nt.CRIT_DETECTED_QUAD]:5,[nt.CRIT_DESKEWED_IMAGE]:5},this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,lo.set(this,new Map),ho.set(this,new Map),co.set(this,new Map),uo.set(this,new Map),fo.set(this,new Map),Object.defineProperties(this,{onOriginalImageResultReceived:{value:t=>{},writable:!1},onDecodedBarcodesReceived:{value:t=>{this.latestOverlappingFilter(t),Oo(this,t,nt.CRIT_BARCODE)},writable:!1},onRecognizedTextLinesReceived:{value:t=>{Oo(this,t,nt.CRIT_TEXT_LINE)},writable:!1},onProcessedDocumentResultReceived:{value:t=>{},writable:!1},onParsedResultsReceived:{value:t=>{},writable:!1}})}_dynamsoft(){Za(this,lo,"f").forEach(((t,e)=>{Ro(e,this.verificationEnabled,t)})),Za(this,ho,"f").forEach(((t,e)=>{Ro(e,this.duplicateFilterEnabled,t)})),Za(this,co,"f").forEach(((t,e)=>{Ro(e,this.duplicateForgetTime,t)})),Za(this,uo,"f").forEach(((t,e)=>{Ro(e,this.latestOverlappingEnabled,t)})),Za(this,fo,"f").forEach(((t,e)=>{Ro(e,this.maxOverlappingFrames,t)}))}enableResultCrossVerification(t,e){Io(t)&&Za(this,lo,"f").set(t,e)}isResultCrossVerificationEnabled(t){return!!Io(t)&&xo(t,this.verificationEnabled)}enableResultDeduplication(t,e){Io(t)&&(e&&this.enableLatestOverlapping(t,!1),Za(this,ho,"f").set(t,e))}isResultDeduplicationEnabled(t){return!!Io(t)&&xo(t,this.duplicateFilterEnabled)}setDuplicateForgetTime(t,e){Io(t)&&(e>18e4&&(e=18e4),e<0&&(e=0),Za(this,co,"f").set(t,e))}getDuplicateForgetTime(t){return Io(t)?xo(t,this.duplicateForgetTime):-1}setMaxOverlappingFrames(t,e){Io(t)&&Za(this,fo,"f").set(t,e)}getMaxOverlappingFrames(t){return Io(t)?xo(t,this.maxOverlappingFrames):-1}enableLatestOverlapping(t,e){Io(t)&&(e&&this.enableResultDeduplication(t,!1),Za(this,uo,"f").set(t,e))}isLatestOverlappingEnabled(t){return!!Io(t)&&xo(t,this.latestOverlappingEnabled)}getFilteredResultItemTypes(){let t=0;const e=[nt.CRIT_BARCODE,nt.CRIT_TEXT_LINE,nt.CRIT_DETECTED_QUAD,nt.CRIT_DESKEWED_IMAGE];for(let i=0;i{if(1!==t.type){const e=(BigInt(t.format)&BigInt(io.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(io.BF_GS1_DATABAR))!=BigInt(0);return new To(l,e?1:2,e,t)}})).filter(Boolean);if(this.overlapSet.length>0){const t=new Array(h).fill(new Array(this.overlapSet.length).fill(1));let e=0;for(;e-1!==t)).length;r>p&&(p=r,m=n,g.x=i.x,g.y=i.y)}}if(0===p){for(let e=0;e-1!=t)).length}let i=this.overlapSet.length<=3?p>=1:p>=2;if(!i&&s&&d>0){let t=0;for(let e=0;e=1:t>=3}i||(this.overlapSet=[])}if(0===this.overlapSet.length)this.stabilityCount=0,t.items.forEach(((t,e)=>{if(1!==t.type){const i=Object.assign({},t),n=(BigInt(t.format)&BigInt(io.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(io.BF_GS1_DATABAR))!=BigInt(0),s=t.confidence5||Math.abs(g.y)>5)&&(e=!1):e=!1;for(let i=0;i0){for(let t=0;t!(t.overlapCount+this.stabilityCount<=0&&t.crossVerificationFrame<=0)))}f.sort(((t,e)=>e-t)).forEach(((e,i)=>{t.items.splice(e,1)})),u.forEach((e=>{t.items.push(Object.assign(Object.assign({},e),{overlapped:!0}))}))}}}lo=new WeakMap,ho=new WeakMap,co=new WeakMap,uo=new WeakMap,fo=new WeakMap;const Do=async t=>{let e;await new Promise(((i,n)=>{e=new Image,e.onload=()=>i(e),e.onerror=n,e.src=URL.createObjectURL(t)}));const i=document.createElement("canvas"),n=i.getContext("2d");return i.width=e.width,i.height=e.height,n.drawImage(e,0,0),{bytes:Uint8Array.from(n.getImageData(0,0,i.width,i.height).data),width:i.width,height:i.height,stride:4*i.width,format:o.IPF_ABGR_8888}};var Mo,Lo,Fo,Po,ko,No,Bo;class jo{async readFromFile(t){return await Do(t)}async saveToFile(t,e,i){if(!t||!e)return null;if("string"!=typeof e)throw new TypeError("FileName must be of type string.");const n=k(t);return M(n,e,i)}async readFromMemory(t){if(!Za(jo,Mo,"f",Lo).has(t))throw new Error("Image data ID does not exist.");const{ptr:e,length:i}=Za(jo,Mo,"f",Lo).get(t);return await new Promise(((t,n)=>{let r=Tt();bt[r]=async e=>{if(e.success)return 0!==e.imageData.errorCode&&n(new Error(`[${e.imageData.errorCode}] ${e.imageData.errorString}`)),t(e.imageData);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,n(t)}},Et.postMessage({type:"utility_readFromMemory",id:r,body:{ptr:e,length:i}})}))}async saveToMemory(t,e){const{bytes:i,width:n,height:r,stride:s,format:a}=await Do(t);return await new Promise(((t,o)=>{let l=Tt();bt[l]=async e=>{var i,n;if(e.success)return function(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");r?r.value=i:e.set(t,i)}(i=jo,Mo,(n=Za(i,Mo,"f",Fo),++n),0,Fo),Za(jo,Mo,"f",Lo).set(Za(jo,Mo,"f",Fo),JSON.parse(e.memery)),t(Za(jo,Mo,"f",Fo));{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},Et.postMessage({type:"utility_saveToMemory",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,fileFormat:e}})}))}}Mo=jo,Lo={value:new Map},Fo={value:0};class Vo{async drawOnImage(t,e,i,n=4294901760,r=1,s){if(!t)throw new Error("Invalid image.");if(!e)throw new Error("Invalid drawingItem.");if(!i)throw new Error("Invalid type.");let a;if(t instanceof Blob)a=await Do(t);else if("string"==typeof t){let e=await R(t,"blob");a=await Do(e)}else w(t)&&(a=t,"bigint"==typeof a.format&&(a.format=Number(a.format)));return await new Promise(((t,o)=>{let l=Tt();bt[l]=async e=>{if(e.success)return s&&(new jo).saveToFile(e.image,"test.png",s),t(e.image);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},Et.postMessage({type:"utility_drawOnImage",id:l,body:{dsImage:a,drawingItem:Array.isArray(e)?e:[e],color:n,thickness:r,type:i}})}))}}class Uo{async cropImage(t,e){let i;if(C(e))i="Rect";else{if(!I(e))throw new Error("Invalid roi.");i="Quadrilateral"}const{bytes:n,width:r,height:s,stride:a,format:o}=await Do(t);return await new Promise(((t,l)=>{let h=Tt();bt[h]=async e=>{if(e.success)return t(e.cropImage);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,l(t)}},Et.postMessage({type:"utility_cropImage",id:h,body:{type:i,bytes:n,width:r,height:s,stride:a,format:o,roi:e}})}))}async adjustBrightness(t,e){if(e>100||e<-100)throw new Error("Invalid brightness, range: [-100, 100].");const{bytes:i,width:n,height:r,stride:s,format:a}=await Do(t);return await new Promise(((t,o)=>{let l=Tt();bt[l]=async e=>{if(e.success)return t(e.adjustBrightness);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},Et.postMessage({type:"utility_adjustBrightness",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,brightness:e}})}))}async adjustContrast(t,e){if(e>100||e<-100)throw new Error("Invalid contrast, range: [-100, 100].");const{bytes:i,width:n,height:r,stride:s,format:a}=await Do(t);return await new Promise(((t,o)=>{let l=Tt();bt[l]=async e=>{if(e.success)return t(e.adjustContrast);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},Et.postMessage({type:"utility_adjustContrast",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,contrast:e}})}))}async filterImage(t,e){if(![0,1,2].includes(e))throw new Error("Invalid filterType.");const{bytes:i,width:n,height:r,stride:s,format:a}=await Do(t);return await new Promise(((t,o)=>{let l=Tt();bt[l]=async e=>{if(e.success)return t(e.filterImage);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},Et.postMessage({type:"utility_filterImage",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,filterType:e}})}))}async convertToGray(t,e,i,n){const{bytes:r,width:s,height:a,stride:o,format:l}=await Do(t);return await new Promise(((t,h)=>{let c=Tt();bt[c]=async e=>{if(e.success)return t(e.convertToGray);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,h(t)}},Et.postMessage({type:"utility_convertToGray",id:c,body:{bytes:r,width:s,height:a,stride:o,format:l,R:e,G:i,B:n}})}))}async convertToBinaryGlobal(t,e=-1,i=!1){const{bytes:n,width:r,height:s,stride:a,format:o}=await Do(t);return await new Promise(((t,l)=>{let h=Tt();bt[h]=async e=>{if(e.success)return t(e.convertToBinaryGlobal);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,l(t)}},Et.postMessage({type:"utility_convertToBinaryGlobal",id:h,body:{bytes:n,width:r,height:s,stride:a,format:o,threshold:e,invert:i}})}))}async convertToBinaryLocal(t,e=0,i=0,n=!1){const{bytes:r,width:s,height:a,stride:o,format:l}=await Do(t);return await new Promise(((t,h)=>{let c=Tt();bt[c]=async e=>{if(e.success)return t(e.convertToBinaryLocal);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,h(t)}},Et.postMessage({type:"utility_convertToBinaryLocal",id:c,body:{bytes:r,width:s,height:a,stride:o,format:l,blockSize:e,compensation:i,invert:n}})}))}}!function(t){t[t.FT_HIGH_PASS=0]="FT_HIGH_PASS",t[t.FT_SHARPEN=1]="FT_SHARPEN",t[t.FT_SMOOTH=2]="FT_SMOOTH"}(Po||(Po={})),Ft.engineResourcePaths.rootDirectory=(t=>{if(null==t&&(t="./"),Pt||kt);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(Nt+"../../"),Ft.engineResourcePaths.dcvBundle={version:"3.0.3001",path:Nt,isInternal:!0},Ft.engineResourcePaths.dcvData={version:"1.0.1",path:Nt,isInternal:!0},function(t){t.Passport="passport",t.TD1="td1",t.TD2="td2",t.PassportAndTD1="passportAndTd1",t.PassportAndTD2="passportAndTd2",t.TD1AndTD2="td1AndTd2",t.All="all"}(ko||(ko={})),function(t){t.Passport="passport",t.TD1="td1",t.TD2="td2"}(No||(No={})),function(t){t.Scanner="scanner",t.Result="scan-result"}(Bo||(Bo={}));const Go={[ko.Passport]:"ReadPassport",[ko.TD1]:"ReadId-TD1",[ko.TD2]:"ReadId-TD2",[ko.PassportAndTD1]:"ReadPassportAndId-TD1",[ko.PassportAndTD2]:"ReadPassportAndId-TD2",[ko.TD1AndTD2]:"ReadId",[ko.All]:"ReadPassportAndId"};var Wo;function Yo(t){if("string"==typeof t){const e=document.querySelector(t);if(!e)throw new Error("Element not found");return e}return t instanceof HTMLElement?t:null}!function(t){t[t.RS_SUCCESS=0]="RS_SUCCESS",t[t.RS_CANCELLED=1]="RS_CANCELLED",t[t.RS_FAILED=2]="RS_FAILED"}(Wo||(Wo={}));function Ho(t,e){if(!document.getElementById(t)){const i=document.createElement("style");i.id=t,i.textContent=e,document.head.appendChild(i)}}const zo=t=>!t||0===Object.keys(t).length;function Xo(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}const qo={"4k":{width:3840,height:2160},"2k":{width:2560,height:1440},"1080p":{width:1920,height:1080},"720p":{width:1280,height:720},"480p":{width:640,height:480}};function Zo(t,e={}){const{message:i,spinnerSize:n=32}=e,r=document.createElement("div");r.className="dynamsoft-mrz-loading-screen";const s=document.createElement("div");s.className="dynamsoft-mrz-loading";const a=document.createElement("div");a.className="dynamsoft-mrz-loading-content";const o=`\n \n \n \n `;if(a.innerHTML=o,i){const t=document.createElement("div");t.className="dynamsoft-mrz-loading-message",t.textContent=i,a.appendChild(t)}return s.appendChild(a),r.appendChild(s),t.appendChild(r),{element:r,updateMessage:t=>{let e=s.querySelector(".dynamsoft-mrz-loading-message");null!==t?e?e.textContent=t:(e=document.createElement("div"),e.className="dynamsoft-mrz-loading-message",e.textContent=t,a.appendChild(e)):null==e||e.remove()},hide:()=>{r&&r.parentNode&&(r.classList.add("fade-out"),setTimeout((()=>{var t;null===(t=r.parentNode)||void 0===t||t.removeChild(r)}),200))}}}const Ko='\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: "Verdana";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n';var Jo;!function(t){t.InvalidFields="invalidFields",t.DocumentType="documentType",t.DocumentNumber="documentNumber",t.MRZText="mrzText",t.FirstName="firstName",t.LastName="lastName",t.Age="age",t.Sex="sex",t.IssuingState="issuingState",t.IssuingStateRaw="issuingStateRaw",t.Nationality="nationality",t.NationalityRaw="nationalityRaw",t.DateOfBirth="dateOfBirth",t.DateOfExpiry="dateOfExpiry"}(Jo||(Jo={}));const $o={[Jo.InvalidFields]:"Invalid Fields",[Jo.DocumentType]:"Document Type",[Jo.DocumentNumber]:"Document Number",[Jo.MRZText]:"MRZ Text",[Jo.FirstName]:"Given Name(s)",[Jo.LastName]:"Surname",[Jo.Age]:"Age",[Jo.Sex]:"Sex",[Jo.IssuingState]:"Issuing State",[Jo.IssuingStateRaw]:"Issuing State (Raw Value)",[Jo.Nationality]:"Nationality",[Jo.NationalityRaw]:"Nationality State (Raw Value)",[Jo.DateOfBirth]:"Date Of Birth (YYYY-MM-DD)",[Jo.DateOfExpiry]:"Date Of Expiry (YYYY-MM-DD)"};function Qo(t,e,i,n=!1){const r=parseInt(t,10);let s;if(n)s=r>=60?1900+r:2e3+r;else{s=r>(new Date).getFullYear()%100?1900+r:2e3+r}return{year:s,month:parseInt(e,10),day:parseInt(i,10)}}function tl(t){const e=t=>{var e;return 1===(null===(e=`${t}`)||void 0===e?void 0:e.length)?`0${t}`:t};return`${null==t?void 0:t.year}-${e(null==t?void 0:t.month)}${(null==t?void 0:t.day)&&`-${e(null==t?void 0:t.day)}`}`}function el(t){return"D<<"===t?"D":t}function il(t,e){const i=[],n=t=>e.getFieldValidationStatus(t)===ya.VS_FAILED,r=e.codeType,s=function(t){switch(t){case"MRTD_TD1_ID":return No.TD1;case"MRTD_TD2_ID":case"MRTD_TD2_VISA":case"MRTD_TD2_FRENCH_ID":return No.TD2;case"MRTD_TD3_PASSPORT":case"MRTD_TD3_VISA":return No.Passport;default:throw new Error(`Unknown document type: ${t}`)}}(r),a=function(t){switch(t){case"MRTD_TD1_ID":return"ID (TD1)";case"MRTD_TD2_ID":return"ID (TD2)";case"MRTD_TD2_VISA":return"ID (VISA)";case"MRTD_TD2_FRENCH_ID":return"French ID (TD2)";case"MRTD_TD3_PASSPORT":return"Passport (TD3)";case"MRTD_TD3_VISA":return"Visa (TD3)";default:throw new Error(`Unknown document type: ${t}`)}}(r),o=s===No.Passport&&"MRTD_TD3_PASSPORT"===r?"passportNumber":"documentNumber",l=Qo(e.getFieldValue("birthYear"),e.getFieldValue("birthMonth"),e.getFieldValue("birthDay")),h=Qo(e.getFieldValue("expiryYear"),e.getFieldValue("expiryMonth"),e.getFieldValue("expiryDay"),!0);["birthYear","birthMonth","birthDay"].forEach((t=>{n(t)&&i.push(Jo.DateOfBirth)})),["expiryYear","expiryMonth","expiryDay"].forEach((t=>{n(t)&&i.push(Jo.DateOfExpiry)}));const c={[Jo.LastName]:e.getFieldValue("primaryIdentifier"),[Jo.FirstName]:e.getFieldValue("secondaryIdentifier"),[Jo.Nationality]:e.getFieldValue("nationality"),[Jo.NationalityRaw]:el(e.getFieldRawValue("nationality")),[Jo.DocumentNumber]:e.getFieldValue(o)||e.getFieldValue("longDocumentNumber"),[Jo.IssuingState]:e.getFieldValue("issuingState"),[Jo.IssuingStateRaw]:el(e.getFieldRawValue("issuingState")),[Jo.Sex]:Xo(e.getFieldValue("sex"))};Object.keys(c).forEach((t=>{let e=!1;switch(t){case Jo.FirstName:e=n("secondaryIdentifier");break;case Jo.LastName:e=n("primaryIdentifier");break;case Jo.DocumentNumber:e=n(o)||n("longDocumentNumber");break;default:e=n(t)}e&&i.push(t)}));const d=function(t){const e=new Date,i=e.getMonth()+1>t.month||e.getMonth()+1===t.month&&e.getDate()>=t.day;return e.getFullYear()-t.year-(i?0:1)}(l);d<1&&i.push(Jo.Age);return{[Jo.InvalidFields]:i,[Jo.FirstName]:c[Jo.FirstName],[Jo.LastName]:c[Jo.LastName],[Jo.Age]:d,[Jo.DateOfBirth]:l,[Jo.Sex]:c[Jo.Sex],[Jo.Nationality]:c[Jo.Nationality],[Jo.NationalityRaw]:c[Jo.NationalityRaw],[Jo.DocumentNumber]:c[Jo.DocumentNumber],[Jo.DateOfExpiry]:h,[Jo.IssuingState]:c[Jo.IssuingState],[Jo.IssuingStateRaw]:c[Jo.IssuingStateRaw],[Jo.DocumentType]:Xo(a),[Jo.MRZText]:t}}const nl={[No.TD1]:{width:85.6,height:53.98},[No.TD2]:{width:105,height:74},[No.Passport]:{width:125,height:88}};class rl{showScannerLoadingOverlay(t){const e=Yo(this.config.container);this.loadingScreen=Zo(e,{message:t}),e.style.display="block",e.style.position="relative"}hideScannerLoadingOverlay(t=!1){this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,t&&(Yo(this.config.container).style.display="none"))}constructor(t,e){this.resources=t,this.config=e,this.isSoundFeedbackOn=!1,this.scanModeManager={[No.Passport]:!0,[No.TD1]:!0,[No.TD2]:!0},this.currentScanMode=ko.All,this.resizeTimer=null,this.capturedResultItems=[],this.originalImageData=null,this.initialized=!1,this.initializedDCE=!1,this.DCE_ELEMENTS={selectCameraBtn:null,uploadImageBtn:null,soundFeedbackBtn:null,closeScannerBtn:null,scanModeSelectContainer:null,passportModeOption:null,td1ModeOption:null,td2ModeOption:null,toast:null},this.loadingScreen=null,this.handleResize=()=>{this.toggleScanGuide(!1),this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((()=>{this.toggleScanGuide(!0)}),500)},this.firstFrame=!0}async initialize(){if(!this.initialized){this.initializeScanModeManager(),this.currentScanMode=this.getScanMode(),Ho("dynamsoft-mrz-loading-screen-style",Ko);try{const{cameraView:t,cameraEnhancer:e,cvRouter:i}=this.resources;if(t.setScanRegionMaskStyle({strokeStyle:"transparent",fillStyle:"transparent",lineWidth:0}),t.setVideoFit("cover"),i.setInput(e),!0===this.config.enableMultiFrameCrossFilter){const t=new Ao;t.enableResultCrossVerification(nt.CRIT_TEXT_LINE,!0),await i.addResultFilter(t)}const n=new Oe;n.onCapturedResultReceived=t=>this.handleMRZResult(t),await i.addResultReceiver(n),this.toggleSoundFeedback(!1),!1===this.config.showScanGuide&&this.toggleScanGuide(!1),this.initialized=!0}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e),this.closeCamera();const i={status:{code:Wo.RS_FAILED,message:"Dynamsoft MRZ Scanner initialize error"}};this.currentScanResolver(i)}}}initializeElements(){var t;const e=Yo(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))throw new Error("Shadow root not found");if(this.DCE_ELEMENTS={selectCameraBtn:i.shadowRoot.querySelector(".dce-mn-select-camera-icon"),uploadImageBtn:i.shadowRoot.querySelector(".dce-mn-upload-image-icon"),soundFeedbackBtn:i.shadowRoot.querySelector(".dce-mn-sound-feedback"),closeScannerBtn:i.shadowRoot.querySelector(".dce-mn-close"),scanModeSelectContainer:i.shadowRoot.querySelector(".dce-mn-scan-mode-select"),passportModeOption:i.shadowRoot.querySelector(".scan-mode-option-passport"),td1ModeOption:i.shadowRoot.querySelector(".scan-mode-option-td1"),td2ModeOption:i.shadowRoot.querySelector(".scan-mode-option-td2"),toast:i.shadowRoot.querySelector(".dce-mn-toast")},this.setupScanModeSelector(),this.assignDCEClickEvents(),this.DCE_ELEMENTS.toast.style.display="none",!1===this.config.showUploadImage&&(this.DCE_ELEMENTS.uploadImageBtn.style.visibility="hidden"),!1===this.config.showSoundToggle&&(this.DCE_ELEMENTS.soundFeedbackBtn.style.visibility="hidden"),!1===(null===(t=this.config)||void 0===t?void 0:t.showPoweredByDynamsoft)){i.shadowRoot.querySelector(".dce-mn-msg-poweredby").style.display="none"}this.initializedDCE=!0}setupScanModeSelector(){if(!1!==this.config.showFormatSelector)switch(this.currentScanMode){case ko.PassportAndTD1:this.DCE_ELEMENTS.td2ModeOption.style.display="none";break;case ko.PassportAndTD2:this.DCE_ELEMENTS.td1ModeOption.style.display="none";break;case ko.TD1AndTD2:this.DCE_ELEMENTS.passportModeOption.style.display="none";break;case ko.All:break;default:this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}else this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}assignDCEClickEvents(){if(!Object.values(this.DCE_ELEMENTS).every(Boolean))throw new Error("Camera control elements not found");this.closeCamera=this.closeCamera.bind(this),this.DCE_ELEMENTS.uploadImageBtn.onclick=()=>this.uploadFile(),this.DCE_ELEMENTS.soundFeedbackBtn.onclick=()=>this.toggleSoundFeedback(),this.DCE_ELEMENTS.closeScannerBtn.onclick=()=>this.handleCloseBtn(),this.DCE_ELEMENTS.selectCameraBtn.onclick=t=>{t.stopPropagation(),this.toggleSelectCameraBox()},this.DCE_ELEMENTS.passportModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.passportModeOption.style.display&&await this.toggleScanDocType(No.Passport)},this.DCE_ELEMENTS.td1ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td1ModeOption.style.display&&await this.toggleScanDocType(No.TD1)},this.DCE_ELEMENTS.td2ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td2ModeOption.style.display&&await this.toggleScanDocType(No.TD2)}}handleCloseBtn(){this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:Wo.RS_CANCELLED,message:"Cancelled"}})}attachOptionClickListeners(){const t=Yo(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings");[...e.shadowRoot.querySelectorAll(".dce-mn-camera-option"),...e.shadowRoot.querySelectorAll(".dce-mn-resolution-option")].forEach((t=>{t.addEventListener("click",(async e=>{const n=t.getAttribute("data-davice-id"),r=t.getAttribute("data-height"),s=t.getAttribute("data-width");n?this.resources.cameraEnhancer.selectCamera(n).then((()=>{this.toggleScanGuide()})):r&&s&&this.resources.cameraEnhancer.setResolution({width:parseInt(s),height:parseInt(r)}).then((()=>{this.toggleScanGuide()})),"none"!==i.style.display&&this.toggleSelectCameraBox()}))}))}highlightCameraAndResolutionOption(){const t=Yo(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings"),n=i.querySelectorAll(".dce-mn-camera-option"),r=i.querySelectorAll(".dce-mn-resolution-option"),s=this.resources.cameraEnhancer.getSelectedCamera(),a=this.resources.cameraEnhancer.getResolution();n.forEach((t=>{const e=t;e.getAttribute("data-davice-id")===(null==s?void 0:s.deviceId)?e.style.border="2px solid #fe814a":e.style.border="none"}));const o={"480p":"480","720p":"720","1080p":"1080","2k":"1440","4k":"2160"},l=function(t){const e=t.width*t.height,i=t.width/t.height;let n="480p",r=Number.MAX_VALUE;for(const[t,s]of Object.entries(qo)){const a=s.width*s.height,o=s.width/s.height,l=.7*Math.abs(a-e)+Math.abs(o-i)*a*.3;l{const e=t,i=e.getAttribute("data-height");e.style.border=i===o[l]?"2px solid #fe814a":"none"}))}toggleSelectCameraBox(){const t=Yo(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-resolution-box");this.highlightCameraAndResolutionOption(),this.attachOptionClickListeners(),i.click()}async relaunch(){}async uploadFile(){var t,e,i,n,r,s;const{cvRouter:a}=this.resources,o=document.createElement("input");o.type="file",o.accept=null!==(t=this.config.uploadAcceptedTypes)&&void 0!==t?t:"image/*",o.style.display="none",document.body.appendChild(o);try{this.showScannerLoadingOverlay("Processing file..."),await this.closeCamera(!1);const t=await new Promise(((t,e)=>{o.onchange=i=>{var n;const r=null===(n=i.target.files)||void 0===n?void 0:n[0];r?t(r):e(new Error("No file selected"))},o.addEventListener("cancel",(async()=>{this.hideScannerLoadingOverlay(!1),this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()})),o.click()}));if(!t)return;let l;if(this.config.uploadFileConverter&&!t.type.startsWith("image/"))try{l=await this.config.uploadFileConverter(t)}catch(t){throw new Error(`Error converting file: ${t.message}`)}else{if(!t.type.startsWith("image/"))throw new Error("Unsupported file type. Please provide a converter function for this file type.");l=t}const h=this.config.utilizedTemplateNames[this.currentScanMode];if(!1!==this.config.showScanGuide){const t=await a.getSimplifiedSettings(h);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await a.updateSettings(h,t)}const c=await a.capture(l,h);this.capturedResultItems=c.items;const d=this.capturedResultItems.filter((t=>t.type===nt.CRIT_ORIGINAL_IMAGE));if(0===d.length)throw new Error("No image data found in the captured result");const u=d[0].imageData;u.toCanvas=()=>L(u),u.toBlob=async()=>await P("image/png",u),this.originalImageData=u;const f=null===(e=null==c?void 0:c.parsedResult)||void 0===e?void 0:e.parsedResultItems;let g={};if(null==f?void 0:f.length){const t=(null===(n=null===(i=f[0])||void 0===i?void 0:i.referencedItem)||void 0===n?void 0:n.text)||"";g=il(t,f[0])}const m={status:{code:Wo.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:g,imageData:!0,_imageData:this.originalImageData};null===(s=(r=this.resources).onResultUpdated)||void 0===s||s.call(r,m),this.currentScanResolver(m)}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e),this.closeCamera();const i={status:{code:Wo.RS_FAILED,message:`Error processing file: ${e}`}};this.currentScanResolver(i)}finally{this.hideScannerLoadingOverlay(!0),document.body.removeChild(o)}}toggleSoundFeedback(t){this.isSoundFeedbackOn=void 0!==t?t:!this.isSoundFeedbackOn;const e=Yo(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))return;const n=i.shadowRoot.querySelector(".dce-mn-sound-feedback"),r=n.querySelector(".dce-mn-sound-feedback-on");n.querySelector(".dce-mn-sound-feedback-off").style.display=this.isSoundFeedbackOn?"none":"block",r.style.display=this.isSoundFeedbackOn?"block":"none"}calculateScanRegion(t){const{cameraEnhancer:e,cameraView:i}=this.resources;if(!e||!e.isOpen())return;const n=nl[t].width/nl[t].height;let r;const s=i.getVisibleRegionOfVideo({inPixels:!0}),{width:a,height:o}=s;if(s){if(s.width>s.height){const t=.5*o*n,e=Math.round(t/a*100),i=(100-e)/2;r={left:i,right:i+e,top:25,bottom:75,isMeasuredInPercentage:!0}}else{const t=.9*a/n,e=Math.round(t/o*100),i=(100-e)/2;r={left:5,right:95,top:i,bottom:i+e,isMeasuredInPercentage:!0}}null==i||i.setScanRegionMaskVisible(!0),e.setScanRegion(r)}}toggleScanGuide(t){const e=Yo(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))return;const n=i.shadowRoot.querySelector(".dce-scanguide-passport"),r=i.shadowRoot.querySelector(".dce-scanguide-td1"),s=i.shadowRoot.querySelector(".dce-scanguide-td2");if(!1===t||!1===this.config.showScanGuide)return n.style.display="none",r.style.display="none",void(s.style.display="none");switch(this.currentScanMode){case ko.All:case ko.Passport:case ko.PassportAndTD1:case ko.PassportAndTD2:n.style.display="block",r.style.display="none",s.style.display="none",this.calculateScanRegion(No.Passport);break;case ko.TD1:case ko.TD1AndTD2:n.style.display="none",r.style.display="block",s.style.display="none",this.calculateScanRegion(No.TD1);break;case ko.TD2:n.style.display="none",r.style.display="none",s.style.display="block",this.calculateScanRegion(No.TD2)}}async openCamera(){try{const{cameraEnhancer:t,cameraView:e}=this.resources,i=Yo(this.config.container);if(i.style.display="block",t.isOpen())t.isPaused()&&await t.resume();else{const n=e.getUIElement();n.parentElement||i.append(n),await t.open()}await t.setResolution({width:2560,height:1440}),!this.initializedDCE&&t.isOpen()&&await this.initializeElements(),window.addEventListener("resize",this.handleResize);const n=i.children[i.children.length-1];if(!(null==n?void 0:n.shadowRoot))throw new Error("Shadow root not found");n.shadowRoot.querySelector(".dce-mn-torch-off").style.display="none",n.shadowRoot.querySelector(".dce-mn-torch-on").style.display="none"}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e),this.closeCamera();const i={status:{code:Wo.RS_FAILED,message:"MRZ Scanner Open Camera Error"}};this.currentScanResolver(i)}}async closeCamera(t=!0){try{window.removeEventListener("resize",this.handleResize),this.resizeTimer&&(window.clearTimeout(this.resizeTimer),this.resizeTimer=null);const{cameraEnhancer:e,cameraView:i}=this.resources,n=Yo(this.config.container);n.style.display=t?"none":"block",(null==i?void 0:i.getUIElement().parentElement)&&n.removeChild(i.getUIElement()),e.close(),this.stopCapturing()}catch(t){let e=(null==t?void 0:t.message)||t;console.error(`Close Camera error: ${e}`)}}pauseCamera(){const{cameraEnhancer:t}=this.resources;t.pause()}stopCapturing(){const{cameraView:t,cvRouter:e}=this.resources;e.stopCapturing(),t.clearAllInnerDrawingItems()}async handleMRZResult(t){var e,i,n;if(this.firstFrame)this.firstFrame=!1;else if(!(t.items.length<=1)){this.capturedResultItems=t.items;try{const{onResultUpdated:r}=this.resources,s=t.items.filter((t=>t.type===nt.CRIT_ORIGINAL_IMAGE))[0].imageData;s.toCanvas=()=>L(s),s.toBlob=async()=>await P("image/png",s),this.originalImageData=s;const a=null===(e=null==t?void 0:t.parsedResult)||void 0===e?void 0:e.parsedResultItems;if(null==a?void 0:a.length){this.isSoundFeedbackOn&&Ms.beep();const t=(null===(n=null===(i=a[0])||void 0===i?void 0:i.referencedItem)||void 0===n?void 0:n.text)||"",e=il(t,a[0]);this.closeCamera();const s={status:{code:Wo.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:e,imageData:!0,_imageData:this.originalImageData};null==r||r(s),this.currentScanResolver(s)}}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e),this.closeCamera();const i={status:{code:Wo.RS_FAILED,message:"Error capturing image"}};this.currentScanResolver(i)}}}initializeScanModeManager(){const{mrzFormatType:t}=this.config;if(this.scanModeManager={[No.Passport]:!0,[No.TD1]:!0,[No.TD2]:!0},!t||Array.isArray(t)&&0===t.length)return;Object.keys(this.scanModeManager).forEach((t=>{this.scanModeManager[t]=!1}));(Array.isArray(t)?t:[t]).forEach((t=>{this.scanModeManager[t]=!0}))}getScanMode(){const t=Object.entries(this.scanModeManager).filter((([t,e])=>e)).map((([t])=>t)).sort().join(",");return{[No.Passport]:ko.Passport,[No.TD1]:ko.TD1,[No.TD2]:ko.TD2,[`${No.Passport},${No.TD1}`]:ko.PassportAndTD1,[`${No.Passport},${No.TD2}`]:ko.PassportAndTD2,[`${No.TD1},${No.TD2}`]:ko.TD1AndTD2,[`${No.Passport},${No.TD1},${No.TD2}`]:ko.All,"":ko.All}[t]}DCEShowToast(t,e=3e3){this.DCE_ELEMENTS.toast&&(this.DCE_ELEMENTS.toast.textContent=t,this.DCE_ELEMENTS.toast.style.display="",setTimeout((()=>{this.DCE_ELEMENTS.toast.style.display="none"}),e))}async startCapturing(){const{cvRouter:t,cameraEnhancer:e}=this.resources,i=this.config.utilizedTemplateNames[this.currentScanMode];try{if(!1!==this.config.showScanGuide){const e=await t.getSimplifiedSettings(i);e.roiMeasuredInPercentage=!0,e.roi.points=[{x:0,y:50},{x:100,y:50},{x:100,y:100},{x:0,y:100}],await t.updateSettings(i,e)}this.firstFrame=!0,await t.startCapturing(i),e.setPixelFormat(o.IPF_ABGR_8888)}catch(t){let e=(null==t?void 0:t.message)||t;console.error("Failed to start capturing:",e),this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:Wo.RS_FAILED,message:"Failed to start capturing"}})}}async toggleScanDocType(t){try{if(this.scanModeManager[t]&&0===Object.entries(this.scanModeManager).filter((([e,i])=>i&&e!==t)).length)return console.warn("MRZ Scanner - At least one mode must be enabled"),void this.DCEShowToast("At least one mode must be enabled");this.scanModeManager[t]=!this.scanModeManager[t],this.currentScanMode=this.getScanMode(),this.stopCapturing(),this.toggleScanGuide(),await this.startCapturing(),this.DCE_ELEMENTS.td1ModeOption.classList.toggle("selected",this.scanModeManager[No.TD1]),this.DCE_ELEMENTS.td2ModeOption.classList.toggle("selected",this.scanModeManager[No.TD2]),this.DCE_ELEMENTS.passportModeOption.classList.toggle("selected",this.scanModeManager[No.Passport])}catch(t){let e=(null==t?void 0:t.message)||t;console.error("MRZ Scanner switch scan mode error: ",e),this.closeCamera();const i={status:{code:Wo.RS_FAILED,message:"MRZ Scanner switch scan mode error"}};this.currentScanResolver(i)}}async launch(){try{await this.initialize();const{cvRouter:t,cameraEnhancer:e}=this.resources;return new Promise((async t=>{this.currentScanResolver=t,this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),!this.initializedDCE&&e.isOpen()&&await this.initializeElements(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()}))}catch(t){let e=(null==t?void 0:t.message)||t;console.error("MRZ Scanner launch error: ",e),this.closeCamera();const i={status:{code:Wo.RS_FAILED,message:"MRZ Scanner launch error"}};this.currentScanResolver(i)}}}const sl={cancel:'\n\n \n \n \n \n \n \n \n \n \n \n ',rescan:'\n\n\n \n\n\n\n\n\n\n\n',complete:'\n\n\n\n \n\n\n\n\n\n\n\n',failed:'\n \n \n \n\n',info:'\n\n \n \n \n\n'};class al{constructor(t,e,i){this.resources=t,this.config=e,this.scannerView=i,this.editedFields={}}async launch(){try{return Yo(this.config.container).textContent="",await this.initialize(),Yo(this.config.container).style.display="flex",new Promise((t=>{this.currentScanResultViewResolver=t}))}catch(t){let e=(null==t?void 0:t.message)||t;throw console.error(e),e}}async handleRescan(){var t;try{if(!this.scannerView)return void console.error("Scanner View not initialized");this.hideView();const e=await this.scannerView.launch();if((null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.code)===Wo.RS_FAILED)return void(this.currentScanResultViewResolver&&this.currentScanResultViewResolver(e));this.resources.onResultUpdated&&((null==e?void 0:e.status.code)===Wo.RS_CANCELLED?this.resources.onResultUpdated(this.resources.result):(null==e?void 0:e.status.code)===Wo.RS_SUCCESS&&this.resources.onResultUpdated(e)),this.dispose(!0),await this.initialize(),Yo(this.config.container).style.display="flex"}catch(t){throw console.error("Error in rescan handler:",t),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:Wo.RS_FAILED,message:(null==t?void 0:t.message)||t}}),t}}async handleCancel(){var t;try{(null===(t=this.config)||void 0===t?void 0:t.onCancel)&&await this.config.onCancel(this.resources.result),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:Wo.RS_CANCELLED,message:"Upload file cancelled"}}),this.hideView(),this.dispose()}catch(t){throw console.error("Error in cancel handler:",t),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:Wo.RS_FAILED,message:(null==t?void 0:t.message)||t}}),t}}async handleDone(){var t,e;try{(null===(t=this.resources.result)||void 0===t?void 0:t.data)&&!zo(this.editedFields)&&(this.resources.result.data=Object.assign(Object.assign({},this.resources.result.data),this.editedFields),this.resources.onResultUpdated&&this.resources.onResultUpdated(this.resources.result)),(null===(e=this.config)||void 0===e?void 0:e.onDone)&&await this.config.onDone(this.resources.result),this.currentScanResultViewResolver&&this.resources.result&&this.currentScanResultViewResolver(this.resources.result),this.hideView(),this.dispose()}catch(t){throw console.error("Error in done handler:",t),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:Wo.RS_FAILED,message:(null==t?void 0:t.message)||t}}),t}}createControls(){var t,e,i,n,r,s,a,o,l,h,c,d;const{toolbarButtonsConfig:u}=this.config;return function(t){Ho("dynamsoft-mrz-controls-style","\n .dynamsoft-mrz-controls {\n display: flex;\n height: 6rem;\n background-color: #323234;\n align-items: center;\n font-size: 12px;\n font-family: Verdana;\n color: white;\n width: 100%;\n }\n\n .dynamsoft-mrz-control-btn {\n background-color: #323234;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n gap: 0.5rem;\n text-align: center;\n user-select: none;\n }\n\n .dynamsoft-mrz-control-btn.hide {\n display: none;\n }\n\n .dynamsoft-mrz-control-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n cursor: default;\n }\n\n .dynamsoft-mrz-control-icon-wrapper {\n flex: 0.75;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n min-height: 40px;\n }\n\n .dynamsoft-mrz-control-icon img,\n .dynamsoft-mrz-control-icon svg {\n width: 32px;\n height: 32px;\n fill: #fe8e14;\n }\n\n .dynamsoft-mrz-control-text {\n flex: 0.5;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-bottom: 0.5rem;\n }\n\n \n @media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-controls {\n flex-direction: column;\n height: 100%;\n width: 5rem;\n }\n\n .dynamsoft-mrz-control-text {\n padding: 0 0.5rem 0.5rem;\n }\n }\n");const e=document.createElement("div");return e.className="dynamsoft-mrz-controls",t.forEach((t=>{const i=document.createElement("div");i.className=`dynamsoft-mrz-control-btn ${null==t?void 0:t.className}`;const n=document.createElement("div");if(n.className="dynamsoft-mrz-control-icon-wrapper",(r=t.icon).trim().startsWith(""))n.innerHTML=t.icon;else{const e=document.createElement("img");e.src=t.icon,e.alt=t.label,e.width=24,e.height=24,n.appendChild(e)}var r;const s=document.createElement("div");s.className="dynamsoft-mrz-control-text",s.textContent=t.label,t.isDisabled&&i.classList.add("disabled"),t.isHidden&&i.classList.add("hide"),i.appendChild(n),i.appendChild(s),t.onClick&&!t.isDisabled&&i.addEventListener("click",t.onClick),e.appendChild(i)})),e}([this.config._isFileMode?{id:"dynamsoft-mrz-scanResult-cancel",icon:(null===(t=null==u?void 0:u.cancel)||void 0===t?void 0:t.icon)||sl.cancel,label:(null===(e=null==u?void 0:u.cancel)||void 0===e?void 0:e.label)||"Cancel",onClick:()=>this.handleCancel(),className:`${(null===(i=null==u?void 0:u.cancel)||void 0===i?void 0:i.className)||""}`,isHidden:(null===(n=null==u?void 0:u.cancel)||void 0===n?void 0:n.isHidden)||!1}:{id:"dynamsoft-mrz-scanResult-rescan",icon:(null===(r=null==u?void 0:u.rescan)||void 0===r?void 0:r.icon)||sl.rescan,label:(null===(s=null==u?void 0:u.rescan)||void 0===s?void 0:s.label)||"Re-scan",onClick:()=>this.handleRescan(),className:`${(null===(a=null==u?void 0:u.rescan)||void 0===a?void 0:a.className)||""}`,isHidden:(null===(o=null==u?void 0:u.rescan)||void 0===o?void 0:o.isHidden)||!1,isDisabled:!this.scannerView},{id:"dynamsoft-mrz-scanResult-done",icon:(null===(l=null==u?void 0:u.done)||void 0===l?void 0:l.icon)||sl.complete,label:(null===(h=null==u?void 0:u.done)||void 0===h?void 0:h.label)||"Done",className:`${(null===(c=null==u?void 0:u.done)||void 0===c?void 0:c.className)||""}`,isHidden:(null===(d=null==u?void 0:u.done)||void 0===d?void 0:d.isHidden)||!1,onClick:()=>this.handleDone()}])}handleFieldEdit(t,e){if(t===Jo.DateOfBirth||t===Jo.DateOfExpiry)try{const[i,n,r]=e.split(/[\/\-\.]/);r&&n&&i&&(this.editedFields[t]={day:parseInt(r,10),month:parseInt(n,10),year:parseInt(i,10)})}catch(t){console.error("Error parsing date",t)}else this.editedFields[t]=e}createMRZDataDisplay(){var t,e,i,n;const r=(null===(t=this.resources.result)||void 0===t?void 0:t.data)||{},s=!!this.config.allowResultEditing,a=r.invalidFields||[],o=[Jo.InvalidFields,Jo.IssuingStateRaw,Jo.NationalityRaw];!1===(null===(e=this.config)||void 0===e?void 0:e.showMRZText)&&o.push(Jo.MRZText);const l=document.createElement("div");if(l.className="dynamsoft-mrz-data-container",zo(r)){const t=document.createElement("div");return t.className="dynamsoft-mrz-data-row empty",t.innerText=null!==(n=null===(i=this.config)||void 0===i?void 0:i.emptyResultMessage)&&void 0!==n?n:"The necessary information couldn't be detected. Please try again.",l.appendChild(t),l}if(a.length>0){const t=document.createElement("div");t.className="dynamsoft-mrz-error-notification",t.innerHTML=`\n
${sl.failed}
\n
\n ${s?"Some fields require correction. Please review highlighted fields.":"Some fields contain invalid information. Please rescan the document."}\n
\n `,l.appendChild(t)}else if(0===a.length&&s){const t=document.createElement("div");t.className="dynamsoft-mrz-info-notification",t.innerHTML=`\n
${sl.info}
\n
\n Please review all fields to ensure the information is correct.\n
\n `,l.appendChild(t)}return Object.entries(r).forEach((([t,e])=>{if(o.includes(t)||!e)return;const i=document.createElement("div");i.className="dynamsoft-mrz-data-row";const n=a.includes(t);n&&i.classList.add("invalid-field");const r=[Jo.MRZText,Jo.DocumentType,Jo.IssuingStateRaw,Jo.NationalityRaw],h=document.createElement("span");if(h.className="dynamsoft-mrz-data-label",h.innerText=$o[t]||t,n){const t=document.createElement("span");if(t.className="dynamsoft-mrz-error-icon",t.innerHTML=sl.failed,h.appendChild(t),s){const t=document.createElement("span");t.className="dynamsoft-mrz-error-hint",t.textContent="Please correct this field",h.appendChild(t)}}const c=document.createElement("div");if(c.className="dynamsoft-mrz-data-value",s&&!r.includes(t)){const r=document.createElement("input");r.className="dynamsoft-mrz-data-input",n&&r.classList.add("invalid"),t===Jo.DateOfBirth||t===Jo.DateOfExpiry?(r.value=tl(e),r.setAttribute("placeholder","YYYY-MM-DD")):r.value=e,r.addEventListener("input",(e=>{if(this.handleFieldEdit(t,e.target.value),n){r.classList.remove("invalid"),i.classList.remove("invalid-field"),this.editedFields.invalidFields||(this.editedFields.invalidFields=[...a]);const e=this.editedFields.invalidFields.indexOf(t);e>-1&&this.editedFields.invalidFields.splice(e,1)}})),c.appendChild(r)}else t===Jo.MRZText?(c.classList.add("code"),c.innerText=e):t===Jo.DateOfBirth||t===Jo.DateOfExpiry?c.innerText=tl(e):c.innerText=e,n&&c.classList.add("invalid-value");i.appendChild(h),i.appendChild(c),l.appendChild(i)})),l}async initialize(){try{if(!this.resources.result)throw Error("Captured image is missing. Please capture an image first!");if(!this.config.container)throw new Error("Please create a Scan Result View Container element");Ho("dynamsoft-mrz-result-view-style",ol);const t=document.createElement("div");if(t.className="dynamsoft-mrz-result-view-container",!1!==this.config.showOriginalImage){const e=this.resources.result.originalImageResult,i=document.createElement("div");let n;i.className="dynamsoft-mrz-result-view-image-container",(null==e?void 0:e.toCanvas)&&(n=null==e?void 0:e.toCanvas()),Object.assign(n.style,{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}),i.appendChild(n),t.appendChild(i)}const e=this.createMRZDataDisplay();t.appendChild(e);const i=this.createControls();t.appendChild(i),Yo(this.config.container).appendChild(t)}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e)}}hideView(){Yo(this.config.container).style.display="none"}dispose(t=!1){Yo(this.config.container).textContent="",t||(this.currentScanResultViewResolver=void 0)}}const ol="\n .dynamsoft-mrz-result-view-container {\n display: flex;\n width: 100%;\n height: 100%;\n background-color:#575757;\n font-size: 12px;\n flex-direction: column;\n align-items: center;\n }\n\n .dynamsoft-mrz-result-view-image-container {\n width: 100%;\n height: 200px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #323234;\n }\n\n \n.dynamsoft-mrz-data-container {\n font-size: 16px;\n font-family: Verdana;\n color: white;\n overflow: auto;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 1rem 0;\n}\n\n.dynamsoft-mrz-data-row {\n padding: 0.5rem 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n transition: background-color 0.3s ease;\n}\n\n.dynamsoft-mrz-data-row.invalid-field {\n background-color: rgba(231, 76, 60, 0.1);\n border-left: 3px solid #e74c3c;\n padding-left: calc(2rem - 3px);\n}\n\n.dynamsoft-mrz-data-label {\n color: #aaa;\n display: flex;\n gap: 0.5rem;\n align-items: end;\n flex-wrap: wrap;\n}\n\n.dynamsoft-mrz-error-notification,\n.dynamsoft-mrz-info-notification {\n color: white;\n padding: 1rem;\n margin: 0.5rem 2rem;\n border-radius: 4px;\n display: flex;\n align-items: center;\n gap: 1rem;\n text-align: start;\n}\n\n.dynamsoft-mrz-error-notification {\n background-color: rgba(231, 76, 60, 0.2);\n}\n\n.dynamsoft-mrz-info-notification {\n background-color: #fe8e14;\n}\n\n.dynamsoft-mrz-edit-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #aaa;\n}\n\n.dynamsoft-mrz-error-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-info-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.dynamsoft-mrz-info-message,\n.dynamsoft-mrz-error-message {\n flex: 1;\n}\n\n.dynamsoft-mrz-error-hint {\n font-size: 0.8rem;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-value {\n word-wrap: break-word;\n text-align: start;\n}\n\n.dynamsoft-mrz-data-value.code {\n font-family: monospace;\n}\n\n.dynamsoft-mrz-data-value.invalid-value {\n color: #e74c3c;\n text-decoration: wavy underline #e74c3c;\n text-decoration-skip-ink: none;\n}\n\n.dynamsoft-mrz-data-input {\n width: 100%;\n padding: 5px;\n background-color: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.3);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n transition: all 0.3s ease;\n}\n\n.dynamsoft-mrz-data-input.invalid {\n background-color: rgba(231, 76, 60, 0.1);\n border-color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-input:focus {\n background-color: rgba(255, 255, 255, 0.2);\n border-color: #fe8e14;\n outline: none;\n}\n\n@media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-result-view-container {\n flex-direction: row;\n }\n\n .dynamsoft-mrz-result-view-image-container{\n flex: 1;\n height: 100%;\n }\n\n .dynamsoft-mrz-data-container{\n flex: 1;\n }\n\n .dynamsoft-mrz-data-row:first-of-type {\n padding-top: 2rem;\n }\n\n .dynamsoft-mrz-data-row:last-of-type {\n padding-bottom: 2rem;\n }\n\n .dynamsoft-mrz-data-row.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding-top: 0;\n padding-bottom: 0;\n }\n}\n",ll={rootDirectory:"https://cdn.jsdelivr.net/npm/"};class hl{showLoadingOverlay(t){var e,i;const n=Yo(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||Yo(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container);this.loadingScreen=Zo(n,{message:t}),n.style.display="block",n.style.position="relative"}hideLoadingOverlay(t=!1){var e,i,n;const r=Yo(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||Yo(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container);this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,r.style.display="none",t&&(null===(n=this.config)||void 0===n?void 0:n.container)&&(Yo(this.config.container).style.display="none"))}constructor(t){this.config=t,this.resources={},this.isInitialized=!1,this.isCapturing=!1,this.loadingScreen=null,this.isDynamsoftResourcesLoaded=!1,this.isFileMode=!1,this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources()}async initialize(){if(this.isInitialized)return{resources:this.resources,components:{scannerView:this.scannerView,resultView:this.resultView}};try{if(!this.initializeMRZScannerConfig())return console.error("Failed to initialize mrz scanner config"),{resources:this.resources,components:{}};Ho("dynamsoft-mrz-loading-screen-style",Ko),this.showLoadingOverlay("Loading..."),await this.initializeDCVResources(),this.resources.onResultUpdated=t=>{this.resources.result=t};const t={};return this.config.scannerViewConfig&&!this.isFileMode&&(this.scannerView=new rl(this.resources,this.config.scannerViewConfig),t.scannerView=this.scannerView,await this.scannerView.initialize()),this.config.resultViewConfig&&(this.resultView=new al(this.resources,this.config.resultViewConfig,this.scannerView),t.resultView=this.resultView),this.isInitialized=!0,{resources:this.resources,components:t}}catch(t){this.isInitialized=!1;const e=`Initialization Failed: ${(null==t?void 0:t.message)||t}`;throw console.error(e),new Error(e)}finally{this.hideLoadingOverlay(!0)}}initializeDynamsoftResources(){var t;Ft.engineResourcePaths=zo(null===(t=this.config)||void 0===t?void 0:t.engineResourcePaths)?ll:this.config.engineResourcePaths,Ft.loadWasm(),La.loadSpec("MRTD_TD3_PASSPORT"),La.loadSpec("MRTD_TD3_VISA"),La.loadSpec("MRTD_TD1_ID"),La.loadSpec("MRTD_TD2_ID"),La.loadSpec("MRTD_TD2_VISA"),this.isDynamsoftResourcesLoaded=!0}async initializeDCVResources(){var t,e;try{this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources(),$e._onAuthMessage=t=>t.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=mrz&deploymenttype=web)"),await $e.initLicense((null===(t=this.config)||void 0===t?void 0:t.license)||"",{executeNow:!0}),this.isFileMode||(this.resources.cameraView=await Hr.createInstance(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.cameraEnhancerUIPath),this.resources.cameraEnhancer=await Bs.createInstance(this.resources.cameraView)),this.resources.cvRouter=await Re.createInstance(),await this.resources.cvRouter.initSettings(this.config.templateFilePath)}catch(t){let e=(null==t?void 0:t.message)||t;const i=(null==e?void 0:e.toLowerCase().includes("license"))?"The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.":`Resource Initialization Failed: ${e}`;throw console.error(i),new Error(i)}}shouldCreateDefaultContainer(){var t,e;const i=!this.config.container,n=!((null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container));return i&&n}createDefaultMRZScannerContainer(){const t=document.createElement("div");return t.className="mrz-scanner-main-container",Object.assign(t.style,{height:"100dvh",width:"100%",position:"absolute",left:"0",top:"0",zIndex:"999"}),document.body.append(t),t}checkForTemporaryLicense(t){return!(null==t?void 0:t.length)||(null==t?void 0:t.startsWith("A"))||(null==t?void 0:t.startsWith("L"))||(null==t?void 0:t.startsWith("P"))||(null==t?void 0:t.startsWith("Y"))?"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9":t}validateViewConfigs(){var t,e,i,n,r,s,a,o;if(!this.config.container){if((null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)&&this.config.showResultView&&!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container)){const t="MRZResultView container is required when showResultView is true";return alert(t),console.error(t),!1}if(!(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.container)&&(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container)&&!this.resources.result){const t="Result is needed to create MRZResultView without a scanner view";return alert(t),console.error(t),!1}}try{if(this.config.container&&!Yo(this.config.container)){const t="Invalid main container reference";return alert(t),console.error(t),!1}if((null===(r=this.config.scannerViewConfig)||void 0===r?void 0:r.container)&&!Yo(null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.container)){const t="Invalid scanner view container reference";return alert(t),console.error(t),!1}if((null===(a=this.config.resultViewConfig)||void 0===a?void 0:a.container)&&!Yo(null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)){const t="Invalid result view container reference";return alert(t),console.error(t),!1}}catch(t){const e=`Error accessing container references: ${t.message}`;return alert(e),console.error(e),!1}return!0}showResultView(){var t,e;return!1!==this.config.showResultView&&(this.config.container?!(void 0!==this.config.showResultView||!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container)&&!this.config.container)||!!this.config.showResultView:this.config.showResultView&&!!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container))}initializeMRZScannerConfig(){var t,e,i,n,r,s,a;this.config=null!==(t=this.config)&&void 0!==t?t:{};if(!this.validateViewConfigs())return!1;this.shouldCreateDefaultContainer()?this.config.container=this.createDefaultMRZScannerContainer():this.config.container&&(this.config.container=Yo(this.config.container));const o=this.config.container?this.createViewContainers(Yo(this.config.container)):{},l={license:this.checkForTemporaryLicense(this.config.license),utilizedTemplateNames:Object.fromEntries(Object.values(ko).map((t=>{var e;return[t,(null===(e=this.config.utilizedTemplateNames)||void 0===e?void 0:e[t])||Go[t]]}))),templateFilePath:(null===(e=this.config)||void 0===e?void 0:e.templateFilePath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.template.json"},h=Object.assign(Object.assign({},this.config.scannerViewConfig),{container:o[Bo.Scanner]||Yo(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.container)||null,cameraEnhancerUIPath:(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.cameraEnhancerUIPath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.ui.html",templateFilePath:l.templateFilePath,utilizedTemplateNames:l.utilizedTemplateNames,enableMultiFrameCrossFilter:null===(s=null===(r=this.config.scannerViewConfig)||void 0===r?void 0:r.enableMultiFrameCrossFilter)||void 0===s||s,mrzFormatType:this.config.mrzFormatType}),c=this.showResultView()?Object.assign(Object.assign({},this.config.resultViewConfig),{_isFileMode:this.isFileMode,container:o[Bo.Result]||Yo(null===(a=this.config.resultViewConfig)||void 0===a?void 0:a.container)||null}):void 0;return Object.assign(this.config,Object.assign(Object.assign({},l),{scannerViewConfig:h,resultViewConfig:c})),!0}createViewContainers(t){t.textContent="";const e=[Bo.Scanner];return this.showResultView()&&e.push(Bo.Result),e.reduce(((e,i)=>{const n=document.createElement("div");return n.className=`mrz-scanner-${i}-view-container`,Object.assign(n.style,{height:"100%",width:"100%",display:"none",position:"relative"}),t.append(n),e[i]=n,e}),{})}dispose(){var t,e;this.resultView&&(this.resultView.dispose(),this.resultView=null),this.scannerView=null,this.resources.cameraEnhancer&&(this.resources.cameraEnhancer.dispose(),this.resources.cameraEnhancer=null),this.resources.cameraView&&(this.resources.cameraView.dispose(),this.resources.cameraView=null),this.resources.cvRouter&&(this.resources.cvRouter.dispose(),this.resources.cvRouter=null),this.resources.result=null,this.resources.onResultUpdated=null;const i=t=>{const e=Yo(t);e&&(e.style.display="none",e.textContent="")};i(this.config.container),i(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container),i(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container),this.isInitialized=!1}async processUploadedFile(t){var e,i,n,r,s,a;try{this.showLoadingOverlay("Processing File...");const{cvRouter:o}=this.resources,l=null===(e=this.config.utilizedTemplateNames)||void 0===e?void 0:e.all,h=await o.getSimplifiedSettings(l);h.roiMeasuredInPercentage=!0,h.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await o.updateSettings(l,h);const c=await o.capture(t,l),d=c.items,u=d.filter((t=>t.type===nt.CRIT_ORIGINAL_IMAGE))[0].imageData;u.toCanvas=()=>L(u),u.toBlob=async()=>await P("image/png",u);const f=null===(i=null==c?void 0:c.parsedResult)||void 0===i?void 0:i.parsedResultItems;let g={};if(null==f?void 0:f.length){const t=(null===(r=null===(n=f[0])||void 0===n?void 0:n.referencedItem)||void 0===r?void 0:r.text)||"";g=il(t,f[0])}const m={status:{code:Wo.RS_SUCCESS,message:"Success"},originalImageResult:u,data:g,imageData:!0,_imageData:u};null===(a=(s=this.resources).onResultUpdated)||void 0===a||a.call(s,m)}catch(t){return console.error("Failed to process uploaded file:",t),{status:{code:Wo.RS_FAILED,message:`Failed to process image: ${t.message||t}`}}}finally{this.hideLoadingOverlay(!1)}}async launch(t){if(this.isCapturing)throw new Error("Capture session already in progress");try{this.isCapturing=!0,this.isFileMode=!!t;const{components:e}=await this.initialize();if(zo(e))throw new Error("MRZ Scanner initialization failed ");if(this.config.container&&(Yo(this.config.container).style.display="block"),this.isFileMode&&await this.processUploadedFile(t),!e.scannerView&&this.resources.result&&e.resultView)return await e.resultView.launch();if(!e.scannerView&&!this.resources.result&&!this.isFileMode)throw new Error("Scanner view is required when no previous result exists");if(e.scannerView){const t=await e.scannerView.launch();if((null==t?void 0:t.status.code)!==Wo.RS_SUCCESS)return{status:{code:null==t?void 0:t.status.code,message:(null==t?void 0:t.status.message)||"Failed to capture image"}};if(e.resultView)return await e.resultView.launch()}return this.resources.result}catch(t){return alert((null==t?void 0:t.message)||t),console.error((null==t?void 0:t.message)||t),{status:{code:Wo.RS_FAILED,message:(null==t?void 0:t.message)||t}}}finally{this.isCapturing=!1,this.dispose()}}}const cl={MRZScanner:hl,MRZScannerView:rl,MRZResultView:al};export{ea as BarcodeReaderModule,Bs as CameraEnhancer,hi as CameraEnhancerModule,qr as CameraManager,Hr as CameraView,Re as CaptureVisionRouter,ee as CaptureVisionRouterModule,Oe as CapturedResultReceiver,Ra as CodeParser,La as CodeParserModule,Ft as CoreModule,Go as DEFAULT_TEMPLATE_NAMES,Va as DocumentNormalizerModule,Bi as DrawingItem,jr as DrawingStyleManager,cl as DynamsoftMRZScanner,ia as EnumBarcodeFormat,s as EnumBufferOverflowProtectionMode,nt as EnumCapturedResultItemType,a as EnumColourChannelUsageType,rt as EnumCornerType,dt as EnumCrossVerificationStatus,aa as EnumDeblurMode,wi as EnumDrawingItemMediaType,Ci as EnumDrawingItemState,Ei as EnumEnhancedFeatures,st as EnumErrorCode,na as EnumExtendedBarcodeResultType,Po as EnumFilterType,at as EnumGrayscaleEnhancementMode,ot as EnumGrayscaleTransformationMode,pt as EnumImageCaptureDistanceMode,Ua as EnumImageColourMode,mt as EnumImageFileFormat,o as EnumImagePixelFormat,ie as EnumImageSourceState,lt as EnumImageTagType,ut as EnumIntermediateResultUnitType,sa as EnumLocalizationMode,Jo as EnumMRZData,No as EnumMRZDocumentType,ko as EnumMRZScanMode,Bo as EnumMRZScannerViews,va as EnumMappingStatus,_t as EnumModuleName,ht as EnumPDFReadingMode,De as EnumPresetTemplate,ra as EnumQRCodeErrorCorrectionLevel,ct as EnumRasterDataSource,_a as EnumRawTextLineStatus,ft as EnumRegionObjectElementType,Wo as EnumResultStatus,gt as EnumSectionType,vt as EnumTransformMatrixType,ya as EnumValidationStatus,Ms as Feedback,$i as GroupDrawingItem,zr as ImageDataGetter,Vo as ImageDrawer,Hi as ImageDrawingItem,qs as ImageEditorView,jo as ImageIO,Uo as ImageProcessor,$ as ImageSourceAdapter,Ae as IntermediateResultReceiver,ma as LabelRecognizerModule,$e as LicenseManager,ti as LicenseModule,Ki as LineDrawingItem,$o as MRZDataLabel,al as MRZResultView,hl as MRZScanner,rl as MRZScannerView,Ao as MultiFrameResultCrossFilter,Ji as QuadDrawingItem,ji as RectDrawingItem,Xi as TextDrawingItem,qa as UtilityModule,k as _getNorImageData,M as _saveToFile,P as _toBlob,L as _toCanvas,F as _toImage,Rt as bDebug,O as checkIsLink,A as compareVersion,tl as displayMRZDate,Ct as doOrWaitAsyncDependency,Tt as getNextTaskID,D as handleEngineResourcePaths,At as innerVersions,p as isArc,_ as isContour,w as isDSImageData,C as isDSRect,E as isImageTag,S as isLineSegment,m as isObject,y as isOriginalDsImageData,T as isPoint,b as isPolygon,I as isQuad,x as isRect,N as isSimdSupported,yt as mapAsyncDependency,Dt as mapPackageRegister,bt as mapTaskCallBack,It as onLog,B as productNameMap,R as requestResource,Ot as setBDebug,xt as setOnLog,pa as utilsFuncs,wt as waitAsyncDependency,Et as worker,Mt as workerAutoResources}; diff --git a/dist/mrz-scanner.d.ts b/dist/mrz-scanner.d.ts index f4eface..6ad688a 100644 --- a/dist/mrz-scanner.d.ts +++ b/dist/mrz-scanner.d.ts @@ -1,20 +1,6 @@ -import { DSImageData, EngineResourcePaths } from 'dynamsoft-core'; -import * as dynamsoftCore from 'dynamsoft-core'; -export { dynamsoftCore as Core }; -import * as dynamsoftLicense from 'dynamsoft-license'; -export { dynamsoftLicense as License }; -import { CapturedResult, CaptureVisionRouter } from 'dynamsoft-capture-vision-router'; -import * as dynamsoftCaptureVisionRouter from 'dynamsoft-capture-vision-router'; -export { dynamsoftCaptureVisionRouter as CVR }; -import { CameraEnhancer, CameraView } from 'dynamsoft-camera-enhancer'; -import * as dynamsoftCameraEnhancer from 'dynamsoft-camera-enhancer'; -export { dynamsoftCameraEnhancer as DCE }; -import * as dynamsoftCodeParser from 'dynamsoft-code-parser'; -export { dynamsoftCodeParser as DCP }; -import * as dynamsoftLabelRecognizer from 'dynamsoft-label-recognizer'; -export { dynamsoftLabelRecognizer as DLR }; -import * as dynamsoftUtility from 'dynamsoft-utility'; -export { dynamsoftUtility as Utility }; +import { DSImageData, CapturedResult, CaptureVisionRouter, CameraEnhancer, CameraView, EngineResourcePaths } from 'dynamsoft-capture-vision-bundle'; +import * as dynamsoftCaptureVisionBundle from 'dynamsoft-capture-vision-bundle'; +export { dynamsoftCaptureVisionBundle as Dynamsoft }; declare enum EnumMRZScanMode { Passport = "passport", @@ -165,12 +151,14 @@ declare class MRZScannerView { private initializeScanModeManager; private getScanMode; private DCEShowToast; + private firstFrame; private startCapturing; private toggleScanDocType; launch(): Promise; } interface MRZResultViewToolbarButtonsConfig { + cancel?: ToolbarButton; rescan?: ToolbarButtonConfig; done?: ToolbarButtonConfig; } @@ -180,7 +168,10 @@ interface MRZResultViewConfig { showOriginalImage?: boolean; showMRZText?: boolean; allowResultEditing?: boolean; + emptyResultMessage?: string; onDone?: (result: MRZResult) => Promise; + onCancel?: (result: MRZResult) => Promise; + _isFileMode?: boolean; } declare class MRZResultView { private resources; @@ -191,6 +182,7 @@ declare class MRZResultView { constructor(resources: SharedResources, config: MRZResultViewConfig, scannerView: MRZScannerView); launch(): Promise; private handleRescan; + private handleCancel; private handleDone; private createControls; private handleFieldEdit; @@ -226,6 +218,8 @@ declare class MRZScanner { private isInitialized; private isCapturing; private loadingScreen; + private isDynamsoftResourcesLoaded; + protected isFileMode: boolean; private showLoadingOverlay; private hideLoadingOverlay; constructor(config: MRZScannerConfig); @@ -236,6 +230,7 @@ declare class MRZScanner { resultView?: MRZResultView; }; }>; + private initializeDynamsoftResources; private initializeDCVResources; private shouldCreateDefaultContainer; private createDefaultMRZScannerContainer; diff --git a/dist/mrz-scanner.js b/dist/mrz-scanner.js index 24161ca..969c81b 100644 --- a/dist/mrz-scanner.js +++ b/dist/mrz-scanner.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("dynamsoft-core"),require("dynamsoft-license"),require("dynamsoft-capture-vision-router"),require("dynamsoft-camera-enhancer"),require("dynamsoft-code-parser"),require("dynamsoft-label-recognizer"),require("dynamsoft-utility")):"function"==typeof define&&define.amd?define(["exports","dynamsoft-core","dynamsoft-license","dynamsoft-capture-vision-router","dynamsoft-camera-enhancer","dynamsoft-code-parser","dynamsoft-label-recognizer","dynamsoft-utility"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).Dynamsoft=e.Dynamsoft||{},e.Dynamsoft.Core,e.Dynamsoft.License,e.Dynamsoft.CVR,e.Dynamsoft.DCE,e.Dynamsoft.DCP,e.Dynamsoft.DLR,e.Dynamsoft.Utility)}(this,(function(e,n,t,i,a,s,o,r){"use strict";function l(e){var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var c,d,u,m=l(n),h=l(t),g=l(i),p=l(a),f=l(s),y=l(o),R=l(r);e.EnumMRZScanMode=void 0,(c=e.EnumMRZScanMode||(e.EnumMRZScanMode={})).Passport="passport",c.TD1="td1",c.TD2="td2",c.PassportAndTD1="passportAndTd1",c.PassportAndTD2="passportAndTd2",c.TD1AndTD2="td1AndTd2",c.All="all",e.EnumMRZDocumentType=void 0,(d=e.EnumMRZDocumentType||(e.EnumMRZDocumentType={})).Passport="passport",d.TD1="td1",d.TD2="td2",e.EnumMRZScannerViews=void 0,(u=e.EnumMRZScannerViews||(e.EnumMRZScannerViews={})).Scanner="scanner",u.Result="scan-result";const E={[e.EnumMRZScanMode.Passport]:"ReadPassport",[e.EnumMRZScanMode.TD1]:"ReadId-TD1",[e.EnumMRZScanMode.TD2]:"ReadId-TD2",[e.EnumMRZScanMode.PassportAndTD1]:"ReadPassportAndId-TD1",[e.EnumMRZScanMode.PassportAndTD2]:"ReadPassportAndId-TD2",[e.EnumMRZScanMode.TD1AndTD2]:"ReadId",[e.EnumMRZScanMode.All]:"ReadPassportAndId"};var w;function v(e){if("string"==typeof e){const n=document.querySelector(e);if(!n)throw new Error("Element not found");return n}return e instanceof HTMLElement?e:null}e.EnumResultStatus=void 0,(w=e.EnumResultStatus||(e.EnumResultStatus={}))[w.RS_SUCCESS=0]="RS_SUCCESS",w[w.RS_CANCELLED=1]="RS_CANCELLED",w[w.RS_FAILED=2]="RS_FAILED";function M(e,n){if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent=n,document.head.appendChild(t)}}const D=e=>!e||0===Object.keys(e).length;function S(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}const C={"4k":{width:3840,height:2160},"2k":{width:2560,height:1440},"1080p":{width:1920,height:1080},"720p":{width:1280,height:720},"480p":{width:640,height:480}};function T(e,n={}){const{message:t,spinnerSize:i=32}=n,a=document.createElement("div");a.className="dynamsoft-mrz-loading-screen";const s=document.createElement("div");s.className="dynamsoft-mrz-loading";const o=document.createElement("div");o.className="dynamsoft-mrz-loading-content";const r=`\n \n \n \n `;if(o.innerHTML=r,t){const e=document.createElement("div");e.className="dynamsoft-mrz-loading-message",e.textContent=t,o.appendChild(e)}return s.appendChild(o),a.appendChild(s),e.appendChild(a),{element:a,updateMessage:e=>{let n=s.querySelector(".dynamsoft-mrz-loading-message");null!==e?n?n.textContent=e:(n=document.createElement("div"),n.className="dynamsoft-mrz-loading-message",n.textContent=e,o.appendChild(n)):null==n||n.remove()},hide:()=>{a&&a.parentNode&&(a.classList.add("fade-out"),setTimeout((()=>{var e;null===(e=a.parentNode)||void 0===e||e.removeChild(a)}),200))}}}const b='\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: "Verdana";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n';var Z;e.EnumMRZData=void 0,(Z=e.EnumMRZData||(e.EnumMRZData={})).InvalidFields="invalidFields",Z.DocumentType="documentType",Z.DocumentNumber="documentNumber",Z.MRZText="mrzText",Z.FirstName="firstName",Z.LastName="lastName",Z.Age="age",Z.Sex="sex",Z.IssuingState="issuingState",Z.IssuingStateRaw="issuingStateRaw",Z.Nationality="nationality",Z.NationalityRaw="nationalityRaw",Z.DateOfBirth="dateOfBirth",Z.DateOfExpiry="dateOfExpiry";const x={[e.EnumMRZData.InvalidFields]:"Invalid Fields",[e.EnumMRZData.DocumentType]:"Document Type",[e.EnumMRZData.DocumentNumber]:"Document Number",[e.EnumMRZData.MRZText]:"MRZ Text",[e.EnumMRZData.FirstName]:"Given Name(s)",[e.EnumMRZData.LastName]:"Surname",[e.EnumMRZData.Age]:"Age",[e.EnumMRZData.Sex]:"Sex",[e.EnumMRZData.IssuingState]:"Issuing State",[e.EnumMRZData.IssuingStateRaw]:"Issuing State (Raw Value)",[e.EnumMRZData.Nationality]:"Nationality",[e.EnumMRZData.NationalityRaw]:"Nationality State (Raw Value)",[e.EnumMRZData.DateOfBirth]:"Date Of Birth (YYYY-MM-DD)",[e.EnumMRZData.DateOfExpiry]:"Date Of Expiry (YYYY-MM-DD)"};function z(e,n,t,i=!1){const a=parseInt(e,10);let s;if(i)s=a>=60?1900+a:2e3+a;else{s=a>(new Date).getFullYear()%100?1900+a:2e3+a}return{year:s,month:parseInt(n,10),day:parseInt(t,10)}}function V(e){const n=e=>{var n;return 1===(null===(n=`${e}`)||void 0===n?void 0:n.length)?`0${e}`:e};return`${null==e?void 0:e.year}-${n(null==e?void 0:e.month)}${(null==e?void 0:e.day)&&`-${n(null==e?void 0:e.day)}`}`}function I(e){return"D<<"===e?"D":e}function L(n,t){const i=[],a=e=>t.getFieldValidationStatus(e)===s.EnumValidationStatus.VS_FAILED,o=t.codeType,r=function(n){switch(n){case"MRTD_TD1_ID":return e.EnumMRZDocumentType.TD1;case"MRTD_TD2_ID":case"MRTD_TD2_VISA":case"MRTD_TD2_FRENCH_ID":return e.EnumMRZDocumentType.TD2;case"MRTD_TD3_PASSPORT":case"MRTD_TD3_VISA":return e.EnumMRZDocumentType.Passport;default:throw new Error(`Unknown document type: ${n}`)}}(o),l=function(e){switch(e){case"MRTD_TD1_ID":return"ID (TD1)";case"MRTD_TD2_ID":return"ID (TD2)";case"MRTD_TD2_VISA":return"ID (VISA)";case"MRTD_TD2_FRENCH_ID":return"French ID (TD2)";case"MRTD_TD3_PASSPORT":return"Passport (TD3)";case"MRTD_TD3_VISA":return"Visa (TD3)";default:throw new Error(`Unknown document type: ${e}`)}}(o),c=r===e.EnumMRZDocumentType.Passport&&"MRTD_TD3_PASSPORT"===o?"passportNumber":"documentNumber",d=z(t.getFieldValue("birthYear"),t.getFieldValue("birthMonth"),t.getFieldValue("birthDay")),u=z(t.getFieldValue("expiryYear"),t.getFieldValue("expiryMonth"),t.getFieldValue("expiryDay"),!0);["birthYear","birthMonth","birthDay"].forEach((n=>{a(n)&&i.push(e.EnumMRZData.DateOfBirth)})),["expiryYear","expiryMonth","expiryDay"].forEach((n=>{a(n)&&i.push(e.EnumMRZData.DateOfExpiry)}));const m={[e.EnumMRZData.LastName]:t.getFieldValue("primaryIdentifier"),[e.EnumMRZData.FirstName]:t.getFieldValue("secondaryIdentifier"),[e.EnumMRZData.Nationality]:t.getFieldValue("nationality"),[e.EnumMRZData.NationalityRaw]:I(t.getFieldRawValue("nationality")),[e.EnumMRZData.DocumentNumber]:t.getFieldValue(c)||t.getFieldValue("longDocumentNumber"),[e.EnumMRZData.IssuingState]:t.getFieldValue("issuingState"),[e.EnumMRZData.IssuingStateRaw]:I(t.getFieldRawValue("issuingState")),[e.EnumMRZData.Sex]:S(t.getFieldValue("sex"))};Object.keys(m).forEach((n=>{let t=!1;switch(n){case e.EnumMRZData.FirstName:t=a("secondaryIdentifier");break;case e.EnumMRZData.LastName:t=a("primaryIdentifier");break;case e.EnumMRZData.DocumentNumber:t=a(c)||a("longDocumentNumber");break;default:t=a(n)}t&&i.push(n)}));const h=function(e){const n=new Date,t=n.getMonth()+1>e.month||n.getMonth()+1===e.month&&n.getDate()>=e.day;return n.getFullYear()-e.year-(t?0:1)}(d);h<1&&i.push(e.EnumMRZData.Age);return{[e.EnumMRZData.InvalidFields]:i,[e.EnumMRZData.FirstName]:m[e.EnumMRZData.FirstName],[e.EnumMRZData.LastName]:m[e.EnumMRZData.LastName],[e.EnumMRZData.Age]:h,[e.EnumMRZData.DateOfBirth]:d,[e.EnumMRZData.Sex]:m[e.EnumMRZData.Sex],[e.EnumMRZData.Nationality]:m[e.EnumMRZData.Nationality],[e.EnumMRZData.NationalityRaw]:m[e.EnumMRZData.NationalityRaw],[e.EnumMRZData.DocumentNumber]:m[e.EnumMRZData.DocumentNumber],[e.EnumMRZData.DateOfExpiry]:u,[e.EnumMRZData.IssuingState]:m[e.EnumMRZData.IssuingState],[e.EnumMRZData.IssuingStateRaw]:m[e.EnumMRZData.IssuingStateRaw],[e.EnumMRZData.DocumentType]:S(l),[e.EnumMRZData.MRZText]:n}}const N={[e.EnumMRZDocumentType.TD1]:{width:85.6,height:53.98},[e.EnumMRZDocumentType.TD2]:{width:105,height:74},[e.EnumMRZDocumentType.Passport]:{width:125,height:88}};class _{showScannerLoadingOverlay(e){const n=v(this.config.container);this.loadingScreen=T(n,{message:e}),n.style.display="block",n.style.position="relative"}hideScannerLoadingOverlay(e=!1){this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,e&&(v(this.config.container).style.display="none"))}constructor(n,t){this.resources=n,this.config=t,this.isSoundFeedbackOn=!1,this.scanModeManager={[e.EnumMRZDocumentType.Passport]:!0,[e.EnumMRZDocumentType.TD1]:!0,[e.EnumMRZDocumentType.TD2]:!0},this.currentScanMode=e.EnumMRZScanMode.All,this.resizeTimer=null,this.capturedResultItems=[],this.originalImageData=null,this.initialized=!1,this.initializedDCE=!1,this.DCE_ELEMENTS={selectCameraBtn:null,uploadImageBtn:null,soundFeedbackBtn:null,closeScannerBtn:null,scanModeSelectContainer:null,passportModeOption:null,td1ModeOption:null,td2ModeOption:null,toast:null},this.loadingScreen=null,this.handleResize=()=>{this.toggleScanGuide(!1),this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((()=>{this.toggleScanGuide(!0)}),500)}}async initialize(){if(!this.initialized){this.initializeScanModeManager(),this.currentScanMode=this.getScanMode(),M("dynamsoft-mrz-loading-screen-style",b);try{const{cameraView:e,cameraEnhancer:t,cvRouter:a}=this.resources;if(e.setScanRegionMaskStyle({strokeStyle:"transparent",fillStyle:"transparent",lineWidth:0}),e.setVideoFit("cover"),a.setInput(t),await a.initSettings(this.config.templateFilePath),!0===this.config.enableMultiFrameCrossFilter){const e=new r.MultiFrameResultCrossFilter;e.enableResultCrossVerification(n.EnumCapturedResultItemType.CRIT_TEXT_LINE,!0),e.enableResultDeduplication(n.EnumCapturedResultItemType.CRIT_TEXT_LINE,!0),await a.addResultFilter(e)}const s=new i.CapturedResultReceiver;s.onCapturedResultReceived=e=>this.handleMRZResult(e),await a.addResultReceiver(s),this.toggleSoundFeedback(!1),!1===this.config.showScanGuide&&this.toggleScanGuide(!1),this.initialized=!0}catch(n){let t=(null==n?void 0:n.message)||n;console.error(t),alert(t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:"Dynamsoft MRZ Scanner initialize error"}};this.currentScanResolver(i)}}}initializeElements(){var e;const n=v(this.config.container),t=n.children[n.children.length-1];if(!(null==t?void 0:t.shadowRoot))throw new Error("Shadow root not found");if(this.DCE_ELEMENTS={selectCameraBtn:t.shadowRoot.querySelector(".dce-mn-select-camera-icon"),uploadImageBtn:t.shadowRoot.querySelector(".dce-mn-upload-image-icon"),soundFeedbackBtn:t.shadowRoot.querySelector(".dce-mn-sound-feedback"),closeScannerBtn:t.shadowRoot.querySelector(".dce-mn-close"),scanModeSelectContainer:t.shadowRoot.querySelector(".dce-mn-scan-mode-select"),passportModeOption:t.shadowRoot.querySelector(".scan-mode-option-passport"),td1ModeOption:t.shadowRoot.querySelector(".scan-mode-option-td1"),td2ModeOption:t.shadowRoot.querySelector(".scan-mode-option-td2"),toast:t.shadowRoot.querySelector(".dce-mn-toast")},this.setupScanModeSelector(),this.assignDCEClickEvents(),this.DCE_ELEMENTS.toast.style.display="none",!1===this.config.showUploadImage&&(this.DCE_ELEMENTS.uploadImageBtn.style.visibility="hidden"),!1===this.config.showSoundToggle&&(this.DCE_ELEMENTS.soundFeedbackBtn.style.visibility="hidden"),!1===(null===(e=this.config)||void 0===e?void 0:e.showPoweredByDynamsoft)){t.shadowRoot.querySelector(".dce-mn-msg-poweredby").style.display="none"}this.initializedDCE=!0}setupScanModeSelector(){if(!1!==this.config.showFormatSelector)switch(this.currentScanMode){case e.EnumMRZScanMode.PassportAndTD1:this.DCE_ELEMENTS.td2ModeOption.style.display="none";break;case e.EnumMRZScanMode.PassportAndTD2:this.DCE_ELEMENTS.td1ModeOption.style.display="none";break;case e.EnumMRZScanMode.TD1AndTD2:this.DCE_ELEMENTS.passportModeOption.style.display="none";break;case e.EnumMRZScanMode.All:break;default:this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}else this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}assignDCEClickEvents(){if(!Object.values(this.DCE_ELEMENTS).every(Boolean))throw new Error("Camera control elements not found");this.closeCamera=this.closeCamera.bind(this),this.DCE_ELEMENTS.uploadImageBtn.onclick=()=>this.uploadFile(),this.DCE_ELEMENTS.soundFeedbackBtn.onclick=()=>this.toggleSoundFeedback(),this.DCE_ELEMENTS.closeScannerBtn.onclick=()=>this.handleCloseBtn(),this.DCE_ELEMENTS.selectCameraBtn.onclick=e=>{e.stopPropagation(),this.toggleSelectCameraBox()},this.DCE_ELEMENTS.passportModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.passportModeOption.style.display&&await this.toggleScanDocType(e.EnumMRZDocumentType.Passport)},this.DCE_ELEMENTS.td1ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td1ModeOption.style.display&&await this.toggleScanDocType(e.EnumMRZDocumentType.TD1)},this.DCE_ELEMENTS.td2ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td2ModeOption.style.display&&await this.toggleScanDocType(e.EnumMRZDocumentType.TD2)}}handleCloseBtn(){this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:e.EnumResultStatus.RS_CANCELLED,message:"Cancelled"}})}attachOptionClickListeners(){const e=v(this.config.container),n=e.children[e.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const t=n.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings");[...n.shadowRoot.querySelectorAll(".dce-mn-camera-option"),...n.shadowRoot.querySelectorAll(".dce-mn-resolution-option")].forEach((e=>{e.addEventListener("click",(async n=>{const i=e.getAttribute("data-davice-id"),a=e.getAttribute("data-height"),s=e.getAttribute("data-width");i?this.resources.cameraEnhancer.selectCamera(i).then((()=>{this.toggleScanGuide()})):a&&s&&this.resources.cameraEnhancer.setResolution({width:parseInt(s),height:parseInt(a)}).then((()=>{this.toggleScanGuide()})),"none"!==t.style.display&&this.toggleSelectCameraBox()}))}))}highlightCameraAndResolutionOption(){const e=v(this.config.container),n=e.children[e.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const t=n.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings"),i=t.querySelectorAll(".dce-mn-camera-option"),a=t.querySelectorAll(".dce-mn-resolution-option"),s=this.resources.cameraEnhancer.getSelectedCamera(),o=this.resources.cameraEnhancer.getResolution();i.forEach((e=>{const n=e;n.getAttribute("data-davice-id")===(null==s?void 0:s.deviceId)?n.style.border="2px solid #fe814a":n.style.border="none"}));const r={"480p":"480","720p":"720","1080p":"1080","2k":"1440","4k":"2160"},l=function(e){const n=e.width*e.height,t=e.width/e.height;let i="480p",a=Number.MAX_VALUE;for(const[e,s]of Object.entries(C)){const o=s.width*s.height,r=s.width/s.height,l=.7*Math.abs(o-n)+Math.abs(r-t)*o*.3;l{const n=e,t=n.getAttribute("data-height");n.style.border=t===r[l]?"2px solid #fe814a":"none"}))}toggleSelectCameraBox(){const e=v(this.config.container),n=e.children[e.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const t=n.shadowRoot.querySelector(".dce-mn-resolution-box");this.highlightCameraAndResolutionOption(),this.attachOptionClickListeners(),t.click()}async relaunch(){}async uploadFile(){var t,i,a,s;const{cvRouter:o}=this.resources,r=document.createElement("input");r.type="file",r.accept=null!==(t=this.config.uploadAcceptedTypes)&&void 0!==t?t:"image/*",r.style.display="none",document.body.appendChild(r);try{this.showScannerLoadingOverlay("Processing file..."),await this.closeCamera(!1);const t=await new Promise(((e,n)=>{r.onchange=t=>{var i;const a=null===(i=t.target.files)||void 0===i?void 0:i[0];a?e(a):n(new Error("No file selected"))},r.addEventListener("cancel",(async()=>{this.hideScannerLoadingOverlay(!1),await this.openCamera(),await this.startCapturing(),this.toggleScanGuide()})),r.click()}));if(!t)return;let l;if(this.config.uploadFileConverter&&!t.type.startsWith("image/"))try{l=await this.config.uploadFileConverter(t)}catch(e){throw new Error(`Error converting file: ${e.message}`)}else{if(!t.type.startsWith("image/"))throw new Error("Unsupported file type. Please provide a converter function for this file type.");l=t}const c=this.config.utilizedTemplateNames[this.currentScanMode];if(!1!==this.config.showScanGuide){const e=await o.getSimplifiedSettings(c);e.roiMeasuredInPercentage=!0,e.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await o.updateSettings(c,e)}const d=await o.capture(l,c);this.capturedResultItems=d.items;const u=this.capturedResultItems.filter((e=>e.type===n.EnumCapturedResultItemType.CRIT_ORIGINAL_IMAGE));if(0===u.length)throw new Error("No image data found in the captured result");const m=u[0].imageData;m.toCanvas=()=>n._toCanvas(m),m.toBlob=async()=>await n._toBlob("image/png",m),this.originalImageData=m;const h=null==d?void 0:d.textLineResultItems,g=null==d?void 0:d.parsedResultItems;let p={};if(null==h?void 0:h.length){const e=(null===(i=h[0])||void 0===i?void 0:i.text)||"";p=L(e,g[0])}const f={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:p,imageData:!0,_imageData:this.originalImageData};null===(s=(a=this.resources).onResultUpdated)||void 0===s||s.call(a,f),this.currentScanResolver(f)}catch(n){let t=(null==n?void 0:n.message)||n;console.error(t),alert(t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:`Error processing file: ${t}`}};this.currentScanResolver(i)}finally{this.hideScannerLoadingOverlay(!0),document.body.removeChild(r)}}toggleSoundFeedback(e){this.isSoundFeedbackOn=void 0!==e?e:!this.isSoundFeedbackOn;const n=v(this.config.container),t=n.children[n.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const i=t.shadowRoot.querySelector(".dce-mn-sound-feedback"),a=i.querySelector(".dce-mn-sound-feedback-on");i.querySelector(".dce-mn-sound-feedback-off").style.display=this.isSoundFeedbackOn?"none":"block",a.style.display=this.isSoundFeedbackOn?"block":"none"}calculateScanRegion(e){const{cameraEnhancer:n,cameraView:t}=this.resources;if(!n||!n.isOpen())return;const i=t.getVisibleRegionOfVideo({inPixels:!0});if(!i)return;const a=t.getVideoElement(),s=a.videoWidth,o=a.videoHeight,r=N[e];let l;const c=i.height-80;if(i.width>i.height){l=.75*c/r.height;l*r.width>.9*i.width&&(l=.9*i.width/r.width)}else{l=.9*i.width/r.width;l*r.height>.75*c&&(l=.75*c/r.height)}const d=l*r.width,u=l*r.height,m=(i.width-d)/2,h=(c-u)/2,g=m,p=m+d,f=h,y=h+u,R=(i.x+g)/s*100,E=(i.x+p)/s*100,w=(i.y+f)/o*100,v=(i.y+y)/o*100,M={left:Math.round(R),right:Math.round(E),top:Math.round(w),bottom:Math.round(v),isMeasuredInPercentage:!0};null==t||t.setScanRegionMaskVisible(!0),n.setScanRegion(M)}toggleScanGuide(n){const t=v(this.config.container),i=t.children[t.children.length-1];if(!(null==i?void 0:i.shadowRoot))return;const a=i.shadowRoot.querySelector(".dce-scanguide-passport"),s=i.shadowRoot.querySelector(".dce-scanguide-td1"),o=i.shadowRoot.querySelector(".dce-scanguide-td2");if(!1===n||!1===this.config.showScanGuide)return a.style.display="none",s.style.display="none",void(o.style.display="none");switch(this.currentScanMode){case e.EnumMRZScanMode.All:case e.EnumMRZScanMode.Passport:case e.EnumMRZScanMode.PassportAndTD1:case e.EnumMRZScanMode.PassportAndTD2:a.style.display="block",s.style.display="none",o.style.display="none",this.calculateScanRegion(e.EnumMRZDocumentType.Passport);break;case e.EnumMRZScanMode.TD1:case e.EnumMRZScanMode.TD1AndTD2:a.style.display="none",s.style.display="block",o.style.display="none",this.calculateScanRegion(e.EnumMRZDocumentType.TD1);break;case e.EnumMRZScanMode.TD2:a.style.display="none",s.style.display="none",o.style.display="block",this.calculateScanRegion(e.EnumMRZDocumentType.TD2)}}async openCamera(){try{this.showScannerLoadingOverlay("Initializing camera...");const{cameraEnhancer:e,cameraView:n}=this.resources,t=v(this.config.container);if(t.style.display="block",e.isOpen())e.isPaused()&&await e.resume();else{const i=n.getUIElement();i.parentElement||t.append(i),await e.open()}await e.setResolution({width:2560,height:1440}),!this.initializedDCE&&e.isOpen()&&await this.initializeElements(),window.addEventListener("resize",this.handleResize);const i=t.children[t.children.length-1];if(!(null==i?void 0:i.shadowRoot))throw new Error("Shadow root not found");i.shadowRoot.querySelector(".dce-mn-torch-off").style.display="none",i.shadowRoot.querySelector(".dce-mn-torch-on").style.display="none"}catch(n){let t=(null==n?void 0:n.message)||n;console.error(t),alert(t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:"MRZ Scanner Open Camera Error"}};this.currentScanResolver(i)}finally{this.hideScannerLoadingOverlay()}}async closeCamera(e=!0){try{window.removeEventListener("resize",this.handleResize),this.resizeTimer&&(window.clearTimeout(this.resizeTimer),this.resizeTimer=null);const{cameraEnhancer:n,cameraView:t}=this.resources,i=v(this.config.container);i.style.display=e?"none":"block",(null==t?void 0:t.getUIElement().parentElement)&&i.removeChild(t.getUIElement()),n.close(),this.stopCapturing()}catch(e){let n=(null==e?void 0:e.message)||e;console.error(`Close Camera error: ${n}`)}}pauseCamera(){const{cameraEnhancer:e}=this.resources;e.pause()}stopCapturing(){const{cameraView:e,cvRouter:n}=this.resources;n.stopCapturing(),e.clearAllInnerDrawingItems()}async handleMRZResult(t){var i;if(this.capturedResultItems=t.items,!(t.items.length<=1))try{const{onResultUpdated:s}=this.resources,o=t.items.filter((e=>e.type===n.EnumCapturedResultItemType.CRIT_ORIGINAL_IMAGE))[0].imageData;o.toCanvas=()=>n._toCanvas(o),o.toBlob=async()=>await n._toBlob("image/png",o),this.originalImageData=o;const r=null==t?void 0:t.textLineResultItems,l=null==t?void 0:t.parsedResultItems;if(r){this.isSoundFeedbackOn&&a.Feedback.beep();const n=(null===(i=null==r?void 0:r[0])||void 0===i?void 0:i.text)||"",t=L(n,l[0]);this.closeCamera();const o={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:t,imageData:!0,_imageData:this.originalImageData};null==s||s(o),this.currentScanResolver(o)}}catch(n){let t=(null==n?void 0:n.message)||n;console.error(t),alert(t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:"Error capturing image"}};this.currentScanResolver(i)}}initializeScanModeManager(){const{mrzFormatType:n}=this.config;if(this.scanModeManager={[e.EnumMRZDocumentType.Passport]:!0,[e.EnumMRZDocumentType.TD1]:!0,[e.EnumMRZDocumentType.TD2]:!0},!n||Array.isArray(n)&&0===n.length)return;Object.keys(this.scanModeManager).forEach((e=>{this.scanModeManager[e]=!1}));(Array.isArray(n)?n:[n]).forEach((e=>{this.scanModeManager[e]=!0}))}getScanMode(){const n=Object.entries(this.scanModeManager).filter((([e,n])=>n)).map((([e])=>e)).sort().join(",");return{[e.EnumMRZDocumentType.Passport]:e.EnumMRZScanMode.Passport,[e.EnumMRZDocumentType.TD1]:e.EnumMRZScanMode.TD1,[e.EnumMRZDocumentType.TD2]:e.EnumMRZScanMode.TD2,[`${e.EnumMRZDocumentType.Passport},${e.EnumMRZDocumentType.TD1}`]:e.EnumMRZScanMode.PassportAndTD1,[`${e.EnumMRZDocumentType.Passport},${e.EnumMRZDocumentType.TD2}`]:e.EnumMRZScanMode.PassportAndTD2,[`${e.EnumMRZDocumentType.TD1},${e.EnumMRZDocumentType.TD2}`]:e.EnumMRZScanMode.TD1AndTD2,[`${e.EnumMRZDocumentType.Passport},${e.EnumMRZDocumentType.TD1},${e.EnumMRZDocumentType.TD2}`]:e.EnumMRZScanMode.All,"":e.EnumMRZScanMode.All}[n]}DCEShowToast(e,n=3e3){this.DCE_ELEMENTS.toast&&(this.DCE_ELEMENTS.toast.textContent=e,this.DCE_ELEMENTS.toast.style.display="",setTimeout((()=>{this.DCE_ELEMENTS.toast.style.display="none"}),n))}async startCapturing(){const{cvRouter:t,cameraEnhancer:i}=this.resources,a=this.config.utilizedTemplateNames[this.currentScanMode];try{if(!1!==this.config.showScanGuide){const e=await t.getSimplifiedSettings(a);e.roiMeasuredInPercentage=!0,e.roi.points=[{x:0,y:50},{x:100,y:50},{x:100,y:100},{x:0,y:100}],await t.updateSettings(a,e)}await t.startCapturing(a),i.setPixelFormat(n.EnumImagePixelFormat.IPF_ABGR_8888)}catch(n){let t=(null==n?void 0:n.message)||n;console.error("Failed to start capturing:",t),this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:e.EnumResultStatus.RS_FAILED,message:"Failed to start capturing"}})}}async toggleScanDocType(n){try{if(this.scanModeManager[n]&&0===Object.entries(this.scanModeManager).filter((([e,t])=>t&&e!==n)).length)return console.warn("MRZ Scanner - At least one mode must be enabled"),void this.DCEShowToast("At least one mode must be enabled");this.scanModeManager[n]=!this.scanModeManager[n],this.currentScanMode=this.getScanMode(),this.stopCapturing(),await this.startCapturing(),this.toggleScanGuide(),this.DCE_ELEMENTS.td1ModeOption.classList.toggle("selected",this.scanModeManager[e.EnumMRZDocumentType.TD1]),this.DCE_ELEMENTS.td2ModeOption.classList.toggle("selected",this.scanModeManager[e.EnumMRZDocumentType.TD2]),this.DCE_ELEMENTS.passportModeOption.classList.toggle("selected",this.scanModeManager[e.EnumMRZDocumentType.Passport])}catch(n){let t=(null==n?void 0:n.message)||n;console.error("MRZ Scanner switch scan mode error: ",t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:"MRZ Scanner switch scan mode error"}};this.currentScanResolver(i)}}async launch(){try{await this.initialize();const{cvRouter:e,cameraEnhancer:n}=this.resources;return new Promise((async e=>{this.currentScanResolver=e,await this.openCamera(),!this.initializedDCE&&n.isOpen()&&await this.initializeElements(),await this.startCapturing(),this.toggleScanGuide()}))}catch(n){let t=(null==n?void 0:n.message)||n;console.error("MRZ Scanner launch error: ",t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:"MRZ Scanner launch error"}};this.currentScanResolver(i)}}}const F={rescan:'\n\n\n \n\n\n\n\n\n\n\n',complete:'\n\n\n\n \n\n\n\n\n\n\n\n',failed:'\n \n \n \n\n',info:'\n\n \n \n \n\n'};class k{constructor(e,n,t){this.resources=e,this.config=n,this.scannerView=t,this.editedFields={}}async launch(){try{return v(this.config.container).textContent="",await this.initialize(),v(this.config.container).style.display="flex",new Promise((e=>{this.currentScanResultViewResolver=e}))}catch(e){let n=(null==e?void 0:e.message)||e;throw console.error(n),n}}async handleRescan(){var n;try{if(!this.scannerView)return void console.error("Scanner View not initialized");this.hideView();const t=await this.scannerView.launch();if((null===(n=null==t?void 0:t.status)||void 0===n?void 0:n.code)===e.EnumResultStatus.RS_FAILED)return void(this.currentScanResultViewResolver&&this.currentScanResultViewResolver(t));this.resources.onResultUpdated&&((null==t?void 0:t.status.code)===e.EnumResultStatus.RS_CANCELLED?this.resources.onResultUpdated(this.resources.result):(null==t?void 0:t.status.code)===e.EnumResultStatus.RS_SUCCESS&&this.resources.onResultUpdated(t)),this.dispose(!0),await this.initialize(),v(this.config.container).style.display="flex"}catch(n){throw console.error("Error in rescan handler:",n),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:e.EnumResultStatus.RS_FAILED,message:(null==n?void 0:n.message)||n}}),n}}async handleDone(){var n,t;try{(null===(n=this.resources.result)||void 0===n?void 0:n.data)&&!D(this.editedFields)&&(this.resources.result.data=Object.assign(Object.assign({},this.resources.result.data),this.editedFields),this.resources.onResultUpdated&&this.resources.onResultUpdated(this.resources.result)),(null===(t=this.config)||void 0===t?void 0:t.onDone)&&await this.config.onDone(this.resources.result),this.currentScanResultViewResolver&&this.resources.result&&this.currentScanResultViewResolver(this.resources.result),this.hideView(),this.dispose()}catch(n){throw console.error("Error in done handler:",n),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:e.EnumResultStatus.RS_FAILED,message:(null==n?void 0:n.message)||n}}),n}}createControls(){var e,n,t,i,a,s,o,r;const{toolbarButtonsConfig:l}=this.config;return function(e){M("dynamsoft-mrz-controls-style","\n .dynamsoft-mrz-controls {\n display: flex;\n height: 6rem;\n background-color: #323234;\n align-items: center;\n font-size: 12px;\n font-family: Verdana;\n color: white;\n width: 100%;\n }\n\n .dynamsoft-mrz-control-btn {\n background-color: #323234;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n gap: 0.5rem;\n text-align: center;\n user-select: none;\n }\n\n .dynamsoft-mrz-control-btn.hide {\n display: none;\n }\n\n .dynamsoft-mrz-control-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n cursor: default;\n }\n\n .dynamsoft-mrz-control-icon-wrapper {\n flex: 0.75;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n min-height: 40px;\n }\n\n .dynamsoft-mrz-control-icon img,\n .dynamsoft-mrz-control-icon svg {\n width: 32px;\n height: 32px;\n fill: #fe8e14;\n }\n\n .dynamsoft-mrz-control-text {\n flex: 0.5;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-bottom: 0.5rem;\n }\n\n \n @media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-controls {\n flex-direction: column;\n height: 100%;\n width: 5rem;\n }\n\n .dynamsoft-mrz-control-text {\n padding: 0 0.5rem 0.5rem;\n }\n }\n");const n=document.createElement("div");return n.className="dynamsoft-mrz-controls",e.forEach((e=>{const t=document.createElement("div");t.className=`dynamsoft-mrz-control-btn ${null==e?void 0:e.className}`;const i=document.createElement("div");if(i.className="dynamsoft-mrz-control-icon-wrapper",(a=e.icon).trim().startsWith(""))i.innerHTML=e.icon;else{const n=document.createElement("img");n.src=e.icon,n.alt=e.label,n.width=24,n.height=24,i.appendChild(n)}var a;const s=document.createElement("div");s.className="dynamsoft-mrz-control-text",s.textContent=e.label,e.isDisabled&&t.classList.add("disabled"),e.isHidden&&t.classList.add("hide"),t.appendChild(i),t.appendChild(s),e.onClick&&!e.isDisabled&&t.addEventListener("click",e.onClick),n.appendChild(t)})),n}([{id:"dynamsoft-mrz-scanResult-rescan",icon:(null===(e=null==l?void 0:l.rescan)||void 0===e?void 0:e.icon)||F.rescan,label:(null===(n=null==l?void 0:l.rescan)||void 0===n?void 0:n.label)||"Re-scan",onClick:()=>this.handleRescan(),className:`${(null===(t=null==l?void 0:l.rescan)||void 0===t?void 0:t.className)||""}`,isHidden:(null===(i=null==l?void 0:l.rescan)||void 0===i?void 0:i.isHidden)||!1,isDisabled:!this.scannerView},{id:"dynamsoft-mrz-scanResult-done",icon:(null===(a=null==l?void 0:l.done)||void 0===a?void 0:a.icon)||F.complete,label:(null===(s=null==l?void 0:l.done)||void 0===s?void 0:s.label)||"Done",className:`${(null===(o=null==l?void 0:l.done)||void 0===o?void 0:o.className)||""}`,isHidden:(null===(r=null==l?void 0:l.done)||void 0===r?void 0:r.isHidden)||!1,onClick:()=>this.handleDone()}])}handleFieldEdit(n,t){if(n===e.EnumMRZData.DateOfBirth||n===e.EnumMRZData.DateOfExpiry)try{const[e,i,a]=t.split(/[\/\-\.]/);a&&i&&e&&(this.editedFields[n]={day:parseInt(a,10),month:parseInt(i,10),year:parseInt(e,10)})}catch(e){console.error("Error parsing date",e)}else this.editedFields[n]=t}createMRZDataDisplay(){var n;const t=(null===(n=this.resources.result)||void 0===n?void 0:n.data)||{},i=!!this.config.allowResultEditing,a=t.invalidFields||[],s=document.createElement("div");if(s.className="dynamsoft-mrz-data-container",D(t)){const e=document.createElement("div");return e.className="dynamsoft-mrz-data-row empty",e.innerText="No MRZ detected. Please try again.",s.appendChild(e),s}if(a.length>0){const e=document.createElement("div");e.className="dynamsoft-mrz-error-notification",e.innerHTML=`\n
${F.failed}
\n
\n ${i?"Some fields require correction. Please review highlighted fields.":"Some fields contain invalid information. Please rescan the document."}\n
\n `,s.appendChild(e)}else if(0===a.length&&i){const e=document.createElement("div");e.className="dynamsoft-mrz-info-notification",e.innerHTML=`\n
${F.info}
\n
\n Please review all fields to ensure the information is correct.\n
\n `,s.appendChild(e)}return Object.entries(t).forEach((([n,t])=>{var o;if(n===e.EnumMRZData.InvalidFields||!t)return;if(n===e.EnumMRZData.MRZText&&!1===(null===(o=this.config)||void 0===o?void 0:o.showMRZText))return;const r=document.createElement("div");r.className="dynamsoft-mrz-data-row";const l=a.includes(n);l&&r.classList.add("invalid-field");const c=[e.EnumMRZData.MRZText,e.EnumMRZData.DocumentType,e.EnumMRZData.IssuingStateRaw,e.EnumMRZData.NationalityRaw],d=document.createElement("span");if(d.className="dynamsoft-mrz-data-label",d.innerText=x[n]||n,l){const e=document.createElement("span");if(e.className="dynamsoft-mrz-error-icon",e.innerHTML=F.failed,d.appendChild(e),i){const e=document.createElement("span");e.className="dynamsoft-mrz-error-hint",e.textContent="Please correct this field",d.appendChild(e)}}const u=document.createElement("div");if(u.className="dynamsoft-mrz-data-value",i&&!c.includes(n)){const i=document.createElement("input");i.className="dynamsoft-mrz-data-input",l&&i.classList.add("invalid"),n===e.EnumMRZData.DateOfBirth||n===e.EnumMRZData.DateOfExpiry?(i.value=V(t),i.setAttribute("placeholder","YYYY-MM-DD")):i.value=t,i.addEventListener("input",(e=>{if(this.handleFieldEdit(n,e.target.value),l){i.classList.remove("invalid"),r.classList.remove("invalid-field"),this.editedFields.invalidFields||(this.editedFields.invalidFields=[...a]);const e=this.editedFields.invalidFields.indexOf(n);e>-1&&this.editedFields.invalidFields.splice(e,1)}})),u.appendChild(i)}else n===e.EnumMRZData.MRZText?(u.classList.add("code"),u.innerText=t):n===e.EnumMRZData.DateOfBirth||n===e.EnumMRZData.DateOfExpiry?u.innerText=V(t):u.innerText=t,l&&u.classList.add("invalid-value");r.appendChild(d),r.appendChild(u),s.appendChild(r)})),s}async initialize(){try{if(!this.resources.result)throw Error("Captured image is missing. Please capture an image first!");if(!this.config.container)throw new Error("Please create a Scan Result View Container element");M("dynamsoft-mrz-result-view-style",O);const e=document.createElement("div");if(e.className="dynamsoft-mrz-result-view-container",!1!==this.config.showOriginalImage){const n=this.resources.result.originalImageResult,t=document.createElement("div");let i;t.className="dynamsoft-mrz-result-view-image-container",(null==n?void 0:n.toCanvas)&&(i=null==n?void 0:n.toCanvas()),Object.assign(i.style,{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}),t.appendChild(i),e.appendChild(t)}const n=this.createMRZDataDisplay();e.appendChild(n);const t=this.createControls();e.appendChild(t),v(this.config.container).appendChild(e)}catch(e){let n=(null==e?void 0:e.message)||e;console.error(n),alert(n)}}hideView(){v(this.config.container).style.display="none"}dispose(e=!1){v(this.config.container).textContent="",e||(this.currentScanResultViewResolver=void 0)}}const O="\n .dynamsoft-mrz-result-view-container {\n display: flex;\n width: 100%;\n height: 100%;\n background-color:#575757;\n font-size: 12px;\n flex-direction: column;\n align-items: center;\n }\n\n .dynamsoft-mrz-result-view-image-container {\n width: 100%;\n height: 200px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #323234;\n }\n\n \n.dynamsoft-mrz-data-container {\n font-size: 16px;\n font-family: Verdana;\n color: white;\n overflow: auto;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 1rem 0;\n}\n\n.dynamsoft-mrz-data-row {\n padding: 0.5rem 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n transition: background-color 0.3s ease;\n}\n\n.dynamsoft-mrz-data-row.invalid-field {\n background-color: rgba(231, 76, 60, 0.1);\n border-left: 3px solid #e74c3c;\n padding-left: calc(2rem - 3px);\n}\n\n.dynamsoft-mrz-data-label {\n color: #aaa;\n display: flex;\n gap: 0.5rem;\n align-items: end;\n flex-wrap: wrap;\n}\n\n.dynamsoft-mrz-error-notification,\n.dynamsoft-mrz-info-notification {\n color: white;\n padding: 1rem;\n margin: 0.5rem 2rem;\n border-radius: 4px;\n display: flex;\n align-items: center;\n gap: 1rem;\n text-align: start;\n}\n\n.dynamsoft-mrz-error-notification {\n background-color: rgba(231, 76, 60, 0.2);\n}\n\n.dynamsoft-mrz-info-notification {\n background-color: rgba(196, 231, 60, 0.2);\n}\n\n.dynamsoft-mrz-edit-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #aaa;\n}\n\n.dynamsoft-mrz-error-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-info-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.dynamsoft-mrz-info-message,\n.dynamsoft-mrz-error-message {\n flex: 1;\n}\n\n.dynamsoft-mrz-error-hint {\n font-size: 0.8rem;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-value {\n word-wrap: break-word;\n text-align: start;\n}\n\n.dynamsoft-mrz-data-value.code {\n font-family: monospace;\n}\n\n.dynamsoft-mrz-data-value.invalid-value {\n color: #e74c3c;\n text-decoration: wavy underline #e74c3c;\n text-decoration-skip-ink: none;\n}\n\n.dynamsoft-mrz-data-input {\n width: 100%;\n padding: 5px;\n background-color: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.3);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n transition: all 0.3s ease;\n}\n\n.dynamsoft-mrz-data-input.invalid {\n background-color: rgba(231, 76, 60, 0.1);\n border-color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-input:focus {\n background-color: rgba(255, 255, 255, 0.2);\n border-color: #fe8e14;\n outline: none;\n}\n\n@media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-result-view-container {\n flex-direction: row;\n }\n\n .dynamsoft-mrz-result-view-image-container{\n flex: 1;\n height: 100%;\n }\n\n .dynamsoft-mrz-data-container{\n flex: 1;\n }\n\n .dynamsoft-mrz-data-row:first-of-type {\n padding-top: 2rem;\n }\n\n .dynamsoft-mrz-data-row:last-of-type {\n padding-bottom: 2rem;\n }\n\n .dynamsoft-mrz-data-row.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding-top: 0;\n padding-bottom: 0;\n }\n}\n",A={rootDirectory:"https://cdn.jsdelivr.net/npm/"};class P{showLoadingOverlay(e){var n,t;const i=v(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)||v(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container);this.loadingScreen=T(i,{message:e}),i.style.display="block",i.style.position="relative"}hideLoadingOverlay(e=!1){var n,t,i;const a=v(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)||v(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container);this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,a.style.display="none",e&&(null===(i=this.config)||void 0===i?void 0:i.container)&&(v(this.config.container).style.display="none"))}constructor(e){this.config=e,this.resources={},this.isInitialized=!1,this.isCapturing=!1,this.loadingScreen=null}async initialize(){if(this.isInitialized)return{resources:this.resources,components:{scannerView:this.scannerView,resultView:this.resultView}};try{if(!this.initializeMRZScannerConfig())return console.error("Failed to initialize mrz scanner config"),{resources:this.resources,components:{}};M("dynamsoft-mrz-loading-screen-style",b),this.showLoadingOverlay("Loading...");if(!await this.initializeDCVResources())return this.hideLoadingOverlay(!0),console.error("Failed to initialize DCV resources"),{resources:this.resources,components:{}};this.resources.onResultUpdated=e=>{this.resources.result=e};const e={};return this.config.scannerViewConfig&&(this.scannerView=new _(this.resources,this.config.scannerViewConfig),e.scannerView=this.scannerView,await this.scannerView.initialize()),this.config.resultViewConfig&&(this.resultView=new k(this.resources,this.config.resultViewConfig,this.scannerView),e.resultView=this.resultView),this.isInitialized=!0,{resources:this.resources,components:e}}catch(e){this.isInitialized=!1;const n=`Initialization Failed: ${(null==e?void 0:e.message)||e}`;return console.error(n),{resources:this.resources,components:{}}}finally{this.hideLoadingOverlay(!0)}}async initializeDCVResources(){var e,r,l;try{return n.CoreModule.engineResourcePaths=D(null===(e=this.config)||void 0===e?void 0:e.engineResourcePaths)?A:this.config.engineResourcePaths,t.LicenseManager._onAuthMessage=e=>e.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=mrz&deploymenttype=web)"),await t.LicenseManager.initLicense((null===(r=this.config)||void 0===r?void 0:r.license)||"",{executeNow:!0}),n.CoreModule.loadWasm(["DLR","DCP"]),s.CodeParserModule.loadSpec("MRTD_TD3_PASSPORT"),s.CodeParserModule.loadSpec("MRTD_TD1_ID"),s.CodeParserModule.loadSpec("MRTD_TD2_ID"),o.LabelRecognizerModule.loadRecognitionData("MRZ"),this.resources.cameraView=await a.CameraView.createInstance(null===(l=this.config.scannerViewConfig)||void 0===l?void 0:l.cameraEnhancerUIPath),this.resources.cameraEnhancer=await a.CameraEnhancer.createInstance(this.resources.cameraView),this.resources.cvRouter=await i.CaptureVisionRouter.createInstance(),!0}catch(e){let n=(null==e?void 0:e.message)||e;if(null==n?void 0:n.toLowerCase().includes("license")){const e="The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.";alert(e),console.error(e)}else{const e=`Resource Initialization Failed: ${n}`;alert(e),console.error(e)}return!1}}shouldCreateDefaultContainer(){var e,n;const t=!this.config.container,i=!((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container));return t&&i}createDefaultMRZScannerContainer(){const e=document.createElement("div");return e.className="mrz-scanner-main-container",Object.assign(e.style,{height:"100dvh",width:"100%",position:"absolute",left:"0",top:"0",zIndex:"999"}),document.body.append(e),e}checkForTemporaryLicense(e){return!(null==e?void 0:e.length)||(null==e?void 0:e.startsWith("A"))||(null==e?void 0:e.startsWith("L"))||(null==e?void 0:e.startsWith("P"))||(null==e?void 0:e.startsWith("Y"))?"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9":e}validateViewConfigs(){var e,n,t,i,a,s,o,r;if(!this.config.container){if((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)&&this.config.showResultView&&!(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container)){const e="MRZResultView container is required when showResultView is true";return alert(e),console.error(e),!1}if(!(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)&&(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container)&&!this.resources.result){const e="Result is needed to create MRZResultView without a scanner view";return alert(e),console.error(e),!1}}try{if(this.config.container&&!v(this.config.container)){const e="Invalid main container reference";return alert(e),console.error(e),!1}if((null===(a=this.config.scannerViewConfig)||void 0===a?void 0:a.container)&&!v(null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.container)){const e="Invalid scanner view container reference";return alert(e),console.error(e),!1}if((null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)&&!v(null===(r=this.config.resultViewConfig)||void 0===r?void 0:r.container)){const e="Invalid result view container reference";return alert(e),console.error(e),!1}}catch(e){const n=`Error accessing container references: ${e.message}`;return alert(n),console.error(n),!1}return!0}showResultView(){var e,n;return!1!==this.config.showResultView&&(this.config.container?!(void 0!==this.config.showResultView||!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container)&&!this.config.container)||!!this.config.showResultView:this.config.showResultView&&!!(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container))}initializeMRZScannerConfig(){var n,t,i,a,s,o,r;this.config=null!==(n=this.config)&&void 0!==n?n:{};if(!this.validateViewConfigs())return!1;this.shouldCreateDefaultContainer()?this.config.container=this.createDefaultMRZScannerContainer():this.config.container&&(this.config.container=v(this.config.container));const l=this.config.container?this.createViewContainers(v(this.config.container)):{},c={license:this.checkForTemporaryLicense(this.config.license),utilizedTemplateNames:Object.fromEntries(Object.values(e.EnumMRZScanMode).map((e=>{var n;return[e,(null===(n=this.config.utilizedTemplateNames)||void 0===n?void 0:n[e])||E[e]]}))),templateFilePath:(null===(t=this.config)||void 0===t?void 0:t.templateFilePath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.template.json"},d=Object.assign(Object.assign({},this.config.scannerViewConfig),{container:l[e.EnumMRZScannerViews.Scanner]||v(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.container)||null,cameraEnhancerUIPath:(null===(a=this.config.scannerViewConfig)||void 0===a?void 0:a.cameraEnhancerUIPath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.ui.html",templateFilePath:c.templateFilePath,utilizedTemplateNames:c.utilizedTemplateNames,enableMultiFrameCrossFilter:null===(o=null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.enableMultiFrameCrossFilter)||void 0===o||o,mrzFormatType:this.config.mrzFormatType}),u=this.showResultView()?Object.assign(Object.assign({},this.config.resultViewConfig),{container:l[e.EnumMRZScannerViews.Result]||v(null===(r=this.config.resultViewConfig)||void 0===r?void 0:r.container)||null}):void 0;return Object.assign(this.config,Object.assign(Object.assign({},c),{scannerViewConfig:d,resultViewConfig:u})),!0}createViewContainers(n){n.textContent="";const t=[e.EnumMRZScannerViews.Scanner];return this.showResultView()&&t.push(e.EnumMRZScannerViews.Result),t.reduce(((e,t)=>{const i=document.createElement("div");return i.className=`mrz-scanner-${t}-view-container`,Object.assign(i.style,{height:"100%",width:"100%",display:"none",position:"relative"}),n.append(i),e[t]=i,e}),{})}dispose(){var e,n;this.resultView&&(this.resultView.dispose(),this.resultView=null),this.scannerView=null,this.resources.cameraEnhancer&&(this.resources.cameraEnhancer.dispose(),this.resources.cameraEnhancer=null),this.resources.cameraView&&(this.resources.cameraView.dispose(),this.resources.cameraView=null),this.resources.cvRouter&&(this.resources.cvRouter.dispose(),this.resources.cvRouter=null),this.resources.result=null,this.resources.onResultUpdated=null;const t=e=>{const n=v(e);n&&(n.style.display="none",n.textContent="")};t(this.config.container),t(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container),t(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container),this.isInitialized=!1}async processUploadedFile(t){var i,a,s,o;try{this.showLoadingOverlay("Processing File...");const{cvRouter:r}=this.resources,l=null===(i=this.config.utilizedTemplateNames)||void 0===i?void 0:i.all,c=await r.getSimplifiedSettings(l);c.roiMeasuredInPercentage=!0,c.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await r.updateSettings(l,c);const d=await r.capture(t,l),u=d.items,m=u.filter((e=>e.type===n.EnumCapturedResultItemType.CRIT_ORIGINAL_IMAGE))[0].imageData;m.toCanvas=()=>n._toCanvas(m),m.toBlob=async()=>await n._toBlob("image/png",m);const h=null==d?void 0:d.textLineResultItems,g=null==d?void 0:d.parsedResultItems;let p={};if(null==h?void 0:h.length){const e=(null===(a=h[0])||void 0===a?void 0:a.text)||"";p=L(e,g[0])}const f={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:m,data:p,imageData:!0,_imageData:m};null===(o=(s=this.resources).onResultUpdated)||void 0===o||o.call(s,f)}catch(n){return console.error("Failed to process uploaded file:",n),{status:{code:e.EnumResultStatus.RS_FAILED,message:`Failed to process image: ${n.message||n}`}}}finally{this.hideLoadingOverlay(!1)}}async launch(n){if(this.isCapturing)throw new Error("Capture session already in progress");try{this.isCapturing=!0;const{components:t}=await this.initialize();if(D(t))throw new Error("MRZ Scanner initialization failed.");if(this.config.container&&(v(this.config.container).style.display="block"),n&&(t.scannerView=null,await this.processUploadedFile(n)),!t.scannerView&&this.resources.result&&t.resultView)return await t.resultView.launch();if(!t.scannerView&&!this.resources.result)throw new Error("Scanner view is required when no previous result exists");if(t.scannerView){const n=await t.scannerView.launch();if((null==n?void 0:n.status.code)!==e.EnumResultStatus.RS_SUCCESS)return{status:{code:null==n?void 0:n.status.code,message:(null==n?void 0:n.status.message)||"Failed to capture image"}};if(t.resultView)return await t.resultView.launch()}return this.resources.result}catch(n){return alert((null==n?void 0:n.message)||n),console.error((null==n?void 0:n.message)||n),{status:{code:e.EnumResultStatus.RS_FAILED,message:(null==n?void 0:n.message)||n}}}finally{this.isCapturing=!1,this.dispose()}}}const j={MRZScanner:P,MRZScannerView:_,MRZResultView:k};e.Core=m,e.License=h,e.CVR=g,e.DCE=p,e.DCP=f,e.DLR=y,e.Utility=R,e.DEFAULT_TEMPLATE_NAMES=E,e.DynamsoftMRZScanner=j,e.MRZDataLabel=x,e.MRZResultView=k,e.MRZScanner=P,e.MRZScannerView=_,e.displayMRZDate=V})); +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("dynamsoft-capture-vision-bundle")):"function"==typeof define&&define.amd?define(["exports","dynamsoft-capture-vision-bundle"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).Dynamsoft=e.Dynamsoft||{},e.Dynamsoft)}(this,(function(e,n){"use strict";function t(e){var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var i,a,s,o=t(n);e.EnumMRZScanMode=void 0,(i=e.EnumMRZScanMode||(e.EnumMRZScanMode={})).Passport="passport",i.TD1="td1",i.TD2="td2",i.PassportAndTD1="passportAndTd1",i.PassportAndTD2="passportAndTd2",i.TD1AndTD2="td1AndTd2",i.All="all",e.EnumMRZDocumentType=void 0,(a=e.EnumMRZDocumentType||(e.EnumMRZDocumentType={})).Passport="passport",a.TD1="td1",a.TD2="td2",e.EnumMRZScannerViews=void 0,(s=e.EnumMRZScannerViews||(e.EnumMRZScannerViews={})).Scanner="scanner",s.Result="scan-result";const r={[e.EnumMRZScanMode.Passport]:"ReadPassport",[e.EnumMRZScanMode.TD1]:"ReadId-TD1",[e.EnumMRZScanMode.TD2]:"ReadId-TD2",[e.EnumMRZScanMode.PassportAndTD1]:"ReadPassportAndId-TD1",[e.EnumMRZScanMode.PassportAndTD2]:"ReadPassportAndId-TD2",[e.EnumMRZScanMode.TD1AndTD2]:"ReadId",[e.EnumMRZScanMode.All]:"ReadPassportAndId"};var l;function c(e){if("string"==typeof e){const n=document.querySelector(e);if(!n)throw new Error("Element not found");return n}return e instanceof HTMLElement?e:null}e.EnumResultStatus=void 0,(l=e.EnumResultStatus||(e.EnumResultStatus={}))[l.RS_SUCCESS=0]="RS_SUCCESS",l[l.RS_CANCELLED=1]="RS_CANCELLED",l[l.RS_FAILED=2]="RS_FAILED";function d(e,n){if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent=n,document.head.appendChild(t)}}const u=e=>!e||0===Object.keys(e).length;function h(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}const m={"4k":{width:3840,height:2160},"2k":{width:2560,height:1440},"1080p":{width:1920,height:1080},"720p":{width:1280,height:720},"480p":{width:640,height:480}};function g(e,n={}){const{message:t,spinnerSize:i=32}=n,a=document.createElement("div");a.className="dynamsoft-mrz-loading-screen";const s=document.createElement("div");s.className="dynamsoft-mrz-loading";const o=document.createElement("div");o.className="dynamsoft-mrz-loading-content";const r=`\n \n \n \n `;if(o.innerHTML=r,t){const e=document.createElement("div");e.className="dynamsoft-mrz-loading-message",e.textContent=t,o.appendChild(e)}return s.appendChild(o),a.appendChild(s),e.appendChild(a),{element:a,updateMessage:e=>{let n=s.querySelector(".dynamsoft-mrz-loading-message");null!==e?n?n.textContent=e:(n=document.createElement("div"),n.className="dynamsoft-mrz-loading-message",n.textContent=e,o.appendChild(n)):null==n||n.remove()},hide:()=>{a&&a.parentNode&&(a.classList.add("fade-out"),setTimeout((()=>{var e;null===(e=a.parentNode)||void 0===e||e.removeChild(a)}),200))}}}const p='\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: "Verdana";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n';var f;e.EnumMRZData=void 0,(f=e.EnumMRZData||(e.EnumMRZData={})).InvalidFields="invalidFields",f.DocumentType="documentType",f.DocumentNumber="documentNumber",f.MRZText="mrzText",f.FirstName="firstName",f.LastName="lastName",f.Age="age",f.Sex="sex",f.IssuingState="issuingState",f.IssuingStateRaw="issuingStateRaw",f.Nationality="nationality",f.NationalityRaw="nationalityRaw",f.DateOfBirth="dateOfBirth",f.DateOfExpiry="dateOfExpiry";const y={[e.EnumMRZData.InvalidFields]:"Invalid Fields",[e.EnumMRZData.DocumentType]:"Document Type",[e.EnumMRZData.DocumentNumber]:"Document Number",[e.EnumMRZData.MRZText]:"MRZ Text",[e.EnumMRZData.FirstName]:"Given Name(s)",[e.EnumMRZData.LastName]:"Surname",[e.EnumMRZData.Age]:"Age",[e.EnumMRZData.Sex]:"Sex",[e.EnumMRZData.IssuingState]:"Issuing State",[e.EnumMRZData.IssuingStateRaw]:"Issuing State (Raw Value)",[e.EnumMRZData.Nationality]:"Nationality",[e.EnumMRZData.NationalityRaw]:"Nationality State (Raw Value)",[e.EnumMRZData.DateOfBirth]:"Date Of Birth (YYYY-MM-DD)",[e.EnumMRZData.DateOfExpiry]:"Date Of Expiry (YYYY-MM-DD)"};function R(e,n,t,i=!1){const a=parseInt(e,10);let s;if(i)s=a>=60?1900+a:2e3+a;else{s=a>(new Date).getFullYear()%100?1900+a:2e3+a}return{year:s,month:parseInt(n,10),day:parseInt(t,10)}}function w(e){const n=e=>{var n;return 1===(null===(n=`${e}`)||void 0===n?void 0:n.length)?`0${e}`:e};return`${null==e?void 0:e.year}-${n(null==e?void 0:e.month)}${(null==e?void 0:e.day)&&`-${n(null==e?void 0:e.day)}`}`}function E(e){return"D<<"===e?"D":e}function v(t,i){const a=[],s=e=>i.getFieldValidationStatus(e)===n.EnumValidationStatus.VS_FAILED,o=i.codeType,r=function(n){switch(n){case"MRTD_TD1_ID":return e.EnumMRZDocumentType.TD1;case"MRTD_TD2_ID":case"MRTD_TD2_VISA":case"MRTD_TD2_FRENCH_ID":return e.EnumMRZDocumentType.TD2;case"MRTD_TD3_PASSPORT":case"MRTD_TD3_VISA":return e.EnumMRZDocumentType.Passport;default:throw new Error(`Unknown document type: ${n}`)}}(o),l=function(e){switch(e){case"MRTD_TD1_ID":return"ID (TD1)";case"MRTD_TD2_ID":return"ID (TD2)";case"MRTD_TD2_VISA":return"ID (VISA)";case"MRTD_TD2_FRENCH_ID":return"French ID (TD2)";case"MRTD_TD3_PASSPORT":return"Passport (TD3)";case"MRTD_TD3_VISA":return"Visa (TD3)";default:throw new Error(`Unknown document type: ${e}`)}}(o),c=r===e.EnumMRZDocumentType.Passport&&"MRTD_TD3_PASSPORT"===o?"passportNumber":"documentNumber",d=R(i.getFieldValue("birthYear"),i.getFieldValue("birthMonth"),i.getFieldValue("birthDay")),u=R(i.getFieldValue("expiryYear"),i.getFieldValue("expiryMonth"),i.getFieldValue("expiryDay"),!0);["birthYear","birthMonth","birthDay"].forEach((n=>{s(n)&&a.push(e.EnumMRZData.DateOfBirth)})),["expiryYear","expiryMonth","expiryDay"].forEach((n=>{s(n)&&a.push(e.EnumMRZData.DateOfExpiry)}));const m={[e.EnumMRZData.LastName]:i.getFieldValue("primaryIdentifier"),[e.EnumMRZData.FirstName]:i.getFieldValue("secondaryIdentifier"),[e.EnumMRZData.Nationality]:i.getFieldValue("nationality"),[e.EnumMRZData.NationalityRaw]:E(i.getFieldRawValue("nationality")),[e.EnumMRZData.DocumentNumber]:i.getFieldValue(c)||i.getFieldValue("longDocumentNumber"),[e.EnumMRZData.IssuingState]:i.getFieldValue("issuingState"),[e.EnumMRZData.IssuingStateRaw]:E(i.getFieldRawValue("issuingState")),[e.EnumMRZData.Sex]:h(i.getFieldValue("sex"))};Object.keys(m).forEach((n=>{let t=!1;switch(n){case e.EnumMRZData.FirstName:t=s("secondaryIdentifier");break;case e.EnumMRZData.LastName:t=s("primaryIdentifier");break;case e.EnumMRZData.DocumentNumber:t=s(c)||s("longDocumentNumber");break;default:t=s(n)}t&&a.push(n)}));const g=function(e){const n=new Date,t=n.getMonth()+1>e.month||n.getMonth()+1===e.month&&n.getDate()>=e.day;return n.getFullYear()-e.year-(t?0:1)}(d);g<1&&a.push(e.EnumMRZData.Age);return{[e.EnumMRZData.InvalidFields]:a,[e.EnumMRZData.FirstName]:m[e.EnumMRZData.FirstName],[e.EnumMRZData.LastName]:m[e.EnumMRZData.LastName],[e.EnumMRZData.Age]:g,[e.EnumMRZData.DateOfBirth]:d,[e.EnumMRZData.Sex]:m[e.EnumMRZData.Sex],[e.EnumMRZData.Nationality]:m[e.EnumMRZData.Nationality],[e.EnumMRZData.NationalityRaw]:m[e.EnumMRZData.NationalityRaw],[e.EnumMRZData.DocumentNumber]:m[e.EnumMRZData.DocumentNumber],[e.EnumMRZData.DateOfExpiry]:u,[e.EnumMRZData.IssuingState]:m[e.EnumMRZData.IssuingState],[e.EnumMRZData.IssuingStateRaw]:m[e.EnumMRZData.IssuingStateRaw],[e.EnumMRZData.DocumentType]:h(l),[e.EnumMRZData.MRZText]:t}}const M={[e.EnumMRZDocumentType.TD1]:{width:85.6,height:53.98},[e.EnumMRZDocumentType.TD2]:{width:105,height:74},[e.EnumMRZDocumentType.Passport]:{width:125,height:88}};class D{showScannerLoadingOverlay(e){const n=c(this.config.container);this.loadingScreen=g(n,{message:e}),n.style.display="block",n.style.position="relative"}hideScannerLoadingOverlay(e=!1){this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,e&&(c(this.config.container).style.display="none"))}constructor(n,t){this.resources=n,this.config=t,this.isSoundFeedbackOn=!1,this.scanModeManager={[e.EnumMRZDocumentType.Passport]:!0,[e.EnumMRZDocumentType.TD1]:!0,[e.EnumMRZDocumentType.TD2]:!0},this.currentScanMode=e.EnumMRZScanMode.All,this.resizeTimer=null,this.capturedResultItems=[],this.originalImageData=null,this.initialized=!1,this.initializedDCE=!1,this.DCE_ELEMENTS={selectCameraBtn:null,uploadImageBtn:null,soundFeedbackBtn:null,closeScannerBtn:null,scanModeSelectContainer:null,passportModeOption:null,td1ModeOption:null,td2ModeOption:null,toast:null},this.loadingScreen=null,this.handleResize=()=>{this.toggleScanGuide(!1),this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((()=>{this.toggleScanGuide(!0)}),500)},this.firstFrame=!0}async initialize(){if(!this.initialized){this.initializeScanModeManager(),this.currentScanMode=this.getScanMode(),d("dynamsoft-mrz-loading-screen-style",p);try{const{cameraView:e,cameraEnhancer:t,cvRouter:i}=this.resources;if(e.setScanRegionMaskStyle({strokeStyle:"transparent",fillStyle:"transparent",lineWidth:0}),e.setVideoFit("cover"),i.setInput(t),!0===this.config.enableMultiFrameCrossFilter){const e=new n.MultiFrameResultCrossFilter;e.enableResultCrossVerification(n.EnumCapturedResultItemType.CRIT_TEXT_LINE,!0),await i.addResultFilter(e)}const a=new n.CapturedResultReceiver;a.onCapturedResultReceived=e=>this.handleMRZResult(e),await i.addResultReceiver(a),this.toggleSoundFeedback(!1),!1===this.config.showScanGuide&&this.toggleScanGuide(!1),this.initialized=!0}catch(n){let t=(null==n?void 0:n.message)||n;console.error(t),alert(t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:"Dynamsoft MRZ Scanner initialize error"}};this.currentScanResolver(i)}}}initializeElements(){var e;const n=c(this.config.container),t=n.children[n.children.length-1];if(!(null==t?void 0:t.shadowRoot))throw new Error("Shadow root not found");if(this.DCE_ELEMENTS={selectCameraBtn:t.shadowRoot.querySelector(".dce-mn-select-camera-icon"),uploadImageBtn:t.shadowRoot.querySelector(".dce-mn-upload-image-icon"),soundFeedbackBtn:t.shadowRoot.querySelector(".dce-mn-sound-feedback"),closeScannerBtn:t.shadowRoot.querySelector(".dce-mn-close"),scanModeSelectContainer:t.shadowRoot.querySelector(".dce-mn-scan-mode-select"),passportModeOption:t.shadowRoot.querySelector(".scan-mode-option-passport"),td1ModeOption:t.shadowRoot.querySelector(".scan-mode-option-td1"),td2ModeOption:t.shadowRoot.querySelector(".scan-mode-option-td2"),toast:t.shadowRoot.querySelector(".dce-mn-toast")},this.setupScanModeSelector(),this.assignDCEClickEvents(),this.DCE_ELEMENTS.toast.style.display="none",!1===this.config.showUploadImage&&(this.DCE_ELEMENTS.uploadImageBtn.style.visibility="hidden"),!1===this.config.showSoundToggle&&(this.DCE_ELEMENTS.soundFeedbackBtn.style.visibility="hidden"),!1===(null===(e=this.config)||void 0===e?void 0:e.showPoweredByDynamsoft)){t.shadowRoot.querySelector(".dce-mn-msg-poweredby").style.display="none"}this.initializedDCE=!0}setupScanModeSelector(){if(!1!==this.config.showFormatSelector)switch(this.currentScanMode){case e.EnumMRZScanMode.PassportAndTD1:this.DCE_ELEMENTS.td2ModeOption.style.display="none";break;case e.EnumMRZScanMode.PassportAndTD2:this.DCE_ELEMENTS.td1ModeOption.style.display="none";break;case e.EnumMRZScanMode.TD1AndTD2:this.DCE_ELEMENTS.passportModeOption.style.display="none";break;case e.EnumMRZScanMode.All:break;default:this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}else this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}assignDCEClickEvents(){if(!Object.values(this.DCE_ELEMENTS).every(Boolean))throw new Error("Camera control elements not found");this.closeCamera=this.closeCamera.bind(this),this.DCE_ELEMENTS.uploadImageBtn.onclick=()=>this.uploadFile(),this.DCE_ELEMENTS.soundFeedbackBtn.onclick=()=>this.toggleSoundFeedback(),this.DCE_ELEMENTS.closeScannerBtn.onclick=()=>this.handleCloseBtn(),this.DCE_ELEMENTS.selectCameraBtn.onclick=e=>{e.stopPropagation(),this.toggleSelectCameraBox()},this.DCE_ELEMENTS.passportModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.passportModeOption.style.display&&await this.toggleScanDocType(e.EnumMRZDocumentType.Passport)},this.DCE_ELEMENTS.td1ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td1ModeOption.style.display&&await this.toggleScanDocType(e.EnumMRZDocumentType.TD1)},this.DCE_ELEMENTS.td2ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td2ModeOption.style.display&&await this.toggleScanDocType(e.EnumMRZDocumentType.TD2)}}handleCloseBtn(){this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:e.EnumResultStatus.RS_CANCELLED,message:"Cancelled"}})}attachOptionClickListeners(){const e=c(this.config.container),n=e.children[e.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const t=n.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings");[...n.shadowRoot.querySelectorAll(".dce-mn-camera-option"),...n.shadowRoot.querySelectorAll(".dce-mn-resolution-option")].forEach((e=>{e.addEventListener("click",(async n=>{const i=e.getAttribute("data-davice-id"),a=e.getAttribute("data-height"),s=e.getAttribute("data-width");i?this.resources.cameraEnhancer.selectCamera(i).then((()=>{this.toggleScanGuide()})):a&&s&&this.resources.cameraEnhancer.setResolution({width:parseInt(s),height:parseInt(a)}).then((()=>{this.toggleScanGuide()})),"none"!==t.style.display&&this.toggleSelectCameraBox()}))}))}highlightCameraAndResolutionOption(){const e=c(this.config.container),n=e.children[e.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const t=n.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings"),i=t.querySelectorAll(".dce-mn-camera-option"),a=t.querySelectorAll(".dce-mn-resolution-option"),s=this.resources.cameraEnhancer.getSelectedCamera(),o=this.resources.cameraEnhancer.getResolution();i.forEach((e=>{const n=e;n.getAttribute("data-davice-id")===(null==s?void 0:s.deviceId)?n.style.border="2px solid #fe814a":n.style.border="none"}));const r={"480p":"480","720p":"720","1080p":"1080","2k":"1440","4k":"2160"},l=function(e){const n=e.width*e.height,t=e.width/e.height;let i="480p",a=Number.MAX_VALUE;for(const[e,s]of Object.entries(m)){const o=s.width*s.height,r=s.width/s.height,l=.7*Math.abs(o-n)+Math.abs(r-t)*o*.3;l{const n=e,t=n.getAttribute("data-height");n.style.border=t===r[l]?"2px solid #fe814a":"none"}))}toggleSelectCameraBox(){const e=c(this.config.container),n=e.children[e.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const t=n.shadowRoot.querySelector(".dce-mn-resolution-box");this.highlightCameraAndResolutionOption(),this.attachOptionClickListeners(),t.click()}async relaunch(){}async uploadFile(){var t,i,a,s,o,r;const{cvRouter:l}=this.resources,c=document.createElement("input");c.type="file",c.accept=null!==(t=this.config.uploadAcceptedTypes)&&void 0!==t?t:"image/*",c.style.display="none",document.body.appendChild(c);try{this.showScannerLoadingOverlay("Processing file..."),await this.closeCamera(!1);const t=await new Promise(((e,n)=>{c.onchange=t=>{var i;const a=null===(i=t.target.files)||void 0===i?void 0:i[0];a?e(a):n(new Error("No file selected"))},c.addEventListener("cancel",(async()=>{this.hideScannerLoadingOverlay(!1),this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()})),c.click()}));if(!t)return;let d;if(this.config.uploadFileConverter&&!t.type.startsWith("image/"))try{d=await this.config.uploadFileConverter(t)}catch(e){throw new Error(`Error converting file: ${e.message}`)}else{if(!t.type.startsWith("image/"))throw new Error("Unsupported file type. Please provide a converter function for this file type.");d=t}const u=this.config.utilizedTemplateNames[this.currentScanMode];if(!1!==this.config.showScanGuide){const e=await l.getSimplifiedSettings(u);e.roiMeasuredInPercentage=!0,e.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await l.updateSettings(u,e)}const h=await l.capture(d,u);this.capturedResultItems=h.items;const m=this.capturedResultItems.filter((e=>e.type===n.EnumCapturedResultItemType.CRIT_ORIGINAL_IMAGE));if(0===m.length)throw new Error("No image data found in the captured result");const g=m[0].imageData;g.toCanvas=()=>n._toCanvas(g),g.toBlob=async()=>await n._toBlob("image/png",g),this.originalImageData=g;const p=null===(i=null==h?void 0:h.parsedResult)||void 0===i?void 0:i.parsedResultItems;let f={};if(null==p?void 0:p.length){const e=(null===(s=null===(a=p[0])||void 0===a?void 0:a.referencedItem)||void 0===s?void 0:s.text)||"";f=v(e,p[0])}const y={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:f,imageData:!0,_imageData:this.originalImageData};null===(r=(o=this.resources).onResultUpdated)||void 0===r||r.call(o,y),this.currentScanResolver(y)}catch(n){let t=(null==n?void 0:n.message)||n;console.error(t),alert(t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:`Error processing file: ${t}`}};this.currentScanResolver(i)}finally{this.hideScannerLoadingOverlay(!0),document.body.removeChild(c)}}toggleSoundFeedback(e){this.isSoundFeedbackOn=void 0!==e?e:!this.isSoundFeedbackOn;const n=c(this.config.container),t=n.children[n.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const i=t.shadowRoot.querySelector(".dce-mn-sound-feedback"),a=i.querySelector(".dce-mn-sound-feedback-on");i.querySelector(".dce-mn-sound-feedback-off").style.display=this.isSoundFeedbackOn?"none":"block",a.style.display=this.isSoundFeedbackOn?"block":"none"}calculateScanRegion(e){const{cameraEnhancer:n,cameraView:t}=this.resources;if(!n||!n.isOpen())return;const i=M[e].width/M[e].height;let a;const s=t.getVisibleRegionOfVideo({inPixels:!0}),{width:o,height:r}=s;if(s){if(s.width>s.height){const e=.5*r*i,n=Math.round(e/o*100),t=(100-n)/2;a={left:t,right:t+n,top:25,bottom:75,isMeasuredInPercentage:!0}}else{const e=.9*o/i,n=Math.round(e/r*100),t=(100-n)/2;a={left:5,right:95,top:t,bottom:t+n,isMeasuredInPercentage:!0}}null==t||t.setScanRegionMaskVisible(!0),n.setScanRegion(a)}}toggleScanGuide(n){const t=c(this.config.container),i=t.children[t.children.length-1];if(!(null==i?void 0:i.shadowRoot))return;const a=i.shadowRoot.querySelector(".dce-scanguide-passport"),s=i.shadowRoot.querySelector(".dce-scanguide-td1"),o=i.shadowRoot.querySelector(".dce-scanguide-td2");if(!1===n||!1===this.config.showScanGuide)return a.style.display="none",s.style.display="none",void(o.style.display="none");switch(this.currentScanMode){case e.EnumMRZScanMode.All:case e.EnumMRZScanMode.Passport:case e.EnumMRZScanMode.PassportAndTD1:case e.EnumMRZScanMode.PassportAndTD2:a.style.display="block",s.style.display="none",o.style.display="none",this.calculateScanRegion(e.EnumMRZDocumentType.Passport);break;case e.EnumMRZScanMode.TD1:case e.EnumMRZScanMode.TD1AndTD2:a.style.display="none",s.style.display="block",o.style.display="none",this.calculateScanRegion(e.EnumMRZDocumentType.TD1);break;case e.EnumMRZScanMode.TD2:a.style.display="none",s.style.display="none",o.style.display="block",this.calculateScanRegion(e.EnumMRZDocumentType.TD2)}}async openCamera(){try{const{cameraEnhancer:e,cameraView:n}=this.resources,t=c(this.config.container);if(t.style.display="block",e.isOpen())e.isPaused()&&await e.resume();else{const i=n.getUIElement();i.parentElement||t.append(i),await e.open()}await e.setResolution({width:2560,height:1440}),!this.initializedDCE&&e.isOpen()&&await this.initializeElements(),window.addEventListener("resize",this.handleResize);const i=t.children[t.children.length-1];if(!(null==i?void 0:i.shadowRoot))throw new Error("Shadow root not found");i.shadowRoot.querySelector(".dce-mn-torch-off").style.display="none",i.shadowRoot.querySelector(".dce-mn-torch-on").style.display="none"}catch(n){let t=(null==n?void 0:n.message)||n;console.error(t),alert(t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:"MRZ Scanner Open Camera Error"}};this.currentScanResolver(i)}}async closeCamera(e=!0){try{window.removeEventListener("resize",this.handleResize),this.resizeTimer&&(window.clearTimeout(this.resizeTimer),this.resizeTimer=null);const{cameraEnhancer:n,cameraView:t}=this.resources,i=c(this.config.container);i.style.display=e?"none":"block",(null==t?void 0:t.getUIElement().parentElement)&&i.removeChild(t.getUIElement()),n.close(),this.stopCapturing()}catch(e){let n=(null==e?void 0:e.message)||e;console.error(`Close Camera error: ${n}`)}}pauseCamera(){const{cameraEnhancer:e}=this.resources;e.pause()}stopCapturing(){const{cameraView:e,cvRouter:n}=this.resources;n.stopCapturing(),e.clearAllInnerDrawingItems()}async handleMRZResult(t){var i,a,s;if(this.firstFrame)this.firstFrame=!1;else if(!(t.items.length<=1)){this.capturedResultItems=t.items;try{const{onResultUpdated:o}=this.resources,r=t.items.filter((e=>e.type===n.EnumCapturedResultItemType.CRIT_ORIGINAL_IMAGE))[0].imageData;r.toCanvas=()=>n._toCanvas(r),r.toBlob=async()=>await n._toBlob("image/png",r),this.originalImageData=r;const l=null===(i=null==t?void 0:t.parsedResult)||void 0===i?void 0:i.parsedResultItems;if(null==l?void 0:l.length){this.isSoundFeedbackOn&&n.Feedback.beep();const t=(null===(s=null===(a=l[0])||void 0===a?void 0:a.referencedItem)||void 0===s?void 0:s.text)||"",i=v(t,l[0]);this.closeCamera();const r={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:i,imageData:!0,_imageData:this.originalImageData};null==o||o(r),this.currentScanResolver(r)}}catch(n){let t=(null==n?void 0:n.message)||n;console.error(t),alert(t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:"Error capturing image"}};this.currentScanResolver(i)}}}initializeScanModeManager(){const{mrzFormatType:n}=this.config;if(this.scanModeManager={[e.EnumMRZDocumentType.Passport]:!0,[e.EnumMRZDocumentType.TD1]:!0,[e.EnumMRZDocumentType.TD2]:!0},!n||Array.isArray(n)&&0===n.length)return;Object.keys(this.scanModeManager).forEach((e=>{this.scanModeManager[e]=!1}));(Array.isArray(n)?n:[n]).forEach((e=>{this.scanModeManager[e]=!0}))}getScanMode(){const n=Object.entries(this.scanModeManager).filter((([e,n])=>n)).map((([e])=>e)).sort().join(",");return{[e.EnumMRZDocumentType.Passport]:e.EnumMRZScanMode.Passport,[e.EnumMRZDocumentType.TD1]:e.EnumMRZScanMode.TD1,[e.EnumMRZDocumentType.TD2]:e.EnumMRZScanMode.TD2,[`${e.EnumMRZDocumentType.Passport},${e.EnumMRZDocumentType.TD1}`]:e.EnumMRZScanMode.PassportAndTD1,[`${e.EnumMRZDocumentType.Passport},${e.EnumMRZDocumentType.TD2}`]:e.EnumMRZScanMode.PassportAndTD2,[`${e.EnumMRZDocumentType.TD1},${e.EnumMRZDocumentType.TD2}`]:e.EnumMRZScanMode.TD1AndTD2,[`${e.EnumMRZDocumentType.Passport},${e.EnumMRZDocumentType.TD1},${e.EnumMRZDocumentType.TD2}`]:e.EnumMRZScanMode.All,"":e.EnumMRZScanMode.All}[n]}DCEShowToast(e,n=3e3){this.DCE_ELEMENTS.toast&&(this.DCE_ELEMENTS.toast.textContent=e,this.DCE_ELEMENTS.toast.style.display="",setTimeout((()=>{this.DCE_ELEMENTS.toast.style.display="none"}),n))}async startCapturing(){const{cvRouter:t,cameraEnhancer:i}=this.resources,a=this.config.utilizedTemplateNames[this.currentScanMode];try{if(!1!==this.config.showScanGuide){const e=await t.getSimplifiedSettings(a);e.roiMeasuredInPercentage=!0,e.roi.points=[{x:0,y:50},{x:100,y:50},{x:100,y:100},{x:0,y:100}],await t.updateSettings(a,e)}this.firstFrame=!0,await t.startCapturing(a),i.setPixelFormat(n.EnumImagePixelFormat.IPF_ABGR_8888)}catch(n){let t=(null==n?void 0:n.message)||n;console.error("Failed to start capturing:",t),this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:e.EnumResultStatus.RS_FAILED,message:"Failed to start capturing"}})}}async toggleScanDocType(n){try{if(this.scanModeManager[n]&&0===Object.entries(this.scanModeManager).filter((([e,t])=>t&&e!==n)).length)return console.warn("MRZ Scanner - At least one mode must be enabled"),void this.DCEShowToast("At least one mode must be enabled");this.scanModeManager[n]=!this.scanModeManager[n],this.currentScanMode=this.getScanMode(),this.stopCapturing(),this.toggleScanGuide(),await this.startCapturing(),this.DCE_ELEMENTS.td1ModeOption.classList.toggle("selected",this.scanModeManager[e.EnumMRZDocumentType.TD1]),this.DCE_ELEMENTS.td2ModeOption.classList.toggle("selected",this.scanModeManager[e.EnumMRZDocumentType.TD2]),this.DCE_ELEMENTS.passportModeOption.classList.toggle("selected",this.scanModeManager[e.EnumMRZDocumentType.Passport])}catch(n){let t=(null==n?void 0:n.message)||n;console.error("MRZ Scanner switch scan mode error: ",t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:"MRZ Scanner switch scan mode error"}};this.currentScanResolver(i)}}async launch(){try{await this.initialize();const{cvRouter:e,cameraEnhancer:n}=this.resources;return new Promise((async e=>{this.currentScanResolver=e,this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),!this.initializedDCE&&n.isOpen()&&await this.initializeElements(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()}))}catch(n){let t=(null==n?void 0:n.message)||n;console.error("MRZ Scanner launch error: ",t),this.closeCamera();const i={status:{code:e.EnumResultStatus.RS_FAILED,message:"MRZ Scanner launch error"}};this.currentScanResolver(i)}}}const S={cancel:'\n\n \n \n \n \n \n \n \n \n \n \n ',rescan:'\n\n\n \n\n\n\n\n\n\n\n',complete:'\n\n\n\n \n\n\n\n\n\n\n\n',failed:'\n \n \n \n\n',info:'\n\n \n \n \n\n'};class C{constructor(e,n,t){this.resources=e,this.config=n,this.scannerView=t,this.editedFields={}}async launch(){try{return c(this.config.container).textContent="",await this.initialize(),c(this.config.container).style.display="flex",new Promise((e=>{this.currentScanResultViewResolver=e}))}catch(e){let n=(null==e?void 0:e.message)||e;throw console.error(n),n}}async handleRescan(){var n;try{if(!this.scannerView)return void console.error("Scanner View not initialized");this.hideView();const t=await this.scannerView.launch();if((null===(n=null==t?void 0:t.status)||void 0===n?void 0:n.code)===e.EnumResultStatus.RS_FAILED)return void(this.currentScanResultViewResolver&&this.currentScanResultViewResolver(t));this.resources.onResultUpdated&&((null==t?void 0:t.status.code)===e.EnumResultStatus.RS_CANCELLED?this.resources.onResultUpdated(this.resources.result):(null==t?void 0:t.status.code)===e.EnumResultStatus.RS_SUCCESS&&this.resources.onResultUpdated(t)),this.dispose(!0),await this.initialize(),c(this.config.container).style.display="flex"}catch(n){throw console.error("Error in rescan handler:",n),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:e.EnumResultStatus.RS_FAILED,message:(null==n?void 0:n.message)||n}}),n}}async handleCancel(){var n;try{(null===(n=this.config)||void 0===n?void 0:n.onCancel)&&await this.config.onCancel(this.resources.result),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:e.EnumResultStatus.RS_CANCELLED,message:"Upload file cancelled"}}),this.hideView(),this.dispose()}catch(n){throw console.error("Error in cancel handler:",n),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:e.EnumResultStatus.RS_FAILED,message:(null==n?void 0:n.message)||n}}),n}}async handleDone(){var n,t;try{(null===(n=this.resources.result)||void 0===n?void 0:n.data)&&!u(this.editedFields)&&(this.resources.result.data=Object.assign(Object.assign({},this.resources.result.data),this.editedFields),this.resources.onResultUpdated&&this.resources.onResultUpdated(this.resources.result)),(null===(t=this.config)||void 0===t?void 0:t.onDone)&&await this.config.onDone(this.resources.result),this.currentScanResultViewResolver&&this.resources.result&&this.currentScanResultViewResolver(this.resources.result),this.hideView(),this.dispose()}catch(n){throw console.error("Error in done handler:",n),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:e.EnumResultStatus.RS_FAILED,message:(null==n?void 0:n.message)||n}}),n}}createControls(){var e,n,t,i,a,s,o,r,l,c,u,h;const{toolbarButtonsConfig:m}=this.config;return function(e){d("dynamsoft-mrz-controls-style","\n .dynamsoft-mrz-controls {\n display: flex;\n height: 6rem;\n background-color: #323234;\n align-items: center;\n font-size: 12px;\n font-family: Verdana;\n color: white;\n width: 100%;\n }\n\n .dynamsoft-mrz-control-btn {\n background-color: #323234;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n gap: 0.5rem;\n text-align: center;\n user-select: none;\n }\n\n .dynamsoft-mrz-control-btn.hide {\n display: none;\n }\n\n .dynamsoft-mrz-control-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n cursor: default;\n }\n\n .dynamsoft-mrz-control-icon-wrapper {\n flex: 0.75;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n min-height: 40px;\n }\n\n .dynamsoft-mrz-control-icon img,\n .dynamsoft-mrz-control-icon svg {\n width: 32px;\n height: 32px;\n fill: #fe8e14;\n }\n\n .dynamsoft-mrz-control-text {\n flex: 0.5;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-bottom: 0.5rem;\n }\n\n \n @media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-controls {\n flex-direction: column;\n height: 100%;\n width: 5rem;\n }\n\n .dynamsoft-mrz-control-text {\n padding: 0 0.5rem 0.5rem;\n }\n }\n");const n=document.createElement("div");return n.className="dynamsoft-mrz-controls",e.forEach((e=>{const t=document.createElement("div");t.className=`dynamsoft-mrz-control-btn ${null==e?void 0:e.className}`;const i=document.createElement("div");if(i.className="dynamsoft-mrz-control-icon-wrapper",(a=e.icon).trim().startsWith(""))i.innerHTML=e.icon;else{const n=document.createElement("img");n.src=e.icon,n.alt=e.label,n.width=24,n.height=24,i.appendChild(n)}var a;const s=document.createElement("div");s.className="dynamsoft-mrz-control-text",s.textContent=e.label,e.isDisabled&&t.classList.add("disabled"),e.isHidden&&t.classList.add("hide"),t.appendChild(i),t.appendChild(s),e.onClick&&!e.isDisabled&&t.addEventListener("click",e.onClick),n.appendChild(t)})),n}([this.config._isFileMode?{id:"dynamsoft-mrz-scanResult-cancel",icon:(null===(e=null==m?void 0:m.cancel)||void 0===e?void 0:e.icon)||S.cancel,label:(null===(n=null==m?void 0:m.cancel)||void 0===n?void 0:n.label)||"Cancel",onClick:()=>this.handleCancel(),className:`${(null===(t=null==m?void 0:m.cancel)||void 0===t?void 0:t.className)||""}`,isHidden:(null===(i=null==m?void 0:m.cancel)||void 0===i?void 0:i.isHidden)||!1}:{id:"dynamsoft-mrz-scanResult-rescan",icon:(null===(a=null==m?void 0:m.rescan)||void 0===a?void 0:a.icon)||S.rescan,label:(null===(s=null==m?void 0:m.rescan)||void 0===s?void 0:s.label)||"Re-scan",onClick:()=>this.handleRescan(),className:`${(null===(o=null==m?void 0:m.rescan)||void 0===o?void 0:o.className)||""}`,isHidden:(null===(r=null==m?void 0:m.rescan)||void 0===r?void 0:r.isHidden)||!1,isDisabled:!this.scannerView},{id:"dynamsoft-mrz-scanResult-done",icon:(null===(l=null==m?void 0:m.done)||void 0===l?void 0:l.icon)||S.complete,label:(null===(c=null==m?void 0:m.done)||void 0===c?void 0:c.label)||"Done",className:`${(null===(u=null==m?void 0:m.done)||void 0===u?void 0:u.className)||""}`,isHidden:(null===(h=null==m?void 0:m.done)||void 0===h?void 0:h.isHidden)||!1,onClick:()=>this.handleDone()}])}handleFieldEdit(n,t){if(n===e.EnumMRZData.DateOfBirth||n===e.EnumMRZData.DateOfExpiry)try{const[e,i,a]=t.split(/[\/\-\.]/);a&&i&&e&&(this.editedFields[n]={day:parseInt(a,10),month:parseInt(i,10),year:parseInt(e,10)})}catch(e){console.error("Error parsing date",e)}else this.editedFields[n]=t}createMRZDataDisplay(){var n,t,i,a;const s=(null===(n=this.resources.result)||void 0===n?void 0:n.data)||{},o=!!this.config.allowResultEditing,r=s.invalidFields||[],l=[e.EnumMRZData.InvalidFields,e.EnumMRZData.IssuingStateRaw,e.EnumMRZData.NationalityRaw];!1===(null===(t=this.config)||void 0===t?void 0:t.showMRZText)&&l.push(e.EnumMRZData.MRZText);const c=document.createElement("div");if(c.className="dynamsoft-mrz-data-container",u(s)){const e=document.createElement("div");return e.className="dynamsoft-mrz-data-row empty",e.innerText=null!==(a=null===(i=this.config)||void 0===i?void 0:i.emptyResultMessage)&&void 0!==a?a:"The necessary information couldn't be detected. Please try again.",c.appendChild(e),c}if(r.length>0){const e=document.createElement("div");e.className="dynamsoft-mrz-error-notification",e.innerHTML=`\n
${S.failed}
\n
\n ${o?"Some fields require correction. Please review highlighted fields.":"Some fields contain invalid information. Please rescan the document."}\n
\n `,c.appendChild(e)}else if(0===r.length&&o){const e=document.createElement("div");e.className="dynamsoft-mrz-info-notification",e.innerHTML=`\n
${S.info}
\n
\n Please review all fields to ensure the information is correct.\n
\n `,c.appendChild(e)}return Object.entries(s).forEach((([n,t])=>{if(l.includes(n)||!t)return;const i=document.createElement("div");i.className="dynamsoft-mrz-data-row";const a=r.includes(n);a&&i.classList.add("invalid-field");const s=[e.EnumMRZData.MRZText,e.EnumMRZData.DocumentType,e.EnumMRZData.IssuingStateRaw,e.EnumMRZData.NationalityRaw],d=document.createElement("span");if(d.className="dynamsoft-mrz-data-label",d.innerText=y[n]||n,a){const e=document.createElement("span");if(e.className="dynamsoft-mrz-error-icon",e.innerHTML=S.failed,d.appendChild(e),o){const e=document.createElement("span");e.className="dynamsoft-mrz-error-hint",e.textContent="Please correct this field",d.appendChild(e)}}const u=document.createElement("div");if(u.className="dynamsoft-mrz-data-value",o&&!s.includes(n)){const s=document.createElement("input");s.className="dynamsoft-mrz-data-input",a&&s.classList.add("invalid"),n===e.EnumMRZData.DateOfBirth||n===e.EnumMRZData.DateOfExpiry?(s.value=w(t),s.setAttribute("placeholder","YYYY-MM-DD")):s.value=t,s.addEventListener("input",(e=>{if(this.handleFieldEdit(n,e.target.value),a){s.classList.remove("invalid"),i.classList.remove("invalid-field"),this.editedFields.invalidFields||(this.editedFields.invalidFields=[...r]);const e=this.editedFields.invalidFields.indexOf(n);e>-1&&this.editedFields.invalidFields.splice(e,1)}})),u.appendChild(s)}else n===e.EnumMRZData.MRZText?(u.classList.add("code"),u.innerText=t):n===e.EnumMRZData.DateOfBirth||n===e.EnumMRZData.DateOfExpiry?u.innerText=w(t):u.innerText=t,a&&u.classList.add("invalid-value");i.appendChild(d),i.appendChild(u),c.appendChild(i)})),c}async initialize(){try{if(!this.resources.result)throw Error("Captured image is missing. Please capture an image first!");if(!this.config.container)throw new Error("Please create a Scan Result View Container element");d("dynamsoft-mrz-result-view-style",T);const e=document.createElement("div");if(e.className="dynamsoft-mrz-result-view-container",!1!==this.config.showOriginalImage){const n=this.resources.result.originalImageResult,t=document.createElement("div");let i;t.className="dynamsoft-mrz-result-view-image-container",(null==n?void 0:n.toCanvas)&&(i=null==n?void 0:n.toCanvas()),Object.assign(i.style,{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}),t.appendChild(i),e.appendChild(t)}const n=this.createMRZDataDisplay();e.appendChild(n);const t=this.createControls();e.appendChild(t),c(this.config.container).appendChild(e)}catch(e){let n=(null==e?void 0:e.message)||e;console.error(n),alert(n)}}hideView(){c(this.config.container).style.display="none"}dispose(e=!1){c(this.config.container).textContent="",e||(this.currentScanResultViewResolver=void 0)}}const T="\n .dynamsoft-mrz-result-view-container {\n display: flex;\n width: 100%;\n height: 100%;\n background-color:#575757;\n font-size: 12px;\n flex-direction: column;\n align-items: center;\n }\n\n .dynamsoft-mrz-result-view-image-container {\n width: 100%;\n height: 200px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #323234;\n }\n\n \n.dynamsoft-mrz-data-container {\n font-size: 16px;\n font-family: Verdana;\n color: white;\n overflow: auto;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 1rem 0;\n}\n\n.dynamsoft-mrz-data-row {\n padding: 0.5rem 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n transition: background-color 0.3s ease;\n}\n\n.dynamsoft-mrz-data-row.invalid-field {\n background-color: rgba(231, 76, 60, 0.1);\n border-left: 3px solid #e74c3c;\n padding-left: calc(2rem - 3px);\n}\n\n.dynamsoft-mrz-data-label {\n color: #aaa;\n display: flex;\n gap: 0.5rem;\n align-items: end;\n flex-wrap: wrap;\n}\n\n.dynamsoft-mrz-error-notification,\n.dynamsoft-mrz-info-notification {\n color: white;\n padding: 1rem;\n margin: 0.5rem 2rem;\n border-radius: 4px;\n display: flex;\n align-items: center;\n gap: 1rem;\n text-align: start;\n}\n\n.dynamsoft-mrz-error-notification {\n background-color: rgba(231, 76, 60, 0.2);\n}\n\n.dynamsoft-mrz-info-notification {\n background-color: #fe8e14;\n}\n\n.dynamsoft-mrz-edit-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #aaa;\n}\n\n.dynamsoft-mrz-error-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-info-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.dynamsoft-mrz-info-message,\n.dynamsoft-mrz-error-message {\n flex: 1;\n}\n\n.dynamsoft-mrz-error-hint {\n font-size: 0.8rem;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-value {\n word-wrap: break-word;\n text-align: start;\n}\n\n.dynamsoft-mrz-data-value.code {\n font-family: monospace;\n}\n\n.dynamsoft-mrz-data-value.invalid-value {\n color: #e74c3c;\n text-decoration: wavy underline #e74c3c;\n text-decoration-skip-ink: none;\n}\n\n.dynamsoft-mrz-data-input {\n width: 100%;\n padding: 5px;\n background-color: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.3);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n transition: all 0.3s ease;\n}\n\n.dynamsoft-mrz-data-input.invalid {\n background-color: rgba(231, 76, 60, 0.1);\n border-color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-input:focus {\n background-color: rgba(255, 255, 255, 0.2);\n border-color: #fe8e14;\n outline: none;\n}\n\n@media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-result-view-container {\n flex-direction: row;\n }\n\n .dynamsoft-mrz-result-view-image-container{\n flex: 1;\n height: 100%;\n }\n\n .dynamsoft-mrz-data-container{\n flex: 1;\n }\n\n .dynamsoft-mrz-data-row:first-of-type {\n padding-top: 2rem;\n }\n\n .dynamsoft-mrz-data-row:last-of-type {\n padding-bottom: 2rem;\n }\n\n .dynamsoft-mrz-data-row.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding-top: 0;\n padding-bottom: 0;\n }\n}\n",b={rootDirectory:"https://cdn.jsdelivr.net/npm/"};class Z{showLoadingOverlay(e){var n,t;const i=c(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)||c(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container);this.loadingScreen=g(i,{message:e}),i.style.display="block",i.style.position="relative"}hideLoadingOverlay(e=!1){var n,t,i;const a=c(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)||c(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container);this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,a.style.display="none",e&&(null===(i=this.config)||void 0===i?void 0:i.container)&&(c(this.config.container).style.display="none"))}constructor(e){this.config=e,this.resources={},this.isInitialized=!1,this.isCapturing=!1,this.loadingScreen=null,this.isDynamsoftResourcesLoaded=!1,this.isFileMode=!1,this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources()}async initialize(){if(this.isInitialized)return{resources:this.resources,components:{scannerView:this.scannerView,resultView:this.resultView}};try{if(!this.initializeMRZScannerConfig())return console.error("Failed to initialize mrz scanner config"),{resources:this.resources,components:{}};d("dynamsoft-mrz-loading-screen-style",p),this.showLoadingOverlay("Loading..."),await this.initializeDCVResources(),this.resources.onResultUpdated=e=>{this.resources.result=e};const e={};return this.config.scannerViewConfig&&!this.isFileMode&&(this.scannerView=new D(this.resources,this.config.scannerViewConfig),e.scannerView=this.scannerView,await this.scannerView.initialize()),this.config.resultViewConfig&&(this.resultView=new C(this.resources,this.config.resultViewConfig,this.scannerView),e.resultView=this.resultView),this.isInitialized=!0,{resources:this.resources,components:e}}catch(e){this.isInitialized=!1;const n=`Initialization Failed: ${(null==e?void 0:e.message)||e}`;throw console.error(n),new Error(n)}finally{this.hideLoadingOverlay(!0)}}initializeDynamsoftResources(){var e;n.CoreModule.engineResourcePaths=u(null===(e=this.config)||void 0===e?void 0:e.engineResourcePaths)?b:this.config.engineResourcePaths,n.CoreModule.loadWasm(),n.CodeParserModule.loadSpec("MRTD_TD3_PASSPORT"),n.CodeParserModule.loadSpec("MRTD_TD3_VISA"),n.CodeParserModule.loadSpec("MRTD_TD1_ID"),n.CodeParserModule.loadSpec("MRTD_TD2_ID"),n.CodeParserModule.loadSpec("MRTD_TD2_VISA"),this.isDynamsoftResourcesLoaded=!0}async initializeDCVResources(){var e,t;try{this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources(),n.LicenseManager._onAuthMessage=e=>e.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=mrz&deploymenttype=web)"),await n.LicenseManager.initLicense((null===(e=this.config)||void 0===e?void 0:e.license)||"",{executeNow:!0}),this.isFileMode||(this.resources.cameraView=await n.CameraView.createInstance(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.cameraEnhancerUIPath),this.resources.cameraEnhancer=await n.CameraEnhancer.createInstance(this.resources.cameraView)),this.resources.cvRouter=await n.CaptureVisionRouter.createInstance(),await this.resources.cvRouter.initSettings(this.config.templateFilePath)}catch(e){let n=(null==e?void 0:e.message)||e;const t=(null==n?void 0:n.toLowerCase().includes("license"))?"The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.":`Resource Initialization Failed: ${n}`;throw console.error(t),new Error(t)}}shouldCreateDefaultContainer(){var e,n;const t=!this.config.container,i=!((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container));return t&&i}createDefaultMRZScannerContainer(){const e=document.createElement("div");return e.className="mrz-scanner-main-container",Object.assign(e.style,{height:"100dvh",width:"100%",position:"absolute",left:"0",top:"0",zIndex:"999"}),document.body.append(e),e}checkForTemporaryLicense(e){return!(null==e?void 0:e.length)||(null==e?void 0:e.startsWith("A"))||(null==e?void 0:e.startsWith("L"))||(null==e?void 0:e.startsWith("P"))||(null==e?void 0:e.startsWith("Y"))?"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9":e}validateViewConfigs(){var e,n,t,i,a,s,o,r;if(!this.config.container){if((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)&&this.config.showResultView&&!(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container)){const e="MRZResultView container is required when showResultView is true";return alert(e),console.error(e),!1}if(!(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)&&(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container)&&!this.resources.result){const e="Result is needed to create MRZResultView without a scanner view";return alert(e),console.error(e),!1}}try{if(this.config.container&&!c(this.config.container)){const e="Invalid main container reference";return alert(e),console.error(e),!1}if((null===(a=this.config.scannerViewConfig)||void 0===a?void 0:a.container)&&!c(null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.container)){const e="Invalid scanner view container reference";return alert(e),console.error(e),!1}if((null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)&&!c(null===(r=this.config.resultViewConfig)||void 0===r?void 0:r.container)){const e="Invalid result view container reference";return alert(e),console.error(e),!1}}catch(e){const n=`Error accessing container references: ${e.message}`;return alert(n),console.error(n),!1}return!0}showResultView(){var e,n;return!1!==this.config.showResultView&&(this.config.container?!(void 0!==this.config.showResultView||!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container)&&!this.config.container)||!!this.config.showResultView:this.config.showResultView&&!!(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container))}initializeMRZScannerConfig(){var n,t,i,a,s,o,l;this.config=null!==(n=this.config)&&void 0!==n?n:{};if(!this.validateViewConfigs())return!1;this.shouldCreateDefaultContainer()?this.config.container=this.createDefaultMRZScannerContainer():this.config.container&&(this.config.container=c(this.config.container));const d=this.config.container?this.createViewContainers(c(this.config.container)):{},u={license:this.checkForTemporaryLicense(this.config.license),utilizedTemplateNames:Object.fromEntries(Object.values(e.EnumMRZScanMode).map((e=>{var n;return[e,(null===(n=this.config.utilizedTemplateNames)||void 0===n?void 0:n[e])||r[e]]}))),templateFilePath:(null===(t=this.config)||void 0===t?void 0:t.templateFilePath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.template.json"},h=Object.assign(Object.assign({},this.config.scannerViewConfig),{container:d[e.EnumMRZScannerViews.Scanner]||c(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.container)||null,cameraEnhancerUIPath:(null===(a=this.config.scannerViewConfig)||void 0===a?void 0:a.cameraEnhancerUIPath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.ui.html",templateFilePath:u.templateFilePath,utilizedTemplateNames:u.utilizedTemplateNames,enableMultiFrameCrossFilter:null===(o=null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.enableMultiFrameCrossFilter)||void 0===o||o,mrzFormatType:this.config.mrzFormatType}),m=this.showResultView()?Object.assign(Object.assign({},this.config.resultViewConfig),{_isFileMode:this.isFileMode,container:d[e.EnumMRZScannerViews.Result]||c(null===(l=this.config.resultViewConfig)||void 0===l?void 0:l.container)||null}):void 0;return Object.assign(this.config,Object.assign(Object.assign({},u),{scannerViewConfig:h,resultViewConfig:m})),!0}createViewContainers(n){n.textContent="";const t=[e.EnumMRZScannerViews.Scanner];return this.showResultView()&&t.push(e.EnumMRZScannerViews.Result),t.reduce(((e,t)=>{const i=document.createElement("div");return i.className=`mrz-scanner-${t}-view-container`,Object.assign(i.style,{height:"100%",width:"100%",display:"none",position:"relative"}),n.append(i),e[t]=i,e}),{})}dispose(){var e,n;this.resultView&&(this.resultView.dispose(),this.resultView=null),this.scannerView=null,this.resources.cameraEnhancer&&(this.resources.cameraEnhancer.dispose(),this.resources.cameraEnhancer=null),this.resources.cameraView&&(this.resources.cameraView.dispose(),this.resources.cameraView=null),this.resources.cvRouter&&(this.resources.cvRouter.dispose(),this.resources.cvRouter=null),this.resources.result=null,this.resources.onResultUpdated=null;const t=e=>{const n=c(e);n&&(n.style.display="none",n.textContent="")};t(this.config.container),t(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container),t(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container),this.isInitialized=!1}async processUploadedFile(t){var i,a,s,o,r,l;try{this.showLoadingOverlay("Processing File...");const{cvRouter:c}=this.resources,d=null===(i=this.config.utilizedTemplateNames)||void 0===i?void 0:i.all,u=await c.getSimplifiedSettings(d);u.roiMeasuredInPercentage=!0,u.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await c.updateSettings(d,u);const h=await c.capture(t,d),m=h.items,g=m.filter((e=>e.type===n.EnumCapturedResultItemType.CRIT_ORIGINAL_IMAGE))[0].imageData;g.toCanvas=()=>n._toCanvas(g),g.toBlob=async()=>await n._toBlob("image/png",g);const p=null===(a=null==h?void 0:h.parsedResult)||void 0===a?void 0:a.parsedResultItems;let f={};if(null==p?void 0:p.length){const e=(null===(o=null===(s=p[0])||void 0===s?void 0:s.referencedItem)||void 0===o?void 0:o.text)||"";f=v(e,p[0])}const y={status:{code:e.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:g,data:f,imageData:!0,_imageData:g};null===(l=(r=this.resources).onResultUpdated)||void 0===l||l.call(r,y)}catch(n){return console.error("Failed to process uploaded file:",n),{status:{code:e.EnumResultStatus.RS_FAILED,message:`Failed to process image: ${n.message||n}`}}}finally{this.hideLoadingOverlay(!1)}}async launch(n){if(this.isCapturing)throw new Error("Capture session already in progress");try{this.isCapturing=!0,this.isFileMode=!!n;const{components:t}=await this.initialize();if(u(t))throw new Error("MRZ Scanner initialization failed ");if(this.config.container&&(c(this.config.container).style.display="block"),this.isFileMode&&await this.processUploadedFile(n),!t.scannerView&&this.resources.result&&t.resultView)return await t.resultView.launch();if(!t.scannerView&&!this.resources.result&&!this.isFileMode)throw new Error("Scanner view is required when no previous result exists");if(t.scannerView){const n=await t.scannerView.launch();if((null==n?void 0:n.status.code)!==e.EnumResultStatus.RS_SUCCESS)return{status:{code:null==n?void 0:n.status.code,message:(null==n?void 0:n.status.message)||"Failed to capture image"}};if(t.resultView)return await t.resultView.launch()}return this.resources.result}catch(n){return alert((null==n?void 0:n.message)||n),console.error((null==n?void 0:n.message)||n),{status:{code:e.EnumResultStatus.RS_FAILED,message:(null==n?void 0:n.message)||n}}}finally{this.isCapturing=!1,this.dispose()}}}const x={MRZScanner:Z,MRZScannerView:D,MRZResultView:C};e.Dynamsoft=o,e.DEFAULT_TEMPLATE_NAMES=r,e.DynamsoftMRZScanner=x,e.MRZDataLabel=y,e.MRZResultView=C,e.MRZScanner=Z,e.MRZScannerView=D,e.displayMRZDate=w})); diff --git a/dist/mrz-scanner.mjs b/dist/mrz-scanner.mjs index 63d52aa..f271a89 100644 --- a/dist/mrz-scanner.mjs +++ b/dist/mrz-scanner.mjs @@ -1 +1 @@ -import{EnumCapturedResultItemType as e,_toCanvas as t,_toBlob as n,EnumImagePixelFormat as i,CoreModule as s}from"dynamsoft-core";import*as a from"dynamsoft-core";export{a as Core};import{LicenseManager as o}from"dynamsoft-license";import*as r from"dynamsoft-license";export{r as License};import{CapturedResultReceiver as l,CaptureVisionRouter as c}from"dynamsoft-capture-vision-router";import*as d from"dynamsoft-capture-vision-router";export{d as CVR};import{Feedback as h,CameraView as u,CameraEnhancer as m}from"dynamsoft-camera-enhancer";import*as g from"dynamsoft-camera-enhancer";export{g as DCE};import{EnumValidationStatus as p,CodeParserModule as f}from"dynamsoft-code-parser";import*as y from"dynamsoft-code-parser";export{y as DCP};import{LabelRecognizerModule as w}from"dynamsoft-label-recognizer";import*as v from"dynamsoft-label-recognizer";export{v as DLR};import{MultiFrameResultCrossFilter as S}from"dynamsoft-utility";import*as R from"dynamsoft-utility";export{R as Utility};var E,D,C;!function(e){e.Passport="passport",e.TD1="td1",e.TD2="td2",e.PassportAndTD1="passportAndTd1",e.PassportAndTD2="passportAndTd2",e.TD1AndTD2="td1AndTd2",e.All="all"}(E||(E={})),function(e){e.Passport="passport",e.TD1="td1",e.TD2="td2"}(D||(D={})),function(e){e.Scanner="scanner",e.Result="scan-result"}(C||(C={}));const T={[E.Passport]:"ReadPassport",[E.TD1]:"ReadId-TD1",[E.TD2]:"ReadId-TD2",[E.PassportAndTD1]:"ReadPassportAndId-TD1",[E.PassportAndTD2]:"ReadPassportAndId-TD2",[E.TD1AndTD2]:"ReadId",[E.All]:"ReadPassportAndId"};var M;function x(e){if("string"==typeof e){const t=document.querySelector(e);if(!t)throw new Error("Element not found");return t}return e instanceof HTMLElement?e:null}!function(e){e[e.RS_SUCCESS=0]="RS_SUCCESS",e[e.RS_CANCELLED=1]="RS_CANCELLED",e[e.RS_FAILED=2]="RS_FAILED"}(M||(M={}));function b(e,t){if(!document.getElementById(e)){const n=document.createElement("style");n.id=e,n.textContent=t,document.head.appendChild(n)}}const z=e=>!e||0===Object.keys(e).length;function I(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}const V={"4k":{width:3840,height:2160},"2k":{width:2560,height:1440},"1080p":{width:1920,height:1080},"720p":{width:1280,height:720},"480p":{width:640,height:480}};function N(e,t={}){const{message:n,spinnerSize:i=32}=t,s=document.createElement("div");s.className="dynamsoft-mrz-loading-screen";const a=document.createElement("div");a.className="dynamsoft-mrz-loading";const o=document.createElement("div");o.className="dynamsoft-mrz-loading-content";const r=`\n \n \n \n `;if(o.innerHTML=r,n){const e=document.createElement("div");e.className="dynamsoft-mrz-loading-message",e.textContent=n,o.appendChild(e)}return a.appendChild(o),s.appendChild(a),e.appendChild(s),{element:s,updateMessage:e=>{let t=a.querySelector(".dynamsoft-mrz-loading-message");null!==e?t?t.textContent=e:(t=document.createElement("div"),t.className="dynamsoft-mrz-loading-message",t.textContent=e,o.appendChild(t)):null==t||t.remove()},hide:()=>{s&&s.parentNode&&(s.classList.add("fade-out"),setTimeout((()=>{var e;null===(e=s.parentNode)||void 0===e||e.removeChild(s)}),200))}}}const L='\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: "Verdana";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n';var F;!function(e){e.InvalidFields="invalidFields",e.DocumentType="documentType",e.DocumentNumber="documentNumber",e.MRZText="mrzText",e.FirstName="firstName",e.LastName="lastName",e.Age="age",e.Sex="sex",e.IssuingState="issuingState",e.IssuingStateRaw="issuingStateRaw",e.Nationality="nationality",e.NationalityRaw="nationalityRaw",e.DateOfBirth="dateOfBirth",e.DateOfExpiry="dateOfExpiry"}(F||(F={}));const _={[F.InvalidFields]:"Invalid Fields",[F.DocumentType]:"Document Type",[F.DocumentNumber]:"Document Number",[F.MRZText]:"MRZ Text",[F.FirstName]:"Given Name(s)",[F.LastName]:"Surname",[F.Age]:"Age",[F.Sex]:"Sex",[F.IssuingState]:"Issuing State",[F.IssuingStateRaw]:"Issuing State (Raw Value)",[F.Nationality]:"Nationality",[F.NationalityRaw]:"Nationality State (Raw Value)",[F.DateOfBirth]:"Date Of Birth (YYYY-MM-DD)",[F.DateOfExpiry]:"Date Of Expiry (YYYY-MM-DD)"};function k(e,t,n,i=!1){const s=parseInt(e,10);let a;if(i)a=s>=60?1900+s:2e3+s;else{a=s>(new Date).getFullYear()%100?1900+s:2e3+s}return{year:a,month:parseInt(t,10),day:parseInt(n,10)}}function A(e){const t=e=>{var t;return 1===(null===(t=`${e}`)||void 0===t?void 0:t.length)?`0${e}`:e};return`${null==e?void 0:e.year}-${t(null==e?void 0:e.month)}${(null==e?void 0:e.day)&&`-${t(null==e?void 0:e.day)}`}`}function O(e){return"D<<"===e?"D":e}function P(e,t){const n=[],i=e=>t.getFieldValidationStatus(e)===p.VS_FAILED,s=t.codeType,a=function(e){switch(e){case"MRTD_TD1_ID":return D.TD1;case"MRTD_TD2_ID":case"MRTD_TD2_VISA":case"MRTD_TD2_FRENCH_ID":return D.TD2;case"MRTD_TD3_PASSPORT":case"MRTD_TD3_VISA":return D.Passport;default:throw new Error(`Unknown document type: ${e}`)}}(s),o=function(e){switch(e){case"MRTD_TD1_ID":return"ID (TD1)";case"MRTD_TD2_ID":return"ID (TD2)";case"MRTD_TD2_VISA":return"ID (VISA)";case"MRTD_TD2_FRENCH_ID":return"French ID (TD2)";case"MRTD_TD3_PASSPORT":return"Passport (TD3)";case"MRTD_TD3_VISA":return"Visa (TD3)";default:throw new Error(`Unknown document type: ${e}`)}}(s),r=a===D.Passport&&"MRTD_TD3_PASSPORT"===s?"passportNumber":"documentNumber",l=k(t.getFieldValue("birthYear"),t.getFieldValue("birthMonth"),t.getFieldValue("birthDay")),c=k(t.getFieldValue("expiryYear"),t.getFieldValue("expiryMonth"),t.getFieldValue("expiryDay"),!0);["birthYear","birthMonth","birthDay"].forEach((e=>{i(e)&&n.push(F.DateOfBirth)})),["expiryYear","expiryMonth","expiryDay"].forEach((e=>{i(e)&&n.push(F.DateOfExpiry)}));const d={[F.LastName]:t.getFieldValue("primaryIdentifier"),[F.FirstName]:t.getFieldValue("secondaryIdentifier"),[F.Nationality]:t.getFieldValue("nationality"),[F.NationalityRaw]:O(t.getFieldRawValue("nationality")),[F.DocumentNumber]:t.getFieldValue(r)||t.getFieldValue("longDocumentNumber"),[F.IssuingState]:t.getFieldValue("issuingState"),[F.IssuingStateRaw]:O(t.getFieldRawValue("issuingState")),[F.Sex]:I(t.getFieldValue("sex"))};Object.keys(d).forEach((e=>{let t=!1;switch(e){case F.FirstName:t=i("secondaryIdentifier");break;case F.LastName:t=i("primaryIdentifier");break;case F.DocumentNumber:t=i(r)||i("longDocumentNumber");break;default:t=i(e)}t&&n.push(e)}));const h=function(e){const t=new Date,n=t.getMonth()+1>e.month||t.getMonth()+1===e.month&&t.getDate()>=e.day;return t.getFullYear()-e.year-(n?0:1)}(l);h<1&&n.push(F.Age);return{[F.InvalidFields]:n,[F.FirstName]:d[F.FirstName],[F.LastName]:d[F.LastName],[F.Age]:h,[F.DateOfBirth]:l,[F.Sex]:d[F.Sex],[F.Nationality]:d[F.Nationality],[F.NationalityRaw]:d[F.NationalityRaw],[F.DocumentNumber]:d[F.DocumentNumber],[F.DateOfExpiry]:c,[F.IssuingState]:d[F.IssuingState],[F.IssuingStateRaw]:d[F.IssuingStateRaw],[F.DocumentType]:I(o),[F.MRZText]:e}}const B={[D.TD1]:{width:85.6,height:53.98},[D.TD2]:{width:105,height:74},[D.Passport]:{width:125,height:88}};class j{showScannerLoadingOverlay(e){const t=x(this.config.container);this.loadingScreen=N(t,{message:e}),t.style.display="block",t.style.position="relative"}hideScannerLoadingOverlay(e=!1){this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,e&&(x(this.config.container).style.display="none"))}constructor(e,t){this.resources=e,this.config=t,this.isSoundFeedbackOn=!1,this.scanModeManager={[D.Passport]:!0,[D.TD1]:!0,[D.TD2]:!0},this.currentScanMode=E.All,this.resizeTimer=null,this.capturedResultItems=[],this.originalImageData=null,this.initialized=!1,this.initializedDCE=!1,this.DCE_ELEMENTS={selectCameraBtn:null,uploadImageBtn:null,soundFeedbackBtn:null,closeScannerBtn:null,scanModeSelectContainer:null,passportModeOption:null,td1ModeOption:null,td2ModeOption:null,toast:null},this.loadingScreen=null,this.handleResize=()=>{this.toggleScanGuide(!1),this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((()=>{this.toggleScanGuide(!0)}),500)}}async initialize(){if(!this.initialized){this.initializeScanModeManager(),this.currentScanMode=this.getScanMode(),b("dynamsoft-mrz-loading-screen-style",L);try{const{cameraView:t,cameraEnhancer:n,cvRouter:i}=this.resources;if(t.setScanRegionMaskStyle({strokeStyle:"transparent",fillStyle:"transparent",lineWidth:0}),t.setVideoFit("cover"),i.setInput(n),await i.initSettings(this.config.templateFilePath),!0===this.config.enableMultiFrameCrossFilter){const t=new S;t.enableResultCrossVerification(e.CRIT_TEXT_LINE,!0),t.enableResultDeduplication(e.CRIT_TEXT_LINE,!0),await i.addResultFilter(t)}const s=new l;s.onCapturedResultReceived=e=>this.handleMRZResult(e),await i.addResultReceiver(s),this.toggleSoundFeedback(!1),!1===this.config.showScanGuide&&this.toggleScanGuide(!1),this.initialized=!0}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:M.RS_FAILED,message:"Dynamsoft MRZ Scanner initialize error"}};this.currentScanResolver(n)}}}initializeElements(){var e;const t=x(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))throw new Error("Shadow root not found");if(this.DCE_ELEMENTS={selectCameraBtn:n.shadowRoot.querySelector(".dce-mn-select-camera-icon"),uploadImageBtn:n.shadowRoot.querySelector(".dce-mn-upload-image-icon"),soundFeedbackBtn:n.shadowRoot.querySelector(".dce-mn-sound-feedback"),closeScannerBtn:n.shadowRoot.querySelector(".dce-mn-close"),scanModeSelectContainer:n.shadowRoot.querySelector(".dce-mn-scan-mode-select"),passportModeOption:n.shadowRoot.querySelector(".scan-mode-option-passport"),td1ModeOption:n.shadowRoot.querySelector(".scan-mode-option-td1"),td2ModeOption:n.shadowRoot.querySelector(".scan-mode-option-td2"),toast:n.shadowRoot.querySelector(".dce-mn-toast")},this.setupScanModeSelector(),this.assignDCEClickEvents(),this.DCE_ELEMENTS.toast.style.display="none",!1===this.config.showUploadImage&&(this.DCE_ELEMENTS.uploadImageBtn.style.visibility="hidden"),!1===this.config.showSoundToggle&&(this.DCE_ELEMENTS.soundFeedbackBtn.style.visibility="hidden"),!1===(null===(e=this.config)||void 0===e?void 0:e.showPoweredByDynamsoft)){n.shadowRoot.querySelector(".dce-mn-msg-poweredby").style.display="none"}this.initializedDCE=!0}setupScanModeSelector(){if(!1!==this.config.showFormatSelector)switch(this.currentScanMode){case E.PassportAndTD1:this.DCE_ELEMENTS.td2ModeOption.style.display="none";break;case E.PassportAndTD2:this.DCE_ELEMENTS.td1ModeOption.style.display="none";break;case E.TD1AndTD2:this.DCE_ELEMENTS.passportModeOption.style.display="none";break;case E.All:break;default:this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}else this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}assignDCEClickEvents(){if(!Object.values(this.DCE_ELEMENTS).every(Boolean))throw new Error("Camera control elements not found");this.closeCamera=this.closeCamera.bind(this),this.DCE_ELEMENTS.uploadImageBtn.onclick=()=>this.uploadFile(),this.DCE_ELEMENTS.soundFeedbackBtn.onclick=()=>this.toggleSoundFeedback(),this.DCE_ELEMENTS.closeScannerBtn.onclick=()=>this.handleCloseBtn(),this.DCE_ELEMENTS.selectCameraBtn.onclick=e=>{e.stopPropagation(),this.toggleSelectCameraBox()},this.DCE_ELEMENTS.passportModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.passportModeOption.style.display&&await this.toggleScanDocType(D.Passport)},this.DCE_ELEMENTS.td1ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td1ModeOption.style.display&&await this.toggleScanDocType(D.TD1)},this.DCE_ELEMENTS.td2ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td2ModeOption.style.display&&await this.toggleScanDocType(D.TD2)}}handleCloseBtn(){this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:M.RS_CANCELLED,message:"Cancelled"}})}attachOptionClickListeners(){const e=x(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings");[...t.shadowRoot.querySelectorAll(".dce-mn-camera-option"),...t.shadowRoot.querySelectorAll(".dce-mn-resolution-option")].forEach((e=>{e.addEventListener("click",(async t=>{const i=e.getAttribute("data-davice-id"),s=e.getAttribute("data-height"),a=e.getAttribute("data-width");i?this.resources.cameraEnhancer.selectCamera(i).then((()=>{this.toggleScanGuide()})):s&&a&&this.resources.cameraEnhancer.setResolution({width:parseInt(a),height:parseInt(s)}).then((()=>{this.toggleScanGuide()})),"none"!==n.style.display&&this.toggleSelectCameraBox()}))}))}highlightCameraAndResolutionOption(){const e=x(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings"),i=n.querySelectorAll(".dce-mn-camera-option"),s=n.querySelectorAll(".dce-mn-resolution-option"),a=this.resources.cameraEnhancer.getSelectedCamera(),o=this.resources.cameraEnhancer.getResolution();i.forEach((e=>{const t=e;t.getAttribute("data-davice-id")===(null==a?void 0:a.deviceId)?t.style.border="2px solid #fe814a":t.style.border="none"}));const r={"480p":"480","720p":"720","1080p":"1080","2k":"1440","4k":"2160"},l=function(e){const t=e.width*e.height,n=e.width/e.height;let i="480p",s=Number.MAX_VALUE;for(const[e,a]of Object.entries(V)){const o=a.width*a.height,r=a.width/a.height,l=.7*Math.abs(o-t)+Math.abs(r-n)*o*.3;l{const t=e,n=t.getAttribute("data-height");t.style.border=n===r[l]?"2px solid #fe814a":"none"}))}toggleSelectCameraBox(){const e=x(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-resolution-box");this.highlightCameraAndResolutionOption(),this.attachOptionClickListeners(),n.click()}async relaunch(){}async uploadFile(){var i,s,a,o;const{cvRouter:r}=this.resources,l=document.createElement("input");l.type="file",l.accept=null!==(i=this.config.uploadAcceptedTypes)&&void 0!==i?i:"image/*",l.style.display="none",document.body.appendChild(l);try{this.showScannerLoadingOverlay("Processing file..."),await this.closeCamera(!1);const i=await new Promise(((e,t)=>{l.onchange=n=>{var i;const s=null===(i=n.target.files)||void 0===i?void 0:i[0];s?e(s):t(new Error("No file selected"))},l.addEventListener("cancel",(async()=>{this.hideScannerLoadingOverlay(!1),await this.openCamera(),await this.startCapturing(),this.toggleScanGuide()})),l.click()}));if(!i)return;let c;if(this.config.uploadFileConverter&&!i.type.startsWith("image/"))try{c=await this.config.uploadFileConverter(i)}catch(e){throw new Error(`Error converting file: ${e.message}`)}else{if(!i.type.startsWith("image/"))throw new Error("Unsupported file type. Please provide a converter function for this file type.");c=i}const d=this.config.utilizedTemplateNames[this.currentScanMode];if(!1!==this.config.showScanGuide){const e=await r.getSimplifiedSettings(d);e.roiMeasuredInPercentage=!0,e.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await r.updateSettings(d,e)}const h=await r.capture(c,d);this.capturedResultItems=h.items;const u=this.capturedResultItems.filter((t=>t.type===e.CRIT_ORIGINAL_IMAGE));if(0===u.length)throw new Error("No image data found in the captured result");const m=u[0].imageData;m.toCanvas=()=>t(m),m.toBlob=async()=>await n("image/png",m),this.originalImageData=m;const g=null==h?void 0:h.textLineResultItems,p=null==h?void 0:h.parsedResultItems;let f={};if(null==g?void 0:g.length){const e=(null===(s=g[0])||void 0===s?void 0:s.text)||"";f=P(e,p[0])}const y={status:{code:M.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:f,imageData:!0,_imageData:this.originalImageData};null===(o=(a=this.resources).onResultUpdated)||void 0===o||o.call(a,y),this.currentScanResolver(y)}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:M.RS_FAILED,message:`Error processing file: ${t}`}};this.currentScanResolver(n)}finally{this.hideScannerLoadingOverlay(!0),document.body.removeChild(l)}}toggleSoundFeedback(e){this.isSoundFeedbackOn=void 0!==e?e:!this.isSoundFeedbackOn;const t=x(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const i=n.shadowRoot.querySelector(".dce-mn-sound-feedback"),s=i.querySelector(".dce-mn-sound-feedback-on");i.querySelector(".dce-mn-sound-feedback-off").style.display=this.isSoundFeedbackOn?"none":"block",s.style.display=this.isSoundFeedbackOn?"block":"none"}calculateScanRegion(e){const{cameraEnhancer:t,cameraView:n}=this.resources;if(!t||!t.isOpen())return;const i=n.getVisibleRegionOfVideo({inPixels:!0});if(!i)return;const s=n.getVideoElement(),a=s.videoWidth,o=s.videoHeight,r=B[e];let l;const c=i.height-80;if(i.width>i.height){l=.75*c/r.height;l*r.width>.9*i.width&&(l=.9*i.width/r.width)}else{l=.9*i.width/r.width;l*r.height>.75*c&&(l=.75*c/r.height)}const d=l*r.width,h=l*r.height,u=(i.width-d)/2,m=(c-h)/2,g=u,p=u+d,f=m,y=m+h,w=(i.x+g)/a*100,v=(i.x+p)/a*100,S=(i.y+f)/o*100,R=(i.y+y)/o*100,E={left:Math.round(w),right:Math.round(v),top:Math.round(S),bottom:Math.round(R),isMeasuredInPercentage:!0};null==n||n.setScanRegionMaskVisible(!0),t.setScanRegion(E)}toggleScanGuide(e){const t=x(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const i=n.shadowRoot.querySelector(".dce-scanguide-passport"),s=n.shadowRoot.querySelector(".dce-scanguide-td1"),a=n.shadowRoot.querySelector(".dce-scanguide-td2");if(!1===e||!1===this.config.showScanGuide)return i.style.display="none",s.style.display="none",void(a.style.display="none");switch(this.currentScanMode){case E.All:case E.Passport:case E.PassportAndTD1:case E.PassportAndTD2:i.style.display="block",s.style.display="none",a.style.display="none",this.calculateScanRegion(D.Passport);break;case E.TD1:case E.TD1AndTD2:i.style.display="none",s.style.display="block",a.style.display="none",this.calculateScanRegion(D.TD1);break;case E.TD2:i.style.display="none",s.style.display="none",a.style.display="block",this.calculateScanRegion(D.TD2)}}async openCamera(){try{this.showScannerLoadingOverlay("Initializing camera...");const{cameraEnhancer:e,cameraView:t}=this.resources,n=x(this.config.container);if(n.style.display="block",e.isOpen())e.isPaused()&&await e.resume();else{const i=t.getUIElement();i.parentElement||n.append(i),await e.open()}await e.setResolution({width:2560,height:1440}),!this.initializedDCE&&e.isOpen()&&await this.initializeElements(),window.addEventListener("resize",this.handleResize);const i=n.children[n.children.length-1];if(!(null==i?void 0:i.shadowRoot))throw new Error("Shadow root not found");i.shadowRoot.querySelector(".dce-mn-torch-off").style.display="none",i.shadowRoot.querySelector(".dce-mn-torch-on").style.display="none"}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:M.RS_FAILED,message:"MRZ Scanner Open Camera Error"}};this.currentScanResolver(n)}finally{this.hideScannerLoadingOverlay()}}async closeCamera(e=!0){try{window.removeEventListener("resize",this.handleResize),this.resizeTimer&&(window.clearTimeout(this.resizeTimer),this.resizeTimer=null);const{cameraEnhancer:t,cameraView:n}=this.resources,i=x(this.config.container);i.style.display=e?"none":"block",(null==n?void 0:n.getUIElement().parentElement)&&i.removeChild(n.getUIElement()),t.close(),this.stopCapturing()}catch(e){let t=(null==e?void 0:e.message)||e;console.error(`Close Camera error: ${t}`)}}pauseCamera(){const{cameraEnhancer:e}=this.resources;e.pause()}stopCapturing(){const{cameraView:e,cvRouter:t}=this.resources;t.stopCapturing(),e.clearAllInnerDrawingItems()}async handleMRZResult(i){var s;if(this.capturedResultItems=i.items,!(i.items.length<=1))try{const{onResultUpdated:a}=this.resources,o=i.items.filter((t=>t.type===e.CRIT_ORIGINAL_IMAGE))[0].imageData;o.toCanvas=()=>t(o),o.toBlob=async()=>await n("image/png",o),this.originalImageData=o;const r=null==i?void 0:i.textLineResultItems,l=null==i?void 0:i.parsedResultItems;if(r){this.isSoundFeedbackOn&&h.beep();const e=(null===(s=null==r?void 0:r[0])||void 0===s?void 0:s.text)||"",t=P(e,l[0]);this.closeCamera();const n={status:{code:M.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:t,imageData:!0,_imageData:this.originalImageData};null==a||a(n),this.currentScanResolver(n)}}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:M.RS_FAILED,message:"Error capturing image"}};this.currentScanResolver(n)}}initializeScanModeManager(){const{mrzFormatType:e}=this.config;if(this.scanModeManager={[D.Passport]:!0,[D.TD1]:!0,[D.TD2]:!0},!e||Array.isArray(e)&&0===e.length)return;Object.keys(this.scanModeManager).forEach((e=>{this.scanModeManager[e]=!1}));(Array.isArray(e)?e:[e]).forEach((e=>{this.scanModeManager[e]=!0}))}getScanMode(){const e=Object.entries(this.scanModeManager).filter((([e,t])=>t)).map((([e])=>e)).sort().join(",");return{[D.Passport]:E.Passport,[D.TD1]:E.TD1,[D.TD2]:E.TD2,[`${D.Passport},${D.TD1}`]:E.PassportAndTD1,[`${D.Passport},${D.TD2}`]:E.PassportAndTD2,[`${D.TD1},${D.TD2}`]:E.TD1AndTD2,[`${D.Passport},${D.TD1},${D.TD2}`]:E.All,"":E.All}[e]}DCEShowToast(e,t=3e3){this.DCE_ELEMENTS.toast&&(this.DCE_ELEMENTS.toast.textContent=e,this.DCE_ELEMENTS.toast.style.display="",setTimeout((()=>{this.DCE_ELEMENTS.toast.style.display="none"}),t))}async startCapturing(){const{cvRouter:e,cameraEnhancer:t}=this.resources,n=this.config.utilizedTemplateNames[this.currentScanMode];try{if(!1!==this.config.showScanGuide){const t=await e.getSimplifiedSettings(n);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:50},{x:100,y:50},{x:100,y:100},{x:0,y:100}],await e.updateSettings(n,t)}await e.startCapturing(n),t.setPixelFormat(i.IPF_ABGR_8888)}catch(e){let t=(null==e?void 0:e.message)||e;console.error("Failed to start capturing:",t),this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:M.RS_FAILED,message:"Failed to start capturing"}})}}async toggleScanDocType(e){try{if(this.scanModeManager[e]&&0===Object.entries(this.scanModeManager).filter((([t,n])=>n&&t!==e)).length)return console.warn("MRZ Scanner - At least one mode must be enabled"),void this.DCEShowToast("At least one mode must be enabled");this.scanModeManager[e]=!this.scanModeManager[e],this.currentScanMode=this.getScanMode(),this.stopCapturing(),await this.startCapturing(),this.toggleScanGuide(),this.DCE_ELEMENTS.td1ModeOption.classList.toggle("selected",this.scanModeManager[D.TD1]),this.DCE_ELEMENTS.td2ModeOption.classList.toggle("selected",this.scanModeManager[D.TD2]),this.DCE_ELEMENTS.passportModeOption.classList.toggle("selected",this.scanModeManager[D.Passport])}catch(e){let t=(null==e?void 0:e.message)||e;console.error("MRZ Scanner switch scan mode error: ",t),this.closeCamera();const n={status:{code:M.RS_FAILED,message:"MRZ Scanner switch scan mode error"}};this.currentScanResolver(n)}}async launch(){try{await this.initialize();const{cvRouter:e,cameraEnhancer:t}=this.resources;return new Promise((async e=>{this.currentScanResolver=e,await this.openCamera(),!this.initializedDCE&&t.isOpen()&&await this.initializeElements(),await this.startCapturing(),this.toggleScanGuide()}))}catch(e){let t=(null==e?void 0:e.message)||e;console.error("MRZ Scanner launch error: ",t),this.closeCamera();const n={status:{code:M.RS_FAILED,message:"MRZ Scanner launch error"}};this.currentScanResolver(n)}}}const $={rescan:'\n\n\n \n\n\n\n\n\n\n\n',complete:'\n\n\n\n \n\n\n\n\n\n\n\n',failed:'\n \n \n \n\n',info:'\n\n \n \n \n\n'};class U{constructor(e,t,n){this.resources=e,this.config=t,this.scannerView=n,this.editedFields={}}async launch(){try{return x(this.config.container).textContent="",await this.initialize(),x(this.config.container).style.display="flex",new Promise((e=>{this.currentScanResultViewResolver=e}))}catch(e){let t=(null==e?void 0:e.message)||e;throw console.error(t),t}}async handleRescan(){var e;try{if(!this.scannerView)return void console.error("Scanner View not initialized");this.hideView();const t=await this.scannerView.launch();if((null===(e=null==t?void 0:t.status)||void 0===e?void 0:e.code)===M.RS_FAILED)return void(this.currentScanResultViewResolver&&this.currentScanResultViewResolver(t));this.resources.onResultUpdated&&((null==t?void 0:t.status.code)===M.RS_CANCELLED?this.resources.onResultUpdated(this.resources.result):(null==t?void 0:t.status.code)===M.RS_SUCCESS&&this.resources.onResultUpdated(t)),this.dispose(!0),await this.initialize(),x(this.config.container).style.display="flex"}catch(e){throw console.error("Error in rescan handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:M.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}async handleDone(){var e,t;try{(null===(e=this.resources.result)||void 0===e?void 0:e.data)&&!z(this.editedFields)&&(this.resources.result.data=Object.assign(Object.assign({},this.resources.result.data),this.editedFields),this.resources.onResultUpdated&&this.resources.onResultUpdated(this.resources.result)),(null===(t=this.config)||void 0===t?void 0:t.onDone)&&await this.config.onDone(this.resources.result),this.currentScanResultViewResolver&&this.resources.result&&this.currentScanResultViewResolver(this.resources.result),this.hideView(),this.dispose()}catch(e){throw console.error("Error in done handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:M.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}createControls(){var e,t,n,i,s,a,o,r;const{toolbarButtonsConfig:l}=this.config;return function(e){b("dynamsoft-mrz-controls-style","\n .dynamsoft-mrz-controls {\n display: flex;\n height: 6rem;\n background-color: #323234;\n align-items: center;\n font-size: 12px;\n font-family: Verdana;\n color: white;\n width: 100%;\n }\n\n .dynamsoft-mrz-control-btn {\n background-color: #323234;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n gap: 0.5rem;\n text-align: center;\n user-select: none;\n }\n\n .dynamsoft-mrz-control-btn.hide {\n display: none;\n }\n\n .dynamsoft-mrz-control-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n cursor: default;\n }\n\n .dynamsoft-mrz-control-icon-wrapper {\n flex: 0.75;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n min-height: 40px;\n }\n\n .dynamsoft-mrz-control-icon img,\n .dynamsoft-mrz-control-icon svg {\n width: 32px;\n height: 32px;\n fill: #fe8e14;\n }\n\n .dynamsoft-mrz-control-text {\n flex: 0.5;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-bottom: 0.5rem;\n }\n\n \n @media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-controls {\n flex-direction: column;\n height: 100%;\n width: 5rem;\n }\n\n .dynamsoft-mrz-control-text {\n padding: 0 0.5rem 0.5rem;\n }\n }\n");const t=document.createElement("div");return t.className="dynamsoft-mrz-controls",e.forEach((e=>{const n=document.createElement("div");n.className=`dynamsoft-mrz-control-btn ${null==e?void 0:e.className}`;const i=document.createElement("div");if(i.className="dynamsoft-mrz-control-icon-wrapper",(s=e.icon).trim().startsWith(""))i.innerHTML=e.icon;else{const t=document.createElement("img");t.src=e.icon,t.alt=e.label,t.width=24,t.height=24,i.appendChild(t)}var s;const a=document.createElement("div");a.className="dynamsoft-mrz-control-text",a.textContent=e.label,e.isDisabled&&n.classList.add("disabled"),e.isHidden&&n.classList.add("hide"),n.appendChild(i),n.appendChild(a),e.onClick&&!e.isDisabled&&n.addEventListener("click",e.onClick),t.appendChild(n)})),t}([{id:"dynamsoft-mrz-scanResult-rescan",icon:(null===(e=null==l?void 0:l.rescan)||void 0===e?void 0:e.icon)||$.rescan,label:(null===(t=null==l?void 0:l.rescan)||void 0===t?void 0:t.label)||"Re-scan",onClick:()=>this.handleRescan(),className:`${(null===(n=null==l?void 0:l.rescan)||void 0===n?void 0:n.className)||""}`,isHidden:(null===(i=null==l?void 0:l.rescan)||void 0===i?void 0:i.isHidden)||!1,isDisabled:!this.scannerView},{id:"dynamsoft-mrz-scanResult-done",icon:(null===(s=null==l?void 0:l.done)||void 0===s?void 0:s.icon)||$.complete,label:(null===(a=null==l?void 0:l.done)||void 0===a?void 0:a.label)||"Done",className:`${(null===(o=null==l?void 0:l.done)||void 0===o?void 0:o.className)||""}`,isHidden:(null===(r=null==l?void 0:l.done)||void 0===r?void 0:r.isHidden)||!1,onClick:()=>this.handleDone()}])}handleFieldEdit(e,t){if(e===F.DateOfBirth||e===F.DateOfExpiry)try{const[n,i,s]=t.split(/[\/\-\.]/);s&&i&&n&&(this.editedFields[e]={day:parseInt(s,10),month:parseInt(i,10),year:parseInt(n,10)})}catch(e){console.error("Error parsing date",e)}else this.editedFields[e]=t}createMRZDataDisplay(){var e;const t=(null===(e=this.resources.result)||void 0===e?void 0:e.data)||{},n=!!this.config.allowResultEditing,i=t.invalidFields||[],s=document.createElement("div");if(s.className="dynamsoft-mrz-data-container",z(t)){const e=document.createElement("div");return e.className="dynamsoft-mrz-data-row empty",e.innerText="No MRZ detected. Please try again.",s.appendChild(e),s}if(i.length>0){const e=document.createElement("div");e.className="dynamsoft-mrz-error-notification",e.innerHTML=`\n
${$.failed}
\n
\n ${n?"Some fields require correction. Please review highlighted fields.":"Some fields contain invalid information. Please rescan the document."}\n
\n `,s.appendChild(e)}else if(0===i.length&&n){const e=document.createElement("div");e.className="dynamsoft-mrz-info-notification",e.innerHTML=`\n
${$.info}
\n
\n Please review all fields to ensure the information is correct.\n
\n `,s.appendChild(e)}return Object.entries(t).forEach((([e,t])=>{var a;if(e===F.InvalidFields||!t)return;if(e===F.MRZText&&!1===(null===(a=this.config)||void 0===a?void 0:a.showMRZText))return;const o=document.createElement("div");o.className="dynamsoft-mrz-data-row";const r=i.includes(e);r&&o.classList.add("invalid-field");const l=[F.MRZText,F.DocumentType,F.IssuingStateRaw,F.NationalityRaw],c=document.createElement("span");if(c.className="dynamsoft-mrz-data-label",c.innerText=_[e]||e,r){const e=document.createElement("span");if(e.className="dynamsoft-mrz-error-icon",e.innerHTML=$.failed,c.appendChild(e),n){const e=document.createElement("span");e.className="dynamsoft-mrz-error-hint",e.textContent="Please correct this field",c.appendChild(e)}}const d=document.createElement("div");if(d.className="dynamsoft-mrz-data-value",n&&!l.includes(e)){const n=document.createElement("input");n.className="dynamsoft-mrz-data-input",r&&n.classList.add("invalid"),e===F.DateOfBirth||e===F.DateOfExpiry?(n.value=A(t),n.setAttribute("placeholder","YYYY-MM-DD")):n.value=t,n.addEventListener("input",(t=>{if(this.handleFieldEdit(e,t.target.value),r){n.classList.remove("invalid"),o.classList.remove("invalid-field"),this.editedFields.invalidFields||(this.editedFields.invalidFields=[...i]);const t=this.editedFields.invalidFields.indexOf(e);t>-1&&this.editedFields.invalidFields.splice(t,1)}})),d.appendChild(n)}else e===F.MRZText?(d.classList.add("code"),d.innerText=t):e===F.DateOfBirth||e===F.DateOfExpiry?d.innerText=A(t):d.innerText=t,r&&d.classList.add("invalid-value");o.appendChild(c),o.appendChild(d),s.appendChild(o)})),s}async initialize(){try{if(!this.resources.result)throw Error("Captured image is missing. Please capture an image first!");if(!this.config.container)throw new Error("Please create a Scan Result View Container element");b("dynamsoft-mrz-result-view-style",Z);const e=document.createElement("div");if(e.className="dynamsoft-mrz-result-view-container",!1!==this.config.showOriginalImage){const t=this.resources.result.originalImageResult,n=document.createElement("div");let i;n.className="dynamsoft-mrz-result-view-image-container",(null==t?void 0:t.toCanvas)&&(i=null==t?void 0:t.toCanvas()),Object.assign(i.style,{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}),n.appendChild(i),e.appendChild(n)}const t=this.createMRZDataDisplay();e.appendChild(t);const n=this.createControls();e.appendChild(n),x(this.config.container).appendChild(e)}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t)}}hideView(){x(this.config.container).style.display="none"}dispose(e=!1){x(this.config.container).textContent="",e||(this.currentScanResultViewResolver=void 0)}}const Z="\n .dynamsoft-mrz-result-view-container {\n display: flex;\n width: 100%;\n height: 100%;\n background-color:#575757;\n font-size: 12px;\n flex-direction: column;\n align-items: center;\n }\n\n .dynamsoft-mrz-result-view-image-container {\n width: 100%;\n height: 200px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #323234;\n }\n\n \n.dynamsoft-mrz-data-container {\n font-size: 16px;\n font-family: Verdana;\n color: white;\n overflow: auto;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 1rem 0;\n}\n\n.dynamsoft-mrz-data-row {\n padding: 0.5rem 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n transition: background-color 0.3s ease;\n}\n\n.dynamsoft-mrz-data-row.invalid-field {\n background-color: rgba(231, 76, 60, 0.1);\n border-left: 3px solid #e74c3c;\n padding-left: calc(2rem - 3px);\n}\n\n.dynamsoft-mrz-data-label {\n color: #aaa;\n display: flex;\n gap: 0.5rem;\n align-items: end;\n flex-wrap: wrap;\n}\n\n.dynamsoft-mrz-error-notification,\n.dynamsoft-mrz-info-notification {\n color: white;\n padding: 1rem;\n margin: 0.5rem 2rem;\n border-radius: 4px;\n display: flex;\n align-items: center;\n gap: 1rem;\n text-align: start;\n}\n\n.dynamsoft-mrz-error-notification {\n background-color: rgba(231, 76, 60, 0.2);\n}\n\n.dynamsoft-mrz-info-notification {\n background-color: rgba(196, 231, 60, 0.2);\n}\n\n.dynamsoft-mrz-edit-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #aaa;\n}\n\n.dynamsoft-mrz-error-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-info-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.dynamsoft-mrz-info-message,\n.dynamsoft-mrz-error-message {\n flex: 1;\n}\n\n.dynamsoft-mrz-error-hint {\n font-size: 0.8rem;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-value {\n word-wrap: break-word;\n text-align: start;\n}\n\n.dynamsoft-mrz-data-value.code {\n font-family: monospace;\n}\n\n.dynamsoft-mrz-data-value.invalid-value {\n color: #e74c3c;\n text-decoration: wavy underline #e74c3c;\n text-decoration-skip-ink: none;\n}\n\n.dynamsoft-mrz-data-input {\n width: 100%;\n padding: 5px;\n background-color: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.3);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n transition: all 0.3s ease;\n}\n\n.dynamsoft-mrz-data-input.invalid {\n background-color: rgba(231, 76, 60, 0.1);\n border-color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-input:focus {\n background-color: rgba(255, 255, 255, 0.2);\n border-color: #fe8e14;\n outline: none;\n}\n\n@media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-result-view-container {\n flex-direction: row;\n }\n\n .dynamsoft-mrz-result-view-image-container{\n flex: 1;\n height: 100%;\n }\n\n .dynamsoft-mrz-data-container{\n flex: 1;\n }\n\n .dynamsoft-mrz-data-row:first-of-type {\n padding-top: 2rem;\n }\n\n .dynamsoft-mrz-data-row:last-of-type {\n padding-bottom: 2rem;\n }\n\n .dynamsoft-mrz-data-row.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding-top: 0;\n padding-bottom: 0;\n }\n}\n",q={rootDirectory:"https://cdn.jsdelivr.net/npm/"};class G{showLoadingOverlay(e){var t,n;const i=x(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||x(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container);this.loadingScreen=N(i,{message:e}),i.style.display="block",i.style.position="relative"}hideLoadingOverlay(e=!1){var t,n,i;const s=x(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||x(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container);this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,s.style.display="none",e&&(null===(i=this.config)||void 0===i?void 0:i.container)&&(x(this.config.container).style.display="none"))}constructor(e){this.config=e,this.resources={},this.isInitialized=!1,this.isCapturing=!1,this.loadingScreen=null}async initialize(){if(this.isInitialized)return{resources:this.resources,components:{scannerView:this.scannerView,resultView:this.resultView}};try{if(!this.initializeMRZScannerConfig())return console.error("Failed to initialize mrz scanner config"),{resources:this.resources,components:{}};b("dynamsoft-mrz-loading-screen-style",L),this.showLoadingOverlay("Loading...");if(!await this.initializeDCVResources())return this.hideLoadingOverlay(!0),console.error("Failed to initialize DCV resources"),{resources:this.resources,components:{}};this.resources.onResultUpdated=e=>{this.resources.result=e};const e={};return this.config.scannerViewConfig&&(this.scannerView=new j(this.resources,this.config.scannerViewConfig),e.scannerView=this.scannerView,await this.scannerView.initialize()),this.config.resultViewConfig&&(this.resultView=new U(this.resources,this.config.resultViewConfig,this.scannerView),e.resultView=this.resultView),this.isInitialized=!0,{resources:this.resources,components:e}}catch(e){this.isInitialized=!1;const t=`Initialization Failed: ${(null==e?void 0:e.message)||e}`;return console.error(t),{resources:this.resources,components:{}}}finally{this.hideLoadingOverlay(!0)}}async initializeDCVResources(){var e,t,n;try{return s.engineResourcePaths=z(null===(e=this.config)||void 0===e?void 0:e.engineResourcePaths)?q:this.config.engineResourcePaths,o._onAuthMessage=e=>e.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=mrz&deploymenttype=web)"),await o.initLicense((null===(t=this.config)||void 0===t?void 0:t.license)||"",{executeNow:!0}),s.loadWasm(["DLR","DCP"]),f.loadSpec("MRTD_TD3_PASSPORT"),f.loadSpec("MRTD_TD1_ID"),f.loadSpec("MRTD_TD2_ID"),w.loadRecognitionData("MRZ"),this.resources.cameraView=await u.createInstance(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.cameraEnhancerUIPath),this.resources.cameraEnhancer=await m.createInstance(this.resources.cameraView),this.resources.cvRouter=await c.createInstance(),!0}catch(e){let t=(null==e?void 0:e.message)||e;if(null==t?void 0:t.toLowerCase().includes("license")){const e="The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.";alert(e),console.error(e)}else{const e=`Resource Initialization Failed: ${t}`;alert(e),console.error(e)}return!1}}shouldCreateDefaultContainer(){var e,t;const n=!this.config.container,i=!((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container));return n&&i}createDefaultMRZScannerContainer(){const e=document.createElement("div");return e.className="mrz-scanner-main-container",Object.assign(e.style,{height:"100dvh",width:"100%",position:"absolute",left:"0",top:"0",zIndex:"999"}),document.body.append(e),e}checkForTemporaryLicense(e){return!(null==e?void 0:e.length)||(null==e?void 0:e.startsWith("A"))||(null==e?void 0:e.startsWith("L"))||(null==e?void 0:e.startsWith("P"))||(null==e?void 0:e.startsWith("Y"))?"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9":e}validateViewConfigs(){var e,t,n,i,s,a,o,r;if(!this.config.container){if((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)&&this.config.showResultView&&!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container)){const e="MRZResultView container is required when showResultView is true";return alert(e),console.error(e),!1}if(!(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)&&(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container)&&!this.resources.result){const e="Result is needed to create MRZResultView without a scanner view";return alert(e),console.error(e),!1}}try{if(this.config.container&&!x(this.config.container)){const e="Invalid main container reference";return alert(e),console.error(e),!1}if((null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.container)&&!x(null===(a=this.config.scannerViewConfig)||void 0===a?void 0:a.container)){const e="Invalid scanner view container reference";return alert(e),console.error(e),!1}if((null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)&&!x(null===(r=this.config.resultViewConfig)||void 0===r?void 0:r.container)){const e="Invalid result view container reference";return alert(e),console.error(e),!1}}catch(e){const t=`Error accessing container references: ${e.message}`;return alert(t),console.error(t),!1}return!0}showResultView(){var e,t;return!1!==this.config.showResultView&&(this.config.container?!(void 0!==this.config.showResultView||!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container)&&!this.config.container)||!!this.config.showResultView:this.config.showResultView&&!!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container))}initializeMRZScannerConfig(){var e,t,n,i,s,a,o;this.config=null!==(e=this.config)&&void 0!==e?e:{};if(!this.validateViewConfigs())return!1;this.shouldCreateDefaultContainer()?this.config.container=this.createDefaultMRZScannerContainer():this.config.container&&(this.config.container=x(this.config.container));const r=this.config.container?this.createViewContainers(x(this.config.container)):{},l={license:this.checkForTemporaryLicense(this.config.license),utilizedTemplateNames:Object.fromEntries(Object.values(E).map((e=>{var t;return[e,(null===(t=this.config.utilizedTemplateNames)||void 0===t?void 0:t[e])||T[e]]}))),templateFilePath:(null===(t=this.config)||void 0===t?void 0:t.templateFilePath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.template.json"},c=Object.assign(Object.assign({},this.config.scannerViewConfig),{container:r[C.Scanner]||x(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)||null,cameraEnhancerUIPath:(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.cameraEnhancerUIPath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.ui.html",templateFilePath:l.templateFilePath,utilizedTemplateNames:l.utilizedTemplateNames,enableMultiFrameCrossFilter:null===(a=null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.enableMultiFrameCrossFilter)||void 0===a||a,mrzFormatType:this.config.mrzFormatType}),d=this.showResultView()?Object.assign(Object.assign({},this.config.resultViewConfig),{container:r[C.Result]||x(null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)||null}):void 0;return Object.assign(this.config,Object.assign(Object.assign({},l),{scannerViewConfig:c,resultViewConfig:d})),!0}createViewContainers(e){e.textContent="";const t=[C.Scanner];return this.showResultView()&&t.push(C.Result),t.reduce(((t,n)=>{const i=document.createElement("div");return i.className=`mrz-scanner-${n}-view-container`,Object.assign(i.style,{height:"100%",width:"100%",display:"none",position:"relative"}),e.append(i),t[n]=i,t}),{})}dispose(){var e,t;this.resultView&&(this.resultView.dispose(),this.resultView=null),this.scannerView=null,this.resources.cameraEnhancer&&(this.resources.cameraEnhancer.dispose(),this.resources.cameraEnhancer=null),this.resources.cameraView&&(this.resources.cameraView.dispose(),this.resources.cameraView=null),this.resources.cvRouter&&(this.resources.cvRouter.dispose(),this.resources.cvRouter=null),this.resources.result=null,this.resources.onResultUpdated=null;const n=e=>{const t=x(e);t&&(t.style.display="none",t.textContent="")};n(this.config.container),n(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container),n(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container),this.isInitialized=!1}async processUploadedFile(i){var s,a,o,r;try{this.showLoadingOverlay("Processing File...");const{cvRouter:l}=this.resources,c=null===(s=this.config.utilizedTemplateNames)||void 0===s?void 0:s.all,d=await l.getSimplifiedSettings(c);d.roiMeasuredInPercentage=!0,d.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await l.updateSettings(c,d);const h=await l.capture(i,c),u=h.items,m=u.filter((t=>t.type===e.CRIT_ORIGINAL_IMAGE))[0].imageData;m.toCanvas=()=>t(m),m.toBlob=async()=>await n("image/png",m);const g=null==h?void 0:h.textLineResultItems,p=null==h?void 0:h.parsedResultItems;let f={};if(null==g?void 0:g.length){const e=(null===(a=g[0])||void 0===a?void 0:a.text)||"";f=P(e,p[0])}const y={status:{code:M.RS_SUCCESS,message:"Success"},originalImageResult:m,data:f,imageData:!0,_imageData:m};null===(r=(o=this.resources).onResultUpdated)||void 0===r||r.call(o,y)}catch(e){return console.error("Failed to process uploaded file:",e),{status:{code:M.RS_FAILED,message:`Failed to process image: ${e.message||e}`}}}finally{this.hideLoadingOverlay(!1)}}async launch(e){if(this.isCapturing)throw new Error("Capture session already in progress");try{this.isCapturing=!0;const{components:t}=await this.initialize();if(z(t))throw new Error("MRZ Scanner initialization failed.");if(this.config.container&&(x(this.config.container).style.display="block"),e&&(t.scannerView=null,await this.processUploadedFile(e)),!t.scannerView&&this.resources.result&&t.resultView)return await t.resultView.launch();if(!t.scannerView&&!this.resources.result)throw new Error("Scanner view is required when no previous result exists");if(t.scannerView){const e=await t.scannerView.launch();if((null==e?void 0:e.status.code)!==M.RS_SUCCESS)return{status:{code:null==e?void 0:e.status.code,message:(null==e?void 0:e.status.message)||"Failed to capture image"}};if(t.resultView)return await t.resultView.launch()}return this.resources.result}catch(e){return alert((null==e?void 0:e.message)||e),console.error((null==e?void 0:e.message)||e),{status:{code:M.RS_FAILED,message:(null==e?void 0:e.message)||e}}}finally{this.isCapturing=!1,this.dispose()}}}const H={MRZScanner:G,MRZScannerView:j,MRZResultView:U};export{T as DEFAULT_TEMPLATE_NAMES,H as DynamsoftMRZScanner,F as EnumMRZData,D as EnumMRZDocumentType,E as EnumMRZScanMode,C as EnumMRZScannerViews,M as EnumResultStatus,_ as MRZDataLabel,U as MRZResultView,G as MRZScanner,j as MRZScannerView,A as displayMRZDate}; +import{EnumValidationStatus as e,MultiFrameResultCrossFilter as t,EnumCapturedResultItemType as n,CapturedResultReceiver as i,_toCanvas as s,_toBlob as a,Feedback as o,EnumImagePixelFormat as r,CoreModule as l,CodeParserModule as c,LicenseManager as d,CameraView as h,CameraEnhancer as u,CaptureVisionRouter as m}from"dynamsoft-capture-vision-bundle";import*as g from"dynamsoft-capture-vision-bundle";export{g as Dynamsoft};var p,f,y;!function(e){e.Passport="passport",e.TD1="td1",e.TD2="td2",e.PassportAndTD1="passportAndTd1",e.PassportAndTD2="passportAndTd2",e.TD1AndTD2="td1AndTd2",e.All="all"}(p||(p={})),function(e){e.Passport="passport",e.TD1="td1",e.TD2="td2"}(f||(f={})),function(e){e.Scanner="scanner",e.Result="scan-result"}(y||(y={}));const w={[p.Passport]:"ReadPassport",[p.TD1]:"ReadId-TD1",[p.TD2]:"ReadId-TD2",[p.PassportAndTD1]:"ReadPassportAndId-TD1",[p.PassportAndTD2]:"ReadPassportAndId-TD2",[p.TD1AndTD2]:"ReadId",[p.All]:"ReadPassportAndId"};var v;function S(e){if("string"==typeof e){const t=document.querySelector(e);if(!t)throw new Error("Element not found");return t}return e instanceof HTMLElement?e:null}!function(e){e[e.RS_SUCCESS=0]="RS_SUCCESS",e[e.RS_CANCELLED=1]="RS_CANCELLED",e[e.RS_FAILED=2]="RS_FAILED"}(v||(v={}));function R(e,t){if(!document.getElementById(e)){const n=document.createElement("style");n.id=e,n.textContent=t,document.head.appendChild(n)}}const E=e=>!e||0===Object.keys(e).length;function D(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}const C={"4k":{width:3840,height:2160},"2k":{width:2560,height:1440},"1080p":{width:1920,height:1080},"720p":{width:1280,height:720},"480p":{width:640,height:480}};function M(e,t={}){const{message:n,spinnerSize:i=32}=t,s=document.createElement("div");s.className="dynamsoft-mrz-loading-screen";const a=document.createElement("div");a.className="dynamsoft-mrz-loading";const o=document.createElement("div");o.className="dynamsoft-mrz-loading-content";const r=`\n \n \n \n `;if(o.innerHTML=r,n){const e=document.createElement("div");e.className="dynamsoft-mrz-loading-message",e.textContent=n,o.appendChild(e)}return a.appendChild(o),s.appendChild(a),e.appendChild(s),{element:s,updateMessage:e=>{let t=a.querySelector(".dynamsoft-mrz-loading-message");null!==e?t?t.textContent=e:(t=document.createElement("div"),t.className="dynamsoft-mrz-loading-message",t.textContent=e,o.appendChild(t)):null==t||t.remove()},hide:()=>{s&&s.parentNode&&(s.classList.add("fade-out"),setTimeout((()=>{var e;null===(e=s.parentNode)||void 0===e||e.removeChild(s)}),200))}}}const T='\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: "Verdana";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n';var b;!function(e){e.InvalidFields="invalidFields",e.DocumentType="documentType",e.DocumentNumber="documentNumber",e.MRZText="mrzText",e.FirstName="firstName",e.LastName="lastName",e.Age="age",e.Sex="sex",e.IssuingState="issuingState",e.IssuingStateRaw="issuingStateRaw",e.Nationality="nationality",e.NationalityRaw="nationalityRaw",e.DateOfBirth="dateOfBirth",e.DateOfExpiry="dateOfExpiry"}(b||(b={}));const x={[b.InvalidFields]:"Invalid Fields",[b.DocumentType]:"Document Type",[b.DocumentNumber]:"Document Number",[b.MRZText]:"MRZ Text",[b.FirstName]:"Given Name(s)",[b.LastName]:"Surname",[b.Age]:"Age",[b.Sex]:"Sex",[b.IssuingState]:"Issuing State",[b.IssuingStateRaw]:"Issuing State (Raw Value)",[b.Nationality]:"Nationality",[b.NationalityRaw]:"Nationality State (Raw Value)",[b.DateOfBirth]:"Date Of Birth (YYYY-MM-DD)",[b.DateOfExpiry]:"Date Of Expiry (YYYY-MM-DD)"};function z(e,t,n,i=!1){const s=parseInt(e,10);let a;if(i)a=s>=60?1900+s:2e3+s;else{a=s>(new Date).getFullYear()%100?1900+s:2e3+s}return{year:a,month:parseInt(t,10),day:parseInt(n,10)}}function I(e){const t=e=>{var t;return 1===(null===(t=`${e}`)||void 0===t?void 0:t.length)?`0${e}`:e};return`${null==e?void 0:e.year}-${t(null==e?void 0:e.month)}${(null==e?void 0:e.day)&&`-${t(null==e?void 0:e.day)}`}`}function V(e){return"D<<"===e?"D":e}function F(t,n){const i=[],s=t=>n.getFieldValidationStatus(t)===e.VS_FAILED,a=n.codeType,o=function(e){switch(e){case"MRTD_TD1_ID":return f.TD1;case"MRTD_TD2_ID":case"MRTD_TD2_VISA":case"MRTD_TD2_FRENCH_ID":return f.TD2;case"MRTD_TD3_PASSPORT":case"MRTD_TD3_VISA":return f.Passport;default:throw new Error(`Unknown document type: ${e}`)}}(a),r=function(e){switch(e){case"MRTD_TD1_ID":return"ID (TD1)";case"MRTD_TD2_ID":return"ID (TD2)";case"MRTD_TD2_VISA":return"ID (VISA)";case"MRTD_TD2_FRENCH_ID":return"French ID (TD2)";case"MRTD_TD3_PASSPORT":return"Passport (TD3)";case"MRTD_TD3_VISA":return"Visa (TD3)";default:throw new Error(`Unknown document type: ${e}`)}}(a),l=o===f.Passport&&"MRTD_TD3_PASSPORT"===a?"passportNumber":"documentNumber",c=z(n.getFieldValue("birthYear"),n.getFieldValue("birthMonth"),n.getFieldValue("birthDay")),d=z(n.getFieldValue("expiryYear"),n.getFieldValue("expiryMonth"),n.getFieldValue("expiryDay"),!0);["birthYear","birthMonth","birthDay"].forEach((e=>{s(e)&&i.push(b.DateOfBirth)})),["expiryYear","expiryMonth","expiryDay"].forEach((e=>{s(e)&&i.push(b.DateOfExpiry)}));const h={[b.LastName]:n.getFieldValue("primaryIdentifier"),[b.FirstName]:n.getFieldValue("secondaryIdentifier"),[b.Nationality]:n.getFieldValue("nationality"),[b.NationalityRaw]:V(n.getFieldRawValue("nationality")),[b.DocumentNumber]:n.getFieldValue(l)||n.getFieldValue("longDocumentNumber"),[b.IssuingState]:n.getFieldValue("issuingState"),[b.IssuingStateRaw]:V(n.getFieldRawValue("issuingState")),[b.Sex]:D(n.getFieldValue("sex"))};Object.keys(h).forEach((e=>{let t=!1;switch(e){case b.FirstName:t=s("secondaryIdentifier");break;case b.LastName:t=s("primaryIdentifier");break;case b.DocumentNumber:t=s(l)||s("longDocumentNumber");break;default:t=s(e)}t&&i.push(e)}));const u=function(e){const t=new Date,n=t.getMonth()+1>e.month||t.getMonth()+1===e.month&&t.getDate()>=e.day;return t.getFullYear()-e.year-(n?0:1)}(c);u<1&&i.push(b.Age);return{[b.InvalidFields]:i,[b.FirstName]:h[b.FirstName],[b.LastName]:h[b.LastName],[b.Age]:u,[b.DateOfBirth]:c,[b.Sex]:h[b.Sex],[b.Nationality]:h[b.Nationality],[b.NationalityRaw]:h[b.NationalityRaw],[b.DocumentNumber]:h[b.DocumentNumber],[b.DateOfExpiry]:d,[b.IssuingState]:h[b.IssuingState],[b.IssuingStateRaw]:h[b.IssuingStateRaw],[b.DocumentType]:D(r),[b.MRZText]:t}}const N={[f.TD1]:{width:85.6,height:53.98},[f.TD2]:{width:105,height:74},[f.Passport]:{width:125,height:88}};class _{showScannerLoadingOverlay(e){const t=S(this.config.container);this.loadingScreen=M(t,{message:e}),t.style.display="block",t.style.position="relative"}hideScannerLoadingOverlay(e=!1){this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,e&&(S(this.config.container).style.display="none"))}constructor(e,t){this.resources=e,this.config=t,this.isSoundFeedbackOn=!1,this.scanModeManager={[f.Passport]:!0,[f.TD1]:!0,[f.TD2]:!0},this.currentScanMode=p.All,this.resizeTimer=null,this.capturedResultItems=[],this.originalImageData=null,this.initialized=!1,this.initializedDCE=!1,this.DCE_ELEMENTS={selectCameraBtn:null,uploadImageBtn:null,soundFeedbackBtn:null,closeScannerBtn:null,scanModeSelectContainer:null,passportModeOption:null,td1ModeOption:null,td2ModeOption:null,toast:null},this.loadingScreen=null,this.handleResize=()=>{this.toggleScanGuide(!1),this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((()=>{this.toggleScanGuide(!0)}),500)},this.firstFrame=!0}async initialize(){if(!this.initialized){this.initializeScanModeManager(),this.currentScanMode=this.getScanMode(),R("dynamsoft-mrz-loading-screen-style",T);try{const{cameraView:e,cameraEnhancer:s,cvRouter:a}=this.resources;if(e.setScanRegionMaskStyle({strokeStyle:"transparent",fillStyle:"transparent",lineWidth:0}),e.setVideoFit("cover"),a.setInput(s),!0===this.config.enableMultiFrameCrossFilter){const e=new t;e.enableResultCrossVerification(n.CRIT_TEXT_LINE,!0),await a.addResultFilter(e)}const o=new i;o.onCapturedResultReceived=e=>this.handleMRZResult(e),await a.addResultReceiver(o),this.toggleSoundFeedback(!1),!1===this.config.showScanGuide&&this.toggleScanGuide(!1),this.initialized=!0}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:"Dynamsoft MRZ Scanner initialize error"}};this.currentScanResolver(n)}}}initializeElements(){var e;const t=S(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))throw new Error("Shadow root not found");if(this.DCE_ELEMENTS={selectCameraBtn:n.shadowRoot.querySelector(".dce-mn-select-camera-icon"),uploadImageBtn:n.shadowRoot.querySelector(".dce-mn-upload-image-icon"),soundFeedbackBtn:n.shadowRoot.querySelector(".dce-mn-sound-feedback"),closeScannerBtn:n.shadowRoot.querySelector(".dce-mn-close"),scanModeSelectContainer:n.shadowRoot.querySelector(".dce-mn-scan-mode-select"),passportModeOption:n.shadowRoot.querySelector(".scan-mode-option-passport"),td1ModeOption:n.shadowRoot.querySelector(".scan-mode-option-td1"),td2ModeOption:n.shadowRoot.querySelector(".scan-mode-option-td2"),toast:n.shadowRoot.querySelector(".dce-mn-toast")},this.setupScanModeSelector(),this.assignDCEClickEvents(),this.DCE_ELEMENTS.toast.style.display="none",!1===this.config.showUploadImage&&(this.DCE_ELEMENTS.uploadImageBtn.style.visibility="hidden"),!1===this.config.showSoundToggle&&(this.DCE_ELEMENTS.soundFeedbackBtn.style.visibility="hidden"),!1===(null===(e=this.config)||void 0===e?void 0:e.showPoweredByDynamsoft)){n.shadowRoot.querySelector(".dce-mn-msg-poweredby").style.display="none"}this.initializedDCE=!0}setupScanModeSelector(){if(!1!==this.config.showFormatSelector)switch(this.currentScanMode){case p.PassportAndTD1:this.DCE_ELEMENTS.td2ModeOption.style.display="none";break;case p.PassportAndTD2:this.DCE_ELEMENTS.td1ModeOption.style.display="none";break;case p.TD1AndTD2:this.DCE_ELEMENTS.passportModeOption.style.display="none";break;case p.All:break;default:this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}else this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}assignDCEClickEvents(){if(!Object.values(this.DCE_ELEMENTS).every(Boolean))throw new Error("Camera control elements not found");this.closeCamera=this.closeCamera.bind(this),this.DCE_ELEMENTS.uploadImageBtn.onclick=()=>this.uploadFile(),this.DCE_ELEMENTS.soundFeedbackBtn.onclick=()=>this.toggleSoundFeedback(),this.DCE_ELEMENTS.closeScannerBtn.onclick=()=>this.handleCloseBtn(),this.DCE_ELEMENTS.selectCameraBtn.onclick=e=>{e.stopPropagation(),this.toggleSelectCameraBox()},this.DCE_ELEMENTS.passportModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.passportModeOption.style.display&&await this.toggleScanDocType(f.Passport)},this.DCE_ELEMENTS.td1ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td1ModeOption.style.display&&await this.toggleScanDocType(f.TD1)},this.DCE_ELEMENTS.td2ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td2ModeOption.style.display&&await this.toggleScanDocType(f.TD2)}}handleCloseBtn(){this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:v.RS_CANCELLED,message:"Cancelled"}})}attachOptionClickListeners(){const e=S(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings");[...t.shadowRoot.querySelectorAll(".dce-mn-camera-option"),...t.shadowRoot.querySelectorAll(".dce-mn-resolution-option")].forEach((e=>{e.addEventListener("click",(async t=>{const i=e.getAttribute("data-davice-id"),s=e.getAttribute("data-height"),a=e.getAttribute("data-width");i?this.resources.cameraEnhancer.selectCamera(i).then((()=>{this.toggleScanGuide()})):s&&a&&this.resources.cameraEnhancer.setResolution({width:parseInt(a),height:parseInt(s)}).then((()=>{this.toggleScanGuide()})),"none"!==n.style.display&&this.toggleSelectCameraBox()}))}))}highlightCameraAndResolutionOption(){const e=S(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings"),i=n.querySelectorAll(".dce-mn-camera-option"),s=n.querySelectorAll(".dce-mn-resolution-option"),a=this.resources.cameraEnhancer.getSelectedCamera(),o=this.resources.cameraEnhancer.getResolution();i.forEach((e=>{const t=e;t.getAttribute("data-davice-id")===(null==a?void 0:a.deviceId)?t.style.border="2px solid #fe814a":t.style.border="none"}));const r={"480p":"480","720p":"720","1080p":"1080","2k":"1440","4k":"2160"},l=function(e){const t=e.width*e.height,n=e.width/e.height;let i="480p",s=Number.MAX_VALUE;for(const[e,a]of Object.entries(C)){const o=a.width*a.height,r=a.width/a.height,l=.7*Math.abs(o-t)+Math.abs(r-n)*o*.3;l{const t=e,n=t.getAttribute("data-height");t.style.border=n===r[l]?"2px solid #fe814a":"none"}))}toggleSelectCameraBox(){const e=S(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-resolution-box");this.highlightCameraAndResolutionOption(),this.attachOptionClickListeners(),n.click()}async relaunch(){}async uploadFile(){var e,t,i,o,r,l;const{cvRouter:c}=this.resources,d=document.createElement("input");d.type="file",d.accept=null!==(e=this.config.uploadAcceptedTypes)&&void 0!==e?e:"image/*",d.style.display="none",document.body.appendChild(d);try{this.showScannerLoadingOverlay("Processing file..."),await this.closeCamera(!1);const e=await new Promise(((e,t)=>{d.onchange=n=>{var i;const s=null===(i=n.target.files)||void 0===i?void 0:i[0];s?e(s):t(new Error("No file selected"))},d.addEventListener("cancel",(async()=>{this.hideScannerLoadingOverlay(!1),this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()})),d.click()}));if(!e)return;let h;if(this.config.uploadFileConverter&&!e.type.startsWith("image/"))try{h=await this.config.uploadFileConverter(e)}catch(e){throw new Error(`Error converting file: ${e.message}`)}else{if(!e.type.startsWith("image/"))throw new Error("Unsupported file type. Please provide a converter function for this file type.");h=e}const u=this.config.utilizedTemplateNames[this.currentScanMode];if(!1!==this.config.showScanGuide){const e=await c.getSimplifiedSettings(u);e.roiMeasuredInPercentage=!0,e.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await c.updateSettings(u,e)}const m=await c.capture(h,u);this.capturedResultItems=m.items;const g=this.capturedResultItems.filter((e=>e.type===n.CRIT_ORIGINAL_IMAGE));if(0===g.length)throw new Error("No image data found in the captured result");const p=g[0].imageData;p.toCanvas=()=>s(p),p.toBlob=async()=>await a("image/png",p),this.originalImageData=p;const f=null===(t=null==m?void 0:m.parsedResult)||void 0===t?void 0:t.parsedResultItems;let y={};if(null==f?void 0:f.length){const e=(null===(o=null===(i=f[0])||void 0===i?void 0:i.referencedItem)||void 0===o?void 0:o.text)||"";y=F(e,f[0])}const w={status:{code:v.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:y,imageData:!0,_imageData:this.originalImageData};null===(l=(r=this.resources).onResultUpdated)||void 0===l||l.call(r,w),this.currentScanResolver(w)}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:`Error processing file: ${t}`}};this.currentScanResolver(n)}finally{this.hideScannerLoadingOverlay(!0),document.body.removeChild(d)}}toggleSoundFeedback(e){this.isSoundFeedbackOn=void 0!==e?e:!this.isSoundFeedbackOn;const t=S(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const i=n.shadowRoot.querySelector(".dce-mn-sound-feedback"),s=i.querySelector(".dce-mn-sound-feedback-on");i.querySelector(".dce-mn-sound-feedback-off").style.display=this.isSoundFeedbackOn?"none":"block",s.style.display=this.isSoundFeedbackOn?"block":"none"}calculateScanRegion(e){const{cameraEnhancer:t,cameraView:n}=this.resources;if(!t||!t.isOpen())return;const i=N[e].width/N[e].height;let s;const a=n.getVisibleRegionOfVideo({inPixels:!0}),{width:o,height:r}=a;if(a){if(a.width>a.height){const e=.5*r*i,t=Math.round(e/o*100),n=(100-t)/2;s={left:n,right:n+t,top:25,bottom:75,isMeasuredInPercentage:!0}}else{const e=.9*o/i,t=Math.round(e/r*100),n=(100-t)/2;s={left:5,right:95,top:n,bottom:n+t,isMeasuredInPercentage:!0}}null==n||n.setScanRegionMaskVisible(!0),t.setScanRegion(s)}}toggleScanGuide(e){const t=S(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const i=n.shadowRoot.querySelector(".dce-scanguide-passport"),s=n.shadowRoot.querySelector(".dce-scanguide-td1"),a=n.shadowRoot.querySelector(".dce-scanguide-td2");if(!1===e||!1===this.config.showScanGuide)return i.style.display="none",s.style.display="none",void(a.style.display="none");switch(this.currentScanMode){case p.All:case p.Passport:case p.PassportAndTD1:case p.PassportAndTD2:i.style.display="block",s.style.display="none",a.style.display="none",this.calculateScanRegion(f.Passport);break;case p.TD1:case p.TD1AndTD2:i.style.display="none",s.style.display="block",a.style.display="none",this.calculateScanRegion(f.TD1);break;case p.TD2:i.style.display="none",s.style.display="none",a.style.display="block",this.calculateScanRegion(f.TD2)}}async openCamera(){try{const{cameraEnhancer:e,cameraView:t}=this.resources,n=S(this.config.container);if(n.style.display="block",e.isOpen())e.isPaused()&&await e.resume();else{const i=t.getUIElement();i.parentElement||n.append(i),await e.open()}await e.setResolution({width:2560,height:1440}),!this.initializedDCE&&e.isOpen()&&await this.initializeElements(),window.addEventListener("resize",this.handleResize);const i=n.children[n.children.length-1];if(!(null==i?void 0:i.shadowRoot))throw new Error("Shadow root not found");i.shadowRoot.querySelector(".dce-mn-torch-off").style.display="none",i.shadowRoot.querySelector(".dce-mn-torch-on").style.display="none"}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:"MRZ Scanner Open Camera Error"}};this.currentScanResolver(n)}}async closeCamera(e=!0){try{window.removeEventListener("resize",this.handleResize),this.resizeTimer&&(window.clearTimeout(this.resizeTimer),this.resizeTimer=null);const{cameraEnhancer:t,cameraView:n}=this.resources,i=S(this.config.container);i.style.display=e?"none":"block",(null==n?void 0:n.getUIElement().parentElement)&&i.removeChild(n.getUIElement()),t.close(),this.stopCapturing()}catch(e){let t=(null==e?void 0:e.message)||e;console.error(`Close Camera error: ${t}`)}}pauseCamera(){const{cameraEnhancer:e}=this.resources;e.pause()}stopCapturing(){const{cameraView:e,cvRouter:t}=this.resources;t.stopCapturing(),e.clearAllInnerDrawingItems()}async handleMRZResult(e){var t,i,r;if(this.firstFrame)this.firstFrame=!1;else if(!(e.items.length<=1)){this.capturedResultItems=e.items;try{const{onResultUpdated:l}=this.resources,c=e.items.filter((e=>e.type===n.CRIT_ORIGINAL_IMAGE))[0].imageData;c.toCanvas=()=>s(c),c.toBlob=async()=>await a("image/png",c),this.originalImageData=c;const d=null===(t=null==e?void 0:e.parsedResult)||void 0===t?void 0:t.parsedResultItems;if(null==d?void 0:d.length){this.isSoundFeedbackOn&&o.beep();const e=(null===(r=null===(i=d[0])||void 0===i?void 0:i.referencedItem)||void 0===r?void 0:r.text)||"",t=F(e,d[0]);this.closeCamera();const n={status:{code:v.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:t,imageData:!0,_imageData:this.originalImageData};null==l||l(n),this.currentScanResolver(n)}}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:"Error capturing image"}};this.currentScanResolver(n)}}}initializeScanModeManager(){const{mrzFormatType:e}=this.config;if(this.scanModeManager={[f.Passport]:!0,[f.TD1]:!0,[f.TD2]:!0},!e||Array.isArray(e)&&0===e.length)return;Object.keys(this.scanModeManager).forEach((e=>{this.scanModeManager[e]=!1}));(Array.isArray(e)?e:[e]).forEach((e=>{this.scanModeManager[e]=!0}))}getScanMode(){const e=Object.entries(this.scanModeManager).filter((([e,t])=>t)).map((([e])=>e)).sort().join(",");return{[f.Passport]:p.Passport,[f.TD1]:p.TD1,[f.TD2]:p.TD2,[`${f.Passport},${f.TD1}`]:p.PassportAndTD1,[`${f.Passport},${f.TD2}`]:p.PassportAndTD2,[`${f.TD1},${f.TD2}`]:p.TD1AndTD2,[`${f.Passport},${f.TD1},${f.TD2}`]:p.All,"":p.All}[e]}DCEShowToast(e,t=3e3){this.DCE_ELEMENTS.toast&&(this.DCE_ELEMENTS.toast.textContent=e,this.DCE_ELEMENTS.toast.style.display="",setTimeout((()=>{this.DCE_ELEMENTS.toast.style.display="none"}),t))}async startCapturing(){const{cvRouter:e,cameraEnhancer:t}=this.resources,n=this.config.utilizedTemplateNames[this.currentScanMode];try{if(!1!==this.config.showScanGuide){const t=await e.getSimplifiedSettings(n);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:50},{x:100,y:50},{x:100,y:100},{x:0,y:100}],await e.updateSettings(n,t)}this.firstFrame=!0,await e.startCapturing(n),t.setPixelFormat(r.IPF_ABGR_8888)}catch(e){let t=(null==e?void 0:e.message)||e;console.error("Failed to start capturing:",t),this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:v.RS_FAILED,message:"Failed to start capturing"}})}}async toggleScanDocType(e){try{if(this.scanModeManager[e]&&0===Object.entries(this.scanModeManager).filter((([t,n])=>n&&t!==e)).length)return console.warn("MRZ Scanner - At least one mode must be enabled"),void this.DCEShowToast("At least one mode must be enabled");this.scanModeManager[e]=!this.scanModeManager[e],this.currentScanMode=this.getScanMode(),this.stopCapturing(),this.toggleScanGuide(),await this.startCapturing(),this.DCE_ELEMENTS.td1ModeOption.classList.toggle("selected",this.scanModeManager[f.TD1]),this.DCE_ELEMENTS.td2ModeOption.classList.toggle("selected",this.scanModeManager[f.TD2]),this.DCE_ELEMENTS.passportModeOption.classList.toggle("selected",this.scanModeManager[f.Passport])}catch(e){let t=(null==e?void 0:e.message)||e;console.error("MRZ Scanner switch scan mode error: ",t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:"MRZ Scanner switch scan mode error"}};this.currentScanResolver(n)}}async launch(){try{await this.initialize();const{cvRouter:e,cameraEnhancer:t}=this.resources;return new Promise((async e=>{this.currentScanResolver=e,this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),!this.initializedDCE&&t.isOpen()&&await this.initializeElements(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()}))}catch(e){let t=(null==e?void 0:e.message)||e;console.error("MRZ Scanner launch error: ",t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:"MRZ Scanner launch error"}};this.currentScanResolver(n)}}}const L={cancel:'\n\n \n \n \n \n \n \n \n \n \n \n ',rescan:'\n\n\n \n\n\n\n\n\n\n\n',complete:'\n\n\n\n \n\n\n\n\n\n\n\n',failed:'\n \n \n \n\n',info:'\n\n \n \n \n\n'};class k{constructor(e,t,n){this.resources=e,this.config=t,this.scannerView=n,this.editedFields={}}async launch(){try{return S(this.config.container).textContent="",await this.initialize(),S(this.config.container).style.display="flex",new Promise((e=>{this.currentScanResultViewResolver=e}))}catch(e){let t=(null==e?void 0:e.message)||e;throw console.error(t),t}}async handleRescan(){var e;try{if(!this.scannerView)return void console.error("Scanner View not initialized");this.hideView();const t=await this.scannerView.launch();if((null===(e=null==t?void 0:t.status)||void 0===e?void 0:e.code)===v.RS_FAILED)return void(this.currentScanResultViewResolver&&this.currentScanResultViewResolver(t));this.resources.onResultUpdated&&((null==t?void 0:t.status.code)===v.RS_CANCELLED?this.resources.onResultUpdated(this.resources.result):(null==t?void 0:t.status.code)===v.RS_SUCCESS&&this.resources.onResultUpdated(t)),this.dispose(!0),await this.initialize(),S(this.config.container).style.display="flex"}catch(e){throw console.error("Error in rescan handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:v.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}async handleCancel(){var e;try{(null===(e=this.config)||void 0===e?void 0:e.onCancel)&&await this.config.onCancel(this.resources.result),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:v.RS_CANCELLED,message:"Upload file cancelled"}}),this.hideView(),this.dispose()}catch(e){throw console.error("Error in cancel handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:v.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}async handleDone(){var e,t;try{(null===(e=this.resources.result)||void 0===e?void 0:e.data)&&!E(this.editedFields)&&(this.resources.result.data=Object.assign(Object.assign({},this.resources.result.data),this.editedFields),this.resources.onResultUpdated&&this.resources.onResultUpdated(this.resources.result)),(null===(t=this.config)||void 0===t?void 0:t.onDone)&&await this.config.onDone(this.resources.result),this.currentScanResultViewResolver&&this.resources.result&&this.currentScanResultViewResolver(this.resources.result),this.hideView(),this.dispose()}catch(e){throw console.error("Error in done handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:v.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}createControls(){var e,t,n,i,s,a,o,r,l,c,d,h;const{toolbarButtonsConfig:u}=this.config;return function(e){R("dynamsoft-mrz-controls-style","\n .dynamsoft-mrz-controls {\n display: flex;\n height: 6rem;\n background-color: #323234;\n align-items: center;\n font-size: 12px;\n font-family: Verdana;\n color: white;\n width: 100%;\n }\n\n .dynamsoft-mrz-control-btn {\n background-color: #323234;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n gap: 0.5rem;\n text-align: center;\n user-select: none;\n }\n\n .dynamsoft-mrz-control-btn.hide {\n display: none;\n }\n\n .dynamsoft-mrz-control-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n cursor: default;\n }\n\n .dynamsoft-mrz-control-icon-wrapper {\n flex: 0.75;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n min-height: 40px;\n }\n\n .dynamsoft-mrz-control-icon img,\n .dynamsoft-mrz-control-icon svg {\n width: 32px;\n height: 32px;\n fill: #fe8e14;\n }\n\n .dynamsoft-mrz-control-text {\n flex: 0.5;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-bottom: 0.5rem;\n }\n\n \n @media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-controls {\n flex-direction: column;\n height: 100%;\n width: 5rem;\n }\n\n .dynamsoft-mrz-control-text {\n padding: 0 0.5rem 0.5rem;\n }\n }\n");const t=document.createElement("div");return t.className="dynamsoft-mrz-controls",e.forEach((e=>{const n=document.createElement("div");n.className=`dynamsoft-mrz-control-btn ${null==e?void 0:e.className}`;const i=document.createElement("div");if(i.className="dynamsoft-mrz-control-icon-wrapper",(s=e.icon).trim().startsWith(""))i.innerHTML=e.icon;else{const t=document.createElement("img");t.src=e.icon,t.alt=e.label,t.width=24,t.height=24,i.appendChild(t)}var s;const a=document.createElement("div");a.className="dynamsoft-mrz-control-text",a.textContent=e.label,e.isDisabled&&n.classList.add("disabled"),e.isHidden&&n.classList.add("hide"),n.appendChild(i),n.appendChild(a),e.onClick&&!e.isDisabled&&n.addEventListener("click",e.onClick),t.appendChild(n)})),t}([this.config._isFileMode?{id:"dynamsoft-mrz-scanResult-cancel",icon:(null===(e=null==u?void 0:u.cancel)||void 0===e?void 0:e.icon)||L.cancel,label:(null===(t=null==u?void 0:u.cancel)||void 0===t?void 0:t.label)||"Cancel",onClick:()=>this.handleCancel(),className:`${(null===(n=null==u?void 0:u.cancel)||void 0===n?void 0:n.className)||""}`,isHidden:(null===(i=null==u?void 0:u.cancel)||void 0===i?void 0:i.isHidden)||!1}:{id:"dynamsoft-mrz-scanResult-rescan",icon:(null===(s=null==u?void 0:u.rescan)||void 0===s?void 0:s.icon)||L.rescan,label:(null===(a=null==u?void 0:u.rescan)||void 0===a?void 0:a.label)||"Re-scan",onClick:()=>this.handleRescan(),className:`${(null===(o=null==u?void 0:u.rescan)||void 0===o?void 0:o.className)||""}`,isHidden:(null===(r=null==u?void 0:u.rescan)||void 0===r?void 0:r.isHidden)||!1,isDisabled:!this.scannerView},{id:"dynamsoft-mrz-scanResult-done",icon:(null===(l=null==u?void 0:u.done)||void 0===l?void 0:l.icon)||L.complete,label:(null===(c=null==u?void 0:u.done)||void 0===c?void 0:c.label)||"Done",className:`${(null===(d=null==u?void 0:u.done)||void 0===d?void 0:d.className)||""}`,isHidden:(null===(h=null==u?void 0:u.done)||void 0===h?void 0:h.isHidden)||!1,onClick:()=>this.handleDone()}])}handleFieldEdit(e,t){if(e===b.DateOfBirth||e===b.DateOfExpiry)try{const[n,i,s]=t.split(/[\/\-\.]/);s&&i&&n&&(this.editedFields[e]={day:parseInt(s,10),month:parseInt(i,10),year:parseInt(n,10)})}catch(e){console.error("Error parsing date",e)}else this.editedFields[e]=t}createMRZDataDisplay(){var e,t,n,i;const s=(null===(e=this.resources.result)||void 0===e?void 0:e.data)||{},a=!!this.config.allowResultEditing,o=s.invalidFields||[],r=[b.InvalidFields,b.IssuingStateRaw,b.NationalityRaw];!1===(null===(t=this.config)||void 0===t?void 0:t.showMRZText)&&r.push(b.MRZText);const l=document.createElement("div");if(l.className="dynamsoft-mrz-data-container",E(s)){const e=document.createElement("div");return e.className="dynamsoft-mrz-data-row empty",e.innerText=null!==(i=null===(n=this.config)||void 0===n?void 0:n.emptyResultMessage)&&void 0!==i?i:"The necessary information couldn't be detected. Please try again.",l.appendChild(e),l}if(o.length>0){const e=document.createElement("div");e.className="dynamsoft-mrz-error-notification",e.innerHTML=`\n
${L.failed}
\n
\n ${a?"Some fields require correction. Please review highlighted fields.":"Some fields contain invalid information. Please rescan the document."}\n
\n `,l.appendChild(e)}else if(0===o.length&&a){const e=document.createElement("div");e.className="dynamsoft-mrz-info-notification",e.innerHTML=`\n
${L.info}
\n
\n Please review all fields to ensure the information is correct.\n
\n `,l.appendChild(e)}return Object.entries(s).forEach((([e,t])=>{if(r.includes(e)||!t)return;const n=document.createElement("div");n.className="dynamsoft-mrz-data-row";const i=o.includes(e);i&&n.classList.add("invalid-field");const s=[b.MRZText,b.DocumentType,b.IssuingStateRaw,b.NationalityRaw],c=document.createElement("span");if(c.className="dynamsoft-mrz-data-label",c.innerText=x[e]||e,i){const e=document.createElement("span");if(e.className="dynamsoft-mrz-error-icon",e.innerHTML=L.failed,c.appendChild(e),a){const e=document.createElement("span");e.className="dynamsoft-mrz-error-hint",e.textContent="Please correct this field",c.appendChild(e)}}const d=document.createElement("div");if(d.className="dynamsoft-mrz-data-value",a&&!s.includes(e)){const s=document.createElement("input");s.className="dynamsoft-mrz-data-input",i&&s.classList.add("invalid"),e===b.DateOfBirth||e===b.DateOfExpiry?(s.value=I(t),s.setAttribute("placeholder","YYYY-MM-DD")):s.value=t,s.addEventListener("input",(t=>{if(this.handleFieldEdit(e,t.target.value),i){s.classList.remove("invalid"),n.classList.remove("invalid-field"),this.editedFields.invalidFields||(this.editedFields.invalidFields=[...o]);const t=this.editedFields.invalidFields.indexOf(e);t>-1&&this.editedFields.invalidFields.splice(t,1)}})),d.appendChild(s)}else e===b.MRZText?(d.classList.add("code"),d.innerText=t):e===b.DateOfBirth||e===b.DateOfExpiry?d.innerText=I(t):d.innerText=t,i&&d.classList.add("invalid-value");n.appendChild(c),n.appendChild(d),l.appendChild(n)})),l}async initialize(){try{if(!this.resources.result)throw Error("Captured image is missing. Please capture an image first!");if(!this.config.container)throw new Error("Please create a Scan Result View Container element");R("dynamsoft-mrz-result-view-style",A);const e=document.createElement("div");if(e.className="dynamsoft-mrz-result-view-container",!1!==this.config.showOriginalImage){const t=this.resources.result.originalImageResult,n=document.createElement("div");let i;n.className="dynamsoft-mrz-result-view-image-container",(null==t?void 0:t.toCanvas)&&(i=null==t?void 0:t.toCanvas()),Object.assign(i.style,{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}),n.appendChild(i),e.appendChild(n)}const t=this.createMRZDataDisplay();e.appendChild(t);const n=this.createControls();e.appendChild(n),S(this.config.container).appendChild(e)}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t)}}hideView(){S(this.config.container).style.display="none"}dispose(e=!1){S(this.config.container).textContent="",e||(this.currentScanResultViewResolver=void 0)}}const A="\n .dynamsoft-mrz-result-view-container {\n display: flex;\n width: 100%;\n height: 100%;\n background-color:#575757;\n font-size: 12px;\n flex-direction: column;\n align-items: center;\n }\n\n .dynamsoft-mrz-result-view-image-container {\n width: 100%;\n height: 200px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #323234;\n }\n\n \n.dynamsoft-mrz-data-container {\n font-size: 16px;\n font-family: Verdana;\n color: white;\n overflow: auto;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 1rem 0;\n}\n\n.dynamsoft-mrz-data-row {\n padding: 0.5rem 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n transition: background-color 0.3s ease;\n}\n\n.dynamsoft-mrz-data-row.invalid-field {\n background-color: rgba(231, 76, 60, 0.1);\n border-left: 3px solid #e74c3c;\n padding-left: calc(2rem - 3px);\n}\n\n.dynamsoft-mrz-data-label {\n color: #aaa;\n display: flex;\n gap: 0.5rem;\n align-items: end;\n flex-wrap: wrap;\n}\n\n.dynamsoft-mrz-error-notification,\n.dynamsoft-mrz-info-notification {\n color: white;\n padding: 1rem;\n margin: 0.5rem 2rem;\n border-radius: 4px;\n display: flex;\n align-items: center;\n gap: 1rem;\n text-align: start;\n}\n\n.dynamsoft-mrz-error-notification {\n background-color: rgba(231, 76, 60, 0.2);\n}\n\n.dynamsoft-mrz-info-notification {\n background-color: #fe8e14;\n}\n\n.dynamsoft-mrz-edit-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #aaa;\n}\n\n.dynamsoft-mrz-error-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-info-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.dynamsoft-mrz-info-message,\n.dynamsoft-mrz-error-message {\n flex: 1;\n}\n\n.dynamsoft-mrz-error-hint {\n font-size: 0.8rem;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-value {\n word-wrap: break-word;\n text-align: start;\n}\n\n.dynamsoft-mrz-data-value.code {\n font-family: monospace;\n}\n\n.dynamsoft-mrz-data-value.invalid-value {\n color: #e74c3c;\n text-decoration: wavy underline #e74c3c;\n text-decoration-skip-ink: none;\n}\n\n.dynamsoft-mrz-data-input {\n width: 100%;\n padding: 5px;\n background-color: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.3);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n transition: all 0.3s ease;\n}\n\n.dynamsoft-mrz-data-input.invalid {\n background-color: rgba(231, 76, 60, 0.1);\n border-color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-input:focus {\n background-color: rgba(255, 255, 255, 0.2);\n border-color: #fe8e14;\n outline: none;\n}\n\n@media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-result-view-container {\n flex-direction: row;\n }\n\n .dynamsoft-mrz-result-view-image-container{\n flex: 1;\n height: 100%;\n }\n\n .dynamsoft-mrz-data-container{\n flex: 1;\n }\n\n .dynamsoft-mrz-data-row:first-of-type {\n padding-top: 2rem;\n }\n\n .dynamsoft-mrz-data-row:last-of-type {\n padding-bottom: 2rem;\n }\n\n .dynamsoft-mrz-data-row.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding-top: 0;\n padding-bottom: 0;\n }\n}\n",O={rootDirectory:"https://cdn.jsdelivr.net/npm/"};class P{showLoadingOverlay(e){var t,n;const i=S(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||S(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container);this.loadingScreen=M(i,{message:e}),i.style.display="block",i.style.position="relative"}hideLoadingOverlay(e=!1){var t,n,i;const s=S(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||S(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container);this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,s.style.display="none",e&&(null===(i=this.config)||void 0===i?void 0:i.container)&&(S(this.config.container).style.display="none"))}constructor(e){this.config=e,this.resources={},this.isInitialized=!1,this.isCapturing=!1,this.loadingScreen=null,this.isDynamsoftResourcesLoaded=!1,this.isFileMode=!1,this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources()}async initialize(){if(this.isInitialized)return{resources:this.resources,components:{scannerView:this.scannerView,resultView:this.resultView}};try{if(!this.initializeMRZScannerConfig())return console.error("Failed to initialize mrz scanner config"),{resources:this.resources,components:{}};R("dynamsoft-mrz-loading-screen-style",T),this.showLoadingOverlay("Loading..."),await this.initializeDCVResources(),this.resources.onResultUpdated=e=>{this.resources.result=e};const e={};return this.config.scannerViewConfig&&!this.isFileMode&&(this.scannerView=new _(this.resources,this.config.scannerViewConfig),e.scannerView=this.scannerView,await this.scannerView.initialize()),this.config.resultViewConfig&&(this.resultView=new k(this.resources,this.config.resultViewConfig,this.scannerView),e.resultView=this.resultView),this.isInitialized=!0,{resources:this.resources,components:e}}catch(e){this.isInitialized=!1;const t=`Initialization Failed: ${(null==e?void 0:e.message)||e}`;throw console.error(t),new Error(t)}finally{this.hideLoadingOverlay(!0)}}initializeDynamsoftResources(){var e;l.engineResourcePaths=E(null===(e=this.config)||void 0===e?void 0:e.engineResourcePaths)?O:this.config.engineResourcePaths,l.loadWasm(),c.loadSpec("MRTD_TD3_PASSPORT"),c.loadSpec("MRTD_TD3_VISA"),c.loadSpec("MRTD_TD1_ID"),c.loadSpec("MRTD_TD2_ID"),c.loadSpec("MRTD_TD2_VISA"),this.isDynamsoftResourcesLoaded=!0}async initializeDCVResources(){var e,t;try{this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources(),d._onAuthMessage=e=>e.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=mrz&deploymenttype=web)"),await d.initLicense((null===(e=this.config)||void 0===e?void 0:e.license)||"",{executeNow:!0}),this.isFileMode||(this.resources.cameraView=await h.createInstance(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.cameraEnhancerUIPath),this.resources.cameraEnhancer=await u.createInstance(this.resources.cameraView)),this.resources.cvRouter=await m.createInstance(),await this.resources.cvRouter.initSettings(this.config.templateFilePath)}catch(e){let t=(null==e?void 0:e.message)||e;const n=(null==t?void 0:t.toLowerCase().includes("license"))?"The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.":`Resource Initialization Failed: ${t}`;throw console.error(n),new Error(n)}}shouldCreateDefaultContainer(){var e,t;const n=!this.config.container,i=!((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container));return n&&i}createDefaultMRZScannerContainer(){const e=document.createElement("div");return e.className="mrz-scanner-main-container",Object.assign(e.style,{height:"100dvh",width:"100%",position:"absolute",left:"0",top:"0",zIndex:"999"}),document.body.append(e),e}checkForTemporaryLicense(e){return!(null==e?void 0:e.length)||(null==e?void 0:e.startsWith("A"))||(null==e?void 0:e.startsWith("L"))||(null==e?void 0:e.startsWith("P"))||(null==e?void 0:e.startsWith("Y"))?"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9":e}validateViewConfigs(){var e,t,n,i,s,a,o,r;if(!this.config.container){if((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)&&this.config.showResultView&&!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container)){const e="MRZResultView container is required when showResultView is true";return alert(e),console.error(e),!1}if(!(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)&&(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container)&&!this.resources.result){const e="Result is needed to create MRZResultView without a scanner view";return alert(e),console.error(e),!1}}try{if(this.config.container&&!S(this.config.container)){const e="Invalid main container reference";return alert(e),console.error(e),!1}if((null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.container)&&!S(null===(a=this.config.scannerViewConfig)||void 0===a?void 0:a.container)){const e="Invalid scanner view container reference";return alert(e),console.error(e),!1}if((null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)&&!S(null===(r=this.config.resultViewConfig)||void 0===r?void 0:r.container)){const e="Invalid result view container reference";return alert(e),console.error(e),!1}}catch(e){const t=`Error accessing container references: ${e.message}`;return alert(t),console.error(t),!1}return!0}showResultView(){var e,t;return!1!==this.config.showResultView&&(this.config.container?!(void 0!==this.config.showResultView||!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container)&&!this.config.container)||!!this.config.showResultView:this.config.showResultView&&!!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container))}initializeMRZScannerConfig(){var e,t,n,i,s,a,o;this.config=null!==(e=this.config)&&void 0!==e?e:{};if(!this.validateViewConfigs())return!1;this.shouldCreateDefaultContainer()?this.config.container=this.createDefaultMRZScannerContainer():this.config.container&&(this.config.container=S(this.config.container));const r=this.config.container?this.createViewContainers(S(this.config.container)):{},l={license:this.checkForTemporaryLicense(this.config.license),utilizedTemplateNames:Object.fromEntries(Object.values(p).map((e=>{var t;return[e,(null===(t=this.config.utilizedTemplateNames)||void 0===t?void 0:t[e])||w[e]]}))),templateFilePath:(null===(t=this.config)||void 0===t?void 0:t.templateFilePath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.template.json"},c=Object.assign(Object.assign({},this.config.scannerViewConfig),{container:r[y.Scanner]||S(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)||null,cameraEnhancerUIPath:(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.cameraEnhancerUIPath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.ui.html",templateFilePath:l.templateFilePath,utilizedTemplateNames:l.utilizedTemplateNames,enableMultiFrameCrossFilter:null===(a=null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.enableMultiFrameCrossFilter)||void 0===a||a,mrzFormatType:this.config.mrzFormatType}),d=this.showResultView()?Object.assign(Object.assign({},this.config.resultViewConfig),{_isFileMode:this.isFileMode,container:r[y.Result]||S(null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)||null}):void 0;return Object.assign(this.config,Object.assign(Object.assign({},l),{scannerViewConfig:c,resultViewConfig:d})),!0}createViewContainers(e){e.textContent="";const t=[y.Scanner];return this.showResultView()&&t.push(y.Result),t.reduce(((t,n)=>{const i=document.createElement("div");return i.className=`mrz-scanner-${n}-view-container`,Object.assign(i.style,{height:"100%",width:"100%",display:"none",position:"relative"}),e.append(i),t[n]=i,t}),{})}dispose(){var e,t;this.resultView&&(this.resultView.dispose(),this.resultView=null),this.scannerView=null,this.resources.cameraEnhancer&&(this.resources.cameraEnhancer.dispose(),this.resources.cameraEnhancer=null),this.resources.cameraView&&(this.resources.cameraView.dispose(),this.resources.cameraView=null),this.resources.cvRouter&&(this.resources.cvRouter.dispose(),this.resources.cvRouter=null),this.resources.result=null,this.resources.onResultUpdated=null;const n=e=>{const t=S(e);t&&(t.style.display="none",t.textContent="")};n(this.config.container),n(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container),n(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container),this.isInitialized=!1}async processUploadedFile(e){var t,i,o,r,l,c;try{this.showLoadingOverlay("Processing File...");const{cvRouter:d}=this.resources,h=null===(t=this.config.utilizedTemplateNames)||void 0===t?void 0:t.all,u=await d.getSimplifiedSettings(h);u.roiMeasuredInPercentage=!0,u.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await d.updateSettings(h,u);const m=await d.capture(e,h),g=m.items,p=g.filter((e=>e.type===n.CRIT_ORIGINAL_IMAGE))[0].imageData;p.toCanvas=()=>s(p),p.toBlob=async()=>await a("image/png",p);const f=null===(i=null==m?void 0:m.parsedResult)||void 0===i?void 0:i.parsedResultItems;let y={};if(null==f?void 0:f.length){const e=(null===(r=null===(o=f[0])||void 0===o?void 0:o.referencedItem)||void 0===r?void 0:r.text)||"";y=F(e,f[0])}const w={status:{code:v.RS_SUCCESS,message:"Success"},originalImageResult:p,data:y,imageData:!0,_imageData:p};null===(c=(l=this.resources).onResultUpdated)||void 0===c||c.call(l,w)}catch(e){return console.error("Failed to process uploaded file:",e),{status:{code:v.RS_FAILED,message:`Failed to process image: ${e.message||e}`}}}finally{this.hideLoadingOverlay(!1)}}async launch(e){if(this.isCapturing)throw new Error("Capture session already in progress");try{this.isCapturing=!0,this.isFileMode=!!e;const{components:t}=await this.initialize();if(E(t))throw new Error("MRZ Scanner initialization failed ");if(this.config.container&&(S(this.config.container).style.display="block"),this.isFileMode&&await this.processUploadedFile(e),!t.scannerView&&this.resources.result&&t.resultView)return await t.resultView.launch();if(!t.scannerView&&!this.resources.result&&!this.isFileMode)throw new Error("Scanner view is required when no previous result exists");if(t.scannerView){const e=await t.scannerView.launch();if((null==e?void 0:e.status.code)!==v.RS_SUCCESS)return{status:{code:null==e?void 0:e.status.code,message:(null==e?void 0:e.status.message)||"Failed to capture image"}};if(t.resultView)return await t.resultView.launch()}return this.resources.result}catch(e){return alert((null==e?void 0:e.message)||e),console.error((null==e?void 0:e.message)||e),{status:{code:v.RS_FAILED,message:(null==e?void 0:e.message)||e}}}finally{this.isCapturing=!1,this.dispose()}}}const B={MRZScanner:P,MRZScannerView:_,MRZResultView:k};export{w as DEFAULT_TEMPLATE_NAMES,B as DynamsoftMRZScanner,b as EnumMRZData,f as EnumMRZDocumentType,p as EnumMRZScanMode,y as EnumMRZScannerViews,v as EnumResultStatus,x as MRZDataLabel,k as MRZResultView,P as MRZScanner,_ as MRZScannerView,I as displayMRZDate}; diff --git a/dist/mrz-scanner.no-content-bundle.esm.js b/dist/mrz-scanner.no-content-bundle.esm.js index f14faed..0f0cda9 100644 --- a/dist/mrz-scanner.no-content-bundle.esm.js +++ b/dist/mrz-scanner.no-content-bundle.esm.js @@ -1 +1 @@ -import{EnumCapturedResultItemType as e,_toCanvas as t,_toBlob as n,EnumImagePixelFormat as i,CoreModule as s}from"dynamsoft-core";export*from"dynamsoft-core";import{LicenseManager as a}from"dynamsoft-license";export*from"dynamsoft-license";import{CapturedResultReceiver as o,CaptureVisionRouter as r}from"dynamsoft-capture-vision-router";export*from"dynamsoft-capture-vision-router";import{Feedback as l,CameraView as c,CameraEnhancer as d}from"dynamsoft-camera-enhancer";export*from"dynamsoft-camera-enhancer";import{LabelRecognizerModule as h}from"dynamsoft-label-recognizer";export*from"dynamsoft-label-recognizer";import{EnumValidationStatus as u,CodeParserModule as m}from"dynamsoft-code-parser";export*from"dynamsoft-code-parser";import{MultiFrameResultCrossFilter as g}from"dynamsoft-utility";export*from"dynamsoft-utility";var p,f,y;!function(e){e.Passport="passport",e.TD1="td1",e.TD2="td2",e.PassportAndTD1="passportAndTd1",e.PassportAndTD2="passportAndTd2",e.TD1AndTD2="td1AndTd2",e.All="all"}(p||(p={})),function(e){e.Passport="passport",e.TD1="td1",e.TD2="td2"}(f||(f={})),function(e){e.Scanner="scanner",e.Result="scan-result"}(y||(y={}));const w={[p.Passport]:"ReadPassport",[p.TD1]:"ReadId-TD1",[p.TD2]:"ReadId-TD2",[p.PassportAndTD1]:"ReadPassportAndId-TD1",[p.PassportAndTD2]:"ReadPassportAndId-TD2",[p.TD1AndTD2]:"ReadId",[p.All]:"ReadPassportAndId"};var v;function S(e){if("string"==typeof e){const t=document.querySelector(e);if(!t)throw new Error("Element not found");return t}return e instanceof HTMLElement?e:null}!function(e){e[e.RS_SUCCESS=0]="RS_SUCCESS",e[e.RS_CANCELLED=1]="RS_CANCELLED",e[e.RS_FAILED=2]="RS_FAILED"}(v||(v={}));function E(e,t){if(!document.getElementById(e)){const n=document.createElement("style");n.id=e,n.textContent=t,document.head.appendChild(n)}}const R=e=>!e||0===Object.keys(e).length;function D(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}const C={"4k":{width:3840,height:2160},"2k":{width:2560,height:1440},"1080p":{width:1920,height:1080},"720p":{width:1280,height:720},"480p":{width:640,height:480}};function T(e,t={}){const{message:n,spinnerSize:i=32}=t,s=document.createElement("div");s.className="dynamsoft-mrz-loading-screen";const a=document.createElement("div");a.className="dynamsoft-mrz-loading";const o=document.createElement("div");o.className="dynamsoft-mrz-loading-content";const r=`\n \n \n \n `;if(o.innerHTML=r,n){const e=document.createElement("div");e.className="dynamsoft-mrz-loading-message",e.textContent=n,o.appendChild(e)}return a.appendChild(o),s.appendChild(a),e.appendChild(s),{element:s,updateMessage:e=>{let t=a.querySelector(".dynamsoft-mrz-loading-message");null!==e?t?t.textContent=e:(t=document.createElement("div"),t.className="dynamsoft-mrz-loading-message",t.textContent=e,o.appendChild(t)):null==t||t.remove()},hide:()=>{s&&s.parentNode&&(s.classList.add("fade-out"),setTimeout((()=>{var e;null===(e=s.parentNode)||void 0===e||e.removeChild(s)}),200))}}}const M='\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: "Verdana";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n';var x;!function(e){e.InvalidFields="invalidFields",e.DocumentType="documentType",e.DocumentNumber="documentNumber",e.MRZText="mrzText",e.FirstName="firstName",e.LastName="lastName",e.Age="age",e.Sex="sex",e.IssuingState="issuingState",e.IssuingStateRaw="issuingStateRaw",e.Nationality="nationality",e.NationalityRaw="nationalityRaw",e.DateOfBirth="dateOfBirth",e.DateOfExpiry="dateOfExpiry"}(x||(x={}));const b={[x.InvalidFields]:"Invalid Fields",[x.DocumentType]:"Document Type",[x.DocumentNumber]:"Document Number",[x.MRZText]:"MRZ Text",[x.FirstName]:"Given Name(s)",[x.LastName]:"Surname",[x.Age]:"Age",[x.Sex]:"Sex",[x.IssuingState]:"Issuing State",[x.IssuingStateRaw]:"Issuing State (Raw Value)",[x.Nationality]:"Nationality",[x.NationalityRaw]:"Nationality State (Raw Value)",[x.DateOfBirth]:"Date Of Birth (YYYY-MM-DD)",[x.DateOfExpiry]:"Date Of Expiry (YYYY-MM-DD)"};function z(e,t,n,i=!1){const s=parseInt(e,10);let a;if(i)a=s>=60?1900+s:2e3+s;else{a=s>(new Date).getFullYear()%100?1900+s:2e3+s}return{year:a,month:parseInt(t,10),day:parseInt(n,10)}}function I(e){const t=e=>{var t;return 1===(null===(t=`${e}`)||void 0===t?void 0:t.length)?`0${e}`:e};return`${null==e?void 0:e.year}-${t(null==e?void 0:e.month)}${(null==e?void 0:e.day)&&`-${t(null==e?void 0:e.day)}`}`}function V(e){return"D<<"===e?"D":e}function N(e,t){const n=[],i=e=>t.getFieldValidationStatus(e)===u.VS_FAILED,s=t.codeType,a=function(e){switch(e){case"MRTD_TD1_ID":return f.TD1;case"MRTD_TD2_ID":case"MRTD_TD2_VISA":case"MRTD_TD2_FRENCH_ID":return f.TD2;case"MRTD_TD3_PASSPORT":case"MRTD_TD3_VISA":return f.Passport;default:throw new Error(`Unknown document type: ${e}`)}}(s),o=function(e){switch(e){case"MRTD_TD1_ID":return"ID (TD1)";case"MRTD_TD2_ID":return"ID (TD2)";case"MRTD_TD2_VISA":return"ID (VISA)";case"MRTD_TD2_FRENCH_ID":return"French ID (TD2)";case"MRTD_TD3_PASSPORT":return"Passport (TD3)";case"MRTD_TD3_VISA":return"Visa (TD3)";default:throw new Error(`Unknown document type: ${e}`)}}(s),r=a===f.Passport&&"MRTD_TD3_PASSPORT"===s?"passportNumber":"documentNumber",l=z(t.getFieldValue("birthYear"),t.getFieldValue("birthMonth"),t.getFieldValue("birthDay")),c=z(t.getFieldValue("expiryYear"),t.getFieldValue("expiryMonth"),t.getFieldValue("expiryDay"),!0);["birthYear","birthMonth","birthDay"].forEach((e=>{i(e)&&n.push(x.DateOfBirth)})),["expiryYear","expiryMonth","expiryDay"].forEach((e=>{i(e)&&n.push(x.DateOfExpiry)}));const d={[x.LastName]:t.getFieldValue("primaryIdentifier"),[x.FirstName]:t.getFieldValue("secondaryIdentifier"),[x.Nationality]:t.getFieldValue("nationality"),[x.NationalityRaw]:V(t.getFieldRawValue("nationality")),[x.DocumentNumber]:t.getFieldValue(r)||t.getFieldValue("longDocumentNumber"),[x.IssuingState]:t.getFieldValue("issuingState"),[x.IssuingStateRaw]:V(t.getFieldRawValue("issuingState")),[x.Sex]:D(t.getFieldValue("sex"))};Object.keys(d).forEach((e=>{let t=!1;switch(e){case x.FirstName:t=i("secondaryIdentifier");break;case x.LastName:t=i("primaryIdentifier");break;case x.DocumentNumber:t=i(r)||i("longDocumentNumber");break;default:t=i(e)}t&&n.push(e)}));const h=function(e){const t=new Date,n=t.getMonth()+1>e.month||t.getMonth()+1===e.month&&t.getDate()>=e.day;return t.getFullYear()-e.year-(n?0:1)}(l);h<1&&n.push(x.Age);return{[x.InvalidFields]:n,[x.FirstName]:d[x.FirstName],[x.LastName]:d[x.LastName],[x.Age]:h,[x.DateOfBirth]:l,[x.Sex]:d[x.Sex],[x.Nationality]:d[x.Nationality],[x.NationalityRaw]:d[x.NationalityRaw],[x.DocumentNumber]:d[x.DocumentNumber],[x.DateOfExpiry]:c,[x.IssuingState]:d[x.IssuingState],[x.IssuingStateRaw]:d[x.IssuingStateRaw],[x.DocumentType]:D(o),[x.MRZText]:e}}const L={[f.TD1]:{width:85.6,height:53.98},[f.TD2]:{width:105,height:74},[f.Passport]:{width:125,height:88}};class F{showScannerLoadingOverlay(e){const t=S(this.config.container);this.loadingScreen=T(t,{message:e}),t.style.display="block",t.style.position="relative"}hideScannerLoadingOverlay(e=!1){this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,e&&(S(this.config.container).style.display="none"))}constructor(e,t){this.resources=e,this.config=t,this.isSoundFeedbackOn=!1,this.scanModeManager={[f.Passport]:!0,[f.TD1]:!0,[f.TD2]:!0},this.currentScanMode=p.All,this.resizeTimer=null,this.capturedResultItems=[],this.originalImageData=null,this.initialized=!1,this.initializedDCE=!1,this.DCE_ELEMENTS={selectCameraBtn:null,uploadImageBtn:null,soundFeedbackBtn:null,closeScannerBtn:null,scanModeSelectContainer:null,passportModeOption:null,td1ModeOption:null,td2ModeOption:null,toast:null},this.loadingScreen=null,this.handleResize=()=>{this.toggleScanGuide(!1),this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((()=>{this.toggleScanGuide(!0)}),500)}}async initialize(){if(!this.initialized){this.initializeScanModeManager(),this.currentScanMode=this.getScanMode(),E("dynamsoft-mrz-loading-screen-style",M);try{const{cameraView:t,cameraEnhancer:n,cvRouter:i}=this.resources;if(t.setScanRegionMaskStyle({strokeStyle:"transparent",fillStyle:"transparent",lineWidth:0}),t.setVideoFit("cover"),i.setInput(n),await i.initSettings(this.config.templateFilePath),!0===this.config.enableMultiFrameCrossFilter){const t=new g;t.enableResultCrossVerification(e.CRIT_TEXT_LINE,!0),t.enableResultDeduplication(e.CRIT_TEXT_LINE,!0),await i.addResultFilter(t)}const s=new o;s.onCapturedResultReceived=e=>this.handleMRZResult(e),await i.addResultReceiver(s),this.toggleSoundFeedback(!1),!1===this.config.showScanGuide&&this.toggleScanGuide(!1),this.initialized=!0}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:"Dynamsoft MRZ Scanner initialize error"}};this.currentScanResolver(n)}}}initializeElements(){var e;const t=S(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))throw new Error("Shadow root not found");if(this.DCE_ELEMENTS={selectCameraBtn:n.shadowRoot.querySelector(".dce-mn-select-camera-icon"),uploadImageBtn:n.shadowRoot.querySelector(".dce-mn-upload-image-icon"),soundFeedbackBtn:n.shadowRoot.querySelector(".dce-mn-sound-feedback"),closeScannerBtn:n.shadowRoot.querySelector(".dce-mn-close"),scanModeSelectContainer:n.shadowRoot.querySelector(".dce-mn-scan-mode-select"),passportModeOption:n.shadowRoot.querySelector(".scan-mode-option-passport"),td1ModeOption:n.shadowRoot.querySelector(".scan-mode-option-td1"),td2ModeOption:n.shadowRoot.querySelector(".scan-mode-option-td2"),toast:n.shadowRoot.querySelector(".dce-mn-toast")},this.setupScanModeSelector(),this.assignDCEClickEvents(),this.DCE_ELEMENTS.toast.style.display="none",!1===this.config.showUploadImage&&(this.DCE_ELEMENTS.uploadImageBtn.style.visibility="hidden"),!1===this.config.showSoundToggle&&(this.DCE_ELEMENTS.soundFeedbackBtn.style.visibility="hidden"),!1===(null===(e=this.config)||void 0===e?void 0:e.showPoweredByDynamsoft)){n.shadowRoot.querySelector(".dce-mn-msg-poweredby").style.display="none"}this.initializedDCE=!0}setupScanModeSelector(){if(!1!==this.config.showFormatSelector)switch(this.currentScanMode){case p.PassportAndTD1:this.DCE_ELEMENTS.td2ModeOption.style.display="none";break;case p.PassportAndTD2:this.DCE_ELEMENTS.td1ModeOption.style.display="none";break;case p.TD1AndTD2:this.DCE_ELEMENTS.passportModeOption.style.display="none";break;case p.All:break;default:this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}else this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}assignDCEClickEvents(){if(!Object.values(this.DCE_ELEMENTS).every(Boolean))throw new Error("Camera control elements not found");this.closeCamera=this.closeCamera.bind(this),this.DCE_ELEMENTS.uploadImageBtn.onclick=()=>this.uploadFile(),this.DCE_ELEMENTS.soundFeedbackBtn.onclick=()=>this.toggleSoundFeedback(),this.DCE_ELEMENTS.closeScannerBtn.onclick=()=>this.handleCloseBtn(),this.DCE_ELEMENTS.selectCameraBtn.onclick=e=>{e.stopPropagation(),this.toggleSelectCameraBox()},this.DCE_ELEMENTS.passportModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.passportModeOption.style.display&&await this.toggleScanDocType(f.Passport)},this.DCE_ELEMENTS.td1ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td1ModeOption.style.display&&await this.toggleScanDocType(f.TD1)},this.DCE_ELEMENTS.td2ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td2ModeOption.style.display&&await this.toggleScanDocType(f.TD2)}}handleCloseBtn(){this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:v.RS_CANCELLED,message:"Cancelled"}})}attachOptionClickListeners(){const e=S(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings");[...t.shadowRoot.querySelectorAll(".dce-mn-camera-option"),...t.shadowRoot.querySelectorAll(".dce-mn-resolution-option")].forEach((e=>{e.addEventListener("click",(async t=>{const i=e.getAttribute("data-davice-id"),s=e.getAttribute("data-height"),a=e.getAttribute("data-width");i?this.resources.cameraEnhancer.selectCamera(i).then((()=>{this.toggleScanGuide()})):s&&a&&this.resources.cameraEnhancer.setResolution({width:parseInt(a),height:parseInt(s)}).then((()=>{this.toggleScanGuide()})),"none"!==n.style.display&&this.toggleSelectCameraBox()}))}))}highlightCameraAndResolutionOption(){const e=S(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings"),i=n.querySelectorAll(".dce-mn-camera-option"),s=n.querySelectorAll(".dce-mn-resolution-option"),a=this.resources.cameraEnhancer.getSelectedCamera(),o=this.resources.cameraEnhancer.getResolution();i.forEach((e=>{const t=e;t.getAttribute("data-davice-id")===(null==a?void 0:a.deviceId)?t.style.border="2px solid #fe814a":t.style.border="none"}));const r={"480p":"480","720p":"720","1080p":"1080","2k":"1440","4k":"2160"},l=function(e){const t=e.width*e.height,n=e.width/e.height;let i="480p",s=Number.MAX_VALUE;for(const[e,a]of Object.entries(C)){const o=a.width*a.height,r=a.width/a.height,l=.7*Math.abs(o-t)+Math.abs(r-n)*o*.3;l{const t=e,n=t.getAttribute("data-height");t.style.border=n===r[l]?"2px solid #fe814a":"none"}))}toggleSelectCameraBox(){const e=S(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-resolution-box");this.highlightCameraAndResolutionOption(),this.attachOptionClickListeners(),n.click()}async relaunch(){}async uploadFile(){var i,s,a,o;const{cvRouter:r}=this.resources,l=document.createElement("input");l.type="file",l.accept=null!==(i=this.config.uploadAcceptedTypes)&&void 0!==i?i:"image/*",l.style.display="none",document.body.appendChild(l);try{this.showScannerLoadingOverlay("Processing file..."),await this.closeCamera(!1);const i=await new Promise(((e,t)=>{l.onchange=n=>{var i;const s=null===(i=n.target.files)||void 0===i?void 0:i[0];s?e(s):t(new Error("No file selected"))},l.addEventListener("cancel",(async()=>{this.hideScannerLoadingOverlay(!1),await this.openCamera(),await this.startCapturing(),this.toggleScanGuide()})),l.click()}));if(!i)return;let c;if(this.config.uploadFileConverter&&!i.type.startsWith("image/"))try{c=await this.config.uploadFileConverter(i)}catch(e){throw new Error(`Error converting file: ${e.message}`)}else{if(!i.type.startsWith("image/"))throw new Error("Unsupported file type. Please provide a converter function for this file type.");c=i}const d=this.config.utilizedTemplateNames[this.currentScanMode];if(!1!==this.config.showScanGuide){const e=await r.getSimplifiedSettings(d);e.roiMeasuredInPercentage=!0,e.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await r.updateSettings(d,e)}const h=await r.capture(c,d);this.capturedResultItems=h.items;const u=this.capturedResultItems.filter((t=>t.type===e.CRIT_ORIGINAL_IMAGE));if(0===u.length)throw new Error("No image data found in the captured result");const m=u[0].imageData;m.toCanvas=()=>t(m),m.toBlob=async()=>await n("image/png",m),this.originalImageData=m;const g=null==h?void 0:h.textLineResultItems,p=null==h?void 0:h.parsedResultItems;let f={};if(null==g?void 0:g.length){const e=(null===(s=g[0])||void 0===s?void 0:s.text)||"";f=N(e,p[0])}const y={status:{code:v.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:f,imageData:!0,_imageData:this.originalImageData};null===(o=(a=this.resources).onResultUpdated)||void 0===o||o.call(a,y),this.currentScanResolver(y)}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:`Error processing file: ${t}`}};this.currentScanResolver(n)}finally{this.hideScannerLoadingOverlay(!0),document.body.removeChild(l)}}toggleSoundFeedback(e){this.isSoundFeedbackOn=void 0!==e?e:!this.isSoundFeedbackOn;const t=S(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const i=n.shadowRoot.querySelector(".dce-mn-sound-feedback"),s=i.querySelector(".dce-mn-sound-feedback-on");i.querySelector(".dce-mn-sound-feedback-off").style.display=this.isSoundFeedbackOn?"none":"block",s.style.display=this.isSoundFeedbackOn?"block":"none"}calculateScanRegion(e){const{cameraEnhancer:t,cameraView:n}=this.resources;if(!t||!t.isOpen())return;const i=n.getVisibleRegionOfVideo({inPixels:!0});if(!i)return;const s=n.getVideoElement(),a=s.videoWidth,o=s.videoHeight,r=L[e];let l;const c=i.height-80;if(i.width>i.height){l=.75*c/r.height;l*r.width>.9*i.width&&(l=.9*i.width/r.width)}else{l=.9*i.width/r.width;l*r.height>.75*c&&(l=.75*c/r.height)}const d=l*r.width,h=l*r.height,u=(i.width-d)/2,m=(c-h)/2,g=u,p=u+d,f=m,y=m+h,w=(i.x+g)/a*100,v=(i.x+p)/a*100,S=(i.y+f)/o*100,E=(i.y+y)/o*100,R={left:Math.round(w),right:Math.round(v),top:Math.round(S),bottom:Math.round(E),isMeasuredInPercentage:!0};null==n||n.setScanRegionMaskVisible(!0),t.setScanRegion(R)}toggleScanGuide(e){const t=S(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const i=n.shadowRoot.querySelector(".dce-scanguide-passport"),s=n.shadowRoot.querySelector(".dce-scanguide-td1"),a=n.shadowRoot.querySelector(".dce-scanguide-td2");if(!1===e||!1===this.config.showScanGuide)return i.style.display="none",s.style.display="none",void(a.style.display="none");switch(this.currentScanMode){case p.All:case p.Passport:case p.PassportAndTD1:case p.PassportAndTD2:i.style.display="block",s.style.display="none",a.style.display="none",this.calculateScanRegion(f.Passport);break;case p.TD1:case p.TD1AndTD2:i.style.display="none",s.style.display="block",a.style.display="none",this.calculateScanRegion(f.TD1);break;case p.TD2:i.style.display="none",s.style.display="none",a.style.display="block",this.calculateScanRegion(f.TD2)}}async openCamera(){try{this.showScannerLoadingOverlay("Initializing camera...");const{cameraEnhancer:e,cameraView:t}=this.resources,n=S(this.config.container);if(n.style.display="block",e.isOpen())e.isPaused()&&await e.resume();else{const i=t.getUIElement();i.parentElement||n.append(i),await e.open()}await e.setResolution({width:2560,height:1440}),!this.initializedDCE&&e.isOpen()&&await this.initializeElements(),window.addEventListener("resize",this.handleResize);const i=n.children[n.children.length-1];if(!(null==i?void 0:i.shadowRoot))throw new Error("Shadow root not found");i.shadowRoot.querySelector(".dce-mn-torch-off").style.display="none",i.shadowRoot.querySelector(".dce-mn-torch-on").style.display="none"}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:"MRZ Scanner Open Camera Error"}};this.currentScanResolver(n)}finally{this.hideScannerLoadingOverlay()}}async closeCamera(e=!0){try{window.removeEventListener("resize",this.handleResize),this.resizeTimer&&(window.clearTimeout(this.resizeTimer),this.resizeTimer=null);const{cameraEnhancer:t,cameraView:n}=this.resources,i=S(this.config.container);i.style.display=e?"none":"block",(null==n?void 0:n.getUIElement().parentElement)&&i.removeChild(n.getUIElement()),t.close(),this.stopCapturing()}catch(e){let t=(null==e?void 0:e.message)||e;console.error(`Close Camera error: ${t}`)}}pauseCamera(){const{cameraEnhancer:e}=this.resources;e.pause()}stopCapturing(){const{cameraView:e,cvRouter:t}=this.resources;t.stopCapturing(),e.clearAllInnerDrawingItems()}async handleMRZResult(i){var s;if(this.capturedResultItems=i.items,!(i.items.length<=1))try{const{onResultUpdated:a}=this.resources,o=i.items.filter((t=>t.type===e.CRIT_ORIGINAL_IMAGE))[0].imageData;o.toCanvas=()=>t(o),o.toBlob=async()=>await n("image/png",o),this.originalImageData=o;const r=null==i?void 0:i.textLineResultItems,c=null==i?void 0:i.parsedResultItems;if(r){this.isSoundFeedbackOn&&l.beep();const e=(null===(s=null==r?void 0:r[0])||void 0===s?void 0:s.text)||"",t=N(e,c[0]);this.closeCamera();const n={status:{code:v.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:t,imageData:!0,_imageData:this.originalImageData};null==a||a(n),this.currentScanResolver(n)}}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:"Error capturing image"}};this.currentScanResolver(n)}}initializeScanModeManager(){const{mrzFormatType:e}=this.config;if(this.scanModeManager={[f.Passport]:!0,[f.TD1]:!0,[f.TD2]:!0},!e||Array.isArray(e)&&0===e.length)return;Object.keys(this.scanModeManager).forEach((e=>{this.scanModeManager[e]=!1}));(Array.isArray(e)?e:[e]).forEach((e=>{this.scanModeManager[e]=!0}))}getScanMode(){const e=Object.entries(this.scanModeManager).filter((([e,t])=>t)).map((([e])=>e)).sort().join(",");return{[f.Passport]:p.Passport,[f.TD1]:p.TD1,[f.TD2]:p.TD2,[`${f.Passport},${f.TD1}`]:p.PassportAndTD1,[`${f.Passport},${f.TD2}`]:p.PassportAndTD2,[`${f.TD1},${f.TD2}`]:p.TD1AndTD2,[`${f.Passport},${f.TD1},${f.TD2}`]:p.All,"":p.All}[e]}DCEShowToast(e,t=3e3){this.DCE_ELEMENTS.toast&&(this.DCE_ELEMENTS.toast.textContent=e,this.DCE_ELEMENTS.toast.style.display="",setTimeout((()=>{this.DCE_ELEMENTS.toast.style.display="none"}),t))}async startCapturing(){const{cvRouter:e,cameraEnhancer:t}=this.resources,n=this.config.utilizedTemplateNames[this.currentScanMode];try{if(!1!==this.config.showScanGuide){const t=await e.getSimplifiedSettings(n);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:50},{x:100,y:50},{x:100,y:100},{x:0,y:100}],await e.updateSettings(n,t)}await e.startCapturing(n),t.setPixelFormat(i.IPF_ABGR_8888)}catch(e){let t=(null==e?void 0:e.message)||e;console.error("Failed to start capturing:",t),this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:v.RS_FAILED,message:"Failed to start capturing"}})}}async toggleScanDocType(e){try{if(this.scanModeManager[e]&&0===Object.entries(this.scanModeManager).filter((([t,n])=>n&&t!==e)).length)return console.warn("MRZ Scanner - At least one mode must be enabled"),void this.DCEShowToast("At least one mode must be enabled");this.scanModeManager[e]=!this.scanModeManager[e],this.currentScanMode=this.getScanMode(),this.stopCapturing(),await this.startCapturing(),this.toggleScanGuide(),this.DCE_ELEMENTS.td1ModeOption.classList.toggle("selected",this.scanModeManager[f.TD1]),this.DCE_ELEMENTS.td2ModeOption.classList.toggle("selected",this.scanModeManager[f.TD2]),this.DCE_ELEMENTS.passportModeOption.classList.toggle("selected",this.scanModeManager[f.Passport])}catch(e){let t=(null==e?void 0:e.message)||e;console.error("MRZ Scanner switch scan mode error: ",t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:"MRZ Scanner switch scan mode error"}};this.currentScanResolver(n)}}async launch(){try{await this.initialize();const{cvRouter:e,cameraEnhancer:t}=this.resources;return new Promise((async e=>{this.currentScanResolver=e,await this.openCamera(),!this.initializedDCE&&t.isOpen()&&await this.initializeElements(),await this.startCapturing(),this.toggleScanGuide()}))}catch(e){let t=(null==e?void 0:e.message)||e;console.error("MRZ Scanner launch error: ",t),this.closeCamera();const n={status:{code:v.RS_FAILED,message:"MRZ Scanner launch error"}};this.currentScanResolver(n)}}}const _={rescan:'\n\n\n \n\n\n\n\n\n\n\n',complete:'\n\n\n\n \n\n\n\n\n\n\n\n',failed:'\n \n \n \n\n',info:'\n\n \n \n \n\n'};class k{constructor(e,t,n){this.resources=e,this.config=t,this.scannerView=n,this.editedFields={}}async launch(){try{return S(this.config.container).textContent="",await this.initialize(),S(this.config.container).style.display="flex",new Promise((e=>{this.currentScanResultViewResolver=e}))}catch(e){let t=(null==e?void 0:e.message)||e;throw console.error(t),t}}async handleRescan(){var e;try{if(!this.scannerView)return void console.error("Scanner View not initialized");this.hideView();const t=await this.scannerView.launch();if((null===(e=null==t?void 0:t.status)||void 0===e?void 0:e.code)===v.RS_FAILED)return void(this.currentScanResultViewResolver&&this.currentScanResultViewResolver(t));this.resources.onResultUpdated&&((null==t?void 0:t.status.code)===v.RS_CANCELLED?this.resources.onResultUpdated(this.resources.result):(null==t?void 0:t.status.code)===v.RS_SUCCESS&&this.resources.onResultUpdated(t)),this.dispose(!0),await this.initialize(),S(this.config.container).style.display="flex"}catch(e){throw console.error("Error in rescan handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:v.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}async handleDone(){var e,t;try{(null===(e=this.resources.result)||void 0===e?void 0:e.data)&&!R(this.editedFields)&&(this.resources.result.data=Object.assign(Object.assign({},this.resources.result.data),this.editedFields),this.resources.onResultUpdated&&this.resources.onResultUpdated(this.resources.result)),(null===(t=this.config)||void 0===t?void 0:t.onDone)&&await this.config.onDone(this.resources.result),this.currentScanResultViewResolver&&this.resources.result&&this.currentScanResultViewResolver(this.resources.result),this.hideView(),this.dispose()}catch(e){throw console.error("Error in done handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:v.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}createControls(){var e,t,n,i,s,a,o,r;const{toolbarButtonsConfig:l}=this.config;return function(e){E("dynamsoft-mrz-controls-style","\n .dynamsoft-mrz-controls {\n display: flex;\n height: 6rem;\n background-color: #323234;\n align-items: center;\n font-size: 12px;\n font-family: Verdana;\n color: white;\n width: 100%;\n }\n\n .dynamsoft-mrz-control-btn {\n background-color: #323234;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n gap: 0.5rem;\n text-align: center;\n user-select: none;\n }\n\n .dynamsoft-mrz-control-btn.hide {\n display: none;\n }\n\n .dynamsoft-mrz-control-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n cursor: default;\n }\n\n .dynamsoft-mrz-control-icon-wrapper {\n flex: 0.75;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n min-height: 40px;\n }\n\n .dynamsoft-mrz-control-icon img,\n .dynamsoft-mrz-control-icon svg {\n width: 32px;\n height: 32px;\n fill: #fe8e14;\n }\n\n .dynamsoft-mrz-control-text {\n flex: 0.5;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-bottom: 0.5rem;\n }\n\n \n @media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-controls {\n flex-direction: column;\n height: 100%;\n width: 5rem;\n }\n\n .dynamsoft-mrz-control-text {\n padding: 0 0.5rem 0.5rem;\n }\n }\n");const t=document.createElement("div");return t.className="dynamsoft-mrz-controls",e.forEach((e=>{const n=document.createElement("div");n.className=`dynamsoft-mrz-control-btn ${null==e?void 0:e.className}`;const i=document.createElement("div");if(i.className="dynamsoft-mrz-control-icon-wrapper",(s=e.icon).trim().startsWith(""))i.innerHTML=e.icon;else{const t=document.createElement("img");t.src=e.icon,t.alt=e.label,t.width=24,t.height=24,i.appendChild(t)}var s;const a=document.createElement("div");a.className="dynamsoft-mrz-control-text",a.textContent=e.label,e.isDisabled&&n.classList.add("disabled"),e.isHidden&&n.classList.add("hide"),n.appendChild(i),n.appendChild(a),e.onClick&&!e.isDisabled&&n.addEventListener("click",e.onClick),t.appendChild(n)})),t}([{id:"dynamsoft-mrz-scanResult-rescan",icon:(null===(e=null==l?void 0:l.rescan)||void 0===e?void 0:e.icon)||_.rescan,label:(null===(t=null==l?void 0:l.rescan)||void 0===t?void 0:t.label)||"Re-scan",onClick:()=>this.handleRescan(),className:`${(null===(n=null==l?void 0:l.rescan)||void 0===n?void 0:n.className)||""}`,isHidden:(null===(i=null==l?void 0:l.rescan)||void 0===i?void 0:i.isHidden)||!1,isDisabled:!this.scannerView},{id:"dynamsoft-mrz-scanResult-done",icon:(null===(s=null==l?void 0:l.done)||void 0===s?void 0:s.icon)||_.complete,label:(null===(a=null==l?void 0:l.done)||void 0===a?void 0:a.label)||"Done",className:`${(null===(o=null==l?void 0:l.done)||void 0===o?void 0:o.className)||""}`,isHidden:(null===(r=null==l?void 0:l.done)||void 0===r?void 0:r.isHidden)||!1,onClick:()=>this.handleDone()}])}handleFieldEdit(e,t){if(e===x.DateOfBirth||e===x.DateOfExpiry)try{const[n,i,s]=t.split(/[\/\-\.]/);s&&i&&n&&(this.editedFields[e]={day:parseInt(s,10),month:parseInt(i,10),year:parseInt(n,10)})}catch(e){console.error("Error parsing date",e)}else this.editedFields[e]=t}createMRZDataDisplay(){var e;const t=(null===(e=this.resources.result)||void 0===e?void 0:e.data)||{},n=!!this.config.allowResultEditing,i=t.invalidFields||[],s=document.createElement("div");if(s.className="dynamsoft-mrz-data-container",R(t)){const e=document.createElement("div");return e.className="dynamsoft-mrz-data-row empty",e.innerText="No MRZ detected. Please try again.",s.appendChild(e),s}if(i.length>0){const e=document.createElement("div");e.className="dynamsoft-mrz-error-notification",e.innerHTML=`\n
${_.failed}
\n
\n ${n?"Some fields require correction. Please review highlighted fields.":"Some fields contain invalid information. Please rescan the document."}\n
\n `,s.appendChild(e)}else if(0===i.length&&n){const e=document.createElement("div");e.className="dynamsoft-mrz-info-notification",e.innerHTML=`\n
${_.info}
\n
\n Please review all fields to ensure the information is correct.\n
\n `,s.appendChild(e)}return Object.entries(t).forEach((([e,t])=>{var a;if(e===x.InvalidFields||!t)return;if(e===x.MRZText&&!1===(null===(a=this.config)||void 0===a?void 0:a.showMRZText))return;const o=document.createElement("div");o.className="dynamsoft-mrz-data-row";const r=i.includes(e);r&&o.classList.add("invalid-field");const l=[x.MRZText,x.DocumentType,x.IssuingStateRaw,x.NationalityRaw],c=document.createElement("span");if(c.className="dynamsoft-mrz-data-label",c.innerText=b[e]||e,r){const e=document.createElement("span");if(e.className="dynamsoft-mrz-error-icon",e.innerHTML=_.failed,c.appendChild(e),n){const e=document.createElement("span");e.className="dynamsoft-mrz-error-hint",e.textContent="Please correct this field",c.appendChild(e)}}const d=document.createElement("div");if(d.className="dynamsoft-mrz-data-value",n&&!l.includes(e)){const n=document.createElement("input");n.className="dynamsoft-mrz-data-input",r&&n.classList.add("invalid"),e===x.DateOfBirth||e===x.DateOfExpiry?(n.value=I(t),n.setAttribute("placeholder","YYYY-MM-DD")):n.value=t,n.addEventListener("input",(t=>{if(this.handleFieldEdit(e,t.target.value),r){n.classList.remove("invalid"),o.classList.remove("invalid-field"),this.editedFields.invalidFields||(this.editedFields.invalidFields=[...i]);const t=this.editedFields.invalidFields.indexOf(e);t>-1&&this.editedFields.invalidFields.splice(t,1)}})),d.appendChild(n)}else e===x.MRZText?(d.classList.add("code"),d.innerText=t):e===x.DateOfBirth||e===x.DateOfExpiry?d.innerText=I(t):d.innerText=t,r&&d.classList.add("invalid-value");o.appendChild(c),o.appendChild(d),s.appendChild(o)})),s}async initialize(){try{if(!this.resources.result)throw Error("Captured image is missing. Please capture an image first!");if(!this.config.container)throw new Error("Please create a Scan Result View Container element");E("dynamsoft-mrz-result-view-style",A);const e=document.createElement("div");if(e.className="dynamsoft-mrz-result-view-container",!1!==this.config.showOriginalImage){const t=this.resources.result.originalImageResult,n=document.createElement("div");let i;n.className="dynamsoft-mrz-result-view-image-container",(null==t?void 0:t.toCanvas)&&(i=null==t?void 0:t.toCanvas()),Object.assign(i.style,{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}),n.appendChild(i),e.appendChild(n)}const t=this.createMRZDataDisplay();e.appendChild(t);const n=this.createControls();e.appendChild(n),S(this.config.container).appendChild(e)}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t)}}hideView(){S(this.config.container).style.display="none"}dispose(e=!1){S(this.config.container).textContent="",e||(this.currentScanResultViewResolver=void 0)}}const A="\n .dynamsoft-mrz-result-view-container {\n display: flex;\n width: 100%;\n height: 100%;\n background-color:#575757;\n font-size: 12px;\n flex-direction: column;\n align-items: center;\n }\n\n .dynamsoft-mrz-result-view-image-container {\n width: 100%;\n height: 200px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #323234;\n }\n\n \n.dynamsoft-mrz-data-container {\n font-size: 16px;\n font-family: Verdana;\n color: white;\n overflow: auto;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 1rem 0;\n}\n\n.dynamsoft-mrz-data-row {\n padding: 0.5rem 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n transition: background-color 0.3s ease;\n}\n\n.dynamsoft-mrz-data-row.invalid-field {\n background-color: rgba(231, 76, 60, 0.1);\n border-left: 3px solid #e74c3c;\n padding-left: calc(2rem - 3px);\n}\n\n.dynamsoft-mrz-data-label {\n color: #aaa;\n display: flex;\n gap: 0.5rem;\n align-items: end;\n flex-wrap: wrap;\n}\n\n.dynamsoft-mrz-error-notification,\n.dynamsoft-mrz-info-notification {\n color: white;\n padding: 1rem;\n margin: 0.5rem 2rem;\n border-radius: 4px;\n display: flex;\n align-items: center;\n gap: 1rem;\n text-align: start;\n}\n\n.dynamsoft-mrz-error-notification {\n background-color: rgba(231, 76, 60, 0.2);\n}\n\n.dynamsoft-mrz-info-notification {\n background-color: rgba(196, 231, 60, 0.2);\n}\n\n.dynamsoft-mrz-edit-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #aaa;\n}\n\n.dynamsoft-mrz-error-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-info-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.dynamsoft-mrz-info-message,\n.dynamsoft-mrz-error-message {\n flex: 1;\n}\n\n.dynamsoft-mrz-error-hint {\n font-size: 0.8rem;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-value {\n word-wrap: break-word;\n text-align: start;\n}\n\n.dynamsoft-mrz-data-value.code {\n font-family: monospace;\n}\n\n.dynamsoft-mrz-data-value.invalid-value {\n color: #e74c3c;\n text-decoration: wavy underline #e74c3c;\n text-decoration-skip-ink: none;\n}\n\n.dynamsoft-mrz-data-input {\n width: 100%;\n padding: 5px;\n background-color: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.3);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n transition: all 0.3s ease;\n}\n\n.dynamsoft-mrz-data-input.invalid {\n background-color: rgba(231, 76, 60, 0.1);\n border-color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-input:focus {\n background-color: rgba(255, 255, 255, 0.2);\n border-color: #fe8e14;\n outline: none;\n}\n\n@media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-result-view-container {\n flex-direction: row;\n }\n\n .dynamsoft-mrz-result-view-image-container{\n flex: 1;\n height: 100%;\n }\n\n .dynamsoft-mrz-data-container{\n flex: 1;\n }\n\n .dynamsoft-mrz-data-row:first-of-type {\n padding-top: 2rem;\n }\n\n .dynamsoft-mrz-data-row:last-of-type {\n padding-bottom: 2rem;\n }\n\n .dynamsoft-mrz-data-row.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding-top: 0;\n padding-bottom: 0;\n }\n}\n",O={rootDirectory:"https://cdn.jsdelivr.net/npm/"};class P{showLoadingOverlay(e){var t,n;const i=S(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||S(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container);this.loadingScreen=T(i,{message:e}),i.style.display="block",i.style.position="relative"}hideLoadingOverlay(e=!1){var t,n,i;const s=S(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||S(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container);this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,s.style.display="none",e&&(null===(i=this.config)||void 0===i?void 0:i.container)&&(S(this.config.container).style.display="none"))}constructor(e){this.config=e,this.resources={},this.isInitialized=!1,this.isCapturing=!1,this.loadingScreen=null}async initialize(){if(this.isInitialized)return{resources:this.resources,components:{scannerView:this.scannerView,resultView:this.resultView}};try{if(!this.initializeMRZScannerConfig())return console.error("Failed to initialize mrz scanner config"),{resources:this.resources,components:{}};E("dynamsoft-mrz-loading-screen-style",M),this.showLoadingOverlay("Loading...");if(!await this.initializeDCVResources())return this.hideLoadingOverlay(!0),console.error("Failed to initialize DCV resources"),{resources:this.resources,components:{}};this.resources.onResultUpdated=e=>{this.resources.result=e};const e={};return this.config.scannerViewConfig&&(this.scannerView=new F(this.resources,this.config.scannerViewConfig),e.scannerView=this.scannerView,await this.scannerView.initialize()),this.config.resultViewConfig&&(this.resultView=new k(this.resources,this.config.resultViewConfig,this.scannerView),e.resultView=this.resultView),this.isInitialized=!0,{resources:this.resources,components:e}}catch(e){this.isInitialized=!1;const t=`Initialization Failed: ${(null==e?void 0:e.message)||e}`;return console.error(t),{resources:this.resources,components:{}}}finally{this.hideLoadingOverlay(!0)}}async initializeDCVResources(){var e,t,n;try{return s.engineResourcePaths=R(null===(e=this.config)||void 0===e?void 0:e.engineResourcePaths)?O:this.config.engineResourcePaths,a._onAuthMessage=e=>e.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=mrz&deploymenttype=web)"),await a.initLicense((null===(t=this.config)||void 0===t?void 0:t.license)||"",{executeNow:!0}),s.loadWasm(["DLR","DCP"]),m.loadSpec("MRTD_TD3_PASSPORT"),m.loadSpec("MRTD_TD1_ID"),m.loadSpec("MRTD_TD2_ID"),h.loadRecognitionData("MRZ"),this.resources.cameraView=await c.createInstance(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.cameraEnhancerUIPath),this.resources.cameraEnhancer=await d.createInstance(this.resources.cameraView),this.resources.cvRouter=await r.createInstance(),!0}catch(e){let t=(null==e?void 0:e.message)||e;if(null==t?void 0:t.toLowerCase().includes("license")){const e="The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.";alert(e),console.error(e)}else{const e=`Resource Initialization Failed: ${t}`;alert(e),console.error(e)}return!1}}shouldCreateDefaultContainer(){var e,t;const n=!this.config.container,i=!((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container));return n&&i}createDefaultMRZScannerContainer(){const e=document.createElement("div");return e.className="mrz-scanner-main-container",Object.assign(e.style,{height:"100dvh",width:"100%",position:"absolute",left:"0",top:"0",zIndex:"999"}),document.body.append(e),e}checkForTemporaryLicense(e){return!(null==e?void 0:e.length)||(null==e?void 0:e.startsWith("A"))||(null==e?void 0:e.startsWith("L"))||(null==e?void 0:e.startsWith("P"))||(null==e?void 0:e.startsWith("Y"))?"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9":e}validateViewConfigs(){var e,t,n,i,s,a,o,r;if(!this.config.container){if((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)&&this.config.showResultView&&!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container)){const e="MRZResultView container is required when showResultView is true";return alert(e),console.error(e),!1}if(!(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)&&(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container)&&!this.resources.result){const e="Result is needed to create MRZResultView without a scanner view";return alert(e),console.error(e),!1}}try{if(this.config.container&&!S(this.config.container)){const e="Invalid main container reference";return alert(e),console.error(e),!1}if((null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.container)&&!S(null===(a=this.config.scannerViewConfig)||void 0===a?void 0:a.container)){const e="Invalid scanner view container reference";return alert(e),console.error(e),!1}if((null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)&&!S(null===(r=this.config.resultViewConfig)||void 0===r?void 0:r.container)){const e="Invalid result view container reference";return alert(e),console.error(e),!1}}catch(e){const t=`Error accessing container references: ${e.message}`;return alert(t),console.error(t),!1}return!0}showResultView(){var e,t;return!1!==this.config.showResultView&&(this.config.container?!(void 0!==this.config.showResultView||!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container)&&!this.config.container)||!!this.config.showResultView:this.config.showResultView&&!!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container))}initializeMRZScannerConfig(){var e,t,n,i,s,a,o;this.config=null!==(e=this.config)&&void 0!==e?e:{};if(!this.validateViewConfigs())return!1;this.shouldCreateDefaultContainer()?this.config.container=this.createDefaultMRZScannerContainer():this.config.container&&(this.config.container=S(this.config.container));const r=this.config.container?this.createViewContainers(S(this.config.container)):{},l={license:this.checkForTemporaryLicense(this.config.license),utilizedTemplateNames:Object.fromEntries(Object.values(p).map((e=>{var t;return[e,(null===(t=this.config.utilizedTemplateNames)||void 0===t?void 0:t[e])||w[e]]}))),templateFilePath:(null===(t=this.config)||void 0===t?void 0:t.templateFilePath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.template.json"},c=Object.assign(Object.assign({},this.config.scannerViewConfig),{container:r[y.Scanner]||S(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)||null,cameraEnhancerUIPath:(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.cameraEnhancerUIPath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.ui.html",templateFilePath:l.templateFilePath,utilizedTemplateNames:l.utilizedTemplateNames,enableMultiFrameCrossFilter:null===(a=null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.enableMultiFrameCrossFilter)||void 0===a||a,mrzFormatType:this.config.mrzFormatType}),d=this.showResultView()?Object.assign(Object.assign({},this.config.resultViewConfig),{container:r[y.Result]||S(null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)||null}):void 0;return Object.assign(this.config,Object.assign(Object.assign({},l),{scannerViewConfig:c,resultViewConfig:d})),!0}createViewContainers(e){e.textContent="";const t=[y.Scanner];return this.showResultView()&&t.push(y.Result),t.reduce(((t,n)=>{const i=document.createElement("div");return i.className=`mrz-scanner-${n}-view-container`,Object.assign(i.style,{height:"100%",width:"100%",display:"none",position:"relative"}),e.append(i),t[n]=i,t}),{})}dispose(){var e,t;this.resultView&&(this.resultView.dispose(),this.resultView=null),this.scannerView=null,this.resources.cameraEnhancer&&(this.resources.cameraEnhancer.dispose(),this.resources.cameraEnhancer=null),this.resources.cameraView&&(this.resources.cameraView.dispose(),this.resources.cameraView=null),this.resources.cvRouter&&(this.resources.cvRouter.dispose(),this.resources.cvRouter=null),this.resources.result=null,this.resources.onResultUpdated=null;const n=e=>{const t=S(e);t&&(t.style.display="none",t.textContent="")};n(this.config.container),n(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container),n(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container),this.isInitialized=!1}async processUploadedFile(i){var s,a,o,r;try{this.showLoadingOverlay("Processing File...");const{cvRouter:l}=this.resources,c=null===(s=this.config.utilizedTemplateNames)||void 0===s?void 0:s.all,d=await l.getSimplifiedSettings(c);d.roiMeasuredInPercentage=!0,d.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await l.updateSettings(c,d);const h=await l.capture(i,c),u=h.items,m=u.filter((t=>t.type===e.CRIT_ORIGINAL_IMAGE))[0].imageData;m.toCanvas=()=>t(m),m.toBlob=async()=>await n("image/png",m);const g=null==h?void 0:h.textLineResultItems,p=null==h?void 0:h.parsedResultItems;let f={};if(null==g?void 0:g.length){const e=(null===(a=g[0])||void 0===a?void 0:a.text)||"";f=N(e,p[0])}const y={status:{code:v.RS_SUCCESS,message:"Success"},originalImageResult:m,data:f,imageData:!0,_imageData:m};null===(r=(o=this.resources).onResultUpdated)||void 0===r||r.call(o,y)}catch(e){return console.error("Failed to process uploaded file:",e),{status:{code:v.RS_FAILED,message:`Failed to process image: ${e.message||e}`}}}finally{this.hideLoadingOverlay(!1)}}async launch(e){if(this.isCapturing)throw new Error("Capture session already in progress");try{this.isCapturing=!0;const{components:t}=await this.initialize();if(R(t))throw new Error("MRZ Scanner initialization failed.");if(this.config.container&&(S(this.config.container).style.display="block"),e&&(t.scannerView=null,await this.processUploadedFile(e)),!t.scannerView&&this.resources.result&&t.resultView)return await t.resultView.launch();if(!t.scannerView&&!this.resources.result)throw new Error("Scanner view is required when no previous result exists");if(t.scannerView){const e=await t.scannerView.launch();if((null==e?void 0:e.status.code)!==v.RS_SUCCESS)return{status:{code:null==e?void 0:e.status.code,message:(null==e?void 0:e.status.message)||"Failed to capture image"}};if(t.resultView)return await t.resultView.launch()}return this.resources.result}catch(e){return alert((null==e?void 0:e.message)||e),console.error((null==e?void 0:e.message)||e),{status:{code:v.RS_FAILED,message:(null==e?void 0:e.message)||e}}}finally{this.isCapturing=!1,this.dispose()}}}const B={MRZScanner:P,MRZScannerView:F,MRZResultView:k};export{w as DEFAULT_TEMPLATE_NAMES,B as DynamsoftMRZScanner,x as EnumMRZData,f as EnumMRZDocumentType,p as EnumMRZScanMode,y as EnumMRZScannerViews,v as EnumResultStatus,b as MRZDataLabel,k as MRZResultView,P as MRZScanner,F as MRZScannerView,I as displayMRZDate}; +import{EnumValidationStatus as e,MultiFrameResultCrossFilter as t,EnumCapturedResultItemType as n,CapturedResultReceiver as i,_toCanvas as s,_toBlob as a,Feedback as o,EnumImagePixelFormat as r,CoreModule as l,CodeParserModule as c,LicenseManager as d,CameraView as h,CameraEnhancer as u,CaptureVisionRouter as m}from"dynamsoft-capture-vision-bundle";export*from"dynamsoft-capture-vision-bundle";var g,p,f;!function(e){e.Passport="passport",e.TD1="td1",e.TD2="td2",e.PassportAndTD1="passportAndTd1",e.PassportAndTD2="passportAndTd2",e.TD1AndTD2="td1AndTd2",e.All="all"}(g||(g={})),function(e){e.Passport="passport",e.TD1="td1",e.TD2="td2"}(p||(p={})),function(e){e.Scanner="scanner",e.Result="scan-result"}(f||(f={}));const w={[g.Passport]:"ReadPassport",[g.TD1]:"ReadId-TD1",[g.TD2]:"ReadId-TD2",[g.PassportAndTD1]:"ReadPassportAndId-TD1",[g.PassportAndTD2]:"ReadPassportAndId-TD2",[g.TD1AndTD2]:"ReadId",[g.All]:"ReadPassportAndId"};var y;function v(e){if("string"==typeof e){const t=document.querySelector(e);if(!t)throw new Error("Element not found");return t}return e instanceof HTMLElement?e:null}!function(e){e[e.RS_SUCCESS=0]="RS_SUCCESS",e[e.RS_CANCELLED=1]="RS_CANCELLED",e[e.RS_FAILED=2]="RS_FAILED"}(y||(y={}));function S(e,t){if(!document.getElementById(e)){const n=document.createElement("style");n.id=e,n.textContent=t,document.head.appendChild(n)}}const R=e=>!e||0===Object.keys(e).length;function E(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}const D={"4k":{width:3840,height:2160},"2k":{width:2560,height:1440},"1080p":{width:1920,height:1080},"720p":{width:1280,height:720},"480p":{width:640,height:480}};function C(e,t={}){const{message:n,spinnerSize:i=32}=t,s=document.createElement("div");s.className="dynamsoft-mrz-loading-screen";const a=document.createElement("div");a.className="dynamsoft-mrz-loading";const o=document.createElement("div");o.className="dynamsoft-mrz-loading-content";const r=`\n \n \n \n `;if(o.innerHTML=r,n){const e=document.createElement("div");e.className="dynamsoft-mrz-loading-message",e.textContent=n,o.appendChild(e)}return a.appendChild(o),s.appendChild(a),e.appendChild(s),{element:s,updateMessage:e=>{let t=a.querySelector(".dynamsoft-mrz-loading-message");null!==e?t?t.textContent=e:(t=document.createElement("div"),t.className="dynamsoft-mrz-loading-message",t.textContent=e,o.appendChild(t)):null==t||t.remove()},hide:()=>{s&&s.parentNode&&(s.classList.add("fade-out"),setTimeout((()=>{var e;null===(e=s.parentNode)||void 0===e||e.removeChild(s)}),200))}}}const M='\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: "Verdana";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n';var T;!function(e){e.InvalidFields="invalidFields",e.DocumentType="documentType",e.DocumentNumber="documentNumber",e.MRZText="mrzText",e.FirstName="firstName",e.LastName="lastName",e.Age="age",e.Sex="sex",e.IssuingState="issuingState",e.IssuingStateRaw="issuingStateRaw",e.Nationality="nationality",e.NationalityRaw="nationalityRaw",e.DateOfBirth="dateOfBirth",e.DateOfExpiry="dateOfExpiry"}(T||(T={}));const b={[T.InvalidFields]:"Invalid Fields",[T.DocumentType]:"Document Type",[T.DocumentNumber]:"Document Number",[T.MRZText]:"MRZ Text",[T.FirstName]:"Given Name(s)",[T.LastName]:"Surname",[T.Age]:"Age",[T.Sex]:"Sex",[T.IssuingState]:"Issuing State",[T.IssuingStateRaw]:"Issuing State (Raw Value)",[T.Nationality]:"Nationality",[T.NationalityRaw]:"Nationality State (Raw Value)",[T.DateOfBirth]:"Date Of Birth (YYYY-MM-DD)",[T.DateOfExpiry]:"Date Of Expiry (YYYY-MM-DD)"};function x(e,t,n,i=!1){const s=parseInt(e,10);let a;if(i)a=s>=60?1900+s:2e3+s;else{a=s>(new Date).getFullYear()%100?1900+s:2e3+s}return{year:a,month:parseInt(t,10),day:parseInt(n,10)}}function z(e){const t=e=>{var t;return 1===(null===(t=`${e}`)||void 0===t?void 0:t.length)?`0${e}`:e};return`${null==e?void 0:e.year}-${t(null==e?void 0:e.month)}${(null==e?void 0:e.day)&&`-${t(null==e?void 0:e.day)}`}`}function I(e){return"D<<"===e?"D":e}function V(t,n){const i=[],s=t=>n.getFieldValidationStatus(t)===e.VS_FAILED,a=n.codeType,o=function(e){switch(e){case"MRTD_TD1_ID":return p.TD1;case"MRTD_TD2_ID":case"MRTD_TD2_VISA":case"MRTD_TD2_FRENCH_ID":return p.TD2;case"MRTD_TD3_PASSPORT":case"MRTD_TD3_VISA":return p.Passport;default:throw new Error(`Unknown document type: ${e}`)}}(a),r=function(e){switch(e){case"MRTD_TD1_ID":return"ID (TD1)";case"MRTD_TD2_ID":return"ID (TD2)";case"MRTD_TD2_VISA":return"ID (VISA)";case"MRTD_TD2_FRENCH_ID":return"French ID (TD2)";case"MRTD_TD3_PASSPORT":return"Passport (TD3)";case"MRTD_TD3_VISA":return"Visa (TD3)";default:throw new Error(`Unknown document type: ${e}`)}}(a),l=o===p.Passport&&"MRTD_TD3_PASSPORT"===a?"passportNumber":"documentNumber",c=x(n.getFieldValue("birthYear"),n.getFieldValue("birthMonth"),n.getFieldValue("birthDay")),d=x(n.getFieldValue("expiryYear"),n.getFieldValue("expiryMonth"),n.getFieldValue("expiryDay"),!0);["birthYear","birthMonth","birthDay"].forEach((e=>{s(e)&&i.push(T.DateOfBirth)})),["expiryYear","expiryMonth","expiryDay"].forEach((e=>{s(e)&&i.push(T.DateOfExpiry)}));const h={[T.LastName]:n.getFieldValue("primaryIdentifier"),[T.FirstName]:n.getFieldValue("secondaryIdentifier"),[T.Nationality]:n.getFieldValue("nationality"),[T.NationalityRaw]:I(n.getFieldRawValue("nationality")),[T.DocumentNumber]:n.getFieldValue(l)||n.getFieldValue("longDocumentNumber"),[T.IssuingState]:n.getFieldValue("issuingState"),[T.IssuingStateRaw]:I(n.getFieldRawValue("issuingState")),[T.Sex]:E(n.getFieldValue("sex"))};Object.keys(h).forEach((e=>{let t=!1;switch(e){case T.FirstName:t=s("secondaryIdentifier");break;case T.LastName:t=s("primaryIdentifier");break;case T.DocumentNumber:t=s(l)||s("longDocumentNumber");break;default:t=s(e)}t&&i.push(e)}));const u=function(e){const t=new Date,n=t.getMonth()+1>e.month||t.getMonth()+1===e.month&&t.getDate()>=e.day;return t.getFullYear()-e.year-(n?0:1)}(c);u<1&&i.push(T.Age);return{[T.InvalidFields]:i,[T.FirstName]:h[T.FirstName],[T.LastName]:h[T.LastName],[T.Age]:u,[T.DateOfBirth]:c,[T.Sex]:h[T.Sex],[T.Nationality]:h[T.Nationality],[T.NationalityRaw]:h[T.NationalityRaw],[T.DocumentNumber]:h[T.DocumentNumber],[T.DateOfExpiry]:d,[T.IssuingState]:h[T.IssuingState],[T.IssuingStateRaw]:h[T.IssuingStateRaw],[T.DocumentType]:E(r),[T.MRZText]:t}}const F={[p.TD1]:{width:85.6,height:53.98},[p.TD2]:{width:105,height:74},[p.Passport]:{width:125,height:88}};class N{showScannerLoadingOverlay(e){const t=v(this.config.container);this.loadingScreen=C(t,{message:e}),t.style.display="block",t.style.position="relative"}hideScannerLoadingOverlay(e=!1){this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,e&&(v(this.config.container).style.display="none"))}constructor(e,t){this.resources=e,this.config=t,this.isSoundFeedbackOn=!1,this.scanModeManager={[p.Passport]:!0,[p.TD1]:!0,[p.TD2]:!0},this.currentScanMode=g.All,this.resizeTimer=null,this.capturedResultItems=[],this.originalImageData=null,this.initialized=!1,this.initializedDCE=!1,this.DCE_ELEMENTS={selectCameraBtn:null,uploadImageBtn:null,soundFeedbackBtn:null,closeScannerBtn:null,scanModeSelectContainer:null,passportModeOption:null,td1ModeOption:null,td2ModeOption:null,toast:null},this.loadingScreen=null,this.handleResize=()=>{this.toggleScanGuide(!1),this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((()=>{this.toggleScanGuide(!0)}),500)},this.firstFrame=!0}async initialize(){if(!this.initialized){this.initializeScanModeManager(),this.currentScanMode=this.getScanMode(),S("dynamsoft-mrz-loading-screen-style",M);try{const{cameraView:e,cameraEnhancer:s,cvRouter:a}=this.resources;if(e.setScanRegionMaskStyle({strokeStyle:"transparent",fillStyle:"transparent",lineWidth:0}),e.setVideoFit("cover"),a.setInput(s),!0===this.config.enableMultiFrameCrossFilter){const e=new t;e.enableResultCrossVerification(n.CRIT_TEXT_LINE,!0),await a.addResultFilter(e)}const o=new i;o.onCapturedResultReceived=e=>this.handleMRZResult(e),await a.addResultReceiver(o),this.toggleSoundFeedback(!1),!1===this.config.showScanGuide&&this.toggleScanGuide(!1),this.initialized=!0}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:y.RS_FAILED,message:"Dynamsoft MRZ Scanner initialize error"}};this.currentScanResolver(n)}}}initializeElements(){var e;const t=v(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))throw new Error("Shadow root not found");if(this.DCE_ELEMENTS={selectCameraBtn:n.shadowRoot.querySelector(".dce-mn-select-camera-icon"),uploadImageBtn:n.shadowRoot.querySelector(".dce-mn-upload-image-icon"),soundFeedbackBtn:n.shadowRoot.querySelector(".dce-mn-sound-feedback"),closeScannerBtn:n.shadowRoot.querySelector(".dce-mn-close"),scanModeSelectContainer:n.shadowRoot.querySelector(".dce-mn-scan-mode-select"),passportModeOption:n.shadowRoot.querySelector(".scan-mode-option-passport"),td1ModeOption:n.shadowRoot.querySelector(".scan-mode-option-td1"),td2ModeOption:n.shadowRoot.querySelector(".scan-mode-option-td2"),toast:n.shadowRoot.querySelector(".dce-mn-toast")},this.setupScanModeSelector(),this.assignDCEClickEvents(),this.DCE_ELEMENTS.toast.style.display="none",!1===this.config.showUploadImage&&(this.DCE_ELEMENTS.uploadImageBtn.style.visibility="hidden"),!1===this.config.showSoundToggle&&(this.DCE_ELEMENTS.soundFeedbackBtn.style.visibility="hidden"),!1===(null===(e=this.config)||void 0===e?void 0:e.showPoweredByDynamsoft)){n.shadowRoot.querySelector(".dce-mn-msg-poweredby").style.display="none"}this.initializedDCE=!0}setupScanModeSelector(){if(!1!==this.config.showFormatSelector)switch(this.currentScanMode){case g.PassportAndTD1:this.DCE_ELEMENTS.td2ModeOption.style.display="none";break;case g.PassportAndTD2:this.DCE_ELEMENTS.td1ModeOption.style.display="none";break;case g.TD1AndTD2:this.DCE_ELEMENTS.passportModeOption.style.display="none";break;case g.All:break;default:this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}else this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}assignDCEClickEvents(){if(!Object.values(this.DCE_ELEMENTS).every(Boolean))throw new Error("Camera control elements not found");this.closeCamera=this.closeCamera.bind(this),this.DCE_ELEMENTS.uploadImageBtn.onclick=()=>this.uploadFile(),this.DCE_ELEMENTS.soundFeedbackBtn.onclick=()=>this.toggleSoundFeedback(),this.DCE_ELEMENTS.closeScannerBtn.onclick=()=>this.handleCloseBtn(),this.DCE_ELEMENTS.selectCameraBtn.onclick=e=>{e.stopPropagation(),this.toggleSelectCameraBox()},this.DCE_ELEMENTS.passportModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.passportModeOption.style.display&&await this.toggleScanDocType(p.Passport)},this.DCE_ELEMENTS.td1ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td1ModeOption.style.display&&await this.toggleScanDocType(p.TD1)},this.DCE_ELEMENTS.td2ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td2ModeOption.style.display&&await this.toggleScanDocType(p.TD2)}}handleCloseBtn(){this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:y.RS_CANCELLED,message:"Cancelled"}})}attachOptionClickListeners(){const e=v(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings");[...t.shadowRoot.querySelectorAll(".dce-mn-camera-option"),...t.shadowRoot.querySelectorAll(".dce-mn-resolution-option")].forEach((e=>{e.addEventListener("click",(async t=>{const i=e.getAttribute("data-davice-id"),s=e.getAttribute("data-height"),a=e.getAttribute("data-width");i?this.resources.cameraEnhancer.selectCamera(i).then((()=>{this.toggleScanGuide()})):s&&a&&this.resources.cameraEnhancer.setResolution({width:parseInt(a),height:parseInt(s)}).then((()=>{this.toggleScanGuide()})),"none"!==n.style.display&&this.toggleSelectCameraBox()}))}))}highlightCameraAndResolutionOption(){const e=v(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings"),i=n.querySelectorAll(".dce-mn-camera-option"),s=n.querySelectorAll(".dce-mn-resolution-option"),a=this.resources.cameraEnhancer.getSelectedCamera(),o=this.resources.cameraEnhancer.getResolution();i.forEach((e=>{const t=e;t.getAttribute("data-davice-id")===(null==a?void 0:a.deviceId)?t.style.border="2px solid #fe814a":t.style.border="none"}));const r={"480p":"480","720p":"720","1080p":"1080","2k":"1440","4k":"2160"},l=function(e){const t=e.width*e.height,n=e.width/e.height;let i="480p",s=Number.MAX_VALUE;for(const[e,a]of Object.entries(D)){const o=a.width*a.height,r=a.width/a.height,l=.7*Math.abs(o-t)+Math.abs(r-n)*o*.3;l{const t=e,n=t.getAttribute("data-height");t.style.border=n===r[l]?"2px solid #fe814a":"none"}))}toggleSelectCameraBox(){const e=v(this.config.container),t=e.children[e.children.length-1];if(!(null==t?void 0:t.shadowRoot))return;const n=t.shadowRoot.querySelector(".dce-mn-resolution-box");this.highlightCameraAndResolutionOption(),this.attachOptionClickListeners(),n.click()}async relaunch(){}async uploadFile(){var e,t,i,o,r,l;const{cvRouter:c}=this.resources,d=document.createElement("input");d.type="file",d.accept=null!==(e=this.config.uploadAcceptedTypes)&&void 0!==e?e:"image/*",d.style.display="none",document.body.appendChild(d);try{this.showScannerLoadingOverlay("Processing file..."),await this.closeCamera(!1);const e=await new Promise(((e,t)=>{d.onchange=n=>{var i;const s=null===(i=n.target.files)||void 0===i?void 0:i[0];s?e(s):t(new Error("No file selected"))},d.addEventListener("cancel",(async()=>{this.hideScannerLoadingOverlay(!1),this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()})),d.click()}));if(!e)return;let h;if(this.config.uploadFileConverter&&!e.type.startsWith("image/"))try{h=await this.config.uploadFileConverter(e)}catch(e){throw new Error(`Error converting file: ${e.message}`)}else{if(!e.type.startsWith("image/"))throw new Error("Unsupported file type. Please provide a converter function for this file type.");h=e}const u=this.config.utilizedTemplateNames[this.currentScanMode];if(!1!==this.config.showScanGuide){const e=await c.getSimplifiedSettings(u);e.roiMeasuredInPercentage=!0,e.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await c.updateSettings(u,e)}const m=await c.capture(h,u);this.capturedResultItems=m.items;const g=this.capturedResultItems.filter((e=>e.type===n.CRIT_ORIGINAL_IMAGE));if(0===g.length)throw new Error("No image data found in the captured result");const p=g[0].imageData;p.toCanvas=()=>s(p),p.toBlob=async()=>await a("image/png",p),this.originalImageData=p;const f=null===(t=null==m?void 0:m.parsedResult)||void 0===t?void 0:t.parsedResultItems;let w={};if(null==f?void 0:f.length){const e=(null===(o=null===(i=f[0])||void 0===i?void 0:i.referencedItem)||void 0===o?void 0:o.text)||"";w=V(e,f[0])}const v={status:{code:y.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:w,imageData:!0,_imageData:this.originalImageData};null===(l=(r=this.resources).onResultUpdated)||void 0===l||l.call(r,v),this.currentScanResolver(v)}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:y.RS_FAILED,message:`Error processing file: ${t}`}};this.currentScanResolver(n)}finally{this.hideScannerLoadingOverlay(!0),document.body.removeChild(d)}}toggleSoundFeedback(e){this.isSoundFeedbackOn=void 0!==e?e:!this.isSoundFeedbackOn;const t=v(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const i=n.shadowRoot.querySelector(".dce-mn-sound-feedback"),s=i.querySelector(".dce-mn-sound-feedback-on");i.querySelector(".dce-mn-sound-feedback-off").style.display=this.isSoundFeedbackOn?"none":"block",s.style.display=this.isSoundFeedbackOn?"block":"none"}calculateScanRegion(e){const{cameraEnhancer:t,cameraView:n}=this.resources;if(!t||!t.isOpen())return;const i=F[e].width/F[e].height;let s;const a=n.getVisibleRegionOfVideo({inPixels:!0}),{width:o,height:r}=a;if(a){if(a.width>a.height){const e=.5*r*i,t=Math.round(e/o*100),n=(100-t)/2;s={left:n,right:n+t,top:25,bottom:75,isMeasuredInPercentage:!0}}else{const e=.9*o/i,t=Math.round(e/r*100),n=(100-t)/2;s={left:5,right:95,top:n,bottom:n+t,isMeasuredInPercentage:!0}}null==n||n.setScanRegionMaskVisible(!0),t.setScanRegion(s)}}toggleScanGuide(e){const t=v(this.config.container),n=t.children[t.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const i=n.shadowRoot.querySelector(".dce-scanguide-passport"),s=n.shadowRoot.querySelector(".dce-scanguide-td1"),a=n.shadowRoot.querySelector(".dce-scanguide-td2");if(!1===e||!1===this.config.showScanGuide)return i.style.display="none",s.style.display="none",void(a.style.display="none");switch(this.currentScanMode){case g.All:case g.Passport:case g.PassportAndTD1:case g.PassportAndTD2:i.style.display="block",s.style.display="none",a.style.display="none",this.calculateScanRegion(p.Passport);break;case g.TD1:case g.TD1AndTD2:i.style.display="none",s.style.display="block",a.style.display="none",this.calculateScanRegion(p.TD1);break;case g.TD2:i.style.display="none",s.style.display="none",a.style.display="block",this.calculateScanRegion(p.TD2)}}async openCamera(){try{const{cameraEnhancer:e,cameraView:t}=this.resources,n=v(this.config.container);if(n.style.display="block",e.isOpen())e.isPaused()&&await e.resume();else{const i=t.getUIElement();i.parentElement||n.append(i),await e.open()}await e.setResolution({width:2560,height:1440}),!this.initializedDCE&&e.isOpen()&&await this.initializeElements(),window.addEventListener("resize",this.handleResize);const i=n.children[n.children.length-1];if(!(null==i?void 0:i.shadowRoot))throw new Error("Shadow root not found");i.shadowRoot.querySelector(".dce-mn-torch-off").style.display="none",i.shadowRoot.querySelector(".dce-mn-torch-on").style.display="none"}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:y.RS_FAILED,message:"MRZ Scanner Open Camera Error"}};this.currentScanResolver(n)}}async closeCamera(e=!0){try{window.removeEventListener("resize",this.handleResize),this.resizeTimer&&(window.clearTimeout(this.resizeTimer),this.resizeTimer=null);const{cameraEnhancer:t,cameraView:n}=this.resources,i=v(this.config.container);i.style.display=e?"none":"block",(null==n?void 0:n.getUIElement().parentElement)&&i.removeChild(n.getUIElement()),t.close(),this.stopCapturing()}catch(e){let t=(null==e?void 0:e.message)||e;console.error(`Close Camera error: ${t}`)}}pauseCamera(){const{cameraEnhancer:e}=this.resources;e.pause()}stopCapturing(){const{cameraView:e,cvRouter:t}=this.resources;t.stopCapturing(),e.clearAllInnerDrawingItems()}async handleMRZResult(e){var t,i,r;if(this.firstFrame)this.firstFrame=!1;else if(!(e.items.length<=1)){this.capturedResultItems=e.items;try{const{onResultUpdated:l}=this.resources,c=e.items.filter((e=>e.type===n.CRIT_ORIGINAL_IMAGE))[0].imageData;c.toCanvas=()=>s(c),c.toBlob=async()=>await a("image/png",c),this.originalImageData=c;const d=null===(t=null==e?void 0:e.parsedResult)||void 0===t?void 0:t.parsedResultItems;if(null==d?void 0:d.length){this.isSoundFeedbackOn&&o.beep();const e=(null===(r=null===(i=d[0])||void 0===i?void 0:i.referencedItem)||void 0===r?void 0:r.text)||"",t=V(e,d[0]);this.closeCamera();const n={status:{code:y.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:t,imageData:!0,_imageData:this.originalImageData};null==l||l(n),this.currentScanResolver(n)}}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t),this.closeCamera();const n={status:{code:y.RS_FAILED,message:"Error capturing image"}};this.currentScanResolver(n)}}}initializeScanModeManager(){const{mrzFormatType:e}=this.config;if(this.scanModeManager={[p.Passport]:!0,[p.TD1]:!0,[p.TD2]:!0},!e||Array.isArray(e)&&0===e.length)return;Object.keys(this.scanModeManager).forEach((e=>{this.scanModeManager[e]=!1}));(Array.isArray(e)?e:[e]).forEach((e=>{this.scanModeManager[e]=!0}))}getScanMode(){const e=Object.entries(this.scanModeManager).filter((([e,t])=>t)).map((([e])=>e)).sort().join(",");return{[p.Passport]:g.Passport,[p.TD1]:g.TD1,[p.TD2]:g.TD2,[`${p.Passport},${p.TD1}`]:g.PassportAndTD1,[`${p.Passport},${p.TD2}`]:g.PassportAndTD2,[`${p.TD1},${p.TD2}`]:g.TD1AndTD2,[`${p.Passport},${p.TD1},${p.TD2}`]:g.All,"":g.All}[e]}DCEShowToast(e,t=3e3){this.DCE_ELEMENTS.toast&&(this.DCE_ELEMENTS.toast.textContent=e,this.DCE_ELEMENTS.toast.style.display="",setTimeout((()=>{this.DCE_ELEMENTS.toast.style.display="none"}),t))}async startCapturing(){const{cvRouter:e,cameraEnhancer:t}=this.resources,n=this.config.utilizedTemplateNames[this.currentScanMode];try{if(!1!==this.config.showScanGuide){const t=await e.getSimplifiedSettings(n);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:50},{x:100,y:50},{x:100,y:100},{x:0,y:100}],await e.updateSettings(n,t)}this.firstFrame=!0,await e.startCapturing(n),t.setPixelFormat(r.IPF_ABGR_8888)}catch(e){let t=(null==e?void 0:e.message)||e;console.error("Failed to start capturing:",t),this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:y.RS_FAILED,message:"Failed to start capturing"}})}}async toggleScanDocType(e){try{if(this.scanModeManager[e]&&0===Object.entries(this.scanModeManager).filter((([t,n])=>n&&t!==e)).length)return console.warn("MRZ Scanner - At least one mode must be enabled"),void this.DCEShowToast("At least one mode must be enabled");this.scanModeManager[e]=!this.scanModeManager[e],this.currentScanMode=this.getScanMode(),this.stopCapturing(),this.toggleScanGuide(),await this.startCapturing(),this.DCE_ELEMENTS.td1ModeOption.classList.toggle("selected",this.scanModeManager[p.TD1]),this.DCE_ELEMENTS.td2ModeOption.classList.toggle("selected",this.scanModeManager[p.TD2]),this.DCE_ELEMENTS.passportModeOption.classList.toggle("selected",this.scanModeManager[p.Passport])}catch(e){let t=(null==e?void 0:e.message)||e;console.error("MRZ Scanner switch scan mode error: ",t),this.closeCamera();const n={status:{code:y.RS_FAILED,message:"MRZ Scanner switch scan mode error"}};this.currentScanResolver(n)}}async launch(){try{await this.initialize();const{cvRouter:e,cameraEnhancer:t}=this.resources;return new Promise((async e=>{this.currentScanResolver=e,this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),!this.initializedDCE&&t.isOpen()&&await this.initializeElements(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()}))}catch(e){let t=(null==e?void 0:e.message)||e;console.error("MRZ Scanner launch error: ",t),this.closeCamera();const n={status:{code:y.RS_FAILED,message:"MRZ Scanner launch error"}};this.currentScanResolver(n)}}}const _={cancel:'\n\n \n \n \n \n \n \n \n \n \n \n ',rescan:'\n\n\n \n\n\n\n\n\n\n\n',complete:'\n\n\n\n \n\n\n\n\n\n\n\n',failed:'\n \n \n \n\n',info:'\n\n \n \n \n\n'};class L{constructor(e,t,n){this.resources=e,this.config=t,this.scannerView=n,this.editedFields={}}async launch(){try{return v(this.config.container).textContent="",await this.initialize(),v(this.config.container).style.display="flex",new Promise((e=>{this.currentScanResultViewResolver=e}))}catch(e){let t=(null==e?void 0:e.message)||e;throw console.error(t),t}}async handleRescan(){var e;try{if(!this.scannerView)return void console.error("Scanner View not initialized");this.hideView();const t=await this.scannerView.launch();if((null===(e=null==t?void 0:t.status)||void 0===e?void 0:e.code)===y.RS_FAILED)return void(this.currentScanResultViewResolver&&this.currentScanResultViewResolver(t));this.resources.onResultUpdated&&((null==t?void 0:t.status.code)===y.RS_CANCELLED?this.resources.onResultUpdated(this.resources.result):(null==t?void 0:t.status.code)===y.RS_SUCCESS&&this.resources.onResultUpdated(t)),this.dispose(!0),await this.initialize(),v(this.config.container).style.display="flex"}catch(e){throw console.error("Error in rescan handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:y.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}async handleCancel(){var e;try{(null===(e=this.config)||void 0===e?void 0:e.onCancel)&&await this.config.onCancel(this.resources.result),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:y.RS_CANCELLED,message:"Upload file cancelled"}}),this.hideView(),this.dispose()}catch(e){throw console.error("Error in cancel handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:y.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}async handleDone(){var e,t;try{(null===(e=this.resources.result)||void 0===e?void 0:e.data)&&!R(this.editedFields)&&(this.resources.result.data=Object.assign(Object.assign({},this.resources.result.data),this.editedFields),this.resources.onResultUpdated&&this.resources.onResultUpdated(this.resources.result)),(null===(t=this.config)||void 0===t?void 0:t.onDone)&&await this.config.onDone(this.resources.result),this.currentScanResultViewResolver&&this.resources.result&&this.currentScanResultViewResolver(this.resources.result),this.hideView(),this.dispose()}catch(e){throw console.error("Error in done handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:y.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}createControls(){var e,t,n,i,s,a,o,r,l,c,d,h;const{toolbarButtonsConfig:u}=this.config;return function(e){S("dynamsoft-mrz-controls-style","\n .dynamsoft-mrz-controls {\n display: flex;\n height: 6rem;\n background-color: #323234;\n align-items: center;\n font-size: 12px;\n font-family: Verdana;\n color: white;\n width: 100%;\n }\n\n .dynamsoft-mrz-control-btn {\n background-color: #323234;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n gap: 0.5rem;\n text-align: center;\n user-select: none;\n }\n\n .dynamsoft-mrz-control-btn.hide {\n display: none;\n }\n\n .dynamsoft-mrz-control-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n cursor: default;\n }\n\n .dynamsoft-mrz-control-icon-wrapper {\n flex: 0.75;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n min-height: 40px;\n }\n\n .dynamsoft-mrz-control-icon img,\n .dynamsoft-mrz-control-icon svg {\n width: 32px;\n height: 32px;\n fill: #fe8e14;\n }\n\n .dynamsoft-mrz-control-text {\n flex: 0.5;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-bottom: 0.5rem;\n }\n\n \n @media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-controls {\n flex-direction: column;\n height: 100%;\n width: 5rem;\n }\n\n .dynamsoft-mrz-control-text {\n padding: 0 0.5rem 0.5rem;\n }\n }\n");const t=document.createElement("div");return t.className="dynamsoft-mrz-controls",e.forEach((e=>{const n=document.createElement("div");n.className=`dynamsoft-mrz-control-btn ${null==e?void 0:e.className}`;const i=document.createElement("div");if(i.className="dynamsoft-mrz-control-icon-wrapper",(s=e.icon).trim().startsWith(""))i.innerHTML=e.icon;else{const t=document.createElement("img");t.src=e.icon,t.alt=e.label,t.width=24,t.height=24,i.appendChild(t)}var s;const a=document.createElement("div");a.className="dynamsoft-mrz-control-text",a.textContent=e.label,e.isDisabled&&n.classList.add("disabled"),e.isHidden&&n.classList.add("hide"),n.appendChild(i),n.appendChild(a),e.onClick&&!e.isDisabled&&n.addEventListener("click",e.onClick),t.appendChild(n)})),t}([this.config._isFileMode?{id:"dynamsoft-mrz-scanResult-cancel",icon:(null===(e=null==u?void 0:u.cancel)||void 0===e?void 0:e.icon)||_.cancel,label:(null===(t=null==u?void 0:u.cancel)||void 0===t?void 0:t.label)||"Cancel",onClick:()=>this.handleCancel(),className:`${(null===(n=null==u?void 0:u.cancel)||void 0===n?void 0:n.className)||""}`,isHidden:(null===(i=null==u?void 0:u.cancel)||void 0===i?void 0:i.isHidden)||!1}:{id:"dynamsoft-mrz-scanResult-rescan",icon:(null===(s=null==u?void 0:u.rescan)||void 0===s?void 0:s.icon)||_.rescan,label:(null===(a=null==u?void 0:u.rescan)||void 0===a?void 0:a.label)||"Re-scan",onClick:()=>this.handleRescan(),className:`${(null===(o=null==u?void 0:u.rescan)||void 0===o?void 0:o.className)||""}`,isHidden:(null===(r=null==u?void 0:u.rescan)||void 0===r?void 0:r.isHidden)||!1,isDisabled:!this.scannerView},{id:"dynamsoft-mrz-scanResult-done",icon:(null===(l=null==u?void 0:u.done)||void 0===l?void 0:l.icon)||_.complete,label:(null===(c=null==u?void 0:u.done)||void 0===c?void 0:c.label)||"Done",className:`${(null===(d=null==u?void 0:u.done)||void 0===d?void 0:d.className)||""}`,isHidden:(null===(h=null==u?void 0:u.done)||void 0===h?void 0:h.isHidden)||!1,onClick:()=>this.handleDone()}])}handleFieldEdit(e,t){if(e===T.DateOfBirth||e===T.DateOfExpiry)try{const[n,i,s]=t.split(/[\/\-\.]/);s&&i&&n&&(this.editedFields[e]={day:parseInt(s,10),month:parseInt(i,10),year:parseInt(n,10)})}catch(e){console.error("Error parsing date",e)}else this.editedFields[e]=t}createMRZDataDisplay(){var e,t,n,i;const s=(null===(e=this.resources.result)||void 0===e?void 0:e.data)||{},a=!!this.config.allowResultEditing,o=s.invalidFields||[],r=[T.InvalidFields,T.IssuingStateRaw,T.NationalityRaw];!1===(null===(t=this.config)||void 0===t?void 0:t.showMRZText)&&r.push(T.MRZText);const l=document.createElement("div");if(l.className="dynamsoft-mrz-data-container",R(s)){const e=document.createElement("div");return e.className="dynamsoft-mrz-data-row empty",e.innerText=null!==(i=null===(n=this.config)||void 0===n?void 0:n.emptyResultMessage)&&void 0!==i?i:"The necessary information couldn't be detected. Please try again.",l.appendChild(e),l}if(o.length>0){const e=document.createElement("div");e.className="dynamsoft-mrz-error-notification",e.innerHTML=`\n
${_.failed}
\n
\n ${a?"Some fields require correction. Please review highlighted fields.":"Some fields contain invalid information. Please rescan the document."}\n
\n `,l.appendChild(e)}else if(0===o.length&&a){const e=document.createElement("div");e.className="dynamsoft-mrz-info-notification",e.innerHTML=`\n
${_.info}
\n
\n Please review all fields to ensure the information is correct.\n
\n `,l.appendChild(e)}return Object.entries(s).forEach((([e,t])=>{if(r.includes(e)||!t)return;const n=document.createElement("div");n.className="dynamsoft-mrz-data-row";const i=o.includes(e);i&&n.classList.add("invalid-field");const s=[T.MRZText,T.DocumentType,T.IssuingStateRaw,T.NationalityRaw],c=document.createElement("span");if(c.className="dynamsoft-mrz-data-label",c.innerText=b[e]||e,i){const e=document.createElement("span");if(e.className="dynamsoft-mrz-error-icon",e.innerHTML=_.failed,c.appendChild(e),a){const e=document.createElement("span");e.className="dynamsoft-mrz-error-hint",e.textContent="Please correct this field",c.appendChild(e)}}const d=document.createElement("div");if(d.className="dynamsoft-mrz-data-value",a&&!s.includes(e)){const s=document.createElement("input");s.className="dynamsoft-mrz-data-input",i&&s.classList.add("invalid"),e===T.DateOfBirth||e===T.DateOfExpiry?(s.value=z(t),s.setAttribute("placeholder","YYYY-MM-DD")):s.value=t,s.addEventListener("input",(t=>{if(this.handleFieldEdit(e,t.target.value),i){s.classList.remove("invalid"),n.classList.remove("invalid-field"),this.editedFields.invalidFields||(this.editedFields.invalidFields=[...o]);const t=this.editedFields.invalidFields.indexOf(e);t>-1&&this.editedFields.invalidFields.splice(t,1)}})),d.appendChild(s)}else e===T.MRZText?(d.classList.add("code"),d.innerText=t):e===T.DateOfBirth||e===T.DateOfExpiry?d.innerText=z(t):d.innerText=t,i&&d.classList.add("invalid-value");n.appendChild(c),n.appendChild(d),l.appendChild(n)})),l}async initialize(){try{if(!this.resources.result)throw Error("Captured image is missing. Please capture an image first!");if(!this.config.container)throw new Error("Please create a Scan Result View Container element");S("dynamsoft-mrz-result-view-style",k);const e=document.createElement("div");if(e.className="dynamsoft-mrz-result-view-container",!1!==this.config.showOriginalImage){const t=this.resources.result.originalImageResult,n=document.createElement("div");let i;n.className="dynamsoft-mrz-result-view-image-container",(null==t?void 0:t.toCanvas)&&(i=null==t?void 0:t.toCanvas()),Object.assign(i.style,{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}),n.appendChild(i),e.appendChild(n)}const t=this.createMRZDataDisplay();e.appendChild(t);const n=this.createControls();e.appendChild(n),v(this.config.container).appendChild(e)}catch(e){let t=(null==e?void 0:e.message)||e;console.error(t),alert(t)}}hideView(){v(this.config.container).style.display="none"}dispose(e=!1){v(this.config.container).textContent="",e||(this.currentScanResultViewResolver=void 0)}}const k="\n .dynamsoft-mrz-result-view-container {\n display: flex;\n width: 100%;\n height: 100%;\n background-color:#575757;\n font-size: 12px;\n flex-direction: column;\n align-items: center;\n }\n\n .dynamsoft-mrz-result-view-image-container {\n width: 100%;\n height: 200px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #323234;\n }\n\n \n.dynamsoft-mrz-data-container {\n font-size: 16px;\n font-family: Verdana;\n color: white;\n overflow: auto;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 1rem 0;\n}\n\n.dynamsoft-mrz-data-row {\n padding: 0.5rem 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n transition: background-color 0.3s ease;\n}\n\n.dynamsoft-mrz-data-row.invalid-field {\n background-color: rgba(231, 76, 60, 0.1);\n border-left: 3px solid #e74c3c;\n padding-left: calc(2rem - 3px);\n}\n\n.dynamsoft-mrz-data-label {\n color: #aaa;\n display: flex;\n gap: 0.5rem;\n align-items: end;\n flex-wrap: wrap;\n}\n\n.dynamsoft-mrz-error-notification,\n.dynamsoft-mrz-info-notification {\n color: white;\n padding: 1rem;\n margin: 0.5rem 2rem;\n border-radius: 4px;\n display: flex;\n align-items: center;\n gap: 1rem;\n text-align: start;\n}\n\n.dynamsoft-mrz-error-notification {\n background-color: rgba(231, 76, 60, 0.2);\n}\n\n.dynamsoft-mrz-info-notification {\n background-color: #fe8e14;\n}\n\n.dynamsoft-mrz-edit-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #aaa;\n}\n\n.dynamsoft-mrz-error-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-info-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.dynamsoft-mrz-info-message,\n.dynamsoft-mrz-error-message {\n flex: 1;\n}\n\n.dynamsoft-mrz-error-hint {\n font-size: 0.8rem;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-value {\n word-wrap: break-word;\n text-align: start;\n}\n\n.dynamsoft-mrz-data-value.code {\n font-family: monospace;\n}\n\n.dynamsoft-mrz-data-value.invalid-value {\n color: #e74c3c;\n text-decoration: wavy underline #e74c3c;\n text-decoration-skip-ink: none;\n}\n\n.dynamsoft-mrz-data-input {\n width: 100%;\n padding: 5px;\n background-color: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.3);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n transition: all 0.3s ease;\n}\n\n.dynamsoft-mrz-data-input.invalid {\n background-color: rgba(231, 76, 60, 0.1);\n border-color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-input:focus {\n background-color: rgba(255, 255, 255, 0.2);\n border-color: #fe8e14;\n outline: none;\n}\n\n@media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-result-view-container {\n flex-direction: row;\n }\n\n .dynamsoft-mrz-result-view-image-container{\n flex: 1;\n height: 100%;\n }\n\n .dynamsoft-mrz-data-container{\n flex: 1;\n }\n\n .dynamsoft-mrz-data-row:first-of-type {\n padding-top: 2rem;\n }\n\n .dynamsoft-mrz-data-row:last-of-type {\n padding-bottom: 2rem;\n }\n\n .dynamsoft-mrz-data-row.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding-top: 0;\n padding-bottom: 0;\n }\n}\n",A={rootDirectory:"https://cdn.jsdelivr.net/npm/"};class O{showLoadingOverlay(e){var t,n;const i=v(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||v(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container);this.loadingScreen=C(i,{message:e}),i.style.display="block",i.style.position="relative"}hideLoadingOverlay(e=!1){var t,n,i;const s=v(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||v(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container);this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,s.style.display="none",e&&(null===(i=this.config)||void 0===i?void 0:i.container)&&(v(this.config.container).style.display="none"))}constructor(e){this.config=e,this.resources={},this.isInitialized=!1,this.isCapturing=!1,this.loadingScreen=null,this.isDynamsoftResourcesLoaded=!1,this.isFileMode=!1,this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources()}async initialize(){if(this.isInitialized)return{resources:this.resources,components:{scannerView:this.scannerView,resultView:this.resultView}};try{if(!this.initializeMRZScannerConfig())return console.error("Failed to initialize mrz scanner config"),{resources:this.resources,components:{}};S("dynamsoft-mrz-loading-screen-style",M),this.showLoadingOverlay("Loading..."),await this.initializeDCVResources(),this.resources.onResultUpdated=e=>{this.resources.result=e};const e={};return this.config.scannerViewConfig&&!this.isFileMode&&(this.scannerView=new N(this.resources,this.config.scannerViewConfig),e.scannerView=this.scannerView,await this.scannerView.initialize()),this.config.resultViewConfig&&(this.resultView=new L(this.resources,this.config.resultViewConfig,this.scannerView),e.resultView=this.resultView),this.isInitialized=!0,{resources:this.resources,components:e}}catch(e){this.isInitialized=!1;const t=`Initialization Failed: ${(null==e?void 0:e.message)||e}`;throw console.error(t),new Error(t)}finally{this.hideLoadingOverlay(!0)}}initializeDynamsoftResources(){var e;l.engineResourcePaths=R(null===(e=this.config)||void 0===e?void 0:e.engineResourcePaths)?A:this.config.engineResourcePaths,l.loadWasm(),c.loadSpec("MRTD_TD3_PASSPORT"),c.loadSpec("MRTD_TD3_VISA"),c.loadSpec("MRTD_TD1_ID"),c.loadSpec("MRTD_TD2_ID"),c.loadSpec("MRTD_TD2_VISA"),this.isDynamsoftResourcesLoaded=!0}async initializeDCVResources(){var e,t;try{this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources(),d._onAuthMessage=e=>e.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=mrz&deploymenttype=web)"),await d.initLicense((null===(e=this.config)||void 0===e?void 0:e.license)||"",{executeNow:!0}),this.isFileMode||(this.resources.cameraView=await h.createInstance(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.cameraEnhancerUIPath),this.resources.cameraEnhancer=await u.createInstance(this.resources.cameraView)),this.resources.cvRouter=await m.createInstance(),await this.resources.cvRouter.initSettings(this.config.templateFilePath)}catch(e){let t=(null==e?void 0:e.message)||e;const n=(null==t?void 0:t.toLowerCase().includes("license"))?"The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.":`Resource Initialization Failed: ${t}`;throw console.error(n),new Error(n)}}shouldCreateDefaultContainer(){var e,t;const n=!this.config.container,i=!((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container));return n&&i}createDefaultMRZScannerContainer(){const e=document.createElement("div");return e.className="mrz-scanner-main-container",Object.assign(e.style,{height:"100dvh",width:"100%",position:"absolute",left:"0",top:"0",zIndex:"999"}),document.body.append(e),e}checkForTemporaryLicense(e){return!(null==e?void 0:e.length)||(null==e?void 0:e.startsWith("A"))||(null==e?void 0:e.startsWith("L"))||(null==e?void 0:e.startsWith("P"))||(null==e?void 0:e.startsWith("Y"))?"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9":e}validateViewConfigs(){var e,t,n,i,s,a,o,r;if(!this.config.container){if((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)&&this.config.showResultView&&!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container)){const e="MRZResultView container is required when showResultView is true";return alert(e),console.error(e),!1}if(!(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)&&(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container)&&!this.resources.result){const e="Result is needed to create MRZResultView without a scanner view";return alert(e),console.error(e),!1}}try{if(this.config.container&&!v(this.config.container)){const e="Invalid main container reference";return alert(e),console.error(e),!1}if((null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.container)&&!v(null===(a=this.config.scannerViewConfig)||void 0===a?void 0:a.container)){const e="Invalid scanner view container reference";return alert(e),console.error(e),!1}if((null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)&&!v(null===(r=this.config.resultViewConfig)||void 0===r?void 0:r.container)){const e="Invalid result view container reference";return alert(e),console.error(e),!1}}catch(e){const t=`Error accessing container references: ${e.message}`;return alert(t),console.error(t),!1}return!0}showResultView(){var e,t;return!1!==this.config.showResultView&&(this.config.container?!(void 0!==this.config.showResultView||!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container)&&!this.config.container)||!!this.config.showResultView:this.config.showResultView&&!!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container))}initializeMRZScannerConfig(){var e,t,n,i,s,a,o;this.config=null!==(e=this.config)&&void 0!==e?e:{};if(!this.validateViewConfigs())return!1;this.shouldCreateDefaultContainer()?this.config.container=this.createDefaultMRZScannerContainer():this.config.container&&(this.config.container=v(this.config.container));const r=this.config.container?this.createViewContainers(v(this.config.container)):{},l={license:this.checkForTemporaryLicense(this.config.license),utilizedTemplateNames:Object.fromEntries(Object.values(g).map((e=>{var t;return[e,(null===(t=this.config.utilizedTemplateNames)||void 0===t?void 0:t[e])||w[e]]}))),templateFilePath:(null===(t=this.config)||void 0===t?void 0:t.templateFilePath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.template.json"},c=Object.assign(Object.assign({},this.config.scannerViewConfig),{container:r[f.Scanner]||v(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)||null,cameraEnhancerUIPath:(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.cameraEnhancerUIPath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.ui.html",templateFilePath:l.templateFilePath,utilizedTemplateNames:l.utilizedTemplateNames,enableMultiFrameCrossFilter:null===(a=null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.enableMultiFrameCrossFilter)||void 0===a||a,mrzFormatType:this.config.mrzFormatType}),d=this.showResultView()?Object.assign(Object.assign({},this.config.resultViewConfig),{_isFileMode:this.isFileMode,container:r[f.Result]||v(null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)||null}):void 0;return Object.assign(this.config,Object.assign(Object.assign({},l),{scannerViewConfig:c,resultViewConfig:d})),!0}createViewContainers(e){e.textContent="";const t=[f.Scanner];return this.showResultView()&&t.push(f.Result),t.reduce(((t,n)=>{const i=document.createElement("div");return i.className=`mrz-scanner-${n}-view-container`,Object.assign(i.style,{height:"100%",width:"100%",display:"none",position:"relative"}),e.append(i),t[n]=i,t}),{})}dispose(){var e,t;this.resultView&&(this.resultView.dispose(),this.resultView=null),this.scannerView=null,this.resources.cameraEnhancer&&(this.resources.cameraEnhancer.dispose(),this.resources.cameraEnhancer=null),this.resources.cameraView&&(this.resources.cameraView.dispose(),this.resources.cameraView=null),this.resources.cvRouter&&(this.resources.cvRouter.dispose(),this.resources.cvRouter=null),this.resources.result=null,this.resources.onResultUpdated=null;const n=e=>{const t=v(e);t&&(t.style.display="none",t.textContent="")};n(this.config.container),n(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container),n(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container),this.isInitialized=!1}async processUploadedFile(e){var t,i,o,r,l,c;try{this.showLoadingOverlay("Processing File...");const{cvRouter:d}=this.resources,h=null===(t=this.config.utilizedTemplateNames)||void 0===t?void 0:t.all,u=await d.getSimplifiedSettings(h);u.roiMeasuredInPercentage=!0,u.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await d.updateSettings(h,u);const m=await d.capture(e,h),g=m.items,p=g.filter((e=>e.type===n.CRIT_ORIGINAL_IMAGE))[0].imageData;p.toCanvas=()=>s(p),p.toBlob=async()=>await a("image/png",p);const f=null===(i=null==m?void 0:m.parsedResult)||void 0===i?void 0:i.parsedResultItems;let w={};if(null==f?void 0:f.length){const e=(null===(r=null===(o=f[0])||void 0===o?void 0:o.referencedItem)||void 0===r?void 0:r.text)||"";w=V(e,f[0])}const v={status:{code:y.RS_SUCCESS,message:"Success"},originalImageResult:p,data:w,imageData:!0,_imageData:p};null===(c=(l=this.resources).onResultUpdated)||void 0===c||c.call(l,v)}catch(e){return console.error("Failed to process uploaded file:",e),{status:{code:y.RS_FAILED,message:`Failed to process image: ${e.message||e}`}}}finally{this.hideLoadingOverlay(!1)}}async launch(e){if(this.isCapturing)throw new Error("Capture session already in progress");try{this.isCapturing=!0,this.isFileMode=!!e;const{components:t}=await this.initialize();if(R(t))throw new Error("MRZ Scanner initialization failed ");if(this.config.container&&(v(this.config.container).style.display="block"),this.isFileMode&&await this.processUploadedFile(e),!t.scannerView&&this.resources.result&&t.resultView)return await t.resultView.launch();if(!t.scannerView&&!this.resources.result&&!this.isFileMode)throw new Error("Scanner view is required when no previous result exists");if(t.scannerView){const e=await t.scannerView.launch();if((null==e?void 0:e.status.code)!==y.RS_SUCCESS)return{status:{code:null==e?void 0:e.status.code,message:(null==e?void 0:e.status.message)||"Failed to capture image"}};if(t.resultView)return await t.resultView.launch()}return this.resources.result}catch(e){return alert((null==e?void 0:e.message)||e),console.error((null==e?void 0:e.message)||e),{status:{code:y.RS_FAILED,message:(null==e?void 0:e.message)||e}}}finally{this.isCapturing=!1,this.dispose()}}}const P={MRZScanner:O,MRZScannerView:N,MRZResultView:L};export{w as DEFAULT_TEMPLATE_NAMES,P as DynamsoftMRZScanner,T as EnumMRZData,p as EnumMRZDocumentType,g as EnumMRZScanMode,f as EnumMRZScannerViews,y as EnumResultStatus,b as MRZDataLabel,L as MRZResultView,O as MRZScanner,N as MRZScannerView,z as displayMRZDate}; diff --git a/dist/mrz-scanner.template.json b/dist/mrz-scanner.template.json index 50645d9..b9ee235 100644 --- a/dist/mrz-scanner.template.json +++ b/dist/mrz-scanner.template.json @@ -5,49 +5,49 @@ "OutputOriginalImage": 1, "ImageROIProcessingNameArray": ["roi-passport-and-id"], "SemanticProcessingNameArray": ["sp-passport-and-id"], - "Timeout": 2000 + "MaxParallelTasks": 0 }, { "Name": "ReadPassport", "OutputOriginalImage": 1, "ImageROIProcessingNameArray": ["roi-passport"], "SemanticProcessingNameArray": ["sp-passport"], - "Timeout": 2000 + "MaxParallelTasks": 0 }, { "Name": "ReadId-TD1", "OutputOriginalImage": 1, "ImageROIProcessingNameArray": ["roi-id-td1"], "SemanticProcessingNameArray": ["sp-id-td1"], - "Timeout": 2000 + "MaxParallelTasks": 0 }, { "Name": "ReadId-TD2", "OutputOriginalImage": 1, "ImageROIProcessingNameArray": ["roi-id-td2"], "SemanticProcessingNameArray": ["sp-id-td2"], - "Timeout": 2000 + "MaxParallelTasks": 0 }, { "Name": "ReadId", "OutputOriginalImage": 1, "ImageROIProcessingNameArray": ["roi-id"], "SemanticProcessingNameArray": ["sp-id"], - "Timeout": 2000 + "MaxParallelTasks": 0 }, { "Name": "ReadPassportAndId-TD1", "OutputOriginalImage": 1, "ImageROIProcessingNameArray": ["roi-passport-and-id-td1"], "SemanticProcessingNameArray": ["sp-passport-and-id-td1"], - "Timeout": 2000 + "MaxParallelTasks": 0 }, { "Name": "ReadPassportAndId-TD2", "OutputOriginalImage": 1, "ImageROIProcessingNameArray": ["roi-passport-and-id-td2"], "SemanticProcessingNameArray": ["sp-passport-and-id-td2"], - "Timeout": 2000 + "MaxParallelTasks": 0 } ], "TargetROIDefOptions": [ @@ -82,8 +82,8 @@ ], "TextLineSpecificationOptions": [ { - "Name": "tls_mrz_passport", - "BaseTextLineSpecificationName": "tls_base", + "Name": "tls-mrz-passport", + "BaseTextLineSpecificationName": "tls-base", "StringLengthRange": [44, 44], "OutputResults": 1, "ExpectedGroupsCount": 1, @@ -93,18 +93,60 @@ { "StringRegExPattern": "(P[A-Z<][A-Z<]{3}[A-Z<]{39}){(44)}", "StringLengthRange": [44, 44], - "BaseTextLineSpecificationName": "tls_base" + "BaseTextLineSpecificationName": "tls-base" }, { "StringRegExPattern": "([A-Z0-9<]{9}[0-9][A-Z<]{3}[0-9]{2}[0-9<]{4}[0-9][MF<][0-9]{2}[(01-12)][(01-31)][0-9][A-Z0-9<]{14}[0-9<][0-9]){(44)}", "StringLengthRange": [44, 44], - "BaseTextLineSpecificationName": "tls_base" + "BaseTextLineSpecificationName": "tls-base" } ] }, { - "Name": "tls_mrz_id_td2", - "BaseTextLineSpecificationName": "tls_base", + "Name": "tls-mrz-visa-td3", + "BaseTextLineSpecificationName": "tls-base", + "StringLengthRange": [44, 44], + "OutputResults": 1, + "ExpectedGroupsCount": 1, + "ConcatResults": 1, + "ConcatSeparator": "\n", + "SubGroups": [ + { + "StringRegExPattern": "(V[A-Z<][A-Z<]{3}[A-Z<]{39}){(44)}", + "StringLengthRange": [44, 44], + "BaseTextLineSpecificationName": "tls-base" + }, + { + "StringRegExPattern": "([A-Z0-9<]{9}[0-9][A-Z<]{3}[0-9]{2}[(01-12)][(01-31)][0-9][MF<][0-9]{2}[(01-12)][(01-31)][0-9][A-Z0-9<]{14}[A-Z0-9<]{2}){(44)}", + "StringLengthRange": [44, 44], + "BaseTextLineSpecificationName": "tls-base" + } + ] + }, + { + "Name": "tls-mrz-visa-td2", + "BaseTextLineSpecificationName": "tls-base", + "StringLengthRange": [36, 36], + "OutputResults": 1, + "ExpectedGroupsCount": 1, + "ConcatResults": 1, + "ConcatSeparator": "\n", + "SubGroups": [ + { + "StringRegExPattern": "(V[A-Z<][A-Z<]{3}[A-Z<]{31}){(36)}", + "StringLengthRange": [36, 36], + "BaseTextLineSpecificationName": "tls-base" + }, + { + "StringRegExPattern": "([A-Z0-9<]{9}[0-9][A-Z<]{3}[0-9]{2}[(01-12)][(01-31)][0-9][MF<][0-9]{2}[(01-12)][(01-31)][0-9][A-Z0-9<]{8}){(36)}", + "StringLengthRange": [36, 36], + "BaseTextLineSpecificationName": "tls-base" + } + ] + }, + { + "Name": "tls-mrz-id-td2", + "BaseTextLineSpecificationName": "tls-base", "StringLengthRange": [36, 36], "OutputResults": 1, "ExpectedGroupsCount": 1, @@ -114,18 +156,18 @@ { "StringRegExPattern": "([ACI][A-Z<][A-Z<]{3}[A-Z<]{31}){(36)}", "StringLengthRange": [36, 36], - "BaseTextLineSpecificationName": "tls_base" + "BaseTextLineSpecificationName": "tls-base" }, { "StringRegExPattern": "([A-Z0-9<]{9}[0-9][A-Z<]{3}[0-9]{2}[0-9<]{4}[0-9][MF<][0-9]{2}[(01-12)][(01-31)][0-9][A-Z0-9<]{8}){(36)}", "StringLengthRange": [36, 36], - "BaseTextLineSpecificationName": "tls_base" + "BaseTextLineSpecificationName": "tls-base" } ] }, { - "Name": "tls_mrz_id_td1", - "BaseTextLineSpecificationName": "tls_base", + "Name": "tls-mrz-id-td1", + "BaseTextLineSpecificationName": "tls-base", "StringLengthRange": [30, 30], "OutputResults": 1, "ExpectedGroupsCount": 1, @@ -135,38 +177,83 @@ { "StringRegExPattern": "([ACI][A-Z<][A-Z<]{3}[A-Z0-9<]{9}[0-9<][A-Z0-9<]{15}){(30)}", "StringLengthRange": [30, 30], - "BaseTextLineSpecificationName": "tls_base" + "BaseTextLineSpecificationName": "tls-base" }, { "StringRegExPattern": "([0-9]{2}[(01-12)][(01-31)][0-9][MF<][0-9]{2}[0-9<]{4}[0-9][A-Z<]{3}[A-Z0-9<]{11}[0-9]){(30)}", "StringLengthRange": [30, 30], - "BaseTextLineSpecificationName": "tls_base" + "BaseTextLineSpecificationName": "tls-base" + }, + { + "StringRegExPattern": "([A-Z<]{30}){(30)}", + "StringLengthRange": [30, 30], + "BaseTextLineSpecificationName": "tls-base" + } + ] + }, + { + "Name": "tls-mrz-FrenchId-td2", + "BaseTextLineSpecificationName": "tls-base", + "StringLengthRange": [36, 36], + "OutputResults": 1, + "ExpectedGroupsCount": 1, + "ConcatResults": 1, + "ConcatSeparator": "\n", + "SubGroups": [ + { + "StringRegExPattern": "(I[A-Z<])(FRA)([A-Z<]{25})([A-Z0-9<]{3})([0-9<]{3}){(36)}", + "StringLengthRange": [36, 36], + "BaseTextLineSpecificationName": "tls-base" + }, + { + "StringRegExPattern": "([A-Z0-9]{12}[0-9][A-Z<]{14}[0-9]{2}[(01-12)][(01-31)][0-9][MF<][0-9]){(36)}", + "StringLengthRange": [36, 36], + "BaseTextLineSpecificationName": "tls-base" + } + ] + }, + { + "Name": "tls-mrz-SuissDL", + "BaseTextLineSpecificationName": "tls-base", + "StringLengthRange": [9, 30], + "OutputResults": 1, + "ExpectedGroupsCount": 1, + "ConcatResults": 1, + "ConcatSeparator": "\n", + "SubGroups": [ + { + "StringRegExPattern": "([A-Z0-9]{3}[0-9]{3}[DFIR](<<)){(9)}", + "StringLengthRange": [9, 9], + "BaseTextLineSpecificationName": "tls-base" + }, + { + "StringRegExPattern": "(FACHE[0-9]{12}(<<)[0-9]{2}[(01-12)][(01-31)][<]{5}){(30)}", + "StringLengthRange": [30, 30], + "BaseTextLineSpecificationName": "tls-base" }, { "StringRegExPattern": "([A-Z<]{30}){(30)}", "StringLengthRange": [30, 30], - "BaseTextLineSpecificationName": "tls_base" + "BaseTextLineSpecificationName": "tls-base" } ] }, { - "Name": "tls_base", - "CharacterModelName": "MRZ", + "Name": "tls-base", + "CharacterModelName": "MRZCharRecognition", + "TextLineRecModelName": "MRZTextLineRecognition", "CharHeightRange": [5, 1000, 1], "BinarizationModes": [ { - "BlockSizeX": 41, - "BlockSizeY": 41, - "Mode": "BM_LOCAL_BLOCK", - "EnableFillBinaryVacancy": 0, - "ThresholdCompensation": 15 + "BlockSizeX": 30, + "BlockSizeY": 30, + "Mode": "BM_LOCAL_BLOCK" } ], "ConfusableCharactersCorrection": { "ConfusableCharacters": [ ["0", "O"], - ["1", "I"], - ["5", "S"] + ["1", "I"] ], "FontNameArray": ["OCR_B"] } @@ -175,9 +262,9 @@ "LabelRecognizerTaskSettingOptions": [ { "Name": "task-passport", - "ConfusableCharactersPath": "ConfusableChars.data", - "TextLineSpecificationNameArray": ["tls_mrz_passport"], - "SectionImageParameterArray": [ + "MaxThreadsInOneTask": 4, + "TextLineSpecificationNameArray": ["tls-mrz-passport", "tls-mrz-visa-td3"], + "SectionArray": [ { "Section": "ST_REGION_PREDETECTION", "ImageParameterName": "ip-mrz" @@ -188,15 +275,26 @@ }, { "Section": "ST_TEXT_LINE_RECOGNITION", - "ImageParameterName": "ip-mrz" + "ImageParameterName": "ip-mrz", + "StageArray": [ + { + "Stage": "SST_RECOGNIZE_RAW_TEXT_LINES", + "ConfusableCharactersPath": "ConfusableChars.data", + "OverlappingCharactersPath": "OverlappingChars.data", + "EnableRegexForceCorrection": 0 + }, + { + "Stage": "SST_ASSEMBLE_TEXT_LINES" + } + ] } ] }, { "Name": "task-id-td1", - "ConfusableCharactersPath": "ConfusableChars.data", - "TextLineSpecificationNameArray": ["tls_mrz_id_td1"], - "SectionImageParameterArray": [ + "MaxThreadsInOneTask": 4, + "TextLineSpecificationNameArray": ["tls-mrz-id-td1"], + "SectionArray": [ { "Section": "ST_REGION_PREDETECTION", "ImageParameterName": "ip-mrz" @@ -207,15 +305,26 @@ }, { "Section": "ST_TEXT_LINE_RECOGNITION", - "ImageParameterName": "ip-mrz" + "ImageParameterName": "ip-mrz", + "StageArray": [ + { + "Stage": "SST_RECOGNIZE_RAW_TEXT_LINES", + "ConfusableCharactersPath": "ConfusableChars.data", + "OverlappingCharactersPath": "OverlappingChars.data", + "EnableRegexForceCorrection": 0 + }, + { + "Stage": "SST_ASSEMBLE_TEXT_LINES" + } + ] } ] }, { "Name": "task-id-td2", - "ConfusableCharactersPath": "ConfusableChars.data", - "TextLineSpecificationNameArray": ["tls_mrz_id_td2"], - "SectionImageParameterArray": [ + "MaxThreadsInOneTask": 4, + "TextLineSpecificationNameArray": ["tls-mrz-id-td2", "tls-mrz-visa-td2", "tls-mrz-FrenchId-td2"], + "SectionArray": [ { "Section": "ST_REGION_PREDETECTION", "ImageParameterName": "ip-mrz" @@ -226,15 +335,33 @@ }, { "Section": "ST_TEXT_LINE_RECOGNITION", - "ImageParameterName": "ip-mrz" + "ImageParameterName": "ip-mrz", + "StageArray": [ + { + "Stage": "SST_RECOGNIZE_RAW_TEXT_LINES", + "ConfusableCharactersPath": "ConfusableChars.data", + "OverlappingCharactersPath": "OverlappingChars.data", + "EnableRegexForceCorrection": 0 + }, + { + "Stage": "SST_ASSEMBLE_TEXT_LINES" + } + ] } ] }, { "Name": "task-passport-and-id", - "ConfusableCharactersPath": "ConfusableChars.data", - "TextLineSpecificationNameArray": ["tls_mrz_passport", "tls_mrz_id_td1", "tls_mrz_id_td2"], - "SectionImageParameterArray": [ + "MaxThreadsInOneTask": 4, + "TextLineSpecificationNameArray": [ + "tls-mrz-passport", + "tls-mrz-visa-td3", + "tls-mrz-id-td1", + "tls-mrz-id-td2", + "tls-mrz-visa-td2", + "tls-mrz-FrenchId-td2" + ], + "SectionArray": [ { "Section": "ST_REGION_PREDETECTION", "ImageParameterName": "ip-mrz" @@ -245,15 +372,26 @@ }, { "Section": "ST_TEXT_LINE_RECOGNITION", - "ImageParameterName": "ip-mrz" + "ImageParameterName": "ip-mrz", + "StageArray": [ + { + "Stage": "SST_RECOGNIZE_RAW_TEXT_LINES", + "ConfusableCharactersPath": "ConfusableChars.data", + "OverlappingCharactersPath": "OverlappingChars.data", + "EnableRegexForceCorrection": 0 + }, + { + "Stage": "SST_ASSEMBLE_TEXT_LINES" + } + ] } ] }, { "Name": "task-passport-and-id-td1", - "ConfusableCharactersPath": "ConfusableChars.data", - "TextLineSpecificationNameArray": ["tls_mrz_passport", "tls_mrz_id_td1"], - "SectionImageParameterArray": [ + "MaxThreadsInOneTask": 4, + "TextLineSpecificationNameArray": ["tls-mrz-passport", "tls-mrz-visa-td3", "tls-mrz-id-td1"], + "SectionArray": [ { "Section": "ST_REGION_PREDETECTION", "ImageParameterName": "ip-mrz" @@ -264,15 +402,32 @@ }, { "Section": "ST_TEXT_LINE_RECOGNITION", - "ImageParameterName": "ip-mrz" + "ImageParameterName": "ip-mrz", + "StageArray": [ + { + "Stage": "SST_RECOGNIZE_RAW_TEXT_LINES", + "ConfusableCharactersPath": "ConfusableChars.data", + "OverlappingCharactersPath": "OverlappingChars.data", + "EnableRegexForceCorrection": 0 + }, + { + "Stage": "SST_ASSEMBLE_TEXT_LINES" + } + ] } ] }, { "Name": "task-passport-and-id-td2", - "ConfusableCharactersPath": "ConfusableChars.data", - "TextLineSpecificationNameArray": ["tls_mrz_passport", "tls_mrz_id_td2"], - "SectionImageParameterArray": [ + "MaxThreadsInOneTask": 4, + "TextLineSpecificationNameArray": [ + "tls-mrz-passport", + "tls-mrz-visa-td3", + "tls-mrz-id-td2", + "tls-mrz-visa-td2", + "tls-mrz-FrenchId-td2" + ], + "SectionArray": [ { "Section": "ST_REGION_PREDETECTION", "ImageParameterName": "ip-mrz" @@ -283,15 +438,31 @@ }, { "Section": "ST_TEXT_LINE_RECOGNITION", - "ImageParameterName": "ip-mrz" + "ImageParameterName": "ip-mrz", + "StageArray": [ + { + "Stage": "SST_RECOGNIZE_RAW_TEXT_LINES", + "ConfusableCharactersPath": "ConfusableChars.data", + "OverlappingCharactersPath": "OverlappingChars.data", + "EnableRegexForceCorrection": 0 + }, + { + "Stage": "SST_ASSEMBLE_TEXT_LINES" + } + ] } ] }, { "Name": "task-id", - "ConfusableCharactersPath": "ConfusableChars.data", - "TextLineSpecificationNameArray": ["tls_mrz_id_td1", "tls_mrz_id_td2"], - "SectionImageParameterArray": [ + "MaxThreadsInOneTask": 4, + "TextLineSpecificationNameArray": [ + "tls-mrz-id-td1", + "tls-mrz-id-td2", + "tls-mrz-visa-td2", + "tls-mrz-FrenchId-td2" + ], + "SectionArray": [ { "Section": "ST_REGION_PREDETECTION", "ImageParameterName": "ip-mrz" @@ -302,56 +473,129 @@ }, { "Section": "ST_TEXT_LINE_RECOGNITION", - "ImageParameterName": "ip-mrz" + "ImageParameterName": "ip-mrz", + "StageArray": [ + { + "Stage": "SST_RECOGNIZE_RAW_TEXT_LINES", + "ConfusableCharactersPath": "ConfusableChars.data", + "OverlappingCharactersPath": "OverlappingChars.data", + "EnableRegexForceCorrection": 0 + }, + { + "Stage": "SST_ASSEMBLE_TEXT_LINES" + } + ] } ] } ], - "CharacterModelOptions": [ + "CaptureVisionModelOptions": [ { + "Name": "MRZCharRecognition", "DirectoryPath": "", - "Name": "MRZ" + "MaxModelInstances": 4 + }, + { + "Name": "MRZTextLineRecognition", + "DirectoryPath": "", + "MaxModelInstances": 1 } ], + "ImageParameterOptions": [ { "Name": "ip-mrz", - "TextureDetectionModes": [ + "ApplicableStages": [ { - "Mode": "TDM_GENERAL_WIDTH_CONCENTRATION", - "Sensitivity": 8 - } - ], - "BinarizationModes": [ + "Stage": "SST_SCALE_IMAGE", + "ImageScaleSetting": { + "ScaleType": "ST_SCALE_DOWN", + "ReferenceEdge": "RE_SHORTER_EDGE", + "EdgeLengthThreshold": 99999 + } + }, { - "EnableFillBinaryVacancy": 0, - "ThresholdCompensation": 21, - "Mode": "BM_LOCAL_BLOCK" + "Stage": "SST_CONVERT_TO_GRAYSCALE", + "ColourConversionModes": [ + { + "Mode": "CICM_HSV", + "ReferChannel": "V_CHANNEL" + } + ] + }, + { + "Stage": "SST_BINARIZE_IMAGE", + "BinarizationModes": [ + { + "EnableFillBinaryVacancy": 0, + "Mode": "BM_THRESHOLD" + }, + { + "EnableFillBinaryVacancy": 0, + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "ThresholdCompensation": 15 + } + ] + }, + { + "Stage": "SST_BINARIZE_TEXTURE_REMOVED_GRAYSCALE", + "BinarizationModes": [ + { + "EnableFillBinaryVacancy": 0, + "Mode": "BM_THRESHOLD" + }, + { + "EnableFillBinaryVacancy": 0, + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "ThresholdCompensation": 15 + } + ] + }, + { + "Stage": "SST_DETECT_TEXTURE", + "TextureDetectionModes": [ + { + "Mode": "TDM_GENERAL_WIDTH_CONCENTRATION", + "Sensitivity": 8 + } + ] + }, + { + "Stage": "SST_DETECT_TEXT_ZONES", + "TextDetectionMode": { + "Mode": "TTDM_LINE", + "MaxSpacingInALine": 300, + "CharHeightRange": [5, 1000, 1], + "StringLengthRange": [9, 50], + "Direction": "HORIZONTAL", + "Sensitivity": 7 + } } - ], - "TextDetectionMode": { - "Mode": "TTDM_LINE", - "CharHeightRange": [5, 1000, 1], - "Direction": "HORIZONTAL", - "Sensitivity": 7 - } + ] } ], + "SemanticProcessingOptions": [ { - "Name": "sp-passport", + "Name": "sp-passport-and-id", "ReferenceObjectFilter": { - "ReferenceTargetROIDefNameArray": ["roi-passport"] + "ReferenceTargetROIDefNameArray": ["roi-passport-and-id"] }, - "TaskSettingNameArray": ["dcp-passport"] + "TaskSettingNameArray": ["dcp-passport-and-id"] }, + { - "Name": "sp-passport-and-id", + "Name": "sp-passport", "ReferenceObjectFilter": { - "ReferenceTargetROIDefNameArray": ["roi-passport-and-id"] + "ReferenceTargetROIDefNameArray": ["roi-passport"] }, - "TaskSettingNameArray": ["dcp-passport-and-id"] + "TaskSettingNameArray": ["dcp-passport"] }, + { "Name": "sp-passport-and-id-td1", "ReferenceObjectFilter": { @@ -390,9 +634,13 @@ } ], "CodeParserTaskSettingOptions": [ + { + "Name": "dcp-passport-and-id", + "CodeSpecifications": ["MRTD_TD3_PASSPORT", "MRTD_TD2_VISA", "MRTD_TD3_VISA", "MRTD_TD1_ID", "MRTD_TD2_ID"] + }, { "Name": "dcp-passport", - "CodeSpecifications": ["MRTD_TD3_PASSPORT"] + "CodeSpecifications": ["MRTD_TD3_PASSPORT", "MRTD_TD3_VISA"] }, { "Name": "dcp-id-td1", @@ -400,23 +648,21 @@ }, { "Name": "dcp-id-td2", - "CodeSpecifications": ["MRTD_TD2_ID"] - }, - { - "Name": "dcp-passport-and-id", - "CodeSpecifications": ["MRTD_TD3_PASSPORT", "MRTD_TD1_ID", "MRTD_TD2_ID"] + "CodeSpecifications": ["MRTD_TD2_ID", "MRTD_TD2_VISA"] }, + { "Name": "dcp-passport-and-id-td1", - "CodeSpecifications": ["MRTD_TD3_PASSPORT", "MRTD_TD1_ID"] + "CodeSpecifications": ["MRTD_TD3_PASSPORT", "MRTD_TD3_VISA", "MRTD_TD1_ID"] }, { "Name": "dcp-passport-and-id-td2", - "CodeSpecifications": ["MRTD_TD3_PASSPORT", "MRTD_TD2_ID"] + "CodeSpecifications": ["MRTD_TD3_PASSPORT", "MRTD_TD3_VISA", "MRTD_TD2_ID", "MRTD_TD2_VISA"] }, + { "Name": "dcp-id", - "CodeSpecifications": ["MRTD_TD1_ID", "MRTD_TD2_ID"] + "CodeSpecifications": ["MRTD_TD1_ID", "MRTD_TD2_ID", "MRTD_TD2_VISA"] } ] } diff --git a/dist/mrz-scanner.ui.html b/dist/mrz-scanner.ui.html index b9ce3cd..eb155d1 100644 --- a/dist/mrz-scanner.ui.html +++ b/dist/mrz-scanner.ui.html @@ -6,38 +6,21 @@
- - - - - - - - - + ; + resultViewConfig?: MRZResultViewConfig; + mrzFormatType?: Array; + showResultView?: boolean; +} +export interface SharedResources { + cvRouter?: CaptureVisionRouter; + cameraEnhancer?: CameraEnhancer; + cameraView?: CameraView; + result?: MRZResult; + onResultUpdated?: (result: MRZResult) => void; +} +declare class MRZScanner { + private config; + private scannerView?; + private resultView?; + private resources; + private isInitialized; + private isCapturing; + private loadingScreen; + private isDynamsoftResourcesLoaded; + protected isFileMode: boolean; + private showLoadingOverlay; + private hideLoadingOverlay; + constructor(config: MRZScannerConfig); + initialize(): Promise<{ + resources: SharedResources; + components: { + scannerView?: MRZScannerView; + resultView?: MRZResultView; + }; + }>; + private initializeDynamsoftResources; + private initializeDCVResources; + private shouldCreateDefaultContainer; + private createDefaultMRZScannerContainer; + private checkForTemporaryLicense; + private validateViewConfigs; + private showResultView; + private initializeMRZScannerConfig; + private createViewContainers; + dispose(): void; + /** + * Processes an uploaded image file + * @param imageOrFile The file to process + * @returns Promise with the document result + */ + private processUploadedFile; + launch(imageOrFile: Blob | string | DSImageData | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement): Promise; +} +export default MRZScanner; +//# sourceMappingURL=MRZScanner.d.ts.map \ No newline at end of file diff --git a/dist/types/MRZScanner.d.ts.map b/dist/types/MRZScanner.d.ts.map new file mode 100644 index 0000000..31961b3 --- /dev/null +++ b/dist/types/MRZScanner.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"MRZScanner.d.ts","sourceRoot":"","sources":["../../src/MRZScanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,EACX,mBAAmB,EAMnB,mBAAmB,EACnB,cAAc,EACd,UAAU,EAEX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,mBAAmB,EAInB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,cAAc,EAAE,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAW,SAAS,EAAkB,MAAM,yBAAyB,CAAC;AAC7E,OAAO,aAAa,EAAE,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAY3E,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAGjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAG1C,iBAAiB,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,kBAAkB,GAAG,uBAAuB,CAAC,CAAC;IAC7F,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;IAEvC,aAAa,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC3C,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC;CAC/C;AAED,cAAM,UAAU;IAsCF,OAAO,CAAC,MAAM;IArC1B,OAAO,CAAC,WAAW,CAAC,CAAiB;IACrC,OAAO,CAAC,UAAU,CAAC,CAAgB;IAEnC,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,aAAa,CAAqD;IAE1E,OAAO,CAAC,0BAA0B,CAAS;IAE3C,SAAS,CAAC,UAAU,EAAE,OAAO,CAAS;IAEtC,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,kBAAkB;gBAeN,MAAM,EAAE,gBAAgB;IAMtC,UAAU,IAAI,OAAO,CAAC;QAC1B,SAAS,EAAE,eAAe,CAAC;QAC3B,UAAU,EAAE;YACV,WAAW,CAAC,EAAE,cAAc,CAAC;YAC7B,UAAU,CAAC,EAAE,aAAa,CAAC;SAC5B,CAAC;KACH,CAAC;IA8DF,OAAO,CAAC,4BAA4B;YAkBtB,sBAAsB;IAwCpC,OAAO,CAAC,4BAA4B;IAMpC,OAAO,CAAC,gCAAgC;IAgBxC,OAAO,CAAC,wBAAwB;IAUhC,OAAO,CAAC,mBAAmB;IA6D3B,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,0BAA0B;IAwDlC,OAAO,CAAC,oBAAoB;IAwB5B,OAAO,IAAI,IAAI;IA2Cf;;;;OAIG;YACW,mBAAmB;IAgF3B,MAAM,CACV,WAAW,EAAE,IAAI,GAAG,MAAM,GAAG,WAAW,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,iBAAiB,GACjG,OAAO,CAAC,SAAS,CAAC;CAuEtB;AAED,eAAe,UAAU,CAAC"} \ No newline at end of file diff --git a/dist/types/views/MRZResultView.d.ts b/dist/types/views/MRZResultView.d.ts new file mode 100644 index 0000000..9605273 --- /dev/null +++ b/dist/types/views/MRZResultView.d.ts @@ -0,0 +1,39 @@ +import { ToolbarButton, ToolbarButtonConfig } from "./utils/types"; +import { MRZResult } from "./utils/MRZParser"; +import MRZScannerView from "./MRZScannerView"; +import { SharedResources } from "../MRZScanner"; +export interface MRZResultViewToolbarButtonsConfig { + cancel?: ToolbarButton; + rescan?: ToolbarButtonConfig; + done?: ToolbarButtonConfig; +} +export interface MRZResultViewConfig { + container?: HTMLElement | string; + toolbarButtonsConfig?: MRZResultViewToolbarButtonsConfig; + showOriginalImage?: boolean; + showMRZText?: boolean; + allowResultEditing?: boolean; + emptyResultMessage?: string; + onDone?: (result: MRZResult) => Promise; + onCancel?: (result: MRZResult) => Promise; + _isFileMode?: boolean; +} +export default class MRZResultView { + private resources; + private config; + private scannerView; + private currentScanResultViewResolver?; + private editedFields; + constructor(resources: SharedResources, config: MRZResultViewConfig, scannerView: MRZScannerView); + launch(): Promise; + private handleRescan; + private handleCancel; + private handleDone; + private createControls; + private handleFieldEdit; + private createMRZDataDisplay; + initialize(): Promise; + hideView(): void; + dispose(preserveResolver?: boolean): void; +} +//# sourceMappingURL=MRZResultView.d.ts.map \ No newline at end of file diff --git a/dist/types/views/MRZResultView.d.ts.map b/dist/types/views/MRZResultView.d.ts.map new file mode 100644 index 0000000..f40c41c --- /dev/null +++ b/dist/types/views/MRZResultView.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"MRZResultView.d.ts","sourceRoot":"","sources":["../../../src/views/MRZResultView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAA+D,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG3G,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,WAAW,iCAAiC;IAChD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IACjC,oBAAoB,CAAC,EAAE,iCAAiC,CAAC;IACzD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAGhD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,CAAC,OAAO,OAAO,aAAa;IAK9B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,WAAW;IANrB,OAAO,CAAC,6BAA6B,CAAC,CAA8B;IACpE,OAAO,CAAC,YAAY,CAAwB;gBAGlC,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,mBAAmB,EAC3B,WAAW,EAAE,cAAc;IAG/B,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC;YAiBpB,YAAY;YA4CZ,YAAY;YAiCZ,UAAU;IAyCxB,OAAO,CAAC,cAAc;IAmCtB,OAAO,CAAC,eAAe;IAoBvB,OAAO,CAAC,oBAAoB;IAgKtB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAoDjC,QAAQ,IAAI,IAAI;IAIhB,OAAO,CAAC,gBAAgB,GAAE,OAAe,GAAG,IAAI;CASjD"} \ No newline at end of file diff --git a/dist/types/views/MRZScannerView.d.ts b/dist/types/views/MRZScannerView.d.ts new file mode 100644 index 0000000..ccc05a9 --- /dev/null +++ b/dist/types/views/MRZScannerView.d.ts @@ -0,0 +1,64 @@ +import { CapturedResult } from "dynamsoft-capture-vision-bundle"; +import { SharedResources } from "../MRZScanner"; +import { UtilizedTemplateNames, EnumMRZDocumentType } from "./utils/types"; +import { MRZResult } from "./utils/MRZParser"; +export interface MRZScannerViewConfig { + cameraEnhancerUIPath?: string; + container?: HTMLElement | string; + templateFilePath?: string; + utilizedTemplateNames?: UtilizedTemplateNames; + mrzFormatType?: EnumMRZDocumentType | Array; + showScanGuide?: boolean; + showUploadImage?: boolean; + showFormatSelector?: boolean; + showSoundToggle?: boolean; + showPoweredByDynamsoft?: boolean; + enableMultiFrameCrossFilter?: boolean; + uploadAcceptedTypes?: string; + uploadFileConverter?: (file: File) => Promise; +} +export default class MRZScannerView { + private resources; + private config; + private isSoundFeedbackOn; + private scanModeManager; + private currentScanMode; + private resizeTimer; + private capturedResultItems; + private originalImageData; + private initialized; + private initializedDCE; + private DCE_ELEMENTS; + private currentScanResolver?; + private loadingScreen; + private showScannerLoadingOverlay; + private hideScannerLoadingOverlay; + private handleResize; + constructor(resources: SharedResources, config: MRZScannerViewConfig); + initialize(): Promise; + private initializeElements; + private setupScanModeSelector; + private assignDCEClickEvents; + private handleCloseBtn; + private attachOptionClickListeners; + private highlightCameraAndResolutionOption; + private toggleSelectCameraBox; + private relaunch; + private uploadFile; + private toggleSoundFeedback; + private calculateScanRegion; + private toggleScanGuide; + openCamera(): Promise; + closeCamera(hideContainer?: boolean): Promise; + pauseCamera(): void; + stopCapturing(): void; + handleMRZResult(result: CapturedResult): Promise; + private initializeScanModeManager; + private getScanMode; + private DCEShowToast; + private firstFrame; + private startCapturing; + private toggleScanDocType; + launch(): Promise; +} +//# sourceMappingURL=MRZScannerView.d.ts.map \ No newline at end of file diff --git a/dist/types/views/MRZScannerView.d.ts.map b/dist/types/views/MRZScannerView.d.ts.map new file mode 100644 index 0000000..57e9936 --- /dev/null +++ b/dist/types/views/MRZScannerView.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"MRZScannerView.d.ts","sourceRoot":"","sources":["../../../src/views/MRZScannerView.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,cAAc,EAKf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAoB,qBAAqB,EAAmB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAG9G,OAAO,EAAW,SAAS,EAAkB,MAAM,mBAAmB,CAAC;AAEvE,MAAM,WAAW,oBAAoB;IACnC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,aAAa,CAAC,EAAE,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAGjE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAEtC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAqBD,MAAM,CAAC,OAAO,OAAO,cAAc;IAsErB,OAAO,CAAC,SAAS;IAAmB,OAAO,CAAC,MAAM;IArE9D,OAAO,CAAC,iBAAiB,CAAkB;IAE3C,OAAO,CAAC,eAAe,CAIrB;IACF,OAAO,CAAC,eAAe,CAAwC;IAE/D,OAAO,CAAC,WAAW,CAAuB;IAE1C,OAAO,CAAC,mBAAmB,CAA+B;IAC1D,OAAO,CAAC,iBAAiB,CAAqD;IAE9E,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,cAAc,CAAkB;IAGxC,OAAO,CAAC,YAAY,CAUlB;IAGF,OAAO,CAAC,mBAAmB,CAAC,CAA8B;IAE1D,OAAO,CAAC,aAAa,CAAqD;IAE1E,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,yBAAyB;IAWjC,OAAO,CAAC,YAAY,CAclB;gBAEkB,SAAS,EAAE,eAAe,EAAU,MAAM,EAAE,oBAAoB;IAE9E,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA2DjC,OAAO,CAAC,kBAAkB;IA6C1B,OAAO,CAAC,qBAAqB;IAwB7B,OAAO,CAAC,oBAAoB;IAoC5B,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,0BAA0B;IAwClC,OAAO,CAAC,kCAAkC;IA4C1C,OAAO,CAAC,qBAAqB;YAiBf,QAAQ;YAIR,UAAU;IA0IxB,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,mBAAmB;IA6D3B,OAAO,CAAC,eAAe;IAiDjB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAsD3B,WAAW,CAAC,aAAa,GAAE,OAAc;IA2B/C,WAAW;IAKX,aAAa;IAOP,eAAe,CAAC,MAAM,EAAE,cAAc;IA2E5C,OAAO,CAAC,yBAAyB;IA2BjC,OAAO,CAAC,WAAW;IAqBnB,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,UAAU,CAAQ;YACZ,cAAc;YAqDd,iBAAiB;IA2CzB,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC;CAuCnC"} \ No newline at end of file diff --git a/dist/types/views/utils/LoadingScreen.d.ts b/dist/types/views/utils/LoadingScreen.d.ts new file mode 100644 index 0000000..1731f28 --- /dev/null +++ b/dist/types/views/utils/LoadingScreen.d.ts @@ -0,0 +1,12 @@ +interface LoadingScreenOptions { + message?: string; + spinnerSize?: number; +} +export declare function showLoadingScreen(container: HTMLElement, options?: LoadingScreenOptions): { + element: HTMLDivElement; + updateMessage: (newMessage: string | null) => void; + hide: () => void; +}; +export declare const DEFAULT_LOADING_SCREEN_STYLE = "\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: \"Verdana\";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n"; +export {}; +//# sourceMappingURL=LoadingScreen.d.ts.map \ No newline at end of file diff --git a/dist/types/views/utils/LoadingScreen.d.ts.map b/dist/types/views/utils/LoadingScreen.d.ts.map new file mode 100644 index 0000000..235271a --- /dev/null +++ b/dist/types/views/utils/LoadingScreen.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"LoadingScreen.d.ts","sourceRoot":"","sources":["../../../../src/views/utils/LoadingScreen.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,GAAE,oBAAyB;;gCA6C5D,MAAM,GAAG,IAAI;;EA6B5C;AAED,eAAO,MAAM,4BAA4B,+/BAuDxC,CAAC"} \ No newline at end of file diff --git a/dist/types/views/utils/MRZParser.d.ts b/dist/types/views/utils/MRZParser.d.ts new file mode 100644 index 0000000..f652922 --- /dev/null +++ b/dist/types/views/utils/MRZParser.d.ts @@ -0,0 +1,50 @@ +import { DSImageData, ParsedResultItem } from "dynamsoft-capture-vision-bundle"; +import { ResultStatus } from "./types"; +export declare enum EnumMRZData { + InvalidFields = "invalidFields", + DocumentType = "documentType", + DocumentNumber = "documentNumber", + MRZText = "mrzText", + FirstName = "firstName", + LastName = "lastName", + Age = "age", + Sex = "sex", + IssuingState = "issuingState", + IssuingStateRaw = "issuingStateRaw", + Nationality = "nationality", + NationalityRaw = "nationalityRaw", + DateOfBirth = "dateOfBirth", + DateOfExpiry = "dateOfExpiry" +} +export interface MRZResult { + status: ResultStatus; + originalImageResult?: DSImageData; + data?: MRZData; + imageData?: boolean; + _imageData?: DSImageData; +} +export interface MRZData { + [EnumMRZData.InvalidFields]?: EnumMRZData[]; + [EnumMRZData.DocumentType]: string; + [EnumMRZData.DocumentNumber]: string; + [EnumMRZData.MRZText]: string; + [EnumMRZData.FirstName]: string; + [EnumMRZData.LastName]: string; + [EnumMRZData.Age]: number; + [EnumMRZData.Sex]: string; + [EnumMRZData.IssuingState]: string; + [EnumMRZData.IssuingStateRaw]: string; + [EnumMRZData.Nationality]: string; + [EnumMRZData.NationalityRaw]: string; + [EnumMRZData.DateOfBirth]: MRZDate; + [EnumMRZData.DateOfExpiry]: MRZDate; +} +export interface MRZDate { + year: number; + month: number; + day: number; +} +export declare const MRZDataLabel: Record; +export declare function displayMRZDate(date: MRZDate): string; +export declare function processMRZData(mrzText: string, parsedResult: ParsedResultItem): MRZData | null; +//# sourceMappingURL=MRZParser.d.ts.map \ No newline at end of file diff --git a/dist/types/views/utils/MRZParser.d.ts.map b/dist/types/views/utils/MRZParser.d.ts.map new file mode 100644 index 0000000..17f680e --- /dev/null +++ b/dist/types/views/utils/MRZParser.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"MRZParser.d.ts","sourceRoot":"","sources":["../../../../src/views/utils/MRZParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAwB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACtG,OAAO,EAAuB,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5D,oBAAY,WAAW;IACrB,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;IACnC,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;CAC9B;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,YAAY,CAAC;IACrB,mBAAmB,CAAC,EAAE,WAAW,CAAC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;IAGf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,WAAW,OAAO;IACtB,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IAC5C,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IACnC,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACrC,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC9B,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAChC,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC/B,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAC1B,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAC1B,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IACnC,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IACtC,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAClC,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACrC,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IACnC,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAgBpD,CAAC;AA8BF,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,UAG3C;AAgDD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,GAAG,OAAO,GAAG,IAAI,CAsG9F"} \ No newline at end of file diff --git a/dist/types/views/utils/icons.d.ts b/dist/types/views/utils/icons.d.ts new file mode 100644 index 0000000..2f5a2c9 --- /dev/null +++ b/dist/types/views/utils/icons.d.ts @@ -0,0 +1,8 @@ +export declare const MRZScanner_ICONS: { + cancel: string; + rescan: string; + complete: string; + failed: string; + info: string; +}; +//# sourceMappingURL=icons.d.ts.map \ No newline at end of file diff --git a/dist/types/views/utils/icons.d.ts.map b/dist/types/views/utils/icons.d.ts.map new file mode 100644 index 0000000..a1ad33c --- /dev/null +++ b/dist/types/views/utils/icons.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../../../src/views/utils/icons.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;CAwE5B,CAAC"} \ No newline at end of file diff --git a/dist/types/views/utils/index.d.ts b/dist/types/views/utils/index.d.ts new file mode 100644 index 0000000..d7530ad --- /dev/null +++ b/dist/types/views/utils/index.d.ts @@ -0,0 +1,37 @@ +import { ToolbarButton } from "./types"; +export declare function getElement(element: string | HTMLElement): HTMLElement | null; +export declare function createControls(buttons: ToolbarButton[], containerStyle?: Partial): HTMLElement; +export declare function createStyle(id: string, style: string): void; +export declare function isSVGString(str: string): boolean; +export declare const isEmptyObject: (obj: object | null | undefined) => boolean; +export declare function checkOrientation(): "portrait" | "landscape"; +export declare function capitalize(string: String): string; +export declare const STANDARD_RESOLUTIONS: { + readonly "4k": { + readonly width: 3840; + readonly height: 2160; + }; + readonly "2k": { + readonly width: 2560; + readonly height: 1440; + }; + readonly "1080p": { + readonly width: 1920; + readonly height: 1080; + }; + readonly "720p": { + readonly width: 1280; + readonly height: 720; + }; + readonly "480p": { + readonly width: 640; + readonly height: 480; + }; +}; +type ResolutionLevel = keyof typeof STANDARD_RESOLUTIONS; +export declare function findClosestResolutionLevel(selectedResolution: { + width: number; + height: number; +}): ResolutionLevel; +export {}; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/types/views/utils/index.d.ts.map b/dist/types/views/utils/index.d.ts.map new file mode 100644 index 0000000..92d9858 --- /dev/null +++ b/dist/types/views/utils/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,WAAW,GAAG,IAAI,CAO5E;AA4ED,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,WAAW,CA0DnH;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAQpD;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,eAAO,MAAM,aAAa,QAAS,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,OAE9D,CAAC;AAEF,wBAAgB,gBAAgB,6BAE/B;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,UAGxC;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;CAMvB,CAAC;AAEX,KAAK,eAAe,GAAG,MAAM,OAAO,oBAAoB,CAAC;AAEzD,wBAAgB,0BAA0B,CAAC,kBAAkB,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,CA6BjH"} \ No newline at end of file diff --git a/dist/types/views/utils/types.d.ts b/dist/types/views/utils/types.d.ts new file mode 100644 index 0000000..00730dd --- /dev/null +++ b/dist/types/views/utils/types.d.ts @@ -0,0 +1,48 @@ +export declare enum EnumMRZScanMode { + Passport = "passport", + TD1 = "td1", + TD2 = "td2", + PassportAndTD1 = "passportAndTd1", + PassportAndTD2 = "passportAndTd2", + TD1AndTD2 = "td1AndTd2", + All = "all" +} +export declare enum EnumMRZDocumentType { + Passport = "passport", + TD1 = "td1", + TD2 = "td2" +} +export declare enum EnumMRZScannerViews { + Scanner = "scanner", + Result = "scan-result" +} +export declare const DEFAULT_TEMPLATE_NAMES: { + passport: string; + td1: string; + td2: string; + passportAndTd1: string; + passportAndTd2: string; + td1AndTd2: string; + all: string; +}; +export type UtilizedTemplateNames = Record; +export declare enum EnumResultStatus { + RS_SUCCESS = 0, + RS_CANCELLED = 1, + RS_FAILED = 2 +} +export type ResultStatus = { + code: EnumResultStatus; + message?: string; +}; +export type ToolbarButtonConfig = Pick; +export interface ToolbarButton { + id: string; + icon: string; + label: string; + onClick?: () => void | Promise; + className?: string; + isDisabled?: boolean; + isHidden?: boolean; +} +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/dist/types/views/utils/types.d.ts.map b/dist/types/views/utils/types.d.ts.map new file mode 100644 index 0000000..a894a31 --- /dev/null +++ b/dist/types/views/utils/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/views/utils/types.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,QAAQ,aAAa;IACrB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,SAAS,cAAc;IACvB,GAAG,QAAQ;CACZ;AAED,oBAAY,mBAAmB;IAC7B,QAAQ,aAAa;IACrB,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,oBAAY,mBAAmB;IAC7B,OAAO,YAAY;IACnB,MAAM,gBAAgB;CACvB;AAED,eAAO,MAAM,sBAAsB;;;;;;;;CAQlC,CAAC;AAGF,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAEpE,oBAAY,gBAAgB;IAC1B,UAAU,IAAI;IACd,YAAY,IAAI;IAChB,SAAS,IAAI;CACd;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,CAAC,CAAC;AAEnG,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..805f9e9 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1742 @@ +{ + "name": "dynamsoft-mrz-scanner", + "version": "3.0.0-beta-202506160001", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "dynamsoft-mrz-scanner", + "version": "3.0.0-beta-202506160001", + "license": "SEE LICENSE IN LICENSE", + "dependencies": { + "dynamsoft-capture-vision-bundle": "3.0.3001", + "dynamsoft-capture-vision-data": "1.0.1" + }, + "devDependencies": { + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.6", + "@types/node": "^20.11.6", + "cors": "^2.8.5", + "express": "^4.21.2", + "formidable": "^3.5.2", + "rollup": "^4.9.5", + "rollup-plugin-dts": "^6.1.1", + "tslib": "^2.6.2", + "typescript": "^5.3.3" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz", + "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.25.9", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz", + "integrity": "sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "15.3.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.3.1.tgz", + "integrity": "sha512-tgg6b91pAybXHJQMAAwW9VuWBO6Thi+q7BCNARLwSqlmsHz0XYURtGvh/AuwSADXSI4h/2uHbs7s4FzlZDGSGA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-terser": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz", + "integrity": "sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==", + "dev": true, + "dependencies": { + "serialize-javascript": "^6.0.1", + "smob": "^1.0.0", + "terser": "^5.17.4" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-typescript": { + "version": "11.1.6", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.1.6.tgz", + "integrity": "sha512-R92yOmIACgYdJ7dJ97p4K69I8gg6IEHt8M7dUBxN3W6nrO8uUxX5ixl0yU/N3aZTi8WhPuICvOHXQvF6FaykAA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.1.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.14.0||^3.0.0||^4.0.0", + "tslib": "*", + "typescript": ">=3.7.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + }, + "tslib": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.4.tgz", + "integrity": "sha512-USm05zrsFxYLPdWWq+K3STlWiT/3ELn3RcV5hJMghpeAIhxfsUIg6mt12CBJBInWMV4VneoV7SfGv8xIwo2qNQ==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.28.1.tgz", + "integrity": "sha512-2aZp8AES04KI2dy3Ss6/MDjXbwBzj+i0GqKtWXgw2/Ma6E4jJvujryO6gJAghIRVz7Vwr9Gtl/8na3nDUKpraQ==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.28.1.tgz", + "integrity": "sha512-EbkK285O+1YMrg57xVA+Dp0tDBRB93/BZKph9XhMjezf6F4TpYjaUSuPt5J0fZXlSag0LmZAsTmdGGqPp4pQFA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.28.1.tgz", + "integrity": "sha512-prduvrMKU6NzMq6nxzQw445zXgaDBbMQvmKSJaxpaZ5R1QDM8w+eGxo6Y/jhT/cLoCvnZI42oEqf9KQNYz1fqQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.28.1.tgz", + "integrity": "sha512-WsvbOunsUk0wccO/TV4o7IKgloJ942hVFK1CLatwv6TJspcCZb9umQkPdvB7FihmdxgaKR5JyxDjWpCOp4uZlQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.28.1.tgz", + "integrity": "sha512-HTDPdY1caUcU4qK23FeeGxCdJF64cKkqajU0iBnTVxS8F7H/7BewvYoG+va1KPSL63kQ1PGNyiwKOfReavzvNA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.28.1.tgz", + "integrity": "sha512-m/uYasxkUevcFTeRSM9TeLyPe2QDuqtjkeoTpP9SW0XxUWfcYrGDMkO/m2tTw+4NMAF9P2fU3Mw4ahNvo7QmsQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.28.1.tgz", + "integrity": "sha512-QAg11ZIt6mcmzpNE6JZBpKfJaKkqTm1A9+y9O+frdZJEuhQxiugM05gnCWiANHj4RmbgeVJpTdmKRmH/a+0QbA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.28.1.tgz", + "integrity": "sha512-dRP9PEBfolq1dmMcFqbEPSd9VlRuVWEGSmbxVEfiq2cs2jlZAl0YNxFzAQS2OrQmsLBLAATDMb3Z6MFv5vOcXg==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.28.1.tgz", + "integrity": "sha512-uGr8khxO+CKT4XU8ZUH1TTEUtlktK6Kgtv0+6bIFSeiSlnGJHG1tSFSjm41uQ9sAO/5ULx9mWOz70jYLyv1QkA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.28.1.tgz", + "integrity": "sha512-QF54q8MYGAqMLrX2t7tNpi01nvq5RI59UBNx+3+37zoKX5KViPo/gk2QLhsuqok05sSCRluj0D00LzCwBikb0A==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.28.1.tgz", + "integrity": "sha512-vPul4uodvWvLhRco2w0GcyZcdyBfpfDRgNKU+p35AWEbJ/HPs1tOUrkSueVbBS0RQHAf/A+nNtDpvw95PeVKOA==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.28.1.tgz", + "integrity": "sha512-pTnTdBuC2+pt1Rmm2SV7JWRqzhYpEILML4PKODqLz+C7Ou2apEV52h19CR7es+u04KlqplggmN9sqZlekg3R1A==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.28.1.tgz", + "integrity": "sha512-vWXy1Nfg7TPBSuAncfInmAI/WZDd5vOklyLJDdIRKABcZWojNDY0NJwruY2AcnCLnRJKSaBgf/GiJfauu8cQZA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.28.1.tgz", + "integrity": "sha512-/yqC2Y53oZjb0yz8PVuGOQQNOTwxcizudunl/tFs1aLvObTclTwZ0JhXF2XcPT/zuaymemCDSuuUPXJJyqeDOg==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.28.1.tgz", + "integrity": "sha512-fzgeABz7rrAlKYB0y2kSEiURrI0691CSL0+KXwKwhxvj92VULEDQLpBYLHpF49MSiPG4sq5CK3qHMnb9tlCjBw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.28.1.tgz", + "integrity": "sha512-xQTDVzSGiMlSshpJCtudbWyRfLaNiVPXt1WgdWTwWz9n0U12cI2ZVtWe/Jgwyv/6wjL7b66uu61Vg0POWVfz4g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.28.1.tgz", + "integrity": "sha512-wSXmDRVupJstFP7elGMgv+2HqXelQhuNf+IS4V+nUpNVi/GUiBgDmfwD0UGN3pcAnWsgKG3I52wMOBnk1VHr/A==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.28.1.tgz", + "integrity": "sha512-ZkyTJ/9vkgrE/Rk9vhMXhf8l9D+eAhbAVbsGsXKy2ohmJaWg0LPQLnIxRdRp/bKyr8tXuPlXhIoGlEB5XpJnGA==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.28.1.tgz", + "integrity": "sha512-ZvK2jBafvttJjoIdKm/Q/Bh7IJ1Ose9IBOwpOXcOvW3ikGTQGmKDgxTC6oCAzW6PynbkKP8+um1du81XJHZ0JA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/estree": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true + }, + "node_modules/@types/node": { + "version": "20.17.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.10.tgz", + "integrity": "sha512-/jrvh5h6NXhEauFFexRin69nA0uHJ5gwk4iDivp/DeoEua3uwCUto6PC86IpRITBOs4+6i2I56K5x5b6WYGXHA==", + "dev": true, + "dependencies": { + "undici-types": "~6.19.2" + } + }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/acorn": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", + "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", + "dev": true + }, + "node_modules/body-parser": { + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", + "dev": true, + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.13.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.1.tgz", + "integrity": "sha512-BhYE+WDaywFg2TBWYNXAE+8B1ATnThNBqXHP5nQu0jWJdVvY2hvkpyB3qOmtmDePiS5/BDQ8wASEWGMWRG148g==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.3.tgz", + "integrity": "sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dezalgo": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", + "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", + "dev": true, + "dependencies": { + "asap": "^2.0.0", + "wrappy": "1" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/dynamsoft-capture-vision-bundle": { + "version": "3.0.3001", + "resolved": "https://registry.npmjs.org/dynamsoft-capture-vision-bundle/-/dynamsoft-capture-vision-bundle-3.0.3001.tgz", + "integrity": "sha512-KwjJuM4LfRbq7QnIYqKwR7aQVF7H9NYRN06/azOGGkVjCLLF9V/B0kjaxVd+6wCwIWJSjUE9M7nwNmO8yfXT2A==" + }, + "node_modules/dynamsoft-capture-vision-data": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dynamsoft-capture-vision-data/-/dynamsoft-capture-vision-data-1.0.1.tgz", + "integrity": "sha512-qZDhSVD9r1XSrDl6alDZ+ocn+gmO3hCjMtzYnwEB9O/Y2TgpthHsDA7tuD1Gcfk+fycfSoI8eW3w0LcelzJFRw==" + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "dev": true, + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", + "integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "dev": true, + "license": "MIT" + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.3", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.7.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.3.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.12", + "proxy-addr": "~2.0.7", + "qs": "6.13.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.19.0", + "serve-static": "1.16.2", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/formidable": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-3.5.2.tgz", + "integrity": "sha512-Jqc1btCy3QzRbJaICGwKcBfGWuLADRerLzDqi2NwSt/UkXLsHJw2TVResiaoBufHVHy9aSgClOHCeJsSsFLTbg==", + "dev": true, + "dependencies": { + "dezalgo": "^1.0.4", + "hexoid": "^2.0.0", + "once": "^1.4.0" + }, + "funding": { + "url": "https://ko-fi.com/tunnckoCore/commissions" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.7.tgz", + "integrity": "sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "function-bind": "^1.1.2", + "get-proto": "^1.0.0", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hexoid": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-2.0.0.tgz", + "integrity": "sha512-qlspKUK7IlSQv2o+5I7yhUd7TxlOG2Vr5LTa3ve2XSNVKAL/n/u/7KLvKmFNimomDIKvZFXWHv0T12mv7rT8Aw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-core-module": { + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.0.tgz", + "integrity": "sha512-urTSINYfAYgcbLb0yDQ6egFm6h3Mo1DcF9EkyXSRjjzdHbsulg01qhwWuXdOoUBuTkbQ80KDboXa0vFJ+BDH+g==", + "dev": true, + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/magic-string": { + "version": "0.30.17", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", + "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true, + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true, + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz", + "integrity": "sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/path-to-regexp": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC", + "optional": true + }, + "node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/resolve": { + "version": "1.22.9", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.9.tgz", + "integrity": "sha512-QxrmX1DzraFIi9PxdG5VkRfRwIgjwyud+z/iBwfRRrVmHc+P9Q7u2lSSpQ6bjr2gy5lrqIiU9vb6iAeGf2400A==", + "dev": true, + "dependencies": { + "is-core-module": "^2.16.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/rollup": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.28.1.tgz", + "integrity": "sha512-61fXYl/qNVinKmGSTHAZ6Yy8I3YIJC/r2m9feHo6SwVAVcLT5MPwOUFe7EuURA/4m0NR8lXG4BBXuo/IZEsjMg==", + "dev": true, + "dependencies": { + "@types/estree": "1.0.6" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.28.1", + "@rollup/rollup-android-arm64": "4.28.1", + "@rollup/rollup-darwin-arm64": "4.28.1", + "@rollup/rollup-darwin-x64": "4.28.1", + "@rollup/rollup-freebsd-arm64": "4.28.1", + "@rollup/rollup-freebsd-x64": "4.28.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.28.1", + "@rollup/rollup-linux-arm-musleabihf": "4.28.1", + "@rollup/rollup-linux-arm64-gnu": "4.28.1", + "@rollup/rollup-linux-arm64-musl": "4.28.1", + "@rollup/rollup-linux-loongarch64-gnu": "4.28.1", + "@rollup/rollup-linux-powerpc64le-gnu": "4.28.1", + "@rollup/rollup-linux-riscv64-gnu": "4.28.1", + "@rollup/rollup-linux-s390x-gnu": "4.28.1", + "@rollup/rollup-linux-x64-gnu": "4.28.1", + "@rollup/rollup-linux-x64-musl": "4.28.1", + "@rollup/rollup-win32-arm64-msvc": "4.28.1", + "@rollup/rollup-win32-ia32-msvc": "4.28.1", + "@rollup/rollup-win32-x64-msvc": "4.28.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/rollup-plugin-dts": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-6.1.1.tgz", + "integrity": "sha512-aSHRcJ6KG2IHIioYlvAOcEq6U99sVtqDDKVhnwt70rW6tsz3tv5OSjEiWcgzfsHdLyGXZ/3b/7b/+Za3Y6r1XA==", + "dev": true, + "license": "LGPL-3.0-only", + "dependencies": { + "magic-string": "^0.30.10" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/Swatinem" + }, + "optionalDependencies": { + "@babel/code-frame": "^7.24.2" + }, + "peerDependencies": { + "rollup": "^3.29.4 || ^4", + "typescript": "^4.5 || ^5.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "license": "MIT" + }, + "node_modules/send": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/serve-static": { + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.19.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true, + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/smob": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/smob/-/smob-1.5.0.tgz", + "integrity": "sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig==", + "dev": true + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/terser": { + "version": "5.37.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.37.0.tgz", + "integrity": "sha512-B8wRRkmre4ERucLM/uXx4MOV5cbnOlVAqUst+1+iLKPI0dOgFO28f84ptoQt9HEI537PMzfYa/d+GEPKTRXmYA==", + "dev": true, + "dependencies": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.8.2", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + } + } +} diff --git a/package.json b/package.json index 22eada6..2016ec7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dynamsoft-mrz-scanner", - "version": "2.1.0", + "version": "3.0.0-beta-202506160001", "description": "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.", "files": [ "/dist", @@ -31,15 +31,11 @@ "url": "git+https://github.com/Dynamsoft/mrz-scanner-javascript" }, "keywords": [ - "document scanning", + "passport scanning", "js", - "javascript", - "dynamsoft", "mrz", - "scanner", - "ui", - "camera", - "vision" + "passport", + "javascript" ], "author": { "name": "Dynamsoft", @@ -67,8 +63,7 @@ "formidable": "^3.5.2" }, "dependencies": { - "dynamsoft-capture-vision-bundle": "2.6.1000", - "dynamsoft-capture-vision-std": "1.4.21", - "dynamsoft-image-processing": "2.4.31" + "dynamsoft-capture-vision-bundle": "3.0.3001", + "dynamsoft-capture-vision-data": "1.0.1" } } diff --git a/rollup.config.mjs b/rollup.config.mjs index 035079d..f4074a6 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -40,38 +40,28 @@ const banner = `/*! const plugin_terser_es6 = terser({ ecma: 6, format: terser_format }); const plugin_terser_es5 = terser({ ecma: 5, format: terser_format }); +const DCV_CONFIG_PATH = `src/dcv-config`; +const BUNDLE_BUILD_PATH = `src/build`; +const TYPES_PATH = "dist/types/build"; + const copyFiles = () => ({ name: "copy-files", writeBundle() { - fs.copyFileSync("src/mrz-scanner.ui.html", "dist/mrz-scanner.ui.html"); - fs.copyFileSync("src/mrz-scanner.template.json", "dist/mrz-scanner.template.json"); + fs.copyFileSync(`${DCV_CONFIG_PATH}/mrz-scanner.ui.html`, "dist/mrz-scanner.ui.html"); + fs.copyFileSync(`${DCV_CONFIG_PATH}/mrz-scanner.template.json`, "dist/mrz-scanner.template.json"); }, }); -const external = [ - "dynamsoft-core", - "dynamsoft-license", - "dynamsoft-capture-vision-router", - "dynamsoft-camera-enhancer", - "dynamsoft-code-parser", - "dynamsoft-label-recognizer", - "dynamsoft-utility", -]; +const external = ["dynamsoft-capture-vision-bundle"]; const globals = { - "dynamsoft-core": "Dynamsoft.Core", - "dynamsoft-license": "Dynamsoft.License", - "dynamsoft-capture-vision-router": "Dynamsoft.CVR", - "dynamsoft-camera-enhancer": "Dynamsoft.DCE", - "dynamsoft-code-parser": "Dynamsoft.DCP", - "dynamsoft-label-recognizer": "Dynamsoft.DLR", - "dynamsoft-utility": "Dynamsoft.Utility", + "dynamsoft-capture-vision-bundle": "Dynamsoft", }; export default [ // 1. Full bundle { - input: "src/mrz-scanner.bundle.ts", + input: `${BUNDLE_BUILD_PATH}/mrz-scanner.bundle.ts`, plugins: [ nodeResolve({ browser: true }), typescript({ @@ -103,7 +93,7 @@ export default [ }, // 2. Standard UMD bundle { - input: "src/mrz-scanner.ts", + input: `${BUNDLE_BUILD_PATH}/mrz-scanner.ts`, external, plugins: [ typescript({ @@ -128,7 +118,7 @@ export default [ }, // 3. ESM bundle { - input: "src/mrz-scanner.bundle.esm.ts", + input: `${BUNDLE_BUILD_PATH}/mrz-scanner.bundle.esm.ts`, plugins: [ nodeResolve({ browser: true }), typescript({ @@ -150,7 +140,7 @@ export default [ }, // 4. ESM with externals { - input: "src/mrz-scanner.ts", + input: `${BUNDLE_BUILD_PATH}/mrz-scanner.ts`, external, plugins: [ typescript({ @@ -171,7 +161,7 @@ export default [ }, // 5. No-content ESM { - input: "src/mrz-scanner.no-content-bundle.esm.ts", + input: `${BUNDLE_BUILD_PATH}/mrz-scanner.no-content-bundle.esm.ts`, external, plugins: [ typescript({ @@ -192,7 +182,7 @@ export default [ }, // 6. Type declarations for CommonJS/UMD { - input: "src/mrz-scanner.ts", + input: `${BUNDLE_BUILD_PATH}/mrz-scanner.ts`, external, plugins: [ dts(), @@ -212,13 +202,13 @@ export default [ }, // 7. Type declarations for ESM { - input: "dist/types/mrz-scanner.bundle.esm.d.ts", + input: `${TYPES_PATH}/mrz-scanner.bundle.esm.d.ts`, plugins: [ dts(), { // https://rollupjs.org/guide/en/#writebundle writeBundle(options, bundle) { - fs.rmSync("dist/types", { recursive: true, force: true }); + fs.rmSync(TYPES_PATH, { recursive: true, force: true }); // change `export { type A }` to `export { A }`, // so project use old typescript still works. let txt = fs diff --git a/samples/demo/assets/mrz-scanner-qr-code.svg b/samples/demo/assets/mrz-scanner-qr-code.svg index 28abf6e..a714719 100644 --- a/samples/demo/assets/mrz-scanner-qr-code.svg +++ b/samples/demo/assets/mrz-scanner-qr-code.svg @@ -1,22 +1,14 @@ - - - - + + + - - - - - - - - \ No newline at end of file + H219.4z M234.1,241.4v7.3h7.3v-7.3H234.1z"/> + + + + + + + + diff --git a/samples/demo/index.html b/samples/demo/index.html index 478ded8..b14e3ee 100644 --- a/samples/demo/index.html +++ b/samples/demo/index.html @@ -5,7 +5,7 @@ Dynamsoft MRZ Scanner - + diff --git a/samples/dwt-mrz/README.md b/samples/dwt-mrz/README.md deleted file mode 100644 index 67ca0f5..0000000 --- a/samples/dwt-mrz/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Using the MRZ Scanner (JavaScript Edition) with Dynamic Web TWAIN - -This sample provides a way to use the MRZ Scanner solution with Dynamic Web TWAIN to allow the user to scan MRZ images via a physical scanner or via one of the different image input methods that Web TWAIN allows. - -To learn more about Dynamic Web TWAIN, feel free to explore the SDK on this [page](https://www.dynamsoft.com/web-twain/overview/). - -## Prerequisites - -To get started with this sample, there is not much that you need except for a license key for both Dynamic Web TWAIN and the MRZ Scanner. - -To get a 30-day trial license for the MRZ Scanner, please visit this [page](https://www.dynamsoft.com/customer/license/trialLicense/thank-you/?product=mrz&deploymenttype=web). The license that is currently used for the MRZ Scanner is a temporary 24-hour public trial license (which is set in the `index.html` file). Please replace this public trial license (`YOUR_LICENSE_KEY_HERE`) with your working trial license. - -To get a 30-day trial license for Dynamic Web TWAIN, please visit this [page](https://www.dynamsoft.com/customer/license/trialLicense/thank-you/?product=dwt&deploymenttype=web). There is no license that is currently set in the `Resources/dynamsoft.webtwain.config.js` file. Please replace `YOUR_DWT_LICENSE_KEY` with your working trial license. - -If you would like to take a deep dive into the implementation of these two products together, please read this [article](https://www.dynamsoft.com/web-twain/docs/indepth/development/mrz.html). - -## Conclusion - -It is best to host this sample on your own server with an HTTPS connection. If you are using VS Code, a quick and easy way to serve the project is using the Live Server (Five Server) VSCode extension. Simply install the extension, open the hello-world.html file in the editor, and click “Go Live” in the bottom right corner of the editor. This will serve the application at http://127.0.0.1:5500/hello-world.html. Alternatively, you can also use IIS or Github Pages to quickly serve your application. - -If you have any questions, do not hesitate to get in touch with the [Dynamsoft Support](https://www.dynamsoft.com/contact/) team. \ No newline at end of file diff --git a/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup-arm64.deb b/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup-arm64.deb deleted file mode 100644 index cc8daf4..0000000 Binary files a/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup-arm64.deb and /dev/null differ diff --git a/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.deb b/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.deb deleted file mode 100644 index 39cc9fa..0000000 Binary files a/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.deb and /dev/null differ diff --git a/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.msi b/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.msi deleted file mode 100644 index f5ece28..0000000 Binary files a/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.msi and /dev/null differ diff --git a/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.pkg b/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.pkg deleted file mode 100644 index 60787ad..0000000 Binary files a/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.pkg and /dev/null differ diff --git a/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.rpm b/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.rpm deleted file mode 100644 index a7b7c58..0000000 Binary files a/samples/dwt-mrz/Resources/dist/DynamicWebTWAINServiceSetup.rpm and /dev/null differ diff --git a/samples/dwt-mrz/Resources/dist/LICENSE b/samples/dwt-mrz/Resources/dist/LICENSE deleted file mode 100644 index 92435df..0000000 --- a/samples/dwt-mrz/Resources/dist/LICENSE +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ------------------------------------------------------------------------- - -Copyright jQuery Foundation and other contributors, https://jquery.org/ - -This software consists of voluntary contributions made by many -individuals. For exact contribution history, see the revision history -available at https://github.com/jquery/sizzle - -The following license applies to all parts of this software except as -documented below: - -==== - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -==== - -All files located in the node_modules and external directories are -externally maintained libraries used by this software which have their -own licenses; we recommend you read them, as their terms may differ from -the terms above. - ------------------------------------------------------------------------- - -bluebird js -URL: https://github.com/petkaantonov/bluebird/ - -The MIT License (MIT) - -Copyright (c) 2013-2020 Petka Antonov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - -Copyright (c) ViliusL -https://github.com/viliusle -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/samples/dwt-mrz/Resources/dynamsoft.webtwain.config.js b/samples/dwt-mrz/Resources/dynamsoft.webtwain.config.js deleted file mode 100644 index 763ecff..0000000 --- a/samples/dwt-mrz/Resources/dynamsoft.webtwain.config.js +++ /dev/null @@ -1,136 +0,0 @@ -// -// Dynamsoft JavaScript Library for Basic Initiation of Dynamic Web TWAIN -// More info on Dynamic Web TWAIN: http://www.dynamsoft.com/Products/WebTWAIN_Overview.aspx -// -// Copyright 2025, Dynamsoft Corporation -// Author: Dynamsoft Team -// Version: 19.0 -// -/// -var Dynamsoft = Dynamsoft || { DWT: {} }; - -/// -Dynamsoft.DWT.AutoLoad = true; -/// -Dynamsoft.DWT.Containers = [{ WebTwainId: "", ContainerId: "dwtcontrolContainer", Width: 350, Height: 380 }]; - -///////////////////////////////////////////////////////////////////////////////////// -// WARNING: The productKey in this file is protected by copyright law // -// and international treaty provisions. Unauthorized reproduction or // -// distribution of this productKey, or any portion of it, may result in severe // -// criminal and civil penalties, and will be prosecuted to the maximum // -// extent possible under the law. Further, you may not reverse engineer, // -// decompile, disassemble, or modify the productKey . // -///////////////////////////////////////////////////////////////////////////////////// -/// If you need to use multiple keys on the same server, you can combine keys and write like this -/// Dynamsoft.DWT.ProductKey = 'key1;key2;key3'; -/// To get a free trial, please visit https://www.dynamsoft.com/customer/license/trialLicense?product=dwt&utm_source=installer. -Dynamsoft.DWT.ProductKey = "YOUR_DWT_LICENSE_KEY"; - -/// -//Dynamsoft.DWT.ResourcesPath = 'Resources'; - -/// -Dynamsoft.DWT.IfAddMD5InUploadHeader = false; - -/// -///true will make our processing icons align with the initiated div container, otherwise align with the whole page instead -Dynamsoft.DWT.IfConfineMaskWithinTheViewer = true; -/*Dynamsoft.DWT.CustomizableDisplayInfo = { - - errorMessages: { - - // launch - ERR_MODULE_NOT_INSTALLED: 'Error: The Dynamic Web TWAIN module is not installed.', - ERR_BROWSER_NOT_SUPPORT: 'Error: This browser is currently not supported.', - ERR_CreateID_MustNotInContainers: 'Error: Duplicate ID detected for creating Dynamic Web TWAIN objects, please check and modify.', - ERR_CreateID_NotContainer: 'Error: The ID of the DIV for creating the new DWT object is invalid.', - ERR_DWT_NOT_DOWNLOADED: 'Error: Failed to download the Dynamic Web TWAIN module.', - - // image view - limitReachedForZoomIn: "Error: You have reached the limit for zooming in", - limitReachedForZoomOut: "Error: You have reached the limit for zooming out", - - // image editor - insufficientParas: 'Error: Not enough parameters.', - invalidAngle: 'Error: The angle you entered is invalid.', - invalidHeightOrWidth: "Error: The height or width you entered is invalid.", - imageNotChanged: "Error: You have not changed the current image." - - }, - - // launch - generalMessages: { - checkingDWTVersion: 'Checking WebTwain version ...', - updatingDService: 'Dynamic Web TWAIN Service is updating ...', - downloadingDWTModule: 'Downloading the Dynamic Web TWAIN module.', - refreshNeeded: 'Please REFRESH your browser.', - downloadNeeded: 'Please download and install the Dynamic Web TWAIN.', - DWTmoduleLoaded: 'The Dynamic Web TWAIN module is loaded.' - }, - - customProgressText: { - - // html5 event - upload: 'Uploading...', - download: 'Downloading...', - load: 'Loading...', - decode: 'Processing...', - decodeTIFF: 'Processing tiff...', - decodePDF: 'Processing pdf...', - encode: 'Processing...', - encodeTIFF: 'Processing tiff...', - encodePDF: 'Processing pdf...', - - transfer: 'Transferring...', - // image control - canvasLoading: 'Loading ...' - }, - - // image editor - buttons: { - titles: { - 'previous': 'Previous Image', - 'next': 'Next Image', - 'print': 'Print Image', - 'scan': 'Acquire new Image(s)', - 'load': 'Load local Image(s)', - 'rotateleft': 'Rotate Left', - 'rotate': 'Rotate', - 'rotateright': 'Rotate Right', - 'deskew': 'Deskew', - 'crop': 'Crop Selected Area', - 'cut': 'Cut Selected Area', - 'changeimagesize': 'Change Image Size', - 'flip': 'Flip Image', - 'mirror': 'Mirror Image', - 'zoomin': 'Zoom In', - 'originalsize': 'Show Original Size', - 'zoomout': 'Zoom Out', - 'stretch': 'Stretch Mode', - 'fit': 'Fit Window', - 'fitw': 'Fit Horizontally', - 'fith': 'Fit Vertically', - 'hand': 'Hand Mode', - 'rectselect': 'Select Mode', - 'zoom': 'Click to Zoom In', - 'restore': 'Restore Orginal Image', - 'save': 'Save Changes', - 'close': 'Close the Editor', - 'removeall': 'Remove All Images', - 'removeselected': 'Remove All Selected Images' - } - }, - - dialogText: { - dlgRotateAnyAngle: ['Angle :', 'Interpolation:', 'Keep size', ' OK ', 'Cancel'], - dlgChangeImageSize: ['New Height :', 'New Width :', 'Interpolation:', ' OK ', 'Cancel'], - saveChangedImage: ['You have changed the image, do you want to keep the change(s)?', ' Yes ', ' No '], - selectSource: ['Select Source:', 'Select', 'Cancel', 'There is no source available!'] - } -};*/ - -/// All callbacks are defined in the dynamsoft.webtwain.install.js file, you can customize them. -// Dynamsoft.DWT.RegisterEvent('OnWebTwainReady', function(){ -// // webtwain has been inited -// }); diff --git a/samples/dwt-mrz/Resources/dynamsoft.webtwain.initiate.js b/samples/dwt-mrz/Resources/dynamsoft.webtwain.initiate.js deleted file mode 100644 index 307611b..0000000 --- a/samples/dwt-mrz/Resources/dynamsoft.webtwain.initiate.js +++ /dev/null @@ -1,53 +0,0 @@ -/*! 20250331150258 - 20230504 -* Dynamsoft JavaScript Library -* Product: Dynamic Web TWAIN -* Web Site: https://www.dynamsoft.com -* -* Copyright 2025, Dynamsoft Corporation -* Author: Dynamsoft Support Team -* Version: 19.0 -*/ -var _gThis=(function(){if(typeof globalThis!=='undefined')return globalThis;if(typeof self!=='undefined')return self;if(typeof window!=='undefined')return window;if(typeof global!=='undefined')return global;return {}})(),Dynamsoft=_gThis.Dynamsoft||{}; -(function(b){if(!b.DWT){b.DWT={}}if(!b.DWT.LTS){b.DWT.LTS={}}if(!b.Lib){b.Lib={}}if(!b.Lib.UI){b.Lib.UI={}}if(!b.Lib.html5){b.Lib.html5={}}_gThis.Dynamsoft=b})(Dynamsoft); -(function(e){if(!e.WeakSet){e.WeakSet=b;var c=Date.now()%1E9;function b(a){this.name="__st"+(1E9*Math.random()>>>0)+(c++ +"__");a&&a.forEach&&a.forEach(this.add,this)}var z=b.prototype;z.add=function(a){var d=this.name;a[d]||Object.defineProperty(a,d,{value:!0,writable:!0});return this};z["delete"]=function(a){if(!a[this.name])return!1;a[this.name]=void 0;return!0};z.has=function(a){return!!a[this.name]};} -if(!e.WeakMap){var r=Object.prototype.hasOwnProperty;var n=Object.defineProperty&&function(){try{return Object.defineProperty({},"x",{value:1}).x===1}catch(e){}}();var i=function(e,t,r){if(n){Object.defineProperty(e,t,{configurable:true,writable:true,value:r})}else{e[t]=r}};e.WeakMap=function(){function WeakMap(){if(this===void 0){throw new TypeError("Constructor WeakMap requires 'new'")}i(this,"_id",genId("_WeakMap"));if(arguments.length>0){throw new TypeError("WeakMap iterable is not supported")}}i(WeakMap.prototype,"delete",function(e){checkInstance(this,"delete");if(!isObject(e)){return false}var t=e[this._id];if(t&&t[0]===e){delete e[this._id];return true}return false});i(WeakMap.prototype,"get",function(e){checkInstance(this,"get");if(!isObject(e)){return void 0}var t=e[this._id];if(t&&t[0]===e){return t[1]}return void 0});i(WeakMap.prototype,"has",function(e){checkInstance(this,"has");if(!isObject(e)){return false}var t=e[this._id];if(t&&t[0]===e){return true}return false});i(WeakMap.prototype,"set",function(e,t){checkInstance(this,"set");if(!isObject(e)){throw new TypeError("Invalid value used as weak map key")}var r=e[this._id];if(r&&r[0]===e){r[1]=t;return this}i(e,this._id,[e,t]);return this});function checkInstance(e,t){if(!isObject(e)||!r.call(e,"_id")){throw new TypeError(t+" method called on incompatible receiver "+typeof e)}}function genId(e){return e+"_"+rand()+"."+rand()}function rand(){return Math.random().toString().substring(2)}i(WeakMap,"_polyfill",true);return WeakMap}();function isObject(e){return Object(e)===e}}})(_gThis); - -if(!Dynamsoft.Lib.jsinited){Dynamsoft.Lib.jsinited=1; -(function(factory){if(typeof exports==="object"){module.exports=factory()}else if(typeof define==="function"&&define.amd){define(factory)}else{var glob;try{glob=window}catch(e){glob=self}glob.SparkMD5=factory()}})(function(undefined){"use strict";var add32=function(a,b){return a+b&4294967295},hex_chr=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function cmn(q,a,b,x,s,t){a=add32(add32(a,q),add32(x,t));return add32(a<>>32-s,b)}function md5cycle(x,k){var a=x[0],b=x[1],c=x[2],d=x[3];a+=(b&c|~b&d)+k[0]-680876936|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[1]-389564586|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[2]+606105819|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[3]-1044525330|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[4]-176418897|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[5]+1200080426|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[6]-1473231341|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[7]-45705983|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[8]+1770035416|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[9]-1958414417|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[10]-42063|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[11]-1990404162|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[12]+1804603682|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[13]-40341101|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[14]-1502002290|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[15]+1236535329|0;b=(b<<22|b>>>10)+c|0;a+=(b&d|c&~d)+k[1]-165796510|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[6]-1069501632|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[11]+643717713|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[0]-373897302|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[5]-701558691|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[10]+38016083|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[15]-660478335|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[4]-405537848|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[9]+568446438|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[14]-1019803690|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[3]-187363961|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[8]+1163531501|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[13]-1444681467|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[2]-51403784|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[7]+1735328473|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[12]-1926607734|0;b=(b<<20|b>>>12)+c|0;a+=(b^c^d)+k[5]-378558|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[8]-2022574463|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[11]+1839030562|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[14]-35309556|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[1]-1530992060|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[4]+1272893353|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[7]-155497632|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[10]-1094730640|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[13]+681279174|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[0]-358537222|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[3]-722521979|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[6]+76029189|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[9]-640364487|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[12]-421815835|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[15]+530742520|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[2]-995338651|0;b=(b<<23|b>>>9)+c|0;a+=(c^(b|~d))+k[0]-198630844|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[7]+1126891415|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[14]-1416354905|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[5]-57434055|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[12]+1700485571|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[3]-1894986606|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[10]-1051523|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[1]-2054922799|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[8]+1873313359|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[15]-30611744|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[6]-1560198380|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[13]+1309151649|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[4]-145523070|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[11]-1120210379|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[2]+718787259|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[9]-343485551|0;b=(b<<21|b>>>11)+c|0;x[0]=a+x[0]|0;x[1]=b+x[1]|0;x[2]=c+x[2]|0;x[3]=d+x[3]|0}function md5blk(s){var md5blks=[],i;for(i=0;i<64;i+=4){md5blks[i>>2]=s.charCodeAt(i)+(s.charCodeAt(i+1)<<8)+(s.charCodeAt(i+2)<<16)+(s.charCodeAt(i+3)<<24)}return md5blks}function md5blk_array(a){var md5blks=[],i;for(i=0;i<64;i+=4){md5blks[i>>2]=a[i]+(a[i+1]<<8)+(a[i+2]<<16)+(a[i+3]<<24)}return md5blks}function md51(s){var n=s.length,state=[1732584193,-271733879,-1732584194,271733878],i,length,tail,tmp,lo,hi;for(i=64;i<=n;i+=64){md5cycle(state,md5blk(s.substring(i-64,i)))}s=s.substring(i-64);length=s.length;tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i>2]|=s.charCodeAt(i)<<(i%4<<3)}tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(state,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=n*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(state,tail);return state}function md51_array(a){var n=a.length,state=[1732584193,-271733879,-1732584194,271733878],i,length,tail,tmp,lo,hi;for(i=64;i<=n;i+=64){md5cycle(state,md5blk_array(a.subarray(i-64,i)))}a=i-64>2]|=a[i]<<(i%4<<3)}tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(state,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=n*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(state,tail);return state}function rhex(n){var s="",j;for(j=0;j<4;j+=1){s+=hex_chr[n>>j*8+4&15]+hex_chr[n>>j*8&15]}return s}function hex(x){var i;for(i=0;i>16)+(y>>16)+(lsw>>16);return msw<<16|lsw&65535}}if(typeof ArrayBuffer!=="undefined"&&!ArrayBuffer.prototype.slice){(function(){function clamp(val,length){val=val|0||0;if(val<0){return Math.max(val+length,0)}return Math.min(val,length)}ArrayBuffer.prototype.slice=function(from,to){var length=this.byteLength,begin=clamp(from,length),end=length,num,target,targetArray,sourceArray;if(to!==undefined){end=clamp(to,length)}if(begin>end){return new ArrayBuffer(0)}num=end-begin;target=new ArrayBuffer(num);targetArray=new Uint8Array(target);sourceArray=new Uint8Array(this,begin,num);targetArray.set(sourceArray);return target}})()}function toUtf8(str){if(/[\u0080-\uFFFF]/.test(str)){str=unescape(encodeURIComponent(str))}return str}function utf8Str2ArrayBuffer(str,returnUInt8Array){var length=str.length,buff=new ArrayBuffer(length),arr=new Uint8Array(buff),i;for(i=0;i>2]|=buff.charCodeAt(i)<<(i%4<<3)}this._finish(tail,length);ret=hex(this._hash);if(raw){ret=hexToBinaryString(ret)}this.reset();return ret};SparkMD5.prototype.reset=function(){this._buff="";this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};SparkMD5.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}};SparkMD5.prototype.setState=function(state){this._buff=state.buff;this._length=state.length;this._hash=state.hash;return this};SparkMD5.prototype.destroy=function(){delete this._hash;delete this._buff;delete this._length};SparkMD5.prototype._finish=function(tail,length){var i=length,tmp,lo,hi;tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(this._hash,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=this._length*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(this._hash,tail)};SparkMD5.hash=function(str,raw){return SparkMD5.hashBinary(toUtf8(str),raw)};SparkMD5.hashBinary=function(content,raw){var hash=md51(content),ret=hex(hash);return raw?hexToBinaryString(ret):ret};SparkMD5.ArrayBuffer=function(){this.reset()};SparkMD5.ArrayBuffer.prototype.append=function(arr){var buff=concatenateArrayBuffers(this._buff.buffer,arr,true),length=buff.length,i;this._length+=arr.byteLength;for(i=64;i<=length;i+=64){md5cycle(this._hash,md5blk_array(buff.subarray(i-64,i)))}this._buff=i-64>2]|=buff[i]<<(i%4<<3)}this._finish(tail,length);ret=hex(this._hash);if(raw){ret=hexToBinaryString(ret)}this.reset();return ret};SparkMD5.ArrayBuffer.prototype.reset=function(){this._buff=new Uint8Array(0);this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};SparkMD5.ArrayBuffer.prototype.getState=function(){var state=SparkMD5.prototype.getState.call(this);state.buff=arrayBuffer2Utf8Str(state.buff);return state};SparkMD5.ArrayBuffer.prototype.setState=function(state){state.buff=utf8Str2ArrayBuffer(state.buff,true);return SparkMD5.prototype.setState.call(this,state)};SparkMD5.ArrayBuffer.prototype.destroy=SparkMD5.prototype.destroy;SparkMD5.ArrayBuffer.prototype._finish=SparkMD5.prototype._finish;SparkMD5.ArrayBuffer.hash=function(arr,raw){var hash=md51_array(new Uint8Array(arr)),ret=hex(hash);return raw?hexToBinaryString(ret):ret};return SparkMD5}); - -if(window && !window['Promise']){ -/* @preserve - * The MIT License (MIT) - * - * Copyright (c) 2013-2018 Petka Antonov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ -/** - * bluebird build version 3.7.2 - * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each -*/ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Promise=t()}}(function(){var t,e,n;return function r(t,e,n){function i(s,a){if(!e[s]){if(!t[s]){var c="function"==typeof _dereq_&&_dereq_;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=e[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return i(n?n:e)},l,l.exports,r,t,e,n)}return e[s].exports}for(var o="function"==typeof _dereq_&&_dereq_,s=0;s0;)c(t)}function c(t){var e=t.shift();if("function"!=typeof e)e._settlePromises();else{var n=t.shift(),r=t.shift();e.call(n,r)}}var u;try{throw new Error}catch(l){u=l}var p=t("./schedule"),f=t("./queue");r.prototype.setScheduler=function(t){var e=this._schedule;return this._schedule=t,this._customScheduler=!0,e},r.prototype.hasCustomScheduler=function(){return this._customScheduler},r.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues},r.prototype.fatalError=function(t,e){e?(process.stderr.write("Fatal "+(t instanceof Error?t.stack:t)+"\n"),process.exit(2)):this.throwLater(t)},r.prototype.throwLater=function(t,e){if(1===arguments.length&&(e=t,t=function(){throw e}),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(n){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")}},r.prototype.invokeLater=i,r.prototype.invoke=o,r.prototype.settlePromises=s,r.prototype._drainQueues=function(){a(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,a(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=r,e.exports.firstLineError=u},{"./queue":26,"./schedule":29}],3:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var i=!1,o=function(t,e){this._reject(e)},s=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(o,o,null,this,t)},a=function(t,e){0===(50397184&this._bitField)&&this._resolveCallback(e.target)},c=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(o){i||(i=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var u=n(o),l=new t(e);l._propagateFrom(this,1);var p=this._target();if(l._setBoundTo(u),u instanceof t){var f={promiseRejectionQueued:!1,promise:l,target:p,bindingPromise:u};p._then(e,s,void 0,l,f),u._then(a,c,void 0,l,f),l._setOnCancel(u)}else l._resolveCallback(p);return l},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],4:[function(t,e,n){"use strict";function r(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise")();o.noConflict=r,e.exports=o},{"./promise":22}],5:[function(t,e,n){"use strict";var r=Object.create;if(r){var i=r(null),o=r(null);i[" size"]=o[" size"]=0}e.exports=function(e){function n(t,n){var r;if(null!=t&&(r=t[n]),"function"!=typeof r){var i="Object "+a.classString(t)+" has no method '"+a.toString(n)+"'";throw new e.TypeError(i)}return r}function r(t){var e=this.pop(),r=n(t,e);return r.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return 0>e&&(e=Math.max(0,e+t.length)),t[e]}var s,a=t("./util"),c=a.canEvaluate;a.isIdentifier;e.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(r,void 0,void 0,e,void 0)},e.prototype.get=function(t){var e,n="number"==typeof t;if(n)e=o;else if(c){var r=s(t);e=null!==r?r:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var o=t("./util"),s=o.tryCatch,a=o.errorObj,c=e._async;e.prototype["break"]=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t._isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n._isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),t._setWillBeCancelled(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),this._enoughBranchesHaveCancelled()?(this._invokeOnCancel(),!0):!1)},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),c.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var n=0;n=0?o[t]:void 0}var i=!1,o=[];return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},e.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},e.prototype._popContext=function(){if(void 0!==this._trace){var t=o.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},e.CapturedTrace=null,e.create=n,e.deactivateLongStackTraces=function(){},e.activateLongStackTraces=function(){var n=t.prototype._pushContext,o=t.prototype._popContext,s=t._peekContext,a=t.prototype._peekContext,c=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=o,t._peekContext=s,t.prototype._peekContext=a,t.prototype._promiseCreated=c,i=!1},i=!0,t.prototype._pushContext=e.prototype._pushContext,t.prototype._popContext=e.prototype._popContext,t._peekContext=t.prototype._peekContext=r,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},e}},{}],9:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){function o(t,e){return{promise:e}}function s(){return!1}function a(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+B.toString(t));r._attachCancellationCallback(t)})}catch(i){return i}}function c(t){if(!this._isCancellable())return this;var e=this._onCancel();void 0!==e?B.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function u(){return this._onCancelField}function l(t){this._onCancelField=t}function p(){this._cancellationParent=void 0,this._onCancelField=void 0}function f(t,e){if(0!==(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function h(t,e){0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function _(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t}function d(){this._trace=new V(this._peekContext())}function v(t,e){if(q(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=F(t);B.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),B.notEnumerableProp(t,"__stackCleaned__",!0)}}}function y(){this._trace=void 0}function g(t,e,n,r,i){if(void 0===t&&null!==e&&Z){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&r._bitField))return;n&&(n+=" ");var o="",s="";if(e._trace){for(var a=e._trace.stack.split("\n"),c=k(a),u=c.length-1;u>=0;--u){var l=c[u];if(!Q.test(l)){var p=l.match(G);p&&(o="at "+p[1]+":"+p[2]+":"+p[3]+" ");break}}if(c.length>0)for(var f=c[0],u=0;u0&&(s="\n"+a[u-1]);break}}var h="a promise was created in a "+n+"handler "+o+"but was not returned from it, see http://goo.gl/rRqMUw"+s;r._warn(h,!0,e)}}function m(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),b(n)}function b(t,n,r){if(lt.warnings){var i,o=new U(t);if(n)r._attachExtraTrace(o);else if(lt.longStackTraces&&(i=e._peekContext()))i.attachExtraTrace(o);else{var s=F(o);o.stack=s.message+"\n"+s.stack.join("\n")}ot("warning",o)||x(o,"",!0)}}function w(t,e){for(var n=0;n=0;--a)if(r[a]===o){s=a;break}for(var a=s;a>=0;--a){var c=r[a];if(e[i]!==c)break;e.pop(),i--}e=r}}function k(t){for(var e=[],n=0;n0&&"SyntaxError"!=t.name&&(e=e.slice(n)),e}function F(t){var e=t.stack,n=t.toString();return e="string"==typeof e&&e.length>0?E(t):[" (No stack trace)"],{message:n,stack:"SyntaxError"==t.name?e:k(e)}}function x(t,e,n){if("undefined"!=typeof console){var r;if(B.isObject(t)){var i=t.stack;r=e+X(i,t)}else r=e+String(t);"function"==typeof I?I(r,n):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}}function T(t,e,n,r){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(o){N.throwLater(o)}"unhandledRejection"===t?ot(t,n,r)||i||x(n,"Unhandled rejection "):ot(t,r)}function P(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():B.toString(t);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(e))try{var r=JSON.stringify(t);e=r}catch(i){}0===e.length&&(e="(empty array)")}return"(<"+R(e)+">, no stack trace)"}function R(t){var e=41;return t.lengths||0>a||!n||!r||n!==r||s>=a||(at=function(t){if($.test(t))return!0;var e=O(t);return e&&e.fileName===n&&s<=e.line&&e.line<=a?!0:!1})}}function V(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);ut(this,V),e>32&&this.uncycle()}var H,D,I,L,N=e._async,U=t("./errors").Warning,B=t("./util"),M=t("./es5"),q=B.canAttachTrace,$=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,Q=/\((?:timers\.js):\d+:\d+\)/,G=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,z=null,X=null,W=!1,K=!(0==B.env("BLUEBIRD_DEBUG")||!B.env("BLUEBIRD_DEBUG")&&"development"!==B.env("NODE_ENV")),J=!(0==B.env("BLUEBIRD_WARNINGS")||!K&&!B.env("BLUEBIRD_WARNINGS")),Y=!(0==B.env("BLUEBIRD_LONG_STACK_TRACES")||!K&&!B.env("BLUEBIRD_LONG_STACK_TRACES")),Z=0!=B.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(J||!!B.env("BLUEBIRD_W_FORGOTTEN_RETURN"));!function(){function t(){for(var t=0;t0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},e.prototype._warn=function(t,e,n){return b(t,e,n||this)},e.onPossiblyUnhandledRejection=function(t){var n=e._getContext();D=B.contextBind(n,t)},e.onUnhandledRejectionHandled=function(t){var n=e._getContext();H=B.contextBind(n,t)};var tt=function(){};e.longStackTraces=function(){if(N.haveItemsQueued()&&!lt.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!lt.longStackTraces&&S()){var t=e.prototype._captureStackTrace,r=e.prototype._attachExtraTrace,i=e.prototype._dereferenceTrace;lt.longStackTraces=!0,tt=function(){if(N.haveItemsQueued()&&!lt.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");e.prototype._captureStackTrace=t,e.prototype._attachExtraTrace=r,e.prototype._dereferenceTrace=i,n.deactivateLongStackTraces(),lt.longStackTraces=!1},e.prototype._captureStackTrace=d,e.prototype._attachExtraTrace=v,e.prototype._dereferenceTrace=y,n.activateLongStackTraces()}},e.hasLongStackTraces=function(){return lt.longStackTraces&&S()};var et={unhandledrejection:{before:function(){var t=B.global.onunhandledrejection;return B.global.onunhandledrejection=null,t},after:function(t){B.global.onunhandledrejection=t}},rejectionhandled:{before:function(){var t=B.global.onrejectionhandled;return B.global.onrejectionhandled=null,t},after:function(t){B.global.onrejectionhandled=t}}},nt=function(){var t=function(t,e){if(!t)return!B.global.dispatchEvent(e);var n;try{return n=t.before(),!B.global.dispatchEvent(e)}finally{t.after(n)}};try{if("function"==typeof CustomEvent){var e=new CustomEvent("CustomEvent");return B.global.dispatchEvent(e),function(e,n){e=e.toLowerCase();var r={detail:n,cancelable:!0},i=new CustomEvent(e,r);return M.defineProperty(i,"promise",{value:n.promise}),M.defineProperty(i,"reason",{value:n.reason}),t(et[e],i)}}if("function"==typeof Event){var e=new Event("CustomEvent");return B.global.dispatchEvent(e),function(e,n){e=e.toLowerCase();var r=new Event(e,{cancelable:!0});return r.detail=n,M.defineProperty(r,"promise",{value:n.promise}),M.defineProperty(r,"reason",{value:n.reason}),t(et[e],r)}}var e=document.createEvent("CustomEvent");return e.initCustomEvent("testingtheevent",!1,!0,{}),B.global.dispatchEvent(e),function(e,n){e=e.toLowerCase();var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,!1,!0,n),t(et[e],r)}}catch(n){}return function(){return!1}}(),rt=function(){return B.isNode?function(){return process.emit.apply(process,arguments)}:B.global?function(t){var e="on"+t.toLowerCase(),n=B.global[e];return n?(n.apply(B.global,[].slice.call(arguments,1)),!0):!1}:function(){return!1}}(),it={promiseCreated:o,promiseFulfilled:o,promiseRejected:o,promiseResolved:o,promiseCancelled:o,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:o},ot=function(t){var e=!1;try{e=rt.apply(null,arguments)}catch(n){N.throwLater(n),e=!0}var r=!1;try{r=nt(t,it[t].apply(null,arguments))}catch(n){N.throwLater(n),r=!0}return r||e};e.config=function(t){if(t=Object(t),"longStackTraces"in t&&(t.longStackTraces?e.longStackTraces():!t.longStackTraces&&e.hasLongStackTraces()&&tt()),"warnings"in t){var n=t.warnings;lt.warnings=!!n,Z=lt.warnings,B.isObject(n)&&"wForgottenReturn"in n&&(Z=!!n.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!lt.cancellation){if(N.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");e.prototype._clearCancellationData=p,e.prototype._propagateFrom=f,e.prototype._onCancel=u,e.prototype._setOnCancel=l,e.prototype._attachCancellationCallback=c,e.prototype._execute=a,st=f,lt.cancellation=!0}if("monitoring"in t&&(t.monitoring&&!lt.monitoring?(lt.monitoring=!0,e.prototype._fireEvent=ot):!t.monitoring&<.monitoring&&(lt.monitoring=!1,e.prototype._fireEvent=s)),"asyncHooks"in t&&B.nodeSupportsAsyncResource){var o=lt.asyncHooks,h=!!t.asyncHooks;o!==h&&(lt.asyncHooks=h,h?r():i())}return e},e.prototype._fireEvent=s,e.prototype._execute=function(t,e,n){try{t(e,n)}catch(r){return r}},e.prototype._onCancel=function(){},e.prototype._setOnCancel=function(t){},e.prototype._attachCancellationCallback=function(t){},e.prototype._captureStackTrace=function(){},e.prototype._attachExtraTrace=function(){},e.prototype._dereferenceTrace=function(){},e.prototype._clearCancellationData=function(){},e.prototype._propagateFrom=function(t,e){};var st=h,at=function(){return!1},ct=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;B.inherits(V,Error),n.CapturedTrace=V,V.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],n={},r=0,i=this;void 0!==i;++r)e.push(i),i=i._parent;t=this._length=r;for(var r=t-1;r>=0;--r){var o=e[r].stack;void 0===n[o]&&(n[o]=r)}for(var r=0;t>r;++r){var s=e[r].stack,a=n[s];if(void 0!==a&&a!==r){a>0&&(e[a-1]._parent=void 0,e[a-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var c=r>0?e[r-1]:this;t-1>a?(c._parent=e[a+1],c._parent.uncycle(),c._length=c._parent._length+1):(c._parent=void 0,c._length=1);for(var u=c._length+1,l=r-2;l>=0;--l)e[l]._length=u,u++;return}}}},V.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=F(t),n=e.message,r=[e.stack],i=this;void 0!==i;)r.push(k(i.stack.split("\n"))),i=i._parent;j(r),C(r),B.notEnumerableProp(t,"stack",w(n,r)),B.notEnumerableProp(t,"__stackCleaned__",!0)}};var ut=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():P(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,z=t,X=e;var n=Error.captureStackTrace;return at=function(t){return $.test(t)},function(t,e){Error.stackTraceLimit+=6,n(t,e),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return z=/@/,X=e,W=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in r||!i||"number"!=typeof Error.stackTraceLimit?(X=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?P(e):e.toString()},null):(z=t,X=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(I=function(t){console.warn(t)},B.isNode&&process.stderr.isTTY?I=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:B.isNode||"string"!=typeof(new Error).stack||(I=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var lt={warnings:J,longStackTraces:!1,cancellation:!1,monitoring:!1,asyncHooks:!1};return Y&&e.longStackTraces(),{asyncHooks:function(){return lt.asyncHooks},longStackTraces:function(){return lt.longStackTraces},warnings:function(){return lt.warnings},cancellation:function(){return lt.cancellation},monitoring:function(){return lt.monitoring},propagateFromFunction:function(){return st},boundValueFunction:function(){return _},checkForgottenReturns:g,setBounds:A,warn:b,deprecated:m,CapturedTrace:V,fireDomEvent:nt,fireGlobalEvent:rt}}},{"./errors":12,"./es5":13,"./util":36}],10:[function(t,e,n){"use strict";e.exports=function(t){function e(){return this.value}function n(){throw this.reason}t.prototype["return"]=t.prototype.thenReturn=function(n){return n instanceof t&&n.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:n},void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return this._then(n,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:t},void 0);var e=arguments[1],r=function(){throw e};return this.caught(t,r)},t.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof t&&n.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:n},void 0);var r=arguments[1];r instanceof t&&r.suppressUnhandledRejections();var i=function(){return r};return this.caught(n,i)}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,e){function n(){return o(this)}function r(t,n){return i(t,n,e,e)}var i=t.reduce,o=t.all;t.prototype.each=function(t){return i(this,t,e,0)._then(n,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return i(this,t,e,e)},t.each=function(t,r){return i(t,r,e,0)._then(n,void 0,void 0,t,void 0)},t.mapSeries=r}},{}],12:[function(t,e,n){"use strict";function r(t,e){function n(r){return this instanceof n?(p(this,"message","string"==typeof r?r:e),p(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return l(n,Error),n}function i(t){return this instanceof i?(p(this,"name","OperationalError"),p(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(p(this,"message",t.message),p(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,s,a=t("./es5"),c=a.freeze,u=t("./util"),l=u.inherits,p=u.notEnumerableProp,f=r("Warning","warning"),h=r("CancellationError","cancellation error"),_=r("TimeoutError","timeout error"),d=r("AggregateError","aggregate error");try{o=TypeError,s=RangeError}catch(v){o=r("TypeError","type error"),s=r("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),g=0;g1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0):!1}function a(){return u.call(this,this.promise._target()._settledValue())}function c(t){return s(this,t)?void 0:(f.e=t,f)}function u(t){var i=this.promise,u=this.handler;if(!this.called){this.called=!0;var l=this.isFinallyHandler()?u.call(i._boundValue()):u.call(i._boundValue(),t);if(l===r)return l;if(void 0!==l){i._setReturnedNonUndefined();var h=n(l,i);if(h instanceof e){if(null!=this.cancelPromise){if(h._isCancelled()){var _=new p("late cancellation observer");return i._attachExtraTrace(_),f.e=_,f}h.isPending()&&h._attachCancellationCallback(new o(this))}return h._then(a,c,void 0,this,void 0)}}}return i.isRejected()?(s(this),f.e=t,f):(s(this),t)}var l=t("./util"),p=e.CancellationError,f=l.errorObj,h=t("./catch_filter")(r);return i.prototype.isFinallyHandler=function(){return 0===this.type},o.prototype._resultCancelled=function(){s(this.finallyHandler)},e.prototype._passThrough=function(t,e,n,r){return"function"!=typeof t?this.then():this._then(n,r,void 0,new i(this,e,t),void 0)},e.prototype.lastly=e.prototype["finally"]=function(t){return this._passThrough(t,0,u,u)},e.prototype.tap=function(t){return this._passThrough(t,1,u)},e.prototype.tapCatch=function(t){var n=arguments.length;if(1===n)return this._passThrough(t,1,void 0,u);var r,i=new Array(n-1),o=0;for(r=0;n-1>r;++r){var s=arguments[r];if(!l.isObject(s))return e.reject(new TypeError("tapCatch statement predicate: expecting an object but got "+l.classString(s)));i[o++]=s}i.length=o;var a=arguments[r];return this._passThrough(h(i,a,this),1,void 0,u)},i}},{"./catch_filter":7,"./util":36}],16:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,n,r){for(var o=0;o0&&"function"==typeof arguments[e]){t=arguments[e];var r}var i=[].slice.call(arguments);t&&i.pop();var r=new n(i).promise();return void 0!==t?r.spread(t):r}}},{"./util":36}],18:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,n,r,i){this.constructor$(t),this._promise._captureStackTrace();var s=e._getContext();if(this._callback=u.contextBind(s,n),this._preservedValues=i===o?new Array(this.length()):null,this._limit=r,this._inFlight=0,this._queue=[],f.invoke(this._asyncInit,this,void 0),u.isArray(t))for(var a=0;a=1?s:0,new a(t,n,s,o).promise()}var u=t("./util"),l=u.tryCatch,p=u.errorObj,f=e._async;u.inherits(a,n),a.prototype._asyncInit=function(){this._init$(void 0,-2)},a.prototype._init=function(){},a.prototype._promiseFulfilled=function(t,n){var r=this._values,o=this.length(),a=this._preservedValues,c=this._limit;if(0>n){if(n=-1*n-1,r[n]=t,c>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(c>=1&&this._inFlight>=c)return r[n]=t,this._queue.push(n),!1;null!==a&&(a[n]=t);var u=this._promise,f=this._callback,h=u._boundValue();u._pushContext();var _=l(f).call(h,t,n,o),d=u._popContext();if(s.checkForgottenReturns(_,d,null!==a?"Promise.filter":"Promise.map",u),_===p)return this._reject(_.e),!0;var v=i(_,this._promise);if(v instanceof e){v=v._target();var y=v._bitField;if(0===(50397184&y))return c>=1&&this._inFlight++,r[n]=v,v._proxy(this,-1*(n+1)),!1;if(0===(33554432&y))return 0!==(16777216&y)?(this._reject(v._reason()),!0):(this._cancel(),!0);_=v._value()}r[n]=_}var g=++this._totalResolved;return g>=o?(null!==a?this._filter(r,a):this._resolve(r),!0):!1},a.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,n=this._values;t.length>0&&this._inFlighto;++o)t[o]&&(r[i++]=e[o]);r.length=i,this._resolve(r)},a.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return c(this,t,e,null)},e.map=function(t,e,n,r){return c(t,e,n,r)}}},{"./util":36}],19:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){var s=t("./util"),a=s.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("expecting a function but got "+s.classString(t));return function(){var r=new e(n);r._captureStackTrace(),r._pushContext();var i=a(t).apply(this,arguments),s=r._popContext();return o.checkForgottenReturns(i,s,"Promise.method",r),r._resolveFromSyncValue(i),r}},e.attempt=e["try"]=function(t){if("function"!=typeof t)return i("expecting a function but got "+s.classString(t));var r=new e(n);r._captureStackTrace(),r._pushContext();var c;if(arguments.length>1){o.deprecated("calling Promise.try with more than 1 argument");var u=arguments[1],l=arguments[2];c=s.isArray(u)?a(t).apply(l,u):a(t).call(l,u)}else c=a(t)();var p=r._popContext();return o.checkForgottenReturns(c,p,"Promise.try",r),r._resolveFromSyncValue(c),r},e.prototype._resolveFromSyncValue=function(t){t===s.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":36}],20:[function(t,e,n){"use strict";function r(t){return t instanceof Error&&l.getPrototypeOf(t)===Error.prototype}function i(t){var e;if(r(t)){e=new u(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var n=l.keys(t),i=0;i1){var n,r=new Array(e-1),i=0;for(n=0;e-1>n;++n){var o=arguments[n];if(!f.isObject(o))return l("Catch statement predicate: expecting an object but got "+f.classString(o));r[i++]=o}if(r.length=i,t=arguments[n],"function"!=typeof t)throw new E("The last argument to .catch() must be a function, got "+f.toString(t));return this.then(void 0,D(r,t,this))}return this.then(void 0,t)},i.prototype.reflect=function(){return this._then(u,u,void 0,this,void 0)},i.prototype.then=function(t,e){if(V.warnings()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+f.classString(t);arguments.length>1&&(n+=", "+f.classString(e)),this._warn(n)}return this._then(t,e,void 0,void 0,void 0)},i.prototype.done=function(t,e){var n=this._then(t,e,void 0,void 0,void 0);n._setIsFinal()},i.prototype.spread=function(t){return"function"!=typeof t?l("expecting a function but got "+f.classString(t)):this.all()._then(t,void 0,void 0,T,void 0)},i.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},i.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new S(this).promise()},i.prototype.error=function(t){return this.caught(f.originatesFromRejection,t)},i.getNewLibraryCopy=e.exports,i.is=function(t){return t instanceof i},i.fromNode=i.fromCallback=function(t){var e=new i(x);e._captureStackTrace();var n=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,r=N(t)(I(e,n));return r===L&&e._rejectCallback(r.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},i.all=function(t){return new S(t).promise()},i.cast=function(t){var e=R(t);return e instanceof i||(e=new i(x),e._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},i.resolve=i.fulfilled=i.cast,i.reject=i.rejected=function(t){var e=new i(x);return e._captureStackTrace(),e._rejectCallback(t,!0),e},i.setScheduler=function(t){if("function"!=typeof t)throw new E("expecting a function but got "+f.classString(t));return j.setScheduler(t)},i.prototype._then=function(t,e,n,r,o){var s=void 0!==o,a=s?o:new i(x),c=this._target(),u=c._bitField;s||(a._propagateFrom(this,3),a._captureStackTrace(),void 0===r&&0!==(2097152&this._bitField)&&(r=0!==(50397184&u)?this._boundValue():c===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,a));var l=g();if(0!==(50397184&u)){var p,h,_=c._settlePromiseCtx;0!==(33554432&u)?(h=c._rejectionHandler0,p=t):0!==(16777216&u)?(h=c._fulfillmentHandler0,p=e,c._unsetRejectionIsUnhandled()):(_=c._settlePromiseLateCancellationObserver,h=new F("late cancellation observer"),c._attachExtraTrace(h),p=e),j.invoke(_,c,{handler:f.contextBind(l,p),promise:a,receiver:r,value:h})}else c._addCallbacks(t,e,a,r,l);return a},i.prototype._length=function(){return 65535&this._bitField},i.prototype._isFateSealed=function(){return 0!==(117506048&this._bitField)},i.prototype._isFollowing=function(){return 67108864===(67108864&this._bitField)},i.prototype._setLength=function(t){this._bitField=-65536&this._bitField|65535&t},i.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},i.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},i.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},i.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},i.prototype._isFinal=function(){return(4194304&this._bitField)>0},i.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},i.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},i.prototype._setWillBeCancelled=function(){this._bitField=8388608|this._bitField},i.prototype._setAsyncGuaranteed=function(){if(!j.hasCustomScheduler()){var t=this._bitField;this._bitField=t|(536870912&t)>>2^134217728}},i.prototype._setNoAsyncGuarantee=function(){this._bitField=-134217729&(536870912|this._bitField)},i.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];return e===p?void 0:void 0===e&&this._isBound()?this._boundValue():e},i.prototype._promiseAt=function(t){return this[4*t-4+2]},i.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},i.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},i.prototype._boundValue=function(){},i.prototype._migrateCallback0=function(t){var e=(t._bitField,t._fulfillmentHandler0),n=t._rejectionHandler0,r=t._promise0,i=t._receiverAt(0);void 0===i&&(i=p),this._addCallbacks(e,n,r,i,null)},i.prototype._migrateCallbackAt=function(t,e){var n=t._fulfillmentHandlerAt(e),r=t._rejectionHandlerAt(e),i=t._promiseAt(e),o=t._receiverAt(e);void 0===o&&(o=p),this._addCallbacks(n,r,i,o,null)},i.prototype._addCallbacks=function(t,e,n,r,i){var o=this._length();if(o>=65531&&(o=0,this._setLength(0)),0===o)this._promise0=n,this._receiver0=r,"function"==typeof t&&(this._fulfillmentHandler0=f.contextBind(i,t)),"function"==typeof e&&(this._rejectionHandler0=f.contextBind(i,e));else{var s=4*o-4;this[s+2]=n,this[s+3]=r,"function"==typeof t&&(this[s+0]=f.contextBind(i,t)),"function"==typeof e&&(this[s+1]=f.contextBind(i,e))}return this._setLength(o+1),o},i.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},i.prototype._resolveCallback=function(t,e){if(0===(117506048&this._bitField)){if(t===this)return this._rejectCallback(c(),!1);var n=R(t,this);if(!(n instanceof i))return this._fulfill(t);e&&this._propagateFrom(n,2);var r=n._target();if(r===this)return void this._reject(c());var o=r._bitField;if(0===(50397184&o)){var s=this._length();s>0&&r._migrateCallback0(this);for(var a=1;s>a;++a)r._migrateCallbackAt(this,a);this._setFollowing(),this._setLength(0),this._setFollowee(n)}else if(0!==(33554432&o))this._fulfill(r._value());else if(0!==(16777216&o))this._reject(r._reason());else{var u=new F("late cancellation observer");r._attachExtraTrace(u),this._reject(u)}}},i.prototype._rejectCallback=function(t,e,n){var r=f.ensureErrorObject(t),i=r===t;if(!i&&!n&&V.warnings()){var o="a promise was rejected with a non-error: "+f.classString(t);this._warn(o,!0)}this._attachExtraTrace(r,e?i:!1),this._reject(t)},i.prototype._resolveFromExecutor=function(t){if(t!==x){var e=this;this._captureStackTrace(),this._pushContext();var n=!0,r=this._execute(t,function(t){e._resolveCallback(t)},function(t){e._rejectCallback(t,n)});n=!1,this._popContext(),void 0!==r&&e._rejectCallback(r,!0)}},i.prototype._settlePromiseFromHandler=function(t,e,n,r){var i=r._bitField;if(0===(65536&i)){r._pushContext();var o;e===T?n&&"number"==typeof n.length?o=N(t).apply(this._boundValue(),n):(o=L,o.e=new E("cannot .spread() a non-array: "+f.classString(n))):o=N(t).call(e,n);var s=r._popContext();i=r._bitField,0===(65536&i)&&(o===P?r._reject(n):o===L?r._rejectCallback(o.e,!1):(V.checkForgottenReturns(o,s,"",r,this),r._resolveCallback(o)))}},i.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},i.prototype._followee=function(){return this._rejectionHandler0},i.prototype._setFollowee=function(t){this._rejectionHandler0=t},i.prototype._settlePromise=function(t,e,r,o){var s=t instanceof i,a=this._bitField,c=0!==(134217728&a);0!==(65536&a)?(s&&t._invokeInternalOnCancel(),r instanceof H&&r.isFinallyHandler()?(r.cancelPromise=t,N(e).call(r,o)===L&&t._reject(L.e)):e===u?t._fulfill(u.call(r)):r instanceof n?r._promiseCancelled(t):s||t instanceof S?t._cancel():r.cancel()):"function"==typeof e?s?(c&&t._setAsyncGuaranteed(),this._settlePromiseFromHandler(e,r,o,t)):e.call(r,o,t):r instanceof n?r._isResolved()||(0!==(33554432&a)?r._promiseFulfilled(o,t):r._promiseRejected(o,t)):s&&(c&&t._setAsyncGuaranteed(),0!==(33554432&a)?t._fulfill(o):t._reject(o))},i.prototype._settlePromiseLateCancellationObserver=function(t){var e=t.handler,n=t.promise,r=t.receiver,o=t.value;"function"==typeof e?n instanceof i?this._settlePromiseFromHandler(e,r,o,n):e.call(r,o,n):n instanceof i&&n._reject(o)},i.prototype._settlePromiseCtx=function(t){this._settlePromise(t.promise,t.handler,t.receiver,t.value)},i.prototype._settlePromise0=function(t,e,n){var r=this._promise0,i=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(r,t,i,e)},i.prototype._clearCallbackDataAtIndex=function(t){var e=4*t-4;this[e+2]=this[e+3]=this[e+0]=this[e+1]=void 0},i.prototype._fulfill=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(t===this){var n=c();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!==(134217728&e)?this._settlePromises():j.settlePromises(this),this._dereferenceTrace())}},i.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16))return this._setRejected(),this._fulfillmentHandler0=t,this._isFinal()?j.fatalError(t,f.isNode):void((65535&e)>0?j.settlePromises(this):this._ensurePossibleRejectionHandled())},i.prototype._fulfillPromises=function(t,e){for(var n=1;t>n;n++){var r=this._fulfillmentHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._rejectPromises=function(t,e){for(var n=1;t>n;n++){var r=this._rejectionHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._settlePromises=function(){var t=this._bitField,e=65535&t;if(e>0){if(0!==(16842752&t)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,t),this._rejectPromises(e,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,t),this._fulfillPromises(e,r)}this._setLength(0)}this._clearCancellationData()},i.prototype._settledValue=function(){var t=this._bitField;return 0!==(33554432&t)?this._rejectionHandler0:0!==(16777216&t)?this._fulfillmentHandler0:void 0},"undefined"!=typeof Symbol&&Symbol.toStringTag&&w.defineProperty(i.prototype,Symbol.toStringTag,{get:function(){return"Object"}}),i.defer=i.pending=function(){V.deprecated("Promise.defer","new Promise");var t=new i(x);return{promise:t,resolve:o,reject:s}},f.notEnumerableProp(i,"_makeSelfResolutionError",c),t("./method")(i,x,R,l,V),t("./bind")(i,x,R,V),t("./cancel")(i,S,l,V),t("./direct_resolve")(i),t("./synchronous_inspection")(i),t("./join")(i,S,R,x,j),i.Promise=i,i.version="3.7.2",t("./call_get.js")(i),t("./generators.js")(i,l,x,R,n,V),t("./map.js")(i,S,l,R,x,V),t("./nodeify.js")(i),t("./promisify.js")(i,x),t("./props.js")(i,S,R,l),t("./race.js")(i,x,R,l),t("./reduce.js")(i,S,l,R,x,V),t("./settle.js")(i,S,V),t("./some.js")(i,S,l),t("./timers.js")(i,x,V),t("./using.js")(i,l,R,A,x,V),t("./any.js")(i),t("./each.js")(i,x),t("./filter.js")(i,x),f.toFastProperties(i),f.toFastProperties(i.prototype),a({a:1}),a({b:2}),a({c:3}),a(1),a(function(){}),a(void 0),a(!1),a(new i(x)),V.setBounds(C.firstLineError,f.lastLineError),i}},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36,async_hooks:void 0}],23:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){function s(t){switch(t){case-2:return[];case-3:return{};case-6:return new Map}}function a(t){var r=this._promise=new e(n);t instanceof e&&(r._propagateFrom(t,3),t.suppressUnhandledRejections()),r._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var c=t("./util");c.isArray;return c.inherits(a,o),a.prototype.length=function(){return this._length},a.prototype.promise=function(){return this._promise},a.prototype._init=function u(t,n){var o=r(this._values,this._promise);if(o instanceof e){o=o._target();var a=o._bitField;if(this._values=o,0===(50397184&a))return this._promise._setAsyncGuaranteed(),o._then(u,this._reject,void 0,this,n);if(0===(33554432&a))return 0!==(16777216&a)?this._reject(o._reason()):this._cancel();o=o._value()}if(o=c.asArray(o),null===o){var l=i("expecting an array or an iterable object but got "+c.classString(o)).reason();return void this._promise._rejectCallback(l,!1)}return 0===o.length?void(-5===n?this._resolveEmptyArray():this._resolve(s(n))):void this._iterate(o)},a.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var i=this._promise,o=!1,s=null,a=0;n>a;++a){var c=r(t[a],i);c instanceof e?(c=c._target(),s=c._bitField):s=null,o?null!==s&&c.suppressUnhandledRejections():null!==s?0===(50397184&s)?(c._proxy(this,a),this._values[a]=c):o=0!==(33554432&s)?this._promiseFulfilled(c._value(),a):0!==(16777216&s)?this._promiseRejected(c._reason(),a):this._promiseCancelled(a):o=this._promiseFulfilled(c,a)}o||i._setAsyncGuaranteed()},a.prototype._isResolved=function(){return null===this._values},a.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},a.prototype._cancel=function(){!this._isResolved()&&this._promise._isCancellable()&&(this._values=null,this._promise._cancel())},a.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1)},a.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},a.prototype._promiseCancelled=function(){return this._cancel(),!0},a.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},a.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var n=0;nc;c+=2){var l=s[c],p=s[c+1],_=l+e;if(r===E)t[_]=E(l,f,l,p,e,i);else{var d=r(p,function(){return E(l,f,l,p,e,i)});h.notEnumerableProp(d,"__isPromisified__",!0),t[_]=d}}return h.toFastProperties(t),t}function l(t,e,n){return E(t,e,void 0,t,null,n)}var p,f={},h=t("./util"),_=t("./nodeback"),d=h.withAppended,v=h.maybeWrapAsError,y=h.canEvaluate,g=t("./errors").TypeError,m="Async",b={__isPromisified__:!0},w=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],C=new RegExp("^(?:"+w.join("|")+")$"),j=function(t){return h.isIdentifier(t)&&"_"!==t.charAt(0)&&"constructor"!==t},k=function(t){return t.replace(new RegExp(/\$/, 'g'),"\\$")},E=y?p:c;e.promisify=function(t,e){if("function"!=typeof t)throw new g("expecting a function but got "+h.classString(t));if(i(t))return t;e=Object(e);var n=void 0===e.context?f:e.context,o=!!e.multiArgs,s=l(t,n,o);return h.copyDescriptors(t,s,r),s},e.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new g("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/MqrFmX\n");e=Object(e);var n=!!e.multiArgs,r=e.suffix;"string"!=typeof r&&(r=m);var i=e.filter;"function"!=typeof i&&(i=j);var o=e.promisifier;if("function"!=typeof o&&(o=E),!h.isIdentifier(r))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/MqrFmX\n");for(var s=h.inheritedDataKeys(t),a=0;ao;++o){var s=r[o];e[o]=t[s],e[o+i]=s}}this.constructor$(e),this._isMap=n,this._init$(void 0,n?-6:-3)}function s(t){var n,s=r(t);return u(s)?(n=s instanceof e?s._then(e.props,void 0,void 0,void 0,void 0):new o(s).promise(),s instanceof e&&n._propagateFrom(s,2),n):i("cannot await properties of a non-object\n\n See http://goo.gl/MqrFmX\n")}var a,c=t("./util"),u=c.isObject,l=t("./es5");"function"==typeof Map&&(a=Map);var p=function(){function t(t,r){this[e]=t,this[e+n]=r,e++}var e=0,n=0;return function(r){n=r.size,e=0;var i=new Array(2*r.size);return r.forEach(t,i),i}}(),f=function(t){for(var e=new a,n=t.length/2|0,r=0;n>r;++r){var i=t[n+r],o=t[r];e.set(i,o)}return e};c.inherits(o,n),o.prototype._init=function(){},o.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var n=++this._totalResolved;if(n>=this._length){var r;if(this._isMap)r=f(this._values);else{r={};for(var i=this.length(),o=0,s=this.length();s>o;++o)r[this._values[o+i]]=this._values[o]}return this._resolve(r),!0}return!1},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(t){return t>>1},e.prototype.props=function(){return s(this)},e.props=function(t){return s(t)}}},{"./es5":13,"./util":36}],26:[function(t,e,n){"use strict";function r(t,e,n,r,i){for(var o=0;i>o;++o)n[o+r]=t[o+e],t[o+e]=void 0}function i(t){this._capacity=t,this._length=0,this._front=0}i.prototype._willBeOverCapacity=function(t){return this._capacityf;++f){var _=t[f];(void 0!==_||f in t)&&e.cast(_)._then(l,p,void 0,u,null)}return u}var s=t("./util"),a=function(t){return t.then(function(e){return o(e,t)})};e.race=function(t){return o(t,void 0)},e.prototype.race=function(){return o(this,void 0)}}},{"./util":36}],28:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,n,r,i){this.constructor$(t);var s=e._getContext();this._fn=f.contextBind(s,n),void 0!==r&&(r=e.resolve(r),r._attachCancellationCallback(this)),this._initialValue=r,this._currentCancellable=null,i===o?this._eachValues=Array(this._length):0===i?this._eachValues=null:this._eachValues=void 0,this._promise._captureStackTrace(),this._init$(void 0,-5)}function c(t,e){this.isFulfilled()?e._resolve(t):e._reject(t)}function u(t,e,n,i){if("function"!=typeof e)return r("expecting a function but got "+f.classString(e));var o=new a(t,e,n,i);return o.promise()}function l(t){this.accum=t,this.array._gotAccum(t);var n=i(this.value,this.array._promise);return n instanceof e?(this.array._currentCancellable=n,n._then(p,void 0,void 0,this,void 0)):p.call(this,n)}function p(t){var n=this.array,r=n._promise,i=h(n._fn);r._pushContext();var o;o=void 0!==n._eachValues?i.call(r._boundValue(),t,this.index,this.length):i.call(r._boundValue(),this.accum,t,this.index,this.length),o instanceof e&&(n._currentCancellable=o);var a=r._popContext();return s.checkForgottenReturns(o,a,void 0!==n._eachValues?"Promise.each":"Promise.reduce",r),o}var f=t("./util"),h=f.tryCatch;f.inherits(a,n),a.prototype._gotAccum=function(t){void 0!==this._eachValues&&null!==this._eachValues&&t!==o&&this._eachValues.push(t)},a.prototype._eachComplete=function(t){return null!==this._eachValues&&this._eachValues.push(t),this._eachValues},a.prototype._init=function(){},a.prototype._resolveEmptyArray=function(){this._resolve(void 0!==this._eachValues?this._eachValues:this._initialValue)},a.prototype.shouldCopyValues=function(){return!1},a.prototype._resolve=function(t){this._promise._resolveCallback(t),this._values=null},a.prototype._resultCancelled=function(t){return t===this._initialValue?this._cancel():void(this._isResolved()||(this._resultCancelled$(),this._currentCancellable instanceof e&&this._currentCancellable.cancel(),this._initialValue instanceof e&&this._initialValue.cancel()))},a.prototype._iterate=function(t){this._values=t;var n,r,i=t.length;void 0!==this._initialValue?(n=this._initialValue,r=0):(n=e.resolve(t[0]),r=1),this._currentCancellable=n;for(var o=r;i>o;++o){var s=t[o];s instanceof e&&s.suppressUnhandledRejections()}if(!n.isRejected())for(;i>r;++r){var a={accum:null,value:t[r],index:r,length:i,array:this};n=n._then(l,void 0,void 0,a,void 0),0===(127&r)&&n._setNoAsyncGuarantee()}void 0!==this._eachValues&&(n=n._then(this._eachComplete,void 0,void 0,this,void 0)),n._then(c,c,void 0,n,this)},e.prototype.reduce=function(t,e){return u(this,t,e,null)},e.reduce=function(t,e,n,r){return u(t,e,n,r)}}},{"./util":36}],29:[function(t,e,n){"use strict";var r,i=t("./util"),o=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")},s=i.getNativePromise();if(i.isNode&&"undefined"==typeof MutationObserver){var a=global.setImmediate,c=process.nextTick;r=i.isRecentNode?function(t){a.call(global,t)}:function(t){c.call(process,t)}}else if("function"==typeof s&&"function"==typeof s.resolve){ -var u=s.resolve();r=function(t){u.then(t)}}else r="undefined"!=typeof MutationObserver&&("undefined"==typeof window||!window.navigator||!window.navigator.standalone&&!window.cordova)&&"classList"in document.documentElement?function(){var t=document.createElement("div"),e={attributes:!0},n=!1,r=document.createElement("div"),i=new MutationObserver(function(){t.classList.toggle("foo"),n=!1});i.observe(r,e);var o=function(){n||(n=!0,r.classList.toggle("foo"))};return function(n){var r=new MutationObserver(function(){r.disconnect(),n()});r.observe(t,e),o()}}():"undefined"!=typeof setImmediate?function(t){setImmediate(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:o;e.exports=r},{"./util":36}],30:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.constructor$(t)}var o=e.PromiseInspection,s=t("./util");s.inherits(i,n),i.prototype._promiseResolved=function(t,e){this._values[t]=e;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},i.prototype._promiseFulfilled=function(t,e){var n=new o;return n._bitField=33554432,n._settledValueField=t,this._promiseResolved(e,n)},i.prototype._promiseRejected=function(t,e){var n=new o;return n._bitField=16777216,n._settledValueField=t,this._promiseResolved(e,n)},e.settle=function(t){return r.deprecated(".settle()",".reflect()"),new i(t).promise()},e.allSettled=function(t){return new i(t).promise()},e.prototype.settle=function(){return e.settle(this)}}},{"./util":36}],31:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(t,e){if((0|e)!==e||0>e)return r("expecting a positive integer\n\n See http://goo.gl/MqrFmX\n");var n=new i(t),o=n.promise();return n.setHowMany(e),n.init(),o}var s=t("./util"),a=t("./errors").RangeError,c=t("./errors").AggregateError,u=s.isArray,l={};s.inherits(i,n),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=u(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){return this._addFulfilled(t),this._fulfilled()===this.howMany()?(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0):!1},i.prototype._promiseRejected=function(t){return this._addRejected(t),this._checkOutcome()},i.prototype._promiseCancelled=function(){return this._values instanceof e||null==this._values?this._cancel():(this._addRejected(l),this._checkOutcome())},i.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var t=new c,e=this.length();e0?this._reject(t):this._cancel(),!0}return!1},i.prototype._fulfilled=function(){return this._totalResolved},i.prototype._rejected=function(){return this._values.length-this.length()},i.prototype._addRejected=function(t){this._values.push(t)},i.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},i.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},i.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new a(e)},i.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return o(t,e)},e.prototype.some=function(t){return o(this,t)},e._SomePromiseArray=i}},{"./errors":12,"./util":36}],32:[function(t,e,n){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var n=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},r=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=e.prototype.isFulfilled=function(){return 0!==(33554432&this._bitField)},o=e.prototype.isRejected=function(){return 0!==(16777216&this._bitField)},s=e.prototype.isPending=function(){return 0===(50397184&this._bitField)},a=e.prototype.isResolved=function(){return 0!==(50331648&this._bitField)};e.prototype.isCancelled=function(){return 0!==(8454144&this._bitField)},t.prototype.__isCancelled=function(){return 65536===(65536&this._bitField)},t.prototype._isCancelled=function(){return this._target().__isCancelled()},t.prototype.isCancelled=function(){return 0!==(8454144&this._target()._bitField)},t.prototype.isPending=function(){return s.call(this._target())},t.prototype.isRejected=function(){return o.call(this._target())},t.prototype.isFulfilled=function(){return i.call(this._target())},t.prototype.isResolved=function(){return a.call(this._target())},t.prototype.value=function(){return n.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),r.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],33:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,r){if(l(t)){if(t instanceof e)return t;var i=o(t);if(i===u){r&&r._pushContext();var c=e.reject(i.e);return r&&r._popContext(),c}if("function"==typeof i){if(s(t)){var c=new e(n);return t._then(c._fulfill,c._reject,void 0,c,null),c}return a(t,i,r)}}return t}function i(t){return t.then}function o(t){try{return i(t)}catch(e){return u.e=e,u}}function s(t){try{return p.call(t,"_promise0")}catch(e){return!1}}function a(t,r,i){function o(t){a&&(a._resolveCallback(t),a=null)}function s(t){a&&(a._rejectCallback(t,p,!0),a=null)}var a=new e(n),l=a;i&&i._pushContext(),a._captureStackTrace(),i&&i._popContext();var p=!0,f=c.tryCatch(r).call(t,o,s);return p=!1,a&&f===u&&(a._rejectCallback(f.e,!0,!0),a=null),l}var c=t("./util"),u=c.errorObj,l=c.isObject,p={}.hasOwnProperty;return r}},{"./util":36}],34:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.handle=t}function o(t){return clearTimeout(this.handle),t}function s(t){throw clearTimeout(this.handle),t}var a=t("./util"),c=e.TimeoutError;i.prototype._resultCancelled=function(){clearTimeout(this.handle)};var u=function(t){return l(+this).thenReturn(t)},l=e.delay=function(t,o){var s,a;return void 0!==o?(s=e.resolve(o)._then(u,null,null,t,void 0),r.cancellation()&&o instanceof e&&s._setOnCancel(o)):(s=new e(n),a=setTimeout(function(){s._fulfill()},+t),r.cancellation()&&s._setOnCancel(new i(a)),s._captureStackTrace()),s._setAsyncGuaranteed(),s};e.prototype.delay=function(t){return l(t,this)};var p=function(t,e,n){var r;r="string"!=typeof e?e instanceof Error?e:new c("operation timed out"):new c(e),a.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._reject(r),null!=n&&n.cancel()};e.prototype.timeout=function(t,e){t=+t;var n,a,c=new i(setTimeout(function(){n.isPending()&&p(n,e,a)},t));return r.cancellation()?(a=this.then(),n=a._then(o,s,void 0,c,void 0),n._setOnCancel(c)):n=this._then(o,s,void 0,c,void 0),n}}},{"./util":36}],35:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t){setTimeout(function(){throw t},0)}function c(t){var e=r(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function u(t,n){function i(){if(s>=u)return l._fulfill();var o=c(t[s++]);if(o instanceof e&&o._isDisposable()){try{o=r(o._getDisposer().tryDispose(n),t.promise)}catch(p){return a(p)}if(o instanceof e)return o._then(i,a,null,null,null)}i()}var s=0,u=t.length,l=new e(o);return i(),l}function l(t,e,n){this._data=t,this._promise=e,this._context=n}function p(t,e,n){this.constructor$(t,e,n)}function f(t){return l.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}function h(t){this.length=t,this.promise=null,this[t-1]=null}var _=t("./util"),d=t("./errors").TypeError,v=t("./util").inherits,y=_.errorObj,g=_.tryCatch,m={};l.prototype.data=function(){return this._data},l.prototype.promise=function(){return this._promise},l.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():m},l.prototype.tryDispose=function(t){var e=this.resource(),n=this._context;void 0!==n&&n._pushContext();var r=e!==m?this.doDispose(e,t):null;return void 0!==n&&n._popContext(),this._promise._unsetDisposable(),this._data=null,r},l.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},v(p,l),p.prototype.doDispose=function(t,e){var n=this.data();return n.call(t,t,e)},h.prototype._resultCancelled=function(){for(var t=this.length,n=0;t>n;++n){var r=this[n];r instanceof e&&r.cancel()}},e.using=function(){var t=arguments.length;if(2>t)return n("you must pass at least 2 arguments to Promise.using");var i=arguments[t-1];if("function"!=typeof i)return n("expecting a function but got "+_.classString(i));var o,a=!0;2===t&&Array.isArray(arguments[0])?(o=arguments[0],t=o.length,a=!1):(o=arguments,t--);for(var c=new h(t),p=0;t>p;++p){var d=o[p];if(l.isDisposer(d)){var v=d;d=d.promise(),d._setDisposable(v)}else{var m=r(d);m instanceof e&&(d=m._then(f,null,null,{resources:c,index:p},void 0))}c[p]=d}for(var b=new Array(c.length),p=0;p0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new p(t,this,i());throw new d}}},{"./errors":12,"./util":36}],36:[function(t,e,n){"use strict";function r(){try{var t=P;return P=null,t.apply(this,arguments)}catch(e){return T.e=e,T}}function i(t){return P=t,r}function o(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function s(t){return"function"==typeof t||"object"==typeof t&&null!==t}function a(t){return o(t)?new Error(v(t)):t}function c(t,e){var n,r=t.length,i=new Array(r+1);for(n=0;r>n;++n)i[n]=t[n];return i[n]=e,i}function u(t,e,n){if(!F.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var r=Object.getOwnPropertyDescriptor(t,e);return null!=r?null==r.get&&null==r.set?r.value:n:void 0}function l(t,e,n){if(o(t))return t;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return F.defineProperty(t,e,r),t}function p(t){throw t}function f(t){try{if("function"==typeof t){var e=F.names(t.prototype),n=F.isES5&&e.length>1,r=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=A.test(t+"")&&F.names(t).length>0;if(n||r||i)return!0}return!1}catch(o){return!1}}function h(t){function e(){}function n(){return typeof r.foo}e.prototype=t;var r=new e;return n(),n(),t}function _(t){return V.test(t)}function d(t,e,n){for(var r=new Array(t),i=0;t>i;++i)r[i]=e+i+n;return r}function v(t){try{return t+""}catch(e){return"[no string representation]"}}function y(t){return t instanceof Error||null!==t&&"object"==typeof t&&"string"==typeof t.message&&"string"==typeof t.name}function g(t){try{l(t,"isOperational",!0)}catch(e){}}function m(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function b(t){return y(t)&&F.propertyIsWritable(t,"stack")}function w(t){return{}.toString.call(t)}function C(t,e,n){for(var r=F.names(t),i=0;i10||t[0]>0}(),B.nodeSupportsAsyncResource=B.isNode&&function(){var e=!1;try{var n=t("async_hooks").AsyncResource;e="function"==typeof n.prototype.runInAsyncScope}catch(r){e=!1}return e}(),B.isNode&&B.toFastProperties(process);try{throw new Error}catch(M){B.lastLineError=M}e.exports=B},{"./es5":13,async_hooks:void 0}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise); -} -!function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r["return"]||r["return"]()}finally{if(s)throw o}}}}function c(e,t,r){return(t=v(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(){return l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},l.apply(null,arguments)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(h=function(){return!!e})()}function g(){g=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=t&&t.prototype instanceof _?t:_,a=Object.create(o.prototype),s=new D(n||[]);return i(a,"_invoke",{value:k(e,r,s)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var f="suspendedStart",h="suspendedYield",m="executing",p="completed",v={};function _(){}function y(){}function S(){}var I={};c(I,a,(function(){return this}));var b=Object.getPrototypeOf,T=b&&b(b(F([])));T&&T!==r&&n.call(T,a)&&(I=T);var C=S.prototype=_.prototype=Object.create(I);function w(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function r(i,o,a,s){var u=d(e[i],e,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(l).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return o=o?o.then(i,i):i()}})}function k(t,r,n){var i=f;return function(o,a){if(i===m)throw Error("Generator is already running");if(i===p){if("throw"===o)throw a;return{value:e,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=p,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=m;var c=d(t,r,n);if("normal"===c.type){if(i=n.done?p:h,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=p,n.method="throw",n.arg=c.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator["return"]&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=d(i,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var a=o.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function F(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function r(){for(;++i=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),v}},"catch":function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:F(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=r["return"]&&(a=r["return"](),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||y(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function _(e){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_(e)}function y(e,r){if(e){if("string"==typeof e)return t(e,r);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}var S;function I(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function T(e){var t=function(e,t){if("object"!=b(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=b(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==b(t)?t:t+""}function C(e,t){for(var r=0;r=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=a.call(o,"catchLoc"),c=a.call(o,"finallyLoc");if(u&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),F(r),y}},"catch":function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;F(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:N(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),y}},i}e.exports=r,e.exports.__esModule=!0,e.exports["default"]=e.exports}(A);var D=(0,A.exports)(),F=D;try{regeneratorRuntime=D}catch(NJ){"object"===("undefined"==typeof globalThis?"undefined":_(globalThis))?globalThis.regeneratorRuntime=D:Function("r","regeneratorRuntime = r")(D)}var W,N,R=k(F);function O(e){var t=e?new Date(e):new Date,r="yyyy-MM-dd HH:mm:ss.SSSZ",n={"M+":t.getUTCMonth()+1,"d+":t.getUTCDate(),"H+":t.getUTCHours(),"h+":t.getUTCHours()%12||12,"m+":t.getUTCMinutes(),"s+":t.getUTCSeconds(),"q+":Math.floor((t.getUTCMonth()+3)/3),"S+":t.getUTCMilliseconds()};for(var i in/(y+)/.test(r)&&(r=r.replace(RegExp.$1,(t.getUTCFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+i+")").test(r)&&(r=r.replace(RegExp.$1,1==RegExp.$1.length?n[i]:("000"+n[i]).substr(("000"+n[i]).length-RegExp.$1.length)));return r}function M(e){return e===N}function L(e){return e!==N}function B(e){return null===e}W="object"===("undefined"==typeof window?"undefined":b(window))?window:{};var U={"[object Function]":"function","[object AsyncFunction]":"function","[object String]":"string","[object Object]":"object","[object Boolean]":"boolean","[object Number]":"number","[object Array]":"array"};function V(e){return B(e)||M(e)?String(e):U[{}.toString.call(e)]||"object"}function j(e){return"function"===V(e)}function G(e){return"string"===V(e)}function H(e){return"object"===V(e)}function z(e){return"boolean"===V(e)}function K(e){return"number"===V(e)}function J(e){return Array.isArray?Array.isArray(e):"array"===V(e)}function Q(e){if(null==e)return[];if(J(e))return e;var t=b(e.length),r=b(e);if("number"!==t||e.alert||"string"===r||"function"===r&&(!("item"in e)||"number"!==t))return[e];for(var n=[],i=0,o=e.length;i2){var o=n[n.length-2],a=n[n.length-1];j(o)&&j(a)&&(n[n.length-2]=function(){try{o.apply(t,arguments)}catch(jj){}ie.timer=setTimeout(ie.doNext,0)},n[n.length-1]=function(){try{a.apply(t,arguments)}catch(jj){}ie.timer=setTimeout(ie.doNext,0)},i=!0)}try{t[r].apply(t,n)}catch(s){}i||(ie.timer=setTimeout(ie.doNext,0))}else if(null===t&&j(r)){try{r.apply(null,n)}catch(u){}ie.timer=setTimeout(ie.doNext,0)}else ee("not invoke a function: "+r),ie.timer=setTimeout(ie.doNext,0)}else ie.stop();else ie.stop()},start:function(){ie.doNextStarted||(ie.doNextStarted=!0,ie.timer=setTimeout(ie.doNext,0))},stop:function(){clearTimeout(ie.timer),ie.timer=null,ie.doNextStarted=!1,ie.queue=[]}},oe=!0,ae=!1;function se(e,t,r){if(e){var n,i,o,a=0,s=e.length;if(r=r||null,M(s)||j(e))for(o=Object.keys(e);a=0;o--)i[o]===t&&i.splice(o,1);else n[e]=null;else this.exec=null}},le="";var de,fe,he,ge,me=navigator,pe=!0;if("userAgentData"in me){var ve=me.userAgentData,_e=[];ve.platform&&""!=ve.platform&&("brands"in ve&&Array.isArray(ve.brands)&&ve.brands.length>0?_e=ve.brands:"uaList"in ve&&Array.isArray(ve.uaList)&&ve.uaList.length>0&&(_e=ve.uaList),_e.length>0&&(pe=!1,fe=ve.platform.toLowerCase(),de=function(e,t,r){var n,i,o,a,s,u,c,l,d,f=!1,h=!1,g=!1,m=e.mobile,p=!1,v=le,_=navigator.maxTouchPoints||0;for(i=t.length,n=0;n=0){g=!0,v=t[n].version;break}if(y.indexOf("edge")>=0){f=!0,v=t[n].version;break}if(y.indexOf("opera")>=0){h=!0,v=t[n].version;break}}return g||f||h||(g=!0,v="100"),o=/windows/g.test(r),a=/mac/g.test(r),s=/linux/g.test(r),u=/android/g.test(r),c=/harmony/g.test(r),l=/(chromeos|chrome\sos)/g.test(r),d=/iphone/g.test(r),o||u||s||d||(p=/macintel/g.test(r)&&_>1),(u||c||d||p)&&(m=!0),{bUseUserAgent:!1,bWin:o,bMac:a,bLinux:s,bAndroid:u,bHarmonyOS:c,bChromeOS:l,bIE:!1,bEdge:f,bUC:!1,bPlaybook:!1,bBlackBerry:!1,bHuaWeiBrowser:!1,bOpera:h,bFirefox:!1,bChrome:g,bJSDom:!1,biPhone:d,biPad:p,bPad:u&&!e.mobile,bSafari:!1,bMobile:m,strBrowserVersion:v,bHTML5Edition:!0,IEVersion:0,IEMode:0}}(ve,_e,fe)))}pe&&(he||(he=me.userAgent.toLowerCase()),ge||(ge=me.platform.toLowerCase()),de=function(e,t){var r,n=e.toLowerCase(),i=t.toLowerCase(),o=/harmonyos/g.test(n);"linux"==i&&n.indexOf("windows nt")>=0&&(i="harmonyos",o=!0);var a=!o&&/cros/.test(n),s=!o&&/android/g.test(n)||/android/g.test(i),u=/iphone/g.test(n)||/iphone/g.test(i),c=/macintosh/.test(n),l=navigator.maxTouchPoints||0,d=/ipad/g.test(n)||(c||"macintel"==i)&&l>1,f=/ucweb|ucbrowser/g.test(n),h=!f&&/nexus/g.test(n)&&/version\/[\d.]+.*safari\//g.test(n),g=/playbook/g.test(n),m=/hp-tablet/g.test(n),p=/blackberry|bb10/g.test(n),v=/symbian/g.test(n),_=/windows phone/g.test(n),y=/mobile/g.test(n),S=/arm64|aarch64/g.test(n),I=/mips64/g.test(n),b=/huaweibrowser/g.test(n),T=/jsdom/g.test(n),C=g||d||m,w=!C&&!a&&(u||h||p||v||_||s||o||y),E=!w&&!C&&!a,k=E&&/win32|win64|windows/.test(i),A=k&&/win64|x64/.test(n),x=E&&/mac68k|macppc|macintosh|macintel/.test(n),P=E&&/linux/.test(i),D="win64"==i||/wow64|x86_64|win64|x64/.test(n)||S||I,F=/wow64/g.test(n),N=ae,R=/opera|opr/g.test(n),O=/360se/g.test(n),M=/maxthon/g.test(n),L=/tencenttraveler|qqbrowser/g.test(n),B=/the world/g.test(n),U=/metasr/g.test(n),V=/avant/g.test(n),j=/firefox|fxios/g.test(n),G=/gecko/g.test(n),H=!(j||b)&&/edge\/|edga\/|edgios\/|edg\//g.test(n),z=!(p||g||f||R||H||b||T)&&/chrome|crios/g.test(n),K=!1,J=le,Q=0,q=0,Y=le;if(k&&!H&&!j&&!z){var X=n.indexOf("msie "),Z=n.indexOf("trident"),$=n.indexOf("rv:");K=-1!=X||-1!=Z||-1!=$}if(!(x||u||d||k||p||g||h)||f||R||H||K||j||(r=n.match(/version\/([\d.]+).*safari\//))&&(p||g||h||(N=oe,z=ae),Y=r[1]),H){var ee=n.indexOf("edge/");ee>-1?ee+=5:(ee=n.indexOf("edg/"))>-1?ee+=4:(ee=n.indexOf("edga/"))>-1?ee+=5:(ee=n.indexOf("edgios/"))>-1&&(ee+=7),ee>-1&&(r=(Y=n.slice(ee)).indexOf(" "))>-1&&(Y=Y.slice(0,r))}else if(j)if((r=n.indexOf("firefox/"))>-1){var te=(r=n.slice(r+8)).indexOf(" ");te>-1&&(r=r.slice(0,te)),Y=r,(te=r.indexOf("."))>-1&&(r=Y.slice(0,te))}else(u||d)&&(r=n.indexOf("fxios/"))>-1&&(Y=r=(r=n.slice(r+6)).slice(0,r.indexOf(" ")));else if(K){var re=n.indexOf("msie "),ne=n.indexOf("trident"),ie=n.indexOf("rv:");-1!=re?J=r=(r=n.slice(re+5)).slice(0,r.indexOf(";")):-1!=ie?J=r=(r=(r=n.slice(ie+3)).slice(0,r.indexOf(";"))).slice(0,r.indexOf(")")):-1!=ne&&(J=r=(r=n.slice(ne+7)).slice(0,r.indexOf(";"))),Y=r}else if(N)(r=Y.indexOf("."))>-1&&(r=Y.slice(0,r));else if(f)(r=n.indexOf("ucweb"))>-1?Y=n.slice(r+5):(r=n.indexOf("ucbrowser/"))>-1&&(r=(Y=n.slice(r+10)).indexOf(" "))>-1&&(Y=Y.slice(0,r));else if(R)(r=n.indexOf("version/"))>-1?Y=n.slice(r+8):(r=n.indexOf("opr/"))>-1&&(Y=n.slice(r+4));else if(v)(r=n.indexOf("browserng/"))>-1&&(Y=n.slice(r+10));else if(_)(r=n.indexOf("iemobile/"))>-1&&(Y=n.slice(r+9));else if(z){var se=n.indexOf("chrome/");se>-1?(r=(Y=n.slice(se+7)).indexOf(" "))>-1&&(Y=Y.slice(0,r)):(se=n.indexOf("crios/"))>-1&&(r=(Y=n.slice(se+6)).indexOf(" "))>-1&&(Y=Y.slice(0,r)),(r=Y.indexOf("."))>-1&&(r=Y.slice(0,r))}else if(b){var ue=n.indexOf("huaweibrowser");ue>-1&&(r=(Y=n.slice(ue+14)).indexOf(" "))>-1&&(Y=Y.slice(0,r))}else if(T){var ce=n.indexOf("jsdom");ce>-1&&(r=(Y=n.slice(ce+6)).indexOf(" "))>-1&&(Y=Y.slice(0,r))}if(H||K){var de=window.document;de&&de.documentMode?Q=de.documentMode:(Q=5,de.compatMode&&"CSS1Compat"==de.compatMode&&(Q=7)),K&&(q=parseInt(Y))}(x||P)&&(D=!0,x&&(r=n.match(/mac os x (\d+)(_|\.)(\d+)/))&&r.length>3&&(10==r[1]&&r[3]<14||r[1]<10)&&(D=!1)),k||x||P||S||I||(w=!0);var fe=!0;if(K)if(""===J||parseInt(J)>=10){var he=W.Dynamsoft;he&&he.DWT&&he.DWT.IfUseActiveXForIE10Plus&&(fe=ae)}else fe=ae;return{bUseUserAgent:!0,bWin:k,bMac:x,bLinux:P,bMobile:w,bPad:C,bChromeOS:a,bHarmonyOS:o,bArm64:S,bMips64:I,bEmbed:S||I,bAndroid:s,biPhone:u,biPad:d,bWin64:A,bWOW64:F,bOSx64:D,bIE:K,bEdge:H,bChrome:z,bFirefox:j,bSafari:N,bOpera:R,bNexus:h,bUC:f,b360SE:O,bMaxthon:M,bTencentTraveler:L,bTheWorld:B,bMetaSr:U,bAvant:V,bHuaWeiBrowser:b,bJSDom:T,bGecko:G,bHTML5Edition:fe,strBrowserVersion:Y,IEVersion:q,IEMode:Q}}(he,ge));var ye=null===(ue=null===document||void 0===document?void 0:document.location)||void 0===ue?void 0:ue.protocol;function Se(e){return de.bGecko&&"mousewheel"===e?"DOMMouseScroll":e}function Ie(e,t,r){var n=Se(t);e&&e.addEventListener(n,r,!1)}function be(e,t,r){var n=Se(t);e&&e.removeEventListener(n,r,!1)}function Te(e){var t=e||W.event;t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.returnValue=!1,t.cancelBubble=!0}function Ce(e,t){var r=W.document.createEvent("HTMLEvents");r.initEvent(e,oe,oe),t.dispatchEvent&&t.dispatchEvent(r)}ye||(ye="https:"),de.protocol=ye,de.bSSL="https:"===ye,de.bFileSystem="https:"!==ye&&"http:"!==ye;var we,Ee,ke,Ae,xe=W.document,Pe=[],De=Pe.push,Fe=Pe.slice,We=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,Ne=function(){Ee()};function Re(e,t,r,n){var i,o,a,s=t&&t.ownerDocument,u=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==u&&9!==u&&11!==u)return r;if(!n&&((t?t.ownerDocument||t:xe)!==ke&&Ee(t),t=t||ke,11!==u&&(a=We.exec(e))))if(i=a[1]){if(9===u){if(!(o=t.getElementById(i)))return r;if(o.id===i)return r.push(o),r}else if(s&&(o=s.getElementById(i))&&Ae(t,o)&&o.id===i)return r.push(o),r}else{if(a[2])return De.apply(r,t.getElementsByTagName(e)),r;if((i=a[3])&&t.getElementsByClassName)return De.apply(r,t.getElementsByClassName(i)),r}return r}De.apply(Fe.call(xe.childNodes),xe.childNodes),Ee=Re.setDocument=function(e){var t,r=e?e.ownerDocument||e:xe;return r!==ke&&9===r.nodeType&&r.documentElement?(xe!==(ke=r)&&(t=ke.defaultView)&&t.top!==t&&(t.addEventListener?t.addEventListener("unload",Ne,!1):t.attachEvent&&t.attachEvent("onunload",Ne)),Ae=function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},ke):ke},Re.contains=function(e,t){return(e.ownerDocument||e)!==ke&&Ee(e),Ae(e,t)},Re.error=function(e){throw new Error("Syntax error: "+e)},we=Re.getText=function(e){var t,r="",n=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)r+=we(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[n++];)r+=we(t);return r},Ee();var Oe={encodeChars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",decodeChars:[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1]},Me={UTF16ToUTF8:function(e){for(var t,r,n=[],i=e.length,o=0;o0&&a<=127)n.push(e.charAt(o));else if(a>=128&&a<=2047)t=192|a>>6&31,r=128|63&a,n.push(String.fromCharCode(t),String.fromCharCode(r));else if(a>=2048&&a<=65535){t=224|a>>12&15,r=128|a>>6&63;var s=128|63&a;n.push(String.fromCharCode(t),String.fromCharCode(r),String.fromCharCode(s))}}return n.join("")},UTF8ToUTF16:function(e){var t,r,n,i,o=[],a=e.length;for(t=0;t>7&255?6==(r>>5&255)?(i=(31&r)<<6|63&(n=e.charCodeAt(++t)),o.push(String.fromCharCode(i))):14==(r>>4&255)&&(i=(255&(r<<4|(n=e.charCodeAt(++t))>>2&15))<<8|((3&n)<<6|63&e.charCodeAt(++t)),o.push(String.fromCharCode(i))):o.push(e.charAt(t));return o.join("")},encode:function(e){for(var t,r,n,i=this.UTF16ToUTF8(e),o=[],a=0,s=i.length;a>2)),o.push(Oe.encodeChars.charAt((3&t)<<4)),o.push("==");break}if(r=i.charCodeAt(a++),a==s){o.push(Oe.encodeChars.charAt(t>>2)),o.push(Oe.encodeChars.charAt((3&t)<<4|(240&r)>>4)),o.push(Oe.encodeChars.charAt((15&r)<<2)),o.push("=");break}n=i.charCodeAt(a++),o.push(Oe.encodeChars.charAt(t>>2)),o.push(Oe.encodeChars.charAt((3&t)<<4|(240&r)>>4)),o.push(Oe.encodeChars.charAt((15&r)<<2|(192&n)>>6)),o.push(Oe.encodeChars.charAt(63&n))}return o.join("")},encodeArray:function(e){for(var t,r,n,i=[],o=0,a=e.length;o>2)),i.push(Oe.encodeChars.charAt((3&t)<<4)),i.push("==");break}if(r=255&e[o++],o==a){i.push(Oe.encodeChars.charAt(t>>2)),i.push(Oe.encodeChars.charAt((3&t)<<4|(240&r)>>4)),i.push(Oe.encodeChars.charAt((15&r)<<2)),i.push("=");break}n=255&e[o++],i.push(Oe.encodeChars.charAt(t>>2)),i.push(Oe.encodeChars.charAt((3&t)<<4|(240&r)>>4)),i.push(Oe.encodeChars.charAt((15&r)<<2|(192&n)>>6)),i.push(Oe.encodeChars.charAt(63&n))}return i.join("")},decode:function(e,t){for(var r,n,i,o,a=this,s=[],u=0,c=e.length;u>4):s.push(String.fromCharCode(r<<2|(48&n)>>4));do{if(61==(i=255&e.charCodeAt(u++)))return t?s:a.UTF8ToUTF16(s.join(""));i=Oe.decodeChars[i]}while(u>2):s.push(String.fromCharCode((15&n)<<4|(60&i)>>2));do{if(61==(o=255&e.charCodeAt(u++)))return t?s:a.UTF8ToUTF16(s.join(""));o=Oe.decodeChars[o]}while(u=1&&t<=127?r.push(e.charAt(n)):t>2047?(r.push(String.fromCharCode(224|t>>12&15)),r.push(String.fromCharCode(128|t>>6&63)),r.push(String.fromCharCode(128|63&t))):(r.push(String.fromCharCode(192|t>>6&31)),r.push(String.fromCharCode(128|63&t))),n++;return r.join("")},toUTF16:function(e){for(var t,r,n,i=[],o=0,a=e.length;o>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:i.push(e.charAt(o-1));break;case 12:case 13:r=e.charCodeAt(o++),i.push(String.fromCharCode((31&t)<<6|63&r));break;case 14:r=e.charCodeAt(o++),n=e.charCodeAt(o++),i.push(String.fromCharCode((15&t)<<12|(63&r)<<6|63&n))}return i.join("")}},Be="undefined"!=typeof self?self:global,Ue=Be.btoa?function(e){return Be.btoa(e)}:function(e){for(var t,r,n=String(e),i=0,o=Oe.encodeChars,a="";n.charAt(0|i)||(o="=",i%1);a+=o.charAt(63&t>>8-i%1*8)){if((r=n.charCodeAt(i+=3/4))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");t=t<<8|r}return a},Ve=Be.atob?function(e){return Be.atob(e)}:function(e){var t=String(e).replace(/[=]+$/,"");if(t.length%4==1)throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,o=0,a="";n=t.charAt(o++);~n&&(r=i%4?64*r+n:n,i++%4)?a+=String.fromCharCode(255&r>>(-2*i&6)):0)n=Oe.encodeChars.indexOf(n);return a};function je(e){if(null==e||"object"!=b(e))return e;var t,r,n;if(e instanceof Date)return(t=new Date).setTime(e.getTime()),t;if(e instanceof Array){for(t=[],n=e.length,r=0;r=0&&!i;e--)G(t=n[e])&&t&&(r=t+"/"+r,i="/"===t.charAt(0));return(i?"/":"")+ot(tt(r.split("/"),(function(e){return!!e})),!i).join("/")||"."}},{key:"join",value:function(){return at(tt(Q(arguments),(function(e){return e&&G(e)})).join("/"))}},{key:"relative",value:function(e,t){e=at(e),t=at(t);var r,n,i=tt(e.split("/"),(function(e){return!!e})),o=[],a=tt(t.split("/"),(function(e){return!!e})),s=Math.min(i.length,a.length);for(r=0;r=0&&e.indexOf(t,r)===r}function mt(e){return null==e?le:String.prototype.trim.call(e)}function pt(e){var t;if(e)for(t in e)if(!M(t))return!1;return!0}function vt(e){return G(e)?e.replace(/[^\x20-\x7E]/g,""):e}function _t(e,t,r){return e.replace(new RegExp(t,"gi"),r)}function yt(e){return e.charAt(0).toUpperCase()+e.substr(1)}var St,It="none",bt={getOffset:function(e,t,r){var n,i;e=e||W.event;for(var o,a,s=r||e.target,u=0,c=0,l=0,d=0,f=!1,h=W.document;s&&!isNaN(s.offsetLeft)&&!isNaN(s.offsetTop);)a=s.scrollLeft,o=s.scrollTop,"BODY"===s.tagName?f?(a=0,o=0):(a|=null===(n=h.documentElement)||void 0===n?void 0:n.scrollLeft,o|=null===(i=h.documentElement)||void 0===i?void 0:i.scrollTop):"fixed"===s.style.position&&(f=!0),u+=s.offsetLeft-a,c+=s.offsetTop-o,s=s.offsetParent;return t&&(l=t.Left,d=t.Top),{x:u=e.clientX-u-l,y:c=e.clientY-c-d}},getElDimensions:function(e,t){var r,n;return e?(r=e.style.display,e.style.display="",n=t?{offsetTop:e.offsetTop,offsetLeft:e.offsetLeft,offsetWidth:e.offsetWidth,offsetHeight:e.offsetHeight}:{clientTop:e.clientTop,clientLeft:e.clientLeft,clientWidth:e.clientWidth?e.clientWidth:parseInt(e.style.width)?parseInt(e.style.width):0,clientHeight:e.clientHeight?e.clientHeight:parseInt(e.style.height)?parseInt(e.style.height):0},e.style.display=r,n):{offsetTop:0,offsetLeft:0,offsetWidth:0,offsetHeight:0}}};function Tt(e){return document.getElementById(e)}function Ct(e){var t=G(e)?Tt(e):e;t&&(t.length>0&&(t=t[0]),t.style.display=It)}function wt(e){var t=G(e)?Tt(e):e;t&&(t.length>0&&(t=t[0]),t.style.display=le)}function Et(e){var t=G(e)?Tt(e):e;t&&(t.length>0&&(t=t[0]),t.style.display===It?t.style.display=le:t.style.display=It)}function kt(e){if(e)for(;e.firstChild;)e.removeChild(e.firstChild)}function At(e){return encodeURIComponent(String(e))}function xt(e){return decodeURIComponent(e.replace(/\+/g," "))}if(window.trustedTypes){try{St=window.trustedTypes.createPolicy("d-create-script",{createScriptURL:function(e){return e}})}catch(RJ){}}function Pt(e){return St?St.createScriptURL(e):e}var Dt=!0,Ft=document,Wt=Ft&&Ft.documentElement,Nt=Ft.getElementsByTagName("head")[0]||Wt,Rt=Ft.createElement("script").readyState?function(e,t){var r=e.onreadystatechange;e.onreadystatechange=function(){var n=e.readyState;if("loaded"===n||"complete"===n){e.onreadystatechange=null,r&&r();t.call(this,{type:"load",path:[e]})}else"loading"===n||t.call(this,{type:"error",path:[e]})}}:function(e,t){e.addEventListener("load",t,ae),e.addEventListener("error",t,ae)};function Ot(e,t,r){return Mt(e,t,!1,r)}function Mt(e,t,r,n){var i,o,a=n;if(j(a)||(a=function(){}),G(e)&&e!=le)return i=Ft.createElement("script"),o=["",e].join(le),i.src=Pt(o),t&&(i.async=Dt),i.charset="utf-8",Rt(i,a),r?Nt.appendChild(i):Nt.insertBefore(i,Nt.firstChild),i;a()}function Lt(e,t,r){return Bt(e,t,!1,r)}function Bt(e,t,r,n){var i=n;if(j(i)||(i=function(){}),de.bJSDom)i("ok");else if(J(e)){var o=e.length,a=function(e){e&&"load"==e.type?o--:(e&&"error"==e.type&&te(["Failed to load resource: ",e.target.src,"."].join("")),i()),o<=0&&i("ok")};o<=0?i("ok"):se(e,(function(e){Mt(e,t,r,a)}))}else i()}function Ut(e,t){return Vt(e,!1,t)}function Vt(e,t,r){var n,i=r;if(j(i)||(i=!1),G(e)&&e!=le){if(!de.bJSDom)return(n=Ft.createElement("link")).href=Pt(e),n.rel="stylesheet",n.async=Dt,i&&Rt(n,i),t?Nt.appendChild(n):Nt.insertBefore(n,Nt.firstChild),n;i&&i()}else i&&i()}function jt(e,t){return Gt(e,!1,t)}function Gt(e,t,r){if(de.bJSDom)r&&r("ok");else if(J(e)){var n=e.length,i=function(e){e&&"load"==e.type&&n--,e&&"load"!=e.type&&(e&&"error"==e.type&&te(["Failed to load resource: ",e.target.href,"."].join("")),r()),n<=0&&r("ok")};se(e,(function(e){Vt(e,t,i)}))}else r&&r()}function Ht(e){var t,r;if(!de.bJSDom){var n=document;if(n&&G(r=e.body)&&r!=le){(t=n.createElement("script")).charset="utf-8",de.bIE?t.text=r:t.appendChild(n.createTextNode(r)),e.language?t.language=e.language:t.language="javascript",e.type?t.type=e.type:t.type="text/javascript";var i=n&&n.documentElement,o=n.getElementsByTagName("head")[0]||i;o.insertBefore(t,o.firstChild)}}}function zt(e){Ht({body:e})}function Kt(e){Ht({body:e,language:"vbscript",type:"text/vbscript"})}function Jt(e){return null!=e&&e==e.window}var Qt,qt,Yt,Xt=function(){return w((function e(){I(this,e),this.nil=undefined,this.bNode=!1,this.noop=function(){},this.mix=Qe,this.clone=je,this.keys=Object.keys,this.now=Ke,this.getFormatedNow=O,this.getRandom=Je,this.guid=He,this.get=Tt,this.show=wt,this.hide=Ct,this.toggle=Et,this.empty=kt,this.stringify=W.JSON.stringify,this.parse=W.JSON.parse,this.isDef=L,this.isUndef=M,this.isUndefined=M,this.isNull=B,this.isNaN=isNaN,this.isFunction=j,this.isString=G,this.isObject=H,this.isBoolean=z,this.isNumber=K,this.isArray=J,this.type=V,this.isPlainObject=ct,this.isDOM=dt,this.isDOMInBody=ft,this.each=se,this.getLogger=Z,this.setLogger=$,this.log=ee,this.error=te,this.warn=re,this.info=ne,this.filter=tt,this.indexOf=rt,this.uniq=nt,this.startsWith=ht,this.endsWith=gt,this.replaceAll=_t,this.upperCaseFirst=yt,this.removeNonPrintableChar=vt,this.trim=mt,this.makeArray=Q,this.isEmptyObject=pt,this.Path=new st,this.DOM=bt,this.isWindow=Jt,this.obj={customEvent:ce},this.addEventListener=Ie,this.removeEventListener=be,this.stopPropagation=Te,this.fireEvent=Ce,this.base64=Me,this.utf8=Le,this.btoa=Ue,this.atob=Ve,this.asyncQueue=ie,this.sizzle=Re,this.toggleWakeLock=Ze,this.getWakeLock=$e,this.urlEncode=At,this.urlDecode=xt,this.scriptOnload=Rt,this.addAllCss=Gt,this.getAllCss=jt,this.addCss=Vt,this.getCss=Ut,this.addScripts=Bt,this.getScripts=Lt,this.addScript=Mt,this.getScript=Ot,this.addJS=zt,this.addVBS=Kt}),[{key:"debug",get:function(){return X.debug},set:function(e){X.debug=e}},{key:"showConsoleError",get:function(){return X.debug},set:function(e){X.showConsoleError=e}}])}(),Zt=new Xt,$t=20241120,er="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},tr=!!("object"==("undefined"==typeof global?"undefined":_(global))&&global.process&&global.process.release&&global.process.release.name&&"undefined"==typeof HTMLCanvasElement),rr=er.Dynamsoft;function nr(e){return Math.floor(e)}function ir(e,t,r){return(t=T(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function or(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function ar(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}function sr(e){var t,r,n="0x";if(/^(rgb|RGB)/.test(e)){var i=e.replace(/[^\d,.]/g,"").split(",");for(r=0;r<3;++r)1==(t=Number(i[r]).toString(16)).length&&(t="0"+t),n+=t;4==i.length?(1==(t=Math.round(255*Number(i[r])).toString(16)).length&&(t="0"+t),n+=t):n+="ff"}else if("transparent"==e)n+="00000000";else if(/^#[0-9a-fA-F]{6}$/.test(e))n+=e.replace(/#/,"")+"ff";else if(/^#[0-9a-fA-F]{3}$/.test(e)){for(r=0;r<3;++r)n+=e[r]+e[r];n+="ff"}else n="-1";return Number(n)}function ur(e){if(e>4294967295||e<0)return null;var t;if(de.bHTML5Edition)t="rgba("+Math.floor(e/16777216)+","+Math.floor(e/65536)%256+","+Math.floor(e/256)%256+","+e%256/255+")";else if(e%256==0)t="transparent";else{for(t=Math.floor(e/256).toString(16);6!=t.length;)t="0"+t;t="#"+t}return t}function cr(e){var t,r=(e=e||window.event).wheelDelta,n=e.detail;return r&&(t=r/120),n&&(t=-(n%3==0?n/3:n)),t}rr?rr.Lib||(rr.Lib={}):(rr={Lib:{},DWT:{}},er.Dynamsoft=rr),rr.navInfoSync=de,Qt=Zt.mix(rr.Lib,Zt),(qt=rr).DWT||(qt.DWT={}),qt.DWT.LTS||(qt.DWT.LTS={}),qt.Lib.UI||(qt.Lib.UI={}),qt.Lib.html5||(qt.Lib.html5={}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,le)}),Yt={registedClass:[],registedObjs:[]};var lr={LEFT:0,MIDDLE:1,RIGHT:2};function dr(e){var t=e||window.event;return null==t.which?t.button<2?lr.LEFT:4==t.button?lr.MIDDLE:lr.RIGHT:t.which<2?lr.LEFT:2==t.which?lr.MIDDLE:lr.RIGHT}var fr,hr,gr=/[\-#$\^*()+\[\]{}|\\,.?\s]/g,mr={"&":"&",">":">","<":"<"," ":" ","`":"`","/":"/",""":'"',"'":"'"},pr={};function vr(e){return e.replace(/\\u([a-f\d]{4})/gi,(function(e,t){return String.fromCharCode(parseInt(t,16))}))}function _r(e){return(e+"").replace(function(){if(fr)return fr;var e=le;return Zt.each(mr,(function(t){e+=t+"|"})),e=e.slice(0,-1),fr=new RegExp(e,"g")}(),(function(e){return pr[e]}))}function yr(e){return e.replace(gr,"\\$&")}function Sr(e){return e.replace(function(){if(hr)return hr;var e=le;return Zt.each(pr,(function(t){e+=t+"|"})),e+="&#(\\d{1,5});",hr=new RegExp(e,"g")}(),(function(e,t){return mr[e]||String.fromCharCode(+t)}))}Zt.each(mr,(function(e,t){pr[e]=t}));var Ir,br,Tr=window;Tr&&Zt.isFunction(Tr.__zone_symbol__Promise)&&(br=Tr.__zone_symbol__Promise);var Cr=w((function OJ(){I(this,OJ)}));function wr(e){return null==(e=e||window.event).which?e.which=e.button<2?1:4==e.button?2:3:e.which=e.which<2?1:2==e.which?2:3,e}function Er(e,t){return e.currentStyle?e.currentStyle[t]:window.getComputedStyle?document.defaultView.getComputedStyle(e,null)[t]:null}Ir=self&&self.Promise?self.Promise:Tr&&Tr.Promise?Tr.Promise:Cr,br||(br=Ir);function kr(e){var t=b(e);return null==e||"object"!==t&&"function"!==t}function Ar(e,t,r,n){t=t||"&",r=r||"=",Zt.isUndefined(n)&&(n=oe);var i=[];return Zt.each(e,(function(e,o){var a=Zt.urlEncode(o);kr(e)?(i.push(a),Zt.isDef(e)&&i.push(r,Zt.urlEncode(e+le)),i.push(t)):Zt.isArray(e)&&e.length&&Zt.each(e,(function(e){kr(e)&&(i.push(a,n?Zt.urlEncode("[]"):le),Zt.isDef(e)&&i.push(r,Zt.urlEncode(e+le)),i.push(t))}))})),i.pop(),i.join(le)}function xr(e,t,r){if(!Zt.isString(e)||!(e=Zt.trim(e)))return{};t=t||"&",r=r||"=";for(var n,i,o,a={},s=Zt.urlDecode,u=e.split(t),c=0,l=u.length;c","<":"<","`":"`","/":"/",""":'"',"'":"'"},(function(e,t){}));var Pr,Dr=w((function MJ(e){I(this,MJ),ir(this,"tagName",void 0),ir(this,"attr",void 0),ir(this,"childNodes",void 0),this.tagName=e,this.attr={},this.childNodes=[]})),Fr=w((function LJ(e){I(this,LJ),ir(this,"value",void 0),this.value=e||""})),Wr=new WeakSet,Nr=function(){return w((function e(){I(this,e),or(this,Wr),ir(this,"stack",void 0),ir(this,"stacks",void 0),this.stack=[],this.stacks=[]}),[{key:"getStacks",value:function(){return this.stacks}},{key:"receiveInput",value:function(e){var t=this.stack;if("startTag"===e.type)t.push(new Dr(e.value));else if("attr"===e.type){var r,n,i=e.value,o=i.indexOf("=");o>-1?(r=i.substring(0,o),n='"'===i.charAt(o+1)||"'"===i.charAt(o+1)?i.substring(o+2,i.length-1):i.substring(o+1),t[t.length-1].attr[r]=n):"readonly"!==i&&"disabled"!==i&&"checked"!==i||(t[t.length-1].attr[i]=i)}else if("text"===e.type)t.length?t[t.length-1].childNodes.push(new Fr(e.value)):this.stacks.push(new Fr(e.value));else if("endTag"===e.type){var a=t.pop();t.length?t[t.length-1].childNodes.push(a):this.stacks.push(a)}}},{key:"getOutPutHtml",value:function(){var e,t=document.createDocumentFragment(),r=this.stacks;for(e=0;e"===o)return ar(Vr,this,Gr).call(this,"endTag",this.thisStartTagName),this.token=[],e.state=this.start,e.curIndex+=2,e}return e.attrQuoteChar="",e.attrStatus=Pr.None,e.state=this.attrState,e}return">"===n?(this.thisStartTagName=this.token.join("").substring(1),ar(Vr,this,Gr).call(this,"startTag",this.thisStartTagName.toLowerCase()),this.token=[],e.state=this.start,ar(Vr,this,Hr).call(this)&&e.curIndex++,e):void 0}},{key:"attrState",value:function(e){var t=e.curIndex,r=e.allChars,n=r[t],i=!1,o=!1;if(e.attrStatus==Pr.AttrSplite?n.match(/[0-9|^<&;#]/)&&(i=!0):e.attrStatus!=Pr.AttrKey&&e.attrStatus!=Pr.AttrKeyQuoteStart||(n.match(/[0-9]/)||"."===n||"-"===n)&&(o=!0),n.match(/[:|a-z|A-Z|_]/)||i||o){if(e.attrStatus==Pr.None||e.attrStatus==Pr.AttrKey||e.attrStatus==Pr.AttrKeyQuoteStart)return this.token.push(n),e.state=this.attrState,e.attrStatus==Pr.None&&(e.attrStatus=Pr.AttrKey),e;if(e.attrStatus==Pr.AttrSpace){var a=this.token.join("");return"readonly"!==a&&"disabled"!==a&&"checked"!==a||ar(Vr,this,Gr).call(this,"attr",a),this.token=[n],e.state=this.attrState,e.attrStatus=Pr.AttrKey,e}var s;if(e.attrStatus==Pr.AttrSplite)for(s=t;s"===u)c=!0;else if("/"===u){if(s+2"===r[s+2]&&(c=!0,l=!0)}if(c)return e.curIndex=s,e.attrStatus=Pr.None,e.attrQuoteChar="",ar(Vr,this,Gr).call(this,"attr",this.token.join("")),this.token=[],e.state=this.attrState,">"===u&&ar(Vr,this,Hr).call(this)&&(this.token=[],e.curIndex++,e.state=this.start),l&&(ar(Vr,this,Gr).call(this,"endTag",this.thisStartTagName),this.token=[],e.curIndex+=2,e.state=this.start),e}}if("="===n&&(e.attrStatus==Pr.AttrKey||e.attrStatus==Pr.AttrKeyQuoteEnd||e.attrStatus==Pr.AttrSpace))return this.token.push(n),e.state=this.attrState,e.attrStatus=Pr.AttrSplite,e;if(n.match(/['"]/)){if(e.attrStatus==Pr.AttrValueQuoteStart||e.attrStatus==Pr.AttrKeyQuoteStart){if(n===e.attrQuoteChar)return e.attrStatus==Pr.AttrValueQuoteStart?(this.token.push(n),ar(Vr,this,Gr).call(this,"attr",this.token.join("")),this.token=[],e.attrStatus=Pr.None):e.attrStatus=Pr.AttrKeyQuoteEnd,e.attrQuoteChar="",e.state=this.attrState,e;this.token.push(n)}else e.attrStatus==Pr.None?e.attrStatus=Pr.AttrKeyQuoteStart:e.attrStatus==Pr.AttrSplite&&(e.attrStatus=Pr.AttrValueQuoteStart,this.token.push(n)),e.attrQuoteChar=n;return e.state=this.attrState,e}if(e.attrStatus==Pr.AttrValueQuoteStart){if(this.token.push(n),"\\"===n&&t"===r[t+1])return ar(Vr,this,Gr).call(this,"attr",this.token.join("")),ar(Vr,this,Gr).call(this,"endTag",this.thisStartTagName),this.token=[],e.state=this.start,e.curIndex++,e;return this.token.push(n),e.state=this.attrState,e}return">"===n?(ar(Vr,this,Gr).call(this,"attr",this.token.join("")),this.token=[],ar(Vr,this,Hr).call(this),e.state=this.start,e):(e.state=this.attrState,e)}},{key:"endTagState",value:function(e){var t=e.allChars[e.curIndex];if(t.match(/[a-zA-Z]/))return this.token.push(t.toLowerCase()),e.state=this.endTagState,e;if(">"===t){var r=this.token.join("").toLowerCase();return r=r.replace("0&&function(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;){var r=t.firstChild;t.removeChild(r),e.appendChild(r)}}(e,n)}}var Kr="ds-dwt-loaderBar",Jr="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjAiIHdpZHRoPSIxMDBweCIgaGVpZ2h0PSIxMDBweCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxnPjxjaXJjbGUgY3g9IjE2IiBjeT0iNjQiIHI9IjE2IiBmaWxsPSIjZmU4ZTE0Ii8+PGNpcmNsZSBjeD0iMTYiIGN5PSI2NCIgcj0iMTQuMzQ0IiBmaWxsPSIjZmU4ZTE0IiB0cmFuc2Zvcm09InJvdGF0ZSg0NSA2NCA2NCkiLz48Y2lyY2xlIGN4PSIxNiIgY3k9IjY0IiByPSIxMi41MzEiIGZpbGw9IiNmZThlMTQiIHRyYW5zZm9ybT0icm90YXRlKDkwIDY0IDY0KSIvPjxjaXJjbGUgY3g9IjE2IiBjeT0iNjQiIHI9IjEwLjc1IiBmaWxsPSIjZmU4ZTE0IiB0cmFuc2Zvcm09InJvdGF0ZSgxMzUgNjQgNjQpIi8+PGNpcmNsZSBjeD0iMTYiIGN5PSI2NCIgcj0iMTAuMDYzIiBmaWxsPSIjZmU4ZTE0IiB0cmFuc2Zvcm09InJvdGF0ZSgxODAgNjQgNjQpIi8+PGNpcmNsZSBjeD0iMTYiIGN5PSI2NCIgcj0iOC4wNjMiIGZpbGw9IiNmZThlMTQiIHRyYW5zZm9ybT0icm90YXRlKDIyNSA2NCA2NCkiLz48Y2lyY2xlIGN4PSIxNiIgY3k9IjY0IiByPSI2LjQzOCIgZmlsbD0iI2ZlOGUxNCIgdHJhbnNmb3JtPSJyb3RhdGUoMjcwIDY0IDY0KSIvPjxjaXJjbGUgY3g9IjE2IiBjeT0iNjQiIHI9IjUuMzc1IiBmaWxsPSIjZmU4ZTE0IiB0cmFuc2Zvcm09InJvdGF0ZSgzMTUgNjQgNjQpIi8+PGFuaW1hdGVUcmFuc2Zvcm0gYXR0cmlidXRlTmFtZT0idHJhbnNmb3JtIiB0eXBlPSJyb3RhdGUiIHZhbHVlcz0iNDUgNjQgNjQ7OTAgNjQgNjQ7MTM1IDY0IDY0OzE4MCA2NCA2NDsyMjUgNjQgNjQ7MjcwIDY0IDY0OzMxNSA2NCA2NDswIDY0IDY0IiBjYWxjTW9kZT0iZGlzY3JldGUiIGR1cj0iNzIwbXMiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIj48L2FuaW1hdGVUcmFuc2Zvcm0+PC9nPjwvc3ZnPg==";function Qr(e){var t,r,n,i="",o="230px",a="240px",s="",u="";return e&&(e.background&&(i=";background:"+e.background),e.width&&(o=e.width),e.height&&(a=e.height),e.imageSource&&(t=e.imageSource)),t||(t=Jr),n=parseInt(o)/2,Zt.isNumber(n)&&n>0&&(u=";width:"+n+"px"),r=parseInt(a)/2,Zt.isNumber(r)&&r>0&&(s=";height:"+r+"px"),['
'].join("")}var qr,Yr=window,Xr=document,Zr=5e5;function $r(e,t){for(var r=0;r=1e3)Zt.error("Too many modal dialogs.");else{if((r=Xr.createElement("div")).style.zIndex="10000",r.className="dynamsoft-backdrop",1==t?(r.style.left=0,r.style.top=0,r.style.position="absolute"):(r.style.left=0,r.style.top=0,r.style.width="100%",r.style.height="100%",r.style.position="fixed"),Xr.createEvent&&Zt.addEventListener(r,"click",(function(t){if(e.dispatchEvent){var r=tn(t);e.dispatchEvent(r)}})),e.parentNode.insertBefore(r,e.nextSibling),e._dlgInfo.mask=r,e.bTopmost){var o=501e3;e._dlgInfo.mask&&(e._dlgInfo.mask.style.zIndex=o),e.style.zIndex=501001}n.push(e),i._updateStacking(t)}},removeDialog:function(e){var t,r,n,i=this;n=e.bTopmost?i.pendingDialogTopmostStack:i.pendingDialogStack,-1!=(t=Zt.isArray(n)?Zt.indexOf(e,n):-1)&&(n.splice(t,1),(r=e._dlgInfo.mask).parentNode&&r.parentNode.removeChild(r),e._dlgInfo.mask=null,i._updateStacking())}};function cn(e,t){var r,n,i,o,a,s,u=this,c=!0,l=1==t?"absolute":"fixed",d="50%",f="50%",h="",g="",m=null;if(u._dlgInfo&&u._dlgInfo.styleConfig){var p=u._dlgInfo.styleConfig;Zt.isString(p.position)&&(l=p.position,c=!1),(Zt.isString(p.left)||Zt.isNumber(p.left))&&(f=p.left,c=!1),(Zt.isString(p.top)||Zt.isNumber(p.top))&&(d=p.top,c=!1),(Zt.isString(p.width)||Zt.isNumber(p.width))&&(h=p.width,c=!1),(Zt.isString(p.height)||Zt.isNumber(p.height))&&(g=p.height,c=!1),Zt.isString(p.transform)&&(m=p.transform,c=!1)}u.open?Zt.error("showDialog called on open dialog."):(u.open=oe,u.removeAttribute("closed"),u.setAttribute("open","open"),c?r=de.bIE&&"fixed"==l?{display:"block",position:"fixed",top:"35%",margin:"0 auto",left:0,right:0}:{display:"block",position:l,left:"50%",top:"50%",transform:"translate(-50%,-50%)"}:(r={display:"block",position:l,left:f,top:d,width:h,height:g},m&&(r.transform=m)),"DIALOG"==u.tagName?(de.bIE?r.margin="0 auto":r.margin="0",r.broderRadius="6px",r.boxShadow="2px 2px 0 0 rgba(0,0,0,.05)",r.webkitBoxSizing="border-box",r.boxSizing="border-box"):(r.border="0",de.bIE?r.margin="0 auto":r.margin="0",r.webkitBoxSizing="border-box",r.boxSizing="border-box"),Zt.mix(u.style,r),en(u)&&(n=u,s=((null===(i=Xr.body)||void 0===i?void 0:i.scrollTop)||(null===(o=Xr.documentElement)||void 0===o?void 0:o.scrollTop)||0)+((Yr.innerHeight?Yr.innerHeight:null===(a=Xr.documentElement)||void 0===a?void 0:a.clientHeight)-n.offsetHeight)/2,n.style.top=s+"px",n._dlgInfo.isTopOverridden=oe),e&&(u._dlgInfo.modal=oe,un.pushDialog(u,t)))}function ln(e){var t=this;return t.open||Zt.error("closeDialog called on closed dialog."),t.open=ae,t.removeAttribute("open"),t.setAttribute("closed","closed"),t.style.display="none",void 0!==e&&(t.returnValue=e),t._dlgInfo.isTopOverridden&&(t.style.top="auto"),t._dlgInfo.modal&&un.removeDialog(t),t.returnValue}function dn(e){Zt.isNumber(e.opacity)?un.opacity=e.opacity:un.opacity=.1,Zt.isNumber(e.grayHex)?un.grayHex=e.grayHex:un.grayHex=128}function fn(e){var t,r,n,i;if(!sn.dlgMask){var o,a,s,u,c=!1;if(e){if(u={},(Zt.isString(e.top)||Zt.isNumber(e.top))&&(u.top=e.top),(Zt.isString(e.left)||Zt.isNumber(e.left))&&(u.left=e.left),Zt.isString(e.position)&&(u.position=e.position),e.confined)document.getElementsByClassName("dwt-viewer-imageEditor-fullScreen")[0]||(c=e.confined);(Zt.isString(e.width)||Zt.isNumber(e.width))&&(t=e.width),(Zt.isString(e.height)||Zt.isNumber(e.height))&&(r=e.height),Zt.isString(e.background)&&(n=e.background),Zt.isString(e.imageSource)&&(i=e.imageSource),dn(e),c&&e.wrapperEl&&(a=e.wrapperEl,Zt.isString(a)&&(a=Xr.getElementById(a)))}if(!i){var l;if(window&&window.Dynamsoft){var d=window.Dynamsoft.DWT;d&&d.CustomizableDisplayInfo&&(l=d.CustomizableDisplayInfo)}l?(de.bIE&&Zt.isString(l.loaderBarSourceIE)&&""!=l.loaderBarSourceIE&&(i=l.loaderBarSourceIE),!i&&Zt.isString(l.loaderBarSource)&&""!=l.loaderBarSource&&(i=l.loaderBarSource)):i=Jr}if(a&&(s=a.getBoundingClientRect(),a.style.position="relative"),o=Xr.createElement("div")){var f;if(o.className="dynamsoft-dialog-wrap",zr(o,Qr({width:t,height:r,backgroundColor:n,imageSource:i})),a)a.appendChild(o),o.style.position="absolute",o.style.top="50%",o.style.left="50%",o.style.transform="translate(-50%, -50%)";else null===(f=Xr.body)||void 0===f||f.appendChild(o);c&&s&&(window.onresize?sn.preOnresize=window.onresize:sn.preOnresize=!1,window.onscroll?sn.preOnscroll=window.onscroll:sn.preOnscroll=!1),sn.dlgMask=o,an.setup(o,c),u&&(o._dlgInfo.styleConfig=u),a&&(o._dlgInfo.wrapperEl=a),o.showModal()}}}function hn(){var e=sn.dlgMask;if(e){var t;if(e.close(),e._dlgInfo&&e._dlgInfo.wrapperEl)e._dlgInfo.wrapperEl.removeChild(e),e._dlgInfo.wrapperEl=null;else null===(t=Xr.body)||void 0===t||t.removeChild(e);sn.dlgMask=!1}sn.preOnresize?window.onresize=sn.preOnresize:window.onresize=null,sn.preOnresize=!1,sn.preOnscroll?window.onscroll=sn.preOnscroll:window.onscroll=null,sn.preOnscroll=!1}an={setup:function(e,t){e.show=cn.bind(e,ae,t),e.showModal=cn.bind(e,oe,t),e.close=ln.bind(e),e._dlgInfo={}}},sn={dlgMask:!1,preOnresize:!1,preOnscroll:!1};var gn=function(){return w((function e(t){I(this,e),ir(this,"div",void 0),ir(this,"container",void 0),ir(this,"docElem",void 0),ir(this,"opacity",void 0),ir(this,"cssFloat",void 0),ir(this,"clearCloneStyle",void 0),ir(this,"boxSizing",void 0),ir(this,"pixelPositionVal",void 0),ir(this,"pixelMarginRightVal",void 0),ir(this,"boxSizingReliableVal",void 0),ir(this,"pixelBoxStylesVal",void 0),ir(this,"reliableHiddenOffsetsVal",void 0),ir(this,"reliableMarginRightVal",void 0),ir(this,"reliableMarginLeftVal",void 0),ir(this,"leadingWhitespace",void 0),ir(this,"tbody",void 0),ir(this,"htmlSerialize",void 0);var r=t.createElement("div"),n=t.createElement("div");if(n.style){this.div=n,this.container=r,this.docElem=t.documentElement,n.textContent=" ";var i=document.createElement("link");n.appendChild(i);var o=document.createElement("table");n.appendChild(o);var a=document.createElement("a");a.href="/a",n.appendChild(a);var s=document.createElement("input");for(s.type="checkbox",n.appendChild(s),this.leadingWhitespace=3===n.firstChild.nodeType,this.tbody=!n.getElementsByTagName("tbody").length,this.htmlSerialize=!!n.getElementsByTagName("link").length,n.style.cssText="float:left;opacity:.5",this.opacity="0.5"===n.style.opacity,this.cssFloat=!!n.style.cssFloat,n.style.backgroundClip="content-box",n.cloneNode(!0).style.backgroundClip="",this.clearCloneStyle="content-box"===n.style.backgroundClip,(r=document.createElement("div")).style.cssText="border:0;width:60px;height:0;top:0;left:-11111px;padding:0;margin-top:1px;position:absolute";n.firstChild;)n.removeChild(n.firstChild);r.appendChild(n),this.boxSizing=""===n.style.boxSizing||""===n.style.MozBoxSizing||""===n.style.WebkitBoxSizing}}),[{key:"reliableHiddenOffsets",value:function(){return null==this.pixelPositionVal&&this.computeStyleTests(),this.reliableHiddenOffsetsVal}},{key:"boxSizingReliable",value:function(){return null==this.pixelPositionVal&&this.computeStyleTests(),this.boxSizingReliableVal}},{key:"pixelBoxStyles",value:function(){return null==this.pixelPositionVal&&this.computeStyleTests(),this.pixelBoxStylesVal}},{key:"pixelMarginRight",value:function(){return null==this.pixelPositionVal&&this.computeStyleTests(),this.pixelMarginRightVal}},{key:"pixelPosition",value:function(){return null==this.pixelPositionVal&&this.computeStyleTests(),this.pixelPositionVal}},{key:"reliableMarginRight",value:function(){return null==this.pixelPositionVal&&this.computeStyleTests(),this.reliableMarginRightVal}},{key:"reliableMarginLeft",value:function(){return null==this.pixelPositionVal&&this.computeStyleTests(),this.reliableMarginLeftVal}},{key:"roundPixelMeasures",value:function(e){return Math.round(parseFloat(e))}},{key:"computeStyleTests",value:function(){var e,t,r=this.div;if(this.docElem&&this.docElem.appendChild(this.container),r.style.cssText="-webkit-box-sizing:border-box;box-sizing:border-box;overflow:scroll;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:60%",this.pixelPositionVal=this.boxSizingReliableVal=this.reliableMarginLeftVal=this.pixelBoxStylesVal=!1,this.pixelMarginRightVal=this.reliableMarginRightVal=!0,window.getComputedStyle)return t=window.getComputedStyle(r),this.pixelPositionVal="1%"!==(t||{}).top,this.reliableMarginLeftVal="2px"===(t||{}).marginLeft,this.boxSizingReliableVal="4px"===(t||{width:"4px"}).width,r.style.marginRight="50%",this.pixelMarginRightVal="4px"===(t||{marginRight:"4px"}).marginRight,(e=r.appendChild(document.createElement("div"))).style.cssText=r.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",e.style.marginRight=e.style.width="0",r.style.width="1px",this.reliableMarginRightVal=!parseFloat((window.getComputedStyle(e)||{}).marginRight),r.style.right="60%",this.pixelBoxStylesVal=36===this.roundPixelMeasures(t.right),r&&r.removeChild(e),void(r=null);if(r.style.display="none",this.reliableHiddenOffsetsVal=0===r.getClientRects().length,this.reliableHiddenOffsetsVal){r.style.display="";var n=document.createElement("table"),i=document.createElement("tr"),o=document.createElement("td");i.appendChild(o);var a=document.createElement("td");a.textContent="t",i.appendChild(a),n.appendChild(i),r.appendChild(i),r.childNodes[0].style.borderCollapse="separate",(e=r.getElementsByTagName("td"))[0].style.cssText="margin:0;border:0;padding:0;display:none",this.reliableHiddenOffsetsVal=0===e[0].offsetHeight,this.reliableHiddenOffsetsVal&&(e[0].style.display="",e[1].style.display="none",this.reliableHiddenOffsetsVal=0===e[0].offsetHeight)}this.docElem&&this.docElem.removeChild(this.container)}},{key:"createHTMLDocument",get:function(){if(document.implementation){var e=document.implementation.createHTMLDocument("").body;return e.innerHTML="
",2===e.childNodes.length}return!1}}])}(),mn=new gn(document),pn=mn.docElem;Zt.sizzle;var vn,_n,yn=/^(top|right|bottom|left)$/,Sn=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,In=new RegExp("^("+Sn+")(?!px)[a-z%]+$","i"),bn=new RegExp("^("+Sn+")(.*)$","i");window.getComputedStyle?vn=function(e){var t,r;return(r=(t=Zt.isFunction(e.getEL)?e.getEL():e).ownerDocument.defaultView)&&r.opener||(r=window),r.getComputedStyle(t)}:pn&&pn.currentStyle&&(vn=function(e){return e.currentStyle});var Tn=/^--/,Cn="[\\x20\\t\\r\\n\\f]",wn=new RegExp("^"+Cn+"+|((?:^|[^\\\\])(?:\\\\.)*)"+Cn+"+$","g"),En=["Top","Right","Bottom","Left"],kn=new RegExp(En.join("|"),"i");window.getComputedStyle?_n=function(e,t,r){var n,i,o,a,s=Tn.test(t),u=e.style;return(r=r||vn(e))&&(a=r.getPropertyValue(t)||r[t],s&&a&&(a=a.replace(wn,"$1")||undefined),""!==a||function(e){return Gn.contains(e.ownerDocument,e)}(e)||(a=Qn(e,t)),!mn.pixelBoxStyles()&&In.test(a)&&kn.test(t)&&(n=u.width,i=u.minWidth,o=u.maxWidth,u.minWidth=u.maxWidth=u.width=a,a=r.width,u.width=n,u.minWidth=i,u.maxWidth=o)),a===undefined?a:a+""}:pn&&pn.currentStyle&&(_n=function(e,t,r){var n,i,o,a,s=e.style;return null==(a=(r=r||vn(e))?r[t]:undefined)&&s&&s[t]&&(a=s[t]),In.test(a)&&!yn.test(t)&&(n=s.left,(o=(i=e.runtimeStyle)&&i.left)&&(i.left=e.currentStyle.left),s.left="fontSize"===t?"1em":a,a=s.pixelLeft+"px",s.left=n,o&&(i.left=o)),a===undefined?a:a+""||"auto"});var An,xn=/<([\w:-]+)/,Pn=/<|&#?\w+;/,Dn=/^-ms-/,Fn=/-([\da-z])/gi,Wn=/^(none|table(?!-c[ea]).+)/,Nn=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,Rn={position:"absolute",visibility:"hidden",display:"block"},On={letterSpacing:"0",fontWeight:"400"},Mn={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:mn.htmlSerialize?[0,"",""]:[1,"X
","
"]},Ln=document.createElement("div");An=Ln.style,mn.cssFloat=!!Ln.style.cssFloat;var Bn=function(e,t){return t.toUpperCase()},Un=["Webkit","Moz","ms"],Vn={};function jn(e){var t=Gn.cssProps[e]||Vn[e];return t||(e in An?e:Vn[e]=function(e){if(e in An)return e;var t=e.charAt(0).toUpperCase()+e.slice(1),r=Un.length;for(;r--;)if((e=Un[r]+t)in An)return e}(e)||e)}var Gn={cssHooks:{},contains:function(e,t){var r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(e.contains?e.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))},merge:function(e,t){for(var r=+t.length,n=0,i=e.length;n=this.length?null:new e(this[t]):new e(t)}},{key:"slice",value:function(){return new e(Zn.apply(this,arguments))}},{key:"getDOMNodes",value:function(){return Zn.call(this)}},{key:"each",value:function(t,r){var n=this;return Zt.each(n,(function(i,o){return i=new e(i),t.call(r||i,i,o,n)})),n}},{key:"getEL",value:function(){return this.length>0?this[0]:undefined}},{key:"all",value:function(t){return this.length>0?ai(t,this):new e}},{key:"one",value:function(e){var t=this.all(e);return t.length?t.slice(0,1):t}},{key:"attr",value:function(e,t){var r=this.getEL();if(r){if(Zt.isUndefined(t))return"readonly"===e?r.readOnly?"readonly":"":("style"!==e&&ei?r=r[e]:(r=r.attributes[e])&&(r=r.value),r);"class"==e?r.className=t:r[e]=t}}},{key:"addClass",value:function(e){var t=this.getEL();t&&function(e,t){var r,n,i,o,a=e.className,s=t.length;if(a){for(r=ii(a),n=a,i=0;i=0;)r=r.replace(i,$n);e.className=Zt.trim(r)}}(t,e.split($n))}},{key:"hasClass",value:function(e){var t=this.getEL();if(t)return function(e,t){var r,n,i,o=e.className,a=t.length;if(o&&a){for(r=ii(o),n=0;n"\s]+)(?=[^<>]*\/>)/gi,n=/"'([^'"]*)'"/gi;return(t=t.replace(r,'$1="$2"').replace(n,'"$1"')).replace(/<(\/?)(\w+)([^>]*)>/g,(function(e,t,r,n){return t?"":("<"+r.toLowerCase()+n+">").replace(/=(("[^"]*?")|('[^']*?')|([\w\-\.]+))([\s>])/g,(function(e,t,r,n,i,o,a,s){return i?'="'+i+'"'+o:e}))})).replace(/<\/?([^>]+)>/g,(function(e){return e}))}(t);for(;t.firstChild;)t.removeChild(t.firstChild);Zt.each(Yn(e),(function(e){t.appendChild(e)}))}}},{key:"style",value:function(e,t){var r=this.getEL();if(r)return Qn(r,e,t)}},{key:"css",value:function(e){Zt.each(this,(function(t){Zt.each(e,(function(e,r){Qn(t,r,e)}))}))}},{key:"show",value:function(){Zt.each(this,(function(e){e.style.display=""}))}},{key:"hide",value:function(){Zt.each(this,(function(e){e.style.display="none"}))}}])}();function ni(e){return Zt.isString(e)&&(e=Zt.trim(e))&&e.length>=3&&Zt.startsWith(e,"<")&&Zt.endsWith(e,">")}function ii(e){return($n+e+$n).replace(ti,$n)}function oi(e){return e.replace(ti,"")}function ai(e,t){var r=t;return r&&r.isNodeList&&(r=r.getEL()),Zt.isString(e)?(ni(e)&&Zt.error("Err 4002."),new ri(Zt.sizzle(e,r))):e.isNodeList?e:new ri(e)}function si(e,t){var r=ai(e,t);return r.length?r.slice(0,1):r}function ui(e){return e instanceof ri}(Xn=self||{}).Map||(Xn.Map=function(){this.keys=[],this.data={},this.set=function(e,t){null==this.data[e]&&-1==this.keys.indexOf(e)&&this.keys.push(e),this.data[e]=t},this.get=function(e){return this.data[e]}});var ci=new(w((function UJ(){I(this,UJ),ir(this,"__ver",20230516),ir(this,"Events",Yt),ir(this,"EnumMouseButton",lr),ir(this,"detectButton",dr),ir(this,"getWheelDelta",cr),ir(this,"fromUnicode",vr),ir(this,"escapeHtml",_r),ir(this,"escapeRegExp",yr),ir(this,"unEscapeHtml",Sr),ir(this,"param",Ar),ir(this,"unparam",xr),ir(this,"colorStrToInt",sr),ir(this,"IntToColorStr",ur),ir(this,"currentStyle",Er),ir(this,"parseHTML",Yn),ir(this,"setHtml",zr),ir(this,"css",qn),ir(this,"style",Qn),ir(this,"support",mn),ir(this,"all",ai),ir(this,"one",si),ir(this,"isNodeList",ui),ir(this,"Promise",Ir),ir(this,"nativePromise",br),ir(this,"loaderBarClassName",Kr),ir(this,"loaderBarSource",Jr),ir(this,"createShowMaskContent",Qr),ir(this,"switchEvent",wr),ir(this,"setBackOpacity",dn),ir(this,"showMask",fn),ir(this,"hideMask",hn),ir(this,"dialog",an),ir(this,"mask",sn)}))),li={getHex:function(e){var t=Number(e).toString(16).toUpperCase();return 1==t.length&&(t=["0",t].join("")),t},getColor:function(e){var t,r,n;return n=e>>16,r=(65280&e)>>8,t=255&e,["#",li.getHex(n),li.getHex(r),li.getHex(t)].join("")},RGB2BGR:function(e){return(255&e)<<16|65280&e|e>>16}};li.BGR2RGB=li.RGB2BGR;var di=!1,fi=!0,hi=/[#\/\?@]/g,gi=/[#\?]/g,mi={scheme:1,userInfo:2,hostname:3,port:4,path:5},pi=new RegExp("^(?:([\\w\\d+.-]+):)?(?://(?:([^/?#@]*)@)?([\\w\\d\\-\\u0100-\\uffff.+%]*|\\[[^\\]]+\\])(?::([0-9]+))?)?(.+)?$");function vi(e,t){return Zt.isString(e)&&Zt.isString(t)?e.toLowerCase()===t.toLowerCase():e===t}function _i(e,t){return encodeURI(e).replace(t,(function(e){return"%"+function(e){return 1===e.length?"0"+e:e}(e.charCodeAt(0).toString(16))}))}var yi,Si=function(){function e(t){if(o(this,e),c(this,"scheme",""),c(this,"userInfo",""),c(this,"hostname",""),c(this,"port",""),c(this,"path",""),t instanceof e)return Zt.clone(t);e.getComponents(t,this)}return s(e,[{key:"clone",value:function(){var t=new e,r=this;return Zt.each(mi,(function(e,n){t[n]=r[n]})),t}},{key:"getScheme",value:function(){return this.scheme}},{key:"setScheme",value:function(e){return this.scheme=e,this}},{key:"getHostname",value:function(){return this.hostname}},{key:"setHostname",value:function(e){return this.hostname=e,this}},{key:"setUserInfo",value:function(e){return this.userInfo=e,this}},{key:"getUserInfo",value:function(){return this.userInfo}},{key:"setPort",value:function(e){return this.port=e,this}},{key:"getPort",value:function(){return this.port}},{key:"setPath",value:function(e){return this.path=e,this}},{key:"getPath",value:function(){return this.path}},{key:"isSameOriginAs",value:function(e){var t=this;return vi(t.hostname,e.hostname)&&vi(t.scheme,e.scheme)&&vi(t.port,e.port)}},{key:"toString",value:function(e){var t,r,n,i,o,a=[],s=this;return(t=s.scheme)&&(a.push(_i(t,hi)),a.push(":")),(r=s.hostname)&&(a.push("//"),(o=s.userInfo)&&(a.push(_i(o,hi)),a.push("@")),a.push(encodeURIComponent(r)),(i=s.port)&&(a.push(":"),a.push(i))),(n=s.path)&&(r&&!Zt.startsWith(n,"/")&&(n="/"+n),a.push(_i(n,gi))),a.join("")}}],[{key:"getComponents",value:function(e,t){var r=(e=e||le).match(pi)||[],n=t||{};return Zt.each(mi,(function(e,t){n[t]=r[e]})),n}}])}(),Ii=Zt.each,bi=Zt.error,Ti=Zt.isFunction,Ci=Zt.isString,wi=de.bIE&&de.IEVersion<=9,Ei=de.bIE&&de.IEVersion<=10,ki=window,Ai=new Si(location.href),xi=Ai&&/^(?:about|app|app\-storage|.+\-extension|file|widget)$/.test(Ai.getScheme()),Pi=!1,Di=function(){try{return new ki.XMLHttpRequest}catch(jj){}},Fi=function(){try{var e=di;return Ii(["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.3.0","Msxml3.XMLHTTP"],(function(t){try{if(!e)return e=new ki.ActiveXObject(t),di}catch(jj){bi("new xhr error: "+jj.message)}})),e}catch(jj){}},Wi=!(xi||!ki.XMLHttpRequest)&&"withCredentials"in(Di()||[]),Ni=ki.ActiveXObject?function(e){return wi?Fi():!xi&&Di()||Fi()}:Di,Ri=function(e){return Pi},Oi=/^(?:GET|HEAD)$/,Mi=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Li={xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},Bi=yi;Ei&&(Bi=Zt.noop);var Ui=function(){function e(){o(this,e),c(this,"url",!1),c(this,"onSuccess",!1),c(this,"onError",!1),c(this,"onComplete",!1),c(this,"method","GET"),c(this,"async",!0),c(this,"xhrFields",!1),c(this,"mimeType",!1),c(this,"username",!1),c(this,"password",!1),c(this,"data",!1),c(this,"dataType","text"),c(this,"headers",!1),c(this,"contentType","application/x-www-form-urlencoded; charset=UTF-8"),c(this,"beforeSend",!1),c(this,"afterSend",!1),c(this,"timeout",0),c(this,"cache",!0),c(this,"crossDomain",!1),c(this,"retry",0)}return s(e,[{key:"setRequestHeader",value:function(e,t){this.headers[e]=t}},{key:"getAllResponseHeaders",value:function(){return 2===this.state?this.responseHeadersString:null}},{key:"getNativeXhr",value:function(){return this.nativeXhr}},{key:"getResponseHeader",value:function(e){var t,r;if(e=e.toLowerCase(),2===this.state){if(!(r=this.responseHeaders))for(r=this.responseHeaders={};t=Mi.exec(this.responseHeadersString);)r[t[1].toLowerCase()]=t[2];t=r[e]}return t===undefined?null:t}},{key:"overrideMimeType",value:function(e){return this.state||(this.mimeType=e),this}},{key:"abort",value:function(e){return this.state=3,this.status=0,this.statusText=null!=e?e:"abort",this.nativeXhr&&this.nativeXhr.abort(),this._callback(),this}},{key:"_ioReady",value:function(e,t){var r=!1,n=this;if(2!==this.state&&3!==this.state){1===this.state&&(this.state=2),this.readyState=4,e>=200&&e<300||304===e?304===e?(t="not modified",r=!0):(t="success",r=!0):e<0&&(e=0);try{e>=200&&this.handleResponseData()}catch(jj){bi(jj,"error"),t=jj.message||"parser error"}return(e<200||!r)&&this.retry>0?(this.retry=this.retry-1,void setTimeout((function(){n.sendInternal()}),200)):(this.status=e,this.statusText=t,this._callback(r),r)}}},{key:"_callback",value:function(e){var t=this,r=this.timeoutTimer;r&&(clearTimeout(r),this.timeoutTimer=0),Ii([e?this.onSuccess:this.onError,this.onComplete],(function(e){Ti(e)&&e.apply(t.context,[t.responseData,t.statusText,t])})),this.responseData=null}},{key:"handleResponseData",value:function(){var e,t=this.dataType,r=this.nativeXhr;if("blob"===t||"arraybuffer"===t)if(wi){var n,i,o;if("responseBody"in r)n=r.responseBody,i=ki.dsVbsBinGetLength(n),e=new ki.VBArray(ki.dsVbsBinGetBytes(n,0,i)).toArray();else for(e=[],i=(n=r.responseText).length,o=0;o0&&(t.timeout<300&&(t.timeout=300),this.timeoutTimer=setTimeout((function(){f.abort("timeout")}),t.timeout));try{if(this.state=1,Ti(this.beforeSend))if(!1===this.beforeSend(a,f))return void this.abort("cancel");a.send(d),d=null,t.data=null,Ti(this.afterSend)&&this.afterSend(f)}catch(jj){this.state<2?(bi(jj,"error"),this._ioReady(-1,"send error: "+(jj.message||""))):bi(jj)}if(!t.async||4===a.readyState)return f._xhrCallback();a.onreadystatechange=function(){f._xhrCallback()}}}},{key:"_xhrCallback",value:function(e,t){var r,n=this.nativeXhr;try{if(4===n.readyState||t)if(Ri()||(n.onreadystatechange=Bi),t)4!==n.readyState&&n.abort();else{Ri()||(this.responseHeadersString=n.getAllResponseHeaders());var i,o=n.status;try{i=n.statusText}catch(jj){bi("xhr statusText error: "),bi(jj),i=""}r=this._ioReady(o,i)}}catch(jj){bi(jj,"error"),n.onreadystatechange=Bi,t||this._ioReady(-1,jj.message||"process error")}return r}},{key:"_setup",value:function(t){var r,n,i,o,a;if(t){for(n in this.context=t.context,delete t.context,t instanceof e&&(t=t.config),this.config=t,o=t.url,Zt.startsWith(o,"//")&&(t.url=o="http:"+o),(Zt.startsWith(o,"http://")||Zt.startsWith(o,"https://"))&&(a=new Si(o)),r=t.dataType?t.dataType.toLowerCase():"text",t.dataType=r,t.method?t.method=t.method.toUpperCase():t.method="GET",a&&!("crossDomain"in t)&&(t.crossDomain=!a.isSameOriginAs(Ai)),i=t.headers)i[n]===yi&&delete i[n];Zt.mix(this,t)}return this.state=1,this}},{key:"dispose",value:function(){this.responseHeaders=null,this.responseHeadersString=null,this.responseData=null,this.responseText=null,this.responseXML=null,this.context=null,this.config=null,this.onSuccess=null,this.onError=null,this.onComplete=null,this.xhrFields=null,this.data=null,this.headers=null,this.beforeSend=null,this.afterSend=null}}])}();function Vi(e){if(e&&Ci(e.url)){var t=new Ui;return e.async?(e.async=!0,t.sendInternal(e),t):(e.async=!1,t.sendInternal(e))}Zt.log("the url is error.")}var ji="Please make sure the Dynamic Web TWAIN Service has been installed.",Gi="Error: This browser is currently not supported.",Hi="Error: Duplicate ContainerId detected while creating a Dynamic Web TWAIN object.",zi="Error: Duplicate WebTwainId detected while creating a Dynamic Web TWAIN object.",Ki="Error: The ID of the target DIV for the new DWT object is invalid.",Ji="19",Qi="0",qi="0",Yi="0318",Xi="0",Zi="0",$i="".concat(Ji,",").concat(Qi,",").concat(qi,",").concat(Yi),eo="".concat(Ji,",").concat(Xi,",").concat(Zi,",").concat("0318"),to=parseInt(Ji),ro=parseInt(Qi),no=parseInt(qi),io=[to,ro,no,Yi],oo=[to,ro,no,Yi],ao=[to,ro,no,Yi],so=[1,9,0,Yi],uo=[1,9,0,Yi],co=[1,9,0,Yi];function lo(){if(de.bWin);else{if(de.bMac)return oo;if(de.bLinux)return ao}return io}function fo(){if(de.bWin);else{if(de.bMac)return uo;if(de.bLinux)return co}return so}function ho(){return"dcp/dwasm2_"+go()}function go(){return lo().join("")}var mo=function(e){return e.NONE=0,e.TRACE=1,e.DEBUG=2,e.INFO=4,e.WARN=8,e.ERROR=16,e}({}),po=Zt.getLogger(),vo=(S=function(){return s((function e(){o(this,e)}),null,[{key:"LogLevel",get:function(){return this._logLevel},set:function(e){this._logLevel=e}},{key:"LogFunc",set:function(e){this._logFunc=e}},{key:"all",value:function(e,t){if((this._logLevel&e)==e)if(this._logFunc)this._logFunc(t,e);else switch(e){case mo.DEBUG:po.debug(t);break;case mo.ERROR:po.error(t);break;case mo.INFO:po.info(t);break;case mo.WARN:po.warn(t);break;case mo.TRACE:po.trace(t)}}},{key:"trace",value:function(e){this.all(mo.TRACE,e)}},{key:"debug",value:function(e){this.all(mo.DEBUG,e)}},{key:"info",value:function(e){this.all(mo.INFO,e)}},{key:"warn",value:function(e){this.all(mo.WARN,e)}},{key:"error",value:function(e){this.all(mo.ERROR,e)}}])}(),c(S,"_logLevel",mo.ERROR),c(S,"_logFunc",undefined),S);function _o(e){var t;window.console&&(e instanceof Error||Zt.isString(e)?(t=e,rr.navInfoSync.bIE&&(t=Zt.stringify(e))):t=Zt.stringify(e),window.console.error(t))}var yo,So="127.0.0.1";de.bAndroid&&de.bSSL&&(So="local.dynamsoft.com"),yo="0"==Zi.toLowerCase()?"Dynamic Web TWAIN "+[Ji,Xi].join("."):"Dynamic Web TWAIN "+[Ji,Xi,Zi].join(".");var Io={JSVersion:eo,ServerVersionInfo:$i,ServerLinuxVersionInfo:$i,ServerMacVersionInfo:$i,ServerAndroidVersionInfo:$i,ActiveXVersion:"18,0,0,1025",ActiveXPdfVersion:"11.5.2.0312",PdfVersion:"11.5.2.0312",PdfLinuxVersion:"11.5.2.0312",PdfMacVersion:"11.5.2.0312"},bo={ProductName:yo,Containers:undefined,ContainerMap:{},WebTwainIdMap:{},RemoteScanIdMap:{},Trial:!1,ResourcesPath:"Resources",Debug:!1,IfUpdateService:!1,AutoLoad:!0,ReConnectToService:!0,OnWebTwainReady:!1,OnWebTwainError:function(e){_o(e)},OnWebTwainNotFound:!1,OnWebTwainOldPluginNotAllowed:!1,OnWebTwainNeedUpgrade:!1,OnWebTwainNeedUpgradeWebJavascript:!1,OnWebTwainInitMessage:!1,ViewerJSIntegerited:!0,ActiveXInstallWithCAB:!1,IfUseActiveXForIE10Plus:!1,IfUseEmbeddedDownloadNoticeForActiveX:!1,IfCheckDCP:!1,IfDisableDefaultSettings:!1,OnWebTwainWillInit:!1,IfAddMD5InUploadHeader:!1,IfAlwaysFocusOnPopupWindow:!0,IfConfineMaskWithinTheViewer:!1,fetchOptions:{mode:"cors",credentials:"same-origin"},HideTrialMessage:!1,CheckCertExpired:!0,ConnectWithSocket:!1,SSLPort:18623,Port:18622,showLoadingMsgDialog:!0,licenseServer:undefined,sessionPassword:undefined,organizationID:undefined,handshakeCode:undefined,UseDefaultViewer:!0,Host:So,DeviceFriendlyName:"",LocalHosts:["127.0.0.1","localhost","local.dynamsoftwebtwain.com","local.dynamsoft.com"],IfCheckCORS:!1,IfCheckCert:!0,IfChromeExtension:!1,IfLoadResources:!0,IfResourcesAddTimestamp:!0,IfCheckCssFiles:!0};function To(){var e=rr.DWT.Host;return Zt.isString(e)&&""!=e||(rr.DWT.Host=e=So),e}function Co(){var e=300,t=rr.DWT.RemoteScanConfig;return t&&Zt.isNumber(t.sessionTimeout)&&t.sessionTimeout>0&&(e=t.sessionTimeout),e}var wo={URL:"",UpdateDaysBeforeExpired:30},Eo=de.bWin,ko=de.bMac,Ao=de.bLinux,xo=de.bSafari,Po=de.bFirefox,Do=de.bChrome,Fo=location.hostname,Wo=location.pathname,No=0,Ro=de.bMobile,Oo=parseFloat(de.strBrowserVersion);if(de.bWin||de.bMac||de.bLinux||de.bChromeOS){if(rr.navInfo){var Mo=rr.navInfo;Ro=Ro||Mo.bAndroid||Mo.bPad||Mo.biPhone||Mo.biPad}}else Ro=!0;""===Fo?Eo&&Wo.lastIndexOf("\\")>1?Wo=Wo.substring(1,Wo.lastIndexOf("\\")).replace(/%20/g," "):(No=1,Wo=Wo.substring(1,Wo.lastIndexOf("/")).replace(/%20/g," ")):(No=1,Wo=Wo.substring(0,Wo.lastIndexOf("/")));var Lo={bChrome:Do,bFirefox:Po,bSafari:xo,bIE:de.bIE,bEdge:de.bEdge,bWin:Eo,bMac:ko,bLinux:Ao,iPluginLength:0,bFileSystem:de.bFileSystem,bMobile:Ro,strIEVersion:de.IEVersion,strChromeVersion:de.bChrome?Oo:"",strFirefoxVersion:de.bFirefox?Oo:"",basePath:Wo,pathType:No,isDesktopViewer:function(){return de.bWin||de.bLinux||de.bChromeOS||de.bMac},isPadViewer:function(){return de.bPad||de.biPad},isMobileViewer:function(){return de.bMobile||de.biPhone||de.bAndroid||de.bHarmonyOS},WSVersion:"18.5.0",WSSession:(new Date).getTime(),bDiscardBlankImage:di},Bo=!0,Uo=!1,Vo=de.bHTML5Edition,jo=0,Go=Uo;de.bIE&&(""===(jo=de.IEVersion)||jo>=10?rr.DWT.IfUseActiveXForIE10Plus?(Vo=Uo,Go=Bo,de.bHTML5Edition=Vo):Vo=Bo:(Vo=Uo,jo>=9&&(Go=Bo))),Go||Vo||(Vo=Bo);var Ho={SSLPort:18626,Port:18625,bEnhancedMode:!1,oldDWASMVerStr:"dwasm_13000404",oldDWASMVer:[13,0,0,"0404"],wsProtocol:"dwt_command",managerVersion:io,managerVersionMac:oo,managerVersionLinux:ao,serviceVersion:so,serviceVersionMac:uo,serviceVersionLinux:co,detect:{dcpStatus:0,ddmPort:0,dwtPort:0,dwtSSLPort:0,bConnected:!1,connectedResult:"",MaxManagerModuleConnectCount:1,EnumDCP_DetectStatus:{Init:0,Connected:1,CheckingManagerVer:15,CheckingServiceVer:16,NotInstalled:17,CheckedService:5,VerifyingZip:6,VerifiedZip:7,UpdatingService:8,UpdateSucceed:9,UpdateFailed:10,UpdateSkipped:11}},strSID:"",b64bit:!0,objEnhancedPorts:{}};function zo(e){var t=Ko(),r=e;return r||(r=de.bWin?".msi":de.bMac?".pkg":rr.navInfo.bArm64?"-arm64.deb":rr.navInfo.bMips64?"-mips64el.deb":rr.navInfo.bAndroid?".apk":de.bLinux||de.bChromeOS||de.bHarmonyOS?".deb":".msi"),[t,"DynamicWebTWAINServiceSetup",r].join("")}function Ko(){var t,r,n=Qo.refServiceInstallerLocation||null;if(!n){var i;if(e.CoreModule&&e.CoreModule.engineResourcePaths?(t=e.CoreModule.engineResourcePaths.dwt,r=e.CoreModule.engineResourcePaths.rootDirectory):null!==(i=window)&&void 0!==i&&null!==(i=i.Dynamsoft)&&void 0!==i&&null!==(i=i.Core)&&void 0!==i&&null!==(i=i.CoreModule)&&void 0!==i&&null!==(i=i.engineResourcePaths)&&void 0!==i&&i.dwt&&(t=window.Dynamsoft.Core.CoreModule.engineResourcePaths.dwt,window.Dynamsoft.Core.CoreModule.engineResourcePaths.rootDirectory&&(r=window.Dynamsoft.Core.CoreModule.engineResourcePaths.rootDirectory)),t&&(Zt.isString(t)||Zt.isString(t.serviceInstallerLocation)&&(n=t.serviceInstallerLocation),Zt.isString(n)))if(Zt.startsWith(n,"https://")||Zt.startsWith(n,"http://"));else if(r&&Zt.isString(r)&&r.length>0){var o="";"/"==r.charAt(r.length-1)||(o="/"),n=[r,o,n].join("")}if(Zt.isString(n)||(n=rr.DWT.ServiceInstallerLocation||""),Zt.isString(n)&&n.length>0)"/"!=n[n.length-1]&&(n+="/");else{var a=Jo();if(Zt.isString(a)&&a.length>0){var s="";"/"==a.charAt(a.length-1)||(s="/"),n=[a,s,"dist/"].join("")}else n="Resources/dist/"}Qo.refServiceInstallerLocation=n}return n}function Jo(){var t=Qo.refResourcesPath||null;if(!t){var r,n,i;if(e.CoreModule&&e.CoreModule.engineResourcePaths)r=e.CoreModule.engineResourcePaths.dwt,n=e.CoreModule.engineResourcePaths.rootDirectory;else null!==(i=window)&&void 0!==i&&null!==(i=i.Dynamsoft)&&void 0!==i&&null!==(i=i.Core)&&void 0!==i&&null!==(i=i.CoreModule)&&void 0!==i&&null!==(i=i.engineResourcePaths)&&void 0!==i&&i.dwt&&(r=window.Dynamsoft.Core.CoreModule.engineResourcePaths.dwt,window.Dynamsoft.Core.CoreModule.engineResourcePaths.rootDirectory&&(n=window.Dynamsoft.Core.CoreModule.engineResourcePaths.rootDirectory));if(r&&(Zt.isString(r)?t=r:Zt.isString(r.resourcesPath)&&(t=r.resourcesPath),Zt.isString(t)))if(Zt.startsWith(t,"https://")||Zt.startsWith(t,"http://"));else if(n&&Zt.isString(n)&&n.length>0){var o="";"/"==n.charAt(n.length-1)||(o="/"),t=[n,o,t].join("")}if(Zt.isString(t)||(t=rr.DWT.ResourcesPath||""),!de.bFileSystem){void 0!==t&&""!=t||(t=Lo.basePath||""),t.length>0&&"/"==t.charAt(t.length-1)&&(t=t.substr(0,t.length-1)),Qo.refResourcesPath=t}}return t}var Qo={name:"Dynamic Web TWAIN",bHTML5Edition:Vo,bActiveXEdition:Go,_iImageCaptureDriverType:3,_iBrokerProcessType:1,getChromeEditionPath:zo,getPKGPath:function(){return Ko()+"DynamicWebTWAINMacEdition.pkg"},getMSIPath:function(){return Ko()+"DynamicWebTWAINPlugIn.msi"},getActiveXCABx86Path:function(){return Ko()+"DynamicWebTWAIN.cab"},getActiveXCABx64Path:function(){return Ko()+"DynamicWebTWAINx64.cab"},onlineResources:"https://demo.dynamsoft.com/DWT/Resources/",strMIMEType:"Application/DynamicWebTwain-Plugin",strFullClassID:"E7DA7F8D-27AB-4EE9-8FC0-3FEC9ECFE758",scripts:{},dwtConfigLoaded:!1,dwtConfigLoading:!1,getServerVersionInfo:function(e){var t=Io.ServerVersionInfo;return de.bWin||(de.bMac?t=Io.ServerMacVersionInfo:de.bAndroid?t=Io.ServerAndroidVersionInfo:(de.bLinux||de.bChromeOS||de.bHarmonyOS)&&(t=Io.ServerLinuxVersionInfo)),e?t:Zt.replaceAll(t,",","")},getDWTPrefix:function(){return!0===rr.DWT.CustomMode?"dwtc_":"dwt_"},loadResourcePath:!1,loadingResourcePath:!1,handshakeCode:undefined,organizationID:undefined,licenseServer:undefined,sessionPassword:"",bPublicLTS:!0,refProductKey:undefined,ltsDebug:!1,bDWTLoading:!1,bDWTUnloading:!1,bAndroidConnected:!1,unloadQueue:[],appendBrowserLicenseWhenServiceMode:function(){},bDCPChecked:!1,bDWTChecked:!1,bUseDynamsoftLicenseManager:!1,bChromeEdition:Vo},qo={bFullEdition:!1,getVersionStrForCheck:function(){return"".concat(Ji,"000000")},versionInfoFromServer:"",hostForCheckCert:So,RemoteReconnectMaxTimes:200,RemoteReconnectTimeSpan:5e3,LocalReconnectMaxTimes:60,LocaleReconnectTimeSpan:3e3,HttpConnectTimeout:de.bSSL?3e3:1e3,WebsocketConnectTimeout:de.bSSL?1e3:600};function Yo(){return Qo.HttpConnectTimeout}function Xo(){return Qo.WebSocketConnectTimeout}function Zo(){return Qo.bUseDynamsoftLicenseManager?Zt.isString(Qo.refProductKey)&&(Zt.startsWith(Qo.refProductKey,"DLS2")||""===Qo.refProductKey):Zt.isString(Qo.handshakeCode)||Zt.isString(Qo.organizationID)||Qo.bPublicLTS||Zt.isString(rr.DWT.ProductKey)&&Zt.startsWith(rr.DWT.ProductKey,"DLS2")}function $o(e){if(e===undefined)return!0;var t;if(e)for(t=0;t0||r){var i;i=n&&n>=200&&n<300?["HTTP process: "]:["HTTP process error: "],r&&(r.indexOf("HTTP process error: ")>=0&&(i=[""]),i.push(r)),n&&n>0&&(i.push(" ("+n+")"),n>=300&&(e._errorCode=ua.HTTPServerError));var o=i.toString().lastIndexOf(".");o>=0&&o==i.toString().length-1?e._errorString=i.join(""):e._errorString=i.join("")+"."}else e._errorString="HTTP process error."}function Sa(e){na(e,-2304,"Http download error: the url is invalid.")}function Ia(e,t,r,n){if(t)na(e,-2305,"User cancelled the operation.");else if(e._errorCode=-2003,n&&n>0||r){var i=["HTTP put error: "];r&&(r.indexOf("HTTP put error: ")>=0&&(i=[""]),i.push(r)),n&&n>=300&&(e._errorCode=ua.HTTPServerError);var o=i.toString().lastIndexOf(".");o>=0&&o==i.toString().length-1?e._errorString=i.join(""):e._errorString=i.join("")+"."}else e._errorString="HTTP put error."}function ba(e,t,r,n){if(t)na(e,-2305,"User cancelled the operation.");else if(e._errorCode=-2003,n&&n>0||r){var i=["HTTP process error: "];r&&(r.indexOf("HTTP process error: ")>=0&&(i=[""]),i.push(r));var o=i.toString().lastIndexOf(".");o>=0&&o==i.toString().length-1?e._errorString=i.join(""):e._errorString=i.join("")+"."}else e._errorString="HTTP process error."}function Ta(e){na(e,-2306,"Upload Error: the upload file cannot be empty.")}function Ca(e){na(e,-2307,"The width or height you entered is invalid.")}function wa(e){na(e,-2313,"The size of the images you are about to upload has exceeded the limit.")}function Ea(e){na(e,-2314,"The parameter cannot be empty.")}function ka(e){na(e,-2320,"Invalid file.")}function Aa(e){na(e,ra.LicenseInvalid,Zo()?"The license is invalid.":"The current product key is empty or invalid."),ia(e)}function xa(e,t){e._errorCode=ra.LicenseExpired;var r="";if(t&&""!=t&&(-1==t.indexOf("on")&&(r=" on "+t),e.__licenseInfo&&(e.__licenseInfo.ExpireDate=t)),Zo()){var n,i,o,a;if(n=rr.DWT.lgdt(),e._bRemoteMode)i=null!==(o=null===(a=e._dmService)||void 0===a||null===(a=a.attrs)||void 0===a?void 0:a.UUID)&&void 0!==o?o:"";else i="";e._errorString="The license has expired"+r+". Please contact the application developer.",rr.DWT.lcexp(n,i).then((function(){e._errorString=rr.DWT.licenseException.message}))}else e._errorString="The current product key has expired"+r+". Please contact the application developer.",ia(e)}function Pa(e,t){Zo()?111==t?(e._errorCode=ra.LicenseExpiredForDLS,e._errorString="The license for v"+Ji+" Service Core Module has expired."):(e._errorCode=ra.LicenseNoCoreForDLS,e._errorString="The license for v"+Ji+" Service Core Module is not found."):(e._errorCode=ra.LicenseNoCore,e._errorString="The product key for the current operating system is missing the Service Core license. "+oa()),ia(e)}function Da(e){e._errorCode=-2339,Zo()?e._errorString="The license for the module pdf rasterizer is not found or has expired.":e._errorString="The current product key does not support pdf rasterizer. "+oa(),ia(e)}function Fa(e){na(e,-2351,"You cannot upload more than one image when the format is BMP, JPG or PNG")}function Wa(e){na(e,-2352,"The indices are out of range.")}function Na(e){na(e,-2353,"The header name being used is a protected keyword and is not allowed.")}function Ra(e){na(e,-2358,"The type of the parameter indices must be an Array.")}function Oa(e){na(e,-2359,"The index is out of range.")}function Ma(e){na(e,-2360,"The index is null or undefined.")}function La(e){na(e,-2362,"The image type is not supported.")}function Ba(e){na(e,-2363,"The data format is not supported.")}function Ua(e){na(e,-2365,"The url is invalid.")}function Va(e){na(e,-2376,"The generate url failed.")}function ja(e){na(e,-2377,"Failed to set Image Capture Driver Type.")}function Ga(e){na(e,-2391,"Invalid event name.")}function Ha(e){na(e,-2393,"Failed to convert the data to blob.")}function za(e){na(e,-2399,"Invalid imageId.")}function Ka(e){na(e,-2416,"Invalid parameter.")}function Ja(e){na(e,-2426,"You have used a full license with a trial license which is not permitted. Please check and update Dynamsoft.DWT.ProductKey.")}function Qa(e){na(e,-2510,"The callback is not a function.")}function qa(e){na(e,-2513,"The WebTwain instance has been destroyed and can not be used anymore.")}function Ya(e){na(e,-2530,"Document name cannot be empty.")}function Xa(e){na(e,-2531,"Document name is not a string.")}function Za(e){na(e,-2548,"You cannot call this function when Dynamsoft.DWT.UseDefaultViewer is set to false.")}function $a(e){na(e,-2549,"You cannot call this function when there is no ui binding.")}function es(e){na(e,0,"")}function ts(e){var t=e;return t||(t="[]"),{code:-2601,message:"Failed to connect to the Dynamic Web TWAIN Service on "+t+". Please make sure Dynamic Web TWAIN Service is running or the certificate is valid."}}function rs(e){var t;return e._bRemoteMode?ts(null===(t=e._dmService)||void 0===t||null===(t=t.attrs)||void 0===t?void 0:t.name).message:"The Dynamic Web TWAIN Service has been stopped."}function ns(e){na(e,-2607,"The device selected was not found under the current service object.")}function is(e){na(e,-2608,"IfShowFileDialog cannot be set to true when Object is created by CreateRemoteScanObjectAsync.")}function os(e,t){Zt.isString(t)&&""!=t?na(e,ua.RemoteDynamsoftServiceStopped,"The Dynamic Web TWAIN Service on ["+t+"] has been stopped."):na(e,-2308,"The Dynamic Web TWAIN Service has been stopped.")}function as(e){na(e,-2615,"User cancelled the operation.")}function ss(e){na(e,-2616,"Invalid image format type.")}function us(e){na(e,-2618,"Only single index selection is allowed when enumImageType is set to BMP, JPG or PNG.")}function cs(e){na(e,-2620,"The RemoteScan object has been disposed.")}function ls(e){na(e,-2621,"Dynamsoft.DWT.Containers was not set.")}function ds(e){na(e,-2622,'Please do not set enumImageType to "IT_MULTIPAGE_PDF", "IT_MULTIPAGE_TIF" or "IT_ALL".')}function fs(e){na(e,-2624,"The element within Dynamsoft.DWT.Containers should be a valid object.")}function hs(e){na(e,-2800,ji)}function gs(e){na(e,ua.ResponseDataTypeError,"Invalid response data was returned from the Dynamic Web TWAIN Service.")}function ms(e){return{code:-2807,message:'Error: The element specified by the id "'+e+"\" doesn't exist."}}function ps(e,t){na(e,-2811,t)}function vs(e){na(e,-2812,zi)}function _s(e){na(e,-2815,Hi)}function ys(e,t,r){na(e,-2816,["HTTP process error: ",r," (",t,")."].join(""))}function Ss(){return{code:ua.HTSTError,message:"The Connection from the insecure (HTTP) web page failed for HTST."}}function Is(){return{code:ua.DWTPortNotReady,message:"The Dynamic Web TWAIN Service is not ready, please try again later."}}function bs(e){return{code:-2826,message:"Failed to connect the Dynamic Web TWAIN Service on ["+e+"]."}}function Ts(e){na(e,-2828,"Invalid PDF Convert Mode Value.")}function Cs(e){na(e,-2848,"The capability value is out of range.")}function ws(e){na(e,-2854,"The imageId does not exist.")}function Es(e){na(e,-2855,"The blob cannot be empty.")}function ks(e){na(e,-2857,"Invalid blob value.")}function As(e){na(e,-2901,"Source document does not exist. Please check the document name or create the document before performing this operation.")}function xs(e){na(e,-2902,"Target document does not exist. Please check the document name or create the document before performing this operation.")}function Ps(e){na(e,-2906,"After initialization, the product key cannot be changed.")}var Ds=de.bIE&&de.IEVersion<=9;aa=self&&self.fetch?self.fetch:window.fetch;var Fs=0;function Ws(e,t){var r,n=!1;return Fs=t,aa?r=function(r,i){var o=!1,a="text",s=!1;if(i&&(i.dataType&&(a=i.dataType),i.fetchRaw&&(s=!0),i.timeout)){var u=i.timeout;u<300&&(u=300);var c=new AbortController;i.signal=c.signal,setTimeout((function(){o||c.abort("timeout")}),u)}n=!1;var l=aa(r,i).then((function(r){if(r.ok){var i,a;if(o=!0,!e)return r;if(e.__clickCancel)return e.__clickCancel=!1,e.__cancelBeforObjectCreated=!1,n=!0,r;e.IfShowCancelDialogWhenImageTransfer?(Rs(!0),a=e.on("cancel",(function(){n=!0}))):Rs(!1);var s=r.headers.get("Content-Length"),u=0;e._onPercent&&Fs==t&&e._onPercent({loaded:u,total:s});var c=null==r||null===(i=r.body)||void 0===i?void 0:i.getReader(),l=new ReadableStream({start:function(r){var i=function(){return c.read().then((function(o){if(o.done||n)return n?c.cancel():a&&e.off("cancel",a),r.close(),void(a=null);var l=o.value;u+=l.length,e._onPercent&&Fs==t&&e._onPercent({loaded:u,total:s});try{return r.enqueue(l),i()}catch(d){Zt.error(d)}}))};c?setTimeout(i,0):r.close()}}),d=r.headers.get("Content-Type");return d&&""!=d||(d="application/octet-stream"),new Response(l,{headers:{"Content-Type":d}})}if("opaqueredirect"==r.type)throw{code:ua.HTTPRedirected,message:"The http url redirected."};var f;throw ys(f={},r.status,r.statusText),{code:f._errorCode,message:f._errorString,httpCode:r.status}}));return s?l:(l="blob"==a?l.then((function(e){var t=e.headers.get("content-type");return ta(t)?e.json():de.bLinux?e.arrayBuffer().then((function(e){return new Blob([e],{type:t})})):e.blob()})):"json"==a?l.then((function(e){return e.json()})):"arraybuffer"==a?l.then((function(e){return ta(e.headers.get("content-type"))?e.json():e.arrayBuffer()})):l.then((function(e){return e.text()}))).then((function(e){var t;if(n)throw as(t={}),{code:t._errorCode,message:t._errorString};return e}))}:(Ds&&Zt.addVBS(["Function dsVbsBinGetAt(strBinary,iOffset)\r\n"," dsVbsBinGetAt=AscB(MidB(strBinary,iOffset+1,1))\r\n","End Function\r\n","Function dsVbsBinGetBytes(strBinary,iOffset,iLength)\r\n"," Dim aBytes()\r\n"," ReDim aBytes(iLength-1)\r\n"," For i=0 To iLength-1\r\n"," aBytes(i)=dsVbsBinGetAt(strBinary,iOffset+i)\r\n"," Next\r\n"," dsVbsBinGetBytes=aBytes\r\n","End Function\r\n","Function dsVbsBinGetLength(strBinary)\r\n"," dsVbsBinGetLength=LenB(strBinary)\r\n","End Function"].join("")),r=function(r,n){return new(Qt.nativePromise||window.Promise)((function(i,o){var a,s=!1;a={url:r,async:!0,onSuccess:function(e,t,r){var n=!1;r.responseHeadersString&&(ea(r.responseHeadersString)&&(Zt.isArray(e)||e instanceof ArrayBuffer)&&(n=!0));if(n){var o=e;e instanceof ArrayBuffer&&(o=new Uint8Array(e));var a=String.fromCharCode.apply(null,o);i(a)}else i(e)},onError:function(e,t,r){var n;ys(n={},r.status,t),o({code:n._errorCode,message:n._errorString,httpCode:r.status})},dataType:"text",method:sa,data:sa,headers:sa,contentType:sa,mimeType:sa},n&&(n.method&&(a.method=n.method),n.body&&(a.data=n.body),n.headers&&(a.headers||(a.headers={}),Zt.each(n.headers,(function(e,t){"content-type"==t.toLowerCase()&&(s=!0),a.headers[t]=e}))),n.dataType&&(a.dataType=n.dataType),n.contentType&&(a.contentType=n.contentType),Zt.isNumber(n.timeout)&&n.timeout>0&&(a.timeout=n.timeout)),s&&(a.contentType=!1),"blob"==a.dataType&&Ds&&(a.mimeType="text/plain; charset=x-user-defined"),e&&(e._onPercent&&(a.beforeSend=function(r,n,i){r.upload.addEventListener("progress",(function(r){e._onPercent&&Fs==t&&e._onPercent(r)}),!1)}),e.IfShowCancelDialogWhenImageTransfer?Rs(!0):Rs(!1));var u=Vi(a);e&&e.IfShowCancelDialogWhenImageTransfer&&e.on("cancel",(function(){u.abort()}))}))}),r}var Ns=Ws(null,0);function Rs(e){var t=Zt.sizzle(".dynamsoft-btnCancel");if(t.length>0){var r=t[0];r.style.display=e?"":"none"}}String.prototype.startsWith||(String.prototype.startsWith=function(e){return 0==this.indexOf(e)});var Os=function(e){var t,r=e,n=r._license||"",i=JSON.parse(JSON.stringify(r._licenseServer)),o=r._sessionPassword,a=0;if(n.startsWith("t")||n.startsWith("f"))a=0;else if(0===n.length||n.startsWith("P")||n.startsWith("L")||n.startsWith("Y")||n.startsWith("A"))a=1;else{a=2;var s=n.indexOf(":");if(-1!=s&&(n=n.substring(s+1)),n.startsWith("DLS2")){var u;try{var c=n.substring(4);c=Dynamsoft.Lib.atob(c),u=JSON.parse(c)}catch(d){throw new Error("Format Error: The license string you specified is invalid, please check to make sure it is correct.")}if("number"==typeof(n=u.handshakeCode?u.handshakeCode:u.organizationID?u.organizationID:"")&&(n=JSON.stringify(n)),0===i.length){var l=[];u.mainServerURL&&(l[0]=u.mainServerURL),u.standbyServerURL&&(l[1]=u.standbyServerURL),i=function(e){if(null==e)e=[];else{e instanceof Array||(e=[e]);for(var t=0;t0)){e.next=3;break}return e.abrupt("return",!1);case 3:return this._disposed=!0,e.next=6,this._terminate();case 6:case"end":return e.stop()}}),u,this)}))),function(){return t.apply(this,arguments)})},{key:"_terminate",value:(e=n(g().mark((function l(){return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),l)}))),function(){return e.apply(this,arguments)})},{key:"addRef",value:function(){this._ref++}}]);var e,t,r}();function qs(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function Ys(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var Xs,Zs=Zt.getLogger(),$s=new WeakSet,eu=function(e){function t(){var e;o(this,t);for(var r=arguments.length,n=new Array(r),a=0;a0)){e.next=17;break}if(!n._processing_blob){e.next=9;break}return e.next=8,new Qt.Promise((function(e){Xs._preBlobResolv=e,Xs._waitForPreBlob(n)}));case 8:Xs._preBlobResolv=null;case 9:return n._processing_blob=!0,s=n._blob_callbacks.shift(),e.next=13,s(r);case 13:return e.sent,n._processing_blob=!1,e.abrupt("return");case 17:if(!(n.bReady&&Zt.isString(r)&&(r.indexOf("Function not found")>0||r.indexOf("Version not found")>0))){e.next=19;break}return e.abrupt("return");case 19:if(n._cbToGetTaskId){e.next=21;break}return e.abrupt("return");case 21:return e.next=23,n._cbToGetTaskId(r,Js.ONMESSAGE_PROCESS_DATA,n._requestTaskId,a);case 23:return u=e.sent,c=!1,e.next=27,n._cbToGetTaskId(u,Js.ONMESSAGE_GET_TASKID,n._requestTaskId,a);case 27:if(o=e.sent){e.next=36;break}if(!u.Detail||!u.Domain){e.next=32;break}return n._lic_callback&&n._lic_callback(u),e.abrupt("return");case 32:return e.next=34,n._cbToGetTaskId(u,Js.ONMESSAGE_GET_EVENT_TASKID,n._requestTaskId,a);case 34:(o=e.sent)&&(c=!0);case 36:if(i=n._tasks[o]){e.next=46;break}if(!c){e.next=42;break}i={},e.next=44;break;case 42:return""!=o&&du.log("invalid task id: "+o),e.abrupt("return");case 44:e.next=48;break;case 46:if(!i.timedout){e.next=48;break}return e.abrupt("return");case 48:return d=i.cb?i.cb:n._cbToGetTaskId,e.next=51,d({rawData:r,jsonData:u},Js.HANDLE_RAW_MESSAGE,n._requestTaskId,i.ctx);case 51:if((l=e.sent)!==undefined){e.next=56;break}return e.next=55,d(u,Js.HANDLE_PROCESSED_MESSAGE,n._requestTaskId,i.ctx);case 55:l=e.sent;case 56:l&&!c&&(i.tmid&&clearTimeout(i.tmid),delete n._tasks[o],i.resolver&&i.resolver.resolve(l)),e.next=65;break;case 59:e.prev=59,e.t0=e["catch"](1),du.debug("failed to handle message."),e.t0 instanceof Error?du.error(e.t0):du.error(Zt.stringify(e.t0)),delete n._tasks[o],null===(f=i)||void 0===f||null===(f=f.resolver)||void 0===f||f.reject(e.t0.message);case 65:case"end":return e.stop()}}),e,null,[[1,59]])}))),vu.apply(this,arguments)}function _u(e,t,r){return yu.apply(this,arguments)}function yu(){return yu=n(g().mark((function e(t,r,n){var i,o;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=r,e.next=e.t0===Js.GET_TASKID?3:e.t0===Js.HANDLE_RAW_MESSAGE?7:9;break;case 3:return(o=iu(t)).cmdId=null!==(i=o.cmdId)&&void 0!==i?i:(n=void 0,a=void 0,a=[ou(8),"-",ou(4),"-",ou(4),"-",ou(4),"-",ou(8)],n&&a.unshift(n),a.join("")),Qt.Promise.resolve(["cmdId"]),e.abrupt("break",9);case 7:return Qt.Promise.resolve(t),e.abrupt("break",9);case 9:case"end":return e.stop()}var n,a}),e)}))),yu.apply(this,arguments)}function Su(e,t,r,n){return Iu.apply(this,arguments)}function Iu(){return Iu=n(g().mark((function e(t,r,n,i){var o,a;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.connected&&!this.disposed){e.next=2;break}return e.abrupt("return");case 2:if(!(o=this)._connectPromise){e.next=7;break}return e.next=6,o._connectPromise;case 6:return e.abrupt("return");case 7:return r=null!=r?r:this._defaultRetries,n=null!=n?n:100,a=uu(fu,o,gu).call(o,o.serverInfo),du.debug("WebSocket URL: "+a+", try to create websocket "+r+"/"+n),o._connectPromise=new Qt.Promise((function(e,t){var s=function(n){uu(fu,o,mu).call(o,o,a,o.serverInfo.protocol,i).then((function(t){e(t)}))["catch"]((function(e){du.debug("create websocket failed: "+e.message),n0){var t=e.charAt(0);if("f"==t||"t"==t)return!0;if(Zt.startsWith(e,"DLS"))return!1;if(Zt.isNumber(e))return!1;var r=parseInt(e)+"-";return!Zt.startsWith(e,r)}return!1}},{key:"isLicenseMixed",value:function(e,t){var r,n=!1,i=e||rr.DWT.ProductKey;(rr.DWT.lclex(),t)&&((pc(rr.DWT.organizationID)||pc(rr.DWT.handshakeCode))&&i&&(n=!0,na(r={},-2444,"A license can only be specified once and has already been set using the ProductKey API.")));if(!n&&Zt.isString(i))if(i=Zt.trim(i),Zt.startsWith(i,"f")||Zt.startsWith(i,"t"));else if(""==i);else if(Zt.startsWith(i,"DLS2"))try{tc(vc,this,Sc).call(this,i)}catch(a){n=!0,na(r={},-2440,""),r._errorString=a.message}else{tc(vc,this,yc).call(this,i).LTS||(n=!0,function(e){na(e,ra.LicenseParseFailed,"The license is invalid.")}(r={}))}if(n&&r){ia(r);var o=rr.DWT.licenseException;Zt.error(o.message)}return n}},{key:"getLicenseFromDynamsoftCore",value:function(){var t,r,n=null;if(e.mapPackageRegister&&e.mapPackageRegister.license)n=null===(r=e.mapPackageRegister.license.LicenseManager)||void 0===r?void 0:r.license;else if(null!==(t=window)&&void 0!==t&&null!==(t=t.Dynamsoft)&&void 0!==t&&null!==(t=t.Core)&&void 0!==t&&null!==(t=t.mapPackageRegister)&&void 0!==t&&t.license){var i;n=null===(i=window.Dynamsoft.Core.mapPackageRegister.license.LicenseManager)||void 0===i?void 0:i.license}if(null!==n){if(""===n)return"";if(Zt.isString(n))return n=Zt.trim(n)}return null}},{key:"_initAR",value:function(e){var t,r;e&&(e.pk||(t=e.ar,r=e.u,t&&r&&(Qo.bUseDynamsoftLicenseManager=!0,rr.DWT.lsdt(rr.DWT.EnumInstance.dwt_browser),rr.DWT.lsmid(r,""),rr.DWT.lsar(t,""))))}},{key:"preParseProductKey",value:(t=n(g().mark((function i(t){var r,n,o,a;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(r=null,n=!1,r=this.getLicenseFromDynamsoftCore(),!Zt.isString(r)){i.next=32;break}if(""===r||!this.isLongKey(r)){i.next=8;break}return this.isLicenseMixed(r,!1)||(this._innerResetLicense(),Qo.bPublicLTS=!1,Qo.refProductKey=r),i.abrupt("return");case 8:if(!e.mapPackageRegister||!e.mapPackageRegister.license){i.next=14;break}return i.next=11,e.mapPackageRegister.license.getAR();case 11:a=i.sent,i.next=18;break;case 14:if(null===(o=window)||void 0===o||null===(o=o.Dynamsoft)||void 0===o||null===(o=o.Core)||void 0===o||null===(o=o.mapPackageRegister)||void 0===o||!o.license){i.next=18;break}return i.next=17,window.Dynamsoft.Core.mapPackageRegister.license.getAR();case 17:a=i.sent;case 18:if(!a){i.next=32;break}if(this._initAR(a),""!==r){i.next=26;break}return this._innerResetLicense(),Qo.refProductKey="",Qo.bPublicLTS=!0,Qo.handshakeCode="200001",i.abrupt("return");case 26:if(!a.pk){i.next=31;break}return this.isLicenseMixed(a.pk,!1)||(this._innerResetLicense(),Qo.bPublicLTS=!1,Qo.refProductKey=a.pk),i.abrupt("return");case 31:Qo.refProductKey!==r&&(n=!0);case 32:!n&&this.isLicenseMixed(null,!0)||this.reparseProductKey(t);case 33:case"end":return i.stop()}}),i,this)}))),function(e){return t.apply(this,arguments)})},{key:"reparseProductKey",value:function(e){e&&ju("Parsing Product Key...");var t=this.getLicenseFromDynamsoftCore(),r=!1;if(null===t||""===t){var n=pc(rr.DWT.organizationID),i=pc(rr.DWT.handshakeCode),o=n||i;if(t=Zt.trim(rr.DWT.ProductKey),!o){var a=tc(vc,this,yc).call(this,t);a.LTS&&(i=pc(a.handshakeCode),o=(n=pc(a.organizationID))||i)}if(o)return this._innerResetLicense(),Zt.isNumber(t)&&(n=t),Qo.handshakeCode=i,Qo.organizationID=n,Qo.licenseServer=rr.DWT.licenseServer,Qo.sessionPassword=rr.DWT.sessionPassword,void(Qo.bPublicLTS=tc(vc,this,Ic).call(this,Qo.licenseServer,o))}if(Qo.refProductKey!==t&&(this._innerResetLicense(),Zt.isString(t)&&t.length>0&&(Qo.refProductKey=t,r=!0)),r)if(this.isLongKey(Qo.refProductKey))Qo.bPublicLTS=!1;else{var s,u={_pLoad:{isEmpty:fi},_license:Qo.refProductKey,_licenseServer:[]};try{s=Os(u)}catch(l){Zt.error(l),s=!1}if(s&&Zt.isString(s.l)){var c=Zt.trim(s.l);""==c?(c="200001",Qo.organizationID=c,Qo.handshakeCode=c):(-1!=c.indexOf("-")||(Qo.organizationID=c),Qo.handshakeCode=c),Zt.isArray(s.ls)&&s.ls.length>0&&(Qo.licenseServer=s.ls),Qo.bPublicLTS=tc(vc,this,Ic).call(this,Qo.licenseServer,c),Qo.sessionPassword=s.sp}else Qo.bPublicLTS=!1,s&&Zt.isNumber(s.l)&&(Qo.handshakeCode=""+s.l)}}},{key:"_innerResetLicense",value:function(){Qo.refProductKey="",Qo.handshakeCode=undefined,Qo.organizationID=undefined,Qo.licenseServer=undefined,Qo.sessionPassword="",Qo.bPublicLTS=!0}},{key:"checkOSForAllowCore",value:function(e,t,r){if(Qo.bHTML5Edition){if(e)return tc(vc,this,kc).call(this,t);var n=r._bRemoteMode,i=r.__serverPlatform;return this.isOSOK(t,n,i)}return fi}},{key:"checkLocalPlatformForRemoteService",value:function(e){var t,r,n,i=e.__licenseInfo,o=Ju(),a=!1;for(t=0;t0&&c-1<=i){for(var l=fi,d=c-1;d>0;d--){if(u[d].indexOf("*")>-1){r=fi;break}if(d+i-c>=0){if(n[d+i-c]!=u[d]){l=di;break}}else if("*"!=u[d]){l=di;break}}if(l&&("*"==u[0]||i>=c&&n[i-c]==u[0])){r=fi;break}}}return r}},{key:"isExpiredOrFuture",value:function(e,t){if(""==e)return di;if(!t){var r=e.length;if(r>2&&"/"==e[r-2]&&"0"==e[r-1])return di}var n=Wc(e),i=(new Date).getTime(),o=i+5184e6;return n.getTime()o?fi:di}},{key:"willTrialExpire",value:function(e){if(""==e)return di;var t=Wc(e),r=(new Date).getTime();return t.getTime()r?fi:di}},{key:"isOSOK",value:function(e,t,r){var n=!1,i=!1,o=!1,a=!1,s=!1,u=!1,c=!1,l=!1;return""==e||"0"==e?fi:(t?r==Gu.enumWindow?o=!0:r==Gu.enumLinux?i=!0:r==Gu.enumMac?n=!0:r==Gu.enumEmbed?s=!0:r==Gu.enumChromeOS?u=!0:r==Gu.enumAndroid?c=!0:r==Gu.enumHarmonyOS?l=!0:r==Gu.enumiOS&&(a=!0):(n=de.bMac,i=de.bLinux,o=de.bWin,a=de.biPhone||de.biPad,u=de.bChromeOS,s=rr.navInfo.bEmbed,c=de.bAndroid,l=de.bHarmonyOS),(e=e.toLowerCase()).indexOf("windows")>-1&&o||e.indexOf("mac")>-1&&n||e.indexOf("linux")>-1&&(i||u||l)||e.indexOf("android")>-1&&c||e.indexOf("ios")>-1&&a||e.indexOf("embed")>-1&&s?fi:di)}},{key:"isBrowserOK",value:function(e){if(Zt.isString(e)){if(""==e||"0"==e)return fi;var t=(e=e.toLowerCase()).split(";"),r=di;return Zt.each(t,(function(e){("chrome"==Zt.trim(e)&&(de.bChrome||de.bSafari||de.bOpera||de.bEdge)||"ie"==Zt.trim(e)&&de.bIE||"firefox"==Zt.trim(e)&&de.bFirefox)&&(r=fi)})),r}return di}},{key:"isAllowLicenseType",value:function(e,t){return t.Core?e.Core:t.PDFRasterizer?e.PDFRasterizer:t.Webcam||t.Camera?e.Webcam:t.barcode1D?e.barcode1D:t.QR?e.QR:t.PDF417?e.PDF417:t.DataMatrix?e.DataMatrix:t.OCR?e.OCR:t.OCRPro?e.OCRPro:e.Core}},{key:"setNoAllowedLicenseTypeError",value:function(e,t,r){r.Core?Pa(e):r.Webcam||r.Camera?t||r.Camera?function(e){e._errorCode=-2431,Zo()?e._errorString="The license for the Camera Addon is not found or has expired.":na(e,-2431,"The current product key does not support Camera Addon. "+oa()),ia(e)}(e):function(e){e._errorCode=-2338,Zo()?e._errorString="The license for the module direct show is not found or has expired.":e._errorString="The current product key does not support Webcam. "+oa(),ia(e)}(e):r.PDFRasterizer?t?function(e){e._errorCode=-2370,Zo()?e._errorString="The license for the module pdf rasterizer is not found or has expired.":e._errorString="The current product key does not support Pdf Rasterizer Wasm. "+oa(),ia(e)}(e):Da(e):r.OCR?function(e){e._errorCode=-2340,Zo()?e._errorString="The license for the module ocr is not found or has expired.":e._errorString="The current product key does not support OCR. "+oa(),ia(e)}(e):r.OCRPro?function(e){e._errorCode=-2341,Zo()?e._errorString="The license for the module ocr pro is not found or has expired.":e._errorString="The current product key does not support OCR pro. "+oa(),ia(e)}(e):Aa(e)}},{key:"getLicenseDateString",value:function(e){var t,r=e.getFullYear();return[(t=e.getMonth()+1)>=10?""+t:"0"+t,"/",e.getDate()>=10?""+e.getDate():"0"+e.getDate(),"/",r].join("")}},{key:"hasPDFRProductKey",value:function(e){return!!this.checkProductKey(e,{PDFRasterizer:!0},!0)||(e._resetErr(),!1)}},{key:"checkPDFProductKeyWhenNeeds",value:function(e,t){var r;if((t==rr.DWT.EnumDWT_ImageType.IT_PDF||t==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_PDF)&&(Qo.bHTML5Edition?e.__addon&&e.__addon.PDF&&(r=e._getConvertMode()):e.Addon&&e.Addon.PDF&&(r=e._getConvertMode()),r==Zu.CM_RENDERALL||r==Zu.CM_RENDERALLWITHANNOTATION))return this.checkProductKey(e,{PDFRasterizer:!0},!0);return fi}},{key:"getPublicLicenseContent",value:function(e){var t=[],r=e;if(!Zt.isString(r)){if(Zt.isUndefined(r))return"";r=r instanceof Error||"message"in r?r.message:""+r}var n=r.indexOf("["),i=r.indexOf("]",n),o=r.indexOf("(",i),a=r.indexOf(")",o);if(-1==n||-1==i||-1==o||-1==a)return r;n>0&&t.push(r.substring(0,n));var s=r.substring(n+1,i),u=r.substring(o+1,a);return t.push(['',s,""].join("")),t.push(r.substring(a+1)),t.join("")}},{key:"getLTSLicense",value:function(){return Qo.bPublicLTS?"":Qo.handshakeCode||Qo.organizationID}}]);var t}();function yc(e){var t,r,n=e,i=e.indexOf("-"),o=-1!=i;return r={},o&&(n=e.substring(0,i)),t=Number(n),isNaN(t)||String(Number(t))!==n||(o?r.handshakeCode=e:r.organizationID=e,r.LTS=fi),r}function Sc(e){Os({_pLoad:{isEmpty:fi},_license:e,_licenseServer:[]})}function Ic(e,t){var r=!0;if(Zt.isArray(e)&&e.length>0){var n=e[0];if(Zt.isString(n)&&""!=n)"mlts.dynamsoft.com"!==new Si(n).getHostname()&&(r=!1)}return r&&(!t||"200001"===t||Zt.startsWith(t,"200001-"))}function bc(e,t,r){return this.checkOSForAllowCore(e,t,r)}function Tc(e,t,r,n,i){var o,a=!1;if(Qo.bHTML5Edition&&Zt.isFunction(e._needCheckProxyRemoteScanLicense)&&(a=e._needCheckProxyRemoteScanLicense()),t&&t.LTS){if(!t||!Zt.isArray(t.Detail)||0==t.Detail.length)return this.isLTS()?Pa(e):Aa(e),di}else if(!t||!Zt.isArray(t.Detail)||0==t.Detail.length)return this.isLTS()?Pa(e):Aa(e),di;var s,u,c,l,d=0,f=0,h=[],g=[],m=di,p=di,v=di,_=di,y=di;if(!this.isBindDomainOK(t.Domain))return function(e){na(e,-2342,"The domain of your current site does not match the domain bound in the current product key. "+oa()),ia(e)}(e),di;for(t.Detail.length>0&&(o="FALSE"!=(c=t.Detail[0]).Trial),u=1;u0)return S.splice(0),function(e,t){var r=oa();na(e,ra.LicenseVersionNotCurrent,"The current product key is not for version ".concat(t,". ").concat(r)),ia(e)}(e,"0"==qi.toString()?[Ji,Qi].join("."):[Ji,Qi,qi].join(".")),!1;S.splice(0)}else g=t.Detail;for(u=0;u=nc||l.Core&&Qo.bActiveXEdition||!l.Core){var C=!1;if(l.Core)(this.checkOSForAllowCore(r,c.OS,e)||Qo.bActiveXEdition&&l.ActiveX)&&(C=!0);else{var w=r;n.Camera&&(w=!0),tc(vc,this,bc).call(this,w,c.OS,e)&&(C=!0)}C?this.isBrowserOK(c.Browser)||i?(d++,b=di):p=fi:n.Core?m=fi:n.PDFRasterizer?_=fi:(n.Webcam||n.Camera)&&(y=fi)}else v=fi;b&&f++}}if(d>0)return fi;if(0==f)return this.setNoAllowedLicenseTypeError(e,r,n),di;if(h.length>0){var E,k=0,A=1e20,x="",P=(new Date).getTime();for(s="",u=0;uk?(k=E.getTime(),s=h[u]):E.getTime()>P&&E.getTime()-1||"win=(aph) or mac=(ph) or linux(h)"==e?(t=fi,e.indexOf("html5;activex;oldie")>-1?i=fi:e.indexOf("html5;activex")>-1?(r=fi,h=fi,i=fi):(r=fi,h=fi),e.indexOf(";remotescan")>-1&&(r=fi,f=fi,e.indexOf(";onlyremote")>-1&&(h=di))):"1d barcode reader"==e?n=fi:"2d barcode reader(qrcode)"==e?o=fi:"2d barcode reader(pdf417)"==e?a=fi:"2d barcode reader(data matrix)"==e?s=fi:"ocr"==e?u=fi:"webcam"==e?c=fi:"pdf rasterizer"==e?l=fi:"proocr"==e&&(d=fi)),{Core:t,Html5:r,RemoteScan:f,LocalScan:h,ActiveX:i,PDFRasterizer:l,Webcam:c,barcode1D:n,QR:o,PDF417:a,DataMatrix:s,OCR:u,OCRPro:d}}function kc(e){var t=e.toLowerCase();return t.indexOf("wasm")>-1||t.indexOf("mobile")>-1}var Ac=new _c;function xc(e,t){return Pc.apply(this,arguments)}function Pc(){return(Pc=n(g().mark((function e(t,r){var n;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Zo()){e.next=2;break}return e.abrupt("return");case 2:if(e.prev=2,rr.DWT.li({instanceMode:rr.DWT.lgdt()},"")){e.next=17;break}return r&&ju("Getting Machine ID."),e.prev=6,e.next=9,Uu();case 9:return n=e.sent,e.next=12,Dc(n);case 12:e.next=17;break;case 14:e.prev=14,e.t0=e["catch"](6),Zt.log(e.t0);case 17:e.next=22;break;case 19:e.prev=19,e.t1=e["catch"](2),Zt.log(e.t1);case 22:case"end":return e.stop()}}),e,null,[[2,19],[6,14]])})))).apply(this,arguments)}function Dc(e){return Fc.apply(this,arguments)}function Fc(){return(Fc=n(g().mark((function e(t){var r;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=7;break}if(!(Zt.isArray(t.result)&&t.result.length>3)){e.next=5;break}r=t.result[3],e.next=7;break;case 5:if(!t.description){e.next=7;break}return e.abrupt("return",{code:t.exception,message:t.description});case 7:Zt.isString(r)&&""!=r&&(rr.DWT.lsmid(r,""),rr.DWT.lsmid2b(r));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Wc(e){var t,r=e;return r=r.replace(/-/g,"/"),t=Date.parse(r),isNaN(t)&&(t=0),(t=new Date(t)).setHours(23,59,59,999),t}function Nc(e){if(""==e)return 65536;var t=Wc(e),r=(new Date).getTime(),n=(t.getTime()-r)/864e5;return t.getTime()=0;i--)n[i]===t&&n.splice(i,1)}else this._exec={}}}])}();function Mc(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function Lc(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=_(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==_(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Bc(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var Uc,Vc="[bio]: ",jc=window,Gc=jc&&jc.FormData,Hc=new WeakSet,zc=function(e){function t(e){var r;return o(this,t),Mc(r=i(this,t),Hc),Lc(r,"_attrs",{}),Zt.mix(r._attrs,{action:"",data:{},bChunkedSendData:fi,ajaxConfig:{value:{},type:"post",processData:di,cache:di,dataType:"text",async:fi,contentType:di,retry:0,headers:{"X-Requested-With":di}},ajax:"",formData:"",CORS:di,bOnlyResponseEmptyIsOK:fi}),Zt.mix(r._attrs,e),Bc(Hc,r,Kc).call(r),r}return f(t,e),s(t,[{key:"get",value:function(e){return e in this._attrs?this._attrs[e]:""}},{key:"set",value:function(e,t){e in this._attrs&&(this._attrs[e]=t)}},{key:"uploadFilesToServer",value:function(e){return Bc(Hc,this,Jc).call(this,e)}},{key:"uploadToServer",value:function(e){var r=this,n=r.get("ajaxConfig");Bc(Hc,r,Qc).call(r),e&&e.size>0&&(Bc(Hc,r,qc).call(r,e),Zt.isString(e.name)&&""!=e.name?r.name=e.name:r.name=e.fileName,e=null),Zt.mix(n,{data:r.get(t.PROP.formData),url:r.get(t.PROP.action),beforeSend:function(e,n,i){e.upload.addEventListener("progress",(function(e){r.fire(t.event.PROGRESS,{loaded:e.loaded,total:e.total,name:r.name})}),!1)}});var i=r.get("async");if(Zt.mix(n,{method:"POST",async:i,onSuccess:function(e,n,i){Zc(r.get(t.PROP.data)),Zc(r.get(t.PROP.formData));var o=r.get(t.PROP.ajax);Zt.isFunction(o.dispose)&&o.dispose(),r.set(t.PROP.data,null),r.set(t.PROP.formData,null),r.set(t.PROP.ajax,null);var a=Bc(Hc,r,Xc).call(r,e,i);r.fire(t.event.SUCCESS,a)},onError:function(e,n,i){var o;Zc(r.get(t.PROP.data)),Zc(r.get(t.PROP.formData));var a,s,u=r.get(t.PROP.ajax);Zt.isFunction(u.dispose)&&u.dispose(),r.set(t.PROP.data,null),r.set(t.PROP.formData,null),r.set(t.PROP.ajax,null),e&&Zt.isArray(e)&&e.length>2?(o=e[0],a=e[1],s=e[2]):(o=e,a=n,s=i),Bc(Hc,r,Yc).call(r,s,a,o)}}),i){var o=Vi(n);return r.set(t.PROP.ajax,o),!0}return Vi(n)}},{key:"abort",value:function(){var e=this,t=e.get("ajax");return Zt.isObject(t)?(t.abort(),e.set("ajax",!1),e):(Zt.log(Vc+"abort(), the value of io invalid!"),e)}},{key:"setRequestHeader",value:function(e,t){var r=this.get("ajaxConfig");return r.headers[e]=t,this.set("ajaxConfig",r),r=null,t}}])}(Oc);function Kc(){this.get("CORS");var e=this.get("ajaxConfig");return Zt.mix(e,{xhrFields:{withCredentials:!1}}),e}function Jc(e){var t=this,r=t.get(Rc.PROP.ajaxConfig),n=[];if(Bc(Hc,t,Qc).call(t),Zt.each(e,(function(e){e&&e.size>0?(Bc(Hc,t,qc).call(t,e),Zt.isString(e.name)&&""!=e.name?n.push(e.name):n.push(e.fileName)):n.push("")})),Zt.mix(r,{data:t.get(Rc.PROP.formData),url:t.get(Rc.PROP.action),beforeSend:function(e,r,n){e.upload.addEventListener("progress",(function(e){t.fire(Rc.event.PROGRESS,{loaded:e.loaded,total:e.total,name:""})}),!1)}}),Zt.mix(r,{method:"POST",async:t.get("async"),onSuccess:function(e,r,i){var o="";n=[],e&&(e&&Zt.isArray(e)&&e.length>1?o=e[0]:Zt.isString(e)&&(o=e)),o=Bc(Hc,t,Xc).call(t,o,i),t.fire(Rc.event.SUCCESS,o)},onError:function(e,r,i){var o,a;n=[],e&&Zt.isArray(e)&&e.length>2?(o=e[1],a=e[2]):(o=r,a=i),Bc(Hc,t,Yc).call(t,a,o)}}),t.name="",t.get("async")){var i=Vi(r);return t.set(Rc.PROP.formData,null),t.set(Rc.PROP.ajax,i),!0}var o=Vi(r);return t.set(Rc.PROP.formData,null),o}function Qc(){var e,t=this,r=t.get("data");if(Gc)if(r instanceof Gc)t.set(Rc.PROP.formData,r);else{e=new Gc;try{Zt.each(r,(function(t,r){e.append(r,t)})),t.set(Rc.PROP.formData,e)}catch(jj){Zt.log(Vc+"something error when reset FormData.")}}else Zt.log(Vc+"the browser does not support ajax.")}function qc(e){if(!Zt.isObject(e))return Zt.log(Vc+"_addFileData(), file parameter invalid!"),!1;var t=this.get(Rc.PROP.formData),r=e.name,n=e.remoteFilename;return n||(n="RemoteFile"),t.append(n,e,r),this.set(Rc.PROP.formData,t),e=null,t}function Yc(e,t,r){var n=Rc.status.ERROR,i={status:n,msg:t,response:!1,name:this.name};e&&(i.httpStatus=e.status,i.response=r||e.responseText),this.fire(n,i)}function Xc(e,t){var r,n,i,o=!1,a=this.name,s=Rc.status.SUCCESS,u=Rc.event.ERROR,c=t?t.status:0;if(Zt.log("Response from server: "+e),!this.get("bOnlyResponseEmptyIsOK"))return{status:s,msg:!1,json:!1,response:e,name:a,httpStatus:c};if(Zt.isUndefined(e)||""===e)r={status:s,msg:!1,json:!1,response:"",name:a,httpStatus:c};else if(Zt.isString(e)){try{for(n=0;n10);n++){if("{"==(i=e[n])){o=!0;break}if(" "!=i&&"\r"!=i&&"\n"!=i&&"\t"!=i)break}if(o){var l=Zt.parse(e);r=1==l.status?{status:s,msg:!1,json:l,response:e,name:a,httpStatus:c}:{status:u,msg:!1,json:l,response:e,name:a,httpStatus:c}}}catch(jj){o=!1,Zt.log(jj)}if(!o){var d=String(e);r=""==(d=d.replace(/( |\t|\r|\n)/g,""))?{status:s,msg:!1,json:!1,response:e,name:a,httpStatus:c}:{status:u,msg:!1,json:!1,response:e,name:a,httpStatus:c}}}else r={status:s,msg:!1,json:!1,response:"",name:a,httpStatus:c};return r}function Zc(e){e&&e instanceof Gc&&e.forEach&&e.forEach((function(t,r){r&&e["delete"](r)}))}function $c(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function el(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=_(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==_(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function tl(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}Rc=zc,Lc(zc,"event",{SUCCESS:"success",ERROR:"error",PROGRESS:"progress"}),Lc(zc,"status",{SUCCESS:"success",ERROR:"error"}),Lc(zc,"PROP",{action:"action",data:"data",bChunkedSendData:"bChunkedSendData",ajaxConfig:"ajaxConfig",ajax:"ajax",formData:"formData",CORS:"CORS",bOnlyResponseEmptyIsOK:"bOnlyResponseEmptyIsOK"});var rl=new WeakSet,nl=function(e){function t(e){var r;return o(this,t),$c(r=i(this,t),rl),r._attrs={action:"",retry:0,timeout:0,CORS:di,async:fi,dataType:"text",fileStatus:"",data:{},bOnlyResponseEmptyIsOK:fi},Zt.mix(r._attrs,e),tl(rl,r,ol).call(r),r}return f(t,e),s(t,[{key:"get",value:function(e){return e in this._attrs?this._attrs[e]:""}},{key:"set",value:function(e,t){e in this._attrs&&(this._attrs[e]=t)}},{key:"upload",value:function(e){var t;if(e){if(Zt.isArray(e))return t=this._uploadType.uploadFilesToServer(e),e=null,t;if(Zt.isObject(e)){var r=e;return r.size?(r.id||(r.id=Zt.guid("file-")),r.size&&(r.textSize=tl(rl,this,il).call(this,r.size))):r.size=0,t=this._uploadType.uploadToServer(r),r=null,e=null,t}}return t=this._uploadType.uploadToServer(e),e=null,t}},{key:"abort",value:function(e){return this._uploadType&&this._uploadType.abort(),!0}},{key:"setRequestHeader",value:function(e,t){this._uploadType.setRequestHeader(e,t)}}])}(Oc);function il(e){var t=-1;do{e/=1024,t++}while(e>99&&t<4);return Math.max(e,.1).toFixed(1)+["KB","MB","GB","TB"][t]}function ol(){var e=this,t={async:e.get(Uc.PROP.async),action:e.get(Uc.PROP.action),data:e.get(Uc.PROP.data),CORS:e.get(Uc.PROP.CORS),bOnlyResponseEmptyIsOK:e.get(Uc.PROP.bOnlyResponseEmptyIsOK)};this._uploadType=new zc(t);var r=this._uploadType.get(zc.PROP.ajaxConfig);return r&&(r.dataType=e.get(Uc.PROP.dataType),r.async=e.get(Uc.PROP.async),r.retry=e.get(Uc.PROP.retry)),this._uploadType.on(zc.event.SUCCESS,tl(rl,e,sl),e),this._uploadType.on(zc.event.ERROR,tl(rl,e,sl),e),this._uploadType.on(zc.event.PROGRESS,tl(rl,e,al),e),this._uploadType}function al(e){this.fire(Uc.event.PROGRESS,e)}function sl(e){var t=this,r=e.status,n=e.msg,i=t.get("file");if(Zt.mix(e,{file:i}),"success"===r)t.fire(Uc.event.SUCCESS,e);else{if(!1===n||("abort"===n?Zt.mix(e,{canceled:!0}):"timeout"===n&&Zt.mix(e,{timeout:!0})),!n){var o=e.httpStatus;o&&o>=200&&o<300&&(200==o?n="OK":201==o?n="Created":202==o?n="Accepted":203==o?n="Non-Authoritative":204==o?n="No Content":205==o?n="Reset Content":206==o?n="Partial Content":207==o&&(n="Multi-Status"),e.msg=n)}t.fire(Uc.event.ERROR,e)}}Uc=nl,el(nl,"event",{SUCCESS:"success",ERROR:"error",PROGRESS:"progress"}),el(nl,"PROP",{action:"action",retry:"retry",timeout:"timeout",CORS:"CORS",async:"async",dataType:"dataType",fileStatus:"fileStatus",data:"data",bOnlyResponseEmptyIsOK:"bOnlyResponseEmptyIsOK"});var ul={Loading:"Processing...",LoadingTiff:"Processing tiff...",LoadingPdf:"Processing pdf...",Encoding:"Processing...",ConvertingToBlob:"Converting to blob...",ConvertingToBase64:"Converting to base64...",SavingPdf:"Saving pdf...",SavingTiff:"Saving tiff...",Downloading:"Downloading...",Uploading:"Uploading...",Transfer:"Transferring...",CanvasLoading:"Loading ...",Err_ServiceModeNotSupportMobile:"Service Mode does not support your Operating System. Please contact the site administrator."};function cl(e,t){Qt.detect.bMaskShow=!0,rr.DWT.ScanDirectly||Zt.isFunction(rr.DWT.OnWebTwainPreExecute)&&rr.DWT.OnWebTwainPreExecute(e,t)}function ll(){Qt.detect.bMaskShow=!1,rr.DWT.ScanDirectly||Zt.isFunction(rr.DWT.OnWebTwainPostExecute)&&rr.DWT.OnWebTwainPostExecute()}function dl(e){var t=e||{};t.basePath&&(Lo.basePath=t.basePath),t.pathType&&(Lo.pathType=t.pathType),Zt.isUndefined(t.bDiscardBlankImage)||(Lo.bDiscardBlankImage=t.bDiscardBlankImage),t.msgPrefix&&t.msgPrefix,t.msgSuffix&&t.msgSuffix,t.detectType&&(Qt.detect.detectType=t.detectType),t.tryTimes&&(Qt.detect.tryTimes=t.tryTimes);var r=rr.DWT.RemoteScanConfig;r||(r={sessionTimeout:300,keepAwake:!0},rr.DWT.RemoteScanConfig=r),r.keepAwake===undefined&&(r.keepAwake=!0)}function fl(){return!!Zt.getWakeLock()}function hl(e){return gl.apply(this,arguments)}function gl(){return(gl=n(g().mark((function e(t){var r;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Zt.getWakeLock(),!t){e.next=7;break}if(null!=r){e.next=5;break}return e.next=5,Zt.toggleWakeLock();case 5:e.next=10;break;case 7:if(!r){e.next=10;break}return e.next=10,Zt.toggleWakeLock();case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ml(){for(var e,t,r,n=["dynamsoft.webtwain.install.js","dynamsoft.webtwain.viewer.js","dynamsoft.lts.js","dynamsoft.webtwain.viewer.css","dynamsoft.webtwain.css"],i=document.head.childNodes,o=i.length-1;o>=0;o--)if("LINK"==(t=i[o]).tagName?r=t.href:"SCRIPT"==t.tagName&&(r=t.src),r)for(e=0;e=0&&t.remove();Qt.detect.cssLoaded=!1}function pl(e){return vl.apply(this,arguments)}function vl(){return(vl=n(g().mark((function e(t){var r;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t&&((r=document.createElement("style")).innerHTML=['@import url("',yl(),"/src/dynamsoft.webtwain.viewer.css",Qt.timestamp,'")'].join(""),t.appendChild(r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function _l(e,t){var r;for(r=0;r
';var i,o=yl()+"/src/dynamsoft.webtwain.css",a=["alwaysRaised=yes,z-look=yes,top=0,left=0,toolbar=no,menubar=no,location=no,status=no,width=",0,",height=",0].join(""),s=window.open("about:blank","_blank",a);t=["",'','',n,""].join(""),s&&(s.document.write(t),s.document.close(),s.focus(),(i=s.document.body)?i.onload=function(){s&&s.print(),Zt.log("print image...ok")}:Zt.log("cannot find image"))}};Qt.html5.Funs2=Il;var bl=Zt.isString,Tl=Zt.isArray,Cl=Zt.each;function wl(e,t){if(bl(t))e.push('"'),e.push(t),e.push('"');else if(Tl(t)){var r=fi;e.push("["),Cl(t,(function(t){r?r=di:e.push(","),wl(e,t)})),e.push("]")}else t===undefined?e.push('""'):e.push(t)}function El(){for(var e=[],t=arguments.length,r=new Array(t),n=0;n0)if(1===r.length){var i=r[0];e.push("["),wl(e,i),e.push("]")}else if(2===r.length){var o=r[0],a=r[1];e.push("["),wl(e,o),e.push(","),wl(e,a),e.push("]")}else wl(e,Array.prototype.slice.call(r));return e.join("")}function kl(e){return e instanceof ArrayBuffer||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||window.Uint8ClampedArray&&e instanceof window.Uint8ClampedArray||e instanceof Float32Array||e instanceof Float64Array}var Al=function(e){return e.TWAINSCANNER=16,e.WIASCANNER=32,e.TWAINX64SCANNER=64,e.ICASCANNER=128,e.SANESCANNER=256,e.ESCLSCANNER=512,e.WIFIDIRECTSCANNER=1024,e.WIATWAINSCANNER=2048,e}(Al||{}),xl=Al.TWAINSCANNER|Al.WIASCANNER|Al.TWAINX64SCANNER|Al.ICASCANNER|Al.SANESCANNER|Al.ESCLSCANNER|Al.WIFIDIRECTSCANNER|Al.WIATWAINSCANNER,Pl=Al.TWAINSCANNER|Al.WIASCANNER|Al.TWAINX64SCANNER|Al.ICASCANNER|Al.SANESCANNER,Dl=Al.TWAINSCANNER|Al.WIATWAINSCANNER|Al.TWAINX64SCANNER|Al.ICASCANNER|Al.SANESCANNER;Al.TWAINSCANNER,Al.WIASCANNER,Al.WIATWAINSCANNER;var Fl=Al.ESCLSCANNER|Al.WIFIDIRECTSCANNER,Wl=Al.TWAINSCANNER|Al.WIATWAINSCANNER,Nl=1;function Rl(){return(++Nl).toString()}function Ol(){return["dwt_",Zt.getRandom()].join("")}var Ml=0;function Ll(e,t,r){if(Zt.log("showMask:"+e+"--"+Ml),0==Ml)if(t){cl(t);var n=Qt.mask.dlgMask;if(n){n.style.zIndex="10000";var i=Zt.sizzle(".dynamsoft-backdrop",n.parentNode);i&&i.length>0&&(i[0].style.zIndex="10000")}}else cl(r||{});Ml++}function Bl(e){Zt.log("hideMask:"+e+"--"+Ml),Ml>1?Ml--:Ml<=1&&(ll(),Ml=0)}var Ul=function(){return s((function e(t,r){o(this,e),c(this,"m_server",""),c(this,"m_iUsingTime",0),c(this,"m_countMap",{}),c(this,"m_newConsum",!1),c(this,"m_mapSavedToDb",!1),this.clearData(),this.m_enumInstance=t,t==rr.DWT.EnumInstance.dwt_desktop?(this.m_deploymentType="desktop",this.m_server=r):t==rr.DWT.EnumInstance.dwt_browser?(this.m_deploymentType="browser",this.m_server=r):t==rr.DWT.EnumInstance.dbr&&(this.m_deploymentType="browser",this.m_server="")}),[{key:"clearData",value:function(){this.m_iUsingTime=0,this.m_jvUsingTime=Zt.nil,this.m_countMap={},this.m_newConsum=!1,this.m_mapSavedToDb=!1,this.m_minExpiredTime=Zt.nil,this.m_maxExpiredTime=Zt.nil,this.m_cu=Zt.nil,this.m_ar=Zt.nil,this.m_ltsInstance=Zt.nil}},{key:"set_cu",value:function(e){this.m_cu=e}},{key:"get_cu",value:function(){return this.m_cu}},{key:"set_ar",value:function(e){this.m_ar=e}},{key:"get_ar",value:function(){return this.m_ar}},{key:"get_ltsInstance",value:function(e){return this.m_ltsInstance||(this.m_ltsInstance=e(this.m_enumInstance)),this.m_ltsInstance}},{key:"inited_ltsInstance",value:function(){return!!this.m_ltsInstance}},{key:"set_maxExpiredTime",value:function(e){this.m_maxExpiredTime=e}},{key:"get_maxExpiredTime",value:function(){return this.m_maxExpiredTime}},{key:"set_minExpiredTime",value:function(e){this.m_minExpiredTime=e}},{key:"get_minExpiredTime",value:function(){return this.m_minExpiredTime}},{key:"get_deploymentType",value:function(){return this.m_deploymentType}},{key:"get_enumDeploymentType",value:function(){return this.m_enumInstance}}])}();var Vl=rr.DWT;Vl.LTS=Vl.LTS||{},Vl.licenseException={code:0,message:"",fromLTS:!1},Vl.bLTSOnline=!0,Vl.axInstance=undefined,Vl.lOnUpdateDWObj=[],Vl.EnumInstance={dwt_desktop:0,dwt_browser:1,dbr:2};var jl,Gl=0,Hl={},zl=!1,Kl=!1,Jl=!1,Ql=!1,ql=!1;function Yl(){var e=Qo.handshakeCode;return Zt.isString(e)||(e=""),e}function Xl(){var e=Qo.organizationID;return Zt.isNumber(e)?e=""+e:Zt.isString(e)||(e=""),e}function Zl(){return Zt.replaceAll(Io.JSVersion,",",".")}function $l(e,t){var r=e;return r===Zt.nil&&(r=rr.DWT.lgdt()),r==Vl.EnumInstance.dbr?(Vl._dbrLicense||(Vl._dbrLicense=new Ul(r,"")),Vl._dbrLicense):(Vl._dwtDLicense||(Vl._dwtDLicense=new Ul(r,"")),Vl._dwtDLicense)}Vl.lupverfy=function(){$l(Vl.lgdt()).get_ltsInstance(rd),$l(Vl.EnumInstance.dbr).get_ltsInstance(rd)};var ed=Vl.EnumInstance.dwt_desktop;Vl.lsdt=function(e,t){ed=e},Vl.lgdt=function(e){return ed},Vl.lsmid=function(e,t){$l(Vl.lgdt()).set_cu(e)},Vl.lsar=function(e,t){$l(Vl.lgdt()).set_ar(e)},Vl.lsmid2b=function(e){$l(Vl.lgdt("")).set_cu(e)},Vl.lgar=function(e,t){return $l(e).get_ar()},Vl.laddDWTObj=function(e){var t=!1;Zt.each(Vl.lOnUpdateDWObj,(function(r){if(r==e)return t=!0,!1})),t||Vl.lOnUpdateDWObj.push(e)},Vl.lremoveDWTObj=function(e){Zt.each(Vl.lOnUpdateDWObj,(function(t,r){if(t==e)return Vl.lOnUpdateDWObj.splice(r,1),!1}))},Vl.lsendUpdateEvt=function(e,t){var r=[];if(Zt.each(Vl.lOnUpdateDWObj,(function(t){e==Vl.EnumInstance.dwt_desktop&&r.push(t)})),0==r.length)return Qt.Promise.resolve();var n,i=r[0];return i._bAx?(Zt.each(r,(function(t){t.SetLTSInfo($l(e).get_ar(),$l(e).get_cu())})),i.GetLicenseInfo().then((function(r){r&&Zt.isArray(r.Detail)&&r.Detail.length>0&&Vl.lsexp(e,r.Detail[0].ExpireDate,t)}))):(n=i.SetLTSLicenseAsync($l(e).get_ar()).then((function(r){r&&Zt.isArray(r.Detail)&&r.Detail.length>0&&Vl.lsexp(e,r.Detail[0].ExpireDate,t)})),Zt.each(r,(function(t,r){0!=r&&t.SetLTSLicenseAsync($l(e).get_ar())})),n)},Vl.lgcb=function(){var e=[];return de.bChrome?e.push("Chrome"):de.bFirefox?e.push("Firefox"):de.bEdge?e.push("Edge"):de.bIE?e.push("IE"):de.bSafari?e.push("Safari"):de.bOpera?e.push("Opera"):de.b360SE?e.push("360SE"):de.bTencentTraveler?e.push("TencentTraveler"):de.bMaxthon?e.push("Maxthon"):de.bMetaSr?e.push("MetaSr"):de.bTheWorld?e.push("TheWorld"):de.bUC?e.push("UC"):de.bHuaWeiBrowser&&e.push("HuaWeiBrowser"),e.push(de.strBrowserVersion),de.bWin?e.push("Windows"):de.bMac?e.push("Mac"):de.bLinux?e.push("Linux"):de.bAndroid?e.push("Android"):de.bChromeOS?e.push("ChromeOS"):de.bHarmonyOS?e.push("HarmonyOS"):Lo.bMobile?e.push("Mobile OS"):rr.navInfo.bEmbed&&e.push("Embed OS"),e.join(" ")};var td={NetworkError:-2440,Timedout:-2441,JsonError:-2442,CorsError:-2443,Expired:-2445,LtsJsLoadError:-2446,UUIDError:-2447};function rd(e){var t,r,n=Qo.licenseServer;if(n&&n.length>0)for(t=0;t-1||e.indexOf("timeout")>-1?t=td.Timedout:(e.indexOf("access-control-allow-origin")>-1||e.indexOf("cors")>-1)&&(t=td.CorsError),t}function cd(e,t){if(t){var r=t.code||t.ltsErrorCode,n=t.message;111==r||106==r||108==r?(Pa(e,r),e._errorString=n):(e._errorCode=r,e._errorString=n),rr.DWT.lsetException(e._errorCode,e._errorString,!0)}}function ld(e,t){e.__licenseInfo=t,function(e){e.__calic||(e.__calic=e.__licenseInfo)}(e)}function dd(e){var t=rr.DWT.licenseException;t.code=e.code,t.message=e.message,e&&(fd(e),e instanceof Error?Zt.error(e):Zt.error(Zt.stringify(e)))}function fd(e){Zt.isFunction(rr.DWT.OnWebTwainError)?rr.DWT.OnWebTwainError(e):Zt.isFunction(window.Dynamsoft_OnError)&&window.Dynamsoft_OnError(e)}function hd(e){return e==ra.LicenseExpiredForDLS||e==ra.LicenseNoCoreForDLS||e==ra.LicenseNoCore||e==ra.LicenseInvalid||e==ra.LicenseExpired||e==ra.LicenseParseFailed||e==ra.LicenseIsFuture||e==ra.LicenseVersionNotCurrent}function gd(e){return e==ra.LicenseExpired}function md(e){var t=0,r=e.message;Zt.isNumber(e.code)?t=e.code:Zt.isString(r)&&(t=-1),0!=t&&function(e,t){Zt.isFunction(rr.OnLicenseError)&&rr.OnLicenseError(t,e)}(t,r)}function pd(e){md(Gs(e))}Vl.lglic=id,Vl.lgbuuid=function(){return""},Vl.lshow=function(){return{t:jl,t2:Gl,m:Zt.stringify(Hl)}},Vl.lgct=function(e){switch(e){case 0:return"3011";case 1:return"3012";case 2:return"3014";case 3:return"3013";case 4:return"3015";case 14:return"3016";case 3001:return"3001";case 3002:return"3002";case 3003:return"3003";case 3004:return"3004";case 3005:return"3005";case 3006:return"3006";case 3007:return"3007";case 3008:return"3008";case 3009:return"3009";case 5001:return"5001";case 4001:return"4001";case 4002:return"4002";case 4003:return"4003"}return""},Vl.lcvrf=function(e){e&&(e._canConsume&&!e._canConsume()||setTimeout((function(){Vl.lcvrf_(e)}),1))},Vl.lcvrf_=function(e){var t;t=Vl.lgdt();var r,n=Vl.DeviceFriendlyName||"",i=Vl.lgcb(),o=$l(t),a={hs:Yl(),og:Xl(),cu:o.get_cu(),fn:n,cw:"",os:i,v:Zl(),dt:o.get_deploymentType(),ed:"js"},s=function(e,t){var r,n,i=0;if(Zt.isString(e)&&""!=e&&"{}"!=e&&t&&Zt.isArray(t)&&!(t.length<1)){if(n=$l(t[0]),r=Zt.parse(e),Vl.lclex(),0==Gl){var o=ad(),a="";Gl=o,jl=sd(o),Hl={},i=0,Zt.each(r,(function(e,t){(t0&&n.get_ltsInstance(rd).s(Qo.licenseServer,a,i,!0).then((function(){}),(function(e){}))}Zt.each(r,(function(e,t){var r=!1,o=parseInt(t);o>0&&o!=i&&(o+18e41&&(i=t);var o=ad();if(Gl>0&&Gl+18e40&&c++})),d.cts=f,u||n+18e40?t.sFun(e.result[0],t.params):t.sFun("",t.params):t.sFun&&t.sFun(e)},Vl.lsexp=function(e,t,r){var n,i=t;if(3==(n=(i=Zt.replaceAll(i,"/","-")).split("-")).length){var o=n[0],a=n[1],s=n[2];a.length<2&&(a=(a="00"+a).substr(a.length-2)),s.length<2&&(s=(s="00"+s).substr(s.length-2)),i=[o,a,s].join("-")}var u=[i,"T23:59:59.999Z"].join("");$l(e).set_minExpiredTime(u),$l(e).set_maxExpiredTime(u)},Vl.lunload=n(g().mark((function GJ(){return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Vl.lavrf__unload();case 2:Gl=0,jl=Zt.nil,Hl={},Kl=!1,zl=!1,Jl=!1,Ql=!1,ql=!1,Vl.lclex(),Vl.bLTSOnline=!0,Vl.axInstance=Zt.nil,Vl.lOnUpdateDWObj=[];case 14:case"end":return e.stop()}}),GJ)}))),Vl.lcexp=function(e,t){return $l(e).get_ltsInstance(rd).caret().then((function(){return!1}),(function(e){var t=Vl.licenseException,r="";return e instanceof Error||"message"in e?r=e.message:Zt.isString(e)&&(r=e),Vl.lsetException(td.Expired,r,!1),Ql||(Ql=!0,Zt.error(r),rr.OnLTSLicenseError&&rr.OnLTSLicenseError(Ac.getPublicLicenseContent(t.message),t.code)),!0}))},Vl.OnLicenseException=function(){var e=Vl.licenseException,t=e.message;if(Zt.isString(t)&&(t.indexOf("Error Code")>-1?t=Zt.replaceAll(t,"Error Code","error code"):t.indexOf("Error code")>-1&&(t=Zt.replaceAll(t,"Error code","error code"))),t.indexOf("(https://www.dynamsoft.com/purchase-center/)")>-1&&(t=t.replace("(https://www.dynamsoft.com/purchase-center/)","(https://www.dynamsoft.com/store/dynamic-web-twain/)"),e.message=t),t.indexOf("error code:")>-1){var r=t.substr(0,t.indexOf("message")),n=t.substr(t.indexOf("message"));r.indexOf("{")>-1&&(r=r.substr(r.indexOf("{")+1)),n.indexOf("}")>-1&&(n=n.substr(0,n.indexOf("}"))),r=Zt.replaceAll(r,"error code:",""),n=Zt.replaceAll(n,"message: ",""),Vl.lsetException(parseInt(r),n,!0),Zt.error(n),rr.OnLTSLicenseError&&rr.OnLTSLicenseError(Ac.getPublicLicenseContent(t),e.code)}else{if(!e.code){var i=ud(t);Vl.lsetException(i,t,!0)}if(Zt.error(e.message),e.code==td.LtsJsLoadError)return;rr.OnLTSLicenseError&&rr.OnLTSLicenseError(Ac.getPublicLicenseContent(e.message),e.code)}},Vl.lol=function(){return Vl.bLTSOnline},Vl.OnFirstOffline=function(e){Vl.bLTSOnline=!1},Vl.lpubdlg=function(e,t){if(Zt.isString(e)&&""!=e){if(e=Zt.atob(e),console&&console.warn&&!Jl&&Qo.bUseDynamsoftLicenseManager,1==t)return Jl||Qo.bUseDynamsoftLicenseManager||(Jl=!0,rr.OnLTSPublicLicenseWarning&&rr.OnLTSPublicLicenseWarning(Ac.getPublicLicenseContent(e))),!0;2==t&&(Jl||(Jl=!0))}return!1},Vl.lcheckLic=function(e,t,r){var n=!1;if(t){if(Zt.isArray(t.Detail)&&t.Detail.length>0){var i=t.Detail[0].ExpireDate;return Vl.lsexp(e,i,r),Vl.lcexp(e,r).then((function(e){var r=!1;e?r=!0:1!=t.Trial&&2!=t.Trial||(r=Vl.lpubdlg(t.Message,t.Trial)),r||Vl.bLTSOnline||ql||(ql=!0,rr.OnLTSConnectionWarning&&rr.OnLTSConnectionWarning())}))}1!=t.Trial&&2!=t.Trial||(n=Vl.lpubdlg(t.Message,t.Trial))}return n||Vl.bLTSOnline||ql||(ql=!0,rr.OnLTSConnectionWarning&&rr.OnLTSConnectionWarning()),Qt.Promise.resolve()},Vl.lisValidID=function(e){if(Zt.isString(e)&&""!=e)return!0;var t,r=Vl.licenseException;return Vl.lsetException(td.UUIDError,"Failed to generate an ID for your device to license it: not enough permission.",!0),Zt.error(r.message),t=r.message,rr.OnLTSLicenseError&&rr.OnLTSLicenseError(t,r.code),!1},Vl.lsetException=function(e,t,r){var n=Vl.licenseException;n.code=e,n.message=t,r?n.fromLTS=!0:r in n&&delete n.fromLTS},Vl.lgcuid=function(e){var t=rr.DWT.li({instanceMode:e},"");return t?Qt.Promise.resolve(t):$l(e).get_ltsInstance(rd).u().then((function(e){return rr.DWT.lsmid(e,""),rr.DWT.lsmid2b(e),e}))};var vd=s((function HJ(){o(this,HJ)}));function _d(e){var t=new vd;return t.server=e.server,t.normal=!0,e.attrs&&(t.attrs=Zt.clone(e.attrs)),t}var yd=function(e){return e.CONNECTING=0,e.OPEN=1,e.CLOSING=2,e.CLOSED=3,e}({});function Sd(e,t,r){if(Zt.isString(e)&&(e.indexOf("Function not found")>0||e.indexOf("Version not found")>0))t&&t(e);else{var n=e.data;if("object"===_(n))return n=null,e=null,void(r&&r());var i=n.replace(/\0/g,"");try{t&&t(i)}catch(o){Zt.log(n),r&&r()}n=null,e=null}}function Id(e,t){e&&e.readyState!=yd.CLOSING&&e.readyState!=yd.CLOSED?e.readyState==yd.CONNECTING?(e.onerror=function(t){t&&Zt.log("websocket error: "+t),e._reject&&(e._reject(t),e._reject=null),e.close()},e.onclose=function(t){e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null,e._reject=null},e.onopen=function(){e.readyState==yd.OPEN?(e.onopen=null,e.send(t)):e.readyState==yd.CONNECTING&&(e.onopen?setTimeout(e.onopen,100):e._reject&&(e._reject(),e._reject=null))}):e.readyState==yd.OPEN&&(e.onopen=null,e.send(t)):e._reject&&(e._reject({closed:!0}),e._reject=null)}function bd(e,t,r){var n,i=r;return i||(rr.DWT.ConnectWithSocket?Zt.startsWith(e,"wss://")||Zt.startsWith(e,"ws://")||(i=de.bSSL?"wss://":"ws://"):Zt.startsWith(e,"https://")||Zt.startsWith(e,"http://")||(i=de.bSSL?"https://":"http://")),t?(Zt.endsWith(e,"/")&&(e=e.substring(0,e.length-1)),n=":"+t+"/"):Zt.endsWith(e,"/")||(n="/"),[i,e,n].join("")}var Td=function(){function e(){o(this,e)}return s(e,null,[{key:"postStringDataByWS",value:function(e,t){return new Qt.Promise((function(r,n){e.onmessage=function(t){Sd(t,(function(t){r(t),e.close(),e=null}),(function(){n(),e.close(),e=null}))},e._reject=n,Id(e,t)}))}},{key:"postStringDataByWSUrl",value:function(t,r){var n=new Qt.Promise((function(n,i){var o=e.newWebsocket(t,!1);o.onmessage=function(e){Sd(e,(function(e){n(e),o.close(),o=null}),(function(e){i(e),o.close(),o=null}))},o._reject=i,Id(o,r)}));return de.bEdge&&n["catch"]((function(){return new Qt.Promise((function(n,i){var o=e.newWebsocket(t,!0);o.onmessage=function(e){Sd(e,(function(e){n(e),o.close(),o=null}),(function(e){i(e),o.close(),o=null}))},o._reject=i,Id(o,r)}))})),n}},{key:"newWebsocket",value:function(e,t){var r,n=Ho.wsProtocol,i=window.MozWebSocket;if(void 0!==i)r=n?new i(e,n):new i(e);else{var o=window.WebSocket;if(t){var a=window,s=parent;try{for(;a!=s&&s.WebSocket;)o=s.WebSocket,a=s.window,s=s.parent}catch(u){o=window.WebSocket}}r=n?new o(e,n):new o(e)}return r}},{key:"getWsUrl",value:function(e,t,r){var n=r;return n===undefined&&(n=de.bSSL),bd(e,t,n?"wss://":"ws://")}},{key:"getDDMUrl",value:function(e,t,r){var n,i,o="/";return Zt.startsWith(e,"https://")?n=!0:Zt.startsWith(e,"http://")?n=!1:e=(n=Qt.detect.ssl)?"https://"+e:"http://"+e,i=n?"18626/":"18625/",Zt.endsWith(e,"/")&&(o=""),t?[e,o,"ddm/",i,r].join(""):[e,o,r].join("")}},{key:"getModuleUrl",value:function(e){var t;return t=bd(To(),de.bSSL?Ho.SSLPort:Ho.Port),e?t+e:t}}])}();rr.DWT.NetManager=Td;var Cd=function(e){return e.ST_UNKNOWN=0,e.ST_TWAIN_DIRECT=1,e.ST_DYNAMSOFT_SERVICE=2,e.ST_ESCL=3,e.ST_WIFI_DIRECT=4,e}({}),wd=function(){return s((function e(t){o(this,e);var r=this;if(r._id=t.id,r._clientId=Zt.getRandom(),r._uuidForActiveUI=null,r._bReady=di,r._destroy=di,r._bMustUpgradeService=di,r._wsClient=null,r._wsRetry=0,r._wsFailedTimes=0,r._bConnecting=di,r._bNoMask=di,r._bNotShowMessage=di,r.__serverPlatform=Gu.enumWindow,r.__productKey="",r.__licenseInfo=null,r._reconnectTimeSpan=qo.RemoteReconnectTimeSpan,r._reconnectShortSpan=300,r._reconnectShortSpanTimes=5,r._bIfShowProgressBar=fi,r.__IfShowCancelDialogWhenImageTransfer=fi,r._bLicenseErrorDispose=!0,t.dmService){var n,i,a,s,u,c,l=_d(t.dmService),d="/",f="";i=l.server;var h=new Si(t.dmService.server),g=h.scheme;g&&(g=g.toLowerCase()),"https"==g?(n=!0,a=i.substring(8)):"http"==g?(n=!1,a=i.substring(7)):"wss"==g?(n=!0,a=i,i=Zt.replaceAll(i,"wss://","")):"ws"==g?(n=!1,a=i,i=Zt.replaceAll(i,"ws://","")):(a=i,i=(n=Qt.detect.ssl)?"https://"+i:"http://"+i),$o(h.hostname||h.scheme)?r._bRemoteMode=di:r._bRemoteMode=fi,Zt.endsWith(i,"/")&&(d="");var m=l.attrs;if(m){var p,v;s=(null===(p=m)||void 0===p?void 0:p.UUID)||"";var _=(null===(v=m.modules)||void 0===v?void 0:v.length)||0;if(""!=s&&_>0){var y;n?_>1&&_>1+(y=m.modules[1])+2&&(u=m.modules[1+y+2]):_>2&&(u=m.modules[2]),Zt.endsWith(u,"/")&&(d=""),f=[s,"/",u,"/"].join("")}}else m={UUID:"",service_type:Cd.ST_DYNAMSOFT_SERVICE};c=[i,d,f].join(""),m.url=c,r._serverInfo=new Ms([a,d,f].join(""),null,n,!0,Ho.wsProtocol),r._httpUrl=c,r._dmService=l}else{var S,I=Qt.detect.ssl,b=t.port,T=t.sslPort;$o(S=t.host?t.host:To())?r._bRemoteMode=!1:r._bRemoteMode=!0,b||(b=rr.DWT.Port),T||(T=rr.DWT.SSLPort),r._serverInfo=new Ms(S,I?T:b,I,!0,Ho.wsProtocol),r._httpUrl=function(e){var t=e.server;if(t){if(Zt.startsWith(t,"wss://")||Zt.startsWith(t,"ws://"))return t}else t=To();return e.ssl?["https://",t,":",e.port,"/"].join(""):["http://",t,":",e.port,"/"].join("")}(r._serverInfo),r._dmService={server:r._httpUrl,attrs:{url:r._httpUrl,UUID:"",service_type:Cd.ST_DYNAMSOFT_SERVICE},normal:!0}}}),[{key:"_resetErr",value:function(){var e=this;e._errorCode=0,e._errorString="",e._errorCause=null;var t=rr.DWT.licenseException;t.code=0,t.message=""}},{key:"dispose",value:function(){this._bReady=di,this._destroy=fi}},{key:"isDestroy",get:function(){return this._destroy}}])}(),Ed=s((function zJ(){o(this,zJ)}));function kd(e,t){var r,n=[],i=t;if(Zt.isString(i)&&(i=Zt.parse(i)),Zt.isArray(i))for(r=0;rr.length?o.length:r.length,s=0;sparseInt(r[s]))return Md}return Md}function Ud(e,t){var r=e.split(","),n=t.split(",");return r.length>1&&Zt.trim(r[0])==n[0]}function Vd(e,t){var r=e.split(","),n=t.split(",");return r.length>3&&Zt.trim(r[0])==n[0]&&(Zt.trim(r[1])>n[1]||Zt.trim(r[1])==n[1]&&Zt.trim(r[2])>n[2]||Zt.trim(r[1])==n[1]&&Zt.trim(r[2])==n[2]&&parseInt(Zt.trim(r[3]))>=parseInt(n[3]))}function jd(e,t){Qt.detect.urls.splice(0),Qt.detect.urls.push({port:e,ssl:de.bSSL}),Qt.detect.ports=[{port:e,ssl:de.bSSL}],Qt.detect.cUrlIndex=0,Ho.detect.dwtPort=e,Ho.detect.dwtSSLPort=t,rr.DWT.Port=e,rr.DWT.SSLPort=t}function Gd(e,t,r){return Hd.apply(this,arguments)}function Hd(){return(Hd=n(g().mark((function e(t,r,n){var i,o,a;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Qo.bDCPChecked){e.next=2;break}return e.abrupt("return",{host:t,port:rr.DWT.Port,sslPort:rr.DWT.SSLPort});case 2:return ju("Initializing the service..."),e.prev=3,e.next=6,qd(t);case 6:i=e.sent,e.next=13;break;case 9:throw e.prev=9,e.t0=e["catch"](3),Zt.log(e.t0),Is();case 13:if(!Ho.bEnhancedMode){e.next=27;break}if(ju("Checking the service enhanced module..."),o=Qt.install._dlgInstall,a=500,o&&o.open||(a=0),!(i.port<=0||i.sslPort<=0)){e.next=25;break}if(!(a>0)){e.next=21;break}return e.next=21,new Qt.Promise((function(e,t){setTimeout((function(){e()}),a)}));case 21:return ju(Qu),e.next=24,zd(t);case 24:i=e.sent;case 25:e.next=28;break;case 27:i={host:t,port:r,sslPort:n};case 28:return Qo.bDCPChecked=!0,e.abrupt("return",i);case 30:case"end":return e.stop()}}),e,null,[[3,9]])})))).apply(this,arguments)}function zd(e){return Kd.apply(this,arguments)}function Kd(){return Kd=n(g().mark((function e(t){var r,n,i,o;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=5,i=1500,o={host:t,port:0,sslPort:0},r=0;case 3:if(!(r2&&(i=3e3),ju(Qu),e.prev=6,e.next=9,Jd(t);case 9:o=e.sent,e.next=14;break;case 12:e.prev=12,e.t0=e["catch"](6);case 14:if(!(Zt.isNumber(o.port)&&o.port>0&&Zt.isNumber(o.sslPort)&&o.sslPort>0)){e.next=17;break}return jd(o.port,o.sslPort),e.abrupt("return",o);case 17:return e.next=19,new Qt.Promise((function(e,t){setTimeout((function(){e()}),i)}));case 19:r++,e.next=3;break;case 22:throw Qt.detect.dcpStatus=3,Is();case 25:case"end":return e.stop()}}),e,null,[[6,12]])}))),Kd.apply(this,arguments)}function Jd(e){return Qd.apply(this,arguments)}function Qd(){return Qd=n(g().mark((function e(t){var r,n,i,o,a,s,u,c,l;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Qo.refProductKey,Zt.startsWith(t,"wss://")||Zt.startsWith(t,"ws://")?i=t:(o=de.bSSL?Ho.SSLPort:Ho.Port,i=Td.getWsUrl(t,o,de.bSSL)),a={id:Zt.guid(),method:"GetPorts",version:"dwasm2_"+go(),parameter:[Ho.strSID]},Ac.isLongKey(r)&&(a.productKey=r),e.next=6,Td.postStringDataByWSUrl(i,Zt.stringify(a));case 6:if(s=e.sent,!Zt.isString(s)){e.next=19;break}if(e.prev=8,(u=Zt.parse(s))&&"result"in u&&(n=u.result),!(Zt.isArray(n)&&n.length>1&&n[1])){e.next=15;break}if(!(c=n[1]).dwt){e.next=15;break}return e.abrupt("return",{host:t,port:c.dwt.port,sslPort:c.dwt.sslPort});case 15:e.next=19;break;case 17:e.prev=17,e.t0=e["catch"](8);case 19:throw gs(l={}),Gs(l);case 22:case"end":return e.stop()}}),e,null,[[8,17]])}))),Qd.apply(this,arguments)}function qd(e){return Yd.apply(this,arguments)}function Yd(){return(Yd=n(g().mark((function e(t){var r,n;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Ho.detect.bConnected=!1,e.prev=1,e.next=4,Xd(t);case 4:return $d(e.sent),Ho.detect.bConnected=!0,e.abrupt("return",{host:t,port:Ho.detect.dwtPort,sslPort:Ho.detect.dwtSSLPort});case 10:if(e.prev=10,e.t0=e["catch"](1),!e.t0){e.next=21;break}if(r=e.t0.code,!Zt.isNumber(r)){e.next=21;break}if(r!=ua.ResponseDataTypeError&&r!=ua.HTSTError&&r!=ua.CORSError&&r!=ua.CORSErrorFromService&&r!=ua.SSLCertExpired&&r!=ua.SSLCertInvalid){e.next=19;break}throw e.t0;case 19:if(r!=ua.MustUpgrade){e.next=21;break}throw e.t0;case 21:throw Ho.detect.dcpStatus=Ho.detect.EnumDCP_DetectStatus.NotInstalled,rr.dcp._sendStatusEvent(),hs(n={}),{code:n._errorCode,message:n._errorString};case 26:case"end":return e.stop()}}),e,null,[[1,10]])})))).apply(this,arguments)}function Xd(e){return Zd.apply(this,arguments)}function Zd(){return(Zd=n(g().mark((function e(t){var r,n,i,o,a,s,u,c,l;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Qo.refProductKey,Zt.startsWith(t,"wss://")||Zt.startsWith(t,"ws://")?i=t:(o=de.bSSL?Ho.SSLPort:Ho.Port,i=Td.getWsUrl(t,o,de.bSSL)),a={id:Zt.guid(),method:"VersionInfo",version:"dwasm2_"+qo.getVersionStrForCheck(),parameter:[]},Ac.isLongKey(r)&&(a.productKey=r),e.next=6,Td.postStringDataByWSUrl(i,Zt.stringify(a));case 6:if(s=e.sent,Zt.isString(s))try{(u=Zt.parse(s))&&"result"in u&&(n=u.result)}catch(d){}if(c={},!(Zt.isArray(n)&&n.length>0&&n[0])){e.next=21;break}if(l=n[0],!Zt.isString(l)||""==l){e.next=21;break}if(!Ud(l,Qo.getServerVersionInfo(!0))){e.next=18;break}return Ho.detect.dcpStatus=Ho.detect.EnumDCP_DetectStatus.UpdateSkipped,rr.dcp._sendStatusEvent(),e.abrupt("return",n);case 18:throw ju(qu),ga(c),Gs(c);case 21:throw gs(c),Gs(c);case 23:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $d(e){var t="",r=!1,n=!1,i={};if(e.length>4&&(t=Zt.isString(e[2])?e[2]:"",r=Zt.isString(e[3])&&"true"===e[3],n=Zt.isString(e[4])&&"64"===e[4]),e.length>5&&(i=e[5]),Ho.detect.connectedResult=e,Ho.strSID=t,Ho.bEnhancedMode=r,Ho.b64bit=n,Ho.objEnhancedPorts=i,r&&i){if(i.dcp){var o=i.dcp;Ho.SSLPort=o.sslPort,Ho.Port=o.port}if(i.ddm){var a=i.ddm;a?de.bSSL?Ho.detect.ddmPort=a.sslPort:Ho.detect.ddmPort=a.port:Ho.detect.ddmPort=0}if(rr.DWT.Port=0,rr.DWT.SSLPort=0,i.dwt){var s=i.dwt;s&&s.port>0&&s.sslPort>0&&jd(s.port,s.sslPort)}}}function ef(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function tf(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}rr.DWT.NetManager.checkModuleManager=function(e,t){qd(To()).then(e,t)};var rf=new WeakSet,nf=function(e){function t(e){var r;return o(this,t),ef(r=i(this,t,[e]),rf),r._acquireDivEL=null,r.__serverId="",r.__bAcquireImageNow=di,r._blts=Zo(),r._bltsCopyImage=!1,r._b64bit=Ho.b64bit,r._logLevel=0,r._bServerAlwaysFocusOnPopupWindow=fi,r._bPageFocus=fi,r.__bOpenFileNow=di,r._bScanForProxyRemote=di,r}return f(t,e),s(t,[{key:"_isValid",value:function(){return!this._destroy||(qa(this),!1)}},{key:"_connnect",value:(A=n(g().mark((function x(){var e;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this,t.abrupt("return",new Qt.Promise((function(t,r){var n,i;n=e._serverInfo.server,i=e._serverInfo.port,rr.DWT.CheckConnectToTheService(n,i,t,r)})));case 2:case"end":return t.stop()}}),x,this)}))),function(){return A.apply(this,arguments)})},{key:"_waitForConnect",value:function(){var e=this;return e._wsRetry=0,e._bReady?Qt.Promise.resolve():new Qt.Promise((function(t,r){e._wsCheckResolve=t,e._wsCheckReject=r,lf(e)}))}},{key:"_getWSCallback",value:function(){return df}},{key:"_getWSContextData",value:function(){return{}}},{key:"_additionalWSCallback",value:function(e,t,r,n){"ConvertToBlob"==e&&t._blob_callbacks.push((function(e){return r(e,Js.HANDLE_RAW_MESSAGE,"0",n)}))}},{key:"_innerSendBlobByWS",value:function(e,t,r,n,i){var o={cmd:e,cmdId:Rl(),sFun:function(e){Zt.isFunction(n)&&n(e)},fFun:i,contextData:{document:r.currentFileName,tag:r.currentTagName,bNeedClearTag:r.bNeedClearCurrentTagName,index:r.index,bNeedRefresh:"UpdateImage"==e},rawData:!0};return this._innerSendByWS(e,t,o,r,!0)}},{key:"_innerSendByWS",value:function(e,t,r,n,i){var o,a,s,u,c=this,l=this._getWSCallback();r&&r.cmdId?(o=r.cmdId,s=cf(c._clientId,o),u=cf(c._clientId,"")):(o=0,s=0,u=0);var d=uf(c._clientId,e,t,o,c._bScanForProxyRemote),f=c._wsClient;a={client:f,userData:{stwain:c,command:r},taskId:o,eventTaskId:s,lastEventTaskId:u};var h,g,m,p,v,_,y,S,I=0;if(!i){try{f.request(d,l,a)}catch(jj){Zt.log(jj)}return di}if(m=new ArrayBuffer(12),n)if(n instanceof Blob)I=n.size;else if(n instanceof ArrayBuffer||n instanceof Uint8Array)I=n.byteLength;else if(n instanceof Array)I=n.length;else{var b=n;I=b.size||b.byteLength||b.length}for(g=(h=(y=new Blob([d])).size)+I,p=new DataView(m),_=0;_<8&&g;_++)p.setUint8(_,g%256),g=Math.floor(g/256);for(_=0;_<4&&h;_++)p.setUint8(8+_,h%256),h=Math.floor(h/256);return v=new Blob([m,y]),S=f.request(v,l,a),this._additionalWSCallback(e,f,l,a),I>0&&(S=f.request(n,l,a)),m=null,y=null,v=null,p=null,n=null,S}},{key:"_sendDataConnectWithSocket",value:function(e,t,r,n){var i=this;return new Qt.Promise((function(r,o){i._sendData(e,t,!0,(function(e){var t=!1;try{t=Zt.isString(e)?Zt.parse(e):e}catch(jj){}if(i._resetErr(),t){if(t instanceof Blob||kl(t))return void r(t);Hs(t)&&(i._errorCode=t.exception,i._errorString=t.description,i._errorCause=zs(t))}r(n?t:t.result)}),(function(e){o({code:i._errorCode,message:i._getErrorString()})}))}))}},{key:"_sendDataByHttpAsync",value:function(e,r,n,i,o){var a,s=this;if("SendEventToScannerUI"!=e&&s._resetErr(),!s._isValid())return Qt.Promise.reject({code:s._errorCode,message:s._getErrorString()});if(t.isServerInvalid(s))return o?Qt.Promise.reject({code:s._errorCode,message:s._getErrorString()}):s._waitForConnect().then((function(){return s._sendDataByHttpAsync(e,r,n)}));if(rr.DWT.ConnectWithSocket)return s._sendDataConnectWithSocket(e,r,n,i);a={method:"post",async:!0,body:uf(s._clientId,e,r,0,s._bScanForProxyRemote),dataType:null!=n?n:"text"};var u=null,c=Zt.guid();return s._bIfShowProgressBar&&(u=Qt.progressContext),Ws(u,c)([s._httpUrl,"fa/",e].join(""),a).then((function(t){var r=!1;try{r=Zt.isString(t)?Zt.parse(t):t}catch(jj){}if(r){if(r instanceof Blob||kl(r))return r;if(!Hs(r))return"SendEventToScannerUI"!=e&&s._resetErr(),i?r:r.result;s._errorCode=r.exception,s._errorString=r.description,s._errorCause=zs(r)}else _a(s),s._errorCause=null;throw{code:s._errorCode,message:s._getErrorString()}}),(function(e){if(s._errorCode=e.code,s._errorString=e.message,!Qt.page.bUnload)throw e}))}},{key:"_sendData",value:function(e,r,n,i,o){var a=this,s=null,u=null,c=!1,l=!0;if(!a._destroy){if("ActiveUI"==e?l=!1:c=t.isServerInvalid(a),c)return a._waitForConnect().then((function(){a._sendData(e,r,n,i,o)}))["catch"]((function(e){Zt.isFunction(o)&&o(e.code,e.message)}));var d;Zt.isFunction(i)&&(u=i),Zt.isFunction(o)&&(s=o),d="ConvertToBlob"==e||"Heartbeat"==e?0:Rl();var f=this._getWSContextData(),h={cmd:e,cmdId:d,sFun:u,fFun:s,contextData:f,rawData:null!=n&&n};return a._innerSendByWS(e,r,h,null,l)}}},{key:"_innerFunV2",value:(k=n(g().mark((function P(e,t,r){var n,i,o;return g().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(n=this,!(o=r)&&!Zt.isUndefined(o)){a.next=7;break}return a.next=4,n._sendDataConnectWithSocket(e,t,"json",!0);case 4:i=a.sent,a.next=10;break;case 7:return a.next=9,n._sendDataByHttpAsync(e,t,"json",!0);case 9:i=a.sent;case 10:if(!(i&&Zt.isArray(i)&&i.length>0)){a.next=12;break}return a.abrupt("return",i[0]);case 12:if(!(i&&Zt.isArray(i.result)&&i.result.length>0)){a.next=14;break}return a.abrupt("return",i.result[0]);case 14:return a.abrupt("return",i);case 15:case"end":return a.stop()}}),P,this)}))),function(e,t,r){return k.apply(this,arguments)})},{key:"_OnReady",value:(E=n(g().mark((function D(){var e,t;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if((e=this)._wsRetry=0,e._wsFailedTimes=0,Qt.detect.starting=!1,e._bRemoteMode||(Qt.detect.bOK=!0),e._bReady=!0,null!==(t=e._wsClient.ws)){r.next=9;break}return r.abrupt("return");case 9:t.onopen=null,e._wsClient.addEvent("close",e._clientId,(function(t){t&&Zt.log("websocket close: "+t),e.__bAcquireImageNow=!1,e._OnWSClose(t)})),e._wsClient.addEvent("error",e._clientId,(function(t){t&&Zt.log("websocket error: "+t),e.__bAcquireImageNow=!1,e._OnWSError(t)})),e._wsClient.addEvent("timeout",e._clientId,(function(t){t&&Zt.log("websocket timeout: "+t),e._OnWSTimeout(t)}));case 13:case"end":return r.stop()}}),D,this)}))),function(){return E.apply(this,arguments)})},{key:"getServiceInfo",value:function(){return this._dmService}},{key:"_OnWSClose",value:function(e){var r,n,i,o=this;(o._bReady=!1,o._wsRetry=0,o._bRemoteMode)&&(r=null!==(n=null===(i=o.getServiceInfo())||void 0===i||null===(i=i.attrs)||void 0===i?void 0:i.name)&&void 0!==n?n:"");os(o,r),o.__closeRemoteScanUI(!0),o._heartBeatTimer&&(clearTimeout(o._heartBeatTimer),o._heartBeatTimer=null),o._bNoMask||function(e){Zt.log("hideMask:"+e+"--"+Ml),ll(),Ml=0}("websocket close"),o.__OnWSClose&&o.__OnWSClose();var a=o._bRemoteMode?qo.RemoteReconnectMaxTimes:qo.LocalReconnectMaxTimes;if(o._wsFailedTimes0?(t.sFun(e.result),!0):(t.fFun&&t.fFun(e.result),!1):(0!=r._errorCode&&t.fFun&&t.fFun(r._errorString),"BeginSaveMem"==i||"CreateLocalStorage"==i||"LocalStorageExist"==i||"SaveToLocalStorage"==i||"LoadFromLocalStorage"==i||"RemoveLocalStorage"==i?t.sFun&&Zt.isArray(e.result)&&e.result.length>0?(t.sFun(e.result),!0):(t.fFun&&t.fFun(e.result),!1):(n=t.rawData?e:Zt.isArray(e.result)&&e.result.length>0?e.result[0]:e.result,t.sFun?t.sFun(n):t.fFun&&t.fFun(n),e=null,!0))}if(0==r._errorCode)return t.sFun&&Zt.isArray(e.result)&&e.result.length>0?(t.sFun(e.result),!0):(t.fFun(e.result),!0);var o=!1;t.fFun&&(o=t.fFun(r._errorString)),!o&&e.exception&&e.exception<0&&-2115!=e.exception&&Zt.isFunction(r.__OnPrintMsg)&&r.__OnPrintMsg(r._errorString)}},{key:"_handleOnBitmapChangedEvent",value:function(e,t){try{var r,n,i,o,a,s,u,c,l,d,f,h,g,m,p,v,_=e.result[0],y=e.result[1];if(Zt.isString(y)){var S=JSON.parse(y);r=Zt.isArray(S)?S:[S]}else Zt.isArray(y)&&(r=y);if(Zt.isArray(r))for(v=t||{},m=0;m12?(r.__serverId=n[1],i=n[12]):n.length>8?(r.__serverId=n[1],i=n[8]):n.length>=2&&(r.__serverId=n[1])),r._bReady=!0,r._bRemoteMode||(Qt.detect.bOK=!0),Qt.detect.starting=!1,i){try{r._OnActiveUIClearBuffer()}catch(l){r._resetErr()}na(r,-2614,"The Dynamic Web TWAIN Service has been restarted.")}if(e.prev=11,!r._blts){e.next=21;break}return o=r._bRemoteMode&&null!==(a=null===(s=r._dmService)||void 0===s||null===(s=s.attrs)||void 0===s?void 0:s.UUID)&&void 0!==a?a:"",e.next=16,id(rr.DWT.lgdt(),o);case 16:return u=e.sent,e.next=19,r._setLTSLicenseAsync(u.ar);case 19:e.next=24;break;case 21:return c=Qo.refProductKey,e.next=24,r._setProductKeyAsync(c);case 24:return e.next=26,r._OnReconnected();case 26:e.next=32;break;case 28:throw e.prev=28,e.t0=e["catch"](11),r._bRemoteMode&&Pa(r),{code:r._errorCode,message:r._errorString};case 32:return e.prev=32,r._bRemoteMode&&t.startHeartBeat(r),e.finish(32);case 35:case"end":return e.stop()}}),W,this,[[11,28,32,35]])}))),function(e){return C.apply(this,arguments)})},{key:"_OnReconnected",value:(T=n(g().mark((function N(){return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),N)}))),function(){return T.apply(this,arguments)})},{key:"_initRemoteDiv",value:function(){if(!this._acquireDivEL){var e=document.createElement("div");e.style.position="fixed",e.style.zIndex="510000",e.style.left="0",e.style.top="0";var t=document.createElement("img");t.className="ds-img-screen",e.appendChild(t),document.body.appendChild(e),this._acquireDivEL=e}}},{key:"getHeartBeatData",value:function(e){var t,r=uf(this._clientId,e.cmd,null,e.cmdId,this._bScanForProxyRemote),n=r.length,i=n,o=new ArrayBuffer(12+i),a=new DataView(o);for(t=0;t<8&&i;t++)a.setUint8(t,i%256),i=Math.floor(i/256);for(t=0;t<4&&n;t++)a.setUint8(8+t,n%256),n=Math.floor(n/256);for(t=0;t0&&Zt.removeEventListener(r[0],"mouseup",t._acquireDivEL.evtFun),t._acquireDivEL.evtFun=null):r&&r.length>0&&Zt.removeEventListener(r[0],"mouseup"),r&&r.length>0&&(r[0].src=""),e&&(document.body.removeChild(t._acquireDivEL),t._acquireDivEL=null)}}},{key:"_removeImageByIdAsync",value:(b=n(g().mark((function R(e){var t;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if((t=this)._resetErr(),t._isValid()){r.next=4;break}throw{code:t._errorCode,message:t._errorString};case 4:return r.next=6,t._innerFunV2("RemoveAllImages",El(e));case 6:return r.abrupt("return",r.sent);case 7:case"end":return r.stop()}}),R,this)}))),function(e){return b.apply(this,arguments)})},{key:"_removeAllImagesAsync",value:(I=n(g().mark((function O(e,t){var r;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((r=this)._resetErr(),r._isValid()){e.next=4;break}throw{code:r._errorCode,message:r._getErrorString()};case 4:return e.next=6,r._innerFunV2("RemoveAllImages");case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),O,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"_LicensePromptExpired",value:function(){}},{key:"_OnActiveUI",value:(S=n(g().mark((function M(e){var r,n,i,o,a,s,u,c,l,d,f,h,m,p,v,_,y;return g().wrap((function(g){for(;;)switch(g.prev=g.next){case 0:if(r=this,i=!1,e&&e.length>=6?(e[2],n=e[5],o=!1,a=!1,s=0,e.length>12?(e[6],r._b64bit="64"==e[7],e[8],o=e[9],a=e[10],s=e[11],e[12]):e.length>8&&(o=e[6],a=e[7],s=e[8]),o?a&&s&&(r._bRemoteMode=!0):r._bRemoteMode=!0,Zt.isString(n)&&("win"==n?r.__serverPlatform=Gu.enumWindow:"linux"==n?r.__serverPlatform=Gu.enumLinux:"mac"==n?r.__serverPlatform=Gu.enumMac:"embed"==n?r.__serverPlatform=Gu.enumEmbed:"chromeos"==n&&(r.__serverPlatform=Gu.enumChromeOS))):i=!0,r._bMustUpgradeService=i,i){g.next=67;break}if(ju("Activating the WebTwain instance..."),u=!1,!r._blts){g.next=44;break}return l=r._bRemoteMode&&null!==(d=null===(f=r._dmService)||void 0===f||null===(f=f.attrs)||void 0===f?void 0:f.UUID)&&void 0!==d?d:"",g.prev=10,g.next=13,id(rr.DWT.lgdt(),l);case 13:c=g.sent,g.next=27;break;case 16:if(g.prev=16,g.t0=g["catch"](10),cd(r,g.t0),h=gd(r._errorCode),!r._bLicenseErrorDispose){g.next=25;break}throw r._bRemoteMode||(h?this._LicensePromptExpired():pd(r)),{code:r._errorCode,message:r._errorString};case 25:h||Zt.warn(r._errorString),c=null;case 27:if(ju(Yu),!c){g.next=41;break}return g.next=31,r._setLTSLicenseAsync(c.ar);case 31:return m=g.sent,rr.DWT.laddDWTObj(r),l="",r._bRemoteMode&&(l=null!==(p=null===(v=r._dmService)||void 0===v||null===(v=v.attrs)||void 0===v?void 0:v.UUID)&&void 0!==p?p:""),ju(Xu),g.next=38,rr.DWT.lcheckLic(rr.DWT.lgdt(),m,l);case 38:u=0==rr.DWT.licenseException.code,g.next=42;break;case 41:u=!1;case 42:g.next=62;break;case 44:return ju(Yu),_=Qo.refProductKey,g.prev=46,g.next=49,r._setProductKeyAsync(_);case 49:g.sent&&(u=!0),g.next=62;break;case 53:if(g.prev=53,g.t1=g["catch"](46),!r._bLicenseErrorDispose){g.next=60;break}throw r._bRemoteMode||hd(g.t1.code)&&md(g.t1),g.t1;case 60:Zt.warn(g.t1.message);case 61:u=!1;case 62:if(u&&(ju(Xu),Ac.checkProductKey(r,{Core:!0})||(y={code:r._errorCode,message:r._getErrorString()},r._resetErr(),rr.DWT.lclex(),de.bWin&&Ac.checkProductKey(r,{Webcam:!0},!0)||(r._errorCode=y.code,r._errorString=y.message))),0==r._errorCode){g.next=67;break}if(r._bRemoteMode||(gd(r._errorCode)?this._LicensePromptExpired():pd(r)),!r._bLicenseErrorDispose){g.next=67;break}throw{code:r._errorCode,message:r._getErrorString()};case 67:r._bRemoteMode&&t.startHeartBeat(r);case 68:case"end":return g.stop()}}),M,this,[[10,16],[46,53]])}))),function(e){return S.apply(this,arguments)})},{key:"_innerConvertToArrayBufferAsync",value:(y=n(g().mark((function L(e,t,r,n){var i,o,a,s,u;return g().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return i=this,o=r,a=null!=n?n:"arraybuffer",s=",",Zt.isString(o)&&""!=o||(o="",s=""),u=["[",e,',"',t.join(","),'"',s,o,"]"].join(""),c.next=6,i._sendDataByHttpAsync("ConvertToBlob",u,a,!0);case 6:return c.abrupt("return",c.sent);case 7:case"end":return c.stop()}}),L,this)}))),function(e,t,r,n){return y.apply(this,arguments)})},{key:"_getImageByServerId",value:(_=n(g().mark((function B(e){var t,r,n;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return t=Wd.IT_PNG,i.next=3,this._innerConvertToArrayBufferAsync(t,[e],void 0,void 0);case 3:return r=i.sent,n=Rd(t),i.abrupt("return",new Blob([r],{type:n}));case 6:case"end":return i.stop()}}),B,this)}))),function(e){return _.apply(this,arguments)})},{key:"_getSourcesAsync",value:(v=n(g().mark((function U(e,t,r){var n,i;return g().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return n=this,o.next=3,n._innerFunV2("GetSources",El(e,null!=t&&t,null!=r&&r));case 3:return i=o.sent,o.abrupt("return",kd(this,i));case 5:case"end":return o.stop()}}),U,this)}))),function(e,t,r){return v.apply(this,arguments)})},{key:"_getDevices",value:(p=n(g().mark((function V(e,t,r){var n,i,o,a,s,u;return g().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:if(i=[],o="getDevices",a=(n=this)._bRemoteMode?Pl:de.bAndroid?Fl:Pl,s=null!=e?e:a,n._resetErr(),n._isValid()){c.next=5;break}return c.abrupt("return",Qt.Promise.reject({code:n._errorCode,message:n._getErrorString()}));case 5:return n._bNoMask||Ll(o,n),c.prev=6,c.next=9,n._getSourcesAsync(s,t,r);case 9:u=c.sent,Zt.isArray(u)&&u.length>0&&(i=i.concat(u)),c.next=16;break;case 13:throw c.prev=13,c.t0=c["catch"](6),c.t0;case 16:return c.prev=16,n._bNoMask||Bl(o),c.finish(16);case 19:return c.abrupt("return",i);case 20:case"end":return c.stop()}}),V,this,[[6,13,16,19]])}))),function(e,t,r){return p.apply(this,arguments)})},{key:"_innerAcquireImageFromService",value:function(e,t,r){var n,i,o=this;if(i=Zt.clone(e),!Ac.checkProductKey(o,{Core:!0}))return Zt.isFunction(r)&&r(o._errorCode,o._getErrorString()),!1;var a=o._bRemoteMode?fi:di;i.RemoteScan=a?1:0,o._bRemoteMode&&(Zt.isFunction(o.__OnRemoteScanStatusAsync)||(o.__OnRemoteScanStatusAsync=function(){}),Zt.isFunction(o.__OnSourceUIClose)||(o.__OnSourceUIClose=function(){}));for(var s=0,u=0;u0&&(s=o[0]),!Zt.isString(s)){t.next=23;break}if(s=Qt.removeNonPrintableChar(s),0!=(a=JSON.parse(s)).errorCode){t.next=16;break}return t.abrupt("return",a.response);case 16:throw n._errorCode=a.errorCode,n._errorString=a.errorString,n._errorCause=zs(a),{code:n._errorCode,message:n._getErrorString()};case 23:throw gs(n),{code:n._errorCode,message:n._getErrorString()};case 25:t.next=32;break;case 27:throw t.prev=27,t.t0=t["catch"](9),n._errorCode=-2302,n._errorString=t.t0,{code:n._errorCode,message:n._getErrorString()};case 32:case"end":return t.stop()}}),G,this,[[9,27]])}))),function(e,t,r){return h.apply(this,arguments)})},{key:"_setCapabilities",value:(d=n(g().mark((function H(e,t,r){var n,i;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(tf(rf,n=this,af).call(n,e),Zt.isObject(t)&&!Zt.isArray(t)){r.next=5;break}throw Ka(n),{code:n._errorCode,message:n._getErrorString()};case 5:return n._initRemoteDiv(),r.next=8,n._innerSelectDeviceAsync(e);case 8:return i=["[",Zt.stringify(t),"]"].join(""),r.next=11,n._sendDataByHttpAsync("SetCapabilities",i);case 11:return r.abrupt("return",r.sent);case 12:case"end":return r.stop()}}),H,this)}))),function(e,t,r){return d.apply(this,arguments)})},{key:"_closeSource",value:(l=n(g().mark((function z(){var e;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this,t.next=3,e._innerFunV2("CloseSource");case 3:case"end":return t.stop()}}),z,this)}))),function(){return l.apply(this,arguments)})},{key:"_innerSelectDeviceAsync",value:(c=n(g().mark((function K(e,t){var r,n,i,o,a,s,u,c;return g().wrap((function(l){for(;;)switch(l.prev=l.next){case 0:if(n=this,e&&e instanceof Ed){l.next=4;break}throw Ka(n),{code:n._errorCode,message:n._errorString};case 4:if(!(i=null===(r=this._dmService.attrs)||void 0===r?void 0:r.UUID)){l.next=17;break}if((null===(o=e.serviceInfo.attrs)||void 0===o?void 0:o.UUID)!=i){l.next=10;break}l.next=17;break;case 10:if(!((s=(null===(a=e.serviceInfo.attrs)||void 0===a?void 0:a.url)||e.serviceInfo.server)&&s.indexOf(i)>-1)){l.next=15;break}l.next=17;break;case 15:throw ns(n),{code:n._errorCode,message:n._errorString};case 17:return u=null!=t?t:Fd.SMF_NAME,c=["[",e.strDevice,",",u,"]"].join(""),l.next=20,n._innerFunV2("SelectSourceEx",c);case 20:return l.abrupt("return",l.sent);case 21:case"end":return l.stop()}}),K,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"registerEvent",value:function(e,t){return Zt.isUndefined(e)?(Ea(this),!1):!Zt.isString(e)||Zt.isString(e)&&0==e.trim().length||Zt.isUndefined(t)||!Zt.isFunction(t)?(Ka(this),!1):!!this._registerEvent(e,t)}},{key:"unregisterEvent",value:function(e,t){return this._unregisterEvent(e,t)}},{key:"_registerEvent",value:function(e,t){var r=this;return r._resetErr(),!!r._isValid()&&(r[["__",e].join("")]=t,!0)}},{key:"_unregisterEvent",value:function(e,t){var r=this;return r._resetErr(),!!r._isValid()&&(r[["__",e].join("")]=null,fi)}},{key:"_OnPageFocus",value:function(e){var t=this;if(t._bPageFocus=!0,t._bReady&&de.bWin&&rr.DWT.IfAlwaysFocusOnPopupWindow){var r=Zt.stringify({sequence:0,wnds:0,wnd:"0",type:3,x:0,y:0});if(t.__bAcquireImageNow||e||t.__bOpenFileNow){t._bServerAlwaysFocusOnPopupWindow=!0;try{t._isValid()&&t._sendDataByHttpAsync("SendEventToScannerUI",["[",r,"]"].join(""))}catch(RJ){}}}}},{key:"_OnPageBlur",value:function(e){var t=this;if(de.bWin&&t._bReady){var r=Zt.stringify({sequence:0,wnds:0,wnd:"0",type:4,x:0,y:0});if((0!=t._bPageFocus||e)&&(t._bPageFocus=!1,t.__bAcquireImageNow||e||t.__bOpenFileNow)){t._bServerAlwaysFocusOnPopupWindow=!1;try{t._isValid()&&t._sendDataByHttpAsync("SendEventToScannerUI",["[",r,"]"].join(""))}catch(RJ){}}}}},{key:"_OnRemoteScanStatusAsync",value:function(e){var t,r,n,i,o,a,s,u=this;if(e&&e.length>=2){try{var c=new String(e[1]);t=Zt.parse(c)}catch(d){Zt.error(d.message),Zt.log("parse json failed: "+e[1])}t||(t={sequence:0,screen:[]})}if(t&&t.sequence)if(t.sequence>0&&t.screen&&t.screen.length>0){if(r=t.screen,i=t.sequence,a=t.wnds,s=(n=r[0]).img,Zt.isString(s)&&""!=s&&(o=n.wnd),i&&o){var l=Zt.sizzle(".ds-img-screen");l&&l.length>0&&u._acquireDivEL&&(u._acquireDivEL.evtFun&&(Zt.removeEventListener(l[0],"mouseup",u._acquireDivEL.evtFun),u._acquireDivEL.evtFun=null),l[0].src=s,u._acquireDivEL.evtFun=function(e){a||(a="0");var t=Zt.stringify({sequence:i,wnds:a,wnd:o+"",type:2,x:e.offsetX,y:e.offsetY});u._sendDataByHttpAsync("SendEventToScannerUI",["[",t,"]"].join(""))},Zt.addEventListener(l[0],"mouseup",u._acquireDivEL.evtFun))}}else u.__closeRemoteScanUI(!1);return Zt.isFunction(u.__OnRemoteScanStatusAsync)&&u.__OnRemoteScanStatusAsync(t),!0}},{key:"_OnBitmapChanged",value:function(e,t,r){var n=this,i="m1"==e[0],o="c1"==e[0],a="c2"==e[0],s=o||a||i,u=e[2],c=e[3],l=-1;if(!s){if(e.length>10&&(l=e[10]),l>-1&&n._canConsume()&&(u==pf.enumBCAppend||u==pf.enumBCInsert)){var d=rr.DWT.lgct(l);Zt.isFunction(n.__OnLtsverify)&&n.__OnLtsverify(d,1)}if((u==pf.enumBCAppend||u==pf.enumBCInsert)&&Zt.isFunction(n.__OnBufferChanged)){var f={action:"add",currentId:c,imageIds:[],selectedIds:[]};n.__OnBufferChanged(f)}}}},{key:"_OnPostTransferAsync",value:function(e,t,r){var n,i=this;if(e&&e.length>=2)try{var o=String(e[1]).replace(/\\/g,"\\\\");n=Zt.parse(o)}catch(s){Zt.error(s)}n||(n={imageId:""});var a=!1;if(Zt.isFunction(i.__OnPostTransferAsync))try{a=i.__OnPostTransferAsync(n)}catch(u){_o(u)}if(Zt.isFunction(i.__OnPostTransferAsync2))try{i.__OnPostTransferAsync2(n)}catch(u){_o(u)}return a}},{key:"_OnCurrentDeviceSelected",value:function(e,t){}},{key:"_getErrorCode",value:function(){return this._errorCode}},{key:"_getErrorString",value:function(){return 0!=this._errorCode?this._errorString:"Successful."}},{key:"_isBindViewer",value:function(){return!1}},{key:"_isNoViewer",value:function(){return!0}},{key:"_isMobileMode",value:function(){return!1}},{key:"_needCheckProxyRemoteScanLicense",value:function(){if(!this._blts&&this._bScanForProxyRemote){if(""==this._strRemoteServiceVer)return!0;var e=function(e){var t=e.split(","),r=[18,3];return Zt.trim(t[0])>r[0]||t.length>1&&Zt.trim(t[0])==r[0]&&Zt.trim(t[1])>=r[1]}(this._strRemoteServiceVer);if(e)return!0}return!1}},{key:"_OnActiveUIClearBuffer",value:function(){}}],[{key:"isServerInvalid",value:function(e){var t,r;if(t=!e._bReady||null===e._wsClient,r=e._bMustUpgradeService,t){var n,i,o;if(e._bRemoteMode)n=null!==(i=null===(o=e._dmService)||void 0===o||null===(o=o.attrs)||void 0===o?void 0:o.name)&&void 0!==i?i:"";os(e,n)}else r?ga(e):e.isDestroy&&qa(e);return t||r||-2208==e._errorCode||e.isDestroy}},{key:"STwainConnectToServer",value:(u=n(g().mark((function J(e){var t,r;return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(t=e._id,!rr.DWT.WebTwainIdMap[t]){n.next=5;break}return n.next=4,e._OnReady();case 4:return n.abrupt("return");case 5:if(!e._bReady&&!e._destroy){n.next=7;break}return n.abrupt("return");case 7:return e._bConnecting=!0,(r=Pu.Instance.getClient(e._serverInfo)).setRetry(0),e._bNoMask||Ll("",e),n.prev=11,n.next=14,xc(e._bRemoteMode);case 14:return n.next=17,r.testConnection(void 0,0,void 0,1e4);case 17:if(e._wsClient=r,e._wsClient.bReady=!0,Qt.detect.bFirst&&(Sf(),Qt.detect.bFirst=!1),e._bReady){n.next=24;break}return e._bReady=!0,n.next=24,e._OnReady();case 24:n.next=30;break;case 26:throw n.prev=26,n.t0=n["catch"](11),e._bReady=!1,{code:e._errorCode,message:e._getErrorString()};case 30:return n.prev=30,e._bConnecting=!1,e._bNoMask||Bl(""),n.finish(30);case 34:case"end":return n.stop()}}),J,null,[[11,26,30,34]])}))),function(e){return u.apply(this,arguments)})},{key:"_innerSendHeartBeat",value:(a=n(g().mark((function Q(e,r){var n,i,o,a;return g().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(s.prev=0,!e.__bAcquireImageNow){s.next=4;break}s.next=14;break;case 4:if(n={client:null,userData:null,taskId:"0",eventTaskId:"0",lastEventTaskId:"0"},i=Rl(),o={cmd:"Heartbeat",cmdId:i,sFun:null,fFun:null,contextData:null,rawData:!0},a=e.getHeartBeatData(o),!e._wsClient){s.next=12;break}return e._wsClient.setRetry(0),s.next=12,e._wsClient.request(a,null,n);case 12:o=null,a=null;case 14:s.next=18;break;case 16:s.prev=16,s.t0=s["catch"](0);case 18:e._wsClient&&e._wsClient.connected&&r&&setTimeout((function(){t._innerSendHeartBeat(e,r)}),e._wsClient._heartBeatTicks);case 19:case"end":return s.stop()}}),Q,null,[[0,16]])}))),function(e,t){return a.apply(this,arguments)})},{key:"startDWTReconnect",value:(r=n(g().mark((function q(e){var r,n,i,o,a;return g().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(s.prev=0,!e._destroy){s.next=3;break}return s.abrupt("return");case 3:if(r=e._serverInfo,!(Ho.bEnhancedMode&&r&&r.port)){s.next=24;break}return Qo.bDCPChecked=!1,s.prev=6,s.next=9,Gd(To(),rr.DWT.Port,rr.DWT.SSLPort);case 9:if(!(n=s.sent)){s.next=14;break}e._serverInfo.port=de.bSSL?n.sslPort:n.port,s.next=16;break;case 14:throw gs(e),Gs(e);case 16:s.next=24;break;case 18:return s.prev=18,s.t0=s["catch"](6),e._wsFailedTimes++,i=e._bRemoteMode?qo.RemoteReconnectMaxTimes:qo.LocalReconnectMaxTimes,e._wsFailedTimes0){if(0!=r._errorCode)throw r.__productKey="",{code:r._errorCode,message:r._getErrorString()};rr.DWT.ProductKey=r.__productKey,Ac.reparseProductKey();return r._innerFunV2("GetLicenseInfo",El(0))}throw Aa(r),t.context=null,{code:r._errorCode,message:r._getErrorString()}}))):Qt.Promise.reject({code:r._errorCode,message:r._getErrorString()})}function af(e){return sf.apply(this,arguments)}function sf(){return(sf=n(g().mark((function e(t){var r;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((r=this)._resetErr(),r._isValid()){e.next=4;break}return e.abrupt("return",Qt.Promise.reject({code:r._errorCode,message:r._errorString}));case 4:if(t&&t instanceof Ed){e.next=7;break}throw Ka(r),{code:r._errorCode,message:r._errorString};case 7:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}function uf(e,t,r,n,i){var o,a=[];return a.push("{"),a.push('"id":"'),a.push(e),a.push('"'),n&&(a.push(',"cmdId":"'),a.push(n),a.push('"')),a.push(',"method":"'),a.push(t),a.push('"'),a.push(',"module":"dwt","version":"'),o=i?[Qo.getDWTPrefix(),qo.getVersionStrForCheck()].join(""):[Qo.getDWTPrefix(),Qo.getServerVersionInfo()].join(""),a.push(o),a.push('"'),r!==undefined&&null!==r&&(a.push(',"parameter":'),Zt.isArray(r)?a.push(Zt.stringify(r)):a.push(r)),a.push("}"),a.join("")}function cf(e,t){return["evt",e,t].join("_")}function lf(e){if(e._bReady)e._wsCheckResolve();else{if(rr.DWT.bConnectCanceled)return Zt.asyncQueue.stop(),as(e),void e._wsCheckReject({code:e._errorCode,message:e._getErrorString()});if(e._wsRetry>10)return rs(e),void e._wsCheckReject({code:e._errorCode,message:e._getErrorString()});e._wsRetry++,setTimeout((function(){lf(e)}),1100)}}function df(e,t,r,n){return ff.apply(this,arguments)}function ff(){return ff=n(g().mark((function e(t,r,n,i){var o,a,s,u,c,l,d,f;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r!=Js.GET_TASKID){e.next=4;break}return e.abrupt("return",i.taskId);case 4:if(r!=Js.GET_EVENT_TASKID){e.next=8;break}return e.abrupt("return",i.eventTaskId);case 8:if(r!=Js.ONMESSAGE_PROCESS_DATA){e.next=17;break}if("object"!==_(t)){e.next=11;break}return e.abrupt("return",t);case 11:if(!((u=t).indexOf("Version not found")>=0||u.indexOf("Function not found")>=0)){e.next=14;break}return e.abrupt("return",{cmdId:null!=n?n:0});case 14:return e.abrupt("return",Zt.parse(t));case 17:if(r!=Js.ONMESSAGE_GET_TASKID){e.next=25;break}if(!t){e.next=22;break}if(!t.event){e.next=21;break}return e.abrupt("return",0);case 21:return e.abrupt("return",t.cmdId);case 22:return e.abrupt("return",t);case 25:if(r!=Js.ONMESSAGE_GET_EVENT_TASKID){e.next=31;break}if(!t||!t.event){e.next=28;break}return e.abrupt("return",cf(t.id,t.cmdId));case 28:return e.abrupt("return",0);case 31:if(r!=Js.HANDLE_RAW_MESSAGE){e.next=59;break}if(c=t.rawData,l=t.jsonData,o=null==i?void 0:i.userData){e.next=36;break}return e.abrupt("return",!1);case 36:if(a=o.stwain,s=o.command){e.next=40;break}return e.abrupt("return",!1);case 40:if(a&&Zt.isFunction(a.__OnWSMessage)&&a.__OnWSMessage(t),"object"!==_(t)){e.next=45;break}if(!rr.DWT.ConnectWithSocket){e.next=45;break}return"ConvertToBlob"!=s.cmd&&"GetImageByIndex"!=s.cmd||s.sFun(t),e.abrupt("return",!0);case 45:if("Heartbeat"!=l.method){e.next=47;break}return e.abrupt("return",!0);case 47:if("EnableBuffer"!=l.method&&"GetBuffer"!=l.method){e.next=50;break}return rr.DWT.lwsproc(l,s),e.abrupt("return",!0);case 50:if(Zt.isString(c)&&(d=c.replace(/\0/g,"")),!(d&&d.indexOf("Exception:")>=0||0==d.indexOf("Error"))){e.next=57;break}return f=!1,Zt.log(d+"@"+s.cmd),s.fFun&&(f=s.fFun(d)),!f&&a&&Zt.isFunction(a.__OnPrintMsg)&&a.__OnPrintMsg(d),e.abrupt("return",!0);case 57:e.next=70;break;case 59:if(r!=Js.HANDLE_PROCESSED_MESSAGE){e.next=70;break}if(o=null==i?void 0:i.userData){e.next=63;break}return e.abrupt("return",!1);case 63:if(a=o.stwain){e.next=66;break}return e.abrupt("return",!1);case 66:if(s=o.command){e.next=69;break}return e.abrupt("return",!1);case 69:return e.abrupt("return",a.__OnRecieveMsg(t,s));case 70:case"end":return e.stop()}}),e)}))),ff.apply(this,arguments)}function hf(e){e.Resolution!==undefined&&(e.Resolution=parseInt(e.Resolution)),e.PixelType!==undefined&&(e.PixelType=parseInt(e.PixelType)),e.SelectSourceByIndex!==undefined&&(e.SelectSourceByIndex=parseInt(e.SelectSourceByIndex))}var gf,mf=["OnPreAllTransfers","OnPreTransfer","OnPostTransfer","OnPostTransferAsync"],pf=function(e){return e.enumBCAppend=1,e.enumBCInsert=2,e.enumBCRemove=3,e.enumBCEdit=4,e.enumBCIndexChange=5,e.enumBCUpdate=6,e}({}),vf=["OnPostAllTransfers","OnPostTransfer","OnPostLoad","OnPreTransfer","OnPreAllTransfers","OnResult","OnTransferCancelled","OnTransferError","OnSourceUIClose","OnGetFilePath","OnPercentDone","OnPostTransferAsync","OnPreAllTransfersAsync","OnRemoteScanStatusAsync","OnConsumed","OnDiskExceedLimit","OnCurrentDeviceSelected"],_f=["OnPreAllTransfers","OnPreTransfer","OnPostTransfer","OnGetFilePath","OnPostLoad"],yf=Zt.each;function Sf(){var e,t=Od.item("DWT_port"),r=Od.item("DWT_ssl");if(Ho.bEnhancedMode)return!0;Qt.detect.urls.splice(0),Qt.detect.cUrlIndex=0,t!==gf&&r!==gf&&(e={port:t,ssl:"true"==r});var n=function(t){return!e||!(!t||t.port==e.port&&t.ssl==e.ssl)};1===Qt.detect.detectType?(e!==gf&&e.ssl&&Qt.detect.urls.push(e),yf(Qt.detect.ports,(function(e){e.ssl&&n(e)&&Qt.detect.urls.push(e)}))):0===Qt.detect.detectType?(e===gf||e.ssl||Qt.detect.urls.push(e),yf(Qt.detect.ports,(function(e){!1===e.ssl&&n(e)&&Qt.detect.urls.push(e)}))):(e!==gf&&Qt.detect.urls.push(e),yf(Qt.detect.ports,(function(e){n(e)&&Qt.detect.urls.push(e)})))}var If=function(e){return e.TWAIN=0,e.ICA=3,e.SANE=3,e.TWAIN_AND_ICA=4,e.TWAIN_AND_TWAIN64=4,e.TWAIN64=5,e}({}),bf={notSupportProperty:function(e){},notSupportMethod:function(e){},refreshImageAfterInvokeFun:function(e,t,r){return 1==r},loadHttpBlob:function(e,t,r,n,i,o,a,s){var u,c,l=di;if(c={method:t,dataType:"blob"},s&&(c.headers=s),""!=e.HTTPUserName&&(c.username=e.HTTPUserName,c.password=e.HTTPPassword),e.__HTTPPostResponseString="",n){if("get"==t){var d=Zt.guid();return Qt.progressContext&&(Qt.progressContext._onPercent=a),void Ws(Qt.progressContext,d)(r,c).then((function(t){var r=t.type;if("text/plain"==r||"text/html"==r||ta(r)){var n=new FileReader;n.readAsText(t),n.onload=function(){e.__HTTPPostResponseString=n.result,i(t)},n.onerror=function(){i(t)}}else i(t)}),(function(t){t&&t.code?(e._errorCode=t.code,e._errorString=t.message):t&&t.httpCode?ba(e,!1,t.message,t.httpCode):Sa(e),Zt.isFunction(o)&&o({code:e._errorCode,message:e._errorString})}))}c.onSuccess=function(t,r,n){var o=n?n.getResponseHeader("content-type"):"";if(o.indexOf("text/")>=0||ta(o)){var a=new FileReader;a.readAsText(t),a.onload=function(){e.__HTTPPostResponseString=a.result,i(t)},a.onerror=function(){i(t)}}else i(t)},Zt.isFunction(a)&&(c.beforeSend=function(e){e.addEventListener("progress",(function(e){!de.bSafari&&e&&(delete e.totalSize,delete e.position),a(e)}),di)})}else de.bIE?(c.dataType="arraybuffer",c.onSuccess=function(t,r,n){var o,a;(o=t||n.responseData)&&(a=new Uint8Array(o)),e.__HTTPPostResponseString=n.responseText,e._errorCode=0,e._errorString="",i(a),a=null,l=fi}):(c.dataType="text",c.contentType="text/plain; charset=x-user-defined",c.mimeType="text/plain; charset=x-user-defined",c.onSuccess=function(t,r,n){var o,a,s;o=n.responseText,e.__HTTPPostResponseString=o,a=o.length,s=new Uint8Array(a);for(var u=0;u2?(i=t[1],a=t[2]):(i=r,a=n),2!=a.state&&3!=a.state||0!=a.status)ba(e,di,i,a.status);else if("abort"===a.statusText){ba(e,true)}else Sa(e);Zt.isFunction(o)&&o()},c.url=r,c.async=n,c.onError=u,c.onComplete=function(){e._cancelableObj=null};var g=Vi(c);if(!n)return l;Qt.progressContext&&(Qt.progressContext._onPercent=a,e.IfShowCancelDialogWhenImageTransfer&&Qt.progressContext.on("cancel",(function(){g.abort()})))},combineUrl:function(e,t,r){var n=[],i=t;return i===undefined||r===undefined?undefined:(Zt.isString(i)||(i=String(t)),0==i.indexOf("http://")?(i=i.replace("http://",""),n.push("http://")):0==i.indexOf("https://")?(i=i.replace("https://",""),n.push("https://")):(0==i.indexOf("//")&&(i=i.replace("//","")),e.IfSSL?n.push("https://"):n.push("http://")),n.push(i),i.indexOf(":")<0&&(e.HTTPPort||(e.HTTPPort=Qt.detect.ssl?443:80),(!Qt.detect.ssl&&80!=e.HTTPPort||Qt.detect.ssl&&443!=e.HTTPPort)&&(n.push(":"),n.push(e.HTTPPort))),0!==r.indexOf("/")&&n.push("/"),n.push(r),n.join(""))},httpPutImage:function(e,t,r,n,i,o,a){var s=fi,u={method:"PUT",url:t,hasContent:fi,processData:di,async:n,data:r,onSuccess:i,onError:function(t,r,n){var i,a;if(s=di,t&&Zt.isArray(t)&&t.length>2?(i=t[1],a=t[2]):(i=r,a=n),2!=a.state&&3!=a.state||0!=a.status)Ia(e,di,i,a.status);else if("abort"===a.statusText){Ia(e,true)}else!function(e){na(e,-2304,"Http put error: the url is invalid.")}(e);Zt.isFunction(o)&&o()},onComplete:function(){e._cancelableObj=null},beforeSend:function(e){Zt.isFunction(a)&&e.upload.addEventListener("progress",(function(e){!de.bSafari&&e&&(delete e.totalSize,delete e.position),a(e)}),di)}};""!=e.HTTPUserName&&(u.username=e.HTTPUserName,u.password=e.HTTPPassword),n||Zt.mix(u,{headers:{"X-Requested-With":di}});var c=Vi(u);return Qt.progressContext&&(Qt.progressContext._onPercent=a,Qt.progressContext._onCancel=function(){c.abort()}),s},GetImageInfo:function(e,t){var r=e._ImgManager.convertClientIndexToServerId(t);return-1==r?(Oa(e),!1):e._innerFun("GetImageInfo",El(r))},getBlobTypeByImageType:Rd,callbacks:[],pushCallback:function(e,t,r){var n={method:e,callback:t,ticks:r};bf.callbacks.push(n)},refreshUIRef:0,isServerInvalid:function(e){nf.isServerInvalid(e)},replaceLocalFilename:function(e){var t;return e===undefined?"":(t=(e=String(e)).replace(/\\/g,"\\\\"),de.bFileSystem&&(t=decodeURI(t)),t)},getImageType:function(e){if(e===undefined)return-1;if(e.length<4)return-1;var t=e.lastIndexOf(".");if(-1===t)return-1;var r=e.slice(t).toLowerCase();return".bmp"===r||".dib"===r?rr.DWT.EnumDWT_ImageType.IT_BMP:".jpg"===r||".jpe"===r||".jpeg"===r||".jfif"===r?rr.DWT.EnumDWT_ImageType.IT_JPG:".tif"===r||".tiff"===r?rr.DWT.EnumDWT_ImageType.IT_TIF:".png"===r?rr.DWT.EnumDWT_ImageType.IT_PNG:".pdf"===r?rr.DWT.EnumDWT_ImageType.IT_PDF:".jp2"===r||".j2k"===r||".j2c"===r?rr.DWT.EnumDWT_ImageType.IT_J2K:-1},makeParams:El,showMask:Ll,hideMask:Bl};function Tf(e,t,r,n,i){var o=0;return e==If.TWAIN&&(o=Wl),e==If.TWAIN64?o=Al.TWAINX64SCANNER:e==If.ICA?r?o=Al.SANESCANNER:n?o=Al.ICASCANNER:(t||i)&&(o=Wl):e==If.TWAIN_AND_TWAIN64&&(r?o=Wl|Al.SANESCANNER:n?o=Wl|Al.ICASCANNER:t?o=Wl|Al.TWAINX64SCANNER:i&&(o=Wl)),o}function Cf(e,t){for(var r=e.HowManyImagesInBuffer,n=0;n=e._ImgManager.count())||(Oa(e),Zt.isFunction(r)&&r(e._errorCode,e._getErrorString()),!1))}function kf(e){var t,r,n,i=[];return e._ImgManager.count()<=0||((r=e._ImgManager.getCurrentImageIndex())>=0&&(t=e._ImgManager.convertClientIndexToServerId(r)),n=e._ImgManager.getSelectedClientIndexArray(),Zt.isArray(n)&&Zt.each(n,(function(t){var r=e._ImgManager.convertClientIndexToServerId(t);-1!=r&&i.push(r)})),-1!=t&&0==i.length&&i.push(t)),i}function Af(e){var t,r=[];return e._ImgManager.count()<=0||(t=e._ImgManager.getCurrentImageIndex(),r=e._ImgManager.getSelectedClientIndexArray(),-1!=t&&0==r.length&&r.push(t)),r}function xf(e,t,r){return e._resetErr(),!!e._isValid()&&(isNaN(t)?(ca(e),Zt.isFunction(r)&&r(e._errorCode,e.ErrorString),di):t<0||t>=e._ImgManager.count()?(Oa(e),Zt.isFunction(r)&&r(e._errorCode,e.ErrorString),di):fi)}function Pf(e){var t,r=[],n=e.HowManyImagesInBuffer;for(t=0;t0&&gh[0]<4?1:+(gh[0]+gh[1])),!mh&&jh&&(!(gh=jh.match(/Edge\/(\d+)/))||gh[1]>=74)&&(gh=jh.match(/Chrome\/(\d+)/))&&(mh=+gh[1]);var Jh=mh,Qh=Jh,qh=Lf,Yh=Mf.String,Xh=!!Object.getOwnPropertySymbols&&!qh((function(){var e=Symbol("symbol detection");return!Yh(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Qh&&Qh<41})),Zh=Xh&&!Symbol.sham&&"symbol"==_(Symbol.iterator),$h=Oh,eg=ih,tg=Mh,rg=Object,ng=Zh?function(e){return"symbol"==_(e)}:function(e){var t=$h("Symbol");return eg(t)&&tg(t.prototype,rg(e))},ig=String,og=function(e){try{return ig(e)}catch(bi){return"Object"}},ag=ih,sg=og,ug=TypeError,cg=function(e){if(ag(e))return e;throw new ug(sg(e)+" is not a function")},lg=cg,dg=bh,fg=function(e,t){var r=e[t];return dg(r)?undefined:lg(r)},hg=ch,gg=ih,mg=Ph,pg=TypeError,vg={exports:{}},_g=!0,yg=Mf,Sg=Object.defineProperty,Ig=Mf,bg=function(e,t){try{Sg(yg,e,{value:t,configurable:!0,writable:!0})}catch(bi){yg[e]=t}return t},Tg="__core-js_shared__",Cg=vg.exports=Ig[Tg]||bg(Tg,{});(Cg.versions||(Cg.versions=[])).push({version:"3.41.0",mode:"pure",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.41.0/LICENSE",source:"https://github.com/zloirock/core-js"});var wg=vg.exports,Eg=wg,kg=function(e,t){return Eg[e]||(Eg[e]=t||{})},Ag=wh,xg=Object,Pg=function(e){return xg(Ag(e))},Dg=Pg,Fg=qf({}.hasOwnProperty),Wg=Object.hasOwn||function(e,t){return Fg(Dg(e),t)},Ng=qf,Rg=0,Og=Math.random(),Mg=Ng(1..toString),Lg=function(e){return"Symbol("+(e===undefined?"":e)+")_"+Mg(++Rg+Og,36)},Bg=kg,Ug=Wg,Vg=Lg,jg=Xh,Gg=Zh,Hg=Mf.Symbol,zg=Bg("wks"),Kg=Gg?Hg["for"]||Hg:Hg&&Hg.withoutSetter||Vg,Jg=function(e){return Ug(zg,e)||(zg[e]=jg&&Ug(Hg,e)?Hg[e]:Kg("Symbol."+e)),zg[e]},Qg=ch,qg=Ph,Yg=ng,Xg=fg,Zg=function(e,t){var r,n;if("string"===t&&gg(r=e.toString)&&!mg(n=hg(r,e)))return n;if(gg(r=e.valueOf)&&!mg(n=hg(r,e)))return n;if("string"!==t&&gg(r=e.toString)&&!mg(n=hg(r,e)))return n;throw new pg("Can't convert object to primitive value")},$g=TypeError,em=Jg("toPrimitive"),tm=function(e,t){if(!qg(e)||Yg(e))return e;var r,n=Xg(e,em);if(n){if(t===undefined&&(t="default"),r=Qg(n,e,t),!qg(r)||Yg(r))return r;throw new $g("Can't convert object to primitive value")}return t===undefined&&(t="number"),Zg(e,t)},rm=ng,nm=function(e){var t=tm(e,"string");return rm(t)?t:t+""},im=Ph,om=Mf.document,am=im(om)&&im(om.createElement),sm=function(e){return am?om.createElement(e):{}},um=sm,cm=!ah&&!Lf((function(){return 7!==Object.defineProperty(um("div"),"a",{get:function(){return 7}}).a})),lm=ah,dm=ch,fm=lh,hm=ph,gm=Ah,mm=nm,pm=Wg,vm=cm,_m=Object.getOwnPropertyDescriptor;oh.f=lm?_m:function(e,t){if(e=gm(e),t=mm(t),vm)try{return _m(e,t)}catch(bi){}if(pm(e,t))return hm(!dm(fm.f,e,t),e[t])};var ym=Lf,Sm=ih,Im=/#|\.prototype\./,bm=function(e,t){var r=Cm[Tm(e)];return r===Em||r!==wm&&(Sm(t)?ym(t):!!t)},Tm=bm.normalize=function(e){return String(e).replace(Im,".").toLowerCase()},Cm=bm.data={},wm=bm.NATIVE="N",Em=bm.POLYFILL="P",km=bm,Am=cg,xm=Bf,Pm=rh(rh.bind),Dm=function(e,t){return Am(e),t===undefined?e:xm?Pm(e,t):function(){return e.apply(t,arguments)}},Fm={},Wm=ah&&Lf((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Nm=Ph,Rm=String,Om=TypeError,Mm=function(e){if(Nm(e))return e;throw new Om(Rm(e)+" is not an object")},Lm=ah,Bm=cm,Um=Wm,Vm=Mm,jm=nm,Gm=TypeError,Hm=Object.defineProperty,zm=Object.getOwnPropertyDescriptor,Km="enumerable",Jm="configurable",Qm="writable";Fm.f=Lm?Um?function(e,t,r){if(Vm(e),t=jm(t),Vm(r),"function"==typeof e&&"prototype"===t&&"value"in r&&Qm in r&&!r[Qm]){var n=zm(e,t);n&&n[Qm]&&(e[t]=r.value,r={configurable:Jm in r?r[Jm]:n[Jm],enumerable:Km in r?r[Km]:n[Km],writable:!1})}return Hm(e,t,r)}:Hm:function(e,t,r){if(Vm(e),t=jm(t),Vm(r),Bm)try{return Hm(e,t,r)}catch(bi){}if("get"in r||"set"in r)throw new Gm("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var qm=Fm,Ym=ph,Xm=ah?function(e,t,r){return qm.f(e,t,Ym(1,r))}:function(e,t,r){return e[t]=r,e},Zm=Mf,$m=Hf,ep=rh,tp=ih,rp=oh.f,np=km,ip=Dh,op=Dm,ap=Xm,sp=Wg,up=function(e){var t=function(r,n,i){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,i)}return $m(e,this,arguments)};return t.prototype=e.prototype,t},cp=function(e,t){var r,n,i,o,a,s,u,c,l,d=e.target,f=e.global,h=e.stat,g=e.proto,m=f?Zm:h?Zm[d]:Zm[d]&&Zm[d].prototype,p=f?ip:ip[d]||ap(ip,d,{})[d],v=p.prototype;for(o in t)n=!(r=np(f?o:d+(h?".":"#")+o,e.forced))&&m&&sp(m,o),s=p[o],n&&(u=e.dontCallGetSet?(l=rp(m,o))&&l.value:m[o]),a=n&&u?u:t[o],(r||g||_(s)!=_(a))&&(c=e.bind&&n?op(a,Zm):e.wrap&&n?up(a):g&&tp(a)?ep(a):a,(e.sham||a&&a.sham||s&&s.sham)&&ap(c,"sham",!0),ap(p,o,c),g&&(sp(ip,i=d+"Prototype")||ap(ip,i,{}),ap(ip[i],o,a),e.real&&v&&(r||!v[o])&&ap(v,o,a)))},lp=qf([].slice),dp=qf,fp=cg,hp=Ph,gp=Wg,mp=lp,pp=Bf,vp=Function,_p=dp([].concat),yp=dp([].join),Sp={},Ip=pp?vp.bind:function(e){var t=fp(this),r=t.prototype,n=mp(arguments,1),i=function(){var r=_p(n,mp(arguments));return this instanceof i?function(e,t,r){if(!gp(Sp,t)){for(var n=[],i=0;i0?ev:$p)(t)},rv=function(e){var t=+e;return t!=t||0===t?0:tv(t)},nv=rv,iv=Math.max,ov=Math.min,av=function(e,t){var r=nv(e);return r<0?iv(r+t,0):ov(r,t)},sv=rv,uv=Math.min,cv=function(e){var t=sv(e);return t>0?uv(t,9007199254740991):0},lv=function(e){return cv(e.length)},dv=Ah,fv=av,hv=lv,gv=function(e){return function(t,r,n){var i=dv(t),o=hv(i);if(0===o)return!e&&-1;var a,s=fv(n,o);if(e&&r!=r){for(;o>s;)if((a=i[s++])!=a)return!0}else for(;o>s;s++)if((e||s in i)&&i[s]===r)return e||s||0;return!e&&-1}},mv={includes:gv(!0),indexOf:gv(!1)},pv={},vv=Wg,_v=Ah,yv=mv.indexOf,Sv=pv,Iv=qf([].push),bv=function(e,t){var r,n=_v(e),i=0,o=[];for(r in n)!vv(Sv,r)&&vv(n,r)&&Iv(o,r);for(;t.length>i;)vv(n,r=t[i++])&&(~yv(o,r)||Iv(o,r));return o},Tv=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Cv=bv,wv=Tv,Ev=Object.keys||function(e){return Cv(e,wv)},kv=ah,Av=Wm,xv=Fm,Pv=Mm,Dv=Ah,Fv=Ev;Zp.f=kv&&!Av?Object.defineProperties:function(e,t){Pv(e);for(var r,n=Dv(t),i=Fv(t),o=i.length,a=0;o>a;)xv.f(e,r=i[a++],n[r]);return e};var Wv,Nv=Oh("document","documentElement"),Rv=Lg,Ov=kg("keys"),Mv=function(e){return Ov[e]||(Ov[e]=Rv(e))},Lv=Mm,Bv=Zp,Uv=Tv,Vv=pv,jv=Nv,Gv=sm,Hv="prototype",zv="script",Kv=Mv("IE_PROTO"),Jv=function(){},Qv=function(e){return"<"+zv+">"+e+""},qv=function(e){e.write(Qv("")),e.close();var t=e.parentWindow.Object;return e=null,t},Yv=function(){try{Wv=new ActiveXObject("htmlfile")}catch(bi){}var e,t,r;Yv="undefined"!=typeof document?document.domain&&Wv?qv(Wv):(t=Gv("iframe"),r="java"+zv+":",t.style.display="none",jv.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(Qv("document.F=Object")),e.close(),e.F):qv(Wv);for(var n=Uv.length;n--;)delete Yv[Hv][Uv[n]];return Yv()};Vv[Kv]=!0;var Xv=Object.create||function(e,t){var r;return null!==e?(Jv[Hv]=Lv(e),r=new Jv,Jv[Hv]=null,r[Kv]=e):r=Yv(),t===undefined?r:Bv.f(r,t)},Zv=cp,$v=Hf,e_=Ip,t_=Xp,r_=Mm,n_=Ph,i_=Xv,o_=Lf,a_=Oh("Reflect","construct"),s_=Object.prototype,u_=[].push,c_=o_((function(){function e(){}return!(a_((function(){}),[],e)instanceof e)})),l_=!o_((function(){a_((function(){}))})),d_=c_||l_;Zv({target:"Reflect",stat:!0,forced:d_,sham:d_},{construct:function(e,t){t_(e),r_(t);var r=arguments.length<3?e:t_(arguments[2]);if(l_&&!c_)return a_(e,t,r);if(e===r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var n=[null];return $v(u_,n,t),new($v(e_,e,n))}var i=r.prototype,o=i_(n_(i)?i:s_),a=$v(e,o,t);return n_(a)?a:o}});var f_=k(Dh.Reflect.construct),h_=Pp,g_=String,m_=function(e){if("Symbol"===h_(e))throw new TypeError("Cannot convert a Symbol value to a string");return g_(e)},p_={},v_=bv,__=Tv.concat("length","prototype");p_.f=Object.getOwnPropertyNames||function(e){return v_(e,__)};var y_={},S_=$f,I_=Ah,b_=p_.f,T_=lp,C_="object"==("undefined"==typeof window?"undefined":_(window))&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];y_.f=function(e){return C_&&"Window"===S_(e)?function(e){try{return b_(e)}catch(bi){return T_(C_)}}(e):b_(I_(e))};var w_={};w_.f=Object.getOwnPropertySymbols;var E_=Xm,k_=function(e,t,r,n){return n&&n.enumerable?e[t]=r:E_(e,t,r),e},A_=Fm,x_=function(e,t,r){return A_.f(e,t,r)},P_={},D_=Jg;P_.f=D_;var F_,W_,N_,R_=Dh,O_=Wg,M_=P_,L_=Fm.f,B_=function(e){var t=R_.Symbol||(R_.Symbol={});O_(t,e)||L_(t,e,{value:M_.f(e)})},U_=ch,V_=Oh,j_=Jg,G_=k_,H_=function(){var e=V_("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=j_("toPrimitive");t&&!t[n]&&G_(t,n,(function(e){return U_(r,this)}),{arity:1})},z_=Pp,K_=Tp?{}.toString:function(){return"[object "+z_(this)+"]"},J_=Tp,Q_=Fm.f,q_=Xm,Y_=Wg,X_=K_,Z_=Jg("toStringTag"),$_=function(e,t,r,n){var i=r?e:e&&e.prototype;i&&(Y_(i,Z_)||Q_(i,Z_,{configurable:!0,value:t}),n&&!J_&&q_(i,"toString",X_))},ey=ih,ty=Mf.WeakMap,ry=ey(ty)&&/native code/.test(String(ty)),ny=Mf,iy=Ph,oy=Xm,ay=Wg,sy=wg,uy=Mv,cy=pv,ly="Object already initialized",dy=ny.TypeError,fy=ny.WeakMap;if(ry||sy.state){var hy=sy.state||(sy.state=new fy);hy.get=hy.get,hy.has=hy.has,hy.set=hy.set,F_=function(e,t){if(hy.has(e))throw new dy(ly);return t.facade=e,hy.set(e,t),t},W_=function(e){return hy.get(e)||{}},N_=function(e){return hy.has(e)}}else{var gy=uy("state");cy[gy]=!0,F_=function(e,t){if(ay(e,gy))throw new dy(ly);return t.facade=e,oy(e,gy,t),t},W_=function(e){return ay(e,gy)?e[gy]:{}},N_=function(e){return ay(e,gy)}}var my={set:F_,get:W_,has:N_,enforce:function(e){return N_(e)?W_(e):F_(e,{})},getterFor:function(e){return function(t){var r;if(!iy(t)||(r=W_(t)).type!==e)throw new dy("Incompatible receiver, "+e+" required");return r}}},py=$f,vy=Array.isArray||function(e){return"Array"===py(e)},_y=vy,yy=Jp,Sy=Ph,Iy=Jg("species"),by=Array,Ty=function(e){var t;return _y(e)&&(t=e.constructor,(yy(t)&&(t===by||_y(t.prototype))||Sy(t)&&null===(t=t[Iy]))&&(t=undefined)),t===undefined?by:t},Cy=function(e,t){return new(Ty(e))(0===t?0:t)},wy=Dm,Ey=Ih,ky=Pg,Ay=lv,xy=Cy,Py=qf([].push),Dy=function(e){var t=1===e,r=2===e,n=3===e,i=4===e,o=6===e,a=7===e,s=5===e||o;return function(u,c,l,d){for(var f,h,g=ky(u),m=Ey(g),p=Ay(m),v=wy(c,l),_=0,y=d||xy,S=t?y(u,p):r||a?y(u,0):undefined;p>_;_++)if((s||_ in m)&&(h=v(f=m[_],_,g),e))if(t)S[_]=h;else if(h)switch(e){case 3:return!0;case 5:return f;case 6:return _;case 2:Py(S,f)}else switch(e){case 4:return!1;case 7:Py(S,f)}return o?-1:n||i?i:S}},Fy={forEach:Dy(0),map:Dy(1),filter:Dy(2),some:Dy(3),every:Dy(4),find:Dy(5),findIndex:Dy(6),filterReject:Dy(7)},Wy=cp,Ny=Mf,Ry=ch,Oy=qf,My=ah,Ly=Xh,By=Lf,Uy=Wg,Vy=Mh,jy=Mm,Gy=Ah,Hy=nm,zy=m_,Ky=ph,Jy=Xv,Qy=Ev,qy=p_,Yy=y_,Xy=w_,Zy=oh,$y=Fm,eS=Zp,tS=lh,rS=k_,nS=x_,iS=kg,oS=pv,aS=Lg,sS=Jg,uS=P_,cS=B_,lS=H_,dS=$_,fS=my,hS=Fy.forEach,gS=Mv("hidden"),mS="Symbol",pS="prototype",vS=fS.set,_S=fS.getterFor(mS),yS=Object[pS],SS=Ny.Symbol,IS=SS&&SS[pS],bS=Ny.RangeError,TS=Ny.TypeError,CS=Ny.QObject,wS=Zy.f,ES=$y.f,kS=Yy.f,AS=tS.f,xS=Oy([].push),PS=iS("symbols"),DS=iS("op-symbols"),FS=iS("wks"),WS=!CS||!CS[pS]||!CS[pS].findChild,NS=function(e,t,r){var n=wS(yS,t);n&&delete yS[t],ES(e,t,r),n&&e!==yS&&ES(yS,t,n)},RS=My&&By((function(){return 7!==Jy(ES({},"a",{get:function(){return ES(this,"a",{value:7}).a}})).a}))?NS:ES,OS=function(e,t){var r=PS[e]=Jy(IS);return vS(r,{type:mS,tag:e,description:t}),My||(r.description=t),r},MS=function(e,t,r){e===yS&&MS(DS,t,r),jy(e);var n=Hy(t);return jy(r),Uy(PS,n)?(r.enumerable?(Uy(e,gS)&&e[gS][n]&&(e[gS][n]=!1),r=Jy(r,{enumerable:Ky(0,!1)})):(Uy(e,gS)||ES(e,gS,Ky(1,Jy(null))),e[gS][n]=!0),RS(e,n,r)):ES(e,n,r)},LS=function(e,t){jy(e);var r=Gy(t),n=Qy(r).concat(jS(r));return hS(n,(function(t){My&&!Ry(BS,r,t)||MS(e,t,r[t])})),e},BS=function(e){var t=Hy(e),r=Ry(AS,this,t);return!(this===yS&&Uy(PS,t)&&!Uy(DS,t))&&(!(r||!Uy(this,t)||!Uy(PS,t)||Uy(this,gS)&&this[gS][t])||r)},US=function(e,t){var r=Gy(e),n=Hy(t);if(r!==yS||!Uy(PS,n)||Uy(DS,n)){var i=wS(r,n);return!i||!Uy(PS,n)||Uy(r,gS)&&r[gS][n]||(i.enumerable=!0),i}},VS=function(e){var t=kS(Gy(e)),r=[];return hS(t,(function(e){Uy(PS,e)||Uy(oS,e)||xS(r,e)})),r},jS=function(e){var t=e===yS,r=kS(t?DS:Gy(e)),n=[];return hS(r,(function(e){!Uy(PS,e)||t&&!Uy(yS,e)||xS(n,PS[e])})),n};Ly||(SS=function(){if(Vy(IS,this))throw new TS("Symbol is not a constructor");var e=arguments.length&&arguments[0]!==undefined?zy(arguments[0]):undefined,t=aS(e),r=function(e){var n=this===undefined?Ny:this;n===yS&&Ry(r,DS,e),Uy(n,gS)&&Uy(n[gS],t)&&(n[gS][t]=!1);var i=Ky(1,e);try{RS(n,t,i)}catch(bi){if(!(bi instanceof bS))throw bi;NS(n,t,i)}};return My&&WS&&RS(yS,t,{configurable:!0,set:r}),OS(t,e)},rS(IS=SS[pS],"toString",(function(){return _S(this).tag})),rS(SS,"withoutSetter",(function(e){return OS(aS(e),e)})),tS.f=BS,$y.f=MS,eS.f=LS,Zy.f=US,qy.f=Yy.f=VS,Xy.f=jS,uS.f=function(e){return OS(sS(e),e)},My&&nS(IS,"description",{configurable:!0,get:function(){return _S(this).description}})),Wy({global:!0,constructor:!0,wrap:!0,forced:!Ly,sham:!Ly},{Symbol:SS}),hS(Qy(FS),(function(e){cS(e)})),Wy({target:mS,stat:!0,forced:!Ly},{useSetter:function(){WS=!0},useSimple:function(){WS=!1}}),Wy({target:"Object",stat:!0,forced:!Ly,sham:!My},{create:function(e,t){return t===undefined?Jy(e):LS(Jy(e),t)},defineProperty:MS,defineProperties:LS,getOwnPropertyDescriptor:US}),Wy({target:"Object",stat:!0,forced:!Ly},{getOwnPropertyNames:VS}),lS(),dS(SS,mS),oS[gS]=!0;var GS=Xh&&!!Symbol["for"]&&!!Symbol.keyFor,HS=cp,zS=Oh,KS=Wg,JS=m_,QS=kg,qS=GS,YS=QS("string-to-symbol-registry"),XS=QS("symbol-to-string-registry");HS({target:"Symbol",stat:!0,forced:!qS},{"for":function(e){var t=JS(e);if(KS(YS,t))return YS[t];var r=zS("Symbol")(t);return YS[t]=r,XS[r]=t,r}});var ZS=cp,$S=Wg,eI=ng,tI=og,rI=GS,nI=kg("symbol-to-string-registry");ZS({target:"Symbol",stat:!0,forced:!rI},{keyFor:function(e){if(!eI(e))throw new TypeError(tI(e)+" is not a symbol");if($S(nI,e))return nI[e]}});var iI=vy,oI=ih,aI=$f,sI=m_,uI=qf([].push),cI=cp,lI=Oh,dI=Hf,fI=ch,hI=qf,gI=Lf,mI=ih,pI=ng,vI=lp,_I=function(e){if(oI(e))return e;if(iI(e)){for(var t=e.length,r=[],n=0;ns;)(r=i(n,t=o[s++]))!==undefined&&ab(a,t,r);return a}});var sb=k(Dh.Object.getOwnPropertyDescriptors),ub={exports:{}},cb=cp,lb=ah,db=Zp.f;cb({target:"Object",stat:!0,forced:Object.defineProperties!==db,sham:!lb},{defineProperties:db});var fb=Dh.Object,hb=ub.exports=function(e,t){return fb.defineProperties(e,t)};fb.defineProperties.sham&&(hb.sham=!0);var gb=k(ub.exports),mb=!Lf((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),pb=Wg,vb=ih,_b=Pg,yb=mb,Sb=Mv("IE_PROTO"),Ib=Object,bb=Ib.prototype,Tb=yb?Ib.getPrototypeOf:function(e){var t=_b(e);if(pb(t,Sb))return t[Sb];var r=t.constructor;return vb(r)&&t instanceof r?r.prototype:t instanceof Ib?bb:null},Cb=qf,wb=cg,Eb=Ph,kb=function(e){return Eb(e)||null===e},Ab=String,xb=TypeError,Pb=function(e,t,r){try{return Cb(wb(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(bi){}},Db=Ph,Fb=wh,Wb=function(e){if(kb(e))return e;throw new xb("Can't set "+Ab(e)+" as a prototype")},Nb=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Pb(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(bi){}return function(r,n){return Fb(r),Wb(n),Db(r)?(t?e(r,n):r.__proto__=n,r):r}}():undefined),Rb=Wg,Ob=ZI,Mb=oh,Lb=Fm,Bb=Ph,Ub=Xm,Vb=Error,jb=qf("".replace),Gb=String(new Vb("zxcasd").stack),Hb=/\n\s*at [^:]*:[^\n]*/,zb=Hb.test(Gb),Kb=ph,Jb=!Lf((function(){var e=new Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Kb(1,7)),7!==e.stack)})),Qb=Xm,qb=function(e,t){if(zb&&"string"==typeof e&&!Vb.prepareStackTrace)for(;t--;)e=jb(e,Hb,"");return e},Yb=Jb,Xb=Error.captureStackTrace,Zb={},$b=Zb,eT=Jg("iterator"),tT=Array.prototype,rT=function(e){return e!==undefined&&($b.Array===e||tT[eT]===e)},nT=Pp,iT=fg,oT=bh,aT=Zb,sT=Jg("iterator"),uT=function(e){if(!oT(e))return iT(e,sT)||iT(e,"@@iterator")||aT[nT(e)]},cT=ch,lT=cg,dT=Mm,fT=og,hT=uT,gT=TypeError,mT=function(e,t){var r=arguments.length<2?hT(e):t;if(lT(r))return dT(cT(r,e));throw new gT(fT(e)+" is not iterable")},pT=ch,vT=Mm,_T=fg,yT=function(e,t,r){var n,i;vT(e);try{if(!(n=_T(e,"return"))){if("throw"===t)throw r;return r}n=pT(n,e)}catch(bi){i=!0,n=bi}if("throw"===t)throw r;if(i)throw n;return vT(n),r},ST=Dm,IT=ch,bT=Mm,TT=og,CT=rT,wT=lv,ET=Mh,kT=mT,AT=uT,xT=yT,PT=TypeError,DT=function(e,t){this.stopped=e,this.result=t},FT=DT.prototype,WT=function(e,t,r){var n,i,o,a,s,u,c,l=r&&r.that,d=!(!r||!r.AS_ENTRIES),f=!(!r||!r.IS_RECORD),h=!(!r||!r.IS_ITERATOR),g=!(!r||!r.INTERRUPTED),m=ST(t,l),p=function(e){return n&&xT(n,"normal",e),new DT(!0,e)},v=function(e){return d?(bT(e),g?m(e[0],e[1],p):m(e[0],e[1])):g?m(e,p):m(e)};if(f)n=e.iterator;else if(h)n=e;else{if(!(i=AT(e)))throw new PT(TT(e)+" is not iterable");if(CT(i)){for(o=0,a=wT(e);a>o;o++)if((s=v(e[o]))&&ET(FT,s))return s;return new DT(!1)}n=kT(e,i)}for(u=f?e.next:n.next;!(c=IT(u,n)).done;){try{s=v(c.value)}catch(bi){xT(n,"throw",bi)}if("object"==_(s)&&s&&ET(FT,s))return s}return new DT(!1)},NT=m_,RT=cp,OT=Mh,MT=Tb,LT=Nb,BT=function(e,t,r){for(var n=Ob(t),i=Lb.f,o=Mb.f,a=0;a2&>(r,arguments[2]);var i=[];return zT(e,qT,{that:i}),VT(r,"errors",i),r};LT?LT(YT,QT):BT(YT,QT,{name:!0});var XT=YT.prototype=UT(QT.prototype,{constructor:jT(1,YT),message:jT(1,""),name:jT(1,"AggregateError")});RT({global:!0,constructor:!0,arity:2},{AggregateError:YT});var ZT,$T,eC,tC=ah,rC=Wg,nC=Function.prototype,iC=tC&&Object.getOwnPropertyDescriptor,oC=rC(nC,"name"),aC={EXISTS:oC,PROPER:oC&&"something"===function(){}.name,CONFIGURABLE:oC&&(!tC||tC&&iC(nC,"name").configurable)},sC=Lf,uC=ih,cC=Ph,lC=Xv,dC=Tb,fC=k_,hC=Jg("iterator"),gC=!1;[].keys&&("next"in(eC=[].keys())?($T=dC(dC(eC)))!==Object.prototype&&(ZT=$T):gC=!0);var mC=!cC(ZT)||sC((function(){var e={};return ZT[hC].call(e)!==e}));uC((ZT=mC?{}:lC(ZT))[hC])||fC(ZT,hC,(function(){return this}));var pC={IteratorPrototype:ZT,BUGGY_SAFARI_ITERATORS:gC},vC=pC.IteratorPrototype,_C=Xv,yC=ph,SC=$_,IC=Zb,bC=function(){return this},TC=function(e,t,r,n){var i=t+" Iterator";return e.prototype=_C(vC,{next:yC(+!n,r)}),SC(e,i,!1,!0),IC[i]=bC,e},CC=cp,wC=ch,EC=TC,kC=Tb,AC=$_,xC=k_,PC=Zb,DC=aC.PROPER,FC=pC.BUGGY_SAFARI_ITERATORS,WC=Jg("iterator"),NC="keys",RC="values",OC="entries",MC=function(){return this},LC=function(e,t,r,n,i,o,a){EC(r,t,n);var s,u,c,l=function(e){if(e===i&&m)return m;if(!FC&&e&&e in h)return h[e];switch(e){case NC:case RC:case OC:return function(){return new r(this,e)}}return function(){return new r(this)}},d=t+" Iterator",f=!1,h=e.prototype,g=h[WC]||h["@@iterator"]||i&&h[i],m=!FC&&g||l(i),p="Array"===t&&h.entries||g;if(p&&(s=kC(p.call(new e)))!==Object.prototype&&s.next&&(AC(s,d,!0,!0),PC[d]=MC),DC&&i===RC&&g&&g.name!==RC&&(f=!0,m=function(){return wC(g,this)}),i)if(u={values:l(RC),keys:o?m:l(NC),entries:l(OC)},a)for(c in u)(FC||f||!(c in h))&&xC(h,c,u[c]);else CC({target:t,proto:!0,forced:FC||f},u);return a&&h[WC]!==m&&xC(h,WC,m,{name:i}),PC[t]=m,u},BC=function(e,t){return{value:e,done:t}},UC=Ah,VC=Zb,jC=my;Fm.f;var GC=LC,HC=BC,zC="Array Iterator",KC=jC.set,JC=jC.getterFor(zC);GC(Array,"Array",(function(e,t){KC(this,{type:zC,target:UC(e),index:0,kind:t})}),(function(){var e=JC(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,HC(undefined,!0);switch(e.kind){case"keys":return HC(r,!1);case"values":return HC(t[r],!1)}return HC([r,t[r]],!1)}),"values"),VC.Arguments=VC.Array;var QC,qC,YC,XC,ZC=Mf,$C=Uh,ew=$f,tw=function(e){return $C.slice(0,e.length)===e},rw=tw("Bun/")?"BUN":tw("Cloudflare-Workers")?"CLOUDFLARE":tw("Deno/")?"DENO":tw("Node.js/")?"NODE":ZC.Bun&&"string"==typeof Bun.version?"BUN":ZC.Deno&&"object"==_(Deno.version)?"DENO":"process"===ew(ZC.process)?"NODE":ZC.window&&ZC.document?"BROWSER":"REST",nw="NODE"===rw,iw=Oh,ow=x_,aw=ah,sw=Jg("species"),uw=function(e){var t=iw(e);aw&&t&&!t[sw]&&ow(t,sw,{configurable:!0,get:function(){return this}})},cw=Mh,lw=TypeError,dw=function(e,t){if(cw(t,e))return e;throw new lw("Incorrect invocation")},fw=Mm,hw=Xp,gw=bh,mw=Jg("species"),pw=function(e,t){var r,n=fw(e).constructor;return n===undefined||gw(r=fw(n)[mw])?t:hw(r)},vw=TypeError,_w=function(e,t){if(e1?EA(arguments,1):[],r=kA.f(this),n=xA((function(){return wA(AA(e),undefined,t)}));return(n.error?r.reject:r.resolve)(n.value),r.promise}});var FA=BE;cp({target:"Promise",stat:!0},{withResolvers:function(){var e=FA.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject}}});var WA=cp,NA=CE,RA=Lf,OA=Oh,MA=ih,LA=pw,BA=oA,UA=NA&&NA.prototype;WA({target:"Promise",proto:!0,real:!0,forced:!!NA&&RA((function(){UA["finally"].call({then:function(){}},(function(){}))}))},{"finally":function(e){var t=LA(this,OA("Promise")),r=MA(e);return this.then(r?function(r){return BA(t,e()).then((function(){return r}))}:e,r?function(r){return BA(t,e()).then((function(){throw r}))}:e)}});var VA=qf,jA=rv,GA=m_,HA=wh,zA=VA("".charAt),KA=VA("".charCodeAt),JA=VA("".slice),QA=function(e){return function(t,r){var n,i,o=GA(HA(t)),a=jA(r),s=o.length;return a<0||a>=s?e?"":undefined:(n=KA(o,a))<55296||n>56319||a+1===s||(i=KA(o,a+1))<56320||i>57343?e?zA(o,a):n:e?JA(o,a,a+2):i-56320+(n-55296<<10)+65536}},qA={codeAt:QA(!1),charAt:QA(!0)},YA=qA.charAt,XA=m_,ZA=my,$A=LC,ex=BC,tx="String Iterator",rx=ZA.set,nx=ZA.getterFor(tx);$A(String,"String",(function(e){rx(this,{type:tx,string:XA(e),index:0})}),(function(){var e,t=nx(this),r=t.string,n=t.index;return n>=r.length?ex(undefined,!0):(e=YA(r,n),t.index+=e.length,ex(e,!1))}));var ix=Dh.Promise,ox={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},ax=Mf,sx=$_,ux=Zb;for(var cx in ox)sx(ax[cx],cx),ux[cx]=ux.Array;var lx=ix,dx=lx,fx=k(dx);function hx(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):fx.resolve(u).then(n,i)}function gx(e){return function(){var t=this,r=arguments;return new fx((function(n,i){var o=e.apply(t,r);function a(e){hx(o,n,i,a,s,"next",e)}function s(e){hx(o,n,i,a,s,"throw",e)}a(void 0)}))}}function mx(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var px=Wg,vx=ch,_x=Ph,yx=Mm,Sx=function(e){return e!==undefined&&(px(e,"value")||px(e,"writable"))},Ix=oh,bx=Tb;cp({target:"Reflect",stat:!0},{get:function KJ(e,t){var r,n,i=arguments.length<3?e:arguments[2];return yx(e)===i?e[t]:(r=Ix.f(e,t))?Sx(r)?r.value:r.get===undefined?undefined:vx(r.get,i):_x(n=bx(e))?KJ(n,t,i):void 0}});var Tx=k(Dh.Reflect.get),Cx=Ip;cp({target:"Function",proto:!0,forced:Function.bind!==Cx},{bind:Cx});var wx=Mf,Ex=Dh,kx=function(e,t){var r=Ex[e+"Prototype"],n=r&&r[t];if(n)return n;var i=wx[e],o=i&&i.prototype;return o&&o[t]},Ax=kx("Function","bind"),xx=Mh,Px=Ax,Dx=Function.prototype,Fx=function(e){var t=e.bind;return e===Dx||xx(Dx,e)&&t===Dx.bind?Px:t},Wx=k(Fx),Nx=k(zI);cp({target:"Object",stat:!0},{setPrototypeOf:Nb});var Rx=Dh.Object.setPrototypeOf,Ox=k(Rx),Mx=Pg,Lx=Tb,Bx=mb;cp({target:"Object",stat:!0,forced:Lf((function(){Lx(1)})),sham:!Bx},{getPrototypeOf:function(e){return Lx(Mx(e))}});var Ux=Dh.Object.getPrototypeOf,Vx=k(Ux);function jx(e){var t;return jx=Ox?Wx(t=Vx).call(t):function(e){return e.__proto__||Vx(e)},jx(e)}function Gx(){var e;return Gx="undefined"!=typeof Reflect&&Tx?Wx(e=Tx).call(e):function(e,t,r){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=jx(e)););return e}(e,t);if(n){var i=Nx(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},Gx.apply(null,arguments)}cp({target:"Object",stat:!0,sham:!ah},{create:Xv});var Hx=Dh.Object,zx=function(e,t){return Hx.create(e,t)},Kx=k(zx),Jx={exports:{}},Qx=cp,qx=ah,Yx=Fm.f;Qx({target:"Object",stat:!0,forced:Object.defineProperty!==Yx,sham:!qx},{defineProperty:Yx});var Xx=Dh.Object,Zx=Jx.exports=function(e,t,r){return Xx.defineProperty(e,t,r)};Xx.defineProperty.sham&&(Zx.sham=!0);var $x=Jx.exports,eP=$x,tP=k(eP);function rP(e,t){var r;return rP=Ox?Wx(r=Ox).call(r):function(e,t){return e.__proto__=t,e},rP(e,t)}function nP(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Kx(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),tP(e,"prototype",{writable:!1}),t&&rP(e,t)}var iP=TypeError,oP=function(e){if(e>9007199254740991)throw iP("Maximum allowed index exceeded");return e},aP=Lf,sP=Jh,uP=Jg("species"),cP=function(e){return sP>=51||!aP((function(){var t=[];return(t.constructor={})[uP]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},lP=cp,dP=Lf,fP=vy,hP=Ph,gP=Pg,mP=lv,pP=oP,vP=rb,_P=Cy,yP=cP,SP=Jh,IP=Jg("isConcatSpreadable"),bP=SP>=51||!dP((function(){var e=[];return e[IP]=!1,e.concat()[0]!==e})),TP=function(e){if(!hP(e))return!1;var t=e[IP];return t!==undefined?!!t:fP(e)};lP({target:"Array",proto:!0,arity:1,forced:!bP||!yP("concat")},{concat:function(e){var t,r,n,i,o,a=gP(this),s=_P(a,0),u=0;for(t=-1,n=arguments.length;t1?arguments[1]:undefined,o=i!==undefined;o&&(i=JD(i,n>2?arguments[2]:undefined));var a,s,u,c,l,d,f=rF(t),h=0;if(!f||this===nF&&XD(f))for(a=$D(t),s=r?new this(a):nF(a);a>h;h++)d=o?i(t[h],h):t[h],eF(s,h,d);else for(s=r?new this:[],l=(c=tF(t,f)).next;!(u=QD(l,c)).done;h++)d=o?YD(c,i,[u.value,h],!0):u.value,eF(s,h,d);return s.length=h,s},oF=iF;cp({target:"Array",stat:!0,forced:!Uk((function(e){Array.from(e)}))},{from:oF});var aF=Dh.Array.from,sF=k(aF);function uF(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r1?arguments[1]:undefined)};cp({target:"Array",proto:!0,forced:[].forEach!==CF},{forEach:CF});var wF=kx("Array","forEach"),EF=Pp,kF=Wg,AF=Mh,xF=wF,PF=Array.prototype,DF={DOMTokenList:!0,NodeList:!0},FF=function(e){var t=e.forEach;return e===PF||AF(PF,e)&&t===PF.forEach||kF(DF,EF(e))?xF:t},WF=FF,NF=cp,RF=vy,OF=qf([].reverse),MF=[1,2];NF({target:"Array",proto:!0,forced:String(MF)===String(MF.reverse())},{reverse:function(){return RF(this)&&(this.length=this.length),OF(this)}});var LF=kx("Array","reverse"),BF=Mh,UF=LF,VF=Array.prototype,jF=function(e){var t=e.reverse;return e===VF||BF(VF,e)&&t===VF.reverse?UF:t},GF=jF;!function(e){var t=SF["default"],r=eP,n=$P,i=zx,o=Ux,a=WF,s=ID,u=Rx,c=dx,l=GF,d=GD;function f(){e.exports=f=function(){return g},e.exports.__esModule=!0,e.exports["default"]=e.exports;var h,g={},m=Object.prototype,p=m.hasOwnProperty,v=r||function(e,t,r){e[t]=r.value},_="function"==typeof n?n:{},y=_.iterator||"@@iterator",S=_.asyncIterator||"@@asyncIterator",I=_.toStringTag||"@@toStringTag";function b(e,t,n){return r(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{b({},"")}catch(h){b=function(e,t,r){return e[t]=r}}function T(e,t,r,n){var o=t&&t.prototype instanceof P?t:P,a=i(o.prototype),s=new j(n||[]);return v(a,"_invoke",{value:L(e,r,s)}),a}function C(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}g.wrap=T;var w="suspendedStart",E="suspendedYield",k="executing",A="completed",x={};function P(){}function D(){}function F(){}var W={};b(W,y,(function(){return this}));var N=o&&o(o(G([])));N&&N!==m&&p.call(N,y)&&(W=N);var R=F.prototype=P.prototype=i(W);function O(e){var t;a(t=["next","throw","return"]).call(t,(function(t){b(e,t,(function(e){return this._invoke(t,e)}))}))}function M(e,r){function n(i,o,a,s){var u=C(e[i],e,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==t(l)&&p.call(l,"__await")?r.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):r.resolve(l).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;v(this,"_invoke",{value:function(e,t){function o(){return new r((function(r,i){n(e,t,r,i)}))}return i=i?i.then(o,o):o()}})}function L(e,t,r){var n=w;return function(i,o){if(n===k)throw Error("Generator is already running");if(n===A){if("throw"===i)throw o;return{value:h,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=B(a,r);if(s){if(s===x)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===w)throw n=A,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=k;var u=C(e,t,r);if("normal"===u.type){if(n=r.done?A:E,u.arg===x)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=A,r.method="throw",r.arg=u.arg)}}}function B(e,t){var r=t.method,n=e.iterator[r];if(n===h)return t.delegate=null,"throw"===r&&e.iterator["return"]&&(t.method="return",t.arg=h,B(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),x;var i=C(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,x;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=h),t.delegate=null,x):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,x)}function U(e){var t,r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),s(t=this.tryEntries).call(t,r)}function V(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],a(e).call(e,U,this),this.reset(!0)}function G(e){if(e||""===e){var r=e[y];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n=0;--n){var i=this.tryEntries[n],o=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var a=p.call(i,"catchLoc"),s=p.call(i,"finallyLoc");if(a&&s){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&p.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),V(r),x}},"catch":function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;V(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:G(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=h),x}},g}e.exports=f,e.exports.__esModule=!0,e.exports["default"]=e.exports}(_F);var HF=(0,_F.exports)(),zF=HF;try{regeneratorRuntime=HF}catch(NJ){"object"===("undefined"==typeof globalThis?"undefined":_(globalThis))?globalThis.regeneratorRuntime=HF:Function("r","regeneratorRuntime = r")(HF)}var KF=k(zF),JF=k(iD),QF=k(FF),qF=Pg,YF=Ev;cp({target:"Object",stat:!0,forced:Lf((function(){YF(1)}))},{keys:function(e){return YF(qF(e))}});var XF=k(Dh.Object.keys);cp({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var ZF=k(Dh.Number.isNaN),$F=kx("Array","concat"),eW=Mh,tW=$F,rW=Array.prototype,nW=function(e){var t=e.concat;return e===rW||eW(rW,e)&&t===rW.concat?tW:t},iW=k(nW),oW=cp,aW=qf,sW=av,uW=RangeError,cW=String.fromCharCode,lW=String.fromCodePoint,dW=aW([].join);oW({target:"String",stat:!0,arity:1,forced:!!lW&&1!==lW.length},{fromCodePoint:function(e){for(var t,r=[],n=arguments.length,i=0;n>i;){if(t=+arguments[i++],sW(t,1114111)!==t)throw new uW(t+" is not a valid code point");r[i]=t<65536?cW(t):cW(55296+((t-=65536)>>10),t%1024+56320)}return dW(r,"")}});var fW=Lf,hW=_g,gW=Jg("iterator"),mW=!fW((function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),n="";return e.pathname="c%20d",t.forEach((function(e,r){t["delete"]("b"),n+=r+e})),r["delete"]("a",2),r["delete"]("b",undefined),!e.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",undefined)||r.has("b")||!t.size&&hW||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[gW]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==n||"x"!==new URL("https://x",undefined).host})),pW=k_,vW=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:pW(e,n,t[n],r);return e},_W=lp,yW=Math.floor,SW=function(e,t){var r=e.length;if(r<8)for(var n,i,o=1;o0;)e[i]=e[--i];i!==o++&&(e[i]=n)}else for(var a=yW(r/2),s=SW(_W(e,0,a),t),u=SW(_W(e,a),t),c=s.length,l=u.length,d=0,f=0;d0&&e&r;r>>=1)t++;return t},wN=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},EN=function(e){for(var t=(e=mN(e,IN," ")).length,r="",n=0;nt){r+="%",n++;continue}var o=TN(e,n+1);if(o!=o){r+=i,n++;continue}n+=2;var a=CN(o);if(0===a)i=cN(o);else{if(1===a||a>4){r+="�",n++;continue}for(var s=[o],u=1;ut||"%"!==fN(e,n));){var c=TN(e,n+1);if(c!=c){n+=3;break}if(c>191||c<128)break;gN(s,c),n+=2,u++}if(s.length!==a){r+="�";continue}var l=wN(s);null===l?r+="�":i=lN(l)}}r+=i,n++}return r},kN=/[!'()~]|%20/g,AN={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},xN=function(e){return AN[e]},PN=function(e){return mN(uN(e),kN,xN)},DN=WW((function(e,t){$W(this,{type:ZW,target:eN(e).entries,index:0,kind:t})}),XW,(function(){var e=tN(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,JW(undefined,!0);var n=t[r];switch(e.kind){case"keys":return JW(n.key,!1);case"values":return JW(n.value,!1)}return JW([n.key,n.value],!1)}),!0),FN=function(e){this.entries=[],this.url=null,e!==undefined&&(VW(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===fN(e,0)?yN(e,1):e:jW(e)))};FN.prototype={type:XW,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,u=this.entries,c=KW(e);if(c)for(r=(t=zW(e,c)).next;!(n=wW(r,t)).done;){if(o=(i=zW(UW(n.value))).next,(a=wW(o,i)).done||(s=wW(o,i)).done||!wW(o,i).done)throw new sN("Expected sequence with length 2");gN(u,{key:jW(a.value),value:jW(s.value)})}else for(var l in e)MW(e,l)&&gN(u,{key:l,value:jW(e[l])})},parseQuery:function(e){if(e)for(var t,r,n=this.entries,i=_N(e,"&"),o=0;o0?arguments[0]:undefined,t=$W(this,new FN(e));kW||(this.size=t.entries.length)},NN=WN.prototype;if(DW(NN,{append:function(e,t){var r=eN(this);QW(arguments.length,2),gN(r.entries,{key:jW(e),value:jW(t)}),kW||this.length++,r.updateURL()},"delete":function(e){for(var t=eN(this),r=QW(arguments.length,1),n=t.entries,i=jW(e),o=r<2?undefined:arguments[1],a=o===undefined?o:jW(o),s=0;st.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=eN(this).entries,n=LW(e,arguments.length>1?arguments[1]:undefined),i=0;i1?MN(arguments[1]):{})}}),OW(nN)){var LN=function(e){return RW(this,oN),new nN(e,arguments.length>1?MN(arguments[1]):{})};oN.constructor=LN,LN.prototype=oN,IW({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:LN})}}var BN,UN={URLSearchParams:WN,getState:eN},VN=ah,jN=qf,GN=ch,HN=Lf,zN=Ev,KN=w_,JN=lh,QN=Pg,qN=Ih,YN=Object.assign,XN=Object.defineProperty,ZN=jN([].concat),$N=!YN||HN((function(){if(VN&&1!==YN({b:1},YN(XN({},"a",{enumerable:!0,get:function(){XN(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!==YN({},e)[r]||zN(YN({},t)).join("")!==n}))?function(e,t){for(var r=QN(e),n=arguments.length,i=1,o=KN.f,a=JN.f;n>i;)for(var s,u=qN(arguments[i++]),c=o?ZN(zN(u),o(u)):zN(u),l=c.length,d=0;l>d;)s=c[d++],VN&&!GN(a,u,s)||(r[s]=u[s]);return r}:YN,eR=qf,tR=2147483647,rR=/[^\0-\u007E]/,nR=/[.\u3002\uFF0E\uFF61]/g,iR="Overflow: input needs wider integers to process",oR=RangeError,aR=eR(nR.exec),sR=Math.floor,uR=String.fromCharCode,cR=eR("".charCodeAt),lR=eR([].join),dR=eR([].push),fR=eR("".replace),hR=eR("".split),gR=eR("".toLowerCase),mR=function(e){return e+22+75*(e<26)},pR=function(e,t,r){var n=0;for(e=r?sR(e/700):e>>1,e+=sR(e/t);e>455;)e=sR(e/35),n+=36;return sR(n+36*e/(e+38))},vR=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r=55296&&i<=56319&&r=o&&nsR((tR-a)/d))throw new oR(iR);for(a+=(l-o)*d,o=l,r=0;rtR)throw new oR(iR);if(n===o){for(var f=a,h=36;;){var g=h<=s?1:h>=s+26?26:h-s;if(f?@[\\\]^|]/,pO=/[\0\t\n\r #/:<>?@[\\\]^|]/,vO=/^[\u0000-\u0020]+/,_O=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,yO=/[\t\n\r]/g,SO=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)iO(t,e%256),e=zR(e/256);return qR(t,".")}if("object"==_(e)){for(t="",n=function(e){for(var t=null,r=1,n=null,i=0,o=0;o<8;o++)0!==e[o]?(i>r&&(t=n,r=i),n=null,i=0):(null===n&&(n=o),++i);return i>r?n:t}(e),r=0;r<8;r++)i&&0===e[r]||(i&&(i=!1),n===r?(t+=r?":":"::",i=!0):(t+=YR(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},IO={},bO=AR({},IO,{" ":1,'"':1,"<":1,">":1,"`":1}),TO=AR({},bO,{"#":1,"?":1,"{":1,"}":1}),CO=AR({},TO,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),wO=function(e,t){var r=DR(e,0);return r>32&&r<127&&!kR(t,e)?e:encodeURIComponent(e)},EO={ftp:21,file:null,http:80,https:443,ws:80,wss:443},kO=function(e,t){var r;return 2===e.length&&QR(uO,JR(e,0))&&(":"===(r=JR(e,1))||!t&&"|"===r)},AO=function(e){var t;return e.length>1&&kO(rO(e,0,2))&&(2===e.length||"/"===(t=JR(e,2))||"\\"===t||"?"===t||"#"===t)},xO=function(e){return"."===e||"%2e"===nO(e)},PO={},DO={},FO={},WO={},NO={},RO={},OO={},MO={},LO={},BO={},UO={},VO={},jO={},GO={},HO={},zO={},KO={},JO={},QO={},qO={},YO={},XO=function(e,t,r){var n,i,o,a=WR(e);if(t){if(i=this.parse(a))throw new GR(i);this.searchParams=null}else{if(r!==undefined&&(n=new XO(r,!0)),i=this.parse(a,null,n))throw new GR(i);(o=VR(new UR)).bindURL(this),this.searchParams=o}};XO.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,u=this,c=t||PO,l=0,d="",f=!1,h=!1,g=!1;for(e=WR(e),t||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,e=$R(e,vO,""),e=$R(e,_O,"$1")),e=$R(e,yO,""),n=xR(e);l<=n.length;){switch(i=n[l],c){case PO:if(!i||!QR(uO,i)){if(t)return oO;c=FO;continue}d+=nO(i),c=DO;break;case DO:if(i&&(QR(cO,i)||"+"===i||"-"===i||"."===i))d+=nO(i);else{if(":"!==i){if(t)return oO;d="",c=FO,l=0;continue}if(t&&(u.isSpecial()!==kR(EO,d)||"file"===d&&(u.includesCredentials()||null!==u.port)||"file"===u.scheme&&!u.host))return;if(u.scheme=d,t)return void(u.isSpecial()&&EO[u.scheme]===u.port&&(u.port=null));d="","file"===u.scheme?c=GO:u.isSpecial()&&r&&r.scheme===u.scheme?c=WO:u.isSpecial()?c=MO:"/"===n[l+1]?(c=NO,l++):(u.cannotBeABaseURL=!0,ZR(u.path,""),c=QO)}break;case FO:if(!r||r.cannotBeABaseURL&&"#"!==i)return oO;if(r.cannotBeABaseURL&&"#"===i){u.scheme=r.scheme,u.path=PR(r.path),u.query=r.query,u.fragment="",u.cannotBeABaseURL=!0,c=YO;break}c="file"===r.scheme?GO:RO;continue;case WO:if("/"!==i||"/"!==n[l+1]){c=RO;continue}c=LO,l++;break;case NO:if("/"===i){c=BO;break}c=JO;continue;case RO:if(u.scheme=r.scheme,i===BN)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=PR(r.path),u.query=r.query;else if("/"===i||"\\"===i&&u.isSpecial())c=OO;else if("?"===i)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=PR(r.path),u.query="",c=qO;else{if("#"!==i){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=PR(r.path),u.path.length--,c=JO;continue}u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=PR(r.path),u.query=r.query,u.fragment="",c=YO}break;case OO:if(!u.isSpecial()||"/"!==i&&"\\"!==i){if("/"!==i){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,c=JO;continue}c=BO}else c=LO;break;case MO:if(c=LO,"/"!==i||"/"!==JR(d,l+1))continue;l++;break;case LO:if("/"!==i&&"\\"!==i){c=BO;continue}break;case BO:if("@"===i){f&&(d="%40"+d),f=!0,o=xR(d);for(var m=0;m65535)return sO;u.port=u.isSpecial()&&_===EO[u.scheme]?null:_,d=""}if(t)return;c=KO;continue}return sO}d+=i;break;case GO:if(u.scheme="file","/"===i||"\\"===i)c=HO;else{if(!r||"file"!==r.scheme){c=JO;continue}switch(i){case BN:u.host=r.host,u.path=PR(r.path),u.query=r.query;break;case"?":u.host=r.host,u.path=PR(r.path),u.query="",c=qO;break;case"#":u.host=r.host,u.path=PR(r.path),u.query=r.query,u.fragment="",c=YO;break;default:AO(qR(PR(n,l),""))||(u.host=r.host,u.path=PR(r.path),u.shortenPath()),c=JO;continue}}break;case HO:if("/"===i||"\\"===i){c=zO;break}r&&"file"===r.scheme&&!AO(qR(PR(n,l),""))&&(kO(r.path[0],!0)?ZR(u.path,r.path[0]):u.host=r.host),c=JO;continue;case zO:if(i===BN||"/"===i||"\\"===i||"?"===i||"#"===i){if(!t&&kO(d))c=JO;else if(""===d){if(u.host="",t)return;c=KO}else{if(a=u.parseHost(d))return a;if("localhost"===u.host&&(u.host=""),t)return;d="",c=KO}continue}d+=i;break;case KO:if(u.isSpecial()){if(c=JO,"/"!==i&&"\\"!==i)continue}else if(t||"?"!==i)if(t||"#"!==i){if(i!==BN&&(c=JO,"/"!==i))continue}else u.fragment="",c=YO;else u.query="",c=qO;break;case JO:if(i===BN||"/"===i||"\\"===i&&u.isSpecial()||!t&&("?"===i||"#"===i)){if(".."===(s=nO(s=d))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(u.shortenPath(),"/"===i||"\\"===i&&u.isSpecial()||ZR(u.path,"")):xO(d)?"/"===i||"\\"===i&&u.isSpecial()||ZR(u.path,""):("file"===u.scheme&&!u.path.length&&kO(d)&&(u.host&&(u.host=""),d=JR(d,0)+":"),ZR(u.path,d)),d="","file"===u.scheme&&(i===BN||"?"===i||"#"===i))for(;u.path.length>1&&""===u.path[0];)eO(u.path);"?"===i?(u.query="",c=qO):"#"===i&&(u.fragment="",c=YO)}else d+=wO(i,TO);break;case QO:"?"===i?(u.query="",c=qO):"#"===i?(u.fragment="",c=YO):i!==BN&&(u.path[0]+=wO(i,IO));break;case qO:t||"#"!==i?i!==BN&&("'"===i&&u.isSpecial()?u.query+="%27":u.query+="#"===i?"%23":wO(i,IO)):(u.fragment="",c=YO);break;case YO:i!==BN&&(u.fragment+=wO(i,bO))}l++}},parseHost:function(e){var t,r,n;if("["===JR(e,0)){if("]"!==JR(e,e.length-1))return aO;if(t=function(e){var t,r,n,i,o,a,s,u=[0,0,0,0,0,0,0,0],c=0,l=null,d=0,f=function(){return JR(e,d)};if(":"===f()){if(":"!==JR(e,1))return;d+=2,l=++c}for(;f();){if(8===c)return;if(":"!==f()){for(t=r=0;r<4&&QR(gO,f());)t=16*t+HR(f(),16),d++,r++;if("."===f()){if(0===r)return;if(d-=r,c>6)return;for(n=0;f();){if(i=null,n>0){if(!("."===f()&&n<4))return;d++}if(!QR(lO,f()))return;for(;QR(lO,f());){if(o=HR(f(),10),null===i)i=o;else{if(0===i)return;i=10*i+o}if(i>255)return;d++}u[c]=256*u[c]+i,2!=++n&&4!==n||c++}if(4!==n)return;break}if(":"===f()){if(d++,!f())return}else if(f())return;u[c++]=t}else{if(null!==l)return;d++,l=++c}}if(null!==l)for(a=c-l,c=7;0!==c&&a>0;)s=u[c],u[c--]=u[l+a-1],u[l+--a]=s;else if(8!==c)return;return u}(rO(e,1,-1)),!t)return aO;this.host=t}else if(this.isSpecial()){if(e=FR(e),QR(mO,e))return aO;if(t=function(e){var t,r,n,i,o,a,s,u=tO(e,".");if(u.length&&""===u[u.length-1]&&u.length--,(t=u.length)>4)return e;for(r=[],n=0;n1&&"0"===JR(i,0)&&(o=QR(dO,i)?16:8,i=rO(i,8===o?1:2)),""===i)a=0;else{if(!QR(10===o?hO:8===o?fO:gO,i))return e;a=HR(i,o)}ZR(r,a)}for(n=0;n=KR(256,5-t))return null}else if(a>255)return null;for(s=XR(r),n=0;n1?arguments[1]:undefined,n=LR(t,new XO(e,!1,r));yR||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},$O=ZO.prototype,eM=function(e,t){return{get:function(){return BR(this)[e]()},set:t&&function(e){return BR(this)[t](e)},configurable:!0,enumerable:!0}};if(yR&&(wR($O,"href",eM("serialize","setHref")),wR($O,"origin",eM("getOrigin")),wR($O,"protocol",eM("getProtocol","setProtocol")),wR($O,"username",eM("getUsername","setUsername")),wR($O,"password",eM("getPassword","setPassword")),wR($O,"host",eM("getHost","setHost")),wR($O,"hostname",eM("getHostname","setHostname")),wR($O,"port",eM("getPort","setPort")),wR($O,"pathname",eM("getPathname","setPathname")),wR($O,"search",eM("getSearch","setSearch")),wR($O,"searchParams",eM("getSearchParams")),wR($O,"hash",eM("getHash","setHash"))),CR($O,"toJSON",(function(){return BR(this).serialize()}),{enumerable:!0}),CR($O,"toString",(function(){return BR(this).serialize()}),{enumerable:!0}),jR){var tM=jR.createObjectURL,rM=jR.revokeObjectURL;tM&&CR(ZO,"createObjectURL",bR(tM,jR)),rM&&CR(ZO,"revokeObjectURL",bR(rM,jR))}NR(ZO,"URL"),_R({global:!0,constructor:!0,forced:!SR,sham:!yR},{URL:ZO});var nM=cp,iM=Lf,oM=_w,aM=m_,sM=mW,uM=Oh("URL"),cM=sM&&iM((function(){uM.canParse()})),lM=iM((function(){return 1!==uM.canParse.length}));nM({target:"URL",stat:!0,forced:!cM||lM},{canParse:function(e){var t=oM(arguments.length,1),r=aM(e),n=t<2||arguments[1]===undefined?undefined:aM(arguments[1]);try{return!!new uM(r,n)}catch(bi){return!1}}});var dM=cp,fM=_w,hM=m_,gM=mW,mM=Oh("URL");dM({target:"URL",stat:!0,forced:!gM},{parse:function(e){var t=fM(arguments.length,1),r=hM(e),n=t<2||arguments[1]===undefined?undefined:hM(arguments[1]);try{return new mM(r,n)}catch(bi){return null}}});var pM=k(Dh.URL),vM=k(jD),_M=cp,yM=mv.indexOf,SM=bF,IM=rh([].indexOf),bM=!!IM&&1/IM([1],1,-0)<0;_M({target:"Array",proto:!0,forced:bM||!SM("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:undefined;return bM?IM(this,e,t)||0:yM(this,e,t)}});var TM=kx("Array","indexOf"),CM=Mh,wM=TM,EM=Array.prototype,kM=function(e){var t=e.indexOf;return e===EM||CM(EM,e)&&t===EM.indexOf?wM:t},AM=k(kM),xM=og,PM=TypeError,DM=cp,FM=Pg,WM=av,NM=rv,RM=lv,OM=dD,MM=oP,LM=Cy,BM=rb,UM=function(e,t){if(!delete e[t])throw new PM("Cannot delete property "+xM(t)+" of "+xM(e))},VM=cP("splice"),jM=Math.max,GM=Math.min;DM({target:"Array",proto:!0,forced:!VM},{splice:function(e,t){var r,n,i,o,a,s,u=FM(this),c=RM(u),l=WM(e,c),d=arguments.length;for(0===d?r=n=0:1===d?(r=0,n=c-l):(r=d-2,n=GM(jM(NM(t),0),c-l)),MM(c+r-n),i=LM(u,n),o=0;oc-n+r;o--)UM(u,o-1)}else if(r>n)for(o=c-n;o>l;o--)s=o+r-1,(a=o+n-1)in u?u[s]=u[a]:UM(u,s);for(o=0;o1?arguments[1]:undefined)}});var eL=kx("Array","findIndex"),tL=Mh,rL=eL,nL=Array.prototype,iL=function(e){var t=e.findIndex;return e===nL||tL(nL,e)&&t===nL.findIndex?rL:t},oL=k(iL),aL=ah,sL=Lf,uL=qf,cL=Tb,lL=Ev,dL=Ah,fL=uL(lh.f),hL=uL([].push),gL=aL&&sL((function(){var e=Object.create(null);return e[2]=2,!fL(e,2)})),mL=function(e){return function(t){for(var r,n=dL(t),i=lL(n),o=gL&&null===cL(n),a=i.length,s=0,u=[];a>s;)r=i[s++],aL&&!(o?r in n:fL(n,r))||hL(u,e?[r,n[r]]:n[r]);return u}},pL={entries:mL(!0),values:mL(!1)}.entries;cp({target:"Object",stat:!0},{entries:function(e){return pL(e)}});var vL=k(Dh.Object.entries),_L=k(lx),yL=cp,SL=Fy.find,IL="find",bL=!0;IL in[]&&Array(1)[IL]((function(){bL=!1})),yL({target:"Array",proto:!0,forced:bL},{find:function(e){return SL(this,e,arguments.length>1?arguments[1]:undefined)}});var TL=kx("Array","find"),CL=Mh,wL=TL,EL=Array.prototype,kL=function(e){var t=e.find;return e===EL||CL(EL,e)&&t===EL.find?wL:t},AL=k(kL),xL=Fy.filter;cp({target:"Array",proto:!0,forced:!cP("filter")},{filter:function(e){return xL(this,e,arguments.length>1?arguments[1]:undefined)}});var PL=kx("Array","filter"),DL=Mh,FL=PL,WL=Array.prototype,NL=function(e){var t=e.filter;return e===WL||DL(WL,e)&&t===WL.filter?FL:t},RL=k(NL),OL=Fy.map;cp({target:"Array",proto:!0,forced:!cP("map")},{map:function(e){return OL(this,e,arguments.length>1?arguments[1]:undefined)}});var ML=kx("Array","map"),LL=Mh,BL=ML,UL=Array.prototype,VL=function(e){var t=e.map;return e===UL||LL(UL,e)&&t===UL.map?BL:t},jL=k(VL),GL=mv.includes;cp({target:"Array",proto:!0,forced:Lf((function(){return!Array(1).includes()}))},{includes:function(e){return GL(this,e,arguments.length>1?arguments[1]:undefined)}});var HL=kx("Array","includes"),zL=Ph,KL=$f,JL=Jg("match"),QL=function(e){var t;return zL(e)&&((t=e[JL])!==undefined?!!t:"RegExp"===KL(e))},qL=TypeError,YL=Jg("match"),XL=cp,ZL=function(e){if(QL(e))throw new qL("The method doesn't accept regular expressions");return e},$L=wh,eB=m_,tB=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[YL]=!1,"/./"[e](t)}catch(n){}}return!1},rB=qf("".indexOf);XL({target:"String",proto:!0,forced:!tB("includes")},{includes:function(e){return!!~rB(eB($L(this)),eB(ZL(e)),arguments.length>1?arguments[1]:undefined)}});var nB=kx("String","includes"),iB=Mh,oB=HL,aB=nB,sB=Array.prototype,uB=String.prototype,cB=function(e){var t=e.includes;return e===sB||iB(sB,e)&&t===sB.includes?oB:"string"==typeof e||e===uB||iB(uB,e)&&t===uB.includes?aB:t},lB=k(cB),dB="\t\n\x0B\f\r                 \u2028\u2029\ufeff",fB=wh,hB=m_,gB=dB,mB=qf("".replace),pB=RegExp("^["+gB+"]+"),vB=RegExp("(^|[^"+gB+"])["+gB+"]+$"),_B=function(e){return function(t){var r=hB(fB(t));return 1&e&&(r=mB(r,pB,"")),2&e&&(r=mB(r,vB,"$1")),r}},yB={start:_B(1),end:_B(2),trim:_B(3)},SB=Mf,IB=Lf,bB=qf,TB=m_,CB=yB.trim,wB=dB,EB=SB.parseInt,kB=SB.Symbol,AB=kB&&kB.iterator,xB=/^[+-]?0x/i,PB=bB(xB.exec),DB=8!==EB(wB+"08")||22!==EB(wB+"0x16")||AB&&!IB((function(){EB(Object(AB))}))?function(e,t){var r=CB(TB(e));return EB(r,t>>>0||(PB(xB,r)?16:10))}:EB;cp({global:!0,forced:parseInt!==DB},{parseInt:DB});var FB=k(Dh.parseInt),WB=k(aF),NB=kx("Array","keys"),RB=Pp,OB=Wg,MB=Mh,LB=NB,BB=Array.prototype,UB={DOMTokenList:!0,NodeList:!0},VB=function(e){var t=e.keys;return e===BB||MB(BB,e)&&t===BB.keys||OB(UB,RB(e))?LB:t},jB=k(VB),GB={exports:{}},HB=Lf((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),zB=Lf,KB=Ph,JB=$f,QB=HB,qB=Object.isExtensible,YB=zB((function(){qB(1)}))||QB?function(e){return!!KB(e)&&((!QB||"ArrayBuffer"!==JB(e))&&(!qB||qB(e)))}:qB,XB=!Lf((function(){return Object.isExtensible(Object.preventExtensions({}))})),ZB=cp,$B=qf,eU=pv,tU=Ph,rU=Wg,nU=Fm.f,iU=p_,oU=y_,aU=YB,sU=XB,uU=!1,cU=Lg("meta"),lU=0,dU=function(e){nU(e,cU,{value:{objectID:"O"+lU++,weakData:{}}})},fU=GB.exports={enable:function(){fU.enable=function(){},uU=!0;var e=iU.f,t=$B([].splice),r={};r[cU]=1,e(r).length&&(iU.f=function(r){for(var n=e(r),i=0,o=n.length;i1?arguments[1]:undefined);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!u(this,e)}}),FU(o,r?{get:function(e){var t=u(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),UU&&DU(o,"size",{configurable:!0,get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=GU(t),o=GU(n);MU(e,t,(function(e,t){jU(this,{type:n,target:e,state:i(e),kind:t,last:null})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?LU("keys"===t?r.key:"values"===t?r.value:[r.key,r.value],!1):(e.target=null,LU(undefined,!0))}),r?"entries":"values",!r,!0),BU(t)}},zU=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=mU[e],u=s&&s.prototype,c={};if(kU&&IU(s)&&(o||u.forEach&&!vU((function(){(new s).entries().next()})))){var l=(n=t((function(t,r){AU(SU(t,l),{type:e,collection:new s}),TU(r)||yU(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,d=xU(e);EU(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"===e||"set"===e;!(e in u)||o&&"clear"===e||_U(l,e,(function(r,n){var i=d(this).collection;if(!t&&o&&!bU(r))return"get"===e&&undefined;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||wU(l,"size",{configurable:!0,get:function(){return d(this).collection.size}})}else n=r.getConstructor(t,e,i,a),pU.enable();return CU(n,e,!1,!0),c[e]=n,gU({global:!0,forced:!0},c),o||r.setStrong(n,e,i),n};zU("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:undefined)}}),HU);var KU=og,JU=TypeError,QU=function(e){if("object"==_(e)&&"size"in e&&"has"in e&&"add"in e&&"delete"in e&&"keys"in e)return e;throw new JU(KU(e)+" is not a set")},qU=function(e,t){return 1===t?function(t,r){return t[e](r)}:function(t,r,n){return t[e](r,n)}},YU=Oh("Set"),XU=YU.prototype,ZU={Set:YU,add:qU("add",1),has:qU("has",1),remove:qU("delete",1),proto:XU},$U=ch,eV=function(e,t,r){for(var n,i,o=r?e:e.iterator,a=e.next;!(n=$U(a,o)).done;)if((i=t(n.value))!==undefined)return i},tV=eV,rV=function(e,t,r){return r?tV(e.keys(),t,!0):e.forEach(t)},nV=rV,iV=ZU.Set,oV=ZU.add,aV=function(e){var t=new iV;return nV(e,(function(e){oV(t,e)})),t},sV=function(e){return e.size},uV=cg,cV=Mm,lV=ch,dV=rv,fV=function(e){return{iterator:e,next:e.next,done:!1}},hV="Invalid size",gV=RangeError,mV=TypeError,pV=Math.max,vV=function(e,t){this.set=e,this.size=pV(t,0),this.has=uV(e.has),this.keys=uV(e.keys)};vV.prototype={getIterator:function(){return fV(cV(lV(this.keys,this.set)))},includes:function(e){return lV(this.has,this.set,e)}};var _V=function(e){cV(e);var t=+e.size;if(t!=t)throw new mV(hV);var r=dV(t);if(r<0)throw new gV(hV);return new vV(e,r)},yV=QU,SV=aV,IV=sV,bV=_V,TV=rV,CV=eV,wV=ZU.has,EV=ZU.remove,kV=function(){return!1},AV=function(e){var t=yV(this),r=bV(e),n=SV(t);return IV(t)<=r.size?TV(t,(function(e){r.includes(e)&&EV(n,e)})):CV(r.getIterator(),(function(e){wV(t,e)&&EV(n,e)})),n};cp({target:"Set",proto:!0,real:!0,forced:!kV()},{difference:AV});var xV=QU,PV=sV,DV=_V,FV=rV,WV=eV,NV=ZU.Set,RV=ZU.add,OV=ZU.has,MV=function(e){var t=xV(this),r=DV(e),n=new NV;return PV(t)>r.size?WV(r.getIterator(),(function(e){OV(t,e)&&RV(n,e)})):FV(t,(function(e){r.includes(e)&&RV(n,e)})),n};cp({target:"Set",proto:!0,real:!0,forced:!kV()},{intersection:MV});var LV=QU,BV=ZU.has,UV=sV,VV=_V,jV=rV,GV=eV,HV=yT,zV=function(e){var t=LV(this),r=VV(e);if(UV(t)<=r.size)return!1!==jV(t,(function(e){if(r.includes(e))return!1}),!0);var n=r.getIterator();return!1!==GV(n,(function(e){if(BV(t,e))return HV(n,"normal",!1)}))};cp({target:"Set",proto:!0,real:!0,forced:!kV()},{isDisjointFrom:zV});var KV=QU,JV=sV,QV=rV,qV=_V,YV=function(e){var t=KV(this),r=qV(e);return!(JV(t)>r.size)&&!1!==QV(t,(function(e){if(!r.includes(e))return!1}),!0)};cp({target:"Set",proto:!0,real:!0,forced:!kV()},{isSubsetOf:YV});var XV=QU,ZV=ZU.has,$V=sV,ej=_V,tj=eV,rj=yT,nj=function(e){var t=XV(this),r=ej(e);if($V(t)","<":"<"," ":" ",""":'"',"'":"'"},(function(e,t){})),function(e,t){for(var r=XF(e),n=0;n","<":"<"," ":" ",""":'"',"'":"'"},(function(e,t){}));var Dj=function(e){var t=pM||window.webkitURL;/^blob:/.test(e)&&t.revokeObjectURL(e)},Fj=function(){function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"",r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"";fF(this,e),vF(this,"prefix",void 0),vF(this,"postfix",void 0),vF(this,"isDestroyed",!1),vF(this,"uid",Pj()),vF(this,"cacheEvents",void 0),vF(this,"events",void 0),vF(this,"isCached",void 0),this.cacheEvents=[],this.events={},this.isCached=!1,this.prefix=t,this.postfix=r}return pF(e,[{key:"save",value:function(){this.isCached=!0}},{key:"restore",value:function(){var e,t=this;this.isCached=!1,QF(e=this.cacheEvents).call(e,(function(e){var r,n=e.eventName,i=e.param;t.emit.apply(t,iW(r=[n]).call(r,dF(i)))})),this.cacheEvents.length=0}},{key:"destroy",value:function(){var e=this;if(!this.isDestroyed){for(var t in this.events)if(Object.prototype.hasOwnProperty.call(this.events,t)){var r,n=this.events[t];n&&QF(r=vM(n).call(n)).call(r,(function(t){var r=t.name,n=t.fn,i=t.context,o=t.once;e.off(r,n,i,o)}))}this.events={},this.isDestroyed=!0}}},{key:"on",value:function(e,t,r){var n,i=arguments.length>3&&arguments[3]!==undefined&&arguments[3],o=this.events,a={name:e=this.format(e),uid:Pj(),context:r,once:i,fn:t};return o[e]||(o[e]=[]),AM(n=o[e]).call(n,a)<0&&o[e].push(a),a}},{key:"once",value:function(e,t,r){return this.on(e,t,r,!0)}},{key:"emit",value:function(e){for(var t,r,n=this,i=arguments.length,o=new Array(i>1?i-1:0),a=1;a=0;o--){var a=i[o];t&&a.fn!==t||r&&a.context!==r||n&&a.once!==n||qM(i).call(i,o,1)}return!0}},{key:"removeAllEventListeners",value:function(e){if(e){var t,r;e=this.format(e);var n=oL(t=this.cacheEvents).call(t,(function(t){return t.eventName===e}));n>-1&&qM(r=this.cacheEvents).call(r,n,1),this.events[e]&&delete this.events[e]}else this.cacheEvents=[],this.events={}}},{key:"getAllEvents",value:function(){return this.events}},{key:"format",value:function(e){var t,r;return iW(t=iW(r="".concat(this.prefix||"")).call(r,e)).call(t,this.postfix||"")}}],[{key:"create",value:function(t,r){return new e(t,r)}}]),e}(),Wj="default",Nj=function(){function e(){fF(this,e),vF(this,"emitter",new Fj)}return pF(e,[{key:"on",value:function(e){this.emitter.on(Wj,e)}},{key:"emit",value:function(){for(var e,t,r=arguments.length,n=new Array(r),i=0;ir.length&&(t=r.length),qM(r).call(r,t,0,e),0))}},{key:"remove",value:function(e){var t=this.children,r=AM(t).call(t,e);return!(r<0||(qM(t).call(t,r,1),0))}},{key:"clear",value:function(){return this.children=[],!0}},{key:"move",value:function(e,t){if(e===t)return!0;var r=this.children,n=lF(qM(r).call(r,e,1),1)[0];return qM(r).call(r,t,0,n),!0}},{key:"switch",value:function(e,t){if(e===t)return!0;var r=this.children,n=r[e];return r[e]=r[t],r[t]=n,!0}},{key:"reorder",value:function(e){var t=this.children,r=e.length,n=[],i=0;if(t.length!==r||0===r)return!1;for(var o=0;o1&&arguments[1]!==undefined?arguments[1]:[],r=this.getTag(e);return r||(r=new Gj({name:e,children:t}),this.tags.push(r)),r}},{key:"removeTag",value:function(e){var t,r,n=this.getTag(e);if(!n)return!1;this.hooks.beforeRemoveTag.emit(n);var i=oL(t=this.tags).call(t,(function(t){return t.name===e}));return e===this.defaultName&&(this.defaultName=null,this.selectedUid=null),qM(r=this.tags).call(r,i,1),!0}},{key:"renameTag",value:function(e,t){if(!Ej(e)||!Ej(t))return!1;var r=this.isTagExisted(t),n=this.getTag(e);return!(!n||r||(n.name=t,this.hooks.afterRenameTag.emit(n),0))}},{key:"getTag",value:function(e){var t;return AL(t=this.tags).call(t,(function(t){return t.name===e}))}},{key:"getTagByUid",value:function(e){var t;return AL(t=this.tags).call(t,(function(t){return t.uid===e}))}},{key:"getTagList",value:function(){var e;return vM(e=this.tags).call(e)}},{key:"setDefaultTag",value:function(e){if(!e)return this.defaultName=null,this.defaultUid=null,!0;var t=this.getTag(e);return!!t&&(this.defaultName=e,this.defaultUid=t.uid,!0)}},{key:"getDefaultTag",value:function(){return this.defaultName}},{key:"isTagExisted",value:function(e){return!!this.getTag(e)}}]),e}(),zj=function(){function e(){fF(this,e)}return pF(e,[{key:"apply",value:function(e){var t=e.hooks,r={beforeStatus:null,afterStatus:null,operation:null,docUid:null},n=function(e){r.beforeStatus={uids:e.uids,selectedUids:[],currentUid:"",modifiedUid:e.modifiedUid,removedUids:e.removedUids}},i=function(t){r.afterStatus={uids:t.uids,selectedUids:[],currentUid:"",modifiedUid:t.modifiedUid,removedUids:t.removedUids},r.docUid=t.docUid,r.operation=t.operation,r.docType=t.docType,r.docName=t.docName,e.emit("bufferChanged",Ij({},r)),r={beforeStatus:null,afterStatus:null,operation:null,docUid:null}};t.beforeBufferChanged.on(n),t.afterBufferChanged.on(i),t.destroy.on((function(){t.beforeBufferChanged.off(n),t.afterBufferChanged.off(i)}))}}]),e}(),Kj=function(){function e(){fF(this,e)}return pF(e,[{key:"apply",value:function(e){var t=e.hooks;e.customStore=new Mj;var r=function(t){var r=t.data;QF(r).call(r,(function(t){var r=t.customData;r||(r={}),e.customStore.set(t.uid,r)}))},n=function(t){var r=t.removedUids;QF(r).call(r,(function(t){e.customStore.remove(t)}))},i=function(t){var r=t.data.customData;r&&e.customStore.update(t.modifiedUid,r)};t.loadSource.on(r),t.removeSource.on(n),t.updateSource.on(i),t.destroy.on((function(){t.loadSource.off(r),t.removeSource.off(n),t.updateSource.off(i)}))}}]),e}(),Jj=function(e){nP(r,e);var t=bj(r);function r(){var e;return fF(this,r),vF(mx(e=t.call(this,{uid:Pj(),children:[]})),"name","dvs-default"),vF(mx(e),"isDestroyed",!1),vF(mx(e),"type",void 0),e}return pF(r,[{key:"destroy",value:function(){this.isDestroyed||(this.isDestroyed=!0)}}]),r}(Rj),Qj=function(){function e(){fF(this,e)}return pF(e,[{key:"apply",value:function(e){e.defaultFile=new Jj;var t=e.hooks,r=function(t){var r,n,i,o=t.filename,a=t.index,s=t.data;if(Cj(o)){var u=jL(s).call(s,(function(e){return e.uid}));void 0===a?(r=e.defaultFile.children).push.apply(r,dF(u)):qM(n=e.defaultFile.children).apply(n,iW(i=[a,0]).call(i,dF(u)));var c={docUid:e.defaultFile.uid,sourceUids:u,type:"default",index:a};e.hooks.loadToDoc.emit(c)}},n=function(t){var r=t.removedUids,n=[];QF(r).call(r,(function(t){var r=e.statusStore.get(t);r&&r.ownerDefaultFile&&(e.defaultFile.remove(t),n.push(t))})),n.length&&e.hooks.removeFromDoc.emit({docUid:e.defaultFile.uid,sourceUids:r,type:"default"})};t.loadSource.on(r),t.removeSource.on(n),t.destroy.on((function(){t.loadSource.off(r),t.removeSource.off(n)}))}}]),e}(),qj=function(){function e(){fF(this,e)}return pF(e,[{key:"apply",value:function(e){e.dir=new Bj,this.listenDirectoryHooks(e),this.listenSpaceHooks(e)}},{key:"listenDirectoryHooks",value:function(e){var t=e.dir.hooks,r=function(t){var r;QF(r=t.children).call(r,(function(r){var n=e.statusStore.get(r);n&&n.ownerFiles.remove(t.uid)})),e.hooks.removeDoc.emit(t)},n=function(t){e.hooks.renameDoc.emit(t)};t.beforeRemoveFile.on(r),t.afterRenameFile.on(n),t.destroy.on((function(){t.beforeRemoveFile.off(r),t.afterRenameFile.off(n)}))}},{key:"listenSpaceHooks",value:function(e){var t=e.hooks,r=function(t){var r=t.data,n=t.filename,i=t.index;if(!Cj(n)){var o=e.dir.getFile(n);e.hooks.beforeBufferChanged.emit({docType:"file",docUid:null==o?void 0:o.uid,uids:dF((null==o?void 0:o.children)||[]),operation:"add"});var a=jL(r).call(r,(function(e){return e.uid})),s=e.dir.appendChildrenToFile(n,a,i),u={docUid:s.uid,sourceUids:a,type:"file",index:i};e.hooks.loadToDoc.emit(u),e.hooks.afterBufferChanged.emit({docType:"file",docName:n,docUid:null==s?void 0:s.uid,uids:dF((null==s?void 0:s.children)||[]),operation:"add"})}},n=function(t){var r=t.removedUids,n={};QF(r).call(r,(function(t){var r,i,o=e.statusStore.get(t);o&&QF(r=vM(i=o.ownerFiles.children).call(i)).call(r,(function(e){n[e]||(n[e]=[]),n[e].push(t)}))}));for(var i=0,o=vL(n);i-1&&qM(t).call(t,r,1)}},{key:"removeViewer",value:function(e){var t=this.owners,r=AM(t).call(t,e);r>-1&&qM(t).call(t,r,1)}},{key:"setVisible",value:function(e){var t;AM(t=this.visible).call(t,e)<0&&this.visible.push(e)}},{key:"cancelVisible",value:function(e){var t,r,n=AM(t=this.visible).call(t,e);n>-1&&qM(r=this.visible).call(r,n,1)}},{key:"setPreload",value:function(e){var t;AM(t=this.preload).call(t,e)<0&&this.preload.push(e)}},{key:"cancelPreload",value:function(e){var t,r,n=AM(t=this.preload).call(t,e);n>-1&&qM(r=this.preload).call(r,n,1)}},{key:"reset",value:function(){this.minData=null,this.oriData=null,this.img=null,this.activeOri=!1,this.activeMin=!1,this.minTask=null,this.oriTask=null,this.operations=[]}}]),e}(),Zj=function(){function e(){fF(this,e)}return pF(e,[{key:"apply",value:function(e){var t=e.hooks;e.statusStore=new Mj;var r=function(t){var r=t.data;t.filename,t.index,QF(r).call(r,(function(t){var r=new Xj(t);e.statusStore.set(t.uid,r)}))},n=function(t){var r=t.removedUids;QF(r).call(r,(function(t){var r,n,i=e.statusStore.get(t);i&&(Dj(i.minData),Dj(i.oriData),i.ownerFiles.clear(),i.ownerTags.clear(),i.ownerDefaultFile=!1,null!==(r=i.img)&&void 0!==r&&r.src&&(i.img.src=""),null!==(n=i.minImg)&&void 0!==n&&n.src&&(i.minImg.src=""),i.img=null,i.minImg=null),e.statusStore.remove(t)}))},i=function(t){var r=t.modifiedUid,n=t.data,i=t.revoke,o=e.statusStore.get(r);if(o){o.img=null,o.minImg=null;var a=n.metadata;a&&(o.metadata=Ij({},a),o.setRealTimeSize(a.width,a.height)),i&&(Dj(o.oriData),Dj(o.minData)),o.reset(),e.statusStore.update(r,o)}},o=function(t){var r;QF(r=t.children).call(r,(function(r){var n=e.statusStore.get(r);n&&("file"===t.type?n.ownerFiles.remove(t.uid):"tag"===t.type&&n.ownerTags.remove(t.uid))}))},a=function(t){var r=t.docUid,n=t.sourceUids,i=t.type;QF(n).call(n,(function(t){var n=e.statusStore.get(t);n&&("file"===i?n.ownerFiles.append(r):"tag"===i?n.ownerTags.append(r):"default"===i&&(n.ownerDefaultFile=!0))}))},s=function(t){var r=t.docUid,n=t.sourceUids,i=t.type;QF(n).call(n,(function(t){var n=e.statusStore.get(t);n&&("file"===i?n.ownerFiles.remove(r):"tag"===i?n.ownerTags.remove(r):"default"===i&&(n.ownerDefaultFile=!0))}))};t.loadSource.on(r),t.afterRemoveSource.on(n),t.updateSource.on(i),t.removeDoc.on(o),t.loadToDoc.on(a),t.removeFromDoc.on(s),t.destroy.on((function(){t.loadSource.off(r),t.afterRemoveSource.off(n),t.updateSource.off(i),t.removeDoc.off(o),t.loadToDoc.off(a),t.removeFromDoc.off(s)}))}}]),e}(),$j=function(){function e(){fF(this,e)}return pF(e,[{key:"apply",value:function(e){var t=e.hooks;e.store=new Oj("space_db","space_doc");var r=function(t){var r=t.data;r&&QF(r).call(r,(function(t){e.store.set(t.uid,t)}))},n=function(t){var r;QF(r=t.removedUids).call(r,(function(t){e.store.remove(t)}))},i=function(t){e.store.update(t.modifiedUid,t.data)};t.loadSource.on(r),t.removeSource.on(n),t.updateSource.on(i),t.destroy.on((function(){t.loadSource.off(r),t.removeSource.off(n),t.updateSource.off(i)}))}}]),e}(),eG=function(){function e(){fF(this,e)}return pF(e,[{key:"apply",value:function(e){e.tag=new Hj,this.listenSpaceHooks(e),this.listenTagHooks(e)}},{key:"listenTagHooks",value:function(e){var t=e.tag.hooks,r=function(t){var r;QF(r=t.children).call(r,(function(r){var n=e.statusStore.get(r);n&&n.ownerFiles.remove(t.uid)})),e.hooks.removeDoc.emit(t)},n=function(t){e.hooks.renameDoc.emit(t)};t.beforeRemoveTag.on(r),t.afterRenameTag.on(n),t.destroy.on((function(){t.beforeRemoveTag.off(r),t.afterRenameTag.off(n)}))}},{key:"listenSpaceHooks",value:function(e){var t=e.hooks,r=function(t){var r=t.data,n=e.tag.defaultName;QF(r).call(r,(function(e){var t;(e.tags||(e.tags=[]),n)&&(AM(t=e.tags).call(t,n)<0&&e.tags.push(n))}))},n=function(t){var r=t.data;QF(r).call(r,(function(t){var r;null===(r=t.tags)||void 0===r||QF(r).call(r,(function(r){var n=e.tag.getTag(r);e.hooks.beforeBufferChanged.emit({uids:dF((null==n?void 0:n.children)||[]),operation:"add"}),e.tag.appendChildToTag(r,t.uid);var i=e.tag.getTag(r),o={docUid:i.uid,sourceUids:[t.uid],type:"tag"};e.hooks.loadToDoc.emit(o),e.hooks.afterBufferChanged.emit({docType:"tag",docName:r,docUid:null==i?void 0:i.uid,uids:dF((null==i?void 0:i.children)||[]),operation:"add"})}))}))},i=function(t){var r=t.removedUids,n={};QF(r).call(r,(function(t){var r,i,o=e.statusStore.get(t);o&&QF(r=vM(i=o.ownerTags.children).call(i)).call(r,(function(e){n[e]||(n[e]=[]),n[e].push(t)}))}));for(var i=0,o=vL(n);i-1&&qM(a=n.tags).call(a,s,1),r.next=9,e.store.update(t,n);case 9:r.next=14;break;case 11:r.prev=11,r.t0=r["catch"](0);case 14:case"end":return r.stop()}}),r,null,[[0,11]])})));return function(e){return t.apply(this,arguments)}}())}},u=function(t){var r,n,i=e.statusStore.get(t.modifiedUid);i&&QF(r=vM(n=i.ownerTags.children).call(n)).call(r,(function(r){var n=e.tag.getTagByUid(r);n&&(e.hooks.beforeBufferChanged.emit({uids:dF(n.children),modifiedUid:t.modifiedUid,operation:"modify"}),e.hooks.afterBufferChanged.emit({docType:"tag",docName:n.name,docUid:r,uids:dF(n.children),modifiedUid:t.modifiedUid,operation:"modify"}))}))};t.beforeLoadSource.on(r),t.loadSource.on(n),t.removeSource.on(i),t.removeDoc.on(o),t.loadToDoc.on(a),t.removeFromDoc.on(s),t.updateSource.on(u),t.destroy.on((function(){t.beforeLoadSource.off(r),t.loadSource.off(n),t.removeSource.off(i),t.removeDoc.off(o),t.loadToDoc.off(a),t.removeFromDoc.off(s),t.updateSource.off(u)}))}}]),e}(),tG=function(e){nP(r,e);var t=bj(r);function r(){var e;return fF(this,r),vF(mx(e=t.call(this)),"uid",Pj()),vF(mx(e),"hooks",{init:Nj.create(),destroy:Nj.create(),beforeLoadSource:Nj.create(),loadSource:Nj.create(),afterLoadSource:Nj.create(),beforeRemoveSource:Nj.create(),removeSource:Nj.create(),afterRemoveSource:Nj.create(),beforeUpdateSource:Nj.create(),updateSource:Nj.create(),afterUpdateSource:Nj.create(),beforeBufferChanged:Nj.create(),afterBufferChanged:Nj.create(),directoryChanged:Nj.create(),tagChanged:Nj.create(),openDoc:Nj.create(),loadToDoc:Nj.create(),removeFromDoc:Nj.create(),removeDoc:Nj.create(),renameDoc:Nj.create(),move:Nj.create(),afterMove:Nj.create(),"switch":Nj.create(),afterSwitch:Nj.create(),reorder:Nj.create(),afterReorder:Nj.create()}),vF(mx(e),"dir",void 0),vF(mx(e),"tag",void 0),vF(mx(e),"store",void 0),vF(mx(e),"customStore",void 0),vF(mx(e),"metadataStore",void 0),vF(mx(e),"statusStore",void 0),vF(mx(e),"defaultFile",void 0),vF(mx(e),"plugins",[]),vF(mx(e),"imageLoader",void 0),e.initPlugins(),e.hooks.init.emit(),e}return pF(r,[{key:"destroy",value:function(){this.hooks.destroy.emit()}},{key:"initPlugins",value:function(){(new $j).apply(this),(new Zj).apply(this),(new Kj).apply(this),(new Yj).apply(this),(new zj).apply(this),(new Qj).apply(this),(new qj).apply(this),(new eG).apply(this)}},{key:"setImageLoader",value:function(e){this.imageLoader=e}},{key:"getCustomData",value:function(e){return this.customStore.get(e)}},{key:"setCustomData",value:function(e,t){return this.customStore.set(e,t)}},{key:"getMetadata",value:function(e){return this.metadataStore.get(e)}},{key:"setMetadata",value:function(e,t){return this.metadataStore.set(e,t)}},{key:"createStore",value:function(e){var t=e.type,r=void 0===t?"sync":t,n=e.tableName,i=e.dbName;return"sync"===r?new Mj:i&&n?new Oj(i,n):null}},{key:"loadSource",value:function(e,t){if(Cj(e))return[];var r=e.data;if(!Tj(r))return[];var n=[];return QF(r).call(r,(function(e){e.uid=Pj(),n.push(e.uid)})),Aj(t)&&t(n),this.hooks.beforeLoadSource.emit(e),this.hooks.loadSource.emit(e),this.hooks.afterLoadSource.emit(e),n}},{key:"removeSource",value:function(e){var t=!(arguments.length>1&&arguments[1]!==undefined)||arguments[1];Ej(e)&&(e=[e]);var r={removedUids:e,docUid:"",trigger:this.uid,operation:"remove"};return this.hooks.beforeRemoveSource.emit(r),this.hooks.removeSource.emit(r),t&&this.hooks.afterRemoveSource.emit(r),!0}},{key:"updateSource",value:function(e,t){var r={modifiedUid:e,data:t,revoke:!(arguments.length>2&&arguments[2]!==undefined)||arguments[2],operation:"modify"};return this.hooks.beforeUpdateSource.emit(r),this.hooks.updateSource.emit(r),this.hooks.afterUpdateSource.emit(r),!0}},{key:"getSource",value:function(e){return this.store.get(e)}},{key:"openDefault",value:function(e){var t={node:this.defaultFile,type:"default",config:e};this.hooks.openDoc.emit(t)}},{key:"createFile",value:function(e){return this.dir.createFile(e)}},{key:"removeFile",value:function(e){return this.dir.removeFile(e)}},{key:"renameFile",value:function(e,t){return this.dir.renameFile(e,t)}},{key:"openFile",value:function(e,t){var r=this.getFile(e);if(!r)return!1;var n={node:r,type:"file",config:t};return this.hooks.openDoc.emit(n),!0}},{key:"movePagesToFile",value:function(e,t,r,n){var i=this,o=this.getFile(e),a=this.getFile(r);if(!o||!a)return!1;for(var s=0;s=o.children.length)return!1;if(n<0)return!1;var u=jL(t).call(t,(function(e){return o.children[e]}));QF(u).call(u,(function(e){var t=i.statusStore.get(e);t&&t.ownerFiles.remove(o.uid)})),this.dir.removeChildFromFile(o.uid,u),this.hooks.removeFromDoc.emit({docUid:o.uid,sourceUids:u}),n>a.children.length&&(n=a.children.length);var c=this.dir.appendChildrenToFile(r,u,n),l={docUid:c.uid,sourceUids:u,type:"file",index:n,isSameDoc:e===r};return QF(u).call(u,(function(e){var t=i.statusStore.get(e);t&&t.ownerFiles.append(c.uid)})),this.hooks.loadToDoc.emit(l),!0}},{key:"getFile",value:function(e){return this.dir.getFile(e)}},{key:"getFileList",value:function(){return this.dir.getCurrentFileList()}},{key:"isFileExisted",value:function(e){return this.dir.isFileExist(e)}},{key:"createTag",value:function(e){return this.tag.createTag(e)}},{key:"removeTag",value:function(e){for(var t=this.getTag(e).children||[],r=0;r=this.getHowManyImagesInBuffer())return this.setError("IndexOutOfRange"),!1;if(this.webViewer)return this.webViewer.myViewer.getUidByIndex(e);var t=this.getCurrentDataSet().children;return!(t&&t.length=g&&(h=g):h=g,this.isActiveFile&&(this.currentSelected=[h]);var m=this.space.loadSource({data:[{oriData:u,minData:c,metadata:i,customData:o}],filename:s,index:h},(function(t){var r=lF(t,1)[0];e.uuid=r})),p=this.getHowManyImagesInBuffer();return this.isActiveTag&&(this.currentSelected=p>0?[p-1]:[]),m}},{key:"insertImage",value:function(e,t,r){var n;if(r&&r>=0)this.currentSelected=[r],n=this.space.loadSource({data:[e],filename:t,index:r});else{n=this.space.loadSource({data:[e],filename:t});var i=this.getHowManyImagesInBuffer();this.currentSelected=i>0?[i-1]:[]}return n[0]}},{key:"updateImage",value:function(e,t){var r=e.imageUrl,n=e.minImageUrl,i=e.imageId,o=e.serverId,a=e.uidFromServer,s=e.uuid,u=Ij({},t);return s&&""!==s&&-1!==s?(this.space.updateSource(s,{oriData:r,minData:n,metadata:u,customData:{imageId:i,serverId:o,uidFromServer:a}}),s):(this.setError("IndexOutOfRange"),!1)}},{key:"removeImageByUid",value:function(e){if(this.e(),this.webViewer){var t=this.webViewer.removePageByUid(e);return this.webViewer.resized(),this.emitViewerEvent(),t}return this.space.removeSource(e)}},{key:"removeImageByIndex",value:function(e){if(this.e(),e<0||e>=this.getHowManyImagesInBuffer())return this.setError("IndexOutOfRange"),!1;var t=this.getCurrentIndex(),r=!1;if(this.currentSelected=e===t&&0===e?this.getHowManyImagesInBuffer()>0?[0]:[]:e<=t?[t-1]:[t],this.webViewer)r=this.webViewer.removePageByIndexes(e),this.webViewer.resized(),this.emitViewerEvent();else{var n=this.getCurrentDataSet();if(!n)return!1;r=this.space.removeSource(n.children[e])}return r||this.setError("Default"),r}},{key:"removeSelectedImages",value:function(e){this.e();var t=this.getSelectedImagesIndices();Tj(e)&&e.length>0&&(t=e);var r=!1;if(this.webViewer)r=this.webViewer.removePageByIndexes(t),this.webViewer.resized(),this.emitViewerEvent();else{var n=[],i=this.getCurrentDataSet();if(!i)return!1;QF(t).call(t,(function(e){i.children[e]&&i.children[e]&&n.push(i.children[e])})),r=this.space.removeSource(n)}r||this.setError("Default");var o=this.getHowManyImagesInBuffer();return this.currentSelected=o>0?[o-1]:[],r}},{key:"removeImageByIndexArr",value:function(e){if(this.e(),!Tj(e))return!1;var t=this.getCurrentDataSet();if(!t)return!1;var r,n=[];QF(e).call(e,(function(e){var r=t.children[e];r&&n.push(r)})),(r=this.space.removeSource(n))||this.setError("Default"),this.webViewer&&(this.webViewer.resized(),this.emitViewerEvent());var i=this.getHowManyImagesInBuffer();return this.currentSelected=i>0?[i-1]:[],r}},{key:"removeAllImages",value:function(){this.e();var e=!1;if(this.currentSelected=[],this.webViewer)e=this.webViewer.removeAllPages(),this.webViewer.resized(),this.emitViewerEvent();else{var t=this.getCurrentDataSet();t&&(e=this.space.removeSource(dF(t.children)))}return e||this.setError("Default"),e}},{key:"tagImages",value:function(e,t){this.e();var r=this.getHowManyImagesInBuffer();if(!Tj(e))return this.setError("IndicesNotArray"),!1;if(!Ej(t)||""===t)return this.setError("InvalidTagName"),!1;for(var n=0;n=r)return this.setError("IndexOutOfRange"),!1}this.space.createTag(t);for(var o=0;o=0){var s=this.getUidByIndex(a);s&&""!==s&&-1!==FB(s,10)&&this.space.addTagToSource(s,t)}}return!0}},{key:"removeImageTag",value:function(e,t){if(this.e(),!kj(e))return this.setError("InvalidValue"),!1;if(e<0||e>this.getHowManyImagesInBuffer())return this.setError("IndexOutOfRange"),!1;var r=this.getUidByIndex(e),n=!1;return r&&""!==r&&-1!==r&&(n=this.space.removeTagFromSource(r,t)),n||this.setError("Default"),n}},{key:"getDefaultTag",value:function(){return this.space.getDefaultTag()}},{key:"setDefaultTag",value:function(e){if(this.e(),!Ej(e))return this.setError("InvalidValue"),!1;if(""===e)return this.space.setDefaultTag(null),!0;var t;return this.space.createTag(e),(t=this.space.setDefaultTag(e))||this.setError("Default"),t}},{key:"removeTag",value:function(e,t){var r=this;if(this.e(),!Ej(e))return this.setError("InvalidValue"),!1;if(!Cj(t)&&!Tj(t))return this.setError("IndicesNotArray"),!1;if(!this.space.isTagExisted(e))return this.setError("TagNotExist"),!1;var n=this.currentTagName,i=!1,o=!1;if(n&&(i=n===e),Cj(t))o=this.space.removeTag(e),i&&this.clearFilter();else{var a=[];QF(t).call(t,(function(e){var t=r.getUidByIndex(e);-1!==t&&a.push(t)}));for(var s=0;s<(null==a?void 0:a.length);s++)if(!(o=this.space.removeTagFromSource(a[s],e)))return!1}return o||this.webViewer.setDefaultError(),o}},{key:"renameTag",value:function(e,t){if(this.e(),Cj(e)||""===e)return this.setError("OldTagNameRequired"),!1;if(Cj(t)||""===t)return this.setError("NewTagNameRequired"),!1;if(!this.space.isTagExisted(e))return this.setError("TagNotExist"),!1;if(this.space.isTagExisted(t))return this.setError("TagExist"),!1;var r;return e===this.currentTagName&&(this.currentTagName=t),(r=this.space.renameTag(e,t))?this.space.setDefaultTag(t):this.setError("Default"),r}},{key:"getTagContents",value:function(e){return this.e(),e&&Ej(e)&&""!==e?this.space.getTag(e).children:[]}},{key:"getTagList",value:function(){var e=this;this.e();var t=this.space.getTagList(),r=[];return t?QF(t).call(t,(function(t){var n,i=[];QF(n=t.children).call(n,(function(t){var r=e.getCustomDataByUid(t);if(r){var n=r.uidFromServer;i.push(n)}})),r.push({name:t.name,imageIds:i})})):r=[],r}},{key:"getTagListByIndex",value:function(e){if(!kj(e))return!1;var t=this.getUidByIndex(e);return this.space.getSourceTags(t)}},{key:"clearFilter",value:function(){this.e(),this.currentTagName="";var e,t=this.getCurrentFileName();return""===t&&(t="dynamsoft-default-document"),(e=this.openDocument(t))||this.setError("Default"),e}},{key:"filterImagesByTag",value:function(e,t,r){this.e();var n=!1;if(Cj(e)||null===e||""===e){this.currentTagName="";var i=this.getCurrentFileName();""===i&&(i="dynamsoft-default-document"),(n=this.openDocument(i))?Aj(t)&&t():(this.setError("Default"),Aj(r)&&r())}else{var o,a;if(!this.space.isTagExisted(e))return this.setError("TagNotExist"),Aj(r)&&r(),!1;if(this.isActiveTag=!0,this.isActiveFile=!1,this.currentTagName=e,this.setDefaultTag(e),n=this.space.openTag(e,null==this||null===(o=this.webViewer)||void 0===o||null===(a=o.myViewer)||void 0===a?void 0:a.uid)){var s=this.space.getTag(e);if(s){var u,c=(null==s||null===(u=s.children)||void 0===u?void 0:u.length)||0;this.currentSelected=c>0?[c-1]:[]}Aj(t)&&t()}else this.setError("Default"),Aj(r)&&r()}return this.webViewer&&this.webViewer.render(),n}},{key:"createDocument",value:function(e){if(this.e(),!e||""===e){var t=kj(e)?"FileNameNotString":"FileNameCannotEmpty";return this.setError(t),!1}return Ej(e)?this.space.isFileExisted(e)?(this.setError("FileExist"),!1):!!this.space.createFile(e)||(this.setError("Default"),!1):(this.setError("FileNameNotString"),!1)}},{key:"openDocument",value:function(e,t){var r,n;if(this.e(),!e||""===e){var i=kj(e)?"FileNameNotString":"FileNameCannotEmpty";return this.setError(i),!1}if(!Ej(e))return this.setError("FileNameNotString"),!1;if(!this.space.isFileExisted(e))return this.setError("FileNotExist"),!1;var o=t&&""!==t?t:null==this||null===(r=this.webViewer)||void 0===r||null===(n=r.myViewer)||void 0===n?void 0:n.uid,a=this.space.getFile(e);if(a){var s,u=null==a||null===(s=a.children)||void 0===s?void 0:s.length;this.currentSelected=u>0?[u-1]:[]}return this.space.openFile(e,{viewerUid:o})?(this.currentFileName=e,this.isActiveFile=!0,this.isActiveTag=!1,!0):(this.setError("Default"),!1)}},{key:"getDocumentContents",value:function(e){return this.e(),e&&Ej(e)&&""!==e?this.space.getFile(e).children:[]}},{key:"renameDocument",value:function(e,t){return this.e(),Ej(e)&&Ej(t)?(e&&""!==e&&t&&""!==t||this.setError("FileNameCannotEmpty"),this.space.isFileExisted(e)?this.space.isFileExisted(t)?(this.setError("FileExist"),!1):this.space.renameFile(e,t)?(this.currentFileName===e&&(this.currentFileName=t),!0):(this.setError("Default"),!1):(this.setError("FileNotExist"),!1)):(this.setError("FileNameNotString"),!1)}},{key:"removeDocument",value:function(e){if(this.e(),!e||!Ej(e))return this.setError("FileNameNotString"),!1;if(!this.space.isFileExisted(e))return this.setError("FileNotExist"),!1;var t=this.space.removeFile(e);return t?(t&&this.webViewer&&this.webViewer.resized(),this.currentFileName===e&&(this.currentFileName=""),!0):(this.setError("Default"),!1)}},{key:"getDocumentInfoList",value:function(){var e=this;this.e();var t=this.space.getFileList(),r=[];return t?(QF(t).call(t,(function(t){if(t.children){for(var n=[],i=0;i=n)return this.setError("ParameterOutRange"),!1;t=!0}return t?this.currentSelected=e:this.setError("Default"),t}},{key:"selectAllImages",value:function(){this.e();var e=!0;if(this.webViewer)e=this.webViewer.myViewer.selectAll(),this.currentSelected=this.webViewer.getSelectedImagesIndices();else{var t,r=this.getCurrentDataSet();this.currentSelected=WB(jB(t=new Array(r.children.length)).call(t))}return e||this.setError("Default"),e}},{key:"moveImage",value:function(e,t){this.e();var r=FB(e,10),n=FB(t,10);if(ZF(e)||ZF(t))return this.setError("InvalidIndex"),!1;var i=this.getHowManyImagesInBuffer();if(r<0||r>=i||n<0||n>i)return this.setError("IndexOutOfRange"),!1;var o=!1;if(this.webViewer)o=this.webViewer.myViewer.movePage(e,t);else{var a=this.getCurrentDataSet();if(!a)return!1;a.children.length>t&&(this.currentSelected=[t]),o=this.space.move({docUid:a.uid,type:a.type,from:e,to:t})}return o||this.setError("Default"),o}},{key:"switchImage",value:function(e,t){this.e();var r=FB(e,10),n=FB(t,10);if(ZF(e)||ZF(t))return this.setError("InvalidIndex"),!1;var i=this.getHowManyImagesInBuffer(),o=this.getCurrentIndex();if(r<0||r>=i||n<0||n>i)return this.setError("IndexOutOfRange"),!1;var a=!1;if(this.webViewer)a=this.webViewer.myViewer.switchPage(e,t);else{var s=this.getCurrentDataSet();if(!s)return!1;a=this.space["switch"]({docUid:s.uid,type:s.type,one:e,other:t})}a||this.setError("Default");var u=o;return r===o?u=n:n===o&&(u=r),this.currentSelected=[u],a}},{key:"moveImageToFile",value:function(e,t,r,n){if(!this.space.isFileExisted(e)||!this.space.isFileExisted(r))return this.setError("FileNotExist"),!1;t=dF(new _j(t));var i=this.getDocumentInfo(e).length;if(!Tj(t)||t.length>i)return this.setError("ParameterOutRange"),!1;var o=this.getDocumentInfo(r).length,a=this.space.movePagesToFile(e,t,r,n);if(!this.webViewer&&this.isActiveFile){var s=this.getHowManyImagesInBuffer();e===this.currentFileName&&(this.currentSelected=s>0?[s-1]:[]),r===this.currentFileName&&(kj(n)&&n=0?this.currentSelected=[n+t.length-1]:this.currentSelected=s>0?[s-1]:[])}return a}}]),e}();HTMLCanvasElement.prototype.toBlob||yj(HTMLCanvasElement.prototype,"toBlob",{value:function(e,t,r){for(var n=atob(this.toDataURL(t,r).split(",")[1]),i=n.length,o=new Uint8Array(i),a=0;a0&&n.controlHeight&&n.controlHeight>0?rr.navInfoSync.bMobile?Il.getImageUrl(this._baseUrl,l,Math.round(n.controlWidth*devicePixelRatio),Math.round(n.controlHeight*devicePixelRatio),c):Il.getImageUrl(this._baseUrl,l,parseInt(n.controlWidth),parseInt(n.controlHeight),c):s},u=n.currentFileName.length>0?this._buffer.addImage(o,n,n.currentFileName):this._buffer.addImage(o,n)){var f=p(u,1)[0],h=this._buffer.getCustomDataByUid(f);return h.serverId=l,h.uidFromServer=d,this._innerInsertModel(l,d,f,s,a),f}return!1}},{key:"insertBefore",value:function(e,t,r,n,i){var o,a,s,u=Date.now(),c=r,l=n;o={index:e,imageId:c,serverId:c,uidFromServer:l,imageUrl:s=Il.getImageUrl(this._baseUrl,c,-1,-1,u),minImageUrl:a=i&&i.controlWidth&&i.controlWidth>0&&i.controlHeight&&i.controlHeight>0?rr.navInfoSync.bMobile?Il.getImageUrl(this._baseUrl,c,Math.round(i.controlWidth*devicePixelRatio),Math.round(i.controlHeight*devicePixelRatio),u):Il.getImageUrl(this._baseUrl,c,parseInt(i.controlWidth),parseInt(i.controlHeight),u):s};var d=this._buffer.addImage(o);if(d){var f=p(d,1)[0],h=this._buffer.getCustomDataByUid(f);return h.serverId=c,h.uidFromServer=l,this._innerInsertModel(c,l,f,s,a),this._buffer.openDocument(this.getCurrentFileName()),f}return!1}},{key:"_innerInsertModel",value:function(e,t,r,n,i){var o=new Rf;o.serverId=e,o.uidFromServer=t,o.uuid=r,o.imageUrl=n,o.minImageUrl=i,this._serverIdMap[e]=o,this._uidMap[t]=o}},{key:"refresh",value:function(e,t,r,n){var i=1*e;if(r){var o=this.count();if(i<0||i>o)return!1;this._setDataImageControl(i,n)}return!0}},{key:"refreshByImageId",value:function(e,t,r){var n=e;return t&&this._setDataImageControl(n,r,!0),!0}},{key:"_setDataImageControl",value:function(e,t,r){var n,i,o,a,s,u,c=this,l=c._baseUrl;if(r)s=e;else if(s=(a=c.getCustomDataByIndex(e)).serverId,u=a.uidFromServer,s<=0)return!1;if((n=c.getImageIdMap(s))||((n=new Rf).serverId=s,n.uidFromServer=u,c._serverIdMap[s]=n,c._uidMap[u]=n),l){null!=n&&(n.ticks=Date.now()),i=Il.getImageUrl(l,s,-1,-1,n.ticks),o=t&&t.controlWidth&&t.controlWidth>0&&t.controlHeight&&t.controlHeight>0?rr.navInfoSync.bMobile?Il.getImageUrl(l,s,Math.round(t.controlWidth*devicePixelRatio),Math.round(t.controlHeight*devicePixelRatio),n.ticks):Il.getImageUrl(l,s,parseInt(t.controlWidth),parseInt(t.controlHeight),n.ticks):i,n.imageUrl=i,n.minImageUrl=o,t&&(t.height&&(n.height=t.height),t.width&&(n.width=t.width));var d=Zt.clone(n);d.imageId=s,c._buffer.updateImage(d,t)}return!0}},{key:"convertIndicesToServerIds",value:function(e){var t,r=e.length,n=[];for(t=0;t=r.count())&&void i.push(a))})),i.length>0&&r._buffer.removeImageByIndexArr(i)}},{key:"removeByServerId",value:function(e,t,r){var n=this,i=null!=r?r:this._buffer.getCurrentDocument();n._removeMapModelImageControlByServerId(e);var o=-1;return o=this._buffer.isActiveFile?this._convertServerIdToIndexInFile(i,e):t,!isNaN(o)&&(!(o<0||o>=n.count())&&n._buffer.removeImageByIndex(o))}},{key:"exists",value:function(e){if(this._serverIdMap[e])return!0;var t=-1;if(this._buffer.isActiveFile){var r=this.getCurrentFileName();t=this._convertServerIdToIndexInFile(r,e)}else t=this._convertServerIdToIndex(e);return t>-1}},{key:"removeImages",value:function(e){var t,r,n;for(n=e.length,t=0;t0){var t,r,n;if((n=this._serverIdMap[e])&&(r=n.uidFromServer))return r;if((t=this.convertServerIdToClientIndex(e))>=0)return this._index2uidFromServer(t)}return-1}},{key:"_uidFromServer2ServerId",value:function(e){if(e){var t,r,n;if((n=this._uidMap[e])&&(r=n.serverId))return r;if((t=this._uidFromServer2index(e))>=0)return this.convertClientIndexToServerId(t)}return-1}},{key:"_index2uidFromServer",value:function(e){var t=this.getCustomDataByIndex(e);return t?t.uidFromServer:-1}},{key:"convertServerIdToClientIndex",value:function(e){var t,r,n,i=this;if((n=i._serverIdMap[e])&&(r=n.uuid),r&&-1!=r)t=i._buffer.getIndexByUid(r);else if(i._buffer.isActiveFile){var o=this.getCurrentFileName();t=this._convertServerIdToIndexInFile(o,e)}else t=this._convertServerIdToIndex(e);return Zt.isNumber(t)||(t=-1),t}},{key:"getIndexByUid",value:function(e){var t;return!1===(t=this._buffer.getIndexByUid(e))?-1:t}},{key:"getUidByIndex",value:function(e){return this._buffer.getUidByIndex(e)}},{key:"convertClientIndexToServerId",value:function(e){var t=this.getCustomDataByIndex(e);return t?t.serverId:-1}},{key:"getCurrentImageIndex",value:function(){var e=this._buffer.getCurrentIndex();return Zt.isBoolean(e)?-1:e}},{key:"setCurrentImageIndex",value:function(e){return this._buffer.selectImages([e])}},{key:"getCurrentFileName",value:function(){return this._buffer.getCurrentFileName()}},{key:"setDefaultTag",value:function(e){return this._buffer.setDefaultTag(e)}},{key:"getDefaultTag",value:function(){return this._buffer.getDefaultTag()}},{key:"count",value:function(){return this._buffer.getHowManyImagesInBuffer()}},{key:"getCountByDocumentName",value:function(e){return this._buffer.getDocumentInfo(e).length}},{key:"dispose",value:function(){this.clear()}},{key:"getImageData",value:function(e){var t=this._buffer.getUidByIndex(e);return t?this._buffer.getDataByUid(t):Qt.Promise.resolve(null)}},{key:"getCustomDataByIndex",value:function(e){return this._buffer.getCustomDataByUid(this._buffer.getUidByIndex(e))}},{key:"getMetadataByIndex",value:function(e){return this._buffer.getMetadataByUid(this._buffer.getUidByIndex(e))}},{key:"setCustomData",value:function(e,t){var r=this._buffer.getUidByIndex(e);return!(!r||!t)&&this._buffer.setCustomDataByUid(r,t)}},{key:"openDocument",value:function(e){return this._buffer.openDocument(e)}},{key:"createDocument",value:function(e){return this._buffer.createDocument(e)}},{key:"getImageIdMap",value:function(e){return this._serverIdMap[e]}},{key:"_removeMapModelImageControlByServerId",value:function(e){var t=this;if(e>0&&t._serverIdMap[e]){var r=t._serverIdMap[e],n=r.uidFromServer;r.Clear(),delete t._serverIdMap[e],delete t._uidMap[n]}}},{key:"_convertServerIdToIndexInFile",value:function(e,t){var r,n,i=-1;for(r=this._buffer.getDocumentContents(e),n=0;n=0&&(t=n._imageBufferWrapper.getCustomDataByIndex(r.curIndex))&&t.serverId&&(o=n._imageBufferWrapper._serverId2uidFromServer(t.serverId)),r.currentId=o,"modify"==r.operation&&""!=r.afterStatus.modifiedUid){var u=n._imageBufferWrapper.getIndexByUid(r.afterStatus.modifiedUid);u>=0&&(t=n._imageBufferWrapper.getCustomDataByIndex(u))&&t.serverId&&(r.modifiedId=n._imageBufferWrapper._serverId2uidFromServer(t.serverId))}if(r.afterStatus.selectedUids)for(var c=0;c=0&&(t=n._imageBufferWrapper.getCustomDataByIndex(d))&&t.serverId&&a.push(n._imageBufferWrapper._serverId2uidFromServer(t.serverId))}}r.selectedIds=a,Zt.mix(r,{}),delete r.uids,delete r.currentUid,delete r.selectedUids,delete r.afterStatus,delete r.beforeStatus,delete r.operation,delete r.curIndex,delete r.docUid;try{return n.__OnBufferChanged(r)}catch(f){_o(f)}}})),r._imageBufferWrapper.on("error",(function(e){n._errorCode=e.code,n._errorString=e.message}));var a=nf.getServerImageUrlPrefix(r);return iG._setBaseUrl(r._imageBufferWrapper,a),r}return f(t,e),s(t,[{key:"_OnActiveUIClearBuffer",value:function(){var e=this.__OnBufferChanged;this.__OnBufferChanged=null,this._imageBufferWrapper.clear(),this.__OnBufferChanged=e}},{key:"_registerMultiEvent",value:function(e,t){var r=this;if(r._resetErr(),!r._isValid())return!1;var n=["_$",e].join("");r[n]||(r[n]={});var i=r[n],o=Zt.guid();return i[o]=t,o}},{key:"_unregisterMultiEvent",value:function(e,t){var r=this;if(r._resetErr(),!r._isValid())return!1;var n=["_$",e].join(""),i=r[n];if(t){var o;if(Zt.isString(t))return delete i[t],fi;if(Zt.isFunction(t))for(o=0;o5&&(v=e[5]),Zt.isArray(v)||(v=[]);else{var _={};if(e.length>5&&(_.width=e[5]),e.length>6&&(_.height=e[6]),e.length>7&&(_.bitDepth=e[7]),e.length>8&&(_.resolutionX=e[8]),e.length>9&&(_.resolutionY=e[9]),e.length>10&&(m=e[10]),e.length>11&&Zt.isString(e[11])&&(_.uidFromServer=e[11]),v.push(_),m>-1&&a._canConsume()&&(f==pf.enumBCAppend||f==pf.enumBCInsert)){var y=rr.DWT.lgct(m);Zt.isFunction(a.__OnLtsverify)&&a.__OnLtsverify(y,1)}}if(Zt.log("OnBitmapChanged:"+e),f==pf.enumBCInsert||f==pf.enumBCAppend&&!a.__IfAppendImage||r&&f==pf.enumBCAppend&&r.index>=0)Zt.each(d,(function(e,t){var i,o,s=parseInt(e),u=a._imageBufferWrapper.getCurrentImageIndex();if(t-1&&(u=a.__insertingIndex),o.controlWidth=400,o.controlHeight=400,a._controlWidth&&a._controlWidth>400&&(o.controlWidth=a._controlWidth),a._controlHeight&&a._controlHeight>400&&(o.controlHeight=a._controlHeight),-1==u&&(u=0),r.index>=0&&(u=r.index),a._imageBufferWrapper.insertBefore(u,g,s,i,o),a.__insertingIndex>-1&&(a.__insertingIndex=a.__insertingIndex+1),r.index++})),Zt.isFunction(a.__OnRefreshUI)&&a.__OnRefreshUI(a._imageBufferWrapper.getCurrentImageIndex(),a._imageBufferWrapper.count());else if(f==pf.enumBCAppend&&a.__IfAppendImage)Zt.each(d,(function(e,t){var r,i,o=parseInt(e);if(isNaN(o)||o<0)return!0;if(t400&&(i.controlWidth=a._controlWidth),a._controlHeight&&a._controlHeight>400&&(i.controlHeight=a._controlHeight),p?a._imageBufferWrapper.append(g,o,r,i,n):a._imageBufferWrapper.append(g,o,r,i)})),Zt.isFunction(a.__OnRefreshUI)&&a.__OnRefreshUI(a._imageBufferWrapper.getCurrentImageIndex(),a._imageBufferWrapper.count());else if(f==pf.enumBCRemove&&l){var S=!1;if(1==d.length&&-1==d[0]&&(S=!0),S)a._imageBufferWrapper.clear();else{var I=[];Zt.each(d,(function(e,t){var r=parseInt(e);if(isNaN(r)||r<0)return!0;I.push(r)})),a._imageBufferWrapper.removeImagesByServerId(I,n)}Zt.isFunction(a.__OnRefreshUI)&&a.__OnRefreshUI(a._imageBufferWrapper.getCurrentImageIndex(),a._imageBufferWrapper.count())}else if(f==pf.enumBCEdit||f==pf.enumBCUpdate)Zt.each(d,(function(e,t){var i,o=parseInt(e);if(isNaN(o)||o<0)return!0;if(t=0&&!a.__bLoadingImage){var s=a._imageBufferWrapper.convertServerIdToClientIndex(o);s>-1?a._innerRefreshUI(s,a._imageBufferWrapper.count(),!0,i,f):r.bNeedRefresh&&a._innerRefreshUIByImageId(o,!0,i,f)}}));else if(f==pf.enumBCIndexChange){var b;if(h>=0&&!a.__bLoadingImage)(b=0-1&&T.push(t)}));var C=a._imageBufferWrapper.getCurrentImageIndex(),w=f;f==pf.enumBCAppend&&(w=a.__IfAppendImage?pf.enumBCAppend:pf.enumBCInsert),a.__OnBitmapChanged(T,w,C,a._imageBufferWrapper.count())}}},{key:"_removeImageAsync",value:(a=n(g().mark((function u(e,t){var r,n,i;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this,n=parseInt(t),xf(r,n)){e.next=4;break}return e.abrupt("return",!1);case 4:return i=r._imageBufferWrapper.convertClientIndexToServerId(n),e.next=7,r._removeImageByIdAsync(i);case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),u,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"_removeImageByIdAsync",value:(r=n(g().mark((function c(e){var t,r;return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this,-1!=e){n.next=4;break}return Oa(t),n.abrupt("return",!1);case 4:return n.next=6,t._innerFunV2("RemoveImage",El(e));case 6:return((r=n.sent)||-1033==t._errorCode)&&t._OnBitmapChanged(["c1",""+e,3,t._imageBufferWrapper.getCurrentImageIndex(),t._imageBufferWrapper.count()]),n.abrupt("return",r);case 9:case"end":return n.stop()}}),c,this)}))),function(e){return r.apply(this,arguments)})}]);var r,a}(nf),aG=function(e){return e.Text=0,e.Blob=1,e.ArrayBuffer=2,e.XML=3,e.JSON=4,e.UserDefined=5,e}({}),sG=function(e){return e.Other=0,e.HTTPUpload=1,e.HTTPDownload=2,e.FTPUpload=3,e.FTPDownload=4,e.Scan=5,e.LoadImage=6,e.ConvertToBlob=7,e.HTTPPut=8,e}({}),uG={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function cG(e,t){if(Zt.isFunction("_".repeat))return e.repeat(t);for(var r=0,n=[];r=0),o.type){case"b":r=parseInt(r,10).toString(2);break;case"c":r=String.fromCharCode(parseInt(r,10));break;case"d":case"i":r=parseInt(r,10);break;case"j":r=Zt.stringify(r,null,o.width?parseInt(o.width):0);break;case"e":r=o.precision?parseFloat(r).toExponential(o.precision):parseFloat(r).toExponential();break;case"f":r=o.precision?parseFloat(r).toFixed(o.precision):parseFloat(r);break;case"g":r=o.precision?String(Number(r.toPrecision(o.precision))):parseFloat(r);break;case"o":r=(parseInt(r,10)>>>0).toString(8);break;case"s":r=String(r),r=o.precision?r.substring(0,o.precision):r;break;case"t":r=String(!!r),r=o.precision?r.substring(0,o.precision):r;break;case"T":r=Object.prototype.toString.call(r).slice(8,-1).toLowerCase(),r=o.precision?r.substring(0,o.precision):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=o.precision?r.substring(0,o.precision):r;break;case"x":r=(parseInt(r,10)>>>0).toString(16);break;case"X":r=(parseInt(r,10)>>>0).toString(16).toUpperCase()}uG.json.test(o.type)?h+=r:(!uG.number.test(o.type)||c&&!o.sign?l="":(l=c?"+":"-",r=r.toString().replace(uG.sign,"")),s=o.pad_char?"0"===o.pad_char?"0":o.pad_char.charAt(1):" ",u=o.width-(l+r).length,a=o.width&&u>0?cG(s,u):"",h+=o.align?l+r+a:"0"===s?l+a+r:a+l+r)}return h}(function(e){if(lG[e])return lG[e];for(var t,r=e,n=[],i=0;r;){if(null!==(t=uG.text.exec(r)))n.push(t[0]);else if(null!==(t=uG.modulo.exec(r)))n.push("%");else{if(null===(t=uG.placeholder.exec(r)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){i|=1;var o=[],a=t[2],s=[];if(null===(s=uG.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(s[1]);""!==(a=a.substring(s[0].length));)if(null!==(s=uG.key_access.exec(a)))o.push(s[1]);else{if(null===(s=uG.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(s[1])}t[2]=o}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}r=r.substring(t[0].length)}return lG[e]=n,n}(e),arguments)}function fG(e,t){if(Zt.isString(e)){var r,n,i,o,a,s=e.indexOf("<%");if(-1==s)return e;if(n=e.substring(0,s),!(s+2<(r=e.indexOf(">",n))))return e;i=e.substring(s+1,r),o=e.substring(r+1);try{a=dG(i,t)}catch(Jj){a=""}return[n,a,o].join("")}return""}function hG(e,t){var r,n=e.substring(e.lastIndexOf(".")).toLowerCase();if(t==rr.DWT.EnumDWT_ImageType.IT_BMP){if(".bmp"==n||".dib"==n)return e;r=[e,".bmp"].join("")}else if(t==rr.DWT.EnumDWT_ImageType.IT_JPG){if(".jpg"==n||".jpe"==n||".jpeg"==n||".jfif"==n)return e;r=[e,".jpg"].join("")}else if(t==rr.DWT.EnumDWT_ImageType.IT_PNG){if(".png"==n)return e;r=[e,".png"].join("")}else if(t==rr.DWT.EnumDWT_ImageType.IT_TIF){if(".tif"==n||".tiff"==n)return e;r=[e,".tif"].join("")}else if(t==rr.DWT.EnumDWT_ImageType.IT_PDF){if(".pdf"==n)return e;r=[e,".pdf"].join("")}else if(t==rr.DWT.EnumDWT_ImageType.IT_J2K){if(".jp2"==n)return e;r=[e,".jp2"].join("")}return r}function gG(e,t,r,n){var i,o,a,s,u=t.url,c=t.headers,l=t.retry,d=t.httpFormData,f=t.bOnlyResponseEmptyIsOK,h=t.bAsync,g=(o=t.responseType)==aG.Text?"text":o==aG.JSON?"json":o==aG.Blob?"blob":o==aG.ArrayBuffer?"arraybuffer":o==aG.XML?"xml":5==o?"user-defined":"text",m=e.IfShowProgressBar,p=e.IfShowCancelDialogWhenImageTransfer,v=e.objUploadStatus;(i=t.content)&&(i.remoteFilename||(i.remoteFilename=t.remoteFilename),i.fileName||(i.fileName=t.fileName||i.name),i.name||(i.name=t.fileName||i.fileName));var _,y=new nl({action:u,data:d,async:h,retry:l,bOnlyResponseEmptyIsOK:f,dataType:g});if(p&&Qt.progressContext&&(_=Qt.progressContext.on("cancel",(function(){y.abort(),y=null}))),(a=y._uploadType)&&(s=a.get("ajaxConfig"),c&&s&&s.headers&&c&&Zt.mix(s.headers,c),e.HTTPRequestswithCredentials&&Zt.mix(s.xhrFields,{withCredentials:!0}),s=null),y.on(nl.event.SUCCESS,(function(n){if(t.content=null,y=null,_&&Qt.progressContext.off("cancel",_),n?e.HTTPPostResponse=n.response:t.responseType==aG.ArrayBuffer?e.HTTPPostResponse=[]:t.responseType==aG.Blob?e.HTTPPostResponse=new Blob([]):t.responseType==aG.JSON?e.HTTPPostResponse={}:e.HTTPPostResponse="",Zt.isFunction(e.onHttpUploadStatus)){var i;i={fileName:n.name,percentage:100,statusCode:200,responseString:e.HTTPPostResponse},e.onHttpUploadStatus(i)}Zt.isFunction(r)&&r(e.HTTPPostResponse)})),y.on(nl.event.ERROR,(function(r){t.content=null,y=null;var i=r&&r.canceled;r&&r.timeout;var o="",a=0;_&&Qt.progressContext.off("cancel",_),r&&Zt.isString(r.response)?e.HTTPPostResponse=r.response:e.HTTPPostResponse="",i||(r&&r.msg&&(o=r.msg),r&&r.httpStatus&&(a=r.httpStatus));var s,u={};(ya(u,i,o,a),Zt.isFunction(e.onHttpUploadStatus))&&(s={fileName:r.name,percentage:100,statusCode:a,responseString:e.HTTPPostResponse},e.onHttpUploadStatus(s));Zt.isFunction(n)&&n(u._errorCode,u._errorString,e.HTTPPostResponse,a)})),(m||Zt.isFunction(e.onHttpUploadStatus))&&(y.on(nl.event.PROGRESS,(function(t){!de.bSafari&&t&&(delete t.totalSize,delete t.position);var r=0===t.total?100:Math.round(100*t.loaded/t.total);if([t.loaded," / ",t.total].join(""),Zt.isFunction(e.onHttpUploadStatus)){var n;n={fileName:t.name,percentage:r,statusCode:0,responseString:""},e.onHttpUploadStatus(n)}e.onPercent([0,r,"","http",t.name])})),e.onPercent([0,-1,ul.Uploading,"http"]),Zt.isFunction(e.onHttpUploadStatus))){var S="";Zt.isArray(i)&&i.length>0||(i&&i.name&&""!=i.name?S=i.name:i&&i.fileName&&(S=i.fileName)),!S&&t.fileName&&(S=t.fileName),e.onHttpUploadStatus({fileName:S,percentage:0,statusCode:0,responseString:""})}if(v&&v.bCancel){v.st=2;var I={};return as(I),t.content=null,Zt.isFunction(n)&&n(I._errorCode,I._errorString),!1}var b=y.upload(i);return i=null,b}function mG(e,t,r,n){var i,o,a=e.MaxUploadImageSize,s=0,u=t.content;if(!u||!Zt.isArray(u)||u.length<=0){t.content=null;var c={};return Ta(c),Zt.isFunction(n)&&n(c._errorCode,c._errorString),di}for(i=0;ia&&-1!=a){var v={};return wa(v),Zt.isFunction(n)&&n(v._errorCode,v._errorString),di}for(Qt.cancelFrom=sG.HTTPUpload,o=gG(e,t,r,n),t=null,i=0;i0){var g;if(u>=o&&o>0?(u-=o,c=o):(c=u,u=0),!(g=0==l&&c==a?s:s.slice(l,l+c))){var m={};Ta(m),f(m._errorCode,m._errorString)}if(!e.IfShowProgressBar||e.IfShowProgressBar&&Qt.dlgRef>0){g.name=i,pG(e.IfShowCancelDialogWhenImageTransfer),t.headers["Content-Range"]=["bytes ",l,"-",l+g.size-1,"/",a].join(""),d._onProgress(e,i,{total:a,loaded:l});var p=Zt.clone(t);return p.content=g,p.offset=0,d.httpPostUpload(e,p,(function(n){0==u&&(Qt.needShowTwiceShowDialog=!1),d._onProgress(e,i,{total:a,loaded:l+c}),0==u?(t.content=null,Zt.isFunction(r)&&Ff(r,n)):(t.offset=t.offset+c,setTimeout((function(){d._uploadBlobFragment(e,t,r,f)}),100))}),f),!0}var v={};return as(v),f(v._errorCode,v._errorString),!1}return Qt.needShowTwiceShowDialog=!1,t.content=null,Zt.isFunction(r)&&r(""),!0}},{key:"httpPostUploadFragment",value:function(e,t,r,n){var i;if(!(i=t.content)){var o={};return Ta(o),Zt.isFunction(n)&&n(o._errorCode,o._errorString),di}if(Zt.isString(i)){if(""==i){var a={};return Ta(a),Zt.isFunction(n)&&n(a._errorCode,a._errorString),di}var s=new Blob([i],{type:"text/plain"}),u=t.fileName;s.name=u,t.content=s,s=null}return Qt.cancelFrom=sG.HTTPUpload,this._uploadBlobFragment(e,t,r,n)}},{key:"httpPostUpload",value:function(e,t,r,n){var i,o,a=t.bAsync,s=function(e,r,i,o){return t.content=null,t=null,Zt.isFunction(n)&&n(e,r,i,o),!1};if(!(i=t.content)){var u={};return Ta(u),s(u._errorCode,u._errorString),!!a&&void 0}if(Zt.isString(i)){var c,l=t.fileName;if(""==i){var d={};return Ta(d),s(d._errorCode,d._errorString),!!a&&void 0}if(c=e.MaxUploadImageSize,i.length>c&&-1!=c){var f={};return wa(f),s(f._errorCode,f._errorString),!!a&&void 0}(o=new Blob([i],{type:"text/plain"})).name=l,i=null}else if(i instanceof Blob&&(o=i,i=null,o.size<=0)){var h={};return Ta(h),s(h._errorCode,h._errorString),!!a&&void 0}if(o){var g,m,p=e.MaxUploadImageSize,v=o.size,_=o.type;if(v>p&&-1!=p){var y={};return wa(y),s(y._errorCode,y._errorString),!!a&&void 0}if(""===_||_&&_!=t.contentType)(g=(o.slice||o.webkitSlice||o.mozSlice).call(o,0,v,t.contentType))instanceof File?(m=g.fileName,g.name=m):g.name=o.name||o.fileName;else g=o;o=null,g&&(t.content=g),g=null}pG(e.IfShowCancelDialogWhenImageTransfer),Qt.cancelFrom=sG.HTTPUpload;var S=gG(e,t,(function(e){return t.content=null,t=null,Zt.isFunction(r)&&r(e),e=null,!0}),s);return a?void 0:!!S}}])}(),_G=s((function JJ(){o(this,JJ),this.method="",this.httpMethod="POST",this.contentType="application/octet-stream",this.remoteFilename="RemoteFile",this.blockSize=0,this.offset=0,this.retry=0,this.bOnlyResponseEmptyIsOK=!0,this.bAsync=!0,this.responseType=aG.Text})),yG=s((function QJ(){o(this,QJ),this.IfShowProgressBar=!1,this.IfShowCancelDialogWhenImageTransfer=!0})),SG=function(e){return e.URL=0,e.Blob=1,e.Base64=2,e}({}),IG=window.SparkMD5,bG=function(){return s((function e(t,r,n,i){o(this,e);var a=this;a._md5=n,a._length=r,a._content=i}),[{key:"getLength",value:function(){return this._length}},{key:"getMD5",value:function(){return this._md5}},{key:"getData",value:function(e,t){var r=this,n=t;return Zt.isNumber(e)&&Zt.isNumber(t)?e<0||t<=0?"":0==e&&n==r._length?r._content:(e+n>r._length&&(n=r._length-e),r._content.substr(e,n)):""}}])}();Qt.html5.Base64Result=bG;var TG=function(e){function t(e){var r;return o(this,t),(r=i(this,t,[e])).__maxUploadImageSize=-1,r._strHttpContentTypeFieldValue="application/octet-stream",r}return f(t,e),s(t,[{key:"_saveBlob",value:(k=n(g().mark((function A(e,t){var r,n;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(r=this,!rr.navInfo.bIE){i.next=7;break}return i.next=5,r._innerSaveLocal(e,t);case 5:i.next=11;break;case 7:return n=URL.createObjectURL(e),i.next=10,r._innerSaveLocal(n,t);case 10:URL.revokeObjectURL(n);case 11:e=null;case 12:case"end":return i.stop()}}),A,this)}))),function(e,t){return k.apply(this,arguments)})},{key:"_saveImages",value:(E=n(g().mark((function x(e,t,r,n){var i,o,a,s,u,c;return g().wrap((function(l){for(;;)switch(l.prev=l.next){case 0:return i=this,o=hG(t,n),a=Df(i,r),Qt.cancelFrom=sG.Other,l.next=5,i._innerConvertToArrayBufferWithUIAsync(e,n,a);case 5:return s=l.sent,u=bf.getBlobTypeByImageType(n),c=new Blob([s],{type:u}),l.next=10,i._saveBlob(c,o);case 10:c=null;case 11:case"end":return l.stop()}}),x,this)}))),function(e,t,r,n){return E.apply(this,arguments)})},{key:"_innerSaveLocal",value:(w=n(g().mark((function P(e,t){return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",new Qt.Promise((function(r,n){var i=window,o=rr.navInfo,a=i.requestFileSystem||i.webkitRequestFileSystem||i.mozRequestFileSystem;if(!o.biPad&&!o.biPhone||a||!(de.bSafari&&parseFloat(de.strBrowserVersion)<13)&&de.bSafari){var s=document.createElementNS("http://www.w3.org/1999/xhtml","a");if(s.href=e,s.download=t,s.target="_blank",document.body.appendChild(s),o.bEdge)s.click(),e=null,s.href=null;else if(o.bIE){var u;(u=window.navigator)&&"msSaveOrOpenBlob"in u&&u.msSaveOrOpenBlob(e,t)}else{var c=document.createEvent("MouseEvents");c.initMouseEvent("click",!0,!1),s.dispatchEvent(c)}setTimeout((function(){document.body.removeChild(s),s=null,r()}),6e3)}else{var l=i.open(e,"","",!1);setTimeout((function(){l.document.title=t,r()}),6e3)}})));case 1:case"end":return r.stop()}}),P)}))),function(e,t){return w.apply(this,arguments)})},{key:"_OnPostTransferAsync",value:function(e,t,r){var n,i=this;if(e&&e.length>=2)try{var o=String(e[1]).replace(/\\/g,"\\\\");n=Zt.parse(o),!r&&n.imageId&&(n.imageId=i._serverId2uidFromServer(n.imageId))}catch(s){Zt.log(e)}n||(n={imageId:""});var a=!1;if(Zt.isFunction(i.__OnPostTransferAsync))try{a=i.__OnPostTransferAsync(n)}catch(u){_o(u)}if(Zt.isFunction(i.__OnPostTransferAsync2))try{i.__OnPostTransferAsync2(n)}catch(u){_o(u)}return a}},{key:"_checkIndices",value:function(e,t){return wG(e,!Zt.isUndefined(t)&&t>=0?t:this._imageBufferWrapper.count(),this)}},{key:"_acquireImageForSendTo",value:(C=n(g().mark((function D(e,t,r,i){var o,a,s,u,c,l,d,f;return g().wrap((function(h){for(;;)switch(h.prev=h.next){case 0:if(o=this,a=r?Zt.clone(r):{},u=s=i,o._resetErr(),o._isValid()){h.next=4;break}throw{code:o._errorCode,message:o._errorString};case 4:if(Zt.isString(s._id)){h.next=6;break}throw{code:-2602,message:'The parameter "SendTo" is invalid.'};case 6:if(!o.__bAcquireImageNow){h.next=9;break}throw ha(o),{code:o._errorCode,message:o._getErrorString()};case 9:if(o.__bAcquireImageNow=!0,Ll(e,u),c=Qt.Promise.resolve(),l=rr.DWT.RemoteScanConfig,d=fl(),h.prev=13,hf(a),l&&hl(l.keepAwake),Ac.checkProductKey(o,{Core:!0})&&o._isValid()){h.next=18;break}throw{code:o._errorCode,message:o._errorString};case 18:return nf._innerSendHeartBeat(s,!1),f=function(){var e=n(g().mark((function t(e){return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:c=c.then((function(){return new Qt.Promise((function(t,r){var i=[o._uidFromServer2ServerId(e.imageId)],a=rr.DWT.EnumDWT_ImageType.IT_PNG;Qt.cancelFrom=sG.Scan,o._innerConvertToArrayBufferAsync(a,i).then((function(i){s._bltsCopyImage=!0,s.__LoadImageFromBytesV2(i,a,"",!0,0,0,!1,0,function(){var r=n(g().mark((function i(r,n){var a;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=o._uidFromServer2ServerId(e.imageId),n?(Zt.log("LoadImageFromBinary success"),s._bltsCopyImage=!1,e.imageId=s._uidFromServer2ServerId(n.ids),Zt.isFunction(s._OnPostTransferAsync)&&s._OnPostTransferAsync([!0,Zt.stringify(e)],null,!0)):Zt.log("LoadImageFromBinary return null."),t(),r.next=5,o._removeImageByIdAsync(a);case 5:case"end":return r.stop()}}),i)})));return function(e,t){return r.apply(this,arguments)}}(),(function(e,t){Zt.log(t),s._bltsCopyImage=!1,r({code:e,message:t})}))}),(function(e){e&&e.message&&Zt.log(e.message),r(e)}))}))}));case 1:case"end":return t.stop()}}),t)})));return function(t){return e.apply(this,arguments)}}(),o._registerEvent("OnPostTransferAsync2",f),null!=t&&(a.Device=t.strDevice,a.DeviceMatchField=Fd.SMF_NAME),h.next=24,o._acquireImageFromServiceAsync(a);case 24:h.next=29;break;case 26:throw h.prev=26,h.t0=h["catch"](13),h.t0;case 29:return h.prev=29,h.prev=30,h.next=33,c;case 33:h.next=37;break;case 35:h.prev=35,h.t1=h["catch"](30);case 37:return o._unregisterEvent("OnPostTransferAsync2"),o.__bAcquireImageNow=!1,Bl(e),hl(d),h.finish(29);case 42:case"end":return h.stop()}}),D,this,[[13,26,29,42],[30,35]])}))),function(e,t,r,n){return C.apply(this,arguments)})},{key:"_uidFromServer2index",value:function(e){var t,r=this;return r._resetErr(),!!r._isValid()&&(Zt.isString(e)?(-1==(t=r._imageBufferWrapper._uidFromServer2index(e))&&ws(r),t):(za(r),-1))}},{key:"_index2uidFromServer",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return!1;var r=parseInt(e);return isNaN(r)?(ca(t),""):r<0||r>=this._imageBufferWrapper.count()?(Oa(t),""):t._imageBufferWrapper._index2uidFromServer(e)}},{key:"__LoadImageFromBytesV2",value:function(e,t,r,n,i,o,a,s,u,c){var l,d=this,f=t||3,h=0,g=e.name,m=!0,p=1;if(e)if(e instanceof Blob)h=e.size;else if(kl(e))h=e.byteLength;else if(e instanceof Array)h=e.length;else{var v=e;h=v.size||v.byteLength||v.length}!isNaN(i)&&i>=0&&!isNaN(o)&&o>0?p=0:(i=0,o=0),l=["[",h,",",0,",",f,',"',r,'",',i,",",o,",",s,",",p,",",a?"true":"false","]"].join("");var _=function(){if(d.__bLoadingImage=!1,m){var e=d._imageBufferWrapper.getCurrentImageIndex();e>=0&&d._innerRefreshUI(e)}return Zt.isFunction(c)&&c(d._errorCode,d._getErrorString(),g),!1};return Ac.checkProductKey(d,{Core:!0})||de.bWin&&Ac.checkProductKey(d,{Webcam:!0},!0)?Ac.checkPDFProductKeyWhenNeeds(d,t)?0===h?(na(d,-2312,"The file length is empty."),m=!1,_()):this._innerSendBlob("LoadImageFromBytes",l,e,n,p,(function(e){if(d.__bLoadingImage=!1,d._isBindViewer()){var t=d._imageBufferWrapper.getCurrentImageIndex();n&&t>=0&&d._innerRefreshUI(t)}if(Zt.isFunction(u)){var r=e;if(Zt.isArray(r)&&(r=r.length>0?r[0]:{}),n)setTimeout((function(){u(g,r)}),30);else try{u(g,r)}catch(i){Zt.error(i.message)}}return d._canConsume()&&rr.DWT.lcvrf(d),!0}),_):(m=!1,_()):(Ac.checkProductKey(d,{Core:!0},!1),m=!1,_())}},{key:"_innerSendBlob",value:function(e,t,r,n,i,o,a){var s=this;if(nf.isServerInvalid(s))return s._waitForConnect().then((function(){s._innerSendBlob(e,t,r,n,i,o,a)}));if(n)return s._innerSendBlobByWS(e,t,r,o,a),!0;var u,c,l,d;return s._resetErr(),!!s._isValid()&&(c=[s._httpUrl,"f/",e].join(""),l=uf(s._clientId,e,t,0,s._bScanForProxyRemote),l+="\r\n\r\n",d={method:"POST",url:c,processData:!1,data:l+=Zt.base64.encodeArray(r),async:!1,onSuccess:function(e,t,n){var o=!1,a=!1;try{o=Zt.isString(e)&&ta(n.getResponseHeader("content-type"))?Zt.parse(e):e}catch(jj){}if(o!==undefined&&null!==o&&(Hs(o)?(s._errorCode=o.exception,s._errorString=o.description,s._errorCause=zs(o)):s._resetErr(),(u=o.result)&&Zt.isArray(u)&&u.length>=1))if(i){var c,l=u[0];l&&Zt.isObject(l)&&(c=l.imageInfos,0==s._errorCode&&Zt.isString(c)&&s._handleOnBitmapChangedEvent({result:["c1",c]},{document:r.currentFileName,tag:r.currentTagName}),a=!0)}else{var d=u.join(",");0==s._errorCode&&d.length>0&&s._OnBitmapChanged(["c1",d,1,s._imageBufferWrapper.getCurrentImageIndex(),s._imageBufferWrapper.count()],null,{document:r.currentFileName,tag:r.currentTagName}),a=!0}a||(_a(s),u="")},onError:function(){va(s),u=""}},Zt.mix(d,{headers:{"X-Requested-With":!1}}),de.bFileSystem&&(d.crossDomain=!1),Vi(d),0==s._errorCode?Zt.isFunction(o)&&o():Zt.isFunction(a)&&a(),u)}},{key:"_convertToBase64ByServerIdsWithUI",value:function(e,t,r,n,i,o,a){this._convertToBase64ByServerIdsWithUIAsync(e,r,t,n).then((function(e){Zt.isFunction(o)&&Ff(o,e)}),(function(){Zt.isFunction(a)&&a()}))}},{key:"_OnPercentDone",value:function(e){var t,r,n,i,o,a=this,s=!1,u=!1,c=0;Zt.isArray(e)&&e.length>2&&(r=e[0],c=e[1],n=e[2],e.length>3&&(i=e[3]),e.length>4&&(o=e[4]),e.length>5&&e[5],t=c,c<0?t=0:c>100&&(t=100),t=Math.floor(t),Qt.cancelFrom!=sG.HTTPUpload&&Qt.cancelFrom!=sG.HTTPDownload&&Qt.cancelFrom!=sG.Scan&&Qt.cancelFrom!=sG.HTTPPut||(u=o)),(a._bServerPercentDone||0==r)&&((c>0||0==c)&&(Qt.cancelFrom!=sG.HTTPUpload&&Qt.cancelFrom!=sG.HTTPDownload&&Qt.cancelFrom!=sG.FTPUpload&&Qt.cancelFrom!=sG.FTPDownload&&Qt.cancelFrom!=sG.HTTPPut||(s=!0)),a.IfShowProgressBar&&Qt.progressBarOnPercentDone(c,n,i,t,u,this._containerElement),1==s&&(Zt.isFunction(a.__OnInternetTransferPercentage)&&a.__OnInternetTransferPercentage(t,!1),Zt.isFunction(a.__OnInternetTransferPercentageEx)&&a.__OnInternetTransferPercentageEx(t,!1)),Zt.isFunction(a.__OnPercentDone)&&a.__OnPercentDone())}},{key:"IfShowProgressBar",get:function(){return this._bIfShowProgressBar},set:function(e){this._resetErr(),Zt.isBoolean(e)?this._bIfShowProgressBar=e:la(this)}},{key:"IfShowCancelDialogWhenImageTransfer",get:function(){return this.__IfShowCancelDialogWhenImageTransfer},set:function(e){Zt.isBoolean(e)?this.__IfShowCancelDialogWhenImageTransfer=e:(this._resetErr(),la(this))}},{key:"_getLogLevel",value:function(){return this._logLevel}},{key:"_setLogLevel",value:(T=n(g().mark((function F(e){return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logLevel=e,t.next=3,this._innerFunV2("LogLevel",El(e));case 3:case"end":return t.stop()}}),F,this)}))),function(e){return T.apply(this,arguments)})},{key:"MaxUploadImageSize",get:function(){return this.__maxUploadImageSize},set:function(e){var t=this;t._resetErr();var r=1*e;!Zt.isNumber(r)||isNaN(r)?la(t):t.__maxUploadImageSize=r}},{key:"HTTPRequestswithCredentials",get:function(){return this._resetErr(),this._bWithCredentials},set:function(e){this._resetErr(),Zt.isBoolean(e)?this._bWithCredentials=e:la(this)}},{key:"cancelableObj",get:function(){return this._cancelableObj},set:function(e){this._cancelableObj=e}},{key:"_getProfile",value:(b=n(g().mark((function W(e){var t,r;return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if((t=this)._resetErr(),t._isValid()){n.next=4;break}throw{code:t._errorCode,message:t._errorString};case 4:return e&&(r=Zt.stringify([e.strDevice])),n.abrupt("return",t._innerFunV2("GetCustomDSDataEx",r));case 6:case"end":return n.stop()}}),W,this)}))),function(e){return b.apply(this,arguments)})},{key:"_setProfile",value:(I=n(g().mark((function N(e,t){var r,n;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if((r=this)._resetErr(),r._isValid()){i.next=4;break}throw{code:r._errorCode,message:r._errorString};case 4:return n=e?Zt.stringify([t,e.strDevice]):El(t),i.abrupt("return",this._innerFunV2("SetCustomDSDataEx",n));case 6:case"end":return i.stop()}}),N,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"_removeAllImagesAsync",value:(S=n(g().mark((function R(e,t){var r,n,i,o,a,s;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((r=this)._resetErr(),r._isValid()){e.next=4;break}throw{code:r._errorCode,message:r._errorString};case 4:for(i=[],a=r._getHowManyImagesInBuffer(),o=a-1;o>=0;o--)(s=r._imageBufferWrapper.convertClientIndexToServerId(o))>-1&&i.push(s);if(0!=i.length){e.next=13;break}return e.next=10,r._innerFunV2("RemoveAllImages");case 10:n=e.sent,e.next=23;break;case 13:if(!t){e.next=19;break}return e.next=16,r._innerFunV2("RemoveAllImages",El(i.join(",")));case 16:n=e.sent,e.next=22;break;case 19:return e.next=21,r._innerFunV2("RemoveAllImages");case 21:n=e.sent;case 22:(n||-1033==r._errorCode)&&r._OnBitmapChanged(["c1",i.join(","),3,r._imageBufferWrapper.getCurrentImageIndex(),r._imageBufferWrapper.count()]);case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),R,this)}))),function(e,t){return S.apply(this,arguments)})},{key:"__OnRecieveMsg",value:function(e,r){var n=this,i=null==r?void 0:r.cmd;if(e.event)return l(d(t.prototype),"__OnRecieveMsg",this).call(this,e,r);if(Hs(e)?(n._errorCode=e.exception,n._errorString=e.description,n._errorCause=zs(e)):"StartScan"!=i&&"GetAddOnVersion"!=i&&(n._errorCode=0,n._errorString=""),"ReadBarcode"==i||"OCRRecognize"==i||e.request&&"OCRProRecognize"==e.request.method)return r.sFun?(r.sFun(e),!0):(r.fFun&&r.fFun(e),!0);if("SetCapabilities"==i||"GetSkewAngleFromBinary"==i||"UpdateImage"==i)return"exception"in e&&"0"!=e.exception?(e.result.errorCode&&e.result.errorString?(n._errorCode=e.result.errorCode,n._errorString=e.result.errorString):(n._errorCode=e.exception,n._errorString=e.description),r.fFun&&r.fFun(e.result),e=null,!0):(r.sFun&&r.sFun(e.result),e=null,!0);if(e.result&&e.result.length&&("1"==e.result[0]||1==e.result[0]||"ok"==e.result[0]))return(r.sFun||r.sFun)&&r.sFun(e.result),!0;if(!e.exception)return r.sFun&&r.sFun(e.result),e=null,!0;var o=!1;return r.fFun&&(o=r.fFun(n._errorString)),!o&&e.exception&&e.exception<0&&-2115!=e.exception&&Zt.isFunction(n.__OnPrintMsg)&&n.__OnPrintMsg(n._errorString),!0}},{key:"_convertServerIdToGuid",value:function(e){return this._serverId2uidFromServer(e)}},{key:"_convertGuidToServerId",value:function(e){return this._uidFromServer2ServerId(e)}},{key:"_serverId2uidFromServer",value:function(e){return this._imageBufferWrapper._serverId2uidFromServer(e)}},{key:"_uidFromServer2ServerId",value:function(e){return this._imageBufferWrapper._uidFromServer2ServerId(e)}},{key:"_innerConvertToBlobWithUI",value:function(e,t,r,n,i,o){var a=this,s=arguments,u=function(e){if(Qt.needShowTwiceShowDialog=!1,Zt.isFunction(o)){var t=[];Zt.isArray(r)&&Zt.each(r,(function(e){var r=a._imageBufferWrapper.convertServerIdToClientIndex(e);r>-1&&t.push(r)})),e&&(a._errorCode=e.code,a._errorString=e.message,e.errorCause&&(a._errorCause=e.errorCause)),o(t)}return!1};a._innerConvertToArrayBufferWithUIAsync(e,t,r,n).then((function(e){if(!e||e.byteLength<=0)return Ha(a),u();var n=a.__maxUploadImageSize;if(e.byteLength>n&&-1!=n)return wa(a),u();if(Qt.needShowTwiceShowDialog=!1,Zt.isFunction(i)){var o=[];Zt.isArray(r)&&Zt.each(r,(function(e){var t=a._imageBufferWrapper.convertServerIdToClientIndex(e);t>-1&&o.push(t)}));var c=bf.getBlobTypeByImageType(t),l=new Blob([e],{type:c});try{i(l,o,s)}catch(d){}l=null}return!0}),u)}},{key:"convertToBlob",value:(y=n(g().mark((function O(e,t,r){var n,i,o,a;return g().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return i=Df(n=this,t),Qt.cancelFrom=sG.ConvertToBlob,s.next=4,n._innerConvertToArrayBufferWithUIAsync("convertToBlob",e,i,r);case 4:return o=s.sent,a=bf.getBlobTypeByImageType(e),s.abrupt("return",new Blob([o],{type:a}));case 7:case"end":return s.stop()}}),O,this)}))),function(e,t,r){return y.apply(this,arguments)})},{key:"_innerConvertToArrayBufferWithUIAsync",value:(_=n(g().mark((function M(e,t,r,n,i){var o,a,s,u;return g().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return a=this,u=null===(o=Qt.progressContext)||void 0===o?void 0:o.IfShowCancelDialogWhenImageTransfer,c.prev=2,a.IfShowProgressBar?Qt.showProgress(a,e,!1):Qt.hideProgress(),a._OnPercentDone([0,-1,ul.Encoding]),Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=!1),c.next=8,this._innerConvertToArrayBufferAsync(t,r,n,i);case 8:s=c.sent;case 9:return c.prev=9,Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=u),a.IfShowProgressBar&&Qt.closeProgress(null,e),c.finish(9);case 13:return c.abrupt("return",s);case 14:case"end":return c.stop()}}),M,this,[[2,,9,13]])}))),function(e,t,r,n,i){return _.apply(this,arguments)})},{key:"_innerConvertToBase64Async",value:(v=n(g().mark((function L(e,t,r){var n,i,o,a,s,u,c,l,d;return g().wrap((function(f){for(;;)switch(f.prev=f.next){case 0:return n=this,i=r,Zt.isString(i)&&""!=i||(i="{}"),o=["[",e,',"',t.join(","),'",',i,",1]"].join(""),f.next=5,n._sendDataByHttpAsync("ConvertToBase64",o,"text",!0);case 5:if(a=f.sent,s=0,u="",c="",l=a&&a.result,0==n._errorCode){f.next=10;break}throw{code:n._errorCode,message:n._getErrorString()};case 10:if(!l||!Zt.isArray(l)||3!=l.length){f.next=18;break}return c=l[0],s=l[1],u=l[2],d=new bG(null,s,u,c),f.abrupt("return",d);case 18:throw na(n,-2366,"Converting images to a base64 string failed."),{code:n._errorCode,message:n._errorString};case 20:case"end":return f.stop()}}),L,this)}))),function(e,t,r){return v.apply(this,arguments)})},{key:"_convertToBase64ByServerIdsWithUIAsync",value:(p=n(g().mark((function B(e,t,r,n){var i,o,a;return g().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=this,a=null===(i=Qt.progressContext)||void 0===i?void 0:i.IfShowCancelDialogWhenImageTransfer,s.prev=2,o.IfShowProgressBar?Qt.showProgress(o,e,!1):Qt.hideProgress(),o._OnPercentDone([0,-1,ul.Encoding]),Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=o.IfShowCancelDialogWhenImageTransfer),s.next=8,this._innerConvertToBase64Async(t,r,n);case 8:return s.abrupt("return",s.sent);case 9:return s.prev=9,Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=a),o.IfShowProgressBar&&Qt.closeProgress(null,e),s.finish(9);case 13:case"end":return s.stop()}}),B,this,[[2,,9,13]])}))),function(e,t,r,n){return p.apply(this,arguments)})},{key:"_convertToBlobForUpload",value:function(e,t,r,n,i,o,a){var s=this,u=arguments;if(rr.DWT.ConnectWithSocket){var c=r,l=",";Zt.isString(c)&&""!=c||(c="",l="");var d=["[",e,',"',t.join(","),'"',l,c,"]"].join("");return Qt.cancelFrom=sG.ConvertToBlob,Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=!1),s._sendData("ConvertToBlob",d,!0,(function(e){s._resetErr();var t=e;if(t){if(t instanceof Blob||kl(t))return void i(t,"",u);Hs(t)&&(s._errorCode=t.exception,s._errorString=t.description,s._errorCause=zs(t))}}),(function(e){s._errorCode=e.code,s._errorString=e.message,o(e)})),!0}s._innerConvertToArrayBufferAsync(e,t,r,"arraybuffer").then((function(e){var t=s._strHttpContentTypeFieldValue,r=new Blob([e],{type:t});if(rr.DWT.IfAddMD5InUploadHeader){var n=new IG.ArrayBuffer;n.append(e),Zt.isFunction(i)&&i(r,n.end(),u)}else Zt.isFunction(i)&&i(r,"",u);r=null}),(function(e){o(e.code,e.message)}))}},{key:"dispose",value:function(){return this.__unload()}},{key:"_innerDisposeWSClient",value:function(){return this._isValid()?this._sendData("dispose",null,!0,(function(){}),(function(){})):Qt.Promise.reject()}},{key:"__unload",value:(m=n(g().mark((function U(){var e,t;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(e=this)._bReady||Qt.page.bUnload){r.next=10;break}if(!e._wsClient){r.next=10;break}return r.prev=3,r.next=6,e._innerDisposeWSClient();case 6:r.next=10;break;case 8:r.prev=8,r.t0=r["catch"](3);case 10:if(!e._wsClient){r.next=24;break}return e._wsClient.removeEvent("close",e._clientId),e._wsClient.removeEvent("error",e._clientId),e._wsClient.removeEvent("timeout",e._clientId),r.prev=14,r.next=17,e._wsClient.dispose();case 17:r.next=22;break;case 19:r.prev=19,r.t1=r["catch"](14),t=r.t1;case 22:delete e._wsClient,e._wsClient=null;case 24:if(this._imageBufferWrapper.dispose(),this._bReady=di,this._destroy=fi,!t){r.next=29;break}throw t;case 29:case"end":return r.stop()}}),U,this,[[3,8],[14,19]])}))),function(){return m.apply(this,arguments)})},{key:"_getImages",value:(h=n(g().mark((function V(e,t,r,n){var i,o,a,s;return g().wrap((function(u){for(;;)switch(u.prev=u.next){case 0:if((i=this)._checkIndices(t)){u.next=3;break}throw{code:this._errorCode,message:this._errorString};case 3:if(n!=SG.URL){u.next=9;break}if(!(t.length>1)){u.next=7;break}throw na(this,-2619,"Only single index selection is allowed when enumImageFormatType is set to url."),{code:this._errorCode,message:this._errorString};case 7:u.next=13;break;case 9:if(r!=rr.DWT.EnumDWT_ImageType.IT_BMP&&r!=rr.DWT.EnumDWT_ImageType.IT_JPG&&r!=rr.DWT.EnumDWT_ImageType.IT_PNG){u.next=13;break}if(!(t.length>1)){u.next=13;break}throw us(this),{code:this._errorCode,message:this._errorString};case 13:if(n!=SG.URL){u.next=17;break}return u.abrupt("return",this._imageBufferWrapper.getImageUrl(t[0]));case 17:if(Qt.cancelFrom=sG.Other,o=Df(i,t),n!=SG.Blob){u.next=27;break}return u.next=22,this._innerConvertToArrayBufferWithUIAsync(e,r,o);case 22:return a=u.sent,s=bf.getBlobTypeByImageType(r),u.abrupt("return",new Blob([a],{type:s}));case 27:if(n!=SG.Base64){u.next=31;break}return u.next=30,this._convertToBase64ByServerIdsWithUIAsync(e,r,o);case 30:return u.abrupt("return",u.sent);case 31:throw ss(this),{code:this._errorCode,message:this._errorString};case 33:case"end":return u.stop()}}),V,this)}))),function(e,t,r,n){return h.apply(this,arguments)})},{key:"_LicensePromptExpired",value:function(){var e=this,t=e.__licenseInfo.bTrial,r="";e.__licenseInfo&&e.__licenseInfo.ExpireDate&&(r=e.__licenseInfo.ExpireDate);var n=Nc(r);n<=0&&(t||_o(e._getErrorString()),Zt.isFunction(rr.OnLicenseExpiredWarning)&&rr.OnLicenseExpiredWarning(r,n,t))}},{key:"__saveToViewerAfterUpdate",value:function(e,t){var r=this,n=this._imageBufferWrapper.getIndexByUid(e),i=this._imageBufferWrapper.convertClientIndexToServerId(n),o=Il.getUrlByAct(this._imageBufferWrapper.BaseUrl,i,2);return new Qt.Promise((function(e,a){Vi({method:"GET",xhrFields:{withCredentials:!0},url:o,onSuccess:function(o){var a,s=r._imageBufferWrapper.getMetadataByIndex(n);s||(s={}),s.width=t.width,s.height=t.height,a=rr.navInfoSync.bMobile?r._imageBufferWrapper.getMinImageUrl(n,Math.round(s.controlWidth*devicePixelRatio),Math.round(s.controlHeight*devicePixelRatio)):r._imageBufferWrapper.getMinImageUrl(n,s.controlWidth,s.controlHeight);var u=r._imageBufferWrapper.getImageIdMap(i);if(u){u.ticks=Date.now(),u.imageUrl=r._imageBufferWrapper.getImageUrl(n),u.minImageUrl=a,u.width=t.width,u.height=t.height;var c=Zt.clone(u);c.imageId=i,r._imageBufferWrapper.UpdateImage(c,s)}e()},onError:function(){e(),Bl("save")}})}))}},{key:"RunCommandAsync",value:(c=n(g().mark((function j(e){var t,r,n,i,o,a;return g().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(t=this,e&&Zt.isString(e.command)&&e.parameter){s.next=4;break}throw Ka(t),{code:t._errorCode,message:t._errorString};case 4:if("Invert"!=e.command){s.next=6;break}return s.abrupt("return",t._invert(e.parameter.index));case 6:if(r=e.parameter.index,!Zt.isNumber(r)){s.next=13;break}if(!(isNaN(r)||!Zt.isNumber(r)||r<0||r>=t._imageBufferWrapper.count())){s.next=11;break}throw Oa(t),{code:t._errorCode,message:t._errorString};case 11:n=t._imageBufferWrapper.convertClientIndexToServerId(r),e.parameter.index=n;case 13:return i=["[",Zt.stringify(e),"]"].join(""),s.next=16,t._innerFunRawV3("runCommand",i);case 16:if(o=s.sent,!de.bIE){s.next=21;break}if(!Zt.isString(o)){s.next=20;break}return s.abrupt("return",Zt.parse(o));case 20:return s.abrupt("return",o);case 21:if(!ta(a=o.headers.get("content-type"))){s.next=28;break}return s.next=25,o.json();case 25:return s.abrupt("return",s.sent);case 28:if("text/plain"!=a&&"text/html"!=a){s.next=32;break}return s.next=31,o.text();case 31:return s.abrupt("return",s.sent);case 32:return s.next=34,o.blob();case 34:return s.abrupt("return",s.sent);case 35:case"end":return s.stop()}}),j,this)}))),function(e){return c.apply(this,arguments)})},{key:"_innerFunRawV3",value:(u=n(g().mark((function G(e,t){var r,n,i;return g().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(i="fa/",(r=this)._resetErr(),r._isValid()){o.next=4;break}throw{code:r._errorCode,message:r._errorString};case 4:if(!nf.isServerInvalid(r)){o.next=7;break}return o.abrupt("return",r._waitForConnect().then((function(){return r._innerFunRawV3(e,t)})));case 7:return n={method:"post",body:uf(r._clientId,e,t,0,r._bScanForProxyRemote),fetchRaw:!0},o.next=10,Ns([r._httpUrl,i,e].join(""),n);case 10:return o.abrupt("return",o.sent);case 11:case"end":return o.stop()}}),G,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"_invert",value:(a=n(g().mark((function H(e){var t,r,n,i,o;return g().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(t=this,r=parseInt(e),t._resetErr(),t._isValid()){a.next=4;break}throw{code:t._errorCode,message:t._errorString};case 4:if(!isNaN(r)){a.next=7;break}throw ca(t),{code:t._errorCode,message:t._errorString};case 7:if(!(r<0||r>=t._imageBufferWrapper.count())){a.next=10;break}throw Oa(t),{code:t._errorCode,message:t._errorString};case 10:if(-1!=(n=t._imageBufferWrapper.convertClientIndexToServerId(r))){a.next=14;break}throw Oa(t),{code:t._errorCode,message:t._errorString};case 14:return a.next=16,t._innerFunV2("Invert",El(n),!0);case 16:if(i=a.sent,!(o=1==i)){a.next=22;break}bf.refreshImageAfterInvokeFun(t,r),a.next=23;break;case 22:throw{code:t._errorCode,message:t._errorString};case 23:return a.abrupt("return",o);case 24:case"end":return a.stop()}}),H,this)}))),function(e){return a.apply(this,arguments)})}],[{key:"create",value:(r=n(g().mark((function z(e){var r;return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new t(e),n.next=3,nf.STwainConnectToServer(r);case 3:return n.abrupt("return",r);case 4:case"end":return n.stop()}}),z)}))),function(e){return r.apply(this,arguments)})}]);var r,a,u,c,h,m,p,v,_,y,S,I,b,T,C,w,E,k}(oG);function CG(e){var t=e,r="",n=!1;if(t&&t.__licenseInfo&&(t.__licenseInfo.ExpireDate&&(r=t.__licenseInfo.ExpireDate),n=t.__licenseInfo.bTrial),n&&!rr.DWT.HideTrialMessage){var i=Nc(r);i<=5&&(Zt.isFunction(rr.OnLicenseExpiredWarning)&&rr.OnLicenseExpiredWarning(r,i,!0),rr.DWT.HideTrialMessage=!0)}}function wG(e,t,r){var n;if(!Zt.isArray(e))return Ra(r),!1;if(0==e.length)return na(r,-2350,"The indices cannot be empty."),!1;if(rr.DWT.ConnectWithSocket)return!0;for(n=0;n=t)return Wa(r),!1}return!0}var EG={changeImageUISize:function(e,t,r){var n,i,o,a,s=t,u=r,c=di;n=ci.one(e._containerElement),Zt.isString(t)&&t.indexOf("%")>=0?(0==(o=ci.css(n,"width"))&&(n[0].style.width="100%"),o=ci.css(n,"width")*parseInt(t)/100,c=fi):s=[(o=parseInt(t))+2,"px"].join(""),Zt.isString(r)&&r.indexOf("%")>=0?(0==(a=ci.css(n,"height"))&&(n[0].style.height="100%"),a=ci.css(n,"height")*parseInt(r)/100,c=fi):u=[(a=parseInt(r))+2,"px"].join(""),n&&(i=ci.one(".dynamsoft-dwt-container-box",n))&&i.getEL()&&(i.style("width",s),i.style("height",u)),c?(e.__funResize||(e.__funResize=function(){if(e._ImgManager&&e._containerElement){var t=EG.__innerGetUIViewRealSize(e._containerElement,e._width,e._height);return e._UIView.ChangeSize(t.width,t.height)}return fi}),Zt.removeEventListener(window,"resize",e.__funResize),Zt.addEventListener(window,"resize",e.__funResize)):e.__funResize&&(Zt.removeEventListener(window,"resize",e.__funResize),e.__funResize=di);var l=EG.__innerGetUIViewRealSize(e._containerElement,o,a);return e._ImgManager?e._UIView.ChangeSize(l.width,l.height):fi},__innerGetUIViewRealSize:function(e,t,r){var n,i=-1,o=-1;return n=ci.one(e),Zt.isString(t)&&t.indexOf("%")>=0&&(i=ci.css(n,"width")*parseInt(t)/100),i<0&&t&&(i=parseInt(t)),Zt.isString(r)&&r.indexOf("%")>=0&&(o=ci.css(n,"height")*parseInt(r)/100),o<0&&r&&(o=parseInt(r)),{width:i,height:o}},bindUIViewEvents:function(e,t){var r=e;t.onSelected=function(e){if(!r._isNoViewer()){var t,n=e.length;n>0&&(r._ImgManager.SetSelectedImageCount(n),t=e[n-1],Zt.isFunction(r.__OnRefreshUI)&&r.__OnRefreshUI(t))}},t.onRefreshUI=function(e){r._isNoViewer()||EG.__innerRefreshFromUIView(r,e)},t.onResetCurrentIndex=function(e){if(!r._isNoViewer()){var t=r._ImgManager.getCurrentImageIndex();if(e>=0&&e0&&"%"===e.charAt(e.length-1)&&(i=e),!i&&e&&(r=parseInt(e))&&(i=r+"px"),Zt.isString(t)&&t.length>0&&"%"===t.charAt(t.length-1)&&(o=t),!o&&t&&(r=parseInt(t))&&(o=r+"px"),i&&(n._width=i),o&&(n._height=o),EG.changeImageUISize(n,i,o))}}])}();function xG(e){var t,r,n,i,o=e._config;Qt.dlgProgress||Qt.initProgress(e),o.bNoViewer?e._containerElement=null:(o.container?e._containerElement=o.container:o.containerId&&(e._containerElement=Zt.get(o.containerId)),e._width=o.width,e._height=o.height,t=ci.one(e._containerElement)),function(e,t){var r={Stwain:e},n=di;if(t){var i,o=e._width,a=e._height;i=ci.one(e._containerElement),Zt.isString(o)&&o.indexOf("%")>=0?(o=ci.css(i,"width")*parseInt(o)/100,n=fi):o=parseInt(o),Zt.isString(a)&&a.indexOf("%")>=0?(a=ci.css(i,"height")*parseInt(a)/100,n=fi):a=parseInt(a),r={Stwain:e,Container:t,Width:o,Height:a}}EG.bindUIViewEvents(e,r),e._UIView?e._UIView._Init(r):e._UIView=new Qt.UI.ImageUIView(e,r),e.Width<=0&&(e.Width=270),e.Height<=0&&(e.Height=350),n&&EG.changeImageUISize(e,e._width,e._height)}(e,t),e._isBindViewer()&&(r=e,n=e._config,i=n||{},r.__OnImageAreaDeSelected=i.onImageAreaDeSelected||"",r.__OnImageAreaSelected=i.onImageAreaSelected||"",r.__OnMouseClick=i.onMouseClick||"",r.__OnMouseDoubleClick=i.onMouseDoubleClick||"",r.__OnMouseMove=i.onMouseMove||"",r.__OnMouseRightClick=i.onMouseRightClick||"",r.__OnTopImageInTheViewChanged=i.onTopImageInTheViewChanged||"",r.__OnBufferChanged=i.onBufferChanged||"",e.__OnMouseClick=o.onMouseClick||"",e.__OnThumbnailMouseClick="",e.__OnKeyDown=o.onKeyDown||"",e.__OnMouseWheel=o.onMouseWheel||"",e.__OnMouseDoubleClick=o.onMouseDoubleClick||"",e.__OnMouseRightClick=o.onMouseRightClick||"",e.__OnMouseMove=o.onMouseMove||"",e.__OnImageAreaSelected=o.onImageAreaSelected||"",e.__OnImageAreaDeSelected=o.onImageAreaDeSelected||"",e.__OnRefreshUI=o.onRefreshUI||"",e.__OnBufferChanged=o.onBufferChanged||"",e.__MouseX=0,e.__MouseY=0,e.__style=new AG(e),e.__fSelectionRectAspectRatio=0)}Qt.install={_divDWTNonInstallContainerID:"dwt-NonInstallContainerID",_divDWTemessageContainer:"",_dlgInstall:!1},Qt.install._strNonInstallDIV=['
'].join("");var PG=rr.DWT;PG.CloseDialog=function(){var e=Qt.install._dlgInstall;if(e){var t=Zt.sizzle(".dynamsoft-dialog-close");Zt.each(t,(function(e,t){Zt.removeEventListener(e,"click",PG.CloseDialog)})),e.open&&e.close(),document.body.removeChild(e),Qt.install._dlgInstall=!1}},PG.ShowDialog=function(e,t,r,n,i){if(!1!==r){var o,a={width:e,height:t,position:"absolute"};n?(o=['
',r,"
"].join(""),a.closeButton=!1):o=['
','
','
',i?"":'
',"
",r,"
","
"].join(""),i&&(a.closeButton=!1),PG.ShowMessage(o,a)}},PG.ShowMessage=function(e,t){var r,n,i,o,a,s=Qt.install,u="ds-dwt-ui-dlg",c="ds-dwt-ui-dlg-wrap",l=screen.width,d=!0,f=0,h=!0,g=!0,m=0,p="fixed",v="Error",_=Qo.bActiveXEdition,y=!1,S=null;if(t&&(r=t.width,n=t.height,t.seconds&&(f=t.seconds),t.headerStyle&&(m=t.headerStyle),1==t.backgroundStyle&&(y=!0),!1===t.closeButton&&(h=!1),t.bAutoClose&&(i=t.bAutoClose,h=!0),0==t.bReadyClosed&&(d=!1),t.position&&(p=t.position),t.caption&&(v=t.caption),Zt.isFunction(t.onClose)&&(S=t.onClose)),r?!de.bMobile&&r>l-10&&(r=l-10):r=l>600?600:l-10,n||(n="100%"),1==m?e=['
','
','
',h?'
':"","
",e,"
"].join(""):2==m&&(e=['
','
',v,"",h?'
':"","
",'
',e,"
"].join("")),0==Zt.sizzle("."+u).length){var I=document.createElement("div"),b=document.createElement("div"),T=document.createElement("div");if(I.className=u,b.className=c,b.style.margin="auto",b.style.zIndex="9999",b.style.position="relative",b.style.border="0",i&&((o=document.createElement("div")).className="dynamsoft-dialog-close",b.insertBefore(o,b.firstElementChild),(a=document.createElement("div")).className="dynamsoft-dialog-closeTimer",a.style.width="100%",a.style.height="2px",a.style.marginTop="-2px",a.style.backgroundColor="#fe8e14",b.insertBefore(a,b.firstElementChild)),b.appendChild(T),DG(T,e),I.appendChild(b),document.body.appendChild(I),S){var C=ci.one(".dynamsoft-dialog-close",ci.one(I));C&&((C=C[0]).onClose=function(){Zt.removeEventListener(C,"click",C.onClose),C.onClose=null,S()},Zt.addEventListener(C,"click",C.onClose))}if(y?ci.setBackOpacity({opacity:.4,grayHex:0}):ci.setBackOpacity({}),I.bTopmost=!0,s._dlgInstall=I,ci.dialog.setup(s._dlgInstall,!1),de.bIE){var w=document.createElement("iframe");w.frameborder="0",w.marginheight="0",w.marginwidth="0",w.style.border="0",w.style.backgroundColor="transparent",w.style.position="absolute",w.style.left=0,w.style.top=0,w.style.width="100%",w.style.height=document.body.clientHeight+"px",w.style.margin="0 auto",w.style.zIndex="10000",w.src=["javas","cript:",'""'].join("");var E=ci.one(".dynamsoft-backdrop");if(E&&E.length>0){for(var k=E[0];k.firstChild;)k.removeChild(k.firstChild);k.style.zIndex="10000",k.appendChild(w)}}}else g=!1;var A=ci.one("."+c);if(A&&A.getEL()&&(A[0].style.width=r+"px",Zt.isNumber(n)&&n>0?A[0].style.height=n+"px":A[0].style.height="100%",g||Zt.each(A[0].childNodes,(function(t){if("DIV"==t.tagName&&"dynamsoft-dialog-close"!=t.className&&"dynamsoft-dialog-closeTimer"!=t.className)return DG(t,e),!1}))),_){var x=ci.one(".dynamsoft-dialog");x&&x.getEL()&&(x.getEL().style.border="1px solid #999")}if(s._dlgInstall.open&&s._dlgInstall.close(),s._dlgInstall.showModal({position:p}),s._dlgInstall.bReadyClosed=d,y&&ci.setBackOpacity({}),h){var P=Zt.sizzle(".dynamsoft-dialog-close");Zt.each(P,(function(e,t){Zt.addEventListener(e,"click",PG.CloseDialog)})),P.length>0&&i&&f>0&&setTimeout(Qt._zdgb_xkz_dhk,100)}},PG.OnWebTwainPreExecute||(PG.OnWebTwainPreExecute=function(e,t){var r,n,i=rr.DWT.IfConfineMaskWithinTheViewer;if(i&&(e&&(n=e._containerElement),n||rr.DWT.Containers&&rr.DWT.Containers.length>0&&rr.DWT.Containers[0].ContainerId&&(n=Zt.get(rr.DWT.Containers[0].ContainerId)),n)){r=n.getBoundingClientRect();for(var o=0;o1||rr.DWT.Containers&&1==rr.DWT.Containers.length&&(0==r.width||0==r.height))&&(i=!1,n=null);var s=null!=t?t:{};i&&(s={confined:i,wrapperEl:n}),Qt.showMask(s)}),PG.OnWebTwainPostExecute||(PG.OnWebTwainPostExecute=function(){ci.hideMask()});function DG(e,t){document.body&&ci.setHtml(e,t)}function FG(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function WG(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}window.DCP_DWT_OnClickCloseInstall=function(e,t){t||rr.DWT.CloseDialog();var r=Zt.get(Qt.install._divDWTNonInstallContainerID);if(r&&r.parentNode&&r.parentNode.removeChild(r),e&&Zt.isDOM(e)&&Zt.show(e),e&&Zt.isString(e))Zt.show(e);else{var n=rr.DWT.WebTwainIdMap;if(n){var i,o,a=Object.keys(n);for(i=0;i0){var r=t[0],n=parseInt(r.style.width);(n-=1)<=0?rr.DWT.CloseDialog():(r.style.width=n+"%",setTimeout(Qt._zdgb_xkz_dhk,100))}}},Qt.ShowLicenseDialog=rr.DWT.ShowMessage,Qt.createLoadingBarContent=function(){};var NG=new WeakSet,RG=function(e){function t(e){var r;return o(this,t),FG(r=i(this,t,[e]),NG),r}return f(t,e),s(t,[{key:"_getWSContextData",value:function(){return{document:this._getCurrentDocumentName(),tag:this._getCurrentDefaultTagName(),bNeedClearTag:!1}}},{key:"_getErrorString",value:function(){var e=this;return-2207==e._errorCode&&e._bMustUpgradeService&&ga(e),0!=e._errorCode?e._errorString:"Successful."}},{key:"_getWebTwainId",value:function(){return this._id}},{key:"_isTwainServiceType",value:function(){return!0}},{key:"_isPC",value:function(){return de.bWin||de.bMac||de.bLinux}},{key:"_serviceSyncMethodNotSupport",value:function(e){var t=this;return na(t,-2605,'The synchronized method "'+e+'" is not supported under the current settings.'),{code:t._errorCode,message:t._getErrorString()}}},{key:"_serviceAsyncMethodNotSupport",value:function(e){var t=this;return na(t,-2606,'The asynchronized method "'+e+'" is not supported under the current settings.'),{code:t._errorCode,message:t._getErrorString()}}},{key:"_serviceNotSupportAsync",value:function(e){var t=this;return na(t,-2397,e+" doesn't work under current settings."),ci.Promise.reject({code:t._errorCode,message:t._getErrorString()})}},{key:"_nouiNotSupport",value:function(e,t){var r=this;return na(r,-2210,"You cannot call this method on this WebTwain instance because it does not use the default viewer."),Zt.isFunction(t)&&t(r._errorCode,r._getErrorString()),!1}},{key:"_innerFunRaw",value:function(e,t,r,n,i,o,a){var s,u,c,l,d=this,f="f/",h=r;if(h&&(f="fa/"),rr.DWT.ConnectWithSocket)this._sendData(e,t,!1,o,a);else{if(d._resetErr(),!d._isValid())return!!h&&void 0;var g=nf.isServerInvalid(d);if(h&&g)return d._waitForConnect().then((function(){return d._innerFunRaw(e,t,h,n,i,o,a)}));if(!h&&g)return rs(d),!1;if(c={method:"POST",url:s=[d._httpUrl,f,e].join(""),data:u=uf(d._clientId,e,t,0,d._bScanForProxyRemote),async:h,onSuccess:function(e,t,r){var n=!1;try{n=Zt.isString(e)&&ta(r.getResponseHeader("content-type"))?Zt.parse(e):e}catch(jj){}n?(Hs(n)?(d._errorCode=n.exception,d._errorString=n.description,d._errorCause=zs(n)):d._resetErr(),l=i?n:n.result):(_a(d),l=""),Zt.isFunction(o)&&o(l),h&&(l=null)},onError:function(){va(d),l="",!Qt.page.bUnload&&Zt.isFunction(a)&&a()}},!h&&n)de.bIE?(c.dataType="arraybuffer",c.onSuccess=function(e,t,r){var n,i,a,s=!1;r.responseHeadersString&&(ea(r.responseHeadersString)&&(s=!0));if(n=r.responseData,d._resetErr(),l=!1,n&&(i=new Uint8Array(n),s?n=String.fromCharCode.apply(null,i):(l=new Blob([i],{type:d._strHttpContentTypeFieldValue}),(a=new IG.ArrayBuffer).append(i),l.md5=a.end())),!n||s){var u,c=!1;if((u=s?n:r.responseText).length>0){if("{"==u.charAt(0))try{c=Zt.parse(u),s=!0}catch(f){Zt.log(u)}s?Hs(c)?(d._errorCode=c.exception,d._errorString=c.description,d._errorCause=zs(c),l=!1):l=!0:(i=new Uint8Array(u),l=new Blob([i],{type:d._strHttpContentTypeFieldValue}),(a=new IG.ArrayBuffer).append(i),l.md5=a.end())}}Zt.isFunction(o)&&o(l)}):(h||(c.dataType="text",c.contentType="text/plain; charset=x-user-defined",c.mimeType="text/plain; charset=x-user-defined"),c.onSuccess=function(e,t,r){var n,i,a;if(d._resetErr(),(i=(n=r.responseText).length)>0){var s,u=!1;if("{"==n.charAt(0))try{s=Zt.parse(n),u=!0}catch(h){Zt.log(n)}if(u)Hs(s)?(d._errorCode=s.exception,d._errorString=s.description,d._errorCause=zs(s),l=!1):l=!0;else{a=new Uint8Array(i);for(var c=0;c=0||t.indexOf("application/octet-stream")>=0?e.arrayBuffer():e.json()}))),m=m.then((function(e){if(d._resetErr(),kl(e))return Zt.isFunction(o)&&o(e),void(e=null);if(Zt.isObject(e)){var t=e;if(Hs(t))d._errorCode=t.exception,d._errorString=t.description,d._errorCause=zs(t),Zt.isFunction(a)&&a();else{var r="";t.result&&(r=t.result),Zt.isFunction(o)&&o(r)}}else va(d),!Qt.page.bUnload&&Zt.isFunction(a)&&a()}),(function(e){va(d),!Qt.page.bUnload&&Zt.isFunction(a)&&a()})),!0}if(h||Zt.mix(c,{headers:{"X-Requested-With":!1}}),de.bFileSystem&&(c.crossDomain=!1),Vi(c),!h)return l}}},{key:"_innerSendCmd",value:function(e,t){this._innerFunRaw(e,t,!0,!1,!0)}},{key:"_innerFun",value:function(e,t){var r;return r=this._innerFunRaw(e,t,!1,!1,!1),Zt.isArray(r)?r[0]:r}},{key:"__OnRecieveMsg",value:function(e,r){var n=this,i=null==r?void 0:r.cmd;if(e.event)return l(d(t.prototype),"__OnRecieveMsg",this).call(this,e,r);if(rr.DWT.ConnectWithSocket)return l(d(t.prototype),"__OnRecieveMsg",this).call(this,e,r);if(Hs(e)?(n._errorCode=e.exception,n._errorString=e.description,n._errorCause=zs(e)):"StartScan"!=i&&"GetAddOnVersion"!=i&&(n._errorCode=0,n._errorString=""),"ReadBarcode"==i||"OCRRecognize"==i||e.request&&"OCRProRecognize"==e.request.method)return r.sFun?r.sFun(e):r.fFun&&r.fFun(e),!0;if("ActiveUI"==i||"VersionInfo"==i||"ConvertToBase64"==i||"SaveSelectedImagesToBase64Binary"==i||"ConvertToBlob"==i||"BeginSaveMem"==i)return r.sFun&&Zt.isArray(e.result)&&e.result.length>0?r.sFun(e.result):r.fFun&&r.fFun(e.result),!0;if("ShowFileDialog"==i||"SplitTiff"==i||"SplitPDF"==i||"EncodeAsBase64"==i||"ProductKey"==i||"GetSourceNames"==i||"GetSkewAngle"==i||"GetImageInfo"==i||"GetSkewAngleFromBinary"==i)return r.sFun?r.sFun(e.result):r.fFun&&r.fFun(e.result),!0;if("SetCapabilities"==i)return l(d(t.prototype),"__OnRecieveMsg",this).call(this,e,r);if(e.result&&e.result.length&&("1"==e.result[0]||1==e.result[0]||"ok"==e.result[0]))(r.sFun||r.sFun)&&r.sFun(r.rawData?e:e.result);else{if(!e.exception)return r.sFun&&r.sFun(e.result),e=null,!0;var o=!1;r.fFun&&(o=r.fFun(n._errorString)),!o&&e.exception&&e.exception<0&&-2115!=e.exception&&Zt.isFunction(n.__OnPrintMsg)&&n.__OnPrintMsg(n._errorString)}return!0}},{key:"OnRefreshUI",value:function(e,t,r,n){return this._innerRefreshUI(e,t,r,n)}},{key:"GetCurrentDocumentName",value:function(){return this._resetErr(),!!this._isValid()&&this._getCurrentDocumentName()}},{key:"RegisterEvent",value:function(e,t){return!!this.registerEvent(e,t)}},{key:"UnregisterEvent",value:function(e,t){return this.unregisterEvent(e,t)}},{key:"onEvent",value:function(e,t){this.registerEvent(e,t)}},{key:"on",value:function(e,t){this.registerEvent(e,t)}},{key:"_OnConsumed",value:function(e){}},{key:"_OnPostLoad",value:function(e,t){var r,n,i,o,a=this;t!==undefined&&t.exception!==undefined&&t.description!==undefined&&(a._errorCode=t.exception,a._errorString=t.description),Zt.log("OnPostLoad Results:"),n=e[1].split(","),r=Zt.base64.decode(n[0]),i=Zt.base64.decode(n[1]),Zt.log(r),Zt.log(i),Zt.log(n[2]),BG(a,"On PostLoad"),(o=a._ImgManager.getCurrentImageIndex())>=0&&a._innerRefreshUI(o),Zt.isFunction(a.__OnPostLoad)&&a.__OnPostLoad(r,i,n[2])}},{key:"_OnPostTransfer",value:function(e){var t=this;if(Zt.log("On PostTransfer Results:"+e),BG(t,"On PostTransfer"),Zt.isFunction(t.__OnPostTransfer))try{t.__OnPostTransfer()}catch(r){_o(r)}}},{key:"_OnPreAllTransfersAsync",value:function(e){var t=this;if(Zt.isFunction(t.__OnPreAllTransfersAsync)){var r={event:"beforeAcquire",result:{}};try{Zt.isArray(e)&&e.length>1&&(r=Zt.parse(e[1]))}catch(Jj){}setTimeout((function(){try{t.__OnPreAllTransfersAsync(r)}catch(e){_o(e)}}),10)}}},{key:"_OnPostAllTransfers",value:function(e){var t=this;if(e.length>=2&&0==t._errorCode&&(t._errorCode=e[1],t._errorString=e[2]),Zt.log("On PostAllTransfers Results:"+e),t.__bLoadingImage=!1,t.__bAcquireImageNow=!1,t.__closeRemoteScanUI(!0),Zt.isFunction(t.__OnPostAllTransfers))try{t.__OnPostAllTransfers()}catch(r){_o(r)}}},{key:"_OnResult",value:function(e){var t=e[1];if(Zt.isFunction(this.__OnResult))try{this.__OnResult(t)}catch(r){_o(r)}}},{key:"_OnTransferCancelled",value:function(e){var t=this;if(t._ImgManager.getCurrentImageIndex(),t._ImgManager.count(),t.__bLoadingImage=!1,t.__bAcquireImageNow=!1,Zt.isFunction(t.__OnTransferCancelled))try{t.__OnTransferCancelled()}catch(r){_o(r)}}},{key:"_OnTransferError",value:function(e){if(Zt.isFunction(this.__OnTransferError))try{this.__OnTransferError()}catch(t){_o(t)}}},{key:"_OnSourceUIClose",value:function(e){var t=this;if(t.__closeRemoteScanUI(!0),Zt.isFunction(t.__OnSourceUIClose))try{t.__OnSourceUIClose()}catch(r){_o(r)}}},{key:"_OnPreTransfer",value:function(e){if(Zt.isFunction(this.__OnPreTransfer))try{this.__OnPreTransfer()}catch(t){_o(t)}}},{key:"_OnPreAllTransfers",value:function(e){if(Zt.isFunction(this.__OnPreAllTransfers))try{this.__OnPreAllTransfers()}catch(t){_o(t)}}},{key:"_OnGetFilePath",value:function(e){var t,r,n,i=this;if(t=e[1].split(","),Zt.log("On GetFilePath Results:"+e),r=Zt.base64.decode(t[3]),n=Zt.base64.decode(t[4]),"-1032"==t[2]&&(t[2]="-1",r=n=""),Zt.isFunction(i.__OnGetFilePath))try{i.__OnGetFilePath(1*t[0]>0,1*t[1],1*t[2],r,n)}catch(o){_o(o)}i.__bOpenFileNow=!1}},{key:"_OnDiskExceedLimit",value:function(){Zt.isFunction(this.__OnDiskExceedLimit)&&this.__OnDiskExceedLimit()}},{key:"__GetLoadEventsNum",value:function(){var e=0;return Zt.isFunction(this.__OnPostLoad)&&(e|=1),Zt.isFunction(this.__OnGetFilePath)&&(e|=2),e}},{key:"_innerSend",value:function(e,t,r,n,i){var o=this;if(rr.DWT.ConnectWithSocket||"SaveSelectedImagesToBytes"!=e&&"ConvertToBlob"!=e)return this._sendData(e,t,r,n,i);var a=Rl(),s=uf(o._clientId,e,t,a,o._bScanForProxyRemote);return o._innerFunRaw(e,s,!0,!0,!0,n,i),ci.Promise.resolve(!0)}},{key:"_convertToBlobByIndices",value:function(e,t,r,n,i,o){var a=this,s=!1,u=function(e){Zt.isFunction(o)&&Nf(o,a,e,t,n),e=null};if(Zt.isFunction(i)&&(s=!0),a._resetErr(),!a._isValid())return u(e),!!s&&void 0;var c=parseInt(t);if(!Ac.checkProductKey(a,{Core:!0}))return u(e),!!s&&void 0;if(!a._checkIndices(e))return u(e),!!s&&void 0;if(c==rr.DWT.EnumDWT_ImageType.IT_BMP||c==rr.DWT.EnumDWT_ImageType.IT_JPG||c==rr.DWT.EnumDWT_ImageType.IT_PNG||c==rr.DWT.EnumDWT_ImageType.IT_J2K){if(e.length>1)return na(a,-2372,"You cannot convert more than one image to binary when the format is BMP, JPG or PNG."),u(e),!!s&&void 0}else if(c!=rr.DWT.EnumDWT_ImageType.IT_TIF&&c!=rr.DWT.EnumDWT_ImageType.IT_PDF)return La(a),u(e),!!s&&void 0;var l=Df(a,e);return 0==l.length?(ca(a),u(e),!!s&&void 0):s?(Qt.cancelFrom=sG.ConvertToBlob,void a._innerConvertToBlobWithUI("ConvertToBlob",c,l,r,(function(e,r){Zt.isFunction(i)&&Ff(i,e,r,t,n),e=r=null}),u)):WG(NG,a,OG).call(a,l,c,r)}},{key:"_getDefaultDevice",value:function(){var e=this;if(e._resetErr(),!e._isValid())return null;var t="",r=Al.TWAINSCANNER,n=e._innerFun("GetDefaultSourceName");if(n.length>0)try{var i=JSON.parse(n);r=i.type,t=Zt.base64.decode(i.ProductName)}catch(a){t=""}var o=new Ed;return o.name=t,o.deviceType=r,o.isSystemDefaultPrinter=!1,xd(o),o}},{key:"_OnCurrentDeviceSelected",value:function(e,t){var r,n,i=this;if(e&&e.length>=2)try{n=parseInt(e[0]);var o=String(e[1]);(r=Ad(this,o)).strDevice=o,i._curDevice=r}catch(s){Zt.error(s)}var a=!1;if(Zt.isFunction(i.__OnCurrentDeviceSelected))try{a=i.__OnCurrentDeviceSelected(r,n)}catch(u){_o(u)}return a}},{key:"_getDefaultDeviceAsync",value:(_=n(g().mark((function y(){var e,t,r,n,i,o;return g().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if((e=this)._resetErr(),e._isValid()){a.next=4;break}return a.abrupt("return",null);case 4:return t="",r=Al.TWAINSCANNER,a.next=8,e._sendDataByHttpAsync("GetDefaultSourceName");case 8:if((n=a.sent).length>0)try{i=JSON.parse(n),r=i.type,t=Zt.base64.decode(i.ProductName)}catch(s){t=""}return(o=new Ed).name=t,o.deviceType=r,o.isSystemDefaultPrinter=!1,r==Al.TWAINX64SCANNER&&t.length>0?o.displayName="Twain64-"+t:r==Al.ICASCANNER&&this.__serverPlatform==Gu.enumMac&&t.length>0?o.displayName="ICA-"+t:o.displayName=t,a.abrupt("return",o);case 16:case"end":return a.stop()}}),y,this)}))),function(){return _.apply(this,arguments)})},{key:"_getSources",value:function(e,t,r){return kd(this,this._innerFun("GetSources",El(e,null!=t&&t,null!=r&&r)))}},{key:"_getSourceCountAsync",value:(v=n(g().mark((function S(e){var t,r,n,i,o,a,s;return g().wrap((function(u){for(;;)switch(u.prev=u.next){case 0:if((t=this)._resetErr(),t._isValid()){u.next=4;break}return u.abrupt("return",ci.Promise.reject({code:t._errorCode,message:t._errorString}));case 4:return WG(NG,t,MG).call(t),Ll("GetSourceCountAsync",t),r=[],u.prev=7,e&&(t._driverType=e),n=di,i=di,o=di,a=di,t._bRemoteMode?t.__serverPlatform==Gu.enumWindow?o=!0:t.__serverPlatform==Gu.enumLinux?i=!0:t.__serverPlatform==Gu.enumMac?n=!0:t.__serverPlatform==Gu.enumAndroid&&(a=!0):(n=de.bMac,i=de.bLinux,o=de.bWin,a=de.bAndroid),s=Tf(t._driverType,o,i,n,a),u.next=15,this._getDevices(s,!0,void 0);case 15:r=u.sent,u.next=21;break;case 18:throw u.prev=18,u.t0=u["catch"](7),u.t0;case 21:return u.prev=21,Bl("GetSourceCountAsync"),u.finish(21);case 24:return u.abrupt("return",t._setDevices(r));case 25:case"end":return u.stop()}}),S,this,[[7,18,21,24]])}))),function(e){return v.apply(this,arguments)})},{key:"_setDevices",value:function(e){var t,r=this;return r.__devices=e,t=e.length,r.__sourceCount=t,t<=0?(r.__defaultSourceName="",r.__sourceCount=0,0):t}},{key:"_getSourceNameByIndex",value:function(e){var t=this.__devices.length;return e<0||e>=t?"":this.__devices[e].displayName}},{key:"_dwtConvertToBlobSync",value:function(e,t,r,n,i,o){var a=this,s=r,u=",";Zt.isString(s)&&""!=s||(s="",u="");var c=["[",e,',"',t.join(","),'"',u,s,"]"].join(""),l=a._innerFunRaw("ConvertToBlob",c,!1,!0,!1),d="";if(0==a._errorCode){l&&"md5"in l&&(d=l.md5);var f=!0;return Zt.isFunction(n)&&(f=n(l,d,o)),f}return Zt.isFunction(i)&&Wf(i,a),!1}},{key:"_getSourceCountSync",value:function(){var e,t=this,r=di,n=di,i=di,o=di;if(t._bRemoteMode?t.__serverPlatform==Gu.enumWindow?i=!0:t.__serverPlatform==Gu.enumLinux?n=!0:t.__serverPlatform==Gu.enumMac?r=!0:t.__serverPlatform==Gu.enumAndroid&&(o=!0):(r=de.bMac,n=de.bLinux,i=de.bWin,o=de.bAndroid),e=Tf(this._driverType,i,n,r,o),t._resetErr(),!t._isValid())return 0;if(!Ac.checkProductKey(t,{Core:!0}))return 0;WG(NG,t,MG).call(t);var a=t._getSources(e,true,undefined);return t._setDevices(a)}},{key:"_OnActiveUI",value:(p=n(g().mark((function I(e){var r;return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this,e&&e.length>2&&(r.__strProductName=e[2]),n.next=4,l(d(t.prototype),"_OnActiveUI",this).call(this,e);case 4:return n.next=6,r._setConvertModeAsync(r._pdfConvertMode)["catch"]((function(){}));case 6:case"end":return n.stop()}}),I,this)}))),function(e){return p.apply(this,arguments)})},{key:"_OnReady",value:(m=n(g().mark((function b(){var e,r,n,i,o;return g().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return $o((e=this)._serverInfo.server)&&(Od.item("DWT_port",e._serverInfo.port),Od.item("DWT_ssl",e._serverInfo.ssl?"true":"false")),e._bNoMask||Ll("OnReady",e),a.prev=3,a.next=6,l(d(t.prototype),"_OnReady",this).call(this);case 6:if(!Zo()){a.next=12;break}if(e._uuidForActiveUI){a.next=12;break}return a.next=10,rr.DWT.lgcuid(rr.DWT.lgdt(),"");case 10:r=a.sent,e._uuidForActiveUI=r;case 12:return a.next=14,e._innerActiveUI(e._uuidForActiveUI);case 14:return n=a.sent,a.next=17,e._OnActiveUI(n);case 17:if(ju("Changing Map..."),(i=e._id)&&!rr.DWT.WebTwainIdMap[i]&&(rr.DWT.WebTwainIdMap[i]=e),xG(e),o=!1,e._bRemoteMode||(o=Qt.attachAddon(e)),rr.DWT.IfDisableDefaultSettings){a.next=29;break}return ju("Configuring the WebTwain instance..."),a.next=27,UG(e);case 27:a.next=32;break;case 29:if(!o){a.next=32;break}return a.next=32,new ci.Promise((function(e){setTimeout(e,300)}));case 32:a.next=39;break;case 34:throw a.prev=34,a.t0=a["catch"](3),a.t0&&(e._errorCode=a.t0.code,e._errorString=a.t0.message),e.dispose(),a.t0;case 39:return a.prev=39,e._bNoMask||Bl("OnReady"),a.finish(39);case 42:case"end":return a.stop()}}),b,this,[[3,34,39,42]])}))),function(){return m.apply(this,arguments)})},{key:"_OnWSClose",value:function(e){l(d(t.prototype),"_OnWSClose",this).call(this,e),Qt.detect.bOK=!1;this.__bAcquireImageNow=!1}},{key:"_OnWSTimeout",value:function(e){l(d(t.prototype),"_OnWSTimeout",this).call(this,e),Qt.detect.bOK=!1}},{key:"_setConvertModeAsync",value:function(e){var t,r=this,n=1*e;return isNaN(n)?(Ts(r),ci.Promise.reject({code:r._errorCode,message:r._errorString})):r._checkConvertModeInner(n)?(t=this._mixSavedPdfReaderOptions({convertMode:n,renderOptions:{renderAnnotations:!!r._pdfOptions.renderOptions.renderAnnotations}}),r._resetPdfOptionsWhenSetConvertMode(t),WG(NG,r,LG).call(r,t,n)):ci.Promise.reject({code:r._errorCode,message:r._errorString})}},{key:"_OnReconnected",value:(h=n(g().mark((function T(){var e;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this,t.next=3,WG(NG,e,LG).call(e,e._pdfOptions);case 3:case"end":return t.stop()}}),T,this)}))),function(){return h.apply(this,arguments)})},{key:"_getConvertMode",value:function(){return this._pdfConvertMode}},{key:"_setConvertMode",value:function(e){var t,r=this,n=1*e;if(isNaN(n))return Ts(r),!1;if(!r._checkConvertModeInner(n))return!1;t=this._mixSavedPdfReaderOptions({convertMode:n,renderOptions:{renderAnnotations:!!r._pdfOptions.renderOptions.renderAnnotations}}),r._resetPdfOptionsWhenSetConvertMode(t);var i=r._setReaderOptions(t,!1);return i&&(r._pdfConvertMode=n,r._pdfOptions.convertMode=t.convertMode,r._pdfOptions.renderOptions.renderAnnotations=t.renderOptions.renderAnnotations,r._pdfOptions.convertMode==Zu.CM_IMAGEONLY&&r._pdfConvertMode==Zu.CM_RENDERALL||r._pdfOptions.convertMode==Zu.CM_IMAGEONLY&&r._pdfConvertMode==Zu.CM_RENDERALLWITHANNOTATION)?(r._pdfConvertMode=Zu.CM_IMAGEONLY,Da(r),!1):i}},{key:"_checkConvertModeInner",value:function(e){var t=this;return!!Ac.checkProductKey(t,{Core:!0})&&(t._resetErr(),!!t._isValid()&&(e==Zu.CM_RENDERALL||e==Zu.CM_IMAGEONLY||e==Zu.CM_AUTO||e==Zu.CM_RENDERALLWITHANNOTATION||(Ts(t),!1)))}},{key:"_resetPdfOptionsWhenSetConvertMode",value:function(e){var t=e.convertMode;t==Zu.CM_IMAGEONLY||Ac.hasPDFRProductKey(this)?e.convertMode=t:e.convertMode=Zu.CM_IMAGEONLY,e.convertMode==Zu.CM_IMAGEONLY||e.convertMode==Zu.CM_RENDERALL?e.renderOptions.renderAnnotations=!1:e.convertMode==Zu.CM_RENDERALLWITHANNOTATION&&(e.renderOptions.renderAnnotations=!0)}},{key:"_checkPDFPasswordValue",value:function(e){if(!Zt.isUndefined(e)){if(!Zt.isString(e))return na(this,-2852,"The password is not a string."),!1;if(e.length>32)return function(e){na(e,-2851,"The password must not exceed 32 characters in length.")}(this),!1}return!0}},{key:"_mixSavedPdfReaderOptions",value:function(e){var t;return t=Zt.clone(this._pdfOptions),e||(e={}),e.convertMode&&(t.convertMode=e.convertMode),Zt.isString(e.password)?t.password=e.password:Zt.isNumber(e.password)&&(t.password=""+e.password),Zt.isBoolean(e.preserveUnmodifiedOnSave)&&(t.preserveUnmodifiedOnSave=e.preserveUnmodifiedOnSave),e.renderOptions&&(t.renderOptions=Zt.mix(this._pdfOptions.renderOptions,e.renderOptions)),t}},{key:"_setReaderOptions",value:function(e,t){var r,n,i=this,o=-1;if(i._resetErr(),e&&e.renderOptions){var a=e.renderOptions.resolution,s=e.renderOptions.maxWidth,u=e.renderOptions.maxHeight,c=e.renderOptions.renderGrayscale;if(!Zt.isUndefined(a)&&(!rr.Lib.isNumber(a)||a<=0))return na(i,-2830,"The PDF resolution must be a positive number."),!1;if(!Zt.isUndefined(s)&&(!rr.Lib.isNumber(s)||s<0))return function(e){na(e,-2831,"The PDF max width must be a positive number.")}(i),!1;if(!Zt.isUndefined(u)&&(!rr.Lib.isNumber(u)||u<0))return function(e){na(e,-2832,"The PDF max height must be a positive number.")}(i),!1;if(!Zt.isUndefined(c)&&!rr.Lib.isBoolean(c))return function(e){na(e,-2833,"The PDF render grayscale must be a boolean.")}(i),!1}if(t){r={},e||(e={}),e.convertMode?r.convertMode=e.convertMode:r.convertMode=Zu.CM_AUTO,o=r.convertMode,Zt.isString(e.password)?r.password=e.password:Zt.isNumber(e.password)?r.password=""+e.password:r.password="",e.preserveUnmodifiedOnSave?r.preserveUnmodifiedOnSave=!0:r.preserveUnmodifiedOnSave=!1,r.renderOptions=Zt.mix({renderAnnotations:!1,resolution:200,maxWidth:0,maxHeight:0,renderGrayscale:!1},e.renderOptions);var l=r.renderOptions.renderAnnotations;Zt.isBoolean(l)||Zt.isString(l)&&(r.renderOptions.renderAnnotations="true"==l.toLowerCase());var d=r.renderOptions.renderGrayscale;if(Zt.isBoolean(d)||Zt.isString(d)&&(r.renderOptions.renderGrayscale="true"==d.toLowerCase()),Zt.isNumber(r.convertMode)){if(!i._checkConvertModeInner(r.convertMode))return!1;Ac.hasPDFRProductKey(i)||(r.convertMode=Zu.CM_IMAGEONLY),r.convertMode==Zu.CM_IMAGEONLY?r.renderOptions.renderAnnotations=!1:r.convertMode==Zu.CM_RENDERALLWITHANNOTATION&&(r.renderOptions.renderAnnotations=!0)}}else{if(Zt.isUndefined(e))return function(e){na(e,-2834,"The PDF reader options is invalid.")}(i),!1;if(r=e,Zt.isString(e.password)||Zt.isUndefined(e.password));else{if(!Zt.isNumber(e.password))return function(e){na(e,-2829,"The type of the PDF password must be a string.")}(i),!1;e.password=""+e.password}}var f=i._getPdfDllname();n=["[",Zt.stringify(r),',"',f,'"',"]"].join("");var h=i._innerFun("SetPDFReaderOptions",n);return h&&t&&(i._pdfOptions=Zt.clone(r),Zt.isNumber(r.convertMode)&&(r.convertMode==Zu.CM_RENDERALL&&r.renderOptions.renderAnnotations&&(r.convertMode=Zu.CM_RENDERALLWITHANNOTATION),i._pdfConvertMode=r.convertMode,i._pdfOptions.convertMode==Zu.CM_IMAGEONLY&&o==Zu.CM_RENDERALL||i._pdfOptions.convertMode==Zu.CM_IMAGEONLY&&o==Zu.CM_RENDERALLWITHANNOTATION))?(i._pdfConvertMode=Zu.CM_IMAGEONLY,Da(i),!1):h}},{key:"_getPdfDllname",value:function(){var e=this,t=!1,r=!1;return e._bRemoteMode?e.__serverPlatform==Gu.enumWindow||(e.__serverPlatform==Gu.enumLinux?r=!0:e.__serverPlatform==Gu.enumMac&&(t=!0)):(t=de.bMac,r=de.bLinux,de.bWin),t?e._b64bit?"libDMCodecx64.dylib":"libDMCodec.dylib":r?"libDMCodec.so":e._b64bit?"DMCodecx64.dll":"DMCodec.dll"}},{key:"_unload_viewer",value:function(){}},{key:"__innerDeleteInMap",value:function(){return this._id,delete rr.DWT.WebTwainIdMap[this._id],fi}},{key:"__unload",value:(c=n(g().mark((function C(){var e,t,r,n;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(e=this,t=Zt.clone(rr.DWT.licenseException),e.__closeRemoteScanUI(!0),!e._destroy&&!e._destroying){i.next=5;break}return i.abrupt("return");case 5:if(e._destroying=!0,this.__innerDeleteInMap(),e.__addon&&e.__addon.Camera&&e.__addon.Camera._viewer&&(""!=e.__addon.Camera.getStatus()&&e.__addon.Camera.closeSource()["catch"]((function(){})),e.__addon.Camera._viewer.dispose(),e.__addon.Camera._viewer=null),e._unload_viewer(),e._containerElement=null,e._ImgManager&&e._ImgManager.clear(),!e._bReady||Qt.page.bUnload){i.next=20;break}if(!e._wsClient){i.next=20;break}return i.prev=13,i.next=16,e._innerDisposeWSClient();case 16:i.next=20;break;case 18:i.prev=18,i.t0=i["catch"](13);case 20:if(!e._wsClient){i.next=34;break}return e._wsClient.removeEvent("close",e._clientId),e._wsClient.removeEvent("error",e._clientId),e._wsClient.removeEvent("timeout",e._clientId),i.prev=24,i.next=27,e._wsClient.dispose();case 27:i.next=32;break;case 29:i.prev=29,i.t1=i["catch"](24),r=i.t1;case 32:delete e._wsClient,e._wsClient=null;case 34:if(e._bReady=!1,rr.DWT.lremoveDWTObj(e),e.__bAcquireImageNow=!1,e._destroying=!1,e._destroy=!0,(n=rr.DWT.licenseException).code=t.code,n.message=t.message,n.fromLTS=t.fromLTS,!r){i.next=45;break}throw r;case 45:case"end":return i.stop()}}),C,this,[[13,18],[24,29]])}))),function(){return c.apply(this,arguments)})},{key:"_setIfShowUI",value:function(e){this._resetErr(),this._isValid()&&(Zt.isBoolean(e)?this._innerFun("IfShowUI",El(e)):la(self))}},{key:"_setIfShowFileDialog",value:function(e){this._resetErr(),this._isValid()&&(Zt.isBoolean(e)?this._innerFun("IfShowFileDialog",El(e)):la(self))}},{key:"_getDevicesAsync",value:(u=n(g().mark((function w(e,t,r,n){var i,o,a,s,u;return g().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:if(i=this,o=[],!t||Zt.isNumber(t)){c.next=4;break}return Ka(i),c.abrupt("return",ci.Promise.reject({code:i._errorCode,message:i._errorString}));case 4:if(a=i._bRemoteMode?Pl:de.bAndroid?Fl:Pl,s=null!=t?t:a,i._resetErr(),i._isValid()){c.next=8;break}return c.abrupt("return",ci.Promise.reject({code:i._errorCode,message:i._errorString}));case 8:return Ll(e,i),c.prev=9,c.next=12,i._getDevices(s,r,n);case 12:u=c.sent,Zt.isArray(u)&&u.length>0&&(o=o.concat(u)),c.next=19;break;case 16:throw c.prev=16,c.t0=c["catch"](9),c.t0;case 19:return c.prev=19,Bl(e),c.finish(19);case 22:return o.length>0&&this._setDevices(o),c.abrupt("return",o);case 24:case"end":return c.stop()}}),w,this,[[9,16,19,22]])}))),function(e,t,r,n){return u.apply(this,arguments)})},{key:"_openSourceAsync",value:function(e){var t=this;return t._resetErr(),t._isValid()?(t._bRemoteMode&&t._initRemoteDiv(),t._innerFunV2("OpenSource").then((function(e){return t.__closeRemoteScanUI(!0),e}),(function(e){return t.__closeRemoteScanUI(!0),ci.Promise.reject(e)}))):ci.Promise.reject({code:t._errorCode,message:t._errorString})}},{key:"_closeSourceAsync",value:function(e){var t=this;return t._resetErr(),t._isValid()?t._innerFunV2("CloseSource").then((function(){return t._curDevice=null,!0})):ci.Promise.reject({code:t._errorCode,message:t._errorString})}},{key:"_selectSourceAsync",value:function(e,t,r){var n=this;return n._resetErr(),n._isValid()?n._getDevicesAsync(e,t).then((function(t){var i,o,a=document,s=t?t.length:0;ci.dialog.selectsourcedlg&&(ci.dialog.selectsourcedlg.close(),document.body.removeChild(ci.dialog.selectsourcedlg),ci.dialog.selectsourcedlg=!1);var u,c,l,d,f=-1;for((o=a.createElement("dialog")).className="dynamsoft-dialog-selectsource",de.bIE&&(o.style.width="300px"),o.setAttribute("closed","closed"),(u=[]).push('
    '),i=0;i'+g+"")}return u.push("
"),u=u.join(""),Zt.isArray(r)&&r.length>=3?(c=r[0],l=r[1],d=r[2]):(c="Select Source:",l="Select",d="Cancel"),DG(o,["

",c,"

",'
',u,"
",'
','
'].join("")),ci.dialog.selectsourcedlg=o,a.body.appendChild(ci.dialog.selectsourcedlg),Zt.each(Zt.sizzle(".dynamsoft-dialog-selectsource-item"),(function(e,t){Zt.addEventListener(e,"click",(function(e){for(var t=e.target,r=t.getAttribute("sourceindex"),n=t.parentElement.children,i=0;i0&&Zt.addEventListener(ci.one(".dynamsoft-dialog-selectsource-button-select")[0],"click",(function(){var r=parseInt(Zt.get("dynamsoft-dialog-selectsource-sourcelist-ul").getAttribute("selectedSourceIndex"));r<0||n._selectSourceByIndexAsync(e,r).then((function(){ci.dialog.selectsourcedlg&&(ci.dialog.selectsourcedlg.close(),document.body.removeChild(ci.dialog.selectsourcedlg),ci.dialog.selectsourcedlg=!1),t(r)}))})),Zt.addEventListener(ci.one(".dynamsoft-dialog-selectsource-button-cancel")[0],"click",(function(){ci.dialog.selectsourcedlg&&(ci.dialog.selectsourcedlg.close(),document.body.removeChild(ci.dialog.selectsourcedlg),ci.dialog.selectsourcedlg=!1);var e={};as(e),r({code:e._errorCode,message:e._errorString})}))}))})):ci.Promise.reject({code:n._errorCode,message:n._errorString})}},{key:"_dwtGetCapabilities",value:function(e,t,r){var n=this,i=null,o=function(){Zt.isFunction(r)&&r(n._errorCode,n._errorString)};if(e){if(!Zt.isArray(e))return Ka(n),void o();if(0==e.length)return void(Zt.isFunction(t)&&t([]));if(!1===function(e,t){var r,n,i,o;for(o=0;o65535)&&(i=!0):n=!0,n)return Ka(e),!1;if(i)return Cs(e),!1}return!0}(n,e))return void o();i=El(e)}n._sendDataByHttpAsync("GetCapabilities",i).then((function(e){try{var r,i;e.length>0&&(i=e[0]),Zt.isString(i)?(i=Qt.removeNonPrintableChar(i),0==(r=JSON.parse(i)).errorCode?Zt.isFunction(t)&&t(r.response):(n._errorCode=r.errorCode,n._errorString=r.errorString,o())):(gs(n),o())}catch(a){n._errorCode=-2302,n._errorString=a,o()}}),o)}},{key:"_dwtSetCapabilities",value:function(e,t,r){var n=this;if(!Zt.isObject(e)||Zt.isArray(e))return Ka(n),Zt.isFunction(r)&&r(n._errorCode,n._getErrorString()),!1;var i=["[",Zt.stringify(e),"]"].join("");return n._innerSend("SetCapabilities",i,0,(function(e){Zt.isFunction(t)&&t(e)}),r),!0}},{key:"_selectDeviceAsync",value:(a=n(g().mark((function E(e,r,n){var i,o;return g().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return i=this,Ll(e,this),a.prev=2,a.next=5,l(d(t.prototype),"_innerSelectDeviceAsync",this).call(this,r,n);case 5:(o=a.sent)&&(i._curDevice=r,i._bSelectedSourceByServer=!1),a.next=12;break;case 9:throw a.prev=9,a.t0=a["catch"](2),a.t0;case 12:return a.prev=12,Bl(e),a.finish(12);case 15:return a.abrupt("return",o);case 16:case"end":return a.stop()}}),E,this,[[2,9,12,15]])}))),function(e,t,r){return a.apply(this,arguments)})},{key:"_selectSourceByIndexAsync",value:(r=n(g().mark((function k(e,t){var r,n,i;return g().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(n=1*t,(r=this)._resetErr(),r._isValid()){o.next=4;break}return o.abrupt("return",ci.Promise.reject({code:r._errorCode,message:r._errorString}));case 4:if(!Zt.isNaN(n)){o.next=7;break}return ca(r),o.abrupt("return",ci.Promise.reject({code:r._errorCode,message:r._errorString}));case 7:if(r.__devices){o.next=10;break}return o.next=10,r._getDevicesAsync(e,null);case 10:if(!(n<0||n>=r.__devices.length)){o.next=13;break}return Oa(r),o.abrupt("return",ci.Promise.reject({code:r._errorCode,message:r._errorString}));case 13:return i=r.__devices[n],o.abrupt("return",r._selectDeviceAsync(e,i));case 15:case"end":return o.stop()}}),k,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_removeAllImages",value:function(e){var t=this,r=!0;if(t._resetErr(),!t._isValid())return!1;var n,i=[];for(n=t._getHowManyImagesInBuffer()-1;n>=0;n--){var o=t._imageBufferWrapper.convertClientIndexToServerId(n);o>-1&&i.push(o)}if(i.length>0){if(t._OnBitmapChanged(["c1",i.join(","),3,t._ImgManager.getCurrentImageIndex(),t._ImgManager.count()]),r=t._innerFunRaw("RemoveAllImages",El(i.join(",")),!1,!1,!1,(function(){}),(function(){})),Zt.isArray(r))return r[0]}else r=!0;return r}},{key:"_removeImage",value:function(e,t){var r,n=this,i=parseInt(t);if(!xf(n,i))return!1;var o=n._ImgManager.convertClientIndexToServerId(i);return-1==o?(Oa(n),!1):(((r=n._innerFun("RemoveImage",El(o)))||-1033==n._errorCode)&&n._OnBitmapChanged(["c1",""+o,3,n._ImgManager.getCurrentImageIndex(),n._ImgManager.count()]),r)}},{key:"__innerAcquireOrLoadImageAsync",value:function(e,t,r,n){var i=this;return new ci.Promise((function(r,n){var o="LoadImage"==e||"LoadImageEx"==e||"GenerateURLForUploadData"==e,a=o||"LoadDibFromClipboard"==e;o?Qt.showProgress(i,e,!1):Ll(e,i),i._innerSend(e,t,!0,(function(t){if(i.__bLoadingImage=!1,i.__bOpenFileNow=!1,i.__closeRemoteScanUI(!0),o){if(Qt.closeProgress(null,e),i._isBindViewer()){var n=i._ImgManager.getCurrentImageIndex();n>=0&&i._innerRefreshUI(n)}}else Bl(e);a&&i._canConsume()&&rr.DWT.lcvrf(i),Zt.isFunction(r)&&r(t)}),(function(t){o?Qt.closeProgress(null,""):Bl(e),i.__bLoadingImage=!1,i.__bAcquireImageNow=!1,i.__bOpenFileNow=!1,i.__closeRemoteScanUI(!0);var r=i._ImgManager.getCurrentImageIndex();r>=0&&i._innerRefreshUI(r),Ks(i._errorCode)&&Da(i),Zt.isFunction(n)&&n({code:i._errorCode,message:i._getErrorString()}),o?Qt.closeProgress(null,e):Bl(e),t&&Zt.error(t)}))}))}},{key:"_innerLoadImageFromBinary",value:function(e,t,r,n,i,o){var a,s,u=this,c=t;if(!Ac.checkProductKey(u,{Core:!0}))return Zt.isFunction(o)&&o(u._errorCode,u._getErrorString()),!1;if(!e||""==e)return Ea(u),Zt.isFunction(o)&&o(u._errorCode,u._getErrorString()),!1;if(Zt.isString(e))return Ka(u),Zt.isFunction(o)&&o(u._errorCode,u._getErrorString()),!1;if(e instanceof Blob)s=e.size;else if(kl(e))s=e.byteLength;else if(e instanceof Array)s=e.length;else{var l=e;s=l.size||l.byteLength||l.length}if(!s||""==s)return Ka(u),Zt.isFunction(o)&&o(u._errorCode,u._getErrorString()),!1;var d=e.currentFileName;d||(d=u._getCurrentDocumentName());var f,h=e.currentTagName;if(h||!Zt.isUndefined(e.bNeedClearCurrentTagName)&&e.bNeedClearCurrentTagName||(h=u._getCurrentDefaultTagName()),e instanceof FileList){if(1==e.length)return e[0].currentFileName=d,e[0].currentTagName=h,u._innerLoadImageFromBinary(e[0],c,r,i,o);if(e.length>1){var g;for(Zt.asyncQueue.stop(),g=0;gt&&-1!=t?(wa(n),!1):e}),(function(e){return!1}))}function MG(){this.__defaultSourceName="",this.__sourceCount=0}function LG(e,t){var r=this,n=r._getPdfDllname(),i=["[",Zt.stringify(e),',"',n,'"',"]"].join("");return r._innerFunV2("SetPDFReaderOptions",i).then((function(){if(Zt.isNumber(t)&&(r._pdfConvertMode=t),r._pdfOptions.convertMode=e.convertMode,r._pdfOptions.renderOptions.renderAnnotations=e.renderOptions.renderAnnotations,r._pdfOptions.preserveUnmodifiedOnSave=e.preserveUnmodifiedOnSave,r._pdfOptions.convertMode==Zu.CM_IMAGEONLY&&r._pdfConvertMode==Zu.CM_RENDERALL||r._pdfOptions.convertMode==Zu.CM_IMAGEONLY&&r._pdfConvertMode==Zu.CM_RENDERALLWITHANNOTATION)throw r._pdfConvertMode=Zu.CM_IMAGEONLY,Da(r),{code:r._errorCode,message:r._errorString};return!0}))}var BG=function(e,t){if(Lo.bDiscardBlankImage){var r=e._ImgManager.getCurrentImageIndex();e.IsBlankImage(r)&&e.RemoveImage(r);var n=["Blank Discard (",t,"): ",e.ErrorString].join("");Zt.isFunction(e.__OnPrintMsg)&&e.__OnPrintMsg(n)}};function UG(e){return VG.apply(this,arguments)}function VG(){return(VG=n(g().mark((function e(t){var r,n,i,o;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t,!rr.DWT.ConnectWithSocket){e.next=6;break}return e.next=4,new ci.Promise((function(e,t){r._sendData("IfDisableSourceAfterAcquire","[1]",!1,e,t)}));case 4:e.next=8;break;case 6:return e.next=8,t._innerFunV2("IfDisableSourceAfterAcquire","[1]");case 8:n=If.TWAIN,i=!1,o=!1,r._bRemoteMode?r.__serverPlatform==Gu.enumWindow||(r.__serverPlatform==Gu.enumLinux?o=!0:r.__serverPlatform==Gu.enumMac&&(i=!0)):(i=de.bMac,o=de.bLinux,de.bWin),i?n=If.TWAIN_AND_ICA:o&&(n=If.SANE),t._driverType=n,t._bRemoteMode&&(t._setIfShowUI(!1),t._setIfShowFileDialog(!1));case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function jG(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function GG(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var HG=new WeakSet,zG=function(e){function t(){var e;o(this,t);for(var r=arguments.length,n=new Array(r),a=0;a=100&&e.loaded0||0==m)){t instanceof File?t.fileName=r:t.name=r,n&&pG(f.__IfShowCancelDialogWhenImageTransfer);var i=new vG,c=f._createHttpUploaderConfig(),l=new _G;return f.__remoteFilename&&""!=f.__remoteFilename&&(l.remoteFilename=f.__remoteFilename),c.objUploadStatus=s,l.url=e,l.method=g,l.content=t,t=null,l.contentType=f._strHttpContentTypeFieldValue,l.headers=h,l.bAsync=m,l.httpFormData=ZG(f.httpFormFields),l.retry=o,l.bOnlyResponseEmptyIsOK=a,l.blockSize=f._moduleSize,i.httpPostUpload(c,l,(function(e){return n&&Qt.closeProgress(null,g),Zt.isFunction(u)&&Ff(u,e),!0}),p)}return ka(f),p(f._errorCode,f._errorString),!1}),p),m?void 0:!!d):(ka(f),p(f._errorCode,f._errorString),!!m&&void 0)}},{key:"_innerUploadFilesDirectly",value:function(e,t,r,n,i,o,a,s,u){var c,l=this,d=l._GetHttpHeadersAndClear(),f="HTTPUploadThroughPostDirectly",h=!1,g=[];if(Zt.isFunction(s)&&(h=!0),!1===e||""===e)return Ea(l),Zt.isFunction(u)&&u({code:l._errorCode,message:l._getErrorString(),files:t}),!1;if(!Ac.checkProductKey(l,{Core:!0}))return Zt.isFunction(u)&&u({code:l._errorCode,message:l._getErrorString(),files:t}),!1;Qt.cancelFrom=sG.HTTPUpload;var m=function(e,r,i){return 0!=e&&r&&(l._errorCode=e,l._errorString=r),i&&(l.__HTTPPostResponseString=i),Qt.needShowTwiceShowDialog=!1,n&&Qt.closeProgress(null,f),Zt.isFunction(u)&&u({code:l._errorCode,message:l._errorString,response:i,files:t}),!1};Qt.needShowTwiceShowDialog=!0,n?Qt.showProgress(l,f,!1):Qt.hideProgress(),Zt.each(t,(function(e){var t=bf.replaceLocalFilename(e);if(!t||""==t)return ka(l),m(l._errorCode,l._errorString),!1;g.push(t)}));var p=[],v=g.length,_=0;return Zt.each(g,(function(t,u){c=GG(HG,l,JG).call(l,t,h,i,(function(t){if(Qt.needShowTwiceShowDialog=!1,!t||n&&!(n&&Qt.dlgRef>0)&&0!=h)return n&&Qt.closeProgress(null,f),ya(l),Zt.isFunction(m)&&m(l._errorCode,l._errorString),!1;var i=fG(r,u+1);if(t instanceof File?t.fileName=i:t.name=i,p[u]=t,t=null,++_==v){n&&pG(l.__IfShowCancelDialogWhenImageTransfer);var c=l._createHttpUploaderConfig(),g=new _G;l.__remoteFilename&&""!=l.__remoteFilename&&(g.remoteFilename=l.__remoteFilename),g.url=e,g.method=f,g.content=p,p=null,g.contentType=l._strHttpContentTypeFieldValue,g.headers=d,g.bAsync=h,g.httpFormData=ZG(l.httpFormFields),g.retry=o,g.bOnlyResponseEmptyIsOK=a,g.blockSize=l._moduleSize;var y=mG(c,g,(function(e){return n&&Qt.closeProgress(null,f),Zt.isFunction(s)&&Ff(s,e),!0}),(function(e,t,r){return n&&Qt.closeProgress(null,f),Zt.isFunction(m)&&m(e,t,r),!1}));return h?void 0:y}}),(function(){return n&&Qt.closeProgress(null,f),Zt.isFunction(m)&&m(),!1}))})),h?void 0:!!c}},{key:"_createHttpUploaderConfig",value:function(){var e=this,t=new yG;return t.IfShowProgressBar=e.IfShowProgressBar,t.IfShowCancelDialogWhenImageTransfer=e.__IfShowCancelDialogWhenImageTransfer,t.MaxUploadImageSize=e.MaxUploadImageSize,t.HTTPRequestswithCredentials=e.HTTPRequestswithCredentials,t.onPercent=function(t){e._OnPercentDone(t)},t.onHttpUploadStatus=function(t){Zt.isFunction(e.__OnHttpUploadStatus)&&e.__OnHttpUploadStatus(t)},t}},{key:"SetUploadSegment",value:function(e,t){var r=this;return r._resetErr(),!!r._isValid()&&(!Zt.isNumber(e)||e<0?(na(r,-2367,"Invalid value for the parameter segmentUploadThreshold."),!1):!Zt.isNumber(t)||t<=0?(function(e){na(e,-2368,"Invalid value for the parameter moduleSize.")}(r),!1):(r._segementUploadThreshold=1024*e*1024,r._moduleSize=1024*t,!0))}},{key:"ConvertToBase64",value:function(e,t,r,n){var i,o=this,a=arguments,s=!1;if(Zt.isFunction(r)&&(s=!0),o._resetErr(),!o._isValid())return Zt.isFunction(n)&&Nf(n,o,e,t,a),!!s&&void 0;var u=parseInt(t);if(!Ac.checkProductKey(o,{Core:!0}))return Zt.isFunction(n)&&Nf(n,o,e,t,a),!!s&&void 0;if(!o._checkIndices(e))return Zt.isFunction(n)&&Nf(n,o,e,t,a),!!s&&void 0;if(u==rr.DWT.EnumDWT_ImageType.IT_BMP||u==rr.DWT.EnumDWT_ImageType.IT_JPG||u==rr.DWT.EnumDWT_ImageType.IT_PNG){if(e.length>1)return na(o,-2361,"You cannot convert more than one image to base64 string when the format is BMP, JPG or PNG."),Zt.isFunction(n)&&Nf(n,o,e,t,a),!!s&&void 0}else if(u!=rr.DWT.EnumDWT_ImageType.IT_TIF&&u!=rr.DWT.EnumDWT_ImageType.IT_PDF)return La(o),Zt.isFunction(n)&&Nf(n,o,e,t,a),!!s&&void 0;if(0==(i=Df(o,e)).length)return ca(o),Zt.isFunction(n)&&Nf(n,o,e,t,a),!!s&&void 0;Qt.cancelFrom=sG.ConvertToBlob,o._convertToBase64ByServerIdsWithUI("ConvertToBase64",i,u,!1,3,(function(e){var n=[];Zt.isArray(i)&&Zt.each(i,(function(e){var t=o._ImgManager.convertServerIdToClientIndex(e);t>-1&&n.push(t)})),Zt.isFunction(r)&&Ff(r,e,n,t,a)}),(function(){var e=[];Zt.isArray(i)&&Zt.each(i,(function(t){var r=o._ImgManager.convertServerIdToClientIndex(t);r>-1&&e.push(r)})),Zt.isFunction(n)&&Nf(n,o,e,t,a)}))}},{key:"ClearAllHTTPFormField",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&(e.httpFormFields={},!0)}},{key:"SetHTTPFormField",value:function(e,t,r){var n=this;if(n._resetErr(),!n._isValid())return!1;var i=e;return Zt.isString(i)||(i=""+i),t instanceof Blob&&(t.name=r),n.httpFormFields[i]=t,!0}},{key:"HTTPDownloadThroughPost",value:function(e,t,r,n,i,o){var a,s,u=this,c=u._GetHttpHeadersAndClear(),l=bf.combineUrl(u,e,t),d=!1;if(Zt.isFunction(n)&&(d=!0),l===undefined)return Ea(u),Zt.isFunction(i)&&Wf(i,u,""),!!d&&void 0;if(!Ac.checkProductKey(u,{Core:!0}))return Zt.isFunction(i)&&Wf(i,u,""),!!d&&void 0;if(!Ac.checkPDFProductKeyWhenNeeds(u,r))return Zt.isFunction(i)&&Wf(i,u,""),!!d&&void 0;Qt.cancelFrom=sG.HTTPDownload,u.IfShowProgressBar?Qt.showProgress(u,"HttpDownloadThroughPost",!1):Qt.hideProgress();u._OnPercentDone([0,-1,ul.Downloading,"http"]);var f=null===(a=Qt.progressContext)||void 0===a?void 0:a.IfShowCancelDialogWhenImageTransfer,h=function(){return u.IfShowProgressBar&&Qt.closeProgress(null,"HttpDownloadThroughPost"),Zt.isFunction(n)&&n(),!0},g=function(){return Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=f),u.IfShowProgressBar&&Qt.closeProgress(null,"HttpDownloadThroughPost"),Zt.isFunction(i)&&Wf(i,u,u.__HTTPPostResponseString),!1};return Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=!0),s=bf.loadHttpBlob(u,"post",l,d,(function(e){Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=f),u._OnPercentDone([0,-1,ul.Loading]);var t=r;t!=rr.DWT.EnumDWT_ImageType.IT_BMP&&t!=rr.DWT.EnumDWT_ImageType.IT_JPG&&t!=rr.DWT.EnumDWT_ImageType.IT_TIF&&t!=rr.DWT.EnumDWT_ImageType.IT_PNG&&t!=rr.DWT.EnumDWT_ImageType.IT_PDF&&t!=rr.DWT.EnumDWT_ImageType.IT_J2K&&(t=-1);var n=u.__GetLoadEventsNum();return u.__LoadImageFromBytesV1(e,t,"",n,d,h,g)}),g,(function(e){var t=0===e.total?100:Math.round(100*e.loaded/e.total);[e.loaded," / ",e.total].join(""),t>=100&&e.loaded=0))return Oa(a),m(),!!l&&void 0}if(""===e)return pa(a),m(),!!l&&void 0;var v=[];Zt.isArray(d)&&Zt.each(d,(function(e){var t=a._ImgManager.convertClientIndexToServerId(e);-1!=t&&v.push(t)}));var _=!1;a._OnPercentDone([0,-1,ul.Encoding,"http"]);var y=function(e,t,o){if(rr.DWT.IfAddMD5InUploadHeader&&t&&""!=t&&(s["dwt-md5"]=t),Qt.needShowTwiceShowDialog=!1,e&&(!h||h&&Qt.dlgRef>0||0==l)){var d=a.__maxUploadImageSize;return e.size>d&&-1!=d?(wa(a),m(),!!l&&void 0):(g=function(e){var t=0===e.total?100:Math.round(100*e.loaded/e.total);[e.loaded," / ",e.total].join(""),t>=100&&e.loaded-1&&t.push(r)})),Ff(i,a.__HTTPPostResponseString,t,r,n)}return!0}),m,g),e=null,l?void 0:!!f)}return e=null,h&&Qt.closeProgress(null,u),!!l&&void 0};if(!l)return a._dwtConvertToBlobSync(n,v,_,y,m);a._convertToBlobForUpload(n,v,_,4,y,m)}},{key:"HTTPUploadAllThroughPutAsMultiPageTIFF",value:function(e,t,r,n){return this.HTTPUploadThroughPutEx(e,-1,t,2,r,n)}},{key:"HTTPUploadThroughPutAsMultiPageTIFF",value:function(e,t,r,n){return this.HTTPUploadThroughPutEx(e,-2,t,2,r,n)}},{key:"HTTPUploadAllThroughPutAsPDF",value:function(e,t,r,n){return this.HTTPUploadThroughPutEx(e,-1,t,4,r,n)}},{key:"HTTPUploadThroughPutAsMultiPagePDF",value:function(e,t,r,n){return this.HTTPUploadThroughPutEx(e,-2,t,4,r,n)}},{key:"GetSelectedImagesSize",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return!1;var r=kf(t);return t._innerFun("GetSelectedImagesSize",El(e,r.join(",")))}},{key:"SetHTTPHeader",value:function(e,t){var r=this;if(r._resetErr(),!r._isValid())return!1;var n,i,o=e;if(r.__httpHeaderMap||(r.__httpHeaderMap={}),!o||!Zt.isString(o))return Zt.isUndefined(o)?na(r,-2356,"The header name cannot be undefined."):""===o?function(e){na(e,-2354,"The header name cannot be empty.")}(r):null===o?function(e){na(e,-2355,"The header name cannot be null.")}(r):function(e){na(e,-2357,"The header name you entered is invalid.")}(r),!1;for(n=["if-none-match","if-range","range","accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"],o=o.toLowerCase(),i=0;i-1&&i.push(t)})),0!=e&&r&&(f._errorCode=e,f._errorString=r),n&&(f.__HTTPPostResponseString=n),f._bServerPercentDone=!0,Qt.needShowTwiceShowDialog=!1,s&&Qt.closeProgress(null,g),p.slice(0),p=null,Zt.isFunction(d))try{d({code:f._errorCode,message:f._errorString,response:n,indices:i})}catch(o){}};Qt.needShowTwiceShowDialog=!0,s?Qt.showProgress(f,g,!1):Qt.hideProgress();var _=t.length,y=0,S=0,I="";f._bServerPercentDone=!1,f._OnPercentDone([0,-1,ul.Encoding,"http"]),Zt.each(t,(function(e,i){f._convertToBlobForUpload(h,[e],a,4,(function(e,a,d){if(!e||e.size<=0)return Ta(f),v(f._errorCode,f._errorString);var h=f.__maxUploadImageSize;if(e.size>h&&-1!=h)return wa(f),v(f._errorCode,f._errorString);var b=fG(o,i+1);if(S=(y+1)/_*100,I=[y+1,"/",_].join(""),f._OnPercentDone([0,S,I,"http",b]),e.name=b,p.push(e),++y>=_){rr.DWT.IfAddMD5InUploadHeader&&a&&""!=a&&(r["dwt-md5"]=a);var T=f._createHttpUploaderConfig(),C=new _G;f.__remoteFilename&&""!=f.__remoteFilename&&(C.remoteFilename=f.__remoteFilename),C.url=m,C.method=g,C.content=p,C.contentType=f._strHttpContentTypeFieldValue,C.headers=r,C.httpFormData=n,C.retry=u,C.bOnlyResponseEmptyIsOK=c,C.blockSize=f._moduleSize,mG(T,C,(function(e){f.__HTTPPostResponseString=T.HTTPPostResponse,function(e){if(f._bServerPercentDone=!0,Qt.needShowTwiceShowDialog=!1,s&&Qt.closeProgress(null,g),p.slice(0),p=null,Zt.isFunction(l)){var r=[];Zt.isArray(t)&&Zt.each(t,(function(e){var t=f._ImgManager.convertServerIdToClientIndex(e);t>-1&&r.push(t)})),Ff(l,e,r)}}(e)}),v)}e=null}),v,[e,i])}))}},{key:"_getVersionInfoAsync",value:function(){return qo.versionInfoFromServer?ci.Promise.resolve(qo.versionInfoFromServer):this._innerFunV2("VersionInfo")}},{key:"__innerLoadImage",value:function(e,t,r,n,i,o,a){var s=this,u=!1;if((Zt.isFunction(o)||rr.DWT.ConnectWithSocket)&&(u=!0),!Ac.checkProductKey(s,{Core:!0}))return Zt.isFunction(a)&&a({code:s._errorCode,message:s._getErrorString()}),!!u&&void 0;if(!Ac.checkPDFProductKeyWhenNeeds(s,r))return Zt.isFunction(a)&&a({code:s._errorCode,message:s._getErrorString()}),!!u&&void 0;if(r==Wd.IT_MULTIPAGE_PDF||r==Wd.IT_MULTIPAGE_TIF)return La(s),Zt.isFunction(a)&&a({code:s._errorCode,message:s._getErrorString()}),!!u&&void 0;if(u){if(s._bRemoteMode&&s._getIfShowFileDialog())return is(s),void(Zt.isFunction(a)&&a({code:s._errorCode,message:s._getErrorString()}));var c=rr.DWT.IfConfineMaskWithinTheViewer;s.Viewer&&s.Viewer.webViewer&&s.Viewer.webViewer.imageEditor&&s.Viewer.webViewer.imageEditor.inner&&1==s.Viewer.webViewer.imageEditor.inner.bShowImageEditor&&s.Viewer.webViewer.imageEditor.inner.bShowImageEditor&&(rr.DWT.IfConfineMaskWithinTheViewer=!1);var l=s.IfShowCancelDialogWhenImageTransfer;return s.IfShowCancelDialogWhenImageTransfer=!1,void s.__innerAcquireOrLoadImageAsync(e,t,n,!0).then((function(){s.IfShowCancelDialogWhenImageTransfer=l,rr.DWT.IfConfineMaskWithinTheViewer=c,Zt.isFunction(o)&&o()}),(function(e){s.IfShowCancelDialogWhenImageTransfer=l,rr.DWT.IfConfineMaskWithinTheViewer=c,s._errorCode=e.code,s._errorString=e.message,Zt.isFunction(a)&&a(e)}))}if(s._bRemoteMode&&s._getIfShowFileDialog())return is(s),!1;var d=s._getCurrentDocumentName(),f=s._getCurrentDefaultTagName();return s.__innerLoadImageFun(e,t,i,d,f)}},{key:"__innerLoadImageFun",value:function(e,t,r,n,i){var o,a=this,s=!0;if(o=a._innerFunRaw(e,t,!1,!1,!0),a.__bOpenFileNow=!1,0!=a._errorCode)return!1;if(o&&Zt.isArray(o.result)&&o.result.length>0){if(r){var u;if("FTPDownload"==e||"FTPDownloadEx"==e)u=JSON.stringify(o.result);else{var c=o.result[0];Zt.isObject(c)?u=c.imageInfos:-1!=c||"LoadImage"!=e&&"LoadImageEx"!=e&&"LoadImageFromBase64Binary"!=e&&"LoadDibFromClipboard"!=e||(s=!1)}Zt.isString(u)&&a._handleOnBitmapChangedEvent({result:["c1",u]},{document:n,tag:i})}else{var l=o.result.join(",");a._OnBitmapChanged(["c1",l,1,a._ImgManager.getCurrentImageIndex(),a._ImgManager.count()],null,{document:n,tag:i})}if(s)return a._canConsume()&&rr.DWT.lcvrf(a),!0}return Ks(a._errorCode)&&Da(a),!1}},{key:"__innerSaveImage",value:function(e,t,r,n){var i,o=this,a=!1;if(Zt.isFunction(r)&&(a=!0),a&&o._OnPercentDone([0,-1,ul.Encoding]),o._bRemoteMode||(rr.DWT.IfAlwaysFocusOnPopupWindow?o._OnPageFocus(!0):o._OnPageBlur(!0)),0==a)return o._bRemoteMode?o._serviceSyncMethodNotSupport(e):this._innerFun(e,t);if(o._bRemoteMode&&o._getIfShowFileDialog())return is(o),void(Zt.isFunction(n)&&n(o._errorCode,o._getErrorString()));var s=null===(i=Qt.progressContext)||void 0===i?void 0:i.IfShowCancelDialogWhenImageTransfer;o.IfShowProgressBar?Qt.showProgress(o,e,!1):Qt.hideProgress(),Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=!1),o._innerSend(e,t,!0,(function(){a&&("SaveAsPNG"!=e&&"SaveAsJPEG"!=e&&"SaveAsBMP"!=e&&"SaveAsBMP"!=e||o._OnPercentDone([0,100,"","http"])),Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=s),setTimeout((function(){Qt.closeProgress(null,e)}),0),Zt.isFunction(r)&&r()}),(function(t){return Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=s),Zt.isFunction(n)&&n(o._errorCode,o._getErrorString()),Qt.closeProgress(null,e),t&&Zt.error(t),!1}))}},{key:"__captureImage",value:function(e,t,r,n){var i=this.__GetLoadEventsNum();return this.__LoadImageFromBytesV2(e,t,"",!0,0,0,!0,i,r,n)}},{key:"_getIfShowFileDialog",value:function(){return this._resetErr(),this._isValid()?this._innerFun("IfShowFileDialog"):di}},{key:"SaveAsBMP",value:function(e,t,r,n){var i=this,o=!1;if((Zt.isFunction(r)||de.bAndroid)&&(o=!0),i._resetErr(),!i._isValid())return Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;if(!(Ac.checkProductKey(i,{Core:!0})||de.bWin&&Ac.checkProductKey(i,{Webcam:!0},!0)))return Ac.checkProductKey(i,{Core:!0},!1),Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;var a,s=bf.replaceLocalFilename(e);if(!Ef(i,t,n))return!!o&&void 0;if(de.bAndroid){if(0==i._ImgManager.count())return da(i),void(Zt.isFunction(n)&&Wf(n,i));var u=[];return u.push(t),void i._saveImages("SaveAsBMP",s,u,Wd.IT_BMP).then((function(){Zt.isFunction(r)&&r()}))["catch"]((function(e){Zt.isFunction(n)&&n(e.code,e.message)}))}if(-1==(a=i._ImgManager.convertClientIndexToServerId(t)))return Oa(i),Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;var c=i.__GetLoadEventsNum(),l=i.__innerSaveImage("SaveAsBMP",El(s,a,c),r,n);return o?void 0:l}},{key:"SaveAsJPEG",value:function(e,t,r,n){var i=this,o=!1;if((Zt.isFunction(r)||de.bAndroid)&&(o=!0),i._resetErr(),!i._isValid())return Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;if(!(Ac.checkProductKey(i,{Core:!0})||de.bWin&&Ac.checkProductKey(i,{Webcam:!0},!0)))return Ac.checkProductKey(i,{Core:!0},!1),Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;if(!Ef(i,t,n))return!!o&&void 0;var a,s=bf.replaceLocalFilename(e);if(de.bAndroid){if(0==i._ImgManager.count())return da(i),void(Zt.isFunction(n)&&Wf(n,i));var u=[];return u.push(t),void i._saveImages("SaveAsJPEG",s,u,Wd.IT_JPG).then((function(){Zt.isFunction(r)&&r()}))["catch"]((function(e){Zt.isFunction(n)&&n(e.code,e.message)}))}if(-1==(a=i._ImgManager.convertClientIndexToServerId(t)))return Oa(i),Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;var c=i.__GetLoadEventsNum(),l=i.__innerSaveImage("SaveAsJPEG",El(s,a,c),r,n);return o?void 0:l}},{key:"SaveAsPDF",value:function(e,t,r,n){var i=this,o=!1;if((Zt.isFunction(r)||de.bAndroid)&&(o=!0),i._resetErr(),!i._isValid())return Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;if(!(Ac.checkProductKey(i,{Core:!0})||de.bWin&&Ac.checkProductKey(i,{Webcam:!0},!0)))return Ac.checkProductKey(i,{Core:!0},!1),Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;if(!Ef(i,t,n))return!!o&&void 0;var a,s=bf.replaceLocalFilename(e);if(de.bAndroid){if(0==i._ImgManager.count())return da(i),void(Zt.isFunction(n)&&Wf(n,i));var u=[];return u.push(t),void i._saveImages("SaveSelectedImagesAsMultiPagePDF",s,u,Wd.IT_PDF).then((function(){Zt.isFunction(r)&&r()}))["catch"]((function(e){Zt.isFunction(n)&&n(e.code,e.message)}))}if(-1==(a=i._ImgManager.convertClientIndexToServerId(t)))return Oa(i),Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;var c=[a],l=i.__GetLoadEventsNum(),d=i.__innerSaveImage("SaveSelectedImagesAsMultiPagePDF",El(s,c.join(","),l),r,n);return o?void 0:d}},{key:"SaveAsPNG",value:function(e,t,r,n){var i=this,o=!1;if((Zt.isFunction(r)||de.bAndroid)&&(o=!0),i._resetErr(),!i._isValid())return Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;if(!(Ac.checkProductKey(i,{Core:!0})||de.bWin&&Ac.checkProductKey(i,{Webcam:!0},!0)))return Ac.checkProductKey(i,{Core:!0},!1),Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;if(!Ef(i,t,n))return!!o&&void 0;var a,s=bf.replaceLocalFilename(e);if(de.bAndroid){if(0==i._ImgManager.count())return da(i),void(Zt.isFunction(n)&&Wf(n,i));var u=[];return u.push(t),void i._saveImages("SaveAsPNG",s,u,Wd.IT_PNG).then((function(){Zt.isFunction(r)&&r()}))["catch"]((function(e){Zt.isFunction(n)&&n(e.code,e.message)}))}if(-1==(a=i._ImgManager.convertClientIndexToServerId(t)))return Oa(i),Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;var c=i.__GetLoadEventsNum(),l=i.__innerSaveImage("SaveAsPNG",El(s,a,c),r,n);return o?void 0:l}},{key:"SaveAsTIFF",value:function(e,t,r,n){var i=this,o=!1;if((Zt.isFunction(r)||de.bAndroid)&&(o=!0),i._resetErr(),!i._isValid())return Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;if(!(Ac.checkProductKey(i,{Core:!0})||de.bWin&&Ac.checkProductKey(i,{Webcam:!0},!0)))return Ac.checkProductKey(i,{Core:!0},!1),Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;if(!Ef(i,t,n))return!!o&&void 0;var a,s=bf.replaceLocalFilename(e);if(de.bAndroid){if(0==i._ImgManager.count())return da(i),void(Zt.isFunction(n)&&Wf(n,i));var u=[];return u.push(t),void i._saveImages("SaveAsTIFF",s,u,Wd.IT_TIF).then((function(){Zt.isFunction(r)&&r()}))["catch"]((function(e){Zt.isFunction(n)&&n(e.code,e.message)}))}if(-1==(a=i._ImgManager.convertClientIndexToServerId(t)))return Oa(i),Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;var c=i.__GetLoadEventsNum(),l=i.__innerSaveImage("SaveAsTIFF",El(s,a,c),r,n);return o?void 0:l}},{key:"SaveSelectedImagesAsMultiPagePDF",value:function(e,t,r){var n=this,i=!1;if((Zt.isFunction(t)||de.bAndroid)&&(i=!0),n._resetErr(),!n._isValid())return Zt.isFunction(r)&&Wf(r,n),!!i&&void 0;if(!(Ac.checkProductKey(n,{Core:!0})||de.bWin&&Ac.checkProductKey(n,{Webcam:!0},!0)))return Ac.checkProductKey(n,{Core:!0},!1),Zt.isFunction(r)&&Wf(r,n),!!i&&void 0;var o=bf.replaceLocalFilename(e);if(!de.bAndroid){var a=kf(n);if(0==a.length)return da(n),Zt.isFunction(r)&&Wf(r,n),!!i&&void 0;var s=n.__GetLoadEventsNum(),u=n.__innerSaveImage("SaveSelectedImagesAsMultiPagePDF",El(o,a.join(","),s),t,r);return i?void 0:u}if(0==n._ImgManager.count())return da(n),void(Zt.isFunction(r)&&Wf(r,n));var c=Af(n);n._saveImages("SaveSelectedImagesAsMultiPagePDF",o,c,Wd.IT_PDF).then((function(){Zt.isFunction(t)&&t()}))["catch"]((function(e){Zt.isFunction(r)&&r(e.code,e.message)}))}},{key:"SaveSelectedImagesAsMultiPageTIFF",value:function(e,t,r){var n=this,i=!1;if((Zt.isFunction(t)||de.bAndroid)&&(i=!0),n._resetErr(),!n._isValid())return Zt.isFunction(r)&&Wf(r,n),!!i&&void 0;if(!(Ac.checkProductKey(n,{Core:!0})||de.bWin&&Ac.checkProductKey(n,{Webcam:!0},!0)))return Ac.checkProductKey(n,{Core:!0},!1),Zt.isFunction(r)&&Wf(r,n),!!i&&void 0;var o=bf.replaceLocalFilename(e);if(!de.bAndroid){var a=kf(n);if(0==a.length)return da(n),Zt.isFunction(r)&&Wf(r,n),!!i&&void 0;var s=n.__GetLoadEventsNum(),u=n.__innerSaveImage("SaveSelectedImagesAsMultiPageTIFF",El(o,a.join(","),s),t,r);return i?void 0:u}if(0==n._ImgManager.count())return da(n),void(Zt.isFunction(r)&&Wf(r,n));var c=Af(n);n._saveImages("SaveSelectedImagesAsMultiPageTIFF",o,c,Wd.IT_TIF).then((function(){Zt.isFunction(t)&&t()}))["catch"]((function(e){Zt.isFunction(r)&&r(e.code,e.message)}))}},{key:"SaveAllAsMultiPageTIFF",value:function(e,t,r){var n=this,i=!1;if((Zt.isFunction(t)||de.bAndroid)&&(i=!0),n._resetErr(),!n._isValid())return Zt.isFunction(r)&&Wf(r,n),!!i&&void 0;if(!(Ac.checkProductKey(n,{Core:!0})||de.bWin&&Ac.checkProductKey(n,{Webcam:!0},!0)))return Ac.checkProductKey(n,{Core:!0},!1),Zt.isFunction(r)&&Wf(r,n),!!i&&void 0;if(!wf(n,r))return!!i&&void 0;var o=[],a=bf.replaceLocalFilename(e);if(!de.bAndroid){if(Cf(n,o),0==o.length)return da(n),Zt.isFunction(r)&&Wf(r,n),!!i&&void 0;var s=n.__GetLoadEventsNum(),u=n.__innerSaveImage("SaveSelectedImagesAsMultiPageTIFF",El(a,o.join(","),s),t,r);return i?void 0:u}if(0==n._ImgManager.count())return da(n),void(Zt.isFunction(r)&&Wf(r,n));for(var c=[],l=0;l5&&(d=arguments[5])),s._isValid()){var f,h=arguments,g=function(e){Zt.isFunction(d)&&Nf(d,s,s.__HTTPPostResponseString,e,h)};if(Zt.isUndefined(e)||""===e)return Ea(s),void(g&&g(t));if(!Zt.isString(e))return Ua(s),void(g&&g(t));if(s._checkIndices(t)){var m=Df(s,t);if(0==m.length)return ca(s),void(g&&g(t));if(Zt.isUndefined(r))return La(s),void(g&&g(t));if(r==rr.DWT.EnumDWT_ImageType.IT_BMP||r==rr.DWT.EnumDWT_ImageType.IT_JPG||r==rr.DWT.EnumDWT_ImageType.IT_PNG){if(m.length>1)return Fa(s),void g(t)}else if(r!=rr.DWT.EnumDWT_ImageType.IT_TIF&&r!=rr.DWT.EnumDWT_ImageType.IT_PDF)return La(s),void g(t);if(Zt.isUndefined(n)||n!=rr.DWT.EnumDWT_UploadDataFormat.Binary&&n!=rr.DWT.EnumDWT_UploadDataFormat.Base64)return Ba(s),void g(t);f={method:"HTTPUpload",url:e,serverIds:m,headers:c,formData:ZG(s.httpFormFields),enumImageType:r,saveSetup:!1,dataFormat:n,fileName:u,retry:0,bOnlyResponseEmptyIsOK:!0,objUploadFileStatus:!1,asyncSuccessFunc:function(e,t){Zt.isFunction(l)&&Ff(l,s.__HTTPPostResponseString,t,h)},asyncFailureFunc:g},this._asyncUploadCmd(f)}else g&&g(t)}else Zt.isFunction(d)&&Wf(d,s,"")}},{key:"_innerFormFieldHTTPUpload",value:function(e,t,r,n){var i,o=this,a="HTTPUpload",s=e,u=o.IfShowProgressBar;if(o._isValid()){if(Zt.isUndefined(s)||""===s)return Ea(o),void(Zt.isFunction(n)&&Wf(n,o,""));if(!Zt.isString(s))return Ua(o),void(Zt.isFunction(n)&&Wf(n,o,""));0!=s.indexOf("http://")&&0!=s.indexOf("https://")&&(s=Qt.detect.ssl?"https://"+s:"http://"+s),o.__HTTPPostResponseString="",Qt.cancelFrom=sG.HTTPUpload,i=function(e,t,r){0!=e&&t&&(o._errorCode=e,o._errorString=t),r&&(o.__HTTPPostResponseString=r),Qt.needShowTwiceShowDialog=!1,Qt.closeProgress(null,a),Zt.isFunction(n)&&Wf(n,o,o.__HTTPPostResponseString)},u?Qt.showProgress(o,a,!1):Qt.hideProgress(),Qt.needShowTwiceShowDialog=!0,o._OnPercentDone([0,-1,ul.Uploading,"http"]);var c=o._createHttpUploaderConfig(),l=new _G;o.__remoteFilename&&""!=o.__remoteFilename&&(l.remoteFilename=o.__remoteFilename),l.url=s,l.method=a,l.content=[],l.headers=t,l.httpFormData=ZG(o.httpFormFields),l.blockSize=o._moduleSize,(new vG).httpPostUpload(c,l,(function(t){Qt.needShowTwiceShowDialog=!1,Qt.closeProgress(null,a),Zt.isFunction(r)&&Ff(r,t,e,[e,r,n])}),i)}else Zt.isFunction(n)&&Wf(n,o,"")}},{key:"HTTPUploadThroughPost",value:function(e,t,r,n,i,o,a){var s=this,u=!1;if(Zt.isFunction(i)&&(u=!0),s._resetErr(),!s._isValid())return!!u&&void 0;var c=bf.getImageType(n),l=arguments,d=!1,f=function(e){return Zt.isFunction(o)&&Nf(o,s,s.__HTTPPostResponseString,e,l),!1};return Zt.isString(n)&&""!=n?(i&&Zt.isFunction(i)&&(d=function(e,t){return Ff(i,s.__HTTPPostResponseString,t,l),!0}),XG(s,t,c,f)?GG(HG,s,KG).call(s,e,t,r,n,c,d,f,a):!!u&&void 0):(Ta(s),f(),!!u&&void 0)}},{key:"HTTPUploadThroughPostEx",value:function(e,t,r,n,i,o,a,s){var u=this,c=!1;if(Zt.isFunction(o)&&(c=!0),u._resetErr(),!u._isValid())return Zt.isFunction(a)&&Nf(a,u,""),!!c&&void 0;var l=arguments,d=!1,f=function(e){Zt.isFunction(a)&&Nf(a,u,u.__HTTPPostResponseString,e,l)};return Zt.isString(n)&&""!=n?(o&&Zt.isFunction(o)&&(d=function(e,t){Ff(o,u.__HTTPPostResponseString,t,l)}),XG(u,t,i,f)?GG(HG,u,KG).call(u,e,t,r,n,i,d,f,s):!!c&&void 0):(Ta(u),f(),!!c&&void 0)}},{key:"HTTPUploadAllThroughPostAsMultiPageTIFF",value:function(e,t,r,n,i,o){var a=this,s=!1;if(Zt.isFunction(n)&&(s=!0),a._resetErr(),!a._isValid())return Zt.isFunction(i)&&Nf(i,a,""),!!s&&void 0;var u=arguments,c=!1,l=function(e){Zt.isFunction(i)&&Nf(i,a,a.__HTTPPostResponseString,e,u)};return Zt.isString(r)&&""!=r?(s&&(c=function(e,t){Ff(n,a.__HTTPPostResponseString,t,u)}),GG(HG,a,KG).call(a,e,-1,t,r,2,c,l,o)):(Ta(a),l(),!!s&&void 0)}},{key:"HTTPUploadAllThroughPostAsPDF",value:function(e,t,r,n,i,o){var a=this,s=!1;if(Zt.isFunction(n)&&(s=!0),a._resetErr(),!a._isValid())return Zt.isFunction(i)&&Wf(i,a,""),!!s&&void 0;var u=arguments,c=!1,l=function(e){return Zt.isFunction(i)&&Nf(i,a,a.__HTTPPostResponseString,e,u),!1};return Zt.isString(r)&&""!=r?(s&&(c=function(e,t){Ff(n,a.__HTTPPostResponseString,t,u)}),GG(HG,a,KG).call(a,e,-1,t,r,4,c,l,o)):(Ta(a),l())}},{key:"HTTPUploadThroughPostAsMultiPagePDF",value:function(e,t,r,n,i,o){var a=this,s=!1;if(Zt.isFunction(n)&&(s=!0),a._resetErr(),!a._isValid())return Zt.isFunction(i)&&Wf(i,a,""),!!s&&void 0;var u=arguments,c=!1,l=function(e){Zt.isFunction(i)&&Nf(i,a,a.__HTTPPostResponseString,e,u)};return Zt.isString(r)&&""!=r?(s&&(c=function(e,t){Ff(n,a.__HTTPPostResponseString,t,u)}),GG(HG,a,KG).call(a,e,-2,t,r,4,c,l,o)):(Ta(a),l(),!!s&&void 0)}},{key:"HTTPUploadThroughPostAsMultiPageTIFF",value:function(e,t,r,n,i,o){var a=this,s=!1;if(Zt.isFunction(n)&&(s=!0),a._resetErr(),!a._isValid())return Zt.isFunction(i)&&Wf(i,a,""),!!s&&void 0;var u=arguments,c=!1,l=function(e){Zt.isFunction(i)&&Nf(i,a,a.__HTTPPostResponseString,e,u)};return Zt.isString(r)&&""!=r?(s&&(c=function(e,t){Ff(n,a.__HTTPPostResponseString,t,u)}),GG(HG,a,KG).call(a,e,-2,t,r,2,c,l,o)):(Ta(a),l(),!!s&&void 0)}},{key:"_innerHTTPDownloadThroughGet",value:function(e,t,r,n,i,o){var a,s,u=this,c=u._GetHttpHeadersAndClear(),l=u.IfShowProgressBar,d=bf.combineUrl(u,t,r),f=!1;if(Zt.isFunction(i)&&(f=!0),d===undefined)return Ea(u),Zt.isFunction(o)&&Wf(o,u),!!f&&void 0;if(!Ac.checkProductKey(u,{Core:!0}))return Zt.isFunction(o)&&Wf(o,u),!!f&&void 0;if(!Ac.checkPDFProductKeyWhenNeeds(u,n))return Zt.isFunction(o)&&Wf(o,u),!!f&&void 0;Qt.cancelFrom=sG.HTTPDownload;var h=null===(a=Qt.progressContext)||void 0===a?void 0:a.IfShowCancelDialogWhenImageTransfer,g=u._getCurrentDocumentName(),m=u._getCurrentDefaultTagName();return Zt.log("_innerHTTPDownloadThroughGet.currentFileName:"+g+", tag="+m),l&&f?(u.__IfShowCancelDialogWhenImageTransfer&&(Qt.progressContext.__cancelBeforObjectCreated=!0),Qt.showProgress(u,e,u.__IfShowCancelDialogWhenImageTransfer)):f&&Qt.hideProgress(),u._OnPercentDone([0,-1,ul.Downloading,"http"]),s=bf.loadHttpBlob(u,"get",d,f,(function(t){Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=h),l&&f&&pG(!1),u._OnPercentDone([0,-1,ul.Loading]);var r=n;r!=rr.DWT.EnumDWT_ImageType.IT_BMP&&r!=rr.DWT.EnumDWT_ImageType.IT_JPG&&r!=rr.DWT.EnumDWT_ImageType.IT_TIF&&r!=rr.DWT.EnumDWT_ImageType.IT_PNG&&r!=rr.DWT.EnumDWT_ImageType.IT_PDF&&r!=rr.DWT.EnumDWT_ImageType.IT_J2K&&(r=-1),t.currentFileName=g,t.currentTagName=m;var a=u.__GetLoadEventsNum();return u.__LoadImageFromBytesV1(t,r,"",a,f,(function(){return l&&f&&Qt.closeProgress(null,e),Zt.isFunction(i)&&i(),!0}),(function(){return l&&f&&Qt.closeProgress(null,e),Zt.isFunction(o)&&Wf(o,u),!1}))}),(function(){return Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=h),l&&f&&Qt.closeProgress(null,e),Zt.isFunction(o)&&Wf(o,u),!1}),(function(e){var t=0===e.total?100:Math.round(100*e.loaded/e.total);[e.loaded," / ",e.total].join(""),t>=100&&e.loaded0&&this._stwain.LoadImageFromBinary(this.files,s,u),this.value="",this._stwain=null,g&&g.parentElement.removeChild(g)},g.onchange=function(){this.files.length>0&&this._stwain.LoadImageFromBinary(this.files,s,u),this.value="",this._stwain=null,g&&g.parentElement.removeChild(g)},document.body.appendChild(g),g.click()}else t==rr.DWT.EnumDWT_ImageType.IT_BMP?h[0].setAttribute("accept","image/bmp"):t==rr.DWT.EnumDWT_ImageType.IT_JPG?h[0].setAttribute("accept","image/jpeg"):t==rr.DWT.EnumDWT_ImageType.IT_TIF?h[0].setAttribute("accept","image/tiff"):t==rr.DWT.EnumDWT_ImageType.IT_PNG?h[0].setAttribute("accept","image/png"):t==rr.DWT.EnumDWT_ImageType.IT_PDF?h[0].setAttribute("accept",".pdf"):t==rr.DWT.EnumDWT_ImageType.IT_J2K?h[0].setAttribute("accept",".jp2,.j2k,.j2c"):Lo.bMobile?h[0].setAttribute("accept","image/jpeg,image/png,image/tiff,image/tif"):h[0].setAttribute("accept","image/*,.pdf,.jp2,.j2k,.j2c"),h[0].value="",h[0]._stwain=i,h[0].click()}},{key:"HTTPDownload",value:function(e,t,r,n){var i=this,o=!1;if(Zt.isFunction(r)&&(o=!0),i._resetErr(),!i._isValid())return Zt.isFunction(n)&&Wf(n,i),!!o&&void 0;var a=bf.getImageType(t);return i._innerHTTPDownloadThroughGet("HTTPDownload",e,t,a,r,n)}},{key:"HTTPDownloadEx",value:function(e,t,r,n,i){var o=this,a=!1;return Zt.isFunction(n)&&(a=!0),o._resetErr(),o._isValid()?o._innerHTTPDownloadThroughGet("HTTPDownloadEx",e,t,r,n,i):(Zt.isFunction(i)&&Wf(i,o),!!a&&void 0)}},{key:"getFormateDate",value:function(){var e=new Date,t=e.getFullYear(),r=e.getMonth()+1,n=e.getDate(),i=e.getHours(),o=e.getMinutes(),a=e.getSeconds();return r<=9&&(r="0"+r),n<=9&&(n="0"+n),i<=9&&(i="0"+i),o<=9&&(o="0"+o),a<=9&&(a="0"+a),{currentTime_title:t+"-"+r+"-"+n+" "+i+":"+o+":"+a,currentTime_info:r+"/"+n+"/"+t+" "+i+":"+o+":"+a}}},{key:"__shareImagesInner",value:function(e,t,r,n){var i=navigator;i.canShare&&i.canShare({files:e})&&i.share({files:e,title:t,text:this.getFormateDate().currentTime_info}).then((function(){Zt.isFunction(r)&&r()}))["catch"]((function(e){Zt.isFunction(n)&&n(e)}))}},{key:"ShareImages",value:(r=n(g().mark((function a(e,t,r){var n,i,o,s,u,c,l,d,f;return g().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(n=this,!de.bAndroid){a.next=38;break}if(r!=Wd.IT_ALL&&r!=Wd.IT_MULTIPAGE_PDF&&r!=Wd.IT_MULTIPAGE_TIF){a.next=5;break}throw ds(n),{code:n._errorCode,message:n._errorString};case 5:if(i=t.sort((function(e,t){return e-t})),!(i.length>0)){a.next=36;break}if(o="IMAGE File",r==Wd.IT_PDF&&(o="PDF File"),s=hG(e,r),Zt.isUndefined(s)&&(s=e),r!=Wd.IT_PDF&&r!=Wd.IT_TIF){a.next=15;break}return a.abrupt("return",new ci.Promise((function(e,t){n.ConvertToBlob(i,r,(function(r,i,a){var u=[new File([r],s,{type:r.type})];n.__shareImagesInner(u,o,(function(){e()}),(function(e){t({code:0!=e.code?e.code:2201,message:e.message})}))}),(function(){t({code:n._errorCode,message:n._errorString})}))})));case 15:u=[],c=s,a.t0=r,a.next=a.t0===Wd.IT_BMP?20:a.t0===Wd.IT_JPG?22:a.t0===Wd.IT_PNG?24:26;break;case 20:return l=".bmp",a.abrupt("break",27);case 22:return l=".jpg",a.abrupt("break",27);case 24:return l=".png",a.abrupt("break",27);case 26:l=".jpg";case 27:s&&s.lastIndexOf(".")>0&&(c=s.substring(0,s.lastIndexOf(".")),l=s.substring(s.lastIndexOf("."),s.length)),d=g().mark((function h(e){return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new ci.Promise((function(t,o){n.ConvertToBlob([i[e]],r,(function(r,n,i){0==e?u.push(new File([r],c+l,{type:r.type})):u.push(new File([r],c+e+l,{type:r.type})),t()}),(function(){o({code:n._errorCode,message:n._errorString})}))}));case 2:case"end":return t.stop()}}),h)})),f=0;case 30:if(!(f-1&&o.push(t)})),0!=e&&t&&(n._errorCode=e,n._errorString=t),r&&(n.__HTTPPostResponseString=r),Zt.isFunction(a))try{a(o)}catch(c){}return!1};return Zt.isNumber(v)&&v>0||(v=0),0!=n._errorCode?S(n._errorCode,n._errorString,n.__HTTPPostResponseString):(n.__HTTPPostResponseString="",n.IfShowCancelDialogWhenImageTransfer=!0,Qt.progressContext.IfShowCancelDialogWhenImageTransfer=n.IfShowCancelDialogWhenImageTransfer,t._innerHTTPUpload(n,c,i,d,f,l,h,g,m,p,v,_,y,(function(e){if(n.IfShowCancelDialogWhenImageTransfer=s,Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=u),Zt.isFunction(o)){var t=[];Zt.isArray(l)&&Zt.each(l,(function(e){var r=n._ImgManager.convertServerIdToClientIndex(e);r>-1&&t.push(r)}));try{Ff(o,e,t)}catch(r){}e=null}return!0}),S))}}],[{key:"_innerHTTPUpload",value:function(e,t,r,n,i,o,a,s,u,c,l,d,f,h,g){var m=parseInt(a),p=parseInt(s),v=u,_=r,y=e._segementUploadThreshold;if(Zt.isUndefined(a))return La(e),Zt.isFunction(g)&&g(e._errorCode,e._errorString,""),!1;e._resetErr(),Qt.cancelFrom=sG.HTTPUpload;var S,I=function(r,n,i,o){return 0!=r&&n&&(e._errorCode=r,e._errorString=n),i&&(e.__HTTPPostResponseString=i),Qt.needShowTwiceShowDialog=!1,e.IfShowProgressBar&&Qt.closeProgress(null,t),Zt.isFunction(g)&&g(e._errorCode,e._errorString,e.__HTTPPostResponseString,o),!1},b=e._createHttpUploaderConfig();if(b.objUploadStatus=f,v=hG(v,m),Qt.needShowTwiceShowDialog=!0,e.IfShowProgressBar?(Qt.showProgress(e,t,!1),Qt.progressContext&&(Qt.progressContext._onPercent=function(e){var t=0;if(e){var r,n;r=e.loaded,n=e.total,(t=Math.floor(r/n*100))>100&&(t=100)}Qt.progressBarOnPercentDone(-1,"Transferring...","",t,"")})):Qt.hideProgress(),p==rr.DWT.EnumDWT_UploadDataFormat.Binary){if(f&&f.bCancel)return f.st=2,as(e),I(e._errorCode,e._errorString);e._OnPercentDone([0,-1,ul.Encoding,"http"]),e._convertToBlobForUpload(m,o,c,4,(function(r,o,a){if(S=function(r){return Qt.needShowTwiceShowDialog=!1,e.IfShowProgressBar&&Qt.closeProgress(null,t),Zt.isFunction(h)&&Ff(h,r),!0},f&&f.bCancel)return f.st=2,as(e),I(e._errorCode,e._errorString);if(!r||r.size<=0)return Ta(e),I(e._errorCode,e._errorString);var s=e.__maxUploadImageSize;if(r.size>s&&-1!=s)return wa(e),I(e._errorCode,e._errorString);if(0!=e._errorCode)return I(e._errorCode,e._errorString);if(rr.DWT.IfAddMD5InUploadHeader&&o&&""!=o&&(n["dwt-md5"]=o),y>0&&r.size>y){e._OnPercentDone([0,-1,ul.Uploading,"http",v]);var u=new vG,c=new _G;return e.__remoteFilename&&""!=e.__remoteFilename&&(c.remoteFilename=e.__remoteFilename),c.url=_,c.method=t,c.content=r,r=null,c.contentType=e._strHttpContentTypeFieldValue,c.headers=n,c.fileName=v,c.httpFormData=i,c.retry=l,c.bOnlyResponseEmptyIsOK=d,c.blockSize=e._moduleSize,u.httpPostUploadFragment(b,c,S,I)}var g=new vG,m=new _G;e.__remoteFilename&&""!=e.__remoteFilename&&(m.remoteFilename=e.__remoteFilename),m.url=_,m.method=t,m.content=r,r=null,m.contentType=e._strHttpContentTypeFieldValue,m.headers=n,m.fileName=v,m.httpFormData=i,m.retry=l,m.bOnlyResponseEmptyIsOK=d,m.blockSize=e._moduleSize,b.objUploadStatus=f,g.httpPostUpload(b,m,S,I)}),I)}else if(p==rr.DWT.EnumDWT_UploadDataFormat.Base64){e._convertToBase64ByServerIdsWithUI(t,o,m,c,4,(function(r){var o;if(!r||r.getLength()<=0)return Ta(e),I(e._errorCode,e._errorString);if(S=function(){return Qt.needShowTwiceShowDialog=!1,e.IfShowProgressBar&&Qt.closeProgress(null,t),Zt.isFunction(h)&&Ff(h,r),!0},y>0&&r.getLength()>y){o=r.getMD5(),rr.DWT.IfAddMD5InUploadHeader&&(n["dwt-md5"]=o),e._OnPercentDone([0,-1,ul.Uploading,"http"]);var a=new _G;e.__remoteFilename&&""!=e.__remoteFilename&&(a.remoteFilename=e.__remoteFilename),a.url=_,a.method=t,a.content=r.getData(0,r.getLength()),a.headers=n,a.fileName=v,a.httpFormData=i,a.retry=l,a.bOnlyResponseEmptyIsOK=d,a.blockSize=e._moduleSize,a.offset=0,(new vG).httpPostUploadFragment(b,a,S,I)}else{var s;if(o=r.getMD5(),rr.DWT.IfAddMD5InUploadHeader&&(n["dwt-md5"]=o),!(s=r.getData(0,r.getLength()))||""==s)return Ta(e),I(e._errorCode,e._errorString);var u=new _G;e.__remoteFilename&&""!=e.__remoteFilename&&(u.remoteFilename=e.__remoteFilename),u.url=_,u.method=t,u.content=s,u.headers=n,u.fileName=v,u.httpFormData=i,u.retry=l,u.bOnlyResponseEmptyIsOK=d,u.blockSize=e._moduleSize,(new vG).httpPostUpload(b,u,S,I)}}),I)}}}]);var r}(RG);function KG(e,t,r,n,i,o,a,s){var u,c,l=this,d="HTTPUploadThroughPostEx",f=l._GetHttpHeadersAndClear(),h=bf.combineUrl(l,e,r),g=[],m=function(e){Zt.isFunction(a)&&a(e)},p=!1,v=!1;if(Zt.isFunction(o)&&(v=!0),l.__HTTPPostResponseString="",Zt.isNumber(t)){if(t<-2)return Oa(l),m(t),!!v&&void 0}else if(!Zt.isArray(t))return Oa(l),m(t),!!v&&void 0;if(!Zt.isString(n)||""==n)return Ta(l),m(),!!v&&void 0;if(Zt.isUndefined(i))return La(l),m(t),!!v&&void 0;if(i==rr.DWT.EnumDWT_ImageType.IT_BMP||i==rr.DWT.EnumDWT_ImageType.IT_JPG||i==rr.DWT.EnumDWT_ImageType.IT_PNG||i==rr.DWT.EnumDWT_ImageType.IT_J2K){if(-1==t&&l._ImgManager.count()>1||Zt.isArray(t)&&t.length>1)return Fa(l),m(t),!!v&&void 0;Zt.isArray(t)?g.push(t[0]):-1==t?g.push(0):g.push(t)}else{if(i!=rr.DWT.EnumDWT_ImageType.IT_TIF&&i!=rr.DWT.EnumDWT_ImageType.IT_PDF)return La(l),m(t),!!v&&void 0;if(-1==t){if(0==l._ImgManager.count())return da(l),m(),!!v&&void 0;for(c=0;cr&&-1!=r)return wa(l),S(l._errorCode,l._errorString),!1;rr.DWT.IfAddMD5InUploadHeader&&t&&""!=t&&(f["dwt-md5"]=t),e instanceof File?e.fileName=n:e.name=n,y&&pG(l.__IfShowCancelDialogWhenImageTransfer);var i=l._createHttpUploaderConfig(),o=new _G;return l.__remoteFilename&&""!=l.__remoteFilename&&(o.remoteFilename=l.__remoteFilename),o.url=h,o.method=d,o.content=e,o.contentType=l._strHttpContentTypeFieldValue,o.headers=f,o.bAsync=!1,o.httpFormData=ZG(l.httpFormFields),o.blockSize=l._moduleSize,(new vG).httpPostUpload(i,o,(function(e){return y&&Qt.closeProgress(null,d),e}),S)}var a={};return ya(a),S(a._errorCode,a._errorString),!1}),S)}u={method:"HTTPUploadThroughPostEx",url:h,serverIds:_,headers:f,formData:ZG(l.httpFormFields),enumImageType:i,saveSetup:p,fileName:n,retry:0,bOnlyResponseEmptyIsOK:!0,objUploadFileStatus:!1,dataFormat:rr.DWT.EnumDWT_UploadDataFormat.Binary,asyncSuccessFunc:o,asyncFailureFunc:m},this._asyncUploadCmd(u)}function JG(e,t,r,n,i){var o=this,a=!0;if(t)return o._innerFunRaw("SaveSelectedImagesToBytes",El(0,0,e,r),t,a,!0,(function(e){if(Zt.isFunction(n)){var t=new Blob([e],{type:o._strHttpContentTypeFieldValue});n(t),t=null}}),i),!0;var s=o._innerFunRaw("SaveSelectedImagesToBytes",El(0,0,e,r),t,a,!1);if(0==o._errorCode){var u=n(s);return s=null,u}return s=null,i(),!1}function QG(){return this._resetErr(),!!this._isValid()&&(this._innerSend("SetCancel",null,!0),!0)}function qG(e,t,r,n,i){var o=this;if(!Zt.isFunction(n))return this._innerFun(e,t);o.IfShowProgressBar?(Qt.showProgress(o,e,r),r&&Qt.progressContext&&Qt.progressContext.on("cancel",(function(){GG(HG,o,QG).call(o)}))):Qt.hideProgress(),this._innerSend(e,t,!0,(function(){Qt.closeProgress(null,e),Zt.isFunction(n)&&n()}),(function(t){Zt.isFunction(i)&&i(o._errorCode,o._getErrorString()),Qt.closeProgress(null,e),t&&Zt.error(t)}))}function YG(e,t,r,n,i){var o,a=this,s=!1;if(Zt.isFunction(n)&&(s=!0),!Ac.checkProductKey(a,{Core:!0}))return Zt.isFunction(i)&&Wf(i,a),!!s&&void 0;if(!Ac.checkPDFProductKeyWhenNeeds(a,r))return Zt.isFunction(i)&&Wf(i,a),!!s&&void 0;if(Qt.cancelFrom=sG.FTPDownload,!s){var u=a._getCurrentDocumentName(),c=a._getCurrentDefaultTagName();(o=a.__innerLoadImageFun(e,t,1,u,c))&&a._canConsume()&&rr.DWT.lcvrf(a);var l=a._ImgManager.getCurrentImageIndex();return l>=0&&a._innerRefreshUI(l),o}GG(HG,a,qG).call(a,e,t,!0,(function(){var e=a._ImgManager.getCurrentImageIndex();e>=0&&a._innerRefreshUI(e),a._canConsume()&&rr.DWT.lcvrf(a),Zt.isFunction(n)&&n()}),i)}function XG(e,t,r,n){if(0==e._ImgManager.count())return da(e),Zt.isFunction(n)&&n(t),!1;if(Zt.isNumber(t)){if(isNaN(t)||t<-2||t>=e._ImgManager.count())return Oa(e),Zt.isFunction(n)&&n(t),!1}else{if(!Zt.isArray(t))return Oa(e),Zt.isFunction(n)&&n(t),!1;var i;for(i=0;i=e._ImgManager.count())return Wa(e),Zt.isFunction(n)&&n(t),!1}}if(r==rr.DWT.EnumDWT_ImageType.IT_BMP||r==rr.DWT.EnumDWT_ImageType.IT_JPG||r==rr.DWT.EnumDWT_ImageType.IT_PNG||r==rr.DWT.EnumDWT_ImageType.IT_J2K)(-1==t&&e._ImgManager.count()>1||Zt.isArray(t)&&t.length>1)&&(Fa(e),Zt.isFunction(n)&&n(t));else if(r!=rr.DWT.EnumDWT_ImageType.IT_TIF&&r!=rr.DWT.EnumDWT_ImageType.IT_PDF)return La(e),Zt.isFunction(n)&&n(t),!1;return!0}function ZG(e){var t;return e&&(t=new FormData,Zt.each(e,(function(e,r){if(e instanceof Blob){var n=e.name;t.append(r,e,n)}else t.append(r,e)}))),t}var $G=function(e){function t(){return o(this,t),i(this,t,arguments)}return f(t,e),s(t,[{key:"Viewer",get:function(){return this._viewer}},{key:"BindViewer",value:function(e){var t=this,r=e;return rr.DWT.UseDefaultViewer?(Zt.isString(e)&&(r=Zt.get(e),Zt.show(r)),t._config.container!=r&&(t._config.container=r,xG(t)),t._UIView.BindView(e)):(na(t,-2439,"You cannot call the method bindViewer() when Dynamsoft.DWT.UseDefaultViewer is set to false."),!1)}},{key:"UnbindViewer",value:function(){return this._innerUnbindViewer(!1)}},{key:"AddText",value:function(e,t,r,n,i,o,a,s){var u=this,c=parseInt(e);if(!xf(u,c))return!1;var l=li.RGB2BGR(i),d=li.RGB2BGR(o),f=u._ImgManager.convertClientIndexToServerId(c);return-1==f?(Oa(u),!1):u._innerFun("AddText",El(f,t,r,n,l,d,a,s))}},{key:"CreateTextFont",value:function(e,t,r,n,i,o,a,s,u,c,l,d,f,h){return this._resetErr(),!!this._isValid()&&this._innerFun("CreateTextFont",El(e,t,r,n,i,o,a,s,u,c,l,d,f,h))}},{key:"CopyToClipboard",value:function(e){var t=parseInt(e);return!!xf(this,t)&&eH(this,"CopyToClipboard",t,null,null,!1,!1)}},{key:"CopyToClipboardAsync",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return ci.Promise.reject({code:t._errorCode,message:t._errorString});var r=parseInt(e);return isNaN(r)?(ca(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):r<0||r>=t._ImgManager.count()?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):function(e,t,r){var n=e._ImgManager.convertClientIndexToServerId(r);if(-1==n)return Oa(e),ci.Promise.reject({code:e._errorCode,message:e._errorString});return e._innerFunV2(t,El(n))}(t,"CopyToClipboard",r)}},{key:"getView",value:function(){return this._UIView}},{key:"Erase",value:function(e,t,r,n,i,o,a){var s=this;if(!Zt.isFunction(o)){var u,c=parseInt(e);if(!xf(s,c,a))return!1;var l=s._ImgManager.convertClientIndexToServerId(c);return-1==l?(Oa(s),Zt.isFunction(a)&&a(s._errorCode,s._getErrorString()),!1):(s.getView().ClearSelectedAreas(),(u=1==s._innerFun("Erase",El(l,t,r,n,i)))?Zt.isFunction(o)&&o():Zt.isFunction(a)&&a(s._errorCode,s._getErrorString()),u)}s.EraseAsync(e,t,r,n,i).then(o,(function(e){s._wrappeAsyncFailed(s,e,a)}))}},{key:"EraseAsync",value:function(e,t,r,n,i){var o=this;if(o._resetErr(),!o._isValid())return ci.Promise.reject({code:o._errorCode,message:o._errorString});var a=parseInt(e);if(isNaN(a))return ca(o),ci.Promise.reject({code:o._errorCode,message:o._errorString});if(a<0||a>=o._ImgManager.count())return Oa(o),ci.Promise.reject({code:o._errorCode,message:o._errorString});var s=o._ImgManager.convertClientIndexToServerId(a);return-1==s?(Oa(o),ci.Promise.reject({code:o._errorCode,message:o._errorString})):(o.getView().ClearSelectedAreas(),o._innerFunV2("Erase",El(s,t,r,n,i),!0).then((function(e){if(1!=e)throw{code:o._errorCode,message:o._errorString}})))}},{key:"GetImageBitDepth",value:function(e){var t=this,r=parseInt(e);if(!xf(t,r))return!1;var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),!1):t._innerFun("GetImageBitDepth",El(n))}},{key:"GetImageWidth",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return!1;var r=parseInt(e);if(isNaN(r))return ca(t),-1;if(r<0||r>=t._ImgManager.count())return Oa(t),-1;var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),-1):t._innerFun("GetImageWidth",El(n))}},{key:"GetImageHeight",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return!1;var r=parseInt(e);if(isNaN(r))return ca(t),-1;if(r<0||r>=t._ImgManager.count())return Oa(t),-1;var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),-1):t._innerFun("GetImageHeight",El(n))}},{key:"GetImageSize",value:function(e,t,r){var n=this;if(n._resetErr(),!n._isValid())return!1;var i=parseInt(e);if(isNaN(i))return ca(n),-1;if(i<0||i>=n._ImgManager.count())return Oa(n),-1;var o=n._ImgManager.convertClientIndexToServerId(i);return-1==o?(Oa(n),-1):n._innerFun("GetImageSize",El(o,t,r))}},{key:"GetImageSizeWithSpecifiedType",value:function(e,t){var r=this;if(r._resetErr(),!r._isValid())return!1;var n=parseInt(e);if(isNaN(n))return ca(r),-1;if(n<0||n>=r._ImgManager.count())return Oa(r),-1;var i=r._ImgManager.convertClientIndexToServerId(n);return-1==i?(Oa(r),-1):r._innerFun("GetImageSizeWithSpecifiedType",El(i,t))}},{key:"GetImageXResolution",value:function(e){var t=this,r=parseInt(e);if(!xf(t,r))return!1;var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),!1):t._innerFun("GetImageXResolution",El(n))}},{key:"GetImageYResolution",value:function(e){var t=this,r=parseInt(e);if(!xf(t,r))return!1;var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),!1):t._innerFun("GetImageYResolution",El(n))}},{key:"SelectAllImages",value:function(){var e,t=this,r=t._getHowManyImagesInBuffer(),n=[];if(t._resetErr(),!t._isValid())return!1;for(e=0;e=t._ImgManager.count())return Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):t._innerFunV2("GetSkewAngle",El(n),!0).then((function(e){var n=e;return Zt.isArray(e)&&(n=e.length>0?e[0]:0),bf.refreshImageAfterInvokeFun(t,r),n}))}},{key:"GetSkewAngleEx",value:function(e,t,r,n,i){var o=this,a=parseInt(e);if(!xf(o,a))return!1;var s=o._ImgManager.convertClientIndexToServerId(a);return-1==s?(Oa(o),!1):o._innerFun("GetSkewAngleEx",El(s,t,r,n,i))}},{key:"GetSkewAngleFromBinaryAsync",value:function(e,t,r,n){var i=this;if(i._resetErr(),!i._isValid())return ci.Promise.reject({code:i._errorCode,message:i._errorString});var o=this._imageBufferWrapper.getCustomDataByIndex(e),a=this._imageBufferWrapper.getMetadataByIndex(e),s=this._ImgManager.convertClientIndexToServerId(e),u={imageId:s,serverId:s,bufferLen:t.size,imageType:Wd.IT_BMP,width:a.width,height:a.height,bit:a.bitDepth,xres:a.resolutionX,yres:a.resolutionY,uidFromServer:o.uidFromServer},c=Zt.stringify([Zt.stringify(u)]);return this._innerSendBlob("GetSkewAngleFromBinary",c,t,!0,!0,r,n)}},{key:"IsBlankImageEx",value:function(e,t,r,n,i,o){var a,s=this;if(!xf(s,a=parseInt(e)))return!1;var u=s._ImgManager.convertClientIndexToServerId(a);return-1==u?(Oa(s),!1):s._innerFun("IsBlankImageEx",El(u,t,r,n,i,o))}},{key:"MirrorAsync",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return ci.Promise.reject({code:t._errorCode,message:t._errorString});var r=parseInt(e);if(isNaN(r))return ca(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});if(r<0||r>=t._ImgManager.count())return Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):t._innerFunV2("Mirror",El(n),!0).then((function(e){if(1!=e)throw{code:t._errorCode,message:t._errorString};bf.refreshImageAfterInvokeFun(t,r),t.getView().ClearSelectedAreas()}))}},{key:"Mirror",value:function(e,t,r){var n=this;if(!Zt.isFunction(t)){var i=parseInt(e);return!!xf(n,i,r)&&eH(n,"Mirror",i,t,r,!1,!0)}n.MirrorAsync(e).then(t,(function(e){n._wrappeAsyncFailed(n,e,r)}))}},{key:"RemoveAllImages",value:function(){return this._removeAllImages("RemoveAllImages")}},{key:"RemoveAllImagesAsync",value:function(){return this._removeAllImagesAsync("RemoveAllImagesAsync",!0)}},{key:"RemoveImageAsync",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return ci.Promise.reject({code:t._errorCode,message:t._errorString});var r=parseInt(e);if(isNaN(r))return ca(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});if(r<0||r>=t._ImgManager.count())return Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):t._innerFunV2("RemoveImage",El(n),!0).then((function(e){return!(!e&&-1033!=t._errorCode)&&(t._OnBitmapChanged(["c1",""+n,3,t._ImgManager.getCurrentImageIndex(),t._ImgManager.count()]),!0)}))}},{key:"Rotate",value:function(e,t,r,n,i){return this.RotateEx(e,t,r,-1,n,i)}},{key:"_wrappeAsyncFailed",value:function(e,t,r){t&&(e._errorCode=t.code,e._errorString=t.message),Zt.isFunction(r)&&r(e._errorCode,e._getErrorString())}},{key:"RotateEx",value:function(e,t,r,n,i,o){var a=this;if(!Zt.isFunction(i)){if(a._resetErr(),!a._isValid())return!1;var s,u=parseInt(e);if(isNaN(u))return ca(a),Zt.isFunction(o)&&o(a._errorCode,a._getErrorString()),!1;if(u<0||u>=a._ImgManager.count())return Oa(a),Zt.isFunction(o)&&o(a._errorCode,a._getErrorString()),!1;var c=a._ImgManager.convertClientIndexToServerId(u);return-1==c?(Oa(a),Zt.isFunction(o)&&o(a._errorCode,a._getErrorString()),!1):((s=1==a._innerFun("RotateEx",El(c,t,r,n)))?(bf.refreshImageAfterInvokeFun(a,u),a.getView().ClearSelectedAreas(),Zt.isFunction(i)&&i()):Zt.isFunction(o)&&o(a._errorCode,a._getErrorString()),s)}a.RotateExAsync(e,t,r,n).then(i,(function(e){a._wrappeAsyncFailed(a,e,o)}))}},{key:"RotateLeft",value:function(e,t,r){return this.RotateEx(e,-90,!0,-1,t,r)}},{key:"RotateRight",value:function(e,t,r){return this.RotateEx(e,90,!0,-1,t,r)}},{key:"RotateAsync",value:function(e,t,r){return this.RotateExAsync(e,t,r,-1)}},{key:"RotateExAsync",value:function(e,t,r,n){var i=this;if(i._resetErr(),!i._isValid())return ci.Promise.reject({code:i._errorCode,message:i._errorString});var o=parseInt(e);if(isNaN(o))return ca(i),ci.Promise.reject({code:i._errorCode,message:i._errorString});if(o<0||o>=i._ImgManager.count())return Oa(i),ci.Promise.reject({code:i._errorCode,message:i._errorString});var a=i._ImgManager.convertClientIndexToServerId(o);return-1==a?(Oa(i),ci.Promise.reject({code:i._errorCode,message:i._errorString})):i._innerFunV2("RotateEx",El(a,t,r,n),!0).then((function(e){if(1!=e&&1!=e)throw{code:i._errorCode,message:i._errorString};bf.refreshImageAfterInvokeFun(i,o),i.getView().ClearSelectedAreas()}))}},{key:"RotateLeftAsync",value:function(e){return this.RotateExAsync(e,-90,!0,-1)}},{key:"RotateRightAsync",value:function(e){return this.RotateExAsync(e,90,!0,-1)}},{key:"ChangeImageSize",value:function(e,t,r,n,i,o){var a=this;if(!Zt.isFunction(i)){var s,u=parseInt(e),c=1*t,l=1*r;if(!xf(a,u,o))return!1;if(c<=0||l<=0)return Ca(a),Zt.isFunction(o)&&o(a._errorCode,a._getErrorString()),!1;var d=a._ImgManager.convertClientIndexToServerId(u);return-1==d?(Oa(a),Zt.isFunction(o)&&o(a._errorCode,a._getErrorString()),!1):((s=1==a._innerFun("ChangeImageSize",El(d,c,l,n)))?(bf.refreshImageAfterInvokeFun(a,u),Zt.isFunction(i)&&i()):Zt.isFunction(o)&&o(a._errorCode,a._getErrorString()),s)}a.ChangeImageSizeAsync(e,t,r,n).then(i,(function(e){a._wrappeAsyncFailed(a,e,o)}))}},{key:"ChangeImageSizeAsync",value:function(e,t,r,n){var i=this,o=parseInt(e),a=1*t,s=1*r;if(i._resetErr(),!i._isValid())return ci.Promise.reject({code:i._errorCode,message:i._errorString});if(isNaN(o))return ca(i),ci.Promise.reject({code:i._errorCode,message:i._errorString});if(o<0||o>=i._ImgManager.count())return Oa(i),ci.Promise.reject({code:i._errorCode,message:i._errorString});if(a<=0||s<=0)return Ca(i),ci.Promise.reject({code:i._errorCode,message:i._errorString});var u=i._ImgManager.convertClientIndexToServerId(o);return-1==u?(Oa(i),ci.Promise.reject({code:i._errorCode,message:i._errorString})):i._innerFunV2("ChangeImageSize",El(u,a,s,n),!0).then((function(e){if(1!=e)throw{code:i._errorCode,message:i._errorString};bf.refreshImageAfterInvokeFun(i,o)}))}},{key:"Flip",value:function(e,t,r){var n=this;if(!Zt.isFunction(t)){var i=parseInt(e);return!!xf(n,i,r)&&eH(n,"Flip",i,t,r,!1,!0)}n.FlipAsync(e).then(t,(function(e){n._wrappeAsyncFailed(n,e,r)}))}},{key:"FlipAsync",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return ci.Promise.reject({code:t._errorCode,message:t._errorString});var r=parseInt(e);if(isNaN(r))return ca(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});if(r<0||r>=t._ImgManager.count())return Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):t._innerFunV2("Flip",El(n),!0).then((function(e){if(1!=e)throw{code:t._errorCode,message:t._errorString};bf.refreshImageAfterInvokeFun(t,r),t.getView().ClearSelectedAreas()}))}},{key:"OutputSelectedAreaAsync",value:(c=n(g().mark((function l(e,t,r,n){var i,o,a,s,u,c,d,f,h,m,p,v,_,y;return g().wrap((function(l){for(;;)switch(l.prev=l.next){case 0:if(a="OutputSelectedArea",(o=this)._resetErr(),o._isValid()){l.next=4;break}throw{code:o._errorCode,message:o._errorString};case 4:if(s=0,u=0,c=0,d=0,!isNaN(e)){l.next=8;break}throw ca(o),{code:o._errorCode,message:o._errorString};case 8:if(r==Wd.IT_BMP||r==Wd.IT_JPG||r==Wd.IT_TIF||r==Wd.IT_PNG||r==Wd.IT_PDF){l.next=11;break}throw Ka(o),{code:o._errorCode,message:o._errorString};case 11:if(n==SG.Blob||n==SG.Base64){l.next=14;break}throw Ka(o),{code:o._errorCode,message:o._errorString};case 14:if(!(e<0||e>=o._ImgManager.count())){l.next=17;break}throw Oa(o),{code:o._errorCode,message:o._errorString};case 17:if(-1!=(f=o._ImgManager.convertClientIndexToServerId(e))){l.next=21;break}throw Oa(o),{code:o._errorCode,message:o._errorString};case 21:return h=n==SG.Base64,m=h?"text":"arraybuffer",t&&(Qt.isNumber(t.x)&&(s=t.x),Qt.isNumber(t.y)&&(u=t.y),Qt.isNumber(t.width)&&(c=t.width),Qt.isNumber(t.height)&&(d=t.height)),v=Zt.stringify([{index:f,left:s,top:u,width:c,height:d}]),_="["+v+","+r+","+n+"]",y=null===(i=Qt.progressContext)||void 0===i?void 0:i.IfShowCancelDialogWhenImageTransfer,l.prev=27,o.IfShowProgressBar?Qt.showProgress(o,a,!1):Qt.hideProgress(),h?o._OnPercentDone([0,-1,ul.ConvertingToBase64]):o._OnPercentDone([0,-1,ul.ConvertingToBlob]),Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=!1),l.next=33,o._sendDataByHttpAsync(a,_,m,!0);case 33:p=l.sent;case 34:return l.prev=34,Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=y),o.IfShowProgressBar&&Qt.closeProgress(null,a),l.finish(34);case 38:if(!h){l.next=52;break}if(!p){l.next=49;break}if(!Hs(p)){l.next=45;break}return o._errorCode=p.exception,o._errorString=p.description,o._errorCause=zs(p),l.abrupt("return","");case 45:if(!(Zt.isArray(p.result)&&p.result.length>0&&Zt.isString(p.result[0]))){l.next=47;break}return l.abrupt("return",p.result[0]);case 47:l.next=50;break;case 49:return l.abrupt("return","");case 50:l.next=53;break;case 52:return l.abrupt("return",new Blob([p],{type:Rd(r)}));case 53:case"end":return l.stop()}}),l,this,[[27,,34,38]])}))),function(e,t,r,n){return c.apply(this,arguments)})},{key:"Crop",value:function(e,t,r,n,i,o,a){var s=this;if(!Zt.isFunction(o)){var u,c=parseInt(e);if(!xf(s,c,a))return!1;var l,d,f=s._ImgManager.convertClientIndexToServerId(c);return-1==f?(Oa(s),Zt.isFunction(a)&&a(s._errorCode,s._getErrorString()),!1):(u=1==s._innerFun("Crop",El(f,t,r,n,i)),l=s._errorCode,d=s._getErrorString(),s.getView().ClearSelectedAreas(),s._errorCode=l,s._errorString=d,u?(bf.refreshImageAfterInvokeFun(s,c),Zt.isFunction(o)&&o()):Zt.isFunction(a)&&a(l,d),u)}s.CropAsync(e,t,r,n,i).then(o,(function(e){s._wrappeAsyncFailed(s,e,a)}))}},{key:"CropAsync",value:function(e,t,r,n,i){var o=this;if(o._resetErr(),!o._isValid())return ci.Promise.reject({code:o._errorCode,message:o._errorString});var a=parseInt(e);if(isNaN(a))return ca(o),ci.Promise.reject({code:o._errorCode,message:o._errorString});if(a<0||a>=o._ImgManager.count())return Oa(o),ci.Promise.reject({code:o._errorCode,message:o._errorString});var s=o._ImgManager.convertClientIndexToServerId(a);return-1==s?(Oa(o),ci.Promise.reject({code:o._errorCode,message:o._errorString})):o._innerFunV2("Crop",El(s,t,r,n,i),!0).then((function(e){var t,r;if(t=o._errorCode,r=o._getErrorString(),o.getView().ClearSelectedAreas(),o._errorCode=t,o._errorString=r,1!=e)throw{code:o._errorCode,message:o._errorString};return bf.refreshImageAfterInvokeFun(o,a),!0}))}},{key:"CropToClipboard",value:function(e,t,r,n,i){var o,a=this,s=parseInt(e);if(!xf(a,s))return!1;var u=a._ImgManager.convertClientIndexToServerId(s);return-1==u?(Oa(a),!1):(a.getView().ClearSelectedAreas(),(o=1==a._innerFun("CropToClipboard",El(u,t,r,n,i)))&&bf.refreshImageAfterInvokeFun(a,s),o)}},{key:"CutFrameToClipboard",value:function(e,t,r,n,i){var o,a=this,s=parseInt(e);if(!xf(a,s))return!1;var u=a._ImgManager.convertClientIndexToServerId(s);return-1==u?(Oa(a),!1):(a.getView().ClearSelectedAreas(),(o=1==a._innerFun("CutFrameToClipboard",El(u,t,r,n,i)))&&bf.refreshImageAfterInvokeFun(a,s),o)}},{key:"CutToClipboard",value:function(e){var t,r=this,n=parseInt(e);if(!xf(r,n))return!1;var i=r._ImgManager.convertClientIndexToServerId(n);return-1==i?(Oa(r),!1):((t=1==r._innerFun("CutToClipboard",El(i)))&&r._OnBitmapChanged(["c1",""+i,3,r._ImgManager.getCurrentImageIndex(),r._ImgManager.count()]),t)}},{key:"CutFrameToClipboardAsync",value:function(e,t,r,n,i){var o=this;if(o._resetErr(),!o._isValid())return ci.Promise.reject({code:o._errorCode,message:o._errorString});var a=parseInt(e);if(isNaN(a))return ca(o),ci.Promise.reject({code:o._errorCode,message:o._errorString});if(a<0||a>=o._ImgManager.count())return Oa(o),ci.Promise.reject({code:o._errorCode,message:o._errorString});var s=o._ImgManager.convertClientIndexToServerId(a);return-1==s?(Oa(o),ci.Promise.reject({code:o._errorCode,message:o._errorString})):o._innerFunV2("CutFrameToClipboard",El(s,t,r,n,i)).then((function(e){var t=1==e;if(!t)throw{code:o._errorCode,message:o._errorString};return bf.refreshImageAfterInvokeFun(o,a),t}))}},{key:"CropToClipboardAsync",value:function(e,t,r,n,i){var o=this;if(o._resetErr(),!o._isValid())return ci.Promise.reject({code:o._errorCode,message:o._errorString});var a=parseInt(e);if(isNaN(a))return ca(o),ci.Promise.reject({code:o._errorCode,message:o._errorString});if(a<0||a>=o._ImgManager.count())return Oa(o),ci.Promise.reject({code:o._errorCode,message:o._errorString});var s=o._ImgManager.convertClientIndexToServerId(a);return-1==s?(Oa(o),ci.Promise.reject({code:o._errorCode,message:o._errorString})):o._innerFunV2("CropToClipboard",El(s,t,r,n,i)).then((function(e){var t=1==e;if(!t)throw{code:o._errorCode,message:o._errorString};return bf.refreshImageAfterInvokeFun(o,a),t}))}},{key:"CutToClipboardAsync",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return ci.Promise.reject({code:t._errorCode,message:t._errorString});var r=parseInt(e);if(isNaN(r))return ca(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});if(r<0||r>=t._ImgManager.count())return Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):t._innerFunV2("CutToClipboard",El(n)).then((function(e){var r=1==e;if(!r)throw{code:t._errorCode,message:t._errorString};return t._OnBitmapChanged(["c1",""+n,3,t._ImgManager.getCurrentImageIndex(),t._ImgManager.count()]),r}))}},{key:"SetDPI",value:function(e,t,r,n,i,o,a){var s,u=this,c=!1;Zt.isFunction(o)&&(c=!0);var l=parseInt(e);if(!xf(u,l,a))return!!c&&void 0;var d=u._ImgManager.convertClientIndexToServerId(l);return-1==d?(Oa(u),Zt.isFunction(a)&&a(u._errorCode,u._getErrorString()),!!c&&void 0):((s=1==u._innerFun("SetDPI",El(d,t,r,n,i)))?Zt.isFunction(o)&&o():Zt.isFunction(a)&&a(u._errorCode,u._getErrorString()),c?void 0:s)}},{key:"MoveImage",value:function(e,t){var r=this;if(r._resetErr(),!r._isValid())return!1;var n=parseInt(e),i=parseInt(t);return isNaN(n)||isNaN(i)?(ca(r),!1):n<0||n>=r._ImgManager.count()||i<0||i>=r._ImgManager.count()?(Oa(r),!1):r._ImgManager.moveImage(n,i)}},{key:"SwitchImage",value:function(e,t){var r=this;if(r._resetErr(),!r._isValid())return!1;var n=parseInt(e),i=parseInt(t);return isNaN(n)||isNaN(i)?(ca(r),!1):n<0||n>=r._ImgManager.count()||i<0||i>=r._ImgManager.count()?(Oa(r),!1):r._ImgManager.switchImage(n,i)}},{key:"CloseWorkingProcess",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._innerFun("CloseWorkerProcess")}},{key:"RemoveAllSelectedImages",value:function(){var e=this;if(e._resetErr(),!e._isValid())return!1;var t=!0,r=e._ImgManager.getCurrentImageIndex(),n=e._ImgManager.getSelectedClientIndexArray(),i=[];if(Zt.isArray(n)&&Zt.each(n,(function(t){var r=e._ImgManager.convertClientIndexToServerId(t);-1!=r&&i.push(r)})),0==i.length&&r>=0){var o=e._ImgManager.convertClientIndexToServerId(r);i.push(o)}return i.length>0&&(t=e._innerFun("RemoveAllSelectedImages",El(i.join(",")))),t&&Zt.each(i,(function(t){e._OnBitmapChanged(["c1",""+t,3,e._ImgManager.getCurrentImageIndex(),e._ImgManager.count()])})),t}},{key:"RemoveAllSelectedImagesAsync",value:function(){var e=this;if(e._resetErr(),!e._isValid())return ci.Promise.reject({code:e._errorCode,message:e._errorString});var t=e._ImgManager.getCurrentImageIndex(),r=e._ImgManager.getSelectedClientIndexArray(),n=[];if(Zt.isArray(r)&&Zt.each(r,(function(t){var r=e._ImgManager.convertClientIndexToServerId(t);-1!=r&&n.push(r)})),0==n.length&&t>=0){var i=e._ImgManager.convertClientIndexToServerId(t);n.push(i)}return n.length>0?e._innerFunV2("RemoveAllSelectedImages",El(n.join(","),!0)).then((function(t){t&&Zt.each(n,(function(t){e._OnBitmapChanged(["c1",""+t,3,e._ImgManager.getCurrentImageIndex(),e._ImgManager.count()])}))})):ci.Promise.resolve()}},{key:"TagImages",value:function(e,t){var r=this;if(r._resetErr(),!r._isValid())return!1;var n=!0,i=r._ImgManager.count();return Zt.isArray(e)?Zt.isString(t)&&""!=t?(Zt.each(e,(function(e){if(isNaN(e)||e<0||e>=i)return Oa(r),n=!1})),n?r._ImgManager.addImageTag(e,t):n):(na(r,-2394,"Invalid tag name."),!1):(Ra(r),!1)}},{key:"ClearImageTags",value:function(e){var t=this;return t._resetErr(),!!t._isValid()&&(-1==e||e>=t._getHowManyImagesInBuffer()?(Oa(t),!1):t._ImgManager.removeImageTag(e))}},{key:"SetDefaultTag",value:function(e){var t=this;return t._resetErr(),!!t._isValid()&&t._ImgManager.setDefaultTag(e)}},{key:"FilterImagesByTag",value:function(e,t,r){var n,i=this,o=!1;if(Zt.isFunction(t)&&(o=!0),i._resetErr(),!i._isValid())return!!o&&void 0;Zt.isFunction(r)&&(n=function(){r({code:i._errorCode,message:i._errorString})});var a=i._ImgManager.showImagesByFilter(e,t,n);return o?void 0:a}},{key:"ClearFilter",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._ImgManager.clearFilter()}},{key:"CreateDocument",value:function(e){var t=this;return t._resetErr(),!!t._isValid()&&(e&&""!=e?Zt.isString(e)?t._ImgManager.CreateFile(e):(Xa(t),!1):(Zt.isNumber(e)?Xa(t):Ya(t),!1))}},{key:"OpenDocument",value:function(e){var t=this;return t._resetErr(),!!t._isValid()&&(e&&""!=e?Zt.isString(e)?t._ImgManager.OpenFile(e):(Xa(t),!1):(Zt.isNumber(e)?Xa(t):Ya(t),!1))}},{key:"RemoveDocument",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return!1;var r=t._ImgManager.GetServerIdsByFileName(e);return r.length>0&&t._innerFun("RemoveAllSelectedImages",El(r.join(","))),t._ImgManager.RemoveFile(e)}},{key:"RenameDocument",value:function(e,t){var r=this;return r._resetErr(),!!r._isValid()&&(Zt.isString(e)&&Zt.isString(t)?e&&""!=e&&t&&""!=t?r._ImgManager.RenameFile(e,t):(Ya(r),!1):(Xa(r),!1))}},{key:"GetDocumentInfoList",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._ImgManager.GetFileInfoList()}},{key:"MoveToDocumentAsync",value:(u=n(g().mark((function d(e,t,r,n){var i,o,a,s,u,c,l,f,h,m;return g().wrap((function(d){for(;;)switch(d.prev=d.next){case 0:if((i=this)._resetErr(),i._isValid()){d.next=4;break}throw{code:i._errorCode,message:i._errorString};case 4:if(!Zt.isUndefined(e)&&0!=e.length){d.next=7;break}throw As(i),{code:i._errorCode,message:i._errorString};case 7:if(!Zt.isUndefined(t)&&0!=t.length){d.next=10;break}throw xs(i),{code:i._errorCode,message:i._errorString};case 10:o=i._ImgManager.GetFileInfoList(),u=0;case 12:if(!(u0)for(h=0;hn&&(f=n),d.next=51;break;case 49:throw Ka(i),{code:i._errorCode,message:i._errorString};case 51:d.next=60;break;case 53:if(!Zt.isNumber(r)){d.next=58;break}if(a.imageIds.length>0)for(m=0;mr&&(f=r),d.next=60;break;case 58:throw Ka(i),{code:i._errorCode,message:i._errorString};case 60:return d.abrupt("return",new ci.Promise((function(r,n){0==l.length||i._ImgManager.MoveImageToFile(e,l,t,f)?r():n({code:i._errorCode,message:i._errorString})})));case 61:case"end":return d.stop()}}),d,this)}))),function(e,t,r,n){return u.apply(this,arguments)})},{key:"CopyToDocumentAsync",value:(a=n(g().mark((function h(e,t,r,n){var i,o,a,s,u,c,l,d;return g().wrap((function(f){for(;;)switch(f.prev=f.next){case 0:if((i=this)._resetErr(),i._isValid()){f.next=4;break}throw{code:i._errorCode,message:i._errorString};case 4:if(!Zt.isUndefined(e)&&0!=e.length){f.next=7;break}throw As(i),{code:i._errorCode,message:i._errorString};case 7:if(!Zt.isUndefined(t)&&0!=t.length){f.next=10;break}throw xs(i),{code:i._errorCode,message:i._errorString};case 10:o=i._ImgManager.GetFileInfoList(),u=0;case 12:if(!(u0&&Zt.isArray(a.imageIds)&&Zt.each(a.imageIds,(function(e){var t=i._uidFromServer2ServerId(e);-1!=t&&l.push(t)})),f.next=60;break;case 40:if(!Zt.isArray(r)){f.next=53;break}if(i._checkIndices(r,a.imageIds.length)){f.next=43;break}throw{code:i._errorCode,message:i._errorString};case 43:if(Zt.each(r,(function(e){var t=i._uidFromServer2ServerId(a.imageIds[e]);-1!=t&&l.push(t)})),Zt.isUndefined(n)){f.next=51;break}if(!Zt.isNumber(n)){f.next=49;break}n<0?d=0:s.imageIds.length>n&&(d=n),f.next=51;break;case 49:throw Ka(i),{code:i._errorCode,message:i._errorString};case 51:f.next=60;break;case 53:if(!Zt.isNumber(r)){f.next=58;break}a.imageIds.length>0&&Zt.isArray(a.imageIds)&&Zt.each(a.imageIds,(function(e){var t=i._uidFromServer2ServerId(e);-1!=t&&l.push(t)})),r<0?d=0:s.imageIds.length>r&&(d=r),f.next=60;break;case 58:throw Ka(i),{code:i._errorCode,message:i._errorString};case 60:return f.abrupt("return",new ci.Promise((function(e,r){var n="copyToDocument";if(s.imageIds.length,0==l.length)e();else{i.IfShowProgressBar?Rs(!1):Qt.hideProgress();var o=i.IfShowCancelDialogWhenImageTransfer;Qt.cancelFrom=sG.LoadImage,i.IfShowCancelDialogWhenImageTransfer=!1,Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=!1),Qt.cancelFrom=sG.Other,i._innerConvertToBlobWithUI(n,rr.DWT.EnumDWT_ImageType.IT_PDF,l,!1,(function(a,s){var u;a.currentFileName=t,a.currentTagName="",a.bNeedClearCurrentTagName=!0,a.index=d,i.IfShowProgressBar?(Rs(!1),Qt.showProgress(i,n,!1),Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=!1)):Qt.hideProgress(),Qt.cancelFrom=sG.LoadImage,i.Addon&&i.Addon.PDF&&(u=i.Addon.PDF.GetReaderOptions(),i.Addon.PDF.SetReaderOptions({convertMode:rr.DWT.EnumDWT_ConvertMode.CM_IMAGEONLY})),i._innerLoadImageFromBinary(a,0,!0,!0,(function(){i.Addon&&i.Addon.PDF&&u&&i.Addon.PDF.SetReaderOptions(u),i.IfShowCancelDialogWhenImageTransfer=o,i.IfShowProgressBar&&Qt.closeProgress(null,n),e()}),(function(){i.Addon&&i.Addon.PDF&&u&&i.Addon.PDF.SetReaderOptions(u),i.IfShowCancelDialogWhenImageTransfer=o,i.IfShowProgressBar&&Qt.closeProgress(null,n),r({code:i._errorCode,message:i._errorString})}))}),(function(){i.IfShowCancelDialogWhenImageTransfer=o,r({code:i._errorCode,message:i._errorString})}))}})));case 61:case"end":return f.stop()}}),h,this)}))),function(e,t,r,n){return a.apply(this,arguments)})},{key:"Invert",value:function(e,t,r){var n=this,i=!1;if(Zt.isFunction(t)&&(i=!0),!i){var o=parseInt(e);return!!xf(n,o,r)&&eH(n,"Invert",o,t,r,!1,!0)}n.InvertAsync(e).then(t,(function(e){n._wrappeAsyncFailed(n,e,r)}))}},{key:"InvertAsync",value:function(e){return this._invert(e)}},{key:"RenameTag",value:function(e,t){var r=this;return r._resetErr(),!!r._isValid()&&(Zt.isUndefined(e)?(Ea(r),!1):0==e.length?(na(r,-2517,"Old tag name is required."),!1):Zt.isUndefined(t)||0==t.length?(function(e){na(e,-2518,"New tag name is required.")}(r),!1):r._ImgManager.renameTag(e,t))}},{key:"RemoveTag",value:function(e,t){var r=this;return r._resetErr(),!!r._isValid()&&(Zt.isUndefined(e)||0==e.length?(Ea(r),!1):Zt.isUndefined(t)||Zt.isArray(t)?r._ImgManager.removeTag(e,t):(Ra(r),!1))}},{key:"GetTagList",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._ImgManager.getTagList()}},{key:"GetTagListByIndex",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return[];var r=parseInt(e);return isNaN(r)?(ca(t),[]):r<0||r>=t._ImgManager.count()||-1==t._ImgManager.convertClientIndexToServerId(r)?(Oa(t),[]):t._ImgManager.getTagListByIndex(r)}},{key:"GetImageBitDepthAsync",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return ci.Promise.reject({code:t._errorCode,message:t._errorString});var r=parseInt(e);if(isNaN(r))return ca(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});if(r<0||r>=t._ImgManager.count())return Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):t._innerFunV2("GetImageBitDepth",El(n))}},{key:"GetImageWidthAsync",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return ci.Promise.reject({code:t._errorCode,message:t._errorString});var r=parseInt(e);if(isNaN(r))return ca(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});if(r<0||r>=t._ImgManager.count())return Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):t._innerFunV2("GetImageWidth",El(n))}},{key:"GetImageHeightAsync",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return ci.Promise.reject({code:t._errorCode,message:t._errorString});var r=parseInt(e);if(isNaN(r))return ca(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});if(r<0||r>=t._ImgManager.count())return Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):t._innerFunV2("GetImageHeight",El(n))}},{key:"GetImageSizeAsync",value:function(e,t,r){var n=this;if(n._resetErr(),!n._isValid())return ci.Promise.reject({code:n._errorCode,message:n._errorString});var i=parseInt(e);if(isNaN(i))return ca(n),ci.Promise.reject({code:n._errorCode,message:n._errorString});if(i<0||i>=n._ImgManager.count())return Oa(n),ci.Promise.reject({code:n._errorCode,message:n._errorString});var o=n._ImgManager.convertClientIndexToServerId(i);return-1==o?(Oa(n),ci.Promise.reject({code:n._errorCode,message:n._errorString})):n._innerFunV2("GetImageSize",El(o,t,r))}},{key:"GetImageSizeWithSpecifiedTypeAsync",value:function(e,t){var r=this;if(r._resetErr(),!r._isValid())return ci.Promise.reject({code:r._errorCode,message:r._errorString});var n=parseInt(e);if(isNaN(n))return ca(r),ci.Promise.reject({code:r._errorCode,message:r._errorString});if(n<0||n>=r._ImgManager.count())return Oa(r),ci.Promise.reject({code:r._errorCode,message:r._errorString});var i=r._ImgManager.convertClientIndexToServerId(n);return-1==i?(Oa(r),ci.Promise.reject({code:r._errorCode,message:r._errorString})):r._innerFunV2("GetImageSizeWithSpecifiedType",El(i,t))}},{key:"GetImageXResolutionAsync",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return ci.Promise.reject({code:t._errorCode,message:t._errorString});var r=parseInt(e);if(isNaN(r))return ca(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});if(r<0||r>=t._ImgManager.count())return Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):t._innerFunV2("GetImageXResolution",El(n))}},{key:"GetImageYResolutionAsync",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return ci.Promise.reject({code:t._errorCode,message:t._errorString});var r=parseInt(e);if(isNaN(r))return ca(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});if(r<0||r>=t._ImgManager.count())return Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):t._innerFunV2("GetImageYResolution",El(n))}},{key:"ChangeBrightnessAsync",value:function(e,t){var r=this,n=parseInt(e);if(!r._isValid())return ci.Promise.reject({code:r._errorCode,message:r._errorString});if(t<-1e3||t>1e3)return la(r),ci.Promise.reject({code:r._errorCode,message:r._errorString});var i=r._ImgManager.convertClientIndexToServerId(n);return-1==i?(Oa(r),ci.Promise.reject({code:r._errorCode,message:r._errorString})):r._innerFunV2("ChangeBrightness",El(i,t))}},{key:"ChangeContrastAsnyc",value:function(e,t){var r=this,n=parseInt(e);if(!r._isValid())return ci.Promise.reject({code:r._errorCode,message:r._errorString});if(t<-1e3||t>1e3)return la(r),ci.Promise.reject({code:r._errorCode,message:r._errorString});var i=r._ImgManager.convertClientIndexToServerId(n);return-1==i?(Oa(r),ci.Promise.reject({code:r._errorCode,message:r._errorString})):r._innerFunV2("ChangeContrast",El(i,t))}},{key:"GetImageAsync",value:function(e,t,r,n,i){var o=this;if(o._resetErr(),!o._isValid())return ci.Promise.reject({code:o._errorCode,message:o._errorString});var a=parseInt(e);if(isNaN(a))return ca(o),ci.Promise.reject({code:o._errorCode,message:o._errorString});if(a<0||a>=o._ImgManager.count())return Oa(o),ci.Promise.reject({code:o._errorCode,message:o._errorString});var s,u=o._ImgManager.convertClientIndexToServerId(a);return-1==u?(Oa(o),ci.Promise.reject({code:o._errorCode,message:o._errorString})):(Zt.isNumber(t)?s=El(u,t):Zt.isNumber(r)&&Zt.isNumber(n)?s=El(u,r,n):Zt.isNumber(i)&&(s=El(u,-1,-1,i)),o._sendDataByHttpAsync("GetImageByIndex",s,"blob"))}},{key:"GetImageInfoAsync",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return ci.Promise.reject({code:t._errorCode,message:t._errorString});var r=parseInt(e);if(isNaN(r))return ca(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});if(r<0||r>=t._ImgManager.count())return Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString});var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),ci.Promise.reject({code:t._errorCode,message:t._errorString})):t._innerFunV2("GetImageInfo",El(n)).then((function(e){var t=0,r=0,n=e;if(Zt.isArray(e)&&1==e.length&&(n=e[0]),Zt.isString(n)){var i=n.split(",");t=parseInt(i[0]),r=parseInt(i[1])}return{width:t,height:r}}))}},{key:"IfShowUI",get:function(){return this._resetErr(),this._isValid()?this._innerFun("IfShowUI"):di},set:function(e){this._setIfShowUI(e)}},{key:"IfShowFileDialog",get:function(){return this._getIfShowFileDialog()},set:function(e){this._setIfShowFileDialog(e)}},{key:"checkErrorString",value:function(){var e=this._errorCode;if(-2115===e)return!0;if(-2003===e&&!rr.DWT.IfHttpPostErrorNoWindow){var t=window.open("","ErrorMessage","height=500,width=750,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no");null==t||t.document.writeln(this.__HTTPPostResponseString)}return 0===e}},{key:"OverlayRectangle",value:function(e,t,r,n,i,o,a){var s,u=this;return u._resetErr(),!!u._isValid()&&(u._isNoViewer()?u._nouiNotSupport("OverlayRectangle"):t>n||r>i||t==n&&r==i?(na(u,-2375,"The left or top or right or bottom you entered is invalid."),!1):(s=Zt.isNumber(o)?li.getColor(o):o,u._UIView.OverlayRectangle(e,t,r,n,i,s,a)))}},{key:"SetViewMode",value:function(e,t){var r=this;if(r._resetErr(),!r._isValid())return!1;if(r._isNoViewer())return r._nouiNotSupport("SetViewMode");if(Zt.isString(e)||Zt.isString(t)||e<-1&&t<-1)return la(r),di;var n=Math.floor(e),i=Math.floor(t);return r._UIView.SetViewMode(n,i),!0}},{key:"ShowImageEditor",value:function(e,t,r,n){var i=this;return i._resetErr(),!!i._isValid()&&(i._isNoViewer()?i._nouiNotSupport("ShowImageEditor"):nf.isServerInvalid(i)?di:i._UIView.GetWebViewer().webViewer.imageEditor?i.ShowImageEditorEx(-1,-1,-1,-1,3):e&&t&&r?i.ShowImageEditorEx(-1,-1,t,r,0,!0,e,n):i.ShowImageEditorEx(-1,-1,-1,-1,0,!1))}},{key:"ShowImageEditorEx",value:function(e,t,r,n,i,o,a,s){var u=this;return u._resetErr(),!!u._isValid()&&(u._isNoViewer()?u._nouiNotSupport("ShowImageEditorEx"):u._UIView.ShowImageEditorEx(e,t,r,n,i,o,a,s))}},{key:"SetSelectedImageArea",value:function(e,t,r,n,i){var o=this;if(o._resetErr(),!o._isValid())return!1;if(o._isNoViewer())return o._nouiNotSupport("SetSelectedImageArea");var a=parseInt(e);return isNaN(a)||a<0||a>=o._ImgManager.count()?(Oa(o),!1):!nf.isServerInvalid(o)&&o._UIView.SetSelectedImageArea(t,r,n,i)}},{key:"first",value:function(){var e=this,t=e._ImgManager.count();return e._resetErr(),!!e._isValid()&&(e._isNoViewer()?e._nouiNotSupport("first"):(t>0&&(e._UIView.Go(0),EG.__innerRefreshFromUIView(e,e._ImgManager.getCurrentImageIndex())),fi))}},{key:"previous",value:function(){var e=this,t=e._ImgManager.count();return e._resetErr(),!!e._isValid()&&(e._isNoViewer()?e._nouiNotSupport("previous"):(t>0&&(e._UIView.__Previous(),EG.__innerRefreshFromUIView(e,e._ImgManager.getCurrentImageIndex())),fi))}},{key:"next",value:function(){var e=this,t=e._ImgManager.count();return e._resetErr(),!!e._isValid()&&(e._isNoViewer()?e._nouiNotSupport("next"):(t>0&&(e._UIView.__Next(),EG.__innerRefreshFromUIView(e,e._ImgManager.getCurrentImageIndex())),fi))}},{key:"last",value:function(){var e=this,t=e._ImgManager.count();return e._resetErr(),!!e._isValid()&&(e._isNoViewer()?e._nouiNotSupport("last"):(t>0&&(e._UIView.Go(t-1),EG.__innerRefreshFromUIView(e,e._ImgManager.getCurrentImageIndex())),fi))}},{key:"_isBindViewer",value:function(){return!(!this._viewer||!this._viewer.webViewer)&&this._viewer.webViewer.bindViewUI}},{key:"_isNoViewer",value:function(){return!this._isBindViewer()}},{key:"_innerUnbindViewer",value:function(e){var t=this;t.__funResize&&(Zt.removeEventListener(window,"resize",t.__funResize),t.__funResize=di),t._viewer&&(e?t._viewer.webViewer.dispose():t._viewer.unbind()),t._config.container=null}},{key:"_unload_viewer",value:function(){var e=this;if(e._isBindViewer())e._innerUnbindViewer(!0);else{var t,r=null===(t=e._containerElement)||void 0===t?void 0:t.id;r&&delete rr.DWT.ContainerMap[r]}e._ImgManager&&(e._ImgManager.dispose(),e._ImgManager=null),e._UIView&&(e._UIView.dispose(),e._UIView=null),e._viewer=null}},{key:"_innerRefreshUI",value:function(e,t,r,n,i){var o=this;return 4==i&&o._isBindViewer()&&(0==o._ImgManager.bImageJustChangedInEditor?o._ImgManager.bImageChangedInViewer=!0:(o._ImgManager.bImageJustChangedInEditor=!1,o._ImgManager.bImageChangedInViewer=!1)),r&&o._ImgManager.refresh(e,o._ImgManager.count(),!0,n),Zt.isFunction(o.__OnRefreshUI)&&o.__OnRefreshUI(o._ImgManager.getCurrentImageIndex(),o._ImgManager.count()),!0}},{key:"updateImage",value:(r=n(g().mark((function m(e,t){var r,n,i,o;return g().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(n=this,Nd.Auto,!Zt.isUndefined(e)&&0!=e.length){a.next=7;break}throw na(n,-2853,"The imageId cannot be empty."),{code:n._errorCode,message:n._errorString};case 7:if(Zt.isString(e)){a.next=10;break}throw za(n),{code:n._errorCode,message:n._errorString};case 10:if(-1!=(i=n._uidFromServer2ServerId(e))){a.next=14;break}throw ws(n),{code:n._errorCode,message:n._errorString};case 14:if(!Zt.isUndefined(t)){a.next=19;break}throw Es(n),{code:n._errorCode,message:n._errorString};case 19:if(t instanceof Blob){a.next=22;break}throw ks(n),{code:n._errorCode,message:n._errorString};case 22:return a.next=24,tH(t);case 24:return o=a.sent,a.next=27,n._updateImage(i,o);case 27:null===(r=n._UIView.GetWebViewer())||void 0===r||null===(r=r.webViewer)||void 0===r||r.resetImageEditorButton();case 28:case"end":return a.stop()}}),m,this)}))),function(e,t){return r.apply(this,arguments)})}],[{key:"ProcessGetBlobByQueue",value:function(){if(t._getblob_queue.length>0&&!t._processing_getblob_queue){t._processing_getblob_queue=!0;var e=t._getblob_queue.shift(),r=e[0],n=e[1],i=e[2];r._convertToBlobForUpload(rr.DWT.EnumDWT_ImageType.IT_PNG,[n],!1,4,(function(e,n,o){var a=o[1][0],s=r._ImgManager.getImageIdMap(a);if(s){var u={imageId:a,serverId:a,uidFromServer:s.uidFromServer,uuid:s.uuid,imageUrl:URL.createObjectURL(e),minImageUrl:URL.createObjectURL(e)};e=null,r._ImgManager.UpdateImage(u,i)}t._processing_getblob_queue=!1,setTimeout(t.ProcessGetBlobByQueue,0)}),(function(e){t._processing_getblob_queue=!1,setTimeout(t.ProcessGetBlobByQueue,0)}))}}},{key:"_getContainer",value:function(e){return e._containerElement}},{key:"_setContainer",value:function(e,t){return e._containerElement=t}},{key:"_closeImageEditorUI",value:function(e){if(Zt.isFunction(e.__CloseImageEditorUI))try{e.__CloseImageEditorUI()}catch(t){_o(t)}}}]);var r,a,u,c}(zG);function eH(e,t,r,n,i,o,a){var s,u=e._ImgManager.convertClientIndexToServerId(r);if(-1==u)return Oa(e),Zt.isFunction(i)&&i(e._errorCode,e._errorString),!1;if(s=e._innerFun(t,El(u)),o)return s;var c=1==s;return c?(a&&(bf.refreshImageAfterInvokeFun(e,r),e.getView().ClearSelectedAreas()),Zt.isFunction(n)&&n()):Zt.isFunction(i)&&i(e._errorCode,e._errorString),c}function tH(e){return Zt.isFunction(e.arrayBuffer)?e.arrayBuffer():new Qt.Promise((function(t,r){if(rr.navInfoSync.bIE||rr.navInfoSync.bSafari){var n=new FileReader;n.onload=function(){t(n.result)},n.onerror=function(e){r(e)},n.readAsArrayBuffer(e)}else{var i;na(i={},-2856,"Cannot convert blob to array buffer."),r({code:i._errorCode,message:i._errorString})}}))}c($G,"_processing_getblob_queue",!1),c($G,"_getblob_queue",[]);var rH=function(e){return e.normal=0,e.balance=1,e}({}),nH="data:image/gif;base64,R0lGODlhZABkAKUAAPyOFPzKjPyuVPzmxPy+dPyeNPzarPz27PzSnPy2ZPymRPzGhPyWJPzu3PzixPzOnPyyZPzChPyiRPzevPz+/PzWrPy6dPyqVPzOlPyyXPzq1PzCfPyiPPzetPz69PzWpPy6bPyqTPyaLPySHPzKlPyuXPzmzPy+fPyePPzatPz29PzSpPy2bPymTPzGjPyWLPzy5P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJCQAxACwAAAAAZABkAAAG/sCYcEgsGo/IpHLJbDqf0Kh0Sq1ar9hslXI4aEwHFUVLLicpjUBrBACMFKTG2Ewne1Khtl4fSnnqgFYUFSJ7hgAiFXOBjE8mDIeHIyaNlUweGZGRGX+WnkYTL5qHIhOfp0MubKN7Iy6oUhQwDSYmDTBPHiyshyydsEwUJgslCiIFCgkPcpcJvIYJv8BJBy4okW8r0kceIM97LIvTRw0Cq5ojBNtGqt9uC08qGisnBA9g4loHAt8jESpKJhT6VqqJMALn3AiYsE7QAneIFCVRkelbiYZFKDhooanAinxWHFyDKABXEhMJ0VFiAkMBqwITQE6hEAGinhRKBg3UlEim/pENzwQcyAKDn00AJ3wKucMxUogKGIsc2DlqhIMsGjgcBRBC6dI0Cla9IaHBKxEHKTWRyGKCqjsUZpeqOFArTFwiK9JGIsDW7TcOd7FU0HuIL5asWwVELfPo2wOiELYuCHzFQ4FnIzRkoYCBsCYGVz3lZZVuMRQNLiGyGOrpQORRClZuHv2tgAPKWNBA0KvgdhkPJzzrYfDBNB0uKwowYDCCQYETMHA78RDB7x6P42J4MFFhhQPWgA4YKJGWAQgHxrObkdXhhAAOHDK4wKd+GgUKHu5Lr8+/v///AAYo4IAEAgODBhNoYFKBdVCgAQkKMDdCcwq40EB6DDoBAwbW/rUhwgMLZlhFA7vxMkICmolIxQEhCLeHUCpK4YEzNvkiIhomOGACDKYNdhQDFWR4wAMCiMKAAA+AZ8QBFR2VgZIBwsACJHswwEKIRAi0FSKmDEjBLtiEYwQFJGzZBgb7eWICabIN4QEBZiKFISxAsRLBkmBumQCU/pXASwZL0rjlagMaNQqgRbwZpzoDnsDLnRmVaSYJaVoygGeTHKHlVgV5mWcvMjG5JQR8/icllcOBgCURKaDqDgM4MXgAAgJAciQCpbopqDs2ZugBDDnaYhwMF7jYxggwxihFAxm4OAIEKSq77AMdIoJBA9JW4UEDLkQ4IYUWzpmtEgcmuOq4/uimq+66/qHhwAQfVDABGOxGodECFyjnBgMoZBAAM/UuAcMJl6HDAQniZiuMVt9AAHDAQ1AwAcPuCIAtxENo0JRNECTs664QjUApxg7EycHFp/x64XpNbjVCAJVS4cAGJQhggR9kaFCtRecCsqmHk2mxgqtbFdAmIw5Y94EWNcUJAKyWeFDnISF4fIQFTrcRZCUw+BmJCNFagXXWWzdSFE9HUzG1mQwYYIkKYx+iQK5RPGAsKyKEVkkK1r2SRdJOh4ByIx48ZEgJdEfhwcYuJ/UJBSu0UIAIEriQuBQVxFnAALBsR68ZBzBuEwExC0hBBzt31LMRKqRAAAEpAESgYgfU2sSB3kscsOueBXqQnDshxOTECocsXeDpokeCImWv7QFBhlxUEIIIEx7LgAgQoBeF13sgeqMJD7gAAgEurPAwFHYb8hjGT4iqB6nsPyELkSWAWHr8+Oev//789+8/u0EAACH5BAkJADEALAAAAABkAGQAAAb+wJhwSCwaj8ikcslsOp/QqHRKrVqv2Kx2y+0uPY1JJ+XQeLxob2OhYAAAjNaika5fKYPL6M0HjC4DFHaDUSYofYgAKCaEjUweAomJAmeOlkYOe5J9Iw6Xn0MEm4kEoJ8UCqOICoKmUB4aJiYNrU4UHKp9HLWuSwcBAhwoBQolFZVMFC25fC28vUceFQWSIyEOz0gWzG8W0EoeLm6jIilNmdyeUBQNsg3IXhXjqhyMX5G5lK8uF8IKJ3S8HKDGjQU8JA5wjeKgzkmDEprejECBrYsLbm/KJXOgJ9Gfik5g4EtUwJ4WSBjfLDiIpEGENm8YKIgQ0NaKiKRYVtGgEGP+Ahi2NExIkWKChmy+QKgKUROLA4IYBTQddCCEqpJbBhxKKQCoowMXVC3aokFCSgAsDljycELVhalWUKZ0gTQNBQPzEI2IUJdKBZxiB3xSsQHwm65dPFhlNmKDzkEwXIjowwAC3CxPmbXwCspDCgICLrBYoRYNhRRQPba4bImChwMHPPTVYoLFZEQcInD+tjbFAgglSrAgYeIxb0KvYcA4MPu48+fQo0ufTr269evYs1t3DaOBdxiytXOB8VnBixEiJJwwsFt8lQEl8vJhUEKweyoUKvTcxMFA8/tG5HdbLiJU8B+AQzSwXy4csDYdBTBoAMOBF521gHYutcBBCBv+OCgEDANiVEB70lHgQAs4tRBIEvKcBUcF1x1QgiQllHbEAi6+EcF16HjUkBHb5OiNdRiMgkESSgl5HQmjkJAEji7uxaNhfvxYRItnMQCjdQeM1IcANhoBoosjXodHKn2oOBuUKV2YXQMnhCBBCAAxoWBKDYoHoYQHCshNgQciKER+CybCgYGCRuFAfJLQZ2WiIVVAgAQijPCCBARUQCKktnjQ3XfhcSrqqKSWauqpqBbhqSwTppqMCScoUIAIBRTQAgm0uGqEBw5AQCUcAAWaKAUPpLaJAiClSsEKL2AkwaOknmZsLkyl2oCXGFkgrHb5/aoKAx7aQcG2T3gwY47+ALgAigoYXCBHuFIc4G0urDThGmyhTqHCYm+gYJ8WDqD7RgHhHjABBhFYAEIEGEwQ5hMBJFICuUoYIDAAIpi06wolTFtACSsYF80yej1sRQUXZ3wEOyHIhwgDTAXqAZqImFzFBBcTvOsEhW6CwgSBioIbxUnAcLEEB5loFp7JKqHBVhkhelLP3IAgJrbcXGDzEb3uEUIKIktBAQnzbjLCv0NEIPCOnXqQ7xYN0JwSBM+Mia4Im4JCrMtXPfpA2aOM8IBzB5wAeEYrPENBAhcDkADRaHhAAN+IFBCymCQLvNlzKjygwK8jCJACUnderAC8l7CDweecQKBpXWU1zoFdBiWCYUIFKZgQ22xxN346qR6EdbEAKpQqtMCllDrB4dVMYCoF/LoYAuTVpUD5t+acKnmOJ4QtKAwgMD8CC3mPWvj180WwdakeIICi2S0g4P2o7KwgAE6hr5ArKEEAACH5BAkJADAALAAAAABkAGQAhfyOFPzKjPyuVPzmxPyeNPzarPy+dPz27PzSnPymRPy2ZPzGhPyWJPzu3PzixPzOnPyiRPzevPzChPz+/PzWrPyqVPy6dPzOlPyyXPzq1PyiPPzetPzCfPz69PzWpPyqTPy6bPyaLPySHPzKlPyuXPzmzPyePPzatPy+fPz29PzSpPymTPy2bPzGjPyWLPzy5P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAb+QJhwSCwaj8ikcslsOp/QqHRKrVqv2Kx2y+16v+CweAydRCyVjyUyIbujkwYGQK9jGu23Xtkg1f8AJA17hEYdLSKAdSItHYWPMA0Jin8Jg5CEA4mUdCIlmIQRnH8OoGUvJSUHeVAlm5yepkwTLyMaIrgMCQWrT5KjAJaySh0OK5QiGBmsS4evgCIBjsNHZhrAApdNfZyCVRPTYS/HwAAszEq0JM8iguhNcQYrGiwO71oj5XQMEWURIAIqrLk36wSDPyIWhNsy4Zo+ACgIisngEGG/Lg0OPqxwoFCAZ3a8OAA5StieDhY4aViYxdXDYNreTDDACQJLLC806hPQkdD+A5IAQHiZ8OGhCAkSxZFDmOELBaCAQjR91KCCRhEJ2Hw5oKAcI1AHEKBA8QAPmAkZKowSAaInqAlJtcRhobNOiBYvqOkxY0FAghUCUMTUK/NAhgYp4hJezLix48eQI0ueTLmy5cuYM397kaFEhheKNS+Z4ICDAA0mNAjgYE/0lA4oQigSEQLFTdd8BJTLhrvJCxZQF7HI2zvJBA/B/zBQEVov3OYHILwM5jZyBw8QQkDwcLuIg+l0SklOseBVwhRL8oEfMdmB7D8ELiahCd6A5AkXKD1IigI8APuRTfCAfkkF4B97kkXwnl3yIfEdeOJFdoAE5klQ3REHTPJSAhf+PnZddtt1R8QEKtQ1ynLNUQNOir8lB4AIwxW3RAO6YTOYjEd0YMCCf9QmIo5EFCOBABBoAIEAEjjwI5BF0JJKCaAxKeWUVFZp5ZVYPgHOCy8kluURL5yAAgYkCICBAWWN8VwHHcAFSgoPJGDiiyZIEGUXHTSgAgYmMMCABiBEcKceHZSgITAhULBkFAdcIN1sHyi61wmP6sPAA4s68ducPbaQ4hUlVPRQCB58ikQHfujDSKZXZOgfAARESEUHC0yXqKlwGPgqABiwikQJJoAnAHFgvFCpf7HMKgGyJ4hBAacvcVBFA0X5ZwGuTsy0ax0QYAtDCTy+tBIYB8yxLaz+Nzox0qsMZFqMCi20oIKSS7yg1rkhfDLFusj+SIstDOCSiwYjDFoEjecCkC8VA7jwKgESdUCBqIpowB2GqW4bQrrbHDqdAgR18AC0yu1nSErnjjvFASC8ylw1Jb7kQqlGjOAiMBhYcUK45ZjUpAPBTmdCa0RkQMC5DUrRQcsvMXDBPSnQVx9L2u66gq9INHAsMCx0KEQGPOvjwo0NhF0OAxR4S4ShXmFArBEIbIuAESTejBAKXk/RAAhhi0CABOglwcK2LOT4gNmzWZA3FSkUYEECIYjAQAgfJLlkta9WcKoKR59t4Rd5luCAAyWYxcRS/q1g3AAKBFfBCVi7kbFpfyQ0U0ILkIcQAgH0OODlYhxsK20THXAGZeyhbJt0cS9Q/JAGb8sooN2LmCzlC+a+pED0QJaw9SgQTEVlHB8kJ8IKplv5ggS3zKaBnV/CUOgICiRAAAEJKDBCCcj3NsEBDThMA3qBiSAAACH5BAkJAC8ALAAAAABkAGQAhfyOFPzKjPyuVPzmxPyeNPy+dPzarPz27PzSnPymRPy2ZPzGhPyWJPzu3PzOnPyiRPzChPzixPz+/PzWrPyqVPy6dPzOlPyyXPzq1PyiPPzCfPzevPz69PzWpPyqTPy6bPyaLPySHPzKlPyuXPzmzPyePPy+fPzatPz29PzSpPymTPy2bPzGjPyWLPzy5P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAb+wJdwSCwaj8ikcslsOp/QqHRKrVqv2Kx2y+16v+CweEwum4sS1yYg2rgk53gzIgDYQ5SIfI9sJOyAAAkNfIVCEgWBgSZwhnsNKoqAKoSOchh/koIYlnKQmoKVnU4SHByNUoghmoyjTRwRDiwBKSSoUA0PkoOuTC4VBKsAIRkWKFN0gHh6vUouI5ohEAepaiIBbreppdpeHB+gww7dcQ0LCSUFtmERBOEAKtSFB3WADwNgEg7vw5yFKZJWkMPCYQE/ABsMXZAEYuAVDiwOJiwETlEJh1YkpBAGKoSoPScktfpCIsM7AfL4cFgRiMLHLhJEMAAFYgNGMhIiFKgwISX+GBQaOAICkYJDszIHHCQQFmLEBqNHy0g4QGJDhAYHbkbdyrWr169gw4odS7as2bNow3BwgcEF1LRVOJwoQCHBgwQUCpx4C7fJ1BPBopXoqRWuBAwrhEZbgaEw1QEkfH5t4EFxRw8v0TQokAGE5wcFGhR2hKLeQUAjJA9BkcKdJAIpVPfiUMAyvxAF+AopaPvOAt29NoA4zXDiEAkTZr5r0WF0HBQmeh80wZfyacxRG5gkLimDKAknpAcKccK5mQjcoxmXYJD4AvNlEKTXlGLISu4rgFuKOF9RAPsVnfaBfo6I0J8iLBwHAXcQEGgIQAcCUt8h4Z1GHnxkoBfhMMz+CGHdQS5lt92B3hGBXAv8MIchGSgkEqEJkvEWTgi/cSXcgQQYRwRrrikC2zFc0dZfCBUQKMFmnXmWQWgrxnEABfN5IFsRLpAQAQkujPXhQSF44E9fSByW2G2MNSmWBChMUIJtIQyWFZhOyEVXAhngpZeDcCpxAFsuTJnnn4AGKuigUJRyAgsfrLDABG+MUYoLDTTgliMSkGCCcoooEAGQXhyQQgEjJKDCBRA8pVIKI2oCwjQwRTACpoAQ8EFmY3AgAoq3KYBnFBykMFw4GXSIkwOwvhMCdVqcUKwmJdBKUgnpMdAcFgek+s6AZHBgQn8jZHmFBdzVRMYBy3Kp4xT+B0TCHbJiTPCimS+Q0ONp3Y6x4IEe7LrEjdzxIkaA82WgrxIn/Eqcv0uU0kAEKaRw1SlMsHRgCQMn0U56FHjrzAkCCBWCACf4KcS2+FaMhAuZEFeByC808EG5ADAwqxIQ9odtFYhwx0AKGLmggnjwaGxEAxFOAG/LBvOTmp6m8YNSmAvNl8CXVlgANAAgCGuErVffIcJA/BIXgggmKwGdeAwggNGW1zl7NncXCH3FASIkrUwGey1RIXfkJeGCAl2X2EUDJqhQAggElOCBBXIfAVF/LDhIG8x2MHCBs1hMNcAGG5DA6RLf9FekEr2+KkkICYjQeCcoSJzeCiynsYFdBgJkUIIABUzQQNlnCDkfu0yUYoopR4uhT3/jDBqB3fxkTegBUROnAMtwXXxajoQe4sDVISSf/QsQUR5z5N/bd4IKyzKgQt7lE+GpAnXhpUBs7YcJKQYH8F6/IUEAACH5BAkJADAALAAAAABkAGQAhfyOFPzKjPyuVPzmxPy+dPyeNPzarPz27Py2ZPymRPzSnPzGhPyWJPzu3PzixPzOnPyyZPzChPyiRPzevPz+/Py6dPyqVPzOlPyyXPzq1PzCfPyiPPzetPz69Py6bPyqTPzWrPyaLPySHPzKlPyuXPzmzPy+fPyePPzatPz29Py2bPymTPzSpPzGjPyWLPzy5P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAb+QJhwSCwaj8ikcslsOp/QqHRKrVqv2Kx2y+16v+CweEwum5EUynkd7Uwuo0mHTVemTCEAIGRK1f9FFyJ6eiIjUhQdBygBJgQLIA0daoBPFAWEhCeUTm4qDJmFJCAHnJVKBy6hAAwHTwcLeauEDCoNp0yXq5tOLxWDs6EfGbhLI8CFh00HHsHBw6bFRAd4enyuuQHOzirYXB0ZICgN0VEHb3FzTS+y26sMIOVWvgUMLgUt8lBpUC3uzgLUZWmAKRQGb2QObPjn7FaWDghmGdLnxUE7hqFYaMlwMROJF2ZAgMK4SoMWFKpmJSBW5gEykoRUaOEwctVKMw9qwtTjQQv+wWAQEIoRuTPTAi0UTMxiwIJilxIdYYLY0gGCThcBnHbp8KGoHgYgtxx4IGBDAggG6LDwCkCFQKQvSmQoRUdh0RATtErbR5SkiAhv92LpkBOjiApCBWMZqzPY4bCKvxk4sS1EgMSRs1AYKyCECwagQyRoQS6zGAoZULB4AKKEH9OwY8ueTbu27duyOzRAYQJDAgwmxgXGHYVCgxYFQ+ErTbz4BAHuBOS1xM82BQ7JtxWYroTCCwcXTDxw8EJvsRIpGYYo0X0CBmQMMHCH3YHETgzDh6DITqgAB9koNPYPAyggwY4zIUAWGUReITAcBRq4o4F5dWQggVc3FXHACu7+rIBZMRNEpd4ERmSw0DYbsBSZAenB5EJaRZjozgkqKhagVwzAOE0C7iTwIS4heoWXERC6YwKFdGTAY1EZFnFgMAnSB0GD+cGw3ywFFBjbjTDBkwQF7tUU33ymHWAfTCRUKYR3DoygwQjkIVlJCQIiyF4TaciJC5j8BbOdnriBacFLoYhgAZnN4dnAAn0CsBygicKgGwe9/RbcC2pGqummnHbq6aeghlpcnqJa8p0CLWjwwASSkKFbBhmUd8oLCghA6AYBZAApniAgkIAEG6ygwp11NGCVYxY4sOuXDRBA6B6XLUtFA0tWxoG0RVDgQLWzfLTGC2f+E4JDWbxgwT/+BGBrSWEYEZApFC7944IDZrwAHUknDPBQo7OooG4TEzzrTj5YZCCwSgqCQcEDRXnwmhUoHLzKBsSGQUEERXl7RcQYUYyInEllnPAUJUgcSgLkMnFACRMowAIHJfxIBAUjFNXNYiLOAsG7QnTggAonIHOCB3IwEfBOC/DcRAUMiaAREx2MwO8JF7wrI0khaInFT9Hp1UEEJgMAWHcthJ3JzkiBwK8eTSrBsTsi/KdEBueO+A0HXa0iggoD6HVA3v98IDOYOWcyURfe4SHC4gwUwAJdTIDQ4jYvLsFnZSMoTYXPE0xQApJFkjSh5RlU0GcIGCibWQcqwORWEz4HUAFdBhioAMnDkaUQEUkOWpLCCy8coDkgFDBNUgX/mnaMYQGUOgRUGK3n/JqtM+TB8IkesDYhG4wsKpjc2oSo8xSUAMGzIkBQAvabJsIB0CGEcIIKciTf3AHeT69/qUEAACH5BAkJADAALAAAAABkAGQAhfyOFPzKjPyuVPzmxPy+dPzarPyeNPz27PzSnPy2ZPymRPzGhPyWJPzu3PzixPzOnPyyZPzChPzevPyiRPz+/PzWrPy6dPzOlPyyXPzq1PzCfPzetPyiPPz69PzWpPy6bPyqTPyaLPySHPzKlPyuXPzmzPy+fPzatPyePPz29PzSpPy2bPymTPzGjPyWLPzy5P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAb+QJhwSCwaj0gk5dDYPBaRx6ZxoCSv2Kx2yx2mThYDYExGfU6prnrN5r5WIbKcHFq92vg8m1ICzf9kLCVWeoWGRnwTgIsACoOHkIYHAoyMAgeRmXgPlZUPmqBdL3GdiyF3oalXDyKliyKfqrJFFBiujBiEs7MvLLeLLKhYFMS6u2olHL+AHCVXFC8lJw8PFQ4NxsdZJSjLfyjOSC8qGKRjDCAB2Npayd5zzUgZAgyvCifZ7EYvCu9yCsKGUHAgphODB/n0CbTlbwyEbIluicCnEAmnhrCMHFjR6haLBqAodMjQoEPCfea8nTIiod4vEQE6ZDrQwqUBFSeLXPSWkVb+gncfI1Fo0fGcBC0HSLy7ZKSDi3cMHERK4VIOiZwCSyj6pcBBvgYNcUIqwQxkFj5+SolwlJCsvxFY1WRgFhDLm5R/6tQl4vbdhbhdOhSUswIwkQMbLCiDZ+EEpiQvGlYwvIWCh6IAGJjtsiSDhCcLpGSogkXwuxBShUrAwGHChwwKKUR4h2HvoRePKw7AaxBhxVkdZv8SYPu3phckMDMyANv4rgYClP/hcNT5sQYmeJ9b8cj6sQ4lIgwGECKBBNLe2RE7kCHDC5Pp48ufT7++/fv48+vfn17kAfj8aQKNBAGY8IEJI2zwAmUBnlWBAE/J4QIJHsjUYB4paFDVHwz+RJDbhWq88FMpdmxxgAMbOFCcfR0Q5YoILViYBAUFgGBACAYIQNF+DWhnymZHdPBAhGQcJCN+wv2iwRUlaBdCOPh10M0yKBxZRAuMtKBfBj4yEkJzRyi1CAn6ObChK1ElwRAgGJR5ZilpIoHlIlrmx6VKYBrRJCBP6ielN1UmISSRY7jwgJX2aeDNks8UIMCNKAhQAIPO9fhLCEBC5oAEKjbYonSAwIgoiFgckACocohQIqlqZPhmkRp8yCoXFKgA4RwuCCDWrHu8sMEIBByY4IK86uEfgMUmq+yyzDbr7LPQRqveqNIicYAEF0SgwQgnZFotER2sFkJRISiAQBr+qXQQzQMqjEZpJiks8CoAqq6jyQEBTDnGPejq08ECpdR2nAWAMDCCrLtsMO8cdULy6SIM7HjMAWt2shIkBFWiAMKqnNDlHw0XQsEIpUA5y8ioAvLQIR0QUEoF2gS3DAj96tEBwZ2oELOiv4DAMRsdBFBKaruMvMxVkLRUiQErItGBA9kucIEE1B5RwcJ/RBDJARBUMkLVR5RQTkciGICByVc00M+LaBfSQFpziGBB00V04IGPIagA9hCsuFKYJhlAkJIBC9BNBAUeLy2xoCuUokCeW//6gQUPOLB33WtrfDkMDVT8R1fvqtFBCshyccItJ2gBTQvjxv1a6No07ndgFw2MgAEIIJCwQHf3UZB5JwqEnsLP9VGwWCkcwH4hJa6Q+S0Mc5YSsrQZpEyGCJBHS8EHpVigPIgvQICqCBAY3mwDFrzJgAXZP39ABQmQUkcFxH/r3wH4l/78/vz3T0QQACH5BAkJADAALAAAAABkAGQAhfyOFPzKjPyuVPzmxPy+dPzarPyeNPz27PzSnPy2ZPymRPzGhPyWJPzu3PzixPzOnPyyZPzChPzevPz+/PzWrPy6dPyqVPzOlPyyXPzq1PzCfPzetPyiPPz69PzWpPy6bPyqTPyaLPySHPzKlPyuXPzmzPy+fPzatPyePPz29PzSpPy2bPymTPzGjPyWLPzy5P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAb+QJhwSCwaj8ikcslsOp9QZad08lBOpUN0y+1CDyoMx8UQhVAYldbLbnMnDpAIQK/TRSDJxM3vIzsUDHaDdQwUHX6JfRMUIYSPACEUe4qVXSUKkJAKJZaeUB0EmpoEiJ+nShkuo5AMGahsGRQBEREXFGtLCKyaKrBREx0nJCFlcyIMKCslpkgQvJAQv09wAnOaIgQNlEYc0I8c003CBt8CA9xEjt+DBuMlFA8PHg4pihMn5ewsr0Yo7IPCKZlQYgUHYwwMWDiRjg0cfQBZ5BqCAaAdDEoORBD0SESCbW5SWLBYR0NDFSTp+EJyQBQrCw3cFEhJx0AnIhk4AnSFZML+iGusEjR7I4AmABER0nWoQJKAvSMlvEETcYJNiXU0BcTEKfUbpz8RAIKYGEWFzpQoBhRhhJWVpIZDGoAAaMCBlwVAUzLYYATQ2VaHkmRoy4vBSi4mjN6hcGSCBBZ57YhgoUdJicisRIzwklixiAJJwGBAYcwFBxJqmJT4m3lzlwCYAbqQsOQAFQoeTgx4yiQDRGiGvARSzOGmpRdF2RX30uA3SQxkE/mMDWnFUGAJjIp4ADdRAxbfGKhl44A6Lw5bP00owPpR0jYdVqTc3l1Rhwft62SLzqVBcnYirFBfJcIoEBsHI/DWBhzgfSMCBun9MkEDD5BgAAMJWRBBCQP+vpFBJrwECJI4QkzwQgYllJDBiJUcsAAK1DHAgQodkojKBBksIMAYyITAQQIPsGjjkEO8UIIEJ5wgQQkKEunkk1BGKeWUVFZp5ZVYZvlGCjVq6UcHDrTwAQQftODAdV76QRAGIQBlBgYcpplIBwWYZwiacr5xAmGEhFBAlyUaKWSe30HDQoQ9NbAChgysMKiWEwTAzgg1vlDRRS/kCcMBXZ3X5FoqRCYCjXm+YB4hImSaRAedDWICnleWYJFxR4TySCl5ZmBRPz2ZNYhhgEZpKoCqJvECCYOQUGyaKYAIjQL8EWFiBYxW8EKwUU7QwqSATujAtZrG1SArh4brxXr+fA7iJ6zmjjMcYOy228SabZkBQZzytpFCmBWQ2YIEn+br0AHxCmzwwQgnrPDCDDfs8MMQRywxlPhoAAEGBKQ28R8SyCGZASoU7EYHDaQI7pMdqJDuURFEy0cDC4DAAQcCjCDyJxKsTAcDNltygMf6vUrkBHOxYgCifMTXEaVDnnBqHRFUchUkAiw7jQlP06FAJe8SshyJE1xaGLZO+PqITTaGHR7ZTTiwMghIw8IUNAIlcsB/kkVwsyIUZA0AAZasRgjcRB7gXEd2VUKQAMUwEEICLg/UwAgGiqDACI8qEeooIgjtyb5WMPOGA+PWwYID2HawESQiQBC3lRkUTQhgP1+MwGfnr1fJ6iieO0FyBCxgyIEJZ+b6jyYo8LoxDOVxnvjyzPPy/PKCa8IArRsjN0rV0AtxX34McNe9EAd8gJkIH0QesbYw3oFCC2wzjOMDC0TwQAbxj6///vz3v38QACH5BAkJADAALAAAAABkAGQAhfyOFPzKjPyuVPzmxPy+dPyeNPzarPz27Py2ZPymRPzSpPzGhPyWJPzu3PzixPzOnPyyZPzChPyiRPzevPz+/Py6dPyqVPzOlPyyXPzq1PzCfPyiPPzetPz69Py6bPyqTPzWpPyaLPySHPzKlPyuXPzmzPy+fPyePPzatPz29Py2bPymTPzGjPyWLPzy5PzWrP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAb+QJhwSCwaj8ikcslsOp/QqHRKrUI7pcmk1LF6v9ZOxlNgmBmFSqYLbruRjQgDQK/TGZrGe/92YeyAdCIkLnyGYRWBigAVbIePThQXc4uADBcUkJpLDR+Vih96m6NGKJSfdgwopFMUHQcZEw4NBx2ZSx0LqIoLjqxMFA0KAiKpHigut0gHCLuBCAe/TR0vFsWKDBgOSgckzoAk0dJKFAstuxsoykXM33bQTi4vASwKa3wdLNe7IS/rQx0iuKvTawmFEipEFFMoIsEEX14ogDjnbkMJJKYGqsKloMAiBgsKgWmwYiAdBP+EdBoYasmLEJ9EsIDY6sE+dyIyHKEw4ub+JwYjUhJx4REVgwlfOpQ0SccEkg4evnmgSYSCiW8JhEI54NPdCqowXJDoameQyCQulu4ScdFKCaZ1Cpw10kDDKUsmRClxUHTtAy8c4NIpoDOJGBVlzhTwUEJrkZfuFniZIBgA4SYHsmwR5wQFTGcyvWSofGKuoRInvolQ4OXAXZaO2xzwBFovlQ7N4F4YZdOZii8UXrx2xsD2oxS0PxVo60UsUw2x3zhIXamFArBRKPAdKMA4JAoZMAwHcOIF9ikGPu/6wJxVBwUWToQIUWCFBtNggm/YJaDxOCEHDIACCrNEV8VBHpAFQAgRePcfKeAtsMIJBRRwwgcKNGDgg5r+UOBCA7RsyOGIJJZoIoQUiHjiHh5OcMECESwwwgTJrDiKCyYkEMI+IoSQgAn42ejGARf0pUiPF3AmZBsuRAVaBUEuOcUBEJgEj5RhaKBgJSJocJ6JWJiwwgYrmOAAWMGpN1AL/mB5kDeAiNBfSgf8IRgGStpYwn6LWGTEBFuuhdSSDViASndFEFAZHQQsmU+gAIiwwDrUVbYBoQk4s4JtkK6lIikTUGTUNkMsWkeeJaLgziqlmgoAqiSq+g2rQnSKighfjuPAeIGEQKoQfJJGqFqfJGBbIos2KuSjt7KwDqCViTCokA0IcKhxdVaGJ5YDBBvIBgMYkSZc/Xz6y0H+xMQ55xEB2VpWBLmS2IEDJnywwQdmntfOQCrAimUUDSQImgcO/ivFASMYGUiPI/hr8BQuaLBCCKcwEEKZDj9MhYccPMDCAiw8gIy5GkORIsklp6zyyiy37PLLMMcs88wcvvKhC7bQLAV4ERQVQgUToCyFGA3E26EDxNIRggJCR4KCAAVsgEFhHGaQHCAFcPAIBQrcxADV43SgwScCRPlFCgoDgIDRfBxQqSIhTLvHW98WvEkDkL5wCGWBXPZfA7uwZohrgQjA9h4uqBkIA1obUk6cckvTAbKLtHTIASxQUgDTHFIwgeJ1iBDUdwfIckDTQlBwwOkbd7S4CaifW0JlACp4EIB/Oz/9GQMfjJ7yC2+XV4ULE7wAAgpFq7wdICG0pzMuuT1z+MwNZKqIsc83kYEEi0gAdvbLXG2HBRmDL4Q+C7NgPhPOAVL2+kwEzEAxDBAMfzxamH3//vz37///AFxREAAAO2l6MlNnMjJPaEJTY1lvVkpORFI0dmF6ek1tK1ZrditmL1VXWmxseUxSc0NPYk4vVU5kVVRWeThHRmlpUWNqNWQ=",iH={loaderBarClassName:"ds-dwt-loaderBar",loaderBarBackgroundColor:"",loaderBarSource:de.bIE?nH:Qt.loaderBarSource,loaderBarSourceIE:nH,loaderBarWidth:120,loaderBarHeight:120,errorMessages:{limitReachedForZoomIn:"Error: You have reached the limit for zooming in",limitReachedForZoomOut:"Error: You have reached the limit for zooming out",insufficientParas:"Error: Not enough parameters.",invalidAngle:"Error: The angle you entered is invalid.",invalidIndex:"Error: The index you entered is invalid.",invalidHeightOrWidth:"Error: The height or width you entered is invalid.",imageNotChanged:"Error: You have not changed the current image."},generalMessages:{checkingDWTVersion:"Checking WebTwain version ...",updatingDService:"Dynamic Web TWAIN Service is updating ...",downloadingDWTModule:"Downloading the Dynamic Web TWAIN module.",refreshNeeded:"Please REFRESH your browser.",downloadNeeded:"Please download and install the Dynamic Web TWAIN.",DWTmoduleLoaded:"The Dynamic Web TWAIN module is loaded."},customProgressText:{upload:"Uploading...",download:"Downloading...",load:"Loading...",decode:"Processing...",decodeTIFF:"Processing tiff...",decodePDF:"Processing pdf...",encode:"Processing...",encodeTIFF:"Processing tiff...",encodePDF:"Processing pdf...",transfer:"Transferring...",canvasLoading:"Loading ..."},buttons:{titles:{previous:"Previous Image",next:"Next Image",print:"Print Image",scan:"Acquire new Image(s)",load:"Load local Image(s)",rotateleft:"Rotate Left",rotate:"Rotate",rotateright:"Rotate Right",deskew:"Deskew",crop:"Crop Selected Area",cut:"Cut Selected Area",changeimagesize:"Change Image Size",flip:"Flip Image",mirror:"Mirror Image",zoomin:"Zoom In",originalsize:"Show Original Size",zoomout:"Zoom Out",stretch:"Stretch Mode",fit:"Fit Window",fitw:"Fit Horizontally",fith:"Fit Vertically",hand:"Hand Mode",rectselect:"Select Mode",zoom:"Click to Zoom In",restore:"Restore Original Image",save:"Save Changes",close:"Close the Editor",removeall:"Remove All Images",removeselected:"Remove All Selected Images"},bShowAllButtons:!0,visibility:{scan:!0,load:!0,print:!0,removeall:!0,removeselected:!0,rotateleft:!0,rotate:!0,rotateright:!0,deskew:!0,crop:!0,cut:!0,changeimagesize:!0,flip:!0,mirror:!0,zoomin:!0,originalsize:!0,zoomout:!0,stretch:!0,fit:!0,fitw:!0,fith:!0,hand:!0,rectselect:!0,zoom:!0,restore:!0,save:!0,close:!0}},dialogText:{dlgRotateAnyAngle:["Angle :","Interpolation:","Keep size"," OK ","Cancel"],dlgChangeImageSize:["New Height :","New Width :","Interpolation:"," OK ","Cancel"],saveChangedImage:["You have changed the image, do you want to keep the change(s)?"," Yes "," No "],selectSource:["Select Source:","Select","Cancel","There is no source available!"]}},oH=Zt.mix({},iH);function aH(){var e;rr.DWT&&(e=rr.DWT.CustomizableDisplayInfo),e&&(Zt.isString(e.loaderBarSource)&&""!=e.loaderBarSource?Qt.loaderBarSource=e.loaderBarSource:de.bIE?(Qt.loaderBarSource=iH.loaderBarSourceIE,Qt.loaderBarSourceIE=iH.loaderBarSourceIE):Qt.loaderBarSource=iH.loaderBarSource,Zt.isString(e.loaderBarClassName)&&""!=e.loaderBarClassName?Qt.loaderBarClassName=e.loaderBarClassName:Qt.loaderBarClassName=iH.loaderBarClassName,Zt.isString(e.loaderBarBackgroundColor)?Qt.loaderBarBackgroundColor=e.loaderBarBackgroundColor:Qt.loaderBarBackgroundColor=iH.loaderBarBackgroundColor,e.loaderBarWidth?Qt.loaderBarWidth=e.loaderBarWidth:Qt.loaderBarWidth=iH.loaderBarWidth,e.loaderBarHeight?Qt.loaderBarHeight=e.loaderBarHeight:Qt.loaderBarHeight=iH.loaderBarHeight)}var sH=!0;function uH(){var e;sH&&(oH=Zt.mix({},iH),rr.DWT&&(e=rr.DWT.CustomizableDisplayInfo),e&&(e.errorMessages&&Zt.mix(oH.errorMessages,e.errorMessages),e.generalMessages&&Zt.mix(oH.generalMessages,e.generalMessages),e.customProgressText&&Zt.mix(oH.customProgressText,e.customProgressText),e.buttons&&(e.buttons.titles&&Zt.mix(oH.buttons.titles,e.buttons.titles),e.buttons.bShowAllButtons&&Zt.mix(oH.buttons.bShowAllButtons,e.buttons.bShowAllButtons),e.buttons.visibility&&Zt.mix(oH.buttons.visibility,e.buttons.visibility)),e.dialogText&&Zt.mix(oH.dialogText,e.dialogText)),aH(),sH=!1)}function cH(e){var t=e,r=window;if(r.ShadowRoot)for(;t;){if(t instanceof r.ShadowRoot)return t;t=t.parentNode}return null}function lH(e){var t=window;return!!(t.ShadowRoot&&e instanceof t.ShadowRoot)}Qt._funsAfterConfigLoaded=[],Qt._safePromptCustomMsg=function(e){e&&e()};var dH=Il;rr.DWT;var fH,hH={background:"#434246",topMenuBorder:"",innerBorder:"",promptToSaveChange:!0,buttons:oH.buttons,dialogText:oH.dialogText},gH=function(){return s((function t(e,r){o(this,t);var n=this;n._stwain=e,n._ImgManager=e._ImgManager,n.zoomInStep=1.2,n.zoomOutStep=.8,n.MIN_ZOOM=.02,n.MAX_ZOOM=65,n.MAX_ROWS=128,n.MAX_COLUMNS=128,n.__MousewheelValue=0,this._Init(r)}),[{key:"_Init",value:function(e){var t=this;if(t.borderWidth=Zt.isUndefined(e.borderWidth)?1:e.borderWidth,e.BackgroundColor?t.BackgroundColorByDefault=e.BackgroundColor:t.BackgroundColorByDefault="#FFFFFF",e.BackgroundColor=t.BackgroundColorByDefault,t.BackgroundFillColor=t.BackgroundColorByDefault,e.onTopImageInTheViewChanged=function(e){Zt.isFunction(t._stwain.__OnTopImageInTheViewChanged)&&t._stwain.__OnTopImageInTheViewChanged(e.index,e.bByScrollBar)},e.onGetImageInfo=function(e){return{width:t._stwain.GetImageWidth(e),height:-1}},!t._stwain._viewer&&rr.DWT.UseDefaultViewer){var r={viewerContainer:{},viewerEvents:{topPageChanged:function(e,r){t.__topPageChanged(e,r,t)},click:function(e){t.__click(e,t)},rightclick:function(e){t.__rightclick(e,t)},dblclick:function(e){t.__dblclick(e,t)},mousemove:function(e){t.__mousemove(e,t)},pageAreaSelected:function(e,r){t.__pageAreaSelected(e,r,t)},pageAreaUnselected:function(e){t.__pageAreaUnselected(e,t)},dragdone:function(e){t.__dragdone(e,t)},onDrop:function(e){t.__onDrop(e,t)},pageChange:function(e){t.__pageChange(e,t)},bufferChanged:function(e,r){t.__bufferChanged(t,e,r)},onBind:function(e){t.__onBindViewer(e)},onUnBind:function(e){t.__onUnBindViewer(e)},save:function(e,r,n,i){return t.__save(t,e,r,n,i)},removeBtnClick:function(e){t.__removePage(t,e)}},viewerError:{setError:function(e,r){t.__setError(e,r,t)}},imageEditorEvents:{acquire:function(e){t.__acquire(t,e)},loadImage:function(){t.__loadImage(t)},deskew:function(e,r){t.__deskew(t,e,r)},removeImage:function(){t.__remove(t)},removeAllImage:function(){t.__removeAll(t)},close:function(){t.__close(t)}},imageEditorServerCallback:{rotateRight:function(){t.__rotateRightForServer(t)},rotate:function(e,r,n){t.__rotateForServer(t,e,r,n)},rotateLeft:function(){t.__rotateLeftForServer(t)},deskew:function(e){t.__deskewForServer(t)},crop:function(e){t.__cropForServer(t,e)},erase:function(e){t.__eraseForServer(t,e)},changeImageSize:function(e,r,n){t.__changeImageSizeForServer(t,e,r,n)},flip:function(){t.__flipForServer(t)},mirror:function(){t.__mirrorForServer(t)},restore:function(e){t.__restoreForServer(t,e)},save:function(e){return t.__saveForServer(t,e)}},beforeImageEditorCreated:function(e){t.__beforeImageEditorCreated(e)}};e.Container&&(ci.isNodeList(e.Container)||Zt.isArray(e.Container)&&e.Container.length>0)&&(r.viewerContainer={container:e.Container[0],width:nr(e.Width),height:nr(e.Height)}),t._stwain._viewer=new rr.DWTViewer(iG._getBuffer(t._ImgManager),r)}else e.Container&&(ci.isNodeList(e.Container)||Zt.isArray(e.Container)&&e.Container.length>0)&&t.__onBindViewer(e.Container[0]);t.__InitEvents(e)}},{key:"dispose",value:function(){this._stwain._viewer}},{key:"__InitEvents",value:function(e){var t=this;Zt.isFunction(e.onTopImageInTheViewChanged)&&(t.onTopImageInTheViewChanged=e.onTopImageInTheViewChanged),Zt.isFunction(e.onGetImageInfo)&&(t.onGetImageInfo=e.onGetImageInfo),Zt.isFunction(e.onZoomChanged)&&(t.onZoomChanged=e.onZoomChanged),Zt.isFunction(e.onMouseMove)&&(t.onMouseMove=e.onMouseMove),Zt.isFunction(e.onMouseClick)&&(t.onMouseClick=e.onMouseClick),Zt.isFunction(e.onMouseRightClick)&&(t.onMouseRightClick=e.onMouseRightClick),Zt.isFunction(e.onMouseDoubleClick)&&(t.onMouseDoubleClick=e.onMouseDoubleClick),Zt.isFunction(e.onImageAreaDeSelected)&&(t.onImageAreaDeSelected=e.onImageAreaDeSelected),Zt.isFunction(e.onImageAreaSelected)&&(t.onImageAreaSelected=e.onImageAreaSelected),Zt.isFunction(e.onBufferChanged)&&(t.onBufferChanged=e.onBufferChanged),Zt.isFunction(e.onSelected)&&(t.onSelected=e.onSelected),Zt.isFunction(e.onRefreshUI)&&(t.onRefreshUI=e.onRefreshUI),Zt.isFunction(e.onResetCurrentIndex)&&(t.onResetCurrentIndex=e.onResetCurrentIndex)}},{key:"GetWebViewer",value:function(){return this._stwain._viewer}},{key:"SetSelectedImageArea",value:function(e,t,r,n){if(null!=this.GetWebViewer()){var i=[],o={};return o.left=e,o.top=t,o.right=r,o.bottom=n,i.push(o),this.GetWebViewer().setSelectedAreas(i)}return!1}},{key:"OverlayRectangle",value:function(e,t,r,n,i,o,a){var s=this;return!!s._stwain._isNoViewer()||null!=s.GetWebViewer()&&s.GetWebViewer().webViewer.overlayRectangle(e,t,r,n,i,o,a)}},{key:"ChangeImageViewSize",value:function(e,t){var r=this;return e>=0&&(r.GetWebViewer().width,r.GetWebViewer().width=e),t>=0&&(r.GetWebViewer().height,r.GetWebViewer().height=t),!0}},{key:"ChangeSize",value:function(e,t){var r=this;return r.GetWidth()!=e&&r.SetWidth(e),r.GetHeight()!=t&&r.SetHeight(t),!0}},{key:"GetWidth",value:function(){return this.GetWebViewer().width}},{key:"SetWidth",value:function(e){var t=e;return this._stwain._isNoViewer()||(this.GetWebViewer().width=t),!0}},{key:"GetHeight",value:function(){return this.GetWebViewer().height}},{key:"SetHeight",value:function(e){var t=e;return this._stwain._isNoViewer()||(this.GetWebViewer().height=t),!0}},{key:"SetViewMode",value:function(e,t){var r=this;return r._stwain._isNoViewer()?r._stwain._nouiNotSupport("SetViewMode"):r.GetWebViewer().setViewMode(e,t)}},{key:"SetIfFitWindowAndType",value:function(e){var t;if(null!=this.GetWebViewer()){switch(e){case 1:t="height";break;case 2:t="width";break;default:t="window"}this.GetWebViewer().fitWindow(t)}return!0}},{key:"GetAllowMultiSelect",value:function(){return!this._stwain._isNoViewer()&&this.GetWebViewer().selectionMode}},{key:"SetAllowMultiSelect",value:function(e){var t=this;return t._stwain._isNoViewer()||(t.GetWebViewer().selectionMode=e?1:0),!0}},{key:"GetFitWindowType",value:function(){return this._stwain._isNoViewer(),0}},{key:"SetSelectionRectAspectRatio",value:function(e){return this.GetWebViewer().selectionRectAspectRatio=e,!0}},{key:"GetSelectionRectAspectRatio",value:function(){return this.GetWebViewer().selectionRectAspectRatio}},{key:"SetFitWindowType",value:function(e){return this._stwain._isNoViewer()||this.SetIfFitWindowAndType(e),!0}},{key:"GetIfFitWindow",value:function(){return this._stwain._isNoViewer(),!0}},{key:"SetIfFitWindow",value:function(e){var t=this;return t._stwain._isNoViewer()||(e?t.GetWebViewer().fitWindow("window"):t.GetWebViewer().zoom=1),!0}},{key:"GetImageMargin",value:function(){return this._stwain._isNoViewer()?0:this.GetWebViewer().pageMargin}},{key:"SetImageMargin",value:function(e){return this._stwain._isNoViewer()||(this.GetWebViewer().pageMargin=e),!0}},{key:"GetSelectionImageBorderColor",value:function(){return this.GetWebViewer().selectedPageBorder}},{key:"SetSelectionImageBorderColor",value:function(e){var t=e;return Zt.isNumber(t)&&(t=li.getColor(t)),-1==t.indexOf("1px solid")&&(t="1px solid "+t),this.GetWebViewer().selectedPageBorder=t,!0}},{key:"GetZoom",value:function(){return this.GetWebViewer().zoom}},{key:"SetZoom",value:function(e,t,r){var n=this;return en.MAX_ZOOM&&(e=n.MAX_ZOOM),null!=n.GetWebViewer()&&(n.GetWebViewer().zoom=e),!0}},{key:"ZoomIn",value:function(e,t){var r=this,n=r._ImgManager.getImageIdMap(r._ImgManager.convertClientIndexToServerId(r._ImgManager.getCurrentImageIndex()));if(!n)return!1;var i=r.GetWebViewer().zoom,o=Math.floor(100*i*r.zoomInStep)+1;return 115e3||nr(n.imageHeight*i)>15e3?(Il.output(r,oH.errorMessages.limitReachedForZoomIn),alert(oH.errorMessages.limitReachedForZoomIn),!1):(r.SetZoom(o/100,e,t),!0):(Il.output(r,oH.errorMessages.limitReachedForZoomIn),alert(oH.errorMessages.limitReachedForZoomIn),!1)}},{key:"ZoomOut",value:function(){var e=this,t=e.GetWebViewer().zoom,r=Math.floor(100*t*e.zoomOutStep)-1;return 10){var o=t[t.length-1];o.index&&(i=nr(o.index)+1),n.__fireEvent("onImageAreaSelected",{index:e,left:nr(o.x),top:nr(o.y),right:nr(o.x+o.width),bottom:nr(o.y+o.height),areaIndex:i})}}},{key:"__pageAreaUnselected",value:function(e,t){t.__fireEvent("onImageAreaDeSelected",e)}},{key:"__dragdone",value:function(e,t){var r=t;Zt.isFunction(r._stwain.__OnIndexChangeDragDropDone)&&r._stwain.__OnIndexChangeDragDropDone(e)}},{key:"__onDrop",value:function(e,t){var r=t;r.GetWebViewer().webViewer.acceptDrop&&r.__dropEvent(e,r)}},{key:"__dropEvent",value:function(e,t){var r,n,i=t,o=function(e){i._stwain._bIfShowProgressBar&&Qt.closeProgress(null),e&&Il.output(null,e+" was loaded successfully!")},a=function(e,t,r){i._stwain._bIfShowProgressBar&&Qt.closeProgress(null),i._stwain._errorCode=e,i._stwain._errorString=t,fd({code:e,message:t}),r&&Il.output(null,r+" failed to load. Error code: "+e+"Error String: "+t)};try{for(var s=e.dataTransfer.files,u=0;u0&&(c=r.name.substring(l+1)),c){case"bmp":n=rr.DWT.EnumDWT_ImageType.IT_BMP;break;case"jpg":case"jpeg":n=rr.DWT.EnumDWT_ImageType.IT_JPG;break;case"tif":case"tiff":n=rr.DWT.EnumDWT_ImageType.IT_TIF;break;case"png":n=rr.DWT.EnumDWT_ImageType.IT_PNG;break;case"pdf":n=rr.DWT.EnumDWT_ImageType.IT_PDF;break;case"jp2":case"j2k":case"j2c":n=rr.DWT.EnumDWT_ImageType.IT_J2K;break;default:Il.output(null,r.name+" failed to load because the file type is not supported!"),n=-1,fa(i._stwain)}}else switch(r.type){case"image/bmp":n=rr.DWT.EnumDWT_ImageType.IT_BMP;break;case"image/jpg":case"image/jpeg":n=rr.DWT.EnumDWT_ImageType.IT_JPG;break;case"image/tif":case"image/tiff":n=rr.DWT.EnumDWT_ImageType.IT_TIF;break;case"image/png":n=rr.DWT.EnumDWT_ImageType.IT_PNG;break;case"application/pdf":n=rr.DWT.EnumDWT_ImageType.IT_PDF;break;case"image/jp2":n=rr.DWT.EnumDWT_ImageType.IT_J2K;break;default:Il.output(null,r.name+" failed to load because the file type is not supported!"),n=-1,fa(i._stwain)}if(-1!=n){if(i._stwain._bIfShowProgressBar){var d=i._stwain.IfShowCancelDialogWhenImageTransfer;i._stwain.IfShowCancelDialogWhenImageTransfer=!1,Qt.showProgress(i._stwain,"DropLoading",i._stwain.IfShowCancelDialogWhenImageTransfer),i._stwain.IfShowCancelDialogWhenImageTransfer=d}else Qt.hideProgress();if(i._stwain._OnPercentDone([0,-1,ul.Loading]),i._stwain.Addon&&i._stwain.Addon.PDF){Ac.checkProductKey(i._stwain,{PDFRasterizer:!0},!0)}!function(e){var t=new FileReader;t.readAsDataURL(e),t.onload=function(){var t=i._stwain.__GetLoadEventsNum();Qt.cancelFrom=sG.LoadImage,i._stwain.__LoadImageFromBytesV2(e,n,"",!0,0,e.size,!1,t,o,a)},t.onerror=function(e){ka(i._stwain),i._stwain._errorString=this.error,a(i._stwain._errorCode,i._stwain._getErrorString())}}(s[u])}}}catch(f){Zt.error(f.stack||f,"error"),setTimeout((function(){throw f}),0)}}},{key:"__pageChange",value:function(e,t){var r,n=t,i=n._ImgManager.count();if(Zt.log("OnPagination"),i<=0)da(n._stwain);else if(1!=i){!/^\d+$/.test(e)||e<=0?alert(oH.errorMessages.invalidIndex):((r=nr(e)-1)<0?r=0:r>=i&&(r=i-1),r!=n._ImgManager.getCurrentImageIndex()&&n.GetWebViewer().gotoPage(r))}}},{key:"__bufferChanged",value:function(e,t,r){var n,i=e,o=[],a=-1,s=[];t.operation&&(t.action=t.operation);for(var u=0;u=0&&(n=i._ImgManager.getCustomDataByIndex(t.curIndex))&&n.serverId&&(a=this._ImgManager._serverId2uidFromServer(n.serverId)),t.currentId=a,"modify"==t.operation&&""!=t.afterStatus.modifiedUid){var c=i._ImgManager.getIndexByUid(t.afterStatus.modifiedUid);c>=0&&(n=i._ImgManager.getCustomDataByIndex(c))&&n.serverId&&(t.modifiedId=this._ImgManager._serverId2uidFromServer(n.serverId))}if(t.afterStatus.selectedUids)for(var l=0;l=0&&(n=i._ImgManager.getCustomDataByIndex(f))&&n.serverId&&s.push(this._ImgManager._serverId2uidFromServer(n.serverId))}}t.selectedIds=s,Zt.mix(t,{}),delete t.uids,delete t.currentUid,delete t.selectedUids,delete t.afterStatus,delete t.beforeStatus,delete t.operation,delete t.curIndex,delete t.docUid,i.__fireEvent("onBufferChanged",t)}},{key:"__setError",value:function(e,t,r){var n=r;n._stwain._errorCode=e,n._stwain._errorString=t}},{key:"__acquire",value:function(e,t){var r=e;try{var n=!1;1==rr.DWT.IfConfineMaskWithinTheViewer&&(rr.DWT.IfConfineMaskWithinTheViewer=!1,n=!0);var i;i=Zt.isArray(t)&&t.length>=3?t:oH.dialogText.selectSource,r._stwain._selectSourceAsync("SelectSourceAsync",null,i).then((function(){return r._stwain.AcquireImageAsync({IfShowUI:!0,IfCloseSourceAfterAcquire:!0})})).then((function(){n&&(rr.DWT.IfConfineMaskWithinTheViewer=!0)}))["catch"]((function(e){Zt.log("User did not select a source"),n&&(rr.DWT.IfConfineMaskWithinTheViewer=!0)}))}catch(o){}}},{key:"__loadImage",value:function(e){if(e){var t=e._stwain._containerElement;try{var r=e,n=null;rr.DWT.IfConfineMaskWithinTheViewer&&(n=!0,rr.DWT.IfConfineMaskWithinTheViewer=!1),r._stwain._containerElement=undefined;if(r._stwain.IfShowFileDialog=!0,r._stwain.Addon&&r._stwain.Addon.PDF){Ac.checkProductKey(r._stwain,{PDFRasterizer:!0},!0)}r._stwain.LoadImageEx("",5,(function(){t&&(r._stwain._containerElement=t),Zt.log("Loaded an image successfully."),null!=n&&(rr.DWT.IfConfineMaskWithinTheViewer=n)}),(function(e,i){t&&(r._stwain._containerElement=t),Zt.log("Loading failed with the error: "+i),null!=n&&(rr.DWT.IfConfineMaskWithinTheViewer=n)}))}catch(i){t&&(e._stwain._containerElement=t)}}}},{key:"__print",value:function(e){var t=e;es(t._stwain),t._ImgManager.getCurrentImageIndex()<0||t._ImgManager.PrintCurrentImage()}},{key:"__save",value:(e=n(g().mark((function r(e,t,n,i,o){var a,s,u,c,l,d;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=e,s="save",e){r.next=3;break}return r.abrupt("return");case 3:if(es(a._stwain),!(a._ImgManager.count()<=0||a._ImgManager.getCurrentImageIndex()<0)){r.next=6;break}return r.abrupt("return");case 6:return u=e._stwain._containerElement,a._stwain._containerElement=undefined,c=a.__getViewerElement(a,o),Ll(s,c),r.prev=10,l=this._ImgManager.getIndexByUid(t),d=this._ImgManager.convertClientIndexToServerId(l),r.next=15,a._stwain._updateImage(d,n,i);case 15:r.sent,r.next=20;break;case 18:r.prev=18,r.t0=r["catch"](10);case 20:return r.prev=20,u&&(e._stwain._containerElement=u),n=null,Bl(s),r.finish(20);case 25:return r.abrupt("return",void 0);case 26:case"end":return r.stop()}}),r,this,[[10,18,20,25]])}))),function(t,r,n,i,o){return e.apply(this,arguments)})},{key:"__removePage",value:function(e,t){var r=e;e&&(r._ImgManager.count()<=0||r._ImgManager.getCurrentImageIndex()<0||r._stwain.RemoveImage(t))}},{key:"__getViewerElement",value:function(e,t){var r,n=e;if(t)if(n.GetWebViewer().webViewer.imageEditor){var i=n.GetWebViewer().createImageEditor();r="dwt-viewer-imageEditor-fullScreen"==i.inner.containerElement.className?{_containerElement:document.body}:{_containerElement:i.inner.containerElement}}else r=n._stwain;else r=n._stwain;return r}},{key:"__deskew",value:function(e,t,r){var n=this,i="deskew";es(n._stwain);var o=n._ImgManager.getCurrentImageIndex();if(n._ImgManager.count()<=0||o<0)dH.output(n,"No image in Buffer");else{var a=n.__getViewerElement(n,!0);Ll(i,a);n._stwain.GetSkewAngleFromBinaryAsync(o,t,(function(e){r(e[0]),Bl(i)}),(function(){Bl(i)}))}}},{key:"__remove",value:function(e){var t=this;es(t._stwain),t._ImgManager.count()<=0||t._ImgManager.getCurrentImageIndex()<0?dH.output(t,"No image in Buffer"):t._stwain.RemoveAllSelectedImages()}},{key:"__removeAll",value:function(e){var t=this;es(t._stwain),t._ImgManager.count()<=0||t._ImgManager.getCurrentImageIndex()<0?dH.output(t,"No image in Buffer"):t._stwain.RemoveAllImages()}},{key:"__onBindViewer",value:function(e){e&&($G._setContainer(this._stwain,e),e.id&&(rr.DWT.ContainerMap[e.id]=this._stwain))}},{key:"__onUnBindViewer",value:function(e){if(e){var t=$G._getContainer(this._stwain);if(t)for(;t.firstChild;)t.removeChild(t.firstChild);if($G._setContainer(this._stwain,null),e.id){var r=rr.DWT.ContainerMap;e.id in r&&delete rr.DWT.ContainerMap[e.id]}}}},{key:"__close",value:function(e){es(this._stwain),$G._closeImageEditorUI(this._stwain)}},{key:"__rotateRightForServer",value:function(e){var t=this;es(t._stwain);var r=t._ImgManager.getCurrentImageIndex();t._ImgManager.count()<=0||r<0?dH.output(t,"No image in Buffer"):t._stwain.RotateRight(r)}},{key:"__rotateForServer",value:function(e,t,r,n){var i=this;es(i._stwain);var o=i._ImgManager.getCurrentImageIndex();i._ImgManager.count()<=0||o<0?dH.output(i,"No image in Buffer"):i._stwain.RotateEx(o,t,n,r)}},{key:"__rotateLeftForServer",value:function(e){var t=this;es(t._stwain);var r=t._ImgManager.getCurrentImageIndex();t._ImgManager.count()<=0||r<0?dH.output(t,"No image in Buffer"):t._stwain.RotateLeft(r)}},{key:"__deskewForServer",value:function(e){var t=this;es(t._stwain);var r=t._ImgManager.getCurrentImageIndex();t._ImgManager.count()<=0||r<0?dH.output(t,"No image in Buffer"):t._stwain.GetSkewAngleAsync(r).then((function(e){t._stwain.RotateEx(r,e,!0,5,(function(){}),(function(){}))}))}},{key:"__cropForServer",value:function(e,t){var r=this;es(r._stwain);var n=r._ImgManager.getCurrentImageIndex();if(r._ImgManager.count()<=0||n<0)dH.output(r,"No image in Buffer");else{var i=t.left,o=t.top,a=i+t.width,s=o+t.height;r._stwain.Crop(n,nr(i),nr(o),nr(a),nr(s))}}},{key:"__eraseForServer",value:function(e,t){var r=this;es(r._stwain);var n=r._ImgManager.getCurrentImageIndex();if(r._ImgManager.count()<=0||n<0)dH.output(r,"No image in Buffer");else{var i=t.left,o=t.top,a=i+t.width,s=o+t.height;r._stwain.CutFrameToClipboard(n,nr(i),nr(o),nr(a),nr(s))}}},{key:"__changeImageSizeForServer",value:function(e,t,r,n){var i=this;es(i._stwain);var o=i._ImgManager.getCurrentImageIndex();i._ImgManager.count()<=0||o<0?dH.output(i,"No image in Buffer"):i._stwain.ChangeImageSize(o,t,r,n)}},{key:"__flipForServer",value:function(e){var t=this;es(t._stwain);var r=t._ImgManager.getCurrentImageIndex();t._ImgManager.count()<=0||r<0?dH.output(t,"No image in Buffer"):t._stwain.Flip(r)}},{key:"__mirrorForServer",value:function(e){var t=this;es(t._stwain);var r=t._ImgManager.getCurrentImageIndex();t._ImgManager.count()<=0||r<0?dH.output(t,"No image in Buffer"):t._stwain.Mirror(r)}},{key:"__restoreForServer",value:function(e,t){var r=e;if(es(r._stwain),r._ImgManager.count()<=0||r._ImgManager.getCurrentImageIndex()<0)dH.output(r,"No image in Buffer");else{var n=r._ImgManager.getIndexByUid(t);n>=0&&r.__RestoreImageInner(r,n)}}},{key:"__saveForServer",value:function(e,t){var r=e;return new ci.Promise((function(e,n){es(r._stwain),(r._ImgManager.count()<=0||r._ImgManager.getCurrentImageIndex()<0)&&(dH.output(r,"No image in Buffer"),e());var i=r._ImgManager.getIndexByUid(t);i>=0?r.__SaveImageInner(r,i,!0,(function(){e()})):e()}))}},{key:"__RestoreImageInner",value:function(e,t,r){var n=e,i=n._ImgManager.getImageIdMap(n._ImgManager.convertClientIndexToServerId(t));i&&n.__OnGetImageFromServerForEdit(i,t,1,(function(e,t,i){if(e){Zt.log("__RestoreImageInner: "+[e.uuid].join(","));var o=Zt.clone(e);o.imageId=e.serverId,n._ImgManager.UpdateImage(o,i)}if(-1==(e&&e.serverId))return r&&r(),!1;r&&r()}))}},{key:"__SaveImageInner",value:function(e,t,r,n){var i=e,o=i._ImgManager.getImageIdMap(i._ImgManager.convertClientIndexToServerId(t));return o&&i.__OnGetImageFromServerForEdit(o,t,2,(function(e,t,o){if(e){if(1==r&&(Zt.log("__SaveImageInner: "+[e.uuid].join(",")),i._ImgManager.getCurrentImageIndex()==t)){var a=Zt.clone(e);a.imageId=e.serverId,i._ImgManager.UpdateImage(a,o)}if(-1==e.serverId)return n&&n(),!1}return n&&n(),!0})),!0}},{key:"__OnGetImageFromServerForEdit",value:function(e,t,r,n){var i=this;if(n&&i._ImgManager.getBaseUrl){var o=i._ImgManager.convertClientIndexToServerId(t);if(-1==o)return!1;rr.DWT.ConnectWithSocket?n():Vi({method:"GET",xhrFields:{withCredentials:!0},url:Il.getUrlByAct(i._ImgManager.getBaseUrl,o,r),onSuccess:function(r){var a;e.ticks=Date.now(),a=rr.navInfoSync.bMobile?Il.getImageUrl(i._ImgManager.getBaseUrl,o,Math.round(e.iImageControlWidth*devicePixelRatio),Math.round(e.iImageControlHeight*devicePixelRatio),e.ticks):Il.getImageUrl(i._ImgManager.getBaseUrl,o,nr(e.iImageControlWidth),nr(e.iImageControlHeight),e.ticks),e.imageUrl=Il.getImageUrl(i._ImgManager.getBaseUrl,o,-1,-1,e.ticks),e.minImageUrl=a;var s=i._ImgManager.GetMetaDataByIndex(t);if(s){var u=i._ImgManager.getImageIdMap(o);u&&u.width?s.width=u.width:s.width=i._stwain.GetImageWidth(t),u&&u.height?s.height=u.height:s.height=i._stwain.GetImageHeight(t)}n(e,t,s)},onError:function(){}})}return!0}}]);var e}(),mH=function(e){function t(e,r){var n;o(this,t);var a=n=i(this,t,[r]);return a._stwain=e,a.bImageJustChangedInEditor=!1,a.bImageChangedInViewer=!1,n}return f(t,e),s(t,[{key:"getUidByIndex",value:function(e){return this._buffer.getUidByIndex(e)}},{key:"dispose",value:function(){return!0}},{key:"append",value:function(e,t,r,n,i){var o,a,s,u,c,l=this;(this._buffer.isActiveFile||!Zt.isUndefined(i))&&n.currentFileName&&n.currentFileName.length>0?c=a=l.getCountByDocumentName(n.currentFileName):(a=l.count(),c=l.getCountByDocumentName(l.GetCurrentFileName())),s=l.getCurrentImageIndex();for(var d=a-1;d>=e;d--)u=l.convertClientIndexToServerId(d),l.removeByServerId(u,d);return a=a-1?0:s+1,u=l.convertClientIndexToServerId(o),l.removeByServerId(u,o),o==e-1?l._updateUIAfterAdd(o,t,r,n,!0):l._updateUIAfterAdd(o,t,r,n,!1))}},{key:"insertBefore",value:function(e,t,r,n,i){var o,a=1*e;return(a<0||a>t)&&(a=-1),a>=(o=this.count())&&(a=o),this._updateUIAfterAdd(a,r,n,i,!1)}},{key:"exists",value:function(e){return!Zt.isUndefined(this.getImageIdMap(e))}},{key:"insert",value:function(e,t,r,n,i){var o,a=1*e;return(a<0||a>t)&&(a=-1),a>=(o=this.count())&&(a=o),this._updateUIAfterAdd(a,r,n,i,!1)}},{key:"moveImage",value:function(e,t,r){return this._buffer.moveImage(e,t)}},{key:"switchImage",value:function(e,t){return this._buffer.switchImage(e,t)}},{key:"setSelectedClientIndexArray",value:function(e){return this._buffer.selectImages(e)}},{key:"getSelectedClientIndexArray",value:function(e){return this._buffer.getSelectedImagesIndices()}},{key:"showImagesByFilter",value:function(e,t,r){return this._buffer.filterImagesByTag(e,t,r)}},{key:"clearFilter",value:function(){return this._buffer.clearFilter()}},{key:"removeImageTag",value:function(e){return this._buffer.removeImageTag(e)}},{key:"addImageTag",value:function(e,t){return this._buffer.tagImages(e,t)}},{key:"getCurrentTag",value:function(){var e;return 0==(e=this._buffer.getCurrentTag())?"":e}},{key:"renameTag",value:function(e,t){return this._buffer.renameTag(e,t)}},{key:"removeTag",value:function(e,t){return this._buffer.removeTag(e,t)}},{key:"getTagList",value:function(){return this._buffer.getTagList()}},{key:"getTagListByIndex",value:function(e){return this._buffer.getTagListByIndex(e)}},{key:"OpenFile",value:function(e){return this._buffer.openDocument(e)}},{key:"CreateFile",value:function(e){return this._buffer.createDocument(e)}},{key:"GetCurrentFileName",value:function(){return this._buffer.getCurrentFileName()}},{key:"RemoveFile",value:function(e){return this._buffer.removeDocument(e)}},{key:"RenameFile",value:function(e,t){return this._buffer.renameDocument(e,t)}},{key:"GetFileInfoList",value:function(){return this._buffer.getDocumentInfoList()}},{key:"MoveImageToFile",value:function(e,t,r,n){return this._buffer.moveImageToFile(e,t,r,n)}},{key:"GetServerIdsByFileName",value:function(e){var t,r=this,n=[];return(t=r.GetFileInfoList())?Zt.each(t,(function(t){if(e==t.name){if(t.imageIds)for(var i=0;i0&&n.push(a)}}return!1}})):n=[],n}},{key:"insertImage",value:function(e,t,r){this._buffer.insertImage(t,e,r)}},{key:"GetMetaDataByIndex",value:function(e){return this._buffer.getMetadataByUid(this._buffer.getUidByIndex(e))}},{key:"RefreshAllImages",value:function(e,t){for(var r,n,i,o=this,a=0;a=0&&(r=n.getImageIdMap(e))&&n.__GetImageAndAttach(r,e,!0,!1,!1,0)}},{key:"AddImage",value:function(e,t,r,n,i){var o,a=this,s=1*e;return!(t<=0)&&((o=new Rf).bIsDirty=!0,o.serverId=t,o.uidFromServer=r,a._serverIdMap[t]=o,a._uidMap[r]=o,t>=0&&a.__GetImageAndAttach(o,t,!1,!0,i,s,n),!0)}},{key:"OnGetImageByURL",value:function(e,t,r,n,i,o,a,s){return t.imageUrl&&""!=t.imageUrl?(t.iImageControlWidth=r,t.iImageControlHeight=n,t.bAddImage=i,t.bAppendImage=o,t.index=a,this._attachImagesForControl(t,s),!0):this.OnGetImageFromServer(e,t,r,n,i,o,a,s)}},{key:"OnGetImageFromServer",value:function(e,t,r,n,i,o,a,s){var u,c,l=this,d=l._baseUrl;if(d){if(e<=0)return!1;t.bIsDirty&&(t.ticks=Date.now()),Zt.isUndefined(r)&&(r=-1),Zt.isUndefined(n)&&(n=-1),t.iImageControlWidth=r,t.iImageControlHeight=n,t.bAddImage=i,t.bAppendImage=o,t.index=a,rr.DWT.ConnectWithSocket&&l._stwain._isBindViewer()?(l._attachImagesForControl(t,s),$G._getblob_queue.push([l._stwain,e,s]),$G.ProcessGetBlobByQueue()):(u=Il.getImageUrl(d,e,-1,-1,t.ticks),c=rr.navInfoSync.bMobile?Il.getImageUrl(d,e,Math.round(r*devicePixelRatio),Math.round(n*devicePixelRatio),t.ticks):Il.getImageUrl(d,e,r,n,t.ticks),t.imageUrl=u,t.minImageUrl=c,l._attachImagesForControl(t,s))}return!0}},{key:"getBaseUrl",get:function(){return this._baseUrl}},{key:"_attachImagesForControl",value:function(e,t){var r,n,i=this;if((n=Zt.clone(e)).imageId=n.serverId,n.bAddImage){if(r=t.currentFileName.length>0?i._buffer.addImage(n,t,t.currentFileName):i._buffer.addImage(n,t)){var o=p(r,1)[0],a=this.getImageIdMap(n.serverId);a&&(a.uuid=o);var s=this._buffer.getCustomDataByUid(o);s&&(s.serverId&&n&&n.serverId&&(s.serverId=n.serverId),s.uidFromServer&&(s.uidFromServer=n.uidFromServer))}}else i._buffer.updateImage(n,t);return!0}},{key:"_updateUIAfterAdd",value:function(e,t,r,n,i){return!(t<0)&&this.AddImage(e,t,r,n,i)}},{key:"__GetImageAndAttach",value:function(e,t,r,n,i,o,a){var s,u,c,l=this;l._stwain._isBindViewer()?(c=l._stwain.Viewer.height>=400?l._stwain.Viewer.height:400,u=l._stwain.Viewer.width>=400?l._stwain.Viewer.width:400):(u=-1,c=-1);var d=!1;d=!!r||1==e.bIsDirty;var f=null===(s=l.getImageIdMap(t))||void 0===s?void 0:s.uuid;f&&-1!=f&&e.iImageControlWidth==u&&e.iImageControlHeight==c&&0==e.bIsDirty||l.__SetArrayControlLoadImage(t,e,u,c,d,n,i,o,a)}},{key:"__SetArrayControlLoadImage",value:function(e,t,r,n,i,o,a,s,u){i?this.OnGetImageFromServer(e,t,r,n,o,a,s,u):this.OnGetImageByURL(e,t,r,n,o,a,s,u)}},{key:"GetServerIdList",value:function(){var e,t,r,n=this,i=[];if(e=n._buffer.getDocumentContents(n._buffer.getCurrentDocument()))for(var o=0;o0?o=i.brands:"uaList"in i&&Zt.isArray(i.uaList)&&i.uaList.length>0&&(o=i.uaList),o.length>0)return(r=function(e){var t=de,r=e.architecture.toLowerCase(),n="64"==e.bitness,i=r.indexOf("arm")>-1,o=r.indexOf("mips")>-1;return{bUseUserAgent:!1,bWin:t.bWin,bMac:t.bMac,bLinux:t.bLinux,bAndroid:t.bAndroid,bMobile:t.bMobile,bPad:t.bPad,bChromeOS:t.bChromeOS,bHarmonyOS:t.bHarmonyOS,bArm64:i,bMips64:o,bEmbed:i||o,bOSx64:n,bIE:!1,bEdge:t.bEdge,bChrome:t.bChrome,bFirefox:t.bFirefox,bSafari:t.bSafari,bOpera:t.bOpera,bGecko:!0,bHuaWeiBrowser:!1,bHTML5Edition:!0,strBrowserVersion:t.strBrowserVersion,IEMode:0}},t?window.Dynamsoft.Lib.Promise.resolve((function(){return r(t)})):navigator.userAgentData.getHighEntropyValues(["platform","platformVersion","architecture","bitness"]).then(r)).then((function(e){return fH=e,e}))}}return fH=de,e.resolve(fH)}var vH=0,_H=[],yH=!(!document||!document.addEventListener),SH="DOMContentLoaded",IH="readystatechange",bH="load",TH="complete",CH=yH?function(e,t,r){e.addEventListener(t,r,!1)}:function(e,t,r){e.attachEvent("on"+t,r)},wH=yH?function(e,t,r){e.removeEventListener(t,r,!1)}:function(e,t,r){e.detachEvent("on"+t,r)};function EH(){vH||(vH=1,pH().then((function(){document&&wH(window,bH,EH),function(){for(var e=function(){try{_H[t]()}catch(jj){Zt.log(jj,"error"),setTimeout((function(){throw jj}),0)}},t=0;t<_H.length;t++)e()}()})))}function kH(e){if(vH)try{e()}catch(jj){Zt.log(jj,"error"),setTimeout((function(){throw jj}),0)}else _H.push(e);return this}var AH=function(e){var t=e||window.event,r=!0;return Zt.each(ci.Events.registedObjs,(function(e){Zt.each(ci.Events.registedClass,(function(n){if(e instanceof n&&e.bFocus&&e.handlerKeyDown&&!(r=e.handlerKeyDown(t)))return!1}))})),r};function xH(e,t){for(var r in t)t.hasOwnProperty(r)&&!Zt.isUndefined(t[r])&&(e.hasOwnProperty(r)&&!Zt.isUndefined(e[r])||(e[r]=t[r]));return e}kH((function(){Zt.addEventListener(document.documentElement,"keydown",AH)})),xH(rr.DWT,Io),xH(rr.DWT,bo),rr.DWT.CertificateConfig?xH(rr.DWT.CertificateConfig,wo):rr.DWT.CertificateConfig=wo,rr.DWT.RegisterEvent=function(e,t){if(Zt.isUndefined(e))throw{code:-2314,message:"The parameter cannot be empty."};if(!Zt.isString(e)||Zt.isString(e)&&0==e.trim().length||Zt.isUndefined(t)||!Zt.isFunction(t))throw{code:-2416,message:"Invalid parameter."};return Zt.isFunction(t)&&(rr.DWT[e]=t),!0};var PH=function(e){return e.CAP_NONE=0,e.CAP_XFERCOUNT=1,e.ICAP_COMPRESSION=256,e.ICAP_PIXELTYPE=257,e.ICAP_UNITS=258,e.ICAP_XFERMECH=259,e.CAP_AUTHOR=4096,e.CAP_CAPTION=4097,e.CAP_FEEDERENABLED=4098,e.CAP_FEEDERLOADED=4099,e.CAP_TIMEDATE=4100,e.CAP_SUPPORTEDCAPS=4101,e.CAP_EXTENDEDCAPS=4102,e.CAP_AUTOFEED=4103,e.CAP_CLEARPAGE=4104,e.CAP_FEEDPAGE=4105,e.CAP_REWINDPAGE=4106,e.CAP_INDICATORS=4107,e.CAP_SUPPORTEDCAPSEXT=4108,e.CAP_PAPERDETECTABLE=4109,e.CAP_UICONTROLLABLE=4110,e.CAP_DEVICEONLINE=4111,e.CAP_AUTOSCAN=4112,e.CAP_THUMBNAILSENABLED=4113,e.CAP_DUPLEX=4114,e.CAP_DUPLEXENABLED=4115,e.CAP_ENABLEDSUIONLY=4116,e.CAP_CUSTOMDSDATA=4117,e.CAP_ENDORSER=4118,e.CAP_ALARMS=4120,e.CAP_ALARMVOLUME=4121,e.CAP_AUTOMATICCAPTURE=4122,e.CAP_TIMEBEFOREFIRSTCAPTURE=4123,e.CAP_TIMEBETWEENCAPTURES=4124,e.CAP_CLEARBUFFERS=4125,e.CAP_MAXBATCHBUFFERS=4126,e.CAP_DEVICETIMEDATE=4127,e.CAP_POWERSUPPLY=4128,e.CAP_CAMERAPREVIEWUI=4129,e.CAP_SERIALNUMBER=4132,e.CAP_PRINTER=4134,e.CAP_PRINTERENABLED=4135,e.CAP_PRINTERINDEX=4136,e.CAP_PRINTERMODE=4137,e.CAP_PRINTERSTRING=4138,e.CAP_PRINTERSUFFIX=4139,e.CAP_LANGUAGE=4140,e.CAP_FEEDERALIGNMENT=4141,e.CAP_FEEDERORDER=4142,e.CAP_REACQUIREALLOWED=4144,e.CAP_BATTERYMINUTES=4146,e.CAP_BATTERYPERCENTAGE=4147,e.CAP_CAMERASIDE=4148,e.CAP_SEGMENTED=4149,e.CAP_CAMERAENABLED=4150,e.CAP_CAMERAORDER=4151,e.CAP_MICRENABLED=4152,e.CAP_FEEDERPREP=4153,e.CAP_FEEDERPOCKET=4154,e.CAP_AUTOMATICSENSEMEDIUM=4155,e.CAP_CUSTOMINTERFACEGUID=4156,e.ICAP_AUTOBRIGHT=4352,e.ICAP_BRIGHTNESS=4353,e.ICAP_CONTRAST=4355,e.ICAP_CUSTHALFTONE=4356,e.ICAP_EXPOSURETIME=4357,e.ICAP_FILTER=4358,e.ICAP_FLASHUSED=4359,e.ICAP_GAMMA=4360,e.ICAP_HALFTONES=4361,e.ICAP_HIGHLIGHT=4362,e.ICAP_IMAGEFILEFORMAT=4364,e.ICAP_LAMPSTATE=4365,e.ICAP_LIGHTSOURCE=4366,e.ICAP_ORIENTATION=4368,e.ICAP_PHYSICALWIDTH=4369,e.ICAP_PHYSICALHEIGHT=4370,e.ICAP_SHADOW=4371,e.ICAP_FRAMES=4372,e.ICAP_XNATIVERESOLUTION=4374,e.ICAP_YNATIVERESOLUTION=4375,e.ICAP_XRESOLUTION=4376,e.ICAP_YRESOLUTION=4377,e.ICAP_MAXFRAMES=4378,e.ICAP_TILES=4379,e.ICAP_BITORDER=4380,e.ICAP_CCITTKFACTOR=4381,e.ICAP_LIGHTPATH=4382,e.ICAP_PIXELFLAVOR=4383,e.ICAP_PLANARCHUNKY=4384,e.ICAP_ROTATION=4385,e.ICAP_SUPPORTEDSIZES=4386,e.ICAP_THRESHOLD=4387,e.ICAP_XSCALING=4388,e.ICAP_YSCALING=4389,e.ICAP_BITORDERCODES=4390,e.ICAP_PIXELFLAVORCODES=4391,e.ICAP_JPEGPIXELTYPE=4392,e.ICAP_TIMEFILL=4394,e.ICAP_BITDEPTH=4395,e.ICAP_BITDEPTHREDUCTION=4396,e.ICAP_UNDEFINEDIMAGESIZE=4397,e.ICAP_EXTIMAGEINFO=4399,e.ICAP_MINIMUMHEIGHT=4400,e.ICAP_MINIMUMWIDTH=4401,e.ICAP_AUTODISCARDBLANKPAGES=4404,e.ICAP_FLIPROTATION=4406,e.ICAP_BARCODEDETECTIONENABLED=4407,e.ICAP_SUPPORTEDBARCODETYPES=4408,e.ICAP_BARCODEMAXSEARCHPRIORITIES=4409,e.ICAP_BARCODESEARCHPRIORITIES=4410,e.ICAP_BARCODESEARCHMODE=4411,e.ICAP_BARCODEMAXRETRIES=4412,e.ICAP_BARCODETIMEOUT=4413,e.ICAP_ZOOMFACTOR=4414,e.ICAP_PATCHCODEDETECTIONENABLED=4415,e.ICAP_SUPPORTEDPATCHCODETYPES=4416,e.ICAP_PATCHCODEMAXSEARCHPRIORITIES=4417,e.ICAP_PATCHCODESEARCHPRIORITIES=4418,e.ICAP_PATCHCODESEARCHMODE=4419,e.ICAP_PATCHCODEMAXRETRIES=4420,e.ICAP_PATCHCODETIMEOUT=4421,e.ICAP_FLASHUSED2=4422,e.ICAP_IMAGEFILTER=4423,e.ICAP_NOISEFILTER=4424,e.ICAP_OVERSCAN=4425,e.ICAP_AUTOMATICBORDERDETECTION=4432,e.ICAP_AUTOMATICDESKEW=4433,e.ICAP_AUTOMATICROTATE=4434,e.ICAP_JPEGQUALITY=4435,e.ICAP_FEEDERTYPE=4436,e.ICAP_ICCPROFILE=4437,e.ICAP_AUTOSIZE=4438,e.ICAP_AUTOMATICCROPUSESFRAME=4439,e.ICAP_AUTOMATICLENGTHDETECTION=4440,e.ICAP_AUTOMATICCOLORENABLED=4441,e.ICAP_AUTOMATICCOLORNONCOLORPIXELTYPE=4442,e.ICAP_COLORMANAGEMENTENABLED=4443,e.ICAP_IMAGEMERGE=4444,e.ICAP_IMAGEMERGEHEIGHTTHRESHOLD=4445,e.ICAP_SUPPORTEDEXTIMAGEINFO=4446,e}({}),DH=function(e){return e.TWLG_DAN=0,e.TWLG_DUT=1,e.TWLG_ENG=2,e.TWLG_FCF=3,e.TWLG_FIN=4,e.TWLG_FRN=5,e.TWLG_GER=6,e.TWLG_ICE=7,e.TWLG_ITN=8,e.TWLG_NOR=9,e.TWLG_POR=10,e.TWLG_SPA=11,e.TWLG_SWE=12,e.TWLG_USA=13,e.TWLG_USERLOCALE=-1,e.TWLG_AFRIKAANS=14,e.TWLG_ALBANIA=15,e.TWLG_ARABIC=16,e.TWLG_ARABIC_ALGERIA=17,e.TWLG_ARABIC_BAHRAIN=18,e.TWLG_ARABIC_EGYPT=19,e.TWLG_ARABIC_IRAQ=20,e.TWLG_ARABIC_JORDAN=21,e.TWLG_ARABIC_KUWAIT=22,e.TWLG_ARABIC_LEBANON=23,e.TWLG_ARABIC_LIBYA=24,e.TWLG_ARABIC_MOROCCO=25,e.TWLG_ARABIC_OMAN=26,e.TWLG_ARABIC_QATAR=27,e.TWLG_ARABIC_SAUDIARABIA=28,e.TWLG_ARABIC_SYRIA=29,e.TWLG_ARABIC_TUNISIA=30,e.TWLG_ARABIC_UAE=31,e.TWLG_ARABIC_YEMEN=32,e.TWLG_BASQUE=33,e.TWLG_BYELORUSSIAN=34,e.TWLG_BULGARIAN=35,e.TWLG_CATALAN=36,e.TWLG_CHINESE=37,e.TWLG_CHINESE_HONGKONG=38,e.TWLG_CHINESE_PRC=39,e.TWLG_CHINESE_SINGAPORE=40,e.TWLG_CHINESE_SIMPLIFIED=41,e.TWLG_CHINESE_TAIWAN=42,e.TWLG_CHINESE_TRADITIONAL=43,e.TWLG_CROATIA=44,e.TWLG_CZECH=45,e.TWLG_DANISH=0,e.TWLG_DUTCH=1,e.TWLG_DUTCH_BELGIAN=46,e.TWLG_ENGLISH=2,e.TWLG_ENGLISH_AUSTRALIAN=47,e.TWLG_ENGLISH_CANADIAN=48,e.TWLG_ENGLISH_IRELAND=49,e.TWLG_ENGLISH_NEWZEALAND=50,e.TWLG_ENGLISH_SOUTHAFRICA=51,e.TWLG_ENGLISH_UK=52,e.TWLG_ENGLISH_USA=13,e.TWLG_ESTONIAN=53,e.TWLG_FAEROESE=54,e.TWLG_FARSI=55,e.TWLG_FINNISH=4,e.TWLG_FRENCH=5,e.TWLG_FRENCH_BELGIAN=56,e.TWLG_FRENCH_CANADIAN=3,e.TWLG_FRENCH_LUXEMBOURG=57,e.TWLG_FRENCH_SWISS=58,e.TWLG_GERMAN=6,e.TWLG_GERMAN_AUSTRIAN=59,e.TWLG_GERMAN_LUXEMBOURG=60,e.TWLG_GERMAN_LIECHTENSTEIN=61,e.TWLG_GERMAN_SWISS=62,e.TWLG_GREEK=63,e.TWLG_HEBREW=64,e.TWLG_HUNGARIAN=65,e.TWLG_ICELANDIC=7,e.TWLG_INDONESIAN=66,e.TWLG_ITALIAN=8,e.TWLG_ITALIAN_SWISS=67,e.TWLG_JAPANESE=68,e.TWLG_KOREAN=69,e.TWLG_KOREAN_JOHAB=70,e.TWLG_LATVIAN=71,e.TWLG_LITHUANIAN=72,e.TWLG_NORWEGIAN=9,e.TWLG_NORWEGIAN_BOKMAL=73,e.TWLG_NORWEGIAN_NYNORSK=74,e.TWLG_POLISH=75,e.TWLG_PORTUGUESE=10,e.TWLG_PORTUGUESE_BRAZIL=76,e.TWLG_ROMANIAN=77,e.TWLG_RUSSIAN=78,e.TWLG_SERBIAN_LATIN=79,e.TWLG_SLOVAK=80,e.TWLG_SLOVENIAN=81,e.TWLG_SPANISH=11,e.TWLG_SPANISH_MEXICAN=82,e.TWLG_SPANISH_MODERN=83,e.TWLG_SWEDISH=12,e.TWLG_THAI=84,e.TWLG_TURKISH=85,e.TWLG_UKRANIAN=86,e.TWLG_ASSAMESE=87,e.TWLG_BENGALI=88,e.TWLG_BIHARI=89,e.TWLG_BODO=90,e.TWLG_DOGRI=91,e.TWLG_GUJARATI=92,e.TWLG_HARYANVI=93,e.TWLG_HINDI=94,e.TWLG_KANNADA=95,e.TWLG_KASHMIRI=96,e.TWLG_MALAYALAM=97,e.TWLG_MARATHI=98,e.TWLG_MARWARI=99,e.TWLG_MEGHALAYAN=100,e.TWLG_MIZO=101,e.TWLG_NAGA=102,e.TWLG_ORISSI=103,e.TWLG_PUNJABI=104,e.TWLG_PUSHTU=105,e.TWLG_SERBIAN_CYRILLIC=106,e.TWLG_SIKKIMI=107,e.TWLG_SWEDISH_FINLAND=108,e.TWLG_TAMIL=109,e.TWLG_TELUGU=110,e.TWLG_TRIPURI=111,e.TWLG_URDU=112,e.TWLG_VIETNAMESE=113,e}({}),FH=function(e){return e.TWSS_NONE=0,e.TWSS_A4LETTER=1,e.TWSS_B5LETTER=2,e.TWSS_USLETTER=3,e.TWSS_USLEGAL=4,e.TWSS_A5=5,e.TWSS_B4=6,e.TWSS_B6=7,e.TWSS_USLEDGER=9,e.TWSS_USEXECUTIVE=10,e.TWSS_A3=11,e.TWSS_B3=12,e.TWSS_A6=13,e.TWSS_C4=14,e.TWSS_C5=15,e.TWSS_C6=16,e.TWSS_4A0=17,e.TWSS_2A0=18,e.TWSS_A0=19,e.TWSS_A1=20,e.TWSS_A2=21,e.TWSS_A4=1,e.TWSS_A7=22,e.TWSS_A8=23,e.TWSS_A9=24,e.TWSS_A10=25,e.TWSS_ISOB0=26,e.TWSS_ISOB1=27,e.TWSS_ISOB2=28,e.TWSS_ISOB3=12,e.TWSS_ISOB4=6,e.TWSS_ISOB5=29,e.TWSS_ISOB6=7,e.TWSS_ISOB7=30,e.TWSS_ISOB8=31,e.TWSS_ISOB9=32,e.TWSS_ISOB10=33,e.TWSS_JISB0=34,e.TWSS_JISB1=35,e.TWSS_JISB2=36,e.TWSS_JISB3=37,e.TWSS_JISB4=38,e.TWSS_JISB5=2,e.TWSS_JISB6=39,e.TWSS_JISB7=40,e.TWSS_JISB8=41,e.TWSS_JISB9=42,e.TWSS_JISB10=43,e.TWSS_C0=44,e.TWSS_C1=45,e.TWSS_C2=46,e.TWSS_C3=47,e.TWSS_C7=48,e.TWSS_C8=49,e.TWSS_C9=50,e.TWSS_C10=51,e.TWSS_USSTATEMENT=52,e.TWSS_BUSINESSCARD=53,e.TWSS_MAXSIZE=54,e}({}),WH=function(e){return e.TWON_NONE=0,e.TWON_ARRAY=3,e.TWON_ENUMERATION=4,e.TWON_ONEVALUE=5,e.TWON_RANGE=6,e}({}),NH=function(e){return e.TWTY_INT8=0,e.TWTY_INT16=1,e.TWTY_INT32=2,e.TWTY_UINT8=3,e.TWTY_UINT16=4,e.TWTY_int=5,e.TWTY_BOOL=6,e.TWTY_FIX32=7,e.TWTY_FRAME=8,e.TWTY_STR32=9,e.TWTY_STR64=10,e.TWTY_STR128=11,e.TWTY_STR255=12,e}({}),RH=function(e){return e.TWFA_NONE=0,e.TWFA_LEFT=1,e.TWFA_CENTER=2,e.TWFA_RIGHT=3,e}({}),OH=function(e){return e.TWFO_FIRSTPAGEFIRST=0,e.TWFO_LASTPAGEFIRST=1,e}({}),MH=function(e){return e.TWPR_IMPRINTERTOPBEFORE=0,e.TWPR_IMPRINTERTOPAFTER=1,e.TWPR_IMPRINTERBOTTOMBEFORE=2,e.TWPR_IMPRINTERBOTTOMAFTER=3,e.TWPR_ENDORSERTOPBEFORE=4,e.TWPR_ENDORSERTOPAFTER=5,e.TWPR_ENDORSERBOTTOMBEFORE=6,e.TWPR_ENDORSERBOTTOMAFTER=7,e}({}),LH=function(e){return e.TWPM_SINGLESTRING=0,e.TWPM_MULTISTRING=1,e.TWPM_COMPOUNDSTRING=2,e}({}),BH=function(e){return e.TWBR_THRESHOLD=0,e.TWBR_HALFTONE=1,e.TWBR_CUSTHALFTONE=2,e.TWBR_DIFFUSION=3,e}({}),UH=function(e){return e.TWBO_LSBFIRST=0,e.TWBO_MSBFIRST=1,e}({}),VH=function(e){return e.TWFT_RED=0,e.TWFT_GREEN=1,e.TWFT_BLUE=2,e.TWFT_NONE=3,e.TWFT_WHITE=4,e.TWFT_CYAN=5,e.TWFT_MAGENTA=6,e.TWFT_YELLOW=7,e.TWFT_BLACK=8,e}({}),jH=function(e){return e.TWFL_NONE=0,e.TWFL_OFF=1,e.TWFL_ON=2,e.TWFL_AUTO=3,e.TWFL_REDEYE=4,e}({}),GH=function(e){return e.TWFR_BOOK=0,e.TWFR_FANFOLD=1,e}({}),HH=function(e){return e.TWIF_NONE=0,e.TWIF_AUTO=1,e.TWIF_LOWPASS=2,e.TWIF_BANDPASS=3,e.TWIF_HIGHPASS=4,e.TWIF_TEXT=3,e.TWIF_FINELINE=4,e}({}),zH=function(e){return e.TWLP_REFLECTIVE=0,e.TWLP_TRANSMISSIVE=1,e}({}),KH=function(e){return e.TWLS_RED=0,e.TWLS_GREEN=1,e.TWLS_BLUE=2,e.TWLS_NONE=3,e.TWLS_WHITE=4,e.TWLS_UV=5,e.TWLS_IR=6,e}({}),JH=function(e){return e.TWNF_NONE=0,e.TWNF_AUTO=1,e.TWNF_LONEPIXEL=2,e.TWNF_MAJORITYRULE=3,e}({}),QH=function(e){return e.TWOR_ROT0=0,e.TWOR_ROT90=1,e.TWOR_ROT180=2,e.TWOR_ROT270=3,e.TWOR_PORTRAIT=0,e.TWOR_LANDSCAPE=3,e.TWOR_AUTO=4,e.TWOR_AUTOTEXT=5,e.TWOR_AUTOPICTURE=6,e}({}),qH=function(e){return e.TWOV_NONE=0,e.TWOV_AUTO=1,e.TWOV_TOPBOTTOM=2,e.TWOV_LEFTRIGHT=3,e.TWOV_ALL=4,e}({}),YH=function(e){return e.TWPF_CHOCOLATE=0,e.TWPF_VANILLA=1,e}({}),XH=function(e){return e.TWPC_CHUNKY=0,e.TWPC_PLANAR=1,e}({}),ZH=function(e){return e.Info=1,e.Error=2,e.NotInstalledError=3,e}({}),$H=function(e){return e.Binary=0,e.Base64=1,e}({}),ez=function(e){return e.TWPT_BW=0,e.TWPT_GRAY=1,e.TWPT_RGB=2,e.TWPT_PALLETE=3,e.TWPT_CMY=4,e.TWPT_CMYK=5,e.TWPT_YUV=6,e.TWPT_YUVK=7,e.TWPT_CIEXYZ=8,e.TWPT_LAB=9,e.TWPT_SRGB=10,e.TWPT_SCRGB=11,e.TWPT_INFRARED=16,e}(ez||{}),tz=function(e){return e.TWUN_INCHES=0,e.TWUN_CENTIMETERS=1,e.TWUN_PICAS=2,e.TWUN_POINTS=3,e.TWUN_TWIPS=4,e.TWUN_PIXELS=5,e.TWUN_MILLIMETERS=6,e}(tz||{});Zt.mix(rr.DWT,{EnumDWT_DeviceType:Al,EnumDWT_Cap:PH,EnumDWT_CapLanguage:DH,EnumDWT_CapSupportedSizes:FH,EnumDWT_CapType:WH,EnumDWT_CapValueType:NH,EnumDWT_CapFeederAlignment:RH,EnumDWT_CapFeederOrder:OH,EnumDWT_CapPrinter:MH,EnumDWT_CapPrinterMode:LH,EnumDWT_CapBitdepthReduction:BH,EnumDWT_CapBitOrder:UH,EnumDWT_CapFilterType:VH,EnumDWT_CapFlash:jH,EnumDWT_CapFlipRotation:GH,EnumDWT_CapImageFilter:HH,EnumDWT_CapLightPath:zH,EnumDWT_CapLightSource:KH,EnumDWT_CapNoiseFilter:JH,EnumDWT_CapORientation:QH,EnumDWT_CapOverscan:qH,EnumDWT_CapPixelFlavor:YH,EnumDWT_CapPlanarChunky:XH,EnumDWT_ImageType:Wd,EnumDWT_ImageFormatType:SG,EnumDWT_ResponseType:aG,EnumDWT_SourceMatchField:Fd,EnumDWT_UploadDataFormat:$H,EnumDWT_WorkMode:rH,EnumDWT_ConvertMode:Zu,EnumDWT_PixelType:ez,EnumDWT_UnitType:tz});var rz=rr.DWT;rz.EnumPDF_Page={Page_Default:0,Page_Custom:1,Page_A4:2,Page_A4_Reverse:3,Page_A3:4,Page_A3_Reverse:5,Page_Letter:6,Page_Letter_Reverse:7,Page_Legal:8,Page_Legal_Reverse:9},rz.EnumDWT_BorderStyle={TWBS_NONE:0,TWBS_SINGLEFLAT:1,TWBS_SINGLE3D:2},rz.EnumDWT_MessageType={TWQC_GET:1,TWQC_SET:2,TWQC_GETDEFAULT:4,TWQC_GETCURRENT:8,TWQC_RESET:16},rz.EnumDWT_TransferMode={TWSX_NATIVE:0,TWSX_FILE:1,TWSX_MEMORY:2},rz.EnumDWT_FileFormat={TWFF_TIFF:0,TWFF_PICT:1,TWFF_BMP:2,TWFF_XBM:3,TWFF_JFIF:4,TWFF_FPX:5,TWFF_TIFFMULTI:6,TWFF_PNG:7,TWFF_SPIFF:8,TWFF_EXIF:9,TWFF_PDF:10,TWFF_JP2:11,TWFF_JPN:12,TWFF_JPX:13,TWFF_DEJAVU:14,TWFF_PDFA:15,TWFF_PDFA2:16},rz.EnumDWT_TIFFCompressionType={TIFF_AUTO:0,TIFF_NONE:1,TIFF_RLE:2,TIFF_FAX3:3,TIFF_T4:3,TIFF_FAX4:4,TIFF_T6:4,TIFF_LZW:5,TIFF_JPEG:7,TIFF_PACKBITS:32773},rz.EnumDWT_InterpolationMethod={IM_NEARESTNEIGHBOUR:1,IM_BILINEAR:2,IM_BICUBIC:3,IM_BESTQUALITY:5},rz.EnumDWT_PDFCompressionType={PDF_AUTO:0,PDF_FAX3:1,PDF_FAX4:2,PDF_LZW:3,PDF_RLE:4,PDF_JPEG:5,PDF_JP2000:6,PDF_JBIG2:7},rz.EnumDWT_ShowMode={SW_ACTIVE:0,SW_MAX:1,SW_MIN:2,SW_CLOSE:3,SW_IFLIVE:4},rz.EnumDWT_DUPLEX={TWDX_NONE:0,TWDX_1PASSDUPLEX:1,TWDX_2PASSDUPLEX:2},rz.EnumDWT_MagType={TWMD_MICR:0,TWMD_RAW:1,TWMD_INVALID:2},rz.EnumDWT_DataSourceStatus={TWDSS_CLOSED:0,TWDSS_OPENED:1,TWDSS_ENABLED:2,TWDSS_ACQUIRING:3};var nz=function(e){return e.enumFitWindow=0,e.enumFitWindowHeight=1,e.enumFitWindowWidth=2,e}(nz||{});rz.EnumDWT_FitWindowType={enumFitWindow:nz.enumFitWindow,enumFitWindowHeight:nz.enumFitWindowHeight,enumFitWindowWidth:nz.enumFitWindowWidth},rz.EnumDWT_PlatformType={enumUnknown:Gu.enumUnknown,enumWindow:Gu.enumWindow,enumMac:Gu.enumMac,enumLinux:Gu.enumLinux,enumEmbed:Gu.enumEmbed,enumChromeOS:Gu.enumChromeOS,enumHarmonyOS:Gu.enumHarmonyOS,enumAndroid:Gu.enumAndroid,enumiOS:Gu.enumiOS};var iz=function(e){return e.Default=0,e.Hand=1,e.Crosshair=2,e.Zoom=3,e.NWResize=4,e.EResize=5,e.NResize=6,e.Resize=7,e.Move=8,e}(iz||{});rz.EnumDWT_MouseShape={Default:iz.Default,Hand:iz.Hand,Crosshair:iz.Crosshair,Zoom:iz.Zoom,NWResize:iz.NWResize,EResize:iz.EResize,NResize:iz.NResize,Resize:iz.Resize,Move:iz.Move},rz.EnumDWT_Language={English:0,French:1,Arabic:2,Spanish:3,Portuguese:4,German:5,Italian:6,Russian:7,Chinese:8},rz.EnumDWT_InitMsg={Info:ZH.Info,Error:ZH.Error,NotInstalledError:ZH.NotInstalledError},rz.EnumDWT_Driver={TWAIN:If.TWAIN,ICA:If.ICA,SANE:If.SANE,TWAIN_AND_ICA:If.TWAIN_AND_ICA,TWAIN_AND_TWAIN64:If.TWAIN_AND_TWAIN64,TWAIN64:If.TWAIN64},rz.EnumDWT_CompressionType={TWCP_NONE:0,TWCP_PACKBITS:1,TWCP_GROUP31D:2,TWCP_GROUP31DEOL:3,TWCP_GROUP32D:4,TWCP_GROUP4:5,TWCP_JPEG:6,TWCP_LZW:7,TWCP_JBIG:8,TWCP_PNG:9,TWCP_RLE4:10,TWCP_RLE8:11,TWCP_BITFIELDS:12,TWCP_ZIP:13,TWCP_JPEG2000:14};var oz=function(e){return e.Single=0,e.Multiple=1,e}(oz||{});rz.EnumDWT_SelectionMode={Single:oz.Single,Multiple:oz.Multiple},rz.EnumDWT_ConfirmExitType={Cancel:0,Exit:1,SaveAndExit:2},rz.EnumDWT_WebsocketReadyState={CONNECTING:yd.CONNECTING,OPEN:yd.OPEN,CLOSING:yd.CLOSING,CLOSED:yd.CLOSED};var az=function(e){return e.TwainService=1,e}(az||{});rz.EnumDWT_ServiceType={TwainService:az.TwainService};var sz,uz=function(e){return e["default"]=0,e.standard=1,e.supported=2,e}(uz||{});rz.EnumDWT_ExtImageInfo={"default":uz["default"],standard:uz.standard,supported:uz.supported};var cz=20230506,lz=function(){if(rr.dcp){var e=rr.dcp.dcpJSVer;if(Zt.isNumber(e))return e>=cz}return!1};if(lz())lz=sz,cz=sz;else{var dz=Ho.detect,fz={_checkService:function(e,t){dz.dcpStatus=dz.EnumDCP_DetectStatus.CheckingServiceVer,hz(null,"DSVersion").then(e,t)},_checkUpdateFile:function(e,t){hz(null,"CheckUpdateFile").then(e,t)},_updateService:function(e,t){hz(null,"UpdateService").then(e,t)},_getDSUpdateZipUrl:function(){var e,t,r="";return e="Win",de.bMac?e="Mac":de.bLinux&&(e="Linux"),t=de.bFileSystem?"":"?t="+Zt.now(),de.bWin&&Ho.b64bit&&(r="_x64"),[yl(),"/dist/serviceupdate/",e,"DSUpdate_",lo().join("."),r,".zip",t].join("")},getPorts:function(e,t){var r="GetPorts",n="dwasm2_"+go();return gz(e,r,{id:Zt.guid(),method:r,version:n,parameter:[t]},Yo())},_getStatusString:function(e,t){var r,n,i="";return e==dz.EnumDCP_DetectStatus.Init?"Getting manager version":e==dz.EnumDCP_DetectStatus.Connected?(t&&(i=t),"Getting manager version succeeded and the version is "+i):e==dz.EnumDCP_DetectStatus.CheckingManagerVer?"Getting manager version":e==dz.EnumDCP_DetectStatus.CheckingServiceVer?"Getting service version":e==dz.EnumDCP_DetectStatus.NotInstalled?"Dynamic Web TWAIN Service Not Installed":e==dz.EnumDCP_DetectStatus.UpdateSkipped?"Update skipped":e==dz.EnumDCP_DetectStatus.CheckedService?(t&&(i=t),"Getting service version succeeded and the version is "+i):e==dz.EnumDCP_DetectStatus.VerifyingZip?"Verifying the update package":e==dz.EnumDCP_DetectStatus.VerifiedZip?"Update package verified":e==dz.EnumDCP_DetectStatus.UpdatingService?"Updating the service":e==dz.EnumDCP_DetectStatus.UpdateSucceed?"Update succeeded":e==dz.EnumDCP_DetectStatus.UpdateFailed?(n=".",t&&t.length>0?("."==t.slice(t.length-1)&&(n=""),r=" with the error: "+t):r="","The update failed"+r+n):""},_sendStatusEvent:function(e,t){var r=!!e,n=window;Zt.isFunction(n.OnGetServiceUpdateStatus)&&n.OnGetServiceUpdateStatus(r,dz.dcpStatus,fz._getStatusString(dz.dcpStatus,t))},_getErr:function(e){var t,r="";try{Zt.isString(e)?(t=e.replace(/\0/g,""),t=Zt.parse(t)):e&&(t=e),"description"in t&&(r=t.description)}catch(n){}return r},_funShowUpgradeDialogWhenUpdateFailed:function(e,t){return dz.bConnected=!0,dz.dcpStatus=dz.EnumDCP_DetectStatus.UpdateFailed,e&&e(),t&&t(),fz._sendStatusEvent(!0),!0},_funUpdateFailed:function(e,t,r,n){var i,o;return dz.bConnected=!0,dz.dcpStatus=dz.EnumDCP_DetectStatus.UpdateFailed,e&&e(),200==n?(i="The update failed.",o=fz._getStatusString(dz.dcpStatus,fz._getErr(r))):o=i="The update failed. The error code is "+n,t&&t(!0,i),fz._sendStatusEvent(!0,o),!0},getDSPath:function(e,t){return Hu(t)},getLinuxHTML5DebPath:function(){return Hu(".deb")},getLinuxHTML5RpmPath:function(){return Hu(".rpm")},getBinaryFileInfo:function(e,t){var r="GetBinaryFileInfo",n={id:Zt.guid(),method:r,version:"dwasm2_"+go(),parameter:[]},i=Zt.stringify(n),o=function(r,n,i){var o;r&&(o=Zt.parse(r)),o?e(o):t(r,n,i)};if(rr.DWT.ConnectWithSocket&&de.bHTML5Edition){var a=Td.getWsUrl(rr.DWT.Host,de.bSSL?Ho.SSLPort:Ho.Port);return Td.postStringDataByWSUrl(a,i).then(o,t),!0}var s=[ho(),"/",r,"?type=1&dsver=",fo().join(""),"&ts=",Zt.now()].join("");Wu.getHttpClientForDcp().request(i,s,{},500).then(o,t)}};Zt.mix(Ho,fz),rr.dcp=Ho,rr.dcp.dcpJSVer=cz,lz=sz,cz=sz}function hz(e,t,r,n){var i;return i={id:Zt.guid(),method:t,version:"dwasm2_"+go(),parameter:[]},"VersionInfo"==t&&(i.version="dwasm2_"+qo.getVersionStrForCheck()),Ac.isLongKey(r)&&(i.productKey=r),gz(e,t,i,Yo(),n)}function gz(e,t,r,n,i){return mz.apply(this,arguments)}function mz(){return mz=n(g().mark((function e(t,r,n,i,o){var a,s,u,c,l,d,f,h,m,p,v;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Zt.stringify(n),Ho.detect.bConnected=!1,s=[ho(),"/",r,"?type=1&dsver=",fo().join(""),"&ts=",Zt.now()].join(""),c=de.bSSL,l=c?Ho.SSLPort:Ho.Port,u=Wu.getHttpClient(t,l,c),d={},o&&!de.bSSL&&(d.redirect="manual"),e.prev=8,e.next=11,u.request(a,s,d,i);case 11:f=e.sent,e.next=21;break;case 14:if(e.prev=14,e.t0=e["catch"](8),!o||de.bSSL){e.next=20;break}if((e.t0&&e.t0.code)!=ua.HTTPRedirected){e.next=20;break}throw Ss();case 20:throw e.t0;case 21:if(f&&(h=Zt.parse(f)),!(h&&"exception"in h&&"description"in h)){e.next=27;break}throw m={code:h.exception,message:h.description},(p=zs(h))&&(m.errorCause=p),m;case 27:if(!h||!("result"in h)){e.next=33;break}if(!Ho.detect.bConnected){e.next=30;break}return e.abrupt("return",h.result);case 30:return Ho.detect.bConnected=!0,Ho.detect.dcpStatus=Ho.detect.EnumDCP_DetectStatus.Connected,e.abrupt("return",h.result);case 33:throw gs(v={}),Gs(v);case 36:case"end":return e.stop()}}),e,null,[[8,14]])}))),mz.apply(this,arguments)}function pz(e){var t=Date.parse(e+"T00:00:00");return""!=e&&!isNaN(t)&&(!!rr.DWT.CheckCertExpired&&(new Date).getTime()>=t-864e5*rr.DWT.CertificateConfig.UpdateDaysBeforeExpired)}rr.DWT.__innerCheckCertDate=function(e){pz(e)&&(Zt.isFunction(rr.OnCertExpired)&&rr.OnCertExpired(e),setTimeout((function(){rr.DWT.UpdateCert(rr.DWT.CertificateConfig.URL,rr.OnUpdateCertSuccess,rr.OnUpdateCertFailure)}),5e3))},rr.DWT.__innerUpdateCert=function(e,t,r,n){var i=[ho(),"/LoadZipFromBytes?type=",4,"&dsver=",fo().join(""),"&ts=",Zt.now()].join("");Wu.getHttpClientForDcp(null,t).request(e,i,{},3e4).then(r,(function(e){Zt.isFunction(n)&&n(e)}))},rr.DWT.__innerReboot=function(e,t){var r=[ho(),"/admin?ts=",Zt.now()].join(""),n='{"id":"'+(new Date).getTime().toString()+'","method":"Reboot","parameter":[],"version":"dwasm2_'+go()+'"}';Wu.getHttpClientForDcp().request(n,r,{},3e4).then(e,t)},rr.DWT.UpdateCert=function(e,t,r){Zt.isString(e)&&""!=e?Ns(e,{mode:"cors",dataType:"arraybuffer"}).then((function(e){rr.DWT.__innerUpdateCert(e,!1,(function(e){var n;try{var i=Qt.parse(e);i.description&&(n={code:i.exception,message:i.description})}catch(a){var o;gs(o={}),o=Gs(o)}n?Qt.isFunction(r)&&r(n):(rr.DWT.CheckCertExpired=!1,Zt.isFunction(t)&&t())}),(function(n){de.bSSL?rr.DWT.__innerUpdateCert(e,!0,t,r):Zt.isFunction(r)&&r(n)}))}),r):Zt.isFunction(r)&&r()};var vz={Errors:{FilePathSyntaxIncorrect:function(e){e._errorCode=-3123,e._errorString="The filename, directory name, or volume label syntax is incorrect."}},checkFilePath:function(e,t){return Zt.isString(t)&&0!=t.length?Zt.startsWith(t,"http://")||Zt.startsWith(t,"https://")||Zt.startsWith(t,"ftp://")?(Qt.File.Errors.FilePathSyntaxIncorrect(e),di):fi:(ka(e),di)}};vz.checkFolder=vz.checkFilePath,Qt.File=vz,Qt.showProgress=function(){},Qt.closeProgress=function(){};var _z=document.location.protocol,yz=location.hostname,Sz=de.bSSL,Iz={detect:{ssl:Sz,dcpStatus:0,dcpCallbackType:0,arySTwains:[],bFirst:fi,bOK:di,__dialog:di,cssLoaded:di,viewerScriptLoaded:di,bNoControlEvent:di,bNeedUpgradeEvent:di,bPromptJSOrServerOutdated:di,detectType:Sz?1:"http:"===_z||""===yz?0:-1,tryTimes:0,ports:[{port:rr.DWT.SSLPort,ssl:fi},{port:rr.DWT.Port,ssl:di}],cUrlIndex:0,urls:[],onNoControl:di,needUpgrade:di,OnDetectNext:di,OnCreatWS:di,bMaskShow:di},page:{bUnload:di}};function bz(){var e=wo;if(rr.DWT.CertificateConfig){var t=rr.DWT.CertificateConfig;Zt.isString(t.URL)||(t.URL=e.URL),(!Zt.isNumber(t.UpdateDaysBeforeExpired)||t.UpdateDaysBeforeExpired<=0)&&(t.UpdateDaysBeforeExpired=e.UpdateDaysBeforeExpired)}else rr.DWT.CertificateConfig=e;uH(),Zt.isString(rr.DWT.ProductKey)&&(rr.DWT.ProductKey=Zt.trim(rr.DWT.ProductKey)),rr.navInfo&&(de.bMac||de.bWin)&&(rr.navInfo.bEmbed=!1,rr.navInfo.bArm64=!1,rr.navInfo.bMips64=!1),rr.DWT.Debug&&(Zt.debug=!0)}function Tz(){return Cz.apply(this,arguments)}function Cz(){return Cz=n(g().mark((function e(){var t,r,n;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Qt.detect.cssLoaded){e.next=2;break}return e.abrupt("return");case 2:if(rr.DWT.IfLoadResources){e.next=5;break}return Qt.detect.cssLoaded=fi,e.abrupt("return");case 5:return t=yl(),r="",!de.bFileSystem&&rr.DWT.IfResourcesAddTimestamp&&(r=Qt.timestamp),n=[[t,"/src/dynamsoft.webtwain.css",r].join("")],Qo.bHTML5Edition&&rr.DWT.UseDefaultViewer&&n.push([t,"/src/dynamsoft.webtwain.viewer.css",r].join("")),Qt.detect.cssLoaded=fi,e.prev=10,e.next=13,new Qt.Promise((function(e,t){if(de.bSafari){var r=!1;if(Zt.addAllCss(n,!1,(function(e){e||(r=!0)})),r)t({code:-2804,message:"Loading the WebTwain css files failed."});else e()}else Zt.addAllCss(n,!1,(function(r){r?e():t({code:-2804,message:"Loading the WebTwain css files failed."})}))}));case 13:if(!Qo.bHTML5Edition||de.bFileSystem||!rr.DWT.IfCheckCssFiles){e.next=16;break}return e.next=16,wz(n);case 16:e.next=21;break;case 18:e.prev=18,e.t0=e["catch"](10),fd(e.t0);case 21:case"end":return e.stop()}}),e,null,[[10,18]])}))),Cz.apply(this,arguments)}function wz(e){return Ez.apply(this,arguments)}function Ez(){return(Ez=n(g().mark((function e(t){var r,n;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=!0,e.prev=1,n=0,n=0;case 4:if(!(n0)){e.next=10;break}return e.abrupt("continue",12);case 10:return r=!1,e.abrupt("break",15);case 12:n++,e.next=4;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e["catch"](1),r=!1;case 20:if(r){e.next=22;break}throw{code:-2804,message:"Loading the WebTwain css files failed."};case 22:return e.abrupt("return",r);case 23:case"end":return e.stop()}}),e,null,[[1,17]])})))).apply(this,arguments)}Zt.mix(Qt,Iz),Qt.Addon_Events=[],Qt.Addon_Sendback_Events=[];var kz=new Sl((function(){return Qo.loadingResourcePath}));function Az(e){return xz.apply(this,arguments)}function xz(){return xz=n(g().mark((function e(t){var r,n,i,o,a,s;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(ju("Loading css..."),bz(),!Qo.loadResourcePath){e.next=4;break}return e.abrupt("return",Qt.Promise.resolve());case 4:if(!Qo.loadingResourcePath){e.next=6;break}return e.abrupt("return",kz.asyncWaitingJSLoaded());case 6:if(Qo.loadingResourcePath=!0,(rr.DWT.Port>0||rr.DWT.SSLPort>0)&&(Qt.detect.ports=[{port:rr.DWT.Port,ssl:!1},{port:rr.DWT.SSLPort,ssl:!0}],Od.removeItem("DWT_port"),Od.removeItem("DWT_ssl")),Zt.each(Qt._funsAfterConfigLoaded,(function(e){try{Zt.isFunction(e)&&e()}catch(t){}})),(r=Zt.sizzle(".dynamsoft_waiting"))&&r.length>0&&(n=r[0]).parentNode&&n.parentNode.removeChild(n),i=yl(),o="",!de.bFileSystem&&rr.DWT.IfResourcesAddTimestamp&&(o=Qt.timestamp),a=fi,s=[],de.bSafari&&(a=di),s.push([i,"/dynamsoft.webtwain.install.js",o].join("")),rr.DWT.bNpm&&(s=[]),Qo.bHTML5Edition&&rr.DWT.UseDefaultViewer&&(ju("Loading the viewer script..."),s.push([i,"/src/dynamsoft.webtwain.viewer.js",o].join(""))),rr.DWT.IfLoadResources||(s=[]),Tz(),0!=s.length){e.next=25;break}return Pz(),Qo.loadResourcePath=!0,Qo.loadingResourcePath=!1,e.abrupt("return");case 25:return e.abrupt("return",new Qt.Promise((function(e,t){Zt.addScripts(s,a,!1,(function(r){var n=r;if(Qo.bHTML5Edition&&rr.DWT.UseDefaultViewer&&!Zt.isFunction(rr.DWTViewer)&&(n=!1),de.bIE&&Qo.bActiveXEdition&&(Zt.isFunction(rr.DWT._innerLoad)||(n=!1)),!n)return Qo.loadingResourcePath=!1,void t({code:-2803,message:"Loading the WebTwain JavaScript source files failed."});Pz(),Qo.loadResourcePath=!0,Qo.loadingResourcePath=!1,rr.DWT.OnWebTwainWillInit&&rr.DWT.OnWebTwainWillInit(),e()}))})));case 26:case"end":return e.stop()}}),e)}))),xz.apply(this,arguments)}function Pz(){if(Qt.bNode||de.bJSDom);else if(Zt.isArray(rr.aryAddonReadyFun)){for(var e=0,t=function(){var t=rr.aryAddonReadyFun[e];if(Zt.isFunction(t))try{t(Qt)}catch(jj){Zt.log(jj.stack||jj,"error"),setTimeout((function(){throw jj}),0)}};e0&&(new Date).getTime()-Oz>Rz){var e,t={code:-2802,message:"The file dynamsoft.webtwain.config.js timed out while loading."},r=rr.DWT.Containers;r&&0!==r.length||(ls(e={}),t={code:e._errorCode,message:e._errorString}),function(e){var t,r=Fz.length;for(t=0;t=10)&&rr.DWT.IfUseActiveXForIE10Plus){var o=di;de.bHTML5Edition=o,Qo.bHTML5Edition=o,Qo.bActiveXEdition=!0,Qo.bChromeEdition=Qo.bHTML5Edition}}if(Qo.bActiveXEdition&&rr.DWT.IfLoadResources){var a="";!de.bFileSystem&&rr.DWT.IfResourcesAddTimestamp&&(a=Qt.timestamp),Zt.addScript([n,"/src/dynamsoft.webtwain.activex.js",a].join(""),!0,!1,(function(){Qo.dwtConfigLoaded=!0,Qo.dwtConfigLoading=!1,Wz()}))}else Qo.dwtConfigLoaded=!0,Qo.dwtConfigLoading=!1,Wz()}else setTimeout(Nz,100)}var Rz=3e3,Oz=0;function Mz(e){return ju("Loading the config script..."),Qo.dwtConfigLoaded?Qt.Promise.resolve():(e&&(Rz=1e3*parseInt(e))<1&&(Rz=1),new Qt.Promise((function(e,t){Dz.push(e),Fz.push(t),kH((function(){Oz=(new Date).getTime(),setTimeout(Nz,100)}))})))}function Lz(){var e;(e=rr.DWT.WebTwainIdMap)&&Zt.each(e,(function(e,t){e&&e._OnPageBlur&&e._OnPageBlur()}))}if(Qo.bActiveXEdition){var Bz=function(){var e,t,r,n,i;if(rr.DWT.lunload(),Qt.closeAll&&Qt.closeAll(),n=rr.DWT.ContainerMap)for(i=Object.keys(n),e=0;e=16&&n<=31||192==r&&168==n)return!0}}return!1}(location.hostname)||de.bSSL||de.bFileSystem||!((de.bChrome||de.bEdge)&&parseInt(de.strBrowserVersion)>=94))}function jz(e,t,r,n){return Gz.apply(this,arguments)}function Gz(){return Gz=n(g().mark((function e(t,r,n,i){var o,a;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r!=Js.GET_TASKID){e.next=4;break}return e.abrupt("return",i.taskId);case 4:if(r!=Js.ONMESSAGE_PROCESS_DATA){e.next=8;break}return e.abrupt("return",Zt.parse(t));case 8:if(r!=Js.ONMESSAGE_GET_TASKID){e.next=15;break}if(!t||!t.cmdId){e.next=11;break}return e.abrupt("return",t.cmdId);case 11:if(!i||!i.client){e.next=13;break}return e.abrupt("return",i.client.getRequestTaskId());case 13:e.next=23;break;case 15:if(r!=Js.HANDLE_RAW_MESSAGE){e.next=23;break}if(a=t.rawData,t.jsonData,o=null==i?void 0:i.userData){e.next=21;break}return e.abrupt("return",!1);case 21:return a.indexOf("Version not found")>=0||a.indexOf("Function not found")>=0?Zt.isFunction(o.fFun)&&o.fFun():Zt.isFunction(o.sFun)&&o.sFun(a),e.abrupt("return",a);case 23:case"end":return e.stop()}}),e)}))),Gz.apply(this,arguments)}function Hz(e){var t,r,n=e.WebTwainId,i=e.Host,o=e.Port,a=e.SSLPort;return r={},Zt.isString(n)&&""!==n?r.id=n:r.id=n=Ol(),Zt.isDOM(e.Container)?(t=e.Container,Zt.isString(t.id)&&""!==t.id||(t.id=["dwt_node_",Zt.getRandom()].join("")),r.container=t,r.bNoViewer=!1):r.bNoViewer=!0,r.bNoViewer?(r.width=0,r.height=0):(Zt.isUndefined(e.Width)?t.style.width?r.width=t.style.width:r.width=300:r.width=e.Width,Zt.isUndefined(e.Height)?t.style.height?r.height=t.style.height:r.height=300:r.height=e.Height),r.dmService=e.dmService,Zt.isString(i)&&""!=i||(i=To()),r.host=i,o||(o=rr.DWT.Port),r.port=o,a||(a=rr.DWT.SSLPort),r.sslPort=a,r}function zz(e,t,r){if(e){var n=null!=t?t:270,i=null!=r?r:350;n<=0&&(n=270),i<=0&&(i=350),ci.one(e).before(Qt.install._strNonInstallDIV);var o=Zt.get(Qt.install._divDWTNonInstallContainerID);o&&(o.style.width=n,o.style.height=i),Zt.show(Qt.install._divDWTNonInstallContainerID)}}function Kz(e){var t=Hu();if(""!=Qt.install._divDWTemessageContainer&&Zt.hide(Qt.install._divDWTemessageContainer),de.bMac)e?Zt.isFunction(rr.OnWebTwainNeedUpgradeCallback)&&rr.OnWebTwainNeedUpgradeCallback(Qo.name,{"default":t},Qo.bHTML5Edition,Gu.enumMac,de.bIE,de.bSafari,Qt.detect.ssl,Lo.strIEVersion):Zt.isFunction(rr.OnWebTwainNotFoundOnMacCallback)&&rr.OnWebTwainNotFoundOnMacCallback(Qo.name,t,Qo.bHTML5Edition,de.bIE,de.bSafari,Qt.detect.ssl,Lo.strIEVersion);else if(de.bLinux||rr.navInfo.bEmbed||de.bChromeOS||Lo.bMobile){var r,n,i=Ju();if(rr.navInfo.bEmbed||de.bAndroid||de.bChromeOS||de.bHarmonyOS?r=t:(r=zu(),n=Ku()),e){if(de.bAndroid)Zt.isFunction(rr.OnWebTwainNeedUpgradeOnAndroidCallback)&&rr.OnWebTwainNeedUpgradeOnAndroidCallback(Qo.name,t,Qt.detect.ssl);else if(Zt.isFunction(rr.OnWebTwainNeedUpgradeCallback)){var o={"default":r};de.bLinux&&(o.deb=r,o.rpm=n),rr.OnWebTwainNeedUpgradeCallback(Qo.name,o,Qo.bHTML5Edition,i,de.bIE,de.bSafari,Qt.detect.ssl,Lo.strIEVersion)}}else de.bAndroid?Zt.isFunction(rr.OnWebTwainNotFoundOnAndroidCallback)&&rr.OnWebTwainNotFoundOnAndroidCallback(Qo.name,t,Qt.detect.ssl,!1):!qo.bFullEdition&&Lo.bMobile?Zt.isFunction(rr.OnMobileNotSupportCallback)&&rr.OnMobileNotSupportCallback():Zt.isFunction(rr.OnWebTwainNotFoundOnLinuxCallback)&&rr.OnWebTwainNotFoundOnLinuxCallback(Qo.name,r,n,Qo.bHTML5Edition,de.bIE,de.bSafari,Qt.detect.ssl,Lo.strIEVersion,i)}else if(de.bChrome||de.bSafari||de.bFirefox||de.bOpera||rr.DWT.IfUseActiveXForIE10Plus==ae||!rr.DWT.ActiveXInstallWithCAB&&de.bIE)if(e){if(Zt.isFunction(rr.OnWebTwainNeedUpgradeCallback)){var a={"default":t};rr.OnWebTwainNeedUpgradeCallback(Qo.name,a,Qo.bHTML5Edition,Gu.enumWindow,de.bIE,de.bSafari,Qt.detect.ssl,Lo.strIEVersion)}}else Zt.isFunction(rr.OnWebTwainNotFoundOnWindowsCallback)&&rr.OnWebTwainNotFoundOnWindowsCallback(Qo.name,t,Qo.bHTML5Edition,de.bIE,de.bSafari,Qt.detect.ssl,Lo.strIEVersion)}rr.DWT.GetWebTwain=rr.DWT.GetWebTwainEx=function(e){var t=e,r=rr.DWT.WebTwainIdMap;if(!t){var n=Object.keys(r);return n.length>0?r[t=n[0]]:void 0}if(t in r)return r[t];var i=rr.DWT.ContainerMap;return t in i?i[t]:void 0},rr.DWT.NeedCheckWebTwainBySocket=Vz,rr.DWT.CheckWebTwainBySocket=function(e,t,r){var n,i,o,a=Qt.detect.urls;if(a&&a.length>0){var s=a[0];n=s.host||To(),i=s.port,o=s.ssl}else $o(n=To())?(o=!(!de.bSSL||!de.bSafari),n=qo.hostForCheckCert):o=de.bSSL,i=o?rr.DWT.SSLPort:rr.DWT.Port;!function(e,t,r,n){var i,o=Zt.now(),a=o,s={id:o,cmdId:o,method:"VersionInfo",version:[Qo.getDWTPrefix(),qo.getVersionStrForCheck()].join("")},u=jz,c={cmdId:a,cmd:null,sFun:t,fFun:r,rawData:!0},l=Xo();i={client:e,userData:c,taskId:o},e.setRetry(0),e.request(Zt.stringify(s),u,i,l).then((function(t){return e.dispose(),t}),(function(){Zt.isFunction(n)&&n(),e.dispose()}))}(Wu.getWsClient(n,i,o,!0),e,t,r)},rr.DWT.IsLocalServiceConnected=function(){return new Qt.Promise((function(e,t){var r,n=To();Zt.each(Qt.detect.ports,(function(e){de.bSSL?e.ssl&&(r=e.port):e.ssl||(r=e.port)})),rr.DWT.CheckConnectToTheService(n,r,(function(t,r,n){e(!0)}),(function(){t(!1)}))}))},Qt.detect.onNoControl=function(e,t,r,n){n&&n._bRemoteMode&&!n._bNotShowMessage?Zt.isFunction(rr.OnRemoteWebTwainNotFoundCallback)&&rr.OnRemoteWebTwainNotFoundCallback(Qo.name,n._serverInfo.server,n._serverInfo.port,n._serverInfo.ssl,Lo.bMobile):(zz(e,t,r),Kz(!1))};var Jz=!1;function Qz(e,t){$o(e)&&(Od.item("DWT_port",t),Od.item("DWT_ssl",de.bSSL?"true":"false"))}function qz(e,t,r,n,i){return Yz.apply(this,arguments)}function Yz(){return(Yz=n(g().mark((function e(t,r,n,i,o){var a,s,u,c,l,d,f,h,m,p,v,_,y,S,I,b,T,C,w,E,k,A,x,P,D,F;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rr.DWT.OnWebTwainInitMessage&&rr.DWT.OnWebTwainInitMessage("Checking WebTwain version ...",ZH.Info),s=!1,u=!1,c=!1,l=rr.DWT.ConnectWithSocket,o&&(o.bRemoteServer&&(c=!0),o.bConnectWithSocket&&(l=!0),o.bCheckCert&&(u=!0)),d=Zt.now(),h=['{"id":"',f=d,'","cmdId":"',f,'","method":"VersionInfo","version":"',Qo.getDWTPrefix(),qo.getVersionStrForCheck(),'"}'].join(""),m=!l&&!de.bSSL,e.prev=6,!l){e.next=18;break}return v=jz,_={client:p,userData:{cmdId:f,cmd:null,sFun:null,fFun:null,rawData:!0},taskId:f},(p=Wu.getWsClient(t,r,n,!0)).setRetry(0),e.next=14,p.request(h,v,_,i);case 14:a=e.sent,s=!0,e.next=25;break;case 18:return y="fa/VersionInfo?v=1&ts="+d,S=Wu.getHttpClient(t,r,n),I={},m&&(I.redirect="manual"),e.next=24,S.request(h,y,I,i);case 24:a=e.sent;case 25:e.next=42;break;case 27:if(e.prev=27,e.t0=e["catch"](6),Zt.log(["check DWT Version failed",Zt.stringify(e.t0)]),!s){e.next=34;break}e.next=42;break;case 34:if(!m){e.next=38;break}if((e.t0&&e.t0.code)!=ua.HTTPRedirected){e.next=38;break}throw Ss();case 38:throw hs(b={}),rr.DWT.OnWebTwainInitMessage&&rr.DWT.OnWebTwainInitMessage(b._errorString,ZH.Error),{code:b._errorCode,message:b._errorString};case 42:if(T="",C="",w={},E=!1,a&&(k=Zt.parse(a)),!k||!("exception"in k)){e.next=49;break}Hs(k)?(w._errorCode=k.exception,w._errorString=k.description,w._errorCause=zs(k)):w._errorCode=ua.CommonError,e.next=91;break;case 49:if(!k||!("result"in k)){e.next=90;break}if(k=k.result,!(Zt.isArray(k)&&k.length>0)){e.next=87;break}if(A=k[0],T=k.length>1?k[1]:"",x=k.length>2?k[2]:0,P=k.length>3?k[3]:"",C=k.length>4?k[4]:"",""!==T){e.next=84;break}if(D="The WebTwain version is: "+A,rr.DWT.OnWebTwainInitMessage&&rr.DWT.OnWebTwainInitMessage(D,ZH.Info),"32"==x&&$o(t)&&(Ho.b64bit=!1),$o(t)&&(rr.DWT.li({instanceMode:rr.DWT.lgdt()},"")||""!=P&&(rr.DWT.lsmid(P,""),rr.DWT.lsmid2b(P))),(Zt.isFunction(rr.DWT.OnSSLCertInfo)||Zt.isFunction(rr.OnSSLCertInfo))&&(""!=C&&(F=Date.parse(C+"T00:00:00"),F=isNaN(F)?null:new Date(F)),Jz||(Zt.isFunction(rr.DWT.OnSSLCertInfo)?rr.DWT.OnSSLCertInfo(F):Zt.isFunction(rr.OnSSLCertInfo)&&rr.OnSSLCertInfo(F)),Jz=!0),!u){e.next=71;break}if(""!=C){e.next=68;break}throw{code:ua.SSLCertInvalid,message:"The Dynamic Web TWAIN Service SSL certificate is invalid."};case 68:if(!pz(C)){e.next=71;break}throw{code:ua.SSLCertExpired,message:"The Dynamic Web TWAIN Service SSL certificate has expired."};case 71:if(!Zt.isString(A)||""==A){e.next=81;break}if(ju("Checking the WebTwain version..."),!c&&!Vd(A,Qo.getServerVersionInfo(!0))){e.next=77;break}return e.abrupt("return",{host:t,port:r,bSSL:n,version:A,certExpiredDate:F});case 77:ju(qu),ga(w);case 79:e.next=82;break;case 81:E=!0;case 82:e.next=85;break;case 84:"Version not found"===T?ga(w):ps(w,T);case 85:e.next=88;break;case 87:E=!0;case 88:e.next=91;break;case 90:E=!0;case 91:throw E&&gs(w),rr.DWT.OnWebTwainInitMessage&&rr.DWT.OnWebTwainInitMessage(w._errorString,ZH.Error),{code:w._errorCode,message:w._errorString};case 94:case"end":return e.stop()}}),e,null,[[6,27]])})))).apply(this,arguments)}var Xz=!1,Zz=new Sl((function(){return Xz}));function $z(e,t,r){return eK.apply(this,arguments)}function eK(){return eK=n(g().mark((function e(t,r,n){var i,o,a,s,u,c;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Qo.bDWTChecked){e.next=2;break}return e.abrupt("return");case 2:if(Xz){e.next=6;break}Xz=!0,e.next=9;break;case 6:return e.next=8,Zz.asyncWaitingJSLoaded();case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,a=de.bSSL?n:r,i=de.bSSL?n:r,o=de.bSSL,e.prev=13,e.next=16,tK(t,i,o,fi);case 16:s=e.sent,e.next=26;break;case 19:if(e.prev=19,e.t0=e["catch"](13),e.t0.code!=ua.MustUpgrade){e.next=24;break}throw Kz(!0),e.t0;case 24:return e.next=26,oK(t,r,n);case 26:if(!Vz()||rr.DWT.ConnectWithSocket){e.next=29;break}return e.next=29,sK(t,a);case 29:return u=s.host,c=s.port,Qt.detect.dcpStatus=2,Qz(u,c),e.next=34,xc(!1,!0);case 34:if(!Zo()||!$o(t)){e.next=38;break}if(rr.DWT.li({instanceMode:rr.DWT.lgdt()},"")){e.next=38;break}throw{code:-2827,message:"Failed to get Machine ID."};case 38:e.next=44;break;case 40:throw e.prev=40,e.t1=e["catch"](9),Xz=!1,e.t1;case 44:Qo.bDWTChecked=!0,Xz=!1;case 46:case"end":return e.stop()}}),e,null,[[9,40],[13,19]])}))),eK.apply(this,arguments)}function tK(e,t,r,n){return rK.apply(this,arguments)}function rK(){return(rK=n(g().mark((function e(t,r,n,i){var o;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ju("Checking the WebTwain module..."),r||Zt.each(Qt.detect.ports,(function(e){de.bSSL?e.ssl&&(r=e.port):e.ssl||(r=e.port)})),e.prev=2,e.next=5,qz(t,r,n,i?Xo():Yo(),{bConnectWithSocket:i});case 5:o=e.sent,e.next=12;break;case 8:throw e.prev=8,e.t0=e["catch"](2),Qt.detect.dcpStatus=3,e.t0;case 12:return ju("Check the WebTwain version successfully."),!qo.versionInfoFromServer&&$o(o.host)&&(qo.versionInfoFromServer=o.version),e.abrupt("return",o);case 15:case"end":return e.stop()}}),e,null,[[2,8]])})))).apply(this,arguments)}function nK(e,t,r,n,i){iK(e,t,{bRemoteServer:!0,bConnectWithSocket:r},n,i)}function iK(e,t,r,n,i){var o=0,a=e,s=t,u=Qt.detect.ssl,c=n,l=i;if(Zt.isFunction(a)&&Zt.isFunction(s))for(c=a,l=s,a=To(),o=0;o=0&&i._innerRefreshUI(e)}i._canConsume()&&rr.DWT.lcvrf(i),r&&r(d,t)}),(function(){Qt.closeProgress(null,f),i.__bLoadingImage=!1,Zt.isFunction(n)&&n(i._errorCode,i._getErrorString(),d,t)}))}},{key:"SaveSelectedImagesToBytes",value:function(e,t){return ma(this),di}},{key:"LoadImageFromBytes",value:function(e,t,r){return ma(this),di}},{key:"SetImageWidth",value:function(e,t,r,n){var i,o=this,a=!1;if(Zt.isFunction(r)&&(a=!0),o._resetErr(),!o._isValid())return!!a&&void 0;var s=parseInt(e);if(isNaN(s))return ca(o),Zt.isFunction(n)&&n(o._errorCode,o._getErrorString()),!!a&&void 0;if(s<0||s>=o._ImgManager.count())return Oa(o),Zt.isFunction(n)&&n(o._errorCode,o._getErrorString()),!!a&&void 0;if(Zt.isUndefined(t))return Ka(o),Zt.isFunction(n)&&n(o._errorCode,o._getErrorString()),!!a&&void 0;var u=o._ImgManager.convertClientIndexToServerId(s);return-1==u?(Oa(o),Zt.isFunction(n)&&n(o._errorCode,o._getErrorString()),!!a&&void 0):((i=1==o._innerFun("SetImageWidth",El(u,t)))?Zt.isFunction(r)&&r():Zt.isFunction(n)&&n(o._errorCode,o._getErrorString()),a?void 0:i)}},{key:"HTTPDownloadStreamThroughPost",value:function(e,t){return ma(this),di}},{key:"HTTPUploadStreamThroughPost",value:function(e,t,r,n,i){return ma(this),di}},{key:"HTTPUploadThroughPutDirectly",value:function(e,t,r,n,i){return ma(this),!1}},{key:"SetCustomDSDataEx",value:function(e){return this._resetErr(),!!this._isValid()&&this._innerFun("SetCustomDSDataEx",El(e))}},{key:"SetCustomDSData",value:function(e){if(this._resetErr(),!this._isValid())return!1;var t=bf.replaceLocalFilename(e);return this._innerFun("SetCustomDSData",El(t))}},{key:"GetCustomDSDataEx",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._innerFun("GetCustomDSDataEx")}},{key:"GetCustomDSData",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return!1;var r=bf.replaceLocalFilename(e);return t._innerFun("GetCustomDSData",El(r))}},{key:"on",value:function(e,t){return this.registerEvent(e,t)}},{key:"off",value:function(e,t){return this.unregisterEvent(e,t)}},{key:"ConvertToBW",value:function(e,t,r){var n=this,i=!1;if(Zt.isFunction(t)&&(i=!0),n._resetErr(),!n._isValid())return!!i&&void 0;if(!Ac.checkProductKey(n,{Core:!0}))return Zt.isFunction(r)&&r(n._errorCode,n._getErrorString()),!!i&&void 0;var o=parseInt(e);if(isNaN(o))return ca(n),Zt.isFunction(r)&&r(n._errorCode,n._getErrorString()),!!i&&void 0;if(o<0||o>=n._ImgManager.count())return Oa(n),Zt.isFunction(r)&&r(n._errorCode,n._getErrorString()),!!i&&void 0;var a=n._ImgManager.convertClientIndexToServerId(o);if(-1==a)return Oa(n),!1;var s=n._innerFun("ConvertToBW",El(a));return s?Zt.isFunction(t)&&t():Zt.isFunction(r)&&r(n._errorCode,n._getErrorString()),i?void 0:s}},{key:"LoadImageFromBinary",value:function(e,t,r){var n,i,o=this,a="LoadImageFromBinary",s=!1;Zt.isFunction(t)&&(s=!0);var u=null===(n=Qt.progressContext)||void 0===n?void 0:n.IfShowCancelDialogWhenImageTransfer;s&&(o.IfShowProgressBar?(Qt.showProgress(o,a,!1),Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=!1)):Qt.hideProgress());return i=o._innerLoadImageFromBinary(e,0,!0,s,(function(){Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=u),Zt.isFunction(t)&&(o.IfShowProgressBar&&Qt.closeProgress(null,a),t())}),(function(e,n){Qt.progressContext&&(Qt.progressContext.IfShowCancelDialogWhenImageTransfer=u),Zt.isFunction(t)&&o.IfShowProgressBar&&Qt.closeProgress(null,a),Zt.isFunction(r)&&r(e,n)})),s?void 0:i}},{key:"EnableSourceUI",value:function(e,t){var r=this;return r._resetErr(),!!r._isValid()&&(r._innerSend("EnableSourceUI",null,!0,e,t),!0)}},{key:"GetIfShowVideoContainer",value:function(){return this._UIView.GetIfShowVideoContainer()}},{key:"ShowVideoContainer",value:function(e){return this._UIView.ShowVideoContainer(e)}},{key:"UpdateVideoContainer",value:function(e){return this._UIView.UpdateVideoContainer(e)}},{key:"ChangeBitDepth",value:function(e,t,r){var n,i=this;if(i._resetErr(),!i._isValid())return!1;if(n=parseInt(e),isNaN(n))return ca(i),!1;if(n<0||n>=i._ImgManager.count())return Oa(i),!1;var o=i._ImgManager.convertClientIndexToServerId(n);return-1==o?(Oa(i),!1):i._innerFun("ChangeBitDepth",El(o,t,r))}},{key:"ConvertToGrayScale",value:function(e,t,r){var n,i=this,o=!1;if(Zt.isFunction(t)&&(o=!0),i._resetErr(),!i._isValid())return!!o&&void 0;var a=parseInt(e);if(isNaN(a))return ca(i),Zt.isFunction(r)&&r(i._errorCode,i._getErrorString()),!!o&&void 0;if(a<0||a>=i._ImgManager.count())return Oa(i),Zt.isFunction(r)&&r(i._errorCode,i._getErrorString()),!!o&&void 0;var s=i._ImgManager.convertClientIndexToServerId(a);return-1==s?(Oa(i),Zt.isFunction(r)&&r(i._errorCode,i._getErrorString()),!!o&&void 0):((n=1==i._innerFun("ConvertToGrayScale",El(s)))?(bf.refreshImageAfterInvokeFun(i,a),Zt.isFunction(t)&&t()):Zt.isFunction(r)&&r(i._errorCode,i._getErrorString()),o?void 0:n)}},{key:"ClearTiffCustomTag",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&(e._aryTiffTag.splice(0,e._aryTiffTag.length),e._innerFun("ClearTiffCustomTag"))}},{key:"SetTiffCustomTag",value:function(e,t,r){var n=this;if(n._resetErr(),!n._isValid())return!1;if(Zt.isUndefined(e)||Zt.isUndefined(t))return Ka(n),!1;var i,o=1*e;if(i=Zt.isString(t)?Zt.replaceAll(t,'"','\\"'):t,o<=0||o>2147483647)return na(n,-2378,"Invalid value for the tiff tag code."),!1;var a,s=0,u=!1,c=n._aryTiffTag.length;for(s=0;s=32?(function(e){na(e,-2428,"Tiff tag count has exceeded the limit.")}(n),!1):n._innerFun("SetTiffCustomTag",El(o,i,r))}},{key:"IsBlankImage",value:function(e){var t,r=this;if(r._resetErr(),!r._isValid())return!1;if(t=parseInt(e),isNaN(t))return ca(r),!1;if(t<0||t>=r._ImgManager.count())return Oa(r),!1;var n=r._ImgManager.convertClientIndexToServerId(t);return-1==n?(Oa(r),!1):r._innerFun("IsBlankImage",El(n,di))}},{key:"IsBlankImageExpress",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return!1;var r=parseInt(e);if(isNaN(r))return ca(t),!1;if(r<0||r>=t._ImgManager.count())return Oa(t),!1;var n=t._ImgManager.convertClientIndexToServerId(r);return-1==n?(Oa(t),!1):t._innerFun("IsBlankImage",El(n,fi))}},{key:"SetOpenSourceTimeout",value:function(e){var t=this;return t._resetErr(),!!t._isValid()&&t._innerFun("SetOpenSourceTimeout",El(e))}},{key:"GetImageURL",value:function(e,t,r,n,i){var o=this;if(o._resetErr(),!o._isValid())return!1;var a,s,u,c,l=e,d=parseInt(t),f=parseInt(r);if(n?(a="",s="dwt://"):(a=o._httpUrl,s="dwt/"),c=o._bScanForProxyRemote?qo.getVersionStrForCheck():Qo.getServerVersionInfo(),u=[a,s,Qo.getDWTPrefix(),c,"/img?id=",o._clientId],Zt.isUndefined(l)||null===l)return Ma(o),"";if(i)u.push("&index=-1&width=-1&height=-1&webcam="),u.push(i);else{if(l=parseInt(l),isNaN(l))return ca(o),"";if(l<-1||l>=o._ImgManager.count())return Oa(o),"";var h=o._ImgManager.convertClientIndexToServerId(l);if(-1==h)return"";u.push("&index="),u.push(h),d>0&&f>0?(u.push("&width="),u.push(d),u.push("&height="),u.push(f)):u.push("&width=-1&height=-1"),Lo.bMobile&&u.push("&type=1&quality=85")}if(u.push("&t="),u.push((new Date).getTime()),u=u.join(""),de.bFileSystem&&u.indexOf("dwt://")<0){var g=new Image;g.crossOrigin="anonymous",g.src=u,g=null}return u}},{key:"GetImagePartURL",value:function(e,t,r){var n=this;if(n._resetErr(),!n._isValid())return!1;var i=parseInt(e);return isNaN(i)?(ca(n),""):i<0||i>=n._ImgManager.count()?(Oa(n),""):this.GetImageURL(i,t,r,!0)}},{key:"SetLanguage",value:function(e){var t=this;return t._resetErr(),!!t._isValid()&&t._innerFun("SetLanguageForSecurity",El(e))}},{key:"GetLicenseInfo",value:function(e,t){var r=this;if(r.__licenseInfo)Zt.isFunction(e)&&e(r.__licenseInfo);else{r._innerFunRaw("GetLicenseInfo",El(0),fi,di,fi,(function(n){n?n.exception?Zt.isFunction(t)&&t(n.exception):(Zt.isArray(n.result)&&n.result.length>0&&ld(r,n.result[0]),Zt.isFunction(e)&&e(r.__licenseInfo)):Zt.isFunction(t)&&t()}),t)}}},{key:"SetProductKeyAsync",value:function(e){return this._setProductKeyAsync(e)}},{key:"GetVersionInfoAsync",value:function(){return ci.Promise.resolve(qo.versionInfoFromServer)}},{key:"isUsingActiveX",value:function(){return!1}},{key:"SetLTSLicenseAsync",value:function(e){return this._setLTSLicenseAsync(e)}},{key:"Print",value:function(e){var t=this;if(t._resetErr(),!t._isValid())return!1;if(t._isNoViewer())return t._nouiNotSupport("Print");if(e){return t._innerSend("PrintEx",El(!0),!0,(function(){}),(function(){})),!0}return t._ImagePrint.Print(),!0}},{key:"PrintEx",value:function(e){var t=this;return t._resetErr(),!!t._isValid()&&(!!t._checkIndices(e)&&(t._isNoViewer()?t._nouiNotSupport("Print"):(t._ImagePrint.PrintEx(e),!0)))}},{key:"IsBlankImageAsync",value:(h=n(g().mark((function m(e,t){var r,n,i,o;return g().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(r=this,Ju()==Gu.enumWindow){a.next=5;break}throw na(r,-2905,"This API is not supported on the current operating system. Please contact your system administrator."),{code:this._errorCode,message:this._getErrorString()};case 5:return i={minBlockHeight:20,maxBlockHeight:30},t&&(Zt.isNumber(t.minBlockHeight)&&t.minBlockHeight>=0&&(i.minBlockHeight=t.minBlockHeight),Zt.isNumber(t.maxBlockHeight)&&t.maxBlockHeight>=0&&(i.maxBlockHeight=t.maxBlockHeight)),n={command:"isBlankImage",parameter:{index:e,minHeight:i.minBlockHeight,maxHeight:i.maxBlockHeight}},a.next=10,r.RunCommandAsync(n);case 10:if(!((o=a.sent)&&Qt.isArray(o.result)&&o.result.length>0)){a.next=13;break}return a.abrupt("return",o.result[0]);case 13:return a.abrupt("return",!1);case 14:case"end":return a.stop()}}),m,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"httpUploadBlob",value:function(e,t,r,n){var i=this,o="httpUploadBlob",a=t,s=r,u=null,c=null,l=aG.Text;if(i._resetErr(),!i._isValid())return Qt.Promise.reject({code:i._errorCode,message:i._errorString});if(Zt.isUndefined(e)||""===e)return Ea(i),Qt.Promise.reject({code:i._errorCode,message:i._errorString});if(!Zt.isString(e))return Ua(i),Qt.Promise.reject({code:i._errorCode,message:i._errorString});if(!(a instanceof Blob))return Ka(i),Qt.Promise.reject({code:i._errorCode,message:i._errorString});var d=a.type.toLocaleLowerCase();if("image/jpeg"!=d&&"image/jpg"!=d&&"image/png"!=d&&"image/bmp"!=d&&"application/pdf"!=d&&"image/tiff"!=d&&"image/tif"!=d)return na(i,-2845,"Only Blob of JPEG, PNG, BMP, TIFF and PDF image types can be uploaded."),Qt.Promise.reject({code:i._errorCode,message:i._errorString});n&&(u=new FormData,Zt.each(n.formFields,(function(e,t){var r=e.name,n=e.value;Zt.isString(r)&&(n instanceof Blob?u.append(r,n,e.fileName):u.append(r,n))})),c={},Zt.each(n.headers,(function(e,t){Zt.isString(e.name)&&(c[e.name]=e.value)})),n.responseType&&(l=n.responseType));var f=i._createHttpUploaderConfig(),h=new vG,g=new _G;return g.url=e,g.method=o,g.content=a,a=null,g.contentType=i._strHttpContentTypeFieldValue,g.headers=c,g.fileName=s,g.httpFormData=u,i.__remoteFilename&&""!=i.__remoteFilename&&(g.remoteFilename=i.__remoteFilename),g.retry=1,g.bOnlyResponseEmptyIsOK=!1,g.responseType=l,f.objUploadStatus=undefined,i.IfShowProgressBar&&Qt.showProgress(i,o,!1),new Qt.Promise((function(e,t){h.httpPostUpload(f,g,(function(t){i.IfShowProgressBar&&Qt.closeProgress(i,o,!1),e(t)}),(function(e,r){i.IfShowProgressBar&&Qt.closeProgress(i,o,!1),t({code:e,message:r})}))}))}},{key:"saveBlob",value:(d=n(g().mark((function p(e,t){var r,n,i,o,a;return g().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(i=e,(r=this)._resetErr(),r._isValid()){s.next=4;break}throw{code:r._errorCode,message:r._errorString};case 4:if(!Zt.isString(e)&&null!==e&&e!==undefined){s.next=8;break}s.next=10;break;case 8:case 23:throw Ka(r),{code:r._errorCode,message:r._errorString};case 10:if(!(t instanceof Blob)){s.next=23;break}if("image/jpeg"!=(a=t.type.toLocaleLowerCase())&&"image/jpg"!=a&&"image/png"!=a&&"image/bmp"!=a&&"application/pdf"!=a&&"image/tiff"!=a&&"image/tif"!=a){s.next=16;break}s.next=18;break;case 16:throw na(r,-2844,"Only Blob of JPEG, PNG, BMP, TIFF and PDF image types can be saved."),{code:r._errorCode,message:r._errorString};case 18:return s.next=20,tH(t);case 20:o=s.sent,s.next=25;break;case 25:return i||(i=""),i=bf.replaceLocalFilename(i),n=El(i),s.next=30,new Qt.Promise((function(e,t){r._innerSendBlobByWS("SaveBlobToFile",n,o,(function(t){e(t)}),(function(e){t({code:r._errorCode,message:r._errorString})}))}));case 30:case"end":return s.stop()}}),p,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"createLocalStorage",value:(l=n(g().mark((function v(e){var t,r,n,i,o;return g().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if((t=this)._resetErr(),t._isValid()){a.next=4;break}throw{code:t._errorCode,message:t._errorString};case 4:if(n="CreateLocalStorage",i=null,!e){a.next=12;break}if(o=e.password,!1!==fK(hK,this,mK).call(this,o)){a.next=9;break}throw{code:t._errorCode,message:t._errorString};case 9:i=JSON.stringify([JSON.stringify(e)]),a.next=13;break;case 12:i='["{}"]';case 13:return a.next=15,new Qt.Promise((function(e,r){t._innerSend(n,i,!1,(function(n){if(Zt.isArray(n)&&n.length>0){var i=n[0];i&&Zt.isString(i.uid)&&e(i.uid)}else gs(t),r({code:t._errorCode,message:t._errorString})}),(function(){r({code:t._errorCode,message:t._errorString})}))}));case 15:return r=a.sent,a.abrupt("return",r);case 17:case"end":return a.stop()}}),v,this)}))),function(e){return l.apply(this,arguments)})},{key:"localStorageExist",value:(c=n(g().mark((function _(e){var t,r,n;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(r="LocalStorageExist",(t=this)._resetErr(),t._isValid()){i.next=4;break}throw{code:t._errorCode,message:t._errorString};case 4:if(0!=fK(hK,t,pK).call(t,e)){i.next=6;break}throw{code:t._errorCode,message:t._errorString};case 6:return i.next=8,new Qt.Promise((function(n,i){t._innerSend(r,El(e),!1,(function(e){if(Zt.isArray(e)&&e.length>0){var r=e[0];(Zt.isBoolean(r)||Zt.isNumber(r))&&n(!!r)}else gs(t),i({code:t._errorCode,message:t._errorString})}),(function(){i({code:t._errorCode,message:t._errorString})}))}));case 8:return n=i.sent,i.abrupt("return",n);case 10:case"end":return i.stop()}}),_,this)}))),function(e){return c.apply(this,arguments)})},{key:"saveToLocalStorage",value:(u=n(g().mark((function y(e){var t,r,n,i;return g().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(r="SaveToLocalStorage",n=null,(t=this)._resetErr(),t._isValid()){o.next=4;break}throw{code:t._errorCode,message:t._errorString};case 4:if(Zt.isObject(e)){o.next=7;break}throw Ka(t),{code:t._errorCode,message:t._errorString};case 7:if(!1!==fK(hK,t,pK).call(t,e.uid)&&!1!==fK(hK,this,mK).call(this,e.password)){o.next=9;break}throw{code:t._errorCode,message:t._errorString};case 9:if(!Zt.isUndefined(e.indices)){o.next=13;break}e.indices=Pf(t),o.next=20;break;case 13:if(!Zt.isArray(e.indices)||0!=e.indices.length){o.next=17;break}o.next=20;break;case 17:if(t._checkIndices(e.indices)){o.next=19;break}throw{code:t._errorCode,message:t._errorString};case 19:e.indices=Df(t,e.indices);case 20:return n=JSON.stringify([JSON.stringify(e)]),o.next=23,new Qt.Promise((function(e,i){t._innerSend(r,n,!1,(function(r){if(Zt.isArray(r)&&r.length>0){var n=r[0];n&&n.imageIds&&e(n.imageIds)}else gs(t),i({code:t._errorCode,message:t._errorString})}),(function(){i({code:t._errorCode,message:t._errorString})}))}));case 23:return i=o.sent,o.abrupt("return",i);case 25:case"end":return o.stop()}}),y,this)}))),function(e){return u.apply(this,arguments)})},{key:"loadFromLocalStorage",value:(a=n(g().mark((function S(e){var t,r,n,i,o;return g().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(r="LoadFromLocalStorage",n=null,(t=this)._resetErr(),t._isValid()){a.next=4;break}throw{code:t._errorCode,message:t._errorString};case 4:if(Zt.isObject(e)){a.next=7;break}throw Ka(t),{code:t._errorCode,message:t._errorString};case 7:if(!1!==fK(hK,t,pK).call(t,e.uid)&&!1!==fK(hK,this,mK).call(this,e.password)){a.next=9;break}throw{code:t._errorCode,message:t._errorString};case 9:return(o=Zt.clone(e)).documentName=t._getCurrentDocumentName(),o.tagName=t._getCurrentDefaultTagName(),n=JSON.stringify([JSON.stringify(o)]),Qt.showProgress(t,r,!1),Qt.progressBarOnPercentDone(-1,"Processing...","",0,""),a.next=17,new Qt.Promise((function(e,i){t._innerSend(r,n,!1,(function(n){var o;Qt.closeProgress(null,r),Zt.isArray(n)&&n.length>0?(o=n[0])&&o.mapImageIds&&e(o.mapImageIds):(!1===o&&0!=t._errorCode||gs(t),i({code:t._errorCode,message:t._errorString}))}),(function(){Qt.closeProgress(null,r),i({code:t._errorCode,message:t._errorString})}))}));case 17:return i=a.sent,a.abrupt("return",i);case 19:case"end":return a.stop()}}),S,this)}))),function(e){return a.apply(this,arguments)})},{key:"removeLocalStorage",value:(r=n(g().mark((function I(e){var t,r,n,i;return g().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(r="RemoveLocalStorage",n=null,(t=this)._resetErr(),t._isValid()){o.next=4;break}throw{code:t._errorCode,message:t._errorString};case 4:if(Zt.isObject(e)){o.next=7;break}throw Ka(t),{code:t._errorCode,message:t._errorString};case 7:if(!1!==fK(hK,t,pK).call(t,e.uid)&&!1!==fK(hK,this,mK).call(this,e.password)){o.next=9;break}throw{code:t._errorCode,message:t._errorString};case 9:return e&&(n=JSON.stringify([JSON.stringify(e)])),o.next=12,new Qt.Promise((function(e,i){t._innerSend(r,n,!1,(function(r){if(Zt.isArray(r)&&r.length>0){var n=r[0];(Zt.isBoolean(n)||Zt.isNumber(n))&&e(!!n)}else gs(t),i({code:t._errorCode,message:t._errorString})}),(function(){i({code:t._errorCode,message:t._errorString})}))}));case 12:return i=o.sent,o.abrupt("return",i);case 14:case"end":return o.stop()}}),I,this)}))),function(e){return r.apply(this,arguments)})}]);var r,a,u,c,l,d,h}($G);function mK(e){if(!Zt.isUndefined(e)){if(!Zt.isString(e))return na(this,-2850,"The password is not a string."),!1;if(e.length>32)return function(e){na(e,-2849,"The password must not exceed 32 characters in length.")}(this),!1}return!0}function pK(e){return Zt.isUndefined(e)||""==e?(na(this,-2846,"The uid cannot be empty."),!1):!!Zt.isString(e)||(function(e){na(e,-2847,"The uid is invalid.")}(this),!1)}function vK(e,t,r,n){var i;0!==r&&1!==r?i=r:(i={},r&&(i.set=1==n?function(r){var n=1*r;return!Zt.isNumber(n)||isNaN(n)?(la(e),di):(e._resetErr(),!!e._isValid()&&e._innerFun(t,El(n)))}:2==n?function(r){return Zt.isBoolean(r)?(e._resetErr(),!!e._isValid()&&e._innerFun(t,El(r))):(la(e),di)}:function(r){return Zt.isString(r)?(e._resetErr(),!!e._isValid()&&e._innerFun(t,El(r))):(la(e),di)})),i.get||(i.get=function(){return e._resetErr(),!!e._isValid()&&e._innerFun(t)}),t in e||Object.defineProperty(e,t,i)}function _K(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function yK(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=_(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==_(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function SK(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var IK=new WeakSet,bK=function(){return s((function r(e,t,n,i){o(this,r),_K(this,IK),yK(this,"serverUrl",undefined),this.serverUrl=e,this.bLocal=$o(e),this.clientId=null!=n?n:Zt.guid(),this.bGlobal=t,this.serverName=i,this.bLicenseOK=!1}),[{key:"checkSource",value:function(e){if(!e)throw{code:-1003,message:"Source Manager unable to find the specified Source"}}},{key:"parseResultDefault",value:function(e){var t;if(Zt.isObject(e)&&e.exception&&0!=e.exception)throw{code:e.exception,message:null!==(t=e.description)&&void 0!==t?t:"general error"};if(e&&Zt.isArray(e.result)&&e.result.length>0){var r=e.result[e.result.length-1];try{return JSON.parse(r)}catch(jj){return r}}throw e}},{key:"_requestAsync",value:(t=n(g().mark((function i(e,t,r){var n,o,a,s,u,c,l,d,f,h;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!rr.DWT.ConnectWithSocket){i.next=12;break}return i.next=3,SK(IK,this,TK).call(this);case 3:return n=i.sent,o=0,e&&(o=e.cmdId),a={client:n,userData:{command:e},taskId:o},s=kK,i.next=9,n.request(Zt.stringify(e),s,a);case 9:return u=i.sent,Zt.isString(u)&&(u=Zt.parse(u)),i.abrupt("return",u);case 12:return c=[Bu(),"/",e.method].join(""),t&&(d=t),f=(h=this).serverUrl?Td.getDDMUrl(h.serverUrl,h.bGlobal,[Mu,e.method].join("")):Td.getModuleUrl(c),i.prev=16,i.next=19,Ns(f,{method:"post",dataType:"json",body:Zt.stringify(e),fetchRaw:null!=r&&r,timeout:d});case 19:l=i.sent,i.next=25;break;case 22:throw i.prev=22,i.t0=i["catch"](16),i.t0;case 25:return i.abrupt("return",l);case 26:case"end":return i.stop()}}),i,this,[[16,22]])}))),function(e,r,n){return t.apply(this,arguments)})},{key:"_resetLicense",value:(e=n(g().mark((function a(e,t,r){return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),a)}))),function(t,r,n){return e.apply(this,arguments)})}]);var e,t}();function TK(){return CK.apply(this,arguments)}function CK(){return(CK=n(g().mark((function e(){var t,r,n,i,o,a,s,u,c;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((t=this)._wsClient){e.next=10;break}return r=new Ms,(n=this.serverUrl)?(i=Qt.detect.ssl,a="/",o=i?"ddm/18626/":"ddm/18625/",Zt.endsWith(n,"/")&&(a=""),Zt.startsWith(n,"https://")||Zt.startsWith(n,"wss://")?(r.ssl=!0,s=Zt.startsWith(n,"https://")?Zt.replaceAll(n,"https://",""):Zt.replaceAll(n,"wss://",""),n=s+a+o):Zt.startsWith(n,"http://")||Zt.startsWith(n,"ws://")?(r.ssl=!1,u=Zt.startsWith(n,"http://")?Zt.replaceAll(n,"http://",""):Zt.replaceAll(n,"ws://",""),n=u+a+o):(r.ssl=Qt.detect.ssl,r.port=r.ssl?Ho.SSLPort:Ho.Port),r.server=n):(r.ssl=Qt.detect.ssl,r.server=To(),r.port=r.ssl?Ho.SSLPort:Ho.Port),r.useWS=!0,r.protocol=Ho.wsProtocol,c=Pu.Instance.getClient(r),e.next=9,c.testConnection();case 9:t._wsClient=c;case 10:return e.abrupt("return",t._wsClient);case 11:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}yK(bK,"logLevel",-1);var wK=function(e){function t(){var e;o(this,t);for(var r=arguments.length,n=new Array(r),a=0;a=3&&p[0]>=1&&p[1]>=8&&p[2]>0&&(h.bGlobalFind=!0,v=EK(this.serverUrl,h),c.push(v)),h.bGlobalFind||(y=null!==(_=null==h?void 0:h.ty)&&void 0!==_?_:"",Zt.warn(["The Dynamic Web TWAIN Service on [",y,"] is old version."].join(""))),a.abrupt("break",38);case 38:a.next=24;break;case 40:a.next=45;break;case 42:a.prev=42,a.t2=a["catch"](22),d.e(a.t2);case 45:return a.prev=45,d.f(),a.finish(45);case 48:return a.abrupt("return",c);case 49:case"end":return a.stop()}}),a,this,[[5,12],[22,42,45,48]])}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"dispose",value:function(){var e={id:this.clientId,cmdId:Zt.guid(),method:"dispose",version:Lu};this._requestAsync(e,500)}}]);var r}(bK);function EK(e,t){var r=new vd;return r.server=e,r.attrs=t,r}function kK(e,t,r,n){return AK.apply(this,arguments)}function AK(){return AK=n(g().mark((function e(t,r,n,i){var o,a;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r!=Js.GET_TASKID){e.next=4;break}return e.abrupt("return",i.taskId);case 4:if(r!=Js.ONMESSAGE_PROCESS_DATA){e.next=8;break}return e.abrupt("return",Zt.parse(t));case 8:if(r!=Js.ONMESSAGE_GET_TASKID){e.next=15;break}if(!t||!t.cmdId){e.next=11;break}return e.abrupt("return",t.cmdId);case 11:if(!i||!i.client){e.next=13;break}return e.abrupt("return",i.client.getRequestTaskId());case 13:e.next=23;break;case 15:if(r!=Js.HANDLE_RAW_MESSAGE){e.next=23;break}if(a=t.rawData,t.jsonData,o=null==i?void 0:i.userData){e.next=21;break}return e.abrupt("return",!1);case 21:return a.indexOf("Version not found")>=0||a.indexOf("Function not found")>=0?Zt.isFunction(o.fFun)&&o.fFun():Zt.isFunction(o.sFun)&&o.sFun(a),e.abrupt("return",a);case 23:case"end":return e.stop()}}),e)}))),AK.apply(this,arguments)}function xK(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=_(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==_(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function PK(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function DK(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}function FK(e){var t,r=Cd.ST_UNKNOWN;return e==Al.ESCLSCANNER?r=Cd.ST_ESCL:e==Al.WIFIDIRECTSCANNER?r=Cd.ST_WIFI_DIRECT:((t=e)==Al.TWAINSCANNER||t==Al.WIATWAINSCANNER||t==Al.TWAINX64SCANNER||t==Al.ICASCANNER||t==Al.SANESCANNER)&&(r=Cd.ST_DYNAMSOFT_SERVICE),r}var WK=new WeakSet,NK=function(e){function t(){var e;o(this,t);for(var r=arguments.length,n=new Array(r),a=0;am.ty.length&&(p.name=m.hostname),p.displayName=(m.service_type==Cd.ST_ESCL?"eSCL-":"")+p.name,this.bGlobal||(m.url=this.serverUrl,this.serverName&&(p.displayName=p.displayName+" on ["+this.serverName+"]")),p.serviceInfo=EK(this.serverUrl,m),o.push(p),g.abrupt("break",46);case 46:g.next=22;break;case 48:g.next=53;break;case 50:g.prev=50,g.t1=g["catch"](20),f.e(g.t1);case 53:return g.prev=53,f.f(),g.finish(53);case 56:return g.abrupt("return",o);case 57:case"end":return g.stop()}}),v,this,[[20,50,53,56]])}))),function(e,t,r){return p.apply(this,arguments)})},{key:"getCapabilitiesAsync",value:(m=n(g().mark((function _(e){var t,r,n;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return this.checkSource(e),(e.deviceType&Al.ESCLSCANNER)!=Al.ESCLSCANNER&&(e.deviceType&Al.WIFIDIRECTSCANNER)!=Al.WIFIDIRECTSCANNER||(this._currentDevice=e),t=FK(e.deviceType),r={id:this.clientId,cmdId:Zt.guid(),method:"SendRequestToScanner",parameter:["getCapabilities",Zt.stringify({UUID:e.serviceInfo.attrs.UUID,service_type:t,ty:e.name})],version:Lu},i.next=6,this._requestAsync(r,0);case 6:return n=i.sent,i.abrupt("return",this.parseResultDefault(n));case 8:case"end":return i.stop()}}),_,this)}))),function(e){return m.apply(this,arguments)})},{key:"selectSourceAsync",value:(h=n(g().mark((function y(e){var t;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.getCapabilitiesAsync(e);case 2:if(!(t=r.sent)&&""!=t){r.next=5;break}return r.abrupt("return",!0);case 5:case"end":return r.stop()}}),y,this)}))),function(e){return h.apply(this,arguments)})},{key:"versionInfo",value:(d=n(g().mark((function S(){var e,t;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return e={id:this.clientId,cmdId:Zt.guid(),method:"VersionInfo",version:Lu},r.next=3,this._requestAsync(e,5e3);case 3:return t=r.sent,this._bInited=!0,r.abrupt("return",t);case 6:case"end":return r.stop()}}),S,this)}))),function(){return d.apply(this,arguments)})},{key:"getLicenseInfo",value:function(e,t,r){return this._resetLicense(e,t,r)}},{key:"getImageAsArrayBuffer",value:(l=n(g().mark((function I(e,t){return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",DK(WK,this,RK).call(this,e,t));case 1:case"end":return r.stop()}}),I,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"getImageToDWT",value:(c=n(g().mark((function b(e,t,r){return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",DK(WK,this,RK).call(this,e,t,r));case 1:case"end":return n.stop()}}),b,this)}))),function(e,t,r){return c.apply(this,arguments)})},{key:"acquireImage",value:(a=n(g().mark((function T(e,t,r){var n,i,o,a,s,u,c;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:e=null!=e?e:this._currentDevice,this.checkSource(e),this._currentDevice=e,n=FK(e.deviceType),i=["scan",Zt.stringify({UUID:e.serviceInfo.attrs.UUID,service_type:n})],o=DK(WK,this,MK).call(this,t),i[2]=Zt.stringify(o),a={id:this.clientId,cmdId:Zt.guid(),method:"SendRequestToScanner",parameter:i,version:Lu},s=0;case 9:if(!(s<5)){r.next=32;break}return r.prev=10,r.next=13,this._requestAsync(a,0);case 13:return c=r.sent,u=this.parseResultDefault(c),Zt.isObject(u)&&(u.device=e,u.scanOptions=o),r.abrupt("break",32);case 19:if(r.prev=19,r.t0=r["catch"](10),-1004!=r.t0.code&&-1001!=r.t0.code){r.next=28;break}if(!(s>=4)){r.next=24;break}throw r.t0;case 24:return r.next=26,new Qt.Promise((function(e,t){setTimeout(e,2e3)}));case 26:r.next=29;break;case 28:throw r.t0;case 29:s++,r.next=9;break;case 32:return r.abrupt("return",u);case 33:case"end":return r.stop()}}),T,this,[[10,19]])}))),function(e,t,r){return a.apply(this,arguments)})},{key:"_resetLicense",value:(r=n(g().mark((function C(e,r,n){var i,o,a,s;return g().wrap((function(u){for(;;)switch(u.prev=u.next){case 0:return this.longKeyOrShortkey=e,this.cu=r,LK(),i=null!=r?r:"",o={id:this.clientId,cmdId:Zt.guid(),method:"GetLicenseInfo",parameter:[e,t.logLevel,i,n],version:Lu},u.prev=5,u.next=8,this._requestAsync(o,1e4);case 8:return a=u.sent,this._bInited=!0,u.abrupt("return",this.parseResultDefault(a));case 13:if(u.prev=13,u.t0=u["catch"](5),!this.bLocal){u.next=19;break}throw os(s={}),{code:s._errorCode,message:s._errorString};case 19:throw{code:-2604,message:"Failed to connect to the Proxy Service. Please make sure the Proxy Service is configured successfully, Dynamic Web TWAIN Service is running, or the certificate is valid."};case 20:case"end":return u.stop()}}),C,this,[[5,13]])}))),function(e,t,n){return r.apply(this,arguments)})}]);var r,a,c,l,d,h,m,p}(wK);function RK(e,t,r){return OK.apply(this,arguments)}function OK(){return(OK=n(g().mark((function e(t,r,n){var i,o,a,s,u;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t&&t.device){e.next=2;break}throw{code:-1011,message:"Operation out of expected sequence"};case 2:return n=null!=n?n:{ver:"",clientId:""},(i=["getImage",Zt.stringify({UUID:t.device.serviceInfo.attrs.UUID,service_type:r})])[2]=Zt.stringify(t.scanOptions),i[3]=t.scanJobs,i[4]=t.scanId,i[5]=n._clientId,i[6]=n._ver,o={id:this.clientId,cmdId:Zt.guid(),method:"SendRequestToScanner",parameter:i,version:Lu},e.next=12,this._requestAsync(o,0,!0);case 12:if(a=e.sent,!(a.headers.get("content-type").indexOf("image/")>=0)){e.next=20;break}return e.next=17,a.arrayBuffer();case 17:return e.abrupt("return",e.sent);case 20:return e.next=22,a.json();case 22:if(s=e.sent,"boolean"!=typeof(u=this.parseResultDefault(s))){e.next=28;break}return e.abrupt("return",null);case 28:return e.abrupt("return",u);case 29:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}function MK(e){var t=[];if(e){Zt.isNumber(e.PixelType)&&(t.push({capability:PH.ICAP_PIXELTYPE,curValue:e.PixelType}),rr.DWT.EnumDWT_PixelType.TWPT_BW==e.PixelType&&(t.push({capability:32771,curValue:"application/octet-stream"}),t.push({capability:32772,curValue:"application/octet-stream"})));var r=e.Resolution;r||(r=300),t.push({capability:PH.ICAP_XRESOLUTION,curValue:r}),t.push({capability:PH.ICAP_YRESOLUTION,curValue:r}),e.Brightness!==undefined&&t.push({capability:PH.ICAP_BRIGHTNESS,curValue:e.Brightness}),e.XferCount!==undefined&&t.push({capability:PH.CAP_XFERCOUNT,curValue:e.XferCount}),e.Contrast!==undefined&&t.push({capability:PH.ICAP_CONTRAST,curValue:e.Contrast}),e.TransferMode!==undefined&&t.push({capability:PH.ICAP_XFERMECH,curValue:e.TransferMode}),e.IfFeederEnabled!==undefined&&t.push({capability:PH.CAP_FEEDERENABLED,curValue:e.IfFeederEnabled?1:0}),e.IfDuplexEnabled!==undefined&&t.push({capability:PH.CAP_DUPLEXENABLED,curValue:e.IfDuplexEnabled?1:0})}return t}function LK(){var e=NK.logLevel;Zt.isNumber(e)||(NK.logLevel=-1)}Qt.removeNonPrintableChar;var BK=function(e,t,r){2==r&&Zt.each(t,(function(t,r){kG(e,t,{get:function(){return e._resetErr(),e._isValid()?fi:di},set:function(t){return e._resetErr(),e._isValid()?fi:di}})}))},UK=function(e,t){Zt.each(t,(function(t,r){vK(e,t,1,2)}))},VK=function(e,t){Zt.each(t,(function(t,r){vK(e,t,1,1)}))},jK=function(e,t){Zt.each(t,(function(t,r){vK(e,t,0)}))},GK=function(e,t){Zt.each(t,(function(t,r){vK(e,t,1)}))};function HK(e){var t=e;if(!t._bRemoteMode){kG(t,"ProductKey",{get:function(){return rr.DWT.ProductKey},set:function(e){return Zt.isString(e)?(t._resetErr(),!!t._isValid()&&t._setProductKey(e,!1)):(la(t),di)}}),kG(t,"ProductName",{get:function(){return t.__strProductName}}),kG(t,"VersionInfo",{get:function(){return Io.JSVersion}}),kG(t,"DefaultSourceName",{get:function(){var e=t._getDefaultDevice();return e?e.displayName:""}}),kG(t,"ImageCaptureDriverType",{get:function(){return t._resetErr(),t._isValid()?t._driverType:0},set:function(e){var r=!1,n=!1,i=!1;if(t._bRemoteMode?t.__serverPlatform==Gu.enumWindow?i=!0:t.__serverPlatform==Gu.enumLinux?n=!0:t.__serverPlatform==Gu.enumMac&&(r=!0):(r=de.bMac,n=de.bLinux,i=de.bWin),t._resetErr(),!t._isValid())return!1;if(""!==e){var o=1*e,a=!1;if(oIf.TWAIN64)return ja(t),di;if(i){if(o===If.TWAIN_AND_TWAIN64)t._b64bit&&(t._driverType=o);else if(o!=If.TWAIN&&o!=If.TWAIN64)return ja(t),di;t._b64bit||(o=If.TWAIN),t._driverType=o,a=!0}else if(n)o=If.SANE,t._driverType=o,a=!0;else if(r){if(o===If.TWAIN_AND_ICA);else if(o!=If.ICA&&o!=If.TWAIN&&o!=If.TWAIN64)return ja(t),di;t._driverType=o,a=!0}return a&&(t._curDevice=null,t.__devices=null),!0}return ja(t),di}}),kG(t,"HTTPPostResponseString",{get:function(){return t._resetErr(),t._isValid()&&t.__HTTPPostResponseString?t.__HTTPPostResponseString:""}}),kG(t,"IfAppendImage",{get:function(){return t._resetErr(),!!t._isValid()&&t.__IfAppendImage},set:function(e){return t._resetErr(),!!t._isValid()&&(Zt.isBoolean(e)?t.__IfAppendImage=e:(la(t),di))}}),kG(t,"FTPPort",{get:function(){return t._resetErr(),t._isValid()?t._innerFun("FTPPort"):0},set:function(e){if(t._resetErr(),!t._isValid())return!1;if(""!==e){var r=1*e;return t._innerFun("FTPPort",El(r))}}}),kG(t,"JPEGQuality",{get:function(){return t._resetErr(),t._isValid()?t._innerFun("JPEGQuality"):0},set:function(e){var r=1*e;return r>=100?r=100:r<0&&(r=0),t._resetErr(),!!t._isValid()&&t._innerFun("JPEGQuality",El(r))}}),vK(t,"TIFFCompressionType",1,1),vK(t,"BufferMemoryLimit",1,1),kG(t,"LogLevel",{get:function(){return t._resetErr(),t._isValid()?t._innerFun("LogLevel"):0},set:function(e){if(t._resetErr(),!t._isValid())return!1;var r=1*e;return t._logLevel=r,NK.logLevel=t._logLevel,t._innerFun("LogLevel",El(r))}}),kG(t,"HttpContentTypeFieldValue",{get:function(){return t._resetErr(),t._isValid()?t._strHttpContentTypeFieldValue:""},set:function(e){return t._resetErr(),!!t._isValid()&&(t._strHttpContentTypeFieldValue=e,e)}}),kG(t,"BrokerProcessType",{get:function(){return t._resetErr(),t._isValid()?1:0},set:function(e){return t._resetErr(),!!t._isValid()}}),kG(t,"BorderStyle",{get:function(){return t._resetErr(),!!t._isValid()&&0},set:function(e){return t._resetErr(),t._isValid(),!1}}),kG(t,"HttpFieldNameOfUploadedImage",{get:function(){return t._resetErr(),t._isValid()?t.__remoteFilename:""},set:function(e){return t._resetErr(),t._isValid()?t.__remoteFilename=e:""}}),kG(t,"style",{get:function(){return t._isValid()?t.__style:""}}),kG(t,"ScaleDownThreshold",{get:function(){return t._resetErr(),t._isValid()?t._scaleDownThreshold:0},set:function(e){var r=1*e;return!Zt.isNumber(r)||isNaN(r)?(la(self),di):(t._resetErr(),!!t._isValid()&&(t._scaleDownThreshold=e))}}),kG(t,"CurrentImageIndexInBuffer",{get:function(){return t._isValid()&&t._ImgManager?t._ImgManager.getCurrentImageIndex():0},set:function(e){var r=1*e;return t._resetErr(),!!t._isValid()&&(r>=0&&r0&&r<32768?t.__maxImagesInBuffer=r:na(t,-1010,"Data parameter out of supported range."),t.__maxImagesInBuffer)}}),kG(t,"IfSSL",{get:function(){return t._bSSL},set:function(e){return t._bSSL=e,t._innerFun("IfSSL",El(e)),!0}}),vK(t,"IfAllowLocalCache",1,2),kG(t,"UseLocalService",{get:function(){return!0}}),kG(t,"PDFCompressionType",{get:function(){return t._resetErr(),!!t._isValid()&&t._innerFun("PDFCompressionType")},set:function(e){var r=1*e;return r==rr.DWT.EnumDWT_PDFCompressionType.PDF_FAX3&&(r=rr.DWT.EnumDWT_PDFCompressionType.PDF_FAX4),t._resetErr(),!!t._isValid()&&t._innerFun("PDFCompressionType",El(r))}}),t._setProductKey=function(e,r,n,i){var o=!0,a=e,s=function(e){e||(t.__licenseInfo=undefined);var r=!0;return i||(r=Ac.checkProductKey(t,{Core:!0})),Zt.isFunction(n)&&n(),r};if(t._resetErr(),!t._isValid())return!1;if(Qo.bUseDynamsoftLicenseManager||t._blts)return Ps(t),!1;if(a=Zt.isString(a)?Zt.trim(a):"",rr.DWT.ProductKey=a,""==a)o=!1,s();else{Ac.reparseProductKey();var u=rr.DWT.licenseException;if(0!=u.code)return t.__licenseInfo=undefined,t._errorCode=u.code,t._errorString=u.message,Zt.isFunction(n)&&n(),!1;t._innerFunRaw("ProductKey",El(a),r,!1,!1,(function(e){var n=!1;n=Zt.isArray(e)?e[0]:e,Zt.isArray(e)&&e.length>=3&&"1"===e[1]&&Zt.isFunction(rr.DWT.ShowMessage)&&rr.DWT.ShowMessage(e[2],{width:510,height:272,headerStyle:1,seconds:10}),r||(o=n),t.__licenseInfo=undefined,t.GetLicenseInfo((function(){t._setConvertMode(t._pdfConvertMode),s(!0)}),s)}),(function(){r||(o=!1),s()}))}return o},GK(t,["ProxyServer"]);GK(t,["CapValueString","CapDescription","FTPPassword","FTPUserName","PDFAuthor","PDFCreationDate","PDFCreator","PDFKeywords","PDFModifiedDate","PDFProducer","PDFSubject","PDFTitle","PDFVersion"]),jK(t,["Manufacturer","ProductFamily","ImageBitsPerPixel","ImageLength","ImageWidth","ImageXResolution","ImageYResolution"]);jK(t,["BlankImageCurrentStdDev","CapDefaultIndex","CapDefaultValue","DataSourceStatus","Duplex","PendingXfers","ImageLayoutDocumentNumber","ImageLayoutFrameBottom","ImageLayoutFrameLeft","ImageLayoutFrameNumber","ImageLayoutFrameRight","ImageLayoutFrameTop","ImageLayoutPageNumber","ImagePixelType","MagData","MagType","IfFeederLoaded","IfPaperDetectable","IfUIControllable"]),UK(t,["AllowPluginAuthentication","IfModalUI","IfScanInNewThread","_AutoCropMethod","IfSortBySelectionOrder"]);UK(t,["IfDisableSourceAfterAcquire","IfDuplexEnabled","IfFeederEnabled","IfPASVMode","IfAutoBright","IfAutoDiscardBlankpages","IfAutoFeed","IfAutomaticBorderDetection","IfAutomaticDeskew","IfAutoScan","IfShowIndicator","IfUseTwainDSM","IfTiffMultiPage"]),VK(t,["MaxInternetTransferThreads"]);VK(t,["BlankImageMaxStdDev","BlankImageThreshold","BitDepth","Brightness","PageSize","PixelType","Resolution","Capability","CapCurrentIndex","CapCurrentValue","CapMaxValue","CapMinValue","CapNumItems","CapStepSize","CapType","CapValue","CapValueType","Contrast","PixelFlavor","TransferMode","Unit","XferCount"]),BK(t,["AsyncMode","EnableInteractiveZoom","IfThrowException","ImageEditorIfEnableEnumerator","ImageEditorIfReadonly","ImageEditorIfModal","ImageEditorWindowTitle","IfShowPrintUI","VScrollBar"],2);BK(t,["IfOpenImageWithGDIPlus"])}}Qt.DynamicLoadAddonFuns=[],Qt.attachAddon=function(e){var t=!1;return Zt.each(Qt.DynamicLoadAddonFuns,(function(r){Zt.isFunction(r)&&(r(e),t=!0)})),!qo.bFullEdition&&e.__addon&&delete e.__addon.Camera,t};var zK=s((function qJ(e,t,r){o(this,qJ),this.Url=e,this.Width=t,this.Height=r})),KK=function(){return s((function t(e){o(this,t),this._stwain=e,this._ImgManager=e._ImgManager}),[{key:"Print",value:function(){var e=this;if(e.count()<=0)return!1;var t,r=[];for(t=0;tt?0:(n=i._ImgManager.convertClientIndexToServerId(o),(r=i._ImgManager.getImageIdMap(n))&&r.imageHeight?r.imageHeight:i._stwain.GetImageHeight(o))}},{key:"getImageWidthFromServer",value:function(e){var t,r,n,i=this,o=1*e;return t=i.count(),o<0||o>t?0:(n=i._ImgManager.convertClientIndexToServerId(o),(r=i._ImgManager.getImageIdMap(n))&&r.imageWidth?r.imageWidth:i._stwain.GetImageWidth(o))}}]);var e}();function JK(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function QK(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}Qt.detect.viewerScriptLoaded=fi;var qK=new WeakSet,YK=function(e){function t(e){var r,n,a;return o(this,t),JK(r=i(this,t,[e]),qK),r._ImgManager=new mH(r,r._imageBufferWrapper),r._imageBufferWrapper=r._ImgManager,r._ImagePrint=new KK(r),n=e||{},r._config=n,r._destroying=di,r._iServiceType=az.TwainService,r.__addon={},r._bNoMask=di,r._bNotShowMessage=di,r._bSelectedSourceByServer=di,r._bKeepAwake=di,r._bAx=di,n.container&&(r._containerElement=n.container),r.__IfShowCancelDialogWhenImageTransfer=fi,r._errorCode=0,r._errorString="",r.__bLoadingImage=di,r.__bAcquireImageNow=di,r.__bOpenFileNow=di,r.__defaultSourceName="",r.__sourceCount=0,r._bConnecting=di,r.__licenseInfo=undefined,r.__strProductName=rr.DWT.ProductName,r.__productKey="",r._moduleSize=1048576,r._driverType=If.TWAIN,r.__maxUploadImageSize=-1,r._bServerPercentDone=fi,r._bSSL=de.bSSL,r._bRegistedLoad=!1,r._logLevel=0,r._scaleDownThreshold=0,r._pdfWriteSetting={},r.__serverPlatform=Gu.enumUnknown,r._reconnectTimeSpan=qo.LocaleReconnectTimeSpan,r._bRemoteMode||(r.httpFormFields={},r.HTTPPassword="",r.HTTPPort=Qt.detect.ssl?443:80,r.HTTPUserName="",r.__HTTPPostResponseString="",r.__remoteFilename="RemoteFile",r.__httpHeaderMap=di,r._b64bit?r._segementUploadThreshold=4294967296:r._segementUploadThreshold=524288e3,r._aryTiffTag=[],r._tiffCompressionType=rr.DWT.EnumDWT_TIFFCompressionType.TIFF_AUTO,r._jpgQuality=80,r._pdfConvertMode=3,r._pdfOptions={convertMode:Zu.CM_AUTO,password:"",renderOptions:{renderAnnotations:!1,resolution:200,maxWidth:0,maxHeight:0,renderGrayscale:!1},preserveUnmodifiedOnSave:!1}),HK(r),kG(a=r,"Width",{get:function(){return a._resetErr(),a._isValid()?a._isNoViewer()?(a._nouiNotSupport("Width"),""):a._UIView.GetWidth():""},set:function(e){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("Width"):a._UIView.SetWidth(e))}}),kG(a,"Height",{get:function(){return a._resetErr(),a._isValid()?a._isNoViewer()?(a._nouiNotSupport("Height"),""):a._UIView.GetHeight():""},set:function(e){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("Height"):a._UIView.SetHeight(e))}}),kG(a,"AllowMultiSelect",{get:function(){return a._resetErr(),a._isValid()?a._isNoViewer()?a._nouiNotSupport("AllowMultiSelect"):a._UIView.GetAllowMultiSelect():""},set:function(e){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("AllowMultiSelect"):void a._UIView.SetAllowMultiSelect(e))}}),kG(a,"BackgroundColor",{get:function(){return a._resetErr(),a._isValid()?a._isNoViewer()?(a._nouiNotSupport("BackgroundColor"),""):a._UIView.GetBackgroundColor():""},set:function(e){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("BackgroundColor"):a._UIView.SetBackgroundColor(e))}}),kG(a,"BackgroundFillColor",{get:function(){if(a._resetErr(),!a._isValid())return"";if(a._isNoViewer())return a._nouiNotSupport("BackgroundFillColor"),"";var e=a._innerFun("BackgroundFillColor");return li.BGR2RGB(e)},set:function(e){if(a._resetErr(),!a._isValid())return!1;if(a._isNoViewer())return a._nouiNotSupport("BackgroundFillColor");var t,r=1*e;return!Zt.isNumber(r)||Zt.isNaN(r)?(la(a),di):(t=li.RGB2BGR(r),a._innerFun("BackgroundFillColor",El(t)))}}),kG(a,"FitWindowType",{get:function(){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?(a._nouiNotSupport("FitWindowType"),0):a._UIView.GetFitWindowType())},set:function(e){if(a._resetErr(),!a._isValid())return!1;if(a._isNoViewer())return a._nouiNotSupport("FitWindowType");var t=1*e;return a._UIView.SetFitWindowType(t)}}),kG(a,"IfFitWindow",{get:function(){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("IfFitWindow"):a._UIView.GetIfFitWindow())},set:function(e){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("IfFitWindow"):e?a._UIView.SetIfFitWindow(!0):a._UIView.SetIfFitWindow(!1))}}),kG(a,"ImageMargin",{get:function(){return a._resetErr(),a._isValid()?a._isNoViewer()?(a._nouiNotSupport("ImageMargin"),0):a._UIView.GetImageMargin():0},set:function(e){if(a._resetErr(),!a._isValid())return!1;if(a._isNoViewer())return a._nouiNotSupport("ImageMargin");var t=parseInt(e);return!isNaN(t)&&a._UIView.SetImageMargin(t)}}),kG(a,"MouseX",{get:function(){return a._resetErr(),a._isValid()?a._isNoViewer()?(a._nouiNotSupport("MouseX"),0):a.__MouseX:0}}),kG(a,"MouseY",{get:function(){return a._resetErr(),a._isValid()?a._isNoViewer()?(a._nouiNotSupport("MouseY"),0):a.__MouseY:0}}),kG(a,"SelectionImageBorderColor",{get:function(){return a._resetErr(),a._isValid()?a._isNoViewer()?(a._nouiNotSupport("SelectionImageBorderColor"),""):a._UIView.GetSelectionImageBorderColor():""},set:function(e){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("SelectionImageBorderColor"):a._UIView.SetSelectionImageBorderColor(e))}}),kG(a,"Zoom",{get:function(){return a._resetErr(),a._isValid()?a._isNoViewer()?(a._nouiNotSupport("Zoom"),0):a._UIView.GetZoom():0},set:function(e){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("Zoom"):a._UIView.SetZoom(e))}}),kG(a,"MouseShape",{get:function(){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("MouseShape"):a._UIView.GetMouseShape())},set:function(e){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("MouseShape"):a._UIView.SetMouseShape(e))}}),kG(a,"SelectionRectAspectRatio",{get:function(){return a._resetErr(),a._isValid()?a._isNoViewer()?(a._nouiNotSupport("SelectionRectAspectRatio"),0):a._UIView.GetSelectionRectAspectRatio():0},set:function(e){if(a._resetErr(),!a._isValid())return!1;if(a._isNoViewer())return a._nouiNotSupport("SelectionRectAspectRatio");var t=parseFloat(e);return t>=0&&(a._UIView.SetSelectionRectAspectRatio(t),!0)}}),kG(a,"ShowPageNumber",{get:function(){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("ShowPageNumber"):a._UIView.GetShowPageNumber())},set:function(e){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("ShowPageNumber"):a._UIView.SetShowPageNumber(e))}}),kG(a,"IfAutoScroll",{get:function(){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("IfAutoScroll"):a._UIView.GetIfAutoScroll())},set:function(e){return a._resetErr(),!!a._isValid()&&(a._isNoViewer()?a._nouiNotSupport("IfAutoScroll"):a._UIView.SetIfAutoScroll(e))}}),r._innerInitEvents(n),r}return f(t,e),s(t,[{key:"GetImageDataAsync",value:function(e){return this._ImgManager.getImageData(e)}},{key:"SetCustomDataAsync",value:function(e,t){return this._ImgManager.setCustomData(e,t)}},{key:"style",get:function(){return this.__style}},{key:"GetSourceNamesAsync",value:(a=n(g().mark((function u(e){var t;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if((t=this)._resetErr(),t._isValid()){r.next=4;break}throw{code:t._errorCode,message:t._errorString};case 4:return Ll("GetSourceNamesAsync",t),r.prev=5,r.next=8,t._getSourceCountAsync(t._driverType);case 8:r.next=13;break;case 10:throw r.prev=10,r.t0=r["catch"](5),r.t0;case 13:return r.prev=13,Bl("GetSourceNamesAsync"),r.finish(13);case 16:if(!e){r.next=20;break}return r.abrupt("return",QK(qK,t,XK).call(t));case 20:return r.abrupt("return",QK(qK,t,ZK).call(t));case 21:case"end":return r.stop()}}),u,this,[[5,10,13,16]])}))),function(e){return a.apply(this,arguments)})},{key:"SelectSourceAsync",value:function(e){var t;return t=oH.dialogText.selectSource,this._selectSourceAsync("SelectSourceAsync",e,t)}},{key:"SelectSourceByIndexAsync",value:function(e){return this._selectSourceByIndexAsync("SelectSourceByIndex",e)}},{key:"OpenSourceAsync",value:function(){return this._openSourceAsync("OpenSourceAsync")}},{key:"CloseSourceAsync",value:function(){return this._closeSourceAsync("CloseSourceAsync")}},{key:"OpenSourceManagerAsync",value:function(){var e=this;return e._resetErr(),e._isValid()?e._innerFunV2("OpenSourceManager"):Qt.Promise.reject({code:e._errorCode,message:e._errorString})}},{key:"CloseSourceManagerAsync",value:function(){var e=this;return e._resetErr(),e._isValid()?e._innerFunV2("CloseSourceManager"):Qt.Promise.reject({code:e._errorCode,message:e._errorString})}},{key:"AcquireImage",value:function(e,t,r){var n,i=this,o=null,a=null;return i._resetErr(),!!i._isValid()&&(Zt.isUndefined(r)&&(Zt.isFunction(e)&&Zt.isFunction(t)||Zt.isFunction(e)&&Zt.isUndefined(t)||Zt.isFunction(e)&&null==t||null==e&&Zt.isFunction(t))?(n={},Zt.isFunction(e)&&(o=e),Zt.isFunction(t)&&(a=function(e){e&&e.code&&(i._errorCode=e.code,i._errorString=e.message),t(i._errorCode,i._errorString)})):(n=Zt.isUndefined(e)||null==e?{}:Zt.clone(e),Zt.isFunction(t)&&(o=function(){t(n)}),Zt.isFunction(r)&&(a=function(e){e&&e.code&&(i._errorCode=e.code,i._errorString=e.message),r(n,i._errorCode,i._errorString)})),o||(o=function(){}),a||(a=function(e){e&&e.code&&(i._errorCode=e.code,i._errorString=e.message)}),i.AcquireImageAsync(n).then(o,a),!nf.isServerInvalid(i))}},{key:"GetDevicesAsync",value:function(e,t,r){return this._getDevicesAsync("GetDevicesAsync",e,t,r)}},{key:"SelectDeviceAsync",value:function(e,t){var r=this;return r._resetErr(),r._isValid()?this._selectDeviceAsync("SelectDeviceAsync",e,t):Qt.Promise.reject({code:r._errorCode,message:r._errorString})}},{key:"AcquireImageAsync",value:function(e){return l(d(t.prototype),"_acquireImage",this).call(this,this._curDevice,e)}},{key:"ImageIDToIndex",value:function(e){return this._uidFromServer2index(e)}},{key:"IndexToImageID",value:function(e){return this._index2uidFromServer(e)}},{key:"RemoveImage",value:function(e){return this._removeImage("RemoveImage",e)}},{key:"_innerGetSourceNamesSync",value:function(e){var t=this;return t._getSourceCountSync(),e?QK(qK,t,XK).call(t):QK(qK,t,ZK).call(t)}},{key:"getCapabilities",value:function(e,t,r){var n,i,o,a=this;if(Qt.isFunction(e)?(i=e,o=t):(n=e,i=t,o=r),!Zt.isUndefined(n)){if(!Zt.isArray(n))return Ka(a),void(Zt.isFunction(o)&&o(a._errorCode,a._getErrorString()));if(Zt.isArray(n)&&n.indexOf(null)>=0)return Ka(a),void(Zt.isFunction(o)&&o(a._errorCode,a._getErrorString()));if(Zt.isString(n)&&0==n.trim().length)return Ka(a),void(Zt.isFunction(o)&&o(a._errorCode,a._getErrorString()))}return this._dwtGetCapabilities(n,i,o)}},{key:"setCapabilities",value:function(e,t,r){return this._dwtSetCapabilities(e,t,r)}},{key:"CancelAllPendingTransfers",value:function(){return this._resetErr(),!!this._isValid()&&this._innerFun("CancelAllPendingTransfers")}},{key:"CloseSource",value:function(){var e=this;if(e._resetErr(),!e._isValid())return!1;var t=e._innerFun("CloseSource");return t&&(e._curDevice=null),t}},{key:"CloseSourceManager",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._innerFun("CloseSourceManager")}},{key:"SelectDevice",value:function(e,t){var r,n=this;if(e&&e.deviceType,n._resetErr(),rr.DWT.ConnectWithSocket)return na(n,-2400,"SelectDevice"+" doesn't work under current settings."),!1;var i,o=null===(r=this._dmService.attrs)||void 0===r?void 0:r.UUID;if(o)if((null===(i=e.serviceInfo.attrs)||void 0===i?void 0:i.UUID)==o);else{var a,s=(null===(a=e.serviceInfo.attrs)||void 0===a?void 0:a.url)||e.serviceInfo.server;if(!(s&&s.indexOf(o)>-1))return ns(n),!1}var u=!1;try{(u=QK(qK,this,$K).call(this,e.strDevice,t))&&(this._curDevice=e,this._bSelectedSourceByServer=!1)}catch(c){u=!1,this._errorCode=ua.CommonError,c&&c.message&&(this._errorString=c.message)}return u}},{key:"DisableSource",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._innerFun("DisableSource")}},{key:"FeedPage",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._innerFun("FeedPage")}},{key:"GetDeviceType",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._innerFun("GetDeviceType")}},{key:"GetSourceNameItems",value:function(e){var t=this;return t._resetErr(),!!t._isValid()&&(t.__sourceCount<0&&(t.__sourceCount=0),e=0?t._getSourceNameByIndex(e):"")}},{key:"SourceNameItems",value:function(e){var t=this;return t._resetErr(),!!t._isValid()&&t.GetSourceNameItems(e)}},{key:"GetSourceNames",value:function(e){return this._innerGetSourceNamesSync(e)}},{key:"getSourceCount",value:function(e){return this._getSourceCountAsync(e)}},{key:"GetSourceCountAsync",value:function(e){return this._getSourceCountAsync(e)}},{key:"GetSourceType",value:function(e){var t=this,r=parseInt(e);if(t._resetErr(),isNaN(r))return Ka(t),!1;if(null==t.__devices&&t.GetSourceNames(!1),r>=t.__devices.length||r<0)return Oa(t),!1;var n,i,o,a=t.__devices[r];return n=a.deviceType,i=If.TWAIN,(o=n&Dl)==Al.TWAINSCANNER||o==Al.WIATWAINSCANNER||(o==Al.TWAINX64SCANNER?i=If.TWAIN64:o==Al.ICASCANNER?i=If.ICA:o==Al.SANESCANNER?i=If.SANE:(o&Al.TWAINX64SCANNER)==Al.TWAINX64SCANNER?(o&Al.TWAINSCANNER)!=Al.TWAINSCANNER&&(o&Al.WIATWAINSCANNER)!=Al.WIATWAINSCANNER||(i=If.TWAIN_AND_TWAIN64):(o&Al.ICASCANNER)==Al.ICASCANNER&&((o&Al.TWAINSCANNER)!=Al.TWAINSCANNER&&(o&Al.WIATWAINSCANNER)!=Al.WIATWAINSCANNER||(i=If.TWAIN_AND_ICA))),i}},{key:"OpenSource",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&(e._bRemoteMode?(na(e,-2610,"OpenSource is not supported when Object is created by CreateRemoteScanObjectAsync. Please use OpenSourceAsync instead."),!1):e._innerFun("OpenSource"))}},{key:"OpenSourceManager",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._innerFun("OpenSourceManager")}},{key:"ResetImageLayout",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._innerFun("ResetImageLayout")}},{key:"RewindPage",value:function(){var e=this;return e._resetErr(),!!e._isValid()&&e._innerFun("RewindPage")}},{key:"SelectSource",value:function(e,t){var r=this,n=!1;if(Zt.isFunction(e)&&(n=!0),r._resetErr(),!r._isValid())return!!n&&void 0;var i=If.TWAIN;if(!n){if(r._bRemoteMode)return na(r,-2438,"SelectSource cannot be used synchronously when Object is created by CreateRemoteScanObjectAsync. Please use SelectSourceAsync instead."),!1;if(r._driverType==If.TWAIN_AND_TWAIN64)return function(e){na(e,-2429,"The method SelectSource() must be invoked asynchronously (i.e. with callback functions) when ImageCaptureDriverType is set to TWAIN_AND_ICA or TWAIN_AND_TWAIN64.")}(r),!1;r._driverType!=If.ICA&&r._driverType!=If.SANE&&r._driverType!=If.TWAIN64||(i=r._driverType);var o=de.bMac,a=de.bLinux,s=Tf(i,de.bWin,a,o,de.bAndroid);return r._bSelectedSourceByServer=!0,r._curDevice=null,r._innerFun("SelectSource",El(s))}r._driverType!=If.ICA&&r._driverType!=If.SANE&&r._driverType!=If.TWAIN64&&r._driverType!=If.TWAIN_AND_TWAIN64||(i=r._driverType);var u=de.bMac,c=de.bLinux,l=Tf(i,de.bWin,c,u,de.bAndroid);r.SelectSourceAsync(l).then((function(){Zt.isFunction(e)&&e()}),(function(e){e&&e.code&&(r._errorCode=e.code,r._errorString=e.message),Zt.isFunction(t)&&t(r._errorCode,r._getErrorString())}))}},{key:"GetSourceTypeAsync",value:function(e){var t=this,r=1*e;return t._resetErr(),t._isValid()?Qt.Promise.resolve(t.GetSourceType(r)):Qt.Promise.reject({code:t._errorCode,message:t._errorString})}},{key:"SetFileXferInfo",value:function(e,t){var r,n,i=this;return i._resetErr(),!!i._isValid()&&(r=de.bFileSystem?e.replace(/<%/g,"<%25"):e,n=bf.replaceLocalFilename(r),i._innerFun("SetFileXferInfo",El(n,t)))}},{key:"SetImageLayout",value:function(e,t,r,n){var i=this;return i._resetErr(),!!i._isValid()&&i._innerFun("SetImageLayout",El(e,t,r,n))}},{key:"CapGet",value:function(){return this._resetErr(),!!this._isValid()&&this._innerFun("CapGet")}},{key:"CapGetCurrent",value:function(){return this._resetErr(),!!this._isValid()&&this._innerFun("CapGetCurrent")}},{key:"CapGetDefault",value:function(){return this._resetErr(),!!this._isValid()&&this._innerFun("CapGetDefault")}},{key:"CapGetFrameBottom",value:function(e){return this._resetErr(),!!this._isValid()&&this._innerFun("CapGetFrameBottom",El(e))}},{key:"CapGetFrameLeft",value:function(e){return this._resetErr(),!!this._isValid()&&this._innerFun("CapGetFrameLeft",El(e))}},{key:"CapGetFrameRight",value:function(e){return this._resetErr(),!!this._isValid()&&this._innerFun("CapGetFrameRight",El(e))}},{key:"CapGetFrameTop",value:function(e){return this._resetErr(),!!this._isValid()&&this._innerFun("CapGetFrameTop",El(e))}},{key:"CapGetHelp",value:function(){return this._resetErr(),!!this._isValid()&&this._innerFun("CapGetHelp")}},{key:"CapGetLabel",value:function(){return this._resetErr(),!!this._isValid()&&this._innerFun("CapGetLabel")}},{key:"CapGetLabels",value:function(){return this._resetErr(),!!this._isValid()&&this._innerFun("CapGetLabels")}},{key:"CapIfSupported",value:function(e){return this._resetErr(),!!this._isValid()&&this._innerFun("CapIfSupported",El(e))}},{key:"CapReset",value:function(){return this._resetErr(),!!this._isValid()&&this._innerFun("CapReset")}},{key:"CapSet",value:function(){return this._resetErr(),!!this._isValid()&&this._innerFun("CapSet")}},{key:"CapSetFrame",value:function(e,t,r,n,i){return this._resetErr(),!!this._isValid()&&this._innerFun("CapSetFrame",El(e,t,r,n,i))}},{key:"GetCapItems",value:function(e){return this._resetErr(),!!this._isValid()&&this._innerFun("GetCapItems",El(e))}},{key:"GetCapItemsString",value:function(e){return this._resetErr(),!!this._isValid()&&this._innerFun("GetCapItemsString",El(e))}},{key:"SetCapItems",value:function(e,t){return this._resetErr(),!!this._isValid()&&this._innerFun("SetCapItems",El(e,t))}},{key:"SetCapItemsString",value:function(e,t){return this._resetErr(),!!this._isValid()&&this._innerFun("SetCapItemsString",El(e,t))}},{key:"GenerateURLForUploadData",value:function(e,t,r,n,i){var o=this,a=[];if(t==rr.DWT.EnumDWT_ImageType.IT_BMP||t==rr.DWT.EnumDWT_ImageType.IT_JPG||t==rr.DWT.EnumDWT_ImageType.IT_PNG){if(!Zt.isArray(e))return Ra(o),Zt.isFunction(n)&&n(o._errorCode,o._getErrorString(),"",e,t),"";if(e.length>1)return Fa(o),Zt.isFunction(n)&&n(o._errorCode,o._getErrorString(),"",e,t),"";if(!o._checkIndices(e))return n(o._errorCode,o._getErrorString(),"",e,t),!1;var s=o._ImgManager.convertClientIndexToServerId(e[0]);-1!=s&&a.push(s)}else{if(t!=rr.DWT.EnumDWT_ImageType.IT_TIF&&t!=rr.DWT.EnumDWT_ImageType.IT_PDF)return Zt.isArray(e)?La(o):Ra(o),Zt.isFunction(n)&&n(o._errorCode,o._getErrorString(),o.__HTTPPostResponseString,e,t),"";var u,c;if(Zt.isArray(e)){if(!o._checkIndices(e))return n(o._errorCode,o._getErrorString(),"",e,t),!1;u=e}else{if(-1!=e)return Ra(o),Zt.isFunction(n)&&n(o._errorCode,o._getErrorString(),o.__HTTPPostResponseString,e,t),"";for(u=[],c=0;c1){var l=n.result[0],d=n.result[1];1==l&&(o=["dcp://dwasm_",a,"/file/",d].join(""))}return Zt.isArray(e)&&Zt.each(e,(function(e){i._ImgManager.convertServerIdToClientIndex(e)})),0==o?(Va(i),""):o}},{key:"_asyncGenerateURLForUploadData",value:function(e,t,r,n,i){var o=this,a=t,s=function(){if(Zt.isFunction(i)){var t=[];Zt.isArray(e)&&Zt.each(e,(function(e){var r=o._ImgManager.convertServerIdToClientIndex(e);r>-1&&t.push(r)})),i(t)}return""},u=",";if(a==rr.DWT.EnumDWT_ImageType.IT_BMP||a==rr.DWT.EnumDWT_ImageType.IT_JPG||a==rr.DWT.EnumDWT_ImageType.IT_PNG){if(e.length>1)return Fa(o),s(),""}else if(a!=rr.DWT.EnumDWT_ImageType.IT_TIF&&a!=rr.DWT.EnumDWT_ImageType.IT_PDF)return La(o),s(),"";var c=!1,l=Ho.managerVersion.join(""),d=r;Zt.isString(d)&&""!=d||(d="",u="");var f=["[",'"dcp","dwasm_'+l,'",',a,',"',e.join(","),'"',u,d,"]"].join("");return this._innerFunRaw("GenerateURLForUploadData",f,!0,!1,!0,(function(r){if(r&&Zt.isArray(r.result)&&r.result.length>0)if(1==r.result[0]&&r.result.length>1){var i=r.result[1];c=["dcp://dwasm_",l,"/file/",i].join("")}else r.exception!==undefined&&r.description!==undefined?(o._errorCode=r.exception,o._errorString=r.description):Va(o);else Va(o);if(0==c)return s(),"";if(Zt.isFunction(n)){var a=[];Zt.isArray(e)&&Zt.each(e,(function(e){var t=o._ImgManager.convertServerIdToClientIndex(e);t>-1&&a.push(t)})),n(c,a,t)}return c}),s)}},{key:"SelectSourceByIndex",value:function(e){var t=this,r=parseInt(e);if(t._resetErr(),isNaN(r))return Ka(t),!1;if(null==t.__devices&&t.GetSourceNames(!1),r>=t.__devices.length||r<0)return Oa(t),!1;var n=t.__devices[r];return t.SelectDevice(n)}},{key:"EnableSource",value:function(e,t,r){var n=this;return n._resetErr(),!!n._isValid()&&n.AcquireImage(e,t,r)}},{key:"SourceCount",get:function(){return this._getSourceCountSync()}},{key:"CurrentSourceName",get:function(){return this._curDevice?this._curDevice.displayName:""}},{key:"checkStartScanParams",value:function(e,t){var r=this;if(!e)return na(r,-2381,"scanSetup is invalid."),!1;if(!Zt.isUndefined(t.transferMode)&&0!=e.transferMode&&1!=e.transferMode&&2!=e.transferMode)return function(e){na(e,-2382,"Scanner setup error: Invalid Transfer Mode.")}(r),!1;if(e.transferMode==rr.DWT.EnumDWT_TransferMode.TWSX_FILE){if(!e.fileXfer)return function(e){na(e,-2383,"Scanner setup error: fileXfer is invalid.")}(r),!1;if(!Zt.isString(e.fileXfer.fileName)||""==e.fileXfer.fileName)return function(e){na(e,-2384,"Scanner setup error: Invalid fileName in fileXfer.")}(r),!1;if(!Zt.isNumber(e.fileXfer.fileFormat)||e.fileXfer.fileFormat<0||e.fileXfer.fileFormat>16)return function(e){na(e,-2385,"Scanner setup error: Invalid fileFormat in fileXfer.")}(r),!1}if(t){if(!Zt.isString(t.type)||""==t.type)return function(e){na(e,-2387,"Output setup error: Invalid type in outputSetup.")}(r),!1;if(!t.httpParams)return function(e){na(e,-2386,"Output setup error: Invalid httpParams in outputSetup.")}(r),!1;if(e.transferMode!=rr.DWT.EnumDWT_TransferMode.TWSX_FILE&&Zt.isUndefined(t.format))return function(e){na(e,-2390,"Output setup error: Invalid format in outputSetup.")}(r),!1;if(!Zt.isString(t.httpParams.url)||""==t.httpParams.url)return function(e){na(e,-2388,"Output setup error: Invalid url in outputSetup.httpParams.")}(r),!1;if(!Zt.isString(t.httpParams.fileName)||""==t.httpParams.fileName)return function(e){na(e,-2389,"Output setup error: Invalid fileName in outputSetup.httpParams.")}(r),!1}return!0}},{key:"startScan",value:function(e){var t,r=this,n=e;if(r._resetErr(),!r._isValid())return!1;if(1==r._startScanFlag)return na(t={},-2432,"Operation in progress, please try again when the current operation has finished."),Qt.Promise.reject({code:t._errorCode,message:t._errorString});r._startScanFlag=!0,Zt.isObject(n)||(n={});var i,o,a,s=!1,u=!1,c=!0,l=!0,d=!0,f=!1,h=n.onFinally,g=[],m=[],p=0,v=1,_=[],y={type:"http",format:rr.DWT.EnumDWT_ImageType.IT_PDF,reTries:3,useUploader:!1,singlePost:!0,showProgressBar:!0,removeAfterOutput:!0,httpParams:{url:"",headers:{},formFields:{},remoteName:"RemoteFile",fileName:""}},S=Zt.clone(n),I=n;if(a=S.funcScanStatus,delete S.funcScanStatus,Zt.isFunction(a)?S.bfuncScanStatus=!0:S.bfuncScanStatus=!1,S.outputSetup){var b={pdfSetup:{},tiffSetup:{}};iJ(S.outputSetup,y),o=S.outputSetup,delete S.outputSetup,o.pdfSetup&&(o.format!=rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_PDF&&o.format!=rr.DWT.EnumDWT_ImageType.IT_PDF||Zt.mix(b.pdfSetup,o.pdfSetup)),o.tiffSetup&&(o.format!=rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_TIF&&o.format!=rr.DWT.EnumDWT_ImageType.IT_TIF||Zt.mix(b.tiffSetup,o.tiffSetup)),o.format!=rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_PDF&&o.format!=rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_TIF||(o.singlePost=!0),o.httpParams&&Zt.isNumber(o.httpParams.threads)&&(v=o.httpParams.threads),s=Zt.stringify(b),u=r.checkStartScanParams(S,o)}else(o=y).type="",u=r.checkStartScanParams(S,!1);if(!u)return new Qt.Promise((function(e,t){c&&(t({code:r._errorCode,message:r._getErrorString(),response:""}),c=!1,r._startScanFlag=!1)}));o.funcHttpUploadStatus&&(f=o.funcHttpUploadStatus);var T,C,w,E,k,A,x=r.__remoteFilename,P=r.MaxUploadImageSize,D=r.IfShowProgressBar,F=r.__OnPostTransferAsync,W=r.__OnPostAllTransfers,N=r.__OnHttpUploadStatus,R=r.__insertingIndex,O=r.__IfAppendImage,M=r.httpFormFields,L=r._tiffCompressionType,B=!1,U=o.showProgressBar;if((T=function(e){var t=!0;Zt.each(_,(function(e,r){-1==e.st&&(t=!1)})),t?C(e):setTimeout((function(){T(e)}),200)},C=function(e){e.__OnPostTransferAsync=F,e.__OnPostAllTransfers=W,e.__OnHttpUploadStatus=N,e.__remoteFilename=x,e.__maxUploadImageSize=P,e.IfShowProgressBar=D,e.__insertingIndex=R,e.__IfAppendImage=O,e.httpFormFields=M,e._tiffCompressionType=L,rr.FileUploader&&(rr.FileUploader.nextLoopTime=600),e._startScanFlag=!1},w=function(e,t,r){l?(t(r),T(e)):setTimeout((function(){w(e,t,r)}),200)},E=function(e,t){B=!0,c&&(c=!1,l||r._innerSendCmd("CancelAllPendingTransfers"),w(r,e,t))},k=function(e,t,r,n){if(Zt.isFunction(f)){var i,o=t,a=0;Zt.isNumber(n)&&n>0&&(a=n),i={fileName:o,percentage:r,statusCode:a,responseString:e.__HTTPPostResponseString},setTimeout((function(){f(i)}),10)}},r.__HTTPPostResponseString="",r.IfShowProgressBar=U,Zt.isNumber(S.insertingIndex)&&S.insertingIndex>-1&&(r.__insertingIndex=S.insertingIndex,r.__IfAppendImage=!1),Zt.isFunction(f)?r.__OnHttpUploadStatus=f:r.__OnHttpUploadStatus=!1,o.useUploader)&&!rr.FileUploader)return new Qt.Promise((function(e,t){na(r,-2380,"Please make sure the Uploader Module has been installed.");var n={code:r._errorCode,message:r._getErrorString(),response:""};l=!0,E(t,n)}));if(i=o.reTries,o.useUploader){if(o.httpParams&&(A=o.httpParams.url),!Zt.startsWith(A,"http://")&&!Zt.startsWith(A,"https://")){var V=window.location.href,j=V.lastIndexOf("/");V=V.substring(0,j+1),o.httpParams.url=V+A}}else o.httpParams&&(Zt.each(o.httpParams.headers,(function(e,t){r.SetHTTPHeader(t,e)})),Zt.each(o.httpParams.formFields,(function(e,t){r.SetHTTPFormField(t,e)})));return o.httpParams&&""!==o.httpParams.remoteName&&(r.__remoteFilename=o.httpParams.remoteName),new Qt.Promise((function(e,t){o.useUploader?rr.FileUploader.Init(0,(function(t){e({uploadManager:t})}),(function(e,n){r._errorCode=e,r._errorString=n;var i={code:e,message:n,response:r.__HTTPPostResponseString};l=!0,E(t,i)})):e({})})).then((function(e){return new Qt.Promise((function(t,n){var u=function(){(S.transferMode==rr.DWT.EnumDWT_TransferMode.TWSX_FILE?p==m.length:p==g.length)?(Qt.closeProgress(null,"Scan Upload"),B=!0,t(I),C(r)):setTimeout(u,100)};a&&Zt.isFunction(a)&&(r.__OnPreAllTransfersAsync=function(e){a(e)}),r.registerEvent("OnPostTransferAsync",(function(t){var u,c,h,y,I,b,T=o.httpParams&&o.httpParams.url,C=r._uidFromServer2ServerId(t.imageId),w=o.singlePost,A=S.transferMode==rr.DWT.EnumDWT_TransferMode.TWSX_FILE,x=o.removeAfterOutput,P=0;if(d&&(l=!1,d=!1),A?(P=m.length,m.push(t.path)):(P=g.length,g.push(C)),a&&Zt.isFunction(a)){var D={event:"postTransfer",bScanCompleted:!1,result:{currentPageNum:P+1}};setTimeout((function(){a(D)}),10)}if(B)return!1;if("http"==o.type)if(o.httpParams&&(c=fG(o.httpParams.fileName,P+1),h=fG(o.httpParams.remoteName,P+1)),w||"http"!=o.type)!w&&o.type;else if(o.httpParams&&Zt.isNumber(o.httpParams.maxSizeLimit)&&(r.__maxUploadImageSize=o.httpParams.maxSizeLimit),o.useUploader){U?(rr.FileUploader.nextLoopTime=300,Qt.showProgress(r,"Scan Upload",r.__IfShowCancelDialogWhenImageTransfer)):Qt.hideProgress(),y=function(e,t){return r.__HTTPPostResponseString=t,k(r,e._fileName,100,200),r._OnPercentDone([0,100,"","http",e._fileName]),U&&Qt.closeProgress(null,"Scan Upload"),!A&&o.removeAfterOutput?setTimeout((function(){r._ImgManager.convertServerIdToClientIndex(C)>-1?QK(qK,r,tJ).call(r,C,(function(){p++}),(function(){p++})):p++}),100):p++,!0};var F,W=e.uploadManager;if(I=function(){if(U){var e,t=0;for(t=A?m.length:g.length,e=0;e-1&&QK(qK,r,tJ).call(r,C)}),100),W.CancelAllUpload();var i={code:r._errorCode,message:r._getErrorString(),response:r.__HTTPPostResponseString};return E(n,i),!1},b=function(e,t,n,i){var o=303;t==nJ.TRANS_SERVICE_ERROR_404?o=404:t==nJ.TRANS_SERVICE_ERROR_500?o=500:t==nJ.TRANS_SERVICE_ERROR_503&&(o=503),r._errorCode=t,r._errorString=n,r.__HTTPPostResponseString=i,k(r,c,100,o),I()},F=function(){r.__HTTPPostResponseString="",k(r,c,100,303),I()},A){var N=W.CreateJob(),R=N.FormField;o.httpParams&&(Zt.each(o.httpParams.headers,(function(e,t){N.HttpHeader[t]=e})),Zt.each(o.httpParams.formFields,(function(e,t){R.Add(t,e)}))),N.ServerUrl=T,N.bDeleteFile=x,N.reTries=i,o.httpParams&&Zt.isNumber(o.httpParams.maxSizeLimit)&&(N.maxSizeLimit=o.httpParams.maxSizeLimit),N._fileName=c,N.SourceValue.Add(t.path,c,h),N.ImageType=S.fileXfer.fileFormat,N.ThreadNum=v,N.OnRunSuccess=y,N.OnRunFailure=b,(U||Zt.isFunction(f))&&(N.OnUploadTransferPercentage=function(e,t){t>0&&t<=100&&(r._OnPercentDone([0,t,"","http",e._fileName]),Zt.isFunction(f)&&k(r,e._fileName,t,0))},Qt.cancelFrom=sG.Scan,U&&QK(qK,r,rJ).call(r,I),r._OnPercentDone([0,-1,ul.Uploading,"http",c]),k(r,c,0,0)),W.Run(N)}else(u=o.format)==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_PDF?u=rr.DWT.EnumDWT_ImageType.IT_PDF:u==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_TIF&&(u=rr.DWT.EnumDWT_ImageType.IT_TIF),Qt.cancelFrom=sG.Scan,U&&QK(qK,r,rJ).call(r,I),r._OnPercentDone([0,-1,ul.Encoding,"http",c]),r._asyncGenerateURLForUploadData([C],u,s,(function(e){var t=W.CreateJob(),n=t.FormField;o.httpParams&&(Zt.each(o.httpParams.headers,(function(e,r){t.HttpHeader[r]=e})),Zt.each(o.httpParams.formFields,(function(e,t){n.Add(t,e)}))),t.ServerUrl=T,t.bDeleteFile=x,t.reTries=i,o.httpParams&&Zt.isNumber(o.httpParams.maxSizeLimit)&&(t.maxSizeLimit=o.httpParams.maxSizeLimit),t._fileName=c,t.SourceValue.Add(e,c,h),t.ImageType=u,t.ThreadNum=v,t.OnRunSuccess=y,t.OnRunFailure=b,(U||Zt.isFunction(f))&&(t.OnUploadTransferPercentage=function(e,t){t>0&&t<=100&&(r._OnPercentDone([0,t,"","http",e._fileName]),Zt.isFunction(f)&&k(r,e._fileName,t,0))},r._OnPercentDone([0,-1,ul.Uploading,"http",c]),k(r,c,0,0)),W.Run(t)}),F)}else{var O={id:C,st:-1,bCancel:!1};if(_.push(O),0==P&&(U?Qt.showProgress(r,"Scan Upload",r.__IfShowCancelDialogWhenImageTransfer):Qt.hideProgress()),A)y=function(e){return O.st=0,!A&&o.removeAfterOutput?setTimeout((function(){r._ImgManager.convertServerIdToClientIndex(C)>-1?QK(qK,r,tJ).call(r,C,(function(){p++}),(function(){p++})):p++}),100):p++,!0},I=function(){!A&&o.removeAfterOutput&&setTimeout((function(){r._ImgManager.convertServerIdToClientIndex(C)>-1&&QK(qK,r,tJ).call(r,C)}),100);var e={code:r._errorCode,message:r._getErrorString(),response:r.__HTTPPostResponseString};return Qt.closeProgress(null,"Scan Upload"),2==O.st||(O.st=1,Zt.each(_,(function(e,t){-1==e.st&&(e.bCancel=!0)})),E(n,e)),!1},r._innerUploadDirectly(T,t.path,c,U,x,i,!1,O,y,I);else{if(y=function(e,t){return O.st=0,!A&&o.removeAfterOutput?setTimeout((function(){r._ImgManager.convertServerIdToClientIndex(C)>-1?QK(qK,r,tJ).call(r,C,(function(){p++}),(function(){p++})):p++}),100):p++,!0},I=function(e){!A&&o.removeAfterOutput&&setTimeout((function(){r._ImgManager.convertServerIdToClientIndex(C)>-1&&QK(qK,r,tJ).call(r,C)}),100);var t={code:r._errorCode,message:r._getErrorString(),response:r.__HTTPPostResponseString};return Qt.closeProgress(null,"Scan Upload"),2==O.st||(O.st=1,Zt.each(_,(function(e,t){-1==e.st&&(e.bCancel=!0)})),E(n,t)),!1},u=o.format,Zt.isUndefined(u)){var M=r._ImgManager.convertServerIdToClientIndex(C);return La(r),I([M]),!1}u==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_PDF?u=rr.DWT.EnumDWT_ImageType.IT_PDF:u==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_TIF&&(u=rr.DWT.EnumDWT_ImageType.IT_TIF);var L={method:"startScan",url:T,serverIds:[C],headers:r._GetHttpHeadersAndClear(),formData:ZG(r.httpFormFields),enumImageType:u,saveSetup:s,fileName:c,dataFormat:$H.Binary,retry:i,bOnlyResponseEmptyIsOK:!1,objUploadFileStatus:O,asyncSuccessFunc:y,asyncFailureFunc:I};r._asyncUploadCmd(L)}}})),r.__OnPostAllTransfers=function(){var c,d,_=-1,y=$H.Binary,b=o.httpParams.url,T=o.singlePost,w=S.transferMode==rr.DWT.EnumDWT_TransferMode.TWSX_FILE,A=o.removeAfterOutput;a&&Zt.isFunction(a)&&(_=w?m.length:g.length,d={event:"postTransfer",bScanCompleted:!0,result:{currentPageNum:_}},setTimeout((function(){a(d)}),10));if(0==_)return function(e){na(e,-1029,"Source has nothing to capture.")}(r),void setTimeout((function(){l=!0,h&&Zt.isFunction(h)&&h();var e={code:r._errorCode,message:r._getErrorString(),response:r.__HTTPPostResponseString};E(n,e)}),1e3);if(_>0&&-1029==r._errorCode)r._errorCode=0;else if(0!=r._errorCode){l=!0,h&&Zt.isFunction(h)&&h();var x={code:r._errorCode,message:r._getErrorString(),response:r.__HTTPPostResponseString};return void E(n,x)}if("http"==o.type){if(T&&"http"==o.type){var P,D,F,W=g;if(o.httpParams&&Zt.isNumber(o.httpParams.maxSizeLimit)&&(r.__maxUploadImageSize=o.httpParams.maxSizeLimit),o.useUploader){var N,R=e.uploadManager,O=R.CreateJob(),M=O.FormField;if(U?(rr.FileUploader.nextLoopTime=300,Qt.showProgress(r,"Scan Upload",r.__IfShowCancelDialogWhenImageTransfer)):Qt.hideProgress(),P=function(e,n){var i=e._fileName;return i||(i=""),r._bServerPercentDone=!0,r.__HTTPPostResponseString=n,k(r,i,100,200),r._OnPercentDone([0,100,"","http"]),U&&Qt.closeProgress(null,"Scan Upload"),!w&&o.removeAfterOutput?setTimeout((function(){p=0,Zt.each(W,(function(e){r._ImgManager.convertServerIdToClientIndex(e)>-1?QK(qK,r,tJ).call(r,e,(function(){p++}),(function(){p++})):p++})),setTimeout(u,100)}),100):(B=!0,t(I),C(r)),!0},D=function(){U&&Qt.closeProgress(null,"Scan Upload"),R.CancelAllUpload(),r._bServerPercentDone=!0;var e={code:r._errorCode,message:r._getErrorString(),response:r.__HTTPPostResponseString};return E(n,e),!w&&o.removeAfterOutput&&setTimeout((function(){Zt.each(W,(function(e){r._ImgManager.convertServerIdToClientIndex(e)>-1&&QK(qK,r,tJ).call(r,e)}))}),100),!1},F=function(e,t,n,i){var o=303;t==nJ.TRANS_SERVICE_ERROR_404?o=404:t==nJ.TRANS_SERVICE_ERROR_500?o=500:t==nJ.TRANS_SERVICE_ERROR_503&&(o=503),r._errorCode=t,r._errorString=n,r.__HTTPPostResponseString=i,k(r,"",100,o),D()},N=function(){r.__HTTPPostResponseString="",k(r,"",100,303),D()},U&&(Qt.cancelFrom=sG.Scan,QK(qK,r,rJ).call(r,D)),w)o.httpParams&&(Zt.each(o.httpParams.headers,(function(e,t){O.HttpHeader[t]=e})),Zt.each(o.httpParams.formFields,(function(e,t){M.Add(t,e)}))),O.ServerUrl=b,O.bDeleteFile=A,O.reTries=i,o.httpParams&&Zt.isNumber(o.httpParams.maxSizeLimit)&&(O.maxSizeLimit=o.httpParams.maxSizeLimit),Zt.each(m,(function(e,t){var r,n;o.httpParams&&(r=fG(o.httpParams.fileName,t+1),n=fG(o.httpParams.remoteName,t+1)),O.SourceValue.Add(e,r,n)})),O.ImageType=S.fileXfer.fileFormat,O.ThreadNum=v,O.OnRunSuccess=P,O.OnRunFailure=F,(U||Zt.isFunction(f))&&(O.OnUploadTransferPercentage=function(e,t){t>0&&t<=100&&(r._OnPercentDone([0,t,"","http"]),Zt.isFunction(f)&&k(r,"",t,0))},r._OnPercentDone([0,-1,ul.Uploading,"http"]),k(r,"",0,0)),R.Run(O);else if((c=o.format)==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_PDF||c==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_TIF)c==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_PDF?c=rr.DWT.EnumDWT_ImageType.IT_PDF:c==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_TIF&&(c=rr.DWT.EnumDWT_ImageType.IT_TIF),r._OnPercentDone([0,-1,ul.Encoding,"http"]),r._asyncGenerateURLForUploadData(W,c,s,(function(e){var t,n;o.httpParams&&(Zt.each(o.httpParams.headers,(function(e,t){O.HttpHeader[t]=e})),Zt.each(o.httpParams.formFields,(function(e,t){M.Add(t,e)}))),O.ServerUrl=b,O.bDeleteFile=A,O.reTries=i,o.httpParams&&Zt.isNumber(o.httpParams.maxSizeLimit)&&(O.maxSizeLimit=o.httpParams.maxSizeLimit),o.httpParams&&(t=fG(o.httpParams.fileName,1),n=fG(o.httpParams.remoteName,1)),O._fileName=t,O.SourceValue.Add(e,t,n),O.ImageType=c,O.ThreadNum=v,O.OnRunSuccess=P,O.OnRunFailure=F,(U||Zt.isFunction(f))&&(O.OnUploadTransferPercentage=function(e,n){n>0&&n<=100&&(r._OnPercentDone([0,n,"","http",t]),Zt.isFunction(f)&&k(r,t,n,0))},r._OnPercentDone([0,-1,ul.Uploading,"http",t])),R.Run(O)}),N);else{var L=W.length,V=0,j=0,G="";U&&(r._bServerPercentDone=!1),r._OnPercentDone([0,-1,ul.Encoding,"http"]),Zt.each(W,(function(e,t){var n,a;o.httpParams&&(n=fG(o.httpParams.fileName,t+1),a=fG(o.httpParams.remoteName,t+1)),r._asyncGenerateURLForUploadData([e],c,s,(function(e){j=(V+1)/L*100,G=[V+1,"/",L].join(""),r._OnPercentDone([0,j,G,"http"]),O.SourceValue.Add(e,n,a),++V>=L&&(U&&(r._bServerPercentDone=!0),o.httpParams&&(Zt.each(o.httpParams.headers,(function(e,t){O.HttpHeader[t]=e})),Zt.each(o.httpParams.formFields,(function(e,t){M.Add(t,e)}))),O.ServerUrl=b,O.bDeleteFile=A,O.reTries=i,o.httpParams&&Zt.isNumber(o.httpParams.maxSizeLimit)&&(O.maxSizeLimit=o.httpParams.maxSizeLimit),O.ImageType=c,O.ThreadNum=v,O.OnRunSuccess=P,O.OnRunFailure=F,(U||Zt.isFunction(f))&&(O.OnUploadTransferPercentage=function(e,t){t>0&&t<=100&&(r._OnPercentDone([0,t,"","http"]),Zt.isFunction(f)&&k(r,"",t,0))},r._OnPercentDone([0,-1,ul.Uploading,"http"])),R.Run(O))}),N)}))}}else if(w)P=function(e){return r._bServerPercentDone=!0,!w&&o.removeAfterOutput?setTimeout((function(){p=0,Zt.each(W,(function(e){r._ImgManager.convertServerIdToClientIndex(e)>-1?QK(qK,r,tJ).call(r,e,(function(){p++}),(function(){p++})):p++})),setTimeout(u,100)}),100):(B=!0,t(I),C(r)),!0},D=function(e){r._bServerPercentDone=!0;var t={code:r._errorCode,message:r._getErrorString(),response:r.__HTTPPostResponseString};return E(n,t),!w&&o.removeAfterOutput&&setTimeout((function(){Zt.each(W,(function(e){r._ImgManager.convertServerIdToClientIndex(e)>-1&&QK(qK,r,tJ).call(r,e)}))}),100),!1},r._innerUploadFilesDirectly(b,m,o.httpParams&&o.httpParams.fileName,U,A,i,!1,P,D);else{P=function(e,n){return r._bServerPercentDone=!0,!w&&o.removeAfterOutput?setTimeout((function(){p=0,Zt.each(W,(function(e){r._ImgManager.convertServerIdToClientIndex(e)>-1?QK(qK,r,tJ).call(r,e,(function(){p++}),(function(){p++})):p++})),setTimeout(u,100)}),100):(B=!0,t(I),C(r)),!0},D=function(e){r._bServerPercentDone=!0;var t={code:r._errorCode,message:r._getErrorString(),response:r.__HTTPPostResponseString};return E(n,t),!w&&o.removeAfterOutput&&setTimeout((function(){Zt.each(W,(function(e){r._ImgManager.convertServerIdToClientIndex(e)>-1&&QK(qK,r,tJ).call(r,e)}))}),100),!1},c=o.format;var H=r._GetHttpHeadersAndClear(),z=ZG(r.httpFormFields);if(c==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_PDF||c==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_TIF){var K;c==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_PDF?c=rr.DWT.EnumDWT_ImageType.IT_PDF:c==rr.DWT.EnumDWT_ImageType.IT_MULTIPAGE_TIF&&(c=rr.DWT.EnumDWT_ImageType.IT_TIF),o.httpParams&&(K=fG(o.httpParams.fileName,1),fG(o.httpParams.remoteName,1));var J={method:"startScan",url:b,headers:H,formData:z,serverIds:W,enumImageType:c,saveSetup:s,fileName:K,dataFormat:y,retry:i,bOnlyResponseEmptyIsOK:!1,objUploadFileStatus:!1,asyncSuccessFunc:P,asyncFailureFunc:D};r._asyncUploadCmd(J)}else W.length>0&&r._asyncUploadFilesCmd(b,W,H,z,c,o.httpParams&&o.httpParams.fileName,s,U,i,!1,P,D)}}T&&o.type}l=!0,h&&Zt.isFunction(h)&&h()};var c=function(){if("http"!=o.type)return B=!0,t(I),void C(r);o.singlePost?setTimeout((function(){if(!l&&r._startScanFlag)return B=!0,t(I),void C(r)}),300):setTimeout(u,100)};QK(qK,r,eJ).call(r,S,c,(function(e){if(-1029==r._errorCode){if(S.transferMode==rr.DWT.EnumDWT_TransferMode.TWSX_FILE?m.length>0:g.length>0)return r._errorCode=0,c()}var t={code:r._errorCode,message:r._getErrorString(),response:r.__HTTPPostResponseString};E(n,t)}))}))}))}},{key:"_innerInitEvents",value:function(e){this.__OnWSReconnect=e.onWSReconnect||null,this.__OnWSClose=e.onWSClose||null,this.__OnWSMessage=e.onWSMessage||null,this.__OnWSError=e.onWSError||null,this.__OnPercentDone=e.onPercentDone||"",this.__OnPrintMsg=e.onPrintMsg||"",this.__OnResult=e.onResult||"",this.__OnAfterOperate=e.onAfterOperate||"",this.__OnBeforeOperate=e.onBeforeOperate||"",this.__OnOperateStatus=e.onOperateStatus||"",this.__OnBitmapChanged=e.onBitmapChanged||"",this.__OnGetFilePath=e.onGetFilePath||"",this.__OnPreAllTransfers=e.onPreAllTransfers||"",this.__OnPreTransfer=e.onPreTransfer||"",this.__OnPostLoad=e.onPostLoad||"",this.__OnPostTransfer=e.onPostTransfer||"",this.__OnPostAllTransfers=e.onPostAllTransfers||"",this.__OnSourceUIClose=e.onSourceUIClose||"",this.__OnTransferCancelled=e.onTransferCancelled||"",this.__OnTransferError=e.onTransferError||"",this.__OnInternetTransferPercentage=e.onInternetTransferPercentage||"",this.__OnInternetTransferPercentageEx=e.onInternetTransferPercentageEx||"",this.__OnRemoteScanStatusAsync=e.onRemoteScanStatusAsync||""}}],[{key:"create",value:(r=n(g().mark((function c(e){var r;return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new t(e),n.next=3,nf.STwainConnectToServer(r);case 3:return n.abrupt("return",r);case 4:case"end":return n.stop()}}),c)}))),function(e){return r.apply(this,arguments)})}]);var r,a}(gK);function XK(){var e,t,r=[],n=this.__devices.length;for(e=0;e0&&r.push(o);if(0!=r.length){a.next=7;break}return a.abrupt("return");case 7:return a.next=9,this._innerFunV2("RemoveAllImages",El(r.join(",")));case 9:if(!a.sent&&-1033!=this._errorCode){a.next=16;break}if(this._imageBufferWrapper.removeImages(t)){a.next=14;break}throw this._imageBufferWrapper.getError();case 14:a.next=17;break;case 16:throw{code:this._errorCode,message:this._errorString};case 17:case"end":return a.stop()}}),C,this)}))),function(e){return m.apply(this,arguments)})},{key:"updateImage",value:function(e,r,n){var i=this._imageBufferWrapper.getIndexByUid(e),o=this._imageBufferWrapper.convertClientIndexToServerId(i);return l(d(t.prototype),"_updateImage",this).call(this,o,r,n)}},{key:"getSkewAngleFromBinaryAsync",value:function(e,t,r,n){var i=this;if(i._resetErr(),!i._isValid())return Qt.Promise.reject({code:i._errorCode,message:i._errorString});var o=this._imageBufferWrapper.getCustomDataByIndex(e),a=this._imageBufferWrapper.getMetadataByIndex(e),s=this._imageBufferWrapper.convertClientIndexToServerId(e),u={imageId:s,serverId:s,bufferLen:t.size,imageType:Wd.IT_BMP,width:a.width,height:a.height,bit:a.bitDepth,xres:a.resolutionX,yres:a.resolutionY,uidFromServer:o.uidFromServer},c=Zt.stringify([Zt.stringify(u)]);return this._innerSendBlob("GetSkewAngleFromBinary",c,t,!0,!0,r,n)}},{key:"httpUpload",value:(h=n(g().mark((function w(e,r,n,i,o,a,s){var u,c;return g().wrap((function(l){for(;;)switch(l.prev=l.next){case 0:if((u=this)._resetErr(),u._isValid()){l.next=4;break}throw{code:u._errorCode,message:u._errorString};case 4:if(!Zt.isUndefined(e)&&""!==e){l.next=9;break}throw Ea(u),{code:u._errorCode,message:u._errorString};case 9:if(Zt.isString(e)){l.next=12;break}throw Ua(u),{code:u._errorCode,message:u._errorString};case 12:if(u._checkIndices(r)){l.next=14;break}throw{code:u._errorCode,message:u._errorString};case 14:if(0!=(c=Df(u,r)).length){l.next=18;break}throw ca(u),{code:u._errorCode,message:u._errorString};case 18:if(!Zt.isUndefined(n)){l.next=21;break}throw La(u),{code:u._errorCode,message:u._errorString};case 21:if(n!=rr.DWT.EnumDWT_ImageType.IT_BMP&&n!=rr.DWT.EnumDWT_ImageType.IT_JPG&&n!=rr.DWT.EnumDWT_ImageType.IT_PNG){l.next=27;break}if(!(c.length>1)){l.next=25;break}throw Fa(u),{code:u._errorCode,message:u._errorString};case 25:l.next=33;break;case 27:if(n!=rr.DWT.EnumDWT_ImageType.IT_TIF&&n!=rr.DWT.EnumDWT_ImageType.IT_PDF){l.next=31;break}l.next=33;break;case 31:throw La(u),{code:u._errorCode,message:u._errorString};case 33:if(!(Zt.isUndefined(i)||i!=rr.DWT.EnumDWT_UploadDataFormat.Binary&&i!=rr.DWT.EnumDWT_UploadDataFormat.Base64)){l.next=36;break}throw Ba(u),{code:u._errorCode,message:u._errorString};case 36:return l.next=38,new Qt.Promise((function(r,l){var d,f,h=parseInt(n),g=parseInt(i);null!=a&&a.formFields&&(d=new FormData,Zt.each(null==a?void 0:a.formFields,(function(e,t){var r=e.name,n=e.value;Zt.isString(r)&&(n instanceof Blob?d.append(r,n,e.fileName):d.append(r,n))}))),null!=a&&a.headers&&(f={},Zt.each(null==a?void 0:a.headers,(function(e,t){Zt.isString(e.name)&&(f[e.name]=e.value)}))),u._containerElement=s,t._innerHTTPUpload(u,"httpUpload",e,null==a?void 0:a.responseType,f,d,c,h,g,o,void 0,0,!1,void 0,(function(e){if(Zt.isFunction(r)){var t=[];Zt.isArray(c)&&Zt.each(c,(function(e){var r=u._imageBufferWrapper.convertServerIdToClientIndex(e);r>-1&&t.push(r)}));try{Ff(r,e,t)}catch(n){}}return e=null,!0}),(function(e){if(Zt.isFunction(l))try{l(e)}catch(t){}return!1}))}));case 38:return l.abrupt("return",l.sent);case 39:case"end":return l.stop()}}),w,this)}))),function(e,t,r,n,i,o,a){return h.apply(this,arguments)})},{key:"getCustomDataByIndex",value:function(e){return this._imageBufferWrapper.getCustomDataByIndex(e)}},{key:"getIndexByUid",value:function(e){return this._imageBufferWrapper.getIndexByUid(e)}},{key:"getProfile",value:function(e){return l(d(t.prototype),"_getProfile",this).call(this,e)}},{key:"setProfile",value:function(e,r){return l(d(t.prototype),"_setProfile",this).call(this,e,r)}},{key:"imageIDToIndex",value:function(e){return this._uidFromServer2index(e)}},{key:"indexToImageID",value:function(e){return this._index2uidFromServer(e)}},{key:"rotate",value:function(e,t,r,n){var i=this;if(i._resetErr(),!i._isValid())return Qt.Promise.reject({code:i._errorCode,message:i._errorString});var o=parseInt(e);if(isNaN(o))return ca(i),Qt.Promise.reject({code:i._errorCode,message:i._errorString});if(o<0||o>=i.howManyImagesInBuffer)return Oa(i),Qt.Promise.reject({code:i._errorCode,message:i._errorString});var a=i._imageBufferWrapper.convertClientIndexToServerId(o);return-1==a?(Oa(i),Qt.Promise.reject({code:i._errorCode,message:i._errorString})):i._innerFunV2("RotateEx",El(a,t,r,n),!0).then((function(e){}))}},{key:"crop",value:function(e,t){var r=this;if(r._resetErr(),!r._isValid())return Qt.Promise.reject({code:r._errorCode,message:r._errorString});var n=parseInt(e);if(isNaN(n))return ca(r),Qt.Promise.reject({code:r._errorCode,message:r._errorString});if(n<0||n>=r.howManyImagesInBuffer)return Oa(r),Qt.Promise.reject({code:r._errorCode,message:r._errorString});var i=r._imageBufferWrapper.convertClientIndexToServerId(n);if(-1==i)return Oa(r),Qt.Promise.reject({code:r._errorCode,message:r._errorString});var o=t.x,a=t.y,s=t.x+t.width,u=t.y+t.height;return r._innerFunV2("Crop",El(i,o,a,s,u),!0).then((function(e){}))}},{key:"_createHttpUploaderConfig",value:function(){var e=this,t=new yG;return t.IfShowProgressBar=e.IfShowProgressBar,t.IfShowCancelDialogWhenImageTransfer=e.IfShowCancelDialogWhenImageTransfer,t.MaxUploadImageSize=e.MaxUploadImageSize,t.HTTPRequestswithCredentials=e.HTTPRequestswithCredentials,t.onPercent=function(t){e._OnPercentDone(t)},t.onHttpUploadStatus=function(e){},t}},{key:"_OnReady",value:(c=n(g().mark((function E(){var e,r,n;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return $o((e=this)._serverInfo.server)&&(Od.item("DWT_port",e._serverInfo.port),Od.item("DWT_ssl",e._serverInfo.ssl?"true":"false")),e._bNoMask||Ll("OnReady",e),i.prev=3,i.next=6,l(d(t.prototype),"_OnReady",this).call(this);case 6:return i.next=8,e._innerActiveUI(e._uuidForActiveUI);case 8:return r=i.sent,i.next=11,e._OnActiveUI(r);case 11:(n=e._id)&&!rr.DWT.WebTwainIdMap[n]&&(rr.DWT.WebTwainIdMap[n]=e),i.next=20;break;case 15:throw i.prev=15,i.t0=i["catch"](3),i.t0&&(e._errorCode=i.t0.code,e._errorString=i.t0.message),e.dispose(),i.t0;case 20:return i.prev=20,e._bNoMask||Bl("OnReady"),i.finish(20);case 23:case"end":return i.stop()}}),E,this,[[3,15,20,23]])}))),function(){return c.apply(this,arguments)})},{key:"_isBindViewer",value:function(){return this._bBindViewer}},{key:"_isNoViewer",value:function(){return!this._isBindViewer()}},{key:"getServiceInfo",value:function(){return l(d(t.prototype),"getServiceInfo",this).call(this)}},{key:"setViewerInfo",value:function(e){this._bBindViewer=e}},{key:"setViewerControlInfo",value:function(e){this._controlWidth=e.width,this._controlHeight=e.height}}],[{key:"create",value:(u=n(g().mark((function k(e){var r;return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new t(e),n.next=3,nf.STwainConnectToServer(r);case 3:return n.abrupt("return",r);case 4:case"end":return n.stop()}}),k)}))),function(e){return u.apply(this,arguments)})},{key:"_getBuffer",value:function(e){return iG._getBuffer(e._imageBufferWrapper)}},{key:"_setError",value:function(e,t,r){e._errorCode=t,e._errorString=r}},{key:"createByServiceInfo",value:(a=n(g().mark((function A(e,r,n){var i,o,a;return g().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o={id:Zt.guid(),dmService:r,bNoViewer:!0,bNoMask:null==r||null===(i=r.attrs)||void 0===i?void 0:i.bNoMask,bNotShowMessage:!0},(a=new t(o))._uuidForActiveUI=e,a._bLicenseErrorDispose=!1,n&&(a._containerElement=n),s.next=7,a._connnect();case 7:return s.next=9,nf.STwainConnectToServer(a);case 9:return s.abrupt("return",a);case 10:case"end":return s.stop()}}),A)}))),function(e,t,r){return a.apply(this,arguments)})},{key:"checkOnlineByServiceInfo",value:(r=n(g().mark((function x(e){var r,n;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return r={id:Zt.guid(),dmService:e,bNoViewer:!0,bNoMask:!0,bNotShowMessage:!0},i.prev=1,n=new t(r),i.next=5,n._connnect();case 5:return n._bReady=!0,n._wsClient||(n._wsClient=new hu(null)),n.dispose(),i.abrupt("return",!0);case 11:return i.prev=11,i.t0=i["catch"](1),Zt.warn(i.t0),i.abrupt("return",!1);case 15:case"end":return i.stop()}}),x,null,[[1,11]])}))),function(e){return r.apply(this,arguments)})},{key:"_isReady",value:function(e){return e._bReady}},{key:"_innerHTTPUpload",value:function(e,t,r,n,i,o,a,s,u,c,l,d,f,h,g,m){var p=c,v=r;if(Zt.isUndefined(s))return La(e),void(Zt.isFunction(m)&&m({code:e._errorCode,message:e._errorString}));Qt.cancelFrom=sG.HTTPUpload;var _,y=function(r,n,i,o){Qt.needShowTwiceShowDialog=!1,e.IfShowProgressBar&&Qt.closeProgress(null,t),Zt.isFunction(m)&&m({code:r,message:n,response:i,httpCode:o})},S=e._createHttpUploaderConfig();if(S.objUploadStatus=h,p=hG(p,s),Qt.needShowTwiceShowDialog=!0,e.IfShowProgressBar?(Qt.showProgress(e,t,!1),Qt.progressContext&&(Qt.progressContext._onPercent=function(e){var t=0;if(e){var r,n;r=e.loaded,n=e.total,(t=Math.floor(r/n*100))>100&&(t=100)}Qt.progressBarOnPercentDone(-1,"Transferring...","",t,"")})):Qt.hideProgress(),u==rr.DWT.EnumDWT_UploadDataFormat.Binary){if(h&&h.bCancel)return h.st=2,as(e),void y(e._errorCode,e._errorString);S.onPercent([0,-1,ul.Encoding,"http"]),e._convertToBlobForUpload(s,a,l,4,(function(r,a,s){if(_=function(r){return Qt.needShowTwiceShowDialog=!1,e.IfShowProgressBar&&Qt.closeProgress(null,t),Zt.isFunction(g)&&Ff(g,r),r=null,!0},h&&h.bCancel)return h.st=2,as(e),y(e._errorCode,e._errorString);if(!r||r.size<=0)return Ta(e),y(e._errorCode,e._errorString);var u=e.__maxUploadImageSize;if(r.size>u&&-1!=u)return wa(e),y(e._errorCode,e._errorString);if(0!=e._errorCode)return y(e._errorCode,e._errorString);rr.DWT.IfAddMD5InUploadHeader&&a&&""!=a&&(i["dwt-md5"]=a);var c=new vG,l=new _G;l.url=v,l.method=t,l.content=r,r=null,l.contentType=e._strHttpContentTypeFieldValue,l.headers=i,l.fileName=p,l.httpFormData=o,l.retry=d,l.bOnlyResponseEmptyIsOK=f,l.responseType=n,S.objUploadStatus=h,c.httpPostUpload(S,l,_,y)}),y)}else if(u==rr.DWT.EnumDWT_UploadDataFormat.Base64){e._convertToBase64ByServerIdsWithUI(t,a,s,l,4,(function(r){var a,s;if(!r||r.getLength()<=0)return Ta(e),y(e._errorCode,e._errorString);if(_=function(r){return Qt.needShowTwiceShowDialog=!1,e.IfShowProgressBar&&Qt.closeProgress(null,t),Zt.isFunction(g)&&Ff(g,r),!0},a=r.getMD5(),rr.DWT.IfAddMD5InUploadHeader&&(i["dwt-md5"]=a),!(s=r.getData(0,r.getLength()))||""==s)return Ta(e),y(e._errorCode,e._errorString);var u=new _G;u.url=v,u.method=t,u.content=s,s=null,u.headers=i,u.fileName=p,u.httpFormData=o,u.retry=d,u.bOnlyResponseEmptyIsOK=f,u.responseType=n,(new vG).httpPostUpload(S,u,_,y)}),y)}}}]);var r,a,u,c,h,m,p,v,_,y}(TG),fJ=Il,hJ=function(){return s((function A(e){var t=this;if(o(this,A),this._serverUrl=e,this._defaultDSScanClient=null,this._dsScanClientsMap={},this._serviceInfos=null,this._id=Zt.guid(),this.onBufferChanged=null,this.onPostTransferAsync=null,this._errorCode=0,this._errorString="",this._bDispose=!1,this._needSetLogLevel=!1,this._logLevel=-1,this._showProgressBar=!0,this._checkServerUrl(),this._id&&!rr.DWT.RemoteScanIdMap[this._id]&&(rr.DWT.RemoteScanIdMap[this._id]=this),this._uuidForRemoteScanObject="",Qt.dlgProgress||Qt.initProgress(null),rr.DWT.UseDefaultViewer){var r={viewerEvents:{bufferChanged:function(e,r){t.__bufferChanged(t,e,r)},save:function(e,r,n,i){return t.__save(e,r,n,i)},rotate:function(e,r,n){return t.__rotate(e,r,n)},crop:function(e,r,n,i,o){return t.__crop(e,{x:r,y:n,width:i,height:o})}},viewerError:{setError:function(e,r){t._defaultDSScanClient?dJ._setError(t._defaultDSScanClient,e,r):0==e&&""==r||(t._errorCode=e,t._errorString=r)}},imageEditorEvents:{deskew:function(e,r){t.__deskew(t,e,r)},removeImage:function(){t.__remove(t)},removeAllImage:function(){t.__removeAll(t)},close:function(){t.__close(t)}},imageEditorUiConfig:{buttons:{visibility:{scan:!1,load:!1}}},beforeImageEditorCreated:function(e){t.__beforeImageEditorCreated(e)}};this._viewer=new rr.DWTViewerEx(null,r)}else this._viewer=null}),[{key:"Viewer",get:function(){return this._viewer}},{key:"_disposeDSClientByKey",value:(k=n(g().mark((function x(e){var t;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(t=this._dsScanClientsMap[e])){r.next=10;break}if(t.isDestroy){r.next=9;break}if(!t.__unload){r.next=8;break}return r.next=6,t.__unload();case 6:r.next=9;break;case 8:t.dispose();case 9:delete this._dsScanClientsMap[e];case 10:case"end":return r.stop()}}),x,this)}))),function(e){return k.apply(this,arguments)})},{key:"_checkServerUrl",value:function(){var e=this._serverUrl;if(e&&Zt.isString(e)&&Zt.startsWith(location.href,"https://")&&Zt.startsWith(e,"http://")){var t={};throw function(e,t,r){na(e,-2436,'Mixed Content: The page at "'+t+'" was loaded over HTTPS, but requested an insecure resource "'+r+'/ddm/18625/ddm/SearchScanner". This request has been blocked; the content must be served over HTTPS.')}(t,location.href,e),Gs(t)}if(!Zt.isString(e)||""==e){var r={};throw na(r,-2545,"The proxy server URL is invalid."),Gs(r)}}},{key:"getDynamsoftService",value:(E=n(g().mark((function P(e){var t,r,n,i,o,a,s,u,c,l,d,f,h,m,p,v,_,y,S;return g().wrap((function(g){for(;;)switch(g.prev=g.next){case 0:if(!this._bDispose){g.next=4;break}throw cs(t={}),Gs(t);case 4:if(r=this._serverUrl,this._checkServerUrl(),n=new NK(r,!0),Ll("getDynamsoftService",this.getViewerElement()),g.prev=8,!e&&this._serviceInfos){g.next=68;break}if(i=null,o=this._serviceInfos,this._serviceInfos=[],a="",s="",!Zo()){g.next=30;break}return g.next=16,this._setRemoteUuid();case 16:return g.prev=16,g.next=19,id(rr.DWT.lgdt(),"");case 19:(u=g.sent)&&(a=u.ar,s=this._uuidForRemoteScanObject),g.next=28;break;case 23:throw g.prev=23,g.t0=g["catch"](16),cd(c={},g.t0),{code:c._errorCode,message:c._errorString};case 28:g.next=31;break;case 30:a=Qo.refProductKey;case 31:return g.next=33,n.getDynamsoftService(a,s,e);case 33:if(!(i=g.sent)){g.next=68;break}d=[],l=0;case 37:if(!(l0&&this.Viewer.height&&this.Viewer.height>0&&this._defaultDSScanClient.setViewerControlInfo({width:this.Viewer.width,height:this.Viewer.height})}},{key:"__beforeImageEditorCreated",value:function(e){var t=rr.DWT.CustomizableDisplayInfo;if(!Zt.isUndefined(t)){if(!Zt.isUndefined(t.buttons)){var r=t.buttons.titles;Zt.isUndefined(r)||(Zt.isUndefined(r.previous)||(e.buttons.titles.previous=r.previous),Zt.isUndefined(r.next)||(e.buttons.titles.next=r.next),Zt.isUndefined(r.print)||(e.buttons.titles.print=r.print),Zt.isUndefined(r.scan)||(e.buttons.titles.scan=r.scan),Zt.isUndefined(r.load)||(e.buttons.titles.load=r.load),Zt.isUndefined(r.rotateleft)||(e.buttons.titles.rotateleft=r.rotateleft),Zt.isUndefined(r.rotate)||(e.buttons.titles.rotate=r.rotate),Zt.isUndefined(r.rotateright)||(e.buttons.titles.rotateright=r.rotateright),Zt.isUndefined(r.deskew)||(e.buttons.titles.deskew=r.deskew),Zt.isUndefined(r.crop)||(e.buttons.titles.crop=r.crop),Zt.isUndefined(r.cut)||(e.buttons.titles.cut=r.cut),Zt.isUndefined(r.changeimagesize)||(e.buttons.titles.changeimagesize=r.changeimagesize),Zt.isUndefined(r.flip)||(e.buttons.titles.flip=r.flip),Zt.isUndefined(r.mirror)||(e.buttons.titles.mirror=r.mirror),Zt.isUndefined(r.zoomin)||(e.buttons.titles.zoomin=r.zoomin),Zt.isUndefined(r.originalsize)||(e.buttons.titles.originalsize=r.originalsize),Zt.isUndefined(r.zoomout)||(e.buttons.titles.zoomout=r.zoomout),Zt.isUndefined(r.stretch)||(e.buttons.titles.stretch=r.stretch),Zt.isUndefined(r.fit)||(e.buttons.titles.fit=r.fit),Zt.isUndefined(r.fitw)||(e.buttons.titles.fitw=r.fitw),Zt.isUndefined(r.fith)||(e.buttons.titles.fith=r.fith),Zt.isUndefined(r.hand)||(e.buttons.titles.hand=r.hand),Zt.isUndefined(r.rectselect)||(e.buttons.titles.rectselect=r.rectselect),Zt.isUndefined(r.zoom)||(e.buttons.titles.zoom=r.zoom),Zt.isUndefined(r.restore)||(e.buttons.titles.restore=r.restore),Zt.isUndefined(r.save)||(e.buttons.titles.save=r.save),Zt.isUndefined(r.close)||(e.buttons.titles.close=r.close),Zt.isUndefined(r.removeall)||(e.buttons.titles.removeall=r.removeall),Zt.isUndefined(r.removeselected)||(e.buttons.titles.removeselected=r.removeselected));var n=t.buttons.bShowAllButtons;Zt.isUndefined(n)||(e.buttons.bShowAllButtons=n);var i=t.buttons.visibility;Zt.isUndefined(i)||(Zt.isUndefined(i.scan)||(e.buttons.visibility.scan=i.scan),Zt.isUndefined(i.load)||(e.buttons.visibility.load=i.load),Zt.isUndefined(i.print)||(e.buttons.visibility.print=i.print),Zt.isUndefined(i.removeall)||(e.buttons.visibility.removeall=i.removeall),Zt.isUndefined(i.removeselected)||(e.buttons.visibility.removeselected=i.removeselected),Zt.isUndefined(i.rotateleft)||(e.buttons.visibility.rotateleft=i.rotateleft),Zt.isUndefined(i.rotate)||(e.buttons.visibility.rotate=i.rotate),Zt.isUndefined(i.rotateright)||(e.buttons.visibility.rotateright=i.rotateright),Zt.isUndefined(i.deskew)||(e.buttons.visibility.deskew=i.deskew),Zt.isUndefined(i.crop)||(e.buttons.visibility.crop=i.crop),Zt.isUndefined(i.cut)||(e.buttons.visibility.cut=i.cut),Zt.isUndefined(i.changeimagesize)||(e.buttons.visibility.changeimagesize=i.changeimagesize),Zt.isUndefined(i.flip)||(e.buttons.visibility.flip=i.flip),Zt.isUndefined(i.mirror)||(e.buttons.visibility.mirror=i.mirror),Zt.isUndefined(i.zoomin)||(e.buttons.visibility.zoomin=i.zoomin),Zt.isUndefined(i.originalsize)||(e.buttons.visibility.originalsize=i.originalsize),Zt.isUndefined(i.zoomout)||(e.buttons.visibility.zoomout=i.zoomout),Zt.isUndefined(i.stretch)||(e.buttons.visibility.stretch=i.stretch),Zt.isUndefined(i.fit)||(e.buttons.visibility.fit=i.fit),Zt.isUndefined(i.fitw)||(e.buttons.visibility.fitw=i.fitw),Zt.isUndefined(i.fith)||(e.buttons.visibility.fith=i.fith),Zt.isUndefined(i.hand)||(e.buttons.visibility.hand=i.hand),Zt.isUndefined(i.rectselect)||(e.buttons.visibility.rectselect=i.rectselect),Zt.isUndefined(i.zoom)||(e.buttons.visibility.zoom=i.zoom))}var o=t.dialogText;Zt.isUndefined(o)||(Zt.isUndefined(o.dlgRotateAnyAngle)||(e.dialogText.dlgRotateAnyAngle=o.dlgRotateAnyAngle),Zt.isUndefined(o.dlgChangeImageSize)||(e.dialogText.dlgChangeImageSize=o.dlgChangeImageSize),Zt.isUndefined(o.saveChangedImage)||(e.dialogText.saveChangedImage=o.saveChangedImage),Zt.isUndefined(o.selectSource)||(e.dialogText.selectSource=o.selectSource))}}},{key:"__bufferChanged",value:function(e,t,r){var n,i=e,o=[],a=-1,s=[];t.operation&&(t.action=t.operation);for(var u=0;u=0&&(n=i._defaultDSScanClient.getCustomDataByIndex(t.curIndex))&&n.uidFromServer&&(a=n.uidFromServer),t.currentId=a,t.afterStatus.selectedUids)for(var c=0;c=0&&(n=i._defaultDSScanClient.getCustomDataByIndex(d))&&n.serverId&&s.push(n.uidFromServer)}}t.selectedIds=s,Zt.mix(t,{}),delete t.uids,delete t.currentUid,delete t.selectedUids,delete t.afterStatus,delete t.beforeStatus,delete t.operation,delete t.curIndex,delete t.docUid,i.__fireEvent("onBufferChanged",t)}},{key:"__acquire",value:function(e,t){var r=e;r._stwain.SelectSource((function(){r._stwain.CloseSource(),r._stwain.OpenSource(),r._stwain.IfShowUI=!0,1==rr.DWT.IfConfineMaskWithinTheViewer?(rr.DWT.IfConfineMaskWithinTheViewer=!1,r._stwain.AcquireImage({},(function(){rr.DWT.IfConfineMaskWithinTheViewer=!0}),(function(){}))):r._stwain.AcquireImage()}),(function(){Zt.log("User did not select a source")}))}},{key:"__remove",value:(T=n(g().mark((function W(e){var t,r;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this,!this._defaultDSScanClient){e.next=10;break}if(es(this._defaultDSScanClient),!(t.howManyImagesInBuffer<=0||t.currentImageIndexInBuffer<0)){e.next=6;break}return fJ.output(t,"No image in Buffer"),e.abrupt("return",!0);case 6:return r=dJ._getBuffer(this._defaultDSScanClient),e.next=9,this._defaultDSScanClient.removeImages(r.getSelectedImagesIndices());case 9:return e.abrupt("return",e.sent);case 10:return e.abrupt("return",!1);case 11:case"end":return e.stop()}}),W,this)}))),function(e){return T.apply(this,arguments)})},{key:"__removeAll",value:(b=n(g().mark((function N(e){return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._defaultDSScanClient){e.next=4;break}return es(this._defaultDSScanClient),e.next=4,this._defaultDSScanClient._removeAllImagesAsync("removeAllImages",!0);case 4:return e.abrupt("return",!1);case 5:case"end":return e.stop()}}),N,this)}))),function(e){return b.apply(this,arguments)})},{key:"__save",value:(I=n(g().mark((function R(e,t,r,n){var i,o,a;return g().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(o="save",a=(i=this).__getViewerElementForViewer(i,n),Ll(o,a),s.prev=3,es(i._defaultDSScanClient),!(i.howManyImagesInBuffer<=0||i.currentImageIndexInBuffer<0)){s.next=8;break}return fJ.output(i,"No image in Buffer"),s.abrupt("return");case 8:return s.next=10,i._defaultDSScanClient.updateImage(e,t,r);case 10:return s.sent,s.next=13,i._defaultDSScanClient.__saveToViewerAfterUpdate(e,r);case 13:s.next=17;break;case 15:s.prev=15,s.t0=s["catch"](3);case 17:return s.prev=17,Bl(o),s.finish(17);case 20:case"end":return s.stop()}}),R,this,[[3,15,17,20]])}))),function(e,t,r,n){return I.apply(this,arguments)})},{key:"__getViewerElementForViewer",value:function(e,t){var r,n=e;if(t)if(n._viewer.webViewer.imageEditor){var i=n._viewer.createImageEditor();r="dwt-viewer-imageEditor-fullScreen"==i.inner.containerElement.className?{_containerElement:document.body}:{_containerElement:i.inner.containerElement}}else r=n.getViewerElement();else r=n.getViewerElement();return r}},{key:"__close",value:function(e){var t=e;if(Zt.isFunction(t.__CloseImageEditorUI))try{t.__CloseImageEditorUI()}catch(r){_o(r)}}},{key:"__deskew",value:function(e,t,r){var n=this,i="deskew";if(es(n._defaultDSScanClient),n.howManyImagesInBuffer<=0||n.currentImageIndexInBuffer<0)fJ.output(n,"No image in Buffer");else{var o=n.__getViewerElementForViewer(n,!0);Ll(i,o);n._defaultDSScanClient.getSkewAngleFromBinaryAsync(n.currentImageIndexInBuffer,t,(function(e){r(e[0]),Bl(i)}),(function(){Bl(i)}))}}},{key:"__rotate",value:(S=n(g().mark((function O(e,t,r){var n;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return es(this._defaultDSScanClient),i.next=4,this._makeSureDefaultServiceInfo();case 4:if(this._defaultDSScanClient){i.next=6;break}throw{code:-2825,message:"Failed to setup the Default Dynamic Web TWAIN Service."};case 6:return i.next=8,this._defaultDSScanClient.rotate(e,t,r,-1);case 8:return n=i.sent,i.abrupt("return",n);case 10:case"end":return i.stop()}}),O,this)}))),function(e,t,r){return S.apply(this,arguments)})},{key:"__crop",value:(y=n(g().mark((function M(e,t){var r;return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return es(this._defaultDSScanClient),n.next=4,this._makeSureDefaultServiceInfo();case 4:if(this._defaultDSScanClient){n.next=6;break}throw{code:-2825,message:"Failed to setup the Default Dynamic Web TWAIN Service."};case 6:return n.next=8,this._defaultDSScanClient.crop(e,t);case 8:return r=n.sent,n.abrupt("return",r);case 10:case"end":return n.stop()}}),M,this)}))),function(e,t){return y.apply(this,arguments)})},{key:"__fireEvent",value:function(e,t){return!Zt.isFunction(this[e])||this[e](t)}},{key:"getDevices",value:(_=n(g().mark((function L(e){var t,r,n,i,o,a,s,u,c,l,d,f,h,m,p,v,_,y,S,I,b,T,C;return g().wrap((function(g){for(;;)switch(g.prev=g.next){case 0:if(!this._bDispose){g.next=4;break}throw cs(r={}),Gs(r);case 4:if(n=[],i="getDevices",o=this.getViewerElement(),a=!1,u=null==e?void 0:e.serviceInfo,c=null!==(t=null==e?void 0:e.deviceType)&&void 0!==t?t:Pl,Ll(i,o),g.prev=6,d=!1,f=[],this._serviceInfos){g.next=12;break}return g.next=12,this.getDynamsoftService();case 12:if(!u){g.next=25;break}return g.next=15,this._createDSClientByServiceInfo(u,!0);case 15:if(!(m=g.sent)){g.next=21;break}f.push(m),d=!1,g.next=23;break;case 21:throw bs(null==u||null===(p=u.attrs)||void 0===p?void 0:p.ty);case 23:g.next=37;break;case 25:if(!this._serviceInfos){g.next=37;break}h=0;case 27:if(!(h0)for(s=0;s0)){t.next=8;break}return e=this._serviceInfos[0],t.next=7,this._createDSClientByServiceInfo(e);case 7:return t.abrupt("return",t.sent);case 8:return t.abrupt("return",null);case 9:case"end":return t.stop()}}),H,this)}))),function(){return d.apply(this,arguments)})},{key:"httpUpload",value:(l=n(g().mark((function z(e,t,r,n,i,o){var a,s,u,c;return g().wrap((function(l){for(;;)switch(l.prev=l.next){case 0:if(!this._bDispose){l.next=4;break}return cs(a={}),l.abrupt("return",Qt.Promise.reject(Gs(a)));case 4:return u=this.getViewerElement(),c=u._containerElement,l.next=7,this._makeSureDefaultServiceInfo();case 7:if(this._defaultDSScanClient){l.next=9;break}throw{code:-2825,message:"Failed to setup the Default Dynamic Web TWAIN Service."};case 9:return l.next=11,this._defaultDSScanClient.httpUpload(e,t,r,n,i,o,c);case 11:return s=l.sent,l.abrupt("return",s);case 13:case"end":return l.stop()}}),z,this)}))),function(e,t,r,n,i,o){return l.apply(this,arguments)})},{key:"runCommand",value:function(e){return this._defaultDSScanClient.RunCommandAsync(e)}},{key:"removeImages",value:(c=n(g().mark((function K(e){var t,r,n,i,o;return g().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._bDispose){a.next=4;break}return cs(t={}),a.abrupt("return",Qt.Promise.reject(Gs(t)));case 4:return r="removeImages",i=this.getViewerElement(),Ll(r,i),a.prev=6,a.next=9,this._makeSureDefaultServiceInfo();case 9:if(this._defaultDSScanClient){a.next=11;break}throw{code:-2825,message:"Failed to setup the Default Dynamic Web TWAIN Service."};case 11:if(!this._defaultDSScanClient){a.next=17;break}return a.next=14,this._defaultDSScanClient.removeImages(e);case 14:n=a.sent,a.next=21;break;case 17:if(0!=this.howManyImagesInBuffer){a.next=21;break}if(o={},wG(e,this.howManyImagesInBuffer,o)){a.next=21;break}throw{code:o._errorCode,message:o._errorString};case 21:a.next=26;break;case 23:throw a.prev=23,a.t0=a["catch"](6),a.t0;case 26:return a.prev=26,Bl(r),a.finish(26);case 29:return a.abrupt("return",n);case 30:case"end":return a.stop()}}),K,this,[[6,23,26,29]])}))),function(e){return c.apply(this,arguments)})},{key:"saveImages",value:(u=n(g().mark((function J(e,t,r){var n,i,o,a;return g().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(n={},!this._bDispose){s.next=4;break}return cs(n),s.abrupt("return",Qt.Promise.reject(Gs(n)));case 4:if(0!=this.howManyImagesInBuffer){s.next=7;break}return da(n),s.abrupt("return",Qt.Promise.reject(Gs(n)));case 7:if(Zt.isNumber(r)){s.next=10;break}return Ka(n),s.abrupt("return",Qt.Promise.reject(Gs(n)));case 10:if(r!=Wd.IT_BMP&&r!=Wd.IT_JPG&&r!=Wd.IT_PNG){s.next=16;break}if(!(t.length>1)){s.next=14;break}return na(n,-2623,"Saving multiple images is not allowable when the selected output format is BMP, JPG or PNG."),s.abrupt("return",Qt.Promise.reject(Gs(n)));case 14:s.next=27;break;case 16:if(r!=Wd.IT_TIF&&r!=Wd.IT_PDF){s.next=20;break}s.next=27;break;case 20:if(r!=Wd.IT_ALL&&r!=Wd.IT_MULTIPAGE_PDF&&r!=Wd.IT_MULTIPAGE_TIF){s.next=25;break}return ds(n),s.abrupt("return",Qt.Promise.reject(Gs(n)));case 25:return La(n),s.abrupt("return",Qt.Promise.reject(Gs(n)));case 27:return o=this.getViewerElement(),a=o._containerElement,s.next=30,this._makeSureDefaultServiceInfo();case 30:if(this._defaultDSScanClient){s.next=32;break}throw{code:-2825,message:"Failed to setup the Default Dynamic Web TWAIN Service."};case 32:return s.next=34,this._defaultDSScanClient.saveImages(e,t,r,a);case 34:return i=s.sent,s.abrupt("return",i);case 36:case"end":return s.stop()}}),J,this)}))),function(e,t,r){return u.apply(this,arguments)})},{key:"getImages",value:(a=n(g().mark((function Q(e,t,r){var n,i,o,a;return g().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(n={},!this._bDispose){s.next=4;break}return cs(n),s.abrupt("return",Qt.Promise.reject(Gs(n)));case 4:if(0!=this.howManyImagesInBuffer){s.next=7;break}return da(n),s.abrupt("return",Qt.Promise.reject(Gs(n)));case 7:if(Zt.isNumber(t)&&Zt.isNumber(r)){s.next=10;break}return Ka(n),s.abrupt("return",Qt.Promise.reject(Gs(n)));case 10:return o=this.getViewerElement(),a=o._containerElement,s.next=13,this._makeSureDefaultServiceInfo();case 13:if(this._defaultDSScanClient){s.next=15;break}throw{code:-2825,message:"Failed to setup the Default Dynamic Web TWAIN Service."};case 15:return s.next=17,this._defaultDSScanClient.getImages(e,t,r,a);case 17:return i=s.sent,s.abrupt("return",i);case 19:case"end":return s.stop()}}),Q,this)}))),function(e,t,r){return a.apply(this,arguments)})},{key:"__unload",value:(i=n(g().mark((function q(){var e,t,r,n;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(this._viewer&&this._viewer.unbind(),!this._dsScanClientsMap){i.next=12;break}t=this._dsScanClientsMap,r=Object.keys(t),e=0;case 5:if(!(en.height/2&&(n.borderRadius=Math.round(n.height/2)),Zt.isNumber(n.width)&&n.orientation==AJ.Orientation.Vertical&&n.borderRadius>n.width/2&&(n.borderRadius=Math.round(n.width/2)),n.backColor=t.backColor||"",n.color=t.color||"#50a8e1",n.animationStyle=0,n.animationInterval=t.animationInterval||100;var o=["parent","background","wrapper","left","middle","right","horizontalText","verticalText","marker"];for(n.extraClassName={},i=0;i0&&rr.DWT.AutoLoad)||Qo.bDWTLoading){i.next=46;break}return Qo.bDWTLoading=!0,EJ(),i.prev=20,i.next=23,Az(!0);case 23:r=3,n=0;case 25:if(!(nt.width/2&&(t.borderRadius=t.width):t.orientation==AJ.Orientation.Vertical&&t.borderRadius>t.height/2&&(t.borderRadius=t.height),t.valueElement=document.createElement("DIV"),t.valueElement.className="",t.leftElement=document.createElement("DIV"),t.middleElement=document.createElement("DIV"),t.rightElement=document.createElement("DIV"),t.leftElement.style.border="1px solid #A0A0A0",t.leftElement.style.cssFloat="left",t.leftElement.style.display="inline-block",t.leftElement.style.backgroundColor=t.backColor,t.leftElement.style.backgroundRepeat="no-repeat",t.leftElement.style.position="relative",t.rightElement.style.border="1px solid #A0A0A0",t.rightElement.style.cssFloat="left",t.rightElement.style.display="inline-block",t.rightElement.style.backgroundColor=t.backColor,t.rightElement.style.backgroundRepeat="no-repeat",t.rightElement.style.position="relative",t.middleElement.style.border="1px solid #A0A0A0",t.middleElement.style.cssFloat="left",t.middleElement.style.display="inline-block",t.middleElement.style.overflow="hidden",t.middleElement.style.position="relative",t.valueElement.style.backgroundColor=t.backColor,t.valueElement.style.position="relative",t.orientation==AJ.Orientation.Horizontal?(t.leftElement.style.width=t.borderRadius+"px",t.leftElement.style.height=t.height+"px",t.leftElement.style.top=-t.height+"px",t.leftElement.style.left="0px",t.leftElement.style.borderRight="none",t.leftElement.style.cssText=t.leftElement.style.cssText+AJ._createBorderRadiusCss(t.borderRadius,0,0,t.borderRadius),t.rightElement.style.width=t.borderRadius+"px",t.rightElement.style.height=t.height+"px",t.rightElement.style.top=-t.height+"px",t.rightElement.style.borderLeft="none",t.rightElement.style.cssText=t.rightElement.style.cssText+AJ._createBorderRadiusCss(0,t.borderRadius,t.borderRadius,0),t.middleElement.style.width=Zt.isNumber(t.width)?t.width-2*t.borderRadius+"px":t.width,t.middleElement.style.height=t.height+"px",t.middleElement.style.top=-t.height+"px",t.middleElement.style.borderLeft="none",t.middleElement.style.borderRight="none",t.valueElement.style.width="0px",t.valueElement.style.height=t.height+"px"):t.orientation==AJ.Orientation.Vertical&&(t.leftElement.style.width=Zt.isNumber(t.width)?t.width+"px":t.width,t.leftElement.style.height=t.borderRadius+"px",t.leftElement.style.top=-t.height+"px",t.leftElement.style.left="0px",t.leftElement.style.borderBottom="none",t.leftElement.style.cssText=t.leftElement.style.cssText+AJ._createBorderRadiusCss(t.borderRadius,t.borderRadius,0,0),t.rightElement.style.width=Zt.isNumber(t.width)?t.width+"px":t.width,t.rightElement.style.height=t.borderRadius+"px",t.rightElement.style.top=-t.height+"px",t.rightElement.style.left="0px",t.rightElement.style.borderTop="none",t.rightElement.style.cssText=t.rightElement.style.cssText+AJ._createBorderRadiusCss(0,0,t.borderRadius,t.borderRadius),t.middleElement.style.width=Zt.isNumber(t.width)?t.width+"px":t.width,t.middleElement.style.height=t.height-2*t.borderRadius+"px",t.middleElement.style.top=-t.height+"px",t.middleElement.style.left="0px",t.middleElement.style.borderTop="none",t.middleElement.style.borderBottom="none",t.valueElement.style.width=Zt.isNumber(t.width)?t.width+"px":t.width,t.valueElement.style.height="0px"),t.middleElement.appendChild(t.valueElement),t.parentElement.appendChild(t.leftElement),t.parentElement.appendChild(t.middleElement),t.parentElement.appendChild(t.rightElement),t.orientation==AJ.Orientation.Horizontal?t.borderWidth={left:AJ._parseInt(AJ._elementCurrentStyle(t.leftElement,"border-left-width")),right:AJ._parseInt(AJ._elementCurrentStyle(t.rightElement,"border-right-width")),top:AJ._parseInt(AJ._elementCurrentStyle(t.middleElement,"border-top-width")),bottom:AJ._parseInt(AJ._elementCurrentStyle(t.middleElement,"border-bottom-width"))}:t.orientation==AJ.Orientation.Vertical&&(t.borderWidth={left:AJ._parseInt(AJ._elementCurrentStyle(t.middleElement,"border-left-width")),right:AJ._parseInt(AJ._elementCurrentStyle(t.middleElement,"border-right-width")),top:AJ._parseInt(AJ._elementCurrentStyle(t.leftElement,"border-top-width")),bottom:AJ._parseInt(AJ._elementCurrentStyle(t.rightElement,"border-bottom-width"))})),Zt.isNumber(t.width)&&(t.parentElement.style.width=t.width+t.borderWidth.left+t.borderWidth.right+"px"),t.parentElement.style.height=t.height+t.borderWidth.top+t.borderWidth.bottom+"px",t.backgroundElement.style.cssFloat="left",t.backgroundElement.style.display="inline-block",Zt.isNumber(t.width)&&(t.backgroundElement.style.width=t.width+t.borderWidth.left+t.borderWidth.right+"px"),t.backgroundElement.style.height=t.height+"px",t.backgroundElement.style.backgroundColor="#FFFFFF",t.backgroundElement.style.position="relative",0==t.displayType&&Zt.isNumber(t.width)&&(t.backgroundElement.style.width=t.width+t.borderWidth.left+t.borderWidth.right+"px"),t.backgroundElement.style.top=t.borderWidth.top+"px",t.markerElement=document.createElement("DIV"),t.markerElement.style.display="inline-block",t.markerElement.style.zoom="1.0",t.markerElement.style.width=Zt.isNumber(t.width)?t.width+"px":t.width,t.markerElement.style.height=t.height+"px",t.markerElement.style.top=2*-t.height-t.borderWidth.top+"px",t.markerElement.style.left=t.borderWidth.left+"px",t.markerElement.style.backgroundColor=t.color,t.markerElement.style.lineHeight=t.height+"px",t.markerElement.style.position="relative",t.parentElement.appendChild(t.markerElement),t.isLoaded=!0,t.setValue(t.initialValue),null!=t.onLoad&&t.onLoad()},AJ.prototype.setValue=function(e){var t=this;if(null!==e&&et.maxValue&&(e=t.maxValue),null===e||(t.value=e),t.isLoaded){var r,n=0,i=t.width;if(Zt.isString(i)){var o=ci.one(".dynamsoft-progressBar");o&&o.getEL()&&(i=o.getEL().offsetWidth)}if(t.orientation==AJ.Orientation.Horizontal){n=t.value/t.maxValue*i,t.progressPosition=n,0==t.displayType||1==t.displayType&&(t.direction==AJ.Direction.LeftToRight?n<=t.borderRadius?t.valueElement.style.width="0px":n>=i-t.borderRadius?t.valueElement.style.width=t.middleElement.style.width:t.valueElement.style.width=n-t.borderRadius+"px":n<=t.borderRadius?t.valueElement.style.width="0px":n>=i-t.borderRadius?(t.valueElement.style.left="0px",t.valueElement.style.width=t.middleElement.style.width):(t.valueElement.style.left=i-n-t.borderRadius+"px",t.valueElement.style.width=n-t.borderRadius+"px")),n>0?(t.animationStyle!=AJ.AnimationStyle.StaticFull&&t.animationStyle!=AJ.AnimationStyle.CustomFull?t.markerElement.style.width=n+"px":t.markerElement.style.width=i+"px",t.markerElement.style.visibility="visible"):(t.markerElement.style.width=i+"px",t.animationStyle!=AJ.AnimationStyle.StaticFull&&t.animationStyle!=AJ.AnimationStyle.CustomFull&&(t.markerElement.style.visibility="hidden")),t.animationStyle!=AJ.AnimationStyle.StaticFull&&t.animationStyle!=AJ.AnimationStyle.CustomFull?t.direction==AJ.Direction.LeftToRight?t.markerElement.style.left=t.borderWidth.left+"px":t.markerElement.style.left=i-n+t.borderWidth.left+"px":t.markerElement.style.left=t.borderWidth.left+"px";var a=2*-t.height-t.borderWidth.top;if(0==n||i==n)t.markerElement.style.top=a+"px",t.markerElement.style.height=t.height+"px",t.markerElement.style.cssText=t.markerElement.style.cssText+AJ._createBorderRadiusCss(t.borderRadius);else if(n=t.height-t.borderRadius?t.valueElement.style.height=t.middleElement.style.height:t.valueElement.style.height=n-t.borderRadius+"px":n<=t.borderRadius?t.valueElement.style.height="0px":n>=t.height-t.borderRadius?(t.valueElement.style.top="0px",t.valueElement.style.height=t.middleElement.style.height):(t.valueElement.style.top=t.height-n-t.borderRadius+"px",t.valueElement.style.height=n+2*t.borderRadius+"px")),n>0?(t.animationStyle!=AJ.AnimationStyle.StaticFull&&t.animationStyle!=AJ.AnimationStyle.CustomFull?t.markerElement.style.height=n+"px":(t.markerElement.style.height=t.height+"px",t.markerElement.style.cssText=t.markerElement.style.cssText+AJ._createBorderRadiusCss(t.borderRadius)),t.markerElement.style.visibility="visible"):(t.markerElement.style.height="0px",t.animationStyle!=AJ.AnimationStyle.StaticFull&&t.animationStyle!=AJ.AnimationStyle.CustomFull&&(t.markerElement.style.visibility="hidden"));var c=t.borderWidth.left;if(0==n||t.height==n)t.markerElement.style.left=c+"px",t.markerElement.style.width=i+"px",t.markerElement.style.cssText=t.markerElement.style.cssText+AJ._createBorderRadiusCss(t.borderRadius);else if(ni&&(l=i);var d=c+i/2-l/2;t.markerElement.style.left=d+"px",t.markerElement.style.width=l+"px",t.direction==AJ.Direction.BottomToTop?t.markerElement.style.cssText=t.markerElement.style.cssText+AJ._createBorderRadiusCss(0,0,t.borderRadius,t.borderRadius):t.markerElement.style.cssText=t.markerElement.style.cssText+AJ._createBorderRadiusCss(t.borderRadius,t.borderRadius,0,0)}else t.height-n
'),r.push('

'),r.push('

0%

'),de.bIE?r.push('
'):r.push(''),r.push('
'),r.push("
"),(t=ci.one(".dynamsoft-dwt-dialogProgress"))&&t.getEL()&&t.remove();var n=Qt.parseHTML(r.join(""));if(n&&n.length>0&&document.body.appendChild(n[0]),de.bIE){var i=ci.one(".dynamsoft-progressBar"),o=i&&i.getEL();o&&(o.objProgressBar=new AJ(o,{height:20}));var a=ci.one(".ds-dwt-progressWrap").getEL();a&&(a.style.boxSizing="content-box")}(t=ci.one(".dynamsoft-dwt-dialogProgress"))&&t.getEL()&&(Qt.dlgProgress=t[0],ci.dialog.setup(Qt.dlgProgress)),Qt.dlgRef=0,Qt.dialogShowStatus=!1,Qt.cancelFrom=sG.Other}},Qt.showProgressMsg=function(){};var DJ=function(e){function t(){return o(this,t),i(this,t,arguments)}return f(t,e),s(t)}(xJ);Qt.progressContext=new DJ;var FJ=function(){var e=Qt.progressContext;if(e){var t,r=e.fire("cancel");if(r>=1)for(t=0;t0)Qt.dlgRef++;else{var o;if((n=rr.DWT.IfConfineMaskWithinTheViewer)?i._isNoViewer&&i._isNoViewer()?o=document.body:i._containerElement?o=i._containerElement:rr.DWT.Containers&&rr.DWT.Containers.length>0&&rr.DWT.Containers[0].ContainerId&&(o=Zt.get(rr.DWT.Containers[0].ContainerId))||(o=document.body):o=document.body,o&&o!==document.body){var a=!1,s=o.firstElementChild;if(s&&s!==Qt.dlgProgress&&"dvs-root dvs-web-viewer"==s.className&&(o=s,a=!0),0==a)for(var u=0;u30&&(i=i.substring(0,30)+"..."),l&&(l.show&&l.show(),l.html(i))):l&&l.hide&&l.hide(),(n||0===n)&&(u&&u.getEL()&&u.html(n+"%"),s&&s.getEL())){var g=n;g>99&&(g=99),de.bIE?s[0].objProgressBar?s[0].objProgressBar.setValue(g):s[0].value=g:de.bEdge?(s[0].style.display="",s[0].value=g):s[0].value=g}Qt.dlgRef<=0&&setTimeout((function(){s&&s.getEL()&&(de.bIE?s[0].objProgressBar?s[0].objProgressBar.setValue(0):s[0].value=0:de.bEdge?(s[0].style.display="none",s[0].value=0):s[0].value=0)}),1e3)},(Qt.__ver||0)<$t&&(Zt.mix(Qt,ci),Qt.__ver=$t),Qt.bNode=tr,Qt._defaultAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",Qt._defaultPlatform="Win64",Qt.timestamp="?t=20250331150258",Zt.mix(Qt,li),Qt.ajax=Vi,Qt.fetch=Ns,Qt.detect.showMask=cl,Qt.detect.hideMask=ll,Qt.env=Lo,Qt.product=Qo,Qt.scannerInfo=qo,Qt.License=Ac,Qt.BIO=nl,Qt.UI.ImageUIView=gH,Qt.UI.ImageManager=mH,rr.MSG=ul,Qt.domReady=kH,function XJ(){if(!window||document&&document.body){var e=document;if(e.readyState!==TH)if(CH(window,bH,EH),yH){var t=function(){wH(e,SH,t),EH()};CH(e,SH,t)}else{var r,n,i,o=function(){e.readyState===TH&&(wH(e,IH,o),EH())};CH(e,IH,o),n=e&&e.documentElement,i=n&&n.doScroll;try{r=null===window.frameElement}catch(jj){r=!1}if(i&&r){var a=function(){try{i("left"),setTimeout(EH,30)}catch(e){setTimeout(a,40)}};a()}}else EH()}else setTimeout(XJ,100)}(),kH((function(){if(rr.DWT.CustomizableDisplayInfo||(rr.DWT.CustomizableDisplayInfo=oH),de.bIE){rr.DWT.CustomizableDisplayInfo.loaderBarSourceIE||(rr.DWT.CustomizableDisplayInfo.loaderBarSourceIE=iH.loaderBarSourceIE);try{document.execCommand("BackgroundImageCache",!1,!0)}catch(jj){}}})),rr.Ready=function(e){if(!rr.navInfo)return pH().then((function(t){rr.navInfo=t;try{e()}catch(jj){throw Zt.log(jj.stack||jj,"error"),jj}}));try{e()}catch(jj){throw Zt.log(jj.stack||jj,"error"),jj}}}({mapPackageRegister:null,CoreModule:null}); - -} diff --git a/samples/dwt-mrz/Resources/dynamsoft.webtwain.install.js b/samples/dwt-mrz/Resources/dynamsoft.webtwain.install.js deleted file mode 100644 index d3d30e0..0000000 --- a/samples/dwt-mrz/Resources/dynamsoft.webtwain.install.js +++ /dev/null @@ -1,592 +0,0 @@ -/*! 20240828181423453 -* Dynamsoft JavaScript Library -* Product: Dynamic Web TWAIN -* Web Site: https://www.dynamsoft.com -* -* Copyright 2025, Dynamsoft Corporation -* Author: Dynamsoft Support Team -* Version: 19.0 -*/ - -//Dynamsoft.On{actionName} It is a callback function called by Web-TWAIN product. The contents of this function are the default templates of the WebTWAIN. Users can modify the fucntions, but be aware that the function name itself cannot be modified -//Dynamsoft._{functionName} It is a private function used by Dynamsoft.On{actionName}. Users can modify and delete according to their needs. -(function () { - "use strict"; - var promptDlgWidth = 620; - - if(Dynamsoft.navInfoSync.bMobile) { - if(screen.width<620) { - promptDlgWidth = screen.width - 10; - } - } - - //----------------------start Install Dialog--------------------------- - - //Web TWAIN Service is not detected dialogs - //Windows - Dynamsoft.OnWebTwainNotFoundOnWindowsCallback = function (ProductName, InstallerUrl, bHTML5, bIE, bSafari, bSSL, strIEVersion) { - var _this = Dynamsoft, - objUrl = { - 'default': InstallerUrl - }; - _this._show_install_dialog(ProductName, objUrl, bHTML5, Dynamsoft.DWT.EnumDWT_PlatformType.enumWindow, bIE, bSafari, bSSL, strIEVersion, false); - }; - - //Linux - Dynamsoft.OnWebTwainNotFoundOnLinuxCallback = function (ProductName, strDebUrl, strRpmUrl, bHTML5, bIE, bSafari, bSSL, strIEVersion, iPlatform) { - var _this = Dynamsoft, - objUrl = { - 'default': strDebUrl, - 'deb': strDebUrl, - 'rpm': strRpmUrl - }; - if (!iPlatform) iPlatform = Dynamsoft.DWT.EnumDWT_PlatformType.enumLinux; - _this._show_install_dialog(ProductName, objUrl, bHTML5, iPlatform, bIE, bSafari, bSSL, strIEVersion, false); - }; - - //MacOS - Dynamsoft.OnWebTwainNotFoundOnMacCallback = function (ProductName, InstallerUrl, bHTML5, bIE, bSafari, bSSL, strIEVersion) { - var _this = Dynamsoft, - objUrl = { - 'default': InstallerUrl - }; - _this._show_install_dialog(ProductName, objUrl, bHTML5, Dynamsoft.DWT.EnumDWT_PlatformType.enumMac, bIE, bSafari, bSSL, strIEVersion, false); - }; - - //Android - Dynamsoft.OnWebTwainNotFoundOnAndroidCallback = function (ProductName, InstallerUrl, bSSL, bUpgrade) { - var ObjString = "Starting from version 19.0, Android platform is no longer supported."; - - Dynamsoft.DWT.ShowMessage(ObjString, { - width: 480, - headerStyle: 2 - }); - }; - - //Web TWAIN Service is not supported dialogs - //Mobile Browsers - Dynamsoft.OnMobileNotSupportCallback = function () { - var ObjString = []; - - if (Dynamsoft.DWT) { - - ObjString.push('
'); - ObjString.push('Service Mode does not support your Operating System, please contact the site administrator.'); - ObjString.push('
'); - - Dynamsoft.DWT.ShowMessage(ObjString.join(''), { - width: 335, - headerStyle: 1, - backgroundStyle: 1 - }); - } else { - console.log("The Dynamsoft namespace is missing"); - } - - }; - - //Error Message - HTTPS is required to allow CORS to function. This error appears when HTTP is detected. (See: https://www.dynamsoft.com/web-twain/docs/faq/http-insecure-websites-in-chromium-browser.html?ver=latest) - Dynamsoft.OnHTTPCorsError = function (msg) { - - var ObjString = [ - "
", msg, "
", - '
To fix the issue, please update your website to HTTPS or refer to
this article for other workarounds.
' - ].join(''); - - Dynamsoft.DWT.ShowMessage(ObjString, { - width: promptDlgWidth, - headerStyle: 2 - }); - }; - - Dynamsoft._show_install_dialog = function (ProductName, objInstallerUrl, bHTML5, iPlatform, bIE, bSafari, bSSL, strIEVersion, bNeedUpgrade) { - var _this = Dynamsoft, - ObjString, title, browserActionNeeded, - EnumPlatform = Dynamsoft.DWT.EnumDWT_PlatformType, - bUnix = (iPlatform == EnumPlatform.enumLinux || iPlatform == EnumPlatform.enumEmbed || - iPlatform == EnumPlatform.enumChromeOS || iPlatform == EnumPlatform.enumHarmonyOS), - imagesInBase64 = { - icn_download: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAABHNCSVQICAgIfAhkiAAABqxJREFUaEPlm01y2zYUxwHJe6cniHMCU7K7tnoCK8uuYp+gzglsn8DOCapuuo1ygsjr2hKz6jLKtpvY61pA/g8ARZDiBwiCnMyYM5omKQnih/fw8L7I2Qu7eNe8o9GvJ/QOKUU0GPBX+s9swrl8ZIzH9Hch5JrzwVrK/59iXF3OKThwFEUHjA1PBgM21WAa0vWSkuDZQgg+Z+z5DvxYmHBXMOAoOnoHuAtMNrKnB4AvkOQjJArJcTV5IdgCcn4Fiat7cQ8WieMnDzDG6yyenAP+Qxzf45n2V2tggE4BeYOJYsL6AsAn/CAhsYCE1k2mCQ2B6g8mUvIzjHmYjskWUj6/b6vy3sBRdAx1ZZf4TQzkN0BexfFy1gSw6l6wQwv2LrCE+PF9s5wzITbXTRcyeY8X8Hh8fIMBMAmF+gSjcxESNL8IKTi7NIv7iMWFtJsvbiNg/eLhn1jtqZnUtRDPt6ENS5nUySByPryFqp+ae66Wy/vrJhrlDKxftvdRGyWSKp+GMiRNJkz3jsdjaNeAtIw0jFSc9raTNXcCJkOClf1MRwxZXSk3Z22NR1PIXTU/muLog73g+zj+Yhi031yga4GNGq00LLvDwJCs22q2hap73ghiTkcZQa9W96O6ZyqBac9CjSFZFhEsBlQW+We6jF1ZaysuZ8vlw3nV/CqBx+Ojj2SgjBpPfhbJFlhxnN3DhYYW75fL5W0ZdCkwYPEQ/0MbqA3BdurjttWaKBqfwWHBCaJ887dx/ADHZ/cqBCanAgbhs36YwRiEcevaQtU9D//gCvdcQiNxTm/eFGlkIfBodEz7lvbrNc45GiToNRodxRQgYL8Z5yXc8Jj7AmNThFY49x1g8o3h1GPvKlU+6GLfQhKSELGYtadE06VItNNIeZR3QXdeiNX/SoGAEOLcx3VzmWCXwPR+MMzA8A7Qf61WD2f2nDLAycbHjd9w44HL5H3u6RqYfAcEHV+1DXqmvbxO5pkBhv7DwWBRl9KlF3cNbEsZW/ODbSu2wPaqdLG3bE3oAzjdy1kPzALW5xgF71DnJBry0djaZ/oA1pp0RHmzfVutt8DY6OSTnnatzn2pdFatU+/LBv5OAUJ+k9eKy+OGviRsGeGt1ipg6+z6AnXOJOE8eGof6Q9YpYi+22d+DrifiKgv4KLto4DTDELWhNeKyvOGPoG1G8sPsVXJ64oNsHa68evEd86vS7/A2rdOgqCXCZxEGH2Fgn1KOAkZE+1VEk7P4PLA2XO7Fj7WL3CSyNBn8ctU6bzYfaSpffHhjSmDVKaDXCWsHQd+UpeYq5pvfruac3jrR+/Ej67wydFmAm/KEZdCuwBnc1T6SHGdi31fGt/rMDGo42EF3pRTKoWuA87CtktE5N9lgKlEubeiYjRcyzc+K5k84wJdBRwSNg155RO2hSrM28EDKu/8deKRdAldBhwS1vYg7VSPDazyQHWJbNeFqJJ0EXBo2Oxxm24LKwGgs5WuNRoX8DLoPHAXsKamrCIlaO0vSfbVTvFsQyn7Bhew6mNhm0HcGjIbuAtYmk+SbqYykR3y5pJ4OusROojIS5oMpF55cZ6WR9pZ4/yip8WEbK0pl6bVJZaqUoWvxG1ojKEtJsKYBDxkDjwtFe0WEwoS8dWlCl9gY0SUYYRkGSTbCax+T3mpqKDUos9ks9kzSew2sNY5/Tegf+9Csnrvbr1GdBVtonypqKSYpg0NkthzHNhvQ4DaY4xG4/+wbf6N45VqSwx16QL+kLoVSktFhcAmEKDOudoCc6jJhhjHLuCXJSNLq3euBeYQEw0xhmsBvxSYJpErMFdGQCEm7TtGVjjVBfxKYNuyNmkN8p24z3N2S5VL1aQW2BgCZP74oUus6zNp32dsyRbVgovGrQXWpl5ZPwvar8/RF6zoObvf0xWWxnECts5Qc1ypf2nc5xgCON/v6aLG9nsbAWtDlvY5Yl+jh5mhlbefLh/dhM6udG+2X79nY2Ct4mmfo1491eDp3cNcJ/mC3mzvfk8v4GRfFzVvSzmYrVb/3NVB1P1/Ul3G9k4gUfqsYKKWFb0nbZvQvYGTCZvmU1IzuKJG3mgMwyTxrQJ927D55Nr6ZD4QOUVcAcBtTzahPuHvtyF6s1sD2+DIS19gT+MbiPyHGurTHUqzqp5makrDf6g719Si1ccd2JfZi4J3fByC7SJmrotWpznBgO0XaV98gKZUTp/xJN3rdXNRksQizAGKBRHzUJD2izsBLiIjjwh7UgX+WmXFoxADk1x/Xvt+tOGwiplbegNuOrGu7v8BEbL8eSr8LDEAAAAASUVORK5CYII=', - icn_install: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAABHNCSVQICAgIfAhkiAAAB51JREFUaEPtW91V20gU1sje5yQVhK0AY3iPUwGkgiUVhFQQqCBQQZwKAhXEvIPtrSDeCgLPizX7ffPjGY1lz0iWDQ+rc3zg6Gd0v/s/916JbItHr3d0nOdZj6+QMhuYV70WYnFuinMPPI9zI/4timw6nd7dbIss0ebCvV5vL8s67wDyBBDw2+SQ1wB/nWXzW3BgtslK/rOtAIYkB5DQF/ysFNU7pJR/CyFAtJKckmCWPT0AACWbgUGQfvc1/weT1LN45gTP7PtEQjtG+F1A8maN5vA3ArwMVD5q4iRAFtfApdS17gE+gAk5geNHRohXmhlc++mzZVjddXl/I8BU3TzvfMHjp/ql8hH/X47Hd+dNiIg90+8fYV15ZoHj/2FRzCHx+qpeG3Cvd0iufwP3IQUNtCieLptKMwbWXqfU87wL0BkYrVT/ARL/OJ3eK5NJPWoBBthPeS4uzQtvpJyfNeFyKnFV91G7hOhcguHHvF4UEjTcX6WumQy43z/85lS4+DwejxXw5zr6/T6knX81JjUcj+8/ptASBUxVEqL7U8dO+Qhve1pXjVIIaXIPzQvefUjbhnpP4dDex0xrLWAfLGzmH6jwySYesgmo2DMMbVDxa6j4W4KeTO4O1j2zFrBVYwO2F+NejLhtXdeC6UwJmh58nXqvBOxshGo8H7w0yYbMo6QRKkc6dK32MZWAtW2IH8YLfngpNhvTkBS6lwAbtz/RcXb33thmb1BN2CZpsBmWHILx32OgrWbqOD0/CMPmEuCDg8MhXvQXHriZTO433ADEyHPXdWLRYehb+U7E3CRtAwY6sWNg+A4Mpz4VJcDkLtz8Tx1+5nRSs3SSm98Zhj68/7woCmZQDzYkciMCidGXRPNznfp2f2mTfKKU1WaFRwnwwcER4+0A5y+2lRdXscXTKoJi6JsFIXEBlnaKNd7Gsiudf2dfuOFAqHq/BDiQ7l4KJ5vLtKTKldIA8+FHsp4v2V6vf5rnOdR+WXIhLcZEoKHiFZIlJCR6a7mQ8HNJ10mibG84Lw2wN2S+D5bnq+wzBF0lZQXY6bx8RNBWnnFXh1XnMCJYwDAt4YM1RYV9qOotVJXmt/ZA8gSbp5Sf/qSpGMBaVXbtmUmpBQwnha3eeGipt4B9NJSqlGJIx5qSRpr1lce26yvA1o2HL41xr43rVu2wVslRwsRGsOF37h3yCtp3ZpMLShohBxua9YfVDitMBTi0l9gibV03iT8iQ3qSAxVFBshYnZYUmcLBb9JM84B96DQylWPbAJvigPheZ8sqT0iOJNBgbiz2mbiIVSrVFrCqdXzJpoIFnSztnHO9uqbnY/QAp6nIpoyIgXUpJt8kkCFJxOKMefVeE7DGZMkoMuxCWOfgB+dNQa16PgWsq66EqzTfptqkiqFsZ4DrgNXZlbxEqNyD+s6gxKNN8voA8OEvqosNzNuQbn2waZuEVFp1caA7YeymDasUji47dYE69z03WEurxblVwC8FrHFcSrCw4cMZi19tq/RLAutUGs29Nrw0Nx+mTToAE7H5EKgRyzNmUFVxdtVet46p1Lm3VS8N22D1nz2fpeMlgCVRJcDITdEyEZ9Sc1OLKqxBMTkXQo6KQsx0r1c8hFWTXUvWc1gu8WiaWrokPi0heC6wxmE5wG7zEG9TOOnaunVase85wZJmWy5SmwffZcNTq3JKzCHY/XOqGXhl0+TKY4yG1OtL20PNAV3HTd2F+PtnFdsW3UVNRlgpdJEgra6cCiblvsoCQHgytpAPeFWy72duTf1EjI6U66EwS0U8tidQNnkTW8gCVrlpUEqtSlWbRoIYHSnXAfg384FSEc8Ytq0hRYvwzob1aJLtCPjVRV/CuN9sUFx9OIXYTe/xyrSLCudiw+CCs2pCsaS50nl5JlAJFmxQBTftEPVoAnvM0J69TUGkPq8jQ4eMhnQrCvF1pUwgcHLo6JWL5H52Ve4U7NZhVUlXOVifY16SXdlqrOKua9Eo78w5iw+YrtuHbSOX1tN1qd4/VXqx+5KbaVrKul0K8q+hliB+/VGepgnvZWLCsSJXYI+t18Z1mwVG26V8meZOB8Wz9aMDZc3grKU8xTOYoWLRTcB7FxgO1SrfBojUNYJRjaWW7/8jD5aTwegA558WTeVUbu/yvtQuxto6lteonpl5iZ2qZyrDTAjiXMperLAfLdzZNgUWImjMWLwsSRvJ/jBgow22KGDDPWRhAj3ZZhOsqZKqe58/2Zs6AxIFbIlw4ar+BGtdICn3B5O9S9M6q9ZIBswFgglWhJ05p9NnKQS2dY8Jm6ij2fGmej2xWoB1nHYTrAYERoyerrYdb81GHrU33UFsOtlbG7BNTpCYn+uMTE+n439+AnDRliT9ddgqtWVf8z6MPszPm2hXI8CWGO0hu5hO16MJGniGyqX6/OamqdQpTdS5+c3TCb938kYQb5GrI1VtHik2AuyAq894IHF/JkNvJnBOfZOAdHOk//77aAnWDPtDfbGClHSgr2f8pqI0u8E2J36Q6DN/xhOqr+5A5JQIP8FR3yQ0PVjnxg/M2qxVGr6/FQmvAmVKwEpa7lM8iY25/hCLsZMFey1h+ymehALU+1KlDlP/Axl/TQ2HYDZNAAAAAElFTkSuQmCC', - icn_scan: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAABHNCSVQICAgIfAhkiAAACBBJREFUaEPNW7tuG0cU3VkynQHbVdJF/gJTtLsEsIw06SQB7i0XqW1/gekuqSL3AUx/gaUvMAUknUXRboRUpj8gsNQEBkLu5Jx57ItLzswO9ViAEMXdmbln7p37XpFc4NXr3d9O06THJaRMtsxSt4TIf5vgtzP+jt9G/JtlyWQyeX94UWSJdU7c6/U2kqTzACB3AAGfmEseAPxBksyPsAPTmJnKY9cCGJzcAode4GO5qNaQUn4QQoBoxTnFwSSZnQEAOZtgg8D97i1+xyapsRizgzF3y0RCOkb4vATnzRzt4UcBXgQqzzVxEiCzA+BS4hp6YR+wCSmB48ONEDf1ZnDu2XO7YaHz8vlWgCm6adp5geF7elF5ju/74/H7QRsiXGP6/fuYVz6zwPF9mGVzcDxc1IMB93r3uOuvsfvgggaaZbP9ttx0gbX3yfU07QJ0go1Won8Gjj+ZTI7VkfG9ggAD7NM0FftmwUMp58/a7LIvcU3PUbqE6Oxjw7d5P8skaDh+5TunN+B+/97rQoSz5+PxWAG/qqvf74Pb6e/mSA3H4+MnPrQ4AVOUhOi+07ZTnkPb7oWKkQ8hbZ7h8YJ2H/JsQ7wnUGgPXUdrJeAyWJyZzxDhnRgN2QaUawxNG0T8ACL+PUGfnLzfXDVmJWArxgZsz7V7LuIu6r5mTGdC0NTgq8R7KeDijFCM51vXjbP1zSOnYSpH2nQt1zGNgPXZEG+NFty9LmfWJSE+dC8ANmr/RNvZMG1sRItjN1zE2fs4LvmjUIzwn+ewre08NE5kJVPb6flm3WwuAN7cvDcEwY8x4PDk5DgoAKCrCa35zhds03O+2nbVGsBAJbYNDG+AYa/8bAVwQbA6t1RS0xDi7XgQfQRtueUzVruNyQsQ9xv+/szAIRa0dn27n/SRnJHLKljhVQG8uXmf9paEvmzjF8cA5pp0UaFtR+sAXWxkMsLmP1wAXOPuRptzFAuYm2z0QA7aZVeXSZH2vTuQUHETzhIcEh1a5hyO5S4niwMsh1KmQ84jZXYDkvYHvn4npciJ9Tki5WeauKwAFzIvz2G0VUDe5tK2sHsSdobLPvHiqrPZ7JePHycE3+qC84SYnFye3aFOMoD7e2mavm6jmetUYAGEi8nI13YbMzgAURvVuSQ3/sbXr//+dHp6+rkVWgyyGjvLMpi78VABrv/oM7nOSnSZv1JJusu6mORDmuiDrwXp9arMVIAh68r6g+23fZRVNQlwWVCLdbRTIZHqGQ9dq5vEwRc+B6UohHXHmHCDkfbiFiTiE70pBhX0jiCOrXJXLmIX78tb0A/MdSEyUp4Uz6VzbdDLwOIukgW7wmoyTO5le61iYmxMBWcU3mMjIW98RS0cbDECAKYEXTY3q+YrYywB9vOby6YHATd2u0NuK80esusxgKkYIVVPfX39CmDYXxj55IHvblUBZ0Ot3ZMjwEWuyX/X4wBrd9RfKrWPTzpFHGC5zzCSnCUAcrruu8YAWzY2/BhWAGsFZA2zi8C6N2WjKz1OvsK5Zir1Qq9wwLlDNOEZViaJKtuHyib3UdeUElbBpj5zxD4TCpjrWZxrARwLIHR8FOBCxWtf07W4K0AwGQdVC4q9YDdReFtMsocCLnx8FPdilFY9yC9sdCzUYnyT9QgHvCYtvQjYTkwPTAxjYEPz7y0zc1GAQ414IdJyClf0ThmUS9xDNmCV5OEeEoVJz9d3WOJp+bmWWuPpGFOXLQUTZsoOI3BHPMxqovwLZ+9HXRX4Jug8S/nfOXNQ8PH/xFw/sFgmRKpyUuA6shgSiUVdpvU1pRXARfDgLlNYDpUmqDCNGVfsPAn7B5mKR20zmIxdUSj7FeO/tXMuSoe/zS8kAsFD2Ub5hocco8VX7gBYHmFpDqio5G/0ZiAD2aHPG5hBUVEQuKrqRZyLbRN5RCSEnAQmGFhXLsJDEt8mAdB0Hi/rDIfogsYEQP3HkAmvQmmF0NeY4rFJPAYB0Ly3QyZcBhihI8USee4wkdYhptiFLhiERHHLaAbgLyaoKZJ4Wqx1mIivXokAl0gTcFHNC9lCVj1U90404FKaNq+E5AFDyb56p07qMK7TGTYJfZWcaEzEr4PL1wlwE3eJsVZMs3Fjc6nRJZjXBbB3Mc2YKFUuhftwgGB+1wWyqrR01Q6KZwrHYS9k7OKzGelgYqJS/fOZE54givkCPoKjXKodCtVlB1dudevACq2oUqI+hLmeYRoYVmPD9Vz5fq1VY6Hku/aWB71hKXY3DSqm10EJkaEbQPVrQlr8rlYtD3bqWusA+5/yorLf8pf7lGlfMnY/sKnFklpqf5iafglnlv9yYerVyr0lTee2TJMzcWfLFFREAI2OnuvFacPZt6b04ywXOQFXK/LtOlgviuvloh5rY2AI+8lWSqETcF28+X9oB+tFAK519i506yxb0xswJ6h1sLKnit3p3lp0HcCN2UQXrX2nwq8mZtcOAqwVRNHBaiYZwDl45RKlWLCmzosCWjLQc7Xr7A0GbLQim7QRzdAj01VDfOcrAC9jgTWNh1/MPi6Em3mV8g3O66CNdLUCbInSGrKL3ioVVhrgyci8fnPYluu6naLDd57gwCR4Y8YCTY4YdsZYiijABXD1Go+KX8scYked7hDgZoiR/quzkkZS8qwmclVb+j4r/NW+EZY58QFHr/g1nrr46aJaSo6wLUG9k9D2YkcRPtisDB1B61OMa+HwMlDGt1VZzeJVPIlmbh1c0Hba/pDiVTwJfGFvqoRs6v/IOTkNXX2kbQAAAABJRU5ErkJggg==' - }; - - // npm file mode - if (bNeedUpgrade) - title = 'Please update your document scanning service'; //'Please follow the steps below to upgrade your local document scanning service.'; - else - title = 'Please download and install the Dynamic Web TWAIN service'; - ObjString = [ - '
', - title, - '
' - ]; - - if (_this.DWT) { - - var bFirefox = Dynamsoft.navInfoSync.bFirefox; - if (bUnix || bFirefox) { - browserActionNeeded = 'RESTART'; - } else { - browserActionNeeded = 'REFRESH'; - } - ObjString.push('
'); - - var left = '134px'; - - ObjString.push('
'); - - ObjString.push('
'); - - var marginRight = '133px'; - - ObjString.push('download'); - ObjString.push('install'); - ObjString.push('scan'); - ObjString.push('
Download'); - ObjString.push('Install'); - ObjString.push('Scan'); - ObjString.push('
'); - ObjString.push('
'); - - if (bHTML5 && bUnix) { - ObjString.push('
'); - ObjString.push('
'); - - var arm64 = Dynamsoft.navInfo.bArm64, - mips64 = Dynamsoft.navInfo.bMips64, - chromeOS = Dynamsoft.navInfoSync.bChromeOS, - harmonyOS = Dynamsoft.navInfoSync.bHarmonyOS; - - if (arm64 || mips64 || chromeOS || harmonyOS) { } else { - ObjString.push('
'); - ObjString.push('
'); - } - ObjString.push('
'); - } - - ObjString.push(''); - if (bHTML5) { - if (bIE) { - ObjString.push('
'); - ObjString.push('If you still see the dialog after installing the Dynamic Web TWAIN Service, please
'); - ObjString.push('1. Add the website to the zone of trusted sites.
'); - ObjString.push('IE | Tools | Internet Options | Security | Trusted Sites.
'); - ObjString.push('2. Refresh your browser.'); - ObjString.push('
'); - - } else { - - if (bUnix) { - ObjString.push('
'); - ObjString.push('
After the installation, please ' + browserActionNeeded + ' your browser.
'); - ObjString.push('
'); - } else { - ObjString.push('

'); - } - } - - } else { - ObjString.push('
'); - ObjString.push('After the installation, please
'); - ObjString.push('1. Restart the browser
'); - ObjString.push('2. Allow "DynamicWebTWAIN" add-on to run by right clicking on the Information Bar in the browser.'); - ObjString.push('
'); - } - _this.DWT.ShowMessage(ObjString.join(''), { - width: promptDlgWidth, - headerStyle: 1 - }); - } else { - console.log("The Dynamsoft namespace is missing"); - } - - if (Dynamsoft.DWT && Dynamsoft.DWT.OnWebTwainNotFound) { - Dynamsoft.DWT.OnWebTwainNotFound(); - } - }; - - Dynamsoft._dwt_change_install_url = function (url) { - var install = document.getElementById('dwt-btn-install'); - if (install) - install.href = url; - }; - - var reconnectTime = 0; - Dynamsoft._dcp_dwt_onclickDownloadButton = function() { - var install = document.getElementById('dwt-install-url-div'); - if (install) - install.style.display = 'none'; - - var el = document.getElementById('dwt-btn-install'); - if (el) { - if (el.getAttribute("html5") == "1") { - var pel = el.parentNode, - newDiv = document.createElement('div'); - newDiv.id = 'dwt-btn-install'; - newDiv.style.textAlign = "center"; - newDiv.style.paddingBottom = '15px'; - newDiv.style.fontSize = '14px'; - newDiv.innerHTML = 'Please proceed with the installation. Once done, click here to verify completion.'; - newDiv.setAttribute("html5", "1"); - pel.removeChild(el); - pel.appendChild(newDiv); - } else { - var pel = el.parentNode; - pel.removeChild(el); - } - } - return true; - }; - Dynamsoft._dcp_dwt_onclickInstallButton = function () { - var install = document.getElementById('dwt-install-url-div'); - if (install) - install.style.display = 'none'; - - var divTitle = Dynamsoft.Lib.one('.dynamsoft-dwt-dlg-title'); - if (divTitle) { - divTitle.style('display',''); - } - var divTitleErr = Dynamsoft.Lib.one('.dynamsoft-dwt-dlg-title-error'); - if (divTitleErr) { - divTitleErr.style('display','none'); - } - - var el = document.getElementById('dwt-btn-install'); - if (el) { - setTimeout(function () { - if (el.getAttribute("html5") == "1") { - var pel = el.parentNode, - newDiv = document.createElement('div'); - newDiv.id = 'dwt-btn-install'; - newDiv.style.textAlign = "center"; - newDiv.style.paddingBottom = '15px'; - newDiv.style.fontSize = '14px'; - - newDiv.innerHTML = 'Connecting to the service...'; - newDiv.setAttribute("html5", "1"); - pel.removeChild(el); - pel.appendChild(newDiv); - reconnectTime = new Date(); - setTimeout(Dynamsoft._dwt_Reconnect, 10); - } else { - var pel = el.parentNode; - pel.removeChild(el); - } - }, 10); - } - return true; - }; - - Dynamsoft._dwt_Reconnect = function () { - var _this = Dynamsoft; - if (((new Date() - reconnectTime) / 1000) > 10) { - // change prompt - var el = document.getElementById('dwt-btn-install'); - if (el) { - el.innerHTML = 'Please make sure your installation is successful. Click here to try reconnecting.'; - } - - var divTitle = Dynamsoft.Lib.one('.dynamsoft-dwt-dlg-title'); - if (divTitle) { - divTitle.style('display','none'); - } - var divTitleErr = Dynamsoft.Lib.one('.dynamsoft-dwt-dlg-title-error'); - if (divTitleErr) { - divTitleErr.html('Failed to connect to the service!'); - divTitleErr.style('display',''); - } - - return; - } - if (_this.DWT) { - - var _timeSpan = 500; - if (navigator.userAgent.indexOf("Safari") > -1) { - _timeSpan = 2000; - } - - _this.DWT.CheckConnectToTheService(function () { - Dynamsoft.DWT.CloseDialog(); - Dynamsoft.DWT.ConnectToTheService(); - }, function () { - if (Dynamsoft.DWT.NeedCheckWebTwainBySocket()) { - Dynamsoft.DWT.CheckWebTwainBySocket(function () { - Dynamsoft.OnHTTPCorsError(); - }, function () { - setTimeout(Dynamsoft._dwt_Reconnect, _timeSpan); - }, function () { - setTimeout(Dynamsoft._dwt_Reconnect, _timeSpan); - }); - return; - } - setTimeout(Dynamsoft._dwt_Reconnect, _timeSpan); - }); - } else { - console.log("The Dynamsoft namespace is missing"); - } - }; - - Dynamsoft._show_android_install_dialog = function (objInstallerUrl, bUpgrade) { - var ObjString; - - if (Dynamsoft.DWT.bNpm && Dynamsoft.navInfoSync.bFileSystem) { - return Dynamsoft._show_online_download_dialog(objInstallerUrl, bHTML5, iPlatform); - } - - ObjString = []; - - if (Dynamsoft.DWT) { - - ObjString.push('
'); - - ObjString.push('
Please download and '); - - if(bUpgrade) { - ObjString.push('update'); - } else { - ObjString.push('install'); - } - - ObjString.push(' the DYNAMIC WEB TWAIN SERVICE app via the
'); - - ObjString.push(''); - ObjString.push('
'); - - ObjString.push('
'); - ObjString.push('If you have '); - - if(bUpgrade) { - ObjString.push('updated'); - } else { - ObjString.push('installed'); - } - - ObjString.push(' it, please click on the button below to initiate the connection.'); - - ObjString.push('
Open Service
'); - - ObjString.push('
'); - - ObjString.push(''); - - Dynamsoft.DWT.ShowMessage(ObjString.join(''), { - width: 335, - headerStyle: 1, - backgroundStyle: 1 - }); - } else { - console.log("The Dynamsoft namespace is missing"); - } - - if (Dynamsoft.DWT && Dynamsoft.DWT.OnWebTwainNotFound) { - Dynamsoft.DWT.OnWebTwainNotFound(); - } - }; - - Dynamsoft._dwt_ReconnectForAndroid = function () { - Dynamsoft.DWT.CheckConnectToTheService(function (bConnected) { - if (bConnected) { - Dynamsoft.DWT.CloseDialog(); - Dynamsoft.DWT.ConnectToTheService(); - } else { - setTimeout(Dynamsoft._dwt_ReconnectForAndroid, 500); - } - - }, function () { - setTimeout(Dynamsoft._dwt_ReconnectForAndroid, 500); - }); - } - - //Dynamsoft.OnWebTwainNotFoundOnAndroidCallback = Dynamsoft.MobileNotSupportCallback; - //------------------------end Install Dilaog--------------------------- - - - //----------------------start Upgrade Dialog--------------------------- - - Dynamsoft.OnWebTwainNeedUpgradeCallback = function (ProductName, objInstallerUrl, bHTML5, iPlatform, bIE, bSafari, bSSL, strIEVersion) { - Dynamsoft._show_install_dialog(ProductName, objInstallerUrl, bHTML5, iPlatform, bIE, bSafari, bSSL, strIEVersion, true, true); - }; - - Dynamsoft.OnWebTwainNeedUpgradeOnAndroidCallback = function (ProductName, InstallerUrl, bSSL) { - Dynamsoft.OnWebTwainNotFoundOnAndroidCallback(ProductName, InstallerUrl, bSSL, true); - }; - - //----------------------end Upgrade Dialog--------------------------- - - //----------------------start DLS License ----------------------- - Dynamsoft.OnLTSLicenseError = function (message, code) { - - var addMessage = '', - ObjString; - - if (code == -2440 || // NetworkError - code == -2441 || // Timedout - code == -2443 || // CorsError - code == -2446 || // LtsJsLoadError - message.indexOf('Internet connection') > -1 || - message.indexOf('Storage') > -1) { - - var purchaseUrl = 'https://www.dynamsoft.com/customer/license/trialLicense?product=dwt&deploymenttype=js'; - addMessage = '
You can register for a free 30-day trial here. Make sure to select the product Dynamic Web TWAIN.
'; - } - - ObjString = [ - message, - addMessage - ]; - - Dynamsoft.DWT.ShowMessage(ObjString.join(''), { - width: promptDlgWidth, - headerStyle: 2 - }); - }; - - Dynamsoft.OnLTSConnectionWarning = function () { - - var ObjString = [ - 'Warning: You are seeing this dialog because Dynamic Web TWAIN has failed to connect to the License Tracking Server. ', - 'A cached authorization is being used, and you can continue to use the software as usual. ', - 'Please get connected to the network as soon as possible. ', - Dynamsoft.DWT.isPublicLicense() ? 'Contact Dynamsoft ' : 'Contact the site administrator ', - 'for more information.' - ].join(''); - - Dynamsoft.DWT.ShowMessage(ObjString, { - width: promptDlgWidth, - caption: 'Warning', - headerStyle: 2 - }); - }; - - Dynamsoft.OnLTSPublicLicenseWarning = function (message) { - - Dynamsoft.DWT.ShowMessage(message, { - width: promptDlgWidth, - caption: 'Warning', - headerStyle: 2 - }); - }; - - //--------------------end DLS License------------------------------- - - //----------------------start Product Key ----------------------- - Dynamsoft.OnLicenseExpiredWarning = function (strExpiredDate, remain, trial) { - - var ObjString, strCaption, - a_online_store = 'online store', - a_new_key_href = 'https://www.dynamsoft.com/customer/license/trialLicense?product=dwt&utm_source=in-product'; - - if (remain > 5 || !trial) { - - } else { - - if (remain > 0) { // 1~5 - - var strDays; - - if (remain <= 1) { - strDays = '1 day'; - } else { - strDays = parseInt(remain) + ' days'; - } - - strCaption = 'Warning'; - ObjString = [ - '
Kindly note your trial key is expiring in ', strDays, '. Two quick steps to extend your trial:
', - '
1. Request a new trial key and follow the instructions to set the new key
', - '
2. Refresh your scan page and try again
', - '
If you are ready to purchase a full license, please go to the ', a_online_store, '.
' - ].join(''); - - } else { - - // Trial remain<=0 Expired - ObjString = [ - '
Sorry. Your product key has expired on ', strExpiredDate, '. You can purchase a full license at the ', a_online_store, '.
', - '
Or, you can try requesting a new product key at this page.
' - ].join(''); - - } - - if (ObjString) { - Dynamsoft.DWT.ShowMessage(ObjString, { - width: promptDlgWidth, - caption: strCaption, - headerStyle: 2 - }); - } - } - - }; - - Dynamsoft.OnLicenseError = Dynamsoft.OnLicenseError || function (message, errorCode) { - - Dynamsoft.DWT.ShowMessage(Dynamsoft.ProcessLicenseErrorContent(message), { - width: promptDlgWidth, - headerStyle: 2 - }); - - }; - - Dynamsoft.OnCorsConfigError = function (msg) { - - var ObjString = [ - msg, " Please contact the Administrator to configure 'Access-Control-Allow-Origin'.", - ].join(''); - - Dynamsoft.DWT.ShowMessage(ObjString, { - width: promptDlgWidth, - headerStyle: 2 - }); - }; - - Dynamsoft.ProcessLicenseErrorContent = function (content) { - var el = [], - _content = content; - if (typeof(_content) != 'string') { - if (undefined === _content) - return ''; - if (_content instanceof Error || 'message' in _content) - _content = _content.message; - else - _content = '' + _content; - } - - var posLeftBracket = _content.indexOf("["); - var posRightBracket = _content.indexOf("]", posLeftBracket); - var posLeftParentheses = _content.indexOf("(", posRightBracket); - var posRightParentheses = _content.indexOf(")", posLeftParentheses); - if (-1 == posLeftBracket || -1 == posRightBracket || -1 == posLeftParentheses || -1 == posRightParentheses) { - return _content; - } - - if (posLeftBracket > 0) { - el.push(_content.substring(0, posLeftBracket)); - } - - var linkText = _content.substring(posLeftBracket + 1, posRightBracket); - var linkAddr = _content.substring(posLeftParentheses + 1, posRightParentheses); - - el.push(['', linkText, ''].join('')); - el.push(_content.substring(posRightParentheses + 1)); - - return el.join(''); - } - //--------------------end Product Key------------------------------- - - -})(); \ No newline at end of file diff --git a/samples/dwt-mrz/Resources/mrz-template.json b/samples/dwt-mrz/Resources/mrz-template.json deleted file mode 100644 index b2ac8fb..0000000 --- a/samples/dwt-mrz/Resources/mrz-template.json +++ /dev/null @@ -1,257 +0,0 @@ -{ - "CaptureVisionTemplates": [ - { - "Name": "ReadPassportAndId", - "OutputOriginalImage": 1, - "ImageROIProcessingNameArray": ["roi-passport-and-id"], - "SemanticProcessingNameArray": ["sp-passport-and-id"], - "Timeout": 2000 - }, - { - "Name": "ReadPassport", - "OutputOriginalImage": 1, - "ImageROIProcessingNameArray": ["roi-passport"], - "SemanticProcessingNameArray": ["sp-passport"], - "Timeout": 2000 - }, - { - "Name": "ReadId", - "OutputOriginalImage": 1, - "ImageROIProcessingNameArray": ["roi-id"], - "SemanticProcessingNameArray": ["sp-id"], - "Timeout": 2000 - } - ], - "TargetROIDefOptions": [ - { - "Name": "roi-passport-and-id", - "TaskSettingNameArray": ["task-passport-and-id"] - }, - { - "Name": "roi-passport", - "TaskSettingNameArray": ["task-passport"] - }, - { - "Name": "roi-id", - "TaskSettingNameArray": ["task-id"] - } - ], - "TextLineSpecificationOptions": [ - { - "Name": "tls_mrz_passport", - "BaseTextLineSpecificationName": "tls_base", - "StringLengthRange": [44, 44], - "OutputResults": 1, - "ExpectedGroupsCount": 1, - "ConcatResults": 1, - "ConcatSeparator": "\n", - "SubGroups": [ - { - "StringRegExPattern": "(P[A-Z<][A-Z<]{3}[A-Z<]{39}){(44)}", - "StringLengthRange": [44, 44], - "BaseTextLineSpecificationName": "tls_base" - }, - { - "StringRegExPattern": "([A-Z0-9<]{9}[0-9][A-Z<]{3}[0-9]{2}[0-9<]{4}[0-9][MF<][0-9]{2}[(01-12)][(01-31)][0-9][A-Z0-9<]{14}[0-9<][0-9]){(44)}", - "StringLengthRange": [44, 44], - "BaseTextLineSpecificationName": "tls_base" - } - ] - }, - { - "Name": "tls_mrz_id_td2", - "BaseTextLineSpecificationName": "tls_base", - "StringLengthRange": [36, 36], - "OutputResults": 1, - "ExpectedGroupsCount": 1, - "ConcatResults": 1, - "ConcatSeparator": "\n", - "SubGroups": [ - { - "StringRegExPattern": "([ACI][A-Z<][A-Z<]{3}[A-Z<]{31}){(36)}", - "StringLengthRange": [36, 36], - "BaseTextLineSpecificationName": "tls_base" - }, - { - "StringRegExPattern": "([A-Z0-9<]{9}[0-9][A-Z<]{3}[0-9]{2}[0-9<]{4}[0-9][MF<][0-9]{2}[(01-12)][(01-31)][0-9][A-Z0-9<]{8}){(36)}", - "StringLengthRange": [36, 36], - "BaseTextLineSpecificationName": "tls_base" - } - ] - }, - { - "Name": "tls_mrz_id_td1", - "BaseTextLineSpecificationName": "tls_base", - "StringLengthRange": [30, 30], - "OutputResults": 1, - "ExpectedGroupsCount": 1, - "ConcatResults": 1, - "ConcatSeparator": "\n", - "SubGroups": [ - { - "StringRegExPattern": "([ACI][A-Z<][A-Z<]{3}[A-Z0-9<]{9}[0-9<][A-Z0-9<]{15}){(30)}", - "StringLengthRange": [30, 30], - "BaseTextLineSpecificationName": "tls_base" - }, - { - "StringRegExPattern": "([0-9]{2}[(01-12)][(01-31)][0-9][MF<][0-9]{2}[0-9<]{4}[0-9][A-Z<]{3}[A-Z0-9<]{11}[0-9]){(30)}", - "StringLengthRange": [30, 30], - "BaseTextLineSpecificationName": "tls_base" - }, - { - "StringRegExPattern": "([A-Z<]{30}){(30)}", - "StringLengthRange": [30, 30], - "BaseTextLineSpecificationName": "tls_base" - } - ] - }, - { - "Name": "tls_base", - "CharacterModelName": "MRZ", - "CharHeightRange": [5, 1000, 1], - "BinarizationModes": [ - { - "BlockSizeX": 30, - "BlockSizeY": 30, - "Mode": "BM_LOCAL_BLOCK", - "EnableFillBinaryVacancy": 0, - "ThresholdCompensation": 15 - } - ], - "ConfusableCharactersCorrection": { - "ConfusableCharacters": [ - ["0", "O"], - ["1", "I"], - ["5", "S"] - ], - "FontNameArray": ["OCR_B"] - } - } - ], - "LabelRecognizerTaskSettingOptions": [ - { - "Name": "task-passport", - "ConfusableCharactersPath": "ConfusableChars.data", - "TextLineSpecificationNameArray": ["tls_mrz_passport"], - "SectionImageParameterArray": [ - { - "Section": "ST_REGION_PREDETECTION", - "ImageParameterName": "ip-mrz" - }, - { - "Section": "ST_TEXT_LINE_LOCALIZATION", - "ImageParameterName": "ip-mrz" - }, - { - "Section": "ST_TEXT_LINE_RECOGNITION", - "ImageParameterName": "ip-mrz" - } - ] - }, - { - "Name": "task-id", - "ConfusableCharactersPath": "ConfusableChars.data", - "TextLineSpecificationNameArray": ["tls_mrz_id_td1", "tls_mrz_id_td2"], - "SectionImageParameterArray": [ - { - "Section": "ST_REGION_PREDETECTION", - "ImageParameterName": "ip-mrz" - }, - { - "Section": "ST_TEXT_LINE_LOCALIZATION", - "ImageParameterName": "ip-mrz" - }, - { - "Section": "ST_TEXT_LINE_RECOGNITION", - "ImageParameterName": "ip-mrz" - } - ] - }, - { - "Name": "task-passport-and-id", - "ConfusableCharactersPath": "ConfusableChars.data", - "TextLineSpecificationNameArray": ["tls_mrz_passport", "tls_mrz_id_td1", "tls_mrz_id_td2"], - "SectionImageParameterArray": [ - { - "Section": "ST_REGION_PREDETECTION", - "ImageParameterName": "ip-mrz" - }, - { - "Section": "ST_TEXT_LINE_LOCALIZATION", - "ImageParameterName": "ip-mrz" - }, - { - "Section": "ST_TEXT_LINE_RECOGNITION", - "ImageParameterName": "ip-mrz" - } - ] - } - ], - "CharacterModelOptions": [ - { - "DirectoryPath": "", - "Name": "MRZ" - } - ], - "ImageParameterOptions": [ - { - "Name": "ip-mrz", - "TextureDetectionModes": [ - { - "Mode": "TDM_GENERAL_WIDTH_CONCENTRATION", - "Sensitivity": 8 - } - ], - "BinarizationModes": [ - { - "EnableFillBinaryVacancy": 0, - "ThresholdCompensation": 21, - "Mode": "BM_LOCAL_BLOCK" - } - ], - "TextDetectionMode": { - "Mode": "TTDM_LINE", - "CharHeightRange": [5, 1000, 1], - "Direction": "HORIZONTAL", - "Sensitivity": 7 - } - } - ], - "SemanticProcessingOptions": [ - { - "Name": "sp-passport-and-id", - "ReferenceObjectFilter": { - "ReferenceTargetROIDefNameArray": ["roi-passport-and-id"] - }, - "TaskSettingNameArray": ["dcp-passport-and-id"] - }, - { - "Name": "sp-passport", - "ReferenceObjectFilter": { - "ReferenceTargetROIDefNameArray": ["roi-passport"] - }, - "TaskSettingNameArray": ["dcp-passport"] - }, - { - "Name": "sp-id", - "ReferenceObjectFilter": { - "ReferenceTargetROIDefNameArray": ["roi-id"] - }, - "TaskSettingNameArray": ["dcp-id"] - } - ], - "CodeParserTaskSettingOptions": [ - { - "Name": "dcp-passport", - "CodeSpecifications": ["MRTD_TD3_PASSPORT"] - }, - { - "Name": "dcp-id", - "CodeSpecifications": ["MRTD_TD1_ID", "MRTD_TD2_ID"] - }, - { - "Name": "dcp-passport-and-id", - "CodeSpecifications": ["MRTD_TD3_PASSPORT", "MRTD_TD1_ID", "MRTD_TD2_ID"] - } - ] -} diff --git a/samples/dwt-mrz/Resources/src/dynamsoft.lts.js b/samples/dwt-mrz/Resources/src/dynamsoft.lts.js deleted file mode 100644 index 520dd53..0000000 --- a/samples/dwt-mrz/Resources/src/dynamsoft.lts.js +++ /dev/null @@ -1,668 +0,0 @@ -/*! 20250310161029 -* Dynamsoft JavaScript Library -* Product: Dynamic Web TWAIN -* Web Site: https://www.dynamsoft.com -* -* Copyright 2025, Dynamsoft Corporation -* Author: Dynamsoft Support Team -* Version: 19.0.0-p0310 -*/ -(function(D){ -!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd&&0)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.localforage=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g=43)}})['catch'](function(){return!1})}function n(a){return"boolean"==typeof xa?va.resolve(xa):m(a).then(function(a){return xa=a})}function o(a){var b=ya[a.name],c={};c.promise=new va(function(a,b){c.resolve=a,c.reject=b}),b.deferredOperations.push(c),b.dbReady?b.dbReady=b.dbReady.then(function(){return c.promise}):b.dbReady=c.promise}function p(a){var b=ya[a.name],c=b.deferredOperations.pop();if(c)return c.resolve(),c.promise}function q(a,b){var c=ya[a.name],d=c.deferredOperations.pop();if(d)return d.reject(b),d.promise}function r(a,b){return new va(function(c,d){if(ya[a.name]=ya[a.name]||B(),a.db){if(!b)return c(a.db);o(a),a.db.close()}var e=[a.name];b&&e.push(a.version);var f=ua.open.apply(ua,e);b&&(f.onupgradeneeded=function(b){var c=f.result;try{c.createObjectStore(a.storeName),b.oldVersion<=1&&c.createObjectStore(wa)}catch(c){if("ConstraintError"!==c.name)throw c;console.warn('The database "'+a.name+'" has been upgraded from version '+b.oldVersion+" to version "+b.newVersion+', but the storage "'+a.storeName+'" already exists.')}}),f.onerror=function(a){a.preventDefault(),d(f.error)},f.onsuccess=function(){c(f.result),p(a)}})}function s(a){return r(a,!1)}function t(a){return r(a,!0)}function u(a,b){if(!a.db)return!0;var c=!a.db.objectStoreNames.contains(a.storeName),d=a.versiona.db.version;if(d&&(a.version!==b&&console.warn('The database "'+a.name+"\" can't be downgraded from version "+a.db.version+" to version "+a.version+"."),a.version=a.db.version),e||c){if(c){var f=a.db.version+1;f>a.version&&(a.version=f)}return!0}return!1}function v(a){return new va(function(b,c){var d=new FileReader;d.onerror=c,d.onloadend=function(c){var d=btoa(c.target.result||"");b({__local_forage_encoded_blob:!0,data:d,type:a.type})},d.readAsBinaryString(a)})}function w(a){return g([l(atob(a.data))],{type:a.type})}function x(a){return a&&a.__local_forage_encoded_blob}function y(a){var b=this,c=b._initReady().then(function(){var a=ya[b._dbInfo.name];if(a&&a.dbReady)return a.dbReady});return i(c,a,a),c}function z(a){o(a);for(var b=ya[a.name],c=b.forages,d=0;d0&&(!a.db||"InvalidStateError"===e.name||"NotFoundError"===e.name))return va.resolve().then(function(){if(!a.db||"NotFoundError"===e.name&&!a.db.objectStoreNames.contains(a.storeName)&&a.version<=a.db.version)return a.db&&(a.version=a.db.version+1),t(a)}).then(function(){return z(a).then(function(){A(a,b,c,d-1)})})['catch'](c);c(e)}}function B(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function C(a){function b(){return va.resolve()}var c=this,d={db:null};if(a)for(var e in a)d[e]=a[e];var f=ya[d.name];f||(f=B(),ya[d.name]=f),f.forages.push(c),c._initReady||(c._initReady=c.ready,c.ready=y);for(var g=[],h=0;h>4,k[i++]=(15&d)<<4|e>>2,k[i++]=(3&e)<<6|63&f;return j}function O(a){var b,c=new Uint8Array(a),d="";for(b=0;b>2],d+=Da[(3&c[b])<<4|c[b+1]>>4],d+=Da[(15&c[b+1])<<2|c[b+2]>>6],d+=Da[63&c[b+2]];return c.length%3==2?d=d.substring(0,d.length-1)+"=":c.length%3==1&&(d=d.substring(0,d.length-2)+"=="),d}function P(a,b){var c="";if(a&&(c=Ua.call(a)),a&&("[object ArrayBuffer]"===c||a.buffer&&"[object ArrayBuffer]"===Ua.call(a.buffer))){var d,e=Ga;a instanceof ArrayBuffer?(d=a,e+=Ia):(d=a.buffer,"[object Int8Array]"===c?e+=Ka:"[object Uint8Array]"===c?e+=La:"[object Uint8ClampedArray]"===c?e+=Ma:"[object Int16Array]"===c?e+=Na:"[object Uint16Array]"===c?e+=Pa:"[object Int32Array]"===c?e+=Oa:"[object Uint32Array]"===c?e+=Qa:"[object Float32Array]"===c?e+=Ra:"[object Float64Array]"===c?e+=Sa:b(new Error("Failed to get type for BinaryArray"))),b(e+O(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var c=Ea+a.type+"~"+O(this.result);b(Ga+Ja+c)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(c){console.error("Couldn't convert value into a JSON string: ",a),b(null,c)}}function Q(a){if(a.substring(0,Ha)!==Ga)return JSON.parse(a);var b,c=a.substring(Ta),d=a.substring(Ha,Ta);if(d===Ja&&Fa.test(c)){var e=c.match(Fa);b=e[1],c=c.substring(e[0].length)}var f=N(c);switch(d){case Ia:return f;case Ja:return g([f],{type:b});case Ka:return new Int8Array(f);case La:return new Uint8Array(f);case Ma:return new Uint8ClampedArray(f);case Na:return new Int16Array(f);case Pa:return new Uint16Array(f);case Oa:return new Int32Array(f);case Qa:return new Uint32Array(f);case Ra:return new Float32Array(f);case Sa:return new Float64Array(f);default:throw new Error("Unkown type: "+d)}}function R(a,b,c,d){a.executeSql("CREATE TABLE IF NOT EXISTS "+b.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],c,d)}function S(a){var b=this,c={db:null};if(a)for(var d in a)c[d]="string"!=typeof a[d]?a[d].toString():a[d];var e=new va(function(a,d){try{c.db=openDatabase(c.name,String(c.version),c.description,c.size)}catch(a){return d(a)}c.db.transaction(function(e){R(e,c,function(){b._dbInfo=c,a()},function(a,b){d(b)})},d)});return c.serializer=Va,e}function T(a,b,c,d,e,f){a.executeSql(c,d,e,function(a,g){g.code===g.SYNTAX_ERR?a.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[b.storeName],function(a,h){h.rows.length?f(a,g):R(a,b,function(){a.executeSql(c,d,e,f)},f)},f):f(a,g)},f)}function U(a,b){var c=this;a=j(a);var d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"SELECT * FROM "+e.storeName+" WHERE key = ? LIMIT 1",[a],function(a,c){var d=c.rows.length?c.rows.item(0).value:null;d&&(d=e.serializer.deserialize(d)),b(d)},function(a,b){d(b)})})})['catch'](d)});return h(d,b),d}function V(a,b){var c=this,d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"SELECT * FROM "+e.storeName,[],function(c,d){for(var f=d.rows,g=f.length,h=0;h0)return void f(W.apply(e,[a,h,c,d-1]));g(b)}})})})['catch'](g)});return h(f,c),f}function X(a,b,c){return W.apply(this,[a,b,c,1])}function Y(a,b){var c=this;a=j(a);var d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"DELETE FROM "+e.storeName+" WHERE key = ?",[a],function(){b()},function(a,b){d(b)})})})['catch'](d)});return h(d,b),d}function Z(a){var b=this,c=new va(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){T(b,d,"DELETE FROM "+d.storeName,[],function(){a()},function(a,b){c(b)})})})['catch'](c)});return h(c,a),c}function $(a){var b=this,c=new va(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){T(b,d,"SELECT COUNT(key) as c FROM "+d.storeName,[],function(b,c){var d=c.rows.item(0).c;a(d)},function(a,b){c(b)})})})['catch'](c)});return h(c,a),c}function _(a,b){var c=this,d=new va(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){T(c,e,"SELECT key FROM "+e.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var d=c.rows.length?c.rows.item(0).key:null;b(d)},function(a,b){d(b)})})})['catch'](d)});return h(d,b),d}function aa(a){var b=this,c=new va(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){T(b,d,"SELECT key FROM "+d.storeName,[],function(b,c){for(var d=[],e=0;e '__WebKitDatabaseInfoTable__'",[],function(c,d){for(var e=[],f=0;f0}function ha(a){var b=this,c={};if(a)for(var d in a)c[d]=a[d];return c.keyPrefix=ea(a,b._defaultConfig),ga()?(b._dbInfo=c,c.serializer=Va,va.resolve()):va.reject()}function ia(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo.keyPrefix,c=localStorage.length-1;c>=0;c--){var d=localStorage.key(c);0===d.indexOf(a)&&localStorage.removeItem(d)}});return h(c,a),c}function ja(a,b){var c=this;a=j(a);var d=c.ready().then(function(){var b=c._dbInfo,d=localStorage.getItem(b.keyPrefix+a);return d&&(d=b.serializer.deserialize(d)),d});return h(d,b),d}function ka(a,b){var c=this,d=c.ready().then(function(){for(var b=c._dbInfo,d=b.keyPrefix,e=d.length,f=localStorage.length,g=1,h=0;h=0;b--){var c=localStorage.key(b);0===c.indexOf(a)&&localStorage.removeItem(c)}}):va.reject("Invalid arguments"),h(d,b),d}function ra(a,b){a[b]=function(){var c=arguments;return a.ready().then(function(){return a[b].apply(a,c)})}}function sa(){for(var a=1;ae.length)&&(t=e.length);for(var r=0,n=Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r["return"]||r["return"]()}finally{if(s)throw i}}}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=r["return"]&&(a=r["return"](),Object(a)!==a))return}finally{if(u)throw o}}return s}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _regeneratorRuntime(){_regeneratorRuntime=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof y?t:y,a=Object.create(i.prototype),s=new A(n||[]);return o(a,"_invoke",{value:T(e,r,s)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",v="completed",m={};function y(){}function g(){}function b(){}var x={};u(x,a,(function(){return this}));var w=Object.getPrototypeOf,_=w&&w(w(L([])));_&&_!==r&&n.call(_,a)&&(x=_);var S=b.prototype=y.prototype=Object.create(x);function k(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function r(o,i,a,s){var c=l(e[o],e,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){u.value=e,a(u)}),(function(e){return r("throw",e,a,s)}))}s(c.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function T(t,r,n){var o=h;return function(i,a){if(o===p)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var c=E(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var u=l(t,r,n);if("normal"===u.type){if(o=n.done?v:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=v,n.method="throw",n.arg=u.arg)}}}function E(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator["return"]&&(r.method="return",r.arg=e,E(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=l(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),m}},"catch":function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;I(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _toPrimitive(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==typeof t?t:t+""}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}!function(){var e,t,r,n,o,i="undefined"==typeof self,a=i?{}:self;"undefined"!=typeof navigator&&(e=navigator,t=e.userAgent,r=e.platform,n=e.mediaDevices),function(){if(!i){var n={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:e.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},a={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:r,search:"Win"},Mac:{str:r},Linux:{str:r}},s="unknownBrowser",c=0,u="unknownOS";for(var f in n){var l=n[f]||{},h=l.str||t,d=l.search||f,p=l.verStr||t,v=l.verSearch||f;if(v instanceof Array||(v=[v]),-1!=h.indexOf(d)){s=f;var m,y=_createForOfIteratorHelper(v);try{for(y.s();!(m=y.n()).done;){var g=m.value,b=p.indexOf(g);if(-1!=b){c=parseFloat(p.substring(b+g.length+1));break}}}catch(k){y.e(k)}finally{y.f()}break}}for(var x in a){var w=a[x]||{},_=w.str||t,S=w.search||x;if(-1!=_.indexOf(S)){u=x;break}}"Linux"==u&&-1!=t.indexOf("Windows NT")&&(u="HarmonyOS"),o={browser:s,version:c,OS:u}}i&&(o={browser:"ssr",version:0,OS:"ssr"})}(),n&&n.getUserMedia;var s="Chrome"===o.browser&&o.version>66||"Safari"===o.browser&&o.version>13||"OPR"===o.browser&&o.version>43||"Edge"===o.browser&&o.version>15;var c=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}();function u(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var r=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),n=0;n=43)}}))["catch"]((function(){return!1}))}(e).then((function(e){return p=e}))}function w(e){var t=m[e.name],r={};r.promise=new Dynamsoft.Lib.Promise((function(e,t){r.resolve=e,r.reject=t})),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then((function(){return r.promise})):t.dbReady=r.promise}function _(e){var t=m[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function S(e,t){var r=m[e.name].deferredOperations.pop();if(r)return r.reject(t),r.promise}function k(e,t){return new Dynamsoft.Lib.Promise((function(r,n){if(m[e.name]=m[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return r(e.db);w(e),e.db.close()}var o=[e.name];t&&o.push(e.version);var i=c.open.apply(c,o);t&&(i.onupgradeneeded=function(t){var r=i.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(v)}catch(n){if("ConstraintError"!==n.name)throw n}}),i.onerror=function(e){e.preventDefault(),n(i.error)},i.onsuccess=function(){var t=i.result;t.onversionchange=function(e){e.target.close()},r(t),_(e)}}))}function C(e){return k(e,!1)}function T(e){return k(e,!0)}function E(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.versione.db.version;if(n&&(e.version,e.version=e.db.version),o||r){if(r){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function O(e){var t=function(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),o=0;o0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return Dynamsoft.Lib.Promise.resolve().then((function(){if(!e.db||"NotFoundError"===i.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),T(e)})).then((function(){return function(e){w(e);for(var t=m[e.name],r=t.forages,n=0;n=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=a.call(i,"catchLoc"),u=a.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),j(r),b}},"catch":function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:N(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),b}},o}e.exports=r,e.exports.__esModule=!0,e.exports["default"]=e.exports}(te);var oe=(0,te.exports)(),ie=oe;try{regeneratorRuntime=oe}catch(Nr){"object"===("undefined"==typeof globalThis?"undefined":_typeof(globalThis))?globalThis.regeneratorRuntime=oe:Function("r","regeneratorRuntime = r")(oe)}var ae,se,ce=ee(ie);function ue(e){var t=e?new Date(e):new Date,r="yyyy-MM-dd HH:mm:ss.SSSZ",n={"M+":t.getUTCMonth()+1,"d+":t.getUTCDate(),"H+":t.getUTCHours(),"h+":t.getUTCHours()%12||12,"m+":t.getUTCMinutes(),"s+":t.getUTCSeconds(),"q+":Math.floor((t.getUTCMonth()+3)/3),"S+":t.getUTCMilliseconds()};for(var o in/(y+)/.test(r)&&(r=r.replace(RegExp.$1,(t.getUTCFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+o+")").test(r)&&(r=r.replace(RegExp.$1,1==RegExp.$1.length?n[o]:("000"+n[o]).substr(("000"+n[o]).length-RegExp.$1.length)));return r}function fe(e){return e===se}function le(e){return e!==se}function he(e){return null===e}ae="object"===("undefined"==typeof window?"undefined":Z(window))?window:{};var de={"[object Function]":"function","[object AsyncFunction]":"function","[object String]":"string","[object Object]":"object","[object Boolean]":"boolean","[object Number]":"number","[object Array]":"array"};function pe(e){return he(e)||fe(e)?String(e):de[{}.toString.call(e)]||"object"}function ve(e){return"function"===pe(e)}function me(e){return"string"===pe(e)}function ye(e){return"object"===pe(e)}function ge(e){return"boolean"===pe(e)}function be(e){return"number"===pe(e)}function xe(e){return Array.isArray?Array.isArray(e):"array"===pe(e)}function we(e){if(null==e)return[];if(xe(e))return e;var t=Z(e.length),r=Z(e);if("number"!==t||e.alert||"string"===r||"function"===r&&(!("item"in e)||"number"!==t))return[e];for(var n=[],o=0,i=e.length;o2){var i=n[n.length-2],a=n[n.length-1];ve(i)&&ve(a)&&(n[n.length-2]=function(){try{i.apply(t,arguments)}catch(e){}Le.timer=setTimeout(Le.doNext,0)},n[n.length-1]=function(){try{a.apply(t,arguments)}catch(e){}Le.timer=setTimeout(Le.doNext,0)},o=!0)}try{t[r].apply(t,n)}catch(s){}o||(Le.timer=setTimeout(Le.doNext,0))}else if(null===t&&ve(r)){try{r.apply(null,n)}catch(c){}Le.timer=setTimeout(Le.doNext,0)}else Ee("not invoke a function: "+r),Le.timer=setTimeout(Le.doNext,0)}else Le.stop();else Le.stop()},start:function(){Le.doNextStarted||(Le.doNextStarted=!0,Le.timer=setTimeout(Le.doNext,0))},stop:function(){clearTimeout(Le.timer),Le.timer=null,Le.doNextStarted=!1,Le.queue=[]}},je=!0,Pe=!1;function Ne(e,t,r){if(e){var n,o,i,a=0,s=e.length;if(r=r||null,fe(s)||ve(e))for(i=Object.keys(e);a=0;i--)o[i]===t&&o.splice(i,1);else n[e]=null;else this.exec=null}},Me="";var Ue,Fe,Be,He,Ge=navigator,We=!0;if("userAgentData"in Ge){var Je=Ge.userAgentData,$e=[];Je.platform&&""!=Je.platform&&("brands"in Je&&Array.isArray(Je.brands)&&Je.brands.length>0?$e=Je.brands:"uaList"in Je&&Array.isArray(Je.uaList)&&Je.uaList.length>0&&($e=Je.uaList),$e.length>0&&(We=!1,Fe=Je.platform.toLowerCase(),Ue=function(e,t,r){var n,o,i,a,s,c,u,f,l,h=!1,d=!1,p=!1,v=e.mobile,m=!1,y=Me,g=navigator.maxTouchPoints||0;for(o=t.length,n=0;n=0){p=!0,y=t[n].version;break}if(b.indexOf("edge")>=0){h=!0,y=t[n].version;break}if(b.indexOf("opera")>=0){d=!0,y=t[n].version;break}}return p||h||d||(p=!0,y="100"),i=/windows/g.test(r),a=/mac/g.test(r),s=/linux/g.test(r),c=/android/g.test(r),u=/harmony/g.test(r),f=/(chromeos|chrome\sos)/g.test(r),l=/iphone/g.test(r),i||c||s||l||(m=/macintel/g.test(r)&&g>1),(c||u||l||m)&&(v=!0),{bUseUserAgent:!1,bWin:i,bMac:a,bLinux:s,bAndroid:c,bHarmonyOS:u,bChromeOS:f,bIE:!1,bEdge:h,bUC:!1,bPlaybook:!1,bBlackBerry:!1,bHuaWeiBrowser:!1,bOpera:d,bFirefox:!1,bChrome:p,bJSDom:!1,biPhone:l,biPad:m,bPad:c&&!e.mobile,bSafari:!1,bMobile:v,strBrowserVersion:y,bHTML5Edition:!0,IEVersion:0,IEMode:0}}(Je,$e,Fe)))}We&&(Be||(Be=Ge.userAgent.toLowerCase()),He||(He=Ge.platform.toLowerCase()),Ue=function(e,t){var r,n=e.toLowerCase(),o=t.toLowerCase(),i=/harmonyos/g.test(n);"linux"==o&&n.indexOf("windows nt")>=0&&(o="harmonyos",i=!0);var a=!i&&/cros/.test(n),s=!i&&/android/g.test(n)||/android/g.test(o),c=/iphone/g.test(n)||/iphone/g.test(o),u=/macintosh/.test(n),f=navigator.maxTouchPoints||0,l=/ipad/g.test(n)||(u||"macintel"==o)&&f>1,h=/ucweb|ucbrowser/g.test(n),d=!h&&/nexus/g.test(n)&&/version\/[\d.]+.*safari\//g.test(n),p=/playbook/g.test(n),v=/hp-tablet/g.test(n),m=/blackberry|bb10/g.test(n),y=/symbian/g.test(n),g=/windows phone/g.test(n),b=/mobile/g.test(n),x=/arm64|aarch64/g.test(n),w=/mips64/g.test(n),_=/huaweibrowser/g.test(n),S=/jsdom/g.test(n),k=p||l||v,C=!k&&!a&&(c||d||m||y||g||s||i||b),T=!C&&!k&&!a,E=T&&/win32|win64|windows/.test(o),O=E&&/win64|x64/.test(n),I=T&&/mac68k|macppc|macintosh|macintel/.test(n),A=T&&/linux/.test(o),L="win64"==o||/wow64|x86_64|win64|x64/.test(n)||x||w,j=/wow64/g.test(n),P=Pe,N=/opera|opr/g.test(n),D=/360se/g.test(n),R=/maxthon/g.test(n),M=/tencenttraveler|qqbrowser/g.test(n),U=/the world/g.test(n),F=/metasr/g.test(n),B=/avant/g.test(n),H=/firefox|fxios/g.test(n),G=/gecko/g.test(n),W=!(H||_)&&/edge\/|edga\/|edgios\/|edg\//g.test(n),J=!(m||p||h||N||W||_||S)&&/chrome|crios/g.test(n),$=!1,q=Me,V=0,z=0,Y=Me;if(E&&!W&&!H&&!J){var Z=n.indexOf("msie "),K=n.indexOf("trident"),X=n.indexOf("rv:");$=-1!=Z||-1!=K||-1!=X}if(!(I||c||l||E||m||p||d)||h||N||W||$||H||(r=n.match(/version\/([\d.]+).*safari\//))&&(m||p||d||(P=je,J=Pe),Y=r[1]),W){var Q=n.indexOf("edge/");Q>-1?Q+=5:(Q=n.indexOf("edg/"))>-1?Q+=4:(Q=n.indexOf("edga/"))>-1?Q+=5:(Q=n.indexOf("edgios/"))>-1&&(Q+=7),Q>-1&&(r=(Y=n.slice(Q)).indexOf(" "))>-1&&(Y=Y.slice(0,r))}else if(H)if((r=n.indexOf("firefox/"))>-1){var ee=(r=n.slice(r+8)).indexOf(" ");ee>-1&&(r=r.slice(0,ee)),Y=r,(ee=r.indexOf("."))>-1&&(r=Y.slice(0,ee))}else(c||l)&&(r=n.indexOf("fxios/"))>-1&&(Y=r=(r=n.slice(r+6)).slice(0,r.indexOf(" ")));else if($){var te=n.indexOf("msie "),re=n.indexOf("trident"),ne=n.indexOf("rv:");-1!=te?q=r=(r=n.slice(te+5)).slice(0,r.indexOf(";")):-1!=ne?q=r=(r=(r=n.slice(ne+3)).slice(0,r.indexOf(";"))).slice(0,r.indexOf(")")):-1!=re&&(q=r=(r=n.slice(re+7)).slice(0,r.indexOf(";"))),Y=r}else if(P)(r=Y.indexOf("."))>-1&&(r=Y.slice(0,r));else if(h)(r=n.indexOf("ucweb"))>-1?Y=n.slice(r+5):(r=n.indexOf("ucbrowser/"))>-1&&(r=(Y=n.slice(r+10)).indexOf(" "))>-1&&(Y=Y.slice(0,r));else if(N)(r=n.indexOf("version/"))>-1?Y=n.slice(r+8):(r=n.indexOf("opr/"))>-1&&(Y=n.slice(r+4));else if(y)(r=n.indexOf("browserng/"))>-1&&(Y=n.slice(r+10));else if(g)(r=n.indexOf("iemobile/"))>-1&&(Y=n.slice(r+9));else if(J){var oe=n.indexOf("chrome/");oe>-1?(r=(Y=n.slice(oe+7)).indexOf(" "))>-1&&(Y=Y.slice(0,r)):(oe=n.indexOf("crios/"))>-1&&(r=(Y=n.slice(oe+6)).indexOf(" "))>-1&&(Y=Y.slice(0,r)),(r=Y.indexOf("."))>-1&&(r=Y.slice(0,r))}else if(_){var ie=n.indexOf("huaweibrowser");ie>-1&&(r=(Y=n.slice(ie+14)).indexOf(" "))>-1&&(Y=Y.slice(0,r))}else if(S){var se=n.indexOf("jsdom");se>-1&&(r=(Y=n.slice(se+6)).indexOf(" "))>-1&&(Y=Y.slice(0,r))}if(W||$){var ce=window.document;ce&&ce.documentMode?V=ce.documentMode:(V=5,ce.compatMode&&"CSS1Compat"==ce.compatMode&&(V=7)),$&&(z=parseInt(Y))}(I||A)&&(L=!0,I&&(r=n.match(/mac os x (\d+)(_|\.)(\d+)/))&&r.length>3&&(10==r[1]&&r[3]<14||r[1]<10)&&(L=!1)),E||I||A||x||w||(C=!0);var ue=!0;if($)if(""===q||parseInt(q)>=10){var fe=ae.Dynamsoft;fe&&fe.DWT&&fe.DWT.IfUseActiveXForIE10Plus&&(ue=Pe)}else ue=Pe;return{bUseUserAgent:!0,bWin:E,bMac:I,bLinux:A,bMobile:C,bPad:k,bChromeOS:a,bHarmonyOS:i,bArm64:x,bMips64:w,bEmbed:x||w,bAndroid:s,biPhone:c,biPad:l,bWin64:O,bWOW64:j,bOSx64:L,bIE:$,bEdge:W,bChrome:J,bFirefox:H,bSafari:P,bOpera:N,bNexus:d,bUC:h,b360SE:D,bMaxthon:R,bTencentTraveler:M,bTheWorld:U,bMetaSr:F,bAvant:B,bHuaWeiBrowser:_,bJSDom:S,bGecko:G,bHTML5Edition:ue,strBrowserVersion:Y,IEVersion:z,IEMode:V}}(Be,He));var qe=null===(De=null===document||void 0===document?void 0:document.location)||void 0===De?void 0:De.protocol;function Ve(e){return Ue.bGecko&&"mousewheel"===e?"DOMMouseScroll":e}function ze(e,t,r){var n=Ve(t);e&&e.addEventListener(n,r,!1)}function Ye(e,t,r){var n=Ve(t);e&&e.removeEventListener(n,r,!1)}function Ze(e){var t=e||ae.event;t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.returnValue=!1,t.cancelBubble=!0}function Ke(e,t){var r=ae.document.createEvent("HTMLEvents");r.initEvent(e,je,je),t.dispatchEvent&&t.dispatchEvent(r)}qe||(qe="https:"),Ue.protocol=qe,Ue.bSSL="https:"===qe,Ue.bFileSystem="https:"!==qe&&"http:"!==qe;var Xe,Qe,et,tt,rt=ae.document,nt=[],ot=nt.push,it=nt.slice,at=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,st=function(){Qe()};function ct(e,t,r,n){var o,i,a,s=t&&t.ownerDocument,c=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==c&&9!==c&&11!==c)return r;if(!n&&((t?t.ownerDocument||t:rt)!==et&&Qe(t),t=t||et,11!==c&&(a=at.exec(e))))if(o=a[1]){if(9===c){if(!(i=t.getElementById(o)))return r;if(i.id===o)return r.push(i),r}else if(s&&(i=s.getElementById(o))&&tt(t,i)&&i.id===o)return r.push(i),r}else{if(a[2])return ot.apply(r,t.getElementsByTagName(e)),r;if((o=a[3])&&t.getElementsByClassName)return ot.apply(r,t.getElementsByClassName(o)),r}return r}ot.apply(it.call(rt.childNodes),rt.childNodes),Qe=ct.setDocument=function(e){var t,r=e?e.ownerDocument||e:rt;return r!==et&&9===r.nodeType&&r.documentElement?(rt!==(et=r)&&(t=et.defaultView)&&t.top!==t&&(t.addEventListener?t.addEventListener("unload",st,!1):t.attachEvent&&t.attachEvent("onunload",st)),tt=function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},et):et},ct.contains=function(e,t){return(e.ownerDocument||e)!==et&&Qe(e),tt(e,t)},ct.error=function(e){throw new Error("Syntax error: "+e)},Xe=ct.getText=function(e){var t,r="",n=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)r+=Xe(e)}else if(3===o||4===o)return e.nodeValue}else for(;t=e[n++];)r+=Xe(t);return r},Qe();var ut={encodeChars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",decodeChars:[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1]},ft={UTF16ToUTF8:function(e){for(var t,r,n=[],o=e.length,i=0;i0&&a<=127)n.push(e.charAt(i));else if(a>=128&&a<=2047)t=192|a>>6&31,r=128|63&a,n.push(String.fromCharCode(t),String.fromCharCode(r));else if(a>=2048&&a<=65535){t=224|a>>12&15,r=128|a>>6&63;var s=128|63&a;n.push(String.fromCharCode(t),String.fromCharCode(r),String.fromCharCode(s))}}return n.join("")},UTF8ToUTF16:function(e){var t,r,n,o,i=[],a=e.length;for(t=0;t>7&255?6==(r>>5&255)?(o=(31&r)<<6|63&(n=e.charCodeAt(++t)),i.push(String.fromCharCode(o))):14==(r>>4&255)&&(o=(255&(r<<4|(n=e.charCodeAt(++t))>>2&15))<<8|((3&n)<<6|63&e.charCodeAt(++t)),i.push(String.fromCharCode(o))):i.push(e.charAt(t));return i.join("")},encode:function(e){for(var t,r,n,o=this.UTF16ToUTF8(e),i=[],a=0,s=o.length;a>2)),i.push(ut.encodeChars.charAt((3&t)<<4)),i.push("==");break}if(r=o.charCodeAt(a++),a==s){i.push(ut.encodeChars.charAt(t>>2)),i.push(ut.encodeChars.charAt((3&t)<<4|(240&r)>>4)),i.push(ut.encodeChars.charAt((15&r)<<2)),i.push("=");break}n=o.charCodeAt(a++),i.push(ut.encodeChars.charAt(t>>2)),i.push(ut.encodeChars.charAt((3&t)<<4|(240&r)>>4)),i.push(ut.encodeChars.charAt((15&r)<<2|(192&n)>>6)),i.push(ut.encodeChars.charAt(63&n))}return i.join("")},encodeArray:function(e){for(var t,r,n,o=[],i=0,a=e.length;i>2)),o.push(ut.encodeChars.charAt((3&t)<<4)),o.push("==");break}if(r=255&e[i++],i==a){o.push(ut.encodeChars.charAt(t>>2)),o.push(ut.encodeChars.charAt((3&t)<<4|(240&r)>>4)),o.push(ut.encodeChars.charAt((15&r)<<2)),o.push("=");break}n=255&e[i++],o.push(ut.encodeChars.charAt(t>>2)),o.push(ut.encodeChars.charAt((3&t)<<4|(240&r)>>4)),o.push(ut.encodeChars.charAt((15&r)<<2|(192&n)>>6)),o.push(ut.encodeChars.charAt(63&n))}return o.join("")},decode:function(e,t){for(var r,n,o,i,a=this,s=[],c=0,u=e.length;c>4):s.push(String.fromCharCode(r<<2|(48&n)>>4));do{if(61==(o=255&e.charCodeAt(c++)))return t?s:a.UTF8ToUTF16(s.join(""));o=ut.decodeChars[o]}while(c>2):s.push(String.fromCharCode((15&n)<<4|(60&o)>>2));do{if(61==(i=255&e.charCodeAt(c++)))return t?s:a.UTF8ToUTF16(s.join(""));i=ut.decodeChars[i]}while(c=1&&t<=127?r.push(e.charAt(n)):t>2047?(r.push(String.fromCharCode(224|t>>12&15)),r.push(String.fromCharCode(128|t>>6&63)),r.push(String.fromCharCode(128|63&t))):(r.push(String.fromCharCode(192|t>>6&31)),r.push(String.fromCharCode(128|63&t))),n++;return r.join("")},toUTF16:function(e){for(var t,r,n,o=[],i=0,a=e.length;i>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o.push(e.charAt(i-1));break;case 12:case 13:r=e.charCodeAt(i++),o.push(String.fromCharCode((31&t)<<6|63&r));break;case 14:r=e.charCodeAt(i++),n=e.charCodeAt(i++),o.push(String.fromCharCode((15&t)<<12|(63&r)<<6|63&n))}return o.join("")}},ht="undefined"!=typeof self?self:global,dt=ht.btoa?function(e){return ht.btoa(e)}:function(e){for(var t,r,n=String(e),o=0,i=ut.encodeChars,a="";n.charAt(0|o)||(i="=",o%1);a+=i.charAt(63&t>>8-o%1*8)){if((r=n.charCodeAt(o+=3/4))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");t=t<<8|r}return a},pt=ht.atob?function(e){return ht.atob(e)}:function(e){var t=String(e).replace(/[=]+$/,"");if(t.length%4==1)throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=t.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=ut.encodeChars.indexOf(n);return a};function vt(e){if(null==e||"object"!=Z(e))return e;var t,r,n;if(e instanceof Date)return(t=new Date).setTime(e.getTime()),t;if(e instanceof Array){for(t=[],n=e.length,r=0;r=0&&!o;e--)me(t=n[e])&&t&&(r=t+"/"+r,o="/"===t.charAt(0));return(o?"/":"")+jt(Ot(r.split("/"),(function(e){return!!e})),!o).join("/")||"."}},{key:"join",value:function(){return Pt(Ot(we(arguments),(function(e){return e&&me(e)})).join("/"))}},{key:"relative",value:function(e,t){e=Pt(e),t=Pt(t);var r,n,o=Ot(e.split("/"),(function(e){return!!e})),i=[],a=Ot(t.split("/"),(function(e){return!!e})),s=Math.min(o.length,a.length);for(r=0;r=0&&e.indexOf(t,r)===r}function Gt(e){return null==e?Me:String.prototype.trim.call(e)}function Wt(e){var t;if(e)for(t in e)if(!fe(t))return!1;return!0}function Jt(e){return me(e)?e.replace(/[^\x20-\x7E]/g,""):e}function $t(e,t,r){return e.replace(new RegExp(t,"gi"),r)}function qt(e){return e.charAt(0).toUpperCase()+e.substr(1)}var Vt,zt="none",Yt={getOffset:function(e,t,r){var n,o;e=e||ae.event;for(var i,a,s=r||e.target,c=0,u=0,f=0,l=0,h=!1,d=ae.document;s&&!isNaN(s.offsetLeft)&&!isNaN(s.offsetTop);)a=s.scrollLeft,i=s.scrollTop,"BODY"===s.tagName?h?(a=0,i=0):(a|=null===(n=d.documentElement)||void 0===n?void 0:n.scrollLeft,i|=null===(o=d.documentElement)||void 0===o?void 0:o.scrollTop):"fixed"===s.style.position&&(h=!0),c+=s.offsetLeft-a,u+=s.offsetTop-i,s=s.offsetParent;return t&&(f=t.Left,l=t.Top),{x:c=e.clientX-c-f,y:u=e.clientY-u-l}},getElDimensions:function(e,t){var r,n;return e?(r=e.style.display,e.style.display="",n=t?{offsetTop:e.offsetTop,offsetLeft:e.offsetLeft,offsetWidth:e.offsetWidth,offsetHeight:e.offsetHeight}:{clientTop:e.clientTop,clientLeft:e.clientLeft,clientWidth:e.clientWidth?e.clientWidth:parseInt(e.style.width)?parseInt(e.style.width):0,clientHeight:e.clientHeight?e.clientHeight:parseInt(e.style.height)?parseInt(e.style.height):0},e.style.display=r,n):{offsetTop:0,offsetLeft:0,offsetWidth:0,offsetHeight:0}}};function Zt(e){return document.getElementById(e)}function Kt(e){var t=me(e)?Zt(e):e;t&&(t.length>0&&(t=t[0]),t.style.display=zt)}function Xt(e){var t=me(e)?Zt(e):e;t&&(t.length>0&&(t=t[0]),t.style.display=Me)}function Qt(e){var t=me(e)?Zt(e):e;t&&(t.length>0&&(t=t[0]),t.style.display===zt?t.style.display=Me:t.style.display=zt)}function er(e){if(e)for(;e.firstChild;)e.removeChild(e.firstChild)}function tr(e){return encodeURIComponent(String(e))}function rr(e){return decodeURIComponent(e.replace(/\+/g," "))}if(window.trustedTypes){try{Vt=window.trustedTypes.createPolicy("d-create-script",{createScriptURL:function(e){return e}})}catch(Dr){}}function nr(e){return Vt?Vt.createScriptURL(e):e}var or=!0,ir=document,ar=ir&&ir.documentElement,sr=ir.getElementsByTagName("head")[0]||ar,cr=ir.createElement("script").readyState?function(e,t){var r=e.onreadystatechange;e.onreadystatechange=function(){var n=e.readyState;if("loaded"===n||"complete"===n){e.onreadystatechange=null,r&&r();t.call(this,{type:"load",path:[e]})}else"loading"===n||t.call(this,{type:"error",path:[e]})}}:function(e,t){e.addEventListener("load",t,Pe),e.addEventListener("error",t,Pe)};function ur(e,t,r){return fr(e,t,!1,r)}function fr(e,t,r,n){var o,i,a=n;if(ve(a)||(a=function(){}),me(e)&&e!=Me)return o=ir.createElement("script"),i=["",e].join(Me),o.src=nr(i),t&&(o.async=or),o.charset="utf-8",cr(o,a),r?sr.appendChild(o):sr.insertBefore(o,sr.firstChild),o;a()}function lr(e,t,r){return hr(e,t,!1,r)}function hr(e,t,r,n){var o=n;if(ve(o)||(o=function(){}),Ue.bJSDom)o("ok");else if(xe(e)){var i=e.length,a=function(e){e&&"load"==e.type?i--:(e&&"error"==e.type&&Oe(["Failed to load resource: ",e.target.src,"."].join("")),o()),i<=0&&o("ok")};i<=0?o("ok"):Ne(e,(function(e){fr(e,t,r,a)}))}else o()}function dr(e,t){return pr(e,!1,t)}function pr(e,t,r){var n,o=r;if(ve(o)||(o=!1),me(e)&&e!=Me){if(!Ue.bJSDom)return(n=ir.createElement("link")).href=nr(e),n.rel="stylesheet",n.async=or,o&&cr(n,o),t?sr.appendChild(n):sr.insertBefore(n,sr.firstChild),n;o&&o()}else o&&o()}function vr(e,t){return mr(e,!1,t)}function mr(e,t,r){if(Ue.bJSDom)r&&r("ok");else if(xe(e)){var n=e.length,o=function(e){e&&"load"==e.type&&n--,e&&"load"!=e.type&&(e&&"error"==e.type&&Oe(["Failed to load resource: ",e.target.href,"."].join("")),r()),n<=0&&r("ok")};Ne(e,(function(e){pr(e,t,o)}))}else r&&r()}function yr(e){var t,r;if(!Ue.bJSDom){var n=document;if(n&&me(r=e.body)&&r!=Me){(t=n.createElement("script")).charset="utf-8",Ue.bIE?t.text=r:t.appendChild(n.createTextNode(r)),e.language?t.language=e.language:t.language="javascript",e.type?t.type=e.type:t.type="text/javascript";var o=n&&n.documentElement,i=n.getElementsByTagName("head")[0]||o;i.insertBefore(t,i.firstChild)}}}function gr(e){yr({body:e})}function br(e){yr({body:e,language:"vbscript",type:"text/vbscript"})}function xr(e){return null!=e&&e==e.window}var wr=new(function(){return Q((function e(){Y(this,e),this.nil=undefined,this.bNode=!1,this.noop=function(){},this.mix=wt,this.clone=vt,this.keys=Object.keys,this.now=bt,this.getFormatedNow=ue,this.getRandom=xt,this.guid=yt,this.get=Zt,this.show=Xt,this.hide=Kt,this.toggle=Qt,this.empty=er,this.stringify=ae.JSON.stringify,this.parse=ae.JSON.parse,this.isDef=le,this.isUndef=fe,this.isUndefined=fe,this.isNull=he,this.isNaN=isNaN,this.isFunction=ve,this.isString=me,this.isObject=ye,this.isBoolean=ge,this.isNumber=be,this.isArray=xe,this.type=pe,this.isPlainObject=Rt,this.isDOM=Ut,this.isDOMInBody=Ft,this.each=Ne,this.getLogger=Ce,this.setLogger=Te,this.log=Ee,this.error=Oe,this.warn=Ie,this.info=Ae,this.filter=Ot,this.indexOf=It,this.uniq=At,this.startsWith=Bt,this.endsWith=Ht,this.replaceAll=$t,this.upperCaseFirst=qt,this.removeNonPrintableChar=Jt,this.trim=Gt,this.makeArray=we,this.isEmptyObject=Wt,this.Path=new Nt,this.DOM=Yt,this.isWindow=xr,this.obj={customEvent:Re},this.addEventListener=ze,this.removeEventListener=Ye,this.stopPropagation=Ze,this.fireEvent=Ke,this.base64=ft,this.utf8=lt,this.btoa=dt,this.atob=pt,this.asyncQueue=Le,this.sizzle=ct,this.toggleWakeLock=Ct,this.getWakeLock=Tt,this.urlEncode=tr,this.urlDecode=rr,this.scriptOnload=cr,this.addAllCss=mr,this.getAllCss=vr,this.addCss=pr,this.getCss=dr,this.addScripts=hr,this.getScripts=lr,this.addScript=fr,this.getScript=ur,this.addJS=gr,this.addVBS=br}),[{key:"debug",get:function(){return ke.debug},set:function(e){ke.debug=e}},{key:"showConsoleError",get:function(){return ke.debug},set:function(e){ke.showConsoleError=e}}])}()),_r=wr.clone,Sr=wr.startsWith,kr=wr.each,Cr=wr.isString,Tr=/[#\/\?@]/g,Er=/[#\?]/g,Or={scheme:1,userInfo:2,hostname:3,port:4,path:5},Ir=new RegExp("^(?:([\\w\\d+.-]+):)?(?://(?:([^/?#@]*)@)?([\\w\\d\\-\\u0100-\\uffff.+%]*|\\[[^\\]]+\\])(?::([0-9]+))?)?(.+)?$");function Ar(e,t){return Cr(e)&&Cr(t)?e.toLowerCase()===t.toLowerCase():e===t}function Lr(e,t){return encodeURI(e).replace(t,(function(e){return"%"+function(e){return 1===e.length?"0"+e:e}(e.charCodeAt(0).toString(16))}))}var jr=function(){function e(t){if(Y(this,e),this.scheme="",this.userInfo="",this.hostname="",this.port="",this.path="",t instanceof e)return _r(t);e.getComponents(t,this)}return Q(e,[{key:"clone",value:function(){var t=new e,r=this;return kr(Or,(function(e,n){t[n]=r[n]})),t}},{key:"getScheme",value:function(){return this.scheme}},{key:"setScheme",value:function(e){return this.scheme=e,this}},{key:"getHostname",value:function(){return this.hostname}},{key:"setHostname",value:function(e){return this.hostname=e,this}},{key:"setUserInfo",value:function(e){return this.userInfo=e,this}},{key:"getUserInfo",value:function(){return this.userInfo}},{key:"setPort",value:function(e){return this.port=e,this}},{key:"getPort",value:function(){return this.port}},{key:"setPath",value:function(e){return this.path=e,this}},{key:"getPath",value:function(){return this.path}},{key:"isSameOriginAs",value:function(e){var t=this;return Ar(t.hostname,e.hostname)&&Ar(t.scheme,e.scheme)&&Ar(t.port,e.port)}},{key:"toString",value:function(e){var t,r,n,o,i,a=[],s=this;return(t=s.scheme)&&(a.push(Lr(t,Tr)),a.push(":")),(r=s.hostname)&&(a.push("//"),(i=s.userInfo)&&(a.push(Lr(i,Tr)),a.push("@")),a.push(encodeURIComponent(r)),(o=s.port)&&(a.push(":"),a.push(o))),(n=s.path)&&(r&&!Sr(n,"/")&&(n="/"+n),a.push(Lr(n,Er))),a.join("")}}],[{key:"getComponents",value:function(e,t){var r=(e=e||"").match(Ir)||[],n=t||{};return kr(Or,(function(e,t){n[t]=r[e]})),n}}])}(),Pr=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).Dynamsoft;Pr.LTS={},Pr.LTS._={createLtsInstance:function(e){var t,r,n,o,i,c,u,f,l,h,d,p,v,m,y,g,b,x,w,_,S,k,C,T,E=e.fetch||a.fetch,O=e.btoa||a.btoa,I=e.atob||a.atob,A=e.bd,L=e.pd,j=e.vm,P=e.hs,N=e.dt,D=e.dm,R=["https://mlts.dynamsoft.com/","https://slts.dynamsoft.com/"],M=!1,U=Dynamsoft.Lib.Promise.resolve(),F=e.lf,B=e.log&&function(){try{for(var t=arguments.length,r=new Array(t),n=0;n100&&o.errorCode<200&&(r=null,u=!0,f=!0)),t.next=10;break;case 8:t.prev=8,t.t0=t["catch"](1);case 10:case"end":return t.stop()}}),t,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}(),x.prev=13,x.next=16,E(R[0]+i,{headers:p,cache:e?"reload":"default",mode:"cors",timeout:1e4});case 16:return t=x.sent,x.next=19,d(t);case 19:x.next=23;break;case 21:x.prev=21,x.t4=x["catch"](13);case 23:if(r||t&&t.ok||u){x.next=32;break}return x.prev=24,x.next=27,E(R[1]+i,{headers:p,mode:"cors",timeout:3e4});case 27:t=x.sent,x.next=32;break;case 30:x.prev=30,x.t5=x["catch"](24);case 32:if(r||t&&t.ok||u){x.next=43;break}return x.prev=33,x.next=36,E(R[0]+i,{headers:p,mode:"cors",timeout:3e4});case 36:return t=x.sent,x.next=39,d(t);case 39:x.next=43;break;case 41:x.prev=41,x.t6=x["catch"](33);case 43:if(x.t7=s&&151==s.errorCode&&!g,!x.t7){x.next=56;break}return v.removeItem(m),v.removeItem(y),n=K(),a.cu=n,h=void 0,i="auth/?ext="+encodeURIComponent(O(JSON.stringify(a))),x.next=53,E(R[0]+i,{headers:p,mode:"cors",timeout:3e4});case 53:return t=x.sent,x.next=56,d(t);case 56:return function(){if(!t||!t.ok){var e;f&&v.setItem(y,""),s?111==s.errorCode?e=s.message:((e=s.message.trim()).endsWith(".")||(e+="."),e="An error occurred during authorization: ".concat(e,c?" [Contact Dynamsoft](https://www.dynamsoft.com/company/contact/) for more information.":" Contact the site administrator for more information.")):e=c?Q.publicTrialFailConnect:Q.failConnect;var r=Error(e);throw s&&s.errorCode&&(r.ltsErrorCode=s.errorCode),r}}(),x.next=59,t.text();case 59:if(b=x.sent,x.prev=60,x.t8=h||g,x.t8){x.next=70;break}return x.t9=v,x.t10=m,x.next=67,Z(JSON.stringify([n,o]));case 67:x.t11=x.sent,x.t9.setItem.call(x.t9,x.t10,x.t11),h=o;case 70:v.setItem(y,b),x.next=75;break;case 73:x.prev=73,x.t12=x["catch"](60);case 75:return x.abrupt("return",b);case 76:case"end":return x.stop()}}),k,null,[[13,21],[24,30],[33,41],[60,73]])})))(),new Dynamsoft.Lib.Promise((function(e,t){var n;n=c?Q.publicTrialNetworkTimeout:Q.networkTimeout,setTimeout((function(){return t(new Error(n))}),r?3e3:15e3)}))]);case 23:S=s.sent,r=S,s.next=30;break;case 27:s.prev=27,s.t3=s["catch"](0),d=s.t3;case 30:x=null;case 31:case"end":return s.stop()}}),s,null,[[0,27]])})))()),a.next=4,x;case 4:case"end":return a.stop()}}),a)})));return function(t){return e.apply(this,arguments)}}(),oe=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function a(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _||(_=_asyncToGenerator(_regeneratorRuntime().mark((function a(){var e;return _regeneratorRuntime().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(H(n),r){a.next=4;break}if(M){a.next=3;break}throw B(d.message),d;case 3:return a.abrupt("return");case 4:e={dm:D},A&&(e.bd=!0),e.brtk=!0,e.ls=R[0],P&&(-1!=P.indexOf("-")?e.hs=P:e.og=P),e.cu=n,i&&(e.fn=i),L&&(e.pd=L),t&&(e.v=t),N&&(e.dt=N),o&&(e.os=o),f&&(e.rmk=f),H(r);try{e.ar=r,e.bafc=!!d}catch(Dr){}return H(e),a.prev=8,a.next=11,W(e);case 11:a.next=16;break;case 13:a.prev=13,a.t0=a["catch"](8),H("error updl");case 16:return a.next=18,ie();case 18:M||(M=!0),_=null;case 20:case"end":return a.stop()}}),a,null,[[8,13]])})))()),e.next=3,_;case 3:case"end":return e.stop()}}),a)})));return function(){return e.apply(this,arguments)}}(),ie=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function t(){var e,r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=(new Date).kUtilFormat("yyyy-MM-ddTHH:mm:ss.SSSZ"),t.next=3,$();case 3:if(r=t.sent,H(r),!(r&&r=102&&d.ltsErrorCode<=120)&&ue(null,!0),a.abrupt("return",{ar:r,cu:n});case 31:case"end":return a.stop()}}),fe)}))),function(e){return T.apply(this,arguments)}),ih:re,c:(C=_asyncToGenerator(_regeneratorRuntime().mark((function le(){var e,t,r,n,o,i;return _regeneratorRuntime().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!((e=new Date).getTime()= _fetch_ver) { - return; - } - } - dynam._fetch_ver = _fetch_ver; - - if(win.fetch) { - return; - } - - var bIE6_9 = Dynamsoft.navInfoSync.bIE && (parseInt(Dynamsoft.navInfoSync.strBrowserVersion) <= 9), - bIE6_10 = Dynamsoft.navInfoSync.bIE && (parseInt(Dynamsoft.navInfoSync.strBrowserVersion) <= 10), - each = lib.each, - rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget)$/, - - STATE_READY = 1, - STATE_OK = 2, - STATE_ABORT = 3, - - OK_CODE = 200, - NO_CONTENT_CODE = 204, - MULTIPLE_CHOICES = 300, - NOT_MODIFIED = 304, - BAD_REQUEST = 400, - UN_AUTH_REQUEST = 401, - FORBIDDEN_REQUEST = 403, - NOT_FOUND_CODE = 404, - NO_CONTENT_CODE2 = 1223, - SERVER_ERR = 500, - ERR_NAME_NOT_RESOLVED = 12007, - ERR_CANNOT_CONNECT = 12029, - ERR_NO_RESPONSE = 2, - - _strOpenErr = 'open error: ', - _strSendErr = 'send error: ', - - simulatedLocation = new lib.Uri(location.href), - isLocal = simulatedLocation && rlocalProtocol.test(simulatedLocation.getScheme()), - XDomainRequest_ = false,//bIE6_9 && win.XDomainRequest, - - createStandardXHR = function () { - try { - return new win.XMLHttpRequest(); - } catch (e) { - } - // return undefined; - }, - - createActiveXHR = function () { - try { - var http = false; - // code for IE9,IE8,IE7,IE6,IE5 - each(['Msxml2.XMLHTTP.6.0', - 'Msxml2.XMLHTTP', - 'Microsoft.XMLHTTP', - 'Msxml2.XMLHTTP.3.0', - 'Msxml3.XMLHTTP'], - function (item) { - try { - if(!http){ - http = new win.ActiveXObject(item); - return false; - } - } - catch (e) { - lib.error('new xhr error: ' + e.message); - } - }); - return http; - } catch (e) { - } - // return undefined; - }, - - supportCORS = (!isLocal && win.XMLHttpRequest) ? ('withCredentials' in (createStandardXHR() || [])) : false, - - //Create a xmlHttpRequest object - _newXhr = win.ActiveXObject ? function (crossDomain) { - - if (bIE6_9) - return createActiveXHR(); - - if (!supportCORS && crossDomain && XDomainRequest_) { - return new XDomainRequest_(); - } - return !isLocal && createStandardXHR() || createActiveXHR(); - - } : createStandardXHR, - - isInstanceOfXDomainRequest = function (xhr) { - return XDomainRequest_ && (xhr instanceof XDomainRequest_); - }, - - rnoContent = /^(?:GET|HEAD)$/, - rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, - accepts = { 'xml': "application/xml, text/xml", 'html': "text/html", 'text': "text/plain", 'json': "application/json, text/javascript", "*": "*/*" }, - nilFun = nil, - nativeFetch; - - // IE<=8 fixed - if (bIE6_10) { - nilFun = function(){}; - } - - function _io() { } - - lib.mix(_io.prototype, { - - url: false, //URL to be loaded - onSuccess: false, //Function that should be called at success - onError: false, //Function that should be called at error - onComplete: false, - method: "GET", //GET or POST - async: true, // async or sync - xhrFields: false, - mimeType: false, - username: false, - password: false, - data: false, - dataType: 'text', //Return type - could be 'blob', 'arraybuffer', 'text', 'xml', 'json', 'user-defined'(which is used for acquiring image data from service) - headers: false, - contentType: 'application/x-www-form-urlencoded; charset=UTF-8', - beforeSend: false, - afterSend: false, - timeout: 0, // seconds default 0 means no timeout - cache: true, - crossDomain: false, - retry: 0, - - setRequestHeader: function (name, value) { - var self = this; - self.headers[name] = value; - return self; - }, getAllResponseHeaders: function () { - var self = this; - return self.state === STATE_OK ? self.responseHeadersString : null; - }, getNativeXhr: function () { - var self = this; - return self.nativeXhr; - }, getResponseHeader: function (name) { - var match, self = this, responseHeaders; - name = name.toLowerCase(); - if (self.state === STATE_OK) { - if (!(responseHeaders = self.responseHeaders)) { - responseHeaders = self.responseHeaders = {}; - while ((match = rheaders.exec(self.responseHeadersString))) { - responseHeaders[match[1].toLowerCase()] = match[2]; - } - } - match = responseHeaders[name]; - } - return match === undefined ? null : match; - }, overrideMimeType: function (type) { - var self = this; - if (!self.state) { - self.mimeType = type; - } - return self; - }, abort: function (statusText) { - var self = this; - statusText = statusText || "abort"; - - self.state = STATE_ABORT; - self.status = 0; - self.statusText = statusText; - - if (self.nativeXhr) { - self.nativeXhr.abort(); - } - - self._callback(); - return self; - }, _ioReady: function (status, statusText) { - var self = this, isSuccess = false; - if (self.state === STATE_OK || self.state === STATE_ABORT) { - return; - } - if (self.state === STATE_READY) - self.state = STATE_OK; - self.readyState = 4; - - if (status >= OK_CODE && status < MULTIPLE_CHOICES || status === NOT_MODIFIED) { - if (status === NOT_MODIFIED) { - statusText = "not modified"; - isSuccess = true; - } else { - statusText = "success"; - isSuccess = true; - } - } else { - if (status < 0) { - status = 0; - } - } - - try { - if (status >= OK_CODE) - self.handleResponseData(); - } catch (e) { - lib.error(e.stack || e, "error"); - statusText = e.message || "parser error"; - } - - - if (status < OK_CODE || !isSuccess) { - if(self.retry > 0) { - self.retry = self.retry - 1; - setTimeout(function(){ - self.sendInternal(); - }, 200); - return; - } - } - - self.status = status; - self.statusText = statusText; - self._callback(isSuccess); - }, - _callback: function (isSuccess) { - var self = this, timeoutTimer = self.timeoutTimer; - if (timeoutTimer) { - clearTimeout(timeoutTimer); - self.timeoutTimer = 0; - } - - each([isSuccess ? self.onSuccess : self.onError, self.onComplete], function (func) { - if (lib.isFunction(func)) { - func.apply(self.context, [self.responseData, self.statusText, self]); - } - }); - - self.responseData = null; - }, - handleResponseData: function () { - var self = this, result, dataType = self.dataType, nativeXhr = self.nativeXhr; - - self.responseText = result = nativeXhr.responseText || ''; - try { - var xml = nativeXhr.responseXML; - if (xml && xml.documentElement /*#4958#*/) { - self.responseXML = xml; - } - } catch (e) { } - - self.responseData = result; - }, - - sendInternal: function (opt) { - //The XMLHttpRequest object is recreated at every call - to defeat Cache problem in IE - var self = this, c, i, - method, url, dataType, contentType, - nativeXhr, xhrFields, mimeType, requestHeaders, - hasContent, sendContent; - - c = self._setup(opt); - - method = c.method; - if(lib.isString(method)) { - method = method.toUpperCase(); - } - - contentType = c.contentType; - - url = c.url; - dataType = c.dataType; - mimeType = c.mimeType; - - if (!lib.isString(url)) return; - - self.nativeXhr = nativeXhr = _newXhr(c.crossDomain); - if (!nativeXhr) return; - - try { - self.state = STATE_READY; - - if (c.username) { - nativeXhr.open(method, url, c.async, c.username, c.password); - } else { - nativeXhr.open(method, url, c.async); - } - - if ((c.async || Dynamsoft.navInfoSync.bIE) && dataType && dataType != 'user-defined' && ('responseType' in nativeXhr)) { - try { - nativeXhr.responseType = dataType; - } catch (e) { } - } - - } catch (ex) { - if (self.state < 2) { - lib.error(ex.stack || ex, "error"); - self._ioReady(-1, _strOpenErr + - (lib.isNumber(ex.number) ? '(' + ex.number + ')' : '') + - (ex.message || '')); - } else { - lib.error(ex); - } - - return; - } - - xhrFields = c.xhrFields || {}; - if ('withCredentials' in xhrFields) { - if (!supportCORS) { - delete xhrFields.withCredentials; - } - } - - each(xhrFields, function(val, key){ - try { - nativeXhr[key] = val; - } catch (e) { - lib.error(e); - } - }); - - // Override mime type if supported - if (mimeType && nativeXhr.overrideMimeType) { - nativeXhr.overrideMimeType(mimeType); - } - - requestHeaders = c.headers || {}; - var xRequestHeader = requestHeaders['X-Requested-With']; - if (xRequestHeader === false) { - delete requestHeaders['X-Requested-With']; - } - - // ie<10 XDomainRequest does not support setRequestHeader - if ('setRequestHeader' in nativeXhr) { - - if (contentType) { - nativeXhr.setRequestHeader("Content-Type", c.contentType); - } - - nativeXhr.setRequestHeader("Accept", dataType && accepts[dataType] ? accepts[dataType] + (dataType === "*" ? "" : ", */*; q=0.01") : accepts["*"]); - - - each(requestHeaders, function(val, key){ - nativeXhr.setRequestHeader(key, val); - }); - } - - if(!c.cache) - { - nativeXhr.setRequestHeader('If-Modified-Since', '0'); - nativeXhr.setRequestHeader('Cache-Control', 'no-cache'); - } - - - hasContent = !rnoContent.test(c.method); - sendContent = hasContent && c.data || null; - - if (hasContent && bIE6_9) { - sendContent = c.data; - } - - // timeout - if (c.async && c.timeout > 0) { - if(c.timeout<300) - c.timeout=300; - self.timeoutTimer = setTimeout(function () { - self.abort("timeout"); - }, c.timeout); - } - - try { - self.state = STATE_READY; - if (lib.isFunction(self.beforeSend)) { - var r = self.beforeSend(nativeXhr, self); - if (r === false) { - self.abort("cancel"); - return; - } - } - nativeXhr.send(sendContent); - sendContent = null; - c.data = null; - if (lib.isFunction(self.afterSend)) - self.afterSend(self); - } catch (e) { - if (self.state < 2) { - lib.error(e.stack || e, "error"); - self._ioReady(-1, _strSendErr + (e.message || '')); - } else { - lib.error(e); - } - } - - if (!c.async || nativeXhr.readyState === 4) { - self._xhrCallback(); - } else { - if (isInstanceOfXDomainRequest(nativeXhr)) { - nativeXhr.onload = function () { - nativeXhr.readyState = 4; - nativeXhr.status = OK_CODE; - self._xhrCallback(); - }; - nativeXhr.onerror = function () { - nativeXhr.readyState = 4; - nativeXhr.status = SERVER_ERR; - self._xhrCallback(); - }; - } else { - nativeXhr.onreadystatechange = function () { - self._xhrCallback(); - }; - } - } - }, - - _xhrCallback: function (evt, abort) { //Call a function when the state changes. - var self = this, nativeXhr = self.nativeXhr; - - try { - if (nativeXhr.readyState === 4 || abort) { //Ready State will be 4 when the document is loaded. - if (isInstanceOfXDomainRequest(nativeXhr)) { - nativeXhr.onerror = nilFun; - nativeXhr.onload = nilFun; - } else { - nativeXhr.onreadystatechange = nilFun; - } - - if (abort) { - if (nativeXhr.readyState !== 4) { - nativeXhr.abort(); - } - } else { - - if (!isInstanceOfXDomainRequest(nativeXhr)) { - self.responseHeadersString = nativeXhr.getAllResponseHeaders(); - } - - var status = nativeXhr.status, statusText; - try { - statusText = nativeXhr.statusText; - } catch (e) { - lib.error("xhr statusText error: "); - lib.error(e); - statusText = ""; - } - - self._ioReady(status, statusText); - } - } - - } catch (e) { - lib.error(e.stack || e, "error"); - - nativeXhr.onreadystatechange = nilFun; - if (!abort) { - self._ioReady(-1, e.message || "process error"); - } - } - }, - - _setup: function (opt) { - var self = this, dataType, i, requestHeaders, url, uri; - - if(opt) { - self.context = opt.context; - delete opt.context; - - if (opt instanceof _io) { - opt = opt.config; - } - - self.config = opt; - - url = opt.url; - - if (lib.startsWith(url, 'http://') || lib.startsWith(url, 'https://')) { - uri = new lib.Uri(url); - } else { - if (lib.startsWith(url, '//')) { - opt.url = url = 'http:' + url; - } - - uri = simulatedLocation.resolve(url); - } - - if (!opt.dataType) - dataType = 'text'; //Default return type is 'text' - else - dataType = opt.dataType.toLowerCase(); - opt.dataType = dataType; - - if (!opt.method) - opt.method = 'GET'; //Default method is GET - else - opt.method = opt.method.toUpperCase(); - - if (!("crossDomain" in opt)) { - opt.crossDomain = !uri.isSameOriginAs(simulatedLocation); - } - - requestHeaders = opt.headers; - for (i in requestHeaders) { - if (lib.isUndefined(requestHeaders[i])) - delete requestHeaders[i]; - } - lib.mix(self, opt); - } - - self.state = STATE_READY; - return self; - } - }); - - // Chrome or Firefox - if(!nativeFetch) { - - // fetch - win.fetch = function(url, options){ - - // options - // { - // mode:"cors", // mode: cors / no-cors / same-origin - // method:"post", - // body:'', - // headers:{ - // // set send data type for body - // 'content-type': 'application/json' - // }, - // dataType: 'blob', // Return type - could be 'blob', 'arraybuffer', 'text', 'json' - // // NOTE: IE<=9 'blob', 'arraybuffer' -> 'user-defined' - - // cache:'reload', // (not supported) http cache: default / no-store / reload / no-cache / force-cache / only-if-cached - // redirect: 'manual', // (not supported) redirect: follow / error / manual - // referrer: 'client', // (not supported) no-referrer / client / URL (string) - // credentials:'include' // (not supported) if carry cookie: omit/ same-origin / include - // }; - - return new Dynamsoft.Lib.Promise(function(resolutionFunc,rejectionFunc){ - - var get_ret_obj = function(_bOK, _data, _reason, _io){ - - return { - 'ok': _bOK, - 'text': function() {return Dynamsoft.Lib.Promise.resolve(_data);}, - 'json': function() { - var _json; - if(Dynamsoft.Lib.isString(_data) && _data != '') { - try{ - _json = Dynamsoft.Lib.parse(_data); - }catch(_ex){ - return Dynamsoft.Lib.Promise.reject({ - code: -2443, - message: 'License server response data error.' - }); - } - } else { - _json = {}; - } - return Dynamsoft.Lib.Promise.resolve(_json); - } - }; - - }, sFun = function(_data, _reason, _io){ - - resolutionFunc(get_ret_obj(true, _data, _reason, _io)); - - }, fFun = function(_data, _reason, _io){ - var reason = _reason, status = _io.status; - - if(status == NOT_FOUND_CODE || status == BAD_REQUEST || status == FORBIDDEN_REQUEST || status == UN_AUTH_REQUEST ) { - - resolutionFunc(get_ret_obj(false, _data, _reason, _io)); - - return; - } else if(status == ERR_NAME_NOT_RESOLVED || status == ERR_CANNOT_CONNECT || status == ERR_NO_RESPONSE) { - reason = 'NetworkError'; - } else { - var isStr = Dynamsoft.Lib.isString(reason); - if(!isStr || isStr && reason == '') { - reason = 'NetworkError'; - } - } - - rejectionFunc({ - 'ok': false, - 'code': status, - 'message': reason, - 'httpCode': status, - 'errorString': reason - }); - }, cfg = { - - url: url, - onSuccess: sFun, - onError: fFun, - contentType: 'text/plain;charset=UTF-8', - dataType: 'text' - - }, bContentTypeInHeaders = false; - - if(options) { - - if(options.method) { - cfg.method = options.method; - } - - if(options.body) { - cfg.data = options.body; - } - - if(options.headers) { - if (!cfg.headers) { - cfg.headers = {}; - } - - each(options.headers, function(val, key){ - if(key.toLowerCase() == 'content-type') { - bContentTypeInHeaders = true; - } - - cfg.headers[key] = val; - }); - - } - - if(options.dataType) { - cfg.dataType = options.dataType; - } - - if(options.contentType) { - cfg.contentType = options.contentType; - } - } - - if(bContentTypeInHeaders) { - cfg.contentType = false; - } - - if(cfg.dataType == 'blob' && bIE6_9) { - cfg.mimeType = 'text/plain; charset=x-user-defined'; - } - - if (!cfg || !lib.isString(cfg.url)) { - lib.log('the url is error.'); - return; //Return if a url is not provided - } - - var self = new _io(); - self.sendInternal(cfg); - }); - }; - } - -})(Dynamsoft); diff --git a/samples/dwt-mrz/Resources/src/dynamsoft.webtwain.css b/samples/dwt-mrz/Resources/src/dynamsoft.webtwain.css deleted file mode 100644 index 61ac94c..0000000 --- a/samples/dwt-mrz/Resources/src/dynamsoft.webtwain.css +++ /dev/null @@ -1,1399 +0,0 @@ -/*! 20240828 - 20240320 -* Product: Dynamic Web TWAIN -* Web Site: https://www.dynamsoft.com -* -* Copyright 2025, Dynamsoft Corporation -* Author: Dynamsoft Support Team -* Version: 19.0 -*/ -.dynamsoft-major-color { - color: #50a8e1; -} - -#dwt-btn-install a:link { - color: #fe8e14; -} - -dialog[open]{display:block} -dialog[closed]{display:none} - -.ds-dwt-ui-dlg a:link,.ds-dwt-ui-dlg a:visited, -.dynamsoft-dialog-license a:link,.dynamsoft-dialog-license a:visited -{ - color: #50A8E1 -} - -.dynamsoft-backdrop { - position: fixed; - background: rgba(128, 128, 128, 0.1); - top: 0; - bottom: 0; - left: 0; - right: 0; - z-index: -99999999; -} - -/* progress bar */ - -.dynamsoft-desc{ - margin:7px 0; - color:#3a3a3a; - font: 14px/22px Arial, sans-serif; -} - -.dynamsoft-finalMessage { - margin: 0 0 15px 0; - color: #3a3a3a; - font: 22px/26px Arial, sans-serif; - height: 14px; -} - -.dynamsoft-status { - color: #555; - font: 14px/22px Arial, sans-serif; - margin: 0 0 5px 0; -} - -.dynamsoft-progressBar { - width: 100% !important; - margin-bottom: 12px; - height: 14px; - background-color: #e7e7e7; - border-radius: 7px; -} - -.dynamsoft-progressBar::-webkit-progress-bar { - border-radius: 7px; - background-color: #e7e7e7; -} - -.dynamsoft-progressBar::-webkit-progress-value { - background-color: #50a8e1; - border-radius: 7px; -} - -.dynamsoft-progressBar::-moz-progress-bar { - background-color: #50a8e1; - border-radius: 7px; -} - -.progressbar_background { - width: 100% !important; -} - -.dynamsoft-btnCancel { - color: #999; - font: 14px/22px Arial, sans-serif; - border: 1px solid #ccc; - background-color: #fff; - border-radius: 3px; - padding: 2px 8px; - min-width: 75px; - cursor: pointer; -} - -.dynamsoft-btnCancel:focus { - outline: none; -} - -.dynamsoft-btnCancel:hover { - color: #555; - box-shadow: 0 1px 2px rgba(0, 0, 0, .06); -} - -/* Image Editor */ - -.dynamsoft-dwt-noPadding { - padding: 0; -} - -.dynamsoft-dwt-noPaddingnoMarginInside>div { - padding: 0; - margin: 0; - box-sizing: border-box; -} - -.dynamsoft-dwt-thinborder { - border: solid 1px #AAAAAA; -} - -.dynamsoft-dwt-notdisplayed { - display: none; -} - -.dynamsoft-dwt-displayed { - display: ''; -} - -.dynamsoft-dwt-container-box { - background-color: white; -} - -/* toolbar */ - -.dynamsoft-dwt-viewerToolbar { - background-color: lightgray; -} - -.dynamsoft-dwt-viewerToolbar>ul { - padding: 0; - margin: 0; - list-style: none; -} - -.dynamsoft-dwt-viewerToolbar>ul>li { - padding: 0 0 0 2px; - margin: 0; - float: left; - z-index: 1; -} - -.dynamsoft-dwt-viewerToolbar img { - cursor: pointer; -} - -.dynamsoft-dwt-imgTag { - position: absolute; - left: 0; - top: 0; - padding: 0; - padding-top: 2px; - text-align: center; - z-index: 1; -} - -.dynamsoft-dwt-imgTag_Normal { - color: black; - border: 1px solid #CCCCCC; - background-color: white; - z-index: 1; -} - -.dynamsoft-dwt-imgTag_Selected { - color: #FFFFFF; - background-color: #7DA2CE; - border: 1px solid #7DA2CE; - z-index: 1; -} - -.dynamsoft-dwt-EditorButton-selected { - background-color: #666; - box-shadow: -3px -3px 2px -2px inset #b7aaaa, 2px 2px 2px 0px inset #000000; -} - -.dynamsoft-dwt-dlg { - padding: 15px; -} - -.dynamsoft-dwt-dlg-header { - padding: 10px 10px 0 0; - height: 38px; - position: relative; -} - -.dynamsoft-dwt-dlg-title, .dynamsoft-dwt-dlg-title-error { - text-align: center; - height: 24px; - font-size: 20px; - font-family: OpenSans,"Segoe UI",SegoeUI,"Helvetica Neue",Helvetica,Arial,sans-serif; - line-height: 32px; - padding: 10px 0 10px 0; -} - -.dynamsoft-dwt-dlg-title-error { - color: #323234; -} -.dynamsoft-dwt-dlg-title-error { - color: red; -} - -.dynamsoft-dwt-dlg-error { - text-align: center; - font-size: 16px; - line-height: 26px; - padding: 15px; -} - -.dynamsoft-dwt-dlg-tips { - font-family: OpenSans,"Segoe UI",SegoeUI,"Helvetica Neue",Helvetica,Arial,sans-serif; - text-align: center; - color: #606060; - font-size: 16px; - line-height: 26px; - padding: 15px; - margin-bottom: 20px; -} - -.dynamsoft-dwt-dlg-errorIcon { - display: inline-block; - width: 80px; - height: 80px; - background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDY3IDc5LjE1Nzc0NywgMjAxNS8wMy8zMC0yMzo0MDo0MiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NUE2NTI3QTZDREJCMTFFN0I5QzRGMjk2QjIzMDhBMjAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NTUyMzI2Q0NDREJGMTFFN0I5QzRGMjk2QjIzMDhBMjAiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo1QTY1MjdBNENEQkIxMUU3QjlDNEYyOTZCMjMwOEEyMCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo1QTY1MjdBNUNEQkIxMUU3QjlDNEYyOTZCMjMwOEEyMCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pja+KokAAAoESURBVHja7J17cFTlFcDPvXsTQkJSDRAIeUKiklADVoUBGWtToIzITH0x6IBDVfyjpdPSaS3a2j9aa1vr1HHkj/oIZcRHm06rM6CoPFQGdYi0GgpYbIJuHjxCQJuQkNfu7Tn3frtdkt39zt39bvbujmfmTNjw3d3v/PI9zjnfY7We3vOQQpmCehXqFaizxc8S1MmouaiTUIdQqZJfiJ9dqMdQ/y1+fojanSoDtHEGSFC+iVqP+g3UOqpDku9poh5CfQt1L+oe1P5MAqijLkVdh7oSNc/lz+tD3Y66FXUXajBdAVL3uxf1B6iVKephn6E+gfqs6P5pAXAi6gbU+8UY5wWhMfL3qE+iXvAywNWov0MtB29KG+pPUf+scnxSIRWoO1Ff8jA8EHWjOr4u6uwJgGvELLgc0ke+Jeq8JpUAc1AbULehFkD6SYGo+xZhy7iOgUWor6AuTNqMwQsQ9B8D83Q7mGdPgdl9EufLL8C8gK7c8KBdJmsCaDnoQuZfAtqUYtAmTwdtWhnoFeh3T5ioAub7qN8WTrrrAGcK/6oqYc/38y4IHnofgi2HwDyBnoaZoKum6aDNqAS9ug70uoWgXVqUDMRW4a9+6ibAGtTdqDOcUwtC8EgTBD7YC2Z7iwgglDoUoJVVg+/aetDnzLfgJiAnUJegfuwGwGoRLpU6BvfRfgi8+yqY57rGZXDTCovAd90K0OctTgRkhwgzW1QCnIr6noDIZ9d5HEZeew7Mk/7UBPrFFWDceBdoJbOcPkrwFqGeUQEwG3Uf6gL2x48MQWBXIwQOYmxvmpBS0TTwXVMPvqWrAIxsJ08eQP06TXPJAqQ48h52q8OZdOSvm8Hs6vSUz6IVlYBx+wZrBncgDSKeTxjgGuErsST46VEYadxsuSaeFHSFjNu/B/rMWidPrUV9PhGAFcJbZznJwaMfwMjLTwMERrztPvsMMG6+D/Taa7lP9ICdt/Q7jUSecgTvb3/0PjwSrCPVlersIGJ5ymkot1rEi4xu+7Hd8swgpI1gXanOVHcHsfMdXIC5IiXFmzAan0yPlhetJWLdyQam/FawkQLcwEpJoatCs61nJwxmHG7ZMDzEKV0u2MQFSGn4n7BcvTf/4jlXJaHejDYEdjdyi98vGMUE+B1gpOFN/zEIHnwLMkXI4Tc7WjlFJwtGUQHSvzfKZw0cgHducyEZkMpmaGLIuY07Ef4oklskwKUiVRWfX/P+jOi6Yxie8qNt73KKVqIuiwZwHaf1Bfa/Cpkqgf07LBsZsm40QJqeV0r5HTlgJUMzVSjdFjzaxCl6E4gNAiGAy4CxYyDQtBsyXQIHdnGK5YkhLwxQuqJmnjlh5fcyXchG8wxrjF8eCbCe033dEKO4AvLXbAQtawL7GS1nIhTc/QAYZdWu1ImWHhhSHwJIKzGXSd+09bB6eDMqoeC+X0B23ULIv3sTCyKtzhXc8yBkzb4KCtb/HIzyy9QD5NlKH1xEAL8mLTrQb6+eqYa3/iHQ8vKt11lVc6QQbXjY8mg5M/T63p8ph2jZOsDaIXc1AZwn/Yu0/Ud5tiV3xdowvJDEgxhqeSF4kb/PXXKb8myNZbNc5hJA6UBinm5T3k16X3gcRjrHLsFaELGVRUIMt7SKy8fG5BhW9r74hPrJhGdztc6JPqzdAqor2H8eep75VXSIs2oR4oMWxHjdlOD1NDwC5oD6DalMm2cRQOkiuXnutDsuA0F8+pcxINZYEOXw3EmnMW0uJoCF0mI9n7vnd13osyF2HI8KMSq8z9yF58DmQgIo3Z1jupw0tSBSd+6QO+oWvC0uw7NsZg0LuQQwX1psaMD9CIABcVxaXtjmQU6pSQRwCLwi1i4GM85/B8dvp4PPYBUjgL3SUtk5rtdXm5iHUclDYJTG3jWXNbMGJxWcncehPkybz7MAamo2McaHR2FZqXzLoVE524bodp0msAD281pgwaUuw4ve8oZpzTnKWoUFkZxtNyHmsfYUnCOA8i1chdNchjcrKrzeht+gi4MTS3ssiO61RKbNpwigdEsr7UtOBTwTZ3+KMqzZub0lCsQrbIg56iEybW4lgNKdmNo09Uc/KAcYG94jFrzw7GtBfDgmxPw7f6geIM/mFgL4kXSqpmhA05VWsP+1F6xQ7iJ4x0PwxvpgYYijsiT0+/49f1dMT7dtlsshovJPaTEM6Gk3vEqh+Je6ptnf+394W6LDuwjis78OQ7ReY1enuFgpP7I1J5dT9CAB7OJ0Y736SuXdxIb4MAwdborZ8mJBHP6k2YpKVMOzbK1i2Up/xa5Qv9wrfdMrac+15grE3uceA3N4kP1MuCX6P3Fj/gW9bhGn4N5QJEKyUz6tF4FWVgWZLmQj2cqQ1yMB0mJonzQ8vKY+4wEybewTzMIA6Rc7pN14zoJkj1N5u/VhyyMbGbIj1OAifZOt8tFVB9/iFZnb+hbfZNnIkK2R2ZiQvAn2HQPxGc5bDNr08sxrfWiTPvc6TlG/YDUGIK1b/oHjZNLxKToBlDn0NGETq/U9DhE3gYx+4k+oZ6WfV1qVURMK2aKVsjwMYtNwUY8cVYBiq0dZH7pkFWhTZ2RA160A37LV3OKPwqjrU6K12c1g324RX7KywVj1fVUnxlMjWHfjtu9y0/dtgg3IANJy1CbWX2/ydBsic/3AW/3WsOrOdJpJHoAoV0rFGjXpapA3WHHjzBowbl6vPFvjbr/VrTpT3ZlCs+6LUd8qzmFDSr80A/e83JEmGHnlmTQ5bIjwaudzn6DDhrQBK2riOV6zIZ9wAzuDMWc+GHds9PaYSGMe1tEBPBAMYmbt3Tlw3biZu012/Hrt1BIc8xwfuN4is50DkPaZvQNOjvwPD1nHpzx15B/dLvIcHAjtab4BdSBZgCSJXTrR0WqdAKJDLKny8Ywb13Kd5EhReulESAje22Bf0cmXIF17sg8C+7aD2XNufMAVFILv+pUYt1/PTQ5ESqdoeUqvPQlJjXBvyhxbhbNz8PABCPzjbXGwT33X1kqrwXf1DaB/dUGivmk72IerXbl4JyQEj7KxtYkaal391PweBFuawTzZltzVT8XloFfPBX3uomRzlUfBPvvR7qgKCV4+Rpsyt4txIjkZ6LcvHzvpB7O7E+F2A/T9N/rlY5O+gpCmgDalxLpUx7p8jLd6JhMa3+mom+MxJpkbLGl2fsyJr+hRofj2xyC5YCem/5vEB9MHYiAMt4B9x3O6CdX5VmHDYKJvoiKAfVmEOm+kETyqK10AnvSWBlUZAL8YgO8ETiosddIm6rgcGMsX4wkwMotDV7rTTbndHgJHddkk6vaSUtfJxYu480Uc6YWLuCkN3+vGB3x5FXwaAIyU0JcRkNItkbSLR8WXEfwL7Ns190AGfhmBLElBs+HlMPbrMPIiWmuf0LMiVg19HQbtLvqQE/S7Jf8TYAA228oDMYgKogAAAABJRU5ErkJggg==) no-repeat; -} - -.dynamsoft-dwt-dlg-tail { - text-align: center; - color: #606060; - background-color: #F5F5F5; - font-family: OpenSans,"Segoe UI",SegoeUI,"Helvetica Neue",Helvetica,Arial,sans-serif; - font-size: 14px; - line-height: 24px; - padding: 20px; -} - -.dynamsoft-dwt-dlg-red { - color: #CC5A4A; - margin: 5px 0; -} - -.dynamsoft-dwt-dlg-center { - text-align: center; -} - -.ds-download-div { - text-align:center -} - -.dynamsoft-dwt-dlg-button, .ds-download-div>a:link { - display: inline-block; - margin: 20px auto; - cursor: pointer; - text-align: center; - width: 117px; - background: #FE8E14; - border-radius: 3px; - font-size: 14px; - font-family: OpenSans,"Segoe UI",SegoeUI,"Helvetica Neue",Helvetica,Arial,sans-serif; - color: #FFFFFF; - line-height: 36px; -} - -.dynamsoft-dwt-dlg-button:hover, .ds-download-div>a:hover { - background-color: #FFAE37; -} -.ds-dwt-ui-dlg .ds-download-div a:visited, .ds-dwt-ui-dlg .ds-download-div a:visited { - color: #FFFFFF; -} - -.dynamsoft-dwt-dlg-button-android { - margin: 10px 0 0 0; - cursor: pointer; - text-align: center; - width: 117px; - background: #323234; - font-size: 14px; - font-family: Oswald,"Segoe UI",SegoeUI,"Helvetica Neue",Helvetica,Arial,sans-serif; - color: #FFFFFF; - line-height: 36px; -} - -.dynamsoft-dwt-dialogProgress { - max-width: 330px; - width: 80% -} - -/* dialog/mask body */ - -.ds-dwt-ui-showdlg { - font-family: OpenSans,"Segoe UI",SegoeUI,"Helvetica Neue",Helvetica,Arial,sans-serif; - color: #444444; - font-size: 14px; - line-height: 24px; - margin: 0 auto; - padding: 0; - border: 1px solid #e7e7e7; - background-color: white; -} - -.ds-dwt-ui-dlg-license-wrap, .ds-dwt-ui-dlg-wrap { - font-family: OpenSans,"Segoe UI",SegoeUI,"Helvetica Neue",Helvetica,Arial,sans-serif; - color: #606060; - font-size: 14px; - line-height: 23px; - width: 510px; - height: 272px; - padding: 0; -} - -.ds-dwt-ui-dlg-android -{ - padding:0 20px 20px 20px -} - -.ds-dwt-ui-dlg-android a:link,.ds-dwt-ui-dlg-android a:visited -{ - color: #FE8E14 -} - -.ds-dwt-ui-dlg .dynamsoft-dialog-close -{ - width: 16px; - height: 16px; - background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAqElEQVQ4jY3RsQ3CMBBA0ceJKiNAzTSwAbRhhQxDCyPANGnDCLTQOBKy7MQu7bwvO7cZhqHDGU+8ta0djnhEwgdc00ELviZzCbzwQdcQmXGXzDMw4dYQyfENU6TDtUgRQ/x9VIrslzBss2vOkT6BPu0XcX6D2k2quBaAb+NeMZC/eXE6eaD0wxZHHCt4sjLiWMHzqkaiAS9F9oFTA65FjoE7xgacR0bcf5DfTZ6fKnj6AAAAAElFTkSuQmCC) no-repeat; -} - - -.ds_license_header { - color: #323234; - font-size: 20px; - padding: 40px 15px 15px 15px; - text-align: center; -} - -.ds_license_l1 { - margin: 0 45px 20px 45px; - padding: 0; -} - -.ds_license_l2 { - color: #777777; - padding: 23px 30px; - height: 110px; - background-color: #F8F8F8; - text-align: center; -} - -.dynamsoft-dialog { - font-family: OpenSans,"Segoe UI",SegoeUI,"Helvetica Neue",Helvetica,Arial,sans-serif; - color: #323234; - font-size: 16px; - line-height: 24px; - background-color: #FFFFFF; - margin: 0 auto; - border: 0; - padding: 0; - width: auto; -} - -.dynamsoft-dialog a, .ds-dwt-ui-showdlg a { - text-decoration: none -} - -.dynamsoft-dialog ul, .ds-dwt-ui-showdlg ul { - margin: 10px 0 10px 20px; - padding-left: 10px; - list-style-type: disc -} - -.dynamsoft-dialog-wrap { - position: fixed; - left: 0; - top: 20%; - width: 90%; - pointer-events: none; -} - -.dynamsoft-dialog .dynamsoft-dwt-dialog-body{ - border: 1px solid #CCC; -} - -.dynamsoft-dialog-license .dynamsoft-dialog-close, -.dynamsoft-dialog-close, .dynamsoft-dwt-dlg-header .dynamsoft-dialog-close { - float: right; - background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDY3IDc5LjE1Nzc0NywgMjAxNS8wMy8zMC0yMzo0MDo0MiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NTUyMzI2RDNDREJGMTFFN0I5QzRGMjk2QjIzMDhBMjAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NTUyMzI2RDRDREJGMTFFN0I5QzRGMjk2QjIzMDhBMjAiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo1NTIzMjZEMUNEQkYxMUU3QjlDNEYyOTZCMjMwOEEyMCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo1NTIzMjZEMkNEQkYxMUU3QjlDNEYyOTZCMjMwOEEyMCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PuW+RZ4AAADASURBVHjafJJdCsIwEIQ3TfBOvnkQf1pN0SMJgr9vPYVPPZSQ1lmYyBKrga8byEx2tq3ruq4RkTk4gEGmVwWOoA94LMAaeNBOmFR8AlswC9xUrA5EY/IUa4oH2KkhgRqMPBB2kkKsNQUeJCPO1fGiO7urRoLJmk22001jZHEeqFyj/Fm2gw545hu7MtKG9SuSii9gxdqabjVNn6E9b1wacc4ci5mawBhZHIsPl0w3NQ1qeIIX2P/4NRIv0tq/BRgAFzc2Awl1/rQAAAAASUVORK5CYII=) no-repeat; - /*display: inline-block;*/ - width: 12px; - height: 12px; - margin: 3px; - cursor: pointer; -} - -.dynamsoft-dwt-overlay { - position: absolute; - z-index: 1000; -} - -/* old dialog styles */ - -.dynamsoft-dialog-body { - margin: 0; - padding: 15px; - background-color: #FFFFFF; - border: 1px solid #E7E7E7; -} - -.dynamsoft-dwt-box-title { - color: #323234; - font-family: OpenSans,"Segoe UI",SegoeUI,"Helvetica Neue",Helvetica,Arial,sans-serif; - font-size: 16px; - font-weight: bold; - clear: both -} - -.dynamsoft-dwt-red { - color: red; - margin-left: 5px -} - -.dynamsoft-dwt-installdlg-splitline { - width: 135px; - height: 1px; - background: #323234; - position: relative; - top: 34px; -} - -.dynamsoft-dwt-installdlg-iconholder { - margin: 40px 10px 10px 10px; - text-align: center; -} - -.dynamsoft-dwt-installdlg-text { - position: relative; - height: 11px; - font-size: 14px; - font-family: OpenSans,"Segoe UI",SegoeUI,"Helvetica Neue",Helvetica,Arial,sans-serif; - color: #323234; - line-height: 36px; -} - -#dwt-install-url-div { - text-align: center; - margin-top: 20px; -} - -.ds-dwt_dragdrop_helper { - background-color: rgb(251, 236, 136); -} - -.dynamsoft-dialog-selectsource { - font-size: 14px; - background-color: #eeeeee; - border: 2px solid #777777; - border-left: 2px solid #dddddd; - border-top: 2px solid #dddddd; - padding: 15px 20px 0px 20px; - min-width: 360px; - max-width: 480px; -} - -.dynamsoft-dialog-selectsource p { - padding: 0px; - margin: 0px; - font-weight: bold; -} - -#dynamsoft-dialog-selectsource-sourcelist { - height: 120px; - padding: 0px; - background-color: #ffffff; - border: 2px solid #777777; - border-right: 2px solid #dddddd; - border-bottom: 2px solid #dddddd; - overflow-y: auto; - overflow-x: hidden; - min-width: 260px; - -webkit-touch-callout: none; - /* iOS Safari */ - -webkit-user-select: none; - /* Safari */ - -khtml-user-select: none; - /* Konqueror HTML */ - -moz-user-select: none; - /* Firefox */ - -ms-user-select: none; - /* Internet Explorer/Edge */ - user-select: none; - /* Non-prefixed version, currently - supported by Chrome and Opera */ -} - -#dynamsoft-dialog-selectsource-sourcelist li { - cursor: pointer; - line-height: 22px; -} - -#dynamsoft-dialog-selectsource-sourcelist li:hover { - background-color: rgb(239, 246, 253); -} - -#dynamsoft-dialog-selectsource-sourcelist li.dynamsoft-dialog-selectsource-sourcelist-li-selected { - background-color: rgb(199, 222, 252); -} - -#dynamsoft-dialog-selectsource-sourcelist-ul { - list-style: none; - margin: 0px; - padding: 0px; -} - -.dynamsoft-dialog-selectsource-button-select, .dynamsoft-dialog-selectsource-button-cancel { - min-width: 90px; - height: 26px; - margin: 10px 10px 20px 0px; - line-height: 0; - cursor: pointer; -} - -@font-face { - font-family: "ds-dvs-ui-iconfont"; - src: url('data:application/x-font-eot;base64,kCwAAMArAAABAAIAAAAAAAIABQMAAAAAAAABAJABAAAAAExQAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAATlPhjwAAAAAAAAAAAAAAAAAAAAAAACQAZABzAC0AZAB3AHQALQB1AGkALQBpAGMAbwBuAGYAbwBuAHQAAAAOAFIAZQBnAHUAbABhAHIAAAAWAFYAZQByAHMAaQBvAG4AIAAxAC4AMAAAACQAZABzAC0AZAB3AHQALQB1AGkALQBpAGMAbwBuAGYAbwBuAHQAAAAAAAABAAAACwCAAAMAMEdTVUKw/rPtAAABOAAAAEJPUy8yPHlRYwAAAXwAAABWY21hcLDGE0UAAAK0AAAFdGdseWbzQuG+AAAInAAAHcBoZWFkGYInhwAAAOAAAAA2aGhlYQfeA/sAAAC8AAAAJGhtdHjglv/5AAAB1AAAAOBsb2Nh4BbZOAAACCgAAABybWF4cAFXAXwAAAEYAAAAIG5hbWWxutg0AAAmXAAAAuVwb3N0QJBe6gAAKUQAAAJ6AAEAAAOA/4AAXARE//3//gQCAAEAAAAAAAAAAAAAAAAAAAA4AAEAAAABAACP4VNOXw889QALBAAAAAAA2zHxxQAAAADbMfHF//3/fQQCA4MAAAAIAAIAAAAAAAAAAQAAADgBcAAVAAAAAAACAAAACgAKAAAA/wAAAAAAAAABAAAACgAeACwAAURGTFQACAAEAAAAAAAAAAEAAAABbGlnYQAIAAAAAQAAAAEABAAEAAAAAQAIAAEABgAAAAEAAAAAAAEEAwGQAAUACAKJAswAAACPAokCzAAAAesAMgEIAAACAAUDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBmRWQAQOYA72sDgP+AAFwDgwCDAAAAAQAAAAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAD//wQAAAAEAAAABAAAAAQA//0EAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABA4AAAQAAAAEBAAABAAAAAQAAAAEAAAABAAAAAQ9AAAEAAAABAAAAAQAAAAEAAAABAAAAAREAAAEAAAABAAAAAQAAAAEAAAABAD//wQA//4EAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAABQAAAAMAAAAsAAAABAAAAtAAAQAAAAABygADAAEAAAAsAAMACgAAAtAABAGeAAAASABAAAUACOYA5gvmD+Yh5iTmKeYx5jPmPuZF5kvmUeZY5lrmX+Zi5nXme+aK5qDmq+bA5yTnNOdM54noDugU6FfoduoS6ozrZevv72v//wAA5gDmAuYN5iDmJOYn5jHmM+Y+5kXmSOZR5ljmWuZf5mHmdeZ75ormoOar5sDnJOc050zniegO6BToV+h26hLqjOtj6+/va///AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAEgASABaAF4AYABgAGQAZABkAGQAZABqAGoAagBqAGoAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAHAAcAAAACYAKAApACoAHgA2ACwAGwAPABoADgAzAAQAAgA0ACEALQANAAwACwADAAoAJwAdAAcACAAUABUANQAcACUAIAAWADcABQAwADIAEQAfACMAEgAJADEABgAQACQAKwAZABcAGAAvAC4AIgABABMAAAEGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAqQAAAAAAAAANwAA5gAAAOYAAAAAJgAA5gIAAOYCAAAAKAAA5gMAAOYDAAAAKQAA5gQAAOYEAAAAKgAA5gUAAOYFAAAAHgAA5gYAAOYGAAAANgAA5gcAAOYHAAAALAAA5ggAAOYIAAAAGwAA5gkAAOYJAAAADwAA5goAAOYKAAAAGgAA5gsAAOYLAAAADgAA5g0AAOYNAAAAMwAA5g4AAOYOAAAABAAA5g8AAOYPAAAAAgAA5iAAAOYgAAAANAAA5iEAAOYhAAAAIQAA5iQAAOYkAAAALQAA5icAAOYnAAAADQAA5igAAOYoAAAADAAA5ikAAOYpAAAACwAA5jEAAOYxAAAAAwAA5jMAAOYzAAAACgAA5j4AAOY+AAAAJwAA5kUAAOZFAAAAHQAA5kgAAOZIAAAABwAA5kkAAOZJAAAACAAA5koAAOZKAAAAFAAA5ksAAOZLAAAAFQAA5lEAAOZRAAAANQAA5lgAAOZYAAAAHAAA5loAAOZaAAAAJQAA5l8AAOZfAAAAIAAA5mEAAOZhAAAAFgAA5mIAAOZiAAAANwAA5nUAAOZ1AAAABQAA5nsAAOZ7AAAAMAAA5ooAAOaKAAAAMgAA5qAAAOagAAAAEQAA5qsAAOarAAAAHwAA5sAAAObAAAAAIwAA5yQAAOckAAAAEgAA5zQAAOc0AAAACQAA50wAAOdMAAAAMQAA54kAAOeJAAAABgAA6A4AAOgOAAAAEAAA6BQAAOgUAAAAJAAA6FcAAOhXAAAAKwAA6HYAAOh2AAAAGQAA6hIAAOoSAAAAFwAA6owAAOqMAAAAGAAA62MAAOtjAAAALwAA62QAAOtkAAAALgAA62UAAOtlAAAAIgAA6+8AAOvvAAAAAQAA72sAAO9rAAAAEwAAAAAAWgC2APIBSgGaAfICDgIoAkoEMAR0BJIEwAUCBVgFkAXUBhQGTAZ6BqgG7gc6B6IH4gf2CBgISAhwCKII5gkwCWQJjgm6Ce4KEgo8Cm4KoArUCzgLkgu2DDAMaAygDSoNWg2YDbgN1g40DlYO4AAAAAMAAP+ABAADgAALABwANwAAERYAFzYANyYAJwYAFzQ+AjIeAhQOAiIuAjc0NT8CPgEeAQ8BITIWFAYHIRcWDgEiLwIFASHa2QEhBQX+39na/t87Q4CitaKAQ0OAorWigEPBAgTUCRoTAQmeAXYNEhIN/omfCQETGgrSBgGA2f7fBQUBIdnaASEFBf7f2luigENDgKK1ooBDQ4CiXQEBBwjgCgETGQuoEhsSAasLGRIK4gwAAAMAAP+ABAADgAALABwANwAAAQYABxYAFzYANyYAEw4BIi4CND4CMh4CFAYnNDUvAi4BDgEfASEiBhQWFyEHBh4BMj8CAgDa/t8FBQEh2tkBIQUF/t9jQKK1ooBDQ4CitaKAQ0N9AgXTChkUAQmf/ooOEhIOAXegCQETGgrSBwOABf7f2tn+3wUFASHZ2gEh/MlAQ0OAorWigENDgKK1ov8BAQcI4AoBExkLqBIbEgGrChoSCuIMAAAFAAD/gAQAA4AABAAMABAAFAAhAAABIREhESUVMzUzFSE1AxEhGQEhNSETJxEhESMRIREhETMXA0D8wAQA/gBAQP8AgAIA/gACAMCA/YCAAQABgF6hA4D8AAM+goCAwL/8gQEA/wABP0H+fwEBwP5AA4D/AAEAoQALAAD/fwQAA4AABQALABEAFwAbAB8AIwAnACsALwAzAAATMzUFETMRIxEhNSMBFTMVMxEDIxUhESMFIRUhNSEVISUhFSE1IRUhNSEVIQUhESEXMxUjTfP+wE1NAUDzAnPzTU3zAUBN/Q0CgP2AAoD9gAF/AQH+/wEB/v8BAf7//oEBQP7ATaamAzNNAf7B/oD+wE0Ds03zAUD8TU0BQBRNzU3PTcZNxk3zAUBNpgAAAAQAAP+zBAADTQAAAA0AIQAtAAABIx4CMj4BNy4BJw4BASMnIQcjDgEHER4BFyE+ATcRLgEBLgEnPgE3HgEXDgECAKQBK01WTSsBAlxGRlwCPKNd/sxdoys6AQE6KwM0KzoBATr+O22QAwOQbW2QAwOQAU0tSywsSy1FXQICXQFUZ2cBOiv9miw6AQE6LAJmKzr9aAOQbW2QAwOQbW2QAAAGAAD/gAPBA4AAFwAfACcAKwAvADMAAAEjNS4BJyEOAQcVIxUzER4BFyE+ATURMyU2NyEWFxUhAQYHISYnESEFMxEjEzMRIxMzESMDwOUBKR7+2h4pAeQ/ASweAm8fKT/9oQEKASYKAf7EAd0BCv2XCgECf/3mPDy9PDy8PDwDADQfLAEBLB80QP0IHygBASgfAvh0CwEBCzT8ywoBAQoC9X/9/wIB/f8CAf3/AAAAAAMAAAAABAACwAADAAcACgAAATMRIwEzESMnEQEDgICA/wCAgID+AALA/YACgP2AIAJA/uAAAAAAAwAAAAAEAALAAAMABwAKAAARMxEjATMRIyURAYCAAQCAgAEAAgACwP2AAoD9gCACQP7gAAIAAP+ABAADgAAJAA8AAAERFA4CIyESAAMXBxc3JwQAESEpF/xyCwJCYbq6KOPjA4D8chcpIREBswJC/mm7uinj4wAAFQAAAAAEAAISAAcACwAPABMAGwAsADwAUQBfAHwAhgCaAMIA5QEFARABJAE4AVUBXwFvAAATIxcHFTM1LwEzByMXIzczFyM1MycjNzMHMyczNyYiDgEdARQeAT4CPQE0JgcUDgEiLgE9ATQ+ATIeARUXLgEiBgc1IxUzNR4BMzI+AT0CJgcUDgEiJic1PgEyFhcVNyYiDgEdARQeATMyNjc1IxUUDgEiLgE9ATM1NCYHIzU0PgEyHgEVNyYiBgc1IxUzNT4BMhYdATM1NCYXJy4BNDYyHgEVNzQuAiMiBhUUFh8BHgEUBiIuATUHHgIyPgE0JjcmIg4BHQEUHgEyPgE9ASMHFAYiJj0BND4BMh4BHQEzNTQmFzQ9ATQmIgYVMzU0PgEyHgEdAQcOAhUUHgEyNjcXMycUDgEiJjQ+AT8CJiIGBzUjFTM1PgEyFh0BMzU0JjcmIgYHNSMVMzU+ATIWHQEzNTQmNyYiDgEdARQeATMyNj0BIxUUDgEiLgE9ATM1NCYHIzU0PgEyHgEVNyMiBgc1IxUzNT4BMx8BNevkHiX3KquuFYRrUhMsU87OB8EfGBmDGxnIBxcNBgYNFw0GBgkDBg0GAgIHDAYDSwIHCwgDDg4DBwQICQMBDgEDBwUCAgUHAwFCBRMLBAQKCgwKAQ8BBAYEAiADDBEBBAgDAUYCCwoEDw8DBQYDDwJXEwQDBgwGAw0EBwoHDA4FBRMGBwcMBgQOAQYNEgwHCjkFEwoDAwoTCgMNAQQIBAEEBwMCDQM9ChgMDwIDBwMBDAUJBQQHDAgBAg4RAwQGAwIFAwZIAwsJBA8PAgUHAg8COwMLCQQPDwIGBgIPAjYFEwsEBAsJDAsPAQMHBAIgAwwRAgMIAwE/AQUJBA8PAwUEBAQCEXhsNTNuY1VLNoUaFVZFRUEECRALLAsRCgEJEQssCxBLBgoFBQoGMwYJBgUKBgwFBwUDB20hAwQJEAgUCQUiBgoFAgE1AgIFBAobBAcPCxILDwcODAMFBAYDAwYFEQcLEBoEBwkDBAcFGQIFBAhSQgIDBQQ+QgQIFBEEBwsHBgoFAwgLCAMODAkMBREFCQ8HBwwGBAoPCAYMFA8cAwgOCxMKDgkHDAgGDgQDBwoaBwgEAwYGBQUJC0EEBCUNDQ0OBAQFAwQGBQYFAwcLBwUJBgkFDBMBBAIFCQUFAgQnAgUECFJCAgMFBD5CBAgDAgUECFJCAgMFBD5CBAgBBAcPCxILDwcODAMFBAYDAwYFEQcLEBoEBwkDBAcFGwUIDFI8BAQBAREAAAAAAv////8EAAMAABgAKQAAASM1LgEnISchDgEHERQXFjMhMjY3EzUuASU0NjsBFyEWFxUhIgcOAQcDA9Q4ARwU/nVg/rAUGwEJDRYDPA8SB3ABGPx5BwX0YAFwCwH9nAQDDBIDUAHgoBQbAVABHBX9XQ8MEBIOAYEJFh+zBQlQAQtkAQIRDP7VAAMAAP+ABAADgAADAAcACwAAAREhESUhESEBIREhA6D8wAOg/AAEAPxfA0D8wAMg/MADQGD8AAOg/MAAAAQAAP+ABAADgAADAAcACwAUAAABESERJSERIQEhESElAScBJwcXFjIDoPzAA6D8AAQA/F8DQPzAAWcBhlz+wKRY5gkaAyD8wANAYPwAA6D8wLQBiFv+vKRc5woACgAA/6AD4ANgAAMABwALAA8AEwAXABsAHwAjACcAAAERIRElIREhATMVIzczFSMlMxUjNTMVIxUzFSM1MxUjJTMVIyczFSMDmPzQA3j8QAPA/OLe3pZISAEISEje3t7eSEj++EhIlt7eAxj80AMwSPxAAohI3t7e3khIwEhI3t7e3kgABP/9/30EAAOAAA8AHQAqADEAAAEHBiIvASY0PwE2Mh8BFhQlAQcGFj8BATY0LwEmIgEmNDcBNjIWFAcBBiIHMxUHJzczA+RcCBMH3gcHXB1NHngc/jj98yoEIhnzAg0HB94HE/64CAgBNQgWEQj+zAkWUWCBPhdIAmRcBwfeBxMIXBwceB5MN/3y8xkiBCoCDQgTB94I/hgJFgkBNAgQFwn+zAigSRY+gQAAAAIAAP+9A8EDQAALACMAAAEOAQceARc+ATcuARM1IxUzByczNSMVJzcVMzUjNxcjFTM1FwH/vv4FBf6+v/0FBf0KolF3d1Gid3eiUXd3UaJ3A0AF/b+//QUF/b+//f3PUaJ3d6JRd3dSo3d3o1J3AAAKAAD/gAQAA4AAAwAHAAsADwATABcAGwAfACMAJwAAAREhESUhESEBMxUjNTMVIyUzFSMnMxUjETMVIzczFSMlMxUjNTMVIwOz/JoDs/wABAD8re3tTU0CWU1NoO3t7e2gTU39p01N7e0DM/yaA2ZN/AADU01N7e3t7U399E3t7e3tTU0AAAAABAAA/4AEAAOAAAsAFwAbAB8AAAEeARcOAQcuASc+ATcOAQceARc+ATcuAQEhFSEJATcBAZqNvAMDvI2OvAMDvI6u6AQE6K6u5wQE5/6FAZn+ZwL9/r82AUEDMwO8jo28AwO8jY68UATorq7nBATnrq7o/pFN/cABQTb+vwAAAAACAAD/5gOaAxoAFQAhAAAlJz4BNS4BJw4BBx4BFz4BNxcWMjY0AyEiJjQ2MyEyFhQGA5OILzUD3KWl2wUF26VLhDWIBhAN+/6ZCw4OCwFnCw4OCog0hEyl2gUF2qWm2gUBNC+IBw0QAYMMEQwMEQwABgAA/4AEAAOAAAMABwAKAA4AEQAVAAABESERJSERIQEnNxUzFSMlFwcnMxUjA7P8mgOz/AAEAP0ampqmpgHMmpqmpqYDM/yaA2ZN/AABgICAWkymgICmTAAAAAAGAAD/gAQAA4AAAwAHAAoADgARABUAAAERIRElIREhATcXIzMVIxMHJzczFSMDs/yaA7P8AAQA/YCAgKZMTKaAgFpMTAMz/JoDZk38AALmmpqm/tqamqamAAAAAAUAAP+ABAADgAALABcAGwAfACMAAAEeARcOAQcuASc+ATcOAQceARc+ATcuAQEhFSE3MxEjCQE3AQGajbwDA7yNjrwDA7yOrugEBOiurucEBOf+hQGZ/mekTU0CWf6/NgFBAzMDvI6NvAMDvI2OvFAE6K6u5wQE566u6P6RTfP+Z/5mAUE2/r8AAAAAAgAA/8wDtANWABUAMQAAJRcWFAYiLwEOASMuASc+ATceARcUBiUjDgEUFjsBFR4BMjY9ATMyNjQmJyM1NCYiBgcDGZIIExkKkTuPTbXxBATxtbbwBTX+amoOEhIOagESGxJrDhISDmsSGxIBlJEKGRMIkjI1BfC2tfEEBPG1TY/8ARIbEmsOEhIOaxIbEgFqDhISDgAAAAAGAAD/ggP+A34AFwAnAC8ANwA/AEcAABMhMh4CFREUDgIjISIuAjURND4CFw4BBxEeARchPgE3ES4BJwMzFSMVIzUzBSM1MzUzFSMFFSM1IzUzFQM1MxUzFSM1lALYHTUqFhYqNR39KB01KhYWKjUdHioBASkfAtgeKgEBKh5JSUlJSf26SUlJSQFHSEnakUhJ2gN+Fio1Hf0oHTUqFhYqNR0C2B01KhZJASoe/SgfKQEBKh4C2B4qAf5vSEnakUhJ2rZJSUlJAkZJSUlJAAAAAgAA/8ADwANAAA8AJAAABSEuAScRPgE3IR4BFxEOASUBNjQvASYiBwEnJiIPAQYUHwEWMgNg/UApNgEBNikCwCk2AQE2/j4BcAkJLgkaCv7UjAoaCS4JCdAKGkABNikCwCk2AQE2Kf1AKTbDAXAKGgkuCQn+1IwJCS0KGgrQCQABAAD/yAPEAlsABQAACQEnBwkBA0z+Xe93AWYCGgJa/l7veP6aAhoAAgAA/4AEAAOAAAAADAAAASEWABc2ADcmACcGAAIA/gAFASHa2gEhBQX+39ra/t8BgNr+3wUFASHa2gEhBQX+3wAAAAABAAAAAANbAscAHAAANxYyPwEXFjI2NC8BNzY0JiIPAScmIgYUHwEHBhSyEjMS9PQSMyQR9fQSJDMS9PQSMyQS9PQTHRIS9fQSJDMS9PQSMyQS9PQRJDMS9PQSMQAAAAACAAD/wAPAA0AADwATAAABIQ4BBxEeARchPgE3ES4BAyERIQNg/UApNgEBNikCwCk2AQE2Kf1AAsADQAE2Kf1AKTYBATYpAsApNvzhAsAAAAIAAP+ABAADgAALABcAAAUmACc2ADcWABcGABMnBycHFwcXNxc3JwIA2v7fBQUBIdraASEFBf7fJjTOzzTPzzTPzjTPgAUBIdraASEFBf7f2tr+3wLKNM/PNM/PNM/PNM8AAAACAAD/xgO8AzsAEAAtAAABLgEiDgIUHgIyPgI0JgMjFQ4BIiY9ASMiJjQ2OwE1NDYyFhcVMzIWFAYHAzpAobOhfkNDfqGzoX9DQ5u+ARIbEr4OEhIOvhIbEgG+DRISDQK5P0JCfqGyoH5DQ36gs6D+578NEhINvxIbEr4OEhIOvhIbEgEAAAAACAAA/7MEAANNAAMABwALAA8AEwAXABoAKAAAEyEVIREhFSEBMxEjATMRIwMhFSE1MxEjARElASM1LgEnIgcnNjMeAReaApn9ZwKZ/WcCTE1N/bRMTJoBZv6aTU0Cmv8AAmYzBKF2PjcXQkqNvQQBmk3+s00B0v49AcP+PQJXTQ792QOa/s2Z/mdndp4DGjMeA72OAAUAAP+ABAADgAACAAYACgAOABgAAAEzFQURIRElIREhEyUXBQERMxEhESEVIRECZs3+TP7OAX/+NAHMHQEXM/7q/eNNA2b+gAHNArPN5/7OATJN/jQCOfo5+gIA/jMBgPyaTQQAAAAAAQAA/4ADNwOAABQAAAkBBiIvASY0NwkBJjQ/ATYyFwEWFAMm/jkSLRE1EREBaf6XERE1ES0SAccRAVj+ORERNREtEgFqAWsRLRE1ERH+ORIsAAAAAgAA/38DtwOAAAYAGAAAAREWHwEWFwUUFjMhERQGIyEiJjURNDYzIQKSDQjpCAj+qSAXATcgF/0AFyAgFwHJAlsBDggI6QgNEhcg/aUXICAXA5IXIAAAAAIAAP+ABAADgAASABsAABkBPgE3IRYXARYUBwEGIicBLgETDgEUFjI2NCYBNikBmCgcAagcHP5oHkwe/lgND+ApNjZSNjYBiAGYKTYBARv+WB1NHv5oHBwBqA0kAYsBNlI2NlI2AAAAAQAAAAAEAAMAABEAAAEhJyEOAQcRHgEXIT4BNxEuAQOg/oCA/sApNgEBNikDQCk2AQE2AoCAATYp/cApNgEBNikBwCk2AAAAAQAA/4ADNwOAABQAABMBNjIfARYUBwkBFhQPAQYiJwEmNNoBxxItETUREf6XAWkRETURLRL+OREBqAHHERE1ES0S/pb+lREtETUREQHHEiwAAAAAAgAA/4AEAAOAABQAGAAACQEGIi8BJjQ3CQEmND8BNjIXARYGASMRMwJe/jkSLRE1EREBaf6XERE1ES0SAccRAQGSs7MBWP45ERE1ES0SAWoBaxEtETUREf45Eiz+FwP/AAAAAAIAAP+AA/8DgAAUABgAAAkBNjIfARYUBwkBFhQPAQYiJwEmNgEzESMBogHHEi0RNRER/pcBaRERNREtEv45EQH+brOzAagBxxERNREtEv6W/pURLRE1EREBxxIsAen8AQAAAAAFAAD/gAQAA4AAAgAGAAoADgAYAAABIzUDESERJSERIQEFJy0BETMRIREhFSERAunNnf7OAX/+NAHMAZr+6TMBFvzOTQNm/oABzQGtzv6E/s4BMk3+NAMn+jn6oP4zAYD8mk0EAAAAAAQAAP+ABAADgAAVACsANAA9AAABMx4BFxEzHgEHAQYiJwEmNjczETQ2ARUOAQchLgEnNT4BNyEXFjI/ASEeAQc0JiIGFBYyNjc0JiIGFBYyNgGwoBQbAa8cExL+zwwfDP7QEhMbsBwCZAEbFPxgFBsBARsUASViIFIgYgElFBv3FyIXFyIXgBciFxciFwOAARsU/rACLRX+0AwMATAVLQIBUBQb/RHgFBsBARsU4BQbAWIeHmIBG8QRFxciFxcRERcXIhcXAAAABAAA/4AEAAOAACMAJwAwADkAAAE1NC8BJiMhDgEHEQ4BBxUUFjsBFR4BFyE+ATc1MzI2PQEuAQMhNSERIREhFRQWOwETLgE0NjIWFAYDgBNaExv92xskATZJARIOYAEkGwKAGyQBYA4SAUm2/gACAP4AAYASDmBgFBsbKBsbAgDlGxNaEwEkG/7AAUk24A4SwBskAQEkG8ASDuA2Sf4BwAEAAUBgDhL+sAEbKBsbKBsAAAAAAgAA/8ADgANAAAcAEQAAASchByMVITUBHgEXIT4BNxEhAuAg/oAgoAMA/UABJBsCABskAf2AAwBAQICA/QAbJAEBJBsCQAAABgAA/78DgQNAABMAHAAsADwATABTAAABERQGIyEiJjURNDY3ITIWHwEeAQcjIiYnNSERIQEhMhYdARQGIyEiJj0BNDYFFRQGIyEiJj0BNDYzITIWHQEUBiMhIiY9ATQ2MyEyFgMzJi8BJicDgBsV/WAVGxsVAcAVLg+cDhRA0BQbAf6AAoD+EAFgBwkJB/6gBwkJAXcJB/6gBwkJBwFgBwkJB/6gBwkJBwFgBwlAvAUGnAcOAjD9wBUbGxUDIBQbARQOnA8uRRsV0P0AAcAJByAHCQkHIAcJkCAHCQkHIAcJCYcgBwkJByAHCQkBiQ4GnQYFAAYAAP+ABAADgAAHAAsADwATABYAGQAAExEhESMRIREBEyETAQMhAwEzESMTIzcTIxfNAmZN/jT+5twCSNz9EKEDIqH+6kxMmeZzc+ZyAZEB7/4RAaL+Xv3vAjr9xgHt/mABoAEt/ekBynP+E3kAAAAG////gQQBA4MABwALAA8AEwAWABkAACUhESEVIREhASURJQEFEQ0BIRUhNxUnJRU3Ae3+EwHt/l8BoQIU/cYCOv4SAaL+Xv7RAjn9x0xyAhNyUQJiTf44/uTbAkrc/Q6hAyShy0yY5HJy5HIAAAAAAv/+/4AEAgOBAEsAVwAAASc2Jzc+AScmJy4BDwEmJzU0JicmIgcOAR0BBgcnJgYHDgEHBhYfAQYXBw4BFxYXHgE/ARYXFRQWFxY2Nz4BPQE2NxcWNjc+ATc2JgUuASc+ATceARcOAQPzXA4OXAgGAiVRBxEIXDpJCwk8dzkJC0g7XAgRByg8EgIGCFwODlwIBgIlUgYRCVs7SQsJO3g4CQtJO1sJEQYoPBMCB/4FSWECAmFJSWICAmIBBTNISTMEEAhwVAYDBTMwGWYIDgIMDAMNCGYZLzIFAwYqYjgIEAQzSUgzBQ8Jb1QHAgQzMBhmCQ0CDQEMAg0JZhgwMwQCByljNwkPJQJdRkZeAQFeRkZdAAAABgAA/4AEAAOAAAMABwALAA8AEwAXAAATMxEjATMRIwEhFSETIRUhAzMVIwEzFSOZTU0CgUxM/OYDKPzY0wMt/NM6TU0CgUxMArT9ZgLN/bMCTU39zEwDZmb9JsAAAAAABgAA/7MEAANNAAMABwALAA8AEgAgAAARIRUhESEVIQEzESMBMxEjARElASM1LgEnIgcnNjMeARcDM/zNAzP8zQLmTU39Gk1NApr/AAJmMwShdj43F0JKjb0EAeZM/mZNAh/98AIQ/fADi/7Nmf5nZ3aeAxozHgO9jgAAAAMAAP9/BAADgAADAAcACwAAARcBJwkEIRUhAbr4/rT5Ai39ZgFmApr9ZgKa/WYCM/n+svkCm/1l/psCmv2zTQABAAAAAAP/AjUADAAAGQEhJzYkASYkBw4BBwGdjg4BzwESEf7c06LMBAHi/mqLKNf+0KfnDxuhCgAAAAAFAAD/gAQAA4AABAAIAAwANAA2AAAZASEnJgEhFSERMxEjEwYEBw4BBzc+ATc+ATc+ATIeAhQOAiImJyYnBxYXHgEXNgA3JgABFQEzmYcBnQEz/s1NTVCr/v43Cw4CWAEEBQ44KjybrJp5QD96mqybPBYSShgdRrlr2QEhBgb+4P0mAub+zZqH/nlNATP+zQKAA7yaHywiAxEKETdkKT1AQHqarJp6QEA9FhgtIR1GTwEFASHa2gEh/gYDAAEAAAAAA/kCXwAPAAABNhYXNxMlNy4BBw4BBz4BAepzz1hQJf6hV0e2aYrFLST/AlQLPkJC/qFJUENCEBKfeq3uAAAABgAA/9UDkQNEAAsAHwAvAD8ASwBXAAAlISIGFBYXIT4BNCYXNS4BJyEOAQcVIzU+ATchHgEXFQMhLgEnET4BNyEeARcRDgEBDgEHER4BFyE+ATcRLgEnByEiJjQ2MyEyFhQGByEiJjQ2MyEyFhQGAsn+XAwREQwBpA0REX8BMyb+DCYzATwCVEAB9EBUApb+DEBUAgJUQAH0QFQCAlT9zCYzAQEzJgH0JjMBATMmL/5cDRERDQGkDBERDP5cDRERDQGkDBERHxEZEQEBERkRSUwmMwEBMyZMTEBVAQFVQEwBHwJUQAEiQFQCAlRA/t5AVAIQATMm/t4mMwEBMyYBIiYzAbYRGhERGhG4ERoRERoRAAAAAAASAN4AAQAAAAAAAAAVAAAAAQAAAAAAAQASABUAAQAAAAAAAgAHACcAAQAAAAAAAwASAC4AAQAAAAAABAASAEAAAQAAAAAABQALAFIAAQAAAAAABgASAF0AAQAAAAAACgArAG8AAQAAAAAACwATAJoAAwABBAkAAAAqAK0AAwABBAkAAQAkANcAAwABBAkAAgAOAPsAAwABBAkAAwAkAQkAAwABBAkABAAkAS0AAwABBAkABQAWAVEAAwABBAkABgAkAWcAAwABBAkACgBWAYsAAwABBAkACwAmAeEKQ3JlYXRlZCBieSBpY29uZm9udApkcy1kd3QtdWktaWNvbmZvbnRSZWd1bGFyZHMtZHd0LXVpLWljb25mb250ZHMtZHd0LXVpLWljb25mb250VmVyc2lvbiAxLjBkcy1kd3QtdWktaWNvbmZvbnRHZW5lcmF0ZWQgYnkgc3ZnMnR0ZiBmcm9tIEZvbnRlbGxvIHByb2plY3QuaHR0cDovL2ZvbnRlbGxvLmNvbQAKAEMAcgBlAGEAdABlAGQAIABiAHkAIABpAGMAbwBuAGYAbwBuAHQACgBkAHMALQBkAHcAdAAtAHUAaQAtAGkAYwBvAG4AZgBvAG4AdABSAGUAZwB1AGwAYQByAGQAcwAtAGQAdwB0AC0AdQBpAC0AaQBjAG8AbgBmAG8AbgB0AGQAcwAtAGQAdwB0AC0AdQBpAC0AaQBjAG8AbgBmAG8AbgB0AFYAZQByAHMAaQBvAG4AIAAxAC4AMABkAHMALQBkAHcAdAAtAHUAaQAtAGkAYwBvAG4AZgBvAG4AdABHAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAHMAdgBnADIAdAB0AGYAIABmAHIAbwBtACAARgBvAG4AdABlAGwAbABvACAAcAByAG8AagBlAGMAdAAuAGgAdAB0AHAAOgAvAC8AZgBvAG4AdABlAGwAbABvAC4AYwBvAG0AAAAAAgAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AQIBAwEEAQUBBgEHAQgBCQEKAQsBDAENAQ4BDwEQAREBEgETARQBFQEWARcBGAEZARoBGwEcAR0BHgEfASABIQEiASMBJAElASYBJwEoASkBKgErASwBLQEuAS8BMAExATIBMwE0ATUBNgE3ATgBOQAJc2hhbmd5aWJ1B3hpYXlpYnULbGlqaXF1ZXJlbngOc2hpYmllLWNodWFudGkLemhhb3hpYW5namkIemhvbmdwYWkJbW92ZV9sZWZ0Cm1vdmVfcmlnaHQLcmlnaHRib3R0b20Hc2Nhbm5lcgpmb2xkZXJvcGVuCnVuc2VsZWN0ZWQJc2VsZWN0ZWQxC2V4aXRGdWxsV2ViBnBlbmNpbAhjcm9wTW92ZQdmdWxsV2ViC3Nocmlua0ltYWdlDHNocmlua0NhbnZhcwhmaXRXaWR0aAlmaXRIZWlnaHQMbWFnbmlmeUltYWdlDW1hZ25pZnlDYW52YXMHYXV0b0ZpdAhzZWxlY3RlZAdjb25maXJlCHRhZ0NvbG9yBmNhbmNsZQdtdXRpcGxlC2V4aXRNdXRpcGxlBmFkZFRhZwlyb3RhdGVBbGwKZnVsbERldmljZQhwYWdlTmV4dAl0aHVtYm5haWwEdGFncwR0cmVlB3BhZ2VQcmUHcGFnZUVuZAlwYWdlU3RhcnQIZXhpdEZ1bGwEc2F2ZQVwcmludAZkZWxldGUEZmlsZQZtaXJyb3IEZmxpcARsaXN0BGNyb3AKcm90YXRlTGVmdAR3aXBlBHVuZG8FcmVzZXQEcmVkbwhyZWFkVHlwZQAAAAA=') format('embedded-opentype'), -url('data:application/x-font-ttf;base64,AAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzI8eVFjAAABfAAAAFZjbWFwsMYTRQAAArQAAAV0Z2x5ZvNC4b4AAAicAAAdwGhlYWQZgieHAAAA4AAAADZoaGVhB94D+wAAALwAAAAkaG10eOCW//kAAAHUAAAA4GxvY2HgFtk4AAAIKAAAAHJtYXhwAVcBfAAAARgAAAAgbmFtZbG62DQAACZcAAAC5XBvc3RAkF7qAAApRAAAAnoAAQAAA4D/gABcBET//f/+BAIAAQAAAAAAAAAAAAAAAAAAADgAAQAAAAEAAI/gqeZfDzz1AAsEAAAAAADbMfHFAAAAANsx8cX//f99BAIDgwAAAAgAAgAAAAAAAAABAAAAOAFwABUAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQQDAZAABQAIAokCzAAAAI8CiQLMAAAB6wAyAQgAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA5gDvawOA/4AAXAODAIMAAAABAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAP//BAAAAAQAAAAEAAAABAD//QQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEDgAABAAAAAQEAAAEAAAABAAAAAQAAAAEAAAABD0AAAQAAAAEAAAABAAAAAQAAAAEAAAABEQAAAQAAAAEAAAABAAAAAQAAAAEAP//BAD//gQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAFAAAAAwAAACwAAAAEAAAC0AABAAAAAAHKAAMAAQAAACwAAwAKAAAC0AAEAZ4AAABIAEAABQAI5gDmC+YP5iHmJOYp5jHmM+Y+5kXmS+ZR5ljmWuZf5mLmdeZ75ormoOar5sDnJOc050zniegO6BToV+h26hLqjOtl6+/va///AADmAOYC5g3mIOYk5ifmMeYz5j7mReZI5lHmWOZa5l/mYeZ15nvmiuag5qvmwOck5zTnTOeJ6A7oFOhX6HbqEuqM62Pr7+9r//8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEASABIAFoAXgBgAGAAZABkAGQAZABkAGoAagBqAGoAagBsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAcABwAAAAJgAoACkAKgAeADYALAAbAA8AGgAOADMABAACADQAIQAtAA0ADAALAAMACgAnAB0ABwAIABQAFQA1ABwAJQAgABYANwAFADAAMgARAB8AIwASAAkAMQAGABAAJAArABkAFwAYAC8ALgAiAAEAEwAAAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAACpAAAAAAAAAA3AADmAAAA5gAAAAAmAADmAgAA5gIAAAAoAADmAwAA5gMAAAApAADmBAAA5gQAAAAqAADmBQAA5gUAAAAeAADmBgAA5gYAAAA2AADmBwAA5gcAAAAsAADmCAAA5ggAAAAbAADmCQAA5gkAAAAPAADmCgAA5goAAAAaAADmCwAA5gsAAAAOAADmDQAA5g0AAAAzAADmDgAA5g4AAAAEAADmDwAA5g8AAAACAADmIAAA5iAAAAA0AADmIQAA5iEAAAAhAADmJAAA5iQAAAAtAADmJwAA5icAAAANAADmKAAA5igAAAAMAADmKQAA5ikAAAALAADmMQAA5jEAAAADAADmMwAA5jMAAAAKAADmPgAA5j4AAAAnAADmRQAA5kUAAAAdAADmSAAA5kgAAAAHAADmSQAA5kkAAAAIAADmSgAA5koAAAAUAADmSwAA5ksAAAAVAADmUQAA5lEAAAA1AADmWAAA5lgAAAAcAADmWgAA5loAAAAlAADmXwAA5l8AAAAgAADmYQAA5mEAAAAWAADmYgAA5mIAAAA3AADmdQAA5nUAAAAFAADmewAA5nsAAAAwAADmigAA5ooAAAAyAADmoAAA5qAAAAARAADmqwAA5qsAAAAfAADmwAAA5sAAAAAjAADnJAAA5yQAAAASAADnNAAA5zQAAAAJAADnTAAA50wAAAAxAADniQAA54kAAAAGAADoDgAA6A4AAAAQAADoFAAA6BQAAAAkAADoVwAA6FcAAAArAADodgAA6HYAAAAZAADqEgAA6hIAAAAXAADqjAAA6owAAAAYAADrYwAA62MAAAAvAADrZAAA62QAAAAuAADrZQAA62UAAAAiAADr7wAA6+8AAAABAADvawAA72sAAAATAAAAAABaALYA8gFKAZoB8gIOAigCSgQwBHQEkgTABQIFWAWQBdQGFAZMBnoGqAbuBzoHogfiB/YIGAhICHAIogjmCTAJZAmOCboJ7goSCjwKbgqgCtQLOAuSC7YMMAxoDKANKg1aDZgNuA3WDjQOVg7gAAAAAwAA/4AEAAOAAAsAHAA3AAARFgAXNgA3JgAnBgAXND4CMh4CFA4CIi4CNzQ1PwI+AR4BDwEhMhYUBgchFxYOASIvAgUBIdrZASEFBf7f2dr+3ztDgKK1ooBDQ4CitaKAQ8ECBNQJGhMBCZ4Bdg0SEg3+iZ8JARMaCtIGAYDZ/t8FBQEh2doBIQUF/t/aW6KAQ0OAorWigENDgKJdAQEHCOAKARMZC6gSGxIBqwsZEgriDAAAAwAA/4AEAAOAAAsAHAA3AAABBgAHFgAXNgA3JgATDgEiLgI0PgIyHgIUBic0NS8CLgEOAR8BISIGFBYXIQcGHgEyPwICANr+3wUFASHa2QEhBQX+32NAorWigENDgKK1ooBDQ30CBdMKGRQBCZ/+ig4SEg4Bd6AJARMaCtIHA4AF/t/a2f7fBQUBIdnaASH8yUBDQ4CitaKAQ0OAorWi/wEBBwjgCgETGQuoEhsSAasKGhIK4gwAAAUAAP+ABAADgAAEAAwAEAAUACEAAAEhESERJRUzNTMVITUDESEZASE1IRMnESERIxEhESERMxcDQPzABAD+AEBA/wCAAgD+AAIAwID9gIABAAGAXqEDgPwAAz6CgIDAv/yBAQD/AAE/Qf5/AQHA/kADgP8AAQChAAsAAP9/BAADgAAFAAsAEQAXABsAHwAjACcAKwAvADMAABMzNQURMxEjESE1IwEVMxUzEQMjFSERIwUhFSE1IRUhJSEVITUhFSE1IRUhBSERIRczFSNN8/7ATU0BQPMCc/NNTfMBQE39DQKA/YACgP2AAX8BAf7/AQH+/wEB/v/+gQFA/sBNpqYDM00B/sH+gP7ATQOzTfMBQPxNTQFAFE3NTc9Nxk3GTfMBQE2mAAAABAAA/7MEAANNAAAADQAhAC0AAAEjHgIyPgE3LgEnDgEBIychByMOAQcRHgEXIT4BNxEuAQEuASc+ATceARcOAQIApAErTVZNKwECXEZGXAI8o13+zF2jKzoBATorAzQrOgEBOv47bZADA5BtbZADA5ABTS1LLCxLLUVdAgJdAVRnZwE6K/2aLDoBATosAmYrOv1oA5BtbZADA5BtbZAAAAYAAP+AA8EDgAAXAB8AJwArAC8AMwAAASM1LgEnIQ4BBxUjFTMRHgEXIT4BNREzJTY3IRYXFSEBBgchJicRIQUzESMTMxEjEzMRIwPA5QEpHv7aHikB5D8BLB4Cbx8pP/2hAQoBJgoB/sQB3QEK/ZcKAQJ//eY8PL08PLw8PAMANB8sAQEsHzRA/QgfKAEBKB8C+HQLAQELNPzLCgEBCgL1f/3/AgH9/wIB/f8AAAAAAwAAAAAEAALAAAMABwAKAAABMxEjATMRIycRAQOAgID/AICAgP4AAsD9gAKA/YAgAkD+4AAAAAADAAAAAAQAAsAAAwAHAAoAABEzESMBMxEjJREBgIABAICAAQACAALA/YACgP2AIAJA/uAAAgAA/4AEAAOAAAkADwAAAREUDgIjIRIAAxcHFzcnBAARISkX/HILAkJhuroo4+MDgPxyFykhEQGzAkL+abu6KePjAAAVAAAAAAQAAhIABwALAA8AEwAbACwAPABRAF8AfACGAJoAwgDlAQUBEAEkATgBVQFfAW8AABMjFwcVMzUvATMHIxcjNzMXIzUzJyM3MwczJzM3JiIOAR0BFB4BPgI9ATQmBxQOASIuAT0BND4BMh4BFRcuASIGBzUjFTM1HgEzMj4BPQImBxQOASImJzU+ATIWFxU3JiIOAR0BFB4BMzI2NzUjFRQOASIuAT0BMzU0JgcjNTQ+ATIeARU3JiIGBzUjFTM1PgEyFh0BMzU0JhcnLgE0NjIeARU3NC4CIyIGFRQWHwEeARQGIi4BNQceAjI+ATQmNyYiDgEdARQeATI+AT0BIwcUBiImPQE0PgEyHgEdATM1NCYXND0BNCYiBhUzNTQ+ATIeAR0BBw4CFRQeATI2NxczJxQOASImND4BPwImIgYHNSMVMzU+ATIWHQEzNTQmNyYiBgc1IxUzNT4BMhYdATM1NCY3JiIOAR0BFB4BMzI2PQEjFRQOASIuAT0BMzU0JgcjNTQ+ATIeARU3IyIGBzUjFTM1PgEzHwE16+QeJfcqq64VhGtSEyxTzs4HwR8YGYMbGcgHFw0GBg0XDQYGCQMGDQYCAgcMBgNLAgcLCAMODgMHBAgJAwEOAQMHBQICBQcDAUIFEwsEBAoKDAoBDwEEBgQCIAMMEQEECAMBRgILCgQPDwMFBgMPAlcTBAMGDAYDDQQHCgcMDgUFEwYHBwwGBA4BBg0SDAcKOQUTCgMDChMKAw0BBAgEAQQHAwINAz0KGAwPAgMHAwEMBQkFBAcMCAECDhEDBAYDAgUDBkgDCwkEDw8CBQcCDwI7AwsJBA8PAgYGAg8CNgUTCwQECwkMCw8BAwcEAiADDBECAwgDAT8BBQkEDw8DBQQEBAIReGw1M25jVUs2hRoVVkVFQQQJEAssCxEKAQkRCywLEEsGCgUFCgYzBgkGBQoGDAUHBQMHbSEDBAkQCBQJBSIGCgUCATUCAgUEChsEBw8LEgsPBw4MAwUEBgMDBgURBwsQGgQHCQMEBwUZAgUECFJCAgMFBD5CBAgUEQQHCwcGCgUDCAsIAw4MCQwFEQUJDwcHDAYECg8IBgwUDxwDCA4LEwoOCQcMCAYOBAMHChoHCAQDBgYFBQkLQQQEJQ0NDQ4EBAUDBAYFBgUDBwsHBQkGCQUMEwEEAgUJBQUCBCcCBQQIUkICAwUEPkIECAMCBQQIUkICAwUEPkIECAEEBw8LEgsPBw4MAwUEBgMDBgURBwsQGgQHCQMEBwUbBQgMUjwEBAEBEQAAAAAC/////wQAAwAAGAApAAABIzUuASchJyEOAQcRFBcWMyEyNjcTNS4BJTQ2OwEXIRYXFSEiBw4BBwMD1DgBHBT+dWD+sBQbAQkNFgM8DxIHcAEY/HkHBfRgAXALAf2cBAMMEgNQAeCgFBsBUAEcFf1dDwwQEg4BgQkWH7MFCVABC2QBAhEM/tUAAwAA/4AEAAOAAAMABwALAAABESERJSERIQEhESEDoPzAA6D8AAQA/F8DQPzAAyD8wANAYPwAA6D8wAAABAAA/4AEAAOAAAMABwALABQAAAERIRElIREhASERISUBJwEnBxcWMgOg/MADoPwABAD8XwNA/MABZwGGXP7ApFjmCRoDIPzAA0Bg/AADoPzAtAGIW/68pFznCgAKAAD/oAPgA2AAAwAHAAsADwATABcAGwAfACMAJwAAAREhESUhESEBMxUjNzMVIyUzFSM1MxUjFTMVIzUzFSMlMxUjJzMVIwOY/NADePxAA8D84t7elkhIAQhISN7e3t5ISP74SEiW3t4DGPzQAzBI/EACiEje3t7eSEjASEje3t7eSAAE//3/fQQAA4AADwAdACoAMQAAAQcGIi8BJjQ/ATYyHwEWFCUBBwYWPwEBNjQvASYiASY0NwE2MhYUBwEGIgczFQcnNzMD5FwIEwfeBwdcHU0eeBz+OP3zKgQiGfMCDQcH3gcT/rgICAE1CBYRCP7MCRZRYIE+F0gCZFwHB94HEwhcHBx4Hkw3/fLzGSIEKgINCBMH3gj+GAkWCQE0CBAXCf7MCKBJFj6BAAAAAgAA/70DwQNAAAsAIwAAAQ4BBx4BFz4BNy4BEzUjFTMHJzM1IxUnNxUzNSM3FyMVMzUXAf++/gUF/r6//QUF/QqiUXd3UaJ3d6JRd3dRoncDQAX9v7/9BQX9v7/9/c9Rond3olF3d1Kjd3ejUncAAAoAAP+ABAADgAADAAcACwAPABMAFwAbAB8AIwAnAAABESERJSERIQEzFSM1MxUjJTMVIyczFSMRMxUjNzMVIyUzFSM1MxUjA7P8mgOz/AAEAPyt7e1NTQJZTU2g7e3t7aBNTf2nTU3t7QMz/JoDZk38AANTTU3t7e3tTf30Te3t7e1NTQAAAAAEAAD/gAQAA4AACwAXABsAHwAAAR4BFw4BBy4BJz4BNw4BBx4BFz4BNy4BASEVIQkBNwEBmo28AwO8jY68AwO8jq7oBATorq7nBATn/oUBmf5nAv3+vzYBQQMzA7yOjbwDA7yNjrxQBOiurucEBOeuruj+kU39wAFBNv6/AAAAAAIAAP/mA5oDGgAVACEAACUnPgE1LgEnDgEHHgEXPgE3FxYyNjQDISImNDYzITIWFAYDk4gvNQPcpaXbBQXbpUuENYgGEA37/pkLDg4LAWcLDg4KiDSETKXaBQXapabaBQE0L4gHDRABgwwRDAwRDAAGAAD/gAQAA4AAAwAHAAoADgARABUAAAERIRElIREhASc3FTMVIyUXByczFSMDs/yaA7P8AAQA/RqamqamAcyamqampgMz/JoDZk38AAGAgIBaTKaAgKZMAAAAAAYAAP+ABAADgAADAAcACgAOABEAFQAAAREhESUhESEBNxcjMxUjEwcnNzMVIwOz/JoDs/wABAD9gICApkxMpoCAWkxMAzP8mgNmTfwAAuaamqb+2pqapqYAAAAABQAA/4AEAAOAAAsAFwAbAB8AIwAAAR4BFw4BBy4BJz4BNw4BBx4BFz4BNy4BASEVITczESMJATcBAZqNvAMDvI2OvAMDvI6u6AQE6K6u5wQE5/6FAZn+Z6RNTQJZ/r82AUEDMwO8jo28AwO8jY68UATorq7nBATnrq7o/pFN8/5n/mYBQTb+vwAAAAACAAD/zAO0A1YAFQAxAAAlFxYUBiIvAQ4BIy4BJz4BNx4BFxQGJSMOARQWOwEVHgEyNj0BMzI2NCYnIzU0JiIGBwMZkggTGQqRO49NtfEEBPG1tvAFNf5qag4SEg5qARIbEmsOEhIOaxIbEgGUkQoZEwiSMjUF8La18QQE8bVNj/wBEhsSaw4SEg5rEhsSAWoOEhIOAAAAAAYAAP+CA/4DfgAXACcALwA3AD8ARwAAEyEyHgIVERQOAiMhIi4CNRE0PgIXDgEHER4BFyE+ATcRLgEnAzMVIxUjNTMFIzUzNTMVIwUVIzUjNTMVAzUzFTMVIzWUAtgdNSoWFio1Hf0oHTUqFhYqNR0eKgEBKR8C2B4qAQEqHklJSUlJ/bpJSUlJAUdISdqRSEnaA34WKjUd/SgdNSoWFio1HQLYHTUqFkkBKh79KB8pAQEqHgLYHioB/m9ISdqRSEnatklJSUkCRklJSUkAAAACAAD/wAPAA0AADwAkAAAFIS4BJxE+ATchHgEXEQ4BJQE2NC8BJiIHAScmIg8BBhQfARYyA2D9QCk2AQE2KQLAKTYBATb+PgFwCQkuCRoK/tSMChoJLgkJ0AoaQAE2KQLAKTYBATYp/UApNsMBcAoaCS4JCf7UjAkJLQoaCtAJAAEAAP/IA8QCWwAFAAAJAScHCQEDTP5d73cBZgIaAlr+Xu94/poCGgACAAD/gAQAA4AAAAAMAAABIRYAFzYANyYAJwYAAgD+AAUBIdraASEFBf7f2tr+3wGA2v7fBQUBIdraASEFBf7fAAAAAAEAAAAAA1sCxwAcAAA3FjI/ARcWMjY0LwE3NjQmIg8BJyYiBhQfAQcGFLISMxL09BIzJBH19BIkMxL09BIzJBL09BMdEhL19BIkMxL09BIzJBL09BEkMxL09BIxAAAAAAIAAP/AA8ADQAAPABMAAAEhDgEHER4BFyE+ATcRLgEDIREhA2D9QCk2AQE2KQLAKTYBATYp/UACwANAATYp/UApNgEBNikCwCk2/OECwAAAAgAA/4AEAAOAAAsAFwAABSYAJzYANxYAFwYAEycHJwcXBxc3FzcnAgDa/t8FBQEh2toBIQUF/t8mNM7PNM/PNM/ONM+ABQEh2toBIQUF/t/a2v7fAso0z880z880z880zwAAAAIAAP/GA7wDOwAQAC0AAAEuASIOAhQeAjI+AjQmAyMVDgEiJj0BIyImNDY7ATU0NjIWFxUzMhYUBgcDOkChs6F+Q0N+obOhf0NDm74BEhsSvg4SEg6+EhsSAb4NEhINArk/QkJ+obKgfkNDfqCzoP7nvw0SEg2/EhsSvg4SEg6+EhsSAQAAAAAIAAD/swQAA00AAwAHAAsADwATABcAGgAoAAATIRUhESEVIQEzESMBMxEjAyEVITUzESMBESUBIzUuASciByc2Mx4BF5oCmf1nApn9ZwJMTU39tExMmgFm/ppNTQKa/wACZjMEoXY+NxdCSo29BAGaTf6zTQHS/j0Bw/49AldNDv3ZA5r+zZn+Z2d2ngMaMx4DvY4ABQAA/4AEAAOAAAIABgAKAA4AGAAAATMVBREhESUhESETJRcFAREzESERIRUhEQJmzf5M/s4Bf/40AcwdARcz/ur9400DZv6AAc0Cs83n/s4BMk3+NAI5+jn6AgD+MwGA/JpNBAAAAAABAAD/gAM3A4AAFAAACQEGIi8BJjQ3CQEmND8BNjIXARYUAyb+ORItETUREQFp/pcRETURLRIBxxEBWP45ERE1ES0SAWoBaxEtETUREf45EiwAAAACAAD/fwO3A4AABgAYAAABERYfARYXBRQWMyERFAYjISImNRE0NjMhApINCOkICP6pIBcBNyAX/QAXICAXAckCWwEOCAjpCA0SFyD9pRcgIBcDkhcgAAAAAgAA/4AEAAOAABIAGwAAGQE+ATchFhcBFhQHAQYiJwEuARMOARQWMjY0JgE2KQGYKBwBqBwc/mgeTB7+WA0P4Ck2NlI2NgGIAZgpNgEBG/5YHU0e/mgcHAGoDSQBiwE2UjY2UjYAAAABAAAAAAQAAwAAEQAAASEnIQ4BBxEeARchPgE3ES4BA6D+gID+wCk2AQE2KQNAKTYBATYCgIABNin9wCk2AQE2KQHAKTYAAAABAAD/gAM3A4AAFAAAEwE2Mh8BFhQHCQEWFA8BBiInASY02gHHEi0RNRER/pcBaRERNREtEv45EQGoAccRETURLRL+lv6VES0RNRERAccSLAAAAAACAAD/gAQAA4AAFAAYAAAJAQYiLwEmNDcJASY0PwE2MhcBFgYBIxEzAl7+ORItETUREQFp/pcRETURLRIBxxEBAZKzswFY/jkRETURLRIBagFrES0RNRER/jkSLP4XA/8AAAAAAgAA/4AD/wOAABQAGAAACQE2Mh8BFhQHCQEWFA8BBiInASY2ATMRIwGiAccSLRE1ERH+lwFpERE1ES0S/jkRAf5us7MBqAHHERE1ES0S/pb+lREtETUREQHHEiwB6fwBAAAAAAUAAP+ABAADgAACAAYACgAOABgAAAEjNQMRIRElIREhAQUnLQERMxEhESEVIREC6c2d/s4Bf/40AcwBmv7pMwEW/M5NA2b+gAHNAa3O/oT+zgEyTf40Ayf6Ofqg/jMBgPyaTQQAAAAABAAA/4AEAAOAABUAKwA0AD0AAAEzHgEXETMeAQcBBiInASY2NzMRNDYBFQ4BByEuASc1PgE3IRcWMj8BIR4BBzQmIgYUFjI2NzQmIgYUFjI2AbCgFBsBrxwTEv7PDB8M/tASExuwHAJkARsU/GAUGwEBGxQBJWIgUiBiASUUG/cXIhcXIheAFyIXFyIXA4ABGxT+sAItFf7QDAwBMBUtAgFQFBv9EeAUGwEBGxTgFBsBYh4eYgEbxBEXFyIXFxERFxciFxcAAAAEAAD/gAQAA4AAIwAnADAAOQAAATU0LwEmIyEOAQcRDgEHFRQWOwEVHgEXIT4BNzUzMjY9AS4BAyE1IREhESEVFBY7ARMuATQ2MhYUBgOAE1oTG/3bGyQBNkkBEg5gASQbAoAbJAFgDhIBSbb+AAIA/gABgBIOYGAUGxsoGxsCAOUbE1oTASQb/sABSTbgDhLAGyQBASQbwBIO4DZJ/gHAAQABQGAOEv6wARsoGxsoGwAAAAACAAD/wAOAA0AABwARAAABJyEHIxUhNQEeARchPgE3ESEC4CD+gCCgAwD9QAEkGwIAGyQB/YADAEBAgID9ABskAQEkGwJAAAAGAAD/vwOBA0AAEwAcACwAPABMAFMAAAERFAYjISImNRE0NjchMhYfAR4BByMiJic1IREhASEyFh0BFAYjISImPQE0NgUVFAYjISImPQE0NjMhMhYdARQGIyEiJj0BNDYzITIWAzMmLwEmJwOAGxX9YBUbGxUBwBUuD5wOFEDQFBsB/oACgP4QAWAHCQkH/qAHCQkBdwkH/qAHCQkHAWAHCQkH/qAHCQkHAWAHCUC8BQacBw4CMP3AFRsbFQMgFBsBFA6cDy5FGxXQ/QABwAkHIAcJCQcgBwmQIAcJCQcgBwkJhyAHCQkHIAcJCQGJDgadBgUABgAA/4AEAAOAAAcACwAPABMAFgAZAAATESERIxEhEQETIRMBAyEDATMRIxMjNxMjF80CZk3+NP7m3AJI3P0QoQMiof7qTEyZ5nNz5nIBkQHv/hEBov5e/e8COv3GAe3+YAGgAS396QHKc/4TeQAAAAb///+BBAEDgwAHAAsADwATABYAGQAAJSERIRUhESEBJRElAQURDQEhFSE3FSclFTcB7f4TAe3+XwGhAhT9xgI6/hIBov5e/tECOf3HTHICE3JRAmJN/jj+5NsCStz9DqEDJKHLTJjkcnLkcgAAAAAC//7/gAQCA4EASwBXAAABJzYnNz4BJyYnLgEPASYnNTQmJyYiBw4BHQEGBycmBgcOAQcGFh8BBhcHDgEXFhceAT8BFhcVFBYXFjY3PgE9ATY3FxY2Nz4BNzYmBS4BJz4BNx4BFw4BA/NcDg5cCAYCJVEHEQhcOkkLCTx3OQkLSDtcCBEHKDwSAgYIXA4OXAgGAiVSBhEJWztJCwk7eDgJC0k7WwkRBig8EwIH/gVJYQICYUlJYgICYgEFM0hJMwQQCHBUBgMFMzAZZggOAgwMAw0IZhkvMgUDBipiOAgQBDNJSDMFDwlvVAcCBDMwGGYJDQINAQwCDQlmGDAzBAIHKWM3CQ8lAl1GRl4BAV5GRl0AAAAGAAD/gAQAA4AAAwAHAAsADwATABcAABMzESMBMxEjASEVIRMhFSEDMxUjATMVI5lNTQKBTEz85gMo/NjTAy380zpNTQKBTEwCtP1mAs39swJNTf3MTANmZv0mwAAAAAAGAAD/swQAA00AAwAHAAsADwASACAAABEhFSERIRUhATMRIwEzESMBESUBIzUuASciByc2Mx4BFwMz/M0DM/zNAuZNTf0aTU0Cmv8AAmYzBKF2PjcXQkqNvQQB5kz+Zk0CH/3wAhD98AOL/s2Z/mdndp4DGjMeA72OAAAAAwAA/38EAAOAAAMABwALAAABFwEnCQQhFSEBuvj+tPkCLf1mAWYCmv1mApr9ZgIz+f6y+QKb/WX+mwKa/bNNAAEAAAAAA/8CNQAMAAAZASEnNiQBJiQHDgEHAZ2ODgHPARIR/tzToswEAeL+aoso1/7Qp+cPG6EKAAAAAAUAAP+ABAADgAAEAAgADAA0ADYAABkBIScmASEVIREzESMTBgQHDgEHNz4BNz4BNz4BMh4CFA4CIiYnJicHFhceARc2ADcmAAEVATOZhwGdATP+zU1NUKv+/jcLDgJYAQQFDjgqPJusmnlAP3qarJs8FhJKGB1GuWvZASEGBv7g/SYC5v7Nmof+eU0BM/7NAoADvJofLCIDEQoRN2QpPUBAepqsmnpAQD0WGC0hHUZPAQUBIdraASH+BgMAAQAAAAAD+QJfAA8AAAE2Fhc3EyU3LgEHDgEHPgEB6nPPWFAl/qFXR7ZpisUtJP8CVAs+QkL+oUlQQ0IQEp96re4AAAAGAAD/1QORA0QACwAfAC8APwBLAFcAACUhIgYUFhchPgE0Jhc1LgEnIQ4BBxUjNT4BNyEeARcVAyEuAScRPgE3IR4BFxEOAQEOAQcRHgEXIT4BNxEuAScHISImNDYzITIWFAYHISImNDYzITIWFAYCyf5cDBERDAGkDRERfwEzJv4MJjMBPAJUQAH0QFQClv4MQFQCAlRAAfRAVAICVP3MJjMBATMmAfQmMwEBMyYv/lwNERENAaQMEREM/lwNERENAaQMEREfERkRAQERGRFJTCYzAQEzJkxMQFUBAVVATAEfAlRAASJAVAICVED+3kBUAhABMyb+3iYzAQEzJgEiJjMBthEaEREaEbgRGhERGhEAAAAAABIA3gABAAAAAAAAABUAAAABAAAAAAABABIAFQABAAAAAAACAAcAJwABAAAAAAADABIALgABAAAAAAAEABIAQAABAAAAAAAFAAsAUgABAAAAAAAGABIAXQABAAAAAAAKACsAbwABAAAAAAALABMAmgADAAEECQAAACoArQADAAEECQABACQA1wADAAEECQACAA4A+wADAAEECQADACQBCQADAAEECQAEACQBLQADAAEECQAFABYBUQADAAEECQAGACQBZwADAAEECQAKAFYBiwADAAEECQALACYB4QpDcmVhdGVkIGJ5IGljb25mb250CmRzLWR3dC11aS1pY29uZm9udFJlZ3VsYXJkcy1kd3QtdWktaWNvbmZvbnRkcy1kd3QtdWktaWNvbmZvbnRWZXJzaW9uIDEuMGRzLWR3dC11aS1pY29uZm9udEdlbmVyYXRlZCBieSBzdmcydHRmIGZyb20gRm9udGVsbG8gcHJvamVjdC5odHRwOi8vZm9udGVsbG8uY29tAAoAQwByAGUAYQB0AGUAZAAgAGIAeQAgAGkAYwBvAG4AZgBvAG4AdAAKAGQAcwAtAGQAdwB0AC0AdQBpAC0AaQBjAG8AbgBmAG8AbgB0AFIAZQBnAHUAbABhAHIAZABzAC0AZAB3AHQALQB1AGkALQBpAGMAbwBuAGYAbwBuAHQAZABzAC0AZAB3AHQALQB1AGkALQBpAGMAbwBuAGYAbwBuAHQAVgBlAHIAcwBpAG8AbgAgADEALgAwAGQAcwAtAGQAdwB0AC0AdQBpAC0AaQBjAG8AbgBmAG8AbgB0AEcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAAcwB2AGcAMgB0AHQAZgAgAGYAcgBvAG0AIABGAG8AbgB0AGUAbABsAG8AIABwAHIAbwBqAGUAYwB0AC4AaAB0AHQAcAA6AC8ALwBmAG8AbgB0AGUAbABsAG8ALgBjAG8AbQAAAAACAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgBAgEDAQQBBQEGAQcBCAEJAQoBCwEMAQ0BDgEPARABEQESARMBFAEVARYBFwEYARkBGgEbARwBHQEeAR8BIAEhASIBIwEkASUBJgEnASgBKQEqASsBLAEtAS4BLwEwATEBMgEzATQBNQE2ATcBOAE5AAlzaGFuZ3lpYnUHeGlheWlidQtsaWppcXVlcmVueA5zaGliaWUtY2h1YW50aQt6aGFveGlhbmdqaQh6aG9uZ3BhaQltb3ZlX2xlZnQKbW92ZV9yaWdodAtyaWdodGJvdHRvbQdzY2FubmVyCmZvbGRlcm9wZW4KdW5zZWxlY3RlZAlzZWxlY3RlZDELZXhpdEZ1bGxXZWIGcGVuY2lsCGNyb3BNb3ZlB2Z1bGxXZWILc2hyaW5rSW1hZ2UMc2hyaW5rQ2FudmFzCGZpdFdpZHRoCWZpdEhlaWdodAxtYWduaWZ5SW1hZ2UNbWFnbmlmeUNhbnZhcwdhdXRvRml0CHNlbGVjdGVkB2NvbmZpcmUIdGFnQ29sb3IGY2FuY2xlB211dGlwbGULZXhpdE11dGlwbGUGYWRkVGFnCXJvdGF0ZUFsbApmdWxsRGV2aWNlCHBhZ2VOZXh0CXRodW1ibmFpbAR0YWdzBHRyZWUHcGFnZVByZQdwYWdlRW5kCXBhZ2VTdGFydAhleGl0RnVsbARzYXZlBXByaW50BmRlbGV0ZQRmaWxlBm1pcnJvcgRmbGlwBGxpc3QEY3JvcApyb3RhdGVMZWZ0BHdpcGUEdW5kbwVyZXNldARyZWRvCHJlYWRUeXBlAAAAAA==') format('truetype'); -} - -.ds-dvs-ui-iconfont { - font-family: 'ds-dvs-ui-iconfont'; - font-size: 20px; - font-style: normal; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -@font-face { -font-family: "ds-dwt-ui-d-iconfont"; -src: url("data:application/x-font-eot;base64,b'ECkAAGgoAAABAAIAAAAAAAIABQMAAAAAAAABAJABAAAAAExQAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAA4vbsiQAAAAAAAAAAAAAAAAAAAAAAABAAaQBjAG8AbgBmAG8AbgB0AAAADgBSAGUAZwB1AGwAYQByAAAAFgBWAGUAcgBzAGkAbwBuACAAMQAuADAAAAAQAGkAYwBvAG4AZgBvAG4AdAAAAAAAAAEAAAALAIAAAwAwR1NVQiCLJXoAAAE4AAAAVE9TLzI8kkkeAAABjAAAAGBjbWFwtk6vzAAAAqQAAAPoZ2x5ZpRyyA4AAAbsAAAc4GhlYWQdWFZRAAAA4AAAADZoaGVhB38DrAAAALwAAAAkaG10eLgC//UAAAHsAAAAuGxvY2G3yK+UAAAGjAAAAF5tYXhwAU0BggAAARgAAAAgbmFtZRCjPLAAACPMAAACZ3Bvc3QbuT2/AAAmNAAAAjIAAQAAA4D/gAAABAD/+f/9BAMAAQAAAAAAAAAAAAAAAAAAAC4AAQAAAAEAAIns9uJfDzz1AAsEAAAAAADdHoknAAAAAN0eiSf/+f9/BAMDhwAAAAgAAgAAAAAAAAABAAAALgF2ABUAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKADAAPgACREZMVAAObGF0bgAaAAQAAAAAAAAAAQAAAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAQEAAGQAAUAAAKJAswAAACPAokCzAAAAesAMgEIAAACAAUDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBmRWQAwOYg5k4DgP+AAFwD3ACBAAAAAQAAAAAAAAAAAAAAAAACBAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAD/+QQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAP/9BAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAD//wAAAAUAAAADAAAALAAAAAQAAAG8AAEAAAAAALYAAwABAAAALAADAAoAAAG8AAQAigAAAAgACAACAADmMeY25k7//wAA5iDmM+Y4//8AAAAAAAAAAQAIACoAMAAAABUAFgAXABgAGQAaABsAHAAdAB4AHwAgACEAIgAjACQAJQAmACcAKAApACoAKwAsAC0AFAATABIADwAQABEADQAOAAsACgAJAAgABwAGAAwABQAEAAMAAQACAAABBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAIsAAAAAAAAAC0AAOYgAADmIAAAABUAAOYhAADmIQAAABYAAOYiAADmIgAAABcAAOYjAADmIwAAABgAAOYkAADmJAAAABkAAOYlAADmJQAAABoAAOYmAADmJgAAABsAAOYnAADmJwAAABwAAOYoAADmKAAAAB0AAOYpAADmKQAAAB4AAOYqAADmKgAAAB8AAOYrAADmKwAAACAAAOYsAADmLAAAACEAAOYtAADmLQAAACIAAOYuAADmLgAAACMAAOYvAADmLwAAACQAAOYwAADmMAAAACUAAOYxAADmMQAAACYAAOYzAADmMwAAACcAAOY0AADmNAAAACgAAOY1AADmNQAAACkAAOY2AADmNgAAACoAAOY4AADmOAAAACsAAOY5AADmOQAAACwAAOY6AADmOgAAAC0AAOY7AADmOwAAABQAAOY8AADmPAAAABMAAOY9AADmPQAAABIAAOY+AADmPgAAAA8AAOY/AADmPwAAABAAAOZAAADmQAAAABEAAOZBAADmQQAAAA0AAOZCAADmQgAAAA4AAOZDAADmQwAAAAsAAOZEAADmRAAAAAoAAOZFAADmRQAAAAkAAOZGAADmRgAAAAgAAOZHAADmRwAAAAcAAOZIAADmSAAAAAYAAOZJAADmSQAAAAwAAOZKAADmSgAAAAUAAOZLAADmSwAAAAQAAOZMAADmTAAAAAMAAOZNAADmTQAAAAEAAOZOAADmTgAAAAIAAAAAACAANgCiANQBCAE4AyYDpAR4BSYFYAWWBdIGVgZyBo4GtgbeB2YHnAewB9oIPAhQCHQIngjcCUAJoAn4ClYKxgsWC2ILlgvIC/gMfgy6DSYNhA3GDhwOOg5wAAAAAwAAAAADwAMAAAMABwANAAATESERAyERIQcnAScHF0ADgFP9JgLaUD7+2X41uwMA/QADAP1TAlqIOP69ZkCYAAIAAAAAA8ADAAADAAcAABMRIREDIREhQAOAU/0mAtoDAP0AAwD9UwJaAAAABgAA/4AEAAOAAAwAGQAmADQAOABEAAABIg4BFB4BMj4BNC4BAyIuATQ+ATIeARQOASUWPgIuAg4CHgElIRUzESMnIQcjESE1IQEhFyEBNSMVIxUzFTM1MzUB4DhgODhgcGA4OGA4IzoiIjtEOyIiOgEMDhkSBAoVGxoRBAkW/UsDZk3lXP6CXeQCAP5NAR0BKzT+bQIwTJqaTJoCEThfcWA4OGBxXzj+sSI6RTsiIjtFOiL5AgoVGxoRBQoVHBkSss8BHMTE/QRMAyd3/auZmU2amk0AAAAABgAA/4AEAQOAAAMABwALAA8AEwAXAAABFSE1JSERIQUhFSEnESERAxUhNSUhESEDs/yaA7P8AAQA/M0CZv2aTQMATf2aArP9AAMAAfPm5k3+gI1ms/8AAQACs2ZmTf8AAAAAAAUAAP+ABAADgAACAAYACgAOABgAAAEjNQMRIRElIREhAQUnLQERMxEhESEVIREC6c2d/s4Bf/40AcwBmv7pMwEW/M5NA2b+gAHNAa3O/oT+zgEyTf40Ayf6Ofqg/jMBgPyaTQQAAAAABAAA/4AEAAOAAAYACgAOABgAAAE1IxcHFzcBIREhFyERIQMRMxEhESEVIREDM81JxTPI/RsBzP40TQEy/s5NTQNm/oABzQHmzUmxObT9TAHMTf7OA7P+MwGA/JpNBAAAFQAAAAAEAQINAAcACwAPABMAGwAsADwAUQBhAH0AhwCbAMQA6AEJARcBKwE/AVsBZQF1AAATIxcHFTM1LwEzByMXIzczFyM1MycjNzMHMyczNyYiDgEdARQeATI+AT0BNCYHFA4BIi4BPQE0PgEyHgEVFy4BIgYHNSMVMzUeATMyPgE9AiYHFAcUBiIvATU+ATIWFx0BNyYiDgEdARQeATMyNj0BIxUOASIuAT0BMzU0JgcjNTQ+ATIeARU3JiIGBzUjFTM1NzYyFh0BMzU0JhcnLgE0NjIeARc3NC4CIyIGFRQWHwEeARQGIi4BJwceAjI+ATU0JjcmIg4BHQEUHgEyPgE9ASMVBxQGIiY9ATQ+ATIeAR0BMzU0Jhc0JzU0JiIGFTM1ND4BMhYVFwcOAhQeATMyNjcXMzU0JwYPAQYiJjQ/ATY/ARU3JiIGBzUjFTM1NzYyFh0BMzU0JjcmIgYHNSMVMzU3NjIWHQEzNTQmMyYiDgEdARQeATMyNj0BIwcUBiIuAT0BMzU0JgcjNTQ+ATIeARU3IyIGBzUjFTM1PgEzHwE17OQdJPYpq64VhGtTEy1Szc0GwR8YGYMbGccHFw0GBg0XDgUFCgIHDAYDAgcMBwJMAgcMBwMPDwMGBQcJAwENAQMHAwUCBQcDAUIEFAoFBAsJDAsPAQQGBAIgAwsRAQMIBAFFAgoLAxAQBQMFAw8CVxMDBAYMBgIBDQQHCwYNDQYFEgYHBwwHAgEOAQcMEwwHCjgFEgoEAwsSCgMNAQQIBAEDCAMCDQM+AQoYDA8CAwYEAQwHCAUECAQHCAIBDg8BAgMCBgQCAwMDBkgDCgsDDw8FAwYCDwI7AwoLAw8PBQMGAhADNgUTCgUECgoMCg4BBAYEAiADDBEBBAgDAT8BBQkEDw8CBwMEBAIMeGw0Mm5jVUo1hBkVVkVFQQQJEAssCxEKChAMKwwQSgcJBQQKBzIHCQUFCgYLBQYEAwZtIQMECREHFAkGIggDBgUBAjUCAgQFChMuBAcQChMKDwgPDAMMAgQDBgUQBwoSGgUFCQQEBwUZAgYDCFJCBAEEBT5DAwgTEQMGDQYFCQcEBgwIBA8MCA0FEQQKDgcHDAYECg8JBwwJCw8bAwcPChMJEAgGDAgGBwcEAwcKGgYJAwIIBAUFCA1CAQMpDQ0NDgQEBQICBA4FBAYLDQgGCQUNBgQKAgEDAQYIAwUCAgQXPgIGAwhSQgQBBAU+QwMIAwIGAwhSQgQBBAU+QwMJBAcQChMKDwgPDAMMAgQDBgUQBwoRGQUFCQQEBwUbBQgMUjwEBAEBEQAAAA4AAP9/BAADgAADAAcADQATABkAIAA0ADgAPABAAEQASABMAFAAABMzESMBMxEjATM1IxUzASMVMzUjISMVMzUjASMVMxUzNQEhETMRMxEzETMRMxEzETMRMzUhNyERIRczFSMlIREhJyM1MwUzFSMlMxUjJzMRI4ozMwGaTU3+KY3aTQNmjdpN/JpN2o0DZo2NTfwAAQ5NTTPdM0VNg/wAigET/u0zra0CwP7tARMzra39nFpaAeBaWtwzMwFQ/sMBPf6/AyRN2v0nTdraTQOzTY3a/dD+wAFA/sEBP/7BAT/+wAFATUABEzOt4P7tM60qWVlZtv7tAAAAAAf/+f+ABAEDhwAQACAARQBVAGAAgACXAAABJiIOAR0BFB4BMj4BPQE0JgcUDgEiLgE9ATQ+ATIeARU3JiIOAR0BFB4BMj4BPQEjFRQOASIuAT0BND4BMh4BHQEzNTQmFz4CNTQuASsBETM1MxczJw4BKwE1MzIWFRQBJz4BNC4DDgIHBhcWFxYXHgEzMjc+ATcBFjI2NCUuAjY3PgIzMhceAhUUBg8BDgEmASERPCMQECM8Iw8PKQQKFQoDAwoVCgTXETskDg4kPCENNQMJFAsEAwoWCgI1Da0NDgYVJxxHOBMgOTwDEA0QExMNAWn/MDQyX4CRk4NlHCcHBzEyVDV6PxUVQXgyAQIKHRX85jRJJAYXHGWERiQiUoRKNTIBPJ6lAlgKFSccZhwoFRUoHGYcJ7cJEQkKEAmBChAKChAKQgkWKRxiGygXFSUXFxsJEgoJEQt8CxELCxAKGRcXJHwGExoRHCAM/u98fK8JCU4UEg79u/46j5aNc0wdFkVvRV1lYlZYOCMlAgczKv7/ChYf9yJjdno5QmQ2BxBmk1NHgDICOzUVAAAHAAD/fwOZA4AAHwA0AEQAUQBaAGcAdAAAATQnJicmIgcGBwYVFBcWFw4BFRQWMyEyNjU0Jic2NzYlNDc2NzYyFxYXFhQHBgcGIicmJyYBFAYjISImNTQ2NxYyNx4BAzI+ATQuASIOARQeATcyFhQGIiY0NhcyPgE0LgEiDgEUHgETMh4BFA4BIi4BND4BA5g3N1xf3l9cNzcsKkwnKS4gAfEfLiknTCos/RcuLUxPtk9MLS4uLUxPtk9MLS4CTwMC/g4CAyQhV8RXIST+GywbGyw2LBsbLBsLDw8WDw8LN1w2NlxuXDY2XDcjPCMjPEY8IyM8AehuYFw2ODg2XGBuYldUOSxuOyAtLSA7biw5VFdiW05NLC8vLE1Ot05NLC8vLE1O/kECBAQCMVojLCwjWgGIGi01LRoaLTUtGnwQFRAQFRDkNl1tXTY2XW1dNgFLIztHOyMjO0c7IwAFAAD/gAQAA4AABAAMABAAFAAhAAABIREhESUVMzUzFSM1AzUhFREhNSETIxEhESMRMxEhETMXAxn85wQA/d9sMvqDAgD+AAIAs2b9ZmbqAZMvugOA/AADFp1mZrq6/JrW1gEjQ/6aAbP+TQNm/voBBr0AAAQAAP9/BAADgAAIABAAFgAaAAAlAScDJwcXFjIBNSERMxUhEQEjESEVIQEhESECNwE4Sv+ERrcIFQED/M3NAzP8zYACmf3nAub9ZwKZXAE6SP79g0m5CAJfzfzNzQMz/ecCmYD9GgKZAAAAAAgAAP+ABAADgAADAAcACwAPABMAFwAbAB8AABEhESEXMxUjAyERIRczFSMDIREhFzMVIwERIREDIREhAWb+mk3NzU0BZv6aTc3NTQFm/ppNzc0BgAIzTf5nAZkCTQEzTZn85gEzTZkBGQE0TZoCTfwABAD8TQNmAAYAAP+ABAADgQAuADsASABMAFAAVAAACQEnJicuAgcGBwYHBgcGByc+ATQuASIOARUUFhcNAQ4BFB4BMj4BNTQmJzcXMwEiLgE0PgEyHgEUDgETFA4BIi4BND4BMh4BJTMVIzczFSM3MxUjAhwBlwIDBAUSGhEUFxkeISV1iLIrMzFVY1QyQTQBB/7jKzQyVGNVMUA02cas/XIdMR0dMToxHBwxTRwxOjEdHTE6MRwBkU1NgE1NgE1NAagBGAMFAwYHAwMDCAoQEhtTYFYYVWRVMTFVMTpdFH3JGFZkVTExVTE6XBWVXQFEHTE6MRwcMToxHf3ZHTEcHDE6MR0dMXlNTU1NTQAAAAIAAP9/A4ADgAAFAAkAABMJARcJASEzESOAAcr+NjYCAP4AAn1NTQNK/jb+NjYCAAIA/AAAAAAAAgAA/4ADgAOAAAUACQAAAScJATcJATMRIwOANv4AAgA2/jb+yk1NA0o2/gD+ADYBygIA/AAAAAADAAD/gAQDA4AABAAJABMAADUVMwEnASM1ARclJyYiDwEXNzY0zwJ20/5AZgImZwEZiBEuEWfSbRFQ0AJz0/0HZwImZ/SIERFp02QRLwAAAAMAAP/pBAADGgAHAA4AEgAAATUhJyERIRMlIRchFSEDKQETIQOa/kZa/noDinb8TQEZWgGN/W1tAwP9SlkCrQHQ42f80AHm/WeW/mYBTQAABgAA/38D/wN/AAsAFAAdACkARABZAAATFAcGKwEVMxUzESMXIgYUFjI2NCYnIgYUFjI2NCY3FAcGKwEVMxUzESMJATY3NjU0JyYnJiIHBgcGFBcWFxYzMjc2NwkBIicmJyY0NzY3NjIXFhcWFAcGBwblCwoWCi09NbQMExQaExMPCxQUGRQTmwsKFgotPTUBvP7WLBgZODZcYN5fXTY4ODZdX29JREI2ASr90VpNTCwtLSxMTbROSywtLSxLTgJqFQwJMLYBGtgTHBMTHBONEhwTExsTQRUMCTC2ARr9QwEqNkJESW9fXTY4ODZdX99fXDc3GBkt/tUBGS4sS060TUstLS0tS020TkssLgAAAAAGAAD/gAQAA4AAAwAHAA0AEwAaACEAABkBIREDIREhBTM1IxUzITM1IxUzEzUjFSMVMyE1IzUjFTMEAE38mgNm/Ueg7U0CDE3toE1NoKD+lKBNTQOA/AAEAPxNA2atTe3tTf2n7aBNTaDtAAABAAD/gAMcA4AABQAAAScJATcBAxs2/gACADb+NwNKNv4A/gA2AcoABAAA/4AEAAOAAAMABwAOABUAABkBIREDIREhATM1IzUHFyE3JxUjFTMEAE38mgNm/WemppqaAcyamqamA4D8AAQA/E0DZv4nTFqAgICAWkwAAAAAAwAA/4AEAAOAAAsAJgBCAAABIxUjFTMVMzUzNSMBNjc2NTQnJicmIgcGBwYUFxYXFjMyNzY3ATclNSMVLgInMzUjPgI3FTM1HgIXIxUzDgIBwE1DQ01DQwEVLRgZODZdX99fXTY4ODZdX29JREE2ASk6/cBNS39RCX5+CVF/S01Lf1EJfn4JUX8CUENNQ0NN/tQ2QkRKb19dNjg4Nl1f319dNjgZFy3+1jrifn4JUX9LTUt/UQl+fglRf0tNS39RAAAAAAEAAP9/AxwDgAAFAAABBwkBFwEBGzYByf43NgIAA4A2/jb+NjYCAAACAAD/fwQAA4AAEQAVAAAlIREhETMRIRUzETMxIRUzNTMBMxUjBAD85gI0TPyamToCR0ya/JlNTWYCNP4AAk1N/YCamgNmZgAEAAD/gAQAA4AAAwAHAA4AFQAAGQEhEQMhESEBMzUzJwczEyM1IxUjFwQATfyaA2b+J0xagIBaplpMWoADgPwABAD8TQNm/o2mmpr+NKammgAAAAAGAAD/gAQAA4AAAwAHAA4AFQAcACMAABkBIREDIREhATM1MycHMxMjFSMXNyMTFTMVNycVBTM1IzUHFwQATfyaA2b+J0xagIBaTExagIBaOoaamv40hoaamgOA/AAEAPxNA2b+rYaamv66hpqaAQxMWoCAWkxMWoCAAAAABgAA/4AEAAOBAAQACgAUACEALgA6AAAlIScHJwEjESE1ISUhESE3IREhEQcDIg4BFB4BMj4BNC4BAyIuATQ+ATIeARQOARMHJwcXBxc3FzcnNwE6AeB9d3D+l00DM/0aAxb9gwEaIP56AxZNST9qPj5qfWo+Pmo+MlUyMlVkVDIyVCBSUyFTUyFTUiFTU7PXoHQBVfzNTZkCgE385wGGIAIAPmp9aj4+an1qPv5hMlVkVDIyVGRVMgEsU1MhUlMhU1MhU1IAAAAFAAD/gAQAA4EADwAUACEALgA6AAAFIREhNyEiFREUMyEyNREHBQchAwcBIg4BFB4BMj4BNC4BAyIuATQ+ATIeARQOARMHJwcXBxc3FzcnNwNN/QABsCD95AEBA5cBTP3ZjAJmtqsBez9qPj5qfWo+Pmo+MlUyMlVkVDIyVCBSUyFTUyFTUiFTUzMDAE0B/GgBAQIcHVbdASPbAus+an1qPj5qfWo+/mEyVWRUMjJUZFUyASxTUyFSUyFTUyFTUgAGAAD/swQAA00AEwAXABsAKQAqADcAAAEjESERIyIOARURMxUhNTMRNC4BJSEVIQEhESEXIzUhFSMRNDYzITIWFQcjFB4BMj4BNC4BIg4BA2Yz/ZozKkcpzQJmzSlH/YoBzP40Acz+NAHMzYD9moAeFQMAFR6AMw4XHBgNDRgcFw4CTQEA/wApRyr+zc3NATMqRymzs/2zAQAzgIABABUeHhUwDhgNDRgcFw4OFwAAAAMAAP+ABAADgQAYAC0AOQAAASIHDgEHBhQXHgEXFjI3PgE3NjQnLgEnJgMiJyYnJjQ3Njc2MhcWFxYUBwYHBhMnBycHFwcXNxc3JwIAaF9cjicoKCeOXF/QX1yOJygoJ45cX2h2ZWM6Ozs6Y2XsZWM6Ozs6Y2WCNsLDN8TCNsLDN8QDgCgnjlxf0F9cjicoKCeOXF/QX1yOJyj8TTs6Y2XsZWM6Ozs6Y2XsZWM6OwJ2N8TCNsLDN8TCNsIAAf/9/4AEAQOBAEYAAAEiBg8BBi4BJyY3NjcTNi4BBgcDDgEmNRE0JiIGFREUBiYnAy4BDgEXExYGJi8BLgEjIg4BHwEWFRQeATsBMjY3AT4BNzYmA9QhPBhfDygfBAUEAgNwBhkwKwd0AxAOIzIjDhACZAcsLxkGZwMMEAWIBxgOExwHCl88R3lIPDpqKQE/BQgBARoBbxkXbhABGxYkIRALAaEYLA0ZGP5nCAUJCQHEGSMjGf5JCQkFCQF3GBkOKRn+fwkMAQjsDA4ZJBGmZndIeUgsKQFPBBEJEhsAAAACAAD/gAQAA4EABQAyAAABESE1IzUTIgcGByYxESEnNjc+ATIeAhQOAiImJyYnBxYXFhcWMjc+ATc2NCcuAScmAbABM+YDhXRwRlEBM6McJzycqpx4QUF4nKubPBUTShgdR1xf0F9cjiYpKCeOXF8CM/7NTeYBTUA/bFH+zaQvJzxBQHmcqpx4QUA9FBotIhxHJygoJ45cX9BfXI4nKAAABwAA/38EAQOAAAQACAANAA4AFwAhACsAABMRIREhFyERISUnByEvASMUFjI2NCYiBgEhNQcXNSEVNycBMycHMxEjFzcjAQL//QFRAlz9pAEIXWwB3YuUPyU0JSU0JQGQ/cBgYAJAYGABJzlgYDo6YGA5Ai79UgMAUv2kqHKq51oaJSU0JSUBqTpgYDo6YGD+oGBg/cBgYAADAAD/gAQBA4AAFQAZAB0AAAE1NCcmJyYjIgc1DQE1NjMyFhcWHQEBIREhFyERIQQAMC9RUmANDf7xAQ8NDVCKKCr8NgMm/NpNAo39cwEOdGRXVDEzAYyrqosBVEZIVHP+cgJtTf4tAAMAAP+ABAADgAAFABAAGwAAAQUhESEFASEVIzUHFzUzFSEFJTUzFTcnFSM1JQQA/e3+EwHtAhP8TQF5k3Nzk/6HA2b+YJp5eZoBoAOAzf2azQLmwE1zc03Aq6HKTXNzTcqhAAADAAD/gAQAA4AABQAQABsAAAUDESERAzcTMxUjFzcjNTMTAxEjNTMnBzMVIxEEAM39ms1vocpNc3NNyqGrwE1zc03AgAITAe3+E/3tTQGgmnl5mv5gA2b+h5Nzc5MBeQAOAAD/fwQAA4AAAwAHAAsADwATABkAHQAhACgAMgA2AD4ASQBPAAABESERJSERIQEHFzcTNxcHAzMVKwEzNSMXNwU3JwcFNxcHBSYnMQcXNxcjNycHFyMVMzUlMxUjEzUnIxUzFzcDKwEnBx8CMzUjATEnBxc3A7P+FwI2/X0Cg/y2RTVGJ0Y2RlyAgHdAtlpDAgVGNkX+UkY1RgKIEBhGNUZUHxk1RiwngP6AgIApHYBPFUXSAQMbRh4FEU4dAW0vRTVGAzP8mgNmTfwAApEgdSD++iB0IALLTU3DIIogdCDvIHQgOSI1IHQgrgt1IGBNQwpNAy0BP00uIP07OyBCASVNAW5mIHQgAAAABQAA/38DyAOAAAkADQARABUAHQAAFyEVNTQDEyETAwUhNSELASEDARchNyMzAyEDMxMhSAOAlmz8xGyGAzP9FwLpP03+Ik0BjUX+1EWYRFoCAWBHfP1DfAS9AgGMAbX+S/54clwDB/7KATb+fsPD/vEBD/7IAAAABQAA/38EAQOAAA0AFgAxADwARQAAJSMmJyYvAQEjARUhNSEDFhceARcjFyEBMyc0NzY3NjIXFhUXMzU0JyYjIgcGBzUjFgclMjc2NTQmIgYUFjcyFhQGIiY0NgLgVAM4N14DAQpm/aMEAP5czB0ZOT4CVG/+DgJMRwEEBgkLHgoSAUcXEiEdGRQLRwEBAQIeFRcoQCopIA0MDhYODUt5a2hFAgGi/E1NTQHRFho7llJ+AVSQBQoLBwoHChyOoEAcFg4MESsNhLcTFSciKytHKm4UGhISGxMAAwAA/4AEAAOBAAsAJgA7AAABIxUjFTMVMzUzNSMJATY3NjU0JyYnJiIHBgcGFBcWFxYzMjc2NwkBIicmJyY0NzY3NjIXFhcWFAcGBwYBvk2kpE2oqAJC/tUtGBk4Nl1f319dNjg4Nl1fcElEQjYBK/3QW01LLS0tLUtNtU1MLC0tLExNArOmTaamTf2pASs2QkRJcF9dNjg4Nl1f319dNjgZGC3+1QEaLSxMTbVNSy0tLS1LTbVNTCwtAAAIAAD/5gQAAxoABQAJAA0AEwAXAB0AIwAnAAAlIxUhNSMRMxUjASEVISUVMxUzNQEhFSElIxUhNSMDMzUzNSERMxUjA62tAQBTU1P90wEA/wABgK1T/YABAP8A/tNTAQCtU1Ot/wBTUzpUzQEamgHnVFRUec39IFTNzVQCE3lU/rOaAAADAAD/gAQAA4EAAwAeADMAABMhFSEJATY3NjU0JyYnJiIHBgcGFBcWFxYzMjc2NwkBIicmJyY0NzY3NjIXFhcWFAcGBwbNAZn+ZwMz/tUtGBk4Nl1f319dNjg4Nl1fcElEQjYBK/3QW01LLS0tLUtNtU1MLC0tLExNAg1N/fYBKzZCRElwX102ODg2XV/fX102OBkYLf7VARotLExNtU1LLS0tLUtNtU1MLC0AAgAA/7MEAANNAAYADgAAJTMRMycHMwERIREjESERAc1NyfDwygHm/JpNBACDAdfz8/7G/uABIP6TAW0AA////4AEAAOAABYAGgAeAAABFS0BFSYjIgcGBwYdATM1NDc2NzYzMgcRIREDIREhAXwBD/7xDgxgUlEvMDYqKERGUA2VAyZN/XMCjQK2i6qrjAEzMVRXZHJwVElGKSvK/ZMCbf3gAdMAAAAAAAASAN4AAQAAAAAAAAATAAAAAQAAAAAAAQAIABMAAQAAAAAAAgAHABsAAQAAAAAAAwAIACIAAQAAAAAABAAIACoAAQAAAAAABQALADIAAQAAAAAABgAIAD0AAQAAAAAACgArAEUAAQAAAAAACwATAHAAAwABBAkAAAAmAIMAAwABBAkAAQAQAKkAAwABBAkAAgAOALkAAwABBAkAAwAQAMcAAwABBAkABAAQANcAAwABBAkABQAWAOcAAwABBAkABgAQAP0AAwABBAkACgBWAQ0AAwABBAkACwAmAWNDcmVhdGVkIGJ5IGljb25mb250aWNvbmZvbnRSZWd1bGFyaWNvbmZvbnRpY29uZm9udFZlcnNpb24gMS4waWNvbmZvbnRHZW5lcmF0ZWQgYnkgc3ZnMnR0ZiBmcm9tIEZvbnRlbGxvIHByb2plY3QuaHR0cDovL2ZvbnRlbGxvLmNvbQBDAHIAZQBhAHQAZQBkACAAYgB5ACAAaQBjAG8AbgBmAG8AbgB0AGkAYwBvAG4AZgBvAG4AdABSAGUAZwB1AGwAYQByAGkAYwBvAG4AZgBvAG4AdABpAGMAbwBuAGYAbwBuAHQAVgBlAHIAcwBpAG8AbgAgADEALgAwAGkAYwBvAG4AZgBvAG4AdABHAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAHMAdgBnADIAdAB0AGYAIABmAHIAbwBtACAARgBvAG4AdABlAGwAbABvACAAcAByAG8AagBlAGMAdAAuAGgAdAB0AHAAOgAvAC8AZgBvAG4AdABlAGwAbABvAC4AYwBvAG0AAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALgECAQMBBAEFAQYBBwEIAQkBCgELAQwBDQEOAQ8BEAERARIBEwEUARUBFgEXARgBGQEaARsBHAEdAR4BHwEgASEBIgEjASQBJQEmAScBKAEpASoBKwEsAS0BLgEvAAhzZWxlY3RlZAp1bnNlbGVjdGVkFGEtYWRkaW1hZ2Vmcm9tY2FtZXJhCWltYWdlbGlzdAx1bmZ1bGxzY3JlZW4KZnVsbHNjcmVlbgtvcGVuc2Nhbm5lcgdiYXJjb2RlA29jcgZ3ZWJjYW0Fc2F2ZTEMbXVsdGktc2VsZWN0B3RodW1iXzIDY3V0D2Fycm93X3JpZ2h0X3RvcA5hcnJvd19sZWZ0X3RvcARlZGl0CWxvYWRsb2NhbAlpY29uLXRlc3QKZmlsbHNjcmVlbgphcnJvd19sZWZ0DGFsaWduaGNlbnRlcg1jbGlja3Rvem9vbmluC2Fycm93X3JpZ2h0BGNyb3AMYWxpZ252Y2VudGVyBmNlbnRlcg5kZWxldGVhbGxpbWFncwpkZWxldGVpbWFnBXByaW50BGV4aXQEaGFuZAVyZXNldBFjaGFuZ2VfaW1hZ2Vfc2l6ZQtyb3RhdGVfbGVmdARmbGlwBm1pcnJvcgZkZXNrZXcHc2Nhbm5lcgZyb3RhdGUHem9vbW91dAZzZWxlY3QGem9vbWluBnVwbG9hZAxyb3RhdGVfcmlnaHQAAAAA'") format('embedded-opentype'), -url('data:font/ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwR1NVQiCLJXoAAAE4AAAAVE9TLzI8kkkeAAABjAAAAGBjbWFwtk6vzAAAAqQAAAPoZ2x5ZpRyyA4AAAbsAAAc4GhlYWQdWFZRAAAA4AAAADZoaGVhB38DrAAAALwAAAAkaG10eLgC//UAAAHsAAAAuGxvY2G3yK+UAAAGjAAAAF5tYXhwAU0BggAAARgAAAAgbmFtZRCjPLAAACPMAAACZ3Bvc3QbuT2/AAAmNAAAAjIAAQAAA4D/gAAABAD/+f/9BAMAAQAAAAAAAAAAAAAAAAAAAC4AAQAAAAEAAIns9uJfDzz1AAsEAAAAAADdHoknAAAAAN0eiSf/+f9/BAMDhwAAAAgAAgAAAAAAAAABAAAALgF2ABUAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKADAAPgACREZMVAAObGF0bgAaAAQAAAAAAAAAAQAAAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAQEAAGQAAUAAAKJAswAAACPAokCzAAAAesAMgEIAAACAAUDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBmRWQAwOYg5k4DgP+AAFwD3ACBAAAAAQAAAAAAAAAAAAAAAAACBAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAD/+QQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAP/9BAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAD//wAAAAUAAAADAAAALAAAAAQAAAG8AAEAAAAAALYAAwABAAAALAADAAoAAAG8AAQAigAAAAgACAACAADmMeY25k7//wAA5iDmM+Y4//8AAAAAAAAAAQAIACoAMAAAABUAFgAXABgAGQAaABsAHAAdAB4AHwAgACEAIgAjACQAJQAmACcAKAApACoAKwAsAC0AFAATABIADwAQABEADQAOAAsACgAJAAgABwAGAAwABQAEAAMAAQACAAABBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAIsAAAAAAAAAC0AAOYgAADmIAAAABUAAOYhAADmIQAAABYAAOYiAADmIgAAABcAAOYjAADmIwAAABgAAOYkAADmJAAAABkAAOYlAADmJQAAABoAAOYmAADmJgAAABsAAOYnAADmJwAAABwAAOYoAADmKAAAAB0AAOYpAADmKQAAAB4AAOYqAADmKgAAAB8AAOYrAADmKwAAACAAAOYsAADmLAAAACEAAOYtAADmLQAAACIAAOYuAADmLgAAACMAAOYvAADmLwAAACQAAOYwAADmMAAAACUAAOYxAADmMQAAACYAAOYzAADmMwAAACcAAOY0AADmNAAAACgAAOY1AADmNQAAACkAAOY2AADmNgAAACoAAOY4AADmOAAAACsAAOY5AADmOQAAACwAAOY6AADmOgAAAC0AAOY7AADmOwAAABQAAOY8AADmPAAAABMAAOY9AADmPQAAABIAAOY+AADmPgAAAA8AAOY/AADmPwAAABAAAOZAAADmQAAAABEAAOZBAADmQQAAAA0AAOZCAADmQgAAAA4AAOZDAADmQwAAAAsAAOZEAADmRAAAAAoAAOZFAADmRQAAAAkAAOZGAADmRgAAAAgAAOZHAADmRwAAAAcAAOZIAADmSAAAAAYAAOZJAADmSQAAAAwAAOZKAADmSgAAAAUAAOZLAADmSwAAAAQAAOZMAADmTAAAAAMAAOZNAADmTQAAAAEAAOZOAADmTgAAAAIAAAAAACAANgCiANQBCAE4AyYDpAR4BSYFYAWWBdIGVgZyBo4GtgbeB2YHnAewB9oIPAhQCHQIngjcCUAJoAn4ClYKxgsWC2ILlgvIC/gMfgy6DSYNhA3GDhwOOg5wAAAAAwAAAAADwAMAAAMABwANAAATESERAyERIQcnAScHF0ADgFP9JgLaUD7+2X41uwMA/QADAP1TAlqIOP69ZkCYAAIAAAAAA8ADAAADAAcAABMRIREDIREhQAOAU/0mAtoDAP0AAwD9UwJaAAAABgAA/4AEAAOAAAwAGQAmADQAOABEAAABIg4BFB4BMj4BNC4BAyIuATQ+ATIeARQOASUWPgIuAg4CHgElIRUzESMnIQcjESE1IQEhFyEBNSMVIxUzFTM1MzUB4DhgODhgcGA4OGA4IzoiIjtEOyIiOgEMDhkSBAoVGxoRBAkW/UsDZk3lXP6CXeQCAP5NAR0BKzT+bQIwTJqaTJoCEThfcWA4OGBxXzj+sSI6RTsiIjtFOiL5AgoVGxoRBQoVHBkSss8BHMTE/QRMAyd3/auZmU2amk0AAAAABgAA/4AEAQOAAAMABwALAA8AEwAXAAABFSE1JSERIQUhFSEnESERAxUhNSUhESEDs/yaA7P8AAQA/M0CZv2aTQMATf2aArP9AAMAAfPm5k3+gI1ms/8AAQACs2ZmTf8AAAAAAAUAAP+ABAADgAACAAYACgAOABgAAAEjNQMRIRElIREhAQUnLQERMxEhESEVIREC6c2d/s4Bf/40AcwBmv7pMwEW/M5NA2b+gAHNAa3O/oT+zgEyTf40Ayf6Ofqg/jMBgPyaTQQAAAAABAAA/4AEAAOAAAYACgAOABgAAAE1IxcHFzcBIREhFyERIQMRMxEhESEVIREDM81JxTPI/RsBzP40TQEy/s5NTQNm/oABzQHmzUmxObT9TAHMTf7OA7P+MwGA/JpNBAAAFQAAAAAEAQINAAcACwAPABMAGwAsADwAUQBhAH0AhwCbAMQA6AEJARcBKwE/AVsBZQF1AAATIxcHFTM1LwEzByMXIzczFyM1MycjNzMHMyczNyYiDgEdARQeATI+AT0BNCYHFA4BIi4BPQE0PgEyHgEVFy4BIgYHNSMVMzUeATMyPgE9AiYHFAcUBiIvATU+ATIWFx0BNyYiDgEdARQeATMyNj0BIxUOASIuAT0BMzU0JgcjNTQ+ATIeARU3JiIGBzUjFTM1NzYyFh0BMzU0JhcnLgE0NjIeARc3NC4CIyIGFRQWHwEeARQGIi4BJwceAjI+ATU0JjcmIg4BHQEUHgEyPgE9ASMVBxQGIiY9ATQ+ATIeAR0BMzU0Jhc0JzU0JiIGFTM1ND4BMhYVFwcOAhQeATMyNjcXMzU0JwYPAQYiJjQ/ATY/ARU3JiIGBzUjFTM1NzYyFh0BMzU0JjcmIgYHNSMVMzU3NjIWHQEzNTQmMyYiDgEdARQeATMyNj0BIwcUBiIuAT0BMzU0JgcjNTQ+ATIeARU3IyIGBzUjFTM1PgEzHwE17OQdJPYpq64VhGtTEy1Szc0GwR8YGYMbGccHFw0GBg0XDgUFCgIHDAYDAgcMBwJMAgcMBwMPDwMGBQcJAwENAQMHAwUCBQcDAUIEFAoFBAsJDAsPAQQGBAIgAwsRAQMIBAFFAgoLAxAQBQMFAw8CVxMDBAYMBgIBDQQHCwYNDQYFEgYHBwwHAgEOAQcMEwwHCjgFEgoEAwsSCgMNAQQIBAEDCAMCDQM+AQoYDA8CAwYEAQwHCAUECAQHCAIBDg8BAgMCBgQCAwMDBkgDCgsDDw8FAwYCDwI7AwoLAw8PBQMGAhADNgUTCgUECgoMCg4BBAYEAiADDBEBBAgDAT8BBQkEDw8CBwMEBAIMeGw0Mm5jVUo1hBkVVkVFQQQJEAssCxEKChAMKwwQSgcJBQQKBzIHCQUFCgYLBQYEAwZtIQMECREHFAkGIggDBgUBAjUCAgQFChMuBAcQChMKDwgPDAMMAgQDBgUQBwoSGgUFCQQEBwUZAgYDCFJCBAEEBT5DAwgTEQMGDQYFCQcEBgwIBA8MCA0FEQQKDgcHDAYECg8JBwwJCw8bAwcPChMJEAgGDAgGBwcEAwcKGgYJAwIIBAUFCA1CAQMpDQ0NDgQEBQICBA4FBAYLDQgGCQUNBgQKAgEDAQYIAwUCAgQXPgIGAwhSQgQBBAU+QwMIAwIGAwhSQgQBBAU+QwMJBAcQChMKDwgPDAMMAgQDBgUQBwoRGQUFCQQEBwUbBQgMUjwEBAEBEQAAAA4AAP9/BAADgAADAAcADQATABkAIAA0ADgAPABAAEQASABMAFAAABMzESMBMxEjATM1IxUzASMVMzUjISMVMzUjASMVMxUzNQEhETMRMxEzETMRMxEzETMRMzUhNyERIRczFSMlIREhJyM1MwUzFSMlMxUjJzMRI4ozMwGaTU3+KY3aTQNmjdpN/JpN2o0DZo2NTfwAAQ5NTTPdM0VNg/wAigET/u0zra0CwP7tARMzra39nFpaAeBaWtwzMwFQ/sMBPf6/AyRN2v0nTdraTQOzTY3a/dD+wAFA/sEBP/7BAT/+wAFATUABEzOt4P7tM60qWVlZtv7tAAAAAAf/+f+ABAEDhwAQACAARQBVAGAAgACXAAABJiIOAR0BFB4BMj4BPQE0JgcUDgEiLgE9ATQ+ATIeARU3JiIOAR0BFB4BMj4BPQEjFRQOASIuAT0BND4BMh4BHQEzNTQmFz4CNTQuASsBETM1MxczJw4BKwE1MzIWFRQBJz4BNC4DDgIHBhcWFxYXHgEzMjc+ATcBFjI2NCUuAjY3PgIzMhceAhUUBg8BDgEmASERPCMQECM8Iw8PKQQKFQoDAwoVCgTXETskDg4kPCENNQMJFAsEAwoWCgI1Da0NDgYVJxxHOBMgOTwDEA0QExMNAWn/MDQyX4CRk4NlHCcHBzEyVDV6PxUVQXgyAQIKHRX85jRJJAYXHGWERiQiUoRKNTIBPJ6lAlgKFSccZhwoFRUoHGYcJ7cJEQkKEAmBChAKChAKQgkWKRxiGygXFSUXFxsJEgoJEQt8CxELCxAKGRcXJHwGExoRHCAM/u98fK8JCU4UEg79u/46j5aNc0wdFkVvRV1lYlZYOCMlAgczKv7/ChYf9yJjdno5QmQ2BxBmk1NHgDICOzUVAAAHAAD/fwOZA4AAHwA0AEQAUQBaAGcAdAAAATQnJicmIgcGBwYVFBcWFw4BFRQWMyEyNjU0Jic2NzYlNDc2NzYyFxYXFhQHBgcGIicmJyYBFAYjISImNTQ2NxYyNx4BAzI+ATQuASIOARQeATcyFhQGIiY0NhcyPgE0LgEiDgEUHgETMh4BFA4BIi4BND4BA5g3N1xf3l9cNzcsKkwnKS4gAfEfLiknTCos/RcuLUxPtk9MLS4uLUxPtk9MLS4CTwMC/g4CAyQhV8RXIST+GywbGyw2LBsbLBsLDw8WDw8LN1w2NlxuXDY2XDcjPCMjPEY8IyM8AehuYFw2ODg2XGBuYldUOSxuOyAtLSA7biw5VFdiW05NLC8vLE1Ot05NLC8vLE1O/kECBAQCMVojLCwjWgGIGi01LRoaLTUtGnwQFRAQFRDkNl1tXTY2XW1dNgFLIztHOyMjO0c7IwAFAAD/gAQAA4AABAAMABAAFAAhAAABIREhESUVMzUzFSM1AzUhFREhNSETIxEhESMRMxEhETMXAxn85wQA/d9sMvqDAgD+AAIAs2b9ZmbqAZMvugOA/AADFp1mZrq6/JrW1gEjQ/6aAbP+TQNm/voBBr0AAAQAAP9/BAADgAAIABAAFgAaAAAlAScDJwcXFjIBNSERMxUhEQEjESEVIQEhESECNwE4Sv+ERrcIFQED/M3NAzP8zYACmf3nAub9ZwKZXAE6SP79g0m5CAJfzfzNzQMz/ecCmYD9GgKZAAAAAAgAAP+ABAADgAADAAcACwAPABMAFwAbAB8AABEhESEXMxUjAyERIRczFSMDIREhFzMVIwERIREDIREhAWb+mk3NzU0BZv6aTc3NTQFm/ppNzc0BgAIzTf5nAZkCTQEzTZn85gEzTZkBGQE0TZoCTfwABAD8TQNmAAYAAP+ABAADgQAuADsASABMAFAAVAAACQEnJicuAgcGBwYHBgcGByc+ATQuASIOARUUFhcNAQ4BFB4BMj4BNTQmJzcXMwEiLgE0PgEyHgEUDgETFA4BIi4BND4BMh4BJTMVIzczFSM3MxUjAhwBlwIDBAUSGhEUFxkeISV1iLIrMzFVY1QyQTQBB/7jKzQyVGNVMUA02cas/XIdMR0dMToxHBwxTRwxOjEdHTE6MRwBkU1NgE1NgE1NAagBGAMFAwYHAwMDCAoQEhtTYFYYVWRVMTFVMTpdFH3JGFZkVTExVTE6XBWVXQFEHTE6MRwcMToxHf3ZHTEcHDE6MR0dMXlNTU1NTQAAAAIAAP9/A4ADgAAFAAkAABMJARcJASEzESOAAcr+NjYCAP4AAn1NTQNK/jb+NjYCAAIA/AAAAAAAAgAA/4ADgAOAAAUACQAAAScJATcJATMRIwOANv4AAgA2/jb+yk1NA0o2/gD+ADYBygIA/AAAAAADAAD/gAQDA4AABAAJABMAADUVMwEnASM1ARclJyYiDwEXNzY0zwJ20/5AZgImZwEZiBEuEWfSbRFQ0AJz0/0HZwImZ/SIERFp02QRLwAAAAMAAP/pBAADGgAHAA4AEgAAATUhJyERIRMlIRchFSEDKQETIQOa/kZa/noDinb8TQEZWgGN/W1tAwP9SlkCrQHQ42f80AHm/WeW/mYBTQAABgAA/38D/wN/AAsAFAAdACkARABZAAATFAcGKwEVMxUzESMXIgYUFjI2NCYnIgYUFjI2NCY3FAcGKwEVMxUzESMJATY3NjU0JyYnJiIHBgcGFBcWFxYzMjc2NwkBIicmJyY0NzY3NjIXFhcWFAcGBwblCwoWCi09NbQMExQaExMPCxQUGRQTmwsKFgotPTUBvP7WLBgZODZcYN5fXTY4ODZdX29JREI2ASr90VpNTCwtLSxMTbROSywtLSxLTgJqFQwJMLYBGtgTHBMTHBONEhwTExsTQRUMCTC2ARr9QwEqNkJESW9fXTY4ODZdX99fXDc3GBkt/tUBGS4sS060TUstLS0tS020TkssLgAAAAAGAAD/gAQAA4AAAwAHAA0AEwAaACEAABkBIREDIREhBTM1IxUzITM1IxUzEzUjFSMVMyE1IzUjFTMEAE38mgNm/Ueg7U0CDE3toE1NoKD+lKBNTQOA/AAEAPxNA2atTe3tTf2n7aBNTaDtAAABAAD/gAMcA4AABQAAAScJATcBAxs2/gACADb+NwNKNv4A/gA2AcoABAAA/4AEAAOAAAMABwAOABUAABkBIREDIREhATM1IzUHFyE3JxUjFTMEAE38mgNm/WemppqaAcyamqamA4D8AAQA/E0DZv4nTFqAgICAWkwAAAAAAwAA/4AEAAOAAAsAJgBCAAABIxUjFTMVMzUzNSMBNjc2NTQnJicmIgcGBwYUFxYXFjMyNzY3ATclNSMVLgInMzUjPgI3FTM1HgIXIxUzDgIBwE1DQ01DQwEVLRgZODZdX99fXTY4ODZdX29JREE2ASk6/cBNS39RCX5+CVF/S01Lf1EJfn4JUX8CUENNQ0NN/tQ2QkRKb19dNjg4Nl1f319dNjgZFy3+1jrifn4JUX9LTUt/UQl+fglRf0tNS39RAAAAAAEAAP9/AxwDgAAFAAABBwkBFwEBGzYByf43NgIAA4A2/jb+NjYCAAACAAD/fwQAA4AAEQAVAAAlIREhETMRIRUzETMxIRUzNTMBMxUjBAD85gI0TPyamToCR0ya/JlNTWYCNP4AAk1N/YCamgNmZgAEAAD/gAQAA4AAAwAHAA4AFQAAGQEhEQMhESEBMzUzJwczEyM1IxUjFwQATfyaA2b+J0xagIBaplpMWoADgPwABAD8TQNm/o2mmpr+NKammgAAAAAGAAD/gAQAA4AAAwAHAA4AFQAcACMAABkBIREDIREhATM1MycHMxMjFSMXNyMTFTMVNycVBTM1IzUHFwQATfyaA2b+J0xagIBaTExagIBaOoaamv40hoaamgOA/AAEAPxNA2b+rYaamv66hpqaAQxMWoCAWkxMWoCAAAAABgAA/4AEAAOBAAQACgAUACEALgA6AAAlIScHJwEjESE1ISUhESE3IREhEQcDIg4BFB4BMj4BNC4BAyIuATQ+ATIeARQOARMHJwcXBxc3FzcnNwE6AeB9d3D+l00DM/0aAxb9gwEaIP56AxZNST9qPj5qfWo+Pmo+MlUyMlVkVDIyVCBSUyFTUyFTUiFTU7PXoHQBVfzNTZkCgE385wGGIAIAPmp9aj4+an1qPv5hMlVkVDIyVGRVMgEsU1MhUlMhU1MhU1IAAAAFAAD/gAQAA4EADwAUACEALgA6AAAFIREhNyEiFREUMyEyNREHBQchAwcBIg4BFB4BMj4BNC4BAyIuATQ+ATIeARQOARMHJwcXBxc3FzcnNwNN/QABsCD95AEBA5cBTP3ZjAJmtqsBez9qPj5qfWo+Pmo+MlUyMlVkVDIyVCBSUyFTUyFTUiFTUzMDAE0B/GgBAQIcHVbdASPbAus+an1qPj5qfWo+/mEyVWRUMjJUZFUyASxTUyFSUyFTUyFTUgAGAAD/swQAA00AEwAXABsAKQAqADcAAAEjESERIyIOARURMxUhNTMRNC4BJSEVIQEhESEXIzUhFSMRNDYzITIWFQcjFB4BMj4BNC4BIg4BA2Yz/ZozKkcpzQJmzSlH/YoBzP40Acz+NAHMzYD9moAeFQMAFR6AMw4XHBgNDRgcFw4CTQEA/wApRyr+zc3NATMqRymzs/2zAQAzgIABABUeHhUwDhgNDRgcFw4OFwAAAAMAAP+ABAADgQAYAC0AOQAAASIHDgEHBhQXHgEXFjI3PgE3NjQnLgEnJgMiJyYnJjQ3Njc2MhcWFxYUBwYHBhMnBycHFwcXNxc3JwIAaF9cjicoKCeOXF/QX1yOJygoJ45cX2h2ZWM6Ozs6Y2XsZWM6Ozs6Y2WCNsLDN8TCNsLDN8QDgCgnjlxf0F9cjicoKCeOXF/QX1yOJyj8TTs6Y2XsZWM6Ozs6Y2XsZWM6OwJ2N8TCNsLDN8TCNsIAAf/9/4AEAQOBAEYAAAEiBg8BBi4BJyY3NjcTNi4BBgcDDgEmNRE0JiIGFREUBiYnAy4BDgEXExYGJi8BLgEjIg4BHwEWFRQeATsBMjY3AT4BNzYmA9QhPBhfDygfBAUEAgNwBhkwKwd0AxAOIzIjDhACZAcsLxkGZwMMEAWIBxgOExwHCl88R3lIPDpqKQE/BQgBARoBbxkXbhABGxYkIRALAaEYLA0ZGP5nCAUJCQHEGSMjGf5JCQkFCQF3GBkOKRn+fwkMAQjsDA4ZJBGmZndIeUgsKQFPBBEJEhsAAAACAAD/gAQAA4EABQAyAAABESE1IzUTIgcGByYxESEnNjc+ATIeAhQOAiImJyYnBxYXFhcWMjc+ATc2NCcuAScmAbABM+YDhXRwRlEBM6McJzycqpx4QUF4nKubPBUTShgdR1xf0F9cjiYpKCeOXF8CM/7NTeYBTUA/bFH+zaQvJzxBQHmcqpx4QUA9FBotIhxHJygoJ45cX9BfXI4nKAAABwAA/38EAQOAAAQACAANAA4AFwAhACsAABMRIREhFyERISUnByEvASMUFjI2NCYiBgEhNQcXNSEVNycBMycHMxEjFzcjAQL//QFRAlz9pAEIXWwB3YuUPyU0JSU0JQGQ/cBgYAJAYGABJzlgYDo6YGA5Ai79UgMAUv2kqHKq51oaJSU0JSUBqTpgYDo6YGD+oGBg/cBgYAADAAD/gAQBA4AAFQAZAB0AAAE1NCcmJyYjIgc1DQE1NjMyFhcWHQEBIREhFyERIQQAMC9RUmANDf7xAQ8NDVCKKCr8NgMm/NpNAo39cwEOdGRXVDEzAYyrqosBVEZIVHP+cgJtTf4tAAMAAP+ABAADgAAFABAAGwAAAQUhESEFASEVIzUHFzUzFSEFJTUzFTcnFSM1JQQA/e3+EwHtAhP8TQF5k3Nzk/6HA2b+YJp5eZoBoAOAzf2azQLmwE1zc03Aq6HKTXNzTcqhAAADAAD/gAQAA4AABQAQABsAAAUDESERAzcTMxUjFzcjNTMTAxEjNTMnBzMVIxEEAM39ms1vocpNc3NNyqGrwE1zc03AgAITAe3+E/3tTQGgmnl5mv5gA2b+h5Nzc5MBeQAOAAD/fwQAA4AAAwAHAAsADwATABkAHQAhACgAMgA2AD4ASQBPAAABESERJSERIQEHFzcTNxcHAzMVKwEzNSMXNwU3JwcFNxcHBSYnMQcXNxcjNycHFyMVMzUlMxUjEzUnIxUzFzcDKwEnBx8CMzUjATEnBxc3A7P+FwI2/X0Cg/y2RTVGJ0Y2RlyAgHdAtlpDAgVGNkX+UkY1RgKIEBhGNUZUHxk1RiwngP6AgIApHYBPFUXSAQMbRh4FEU4dAW0vRTVGAzP8mgNmTfwAApEgdSD++iB0IALLTU3DIIogdCDvIHQgOSI1IHQgrgt1IGBNQwpNAy0BP00uIP07OyBCASVNAW5mIHQgAAAABQAA/38DyAOAAAkADQARABUAHQAAFyEVNTQDEyETAwUhNSELASEDARchNyMzAyEDMxMhSAOAlmz8xGyGAzP9FwLpP03+Ik0BjUX+1EWYRFoCAWBHfP1DfAS9AgGMAbX+S/54clwDB/7KATb+fsPD/vEBD/7IAAAABQAA/38EAQOAAA0AFgAxADwARQAAJSMmJyYvAQEjARUhNSEDFhceARcjFyEBMyc0NzY3NjIXFhUXMzU0JyYjIgcGBzUjFgclMjc2NTQmIgYUFjcyFhQGIiY0NgLgVAM4N14DAQpm/aMEAP5czB0ZOT4CVG/+DgJMRwEEBgkLHgoSAUcXEiEdGRQLRwEBAQIeFRcoQCopIA0MDhYODUt5a2hFAgGi/E1NTQHRFho7llJ+AVSQBQoLBwoHChyOoEAcFg4MESsNhLcTFSciKytHKm4UGhISGxMAAwAA/4AEAAOBAAsAJgA7AAABIxUjFTMVMzUzNSMJATY3NjU0JyYnJiIHBgcGFBcWFxYzMjc2NwkBIicmJyY0NzY3NjIXFhcWFAcGBwYBvk2kpE2oqAJC/tUtGBk4Nl1f319dNjg4Nl1fcElEQjYBK/3QW01LLS0tLUtNtU1MLC0tLExNArOmTaamTf2pASs2QkRJcF9dNjg4Nl1f319dNjgZGC3+1QEaLSxMTbVNSy0tLS1LTbVNTCwtAAAIAAD/5gQAAxoABQAJAA0AEwAXAB0AIwAnAAAlIxUhNSMRMxUjASEVISUVMxUzNQEhFSElIxUhNSMDMzUzNSERMxUjA62tAQBTU1P90wEA/wABgK1T/YABAP8A/tNTAQCtU1Ot/wBTUzpUzQEamgHnVFRUec39IFTNzVQCE3lU/rOaAAADAAD/gAQAA4EAAwAeADMAABMhFSEJATY3NjU0JyYnJiIHBgcGFBcWFxYzMjc2NwkBIicmJyY0NzY3NjIXFhcWFAcGBwbNAZn+ZwMz/tUtGBk4Nl1f319dNjg4Nl1fcElEQjYBK/3QW01LLS0tLUtNtU1MLC0tLExNAg1N/fYBKzZCRElwX102ODg2XV/fX102OBkYLf7VARotLExNtU1LLS0tLUtNtU1MLC0AAgAA/7MEAANNAAYADgAAJTMRMycHMwERIREjESERAc1NyfDwygHm/JpNBACDAdfz8/7G/uABIP6TAW0AA////4AEAAOAABYAGgAeAAABFS0BFSYjIgcGBwYdATM1NDc2NzYzMgcRIREDIREhAXwBD/7xDgxgUlEvMDYqKERGUA2VAyZN/XMCjQK2i6qrjAEzMVRXZHJwVElGKSvK/ZMCbf3gAdMAAAAAAAASAN4AAQAAAAAAAAATAAAAAQAAAAAAAQAIABMAAQAAAAAAAgAHABsAAQAAAAAAAwAIACIAAQAAAAAABAAIACoAAQAAAAAABQALADIAAQAAAAAABgAIAD0AAQAAAAAACgArAEUAAQAAAAAACwATAHAAAwABBAkAAAAmAIMAAwABBAkAAQAQAKkAAwABBAkAAgAOALkAAwABBAkAAwAQAMcAAwABBAkABAAQANcAAwABBAkABQAWAOcAAwABBAkABgAQAP0AAwABBAkACgBWAQ0AAwABBAkACwAmAWNDcmVhdGVkIGJ5IGljb25mb250aWNvbmZvbnRSZWd1bGFyaWNvbmZvbnRpY29uZm9udFZlcnNpb24gMS4waWNvbmZvbnRHZW5lcmF0ZWQgYnkgc3ZnMnR0ZiBmcm9tIEZvbnRlbGxvIHByb2plY3QuaHR0cDovL2ZvbnRlbGxvLmNvbQBDAHIAZQBhAHQAZQBkACAAYgB5ACAAaQBjAG8AbgBmAG8AbgB0AGkAYwBvAG4AZgBvAG4AdABSAGUAZwB1AGwAYQByAGkAYwBvAG4AZgBvAG4AdABpAGMAbwBuAGYAbwBuAHQAVgBlAHIAcwBpAG8AbgAgADEALgAwAGkAYwBvAG4AZgBvAG4AdABHAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAHMAdgBnADIAdAB0AGYAIABmAHIAbwBtACAARgBvAG4AdABlAGwAbABvACAAcAByAG8AagBlAGMAdAAuAGgAdAB0AHAAOgAvAC8AZgBvAG4AdABlAGwAbABvAC4AYwBvAG0AAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALgECAQMBBAEFAQYBBwEIAQkBCgELAQwBDQEOAQ8BEAERARIBEwEUARUBFgEXARgBGQEaARsBHAEdAR4BHwEgASEBIgEjASQBJQEmAScBKAEpASoBKwEsAS0BLgEvAAhzZWxlY3RlZAp1bnNlbGVjdGVkFGEtYWRkaW1hZ2Vmcm9tY2FtZXJhCWltYWdlbGlzdAx1bmZ1bGxzY3JlZW4KZnVsbHNjcmVlbgtvcGVuc2Nhbm5lcgdiYXJjb2RlA29jcgZ3ZWJjYW0Fc2F2ZTEMbXVsdGktc2VsZWN0B3RodW1iXzIDY3V0D2Fycm93X3JpZ2h0X3RvcA5hcnJvd19sZWZ0X3RvcARlZGl0CWxvYWRsb2NhbAlpY29uLXRlc3QKZmlsbHNjcmVlbgphcnJvd19sZWZ0DGFsaWduaGNlbnRlcg1jbGlja3Rvem9vbmluC2Fycm93X3JpZ2h0BGNyb3AMYWxpZ252Y2VudGVyBmNlbnRlcg5kZWxldGVhbGxpbWFncwpkZWxldGVpbWFnBXByaW50BGV4aXQEaGFuZAVyZXNldBFjaGFuZ2VfaW1hZ2Vfc2l6ZQtyb3RhdGVfbGVmdARmbGlwBm1pcnJvcgZkZXNrZXcHc2Nhbm5lcgZyb3RhdGUHem9vbW91dAZzZWxlY3QGem9vbWluBnVwbG9hZAxyb3RhdGVfcmlnaHQAAAAA') format('truetype'); -} - -@font-face { -font-family: "ds-dwt-ui-mobile-iconfont"; -src: url('data:font/ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwR1NVQiCLJXoAAAE4AAAAVE9TLzI8Z0mMAAABjAAAAGBjbWFwtV65gAAAAlQAAALQZ2x5ZqbV24YAAAVcAAAVQGhlYWQhKTCdAAAA4AAAADZoaGVhCssGiAAAALwAAAAkaG10eG/N//sAAAHsAAAAaGxvY2FRSEysAAAFJAAAADZtYXhwATEA2QAAARgAAAAgbmFtZRCjPLAAABqcAAACZ3Bvc3TgsNTcAAAdBAAAAW4AAQAAA4D/gABcBu7/////Bu0AAQAAAAAAAAAAAAAAAAAAABoAAQAAAAEAACzWudZfDzz1AAsEAAAAAADdjvZQAAAAAN2O9lD///9+Bu0DggAAAAgAAgAAAAAAAAABAAAAGgDNAA0AAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKADAAPgACREZMVAAObGF0bgAaAAQAAAAAAAAAAQAAAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAQETQGQAAUAAAKJAswAAACPAokCzAAAAesAMgEIAAACAAUDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBmRWQAwOZQ5m8DgP+AAAAD3ACCAAAAAQAAAAAAAAAAAAAAAAACBAAAAAQAAAAEAAAABUcAAAUQAAAG7gAABD0AAAQA//8EAP//BkL//wQF//8EAAAABAAAAAQAAAAEAAAABAAAAAQA//8EAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAFAAAAAwAAACwAAAAEAAABlAABAAAAAACOAAMAAQAAACwAAwAKAAABlAAEAGIAAAAIAAgAAgAA5lrmauZv//8AAOZQ5l/mbv//AAAAAAAAAAEACAAcADIAAAAZABgAFQAWABcAEgATABQADwAQABEADgANAAwACQALAAoABwAIAAQABQAGAAEAAwACAAABBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAE8AAAAAAAAABkAAOZQAADmUAAAABkAAOZRAADmUQAAABgAAOZSAADmUgAAABUAAOZTAADmUwAAABYAAOZUAADmVAAAABcAAOZVAADmVQAAABIAAOZWAADmVgAAABMAAOZXAADmVwAAABQAAOZYAADmWAAAAA8AAOZZAADmWQAAABAAAOZaAADmWgAAABEAAOZfAADmXwAAAA4AAOZgAADmYAAAAA0AAOZhAADmYQAAAAwAAOZiAADmYgAAAAkAAOZjAADmYwAAAAsAAOZkAADmZAAAAAoAAOZlAADmZQAAAAcAAOZmAADmZgAAAAgAAOZnAADmZwAAAAQAAOZoAADmaAAAAAUAAOZpAADmaQAAAAYAAOZqAADmagAAAAEAAOZuAADmbgAAAAMAAOZvAADmbwAAAAIAAAAAACAARgDyAbwCegOYBAoEtgW4BpYGzAb8BxQHeAeuB+QIHghUCHIJMAliCbYJ2go0CqAAAAACAAD/gAQAA4AABAANAAATIxEhEQEGIi8BNxcBFwEBBAD91gcWB7xIhgEFSwOA/AAEAP1BCAi8S4YBCEoAAAAAAQAA/38DDwN+ABIAAAUiJyY0NwkBJjQ2MhcBFhQHAQYBEREGCAgBzf4zCBEXCAHkCAj+HAaABggXCQHSAc0IFxEI/hwIFwn+HQYAAAQAAP9/BUYDgQBHAFwAZQB0AAAFISIuBDURND4EOwEWNz4BNzY/ATY3Njc+ATchMhcWFxYfARYfARYXHgEXMjsBMh4CFxUWFxYVERQOAQcGBwYrAQEiBwYHBhQXFhceATc2NzY0JyYnJiUiBhQWPgImASIuATQ+Ah4BFRYOAgTD+7IPIBwWDwUFDxYcHxChDxASIA0MBgkCBBAiECQRASsSEiQaDQkGAgUCBgwNIBIKCq8QHxwXBwYCAwYOCxcgEBAO/eFSSEUoKikoRUelSEUpKikpRUcBMxEYGCIYARj+aUNxQ0JxhXJCASVFW4AFDxYdIBACWxAfHRcOBQEBBBEMFRcYCAcjEggGAQMGGw0QDwYOBxYTDREEBQ4XDgQKDBIS/aUQHx0LFwYCAvApKEVHpkdFKSoBKihER6ZHRikqBBgjGAEXIhn91kJxhnFCAUJxQzFaRiYABAAA/4AFAQOBACQASABuAJIAACUOAisBLgEnFRQGIiY9ATQ2OwEyFhQGKwEeAz4BNz4BHgE3FAYrASImNDY7AS4DDgEHDgEuATc+AjIeARc1NDYyFhU3IyIvASYnJicmIyEiBwYHBg8BBisBIgcGFREUFjMhMjY1ETQnJhMUIyEiNRE0NzY7ATI2PwE2Nz4BMyEyFhcWHwEeATsBMhcWFQOPFE9rOx9QfRoMEg0NCaEJDQ0JbAs+W2lgSBEDEBEHGg0JoQkNDQlsCz5baWBIEQQPDwgBFE5rdmpPEwwSDdW9EQkbIA4XExYa/vQaFxMXDyAbCRC8SCAYREAD+EBEGCEOWfwIWQ4UM74SIAoZHwwSGw8BDBAaEg4eGAogE70zFA7POFUwCmZMYQkMDAmiCQwMEgw0UzIHJ0oyCAgGEJQJDAwSDDRTMgcmSzIHBgUOCDdWLy9WN2IJDAwJ0A0lLRAbDA0ODBsRLiINJh0x/ZQ9QEA9AmwxHSb9IFJSAmwhEBYRDiMrDxcSEhcQKiEPEBYQIgAHAAD/fwbtA4EAFwAnAD4AUwBfAG8AfwAAASEiDgIVERQeAjMhMj4CNRE0LgITFgYjISImNRE0NjMhMhYVBS4BBwUOARURFBYXBRYzMjc+ATURNCYDFA4CJyUuATURNDY3JTYzMh4BFQEjNSMRMxEzETMRIwUmByMRMxY3Njc2JzU2JyYDFAcGBwYnIxEzNhcWFxYHBDP8MRQlHA8PHCUUA9EUJBwPDx0lHgEeFfwxFR4eFQPRFR4CVxY1F/7VGh0eGQErFRcdFxYZGBUMFxoM/tINDw8NASwLDQ4XDfs4rjQ0rjQ0AWgrMHd8LygiDA8BAQ8NHAYDFR0jR0MiHRYGCAEDgA8cJRT8yBQlHA8PHCUUAzgUJhwO/GQWHx0VAzsVHh4VJA4CDJYNMRz+6BwwDZcLDw4tGgJGGi39cw4XDgIGmAYaDgEYDhoGlwUPFg7+/vT91wEN/vMCKRQYAv3VAhgVJiwu3CwqJf6yJSQdFBUDAdkDEhAaIyMAAAcAAP9+BD0DgQAXADYAbgCmALMAvwDMAAAFISImNRE0NjsBPgEXMzYWFzMyFhURFAYBIgYHERQWMyE+ATcRLgEnIwYvAS4BKwEiBwYPAQYjBSImNDYzPgE3ES4BJyMiLwEmJyYrASIHBg8BBisBDgEHFAYiJjU0NjsBPgEXMzYWFzMyFhURFAY3IiY0NjMyNjURNCYnIyIvASYnJisBIgcGDwEGKwEmBhcOASImJzQ2OwE+ATsBMhYXMzIWFREUBgEiLgE+Ah4BFRQOASciDgEeAj4BNTQmJSImPQE0NjIWHQEUBgKQ/b8hLi4h2ggrHIMbLAdKIS4w/Z0QFwEXEQJBDxYBARYPVgwHAwwPEIMQCAcMAwYNAgkJDAwJDxUBARUPVw0FAw0GCRCCEAkGDQMFDecQFQEMEQwuIdoILBuDGywISiEuMYwIDAwIDxYVEFcMBgMMBwgQgxAIBw0CBg3nERcBAgsOCwIvINsHLBuDHCsISiEuMf2dKUUgEDtRTC4lPiUdMBYLKTg2IDf+twgMDBEMDIAuIQFaIS4aIAEBIBouIf6mIi4B0BYQ/qYRFwEWDwFcDxYBAQoHGA8IBxgHC+YMEQwBFQ8BWw8WAQsGGQYJCQYZBQwBFQ8JDAwJIC4aIQEBIRouIP6lIi7pDBEMFg8BWhAXAQsGGQcICQYZBgsBGBEGCAgGIS4aICAaLiH+piIu/qcuTFE7ECBFKSU/JOcgNTkpCxYwHSc4dAwIVwgNDAlXCAwAAAAAA////38EAQOBABsANABJAAAlFhQGIi8BBwYiJjQ/AScmNDYyHwE3NjIWFA8BAyIHDgEHBhQXHgEXFjI3PgE3NjQnLgEnJgMiJyYnJjQ3Njc2MhcWFxYVFA4CAs8GDRIHr68HEg0Gr68HDhIHr68HEg4HryBoX1yOJygoJ45cX9BfXI4nKCgnjlxfaH9uaj5AQD5qbv5uaj5AR4St0QcSDQavrwYNEgevrwcSDgevrwcOEgevAgAoJ45cX9BfXI4nKCgnjlxf0F9cjico/CtAPmpu/m5qPkBAPmpuf12thEcAAAAABv///38EAAOBADMAQgBPAFwAaQB2AAAlISImNRE0NjsBMhYfAR4BMyEyFh0BFAYiJj0BNCYjISImLwEuASsBDgEHER4BMyEyFhQGASIuATQ+ATIeARUUDgIDIg4BFB4CPgIuAQMiJjURNDYyFhURFAYnLgE0PwE2MhYUDwEGFyIvASY0NjIfARYUBgFq/tQaJCQa5xEeCCcDDAcBqBokCxALDgr+WRIeCCcDDQbnCQ0BAQ4JASsICwsBekt+Skp+ln9KKk5lN0BsQD9sgG1AAUBsQQgLCxALC2kHDAZhBRALBmAGuQcGYAYLEAVhBQuBJBoCgxokEhBRBwckGqsICwsIqwoOExBRBgYBDQn9fQoOCxAL/v9Kf5Z+Skp+SzdlTioCAj9sgG1AAT9sgG1B/n8LCAEBCAsLCP7/CAugAQsPBmAGCxAGYAUBBmAGEAsGYAYPCwAAAAAM////fwZDA4AAOwBIAFcAYABqAH0AkgClAKYAqQCqAKwAAAUhIi4BNRE0PgE3MzY/ATY3MxYfARYXMzIWFxYOASYnLgErASYvASYnIwYPAQYHIw4BFREGFjchHgEUBiUiLgE+Ah4BFRQOAQMiDgEUHgI+ATU0LgIFIiY0NjIWFAYnIgYVFDI1NiYjASIuAjQ+Ax4CFQYHBgcGAyIHBgcGFBcWFxYyNzY3NjQnJicmAyIuATc1Jj4BMh8BHgEUBg8BBic3FTcXJzUDVf0hIDYgHjUhrRgTWh4olCcfXRMYqhgsEAUBDhMGCR0PqycfXRIYjxgTWx4mqyEsAS0fAt8HCQn+2Up8Oh1qkopTQnFDNlw2Nl1tXDcfOUr+aBAWFiAWFhADAwwCBQMEJEV/YTU0Yn+JgGA1AS8tTlFdUUZDKCkpKENGokZDKCgoKENGowsUCQEBChMXCskKDAwKzAkNCLUQxSsgNiACNSE4JAMBD1UZAgIZVQ8BFRMHEgwCBwwNAhlWDgEBD1YYAgMxIf3LHy0BAgwPDL5SipNpHTl8SkNxQgHANl1tXDYBNlw3KEs5H2IXHxcXHxcrBAMFBQQF/V81YICJfmI0ATZhfkVeUE4uLwKFKSdERaNFRCcpKSdERaNFRCcp/jsMFQvBCxMMB2QEEhYRBGYGK7m0WghuAgAAAAAG////fwQCA4IAFAAoADwAUQB9AKkAABMWNj0BNDY7ATI+ASYrASIGHQEUFgEjIgYUFjsBMhYdARQWMjY9ATQmASMiJj0BNCYiBh0BFBY7ATI2NCYBJgYdARQGKwEiBhQWOwEyNic1NCYnMzI2NCYrAS4CJzU0JiIGHQEOAgcjIgYUFjsBHgIXFRQWMjY9AT4CJTMyNjQmKwE+AjcVFBYyNj0BHgIXIyIGFBY7AQ4CBzU0JiIGHQEuAhYJDRkS8AgMAQwJ9CEwDAOf9AkMDAn0ERkNEQ0z/Xj0ERkMEQwxIvQJDAwCmgkMGBLyCQwMCfQiMQIM01AJDQ0JUAVJdkcMEgxGd0gFTwkNDQlQBUl2RwwSDEZ2SP3wTwkMDAlPBT5jPAwSDDtkPgRQCQwMCU8FPmM8DBIMO2M9AiUBDAn1EhkKEQwwIvUIDAFbDBEMGRH0CA0NCPUjMPwtGRHyCA0NCPUiMA0RDQEwAQ0I9RIYDRIMMiP1CA2ODRENRnZJBU8JDAwJUQVJdkYMEgxHdkkFUAkNDQlQBkl3Rg0RDTtjPgVQCQwMCU4EPmQ7DBIMPGM+BVEIDQ0ITwU+YwABAAD/gAMcA4IAGwAABSImJwEiJicuATY3ATYWFxYGBwEGFwEeAQcOAQLhCRYI/loEBgIZDhccAaYRLREQBRH+WggIAawQAg0NFIAJCAGKCQIcRkUZAYoRAhUQLRL+dhcQ/nYRLREJCAAAAAADAAD/gAQAA4AABQAQABsAAAERIREDIQEhESM1MycHMxUjBzMVIxc3IzUzEyEDM/2azQQA/RoBzMBNc3NNwArKTXNzTcqh/N4BlAHs/hT97AOz/oeTc3OTTZp5eZr+YAABAAAAAAQAAvYACAAACQEHASEVIQEXBAD+izYBGPyTA23+6DYBgAF1Nv7nTP7nNgAJAAD/gAQAA4AAFAAYABwAKAAsADAANQA2AEIAAAEjFSE1IxUzESMVMzUhFTM1IxEzNQU1MxURIzUzJRUhNSMRMzUhFTMRFxUjNRMjNTMBJwchLwEjFB4BMj4BNTQmIgYDs6D92u1QUO0CJu1QUPxNU1NTAnP92lBQAiZQUFNTU1P+LF1sAd2LlD8RHSIdESU0JQOAUFDt/drtUFDtAibtoFNT/O1TTVBQAiZQUP3aTVNTAsBT/dVyqudaER0RER0RGiUlAAAAAAMAAP+ABAEDgAAWABoAHgAAATU0JyYnJiMiBzUNATU3NjMyFhcWHQEBIREhFyERIQQAMC9RUmANDf7xAQ8BEAlQiigq/DYDJvzaTQKN/XMBDnRkV1QxMwGMq6qKAQFURkhUc/5yAm1N/i0AAAP///+ABAADgAAWABoAHgAAARUtARUmIyIHBgcGHQEzNTQ3Njc2MzIHESERAyERIQF8AQ/+8Q0NYFJRLzA2KihERlAOlgMmTf1zAo0CtYqqq4wBMzFUV2RycFRJRikryv2TAm394AHTAAAAAAUAAP+ABAADgAAEAAwAEAAUACEAAAEhESERJTMVMzUzFSMBITUhNSE1IRMjESERIxEzESERMxcDGfznBAD9g1xsMvoBff4AAgD+AAIAs2b9ZmbqAZMvugOA/AADFp1mZrr9VNZNQ/6aAbP+TQNm/voBBr0ABAAA/38EAAOAAAgAEAAWABoAAAEXARcBBiIvAQE1IREzFSERASMRIRUhASERIQGigwEASv7IBxUItwHX/M3NAzP8zYACmf3nAub9ZwKZAV6CAQJI/sYICLkBns38zc0DM/3nApmA/RoCmQAAAwAA/4AEAAOAAAMABwALAAABMxEjAREhEQMhESEDnwEB/GEEAGD8vwNBAyD8wAOg/AAEAPxgA0AAAAAADQAA/38EAAOAAAgAEQAaACMALwBEAEoAUwBgAGQAaAB1AIIAADciJjQ2MhYUBjMiJjQ2MhYUBgMyFhQGIiY0NiMyFhQGIiY0NgEvAQc5ARc3FTM1Fzc1IREhBgchESEeATMyNzY3NjU0JgE1IRUUFwE1IRUmIyIGBxMiLgE0PgEyHgEUDgETIREhJyE1IQEiBhUxFBYyNjUxNCYzIgYVMRQWMjY1MTQmnQ8VFR4VFWgPFRUeFRUPDxUVHhUVaA8VFR4VFQLnXzaVNjhNOYH8QAHUBQX+NgIqJl0zTkNBJigi/GoBeCv+XQMwRVNDdyjiO2Q7O2R2ZDo6ZKX8QAPASPzQAzD9JQ8VFR4VFWgPFRUeFRU0FR0VFR0VFR0VFR0VAtoUHhUVHhQUHhUVHhT9pF82lTY4uro42eH+1A0Q/tQfIicmQUROMl3+2pwFUkUBSZxaLDsz/nU6ZHZkOztkdmQ6A7n+1Eic/owVDw8VFQ8PFRUPDxUVDw8VAAADAAD/gAQAA4AABQAQABsAAAEhESEFEQEjNQcXNTMVIREhASU1MxU3JxUjNSUB7P4UAewCFP3Gk3Nzk/6HAXkB7f5gmnl5mgGgArP9ms0EAP4mTXNzTcABzP2JocpNc3NNyqEACQAA/4AD/wOAAAMABwALAA8AEwAXACkALgAyAAABMxEjAzMRIwMzESMRMxEjEzMRIxMzESMTNSM1IRUjFSMVMxEhFTMRMzUlNSEVIQEhESECnU1Nw01NwE1NTU3ATU3DTU1iFv4pE/9zAsxNc/1NAWb+mgHz/YECfwJB/cACQP3AAkD9wAJA/cACQP3AAkD9wALZpQEBpVn9AAEDAVkmJ0389AKzAAAAAgAA/38EAAOAABEAFQAANxEhETMRIRUzETMxIRUzNTM1ATMVI+YCNEz8mpk6AkdMmvyZTU1mAjT+AAJNTf2AmppMAxpmAAAABQAA/4AEAAOBAA8AFAAhAC4AOgAABSERITchIhURFDMhMjURBwUHIQMHASIOARQeATI+ATQuAQMiLgE0PgEyHgEUDgE3IzUjFSMVMxUzNTMDTf0AAbAg/eQBAQOXAUz92YwCZreqAXo+aj4+an1qPj5qPzJUMjJUZFUyMlVadS50dC51MwMATQH8aQEBAhsdVt0BI9sC6z5qfWo+Pmp9aj7+YTJVZFQyMlRkVTLQdHQudXUABwAA/4AEAAOAAAwAGQAaACcANQA5AEUAAAEiDgEUHgEyPgE0LgEDIi4BND4BMh4BFA4BASMUHgEyPgE0LgEiDgE3JyEHIxEhNSERIRUzESE3IRcTIxUjFTMVMzUzNSMB4DhgODhgcGA4OGA4IzoiIjtEOyIiOgEUMw4YGxgODhgbGA43XP6CXeQCAP5NA2ZN/TY0ASs0nUyamkyamgIROF9xYDg4YHFfOP6xIjpFOyIiO0U6IgEsDhgNDRgbGA4OGMHExP0ETAJjzwEcd3f+RJlNmppNAAAAAAASAN4AAQAAAAAAAAATAAAAAQAAAAAAAQAIABMAAQAAAAAAAgAHABsAAQAAAAAAAwAIACIAAQAAAAAABAAIACoAAQAAAAAABQALADIAAQAAAAAABgAIAD0AAQAAAAAACgArAEUAAQAAAAAACwATAHAAAwABBAkAAAAmAIMAAwABBAkAAQAQAKkAAwABBAkAAgAOALkAAwABBAkAAwAQAMcAAwABBAkABAAQANcAAwABBAkABQAWAOcAAwABBAkABgAQAP0AAwABBAkACgBWAQ0AAwABBAkACwAmAWNDcmVhdGVkIGJ5IGljb25mb250aWNvbmZvbnRSZWd1bGFyaWNvbmZvbnRpY29uZm9udFZlcnNpb24gMS4waWNvbmZvbnRHZW5lcmF0ZWQgYnkgc3ZnMnR0ZiBmcm9tIEZvbnRlbGxvIHByb2plY3QuaHR0cDovL2ZvbnRlbGxvLmNvbQBDAHIAZQBhAHQAZQBkACAAYgB5ACAAaQBjAG8AbgBmAG8AbgB0AGkAYwBvAG4AZgBvAG4AdABSAGUAZwB1AGwAYQByAGkAYwBvAG4AZgBvAG4AdABpAGMAbwBuAGYAbwBuAHQAVgBlAHIAcwBpAG8AbgAgADEALgAwAGkAYwBvAG4AZgBvAG4AdABHAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAHMAdgBnADIAdAB0AGYAIABmAHIAbwBtACAARgBvAG4AdABlAGwAbABvACAAcAByAG8AagBlAGMAdAAuAGgAdAB0AHAAOgAvAC8AZgBvAG4AdABlAGwAbABvAC4AYwBvAG0AAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGgECAQMBBAEFAQYBBwEIAQkBCgELAQwBDQEOAQ8BEAERARIBEwEUARUBFgEXARgBGQEaARsADWEtYWxsc2VsZWN0ZWQFYXJyb3cHY2FwdHVyZQxhLXR1cm5jYW1lcmEKcmVzb2x1dGlvbhFhLW11bHRpcGxlY2FwdHVyZQVjbG9zZQ1hLWxvY2FsdXBsb2FkDWEtYXV0b2NhcHR1cmUPYS1hdXRvZGV0ZWN0aW9uBWJhY2sxBm1pcnJvcgRuZXh0EmEtZnVsbGRldGV0ZWRpbWFnZQtyb3RhdGVfbGVmdAxyb3RhdGVfcmlnaHQEc2F2ZQpzZWxlY3RfYWxsCnVuc2VsZWN0ZWQSYS11cGxvYWRmcm9tc2VydmVyBGZsaXAGZGVsZXRlBGNyb3AKYS1hZGRpbWFnZRRhLWFkZGltYWdlZnJvbWNhbWVyYQAAAAA=') format('truetype'); -} - -.ds-dwt-ui-icon-selected, .ds-dwt-ui-icon-unselected, .ds-dwt-ui-icon-addImageFromCamera, -.ds-dwt-ui-icon-preImage, .ds-dwt-ui-icon-preImage-grey, .ds-dwt-ui-icon-nextImage, .ds-dwt-ui-icon-nextImage-grey, -.ds-dwt-ui-icon-acquire, .ds-dwt-ui-icon-load, .ds-dwt-ui-icon-printImage, .ds-dwt-ui-icon-removeall, -.ds-dwt-ui-icon-removeImage, .ds-dwt-ui-icon-rotateLeftImage, .ds-dwt-ui-icon-rotateLeftImage-grey, .ds-dwt-ui-icon-rotate, -.ds-dwt-ui-icon-rotateRightImage, .ds-dwt-ui-icon-rotateRightImage-grey, .ds-dwt-ui-icon-deskew, .ds-dwt-ui-icon-cropImage, -.ds-dwt-ui-icon-cropImage-grey, .ds-dwt-ui-icon-erase, .ds-dwt-ui-icon-erase-grey, .ds-dwt-ui-icon-changeImageSize, -.ds-dwt-ui-icon-flipImage, .ds-dwt-ui-icon-flipImage-grey, .ds-dwt-ui-icon-mirrorImage, .ds-dwt-ui-icon-mirrorImage-grey, -.ds-dwt-ui-icon-zoomin, .ds-dwt-ui-icon-zoomin-grey, .ds-dwt-ui-icon-originalsize, .ds-dwt-ui-icon-zoomout, -.ds-dwt-ui-icon-zoomout-grey, .ds-dwt-ui-icon-stretch, .ds-dwt-ui-icon-fullWebType, .ds-dwt-ui-icon-fitWidthType, -.ds-dwt-ui-icon-fitHeightType, .ds-dwt-ui-icon-hand, .ds-dwt-ui-icon-select, .ds-dwt-ui-icon-clicktozoomin, -.ds-dwt-ui-icon-restore, .icon-restore-grey, .ds-dwt-ui-icon-saveImage, .ds-dwt-ui-icon-saveImage-grey, -.ds-dwt-ui-icon-close, .ds-dwt-ui-icon-imageEditor, .ds-dwt-ui-icon-upload, .d-icon-font, -.ds-dwt-ui-icon-thumbnail, .ds-dwt-ui-icon-selectAll, .ds-dwt-ui-icon-fullScreen, .ds-dwt-ui-icon-unFullScreen { - font-family: "ds-dwt-ui-d-iconfont" !important; - font-size: 20px; - color: #FFF; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -@media screen and (max-device-width: 500px) { -.ds-dwt-ui-icon-selected, .ds-dwt-ui-icon-unselected, .ds-dwt-ui-icon-addImageFromCamera, -.ds-dwt-ui-icon-preImage, .ds-dwt-ui-icon-preImage-grey, .ds-dwt-ui-icon-nextImage, .ds-dwt-ui-icon-nextImage-grey, -.ds-dwt-ui-icon-acquire, .ds-dwt-ui-icon-load, .ds-dwt-ui-icon-printImage, .ds-dwt-ui-icon-removeall, -.ds-dwt-ui-icon-removeImage, .ds-dwt-ui-icon-rotateLeftImage, .ds-dwt-ui-icon-rotateLeftImage-grey, .ds-dwt-ui-icon-rotate, -.ds-dwt-ui-icon-rotateRightImage, .ds-dwt-ui-icon-rotateRightImage-grey, .ds-dwt-ui-icon-deskew, .ds-dwt-ui-icon-cropImage, -.ds-dwt-ui-icon-cropImage-grey, .ds-dwt-ui-icon-erase, .ds-dwt-ui-icon-erase-grey, .ds-dwt-ui-icon-changeImageSize, -.ds-dwt-ui-icon-flipImage, .ds-dwt-ui-icon-flipImage-grey, .ds-dwt-ui-icon-mirrorImage, .ds-dwt-ui-icon-mirrorImage-grey, -.ds-dwt-ui-icon-originalsize, .ds-dwt-ui-icon-stretch, .ds-dwt-ui-icon-fullWebType, .ds-dwt-ui-icon-fitWidthType, -.ds-dwt-ui-icon-fitHeightType, .ds-dwt-ui-icon-hand, .ds-dwt-ui-icon-select, .ds-dwt-ui-icon-clicktozoomin, -.ds-dwt-ui-icon-restore, .ds-dwt-ui-icon-restore-grey, .ds-dwt-ui-icon-saveImage, .ds-dwt-ui-icon-saveImage-grey, -.ds-dwt-ui-icon-close, .ds-dwt-ui-icon-imageEditor, .ds-dwt-ui-icon-upload, .d-icon-font, -.ds-dwt-ui-icon-thumbnail { - -webkit-flex: 0 0 40px; - flex: 0 0 40px; -} -} - -@media screen and (max-device-width: 500px) { -.DVS_emptyBtn, .ds-dwt-ui-icon-zoomin, .ds-dwt-ui-icon-zoomin-grey, .ds-dwt-ui-icon-zoomout, .ds-dwt-ui-icon-zoomout-grey, .ds-dwt-ui-icon-selectAll, .ds-dwt-ui-icon-fullScreen, .ds-dwt-ui-icon-unFullScreen { - -webkit-flex: 0 0 24px; - flex: 0 0 24px; -} -.dvs-myGroup3{ - width:100%; -} -} - -@media screen and (min-device-width: 500px) { - .ds-dwt-ui-icon-close-right { - margin-left: auto; - } -} - -.ds-dwt-ui-icon-selected:before { - content: "\e64d"; -} -.ds-dwt-ui-icon-unselected:before { - content: "\e64e"; -} -.ds-dwt-ui-icon-addImageFromCamera:before { - content: "\e64c"; -} - -.ds-dwt-ui-icon-selectAll:before { - content: "\e649"; -} - -.ds-dwt-ui-icon-thumbnail:before { - content: "\e641"; -} - -.ds-dwt-ui-icon-imageEditor:before { - content: "\e640"; -} - -.ds-dwt-ui-icon-pageRightTop:before { - content: "\e63e"; -} - -.ds-dwt-ui-icon-pageLeftTop:before { - content: "\e63f"; -} - -.ds-dwt-ui-icon-load:before { - content: "\e63d"; -} - -.ds-dwt-ui-icon-originalsize:before { - content: "\e63c"; -} - -.ds-dwt-ui-icon-stretch:before { - content: "\e63b"; -} - -.ds-dwt-ui-icon-preImage:before { - content: "\e620"; -} - -.ds-dwt-ui-icon-fitWidthType:before { - content: "\e621"; -} - -.ds-dwt-ui-icon-clicktozoomin:before { - content: "\e622"; -} - -.ds-dwt-ui-icon-nextImage:before { - content: "\e623"; -} - -.ds-dwt-ui-icon-cropImage:before { - content: "\e624"; -} - -.ds-dwt-ui-icon-cropImage-grey:before { - content: "\e624"; -} - -.ds-dwt-ui-icon-fitHeightType:before { - content: "\e625"; -} - -.ds-dwt-ui-icon-fullWebType:before { - content: "\e626"; -} - -.ds-dwt-ui-icon-removeall:before { - content: "\e627"; -} - -.ds-dwt-ui-icon-removeImage:before { - content: "\e628"; -} - -.ds-dwt-ui-icon-printImage:before { - content: "\e629"; -} - -.ds-dwt-ui-icon-close:before { - content: "\e62a"; -} - -.ds-dwt-ui-icon-hand:before { - content: "\e62b"; -} - -.ds-dwt-ui-icon-restore:before { - content: "\e62c"; -} - -.ds-dwt-ui-icon-changeImageSize:before { - content: "\e62d"; -} - -.ds-dwt-ui-icon-rotateLeftImage:before { - content: "\e62e"; -} - -.ds-dwt-ui-icon-mirrorImage:before { - content: "\e62f"; -} - -.ds-dwt-ui-icon-flipImage:before { - content: "\e630"; -} - -.ds-dwt-ui-icon-deskew:before { - content: "\e631"; -} - -.ds-dwt-ui-icon-erase:before { - content: "\e642"; -} - -.ds-dwt-ui-icon-erase-grey:before { - content: "\e642"; -} - -.ds-dwt-ui-icon-acquire:before { - content: "\e633"; -} - -.ds-dwt-ui-icon-rotate:before { - content: "\e634"; -} - -.ds-dwt-ui-icon-zoomin:before { - content: "\e635"; -} - -.ds-dwt-ui-icon-select:before { - content: "\e636"; -} - -.ds-dwt-ui-icon-saveImage:before { - content: "\e643"; -} - -.ds-dwt-ui-icon-zoomout:before { - content: "\e638"; -} - -.ds-dwt-ui-icon-upload:before { - content: "\e639"; -} - -.ds-dwt-ui-icon-rotateRightImage:before { - content: "\e63a"; -} - -.ds-dwt-ui-icon-fullScreen:before { - content: "\e648"; -} - -.ds-dwt-ui-icon-unFullScreen:before { - content: "\e64a"; -} - -/* mobile iconfont*/ -.ds-dwt-ui-mobile-icon-a-allselected, .ds-dwt-ui-mobile-icon-arrow, .ds-dwt-ui-mobile-icon-capture, .ds-dwt-ui-mobile-icon-a-turncamera, -.ds-dwt-ui-mobile-icon-resolution, .ds-dwt-ui-mobile-icon-a-multiplecapture, .ds-dwt-ui-mobile-icon-close, -.ds-dwt-ui-mobile-icon-a-localupload, .ds-dwt-ui-mobile-icon-a-autocapture, .ds-dwt-ui-mobile-icon-a-autodetection, -.ds-dwt-ui-mobile-icon-back1, .ds-dwt-ui-mobile-icon-mirror, .ds-dwt-ui-mobile-icon-next, .ds-dwt-ui-mobile-icon-a-fulldetetedimage, -.ds-dwt-ui-mobile-icon-rotate_left, .ds-dwt-ui-mobile-icon-rotate_right, .ds-dwt-ui-mobile-icon-save, .ds-dwt-ui-mobile-icon-select_all, -.ds-dwt-ui-mobile-icon-unselected, .ds-dwt-ui-mobile-icon-a-uploadfromserver, .ds-dwt-ui-mobile-icon-flip, .ds-dwt-ui-mobile-icon-delete, -.ds-dwt-ui-mobile-icon-crop, .ds-dwt-ui-mobile-icon-a-addimage, .ds-dwt-ui-mobile-icon-a-addimagefromcamera -{ - font-family: "ds-dwt-ui-mobile-iconfont" !important; - font-size: 20px; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -@media screen and (max-device-width: 500px) { -.ds-dwt-ui-mobile-icon-a-allselected, .ds-dwt-ui-mobile-icon-arrow, .ds-dwt-ui-mobile-icon-capture, .ds-dwt-ui-mobile-icon-a-turncamera, -.ds-dwt-ui-mobile-icon-resolution, .ds-dwt-ui-mobile-icon-a-multiplecapture, .ds-dwt-ui-mobile-icon-close, -.ds-dwt-ui-mobile-icon-a-localupload, .ds-dwt-ui-mobile-icon-a-autocapture, .ds-dwt-ui-mobile-icon-a-autodetection, -.ds-dwt-ui-mobile-icon-back1, .ds-dwt-ui-mobile-icon-mirror, .ds-dwt-ui-mobile-icon-next, .ds-dwt-ui-mobile-icon-a-fulldetetedimage, -.ds-dwt-ui-mobile-icon-rotate_left, .ds-dwt-ui-mobile-icon-rotate_right, .ds-dwt-ui-mobile-icon-save, .ds-dwt-ui-mobile-icon-select_all, -.ds-dwt-ui-mobile-icon-unselected, .ds-dwt-ui-mobile-icon-a-uploadfromserver, .ds-dwt-ui-mobile-icon-flip, .ds-dwt-ui-mobile-icon-delete, -.ds-dwt-ui-mobile-icon-crop, .ds-dwt-ui-mobile-icon-a-addimage, .ds-dwt-ui-mobile-icon-a-addimagefromcamera -{ - -webkit-flex: 0 0 40px; - flex: 0 0 40px; -} -} - -.ds-dwt-ui-mobile-icon-a-allselected:before { - content: "\e66a"; -} - -.ds-dwt-ui-mobile-icon-arrow:before { - content: "\e66f"; -} - -.ds-dwt-ui-mobile-icon-capture:before { - content: "\e66e"; -} - -.ds-dwt-ui-mobile-icon-a-turncamera:before { - content: "\e667"; -} - -.ds-dwt-ui-mobile-icon-resolution:before { - content: "\e668"; -} - -.ds-dwt-ui-mobile-icon-a-multiplecapture:before { - content: "\e669"; -} - -.ds-dwt-ui-mobile-icon-close:before { - content: "\e665"; -} - -.ds-dwt-ui-mobile-icon-a-localupload:before { - content: "\e666"; -} - -.ds-dwt-ui-mobile-icon-a-autocapture:before { - content: "\e662"; -} - -.ds-dwt-ui-mobile-icon-a-autodetection:before { - content: "\e664"; -} - -.ds-dwt-ui-mobile-icon-back1:before { - content: "\e663"; -} - -.ds-dwt-ui-mobile-icon-mirror:before { - content: "\e661"; -} - -.ds-dwt-ui-mobile-icon-next:before { - content: "\e660"; -} - -.ds-dwt-ui-mobile-icon-a-fulldetetedimage:before { - content: "\e65f"; -} - -.ds-dwt-ui-mobile-icon-rotate_left:before { - content: "\e658"; -} - -.ds-dwt-ui-mobile-icon-rotate_right:before { - content: "\e659"; -} - -.ds-dwt-ui-mobile-icon-save:before { - content: "\e65a"; -} - -.ds-dwt-ui-mobile-icon-select_all:before { - content: "\e655"; -} - -.ds-dwt-ui-mobile-icon-unselected:before { - content: "\e656"; -} - -.ds-dwt-ui-mobile-icon-a-uploadfromserver:before { - content: "\e657"; -} - -.ds-dwt-ui-mobile-icon-flip:before { - content: "\e652"; -} - -.ds-dwt-ui-mobile-icon-delete:before { - content: "\e653"; -} - -.ds-dwt-ui-mobile-icon-crop:before { - content: "\e654"; -} - -.ds-dwt-ui-mobile-icon-a-addimage:before { - content: "\e651"; -} - -.ds-dwt-ui-mobile-icon-a-addimagefromcamera:before { - content: "\e650"; -} - - -.ds-dwt-ui-icon-preImage-grey, -.ds-dwt-ui-icon-nextImage-grey, -.ds-dwt-ui-icon-restore-grey, -.ds-dwt-ui-icon-erase-grey, -.ds-dwt-ui-icon-zoomin-grey, -.ds-dwt-ui-icon-saveImage-grey, -.ds-dwt-ui-icon-zoomout-grey, -.ds-dwt-ui-icon-rotateLeftImage-grey, -.ds-dwt-ui-icon-rotateRightImage-grey, -.ds-dwt-ui-icon-flipImage-grey, -.ds-dwt-ui-icon-mirrorImage-grey -{ color:#999 } - - -.ds-dwt-ui-icon-erase-grey, -.ds-dwt-ui-icon-cropImage-grey { - color:#999 -} - -.ds-dwt-ui-icon-erase, -.ds-dwt-ui-icon-cropImage { - color:#fff -} - -.DVS_content, .DVS_content > .DVS_middle > .DVS_container { - border: 0; -} - -.ds-dvs-ui-move_left:before { - content: '\e648'; -} - -.ds-dvs-ui-move_right:before { - content: '\e649'; -} - -.ds-dvs-ui-rightbottom:before { - content: '\e734'; -} - -.ds-dvs-ui-scanner:before { - content: '\e633'; -} - -.ds-dvs-ui-folderopen:before { - content: '\e629'; -} - -.ds-dvs-ui-unselected:before { - content: '\e628'; -} - -.ds-dvs-ui-exitFullWeb:before { - content: '\e60b'; -} - -.ds-dvs-ui-pencil:before { - content: '\e609'; -} - -.ds-dvs-ui-cropMove:before { - content: '\e80e'; -} - -.ds-dvs-ui-fullWeb:before { - content: '\e6a0'; -} - -.ds-dvs-ui-shrinkImage:before { - content: '\e724'; -} - -.ds-dvs-ui-shrinkCanvas:before { - content: '\ef6b'; -} - -.ds-dvs-ui-fitWidth:before { - content: '\e64a'; -} - -.ds-dvs-ui-fitHeight:before { - content: '\e64b'; -} - -.ds-dvs-ui-magnifyImage:before { - content: '\e661'; -} - -.ds-dvs-ui-magnifyCanvas:before { - content: '\ea12'; -} - -.ds-dvs-ui-autoFit:before { - content: '\ea8c'; -} - -.ds-dvs-ui-selected:before { - content: '\e876'; -} - -.ds-dvs-ui-confire:before { - content: '\e60a'; -} - -.ds-dvs-ui-tagColor:before { - content: '\e608'; -} - -.ds-dvs-ui-cancle:before { - content: '\e658'; -} - -.ds-dvs-ui-mutiple:before { - content: '\e645'; -} - -.ds-dvs-ui-exitMutiple:before { - content: '\e605'; -} - -.ds-dvs-ui-addTag:before { - content: '\e6ab'; -} - -.ds-dvs-ui-rotateAll:before { - content: '\e65f'; -} - -.ds-dvs-ui-fullDevice:before { - content: '\e621'; -} - -.ds-dvs-ui-pageNext:before { - content: '\eb65'; -} - -.ds-dvs-ui-thumbnail:before { - content: '\e6c0'; -} - -.ds-dvs-ui-tags:before { - content: '\e814'; -} - -.ds-dvs-ui-tree:before { - content: '\e65a'; -} - -.ds-dvs-ui-pagePre:before { - content: '\e600'; -} - -.ds-dvs-ui-pageEnd:before { - content: '\e63e'; -} - -.ds-dvs-ui-pageStart:before { - content: '\e602'; -} - -.ds-dvs-ui-exitFull:before { - content: '\e603'; -} - -.ds-dvs-ui-save:before { - content: '\e604'; -} - -.ds-dvs-ui-print:before { - content: '\e857'; -} - -.ds-dvs-ui-delete:before { - content: '\e607'; -} - -.ds-dvs-ui-file:before { - content: '\e624'; -} - -.ds-dvs-ui-mirror:before { - content: '\eb64'; -} - -.ds-dvs-ui-flip:before { - content: '\eb63'; -} - -.ds-dvs-ui-list:before { - content: '\e67b'; -} - -.ds-dvs-ui-crop:before { - content: '\e74c'; -} - -.ds-dvs-ui-rotateLeft:before { - content: '\e68a'; -} - -.ds-dvs-ui-wipe:before { - content: '\e60d'; -} - -.ds-dvs-ui-undo:before { - content: '\e620'; -} - -.ds-dvs-ui-reset:before { - content: '\e651'; -} - -.ds-dvs-ui-redo:before { - content: '\e606'; -} - -.ds-dvs-ui-readType:before { - content: '\e662'; -} - -.dynamsoft-dialog-selectsource li{list-style:none} -.dynamsoft-dialog-license li{list-style:none} -.ds-dwt-ui-dlg li{list-style:none} - -.ds-dwt-loaderBar-noserver-parent -{ - height:100%; -} - -.ds-dwt-loaderBar-noserver -{ - margin: 0 auto; - padding-top: 35px; - text-align: center; -} - -.ds-dwt-loaderBar-noserver img{ - height: 100px -} - -.ds-dwt-loaderBar -{ - margin: 0 auto; - text-align: center; -} - -.ds-dwt-loaderBar img -{ - border: 0; - vertical-align: middle; -} - -.dynamsoft-dwt-dialogProgress { - min-width: 328px; -} - -.ds-dwt-progressWrap -{ - padding: 15px 18px 8px 18px; -} - -.ds-dwt-textLeft -{ - text-align: left; -} - -.dynamsoft-dwt-ltsdlg-header { - position: relative; - padding: 7px 0 7px 0; - background: #323234; -} - -.dynamsoft-dwt-ltsdlg-body { - font-size: 17px; - padding: 25px 20px 20px 25px; - line-height: 24px; - text-align:left; -} - -.dynamsoft-dwt-warning,.dynamsoft-dwt-error { - position: absolute; - left: 16px; - top: 5px; - width: 20px; - height: 20px; - display: inline-block; -} - -.dynamsoft-dwt-warning{ -background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsSAAALEgHS3X78AAABKklEQVQ4ja1UAXHDMAz85QogEMqgGYNAGIRAMIRCKISMQSF4CGYIHYMMwe/UvW6e66RZl7/T6WJJL0W29EQSM+gA9NJ7uVwAJABR+hZGWMhA8sJvmI4kj5JY2IYyPv9oSSY5jyS7SjKXTj5UTFsS7klOMtaIuoXzpFjjgPfQ+2E9myqdORY6R6ueGrodgAHAAcDzDNk9TOJ4N90ACABeZ29tHZI4QqPqxn+QOYzj0GxA9AubE9qlfGga4oLfeQWXcXw2IgobFBeuibNHfVqYjNMd++iP2w8GjVFYCFpKRp/r3BCUZS1Rr2XBfEnsiqb6pAySWLksG88Xvd83TdjPUGSbZlIvfD2ds+2TI8mvr1We/67DiK6b4xHxIKvKMlez/kX82dxs3oeExBcP2agdc6IF/QAAAABJRU5ErkJggg=='); -} -.dynamsoft-dwt-error { -background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsSAAALEgHS3X78AAABRUlEQVQ4jZ1UwU3EQAwc0BWQEq4DwhcJKSVQwpZwJVDClZASKCF8eKeE0EEoAA3y3Vgyi/cuhyVrtVnv2BmP944kGtYDGLTuFbIAmAFMWv+aAVZeSC48m60TyVf5VJ2V+n7cdCRnBY8k+ySZe68Y6k5XA+5Jrjq8BJQBz7prGHAOnQ/jbG2R2rBOnOLEt3hgUtkx40jfjkmlZgUqeWz8zlqBFn3LaDGMGUIeLnDkoJfAIAzurvAzi9cP7Z+a+pPdbyDdhP0t768FW4WfCpyS8wLgCOBZe48ZG4m/nMyl0c2as6xR7oYxRlHXUiiNBvQJ4OjijpfNDjdMSdQrPUk8OCjLVqBBjwVjxbuKVB+7Ip+SZpmMXgA8AHgH8PhLSuGlWUODzN7C6xPNJysdhvi7bgZ0ejn+47Hllrk1gpvdZZPp6nYn8QM3jKdoTCb4owAAAABJRU5ErkJggg=='); -} - -.dynamsoft-dwt-ltsdlg-header .dynamsoft-dialog-close { - float: right; - margin: 2px 10px 0 0; - width: 25px; - height: 25px; - cursor: pointer; - color: #CCCCCC; - background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAABHNCSVQICAgIfAhkiAAAAotJREFUSEuVVktSAjEQdWAjnyq9gbh0hZwAOIF4AvUE4gngBuIJxBOIJwBOAK5cijeAKmDcAL6X6qRCmCRC1RSZSTrvded1d5KTwG+3252v1+s6lrQwriRJ0tDL8T7C+wzvg2KxOMZ47tsq8U1g8/Z2u+3A+DxEhHMAnOdyuS7AXrLWHoCkaVrB5u9YfC0Gn2SN8ZRPuVyeLpdLzqlHvKvK2inAbguFAj00vz0QMR6SPTZeCLtezBPxugu7M3qF9U2S0XYGhB5sNpuJAIzz+fy9yygEJvZ92NcJBPuatjcgq9WKyFUsGIOFOeCYF+683oehLZVKNc4rELqLzZ8ZIjC4JgNR1iMPM6Qcd514NGXo8DzBvpdwEdC/GSb9kcD41sVfh4ywsJkFJABDCgDjB0Sg75Cew5vLBJu1MEE1feKDVhRlyRwZMYRZQDYAbUGkYROxwnZLEKLfwegFTNp2jH1AMQDuAaX2APqI4VuCF2YuFWHcjQC14OGAIcryQNti33vs+0oh0ZMdJ/BSs7XtA4JhirWFEIB4wkSdUM4GBOfhLTFC4gLK+SIAgaDAK/z/2GTcsXbgGE+UivD84jkNqc7xZPHfM9EAVNENzuTDpzrfmcTUZQMomcbkfaAuK09MGZAzYJ4cAGimMaC9PJGMn9llgBtZGX+QaFlAnoxfQFAVt3aZ6ilM26r2BLqeu86u5qZ2aVZWFR4hX5ohaUZkq6o580iXKbefqOoJdiNU44dj+4nuqHY1J6GszsgyozpcqG/b3tj3AQJgrpHZGbWR9HjWJtO36RmTjyGwejzndY839wEQawV7fAY71bdj50P2oftArF4xVxoAUfcuYc5QMiQ8vxn+ee9iiL33rj9rSGBbV1zs3AAAAABJRU5ErkJggg=='); -} - -.ds-dwt-ui-icon-color{ - color: black; -} - -.ds-dwt-ui-icon-color-grey{ - color:#999 -} - -.dvs-dynamsoftDocumentTopGroup, .dvs-dynamsoftDocumentBottomGroup { - background: white; - color: #aaa; -} - -.dvs-myMainTopGroup, .dvs-myMainBottomGroup, .dvs-myMultiSelectionTopGroup, .dvs-dynamsoftDocumentTopRightGroup{ - background: white; - width: 100%; -} - -.dvs-myMultiSelectionBottomGroup, .dvs-dynamsoftDocumentBottomGroup { - background: #F0EFF4 0% 0% no-repeat padding-box; - width: 100%; - border-top: 1px solid #ccc; -} - -.ds-dwt-ui-icon-left { - left: 0; -} - -.ds-dwt-ui-icon-right { - right: 2px; - position: absolute; -} - -.dvs-myMainTopGroup { - justify-content: space-around; -} - -.dvs-myMainTopGroup, .dvs-myMultiSelectionTopGroup { - -webkit-justify-content: flex-start !important; - justify-content: flex-start !important; -} - - @media screen and (max-device-width: 500px) { - /*.ds-dwt-ui-icon-left { - position: absolute; - } - - .dvs-myMainTopGroup { - -webkit-justify-content: flex-start !important; - justify-content: flex-start !important; - }*/ - - .ds-dwt-ui-mobile-icon-left { - position: absolute; - } -} - -.dynamsoft-loadingMsg{ - width:290px; - height:290px; - margin:auto; - color:#CCC; - border: 1px solid #ccc; - background:#FFF -} - -.dynamsoft-loadingMsg-msg{margin:0 0 15px 25px;color:#3a3a3a;font:20px Arial,sans-serif} -.dynamsoft-loadingMsg-desc{text-align:center;margin:0 0 15px 0;color:#3a3a3a;font:14px Arial,sans-serif} - -.dynamsoft-dwt-dialogProgress { - background:#FFF; - border: 1px solid #ccc; -} - -.dynamsoft-dwt-btnCapture { - position: absolute; - bottom: 50px; - left: 50%; - transform: translateX(-50%); - width: 80px; - height: 80px; - border-radius: 50%; - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - background: #323234 0% 0% no-repeat padding-box; - box-shadow: 0px 4px 4px #00000029; - border: 1px solid #707070; - font-size: 35px; -} - -.dynamsoft-dwt-btnCapture-position-absolute { - position: absolute; -} - -.dynamsoft-dwt-btnCapture-position-relative { - position: relative; -} - -.dynamsoft-dwt-selectColor { - color: #FE8E14; -} - -@font-face{font-family:dcs-ui-icon;src:url(data:application/vnd.ms-fontobject;base64,7AsAADgLAAABAAIAAAAAAAIABQMAAAAAAAABAJABAAAAAExQAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAeL6+AQAAAAAAAAAAAAAAAAAAAAAAABYAZABjAHMALQB1AGkALQBpAGMAbwBuAAAADgBSAGUAZwB1AGwAYQByAAAAFgBWAGUAcgBzAGkAbwBuACAAMQAuADAAAAAWAGQAYwBzAC0AdQBpAC0AaQBjAG8AbgAAAAAAAAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzI8hU3hAAABfAAAAFZjbWFwcqsSKgAAAfQAAAHsZ2x5Zh+ykfAAAAP0AAAERGhlYWQb7ra+AAAA4AAAADZoaGVhB94DiQAAALwAAAAkaG10eCAAAAAAAAHUAAAAIGxvY2EEsgN2AAAD4AAAABJtYXhwAR0ARAAAARgAAAAgbmFtZVkpOWIAAAg4AAACkXBvc3QLnBgqAAAKzAAAAGoAAQAAA4D/gABcBAAAAAAABAAAAQAAAAAAAAAAAAAAAAAAAAgAAQAAAAEAAAG+vnhfDzz1AAsEAAAAAADcZ7lhAAAAANxnuWEAAP9/BAADgAAAAAgAAgAAAAAAAAABAAAACAA4AAsAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQQAAZAABQAIAokCzAAAAI8CiQLMAAAB6wAyAQgAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA5g7r7wOA/4AAXAOAAIEAAAABAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAFAAAAAwAAACwAAAAEAAABiAABAAAAAACCAAMAAQAAACwAAwAKAAABiAAEAFYAAAAOAAgAAgAG5g/mMeZY5nXnievv//8AAOYO5jHmWOZ154nr7///AAAAAAAAAAAAAAAAAAEADgAQABAAEAAQABAAAAAFAAMABAABAAYABwACAAABBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAABkAAAAAAAAAAcAAOYOAADmDgAAAAUAAOYPAADmDwAAAAMAAOYxAADmMQAAAAQAAOZYAADmWAAAAAEAAOZ1AADmdQAAAAYAAOeJAADniQAAAAcAAOvvAADr7wAAAAIAAAAAADAAigDmASIBegHKAiIAAAABAAAAAANbAscAHAAANxYyPwEXFjI2NC8BNzY0JiIPAScmIgYUHwEHBhSyEjMS9PQSMyQR9fQSJDMS9PQSMyQS9PQTHRIS9fQSJDMS9PQSMyQS9PQRJDMS9PQSMQAAAAADAAD/gAQAA4AACwAcADcAABEWABc2ADcmACcGABc0PgIyHgIUDgIiLgI3NDU/Aj4BHgEPASEyFhQGByEXFg4BIi8CBQEh2tkBIQUF/t/Z2v7fO0OAorWigENDgKK1ooBDwQIE1AkaEwEJngF2DRISDf6JnwkBExoK0gYBgNn+3wUFASHZ2gEhBQX+39pbooBDQ4CitaKAQ0OAol0BAQcI4AoBExkLqBIbEgGrCxkSCuIMAAADAAD/gAQAA4AACwAcADcAAAEGAAcWABc2ADcmABMOASIuAjQ+AjIeAhQGJzQ1LwIuAQ4BHwEhIgYUFhchBwYeATI/AgIA2v7fBQUBIdrZASEFBf7fY0CitaKAQ0OAorWigENDfQIF0woZFAEJn/6KDhISDgF3oAkBExoK0gcDgAX+39rZ/t8FBQEh2doBIfzJQENDgKK1ooBDQ4CitaL/AQEHCOAKARMZC6gSGxIBqwoaEgriDAAABQAA/4AEAAOAAAQADAAQABQAIQAAASERIRElFTM1MxUhNQMRIRkBITUhEycRIREjESERIREzFwNA/MAEAP4AQED/AIACAP4AAgDAgP2AgAEAAYBeoQOA/AADPoKAgMC//IEBAP8AAT9B/n8BAcD+QAOA/wABAKEACwAA/38EAAOAAAUACwARABcAGwAfACMAJwArAC8AMwAAEzM1BREzESMRITUjARUzFTMRAyMVIREjBSEVITUhFSElIRUhNSEVITUhFSEFIREhFzMVI03z/sBNTQFA8wJz801N8wFATf0NAoD9gAKA/YABfwEB/v8BAf7/AQH+//6BAUD+wE2mpgMzTQH+wf6A/sBNA7NN8wFA/E1NAUAUTc1Nz03GTcZN8wFATaYAAAAEAAD/swQAA00AAAANACEALQAAASMeAjI+ATcuAScOAQEjJyEHIw4BBxEeARchPgE3ES4BAS4BJz4BNx4BFw4BAgCkAStNVk0rAQJcRkZcAjyjXf7MXaMrOgEBOisDNCs6AQE6/jttkAMDkG1tkAMDkAFNLUssLEstRV0CAl0BVGdnATor/ZosOgEBOiwCZis6/WgDkG1tkAMDkG1tkAAABgAA/4ADwQOAABcAHwAnACsALwAzAAABIzUuASchDgEHFSMVMxEeARchPgE1ETMlNjchFhcVIQEGByEmJxEhBTMRIxMzESMTMxEjA8DlASke/toeKQHkPwEsHgJvHyk//aEBCgEmCgH+xAHdAQr9lwoBAn/95jw8vTw8vDw8AwA0HywBASwfNED9CB8oAQEoHwL4dAsBAQs0/MsKAQEKAvV//f8CAf3/AgH9/wAAAAAAABIA3gABAAAAAAAAABUAAAABAAAAAAABAAsAFQABAAAAAAACAAcAIAABAAAAAAADAAsAJwABAAAAAAAEAAsAMgABAAAAAAAFAAsAPQABAAAAAAAGAAsASAABAAAAAAAKACsAUwABAAAAAAALABMAfgADAAEECQAAACoAkQADAAEECQABABYAuwADAAEECQACAA4A0QADAAEECQADABYA3wADAAEECQAEABYA9QADAAEECQAFABYBCwADAAEECQAGABYBIQADAAEECQAKAFYBNwADAAEECQALACYBjQpDcmVhdGVkIGJ5IGljb25mb250CmRjcy11aS1pY29uUmVndWxhcmRjcy11aS1pY29uZGNzLXVpLWljb25WZXJzaW9uIDEuMGRjcy11aS1pY29uR2VuZXJhdGVkIGJ5IHN2ZzJ0dGYgZnJvbSBGb250ZWxsbyBwcm9qZWN0Lmh0dHA6Ly9mb250ZWxsby5jb20ACgBDAHIAZQBhAHQAZQBkACAAYgB5ACAAaQBjAG8AbgBmAG8AbgB0AAoAZABjAHMALQB1AGkALQBpAGMAbwBuAFIAZQBnAHUAbABhAHIAZABjAHMALQB1AGkALQBpAGMAbwBuAGQAYwBzAC0AdQBpAC0AaQBjAG8AbgBWAGUAcgBzAGkAbwBuACAAMQAuADAAZABjAHMALQB1AGkALQBpAGMAbwBuAEcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAAcwB2AGcAMgB0AHQAZgAgAGYAcgBvAG0AIABGAG8AbgB0AGUAbABsAG8AIABwAHIAbwBqAGUAYwB0AC4AaAB0AHQAcAA6AC8ALwBmAG8AbgB0AGUAbABsAG8ALgBjAG8AbQAAAAACAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgBAgEDAQQBBQEGAQcBCAEJAAtleGl0TXV0aXBsZQhwcmV2aW91cwRuZXh0BHNhdmUGZGV0ZWN0B2NhcHR1cmUGZGVsZXRlAAAAAA==);src:url(data:application/vnd.ms-fontobject;base64,7AsAADgLAAABAAIAAAAAAAIABQMAAAAAAAABAJABAAAAAExQAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAeL6+AQAAAAAAAAAAAAAAAAAAAAAAABYAZABjAHMALQB1AGkALQBpAGMAbwBuAAAADgBSAGUAZwB1AGwAYQByAAAAFgBWAGUAcgBzAGkAbwBuACAAMQAuADAAAAAWAGQAYwBzAC0AdQBpAC0AaQBjAG8AbgAAAAAAAAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzI8hU3hAAABfAAAAFZjbWFwcqsSKgAAAfQAAAHsZ2x5Zh+ykfAAAAP0AAAERGhlYWQb7ra+AAAA4AAAADZoaGVhB94DiQAAALwAAAAkaG10eCAAAAAAAAHUAAAAIGxvY2EEsgN2AAAD4AAAABJtYXhwAR0ARAAAARgAAAAgbmFtZVkpOWIAAAg4AAACkXBvc3QLnBgqAAAKzAAAAGoAAQAAA4D/gABcBAAAAAAABAAAAQAAAAAAAAAAAAAAAAAAAAgAAQAAAAEAAAG+vnhfDzz1AAsEAAAAAADcZ7lhAAAAANxnuWEAAP9/BAADgAAAAAgAAgAAAAAAAAABAAAACAA4AAsAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQQAAZAABQAIAokCzAAAAI8CiQLMAAAB6wAyAQgAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA5g7r7wOA/4AAXAOAAIEAAAABAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAFAAAAAwAAACwAAAAEAAABiAABAAAAAACCAAMAAQAAACwAAwAKAAABiAAEAFYAAAAOAAgAAgAG5g/mMeZY5nXnievv//8AAOYO5jHmWOZ154nr7///AAAAAAAAAAAAAAAAAAEADgAQABAAEAAQABAAAAAFAAMABAABAAYABwACAAABBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAABkAAAAAAAAAAcAAOYOAADmDgAAAAUAAOYPAADmDwAAAAMAAOYxAADmMQAAAAQAAOZYAADmWAAAAAEAAOZ1AADmdQAAAAYAAOeJAADniQAAAAcAAOvvAADr7wAAAAIAAAAAADAAigDmASIBegHKAiIAAAABAAAAAANbAscAHAAANxYyPwEXFjI2NC8BNzY0JiIPAScmIgYUHwEHBhSyEjMS9PQSMyQR9fQSJDMS9PQSMyQS9PQTHRIS9fQSJDMS9PQSMyQS9PQRJDMS9PQSMQAAAAADAAD/gAQAA4AACwAcADcAABEWABc2ADcmACcGABc0PgIyHgIUDgIiLgI3NDU/Aj4BHgEPASEyFhQGByEXFg4BIi8CBQEh2tkBIQUF/t/Z2v7fO0OAorWigENDgKK1ooBDwQIE1AkaEwEJngF2DRISDf6JnwkBExoK0gYBgNn+3wUFASHZ2gEhBQX+39pbooBDQ4CitaKAQ0OAol0BAQcI4AoBExkLqBIbEgGrCxkSCuIMAAADAAD/gAQAA4AACwAcADcAAAEGAAcWABc2ADcmABMOASIuAjQ+AjIeAhQGJzQ1LwIuAQ4BHwEhIgYUFhchBwYeATI/AgIA2v7fBQUBIdrZASEFBf7fY0CitaKAQ0OAorWigENDfQIF0woZFAEJn/6KDhISDgF3oAkBExoK0gcDgAX+39rZ/t8FBQEh2doBIfzJQENDgKK1ooBDQ4CitaL/AQEHCOAKARMZC6gSGxIBqwoaEgriDAAABQAA/4AEAAOAAAQADAAQABQAIQAAASERIRElFTM1MxUhNQMRIRkBITUhEycRIREjESERIREzFwNA/MAEAP4AQED/AIACAP4AAgDAgP2AgAEAAYBeoQOA/AADPoKAgMC//IEBAP8AAT9B/n8BAcD+QAOA/wABAKEACwAA/38EAAOAAAUACwARABcAGwAfACMAJwArAC8AMwAAEzM1BREzESMRITUjARUzFTMRAyMVIREjBSEVITUhFSElIRUhNSEVITUhFSEFIREhFzMVI03z/sBNTQFA8wJz801N8wFATf0NAoD9gAKA/YABfwEB/v8BAf7/AQH+//6BAUD+wE2mpgMzTQH+wf6A/sBNA7NN8wFA/E1NAUAUTc1Nz03GTcZN8wFATaYAAAAEAAD/swQAA00AAAANACEALQAAASMeAjI+ATcuAScOAQEjJyEHIw4BBxEeARchPgE3ES4BAS4BJz4BNx4BFw4BAgCkAStNVk0rAQJcRkZcAjyjXf7MXaMrOgEBOisDNCs6AQE6/jttkAMDkG1tkAMDkAFNLUssLEstRV0CAl0BVGdnATor/ZosOgEBOiwCZis6/WgDkG1tkAMDkG1tkAAABgAA/4ADwQOAABcAHwAnACsALwAzAAABIzUuASchDgEHFSMVMxEeARchPgE1ETMlNjchFhcVIQEGByEmJxEhBTMRIxMzESMTMxEjA8DlASke/toeKQHkPwEsHgJvHyk//aEBCgEmCgH+xAHdAQr9lwoBAn/95jw8vTw8vDw8AwA0HywBASwfNED9CB8oAQEoHwL4dAsBAQs0/MsKAQEKAvV//f8CAf3/AgH9/wAAAAAAABIA3gABAAAAAAAAABUAAAABAAAAAAABAAsAFQABAAAAAAACAAcAIAABAAAAAAADAAsAJwABAAAAAAAEAAsAMgABAAAAAAAFAAsAPQABAAAAAAAGAAsASAABAAAAAAAKACsAUwABAAAAAAALABMAfgADAAEECQAAACoAkQADAAEECQABABYAuwADAAEECQACAA4A0QADAAEECQADABYA3wADAAEECQAEABYA9QADAAEECQAFABYBCwADAAEECQAGABYBIQADAAEECQAKAFYBNwADAAEECQALACYBjQpDcmVhdGVkIGJ5IGljb25mb250CmRjcy11aS1pY29uUmVndWxhcmRjcy11aS1pY29uZGNzLXVpLWljb25WZXJzaW9uIDEuMGRjcy11aS1pY29uR2VuZXJhdGVkIGJ5IHN2ZzJ0dGYgZnJvbSBGb250ZWxsbyBwcm9qZWN0Lmh0dHA6Ly9mb250ZWxsby5jb20ACgBDAHIAZQBhAHQAZQBkACAAYgB5ACAAaQBjAG8AbgBmAG8AbgB0AAoAZABjAHMALQB1AGkALQBpAGMAbwBuAFIAZQBnAHUAbABhAHIAZABjAHMALQB1AGkALQBpAGMAbwBuAGQAYwBzAC0AdQBpAC0AaQBjAG8AbgBWAGUAcgBzAGkAbwBuACAAMQAuADAAZABjAHMALQB1AGkALQBpAGMAbwBuAEcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAAcwB2AGcAMgB0AHQAZgAgAGYAcgBvAG0AIABGAG8AbgB0AGUAbABsAG8AIABwAHIAbwBqAGUAYwB0AC4AaAB0AHQAcAA6AC8ALwBmAG8AbgB0AGUAbABsAG8ALgBjAG8AbQAAAAACAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgBAgEDAQQBBQEGAQcBCAEJAAtleGl0TXV0aXBsZQhwcmV2aW91cwRuZXh0BHNhdmUGZGV0ZWN0B2NhcHR1cmUGZGVsZXRlAAAAAA==#iefix) format("embedded-opentype"),url("data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAVwAAsAAAAACzgAAAUjAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDbAqIRIcLATYCJAMgCxIABCAFhREHahujCREVpG+R/TywYzrDWpv1mZHP4JG0z/n/vVO7TzOylRlJjkPolBANJQC5XbQLCF8LxGFUFtibc/q1DgDfd2odmyABkglL27tDY3PX+U62/GS5g/FjMAYTtyaOpX6mQKR7dFB00G42y/M8j0jKAs/z8YB0C+wc6mCCjgcCIJCFLqAx46Z4oYFDWo0A0Ia1q5dC8+nAU4gETemI2ZaDTkGFprysfA/gpPn99Bt6kQYoUBmkE81YNXYFRtjmb38xK2phAbMQrM8C4LYTwAB0AcABeinWdgTMDnYBg/j8FQ4/ABMaFDhsl93TnmPvbH75t7+iUdv010pRgolYORlQwcBH9Y/nhAKQAyTTEboi5ARsU2WCCtguJjDA7skEDthzmECAvZMJDqD5ZSY4gd/+0kFBsLZyLIAcgMYC9AVAu2xMYGBQIcHhyNTd6UqcqnFuOCQIjyMjQU/RImJ54HG4c8CnXclHwU7+wNPgh6EOXv+T0PtWR5/3kcWKmnwlzYFi21/Y6AuWECJchLAKEaHiiwaClJwcuPjw8eUErxF+bD1K0H3nLz0KJfmT9hc2eovp9ubmrPk/gT9ISUn+Cw8eXUr06aFH1uNEw3vu8uNwciB5f6wW71wGSRI67WEuhZnkmuvXr0URTkMxmPTtl7REkYpQDBL7ISHZHgGDiQ0uZEuHudyATup1LjGY7pMQq8X1oqJwSUl2cbG/sHC78Ote8XpuBr+e19f9VkG2eiN/Tez7lJQEiop8hYX7BV35sJ1+7/0UCEh++YO2rocfkSo3XUw2zidC33suwbyQpLo2SC4WY+4rGe7e7sh/kYjBliRk8kSkOwKLzc3pCYuXejxlGpF7PMQyj4fzn2dQ2fxRtw8fvj3qDYVtjBx1+w3fjXy8gCipf0HNy6daaaHrD3cZ7nT3x7tvPAlpOWmX8+rmw8OsGoblZTVPxtG7f7RCDmsO/P+nGp9fc9nqBbgBNBlyd9988nIMYT36xIwAhkWDBlvez8f4SGOHAQzHSHxkHcbHFpzHAiwsunULvKB3ZOpwDJ9qTR0xYmqkfe/XNHHE8fKC1yKBuH/jranWDyrLoR9pKn1pPvTvCIkwZcqDeRCd8q93mjSls19hG7E6jZm/YCzJbD1m8Oy7C1b14dy7ty6LVfLyrT7mfHKVuPz5xQ3KyZOKJt7AHBS5z4MhDE19zHBuu9yw2adxxPBn5lu5m2tfzH42fNF2cardKdFnSGZB35hTa0/FtBxOPTSEhrwPRL4HO3ZC+jCbr3wFRC0OZpnQw0SLfSKnA/sr/3x4u3Kxa0iLJjkAoHL1O0tRmJ932crx4V/f/Jw9/CuU9Bp/t6bqQHXZBkDe/QoAIQ8BrmtXHKrrVCTmJgKkSHRJCpzwkBgk2gM5tBdQhQ4FOqATSAKdMXtniXgcAgPxGACdcBpIhCS8R1JgIo/EkIQaIIe2AFQsSaADmkMS8FP/fUq0o+PCeBIYRUWXB7WWJ6cU6qGyIYlt4p/6C3UcjNxrHd8fJLQ4moo0j4m8YILUt0G41qWqIyc80nPFJ8MwMHnhDlbTRtUfs8zF3VJqeZwdMFpgFBVdHtRanpy+kR6wwoYktiBM+zlfqONgJL2FGP8f5C5raW6oSPN8wBc2cvM27GN+uNalyhZHarnwSM+9tmCgIJOPX6qD1bQp4ffHjAa5vLK0XcW47ScBCEjPo1Eqbazz/JAr762+Rm39gJ0XXFuOYTXhrqtgrthU0KVI3FrjNYpXMty1sxkA") format("woff2"),url(data:font/woff;base64,d09GRgABAAAAAAdgAAsAAAAACzgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFY8hU3hY21hcAAAAYAAAACJAAAB7HKrEipnbHlmAAACDAAAAxkAAAREH7KR8GhlYWQAAAUoAAAALwAAADYb7ra+aGhlYQAABVgAAAAcAAAAJAfeA4lobXR4AAAFdAAAAA4AAAAgIAAAAGxvY2EAAAWEAAAAEgAAABIEsgN2bWF4cAAABZgAAAAfAAAAIAEdAERuYW1lAAAFuAAAAVMAAAKRWSk5YnBvc3QAAAcMAAAAUgAAAGoLnBgqeJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkYWCcwMDKwMHUyXSGgYGhH0IzvmYwYuRgYGBiYGVmwAoC0lxTGBye8b1+z9zwv4EhhrmBoREozAiSAwDwdQzmeJztkcENgzAMRZ8JDaiqoIP0wjIVA7ACC/RUFjUHDoxA7biq2h3q6EX6X8qP5A+cgGTcjBrkieDzMFeKnzgXv+ZuuqOlImuvg446r8u2Hwdo96u/RuzN9XP8x2RZQqaxJCTzn0u5p7dqfJ+B96N94D3pEHhXOgbek86BbZV1CTxn2wOqF5YnKTcAAAB4nG2Tz2/bZBjHn+/7xs7qrNns/LDaQaK3XpNVSVMR243URY1RxS6Tb2iXLVwmsV2mHUDbaaq3G5x2Q+LA6IYqJG5M3DYtlSYQAoQEXBoJFSHgH2gn7RA7PG7SURC2nvd53tfP8z4ff1+bQHzJy+Ibeo2oU273YJfbq94KOqtebeEU6rUFvVhFVi9+abnWwYHlnjVfHFhnpzGPhdct698r5iR+43BronGUIRlRjjt0iMwy2avUqVFdJ9tbF+2KKObFQkt0PL8n1lHBKah2uahnlV3OY2FFaFDDXShNS/Z2h8ne+Y3o4VcPo42p2xGZX2bmC5j5BLdmLWs2+eDBDArzxk86ot1kT+Pq3eGkenj5nzJ2fSB74jcDhbnc59YZC1/k5izj95P/wwydskfYBWZqiSm4Xvf8FdFCHlUoFqpsq6xeQbsnBA0nzY/QrwbHqTfuCO1nY66ImQfJh3nLyuP2pxPsrIxS1GPoo2+DjePvPP4vtzE/4dZecWfoJJ2mIilmV6YyF0uu75aUL001B+WrQp0XHTN95NoyGA0ylFAQjCkSHAgaRHEUgRC9syWjEcn1e1E0eDa6CxoTem8mm8AgCWTEM9pilWi8edhX49gkm85QlRyqU4NWyCUquL5mumlD30HJLbmmdEoMoClmYluc+tQ0hrLdkhPuJ4MwRLAv3tsPw30EYTwrGCs1cP9kfGTJXQScu70t3RDJThLxRD5OS0bpBsXwh/DH8Gu+0022+ZvMMO9j5g05nmWNllklpyLa6+i0UM8DTl1lnTyyZgW24lWzBfATjnghD0GfoRFeChsQVy5cuCK6j/rJ9/1HjTVgrSG9Q5+cv3Ffyvs3DkeEyxebzYvLb/WF6OPta9c4L/64meY1xbuNtfj6USaPRHp6jnKH9bRZx1cqwvEZQjFXyWEJJ2y+6S6udlTZLinwL1Pjg9VY6cLU5OBPLFWSYWUJf/TQrIib1aVevAUDNQPJc/wKI/7IgNiM/+p2n3a7T7pdSV61CTSrXhCfqJ4DzlXFy/dzQM4bfWcAhnixGY8FJsYS/g2wUhOTAAAAeJxjYGRgYABixn0L78Tz23xl4GZhAIE76TsTEfT/ehYG5gYgl4OBCSQKADghCrYAeJxjYGRgYG7438AQw8IAAkCSkQEVcAAARw4CcXicY2FgYGDBgwECYAAhAAAAAAAAADAAigDmASIBegHKAiIAAHicY2BkYGDgYLBg4GYAASYg5gJCBob/YD4DAA+XAWIAeJx1kM1Kw0AUhU/6JybgQrHrcaOgJP3ZCAVXhdZ1he7bZNKmJJkwmRa68Q1c+Dw+hS+gT+HeYzpKKTbDXL577rl3LgFwjg842H2XvDt24DHbcQ0nEJbr1G8sN8h9y03yg+UW+dGyizs8WfZwgWdOcBqnzG7xatlBG2+WazjDu+U69U/LDfKX5Sbajme5Rb6y7GLq3Fv2cO28uEMtZ0ZGYr4VSajyWOXGjcLSXyf+Tz6Ri3U603vKHk6lLhOVi17Q3VPHMpf6d2a5WfSNiUWsVSZGHC7TVIlCq5UMTbA0phh0OrHVg1BlXHEIDYkZDGPE3zrHljFBCIUccRUNfRGVEj7WrPl/9Qm7FtRSTtBHPP+rU3Zq6kmVCfQQoHvEO6Y3r/yHe5bY8P0+VcNdBa9mR0Ya2c0ld0vJAkVVW1EJqQdYVl0FBujwxAf+oHo7+waXkXTTAHicbcjBDYAgEAXR/YiAWptFENwDCVECC6F8NV59txlS9Fnpn4PCBI0ZBhYOC208ouxNYk7scuEer1b1yUN09Z3NwcJBbPBZWnkzPYPoBkuHE9wAAA==) format("woff"),url(data:font/ttf;base64,AAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzI8hU3hAAABfAAAAFZjbWFwcqsSKgAAAfQAAAHsZ2x5Zh+ykfAAAAP0AAAERGhlYWQb7ra+AAAA4AAAADZoaGVhB94DiQAAALwAAAAkaG10eCAAAAAAAAHUAAAAIGxvY2EEsgN2AAAD4AAAABJtYXhwAR0ARAAAARgAAAAgbmFtZVkpOWIAAAg4AAACkXBvc3QLnBgqAAAKzAAAAGoAAQAAA4D/gABcBAAAAAAABAAAAQAAAAAAAAAAAAAAAAAAAAgAAQAAAAEAAAG+odxfDzz1AAsEAAAAAADcZ7lhAAAAANxnuWEAAP9/BAADgAAAAAgAAgAAAAAAAAABAAAACAA4AAsAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQQAAZAABQAIAokCzAAAAI8CiQLMAAAB6wAyAQgAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA5g7r7wOA/4AAXAOAAIEAAAABAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAFAAAAAwAAACwAAAAEAAABiAABAAAAAACCAAMAAQAAACwAAwAKAAABiAAEAFYAAAAOAAgAAgAG5g/mMeZY5nXnievv//8AAOYO5jHmWOZ154nr7///AAAAAAAAAAAAAAAAAAEADgAQABAAEAAQABAAAAAFAAMABAABAAYABwACAAABBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAABkAAAAAAAAAAcAAOYOAADmDgAAAAUAAOYPAADmDwAAAAMAAOYxAADmMQAAAAQAAOZYAADmWAAAAAEAAOZ1AADmdQAAAAYAAOeJAADniQAAAAcAAOvvAADr7wAAAAIAAAAAADAAigDmASIBegHKAiIAAAABAAAAAANbAscAHAAANxYyPwEXFjI2NC8BNzY0JiIPAScmIgYUHwEHBhSyEjMS9PQSMyQR9fQSJDMS9PQSMyQS9PQTHRIS9fQSJDMS9PQSMyQS9PQRJDMS9PQSMQAAAAADAAD/gAQAA4AACwAcADcAABEWABc2ADcmACcGABc0PgIyHgIUDgIiLgI3NDU/Aj4BHgEPASEyFhQGByEXFg4BIi8CBQEh2tkBIQUF/t/Z2v7fO0OAorWigENDgKK1ooBDwQIE1AkaEwEJngF2DRISDf6JnwkBExoK0gYBgNn+3wUFASHZ2gEhBQX+39pbooBDQ4CitaKAQ0OAol0BAQcI4AoBExkLqBIbEgGrCxkSCuIMAAADAAD/gAQAA4AACwAcADcAAAEGAAcWABc2ADcmABMOASIuAjQ+AjIeAhQGJzQ1LwIuAQ4BHwEhIgYUFhchBwYeATI/AgIA2v7fBQUBIdrZASEFBf7fY0CitaKAQ0OAorWigENDfQIF0woZFAEJn/6KDhISDgF3oAkBExoK0gcDgAX+39rZ/t8FBQEh2doBIfzJQENDgKK1ooBDQ4CitaL/AQEHCOAKARMZC6gSGxIBqwoaEgriDAAABQAA/4AEAAOAAAQADAAQABQAIQAAASERIRElFTM1MxUhNQMRIRkBITUhEycRIREjESERIREzFwNA/MAEAP4AQED/AIACAP4AAgDAgP2AgAEAAYBeoQOA/AADPoKAgMC//IEBAP8AAT9B/n8BAcD+QAOA/wABAKEACwAA/38EAAOAAAUACwARABcAGwAfACMAJwArAC8AMwAAEzM1BREzESMRITUjARUzFTMRAyMVIREjBSEVITUhFSElIRUhNSEVITUhFSEFIREhFzMVI03z/sBNTQFA8wJz801N8wFATf0NAoD9gAKA/YABfwEB/v8BAf7/AQH+//6BAUD+wE2mpgMzTQH+wf6A/sBNA7NN8wFA/E1NAUAUTc1Nz03GTcZN8wFATaYAAAAEAAD/swQAA00AAAANACEALQAAASMeAjI+ATcuAScOAQEjJyEHIw4BBxEeARchPgE3ES4BAS4BJz4BNx4BFw4BAgCkAStNVk0rAQJcRkZcAjyjXf7MXaMrOgEBOisDNCs6AQE6/jttkAMDkG1tkAMDkAFNLUssLEstRV0CAl0BVGdnATor/ZosOgEBOiwCZis6/WgDkG1tkAMDkG1tkAAABgAA/4ADwQOAABcAHwAnACsALwAzAAABIzUuASchDgEHFSMVMxEeARchPgE1ETMlNjchFhcVIQEGByEmJxEhBTMRIxMzESMTMxEjA8DlASke/toeKQHkPwEsHgJvHyk//aEBCgEmCgH+xAHdAQr9lwoBAn/95jw8vTw8vDw8AwA0HywBASwfNED9CB8oAQEoHwL4dAsBAQs0/MsKAQEKAvV//f8CAf3/AgH9/wAAAAAAABIA3gABAAAAAAAAABUAAAABAAAAAAABAAsAFQABAAAAAAACAAcAIAABAAAAAAADAAsAJwABAAAAAAAEAAsAMgABAAAAAAAFAAsAPQABAAAAAAAGAAsASAABAAAAAAAKACsAUwABAAAAAAALABMAfgADAAEECQAAACoAkQADAAEECQABABYAuwADAAEECQACAA4A0QADAAEECQADABYA3wADAAEECQAEABYA9QADAAEECQAFABYBCwADAAEECQAGABYBIQADAAEECQAKAFYBNwADAAEECQALACYBjQpDcmVhdGVkIGJ5IGljb25mb250CmRjcy11aS1pY29uUmVndWxhcmRjcy11aS1pY29uZGNzLXVpLWljb25WZXJzaW9uIDEuMGRjcy11aS1pY29uR2VuZXJhdGVkIGJ5IHN2ZzJ0dGYgZnJvbSBGb250ZWxsbyBwcm9qZWN0Lmh0dHA6Ly9mb250ZWxsby5jb20ACgBDAHIAZQBhAHQAZQBkACAAYgB5ACAAaQBjAG8AbgBmAG8AbgB0AAoAZABjAHMALQB1AGkALQBpAGMAbwBuAFIAZQBnAHUAbABhAHIAZABjAHMALQB1AGkALQBpAGMAbwBuAGQAYwBzAC0AdQBpAC0AaQBjAG8AbgBWAGUAcgBzAGkAbwBuACAAMQAuADAAZABjAHMALQB1AGkALQBpAGMAbwBuAEcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAAcwB2AGcAMgB0AHQAZgAgAGYAcgBvAG0AIABGAG8AbgB0AGUAbABsAG8AIABwAHIAbwBqAGUAYwB0AC4AaAB0AHQAcAA6AC8ALwBmAG8AbgB0AGUAbABsAG8ALgBjAG8AbQAAAAACAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgBAgEDAQQBBQEGAQcBCAEJAAtleGl0TXV0aXBsZQhwcmV2aW91cwRuZXh0BHNhdmUGZGV0ZWN0B2NhcHR1cmUGZGVsZXRlAAAAAA==) format("truetype"),url(data:image/svg+xml;base64,PHN2Zz48ZGVmcz48Zm9udCBpZD0iZGNzLXVpLWljb24iIGhvcml6LWFkdi14PSIxMDI0Ij48Zm9udC1mYWNlIGZvbnQtZmFtaWx5PSJkY3MtdWktaWNvbiIgZm9udC13ZWlnaHQ9IjUwMCIgdW5pdHMtcGVyLWVtPSIxMDI0IiBhc2NlbnQ9Ijg5NiIgZGVzY2VudD0iLTEyOCIvPjxnbHlwaCBnbHlwaC1uYW1lPSJleGl0TXV0aXBsZSIgdW5pY29kZT0i7pmYIiBkPSJNMTc3LjUxMiAyOS4zNDJhNjEuNTg2IDYxLjU4NiAwIDAxODcuNDMyIDBsMjQ0LjIyNyAyNDQuMjI3TDc1My4yMTUgMjkuNTI0YTYxLjU4NiA2MS41ODYgMCAwMTg3LjQzMiAwIDYxLjU4NiA2MS41ODYgMCAwMTAgODcuNDMzTDU5Ni40MjEgMzYxbDI0NC4wNDQgMjQ0LjA0NGE2MS41ODYgNjEuNTg2IDAgMDEwIDg3LjQzMyA2MS41ODYgNjEuNTg2IDAgMDEtODcuNDMzIDBMNTA5LjE3MSA0NDguMjUgMjY0Ljk0NCA2OTEuNTY1YTYxLjU4NiA2MS41ODYgMCAwMS04Ny40MzIgMCA2MS41ODYgNjEuNTg2IDAgMDEwLTg3LjQzMmwyNDQuMjI2LTI0NC4wNDUtMjQ0LjIyNi0yNDQuMDQ0Yy0yNC4wOTUtMjMuMzY0LTI0LjA5NS02Mi40MjUgMC04Ni43MDJ6IiBob3Jpei1hZHYteD0iMTAyNCIvPjxnbHlwaCBnbHlwaC1uYW1lPSJwcmV2aW91cyIgdW5pY29kZT0i7q+vIiBkPSJNMCAzODQuMjg4YzAtMjgyLjYyNSAyMjkuMTItNTExLjcxMiA1MTEuNzEyLTUxMS43MTIgMjgyLjYyNSAwIDUxMS43MTIgMjI5LjA4NyA1MTEuNzEyIDUxMS43MTJTNzk0LjMzNyA4OTYgNTExLjcxMiA4OTYgMCA2NjYuOTEzIDAgMzg0LjI4OHptNjMuOTY0IDBjMCAxMTkuNjEzIDQ2LjU2NiAyMzIuMDMgMTMxLjE1OCAzMTYuNTkgODQuNTYgODQuNTYgMTk3LjAxIDEzMS4xNTggMzE2LjU5IDEzMS4xNTggMTE5LjYxMyAwIDIzMi4wMy00Ni41NjYgMzE2LjU5LTEzMS4xNTggODQuNTYtODQuNTYgMTMxLjE1OC0xOTcuMDEgMTMxLjE1OC0zMTYuNTkgMC0xMTkuNjEzLTQ2LjU2NS0yMzIuMDMtMTMxLjE1OC0zMTYuNTktODQuNTYtODQuNTYtMTk3LjAxLTEzMS4xNTgtMzE2LjU5LTEzMS4xNTgtMTE5LjYxMyAwLTIzMi4wMyA0Ni41NjYtMzE2LjU5IDEzMS4xNTgtODQuNTkyIDg0LjU2LTEzMS4xNTggMTk3LjAxLTEzMS4xNTggMzE2LjU5em0xOTIuNjI4IDMuMTY2Yy4wMzIuMzg0LjEyOC43NjguMTYgMS4xNTEuMDk2LjY0LjE2IDEuMjQ4LjI4NyAxLjg1NS4wOTYuNDguMjI0Ljk2LjM1MiAxLjQ0bC4zODQgMS41MzUuNDggMS40MzljLjE2LjQ4LjMyLjk2LjU0MyAxLjQ0LjE5Mi40NzkuNDE2LjkyNy42MDggMS4zNzQuMjI0LjQ4LjQ0OC45Ni42NzIgMS40MDguMjI0LjQ0Ny40OC44NjMuNzM1IDEuMjc5LjI1Ni40NDguNTQ0Ljg5NS44MzIgMS4zNDNsLjg2MyAxLjI0N2MuMjg4LjQxNi42MDguODMyLjkyOCAxLjI0OC4zMi40MTUuNjcxLjgzMSAxLjA1NSAxLjIxNS4yMjQuMjU2LjQxNi41NDQuNjcyLjc2OEw0NzQuNTE3IDYyOC4zMWMxMi4xMjEgMTIuODU2IDMyLjM2NiAxMy40NjQgNDUuMjIzIDEuMzQzIDEyLjg1Ni0xMi4xMjEgMTMuNDY0LTMyLjM2NiAxLjM0My00NS4yMjNMMzYyLjU0OCA0MTYuMjA2aDM3My45NjZjMTcuNjU0IDAgMzEuOTgyLTE0LjMyOCAzMS45ODItMzEuOTgycy0xNC4zMjgtMzEuOTgyLTMxLjk4Mi0zMS45ODJIMzYxLjc4bDE1OS4zOTgtMTcxLjU4NGMxMi4wMjUtMTIuOTUyIDExLjI5LTMzLjE2NS0xLjY2My00NS4xOWEzMS44NyAzMS44NyAwIDAwLTIxLjc0OC04LjU0Yy04LjU3MSAwLTE3LjE0MiAzLjQyMy0yMy40NDMgMTAuMjAzTDI2NC45NzEgMzYyLjQ0NGE2Ljc0OCA2Ljc0OCAwIDAwLS42MDguNzM2Yy0uMzUxLjM4My0uNjcxLjc2Ny0uOTkxIDEuMTgzcy0uNjQuODMyLS45NiAxLjI4Yy0uMjg3LjM4My0uNTc1Ljc5OS0uODMxIDEuMjE1YTIwLjM0IDIwLjM0IDAgMDAtLjgzMiAxLjQwN2MtLjIyNC40MTYtLjQ4LjgzMS0uNzAzIDEuMjQ3LS4yNTYuNDgtLjQ4Ljk2LS43MDQgMS40NC0uMTkyLjQ0Ny0uNDE2Ljg5NS0uNTc2IDEuMzQzLS4xOTEuNDgtLjM4My45OTEtLjU0MyAxLjQ3LS4xNi40OC0uMzIuOTI4LS40OCAxLjQwOC0uMTYuNTEyLS4yODggMS4wMjMtLjM4NCAxLjU2Ny0uMTI4LjQ4LS4yMjQuOTI4LS4zMiAxLjQwNy0uMTI3LjU3Ni0uMTkxIDEuMTg0LS4yNTUgMS43Ni0uMDY0LjQxNS0uMTI4LjgzLS4xNiAxLjI3OWE2My40NyA2My40NyAwIDAwLS4xMjggMi40NjJjMCAuMTkyLS4wMzIuMzg0LS4wMzIuNTc2di4wNjRhMjUuNjg2IDI1LjY4NiAwIDAwLjEyOCAzLjE2NnoiIGhvcml6LWFkdi14PSIxMDI0Ii8+PGdseXBoIGdseXBoLW5hbWU9Im5leHQiIHVuaWNvZGU9Iu6YjyIgZD0iTTUxMS43MTIgODk2QzIyOS4wODcgODk2IDAgNjY2LjkxMyAwIDM4NC4yODhzMjI5LjA4Ny01MTEuNzEyIDUxMS43MTItNTExLjcxMmMyODIuNTkzIDAgNTExLjcxMiAyMjkuMDg3IDUxMS43MTIgNTExLjcxMlM3OTQuMzA1IDg5NiA1MTEuNzEyIDg5NnptMzE2LjU5LTgyOC4zMDJjLTg0LjU2LTg0LjU2LTE5Ny4wMS0xMzEuMTU4LTMxNi41OS0xMzEuMTU4LTExOS42MTMgMC0yMzIuMDMgNDYuNTY2LTMxNi41OSAxMzEuMTU4LTg0LjU2IDg0LjU2LTEzMS4xNTggMTk3LjAxLTEzMS4xNTggMzE2LjU5IDAgMTE5LjYxMyA0Ni41NjYgMjMyLjAzIDEzMS4xNTggMzE2LjU5IDg0LjU2IDg0LjU2IDE5Ny4wMSAxMzEuMTU4IDMxNi41OSAxMzEuMTU4IDExOS42MTMgMCAyMzIuMDMtNDYuNTY2IDMxNi41OS0xMzEuMTU4IDg0LjU2LTg0LjU2IDEzMS4xNTgtMTk3LjAxIDEzMS4xNTgtMzE2LjU5IDAtMTE5LjU4LTQ2LjU2NS0yMzIuMDMtMTMxLjE1OC0zMTYuNTl6bS02MS40NyAzMTkuNzU2Yy0uMDMxLjM4NC0uMTI3Ljc2OC0uMTYgMS4xNTEtLjA5NS42NC0uMTYgMS4yNDgtLjI4NyAxLjg1NS0uMDk2LjQ4LS4yMjQuOTYtLjM1MiAxLjQ0bC0uMzg0IDEuNTM1LS40OCAxLjQzOWMtLjE2LjQ4LS4zMi45Ni0uNTQzIDEuNDQtLjE5Mi40NzktLjQxNi45MjctLjYwOCAxLjM3NC0uMjI0LjQ4LS40NDcuOTYtLjY3MSAxLjQwOC0uMjI0LjQ0Ny0uNDguODYzLS43MzYgMS4yNzktLjI1Ni40NDgtLjU0NC44OTUtLjgzMSAxLjM0M2wtLjg2NCAxLjI0N2EzMS4zOCAzMS4zOCAwIDAxLS45MjcgMS4yNDhjLS4zMi40MTUtLjY3Mi44MzEtMS4wNTYgMS4yMTUtLjIyNC4yNTYtLjQxNi41NDQtLjY3Mi43NjhMNTQ4Ljk0IDYyOC4zNzVjLTEyLjEyIDEyLjg1Ni0zMi4zNjYgMTMuNDY0LTQ1LjIyMiAxLjM0My0xMi44NTctMTIuMTIxLTEzLjQ2NS0zMi4zNjYtMS4zNDQtNDUuMjIzTDY2MC45MDggNDE2LjI3SDI4Ni45NzVjLTE3LjY1NCAwLTMxLjk4Mi0xNC4zMjgtMzEuOTgyLTMxLjk4MnMxNC4zMjgtMzEuOTgyIDMxLjk4Mi0zMS45ODJoMzc0LjY2OUw1MDIuMjQ2IDE4MC43MjJjLTEyLjAyNi0xMi45NTItMTEuMjktMzMuMTY1IDEuNjYzLTQ1LjE5YTMxLjg3IDMxLjg3IDAgMDEyMS43NDctOC41NGM4LjU3MiAwIDE3LjE0MyAzLjQyMyAyMy40NDMgMTAuMjAzbDIwOS4zNTQgMjI1LjMxM2MuMjI0LjIyNC40MTYuNDguNjA4LjczNi4zNTIuMzgzLjY3Mi43NjcuOTkxIDEuMTgzcy42NC44MzIuOTYgMS4yOGMuMjg4LjM4My41NzYuNzk5LjgzMSAxLjIxNS4yODguNDQ3LjU3Ni45MjcuODMyIDEuNDA3LjIyNC40MTYuNDguODMxLjcwNCAxLjI0Ny4yNTUuNDguNDguOTYuNzAzIDEuNDQuMTkyLjQ0Ny40MTYuODk1LjU3NiAxLjM0My4xOTIuNDguMzg0Ljk5MS41NDQgMS40Ny4xNi40OC4zMi45MjguNDggMS40MDguMTYuNTEyLjI4NyAxLjAyMy4zODMgMS41NjcuMTI4LjQ4LjIyNC45MjguMzIgMS40MDcuMTI4LjU3Ni4xOTIgMS4xODQuMjU2IDEuNzYuMDY0LjQxNS4xMjguODMuMTYgMS4yNzkuMDY0LjgzMS4wOTYgMS42My4xMjggMi40NjIgMCAuMTkyLjAzMi4zODQuMDMyLjU3NnYuMDY0Yy4wMzIgMS4wMjMtLjAzMiAyLjA3OS0uMTI4IDMuMTAyeiIgaG9yaXotYWR2LXg9IjEwMjQiLz48Z2x5cGggZ2x5cGgtbmFtZT0ic2F2ZSIgdW5pY29kZT0i7pixIiBkPSJNODMyLjI4OCA4OTZIMFYtMTI4aDEwMjR2ODI5LjUwNEw4MzIuMjg4IDg5NnptLTMyMC4xOTItNjQuMDY0TDUxMiA3MDMuNzQ0aDYzLjkwNEw1NzYuMDMyIDgzMmw2NC4wNjQtLjA2NEw2NDAuMDMyIDY0MGwtMjU1Ljk2OC0uMDMyLS4wMzIgMTkxLjQ1NiAxMjguMDY0LjUxMnpNMjU2LTY0LjAzMlYxOTEuNTJoNTEyLjA2NFYtNjMuOTM2TDI1Ni02NC4wMzJ6bTUxMi4wNjQgMzE5LjAwOEwyNTYgMjU1LjI2NHY2NC4zMmw1MTIuMDY0LjI4OHYtNjQuODk2em0xOTItMzE5LjYxNmwtMTI3Ljk2OC42NzJMODMyLjAzMiAzODRoLTY0MGwuMDMyLTQ0OEg2NC4wMzJsLjE2IDg5NS41NTIgMjU1Ljg0LjI1NlY1NzYuMDMyaDM4NGwtLjA5NiAyNTUuOTA0IDkzLjk1Mi0uMTI4IDE2MS42LTE2MC40OC41NzYtNzM1Ljk2OHoiIGhvcml6LWFkdi14PSIxMDI0Ii8+PGdseXBoIGdseXBoLW5hbWU9ImRldGVjdCIgdW5pY29kZT0i7piOIiBkPSJNNzYuOCA4MTkuMkgzMjBWODk2bC0zMjAtLjY0VjU3Nmg3Ni44em0wLTYyNy4ySDB2LTMyMGgzMjB2NzYuOEg3Ni44ek03MDQgODk2di03Ni44aDI0My4yVjU3Nmg3Ni44djMyMHpNOTQ3LjItNTEuMkg3MDRWLTEyOGgzMjB2MzIwaC03Ni44ek0xOTIgMTcyLjE2aDY0MHYtNzYuOEgxOTJ6bTAgMTI3LjM2aDY0MHYtNzYuOEgxOTJ6bTM4My4wNCAxMzAuNTZIODMydi03Ni44SDU3NS4wNHptMCAxMjAuOTZIODMydi03Ni44SDU3NS4wNHptMCAxMjAuOTZIODMydi03Ni44SDU3NS4wNHpNMTkyIDM1MmgzMjB2MzIwLjMyTDE5MiA2NzJWMzUyem03Ni44IDI0My4yaDE2Ni40VjQyOC44SDI2OC44djE2Ni40eiIgaG9yaXotYWR2LXg9IjEwMjQiLz48Z2x5cGggZ2x5cGgtbmFtZT0iY2FwdHVyZSIgdW5pY29kZT0i7pm1IiBkPSJNMzQ4LjE1OTk5OTk5OTk5OTk3IDMzMi44YTE2My44NCAxNjMuODQgMCAxMTMyNy42OCAwIDE2My44NCAxNjMuODQgMCAxMS0zMjcuNjggMHpNOTIxLjYgNzQyLjRINzU5LjI5Nkw2NjUuNiA4NDQuOEgzNTguNGwtOTMuNjk2LTEwMi40SDEwMi40QzQ2LjA4IDc0Mi40IDAgNjk2LjMyIDAgNjQwVjI1LjZDMC0zMC43MiA0Ni4wOC03Ni44IDEwMi40LTc2LjhoODE5LjJjNTYuMzIgMCAxMDIuNCA0Ni4wOCAxMDIuNCAxMDIuNFY2NDBjMCA1Ni4zMi00Ni4wOCAxMDIuNC0xMDIuNCAxMDIuNHpNNTEyIDc2LjhjLTE0MS4zMTIgMC0yNTYgMTE0LjY4OC0yNTYgMjU2czExNC42ODggMjU2IDI1NiAyNTYgMjU2LTExNC42ODggMjU2LTI1Ni0xMTQuNjg4LTI1Ni0yNTYtMjU2eiIgaG9yaXotYWR2LXg9IjEwMjQiLz48Z2x5cGggZ2x5cGgtbmFtZT0iZGVsZXRlIiB1bmljb2RlPSLunokiIGQ9Ik05NjAuNDAyIDc2OC4xaC0yMjkuNzJ2NTIuMzE4YzAgMzkuNzExLTMyLjMyIDc1LjU4Mi03Mi4wMyA3NS41ODJIMzY1LjM0OGMtMzkuNzExIDAtNzIuMDMtMzUuODctNzIuMDMtNzUuNTgydi01Mi4zNUg2NC41NTh2LTY0LjQxNGg2My42NDZWLTU1Ljk3YzAtMzkuNzExIDM1LjU1LTcyLjAzIDc1LjI2Mi03Mi4wM2g2MjIuNzk2YzM5LjcxIDAgNzIuMDMgMzIuMzE5IDcyLjAzIDcyLjAzdjc1OS42MjRoNjIuNDk0bC0uMzg0IDY0LjQ0NnptLTYwNi44MjkgNTIuMzE4YzAgNi40OTYgNS4yOCAxMS43NzYgMTEuNzc2IDExLjc3Nkg2NTguNjVjNi40OTYgMCAxMS43NzYtNS4yOCAxMS43NzYtMTEuNzc2di01Mi4zNUgzNTMuNTQxdjUyLjM1ek04MzEuNDE0LTUyLjUxNGMwLTYuNDk2LTUuMjgtMTEuNzc2LTExLjc3Ni0xMS43NzZIMjAzLjQ2NmMtNi40OTYgMC0xMS43NzYgNS4yOC0xMS43NzYgMTEuNzc2djc1Ni4xNjhoNjM5LjcyNFYtNTIuNTE0em0tNTM4LjMyIDYyOS4zNTZoNjAuMjIzVjY0LjA1OGgtNjAuMjIyem0xODguNTcgMGg2MC4yMjNWNjQuMDU4aC02MC4yMjJ6bTE4OC41NCAwaDYwLjIyMVY2NC4wNThoLTYwLjIyMnoiIGhvcml6LWFkdi14PSIxMDI0Ii8+PC9mb250PjwvZGVmcz48L3N2Zz4=) format("svg")}.dcs-ui-icon{font-family:dcs-ui-icon!important;font-size:16px;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.dcs-ui-exitMutiple:before{content:"\e658"}.dcs-ui-previous:before{content:"\ebef"}.dcs-ui-next:before{content:"\e60f"}.dcs-ui-save:before{content:"\e631"}.dcs-ui-detect:before{content:"\e60e"}.dcs-ui-capture:before{content:"\e675"}.dcs-ui-delete:before{content:"\e789"}.dvs-cameraContainer,.dynamsoft-cvs-container{display:flex;flex-direction:column}.dynamsoft-cvs-container{width:100%;height:100%;min-width:100px;min-height:100px;background:#eee;position:relative;align-items:center}.dynamsoft-cvs-container>.dynamsoft-video{width:100%;height:100%}.dynamsoft-cvs-container>.dynamsoft-cvs-drawarea{width:100%;height:100%;position:absolute;left:0;top:0}.dynamsoft-cvs-container>.dynamsoft-cvs-exit{width:32px;height:32px;font-size:21px;position:absolute;top:16px;right:16px;display:flex;justify-content:center;align-items:center;background:#666;color:#fcfcfc;border-radius:50%}.dynamsoft-cvs-container>.dynamsoft-cvs-exit:hover{background:#fcfcfc;color:#666}.dynamsoft-cvs-container>.dynamsoft-resultImg{width:100%;height:100%;object-fit:contain;display:none}.camera-controlBox{background-color:#222224;width:100%;height:20%;flex:0 0 20%;order:1}.camera-controlBox .controlwrapper{width:100%;height:100%;display:flex;justify-content:center;align-items:center}.camera-controlBox .controlwrapper>.camera-main{width:60px;height:60px;flex:0 0 60px;margin:0 15%;border:1px solid #fff;border-radius:50%;color:#fff;display:flex;justify-content:center;align-items:center}.camera-controlBox .controlwrapper>.camera-main:hover{background-color:#fff;color:#222224}.camera-controlBox .controlwrapper>.camera-main>div{font-size:33px}.camera-controlBox .controlwrapper>.camera-around,.camera-controlBox .controlwrapper>.camera-left,.camera-controlBox .controlwrapper>.camera-right{display:flex;justify-content:center;align-items:center;flex-direction:column;color:#fff;width:40px;flex:0 0 40px;cursor:pointer}.camera-controlBox .controlwrapper>.camera-around>div,.camera-controlBox .controlwrapper>.camera-left>div,.camera-controlBox .controlwrapper>.camera-right>div{font-size:40px}.camera-controlBox .controlwrapper>.camera-around:hover,.camera-controlBox .controlwrapper>.camera-left:hover,.camera-controlBox .controlwrapper>.camera-right:hover{background-color:#fff;color:#222224}.camera-controlBox .controlwrapper>.camera-around{margin:0 5%;font-size:32px}.camera-controlBox .controlwrapper .camera-empty{padding:10px;width:40px;flex:0 0 40px}.camera-controlBox .controlwrapper .camera-saveEmpty{width:25%}.camera-controlBox .controlwrapper>.selectedBtn{background-color:#fff;color:#222224}.dvs-homeControl.dvs-suspend{position:absolute;bottom:0;background-color:rgba(0,0,0,.2)}.dvs-editControl{background-color:#222224;height:10%;flex:0 0 10%;z-index:2}.dvs-editControl .camera-editEmpty{width:50%} - -@media print { - body, html { - margin: 0; - padding: 0; - width: 100%; - height: 100%; - } - .image-container { - break-after: page; - position: relative; - width: 100%; - height: 100%; - display: flex; - align-items: center; - justify-content: center; - } - img { - object-fit: contain; - max-width: 100%; - max-height: 100%; - } -} - -@media screen and (min-width: 1921px) { - .dynamsoft-dwt-dialogProgress { - max-width: 380px; - width: 80% - } - - .ds-dwt-progressWrap { - padding: 22px 24px 10px 24px; - } - - .dynamsoft-finalMessage { - margin: 0 0 15px 0; - color: #3a3a3a; - font: 22px/32px Arial, sans-serif; - } - .dynamsoft-desc { - margin: 7px 0; - color: #3a3a3a; - font: 16px/26px Arial, sans-serif; - } - .dynamsoft-status { - color: #555; - font: 16px/26px Arial, sans-serif; - margin: 0 0 10px 0; - } - .dynamsoft-progressBar { - margin-bottom: 15px; - background-color: #e7e7e7; - border-radius: 20px; - } -} - -@media screen and (min-width: 2561px) { - .dynamsoft-dwt-dialogProgress { - max-width: 520px; - width: 80% - } - - .ds-dwt-progressWrap { - padding: 38px 28px 28px 28px; - } - - .dynamsoft-finalMessage { - margin: 0 0 15px 0; - color: #3a3a3a; - font: 32px/48px Arial, sans-serif; - } - .dynamsoft-desc { - margin: 7px 0; - color: #3a3a3a; - font: 20px/32px Arial, sans-serif; - } - .dynamsoft-status { - color: #555; - font: 20px/32px Arial, sans-serif; - margin: 0 0 12px 0; - } - .dynamsoft-progressBar { - margin-bottom: 30px; - background-color: #e7e7e7; - border-radius: 20px; - } -} diff --git a/samples/dwt-mrz/Resources/src/dynamsoft.webtwain.viewer.css b/samples/dwt-mrz/Resources/src/dynamsoft.webtwain.viewer.css deleted file mode 100644 index 9935695..0000000 --- a/samples/dwt-mrz/Resources/src/dynamsoft.webtwain.viewer.css +++ /dev/null @@ -1,9 +0,0 @@ -/*! 20250321141615 -* Dynamsoft JavaScript Library -* Product: Dynamic Web TWAIN -* Web Site: https://www.dynamsoft.com -* -* Copyright 2025, Dynamsoft Corporation -* Author: Dynamsoft Support Team -* Version: 19.0 -*/.dvs-root{--dvs-background-first:#2a292b;--dvs-background-second:#434246;--dvs-color-first:#fff;--dvs-color-second:#000;--dvs-border-color:#626262;--dvs-highlight-color-first:green;--dvs-shadow-first:#c5c5c5;--dvs-shadow-second:#000;--dvs-active:#505050;--dvs-aside-border:var(--dvs-background-first);--dvs-color:var(--dvs-color-first);--dvs-button-color:var(--dvs-color-first);--dvs-button-background:var(--dvs-background-first);--dvs-button-disable-color:#505050;--dvs-button-active-color:var(--dvs-active);--dvs-button-active-background:var(--dvs-background-second);--dvs-button-hover-color:var(--dvs-active);--dvs-button-active-shadow:red;--dvs-button-shadow-first:var(--dvs-shadow-first);--dvs-button-shadow-second:var(--dvs-shadow-second);--dvs-placeholder-color:#505050;--dvs-text-color:var(--dvs-color-first);--dvs-text-faded-color:#505050;--dvs-divider-color:#505050;--dvs-header-border:var(--dvs-background-second);--dvs-header-background:var(--dvs-background-first);--dvs-subheader-background:var(--dvs-background-first);--dvs-footer-background:var(--dvs-background-first);--dvs-footer-color:var(--dvs-color-first);--dvs-panel-left-background:var(--dvs-background-second);--dvs-panel-left-border:var(--dvs-background-first);--dvs-panel-right-background:var(--dvs-background-second);--dvs-panel-notes-background:var(--dvs-background-second);--dvs-input-background:var(--dvs-background-first);--dvs-tab-background:var(--dvs-background-first);--dvs-tab-item-background:var(--dvs-background-first);--dvs-tab-item-border:var(--dvs-background-second);--dvs-tab-item-active-background:var(--dvs-background-second);--dvs-tab-item-hover-background:var(--dvs-background-second);--dvs-progressbar-bar-background:var(--dvs-border-color);--dvs-progressbar-valid-bar-background:green;--dvs-progressbar-point-background:green;--dvs-progressbar-text-color:var(--dvs-color-first);--dvs-select-background:var(--dvs-background-first);--dvs-select-options-color:var(--dvs-color-first);--dvs-graphic-boxshadow:var(--dvs-background-first);--dvs-graphic-border:var(--dvs-border-color);--dvs-graphic-background:var(--dvs-background-second);--dvs-graphic-active-color:#dde6ee;--dvs-graphic-text-color:var(--dvs-color-first);--dvs-graphic-color-box-border:var(--dvs-border-color);--dvs-graphic-arrow-color:var(--dvs-color-second);--dvs-graphic-select-color:var(--dvs-color-first);--dvs-graphic-select-background:var(--dvs-background-second);--dvs-graphic-tab-active-background:var(--dvs-background-first);--dvs-graphic-tab-active-color:var(--dvs-color-first);--tree-background:var(--dvs-background-second);--tree-color:var(--dvs-color-first);--tree-item-active-color:var(--dvs-color-first);--tree-item-active-background:var(--dvs-background-first);--dvs-note-input-background:var(--dvs-background-first);--dvs-note-input-color:var(--dvs-color-first);--dvs-note-divider-background:var(--dvs-background-first);--dvs-note-border:var(--dvs-background-first);--dvs-note-select-color:var(--dvs-color-first);--dvs-note-select-background:var(--dvs-background-first);--dvs-note-highlight-color:var(--dvs-highlight-color-first);--dvs-note-text-color:var(--dvs-color-first);--dvs-note-textarea-background:var(--dvs-background-first);--dvs-note-textarea-color:var(--dvs-color-first);--dvs-note-boxshadow:var(--dvs-background-first);--dvs-note-filter-background:var(--dvs-background-first)}.dvs-viewer .dvs-viewer-middle .dvs-viewer-main{height:100%;width:100%}.dvs-viewer .dvs-thumbnail-left,.dvs-viewer .dvs-thumbnail-right{border:1px solid #000;box-sizing:border-box;height:100%}.dvs-viewer .dvs-thumbnail-bottom,.dvs-viewer .dvs-thumbnail-top{border:1px solid #000;box-sizing:border-box;width:100%}.dvs-viewer .dvs-canvas-container,.dvs-viewer .dvs-video-container{height:100%;left:0;position:absolute;top:0;width:100%}.dvs-btn,.dvs-viewer .dvs-canvas-container,.dvs-viewer .dvs-video-container{align-items:center;box-sizing:border-box;display:flex;justify-content:center}.dvs-btn{background:var(--dvs-button-background);border:none;border-radius:4px;color:var(--dvs-button-color);flex-direction:row;font-size:20px;height:32px;margin:4px;width:32px}.dvs-btn:active{background:var(--dvs-button-active-color)}.dvs-group{align-items:center;display:flex;justify-content:flex-start}.dvs-group,.dvs-main-canvas{height:100%;position:relative;width:100%}.dvs-pagination{align-items:center;color:#fff;display:flex;font-size:24px;justify-content:flex-start}.dvs-pagination .dvs-pagination-first-page,.dvs-pagination .dvs-pagination-last-page,.dvs-pagination .dvs-pagination-next-page,.dvs-pagination .dvs-pagination-prev-page{width:36px}.dvs-pagination .dvs-pagination-goto{border:0;border-radius:4px;font-size:20px;height:24px;margin:0 5px;outline:none;text-align:center;width:48px}.dvs-pagination .dvs-pagination-separator{border:1px solid #fff;height:20px;width:0}.dvs-pagination .dvs-pagination-total{margin:0 5px;max-width:48px;overflow:hidden}.dvs-pagination .dvs-btn.dvs-pagination-disable{cursor:not-allowed;opacity:.5}@font-face{font-family:dvs-pagination;src:url("data:font/woff;base64,d09GRgABAAAAAAUMAAsAAAAAB+QAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADsAAABUIIslek9TLzIAAAFEAAAARAAAAGA8F08XY21hcAAAAYgAAABnAAABoiIg0OdnbHlmAAAB8AAAARwAAAF0VZxrHWhlYWQAAAMMAAAALwAAADYhe/BGaGhlYQAAAzwAAAAcAAAAJAfeA4ZobXR4AAADWAAAAA4AAAAUFAAAAGxvY2EAAANoAAAADAAAAAwAygEWbWF4cAAAA3QAAAAeAAAAIAERACxuYW1lAAADlAAAAUAAAAJnEKM8sHBvc3QAAATUAAAAOAAAAFiC0OKkeJxjYGRgYOBiMGCwY2BycfMJYeDLSSzJY5BiYGGAAJA8MpsxJzM9kYEDxgPKsYBpDiBmg4gCACY7BUgAeJxjYGFhYJzAwMrAwNTJdIaBgaEfQjO+ZjBi5ACKMrAyM2AFAWmuKQwHnjG9cWdu+N/AwMB8hwFIMjCiKGICAGs+DK94nO2RwQ2AIBAE5wCJMZbiwxJ8SRO+LJ4XPegeWIabDJtbcjwWYAKi2EQCuzFcl1LreWTpeWLXnOVGqLGV54Ea2ukume7m7kE7/lbm19rP45uSNzbwdmscqDHaOfDfaGVAegEkSRLyAHicNc+xSsRAEADQmV2MhAS9xNNdWDUQzgRT3OUkrk2wuYBVRPBPlCsFwVL0W+zEPv0Vdtr6B7beejOEbDHszCwzb0EA/L/JT3kLMSQAPl7iVHjb6I0VHpzZKsfU24/GdD2Pqkw84TwOw0lZRu7FGLw3rTV/X7m1rbX4iPOoLCdhGLtXc20o2NZIsPn6kF7k4ie3gLTvQ/zKK4gAtmi+j7bK0mGh+NbadVjrcqHds9a4VM1UNQprrFUz4xo3FPTulbyBERyx2yPjBTI4S3lWD+7x+OBWbCGvITeZZTaYqUM53hGYAj1aQ0/t2UCHze8yI/MeJTTcxx08FnZYhycErV23GwRJcTrCpWZiIxnuOqoXRRIEXF/whzZ3WE5CeJxjYGRgYABiAaPZC+L5bb4ycLMwgMB9vTBlBP1/AwsDczCQy8HABBIFAO/CCE0AeJxjYGRgYG7438AQw8IAAkCSkQEVsAIARwsCbnicY2FgYGBBwwABBAAVAAAAAAAAADgAXACSALp4nGNgZGBgYGVQYGBiAAEQyQWEDAz/wXwGAAwfAT4AAHichZE9bsJAEIWfwZAElChKpDRpVikoEsn8lEipUKCnoAez5ke211ovSNQ5TY6QE+QI6Whzikh52EMDRbza2W/evpkdyQDusIeH8rvnLtnDJbOSK7jAo3CV+pOwT34WrqGJnnCd+qtwAy94E26yY8YOnn/FrIV3YQ+3+BCu4AafwlXqX8I++Vu4hgf8CNep/wo3MPGuhZtoeeHA6qnTczXbqVVo0sik7niO9WITT+2pPNE2X5lUdYPOURrpVNtjm3y76DkXqciaRA15q+PYqMyatQ5dsHQu67fbkehBaBIMYKExhWOcQ2GGHeMKIQxSREV0Z/mY7gU2iFlp/3VP6LbIqR9yhS4CdM5cI7rSwnk6TY4tX+tRdXQrbsuahDSUWs1JYrLiDzzcramE1AMsi6oMfbS5ohN/UMyQ/AHYk29XeJxjYGKAAC4G7ICVkYmRmZGFkZWRjYErLbOouES3IDE9lbOgKLUMwspJhInlpVZAWAwMAFaADtA=") format("woff")}.dvs-pagination-iconfont{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:dvs-pagination!important;font-size:16px;font-style:normal}.dvs-icon-first-page:before{content:"\e602"}.dvs-icon-prev-page:before{content:"\e603"}.dvs-icon-last-page:before{content:"\ec46"}.dvs-icon-next-page:before{content:"\ec47"}.dvs-root{align-items:flex-start;box-sizing:border-box;display:flex;height:100%;justify-content:flex-start;overflow:hidden;position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.dvs-root .dvs-selected{background:var(--dvs-button-active-color);box-shadow:-2px -2px 2px -1px inset var(--dvs-button-shadow-first),1px 1px 3px 0 inset var(--dvs-button-shadow-second)}.dvs-viewer .dvs-canvas-container,.dvs-viewer .dvs-scroll-container,.dvs-viewer .dvs-scroller-and-canvas,.dvs-viewer .dvs-video-container{box-sizing:border-box;height:100%;left:0;position:absolute;top:0;width:100%}.dvs-viewer{align-items:center;box-sizing:border-box;flex-direction:column;justify-content:center}.dvs-viewer,.dvs-viewer .dvs-viewer-middle{display:flex;height:100%;position:relative;width:100%}.dvs-viewer .dvs-viewer-middle{flex:1}.dvs-viewer .dvs-viewer-middle .dvs-viewer-main{display:flex;flex:1;overflow:hidden;position:relative}.dvs-viewer .dvs-canvas-container,.dvs-viewer .dvs-video-container{z-index:0}.dvs-viewer .dvs-canvas-container canvas,.dvs-viewer .dvs-video-container canvas{-webkit-tap-highlight-color:transparent;box-sizing:border-box}.dvs-viewer .dvs-canvas-container canvas:focus,.dvs-viewer .dvs-video-container canvas:focus{outline:2px solid currentColor;outline-offset:-2px}.dvs-viewer .dvs-video-container{align-items:center;display:none;justify-content:center}.dvs-viewer .dvs-video-container img{display:none}.dvs-viewer .dvs-disable-outline:focus{outline:none!important}.dvs-viewer .dvs-scroll-container{overflow:auto}.dvs-viewer .dvs-scroll-container:focus{outline:2px solid currentColor;outline-offset:-2px}.dvs-main-container{height:100%;position:relative;width:100%}.dvs-editor-iconfont{color:#fff!important;font-family:ds-dwt-ui-d-iconfont!important}.dvs-grey{color:#999!important}.dvs-grey:active{background:transparent!important}.dwt-viewer-imageEditor-header{align-items:center;display:flex;flex-direction:row;justify-content:space-between;width:100%}.dwt-viewer-imageEditor-selected{background-color:#666!important;border-radius:0;box-shadow:inset -3px -3px 2px -2px #b7aaaa,inset 2px 2px 2px 0 #000}.dwt-viewer-imageEditor-fullScreen{display:none;height:100%;left:0;position:fixed;top:0;width:100%;z-index:9999}.dvs-buttons{background:none;cursor:default;flex-basis:1.5em;height:1.5em;margin:0;width:1.5em}.dvs-buttons,.dvs-buttons-ie{font-size:1em!important}.dvs-buttons-ie{background:none;cursor:default;flex-basis:1.3em;height:1.3em;margin:0;width:1.3em}.dvs-imageEditor-mask{background:#dce2f1;height:100%;left:0;opacity:.4;position:absolute;top:0;width:100%;z-index:9998}.dvs-imageEditor-saveDlg{background:#fff;border:1px solid #ccc;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);z-index:9999}.dvs-imageEditor-saveDlg-header{height:28px;padding:10px 10px 0 0;position:relative}.dvs-imageEditor-saveDlg-box{color:#606060;font-family:OpenSans,Segoe UI,SegoeUI,Helvetica Neue,Helvetica,Arial,sans-serif;font-size:16px;line-height:26px;margin-bottom:10px;padding:15px;text-align:center}.dvs-imageEditor-saveDlg-btnGroup{display:flex;justify-content:space-between;margin:20px auto 0;white-space:nowrap;width:75%}.dvs-imageEditor-saveDlg-btnGroup input{height:30px;width:80px}.dvs-imageEditor-changeSizeBox,.dvs-imageEditor-rotateBox{background-color:#f0f0f0;border:2px solid #ce5e04;box-sizing:border-box;color:#000;font-family:OpenSans,Segoe UI,SegoeUI,Helvetica Neue,Helvetica,Arial,sans-serif;font-size:12px;font-weight:700;padding:15px;position:absolute;width:280px;z-index:9999}.dvs-imageEditor-rotateBox>div:first-child input{box-sizing:border-box;height:22px;margin-left:5px;width:155px}.dvs-imageEditor-rotateBox>div:nth-child(2){align-items:center;margin-top:10px}.dvs-imageEditor-rotateBox>div:nth-child(2) select{box-sizing:border-box;height:22px;margin-left:5px}.dvs-imageEditor-rotateBox div:nth-child(3){align-items:center;display:flex;height:22px;margin-top:8px}.dvs-imageEditor-rotateBox>div:nth-child(3) input{box-sizing:content-box;height:15px;margin:0 5px 0 0;width:15px}.dvs-imageEditor-rotateBox div:nth-child(4){margin-top:8px}.dvs-imageEditor-rotateBox>div:nth-child(4) input{box-sizing:content-box;font-size:12px;height:24px;margin-right:30px;width:60px}.dvs-imageEditor-changeSizeBox>div{align-items:center;display:flex;justify-content:space-between}.dvs-imageEditor-changeSizeBox input{box-sizing:border-box;height:22px;margin-left:5px;width:108px}.dvs-imageEditor-changeSizeBox>div:nth-child(3){margin-top:10px}.dvs-imageEditor-changeSizeBox>div:nth-child(3) select{box-sizing:border-box;height:22px;margin-right:10px}.dvs-imageEditor-changeSizeBox>div:nth-child(4){justify-content:space-around;margin-top:10px}.dvs-imageEditor-changeSizeBox>div:nth-child(4) input{font-size:12px;height:24px;width:60px}.dvs-imageEditor-pagination{font-size:16px!important}.dvs-imageEditor-pagination input{background:transparent;caret-color:"transparent";color:#fff;font-family:Microsoft YaHei;font-size:16px!important;height:21px!important;padding:0;width:24px!important}.dvs-imageEditor-pagination div{background-color:#3a393b}.dwt-viewer-imageEditor-emptyBtn{flex-basis:1em;font-size:1em;height:1em;width:1em}.dwt-viewer-imageEditor-emptyBtn:active{background-color:transparent}.dvs-customElement-full{background:#fff;height:100%!important;left:0;position:absolute;top:0;width:100%!important}.dvs-customElement-left{align-items:center;flex-direction:row-reverse}.dvs-customElement-right{align-items:center}.dvs-customElement-top{align-items:center;flex-direction:column-reverse}.dvs-customElement-bottom{align-items:center;flex-direction:column}.dvs-thbStretchBarH{cursor:e-resize;height:100%;position:absolute;width:10px}.dvs-thbStretchBarV{cursor:n-resize;height:10px;position:absolute;width:100%}.dvs-thbStretchBar-left{right:-8px;top:0}.dvs-thbStretchBar-right{left:-8px;top:0}.dvs-thbStretchBar-top{bottom:-8px;left:0}.dvs-thbStretchBar-bottom{left:0;top:-8px} \ No newline at end of file diff --git a/samples/dwt-mrz/Resources/src/dynamsoft.webtwain.viewer.js b/samples/dwt-mrz/Resources/src/dynamsoft.webtwain.viewer.js deleted file mode 100644 index 0fa3910..0000000 --- a/samples/dwt-mrz/Resources/src/dynamsoft.webtwain.viewer.js +++ /dev/null @@ -1,9 +0,0 @@ -/* ! 20250321141615 -* Dynamsoft JavaScript Library -* Product: Dynamic Web TWAIN -* Web Site: https://www.dynamsoft.com -* -* Copyright 2025, Dynamsoft Corporation -* Author: Dynamsoft Support Team -* Version: 19.0 -*/function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}!function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;}var i={},r={get exports(){return i;},set exports(e){i=e;}},n=function n(e){return e&&e.Math===Math&&e;},o=n("object"==(typeof globalThis==="undefined"?"undefined":_typeof(globalThis))&&globalThis)||n("object"==(typeof window==="undefined"?"undefined":_typeof(window))&&window)||n("object"==(typeof self==="undefined"?"undefined":_typeof(self))&&self)||n("object"==_typeof(e)&&e)||n("object"==_typeof(e)&&e)||function(){return this;}()||Function("return this")(),a=function a(e){try{return!!e();}catch(e){return!0;}},s=!a(function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype");}),u=s,l=Function.prototype,c=l.apply,h=l.call,d="object"==(typeof Reflect==="undefined"?"undefined":_typeof(Reflect))&&Reflect.apply||(u?h.bind(c):function(){return h.apply(c,arguments);}),f=s,v=Function.prototype,g=v.call,m=f&&v.bind.bind(g,g),y=f?m:function(e){return function(){return g.apply(e,arguments);};},p=y,w=p({}.toString),b=p("".slice),k=function k(e){return b(w(e),8,-1);},S=k,x=y,C=function C(e){if("Function"===S(e))return x(e);},V="object"==(typeof document==="undefined"?"undefined":_typeof(document))&&document.all,T=void 0===V&&void 0!==V?function(e){return"function"==typeof e||e===V;}:function(e){return"function"==typeof e;},I={},E=!a(function(){return 7!==Object.defineProperty({},1,{get:function get(){return 7;}})[1];}),P=s,B=Function.prototype.call,D=P?B.bind(B):function(){return B.apply(B,arguments);},M={},z={}.propertyIsEnumerable,A=Object.getOwnPropertyDescriptor,U=A&&!z.call({1:2},1);M.f=U?function(e){var t=A(this,e);return!!t&&t.enumerable;}:z;var R,L,N=function N(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t};},O=a,W=k,H=Object,F=y("".split),j=O(function(){return!H("z").propertyIsEnumerable(0);})?function(e){return"String"===W(e)?F(e,""):H(e);}:H,Y=function Y(e){return null==e;},X=Y,q=TypeError,Z=function Z(e){if(X(e))throw new q("Can't call method on "+e);return e;},_=j,G=Z,K=function K(e){return _(G(e));},$=T,J=function J(e){return"object"==_typeof(e)?null!==e:$(e);},Q={},ee=Q,te=o,ie=T,re=function re(e){return ie(e)?e:void 0;},ne=function ne(e,t){return arguments.length<2?re(ee[e])||re(te[e]):ee[e]&&ee[e][t]||te[e]&&te[e][t];},oe=y({}.isPrototypeOf),ae=o.navigator,se=ae&&ae.userAgent,ue=se?String(se):"",le=o,ce=ue,he=le.process,de=le.Deno,fe=he&&he.versions||de&&de.version,ve=fe&&fe.v8;ve&&(L=(R=ve.split("."))[0]>0&&R[0]<4?1:+(R[0]+R[1])),!L&&ce&&(!(R=ce.match(/Edge\/(\d+)/))||R[1]>=74)&&(R=ce.match(/Chrome\/(\d+)/))&&(L=+R[1]);var ge=L,me=ge,ye=a,pe=o.String,we=!!Object.getOwnPropertySymbols&&!ye(function(){var e=Symbol("symbol detection");return!pe(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&me&&me<41;}),be=we&&!Symbol.sham&&"symbol"==_typeof(Symbol.iterator),ke=ne,Se=T,xe=oe,Ce=Object,Ve=be?function(e){return"symbol"==_typeof(e);}:function(e){var t=ke("Symbol");return Se(t)&&xe(t.prototype,Ce(e));},Te=String,Ie=function Ie(e){try{return Te(e);}catch(e){return"Object";}},Ee=T,Pe=Ie,Be=TypeError,De=function De(e){if(Ee(e))return e;throw new Be(Pe(e)+" is not a function");},Me=De,ze=Y,Ae=function Ae(e,t){var i=e[t];return ze(i)?void 0:Me(i);},Ue=D,Re=T,Le=J,Ne=TypeError,Oe={},We={get exports(){return Oe;},set exports(e){Oe=e;}},He=!0,Fe=o,je=Object.defineProperty,Ye=o,Xe=function Xe(e,t){try{je(Fe,e,{value:t,configurable:!0,writable:!0});}catch(i){Fe[e]=t;}return t;},qe="__core-js_shared__",Ze=We.exports=Ye[qe]||Xe(qe,{});(Ze.versions||(Ze.versions=[])).push({version:"3.41.0",mode:"pure",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.41.0/LICENSE",source:"https://github.com/zloirock/core-js"});var _e=Oe,Ge=function Ge(e,t){return _e[e]||(_e[e]=t||{});},Ke=Z,$e=Object,Je=function Je(e){return $e(Ke(e));},Qe=Je,et=y({}.hasOwnProperty),tt=Object.hasOwn||function(e,t){return et(Qe(e),t);},it=y,rt=0,nt=Math.random(),ot=it(1..toString),at=function at(e){return"Symbol("+(void 0===e?"":e)+")_"+ot(++rt+nt,36);},st=Ge,ut=tt,lt=at,ct=we,ht=be,dt=o.Symbol,ft=st("wks"),vt=ht?dt.for||dt:dt&&dt.withoutSetter||lt,gt=function gt(e){return ut(ft,e)||(ft[e]=ct&&ut(dt,e)?dt[e]:vt("Symbol."+e)),ft[e];},mt=D,yt=J,pt=Ve,wt=Ae,bt=function bt(e,t){var i,r;if("string"===t&&Re(i=e.toString)&&!Le(r=Ue(i,e)))return r;if(Re(i=e.valueOf)&&!Le(r=Ue(i,e)))return r;if("string"!==t&&Re(i=e.toString)&&!Le(r=Ue(i,e)))return r;throw new Ne("Can't convert object to primitive value");},kt=TypeError,St=gt("toPrimitive"),xt=function xt(e,t){if(!yt(e)||pt(e))return e;var i,r=wt(e,St);if(r){if(void 0===t&&(t="default"),i=mt(r,e,t),!yt(i)||pt(i))return i;throw new kt("Can't convert object to primitive value");}return void 0===t&&(t="number"),bt(e,t);},Ct=xt,Vt=Ve,Tt=function Tt(e){var t=Ct(e,"string");return Vt(t)?t:t+"";},It=J,Et=o.document,Pt=It(Et)&&It(Et.createElement),Bt=function Bt(e){return Pt?Et.createElement(e):{};},Dt=Bt,Mt=!E&&!a(function(){return 7!==Object.defineProperty(Dt("div"),"a",{get:function get(){return 7;}}).a;}),zt=E,At=D,Ut=M,Rt=N,Lt=K,Nt=Tt,Ot=tt,Wt=Mt,Ht=Object.getOwnPropertyDescriptor;I.f=zt?Ht:function(e,t){if(e=Lt(e),t=Nt(t),Wt)try{return Ht(e,t);}catch(e){}if(Ot(e,t))return Rt(!At(Ut.f,e,t),e[t]);};var Ft=a,jt=T,Yt=/#|\.prototype\./,Xt=function Xt(e,t){var i=Zt[qt(e)];return i===Gt||i!==_t&&(jt(t)?Ft(t):!!t);},qt=Xt.normalize=function(e){return String(e).replace(Yt,".").toLowerCase();},Zt=Xt.data={},_t=Xt.NATIVE="N",Gt=Xt.POLYFILL="P",Kt=Xt,$t=De,Jt=s,Qt=C(C.bind),ei=function ei(e,t){return $t(e),void 0===t?e:Jt?Qt(e,t):function(){return e.apply(t,arguments);};},ti={},ii=E&&a(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype;}),ri=J,ni=String,oi=TypeError,ai=function ai(e){if(ri(e))return e;throw new oi(ni(e)+" is not an object");},si=E,ui=Mt,li=ii,ci=ai,hi=Tt,di=TypeError,fi=Object.defineProperty,vi=Object.getOwnPropertyDescriptor,gi="enumerable",mi="configurable",yi="writable";ti.f=si?li?function(e,t,i){if(ci(e),t=hi(t),ci(i),"function"==typeof e&&"prototype"===t&&"value"in i&&yi in i&&!i[yi]){var r=vi(e,t);r&&r[yi]&&(e[t]=i.value,i={configurable:mi in i?i[mi]:r[mi],enumerable:gi in i?i[gi]:r[gi],writable:!1});}return fi(e,t,i);}:fi:function(e,t,i){if(ci(e),t=hi(t),ci(i),ui)try{return fi(e,t,i);}catch(e){}if("get"in i||"set"in i)throw new di("Accessors not supported");return"value"in i&&(e[t]=i.value),e;};var pi=ti,wi=N,bi=E?function(e,t,i){return pi.f(e,t,wi(1,i));}:function(e,t,i){return e[t]=i,e;},ki=o,Si=d,xi=C,Ci=T,Vi=I.f,Ti=Kt,Ii=Q,Ei=ei,Pi=bi,Bi=tt,Di=function Di(e){var _t2=function t(i,r,n){if(this instanceof _t2){switch(arguments.length){case 0:return new e();case 1:return new e(i);case 2:return new e(i,r);}return new e(i,r,n);}return Si(e,this,arguments);};return _t2.prototype=e.prototype,_t2;},Mi=function Mi(e,t){var i,r,n,o,a,s,u,l,c,h=e.target,d=e.global,f=e.stat,v=e.proto,g=d?ki:f?ki[h]:ki[h]&&ki[h].prototype,m=d?Ii:Ii[h]||Pi(Ii,h,{})[h],y=m.prototype;for(o in t)r=!(i=Ti(d?o:h+(f?".":"#")+o,e.forced))&&g&&Bi(g,o),s=m[o],r&&(u=e.dontCallGetSet?(c=Vi(g,o))&&c.value:g[o]),a=r&&u?u:t[o],(i||v||_typeof(s)!=_typeof(a))&&(l=e.bind&&r?Ei(a,ki):e.wrap&&r?Di(a):v&&Ci(a)?xi(a):a,(e.sham||a&&a.sham||s&&s.sham)&&Pi(l,"sham",!0),Pi(m,o,l),v&&(Bi(Ii,n=h+"Prototype")||Pi(Ii,n,{}),Pi(Ii[n],o,a),e.real&&y&&(i||!y[o])&&Pi(y,o,a)));},zi=y([].slice),Ai=y,Ui=De,Ri=J,Li=tt,Ni=zi,Oi=s,Wi=Function,Hi=Ai([].concat),Fi=Ai([].join),ji={},Yi=Oi?Wi.bind:function(e){var t=Ui(this),i=t.prototype,r=Ni(arguments,1),_n2=function n(){var i=Hi(r,Ni(arguments));return this instanceof _n2?function(e,t,i){if(!Li(ji,t)){for(var r=[],n=0;n0?xr:Sr)(t);},Vr=Cr,Tr=function Tr(e){var t=+e;return t!=t||0===t?0:Vr(t);},Ir=Tr,Er=Math.max,Pr=Math.min,Br=function Br(e,t){var i=Ir(e);return i<0?Er(i+t,0):Pr(i,t);},Dr=Tr,Mr=Math.min,zr=function zr(e){var t=Dr(e);return t>0?Mr(t,9007199254740991):0;},Ar=zr,Ur=function Ur(e){return Ar(e.length);},Rr=K,Lr=Br,Nr=Ur,Or=function Or(e){return function(t,i,r){var n=Rr(t),o=Nr(n);if(0===o)return!e&&-1;var a,s=Lr(r,o);if(e&&i!=i){for(;o>s;)if((a=n[s++])!=a)return!0;}else for(;o>s;s++)if((e||s in n)&&n[s]===i)return e||s||0;return!e&&-1;};},Wr={includes:Or(!0),indexOf:Or(!1)},Hr={},Fr=tt,jr=K,Yr=Wr.indexOf,Xr=Hr,qr=y([].push),Zr=function Zr(e,t){var i,r=jr(e),n=0,o=[];for(i in r)!Fr(Xr,i)&&Fr(r,i)&&qr(o,i);for(;t.length>n;)Fr(r,i=t[n++])&&(~Yr(o,i)||qr(o,i));return o;},_r=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Gr=Zr,Kr=_r,$r=Object.keys||function(e){return Gr(e,Kr);},Jr=E,Qr=ii,en=ti,tn=ai,rn=K,nn=$r;kr.f=Jr&&!Qr?Object.defineProperties:function(e,t){tn(e);for(var i,r=rn(t),n=nn(t),o=n.length,a=0;o>a;)en.f(e,i=n[a++],r[i]);return e;};var on,an=ne("document","documentElement"),sn=at,un=Ge("keys"),ln=function ln(e){return un[e]||(un[e]=sn(e));},cn=ai,hn=kr,dn=_r,fn=Hr,vn=an,gn=Bt,mn="prototype",yn="script",pn=ln("IE_PROTO"),wn=function wn(){},bn=function bn(e){return"<"+yn+">"+e+"";},kn=function kn(e){e.write(bn("")),e.close();var t=e.parentWindow.Object;return e=null,t;},_Sn=function Sn(){try{on=new ActiveXObject("htmlfile");}catch(e){}var e,t,i;_Sn="undefined"!=typeof document?document.domain&&on?kn(on):(t=gn("iframe"),i="java"+yn+":",t.style.display="none",vn.appendChild(t),t.src=String(i),(e=t.contentWindow.document).open(),e.write(bn("document.F=Object")),e.close(),e.F):kn(on);for(var r=dn.length;r--;)delete _Sn[mn][dn[r]];return _Sn();};fn[pn]=!0;var xn=Object.create||function(e,t){var i;return null!==e?(wn[mn]=cn(e),i=new wn(),wn[mn]=null,i[pn]=e):i=_Sn(),void 0===t?i:hn.f(i,t);},Cn=Mi,Vn=d,Tn=Yi,In=br,En=ai,Pn=J,Bn=xn,Dn=a,Mn=ne("Reflect","construct"),zn=Object.prototype,An=[].push,Un=Dn(function(){function e(){}return!(Mn(function(){},[],e)instanceof e);}),Rn=!Dn(function(){Mn(function(){});}),Ln=Un||Rn;Cn({target:"Reflect",stat:!0,forced:Ln,sham:Ln},{construct:function construct(e,t){In(e),En(t);var i=arguments.length<3?e:In(arguments[2]);if(Rn&&!Un)return Mn(e,t,i);if(e===i){switch(t.length){case 0:return new e();case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);}var r=[null];return Vn(An,r,t),new(Vn(Tn,e,r))();}var n=i.prototype,o=Bn(Pn(n)?n:zn),a=Vn(e,o,t);return Pn(a)?a:o;}});var Nn=Q.Reflect.construct;r.exports=Nn;var On=t(i),Wn={},Hn={get exports(){return Wn;},set exports(e){Wn=e;}},Fn={},jn={get exports(){return Fn;},set exports(e){Fn=e;}},Yn=k,Xn=Array.isArray||function(e){return"Array"===Yn(e);},qn=TypeError,Zn=function Zn(e){if(e>9007199254740991)throw qn("Maximum allowed index exceeded");return e;},_n=E,Gn=ti,Kn=N,$n=function $n(e,t,i){_n?Gn.f(e,t,Kn(0,i)):e[t]=i;},Jn=Xn,Qn=mr,eo=J,to=gt("species"),io=Array,ro=function ro(e){var t;return Jn(e)&&(t=e.constructor,(Qn(t)&&(t===io||Jn(t.prototype))||eo(t)&&null===(t=t[to]))&&(t=void 0)),void 0===t?io:t;},no=function no(e,t){return new(ro(e))(0===t?0:t);},oo=a,ao=ge,so=gt("species"),uo=function uo(e){return ao>=51||!oo(function(){var t=[];return(t.constructor={})[so]=function(){return{foo:1};},1!==t[e](Boolean).foo;});},lo=Mi,co=a,ho=Xn,fo=J,vo=Je,go=Ur,mo=Zn,yo=$n,po=no,wo=uo,bo=ge,ko=gt("isConcatSpreadable"),So=bo>=51||!co(function(){var e=[];return e[ko]=!1,e.concat()[0]!==e;}),xo=function xo(e){if(!fo(e))return!1;var t=e[ko];return void 0!==t?!!t:ho(e);};lo({target:"Array",proto:!0,arity:1,forced:!So||!wo("concat")},{concat:function concat(e){var t,i,r,n,o,a=vo(this),s=po(a,0),u=0;for(t=-1,r=arguments.length;tp;p++)if((s||p in g)&&(f=y(d=g[p],p,v),e))if(t)b[p]=f;else if(f)switch(e){case 3:return!0;case 5:return d;case 6:return p;case 2:Ma(b,d);}else switch(e){case 4:return!1;case 7:Ma(b,d);}return o?-1:r||n?n:b;};},Aa={forEach:za(0),map:za(1),filter:za(2),some:za(3),every:za(4),find:za(5),findIndex:za(6),filterReject:za(7)},Ua=Mi,Ra=o,La=D,Na=y,Oa=E,Wa=we,Ha=a,Fa=tt,ja=oe,Ya=ai,Xa=K,qa=Tt,Za=To,_a=N,Ga=xn,Ka=$r,$a=Io,Ja=Bo,Qa=Ro,es=I,ts=ti,is=kr,rs=M,ns=No,os=Wo,as=Ge,ss=Hr,us=at,ls=gt,cs=Ho,hs=Ko,ds=ta,fs=ca,vs=Ta,gs=Aa.forEach,ms=ln("hidden"),ys="Symbol",ps="prototype",ws=vs.set,bs=vs.getterFor(ys),ks=Object[ps],Ss=Ra.Symbol,xs=Ss&&Ss[ps],Cs=Ra.RangeError,Vs=Ra.TypeError,Ts=Ra.QObject,Is=es.f,Es=ts.f,Ps=Ja.f,Bs=rs.f,Ds=Na([].push),Ms=as("symbols"),zs=as("op-symbols"),As=as("wks"),Us=!Ts||!Ts[ps]||!Ts[ps].findChild,Rs=function Rs(e,t,i){var r=Is(ks,t);r&&delete ks[t],Es(e,t,i),r&&e!==ks&&Es(ks,t,r);},Ls=Oa&&Ha(function(){return 7!==Ga(Es({},"a",{get:function get(){return Es(this,"a",{value:7}).a;}})).a;})?Rs:Es,Ns=function Ns(e,t){var i=Ms[e]=Ga(xs);return ws(i,{type:ys,tag:e,description:t}),Oa||(i.description=t),i;},_Os=function Os(e,t,i){e===ks&&_Os(zs,t,i),Ya(e);var r=qa(t);return Ya(i),Fa(Ms,r)?(i.enumerable?(Fa(e,ms)&&e[ms][r]&&(e[ms][r]=!1),i=Ga(i,{enumerable:_a(0,!1)})):(Fa(e,ms)||Es(e,ms,_a(1,Ga(null))),e[ms][r]=!0),Ls(e,r,i)):Es(e,r,i);},Ws=function Ws(e,t){Ya(e);var i=Xa(t),r=Ka(i).concat(Ys(i));return gs(r,function(t){Oa&&!La(Hs,i,t)||_Os(e,t,i[t]);}),e;},Hs=function Hs(e){var t=qa(e),i=La(Bs,this,t);return!(this===ks&&Fa(Ms,t)&&!Fa(zs,t))&&(!(i||!Fa(this,t)||!Fa(Ms,t)||Fa(this,ms)&&this[ms][t])||i);},Fs=function Fs(e,t){var i=Xa(e),r=qa(t);if(i!==ks||!Fa(Ms,r)||Fa(zs,r)){var n=Is(i,r);return!n||!Fa(Ms,r)||Fa(i,ms)&&i[ms][r]||(n.enumerable=!0),n;}},js=function js(e){var t=Ps(Xa(e)),i=[];return gs(t,function(e){Fa(Ms,e)||Fa(ss,e)||Ds(i,e);}),i;},Ys=function Ys(e){var t=e===ks,i=Ps(t?zs:Xa(e)),r=[];return gs(i,function(e){!Fa(Ms,e)||t&&!Fa(ks,e)||Ds(r,Ms[e]);}),r;};Wa||(Ss=function Ss(){if(ja(xs,this))throw new Vs("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Za(arguments[0]):void 0,t=us(e),_i2=function i(e){var r=void 0===this?Ra:this;r===ks&&La(_i2,zs,e),Fa(r,ms)&&Fa(r[ms],t)&&(r[ms][t]=!1);var n=_a(1,e);try{Ls(r,t,n);}catch(e){if(!(e instanceof Cs))throw e;Rs(r,t,n);}};return Oa&&Us&&Ls(ks,t,{configurable:!0,set:_i2}),Ns(t,e);},ns(xs=Ss[ps],"toString",function(){return bs(this).tag;}),ns(Ss,"withoutSetter",function(e){return Ns(us(e),e);}),rs.f=Hs,ts.f=_Os,is.f=Ws,es.f=Fs,$a.f=Ja.f=js,Qa.f=Ys,cs.f=function(e){return Ns(ls(e),e);},Oa&&os(xs,"description",{configurable:!0,get:function get(){return bs(this).description;}})),Ua({global:!0,constructor:!0,wrap:!0,forced:!Wa,sham:!Wa},{Symbol:Ss}),gs(Ka(As),function(e){hs(e);}),Ua({target:ys,stat:!0,forced:!Wa},{useSetter:function useSetter(){Us=!0;},useSimple:function useSimple(){Us=!1;}}),Ua({target:"Object",stat:!0,forced:!Wa,sham:!Oa},{create:function create(e,t){return void 0===t?Ga(e):Ws(Ga(e),t);},defineProperty:_Os,defineProperties:Ws,getOwnPropertyDescriptor:Fs}),Ua({target:"Object",stat:!0,forced:!Wa},{getOwnPropertyNames:js}),ds(),fs(Ss,ys),ss[ms]=!0;var Xs=we&&!!Symbol.for&&!!Symbol.keyFor,qs=Mi,Zs=ne,_s=tt,Gs=To,Ks=Ge,$s=Xs,Js=Ks("string-to-symbol-registry"),Qs=Ks("symbol-to-string-registry");qs({target:"Symbol",stat:!0,forced:!$s},{for:function _for(e){var t=Gs(e);if(_s(Js,t))return Js[t];var i=Zs("Symbol")(t);return Js[t]=i,Qs[i]=t,i;}});var eu=Mi,tu=tt,iu=Ve,ru=Ie,nu=Xs,ou=Ge("symbol-to-string-registry");eu({target:"Symbol",stat:!0,forced:!nu},{keyFor:function keyFor(e){if(!iu(e))throw new TypeError(ru(e)+" is not a symbol");if(tu(ou,e))return ou[e];}});var au=Xn,su=T,uu=k,lu=To,cu=y([].push),hu=Mi,du=ne,fu=d,vu=D,gu=y,mu=a,yu=T,pu=Ve,wu=zi,bu=function bu(e){if(su(e))return e;if(au(e)){for(var t=e.length,i=[],r=0;r=t.length)return e.target=null,nc(void 0,!0);switch(e.kind){case"keys":return nc(i,!1);case"values":return nc(t[i],!1);}return nc([i,t[i]],!1);},"values");tc.Arguments=tc.Array;ec(),ec(),ec();var uc={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},lc=o,cc=ca,hc=Xu;for(var dc in uc)cc(lc[dc],dc),hc[dc]=hc.Array;var fc=Yu,vc=gt,gc=ti.f,mc=vc("metadata"),yc=Function.prototype;void 0===yc[mc]&&gc(yc,mc,{value:null}),Ko("asyncDispose"),Ko("dispose"),Ko("metadata");var pc=fc,wc=y,bc=ne("Symbol"),kc=bc.keyFor,Sc=wc(bc.prototype.valueOf),xc=bc.isRegisteredSymbol||function(e){try{return void 0!==kc(Sc(e));}catch(e){return!1;}};Mi({target:"Symbol",stat:!0},{isRegisteredSymbol:xc});for(var Cc=Ge,Vc=ne,Tc=y,Ic=Ve,Ec=gt,Pc=Vc("Symbol"),Bc=Pc.isWellKnownSymbol,Dc=Vc("Object","getOwnPropertyNames"),Mc=Tc(Pc.prototype.valueOf),zc=Cc("wks"),Ac=0,Uc=Dc(Pc),Rc=Uc.length;Ac=s?e?"":void 0:(r=Kc(o,a))<55296||r>56319||a+1===s||(n=Kc(o,a+1))<56320||n>57343?e?Gc(o,a):r:e?$c(o,a,a+2):n-56320+(r-55296<<10)+65536;};},Qc={codeAt:Jc(!1),charAt:Jc(!0)},eh=Qc.charAt,th=To,ih=Ta,rh=$l,nh=Jl,oh="String Iterator",ah=ih.set,sh=ih.getterFor(oh);rh(String,"String",function(e){ah(this,{type:oh,string:th(e),index:0});},function(){var e,t=sh(this),i=t.string,r=t.index;return r>=i.length?nh(void 0,!0):(e=eh(i,r),t.index+=e.length,nh(e,!1));});var uh=Ho.f("iterator");!function(e){e.exports=uh;}(Yc),function(e){e.exports=jc;}(Fc);var lh=t(Hc);function ch(e){return ch="function"==typeof Wc&&"symbol"==_typeof(lh)?function(e){return _typeof(e);}:function(e){return e&&"function"==typeof Wc&&e.constructor===Wc&&e!==Wc.prototype?"symbol":_typeof(e);},ch(e);}var hh={},dh={get exports(){return hh;},set exports(e){hh=e;}},fh={},vh={get exports(){return fh;},set exports(e){fh=e;}};Mi({target:"Array",stat:!0},{isArray:Xn});var gh=Q.Array.isArray,mh=gh;!function(e){e.exports=mh;}(vh),function(e){e.exports=fh;}(dh);var yh=t(hh);function ph(e){if(yh(e))return e;}var wh={},bh={get exports(){return wh;},set exports(e){wh=e;}},kh={},Sh={get exports(){return kh;},set exports(e){kh=e;}},xh=Qi,Ch=Ae,Vh=Y,Th=Xu,Ih=gt("iterator"),Eh=function Eh(e){if(!Vh(e))return Ch(e,Ih)||Ch(e,"@@iterator")||Th[xh(e)];},Ph=Eh;!function(e){e.exports=Ph;}(Sh),function(e){e.exports=kh;}(bh);var Bh=t(wh),Dh={},Mh={get exports(){return Dh;},set exports(e){Dh=e;}},zh={},Ah={get exports(){return zh;},set exports(e){zh=e;}},Uh=D,Rh=ai,Lh=Ae,Nh=function Nh(e,t,i){var r,n;Rh(e);try{if(!(r=Lh(e,"return"))){if("throw"===t)throw i;return i;}r=Uh(r,e);}catch(e){n=!0,r=e;}if("throw"===t)throw i;if(n)throw r;return Rh(r),i;},Oh=ai,Wh=Nh,Hh=Xu,Fh=gt("iterator"),jh=Array.prototype,Yh=function Yh(e){return void 0!==e&&(Hh.Array===e||jh[Fh]===e);},Xh=D,qh=De,Zh=ai,_h=Ie,Gh=Eh,Kh=TypeError,$h=function $h(e,t){var i=arguments.length<2?Gh(e):t;if(qh(i))return Zh(Xh(i,e));throw new Kh(_h(e)+" is not iterable");},Jh=ei,Qh=D,ed=Je,td=function td(e,t,i,r){try{return r?t(Oh(i)[0],i[1]):t(i);}catch(t){Wh(e,"throw",t);}},id=Yh,rd=mr,nd=Ur,od=$n,ad=$h,sd=Eh,ud=Array,ld=function ld(e){var t=ed(e),i=rd(this),r=arguments.length,n=r>1?arguments[1]:void 0,o=void 0!==n;o&&(n=Jh(n,r>2?arguments[2]:void 0));var a,s,u,l,c,h,d=sd(t),f=0;if(!d||this===ud&&id(d))for(a=nd(t),s=i?new this(a):ud(a);a>f;f++)h=o?n(t[f],f):t[f],od(s,f,h);else for(s=i?new this():[],c=(l=ad(t,d)).next;!(u=Qh(c,l)).done;f++)h=o?td(l,n,[u.value,f],!0):u.value,od(s,f,h);return s.length=f,s;},cd=gt("iterator"),hd=!1;try{var dd=0,fd={next:function next(){return{done:!!dd++};},return:function _return(){hd=!0;}};fd[cd]=function(){return this;},Array.from(fd,function(){throw 2;});}catch(e){}var vd=function vd(e,t){try{if(!t&&!hd)return!1;}catch(e){return!1;}var i=!1;try{var r={};r[cd]=function(){return{next:function next(){return{done:i=!0};}};},e(r);}catch(e){}return i;},gd=ld;Mi({target:"Array",stat:!0,forced:!vd(function(e){Array.from(e);})},{from:gd});var md=Q.Array.from,yd=md;!function(e){e.exports=yd;}(Ah),function(e){e.exports=zh;}(Mh);var pd=t(Dh);function wd(e){if(void 0!==Wc&&null!=Bh(e)||null!=e["@@iterator"])return pd(e);}var bd={},kd={get exports(){return bd;},set exports(e){bd=e;}},Sd={},xd={get exports(){return Sd;},set exports(e){Sd=e;}},Cd=Mi,Vd=Xn,Td=mr,Id=J,Ed=Br,Pd=Ur,Bd=K,Dd=$n,Md=gt,zd=zi,Ad=uo("slice"),Ud=Md("species"),Rd=Array,Ld=Math.max;Cd({target:"Array",proto:!0,forced:!Ad},{slice:function slice(e,t){var i,r,n,o=Bd(this),a=Pd(o),s=Ed(e,a),u=Ed(void 0===t?a:t,a);if(Vd(o)&&(i=o.constructor,(Td(i)&&(i===Rd||Vd(i.prototype))||Id(i)&&null===(i=i[Ud]))&&(i=void 0),i===Rd||void 0===i))return zd(o,s,u);for(r=new(void 0===i?Rd:i)(Ld(u-s,0)),n=0;se.length)&&(t=e.length);for(var i=0,r=new Array(t);i1?arguments[1]:void 0;return gf?vf(this,e,t)||0:df(this,e,t);}});var mf=Wd("Array","indexOf"),yf=oe,pf=mf,wf=Array.prototype,bf=function bf(e){var t=e.indexOf;return e===wf||yf(wf,e)&&t===wf.indexOf?pf:t;},kf=bf,Sf=kf;!function(e){e.exports=Sf;}(uf),function(e){e.exports=sf;}(af);var xf=t(of),Cf={},Vf={get exports(){return Cf;},set exports(e){Cf=e;}},Tf={},If={get exports(){return Tf;},set exports(e){Tf=e;}},Ef=Je,Pf=$r;Mi({target:"Object",stat:!0,forced:a(function(){Pf(1);})},{keys:function keys(e){return Pf(Ef(e));}});var Bf=Q.Object.keys,Df=Bf;!function(e){e.exports=Df;}(If),function(e){e.exports=Tf;}(Vf);var Mf=t(Cf);function zf(e,t){if(null==e)return{};var i,r,n=function(e,t){if(null==e)return{};var i,r,n={},o=Mf(e);for(r=0;r=0||(n[i]=e[i]);return n;}(e,t);if(nf){var o=nf(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i]);}return n;}var Af={},Uf={get exports(){return Af;},set exports(e){Af=e;}},Rf={},Lf={get exports(){return Rf;},set exports(e){Rf=e;}},Nf=Yi;Mi({target:"Function",proto:!0,forced:Function.bind!==Nf},{bind:Nf});var Of=Wd("Function","bind"),Wf=oe,Hf=Of,Ff=Function.prototype,jf=function jf(e){var t=e.bind;return e===Ff||Wf(Ff,e)&&t===Ff.bind?Hf:t;},Yf=jf,Xf=Yf;!function(e){e.exports=Xf;}(Lf),function(e){e.exports=Rf;}(Uf);var qf=t(Af),Zf={},_f={get exports(){return Zf;},set exports(e){Zf=e;}},Gf={},Kf={get exports(){return Gf;},set exports(e){Gf=e;}},$f=Nn;!function(e){e.exports=$f;}(Kf),function(e){e.exports=Gf;}(_f);var Jf=t(Zf),Qf={},ev={get exports(){return Qf;},set exports(e){Qf=e;}},tv={},iv={get exports(){return tv;},set exports(e){tv=e;}};Mi({target:"Object",stat:!0},{setPrototypeOf:Al});var rv=Q.Object.setPrototypeOf;!function(e){e.exports=rv;}(iv),function(e){e.exports=tv;}(ev);var nv=t(Qf);function ov(e,t){var i;return ov=nv?qf(i=nv).call(i):function(e,t){return e.__proto__=t,e;},ov(e,t);}function av(){if("undefined"==typeof Reflect||!Jf)return!1;if(Jf.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Jf(Boolean,[],function(){})),!0;}catch(e){return!1;}}function sv(e,t,i){var r;av()?sv=qf(r=Jf).call(r):sv=function sv(e,t,i){var r=[null];r.push.apply(r,t);var n=new(qf(Function).apply(e,r))();return i&&ov(n,i.prototype),n;};return sv.apply(null,arguments);}var uv={},lv={get exports(){return uv;},set exports(e){uv=e;}},cv={},hv={get exports(){return cv;},set exports(e){cv=e;}},dv={},fv={get exports(){return dv;},set exports(e){dv=e;}},vv=Mi,gv=E,mv=ti.f;vv({target:"Object",stat:!0,forced:Object.defineProperty!==mv,sham:!gv},{defineProperty:mv});var yv=Q.Object,pv=fv.exports=function(e,t,i){return yv.defineProperty(e,t,i);};yv.defineProperty.sham&&(pv.sham=!0);var wv=dv,bv=wv;!function(e){e.exports=bv;}(hv),function(e){e.exports=cv;}(lv);var kv=t(uv),Sv={},xv={get exports(){return Sv;},set exports(e){Sv=e;}},Cv={},Vv={get exports(){return Cv;},set exports(e){Cv=e;}};Mi({target:"Object",stat:!0,sham:!E},{create:xn});var Tv=Q.Object,Iv=function Iv(e,t){return Tv.create(e,t);},Ev=Iv;!function(e){e.exports=Ev;}(Vv),function(e){e.exports=Cv;}(xv);var Pv=t(Sv),Bv={},Dv={get exports(){return Bv;},set exports(e){Bv=e;}},Mv={},zv={get exports(){return Mv;},set exports(e){Mv=e;}},Av=Je,Uv=al,Rv=Ju;Mi({target:"Object",stat:!0,forced:a(function(){Uv(1);}),sham:!Rv},{getPrototypeOf:function getPrototypeOf(e){return Uv(Av(e));}});var Lv=Q.Object.getPrototypeOf;!function(e){e.exports=Lv;}(zv),function(e){e.exports=Mv;}(Dv);var Nv=t(Bv),Ov={},Wv={get exports(){return Ov;},set exports(e){Ov=e;}},Hv={},Fv={get exports(){return Hv;},set exports(e){Hv=e;}},jv=Aa.forEach,Yv=cf("forEach")?[].forEach:function(e){return jv(this,e,arguments.length>1?arguments[1]:void 0);};Mi({target:"Array",proto:!0,forced:[].forEach!==Yv},{forEach:Yv});var Xv=Wd("Array","forEach"),qv=Qi,Zv=tt,_v=oe,Gv=Xv,Kv=Array.prototype,$v={DOMTokenList:!0,NodeList:!0},Jv=function Jv(e){var t=e.forEach;return e===Kv||_v(Kv,e)&&t===Kv.forEach||Zv($v,qv(e))?Gv:t;},Qv=Jv;!function(e){e.exports=Qv;}(Fv),function(e){e.exports=Hv;}(Wv);var eg=t(Ov),tg={},ig={get exports(){return tg;},set exports(e){tg=e;}},rg={},ng={get exports(){return rg;},set exports(e){rg=e;}},og=ne,ag=Io,sg=Ro,ug=ai,lg=y([].concat),cg=og("Reflect","ownKeys")||function(e){var t=ag.f(ug(e)),i=sg.f;return i?lg(t,i(e)):t;},hg=tt,dg=cg,fg=I,vg=ti,gg=J,mg=bi,yg=Error,pg=y("".replace),wg=String(new yg("zxcasd").stack),bg=/\n\s*at [^:]*:[^\n]*/,kg=bg.test(wg),Sg=N,xg=!a(function(){var e=new Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Sg(1,7)),7!==e.stack);}),Cg=bi,Vg=function Vg(e,t){if(kg&&"string"==typeof e&&!yg.prepareStackTrace)for(;t--;)e=pg(e,bg,"");return e;},Tg=xg,Ig=Error.captureStackTrace,Eg=ei,Pg=D,Bg=ai,Dg=Ie,Mg=Yh,zg=Ur,Ag=oe,Ug=$h,Rg=Eh,Lg=Nh,Ng=TypeError,Og=function Og(e,t){this.stopped=e,this.result=t;},Wg=Og.prototype,Hg=function Hg(e,t,i){var r,n,o,a,s,u,l,c=i&&i.that,h=!(!i||!i.AS_ENTRIES),d=!(!i||!i.IS_RECORD),f=!(!i||!i.IS_ITERATOR),v=!(!i||!i.INTERRUPTED),g=Eg(t,c),m=function m(e){return r&&Lg(r,"normal",e),new Og(!0,e);},y=function y(e){return h?(Bg(e),v?g(e[0],e[1],m):g(e[0],e[1])):v?g(e,m):g(e);};if(d)r=e.iterator;else if(f)r=e;else{if(!(n=Rg(e)))throw new Ng(Dg(e)+" is not iterable");if(Mg(n)){for(o=0,a=zg(e);a>o;o++)if((s=y(e[o]))&&Ag(Wg,s))return s;return new Og(!1);}r=Ug(e,n);}for(u=d?e.next:r.next;!(l=Pg(u,r)).done;){try{s=y(l.value);}catch(e){Lg(r,"throw",e);}if("object"==_typeof(s)&&s&&Ag(Wg,s))return s;}return new Og(!1);},Fg=To,jg=Mi,Yg=oe,Xg=al,qg=Al,Zg=function Zg(e,t,i){for(var r=dg(t),n=vg.f,o=fg.f,a=0;a2&&$g(i,arguments[2]);var n=[];return Qg(e,rm,{that:n}),Gg(i,"errors",n),i;};qg?qg(_nm,im):Zg(_nm,im,{name:!0});var om=_nm.prototype=_g(im.prototype,{constructor:Kg(1,_nm),message:Kg(1,""),name:Kg(1,"AggregateError")});jg({global:!0,constructor:!0,arity:2},{AggregateError:_nm});var am,sm,um,lm,cm=o,hm=ue,dm=k,fm=function fm(e){return hm.slice(0,e.length)===e;},vm=fm("Bun/")?"BUN":fm("Cloudflare-Workers")?"CLOUDFLARE":fm("Deno/")?"DENO":fm("Node.js/")?"NODE":cm.Bun&&"string"==typeof Bun.version?"BUN":cm.Deno&&"object"==_typeof(Deno.version)?"DENO":"process"===dm(cm.process)?"NODE":cm.window&&cm.document?"BROWSER":"REST",gm="NODE"===vm,mm=ne,ym=Wo,pm=E,wm=gt("species"),bm=function bm(e){var t=mm(e);pm&&t&&!t[wm]&&ym(t,wm,{configurable:!0,get:function get(){return this;}});},km=oe,Sm=TypeError,xm=function xm(e,t){if(km(t,e))return e;throw new Sm("Incorrect invocation");},Cm=ai,Vm=br,Tm=Y,Im=gt("species"),Em=function Em(e,t){var i,r=Cm(e).constructor;return void 0===r||Tm(i=Cm(r)[Im])?t:Vm(i);},Pm=TypeError,Bm=function Bm(e,t){if(e1?Aw(arguments,1):[],i=Uw.f(this),r=Lw(function(){return zw(Rw(e),void 0,t);});return(r.error?i.reject:i.resolve)(r.value),i.promise;}});var Ww=$y;Mi({target:"Promise",stat:!0},{withResolvers:function withResolvers(){var e=Ww.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject};}});var Hw=Mi,Fw=Ry,jw=a,Yw=ne,Xw=T,qw=Em,Zw=fw,_w=Fw&&Fw.prototype;Hw({target:"Promise",proto:!0,real:!0,forced:!!Fw&&jw(function(){_w.finally.call({then:function then(){}},function(){});})},{finally:function _finally(e){var t=qw(this,Yw("Promise")),i=Xw(e);return this.then(i?function(i){return Zw(t,e()).then(function(){return i;});}:e,i?function(i){return Zw(t,e()).then(function(){throw i;});}:e);}});var Gw=Q.Promise,Kw=Gw;!function(e){e.exports=Kw;}(ng),function(e){e.exports=rg;}(ig);var $w=t(tg),Jw={},Qw={get exports(){return Jw;},set exports(e){Jw=e;}},eb={},tb={get exports(){return eb;},set exports(e){eb=e;}},ib=Mi,rb=Xn,nb=y([].reverse),ob=[1,2];ib({target:"Array",proto:!0,forced:String(ob)===String(ob.reverse())},{reverse:function reverse(){return rb(this)&&(this.length=this.length),nb(this);}});var ab=Wd("Array","reverse"),sb=oe,ub=ab,lb=Array.prototype,cb=function cb(e){var t=e.reverse;return e===lb||sb(lb,e)&&t===lb.reverse?ub:t;},hb=cb,db=hb;!function(e){e.exports=db;}(tb),function(e){e.exports=eb;}(Qw);var fb=t(Jw);function vb(){vb=function vb(){return e;};var e={},t=Object.prototype,i=t.hasOwnProperty,r=kv||function(e,t,i){e[t]=i.value;},n="function"==typeof Wc?Wc:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function u(e,t,i){return kv(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t];}try{u({},"");}catch(e){u=function u(e,t,i){return e[t]=i;};}function l(e,t,i,n){var o=t&&t.prototype instanceof d?t:d,a=Pv(o.prototype),s=new C(n||[]);return r(a,"_invoke",{value:b(e,i,s)}),a;}function c(e,t,i){try{return{type:"normal",arg:e.call(t,i)};}catch(e){return{type:"throw",arg:e};}}e.wrap=l;var h={};function d(){}function f(){}function v(){}var g={};u(g,o,function(){return this;});var m=Nv&&Nv(Nv(V([])));m&&m!==t&&i.call(m,o)&&(g=m);var y=v.prototype=d.prototype=Pv(g);function p(e){var t;eg(t=["next","throw","return"]).call(t,function(t){u(e,t,function(e){return this._invoke(t,e);});});}function w(e,t){function n(r,o,a,s){var u=c(e[r],e,o);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==ch(h)&&i.call(h,"__await")?t.resolve(h.__await).then(function(e){n("next",e,a,s);},function(e){n("throw",e,a,s);}):t.resolve(h).then(function(e){l.value=e,a(l);},function(e){return n("throw",e,a,s);});}s(u.arg);}var o;r(this,"_invoke",{value:function value(e,i){function r(){return new t(function(t,r){n(e,i,t,r);});}return o=o?o.then(r,r):r();}});}function b(e,t,i){var r="suspendedStart";return function(n,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===n)throw o;return T();}for(i.method=n,i.arg=o;;){var a=i.delegate;if(a){var s=k(a,i);if(s){if(s===h)continue;return s;}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if("suspendedStart"===r)throw r="completed",i.arg;i.dispatchException(i.arg);}else"return"===i.method&&i.abrupt("return",i.arg);r="executing";var u=c(e,t,i);if("normal"===u.type){if(r=i.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:i.done};}"throw"===u.type&&(r="completed",i.method="throw",i.arg=u.arg);}};}function k(e,t){var i=t.method,r=e.iterator[i];if(void 0===r)return t.delegate=null,"throw"===i&&e.iterator.return&&(t.method="return",t.arg=void 0,k(e,t),"throw"===t.method)||"return"!==i&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+i+"' method")),h;var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,h;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h);}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t);}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t;}function C(e){this.tryEntries=[{tryLoc:"root"}],eg(e).call(e,S,this),this.reset(!0);}function V(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r=0;--n){var o=this.tryEntries[n],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=i.call(o,"catchLoc"),u=i.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),x(i),h;}},catch:function _catch(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var r=i.completion;if("throw"===r.type){var n=r.arg;x(i);}return n;}}throw new Error("illegal catch attempt");},delegateYield:function delegateYield(e,t,i){return this.delegate={iterator:V(e),resultName:t,nextLoc:i},"next"===this.method&&(this.arg=void 0),h;}},e;}function gb(e,t,i,r,n,o,a){try{var s=e[o](a),u=s.value;}catch(e){return void i(e);}s.done?t(u):$w.resolve(u).then(r,n);}function mb(e){return function(){var t=this,i=arguments;return new $w(function(r,n){var o=e.apply(t,i);function a(e){gb(o,r,n,a,s,"next",e);}function s(e){gb(o,r,n,a,s,"throw",e);}a(void 0);});};}function yb(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function pb(e){var t;return pb=nv?qf(t=Nv).call(t):function(e){return e.__proto__||Nv(e);},pb(e);}var wb={},bb={get exports(){return wb;},set exports(e){wb=e;}},kb={},Sb={get exports(){return kb;},set exports(e){kb=e;}},xb=tt,Cb=D,Vb=J,Tb=ai,Ib=function Ib(e){return void 0!==e&&(xb(e,"value")||xb(e,"writable"));},Eb=I,Pb=al;Mi({target:"Reflect",stat:!0},{get:function e(t,i){var r,n,o=arguments.length<3?t:arguments[2];return Tb(t)===o?t[i]:(r=Eb.f(t,i))?Ib(r)?r.value:void 0===r.get?void 0:Cb(r.get,o):Vb(n=Pb(t))?e(n,i,o):void 0;}});var Bb=Q.Reflect.get;!function(e){e.exports=Bb;}(Sb),function(e){e.exports=kb;}(bb);var Db=t(wb),Mb={},zb={get exports(){return Mb;},set exports(e){Mb=e;}},Ab={},Ub={get exports(){return Ab;},set exports(e){Ab=e;}},Rb={},Lb={get exports(){return Rb;},set exports(e){Rb=e;}},Nb=Mi,Ob=a,Wb=K,Hb=I.f,Fb=E;Nb({target:"Object",stat:!0,forced:!Fb||Ob(function(){Hb(1);}),sham:!Fb},{getOwnPropertyDescriptor:function getOwnPropertyDescriptor(e,t){return Hb(Wb(e),t);}});var jb=Q.Object,Yb=Lb.exports=function(e,t){return jb.getOwnPropertyDescriptor(e,t);};jb.getOwnPropertyDescriptor.sham&&(Yb.sham=!0);var Xb=Rb;!function(e){e.exports=Xb;}(Ub),function(e){e.exports=Ab;}(zb);var qb=t(Mb);function Zb(){var e;"undefined"!=typeof Reflect&&Db?Zb=qf(e=Db).call(e):Zb=function Zb(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=pb(e)););return e;}(e,t);if(r){var n=qb(r,t);return n.get?n.get.call(arguments.length<3?e:i):n.value;}};return Zb.apply(this,arguments);}function _b(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Pv(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),kv(e,"prototype",{writable:!1}),t&&ov(e,t);}function Gb(e,t){return ph(e)||function(e,t){var i=null==e?null:void 0!==Wc&&Bh(e)||e["@@iterator"];if(null!=i){var r,n,o,a,s=[],u=!0,l=!1;try{if(o=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;u=!1;}else for(;!(u=(r=o.call(i)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){l=!0,n=e;}finally{try{if(!u&&null!=i.return&&(a=i.return(),Object(a)!==a))return;}finally{if(l)throw n;}}return s;}}(e,t)||Kd(e,t)||$d();}function Kb(e){return function(e){if(yh(e))return Gd(e);}(e)||wd(e)||Kd(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}();}var $b={},Jb={get exports(){return $b;},set exports(e){$b=e;}},Qb={},ek={get exports(){return Qb;},set exports(e){Qb=e;}},tk=Aa.filter;Mi({target:"Array",proto:!0,forced:!uo("filter")},{filter:function filter(e){return tk(this,e,arguments.length>1?arguments[1]:void 0);}});var ik=Wd("Array","filter"),rk=oe,nk=ik,ok=Array.prototype,ak=function ak(e){var t=e.filter;return e===ok||rk(ok,e)&&t===ok.filter?nk:t;},sk=ak,uk=sk;!function(e){e.exports=uk;}(ek),function(e){e.exports=Qb;}(Jb);var lk=t($b),ck={},hk={get exports(){return ck;},set exports(e){ck=e;}},dk={},fk={get exports(){return dk;},set exports(e){dk=e;}},vk=cg,gk=K,mk=I,yk=$n;Mi({target:"Object",stat:!0,sham:!E},{getOwnPropertyDescriptors:function getOwnPropertyDescriptors(e){for(var t,i,r=gk(e),n=mk.f,o=vk(r),a={},s=0;o.length>s;)void 0!==(i=n(r,t=o[s++]))&&yk(a,t,i);return a;}});var pk=Q.Object.getOwnPropertyDescriptors;!function(e){e.exports=pk;}(fk),function(e){e.exports=dk;}(hk);var wk=t(ck),bk={},kk={get exports(){return bk;},set exports(e){bk=e;}},Sk={},xk={get exports(){return Sk;},set exports(e){Sk=e;}},Ck={},Vk={get exports(){return Ck;},set exports(e){Ck=e;}},Tk=Mi,Ik=E,Ek=kr.f;Tk({target:"Object",stat:!0,forced:Object.defineProperties!==Ek,sham:!Ik},{defineProperties:Ek});var Pk=Q.Object,Bk=Vk.exports=function(e,t){return Pk.defineProperties(e,t);};Pk.defineProperties.sham&&(Bk.sham=!0);var Dk=Ck;!function(e){e.exports=Dk;}(xk),function(e){e.exports=Sk;}(kk);var Mk=t(bk),zk={},Ak={get exports(){return zk;},set exports(e){zk=e;}},Uk={},Rk={get exports(){return Uk;},set exports(e){Uk=e;}},Lk=Ho.f("toPrimitive");!function(e){e.exports=Lk;}(Rk),function(e){e.exports=Uk;}(Ak);var Nk=t(zk);function Ok(e){var t=function(e,t){if("object"!==ch(e)||null===e)return e;var i=e[Nk];if(void 0!==i){var r=i.call(e,t||"default");if("object"!==ch(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===t?String:Number)(e);}(e,"string");return"symbol"===ch(t)?t:String(t);}function Wk(e,t,i){return(t=Ok(t))in e?kv(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e;}function Hk(e,t){var i=Mf(e);if(nf){var r=nf(e);t&&(r=lk(r).call(r,function(t){return qb(e,t).enumerable;})),i.push.apply(i,r);}return i;}function Fk(e){for(var t=1;t>>0||(_S(ZS,i)?16:10));}:YS;Mi({global:!0,forced:parseInt!==GS},{parseInt:GS});var KS=Q.parseInt;!function(e){e.exports=KS;}(LS);var $S=t(RS),JS={},QS={get exports(){return JS;},set exports(e){JS=e;}},ex=De,tx=Je,ix=j,rx=Ur,nx=TypeError,ox="Reduce of empty array with no initial value",ax=function ax(e){return function(t,i,r,n){var o=tx(t),a=ix(o),s=rx(o);if(ex(i),0===s&&r<2)throw new nx(ox);var u=e?s-1:0,l=e?-1:1;if(r<2)for(;;){if(u in a){n=a[u],u+=l;break;}if(u+=l,e?u<0:s<=u)throw new nx(ox);}for(;e?u>=0:s>u;u+=l)u in a&&(n=i(n,a[u],u,o));return n;};},sx={left:ax(!1),right:ax(!0)}.left;Mi({target:"Array",proto:!0,forced:!gm&&ge>79&&ge<83||!cf("reduce")},{reduce:function reduce(e){var t=arguments.length;return sx(this,e,t,t>1?arguments[1]:void 0);}});var ux=Wd("Array","reduce"),lx=oe,cx=ux,hx=Array.prototype,dx=function dx(e){var t=e.reduce;return e===hx||lx(hx,e)&&t===hx.reduce?cx:t;},fx=dx;!function(e){e.exports=fx;}(QS);var vx=t(JS),gx={},mx={get exports(){return gx;},set exports(e){gx=e;}};!function(e){e.exports=sk;}(mx);var yx=t(gx),px={},wx={get exports(){return px;},set exports(e){px=e;}},bx=Mi,kx=y,Sx=Br,xx=RangeError,Cx=String.fromCharCode,Vx=String.fromCodePoint,Tx=kx([].join);bx({target:"String",stat:!0,arity:1,forced:!!Vx&&1!==Vx.length},{fromCodePoint:function fromCodePoint(e){for(var t,i=[],r=arguments.length,n=0;r>n;){if(t=+arguments[n++],Sx(t,1114111)!==t)throw new xx(t+" is not a valid code point");i[n]=t<65536?Cx(t):Cx(55296+((t-=65536)>>10),t%1024+56320);}return Tx(i,"");}});var Ix=a,Ex=He,Px=gt("iterator"),Bx=!Ix(function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,i=new URLSearchParams("a=1&a=2&b=3"),r="";return e.pathname="c%20d",t.forEach(function(e,i){t.delete("b"),r+=i+e;}),i.delete("a",2),i.delete("b",void 0),!e.toJSON||!i.has("a",1)||i.has("a",2)||!i.has("a",void 0)||i.has("b")||!t.size&&Ex||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[Px]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==r||"x"!==new URL("https://x",void 0).host;}),Dx=No,Mx=function Mx(e,t,i){for(var r in t)i&&i.unsafe&&e[r]?e[r]=t[r]:Dx(e,r,t[r],i);return e;},zx=zi,Ax=Math.floor,_Ux=function Ux(e,t){var i=e.length;if(i<8)for(var r,n,o=1;o0;)e[n]=e[--n];n!==o++&&(e[n]=r);}else for(var a=Ax(i/2),s=_Ux(zx(e,0,a),t),u=_Ux(zx(e,a),t),l=s.length,c=u.length,h=0,d=0;h0&&e&i;i>>=1)t++;return t;},HC=function HC(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3];}return t>1114111?null:t;},FC=function FC(e){for(var t=(e=DC(e,LC," ")).length,i="",r=0;rt){i+="%",r++;continue;}var o=OC(e,r+1);if(o!=o){i+=n,r++;continue;}r+=2;var a=WC(o);if(0===a)n=VC(o);else{if(1===a||a>4){i+="�",r++;continue;}for(var s=[o],u=1;ut||"%"!==EC(e,r));){var l=OC(e,r+1);if(l!=l){r+=3;break;}if(l>191||l<128)break;BC(s,l),r+=2,u++;}if(s.length!==a){i+="�";continue;}var c=HC(s);null===c?i+="�":n=TC(c);}}i+=n,r++;}return i;},jC=/[!'()~]|%20/g,YC={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},XC=function XC(e){return YC[e];},qC=function qC(e){return DC(CC(e),jC,XC);},ZC=Gx(function(e,t){gC(this,{type:vC,target:mC(e).entries,index:0,kind:t});},fC,function(){var e=yC(this),t=e.target,i=e.index++;if(!t||i>=t.length)return e.target=null,lC(void 0,!0);var r=t[i];switch(e.kind){case"keys":return lC(r.key,!1);case"values":return lC(r.value,!1);}return lC([r.key,r.value],!1);},!0),_C=function _C(e){this.entries=[],this.url=null,void 0!==e&&(rC(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===EC(e,0)?UC(e,1):e:nC(e)));};_C.prototype={type:fC,bindURL:function bindURL(e){this.url=e,this.update();},parseObject:function parseObject(e){var t,i,r,n,o,a,s,u=this.entries,l=uC(e);if(l)for(i=(t=sC(e,l)).next;!(r=Hx(i,t)).done;){if(o=(n=sC(iC(r.value))).next,(a=Hx(o,n)).done||(s=Hx(o,n)).done||!Hx(o,n).done)throw new xC("Expected sequence with length 2");BC(u,{key:nC(a.value),value:nC(s.value)});}else for(var c in e)Qx(e,c)&&BC(u,{key:c,value:nC(e[c])});},parseQuery:function parseQuery(e){if(e)for(var t,i,r=this.entries,n=AC(e,"&"),o=0;o0?arguments[0]:void 0));jx||(this.size=e.entries.length);},KC=GC.prototype;if(Zx(KC,{append:function append(e,t){var i=mC(this);cC(arguments.length,2),BC(i.entries,{key:nC(e),value:nC(t)}),jx||this.length++,i.updateURL();},delete:function _delete(e){for(var t=mC(this),i=cC(arguments.length,1),r=t.entries,n=nC(e),o=i<2?void 0:arguments[1],a=void 0===o?o:nC(o),s=0;st.key?1:-1;}),e.updateURL();},forEach:function forEach(e){for(var t,i=mC(this).entries,r=eC(e,arguments.length>1?arguments[1]:void 0),n=0;n1?QC(arguments[1]):{});}}),Jx(wC)){var eV=function eV(e){return $x(this,kC),new wC(e,arguments.length>1?QC(arguments[1]):{});};kC.constructor=eV,eV.prototype=kC,Lx({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:eV});}}var tV,iV={URLSearchParams:GC,getState:mC},rV=E,nV=y,oV=D,aV=a,sV=$r,uV=Ro,lV=M,cV=Je,hV=j,dV=Object.assign,fV=Object.defineProperty,vV=nV([].concat),gV=!dV||aV(function(){if(rV&&1!==dV({b:1},dV(fV({},"a",{enumerable:!0,get:function get(){fV(this,"b",{value:3,enumerable:!1});}}),{b:2})).b)return!0;var e={},t={},i=Symbol("assign detection"),r="abcdefghijklmnopqrst";return e[i]=7,r.split("").forEach(function(e){t[e]=e;}),7!==dV({},e)[i]||sV(dV({},t)).join("")!==r;})?function(e,t){for(var i=cV(e),r=arguments.length,n=1,o=uV.f,a=lV.f;r>n;)for(var s,u=hV(arguments[n++]),l=o?vV(sV(u),o(u)):sV(u),c=l.length,h=0;c>h;)s=l[h++],rV&&!oV(a,u,s)||(i[s]=u[s]);return i;}:dV,mV=y,yV=2147483647,pV=/[^\0-\u007E]/,wV=/[.\u3002\uFF0E\uFF61]/g,bV="Overflow: input needs wider integers to process",kV=RangeError,SV=mV(wV.exec),xV=Math.floor,CV=String.fromCharCode,VV=mV("".charCodeAt),TV=mV([].join),IV=mV([].push),EV=mV("".replace),PV=mV("".split),BV=mV("".toLowerCase),DV=function DV(e){return e+22+75*(e<26);},MV=function MV(e,t,i){var r=0;for(e=i?xV(e/700):e>>1,e+=xV(e/t);e>455;)e=xV(e/35),r+=36;return xV(r+36*e/(e+38));},zV=function zV(e){var t=[];e=function(e){for(var t=[],i=0,r=e.length;i=55296&&n<=56319&&i=o&&rxV((yV-a)/h))throw new kV(bV);for(a+=(c-o)*h,o=c,i=0;iyV)throw new kV(bV);if(r===o){for(var d=a,f=36;;){var v=f<=s?1:f>=s+26?26:f-s;if(d?@[\\\]^|]/,MT=/[\0\t\n\r #/:<>?@[\\\]^|]/,zT=/^[\u0000-\u0020]+/,AT=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,UT=/[\t\n\r]/g,RT=function RT(e){var t,i,r,n;if("number"==typeof e){for(t=[],i=0;i<4;i++)bT(t,e%256),e=sT(e/256);return hT(t,".");}if("object"==_typeof(e)){for(t="",r=function(e){for(var t=null,i=1,r=null,n=0,o=0;o<8;o++)0!==e[o]?(n>i&&(t=r,i=n),r=null,n=0):(null===r&&(r=o),++n);return n>i?r:t;}(e),i=0;i<8;i++)n&&0===e[i]||(n&&(n=!1),r===i?(t+=i?":":"::",n=!0):(t+=dT(e[i],16),i<7&&(t+=":")));return"["+t+"]";}return e;},LT={},NT=YV({},LT,{" ":1,'"':1,"<":1,">":1,"`":1}),OT=YV({},NT,{"#":1,"?":1,"{":1,"}":1}),WT=YV({},OT,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),HT=function HT(e,t){var i=ZV(e,0);return i>32&&i<127&&!jV(t,e)?e:encodeURIComponent(e);},FT={ftp:21,file:null,http:80,https:443,ws:80,wss:443},jT=function jT(e,t){var i;return 2===e.length&&cT(CT,lT(e,0))&&(":"===(i=lT(e,1))||!t&&"|"===i);},YT=function YT(e){var t;return e.length>1&&jT(pT(e,0,2))&&(2===e.length||"/"===(t=lT(e,2))||"\\"===t||"?"===t||"#"===t);},XT=function XT(e){return"."===e||"%2e"===wT(e);},qT={},ZT={},_T={},GT={},KT={},$T={},JT={},QT={},eI={},tI={},iI={},rI={},nI={},oI={},aI={},sI={},uI={},lI={},cI={},hI={},dI={},_fI=function fI(e,t,i){var r,n,o,a=GV(e);if(t){if(n=this.parse(a))throw new oT(n);this.searchParams=null;}else{if(void 0!==i&&(r=new _fI(i,!0)),n=this.parse(a,null,r))throw new oT(n);(o=rT(new iT())).bindURL(this),this.searchParams=o;}};_fI.prototype={type:"URL",parse:function parse(e,t,i){var r,n,o,a,s,u=this,l=t||qT,c=0,h="",d=!1,f=!1,v=!1;for(e=GV(e),t||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,e=gT(e,zT,""),e=gT(e,AT,"$1")),e=gT(e,UT,""),r=XV(e);c<=r.length;){switch(n=r[c],l){case qT:if(!n||!cT(CT,n)){if(t)return kT;l=_T;continue;}h+=wT(n),l=ZT;break;case ZT:if(n&&(cT(VT,n)||"+"===n||"-"===n||"."===n))h+=wT(n);else{if(":"!==n){if(t)return kT;h="",l=_T,c=0;continue;}if(t&&(u.isSpecial()!==jV(FT,h)||"file"===h&&(u.includesCredentials()||null!==u.port)||"file"===u.scheme&&!u.host))return;if(u.scheme=h,t)return void(u.isSpecial()&&FT[u.scheme]===u.port&&(u.port=null));h="","file"===u.scheme?l=oI:u.isSpecial()&&i&&i.scheme===u.scheme?l=GT:u.isSpecial()?l=QT:"/"===r[c+1]?(l=KT,c++):(u.cannotBeABaseURL=!0,vT(u.path,""),l=cI);}break;case _T:if(!i||i.cannotBeABaseURL&&"#"!==n)return kT;if(i.cannotBeABaseURL&&"#"===n){u.scheme=i.scheme,u.path=qV(i.path),u.query=i.query,u.fragment="",u.cannotBeABaseURL=!0,l=dI;break;}l="file"===i.scheme?oI:$T;continue;case GT:if("/"!==n||"/"!==r[c+1]){l=$T;continue;}l=eI,c++;break;case KT:if("/"===n){l=tI;break;}l=lI;continue;case $T:if(u.scheme=i.scheme,n===tV)u.username=i.username,u.password=i.password,u.host=i.host,u.port=i.port,u.path=qV(i.path),u.query=i.query;else if("/"===n||"\\"===n&&u.isSpecial())l=JT;else if("?"===n)u.username=i.username,u.password=i.password,u.host=i.host,u.port=i.port,u.path=qV(i.path),u.query="",l=hI;else{if("#"!==n){u.username=i.username,u.password=i.password,u.host=i.host,u.port=i.port,u.path=qV(i.path),u.path.length--,l=lI;continue;}u.username=i.username,u.password=i.password,u.host=i.host,u.port=i.port,u.path=qV(i.path),u.query=i.query,u.fragment="",l=dI;}break;case JT:if(!u.isSpecial()||"/"!==n&&"\\"!==n){if("/"!==n){u.username=i.username,u.password=i.password,u.host=i.host,u.port=i.port,l=lI;continue;}l=tI;}else l=eI;break;case QT:if(l=eI,"/"!==n||"/"!==lT(h,c+1))continue;c++;break;case eI:if("/"!==n&&"\\"!==n){l=tI;continue;}break;case tI:if("@"===n){d&&(h="%40"+h),d=!0,o=XV(h);for(var g=0;g65535)return xT;u.port=u.isSpecial()&&p===FT[u.scheme]?null:p,h="";}if(t)return;l=uI;continue;}return xT;}h+=n;break;case oI:if(u.scheme="file","/"===n||"\\"===n)l=aI;else{if(!i||"file"!==i.scheme){l=lI;continue;}switch(n){case tV:u.host=i.host,u.path=qV(i.path),u.query=i.query;break;case"?":u.host=i.host,u.path=qV(i.path),u.query="",l=hI;break;case"#":u.host=i.host,u.path=qV(i.path),u.query=i.query,u.fragment="",l=dI;break;default:YT(hT(qV(r,c),""))||(u.host=i.host,u.path=qV(i.path),u.shortenPath()),l=lI;continue;}}break;case aI:if("/"===n||"\\"===n){l=sI;break;}i&&"file"===i.scheme&&!YT(hT(qV(r,c),""))&&(jT(i.path[0],!0)?vT(u.path,i.path[0]):u.host=i.host),l=lI;continue;case sI:if(n===tV||"/"===n||"\\"===n||"?"===n||"#"===n){if(!t&&jT(h))l=lI;else if(""===h){if(u.host="",t)return;l=uI;}else{if(a=u.parseHost(h))return a;if("localhost"===u.host&&(u.host=""),t)return;h="",l=uI;}continue;}h+=n;break;case uI:if(u.isSpecial()){if(l=lI,"/"!==n&&"\\"!==n)continue;}else if(t||"?"!==n){if(t||"#"!==n){if(n!==tV&&(l=lI,"/"!==n))continue;}else u.fragment="",l=dI;}else u.query="",l=hI;break;case lI:if(n===tV||"/"===n||"\\"===n&&u.isSpecial()||!t&&("?"===n||"#"===n)){if(".."===(s=wT(s=h))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(u.shortenPath(),"/"===n||"\\"===n&&u.isSpecial()||vT(u.path,"")):XT(h)?"/"===n||"\\"===n&&u.isSpecial()||vT(u.path,""):("file"===u.scheme&&!u.path.length&&jT(h)&&(u.host&&(u.host=""),h=lT(h,0)+":"),vT(u.path,h)),h="","file"===u.scheme&&(n===tV||"?"===n||"#"===n))for(;u.path.length>1&&""===u.path[0];)mT(u.path);"?"===n?(u.query="",l=hI):"#"===n&&(u.fragment="",l=dI);}else h+=HT(n,OT);break;case cI:"?"===n?(u.query="",l=hI):"#"===n?(u.fragment="",l=dI):n!==tV&&(u.path[0]+=HT(n,LT));break;case hI:t||"#"!==n?n!==tV&&("'"===n&&u.isSpecial()?u.query+="%27":u.query+="#"===n?"%23":HT(n,LT)):(u.fragment="",l=dI);break;case dI:n!==tV&&(u.fragment+=HT(n,NT));}c++;}},parseHost:function parseHost(e){var t,i,r;if("["===lT(e,0)){if("]"!==lT(e,e.length-1))return ST;if(t=function(e){var t,i,r,n,o,a,s,u=[0,0,0,0,0,0,0,0],l=0,c=null,h=0,d=function d(){return lT(e,h);};if(":"===d()){if(":"!==lT(e,1))return;h+=2,c=++l;}for(;d();){if(8===l)return;if(":"!==d()){for(t=i=0;i<4&&cT(BT,d());)t=16*t+aT(d(),16),h++,i++;if("."===d()){if(0===i)return;if(h-=i,l>6)return;for(r=0;d();){if(n=null,r>0){if(!("."===d()&&r<4))return;h++;}if(!cT(TT,d()))return;for(;cT(TT,d());){if(o=aT(d(),10),null===n)n=o;else{if(0===n)return;n=10*n+o;}if(n>255)return;h++;}u[l]=256*u[l]+n,2!=++r&&4!==r||l++;}if(4!==r)return;break;}if(":"===d()){if(h++,!d())return;}else if(d())return;u[l++]=t;}else{if(null!==c)return;h++,c=++l;}}if(null!==c)for(a=l-c,l=7;0!==l&&a>0;)s=u[l],u[l--]=u[c+a-1],u[c+--a]=s;else if(8!==l)return;return u;}(pT(e,1,-1)),!t)return ST;this.host=t;}else if(this.isSpecial()){if(e=_V(e),cT(DT,e))return ST;if(t=function(e){var t,i,r,n,o,a,s,u=yT(e,".");if(u.length&&""===u[u.length-1]&&u.length--,(t=u.length)>4)return e;for(i=[],r=0;r1&&"0"===lT(n,0)&&(o=cT(IT,n)?16:8,n=pT(n,8===o?1:2)),""===n)a=0;else{if(!cT(10===o?PT:8===o?ET:BT,n))return e;a=aT(n,o);}vT(i,a);}for(r=0;r=uT(256,5-t))return null;}else if(a>255)return null;for(s=fT(i),r=0;r1?arguments[1]:void 0,r=eT(t,new _fI(e,!1,i));UV||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash());},gI=vI.prototype,mI=function mI(e,t){return{get:function get(){return tT(this)[e]();},set:t&&function(e){return tT(this)[t](e);},configurable:!0,enumerable:!0};};if(UV&&(HV(gI,"href",mI("serialize","setHref")),HV(gI,"origin",mI("getOrigin")),HV(gI,"protocol",mI("getProtocol","setProtocol")),HV(gI,"username",mI("getUsername","setUsername")),HV(gI,"password",mI("getPassword","setPassword")),HV(gI,"host",mI("getHost","setHost")),HV(gI,"hostname",mI("getHostname","setHostname")),HV(gI,"port",mI("getPort","setPort")),HV(gI,"pathname",mI("getPathname","setPathname")),HV(gI,"search",mI("getSearch","setSearch")),HV(gI,"searchParams",mI("getSearchParams")),HV(gI,"hash",mI("getHash","setHash"))),WV(gI,"toJSON",function(){return tT(this).serialize();},{enumerable:!0}),WV(gI,"toString",function(){return tT(this).serialize();},{enumerable:!0}),nT){var yI=nT.createObjectURL,pI=nT.revokeObjectURL;yI&&WV(vI,"createObjectURL",NV(yI,nT)),pI&&WV(vI,"revokeObjectURL",NV(pI,nT));}KV(vI,"URL"),AV({global:!0,constructor:!0,forced:!RV,sham:!UV},{URL:vI});var wI=Mi,bI=a,kI=Bm,SI=To,xI=Bx,CI=ne("URL"),VI=xI&&bI(function(){CI.canParse();}),TI=bI(function(){return 1!==CI.canParse.length;});wI({target:"URL",stat:!0,forced:!VI||TI},{canParse:function canParse(e){var t=kI(arguments.length,1),i=SI(e),r=t<2||void 0===arguments[1]?void 0:SI(arguments[1]);try{return!!new CI(i,r);}catch(e){return!1;}}});var II=Mi,EI=Bm,PI=To,BI=Bx,DI=ne("URL");II({target:"URL",stat:!0,forced:!BI},{parse:function parse(e){var t=EI(arguments.length,1),i=PI(e),r=t<2||void 0===arguments[1]?void 0:PI(arguments[1]);try{return new DI(i,r);}catch(e){return null;}}});var MI=Q.URL;!function(e){e.exports=MI;}(wx);var zI=t(px),AI={},UI={get exports(){return AI;},set exports(e){AI=e;}};!function(e){e.exports=qd;}(UI);var RI=t(AI),LI={},NI={get exports(){return LI;},set exports(e){LI=e;}};!function(e){e.exports=kf;}(NI);var OI=t(LI),WI={},HI={get exports(){return WI;},set exports(e){WI=e;}},FI=E,jI=Xn,YI=TypeError,XI=Object.getOwnPropertyDescriptor,qI=FI&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1;}catch(e){return e instanceof TypeError;}}()?function(e,t){if(jI(e)&&!XI(e,"length").writable)throw new YI("Cannot set read only .length");return e.length=t;}:function(e,t){return e.length=t;},ZI=Ie,_I=TypeError,GI=function GI(e,t){if(!delete e[t])throw new _I("Cannot delete property "+ZI(t)+" of "+ZI(e));},KI=Mi,$I=Je,JI=Br,QI=Tr,eE=Ur,tE=qI,iE=Zn,rE=no,nE=$n,oE=GI,aE=uo("splice"),sE=Math.max,uE=Math.min;KI({target:"Array",proto:!0,forced:!aE},{splice:function splice(e,t){var i,r,n,o,a,s,u=$I(this),l=eE(u),c=JI(e,l),h=arguments.length;for(0===h?i=r=0:1===h?(i=0,r=l-c):(i=h-2,r=uE(sE(QI(t),0),l-c)),iE(l+i-r),n=rE(u,r),o=0;ol-r+i;o--)oE(u,o-1);}else if(i>r)for(o=l-r;o>c;o--)s=o+i-1,(a=o+r-1)in u?u[s]=u[a]:oE(u,s);for(o=0;o1?arguments[1]:void 0);}});var SE=Wd("Array","findIndex"),xE=oe,CE=SE,VE=Array.prototype,TE=function TE(e){var t=e.findIndex;return e===VE||xE(VE,e)&&t===VE.findIndex?CE:t;},IE=TE;!function(e){e.exports=IE;}(yE);var EE=t(mE),PE={},BE={get exports(){return PE;},set exports(e){PE=e;}},DE=Mi,ME=Math.hypot,zE=Math.abs,AE=Math.sqrt;DE({target:"Math",stat:!0,arity:2,forced:!!ME&&ME(1/0,NaN)!==1/0},{hypot:function hypot(e,t){for(var i,r,n=0,o=0,a=arguments.length,s=0;o0?(r=i/s)*r:i;return s===1/0?1/0:s*AE(n);}});var UE=Q.Math.hypot;!function(e){e.exports=UE;}(BE);var RE=t(PE),LE={},NE={get exports(){return LE;},set exports(e){LE=e;}},OE=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1;};Mi({target:"Math",stat:!0},{sign:OE});var WE=Q.Math.sign;!function(e){e.exports=WE;}(NE);var HE=t(LE),FE={},jE={get exports(){return FE;},set exports(e){FE=e;}},YE=Aa.map;Mi({target:"Array",proto:!0,forced:!uo("map")},{map:function map(e){return YE(this,e,arguments.length>1?arguments[1]:void 0);}});var XE=Wd("Array","map"),qE=oe,ZE=XE,_E=Array.prototype,GE=function GE(e){var t=e.map;return e===_E||qE(_E,e)&&t===_E.map?ZE:t;},KE=GE;!function(e){e.exports=KE;}(jE);var $E=t(FE),JE={},QE={get exports(){return JE;},set exports(e){JE=e;}},eP=Je,tP=Br,iP=Ur,rP=function rP(e){for(var t=eP(this),i=iP(t),r=arguments.length,n=tP(r>1?arguments[1]:void 0,i),o=r>2?arguments[2]:void 0,a=void 0===o?i:tP(o,i);a>n;)t[n++]=e;return t;};Mi({target:"Array",proto:!0},{fill:rP});var nP=Wd("Array","fill"),oP=oe,aP=nP,sP=Array.prototype,uP=function uP(e){var t=e.fill;return e===sP||oP(sP,e)&&t===sP.fill?aP:t;},lP=uP;!function(e){e.exports=lP;}(QE);var cP=t(JE),hP={},dP={get exports(){return hP;},set exports(e){hP=e;}},fP=Mi,vP=Aa.find,gP="find",mP=!0;gP in[]&&Array(1)[gP](function(){mP=!1;}),fP({target:"Array",proto:!0,forced:mP},{find:function find(e){return vP(this,e,arguments.length>1?arguments[1]:void 0);}});var yP=Wd("Array","find"),pP=oe,wP=yP,bP=Array.prototype,kP=function kP(e){var t=e.find;return e===bP||pP(bP,e)&&t===bP.find?wP:t;},SP=kP;!function(e){e.exports=SP;}(dP);var xP=t(hP),CP={},VP={get exports(){return CP;},set exports(e){CP=e;}},TP=o,IP=d,EP=T,PP=vm,BP=ue,DP=zi,MP=Bm,zP=TP.Function,AP=/MSIE .\./.test(BP)||"BUN"===PP&&function(){var e=TP.Bun.version.split(".");return e.length<3||"0"===e[0]&&(e[1]<3||"3"===e[1]&&"0"===e[2]);}(),UP=function UP(e,t){var i=t?2:1;return AP?function(r,n){var o=MP(arguments.length,1)>i,a=EP(r)?r:zP(r),s=o?DP(arguments,i):[],u=o?function(){IP(a,this,s);}:a;return t?e(u,n):e(u);}:e;},RP=Mi,LP=o,NP=UP(LP.setInterval,!0);RP({global:!0,bind:!0,forced:LP.setInterval!==NP},{setInterval:NP});var OP=Mi,WP=o,HP=UP(WP.setTimeout,!0);OP({global:!0,bind:!0,forced:WP.setTimeout!==HP},{setTimeout:HP});var FP=Q.setTimeout;!function(e){e.exports=FP;}(VP);var jP=t(CP),YP={},XP={get exports(){return YP;},set exports(e){YP=e;}},qP=E,ZP=a,_P=y,GP=al,KP=$r,$P=K,JP=_P(M.f),QP=_P([].push),eB=qP&&ZP(function(){var e=Object.create(null);return e[2]=2,!JP(e,2);}),tB=function tB(e){return function(t){for(var i,r=$P(t),n=KP(r),o=eB&&null===GP(r),a=n.length,s=0,u=[];a>s;)i=n[s++],qP&&!(o?i in r:JP(r,i))||QP(u,e?[i,r[i]]:r[i]);return u;};},iB={entries:tB(!0),values:tB(!1)},rB=iB.entries;Mi({target:"Object",stat:!0},{entries:function entries(e){return rB(e);}});var nB=Q.Object.entries;!function(e){e.exports=nB;}(XP);var oB=t(YP),aB={},sB={get exports(){return aB;},set exports(e){aB=e;}};!function(e){e.exports=Gw;}(sB);var uB=t(aB),lB={},cB={get exports(){return lB;},set exports(e){lB=e;}},hB=Wr.includes;Mi({target:"Array",proto:!0,forced:a(function(){return!Array(1).includes();})},{includes:function includes(e){return hB(this,e,arguments.length>1?arguments[1]:void 0);}});var dB=Wd("Array","includes"),fB=J,vB=k,gB=gt("match"),mB=function mB(e){var t;return fB(e)&&(void 0!==(t=e[gB])?!!t:"RegExp"===vB(e));},yB=TypeError,pB=function pB(e){if(mB(e))throw new yB("The method doesn't accept regular expressions");return e;},wB=gt("match"),bB=function bB(e){var t=/./;try{"/./"[e](t);}catch(i){try{return t[wB]=!1,"/./"[e](t);}catch(e){}}return!1;},kB=Mi,SB=pB,xB=Z,CB=To,VB=bB,TB=y("".indexOf);kB({target:"String",proto:!0,forced:!VB("includes")},{includes:function includes(e){return!!~TB(CB(xB(this)),CB(SB(e)),arguments.length>1?arguments[1]:void 0);}});var IB=Wd("String","includes"),EB=oe,PB=dB,BB=IB,DB=Array.prototype,MB=String.prototype,zB=function zB(e){var t=e.includes;return e===DB||EB(DB,e)&&t===DB.includes?PB:"string"==typeof e||e===MB||EB(MB,e)&&t===MB.includes?BB:t;},AB=zB;!function(e){e.exports=AB;}(cB);var UB=t(lB),RB={},LB={get exports(){return RB;},set exports(e){RB=e;}};!function(e){e.exports=md;}(LB);var NB=t(RB),OB={},WB={get exports(){return OB;},set exports(e){OB=e;}},HB=Wd("Array","keys"),FB=Qi,jB=tt,YB=oe,XB=HB,qB=Array.prototype,ZB={DOMTokenList:!0,NodeList:!0},_B=function _B(e){var t=e.keys;return e===qB||YB(qB,e)&&t===qB.keys||jB(ZB,FB(e))?XB:t;};!function(e){e.exports=_B;}(WB);var GB=t(OB),KB={},$B={get exports(){return KB;},set exports(e){KB=e;}},JB={},QB={get exports(){return JB;},set exports(e){JB=e;}},eD=a(function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8});}}),tD=a,iD=J,rD=k,nD=eD,oD=Object.isExtensible,aD=tD(function(){oD(1);})||nD?function(e){return!!iD(e)&&(!nD||"ArrayBuffer"!==rD(e))&&(!oD||oD(e));}:oD,sD=!a(function(){return Object.isExtensible(Object.preventExtensions({}));}),uD=Mi,lD=y,cD=Hr,hD=J,dD=tt,fD=ti.f,vD=Io,gD=Bo,mD=aD,yD=sD,pD=!1,wD=at("meta"),bD=0,kD=function kD(e){fD(e,wD,{value:{objectID:"O"+bD++,weakData:{}}});},SD=QB.exports={enable:function enable(){SD.enable=function(){},pD=!0;var e=vD.f,t=lD([].splice),i={};i[wD]=1,e(i).length&&(vD.f=function(i){for(var r=e(i),n=0,o=r.length;n1?arguments[1]:void 0);t=t?t.next:i.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous;},has:function has(e){return!!u(this,e);}}),HD(o,i?{get:function get(e){var t=u(this,e);return t&&t.value;},set:function set(e,t){return s(this,0===e?0:e,t);}}:{add:function add(e){return s(this,e=0===e?0:e,e);}}),GD&&WD(o,"size",{configurable:!0,get:function get(){return a(this).size;}}),n;},setStrong:function setStrong(e,t,i){var r=t+" Iterator",n=JD(t),o=JD(r);qD(e,t,function(e,t){$D(this,{type:r,target:e,state:n(e),kind:t,last:null});},function(){for(var e=o(this),t=e.kind,i=e.last;i&&i.removed;)i=i.previous;return e.target&&(e.last=i=i?i.next:e.state.first)?ZD("keys"===t?i.key:"values"===t?i.value:[i.key,i.value],!1):(e.target=null,ZD(void 0,!0));},i?"entries":"values",!i,!0),_D(t);}},eM=function eM(e,t,i){var r,n=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=n?"set":"add",s=CD[e],u=s&&s.prototype,l={};if(RD&&BD(s)&&(o||u.forEach&&!TD(function(){new s().entries().next();}))){var c=(r=t(function(t,i){LD(PD(t,c),{type:e,collection:new s()}),MD(i)||ED(i,t[a],{that:t,AS_ENTRIES:n});})).prototype,h=ND(e);UD(["add","clear","delete","forEach","get","has","set","keys","values","entries"],function(e){var t="add"===e||"set"===e;!(e in u)||o&&"clear"===e||ID(c,e,function(i,r){var n=h(this).collection;if(!t&&o&&!DD(i))return"get"===e&&void 0;var a=n[e](0===i?0:i,r);return t?this:a;});}),o||AD(c,"size",{configurable:!0,get:function get(){return h(this).collection.size;}});}else r=i.getConstructor(t,e,n,a),VD.enable();return zD(r,e,!1,!0),l[e]=r,xD({global:!0,forced:!0},l),o||i.setStrong(r,e,n),r;};eM("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0);};},QD);var tM=Ie,iM=TypeError,rM=function rM(e){if("object"==_typeof(e)&&"size"in e&&"has"in e&&"add"in e&&"delete"in e&&"keys"in e)return e;throw new iM(tM(e)+" is not a set");},nM=function nM(e,t){return 1===t?function(t,i){return t[e](i);}:function(t,i,r){return t[e](i,r);};},oM=ne("Set"),aM=oM.prototype,sM={Set:oM,add:nM("add",1),has:nM("has",1),remove:nM("delete",1),proto:aM},uM=D,lM=function lM(e,t,i){for(var r,n,o=i?e:e.iterator,a=e.next;!(r=uM(a,o)).done;)if(void 0!==(n=t(r.value)))return n;},cM=lM,hM=function hM(e,t,i){return i?cM(e.keys(),t,!0):e.forEach(t);},dM=hM,fM=sM.Set,vM=sM.add,gM=function gM(e){var t=new fM();return dM(e,function(e){vM(t,e);}),t;},mM=function mM(e){return e.size;},yM=De,pM=ai,wM=D,bM=Tr,kM=function kM(e){return{iterator:e,next:e.next,done:!1};},SM="Invalid size",xM=RangeError,CM=TypeError,VM=Math.max,TM=function TM(e,t){this.set=e,this.size=VM(t,0),this.has=yM(e.has),this.keys=yM(e.keys);};TM.prototype={getIterator:function getIterator(){return kM(pM(wM(this.keys,this.set)));},includes:function includes(e){return wM(this.has,this.set,e);}};var IM=function IM(e){pM(e);var t=+e.size;if(t!=t)throw new CM(SM);var i=bM(t);if(i<0)throw new xM(SM);return new TM(e,i);},EM=rM,PM=gM,BM=mM,DM=IM,MM=hM,zM=lM,AM=sM.has,UM=sM.remove,RM=function RM(){return!1;},LM=function LM(e){var t=EM(this),i=DM(e),r=PM(t);return BM(t)<=i.size?MM(t,function(e){i.includes(e)&&UM(r,e);}):zM(i.getIterator(),function(e){AM(t,e)&&UM(r,e);}),r;};Mi({target:"Set",proto:!0,real:!0,forced:!RM()},{difference:LM});var NM=rM,OM=mM,WM=IM,HM=hM,FM=lM,jM=sM.Set,YM=sM.add,XM=sM.has,qM=a,ZM=function ZM(e){var t=NM(this),i=WM(e),r=new jM();return OM(t)>i.size?FM(i.getIterator(),function(e){XM(t,e)&&YM(r,e);}):HM(t,function(e){i.includes(e)&&YM(r,e);}),r;};Mi({target:"Set",proto:!0,real:!0,forced:!RM()||qM(function(){return"3,2"!==String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))));})},{intersection:ZM});var _M=rM,GM=sM.has,KM=mM,$M=IM,JM=hM,QM=lM,ez=Nh,tz=function tz(e){var t=_M(this),i=$M(e);if(KM(t)<=i.size)return!1!==JM(t,function(e){if(i.includes(e))return!1;},!0);var r=i.getIterator();return!1!==QM(r,function(e){if(GM(t,e))return ez(r,"normal",!1);});};Mi({target:"Set",proto:!0,real:!0,forced:!RM()},{isDisjointFrom:tz});var iz=rM,rz=mM,nz=hM,oz=IM,az=function az(e){var t=iz(this),i=oz(e);return!(rz(t)>i.size)&&!1!==nz(t,function(e){if(!i.includes(e))return!1;},!0);};Mi({target:"Set",proto:!0,real:!0,forced:!RM()},{isSubsetOf:az});var sz=rM,uz=sM.has,lz=mM,cz=IM,hz=lM,dz=Nh,fz=function fz(e){var t=sz(this),i=cz(e);if(lz(t)0&&Mz(u)?(l=zz(u),c=_Rz(e,t,u,l,c,o-1)-1):(Az(c+1),e[c]=u),c++),h++;return c;},Lz=_Rz,Nz=Je,Oz=Ur,Wz=Tr,Hz=no;Mi({target:"Array",proto:!0},{flat:function flat(){var e=arguments.length?arguments[0]:void 0,t=Nz(this),i=Oz(t),r=Hz(t,0);return r.length=Lz(r,t,t,i,0,void 0===e?1:Wz(e)),r;}});var Fz=Wd("Array","flat"),jz=oe,Yz=Fz,Xz=Array.prototype,qz=function qz(e){var t=e.flat;return e===Xz||jz(Xz,e)&&t===Xz.flat?Yz:t;},Zz=qz;!function(e){e.exports=Zz;}(Dz);var _z=t(Bz),Gz={},Kz={get exports(){return Gz;},set exports(e){Gz=e;}},$z=o.isFinite,Jz=Number.isFinite||function(e){return"number"==typeof e&&$z(e);};Mi({target:"Number",stat:!0},{isFinite:Jz});var Qz=Q.Number.isFinite;!function(e){e.exports=Qz;}(Kz);var eA=t(Gz),tA={},iA={get exports(){return tA;},set exports(e){tA=e;}},rA=o,nA=a,oA=To,aA=CS.trim,sA=mS,uA=y("".charAt),lA=rA.parseFloat,cA=rA.Symbol,hA=cA&&cA.iterator,dA=1/lA(sA+"-0")!=-1/0||hA&&!nA(function(){lA(Object(hA));})?function(e){var t=aA(oA(e)),i=lA(t);return 0===i&&"-"===uA(t,0)?-0:i;}:lA;Mi({global:!0,forced:parseFloat!==dA},{parseFloat:dA});var fA=Q.parseFloat;!function(e){e.exports=fA;}(iA);var vA=t(tA),gA={},mA={get exports(){return gA;},set exports(e){gA=e;}},yA=Mi,pA=C;I.f;var wA=zr,bA=To,kA=pB,SA=Z,xA=bB,CA=pA("".slice),VA=Math.min;yA({target:"String",proto:!0,forced:!xA("startsWith")},{startsWith:function startsWith(e){var t=bA(SA(this));kA(e);var i=wA(VA(arguments.length>1?arguments[1]:void 0,t.length)),r=bA(e);return CA(t,i,i+r.length)===r;}});var TA=Wd("String","startsWith"),IA=oe,EA=TA,PA=String.prototype,BA=function BA(e){var t=e.startsWith;return"string"==typeof e||e===PA||IA(PA,e)&&t===PA.startsWith?EA:t;},DA=BA;!function(e){e.exports=DA;}(mA);var MA=t(gA),zA={},AA={get exports(){return zA;},set exports(e){zA=e;}},UA=gV;Mi({target:"Object",stat:!0,arity:2,forced:Object.assign!==UA},{assign:UA});var RA=Q.Object.assign;!function(e){e.exports=RA;}(AA);var LA=t(zA),NA={},OA={get exports(){return NA;},set exports(e){NA=e;}},WA=ue.match(/firefox\/(\d+)/i),HA=!!WA&&+WA[1],FA=/MSIE|Trident/.test(ue),jA=ue.match(/AppleWebKit\/(\d+)\./),YA=!!jA&&+jA[1],XA=Mi,qA=y,ZA=De,_A=Je,GA=Ur,KA=GI,$A=To,JA=a,QA=Rx,eU=cf,tU=HA,iU=FA,rU=ge,nU=YA,oU=[],aU=qA(oU.sort),sU=qA(oU.push),uU=JA(function(){oU.sort(void 0);}),lU=JA(function(){oU.sort(null);}),cU=eU("sort"),hU=!JA(function(){if(rU)return rU<70;if(!(tU&&tU>3)){if(iU)return!0;if(nU)return nU<603;var e,t,i,r,n="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:i=3;break;case 68:case 71:i=4;break;default:i=2;}for(r=0;r<47;r++)oU.push({k:t+r,v:i});}for(oU.sort(function(e,t){return t.v-e.v;}),r=0;r$A(i)?1:-1;};}(e)),i=GA(n),r=0;r0;(r>>>=1)&&(t+=t))1&r&&(i+=t);return i;},_U=Z,GU=YU(ZU),KU=YU("".slice),$U=Math.ceil,JU=function JU(e){return function(t,i,r){var n,o,a=qU(_U(t)),s=XU(i),u=a.length,l=void 0===r?" ":qU(r);return s<=u||""===l?a:((o=GU(l,$U((n=s-u)/l.length))).length>n&&(o=KU(o,0,n)),e?a+o:o+a);};},QU=y,eR=a,tR={start:JU(!1),end:JU(!0)}.start,iR=RangeError,rR=isFinite,nR=Math.abs,oR=Date.prototype,aR=oR.toISOString,sR=QU(oR.getTime),uR=QU(oR.getUTCDate),lR=QU(oR.getUTCFullYear),cR=QU(oR.getUTCHours),hR=QU(oR.getUTCMilliseconds),dR=QU(oR.getUTCMinutes),fR=QU(oR.getUTCMonth),vR=QU(oR.getUTCSeconds),gR=eR(function(){return"0385-07-25T07:06:39.999Z"!==aR.call(new Date(-50000000000001));})||!eR(function(){aR.call(new Date(NaN));})?function(){if(!rR(sR(this)))throw new iR("Invalid time value");var e=this,t=lR(e),i=hR(e),r=t<0?"-":t>9999?"+":"";return r+tR(nR(t),r?6:4,0)+"-"+tR(fR(e)+1,2,0)+"-"+tR(uR(e),2,0)+"T"+tR(cR(e),2,0)+":"+tR(dR(e),2,0)+":"+tR(vR(e),2,0)+"."+tR(i,3,0)+"Z";}:aR,mR=D,yR=Je,pR=xt,wR=gR,bR=k;Mi({target:"Date",proto:!0,forced:a(function(){return null!==new Date(NaN).toJSON()||1!==mR(Date.prototype.toJSON,{toISOString:function toISOString(){return 1;}});})},{toJSON:function toJSON(e){var t=yR(this),i=pR(t,"number");return"number"!=typeof i||isFinite(i)?"toISOString"in t||"Date"!==bR(t)?t.toISOString():mR(wR,t):null;}});var kR=Q,SR=d;kR.JSON||(kR.JSON={stringify:JSON.stringify});var xR=function xR(e,t,i){return SR(kR.JSON.stringify,null,arguments);},CR=xR;!function(e){e.exports=CR;}(OU);var VR=t(NU),TR={},IR={get exports(){return TR;},set exports(e){TR=e;}},ER=iB.values;Mi({target:"Object",stat:!0},{values:function values(e){return ER(e);}});var PR=Q.Object.values;!function(e){e.exports=PR;}(IR);var BR=t(TR),DR={},MR={get exports(){return DR;},set exports(e){DR=e;}};!function(e){e.exports=Yf;}(MR);var zR=t(DR),AR={},UR={get exports(){return AR;},set exports(e){AR=e;}},RR=Aa.some;Mi({target:"Array",proto:!0,forced:!cf("some")},{some:function some(e){return RR(this,e,arguments.length>1?arguments[1]:void 0);}});var LR=Wd("Array","some"),NR=oe,OR=LR,WR=Array.prototype,HR=function HR(e){var t=e.some;return e===WR||NR(WR,e)&&t===WR.some?OR:t;},FR=HR;!function(e){e.exports=FR;}(UR);var jR=t(AR),YR={},XR={get exports(){return YR;},set exports(e){YR=e;}};!function(e){e.exports=wv;}(XR);var qR,ZR,_R,GR,KR,$R,JR,QR,eL,tL=t(YR),iL=["style"],rL=["style"],nL=["style"],oL=["style"],aL=["style"],sL=["style"],uL=["style"],lL=["style"];function cL(e,t,i){return t=pb(t),function(e,t){if(t&&("object"===ch(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return yb(e);}(e,av()?On(t,i||[],pb(e).constructor):t.apply(e,i));}function hL(e,t,i,r){var n=Zb(pb(1&r?e.prototype:e),t,i);return 2&r&&"function"==typeof n?function(e){return n.apply(i,e);}:n;}var dL={code:0,message:"ok."},fL={code:8e4,message:"The parameter type is wrong."},vL={code:80002,message:"The parameter is out of range."},gL={code:80003,message:"The image does not exist."},mL={code:80013,message:"The parameter is invalid."},yL={code:80021,message:"The size is invalid."},pL=function pL(e){return e.replace(/[A-Z]/g,function(e){return"-".concat(e.toLowerCase());});},wL=function wL(e){return Object.prototype.toString.call(e);},bL=function bL(e){return _k?_k(e):"[object Array]"===wL(e);},kL=function kL(e){return null!==e&&"[object Object]"===wL(e);},_SL=function SL(e){var t,i=null;return bL(e)&&(i||(i=[]),$k(e).call(e,function(e){i.push(_SL(e));})),kL(e)&&(i||(i={}),$k(t=eS(e)).call(t,function(t){i[t]=_SL(e[t]);})),i||e;};function xL(e,t){for(var i in t)e[i]=e[i]&&"[object Object]"===e[i].toString()?xL(e[i],t[i]):e[i]=t[i];return e;}var CL=function CL(e){return void 0===e;},VL=function VL(e,t){var i,r;e=null!==(i=e)&&void 0!==i?i:"yyyy-MM-dd hh:mm:ss";var n=CL(t)?new Date():new Date(t),o={"M+":(n.getMonth()+1).toString(),"d+":n.getDate().toString(),"h+":n.getHours().toString(),"m+":n.getMinutes().toString(),"s+":n.getSeconds().toString(),"q+":Math.floor((n.getMonth()+3)/3).toString(),S:n.getMilliseconds().toString()};return /(y+)/.test(e)&&(e=e.replace(RegExp.$1,"".concat(n.getFullYear()).substring(4-RegExp.$1.length))),$k(r=eS(o)).call(r,function(t){new RegExp("(".concat(t,")")).test(e)&&(e=e.replace(RegExp.$1,1===RegExp.$1.length?o[t]:"00".concat(o[t]).substring("".concat(o[t]).length)));}),e;},TL=function TL(e){return"string"==typeof e;};function IL(e,t){return Math.pow(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2),.5);}function EL(e){var t=e.type,i=e.value;return"hex"===t?"#".concat(i):"literal"===t?i:"rgb"===t?"rgb(".concat(i.join(","),")"):"rgba(".concat(i.join(","),")");}var PL=function(){var e=/^(linear\-gradient)/i,t=/^(repeating\-linear\-gradient)/i,i=/^(radial\-gradient)/i,r=/^(repeating\-radial\-gradient)/i,n=/^(conic\-gradient)/i,o=/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,a=/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,s=/^(left|center|right|top|bottom)/i,u=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,l=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,c=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,h=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,d=/^\(/,f=/^\)/,v=/^,/,g=/^\#([0-9a-fA-F]+)/,m=/^([a-zA-Z]+)/,y=/^rgb/i,p=/^rgba/i,w=/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/,b="";function k(e){var t;throw new Error(lS(t="".concat(b,": ")).call(t,e));}function S(){return x("linear-gradient",e,V)||x("repeating-linear-gradient",t,V)||x("radial-gradient",i,T)||x("repeating-radial-gradient",r,T)||x("conic-gradient",n,T);}function x(e,t,i){return C(t,function(t){var r=i();return r&&(L(v)||k("Missing comma before color stops")),{type:e,orientation:r,colorStops:D(M)};});}function C(e,t){var i=L(e);if(i){L(d)||k("Missing (");var r=t(i);return L(f)||k("Missing )"),r;}}function V(){return R("directional",o,1)||R("angular",h,1);}function T(){var e,t,i=I();return i&&((e=[]).push(i),t=b,L(v)&&((i=I())?e.push(i):b=t)),e;}function I(){var e=function(){var e=R("shape",/^(circle)/i,0);return e&&(e.style=U()||E()),e;}()||function(){var e=R("shape",/^(ellipse)/i,0);return e&&(e.style=A()||E()),e;}();if(e)e.at=P();else{var t=E();if(t){e=t;var i=P();i&&(e.at=i);}else{var r=B();r&&(e={type:"default-radial",at:r});}}return e;}function E(){return R("extent-keyword",a,1);}function P(){if(R("position",/^at/,0)){var e=B();return e||k("Missing positioning value"),e;}}function B(){var e={x:A(),y:A()};if(e.x||e.y)return{type:"position",value:e};}function D(e){var t=e(),i=[];if(t)for(i.push(t);L(v);)(t=e())?i.push(t):k("One extra comma");return i;}function M(){var e=R("hex",g,1)||C(p,function(){return{type:"rgba",value:D(z)};})||C(y,function(){return{type:"rgb",value:D(z)};})||R("literal",m,0);return e||k("Expected color definition"),e.length=A(),e;}function z(){return L(w)[1];}function A(){return R("%",l,1)||R("position-keyword",s,1)||U();}function U(){return R("px",u,1)||R("em",c,1);}function R(e,t,i){var r=L(t);if(r)return{type:e,value:r[i]};}function L(e){var t=/^[\n\r\t\s]+/.exec(b);t&&N(t[0].length);var i=e.exec(b);return i&&N(i[0].length),i;}function N(e){b=b.substring(e);}return function(e){return b=e,function(){var e=D(S);return b.length>0&&k("Invalid input not EOF"),e;}();};}(),BL=function BL(e){return"number"==typeof e&&!fS(e);},DL=function DL(e){return"[object Boolean]"===wL(e);},ML=function ML(e){return"function"==typeof e;},zL=function zL(){return void 0!==document.documentMode;},AL=function AL(){return"ontouchstart"in document.documentElement;};function UL(e){return null==e;}var RL=function RL(e,t){return e in t;},LL=function LL(e,t){for(var i=[];e;){var r=e.match(t);if(!r)break;i.push(r),e=e.substring(r.index+r[0].length);}return i;};function NL(e,t){var i;return $k(i=eS(e)).call(i,function(i){CL(t[i])?t[i]=e[i]:kL(e[i])?NL(e[i],t[i]):t[i]=e[i];}),t;}var OL=0,WL=function WL(){var e;return OL+=1,lS(e="".concat(new Date().getTime().toString(36))).call(e,OL.toString(36));},HL=function HL(e,t,i){return Math.min(Math.max(e,t),i);},FL="\\s*([+-]?\\d+)\\s*",jL="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",YL="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",XL=/^#([0-9a-f]{3,8})$/,qL=new RegExp(lS(qR="^rgb\\(".concat(FL,",").concat(FL,",")).call(qR,FL,"\\)$")),ZL=new RegExp(lS(ZR="^rgb\\(".concat(YL,",").concat(YL,",")).call(ZR,YL,"\\)$")),_L=new RegExp(lS(_R=lS(GR="^rgba\\(".concat(FL,",").concat(FL,",")).call(GR,FL,",")).call(_R,jL,"\\)$")),GL=new RegExp(lS(KR=lS($R="^rgba\\(".concat(YL,",").concat(YL,",")).call($R,YL,",")).call(KR,jL,"\\)$")),KL=new RegExp(lS(JR="^hsl\\(".concat(jL,",").concat(YL,",")).call(JR,YL,"\\)$")),$L=new RegExp(lS(QR=lS(eL="^hsla\\(".concat(jL,",").concat(YL,",")).call(eL,YL,",")).call(QR,jL,"\\)$")),JL={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},QL=Yk(function e(t,i,r,n){Xk(this,e),Wk(this,"r",void 0),Wk(this,"g",void 0),Wk(this,"b",void 0),Wk(this,"opacity",void 0),this.r=t,this.g=i,this.b=r,this.opacity=n;});function eN(e){return new QL(e>>16&255,e>>8&255,255&e,1);}function tN(e,t,i,r){return r<=0&&(e=NaN,t=NaN,i=NaN),new QL(e,t,i,r);}function iN(e,t,i,r){return r<=0?(e=NaN,t=NaN,i=NaN):i<=0||i>=1?(e=NaN,t=NaN):t<=0&&(e=NaN),{h:e,s:t,l:i,opacity:r};}function rN(e,t,i){return e<60?(t+(i-t)*e)/60*255:e<180?255*i:e<240?(t+(i-t)*(240-e))/60*255:255*t;}function nN(e){var t=e.h<0?e.h%360+360:e.h%360,i=fS(t)||fS(e.s)?0:e.s,r=e.l,n=r+(r<.5?r:1-r)*i,o=2*r-n;return new QL(rN(t>=240?t-240:t+120,o,n),rN(t,o,n),rN(t<120?t+240:t-120,o,n),e.opacity);}function oN(e){var t,i;return e?vx(t=yx(i=eS(e)).call(i,function(t){return null!==e[t]&&void 0!==e[t];})).call(t,function(t,i){return Fk(Fk({},t),{},Wk({},i,e[i]));},{}):{};}var aN,sN={"&":"&",">":">","<":"<"," ":" ",""":'"',"'":"'"},uN={};function lN(e,t){for(var i=eS(e),r=0;r","<":"<"," ":" ",""":'"',"'":"'"},function(e,t){});var hN=function hN(e,t,i){void 0===t?i.appendChild(e):i.insertBefore(e,t);},dN=function dN(e,t){var i=t.parentNode;i.lastChild===t?i.appendChild(e):hN(e,t.nextSibling,i);},fN=function fN(e){e&&(e.stopPropagation?e.stopPropagation():e.cancelBubble=!0);},vN=function vN(e){var t=zI||window.webkitURL,i="string";return TL(e)?i="string":"[object Blob]"===wL(e)?(i="blob",e=t.createObjectURL(e)):("[object ArrayBuffer]"===wL(e)||bL(e))&&(i="blob",e=t.createObjectURL(new Blob([e]))),{type:i,data:e};},gN=function gN(){var e=window;if(e){if(e.devicePixelRatio)return e.devicePixelRatio;if(e.screen.deviceXDPI&&e.screen.logicalXDPI)return e.screen.deviceXDPI/e.screen.logicalXDPI;}return 1;},mN=function mN(e){var t=zI||window.webkitURL;/^blob:/.test(e)&&t.revokeObjectURL(e);},yN=function yN(){return{scrollX:void 0===window.scrollX?window.pageXOffset:window.scrollX,scrollY:void 0===window.scrollY?window.pageYOffset:window.scrollY};},pN=function pN(e){return(e/=.5)<1?Math.pow(e,3):.5*(Math.pow(e-2,3)+2);},wN=function wN(e){return Math.pow(e-1,3)+1;},bN=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";Xk(this,e),Wk(this,"prefix",void 0),Wk(this,"postfix",void 0),Wk(this,"isDestroyed",!1),Wk(this,"uid",WL()),Wk(this,"cacheEvents",void 0),Wk(this,"events",void 0),Wk(this,"isCached",void 0),this.cacheEvents=[],this.events={},this.isCached=!1,this.prefix=t,this.postfix=i;}return Yk(e,[{key:"save",value:function value(){this.isCached=!0;}},{key:"restore",value:function value(){var e,t=this;this.isCached=!1,$k(e=this.cacheEvents).call(e,function(e){var i,r=e.eventName,n=e.param;t.emit.apply(t,lS(i=[r]).call(i,Kb(n)));}),this.cacheEvents.length=0;}},{key:"destroy",value:function value(){var e=this;if(!this.isDestroyed){for(var t in this.events)if(Object.prototype.hasOwnProperty.call(this.events,t)){var i,r=this.events[t];r&&$k(i=RI(r).call(r)).call(i,function(t){var i=t.name,r=t.fn,n=t.context,o=t.once;e.off(i,r,n,o);});}this.events={},this.isDestroyed=!0;}}},{key:"on",value:function value(e,t,i){var r,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=this.events,a={name:e=this.format(e),uid:WL(),context:i,once:n,fn:t};return o[e]||(o[e]=[]),OI(r=o[e]).call(r,a)<0&&o[e].push(a),a;}},{key:"once",value:function value(e,t,i){return this.on(e,t,i,!0);}},{key:"emit",value:function value(e){for(var t,i,r=this,n=arguments.length,o=new Array(n>1?n-1:0),a=1;a=0;o--){var a=n[o];t&&a.fn!==t||i&&a.context!==i||r&&a.once!==r||gE(n).call(n,o,1);}return!0;}},{key:"removeAllEventListeners",value:function value(e){if(e){var t,i;e=this.format(e);var r=EE(t=this.cacheEvents).call(t,function(t){return t.eventName===e;});r>-1&&gE(i=this.cacheEvents).call(i,r,1),this.events[e]&&delete this.events[e];}else this.cacheEvents=[],this.events={};}},{key:"getAllEvents",value:function value(){return this.events;}},{key:"format",value:function value(e){var t,i;return lS(t=lS(i="".concat(this.prefix||"")).call(i,e)).call(t,this.postfix||"");}}],[{key:"create",value:function value(t,i){return new e(t,i);}}]);}(),kN="default",SN=function(){function e(){Xk(this,e),Wk(this,"emitter",new bN());}return Yk(e,[{key:"on",value:function value(e){this.emitter.on(kN,e);}},{key:"emit",value:function value(){for(var e,t,i=arguments.length,r=new Array(i),n=0;n0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;Xk(this,e),Wk(this,"x",void 0),Wk(this,"y",void 0),Wk(this,"z",void 0),this.x=t,this.y=i,this.z=r;}return Yk(e,[{key:"setFromVector",value:function value(e){var t;this.x=e.x,this.y=e.y,this.z=null!==(t=e.z)&&void 0!==t?t:0;}},{key:"clone",value:function value(){return new e(this.x,this.y,this.z);}},{key:"norm",value:function value(){return RE(this.x,this.y,this.z);}},{key:"dot",value:function value(e){var t;return this.x*e.x+this.y*e.y+this.z*(null!==(t=e.z)&&void 0!==t?t:0);}},{key:"projectionTo",value:function value(e){var t=RE(e.x,e.y,e.z);return this.dot(e)/t;}},{key:"angle",value:function value(e){var t=this.norm()*RE(e.x,e.y,e.z),i=t&&this.dot(e)/t;return Math.acos(HL(i,-1,1));}},{key:"equals",value:function value(e){var t;return this.x===e.x&&this.y===e.y&&this.z===(null!==(t=e.z)&&void 0!==t?t:0);}},{key:"distance",value:function value(e){var t;return RE(this.x-e.x,this.y-e.y,this.z-(null!==(t=e.z)&&void 0!==t?t:0));}},{key:"lerp",value:function value(t){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,n=this.x,o=this.y,a=this.z;return new e(n+r*(t.x-n),o+r*(t.y-o),a+r*((null!==(i=t.z)&&void 0!==i?i:0)-a));}},{key:"normalize",value:function value(){var e=this,t=e.norm();return e.x/=t,e.y/=t,e.z/=t,this;}},{key:"negate",value:function value(){return this.x*=-1,this.y*=-1,this.z*=-1,this;}},{key:"cross",value:function value(e){var t=this;return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x};}},{key:"add",value:function value(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this;}},{key:"multiply",value:function value(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this;}}],[{key:"fromPoint",value:function value(t){return new e(t.x,t.y,t.z);}},{key:"fromTwoPoint",value:function value(t,i){var r,n,o,a,s,u;return new e((null!==(r=i.x)&&void 0!==r?r:0)-(null!==(n=t.x)&&void 0!==n?n:0),(null!==(o=i.y)&&void 0!==o?o:0)-(null!==(a=t.y)&&void 0!==a?a:0),(null!==(s=i.z)&&void 0!==s?s:0)-(null!==(u=t.z)&&void 0!==u?u:0));}},{key:"fromValue",value:function value(t,i,r){return new e(t,i,r);}}]);}();function VN(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return BL(e)?CN.fromValue(e,t,i):CN.fromPoint(e);}function TN(e,t){return CN.fromTwoPoint(e,t);}var IN=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;Xk(this,e),Wk(this,"x",void 0),Wk(this,"y",void 0),Wk(this,"z",void 0),this.x=t,this.y=i,this.z=r;}return Yk(e,[{key:"matrixTransform",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.x,i=this.y,r=this.z,n=e.m11,o=e.m21,a=e.m31,s=e.m41,u=e.m12,l=e.m22,c=e.m32,h=e.m42,d=e.m13,f=e.m23,v=e.m33,g=e.m43,m=e.m14*t+e.m24*i+e.m34*r+e.m44;return EN({x:(n*t+o*i+a*r+s)/m,y:(u*t+l*i+c*r+h)/m,z:(d*t+f*i+v*r+g)/m});}},{key:"setFromPoint",value:function value(e){return this.x=e.x||0,this.y=e.y||0,this.z=e.z||0,this;}},{key:"clone",value:function value(){return EN(this);}},{key:"equals",value:function value(e){var t=e.x,i=void 0===t?0:t,r=e.y,n=void 0===r?0:r,o=e.z,a=void 0===o?0:o,s=this;return s.x===i&&s.y===n&&s.z===a;}},{key:"distanceTo",value:function value(e){var t=e.x,i=void 0===t?0:t,r=e.y,n=void 0===r?0:r,o=e.z,a=void 0===o?0:o,s=this;return RE(s.x-i,s.y-n,s.z-a);}},{key:"lerpTo",value:function value(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,i=e.x,r=void 0===i?0:i,n=e.y,o=void 0===n?0:n,a=e.z,s=void 0===a?0:a,u=this;return EN({x:u.x+t*(r-u.x),y:u.y+t*(o-u.y),z:u.z+t*(s-u.z)});}},{key:"footPointInSegment",value:function value(e,t){var i=TN(e,this),r=TN(e,t),n=r.norm(),o=EN(e);if(0===n)return o;var a=i.projectionTo(r)/n;return o.lerpTo(t,a);}},{key:"perpendicularToSegment",value:function value(e,t){var i=this.footPointInSegment(e,t);return this.distanceTo(i);}}],[{key:"fromPoint",value:function value(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new e(t.x,t.y,t.z);}}]);}();function EN(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return BL(e)?new IN(e,t,i):new IN(e.x,e.y,e.z);}var PN=function PN(e){return e/Math.PI*180;},BN=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;Xk(this,e),Wk(this,"x",void 0),Wk(this,"y",void 0),Wk(this,"z",void 0),Wk(this,"w",void 0),this.x=t,this.y=i,this.z=r,this.w=n;}return Yk(e,[{key:"clone",value:function value(){var t=new e();return t.setFromQuat(this),t;}},{key:"setFromQuat",value:function value(e){var t,i,r,n,o=this;return o.x=null!==(t=e.x)&&void 0!==t?t:0,o.y=null!==(i=e.y)&&void 0!==i?i:0,o.z=null!==(r=e.z)&&void 0!==r?r:0,o.w=null!==(n=e.w)&&void 0!==n?n:1,this;}},{key:"toEuler",value:function value(){var e=this.x,t=this.y,i=this.z,r=this.w,n=.4990234375,o=this.w*this.y-this.x*this.z;if(o<-n||o>n){var a=HE(o);return{z:-2*a*Math.atan2(this.x,this.w),y:a*(Math.PI/2),x:0};}return{x:PN(Math.atan2(2*(t*i+r*e),r*r-e*e-t*t+i*i)),y:PN(Math.asin(-2*(e*i-r*t))),z:PN(Math.atan2(2*(e*t+r*i),r*r+e*e-t*t-i*i))};}},{key:"invert",value:function value(){var e=this.x,t=this.y,i=this.z,r=this.w,n=e*e+t*t+i*i+r*r,o=n?1/n:0;return this.x=-e*o,this.y=-t*o,this.z=-i*o,this.w=r*o,this;}},{key:"multiply",value:function value(e){var t=this.x,i=this.y,r=this.z,n=this.w,o=e.x,a=e.y,s=e.z,u=e.w;return this.x=t*u+n*o+i*s-r*a,this.y=i*u+n*a+r*o-t*s,this.z=r*u+n*s+t*a-i*o,this.w=n*u-t*o-i*a-r*s,this;}},{key:"normalize",value:function value(){var e=this.x,t=this.y,i=this.z,r=this.w,n=e*e+t*t+i*i+r*r;return this.x/=n,this.y/=n,this.z/=n,this.w/=n,this;}}],[{key:"fromQuat",value:function value(t){return new e().setFromQuat(t);}},{key:"fromEuler",value:function value(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t=xN(t)/2,i=xN(i)/2,r=xN(r)/2;var n=Math.sin(t),o=Math.cos(t),a=Math.sin(i),s=Math.cos(i),u=Math.sin(r),l=Math.cos(r),c=new e();return c.setFromQuat({x:n*s*l-o*a*u,y:o*a*l+n*s*u,z:o*s*u-n*a*l,w:o*s*l+n*a*u}),c;}}]);}();function DN(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return BL(e)?new BN(e,t,i,r):BN.fromQuat(e);}function MN(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return BN.fromEuler(e,t,i);}var zN=function(){return Yk(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;Xk(this,e),Wk(this,"x",void 0),Wk(this,"y",void 0),Wk(this,"z",void 0),Wk(this,"w",void 0),this.x=t,this.y=i,this.z=r,this.w=n;},[{key:"negate",value:function value(){this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1;}},{key:"normalize",value:function value(){var e=this.norm();this.x/=e,this.y/=e,this.z/=e,this.w/=e;}},{key:"norm",value:function value(){return RE(this.x,this.y,this.z,this.w);}}]);}();function AN(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return BL(e)?new zN(e,t,i,r):new zN(e.x,e.y,e.z,e.w);}var UN=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],RN=function(){function e(t){if(Xk(this,e),Wk(this,"a",1),Wk(this,"b",0),Wk(this,"c",0),Wk(this,"d",1),Wk(this,"e",0),Wk(this,"f",0),Wk(this,"m11",1),Wk(this,"m12",0),Wk(this,"m13",0),Wk(this,"m14",0),Wk(this,"m21",0),Wk(this,"m22",1),Wk(this,"m23",0),Wk(this,"m24",0),Wk(this,"m31",0),Wk(this,"m32",0),Wk(this,"m33",1),Wk(this,"m34",0),Wk(this,"m41",0),Wk(this,"m42",0),Wk(this,"m43",0),Wk(this,"m44",1),Wk(this,"is2D",void 0),t||(t=UN),TL(t));else{if(!bL(t))throw new Error("DefaultMatrix error.");WN(t,this);}}return Yk(e,[{key:"isIdentity",get:function get(){for(var e=this.toArray(),t=0;t<16;t++)if(e[t]!==UN[t])return!1;return!0;}},{key:"translate",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.clone().translateSelf(e,t,i);}},{key:"scale",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return CL(t)&&(t=e),this.clone().scaleSelf(e,t,i,r,n,o);}},{key:"scale3d",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return this.clone().scale3dSelf(e,t,i,r);}},{key:"rotate",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;return this.clone().rotateSelf(e,t,i);}},{key:"rotateFromVector",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.clone().rotateFromVectorSelf(e,t);}},{key:"rotateAxisAngle",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return this.clone().rotateAxisAngleSelf(e,t,i,r);}},{key:"skewX",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.clone().skewXSelf(e);}},{key:"skewY",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.clone().skewYSelf(e);}},{key:"multiply",value:function value(e){return this.clone().multiplySelf(e);}},{key:"flipX",value:function value(){return this.clone().multiplySelf(new e([-1,0,0,1,0,0]));}},{key:"flipY",value:function value(){return this.clone().multiplySelf(new e([1,0,0,-1,0,0]));}},{key:"inverse",value:function value(){return this.clone().invertSelf();}},{key:"transformPoint",value:function value(){return EN(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).matrixTransform(this);}},{key:"toFloat32Array",value:function value(){var e=this.toArray();return new Float32Array(e);}},{key:"toFloat64Array",value:function value(){var e=this.toArray();return new Float64Array(e);}},{key:"toJSON",value:function value(){}},{key:"multiplySelf",value:function value(){var e=HN(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return this.setFromMatrix(e),this;}},{key:"preMultiplySelf",value:function value(){var e=HN(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},this);return this.setFromMatrix(e),this;}},{key:"translateSelf",value:function value(){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,t=function(){return{m11:1,m21:0,m31:0,m41:arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,m12:0,m22:1,m32:0,m42:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,m13:0,m23:0,m33:1,m43:arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,m14:0,m24:0,m34:0,m44:1};}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e);return this.multiplySelf(t),e&&(this.is2D=!1),this;}},{key:"scaleSelf",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this.translateSelf(r,n,o),CL(t)&&(t=e);var a=function(){return{m11:arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,m21:0,m31:0,m41:0,m12:0,m22:arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,m32:0,m42:0,m13:0,m23:0,m33:arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,m43:0,m14:0,m24:0,m34:0,m44:1};}(e,t,i);return this.multiplySelf(a),this.translateSelf(-r,-n,-o),1!==i&&(this.is2D=!1),this;}},{key:"scale3dSelf",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return this.scaleSelf(e,e,e,t,i,r);}},{key:"rotateSelf",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;CL(t)&&CL(i)&&(i=e,e=0,t=0),CL(t)&&(t=0),CL(i)&&(i=0),0===e&&0===t||(this.is2D=!1);var r=FN(i,[0,0,1]),n=FN(t,[0,1,0]),o=FN(e,[1,0,0]);return this.multiplySelf(r),this.multiplySelf(n),this.multiplySelf(o),this;}},{key:"rotateFromVectorSelf",value:function value(){var e=VN(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0),t=VN(1,0),i=FN(e.angle(t),[0,0,1]);return this.multiplySelf(i),this;}},{key:"rotateAxisAngleSelf",value:function value(){var e=FN(arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,[arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0]);return this.multiplySelf(e),this;}},{key:"skewXSelf",value:function value(){var e=jN(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,0);return this.multiplySelf(e),this;}},{key:"skewYSelf",value:function value(){var e=jN(0,arguments.length>0&&void 0!==arguments[0]?arguments[0]:0);return this.multiplySelf(e),this;}},{key:"invertSelf",value:function value(){var e=function(e){if(e[0].length!==e.length)throw new Error();for(var t=NN(e),i=function(e,t,i){if(e[0].length!==e.length)throw new Error("Not square matrix.");for(var r=e.length,n=$E(t=cP(i=new Array(r)).call(i,0)).call(t,function(e){var t;return cP(t=new Array(r)).call(t,0);}),o=0;ou[1].z&&(t.x*=-1),u[0].z>u[2].x&&(t.y*=-1),u[1].x>u[0].y&&(t.z*=-1),t.x<.001&&t.x>=0&&t.y<.001&&t.y>=0){var h=Math.atan2(u[0].y,u[0].x);l={x:0,y:0,z:Number(PN(h).toFixed(3))};}else l=t.toEuler();return{rotation:l,scale:i,translation:n,skew:r,quaternion:t,perspective:e};}},{key:"multiplyVector",value:function value(e){var t=this,i=e.x,r=e.y,n=e.z,o=e.w;return{x:t.m11*i+t.m21*r+t.m31*n+t.m41*o,y:t.m12*i+t.m22*r+t.m32*n+t.m42*o,z:t.m13*i+t.m23*r+t.m33*n+t.m43*o,w:t.m14*i+t.m24*r+t.m34*n+t.m44*o};}},{key:"transpose",value:function value(){var e=this.clone();return e.transposeSelf(),e;}},{key:"transposeSelf",value:function value(){var e=this.m11,t=this.m21,i=this.m31,r=this.m41,n=this.m12,o=this.m22,a=this.m32,s=this.m42,u=this.m13,l=this.m23,c=this.m33,h=this.m43,d=this.m14,f=this.m24,v=this.m34,g=this.m44;return this.setFromMatrix({m11:e,m21:n,m31:u,m41:d,m12:t,m22:o,m32:l,m42:f,m13:i,m23:a,m33:c,m43:v,m14:r,m24:s,m34:h,m44:g}),this;}},{key:"normalize",value:function value(){var e=this,t=e.m44;e.m11/=t,e.m12/=t,e.m13/=t,e.m14/=t,e.m21/=t,e.m22/=t,e.m23/=t,e.m24/=t,e.m31/=t,e.m32/=t,e.m33/=t,e.m34/=t,e.m41/=t,e.m42/=t,e.m43/=t,e.m44/=t;}},{key:"getTranslation",value:function value(){return VN(this.m41,this.m42,this.m43);}},{key:"getRotation",value:function value(){var e=this,t=.5*Math.pow(e.m11+e.m22+e.m33+1,.5);return DN(.25*(e.m23-e.m32)/t,.25*(e.m31-e.m13)/t,.25*(e.m12-e.m21)/t,t);}},{key:"getScaling",value:function value(){var e=this;return VN(RE(e.m11,e.m12,e.m13),RE(e.m21,e.m22,e.m23),RE(e.m31,e.m32,e.m33));}},{key:"toEuler",value:function value(){var e=this.getRotation().toEuler();return VN(e.x,e.y,e.z);}}],[{key:"fromQuat",value:function value(t){var i=t.x,r=t.y,n=t.z,o=t.w,a=new e();return a.m11=1-2*(r*r+n*n),a.m12=2*(i*r+n*o),a.m13=2*(i*n-r*o),a.m21=2*(i*r-n*o),a.m22=1-2*(i*i+n*n),a.m23=2*(r*n+i*o),a.m31=2*(i*n+r*o),a.m32=2*(r*n-i*o),a.m33=1-2*(i*i+r*r),a.setFromMatrix(a),a;}},{key:"fromMatrix",value:function value(t){var i=new e();return i.setFromMatrix(t),i.is2D=!!t.is2D,i;}},{key:"fromFloat32Array",value:function value(t){var i=new e();return WN(t,i),i;}},{key:"fromFloat64Array",value:function value(t){var i=new e();return WN(t,i),i;}}]);}();function LN(e,t,i,r){return{x:i*e.x+r*t.x,y:i*e.y+r*t.y,z:i*e.z+r*t.z};}function NN(e){var t;if(e.length!==e[0].length)throw new Error();var i=e.length,r=0;if(i>3)for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=e.length,a=$E(t=cP(i=new Array(o-1)).call(i,0)).call(t,function(e){var t;return cP(t=new Array(o-1)).call(t,0);}),s=0;s0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,1];e=xN(e);var i=Math.sin(e/2)*Math.cos(e/2),r=Math.pow(Math.sin(e/2),2),n=Gb(t,3),o=n[0],a=n[1],s=n[2];return{m11:1-2*(Math.pow(a,2)+Math.pow(s,2))*r,m21:2*(o*a*r-s*i),m31:2*(o*s*r+a*i),m41:0,m12:2*(o*a*r+s*i),m22:1-2*(Math.pow(o,2)+Math.pow(a,2))*r,m32:2*(a*s*r-o*i),m42:0,m13:2*(o*s*r-a*i),m23:2*(a*s*r+o*i),m33:1-2*(Math.pow(o,2)+Math.pow(a,2))*r,m43:0,m14:0,m24:0,m34:0,m44:1};}function jN(e,t){var i=new RN();return e&&(i.m21=Math.tan(xN(e))),t&&(i.m12=Math.tan(xN(t))),i;}function YN(e,t,i){var r=e.x-t.x,n=e.y-t.y,o=(i.x-e.x)*r+(i.y-e.y)*n;return o/=r*r+n*n,new IN(e.x+o*r,e.y+o*n);}function XN(e,t){return Math.pow(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2),.5);}function qN(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);}var ZN=function(){return Yk(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;Xk(this,e),Wk(this,"x",0),Wk(this,"y",0),Wk(this,"left",0),Wk(this,"top",0),Wk(this,"right",0),Wk(this,"bottom",0),Wk(this,"width",0),Wk(this,"height",0),this.update(t,i,r,n);},[{key:"update",value:function value(e,t,i,r){this.x=e,this.y=t,this.left=e,this.top=t,this.right=e+i,this.bottom=t+r,this.width=i,this.height=r;}},{key:"toJSON",value:function value(){}}]);}();function _N(e,t,i,r,n){var o=Math.cos,a=Math.sin;return{x:(e-i)*o(n)-(t-r)*a(n)+i,y:(e-i)*a(n)+(t-r)*o(n)+r};}var GN=function(){return Yk(function e(t){Xk(this,e),Wk(this,"uid",void 0),Wk(this,"children",void 0),this.uid=t.uid,this.children=t.children||[];},[{key:"append",value:function value(e){var t=this.children;return OI(t).call(t,e)<0&&(t.push(e),!0);}},{key:"insert",value:function value(e,t){var i=this.children;return!(t<0||(t>i.length&&(t=i.length),gE(i).call(i,t,0,e),0));}},{key:"remove",value:function value(e){var t=this.children,i=OI(t).call(t,e);return!(i<0||(gE(t).call(t,i,1),0));}},{key:"clear",value:function value(){return this.children=[],!0;}},{key:"move",value:function value(e,t){if(e===t)return!0;var i=this.children,r=Gb(gE(i).call(i,e,1),1)[0];return gE(i).call(i,t,0,r),!0;}},{key:"switch",value:function value(e,t){if(e===t)return!0;var i=this.children,r=i[e];return i[e]=i[t],i[t]=r,!0;}},{key:"reorder",value:function value(e){var t=this.children,i=e.length,r=[],n=0;if(t.length!==i||0===i)return!1;for(var o=0;o1?n-1:0),a=1;a-1&&(clearTimeout(this.tasks[r].timer),this.tasks[r].timer=null,gE(i=this.tasks).call(i,r,1));}}]);}())(),JN=function(){return Yk(function e(t,i){Xk(this,e),Wk(this,"isDestroyed",!1),Wk(this,"data",void 0),Wk(this,"table",["database","table","item"]),Wk(this,"dbName",void 0),Wk(this,"tableName",void 0),this.data={},this.dbName=t,this.tableName=i,this.createDatabase(t,i);},[{key:"destroy",value:function value(){if(!this.isDestroyed){for(var e=0,t=oB(this.data);e1&&void 0!==arguments[1]?arguments[1]:[],i=this.getTag(e);return i||(i=new nO({name:e,children:t}),this.tags.push(i)),i;}},{key:"removeTag",value:function value(e){var t,i,r=this.getTag(e);if(!r)return!1;this.hooks.beforeRemoveTag.emit(r);var n=EE(t=this.tags).call(t,function(t){return t.name===e;});return e===this.defaultName&&(this.defaultName=null,this.selectedUid=null),gE(i=this.tags).call(i,n,1),!0;}},{key:"renameTag",value:function value(e,t){if(!TL(e)||!TL(t))return!1;var i=this.isTagExisted(t),r=this.getTag(e);return!(!r||i||(r.name=t,this.hooks.afterRenameTag.emit(r),0));}},{key:"getTag",value:function value(e){var t;return xP(t=this.tags).call(t,function(t){return t.name===e;});}},{key:"getTagByUid",value:function value(e){var t;return xP(t=this.tags).call(t,function(t){return t.uid===e;});}},{key:"getTagList",value:function value(){var e;return RI(e=this.tags).call(e);}},{key:"setDefaultTag",value:function value(e){if(!e)return this.defaultName=null,this.defaultUid=null,!0;var t=this.getTag(e);return!!t&&(this.defaultName=e,this.defaultUid=t.uid,!0);}},{key:"getDefaultTag",value:function value(){return this.defaultName;}},{key:"isTagExisted",value:function value(e){return!!this.getTag(e);}}]);}(),aO=function(){return Yk(function e(){Xk(this,e);},[{key:"apply",value:function value(e){var t=e.hooks,i={beforeStatus:null,afterStatus:null,operation:null,docUid:null},r=function r(e){i.beforeStatus={uids:e.uids,selectedUids:[],currentUid:"",modifiedUid:e.modifiedUid,removedUids:e.removedUids};},n=function n(t){i.afterStatus={uids:t.uids,selectedUids:[],currentUid:"",modifiedUid:t.modifiedUid,removedUids:t.removedUids},i.docUid=t.docUid,i.operation=t.operation,i.docType=t.docType,i.docName=t.docName,e.emit("bufferChanged",Fk({},i)),i={beforeStatus:null,afterStatus:null,operation:null,docUid:null};};t.beforeBufferChanged.on(r),t.afterBufferChanged.on(n),t.destroy.on(function(){t.beforeBufferChanged.off(r),t.afterBufferChanged.off(n);});}}]);}(),sO=function(){return Yk(function e(){Xk(this,e);},[{key:"apply",value:function value(e){var t=e.hooks;e.customStore=new QN();var i=function i(t){var i=t.data;$k(i).call(i,function(t){var i=t.customData;i||(i={}),e.customStore.set(t.uid,i);});},r=function r(t){var i=t.removedUids;$k(i).call(i,function(t){e.customStore.remove(t);});},n=function n(t){var i=t.data.customData;i&&e.customStore.update(t.modifiedUid,i);};t.loadSource.on(i),t.removeSource.on(r),t.updateSource.on(n),t.destroy.on(function(){t.loadSource.off(i),t.removeSource.off(r),t.updateSource.off(n);});}}]);}(),uO=function(e){function t(){var e;return Xk(this,t),Wk(e=cL(this,t,[{uid:WL(),children:[]}]),"name","dvs-default"),Wk(e,"isDestroyed",!1),Wk(e,"type",void 0),e;}return _b(t,e),Yk(t,[{key:"destroy",value:function value(){this.isDestroyed||(this.isDestroyed=!0);}}]);}(GN),lO=function(){return Yk(function e(){Xk(this,e);},[{key:"apply",value:function value(e){e.defaultFile=new uO();var t=e.hooks,i=function i(t){var i,r,n,o=t.filename,a=t.index,s=t.data;if(CL(o)){var u=$E(s).call(s,function(e){return e.uid;});void 0===a?(i=e.defaultFile.children).push.apply(i,Kb(u)):gE(r=e.defaultFile.children).apply(r,lS(n=[a,0]).call(n,Kb(u)));var l={docUid:e.defaultFile.uid,sourceUids:u,type:"default",index:a};e.hooks.loadToDoc.emit(l);}},r=function r(t){var i=t.removedUids,r=[];$k(i).call(i,function(t){var i=e.statusStore.get(t);i&&i.ownerDefaultFile&&(e.defaultFile.remove(t),r.push(t));}),r.length&&e.hooks.removeFromDoc.emit({docUid:e.defaultFile.uid,sourceUids:i,type:"default"});};t.loadSource.on(i),t.removeSource.on(r),t.destroy.on(function(){t.loadSource.off(i),t.removeSource.off(r);});}}]);}(),cO=function(){return Yk(function e(){Xk(this,e);},[{key:"apply",value:function value(e){e.dir=new tO(),this.listenDirectoryHooks(e),this.listenSpaceHooks(e);}},{key:"listenDirectoryHooks",value:function value(e){var t=e.dir.hooks,i=function i(t){var i;$k(i=t.children).call(i,function(i){var r=e.statusStore.get(i);r&&r.ownerFiles.remove(t.uid);}),e.hooks.removeDoc.emit(t);},r=function r(t){e.hooks.renameDoc.emit(t);};t.beforeRemoveFile.on(i),t.afterRenameFile.on(r),t.destroy.on(function(){t.beforeRemoveFile.off(i),t.afterRenameFile.off(r);});}},{key:"listenSpaceHooks",value:function value(e){var t=e.hooks,i=function i(t){var i=t.data,r=t.filename,n=t.index;if(!CL(r)){var o=e.dir.getFile(r);e.hooks.beforeBufferChanged.emit({docType:"file",docUid:null==o?void 0:o.uid,uids:Kb((null==o?void 0:o.children)||[]),operation:"add"});var a=$E(i).call(i,function(e){return e.uid;}),s=e.dir.appendChildrenToFile(r,a,n),u={docUid:s.uid,sourceUids:a,type:"file",index:n};e.hooks.loadToDoc.emit(u),e.hooks.afterBufferChanged.emit({docType:"file",docName:r,docUid:null==s?void 0:s.uid,uids:Kb((null==s?void 0:s.children)||[]),operation:"add"});}},r=function r(t){var i=t.removedUids,r={};$k(i).call(i,function(t){var i,n,o=e.statusStore.get(t);o&&$k(i=RI(n=o.ownerFiles.children).call(n)).call(i,function(e){r[e]||(r[e]=[]),r[e].push(t);});});for(var n=0,o=oB(r);n-1&&gE(t).call(t,i,1);}},{key:"removeViewer",value:function value(e){var t=this.owners,i=OI(t).call(t,e);i>-1&&gE(t).call(t,i,1);}},{key:"setVisible",value:function value(e){var t;OI(t=this.visible).call(t,e)<0&&this.visible.push(e);}},{key:"cancelVisible",value:function value(e){var t,i,r=OI(t=this.visible).call(t,e);r>-1&&gE(i=this.visible).call(i,r,1);}},{key:"setPreload",value:function value(e){var t;OI(t=this.preload).call(t,e)<0&&this.preload.push(e);}},{key:"cancelPreload",value:function value(e){var t,i,r=OI(t=this.preload).call(t,e);r>-1&&gE(i=this.preload).call(i,r,1);}},{key:"reset",value:function value(){this.minData=null,this.oriData=null,this.img=null,this.activeOri=!1,this.activeMin=!1,this.minTask=null,this.oriTask=null,this.operations=[];}}]);}(),fO=function(){return Yk(function e(){Xk(this,e);},[{key:"apply",value:function value(e){var t=e.hooks;e.statusStore=new QN();var i=function i(t){var i=t.data;t.filename,t.index,$k(i).call(i,function(t){var i=new dO(t);e.statusStore.set(t.uid,i);});},r=function r(t){var i=t.removedUids;$k(i).call(i,function(t){var i,r,n=e.statusStore.get(t);n&&(mN(n.minData),mN(n.oriData),n.ownerFiles.clear(),n.ownerTags.clear(),n.ownerDefaultFile=!1,null!==(i=n.img)&&void 0!==i&&i.src&&(n.img.src=""),null!==(r=n.minImg)&&void 0!==r&&r.src&&(n.minImg.src=""),n.img=null,n.minImg=null),e.statusStore.remove(t);});},n=function n(t){var i=t.modifiedUid,r=t.data,n=t.revoke,o=e.statusStore.get(i);if(o){o.img=null,o.minImg=null;var a=r.metadata;a&&(o.metadata=Fk({},a),o.setRealTimeSize(a.width,a.height)),n&&(mN(o.oriData),mN(o.minData)),o.reset(),e.statusStore.update(i,o);}},o=function o(t){var i;$k(i=t.children).call(i,function(i){var r=e.statusStore.get(i);r&&("file"===t.type?r.ownerFiles.remove(t.uid):"tag"===t.type&&r.ownerTags.remove(t.uid));});},a=function a(t){var i=t.docUid,r=t.sourceUids,n=t.type;$k(r).call(r,function(t){var r=e.statusStore.get(t);r&&("file"===n?r.ownerFiles.append(i):"tag"===n?r.ownerTags.append(i):"default"===n&&(r.ownerDefaultFile=!0));});},s=function s(t){var i=t.docUid,r=t.sourceUids,n=t.type;$k(r).call(r,function(t){var r=e.statusStore.get(t);r&&("file"===n?r.ownerFiles.remove(i):"tag"===n?r.ownerTags.remove(i):"default"===n&&(r.ownerDefaultFile=!0));});};t.loadSource.on(i),t.afterRemoveSource.on(r),t.updateSource.on(n),t.removeDoc.on(o),t.loadToDoc.on(a),t.removeFromDoc.on(s),t.destroy.on(function(){t.loadSource.off(i),t.afterRemoveSource.off(r),t.updateSource.off(n),t.removeDoc.off(o),t.loadToDoc.off(a),t.removeFromDoc.off(s);});}}]);}(),vO=function(){return Yk(function e(){Xk(this,e);},[{key:"apply",value:function value(e){var t=e.hooks;e.store=new JN("space_db","space_doc");var i=function i(t){var i=t.data;i&&$k(i).call(i,function(t){e.store.set(t.uid,t);});},r=function r(t){var i;$k(i=t.removedUids).call(i,function(t){e.store.remove(t);});},n=function n(t){e.store.update(t.modifiedUid,t.data);};t.loadSource.on(i),t.removeSource.on(r),t.updateSource.on(n),t.destroy.on(function(){t.loadSource.off(i),t.removeSource.off(r),t.updateSource.off(n);});}}]);}(),gO=function(){return Yk(function e(){Xk(this,e);},[{key:"apply",value:function value(e){e.tag=new oO(),this.listenSpaceHooks(e),this.listenTagHooks(e);}},{key:"listenTagHooks",value:function value(e){var t=e.tag.hooks,i=function i(t){var i;$k(i=t.children).call(i,function(i){var r=e.statusStore.get(i);r&&r.ownerFiles.remove(t.uid);}),e.hooks.removeDoc.emit(t);},r=function r(t){e.hooks.renameDoc.emit(t);};t.beforeRemoveTag.on(i),t.afterRenameTag.on(r),t.destroy.on(function(){t.beforeRemoveTag.off(i),t.afterRenameTag.off(r);});}},{key:"listenSpaceHooks",value:function value(e){var t=e.hooks,i=function i(t){var i=t.data,r=e.tag.defaultName;$k(i).call(i,function(e){var t;(e.tags||(e.tags=[]),r)&&OI(t=e.tags).call(t,r)<0&&e.tags.push(r);});},r=function r(t){var i=t.data;$k(i).call(i,function(t){var i;null!==(i=t.tags)&&void 0!==i&&$k(i).call(i,function(i){var r=e.tag.getTag(i);e.hooks.beforeBufferChanged.emit({uids:Kb((null==r?void 0:r.children)||[]),operation:"add"}),e.tag.appendChildToTag(i,t.uid);var n=e.tag.getTag(i),o={docUid:n.uid,sourceUids:[t.uid],type:"tag"};e.hooks.loadToDoc.emit(o),e.hooks.afterBufferChanged.emit({docType:"tag",docName:i,docUid:null==n?void 0:n.uid,uids:Kb((null==n?void 0:n.children)||[]),operation:"add"});}),t.tags.length=0;});},n=function n(t){var i=t.removedUids,r={};$k(i).call(i,function(t){var i,n,o=e.statusStore.get(t);o&&$k(i=RI(n=o.ownerTags.children).call(n)).call(i,function(e){r[e]||(r[e]=[]),r[e].push(t);});});for(var n=0,o=oB(r);n-1&&gE(a=r.tags).call(a,s,1),t.next=9,e.store.update(i,r);case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(0),console.log();case 14:case"end":return t.stop();}},t,null,[[0,11]]);}));return function(e){return t.apply(this,arguments);};}());}},u=function u(t){var i,r,n=e.statusStore.get(t.modifiedUid);n&&$k(i=RI(r=n.ownerTags.children).call(r)).call(i,function(i){var r=e.tag.getTagByUid(i);r&&(e.hooks.beforeBufferChanged.emit({uids:Kb(r.children),modifiedUid:t.modifiedUid,operation:"modify"}),e.hooks.afterBufferChanged.emit({docType:"tag",docName:r.name,docUid:i,uids:Kb(r.children),modifiedUid:t.modifiedUid,operation:"modify"}));});};t.beforeLoadSource.on(i),t.loadSource.on(r),t.removeSource.on(n),t.removeDoc.on(o),t.loadToDoc.on(a),t.removeFromDoc.on(s),t.updateSource.on(u),t.destroy.on(function(){t.beforeLoadSource.off(i),t.loadSource.off(r),t.removeSource.off(n),t.removeDoc.off(o),t.loadToDoc.off(a),t.removeFromDoc.off(s),t.updateSource.off(u);});}}]);}(),mO=function(e){function t(){var e;return Xk(this,t),Wk(yb(e=cL(this,t)),"uid",WL()),Wk(yb(e),"hooks",{init:SN.create(),destroy:SN.create(),beforeLoadSource:SN.create(),loadSource:SN.create(),afterLoadSource:SN.create(),beforeRemoveSource:SN.create(),removeSource:SN.create(),afterRemoveSource:SN.create(),beforeUpdateSource:SN.create(),updateSource:SN.create(),afterUpdateSource:SN.create(),beforeBufferChanged:SN.create(),afterBufferChanged:SN.create(),directoryChanged:SN.create(),tagChanged:SN.create(),openDoc:SN.create(),loadToDoc:SN.create(),removeFromDoc:SN.create(),removeDoc:SN.create(),renameDoc:SN.create(),move:SN.create(),afterMove:SN.create(),switch:SN.create(),afterSwitch:SN.create(),reorder:SN.create(),afterReorder:SN.create()}),Wk(yb(e),"dir",void 0),Wk(yb(e),"tag",void 0),Wk(yb(e),"store",void 0),Wk(yb(e),"customStore",void 0),Wk(yb(e),"metadataStore",void 0),Wk(yb(e),"statusStore",void 0),Wk(yb(e),"defaultFile",void 0),Wk(yb(e),"plugins",[]),Wk(yb(e),"imageLoader",void 0),e.initPlugins(),e.hooks.init.emit(),e;}return _b(t,e),Yk(t,[{key:"destroy",value:function value(){this.hooks.destroy.emit();}},{key:"initPlugins",value:function value(){new vO().apply(this),new fO().apply(this),new sO().apply(this),new hO().apply(this),new aO().apply(this),new lO().apply(this),new cO().apply(this),new gO().apply(this);}},{key:"setImageLoader",value:function value(e){this.imageLoader=e;}},{key:"getCustomData",value:function value(e){return this.customStore.get(e);}},{key:"setCustomData",value:function value(e,t){return this.customStore.set(e,t);}},{key:"getMetadata",value:function value(e){return this.metadataStore.get(e);}},{key:"setMetadata",value:function value(e,t){return this.metadataStore.set(e,t);}},{key:"createStore",value:function value(e){var t=e.type,i=void 0===t?"sync":t,r=e.tableName,n=e.dbName;return"sync"===i?new QN():n&&r?new JN(n,r):null;}},{key:"loadSource",value:function value(e,t){if(CL(e))return[];var i=e.data;if(!bL(i))return[];var r=[];return $k(i).call(i,function(e){e.uid=WL(),r.push(e.uid);}),ML(t)&&t(r),this.hooks.beforeLoadSource.emit(e),this.hooks.loadSource.emit(e),this.hooks.afterLoadSource.emit(e),r;}},{key:"removeSource",value:function value(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];TL(e)&&(e=[e]);var i={removedUids:e,docUid:"",trigger:this.uid,operation:"remove"};return this.hooks.beforeRemoveSource.emit(i),this.hooks.removeSource.emit(i),t&&this.hooks.afterRemoveSource.emit(i),!0;}},{key:"updateSource",value:function value(e,t){var i={modifiedUid:e,data:t,revoke:!(arguments.length>2&&void 0!==arguments[2])||arguments[2],operation:"modify"};return this.hooks.beforeUpdateSource.emit(i),this.hooks.updateSource.emit(i),this.hooks.afterUpdateSource.emit(i),!0;}},{key:"getSource",value:function value(e){return this.store.get(e);}},{key:"openDefault",value:function value(e){var t={node:this.defaultFile,type:"default",config:e};this.hooks.openDoc.emit(t);}},{key:"createFile",value:function value(e){return this.dir.createFile(e);}},{key:"removeFile",value:function value(e){return this.dir.removeFile(e);}},{key:"renameFile",value:function value(e,t){return this.dir.renameFile(e,t);}},{key:"openFile",value:function value(e,t){var i=this.getFile(e);if(!i)return!1;var r={node:i,type:"file",config:t};return this.hooks.openDoc.emit(r),!0;}},{key:"movePagesToFile",value:function value(e,t,i,r){var n=this,o=this.getFile(e),a=this.getFile(i);if(!o||!a)return!1;for(var s=0;s=o.children.length)return!1;if(r<0)return!1;var u=$E(t).call(t,function(e){return o.children[e];});$k(u).call(u,function(e){var t=n.statusStore.get(e);t&&t.ownerFiles.remove(o.uid);}),this.dir.removeChildFromFile(o.uid,u),this.hooks.removeFromDoc.emit({docUid:o.uid,sourceUids:u}),r>a.children.length&&(r=a.children.length);var l=this.dir.appendChildrenToFile(i,u,r),c={docUid:l.uid,sourceUids:u,type:"file",index:r,isSameDoc:e===i};return $k(u).call(u,function(e){var t=n.statusStore.get(e);t&&t.ownerFiles.append(l.uid);}),this.hooks.loadToDoc.emit(c),!0;}},{key:"getFile",value:function value(e){return this.dir.getFile(e);}},{key:"getFileList",value:function value(){return this.dir.getCurrentFileList();}},{key:"isFileExisted",value:function value(e){return this.dir.isFileExist(e);}},{key:"createTag",value:function value(e){return this.tag.createTag(e);}},{key:"removeTag",value:function value(e){for(var t=this.getTag(e).children||[],i=0;i=this.getHowManyImagesInBuffer())return this.setError("IndexOutOfRange"),!1;if(this.webViewer)return this.webViewer.myViewer.getUidByIndex(e);var t=this.getCurrentDataSet().children;return!(t&&t.length=v&&(f=v):f=v,this.isActiveFile&&(this.currentSelected=[f]);var g=this.space.loadSource({data:[{oriData:u,minData:l,metadata:n,customData:o}],filename:s,index:f},function(t){var i=Gb(t,1)[0];e.uuid=i;}),m=this.getHowManyImagesInBuffer();return this.isActiveTag&&(this.currentSelected=m>0?[m-1]:[]),g;}},{key:"insertImage",value:function value(e,t,i){var r;if(i&&i>=0)this.currentSelected=[i],r=this.space.loadSource({data:[e],filename:t,index:i});else{r=this.space.loadSource({data:[e],filename:t});var n=this.getHowManyImagesInBuffer();this.currentSelected=n>0?[n-1]:[];}return r[0];}},{key:"updateImage",value:function value(e,t){var i=e.imageUrl,r=e.minImageUrl,n=e.imageId,o=e.serverId,a=e.uidFromServer,s=e.uuid,u=Fk({},t);return s&&""!==s&&-1!==s?(this.space.updateSource(s,{oriData:i,minData:r,metadata:u,customData:{imageId:n,serverId:o,uidFromServer:a}}),s):(this.setError("IndexOutOfRange"),!1);}},{key:"removeImageByUid",value:function value(e){if(this.e(),this.webViewer){var t=this.webViewer.removePageByUid(e);return this.webViewer.resized(),this.emitViewerEvent(),t;}return this.space.removeSource(e);}},{key:"removeImageByIndex",value:function value(e){if(this.e(),e<0||e>=this.getHowManyImagesInBuffer())return this.setError("IndexOutOfRange"),!1;var t=this.getCurrentIndex(),i=!1;if(this.currentSelected=e===t&&0===e?this.getHowManyImagesInBuffer()>0?[0]:[]:e<=t?[t-1]:[t],this.webViewer)i=this.webViewer.removePageByIndexes(e),this.webViewer.resized(),this.emitViewerEvent();else{var r=this.getCurrentDataSet();if(!r)return!1;i=this.space.removeSource(r.children[e]);}return i||this.setError("Default"),i;}},{key:"removeSelectedImages",value:function value(e){this.e();var t=this.getSelectedImagesIndices();bL(e)&&e.length>0&&(t=e);var i=!1;if(this.webViewer)i=this.webViewer.removePageByIndexes(t),this.webViewer.resized(),this.emitViewerEvent();else{var r=[],n=this.getCurrentDataSet();if(!n)return!1;$k(t).call(t,function(e){n.children[e]&&n.children[e]&&r.push(n.children[e]);}),i=this.space.removeSource(r);}i||this.setError("Default");var o=this.getHowManyImagesInBuffer();return this.currentSelected=o>0?[o-1]:[],i;}},{key:"removeImageByIndexArr",value:function value(e){if(this.e(),!bL(e))return!1;var t=this.getCurrentDataSet();if(!t)return!1;var i,r=[];$k(e).call(e,function(e){var i=t.children[e];i&&r.push(i);}),(i=this.space.removeSource(r))||this.setError("Default"),this.webViewer&&(this.webViewer.resized(),this.emitViewerEvent());var n=this.getHowManyImagesInBuffer();return this.currentSelected=n>0?[n-1]:[],i;}},{key:"removeAllImages",value:function value(){this.e();var e=!1;if(this.currentSelected=[],this.webViewer)e=this.webViewer.removeAllPages(),this.webViewer.resized(),this.emitViewerEvent();else{var t=this.getCurrentDataSet();t&&(e=this.space.removeSource(Kb(t.children)));}return e||this.setError("Default"),e;}},{key:"tagImages",value:function value(e,t){this.e();var i=this.getHowManyImagesInBuffer();if(!bL(e))return this.setError("IndicesNotArray"),!1;if(!TL(t)||""===t)return this.setError("InvalidTagName"),!1;for(var r=0;r=i)return this.setError("IndexOutOfRange"),!1;}this.space.createTag(t);for(var o=0;o=0){var s=this.getUidByIndex(a);s&&""!==s&&-1!==$S(s,10)&&this.space.addTagToSource(s,t);}}return!0;}},{key:"removeImageTag",value:function value(e,t){if(this.e(),!BL(e))return this.setError("InvalidValue"),!1;if(e<0||e>this.getHowManyImagesInBuffer())return this.setError("IndexOutOfRange"),!1;var i=this.getUidByIndex(e),r=!1;return i&&""!==i&&-1!==i&&(r=this.space.removeTagFromSource(i,t)),r||this.setError("Default"),r;}},{key:"getDefaultTag",value:function value(){return this.space.getDefaultTag();}},{key:"setDefaultTag",value:function value(e){if(this.e(),!TL(e))return this.setError("InvalidValue"),!1;if(""===e)return this.space.setDefaultTag(null),!0;var t;return this.space.createTag(e),(t=this.space.setDefaultTag(e))||this.setError("Default"),t;}},{key:"removeTag",value:function value(e,t){var i=this;if(this.e(),!TL(e))return this.setError("InvalidValue"),!1;if(!CL(t)&&!bL(t))return this.setError("IndicesNotArray"),!1;if(!this.space.isTagExisted(e))return this.setError("TagNotExist"),!1;var r=this.currentTagName,n=!1,o=!1;if(r&&(n=r===e),CL(t))o=this.space.removeTag(e),n&&this.clearFilter();else{var a=[];$k(t).call(t,function(e){var t=i.getUidByIndex(e);-1!==t&&a.push(t);});for(var s=0;s<(null==a?void 0:a.length);s++)if(!(o=this.space.removeTagFromSource(a[s],e)))return!1;}return o||this.webViewer.setDefaultError(),o;}},{key:"renameTag",value:function value(e,t){if(this.e(),CL(e)||""===e)return this.setError("OldTagNameRequired"),!1;if(CL(t)||""===t)return this.setError("NewTagNameRequired"),!1;if(!this.space.isTagExisted(e))return this.setError("TagNotExist"),!1;if(this.space.isTagExisted(t))return this.setError("TagExist"),!1;var i;return e===this.currentTagName&&(this.currentTagName=t),(i=this.space.renameTag(e,t))?this.space.setDefaultTag(t):this.setError("Default"),i;}},{key:"getTagContents",value:function value(e){return this.e(),e&&TL(e)&&""!==e?this.space.getTag(e).children:[];}},{key:"getTagList",value:function value(){var e=this;this.e();var t=this.space.getTagList(),i=[];return t?$k(t).call(t,function(t){var r,n=[];$k(r=t.children).call(r,function(t){var i=e.getCustomDataByUid(t);if(i){var r=i.uidFromServer;n.push(r);}}),i.push({name:t.name,imageIds:n});}):i=[],i;}},{key:"getTagListByIndex",value:function value(e){if(!BL(e))return!1;var t=this.getUidByIndex(e);return this.space.getSourceTags(t);}},{key:"clearFilter",value:function value(){this.e(),this.currentTagName="",this.space.setDefaultTag(null);var e,t=this.getCurrentFileName();return""===t&&(t="dynamsoft-default-document"),(e=this.openDocument(t))||this.setError("Default"),e;}},{key:"filterImagesByTag",value:function value(e,t,i){this.e();var r=!1;if(CL(e)||null===e||""===e){this.currentTagName="";var n=this.getCurrentFileName();""===n&&(n="dynamsoft-default-document"),(r=this.openDocument(n))?ML(t)&&t():(this.setError("Default"),ML(i)&&i());}else{var o,a;if(!this.space.isTagExisted(e))return this.setError("TagNotExist"),ML(i)&&i(),!1;if(this.isActiveTag=!0,this.isActiveFile=!1,this.currentTagName=e,this.setDefaultTag(e),r=this.space.openTag(e,null==this||null===(o=this.webViewer)||void 0===o||null===(a=o.myViewer)||void 0===a?void 0:a.uid)){var s=this.space.getTag(e);if(s){var u,l=(null==s||null===(u=s.children)||void 0===u?void 0:u.length)||0;this.currentSelected=l>0?[l-1]:[];}ML(t)&&t();}else this.setError("Default"),ML(i)&&i();}return this.webViewer&&this.webViewer.render(),r;}},{key:"createDocument",value:function value(e){if(this.e(),!e||""===e){var t=BL(e)?"FileNameNotString":"FileNameCannotEmpty";return this.setError(t),!1;}return TL(e)?this.space.isFileExisted(e)?(this.setError("FileExist"),!1):!!this.space.createFile(e)||(this.setError("Default"),!1):(this.setError("FileNameNotString"),!1);}},{key:"openDocument",value:function value(e,t){var i,r;if(this.e(),!e||""===e){var n=BL(e)?"FileNameNotString":"FileNameCannotEmpty";return this.setError(n),!1;}if(!TL(e))return this.setError("FileNameNotString"),!1;if(!this.space.isFileExisted(e))return this.setError("FileNotExist"),!1;var o=t&&""!==t?t:null==this||null===(i=this.webViewer)||void 0===i||null===(r=i.myViewer)||void 0===r?void 0:r.uid,a=this.space.getFile(e);if(a){var s,u=null==a||null===(s=a.children)||void 0===s?void 0:s.length;this.currentSelected=u>0?[u-1]:[];}return this.space.openFile(e,{viewerUid:o})?(this.currentFileName=e,this.isActiveFile=!0,this.isActiveTag=!1,!0):(this.setError("Default"),!1);}},{key:"getDocumentContents",value:function value(e){return this.e(),e&&TL(e)&&""!==e?this.space.getFile(e).children:[];}},{key:"renameDocument",value:function value(e,t){return this.e(),TL(e)&&TL(t)?(e&&""!==e&&t&&""!==t||this.setError("FileNameCannotEmpty"),this.space.isFileExisted(e)?this.space.isFileExisted(t)?(this.setError("FileExist"),!1):this.space.renameFile(e,t)?(this.currentFileName===e&&(this.currentFileName=t),!0):(this.setError("Default"),!1):(this.setError("FileNotExist"),!1)):(this.setError("FileNameNotString"),!1);}},{key:"removeDocument",value:function value(e){if(this.e(),!e||!TL(e))return this.setError("FileNameNotString"),!1;if(!this.space.isFileExisted(e))return this.setError("FileNotExist"),!1;var t=this.space.removeFile(e);return t?(t&&this.webViewer&&this.webViewer.resized(),this.currentFileName===e&&(this.currentFileName=""),!0):(this.setError("Default"),!1);}},{key:"getDocumentInfoList",value:function value(){var e=this;this.e();var t=this.space.getFileList(),i=[];return t?($k(t).call(t,function(t){if(t.children){for(var r=[],n=0;n=r)return this.setError("ParameterOutRange"),!1;t=!0;}return t?this.currentSelected=e:this.setError("Default"),t;}},{key:"selectAllImages",value:function value(){this.e();var e=!0;if(this.webViewer)e=this.webViewer.myViewer.selectAll(),this.currentSelected=this.webViewer.getSelectedImagesIndices();else{var t,i=this.getCurrentDataSet();this.currentSelected=NB(GB(t=new Array(i.children.length)).call(t));}return e||this.setError("Default"),e;}},{key:"moveImage",value:function value(e,t){this.e();var i=$S(e,10),r=$S(t,10);if(fS(e)||fS(t))return this.setError("InvalidIndex"),!1;var n=this.getHowManyImagesInBuffer();if(i<0||i>=n||r<0||r>n)return this.setError("IndexOutOfRange"),!1;var o=!1;if(this.webViewer)o=this.webViewer.myViewer.movePage(e,t);else{var a=this.getCurrentDataSet();if(!a)return!1;a.children.length>t&&(this.currentSelected=[t]),o=this.space.move({docUid:a.uid,type:a.type,from:e,to:t});}return o||this.setError("Default"),o;}},{key:"switchImage",value:function value(e,t){this.e();var i=$S(e,10),r=$S(t,10);if(fS(e)||fS(t))return this.setError("InvalidIndex"),!1;var n=this.getHowManyImagesInBuffer(),o=this.getCurrentIndex();if(i<0||i>=n||r<0||r>n)return this.setError("IndexOutOfRange"),!1;var a=!1;if(this.webViewer)a=this.webViewer.myViewer.switchPage(e,t);else{var s=this.getCurrentDataSet();if(!s)return!1;a=this.space.switch({docUid:s.uid,type:s.type,one:e,other:t});}a||this.setError("Default");var u=o;return i===o?u=r:r===o&&(u=i),this.currentSelected=[u],a;}},{key:"moveImageToFile",value:function value(e,t,i,r){if(!this.space.isFileExisted(e)||!this.space.isFileExisted(i))return this.setError("FileNotExist"),!1;t=Kb(new Pz(t));var n=this.getDocumentInfo(e).length;if(!bL(t)||t.length>n)return this.setError("ParameterOutRange"),!1;var o=this.getDocumentInfo(i).length,a=this.space.movePagesToFile(e,t,i,r);if(!this.webViewer&&this.isActiveFile){var s=this.getHowManyImagesInBuffer();e===this.currentFileName&&(this.currentSelected=s>0?[s-1]:[]),i===this.currentFileName&&(BL(r)&&r=0?this.currentSelected=[r+t.length-1]:this.currentSelected=s>0?[s-1]:[]);}return a;}}]);}(),PO=function(){return Yk(function e(t){var i,r,n,o,a=this;Xk(this,e),Wk(this,"uid",null),Wk(this,"mode","default"),Wk(this,"vertexes",[]),Wk(this,"midpoints",[]),Wk(this,"probePoints",[]),Wk(this,"slopeRatio",[]),Wk(this,"sensorRadius",4),Wk(this,"isPointSelected",!1),Wk(this,"activeProbePoint",null),Wk(this,"isConvex",!0),Wk(this,"isMoveBox",!1),Wk(this,"width",0),Wk(this,"height",0),Wk(this,"zoom",1),Wk(this,"keepAspectRatio",!1),Wk(this,"aspectRatio",0),Wk(this,"startX",null),Wk(this,"startY",null),Wk(this,"lastX",null),Wk(this,"lastY",null),Wk(this,"lastWhr",1),Wk(this,"b1",void 0),Wk(this,"b2",void 0),Wk(this,"k1",void 0),Wk(this,"k2",void 0),this.uid=WL(),$k(i=eS(t)).call(i,function(e){a[e]=t[e];}),this.midpoints=BO(this.vertexes),this.probePoints=lS(r=RI(n=this.vertexes).call(n)).call(r,RI(o=this.midpoints).call(o)),this.slopeRatio=DO(this.vertexes);},[{key:"getRect",value:function value(){if("free"===this.mode)return null;var e=this.getBounds(),t=e.minX,i=e.maxX,r=e.minY;return{x:t,y:r,width:i-t||1,height:e.maxY-r||1};}},{key:"isBoxSelected",value:function value(e,t){var i=this.isPointOnBox(e,t),r=this.isCtrlPointSelected(e,t);return null!==r?r:i?8:-1;}},{key:"isCtrlPointSelected",value:function value(e,t){for(var i=gN(),r=this.sensorRadius,n=this.zoom,o=this.probePoints,a=this.width,s=this.height,u=r/n,l=HL(u,0,3*u)*i,c=HL(u,0,3*u)*i,h=0;h<8;h++){var d=o[2*h],f=o[2*h+1];if(e<=d+l&&e>=d-l&&t<=f+c&&t>=f-c&&e>=0-l&&e<=a+l&&t>=0-c&&t<=s+c)return h;}return null;}},{key:"checkOrientation",value:function value(e){if(e<0||e>7)return null;var t=this.getBounds(),i=t.minX,r=t.maxX,n=t.minY,o=t.maxY,a=this.probePoints,s=a[2*e],u=a[2*e+1],l=null,c=null;return s===r?l="e":s===i&&(l="w"),u===o?c="s":u===n&&(c="n"),e<4?c+l:c||l;}},{key:"onStartHandler",value:function value(e,t,i){if(void 0===i&&(i=this.isBoxSelected(e,t)),!(i<0)){this.startX=e,this.startY=t,this.lastX=e,this.lastY=t,8===i?(this.isPointSelected=!1,this.activeProbePoint=null,this.isMoveBox=!0):(this.isPointSelected=!0,this.activeProbePoint=i,this.isMoveBox=!1);var r=this.mode,n=this.probePoints,o=this.slopeRatio;if("free"===r&&i>3&&i<8){var a=i-4;this.k1=o[(a+1)%4],this.b1=n[(2*a+3)%8]-this.k1*n[(2*a+2)%8],this.k2=o[(a+3)%4],this.b2=n[(2*a+1)%8]-this.k2*n[(2*a+0)%8];}}}},{key:"onMoveHandler",value:function value(e,t,i){var r,n,o=this.isPointSelected,a=this.isMoveBox,s=this.probePoints,u=this.activeProbePoint,l=this.lastX,c=this.lastY,h=this.mode;if(o||a){var d=e-l,f=t-c;if(0!==d||0!==f){var v=RI(s).call(s);o?(void 0===i&&(i=u),"default"===h?v=this.movePointNormal(v,i,e,t):(v=this.movePointFree(v,i,e,t),this.slopeRatio=RI(r=DO(s)).call(r,0,4),this.isConvex=this.checkConvexity(v))):a&&(v=this.moveBox(v,d,f));var g=BO(v);this.probePoints=lS(n=RI(v).call(v,0,8)).call(n,g),this.midpoints=g,this.lastX=e,this.lastY=t;}}}},{key:"onEndHandler",value:function value(){var e,t,i,r,n=this.isPointSelected,o=this.isMoveBox,a=this.startX,s=this.startY,u=this.vertexes,l=this.midpoints,c=this.lastX,h=this.lastY;if(this.startX=0,this.startY=0,n||o){this.isPointSelected=!1,this.isMoveBox=!1,this.activeProbePoint=null;var d=RI(e=this.probePoints).call(e),f=this.checkConvexity(d);(a===c&&s===h||!f)&&(d=lS(t=RI(u).call(u)).call(t,l)),this.isConvex=!0,this.vertexes=RI(d).call(d,0,8),this.midpoints=BO(d),this.probePoints=lS(i=RI(d).call(d,0,8)).call(i,this.midpoints),this.slopeRatio=RI(r=DO(d)).call(r,0,4);}}},{key:"getBounds",value:function value(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.probePoints;return{minX:Math.min(e[0],e[2],e[4],e[6]),maxX:Math.max(e[0],e[2],e[4],e[6]),minY:Math.min(e[1],e[3],e[5],e[7]),maxY:Math.max(e[1],e[3],e[5],e[7])};}},{key:"movePointNormal",value:function value(e,t,i,r){i=Math.max(0,Math.min(this.width,i)),r=Math.max(0,Math.min(this.height,r));var n=0,o=0;if(this.keepAspectRatio){var a=this.getBounds(),s=a.minX,u=a.maxX,l=a.minY,c=a.maxY,h=this.checkOrientation(t),d=(u-s)/(c-l);0===d||d===1/0||d===-1/0||fS(d)?d=this.lastWhr:this.lastWhr=d,n=0,o=0;var f="w";if(t<4){if(n=i-e[2*t],o=r-e[2*t+1],0===n||0===o)return e;f="w";}else{var v=t-4;if("e"===h?(t=(v+1)%4,f="w"):"s"===h?(t=v,f="h"):"w"===h?(t=v,f="w"):"n"===h&&(t=(v+1)%4,f="h"),n=i-e[2*v],o=r-e[2*v+1],0===n||0===o)return e;}"h"===f?(n=o*d,"ne"!==h&&"sw"!==h&&"n"!==h&&"w"!==h||(n=-n)):(o=n/d,"ne"!==h&&"sw"!==h&&"n"!==h&&"w"!==h||(o=-o));var g=e[2*t]+n,m=e[2*t+1]+o,y=this.width,p=this.height;g<0?(n=0-e[2*t],o=0):g>y?(n=y-e[2*t],o=0):m<0?(o=0-e[2*t+1],n=0):m>p&&(o=p-e[2*t+1],n=0),e[2*t]+=n,e[2*t+1]+=o;var w=(t+1)%4,b=(t+3)%4;t%2?(e[2*w]+=n,e[2*b+1]+=o):(e[2*w+1]+=o,e[2*b]+=n);}else if(t<4){if(n=i-e[2*t],o=r-e[2*t+1],0===n&&0===o)return e;e[2*t]=i,e[2*t+1]=r;var k=(t+1)%4,S=(t+3)%4;t%2?(e[2*k]=i,e[2*S+1]=r):(e[2*k+1]=r,e[2*S]=i);}else{var x=t-4,C=this.slopeRatio[x%4];0===C?(e[(2*x+3)%8]=r,e[(2*x+1)%8]=r):C!==1/0&&C!==-1/0||(e[(2*x+2)%8]=i,e[(2*x+0)%8]=i);}return e;}},{key:"movePointFree",value:function value(e,t,i,r){i=Math.max(0,Math.min(this.width,i)),r=Math.max(0,Math.min(this.height,r));var n=RI(e).call(e);if(t<4){var o=i-e[2*t],a=r-e[2*t+1];if(0===o&&0===a)return e;e[2*t]=i,e[2*t+1]=r;}else{var s=t-4,u=this.slopeRatio[s%4],l=r-u*i,c=-l/u,h=l,d=e[(2*s+9)%8]-u*e[(2*s+8)%8],f=-d/u,v=this.k1,g=this.b1,m=this.k2,y=this.b2;0===u?(e[(2*s+3)%8]=r,v!==1/0&&v!==-1/0&&(e[(2*s+2)%8]=(r-g)/v),e[(2*s+1)%8]=r,m!==1/0&&m!==-1/0&&(e[(2*s+0)%8]=(r-y)/m)):u===1/0||u===-1/0?(e[(2*s+2)%8]=i,e[(2*s+3)%8]=v*i+g,e[(2*s+0)%8]=i,e[(2*s+1)%8]=m*i+y):(0===v?e[(2*s+2)%8]+=c-f:v===1/0||v===-1/0?e[(2*s+3)%8]+=h-d:(e[(2*s+2)%8]=(g-l)/(u-v),e[(2*s+3)%8]=(u*g-v*l)/(u-v)),0===m?e[(2*s+0)%8]+=c-f:m===1/0||m===-1/0?e[(2*s+1)%8]+=h-d:(e[(2*s+0)%8]=(y-l)/(u-m),e[(2*s+1)%8]=(u*y-m*l)/(u-m)));for(var p=0;p<4;p++){var w=e[2*p],b=e[2*p+1];if(w<0||w>this.width||b<0||b>this.height)return n;}}return e;}},{key:"moveBox",value:function value(e,t,i){var r=this.getBounds(e),n=r.minX,o=r.maxX,a=r.minY,s=r.maxY,u=this.width,l=this.height;n+t<0&&(t=0-n),o+t>u&&(t=u-o),a+i<0&&(i=0-a),s+i>l&&(i=l-s);for(var c=0;c<4;c++)e[2*c]+=t,e[2*c+1]+=i;return e;}},{key:"isPointOnBox",value:function value(e,t){var i=this.getBounds(),r=i.minX,n=i.maxX,o=i.minY,a=i.maxY;if(en||ta)return!1;if("free"===this.mode){for(var s=Kb(this.vertexes),u=Kb(this.midpoints),l=[],c=0;c<4;c++)l.push(gE(s).call(s,0,2)),l.push(gE(u).call(u,0,2));var h=function(e,t){var i,r,n,o,a=0,s=t.length;for(n=Gb(t,1)[0],i=1;i<=s;i++){o=t[i%s],e[0]>Math.min(n[0],o[0])&&e[0]<=Math.max(n[0],o[0])&&e[1]<=Math.max(n[1],o[1])&&n[0]!==o[0]&&(r=(e[0]-n[0])*(o[1]-n[1])/(o[0]-n[0])+n[1],(n[1]===o[1]||e[1]<=r)&&(a+=1)),n=o;}return a%2!=0;}([e,t],l);return h;}return!0;}},{key:"checkConvexity",value:function value(e){var t,i=Gb(e,8),r=i[0],n=i[1],o=i[2],a=i[3],s=i[4],u=i[5],l=i[6],c=i[7],h=(l-r)*(a-n)-(c-n)*(o-r),d=(r-o)*(u-a)-(n-a)*(s-o),f=(o-s)*(c-u)-(a-u)*(l-s),v=(s-l)*(n-c)-(u-c)*(r-l);if(h*d*f*v<0)return!1;var g=lS(t=RI(e).call(e)).call(t,RI(e).call(e,0,2)),m=this.slopeRatio;if(m.length)for(var y=0;y<2;y++)if(m[y]!==m[y+2]&&MO(RI(g).call(g,2*y,2*y+2),RI(g).call(g,2*y+2,2*y+4),RI(g).call(g,2*y+4,2*y+6),RI(g).call(g,2*y+6,2*y+8)))return!1;return h*d*f*v>0;}}]);}();function BO(e){for(var t,i=lS(t=RI(e).call(e,0,8)).call(t,e[0],e[1]),r=[],n=0;n<4;n++){var o=(i[2*n]+i[2*n+2])/2,a=(i[2*n+1]+i[2*n+3])/2;r.push(o,a);}return r;}function DO(e){for(var t,i=[],r=null,n=lS(t=RI(e).call(e,0,8)).call(t,e[0],e[1]),o=0;o<4;o++)r=n[2*o+3]-n[2*o+1]==0&&n[2*o+2]-n[2*o]==0?0:(n[2*o+3]-n[2*o+1])/(n[2*o+2]-n[2*o]),i.push(r);return i;}function MO(e,t,i,r){if(function(e,t,i,r){var n=Math.min,o=Math.max;return n(e[0],t[0])<=o(i[0],r[0])&&n(i[0],r[0])<=o(e[0],t[0])&&n(e[1],t[1])<=o(i[1],r[1])&&n(i[1],r[1])<=o(e[1],t[1]);}(e,t,i,r)&&function(e,t,i,r){var n=e[0]*(i[1]-t[1])+t[0]*(e[1]-i[1])+i[0]*(t[1]-e[1]),o=e[0]*(r[1]-t[1])+t[0]*(e[1]-r[1])+r[0]*(t[1]-e[1]);return!((n^o)>=0&&0!==n&&0!==o||(n=i[0]*(e[1]-r[1])+r[0]*(i[1]-e[1])+e[0]*(r[1]-i[1]),o=i[0]*(t[1]-r[1])+r[0]*(i[1]-t[1])+t[0]*(r[1]-i[1]),(n^o)>=0&&0!==n&&0!==o));}(e,t,i,r)){var n=(r[0]-i[0])*(e[1]-t[1])-(t[0]-e[0])*(i[1]-r[1]),o=(e[1]-i[1])*(t[0]-e[0])*(r[0]-i[0])+i[0]*(r[1]-i[1])*(t[0]-e[0])-e[0]*(t[1]-e[1])*(r[0]-i[0]);if(0===n||0===o){var a=zO(e,t),s=zO(i,r),u=a[0],l=a[1],c=s[0],h=s[1];if(l[0]===c[0]&&l[1]===c[1])return l;if(u[0]===h[0]&&u[1]===h[1])return u;if(AO(l,s)&&AO(c,a))return[c,l];if(AO(u,s)&&AO(h,a))return[u,h];if(AO(u,s)&&AO(l,s))return[u,l];if(AO(c,s)&&AO(h,s))return[c,h];}var d=o/n;return n=(e[0]-t[0])*(r[1]-i[1])-(t[1]-e[1])*(i[0]-r[0]),[d,(o=t[1]*(e[0]-t[0])*(r[1]-i[1])+(r[0]-t[0])*(r[1]-i[1])*(e[1]-t[1])-r[1]*(i[0]-r[0])*(t[1]-e[1]))/n];}return!1;}function zO(e,t){return e[0]===t[0]?e[1]=t[0][1]&&e[1]<=t[1][1]:e[0]>=t[0][0]&&e[0]<=t[1][0];}var UO={aspectRatio:1,keepAspectRatio:!1,keepAspectRatioEdit:!1,keepAspectRatioWithShift:!0,multipleCropping:!0,enableCreateBoxByPointer:!0,enableCursor:!0,enableMagnifier:!0,borderColor:"orange",borderWidth:2,background:"rgba(255,255,255,0)",dashLine:[5,2],ctrlSize:16,ctrlBorderWidth:2,ctrlBorderRadius:4,ctrlBorderColor:"orange",ctrlBackground:"rgba(255,0,0,0)",invalidCtrlBorderColor:"red",invalidBorderColor:"red",magnifier:{fixed:!1,fixedTop:0,fixedLeft:0,size:50,magnification:2}},RO=function(){return Yk(function e(t,i){Xk(this,e),Wk(this,"activeBoxId",null),Wk(this,"startX",null),Wk(this,"startY",null),Wk(this,"addNewFlag",null),Wk(this,"drawingFlag",!1),Wk(this,"lastKeepAspectRatio",!1),Wk(this,"area",null),Wk(this,"canvasItem",null),Wk(this,"cropBoxes",[]),Wk(this,"width",0),Wk(this,"height",0),Wk(this,"scrollTop",0),Wk(this,"scrollLeft",0),Wk(this,"zoom",1),Wk(this,"aspectRatio",0),Wk(this,"keepAspectRatio",!1),Wk(this,"keepAspectRatioEdit",!1),Wk(this,"mouseDown",!1),Wk(this,"cropSetting",{}),Wk(this,"currentBoxId",void 0),Wk(this,"unselectedCallback",null),Wk(this,"selectedCallback",null),this.width=t,this.height=i,this.cropSetting=_SL(UO);},[{key:"count",value:function value(){return this.cropBoxes.length;}},{key:"setCanvas",value:function value(e){this.canvasItem=e;}},{key:"setCanvasSize",value:function value(e,t){this.width=e,this.height=t,this.area||this.setArea(0,0,e,t);}},{key:"setKeepAspectRatio",value:function value(e){var t;this.keepAspectRatio=e,this.drawingFlag||$k(t=this.cropBoxes).call(t,function(t){t.keepAspectRatio=e;});}},{key:"setAspectRatio",value:function value(e){this.aspectRatio=e;}},{key:"setZoom",value:function value(e){var t;this.zoom=e,$k(t=this.cropBoxes).call(t,function(t){t.zoom=e;});}},{key:"setScrollTop",value:function value(e){this.scrollTop=e;}},{key:"setScrollLeft",value:function value(e){this.scrollLeft=e;}},{key:"setCropSetting",value:function value(){var e=NL(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},_SL(this.cropSetting));this.cropSetting=e;var t=this.cropSetting,i=t.keepAspectRatioEdit,r=t.keepAspectRatio;return this.keepAspectRatioEdit=i,r?(this.setKeepAspectRatio(!0),this.setAspectRatio(this.cropSetting.aspectRatio)):this.setKeepAspectRatio(!1),!0;}},{key:"getCropBoxes",value:function value(){var e,t=[];return $k(e=this.cropBoxes).call(e,function(e,i){var r=e.getRect();null!==r&&t.push({index:i,left:r.x,top:r.y,width:r.width,height:r.height});}),t;}},{key:"getRectArr",value:function value(){var e;return $E(e=this.cropBoxes).call(e,function(e,t){return Fk({index:t},e.getRect());});}},{key:"clear",value:function value(){var e;this.cropBoxes.length>0&&null!==(e=this.unselectedCallback)&&void 0!==e&&e.call(this),this.cropBoxes=[];}},{key:"addFreeBox",value:function value(e){var t=this.cropSetting,i=t.ctrlSize,r=t.ctrlHeight,n=t.ctrlWidth,o=i;(n||r)&&(o=Math.max(n,r));var a=new PO({vertexes:RI(e).call(e),width:this.area.width,height:this.area.height,sensorRadius:o/2,mode:"free"});return this.cropBoxes.push(a),a;}},{key:"addBox",value:function value(e){var t=this.cropSetting,i=t.ctrlSize,r=t.ctrlHeight,n=t.ctrlWidth,o=i;(n||r)&&(o=Math.max(n,r));var a=new PO({vertexes:RI(e).call(e),width:this.area.width,height:this.area.height,mode:"default",aspectRatio:this.aspectRatio,keepAspectRatio:this.keepAspectRatio,sensorRadius:o/2,zoom:this.zoom});return a.isScaled=!1,this.cropBoxes.push(a),a;}},{key:"removeBox",value:function value(e){var t=this.cropBoxes;return CL(e)?(this.clear(),!0):!(e<0||e>=t.length||(gE(t).call(t,e,1),0));}},{key:"getBoxByUid",value:function value(e){var t;return xP(t=this.cropBoxes).call(t,function(t){return t.uid===e;});}},{key:"setArea",value:function value(e,t,i,r){var n;this.area={left:e,top:t,width:i,height:r},$k(n=this.cropBoxes).call(n,function(e){e.width=i,e.height=r;});}},{key:"isInArea",value:function value(e,t){var i=this.area,r=i.width,n=i.height;return!(e<0||e>r||t<0||t>n);}},{key:"checkSelect",value:function value(e,t){var i;return EE(i=this.cropBoxes).call(i,function(i){return i.isBoxSelected(e,t)>-1;});}},{key:"checkSelectForCursor",value:function value(e,t){for(var i=this.cropBoxes.length-1;i>=0;i--){var r=this.cropBoxes[i],n=r.isBoxSelected(e,t);if(n>-1){var o="move";return n<8&&(o=r.checkOrientation(n)),{part:n,position:o,mode:r.mode};}}return null;}},{key:"checkSelectVertex",value:function value(e,t){for(var i=this.cropBoxes.length-1;i>=0;i--){var r=this.cropBoxes[i].isBoxSelected(e,t);if(r>-1&&r<4)return!0;}return!1;}},{key:"onStartHandler",value:function value(e,t,i){var r=this.area,n=r.width,o=r.height,a=this.checkSelect(e,t);if(e=HL(e,0,n),t=HL(t,0,o),this.startX=e,this.startY=t,this.mouseDown=!0,a<0)return i||this.clear(),this.activeBoxId=null,void(this.lastKeepAspectRatio&&!this.keepAspectRatio&&this.setKeepAspectRatio(!0));var s=this.cropBoxes[a].uid;this.currentBoxId=s,this.activeBoxId=s,this.getBoxByUid(s).onStartHandler(e,t),!this.keepAspectRatioEdit&&this.keepAspectRatio&&(this.lastKeepAspectRatio=this.keepAspectRatio,this.setKeepAspectRatio(!1));}},{key:"onMoveHandler",value:function value(e,t){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(this.mouseDown){var r=null,n=this.activeBoxId,o=this.startX,a=this.startY,s=this.aspectRatio,u=this.area,l=u.width,c=u.height;e=HL(e,0,l);var h=(t=HL(t,0,c))-a,d=e-o,f=2/this.zoom,v=null;if(n||(d<-f&&h<-f?v=0:d>f&&h<-f?v=1:d>f&&h>f?v=2:d<-f&&h>f&&(v=3),null!==v&&s>0&&(h=d/s,v%2&&(h=-d/s))),null!==v&&i){for(var g=[],m=v%2?[o,a,o,a+h,e,a+h,e,a]:[e,a+h,o,a+h,o,a,e,a],y=0;y<4;y++)g.push(m[2*(v+y)%8]),g.push(m[(2*(v+y)+1)%8]);return(r=this.addBox(g)).keepAspectRatio=this.keepAspectRatio&&s>0,this.drawingFlag=!0,this.addNewFlag=this.keepAspectRatio,this.currentBoxId=r.uid,this.activeBoxId=r.uid,r.onStartHandler(this.startX,this.startY,v),r.onMoveHandler(e,t,v),void(v=null);}this.activeBoxId&&(r=this.getBoxByUid(this.activeBoxId)),r&&r.onMoveHandler(e,t);}}},{key:"onEndHandler",value:function value(){var e;if(this.mouseDown&&this.activeBoxId){this.mouseDown=!1,this.drawingFlag=!1;var t=this.getBoxByUid(this.activeBoxId);t&&(null!==this.addNewFlag&&(t.keepAspectRatio=this.addNewFlag,this.addNewFlag=null),t.onEndHandler(),this.cropBoxes.length>0&&null!==(e=this.selectedCallback)&&void 0!==e&&e.call(this,this.getRectArr()),this.activeBoxId=null);}}}]);}(),LO=function(){return Yk(function e(){Xk(this,e),Wk(this,"cropMng",void 0),Wk(this,"originalBoxes",[]),Wk(this,"mouseDown",!1),Wk(this,"imgData",null),this.cropMng=new RO(0,0);},[{key:"getBoxesData",value:function value(e,t){for(var i=e.length,r=[],n=[],o=0;o0&&t.height>0&&(s=s<0||s>t.width?0:s,u=u<0||u>t.height?0:u,c=c<=0?1:c,(l=l<=0?1:l)+s>t.width&&(l=t.width-s),c+u>t.height&&(c=t.height-u));var h={left:s,top:u,width:l,height:c};n.push(h);}}return{oriBoxes:r,newBoxes:n};}},{key:"resetBoxes",value:function value(){if(this.originalBoxes.length<1)return!1;var e=this.cropMng;e.removeBox();for(var t=this.getBoxesData(this.originalBoxes,e.area).newBoxes,i=t.length,r=0;r1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=this.cropMng,s=a.canvasItem,u=a.area;if(!s)return!1;var l=null;if(bL(e)){if(0===(l=e).length)return!1;}else{if(!kL(e))return!1;l=[e];}var c=this.getBoxesData(l,u),h=c.oriBoxes,d=c.newBoxes,f=d.length;n||this.cropMng.count()>0&&this.clearBox();for(var v=0;v1&&void 0!==arguments[1]&&arguments[1],i=this.getCurrentTab(),r=!1;if(i){var n=i.currentPage;if(n){var o=this.context.getStatus(n.uid);if(o&&(this.context.boxRenderer.setCropArea(0,0,n.realTimeWidth||0,n.realTimeHeight||0),"multiple"===this.context.config.displayMode&&this.context.config.useMinImage)){var a=o.imageScale;bL(e)||(e=[e]);var s=[];$k(e).call(e,function(e){var t={left:e.left/a,top:e.top/a,width:e.width/a,height:e.height/a};s.push(t);}),e=s,r=!0;}}}var u=this.context.boxRenderer.setNormalBoxes(e,t,r);return u&&this.context.renderOnly(),u;}},{key:"clearCropBox",value:function value(){var e=this.context.boxRenderer.clearBox();return e&&this.context.boxRenderer.getBoxCount()>0&&this.context.renderOnly(),e;}},{key:"getCropBoxes",value:function value(){var e=this.context.boxRenderer.getCropBoxes(),t=this.getCurrentTab();if(t){var i=t.currentPage;if(i){var r=this.context.getStatus(i.uid);if(r&&"multiple"===this.context.config.displayMode&&this.context.config.useMinImage){var n=r.imageScale;e=$E(e).call(e,function(e){return{left:e.left*n,top:e.top*n,width:e.width*n,height:e.height*n};});}}}return e;}}]);}(e),Wk(t,"use",e.use),t;}(i);t.Viewer=r;}}};function WO(e,t){if(fS(t))return{unit:"px",value:0};if(UL(t))return{unit:"px",value:0};if(BL(t))return{unit:"px",value:t};if(t=US(t).call(t).toLowerCase(),eA(Number(t))&&"px".search(e)>=0)return{unit:"px",value:Number(t)};var i=[];t=t.replace(e,function(e){return i.push(e),"U".concat(e);});var r="U(".concat(e.source,")");return $E(i).call(i,function(e){return{unit:e,value:Number(t.replace(new RegExp("U".concat(e),"g"),"").replace(new RegExp(r,"g"),"*0"))};})[0];}var HO=function HO(e){return WO(/px/g,e);},FO=function FO(e){return WO(/px|%|em/g,e);},jO=function jO(e){return WO(/deg|rad|grad|turn/g,e);},YO=function(){function e(t,i,r){var n,o,a,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,u=arguments.length>4&&void 0!==arguments[4]&&arguments[4];Xk(this,e),Wk(this,"r",void 0),Wk(this,"g",void 0),Wk(this,"b",void 0),Wk(this,"alpha",void 0),Wk(this,"isNone",void 0),Wk(this,"formatted",""),this.r=t,this.g=i,this.b=r,this.alpha=s,this.isNone=u,this.formatted=lS(n=lS(o=lS(a="rgba(".concat(t,", ")).call(a,i,", ")).call(o,r,", ")).call(n,s,")");}return Yk(e,[{key:"clone",value:function value(){return new e(this.r,this.g,this.b,this.alpha);}}]);}(),XO=function(){function e(t,i){Xk(this,e),Wk(this,"type",void 0),Wk(this,"value",void 0),this.type=t,this.value=i;}return Yk(e,[{key:"clone",value:function value(){return new e(this.type,this.value);}}]);}(),qO={left:180,top:-90,bottom:90,right:0,"left top":225,"top left":225,"left bottom":135,"bottom left":135,"right top":-45,"top right":-45,"right bottom":45,"bottom right":45},ZO=function ZO(e){return{value:"angular"===e.type?Number(e.value):qO[e.value]||0,unit:"deg"};};function _O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if(UL(e))return null;if("currentColor"===e&&(e="black"),"transparent"===e)return new YO(0,0,0,0);var t=function(e){var t;if(OI(e).call(e,"linear")>-1||OI(e).call(e,"radial")>-1)return $E(t=PL(e)).call(t,function(e){var t=e.type,i=e.orientation,r=e.colorStops;!function(e,t,i){var r=e.length;e[r-1].length=null!==(t=e[r-1].length)&&void 0!==t?t:{type:"%",value:"100"},r>1&&(e[0].length=null!==(i=e[0].length)&&void 0!==i?i:{type:"%",value:"0"});for(var n=0,o=Number(e[0].length.value),a=1;a>8&15|i>>4&240,i>>4&15|240&i,(15&i)<<4|15&i,1);case 8:return tN(i>>24&255,i>>16&255,i>>8&255,(255&i)/255);case 4:return tN(i>>12&15|i>>8&240,i>>8&15|i>>4&240,i>>4&15|240&i,((15&i)<<4|15&i)/255);default:return null;}return qL.exec(e)?(i=qL.exec(e),new QL(i[1],i[2],i[3],1)):ZL.exec(e)?(i=ZL.exec(e),new QL(255*i[1]/100,255*i[2]/100,255*i[3]/100,1)):_L.exec(e)?tN((i=_L.exec(e))[1],i[2],i[3],i[4]):GL.exec(e)?tN(255*(i=GL.exec(e))[1]/100,255*i[2]/100,255*i[3]/100,i[4]):KL.exec(e)?nN(iN((i=KL.exec(e))[1],i[2]/100,i[3]/100,1)):$L.exec(e)?nN(iN((i=$L.exec(e))[1],i[2]/100,i[3]/100,i[4])):JL.hasOwnProperty(e)?eN(JL[e]):"transparent"===e?new QL(NaN,NaN,NaN,0):null;}(e),r=[0,0,0,0];return null!==i&&(r[0]=$S(i.r,10)||0,r[1]=$S(i.g,10)||0,r[2]=$S(i.b,10)||0,r[3]=vA(i.opacity)),sv(YO,r);}function GO(e){var t=null;bL(e)&&(t=e),TL(e)&&(t=e.split(" "));for(var i=0;i<3;i++)t[i]?t[i]=HO(t[i]).value:t[i]=0;var r=_O(t[3]);return t[3]=r?r.formatted:"black",RI(t).call(t,0,4);}function KO(e){var t,i=[];return TL(e)?$k(t=e.split(" ")).call(t,function(e){var t=HO(e);t&&i.push(t.value);}):i.push.apply(i,Kb(e)),1===i.length?[i[0],i[0]]:i;}var $O=function $O(e){var t=e;if(TL(e)){var i=FO(e);"%"===i.unit&&(t=i.value/100),"px"===i.unit&&(t=i.value);}return t>1&&(t=1),t;};function JO(e,t,i){var r=i.parsedStyle,n=r.x,o=void 0===n?0:n,a=r.y,s=void 0===a?0:a;r.z,e!==t&&i.setLocalPosition(o,s);}var QO=function(){return Yk(function e(t){Xk(this,e),Wk(this,"bubbles",!0),Wk(this,"cancelBubble",!0),Wk(this,"cancelable",!1),Wk(this,"composed",!1),Wk(this,"currentTarget",void 0),Wk(this,"defaultPrevented",!1),Wk(this,"eventPhase",e.prototype.NONE),Wk(this,"isTrusted",void 0),Wk(this,"returnValue",void 0),Wk(this,"srcElement",void 0),Wk(this,"target",void 0),Wk(this,"timeStamp",void 0),Wk(this,"type",void 0),Wk(this,"detail",void 0),Wk(this,"view",void 0),Wk(this,"which",void 0),Wk(this,"path",void 0),Wk(this,"immediatePropagationStopped",!1),Wk(this,"propagationStopped",!1),Wk(this,"nativeEvent",void 0),Wk(this,"originalEvent",void 0),Wk(this,"eventService",void 0),Wk(this,"AT_TARGET",1),Wk(this,"BUBBLING_PHASE",2),Wk(this,"CAPTURING_PHASE",3),Wk(this,"NONE",0),this.eventService=t;},[{key:"initUIEvent",value:function value(e,t,i,r,n){}},{key:"composedPath",value:function value(){var e=this.path,t=this.eventService,i=this.target;return!t||e&&e[this.path.length-1]===i||(this.path=i?t.getPropagationPath(i):[]),this.path;}},{key:"initEvent",value:function value(e,t,i){}},{key:"preventDefault",value:function value(){var e=this.nativeEvent;e instanceof Event&&e.cancelable&&e.preventDefault(),this.defaultPrevented=!0;}},{key:"stopImmediatePropagation",value:function value(){this.immediatePropagationStopped=!0;}},{key:"stopPropagation",value:function value(){this.propagationStopped=!0;}}]);}(),eW=function(e){function t(e,i){var r;return Xk(this,t),(r=cL(this,t,[null])).type=e,r.detail=i,r;}return _b(t,e),Yk(t);}(QO),tW=function(){return Yk(function e(){Xk(this,e),Wk(this,"pubsub",bN.create());},[{key:"addEventListener",value:function value(e,t,i){var r,n=DL(i)&&i;kL(i)&&(n=i.capture,r=i.once),e=n?"".concat(e,":capture"):e,t=ML(t)?t:t.handleEvent,this.pubsub.on(e,t,this,r);}},{key:"dispatchEvent",value:function value(e){var t,i=this.ownerDocument||this.document;return i&&(e.eventService=(null===(t=i.defaultView)||void 0===t?void 0:t.eventService)||null,e.defaultPrevented=!1,e.path=[],e.target=this,function(e,t,i){if(t=null!==(i=t)&&void 0!==i?i:e.type,e.propagationStopped=!1,e.immediatePropagationStopped=!1,e.target){var r=e.composedPath(),n=r.length;e.eventPhase=e.CAPTURING_PHASE;for(var o=0;o=0;a--)if(e.currentTarget=r[a],iW(e,t),rW(e))return;}}}(e)),!e.defaultPrevented;}},{key:"removeEventListener",value:function value(e,t,i){var r=DL(i)&&i;kL(i)&&(r=i.capture),e=r?"".concat(e,":capture"):e,t=ML(t)?t:t.handleEvent,this.pubsub.off(e,t,context);}},{key:"removeAllEventListeners",value:function value(){this.pubsub.removeAllEventListeners();}},{key:"getAllEvents",value:function value(){return this.pubsub.getAllEvents();}}]);}();function iW(e,t){for(var i=e.currentTarget.getAllEvents()[t]||[],r=0,n=i.length;r-1?(i=!0,gE(n).call(n,o,1)):i=!1;var a=e.transform;return a&&this.dirtyWorld(e,a),e.parentNode=null,i;}},{key:"isChildExist",value:function value(e){var t=e.parentNode;if(!t)return!1;var i=t.childNodes;return!(OI(i).call(i,e)<0);}},{key:"setOrigin",value:function value(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;BL(t)&&(t=CN.fromValue(t,i));var r=e.transform;r.origin.equals(t)||(r.origin.setFromVector(t),this.dirtyLocal(e,r));}},{key:"getOrigin",value:function value(e){return e.transform.origin;}},{key:"setPosition",value:function value(e,t){var i=e.transform;t=CN.fromValue(t.x,t.y,t.z||0);var r=this.getPosition(e);if(!t.equals(r)){var n=this.getWorldTransform(e),o=this.getPosition(e),a=t.x-o.x,s=t.y-o.y,u=t.z-o.z;if(i.position=t,e.hasParentTransform()){n=new RN().translateSelf(a,s,u).multiply(n);var l=e.parentNode.transform.worldTransform,c=this.getWorldTransform(e);c.m41=t.x,c.m42=t.y,c.m43=t.z;var h=l.inverse().multiply(n),d=this.getOrigin(e),f=h.getScaling(),v=this.createScaleMatrix(f.x,f.y,f.z),g=RN.fromMatrix(v).inverse(),m=h.translate(d.x,d.y,d.z).multiply(g),y=m.getRotation(),p=RN.fromQuat(y).inverse(),w=m.multiply(p).getTranslation();w.x-=d.x,w.y-=d.y,w.z-=d.z,i.localPosition.setFromVector(w);}else i.localPosition=t;this.dirtyLocal(e,i);}}},{key:"setLocalPosition",value:function value(e,t){var i=e.transform;(t=CN.fromValue(t.x,t.y,t.z||0)).equals(i.localPosition)||(i.localPosition=t,this.dirtyLocal(e,i));}},{key:"getPosition",value:function value(e){var t=this.getWorldTransform(e),i=e.transform,r=t.getTranslation();return i.position.setFromVector(r),e.transform.position;}},{key:"getLocalPosition",value:function value(e){return e.transform.localPosition;}},{key:"translate",value:function value(e,t){if(!t.equals(new CN())){var i=this.getPosition(e),r=this.getWorldTransform(e),n=r.getScaling(),o=this.createScaleMatrix(n.x,n.y,n.z),a=r.multiply(RN.fromMatrix(o).inverse()).getRotation(),s=RN.fromQuat(a).transformPoint(t);i.add(s),this.setPosition(e,i);}}},{key:"translateLocal",value:function value(e,t){var i=e.transform;if(!t.equals(new CN())){t.multiply(i.localScale);var r=RN.fromQuat(i.localRotation).transformPoint(t);i.localPosition.add(r),this.dirtyLocal(e,i);}}},{key:"scaleLocal",value:function value(e,t){var i=e.transform;i.localScale.multiply(t),this.dirtyLocal(e,i);}},{key:"setLocalScale",value:function value(e,t){var i=e.transform,r=CN.fromValue(t.x,t.y,t.z||i.localScale.z);r.equals(i.localScale)||(i.localScale=r,this.dirtyLocal(e,i));}},{key:"getScale",value:function value(e){var t=e.transform,i=this.getWorldTransform(e).getScaling();return t.scale.setFromVector(i),t.scale;}},{key:"getLocalScale",value:function value(e){return e.transform.localScale;}},{key:"getRotation",value:function value(e){var t=e.transform,i=this.getWorldTransform(e),r=i.getScaling(),n=this.createScaleMatrix(r.x,r.y,r.z),o=i.multiply(RN.fromMatrix(n).inverse()).getRotation();return t.rotation.setFromQuat(o),t.rotation;}},{key:"getLocalRotation",value:function value(e){return e.transform.localRotation;}},{key:"rotate",value:function value(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=e.transform;if(BL(t)&&(t=VN(t,i,r)),e.hasParentTransform()){var o=MN(t.x,t.y,t.z),a=this.getRotation(e),s=this.getRotation(e.parentNode).clone().invert().multiply(o).multiply(a).normalize();n.localRotation.setFromQuat(s),this.dirtyLocal(e,n);}else this.rotateLocal(e,t);}},{key:"rotateLocal",value:function value(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;BL(t)&&(t=VN(t,i,r));var n=e.transform,o=MN(t.x,t.y,t.z);n.localRotation.multiply(o),this.dirtyLocal(e,n);}},{key:"setAngle",value:function value(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;BL(t)&&(t=VN(t,i,r));var n=e.transform;if(e.hasParentTransform()){var o=MN(t.x,t.y,t.z);n.localRotation.setFromQuat(o);var a=this.getRotation(e.parentNode);a.invert(),n.localRotation.setFromQuat(a.multiply(n.localRotation)),this.dirtyLocal(e,n);}else this.setLocalAngle(e,t);}},{key:"setLocalAngle",value:function value(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;BL(t)&&(t=VN(t,i,r));var n=e.transform,o=MN(t.x,t.y,t.z);n.localRotation.setFromQuat(o),this.dirtyLocal(e,n);}},{key:"setRotation",value:function value(e,t){var i=e.transform;if(e.hasParentTransform()){var r=this.getRotation(e.parentNode);r=r.clone().invert().multiply(t).normalize(),i.localRotation.setFromQuat(r),this.dirtyLocal(e,i);}else this.setLocalRotation(e,t);}},{key:"setLocalRotation",value:function value(e,t){var i=e.transform;i.localRotation.setFromQuat(t),this.dirtyLocal(e,i);}},{key:"getAngle",value:function value(e){var t=this.getWorldTransform(e);return BN.fromQuat(t.decompose().quaternion).toEuler();}},{key:"getLocalAngle",value:function value(e){return this.getLocalTransform(e),this.getLocalRotation(e).toEuler();}},{key:"setLocalTransform",value:function value(e,t){var i=this.getOrigin(e),r=t.decompose();r.quaternion;var n=r.rotation,o=r.scale,a=this.createScaleMatrix(o.x,o.y,o.z),s=RN.fromMatrix(a).inverse(),u=t.translate(i.x,i.y,i.z).multiply(s).getTranslation();u.x-=i.x,u.y-=i.y,u.z-=i.z,this.setLocalPosition(e,u),this.setLocalAngle(e,n.x,n.y,n.z),this.setLocalScale(e,o);}},{key:"createScaleMatrix",value:function value(){return{m11:arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,m21:0,m31:0,m41:0,m12:0,m22:arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,m32:0,m42:0,m13:0,m23:0,m33:arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,m43:0,m14:0,m24:0,m34:0,m44:1};}},{key:"resetLocalTransform",value:function value(e){this.setLocalScale(e,new CN(1,1,1)),this.setLocalPosition(e,new CN(0,0,0)),this.setLocalAngle(e,0);}},{key:"getWorldTransform",value:function value(e){var t=e.transform;if(!t.worldDirty&&!t.localDirty)return t.worldTransform;var i=e.parentNode;return i&&i.transform&&this.getWorldTransform(i),this.updateHierarchy(e),t.worldTransform;}},{key:"getLocalTransform",value:function value(e){var t=e.transform;return t.localDirty&&t.updateLocalTransform(),t.localTransform;}},{key:"getBounds",value:function value(e,t){var i=this,r=e.renderable,n=e.childNodes;if(t&&!r.renderBoundsDirty&&r)return r.renderBounds;if(!t&&!r.boundsDirty&&r.bounds)return r.bounds;var o=this.getTransformedGeometryBounds(e,t);$k(n).call(n,function(e){var r=i.getBounds(e,t);r&&(o?o.addBounds(r):o=qW.fromBounds(r));});var a=e.style.clipPath;if(a){var s=this.getTransformedGeometryBounds(a,!0),u=null;s&&(u=qW.create()).setFromTransformedBounds(this.getWorldTransform(e),s),o?u&&(o=u.intersection(o)):o=u;}return t?(r.renderBoundsDirty=!1,o&&(r.renderBounds=o)):(r.boundsDirty=!1,o&&(r.bounds=o)),o||qW.create();}},{key:"getLocalBounds",value:function value(e){var t=e.parentNode;if(t){var i=new RN();t.transform&&(i=this.getWorldTransform(t).inverse());var r=this.getBounds(e);if(!qW.isEmpty(r)){var n=qW.create();return n.setFromTransformedBounds(i,r),n;}}return this.getBounds(e);}},{key:"getGeometryBounds",value:function value(e,t){var i=e.geometry;return(t?i.renderBounds:i.contentBounds)||qW.create();}},{key:"getBoundingClientRect",value:function value(e){var t,i,r=this.getGeometryBounds(e);qW.isEmpty(r)||(i=qW.create()).setFromTransformedBounds(this.getWorldTransform(e),r);var n=null===(t=e.ownerDocument)||void 0===t?void 0:t.defaultView.getContextService().getBoundingClientRect();return i?{x:i.minX+((null==n?void 0:n.left)||0),y:i.minY+((null==n?void 0:n.top)||0),width:i.maxX-i.minX,height:i.maxY-i.minY}:{x:(null==n?void 0:n.left)||0,y:(null==n?void 0:n.top)||0,width:0,height:0};}},{key:"updateHierarchy",value:function value(e){var t=e.transform;if(t.localDirty&&t.updateLocalTransform(),t.worldDirty){var i,r=null==e||null===(i=e.parentNode)||void 0===i?void 0:i.transform;e.parentNode&&r||(r=new hW()),t.updateWorldTransform(r);}}},{key:"getTransformedGeometryBounds",value:function value(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.getGeometryBounds(e,t);if(!qW.isEmpty(i)){var r=qW.create();return this.getWorldTransform(e),r.setFromTransformedBounds(this.getWorldTransform(e),i),r;}return null;}},{key:"dirtyLocal",value:function value(e,t){t.localDirty||(t.localDirty=!0,t.worldDirty||this.dirtyWorld(e,t));}},{key:"dirtyWorld",value:function value(e,t){t.worldDirty||this.unfreezeParentToRoot(e),this.recursiveDirtyWorld(e,t),function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=e;i;){var r=i.renderable;r&&(r.boundsDirty=!0,r.renderBoundsDirty=!0),i=i.parentNode;}e.dispatchEvent(new eW("bounds-changed",{affectChildren:t}));}(e,!0);}},{key:"recursiveDirtyWorld",value:function value(e,t){var i,r=this;if(!t.worldDirty){t.worldDirty=!0,t.frozen=!1,$k(i=e.childNodes).call(i,function(e){var t=e.transform;t.worldDirty||r.recursiveDirtyWorld(e,t);});var n=e.renderable;n&&(n.boundsDirty=!0,n.renderBoundsDirty=!0);var o=new nW("DOMAttrModified",e,null,null,"modelMatrix",nW.MODIFICATION,null,null);e.dispatchEvent(o);}}},{key:"unfreezeParentToRoot",value:function value(e){for(var t=e;t;){var i=t.transform;i&&(i.frozen=!1),t=t.parentNode;}}}]);}())(oW),sW=function(e){function t(){var e,i;Xk(this,t);for(var r=arguments.length,n=new Array(r),o=0;o0?this.childNodes[0]:null;}},{key:"lastChild",get:function get(){var e=this.childNodes;return e.length>0?e[e.length-1]:null;}},{key:"nextSibling",get:function get(){var e=this.parentNode;if(e){var t,i=OI(t=e.childNodes).call(t,this);return e.childNodes[i+1];}return null;}},{key:"parentElement",get:function get(){return this.parentNode;}},{key:"previousSibling",get:function get(){var e=this.parentNode;if(e){var t,i=OI(t=e.childNodes).call(t,this);return e.childNodes[i-1];}return null;}},{key:"contains",value:function value(e){for(var t=e;t&&this!==t;)t=t.parentNode;return!!t;}},{key:"getRootNode",value:function value(e){return this.parentNode?this.parentNode.getRootNode(e):this;}},{key:"hasChildNodes",value:function value(){return this.childNodes.length>0;}},{key:"isEqualNode",value:function value(e){return this===e;}},{key:"isSameNode",value:function value(e){return this.isEqualNode(e);}},{key:"compareDocumentPosition",value:function value(e){throw new Error("Method to be implemented");}},{key:"isDefaultNamespace",value:function value(e){throw new Error("Method to be implemented");}},{key:"lookupNamespaceURI",value:function value(e){throw new Error("Method to be implemented");}},{key:"lookupPrefix",value:function value(e){throw new Error("Method to be implemented");}},{key:"normalize",value:function value(){throw new Error("Method to be implemented");}},{key:"recursiveCall",value:function value(e){var t;e(this)||$k(t=this.childNodes).call(t,function(t){t.recursiveCall(e);});}},{key:"hasParentTransform",value:function value(){return!(!this.parentNode||!this.parentNode.transform);}}],[{key:"isNode",value:function value(e){return!!e.childNodes;}}]);}(tW);Wk(sW,"ELEMENT_NODE",1),Wk(sW,"ATTRIBUTE_NODE",2),Wk(sW,"TEXT_NODE",3),Wk(sW,"CDATA_SECTION_NODE",4),Wk(sW,"ENTITY_REFERENCE_NODE",5),Wk(sW,"ENTITY_NODE",6),Wk(sW,"PROCESSING_INSTRUCTION_NODE",7),Wk(sW,"COMMENT_NODE",8),Wk(sW,"DOCUMENT_NODE",9),Wk(sW,"DOCUMENT_TYPE_NODE",10),Wk(sW,"DOCUMENT_FRAGMENT_NODE",11),Wk(sW,"NOTATION_NODE",12),Wk(sW,"DOCUMENT_POSITION_DISCONNECTED",1),Wk(sW,"DOCUMENT_POSITION_PRECEDING",2),Wk(sW,"DOCUMENT_POSITION_FOLLOWING",4),Wk(sW,"DOCUMENT_POSITION_CONTAINS",8),Wk(sW,"DOCUMENT_POSITION_CONTAINED_BY",16),Wk(sW,"DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",32);var uW=Yk(function e(){Xk(this,e),Wk(this,"contentBounds",void 0),Wk(this,"renderBounds",void 0);}),lW=function(){return Yk(function e(){Xk(this,e),Wk(this,"boundsDirty",!0),Wk(this,"bounds",void 0),Wk(this,"renderBoundsDirty",!0),Wk(this,"renderBounds",void 0);},[{key:"isRenderable",value:function value(){return this.boundsDirty||this.renderBoundsDirty;}},{key:"toRenderable",value:function value(){this.boundsDirty=!0,this.renderBoundsDirty=!0;}}]);}(),cW=Yk(function e(){Xk(this,e),Wk(this,"renderOrder",0),Wk(this,"lastSortedIndex",void 0),Wk(this,"sorted",void 0),Wk(this,"dirty",!1);}),hW=function(){return Yk(function e(){Xk(this,e),Wk(this,"frozen",!0),Wk(this,"worldDirty",!1),Wk(this,"localDirty",!1),Wk(this,"localRotation",DN(0,0,0,1)),Wk(this,"rotation",DN(0,0,0,1)),Wk(this,"localScale",VN(1,1,1)),Wk(this,"scale",VN(1,1,1)),Wk(this,"localPosition",VN(0,0,0)),Wk(this,"position",VN(0,0,0)),Wk(this,"localSkew",VN(0,0,0)),Wk(this,"skew",VN(0,0,0)),Wk(this,"origin",VN(0,0,0)),Wk(this,"worldTransform",new RN()),Wk(this,"localTransform",new RN());},[{key:"updateLocalTransform",value:function value(){var e=this.origin,t=this.localScale,i=this.localPosition,r=this.localRotation,n=this.localSkew,o=new RN();o.translateSelf(e.x,e.y,e.z);var a=AN(0,0,0,1),s=this.compose(a,i,r,n,t);o.multiplySelf(s),o.translateSelf(-e.x,-e.y,-e.z),this.localTransform.setFromMatrix(o),this.localDirty=!1;}},{key:"updateWorldTransform",value:function value(e){var t=e.worldTransform.clone();t.multiplySelf(this.localTransform),this.worldTransform.setFromMatrix(t),this.worldDirty=!1;}},{key:"compose",value:function value(e,t,i,r,n){var o=new RN();o.m14=e.x,o.m24=e.y,o.m34=e.z,o.m44=e.w,o.translateSelf(t.x,t.y,t.z);var a=RN.fromQuat(i);o.multiplySelf(a);var s=new RN();return r.z&&(s.m32=r.z,o.multiplySelf(s)),r.y&&(s.m32=0,s.m31=r.y,o.multiplySelf(s)),r.x&&(s.m31=0,s.m21=r.x,o.multiplySelf(s)),o.scaleSelf(n.x,n.y,n.z),o;}}]);}(),dW=function(e){function t(){var e,i;Xk(this,t);for(var r=arguments.length,n=new Array(r),o=0;o-1;}},{key:"removeAttribute",value:function value(e){this.setAttribute(e,null),delete this.attributes[e];}},{key:"setAttribute",value:function value(e,t){this.attributes[e]=t;}},{key:"appendChild",value:function value(e,t){aW.append(e,this,t);var i=new eW("child-inserted",{child:e});this.dispatchEvent(i);var r=new nW("DOMNodeInserted",this,"","","",0,"","");return e.dispatchEvent(r),e;}},{key:"cloneNode",value:function value(e){return null;}},{key:"insertBefore",value:function value(e,t){if(t){var i,r=OI(i=this.childNodes).call(i,t);this.appendChild(e,r-1);}else this.appendChild(e);return e;}},{key:"removeChild",value:function value(e){var t=new nW("removed",this,"","","",0,"","");e.dispatchEvent(t);var i=new eW("child-removed",{child:e});return this.dispatchEvent(i),aW.remove(e),e;}},{key:"isChildExist",value:function value(e){return aW.isChildExist(e);}},{key:"replaceChild",value:function value(e,t){var i,r=OI(i=this.childNodes).call(i,t);return this.removeChild(t),this.appendChild(e,r),t;}},{key:"destroy",value:function value(){var e=new eW("destroy",{});this.dispatchEvent(e),this.remove(),this.removeAllEventListeners(),this.isDestroyed=!0;}},{key:"after",value:function value(){var e=this.parentNode;if(e){for(var t,i=OI(t=e.childNodes).call(t,this),r=arguments.length,n=new Array(r),o=0;o0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e)if(RL(t,e)){if("style"===t)continue;this.attributes[t]=e[t];}for(var i in e.style)RL(i,e.style)&&(this.parseStyleProperty(i,e.style[i]),this.attributes[i]=e.style[i]);this.renderable.toRenderable();}},{key:"setAttribute",value:function value(e,i){if(!CL(i)&&i!==this.attributes[e]){var r=this.attributes[e];hL(t,"setAttribute",this,3)([e,i]),this.config.hasOwnProperty(e)||(this.parseStyleProperty(e,i),this.updateStyleProperty(e,r,i));}}},{key:"parseStyleProperty",value:function value(e,t){var i=vW[e];this.parsedStyle[e]=i?i(t,this,e):t;}},{key:"updateStyleProperty",value:function value(e,t,i){var r=this,n=gW[e];n&&$k(n).call(n,function(n){n(t,i,r,e);});}},{key:"toFront",value:function value(){var e=this.parentNode;if(e){var t,i=Math.max.apply(Math,Kb($E(t=e.children).call(t,function(e){return e.style.zIndex;})));this.style.zIndex=i+1;}return this;}},{key:"toBack",value:function value(){var e=this.parentNode;if(e){var t,i=Math.min.apply(Math,Kb($E(t=e.children).call(t,function(e){return e.style.zIndex;})));this.style.zIndex=i-1;}return this;}},{key:"setOrigin",value:function value(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return aW.setOrigin(this,e,t),this;}},{key:"getOrigin",value:function value(){return aW.getOrigin(this);}},{key:"setPosition",value:function value(e){return aW.setPosition(this,e),this;}},{key:"setLocalPosition",value:function value(e){var t=VN(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0);return aW.setLocalPosition(this,t),this;}},{key:"getPosition",value:function value(){return aW.getPosition(this);}},{key:"getLocalPosition",value:function value(){return aW.getLocalPosition(this);}},{key:"translate",value:function value(e){var t=VN(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0);return aW.translate(this,t),this;}},{key:"translateLocal",value:function value(e){var t=VN(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0);return aW.translateLocal(this,t),this;}},{key:"scale",value:function value(e,t,i){return this.scaleLocal(e,t,i);}},{key:"scaleLocal",value:function value(e,t,i){return BL(e)&&(e=VN(e,t=t||e,i=i||e)),aW.scaleLocal(this,e),this;}},{key:"setLocalScale",value:function value(e,t,i){return BL(e)&&(e=VN(e,t=t||e,i=i||e)),aW.setLocalScale(this,e),this;}},{key:"getScale",value:function value(){return aW.getScale(this);}},{key:"getLocalScale",value:function value(){return aW.getLocalScale(this);}},{key:"rotate",value:function value(e,t,i){return CL(t)&&CL(i)?aW.rotate(this,0,0,e):aW.rotate(this,e,t,i),this;}},{key:"rotateLocal",value:function value(e,t,i){return CL(t)&&CL(i)?aW.rotateLocal(this,0,0,e):aW.rotateLocal(this,e,t,i),this;}},{key:"setAngle",value:function value(e){return aW.setAngle(this,0,0,e),this;}},{key:"setLocalAngle",value:function value(e){return aW.setLocalAngle(this,0,0,e),this;}},{key:"getAngle",value:function value(){return aW.getAngle(this).z;}},{key:"getLocalAngle",value:function value(){return aW.getLocalAngle(this).z;}},{key:"getLocalTransform",value:function value(){return aW.getLocalTransform(this);}},{key:"getWorldTransform",value:function value(){return aW.getWorldTransform(this);}},{key:"setLocalTransform",value:function value(e){return aW.setLocalTransform(this,e),this;}},{key:"resetLocalTransform",value:function value(){aW.resetLocalTransform(this);}},{key:"getPath",value:function value(){}},{key:"getConfig",value:function value(){}},{key:"getBoundingRect",value:function value(){}},{key:"getBoundingRectObject",value:function value(){}},{key:"updateStyle",value:function value(e){}},{key:"isPointInPath",value:function value(e){}}]);}(dW);function yW(e,t){return{type:e,data:t};}function pW(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=[],r=Gb(e,1)[0];i.push(yW("moveTo",[r]));for(var n=1;n2&&(r=Gb(e,1)[0],i.push(yW("lineTo",[r]))),i;}function wW(e,t){var i=t.data,r=t.type,n=Gb(i,3),o=n[0],a=n[1],s=n[2];switch(r){case"moveTo":e.moveTo(o.x,o.y);break;case"lineTo":e.lineTo(o.x,o.y);break;case"bezierCurveTo":e.bezierCurveTo(o.x,o.y,a.x,a.y,s.x,s.y);break;case"quadraticCurveTo":e.quadraticCurveTo(o.x,o.y,a.x,a.y);}}function bW(e){for(var t=Math.min,i=Math.max,r=e[0],n=r.x,o=r.y,a=n,s=o,u=n,l=o,c=1;c0&&t.push({step:i,close:e[r-1].close}),(i=[]).push(yW("moveTo",[{x:n.x,y:n.y}]));else if(1===n.step)i.push(yW("lineTo",[{x:n.x,y:n.y}]));else if(2===n.step&&r+2=c-v&&u<=h+v&&l>=d-v&&l<=f+v&&function(e,t,i,r,n,o){var a=[i-e,r-t];if(new CN(a[0],a[1]).equals({x:0,y:0}))return Math.sqrt((n-e)*(n-e)+(o-t)*(o-t));var s=[-a[1],a[0]],u=new CN(s[0],s[1]);u.normalize();var l=[n-e,o-t],c=new CN(l[0],l[1]);return Math.abs(c.dot(u));}(n,o,a,s,u,l)<=i/2;}function TW(e,t,i,r,n){var o=e.length;if(o<2)return!1;for(var a=0;a=e&&n<=e+i&&o>=t&&o<=t+r;}function EW(e,t,i,r,n,o){var a=o,s=r.x,u=r.y,l=n.x,c=n.y;0===t&&(s=n.x,u=n.y,l=r.x,c=r.y);var h=Math.PI/2,d=l-s>=0?1:-1,f=c-u>=0?1:-1;s!==l&&(h=Math.atan(Math.abs(c-u)/Math.abs(l-s)));var v=Math.cos(h),g=Math.sin(h),m=i?1:-1,y={x:l+9*m*a*v*d-4.5*a*g*d,y:c+9*m*a*g*f+4.5*a*v*f,step:0,close:!1},p={x:l+m*a*v*d,y:c+m*a*g*f,step:1,close:!1},w={x:l+9*m*a*v*d+4.5*a*g*d,y:c+9*m*a*g*f-4.5*a*v*f,step:1,close:!1};e.push(y,p,w);}function PW(e,t,i,r,n,o){var a=o,s=r.x,u=r.y,l=n.x,c=n.y;0===t&&(s=n.x,u=n.y,l=r.x,c=r.y);var h=Math.PI/2,d=l-s>=0?1:-1,f=c-u>=0?1:-1;s!==l&&(h=Math.atan(Math.abs(c-u)/Math.abs(l-s)));var v=Math.cos(h),g=Math.sin(h),m=i?1:-1,y={x:l+9*m*a*v*d-4.5*a*g*d,y:c+9*m*a*g*f+4.5*a*v*f,step:0,close:!1},p={x:l+m*a*v*d,y:c+m*a*g*f,step:1,close:!1},w={x:l+9*m*a*v*d+4.5*a*g*d,y:c+9*m*a*g*f-4.5*a*v*f,step:1,close:!0};e.push(y,p,w);}function BW(e,t,i,r,n){var o=n,a=i.x,s=i.y,u=r.x,l=r.y;0===t&&(a=r.x,s=r.y,u=i.x,l=i.y);var c=Math.PI/2,h=u-a>=0?1:-1,d=l-s>=0?1:-1;a!==u&&(c=Math.atan(Math.abs(l-s)/Math.abs(u-a)));var f=Math.cos(c),v=Math.sin(c),g={x:u-3*o*v*h,y:l+3*o*f*d,step:0,close:!1},m={x:u+3*o*v*h,y:l-3*o*f*d,step:1,close:!1};e.push(g,m);}function DW(e,t,i,r,n){var o=n,a=i.x,s=i.y,u=r.x,l=r.y;0===t&&(a=r.x,s=r.y,u=i.x,l=i.y);var c=Math.PI/2,h=u-a>=0?1:-1,d=l-s>=0?1:-1,f=l>=s&&u>=a||l<=s&&u<=a?-1:1;a!==u&&(c=Math.atan(Math.abs(l-s)/Math.abs(u-a)));var v=Math.cos(c),g=Math.sin(c),m=4.5*Math.sqrt(3)*o,y={x:u+4.5*o*v*h-m*g*h*f,y:l+4.5*o*g*d+m*v*d*f,step:0,close:!1},p={x:u-4.5*o*v*h+m*g*h*f,y:l-4.5*o*g*d-m*v*d*f,step:1,close:!1};e.push(y,p);}function MW(e,t,i,r,n){var o=n,a=r.x,s=r.y;0===t&&(a=i.x,s=i.y);var u={x:a-3*o,y:s,step:0,close:!1},l={x:a,y:s-3*o,step:1,close:!1},c={x:a+3*o,y:s,step:1,close:!1},h={x:a,y:s+3*o,step:1,close:!0};e.push(u,l,c,h);}function zW(e,t,i,r,n){var o=n,a=r.x,s=r.y;0===t&&(a=i.x,s=i.y);var u=3*o-0*o,l=function(e,t,i,r){var n=e-i,o=e+i,a=t-r,s=t+r,u=.551915024494,l=u*i,c=u*r,h=[];return h.push({x:o,y:t}),h.push({x:o,y:t+c},{x:e+l,y:s},{x:e,y:s}),h.push({x:e-l,y:s},{x:n,y:t+c},{x:n,y:t}),h.push({x:n,y:t-c},{x:e-l,y:a},{x:e,y:a}),h.push({x:e+l,y:a},{x:o,y:t-c},{x:o,y:t}),h;}(a,s,u,u);$k(l).call(l,function(t,i){var r=0===i?0:2,n=i===l.length-1,o={x:t.x,y:t.y,step:r,close:n};e.push(o);});}function AW(e,t){if(CL(e)||""===e)return null;var i=FO(e);return"%"===i.unit?.01*t*i.value:i.value;}var UW=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.style,n=zf(i,iL);Xk(this,t),Wk(e=cL(this,t,[Fk({type:"rect",style:Fk(Fk({},kW),{},{x:0,y:0,width:0,height:0},r)},n)]),"shapeType","rect");var o=e.parsedStyle,a=o.x,s=o.y;return e.setLocalPosition(a,s),e.updateOrigin(),e;}return _b(t,e),Yk(t,[{key:"updateStyle",value:function value(e){var t,i=this;$k(t=eS(e)).call(t,function(t){RL(t,e)&&(i.style[t]=e[t]);});}},{key:"updateOrigin",value:function value(){var e=this.parsedStyle,t=e.width,i=e.height;this.setOrigin(t.value/2,i.value/2);}},{key:"updatePosition",value:function value(e,t){this.style.x=e,this.style.y=t;}},{key:"getPath",value:function value(){var e=this.parsedStyle,t=e.width,i=e.height,r=e.borderWidth,n=.5*((null==r?void 0:r.value)||0),o=0,a=0;o+=n,a+=n;var s=t.value-2*n,u=i.value-2*n;return this.path=[{x:o,y:a},{x:o+s,y:a},{x:o+s,y:a+u},{x:o,y:a+u}],this.steps=pW(this.path),this.path;}},{key:"getBoundingRect",value:function value(){var e=this.parsedStyle,t=e.x,i=e.y,r=e.width,n=e.height;return e.borderWidth,{x:t,y:i,width:r.value,height:n.value};}},{key:"getBoundingRectObject",value:function value(){var e=this.getBoundingRect();return new t({style:{x:e.x,y:e.y,width:e.width,height:e.height,borderWidth:1,background:"rgba(0,0,0,0)"}});}},{key:"isPointInPath",value:function value(e){var t=this.parsedStyle,i=t.x,r=t.y,n=t.background,o=t.borderWidth,a=t.width,s=t.height,u=o&&o.value,l=((null==o?void 0:o.value)||0)/2;return n&&u?IW(i-l,r-l,a.value+l,s.value+l,e.x,e.y):n?IW(i,r,a.value,s.value,e.x,e.y):!!u&&function(e,t,i,r,n,o,a){var s=n/2;return IW(e-s,t-s,i,n,o,a)||IW(e+i-s,t-s,n,r,o,a)||IW(e+s,t+r-s,i,n,o,a)||IW(e-s,t+s,n,r,o,a);}(i-l,r-l,a.value,s.value,o.value,e.x,e.y);}}]);}(mW);function RW(e,t,i,r,n){for(var o=n||[],a=e[t],s=e[i-1],u=0,l=1,c=t+1;cu&&(u=h,l=c);}return u>=r?(RW(e,t,l,r,o),RW(e,l,i,r,o)):(o.length||o.push(a),o.push(s)),o;}var LW=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.style,n=zf(i,rL);Xk(this,t),Wk(yb(e=cL(this,t,[Fk({type:"image",style:Fk(Fk({},kW),{},{x:0,y:0,width:0,height:0,img:""},r)},n)])),"shapeType","image"),Wk(yb(e),"meteData",void 0),e.meteData=(null==n?void 0:n.meteData)||null;var o=e.parsedStyle,a=o.x,s=o.y;return e.setLocalPosition(a,s),e.updateOrigin(),e;}return _b(t,e),Yk(t,[{key:"updateStyle",value:function value(e){var t,i=this;$k(t=eS(e)).call(t,function(t){RL(t,e)&&(i.style[t]=e[t]);});}},{key:"updateOrigin",value:function value(){var e=this.parsedStyle,t=e.width,i=e.height;this.setOrigin(t.value/2,i.value/2);}},{key:"updatePosition",value:function value(e,t){this.style.x=e,this.style.y=t;}},{key:"getBoundingRect",value:function value(){var e=this.parsedStyle,t=e.x,i=e.y,r=e.width,n=e.height;return{x:t,y:i,width:r.value,height:n.value};}},{key:"getBoundingRectObject",value:function value(){var e=this.getBoundingRect(),t=e.x,i=e.y,r=e.width,n=e.height;return new UW({style:{x:t,y:i,width:r,height:n,borderWidth:1,background:"rgba(0,0,0,0)"}});}},{key:"isPointInPath",value:function value(e){return this.getBoundingRectObject().isPointInPath(e);}}]);}(mW),NW=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.style,n=zf(i,nL);Xk(this,t),Wk(e=cL(this,t,[Fk({type:"line",style:Fk(Fk({},kW),{},{x1:0,y1:0,x2:0,y2:0,borderWidth:2},r)},n)]),"shapeType","line"),Wk(e,"renderPath",void 0);var o=e.getBoundingRect(),a=o.x,s=o.y;return e.updatePosition(a,s),e.updateOrigin(),e;}return _b(t,e),Yk(t,[{key:"updateOrigin",value:function value(){var e=this.getBoundingRect(),t=e.width,i=e.height;this.setOrigin(t/2,i/2);}},{key:"updatePoints",value:function value(){var e=this.renderPath,t=this.getLocalPosition(),i=[];$k(e).call(e,function(e){i.push({x:e.x+t.x,y:e.y+t.y});}),this.updateStyle({x1:i[0].x||0,y1:i[0].y||0,x2:i[1].x||0,y2:i[1].y||0});}},{key:"updateStyle",value:function value(e){var t,i=this;$k(t=eS(e)).call(t,function(t){RL(t,e)&&(i.style[t]=e[t]);});}},{key:"updatePosition",value:function value(e,t){this.style.x=e,this.style.y=t;}},{key:"getPath",value:function value(){var e=this.renderable,t=this.parsedStyle,i=t.x1,r=t.x2,n=t.y1,o=t.y2,a=this.getBoundingRect(),s=a.x,u=a.y;return this.path&&!e.isRenderable()||(this.renderPath=[{x:i-s,y:n-u},{x:r-s,y:o-u}],this.path=[{x:i,y:n},{x:r,y:o}],this.steps=pW(this.renderPath,!1),e.toRenderable()),this.path;}},{key:"getBoundingRect",value:function value(){var e=this.parsedStyle,t=e.x1,i=e.x2,r=e.y1,n=e.y2,o=e.borderWidth,a=e.lineCap;return xW({x:t,y:r},{x:i,y:n},o.value,a);}},{key:"getBoundingRectObject",value:function value(){var e=this.getBoundingRect(),t=e.x,i=e.y,r=e.width,n=e.height;return new UW({style:{x:t,y:i,width:r,height:n,borderWidth:1,background:"rgba(0,0,0,0)"}});}},{key:"isPointInPath",value:function value(e){if(!this.getBoundingRectObject().isPointInPath(e))return!1;var t=this.parsedStyle,i=t.x1,r=t.x2,n=t.y1,o=t.y2,a=t.borderWidth;return VW({x:i,y:n},{x:r,y:o},a.value<20?10:a.value/2,e);}}]);}(mW),OW=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.style,n=zf(i,oL);return Xk(this,t),Wk(yb(e=cL(this,t,[Fk({type:"path",style:Fk(Fk({},kW),{},{points:[],lineJoin:"miter",lineCap:"butt",borderWidth:2,miterLimit:4},r)},n)])),"shapeType","path"),Wk(yb(e),"renderPath",void 0),Wk(yb(e),"pointArray",[]),Wk(yb(e),"pointLength",0),Wk(yb(e),"initialRect",void 0),e.getPath(),e.initialRect=e.getBoundingRect(),e.updatePosition(e.initialRect.x,e.initialRect.y),e.setOrigin(e.initialRect.width,e.initialRect.height),e;}return _b(t,e),Yk(t,[{key:"addPoint",value:function value(e){var t=Kb(this.style.points);t.push(e),this.style.points=t;}},{key:"updateStyle",value:function value(e){var t,i=this;$k(t=eS(e)).call(t,function(t){RL(t,e)&&(i.style[t]=e[t]);});}},{key:"updateOrigin",value:function value(){var e=this.getBoundingRect(),t=e.width,i=e.height;this.setOrigin(t/2,i/2);}},{key:"updatePosition",value:function value(e,t){this.style.x=e,this.style.y=t;}},{key:"getPath",value:function value(){var e,t,i=$E(e=this.parsedStyle.points).call(e,function(e){return new IN(e.x,e.y);});return i=lS(t=this.pointArray).call(t,RW(i,this.pointLength,i.length,2)),this.parsedStyle.points.length-this.pointLength==30&&(this.pointArray=_SL(i),this.pointLength=this.parsedStyle.points.length),i.length<=3&&i.push(i[i.length-1].clone()),i=function(e){var t=e.length;if(t<3)return e;var i=[];if(3===t)i.push(e[0].clone(),e[1].clone(),e[2].clone(),e[2].clone());else{var r=RI(e).call(e);i.push(r[0]);for(var n=0;n+21&&void 0!==arguments[1]&&arguments[1],i=e.length;if(i<=1)return[];var r=[],n=Gb(e,1)[0];r.push(yW("moveTo",[n]));for(var o=0;o+22&&r.push(yW("lineTo",[n])),r;}(this.renderPath),this.path;}},{key:"getRenderPath",value:function value(e){var t=this.getBoundingRect(),i=t.x,r=t.y,n=[];return $k(e).call(e,function(e){!e||fS(e.x)||fS(e.y)||n.push({x:e.x-i,y:e.y-r});}),n;}},{key:"getBoundingRect",value:function value(){var e=this.parsedStyle,t=e.borderWidth,i=e.points,r=e.lineCap,n=$E(i).call(i,function(e){return new IN(e.x,e.y);}),o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=e.length;if(i<3)return e;var r=[];if(3===i)r.push(e[0].clone(),e[1].clone(),e[2].clone(),e[2].clone());else{var n=RI(e).call(e);n.unshift(e[0]),n.push(e[e.length-1]);var o=[],a=1-t;r.push(_SL(n[0]));for(var s=1;s+22&&void 0!==arguments[2]?arguments[2]:10,r=0;r0&&void 0!==arguments[0]?arguments[0]:{},r=i.style,n=zf(i,aL);Xk(this,t),Wk(yb(e=cL(this,t,[Fk({type:"polygon",style:Fk(Fk({},kW),{},{points:[{x:0,y:0},{x:10,y:10}],miterLimit:4,borderWidth:2},r)},n)])),"shapeType","polygon"),Wk(yb(e),"renderPath",void 0),0===e.parsedStyle.points.length&&(e.style.points=[{x:0,y:0},{x:10,y:10}]);var o=e.getBoundingRect(),a=o.x,s=o.y,u=o.width,l=o.height;return e.updatePosition(a,s),e.setOrigin(u/2,l/2),e;}return _b(t,e),Yk(t,[{key:"addPoint",value:function value(e){var t=Kb(this.style.points);t.push(e),this.style.points=t;}},{key:"updatePoints",value:function value(){var e=this.renderPath,t=this.getLocalPosition(),i=[];$k(e).call(e,function(e){i.push({x:e.x+t.x,y:e.y+t.y});}),this.style.points=i;}},{key:"updateStyle",value:function value(e){var t,i=this;$k(t=eS(e)).call(t,function(t){RL(t,e)&&(i.style[t]=e[t]);});}},{key:"updateOrigin",value:function value(){var e=this.getBoundingRect(),t=e.width,i=e.height;this.setOrigin(t/2,i/2);}},{key:"updatePosition",value:function value(e,t){this.style.x=e,this.style.y=t;}},{key:"getPath",value:function value(){var e,t=this.getBoundingRect(),i=t.x,r=t.y;return this.path=this.parsedStyle.points,this.renderPath=$E(e=this.parsedStyle.points).call(e,function(e){return{x:e.x-i,y:e.y-r};}),this.steps=pW(this.renderPath,!0),this.path;}},{key:"getBoundingRect",value:function value(){var e=this.parsedStyle,t=e.borderWidth,i=e.points,r=e.lineCap;if(2===i.length)return xW(i[0],i[1],t.value,r);var n=bW(i),o=t.value/2||0;return{x:n.left-o,y:n.top-o,width:n.width+2*o,height:n.height+2*o};}},{key:"getBoundingRectObject",value:function value(){var e=this.getBoundingRect(),t=e.x,i=e.y,r=e.width,n=e.height;return new UW({style:{x:t,y:i,width:r,height:n,borderWidth:1,background:"rgba(0,0,0,0)"}});}},{key:"isPointInPath",value:function value(e){if(!this.getBoundingRectObject().isPointInPath(e))return!1;var t=this.parsedStyle,i=t.borderWidth,r=t.background,n=t.points,o=i&&i.value,a=i.value<20?10:i.value/2,s=!1;return o&&(s=TW(n,a,e.x,e.y,!0)),!s&&r&&(s=function(e,t,i){var r=!1,n=e.length;if(n<=2)return!1;for(var o=0;o0!=CW(s.y-i)>0&&CW(t-(i-a.y)*(a.x-s.x)/(a.y-s.y)-a.x)<0&&(r=!r);}return r;}(n,e.x,e.y)),s;}}]);}(mW),HW=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.style,n=zf(i,sL);Xk(this,t),Wk(yb(e=cL(this,t,[Fk({type:"polyline",style:Fk(Fk({},kW),{},{points:[{x:0,y:0},{x:0,y:0}],lineEnding:null,borderWidth:2,miterLimit:4},r)},n)])),"shapeType","polyline"),Wk(yb(e),"renderPath",void 0),e.getPath();var o=e.getBoundingRect(),a=o.x,s=o.y;return e.updatePosition(a,s),e.updateOrigin(),e;}return _b(t,e),Yk(t,[{key:"initPath",value:function value(){var e=this.parsedStyle,t=e.points,i=e.lineEnding;t.length;var r=[];if($k(t).call(t,function(e,t){0===t?r.push({x:e.x,y:e.y,step:0,close:!1}):r.push({x:e.x,y:e.y,step:1,close:!1});}),i)for(var n=0;n2&&void 0!==arguments[2]&&arguments[2],r=this.parsedStyle,n=r.points,o=r.borderWidth,a=n.length,s=n[a-2],u=n[a-1];0===t&&(s=Fk({},n[1]),u=Fk({},n[0])),EW(e,t,i,s,u,o.value);}},{key:"addCloseArrow",value:function value(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.parsedStyle,n=r.points,o=r.borderWidth,a=n.length,s=n[a-2],u=n[a-1];0===t&&(s=Fk({},n[1]),u=Fk({},n[0])),PW(e,t,i,s,u,o.value);}},{key:"addCircle",value:function value(e,t){var i=this.parsedStyle,r=i.points,n=i.borderWidth,o=r.length;zW(e,t,r[0],r[o-1],n.value);}},{key:"addDiamond",value:function value(e,t){var i=this.parsedStyle,r=i.points,n=i.borderWidth,o=r.length;MW(e,t,r[0],r[o-1],n.value);}},{key:"addSquare",value:function value(e,t){var i=this.parsedStyle,r=i.points,n=i.borderWidth,o=r.length;DW(e,t,r[0],r[o-1],n.value);}},{key:"addSlash",value:function value(e,t){var i=this.parsedStyle,r=i.points,n=i.borderWidth,o=r.length,a=r[o-2],s=r[o-1];0===t&&(a=Fk({},r[1]),s=Fk({},r[0])),DW(e,t,a,s,n.value);}},{key:"addButt",value:function value(e,t){var i=this.parsedStyle,r=i.points,n=i.borderWidth,o=r.length,a=r[o-2],s=r[o-1];0===t&&(a=Fk({},r[1]),s=Fk({},r[0])),BW(e,t,a,s,n.value);}}]);}(mW),FW=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.style,n=zf(i,uL);Xk(this,t),Wk(e=cL(this,t,[Fk({type:"text",style:Fk(Fk({},kW),{},{x:0,y:0,text:"",width:300,wordWarp:!0,wordBreak:!0,underline:!1,strikeout:!1,textAlign:"left",textBaseLine:"top",textTransform:"none",letterSpacing:0,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",fontFamily:"Microsoft YaHei",color:"white",fontSize:12,lineHeight:12},r)},n)]),"shapeType","text"),Wk(e,"lines",[]),Wk(e,"chars",[]),Wk(e,"totalHeight",void 0),Wk(e,"textX",void 0),Wk(e,"textY",void 0),Wk(e,"rowWidth",void 0),Wk(e,"realWidth",void 0),Wk(e,"cacheWidth",void 0),Wk(e,"font",void 0);var o=e.parsedStyle,a=o.x,s=o.y;return e.setFont(),e.calculateTextPosition(),e.lineWrap(),e.saveCharPosition(),e.setLocalPosition(a,s),e.updateOrigin(),e;}return _b(t,e),Yk(t,[{key:"setFont",value:function value(){var e,t,i,r,n,o=this.parsedStyle,a=o.fontStyle,s=o.fontVariant,u=o.fontWeight,l=o.fontFamily,c=o.fontSize;this.font=lS(e=lS(t=lS(i=lS(r=lS(n="".concat(a," ")).call(n,s," ")).call(r,u," ")).call(i,c.value)).call(t,c.unit," ")).call(e,l);}},{key:"updateStyle",value:function value(e){var t,i=this;$k(t=eS(e)).call(t,function(t){RL(t,e)&&(i.style[t]=e[t]);});}},{key:"updateOrigin",value:function value(){if(this.chars[0]){var e=this.getBoundingRect(),t=e.width,i=e.height,r=this.chars[0].height/10||0,n=this.chars[0].height/2||0,o=0;switch(this.parsedStyle.textBaseLine){case"top":o=i/2-r;break;case"hanging":o=i/2;break;case"middle":o=-r+n*(this.lines.length-1);break;case"ideographic":o=1.5*-r+n*(this.lines.length-2);break;case"bottom":o=-r+n*(this.lines.length-2);break;default:o=r+n*(this.lines.length-2);}this.setOrigin(t/2-r,o);}}},{key:"updatePosition",value:function value(e,t){this.style.x=e,this.style.y=t;}},{key:"calculateTextPosition",value:function value(){var e=this.parsedStyle,t=e.x,i=e.y,r=e.width,n=e.letterSpacing,o=e.borderWidth,a=((null==o?void 0:o.value)||0)/2;this.textX=t+a+n.value,this.textY=i+a+n.value,this.rowWidth=r.value-2*a-2*n.value;}},{key:"lineWrap",value:function value(){this.totalHeight=0,this.realWidth=0;var e=this.textX,t=this.rowWidth,i=this.parsedStyle,r=i.lineHeight,n=i.wordWarp,o=i.fontSize,a=i.borderWidth,s=document.createElement("canvas").getContext("2d"),u=0;s.font=this.font;var l=o.value>r?o.value:r,c=this.transformText(this.parsedStyle.text);if(c.length||(this.lines=[],this.totalHeight=0),c.length){for(var h=[],d=this.textY,f="",v=0;v=t&&n){if(""===(f=f.substring(0,f.length-1))){f=g;continue;}u+=f.length;var m=s.measureText(f).width;m>this.realWidth&&(this.realWidth=s.measureText(f).width),h.push({text:f,x:e,y:d,lineWidth:m,length:f.length,sum:u}),f=g,d+=l,this.totalHeight+=l;}}else{var y=s.measureText(f).width;y>this.realWidth&&(this.realWidth=s.measureText(f).width),u+=(f+=g).length,h.push({text:f,x:e,y:d,lineWidth:y,length:f.length,sum:u}),f="",d+=l,this.totalHeight+=l;}}if(""!==f){u+=f.length;var p=s.measureText(f).width;p>this.realWidth&&(this.realWidth=s.measureText(f).width),h.push({text:f,x:e,y:d,lineWidth:p,length:f.length,sum:u});}this.totalHeight+=l,this.lines=h;}1===this.lines.length&&(this.realWidth=s.measureText(this.lines[0].text).width),a&&a.value&&(this.realWidth+=a.value);}},{key:"getBoundingRect",value:function value(){var e=this.parsedStyle,t=e.x,i=e.y,r=e.textBaseLine,n=e.fontSize,o=e.lineHeight,a=n.value>o?n.value:o,s=a/10;return{x:t-s,y:jW(r,i,a)-s,width:this.realWidth+2*s,height:this.totalHeight};}},{key:"getBoundingRectObject",value:function value(){var e=this.getBoundingRect(),t=e.x,i=e.y,r=e.width,n=e.height;return new UW({style:{x:t,y:i,width:r,height:n,borderWidth:1,background:"rgba(0,0,0,0)"}});}},{key:"isPointInPath",value:function value(e){return this.getBoundingRectObject().isPointInPath(e);}},{key:"saveCharPosition",value:function value(){var e=this;this.chars=[];var t=this.lines,i=this.parsedStyle,r=i.fontSize,n=i.textBaseLine,o=document.createElement("canvas").getContext("2d"),a=r.value;o.font=this.font;var s=0;$k(t).call(t,function(t,i){for(var r=t.x,u=0;u0&&void 0!==arguments[0]?arguments[0]:{},r=i.style,n=zf(i,lL);Xk(this,t),Wk(yb(e=cL(this,t,[Fk({type:"freeline",style:Fk(Fk({},kW),{},{startPoint:{x:0,y:0},endPoint:{x:0,y:0},lineEnding:null,borderWidth:2},r)},n)])),"shapeType","freeline"),Wk(yb(e),"renderPath",void 0),e.getPath();var o=e.getBoundingRect(),a=o.x,s=o.y;return e.updatePosition(a,s),e.updateOrigin(),e;}return _b(t,e),Yk(t,[{key:"initPath",value:function value(){var e=this.parsedStyle,t=e.startPoint,i=e.endPoint,r=e.lineEnding,n=[Fk(Fk({},t),{},{step:0,close:!1}),Fk(Fk({},i),{},{step:1,close:!0})];if(r)for(var o=0;o2&&void 0!==arguments[2]&&arguments[2],r=this.parsedStyle;EW(e,t,i,r.startPoint,r.endPoint,r.borderWidth.value);}},{key:"addCloseArrow",value:function value(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.parsedStyle;PW(e,t,i,r.startPoint,r.endPoint,r.borderWidth.value);}}]);}(mW),XW=1/0,qW=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1/0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1/0;Xk(this,e),Wk(this,"minX",void 0),Wk(this,"maxX",void 0),Wk(this,"minY",void 0),Wk(this,"maxY",void 0),Wk(this,"rect",void 0),Wk(this,"updateId",void 0),this.minX=t,this.maxX=i,this.minY=r,this.maxY=n,this.rect=null,this.updateId=-1;}return Yk(e,[{key:"setFromBounds",value:function value(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this;}},{key:"clear",value:function value(){return this.minX=XW,this.maxX=-1/0,this.minY=XW,this.maxY=-1/0,this;}},{key:"getRect",value:function value(e){var t=this.minX,i=this.minY,r=this.maxX,n=this.maxY;if(t>r||i>n)return new ZN(0,0,0,0);var o=e||new ZN();return o.update(t,i,r-t,n-i),o;}},{key:"addPoint",value:function value(e){return this.addBounds({minX:e.x,maxX:e.x,minY:e.y,maxY:e.y});}},{key:"addBounds",value:function value(e){var t=_W(this,e);return this.setFromBounds(t);}},{key:"addBoundsMask",value:function value(e,t){var i=ZW(e,t);if(i.minX<=i.maxX&&i.minY<=i.maxY){var r=_W(i,this);this.setFromBounds(r);}return this;}},{key:"intersection",value:function value(t){if(r=t,!((i=this).minX<=r.maxX&&i.maxX>=r.minX&&i.minY<=r.maxY&&i.maxY>=r.minY))return null;var i,r,n=ZW(this,t);return e.fromBounds(n);}},{key:"union",value:function value(t){var i=_W(this,t);return e.fromBounds(i);}},{key:"addBoundsArea",value:function value(e,t){var i=t.x,r=t.y,n={minX:i,minY:r,maxX:i+t.width,maxY:r+t.height};return this.addBoundsMask(e,n);}},{key:"addFrame",value:function value(e,t){return this.setFromTransformedBounds(e.worldTransform,t);}},{key:"setFromTransformedBounds",value:function value(e,t){for(var i=0;i<2;i++){var r=e.transformPoint({x:i?t.maxX:t.minX,y:i?t.maxY:t.minY});this.addPoint(r);}return this;}},{key:"addQuad",value:function value(e){for(var t=0;t<4;t++)this.addPoint({x:e[2*t],y:e[2*t+1]});}}],[{key:"isEmpty",value:function value(e){return e.minX===e.maxX&&e.minY===e.maxY;}},{key:"fromBounds",value:function value(t){return new e().setFromBounds(t);}},{key:"create",value:function value(){return new e();}}]);}();function ZW(e,t){return{minX:e.minX>t.minX?e.minX:t.minX,minY:e.minY>t.minY?e.minY:t.minY,maxX:e.maxXt.maxX?e.maxX:t.maxX,maxY:e.maxY>t.maxY?e.maxY:t.maxY};}var GW=function(e){function t(){var e;return Xk(this,t),Wk(yb(e=cL(this,t)),"defaultView",void 0),Wk(yb(e),"documentElement",void 0),Wk(yb(e),"timeLine",void 0),e.nodeName="document",e.documentElement=new mW({id:"root",style:{visibility:"visible"}}),e.documentElement.ownerDocument=yb(e),e.documentElement.parentNode=yb(e),e.childNodes=[e.documentElement],e;}return _b(t,e),Yk(t,[{key:"children",get:function get(){return this.childNodes;}},{key:"childElementCount",get:function get(){return this.childNodes.length;}},{key:"firstElementChild",get:function get(){return this.firstChild;}},{key:"lastElementChild",get:function get(){return this.lastChild;}},{key:"createElement",value:function value(e,t){var i=this.defaultView.customElements.get(e);return i||console.warn("Unsupported tagName: ",e),new i(t);}},{key:"getElementById",value:function value(e){return null;}},{key:"getElementsByName",value:function value(e){return this.documentElement.getElementsByTagName(e);}},{key:"getElementsByTagName",value:function value(e){return this.documentElement.getElementsByTagName(e);}},{key:"getElementsByClassName",value:function value(e){return this.documentElement.getElementsByClassName(e);}},{key:"append",value:function value(){var e;return(e=this.documentElement).append.apply(e,arguments);}},{key:"prepend",value:function value(){var e;return(e=this.documentElement).prepend.apply(e,arguments);}},{key:"querySelector",value:function value(e){return this.documentElement.querySelector(e);}},{key:"querySelectorAll",value:function value(e){return this.documentElement.querySelectorAll(e);}},{key:"find",value:function value(e){var t;return xP(t=this.documentElement).call(t,e);}},{key:"findAll",value:function value(e){return this.documentElement.findAll(e);}},{key:"appendChild",value:function value(e){return this.documentElement.appendChild(e);}},{key:"cloneNode",value:function value(e){return this.documentElement.cloneNode(e);}},{key:"insertBefore",value:function value(e,t){return this.documentElement.insertBefore(e,t);}},{key:"removeChild",value:function value(e){return this.documentElement.removeChild(e);}},{key:"replaceChild",value:function value(e,t){return this.documentElement.replaceChild(e,t);}},{key:"destroy",value:function value(){}}]);}(sW);function KW(e,t,i){i instanceof FW!=0&&e!==t&&(i.calculateTextPosition(),i.lineWrap(),i.saveCharPosition(),i.updateOrigin());}function $W(e,t,i){if(i instanceof NW!=0&&e!==t){var r=i.getBoundingRect(),n=r.x,o=r.y;i.updatePosition(n,o);}}function JW(e,t,i){if((i instanceof WW||i instanceof HW||i instanceof OW)&&e!==t){i.getPath();var r=i.getBoundingRect(),n=r.x,o=r.y;i.updatePosition(n,o),i.updateOrigin();}}function QW(e,t,i){i instanceof FW!=0&&e!==t&&(i.setFont(),i.calculateTextPosition(),i.lineWrap(),i.saveCharPosition(),i.updateOrigin());}function eH(e,t,i){(i instanceof UW||i instanceof LW)&&e!==t&&i.updateOrigin();}function tH(e,t,i){if(i instanceof YW!=0&&e!==t){i.getPath();var r=i.getBoundingRect(),n=r.x,o=r.y;i.updatePosition(n,o),i.updateOrigin();}}function iH(e,t,i){i instanceof YW==0&&i instanceof HW==0||e!==t&&(i.getPath(),i.updateOrigin());}function rH(e,t,i){t&&(vW[e]=t),i&&(gW[e]||(gW[e]=[]),gW[e].push(i));}function nH(e,t,i){for(var r=0;r1&&pU(a).call(a,function(e,t){return e.style.zIndex-t.style.zIndex;}),$k(a).call(a,function(e){r.renderDisplayObject(e);}),pU(a).call(a,function(e,t){return e.index-t.index;}),o&&e.recursiveCall(function(e){var t=new eW("renderOrderChanged",{renderOrder:e.sortable.renderOrder});e.dispatchEvent(t);});}}}},{key:"dirty",value:function value(){this.renderingContext.renderCondition.add(0);}}]);}();function sH(e,t){var i=Number(e.style.zIndex),r=Number(t.style.zIndex);if(i===r&&e.parentNode){var n=e.parentNode.childNodes,o=void 0===n?[]:n;return OI(o).call(o,e)-OI(o).call(o,t);}return i-r;}var uH=function(e){function t(e){var i;Xk(this,t),Wk(i=cL(this,t),"document",void 0),Wk(i,"customElements",void 0),Wk(i,"devicePixelRatio",void 0),Wk(i,"eventService",void 0),Wk(i,"renderingService",void 0),Wk(i,"renderingContext",void 0),Wk(i,"canvasConfig",void 0),Wk(i,"renderer",void 0),Wk(i,"supportTouchEvent",void 0),Wk(i,"supportPointerEvent",void 0),Wk(i,"contextService",void 0);var r=e.renderer,n=e.dpr,o=e.width,a=e.height,s=e.canvas,u=e.supportPointerEvent,l=e.supportTouchEvent;i.supportPointerEvent=null!=u?u:!!IU.PointerEvent,i.supportTouchEvent=null!=l?l:"touchstart"in window;var c=o,h=a,d=n;return s&&(d=n||window.devicePixelRatio||1,c=o||s.width/d,h=a||s.height/d),i.canvasConfig=Fk(Fk({},e),{},{width:c,height:h,dpr:d}),i.canvasConfig=e,i.renderer=r,i.document=new GW(),i.document.defaultView=i,i.initRenderingContext(),i.renderingService=new aH(i.renderingContext),i.initRenderer(r),i;}return _b(t,e),Yk(t,[{key:"initRenderingContext",value:function value(){var e=this;this.renderingContext={root:this.document.documentElement,force:!1,dirty:!1,renderCondition:new Pz()},this.document.documentElement.addEventListener("child-inserted",function(t){e.mountChildren(t.detail.child);}),this.document.documentElement.addEventListener("child-removed",function(t){e.unmountChildren(t.detail.child);});}},{key:"initRenderer",value:function value(e){this.renderingService.init(),e.initPlugins(this),this.contextService.init(),e.getConfig().autoRendering&&this.render(),this.document.documentElement.recursiveCall(function(e){var t=e.renderable;t&&(t.boundsDirty=!0,t.renderBoundsDirty=!0);}),this.mountChildren(this.document.documentElement);}},{key:"render",value:function value(){var e=new eW("beforeRender",{});this.dispatchEvent(e),this.contextService.clearCanvas(),this.renderingService.render();}},{key:"setDPR",value:function value(e){this.canvasConfig.dpr=e,this.contextService.setDPR(e);}},{key:"resize",value:function value(e,t){this.canvasConfig.width=e,this.canvasConfig.height=t,this.contextService.resize(e,t);}},{key:"getContextService",value:function value(){return this.contextService;}},{key:"getEventService",value:function value(){return this.eventService;}},{key:"appendChild",value:function value(e,t){return this.document.documentElement.appendChild(e,t);}},{key:"insertBefore",value:function value(e,t){return this.document.documentElement.insertBefore(e,t);}},{key:"removeChild",value:function value(e){return this.document.documentElement.removeChild(e);}},{key:"getBoundingClientRect",value:function value(){return this.contextService.getBoundingClientRect();}},{key:"mountChildren",value:function value(e){var t=this;e.recursiveCall(function(e){e.isConnected||(e.isConnected=!0,e.ownerDocument=t.document,e.dispatchEvent(new eW("DOMNodeInsertedIntoDocument",{})));});}},{key:"unmountChildren",value:function value(e){var t,i=this,r=[];e.recursiveCall(function(e){e.isConnected&&r.push(e);}),$k(t=BU(r).call(r)).call(t,function(e){e.isConnected=!1,e.dispatchEvent(new eW("DOMNodeRemovedFromDocument",{})),e!==i.document.documentElement&&(e.ownerDocument=null);});}}]);}(tW),lH=Yk(function e(){Xk(this,e);}),cH=function(e){function t(){var e,i;Xk(this,t);for(var r=arguments.length,n=new Array(r),o=0;o2&&t.closePath();}},{key:"renderFill",value:function value(e,t){var i=e.parsedStyle,r=i.background,n=i.opacity,o=i.fillOpacity;if(t.save(),t.globalAlpha=n*o,_k(r)){this.setShapeGradientOrigin(e,t);for(var a=0;a0&&(t.save(),UL(n)||(t.lineWidth=n.value),t.miterLimit=l,t.globalAlpha=a*d,t.lineCap=s,t.lineJoin=u,t.setLineDash(c),t.lineDashOffset=h.value,_k(o)?(this.setShapeGradientOrigin(e,t),$k(o).call(o,function(r){t.strokeStyle=i.getColor(e,r,t),t.stroke();})):(t.strokeStyle=o.formatted,t.stroke()),t.restore());}},{key:"setShadow",value:function value(e,t){var i=e.parsedStyle,r=i.shadow,n=i.shadowOffsetX,o=i.shadowOffsetY,a=i.shadowBlur,s=i.shadowColor;(r||s)&&(t.shadowOffsetX=(null==n?void 0:n.value)||r[0],t.shadowOffsetY=(null==o?void 0:o.value)||r[1],t.shadowBlur=(null==a?void 0:a.value)||r[2],t.shadowColor=(null==s?void 0:s.formatted)||r[3]);}},{key:"getColor",value:function value(e,t,i){var r;if(1===t.type||2===t.type){var n=e.getBoundingRect(),o=n.width,a=n.height;r=function(e,t){var i=e.type,r=e.steps,n=e.width,o=e.height,a=e.angle,s=e.cx,u=e.cy,l=e.size,c=null;if(1===i){var h=function(e,t,i){var r=i*Math.PI/180,n=0+e/2,o=0+t/2,a=Math.abs(e*Math.cos(r))+Math.abs(t*Math.sin(r));return{x1:n-Math.cos(r)*a/2,y1:o-Math.sin(r)*a/2,x2:n+Math.cos(r)*a/2,y2:o+Math.sin(r)*a/2};}(n,o,a.value),d=h.x1,f=h.y1,v=h.x2,g=h.y2;c=t.createLinearGradient(d,f,v,g);}else if(2===i){var m=function(e,t,i,r,n){var o=i.value,a=r.value;"%"===i.unit&&(o=i.value/100*e),"%"===r.unit&&(a=r.value/100*t);var s=Math.max(IL({x:0,y:0},{x:o,y:a}),IL({x:0,y:t},{x:o,y:a}),IL({x:e,y:t},{x:o,y:a}),IL({x:e,y:0},{x:o,y:a}));return n&&(kL(n)?s=n.value:TL(n)&&("closest-side"===n?s=Math.min(o,e-o,a,t-a):"farthest-side"===n?s=Math.max(o,e-o,a,t-a):"closest-corner"===n&&(s=Math.min(IL({x:0,y:0},{x:o,y:a}),IL({x:0,y:t},{x:o,y:a}),IL({x:e,y:t},{x:o,y:a}),IL({x:e,y:0},{x:o,y:a}))))),{x:o,y:a,r:s};}(n,o,s,u,l),y=m.x,p=m.y,w=m.r;c=t.createRadialGradient(y,p,0,y,p,w);}return c&&$k(r).call(r,function(e){var t,i=e.offset,r=e.color;"%"===i.unit&&(null===(t=c)||void 0===t||t.addColorStop(i.value/100,r.toString()));}),c;}(Fk(Fk({type:t.type},t.value),{},{width:o,height:a}),i);}return r;}},{key:"setShapeGradientOrigin",value:function value(e,t){var i=e.config.type,r=e.parsedStyle,n=r.r,o=r.rx,a=r.ry;switch(i){case"circle":case"arc":t.translate(0-n.value,0-n.value);break;case"ellipse":t.translate(0-o.value,0-a.value);break;default:t.translate(0,0);}}}]);}(lH),hH=function(e){function t(){var e;return Xk(this,t),(e=cL(this,t)).close=!1,e;}return _b(t,e),Yk(t);}(cH),dH=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t);}(cH),fH=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t);}(cH),vH=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t,[{key:"render",value:function value(e,t){var i=e.parsedStyle,r=i.width,n=i.height;i.src;var o=i.img,a=i.opacity;"hidden"!==i.visibility&&(TL(o)||o&&(t.save(),t.globalAlpha=a,o instanceof ImageData?t.putImageData(o,0,0):t.drawImage(o,0,0,r.value,n.value),t.restore()));}}]);}(cH),gH=function(e){function t(){var e;return Xk(this,t),(e=cL(this,t)).close=!1,e;}return _b(t,e),Yk(t);}(cH),mH=function(e){function t(){var e;return Xk(this,t),(e=cL(this,t)).close=!1,e;}return _b(t,e),Yk(t);}(cH),yH=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t);}(cH),pH=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t,[{key:"render",value:function value(e,t){var i=e.parsedStyle,r=i.background,n=i.borderColor;if("hidden"!==i.visibility){var o=!UL(r)&&!r.isNone,a=!UL(n)&&!n.isNone;e.getPath();for(var s=e.steps.length,u=0;u0&&r.strokeText(t,n,0,o,g,null==f?void 0:f.value);}),t.closePath(),t.restore();}},{key:"fillText",value:function value(e,t,i,r,n,o){var a,s=!UL(n)&&1!==n;s&&(a=e.globalAlpha,e.globalAlpha=n*n),e.fillText(t,i,r,o),s&&(e.globalAlpha=a);}},{key:"strokeText",value:function value(e,t,i,r,n,o){var a,s=!UL(n)&&1!==n;s&&(a=e.globalAlpha,e.globalAlpha=n),e.strokeText(t,i,r,o),s&&(e.globalAlpha=a);}}]);}(cH),kH=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t);}(cH),SH=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t,[{key:"render",value:function value(e,t){var i,r=this,n=e.parsedStyle,o=n.background,a=n.borderColor;if("hidden"!==n.visibility){var s=!UL(o)&&!o.isNone,u=!UL(a)&&!a.isNone;e.getPath(),t.beginPath();var l=e.steps.length,c=!0;$k(i=e.steps).call(i,function(i,n){for(var o=0;o-1&&(gE(t=this.docs).call(t,i,1),!0);}},{key:"removePage",value:function value(e,t){var i=this.getDoc(e);return!!i&&i.remove(t);}}]);}(),PH=function(){return Yk(function e(){Xk(this,e),Wk(this,"canvas",void 0),Wk(this,"renderer",void 0),Wk(this,"root",void 0),this.renderer=new TH(),this.canvas=new uH({renderer:this.renderer,width:10,height:10,canvas:document.createElement("canvas"),dpr:1,willReadFrequently:!0}),this.root=this.canvas.document.documentElement;},[{key:"render",value:function value(e){var t,i,r=this;$k(t=RI(i=this.root.children).call(i)).call(t,function(e){r.root.removeChild(e);}),this.root.appendChild(e),this.canvas.resize(e.width,e.height),this.canvas.render();}},{key:"clear",value:function value(){var e,t,i=this;$k(e=RI(t=this.root.children).call(t)).call(e,function(e){i.root.removeChild(e);}),this.root.sortable.sorted=[];}},{key:"getCanvas",value:function value(){return this.canvas.contextService.getDomElement();}}]);}(),BH=function(e){function t(){var e,i;Xk(this,t);for(var r=arguments.length,n=new Array(r),o=0;oo?(g||(g=!0,v=!0,b=n<=a-s?1:(a-s)/n),w=l*b):g&&(g=!1,v=!0),u=c*b;var k="vertical"===m?(y-w-h)/2:0,S="vertical"===m?0:(p-u-d)/2;return k<0&&(k=0),S<0&&(S=0),e.updateLayoutStatus({layoutLeft:k,layoutTop:S,zoom:b,visualWidth:y,visualHeight:p,currentLayoutWidth:w+h,currentLayoutHeight:u+d,isScrollbarChanged:v,isScrollbarXAppeared:g}),e.setZoom(b),!v||"break";},MH=function MH(e){if(e.layoutStatus.skipCalcZoom)return e.layoutStatus.skipCalcZoom=!1,!0;var t=e.layoutStatus,i=t.viewWidth,r=t.viewHeight;t.scrollbarWidth;var n,o,a=t.validVisualWidth,s=t.validVisualHeight,u=t.validLayoutWidth,l=t.validLayoutHeight,c=t.fixedWidth,h=t.fixedHeight,d=t.zoom,f=e.layoutStatus,v=f.isScrollbarXAppeared,g=f.isScrollbarYAppeared,m=f.isScrollbarChanged,y=e.direction,p=r,w=i;n=u*d,o=l*d,Math.floor(n)>a?v||(v=!0,m=!0):v&&(v=!1,m=!0),Math.floor(o)>s?g||(g=!0,m=!0):g&&(g=!1,m=!0);var b="vertical"===y?(w-n-c)/2:0,k="vertical"===y?0:(p-o-h)/2;return b<0&&(b=0),k<0&&(k=0),e.updateLayoutStatus({layoutLeft:b,layoutTop:k,visualWidth:w,visualHeight:p,currentLayoutWidth:n+c,currentLayoutHeight:o+h,isScrollbarXAppeared:v,isScrollbarYAppeared:g,isScrollbarChanged:m}),e.setZoom(d),!m||"break";},zH=function zH(e){if(e.layoutStatus.skipCalcZoom)return e.layoutStatus.skipCalcZoom=!1,!0;var t=e.layoutStatus,i=t.viewWidth,r=t.viewHeight,n=t.calcWidth,o=t.calcViewWidth;t.calcViewHeight;var a,s=t.scrollbarWidth,u=t.validVisualHeight,l=t.validLayoutWidth,c=t.validLayoutHeight,h=t.fixedWidth,d=t.fixedHeight,f=e.layoutStatus,v=f.isScrollbarChanged,g=f.isScrollbarYAppeared,m=e.direction,y=r,p=i,w=0,b=1;(w=c*(b=n<=o?1:o/n))>u?(g||(g=!0,v=!0,b=n<=o-s?1:(o-s)/n),w=c*b):g&&(g=!1,v=!0),a=l*b;var k="vertical"===m?0:(p-a-h)/2,S="vertical"===m?(y-w-d)/2:0;return k<0&&(k=0),S<0&&(S=0),e.updateLayoutStatus({layoutLeft:k,layoutTop:S,zoom:b,visualWidth:p,visualHeight:y,currentLayoutWidth:a+h,currentLayoutHeight:w+d,isScrollbarYAppeared:g,isScrollbarChanged:v}),e.setZoom(b),!v||"break";},AH=function AH(e){if(e.layoutStatus.skipCalcZoom)return e.layoutStatus.skipCalcZoom=!1,!0;var t=e.layoutStatus,i=t.calcWidth,r=t.calcHeight;return i/t.calcViewWidth>=r/t.calcViewHeight?zH(e):DH(e);},UH=function(e){function t(){var e;return Xk(this,t),(e=cL(this,t)).addStrategy("width",zH),e.addStrategy("height",DH),e.addStrategy("window",AH),e.addStrategy("none",MH),e;}return _b(t,e),Yk(t,[{key:"layout",value:function value(e){var t=this.next,i=e.fitType;"break"!==this.executeStrategy(i,e)&&t&&t.layout(e);}}]);}(BH),RH=function RH(e){var t=e.currentPage;if(t){var i=e.layoutStatus,r=i.defaultWidth,n=i.defaultHeight,o=i.viewWidth,a=i.viewHeight,s=e.viewer.context.getMargin(),u=e.borderWidth,l=t.image.style.img,c=t.realTimeWidth||(null==l?void 0:l.naturalWidth)||r,h=t.realTimeHeight||(null==l?void 0:l.naturalHeight)||n;e.viewer.context.config.enableSingleModeBorder||(u=0);var d=2*u,f=2*s,v=o-d-f,g=a-d-f;e.updateLayoutStatus({layoutWidth:c,layoutHeight:h,calcWidth:c,calcHeight:h,calcViewWidth:v,calcViewHeight:g,validVisualWidth:v,validVisualHeight:g,validLayoutWidth:c,validLayoutHeight:h,fixedWidth:f+d,fixedHeight:f+d});}},LH=function LH(e){if(!e.total)return!1;var t=e.layoutStatus,i=t.viewWidth,r=t.viewHeight,n=t.isScrollbarAppeared,o=t.isScrollbarChanged,a=e.layoutStatus.scrollbarWidth,s=e.total,u=e.row,l=e.column,c=e.direction,h=e.enableDWT1x1,d=e.viewer.context.getMargin(),f=e.viewer.context.getGap();1===u&&1===l&&h&&(d=0),l*ud/f?(v=d,g=h*(m=d/c)):(g=f,v=c*(m=f/h));var y=(d-c*m)/2+s/2+u,p=(f-h*m)/2+s/2+u;y=Math.max(u+s/2,y),p=Math.max(u+s/2,p);var w=c*(1-m)/2,b=h*(1-m)/2;return t.borderBox.updateStyle({x:0,y:0,width:v+2*s,height:g+2*s,borderWidth:s}),t.imageContainer.setLocalScale(1),t.imageContainer.updateStyle({x:s-w,y:s-b,width:c,height:h}),t.imageContainer.setLocalScale(m,m,1),t.zoom=m,t.image.updateStyle({x:0,y:0,width:(null===(i=t.image.style.img)||void 0===i?void 0:i.naturalWidth)||0,height:(null===(r=t.image.style.img)||void 0===r?void 0:r.naturalHeight)||0}),t.updateStyle({visibility:"visible"}),t.imageContainer.updateStyle({visibility:"visible"}),t.borderBox.updateStyle({visibility:"visible"}),t.image.updateStyle({visibility:"visible"}),{left:y-s/2,top:p-s/2};}var WH=function(e){function t(){var e;return Xk(this,t),(e=cL(this,t)).addStrategy("single",RH),e.addStrategy("multiple",LH),e.addStrategy("slide",NH),e;}return _b(t,e),Yk(t,[{key:"layout",value:function value(e){var t=this.next,i=e.displayMode;"break"!==this.executeStrategy(i,e)&&t&&t.layout(e);}}]);}(BH),HH=function HH(e){var t=e.layoutStatus,i=t.zoom,r=t.visualWidth,n=t.visualHeight,o=t.defaultWidth,a=t.defaultHeight,s=t.currentLayoutWidth,u=t.currentLayoutHeight,l=e.currentPage,c=e.viewer.context.getMargin(),h=e.borderWidth;if(l){e.viewer.context.uiService.updateScrollContentSize(s,u);var d=e.viewer.context.uiService.scrollContainer,f=d.scrollLeft,v=d.scrollTop;e.setPosition({x:-f,y:-v}),e.viewer.context.config.enableSingleModeBorder||(h=0);var g=l.image.style.img,m=l.realTimeWidth||(null==g?void 0:g.naturalWidth)||o,y=l.realTimeHeight||(null==g?void 0:g.naturalHeight)||a,p=m*i,w=y*i,b=(r-p)/2-h/2,k=(n-w)/2-h/2;b=Math.max(c+h/2,b),k=Math.max(c+h/2,k);var S=m*(1-i)/2,x=y*(1-i)/2;l.updateStyle({x:b-h/2,y:k-h/2,width:p+2*h,height:w+2*h,borderWidth:h}),l.borderBox.updateStyle({x:0,y:0,width:p+2*h,height:w+2*h,borderWidth:h}),l.image.updateStyle({width:(null==g?void 0:g.naturalWidth)||0,height:(null==g?void 0:g.naturalHeight)||0}),l.imageContainer.setLocalScale(1),l.imageContainer.updateStyle({x:h-S,y:h-x,width:m,height:y}),l.imageContainer.setLocalScale(i),l.zoom=i;}},FH=function FH(e){var t=e.layoutStatus,i=t.rowHeightArray,r=t.columnWidthArray,n=t.currentLayoutWidth,o=t.currentLayoutHeight,a=e.children,s=e.row,u=e.column,l=e.direction,c=e.borderWidth,h=e.hoveredBorderWidth,d=e.selectedBorderWidth,f=e.enableDWT1x1,v=e.viewer.context.getMargin(),g=e.viewer.context.getGap();1===s&&1===u&&f&&(v=0);var m=Gb(r,1)[0],y=Gb(i,1)[0];e.viewer.context.uiService.updateScrollContentSize(n,o);var p=e.viewer.context.uiService.scrollContainer,w=p.scrollLeft,b=p.scrollTop;e.setPosition({x:-w,y:-b}),$k(a).call(a,function(t,i){var r,n=c;t.isHovered&&(n=h),OI(r=e.selected).call(r,t.uid)>-1&&(n=d);var o=i%u,a=Math.floor(i/u);"horizontal"===l&&(o=Math.floor(i/s),a=i%s);var f=v+o*(g+m)+n/2,p=v+a*(g+y)+n/2,w=m-2*n,b=y-2*n,k=t.getImage().style.img,S=t.realTimeWidth||(null==k?void 0:k.naturalWidth)||0,x=t.realTimeHeight||(null==k?void 0:k.naturalHeight)||0,C=0,V=0,T=S,I=x,E=1;(S>w||x>b)&&(S/x>w/b?(T=w,I=x*(E=w/S)):(I=b,T=S*(E=b/x))),C+=(w-T)/2,V+=(b-I)/2,C+=n,V+=n;var P=S*(1-E)/2,B=x*(1-E)/2;t.image.updateStyle({width:(null==k?void 0:k.naturalWidth)||0,height:(null==k?void 0:k.naturalHeight)||0}),t.imageContainer.updateStyle({x:C-P,y:V-B,width:S,height:x}),t.imageContainer.setLocalScale(E,E,1),t.zoom=E,t.updateStyle({x:f-n/2,y:p-n/2,width:m,height:y}),t.borderBox.updateStyle({x:0,y:0,width:m,height:y});});},jH=function(e){function t(){var e;return Xk(this,t),(e=cL(this,t)).addStrategy("single",HH),e.addStrategy("multiple",FH),e;}return _b(t,e),Yk(t,[{key:"layout",value:function value(e){var t=this.next,i=e.displayMode;this.executeStrategy(i,e),t&&t.layout(e);}}]);}(BH);function YH(e){var t,i=e.current,r=e.total,n=e.currentPage,o=e.preloadCount;if(e.topPageUid,n){var a=i-o;a<0&&(a=0);var s=i+o;s>=r&&(s=r-1),$k(t=e.children).call(t,function(e,t){var i=e.uid===n.uid,r=t>=a&&t<=s,o=e.isEdited,u=e.isUpdated,l=e.isVisible;((o||u)&&i||!l&&i)&&(e.isPageRendered=!0),e.updateStyle({visibility:i?"visible":"hidden"}),e.borderBox.updateStyle({visibility:i?"visible":"hidden"}),e.image.updateStyle({visibility:i?"visible":"hidden"}),e.imageContainer.updateStyle({visibility:i?"visible":"hidden"}),e.isPreload=r;});}}function XH(e){var t,i=e.layoutStatus,r=i.rowHeightArray,n=i.columnWidthArray,o=i.viewWidth,a=i.viewHeight,s=e.total,u=e.row,l=e.column,c=e.direction,h=e.preloadCount,d=e.topPageUid,f=e.enableDWT1x1,v=e.viewer.context.getMargin(),g=e.viewer.context.getGap();1===u&&1===l&&f&&(v=0);var m=Math.ceil,y=Math.floor,p="vertical"===c,w=p?l:m(s/u),b=p?m(s/l):u,k=0,S=w-1,x=0,C=b-1;if(p)for(var V=0;V1&&(x=V),B-a<-1&&B+P+I-a>=-1){C=V;break;}}}else for(var D=0;D1&&(k=D),R-o<=-1&&R+U+z-o>=-1){S=D;break;}}}var L=null;$k(t=e.children).call(t,function(e,t){var i=p?y(t/l):t%u,r=p?t%l:y(t/u),n=i>=x&&i<=C&&r>=k&&r<=S,o=i>=x-h&&i<=C+h&&r>=k-h&&r<=S+h;n&&!L&&(L=e.uid);var a=e.isEdited,s=e.isUpdated,c=e.isVisible;((a||s)&&n||!c&&n)&&(e.isPageRendered=!0),e.updateStyle({visibility:n?"visible":"hidden"}),e.borderBox.updateStyle({visibility:n?"visible":"hidden"}),e.imageContainer.updateStyle({visibility:n?"visible":"hidden"}),e.image.updateStyle({visibility:n?"visible":"hidden"}),e.isPreload=o;var d={x:r<=k?"ahead":r>=S?"behind":"inside",y:i<=x&&i=C&&i>=x?"behind":"inside",column:r,row:i};e.viewportPosition=d;}),L&&L!==d&&(e.isTopPageChanged=!0,e.topPageUid=L);}var qH=function(e){function t(){var e;return Xk(this,t),(e=cL(this,t)).addStrategy("single",YH),e.addStrategy("multiple",XH),e;}return _b(t,e),Yk(t,[{key:"layout",value:function value(e){var t=this.next,i=e.displayMode;this.executeStrategy(i,e),t&&t.layout(e);}}]);}(BH),ZH=function(){return Yk(function e(){Xk(this,e),Wk(this,"viewers",void 0),Wk(this,"group",{}),Wk(this,"isDestroyed",!1),this.viewers=[];},[{key:"destroy",value:function value(){this.isDestroyed||(this.viewers=[],this.viewers=null,this.group=null,this.isDestroyed=!0);}},{key:"addViewer",value:function value(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(OI(t=this.viewers).call(t,e)>-1)return!1;var r=[];return this.group[i]?r=this.group[i]:this.group[i]=r,r.push(e.uid),this.viewers.push(e),!0;}},{key:"removeViewer",value:function value(e){var t,i,r=EE(t=this.viewers).call(t,function(t){return t.uid===e.uid;});if(r<0)return!1;var n=this.group[e.groupUid],o=OI(n).call(n,e.uid);return gE(n).call(n,o,1),0===n.length&&delete this.group[e.groupUid],gE(i=this.viewers).call(i,r,1),e.destroy(),!0;}},{key:"getViewer",value:function value(e){var t=this.viewers;return e?xP(t).call(t,function(t){return t.uid===e;}):t[0]||null;}},{key:"getAllViewers",value:function value(){var e;return RI(e=this.viewers).call(e);}},{key:"getGroup",value:function value(e){var t=this.getViewer(e);return t?this.group[t.groupUid]:null;}}]);}();function _H(){onmessage=function onmessage(e){var t=e.data.core,i=e.data.sourceWidth,r=e.data.sourceHeight,n=e.data.width,o=e.data.height,a=e.data.source.data,s=n*o*4,u=new ArrayBuffer(s),l=null;try{l=new Uint8ClampedArray(u,0,s);}catch(e){l=new Uint8Array(u,0,s);}for(var c=0;c=e.length?{done:!0}:{done:!1,value:e[r++]};},e:function e(_e2){throw _e2;},f:n};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,s=!1;return{s:function s(){i=i.call(e);},n:function n(){var e=i.next();return a=e.done,e;},e:function e(_e3){s=!0,o=_e3;},f:function f(){try{a||null==i.return||i.return();}finally{if(s)throw o;}}};}(this.actors);try{for(t.s();!(e=t.n()).done;){e.value.getWorker().terminate();}}catch(e){t.e(e);}finally{t.f();}this.actors=[];}}]);}(),$H=function(){return Yk(function e(){Xk(this,e);},[{key:"apply",value:function value(e){this.listenSpaceHooks(e),this.listenDVSHooks(e);}},{key:"listenDVSHooks",value:function value(e){var t=this,i=e.hooksService.hooks,r=function r(t){var i=e.spaceService.space;t.trigger!==i.uid&&i.removeSource(t.removedUids);},n=function n(t){var i=e.spaceService.space;t.trigger!==i.uid&&i.move(Fk({emit:!1},t));},o=function o(t){var i=e.spaceService.space;t.trigger!==i.uid&&i.switch(Fk({emit:!1},t));},a=function a(t){var i=e.spaceService.space;t.trigger!==i.uid&&i.reorder(Fk({emit:!1},t));},s=function s(){t.listenSpaceHooks(e);};i.remove.on(r),i.move.on(n),i.switch.on(o),i.reorder.on(a),i.afterSetSpace.on(s),e.hooksService.hooks.destroy.on(function(){i.remove.off(r),i.move.off(n),i.switch.off(o),i.reorder.off(a),i.afterSetSpace.off(s);});}},{key:"listenSpaceHooks",value:function value(e){var t=e.spaceService.space.hooks,i=e.hooksService.hooks,r=function r(e){var t=e.uid;i.removeDoc.emit(t);},n=function n(e){var t=e.name,r=e.uid;i.renameDoc.emit(t,r);},o=function o(t){var i=t.node,r=t.config,n=t.type;e.viewerService.openDoc(i,n,null==r?void 0:r.viewerUid);},a=function a(e){i.appendPagesToDoc.emit(e);},s=function s(e){i.removePagesFromDoc.emit(e);},u=function u(e){i.afterUpdate.emit(e);},l=function l(e){i.remove.emit(e);},c=function c(e){i.switch.emit(e);},h=function h(e){i.move.emit(e);},d=function d(e){i.reorder.emit(e);};t.removeDoc.on(r),t.renameDoc.on(n),t.openDoc.on(o),t.loadToDoc.on(a),t.removeFromDoc.on(s),t.afterUpdateSource.on(u),t.afterRemoveSource.on(l),t.switch.on(c),t.move.on(h),t.reorder.on(d);var _f2=function f(){t.removeDoc.off(r),t.renameDoc.off(n),t.openDoc.off(o),t.loadToDoc.off(a),t.removeFromDoc.off(s),t.afterUpdateSource.off(u),t.afterRemoveSource.off(l),t.switch.off(c),t.move.off(h),t.reorder.off(d),e.spaceService.space.hooks.destroy.off(_f2),e.hooksService.hooks.afterSetSpace.off(_f2);};e.spaceService.space.hooks.destroy.on(_f2),e.hooksService.hooks.afterSetSpace.on(_f2);}}]);}(),JH=function(){return Yk(function e(){Xk(this,e);},[{key:"apply",value:function value(e){this.listenDVSHooks(e);}},{key:"listenDVSHooks",value:function value(e){var t=e.hooksService.hooks,i=function i(t){var i=e.viewerService.getDoc(t.docUid);i&&i.move(t.from,t.to);},r=function r(t){var i=e.viewerService.getDoc(t.docUid);i&&i.switch(t.one,t.other);},n=function n(t){var i=e.viewerService.getDoc(t.docUid);i&&i.reorder(t.indexes);},o=function o(t,i){var r=e.viewerService.getDoc(t);r&&r.removeOwner(i);},a=function a(t){var i=t.uid;e.viewerService.removeDoc(i);},s=function s(t){var i=t.name,r=t.uid;e.viewerService.renameDoc(i,r);},u=function u(t){e.viewerService.appendImagesToDoc(t.docUid,t.sourceUids,t.index);},l=function l(t){e.viewerService.removePagesFromDoc(t.docUid,t.sourceUids);},_c2=function c(){e.viewerService.destroy(),t.move.off(i),t.switch.off(r),t.reorder.off(n),t.removeTab.off(o),t.removeDoc.off(a),t.renameDoc.off(s),t.appendPagesToDoc.off(u),t.removePagesFromDoc.off(l),t.destroy.off(_c2);};t.move.on(i),t.switch.on(r),t.reorder.on(n),t.removeTab.on(o),t.removeDoc.on(a),t.renameDoc.on(s),t.appendPagesToDoc.on(u),t.removePagesFromDoc.on(l),t.destroy.on(_c2);}}]);}(),QH=function(){return Yk(function e(t){Xk(this,e),Wk(this,"context",void 0),Wk(this,"errorMessage","ok"),Wk(this,"errorCode",0),this.context=t;},[{key:"updateErrorMessage",value:function value(e){this.errorMessage=e.message,this.errorCode=e.code;}},{key:"err",value:function value(e){this.errorMessage=e.message,this.errorCode=e.code;}},{key:"destroy",value:function value(){this.errorMessage="",this.errorCode=null;}}]);}(),eF=Yk(function e(t){Xk(this,e),Wk(this,"context",void 0),Wk(this,"hooks",{init:SN.create(),destroy:SN.create(),beforeLoad:SN.create(),load:SN.create(),afterLoad:SN.create(),beforeRemove:SN.create(),remove:SN.create(),afterRemove:SN.create(),beforeUpdate:SN.create(),update:SN.create(),afterUpdate:SN.create(),move:SN.create(),switch:SN.create(),reorder:SN.create(),appendPagesToDoc:SN.create(),removePagesFromDoc:SN.create(),removeDoc:SN.create(),renameDoc:SN.create(),openDoc:SN.create(),beforeChangeBuffer:SN.create(),afterChangeBuffer:SN.create(),changePage:SN.create(),selectPage:SN.create(),beforeRender:SN.create(),render:SN.create(),afterRender:SN.create(),createViewer:SN.create(),removeViewer:SN.create(),afterLoadImage:SN.create(),error:SN.create(),log:SN.create(),rotate:SN.create(),scale:SN.create(),flip:SN.create(),mirror:SN.create(),crop:SN.create(),erase:SN.create(),changeSize:SN.create(),reset:SN.create(),overlay:SN.create(),beforeUndo:SN.create(),undo:SN.create(),beforeRedo:SN.create(),redo:SN.create(),layout:SN.create(),beforeSetSpace:SN.create(),afterSetSpace:SN.create(),focusChanged:SN.create(),checkVisibility:SN.create(),removeTab:SN.create()}),this.context=t;}),tF=function(){return Yk(function e(t){Xk(this,e),Wk(this,"imagePool",{}),Wk(this,"tasks",[]),Wk(this,"loaders",3),Wk(this,"loadTimer",null),Wk(this,"context",void 0),Wk(this,"isDestroyed",!1),this.context=t;},[{key:"destroy",value:function value(){this.context=null,this.tasks=[],this.loaders=0,this.isDestroyed=!0;}},{key:"checkVisibility",value:function value(e){return this.context.viewerService.isPageNeedLoad(e);}},{key:"load",value:function value(e){var t,i=this,r=this.context.spaceService.getStatus(e);r&&!r.isLoading&&(OI(t=this.tasks).call(t,e)<0&&(this.tasks.push(e),this.loading()),this.loadTimer||(this.loadTimer=$N.createTimer(function(){i.loading();},20)));}},{key:"loading",value:function value(){if(this.loaders>0)if(this.tasks.length)for(;this.tasks.length;){var e=this.tasks.shift();if(this.context.viewerService.isPageNeedLoad(e).ori&&(this.loaders-=1,this.run(e).catch(function(){})),this.loaders<1)break;}else this.loadTimer&&($N.clearTimer(this.loadTimer),this.loadTimer=null);}},{key:"run",value:(t=mb(vb().mark(function e(t){var i,r,n,o,a,s,u,l,c,h,d;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=this.context,r=i.spaceService,n=i.hooksService,o=i.viewerService,!(a=r.getStatus(t))){e.next=49;break;}if(a.isLoading=!0,s=WL(),a.oriTask=s,a.oriData){e.next=33;break;}return e.next=7,r.getOriginalData(t);case 7:if(u=e.sent,a.oriTask===s){e.next=12;break;}return e.next=11,this.run(t);case 11:return e.abrupt("return",void e.sent);case 12:if(o.isPageNeedLoad(t).ori){e.next=14;break;}return e.abrupt("return",(this.loaders+=1,void(a.isLoading=!1)));case 14:if(u&&u.oriData){e.next=24;break;}if(l=r.getExternalImageLoader()){e.next=18;break;}return e.abrupt("return",(this.loaders+=1,void(a.isLoading=!1)));case 18:return e.next=20,l.getImage(t);case 20:if(c=e.sent){e.next=23;break;}return e.abrupt("return",(this.loaders+=1,void(a.isLoading=!1)));case 23:u.oriData=c,r.updateOriginalData(t,u);case 24:if(h="",10!==document.documentMode){e.next=31;break;}return e.next=28,this.convertData(u.oriData);case 28:h=e.sent.data,e.next=32;break;case 31:h=vN(u.oriData).data;case 32:a.oriData=h;case 33:if(a.img&&(!a.img||a.img.src===a.oriData)){e.next=48;break;}if(!this.isDestroyed){e.next=36;break;}return e.abrupt("return");case 36:return e.next=38,this.loadImage(a.oriData);case 38:if(d=e.sent){e.next=41;break;}return e.abrupt("return",(this.loaders+=1,void(a.isLoading=!1)));case 41:if(a.oriTask===s){e.next=45;break;}return e.next=44,this.run(t);case 44:return e.abrupt("return",void e.sent);case 45:if(o.isPageNeedLoad(t).ori){e.next=47;break;}return e.abrupt("return",(this.loaders+=1,void(a.isLoading=!1)));case 47:a.img=d;case 48:a.isLoading=!1,n.hooks.afterLoadImage.emit(t,"ori");case 49:this.loaders+=1;case 50:case"end":return e.stop();}},e,this);})),function(e){return t.apply(this,arguments);})},{key:"convertData",value:function value(e){return new uB(function(t,i){if(kL(e))t(e);else{var r=new XMLHttpRequest();r.onload=function(){var e=vN(r.response);t(e);},r.open("GET",e,!0),r.responseType="blob",r.send();}});}},{key:"loadImage",value:(e=mb(vb().mark(function e(t){return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new uB(function(e,i){var r=new Image();r.crossOrigin="Anonymous",r.onload=function(){r.onload=null,r.onerror=null,e(r);},r.onerror=function(t){r.onload=null,r.onerror=null,e(null);},r.src=t;}));case 1:case"end":return e.stop();}},e);})),function(t){return e.apply(this,arguments);})}]);var e,t;}(),iF=function(){return Yk(function e(t){Xk(this,e),Wk(this,"context",void 0),Wk(this,"layouts",[]),Wk(this,"head",void 0),this.context=t,this.use(new WH()),this.use(new UH()),this.use(new jH()),this.use(new qH()),this.init();},[{key:"use",value:function value(e){var t;OI(t=this.layouts).call(t,e)>-1||this.layouts.push(e);}},{key:"clear",value:function value(){this.layouts=[];}},{key:"layout",value:function value(e){0!==e.total?this.head.layout(e):e.layoutStatus.reset();}},{key:"destroy",value:function value(){this.head=null;}},{key:"init",value:function value(){var e=this.layouts;if(e.length){var t=e[0],i=null;this.head=t;for(var r=1,n=e.length;r0)if(this.tasks.length)for(;this.tasks.length;){var e=this.tasks.shift();if(this.context.viewerService.isPageNeedLoad(e).min&&(this.loaders-=1,this.run(e).catch(function(){})),this.loaders<1)break;}else this.loadTimer&&($N.clearTimer(this.loadTimer),this.loadTimer=null);}},{key:"run",value:(t=mb(vb().mark(function e(t){var i,r,n,o,a,s,u,l,c,h,d;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=this.context,r=i.spaceService,n=i.hooksService,o=i.viewerService,!(a=r.getStatus(t))){e.next=34;break;}if(a.isMinLoading=!0,s=WL(),a.minTask=s,a.minData){e.next=16;break;}return e.next=7,r.getOriginalData(t);case 7:if(u=e.sent,a.minTask===s){e.next=12;break;}return e.next=11,this.run(t);case 11:return e.abrupt("return",void e.sent);case 12:if(o.isPageNeedLoad(t).min){e.next=14;break;}return e.abrupt("return",(this.loaders+=1,void(a.isMinLoading=!1)));case 14:l=vN(u.minData||u.oriData).data,a.minData=l;case 16:if(a.minImg&&(!a.minImg||a.minImg.src===a.minData)){e.next=33;break;}if(!this.isDestroyed){e.next=19;break;}return e.abrupt("return");case 19:return e.next=21,this.loadImage(a.minData);case 21:if(c=e.sent){e.next=24;break;}return e.abrupt("return",(this.loaders+=1,void(a.isMinLoading=!1)));case 24:if(a.minTask===s){e.next=28;break;}return e.next=27,this.run(t);case 27:return e.abrupt("return",void e.sent);case 28:if(o.isPageNeedLoad(t).min){e.next=30;break;}return e.abrupt("return",(this.loaders+=1,void(a.isMinLoading=!1)));case 30:a.minImg=c,(h=r.space.getMetadata(t))&&(d=h.height/c.naturalHeight,a.imageScale=d);case 33:a.isMinLoading=!1,n.hooks.afterLoadImage.emit(t,"min");case 34:this.loaders+=1;case 35:case"end":return e.stop();}},e,this);})),function(e){return t.apply(this,arguments);})},{key:"loadImage",value:(e=mb(vb().mark(function e(t){return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new uB(function(e,i){var r=new Image();r.crossOrigin="Anonymous",r.onload=function(){r.onload=null,r.onerror=null,e(r);},r.onerror=function(t){r.onload=null,r.onerror=null,e(null);},r.src=t;}));case 1:case"end":return e.stop();}},e);})),function(t){return e.apply(this,arguments);})}]);var e,t;}(),nF=function(){return Yk(function e(t){Xk(this,e),Wk(this,"context",void 0),this.context=t;},[{key:"getImageData",value:(e=mb(vb().mark(function e(t,i){var r=this;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new uB(function(e,n){var o=r.context.spaceService.getStatus(t);o||n(new Error("The page is not exist."));var _a2=function a(n,s){if("min"!==s&&n===t&&o.isSaving){o.isSaving=!1,r.context.hooksService.hooks.afterLoadImage.off(_a2);var u=o.img.naturalWidth,l=o.img.naturalHeight,c=[],h=[];if(r.context.editService){var d={operations:o.operations,width:o.img.naturalWidth,height:o.img.naturalHeight},f=r.context.editService.handle(d);u=f.width,l=f.height,c=f.matrixes,h=f.blanks;}var v=new LW({style:{x:0,y:0,img:o.img,width:o.img.naturalWidth,height:o.img.naturalHeight}});v.externalMatrixes=c;var g=new UW({style:{x:0,y:0,width:u,height:l,background:"#fff"}}),m=new UW();$k(h).call(h,function(e){var t=new WW({id:e.uid,style:{background:e.background,points:e.points,borderWidth:0}});m.appendChild(t);}),v.appendChild(m),g.appendChild(v),r.context.commonCanvas.render(g),r.context.commonCanvas.clear();var y=r.context.commonCanvas.getCanvas(),p=(null==i?void 0:i.type)||"imageData",w=(null==i?void 0:i.mime)||"image/png",b=(null==i?void 0:i.mime)||1,k=Math.max(u,l)||1;if(null!=i&&i.min&&k>720){var S=720/k,x=S*u,C=S*l,V=document.createElement("canvas");V.width=x,V.height=C;var T=V.getContext("2d",{willReadFrequently:!0});if(T.drawImage(y,0,0,Math.floor(u),Math.floor(l),0,0,x,C),"imageData"===p){var I=T.getImageData(0,0,x,C);e(I);}else"blob"===p&&V.toBlob(function(t){e(t);},w,b);}else if("imageData"===p){var E=y.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,u,l);e(E);}else"blob"===p&&y.toBlob(function(t){e(t);},w,b);}};r.context.hooksService.hooks.afterLoadImage.on(_a2),o.isSaving=!0,r.context.imageService.load(t);}));case 1:case"end":return e.stop();}},e);})),function(t,i){return e.apply(this,arguments);})}]);var e;}(),oF=function(){return Yk(function e(t,i){Xk(this,e),Wk(this,"context",void 0),Wk(this,"iSpace",void 0),this.context=t,this.iSpace=i||new mO();},[{key:"space",get:function get(){return this.iSpace;}},{key:"setSpace",value:function value(e){this.iSpace=e;}},{key:"getStatus",value:function value(e){return this.space.statusStore.get(e);}},{key:"getOriginalData",value:function value(e){return this.space.store.get(e);}},{key:"updateOriginalData",value:function value(e,t){return this.space.store.update(e,t);}},{key:"removeOriginalData",value:function value(e){return this.space.store.remove(e);}},{key:"getExternalImageLoader",value:function value(){return this.space.imageLoader;}},{key:"destroy",value:function value(){this.iSpace.destroy(),this.iSpace=null;}}]);}();function aF(e){var t;return lS(t="".concat(VL()," DVS: ")).call(t,e);}var sF=function(){return Yk(function e(t){Xk(this,e),Wk(this,"context",void 0),Wk(this,"logs",[]),Wk(this,"enableLog",!0),this.context=t,this.logs.push(aF("Initialize Log object."));},[{key:"updateLogMessage",value:function value(e){this.enableLog&&(null==this||this.logs.push(aF(e)));}},{key:"log",value:function value(e){this.enableLog&&(null==this||this.logs.push(aF(e)));}},{key:"clear",value:function value(){this.logs=[];}},{key:"destroy",value:function value(){this.logs=null;}}]);}(),uF=function(){return Yk(function e(t){Xk(this,e),Wk(this,"context",void 0),Wk(this,"docManager",void 0),Wk(this,"viewerManager",void 0),Wk(this,"isDestroyed",!1),Wk(this,"scrollbarWidth",0),this.context=t,this.docManager=new EH(),this.viewerManager=new ZH(),this.getScrollbarWidth();},[{key:"isPageNeedLoad",value:function value(e){for(var t={ori:!1,min:!1},i=this.viewerManager.getAllViewers(),r=0,n=i.length;r0&&void 0!==arguments[0]?arguments[0]:{},i=null,r=null,n=t.syncViewerUid;if(n){if(!(r=this.getViewer(n)))return this.context.errorService.err(mL),null;i=r.groupUid;}else i=WL();var o=bN.create(),a=this.context;o.save();var s,u=Fk(Fk({},t),{},{groupUid:i,emitter:o,dvsContext:a}),l=new a.dvs.subClasses.Viewer(u),c=l.uid;(o.restore(),this.context.hooksService.hooks.createViewer.emit({viewer:l}),this.viewerManager.addViewer(l,i),r)&&($k(s=r.getAllTabs()).call(s,function(t){var i;$k(i=t.children).call(i,function(t){var i=e.context.spaceService.getStatus(t.uid);i&&i.addOwner(c);}),e.docManager.getDoc(t.uid).addOwner(c);}),l.context.syncFromViewer(r));return this.context.trackerService.log("Invoking ViewerController#createViewer."),l;}},{key:"removeViewer",value:function value(e){var t,i=this;if(!e)return!1;var r=e;return TL(e)&&(r=this.viewerManager.getViewer(e)),!!r&&(this.viewerManager.removeViewer(r),$k(t=this.docManager.docs).call(t,function(e){var t;e.removeOwner(r.uid)&&$k(t=e.children).call(t,function(e){var t=i.context.spaceService.getStatus(e);t&&t.removeViewer(r.uid);});}),this.context.trackerService.log("Invoking ViewerController#removeViewer."),!0);}},{key:"getViewer",value:function value(e){return this.viewerManager.getViewer(e);}},{key:"openDoc",value:function value(e,t,i){var r,n=this,o=RI(r=e.children).call(r),a=this.docManager.getDoc(e.uid);a||(a=this.docManager.addDoc({uid:e.uid,name:e.name,type:t,children:[]},i)),a.children=o;var s=[];if(i){var u=this.viewerManager.getGroup(i);if(!u)return void this.context.errorService.err(mL);s=$E(u).call(u,function(e){return n.viewerManager.getViewer(e);});}else s=this.viewerManager.getAllViewers();$k(s).call(s,function(e){e&&(a.addOwner(e.uid),e.context.hooksService.hooks.openDoc.emit(a));});}},{key:"removeDoc",value:function value(e){this.docManager.getDoc(e)&&this.docManager.removeDoc(e);}},{key:"renameDoc",value:function value(e,t){var i=this.docManager.getDoc(t);i&&(i.name=e);}},{key:"removePagesFromDoc",value:function value(e,t){var i=this.docManager.getDoc(e);i&&$k(t).call(t,function(e){i.remove(e);});}},{key:"appendImagesToDoc",value:function value(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=this.docManager.getDoc(e);if(r){var n=i>-1;$k(t).call(t,function(e,t){var o;OI(o=r.children).call(o,e)<0&&(n?r.insert(e,i+t):r.append(e));});}}},{key:"getDoc",value:function value(e){return this.docManager.getDoc(e);}},{key:"getScrollbarWidth",value:function value(){var e,t=document.createElement("div"),i=document.createElement("div");t.appendChild(i),t.style.width="60px",t.style.height="60px",t.style.position="absolute",t.style.overflow="auto",i.style.width="100px",i.style.height="100px",document.body.appendChild(t);var r=t.offsetWidth-t.clientWidth;document.body.removeChild(t),this.scrollbarWidth=r,$k(e=this.viewerManager.getAllViewers()).call(e,function(e){e.context.setScrollbarWidth(r);});}}]);}(),lF=function(){return Yk(function e(t){Xk(this,e),Wk(this,"context",void 0),Wk(this,"hermiteWorkerUrl",void 0),Wk(this,"workers",[]),Wk(this,"concurrency",navigator.hardwareConcurrency||4),Wk(this,"cores",0),this.context=t,this.createWorkerUlr();},[{key:"createWorkerUlr",value:function value(){this.hermiteWorkerUrl=zI.createObjectURL(new Blob(["(",_H.toString(),")()"],{type:"application/javascript"}));}},{key:"run",value:function value(e,t){var i=this;return new uB(function(r,n){var o=i.getWorker();o||n(new Error("There is no idle worker.")),o.running=!0,o.worker.onmessage=function(e){o.running=!1,r(e.data);},o.worker.onerror=function(e){o.running=!1,n(e);},t?o.worker.postMessage(e,[t]):o.worker.postMessage(e);});}},{key:"getWorker",value:function value(){for(var e=this.workers.length,t=0;t=o&&i>=a&&t<=o+s&&i<=a+u;var l=e.getScale();r.pointerX=(t-o)/l.x,r.pointerY=(i-a)/l.y;}return r;}function fF(e,t){return void 0===t&&(t=[e.getCurrentIndex()]),BL(t)&&(t=[t]),t;}function vF(e,t){var i;if(!bL(t))return e.err(fL),!1;if(0===t.length)return e.err(mL),!1;var r=e.getCurrentTab();if(!r)return!1;var n=pU(i=RI(t).call(t)).call(i,function(e,t){return e-t;});return n[0]<0||n[n.length-1]>r.total?(e.err(vL),!1):r;}var gF={tag:"div",id:"dvs-viewer",className:"dvs-viewer",children:[{tag:"div",id:"dvs-viewer-middle",className:"dvs-viewer-middle",children:[{tag:"div",id:"dvs-viewer-main",className:"dvs-viewer-main",children:[{tag:"div",id:"dvs-main-container",className:"dvs-main-container",children:[{tag:"div",id:"dvs-scroller-and-canvas",className:"dvs-scroller-and-canvas",children:[{tag:"div",id:"dvs-scroll-container",className:"dvs-scroll-container",children:[{tag:"div",id:"dvs-scroll-content",className:"dvs-scroll-content"}]},{tag:"div",id:"dvs-canvas-container",className:"dvs-canvas-container",children:[]}]},{tag:"div",id:"dvs-video-container",className:"dvs-video-container",children:[{tag:"img",id:"dvs-video-image",class:"dvs-video-image"}]}]}]}]}]},mF={tag:"div",id:"dvs-viewer",className:"dvs-viewer",children:[{tag:"div",id:"dvs-scroll-container",className:"dvs-scroll-container",children:[{tag:"div",id:"dvs-scroll-content",className:"dvs-scroll-content"}]},{tag:"div",id:"dvs-canvas-container",className:"dvs-canvas-container"}]},yF={viewerStyle:{background:"#434246"},canvasStyle:{cursor:"default"},pageStyle:{border:"4px solid #707070",background:"#e2e2e2"},selectedPageStyle:{background:"#6f76ff",border:"4px solid #e98b1f"},hoveredPageStyle:{background:"#a5a9fb",border:"4px solid #e98b1f"},placeholderStyle:{background:"#b5b5b5",border:"0px solid #f00"},pageNumberStyle:{visibility:"visible",width:24,height:24,background:"#fff",borderWidth:1,borderRadius:0,borderColor:"#000",opacity:.5,color:"#000",fontSize:12,fontFamily:"sans-serif",textAlign:"center",textBaseline:"middle",left:"",top:"",right:0,bottom:0},checkboxStyle:{visibility:"visible",width:24,height:24,background:"#fff",borderWidth:2,borderRadius:0,borderColor:"#000",opacity:.5,left:0,top:0},removeBtnStyle:{visibility:"visible",width:24,height:24,background:"#fff",borderWidth:1,borderRadius:"50%",borderColor:"#515151",opacity:1,left:"",top:-8,right:-8,bottom:"",checkMarkColor:"#ea2e2e"},enableDragPage:!0,enableKeyboardControl:!0,multiselectMode:!1,enableOptimizeImage:!1,zoomOrigin:{x:"center",y:"center"},zoom:1,minZoom:.02,maxZoom:8,enableZoom:!0,enableScrollX:!0,enableScrollY:!0,keepZoom:!0,zoomInDelta:1.2,zoomOutDelta:1.2,wheelZoomDelta:1.2,scrollDirection:"vertical",displayMode:"single",toolType:"default",fitType:"window",enableSlide:!0,show:!0,rows:1,columns:1,pure:!1,margin:10,gap:10,autoScroll:!0,autoChangeIndex:!0,autoSelectLatest:!0,enableSelectWithShift:!0,enableSelectWithCtrl:!0,enableZoomWithCtrl:!0,tabMode:"single",enableSyncSelect:!0,enableSingleModeBorder:!1,blankFillColor:"#fff",dragThreshold:3,slideThreshold:20,maxOptimizationSize:7e3,useMinImage:!0,enableDWT1x1:!1,enableEmitPageRendered:!0,autoSelectTopPage:!1,showVideoContainer:!1},pF=function(){return Yk(function e(){Xk(this,e);},[{key:"init",value:function value(e){this.listenDVSHooks(e),this.listenViewerHooks(e);}},{key:"listenDVSHooks",value:function value(e){var t=e.dvsContext.hooksService.hooks,i=function i(t,_i3){"min"===_i3?e.renderMinPage(t):e.renderPage(t);},r=function r(t){e.tabService.updateTab(t);},n=function n(t){e.tabService.movePage(t);},o=function o(t){e.tabService.switchPage(t);},a=function a(t){e.tabService.reorderPages(t);},s=function s(t){e.tabService.changePage(t);},u=function u(t){e.tabService.selectPage(t);},l=function l(t){e.tabService.appendPagesToDoc(t.docUid,t.sourceUids,t.index,t.isSameDoc);},c=function c(t){e.tabService.removePagesFromDoc(t.docUid,t.sourceUids);},h=function h(t){e.tabService.removeDoc(t);},d=function d(t,i){e.tabService.renameDoc(t,i);},f=function f(){e.tabCleared();},v=function v(t){e.isFocus=t===e.viewerUid;};t.afterLoadImage.on(i),t.afterUpdate.on(r),t.move.on(n),t.switch.on(o),t.reorder.on(a),t.changePage.on(s),t.selectPage.on(u),t.appendPagesToDoc.on(l),t.removePagesFromDoc.on(c),t.removeDoc.on(h),t.renameDoc.on(d),t.afterSetSpace.on(f),t.focusChanged.on(v),e.hooksService.hooks.destroy.on(function(){t.afterLoadImage.off(i),t.afterUpdate.off(r),t.move.off(n),t.switch.off(o),t.reorder.off(a),t.changePage.off(s),t.selectPage.off(u),t.appendPagesToDoc.off(l),t.removePagesFromDoc.off(c),t.removeDoc.off(h),t.renameDoc.off(d),t.afterSetSpace.off(f),t.focusChanged.off(v);});}},{key:"listenViewerHooks",value:function value(e){var t=e.hooksService.hooks,i=e.dvsContext.hooksService,r=function r(e){i.hooks.remove.emit(e);},n=function n(e){i.hooks.move.emit(e);},o=function o(e){i.hooks.switch.emit(e);},a=function a(e){i.hooks.reorder.emit(e);},s=function s(e){i.hooks.changePage.emit(e);},u=function u(e){i.hooks.selectPage.emit(e);},l=function l(e){i.hooks.focusChanged.emit(e);},c=function c(t){i.hooks.focusChanged.emit(t,e.viewerUid);},_h2=function h(){t.remove.off(r),t.move.off(n),t.switch.off(o),t.reorder.off(a),t.changePage.off(s),t.selectPage.off(u),t.focusChanged.off(l),t.removeTab.off(c),e.hooksService.hooks.destroy.off(_h2);};t.remove.on(r),t.move.on(n),t.switch.on(o),t.reorder.on(a),t.changePage.on(s),t.selectPage.on(u),t.focusChanged.on(l),t.removeTab.on(c),e.hooksService.hooks.destroy.on(_h2);}}]);}(),wF=Yk(function e(){Xk(this,e);});function bF(e,t){if(e.tabUid===t.uid)return!0;if("tag"===e.tabType)for(var i=t.total,r=0;r-1)return!0;}return!1;}var kF=function(){return Yk(function e(){Xk(this,e),Wk(this,"undoStack",[]),Wk(this,"redoStack",[]);},[{key:"execute",value:function value(e){e.execute(),this.undoStack.push(e),this.redoStack.length>0&&(this.redoStack.length=0);}},{key:"undo",value:function value(e){var t,i=EE(t=this.undoStack).call(t,function(t){return t.uid===e;});if(i>-1){var r,n=this.undoStack[i];gE(r=this.undoStack).call(r,i,1),n.undo(),this.redoStack.push(n);}}},{key:"redo",value:function value(e){var t,i=EE(t=this.redoStack).call(t,function(t){return t.uid===e;});if(i>-1){var r,n=this.redoStack[i];gE(r=this.redoStack).call(r,i,1),n.execute(),this.undoStack.push(n);}}},{key:"removeUidsFromCommand",value:function value(e){this.removeFromStack(this.undoStack,e),this.removeFromStack(this.redoStack,e);}},{key:"removeFromStack",value:function value(e,t){var i;$k(i=RI(e).call(e)).call(i,function(i){var r,n=i.action.uids;if(n&&($k(r=RI(n).call(n)).call(r,function(e){if(OI(t).call(t,e)>-1){var i=OI(n).call(n,e);gE(n).call(n,i,1);}}),!n.length)){var o=OI(e).call(e,i);gE(e).call(e,o,1);}});}},{key:"reset",value:function value(){this.undoStack=[],this.redoStack=[];}}]);}(),SF=function(){return Yk(function e(){Xk(this,e);},[{key:"init",value:function value(e){var t=e.dvsContext.hooksService.hooks,i=t.undo,r=t.redo,n=t.reset,o=t.afterUpdate,a=function a(t){var i,r=t.commandUid;t.trigger,$k(i=e.tabService.getAllTabs()).call(i,function(t){var i=t.commandController.undoStack.length,n=t.commandController.undoStack[i-1];(null==n?void 0:n.uid)===r&&(t.commandController.undo(r),e.tabService.isCurrentTab(t.uid)&&e.render());});},s=function s(t){var i,r=t.commandUid;t.trigger,$k(i=e.tabService.getAllTabs()).call(i,function(t){var i=t.commandController.redoStack.length,n=t.commandController.redoStack[i-1];(null==n?void 0:n.uid)===r&&(t.commandController.redo(r),e.tabService.isCurrentTab(t.uid)&&e.render());});},u=function u(t){var i,r=t.uids;$k(i=e.tabService.getAllTabs()).call(i,function(i){bF(t,i)&&(i.commandController.removeUidsFromCommand(r),e.tabService.isCurrentTab(i.uid)&&e.render());});};i.on(a),r.on(s),n.on(u),e.hooksService.hooks.destroy.on(function(){i.off(a),r.off(s),n.off(u);});var l=e.hooksService.hooks.removePagesFromDoc,c=function c(t,i){var r=e.tabService.getTab(t);r&&r.commandController.removeUidsFromCommand(i);},h=function h(t){var i;$k(i=e.tabService.getAllTabs()).call(i,function(e){e.commandController.removeUidsFromCommand([t.modifiedUid]);});};l.on(c),o.on(h),e.hooksService.hooks.destroy.on(function(){l.off(c),o.off(h);});}}]);}();function xF(e,t){var i,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=-1,o=-1,a=0,s=0,u={canvasOffsetX:-1,canvasOffsetY:-1,containerOffsetX:-1,containerOffsetY:-1},l=e.pageX,c=e.pageY,h=Gb(t.formatTouches(e,r),1)[0],d=t.getPointerOverPageInfo(h.pageX,h.pageY);if((i=d.index)>=0){u.canvasOffsetX=d.pageInfo.pagePositionX,u.canvasOffsetY=d.pageInfo.pagePositionY,a=d.pageInfo.pageWidth,s=d.pageInfo.pageHeight;var f=t.rendererService,v=t.uiService.container,g=f.canvasDom,m=v.getBoundingClientRect(),y=m.left,p=m.top,w=g.getBoundingClientRect(),b=w.left,k=w.top;u.containerOffsetX=b-y+d.pageInfo.pagePositionX,u.containerOffsetY=k-p+d.pageInfo.pagePositionY;}if(d.imageInfo.isOver){n=d.imageInfo.pointerX,o=d.imageInfo.pointerY;var S=t.getCurrentTab();if(S){var x=S.getChildByIndex(i);if(x){var C=t.getStatus(x.uid);if(C&&"multiple"===t.config.displayMode&&t.config.useMinImage){var V=C.imageScale;n*=V,o*=V;}}}}return{index:i,imageX:n,imageY:o,pageX:l,pageY:c,pageWidth:a,pageHeight:s,position:u};}var CF=function(){return Yk(function e(){Xk(this,e);},[{key:"init",value:function value(e){var t,i,r,n,o=e.rendererService.canvasDom,a=0,s=0,u=0,l=0,c=!1,h=!1,d=null,f=!1,v=null,g=null,m=function m(){g&&(clearTimeout(g),g=null),v?g=jP(function(){e.externalResized();},50):v=jP(function(){e.externalResized(),v=null;},42);},y=function y(t){e.isFocus&&e.emit("keyup",t);},p=function p(t){e.isFocus&&e.emit("keydown",t);},w=function w(t){e.hooksService.hooks.focusChanged.emit("");},b=function b(t){var i=xF(t,e);e.emit("click",i,t),e.hooksService.hooks.focusChanged.emit(e.viewerUid),t.stopPropagation();},k=null,S=function S(i){if(0===i.button){var n=xF(i,e);e.emit("mousedown",n,i),h=!0;var o=i.pointerType;"mouse"===o?e.draggingPrepared=!0:"touch"!==o&&"pen"!==o||"multiple"!==e.config.displayMode||(k=jP(function(){e.draggingPrepared=!0;},300));var c=Gb(e.formatTouches(i),1)[0],d=e.getPointerOverPageInfo(c.pageX,c.pageY).pageInfo.obj,f=e.tabService.getCurrentTab();if(f){var v=e.config;if(d&&"multiple"===v.displayMode&&!i.ctrlKey){var g=f.getChildIndex(d);if(i.shiftKey&&v.enableSelectWithShift||v.multiselectMode){if(i.shiftKey&&v.enableSelectWithShift&&(d!==f.currentPage||1!==f.selected.length)){var m=f.getIndexByUid(f.shiftReference);if(m>-1){var y,p=Math.min(g,m),w=Math.max(g,m)-p+1,b=[];e.isSelectedBorderWidthEqualHovered()||d.clearOptimization();for(var S=0;S-1;if(f.currentPage!==d&&T.length<2||!I){var E,P={index:g,docUid:f.uid,trigger:e.viewerUid,groupUid:e.groupUid,operation:"shift"};$k(E=f.selected).call(E,function(t){var i=f.getChildByUid(t);i&&(e.isSelectedBorderWidthEqualNormal()||i.clearOptimization());}),e.isSelectedBorderWidthEqualHovered()||d.clearOptimization(),e.hooksService.hooks.changePage.emit(P);}}}if(d){var B;u=c.pageX,l=c.pageY;var D=d.getPosition();a=c.pageX-D.x,s=c.pageY-D.y,t=d,r=RI(B=f.children).call(B);}}}},x=function x(r){var o=xF(r,e);e.emit("mousemove",o,r),h&&!1===e.draggingPrepared&&k&&(clearTimeout(k),k=null);var v=Gb(e.formatTouches(r),1)[0],g=e.tabService.getCurrentTab();if(g){var m=e.config,y=e.getPointerOverPageInfo(v.pageX,v.pageY).pageInfo.obj,p=g.getChildIndex(d);if(y?d?d!==y&&(c||(d.isSelected||e.isBorderWidthEqualHovered()||d.clearOptimization(),y.isSelected||e.isBorderWidthEqualHovered()||y.clearOptimization()),e.emit("mouseout",Fk(Fk({},o),{},{index:p}),r,"page"),e.emit("mouseover",Fk({},o),r,"page"),d=y):(c||y.isSelected||e.isBorderWidthEqualHovered()||y.clearOptimization(),f||e.emit("mouseout",Fk(Fk({},o),{},{index:-1}),r,"canvas"),e.emit("mouseover",Fk({},o),r,"page"),d=y,f=!1):d&&(c||d.isSelected||e.isBorderWidthEqualHovered()||d.clearOptimization(),e.emit("mouseout",Fk(Fk({},o),{},{index:p}),r,"page"),e.emit("mouseover",Fk(Fk({},o),{},{index:-1}),r,"canvas"),d=null),g&&"multiple"===m.displayMode)if(c){var w,b,S,x;if(y)if(!(OI(x=g.selected).call(x,y.uid)>-1)){var C,V,T,I,E,P=pU(C=$E(V=g.selected).call(V,function(e){return g.getIndexByUid(e);})).call(C,function(e,t){return e-t;}),B=P[0],D=g.getChildIndex(y),M=RI(T=g.children).call(T);$k(I=BU(E=RI(P).call(P)).call(E)).call(I,function(e){gE(M).call(M,e,1);});var z=OI(M).call(M,y);D>B&&(z+=1),$k(n).call(n,function(e,t){var i=g.getChildByUid(e.uid);gE(M).call(M,z+t,0,i);}),i=$E(M).call(M,function(e){return g.getChildIndex(e);}),g.reorder(i),e.layoutService.layout(g);}$k(w=g.selected).call(w,function(e){var t=g.getChildByUid(e);t.borderBox.setPosition({x:v.pageX-a,y:v.pageY-s}),t.isDragging=!0,t.borderBox.updateStyle({visibility:"hidden"});}),null!==(b=t)&&void 0!==b&&b.updateStyle({zIndex:1}),null!==(S=t)&&void 0!==S&&S.borderBox.updateStyle({visibility:"visible"}),e.render();}else{var A,U,R,L;if(y&&y===t&&OI(A=g.selected).call(A,y.uid)>-1&&"crop"!==m.toolType&&e.draggingPrepared)Math.pow(Math.pow(v.pageX-u,2)+Math.pow(v.pageY-l,2),.5)>=m.dragThreshold&&t&&m.enableDragPage&&(c=!0,n=pU(R=$E(L=g.selected).call(L,function(e){return{uid:e,index:g.getIndexByUid(e)};})).call(R,function(e,t){return e.index-t.index;}));var N=!1;r instanceof MouseEvent&&$k(U=g.children).call(U,function(e){y&&y.uid===e.uid?(e.isHovered||(N=!0),e.isHovered=!0):(e.isHovered&&(N=!0),e.isHovered=!1);}),N&&e.render();}}},C=function C(t){if(0===t.button){var i=xF(t,e,!0);e.emit("mouseup",i,t);}},V=function V(o){if(0===o.button&&"annotation"!==e.config.toolType&&h){o instanceof MouseEvent?e.draggingPrepared=!1:o instanceof TouchEvent&&(k&&(clearTimeout(k),k=null),e.draggingPrepared=!1);var a=Gb(e.formatTouches(o,!0),1)[0],s=e.tabService.getCurrentTab();if(s){var u=e.getPointerOverPageInfo(a.pageX,a.pageY).pageInfo.obj;if(c){var l;if(i){var d,f=$E(d=s.children).call(d,function(e){return OI(r).call(r,e);});s.childNodes=r;var v={indexes:f,trigger:e.viewerUid,docUid:s.uid,type:s.type,operation:"shift"};e.hooksService.hooks.reorder.emit(v),i=null;}null==s||$k(l=s.selected).call(l,function(e){var t=s.getChildByUid(e);t.borderBox.setLocalPosition({x:0,y:0}),t.isDragging=!1,t.borderBox.updateStyle({visibility:"visible"});});var g=[];$k(n).call(n,function(e){var t=s.getIndexByUid(e.uid);g.push([e.index,t]);}),e.emit("dragdone",g);}else if(u&&t===u&&"multiple"===e.config.displayMode&&!o.shiftKey)if(o.ctrlKey&&e.config.enableSelectWithCtrl||e.config.multiselectMode){var m,y=RI(m=s.selected).call(m),p=OI(y).call(y,u.uid),w=!1;if(p>-1?(o.ctrlKey&&y.length>1||e.config.multiselectMode)&&(gE(y).call(y,p,1),w=!0):(y.push(u.uid),w=!0),w){var b={selectedUids:y,indexes:[],docUid:s.uid,trigger:e.viewerUid,groupUid:e.groupUid,operation:"shift"};e.isSelectedBorderWidthEqualHovered()||u.clearOptimization(),e.hooksService.hooks.selectPage.emit(b);}}else if((!o.ctrlKey||!o.shiftKey)&&s.selected.length>1){var S,x={index:s.getChildIndex(u),docUid:s.uid,trigger:e.viewerUid,groupUid:e.groupUid,operation:"shift"};$k(S=s.selected).call(S,function(t){var i=s.getChildByUid(t);i&&(e.isSelectedBorderWidthEqualNormal()||i.clearOptimization());}),e.isSelectedBorderWidthEqualHovered()||u.clearOptimization(),e.hooksService.hooks.changePage.emit(x);}if(s&&"multiple"===e.config.displayMode){var C;if("visible"===e.config.removeBtnStyle.visibility){var V=e.getHitRemoveBtn(a.pageX,a.pageY);V>-1&&e.emit("removeBtnClick",V);}null!==(C=t)&&void 0!==C&&C.updateStyle({zIndex:0}),t=null,c=!1,e.render();}h=!1,t=null;}}},T=function T(t){f=!0;var i=xF(t,e);e.emit("mouseover",i,t);},I=function I(t){var i=e.tabService.getCurrentTab(),r=xF(t,e);if(i){var n;if(d){var o=i.getChildIndex(d);r.index=o;}d=null,e.emit("mouseout",r,t),i&&"multiple"===e.config.displayMode&&($k(n=i.children).call(n,function(e){e.isHovered=!1;}),e.rendererService.render());}},E=function E(t){var i=xF(t,e);e.emit("dblclick",i,t);},P=function P(t){var i=xF(t,e);e.emit("wheel",i,t);},B=function B(t){t.preventDefault();var i=xF(t,e);e.emit("contextmenu",i,t);},D=function D(e){},M=function M(e){e.preventDefault();},z=function z(t){t.preventDefault(),e.emit("drop",t);},A=function A(t){if(!e.isDestroyed){e.emit("scroll",t);var i=e.getCurrentTab();if(i){var r,n=t.target,o=n.scrollLeft,a=n.scrollTop;if(i.setPosition({x:-o,y:-a}),e.layoutService.layout(i),i.updateLayoutStatus({scrollLeft:o,scrollTop:a}),$k(r=i.children).call(r,function(t){!t.isPreload||t.isLoaded||t.imageContainer.imageData||("multiple"===e.config.displayMode&&e.config.useMinImage?e.dvsContext.minImageService.load(t.uid):e.dvsContext.imageService.load(t.uid));}),e.scrollerService.updateScroller({scrollLeft:o,scrollTop:a}),i&&i.isTopPageChanged&&!i.isLoadPage){var s=i.getIndexByUid(i.topPageUid);if(e.config.autoSelectTopPage){i.current=s,i.select([i.currentUid]);var u={selectedUids:[i.currentUid],indexes:[s],docUid:i.uid,trigger:e.viewerUid,groupUid:e.groupUid,operation:"shift",triggerByScroll:!0};e.getLocalHooks().selectPage.emit(u),e.layoutService.layout(i);}}i.isLoadPage&&(i.isLoadPage=!1),e.render();}}};window.addEventListener("resize",m),document.addEventListener("keydown",p),document.addEventListener("keyup",y),document.addEventListener("click",w),o.addEventListener("click",b),window.PointerEvent?(o.addEventListener("pointerdown",S),o.addEventListener("pointermove",x),o.addEventListener("pointerup",C),document.addEventListener("pointerup",V)):window.MSPointerEvent&&(o.addEventListener("MSPointerDown",S),o.addEventListener("MSPointerMove",x),o.addEventListener("MSPointerUp",C),document.addEventListener("MSPointerUp",V)),o.addEventListener("touchmove",function(e){e.cancelable&&e.preventDefault();},{passive:!1}),o.addEventListener("blur",function(){e.hooksService.hooks.focusChanged.emit("");}),o.addEventListener("focus",function(t){e.hooksService.hooks.focusChanged.emit(e.viewerUid);}),o.addEventListener("mouseover",T),o.addEventListener("mouseout",I),o.addEventListener("dblclick",E),o.addEventListener("wheel",P,{passive:!0}),o.addEventListener("contextmenu",B),o.addEventListener("dragstart",D),o.addEventListener("dragover",M),e.uiService.defaultDom.addEventListener("drop",z),e.uiService.hooks.scroll.on(A);var _U2=function U(){v&&clearTimeout(v),g&&clearTimeout(g),k&&clearTimeout(k),window.removeEventListener("resize",m),document.removeEventListener("keydown",p),document.removeEventListener("keyup",y),document.removeEventListener("click",w),o.removeEventListener("click",b),window.PointerEvent?(o.removeEventListener("pointerdown",S),o.removeEventListener("pointermove",x),o.removeEventListener("pointerup",C),document.removeEventListener("pointerup",V)):window.MSPointerEvent&&(o.removeEventListener("MSPointerDown",S),o.removeEventListener("MSPointerMove",x),o.removeEventListener("MSPointerUp",C),document.removeEventListener("MSPointerUp",V)),o.removeEventListener("pointerdown",S),o.removeEventListener("pointermove",x),o.removeEventListener("pointerup",C),document.removeEventListener("pointerup",V),o.removeEventListener("mouseover",T),o.removeEventListener("mouseout",I),o.removeEventListener("dblclick",E),o.removeEventListener("wheel",P),o.removeEventListener("contextmenu",B),o.removeEventListener("dragstart",D),o.removeEventListener("dragover",M),e.uiService.defaultDom.removeEventListener("drop",z),e.hooksService.hooks.destroy.off(_U2),e.uiService.hooks.scroll.off(A);};e.hooksService.hooks.destroy.on(_U2);}}]);}(),VF={visibility:"hidden",left:0,top:0,right:"",bottom:"",width:"24px",height:"24px",opacity:1,borderWidth:1,borderRadius:0,background:"#ffffff",borderColor:"#000000",checkMarkColor:"#000000",checkMarkLineWidth:"2px",translateX:0,translateY:0},TF=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_SL(VF);return Xk(this,t),Wk(yb(e=cL(this,t,[{style:{visibility:"visible"===i.visibility?"visible":"hidden"}}])),"shapeType","checkbox"),Wk(yb(e),"checkBoxStyle",void 0),Wk(yb(e),"parsedCheckBoxStyle",void 0),Wk(yb(e),"isChecked",!1),e.checkBoxStyle=Fk(Fk({},VF),i),e;}return _b(t,e),Yk(t,[{key:"checked",get:function get(){return this.isChecked;},set:function set(e){this.isChecked=e;}},{key:"updateStyle",value:function value(e){this.checkBoxStyle=Fk(Fk({},this.checkBoxStyle),e),this.style.visibility=this.checkBoxStyle.visibility;}}]);}(mW),IF={visibility:"hidden",left:"",top:"",right:0,bottom:0,width:"24px",height:"24px",opacity:1,borderWidth:1,borderRadius:"50%",background:"#ffffff",borderColor:"#a79898",color:"#a79898",fontFamily:"sans-serif",fontSize:12,translateX:0,translateY:0},EF=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_SL(IF),r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";return Xk(this,t),Wk(yb(e=cL(this,t,[{style:{visibility:"visible"===i.visibility?"visible":"hidden"}}])),"shapeType","pageNumber"),Wk(yb(e),"pageNumberStyle",void 0),Wk(yb(e),"text",void 0),Wk(yb(e),"parsedPageNumberStyle",void 0),e.text=r,e.pageNumberStyle=Fk(Fk({},IF),i),e;}return _b(t,e),Yk(t,[{key:"updateText",value:function value(e){this.text=e;}},{key:"updateStyle",value:function value(e){this.pageNumberStyle=Fk(Fk({},this.pageNumberStyle),e),this.style.visibility="visible"===this.pageNumberStyle.visibility?"visible":"hidden";}}]);}(mW),PF={visibility:"hidden",left:"",top:0,right:0,bottom:"",width:"24px",height:"24px",borderWidth:1,borderRadius:0,background:"#ffffff",borderColor:"#000000",checkMarkColor:"#ff0000",checkMarkLineWidth:"2px",translateX:0,translateY:0},BF=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_SL(PF);return Xk(this,t),Wk(e=cL(this,t,[i]),"shapeType","removeBtn"),e;}return _b(t,e),Yk(t);}(TF),DF=function(e){function t(e){var i;Xk(this,t),Wk(yb(i=cL(this,t,[e])),"uid",void 0),Wk(yb(i),"isSelected",!1),Wk(yb(i),"isPreload",!1),Wk(yb(i),"isMouseover",!1),Wk(yb(i),"isLoaded",!1),Wk(yb(i),"blanks",void 0),Wk(yb(i),"overlays",void 0),Wk(yb(i),"image",void 0),Wk(yb(i),"borderBox",void 0),Wk(yb(i),"imageContainer",void 0),Wk(yb(i),"checkbox",void 0),Wk(yb(i),"pageNumber",void 0),Wk(yb(i),"removeBtn",void 0),Wk(yb(i),"isHovered",!1),Wk(yb(i),"isDragging",!1),Wk(yb(i),"viewportPosition",void 0),Wk(yb(i),"isPageRendered",!1),Wk(yb(i),"isEdited",!1),Wk(yb(i),"isUpdated",!1),Wk(yb(i),"isOptimized",!1),Wk(yb(i),"optimizationUid",null),Wk(yb(i),"optimizedUid",null),Wk(yb(i),"realTimeWidth",void 0),Wk(yb(i),"realTimeHeight",void 0),Wk(yb(i),"zoom",1),Wk(yb(i),"imageScale",1),i.uid=e.uid,i.realTimeWidth=e.realTimeWidth,i.realTimeHeight=e.realTimeHeight,i.updateStyle(e.style);var r=new LW({id:i.uid,style:{x:0,y:0}}),n=new UW({style:{x:0,y:0}});n.clippable=!0;var o=new UW({style:Fk(Fk({},e.style),e.formattedPageStyle)}),a=new TF(Fk({},e.checkboxStyle)),s=new EF(Fk({},e.pageNumberStyle),"0"),u=new BF(Fk({},e.removeBtnStyle)),l=new UW(),c=new UW();return r.appendChild(l),i.appendChild(o),n.appendChild(r),n.appendChild(c),o.appendChild(n),o.appendChild(s),o.appendChild(a),o.appendChild(u),i.pageNumber=s,i.checkbox=a,i.removeBtn=u,i.image=r,i.borderBox=o,i.imageContainer=n,i.blanks=l,i.overlays=c,i.initEvent(),i;}return _b(t,e),Yk(t,[{key:"initEvent",value:function value(){var e=this;this.addEventListener("mouseover",function(){e.isMouseover=!0;}),this.addEventListener("mouseout",function(){e.isMouseover=!1;}),this.addEventListener("mouseup",function(){e.isMouseover=!1;});}},{key:"getImage",value:function value(){return this.image;}},{key:"updateImage",value:function value(e){this.image.style.img=e;}},{key:"clearOptimization",value:function value(){var e;this.isOptimized=!1,null!=this&&null!==(e=this.imageContainer)&&void 0!==e&&e.imageData&&(this.imageContainer.imageData=null),this.optimizationUid=WL();}},{key:"destroy",value:function value(){this.clearOptimization(),this.image.style.img=null,this.image=null,this.imageContainer=null,this.overlays=null,this.blanks=null;}}]);}(UW),MF=function(){return Yk(function e(t,i,r,n){Xk(this,e),Wk(this,"id",void 0),Wk(this,"duration",void 0),Wk(this,"step",void 0),Wk(this,"verify",void 0),Wk(this,"complete",void 0),Wk(this,"active",!1),Wk(this,"effect",void 0),Wk(this,"fps",60),this.id=WL(),this.step=t,this.complete=i,this.duration=r,this.effect=n;},[{key:"play",value:function value(){var e=this,t=LU(),i=t,r=0,_n3=function n(o){var a=LU();if(e.active&&!e.verify(e.id)){var s=!0!==o;if(s)for(var u=Math.round((a-i)/(1e3/e.fps))-1,l=0;l1&&(r=1);var c=e.effect(r);!1!==e.step(c,s)&&1!==r||!s?s&&(i=a,requestAnimationFrame(_n3)):(e.active=!1,e.complete(e.id,1===r||null===e.duration));}else e.complete(e.id,!1);};return this.active=!0,requestAnimationFrame(_n3),this.id;}},{key:"cancel",value:function value(){var e=!0===this.active;return e&&(this.active=!1),e;}},{key:"pause",value:function value(){}}]);}(),zF=function(e){function t(){var e;return Xk(this,t),Wk(yb(e=cL(this,t)),"viewportWidth",void 0),Wk(yb(e),"viewportHeight",void 0),Wk(yb(e),"contentWidth",void 0),Wk(yb(e),"contentHeight",void 0),Wk(yb(e),"scrollingX",!0),Wk(yb(e),"scrollingY",!0),Wk(yb(e),"scrollLeft",0),Wk(yb(e),"scrollTop",0),Wk(yb(e),"maxScrollLeft",0),Wk(yb(e),"maxScrollTop",0),Wk(yb(e),"zoom",1),Wk(yb(e),"minZoom",.01),Wk(yb(e),"maxZoom",8),Wk(yb(e),"zooming",!0),Wk(yb(e),"locking",!1),Wk(yb(e),"animating",!1),Wk(yb(e),"animationDuration",300),Wk(yb(e),"moveThreshold",5),Wk(yb(e),"scrollThreshold",3),Wk(yb(e),"moveSpeed",1),Wk(yb(e),"decelerationVelocityThreshold",1),Wk(yb(e),"startX",0),Wk(yb(e),"startY",0),Wk(yb(e),"startZoom",1),Wk(yb(e),"lastX",0),Wk(yb(e),"lastY",0),Wk(yb(e),"lastScale",0),Wk(yb(e),"lastTimeStamp",0),Wk(yb(e),"futureLeft",0),Wk(yb(e),"futureTop",0),Wk(yb(e),"futureZoom",0),Wk(yb(e),"isStart",!1),Wk(yb(e),"isMoving",!1),Wk(yb(e),"originLeft",0),Wk(yb(e),"originTop",0),Wk(yb(e),"decelerationVelocityX",0),Wk(yb(e),"decelerationVelocityY",0),Wk(yb(e),"enableScrollX",!0),Wk(yb(e),"enableScrollY",!0),Wk(yb(e),"interruptedAnimation",!1),Wk(yb(e),"isDecelerating",!1),Wk(yb(e),"decelerationId",void 0),Wk(yb(e),"isAnimating",!1),Wk(yb(e),"animationId",void 0),Wk(yb(e),"isSingleTouch",!1),Wk(yb(e),"isProcessing",!1),Wk(yb(e),"isDecelerationComplete",!1),Wk(yb(e),"isDragging",!1),Wk(yb(e),"positions",[]),Wk(yb(e),"hooks",{zoomComplete:SN.create(),scrollComplete:SN.create(),publish:SN.create(),beforeZoom:SN.create(),zoomTo:SN.create()}),Wk(yb(e),"animations",{}),e.viewportWidth=800,e.viewportHeight=800,e;}return _b(t,e),Yk(t,[{key:"updateScroller",value:function value(e){LA(this,e),this.calcMaxScroll();}},{key:"setOrigin",value:function value(e,t){this.originLeft=e,this.originTop=t;}},{key:"initScroller",value:function value(e){LA(this,e);}},{key:"zoomTo",value:function value(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;if(this.zooming){this.zoom;var n=this.minZoom,o=this.maxZoom;this.viewportWidth,this.viewportHeight;var a=this.scrollLeft,s=this.scrollTop;this.maxScrollLeft,this.maxScrollTop,CL(i)&&(i=this.originLeft),CL(r)&&(r=this.originTop),this.hooks.beforeZoom.emit(i,r),e=HL(e,n,o),this.publish(a,s,e,t);}}},{key:"zoomBy",value:function value(e,t,i,r){this.zoomTo(this.zoom*e,t,i,r);}},{key:"scrollTo",value:function value(e,t,i,r){this.enableScrollX&&(this.scrollLeft=e),this.enableScrollY&&(this.scrollTop=t);var n=this.scrollLeft,o=this.scrollTop;this.emit("_scrollChanged",{scrollLeft:n,scrollTop:o});}},{key:"scrollBy",value:function value(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.scrollTo(e+this.scrollLeft,t+this.scrollTop,i);}},{key:"canScroll",value:function value(){return this.contentWidth>this.viewportWidth||this.contentHeight>this.viewportHeight;}},{key:"onStartHandler",value:function value(e,t){if(this.canScroll()&&!this.isMoving){var i,r;this.isStart=!0,t instanceof Date&&(t=t.valueOf()),this.interruptedAnimation=!0,this.isDecelerating&&(this.cancelAnimate(this.decelerationId),this.isDecelerating=!0),this.isAnimating&&(this.cancelAnimate(this.animationId),this.isAnimating=!1);var n=1===e.length;n?(i=e[0].pageX,r=e[0].pageY):(i=Math.abs(e[0].pageX+e[1].pageX)/2,r=Math.abs(e[0].pageY+e[1].pageY)/2),this.startX=i,this.startY=r,this.startZoom=this.zoom,this.lastX=i,this.lastY=r,this.lastScale=1,this.lastTimeStamp=t,this.enableScrollX=this.scrollingX&&n,this.enableScrollY=this.scrollingY&&n,this.isProcessing=!0,this.isDecelerationComplete=!1,this.isDragging=!n,this.isSingleTouch=n,this.positions=[];}}},{key:"onMoveHandler",value:function value(e,t,i){if(this.canScroll()&&this.isStart){var r,n;t instanceof Date&&(t=t.valueOf());var o=1===e.length,a=this.positions;if(o?(r=e[0].pageX,n=e[0].pageY):(r=Math.abs(e[0].pageX+e[1].pageX)/2,n=Math.abs(e[0].pageY+e[1].pageY)/2),this.isDragging){var s=r-this.lastX,u=n-this.lastY,l=this.scrollLeft,c=this.scrollTop,h=this.zoom;if(!CL(i)&&this.zooming){var d=h;h=h/this.lastScale*i,d!==(h=HL(h,this.minZoom,this.maxZoom))&&(l=(r+l)/d*h-r,c=(n+c)/d*h-n,this.calcMaxScroll(h));}this.enableScrollX&&(l-=s*this.moveSpeed,l=HL(l,0,this.maxScrollLeft)),this.enableScrollY&&(c-=u*this.moveSpeed,c=HL(c,0,this.maxScrollTop)),a.length>60&&gE(a).call(a,0,30),a.push({scrollLeft:l,scrollTop:c,timeStamp:t}),this.publish(l,c,h);}else{var f=this.locking?this.scrollThreshold:0,v=this.moveThreshold,g=Math.abs(r-this.startX),m=Math.abs(n-this.startY);this.enableScrollX=this.scrollingX&&g>=f,this.enableScrollY=this.scrollingY&&m>=f,a.push({scrollLeft:this.scrollLeft,scrollTop:this.scrollTop,timeStamp:t}),this.isDragging=(this.enableScrollX||this.enableScrollY)&&(g>=v||m>=v),this.isDragging&&(this.interruptedAnimation=!1);}this.lastX=r,this.lastY=n,this.lastTimeStamp=t,this.lastScale=i;}}},{key:"onEndHandler",value:function value(e){if(this.canScroll()&&this.isStart&&this.isProcessing){if(e instanceof Date&&(e=e.valueOf()),this.isProcessing=!1,this.isDragging)if(this.isDragging=!1,this.isSingleTouch&&this.animating&&e-this.lastTimeStamp<100){for(var t=this.positions,i=this.decelerationVelocityThreshold,r=t.length-1,n=r,o=r;o>0&&t[o].timeStamp>this.lastTimeStamp-100;o--)n=o;if(n!==r){var a=t[r].timeStamp-t[n].timeStamp,s=this.scrollLeft-t[n].scrollLeft,u=this.scrollTop-this.positions[n].scrollTop;this.decelerationVelocityX=s/a*(1e3/60),this.decelerationVelocityX=u/a*(1e3/60),Math.abs(this.decelerationVelocityX)>i||Math.abs(this.decelerationVelocityY)>i?this.startDeceleration(e):this.hooks.scrollComplete.emit();}else this.hooks.scrollComplete.emit();}else e-this.lastTimeStamp>100&&this.hooks.scrollComplete.emit();this.isDecelerating||((this.interruptedAnimation||this.isDragging)&&this.hooks.scrollComplete.emit(),this.scrollTo(this.scrollLeft,this.scrollTop,!0,this.zoom)),this.isStart=!1,this.isMoving=!1,this.positions.length=0;}}},{key:"onZoomHandler",value:function value(e,t,i){this.zoomTo(this.zoom*e,!1,t,i);}},{key:"onWheelHandler",value:function value(e){if(!e.ctrlKey){var t=this.scrollLeft,i=this.scrollTop;e.shiftKey?t=this.scrollLeft+e.deltaY:i=this.scrollTop+e.deltaY,this.scrollTo(t,i);}}},{key:"publish",value:function value(e,t,i){var r=this,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=this.isAnimating;if(o&&(this.cancelAnimate(this.animationId),this.isAnimating=!1),n&&this.animating){this.futureLeft=e,this.futureTop=t,this.futureZoom=i;var a=this.scrollLeft,s=this.scrollTop,u=this.zoom;this.isAnimating=!0,this.animationId=this.animate(function(n,o){return o&&(r.scrollLeft=a+(e-a)*n,r.scrollTop=s+(t-s)*n,r.zoom=u+(i-u)*n,r.hooks.publish.emit(r.scrollLeft,r.scrollTop,r.zoom)),!0;},function(e,t){r.animationId===e&&(r.isAnimating=!1),(r.isDecelerationComplete||t)&&r.hooks.scrollComplete.emit(),r.zooming&&(r.calcMaxScroll(),r.hooks.zoomComplete.emit());},this.animationDuration,o?wN:pN);}else this.futureLeft=e,this.futureTop=t,this.futureZoom=i,this.scrollLeft=e,this.scrollTop=t,this.zoom=i,this.hooks.publish.emit(e,t,i),this.zooming&&(this.calcMaxScroll(),this.hooks.zoomComplete.emit());}},{key:"startDeceleration",value:function value(e){}},{key:"animate",value:function value(e,t,i,r){var n=new MF(e,t,i,r);return this.animations[n.id]=n,n.play(),n.id;}},{key:"cancelAnimate",value:function value(e){var t=this.animations[e];t&&(t.cancel(),delete this.animations[e]);}},{key:"calcMaxScroll",value:function value(e){e=e||this.zoom,this.maxScrollLeft=Math.max(0,this.contentWidth*e-this.viewportWidth),this.maxScrollTop=Math.max(0,this.contentHeight*e-this.viewportHeight);}}]);}(bN),AF=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t,[{key:"render",value:function value(e,t){e.parsedCheckBoxStyle=UF(e,e.checkBoxStyle);var i=e.parsedCheckBoxStyle.opacity;t.save(),t.globalAlpha=i,this.renderBox(e,t,"out"),t.clip(),this.renderBox(e,t,"in"),cP(this).call(this,e,t),this.renderBox(e,t,"center"),this.stroke(e,t),this.renderCheckMark(e,t),t.restore();}},{key:"renderBox",value:function value(e,t,i){var r=e.parsedCheckBoxStyle,n=r.x,o=r.y,a=r.width,s=r.height,u=r.borderWidth,l=r.borderRadiusX,c=r.borderRadiusY,h=0;"center"===i?h=u/2:"in"===i&&(h=u);var d=[{x:n+l,y:o+c,start:Math.PI,end:3*Math.PI/2},{x:n+a-l,y:o+c,start:3*Math.PI/2,end:2*Math.PI},{x:n+a-l,y:o+s-c,start:0,end:Math.PI/2},{x:n+l,y:o+s-c,start:Math.PI/2,end:Math.PI}],f=Math.max(l-h,0),v=Math.max(c-h,0);if(t.beginPath(),t.ellipse)for(var g=0;g<4;g++){var m=d[g],y=m.x,p=m.y,w=m.start,b=m.end;t.ellipse(y,p,f,v,0,w,b);}else t.rect(n,o,a,s);t.closePath();}},{key:"fill",value:function value(e,t){var i=e.parsedCheckBoxStyle.background;if(zL()){var r=_O(i);t.fillStyle=r.formatted;}else t.fillStyle=i;cP(t).call(t);}},{key:"stroke",value:function value(e,t){var i=e.parsedCheckBoxStyle,r=i.borderColor,n=i.borderWidth;if(zL()){var o=_O(r);t.strokeStyle=o.formatted;}else t.strokeStyle=r;t.lineWidth=n,n>0&&t.stroke();}},{key:"renderCheckMark",value:function value(e,t){if(e.checked){var i=e.parsedCheckBoxStyle,r=i.x,n=i.y,o=i.width,a=i.height,s=i.borderWidth,u=i.checkMarkLineWidth,l=i.checkMarkColor,c=Math.max(Math.min(o-2*s,a-2*s),0),h=r,d=n;if(0!==c){if(oo.width&&(o.width=2*v),2*v>o.height&&(o.height=2*v),BL(o.right)&&!BL(o.left)&&(g=a-o.width-c),BL(o.bottom)&&!BL(o.top)&&(m=s-o.height-h),Fk({x:g+d,y:m+f},o);}var RF=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t,[{key:"render",value:function value(e,t){e.parsedPageNumberStyle=UF(e,e.pageNumberStyle);var i=e.parsedPageNumberStyle.opacity;t.save(),t.globalAlpha=i,this.renderBox(e,t,"out"),t.clip(),this.renderBox(e,t,"in"),cP(this).call(this,e,t),this.renderBox(e,t,"center"),this.stroke(e,t),this.renderFont(e,t),t.restore();}},{key:"renderBox",value:function value(e,t,i){var r=e.parsedPageNumberStyle,n=r.x,o=r.y,a=r.width,s=r.height,u=r.borderWidth,l=r.borderRadiusX,c=r.borderRadiusY,h=0;"center"===i?h=u/2:"in"===i&&(h=u);var d=[{x:n+l,y:o+c,start:Math.PI,end:3*Math.PI/2},{x:n+a-l,y:o+c,start:3*Math.PI/2,end:2*Math.PI},{x:n+a-l,y:o+s-c,start:0,end:Math.PI/2},{x:n+l,y:o+s-c,start:Math.PI/2,end:Math.PI}],f=Math.max(l-h,0),v=Math.max(c-h,0);if(t.beginPath(),t.ellipse)for(var g=0;g<4;g++){var m=d[g],y=m.x,p=m.y,w=m.start,b=m.end;t.ellipse(y,p,f,v,0,w,b);}else t.rect(n,o,a,s);t.closePath();}},{key:"renderFont",value:function value(e,t){var i,r=e.parsedPageNumberStyle,n=r.x,o=r.y,a=r.width,s=r.height,u=r.fontSize,l=r.color,c=r.fontFamily;if(zL()){var h=_O(l);t.fillStyle=h.formatted;}else t.fillStyle=l;t.textAlign="center",t.textBaseline="middle",t.font=lS(i="".concat(u,"px ")).call(i,c),t.fillText(e.text,n+a/2,o+s/2+u/8,a);}},{key:"fill",value:function value(e,t){var i=e.parsedPageNumberStyle.background;if(zL()){var r=_O(i);t.fillStyle=r.formatted;}else t.fillStyle=i;cP(t).call(t);}},{key:"stroke",value:function value(e,t){var i=e.parsedPageNumberStyle,r=i.borderColor,n=i.borderWidth;if(zL()){var o=_O(r);t.strokeStyle=o.formatted;}else t.strokeStyle=r;t.lineWidth=n,n>0&&t.stroke();}}]);}(lH),LF=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t,[{key:"renderCheckMark",value:function value(e,t){var i=e.parsedCheckBoxStyle,r=i.x,n=i.y,o=i.width,a=i.height,s=i.borderWidth,u=i.checkMarkLineWidth,l=i.checkMarkColor,c=Math.max(Math.min(o-2*s,a-2*s),0),h=r,d=n;0!==c&&(o=0||e1&&(this.current+=1),this.selected=[this.children[this.current].uid],this.current);}},{key:"prev",value:function value(){return this.total<=0||this.current<0?-1:(this.current>0&&(this.current-=1),this.selected=[this.children[this.current].uid],this.current);}},{key:"first",value:function value(){return 0===this.total?-1:(this.current=0,this.selected=[this.children[0].uid],0);}},{key:"last",value:function value(){return 0===this.total?-1:(this.current=this.total-1,this.selected=[this.children[this.current].uid],this.current);}},{key:"goto",value:function value(e){var t,i=this;return 0===this.total?-1:(e!==this.current&&(e=HL(e,0,this.total-1),this.current=e),this.selected=[this.children[this.current].uid],$k(t=this.children).call(t,function(e){var t;e.isSelected=OI(t=i.selected).call(t,e.uid)>-1;}),this.current);}},{key:"select",value:function value(e){var t,i=e.length;if(0===i)return this.selected=e,this.current=-1,!0;var r=this.getIndexByUid(e[i-1]);return!(r<0||($k(t=this.children).call(t,function(t){t.isSelected=OI(e).call(e,t.uid)>-1;}),this.selected=e,this.current=r,0));}},{key:"getSelected",value:function value(){var e;return RI(e=this.selected).call(e);}},{key:"getChildByIndex",value:function value(e){return this.children[e];}},{key:"getChildByUid",value:function value(e){var t;return xP(t=this.children).call(t,function(t){return t.uid===e;});}},{key:"getIndexByUid",value:function value(e){var t;return EE(t=this.children).call(t,function(t){return t.uid===e;});}},{key:"getUidByIndex",value:function value(e){var t;return null===(t=this.children[e])||void 0===t?void 0:t.uid;}},{key:"getChildIndex",value:function value(e){var t;return OI(t=this.children).call(t,e);}},{key:"getChildUids",value:function value(){var e;return $E(e=this.children).call(e,function(e){return e.uid;});}},{key:"reorder",value:function value(e){var t=this.children,i=e.length,r=[],n=!1;if(t.length!==i)return!1;for(var o=0;o-1&&gE(i=this.tabSelectionStack).call(i,r,1),this.tabSelectionStack.push(e),this.currentTabUid=e,!0;}},{key:"closeTab",value:function value(e){if(!this.removeTab(e))return!1;var t=this.tabs,i=this.tabSelectionStack,r=OI(i).call(i,e);return gE(i).call(i,r,1),t.length?this.currentTabUid=i[i.length-1]:this.currentTabUid=null,!0;}},{key:"removeTab",value:function value(e){var t,i=EE(this).call(this,e);return i>-1&&(gE(t=this.tabs).call(t,i,1),this.hooks.removeTab.emit(e),!0);}},{key:"getCurTab",value:function value(){return xP(this).call(this,this.currentTabUid);}},{key:"getAllTabs",value:function value(){var e;return RI(e=this.tabs).call(e);}},{key:"setMode",value:function value(e){return("single"===e||"multiple"===e)&&(this.mode=e,!0);}}]);}(),HF=function(){return Yk(function e(){Xk(this,e),Wk(this,"lastTopPageIndex",-1);},[{key:"init",value:function value(e){var t=e.uiService,i=e.rendererService,r=t.canvasContainer,n=t.getViewportSize(),o=n.width,a=n.height;i.initCanvas({container:r,width:o,height:a}),i.registerShapeRenderer("checkbox",new AF()),i.registerShapeRenderer("pageNumber",new RF()),i.registerShapeRenderer("removeBtn",new LF()),this.listenHooks(e);}},{key:"listenHooks",value:function value(e){var t=this,i=e.rendererService.hooks;i.beforeRender.on(this.beforeRenderListener),i.afterRender.on(this.afterRenderListener),e.hooksService.hooks.destroy.on(function(){i.beforeRender.off(t.beforeRenderListener),i.afterRender.off(t.afterRenderListener);});}},{key:"beforeRenderListener",value:function value(e){var t=e.tabService,i=e.config,r=t.getCurrentTab();if(r){var n,o="multiple"===i.displayMode;$k(n=r.children).call(n,function(t,n){var a,s=i.pageNumberStyle.visibility,u=i.checkboxStyle.visibility,l=i.removeBtnStyle.visibility;o||(s="hidden",u="hidden",l="hidden"),t.pageNumber.updateText(String(n+1)),t.pageNumber.updateStyle({visibility:s}),t.checkbox.checked=OI(a=r.selected).call(a,t.uid)>-1,t.checkbox.updateStyle({visibility:u}),t.removeBtn.updateStyle({visibility:l});var c=r.selected,h=i.pageStyle;o&&(xP(c).call(c,function(e){return e===t.uid;})?h=i.selectedPageStyle:t.isHovered&&(h=i.hoveredPageStyle));var d=h,f=d.background,v=d.border,g={};v&&(g=hF(v));var m=g.borderWidth;if(i.enableSingleModeBorder||"single"!==i.displayMode&&"slide"!==i.displayMode||(m=0),t.borderBox.updateStyle(Fk(Fk({background:f},g),{},{borderWidth:m})),t.isDragging&&o){g={};var y=i.placeholderStyle,p=y.background,w=y.border;w&&(g=hF(w)),t.updateStyle(Fk({background:p},g));}else t.updateStyle({background:"#ffffff00",borderWidth:0});"slide"!==i.displayMode&&"single"!==i.displayMode&&"doc"!==i.displayMode||t.borderBox.updateStyle({background:"rgba(255,255,255,0)"}),!AL()&&!zL()&&!t.isOptimized&&t.isVisible&&t.isLoaded&&t.zoom<1&&new uB(function(e,t){jP(function(){e(null);},500);}).then(function(){e.optimizePage(t.uid);});});}}},{key:"afterRenderListener",value:function value(e){var t,i=e.tabService,r=e.config,n=e.rendererService,o=i.getCurrentTab();if(o&&(o.isTopPageChanged||-1!==n.lastTopPageIndex&&0===o.total)&&(o.isTopPageChanged=!1,"multiple"===r.displayMode)){var a=o.getIndexByUid(o.topPageUid);a!==n.lastTopPageIndex&&(e.emit("topPageChanged",a),n.lastTopPageIndex=a);}o&&$k(t=o.children).call(t,function(t,i){t.isPageRendered&&t.isVisible&&(t.isPageRendered=!1,t.isUpdated=!1,t.isEdited=!1,r.enableEmitPageRendered&&e.emit("pageRendered",i));});}}]);}(),FF=function(){return Yk(function e(){Xk(this,e);},[{key:"init",value:function value(e){this.listenNativeEvent(e),this.listenViewerHooks(e);}},{key:"listenViewerHooks",value:function value(e){var t=e.hooksService.hooks,i=function i(t){var i,r,n,o=t.tabNode,a=(null==o||null===(i=o.layoutStatus)||void 0===i?void 0:i.currentLayoutWidth)||0,s=(null==o||null===(r=o.layoutStatus)||void 0===r?void 0:r.currentLayoutHeight)||0;a=Math.max(Math.floor(a)-1,0),s=Math.max(Math.floor(s)-1,0),e.uiService.updateScrollContentSize(a,s),e.scrollerService.updateScroller({contentWidth:a,contentHeight:s}),"single"===e.config.displayMode&&(e.config.zoom=o.layoutStatus.zoom),0!==o.layoutStatus.viewWidth&&0!==o.layoutStatus.viewHeight&&$k(n=o.children).call(n,function(t){if(t.isPreload)t.isLoaded||t.imageContainer.imageData||("multiple"===e.config.displayMode&&e.config.useMinImage?e.dvsContext.minImageService.load(t.uid):e.dvsContext.imageService.load(t.uid));else{t.image.style.img=null,t.isLoaded=!1;var i=e.dvsContext.viewerService.isPageNeedLoad(t.uid);if(i.min&&"multiple"===e.config.displayMode&&e.config.useMinImage){var r=e.getStatus(t.uid);r&&(r.minImg=null);}if(i.ori&&"single"===e.config.displayMode){var n=e.getStatus(t.uid);n&&(n.img=null);}}});},r=function r(t){if(!t.isPassive&&e.config.autoScroll&&"single"!==e.config.displayMode&&"slide"!==e.config.displayMode){var i=e.getCurrentTab(),r=i.layoutStatus,n=r.viewWidth,o=r.viewHeight,a=r.rowHeightArray,s=r.columnWidthArray,u=r.placeholderPages,l=r.scrollLeft,c=r.scrollTop,h=r.realRow,d=r.realCol,f=i.currentPage,v=i.current,g=i.row,m=i.column,y=i.enableDWT1x1,p=f.getLocalPosition(),w=p.x,b=p.y,k=f.viewportPosition,S=l,x=c,C=!1,V=0,T=e.getMargin(),I=e.getGap(),E=1===m&&1===g&&y;if("multiple"===e.config.displayMode)"ahead"===k.x?(S=w-(V=0===k.column?T:E?0:I),C=!0):"behind"===k.x&&(V=k.column===d-1?T:E?0:I,S=w+s[0]-n+V,i.total<=i.row*i.column&&(S=i.getChildByIndex(0).getLocalPosition().x-T),C=!0),"ahead"===k.y?(x=b-(V=0===k.row?T:E?0:I),C=!0):"behind"===k.y&&(V=k.row===h-1?T:E?0:I,x=b+a[0]-o+V,i.total<=i.row*i.column&&(x=i.getChildByIndex(0).getLocalPosition().y-T),C=!0);else if("doc"===e.config.displayMode){var P=u[v];if("ahead"===k.x&&P.x<=i.gap?(C=!0,S=P.x-i.gap):"behind"===k.x&&P.x<=i.gap&&(C=!0,S=P.x+P.width-n+i.gap,P.width>n&&(S=P.x-i.gap)),i.getChildByIndex(i.total-1).getLocalPosition(),u[i.total-1].height,i.margin,"ahead"===k.y)C=!0,x=P.y-i.gap;else if("behind"===k.y){C=!0,x=P.y+P.height-o+i.gap;var B=i.layoutStatus;B.validLayoutHeight*B.zoom+B.fixedHeight<=o&&(x=0),P.height>o&&(x=P.y-i.gap);}}C&&(i.setPosition({x:-S,y:-x}),i.updateLayoutStatus({scrollLeft:S,scrollTop:x}),e.scrollerService.updateScroller({scrollLeft:S,scrollTop:x}),0===i.current?e.uiService.scrollTo(S+1,x+100):i.current===i.total-1&&e.uiService.scrollTo(S-100,x-100),e.uiService.scrollTo(S,x));}};e.layoutService.hooks.afterLayout.on(i),t.currentIndexChanged.on(r),e.hooksService.hooks.destroy.on(function(){e.layoutService.hooks.afterLayout.off(i),t.currentIndexChanged.off(r);});}},{key:"listenNativeEvent",value:function value(e){var t=e.rendererService.canvasDom,i=function i(t){e.scrollerService.mousedownListener(t);},r=function r(t){e.scrollerService.mousemoveListener(t);},n=function n(t){e.scrollerService.mouseupListener(t);},o=function o(t){e.scrollerService.mousedownListener(t);},a=function a(t){e.scrollerService.mousemoveListener(t);},s=function s(t){e.scrollerService.mouseupListener(t);},u=function u(t){var i=e.tabService.getCurrentTab();null==i||!i.total||0===i.selected.length&&"single"===e.config.displayMode||e.scrollerService.wheelListener(t);},l=function l(e){e.cancelable&&e.preventDefault();};t.addEventListener("wheel",u,{passive:!1}),t.addEventListener("touchstart",o,{passive:!1}),t.addEventListener("touchmove",l,{passive:!1}),document.addEventListener("touchmove",a,{passive:!1}),document.addEventListener("touchend",s),t.addEventListener("mousedown",i),document.addEventListener("mousemove",r),document.addEventListener("mouseup",n),e.hooksService.hooks.destroy.on(function(){t.removeEventListener("wheel",u),t.removeEventListener("touchstart",o),t.removeEventListener("touchmove",l),document.removeEventListener("touchmove",a),document.removeEventListener("touchend",s),t.removeEventListener("mousedown",i),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",n);});}}]);}(),jF=function(){return Yk(function e(){Xk(this,e);},[{key:"init",value:function value(e){this.listenViewerHooks(e);}},{key:"listenTabHooks",value:function value(e){var t=function t(_t4){e.hooksService.hooks.removeTab.emit(_t4);},_i4=function i(){e.tabService.tabManager.hooks.removeTab.off(t),e.hooksService.hooks.destroy.off(_i4);};e.tabService.tabManager.hooks.removeTab.on(t),e.hooksService.hooks.destroy.on(_i4);}},{key:"listenViewerHooks",value:function value(e){var t=this,i={beforeStatus:null,afterStatus:null,operation:null,docUid:null},r=function r(_r3){var n=_r3.modifiedUid,o=_r3.docUid,a=_r3.removedUids,s=e.tabService.getTab(o);s&&e.tabService.isCurrentTab(o)&&(i.beforeStatus=t.createBufferStatus(s,n,a));},n=function n(r){var n=r.modifiedUid,o=r.docUid,a=r.operation,s=r.removedUids,u=e.tabService.getTab(o);if(u&&e.tabService.isCurrentTab(o)){var l,c;i.afterStatus=t.createBufferStatus(u,n,s),i.operation=a,i.docUid=o,i.curIndex=u.current||0,i.total=u.total||0;var h=e.viewer.getSelectedIndexes();e.emit("_imageSelectedUI",h),e.emit("imageSelected",h);var d=u.current,f=u.total;e.emit("_dvsPagerChanged",{current:d,total:f}),r.isSameDoc||e.emit("bufferChanged",Fk({},i));var v=null===(l=i.beforeStatus)||void 0===l?void 0:l.currentUid,g=null===(c=i.afterStatus)||void 0===c?void 0:c.currentUid;if("add"===a&&v!==g){var m=_SL(i);m.operation="shift",e.emit("bufferChanged",m);}}i={beforeStatus:null,afterStatus:null,operation:null,docUid:null,curIndex:0,total:0};},o=function o(t){e.tabService.openDoc(t);},a=e.hooksService.hooks;a.beforeBufferChanged.on(r),a.afterBufferChanged.on(n),a.openDoc.on(o);var _s2=function s(){a.beforeBufferChanged.off(r),a.afterBufferChanged.off(n),a.openDoc.off(o),e.hooksService.hooks.destroy.off(_s2);};e.hooksService.hooks.destroy.on(_s2);}},{key:"createBufferStatus",value:function value(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return{uids:e.getChildUids(),selectedUids:e.getSelected(),currentUid:e.currentUid,modifiedUid:t,removedUids:i};}}]);}();function YF(e,t){if(kL(t)){LA(e.config.viewerStyle,t);var i=e.uiService,r=i.scrollContainer,n=i.canvasContainer,o=e.getBorderWidth(e.config.viewerStyle);n&&r&&(LA(n.style,{left:"".concat(o,"px"),top:"".concat(o,"px")}),LA(r.style,t),e.resized());}}function XF(e,t){if(kL(t)){LA(e.config.canvasStyle,t);var i,r=e.rendererService.canvasDom;if(r)LA(r.style,t),OI(i=eS(t||{})).call(i,"border")>-1&&e.resized();}}function qF(e,t){if(kL(t)){var i;LA(e.config.pageStyle,t);var r=e.getBorderWidth(e.config.pageStyle);$k(i=e.getAllTabs()).call(i,function(e){e.borderWidth=r;}),e.clearCurTabOptimization(),e.render();}}function ZF(e,t){if(kL(t)){var i;LA(e.config.selectedPageStyle,t);var r=e.getBorderWidth(e.config.selectedPageStyle);$k(i=e.getAllTabs()).call(i,function(e){e.selectedBorderWidth=r;}),e.clearCurTabOptimization(),e.render();}}function _F(e,t){if(kL(t)){var i;LA(e.config.hoveredPageStyle,t);var r=e.getBorderWidth(e.config.hoveredPageStyle);$k(i=e.getAllTabs()).call(i,function(e){e.hoveredBorderWidth=r;}),e.clearCurTabOptimization(),e.render();}}function GF(e,t){kL&&(LA(e.config.placeholderStyle,t),e.render());}function KF(e,t){var i;kL(t)&&(LA(e.config.pageNumberStyle,t),$k(i=e.getAllTabs()).call(i,function(t){var i;$k(i=t.children).call(i,function(t){t.pageNumber.updateStyle(e.config.pageNumberStyle);});}),e.rendererService.render());}function $F(e,t){var i;kL(t)&&(LA(e.config.checkboxStyle,t),$k(i=e.getAllTabs()).call(i,function(t){var i;$k(i=t.children).call(i,function(t){t.checkbox.updateStyle(e.config.checkboxStyle);});}),e.rendererService.render());}function JF(e,t){var i;kL(t)&&(LA(e.config.removeBtnStyle,t),$k(i=e.getAllTabs()).call(i,function(t){var i;$k(i=t.children).call(i,function(t){t.removeBtn.updateStyle(e.config.removeBtnStyle);});}),e.rendererService.render());}function QF(e,t){e.config.enableDragPage=t;}function ej(e,t){e.config.enableKeyboardControl=t;}function tj(e,t){e.config.multiselectMode=t;}function ij(e,t){e.config.zoomOrigin=t;}function rj(e,t){t=HL(t,e.config.minZoom,e.config.maxZoom),e.zoomService.zoomTo(t),e.config.zoom=t;}function nj(e,t){e.config.minZoom=t;}function oj(e,t){e.config.maxZoom=t;}function aj(e,t){e.config.enableZoom=t;}function sj(e,t){e.config.enableScrollX=t;}function uj(e,t){e.config.enableScrollY=t;}function lj(e,t){e.config.keepZoom=t;}function cj(e,t){e.config.zoomInDelta=t;}function hj(e,t){e.config.zoomOutDelta=t;}function dj(e,t){e.config.wheelZoomDelta=t;}function fj(e,t){e.config.scrollDirection=t;var i=e.getCurrentTab();i&&(i.direction=t,e.resized());}function vj(e,t){var i,r=t!==e.config.displayMode;e.config.displayMode=t;var n=e.getCurrentTab();n&&(n.displayMode=t,$k(i=n.children).call(i,function(e){e.isLoaded=!1;}),e.showTab(n),r&&e.resetScrollbarStatus(),e.clearCurTabOptimization(),e.render(),"multiple"===t&&e.emitCurrentIndexChanged());}function gj(e,t){e.config.toolType=t;var i=e.getCurrentTab();i&&(i.toolType=t,e.rendererService.render());}function mj(e,t){if(e.config.fitType!==t){e.config.fitType=t;var i=e.getCurrentTab();if(i){i.fitType=t,e.resetScrollbarStatus(),e.resetScrollerSize(),e.resize(),e.clearCurTabOptimization(),e.render();var r=e.uiService.scrollContainer,n=r.scrollWidth,o=r.scrollHeight,a=n-r.clientWidth,s=o-r.clientHeight,u=e.config.zoomOrigin,l=u.x,c=u.y,h=0,d=0;"center"===l?h=a/2:"right"===l&&(h=a),"center"===c?d=s/2:"bottom"===c&&(d=s),0===h&&0===d||e.uiService.scrollTo(h,d);}}}function yj(e,t){if(e.config.show!==t){e.config.show=t;var i=e.uiService,r=i.rootDom,n=i.defaultDom;if(r&&(t?(r.style.display="flex",n.style.display="flex"):r.style.display="none"),e.resized(),t){var o=e.getCurrentTab();o&&(e.showTab(o),e.renderOnly());}}}function pj(e,t){e.setViewMode(t,e.config.columns);}function wj(e,t){e.setViewMode(e.config.rows,t);}function bj(e,t){e.config.pure=!0;}function kj(e,t){e.config.margin!==t&&(e.config.margin=t,e.clearCurTabOptimization(),e.render());}function Sj(e,t){e.config.gap!==t&&(e.config.gap=t,e.clearCurTabOptimization(),e.render());}function xj(e,t){e.config.autoChangeIndex=t;}function Cj(e,t){e.config.autoScroll=t;}function Vj(e,t){e.config.autoSelectLatest=t;}function Tj(e,t){e.config.enableSelectWithShift=t;}function Ij(e,t){e.config.enableZoomWithCtrl=t;}function Ej(e,t){e.config.enableSelectWithCtrl=t;}function Pj(e,t){"single"===t||"multiple"===t?(e.config.tabMode=t,e.tabService.tabManager.setMode(t),e.ok()):e.err(mL);}function Bj(e,t){e.config.enableSyncSelect=t;}function Dj(e,t){e.config.enableSingleModeBorder=t;}function Mj(e,t){e.config.blankFillColor=t;}function zj(e,t){e.config.dragThreshold=t;}function Aj(e,t){e.config.slideThreshold=t;}function Uj(e,t){e.config.maxOptimizationSize=t;}function Rj(e,t){e.config.enableSlide=t;}function Lj(e,t){e.config.enableDWT1x1=t;}function Nj(e,t){e.config.enableEmitPageRendered=t;}function Oj(e,t){e.config.autoSelectTopPage=t;}function Wj(e,t){e.config.enableOptimizeImage=t;}function Hj(e,t){e.config.useMinImage=t;}var Fj=function(){return Yk(function e(t){Xk(this,e),Wk(this,"context",void 0),Wk(this,"handlers",{}),this.context=t,this.initHandlers();},[{key:"destroy",value:function value(){this.context=null,this.handlers={};}},{key:"updateConfig",value:function value(e){for(var t=0,i=oB(e);t=0;n--)r.removeChild(r.childNodes[n]);this.canvas.render();}},{key:"initCanvas",value:function value(e){var t=e.container,i=e.width,r=e.height,n=new TH({}),o=new uH({renderer:n,container:t,width:i,height:r});this.renderer=n,this.canvas=o,this.canvasDom=o.contextService.getDomElement(),this.canvasDom.tabIndex=0,LA(this.canvasDom.style,this.context.config.canvasStyle),this.isInitialized=!0;}},{key:"registerShapeRenderer",value:function value(e,t){this.canvas.contextService.registerShapeRenderer(e,t);}},{key:"getCanvasPosition",value:function value(){var e=this.canvasDom.getBoundingClientRect(),t=yN(),i=t.scrollX,r=t.scrollY;return{x:e.left+i,y:e.top+r};}},{key:"resetCanvasSize",value:function value(){this.canvasDom.style.width="0px",this.canvasDom.style.height="0px";}}]);}(),qj=function(){return Yk(function e(t){var i=this;Xk(this,e),Wk(this,"context",void 0),Wk(this,"isStart",!1),Wk(this,"scroller",void 0),Wk(this,"startDistance",0),Wk(this,"startZoom",1),Wk(this,"lastScale",1),Wk(this,"originX",0),Wk(this,"originY",0),Wk(this,"startX",0),Wk(this,"startY",0),Wk(this,"isSliding",!1),Wk(this,"isZoom",!1),Wk(this,"slideDirection","left"),Wk(this,"slideDistance",0),Wk(this,"slideTimer",null),Wk(this,"wheelTimer",null),Wk(this,"touchZoomTimer",null),Wk(this,"startTime",0),Wk(this,"isScrolling",!1),Wk(this,"scrollTimer",null),Wk(this,"scrollDirectionX","left"),Wk(this,"scrollDirectionY","up"),Wk(this,"lineHeight",this.getLineHeight()),Wk(this,"startHandler",function(e,t){var r=i.context.config;"default"===r.toolType?(i.isStart=!0,e.length>1&&(i.startDistance=Math.pow(Math.pow(e[0].pageX-e[1].pageX,2)+Math.pow(e[0].pageY-e[1].pageY,2),.5)),i.scroller.onStartHandler(e,t)):"zoomIn"===r.toolType&&"multiple"!==r.displayMode?i.context.zoomService.zoomTo(r.zoom*r.zoomInDelta,e[0].pageX,e[0].pageY):"zoomOut"===r.toolType&&"multiple"!==r.displayMode&&i.context.zoomService.zoomTo(r.zoom/r.zoomOutDelta,e[0].pageX,e[0].pageY);}),this.context=t,this.scroller=new zF(),this.scroller.hooks.publish.on(function(e,i,r){t.uiService.scrollTo(e,i);});},[{key:"getLineHeight",value:function value(){var e=getComputedStyle(document.body),t=e.lineHeight,i=e.fontSize;if(/\d+/.test(t)){var r=Gb(t.match(/(\d+)/),1)[0];return $S(r,10);}if(/\d+/.test(i)){var n=Gb(i.match(/(\d+)/),1)[0];return 1.2*$S(n,10);}return 16;}},{key:"destroy",value:function value(){this.wheelTimer&&(clearTimeout(this.wheelTimer),this.wheelTimer=null),this.touchZoomTimer&&(clearTimeout(this.touchZoomTimer),this.touchZoomTimer=null),this.scrollTimer&&($N.clearTimer(this.scrollTimer),this.scrollTimer=null),this.slideTimer&&($N.clearTimer(this.slideTimer),this.slideTimer=null);}},{key:"updateScroller",value:function value(e){this.scroller.updateScroller(e);}},{key:"mousedownListener",value:function value(e){var t;if(!(e instanceof MouseEvent&&"multiple"===this.context.config.displayMode||this.isSliding)){var i=null===(t=this.context)||void 0===t?void 0:t.getCurrentTab();if(i&&i.total){var r=this.context.formatTouches(e);this.startX=r[0].pageX,this.startY=r[0].pageY,this.lastScale=1,this.startTime=new Date().getTime(),this.isScrolling=!1,this.scrollTimer&&($N.clearTimer(this.scrollTimer),this.scrollTimer=null),this.startZoom=this.context.config.zoom,this.startHandler(r,e.timeStamp);}}}},{key:"mousemoveListener",value:function value(e){var t,i=this;if(this.isStart){var r=this.context.formatTouches(e);if(window.TouchEvent&&e instanceof TouchEvent){if(this.context.draggingPrepared)return void(e.cancelable&&e.preventDefault());if(r.length>1&&this.context.config.enableZoom&&"single"===this.context.config.displayMode){var n=(r[0].pageX+r[1].pageX)/2,o=(r[0].pageY+r[1].pageY)/2,a=Math.pow(Math.pow(r[0].pageX-r[1].pageX,2)+Math.pow(r[0].pageY-r[1].pageY,2),.5)/this.startDistance;e.scale&&(a=e.scale);var s=this.context.config.zoom,u=s;return(s=this.startZoom*a)!==u&&(this.touchZoomTimer||(this.touchZoomTimer=jP(function(){i.context.zoomService.zoomTo(s,n,o),clearTimeout(i.touchZoomTimer),i.touchZoomTimer=null;},25))),this.lastScale=a,void(this.isZoom=!0);}}var l=null===(t=this.context)||void 0===t?void 0:t.getCurrentTab(),c=r[0].pageX-this.startX;if(l&&l.total){if(c>0?this.slideDirection="right":c<0&&(this.slideDirection="left"),this.slideDistance=Math.min(l.layoutStatus.viewWidth,Math.abs(c)),this.isSliding)return"right"===this.slideDirection?l.setPosition({x:this.slideDistance,y:0,z:0}):"left"===this.slideDirection&&l.setPosition({x:-this.slideDistance,y:0,z:0}),void this.context.renderOnly();"single"===this.context.config.displayMode&&"default"===this.context.config.toolType&&this.context.config.enableSlide&&Math.abs(c)>this.context.config.slideThreshold&&!this.context.uiService.isScrollbarAppeared()&&(this.isSliding=!0,this.context.updateViewerConfig({displayMode:"slide"}));}this.scroller.onMoveHandler(r,e.timeStamp);}}},{key:"slide",value:function value(e){var t,i=this,r=0,n=0,o=0,a=!1;this.slideDistance>=this.context.config.slideThreshold?(t=(n=e.layoutStatus.viewWidth)-this.slideDistance,"left"===this.slideDirection?e.current!==e.total-1?(o=-this.slideDistance,r=-t/8):(n=0,t=this.slideDistance,a=!0,o=-this.slideDistance,r=t/8):0!==e.current?(o=this.slideDistance,r=t/8):(n=0,t=this.slideDistance,a=!0,o=this.slideDistance,r=-t/8)):(a=!0,n=0,t=this.slideDistance,"left"===this.slideDirection?(o=-this.slideDistance,r=t/8):(o=this.slideDistance,r=-t/8)),this.slideTimer=$N.createTimer(function(){var t=(o+=r)>=0;if(Math.abs(o)>=n&&(o=n,t||(o*=-1)),e.setPosition({x:o,y:0,z:0}),Math.abs(o)===n)return a||("right"===i.slideDirection?i.context.viewer.prevPage():i.context.viewer.nextPage(),i.context.updateViewerConfig({fitType:"window"})),i.isSliding=!1,i.context.updateViewerConfig({displayMode:"single"}),void $N.clearTimer(i.slideTimer);i.context.renderOnly();},25);}},{key:"mouseupListener",value:function value(e){if(this.isStart){var t=this.context.formatTouches(e,!0),i=this.context.config.displayMode;if(this.isZoom||"slide"!==i){this.scroller.onEndHandler(e.timeStamp);var r=this.context.uiService.getMaxScrollValue(),n=r.maxScrollLeft,o=r.maxScrollTop,a=this.context.uiService.scrollContainer,s=a.scrollLeft,u=a.scrollTop;if(!this.isZoom&&!this.isSliding&&!this.isScrolling&&!this.context.draggingPrepared&&(n>0||o>0)&&window.TouchEvent&&e instanceof TouchEvent&&"default"===this.context.config.toolType){var l=new Date().getTime(),c=t[0].pageX,h=t[0].pageY,d=c-this.startX,f=h-this.startY,v=!1,g=!1;d>0?(v=0!==s,this.scrollDirectionX="right"):(v=s!==n,this.scrollDirectionX="left"),f>0?(g=0!==u,this.scrollDirectionY="down"):(g=u!==o,this.scrollDirectionY="up");var m=l-this.startTime;if((Math.abs(d)>10||Math.abs(f)>10)&&m>0&&m<300&&(v||g)){var y=Math.abs(d)/m,p=Math.abs(f)/m;(y>.4||p>.4)&&(y=Math.min(y,2.8),p=Math.min(p,2.8),this.scroll(y,p,-.05));}}}else{var w,b=null===(w=this.context)||void 0===w?void 0:w.getCurrentTab();b&&this.slide(b);}this.isStart=!1,this.lastScale=1,this.isZoom=!1;}}},{key:"scroll",value:function value(e,t,i){var r=this;this.isScrolling=!0;var n=this.context.uiService.scrollContainer,o=n.scrollLeft,a=n.scrollTop,s=0,u=0;this.scrollTimer=$N.createTimer(function(){var n=r.context.uiService.getMaxScrollValue(),l=n.maxScrollLeft,c=n.maxScrollTop;if(e<=0&&t<=0||!1===r.isScrolling)return $N.clearTimer(r.scrollTimer),r.scrollTimer=null,void(r.isScrolling=!1);e>=0&&("right"===r.scrollDirectionX?s-=40*e:s+=40*e,e+=i),t>=0&&("down"===r.scrollDirectionY?u-=40*t:u+=40*t,t+=i);var h=HL(o+s,0,l),d=HL(a+u,0,c);r.context.uiService.scrollTo(h,d);},25);}},{key:"wheelListener",value:function value(e){var t=this,i=this.context.config,r=e.wheelDelta;if(e.deltaY&&(r=-e.deltaY),1===e.deltaMode&&(r*=this.lineHeight),2===e.deltaMode&&(r=r<0?-100:100),e.ctrlKey&&i.enableZoomWithCtrl){if("multiple"!==i.displayMode){e.cancelable&&e.preventDefault();var n=r>0?i.wheelZoomDelta:1/i.wheelZoomDelta,o=this.context.rendererService.getCanvasPosition(),a=o.x,s=o.y;this.wheelTimer||(this.wheelTimer=jP(function(){t.context.zoomService.zoomTo(i.zoom*n,e.pageX-a,e.pageY-s),clearTimeout(t.wheelTimer),t.wheelTimer=null;},40));}}else e.shiftKey?(e.cancelable&&e.preventDefault(),this.context.uiService.scrollBy(-r,0)):(e.cancelable&&e.preventDefault(),this.context.uiService.scrollBy(0,-r));}}]);}(),Zj=function(){return Yk(function e(t){var i=this;Xk(this,e),Wk(this,"context",void 0),Wk(this,"tabManager",void 0),Wk(this,"appendPageTimer",null),Wk(this,"selectPage",function(e){var t=i.context,r=t.groupUid,n=t.hooksService,o=t.viewerUid;if(e.groupUid===r){var a=i.getTab(e.docUid);if(a){i.isCurrentTab(a.uid)&&n.hooks.beforeBufferChanged.emit(e);var s=!e.triggerByScroll||e.triggerByScroll&&e.trigger!==o;s&&(a.select(e.selectedUids),!1!==e.updateShiftReference&&a.updateShiftReference()),i.isCurrentTab(a.uid)&&(s&&!1!==e.updateShiftReference&&i.context.emitCurrentIndexChanged(),n.hooks.afterBufferChanged.emit(e),s&&(i.context.showTab(a),i.context.handleOrigin(),i.context.renderOnly()));}}}),this.context=t,this.tabManager=new WF({tabMode:this.context.config.tabMode});},[{key:"destroy",value:function value(){this.appendPageTimer&&(clearTimeout(this.appendPageTimer),this.appendPageTimer=null);}},{key:"createTab",value:function value(e){var t,i,r=this,n=this.context.config,o=n.displayMode,a=n.toolType,s=n.scrollDirection,u=n.fitType,l=n.rows,c=n.columns,h=n.enableDWT1x1,d=n.pageStyle,f=n.selectedPageStyle,v=n.hoveredPageStyle,g=n.zoom,m=this.context.getBorderWidth(d),y=this.context.getBorderWidth(f),p=this.context.getBorderWidth(v),w=this.context.uiService.getViewportSize(),b={doc:e,displayMode:o,toolType:a,fitType:u,direction:s,viewWidth:w.width||800,viewHeight:w.height||800,dpr:1,scrollbarWidth:17,row:l,column:c,borderWidth:m,selectedBorderWidth:y,hoveredBorderWidth:p,enableDWT1x1:h,viewer:this.context.viewer},k=xP(t=this.tabManager).call(t,e.uid);return k||((k=this.tabManager.createTab(e,b)).layoutStatus.zoom=g,$k(i=e.children).call(i,function(e){var t=r.createPage(e);t&&k.appendChild(t);})),k;}},{key:"getCurrentTab",value:function value(){return this.tabManager.getCurTab();}},{key:"getAllTabs",value:function value(){return this.tabManager.getAllTabs();}},{key:"isCurrentTab",value:function value(e){return this.tabManager.currentTabUid===e;}},{key:"updateTab",value:function value(e){var t,i=this,r=e.modifiedUid,n=e.data,o=this.context,a=o.viewerUid,s=o.groupUid,u=o.hooksService;$k(t=this.tabManager.getAllTabs()).call(t,function(e){var t=e.getChildByUid(r);if(t){var o,l,c,h,d,f={docUid:e.uid,trigger:a,groupUid:s,operation:"modify",modifiedUid:r};i.isCurrentTab(e.uid)&&u.hooks.beforeBufferChanged.emit(f);var v=e.current,g=RI(o=e.selected).call(o);t.isPreload=!1,t.isLoaded=!1,t.isUpdated=!0,t.image.style.img=null,t.clearOptimization(),$k(l=RI(c=t.blanks.childNodes).call(c)).call(l,function(e){t.blanks.removeChild(e);}),void 0!==(null===(h=n.metadata)||void 0===h?void 0:h.width)&&(t.realTimeWidth=n.metadata.width),void 0!==(null===(d=n.metadata)||void 0===d?void 0:d.height)&&(t.realTimeHeight=n.metadata.height),e.current=v,e.selected=g,i.isCurrentTab(e.uid)&&(i.context.showTab(e),u.hooks.afterBufferChanged.emit(f));}});}},{key:"movePage",value:function value(e){var t=this.getTab(e.docUid);if(t){var i=this.context.hooksService;this.isCurrentTab(t.uid)&&i.hooks.beforeBufferChanged.emit(e),t.move(e.from,e.to),this.isCurrentTab(t.uid)&&(this.context.emitCurrentIndexChanged(),i.hooks.afterBufferChanged.emit(e),this.context.showTab(t),this.context.renderOnly());}}},{key:"switchPage",value:function value(e){var t=this.getTab(e.docUid);if(t){var i=this.context.hooksService;this.isCurrentTab(t.uid)&&i.hooks.beforeBufferChanged.emit(e),t.switch(e.one,e.other),this.isCurrentTab(t.uid)&&(this.context.emitCurrentIndexChanged(),i.hooks.afterBufferChanged.emit(e),this.context.showTab(t),this.context.renderOnly());}}},{key:"reorderPages",value:function value(e){var t,i=xP(t=this.tabManager).call(t,e.docUid);if(i){var r=this.context.hooksService;this.isCurrentTab(i.uid)&&r.hooks.beforeBufferChanged.emit(e),i.reorder(e.indexes),this.isCurrentTab(i.uid)&&(r.hooks.afterBufferChanged.emit(e),this.context.showTab(i),this.context.emitCurrentIndexChanged());}}},{key:"changePage",value:function value(e){var t=this.context,i=t.groupUid,r=t.hooksService;if(e.groupUid===i){var n,o=xP(n=this.tabManager).call(n,e.docUid);o&&(o.current!==e.index||o.selected.length>1)&&(this.isCurrentTab(o.uid)&&r.hooks.beforeBufferChanged.emit(e),o.goto(e.index),o.updateShiftReference(),this.isCurrentTab(o.uid)&&(this.context.emitCurrentIndexChanged(),r.hooks.afterBufferChanged.emit(e),this.context.showTab(o),this.context.handleOrigin(),this.context.renderOnly()));}}},{key:"removePagesFromDoc",value:function value(e,t){var i=this.getTab(e);if(i){var r=this.context.hooksService,n={removedUids:t,docUid:i.uid,operation:"remove"};this.isCurrentTab(i.uid)&&r.hooks.beforeBufferChanged.emit(n),$k(t).call(t,function(e){var t=i.getChildByUid(e);t&&t.destroy(),i.removeChildByUid(e);}),i.updateShiftReference(),i.total||(i.topPageUid=null),this.isCurrentTab(i.uid)&&(r.hooks.afterBufferChanged.emit(n),this.context.showTab(i),this.context.handleOrigin(),this.context.renderOnly());}}},{key:"appendPagesToDoc",value:function value(e,t){var i=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=this.getTab(e);if(o){var a=this.context,s=a.viewerUid,u=a.groupUid,l=a.hooksService,c=a.config,h={docUid:e,trigger:s,groupUid:u,operation:"add",isSameDoc:n};this.isCurrentTab(o.uid)&&l.hooks.beforeBufferChanged.emit(h);var d=r>-1;if($k(t).call(t,function(e,t){var n=i.createPage(e);n&&(n.clearOptimization(),d?o.insertChild(n,r+t):o.appendChild(n));}),c.autoSelectLatest){o.currentPage&&o.currentPage.clearOptimization(),o.current=d?r+t.length-1:o.total-1;var f=o.currentPage;f&&o.select([f.uid]);}else o.total>0&&-1===o.current&&(o.current=0,o.select([o.getChildByIndex(0).uid]));o.updateShiftReference(),this.isCurrentTab(o.uid)&&(l.hooks.afterBufferChanged.emit(h),this.appendPageTimer||(this.appendPageTimer=jP(function(){o.isLoadPage=!0,i.getCurrentTab()===o&&(i.context.showTab(o),c.autoSelectLatest&&"single"!==c.displayMode&&"slide"!==c.displayMode&&i.context.config.show?i.context.emitCurrentIndexChanged():i.context.renderOnly()),clearTimeout(i.appendPageTimer),i.appendPageTimer=null;},42)));}}},{key:"openDoc",value:function value(e){var t=this.context,i=t.config,r=t.hooksService,n=t.viewerUid,o=t.groupUid,a=this.getTab(e.uid);a||(a=this.createTab(e)).total>0&&(i.autoSelectLatest?a.current=a.total-1:a.current=0,a.select([a.getChildByIndex(a.current).uid])),this.context.showTab(a);var s={docUid:e.uid,trigger:n,groupUid:o,operation:"filter"};r.hooks.beforeBufferChanged.emit(s),r.hooks.afterBufferChanged.emit(s),i.autoSelectLatest&&"single"!==i.displayMode&&"slide"!==i.displayMode&&this.context.config.show?this.context.emitCurrentIndexChanged():this.context.renderOnly();}},{key:"renameDoc",value:function value(e,t){var i=this.getTab(t);i&&(i.name=e);}},{key:"removeDoc",value:function value(e){return!!TL(e)&&!!this.tabManager.closeTab(e)&&(0===this.getAllTabs().length&&this.context.tabCleared(),this.context.render(),!0);}},{key:"getTab",value:function value(e){var t;return xP(t=this.tabManager).call(t,e);}},{key:"createPage",value:function value(e){var t=this.context.config,i=t.pageStyle,r=t.checkboxStyle,n=t.pageNumberStyle,o=t.removeBtnStyle,a=t.blankFillColor,s=t.defaultWidth,u=t.defaultHeight,l=this.getFormattedStyle(i),c=this.context.getStatus(e);if(!c)return null;var h=c.realTimeWidth,d=c.realTimeHeight;return new DF({uid:e,style:{visibility:"hidden",pointerEvents:"auto",width:h||s,height:d||u},formattedPageStyle:l,checkboxStyle:r,pageNumberStyle:n,removeBtnStyle:o,realTimeWidth:h,realTimeHeight:d,blankFillColor:a||"rgba(0,0,0,0)"});}},{key:"getFormattedStyle",value:function value(e){var t=e.border,i=e.background,r={};return t&&(r=hF(t)),Fk({background:i},r);}},{key:"setViewportSize",value:function value(e,t){var i=this.tabManager.getCurTab();i&&i.updateLayoutStatus({viewWidth:e,viewHeight:t});}}]);}(),_j=function(){return Yk(function e(t){Xk(this,e),Wk(this,"container",void 0),Wk(this,"scrollContent",void 0),Wk(this,"scrollContainer",void 0),Wk(this,"canvasAndScrollContainer",void 0),Wk(this,"canvasContainer",void 0),Wk(this,"defaultDom",void 0),Wk(this,"rootDom",void 0),Wk(this,"hooks",{scroll:SN.create()}),Wk(this,"isBindContainer",!1),Wk(this,"viewerWidth",void 0),Wk(this,"viewerHeight",void 0),Wk(this,"context",void 0),Wk(this,"dpr",gN()),this.context=t;},[{key:"initDefaultUI",value:function value(){var e=this,t=this.context,i=t.postfix,r=t.config,n=this.createDefaultUI(),o=n.querySelector("#dvs-canvas-container".concat(i)),a=n.querySelector("#dvs-scroller-and-canvas".concat(i)),s=n.querySelector("#dvs-scroll-container".concat(i)),u=n.querySelector("#dvs-scroll-content".concat(i));if(this.canvasAndScrollContainer=a,this.scrollContainer=s,this.scrollContent=u,this.canvasContainer=o,this.defaultDom=n,o&&s){var l=this.context.getBorderWidth(r.viewerStyle);LA(o.style,{left:"".concat(l,"px"),top:"".concat(l,"px")}),LA(s.style,r.viewerStyle);}this.scrollContainer.addEventListener("scroll",function(t){e.hooks.scroll.emit(t);});}},{key:"createDefaultUI",value:function value(){var e=this.context,t=e.postfix;return e.config.pure?Gj(mF,t):Gj(gF,t);}},{key:"updateScrollContentSize",value:function value(e,t){this.scrollContent.style.width="".concat(e,"px"),this.scrollContent.style.height="".concat(t,"px");}},{key:"resizeViewport",value:function value(){var e=this.scrollContainer,t=e.clientWidth,i=e.clientHeight;return this.viewerWidth=e.offsetWidth,this.viewerHeight=e.offsetHeight,LA(this.canvasContainer.style,{width:"".concat(t,"px"),height:"".concat(i,"px")}),{width:t,height:i};}},{key:"getMaxScrollValue",value:function value(){var e=this.scrollContainer;return{maxScrollLeft:e.scrollWidth-e.clientWidth,maxScrollTop:e.scrollHeight-e.clientHeight};}},{key:"isViewerResized",value:function value(){return this.scrollContainer.offsetWidth!==this.viewerWidth||this.scrollContainer.offsetHeight!==this.viewerHeight;}},{key:"isDPRChanged",value:function value(){var e=gN();return this.dpr!==e&&(this.dpr=e,!0);}},{key:"isScrollbarAppeared",value:function value(){return this.scrollContent.offsetWidth>this.scrollContainer.clientWidth||this.scrollContent.offsetHeight>this.scrollContainer.clientHeight;}},{key:"getViewportSize",value:function value(){return{width:this.scrollContainer.clientWidth,height:this.scrollContainer.clientHeight};}},{key:"bindContainer",value:function value(e){if(!e)return!1;var t=e;return e&&TL(e)&&(t=document.querySelector("#".concat(e))),t.appendChild(this.defaultDom),this.container=t,this.rootDom=this.defaultDom,this.isBindContainer=!0,this.context.resize(),!0;}},{key:"unbindContainer",value:function value(){if(0===this.container.children.length)return!1;for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:"",i=e.tag,r=e.style,n=e.id,o=e.className,a=e.children,s=document.createElement(i);return n&&(s.id=n+t),o&&(s.className=o),LA(s.style,r||{}),a&&$k(a).call(a,function(e){var i=Gj(e,t);s.appendChild(i);}),s;}var Kj=function(){return Yk(function e(t){Xk(this,e),Wk(this,"context",void 0),Wk(this,"zoomOriginCache",void 0),this.context=t;},[{key:"zoomTo",value:function value(e,t,i){var r;if((e=HL(e,this.context.config.minZoom,this.context.config.maxZoom))===this.context.config.zoom)return!1;var n=this.formatZoomOrigin(t,i);this.updateZoomReferencePoint(n),this.context.config.fitType="none",this.context.config.zoom=e;var o=null===(r=this.context)||void 0===r?void 0:r.getCurrentTab();if(o){var a;if(o.layoutStatus.zoom=e,o.fitType="none","multiple"===this.context.config.displayMode)return!1;this.context.layoutService.layout(o),n=this.formatZoomOrigin(t,i);var s=this.alignZoomReferencePoint(n),u=s.scrollLeft,l=s.scrollTop;return o.updateLayoutStatus({scrollLeft:u,scrollTop:l}),this.context.uiService.scrollTo(u,l),this.context.scrollerService.updateScroller({scrollLeft:u,scrollTop:l}),$k(a=o.childNodes).call(a,function(e){e.clearOptimization();}),this.context.rendererService.render(),!0;}return!1;}},{key:"formatZoomOrigin",value:function value(e,t){var i=this.context.rendererService.canvasDom.getBoundingClientRect(),r=i.width,n=i.height;if(CL(e)||CL(t)){var o=this.context.config.zoomOrigin,a=.5,s=.5;"left"===o.x?a=0:"right"===o.x&&(a=1),"top"===o.y?s=0:"bottom"===o.y&&(s=1),e=r*a,t=n*s;}return{originX:e=HL(e,0,r),originY:t=HL(t,0,n)};}},{key:"updateZoomReferencePoint",value:function value(e){var t,i,r,n,o=this,a=e.originX,s=e.originY,u=null,l=this.context.getPointerOverPageInfo(a,s).pageInfo.obj;if(l){var c=l.imageContainer.getPosition();r=(a-c.x)/this.context.config.zoom,n=(s-c.y)/this.context.config.zoom,t="center",i="center",u=l.uid;}else{var h,d,f=null===(h=this.context)||void 0===h?void 0:h.getCurrentTab(),v=Number.MAX_VALUE;null==f||$k(d=f.children).call(d,function(e){if(e.isVisible){var l=e.imageContainer.getPosition(),c=e.imageContainer,h=c.width,d=c.height,f=new IN(l.x+h/2,l.y+d/2).distanceTo({x:a,y:s});fl.x+h?(t="end",r=a-(l.x+h)):(t="center",r=(a-l.x)/o.context.config.zoom),sl.y+d?(i="end",n=s-(l.y+d)):(i="center",n=(s-l.y)/o.context.config.zoom));}});}this.zoomOriginCache={imageX:r,imageY:n,positionX:t,positionY:i,pageUid:u};}},{key:"alignZoomReferencePoint",value:function value(e){var t,i=e.originX,r=e.originY,n=0,o=0,a=this.zoomOriginCache,s=a.imageX,u=a.imageY,l=a.positionX,c=a.positionY,h=a.pageUid,d=null===(t=this.context)||void 0===t?void 0:t.getCurrentTab();if(d){var f=d.getChildByUid(h);if(f){var v,g,m=f.imageContainer.getPosition();"start"===l?v=m.x-s:"center"===l?v=m.x+s*this.context.config.zoom:"end"===l&&(v=m.x+f.imageContainer.width+s),"start"===c?g=m.y-u:"center"===c?g=m.y+u*this.context.config.zoom:"end"===c&&(g=m.y+f.imageContainer.height+u),n=v-i,o=g-r;}}var y=this.context.uiService.scrollContainer,p=y.scrollLeft,w=y.scrollTop,b=this.context.uiService.getMaxScrollValue(),k=b.maxScrollLeft,S=b.maxScrollTop;return w+=o,{scrollLeft:p=HL(p+=n,0,k),scrollTop:w=HL(w,0,S)};}}]);}(),$j=function(){return Yk(function e(t,i){Xk(this,e),Wk(this,"viewerUid",void 0),Wk(this,"postfix",void 0),Wk(this,"groupUid",void 0),Wk(this,"emitter",void 0),Wk(this,"viewer",void 0),Wk(this,"config",_SL(yF)),Wk(this,"dvsContext",void 0),Wk(this,"boxRenderer",void 0),Wk(this,"configService",void 0),Wk(this,"hooksService",void 0),Wk(this,"layoutService",void 0),Wk(this,"rendererService",void 0),Wk(this,"scrollerService",void 0),Wk(this,"tabService",void 0),Wk(this,"uiService",void 0),Wk(this,"zoomService",void 0),Wk(this,"isFocus",!1),Wk(this,"defaultWidth",600),Wk(this,"defaultHeight",800),Wk(this,"isDestroyed",!1),Wk(this,"iListeners",[]),Wk(this,"draggingPrepared",!1),Wk(this,"showOutline",!1),this.viewer=t,this.configService=new Fj(this),this.hooksService=new jj(this),this.layoutService=new Yj(this),this.rendererService=new Xj(this),this.scrollerService=new qj(this),this.tabService=new Zj(this),this.uiService=new _j(this),this.zoomService=new Kj(this),this.viewerUid=WL(),this.groupUid=i.groupUid,NL(i.viewerConfig||{},this.config),this.emitter=i.emitter,this.postfix="-".concat(this.viewerUid),this.dvsContext=i.dvsContext,this.uiService.initDefaultUI(),this.initPlugins(),i.container&&this.uiService.bindContainer(i.container),this.config.show||(this.uiService.rootDom?this.uiService.rootDom.style.display="none":this.uiService.defaultDom.style.display="none");},[{key:"initPlugins",value:function value(){var e=this;new SF().init(this),new HF().init(this),new FF().init(this),new CF().init(this),new jF().init(this),new pF().init(this),$k(Jj).call(Jj,function(t){return t.init(e);});}},{key:"setDisableFocusOutline",value:function value(e){var t,i;this.showOutline=!e;var r=null==this||null===(t=this.rendererService)||void 0===t?void 0:t.canvasDom,n=null==this||null===(i=this.uiService)||void 0===i?void 0:i.scrollContainer;e?(n.classList.add("dvs-disable-outline"),r.classList.add("dvs-disable-outline")):(n.classList.remove("dvs-disable-outline"),r.classList.remove("dvs-disable-outline"));}},{key:"clearCurTabOptimization",value:function value(){var e,t=this.getCurrentTab();t&&$k(e=t.children).call(e,function(e){e.clearOptimization();});}},{key:"updateViewerConfig",value:function value(e){this.configService.updateConfig(e);}},{key:"setViewMode",value:function value(e,t){var i;if(!BL(t)||!BL(e))return this.err(fL),!1;if(e<=0||t<=0)return this.err(vL),!1;var r=this.config.rows!==e||this.config.columns!==t;this.config.rows=e,this.config.columns=t;var n=this.getCurrentTab();return n&&(n.row=e,n.column=t,this.resetScrollbarStatus(),$k(i=n.children).call(i,function(e){e.clearOptimization();}),this.render(),r&&this.emitCurrentIndexChanged()),this.ok(),!0;}},{key:"syncFromViewer",value:function value(e){var t=this,i=e.context.tabService.getAllTabs(),r=e.context.tabService.getCurrentTab();$k(i).call(i,function(e){var i,n,o=t.tabService.createTab(e.doc);o.current=e.current,o.select(RI(i=e.selected).call(i)),$k(n=e.children).call(n,function(e,t){if(e.blanks.children.length){var i,r=o.childNodes[t];$k(i=e.blanks.children).call(i,function(e){var t=new WW({id:e.id,style:{points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],background:e.style.background,borderWidth:0}});r.blanks.appendChild(t);});}if(e.overlays.children.length){var n,a=o.children[t];$k(n=e.overlays.children).call(n,function(e){var t,i=new WW({id:e.id,style:{points:RI(t=e.style.points).call(t),background:e.style.background,borderWidth:0,opacity:e.style.opacity}});a.overlays.appendChild(i);});}}),r.uid===o.uid&&t.showTab(o);});}},{key:"getStatus",value:function value(e){return this.dvsContext.spaceService.getStatus(e);}},{key:"getGlobalHooks",value:function value(){return this.dvsContext.hooksService.hooks;}},{key:"getLocalHooks",value:function value(){return this.hooksService.hooks;}},{key:"getCurrentTab",value:function value(){return this.tabService.getCurrentTab();}},{key:"getTab",value:function value(e){return this.tabService.getTab(e);}},{key:"getAllTabs",value:function value(){return this.tabService.getAllTabs();}},{key:"showTab",value:function value(e){var t,i,r=this;this.tabService.tabManager.setCurrentTab(e.uid),e.style.visibility="visible",this.config.show&&(0===e.total&&(this.resetScrollbarStatus(),this.resetScrollerSize(),this.resize()),this.layoutService.layout(e),0!==e.layoutStatus.viewWidth&&0!==e.layoutStatus.viewHeight&&(0===e.selected.length&&"single"===this.config.displayMode&&($k(t=e.children).call(t,function(e){e.updateStyle({visibility:"hidden"});}),this.resetScrollbarStatus(),this.resetScrollerSize(),this.resize()),$k(i=e.children).call(i,function(e){e.isPreload&&!e.isLoaded&&("multiple"===r.config.displayMode&&r.config.useMinImage?r.dvsContext.minImageService.load(e.uid):r.dvsContext.imageService.load(e.uid));}),this.hooksService.hooks.pageChanged.emit({current:e.current,total:e.total})));}},{key:"emitCurrentIndexChanged",value:function value(){var e=this.tabService.getCurrentTab();if(e&&(this.layoutService.layout(e),e.currentPage)){var t={isPassive:!1,trigger:this.viewerUid,docUid:""};this.hooksService.hooks.currentIndexChanged.emit(t);}}},{key:"resize",value:function value(){this.rendererService.resetCanvasSize();var e=this.uiService.resizeViewport(),t=e.width,i=e.height,r=gN();this.rendererService.canvas.setDPR(r),this.rendererService.canvas.resize(t,i),this.tabService.setViewportSize(t,i),this.scrollerService.updateScroller({viewportWidth:t,viewportHeight:i});}},{key:"resized",value:function value(){this.uiService.isBindContainer&&this.config.show&&(this.resetScrollbarStatus(),this.resize(),this.hooksService.hooks.resize.emit(),this.emitCurrentIndexChanged(),this.clearCurTabOptimization(),this.rendererService.render(),this.handleOrigin(),this.emit("resize",this.viewer.width,this.viewer.height));}},{key:"externalResized",value:function value(){if((this.uiService.isViewerResized()||this.uiService.isDPRChanged())&&this.uiService.isBindContainer&&this.config.show){this.resetScrollbarStatus(),this.resetScrollerSize(),this.resize(),this.hooksService.hooks.externalResized.emit(),this.emitCurrentIndexChanged();var e=this.getCurrentTab();e&&(this.layoutService.layout(e),this.clearCurTabOptimization()),this.rendererService.render(),this.handleOrigin(),this.emit("resize",this.viewer.width,this.viewer.height);}}},{key:"handleOrigin",value:function value(){if("single"===this.config.displayMode){var e=this.uiService.getMaxScrollValue(),t=e.maxScrollLeft,i=e.maxScrollTop,r=this.config.zoomOrigin,n=r.x,o=r.y,a=t/2,s=i/2;"left"===n?a=0:"right"===n&&(a=t),"top"===o?s=0:"bottom"===o&&(s=i),this.uiService.scrollTo(a,s);}}},{key:"getScrollbarWidth",value:function value(){var e,t=document.createElement("div"),i=document.createElement("div");if(t.appendChild(i),t.style.width="60px",t.style.height="60px",t.style.position="absolute",t.style.overflow="auto",i.style.width="100px",i.style.height="100px",null===(e=document)||void 0===e||!e.body)return 0;document.body.appendChild(t);var r=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),r;}},{key:"selectPage",value:function value(e){this.tabService.selectPage(e),this.dvsContext.hooksService.hooks.selectPage.emit(e);}},{key:"getCanvasDpr",value:function value(){return this.rendererService.canvas.contextService.getDPR();}},{key:"optimizePage",value:function value(e){var t=this;if(this.config.enableOptimizeImage){var i=this.tabService.getCurrentTab();if(i){var r=i.getChildByUid(e);if(r){var n;if(r.isOptimized||!r.isVisible||!r.isLoaded||r.optimizationUid===r.optimizedUid||this.scrollerService.isSliding||this.isDestroyed)return;var o=this.getStatus(e);if(!(null!=o&&o.img||null!=o&&o.minImg))return;var a=r.image.style.img,s=a.naturalWidth,u=a.naturalHeight,l=s,c=u,h=this.config.maxOptimizationSize;if(l>h||c>h||r.realTimeWidth>h||r.realTimeHeight>h)return;var d=[],f=[];if(this.dvsContext.editService){var v={operations:o.operations,width:s,height:u};"multiple"===this.config.displayMode&&this.config.useMinImage&&(v.operations=this.dvsContext.editService.toMinImageOperations(o.operations,o.imageScale));var g=this.dvsContext.editService.handle(v);l=g.width,c=g.height,d=g.matrixes,f=g.blanks||[];}var m=new LW({style:{x:0,y:0,img:a,width:s,height:u}});m.externalMatrixes=d;var y="rgba(0,0,0,0)";if("multiple"===this.config.displayMode){var p=this.config.pageStyle;r.isSelected?p=this.config.selectedPageStyle:r.isHovered&&(p=this.config.hoveredPageStyle),y=p.background;}o.useFillColor&&(y=this.config.blankFillColor);var w=new UW({style:{x:0,y:0,width:l,height:c,background:y}}),b=new UW();$k(f).call(f,function(e){var t=new WW({id:e.uid,style:{background:e.background,points:e.points,borderWidth:0}});b.appendChild(t);}),m.appendChild(b),w.appendChild(m);var k=new UW();$k(n=r.overlays.children).call(n,function(e){var t,i=new WW({id:e.id,style:{points:RI(t=e.style.points).call(t),background:e.style.background,borderWidth:0,opacity:e.style.opacity}});k.appendChild(i);}),w.appendChild(k),this.dvsContext.commonCanvas.render(w),this.dvsContext.commonCanvas.clear();var S=this.dvsContext.commonCanvas.getCanvas(),x=gN(),C=Math.floor(r.imageContainer.width*x-1),V=Math.floor(r.imageContainer.height*x-1);r.isOptimized=!0,this.dvsContext.optimizationService.optimize(S,l,c,C,V,r.optimizationUid).then(function(e){if(!t.isDestroyed&&e.taskUid===r.optimizationUid){r.isOptimized=!0,r.optimizedUid=r.optimizationUid;var i=S.getContext("2d",{willReadFrequently:!0}).createImageData(C,V);i.data.set(e.target),r.imageContainer.imageData=i,r.isVisible&&t.render();}}).catch(function(e){r.isOptimized=!1;});}}}}},{key:"renderPage",value:function value(e){if(!(this.isDestroyed||this.config.useMinImage&&"multiple"===this.config.displayMode)){var t=this.tabService.getCurrentTab();if(t){var i=t.getChildByUid(e);if(i){var r=this.dvsContext.spaceService.getStatus(e);r&&(r.img&&(i.isLoaded=!0,i.updateImage(r.img)),i.isVisible&&(this.render(),this.handleOrigin()));}}}}},{key:"renderMinPage",value:function value(e){if(!this.isDestroyed&&this.config.useMinImage&&"multiple"===this.config.displayMode){var t=this.tabService.getCurrentTab();if(t){var i=t.getChildByUid(e);if(i){var r=this.dvsContext.spaceService.getStatus(e);r&&(r.minImg&&(i.isLoaded=!0,i.updateImage(r.minImg)),i.isVisible&&(this.render(),this.handleOrigin()));}}}}},{key:"renderOnly",value:function value(){this.rendererService.render();}},{key:"render",value:function value(){if(!this.config.show)return!1;if(this.isDestroyed)return!1;var e=this.tabService.getCurrentTab();if(e){var t;this.layoutService.layout(e),0===e.selected.length&&"single"===this.config.displayMode&&($k(t=e.children).call(t,function(e){e.updateStyle({visibility:"hidden"});}),this.resetScrollbarStatus(),this.resetScrollerSize(),this.resize()),this.config.zoom=e.layoutStatus.zoom;var i=this.uiService.scrollContainer,r=i.scrollLeft,n=i.scrollTop;e.setPosition({x:-r,y:-n}),e.updateLayoutStatus({scrollLeft:r,scrollTop:n}),this.scrollerService.updateScroller({scrollLeft:r,scrollTop:n});}return this.rendererService.render(),this.ok(),!0;}},{key:"tabCleared",value:function value(){this.tabService.tabManager.clear(),this.uiService.updateScrollContentSize(0,0),this.scrollerService.updateScroller({contentWidth:0,contentHeight:0}),this.render();}},{key:"storeActionToStatus",value:function value(e){var t,i=this;$k(t=(e=_SL(e)).uids).call(t,function(t){var r=i.getStatus(t);if(r){var n=r.operations[r.operations.length-1];n&&n.type===e.actionType||(n={type:e.actionType,detail:[]},r.operations.push(n)),n.detail.push(e);}});}},{key:"removeActionFromStatus",value:function value(e){var t,i=this;$k(t=e.uids).call(t,function(t){var r=i.getStatus(t);if(r){var n=r.operations[r.operations.length-1];if(n&&n.type===e.actionType&&(n.detail.pop(),!n.detail.length)){var o,a,s=OI(o=r.operations).call(o,n);s>-1&&gE(a=r.operations).call(a,s,1);}}});}},{key:"isEmpty",value:function value(){var e=this.getCurrentTab();return!e||0===e.children.length;}},{key:"resetScrollbarStatus",value:function value(){var e,t=this;$k(e=this.getAllTabs()).call(e,function(e){e.layoutStatus.scrollbarWidth=t.getScrollbarWidth(),e.layoutStatus.resetScrollbarStatus();});}},{key:"resetScrollerSize",value:function value(){var e=this.uiService.scrollContainer;this.rendererService.canvasDom.style.width="0px",this.rendererService.canvasDom.style.height="0px",this.uiService.canvasContainer.style.width="0px",this.uiService.canvasContainer.style.height="0px",this.uiService.scrollContent.style.width="0px",this.uiService.scrollContent.style.height="0px";var t=e.clientWidth,i=e.clientHeight;LA(this.uiService.canvasContainer.style,{width:"".concat(t,"px"),height:"".concat(i,"px")});}},{key:"setScrollbarWidth",value:function value(e){var t;$k(t=this.tabService.tabManager.tabs).call(t,function(t){t.scrollbarWidth=e;});}},{key:"getPointerOverPageInfo",value:function value(e,t){var i=function(e,t,i){var r={pageInfo:{isOver:!1,pointerX:-1,pointerY:-1,obj:null,pagePositionX:-1,pagePositionY:-1,pageWidth:-1,pageHeight:-1},imageInfo:{isOver:!1,pointerX:-1,pointerY:-1,obj:null},index:-1};if(e)for(var n=0;n=a+h&&t>=s+d&&e<=a+h+u&&t<=s+d+l)return r;}}return-1;}},{key:"getCanvasPosition",value:function value(){return this.rendererService.getCanvasPosition();}},{key:"getBorderWidth",value:function value(e){var t=e.border;if(!t)return 0;var i=t.match(/[0-9]+/g)[0];return $S(i||"0",10);}},{key:"isBorderWidthEqualHovered",value:function value(){return this.getBorderWidth(this.config.pageStyle)===this.getBorderWidth(this.config.hoveredPageStyle);}},{key:"isSelectedBorderWidthEqualHovered",value:function value(){return this.getBorderWidth(this.config.selectedPageStyle)===this.getBorderWidth(this.config.hoveredPageStyle);}},{key:"isSelectedBorderWidthEqualNormal",value:function value(){return this.getBorderWidth(this.config.pageStyle)===this.getBorderWidth(this.config.selectedPageStyle);}},{key:"formatTouches",value:function value(e){var t,i=[];t=e instanceof MouseEvent||e instanceof PointerEvent?[e]:arguments.length>1&&void 0!==arguments[1]&&arguments[1]?e.changedTouches:e.touches;for(var r=this.rendererService.getCanvasPosition(),n=r.x,o=r.y,a=0;a1?r-1:0),o=1;ot.total-1||e<0)return-1;if(i===e&&t.selected.length<=1)return i;var r={index:e,docUid:t.uid,trigger:this.uid,groupUid:this.groupUid,operation:"shift"};return this.context.getLocalHooks().changePage.emit(r),t.current;}},{key:"getCurrentIndex",value:function value(){var e=this.getCurrentTab();return e?(this.err(dL),e.current):(this.err(gL),-1);}},{key:"setCurrentIndex",value:function value(e){return-1!==this.gotoPage(e);}},{key:"setSelectedIndexes",value:function value(e){if(!bL(e))return this.err(fL),!1;var t=this.getCurrentTab();if(!t)return!1;var i=t.selected,r=!1;i.length!==e.length&&(r=!0);for(var n=[],o=0;o-1?this.ok():this.err(mL),i;}},{key:"getUidByIndex",value:function value(e){var t=this.getCurrentTab();return t?this.isIndexValid(t,e)?(this.ok(),t.children[e].uid):null:(this.err(gL),null);}},{key:"undo",value:function value(){var e=this.getCurrentTab();if(e){var t=e.commandController.undoStack,i=t[t.length-1];if(i){var r,n={commandUid:i.uid,trigger:this.uid};return $k(r=i.action.uids).call(r,function(t){var i=e.getChildByUid(t);i&&i.clearOptimization();}),this.context.getGlobalHooks().undo.emit(n),!0;}}return!1;}},{key:"redo",value:function value(){var e=this.getCurrentTab();if(e){var t=e.commandController.redoStack,i=t[t.length-1];if(i){var r,n={commandUid:i.uid,trigger:this.uid};return $k(r=i.action.uids).call(r,function(t){var i=e.getChildByUid(t);i&&i.clearOptimization();}),this.context.storeActionToStatus(i.action),this.context.getGlobalHooks().redo.emit(n),!0;}}return!1;}},{key:"reset",value:function value(e){var t=this;if(!vF(this,e=fF(this,e)))return!1;var i=this.getCurrentTab(),r=$E(e).call(e,function(e){return i.getChildByIndex(e).uid;}),n={tabUid:i.uid,tabType:i.type,trigger:this.uid,uids:r};return $k(r).call(r,function(e){var r=t.context.getStatus(e);r&&(r.operations=[]);var n=i.getChildByUid(e);n&&n.clearOptimization();}),this.context.getGlobalHooks().reset.emit(n),!0;}},{key:"zoomIn",value:function value(){var e=this.getViewerConfigByName("zoom");this.updateViewerConfig({zoom:1.2*e});}},{key:"zoomOut",value:function value(){var e=this.getViewerConfigByName("zoom");this.updateViewerConfig({zoom:e/1.2});}},{key:"render",value:function value(){return this.context.render();}},{key:"on",value:function value(e,t){this.context.on(e,t);}},{key:"emit",value:function value(e){for(var t,i,r=arguments.length,n=new Array(r>1?r-1:0),o=1;o=e.total)||(this.err(vL),!1):(this.err(fL),!1);}},{key:"destroy",value:function value(){this.destroyFlag||(this.context.destroy(),this.context=null,this.destroyFlag=!0);}}],[{key:"use",value:function value(e){OI(Jj).call(Jj,e)<0&&Jj.push(e);}}]);}(),eY={Viewer:Qj},tY=function(){return Yk(function e(t,i){Xk(this,e),Wk(this,"dvs",void 0),Wk(this,"errorService",void 0),Wk(this,"hooksService",void 0),Wk(this,"imageService",void 0),Wk(this,"minImageService",void 0),Wk(this,"layoutService",void 0),Wk(this,"spaceService",void 0),Wk(this,"trackerService",void 0),Wk(this,"viewerService",void 0),Wk(this,"saveService",void 0),Wk(this,"workerService",void 0),Wk(this,"commonCanvas",void 0),Wk(this,"optimizationService",void 0),this.dvs=t,this.errorService=new QH(this),this.hooksService=new eF(this),this.imageService=new tF(this),this.minImageService=new rF(this),this.layoutService=new iF(this),this.spaceService=new oF(this,i),this.trackerService=new sF(this),this.viewerService=new uF(this),this.saveService=new nF(this),this.workerService=new lF(this),this.commonCanvas=new PH(),this.optimizationService=new cF(this);},[{key:"destroy",value:function value(){this.imageService.destroy(),this.minImageService.destroy();}},{key:"getSpace",value:function value(){return this.spaceService.space;}}]);}(),iY=[],rY=function(){return Yk(function e(t){Xk(this,e),Wk(this,"uid",void 0),Wk(this,"emitter",void 0),Wk(this,"subClasses",void 0),Wk(this,"isDestroyed",!1),Wk(this,"options",void 0),Wk(this,"context",void 0),this.uid=WL(),this.subClasses=eY,this.emitter=bN.create(),this.options=t,this.context=new tY(this,t.space),this.init(),nH(["borderWidth","letterSpacing","lineDashOffset","shadowOffsetX","shadowOffsetY","shadowBlur","textMaxWidth"],HO,void 0),nH(["startAngle","endAngle"],jO,void 0),nH(["r","rx","ry","width","height","padding","fontSize","arrowWidth","markSize","markLineWidth"],HO,void 0),nH(["borderColor","background","shadowColor","color"],_O,void 0),nH(["opacity","fillOpacity","borderOpacity"],$O,void 0),rH("lineDash",KO,void 0),rH("shadow",GO,void 0),nH(["x","y"],void 0,JO),nH(["points"],void 0,JW),nH(["x1","y1","x2","y2"],void 0,$W),nH(["startPoint","endPoint"],void 0,tH),nH(["lineEnding"],void 0,iH),nH(["fontStyle","fontVariant","fontWeight","fontFamily","fontSize"],void 0,QW),nH(["x","y","width","wordWarp","lineHeight","text","textTransform","textBaseLine"],void 0,KW),nH(["width","height"],void 0,eH);},[{key:"init",value:function value(){var e=this;new $H().apply(this.context),new JH().apply(this.context),this.emitter.save(),$k(iY).call(iY,function(t){var i,r=t.plugin,n=t.config;!ML(r)&&ML(r.init)&&r.init.apply(r,lS(i=[e]).call(i,Kb(n)));}),this.context.hooksService.hooks.init.emit(),this.emitter.restore();}},{key:"setSpace",value:function value(e){e!==this.context.spaceService.space&&(this.context.hooksService.hooks.beforeSetSpace.emit(e),this.context.spaceService.setSpace(e),this.context.hooksService.hooks.afterSetSpace.emit(e));}},{key:"getImageData",value:function value(e,t){return this.context.saveService.getImageData(e,t);}},{key:"destroy",value:function value(){var e;this.isDestroyed||(this.context.hooksService.hooks.destroy.emit(),this.context.destroy(),null!==(e=this.emitter)&&void 0!==e&&e.destroy(),this.emitter=null,this.subClasses=null,this.isDestroyed=!0);}},{key:"removeSource",value:function value(e){return this.context.spaceService.space.removeSource(e);}},{key:"loadSource",value:function value(e){return this.context.spaceService.space.loadSource(e);}},{key:"updateSource",value:function value(e,t){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return this.context.spaceService.space.updateSource(e,t,i);}},{key:"createViewer",value:function value(e){return this.context.viewerService.createViewer(e);}},{key:"removeViewer",value:function value(e){return this.context.viewerService.removeViewer(e);}},{key:"getViewerByUid",value:function value(e){return this.context.viewerService.getViewer(e);}},{key:"getViewerByIndex",value:function value(e){return this.context.viewerService.viewerManager.getAllViewers()[e];}},{key:"getViewerList",value:function value(){var e;return RI(e=this.context.viewerService.viewerManager.getAllViewers()).call(e);}}],[{key:"use",value:function value(e){for(var t,i,r,n=arguments.length,o=new Array(n>1?n-1:0),a=1;a-1?(console.error("The plugin ".concat(e.name," is already installed.")),this):("function"==typeof e?e.apply(void 0,lS(i=[this]).call(i,o)):"function"==typeof e.install&&e.install.apply(e,lS(r=[this]).call(r,o)),iY.push({plugin:e,config:o}),this);}},{key:"useAll",value:function value(e){var t=this;return $k(e).call(e,function(e){if(bL(e)){var i,r=ph(a=e)||wd(a)||Kd(a)||$d(),n=r[0],o=RI(r).call(r,1);t.use.apply(t,lS(i=[n]).call(i,Kb(o)));}else t.use(e);var a;}),this;}},{key:"getClassStore",value:function value(){return eY;}},{key:"getPlugins",value:function value(){return iY;}}]);}(),nY={sequence:-1,location:"horizontal",size:180,thumbnailStyle:{},canvasStyle:{border:"1px solid #2a2a2a"},pageStyle:{},selectedPageStyle:{},placeholderStyle:{},hoveredPageStyle:{},pageNumberStyle:{},checkboxStyle:{},removeBtnStyle:{},enableDragPage:!0,enableKeyboardControl:!0,multiselectMode:!1,scrollDirection:"vertical",rows:4,columns:1,show:!0,enableResizing:!0,autoChangeIndex:!0,gap:10,margin:10,autoSelectTopPage:!1,autoScroll:!0,autoSelectLatest:!0},oY={enableOptimizeImage:!1,enableZoom:!1,displayMode:"multiple",toolType:"default",rows:4,columns:1,pure:!0,tabMode:"single"},aY=function(){return Yk(function e(t){Xk(this,e),Wk(this,"uid",void 0),Wk(this,"emitter",void 0),Wk(this,"thbConfig",{}),Wk(this,"innerViewer",void 0),Wk(this,"viewer",void 0),Wk(this,"postfix",void 0),Wk(this,"container",void 0),Wk(this,"hooks",{destroy:SN.create()}),Wk(this,"configHandlers",{}),Wk(this,"isDestroyed",!1);var i=bN.create();this.emitter=i,this.viewer=t.viewer,NL(oY,this.thbConfig),NL(nY,this.thbConfig),NL(t.viewerConfig||{},this.thbConfig),this.initThbConfigHandlers(),this.innerViewer=new this.viewer.OriginalViewer(Fk(Fk({},t),{},{emitter:i,viewerConfig:Fk(Fk({},this.thbConfig),{},{viewerStyle:Fk({},this.thbConfig.thumbnailStyle)}),groupUid:this.viewer.groupUid,dvsContext:t.viewer.context.dvsContext})),this.uid=this.innerViewer.uid,this.postfix=this.innerViewer.context.postfix,this.listenViewerHooks(),t.container||this.updatePosition();},[{key:"listenViewerHooks",value:function value(){var e=this,t=this.viewer.context.hooksService.hooks,i=function i(){e.innerViewer&&e.innerViewer.context.resized();},r=function r(){e.innerViewer&&e.innerViewer.externalResized();},n=function n(t){e.innerViewer.context.hooksService.hooks.openDoc.emit(t);};t.resize.on(i),t.externalResized.on(r),t.openDoc.on(n),t.destroy.on(function(){e.destroy();}),this.hooks.destroy.on(function(){t.resize.off(i),t.externalResized.off(r),t.openDoc.off(n);});}},{key:"updatePosition",value:function value(){var e=null,t=this.innerViewer.context.uiService.defaultDom,i=this.viewer.context.uiService.defaultDom;"horizontal"===this.thbConfig.location?(t.style.width=sY(this.thbConfig.size),t.style.height="100%",e=i.querySelector("#dvs-viewer-middle".concat(this.viewer.context.postfix))):(t.style.width="100%",t.style.height=sY(this.thbConfig.size),e=i);var r=String(this.thbConfig.sequence);t.style.order=r,this.container=e,this.innerViewer.context.uiService.bindContainer(e),this.viewer.externalResized();}},{key:"getThbConfig",value:function value(){return this.thbConfig;}},{key:"getThbConfigByName",value:function value(e){return this.thbConfig[e];}},{key:"updateThbConfig",value:function value(e){for(var t=0,i=oB(e);t1?r-1:0),o=1;o0&&void 0!==arguments[0]?arguments[0]:{},t=new aY({container:e.container||"",viewerConfig:e,dvs:this.dvs,viewer:this});this.thumbnails.push(t);var i=this.context.getCurrentTab();if(i){var r,n,o=t.innerViewer.context,a=o.tabService.createTab(i.doc);a.current=i.current,a.select(RI(r=i.selected).call(r)),$k(n=i.children).call(n,function(e,t){if(e.blanks.children.length){var i,r=a.childNodes[t];$k(i=e.blanks.children).call(i,function(e){var t=new WW({id:e.id,style:{points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],background:e.style.background,borderWidth:0}});r.blanks.appendChild(t);});}if(e.overlays.children.length){var n,o=a.children[t];$k(n=e.overlays.children).call(n,function(e){var t,i=new WW({id:e.id,style:{points:RI(t=e.style.points).call(t),background:e.style.background,borderWidth:0,opacity:e.style.opacity}});o.overlays.appendChild(i);});}}),o.showTab(a),o.config.autoSelectLatest&&o.config.show?o.emitCurrentIndexChanged():o.renderOnly();}return e.container&&this.context.resized(),t;}},{key:"removeThumbnail",value:function value(e){var t,i,r,n;return TL(e)?r=EE(t=this.thumbnails).call(t,function(t){return t.uid===e;}):kL(e)&&(r=EE(i=this.thumbnails).call(i,function(t){return t===e;})),r>-1&&(Gb(gE(n=this.thumbnails).call(n,r,1),1)[0].destroy(),!0);}},{key:"getThumbnailList",value:function value(){return this.thumbnails;}},{key:"getThumbnailByIndex",value:function value(e){return this.thumbnails[e];}},{key:"getThumbnailByUid",value:function value(e){var t;return xP(t=this.thumbnails).call(t,function(t){return t.uid===e;});}},{key:"checkPageVisibility",value:function value(e){var t={min:!1,ori:!1},i=this.getCurrentTab();if(i){var r=i.getChildByUid(e);r&&r.isPreload&&("multiple"===this.context.config.displayMode&&(t.min=!0),t.ori=!0);}for(var n=0,o=this.thumbnails.length;n]*)>/,RY=/^<([^\s>]+)[^>]*>/,LY=/^.*<\/slot>/,NY=/(:?[@\w-]+)\s*=\s*"(.*?)"/;function OY(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=WY(e.template,e.data,e.components,e.injection,t),r=i.length;return r&&(i[0].cpInstance=e,i[r-1].cpInstance=e),i;}function WY(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],o=US(e).call(e),a=[];function s(e){o=o.substring(e);}function u(e){var n=Gb(e,2),o=n[0],s=n[1];if(s){var u=function(e){var t={},i=LL(e,NY);return i?($k(i).call(i,function(e){var i=Gb(e,3),r=i[1],n=i[2];t[r]=n;}),t):t;}(o),l=t[":for"];l&&(delete t[":for"],u[":for"]=l);var c={type:"start",name:s,data:t,attrs:u};if(a.push(c),(i[s]||r.components&&r.components[s])&&(c.cpOption={Component:i[s]||r.components[s],injection:r}),"input"===s||/\/>/.test(o)){var h={type:"end",name:s,data:t,attrs:{}};a.push(h);}}}function l(e){var t=Gb(e,2)[1];if(t){var i={type:"end",name:t,attrs:{}};a.push(i);}}function c(e){if(e=US(e).call(e)){var i={type:"text",name:e,attrs:{},data:t};a.push(i);}}for(;o;){var h=OI(o).call(o,"<"),d=void 0;if(0===h){var f=o.match(UY);if(f){s(f[0].length),l(f);continue;}var v=o.match(LY);if(v){s(v[0].length),a.push.apply(a,Kb(n));continue;}var g=o.match(RY);if(g&&g[0]!==g.input){s(g[0].length),u(g);continue;}d=o;}else d=h>0?o.substring(0,h):o;d&&(s(d.length),c(d));}return a;}function HY(e){var t=e.cpInstance;e.el;var i=e.children;t&&!t.isInserted&&(t.isInserted=!0,t.inserted&&t.inserted()),$k(i).call(i,function(e){HY(e);});}function FY(e,t){return t.key===e.key&&t.tagName===e.tagName;}function jY(e,t,i){for(var r={},n=t;n<=i;++n){var o=e[n];if(o&&o.data){var a=o.data.key;a&&(r[a]=n);}}return r;}function YY(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t<=i;)XY(e[t]),t+=1;}function XY(e){if(e){var t=e.el,i=e.children;if(function(e,t){var i=e.cpInstance;i&&(i.unbindSelfEvents(),i.unbindGlobalEvents(),i.unbindNativeEvents(),null===(t=i.beforeDestroyed)||void 0===t||t.call(i,e));}(e),t){var r=t.parentElement;r&&r.removeChild(t),t.dvsNode=null,e.el=null;}return function(e){var t=e.cpInstance;t&&t.destroyed&&t.destroyed(e);}(e),e.text=null,e.parent=null,i.length&&$k(i).call(i,function(e){XY(e);}),!0;}return!1;}function qY(e,t,i,r,n){for(var o=document.createDocumentFragment(),a=r;a<=n;a++){var s=i[a];o.appendChild(s.renderDom());}hN(o,t,e);}function ZY(e,t){var i,r,n,o;if(e!==t){if((null===(i=e.cpInstance)||void 0===i||null===(r=i.constructor)||void 0===r?void 0:r.name)!==(null===(n=t.cpInstance)||void 0===n||null===(o=n.constructor)||void 0===o?void 0:o.name))return qY(e.parent.el,e.el,[t],0,0),void XY(e);var a=e.el;e.data;var s=e.children,u=e.tagName,l=e.text;t.el=a,a.dvsNode=t;var c,h=t.data,d=t.children,f=t.tagName,v=t.text;if(a.setAttribute)$k(c=eS(h)).call(c,function(e){a instanceof HTMLInputElement&&"value"===e?a.value=h[e]:a.setAttribute(e,h[e]);});u===f&&"TEXT"===f&&l!==v?a.textContent=cN(v):s.length&&d.length?function(e,t,i){for(var r,n=0,o=0,a=t.length-1,s=i.length-1,u=t[n],l=t[a],c=i[o],h=i[s];n<=a&&o<=s;)if(null==u)u=t[n+=1];else if(null==l)l=t[a-=1];else if(null==c)c=i[o+=1];else if(null==h)h=i[s-=1];else if(FY(u,c))ZY(u,c),o+=1,u=t[n+=1],c=i[o];else if(FY(l,h))ZY(l,h),s-=1,l=t[a-=1],h=i[s];else if(FY(u,h))ZY(u,h),dN(u.el,l.el),s-=1,u=t[n+=1],h=i[s];else if(FY(l,c))ZY(l,c),hN(l.el,u.el,e),o+=1,l=t[a-=1],c=i[o];else{void 0===r&&(r=jY(t,n,a));var d=r[c.key];if(void 0===d)qY(e,u.el,i,o,o),c=i[o+=1];else{var f=t[d];ZY(f,c),hN(f.el,u.el,e),t[d]=null,c=i[o+=1];}}n>a?qY(e,i[s+1]?i[s+1].el:null,i,o,s):o>s&&YY(t,n,a);}(a,s,d):d.length?qY(a,null,d,0,d.length-1):s.length&&YY(s,0,s.length),function(e,t){var i=(e||{}).cpInstance,r=t.cpInstance;i&&(r&&(i.data=r.data,i.injection=Fk(Fk({},i.injection),r.injection)),t.cpInstance=i,i.dvsNode=t,i.updated&&i.updated(t));}(e,t);}}var _Y=function(){return Yk(function e(t){Xk(this,e),Wk(this,"el",void 0),Wk(this,"tagName",void 0),Wk(this,"sel",""),Wk(this,"data",void 0),Wk(this,"children",void 0),Wk(this,"text",void 0),Wk(this,"key",void 0),Wk(this,"cpInstance",void 0),Wk(this,"cpOptions",void 0),Wk(this,"inserted",!1),Wk(this,"parent",void 0),this.createVNode(t);},[{key:"renderDom",value:function value(){var e,t;if(this.el)return this.el;var i,r=this.cpInstance;if("FRAGMENT"===this.tagName)i=document.createDocumentFragment();else if("TEXT"===this.tagName){var n=cN(this.text);i=document.createTextNode(n);}else{var o;i=document.createElement("IMAGE"===this.tagName?"IMG":this.tagName);for(var a=0,s=oB(this.data);a-1&&(a.children[o]=t,t.parent=a,e.el=null),t;}(this,e);}},{key:"destroy",value:function value(){return XY(this);}},{key:"createVNode",value:function value(e){var t=e.tagName,i=e.data,r=void 0===i?{}:i,n=e.children,o=void 0===n?[]:n,a=e.el,s=void 0===a?null:a,u=e.key,l=e.text,c=void 0===l?"":l,h=e.cpOptions,d=e.cpInstance,f=t;r.id&&(f+="#".concat(r.id)),r.class&&(f+=".".concat(r.class)),this.sel=f,this.data=r,this.tagName=t,this.children=o,this.el=s,this.key=u,this.text=c,this.cpInstance=d,this.cpOptions=h;}}]);}();function GY(e){var t=e.split(";"),i={};return $k(t).call(t,function(e){var t,r=US(e).call(e);if(r){var n=$E(t=r.split(":")).call(t,function(e){return US(e).call(e);}),o=Gb(n,2),a=o[0],s=o[1],u=a.replace(/-(\w)/g,function(e,t){return t.toUpperCase();});i[u]=s;}}),i;}function KY(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=[],r=[],n=[];return $k(e).call(e,function(e){if("start"===e.type)i.push(e),r.push(n),n=[];else if("text"===e.type)n.push({type:"text",value:e.name,data:e.data});else if(e instanceof _Y)n.push(e);else{for(var t=i.pop();t.name!==e.name;)t=i.pop();if(t){var o=t,a=o.name,s=o.cpInstance,u=o.attrs,l={type:"token",tagName:a,cpInstance:s,cpOption:o.cpOption,attrs:u,data:o.data,children:n};$k(n).call(n,function(e){e.parent=l;}),(n=r.pop()).push(l);}}}),t?n[0]:n;}var $Y=/'.+'|\\".+\\"|[\w$.]+/g,JY=/{{([^\s@}]+)}}/;function QY(e,t){for(var i=function i(){var i=n[r],o=Gb(i.match(/^(:|@)(.+)/)||[],3),a=o[1],s=o[2];if(!s)return 1;var u=e[i];if(delete e[i],"for"===s){var l,c,h,d=Gb(u.split(" in "),2),f=d[0],v=d[1],g=Gb(f.split(","),2),m=g[0],y=g[1];m=US(m).call(m),y=null===(l=y)||void 0===l?void 0:US(l).call(l),v=null===(c=v)||void 0===c?void 0:US(c).call(c);var p=[],w=vx(h=v.split(".")).call(h,function(e,t){return e[t];},t);if(bL(w))$k(w).call(w,function(e,t){var i={};i[m]=e,y&&(i[y]=t),p.push(i);});else if(kL(w))for(var b=0,k=oB(w);b1&&void 0!==arguments[1]?arguments[1]:{};if(bL(e)){var i=[];return $k(e).call(e,function(e){i.push.apply(i,Kb(tX(eX(e))));}),i;}if(e instanceof _Y)return e;if("token"===e.type){var r,n,o=e.tagName,a=e.attrs,s=e.cpInstance,u=e.children,l=e.data,c=e.cpOption;if(a[":for"])return function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.attrs,n=e.data,o=JSON.parse(VR(r)),a={":for":r[":for"]};delete r[":for"],QY(a,Fk(Fk({},n),i));var s=[];return $k(t=a[":for"]).call(t,function(t){var i=eX(e,t);s.push.apply(s,Kb(tX(i)));}),e.attrs=o,s;}(e,t);var h,d=Fk(Fk({},l),t),f=Fk({},a);if(QY(a,d),Object.prototype.hasOwnProperty.call(a,"if")&&!a.if)h=null;else if(delete a.if,c)h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.children,r=e.attrs,n=e.cpOption,o=iX(i,t),a=KY(OY(new(0,n.Component)({data:r,injection:n.injection}),o));return a?tX(eX(a))[0]:null;}(e,t);else{var v=a.key;void 0!==v&&delete a.key;var g=iX(u,t);h=new _Y({tagName:o.toUpperCase(),data:a,cpInstance:s,key:v,children:g});}return e.attrs=f,null!==(r=h)&&void 0!==r&&$k(n=r.children).call(n,function(e){e.parent=h;}),h;}return function(e){var t,i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.value,o=null===(t=e.parent)||void 0===t||null===(i=t.attrs)||void 0===i?void 0:i.html;return n=function(e,t){var i=LL(e,JY);return i.length&&$k(i).call(i,function(i){var r,n=vx(r=i[1].split(".")).call(r,function(e,t){return e[t];},t),o=i[0];e=e.replace(o,n);}),e;}(US(n).call(n),Fk(Fk({},e.data),r)),o?eX(KY(WY(n),!1)):new _Y({tagName:"TEXT",text:n});}(e,t);}function tX(e){return e?(bL(e)||(e=[e]),e):[];}function iX(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=[];return $k(e).call(e,function(e){var r=eX(e,t)||[];i.push.apply(i,Kb(tX(r)));}),i;}var rX=function(){return Yk(function e(t){var i=t.data,r=void 0===i?{}:i,n=t.template,o=void 0===n?"":n,a=t.components,s=void 0===a?{}:a,u=t.injection,l=void 0===u?{}:u;Xk(this,e),Wk(this,"template",""),Wk(this,"data",{}),Wk(this,"components",{}),Wk(this,"injection",{}),Wk(this,"isInserted",!1),Wk(this,"emitter",void 0),Wk(this,"uiEmitter",void 0),Wk(this,"viewerEmitter",void 0),Wk(this,"dvsNode",null),Wk(this,"el",void 0),Wk(this,"created",void 0),Wk(this,"inserted",void 0),Wk(this,"updated",void 0),Wk(this,"beforeDestroyed",void 0),Wk(this,"destroyed",void 0),Wk(this,"selfEvents",[]),Wk(this,"globalEvents",[]),Wk(this,"nativeEvents",[]),this.emitter=bN.create(),this.setData(r),this.template=o,this.setComponents(s),this.setInjects(l),this.uiEmitter=this.injection.emitter,this.viewerEmitter=this.injection.viewerEmitter,this.autoBindEvents();},[{key:"parseHTML",value:function value(){return eX(KY(OY(this,[])));}},{key:"setData",value:function value(e){LA(this.data,e);}},{key:"setComponents",value:function value(e){LA(this.components,e);}},{key:"setInjects",value:function value(e){LA(this.injection,e);}},{key:"autoBindEvents",value:function value(){for(var e=this,t=function t(){var t=Gb(r[i],2),n=t[0],o=t[1];e.on(n,function(){o.apply(void 0,arguments);});},i=0,r=oB(this.data.events||{});i1?r-1:0),o=1;o1?r-1:0),o=1;o',components:e.getComponents(),injection:Fk(Fk({},this.injection),{},{components:e.getComponents(),postfix:this.postfix,emitter:this.emitter,viewerEmitter:this.viewerEmitter,stores:this.stores,i18n:this.options.uiConfig.i18n})}).parseHTML(),i=t.renderDom();this.rootVNode=t,this.rootDom=i,this.container&&(this.container.appendChild(i),HY(t),this.isInserted=!0);}},{key:"bindContainer",value:function value(e){this.container=e,e.appendChild(this.rootDom),this.isInserted||HY(this.rootVNode);}},{key:"unbindContainer",value:function value(){for(var e=0;e1?r-1:0),o=1;o0&&void 0!==arguments[0]?arguments[0]:{});t-1}),i.unsubscribe=i.store.subscribe(function(){var e=i.data.options.dataId,t=i.store.getState(),r=t.select,n=t.unselect;OI(r).call(r,e)>-1&&!i.data.isSelect?(i.data.isSelect=!0,i.reRenderVNode()):OI(n).call(n,e)>-1&&i.data.isSelect&&(i.data.isSelect=!1,i.reRenderVNode());});}return i.initTemplate(),i;}return _b(t,e),Yk(t,[{key:"initEvent",value:function value(){var e=this,t=this.data.options,i=t.events;if(t.selectable,i)for(var r=function r(){var t=Gb(o[n],2),i=t[0],r=t[1];e.el.addEventListener(i,function(t){e.uiEmitter.emit(r,t,e);});},n=0,o=oB(i);n")).call(e,CL(t.label)?"":t.label,"");}}]);}(rX);Wk(sX,"hasStore",!0),Wk(sX,"storeName","button"),Wk(sX,"reducer",function(e,t){var i,r,n,o;switch(e||(e={select:[],unselect:[]}),t.type){case"setButton":return $k(i=t.select).call(i,function(t){var i,r,n=EE(i=e.unselect).call(i,function(e){return e===t;});gE(r=e.unselect).call(r,n,1);}),$k(r=t.unselect).call(r,function(t){var i,r,n=EE(i=e.select).call(i,function(e){return e===t;});gE(r=e.select).call(r,n,1);}),e.select=Kb(new Pz(lS(n=[]).call(n,Kb(e.select),Kb(t.select)))),e.unselect=Kb(new Pz(lS(o=[]).call(o,Kb(e.unselect),Kb(t.unselect)))),Fk({},e);case"select":return Fk(Fk({},e),{},{select:t.select});case"unselect":return Fk(Fk({},e),{},{unselect:t.unselect});default:return e;}});var uX=function(e){function t(e){var i;return Xk(this,t),Wk(yb(i=cL(this,t,[e])),"startScroll",!1),Wk(yb(i),"allowScroll",!1),Wk(yb(i),"startInfo",void 0),Wk(yb(i),"created",function(e){i.el=e,i.allowScroll&&(i.addButtonScroll(),i.addResizeEvent());}),Wk(yb(i),"inserted",function(){i.updateShowMore();}),i.initTemplate(),i;}return _b(t,e),Yk(t,[{key:"initTemplate",value:function value(){var e=this.data.options;e.style,e.id,e.className;var t=e.children;this.injection;var i="
");t&&$k(t).call(t,function(e,t){var r,n,o=e.enable,a=e.type;!1!==o&&(US(a).call(a),i+=lS(r=lS(n="<".concat(a,' :options="options.children.')).call(n,t,'">"));}),i+="
",this.template=i;}},{key:"addButtonScroll",value:function value(){var e=this,t=this.el;t.onmousedown=function(i){return!(i.button&&0!==i.button||t.scrollWidth<=t.clientWidth&&t.scrollHeight<=t.clientHeight||(e.startScroll=!0,e.startInfo={x:i.clientX,y:i.clientY,left:t.scrollLeft,top:t.scrollTop},0));},t.onmousemove=function(i){if(!e.startScroll)return!1;var r=e.startInfo,n=r.x,o=r.y,a=r.left,s=r.top,u=i.clientX-n,l=i.clientY-o;return(Math.abs(u)>5||Math.abs(l)>5)&&(t.scrollLeft=a-u,t.scrollTop=s-l),e.updateShowMore(),!0;},this.nativeOn(document.body,"mouseup",function(){e.startScroll=!1;});var i=t.querySelector(".dvs-showBefore");i&&(i.onclick=function(){t.scrollLeft=0,e.updateShowMore();});var r=t.querySelector(".dvs-showAfter");r&&(r.onclick=function(){t.scrollLeft=t.scrollWidth,e.updateShowMore();});}},{key:"updateShowMore",value:function value(){var e=this.el,t=e.clientWidth,i=e.scrollWidth,r=e.scrollLeft,n=e.querySelector(".dvs-showBefore");n&&(n.classList[r>5&&t>40?"remove":"add"]("dvs-display-none"),n.style.transform="translate3d(".concat(r,"px,0,0)"));var o=e.querySelector(".dvs-showAfter");o&&(o.classList[r+t40?"remove":"add"]("dvs-display-none"),o.style.transform="translate3d(".concat(r,"px,0,0)"));}},{key:"addResizeEvent",value:function value(){var e=this;this.nativeOn(window,"resize",function(){e.updateShowMore();});}}]);}(rX),lX=function(e){function t(e){var i;return Xk(this,t),Wk(yb(i=cL(this,t,[e])),"created",function(e){i.el=e;}),Wk(yb(i),"inserted",function(){i.injection.viewer.context.uiService.bindContainer(i.el);}),i.initTemplate(),i;}return _b(t,e),Yk(t,[{key:"initTemplate",value:function value(){var e="
");this.template=e;}}]);}(rX);var cX=function(e){function t(e){var i;return Xk(this,t),Wk(yb(i=cL(this,t,[e])),"current",0),Wk(yb(i),"total",0),Wk(yb(i),"store",void 0),Wk(yb(i),"unsubscribe",void 0),Wk(yb(i),"prefix","dvs-pagination-"),Wk(yb(i),"created",function(e){i.el=e,i.updateStyle(),i.initEvent();}),Wk(yb(i),"updated",function(){i.updateStyle();}),Wk(yb(i),"destroyed",function(){var e,t;null===(e=(t=i).unsubscribe)||void 0===e||e.call(t);}),i.data.firstPage=aX(i.data.options.firstPage,{className:i.getClassName("first-page")}),i.data.prevPage=aX(i.data.options.prevPage,{className:i.getClassName("prev-page")}),i.data.nextPage=aX(i.data.options.nextPage,{className:i.getClassName("next-page")}),i.data.lastPage=aX(i.data.options.lastPage,{className:i.getClassName("last-page")}),i.data.gotoPage=e.gotoPage||{},i.data.total=e.total||{},i.data.separator=e.separator||{},i.store=i.injection.stores[t.storeName],i.unsubscribe=i.store.subscribe(function(){i.initDataFromStore(),i.reRenderVNode();}),i.initDataFromStore(),i.initTemplate(),i;}return _b(t,e),Yk(t,[{key:"getClassName",value:function value(e){var t,i,r=this.prefix;return lS(t=lS(i="".concat(r,"iconfont dvs-icon-")).call(i,e," ")).call(t,r+e);}},{key:"initDataFromStore",value:function value(){this.setData({pageDetails:Fk(Fk({},this.store.getState()),{},{current:this.store.getState().current+1})});}},{key:"updateStyle",value:function value(){if(this.el){var e=this.data.pageDetails,t=e.current,i=e.total,r=this.prefix,n=this.query(".".concat(r,"first-page")),o=this.query(".".concat(r,"prev-page")),a=this.query(".".concat(r,"next-page")),s=this.query(".".concat(r,"last-page"));1===t||0===i?(this.disable(n),this.disable(o)):(this.enable(n),this.enable(o)),t===i||0===i?(this.disable(a),this.disable(s)):(this.enable(a),this.enable(s));}}},{key:"disable",value:function value(e){var t="".concat(this.prefix,"disable");e.classList.contains(t)||e.classList.add(t);}},{key:"enable",value:function value(e){var t="".concat(this.prefix,"disable");e.classList.contains(t)&&e.classList.remove(t);}},{key:"initEvent",value:function value(){var e=this,t=this.prefix,i=this.query(".".concat(t,"first-page")),r=this.query(".".concat(t,"prev-page")),n=this.query(".".concat(t,"next-page")),o=this.query(".".concat(t,"last-page")),a=this.query(".".concat(t,"goto"));this.nativeOn(i,"click",function(){var t=e.data.pageDetails,i=t.current,r=t.total;1!==i&&r>1&&(e.store.dispatch({type:"firstPage"}),e.emit("change",e.data.pageDetails));}),this.nativeOn(r,"click",function(){var t=e.data.pageDetails,i=t.current,r=t.total;1!==i&&r>1&&(e.store.dispatch({type:"previousPage"}),e.emit("change",e.data.pageDetails));}),this.nativeOn(n,"click",function(){var t=e.data.pageDetails,i=t.current,r=t.total;i!==r&&r>1&&(e.store.dispatch({type:"nextPage"}),e.emit("change",e.data.pageDetails));}),this.nativeOn(o,"click",function(){var t=e.data.pageDetails,i=t.current,r=t.total;i!==r&&r>1&&(e.store.dispatch({type:"lastPage"}),e.emit("change",e.data.pageDetails));}),this.nativeOn(a,"input",function(e){a.value=e.target.value.replace(/[^\d]/g,"");}),this.nativeOn(a,"keyup",function(t){if("Enter"===t.key){var i=e.data.pageDetails.total,r=$S(a.value,10);r=HL(r,1,i),a.value=String(r),0!==i&&(e.store.dispatch({type:"gotoPage",current:r-1}),e.emit("change",e.data.pageDetails));}});}},{key:"initTemplate",value:function value(){var e,t,i,r=this.data.options,n=r.gotoPage,o=r.total,a=r.separator;this.injection;var s="dvs-pagination",u=lS(e=lS(t=lS(i="
{{pageDetails.total}}
');this.template=u;}}]);}(rX);Wk(cX,"hasStore",!0),Wk(cX,"storeName","pagination"),Wk(cX,"reducer",function(e,t){switch(e||(e={current:-1,total:0}),t.type){case"setPageNumber":return Fk(Fk({},e),t.pageDetails);case"firstPage":return Fk(Fk({},e),{},{current:0});case"lastPage":return Fk(Fk({},e),{},{current:e.total-1});case"nextPage":return Fk(Fk({},e),{},{current:e.current+1});case"previousPage":return Fk(Fk({},e),{},{current:e.current-1});case"gotoPage":return Fk(Fk({},e),{},{current:t.current});default:return e;}});var hX=function(e){function t(e){var i;Xk(this,t),Wk(yb(i=cL(this,t,[e])),"postfix",""),Wk(yb(i),"created",function(e){i.el=e,i.initNativeEvent();}),e.template&&(i.template=e.template);var r=i.injection,n=r.emitter,o=r.postfix;return i.uiEmitter=n,i.emitter=n,i.postfix=o,i.initTemplate(),i;}return _b(t,e),Yk(t,[{key:"initTemplate",value:function value(){var e=this.data.options.children,t="
");e&&$k(e).call(e,function(e,i){var r,n,o=e.enable,a=e.type;!1!==o&&(t+=lS(r=lS(n="<".concat(a,' :options="options.children.')).call(n,i,'">"));}),t+="
",this.template=t;}},{key:"initNativeEvent",value:function value(){}}]);}(rX),dX={name:"dvsUi",install:function install(e){for(var t=e.getClassStore(),i=t.Viewer,r=arguments.length,n=new Array(r>1?r-1:0),o=1;o=i/r?(s=i,u=a*(i/o)):(u=r,s=o*(r/a)),t.style.width="".concat(s,"px"),t.style.height="".concat(u,"px"),this.imageSize.clientWidth=t.clientWidth,this.imageSize.clientHeight=t.clientHeight;}}},{key:"overlayRectangle",value:function value(e,t,i,r,n){var o=this,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"#000",s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1;if(!vF(this,e=fF(this,e)))return!1;var u=this.getCurrentTab(),l=$E(e).call(e,function(e){return u.getUidByIndex(e);}),c={tabUid:u.uid,tabType:u.type,trigger:this.uid,uids:l,left:t,top:i,width:r,height:n,color:a,opacity:s,overlayUid:WL()};return $k(l).call(l,function(e){o.context.getStatus(e).overlays.push(Fk({},c));}),this.context.dvsContext.hooksService.hooks.overlay.emit(c),!0;}},{key:"getCurrentPageUids",value:function value(){var e,t=this.getCurrentTab();return t?$E(e=t.children).call(e,function(e){return e.uid;}):[];}},{key:"getCurrentPageCounts",value:function value(){var e=this.getCurrentTab();return(null==e?void 0:e.total)||0;}}]);}(e),Wk(t,"use",e.use),t;}(i);r.use(new fX()),t.Viewer=r;}}},gX=function(){return Yk(function e(t){Xk(this,e),Wk(this,"context",void 0),Wk(this,"outer",void 0),Wk(this,"inner",void 0),Wk(this,"original",void 0),Wk(this,"matrixes",void 0),Wk(this,"blanks",[]),Wk(this,"overlays",[]),this.context=t;},[{key:"handle",value:function value(e){var t,i=this;this.outer=new UW(),this.inner=new UW(),this.outer.appendChild(this.inner),this.original=this.inner,this.matrixes=[],this.blanks=[],this.overlays=[];var r=e.operations,n=e.width,o=e.height,a=e.blanks,s=n,u=o;return this.inner.updateStyle({x:0,y:0,width:n,height:o}),this.outer.updateStyle({width:n,height:o}),r&&$k(r).call(r,function(e){if("r"===e.type){var t=i.rotate(e,s,u),r=t.rWidth,n=t.rHeight;s=r,u=n;}else if("c"===e.type){var o=i.crop(e),l=o.width,c=o.height;s=l,u=c;}else if("f"===e.type)i.flip(e);else if("z"===e.type){var h=i.resize(e,s,u),d=h.rWidth,f=h.rHeight;s=d,u=f;}else"e"===e.type&&i.erase(e,a);}),{width:s,height:u,matrixes:RI(t=this.matrixes).call(t),blanks:this.blanks};}},{key:"erase",value:function value(e,t){var i,r=this;$k(i=e.detail).call(i,function(e){var t,i=e.left,n=e.top,o=e.width,a=e.height,s=r.original.getWorldTransform().clone().invertSelf(),u=$E(t=[[i,n],[i+o,n],[i+o,n+a],[i,n+a]]).call(t,function(e){var t=Gb(e,2),i=t[0],r=t[1];return s.transformPoint({x:i,y:r,z:0});});r.blanks.push({uid:e.eraseUid,points:u,background:e.color});});}},{key:"resize",value:function value(e,t,i){var r=e.detail[e.detail.length-1];r||console.error("resize operation is empty");var n=r.width,o=r.height,a=n/t,s=o/i,u=(n-t)/2,l=(o-i)/2,c=new UW();c.updateStyle({x:0,y:0,width:n,height:o}),c.appendChild(this.outer),this.inner=this.outer,this.outer=c,this.inner.scale(a,s,1);var h=this.inner.getPosition(),d=h.x,f=h.y;this.inner.setPosition({x:d+u,y:f+l,z:0});var v=this.inner.getLocalTransform();return this.matrixes.push(v),{rWidth:n,rHeight:o};}},{key:"flip",value:function value(e){var t,i=[1,1,1];$k(t=e.detail).call(t,function(e){"v"===e.dir?(i[1]*=-1,i[2]*=-1):"h"===e.dir&&(i[0]*=-1,i[2]*=-1);});var r=new UW();r.updateStyle({x:0,y:0,width:this.outer.width,height:this.outer.height}),r.appendChild(this.outer),this.outer.scale(i[0],i[1],i[2]),this.inner=this.outer,this.outer=r;var n=this.inner.getLocalTransform();this.matrixes.push(n);}},{key:"crop",value:function value(e){var t,i=null;if($k(t=e.detail).call(t,function(e){var t=e.left,r=e.top,n=e.width,o=e.height;if(i){var a=i.getRect(),s=a.left,u=a.top,l=new qW(t+s,t+s+n,r+u,r+u+o);i=i.intersection(l);}else i=new qW(t,t+n,r,r+o);}),!i)return console.error("there is no crop operation"),{width:0,height:0};var r=i.getRect(),n=new UW();n.updateStyle({x:0,y:0,width:r.width,height:r.height}),n.appendChild(this.outer),this.inner=this.outer,this.outer=n;var o=this.inner.getPosition(),a=o.x,s=o.y;this.inner.setPosition({x:a-r.left,y:s-r.top,z:0});var u=this.inner.getLocalTransform();return this.matrixes.push(u),i.getRect();}},{key:"rotate",value:function value(e,t,i){var r,n=this,o=null,a=0;if($k(r=e.detail).call(r,function(e){if(null===o&&(o=e.type),e.type===o)a+=e.angle;else{var r=n.executeRotate(o,a,t,i),s=r.width,u=r.height;t=s,i=u,o=e.type,a=e.angle;}}),o){var s=this.executeRotate(o,a,t,i),u=s.width,l=s.height;t=u,i=l;}return{rWidth:t,rHeight:i};}},{key:"rotateInContainMode",value:function value(e,t,i){var r=function(e,t,i,r,n,o,a){var s=0+i/2,u=0+r/2,l=_N(0,0,s,u,n),c=_N(0+i,0,s,u,n),h=_N(0+i,0+r,s,u,n),d=_N(0,0+r,s,u,n),f=pU(o=[c.x,l.x,d.x,h.x]).call(o,function(e,t){return e-t;}),v=pU(a=[c.y,l.y,d.y,h.y]).call(a,function(e,t){return e-t;});return{x:f[0],y:v[0],width:f[3]-f[0],height:v[3]-v[0]};}(0,0,t,i,xN(e)),n=r.width,o=r.height,a=(n-t)/2,s=(o-i)/2;t=n,i=o;var u=new UW();u.updateStyle({x:0,y:0,width:n,height:o}),u.appendChild(this.outer),this.outer.rotateLocal(e),this.inner=this.outer,this.outer=u;var l=this.inner.getPosition(),c=l.x,h=l.y;this.inner.setPosition({x:c+a,y:h+s,z:0});var d=this.inner.getLocalTransform();return this.matrixes.push(d),{rWidth:n,rHeight:o};}},{key:"executeRotate",value:function value(e,t,i,r){if("clip"===e){var n=new UW();n.updateStyle({x:0,y:0,width:i,height:r}),n.appendChild(this.outer),this.outer.rotateLocal(t),this.inner=this.outer,this.outer=n;var o=this.inner.getLocalTransform();this.matrixes.push(o);}else if("contain"===e){var a=this.rotateInContainMode(t,i,r);i=a.rWidth,r=a.rHeight;}return{width:i,height:r};}},{key:"toMinImageOperations",value:function value(e,t){var i=[];return $k(e).call(e,function(e){var r,n,o,a={type:e.type,detail:[]};i.push(a),"c"===e.type||"e"===e.type?$k(r=e.detail).call(r,function(e){var i=Fk(Fk({},e),{},{left:e.left/t,top:e.top/t,width:e.width/t,height:e.height/t});a.detail.push(i);}):"f"===e.type||"r"===e.type?$k(n=e.detail).call(n,function(e){var t=Fk({},e);a.detail.push(t);}):"z"===e.type&&$k(o=e.detail).call(o,function(e){var i=Fk(Fk({},e),{},{width:e.width/t,height:e.height/t});a.detail.push(i);});}),i;}}]);}(),mX=function(e){function t(e,i){var r;return Xk(this,t),Wk(yb(r=cL(this,t)),"uid",void 0),Wk(yb(r),"context",void 0),Wk(yb(r),"action",void 0),Wk(yb(r),"tabUid",void 0),r.context=e,r.action=i,r.uid=i.commandUid,r.tabUid=i.tabUid,r;}return _b(t,e),Yk(t,[{key:"execute",value:function value(){}},{key:"undo",value:function value(){this.context.removeActionFromStatus(this.action);}}]);}(wF),yX=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t);}(mX),pX=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t);}(mX),wX=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t,[{key:"execute",value:function value(){var e=this.action,t=e.left,i=e.top,r=e.width,n=e.height,o=e.color,a=e.uids,s=e.eraseUid,u=this.context.getTab(this.tabUid);u&&$k(a).call(a,function(e){var a=u.getChildByUid(e);if(a){var l=new WW({id:s,style:{points:[{x:t,y:i},{x:t+r,y:i},{x:t+r,y:i+n},{x:t,y:i+n}],background:o,borderWidth:0}});a.blanks.appendChild(l);}});}},{key:"undo",value:function value(){var e,t=this;this.context.removeActionFromStatus(this.action);var i=this.context.getTab(this.tabUid);i&&$k(e=this.action.uids).call(e,function(e){var r=i.getChildByUid(e);if(r){var n,o=xP(n=r.blanks.children).call(n,function(e){return e.id===t.action.eraseUid;});o&&r.blanks.removeChild(o);}});}}]);}(mX),bX=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t);}(mX),kX=function(e){function t(){return Xk(this,t),cL(this,t,arguments);}return _b(t,e),Yk(t);}(mX),SX=function(){return Yk(function e(){Xk(this,e);},[{key:"init",value:function value(e){var t=e.getGlobalHooks(),i=t.rotate,r=t.flip,n=t.crop,o=t.erase,a=t.changeSize,s=t.reset,u=function u(t){var i;$k(i=e.getAllTabs()).call(i,function(i){var r;if(bF(t,i)){var n,o=null;switch($k(n=(t=_SL(t)).uids).call(n,function(e){var t=i.getChildByUid(e);t.isEdited=!0,t&&t.clearOptimization();}),t.actionType){case"r":(Math.abs(t.angle)%90||"clip"===t.type)&&$k(r=t.uids).call(r,function(t){var r=i.getChildByUid(t);r&&(r.imageContainer.updateStyle({background:e.config.blankFillColor}),e.getStatus(r.uid).useFillColor=!0);}),o=new kX(e,t);break;case"f":o=new bX(e,t);break;case"c":o=new pX(e,t);break;case"e":o=new wX(e,t);break;case"z":o=new yX(e,t);}i.commandController.execute(o),e.tabService.isCurrentTab(i.uid)&&e.render();}});},l=function l(t){var i,r=t.uids;$k(i=e.getAllTabs()).call(i,function(i){bF(t,i)&&($k(r).call(r,function(e){var t,r,n=i.getChildByUid(e);n.isEdited=!0,n&&$k(t=RI(r=n.blanks.childNodes).call(r)).call(t,function(e){n.blanks.removeChild(e);});}),e.tabService.isCurrentTab(i.uid)&&e.render());});};e.layoutService.hooks.beforeLayout.on(function(t){var i,r=t.tabNode;$k(i=r.childNodes).call(i,function(t){var i=e.getStatus(t.uid);if(i&&t.isVisible&&t.isLoaded&&t.image.style.img){var r,n,o,a={operations:i.operations,width:(null===(r=t.image.style.img)||void 0===r?void 0:r.naturalWidth)||0,height:(null===(n=t.image.style.img)||void 0===n?void 0:n.naturalHeight)||0,blanks:$E(o=t.blanks.children).call(o,function(e){return e.id;})};"multiple"===e.config.displayMode&&e.config.useMinImage&&(a.operations=e.dvsContext.editService.toMinImageOperations(i.operations,i.imageScale));var s=e.dvsContext.editService.handle(a),u=s.width,l=s.height,c=s.matrixes,h=s.blanks;t.image.externalMatrixes=c,t.realTimeWidth=u,t.realTimeHeight=l,"multiple"===e.config.displayMode&&e.config.useMinImage||i.setRealTimeSize(u,l),$k(h).call(h,function(e){var i;xP(i=t.blanks.children).call(i,function(t){return t.id===e.uid;}).updateStyle({points:e.points,background:e.background});});}});}),i.on(u),r.on(u),n.on(u),o.on(u),a.on(u),s.on(l),e.hooksService.hooks.destroy.on(function(){i.off(u),r.off(u),n.off(u),o.off(u),a.off(u),s.off(l);});}}]);}(),xX={name:"dvsEdit",install:function install(e){var t=e.getClassStore(),i=t.Viewer;if(i){var r=function(e,t){return t=function(e){function t(e){var i;return Xk(this,t),Wk(yb(i=cL(this,t,[e])),"viewerConfig",void 0),i.context.configService.registerHandler("rotationType",function(e,t){e.config.rotationType=t;}),i.context.config.rotationType||(i.context.config.rotationType="contain"),i;}return _b(t,e),Yk(t,[{key:"rotate",value:function value(e,t){if(!vF(this,t=fF(this,t)))return!1;var i=this.getCurrentTab(),r=$E(t).call(t,function(e){return i.getUidByIndex(e);}),n={actionType:"r",commandUid:WL(),tabUid:i.uid,tabType:i.type,trigger:this.uid,uids:r,angle:e,type:this.getViewerConfigByName("rotationType")};return this.context.storeActionToStatus(n),this.context.getGlobalHooks().rotate.emit(n),!0;}},{key:"flip",value:function value(e,t){if(!vF(this,e=fF(this,e)))return!1;var i=this.getCurrentTab(),r=$E(e).call(e,function(e){return i.getUidByIndex(e);}),n={actionType:"f",commandUid:WL(),tabUid:i.uid,tabType:i.type,trigger:this.uid,uids:r,dir:t||"v"};return this.context.storeActionToStatus(n),this.context.getGlobalHooks().flip.emit(n),!0;}},{key:"mirror",value:function value(e){return this.flip(e,"h");}},{key:"changePageSize",value:function value(e,t,i){if(!vF(this,e=fF(this,e)))return!1;var r=this.getCurrentTab(),n=$E(e).call(e,function(e){return r.getUidByIndex(e);}),o={actionType:"z",commandUid:WL(),tabUid:r.uid,tabType:r.type,trigger:this.uid,uids:n,width:t,height:i};return this.context.storeActionToStatus(o),this.context.getGlobalHooks().changeSize.emit(o),!0;}},{key:"crop",value:function value(e,t,i,r,n){if(!vF(this,e=fF(this,e)))return!1;var o=this.getCurrentTab(),a=$E(e).call(e,function(e){return o.getUidByIndex(e);}),s={actionType:"c",commandUid:WL(),tabUid:o.uid,tabType:o.type,trigger:this.uid,uids:a,left:t,top:i,width:r,height:n};return this.context.storeActionToStatus(s),this.context.getGlobalHooks().crop.emit(s),!0;}},{key:"erase",value:function value(e,t,i,r,n,o){if(!vF(this,e=fF(this,e)))return!1;var a=this.getCurrentTab(),s=$E(e).call(e,function(e){return a.getUidByIndex(e);}),u={actionType:"e",commandUid:WL(),tabUid:a.uid,tabType:a.type,trigger:this.uid,eraseUid:WL(),uids:s,left:t,top:i,width:r,height:n,color:o};return this.context.storeActionToStatus(u),this.context.getGlobalHooks().erase.emit(u),!0;}}]);}(e),Wk(t,"use",e.use),t;}(i);r.use(new SX()),t.Viewer=r;}},init:function init(e){e.context.editService=new gX(e.context);}},CX=function(){return Yk(function e(t,i,r,n){Xk(this,e),Wk(this,"webViewer",void 0),Wk(this,"bDispose",!1),Wk(this,"element",void 0),Wk(this,"container",void 0),Wk(this,"css",void 0),this.webViewer=t,this.element=i,this.element.style.flexShrink="0";var o=this.webViewer.myViewer.rootDom;this.container=o.querySelector("#dvs-viewer-main".concat(t.myViewer.postfix));var a="dvs-customElement-right";switch(r){case"left":a="dvs-customElement-left";break;case"top":a="dvs-customElement-top";break;case"bottom":a="dvs-customElement-bottom";}n&&this.element.classList.add("dvs-customElement-full"),this.css=a,this.container.classList.add(a),this.container.appendChild(i),this.hide();},[{key:"show",value:function value(){if(this.element)return this.element.style.display="block",this.webViewer.resized(),this.webViewer.resized(),!0;var e=this.bDispose?"CustomElementDispose":"CustomElementNotExist";return this.webViewer.setError(e),!1;}},{key:"hide",value:function value(){if(this.element)return this.element.style.display="none",this.webViewer.resized(),this.webViewer.resized(),!0;var e=this.bDispose?"CustomElementDispose":"CustomElementNotExist";return this.webViewer.setError(e),!1;}},{key:"dispose",value:function value(){return this.bDispose||(this.element&&(this.container.removeChild(this.element),this.webViewer.resized(),this.webViewer.resized(),this.webViewer.customElement=void 0,this.element=null,this.container.classList.remove(this.css),this.container=void 0),this.bDispose=!0),!0;}}]);}();function VX(e){var t=function t(e){var t=Number(e).toString(16).toUpperCase();return 1===t.length&&(t=["0",t].join("")),t;},i=(65280&e)>>8,r=255&e;return["#",t(e>>16),t(i),t(r)].join("");}function TX(e){if(CL(e))return!1;if(""===e)return!0;var t=document.createElement("div");return t.style.background=e,""!==t.style.background;}function IX(e){if(CL(e))return!1;if(""===e)return!0;var t=document.createElement("div");t.style.border=e;var i=t.style,r=i.borderWidth,n=i.borderColor,o=i.borderStyle;return"initial"!==r&&""!==r&&"initial"!==n&&""!==r&&"initial"!==o&&""!==r;}function EX(e){var t=FO(e);return!(CL(t)||t.value<0);}var PX=10===document.documentMode?"dvs-buttons-ie":"dvs-buttons";function BX(e){var t;return lS(t="dvs-editor-iconfont ds-dwt-ui-icon-".concat(e," ")).call(t,PX);}var DX={type:"Button",className:"".concat(PX," dwt-viewer-imageEditor-emptyBtn"),style:{visibility:"visible"}},MX={type:"Button",name:"previous",id:"previous",className:BX("preImage"),style:{visibility:"visible"},events:{click:"previousImage"}},zX={type:"Button",name:"next",id:"next",className:BX("nextImage"),style:{visibility:"visible"},events:{click:"nextImage"}},AX={type:"Button",name:"scan",id:"scan",className:BX("acquire"),style:{visibility:"visible"},events:{click:"scanImage"}},UX={type:"Button",name:"load",id:"load",className:BX("load"),style:{visibility:"visible"},events:{click:"loadImage"}},RX={type:"Button",name:"print",id:"print",className:BX("printImage"),style:{visibility:"visible"},events:{click:"printImage"}},LX={type:"Button",name:"removeAll",id:"removeAll",className:BX("removeall"),style:{visibility:"visible"},events:{click:"removeAllImage"}},NX={type:"Button",name:"removeSelected",id:"removeSelected",className:BX("removeImage"),style:{visibility:"visible"},events:{click:"removeImage"}},OX={type:"Button",name:"rotateLeft",id:"rotateLeft",className:BX("rotateLeftImage"),style:{visibility:"visible"},events:{click:"rotateLeft"}},WX={type:"Button",name:"rotate",id:"rotate",className:BX("rotate"),style:{visibility:"visible",position:"relative"},events:{click:"rotate"}},HX={type:"Button",name:"rotateRight",id:"rotateRight",className:BX("rotateRightImage"),style:{visibility:"visible"},events:{click:"rotateRight"}},FX={type:"Button",name:"deskew",id:"deskew",className:BX("deskew"),style:{visibility:"visible"},events:{click:"deskew"}},jX={type:"Button",name:"crop",id:"crop",className:BX("cropImage-grey"),style:{visibility:"visible"},events:{click:"cropImage"}},YX={type:"Button",name:"cut",id:"cut",className:BX("erase-grey"),style:{visibility:"visible"},events:{click:"cutImage"}},XX={type:"Button",name:"changeImageSize",id:"changeImageSize",className:BX("changeImageSize"),style:{visibility:"visible",position:"relative"},events:{click:"changeImageSize"}},qX={type:"Button",name:"flip",id:"flip",className:BX("flipImage"),style:{visibility:"visible"},events:{click:"flipImage"}},ZX={type:"Button",name:"mirror",id:"mirror",className:BX("mirrorImage"),style:{visibility:"visible"},events:{click:"mirrorImage"}},_X={type:"Button",name:"zoomIn",id:"zoomIn",className:BX("zoomin"),style:{visibility:"visible"},events:{click:"zoomIn"}},GX={type:"Button",name:"originalSize",id:"originalSize",className:BX("originalsize"),style:{visibility:"visible"},events:{click:"originalSize"}},KX={type:"Button",name:"zoomOut",id:"zoomOut",className:BX("zoomout"),style:{visibility:"visible"},events:{click:"zoomOut"}},$X={type:"Button",name:"fit",id:"fit",className:BX("fullWebType"),style:{visibility:"visible"},events:{click:"fitWindow"}},JX={type:"Button",name:"fitW",id:"fitW",className:BX("fitWidthType"),style:{visibility:"visible"},events:{click:"fitWidth"}},QX={type:"Button",name:"fitH",id:"fitH",className:BX("fitHeightType"),style:{visibility:"visible"},events:{click:"fitHeight"}},eq={type:"Button",name:"hand",id:"hand",className:BX("hand"),style:{visibility:"visible"},events:{click:"handMode"}},tq={type:"Button",name:"rectSelect",id:"rectSelect",className:BX("select"),style:{visibility:"visible"},events:{click:"selectMode"}},iq={type:"Button",name:"zoom",id:"zoom",className:BX("clicktozoomin"),style:{visibility:"visible"},events:{click:"zoomMode"}},rq={type:"Button",name:"restore",id:"restore",className:BX("restore"),style:{visibility:"visible"},events:{click:"restoreImage"}},nq={type:"Button",name:"save",id:"save",className:BX("saveImage"),style:{visibility:"visible"},events:{click:"saveImage"}},oq={type:"Button",name:"close",id:"close",className:BX("close"),style:{visibility:"visible"},events:{click:"closeImageEditor"}},aq=["previousImage","nextImage","scanImage","loadImage","printImage","removeAllImage","removeImage","rotateLeft","rotate","rotateRight","deskew","cropImage","cutImage","changeImageSize","flipImage","mirrorImage","zoomIn","originalSize","zoomOut","fitWindow","fitWidth","fitHeight","handMode","selectMode","zoomMode","restoreImage","saveImage","closeImageEditor"],sq=["bufferChanged","click","pageAreaSelected","pageAreaUnselected"],uq={root:{style:{display:"flex",flexDirection:"column",position:"relative"},id:"root",children:[{type:"Group",style:{height:"40px",minHeight:"30px",background:"rgb(58, 57, 59)",boxSizing:"border-box"},id:"header",className:"dwt-viewer-imageEditor-header",children:[{style:{width:"95%"},type:"Group",className:"dwt-viewer-imageEditor-leftButtons",children:[MX,zX,DX,AX,UX,RX,DX,LX,NX,DX,OX,WX,HX,FX,DX,jX,YX,XX,qX,ZX,DX,_X,GX,KX,DX,$X,JX,QX,DX,eq,tq,iq,DX,rq,nq]},{style:{width:"5%",justifyContent:"flex-end"},type:"Group",className:"dwt-viewer-imageEditor-rightButtons",children:[oq]}]},{type:"MainCanvas",id:"canvas",className:"dvs-canvas"}]}},lq={flex:"1",visibility:"visible",fontSize:"1.2em"},cq={visibility:"visible",fontSize:"1.2em"},hq={root:{style:{display:"flex",flexDirection:"column",position:"relative"},id:"root",children:[{type:"Group",dataId:"header",style:{padding:"0 8px",height:"40px",background:"#2a292b",boxSizing:"border-box"},className:"dwt-viewer-imageEditor-header",children:[Fk(Fk({},UX),{},{style:Fk({},cq)}),Fk(Fk({},oq),{},{style:Fk({},cq)})]},{type:"Group",dataId:"body",style:{display:"flex",flexDirection:"column"},children:[{type:"Group",dataId:"topMenu",style:{height:"60px",boxSizing:"border-box",background:"#3a393b"},children:[Fk(Fk({},OX),{},{style:Fk({},lq)}),Fk(Fk({},HX),{},{style:Fk({},lq)}),Fk(Fk({},qX),{},{style:Fk({},lq)}),Fk(Fk({},ZX),{},{style:Fk({},lq)}),Fk(Fk({},jX),{},{style:Fk({},lq)}),Fk(Fk({},YX),{},{style:Fk({},lq)}),Fk(Fk({},eq),{},{style:Fk({},lq)}),Fk(Fk({},tq),{},{style:Fk({},lq)})]},{type:"MainCanvas",dataId:"canvas",className:"dvs-canvas"},{type:"Group",dataId:"bottomMenu",style:{height:"60px",background:"rgb(58, 57, 59)"},children:[{type:"Pagination",className:"dvs-imageEditor-pagination",events:{change:"paginationChange"},style:{display:"flex",width:"50%"},firstPage:{id:"firstPage",style:{visibility:"visible",flex:1}},lastPage:{id:"lastPage",style:{visibility:"visible",flex:1}},prevPage:{id:"previousPage",style:{visibility:"visible",flex:1}},nextPage:{id:"nextPage",style:{visibility:"visible",flex:1}},gotoPage:{style:{visibility:"visible",flex:1}},total:{style:{visibility:"visible",flex:1,textAlign:"center"}}},Fk(Fk({},LX),{},{style:Fk({},lq)}),Fk(Fk({},NX),{},{style:Fk({},lq)}),Fk(Fk({},rq),{},{style:Fk({},lq)}),Fk(Fk({},nq),{},{style:Fk({},lq)})]}]}]}};function dq(e){var t={};return BL(null==e?void 0:e.borderWidth)&&(t.borderWidth=e.borderWidth),bL(null==e?void 0:e.lineDash)&&BL(e.lineDash[0])&&BL(e.lineDash[1])&&(t.dashLine=[e.lineDash[0],e.lineDash[1]]),TL(null==e?void 0:e.borderColor)&&(t.borderColor=e.borderColor),TL(null==e?void 0:e.handleColor)&&(t.ctrlBorderColor=e.handleColor),BL(null==e?void 0:e.handleWidth)&&(t.ctrlWidth=e.handleWidth),BL(null==e?void 0:e.handleHeight)&&(t.ctrlHeight=e.handleHeight),t;}function fq(e){return{borderWidth:e.borderWidth,lineDash:e.dashLine,handleWidth:e.ctrlWidth,handleHeight:e.ctrlHeight,handleColor:e.ctrlBorderColor,borderColor:e.borderColor};}var vq=function(){return Yk(function e(t,i){Xk(this,e),Wk(this,"dvs",void 0),Wk(this,"cutColor","white"),Wk(this,"webViewer",void 0),Wk(this,"editorViewer",void 0),Wk(this,"viewerSetting",void 0),Wk(this,"containerElement",void 0),Wk(this,"uiSetting",uq),Wk(this,"editorSetting",void 0),Wk(this,"bShowImageEditor",!1),Wk(this,"lastRotateAngle",45),Wk(this,"lastRotateKeepSize",!1),Wk(this,"promoteSaveChange",!0),Wk(this,"workMode",!1),Wk(this,"bCrop",!1),Wk(this,"bErase",!1),Wk(this,"curIndex",0),Wk(this,"bChanged",!1),Wk(this,"bChangedUid",""),Wk(this,"cursor","select"),Wk(this,"defaultBtnClass","dvs-btn dvs-editor-iconfont dvs-buttons"),Wk(this,"bDispose",!1),Wk(this,"bMobile",!1),Wk(this,"bFullScreen",!1),Wk(this,"deskewStarted",!1),this.webViewer=t,this.dvs=t.myDvs,this.editorSetting=i||VO,this.promoteSaveChange=i.promptToSaveChange,this.workMode=0===i.workMode,this.updateEditorSetting(i),this.init(i);},[{key:"init",value:function value(e){this.bMobile=AL(),this.editorViewer=this.webViewer.myDvs.createViewer({viewerConfig:{viewerStyle:{background:"white"},canvasStyle:{background:"rgba(0,0,0,0)"},pageStyle:{background:"white"},displayMode:"single",enableOptimizeImage:!0,enableSlide:!0,maxZoom:50,margin:0},uiConfig:this.uiSetting,syncViewerUid:this.webViewer.myViewer.uid}),this.updateViewerSetting(e),0!==this.dvs.context.errorService.errorCode&&this.webViewer.setDefaultError(),this.bDispose=!1,this.bindEditorEvents(),zR(this).call(this),this.disableMobileInput(),this.setWidth(null==e?void 0:e.width),this.setHeight(null==e?void 0:e.height),this.setIfAutoScroll(this.webViewer.getIfAutoScroll());}},{key:"updateViewerSetting",value:function value(e){if(!this.editorViewer)return!1;var t=e.innerBorder,i=e.background,r=e.zoomOrigin,n=this.editorViewer.getViewerConfig().canvasStyle,o={border:t||n.border,background:i||n.background};return this.setZoomOrigin(r),this.editorViewer.updateViewerConfig({cropBoxConfig:_SL(TO),canvasStyle:o}),!0;}},{key:"updateUISetting",value:function value(e){this.editorSetting=e,this.uiSetting=_SL(uq);var t=this.uiSetting.root.children[0],i=t.children[0].children,r=t.children[1].children;if(e.topMenuBorder&&IX(e.topMenuBorder)&&(t.style.border=e.topMenuBorder),e.border&&IX(e.border)&&(this.uiSetting.root.style.border=e.border),this.editorSetting.buttons){for(var n,o=this.editorSetting.buttons,a=o.titles,s=o.visibility,u=[i,r],l=[],c=function c(e){var t;$k(t=u[e]).call(t,function(t,i){var r,n=null==t||null===(r=t.name)||void 0===r?void 0:r.toLocaleLowerCase();CL(a)||CL(a[n])||(t.title=a[n]),CL(s)||CL(s[n])||(t.style.display=!0===s[n]?"":"none",!1===s[n]&&0===e&&l.push(i));});},h=0;h600&&(i=Math.min(22,t/750*16)),i<16&&(i=16),this.bMobile&&(i=20),e.style.fontSize="".concat(i,"px");}}}},{key:"hideImageEditorDialog",value:function value(){this.closeRotateDialog(),this.closeChangeSizeDialog();}},{key:"updateZoomInState",value:function value(e){var t=e?"ds-dwt-ui-icon-zoomin":"ds-dwt-ui-icon-zoomin dvs-grey";this.setButtonClass("zoomIn",t);}},{key:"updateZoomOutState",value:function value(e){var t=e?"ds-dwt-ui-icon-zoomout":"ds-dwt-ui-icon-zoomout dvs-grey";this.setButtonClass("zoomOut",t);}},{key:"updateDeskewState",value:function value(e){var t=e?"ds-dwt-ui-icon-deskew":"ds-dwt-ui-icon-deskew dvs-grey";this.setButtonClass("deskew",t);}},{key:"updateEraseState",value:function value(e,t){var i=e?"ds-dwt-ui-icon-erase":"ds-dwt-ui-icon-erase dvs-grey";this.setButtonClass("cut",i),t&&this.clearSelectedArea();}},{key:"updateCropState",value:function value(e,t){var i=e?"ds-dwt-ui-icon-cropImage":"ds-dwt-ui-icon-cropImage dvs-grey";this.setButtonClass("crop",i),t&&this.clearSelectedArea();}},{key:"updateSaveAndRestoreBtn",value:function value(){var e=this.bChanged?"ds-dwt-ui-icon-saveImage":"ds-dwt-ui-icon-saveImage dvs-grey",t=this.bChanged?"ds-dwt-ui-icon-restore":"ds-dwt-ui-icon-restore dvs-grey";this.setButtonClass("save",e),this.setButtonClass("restore",t);}},{key:"updateCursorState",value:function value(){switch(this.cursor){case"pointer":this.handMode();break;case"zoom":this.zoomMode();break;default:this.selectMode();}return!0;}},{key:"updateMouseModeState",value:function value(e){this.setButtonClass("hand","ds-dwt-ui-icon-hand"),this.setButtonClass("rectSelect","ds-dwt-ui-icon-select"),this.setButtonClass("zoom","ds-dwt-ui-icon-clicktozoomin"),"pointer"===e?this.setButtonClass("hand","ds-dwt-ui-icon-hand dwt-viewer-imageEditor-selected"):"crosshair"===e?this.setButtonClass("rectSelect","ds-dwt-ui-icon-select dwt-viewer-imageEditor-selected"):this.setButtonClass("zoom","ds-dwt-ui-icon-clicktozoomin dwt-viewer-imageEditor-selected");}},{key:"updateState",value:function value(){if(this.editorViewer){var e=this.webViewer.getHowManyImagesInBuffer(),t=this.webViewer.getCurrentIndex();e>1?(this.webViewer.getCurrentIndex()===e-1||e<=1?this.setButtonClass("next","ds-dwt-ui-icon-nextImage dvs-grey"):this.setButtonClass("next","ds-dwt-ui-icon-nextImage"),t<=0||e<=1?this.setButtonClass("previous","ds-dwt-ui-icon-preImage dvs-grey"):this.setButtonClass("previous","ds-dwt-ui-icon-preImage")):(this.setButtonClass("next","ds-dwt-ui-icon-nextImage dvs-grey"),this.setButtonClass("previous","ds-dwt-ui-icon-preImage dvs-grey")),this.updateSaveAndRestoreBtn(),this.updateCropState(!1,!0),this.updateEraseState(!1,!0),this.updateCursorState();}}},{key:"setChangedState",value:function value(e){e?(this.bChanged=!0,this.bChangedUid=this.webViewer.getCurrentImgUUid()):(this.bChanged=!1,this.bChangedUid="");}},{key:"disableMobileInput",value:function value(){if(this.bMobile){var e=document.querySelector(".dvs-pagination-goto");e&&(e.disabled=!0);}}},{key:"bindStopPropagation",value:function value(e){var t=document.getElementById(e);t&&(t.onclick=function(e){fN(e);});}},{key:"updateEditorConfig",value:function value(e){this.editorViewer.updateViewerConfig(e);}},{key:"setIfAutoScroll",value:function value(e){return!!this.editorViewer&&(this.updateEditorConfig({autoSelectLatest:e,autoScroll:e}),!0);}},{key:"getSelectionBoxStyle",value:function value(){if(!this.editorViewer){var e=this.bDispose?"ImageEditorDispose":"ImageEditorNotExist";return this.webViewer.setError(e),!1;}return fq(this.editorViewer.cropBoxConfig);}},{key:"setSelectionBoxStyle",value:function value(e){if(!this.editorViewer){var t=this.bDispose?"ImageEditorDispose":"ImageEditorNotExist";return this.webViewer.setError(t),!1;}if(!kL(e))return!1;var i=dq(e);return this.updateEditorConfig({cropBoxConfig:i}),!0;}},{key:"resetButtonState",value:function value(){this.setChangedState(!1),this.updateSaveAndRestoreBtn();}},{key:"bind",value:function value(){var e;if(this.bShowImageEditor)return!0;if(!this.editorViewer){var t=this.bDispose?"ImageEditorDispose":"ImageEditorNotExist";return this.webViewer.setError(t),!1;}if(this.editorSetting&&this.editorSetting.element)this.bFullScreen=!1,TL(this.editorSetting.element)?this.containerElement=document.getElementById(this.editorSetting.element):this.containerElement=this.editorSetting.element;else{var i=document.createElement("div");i.className="dwt-viewer-imageEditor-fullScreen",document.body.insertBefore(i,document.body.firstElementChild),this.bFullScreen=!0,this.containerElement=i;}if(this.editorViewer.bindContainer(this.containerElement),this.editorViewer.hide(),this.updateState(),this.setSelectionRectAspectRatio((null===(e=this.editorSetting)||void 0===e?void 0:e.selectionRectAspectRatio)||0),!this.bMobile){var r=document.getElementById("header".concat(this.editorViewer.postfix));r&&r.addEventListener("wheel",function(e){e.preventDefault();},{passive:!1});}return!0;}},{key:"close",value:function value(){if(!this.editorViewer){var e=this.bDispose?"ImageEditorDispose":"ImageEditorNotExist";return this.webViewer.setError(e),!1;}this.bFullScreen&&document.body.removeChild(this.containerElement);var t=this.webViewer.webViewerInitConfig.imageEditorEvents;return this.bShowImageEditor=!1,this.webViewer.bShowImageEditor=!1,this.hideImageEditorDialog(),this.dvs.removeViewer(this.editorViewer),this.bFullScreen=!1,this.containerElement=null,this.editorViewer=void 0,this.webViewer.imageEditor=void 0,this.dvs=null,this.bDispose=!0,t&&ML(null==t?void 0:t.close)&&null!=t&&t.close(),window.removeEventListener("resize",window.dvsResize),window.dvsResize=null,document.body.style.overflow="",!0;}},{key:"show",value:function value(){var e;if(this.bShowImageEditor)return!0;if(this.editorViewer)return this.bFullScreen&&(this.containerElement.style.display="block",document.body.style.overflow="hidden"),this.bShowImageEditor=!0,this.editorViewer.show(),window.dvsResize=zR(e=this.resize).call(e,this),window.addEventListener("resize",window.dvsResize),this.resize(),!0;var t=this.bDispose?"ImageEditorDispose":"ImageEditorNotExist";return this.webViewer.setError(t),!1;}},{key:"hide",value:function value(){if(this.editorViewer)return this.editorViewer.hide(),this.bShowImageEditor=!1,this.bFullScreen&&(document.body.style.overflow="",this.containerElement.style.display="none"),window.removeEventListener("resize",window.dvsResize),window.dvsResize=null,!0;var e=this.bDispose?"ImageEditorDispose":"ImageEditorNotExist";return this.webViewer.setError(e),!1;}},{key:"hideImageEditor",value:function value(){var e=this;this.bChanged?this.showSaveDialog(function(){e.hide();},this.webViewer.getCurrentImgUUid()):this.hide();}},{key:"setSelectionRectAspectRatio",value:function value(e){if(!this.editorViewer)return!1;var t=e>0,i=e>0?e:0;return this.editorViewer.updateViewerConfig({cropBoxConfig:{aspectRatio:i,keepAspectRatio:t}}),!0;}},{key:"clearSelectedArea",value:function value(){if(!this.editorViewer||this.bDispose)return!1;var e=this.webViewer.getHowManyImagesInBuffer(),t=this.webViewer.getCurrentIndex();if(e<=0||t<0)return!0;var i=this.editorViewer.clearCropBox();return this.editorViewer.render(),i||this.webViewer.setDefaultError(),i;}},{key:"setOperationMode",value:function value(e){if(this.editorViewer){var t="default";switch(e){case 1:t="crop";break;case 2:t="zoomIn";break;case 3:t="zoomOut";break;case 4:t="annotation";break;default:t="default";}this.editorViewer.updateViewerConfig({toolType:t});}}},{key:"setCursor",value:function value(e){if(!this.editorViewer)return!1;var t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex();if(t<=0||i<0)return!1;var r="pointer",n=0,o=this.bMobile?"pointer":"crosshair";switch(e){case"zoom-out":o="zoom",r="zoom-out",n=3;break;case"zoom-in":o="zoom",r="zoom-in",n=2;break;case"crosshair":o="crosshair",r="crosshair",n=1;break;default:o="pointer",r="pointer",n=0;}var a={cursor:r};return this.editorViewer.updateViewerConfig({canvasStyle:a}),this.setOperationMode(n),this.updateMouseModeState(e),this.cursor=o,!0;}},{key:"setFit",value:function value(e){if(!this.webViewer||!this.editorViewer)return!1;var t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex();return!(t<=0||i<0||(this.editorViewer.updateViewerConfig({fitType:e}),this.updateZoomInState(!0),this.updateZoomOutState(!0),this.updateCropState(!1,!0),this.updateEraseState(!1,!0),0));}},{key:"setWidth",value:function value(e){return!(!this.webViewer||!this.editorViewer)&&!(TL(e)&&!/^((\d+em)|(\d+px)|(\d+%)|(\d+))$/.test(e)||BL(e)&&e<=0||(this.editorViewer.dwtWidth=e,this.resize(),0));}},{key:"setHeight",value:function value(e){return!(!this.webViewer||!this.editorViewer)&&!(TL(e)&&!/^((\d+em)|(\d+px)|(\d+%)|(\d+))$/.test(e)||BL(e)&&e<=0||(this.editorViewer.dwtHeight=e,this.resize(),0));}},{key:"setButtonClass",value:function value(e,t){var i;return!!this.editorViewer&&this.editorViewer.setButtonClass(e,lS(i="".concat(this.defaultBtnClass," ")).call(i,t));}},{key:"setZoomOrigin",value:function value(e){var t,i;if(!this.editorViewer){var r=this.bDispose?"ImageEditorDispose":"ImageEditorNotExist";return this.webViewer.setError(r),!1;}if(!kL(e)||!TL(null==e?void 0:e.x)||!TL(null==e?void 0:e.y))return this.webViewer.setError("InvalidValue"),!1;var n=e.x,o=e.y;return-1===OI(t=["left","right","center"]).call(t,n)||-1===OI(i=["top","bottom","center"]).call(i,o)?(this.webViewer.setError("InvalidValue"),!1):(this.editorViewer.updateViewerConfig({zoomOrigin:{x:n,y:o}}),!0);}},{key:"getZoomOrigin",value:function value(){return this.bDispose?"":this.editorViewer.getViewerConfigByName("zoomOrigin");}},{key:"previousImage",value:function value(){var e=this;if(!this.webViewer||!this.editorViewer)return!1;var t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex();return!(t<2||0===i||(this.bChanged?this.showSaveDialog(function(){e.editorViewer.prevPage(),e.updateState();},this.webViewer.getCurrentImgUUid()):(this.editorViewer.prevPage(),this.updateState()),0));}},{key:"nextImage",value:function value(){var e=this;if(!this.webViewer||!this.editorViewer)return!1;var t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex();return!(t<2||i===t-1||(this.bChanged?this.showSaveDialog(function(){e.editorViewer.nextPage(),e.updateState();},this.webViewer.getCurrentImgUUid()):(this.editorViewer.nextPage(),this.updateState()),0));}},{key:"scanImage",value:function value(){var e=this;if(!this.webViewer||!this.editorViewer)return!1;var t=this.webViewer.webViewerInitConfig.imageEditorEvents;return!(!t||!ML(null==t?void 0:t.acquire)||(this.bChanged?this.showSaveDialog(function(){null!=t&&t.acquire(e.editorSetting.dialogText.selectSource),e.updateState();},this.webViewer.getCurrentImgUUid()):(null!=t&&t.acquire(this.editorSetting.dialogText.selectSource),this.updateState()),0));}},{key:"loadImage",value:function value(){var e=this;if(!this.webViewer||!this.editorViewer)return!1;var t=this.webViewer.webViewerInitConfig.imageEditorEvents;return!(!t||!ML(null==t?void 0:t.loadImage)||(this.bChanged?this.showSaveDialog(function(){null!=t&&t.loadImage(),e.updateState();},this.webViewer.getCurrentImgUUid()):(null!=t&&t.loadImage(),this.updateState()),0));}},{key:"removeAllImage",value:function value(){var e=this.webViewer.webViewerInitConfig.imageEditorEvents,t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex();return!(t<=0||i<0||(e&&ML(null==e?void 0:e.removeAllImage)?null==e||e.removeAllImage():this.webViewer.bufferService.removeAllImages(),this.setChangedState(!1),this.updateState(),0));}},{key:"removeImage",value:function value(){var e=this.webViewer.webViewerInitConfig.imageEditorEvents,t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex();return!(t<=0||i<0||(e&&ML(null==e?void 0:e.removeImage)?null==e||e.removeImage():this.webViewer.bufferService.removeSelectedImages(),this.setChangedState(!1),this.updateState(),0));}},{key:"rotate",value:function value(){this.showRotateDialog();}},{key:"changeImageSize",value:function value(){this.showChangeSizeDialog();}},{key:"zoomIn",value:function value(){if(!this.webViewer||!this.editorViewer)return!1;var e=this.webViewer.getHowManyImagesInBuffer(),t=this.webViewer.getCurrentIndex();if(e<=0||t<0)return!1;var i=this.editorViewer.getViewerConfig();return i.zoomi.minZoom?(this.editorViewer.zoomOut(),this.updateZoomOutState(!0)):this.updateZoomOutState(!1),this.updateZoomInState(!0),this.updateCropState(!1,!0),this.updateEraseState(!1,!0),!0;}},{key:"fitWindow",value:function value(){this.setFit("window");}},{key:"fitWidth",value:function value(){this.setFit("width");}},{key:"fitHeight",value:function value(){this.setFit("height");}},{key:"selectMode",value:function value(){this.setCursor("crosshair");}},{key:"handMode",value:function value(){this.clearSelectedArea(),this.setCursor("pointer");}},{key:"zoomMode",value:function value(){this.clearSelectedArea(),this.setCursor("zoom-in");}},{key:"restoreImage",value:function value(e){if(!this.webViewer||!this.editorViewer)return!1;if(!this.bChanged)return!1;var t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex();if(CL(e)||(i=this.webViewer.myViewer.getIndexByUid(e)),t<=0||i<0)return!1;var r=this.webViewer.webViewerInitConfig.imageEditorServerCallback;if(this.workMode&&r&&ML(null==r?void 0:r.restore)){var n=e||this.webViewer.getCurrentImgUUid();r.restore(n);}else this.editorViewer.reset(i),this.webViewer.myViewer.resized();return this.setChangedState(!1),this.updateState(),this.webViewer.clearSelectedAreas(),!0;}},{key:"first",value:function value(){var e=this;this.bChanged?this.showSaveDialog(function(){e.goToPage(0);},this.webViewer.getCurrentImgUUid()):this.goToPage(0);}},{key:"last",value:function value(){var e=this,t=this.webViewer.getHowManyImagesInBuffer()-1;this.bChanged?this.showSaveDialog(function(){e.goToPage(t);},this.webViewer.getCurrentImgUUid()):this.goToPage(t);}},{key:"go",value:function value(e){var t=this;this.bChanged?this.showSaveDialog(function(){t.goToPage(e);},this.webViewer.getCurrentImgUUid()):this.goToPage(e);}},{key:"goToPage",value:function value(e){var t=this;if(!this.webViewer||!this.editorViewer)return!1;var i=this.webViewer.getHowManyImagesInBuffer(),r=this.webViewer.getCurrentIndex();return!(i<=0||r<0||!this.bShowImageEditor||CL(e)||-1===e||(this.bChanged?this.showSaveDialog(function(){t.editorViewer.gotoPage(e),t.updateState();},this.webViewer.getCurrentImgUUid()):(this.editorViewer.gotoPage(e),this.updateState()),0));}},{key:"selectPages",value:function value(e){var t=this,i=this.webViewer.getHowManyImagesInBuffer();return jR(e).call(e,function(e){return e>i-1;})?(this.webViewer.setError("ParameterOutRange"),!1):(this.bChanged?this.showSaveDialog(function(){t.webViewer.myViewer.setSelectedIndexes(e),t.updateState();},this.webViewer.getCurrentImgUUid()):(this.webViewer.myViewer.setSelectedIndexes(e),this.updateState()),!0);}},{key:"closeImageEditor",value:function value(){var e=this;0!==this.webViewer.getHowManyImagesInBuffer()&&this.bChanged?this.showSaveDialog(function(){e.close();},this.webViewer.getCurrentImgUUid()):this.close();}},{key:"dispose",value:function value(){this.bChanged&&this.saveImage(this.webViewer.getCurrentImgUUid()),this.close();}},{key:"printImage",value:(d=mb(vb().mark(function e(){var t,i,r,n,o,a,s,u,l;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.webViewer&&this.editorViewer){e.next=2;break;}return e.abrupt("return",!1);case 2:if(t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex(),!(t<=0||i<0)){e.next=5;break;}return e.abrupt("return",!1);case 5:return r=this.editorViewer.getCurrentTab(),n=r.currentPage,o=n.realTimeWidth,a=n.realTimeHeight,s=n.uid,u="",e.next=9,this.webViewer.myDvs.getImageData(s,{type:"blob"});case 9:if(l=e.sent,!zL()){e.next=16;break;}return e.next=13,new uB(function(e){var t=new FileReader();t.onload=function(){return e(t.result);},t.readAsDataURL(l);});case 13:u=e.sent,e.next=17;break;case 16:u=vN(l).data;case 17:return e.abrupt("return",(function(e,t){var i,r="";r=lS(t="".concat(r,'
');var n="".concat(Dynamsoft.DWT.ResourcesPath,"/src/dynamsoft.webtwain.css"),o=["alwaysRaised=yes,z-look=yes,top=0,left=0,toolbar=no,menubar=no,location=no,status=no,width=",0,",height=",0].join(""),a=window.open("about:blank","_blank",o),s=["",'','',r,""].join("");a&&(a.document.write(s),a.document.close(),a.focus(),(i=a.document.body)&&(i.onload=function(){a&&a.print();}));}({url:u,width:Math.floor(o),height:Math.floor(a)}),this.updateState(),!0));case 18:case"end":return e.stop();}},e,this);})),function(){return d.apply(this,arguments);})},{key:"rotateLeft",value:(h=mb(vb().mark(function e(){var t,i,r;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex(),!(t<=0||i<0)){e.next=3;break;}return e.abrupt("return",!1);case 3:if(e.t0=!1===this.bChanged&&this.workMode,!e.t0){e.next=7;break;}return e.next=7,this.saveToServerBeforeEdit();case 7:return r=this.webViewer.webViewerInitConfig.imageEditorServerCallback,e.abrupt("return",(this.workMode&&r&&ML(null==r?void 0:r.rotateLeft)?null==r||r.rotateLeft():this.editorViewer.rotate(-90,i),this.setChangedState(!0),this.updateState(),this.webViewer.clearSelectedAreas(),!0));case 9:case"end":return e.stop();}},e,this);})),function(){return h.apply(this,arguments);})},{key:"rotateInner",value:(c=mb(vb().mark(function e(){var t,i,r,n,o,a,s;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=document.getElementById("dvsImageEditorKeepSize"),i=document.getElementById("dvsImageEditorRotateAngle"),r=$S(i.value,10),n=this.webViewer.getHowManyImagesInBuffer(),o=this.webViewer.getCurrentIndex(),!(n<=0||o<0)){e.next=3;break;}return e.abrupt("return",!1);case 3:if(e.t0=!1===this.bChanged&&this.workMode,!e.t0){e.next=7;break;}return e.next=7,this.saveToServerBeforeEdit();case 7:return a=this.webViewer.webViewerInitConfig.imageEditorServerCallback,this.workMode&&a&&ML(null==a?void 0:a.rotate)?(s=document.getElementById("dvsImageEditorInterpolation"),null==a||a.rotate(r,s.selectedIndex+1,t.checked)):this.webViewer.rotateInner(o,r,t.checked),e.abrupt("return",(this.setChangedState(!0),this.closeRotateDialog(),this.updateState(),this.webViewer.clearSelectedAreas(),this.lastRotateAngle=r,this.lastRotateKeepSize=t.checked,!0));case 10:case"end":return e.stop();}},e,this);})),function(){return c.apply(this,arguments);})},{key:"rotateRight",value:(l=mb(vb().mark(function e(){var t,i,r,n;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=this.webViewer.getHowManyImagesInBuffer(),r=this.webViewer.getCurrentIndex(),!(i<=0||r<0)){e.next=3;break;}return e.abrupt("return",!1);case 3:if(e.t0=!1===this.bChanged&&this.workMode,!e.t0){e.next=7;break;}return e.next=7,this.saveToServerBeforeEdit();case 7:return n=this.webViewer.webViewerInitConfig.imageEditorServerCallback,e.abrupt("return",(this.workMode&&n&&ML(null==n?void 0:n.rotateRight)?null==n||n.rotateRight():null===(t=this.editorViewer)||void 0===t||t.rotate(90,r),this.setChangedState(!0),this.updateState(),this.webViewer.clearSelectedAreas(),!0));case 9:case"end":return e.stop();}},e,this);})),function(){return l.apply(this,arguments);})},{key:"deskew",value:(u=mb(vb().mark(function e(){var t,i,r,n,o,a,s,u,l=this;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex(),!(t<=0||i<0)){e.next=3;break;}return e.abrupt("return",!1);case 3:if(r=this.webViewer.webViewerInitConfig,n=r.imageEditorEvents,o=r.imageEditorServerCallback,e.t0=!1===this.bChanged&&this.workMode,!e.t0){e.next=8;break;}return e.next=8,this.saveToServerBeforeEdit();case 8:if(!this.deskewStarted){e.next=10;break;}return e.abrupt("return",!1);case 10:if(this.deskewStarted=!0,this.updateDeskewState(!1),!(this.workMode&&o&&ML(null==o?void 0:o.deskew))){e.next=14;break;}o.deskew(),this.setChangedState(!0),this.deskewStarted=!1,this.updateDeskewState(!0),e.next=22;break;case 14:if(n&&ML(null==n?void 0:n.deskew)){e.next=16;break;}return e.abrupt("return",!1);case 16:return a=this.webViewer.getCurrentImgUUid(),s=this.webViewer.getCurrentIndex(),e.next=20,this.webViewer.myDvs.getImageData(a,{type:"blob",min:!0});case 20:u=e.sent,n.deskew(u,function(e){l.webViewer.rotateInner(s,e,!0),l.setChangedState(!0),l.deskewStarted=!1,l.updateDeskewState(!0),l.updateSaveAndRestoreBtn();});case 22:return e.abrupt("return",(this.updateState(),!0));case 23:case"end":return e.stop();}},e,this);})),function(){return u.apply(this,arguments);})},{key:"cropImage",value:(s=mb(vb().mark(function e(){var t,i,r,n,o,a,s,u,l;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.bCrop){e.next=2;break;}return e.abrupt("return",!1);case 2:if(t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex(),!(t<=0||i<0)){e.next=5;break;}return e.abrupt("return",!1);case 5:if(1===(r=this.editorViewer.getCropBoxes()).length){e.next=8;break;}return e.abrupt("return",!1);case 8:if(n=r[0],o=n.left,a=n.top,s=n.width,u=n.height,e.t0=!1===this.bChanged&&this.workMode,!e.t0){e.next=13;break;}return e.next=13,this.saveToServerBeforeEdit();case 13:return l=this.webViewer.webViewerInitConfig.imageEditorServerCallback,e.abrupt("return",(this.workMode&&l&&ML(null==l?void 0:l.crop)?l.crop(n):this.editorViewer.crop(i,o,a,s,u),this.setChangedState(!0),this.updateState(),this.webViewer.clearSelectedAreas(),!0));case 15:case"end":return e.stop();}},e,this);})),function(){return s.apply(this,arguments);})},{key:"cutImage",value:(a=mb(vb().mark(function e(){var t,i,r,n,o,a,s,u,l;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.bErase){e.next=2;break;}return e.abrupt("return",!1);case 2:if(t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex(),!(t<=0||i<0)){e.next=5;break;}return e.abrupt("return",!1);case 5:if(1===(r=this.editorViewer.getCropBoxes()).length){e.next=8;break;}return e.abrupt("return",!1);case 8:if(n=r[0],o=n.left,a=n.top,s=n.width,u=n.height,e.t0=!1===this.bChanged&&this.workMode,!e.t0){e.next=13;break;}return e.next=13,this.saveToServerBeforeEdit();case 13:return l=this.webViewer.webViewerInitConfig.imageEditorServerCallback,e.abrupt("return",(this.workMode&&l&&ML(null==l?void 0:l.erase)?l.erase(n):this.editorViewer.erase(i,o,a,s,u,this.cutColor),this.setChangedState(!0),this.updateState(),this.webViewer.clearSelectedAreas(),!0));case 15:case"end":return e.stop();}},e,this);})),function(){return a.apply(this,arguments);})},{key:"changeImageSizeInner",value:(o=mb(vb().mark(function e(){var t,i,r,n,o,a,s,u;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex(),!(t<=0||i<0)){e.next=3;break;}return e.abrupt("return",!1);case 3:if(r=document.getElementById("dvsImageEditorChangeH"),n=document.getElementById("dvsImageEditorChangeW"),o=$S(r.value,10),a=$S(n.value,10),e.t0=!1===this.bChanged&&this.workMode,!e.t0){e.next=8;break;}return e.next=8,this.saveToServerBeforeEdit();case 8:return s=this.webViewer.webViewerInitConfig.imageEditorServerCallback,this.workMode&&s&&ML(null==s?void 0:s.changeImageSize)?(u=document.getElementById("dvsImageEditorInterpolation"),s.changeImageSize(a,o,u.selectedIndex+1)):this.editorViewer.changePageSize(i,a,o),e.abrupt("return",(this.setChangedState(!0),this.updateState(),this.closeChangeSizeDialog(),this.webViewer.clearSelectedAreas(),!0));case 11:case"end":return e.stop();}},e,this);})),function(){return o.apply(this,arguments);})},{key:"flipImage",value:(n=mb(vb().mark(function e(){var t,i,r;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex(),!(t<=0||i<0)){e.next=3;break;}return e.abrupt("return",!1);case 3:if(e.t0=!1===this.bChanged&&this.workMode,!e.t0){e.next=7;break;}return e.next=7,this.saveToServerBeforeEdit();case 7:return r=this.webViewer.webViewerInitConfig.imageEditorServerCallback,e.abrupt("return",(this.workMode&&r&&ML(null==r?void 0:r.flip)?r.flip():this.editorViewer.flip(i),this.setChangedState(!0),this.updateState(),this.webViewer.clearSelectedAreas(),!0));case 9:case"end":return e.stop();}},e,this);})),function(){return n.apply(this,arguments);})},{key:"mirrorImage",value:(r=mb(vb().mark(function e(){var t,i,r;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex(),!(t<=0||i<0)){e.next=3;break;}return e.abrupt("return",!1);case 3:if(e.t0=!1===this.bChanged&&this.workMode,!e.t0){e.next=7;break;}return e.next=7,this.saveToServerBeforeEdit();case 7:return r=this.webViewer.webViewerInitConfig.imageEditorServerCallback,e.abrupt("return",(this.workMode&&r&&ML(null==r?void 0:r.mirror)?r.mirror():this.editorViewer.mirror(i),this.setChangedState(!0),this.updateState(),this.webViewer.clearSelectedAreas(),!0));case 9:case"end":return e.stop();}},e,this);})),function(){return r.apply(this,arguments);})},{key:"saveImageAsync",value:(i=mb(vb().mark(function e(){var t,i,r,n,o,a,s;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.editorViewer){e.next=3;break;}return t=this.bDispose?"ImageEditorDispose":"ImageEditorNotExist",e.abrupt("return",(this.webViewer.setError(t),uB.reject("The ImageEditor object has been disposed.")));case 3:if(this.bChanged||!this.workMode){e.next=5;break;}return e.abrupt("return",uB.resolve());case 5:if(this.bChanged){e.next=7;break;}return e.abrupt("return",uB.resolve());case 7:if(i=this.webViewer.webViewerInitConfig,r=i.viewerEvents,n=i.imageEditorServerCallback,o=this.webViewer.getCurrentImgUUid(),this.setChangedState(!1),this.updateState(),this.webViewer.clearSelectedAreas(),this.workMode&&n&&ML(null==n?void 0:n.save)){e.next=16;break;}if(r&&ML(null==r?void 0:r.save)){e.next=11;break;}return e.abrupt("return",uB.reject());case 11:return e.next=13,this.webViewer.myDvs.getImageData(o,{type:"imageData"});case 13:return a=e.sent,s=Fk(Fk({},this.webViewer.bufferService.getMetadataByUid(o)),{},{width:Math.floor(a.width),height:Math.floor(a.height)}),e.abrupt("return",null==r?void 0:r.save(o,a.data.buffer,s,!0));case 16:return e.abrupt("return",(n.save(o),uB.resolve()));case 17:case"end":return e.stop();}},e,this);})),function(){return i.apply(this,arguments);})},{key:"saveImage",value:(t=mb(vb().mark(function e(t){var i,r,n,o,a,s,u,l;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.editorViewer){e.next=2;break;}return e.abrupt("return");case 2:if(this.bChanged){e.next=4;break;}return e.abrupt("return");case 4:if(i=this.webViewer.webViewerInitConfig,r=i.viewerEvents,n=i.imageEditorServerCallback,o=t||this.webViewer.getCurrentImgUUid(),this.setChangedState(!1),this.updateState(),this.webViewer.clearSelectedAreas(),!(this.workMode&&n&&ML(null==n?void 0:n.save))){e.next=9;break;}n.save(o),e.next=23;break;case 9:if(r&&ML(null==r?void 0:r.save)){e.next=11;break;}return e.abrupt("return");case 11:return e.next=13,this.webViewer.myDvs.getImageData(o,{type:"imageData"});case 13:return u=e.sent,l=Fk(Fk({},(null===(a=this.webViewer)||void 0===a||null===(s=a.bufferService)||void 0===s?void 0:s.getMetadataByUid(o))||{}),{},{width:Math.floor(u.width),height:Math.floor(u.height)}),e.prev=15,e.next=18,null==r?void 0:r.save(o,u.data.buffer,l,!0);case 18:e.next=23;break;case 20:e.prev=20,e.t0=e.catch(15),this.setChangedState(!0),this.updateState();case 23:case"end":return e.stop();}},e,this,[[15,20]]);})),function(e){return t.apply(this,arguments);})},{key:"saveToServerBeforeEdit",value:(e=mb(vb().mark(function e(){var t,i,r;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.webViewer.webViewerInitConfig.imageEditorServerCallback,i=this.webViewer.myViewer,!(this.workMode&&t&&ML(null==t?void 0:t.save))){e.next=8;break;}return i.updateViewerConfig({enableEmitPageRendered:!1}),this.webViewer.bEmitBufferChanged=!1,r=this.webViewer.getCurrentImgUUid(),e.next=6,t.save(r);case 6:this.webViewer.bEmitBufferChanged=!0,i.updateViewerConfig({enableEmitPageRendered:!0});case 8:case"end":return e.stop();}},e,this);})),function(){return e.apply(this,arguments);})},{key:"bufferChanged",value:function value(e){return this.curIndex!==this.webViewer.getCurrentIndex()&&(this.curIndex=this.webViewer.getCurrentIndex(),this.updateState()),"shift"===e.operation&&this.bChanged||"add"===e.operation&&this.bChanged?(this.showSaveDialog(function(){},e.beforeStatus.currentUid),!1):("remove"===e.operation&&this.bChanged&&this.bChangedUid===e.beforeStatus.currentUid&&(this.setChangedState(!1),this.updateState()),!0);}},{key:"click",value:function value(){this.hideImageEditorDialog();var e=this.editorViewer.getViewerConfig();e.zoomi.minZoom;this.updateZoomInState(n),this.updateZoomOutState(o);}}},{key:"showMask",value:function value(){var e=document.createElement("div");e.className="dvs-imageEditor-mask",this.editorViewer.rootDom.appendChild(e);}},{key:"closeMask",value:function value(){var e=document.querySelector(".dvs-imageEditor-mask");e&&e.parentNode.removeChild(e);}},{key:"createSaveDialog",value:function value(){var e=this.editorSetting.dialogText,t=null==e?void 0:e.saveChangedImage;(CL(e)||CL(null==e?void 0:e.saveChangedImage))&&(t=CO.saveChangedImage);var i=gq({tag:"div",className:"dvs-imageEditor-saveDlg",children:[{tag:"div",className:"dvs-imageEditor-saveDlg-header",children:[{tag:"i",className:"dynamsoft-dialog-close"}]},{tag:"div",className:"dvs-imageEditor-saveDlg-box",children:[{tag:"div",textContent:t[0]},{tag:"div",className:"dvs-imageEditor-saveDlg-btnGroup",children:[{tag:"input",className:"dynamsoft_btnSave",attributes:{type:"button",value:t[1]}},{tag:"input",className:"dynamsoft_btnCancel",attributes:{type:"button",value:t[2]}}]}]}]});return i.style.width=this.bMobile?"300px":"420px",i;}},{key:"showSaveDialog",value:function value(e,t){var i=this;if(document.querySelector(".dvs-imageEditor-saveDlg")||!this.bChanged)return!1;if(!this.promoteSaveChange)return this.saveImage(t),e(),!0;this.showMask();var r=this.createSaveDialog();this.editorViewer.rootDom.appendChild(r);var n=document.querySelector(".dynamsoft_btnSave"),o=document.querySelector(".dynamsoft_btnCancel"),a=document.querySelector(".dynamsoft-dialog-close");return a&&(a.onclick=function(){i.closeSaveDialog(),i.closeMask();}),n&&(n.onclick=mb(vb().mark(function r(){return vb().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,i.saveImage(t);case 2:i.closeSaveDialog(),i.closeMask(),e();case 5:case"end":return r.stop();}},r);}))),o&&(o.onclick=function(){i.restoreImage(t),i.closeSaveDialog(),i.closeMask(),e();}),!0;}},{key:"closeSaveDialog",value:function value(){var e=document.querySelector(".dvs-imageEditor-saveDlg");e&&e.parentNode.removeChild(e);}},{key:"createRotateDialog",value:function value(){var e=this.editorSetting.dialogText,t=null==e?void 0:e.dlgRotateAnyAngle;(CL(e)||CL(null==e?void 0:e.dlgRotateAnyAngle))&&(t=CO.dlgRotateAnyAngle);var i=!0===this.lastRotateKeepSize?"checked":"",r=this.workMode?"flex":"none",n=gq({tag:"div",children:[{tag:"div",children:[{tag:"span",textContent:t[0]},{tag:"input",attributes:{id:"dvsImageEditorRotateAngle",type:"number",value:this.lastRotateAngle}}]},{tag:"div",attributes:{style:"display:".concat(r)},children:[{tag:"span",textContent:t[1]},{tag:"select",attributes:{size:"1",id:"dvsImageEditorInterpolation"},children:[{tag:"option",attributes:{value:"1"},textContent:"NearestNeighbor"},{tag:"option",attributes:{value:"2"},textContent:"Bilinear"},{tag:"option",attributes:{value:"3"},textContent:"Bicubic"}]}]},{tag:"div",children:[{tag:"label",children:[Fk({tag:"input",attributes:{type:"checkbox",id:"dvsImageEditorKeepSize"}},i&&{checked:"checked"}),{tag:"span",textContent:t[2]}]}]},{tag:"div",children:[{tag:"input",attributes:{id:"dvsImageEditorRotateOk",type:"button",value:t[3]}},{tag:"input",attributes:{id:"dvsImageEditorRotateCancel",type:"button",value:t[4]}}]}]});return n.className="dvs-imageEditor-rotateBox",n.id="dvsImageEditorRotateBox",n;}},{key:"showRotateDialog",value:function value(){var e=this;if(!document.getElementById("dvsImageEditorRotateBox")){var t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex();if(!(t<=0||i<0)){var r=document.getElementById("rotate".concat(this.editorViewer.postfix));if(r){var n=this.createRotateDialog();r.appendChild(n);var o=r.getBoundingClientRect(),a=o.width,s=o.height;n.style.left=a/2+"px",n.style.top=s/2+"px";var u=document.getElementById("dvsImageEditorRotateOk"),l=document.getElementById("dvsImageEditorRotateCancel");this.bindStopPropagation("dvsImageEditorRotateBox"),u&&(u.onclick=function(t){e.rotateInner();}),l&&(l.onclick=function(t){e.closeRotateDialog();});}}}}},{key:"closeRotateDialog",value:function value(){var e=document.getElementById("dvsImageEditorRotateBox");e&&e.parentNode.removeChild(e);}},{key:"createChangeSizeDialog",value:function value(e,t){var i=this.editorSetting.dialogText,r=null==i?void 0:i.dlgChangeImageSize;(CL(i)||CL(null==i?void 0:i.dlgChangeImageSize))&&(r=CO.dlgChangeImageSize);var n=this.workMode?"flex":"none",o=gq({tag:"div",children:[{tag:"div",children:[{tag:"span",textContent:r[0]},{tag:"div",children:[{tag:"input",attributes:{id:"dvsImageEditorChangeH",type:"number",value:t}},{tag:"span",textContent:"pixel"}]}]},{tag:"div",attributes:{style:"margin-top:10px"},children:[{tag:"span",textContent:r[1]},{tag:"div",children:[{tag:"input",attributes:{id:"dvsImageEditorChangeW",type:"number",value:e}},{tag:"span",textContent:"pixel"}]}]},{tag:"div",attributes:{style:"display:".concat(n)},children:[{tag:"span",textContent:r[2]},{tag:"select",attributes:{size:"1",id:"dvsImageEditorInterpolation"},children:[{tag:"option",attributes:{value:"1"},textContent:"NearestNeighbor"},{tag:"option",attributes:{value:"2"},textContent:"Bilinear"},{tag:"option",attributes:{value:"3"},textContent:"Bicubic"}]}]},{tag:"div",children:[{tag:"input",attributes:{id:"dvsImageEditorChangeSizeOk",type:"button",value:r[3]}},{tag:"input",attributes:{id:"dvsImageEditorChangeSizeCancel",type:"button",value:r[4]}}]}]});return o.className="dvs-imageEditor-changeSizeBox",o.id="dvsImageEditorChangeSizeBox",o;}},{key:"showChangeSizeDialog",value:function value(){var e=this;if(!document.getElementById("dvsImageEditorChangeSizeBox")){var t=this.webViewer.getHowManyImagesInBuffer(),i=this.webViewer.getCurrentIndex();if(!(t<=0||i<0)){var r=document.getElementById("changeImageSize".concat(this.editorViewer.postfix));if(r){var n=this.editorViewer.getCurrentTab().currentPage,o=n.realTimeWidth,a=n.realTimeHeight,s=this.createChangeSizeDialog(Math.floor(o),Math.floor(a));r.appendChild(s);var u=r.getBoundingClientRect(),l=u.width,c=u.height;s.style.left=l/2+"px",s.style.top=c/2+"px";var h=document.getElementById("dvsImageEditorChangeSizeOk"),d=document.getElementById("dvsImageEditorChangeSizeCancel");this.bindStopPropagation("dvsImageEditorChangeSizeBox"),h&&(h.onclick=function(t){fN(t),e.changeImageSizeInner();}),d&&(d.onclick=function(t){fN(t),e.closeChangeSizeDialog();});}}}}},{key:"closeChangeSizeDialog",value:function value(){var e=document.getElementById("dvsImageEditorChangeSizeBox");e&&e.parentNode.removeChild(e);}}]);var e,t,i,r,n,o,a,s,u,l,c,h,d;}();function gq(e){var t=e.tag,i=e.className,r=void 0===i?"":i,n=e.attributes,o=void 0===n?{}:n,a=e.textContent,s=void 0===a?"":a,u=e.children,l=void 0===u?[]:u,c=document.createElement(t);r&&(c.className=r);for(var h=0,d=oB(o);hf)switch(l.unit){case"%":v="".concat(Math.floor(f/c*100),"%");break;case"em":v="".concat(Math.floor(f/d),"em");break;case"px":v="".concat(f,"px");break;default:v=f;}return v;}var wq=function(){return Yk(function e(t,i){if(Xk(this,e),Wk(this,"stretchBarColor","black"),Wk(this,"bHide",!0),Wk(this,"pageMargin",10),Wk(this,"bSingleMode",!1),Wk(this,"bDispose",!1),Wk(this,"webViewer",void 0),Wk(this,"myThumbnailViewer",void 0),Wk(this,"thbStretchBar",null),Wk(this,"enableResizing",!1),Wk(this,"enableProps",["enableDragPage","enableResizing","autoSelectTopPage"]),Wk(this,"keyboardControl",!0),this.webViewer=t,i){var r=i.removeBtn;CL(null==r?void 0:r.removeMarkColor)||(r.checkMarkColor=r.removeMarkColor),CL(null==r?void 0:r.removeMarkLineWidth)||(r.checkMarkLineWidth=r.removeMarkLineWidth);var n=function(e){var t,i,r,n,o,a,s=e.size,u=e.pageMargin,l=e.checkbox,c=e.pageNumber,h=e.removeBtn,d=e.scrollDirection,f={};return $k(t=["showThumbnail","allowKeyboardControl","allowPageDragging","allowResizing","autoChangeIndex"]).call(t,function(t){var i;i=e[t],!CL(i)&&DL(i)&&(f[t]=e[t]);}),$k(i=["columns","rows"]).call(i,function(t){(function(e){var t=FO(e);return!(CL(t)||t.value<0);})(e[t])&&(f[t]=e[t]);}),$k(r=["background","hoverPageBackground","pageBackground","placeholderBackground","selectedPageBackground"]).call(r,function(t){TX(e[t])&&(f[t]=e[t]);}),$k(n=["border","hoverPageBorder","pageBorder","selectedPageBorder"]).call(n,function(t){IX(e[t])&&(f[t]=e[t]);}),$k(o=["location"]).call(o,function(t){var i;i=e[t],!CL(i)&&TL(i)&&(f[t]=e[t]);}),function(e){var t=FO(e);return!CL(t)&&!(t.value>100&&"%"===t.unit||t.value<0);}(s)&&(f.size=s),EX(u)&&(f.pageMargin=u),CL(l)||(f.checkbox=l),CL(c)||(f.pageNumber=c),CL(h)||(f.removeBtn=h),-1!==OI(a=["vertical","horizontal"]).call(a,d)&&(f.scrollDirection=d),f;}(i);i=this.mergeThumbSettings(n);}else i=_SL(xO);this.myThumbnailViewer=this.webViewer.myViewer.createThumbnail(i),this.bDispose=!1,this.pageMargin=this.myThumbnailViewer.getThbConfigByName("gap"),this.webViewer.bThumbnailDispose=!1,this.setIfAutoScroll(this.webViewer.getIfAutoScroll()),i.show&&(this.bHide=!1,this.setPageMargin(this.pageMargin)),this.bindDefaultEvent(),this.initStretchBar(),this.allowResize=i.enableResizing;},[{key:"setDefaultError",value:function value(){var e=this.bDispose?"ThumbnailViewerDispose":"ThumbnailViewerNotExist";this.webViewer.setError(e);}},{key:"getLegalBorder",value:function value(e,t){var i,r;if(CL(e))return"";if(""===e)return"";var n=document.createElement("div");n.style.border=e;var o=n.style,a=o.borderWidth,s=o.borderColor,u=o.borderStyle;return lS(i=lS(r="".concat(""===a||"initial"===a||"medium"===a?"1px":a," ")).call(r,"initial"===u||"none"===u?"solid":u," ")).call(i,"initial"===s||"currentcolor"===s?t:s);}},{key:"mergeThumbSettings",value:function value(e){var t="horizontal",i=-1;switch(e.location||"left"){case"right":t="horizontal",i=1;break;case"top":t="vertical",i=-1;break;case"bottom":t="vertical",i=1;}var r=e.showThumbnail,n=e.size,o=e.columns,a=e.rows,s=e.autoChangeIndex,u=e.allowPageDragging,l=e.allowKeyboardControl,c=e.allowResizing,h=e.pageMargin,d=e.scrollDirection,f=e.background,v=e.border,g=e.hoverPageBackground,m=e.hoverPageBorder,y=e.pageBackground,p=e.pageBorder,w=e.placeholderBackground,b=e.selectedPageBackground,k=e.selectedPageBorder,S=h,x=h;a===o&&1===a&&(x=0,this.bSingleMode=!0);var C={location:t,sequence:i,show:r,size:n,columns:o,rows:a,autoSelectTopPage:s,enableDragPage:u,enableKeyboardControl:l,enableResizing:c,gap:S,margin:x,scrollDirection:d,thumbnailStyle:{background:f||this.webViewer.getBackground(),border:this.getLegalBorder(v,"rgba(0,0,0,0)")||""},hoveredPageStyle:{background:g||"rgb(239, 246, 253)",border:this.getLegalBorder(m,"rgb(238, 238, 238)")||"1px solid rgb(238, 238, 238)"},pageStyle:{background:y||"transparent",border:this.getLegalBorder(p,"rgb(238, 238, 238)")||"1px solid rgb(238, 238, 238)"},placeholderStyle:{background:w||"rgb(251, 236, 136)"},selectedPageStyle:{background:b||"rgb(199, 222, 252)",border:this.getLegalBorder(k,"rgb(125, 162, 206)")||"1px solid rgb(125, 162, 206)"},checkboxStyle:Fk(Fk({},this.webViewer.myViewer.getViewerConfig().checkboxStyle),oN(e.checkbox)),pageNumberStyle:Fk(Fk({},this.webViewer.myViewer.getViewerConfig().pageNumberStyle),oN(e.pageNumber)),removeBtnStyle:Fk(Fk({},this.webViewer.myViewer.getViewerConfig().removeBtnStyle),oN(e.removeBtn)),multiselectMode:1===this.webViewer.getMultiSelectMode()},V={};return NL(_SL(xO),V),NL(oN(C),V),V;}},{key:"bindDefaultEvent",value:function value(){this.myThumbnailViewer&&this.webViewer&&(this.bindDefaultKeyDown(),this.bindDefaultContextmenu());}},{key:"bindDefaultKeyDown",value:function value(){var e=this;this.myThumbnailViewer.on("keydown",function(t){if(e.keyboardControl)return"ArrowUp"===t.key||"Up"===t.key?(t.preventDefault(),void e.webViewer.previous()):void("ArrowDown"!==t.key&&"Down"!==t.key||(t.preventDefault(),e.webViewer.next()));});}},{key:"bindDefaultContextmenu",value:function value(){var e=this;this.myThumbnailViewer.on("contextmenu",function(t,i){e.webViewer.hideContextmenu&&i.preventDefault();});}},{key:"initStretchBar",value:function value(){var e=document.createElement("div");e.id="thbStretchBar",e.style.display="none",this.thbStretchBar=e;var t=this.getLocation(),i=this.myThumbnailViewer.innerViewer.rootDom;e.className="top"!==t&&"bottom"!==t?"dvs-thbStretchBarH dvs-thbStretchBar-".concat(t):"dvs-thbStretchBarV dvs-thbStretchBar-".concat(t),i.appendChild(e),this.bindStretchEvent(e);}},{key:"bindStretchEvent",value:function value(e){var t=this,i=0,r=0,n=!1,o=this.getLocation(),a=0,s=0,u=0,l=0,c=function c(_c3){if(t.myThumbnailViewer){var h=t.myThumbnailViewer.innerViewer.rootDom,d=t.webViewer.myViewer.rootDom,f=getComputedStyle(h),v=getComputedStyle(d);u=HO(f.width).value,l=HO(f.height).value,a=HO(v.width).value,s=HO(v.height).value,i=_c3.clientX,r=_c3.clientY,n=!0,o=t.getLocation(),e.style.background=t.stretchBarColor;}},h=function h(c){if(n&&t.myThumbnailViewer){var h="left"===o?c.clientX-i:i-c.clientX,d="top"===o?c.clientY-r:r-c.clientY;"right"===o&&t.thbStretchBar.classList.remove("dvs-thbStretchBar-right"),"bottom"===o&&t.thbStretchBar.classList.remove("dvs-thbStretchBar-bottom");var f=u+h;"top"!==o&&"bottom"!==o||(f=l+d),f<0&&(f=0),("left"===o||"right"===o)&&f>a&&(f=a),("top"===o||"bottom"===o)&&f>s&&(f=s),e.style[o]="".concat(f,"px");}},d=function d(i){if(n&&t.myThumbnailViewer){n=!1;var r,a=t.myThumbnailViewer.getThbConfigByName("size");switch(o){case"top":""!==e.style.top&&(r=HO(e.style.top),e.style.top="");break;case"bottom":""!==e.style.bottom&&(r=HO(e.style.bottom),e.style.bottom="",t.thbStretchBar.classList.add("dvs-thbStretchBar-bottom"));break;case"right":""!==e.style.right&&(r=HO(e.style.right),e.style.right="",t.thbStretchBar.classList.add("dvs-thbStretchBar-right"));break;default:""!==e.style.left&&(r=HO(e.style.left),e.style.left="");}e.style.background="",r&&a!==r.value&&(t.myThumbnailViewer.updateThbConfig({size:Math.floor(r.value)}),t.emitThumbnailResize(),t.resized());}};window.PointerEvent?(e.addEventListener("pointerdown",c),document.addEventListener("pointermove",h),document.addEventListener("pointerup",d)):window.MSPointerEvent?(e.addEventListener("MSPointerDown",c),document.addEventListener("MSPointerMove",h),document.addEventListener("MSPointerUp",d)):(e.addEventListener("mousedown",c),document.addEventListener("mousemove",h),document.addEventListener("mouseup",d));}},{key:"showThumbnail",get:function get(){return this.myThumbnailViewer.getThbConfig().show;},set:function set(e){this.showThumbnail===e&&!0===e||(this.bHide=!e,this.myThumbnailViewer.updateThbConfig({show:e}),this.setPageMargin(this.pageMargin));}},{key:"allowResize",get:function get(){return this.enableResizing;},set:function set(e){this.enableResizing=e,this.thbStretchBar.style.display=!0===e?"":"none";}},{key:"updateThumbnailConfig",value:function value(e){this.myThumbnailViewer.updateThbConfig(e);}},{key:"e",value:function value(){this.webViewer.setError("Successful");}},{key:"setError",value:function value(e){this.webViewer.setError(e);}},{key:"setBorder",value:function value(e){var t;if(!this.myThumbnailViewer)return!1;var i=this.getLocation(),r=this.myThumbnailViewer.innerViewer.defaultDom;if(!r)return!1;switch($k(t=["borderLeft","borderBottom","borderTop","borderRight"]).call(t,function(e){r.style[e]="";}),i){case"right":r.style.borderLeft=e;break;case"top":r.style.borderBottom=e;break;case"bottom":r.style.borderTop=e;break;default:r.style.borderRight=e;}return!0;}},{key:"getLocation",value:function value(){return this.myThumbnailViewer?"vertical"===this.myThumbnailViewer.getThbConfig().location?this.myThumbnailViewer.getThbConfig().sequence>0?"bottom":"top":this.myThumbnailViewer.getThbConfig().sequence>0?"right":"left":(this.setDefaultError(),"");}},{key:"setLocation",value:function value(e){var t=e||"left",i="horizontal",r=-1;if(this.myThumbnailViewer){switch(t){case"right":i="horizontal",r=1;break;case"top":i="vertical",r=-1;break;case"bottom":i="vertical",r=1;}this.myThumbnailViewer.updateThbConfig({location:i,sequence:r});var n=this.getLocation();return this.setBorder(this.webViewer.getBorder()),this.thbStretchBar.className="top"!==n&&"bottom"!==n?"dvs-thbStretchBarH dvs-thbStretchBar-".concat(n):"dvs-thbStretchBarV dvs-thbStretchBar-".concat(n),this.resized(),!0;}return this.setDefaultError(),!1;}},{key:"getSize",value:function value(){return this.myThumbnailViewer?this.myThumbnailViewer.getThbConfig().size:(this.setDefaultError(),!1);}},{key:"setSize",value:function value(e){return!/^((\d+em)|(\d+px)|(\d+%)|(\d+))$/.test(e)||e<0?(this.webViewer.setError("InvalidValue"),!1):e===this.myThumbnailViewer.getThbConfig().size||(this.myThumbnailViewer?(this.setPageMargin(this.pageMargin),this.myThumbnailViewer.updateThbConfig({size:e}),this.bHide?(this.show(),this.emitThumbnailResize(),this.hide()):this.emitThumbnailResize(),this.myThumbnailViewer.innerViewer.resized(),!0):(this.setDefaultError(),!1));}},{key:"getScrollDirection",value:function value(){return this.myThumbnailViewer?this.myThumbnailViewer.getThbConfig().scrollDirection:(this.setDefaultError(),!1);}},{key:"setScrollDirection",value:function value(e){return"horizontal"!==e&&(e="vertical"),this.myThumbnailViewer?(this.myThumbnailViewer.updateThbConfig({scrollDirection:e}),!0):(this.setDefaultError(),!1);}},{key:"getShowPageNumber",value:function value(){return this.myThumbnailViewer?"visible"===this.myThumbnailViewer.getThbConfig().pageNumberStyle.visibility:(this.setDefaultError(),!1);}},{key:"setShowPageNumber",value:function value(e){if(!DL(e))return this.webViewer.setError("InvalidValue"),!1;var t={visibility:e?"visible":"hidden"};return this.updatePageNumberStyle(t),!0;}},{key:"getShowCheckbox",value:function value(){return this.myThumbnailViewer?"visible"===this.myThumbnailViewer.getThbConfig().checkboxStyle.visibility:(this.setDefaultError(),!1);}},{key:"setShowCheckbox",value:function value(e){if(!DL(e))return this.webViewer.setError("InvalidValue"),!1;if(this.myThumbnailViewer){var t={visibility:e?"visible":"hidden"};this.updateCheckboxStyle(t);var i="visible"===t.visibility?1:0;return this.setMultiSelectMode(i),!0;}return this.setDefaultError(),!1;}},{key:"getShowRemoveBtn",value:function value(){return this.myThumbnailViewer?"visible"===this.myThumbnailViewer.getThbConfig().removeBtnStyle.visibility:(this.setDefaultError(),!1);}},{key:"setShowRemoveBtn",value:function value(e){if(!DL(e))return this.webViewer.setError("InvalidValue"),!1;if(this.myThumbnailViewer){var t={visibility:e?"visible":"hidden"};return this.updateRemoveBtnStyle(t),!0;}return this.setDefaultError(),!1;}},{key:"getPageMargin",value:function value(){if(this.myThumbnailViewer){var e=this.myThumbnailViewer.getThbConfig(),t=e.columns,i=e.rows;return t===i&&1===i?0:this.pageMargin;}return this.setDefaultError(),0;}},{key:"setPageMargin",value:function value(e){if(!/^((\d+em)|(\d+px)|(\d+%)|(\d+))$/.test(e)||e<0)return this.webViewer.setError("InvalidValue"),!1;this.pageMargin=e;var t=pq(e,this.myThumbnailViewer.innerViewer);return this.myThumbnailViewer?(this.myThumbnailViewer.updateThbConfig({gap:t}),this.bSingleMode||this.myThumbnailViewer.updateThbConfig({margin:t}),this.resized(),!0):(this.setDefaultError(),!1);}},{key:"getEnableProp",value:function value(e){var t;return-1!==OI(t=this.enableProps).call(t,e)&&("enableResizing"===e?this.allowResize:this.myThumbnailViewer?this.myThumbnailViewer.getThbConfigByName(e):(this.setDefaultError(),!1));}},{key:"setEnableProp",value:function value(e,t){var i;return-1!==OI(i=this.enableProps).call(i,e)&&(DL(t)?("enableResizing"===e&&(this.allowResize=t),this.myThumbnailViewer?(this.myThumbnailViewer.updateThbConfig(Wk({},e,t)),!0):(this.setDefaultError(),!1)):(this.webViewer.setError("InvalidValue"),!1));}},{key:"getThumbSetting",value:function value(e){return this.myThumbnailViewer?this.myThumbnailViewer.getThbConfig().thumbnailStyle[e]:(this.setDefaultError(),"");}},{key:"setThumbSetting",value:function value(e,t){if(this.myThumbnailViewer){var i=Wk({},e,t);return this.myThumbnailViewer.updateThbConfig({thumbnailStyle:i}),!0;}return this.setDefaultError(),!1;}},{key:"getPageSetting",value:function value(e){return this.myThumbnailViewer?this.myThumbnailViewer.getThbConfig().pageStyle[e]:(this.setDefaultError(),"");}},{key:"setPageSetting",value:function value(e,t){if(this.myThumbnailViewer){var i=Wk({},e,t);return this.myThumbnailViewer.updateThbConfig({pageStyle:i}),!0;}return this.setDefaultError(),!1;}},{key:"getHoverSetting",value:function value(e){return this.myThumbnailViewer?this.myThumbnailViewer.getThbConfig().hoveredPageStyle[e]:(this.setDefaultError(),"");}},{key:"setHoverSetting",value:function value(e,t){if(this.myThumbnailViewer){var i=Wk({},e,t);return this.myThumbnailViewer.updateThbConfig({hoveredPageStyle:i}),!0;}return this.setDefaultError(),!1;}},{key:"getSelectSetting",value:function value(e){return this.myThumbnailViewer?this.myThumbnailViewer.getThbConfig().selectedPageStyle[e]:(this.setDefaultError(),"");}},{key:"setSelectSetting",value:function value(e,t){if(this.myThumbnailViewer){var i=Wk({},e,t);return this.myThumbnailViewer.updateThbConfig({selectedPageStyle:i}),!0;}return this.setDefaultError(),!1;}},{key:"getPlaceholderSetting",value:function value(e){return this.myThumbnailViewer?this.myThumbnailViewer.getThbConfig().placeholderStyle[e]:(this.setDefaultError(),"");}},{key:"setPlaceholderSetting",value:function value(e,t){if(this.myThumbnailViewer){var i=Wk({},e,t);return this.myThumbnailViewer.updateThbConfig({placeholderStyle:i}),!0;}return this.setDefaultError(),!1;}},{key:"show",value:function value(){return this.myThumbnailViewer?(this.webViewer.myViewer.setViewMode(1,1),this.webViewer.setIfSinglePageMode(!0),this.myThumbnailViewer.show(),this.bHide=!1,this.setPageMargin(this.pageMargin),!0):(this.setDefaultError(),!1);}},{key:"hide",value:function value(){return this.myThumbnailViewer?(this.bHide=!0,this.myThumbnailViewer.hide(),!0):(this.setDefaultError(),!1);}},{key:"dispose",value:function value(){if(this.bDispose)return!0;var e=this.webViewer.myViewer.removeThumbnail(this.myThumbnailViewer);return this.webViewer.resized(),e&&(this.bDispose=!0,this.webViewer.bThumbnailDispose=!0,this.myThumbnailViewer=void 0,this.webViewer.thumbnailViewer=void 0),e;}},{key:"updateViewMode",value:function value(e){if(!e)return this.webViewer.setError("InvalidValue"),!1;if(this.myThumbnailViewer){var t=e.columns,i=e.rows,r=e.scrollDirection;if(i&&t){var n;if(i<0||t<0)return this.webViewer.setError("InvalidPropertyValue"),!1;this.myThumbnailViewer.setViewMode(i,t),i===t&&1===i?(this.bSingleMode=!0,this.myThumbnailViewer.updateThbConfig({margin:0})):(this.bSingleMode=!1,this.setPageMargin(this.pageMargin),this.myThumbnailViewer.updateThbConfig({margin:this.myThumbnailViewer.getThbConfig().gap})),r&&-1!==OI(n=["horizontal","vertical"]).call(n,r)&&this.myThumbnailViewer.updateThbConfig({scrollDirection:r});}return this.resized(),!0;}return this.setDefaultError(),!1;}},{key:"updateCheckboxStyle",value:function value(e){return this.myThumbnailViewer?(this.myThumbnailViewer.updateThbConfig({checkboxStyle:e}),!0):(this.setDefaultError(),!1);}},{key:"updatePageNumberStyle",value:function value(e){return this.myThumbnailViewer?(this.myThumbnailViewer.updateThbConfig({pageNumberStyle:e}),!0):(this.setDefaultError(),!1);}},{key:"updateRemoveBtnStyle",value:function value(e){if(this.myThumbnailViewer){var t=Fk({},e);return CL(null==e?void 0:e.removeMarkColor)||(t.checkMarkColor=null==e?void 0:e.removeMarkColor),CL(null==e?void 0:e.removeMarkLineWidth)||(t.checkMarkLineWidth=null==e?void 0:e.removeMarkLineWidth),this.myThumbnailViewer.updateThbConfig({removeBtnStyle:t}),!0;}return this.setDefaultError(),!1;}},{key:"on",value:function value(e,t){if(e)if(ML(t)){var i=e;switch(e){case"onDrop":i="drop";break;case"rightclick":i="contextmenu";break;case"resize":i="dwtResize";break;default:i=e;}this.myThumbnailViewer.on(i,t);}else this.webViewer.setError("CallbackNotAFunction");}},{key:"off",value:function value(e,t){if(e){var i=e;switch(e){case"onDrop":i="drop";break;case"rightclick":i="contextmenu";break;case"resize":i="dwtResize";break;default:i=e;}if(CL(t))return this.myThumbnailViewer.off(i),"keydown"===i&&this.bindDefaultKeyDown(),void("contextmenu"===i&&this.bindDefaultContextmenu());ML(t)?this.myThumbnailViewer.off(i,t):this.webViewer.setError("CallbackNotAFunction");}}},{key:"setIfAutoScroll",value:function value(e){return!!this.myThumbnailViewer&&(this.myThumbnailViewer.updateThbConfig({autoSelectLatest:e,autoScroll:e}),!0);}},{key:"setMultiSelectMode",value:function value(e){return BL(e)?this.myThumbnailViewer?(this.myThumbnailViewer.updateThbConfig({multiselectMode:1===e}),!0):(this.setDefaultError(),!1):(this.webViewer.setError("InvalidValue"),!1);}},{key:"emitThumbnailResize",value:function value(){if(this.myThumbnailViewer){var e=this.myThumbnailViewer.innerViewer.defaultDom;if(e){var t=e.getClientRects();if(!(t.length<1)){var i=t[0],r=i.width,n=i.height;this.myThumbnailViewer.innerViewer.emit("dwtResize",r,n);}}}}},{key:"resized",value:function value(){this.myThumbnailViewer&&this.myThumbnailViewer.innerViewer.resized();}},{key:"showFocusOutLine",value:function value(e){this.myThumbnailViewer&&this.myThumbnailViewer.innerViewer.context.setDisableFocusOutline(!e);}}]);}(),bq=function(){return Yk(function e(t,i){Xk(this,e),Wk(this,"inner",void 0),this.inner=new wq(t,i);},[{key:"location",get:function get(){return this.inner.e(),this.inner.getLocation();},set:function set(e){this.inner.e(),this.inner.setLocation(e);}},{key:"size",get:function get(){return this.inner.e(),this.inner.getSize();},set:function set(e){this.inner.e(),this.inner.setSize(e);}},{key:"scrollDirection",get:function get(){return this.inner.e(),this.inner.getScrollDirection();},set:function set(e){this.inner.e(),this.inner.setScrollDirection(e);}},{key:"showPageNumber",get:function get(){return this.inner.e(),this.inner.getShowPageNumber();},set:function set(e){this.inner.e(),this.inner.setShowPageNumber(e);}},{key:"showCheckbox",get:function get(){return this.inner.e(),this.inner.getShowCheckbox();},set:function set(e){this.inner.e(),this.inner.setShowCheckbox(e);}},{key:"showRemoveBtn",get:function get(){return this.inner.e(),this.inner.getShowRemoveBtn();},set:function set(e){this.inner.e(),this.inner.setShowRemoveBtn(e);}},{key:"pageMargin",get:function get(){return this.inner.e(),this.inner.getPageMargin();},set:function set(e){this.inner.e(),EX(e)?this.inner.setPageMargin(e):this.inner.setError("InvalidValue");}},{key:"border",get:function get(){return this.inner.e(),this.inner.getThumbSetting("border");},set:function set(e){this.inner.e(),IX(e)&&this.inner.setThumbSetting("border",e);}},{key:"background",get:function get(){return this.inner.e(),this.inner.getThumbSetting("background");},set:function set(e){this.inner.e(),BL(e)&&(e=VX(e)),TX(e)&&this.inner.setThumbSetting("background",e);}},{key:"pageBackground",get:function get(){return this.inner.e(),this.inner.getPageSetting("background");},set:function set(e){this.inner.e(),BL(e)&&(e=VX(e)),TX(e)&&this.inner.setPageSetting("background",e);}},{key:"pageBorder",get:function get(){return this.inner.e(),this.inner.getPageSetting("border");},set:function set(e){this.inner.e(),IX(e)&&this.inner.setPageSetting("border",e);}},{key:"hoverPageBackground",get:function get(){return this.inner.e(),this.inner.getHoverSetting("background");},set:function set(e){this.inner.e(),BL(e)&&(e=VX(e)),TX(e)&&this.inner.setHoverSetting("background",e);}},{key:"hoverPageBorder",get:function get(){return this.inner.e(),this.inner.getHoverSetting("border");},set:function set(e){this.inner.e(),IX(e)&&this.inner.setHoverSetting("border",e);}},{key:"placeholderBackground",get:function get(){return this.inner.e(),this.inner.getPlaceholderSetting("background");},set:function set(e){this.inner.e(),BL(e)&&(e=VX(e)),TX(e)&&this.inner.setPlaceholderSetting("background",e);}},{key:"selectedPageBorder",get:function get(){return this.inner.e(),this.inner.getSelectSetting("border");},set:function set(e){this.inner.e(),IX(e)&&this.inner.setSelectSetting("border",e);}},{key:"selectedPageBackground",get:function get(){return this.inner.e(),this.inner.getSelectSetting("background");},set:function set(e){this.inner.e(),BL(e)&&(e=VX(e)),TX(e)&&this.inner.setSelectSetting("background",e);}},{key:"allowKeyboardControl",get:function get(){return this.inner.e(),this.inner.keyboardControl;},set:function set(e){this.inner.e(),DL(e)&&(this.inner.keyboardControl=e);}},{key:"allowPageDragging",get:function get(){return this.inner.e(),this.inner.getEnableProp("enableDragPage");},set:function set(e){this.inner.e(),this.inner.setEnableProp("enableDragPage",e);}},{key:"allowResizing",get:function get(){return this.inner.e(),this.inner.getEnableProp("enableResizing");},set:function set(e){this.inner.e(),this.inner.setEnableProp("enableResizing",e);}},{key:"autoChangeIndex",get:function get(){return this.inner.e(),this.inner.getEnableProp("autoSelectTopPage");},set:function set(e){this.inner.e(),this.inner.setEnableProp("autoSelectTopPage",e);}},{key:"show",value:function value(){return this.inner.e(),this.inner.show();}},{key:"hide",value:function value(){return this.inner.e(),this.inner.hide();}},{key:"dispose",value:function value(){return this.inner.e(),this.inner.dispose();}},{key:"updateViewMode",value:function value(e){return this.inner.e(),this.inner.updateViewMode(e);}},{key:"updateCheckboxStyle",value:function value(e){return this.inner.e(),this.inner.updateCheckboxStyle(e);}},{key:"updatePageNumberStyle",value:function value(e){return this.inner.e(),this.inner.updatePageNumberStyle(e);}},{key:"on",value:function value(e,t){return this.inner.e(),this.inner.on(e,t);}},{key:"off",value:function value(e,t){return this.inner.e(),this.inner.off(e,t);}}]);}(),kq={root:{style:{},className:"dvs-web-viewer",id:"root",children:[{type:"Group",dataId:"body",className:"dvs-body",children:[{type:"MainCanvas",style:{},dataId:"canvas",className:"dvs-canvas"}]}]}},Sq=function(){function e(t,i){Xk(this,e),Wk(this,"myDvs",void 0),Wk(this,"myViewer",void 0),Wk(this,"error",void 0),Wk(this,"containerElement",void 0),Wk(this,"imageEditor",void 0),Wk(this,"customElement",void 0),Wk(this,"thumbnailViewer",void 0),Wk(this,"bindViewUI",!1),Wk(this,"hideContextmenu",!0),Wk(this,"acceptDrop",void 0),Wk(this,"bShowImageEditor",void 0),Wk(this,"bThumbnailDispose",void 0),Wk(this,"bufferService",void 0),Wk(this,"webViewerInitConfig",{}),Wk(this,"bEmitBufferChanged",!0),Wk(this,"pageMargin",10),Wk(this,"initWidth",void 0),Wk(this,"initHeight",void 0),Wk(this,"bSingleMode",!0),Wk(this,"oldEnableDrag",!0),Wk(this,"oldBShowThumbnail",!1),Wk(this,"outerBorder","1px solid rgb(204, 204, 204)"),Wk(this,"minZoom",.02),Wk(this,"maxZoom",65),Wk(this,"bindViewEvent",!1),Wk(this,"resizeObserver",null),this.acceptDrop=!0,this.bShowImageEditor=!1,this.error=new IO(),this.bufferService=t||new EO(),this.webViewerInitConfig=i||{},this.init(),this.bufferService.bindViewer(this);}return Yk(e,[{key:"init",value:function value(){var t=this;e.isInstallDVSPlugin||(rY.use(dX),rY.use(xX),rY.use(zY),rY.use(OO),rY.use(vX),e.isInstallDVSPlugin=!0),this.myDvs=new rY({space:this.bufferService.space,container:""}),this.myViewer=this.myDvs.createViewer({uiConfig:_SL(kq),viewerConfig:_SL(SO)}),this.myViewer.updateViewerConfig({cropBoxConfig:_SL(TO)});var i=this.webViewerInitConfig.viewerEvents;ML(null==i?void 0:i.bufferChanged)&&this.myViewer.on("bufferChanged",function(e,r){t.bEmitBufferChanged&&i.bufferChanged(e,r);}),ML(null==i?void 0:i.removeBtnClick)&&this.myViewer.on("removeBtnClick",function(e){i.removeBtnClick(e);}),this.initBind();}},{key:"initBind",value:function value(){var e=this.webViewerInitConfig.viewerContainer;if(CL(e))return!1;var t=e.container,i=e.width,r=e.height;return!!this.bindView(t)&&(CL(i)||(this.setWidth(i),this.initWidth=this.getWidth()),CL(r)||(this.setHeight(r),this.initHeight=this.getHeight()),this.show(),!0);}},{key:"bindDefaultKeyEvent",value:function value(){var e=this;this.myViewer.on("keydown",function(t){var i=e.myViewer.getViewerConfig(),r=i.rows,n=i.columns,o=i.displayMode;if(!(r<1&&n<1||"single"===o))return"ArrowUp"===t.key||"Up"===t.key?(t.preventDefault(),void e.previous()):void("ArrowDown"!==t.key&&"Down"!==t.key||(t.preventDefault(),e.next()));});}},{key:"bindDefaultDrop",value:function value(){var e=this,t=this.webViewerInitConfig.viewerEvents;this.myViewer.on("drop",function(i,r){e.acceptDrop&&t.onDrop(i,r);});}},{key:"bindDefaultRightClick",value:function value(){var e=this.webViewerInitConfig.viewerEvents;this.myViewer.on("contextmenu",function(t,i){e.rightclick(t,i);});}},{key:"preventDefaultContextmenu",value:function value(){var e=this;this.myViewer.on("contextmenu",function(t,i){e.hideContextmenu&&i.preventDefault();});}},{key:"bindViewerEvents",value:function value(){var e=this;if(this.myViewer){var t=this.webViewerInitConfig.viewerEvents;this.myViewer.off("bufferChanged"),this.bindDefaultKeyEvent(),this.preventDefaultContextmenu(),$k(kO).call(kO,function(i){t&&ML(t[i])&&("onDrop"===i?e.bindDefaultDrop():"rightclick"===i?e.bindDefaultRightClick():"bufferChanged"===i?e.myViewer.on("bufferChanged",function(i,r){e.bEmitBufferChanged&&t.bufferChanged(i,r);}):e.myViewer.on(i,function(e,r){t[i](e,r);}));}),this.bindViewEvent=!0;}}},{key:"unbindViewEvents",value:function value(){var e=this;$k(kO).call(kO,function(t){"bufferChanged"!==t&&e.myViewer.off(t);});}},{key:"initViewer",value:function value(){this.myViewer.updateViewerConfig({autoSelectLatest:!0,maxZoom:this.maxZoom,minZoom:this.minZoom}),AL()?this.setCursor("default"):this.setCursor("crosshair"),this.setAcceptDrop(!0),this.setAllowSlide(!0);}},{key:"getErrorInfo",value:function value(e){return yO[e].errorString||"Successful";}},{key:"disConnectObserver",value:function value(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null);}},{key:"emitPageRendered",value:function value(){var e,t=this;this.myViewer.updateViewerConfig({enableEmitPageRendered:!0});var i=this.myViewer.getCurrentTab();i&&$k(e=i.children).call(e,function(e,i){e.isVisible&&t.myViewer.emit("pageRendered",i);});}},{key:"updateViewerConfig",value:function value(e){this.myViewer.updateViewerConfig(e);}},{key:"resetImageEditorButton",value:function value(){this.imageEditor&&this.imageEditor.inner.resetButtonState();}},{key:"resized",value:function value(){return!!this.myViewer&&(this.myViewer.resized(),!0);}},{key:"setBufferService",value:function value(e){return!!e&&e!==this.bufferService&&(this.bufferService.webViewer=void 0,this.myDvs.setSpace(e.space),this.bufferService=e,this.bufferService.bindViewer(this),this.bufferService.isActiveFile?this.bufferService.openDocument(this.bufferService.getCurrentDocument()):this.bufferService.isActiveTag&&this.bufferService.filterImagesByTag(this.bufferService.getCurrentTag(),function(){},function(){}),this.resized(),!0);}},{key:"setDefaultError",value:function value(){var e=this.webViewerInitConfig.viewerError,t=this.myDvs.context.errorService,i=t.errorCode,r=t.errorMessage;ML(null==e?void 0:e.setError)&&null!=e&&e.setError(i,r),this.error.setError(i,r);}},{key:"setError",value:function value(e){var t=this.webViewerInitConfig.viewerError,i=yO[e],r=i.errorCode,n=i.errorString;ML(null==t?void 0:t.setError)&&null!=t&&t.setError(r,n),this.error.setError(r,n);}},{key:"show",value:function value(){return this.bindViewUI?!!this.myViewer&&(this.myViewer.show(),this.setPageMargin(this.pageMargin),!0):(this.setError("UnBindViewer"),!1);}},{key:"hide",value:function value(){return this.bindViewUI?!!this.myViewer&&(this.myViewer.hide(),!0):(this.setError("UnBindViewer"),!1);}},{key:"setOperationMode",value:function value(e){if(this.myViewer){var t="default";switch(e){case 1:t="crop";break;case 3:t="zoomOut";break;case 2:t="zoomIn";break;case 4:t="annotation";break;default:t="default";}this.myViewer.updateViewerConfig({toolType:t});}}},{key:"bindView",value:function value(e){var t,i,r,n=this,o=null;if(this.closeImageEditor(),e&&(o="DIV"===(null==e?void 0:e.nodeName)?e:document.getElementById(e)),CL(o)||UL(o))return this.setError("ElementNotExist"),!1;if(TL(o.id)||(o.id=WL()),(null===(t=o)||void 0===t||null===(i=t.getElementsByClassName("dvs-root dvs-web-viewer"))||void 0===i?void 0:i.length)>0)return this.setError("AlReadyBindViewer"),!1;if(!(r=this.myViewer.bindContainer(o)))return this.setDefaultError(),!1;var a=this.webViewerInitConfig.viewerEvents;if(a&&ML(a.onBind)&&a.onBind(o),this.bindViewUI=!0,this.containerElement=o,this.initWidth=this.getWidth(),this.initHeight=this.getHeight(),this.initViewer(),this.setBorder(this.outerBorder),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),ML(window.ResizeObserver)){var s=new ResizeObserver(function(){var e;(null===(e=document)||void 0===e?void 0:e.body)&&n.render();});s.observe(this.myViewer.rootDom),this.resizeObserver=s;}else this.resizeObserver=null;return this.bindViewUI&&!this.bindViewEvent&&this.bindViewerEvents(),r;}},{key:"unbindView",value:function value(){if(!this.bindViewUI)return!0;var e;if(this.resetViewerSettings(!1),this.disposeComponent(),e=this.myViewer.unbindContainer()){this.hide(),this.unbindViewEvents(),this.bindViewUI=!1,this.bindViewEvent=!1;var t=this.webViewerInitConfig.viewerEvents;t&&ML(t.onUnBind)&&t.onUnBind(this.containerElement),this.containerElement="";}else this.setDefaultError();return e;}},{key:"getIdPostfix",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.postfix:(this.setError("UnBindViewer"),"");}},{key:"getCursor",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.getViewerConfig().canvasStyle.cursor:(this.setError("UnBindViewer"),"");}},{key:"setCursor",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(!this.myViewer)return!1;if(("zoom-in"===e||"zoom-out"===e)&&!this.getIfSinglePageMode())return this.setError("CursorInvalidMode"),!1;"crosshair"===this.getCursor()&&"crosshair"!==e&&this.clearSelectedAreas();var t="default",i=0;switch(e){case"zoom-out":t="zoom-out",i=3;break;case"zoom-in":t="zoom-in",i=2;break;case"crosshair":t="crosshair",i=1;break;case"pointer":t="pointer",i=0;break;default:t="default",i=0;}return this.myViewer.updateViewerConfig({canvasStyle:{cursor:t}}),this.setOperationMode(i),!0;}},{key:"setIfSinglePageMode",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(!this.myViewer)return!1;var t=e?"single":"multiple",i=0;if(e)this.bSingleMode=!0,i=0;else{var r=this.myViewer.getViewerConfig(),n=r.rows,o=r.columns;(n>1||o>1)&&(i=this.myViewer.getViewerConfig().gap,this.bSingleMode=!1);}return this.myViewer.updateViewerConfig({displayMode:t,margin:i}),this.clearSelectedAreas(),this.resized(),!0;}},{key:"getIfSinglePageMode",value:function value(){return this.bindViewUI?!!this.myViewer&&"single"===this.myViewer.getViewerConfigByName("displayMode"):(this.setError("UnBindViewer"),!1);}},{key:"setZoom",value:function value(e){return this.bindViewUI?!!this.myViewer&&(this.myViewer.updateViewerConfig({zoom:e}),!0):(this.setError("UnBindViewer"),!1);}},{key:"getZoom",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.getViewerConfigByName("zoom"):(this.setError("UnBindViewer"),"");}},{key:"setZoomOrigin",value:function value(e){var t,i;if(!this.bindViewUI)return this.setError("UnBindViewer"),"";if(!this.myViewer)return!1;if(!kL(e)||!TL(null==e?void 0:e.x)||!TL(null==e?void 0:e.y))return this.setError("InvalidValue"),!1;var r=e.x,n=e.y;return-1===OI(t=["left","right","center"]).call(t,r)||-1===OI(i=["top","bottom","center"]).call(i,n)?(this.setError("InvalidValue"),!1):(this.updateViewerConfig({zoomOrigin:{x:r,y:n}}),!0);}},{key:"getZoomOrigin",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.getViewerConfigByName("zoomOrigin"):(this.setError("UnBindViewer"),"");}},{key:"setAcceptDrop",value:function value(e){return this.bindViewUI?!!this.myViewer&&(DL(e)?(this.acceptDrop=e,!0):(this.setError("InvalidValue"),!1)):(this.setError("UnBindViewer"),!1);}},{key:"getAcceptDrop",value:function value(){return this.bindViewUI?!!this.myViewer&&this.acceptDrop:(this.setError("UnBindViewer"),"");}},{key:"setAllowSlide",value:function value(e){return this.bindViewUI?!!this.myViewer&&(DL(e)?(this.myViewer.updateViewerConfig({enableSlide:e}),!0):(this.setError("InvalidValue"),!1)):(this.setError("UnBindViewer"),!1);}},{key:"getAllowSlide",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.getViewerConfigByName("enableSlide"):(this.setError("UnBindViewer"),"");}},{key:"setShowRemoveBtn",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(!this.myViewer)return!1;if(!DL(e))return this.setError("InvalidValue"),!1;var t=e?"visible":"hidden";return this.myViewer.updateViewerConfig({removeBtnStyle:{visibility:t}}),!0;}},{key:"getShowRemoveBtn",value:function value(){return this.bindViewUI?!!this.myViewer&&"visible"===this.myViewer.getViewerConfig().removeBtnStyle.visibility:(this.setError("UnBindViewer"),"");}},{key:"setShowCheckbox",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(!this.myViewer)return!1;if(!DL(e))return this.setError("InvalidValue"),!1;var t=e?"visible":"hidden",i="visible"===t?1:0;return this.myViewer.updateViewerConfig({checkboxStyle:{visibility:t}}),this.setMultiSelectMode(i),this.thumbnailViewer&&(this.thumbnailViewer.showCheckbox=!0),!0;}},{key:"getShowCheckbox",value:function value(){return this.bindViewUI?!!this.myViewer&&"visible"===this.myViewer.getViewerConfig().checkboxStyle.visibility:(this.setError("UnBindViewer"),"");}},{key:"getSelectionRectAspectRatio",value:function value(){if(!this.bindViewUI)return this.setError("UnBindViewer"),"";if(!this.myViewer)return!1;var e=this.myViewer.cropBoxConfig,t=e.aspectRatio;return!1===e.keepAspectRatio||t<1?0:this.myViewer.cropBoxConfig.aspectRatio;}},{key:"setSelectionRectAspectRatio",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(!this.myViewer)return!1;var t=e>0,i=e>0?e:0;return this.myViewer.updateViewerConfig({cropBoxConfig:{aspectRatio:i,keepAspectRatio:t}}),!0;}},{key:"getIfAutoScroll",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.getViewerConfig().autoScroll:(this.setError("UnBindViewer"),"");}},{key:"setIfAutoScroll",value:function value(e){return this.bindViewUI?!!this.myViewer&&(DL(e)?(this.thumbnailViewer&&this.thumbnailViewer.inner.setIfAutoScroll(e),this.imageEditor&&this.imageEditor.inner.setIfAutoScroll(e),this.myViewer.updateViewerConfig({autoSelectLatest:e,autoScroll:e}),!0):(this.setError("InvalidValue"),!1)):(this.setError("UnBindViewer"),!1);}},{key:"getPageMargin",value:function value(){return this.bindViewUI?!!this.myViewer&&this.pageMargin:(this.setError("UnBindViewer"),0);}},{key:"setPageMargin",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(!this.myViewer)return!1;if(!/^((\d+em)|(\d+px)|(\d+%)|(\d+))$/.test(e)||e<0)return this.setError("InvalidValue"),!1;if(!EX(e))return!1;this.pageMargin=e;var t=pq(e,this.myViewer);return this.myViewer.updateViewerConfig({gap:t}),this.bSingleMode||this.myViewer.updateViewerConfig({margin:t}),this.resized(),!0;}},{key:"getWidth",value:function value(){if(!this.bindViewUI)return this.setError("UnBindViewer"),"";if(this.myViewer){var e=this.myViewer.dwtWidth||"";if(window.navigator.userAgent.match(/Trident/g)||window.navigator.userAgent.match(/MSIE/g)){var t=this.myViewer.rootDom,i=getComputedStyle(t).borderLeftWidth,r=2*HO(i).value;if(BL(e))return e+r;}return e;}return"";}},{key:"setWidth",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(TL(e)&&!/^((\d+em)|(\d+px)|(\d+%)|(\d+))$/.test(e)||BL(e)&&e<0)return this.setError("InvalidWidth"),!1;if(e===this.myViewer.dwtWidth)return!0;if(this.myViewer.dwtWidth=e,this.myViewer.getViewerConfig().show&&this.setPageMargin(this.pageMargin),this.thumbnailViewer){var t=this.thumbnailViewer.size;"%"===FO(t).unit&&this.thumbnailViewer.inner.emitThumbnailResize();}return!0;}},{key:"getHeight",value:function value(){if(!this.bindViewUI)return this.setError("UnBindViewer"),"";if(this.myViewer){var e=this.myViewer.dwtHeight||"";if(window.navigator.userAgent.match(/Trident/g)||window.navigator.userAgent.match(/MSIE/g)){var t=this.myViewer.rootDom,i=getComputedStyle(t).borderLeftWidth,r=2*HO(i).value;if(BL(e))return e+r;}return e;}return"";}},{key:"setHeight",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(TL(e)&&!/^((\d+em)|(\d+px)|(\d+%)|(\d+))$/.test(e)||BL(e)&&e<0)return this.setError("InvalidHeight"),!1;if(e===this.myViewer.dwtHeight)return!0;if(this.myViewer.dwtHeight=e,this.myViewer.getViewerConfig().show&&this.setPageMargin(this.pageMargin),this.thumbnailViewer){var t=this.thumbnailViewer.size;"%"===FO(t).unit&&this.thumbnailViewer.inner.emitThumbnailResize();}return!0;}},{key:"getBackground",value:function value(){return this.bindViewUI?this.myViewer?this.myViewer.getViewerConfig().canvasStyle.background:"":(this.setError("UnBindViewer"),"");}},{key:"setBackground",value:function value(e){return this.bindViewUI?!(!this.myViewer&&!this.thumbnailViewer||!TX(e)||(this.myViewer&&this.myViewer.updateViewerConfig({canvasStyle:{background:e}}),this.thumbnailViewer&&(this.thumbnailViewer.background=e),0)):(this.setError("UnBindViewer"),!1);}},{key:"getBorder",value:function value(){return this.bindViewUI?this.outerBorder:(this.setError("UnBindViewer"),"");}},{key:"setBorder",value:function value(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(!this.myViewer)return!1;if(!IX(e))return!1;var i=this.myViewer.rootDom;return i&&(i.style.border=e),this.outerBorder=e,this.thumbnailViewer&&this.thumbnailViewer.inner.setBorder(e),t&&this.myViewer.externalResized(),!0;}},{key:"getInnerBorder",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.getViewerConfig().viewerStyle.border:(this.setError("UnBindViewer"),"");}},{key:"setInnerBorder",value:function value(e){return this.bindViewUI?!!this.myViewer&&!!IX(e)&&(this.myViewer.updateViewerConfig({viewerStyle:{border:e}}),this.resized(),!0):(this.setError("UnBindViewer"),!1);}},{key:"getSelectedPageBorder",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.getViewerConfig().selectedPageStyle.border:(this.setError("UnBindViewer"),"");}},{key:"setSelectedPageBorder",value:function value(e){return this.bindViewUI?!!this.myViewer&&!!IX(e)&&(this.myViewer.updateViewerConfig({selectedPageStyle:{border:e}}),this.thumbnailViewer&&(this.thumbnailViewer.selectedPageBorder=e),!0):(this.setError("UnBindViewer"),!1);}},{key:"getSelectedPageBackground",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.getViewerConfig().selectedPageStyle.background:(this.setError("UnBindViewer"),"");}},{key:"setSelectedPageBackground",value:function value(e){return this.bindViewUI?!(!this.myViewer&&!this.thumbnailViewer||!TX(e)||(this.myViewer.updateViewerConfig({selectedPageStyle:{background:e}}),this.thumbnailViewer&&(this.thumbnailViewer.selectedPageBackground=e),0)):(this.setError("UnBindViewer"),!1);}},{key:"getShowPageNumber",value:function value(){return this.bindViewUI?!!this.myViewer&&"visible"===this.myViewer.getViewerConfig().pageNumberStyle.visibility:(this.setError("UnBindViewer"),"");}},{key:"setShowPageNumber",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(!this.myViewer)return!1;if(!DL(e))return this.setError("InvalidValue"),!1;var t={visibility:e?"visible":"hidden"};return this.updatePageNumberStyle(t),!0;}},{key:"setMultiSelectMode",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(!this.myViewer)return!1;if(!BL(e))return this.setError("InvalidValue"),!1;var t=1===e;return this.myViewer.updateViewerConfig({multiselectMode:t}),this.thumbnailViewer&&this.thumbnailViewer.inner.setMultiSelectMode(e),t&&this.setCursor("pointer"),!0;}},{key:"getMultiSelectMode",value:function value(){return this.bindViewUI?!!this.myViewer&&(this.myViewer.getViewerConfig().multiselectMode?1:0):(this.setError("UnBindViewer"),"");}},{key:"setAllowPageDragging",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(!this.myViewer)return!1;if(!DL)return this.setError("InvalidValue"),!1;var t=e;return this.bSingleMode&&(this.oldEnableDrag=e,t=!1),this.myViewer.updateViewerConfig({enableDragPage:t}),!0;}},{key:"getAllowPageDragging",value:function value(){return this.bindViewUI?!!this.myViewer&&(this.bSingleMode?this.oldEnableDrag:this.myViewer.getViewerConfig().enableDragPage):(this.setError("UnBindViewer"),"");}},{key:"getAutoChangeIndex",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.getViewerConfig().autoSelectTopPage:(this.setError("UnBindViewer"),"");}},{key:"setAutoChangeIndex",value:function value(e){return this.bindViewUI?!!this.myViewer&&(DL(e)?(this.myViewer.updateViewerConfig({autoSelectTopPage:e}),!0):(this.setError("InvalidValue"),!1)):(this.setError("UnBindViewer"),!1);}},{key:"getSelectedAreaBorderColor",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.cropBoxConfig.borderColor:(this.setError("UnBindViewer"),"");}},{key:"setSelectedAreaBorderColor",value:function value(e){return this.bindViewUI?!!this.myViewer&&!!TX(e)&&(this.myViewer.updateViewerConfig({cropBoxConfig:{borderColor:e,ctrlBorderColor:e}}),!0):(this.setError("UnBindViewer"),!1);}},{key:"updateCheckboxStyle",value:function value(e){return this.bindViewUI?(this.myViewer.updateViewerConfig({checkboxStyle:e}),this.thumbnailViewer&&this.thumbnailViewer.inner.updateCheckboxStyle(e),!0):(this.setError("UnBindViewer"),!1);}},{key:"updatePageNumberStyle",value:function value(e){return this.bindViewUI?!(!this.myViewer&&!this.thumbnailViewer||(this.myViewer&&this.myViewer.updateViewerConfig({pageNumberStyle:e}),this.thumbnailViewer&&this.thumbnailViewer.updatePageNumberStyle(e),0)):(this.setError("UnBindViewer"),!1);}},{key:"updateRemoveBtnStyle",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;var t=Fk({},e);return CL(null==e?void 0:e.removeMarkColor)||(t.checkMarkColor=null==e?void 0:e.removeMarkColor),CL(null==e?void 0:e.removeMarkLineWidth)||(t.checkMarkLineWidth=null==e?void 0:e.removeMarkLineWidth),this.myViewer.updateViewerConfig({removeBtnStyle:t}),this.thumbnailViewer&&this.thumbnailViewer.inner.updateRemoveBtnStyle(t),!0;}},{key:"getUISettings",value:function value(){return this.bindViewUI?!!this.myViewer&&this.myViewer.uiConfig:(this.setError("UnBindViewer"),!1);}},{key:"resetViewerSettings",value:function value(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if(!this.myViewer)return!1;var t=_SL(SO);return this.initViewer(),this.setWidth(this.initWidth),this.setHeight(this.initHeight),this.setBorder("1px solid rgb(204, 204, 204)",e),this.pageMargin=10,this.bSingleMode=!0,this.oldEnableDrag=!0,this.myViewer.updateViewerConfig({rows:1,columns:1,margin:0,gap:10,zoom:1,enableDragPage:!1,scrollDirection:"vertical",displayMode:"multiple",fitType:"window",autoSelectTopPage:!1,autoScroll:!0,viewerStyle:t.viewerStyle,canvasStyle:t.canvasStyle,pageStyle:t.pageStyle,selectedPageStyle:t.selectedPageStyle,hoveredPageStyle:t.hoveredPageStyle,placeholderStyle:t.placeholderStyle,checkboxStyle:t.checkboxStyle,pageNumberStyle:t.pageNumberStyle}),this.resized(),!0;}},{key:"updateUISettings",value:function value(){return!!this.bindViewUI||(this.setError("UnBindViewer"),!1);}},{key:"setSelectionBoxStyle",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),"";if(!kL(e))return!1;if(!this.myViewer)return!1;var t=dq(e);return this.updateCropBoxConfig(t),!0;}},{key:"getSelectionBoxStyle",value:function value(){return this.bindViewUI?!!this.myViewer&&fq(this.myViewer.cropBoxConfig):(this.setError("UnBindViewer"),"");}},{key:"updateCropBoxConfig",value:function value(e){return!!this.myViewer&&(this.myViewer.updateViewerConfig({cropBoxConfig:e}),!0);}},{key:"isFocusOutLine",value:function value(){return!!this.myViewer&&this.myViewer.context.showOutline;}},{key:"showFocusOutLine",value:function value(e){this.thumbnailViewer&&this.thumbnailViewer.inner.showFocusOutLine(e),this.imageEditor&&this.imageEditor.inner.editorViewer.context.setDisableFocusOutline(!e),this.myViewer.context.setDisableFocusOutline(!e);}},{key:"getIfShowVideoContainer",value:function value(){return!!this.myViewer&&this.myViewer.getViewerConfig().showVideoContainer;}},{key:"showVideoContainer",value:function value(e){return!!this.myViewer&&(this.getIfShowVideoContainer()===e||(this.thumbnailViewer&&(e?(this.oldBShowThumbnail=this.thumbnailViewer.inner.showThumbnail,this.thumbnailViewer.inner.showThumbnail=!1):this.thumbnailViewer.inner.showThumbnail=this.oldBShowThumbnail),this.myViewer.updateViewerConfig({showVideoContainer:e})),!0);}},{key:"updateVideoImage",value:function value(e){var t=this.myViewer.updateVideoImage(e);return t||this.setDefaultError(),t;}},{key:"createThumbnailViewer",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),null;if(this.thumbnailViewer)return this.setError("ThumbnailViewerExist"),this.thumbnailViewer;this.thumbnailViewer=new bq(this,e),this.setBorder(this.outerBorder);var t=this.webViewerInitConfig.viewerEvents;return ML(null==t?void 0:t.removeBtnClick)&&this.thumbnailViewer.on("removeBtnClick",function(e){t.removeBtnClick(e);}),this.showFocusOutLine(this.isFocusOutLine()),this.thumbnailViewer;}},{key:"createImageEditor",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),null;if(this.imageEditor)this.setError("ImageEditorExist");else{var t,i,r=xL(_SL(VO),this.webViewerInitConfig.imageEditorUiConfig);r.border=this.getBorder(),r.selectionRectAspectRatio=this.getSelectionRectAspectRatio();var n=r;ML(null===(t=this.webViewerInitConfig)||void 0===t?void 0:t.beforeImageEditorCreated)&&null!==(i=this.webViewerInitConfig)&&void 0!==i&&i.beforeImageEditorCreated(n),e&&(n=xL(n,e)),this.imageEditor=new yq(this,n);var o=this.getSelectionBoxStyle();this.imageEditor.updateSelectionBoxStyle(o);}return this.showFocusOutLine(this.isFocusOutLine()),this.imageEditor;}},{key:"closeImageEditor",value:function value(){this.imageEditor&&(this.imageEditor.dispose(),this.imageEditor=void 0);}},{key:"createCustomElement",value:function value(e,t,i){if(!this.bindViewUI)return this.setError("UnBindViewer"),null;var r=t||"right",n=!!DL(i)&&i;return CL(e)?(this.setError("ElementRequired"),null):e instanceof HTMLDivElement?(this.customElement?this.setError("CustomElementExist"):this.customElement=new CX(this,e,r,n),this.customElement):(this.setError("ElementNotExist"),null);}},{key:"getCurrentIndex",value:function value(){var e=-1;return this.getHowManyImagesInBuffer()>0&&(e=this.myViewer.getCurrentIndex(),(CL(e)||e<0)&&this.setDefaultError()),e;}},{key:"getCurrentImgUUid",value:function value(){var e=this.myViewer.getCurrentIndex();return-1===e?"":this.bufferService.getUidByIndex(e);}},{key:"getHowManyImagesInBuffer",value:function value(){return!!this.myViewer&&(CL(this.myViewer.currentPageCount)?0:this.myViewer.currentPageCount);}},{key:"getSelectedImagesIndices",value:function value(){return!!this.myViewer&&this.myViewer.getSelectedIndexes();}},{key:"setButtonClass",value:function value(e,t){return this.bindViewUI?CL(e)||CL(t)?(this.setError("InvalidValue"),!1):(this.myViewer.setButtonClass(e,t),!0):(this.setError("UnBindViewer"),!1);}},{key:"setViewMode",value:function value(e,t){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;var i=!1,r="vertical";if(!BL(e)||!BL(t))return this.setError("InvalidValue"),!1;this.myViewer.updateViewerConfig({enableEmitPageRendered:!1}),this.thumbnailViewer&&this.thumbnailViewer.hide();var n=this.myViewer.getViewerConfig(),o=n.rows,a=n.columns;return-1===e&&-1===t?(this.setIfSinglePageMode(!0),i=!0):(t<0&&(r="horizontal",t=-t),e=e<0?-e:e,this.myViewer.updateViewerConfig({scrollDirection:r}),i=this.myViewer.setViewMode(t,e),1===e&&1===t?(this.bSingleMode=!0,1===o&&1===a||(this.oldEnableDrag=this.myViewer.getViewerConfig().enableDragPage),this.myViewer.updateViewerConfig({margin:0,enableDragPage:!1})):(this.bSingleMode=!1,this.setPageMargin(this.pageMargin),this.myViewer.updateViewerConfig({enableDragPage:this.oldEnableDrag})),this.setIfSinglePageMode(!1),i||this.setDefaultError(),"zoom-in"===this.getCursor()&&this.setCursor("crosshair")),this.emitPageRendered(),i;}},{key:"setFitType",value:function value(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"window";if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;var i="window";return-1===OI(e=["width","height","window"]).call(e,t)?(this.setError("InvalidValue"),!1):(i=t,this.myViewer.updateViewerConfig({fitType:i}),!0);}},{key:"setSelectedAreas",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;if("crosshair"!==this.getCursor())return this.setError("OperationError"),!1;var t,i=[],r=!0;if(this.getCurrentIndex()<0)return this.setError("NoImage"),!1;if(CL(e)||CL(e.length)||0===e.length)return this.setError("InvalidLeftOrTopOrRightOrBottom"),!1;if(e.length&&e.length>0)for(var n=0;ns||u>l)continue;t.left=a,t.top=u,t.width=s-a,t.height=l-u,i.push(t);}}return 0===i.length?(this.setError("InvalidLeftOrTopOrRightOrBottom"),!1):((r=this.myViewer.setCropBox(i,!0))||this.setDefaultError(),r);}},{key:"clearSelectedAreas",value:function value(){if(!this.bindViewUI)return this.setError("UnBindViewer"),!1;var e=!0;return!(this.getHowManyImagesInBuffer()<=0)&&(e=this.myViewer.clearCropBox(),this.myViewer.render(),e||this.setDefaultError(),e);}},{key:"next",value:function value(){if(!this.bindViewUI)return this.setError("UnBindViewer"),-1;if(!this.myViewer)return!1;var e=this.getHowManyImagesInBuffer();if(e<=0)return this.setError("NoImage"),-1;if(0===e)return 0;var t=this.getIfAutoScroll();return!1===t&&this.setIfAutoScroll(!0),this.imageEditor&&this.imageEditor.inner&&this.imageEditor.inner.bShowImageEditor?this.imageEditor.inner.nextImage():this.myViewer.nextPage(),!1===t&&this.setIfAutoScroll(!1),this.getCurrentIndex();}},{key:"previous",value:function value(){if(!this.bindViewUI)return this.setError("UnBindViewer"),-1;if(!this.myViewer)return!1;var e=this.getHowManyImagesInBuffer();if(e<=0)return this.setError("NoImage"),-1;if(0===e)return 0;var t=this.getIfAutoScroll();return!1===t&&this.setIfAutoScroll(!0),this.imageEditor&&this.imageEditor.inner&&this.imageEditor.inner.bShowImageEditor?this.imageEditor.inner.previousImage():this.myViewer.prevPage(),!1===t&&this.setIfAutoScroll(!1),this.getCurrentIndex();}},{key:"first",value:function value(){if(!this.bindViewUI)return this.setError("UnBindViewer"),-1;if(this.getHowManyImagesInBuffer()<=0)return this.setError("NoImage"),-1;var e=this.getIfAutoScroll();return!1===e&&this.setIfAutoScroll(!0),this.imageEditor&&this.imageEditor.inner&&this.imageEditor.inner.bShowImageEditor?this.imageEditor.inner.first():this.myViewer.firstPage(),this.myViewer.firstPage(),!1===e&&this.setIfAutoScroll(!1),0;}},{key:"last",value:function value(){if(!this.bindViewUI)return this.setError("UnBindViewer"),-1;var e=this.getHowManyImagesInBuffer();if(e<=0)return this.setError("NoImage"),-1;var t=this.getIfAutoScroll();return!1===t&&this.setIfAutoScroll(!0),this.imageEditor&&this.imageEditor.inner&&this.imageEditor.inner.bShowImageEditor?this.imageEditor.inner.last():this.myViewer.lastPage(),!1===t&&this.setIfAutoScroll(!1),e-1;}},{key:"gotoPage",value:function value(e){if(!this.bindViewUI)return this.setError("UnBindViewer"),-1;var t=this.getHowManyImagesInBuffer();if(t<=0)return this.setError("NoImage"),-1;if(t<0||e>=this.getHowManyImagesInBuffer())return this.setError("IndexOutOfRange"),-1;if(!/^(\d+)$/.test(e)||e<0)return this.setError("MobileServer_InvalidIndex"),-1;var i=this.getIfAutoScroll();return!1===i&&this.setIfAutoScroll(!0),this.imageEditor&&this.imageEditor.inner&&this.imageEditor.inner.bShowImageEditor?this.imageEditor.inner.goToPage(e):this.myViewer.gotoPage(e),!1===i&&this.setIfAutoScroll(!1),this.resized(),e;}},{key:"render",value:function value(){return this.bindViewUI?!!this.myViewer&&(this.myViewer.dwtRender(),this.myViewer.externalResized(),this.resized(),!0):(this.setError("UnBindViewer"),!1);}},{key:"on",value:function value(e,t){if(!e)return this.setError("InvalidValue"),!1;if(!ML(t))return this.setError("CallbackNotAFunction"),!1;var i=e;switch(e){case"onDrop":i="drop";break;case"rightclick":i="contextmenu";break;case"resize":i="dwtResize";break;default:i=e;}return this.myViewer.on(i,t),!0;}},{key:"off",value:function value(e,t){if(!e)return this.setError("InvalidValue"),!1;var i=e;switch(e){case"onDrop":i="drop";break;case"rightclick":i="contextmenu";break;case"resize":i="dwtResize";break;default:i=e;}if(CL(t)){this.myViewer.off(i),"contextmenu"===e&&this.preventDefaultContextmenu();var r=this.webViewerInitConfig.viewerEvents;OI(kO).call(kO,e)>=0&&ML(r[e])&&("onDrop"===e?this.bindDefaultDrop():"rightclick"===e?this.bindDefaultRightClick():this.myViewer.on(i,function(t,i){r[e](t,i);}));}else{if(!ML(t))return this.setError("CallbackNotAFunction"),!1;this.myViewer.off(i,t);}return!0;}},{key:"disposeComponent",value:function value(){this.disConnectObserver(),this.imageEditor&&this.imageEditor.dispose(),this.thumbnailViewer&&this.thumbnailViewer.dispose(),this.customElement&&this.customElement.dispose();}},{key:"dispose",value:function value(){if(this.myViewer){this.myViewer.off("bufferChanged"),this.disposeComponent(),this.myViewer.destroy(),this.myViewer=null;var e=this.webViewerInitConfig.viewerEvents;e&&ML(e.onUnBind)&&e.onUnBind(this.containerElement);}this.bufferService&&(this.bufferService.space.destroy(),this.bufferService=null),this.myDvs&&(this.myDvs.destroy(),this.myDvs=null);}},{key:"rotateInner",value:function value(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:90,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!this.myViewer)return!1;if(!BL(e)||e<0)return this.setError("InvalidIndex"),!1;var r=this.getHowManyImagesInBuffer();return r<0?(this.setError("NoImage"),!1):e>=r?(this.setError("IndexOutOfRange"),!1):BL(t)?(this.myViewer.updateViewerConfig({rotationType:i?"clip":"contain"}),this.myViewer.rotate(t,e)):(this.setError("InvalidValue"),!1);}},{key:"rotate",value:function value(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:90,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!BL(e)||e<0)return this.setError("InvalidIndex"),uB.reject(this.getErrorInfo("InvalidIndex"));var r=this.getHowManyImagesInBuffer();if(r<0)return this.setError("NoImage"),uB.reject(this.getErrorInfo("NoImage"));if(e>=r)return this.setError("IndexOutOfRange"),uB.reject(this.getErrorInfo("IndexOutOfRange"));if(!BL(t))return this.setError("InvalidValue"),uB.reject(this.getErrorInfo("InvalidValue"));var n=this.webViewerInitConfig.viewerEvents;return n&&ML(null==n?void 0:n.rotate)?n.rotate(e,t,i):(this.myViewer.updateViewerConfig({rotationType:i?"clip":"contain"}),this.myViewer.rotate(t,e),this.saveToServer(e));}},{key:"crop",value:(i=mb(vb().mark(function e(t,i){var r,n,o,a,s,u,l,c,h;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getHowManyImagesInBuffer(),!(t<0)&&BL(t)){e.next=3;break;}return e.abrupt("return",(this.setError("InvalidIndex"),uB.reject(this.getErrorInfo("InvalidIndex"))));case 3:if(!(r<0)){e.next=5;break;}return e.abrupt("return",(this.setError("NoImage"),uB.reject(this.getErrorInfo("NoImage"))));case 5:if(!(t>=r)){e.next=7;break;}return e.abrupt("return",(this.setError("IndexOutOfRange"),uB.reject(this.getErrorInfo("IndexOutOfRange"))));case 7:if(n=i.x,o=i.y,a=i.width,s=i.height,!CL(i)&&BL(n+o+a+s)){e.next=10;break;}return e.abrupt("return",(this.setError("InvalidValue"),uB.reject(this.getErrorInfo("InvalidValue"))));case 10:if(!(n<0||o<0||a<=0||s<=0)){e.next=12;break;}return e.abrupt("return",(this.setError("InvalidValue"),uB.reject(this.getErrorInfo("InvalidValue"))));case 12:if(u=this.myViewer.getCurrentTab().getChildByIndex(t),l=u.realTimeWidth,c=u.realTimeHeight,!(a>l||s>c)){e.next=15;break;}return e.abrupt("return",(this.setError("WidthOrHeightOutOfImageSize"),uB.reject(this.getErrorInfo("WidthOrHeightOutOfImageSize"))));case 15:return h=this.webViewerInitConfig.viewerEvents,e.abrupt("return",h&&ML(null==h?void 0:h.crop)?h.crop(t,n,o,a,s):(this.myViewer.crop(t,n,o,a,s),this.saveToServer(t)));case 17:case"end":return e.stop();}},e,this);})),function(e,t){return i.apply(this,arguments);})},{key:"saveToServer",value:(t=mb(vb().mark(function e(t){var i,r,n,o;return vb().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=this.bufferService.getUidByIndex(t),(r=this.webViewerInitConfig.viewerEvents)&&ML(null==r?void 0:r.save)){e.next=3;break;}return e.abrupt("return",uB.reject());case 3:return e.next=5,this.myDvs.getImageData(i,{type:"imageData"});case 5:return n=e.sent,o=Fk(Fk({},this.bufferService.getMetadataByUid(i)),{},{width:Math.floor(n.width),height:Math.floor(n.height)}),e.abrupt("return",r.save(i,n.data.buffer,o,!1));case 8:case"end":return e.stop();}},e,this);})),function(e){return t.apply(this,arguments);})},{key:"overlayRectangle",value:function value(e,t,i,r,n,o,a){if(CL(e)||CL(t)||CL(i)||CL(r)||CL(n))return!1;var s=r-t,u=n-i;return!(s<=0||u<=0)&&this.myViewer.overlayRectangle(e,t,i,s,u,o,a);}},{key:"selectPages",value:function value(e){if(!this.myViewer)return!1;var t=e[e.length-1],i=this.getCurrentIndex();return this.imageEditor&&this.imageEditor.inner&&this.imageEditor.inner.bShowImageEditor&&t!==i?this.imageEditor.inner.selectPages(e):this.myViewer.setSelectedIndexes(e);}},{key:"removePageByUid",value:function value(e){if(!this.myViewer)return!1;var t=this.myViewer.getIndexByUid(e);return null!==t&&this.myViewer.removePage(t);}},{key:"removePageByIndexes",value:function value(e){return!!this.myViewer&&this.myViewer.removePage(e);}},{key:"removeAllPages",value:function value(){return!!this.myViewer&&this.myViewer.removeAllPages();}}]);var t,i;}();Wk(Sq,"isInstallDVSPlugin",!1);var xq=function(){return Yk(function e(t,i){Xk(this,e),Wk(this,"webViewer",void 0),Wk(this,"elements",[]),this.webViewer=new Sq(t,i),this.elements=[],this.disableFocusOutline=!0;},[{key:"e",value:function value(){this.webViewer.setError("Successful");}},{key:"disableFocusOutline",get:function get(){return!this.webViewer.isFocusOutLine();},set:function set(e){this.e(),this.webViewer.showFocusOutLine(!e);}},{key:"idPostfix",get:function get(){return this.e(),this.webViewer.getIdPostfix();}},{key:"width",get:function get(){return this.e(),this.webViewer.getWidth();},set:function set(e){this.e(),this.webViewer.setWidth(e);}},{key:"height",get:function get(){return this.e(),this.webViewer.getHeight();},set:function set(e){this.e(),this.webViewer.setHeight(e);}},{key:"background",get:function get(){return this.e(),this.webViewer.getBackground();},set:function set(e){this.e(),BL(e)&&(e=VX(e)),this.webViewer.setBackground(e);}},{key:"border",get:function get(){return this.e(),this.webViewer.getBorder();},set:function set(e){this.e(),this.webViewer.setBorder(e);}},{key:"innerBorder",get:function get(){return this.e(),this.webViewer.getInnerBorder();},set:function set(e){this.e(),this.webViewer.setInnerBorder(e);}},{key:"selectedPageBorder",get:function get(){return this.e(),this.webViewer.getSelectedPageBorder();},set:function set(e){this.e(),this.webViewer.setSelectedPageBorder(e);}},{key:"selectedPageBackground",get:function get(){return this.e(),this.webViewer.getSelectedPageBackground();},set:function set(e){this.e(),BL(e)&&(e=VX(e)),this.webViewer.setSelectedPageBackground(e);}},{key:"selectedAreaBorderColor",get:function get(){return this.e(),this.webViewer.getSelectedAreaBorderColor();},set:function set(e){this.e(),BL(e)&&(e=VX(e)),this.webViewer.setSelectedAreaBorderColor(e);}},{key:"selectionRectAspectRatio",get:function get(){return this.e(),this.webViewer.getSelectionRectAspectRatio();},set:function set(e){this.e(),this.webViewer.setSelectionRectAspectRatio(e);}},{key:"showPageNumber",get:function get(){return this.e(),this.webViewer.getShowPageNumber();},set:function set(e){this.e(),this.webViewer.setShowPageNumber(e);}},{key:"showCheckbox",get:function get(){return this.e(),this.webViewer.getShowCheckbox();},set:function set(e){this.e(),this.webViewer.setShowCheckbox(e);}},{key:"cursor",get:function get(){return this.e(),this.webViewer.getCursor();},set:function set(e){this.e(),this.webViewer.setCursor(e);}},{key:"ifAutoScroll",get:function get(){return this.e(),this.webViewer.getIfAutoScroll();},set:function set(e){this.e(),this.webViewer.setIfAutoScroll(e);}},{key:"pageMargin",get:function get(){return this.e(),this.webViewer.getPageMargin();},set:function set(e){this.e(),this.webViewer.setPageMargin(e);}},{key:"zoom",get:function get(){return this.e(),this.webViewer.getZoom();},set:function set(e){this.e(),this.webViewer.setZoom(e);}},{key:"zoomOrigin",get:function get(){return this.e(),this.webViewer.getZoomOrigin();},set:function set(e){this.e(),this.webViewer.setZoomOrigin(e);}},{key:"singlePageMode",get:function get(){return this.e(),this.webViewer.getIfSinglePageMode();},set:function set(e){this.e(),this.webViewer.setIfSinglePageMode(e);}},{key:"acceptDrop",get:function get(){return this.e(),this.webViewer.getAcceptDrop();},set:function set(e){this.e(),this.webViewer.setAcceptDrop(e);}},{key:"allowSlide",get:function get(){return this.e(),this.webViewer.getAllowSlide();},set:function set(e){this.e(),this.webViewer.setAllowSlide(e);}},{key:"autoChangeIndex",get:function get(){return this.e(),this.webViewer.getAutoChangeIndex();},set:function set(e){this.e(),this.webViewer.setAutoChangeIndex(e);}},{key:"selectionMode",get:function get(){return this.e(),this.webViewer.getMultiSelectMode();},set:function set(e){this.e(),this.webViewer.setMultiSelectMode(e);}},{key:"allowPageDragging",get:function get(){return this.e(),this.webViewer.getAllowPageDragging();},set:function set(e){this.e(),this.webViewer.setAllowPageDragging(e);}},{key:"selectedImagesIndices",get:function get(){return this.e(),this.webViewer.getSelectedImagesIndices();}},{key:"next",value:function value(){return this.e(),this.webViewer.next();}},{key:"previous",value:function value(){return this.e(),this.webViewer.previous();}},{key:"first",value:function value(){return this.e(),this.webViewer.first();}},{key:"last",value:function value(){return this.e(),this.webViewer.last();}},{key:"gotoPage",value:function value(e){return this.e(),this.webViewer.gotoPage(e);}},{key:"render",value:function value(){return this.e(),this.webViewer.render();}},{key:"show",value:function value(){return this.e(),this.webViewer.show();}},{key:"hide",value:function value(){return this.e(),this.webViewer.hide();}},{key:"on",value:function value(e,t){return this.e(),this.webViewer.on(e,t);}},{key:"off",value:function value(e,t){return this.e(),this.webViewer.off(e,t);}},{key:"createImageEditor",value:function value(e){return this.e(),this.webViewer.createImageEditor(e);}},{key:"createThumbnailViewer",value:function value(e){return this.e(),this.webViewer.createThumbnailViewer(e);}},{key:"createCustomElement",value:function value(e,t,i){return this.e(),this.webViewer.createCustomElement(e,t,i);}},{key:"updateCheckboxStyle",value:function value(e){return this.e(),this.webViewer.updateCheckboxStyle(e);}},{key:"updatePageNumberStyle",value:function value(e){return this.e(),this.webViewer.updatePageNumberStyle(e);}},{key:"updateSelectionBoxStyle",value:function value(e){return this.e(),this.webViewer.setSelectionBoxStyle(e);}},{key:"clearSelectedAreas",value:function value(){return this.e(),this.webViewer.clearSelectedAreas();}},{key:"setSelectedAreas",value:function value(e){return this.e(),this.webViewer.setSelectedAreas(e);}},{key:"fitWindow",value:function value(e){return this.e(),this.webViewer.setFitType(e);}},{key:"setButtonClass",value:function value(e,t){return this.e(),this.webViewer.setButtonClass(e,t);}},{key:"setViewMode",value:function value(e,t){return this.e(),this.webViewer.setViewMode(e,t);}},{key:"bind",value:function value(e){this.e();var t,i,r=e;if(t=r,window.ShadowRoot&&t instanceof window.ShadowRoot){var n=document.createElement("div");r.appendChild(n),this.elements.push(n),r=n;}if(i=r,"object"==("undefined"==typeof HTMLElement?"undefined":ch(HTMLElement))?i instanceof HTMLElement:i&&"object"==ch(i)&&1===i.nodeType&&"string"==typeof i.nodeName){var o=function(e){var t=e;if(window.ShadowRoot)for(;t;){if(t instanceof window.ShadowRoot)return t;t=t.parentNode;}return!1;}(r);if(o){var a=document.createElement("style");a.innerHTML=['@import url("',Dynamsoft.DWT.ResourcesPath,"/src/dynamsoft.webtwain.viewer.css",'")'].join(""),o.appendChild(a);var s=document.createElement("style");s.innerHTML=['@import url("',Dynamsoft.DWT.ResourcesPath,"/src/dynamsoft.webtwain.css",'")'].join(""),o.appendChild(s),this.elements.push(a,s);}else o=!1;r.id&&""!==r.id||(r.id=["dwt_",WL()].join(""));}return this.webViewer.bindView(r);}},{key:"unbind",value:function value(){var e;return this.e(),$k(e=this.elements).call(e,function(e){e.parentNode&&e.parentNode.removeChild(e);}),this.webViewer.unbindView();}},{key:"getUISettings",value:function value(){return this.e(),this.webViewer.getUISettings();}},{key:"updateUISettings",value:function value(){return this.e(),this.webViewer.updateUISettings();}},{key:"resetUISettings",value:function value(){return this.e(),this.webViewer.resetViewerSettings();}}]);}(),Cq=function(e){function t(e,i){return Xk(this,t),cL(this,t,[e,i]);}return _b(t,e),Yk(t,[{key:"errorCode",get:function get(){return this.webViewer.error.getError().errCode;}},{key:"errorString",get:function get(){return this.webViewer.error.getError().errorString;}},{key:"SelectedImagesIndices",get:function get(){return this.webViewer.getSelectedImagesIndices();}},{key:"rotate",value:function value(e,t,i){return this.webViewer.rotate(e,t,i);}},{key:"crop",value:function value(e,t){return this.webViewer.crop(e,t);}}]);}(xq);HTMLCanvasElement.prototype.toBlob||tL(HTMLCanvasElement.prototype,"toBlob",{value:function value(e,t,i){for(var r=atob(this.toDataURL(t,i).split(",")[1]),n=r.length,o=new Uint8Array(n),a=0;a - - - Hello World - - - - - - - - - -
- -

MRZ Result:

-
- - - - diff --git a/samples/frameworks/angular/package.json b/samples/frameworks/angular/package.json index fe2b762..91857e2 100644 --- a/samples/frameworks/angular/package.json +++ b/samples/frameworks/angular/package.json @@ -17,7 +17,7 @@ "@angular/platform-browser": "^19.2.0", "@angular/platform-browser-dynamic": "^19.2.0", "@angular/router": "^19.2.0", - "dynamsoft-mrz-scanner": "2.0.0", + "dynamsoft-mrz-scanner": "3.0.0-beta-202506160001", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.15.0" diff --git a/samples/frameworks/react-hooks/package.json b/samples/frameworks/react-hooks/package.json index 3d4434b..8f726b5 100644 --- a/samples/frameworks/react-hooks/package.json +++ b/samples/frameworks/react-hooks/package.json @@ -7,7 +7,7 @@ "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.3.0", "@testing-library/user-event": "^13.5.0", - "dynamsoft-mrz-scanner": "2.1.0", + "dynamsoft-mrz-scanner": "3.0.0-beta-202506160001", "react": "^19.1.0", "react-dom": "^19.1.0", "react-scripts": "5.0.1", diff --git a/samples/frameworks/react-hooks/src/App.js b/samples/frameworks/react-hooks/src/App.js index 035e96a..bcaeedc 100644 --- a/samples/frameworks/react-hooks/src/App.js +++ b/samples/frameworks/react-hooks/src/App.js @@ -29,7 +29,9 @@ function App() { const formattedMRZ = Object.entries(data) .map(([key, value]) => { - return `${MRZDataLabel[key]}:\n${key === "mrzText" ? value : JSON.stringify(value)}`; + return `${MRZDataLabel[key]}:\n${ + key === "mrzText" ? value : JSON.stringify(value) + }`; }) .join("\n\n"); @@ -40,10 +42,16 @@ function App() {

Hello World for React

- logo + logo
- {result?.image && mrz-result} + {result?.image && ( + mrz-result + )} {result?.data &&
{result.data}
}
diff --git a/samples/frameworks/vue/package.json b/samples/frameworks/vue/package.json index 9d061ae..8c8b72a 100644 --- a/samples/frameworks/vue/package.json +++ b/samples/frameworks/vue/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "core-js": "^3.8.3", - "dynamsoft-mrz-scanner": "^2.1.0", + "dynamsoft-mrz-scanner": "3.0.0-beta-202506160001", "vue": "^3.2.13" }, "devDependencies": { diff --git a/samples/frameworks/vue/src/App.vue b/samples/frameworks/vue/src/App.vue index 8f9e66c..6da8188 100644 --- a/samples/frameworks/vue/src/App.vue +++ b/samples/frameworks/vue/src/App.vue @@ -5,7 +5,12 @@
- mrz-result + mrz-result
{{ result.data }}
@@ -36,7 +41,9 @@ onMounted(async () => { const formattedMRZ = Object.entries(data) .map(([key, value]) => { - return `${MRZDataLabel[key]}:\n${key === "mrzText" ? value : JSON.stringify(value)}`; + return `${MRZDataLabel[key]}:\n${ + key === "mrzText" ? value : JSON.stringify(value) + }`; }) .join("\n\n"); diff --git a/samples/hello-world.html b/samples/hello-world.html index 5a14fdf..1854b37 100644 --- a/samples/hello-world.html +++ b/samples/hello-world.html @@ -4,7 +4,7 @@ Dynamsoft MRZ Scanner - Hello World - + @@ -22,6 +22,10 @@

Dynamsoft MRZ Scanner

// Initialize the Dynamsoft MRZ Scanner const mrzscanner = new Dynamsoft.MRZScanner({ license: "YOUR_LICENSE_KEY_HERE", + scannerViewConfig: { + cameraEnhancerUIPath: "../dist/mrz-scanner.ui.html", + }, + templateFilePath: "../dist/mrz-scanner.template.json", }); (async () => { diff --git a/samples/scenarios/use-file-input.html b/samples/scenarios/use-file-input.html index c5a990c..247a7f8 100644 --- a/samples/scenarios/use-file-input.html +++ b/samples/scenarios/use-file-input.html @@ -4,7 +4,7 @@ Dynamsoft MRZ Scanner - Use File Input - + @@ -164,6 +164,8 @@ resultContainer.innerHTML = `

Error: ${error.message}

`; } } + + this.value = ""; }; diff --git a/src/MRZScanner.ts b/src/MRZScanner.ts index 3f510c4..f4d457a 100644 --- a/src/MRZScanner.ts +++ b/src/MRZScanner.ts @@ -1,5 +1,5 @@ -import { LicenseManager } from "dynamsoft-license"; import { + LicenseManager, _toBlob, _toCanvas, CoreModule, @@ -7,12 +7,14 @@ import { EngineResourcePaths, EnumCapturedResultItemType, MimeType, + CodeParserModule, + ParsedResultItem, OriginalImageResultItem, -} from "dynamsoft-core"; -import { CaptureVisionRouter } from "dynamsoft-capture-vision-router"; -import { CameraEnhancer, CameraView } from "dynamsoft-camera-enhancer"; -import { CodeParserModule, ParsedResultItem } from "dynamsoft-code-parser"; -import { LabelRecognizerModule } from "dynamsoft-label-recognizer"; + CaptureVisionRouter, + CameraEnhancer, + CameraView, + TextLineResultItem, +} from "dynamsoft-capture-vision-bundle"; import { DEFAULT_TEMPLATE_NAMES, EnumMRZDocumentType, @@ -29,9 +31,9 @@ import { DEFAULT_LOADING_SCREEN_STYLE, showLoadingScreen } from "./views/utils/L // Default DCE UI path const DEFAULT_DCE_UI_PATH = - "https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.ui.html"; // TODO + "https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.ui.html"; // TODO const DEFAULT_MRZ_SCANNER_TEMPLATE_PATH = - "https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0-beta-0514202502/dist/mrz-scanner.template.json"; // TODO + "https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.0-beta-202506160001/dist/mrz-scanner.template.json"; // TODO const DEFAULT_DCV_ENGINE_RESOURCE_PATHS = { rootDirectory: "https://cdn.jsdelivr.net/npm/" }; const DEFAULT_CONTAINER_HEIGHT = "100dvh"; @@ -71,6 +73,10 @@ class MRZScanner { private loadingScreen: ReturnType | null = null; + private isDynamsoftResourcesLoaded = false; + + protected isFileMode: boolean = false; + private showLoadingOverlay(message?: string) { const configContainer = getElement(this.config.scannerViewConfig?.container) || getElement(this.config.resultViewConfig?.container); @@ -95,7 +101,11 @@ class MRZScanner { } } - constructor(private config: MRZScannerConfig) {} + constructor(private config: MRZScannerConfig) { + if (!this.isDynamsoftResourcesLoaded) { + this.initializeDynamsoftResources(); + } + } async initialize(): Promise<{ resources: SharedResources; @@ -126,13 +136,7 @@ class MRZScanner { createStyle("dynamsoft-mrz-loading-screen-style", DEFAULT_LOADING_SCREEN_STYLE); this.showLoadingOverlay("Loading..."); - const success = await this.initializeDCVResources(); - if (!success) { - this.hideLoadingOverlay(true); - // Failed to initialize DCV resources - console.error("Failed to initialize DCV resources"); - return { resources: this.resources, components: {} }; - } + await this.initializeDCVResources(); this.resources.onResultUpdated = (result) => { this.resources.result = result; @@ -144,7 +148,7 @@ class MRZScanner { } = {}; // Only initialize components that are configured - if (this.config.scannerViewConfig) { + if (this.config.scannerViewConfig && !this.isFileMode) { this.scannerView = new MRZScannerView(this.resources, this.config.scannerViewConfig); components.scannerView = this.scannerView; await this.scannerView.initialize(); @@ -165,18 +169,35 @@ class MRZScanner { const error = `Initialization Failed: ${errMsg}`; console.error(error); - return { resources: this.resources, components: {} }; + throw new Error(error); } finally { this.hideLoadingOverlay(true); } } - private async initializeDCVResources(): Promise { + private initializeDynamsoftResources() { + //The following code uses the jsDelivr CDN, feel free to change it to your own location of these files + CoreModule.engineResourcePaths = isEmptyObject(this.config?.engineResourcePaths) + ? DEFAULT_DCV_ENGINE_RESOURCE_PATHS + : this.config.engineResourcePaths; + + // Optional. Used to load wasm resources in advance, reducing latency between video playing and document modules. + // Can add other specs. Please check https://www.dynamsoft.com/code-parser/docs/core/code-types/mrtd.html + CoreModule.loadWasm(); + CodeParserModule.loadSpec("MRTD_TD3_PASSPORT"); + CodeParserModule.loadSpec("MRTD_TD3_VISA"); + CodeParserModule.loadSpec("MRTD_TD1_ID"); + CodeParserModule.loadSpec("MRTD_TD2_ID"); + CodeParserModule.loadSpec("MRTD_TD2_VISA"); + + this.isDynamsoftResourcesLoaded = true; + } + + private async initializeDCVResources(): Promise { try { - //The following code uses the jsDelivr CDN, feel free to change it to your own location of these files - CoreModule.engineResourcePaths = isEmptyObject(this.config?.engineResourcePaths) - ? DEFAULT_DCV_ENGINE_RESOURCE_PATHS - : this.config.engineResourcePaths; + if (!this.isDynamsoftResourcesLoaded) { + this.initializeDynamsoftResources(); + } // Change trial link to include product and deploymenttype (LicenseManager as any)._onAuthMessage = (message: string) => @@ -187,35 +208,28 @@ class MRZScanner { await LicenseManager.initLicense(this.config?.license || "", { executeNow: true }); - // Optional. Used to load wasm resources in advance, reducing latency between video playing and document modules. - // Can add other specs. Please check https://www.dynamsoft.com/code-parser/docs/core/code-types/mrtd.html - CoreModule.loadWasm(["DLR", "DCP"]); - CodeParserModule.loadSpec("MRTD_TD3_PASSPORT"); - CodeParserModule.loadSpec("MRTD_TD1_ID"); - CodeParserModule.loadSpec("MRTD_TD2_ID"); - LabelRecognizerModule.loadRecognitionData("MRZ"); + // No need to create cameraEnhancer if user launches with a file + if (!this.isFileMode) { + this.resources.cameraView = await CameraView.createInstance( + this.config.scannerViewConfig?.cameraEnhancerUIPath + ); + + this.resources.cameraEnhancer = await CameraEnhancer.createInstance(this.resources.cameraView); + } - this.resources.cameraView = await CameraView.createInstance(this.config.scannerViewConfig?.cameraEnhancerUIPath); - this.resources.cameraEnhancer = await CameraEnhancer.createInstance(this.resources.cameraView); this.resources.cvRouter = await CaptureVisionRouter.createInstance(); - return true; + // Initialize the template parameters for mrz scanning + await this.resources.cvRouter.initSettings(this.config.templateFilePath); } catch (ex: any) { let errMsg = ex?.message || ex; - if (errMsg?.toLowerCase().includes("license")) { - const error = `The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.`; + const error = errMsg?.toLowerCase().includes("license") + ? `The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.` + : `Resource Initialization Failed: ${errMsg}`; - alert(error); - console.error(error); - } else { - const error = `Resource Initialization Failed: ${errMsg}`; - - alert(error); - console.error(error); - } - - return false; + console.error(error); + throw new Error(error); } } @@ -371,6 +385,7 @@ class MRZScanner { const resultViewConfig = this.showResultView() ? { ...this.config.resultViewConfig, + _isFileMode: this.isFileMode, container: viewContainers[EnumMRZScannerViews.Result] || getElement(this.config.resultViewConfig?.container) || null, } @@ -499,13 +514,12 @@ class MRZScanner { (imageData as any).toCanvas = () => _toCanvas(imageData); (imageData as any).toBlob = async () => await _toBlob(`image/png` as MimeType, imageData); - const textLineResultItems = capturedResult?.textLineResultItems; - const parsedResultItems = capturedResult?.parsedResultItems; + const parsedResultItems = capturedResult?.parsedResult?.parsedResultItems; let processedData = {} as MRZData; - if (textLineResultItems?.length) { - const mrzText = textLineResultItems[0]?.text || ""; + if (parsedResultItems?.length) { + const mrzText = ((parsedResultItems[0] as any)?.referencedItem as TextLineResultItem)?.text || ""; // TODO const parsedResult = parsedResultItems[0] as ParsedResultItem; processedData = processMRZData(mrzText, parsedResult); @@ -547,10 +561,14 @@ class MRZScanner { try { this.isCapturing = true; + + // Check if user uploads a static file + this.isFileMode = !!imageOrFile; + const { components } = await this.initialize(); if (isEmptyObject(components)) { - throw new Error(`MRZ Scanner initialization failed.`); + throw new Error(`MRZ Scanner initialization failed `); } if (this.config.container) { @@ -558,8 +576,7 @@ class MRZScanner { } // Handle direct file upload if provided - if (imageOrFile) { - components.scannerView = null; + if (this.isFileMode) { await this.processUploadedFile(imageOrFile); } @@ -569,7 +586,7 @@ class MRZScanner { } // Scanner view is required if no existing result - if (!components.scannerView && !this.resources.result) { + if (!components.scannerView && !this.resources.result && !this.isFileMode) { throw new Error("Scanner view is required when no previous result exists"); } diff --git a/src/index.ts b/src/build/index.ts similarity index 70% rename from src/index.ts rename to src/build/index.ts index 19326e1..b7b1fcf 100644 --- a/src/index.ts +++ b/src/build/index.ts @@ -1,7 +1,7 @@ -import MRZScanner from "./MRZScanner"; -import MRZResultView from "./views/MRZResultView"; -import MRZScannerView from "./views/MRZScannerView"; -import { MRZDataLabel, EnumMRZData, MRZResult, MRZData, MRZDate, displayMRZDate } from "./views/utils/MRZParser"; +import MRZScanner from "../MRZScanner"; +import MRZResultView from "../views/MRZResultView"; +import MRZScannerView from "../views/MRZScannerView"; +import { MRZDataLabel, EnumMRZData, MRZResult, MRZData, MRZDate, displayMRZDate } from "../views/utils/MRZParser"; import { EnumMRZScanMode, EnumMRZDocumentType, @@ -12,7 +12,7 @@ import { ResultStatus, ToolbarButtonConfig, ToolbarButton, -} from "./views/utils/types"; +} from "../views/utils/types"; export const DynamsoftMRZScanner = { MRZScanner, @@ -20,8 +20,8 @@ export const DynamsoftMRZScanner = { MRZResultView, }; -export type { MRZResultViewToolbarButtonsConfig, MRZResultViewConfig } from "./views/MRZResultView"; -export type { MRZScannerViewConfig } from "./views/MRZScannerView"; +export type { MRZResultViewToolbarButtonsConfig, MRZResultViewConfig } from "../views/MRZResultView"; +export type { MRZScannerViewConfig } from "../views/MRZScannerView"; export type { MRZResult, MRZData, MRZDate, UtilizedTemplateNames, ResultStatus, ToolbarButtonConfig, ToolbarButton }; export { diff --git a/src/mrz-scanner.bundle.esm.ts b/src/build/mrz-scanner.bundle.esm.ts similarity index 100% rename from src/mrz-scanner.bundle.esm.ts rename to src/build/mrz-scanner.bundle.esm.ts diff --git a/src/build/mrz-scanner.bundle.ts b/src/build/mrz-scanner.bundle.ts new file mode 100644 index 0000000..3b78bf4 --- /dev/null +++ b/src/build/mrz-scanner.bundle.ts @@ -0,0 +1,6 @@ +// MRZScanner bundled together with DCV Bundle. +// Use this bundle to allow users to use MRZScanner without installing DCV bundle as dependencies +// Used for