UNPKG

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.

14 lines (12 loc) 1.62 MB
/*! * 20260417111300 * Dynamsoft JavaScript Library * Product: Dynamsoft Document Viewer * Web Site: https://www.dynamsoft.com * * Copyright 2026, Dynamsoft Corporation * Author: Dynamsoft Support Team * Version: 4.0.0 */ import { mapPackageRegister, CoreModule } from 'dynamsoft-core'; 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 c(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 d(t,e),u(i,"get"),h(t,i)}function a(t,e,i,n){return d(t,e),u(i,"set"),c(t,i,n),n}function l(t,e,i){return d(t,e),i}function h(t,e){return e.get?e.get.call(t):e.value}function c(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 d(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 v(t,e){g(t,e),e.add(t);}function y(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 m(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,S,C,P,T,A,k,R,D,E,M,I,B,U,L,O,N,F,_,W,H,V,z,$,j,G,X,Y,q,J,Z,Q,K,tt,et,it,nt,st,ot,rt,at,lt,ht,ct,dt,ut,pt,gt,ft,vt,yt,mt,xt,wt,bt,St,Ct,Pt,Tt,At,kt,Rt,Dt,Et,Mt,It,Bt,Ut,Lt,Ot,Nt,Ft,_t,Wt,Ht,Vt,zt,$t,jt,Gt,Xt,Yt,qt,Jt,Zt,Qt,Kt,te,ee,ie,ne,se,oe,re,ae,le,he,ce,de,ue,pe,ge,fe,ve,ye,me,xe,we,be,Se,Ce,Pe,Te,Ae,ke,Re,De,Ee,Me,Ie,Be,Ue;"function"==typeof SuppressedError&&SuppressedError,function(t){t.logNone="",t.logError="logError",t.logDebug="logDebug",t.logAll="logAll",t.imgIO="imgIO",t.imgProc="imgProc",t.binaryBlobType="application/octet-stream",t.wasmExtension=".wasm";}(w||(w={})),function(t){t.imgCore="imgCore",t.imgProc="imgProc",t.pdfCore="pdfCore";}(b||(b={})),function(t){t.core="ddv-core",t.reader="ddv-reader",t.detector="ddv-detector",t.loader="ddv-loader",t.proc="ddv-proc";}(S||(S={})),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.";}(P||(P={})),function(t){t[t.LONG_KEY=0]="LONG_KEY",t[t.DLS_KEY=1]="DLS_KEY";}(T||(T={})),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";}(k||(k={})),function(t){t[t.RT_AUTO=-1]="RT_AUTO",t[t.RT_BINARY=1]="RT_BINARY",t[t.RT_BASE64=2]="RT_BASE64";}(R||(R={})),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="4.0.0",t.imgProcVer="4.0.0";}(rt||(rt={}));let Le=class{static setLogFunc(t,e,i){x(this,E,null!=t?t:w.logNone,"f",M),x(this,E,m(this,E,"f",L)[t],"f",I),x(this,E,e,"f",B),x(this,E,i,"f",U);}static changeLogLevel(t){x(this,E,null!=t?t:w.logNone,"f",M),x(this,E,m(this,E,"f",L)[t],"f",I);}static get level(){return m(this,E,"f",M)}static get func(){return m(this,E,"f",B)}static get context(){return m(this,E,"f",U)}static logAll(t){this.log(m(this,E,"f",L)[w.logAll],t);}static logD(t){this.log(m(this,E,"f",L)[w.logDebug],t);}static log(t,e){m(this,E,"f",B)&&m(this,E,"f",I)>=t&&m(this,E,"f",B).call(this,e,m(this,E,"f",U));}};E=Le,M={value:w.logNone},I={value:0},B={value:void 0},U={value:null},L={value:{[w.logNone]:0,[w.logError]:1,[w.logDebug]:2,[w.logAll]:3}};let Oe=class t{static unload(){x(this,O,"","f",N),x(this,O,"","f",_),x(this,O,null,"f",W),x(this,O,null,"f",$),x(this,O,{name:w.imgIO,instanceName:b.imgCore,workerName:S.core,autoLoad:!1,ver:rt.imgIOVer,prefixName:t.ImageIOPrefixName,useSimd:!1,fetchOptions:m(t,O,"f",K),useBrotli:t.UseBrotli},"f",nt),x(this,O,{name:w.imgProc,instanceName:b.imgProc,workerName:S.proc,autoLoad:!1,ver:rt.imgProcVer,prefixName:t.ImageProcPrefixName,useSimd:t.UseSimd,useBrotli:t.UseBrotli},"f",st),Le.setLogFunc("",void 0,null);}static get UseSimd(){return m(this,O,"f",V)}static set UseSimd(t){x(this,O,t,"f",V);}static get UseBrotli(){return m(this,O,"f",z)}static set UseBrotli(t){x(this,O,t,"f",z);}static get License(){return m(this,O,"f",N)}static set License(t){x(this,O,t,"f",N);}static get LicMode(){return m(this,O,"f",F)}static set LicMode(t){x(this,O,t,"f",F);}static get UUID(){return m(this,O,"f",_)}static set UUID(t){x(this,O,t,"f",_);}static get NavInfo(){return m(this,O,"f",W)}static set NavInfo(t){x(this,O,t,"f",W);}static get Mobile(){return m(this,O,"f",H)}static set Mobile(t){x(this,O,t,"f",H);}static get CustomFontsConfig(){return m(this,O,"f",$)}static set CustomFontsConfig(t){x(this,O,t,"f",$);}static get DefHeapSize(){return m(this,O,"f",j)}static set DefHeapSize(t){x(this,O,t,"f",j);}static get MaxHeapSize(){return m(this,O,"f",G)}static get HeapConfig(){return m(this,O,"m",Y).call(this),Object.assign({},m(this,O,"f",X))}static getWorkerHeap(t){return void 0!==m(this,O,"f",X)[t]?m(this,O,"f",X)[t]:{maxHeapSize:m(this,O,"f",G),initHeapSize:m(this,O,"f",j)}}static UpdateHeapConfig(t,e,i){m(this,O,"m",Y).call(this),e&&void 0!==m(this,O,"f",X)[t]&&(m(this,O,"f",X)[t].maxHeapSize=e),i&&void 0!==m(this,O,"f",X)[t]&&(m(this,O,"f",X)[t].initHeapSize=i);}static get FileReadModeSize(){return m(this,O,"f",q)}static set FileReadModeSize(t){x(this,O,t,"f",q);}static get FontUseFileReadMode(){return {load:m(this,O,"f",J),save:m(this,O,"f",Z)}}static set FontUseFileReadMode(t){"boolean"==typeof t.load&&x(this,O,t.load,"f",J),"boolean"==typeof t.save&&x(this,O,t.save,"f",Z);}static get ImageIOWorkerJS(){return "ddv-imageio.worker.js?v="+rt.imgIOVer}static get ImageProcWorkerJS(){return "ddv-imageproc.worker.js?v="+rt.imgProcVer}static get ImageProcSimdWorkerJS(){return "ddv-imageproc-simd.worker.js?v="+rt.imgProcVer}static get ImageIOPrefixName(){return "ddv-imageio"}static get ImageProcPrefixName(){return "ddv-imageproc"}static get ImageIOResource(){return m(this,O,"f",tt)}static set ImageIOResource(t){x(this,O,m(this,O,"m",Q).call(this,t),"f",tt),m(this,O,"m",it).call(this,m(this,O,"f",tt),m(this,O,"f",nt)),m(this,O,"m",it).call(this,m(this,O,"f",tt),m(this,O,"f",st));}static get ImageProcResource(){return m(this,O,"f",et)}static set ImageProcResource(t){t.useFastCompEdition=!1,x(this,O,m(this,O,"m",Q).call(this,t),"f",et),m(this,O,"m",it).call(this,m(this,O,"f",et),m(this,O,"f",st));}static get ImageIOModule(){return m(this,O,"f",nt)}static get ImageCoreModule(){return Object.assign({},m(this,O,"f",nt))}static get ImageReadereModule(){const t=Object.assign({},m(this,O,"f",nt));return t.workerName=S.reader,t}static get PdfReaderModule(){const t=Object.assign({},m(this,O,"f",nt));return t.workerName=S.reader,t.singleInstance=!0,t.instanceName=b.pdfCore,t}static get PdfWriterModule(){const t=Object.assign({},m(this,O,"f",nt));return t.singleInstance=!0,t.instanceName=b.pdfCore,t}static get ImageProcModule(){return m(this,O,"f",st)}static get DetectorModule(){return x(this,O,Object.assign({},m(this,O,"f",st)),"f",ot),m(this,O,"f",ot).workerName=S.detector,m(this,O,"f",ot)}static setLogFunc(t,e,i){Le.setLogFunc(t,e,i);}static changeLogLevel(t){Le.changeLogLevel(t);}static hasLogFunc(){return void 0!==Le.func}};O=Oe,Y=function(){0===Object.keys(m(this,O,"f",X)).length&&(m(this,O,"f",X)[S.core]={},m(this,O,"f",X)[S.core].maxHeapSize=m(this,O,"f",G),m(this,O,"f",X)[S.core].initHeapSize=m(this,O,"f",j),m(this,O,"f",X)[S.reader]={},m(this,O,"f",X)[S.reader].maxHeapSize=m(this,O,"f",G),m(this,O,"f",X)[S.reader].initHeapSize=m(this,O,"f",j),m(this,O,"f",X)[S.detector]={},m(this,O,"f",X)[S.detector].maxHeapSize=m(this,O,"f",G),m(this,O,"f",X)[S.detector].initHeapSize=m(this,O,"f",j),m(this,O,"f",X)[S.proc]={},m(this,O,"f",X)[S.proc].maxHeapSize=m(this,O,"f",G),m(this,O,"f",X)[S.proc].initHeapSize=m(this,O,"f",j));},Q=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:m(this,O,"f",V),fetchOptions:null!==(n=t.fetchOptions)&&void 0!==n?n:m(this,O,"f",K),useBrotli:null!==(s=t.useBrotli)&&void 0!==s?s:m(this,O,"f",z)};return t.resourceDir.startsWith("http://")||t.resourceDir.startsWith("https://")||t.resourceDir.includes("://")?(o.resourceDir=t.resourceDir,t.resourceDir.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.replace(/[?#].*/,"").lastIndexOf("/")+1)+t.resourceDir),o.resourceDir.endsWith("/")||(o.resourceDir+="/"),t.useFastCompEdition&&(o.resourceDir+="fastcomp/"),o.workerScript=o.resourceDir+t.workerScript,o},it=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;},N={value:""},F={value:T.LONG_KEY},_={value:""},W={value:null},H={value:!1},V={value:!1},z={value:!1},$={value:null},j={value:32},G={value:200},X={value:Object.create(null)},q={value:20},J={value:!0},Z={value:!1},K={value:{mode:"cors",credentials:"same-origin",retries:3,retryDelay:500}},tt={value:{resourceDir:"",workerScript:Oe.ImageIOWorkerJS,useFastCompEdition:!1,useSimd:!1,crossScript:!1,fetchOptions:m(Oe,O,"f",K),useBrotli:Oe.UseBrotli}},et={value:{resourceDir:"",workerScript:Oe.ImageIOWorkerJS,useFastCompEdition:!1,useSimd:!1,crossScript:!1,fetchOptions:m(Oe,O,"f",K),useBrotli:Oe.UseBrotli}},nt={value:{name:w.imgIO,instanceName:b.imgCore,workerName:S.core,autoLoad:!1,ver:rt.imgIOVer,prefixName:Oe.ImageIOPrefixName,useSimd:!1,fetchOptions:m(Oe,O,"f",K),useBrotli:Oe.UseBrotli}},st={value:{name:w.imgProc,instanceName:b.imgProc,workerName:S.proc,autoLoad:!1,ver:rt.imgProcVer,prefixName:Oe.ImageProcPrefixName,useSimd:Oe.UseSimd,useBrotli:Oe.UseBrotli}},ot={value:void 0};class Ne{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),m(Ne,at,"m",lt).call(Ne,s,e,i);}else "[object ArrayBuffer]"===n||"[object Uint8ClampedArray]"===n?e(t):i("Not support source type: "+n);}))}}at=Ne,lt=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 Fe{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)}))}}let _e=class{constructor(t,e,i,n,s,o){ht.add(this),ct.set(this,void 0),dt.set(this,void 0),ut.set(this,void 0),pt.set(this,void 0),gt.set(this,void 0),ft.set(this,void 0),vt.set(this,void 0),yt.set(this,void 0),mt.set(this,void 0),xt.set(this,void 0),wt.set(this,void 0),bt.set(this,void 0),St.set(this,void 0),Ct.set(this,0),Pt.set(this,{}),Tt.set(this,null),x(this,ct,t,"f"),x(this,mt,n,"f"),x(this,St,i,"f"),x(this,ut,[],"f"),x(this,pt,!1,"f"),x(this,gt,!1,"f"),x(this,Ct,e,"f"),x(this,Tt,Object.create(null),"f"),m(this,Pt,"f").modulesInfo=[],x(this,wt,Object.create(null),"f"),x(this,yt,null,"f"),x(this,xt,0,"f"),x(this,bt,0,"f"),x(this,dt,m(this,ht,"m",kt).call(this,m(this,ct,"f")),"f"),m(this,dt,"f").on("message",m(this,ht,"m",Dt),this),m(this,dt,"f").on("error",m(this,ht,"m",Rt),this),m(this,dt,"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",m(n,ht,"m",Rt).call(n,new Error(s),n);}),this);}get WorkerScript(){return m(this,mt,"f")}get id(){return m(this,Ct,"f")}get Module(){return m(this,Pt,"f")}get Instances(){return m(this,Tt,"f")}get WorkerName(){return m(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,bt,+m(this,bt,"f")+1,"f");m(this,wt,"f")[n]={id:n,insId:e.insId,resolver:i,cost:e.cost},delete e.cost;let s={id:n,func:t,params:e};return Le.logD("["+e.insId+"] "+t+" send"),m(this,gt,"f")?i.reject(new Error("Worker is #terminated")):m(this,pt,"f")?i.reject(new Error("Worker is #terminating")):m(this,dt,"f").wasmReady||m(this,dt,"f").ready&&"loadWasm"===t?m(this,dt,"f").send(s):m(this,ut,"f").push(s),i.promise}get memSize(){return m(this,xt,"f")}get busy(){return this.howManyTasks>0}get howManyTasks(){return Object.keys(m(this,wt,"f")).length}get alive(){return !m(this,pt,"f")&&!m(this,gt,"f")}terminate(t,e){if(Le.logD("["+this.id+"] worker terminate "+t),t&&m(this,ht,"m",Mt).call(this,"Worker has been #terminated"),"function"==typeof e&&x(this,yt,e,"f"),this.busy)x(this,pt,!0,"f");else {if(m(this,dt,"f")){if("function"!=typeof m(this,dt,"f").terminate)throw new Error("Failed to terminate worker");Le.logD("["+this.id+"] will be terminated"),m(this,dt,"f").terminate(),x(this,dt,null,"f");}x(this,pt,!1,"f"),x(this,gt,!0,"f"),m(this,yt,"f")&&m(this,yt,"f").call(this,this);}}hasInstance(t){if(t){const e=m(this,Tt,"f")[t];if(e)return 0!=Object.keys(e).length}else {const t=Object.keys(m(this,Tt,"f"));for(const e of t)if(0!=Object.keys(m(this,Tt,"f")[e]).length)return !0}return !1}exceedMaxMemory(){const t=1024*Oe.getWorkerHeap(this.WorkerName).maxHeapSize*1024;return !!(m(this,xt,"f")&&m(this,xt,"f")>t&&0!=t)&&(Le.logD("[w-"+this.id+"] current memSize="+m(this,xt,"f")+", max="+t),!0)}shouldBeFreed(){return !(!this.exceedMaxMemory()||this.hasInstance(void 0)||(Le.logD("[w-"+this.id+"] try to terminate the worker"),this.terminate(),0))}};ct=new WeakMap,dt=new WeakMap,ut=new WeakMap,pt=new WeakMap,gt=new WeakMap,ft=new WeakMap,vt=new WeakMap,yt=new WeakMap,mt=new WeakMap,xt=new WeakMap,wt=new WeakMap,bt=new WeakMap,St=new WeakMap,Ct=new WeakMap,Pt=new WeakMap,Tt=new WeakMap,ht=new WeakSet,At=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},kt=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},Rt=function(t,e){x(e,gt,!0,"f"),Le.logD("[js]["+e.id+"] worker error "+JSON.stringify(t)),m(e,pt,"f")&&m(e,yt,"f")&&m(e,yt,"f").call(e,e),x(e,pt,!1,"f"),m(e,ht,"m",Mt).call(e);},Dt=function(t,e){let i=t.id,n=m(e,wt,"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(Le.logD(t.log?t.log:t),"string"==typeof t&&"ready"===t)m(e,dt,"f").ready=!0,setTimeout((()=>{m(e,ht,"m",Et).call(e);}),0);else if(t.font)We.Instance.updateFontCache(w.imgIO,t.font.url,t.font.data);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,xt,t.memSize,"f");}if(void 0!==n){const s=n.insId;delete m(e,wt,"f")[i],Le.logD("["+s+"] "+t.func+" received"),!0===m(e,pt,"f")&&e.terminate(),"loadWasm"===t.func&&null!=t.result&&(m(e,dt,"f").wasmReady=!0,setTimeout((()=>{m(e,ht,"m",Et).call(e);}),0)),t.error?n.resolver.reject(m(e,ht,"m",At).call(e,t.error)):t.result&&n.resolver.resolve(t.result);}}},Et=function(){this.alive&&(m(this,ut,"f").forEach(m(this,dt,"f").send.bind(m(this,dt,"f"))),x(this,ut,[],"f"));},Mt=function(t){for(let e in m(this,wt,"f"))void 0!==m(this,wt,"f")[e]&&m(this,wt,"f")[e].resolver.reject(new Error(t));x(this,wt,Object.create(null),"f");};class We{constructor(){It.add(this),Lt.set(this,[]),Ot.set(this,4),Nt.set(this,60),Ft.set(this,!1),_t.set(this,0),Ht.set(this,!1);}static get Instance(){return m(this,Bt,"f",Ut)||x(this,Bt,new We,"f",Ut),m(this,Bt,"f",Ut)}get Terminated(){return m(this,Ft,"f")}getModuleLoadedError(t){for(let e of m(We,Bt,"f",Wt))if(e.name==t)return e.error}getModuleStatus(t){for(let e of m(We,Bt,"f",Wt))if(e.name==t)return e.status;return ""}addModules(t,e){let i=!1;if(m(We,Bt,"f",Wt).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,m(We,Bt,"f",Wt).push(i);}}loadModule(t,e){return y(this,void 0,void 0,(function*(){let i,n,s,o;null==e&&(e=0!=m(this,It,"m",qt).call(this,t).length),this.addModules(t);for(let r of m(We,Bt,"f",Wt))if(r.name===t.name){if(r.status===C.pending)return !1;if(r.wasmModule){if(e)return !0;i=r.wasmModule,n=r.wasmBinary,s=r.customFontsCache,o=r.customFontsConfig;break}break}let r=t;return r.status!==C.pending&&(i?(r.wasmModule=i,r.wasmBinary=n,r.customFontsCache=s,r.customFontsConfig=o,r.status=C.pending):""===r.status?(r.status=C.pending,r.wasmModule=null):e||(r.error={code:0,message:""},r.status=C.pending),m(this,It,"m",Vt).call(this,r))}))}updateFontCache(t,e,i){for(let n of m(We,Bt,"f",Wt))if(n.name===t){n.customFontsCache||(n.customFontsCache=new Map),n.customFontsCache.set(e,i);break}}get busy(){m(this,It,"m",Kt).call(this);let t=m(this,Lt,"f");for(let e of t)if(e.busy)return !0;return !1}getWorker(t,e){return y(this,void 0,void 0,(function*(){if(m(this,It,"m",Jt).call(this,t.name))return m(this,It,"m",Qt).call(this),{worker:null,workers:0};let i=m(this,It,"m",qt).call(this,t,!0);return 0!=i.length?{worker:m(this,It,"m",te).call(this,i,e,t),workers:i.length}:(yield this.loadModule(t,!1),{worker:null,workers:0})}))}removeInstanceInWorker(t,e,i,n){if(m(this,It,"m",ee).call(this,e,t.instanceName,i),n&&e&&e.shouldBeFreed()){let t=m(this,Lt,"f").indexOf(e);-1!==t&&m(this,Lt,"f").splice(t,1);}}terminate(t){x(We,Bt,null,"f",Ut),Le.logD("worker pool terminate "+t),x(this,Ft,!0,"f");let e=[];return m(this,Lt,"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(We,Bt,new Array,"f",Wt);}terminateWorker(t){m(this,Lt,"f").splice(0,m(this,Lt,"f").length,...m(this,Lt,"f").filter((e=>e.WorkerName!==t||(e.terminate(!0),!1))));}getMemoryUsed(){let t=m(this,Lt,"f"),e=[],i=0;for(let n of t)n&&null!=n.memSize&&(e[i]={},e[i].size=n.memSize,e[i].limit=1024*Oe.getWorkerHeap(n.WorkerName).maxHeapSize*1024,e[i].name=n.WorkerName,e[i].id=n.id,i+=1);return e}}Bt=We,Lt=new WeakMap,Ot=new WeakMap,Nt=new WeakMap,Ft=new WeakMap,_t=new WeakMap,Ht=new WeakMap,It=new WeakSet,Vt=function(t){return y(this,void 0,void 0,(function*(){let e=this,i=yield m(this,It,"m",Xt).call(this,t);if(i){let n={id:0,func:"loadWasm",params:{insId:0,priority:0,module:{modulesInfo:[]},fetchOptions:t.fetchOptions}};n.params.resourceDir=t.resourceDir,n.params.initMemory=Oe.getWorkerHeap(t.workerName).initHeapSize,n.params.module&&n.params.module.modulesInfo.push(t),yield m(this,It,"m",$t).call(this,i,n),x(e,Ot,m(e,It,"m",Gt).call(e),"f"),t.status===C.pending&&(t.status="");}else t.status="",t.wasmModule=null;}))},zt=function(t,e,i,n){for(let s of m(We,Bt,"f",Wt))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 y(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=m(n,It,"m",jt).call(n,i,t):Le.logD(i),s}catch(n){return Le.logD(n),!1}finally{i&&i();}}))},jt=function(t,e){if(Le.logD("handleWasmLoad:"),Le.logD(t),m(this,Ft,"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?(m(this,It,"m",zt).call(this,n.name,C.failed,null,{code:t.code,message:t.message}),e.Module.modulesInfo[n.name]=!1):(m(this,It,"m",zt).call(this,n.name,C.ready,n.wasmResource,void 0),e.Module.modulesInfo[n.name]=!0,i=!0);return i},Gt=function(){let t=2;return "hardwareConcurrency"in self.navigator&&(t=self.navigator.hardwareConcurrency),Math.max(Math.min(m(this,Ot,"f"),Math.max(m(this,Ot,"f"),t/2)),1)},Xt=function(t){return y(this,void 0,void 0,(function*(){m(this,It,"m",Kt).call(this);let e=m(this,Lt,"f");for(let i of e)if(i.WorkerName===t.workerName)return i.busy?null:i;return m(this,It,"m",Yt).call(this,t)}))},Yt=function(t){var e;return y(this,void 0,void 0,(function*(){let i=this,n=m(i,Lt,"f");if(n.length<m(i,Ot,"f")&&!m(i,Ht,"f")){x(i,Ht,!0,"f");let s=t.script;t.crossScript&&(s=yield Fe.fetchRetry(t.script,t.fetchOptions,Le.func,i).then((t=>t.blob())).then((t=>URL.createObjectURL(t))).catch((t=>(Le.logD("get new worker fetch failed: "),Le.logD(t),x(i,Ht,!1,"f"),null))));let o=new _e(s,x(e=i,_t,+m(e,_t,"f")+1,"f"),t.workerName,t.script,Le.func,Le.context);return n.push(o),x(i,Ht,!1,"f"),Le.logD("[wl-"+m(i,Lt,"f").length+"] got new worker w-"+o.id+"("+o.WorkerName+") succeed!"),o}return null}))},qt=function(t,e){m(this,It,"m",Kt).call(this);let i=m(this,Lt,"f"),n=[];for(let s of i)if(s.Module.modulesInfo[t.name]){if(e&&s.WorkerName!==t.workerName)continue;n.push(s);}return Le.logAll("[wl-"+i.length+"] got workers for module "+t.name),n},Jt=function(t){for(let e of m(We,Bt,"f",Wt))if(e.name===t&&e.status===C.pending)return !0;return !1},Zt=function(){return y(this,void 0,void 0,(function*(){this.terminate(!0);for(let t of m(We,Bt,"f",Wt))yield m(this,It,"m",Vt).call(this,t);}))},Qt=function(){m(this,It,"m",Kt).call(this),0==m(this,Lt,"f").length&&0!=m(We,Bt,"f",Wt).length&&(Le.logD("no worker ready, reinit"),m(this,It,"m",Zt).call(this));},Kt=function(){m(this,Lt,"f").splice(0,m(this,Lt,"f").length,...m(this,Lt,"f").filter((function(t){return t.alive})));},te=function(t,e,i){Le.logAll("[wl-"+m(this,Lt,"f").length+"] getWorkerByIntanceId");let n,s=9007199254740991;for(let o of t){if(i.singleInstance&&o.hasInstance(i.instanceName)&&!o.Instances[i.instanceName][e])continue;const t=o.Instances[i.instanceName];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.instanceName];if(s)s[e]="";else {const t=Object.create(null);t[e]="",n.Instances[i.instanceName]=t;}return Le.logD("[wl-"+t.length+"]["+e+"] got worker w-"+n.id),n}return Le.logAll("#getWorkerByIntanceId: no suitable worker"),null},ee=function(t,e,i){let n=m(this,Lt,"f");Le.logAll("removeInstanceInWorkerInner");for(let s of n)if(s===t){const n=s.Instances[e];if(n){if(null!=n[i]){delete n[i],Le.logD("[w-"+s.id+"] removeInstanceInWorkerInner "+i+" in "+t.id+" succeed!");break}Le.logD("[w-"+s.id+"] not found instance "+i);}}},Ut={value:null},Wt={value:new Array};let He=class{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|=m(this,ie,"m",ne).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}};ie=He,ne=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 Ve{constructor(t,e){var i,n,s,o;se.add(this),ae.set(this,void 0),this._outputType=k.IT_JPG,this._inputType=k.IT_ALL,this._jpegQuality=80,le.set(this,null!==(i=Oe.License)&&void 0!==i?i:""),he.set(this,[]),ce.set(this,null),de.set(this,0),ue.set(this,x(o=Ve,oe,+m(o,oe,"f",re)+1,"f",re)),pe.set(this,null),ge.set(this,JSON.parse(JSON.stringify(Oe.NavInfo))),fe.set(this,Oe.Mobile),ve.set(this,location.origin),ye.set(this,""),me.set(this,C.init),xe.set(this,!1),we.set(this,null!==(n=Oe.LicMode)&&void 0!==n?n:T.LONG_KEY),be.set(this,null!==(s=Oe.UUID)&&void 0!==s?s:""),Se.set(this,0),Ce.set(this,!1),Pe.set(this,!1),this._handleBooleanResult=function(t,e){return !0},x(this,ae,t,"f"),x(this,le,null!=e?e:Oe.License,"f");}_prepareModule(t){}get workerId(){return m(this,ce,"f")&&m(this,ce,"f").alive?m(this,ce,"f").id:0}get moduleInfo(){return m(this,ae,"f")}get id(){return m(this,ue,"f")}hasTask(){return m(this,he,"f").length>0}_canTerminateWork(){return !1}_makeSureWorkerMemoryNotExceed(){return !(m(this,ce,"f")&&m(this,ce,"f").alive&&this._canTerminateWork()&&m(this,ce,"f").exceedMaxMemory()&&(Le.logD(`[${this.id}] try to termiate worker [${m(this,ce,"f").id}]`),m(this,ce,"f").terminate(!0),x(this,ce,null,"f"),x(this,me,C.init,"f"),1))}_makeSureWorkerChanged(){return !!(m(this,ce,"f")&&m(this,ce,"f").alive&&this._canTerminateWork())&&(Le.logD(`[${this.id}] try to termiate worker [${m(this,ce,"f").id}]`),m(this,ce,"f").terminate(!0),x(this,ce,null,"f"),x(this,me,C.init,"f"),!0)}_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]=m(i=e.context,se,"m",ke).call(i,t.imageData[n],t.blobType,e.params.returnBlob,t.imageDataSize);else t.imageData=m(n=e.context,se,"m",ke).call(n,t.imageData,t.blobType,e.params.returnBlob,t.imageDataSize);return "object"==typeof t.pdfData&&(t.pdfData=m(s=e.context,se,"m",ke).call(s,t.pdfData,t.blobType,e.params.returnBlob,t.pdfDataSize)),t}_handleResult(t,e){var i,n;let s=m(n=e.context,se,"m",Re).call(n,t);if(void 0===s.code||!s.code&&"Successful."===s.message)s=e.handleResult(s,e),setTimeout((()=>{var t;m(t=e.context,se,"m",Ae).call(t);}),0),(0, e.resolve)(s);else {let t={code:s.code,message:s.code===A.wasmException?P.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=m(e,ce,"f");if(Le.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(m(e,se,"m",Re).call(e,i),t);})).catch((function(i){Le.logD(i),setTimeout((()=>{m(e,se,"m",Ae).call(e);}),0);let n=i;"object"==typeof i&&null!=i.message&&(n=i.message);let s={code:A.wasmJsWorkerRunFailed,message:n};m(e,xe,"f")?t.resolve(s):t.reject(s);}));}catch(i){setTimeout((()=>{m(e,se,"m",Ae).call(e);}),0),Le.logD(i);let n={code:A.wasmJsWorkerRunException,message:i.message,stack:i.stack};m(e,xe,"f")?t.resolve(n):t.reject(n);}}_cancelAllTasks(t,e){for(let i of m(this,he,"f"))if(void 0!==i){let n={code:t,message:e};m(this,xe,"f")?i.resolve(n):i.reject(n);}x(this,he,[],"f");}_createTask(t,e,i){let n={moduleName:m(this,ae,"f").instanceName,insId:m(this,ue,"f")},s={id:x(this,de,+m(this,de,"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=R.RT_AUTO,s.params.returnBlob=!0,s.params.logLevel=Le.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 m(this,me,"f")===C.destroyed?t.reject({code:A.wasmJsObjectNotInit,message:m(this,xe,"f")?"object has been disposed":"object not init"}):m(this,me,"f")===C.failed?t.reject({code:A.wasmJsObjectInitFailed,message:m(this,ye,"f")}):(e?m(this,he,"f").unshift(t):m(this,he,"f").push(t),m(this,se,"m",Ae).call(this)),t.promise}terminate(t){let e=this;m(e,Ce,"f")?x(e,xe,!0,"f"):(x(this,Pe,!0,"f"),m(e,se,"m",Ee).call(e).then((function(t){Le.logD("["+e.id+"] "+m(e,ae,"f").name+" destroy return: "),Le.logD(t);})).catch((function(t){Le.logD("["+e.id+"] "+m(e,ae,"f").name+" destroy failed"),Le.logD(t);})).finally((()=>{We.Instance&&We.Instance.removeInstanceInWorker(m(e,ae,"f"),m(e,ce,"f"),m(e,ue,"f"),null==t||t),x(e,ce,null,"f"),x(e,xe,!0,"f"),x(e,Pe,!1,"f");}))),x(e,me,"","f");}_readFile(t){return Ne.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 y(this,void 0,void 0,(function*(){x(this,le,t,"f"),x(this,we,null!=e?e:T.LONG_KEY,"f"),x(this,be,null!=i?i:"","f");let n=this,s=n._createTask("UpdateLicense");return s.params.input=[m(n,le,"f"),m(n,we,"f"),m(n,be,"f")],n._addTask(s),s.promise}))}}oe=Ve,ae=new WeakMap,le=new WeakMap,he=new WeakMap,ce=new WeakMap,de=new WeakMap,ue=new WeakMap,pe=new WeakMap,ge=new WeakMap,fe=new WeakMap,ve=new WeakMap,ye=new WeakMap,me=new WeakMap,xe=new WeakMap,we=new WeakMap,be=new WeakMap,Se=new WeakMap,Ce=new WeakMap,Pe=new WeakMap,se=new WeakSet,Te=function t(e){let i=null!=e?e:this;return m(i,pe,"f")&&clearTimeout(m(i,pe,"f")),m(i,xe,"f")?(Le.logD(`[${i.id}] has been termiated.(getWorker)`),i._cancelAllTasks(A.wasmJsObjectTerminated,`Instance [${i.id}] has been termiated.`),m(i,ce,"f")):m(i,ce,"f")&&m(i,ce,"f").alive?m(i,ce,"f"):void(We.Instance?We.Instance.getWorker(m(i,ae,"f"),m(i,ue,"f")).then((e=>{var n;if(x(i,ce,e.worker,"f"),m(i,ce,"f")&&m(i,ce,"f").alive)m(i,Se,"f")!=m(i,ce,"f").id&&(0!==m(i,Se,"f")&&i._workerChanged(m(i,ce,"f").id),x(i,Se,m(i,ce,"f").id,"f")),m(i,he,"f").length>0&&setTimeout((()=>{m(i,se,"m",Ae).call(i);}),0);else {let e=null===(n=We.Instance)||void 0===n?void 0:n.getModuleLoadedError(m(i,ae,"f").name);if(null==e?void 0:e.code)return i._cancelAllTasks(A.wasmJsNotLoaded,e.message),m(i,ce,"f");m(i,he,"f").length>0&&x(i,pe,setTimeout(m(i,se,"m",t),50,i),"f");}return m(i,ce,"f")})).catch((t=>m(i,ce,"f"))):i._cancelAllTasks(A.wasmJsNotLoaded,"wasm env not loaded or unloaded"))},Ae=function(){if(Le.logAll(`[${this.id}] dispatchQueuedTasks, status=${m(this,me,"f")}, workerId=${this.workerId}`),Le.logAll(m(this,he,"f")),m(this,me,"f")!=C.init)if(m(this,ce,"f")&&m(this,ce,"f").alive){if(m(this,he,"f").length>0&&(m(this,me,"f")===C.ready||"init"===m(this,he,"f")[0].func)){const t=m(this,he,"f").shift();this._execTask(t);}}else {if(m(this,ce,"f")&&!m(this,ce,"f").alive&&m(this,he,"f").length>0&&"init"!=m(this,he,"f")[0].func)return x(this,ce,null,"f"),void m(this,se,"m",De).call(this);m(this,he,"f").length>0&&m(this,ae,"f").script&&m(this,se,"m",Te).call(this,this);}else m(this,se,"m",De).call(this);},ke=function(t,e,i,n){return i?He.newBlobInChunks(t,e,n):void 0===n||n===t.byteLength?t:t.slice(0,n)},Re=function(t){try{return "string"==typeof t?JSON.parse(t):t}catch(e){return t}},De=function(){let t=this;t._prepareModule(m(this,ae,"f"));let e=this._createTask("init");e.params.key=m(this,le,"f"),e.params.uuid=m(this,be,"f"),e.params.licMode=m(this,we,"f"),e.params.val={nv:m(this,ge,"f"),mb:m(this,fe,"f"),dm:m(this,ve,"f")},e.handleResult=function(t,e){return x(e.context,me,C.ready,"f"),t},x(this,me,C.pending,"f"),this._addTask(e,!0),e.promise.then((function(e){Le.logD("["+t.id+"] "+m(t,ae,"f").name+" init return: "),Le.logD(e),x(t,Ce,!1,"f");})).catch((function(e){x(t,me,C.failed,"f"),x(t,ye,e.message,"f"),Le.logD(m(t,ae,"f").name+" init failed"),Le.logD(e),t._cancelAllTasks(A.wasmJsObjectInitFailed,e.message);}));},Ee=function(){if(m(this,me,"f")==C.pending||m(this,me,"f")==C.ready){let t=this._createTask("destroy",null,this._handleBooleanResult);return this._addTask(t),t.promise}return Promise.resolve(!0)},re={value:0};class ze extends Ve{constructor(t,e){super(t,e);}_prepareModule(t){We.Instance.addModules(t);}}let $e=class extends ze{constructor(t){super(Oe.ImageCoreModule,t),Me.add(this),Ie.set(this,0);}getImageFormat(t){return y(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 y(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 y(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 y(this,void 0,void 0,(function*(){return this._addTask(this._createTask("GetLicenseInfo"))}))}getAesResult(t){return y(this,void 0,void 0,(function*(){return t=null!=t?t:"",this._addTask(this._createTask("GetAesResult",[t]))}))}saveImage(t,e,i,n,s){return y(this,void 0,void 0,(function*(){return (s=null!=s&&s)?m(this,Me,"m",Be).call(this,t,void 0,void 0,void 0,1,void 0,void 0,e,i,n):m(this,Me,"m",Be).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 y(this,void 0,void 0,(function*(){e=null!=e?e:this._outputType,i=null!=i?i:this._jpegQuality,n=null!=n?n:R.RT_AUTO,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,r.params.returnBlob=n===R.RT_AUTO,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 y(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:R.RT_AUTO,n=null!=n&&n;let s=this._createTask("ReadTiffPage");return s.params.input=[t,e,n],s.params.returnType=i,s.params.returnBlob=i===R.RT_AUTO,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 y(this,void 0,void 0,(function*(){e=null!=e?e:this._inputType,i=null!=i?i:m(this,Ie,"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){t=null!=t?t:R.RT_AUTO;let e=this._createTask("GetTiffStream");return e.handleResult=this._handleImageData,e.params.returnType=t,e.params.returnBlob=t===R.RT_AUTO,this._addTask(e)}getMemoryUsed(){return this._addTask(this._createTask("getMemoryUsed",null,(function(t,e){return t.memoryUsed})))}getWasmVersion(){return this._addTask(this._createTask("GetWasmVersion",null,(function(t,e){return t.version})))}getMultiPartFile(t,e){return this._addTask(this._createTask("ds_get_file",[t,e],(function(t,e){return t})))}};Ie=new WeakMap,Me=new WeakSet,Be=function(t,e,i,n,s,o,r,a,l,h){return y(this,void 0,void 0,(function*(){let c=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:R.RT_AUTO;let d=c._createTask("SaveImage");const u=yield c._readFile(t);return d.params.input=[u,e,i,n,s,o,r,a,l],d.params.returnType=h,d.params.returnBlob=h===R.RT_AUTO,d.handleResult=c._handleImageData,c._addTask(d),d.promise}))};class je{constructor(){Ue.set(this,!1);}terminate(){x(this,Ue,!0,"f");}terminated(){return m(this,Ue,"f")}}Ue=new WeakMap;const Ge={code:A.wasmJsObjectTerminated,message:"Instance has been termiated."};var Xe,Ye,qe,Je,Ze,Qe,Ke,ti,ei,ii,ni,si,oi,ri,ai,li,hi,ci,di,ui,pi,gi,fi,vi,yi,mi,xi,wi,bi,Si,Ci,Pi,Ti,Ai,ki,Ri,Di,Ei,Mi,Ii,Bi,Ui,Li,Oi;class Ni extends ze{constructor(t){super(Oe.ImageReadereModule,t),Xe.add(this),Ye.set(this,0),qe.set(this,!1),Je.set(this,null),Ze.set(this,void 0),Qe.set(this,0),Ke.set(this,void 0),ti.set(this,void 0);}workerChanged(t){x(this,qe,!1,"f"),t&&(Le.logD("["+this.id+"] worker changed to "+t),x(this,Qe,t,"f"));}setExternalWorkerChanged(t,e){x(this,Ke,t,"f"),x(this,ti,e,"f");}_workerChanged(t){this.workerChanged(t),m(this,Ke,"f")&&m(this,Ke,"f").call(this,m(this,ti,"f"),this,t);}_canTerminateWork(){return !0}makeSureWorkerMemoryNotExceed(){this._makeSureWorkerMemoryNotExceed()||(x(this,qe,!1,"f"),m(this,Ke,"f")&&m(this,Ke,"f").call(this,m(this,ti,"f"),this));}getImageFormat(t){return y(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 y(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 y(this,void 0,void 0,(function*(){e=null!=e?e:this._outputType,i=null!=i?i:this._jpegQuality,n=null!=n?n:R.RT_AUTO,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=null!=n?n:R.RT_AUTO,r.params.returnBlob=n===R.RT_AUTO,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 y(this,void 0,void 0,(function*(){e=null!=e&&e;let i,n=this,s=n._createTask("LoadTiff");t!=m(this,Je,"f")&&(t instanceof Blob?x(n,Je,t,"f"):(i=yield n._readFile(t),x(n,Je,He.newBlobInChunks(i),"f"))),m(n,Je,"f").size>1024*Oe.FileReadModeSize*1024?s.params.input=[m(n,Je,"f"),e]:(i||(i=yield n._readFile(m(n,Je,"f"))),s.params.input=[i,e]),n._addTask(s);const o=yield s.promise;if(x(n,qe,!0,"f"),o.srcBuffer){let e=Object.prototype.toString.call(t);"[object ArrayBuffer]"!=e&&"[object Uint8ClampedArray]"!=e&&delete o.srcBuffer;}return x(n,Ze,{pageCount:o.pageCount},"f"),o}))}readTiffPage(t,e,i,n,s){return y(this,void 0,void 0,(function*(){yield m(this,Xe,"m",ei).call(this,t.fileSource),e=null!=e?e:0,i=null!=i?i:this._outputType,n=null!=n?n:R.RT_AUTO,s=null!=s&&s;let o=this._createTask("ReadTiffPage");return o.params.input=[e,i,s],o.params.returnType=null!=n?n:R.RT_AUTO,o.params.returnBlob=n===R.RT_AUTO,o.handleResult=this._handleImageData,this._addTask(o)}))}getTiffInfo(t,e){return y(this,void 0,void 0,(function*(){return yield m(this,Xe,"m",ei).call(this,t.fileSource),m(this,Ze,"f")}))}getTiffPageInfos(t,e){return y(this,void 0,void 0,(function*(){yield m(this,Xe,"m",ei).call(this,t.fileSource);let i=this._createTask("GetTiffPageInfos");return i.params.input=[e],this._addTask(i)}))}}Ye=new WeakMap,qe=new WeakMap,Je=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,Ke=new WeakMap,ti=new WeakMap,Xe=new WeakSet,ei=function(t){return y(this,void 0,void 0,(function*(){if(this.makeSureWorkerMemoryNotExceed(),m(this,qe,"f")){if(m(this,Je,"f")===t)return void Le.logD("["+this.id+"] already opened in "+this.workerId);yield m(this,Xe,"m",ii).call(this);}Le.logD("["+this.id+"] reopen in worker "+this.workerId),yield this.openTiff(t,!1);}))},ii=function(){if(x(this,Je,null,"f"),m(this,qe,"f"))return x(this,qe,!1,"f"),this._addTask(this._createTask("EndReadTiff",null,this._handleBooleanResult))};class Fi{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";}(Si||(Si={}));class _i extends Ve{constructor(t){super(Oe.PdfReaderModule,t),ni.add(this),ri.set(this,void 0),ai.set(this,void 0),hi.set(this,0),ci.set(this,200),di.set(this,3),ui.set(this,!1),pi.set(this,void 0),gi.set(this,null),fi.set(this,""),this._outputType=k.IT_ALL;}static get fonts(){return m(this,si,"f",oi)}static addPdfFont(t,e){return y(this,void 0,void 0,(function*(){return m(this,si,"m",li).call(this,t,e)}))}static getPdfFonts(){return this.fonts?Object.keys(this.fonts):[]}static removeFont(){x(this,si,Object.create(null),"f",oi);}workerChanged(t){x(this,ui,!1,"f"),t&&(Le.logD("["+this.id+"] worker changed to "+t),x(this,hi,t,"f"));}setExternalWorkerChanged(t,e){x(this,ri,t,"f"),x(this,ai,e,"f");}_workerChanged(t){this.workerChanged(t),m(this,ri,"f")&&m(this,ri,"f").call(this,m(this,ai,"f"),this,t);}_canTerminateWork(){return !0}makeSureWorkerMemoryNotExceed(){this._makeSureWorkerMemoryNotExceed()||(x(this,ui,!1,"f"),m(this,ri,"f")&&m(this,ri,"f").call(this,m(this,ai,"f"),this));}makeSureWorkerChanged(){this._makeSureWorkerChanged()&&(x(this,ui,!1,"f"),m(this,ri,"f")&&m(this,ri,"f").call(this,m(this,ai,"f"),this));}getPdfInfo(t){return y(this,void 0,void 0,(function*(){return yield m(this,ni,"m",vi).call(this,t),m(this,pi,"f")}))}readPage(t,e,i,n,s,o,r,a){return y(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 y(this,void 0,void 0,(function*(){yield m(this,ni,"m",vi).call(this,t),e=null!=e?e:0,n=null!=n?n:this._outputType,o=null!=o?o:R.RT_AUTO,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,l.params.returnBlob=o===R.RT_AUTO,l.handleResult=this._handleImageData,this._addTask(l)}))}renderPage(t,e,i,n,s){var o,r,a,l,h;return y(this,void 0,void 0,(function*(){yield m(this,ni,"m",vi).call(this,t),e=null!=e?e:0;const c=null!==(o=null==s?void 0:s.outputType)&&void 0!==o?o:k.IT_RGBA,d=null!==(r=null==s?void 0:s.rect)&&void 0!==r?r:null,u=null!==(a=null==s?void 0:s.returnType)&&void 0!==a?a:R.RT_AUTO,p=null!==(l=null==s?void 0:s.is1BitTo8Bit)&&void 0!==l&&l,g=null!==(h=null==s?void 0:s.scale)&&void 0!==h?h:1;let f=(null==s?void 0:s.renderOptions)?JSON.stringify(s.renderOptions):"{}",v=this._createTask("RenderPdfPageEx");return v.params.input=[e,f,d,i,n,g,c,p],v.params.returnType=u,v.params.returnBlob=u===R.RT_AUTO,v.handleResult=this._handleImageData,this._addTask(v)}))}readPageImageInfos(t,e,i,n){return y(this,void 0,void 0,(function*(){yield m(this,ni,"m",vi).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 y(this,void 0,void 0,(function*(){yield m(this,ni,"m",vi).call(this,t),e=null!=e?e:0;let i=this._createTask("GetPageAnnot",[e]);return this._addTask(i)}))}findText(t,e,i,n){return y(this,void 0,void 0,(function*(){yield m(this,ni,"m",vi).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 y(this,void 0,void 0,(function*(){return yield m(this,ni,"m",vi).call(this,t),this._addTask(this._createTask("GetPageCharInfos",[e]))}))}getCharInfosEx(t,e,i){return y(this,void 0,void 0,(function*(){return yield m(this,ni,"m",vi).call(this,t),this._addTask(this._createTask("GetPageCharInfosEx",[e,i]))}))}getPageInfos(t,e){return y(this,void 0,void 0,(function*(){return yield m(this,ni,"m",vi).call(this,t),this._addTask(this._createTask("GetPdfPageInfos",[e]))}))}getPdfPageType(t,e){return y(this,void 0,void 0,(function*(){return yield m(this,ni,"m",vi).call(this,t),this._addTask(this._createTask("GetPageContentType",[e]))}))}UnloadPage(t){return y(this,void 0,void 0,(function*(){return t=null!=t?t:0,this._addTask(this._createTask("UnloadPdfPage",[t]))}))}SetLoadedPageCapacity(t){return y(this,void 0,void 0,(function*(){return t=null!=t?t:0,this._addTask(this._createTask("SetLoadedPageCapacity",[t]))}))}setCustomFontsConf