dynamsoft-document-viewer
Version:
Dynamsoft Document Viewer (DDV) is an SDK designed to provide different types of viewers to configure and achieve different processing flows for documents.
15 lines (13 loc) • 1.3 MB
JavaScript
/*!
* 20241126123417
* Dynamsoft JavaScript Library
* Product: Dynamsoft Document Viewer
* Web Site: https://www.dynamsoft.com
*
* Copyright 2024, Dynamsoft Corporation
* Author: Dynamsoft Support Team
* Version: 2.1.0
*/
(function (exports, dynamsoftCore) {
'use strict';
function i(t,e,i){return (e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(t,"string");return "symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function n(t,e){return h(t,o(t,e,"get"))}function s(t,e,i){return d(t,o(t,e,"set"),i),i}function o(t,e,i){if(!e.has(t))throw new TypeError("attempted to "+i+" private field on non-instance");return e.get(t)}function r(t,e,i){return c(t,e),u(i,"get"),h(t,i)}function a(t,e,i,n){return c(t,e),u(i,"set"),d(t,i,n),n}function l(t,e,i){return c(t,e),i}function h(t,e){return e.get?e.get.call(t):e.value}function d(t,e,i){if(e.set)e.set.call(t,i);else {if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=i;}}function c(t,e){if(t!==e)throw new TypeError("Private static access of wrong provenance")}function u(t,e){if(void 0===t)throw new TypeError("attempted to "+e+" private static field before its declaration")}function p(t,e,i){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return i}function g(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function f(t,e,i){g(t,e),e.set(t,i);}function y(t,e){g(t,e),e.add(t);}function m(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{l(n.next(t));}catch(t){o(t);}}function a(t){try{l(n.throw(t));}catch(t){o(t);}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e);}))).then(r,a);}l((n=n.apply(t,e||[])).next());}))}function v(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 x(t,e,i,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return "a"===n?s.call(t,i):s?s.value=i:e.set(t,i),i}var w,b,C,S,P,A,T,k,D,E,I,R,M,B,L,U,O,N,_,W,F,H,V,z,j,$,G,X,Y,q,J,Z,Q,K,tt,et,it,nt,st,ot,rt,at,lt,ht,dt,ct,ut,pt,gt,ft,yt,mt,vt,xt,wt,bt,Ct,St,Pt,At,Tt,kt,Dt,Et,It,Rt,Mt,Bt,Lt,Ut,Ot,Nt,_t,Wt,Ft,Ht,Vt,zt,jt,$t,Gt,Xt,Yt,qt,Jt,Zt,Qt,Kt,te,ee,ie,ne,se,oe,re,ae,le,he,de,ce,ue,pe,ge,fe,ye,me,ve,xe,we,be,Ce,Se,Pe,Ae,Te,ke,De,Ee,Ie,Re,Me,Be,Le,Ue,Oe,Ne,_e,We,Fe,He,Ve,ze,je,$e,Ge,Xe,Ye,qe,Je,Ze,Qe,Ke,ti,ei,ii,ni,si,oi,ri,ai,li,hi,di,ci,ui,pi,gi,fi,yi,mi,vi,xi,wi,bi,Ci,Si,Pi;"function"==typeof SuppressedError&&SuppressedError,function(t){t.logInfo="logInfo",t.logDebug="logDebug",t.logAll="logAll",t.imgIO="imgIO",t.core="imgCore",t.imgProc="imgProc",t.pdfR="pdfReader",t.pdfW="pdfWriter",t.crypto="crypto",t.binaryBlobType="application/octet-stream",t.wasmExtension=".wasm";}(w||(w={})),function(t){t.core="ddv-core",t.reader="ddv-reader",t.detector="ddv-detector",t.loader="ddv-loader";}(b||(b={})),function(t){t.pending="pending",t.ready="ready",t.failed="failed",t.destroyed="destroyed",t.init="init";}(C||(C={})),function(t){t.PARAMETER_TYPE_ERROR="Parameter Type not Supported = ",t.TIMEOUT="Timeout no Response = ",t.FILE_STREAM_ERROR="File Stream Error = ",t.WASM_EXCEPTION_ERROR="An WASM exception occurred.";}(S||(S={})),function(t){t[t.LONG_KEY=0]="LONG_KEY",t[t.DLS_KEY=1]="DLS_KEY";}(P||(P={})),function(t){t[t.wasmSucceed=0]="wasmSucceed",t[t.wasmBase=-4e3]="wasmBase",t[t.wasmException=-4001]="wasmException",t[t.wasmNoModule=-4002]="wasmNoModule",t[t.wasmJsBase=-4100]="wasmJsBase",t[t.wasmJsObjectNotInit=-4101]="wasmJsObjectNotInit",t[t.wasmJsObjectTerminated=-4102]="wasmJsObjectTerminated",t[t.wasmJsObjectInitFailed=-4103]="wasmJsObjectInitFailed",t[t.wasmJsNotLoaded=-4104]="wasmJsNotLoaded",t[t.wasmJsInvalidJson=-4105]="wasmJsInvalidJson",t[t.wasmJsWorkerRunException=-4106]="wasmJsWorkerRunException",t[t.wasmJsWorkerRunFailed=-4107]="wasmJsWorkerRunFailed",t[t.wasmJsReadFileFailed=-4108]="wasmJsReadFileFailed",t[t.wasmJsCoreTaskException=-4109]="wasmJsCoreTaskException",t[t.wasmJsProcTaskException=-4110]="wasmJsProcTaskException",t[t.wasmJsSavePdfFailed=-4111]="wasmJsSavePdfFailed",t[t.wasmJsSaveTiffFailed=-4112]="wasmJsSaveTiffFailed";}(A||(A={})),function(t){t[t.IT_DIB=-1]="IT_DIB",t[t.IT_RGBA=-2]="IT_RGBA",t[t.IT_BGRA=-3]="IT_BGRA",t[t.IT_BMP=0]="IT_BMP",t[t.IT_JPG=1]="IT_JPG",t[t.IT_PNG=3]="IT_PNG",t[t.IT_ALL=5]="IT_ALL";}(T||(T={})),function(t){t[t.RT_AUTO=-1]="RT_AUTO",t[t.RT_BINARY=1]="RT_BINARY",t[t.RT_BASE64=2]="RT_BASE64";}(k||(k={})),function(t){t[t.SF_DEF=0]="SF_DEF",t[t.SF_ENABLE=1]="SF_ENABLE",t[t.SF_DISABLE=2]="SF_DISABLE";}(D||(D={})),function(t){t.imgIOVer="2.1.0",t.coreVer="2.1.0",t.imgProcVer="2.1.0",t.pdfRVer="2.1.0",t.pdfWVer="2.1.0",t.cryptoVer="2.1.0";}(at||(at={}));class Ai{static setLogFunc(t,e,i){x(this,E,t,"f",I),x(this,E,e,"f",R),x(this,E,i,"f",M);}static get level(){return v(this,E,"f",I)}static get func(){return v(this,E,"f",R)}static get context(){return v(this,E,"f",M)}static logAll(t){this.log(w.logAll,t);}static logD(t){this.log(w.logDebug,t);}static log(t,e){v(this,E,"f",R)&&v(this,E,"f",I)===t&&v(this,E,"f",R).call(this,e,v(this,E,"f",M));}}E=Ai,I={value:""},R={value:void 0},M={value:null};class Ti{static unload(){x(this,B,"","f",L),x(this,B,"","f",O),x(this,B,null,"f",N),x(this,B,{name:w.imgIO,workerName:b.core,autoLoad:!1,ver:at.imgIOVer,prefixName:Ti.ImageIOPrefixName,dependencyModules:[],useSimd:!1,fetchOptions:v(Ti,B,"f",Z),useBrotli:Ti.UseBrotli},"f",et),x(this,B,{name:w.crypto,workerName:b.core,autoLoad:!1,ver:at.cryptoVer,prefixName:Ti.CryptoPrefixName,dependencyModules:[w.imgIO],fetchOptions:v(Ti,B,"f",Z),useBrotli:Ti.UseBrotli},"f",it),x(this,B,{name:w.pdfR,workerName:b.reader,autoLoad:!1,ver:at.pdfRVer,prefixName:Ti.PdfReaderPrefixName,dependencyModules:[w.imgIO,w.core],fetchOptions:v(Ti,B,"f",Z),useBrotli:Ti.UseBrotli},"f",nt),x(this,B,{name:w.core,workerName:b.core,autoLoad:!1,ver:at.coreVer,prefixName:Ti.ImagecorePrefixName,dependencyModules:[w.imgIO],fetchOptions:v(Ti,B,"f",Z),useBrotli:Ti.UseBrotli},"f",st),x(this,B,{name:w.imgProc,workerName:b.core,autoLoad:!1,ver:at.imgProcVer,prefixName:Ti.ImageProcPrefixName,dependencyModules:[w.imgIO,w.core],useSimd:Ti.UseSimd,useBrotli:Ti.UseBrotli},"f",ot),Ai.setLogFunc("",void 0,null);}static get UseSimd(){return v(this,B,"f",W)}static set UseSimd(t){x(this,B,t,"f",W);}static get UseBrotli(){return v(this,B,"f",F)}static set UseBrotli(t){x(this,B,t,"f",F);}static get License(){return v(this,B,"f",L)}static set License(t){x(this,B,t,"f",L);}static get LicMode(){return v(this,B,"f",U)}static set LicMode(t){x(this,B,t,"f",U),v(this,B,"m",V).call(this);}static get UUID(){return v(this,B,"f",O)}static set UUID(t){x(this,B,t,"f",O);}static get NavInfo(){return v(this,B,"f",N)}static set NavInfo(t){x(this,B,t,"f",N);}static get Mobile(){return v(this,B,"f",_)}static set Mobile(t){x(this,B,t,"f",_);}static get DefHeapSize(){return v(this,B,"f",z)}static set DefHeapSize(t){x(this,B,t,"f",z);}static get MaxHeapSize(){return v(this,B,"f",j)}static get HeapConfig(){return v(this,B,"m",G).call(this),Object.assign({},v(this,B,"f",$))}static getWorkerHeap(t){return void 0!==v(this,B,"f",$)[t]?v(this,B,"f",$)[t]:{maxHeapSize:v(this,B,"f",j),initHeapSize:v(this,B,"f",z)}}static UpdateHeapConfig(t,e,i){v(this,B,"m",G).call(this),e&&void 0!==v(this,B,"f",$)[t]&&(v(this,B,"f",$)[t].maxHeapSize=e),i&&void 0!==v(this,B,"f",$)[t]&&(v(this,B,"f",$)[t].initHeapSize=i);}static get FileReadModeSize(){return v(this,B,"f",X)}static set FileReadModeSize(t){x(this,B,t,"f",X);}static get FontUseFileReadMode(){return {load:v(this,B,"f",Y),save:v(this,B,"f",q)}}static set FontUseFileReadMode(t){"boolean"==typeof t.load&&x(this,B,t.load,"f",Y),"boolean"==typeof t.save&&x(this,B,t.save,"f",q);}static get ImageIOWorkerJS(){return "ddv-imageio.worker.js?v="+at.imgIOVer}static get PdfReaderWorkerJS(){return "dynamsoft.pdfReader_wasm-"+at.pdfRVer+".js"}static get ImageIOPrefixName(){return "ddv-imageio"}static get ImagecorePrefixName(){return "ddv-imagecore"}static get ImageProcPrefixName(){return "ddv-imageproc"}static get PdfReaderPrefixName(){return "ddv-pdfreader"}static get CryptoPrefixName(){return "ddv-crypto"}static get ImageIOResource(){return v(this,B,"f",Q)}static set ImageIOResource(t){x(this,B,v(this,B,"m",J).call(this,t),"f",Q),v(this,B,"m",tt).call(this,v(this,B,"f",Q),v(this,B,"f",et)),v(this,B,"m",tt).call(this,v(this,B,"f",Q),v(this,B,"f",it)),v(this,B,"m",tt).call(this,v(this,B,"f",Q),v(this,B,"f",st)),v(this,B,"m",tt).call(this,v(this,B,"f",Q),v(this,B,"f",ot));}static get PdfReaderResource(){return v(this,B,"f",K)}static set PdfReaderResource(t){t.useFastCompEdition=!1,x(this,B,v(this,B,"m",J).call(this,t),"f",K),v(this,B,"m",tt).call(this,v(this,B,"f",K),v(this,B,"f",nt)),this.PdfReaderModule.singleInstance=!0;}static get ImageIOModule(){return v(this,B,"f",et)}static get CryptoModule(){return v(this,B,"f",it)}static get PdfReaderModule(){return v(this,B,"f",nt)}static get ImagecoreModule(){return v(this,B,"f",st)}static get ImageReadereModule(){const t=Object.assign({},v(this,B,"f",st));return t.workerName=b.reader,t}static get ImageProcModule(){return v(this,B,"f",ot)}static get DetectorModule(){return x(this,B,Object.assign({},v(this,B,"f",ot)),"f",rt),v(this,B,"f",rt).workerName=b.detector,v(this,B,"f",rt)}static get PdfWriterModule(){const t=Object.assign({},v(this,B,"f",nt));return t.workerName=b.core,t}static setLogFunc(t,e,i){Ai.setLogFunc(t,e,i);}static hasLogFunc(){return void 0!==Ai.func}}B=Ti,H=function(t){this.LicMode==P.DLS_KEY&&t.dependencyModules&&-1!=t.dependencyModules.indexOf(w.imgIO)&&-1==t.dependencyModules.indexOf(w.crypto)&&t.dependencyModules.push(w.crypto);},V=function(){v(this,B,"m",H).call(this,v(this,B,"f",st)),v(this,B,"m",H).call(this,v(this,B,"f",ot)),v(this,B,"m",H).call(this,v(this,B,"f",nt));},G=function(){0===Object.keys(v(this,B,"f",$)).length&&(v(this,B,"f",$)[b.core]={},v(this,B,"f",$)[b.core].maxHeapSize=v(this,B,"f",j),v(this,B,"f",$)[b.core].initHeapSize=v(this,B,"f",z),v(this,B,"f",$)[b.reader]={},v(this,B,"f",$)[b.reader].maxHeapSize=v(this,B,"f",j),v(this,B,"f",$)[b.reader].initHeapSize=v(this,B,"f",z),v(this,B,"f",$)[b.detector]={},v(this,B,"f",$)[b.detector].maxHeapSize=v(this,B,"f",j),v(this,B,"f",$)[b.detector].initHeapSize=v(this,B,"f",z));},J=function(t){var e,i,n,s;let o={crossScript:!1,resourceDir:t.resourceDir,workerScript:t.workerScript,useFastCompEdition:null!==(e=t.useFastCompEdition)&&void 0!==e&&e,useSimd:null!==(i=t.useSimd)&&void 0!==i?i:v(this,B,"f",W),fetchOptions:null!==(n=t.fetchOptions)&&void 0!==n?n:v(this,B,"f",Z),useBrotli:null!==(s=t.useBrotli)&&void 0!==s?s:v(this,B,"f",F)};return o.workerScript=t.resourceDir+t.workerScript,o.workerScript.startsWith("http://")||o.workerScript.startsWith("https://")||o.workerScript.includes("://")?(o.resourceDir=t.resourceDir,o.workerScript.startsWith(location.origin)||(o.crossScript=!0)):t.resourceDir.startsWith("/")?null!=location.origin&&(o.resourceDir=location.origin+t.resourceDir):null!=location.href&&(o.resourceDir=location.href.substring(0,location.href.lastIndexOf("/")+1)+t.resourceDir),o.resourceDir.endsWith("/")||(o.resourceDir+="/"),t.useFastCompEdition&&(o.resourceDir+="fastcomp/",o.workerScript=o.resourceDir+t.workerScript),o},tt=function(t,e){e.resourceDir=t.resourceDir,e.crossScript=t.crossScript,e.name===w.imgProc?e.useSimd=t.useSimd:e.useSimd=!1,e.script=t.workerScript,e.fetchOptions=t.fetchOptions,e.useBrotli=t.useBrotli;},L={value:""},U={value:P.LONG_KEY},O={value:""},N={value:null},_={value:!1},W={value:!1},F={value:!1},z={value:32},j={value:200},$={value:Object.create(null)},X={value:20},Y={value:!0},q={value:!1},Z={value:{mode:"cors",credentials:"same-origin",retries:3,retryDelay:500}},Q={value:{resourceDir:"",workerScript:Ti.ImageIOWorkerJS,useFastCompEdition:!1,useSimd:!1,crossScript:!1,fetchOptions:v(Ti,B,"f",Z),useBrotli:Ti.UseBrotli}},K={value:{resourceDir:"",workerScript:Ti.ImageIOWorkerJS,useFastCompEdition:!1,useSimd:!1,crossScript:!1,fetchOptions:v(Ti,B,"f",Z),useBrotli:Ti.UseBrotli}},et={value:{name:w.imgIO,workerName:b.core,autoLoad:!1,ver:at.imgIOVer,prefixName:Ti.ImageIOPrefixName,dependencyModules:[],useSimd:!1,fetchOptions:v(Ti,B,"f",Z),useBrotli:Ti.UseBrotli}},it={value:{name:w.crypto,workerName:b.core,autoLoad:!1,ver:at.cryptoVer,prefixName:Ti.CryptoPrefixName,dependencyModules:[w.imgIO],fetchOptions:v(Ti,B,"f",Z),useBrotli:Ti.UseBrotli}},nt={value:{name:w.pdfR,workerName:b.reader,autoLoad:!1,ver:at.pdfRVer,prefixName:Ti.PdfReaderPrefixName,dependencyModules:[w.imgIO,w.core],fetchOptions:v(Ti,B,"f",Z),useBrotli:Ti.UseBrotli}},st={value:{name:w.core,workerName:b.core,autoLoad:!1,ver:at.coreVer,prefixName:Ti.ImagecorePrefixName,dependencyModules:[w.imgIO],fetchOptions:v(Ti,B,"f",Z),useBrotli:Ti.UseBrotli}},ot={value:{name:w.imgProc,workerName:b.core,autoLoad:!1,ver:at.imgProcVer,prefixName:Ti.ImageProcPrefixName,dependencyModules:[w.imgIO,w.core],useSimd:Ti.UseSimd,useBrotli:Ti.UseBrotli}},rt={value:void 0};class ki{static read(t){return new Promise((function(e,i){let n=Object.prototype.toString.call(t);if("[object String]"===n){if(0===t.indexOf("blob:")||t.indexOf(".jpg")>0||t.indexOf(".jpeg")>0||t.indexOf(".png")>0||t.indexOf(".bmp")>0||t.indexOf(".dib")>0||t.indexOf(".pdf")>0||t.indexOf(".tiff")>0||t.indexOf(".tif")>0)return fetch(t,{mode:"cors"}).then((function(t){return t.arrayBuffer()})).then((function(t){return e(t)})).catch((function(t){return Promise.reject(t)}));i("Error url: Can not read the file URL");}else if("[object Blob]"===n||"[object FileList]"===n||"[object File]"===n){let s=t;"[object FileList]"!==n&&"[object File]"!==n||(s=t[0]?t[0]:t),v(ki,lt,"m",ht).call(ki,s,e,i);}else "[object ArrayBuffer]"===n||"[object Uint8ClampedArray]"===n?e(t):i("Not support source type: "+n);}))}}lt=ki,ht=function(t,e,i){let n,s,o=0;try{n=new ArrayBuffer(t.size),s=new Uint8Array(n);}catch(t){i(t);}!function r(){const a=new FileReader;a.onload=function(a){var l;if(null===(l=null==a?void 0:a.target)||void 0===l?void 0:l.result){const i=a.target.result;s.set(new Uint8Array(i),o),o+=i.byteLength,o<t.size?r():e(n);}else i(a);},a.onerror=function(t){i(t);},a.onabort=function(t){i(t);};const l=Math.min(o+1048576,t.size),h=t.slice(o,l);a.readAsArrayBuffer(h);}();};class Di{static fetchRetry(t,e,i,n){let s=e.retries,o=e.retryDelay;return new Promise((function(r,a){const l=function(h){return fetch(t,e).then((function(t){r(t);})).catch((function(t){h<s?function(t,e,s){i&&i(e,n),setTimeout((function(){l(++t);}),o);}(h,t):a(t);}))};return l(0)}))}}class Ei{constructor(t,e,i,n,s,o){dt.add(this),ct.set(this,void 0),ut.set(this,void 0),pt.set(this,void 0),gt.set(this,void 0),ft.set(this,void 0),yt.set(this,void 0),mt.set(this,void 0),vt.set(this,void 0),xt.set(this,void 0),wt.set(this,void 0),bt.set(this,void 0),Ct.set(this,void 0),St.set(this,void 0),Pt.set(this,0),At.set(this,{}),Tt.set(this,null),x(this,ct,t,"f"),x(this,xt,n,"f"),x(this,St,i,"f"),x(this,pt,[],"f"),x(this,gt,!1,"f"),x(this,ft,!1,"f"),x(this,Pt,e,"f"),x(this,Tt,Object.create(null),"f"),v(this,At,"f").modulesInfo=[],x(this,bt,Object.create(null),"f"),x(this,vt,null,"f"),x(this,wt,0,"f"),x(this,Ct,0,"f"),x(this,ut,v(this,dt,"m",Dt).call(this,v(this,ct,"f")),"f"),v(this,ut,"f").on("message",v(this,dt,"m",It),this),v(this,ut,"f").on("error",v(this,dt,"m",Et),this),v(this,ut,"f").on("exit",(function(e,i,n){let s="Worker #terminated Unexpectedly\n";s+=" exitCode: `"+e+"`\n",s+=" signalCode: `"+i+"`\n",s+=" #script: `"+t+"`\n",v(n,dt,"m",Et).call(n,new Error(s),n);}),this);}get WorkerScript(){return v(this,xt,"f")}get id(){return v(this,Pt,"f")}get Module(){return v(this,At,"f")}get Instances(){return v(this,Tt,"f")}get WorkerName(){return v(this,St,"f")}execTask(t,e,i){i||((i={}).promise=new Promise((function(t,e){i.resolve=t,i.reject=e;})));let n=x(this,Ct,+v(this,Ct,"f")+1,"f");v(this,bt,"f")[n]={id:n,insId:e.insId,resolver:i,cost:e.cost},delete e.cost;let s={id:n,func:t,params:e};return Ai.logD("["+e.insId+"] "+t+" send"),v(this,ft,"f")?i.reject(new Error("Worker is #terminated")):v(this,gt,"f")?i.reject(new Error("Worker is #terminating")):v(this,ut,"f").wasmReady||v(this,ut,"f").ready&&"loadWasm"===t?v(this,ut,"f").send(s):v(this,pt,"f").push(s),i.promise}get memSize(){return v(this,wt,"f")}get busy(){return this.howManyTasks>0}get howManyTasks(){return Object.keys(v(this,bt,"f")).length}get alive(){return !v(this,gt,"f")&&!v(this,ft,"f")}terminate(t,e){if(Ai.logD("["+this.id+"] worker terminate "+t),t&&v(this,dt,"m",Mt).call(this,"Worker has been #terminated"),"function"==typeof e&&x(this,vt,e,"f"),this.busy)x(this,gt,!0,"f");else {if(v(this,ut,"f")){if("function"!=typeof v(this,ut,"f").terminate)throw new Error("Failed to terminate worker");Ai.logD("["+this.id+"] will be terminated"),v(this,ut,"f").terminate(),x(this,ut,null,"f");}x(this,gt,!1,"f"),x(this,ft,!0,"f"),v(this,vt,"f")&&v(this,vt,"f").call(this,this);}}hasInstance(t){if(t){const e=v(this,Tt,"f")[t];if(e)return 0!=Object.keys(e).length}else {const t=Object.keys(v(this,Tt,"f"));for(const e of t)if(0!=Object.keys(v(this,Tt,"f")[e]).length)return !0}return !1}exceedMaxMemory(){const t=1024*Ti.getWorkerHeap(this.WorkerName).maxHeapSize*1024;return !!(v(this,wt,"f")&&v(this,wt,"f")>t&&0!=t)&&(Ai.logD("[w-"+this.id+"] current memSize="+v(this,wt,"f")+", max="+t),!0)}shouldBeFreed(){return !(!this.exceedMaxMemory()||this.hasInstance(void 0)||(Ai.logD("[w-"+this.id+"] try to terminate the worker"),this.terminate(),0))}}ct=new WeakMap,ut=new WeakMap,pt=new WeakMap,gt=new WeakMap,ft=new WeakMap,yt=new WeakMap,mt=new WeakMap,vt=new WeakMap,xt=new WeakMap,wt=new WeakMap,bt=new WeakMap,Ct=new WeakMap,St=new WeakMap,Pt=new WeakMap,At=new WeakMap,Tt=new WeakMap,dt=new WeakSet,kt=function(t){let e=new Error(""),i=Object.keys(t);for(let n=0;n<i.length;n++)e[i[n]]=t[i[n]];return e},Dt=function(t){if("function"!=typeof Worker&&"object"!=typeof Worker)throw new Error("Web Workers not supported");let e=new Worker(t,{name:this.WorkerName});return e.on=function(t,e,i){this.addEventListener(t,(function(n){"exit"===t?e(n.data,"",i):e(n.data,i);}));},e.send=function(t){if(null!=t&&null!=t.params&&null!=t.params.input){let e=Object.prototype.toString.call(t.params.input);if("[object Array]"===Object.prototype.toString.call(t.params.input)){if(e=Object.prototype.toString.call(t.params.input[0]),"[object ArrayBuffer]"===e||"[object Uint8ClampedArray]"===e||"[object Uint8Array]"===e)return void this.postMessage(t,[null!=t.params.input[0].buffer?t.params.input[0].buffer:t.params.input[0]])}else if("[object ArrayBuffer]"===e||"[object Uint8ClampedArray]"===e||"[object Uint8Array]"===e)return void this.postMessage(t,[null!=t.params.input.buffer?t.params.input.buffer:t.params.input])}this.postMessage(t);},e},Et=function(t,e){x(e,ft,!0,"f"),Ai.logD("[js]["+e.id+"] worker error "+JSON.stringify(t)),v(e,gt,"f")&&v(e,vt,"f")&&v(e,vt,"f").call(e,e),x(e,gt,!1,"f"),v(e,dt,"m",Mt).call(e);},It=function(t,e){let i=t.id,n=v(e,bt,"f")[i];if(t&&t.cost&&n&&n.cost){const e=n.cost;e.exec=t.cost;const i=Date.now();e.total=i-e.ctime,e.msgQueue=t.ctime-e.time;const s=i-t.time;delete e.time,delete e.ctime,t.cost=e,t.cost.receive=s,delete t.ctime,delete t.time;}if(Ai.logD(t.log?t.log:t),"string"==typeof t&&"ready"===t)v(e,ut,"f").ready=!0,setTimeout((()=>{v(e,dt,"m",Rt).call(e);}),0);else if(!t.log){if("object"==typeof t){let i=t.result;"object"==typeof i?(null!=i.errorCode&&(i.code=i.errorCode,delete i.errorCode),null!=i.errorMessage&&(i.message=i.errorMessage,delete i.errorMessage)):"string"==typeof i&&(i=i.replace('"errorCode"','"code"'),i=i.replace("'errorCode'","'code'"),i=i.replace('"errorMessage"','"message"'),i=i.replace("'errorMessage'","'message'"),t.result=i),null!=t.memSize&&x(e,wt,t.memSize,"f");}if(void 0!==n){const s=n.insId;delete v(e,bt,"f")[i],Ai.logD("["+s+"] "+t.func+" received"),!0===v(e,gt,"f")&&e.terminate(),"loadWasm"===t.func&&null!=t.result&&(v(e,ut,"f").wasmReady=!0,setTimeout((()=>{v(e,dt,"m",Rt).call(e);}),0)),t.error?n.resolver.reject(v(e,dt,"m",kt).call(e,t.error)):t.result&&n.resolver.resolve(t.result);}}},Rt=function(){this.alive&&(v(this,pt,"f").forEach(v(this,ut,"f").send.bind(v(this,ut,"f"))),x(this,pt,[],"f"));},Mt=function(t){for(let e in v(this,bt,"f"))void 0!==v(this,bt,"f")[e]&&v(this,bt,"f")[e].resolver.reject(new Error(t));x(this,bt,Object.create(null),"f");};class Ii{constructor(){Bt.add(this),Ot.set(this,[]),Nt.set(this,4),_t.set(this,60),Wt.set(this,!1),Ft.set(this,0),Vt.set(this,!1);}static get Instance(){return v(this,Lt,"f",Ut)||x(this,Lt,new Ii,"f",Ut),v(this,Lt,"f",Ut)}get Terminated(){return v(this,Wt,"f")}getModuleLoadedError(t){for(let e of v(Ii,Lt,"f",Ht))if(e.name==t)return e.error}getModuleStatus(t){for(let e of v(Ii,Lt,"f",Ht))if(e.name==t)return e.status;return ""}addModules(t,e){let i=!1;if(v(Ii,Lt,"f",Ht).forEach((function(e,n,s){e.name==t.name&&(e.ver==t.ver?i=!0:s.splice(n,1));})),!i){let i=t;i.status=e||"",i.wasmModule=null,v(Ii,Lt,"f",Ht).push(i);}}loadModule(t,e){return m(this,void 0,void 0,(function*(){null==e&&(e=0!=v(this,Bt,"m",Jt).call(this,t).length),this.addModules(t);for(let e of t.dependencyModules)e===w.imgIO?(this.addModules(Ti.ImageIOModule,C.pending),Ti.LicMode===P.DLS_KEY&&t.name!=w.crypto&&this.addModules(Ti.CryptoModule,C.pending)):e===w.core&&this.addModules(Ti.ImagecoreModule,C.pending);let i,n;for(let s of v(Ii,Lt,"f",Ht))if(s.name===t.name){if(s.status===C.pending)return !1;if(s.wasmModule){if(e)return !0;i=s.wasmModule,n=s.wasmBinary;break}break}let s=null;if(i)s=t,s.wasmModule=i,s.wasmBinary=n,s.status=C.pending;else if(s=t,""===s.status)s.status=C.pending,s.wasmModule=null;else {if(s.status===C.pending)return !1;e||(s.error={code:0,message:""},s.status=C.pending);}return v(this,Bt,"m",zt).call(this,s)}))}get busy(){v(this,Bt,"m",te).call(this);let t=v(this,Ot,"f");for(let e of t)if(e.busy)return !0;return !1}getWorker(t,e){return m(this,void 0,void 0,(function*(){if(v(this,Bt,"m",Zt).call(this,t.name))return v(this,Bt,"m",Kt).call(this),{worker:null,workers:0};let i=v(this,Bt,"m",Jt).call(this,t,!0);return 0!=i.length?{worker:v(this,Bt,"m",ee).call(this,i,e,t),workers:i.length}:(yield this.loadModule(t,!1),{worker:null,workers:0})}))}removeInstanceInWorker(t,e,i,n){if(v(this,Bt,"m",ie).call(this,e,t.name,i),n&&e&&e.shouldBeFreed()){let t=v(this,Ot,"f").indexOf(e);-1!==t&&v(this,Ot,"f").splice(t,1);}}terminate(t){x(Ii,Lt,null,"f",Ut),Ai.logD("worker pool terminate "+t),x(this,Wt,!0,"f");let e=[];return v(this,Ot,"f").splice(0).forEach((function(i){let n={};n.promise=new Promise((function(t,e){n.resolve=t,n.reject=e;})),e.push(n.promise),i.terminate(t,(function(t){n.resolve(t);}));})),Promise.all(e)}static unload(){x(Ii,Lt,new Array,"f",Ht);}terminateWorker(t){v(this,Ot,"f").splice(0,v(this,Ot,"f").length,...v(this,Ot,"f").filter((e=>e.WorkerName!==t||(e.terminate(!0),!1))));}getMemoryUsed(){let t=v(this,Ot,"f"),e=[],i=0;for(let n of t)n&&null!=n.memSize&&(e[i]={},e[i].size=n.memSize,e[i].limit=1024*Ti.getWorkerHeap(n.WorkerName).maxHeapSize*1024,e[i].name=n.WorkerName,e[i].id=n.id,i+=1);return e}}Lt=Ii,Ot=new WeakMap,Nt=new WeakMap,_t=new WeakMap,Wt=new WeakMap,Ft=new WeakMap,Vt=new WeakMap,Bt=new WeakSet,zt=function(t){return m(this,void 0,void 0,(function*(){let e=this,i=yield v(this,Bt,"m",Yt).call(this,t);if(i){let n={id:0,func:"loadWasm",params:{insId:0,priority:0,module:{modulesInfo:[]},fetchOptions:t.fetchOptions}};if(n.params.resourceDir=t.resourceDir,n.params.initMemory=Ti.getWorkerHeap(t.workerName).initHeapSize,n.params.module){for(let e of v(Ii,Lt,"f",Ht))for(let i of t.dependencyModules)i==e.name&&n.params.module.modulesInfo.push(e);n.params.module.modulesInfo.push(t);}yield v(this,Bt,"m",$t).call(this,i,n),x(e,Nt,v(e,Bt,"m",Xt).call(e),"f"),t.status===C.pending&&(t.status="");}else t.status="",t.wasmModule=null;}))},jt=function(t,e,i,n){for(let s of v(Ii,Lt,"f",Ht))if(s.name===t){s.status=e,s.wasmModule=i.wasmModule,s.wasmBinary=i.wasmBinary,s.error=n;break}},$t=function(t,e,i){return m(this,void 0,void 0,(function*(){let n=this;try{const i=yield t.execTask(e.func,e.params);let s=!1;return void 0===i.code||i.modules?s=v(n,Bt,"m",Gt).call(n,i,t):Ai.logD(i),s}catch(n){return Ai.logD(n),!1}finally{i&&i();}}))},Gt=function(t,e){if(Ai.logD("handleWasmLoad:"),Ai.logD(t),v(this,Wt,"f"))return e.terminate(),!1;if(("object"!=typeof t||null==t.modules)&&"object"==typeof t)return !1;let i=!1;for(const n of t.modules)t.code?(v(this,Bt,"m",jt).call(this,n.name,C.failed,null,{code:t.code,message:t.message}),e.Module.modulesInfo[n.name]=!1):(v(this,Bt,"m",jt).call(this,n.name,C.ready,n.wasmResource,void 0),e.Module.modulesInfo[n.name]=!0,i=!0);return i},Xt=function(){let t=2;return "hardwareConcurrency"in self.navigator&&(t=self.navigator.hardwareConcurrency),Math.max(Math.min(v(this,Nt,"f"),Math.max(v(this,Nt,"f"),t/2)),1)},Yt=function(t){return m(this,void 0,void 0,(function*(){v(this,Bt,"m",te).call(this);let e=v(this,Ot,"f");for(let i of e)if(i.WorkerName===t.workerName)return i.busy?null:i;return v(this,Bt,"m",qt).call(this,t)}))},qt=function(t){var e;return m(this,void 0,void 0,(function*(){let i=this,n=v(i,Ot,"f");if(n.length<v(i,Nt,"f")&&!v(i,Vt,"f")){x(i,Vt,!0,"f");let s=t.script;t.crossScript&&(s=yield Di.fetchRetry(t.script,t.fetchOptions,Ai.func,i).then((t=>t.blob())).then((t=>URL.createObjectURL(t))).catch((t=>(Ai.logD("get new worker fetch failed: "),Ai.logD(t),x(i,Vt,!1,"f"),null))));let o=new Ei(s,x(e=i,Ft,+v(e,Ft,"f")+1,"f"),t.workerName,t.script,Ai.func,Ai.context);return n.push(o),x(i,Vt,!1,"f"),Ai.logAll(n),Ai.logD("[wl-"+v(i,Ot,"f").length+"] got new worker w-"+o.id+"("+o.WorkerName+") succeed!"),o}return null}))},Jt=function(t,e){v(this,Bt,"m",te).call(this);let i=v(this,Ot,"f");Ai.logAll(i);let n=[];for(let s of i)if(s.Module.modulesInfo[t.name]){let i=!0;if(t.dependencyModules.forEach((t=>{s.Module.modulesInfo[t]||(i=!1);})),!i)continue;if(e&&s.WorkerName!==t.workerName)continue;n.push(s);}return Ai.logAll("[wl-"+i.length+"] got workers for module "+t.name),Ai.logAll(n),n},Zt=function(t){for(let e of v(Ii,Lt,"f",Ht))if(e.name===t&&e.status===C.pending)return !0;return !1},Qt=function(){return m(this,void 0,void 0,(function*(){this.terminate(!0);for(let t of v(Ii,Lt,"f",Ht))yield v(this,Bt,"m",zt).call(this,t);}))},Kt=function(){v(this,Bt,"m",te).call(this),0==v(this,Ot,"f").length&&0!=v(Ii,Lt,"f",Ht).length&&(Ai.logD("no worker ready, reinit"),v(this,Bt,"m",Qt).call(this));},te=function(){v(this,Ot,"f").splice(0,v(this,Ot,"f").length,...v(this,Ot,"f").filter((function(t){return t.alive})));},ee=function(t,e,i){Ai.logAll("[wl-"+v(this,Ot,"f").length+"] getWorkerByIntanceId"),Ai.logAll(t);let n,s=9007199254740991;for(let o of t){if(i.singleInstance&&o.hasInstance(i.name)&&!o.Instances[i.name][e])continue;const t=o.Instances[i.name];if(!t||void 0!==t[e]){n=o;break}{let t=o.howManyTasks;t<s&&(n=o,s=t);}}if(n){if(n.shouldBeFreed())return null;const s=n.Instances[i.name];if(s)s[e]="";else {const t=Object.create(null);t[e]="",n.Instances[i.name]=t;}return Ai.logAll(t),Ai.logD("[wl-"+t.length+"]["+e+"] got worker w-"+n.id),n}return Ai.logAll("#getWorkerByIntanceId: no suitable worker"),null},ie=function(t,e,i){let n=v(this,Ot,"f");Ai.logAll("removeInstanceInWorkerInner"),Ai.logAll(n);for(let s of n)if(s===t){const o=s.Instances[e];if(o){if(null!=o[i]){delete o[i],Ai.logAll(n),Ai.logD("[w-"+s.id+"] removeInstanceInWorkerInner "+i+" in "+t.id+" succeed!");break}Ai.logD("[w-"+s.id+"] not found instance "+i);}}},Ut={value:null},Ht={value:new Array};class Ri{static buildWasmFileName(t,e,i,n,s){return t+(n?"-simd":"")+i+"?v="+e}static base64DecToArr(t,e){let i=t.replace(/[^A-Za-z0-9\+\/]/g,""),n=i.length,s=e?Math.ceil((3*n+1>>>2)/e)*e:3*n+1>>>2,o=new Uint8Array(s);for(let t,e,r=0,a=0,l=0;l<n;l++)if(e=3&l,r|=v(this,ne,"m",se).call(this,i.charCodeAt(l))<<18-6*e,3===e||n-l==1){for(t=0;t<3&&a<s;t++,a++)o[a]=r>>>(16>>>t&24)&255;r=0;}return o}static isWasmSupport(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){let t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return !1}static random(){return (Date.now()%10086).toString(36).slice(2)+Math.random().toString(36).slice(2)}static newBlobInChunks(t,e,i){var n;let s;const o=i||t.byteLength,r=8388608,a=[];for(let e=0;e<o;e+=r)a.push(new Blob([new Uint8Array(null!==(n=t.buffer)&&void 0!==n?n:t,e,Math.min(o-e,r))]));return s=null!=e?new Blob(a,{type:e}):new Blob(a),s}}ne=Ri,se=function(t){return t>64&&t<91?t-65:t>96&&t<123?t-71:t>47&&t<58?t+4:43===t?62:47===t?63:0};class Mi{constructor(t,e){var i,n,s,o;oe.add(this),le.set(this,void 0),this._outputType=T.IT_JPG,this._inputType=T.IT_ALL,this._jpegQuality=80,he.set(this,null!==(i=Ti.License)&&void 0!==i?i:""),de.set(this,[]),ce.set(this,null),ue.set(this,0),pe.set(this,x(o=Mi,re,+v(o,re,"f",ae)+1,"f",ae)),ge.set(this,null),fe.set(this,JSON.parse(JSON.stringify(Ti.NavInfo))),ye.set(this,Ti.Mobile),me.set(this,location.origin),ve.set(this,""),xe.set(this,C.init),we.set(this,!1),be.set(this,null!==(n=Ti.LicMode)&&void 0!==n?n:P.LONG_KEY),Ce.set(this,null!==(s=Ti.UUID)&&void 0!==s?s:""),Se.set(this,0),Pe.set(this,!1),Ae.set(this,!1),this._handleBooleanResult=function(t,e){return !0},x(this,le,t,"f"),x(this,he,null!=e?e:Ti.License,"f");}_prepareModule(t){}get workerId(){return v(this,ce,"f")&&v(this,ce,"f").alive?v(this,ce,"f").id:0}get id(){return v(this,pe,"f")}hasTask(){return v(this,de,"f").length>0}_canTerminateWork(){return !1}_makeSureWorkerMemoryNotExceed(){return !(v(this,ce,"f")&&v(this,ce,"f").alive&&this._canTerminateWork()&&v(this,ce,"f").exceedMaxMemory()&&(Ai.logD(`[${this.id}] try to termiate worker [${v(this,ce,"f").id}]`),v(this,ce,"f").terminate(!0),x(this,ce,null,"f"),x(this,xe,C.init,"f"),1))}_workerChanged(t){}_handleBasicResult(t,e){return delete t.code,delete t.message,t}_handleImageData(t,e){var i,n,s;if("object"==typeof t.imageData)if(null!=t.imageCount&&t.imageCount>1)for(let n=0;n<t.imageCount;n++)t.imageData[n]=v(i=e.context,oe,"m",De).call(i,t.imageData[n],t.blobType,e.params.returnBlob,t.imageDataSize);else t.imageData=v(n=e.context,oe,"m",De).call(n,t.imageData,t.blobType,e.params.returnBlob,t.imageDataSize);return "object"==typeof t.pdfData&&(t.pdfData=v(s=e.context,oe,"m",De).call(s,t.pdfData,t.blobType,e.params.returnBlob,t.pdfDataSize)),t}_handleResult(t,e){var i,n;let s=v(n=e.context,oe,"m",Ee).call(n,t);if(void 0===s.code||!s.code&&"Successful."===s.message)s=e.handleResult(s,e),setTimeout((()=>{var t;v(t=e.context,oe,"m",ke).call(t);}),0),(0, e.resolve)(s);else {let t={code:s.code,message:s.code===A.wasmException?S.WASM_EXCEPTION_ERROR+"("+(null===(i=e.params)||void 0===i?void 0:i.moduleName)+":"+e.func+":"+s.message+")":s.message};e.context.terminated?e.resolve(t):e.reject(t);}}_execTask(t){let e=this,i=v(e,ce,"f");if(Ai.logAll(t),i)try{if(t.params.cost){const e=t.params.cost.time;t.params.cost.time=Date.now(),t.params.cost.taskQueue=t.params.cost.time-e;}i.execTask(t.func,t.params).then((function(i){e._handleResult(v(e,oe,"m",Ee).call(e,i),t);})).catch((function(i){Ai.logD(i),setTimeout((()=>{v(e,oe,"m",ke).call(e);}),0);let n=i;"object"==typeof i&&null!=i.message&&(n=i.message);let s={code:A.wasmJsWorkerRunFailed,message:n};v(e,we,"f")?t.resolve(s):t.reject(s);}));}catch(i){setTimeout((()=>{v(e,oe,"m",ke).call(e);}),0),Ai.logD(i);let n={code:A.wasmJsWorkerRunException,message:i.message,stack:i.stack};v(e,we,"f")?t.resolve(n):t.reject(n);}}_cancelAllTasks(t,e){for(let i of v(this,de,"f"))if(void 0!==i){let n={code:t,message:e};v(this,we,"f")?i.resolve(n):i.reject(n);}x(this,de,[],"f");}_createTask(t,e,i){let n={moduleName:v(this,le,"f").name,insId:v(this,pe,"f")},s={id:x(this,ue,+v(this,ue,"f")+1,"f"),func:t,params:n};return s.promise=new Promise((function(t,e){s.resolve=t,s.reject=e;})),s.func=t,s.context=this,s.handleResult=void 0!==i&&i?i:this._handleBasicResult,s.params.input=void 0!==e&&e?e:"",s.params.returnType=k.RT_AUTO,s.params.returnBlob=!0,s.params.logLevel=Ai.level,s.params.cost={},s.params.cost.ctime=Date.now(),s.params.cost.time=s.params.cost.ctime,s}_addTask(t,e){if(t.params.cost){const e=t.params.cost.time;t.params.cost.time=Date.now(),t.params.cost.create=t.params.cost.time-e;}return v(this,xe,"f")===C.destroyed?t.reject({code:A.wasmJsObjectNotInit,message:v(this,we,"f")?"object has been disposed":"object not init"}):v(this,xe,"f")===C.failed?t.reject({code:A.wasmJsObjectInitFailed,message:v(this,ve,"f")}):(e?v(this,de,"f").unshift(t):v(this,de,"f").push(t),v(this,oe,"m",ke).call(this)),t.promise}terminate(t){let e=this;v(e,Pe,"f")?x(e,we,!0,"f"):(x(this,Ae,!0,"f"),v(e,oe,"m",Re).call(e).then((function(t){Ai.logD("["+e.id+"] "+v(e,le,"f").name+" destroy return: "),Ai.logD(t);})).catch((function(t){Ai.logD(v(e,le,"f").name+" destroy failed"),Ai.logD(t);})).finally((()=>{Ii.Instance&&Ii.Instance.removeInstanceInWorker(v(e,le,"f"),v(e,ce,"f"),v(e,pe,"f"),null==t||t),x(e,ce,null,"f"),x(e,we,!0,"f"),x(e,Ae,!1,"f");}))),x(e,xe,"","f");}_readFile(t){return ki.read(t).catch((function(t){let e=t;return "object"!=typeof e&&(e={},e.code=A.wasmJsReadFileFailed,e.message=t),Promise.reject(e)}))}updateLicense(t,e,i){return m(this,void 0,void 0,(function*(){x(this,he,t,"f"),x(this,be,null!=e?e:P.LONG_KEY,"f"),x(this,Ce,null!=i?i:"","f");let n=this,s=n._createTask("UpdateLicense");return s.params.input=[v(n,he,"f"),v(n,be,"f"),v(n,Ce,"f")],n._addTask(s),s.promise}))}}re=Mi,le=new WeakMap,he=new WeakMap,de=new WeakMap,ce=new WeakMap,ue=new WeakMap,pe=new WeakMap,ge=new WeakMap,fe=new WeakMap,ye=new WeakMap,me=new WeakMap,ve=new WeakMap,xe=new WeakMap,we=new WeakMap,be=new WeakMap,Ce=new WeakMap,Se=new WeakMap,Pe=new WeakMap,Ae=new WeakMap,oe=new WeakSet,Te=function t(e){let i=null!=e?e:this;return v(i,ge,"f")&&clearTimeout(v(i,ge,"f")),v(i,we,"f")?(Ai.logD(`[${i.id}] has been termiated.(getWorker)`),i._cancelAllTasks(A.wasmJsObjectTerminated,`Instance [${i.id}] has been termiated.`),v(i,ce,"f")):v(i,ce,"f")&&v(i,ce,"f").alive?v(i,ce,"f"):void(Ii.Instance?Ii.Instance.getWorker(v(i,le,"f"),v(i,pe,"f")).then((e=>{var n;if(x(i,ce,e.worker,"f"),v(i,ce,"f")&&v(i,ce,"f").alive)v(i,Se,"f")!=v(i,ce,"f").id&&(0!==v(i,Se,"f")&&i._workerChanged(v(i,ce,"f").id),x(i,Se,v(i,ce,"f").id,"f")),v(i,de,"f").length>0&&setTimeout((()=>{v(i,oe,"m",ke).call(i);}),0);else {let e=null===(n=Ii.Instance)||void 0===n?void 0:n.getModuleLoadedError(v(i,le,"f").name);if(null==e?void 0:e.code)return i._cancelAllTasks(A.wasmJsNotLoaded,e.message),v(i,ce,"f");v(i,de,"f").length>0&&x(i,ge,setTimeout(v(i,oe,"m",t),50,i),"f");}return v(i,ce,"f")})).catch((t=>v(i,ce,"f"))):i._cancelAllTasks(A.wasmJsNotLoaded,"wasm env not loaded or unloaded"))},ke=function(){if(Ai.logAll(v(this,de,"f")),v(this,xe,"f")!=C.init)if(v(this,ce,"f")&&v(this,ce,"f").alive){if(v(this,de,"f").length>0&&(v(this,xe,"f")===C.ready||"init"===v(this,de,"f")[0].func)){const t=v(this,de,"f").shift();this._execTask(t);}}else {if(v(this,ce,"f")&&!v(this,ce,"f").alive&&v(this,de,"f").length>0&&"init"!=v(this,de,"f")[0].func)return x(this,ce,null,"f"),void v(this,oe,"m",Ie).call(this);v(this,de,"f").length>0&&v(this,le,"f").script&&v(this,oe,"m",Te).call(this,this);}else v(this,oe,"m",Ie).call(this);},De=function(t,e,i,n){return i?Ri.newBlobInChunks(t,e,n):void 0===n||n===t.byteLength?t:t.slice(0,n)},Ee=function(t){try{return "string"==typeof t?JSON.parse(t):t}catch(e){return t}},Ie=function(){let t=this;t._prepareModule(v(this,le,"f"));let e=this._createTask("init");e.params.key=v(this,he,"f"),e.params.uuid=v(this,Ce,"f"),e.params.licMode=v(this,be,"f"),e.params.val={nv:v(this,fe,"f"),mb:v(this,ye,"f"),dm:v(this,me,"f")},e.handleResult=function(t,e){return x(e.context,xe,C.ready,"f"),t},x(this,xe,C.pending,"f"),this._addTask(e,!0),e.promise.then((function(e){Ai.logD("["+t.id+"] "+v(t,le,"f").name+" init return: "),Ai.logD(e),x(t,Pe,!1,"f");})).catch((function(e){x(t,xe,C.failed,"f"),x(t,ve,e.message,"f"),Ai.logD(v(t,le,"f").name+" init failed"),Ai.logD(e),t._cancelAllTasks(A.wasmJsObjectInitFailed,e.message);}));},Re=function(){if(v(this,xe,"f")==C.pending||v(this,xe,"f")==C.ready){let t=this._createTask("destroy",null,this._handleBooleanResult);return this._addTask(t),t.promise}return Promise.resolve(!0)},ae={value:0};class Bi extends Mi{constructor(t,e){super(t,e);}_prepareModule(t){let e=Ii.Instance;e.addModules(Ti.ImageIOModule),Ti.LicMode===P.DLS_KEY&&e.addModules(Ti.CryptoModule),v(Bi,Me,"m",Be).call(Bi,Ti.ImageIOModule,t),e.addModules(t);}}Me=Bi,Be=function(t,e){e.resourceDir=t.resourceDir,e.crossScript=t.crossScript,e.script=t.script,e.useSimd=t.useSimd,e.name===w.imgProc?e.useSimd=Ti.UseSimd:e.useSimd=!1,e.fetchOptions=t.fetchOptions;};class Li extends Bi{constructor(t){super(Ti.ImagecoreModule,t),Le.add(this),Ue.set(this,0);}getImageFormat(t){return m(this,void 0,void 0,(function*(){let e=this,i=e._createTask("GetImageFormat");const n=yield e._readFile(t);return i.params.input=n,e._addTask(i),i.promise}))}readImageInfo(t){return m(this,void 0,void 0,(function*(){let e=this,i=e._createTask("ReadImageInfo");const n=yield e._readFile(t);return i.params.input=n,e._addTask(i),i.promise}))}getMD5(t){return m(this,void 0,void 0,(function*(){let e=this,i=e._createTask("GetMD5");const n=yield e._readFile(t);return i.params.input=n,i.handleResult=function(t,e){return t.MD5},e._addTask(i),i.promise}))}getLicenseInfo(){return m(this,void 0,void 0,(function*(){return this._addTask(this._createTask("GetLicenseInfo"))}))}getAesResult(t){return m(this,void 0,void 0,(function*(){return t=null!=t?t:"",this._addTask(this._createTask("GetAesResult",[t]))}))}saveImage(t,e,i,n,s){return m(this,void 0,void 0,(function*(){return (s=null!=s&&s)?v(this,Le,"m",Oe).call(this,t,void 0,void 0,void 0,1,void 0,void 0,e,i,n):v(this,Le,"m",Oe).call(this,t,void 0,void 0,void 0,void 0,void 0,void 0,e,i,n)}))}readImage(t,e,i,n,s){return m(this,void 0,void 0,(function*(){e=null!=e?e:this._outputType,i=null!=i?i:this._jpegQuality,n=null!=n&&n,s=null!=s&&s;let o=this,r=o._createTask("ReadImage");const a=yield o._readFile(t);r.params.input=[a,e,i,s],r.params.returnType=n?k.RT_BASE64:k.RT_AUTO,r.params.returnBlob=!n,r.handleResult=o._handleImageData,o._addTask(r);const l=yield r.promise;if(l.srcBuffer){let e=Object.prototype.toString.call(t);"[object ArrayBuffer]"!=e&&"[object Uint8ClampedArray]"!=e&&delete l.srcBuffer;}return l}))}openTiff(t,e){return m(this,void 0,void 0,(function*(){let i=this,n=i._createTask("LoadTiff");e=null!=e&&e;const s=yield i._readFile(t);n.params.input=[s,e],i._addTask(n);const o=yield n.promise;if(o.srcBuffer){let e=Object.prototype.toString.call(t);"[object ArrayBuffer]"!=e&&"[object Uint8ClampedArray]"!=e&&delete o.srcBuffer;}return o}))}readTiff(t,e,i,n){t=null!=t?t:0,e=null!=e?e:this._outputType,i=null!=i&&i,n=null!=n&&n;let s=this._createTask("ReadTiffPage");return s.params.input=[t,e,n],s.params.returnType=i?k.RT_BASE64:k.RT_AUTO,s.params.returnBlob=!i,s.handleResult=this._handleImageData,this._addTask(s)}readTiffInfos(t){let e=this._createTask("GetTiffPageInfos");return e.params.input=[t],this._addTask(e)}closeTiff(){return this._addTask(this._createTask("EndReadTiff",null,this._handleBooleanResult))}createTiff(){return this._addTask(this._createTask("NewTiff",null,this._handleBooleanResult))}appendImage(t,e,i,n,s){return m(this,void 0,void 0,(function*(){e=null!=e?e:this._inputType,i=null!=i?i:v(this,Ue,"f"),n=null!=n?n:this._jpegQuality,s=null!=s&&s;let o=this,r=o._createTask("AppendImageToTiff");const a=yield o._readFile(t);return r.params.input=[a,e,i,n,s],r.handleResult=o._handleBooleanResult,o._addTask(r),r.promise}))}addTag(t,e,i){return i=null!=i&&i,this._addTask(this._createTask("AddTagToNextPage",[t,e,i],this._handleBooleanResult))}getTiff(t){let e=this._createTask("GetTiffStream");return e.handleResult=this._handleImageData,e.params.returnType=null!=t?t:k.RT_AUTO,e.params.returnBlob=t!=k.RT_AUTO,this._addTask(e)}getMemoryUsed(){return this._addTask(this._createTask("getMemoryUsed",null,(function(t,e){return t.memoryUsed})))}getMultiPartFile(t,e){return this._addTask(this._createTask("ds_get_file",[t,e],(function(t,e){return t})))}}Ue=new WeakMap,Le=new WeakSet,Oe=function(t,e,i,n,s,o,r,a,l,h){return m(this,void 0,void 0,(function*(){let d=this;e=null!=e?e:this._inputType,i=null!=i?i:0,n=null!=n?n:0,s=null!=s?s:24,o=null!=o?o:96,r=null!=r?r:96,a=null!=a?a:this._outputType,l=null!=l?l:this._jpegQuality,h=null!=h?h:k.RT_AUTO;let c=d._createTask("SaveImage");const u=yield d._readFile(t);return c.params.input=[u,e,i,n,s,o,r,a,l],c.params.returnType=h,c.params.returnBlob=h!=k.RT_BASE64,c.handleResult=d._handleImageData,d._addTask(c),c.promise}))};class Ui extends Bi{constructor(t){super(Ti.ImageReadereModule,t),Ne.add(this),_e.set(this,0),We.set(this,!1),Fe.set(this,null),He.set(this,void 0),Ve.set(this,0),ze.set(this,void 0),je.set(this,void 0);}workerChanged(t){x(this,We,!1,"f"),t&&(Ai.logD("["+this.id+"] worker changed to "+t),x(this,Ve,t,"f"));}setExternalWorkerChanged(t,e){x(this,ze,t,"f"),x(this,je,e,"f");}_workerChanged(t){this.workerChanged(t),v(this,ze,"f")&&v(this,ze,"f").call(this,v(this,je,"f"),this,t);}_canTerminateWork(){return !0}makeSureWorkerMemoryNotExceed(){this._makeSureWorkerMemoryNotExceed()||(x(this,We,!1,"f"),v(this,ze,"f")&&v(this,ze,"f").call(this,v(this,je,"f"),this));}getImageFormat(t){return m(this,void 0,void 0,(function*(){let e=this,i=e._createTask("GetImageFormat");const n=yield e._readFile(t.fileSource);return i.params.input=n,e._addTask(i),i.promise}))}readImageInfo(t){return m(this,void 0,void 0,(function*(){let e=this,i=e._createTask("ReadImageInfo");const n=yield e._readFile(t.fileSource);return i.params.input=n,e._addTask(i),i.promise}))}readImage(t,e,i,n,s){return m(this,void 0,void 0,(function*(){e=null!=e?e:this._outputType,i=null!=i?i:this._jpegQuality,n=null!=n&&n,s=null!=s&&s;let o=this,r=o._createTask("ReadImage");const a=yield o._readFile(t.fileSource);r.params.input=[a,e,i,s],r.params.returnType=n?k.RT_BASE64:k.RT_AUTO,r.params.returnBlob=!n,r.handleResult=o._handleImageData,o._addTask(r);const l=yield r.promise;if(l.srcBuffer){let e=Object.prototype.toString.call(t.fileSource);"[object ArrayBuffer]"!=e&&"[object Uint8ClampedArray]"!=e&&delete l.srcBuffer;}return l}))}openTiff(t,e){return m(this,void 0,void 0,(function*(){e=null!=e&&e;let i,n=this,s=n._createTask("LoadTiff");t!=v(this,Fe,"f")&&(t instanceof Blob?x(n,Fe,t,"f"):(i=yield n._readFile(t),x(n,Fe,Ri.newBlobInChunks(i),"f"))),v(n,Fe,"f").size>1024*Ti.FileReadModeSize*1024?s.params.input=[v(n,Fe,"f"),e]:(i||(i=yield n._readFile(v(n,Fe,"f"))),s.params.input=[i,e]),n._addTask(s);const o=yield s.promise;if(x(n,We,!0,"f"),o.srcBuffer){let e=Object.prototype.toString.call(t);"[object ArrayBuffer]"!=e&&"[object Uint8ClampedArray]"!=e&&delete o.srcBuffer;}return x(n,He,{pageCount:o.pageCount},"f"),o}))}readTiffPage(t,e,i,n,s){return m(this,void 0,void 0,(function*(){yield v(this,Ne,"m",$e).call(this,t.fileSource),e=null!=e?e:0,i=null!=i?i:this._outputType,n=null!=n&&n,s=null!=s&&s;let o=this._createTask("ReadTiffPage");return o.params.input=[e,i,s],o.params.returnType=n?k.RT_BASE64:k.RT_AUTO,o.params.returnBlob=!n,o.handleResult=this._handleImageData,this._addTask(o)}))}getTiffInfo(t,e){return m(this,void 0,void 0,(function*(){return yield v(this,Ne,"m",$e).call(this,t.fileSource),v(this,He,"f")}))}getTiffPageInfos(t,e){return m(this,void 0,void 0,(function*(){yield v(this,Ne,"m",$e).call(this,t.fileSource);let i=this._createTask("GetTiffPageInfos");return i.params.input=[e],this._addTask(i)}))}}_e=new WeakMap,We=new WeakMap,Fe=new WeakMap,He=new WeakMap,Ve=new WeakMap,ze=new WeakMap,je=new WeakMap,Ne=new WeakSet,$e=function(t){return m(this,void 0,void 0,(function*(){if(this.makeSureWorkerMemoryNotExceed(),v(this,We,"f")){if(v(this,Fe,"f")===t)return void Ai.logD("["+this.id+"] already opened in "+this.workerId);yield v(this,Ne,"m",Ge).call(this);}Ai.logD("["+this.id+"] reopen in worker "+this.workerId),yield this.openTiff(t,!1);}))},Ge=function(){if(x(this,Fe,null,"f"),v(this,We,"f"))return x(this,We,!1,"f"),this._addTask(this._createTask("EndReadTiff",null,this._handleBooleanResult))};class Oi{static decode(t){const e={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]};function i(t){let e,i,n,s,o,r,a,l=[],h=t.length;for(e=0;e<h;e++)s=t.charCodeAt(e),s>>7&255?6==(s>>5&255)?(o=t.charCodeAt(++e),i=(31&s)<<6,n=63&o,a=i|n,l.push(String.fromCharCode(a))):14==(s>>4&255)&&(o=t.charCodeAt(++e),r=t.charCodeAt(++e),i=s<<4|o>>2&15,n=(3&o)<<6|63&r,a=(255&i)<<8|n,l.push(String.fromCharCode(a))):l.push(t.charAt(e));return l.join("")}return function(t){let n,s,o,r,a=[],l=0,h=t.length;for(;l<h;){do{n=e.decodeChars[255&t.charCodeAt(l++)];}while(l<h&&-1==n);if(-1==n)break;do{s=e.decodeChars[255&t.charCodeAt(l++)];}while(l<h&&-1==s);if(-1==s)break;a.push(String.fromCharCode(n<<2|(48&s)>>4));do{if(o=255&t.charCodeAt(l++),61==o)return i(a.join(""));o=e.decodeChars[o];}while(l<h&&-1==o);if(-1==o)break;a.push(String.fromCharCode((15&s)<<4|(60&o)>>2));do{if(r=255&t.charCodeAt(l++),61==r)return i(a.join(""));r=e.decodeChars[r];}while(l<h&&-1==r);if(-1==r)break;a.push(String.fromCharCode((3&o)<<6|r));}return i(a.join(""))}(t)}}!function(t){t[t.render=1]="render",t[t.extractImageOnly=2]="extractImageOnly",t[t.auto=3]="auto",t[t.renderWithAnnot=4]="renderWithAnnot";}(ui||(ui={}));class Ni extends Mi{constructor(t){super(Ti.PdfReaderModule,t),Xe.add(this),Je.set(this,void 0),Ze.set(this,void 0),Ke.set(this,0),ti.set(this,200),ei.set(this,3),ii.set(this,!1),ni.set(this,void 0),si.set(this,null),oi.set(this,""),this._outputType=T.IT_ALL;}static get fonts(){return v(this,Ye,"f",qe)}static addPdfFont(t,e){return m(this,void 0,void 0,(function*(){return v(this,Ye,"m",Qe).call(this,t,e)}))}static getPdfFonts(){return this.fonts?Object.keys(this.fonts):[]}static removeFont(){x(this,Ye,Object.create(null),"f",qe);}workerChanged(t){x(this,ii,!1,"f"),t&&(Ai.logD("["+this.id+"] worker changed to "+t),x(this,Ke,t,"f"));}setExternalWorkerChanged(t,e){x(this,Je,t,"f"),x(this,Ze,e,"f");}_workerChanged(t){this.workerChanged(t),v(this,Je,"f")&&v(this,Je,"f").call(this,v(this,Ze,"f"),this,t);}_canTerminateWork(){return !0}makeSureWorkerMemoryNotExceed(){this._makeSureWorkerMemoryNotExceed()||(x(this,ii,!1,"f"),v(this,Je,"f")&&v(this,Je,"f").call(this,v(this,Ze,"f"),this));}getPdfInfo(t){return m(this,void 0,void 0,(function*(){return yield v(this,Xe,"m",ri).call(this,t),v(this,ni,"f")}))}readPage(t,e,i,n,s,o,r,a){return m(this,void 0,void 0,(function*(){return this.readPageEx(t,e,{convertMode:n,renderOptions:{resolution:i}},s,o,r,a)}))}readPageEx(t,e,i,n,s,o,r){return m(this,void 0,void 0,(function*(){yield v(this,Xe,"m",ri).call(this,t),e=null!=e?e:0,n=null!=n?n:this._outputType,o=null!=o&&o,s=null!=s&&s,r=null!=r&&r;let a=i?JSON.stringify(i):"{}",l=this._createTask("ReadPdfPageEx");return l.params.input=[e,a,n,s,r],l.params.returnType=o?k.RT_BASE64:k.RT_AUTO,l.params.returnBlob=!o,l.handleResult=this._handleImageData,this._addTask(l)}))}readPageImageInfos(t,e,i,n){return m(this,void 0,void 0,(function*(){yield v(this,Xe,"m",ri).call(this,t),n=null!=n?n:this._outputType;let s=i?JSON.stringify(i):"{}",o=this._createTask("ReadPageImageInfos");return o.params.input=[e,s,n],this._addTask(o)}))}readPageAnnot(t,e){return m(this,void 0,void 0,(function*(){yield v(this,Xe,"m",ri).call(this,t),e=null!=e?e:0;let i=this._createTask("GetPageAnnot",[e]);return this._addTask(i)}))}findText(t,e,i,n){return m(this,void 0,void 0,(function*(){yield v(this,Xe,"m",ri).call(this,t);let s=0;return n&&(n.matchCase&&(s|=1),n.matchWholeWord&&(s|=2),n.consecutive&&(s|=4)),this._addTask(this._createTask("SearchText",[e,i,s]))}))}getCharInfos(t,e){return m(this,void 0,void 0,(function*(){return yield v(this,Xe,"m",ri).call(this,t),this._addTask(this._createTask("GetPageCharInfos",[e]))}))}getPageInfos(t,e){return m(this,void 0,void 0,(function*(){return yield v(this,Xe,"m",ri).call(this,t),this._addTask(this._createTask("GetPdfPageInfos",[e]))}))}getPdfPageType(t,e){return m(this,void 0,void 0,(function*(){return yield v(this,Xe,"m",ri).call(this,t),this._addTask(this._createTask("GetPageContentType",[e]))}))}UnloadPage(t){return m(this,void 0,void 0,(function*(){return t=null!=t?t:0,this._addTask(this._createTask("UnloadPdfPage",[t]))}))}}Ye=Ni,Je=new WeakMap,Ze=new WeakMap,Ke=new WeakMap,ti=new WeakMap,ei=new WeakMap,ii=new WeakMap,ni=new WeakMap,si=new WeakMap,oi=new WeakMap,Xe=new WeakSet,Qe=function(t,e){return m(this,void 0,void 0,(function*(){if("string"==typeof t&&0!==t.length||Promise.reject("The 'name' should be a valid string"),