D;D++)q[D]=M[V[D]];for(P=19;4=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:t("invalid length: "+e)}}var r,n,o=[];for(r=3;258>=r;r++)n=e(r),o[r]=n[2]<<24|n[1]<<16|n[0];return o}(),S=o?new Uint32Array(O):O;function I(e,n){function a(e,r){var n,o,a,s,u=e.N,f=[],c=0;switch(n=S[e.length],f[c++]=65535&n,f[c++]=n>>16&255,f[c++]=n>>24,i){case 1===u:o=[0,u-1,0];break;case 2===u:o=[1,u-2,0];break;case 3===u:o=[2,u-3,0];break;case 4===u:o=[3,u-4,0];break;case 6>=u:o=[4,u-5,1];break;case 8>=u:o=[5,u-7,1];break;case 12>=u:o=[6,u-9,2];break;case 16>=u:o=[7,u-13,2];break;case 24>=u:o=[8,u-17,3];break;case 32>=u:o=[9,u-25,3];break;case 48>=u:o=[10,u-33,4];break;case 64>=u:o=[11,u-49,4];break;case 96>=u:o=[12,u-65,5];break;case 128>=u:o=[13,u-97,5];break;case 192>=u:o=[14,u-129,6];break;case 256>=u:o=[15,u-193,6];break;case 384>=u:o=[16,u-257,7];break;case 512>=u:o=[17,u-385,7];break;case 768>=u:o=[18,u-513,8];break;case 1024>=u:o=[19,u-769,8];break;case 1536>=u:o=[20,u-1025,9];break;case 2048>=u:o=[21,u-1537,9];break;case 3072>=u:o=[22,u-2049,10];break;case 4096>=u:o=[23,u-3073,10];break;case 6144>=u:o=[24,u-4097,11];break;case 8192>=u:o=[25,u-6145,11];break;case 12288>=u:o=[26,u-8193,12];break;case 16384>=u:o=[27,u-12289,12];break;case 24576>=u:o=[28,u-16385,13];break;case 32768>=u:o=[29,u-24577,13];break;default:t("invalid distance")}for(n=o,f[c++]=n[0],f[c++]=n[1],f[c++]=n[2],a=0,s=f.length;a=f;)m[f++]=0;for(f=0;29>=f;)E[f++]=0}for(m[256]=1,s=0,u=n.length;s=u){for(y&&a(y,-1),f=0,c=u-s;fo&&e+of&&(i=n,f=o),258===o)break}return new k(f,e-i)}function U(t,e){var r,n,i,a,s,u=t.length,f=new v(572),c=new(o?Uint8Array:Array)(u);if(!o)for(a=0;a2*c[a-1]+h[a]&&(c[a]=2*c[a-1]+h[a]),p[a]=Array(c[a]),y[a]=Array(c[a]);for(i=0;it[i]?(p[a][s]=u,y[a][s]=e,f+=2):(p[a][s]=t[i],y[a][s]=i,++i);d[a]=0,1===h[a]&&n(a)}return l}(n,n.length,e),a=0,s=r.length;a>>=1;return a}function j(t,e){this.input=t,this.b=this.c=0,this.g={},e&&(e.flags&&(this.g=e.flags),"string"==typeof e.filename&&(this.filename=e.filename),"string"==typeof e.comment&&(this.w=e.comment),e.deflateOptions&&(this.l=e.deflateOptions)),this.l||(this.l={})}j.prototype.h=function(){var t,e,n,i,a,s,u,f,c=new(o?Uint8Array:Array)(32768),h=0,l=this.input,y=this.c,d=this.filename,g=this.w;if(c[h++]=31,c[h++]=139,c[h++]=8,t=0,this.g.fname&&(t|=T),this.g.fcomment&&(t|=R),this.g.fhcrc&&(t|=P),c[h++]=t,e=(Date.now?Date.now():+new Date)/1e3|0,c[h++]=255&e,c[h++]=e>>>8&255,c[h++]=e>>>16&255,c[h++]=e>>>24&255,c[h++]=0,c[h++]=B,this.g.fname!==r){for(u=0,f=d.length;u>>8&255),c[h++]=255&s;c[h++]=0}if(this.g.comment){for(u=0,f=g.length;u>>8&255),c[h++]=255&s;c[h++]=0}return this.g.fhcrc&&(n=65535&p(c,0,h),c[h++]=255&n,c[h++]=n>>>8&255),this.l.outputBuffer=c,this.l.outputIndex=h,c=(a=new w(l,this.l)).h(),h=a.b,o&&(h+8>c.buffer.byteLength?(this.a=new Uint8Array(h+8),this.a.set(new Uint8Array(c.buffer)),c=this.a):c=new Uint8Array(c.buffer)),i=p(l,r,r),c[h++]=255&i,c[h++]=i>>>8&255,c[h++]=i>>>16&255,c[h++]=i>>>24&255,f=l.length,c[h++]=255&f,c[h++]=f>>>8&255,c[h++]=f>>>16&255,c[h++]=f>>>24&255,this.c=y,o&&h>>=1){case 0:var n=this.input,a=this.c,s=this.a,u=this.b,f=n.length,c=r,h=s.length,l=r;switch(this.e=this.j=0,a+1>=f&&t(Error("invalid uncompressed block header: LEN")),c=n[a++]|n[a++]<<8,a+1>=f&&t(Error("invalid uncompressed block header: NLEN")),c===~(n[a++]|n[a++]<<8)&&t(Error("invalid uncompressed block header: length verify")),a+c>n.length&&t(Error("input buffer is broken")),this.q){case C:for(;u+c>s.length;){if(c-=l=h-u,o)s.set(n.subarray(a,a+l),u),u+=l,a+=l;else for(;l--;)s[u++]=n[a++];this.b=u,s=this.f(),u=this.b}break;case M:for(;u+c>s.length;)s=this.f({B:2});break;default:t(Error("invalid inflate mode"))}if(o)s.set(n.subarray(a,a+c),u),u+=c,a+=c;else for(;c--;)s[u++]=n[a++];this.c=a,this.b=u,this.a=s;break;case 1:this.r(tt,rt);break;case 2:var p,y,d,g,v=nt(this,5)+257,w=nt(this,5)+1,m=nt(this,4)+4,E=new(o?Uint8Array:Array)(D.length),x=r,A=r,k=r,O=r,S=r;for(S=0;S=G?8:255>=G?9:279>=G?7:8;var X,Z,tt=b(Q),et=new(o?Uint8Array:Array)(30);for(X=0,Z=et.length;X=u&&t(Error("input buffer is broken")),i|=a[s++]<>>r,e.e=o-r,e.c=s,n}function it(e,r){for(var n,i,o=e.j,a=e.e,s=e.input,u=e.c,f=s.length,c=r[0],h=r[1];a=f);)o|=s[u++]<>>16)>a&&t(Error("invalid code length: "+i)),e.j=o>>i,e.e=a-i,e.c=u,65535&n}function ot(t){this.input=t,this.c=0,this.G=[],this.R=!1}function at(t){if("string"==typeof t){var e,r,n=t.split("");for(e=0,r=n.length;e>>0;t=n}for(var i,o=1,a=0,s=t.length,u=0;0>>0}function st(e,r){var n,i;this.input=e,this.c=0,!r&&(r={})||(r.index&&(this.c=r.index),r.verify&&(this.V=r.verify)),n=e[this.c++],i=e[this.c++],(15&n)===ut?this.method=ut:t(Error("unsupported compression method")),0!=((n<<8)+i)%31&&t(Error("invalid fcheck flag:"+((n<<8)+i)%31)),32&i&&t(Error("fdict flag is not supported")),this.J=new N(e,{index:this.c,bufferSize:r.bufferSize,bufferType:r.bufferType,resize:r.resize})}N.prototype.r=function(t,e){var r=this.a,n=this.b;this.A=t;for(var i,o,a,s,u=r.length-258;256!==(i=it(this,t));)if(256>i)n>=u&&(this.b=n,r=this.f(),n=this.b),r[n++]=i;else for(s=Y[o=i-257],0=u&&(this.b=n,r=this.f(),n=this.b);s--;)r[n]=r[n++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},N.prototype.Q=function(t,e){var r=this.a,n=this.b;this.A=t;for(var i,o,a,s,u=r.length;256!==(i=it(this,t));)if(256>i)n>=u&&(u=(r=this.f()).length),r[n++]=i;else for(s=Y[o=i-257],0u&&(u=(r=this.f()).length);s--;)r[n]=r[n++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},N.prototype.f=function(){var t,e,r=new(o?Uint8Array:Array)(this.b-32768),n=this.b-32768,i=this.a;if(o)r.set(i.subarray(32768,r.length));else for(t=0,e=r.length;tt;++t)i[t]=i[n+t];return this.b=32768,i},N.prototype.S=function(t){var e,r,n,i=this.input.length/this.c+1|0,a=this.input,s=this.a;return t&&("number"==typeof t.B&&(i=t.B),"number"==typeof t.M&&(i+=t.M)),r=2>i?(n=(a.length-this.c)/this.A[2]/2*258|0)e&&(this.a.length=e),t=this.a),this.buffer=t},ot.prototype.i=function(){for(var e=this.input.length;this.c>>0,p(n,r,r)!==d&&t(Error("invalid CRC-32 checksum: 0x"+p(n,r,r).toString(16)+" / 0x"+d.toString(16))),s.Z=u=(v[b++]|v[b++]<<8|v[b++]<<16|v[b++]<<24)>>>0,(4294967295&n.length)!==u&&t(Error("invalid input size: "+(4294967295&n.length)+" / "+u)),this.G.push(s),this.c=b}this.R=i;var w,m,E,x=this.G,A=0,k=0;for(w=0,m=x.length;w>>0!==at(e)&&t(Error("invalid adler-32 checksum")),e};var ut=8;function ft(t,e){this.input=t,this.a=new(o?Uint8Array:Array)(32768),this.k=ct.t;var r,n={};for(r in!e&&(e={})||"number"!=typeof e.compressionType||(this.k=e.compressionType),e)n[r]=e[r];n.outputBuffer=this.a,this.I=new w(this.input,n)}var ct=x;function ht(t,e){var r;return r=new ft(t).h(),e||(e={}),e.H?r:dt(r)}function lt(t,e){var r;return t.subarray=t.slice,r=new st(t).i(),e||(e={}),e.noBuffer?r:dt(r)}function pt(t,e){var r;return t.subarray=t.slice,r=new j(t).h(),e||(e={}),e.H?r:dt(r)}function yt(t,e){var r;return t.subarray=t.slice,r=new ot(t).i(),e||(e={}),e.H?r:dt(r)}function dt(t){var e,r,i=new n(t.length);for(e=0,r=t.length;e>24&255,u[f++]=s>>16&255,u[f++]=s>>8&255,u[f++]=255&s,u},e.deflate=function(t,e,r){process.nextTick((function(){var n,i;try{i=ht(t,r)}catch(t){n=t}e(n,i)}))},e.deflateSync=ht,e.inflate=function(t,e,r){process.nextTick((function(){var n,i;try{i=lt(t,r)}catch(t){n=t}e(n,i)}))},e.inflateSync=lt,e.gzip=function(t,e,r){process.nextTick((function(){var n,i;try{i=pt(t,r)}catch(t){n=t}e(n,i)}))},e.gzipSync=pt,e.gunzip=function(t,e,r){process.nextTick((function(){var n,i;try{i=yt(t,r)}catch(t){n=t}e(n,i)}))},e.gunzipSync=yt}).call(this)},188:t=>{t.exports={OSD_ONLY:"0",AUTO_OSD:"1",AUTO_ONLY:"2",AUTO:"3",SINGLE_COLUMN:"4",SINGLE_BLOCK_VERT_TEXT:"5",SINGLE_BLOCK:"6",SINGLE_LINE:"7",SINGLE_WORD:"8",CIRCLE_WORD:"9",SINGLE_CHAR:"10",SPARSE_TEXT:"11",SPARSE_TEXT_OSD:"12",RAW_LINE:"13"}},753:t=>{t.exports={COLOR:0,GREY:1,BINARY:2}},827:t=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}t.exports=function(t){var r={};return"undefined"!=typeof WorkerGlobalScope?r.type="webworker":"object"===("undefined"==typeof document?"undefined":e(document))?r.type="browser":"object"===("undefined"==typeof process?"undefined":e(process))&&(r.type="node"),void 0===t?r:r[t]}},86:function(t,e){var r=this,n=!1;e.logging=n,e.setLogging=function(t){n=t},e.log=function(){for(var t=arguments.length,e=new Array(t),i=0;i{var n=r(613),i=n.set,o=n.get,a=n.del;t.exports={readCache:o,writeCache:i,deleteCache:a,checkCache:function(t){return o(t).then((function(t){return void 0!==t}))}}},667:(t,e,r)=>{function n(){"use strict";n=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",f=a.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var i=e&&e.prototype instanceof y?e:y,a=Object.create(i.prototype),s=new I(n||[]);return o(a,"_invoke",{value:A(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var p={};function y(){}function d(){}function g(){}var v={};c(v,s,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(L([])));w&&w!==e&&r.call(w,s)&&(v=w);var m=g.prototype=y.prototype=Object.create(v);function E(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,a,s,u){var f=l(t[o],t,a);if("throw"!==f.type){var c=f.arg,h=c.value;return h&&"object"==i(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):e.resolve(h).then((function(t){c.value=t,s(c)}),(function(t){return n("throw",t,s,u)}))}u(f.arg)}var a;o(this,"_invoke",{value:function(t,r){function i(){return new e((function(e,i){n(t,r,e,i)}))}return a=a?a.then(i,i):i()}})}function A(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=k(a,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function k(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var i=l(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,p;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function L(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;S(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}var a=r(633).simd,s=r(330).El.QE;t.exports=function(){var t,e=(t=n().mark((function t(e,o,u){var f,c,h,l;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==r.g.TesseractCore){t.next=20;break}if(f="loading tesseract core",u.progress({status:f,progress:0}),"js"!==(c=o||"https://cdn.jsdelivr.net/npm/tesseract.js-core@v".concat(s.substring(1))).slice(-2)){t.next=8;break}h=c,t.next=12;break;case 8:return t.next=10,a();case 10:l=t.sent,h="".concat(c.replace(/\/$/,""),l?e?"/tesseract-core-simd-lstm.wasm.js":"/tesseract-core-simd.wasm.js":e?"/tesseract-core-lstm.wasm.js":"/tesseract-core.wasm.js");case 12:if(r.g.importScripts(h),void 0!==r.g.TesseractCore||void 0===r.g.TesseractCoreWASM||"object"!==("undefined"==typeof WebAssembly?"undefined":i(WebAssembly))){t.next=17;break}r.g.TesseractCore=r.g.TesseractCoreWASM,t.next=19;break;case 17:if(void 0!==r.g.TesseractCore){t.next=19;break}throw Error("Failed to load TesseractCore");case 19:u.progress({status:f,progress:1});case 20:return t.abrupt("return",r.g.TesseractCore);case 21:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function s(t){o(a,n,i,s,u,"next",t)}function u(t){o(a,n,i,s,u,"throw",t)}s(void 0)}))});return function(t,r,n){return e.apply(this,arguments)}}()},891:(t,e,r)=>{t.exports=r(133).gunzipSync},993:t=>{t.exports={text:!0,blocks:!1,layoutBlocks:!1,hocr:!1,tsv:!1,box:!1,unlv:!1,osd:!1,pdf:!1,imageColor:!1,imageGrey:!1,imageBinary:!1,debug:!1}},67:function(t,e,r){var n=this;function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function a(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;S(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function c(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function h(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){c(o,n,i,a,s,"next",t)}function s(t){c(o,n,i,a,s,"throw",t)}a(void 0)}))}}r(30);var l,p,y,d,g=r(443),v=r(107),b=r(827)("type"),w=r(576),m=r(993),E=r(86),x=E.log,A=E.setLogging,k=r(188),O=null,S={},I={},L=!1,U=function(){var t=h(f().mark((function t(e,r){var n,i,o,a,s,u,c,h;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.workerId,i=e.jobId,o=e.payload.options,a=o.lstmOnly,s=o.corePath,u=o.logging,A(u),c="initializing tesseract",l){t.next=11;break}return t.next=6,S.getCore(a,s,r);case 6:h=t.sent,r.progress({workerId:n,status:c,progress:0}),h({TesseractProgress:function(t){p.progress({workerId:n,jobId:i,status:"recognizing text",progress:Math.max(0,(t-30)/70)})}}).then((function(t){l=t,r.progress({workerId:n,status:c,progress:1}),r.resolve({loaded:!0})})),t.next=12;break;case 11:r.resolve({loaded:!0});case 12:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),_=function(){var t=h(f().mark((function t(e,r){var n,i,o,a,s;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=e.workerId,o=e.payload,a=o.method,s=o.args,x("[".concat(i,"]: FS.").concat(a)),r.resolve((n=l.FS)[a].apply(n,function(t){if(Array.isArray(t))return u(t)}(f=s)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(f)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}(f)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()));case 3:case"end":return t.stop()}var f}),t)})));return function(e,r){return t.apply(this,arguments)}}(),j=function(){var t=h(f().mark((function t(e,r){var n,i,o,a,s,u,c,p,v,w,m,E,A,k,O;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.workerId,i=e.payload,o=i.langs,a=i.options,s=a.langPath,u=a.dataPath,c=a.cachePath,p=a.cacheMethod,v=a.gzip,w=void 0===v||v,m=a.lstmOnly,y=o,d={langPath:s,dataPath:u,cachePath:c,cacheMethod:p,gzip:w,lstmOnly:m},E="loading language traineddata",A="string"==typeof o?o.split("+"):o,k=0,O=function(){var t=h(f().mark((function t(e){var i,o,a,h,y,d,v,O,I;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i="string"==typeof e?e:e.code,o=["refresh","none"].includes(p)?function(){return Promise.resolve()}:S.readCache,a=null,h=!1,t.prev=4,t.next=7,o("".concat(c||".","/").concat(i,".traineddata"));case 7:if(void 0===(y=t.sent)){t.next=14;break}x("[".concat(n,"]: Load ").concat(i,".traineddata from cache")),a=y,L=!0,t.next=15;break;case 14:throw Error("Not found in cache");case 15:t.next=45;break;case 17:if(t.prev=17,t.t0=t.catch(4),h=!0,x("[".concat(n,"]: Load ").concat(i,".traineddata from ").concat(s)),"string"!=typeof e){t.next=44;break}if(d=null,v=s||"https://cdn.jsdelivr.net/npm/@tesseract.js-data/".concat(i,m?"/4.0.0_best_int":"/4.0.0"),("node"!==b||g(v)||v.startsWith("moz-extension://")||v.startsWith("chrome-extension://")||v.startsWith("file://"))&&(d=v.replace(/\/$/,"")),null===d){t.next=39;break}return O="".concat(d,"/").concat(i,".traineddata").concat(w?".gz":""),t.next=29,("webworker"===b?fetch:S.fetch)(O);case 29:if((I=t.sent).ok){t.next=32;break}throw Error("Network error while fetching ".concat(O,". Response code: ").concat(I.status));case 32:return t.t1=Uint8Array,t.next=35,I.arrayBuffer();case 35:t.t2=t.sent,a=new t.t1(t.t2),t.next=42;break;case 39:return t.next=41,S.readCache("".concat(v,"/").concat(i,".traineddata").concat(w?".gz":""));case 41:a=t.sent;case 42:t.next=45;break;case 44:a=e.data;case 45:if(k+=.5/A.length,r&&r.progress({workerId:n,status:E,progress:k}),(31===a[0]&&139===a[1]||31===a[1]&&139===a[0])&&(a=S.gunzip(a)),l){if(u)try{l.FS.mkdir(u)}catch(t){r&&r.reject(t.toString())}l.FS.writeFile("".concat(u||".","/").concat(i,".traineddata"),a)}if(!h||!["write","refresh",void 0].includes(p)){t.next=60;break}return t.prev=51,t.next=54,S.writeCache("".concat(c||".","/").concat(i,".traineddata"),a);case 54:t.next=60;break;case 56:t.prev=56,t.t3=t.catch(51),x("[".concat(n,"]: Failed to write ").concat(i,".traineddata to cache due to error:")),x(t.t3.toString());case 60:k+=.5/A.length,100===Math.round(100*k)&&(k=1),r&&r.progress({workerId:n,status:E,progress:k});case 63:case"end":return t.stop()}}),t,null,[[4,17],[51,56]])})));return function(e){return t.apply(this,arguments)}}(),r&&r.progress({workerId:n,status:E,progress:0}),t.prev=8,t.next=11,Promise.all(A.map(O));case 11:r&&r.resolve(o),t.next=17;break;case 14:t.prev=14,t.t0=t.catch(8),r&&r.reject(t.t0.toString());case 17:case"end":return t.stop()}}),t,null,[[8,14]])})));return function(e,r){return t.apply(this,arguments)}}(),B=function(){var t=h(f().mark((function t(e,r){var n,i,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.payload.params,i=["ambigs_debug_level","user_words_suffix","user_patterns_suffix","user_patterns_suffix","load_system_dawg","load_freq_dawg","load_unambig_dawg","load_punc_dawg","load_number_dawg","load_bigram_dawg","tessedit_ocr_engine_mode","tessedit_init_config_only","language_model_ngram_on","language_model_use_sigmoidal_certainty"],(o=Object.keys(n).filter((function(t){return i.includes(t)})).join(", ")).length>0&&console.log("Attempted to set parameters that can only be set during initialization: ".concat(o)),Object.keys(n).filter((function(t){return!t.startsWith("tessjs_")})).forEach((function(t){O.SetVariable(t,n[t])})),I=a(a({},I),n),void 0!==r&&r.resolve(I);case 7:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),P=function(){var t=h(f().mark((function t(e,r){var n,o,a,s,u,c,h,p,g,v,b,w,m,E;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.workerId,o=e.payload,a=o.langs,s=o.oem,u=o.config,c="string"==typeof a?a:a.map((function(t){return"string"==typeof t?t:t.data})).join("+"),h="initializing api",t.prev=3,r.progress({workerId:n,status:h,progress:0}),null!==O&&O.End(),u&&"object"===i(u)&&Object.keys(u).length>0?g=JSON.stringify(u).replace(/,/g,"\n").replace(/:/g," ").replace(/["'{}]/g,""):u&&"string"==typeof u&&(g=u),"string"==typeof g&&(p="/config",l.FS.writeFile(p,g)),O=new l.TessBaseAPI,-1!==(v=O.Init(null,c,s,p))){t.next=30;break}if(!["write","refresh",void 0].includes(d.cacheMethod)){t.next=30;break}return b=c.split("+"),w=b.map((function(t){return S.deleteCache("".concat(d.cachePath||".","/").concat(t,".traineddata"))})),t.next=16,Promise.all(w);case 16:if(m=l.FS.readFile("/debugDev.txt",{encoding:"utf8",flags:"a+"}),!L||!/components are not present/.test(m)){t.next=30;break}return x("Data from cache missing requested OEM model. Attempting to refresh cache with new language data."),t.next=21,j({workerId:n,payload:{langs:y,options:d}});case 21:if(-1!==(v=O.Init(null,c,s,p))){t.next=29;break}return x("Language data refresh failed."),E=b.map((function(t){return S.deleteCache("".concat(d.cachePath||".","/").concat(t,".traineddata"))})),t.next=27,Promise.all(E);case 27:t.next=30;break;case 29:x("Language data refresh successful.");case 30:-1===v&&r.reject("initialization failed"),r.progress({workerId:n,status:h,progress:1}),r.resolve(),t.next=38;break;case 35:t.prev=35,t.t0=t.catch(3),r.reject(t.t0.toString());case 38:case"end":return t.stop()}}),t,null,[[3,35]])})));return function(e,r){return t.apply(this,arguments)}}(),T=function(t){for(var e=JSON.parse(JSON.stringify(m)),r=["imageColor","imageGrey","imageBinary","layoutBlocks","debug"],n=0,i=0,o=Object.keys(t);i0)for(c=0,h=Object.keys(a);c