@picovoice/web-utils
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -1,1 +0,1 @@ | ||
function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e={exports:{}},r={exports:{}};!function(t){function e(r){return t.exports=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},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(r);var n=r.exports;!function(t){var e=n.default;function r(){t.exports=r=function(){return o},t.exports.__esModule=!0,t.exports.default=t.exports;var n,o={},i=Object.prototype,a=i.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",f=c.asyncIterator||"@@asyncIterator",l=c.toStringTag||"@@toStringTag";function p(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{p({},"")}catch(n){p=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,i=Object.create(o.prototype),a=new M(n||[]);return s(i,"_invoke",{value:A(t,r,a)}),i}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}o.wrap=h;var v="suspendedStart",_="suspendedYield",y="executing",m="completed",E={};function w(){}function g(){}function x(){}var b={};p(b,u,(function(){return this}));var k=Object.getPrototypeOf,P=k&&k(k(R([])));P&&P!==i&&a.call(P,u)&&(b=P);var S=x.prototype=w.prototype=Object.create(b);function O(t){["next","throw","return"].forEach((function(e){p(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,r){function n(o,i,s,c){var u=d(t[o],t,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==e(l)&&a.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):r.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;s(this,"_invoke",{value:function(t,e){function i(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(i,i):i()}})}function A(t,e,r){var o=v;return function(i,a){if(o===y)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:n,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var c=I(s,r);if(c){if(c===E)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===v)throw o=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=y;var u=d(t,e,r);if("normal"===u.type){if(o=r.done?m:_,u.arg===E)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=m,r.method="throw",r.arg=u.arg)}}}function I(t,e){var r=e.method,o=t.iterator[r];if(o===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,I(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),E;var i=d(o,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,E;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,E):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,E)}function N(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 L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function R(t){if(t||""===t){var r=t[u];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function e(){for(;++o<t.length;)if(a.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=n,e.done=!0,e};return i.next=i}}throw new TypeError(e(t)+" is not iterable")}return g.prototype=x,s(S,"constructor",{value:x,configurable:!0}),s(x,"constructor",{value:g,configurable:!0}),g.displayName=p(x,l,"GeneratorFunction"),o.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},o.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,p(t,l,"GeneratorFunction")),t.prototype=Object.create(S),t},o.awrap=function(t){return{__await:t}},O(T.prototype),p(T.prototype,f,(function(){return this})),o.AsyncIterator=T,o.async=function(t,e,r,n,i){void 0===i&&(i=Promise);var a=new T(h(t,e,r,n),i);return o.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(S),p(S,l,"Generator"),p(S,u,(function(){return this})),p(S,"toString",(function(){return"[object Generator]"})),o.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},o.values=R,M.prototype={constructor:M,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,o){return s.type="throw",s.arg=t,e.next=r,o&&(e.method="next",e.arg=n),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=a.call(i,"catchLoc"),u=a.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,E):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),E},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),E}},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 o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:R(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),E}},o}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(e);var o=(0,e.exports)(),i=o;try{regeneratorRuntime=o}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=o:Function("r","regeneratorRuntime = r")(o)}var a=t(i);function s(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))}const c=new WeakMap;function u(t,e){return new Proxy(t,{get:(t,r)=>e(t[r])})}class f{constructor(){this.value=void 0,this.exports=null}getState(){return this.exports.asyncify_get_state()}assertNoneState(){let t=this.getState();if(0!==t)throw new Error(`Invalid async state ${t}, expected 0.`)}wrapImportFn(t){return(...e)=>{if(2===this.getState())return this.exports.asyncify_stop_rewind(),this.value;this.assertNoneState();let r=t(...e);if(!(n=r)||"object"!=typeof n&&"function"!=typeof n||"function"!=typeof n.then)return r;var n;this.exports.asyncify_start_unwind(16),this.value=r}}wrapModuleImports(t){return u(t,(t=>"function"==typeof t?this.wrapImportFn(t):t))}wrapImports(t){if(void 0!==t)return u(t,((t=Object.create(null))=>this.wrapModuleImports(t)))}wrapExportFn(t){let e=c.get(t);return void 0!==e||(e=async(...e)=>{this.assertNoneState();let r=t(...e);for(;1===this.getState();)this.exports.asyncify_stop_unwind(),this.value=await this.value,this.assertNoneState(),this.exports.asyncify_start_rewind(16),r=t();return this.assertNoneState(),r},c.set(t,e)),e}wrapExports(t){let e=Object.create(null);for(let r in t){let n=t[r];"function"!=typeof n||r.startsWith("asyncify_")||(n=this.wrapExportFn(n)),Object.defineProperty(e,r,{enumerable:!0,value:n})}return c.set(t,e),e}init(t,e){const{exports:r}=t,n=r.memory||e.env&&e.env.memory;new Int32Array(n.buffer,16).set([24,1024]),this.exports=this.wrapExports(r),Object.setPrototypeOf(t,l.prototype)}}class l extends WebAssembly.Instance{constructor(t,e){let r=new f;super(t,r.wrapImports(e)),r.init(this,e)}get exports(){return c.get(super.exports)}}async function p(t,e){let r=new f,n=await WebAssembly.instantiate(t,r.wrapImports(e));return r.init(n instanceof WebAssembly.Instance?n:n.instance,e),n}async function h(t,e){let r=new f,n=await WebAssembly.instantiateStreaming(t,r.wrapImports(e));return r.init(n.instance,e),n}function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function v(t){return v="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},v(t)}function _(t){var e=function(t,e){if("object"!==v(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===v(e)?e:String(e)}function y(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_(n.key),n)}}function m(t,e,r){return e&&y(t.prototype,e),r&&y(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function E(t,e){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},E(t,e)}function w(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&E(t,e)}function g(t,e){if(e&&("object"===v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(t)}Object.defineProperty(l.prototype,"exports",{enumerable:!0});var b=function(){function t(){d(this,t),this._path=""}return m(t,[{key:"meta",get:function(){if(void 0!==this._meta)return Object.assign({version:0},this._meta)}}],[{key:"getPtr",value:function(e){if(t._filePtrs.has(e))return t._filePtrs.get(e);throw new Error("File instance not found.")}},{key:"setPtr",value:function(e,r){t._filePtrs.set(e,r)}},{key:"removePtr",value:function(e){t._filePtrs.delete(e)}}]),t}();function k(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x(t);if(e){var o=x(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return g(this,r)}}b._filePtrs=new Map;var P="pv_db",S="pv_file";function O(){return new Promise((function(t,e){var r=self.indexedDB.open(P,3);r.onerror=function(){e(r.error)},r.onsuccess=function(){t(r.result)},r.onupgradeneeded=function(){r.result.objectStoreNames.contains(S)||r.result.createObjectStore(S)}}))}var T=function(t){w(r,b);var e=k(r);function r(t,n,o,i){var a;return d(this,r),(a=e.call(this))._pageSize=65536,a._pagePtr=0,a._pageOffset=0,a._path=t,a._meta=n,a._db=o,a._mode=i,a}return m(r,[{key:"close",value:function(){return s(this,void 0,void 0,a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._db.close();case 1:case"end":return t.stop()}}),t,this)})))}},{key:"read",value:function(t,e){return s(this,void 0,void 0,a.mark((function n(){var o=this;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,i){if(o.exists()){if(o._isEOF){var a=new Error("EOF");return a.name="EndOfFile",void i(a)}var s=0,c=Math.min(t*e,o._meta.size),u=c-c%t,f=new Uint8Array(u),l=IDBKeyRange.bound("".concat(o._path,"-").concat(r.createPage(o._pagePtr)),"".concat(o._path,"-").concat(r.createPage(o._meta.numPages))),p=o._store,h=p.openCursor(l);h.onsuccess=function(){var t=h.result;if(t&&!o._isEOF){var e=Math.min(u-s,t.value.length-o._pageOffset);f.set(t.value.slice(o._pageOffset,o._pageOffset+e),s),s+=e,o._pageOffset+=e,o._pageOffset===o._pageSize&&(o._pagePtr+=1,o._pageOffset=0),s<u&&t.continue()}},p.transaction.onerror=function(){i(p.transaction.error)},p.transaction.oncomplete=function(){n(f.slice(0,s))}}else i(new Error("'".concat(o._path,"' doesn't exist.")))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"write",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return s(this,void 0,void 0,a.mark((function n(){var o=this;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,i){return s(o,void 0,void 0,a.mark((function o(){var s,c,u,f,l,p,h,d,v,_=this;return a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if("readonly"!==this._mode){o.next=3;break}return i(new Error("Instance is readonly mode only.")),o.abrupt("return");case 3:if(!("number"!=typeof e&&e<=0)){o.next=6;break}return i(new Error("Version should be a positive number")),o.abrupt("return");case 6:return s=this._store,c=function(){return new Promise((function(t){var e=s.get("".concat(_._path,"-").concat(r.createPage(_._pagePtr)));e.onsuccess=function(){void 0!==e.result?t(e.result.slice(0,_._pageOffset)):t(new Uint8Array(0))}}))},o.next=10,c();case 10:for(u=o.sent,(f=new Uint8Array(u.length+t.length)).set(u),f.set(t,u.length),l=this._pagePtr*this._pageSize+f.length,p={size:l,numPages:Math.ceil(l/this._pageSize),version:e},s.put(p,this._path),h=Math.ceil(f.length/this._pageSize),d=0;d<h;d++)s.put(f.slice(d*this._pageSize,(d+1)*this._pageSize),"".concat(this._path,"-").concat(r.createPage(this._pagePtr+d)));this.exists()&&p.numPages<this._meta.numPages&&(v=IDBKeyRange.bound("".concat(this._path,"-").concat(r.createPage(p.numPages)),"".concat(this._path,"-").concat(r.createPage(this._meta.numPages)),!0),s.delete(v)),s.transaction.onerror=function(){i(s.transaction.error)},s.transaction.oncomplete=function(){_._meta=p,_.seek(0,2),n()};case 22:case"end":return o.stop()}}),o,this)})))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._meta.size);else if(1===e){var o=this._pageSize*this._pagePtr+this._pageOffset;n=Math.min(o+t,this._meta.size)}else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._meta.size+t,this._meta.size)}this._pageOffset=n%this._pageSize,this._pagePtr=Math.floor(n/this._pageSize)}},{key:"tell",value:function(){return this.exists()?this._pagePtr*this._pageSize+this._pageOffset:-1}},{key:"remove",value:function(){return s(this,void 0,void 0,a.mark((function t(){var e=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){return s(e,void 0,void 0,a.mark((function e(){var o,i,s,c,u=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.exists()){e.next=3;break}return n(new Error("ENOENT")),e.abrupt("return");case 3:o=this._meta.numPages,i=IDBKeyRange.bound(this._path,"".concat(this._path,"-").concat(r.createPage(o))),s=this._store,(c=s.delete(i)).onerror=function(){n(c.error)},c.onsuccess=function(){u._meta=void 0,u._pageOffset=0,u._pagePtr=0,t()};case 9:case"end":return e.stop()}}),e,this)})))})));case 1:case"end":return t.stop()}}),t)})))}},{key:"exists",value:function(){return void 0!==this._meta}},{key:"_isEOF",get:function(){return this._pagePtr>=this._meta.numPages-1&&this._pageOffset>=this._meta.size%this._pageSize}},{key:"_store",get:function(){return this._db.transaction(S,this._mode).objectStore(S)}}],[{key:"open",value:function(t,e){var n=this;if(!self.indexedDB){var o=new Error("IndexedDB is not supported");throw o.name="IndexedDBNotSupported",o}return new Promise((function(o,i){return s(n,void 0,void 0,a.mark((function n(){var s,c,u;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,O();case 3:s=n.sent,(c=s.transaction(S,"readwrite").objectStore(S).get(t)).onerror=function(){i(c.error)},c.onsuccess=function(){var n=c.result,a=e.includes("r")?"readonly":"readwrite";if(void 0===n&&"readonly"===a){var u=new Error("'".concat(t,"' doesn't exist."));return u.name="FileNotExists",void i(u)}var f=new r(t,n,s,a);e.includes("a")&&f.seek(0,2),o(f)},n.next=12;break;case 9:n.prev=9,n.t0=n.catch(0),"InvalidStateError"===n.t0.name?((u=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",i(u)):i(n.t0);case 12:case"end":return n.stop()}}),n,null,[[0,9]])})))}))}},{key:"createPage",value:function(t){return("000"+t).slice(-4)}}]),r}();function A(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x(t);if(e){var o=x(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return g(this,r)}}var I=function(t){w(r,b);var e=A(r);function r(t,n,o,i){var a;return d(this,r),(a=e.call(this))._pos=0,a._path=t,a._meta=n,a._mode=i,a}return m(r,[{key:"close",value:function(){}},{key:"read",value:function(t,e){if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(this._isEOF){var r=new Error("EOF");throw r.name="EndOfFile",r}var n=Math.min(t*e,this._file.length-this._pos),o=n-n%t,i=new Uint8Array(o);return i.set(this._file.slice(this._pos,this._pos+o),0),this._pos+=o,i}},{key:"write",value:function(t){var e=new Uint8Array(this._pos+t.length);void 0!==this._file?(e.set(this._file.slice(0,this._pos)),e.set(t,this._pos)):e.set(t),this._file=e,this._pos+=t.length}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._file.length);else if(1===e)n=Math.min(this._pos+t,this._file.length);else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._file.length+t,this._file.length)}this._pos=n}},{key:"tell",value:function(){return this.exists()?this._pos:-1}},{key:"remove",value:function(){return s(this,void 0,void 0,a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.exists()){t.next=2;break}throw new Error("ENOENT");case 2:r._memFiles.delete(this._path),this._pos=0;case 4:case"end":return t.stop()}}),t,this)})))}},{key:"exists",value:function(){return void 0!==this._file}},{key:"_isEOF",get:function(){return this._pos>=this._file.length}},{key:"_file",get:function(){return r._memFiles.get(this._path)},set:function(t){r._memFiles.set(this._path,t)}}],[{key:"open",value:function(t,e){var n=r._memFiles.get(t),o=e.includes("r")?"readonly":"readwrite";if(void 0===n&&"readonly"===o){var i=new Error("'".concat(t,"' doesn't exist."));throw i.name="FileNotExists",i}var a=new r(t,void 0,void 0,o);return e.includes("a")&&a.seek(0,2),a}}]),r}();function N(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return L(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return L(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function M(t,e){for(var r=e;0!==t[r];)r++;return new TextDecoder("utf-8").decode(t.subarray(e,r))}function R(t){for(var e=atob(t),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function F(t,e,r){for(var n="",o=0;o<e;o++)n+=String.fromCharCode(t[r+o]);return btoa(n)}function j(t){var e,r={},n=N(t.split("\r\n"));try{for(n.s();!(e=n.n()).done;){var o=e.value.split(": ");""!==o[0]&&(r[o[0]]=o[1])}}catch(t){n.e(t)}finally{n.f()}return r}function B(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;return s(this,void 0,void 0,a.mark((function n(){var o,i,s,c;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=new AbortController,i=Object.assign(Object.assign({},e),{signal:o.signal}),s=setTimeout((function(){o.abort()}),r),n.next=5,fetch(t,i);case 5:return c=n.sent,clearTimeout(s),n.abrupt("return",c);case 8:case"end":return n.stop()}}),n)})))}function Y(t){if("string"!=typeof t)return!1;var e=t.trim();if(""===e)return!1;try{return btoa(atob(e))===e}catch(t){return!1}}function z(t,e){return s(this,void 0,void 0,a.mark((function r(){var n;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,T.open(t,e);case 3:return r.abrupt("return",r.sent);case 6:if(r.prev=6,r.t0=r.catch(0),"IndexedDBNotSupported"===r.t0.name?console.warn("IndexedDB is not supported. Fallback to in-memory storage."):"FileNotExists"!==r.t0.name&&console.warn("Unable to access IndexedDB (".concat(r.t0.toString(),"). Fallback to in-memory storage.")),!("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope)){r.next=16;break}if("FileNotExists"!==r.t0.name){r.next=12;break}throw r.t0;case 12:throw console.error("In-memory storage cannot be used inside a worker."),(n=new Error("Failed to start PvFile: ".concat(r.t0.toString()))).name="PvFileNotSupported",n;case 16:return r.abrupt("return",I.open(t,e));case 17:case"end":return r.stop()}}),r,null,[[0,6]])})))}function W(t,e,r,n){return s(this,void 0,void 0,a.mark((function o(){var i;return a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,z(t,"w");case 2:if(i=o.sent,!(r||void 0===i.meta||n>i.meta.version)){o.next=6;break}return o.next=6,i.write(R(e),n);case 6:case"end":return o.stop()}}),o)})))}I._memFiles=new Map;var U=5e3,D=2;function C(t,e,r,n,o){return s(this,void 0,void 0,a.mark((function i(){var s,c,u,f,l,p,h,d;return a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,z(t,"w");case 2:if(s=i.sent,!(r||void 0===s.meta||n>s.meta.version)){i.next=43;break}if(!(o<0)){i.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:c=D,u=function(t){return new Promise((function(e){setTimeout(e,t)}))},f=o+1,l=null;case 10:if(!(f>0)){i.next=38;break}return l=null,i.prev=12,i.next=15,fetch(e,{cache:"no-cache"});case 15:if(!(p=i.sent).ok){i.next=23;break}return i.next=19,p.arrayBuffer();case 19:return h=i.sent,i.next=22,s.write(new Uint8Array(h),n);case 22:return i.abrupt("return");case 23:return i.next=25,p.text();case 25:d=i.sent,l=new Error("Error response returned while fetching model from '".concat(e,"': ").concat(d)),i.next=32;break;case 29:i.prev=29,i.t0=i.catch(12),l=new Error("Failed to fetch model from '".concat(e,"': ").concat(i.t0.message));case 32:return f--,i.next=35,u(c);case 35:c=Math.min(U,c*D),i.next=10;break;case 38:if(null===l){i.next=42;break}throw l;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(e,"'"));case 43:case"end":return i.stop()}}),i,null,[[12,29]])})))}function G(t){return s(this,void 0,void 0,a.mark((function e(){var r,n,o,i,s,c,u,f,l;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new Error("The model is undefined / empty");case 2:if(r=t.base64,n=t.publicPath,o=t.customWritePath,i=t.forceWrite,s=void 0!==i&&i,c=t.version,u=void 0===c?1:c,f=t.numFetchRetries,l=void 0===f?0:f,null!=o){e.next=5;break}throw new Error("The customWritePath of the provided model is undefined / empty");case 5:if(null==r){e.next=10;break}return e.next=8,W(o,r,s,u);case 8:case 13:e.next=16;break;case 10:if(null==n){e.next=15;break}return e.next=13,C(o,n,s,u,l);case 15:throw new Error("The provided model doesn't contain a valid publicPath or base64 value");case 16:return e.abrupt("return",o);case 17:case"end":return e.stop()}}),e)})))}var q={args_get:function(t){return 0},args_sizes_get:function(t){return 0},environ_get:function(t){return 0},environ_sizes_get:function(t){return 0},clock_res_get:function(t){return 0},clock_time_get:function(t){return 0},fd_advise:function(t){return 0},fd_allocate:function(t){return 0},fd_close:function(t){return 0},fd_datasync:function(t){return 0},fd_fdstat_get:function(t){return 0},fd_fdstat_set_flags:function(t){return 0},fd_fdstat_set_rights:function(t){return 0},fd_filestat_get:function(t){return 0},fd_filestat_set_size:function(t){return 0},fd_filestat_set_times:function(t){return 0},fd_pread:function(t){return 0},fd_prestat_get:function(t){return 0},fd_prestat_dir_name:function(t){return 0},fd_pwrite:function(t){return 0},fd_read:function(t){return 0},fd_readdir:function(t){return 0},fd_renumber:function(t){return 0},fd_seek:function(t){return 0},fd_sync:function(t){return 0},fd_tell:function(t){return 0},fd_write:function(t){return 0},path_create_directory:function(t){return 0},path_filestat_get:function(t){return 0},path_filestat_set_times:function(t){return 0},path_link:function(t){return 0},path_open:function(t){return 0},path_readlink:function(t){return 0},path_remove_directory:function(t){return 0},path_rename:function(t){return 0},path_symlink:function(t){return 0},path_unlink_file:function(t){return 0},poll_oneoff:function(t){return 0},proc_exit:function(t){return 0},proc_raise:function(t){return 0},sched_yield:function(t){return 0},random_get:function(t){return 0},sock_recv:function(t){return 0},sock_send:function(t){return 0},sock_shutdown:function(t){return 0}};function H(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return s(this,void 0,void 0,a.mark((function o(){var i,c,u,f,l,d,v,_,y,m,E,w,g,x,k,P,S,O,T,A,I;return a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(i=new Uint8Array(t.buffer),c=new Int32Array(t.buffer),u=function(t){console.log(M(i,t))},f=function(t,e,r){if(0===t){var n=M(i,r);throw new Error("assertion failed at line ".concat(e,' in "').concat(n,'"'))}},l=function(){return Date.now()/1e3},d=function(t,e,n,o,u,f,l,p,h){return s(this,void 0,void 0,a.mark((function s(){var d,v,_,y,m,E,w,g,x,b,k,P;return a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return d=M(i,t),v=M(i,e),_=M(i,n),y=M(i,o),m=M(i,u),E=j(y),w={method:d},m.length>0&&(w.body=m),Object.keys(E).length>0&&(w.headers=E),a.prev=9,a.next=12,B("https://"+v+_,w,f);case 12:g=a.sent,b=g.status,a.next=20;break;case 16:return a.prev=16,a.t0=a.catch(9),null==r||r.addError("pvHttpsRequestWasm","Failed to fetch: ".concat(a.t0)),a.abrupt("return");case 20:return a.prev=20,a.next=23,g.text();case 23:x=a.sent,a.next=30;break;case 26:return a.prev=26,a.t1=a.catch(20),null==r||r.addError("pvHttpsRequestWasm","Failed to get response text: ".concat(a.t1)),a.abrupt("return");case 30:return a.next=32,I(Int8Array.BYTES_PER_ELEMENT,(x.length+1)*Int8Array.BYTES_PER_ELEMENT);case 32:if(0!==(k=a.sent)){a.next=37;break}return null==r||r.addError("pvMallocError","pvHttpsRequestWasm: cannot allocate memory for response"),c[l/Int32Array.BYTES_PER_ELEMENT]=0,a.abrupt("return");case 37:for(c[p/Int32Array.BYTES_PER_ELEMENT]=x.length+1,c[l/Int32Array.BYTES_PER_ELEMENT]=k,P=0;P<x.length;P++)i[k+P]=x.charCodeAt(P);i[k+x.length]=0,c[h/Int32Array.BYTES_PER_ELEMENT]=b;case 42:case"end":return a.stop()}}),s,null,[[9,16],[20,26]])})))},v=function(t){return s(this,void 0,void 0,a.mark((function e(){var n,o,s;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=void 0!==navigator.userAgent?navigator.userAgent:"unknown",e.next=3,I(Uint8Array.BYTES_PER_ELEMENT,(n.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 3:if(0!==(o=e.sent)){e.next=8;break}return null==r||r.addError("pvMallocError","pvGetBrowserInfo: cannot allocate memory for browser info"),c[t/Int32Array.BYTES_PER_ELEMENT]=0,e.abrupt("return");case 8:for(c[t/Int32Array.BYTES_PER_ELEMENT]=o,s=0;s<n.length;s++)i[o+s]=n.charCodeAt(s);i[o+n.length]=0;case 11:case"end":return e.stop()}}),e)})))},_=function(t){var e;return s(this,void 0,void 0,a.mark((function n(){var o,s,u,f;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=null!==(e=self.origin)&&void 0!==e?e:self.location.origin,s=new URL(o).hostname,n.next=4,I(Uint8Array.BYTES_PER_ELEMENT,(s.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 4:if(0!==(u=n.sent)){n.next=9;break}return null==r||r.addError("pvMallocError","pvGetOriginInfo: cannot allocate memory for origin info"),c[t/Int32Array.BYTES_PER_ELEMENT]=0,n.abrupt("return");case 9:for(c[t/Int32Array.BYTES_PER_ELEMENT]=u,f=0;f<s.length;f++)i[u+f]=s.charCodeAt(f);i[u+s.length]=0;case 12:case"end":return n.stop()}}),n)})))},y=function(t,e,n,o){return s(this,void 0,void 0,a.mark((function s(){var u,f,l;return a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return u=M(i,e),f=M(i,n),a.prev=2,a.next=5,z(u,f);case 5:l=a.sent,b.setPtr(t,l),c[o/Int32Array.BYTES_PER_ELEMENT]=0,a.next=14;break;case 10:a.prev=10,a.t0=a.catch(2),"FileNotExists"!==a.t0.name&&(null==r||r.addError("pvFileOpenWasm",a.t0)),c[o/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return a.stop()}}),s,null,[[2,10]])})))},m=function(t,e){return s(this,void 0,void 0,a.mark((function n(){var o;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,b.getPtr(t);case 3:return o=n.sent,n.next=6,o.close();case 6:c[e/Int32Array.BYTES_PER_ELEMENT]=0,n.next=13;break;case 9:n.prev=9,n.t0=n.catch(0),null==r||r.addError("pvFileCloseWasm",n.t0),c[e/Int32Array.BYTES_PER_ELEMENT]=-1;case 13:case"end":return n.stop()}}),n,null,[[0,9]])})))},E=function(t,e,n,o,u){return s(this,void 0,void 0,a.mark((function s(){var f,l;return a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,b.getPtr(t);case 3:return f=a.sent,a.next=6,f.read(n,o);case 6:l=a.sent,i.set(l,e),c[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,a.next=15;break;case 11:a.prev=11,a.t0=a.catch(0),null==r||r.addError("pvFileReadWasm",a.t0),c[u/Int32Array.BYTES_PER_ELEMENT]=-1;case 15:case"end":return a.stop()}}),s,null,[[0,11]])})))},w=function(t,e,n,o,u){return s(this,void 0,void 0,a.mark((function s(){var f,l;return a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,b.getPtr(t);case 3:return f=a.sent,(l=new Uint8Array(n*o)).set(i.slice(e,e+n*o),0),a.next=8,f.write(l);case 8:c[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,a.next=15;break;case 11:a.prev=11,a.t0=a.catch(0),null==r||r.addError("pvFileWriteWasm",a.t0),c[u/Int32Array.BYTES_PER_ELEMENT]=1;case 15:case"end":return a.stop()}}),s,null,[[0,11]])})))},g=function(t,e,n,o){try{b.getPtr(t).seek(e,n),c[o/Int32Array.BYTES_PER_ELEMENT]=0}catch(t){null==r||r.addError("pvFileSeekWasm",t),c[o/Int32Array.BYTES_PER_ELEMENT]=-1}},x=function(t,e){try{var n=b.getPtr(t);c[e/Int32Array.BYTES_PER_ELEMENT]=n.tell()}catch(t){null==r||r.addError("pvFileTellWasm",t),c[e/Int32Array.BYTES_PER_ELEMENT]=-1}},k=function(t,e){return s(this,void 0,void 0,a.mark((function n(){var o,s;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=M(i,t),n.prev=1,n.next=4,z(o,"w");case 4:return s=n.sent,n.next=7,s.remove();case 7:c[e/Int32Array.BYTES_PER_ELEMENT]=0,n.next=14;break;case 10:n.prev=10,n.t0=n.catch(1),null==r||r.addError("pvFileRemoveWasm",n.t0),c[e/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return n.stop()}}),n,null,[[1,10]])})))},P={wasi_snapshot_preview1:q,env:Object.assign({memory:t,pv_console_log_wasm:u,pv_assert_wasm:f,pv_time_wasm:l,pv_https_request_wasm:d,pv_get_browser_info:v,pv_get_origin_info:_,pv_file_open_wasm:y,pv_file_close_wasm:m,pv_file_read_wasm:E,pv_file_write_wasm:w,pv_file_seek_wasm:g,pv_file_tell_wasm:x,pv_file_remove_wasm:k},n)},!(e instanceof Promise)){o.next=34;break}if(!h){o.next=23;break}return o.next=20,h(e,P);case 20:S=o.sent.instance,o.next=32;break;case 23:return o.next=25,e;case 25:return O=o.sent,o.next=28,O.arrayBuffer();case 28:return T=o.sent,o.next=31,p(new Uint8Array(T),P);case 31:S=o.sent.instance;case 32:o.next=38;break;case 34:return A=R(e),o.next=37,p(A,P);case 37:S=o.sent.instance;case 38:return I=S.exports.aligned_alloc,o.abrupt("return",S.exports);case 40:case"end":return o.stop()}}),o)})))}function K(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function V(t){return function(t){if(Array.isArray(t))return K(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return K(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)?K(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var $=function(){function t(){d(this,t),this._maxNumErrors=10,this._errors=[],this._lastError=new Error("null")}return m(t,[{key:"addError",value:function(t,e){this._lastError=e instanceof Error?e:new Error(e),this._errors.length>=this._maxNumErrors&&this._errors.shift(),e instanceof Error?this._errors.push({key:t,message:e.toString()}):this._errors.push({key:t,message:JSON.stringify(e)})}},{key:"getErrors",value:function(){var t=V(this._errors);return this._errors=[],t}},{key:"getErrorString",value:function(){return this.getErrors().map((function(t){var e=t.key,r=t.message;return"'".concat(e,"' failed with: ").concat(r,".")})).join("\n")}},{key:"getLastError",value:function(){return this._lastError}},{key:"setMaxErrorNum",value:function(t){this._maxNumErrors=t}}]),t}(),J={DB_NAME:P,DB_VERSION:3,PV_FILE_STORE:S};export{$ as PvError,b as PvFile,T as PvFileIDB,I as PvFileMem,F as arrayBufferToBase64AtIndex,M as arrayBufferToStringAtIndex,R as base64ToUint8Array,H as buildWasm,J as dbConfig,B as fetchWithTimeout,W as fromBase64,C as fromPublicDirectory,O as getDB,Y as isAccessKeyValid,G as loadModel,z as open,j as stringHeaderToObject}; | ||
function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e={exports:{}},r={exports:{}};!function(t){function e(r){return t.exports=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},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(r);var n=r.exports;!function(t){var e=n.default;function r(){t.exports=r=function(){return o},t.exports.__esModule=!0,t.exports.default=t.exports;var n,o={},i=Object.prototype,a=i.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",f=c.asyncIterator||"@@asyncIterator",l=c.toStringTag||"@@toStringTag";function p(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{p({},"")}catch(n){p=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,i=Object.create(o.prototype),a=new M(n||[]);return s(i,"_invoke",{value:A(t,r,a)}),i}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}o.wrap=h;var v="suspendedStart",_="suspendedYield",y="executing",m="completed",E={};function w(){}function g(){}function x(){}var b={};p(b,u,(function(){return this}));var k=Object.getPrototypeOf,P=k&&k(k(R([])));P&&P!==i&&a.call(P,u)&&(b=P);var S=x.prototype=w.prototype=Object.create(b);function O(t){["next","throw","return"].forEach((function(e){p(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,r){function n(o,i,s,c){var u=d(t[o],t,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==e(l)&&a.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):r.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;s(this,"_invoke",{value:function(t,e){function i(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(i,i):i()}})}function A(t,e,r){var o=v;return function(i,a){if(o===y)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:n,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var c=I(s,r);if(c){if(c===E)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===v)throw o=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=y;var u=d(t,e,r);if("normal"===u.type){if(o=r.done?m:_,u.arg===E)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=m,r.method="throw",r.arg=u.arg)}}}function I(t,e){var r=e.method,o=t.iterator[r];if(o===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,I(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),E;var i=d(o,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,E;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,E):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,E)}function N(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 L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function R(t){if(t||""===t){var r=t[u];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function e(){for(;++o<t.length;)if(a.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=n,e.done=!0,e};return i.next=i}}throw new TypeError(e(t)+" is not iterable")}return g.prototype=x,s(S,"constructor",{value:x,configurable:!0}),s(x,"constructor",{value:g,configurable:!0}),g.displayName=p(x,l,"GeneratorFunction"),o.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},o.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,p(t,l,"GeneratorFunction")),t.prototype=Object.create(S),t},o.awrap=function(t){return{__await:t}},O(T.prototype),p(T.prototype,f,(function(){return this})),o.AsyncIterator=T,o.async=function(t,e,r,n,i){void 0===i&&(i=Promise);var a=new T(h(t,e,r,n),i);return o.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(S),p(S,l,"Generator"),p(S,u,(function(){return this})),p(S,"toString",(function(){return"[object Generator]"})),o.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},o.values=R,M.prototype={constructor:M,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,o){return s.type="throw",s.arg=t,e.next=r,o&&(e.method="next",e.arg=n),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=a.call(i,"catchLoc"),u=a.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,E):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),E},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),E}},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 o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:R(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),E}},o}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(e);var o=(0,e.exports)(),i=o;try{regeneratorRuntime=o}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=o:Function("r","regeneratorRuntime = r")(o)}var a=t(i);function s(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))}const c=new WeakMap;function u(t,e){return new Proxy(t,{get:(t,r)=>e(t[r])})}class f{constructor(){this.value=void 0,this.exports=null}getState(){return this.exports.asyncify_get_state()}assertNoneState(){let t=this.getState();if(0!==t)throw new Error(`Invalid async state ${t}, expected 0.`)}wrapImportFn(t){return(...e)=>{if(2===this.getState())return this.exports.asyncify_stop_rewind(),this.value;this.assertNoneState();let r=t(...e);if(!(n=r)||"object"!=typeof n&&"function"!=typeof n||"function"!=typeof n.then)return r;var n;this.exports.asyncify_start_unwind(16),this.value=r}}wrapModuleImports(t){return u(t,(t=>"function"==typeof t?this.wrapImportFn(t):t))}wrapImports(t){if(void 0!==t)return u(t,((t=Object.create(null))=>this.wrapModuleImports(t)))}wrapExportFn(t){let e=c.get(t);return void 0!==e||(e=async(...e)=>{this.assertNoneState();let r=t(...e);for(;1===this.getState();)this.exports.asyncify_stop_unwind(),this.value=await this.value,this.assertNoneState(),this.exports.asyncify_start_rewind(16),r=t();return this.assertNoneState(),r},c.set(t,e)),e}wrapExports(t){let e=Object.create(null);for(let r in t){let n=t[r];"function"!=typeof n||r.startsWith("asyncify_")||(n=this.wrapExportFn(n)),Object.defineProperty(e,r,{enumerable:!0,value:n})}return c.set(t,e),e}init(t,e){const{exports:r}=t,n=r.memory||e.env&&e.env.memory;new Int32Array(n.buffer,16).set([24,1024]),this.exports=this.wrapExports(r),Object.setPrototypeOf(t,l.prototype)}}class l extends WebAssembly.Instance{constructor(t,e){let r=new f;super(t,r.wrapImports(e)),r.init(this,e)}get exports(){return c.get(super.exports)}}async function p(t,e){let r=new f,n=await WebAssembly.instantiate(t,r.wrapImports(e));return r.init(n instanceof WebAssembly.Instance?n:n.instance,e),n}async function h(t,e){let r=new f,n=await WebAssembly.instantiateStreaming(t,r.wrapImports(e));return r.init(n.instance,e),n}function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function v(t){return v="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},v(t)}function _(t){var e=function(t,e){if("object"!==v(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===v(e)?e:String(e)}function y(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_(n.key),n)}}function m(t,e,r){return e&&y(t.prototype,e),r&&y(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function E(t,e){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},E(t,e)}function w(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&E(t,e)}function g(t,e){if(e&&("object"===v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(t)}Object.defineProperty(l.prototype,"exports",{enumerable:!0});var b=function(){function t(){d(this,t),this._path=""}return m(t,[{key:"meta",get:function(){if(void 0!==this._meta)return Object.assign({version:0},this._meta)}}],[{key:"getPtr",value:function(e){if(t._filePtrs.has(e))return t._filePtrs.get(e);throw new Error("File instance not found.")}},{key:"setPtr",value:function(e,r){t._filePtrs.set(e,r)}},{key:"removePtr",value:function(e){t._filePtrs.delete(e)}}]),t}();function k(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x(t);if(e){var o=x(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return g(this,r)}}b._filePtrs=new Map;var P="pv_db",S="pv_file";function O(){return new Promise((function(t,e){var r=self.indexedDB.open(P,3);r.onerror=function(){e(r.error)},r.onsuccess=function(){t(r.result)},r.onupgradeneeded=function(){r.result.objectStoreNames.contains(S)||r.result.createObjectStore(S)}}))}var T=function(t){w(r,b);var e=k(r);function r(t,n,o,i){var a;return d(this,r),(a=e.call(this))._pageSize=65536,a._pagePtr=0,a._pageOffset=0,a._path=t,a._meta=n,a._db=o,a._mode=i,a}return m(r,[{key:"close",value:function(){return s(this,void 0,void 0,a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._db.close();case 1:case"end":return t.stop()}}),t,this)})))}},{key:"read",value:function(t,e){return s(this,void 0,void 0,a.mark((function n(){var o=this;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,i){if(o.exists()){if(o._isEOF){var a=new Error("EOF");return a.name="EndOfFile",void i(a)}var s=0,c=Math.min(t*e,o._meta.size),u=c-c%t,f=new Uint8Array(u),l=IDBKeyRange.bound("".concat(o._path,"-").concat(r.createPage(o._pagePtr)),"".concat(o._path,"-").concat(r.createPage(o._meta.numPages))),p=o._store,h=p.openCursor(l);h.onsuccess=function(){var t=h.result;if(t&&!o._isEOF){var e=Math.min(u-s,t.value.length-o._pageOffset);f.set(t.value.slice(o._pageOffset,o._pageOffset+e),s),s+=e,o._pageOffset+=e,o._pageOffset===o._pageSize&&(o._pagePtr+=1,o._pageOffset=0),s<u&&t.continue()}},p.transaction.onerror=function(){i(p.transaction.error)},p.transaction.oncomplete=function(){n(f.slice(0,s))}}else i(new Error("'".concat(o._path,"' doesn't exist.")))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"write",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return s(this,void 0,void 0,a.mark((function n(){var o=this;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,i){return s(o,void 0,void 0,a.mark((function o(){var s,c,u,f,l,p,h,d,v,_=this;return a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if("readonly"!==this._mode){o.next=3;break}return i(new Error("Instance is readonly mode only.")),o.abrupt("return");case 3:if(!("number"!=typeof e&&e<=0)){o.next=6;break}return i(new Error("Version should be a positive number")),o.abrupt("return");case 6:return s=this._store,c=function(){return new Promise((function(t){var e=s.get("".concat(_._path,"-").concat(r.createPage(_._pagePtr)));e.onsuccess=function(){void 0!==e.result?t(e.result.slice(0,_._pageOffset)):t(new Uint8Array(0))}}))},o.next=10,c();case 10:for(u=o.sent,(f=new Uint8Array(u.length+t.length)).set(u),f.set(t,u.length),l=this._pagePtr*this._pageSize+f.length,p={size:l,numPages:Math.ceil(l/this._pageSize),version:e},s.put(p,this._path),h=Math.ceil(f.length/this._pageSize),d=0;d<h;d++)s.put(f.slice(d*this._pageSize,(d+1)*this._pageSize),"".concat(this._path,"-").concat(r.createPage(this._pagePtr+d)));this.exists()&&p.numPages<this._meta.numPages&&(v=IDBKeyRange.bound("".concat(this._path,"-").concat(r.createPage(p.numPages)),"".concat(this._path,"-").concat(r.createPage(this._meta.numPages)),!0),s.delete(v)),s.transaction.onerror=function(){i(s.transaction.error)},s.transaction.oncomplete=function(){_._meta=p,_.seek(0,2),n()};case 22:case"end":return o.stop()}}),o,this)})))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._meta.size);else if(1===e){var o=this._pageSize*this._pagePtr+this._pageOffset;n=Math.min(o+t,this._meta.size)}else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._meta.size+t,this._meta.size)}this._pageOffset=n%this._pageSize,this._pagePtr=Math.floor(n/this._pageSize)}},{key:"tell",value:function(){return this.exists()?this._pagePtr*this._pageSize+this._pageOffset:-1}},{key:"remove",value:function(){return s(this,void 0,void 0,a.mark((function t(){var e=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){return s(e,void 0,void 0,a.mark((function e(){var o,i,s,c,u=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.exists()){e.next=3;break}return n(new Error("ENOENT")),e.abrupt("return");case 3:o=this._meta.numPages,i=IDBKeyRange.bound(this._path,"".concat(this._path,"-").concat(r.createPage(o))),s=this._store,(c=s.delete(i)).onerror=function(){n(c.error)},c.onsuccess=function(){u._meta=void 0,u._pageOffset=0,u._pagePtr=0,t()};case 9:case"end":return e.stop()}}),e,this)})))})));case 1:case"end":return t.stop()}}),t)})))}},{key:"exists",value:function(){return void 0!==this._meta}},{key:"_isEOF",get:function(){return this._pagePtr>=this._meta.numPages-1&&this._pageOffset>=this._meta.size%this._pageSize}},{key:"_store",get:function(){return this._db.transaction(S,this._mode).objectStore(S)}}],[{key:"open",value:function(t,e){var n=this;if(!self.indexedDB){var o=new Error("IndexedDB is not supported");throw o.name="IndexedDBNotSupported",o}return new Promise((function(o,i){return s(n,void 0,void 0,a.mark((function n(){var s,c,u;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,O();case 3:s=n.sent,(c=s.transaction(S,"readwrite").objectStore(S).get(t)).onerror=function(){i(c.error)},c.onsuccess=function(){var n=c.result,a=e.includes("r")?"readonly":"readwrite";if(void 0===n&&"readonly"===a){var u=new Error("'".concat(t,"' doesn't exist."));return u.name="FileNotExists",void i(u)}var f=new r(t,n,s,a);e.includes("a")&&f.seek(0,2),o(f)},n.next=12;break;case 9:n.prev=9,n.t0=n.catch(0),"InvalidStateError"===n.t0.name?((u=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",i(u)):i(n.t0);case 12:case"end":return n.stop()}}),n,null,[[0,9]])})))}))}},{key:"createPage",value:function(t){return("00000"+t).slice(-6)}}]),r}();function A(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x(t);if(e){var o=x(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return g(this,r)}}var I=function(t){w(r,b);var e=A(r);function r(t,n,o,i){var a;return d(this,r),(a=e.call(this))._pos=0,a._path=t,a._meta=n,a._mode=i,a}return m(r,[{key:"close",value:function(){}},{key:"read",value:function(t,e){if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(this._isEOF){var r=new Error("EOF");throw r.name="EndOfFile",r}var n=Math.min(t*e,this._file.length-this._pos),o=n-n%t,i=new Uint8Array(o);return i.set(this._file.slice(this._pos,this._pos+o),0),this._pos+=o,i}},{key:"write",value:function(t){var e=new Uint8Array(this._pos+t.length);void 0!==this._file?(e.set(this._file.slice(0,this._pos)),e.set(t,this._pos)):e.set(t),this._file=e,this._pos+=t.length}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._file.length);else if(1===e)n=Math.min(this._pos+t,this._file.length);else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._file.length+t,this._file.length)}this._pos=n}},{key:"tell",value:function(){return this.exists()?this._pos:-1}},{key:"remove",value:function(){return s(this,void 0,void 0,a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.exists()){t.next=2;break}throw new Error("ENOENT");case 2:r._memFiles.delete(this._path),this._pos=0;case 4:case"end":return t.stop()}}),t,this)})))}},{key:"exists",value:function(){return void 0!==this._file}},{key:"_isEOF",get:function(){return this._pos>=this._file.length}},{key:"_file",get:function(){return r._memFiles.get(this._path)},set:function(t){r._memFiles.set(this._path,t)}}],[{key:"open",value:function(t,e){var n=r._memFiles.get(t),o=e.includes("r")?"readonly":"readwrite";if(void 0===n&&"readonly"===o){var i=new Error("'".concat(t,"' doesn't exist."));throw i.name="FileNotExists",i}var a=new r(t,void 0,void 0,o);return e.includes("a")&&a.seek(0,2),a}}]),r}();function N(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return L(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return L(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function M(t,e){for(var r=e;0!==t[r];)r++;return new TextDecoder("utf-8").decode(t.subarray(e,r))}function R(t){for(var e=atob(t),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function F(t,e,r){for(var n="",o=0;o<e;o++)n+=String.fromCharCode(t[r+o]);return btoa(n)}function j(t){var e,r={},n=N(t.split("\r\n"));try{for(n.s();!(e=n.n()).done;){var o=e.value.split(": ");""!==o[0]&&(r[o[0]]=o[1])}}catch(t){n.e(t)}finally{n.f()}return r}function B(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;return s(this,void 0,void 0,a.mark((function n(){var o,i,s,c;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=new AbortController,i=Object.assign(Object.assign({},e),{signal:o.signal}),s=setTimeout((function(){o.abort()}),r),n.next=5,fetch(t,i);case 5:return c=n.sent,clearTimeout(s),n.abrupt("return",c);case 8:case"end":return n.stop()}}),n)})))}function Y(t){if("string"!=typeof t)return!1;var e=t.trim();if(""===e)return!1;try{return btoa(atob(e))===e}catch(t){return!1}}function z(t,e){return s(this,void 0,void 0,a.mark((function r(){var n;return a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,T.open(t,e);case 3:return r.abrupt("return",r.sent);case 6:if(r.prev=6,r.t0=r.catch(0),"IndexedDBNotSupported"===r.t0.name?console.warn("IndexedDB is not supported. Fallback to in-memory storage."):"FileNotExists"!==r.t0.name&&console.warn("Unable to access IndexedDB (".concat(r.t0.toString(),"). Fallback to in-memory storage.")),!("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope)){r.next=16;break}if("FileNotExists"!==r.t0.name){r.next=12;break}throw r.t0;case 12:throw console.error("In-memory storage cannot be used inside a worker."),(n=new Error("Failed to start PvFile: ".concat(r.t0.toString()))).name="PvFileNotSupported",n;case 16:return r.abrupt("return",I.open(t,e));case 17:case"end":return r.stop()}}),r,null,[[0,6]])})))}function W(t,e,r,n){return s(this,void 0,void 0,a.mark((function o(){var i;return a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,z(t,"w");case 2:if(i=o.sent,!(r||void 0===i.meta||n>i.meta.version)){o.next=6;break}return o.next=6,i.write(R(e),n);case 6:case"end":return o.stop()}}),o)})))}I._memFiles=new Map;var U=5e3,D=2;function C(t,e,r,n,o){return s(this,void 0,void 0,a.mark((function i(){var s,c,u,f,l,p,h,d;return a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,z(t,"w");case 2:if(s=i.sent,!(r||void 0===s.meta||n>s.meta.version)){i.next=43;break}if(!(o<0)){i.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:c=D,u=function(t){return new Promise((function(e){setTimeout(e,t)}))},f=o+1,l=null;case 10:if(!(f>0)){i.next=38;break}return l=null,i.prev=12,i.next=15,fetch(e,{cache:"no-cache"});case 15:if(!(p=i.sent).ok){i.next=23;break}return i.next=19,p.arrayBuffer();case 19:return h=i.sent,i.next=22,s.write(new Uint8Array(h),n);case 22:return i.abrupt("return");case 23:return i.next=25,p.text();case 25:d=i.sent,l=new Error("Error response returned while fetching model from '".concat(e,"': ").concat(d)),i.next=32;break;case 29:i.prev=29,i.t0=i.catch(12),l=new Error("Failed to fetch model from '".concat(e,"': ").concat(i.t0.message));case 32:return f--,i.next=35,u(c);case 35:c=Math.min(U,c*D),i.next=10;break;case 38:if(null===l){i.next=42;break}throw l;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(e,"'"));case 43:case"end":return i.stop()}}),i,null,[[12,29]])})))}function G(t){return s(this,void 0,void 0,a.mark((function e(){var r,n,o,i,s,c,u,f,l;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new Error("The model is undefined / empty");case 2:if(r=t.base64,n=t.publicPath,o=t.customWritePath,i=t.forceWrite,s=void 0!==i&&i,c=t.version,u=void 0===c?1:c,f=t.numFetchRetries,l=void 0===f?0:f,null!=o){e.next=5;break}throw new Error("The customWritePath of the provided model is undefined / empty");case 5:if(null==r){e.next=10;break}return e.next=8,W(o,r,s,u);case 8:case 13:e.next=16;break;case 10:if(null==n){e.next=15;break}return e.next=13,C(o,n,s,u,l);case 15:throw new Error("The provided model doesn't contain a valid publicPath or base64 value");case 16:return e.abrupt("return",o);case 17:case"end":return e.stop()}}),e)})))}var q={args_get:function(t){return 0},args_sizes_get:function(t){return 0},environ_get:function(t){return 0},environ_sizes_get:function(t){return 0},clock_res_get:function(t){return 0},clock_time_get:function(t){return 0},fd_advise:function(t){return 0},fd_allocate:function(t){return 0},fd_close:function(t){return 0},fd_datasync:function(t){return 0},fd_fdstat_get:function(t){return 0},fd_fdstat_set_flags:function(t){return 0},fd_fdstat_set_rights:function(t){return 0},fd_filestat_get:function(t){return 0},fd_filestat_set_size:function(t){return 0},fd_filestat_set_times:function(t){return 0},fd_pread:function(t){return 0},fd_prestat_get:function(t){return 0},fd_prestat_dir_name:function(t){return 0},fd_pwrite:function(t){return 0},fd_read:function(t){return 0},fd_readdir:function(t){return 0},fd_renumber:function(t){return 0},fd_seek:function(t){return 0},fd_sync:function(t){return 0},fd_tell:function(t){return 0},fd_write:function(t){return 0},path_create_directory:function(t){return 0},path_filestat_get:function(t){return 0},path_filestat_set_times:function(t){return 0},path_link:function(t){return 0},path_open:function(t){return 0},path_readlink:function(t){return 0},path_remove_directory:function(t){return 0},path_rename:function(t){return 0},path_symlink:function(t){return 0},path_unlink_file:function(t){return 0},poll_oneoff:function(t){return 0},proc_exit:function(t){return 0},proc_raise:function(t){return 0},sched_yield:function(t){return 0},random_get:function(t){return 0},sock_recv:function(t){return 0},sock_send:function(t){return 0},sock_shutdown:function(t){return 0}};function H(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return s(this,void 0,void 0,a.mark((function o(){var i,c,u,f,l,d,v,_,y,m,E,w,g,x,k,P,S,O,T,A,I;return a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(i=new Uint8Array(t.buffer),c=new Int32Array(t.buffer),u=function(t){console.log(M(i,t))},f=function(t,e,r){if(0===t){var n=M(i,r);throw new Error("assertion failed at line ".concat(e,' in "').concat(n,'"'))}},l=function(){return Date.now()/1e3},d=function(t,e,n,o,u,f,l,p,h){return s(this,void 0,void 0,a.mark((function s(){var d,v,_,y,m,E,w,g,x,b,k,P;return a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return d=M(i,t),v=M(i,e),_=M(i,n),y=M(i,o),m=M(i,u),E=j(y),w={method:d},m.length>0&&(w.body=m),Object.keys(E).length>0&&(w.headers=E),a.prev=9,a.next=12,B("https://"+v+_,w,f);case 12:g=a.sent,b=g.status,a.next=20;break;case 16:return a.prev=16,a.t0=a.catch(9),null==r||r.addError("pvHttpsRequestWasm","Failed to fetch: ".concat(a.t0)),a.abrupt("return");case 20:return a.prev=20,a.next=23,g.text();case 23:x=a.sent,a.next=30;break;case 26:return a.prev=26,a.t1=a.catch(20),null==r||r.addError("pvHttpsRequestWasm","Failed to get response text: ".concat(a.t1)),a.abrupt("return");case 30:return a.next=32,I(Int8Array.BYTES_PER_ELEMENT,(x.length+1)*Int8Array.BYTES_PER_ELEMENT);case 32:if(0!==(k=a.sent)){a.next=37;break}return null==r||r.addError("pvMallocError","pvHttpsRequestWasm: cannot allocate memory for response"),c[l/Int32Array.BYTES_PER_ELEMENT]=0,a.abrupt("return");case 37:for(c[p/Int32Array.BYTES_PER_ELEMENT]=x.length+1,c[l/Int32Array.BYTES_PER_ELEMENT]=k,P=0;P<x.length;P++)i[k+P]=x.charCodeAt(P);i[k+x.length]=0,c[h/Int32Array.BYTES_PER_ELEMENT]=b;case 42:case"end":return a.stop()}}),s,null,[[9,16],[20,26]])})))},v=function(t){return s(this,void 0,void 0,a.mark((function e(){var n,o,s;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=void 0!==navigator.userAgent?navigator.userAgent:"unknown",e.next=3,I(Uint8Array.BYTES_PER_ELEMENT,(n.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 3:if(0!==(o=e.sent)){e.next=8;break}return null==r||r.addError("pvMallocError","pvGetBrowserInfo: cannot allocate memory for browser info"),c[t/Int32Array.BYTES_PER_ELEMENT]=0,e.abrupt("return");case 8:for(c[t/Int32Array.BYTES_PER_ELEMENT]=o,s=0;s<n.length;s++)i[o+s]=n.charCodeAt(s);i[o+n.length]=0;case 11:case"end":return e.stop()}}),e)})))},_=function(t){var e;return s(this,void 0,void 0,a.mark((function n(){var o,s,u,f;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=null!==(e=self.origin)&&void 0!==e?e:self.location.origin,s=new URL(o).hostname,n.next=4,I(Uint8Array.BYTES_PER_ELEMENT,(s.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 4:if(0!==(u=n.sent)){n.next=9;break}return null==r||r.addError("pvMallocError","pvGetOriginInfo: cannot allocate memory for origin info"),c[t/Int32Array.BYTES_PER_ELEMENT]=0,n.abrupt("return");case 9:for(c[t/Int32Array.BYTES_PER_ELEMENT]=u,f=0;f<s.length;f++)i[u+f]=s.charCodeAt(f);i[u+s.length]=0;case 12:case"end":return n.stop()}}),n)})))},y=function(t,e,n,o){return s(this,void 0,void 0,a.mark((function s(){var u,f,l;return a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return u=M(i,e),f=M(i,n),a.prev=2,a.next=5,z(u,f);case 5:l=a.sent,b.setPtr(t,l),c[o/Int32Array.BYTES_PER_ELEMENT]=0,a.next=14;break;case 10:a.prev=10,a.t0=a.catch(2),"FileNotExists"!==a.t0.name&&(null==r||r.addError("pvFileOpenWasm",a.t0)),c[o/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return a.stop()}}),s,null,[[2,10]])})))},m=function(t,e){return s(this,void 0,void 0,a.mark((function n(){var o;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,b.getPtr(t);case 3:return o=n.sent,n.next=6,o.close();case 6:c[e/Int32Array.BYTES_PER_ELEMENT]=0,n.next=13;break;case 9:n.prev=9,n.t0=n.catch(0),null==r||r.addError("pvFileCloseWasm",n.t0),c[e/Int32Array.BYTES_PER_ELEMENT]=-1;case 13:case"end":return n.stop()}}),n,null,[[0,9]])})))},E=function(t,e,n,o,u){return s(this,void 0,void 0,a.mark((function s(){var f,l;return a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,b.getPtr(t);case 3:return f=a.sent,a.next=6,f.read(n,o);case 6:l=a.sent,i.set(l,e),c[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,a.next=15;break;case 11:a.prev=11,a.t0=a.catch(0),null==r||r.addError("pvFileReadWasm",a.t0),c[u/Int32Array.BYTES_PER_ELEMENT]=-1;case 15:case"end":return a.stop()}}),s,null,[[0,11]])})))},w=function(t,e,n,o,u){return s(this,void 0,void 0,a.mark((function s(){var f,l;return a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,b.getPtr(t);case 3:return f=a.sent,(l=new Uint8Array(n*o)).set(i.slice(e,e+n*o),0),a.next=8,f.write(l);case 8:c[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,a.next=15;break;case 11:a.prev=11,a.t0=a.catch(0),null==r||r.addError("pvFileWriteWasm",a.t0),c[u/Int32Array.BYTES_PER_ELEMENT]=1;case 15:case"end":return a.stop()}}),s,null,[[0,11]])})))},g=function(t,e,n,o){try{b.getPtr(t).seek(e,n),c[o/Int32Array.BYTES_PER_ELEMENT]=0}catch(t){null==r||r.addError("pvFileSeekWasm",t),c[o/Int32Array.BYTES_PER_ELEMENT]=-1}},x=function(t,e){try{var n=b.getPtr(t);c[e/Int32Array.BYTES_PER_ELEMENT]=n.tell()}catch(t){null==r||r.addError("pvFileTellWasm",t),c[e/Int32Array.BYTES_PER_ELEMENT]=-1}},k=function(t,e){return s(this,void 0,void 0,a.mark((function n(){var o,s;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=M(i,t),n.prev=1,n.next=4,z(o,"w");case 4:return s=n.sent,n.next=7,s.remove();case 7:c[e/Int32Array.BYTES_PER_ELEMENT]=0,n.next=14;break;case 10:n.prev=10,n.t0=n.catch(1),null==r||r.addError("pvFileRemoveWasm",n.t0),c[e/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return n.stop()}}),n,null,[[1,10]])})))},P={wasi_snapshot_preview1:q,env:Object.assign({memory:t,pv_console_log_wasm:u,pv_assert_wasm:f,pv_time_wasm:l,pv_https_request_wasm:d,pv_get_browser_info:v,pv_get_origin_info:_,pv_file_open_wasm:y,pv_file_close_wasm:m,pv_file_read_wasm:E,pv_file_write_wasm:w,pv_file_seek_wasm:g,pv_file_tell_wasm:x,pv_file_remove_wasm:k},n)},!(e instanceof Promise)){o.next=34;break}if(!h){o.next=23;break}return o.next=20,h(e,P);case 20:S=o.sent.instance,o.next=32;break;case 23:return o.next=25,e;case 25:return O=o.sent,o.next=28,O.arrayBuffer();case 28:return T=o.sent,o.next=31,p(new Uint8Array(T),P);case 31:S=o.sent.instance;case 32:o.next=38;break;case 34:return A=R(e),o.next=37,p(A,P);case 37:S=o.sent.instance;case 38:return I=S.exports.aligned_alloc,o.abrupt("return",S.exports);case 40:case"end":return o.stop()}}),o)})))}function K(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function V(t){return function(t){if(Array.isArray(t))return K(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return K(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)?K(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var $=function(){function t(){d(this,t),this._maxNumErrors=10,this._errors=[],this._lastError=new Error("null")}return m(t,[{key:"addError",value:function(t,e){this._lastError=e instanceof Error?e:new Error(e),this._errors.length>=this._maxNumErrors&&this._errors.shift(),e instanceof Error?this._errors.push({key:t,message:e.toString()}):this._errors.push({key:t,message:JSON.stringify(e)})}},{key:"getErrors",value:function(){var t=V(this._errors);return this._errors=[],t}},{key:"getErrorString",value:function(){return this.getErrors().map((function(t){var e=t.key,r=t.message;return"'".concat(e,"' failed with: ").concat(r,".")})).join("\n")}},{key:"getLastError",value:function(){return this._lastError}},{key:"setMaxErrorNum",value:function(t){this._maxNumErrors=t}}]),t}(),J={DB_NAME:P,DB_VERSION:3,PV_FILE_STORE:S};export{$ as PvError,b as PvFile,T as PvFileIDB,I as PvFileMem,F as arrayBufferToBase64AtIndex,M as arrayBufferToStringAtIndex,R as base64ToUint8Array,H as buildWasm,J as dbConfig,B as fetchWithTimeout,W as fromBase64,C as fromPublicDirectory,O as getDB,Y as isAccessKeyValid,G as loadModel,z as open,j as stringHeaderToObject}; |
@@ -1,1 +0,1 @@ | ||
var WebUtils=function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r={exports:{}},n={exports:{}};!function(t){function e(r){return t.exports=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},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(n);var o=n.exports;!function(t){var e=o.default;function r(){t.exports=r=function(){return o},t.exports.__esModule=!0,t.exports.default=t.exports;var n,o={},i=Object.prototype,a=i.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",f=c.asyncIterator||"@@asyncIterator",l=c.toStringTag||"@@toStringTag";function p(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{p({},"")}catch(n){p=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,i=Object.create(o.prototype),a=new L(n||[]);return s(i,"_invoke",{value:A(t,r,a)}),i}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}o.wrap=h;var v="suspendedStart",_="suspendedYield",y="executing",m="completed",E={};function g(){}function w(){}function b(){}var x={};p(x,u,(function(){return this}));var k=Object.getPrototypeOf,P=k&&k(k(B([])));P&&P!==i&&a.call(P,u)&&(x=P);var S=b.prototype=g.prototype=Object.create(x);function T(t){["next","throw","return"].forEach((function(e){p(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,r){function n(o,i,s,c){var u=d(t[o],t,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==e(l)&&a.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):r.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;s(this,"_invoke",{value:function(t,e){function i(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(i,i):i()}})}function A(t,e,r){var o=v;return function(i,a){if(o===y)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:n,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var c=I(s,r);if(c){if(c===E)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===v)throw o=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=y;var u=d(t,e,r);if("normal"===u.type){if(o=r.done?m:_,u.arg===E)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=m,r.method="throw",r.arg=u.arg)}}}function I(t,e){var r=e.method,o=t.iterator[r];if(o===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,I(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),E;var i=d(o,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,E;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,E):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,E)}function N(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 M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function B(t){if(t||""===t){var r=t[u];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function e(){for(;++o<t.length;)if(a.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=n,e.done=!0,e};return i.next=i}}throw new TypeError(e(t)+" is not iterable")}return w.prototype=b,s(S,"constructor",{value:b,configurable:!0}),s(b,"constructor",{value:w,configurable:!0}),w.displayName=p(b,l,"GeneratorFunction"),o.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},o.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,p(t,l,"GeneratorFunction")),t.prototype=Object.create(S),t},o.awrap=function(t){return{__await:t}},T(O.prototype),p(O.prototype,f,(function(){return this})),o.AsyncIterator=O,o.async=function(t,e,r,n,i){void 0===i&&(i=Promise);var a=new O(h(t,e,r,n),i);return o.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},T(S),p(S,l,"Generator"),p(S,u,(function(){return this})),p(S,"toString",(function(){return"[object Generator]"})),o.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},o.values=B,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(M),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,o){return s.type="throw",s.arg=t,e.next=r,o&&(e.method="next",e.arg=n),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=a.call(i,"catchLoc"),u=a.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,E):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),E},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),M(r),E}},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 o=n.arg;M(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:B(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),E}},o}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(r);var i=(0,r.exports)(),a=i;try{regeneratorRuntime=i}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}var s=e(a);function c(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))}const u=new WeakMap;function f(t,e){return new Proxy(t,{get:(t,r)=>e(t[r])})}class l{constructor(){this.value=void 0,this.exports=null}getState(){return this.exports.asyncify_get_state()}assertNoneState(){let t=this.getState();if(0!==t)throw new Error(`Invalid async state ${t}, expected 0.`)}wrapImportFn(t){return(...e)=>{if(2===this.getState())return this.exports.asyncify_stop_rewind(),this.value;this.assertNoneState();let r=t(...e);if(!(n=r)||"object"!=typeof n&&"function"!=typeof n||"function"!=typeof n.then)return r;var n;this.exports.asyncify_start_unwind(16),this.value=r}}wrapModuleImports(t){return f(t,(t=>"function"==typeof t?this.wrapImportFn(t):t))}wrapImports(t){if(void 0!==t)return f(t,((t=Object.create(null))=>this.wrapModuleImports(t)))}wrapExportFn(t){let e=u.get(t);return void 0!==e||(e=async(...e)=>{this.assertNoneState();let r=t(...e);for(;1===this.getState();)this.exports.asyncify_stop_unwind(),this.value=await this.value,this.assertNoneState(),this.exports.asyncify_start_rewind(16),r=t();return this.assertNoneState(),r},u.set(t,e)),e}wrapExports(t){let e=Object.create(null);for(let r in t){let n=t[r];"function"!=typeof n||r.startsWith("asyncify_")||(n=this.wrapExportFn(n)),Object.defineProperty(e,r,{enumerable:!0,value:n})}return u.set(t,e),e}init(t,e){const{exports:r}=t,n=r.memory||e.env&&e.env.memory;new Int32Array(n.buffer,16).set([24,1024]),this.exports=this.wrapExports(r),Object.setPrototypeOf(t,p.prototype)}}class p extends WebAssembly.Instance{constructor(t,e){let r=new l;super(t,r.wrapImports(e)),r.init(this,e)}get exports(){return u.get(super.exports)}}async function h(t,e){let r=new l,n=await WebAssembly.instantiate(t,r.wrapImports(e));return r.init(n instanceof WebAssembly.Instance?n:n.instance,e),n}async function d(t,e){let r=new l,n=await WebAssembly.instantiateStreaming(t,r.wrapImports(e));return r.init(n.instance,e),n}function v(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _(t){return _="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},_(t)}function y(t){var e=function(t,e){if("object"!==_(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===_(e)?e:String(e)}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,y(n.key),n)}}function E(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function g(t,e){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},g(t,e)}function w(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&g(t,e)}function b(t,e){if(e&&("object"===_(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(t)}Object.defineProperty(p.prototype,"exports",{enumerable:!0});var k=function(){function t(){v(this,t),this._path=""}return E(t,[{key:"meta",get:function(){if(void 0!==this._meta)return Object.assign({version:0},this._meta)}}],[{key:"getPtr",value:function(e){if(t._filePtrs.has(e))return t._filePtrs.get(e);throw new Error("File instance not found.")}},{key:"setPtr",value:function(e,r){t._filePtrs.set(e,r)}},{key:"removePtr",value:function(e){t._filePtrs.delete(e)}}]),t}();function P(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x(t);if(e){var o=x(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return b(this,r)}}k._filePtrs=new Map;var S="pv_db",T="pv_file";function O(){return new Promise((function(t,e){var r=self.indexedDB.open(S,3);r.onerror=function(){e(r.error)},r.onsuccess=function(){t(r.result)},r.onupgradeneeded=function(){r.result.objectStoreNames.contains(T)||r.result.createObjectStore(T)}}))}var A=function(t){w(r,t);var e=P(r);function r(t,n,o,i){var a;return v(this,r),(a=e.call(this))._pageSize=65536,a._pagePtr=0,a._pageOffset=0,a._path=t,a._meta=n,a._db=o,a._mode=i,a}return E(r,[{key:"close",value:function(){return c(this,void 0,void 0,s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._db.close();case 1:case"end":return t.stop()}}),t,this)})))}},{key:"read",value:function(t,e){return c(this,void 0,void 0,s.mark((function n(){var o=this;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,i){if(o.exists()){if(o._isEOF){var a=new Error("EOF");return a.name="EndOfFile",void i(a)}var s=0,c=Math.min(t*e,o._meta.size),u=c-c%t,f=new Uint8Array(u),l=IDBKeyRange.bound("".concat(o._path,"-").concat(r.createPage(o._pagePtr)),"".concat(o._path,"-").concat(r.createPage(o._meta.numPages))),p=o._store,h=p.openCursor(l);h.onsuccess=function(){var t=h.result;if(t&&!o._isEOF){var e=Math.min(u-s,t.value.length-o._pageOffset);f.set(t.value.slice(o._pageOffset,o._pageOffset+e),s),s+=e,o._pageOffset+=e,o._pageOffset===o._pageSize&&(o._pagePtr+=1,o._pageOffset=0),s<u&&t.continue()}},p.transaction.onerror=function(){i(p.transaction.error)},p.transaction.oncomplete=function(){n(f.slice(0,s))}}else i(new Error("'".concat(o._path,"' doesn't exist.")))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"write",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return c(this,void 0,void 0,s.mark((function n(){var o=this;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,i){return c(o,void 0,void 0,s.mark((function o(){var a,c,u,f,l,p,h,d,v,_=this;return s.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if("readonly"!==this._mode){o.next=3;break}return i(new Error("Instance is readonly mode only.")),o.abrupt("return");case 3:if(!("number"!=typeof e&&e<=0)){o.next=6;break}return i(new Error("Version should be a positive number")),o.abrupt("return");case 6:return a=this._store,c=function(){return new Promise((function(t){var e=a.get("".concat(_._path,"-").concat(r.createPage(_._pagePtr)));e.onsuccess=function(){void 0!==e.result?t(e.result.slice(0,_._pageOffset)):t(new Uint8Array(0))}}))},o.next=10,c();case 10:for(u=o.sent,(f=new Uint8Array(u.length+t.length)).set(u),f.set(t,u.length),l=this._pagePtr*this._pageSize+f.length,p={size:l,numPages:Math.ceil(l/this._pageSize),version:e},a.put(p,this._path),h=Math.ceil(f.length/this._pageSize),d=0;d<h;d++)a.put(f.slice(d*this._pageSize,(d+1)*this._pageSize),"".concat(this._path,"-").concat(r.createPage(this._pagePtr+d)));this.exists()&&p.numPages<this._meta.numPages&&(v=IDBKeyRange.bound("".concat(this._path,"-").concat(r.createPage(p.numPages)),"".concat(this._path,"-").concat(r.createPage(this._meta.numPages)),!0),a.delete(v)),a.transaction.onerror=function(){i(a.transaction.error)},a.transaction.oncomplete=function(){_._meta=p,_.seek(0,2),n()};case 22:case"end":return o.stop()}}),o,this)})))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._meta.size);else if(1===e){var o=this._pageSize*this._pagePtr+this._pageOffset;n=Math.min(o+t,this._meta.size)}else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._meta.size+t,this._meta.size)}this._pageOffset=n%this._pageSize,this._pagePtr=Math.floor(n/this._pageSize)}},{key:"tell",value:function(){return this.exists()?this._pagePtr*this._pageSize+this._pageOffset:-1}},{key:"remove",value:function(){return c(this,void 0,void 0,s.mark((function t(){var e=this;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){return c(e,void 0,void 0,s.mark((function e(){var o,i,a,c,u=this;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.exists()){e.next=3;break}return n(new Error("ENOENT")),e.abrupt("return");case 3:o=this._meta.numPages,i=IDBKeyRange.bound(this._path,"".concat(this._path,"-").concat(r.createPage(o))),a=this._store,(c=a.delete(i)).onerror=function(){n(c.error)},c.onsuccess=function(){u._meta=void 0,u._pageOffset=0,u._pagePtr=0,t()};case 9:case"end":return e.stop()}}),e,this)})))})));case 1:case"end":return t.stop()}}),t)})))}},{key:"exists",value:function(){return void 0!==this._meta}},{key:"_isEOF",get:function(){return this._pagePtr>=this._meta.numPages-1&&this._pageOffset>=this._meta.size%this._pageSize}},{key:"_store",get:function(){return this._db.transaction(T,this._mode).objectStore(T)}}],[{key:"open",value:function(t,e){var n=this;if(!self.indexedDB){var o=new Error("IndexedDB is not supported");throw o.name="IndexedDBNotSupported",o}return new Promise((function(o,i){return c(n,void 0,void 0,s.mark((function n(){var a,c,u;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,O();case 3:a=n.sent,(c=a.transaction(T,"readwrite").objectStore(T).get(t)).onerror=function(){i(c.error)},c.onsuccess=function(){var n=c.result,s=e.includes("r")?"readonly":"readwrite";if(void 0===n&&"readonly"===s){var u=new Error("'".concat(t,"' doesn't exist."));return u.name="FileNotExists",void i(u)}var f=new r(t,n,a,s);e.includes("a")&&f.seek(0,2),o(f)},n.next=12;break;case 9:n.prev=9,n.t0=n.catch(0),"InvalidStateError"===n.t0.name?((u=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",i(u)):i(n.t0);case 12:case"end":return n.stop()}}),n,null,[[0,9]])})))}))}},{key:"createPage",value:function(t){return("000"+t).slice(-4)}}]),r}(k);function I(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x(t);if(e){var o=x(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return b(this,r)}}var N=function(t){w(r,t);var e=I(r);function r(t,n,o,i){var a;return v(this,r),(a=e.call(this))._pos=0,a._path=t,a._meta=n,a._mode=i,a}return E(r,[{key:"close",value:function(){}},{key:"read",value:function(t,e){if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(this._isEOF){var r=new Error("EOF");throw r.name="EndOfFile",r}var n=Math.min(t*e,this._file.length-this._pos),o=n-n%t,i=new Uint8Array(o);return i.set(this._file.slice(this._pos,this._pos+o),0),this._pos+=o,i}},{key:"write",value:function(t){var e=new Uint8Array(this._pos+t.length);void 0!==this._file?(e.set(this._file.slice(0,this._pos)),e.set(t,this._pos)):e.set(t),this._file=e,this._pos+=t.length}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._file.length);else if(1===e)n=Math.min(this._pos+t,this._file.length);else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._file.length+t,this._file.length)}this._pos=n}},{key:"tell",value:function(){return this.exists()?this._pos:-1}},{key:"remove",value:function(){return c(this,void 0,void 0,s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.exists()){t.next=2;break}throw new Error("ENOENT");case 2:r._memFiles.delete(this._path),this._pos=0;case 4:case"end":return t.stop()}}),t,this)})))}},{key:"exists",value:function(){return void 0!==this._file}},{key:"_isEOF",get:function(){return this._pos>=this._file.length}},{key:"_file",get:function(){return r._memFiles.get(this._path)},set:function(t){r._memFiles.set(this._path,t)}}],[{key:"open",value:function(t,e){var n=r._memFiles.get(t),o=e.includes("r")?"readonly":"readwrite";if(void 0===n&&"readonly"===o){var i=new Error("'".concat(t,"' doesn't exist."));throw i.name="FileNotExists",i}var a=new r(t,void 0,void 0,o);return e.includes("a")&&a.seek(0,2),a}}]),r}(k);function M(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return L(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return L(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function B(t,e){for(var r=e;0!==t[r];)r++;return new TextDecoder("utf-8").decode(t.subarray(e,r))}function F(t){for(var e=atob(t),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function R(t){var e,r={},n=M(t.split("\r\n"));try{for(n.s();!(e=n.n()).done;){var o=e.value.split(": ");""!==o[0]&&(r[o[0]]=o[1])}}catch(t){n.e(t)}finally{n.f()}return r}function j(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;return c(this,void 0,void 0,s.mark((function n(){var o,i,a,c;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=new AbortController,i=Object.assign(Object.assign({},e),{signal:o.signal}),a=setTimeout((function(){o.abort()}),r),n.next=5,fetch(t,i);case 5:return c=n.sent,clearTimeout(a),n.abrupt("return",c);case 8:case"end":return n.stop()}}),n)})))}function Y(t,e){return c(this,void 0,void 0,s.mark((function r(){var n;return s.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,A.open(t,e);case 3:return r.abrupt("return",r.sent);case 6:if(r.prev=6,r.t0=r.catch(0),"IndexedDBNotSupported"===r.t0.name?console.warn("IndexedDB is not supported. Fallback to in-memory storage."):"FileNotExists"!==r.t0.name&&console.warn("Unable to access IndexedDB (".concat(r.t0.toString(),"). Fallback to in-memory storage.")),!("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope)){r.next=16;break}if("FileNotExists"!==r.t0.name){r.next=12;break}throw r.t0;case 12:throw console.error("In-memory storage cannot be used inside a worker."),(n=new Error("Failed to start PvFile: ".concat(r.t0.toString()))).name="PvFileNotSupported",n;case 16:return r.abrupt("return",N.open(t,e));case 17:case"end":return r.stop()}}),r,null,[[0,6]])})))}function W(t,e,r,n){return c(this,void 0,void 0,s.mark((function o(){var i;return s.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,Y(t,"w");case 2:if(i=o.sent,!(r||void 0===i.meta||n>i.meta.version)){o.next=6;break}return o.next=6,i.write(F(e),n);case 6:case"end":return o.stop()}}),o)})))}N._memFiles=new Map;var z=5e3,U=2;function D(t,e,r,n,o){return c(this,void 0,void 0,s.mark((function i(){var a,c,u,f,l,p,h,d;return s.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,Y(t,"w");case 2:if(a=i.sent,!(r||void 0===a.meta||n>a.meta.version)){i.next=43;break}if(!(o<0)){i.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:c=U,u=function(t){return new Promise((function(e){setTimeout(e,t)}))},f=o+1,l=null;case 10:if(!(f>0)){i.next=38;break}return l=null,i.prev=12,i.next=15,fetch(e,{cache:"no-cache"});case 15:if(!(p=i.sent).ok){i.next=23;break}return i.next=19,p.arrayBuffer();case 19:return h=i.sent,i.next=22,a.write(new Uint8Array(h),n);case 22:return i.abrupt("return");case 23:return i.next=25,p.text();case 25:d=i.sent,l=new Error("Error response returned while fetching model from '".concat(e,"': ").concat(d)),i.next=32;break;case 29:i.prev=29,i.t0=i.catch(12),l=new Error("Failed to fetch model from '".concat(e,"': ").concat(i.t0.message));case 32:return f--,i.next=35,u(c);case 35:c=Math.min(z,c*U),i.next=10;break;case 38:if(null===l){i.next=42;break}throw l;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(e,"'"));case 43:case"end":return i.stop()}}),i,null,[[12,29]])})))}var C={args_get:function(t){return 0},args_sizes_get:function(t){return 0},environ_get:function(t){return 0},environ_sizes_get:function(t){return 0},clock_res_get:function(t){return 0},clock_time_get:function(t){return 0},fd_advise:function(t){return 0},fd_allocate:function(t){return 0},fd_close:function(t){return 0},fd_datasync:function(t){return 0},fd_fdstat_get:function(t){return 0},fd_fdstat_set_flags:function(t){return 0},fd_fdstat_set_rights:function(t){return 0},fd_filestat_get:function(t){return 0},fd_filestat_set_size:function(t){return 0},fd_filestat_set_times:function(t){return 0},fd_pread:function(t){return 0},fd_prestat_get:function(t){return 0},fd_prestat_dir_name:function(t){return 0},fd_pwrite:function(t){return 0},fd_read:function(t){return 0},fd_readdir:function(t){return 0},fd_renumber:function(t){return 0},fd_seek:function(t){return 0},fd_sync:function(t){return 0},fd_tell:function(t){return 0},fd_write:function(t){return 0},path_create_directory:function(t){return 0},path_filestat_get:function(t){return 0},path_filestat_set_times:function(t){return 0},path_link:function(t){return 0},path_open:function(t){return 0},path_readlink:function(t){return 0},path_remove_directory:function(t){return 0},path_rename:function(t){return 0},path_symlink:function(t){return 0},path_unlink_file:function(t){return 0},poll_oneoff:function(t){return 0},proc_exit:function(t){return 0},proc_raise:function(t){return 0},sched_yield:function(t){return 0},random_get:function(t){return 0},sock_recv:function(t){return 0},sock_send:function(t){return 0},sock_shutdown:function(t){return 0}};function G(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function q(t){return function(t){if(Array.isArray(t))return G(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return G(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)?G(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var H=function(){function t(){v(this,t),this._maxNumErrors=10,this._errors=[],this._lastError=new Error("null")}return E(t,[{key:"addError",value:function(t,e){this._lastError=e instanceof Error?e:new Error(e),this._errors.length>=this._maxNumErrors&&this._errors.shift(),e instanceof Error?this._errors.push({key:t,message:e.toString()}):this._errors.push({key:t,message:JSON.stringify(e)})}},{key:"getErrors",value:function(){var t=q(this._errors);return this._errors=[],t}},{key:"getErrorString",value:function(){return this.getErrors().map((function(t){var e=t.key,r=t.message;return"'".concat(e,"' failed with: ").concat(r,".")})).join("\n")}},{key:"getLastError",value:function(){return this._lastError}},{key:"setMaxErrorNum",value:function(t){this._maxNumErrors=t}}]),t}(),K={DB_NAME:S,DB_VERSION:3,PV_FILE_STORE:T};return t.PvError=H,t.PvFile=k,t.PvFileIDB=A,t.PvFileMem=N,t.arrayBufferToBase64AtIndex=function(t,e,r){for(var n="",o=0;o<e;o++)n+=String.fromCharCode(t[r+o]);return btoa(n)},t.arrayBufferToStringAtIndex=B,t.base64ToUint8Array=F,t.buildWasm=function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return c(this,void 0,void 0,s.mark((function o(){var i,a,u,f,l,p,v,_,y,m,E,g,w,b,x,P,S,T,O,A,I;return s.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(i=new Uint8Array(t.buffer),a=new Int32Array(t.buffer),u=function(t){console.log(B(i,t))},f=function(t,e,r){if(0===t){var n=B(i,r);throw new Error("assertion failed at line ".concat(e,' in "').concat(n,'"'))}},l=function(){return Date.now()/1e3},p=function(t,e,n,o,u,f,l,p,h){return c(this,void 0,void 0,s.mark((function c(){var d,v,_,y,m,E,g,w,b,x,k,P;return s.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return d=B(i,t),v=B(i,e),_=B(i,n),y=B(i,o),m=B(i,u),E=R(y),g={method:d},m.length>0&&(g.body=m),Object.keys(E).length>0&&(g.headers=E),s.prev=9,s.next=12,j("https://"+v+_,g,f);case 12:w=s.sent,x=w.status,s.next=20;break;case 16:return s.prev=16,s.t0=s.catch(9),null==r||r.addError("pvHttpsRequestWasm","Failed to fetch: ".concat(s.t0)),s.abrupt("return");case 20:return s.prev=20,s.next=23,w.text();case 23:b=s.sent,s.next=30;break;case 26:return s.prev=26,s.t1=s.catch(20),null==r||r.addError("pvHttpsRequestWasm","Failed to get response text: ".concat(s.t1)),s.abrupt("return");case 30:return s.next=32,I(Int8Array.BYTES_PER_ELEMENT,(b.length+1)*Int8Array.BYTES_PER_ELEMENT);case 32:if(0!==(k=s.sent)){s.next=37;break}return null==r||r.addError("pvMallocError","pvHttpsRequestWasm: cannot allocate memory for response"),a[l/Int32Array.BYTES_PER_ELEMENT]=0,s.abrupt("return");case 37:for(a[p/Int32Array.BYTES_PER_ELEMENT]=b.length+1,a[l/Int32Array.BYTES_PER_ELEMENT]=k,P=0;P<b.length;P++)i[k+P]=b.charCodeAt(P);i[k+b.length]=0,a[h/Int32Array.BYTES_PER_ELEMENT]=x;case 42:case"end":return s.stop()}}),c,null,[[9,16],[20,26]])})))},v=function(t){return c(this,void 0,void 0,s.mark((function e(){var n,o,c;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=void 0!==navigator.userAgent?navigator.userAgent:"unknown",e.next=3,I(Uint8Array.BYTES_PER_ELEMENT,(n.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 3:if(0!==(o=e.sent)){e.next=8;break}return null==r||r.addError("pvMallocError","pvGetBrowserInfo: cannot allocate memory for browser info"),a[t/Int32Array.BYTES_PER_ELEMENT]=0,e.abrupt("return");case 8:for(a[t/Int32Array.BYTES_PER_ELEMENT]=o,c=0;c<n.length;c++)i[o+c]=n.charCodeAt(c);i[o+n.length]=0;case 11:case"end":return e.stop()}}),e)})))},_=function(t){var e;return c(this,void 0,void 0,s.mark((function n(){var o,c,u,f;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=null!==(e=self.origin)&&void 0!==e?e:self.location.origin,c=new URL(o).hostname,n.next=4,I(Uint8Array.BYTES_PER_ELEMENT,(c.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 4:if(0!==(u=n.sent)){n.next=9;break}return null==r||r.addError("pvMallocError","pvGetOriginInfo: cannot allocate memory for origin info"),a[t/Int32Array.BYTES_PER_ELEMENT]=0,n.abrupt("return");case 9:for(a[t/Int32Array.BYTES_PER_ELEMENT]=u,f=0;f<c.length;f++)i[u+f]=c.charCodeAt(f);i[u+c.length]=0;case 12:case"end":return n.stop()}}),n)})))},y=function(t,e,n,o){return c(this,void 0,void 0,s.mark((function c(){var u,f,l;return s.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return u=B(i,e),f=B(i,n),s.prev=2,s.next=5,Y(u,f);case 5:l=s.sent,k.setPtr(t,l),a[o/Int32Array.BYTES_PER_ELEMENT]=0,s.next=14;break;case 10:s.prev=10,s.t0=s.catch(2),"FileNotExists"!==s.t0.name&&(null==r||r.addError("pvFileOpenWasm",s.t0)),a[o/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return s.stop()}}),c,null,[[2,10]])})))},m=function(t,e){return c(this,void 0,void 0,s.mark((function n(){var o;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,k.getPtr(t);case 3:return o=n.sent,n.next=6,o.close();case 6:a[e/Int32Array.BYTES_PER_ELEMENT]=0,n.next=13;break;case 9:n.prev=9,n.t0=n.catch(0),null==r||r.addError("pvFileCloseWasm",n.t0),a[e/Int32Array.BYTES_PER_ELEMENT]=-1;case 13:case"end":return n.stop()}}),n,null,[[0,9]])})))},E=function(t,e,n,o,u){return c(this,void 0,void 0,s.mark((function c(){var f,l;return s.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.prev=0,s.next=3,k.getPtr(t);case 3:return f=s.sent,s.next=6,f.read(n,o);case 6:l=s.sent,i.set(l,e),a[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,s.next=15;break;case 11:s.prev=11,s.t0=s.catch(0),null==r||r.addError("pvFileReadWasm",s.t0),a[u/Int32Array.BYTES_PER_ELEMENT]=-1;case 15:case"end":return s.stop()}}),c,null,[[0,11]])})))},g=function(t,e,n,o,u){return c(this,void 0,void 0,s.mark((function c(){var f,l;return s.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.prev=0,s.next=3,k.getPtr(t);case 3:return f=s.sent,(l=new Uint8Array(n*o)).set(i.slice(e,e+n*o),0),s.next=8,f.write(l);case 8:a[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,s.next=15;break;case 11:s.prev=11,s.t0=s.catch(0),null==r||r.addError("pvFileWriteWasm",s.t0),a[u/Int32Array.BYTES_PER_ELEMENT]=1;case 15:case"end":return s.stop()}}),c,null,[[0,11]])})))},w=function(t,e,n,o){try{k.getPtr(t).seek(e,n),a[o/Int32Array.BYTES_PER_ELEMENT]=0}catch(t){null==r||r.addError("pvFileSeekWasm",t),a[o/Int32Array.BYTES_PER_ELEMENT]=-1}},b=function(t,e){try{var n=k.getPtr(t);a[e/Int32Array.BYTES_PER_ELEMENT]=n.tell()}catch(t){null==r||r.addError("pvFileTellWasm",t),a[e/Int32Array.BYTES_PER_ELEMENT]=-1}},x=function(t,e){return c(this,void 0,void 0,s.mark((function n(){var o,c;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=B(i,t),n.prev=1,n.next=4,Y(o,"w");case 4:return c=n.sent,n.next=7,c.remove();case 7:a[e/Int32Array.BYTES_PER_ELEMENT]=0,n.next=14;break;case 10:n.prev=10,n.t0=n.catch(1),null==r||r.addError("pvFileRemoveWasm",n.t0),a[e/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return n.stop()}}),n,null,[[1,10]])})))},P={wasi_snapshot_preview1:C,env:Object.assign({memory:t,pv_console_log_wasm:u,pv_assert_wasm:f,pv_time_wasm:l,pv_https_request_wasm:p,pv_get_browser_info:v,pv_get_origin_info:_,pv_file_open_wasm:y,pv_file_close_wasm:m,pv_file_read_wasm:E,pv_file_write_wasm:g,pv_file_seek_wasm:w,pv_file_tell_wasm:b,pv_file_remove_wasm:x},n)},!(e instanceof Promise)){o.next=34;break}if(!d){o.next=23;break}return o.next=20,d(e,P);case 20:S=o.sent.instance,o.next=32;break;case 23:return o.next=25,e;case 25:return T=o.sent,o.next=28,T.arrayBuffer();case 28:return O=o.sent,o.next=31,h(new Uint8Array(O),P);case 31:S=o.sent.instance;case 32:o.next=38;break;case 34:return A=F(e),o.next=37,h(A,P);case 37:S=o.sent.instance;case 38:return I=S.exports.aligned_alloc,o.abrupt("return",S.exports);case 40:case"end":return o.stop()}}),o)})))},t.dbConfig=K,t.fetchWithTimeout=j,t.fromBase64=W,t.fromPublicDirectory=D,t.getDB=O,t.isAccessKeyValid=function(t){if("string"!=typeof t)return!1;var e=t.trim();if(""===e)return!1;try{return btoa(atob(e))===e}catch(t){return!1}},t.loadModel=function(t){return c(this,void 0,void 0,s.mark((function e(){var r,n,o,i,a,c,u,f,l;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new Error("The model is undefined / empty");case 2:if(r=t.base64,n=t.publicPath,o=t.customWritePath,i=t.forceWrite,a=void 0!==i&&i,c=t.version,u=void 0===c?1:c,f=t.numFetchRetries,l=void 0===f?0:f,null!=o){e.next=5;break}throw new Error("The customWritePath of the provided model is undefined / empty");case 5:if(null==r){e.next=10;break}return e.next=8,W(o,r,a,u);case 8:case 13:e.next=16;break;case 10:if(null==n){e.next=15;break}return e.next=13,D(o,n,a,u,l);case 15:throw new Error("The provided model doesn't contain a valid publicPath or base64 value");case 16:return e.abrupt("return",o);case 17:case"end":return e.stop()}}),e)})))},t.open=Y,t.stringHeaderToObject=R,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
var WebUtils=function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r={exports:{}},n={exports:{}};!function(t){function e(r){return t.exports=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},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(n);var o=n.exports;!function(t){var e=o.default;function r(){t.exports=r=function(){return o},t.exports.__esModule=!0,t.exports.default=t.exports;var n,o={},i=Object.prototype,a=i.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",f=c.asyncIterator||"@@asyncIterator",l=c.toStringTag||"@@toStringTag";function p(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{p({},"")}catch(n){p=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,i=Object.create(o.prototype),a=new L(n||[]);return s(i,"_invoke",{value:A(t,r,a)}),i}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}o.wrap=h;var v="suspendedStart",_="suspendedYield",y="executing",m="completed",E={};function g(){}function w(){}function b(){}var x={};p(x,u,(function(){return this}));var k=Object.getPrototypeOf,P=k&&k(k(B([])));P&&P!==i&&a.call(P,u)&&(x=P);var S=b.prototype=g.prototype=Object.create(x);function T(t){["next","throw","return"].forEach((function(e){p(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,r){function n(o,i,s,c){var u=d(t[o],t,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==e(l)&&a.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):r.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;s(this,"_invoke",{value:function(t,e){function i(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(i,i):i()}})}function A(t,e,r){var o=v;return function(i,a){if(o===y)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:n,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var c=I(s,r);if(c){if(c===E)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===v)throw o=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=y;var u=d(t,e,r);if("normal"===u.type){if(o=r.done?m:_,u.arg===E)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=m,r.method="throw",r.arg=u.arg)}}}function I(t,e){var r=e.method,o=t.iterator[r];if(o===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,I(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),E;var i=d(o,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,E;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,E):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,E)}function N(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 M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function B(t){if(t||""===t){var r=t[u];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function e(){for(;++o<t.length;)if(a.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=n,e.done=!0,e};return i.next=i}}throw new TypeError(e(t)+" is not iterable")}return w.prototype=b,s(S,"constructor",{value:b,configurable:!0}),s(b,"constructor",{value:w,configurable:!0}),w.displayName=p(b,l,"GeneratorFunction"),o.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},o.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,p(t,l,"GeneratorFunction")),t.prototype=Object.create(S),t},o.awrap=function(t){return{__await:t}},T(O.prototype),p(O.prototype,f,(function(){return this})),o.AsyncIterator=O,o.async=function(t,e,r,n,i){void 0===i&&(i=Promise);var a=new O(h(t,e,r,n),i);return o.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},T(S),p(S,l,"Generator"),p(S,u,(function(){return this})),p(S,"toString",(function(){return"[object Generator]"})),o.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},o.values=B,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(M),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,o){return s.type="throw",s.arg=t,e.next=r,o&&(e.method="next",e.arg=n),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=a.call(i,"catchLoc"),u=a.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,E):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),E},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),M(r),E}},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 o=n.arg;M(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:B(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),E}},o}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(r);var i=(0,r.exports)(),a=i;try{regeneratorRuntime=i}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}var s=e(a);function c(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))}const u=new WeakMap;function f(t,e){return new Proxy(t,{get:(t,r)=>e(t[r])})}class l{constructor(){this.value=void 0,this.exports=null}getState(){return this.exports.asyncify_get_state()}assertNoneState(){let t=this.getState();if(0!==t)throw new Error(`Invalid async state ${t}, expected 0.`)}wrapImportFn(t){return(...e)=>{if(2===this.getState())return this.exports.asyncify_stop_rewind(),this.value;this.assertNoneState();let r=t(...e);if(!(n=r)||"object"!=typeof n&&"function"!=typeof n||"function"!=typeof n.then)return r;var n;this.exports.asyncify_start_unwind(16),this.value=r}}wrapModuleImports(t){return f(t,(t=>"function"==typeof t?this.wrapImportFn(t):t))}wrapImports(t){if(void 0!==t)return f(t,((t=Object.create(null))=>this.wrapModuleImports(t)))}wrapExportFn(t){let e=u.get(t);return void 0!==e||(e=async(...e)=>{this.assertNoneState();let r=t(...e);for(;1===this.getState();)this.exports.asyncify_stop_unwind(),this.value=await this.value,this.assertNoneState(),this.exports.asyncify_start_rewind(16),r=t();return this.assertNoneState(),r},u.set(t,e)),e}wrapExports(t){let e=Object.create(null);for(let r in t){let n=t[r];"function"!=typeof n||r.startsWith("asyncify_")||(n=this.wrapExportFn(n)),Object.defineProperty(e,r,{enumerable:!0,value:n})}return u.set(t,e),e}init(t,e){const{exports:r}=t,n=r.memory||e.env&&e.env.memory;new Int32Array(n.buffer,16).set([24,1024]),this.exports=this.wrapExports(r),Object.setPrototypeOf(t,p.prototype)}}class p extends WebAssembly.Instance{constructor(t,e){let r=new l;super(t,r.wrapImports(e)),r.init(this,e)}get exports(){return u.get(super.exports)}}async function h(t,e){let r=new l,n=await WebAssembly.instantiate(t,r.wrapImports(e));return r.init(n instanceof WebAssembly.Instance?n:n.instance,e),n}async function d(t,e){let r=new l,n=await WebAssembly.instantiateStreaming(t,r.wrapImports(e));return r.init(n.instance,e),n}function v(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _(t){return _="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},_(t)}function y(t){var e=function(t,e){if("object"!==_(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===_(e)?e:String(e)}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,y(n.key),n)}}function E(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function g(t,e){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},g(t,e)}function w(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&g(t,e)}function b(t,e){if(e&&("object"===_(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(t)}Object.defineProperty(p.prototype,"exports",{enumerable:!0});var k=function(){function t(){v(this,t),this._path=""}return E(t,[{key:"meta",get:function(){if(void 0!==this._meta)return Object.assign({version:0},this._meta)}}],[{key:"getPtr",value:function(e){if(t._filePtrs.has(e))return t._filePtrs.get(e);throw new Error("File instance not found.")}},{key:"setPtr",value:function(e,r){t._filePtrs.set(e,r)}},{key:"removePtr",value:function(e){t._filePtrs.delete(e)}}]),t}();function P(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x(t);if(e){var o=x(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return b(this,r)}}k._filePtrs=new Map;var S="pv_db",T="pv_file";function O(){return new Promise((function(t,e){var r=self.indexedDB.open(S,3);r.onerror=function(){e(r.error)},r.onsuccess=function(){t(r.result)},r.onupgradeneeded=function(){r.result.objectStoreNames.contains(T)||r.result.createObjectStore(T)}}))}var A=function(t){w(r,t);var e=P(r);function r(t,n,o,i){var a;return v(this,r),(a=e.call(this))._pageSize=65536,a._pagePtr=0,a._pageOffset=0,a._path=t,a._meta=n,a._db=o,a._mode=i,a}return E(r,[{key:"close",value:function(){return c(this,void 0,void 0,s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._db.close();case 1:case"end":return t.stop()}}),t,this)})))}},{key:"read",value:function(t,e){return c(this,void 0,void 0,s.mark((function n(){var o=this;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,i){if(o.exists()){if(o._isEOF){var a=new Error("EOF");return a.name="EndOfFile",void i(a)}var s=0,c=Math.min(t*e,o._meta.size),u=c-c%t,f=new Uint8Array(u),l=IDBKeyRange.bound("".concat(o._path,"-").concat(r.createPage(o._pagePtr)),"".concat(o._path,"-").concat(r.createPage(o._meta.numPages))),p=o._store,h=p.openCursor(l);h.onsuccess=function(){var t=h.result;if(t&&!o._isEOF){var e=Math.min(u-s,t.value.length-o._pageOffset);f.set(t.value.slice(o._pageOffset,o._pageOffset+e),s),s+=e,o._pageOffset+=e,o._pageOffset===o._pageSize&&(o._pagePtr+=1,o._pageOffset=0),s<u&&t.continue()}},p.transaction.onerror=function(){i(p.transaction.error)},p.transaction.oncomplete=function(){n(f.slice(0,s))}}else i(new Error("'".concat(o._path,"' doesn't exist.")))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"write",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return c(this,void 0,void 0,s.mark((function n(){var o=this;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,i){return c(o,void 0,void 0,s.mark((function o(){var a,c,u,f,l,p,h,d,v,_=this;return s.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if("readonly"!==this._mode){o.next=3;break}return i(new Error("Instance is readonly mode only.")),o.abrupt("return");case 3:if(!("number"!=typeof e&&e<=0)){o.next=6;break}return i(new Error("Version should be a positive number")),o.abrupt("return");case 6:return a=this._store,c=function(){return new Promise((function(t){var e=a.get("".concat(_._path,"-").concat(r.createPage(_._pagePtr)));e.onsuccess=function(){void 0!==e.result?t(e.result.slice(0,_._pageOffset)):t(new Uint8Array(0))}}))},o.next=10,c();case 10:for(u=o.sent,(f=new Uint8Array(u.length+t.length)).set(u),f.set(t,u.length),l=this._pagePtr*this._pageSize+f.length,p={size:l,numPages:Math.ceil(l/this._pageSize),version:e},a.put(p,this._path),h=Math.ceil(f.length/this._pageSize),d=0;d<h;d++)a.put(f.slice(d*this._pageSize,(d+1)*this._pageSize),"".concat(this._path,"-").concat(r.createPage(this._pagePtr+d)));this.exists()&&p.numPages<this._meta.numPages&&(v=IDBKeyRange.bound("".concat(this._path,"-").concat(r.createPage(p.numPages)),"".concat(this._path,"-").concat(r.createPage(this._meta.numPages)),!0),a.delete(v)),a.transaction.onerror=function(){i(a.transaction.error)},a.transaction.oncomplete=function(){_._meta=p,_.seek(0,2),n()};case 22:case"end":return o.stop()}}),o,this)})))})));case 1:case"end":return n.stop()}}),n)})))}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._meta.size);else if(1===e){var o=this._pageSize*this._pagePtr+this._pageOffset;n=Math.min(o+t,this._meta.size)}else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._meta.size+t,this._meta.size)}this._pageOffset=n%this._pageSize,this._pagePtr=Math.floor(n/this._pageSize)}},{key:"tell",value:function(){return this.exists()?this._pagePtr*this._pageSize+this._pageOffset:-1}},{key:"remove",value:function(){return c(this,void 0,void 0,s.mark((function t(){var e=this;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){return c(e,void 0,void 0,s.mark((function e(){var o,i,a,c,u=this;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.exists()){e.next=3;break}return n(new Error("ENOENT")),e.abrupt("return");case 3:o=this._meta.numPages,i=IDBKeyRange.bound(this._path,"".concat(this._path,"-").concat(r.createPage(o))),a=this._store,(c=a.delete(i)).onerror=function(){n(c.error)},c.onsuccess=function(){u._meta=void 0,u._pageOffset=0,u._pagePtr=0,t()};case 9:case"end":return e.stop()}}),e,this)})))})));case 1:case"end":return t.stop()}}),t)})))}},{key:"exists",value:function(){return void 0!==this._meta}},{key:"_isEOF",get:function(){return this._pagePtr>=this._meta.numPages-1&&this._pageOffset>=this._meta.size%this._pageSize}},{key:"_store",get:function(){return this._db.transaction(T,this._mode).objectStore(T)}}],[{key:"open",value:function(t,e){var n=this;if(!self.indexedDB){var o=new Error("IndexedDB is not supported");throw o.name="IndexedDBNotSupported",o}return new Promise((function(o,i){return c(n,void 0,void 0,s.mark((function n(){var a,c,u;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,O();case 3:a=n.sent,(c=a.transaction(T,"readwrite").objectStore(T).get(t)).onerror=function(){i(c.error)},c.onsuccess=function(){var n=c.result,s=e.includes("r")?"readonly":"readwrite";if(void 0===n&&"readonly"===s){var u=new Error("'".concat(t,"' doesn't exist."));return u.name="FileNotExists",void i(u)}var f=new r(t,n,a,s);e.includes("a")&&f.seek(0,2),o(f)},n.next=12;break;case 9:n.prev=9,n.t0=n.catch(0),"InvalidStateError"===n.t0.name?((u=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",i(u)):i(n.t0);case 12:case"end":return n.stop()}}),n,null,[[0,9]])})))}))}},{key:"createPage",value:function(t){return("00000"+t).slice(-6)}}]),r}(k);function I(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=x(t);if(e){var o=x(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return b(this,r)}}var N=function(t){w(r,t);var e=I(r);function r(t,n,o,i){var a;return v(this,r),(a=e.call(this))._pos=0,a._path=t,a._meta=n,a._mode=i,a}return E(r,[{key:"close",value:function(){}},{key:"read",value:function(t,e){if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(this._isEOF){var r=new Error("EOF");throw r.name="EndOfFile",r}var n=Math.min(t*e,this._file.length-this._pos),o=n-n%t,i=new Uint8Array(o);return i.set(this._file.slice(this._pos,this._pos+o),0),this._pos+=o,i}},{key:"write",value:function(t){var e=new Uint8Array(this._pos+t.length);void 0!==this._file?(e.set(this._file.slice(0,this._pos)),e.set(t,this._pos)):e.set(t),this._file=e,this._pos+=t.length}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._file.length);else if(1===e)n=Math.min(this._pos+t,this._file.length);else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._file.length+t,this._file.length)}this._pos=n}},{key:"tell",value:function(){return this.exists()?this._pos:-1}},{key:"remove",value:function(){return c(this,void 0,void 0,s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.exists()){t.next=2;break}throw new Error("ENOENT");case 2:r._memFiles.delete(this._path),this._pos=0;case 4:case"end":return t.stop()}}),t,this)})))}},{key:"exists",value:function(){return void 0!==this._file}},{key:"_isEOF",get:function(){return this._pos>=this._file.length}},{key:"_file",get:function(){return r._memFiles.get(this._path)},set:function(t){r._memFiles.set(this._path,t)}}],[{key:"open",value:function(t,e){var n=r._memFiles.get(t),o=e.includes("r")?"readonly":"readwrite";if(void 0===n&&"readonly"===o){var i=new Error("'".concat(t,"' doesn't exist."));throw i.name="FileNotExists",i}var a=new r(t,void 0,void 0,o);return e.includes("a")&&a.seek(0,2),a}}]),r}(k);function M(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return L(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return L(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function B(t,e){for(var r=e;0!==t[r];)r++;return new TextDecoder("utf-8").decode(t.subarray(e,r))}function F(t){for(var e=atob(t),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function R(t){var e,r={},n=M(t.split("\r\n"));try{for(n.s();!(e=n.n()).done;){var o=e.value.split(": ");""!==o[0]&&(r[o[0]]=o[1])}}catch(t){n.e(t)}finally{n.f()}return r}function j(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;return c(this,void 0,void 0,s.mark((function n(){var o,i,a,c;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=new AbortController,i=Object.assign(Object.assign({},e),{signal:o.signal}),a=setTimeout((function(){o.abort()}),r),n.next=5,fetch(t,i);case 5:return c=n.sent,clearTimeout(a),n.abrupt("return",c);case 8:case"end":return n.stop()}}),n)})))}function Y(t,e){return c(this,void 0,void 0,s.mark((function r(){var n;return s.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,A.open(t,e);case 3:return r.abrupt("return",r.sent);case 6:if(r.prev=6,r.t0=r.catch(0),"IndexedDBNotSupported"===r.t0.name?console.warn("IndexedDB is not supported. Fallback to in-memory storage."):"FileNotExists"!==r.t0.name&&console.warn("Unable to access IndexedDB (".concat(r.t0.toString(),"). Fallback to in-memory storage.")),!("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope)){r.next=16;break}if("FileNotExists"!==r.t0.name){r.next=12;break}throw r.t0;case 12:throw console.error("In-memory storage cannot be used inside a worker."),(n=new Error("Failed to start PvFile: ".concat(r.t0.toString()))).name="PvFileNotSupported",n;case 16:return r.abrupt("return",N.open(t,e));case 17:case"end":return r.stop()}}),r,null,[[0,6]])})))}function W(t,e,r,n){return c(this,void 0,void 0,s.mark((function o(){var i;return s.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,Y(t,"w");case 2:if(i=o.sent,!(r||void 0===i.meta||n>i.meta.version)){o.next=6;break}return o.next=6,i.write(F(e),n);case 6:case"end":return o.stop()}}),o)})))}N._memFiles=new Map;var z=5e3,U=2;function D(t,e,r,n,o){return c(this,void 0,void 0,s.mark((function i(){var a,c,u,f,l,p,h,d;return s.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,Y(t,"w");case 2:if(a=i.sent,!(r||void 0===a.meta||n>a.meta.version)){i.next=43;break}if(!(o<0)){i.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:c=U,u=function(t){return new Promise((function(e){setTimeout(e,t)}))},f=o+1,l=null;case 10:if(!(f>0)){i.next=38;break}return l=null,i.prev=12,i.next=15,fetch(e,{cache:"no-cache"});case 15:if(!(p=i.sent).ok){i.next=23;break}return i.next=19,p.arrayBuffer();case 19:return h=i.sent,i.next=22,a.write(new Uint8Array(h),n);case 22:return i.abrupt("return");case 23:return i.next=25,p.text();case 25:d=i.sent,l=new Error("Error response returned while fetching model from '".concat(e,"': ").concat(d)),i.next=32;break;case 29:i.prev=29,i.t0=i.catch(12),l=new Error("Failed to fetch model from '".concat(e,"': ").concat(i.t0.message));case 32:return f--,i.next=35,u(c);case 35:c=Math.min(z,c*U),i.next=10;break;case 38:if(null===l){i.next=42;break}throw l;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(e,"'"));case 43:case"end":return i.stop()}}),i,null,[[12,29]])})))}var C={args_get:function(t){return 0},args_sizes_get:function(t){return 0},environ_get:function(t){return 0},environ_sizes_get:function(t){return 0},clock_res_get:function(t){return 0},clock_time_get:function(t){return 0},fd_advise:function(t){return 0},fd_allocate:function(t){return 0},fd_close:function(t){return 0},fd_datasync:function(t){return 0},fd_fdstat_get:function(t){return 0},fd_fdstat_set_flags:function(t){return 0},fd_fdstat_set_rights:function(t){return 0},fd_filestat_get:function(t){return 0},fd_filestat_set_size:function(t){return 0},fd_filestat_set_times:function(t){return 0},fd_pread:function(t){return 0},fd_prestat_get:function(t){return 0},fd_prestat_dir_name:function(t){return 0},fd_pwrite:function(t){return 0},fd_read:function(t){return 0},fd_readdir:function(t){return 0},fd_renumber:function(t){return 0},fd_seek:function(t){return 0},fd_sync:function(t){return 0},fd_tell:function(t){return 0},fd_write:function(t){return 0},path_create_directory:function(t){return 0},path_filestat_get:function(t){return 0},path_filestat_set_times:function(t){return 0},path_link:function(t){return 0},path_open:function(t){return 0},path_readlink:function(t){return 0},path_remove_directory:function(t){return 0},path_rename:function(t){return 0},path_symlink:function(t){return 0},path_unlink_file:function(t){return 0},poll_oneoff:function(t){return 0},proc_exit:function(t){return 0},proc_raise:function(t){return 0},sched_yield:function(t){return 0},random_get:function(t){return 0},sock_recv:function(t){return 0},sock_send:function(t){return 0},sock_shutdown:function(t){return 0}};function G(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function q(t){return function(t){if(Array.isArray(t))return G(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return G(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)?G(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var H=function(){function t(){v(this,t),this._maxNumErrors=10,this._errors=[],this._lastError=new Error("null")}return E(t,[{key:"addError",value:function(t,e){this._lastError=e instanceof Error?e:new Error(e),this._errors.length>=this._maxNumErrors&&this._errors.shift(),e instanceof Error?this._errors.push({key:t,message:e.toString()}):this._errors.push({key:t,message:JSON.stringify(e)})}},{key:"getErrors",value:function(){var t=q(this._errors);return this._errors=[],t}},{key:"getErrorString",value:function(){return this.getErrors().map((function(t){var e=t.key,r=t.message;return"'".concat(e,"' failed with: ").concat(r,".")})).join("\n")}},{key:"getLastError",value:function(){return this._lastError}},{key:"setMaxErrorNum",value:function(t){this._maxNumErrors=t}}]),t}(),K={DB_NAME:S,DB_VERSION:3,PV_FILE_STORE:T};return t.PvError=H,t.PvFile=k,t.PvFileIDB=A,t.PvFileMem=N,t.arrayBufferToBase64AtIndex=function(t,e,r){for(var n="",o=0;o<e;o++)n+=String.fromCharCode(t[r+o]);return btoa(n)},t.arrayBufferToStringAtIndex=B,t.base64ToUint8Array=F,t.buildWasm=function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return c(this,void 0,void 0,s.mark((function o(){var i,a,u,f,l,p,v,_,y,m,E,g,w,b,x,P,S,T,O,A,I;return s.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(i=new Uint8Array(t.buffer),a=new Int32Array(t.buffer),u=function(t){console.log(B(i,t))},f=function(t,e,r){if(0===t){var n=B(i,r);throw new Error("assertion failed at line ".concat(e,' in "').concat(n,'"'))}},l=function(){return Date.now()/1e3},p=function(t,e,n,o,u,f,l,p,h){return c(this,void 0,void 0,s.mark((function c(){var d,v,_,y,m,E,g,w,b,x,k,P;return s.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return d=B(i,t),v=B(i,e),_=B(i,n),y=B(i,o),m=B(i,u),E=R(y),g={method:d},m.length>0&&(g.body=m),Object.keys(E).length>0&&(g.headers=E),s.prev=9,s.next=12,j("https://"+v+_,g,f);case 12:w=s.sent,x=w.status,s.next=20;break;case 16:return s.prev=16,s.t0=s.catch(9),null==r||r.addError("pvHttpsRequestWasm","Failed to fetch: ".concat(s.t0)),s.abrupt("return");case 20:return s.prev=20,s.next=23,w.text();case 23:b=s.sent,s.next=30;break;case 26:return s.prev=26,s.t1=s.catch(20),null==r||r.addError("pvHttpsRequestWasm","Failed to get response text: ".concat(s.t1)),s.abrupt("return");case 30:return s.next=32,I(Int8Array.BYTES_PER_ELEMENT,(b.length+1)*Int8Array.BYTES_PER_ELEMENT);case 32:if(0!==(k=s.sent)){s.next=37;break}return null==r||r.addError("pvMallocError","pvHttpsRequestWasm: cannot allocate memory for response"),a[l/Int32Array.BYTES_PER_ELEMENT]=0,s.abrupt("return");case 37:for(a[p/Int32Array.BYTES_PER_ELEMENT]=b.length+1,a[l/Int32Array.BYTES_PER_ELEMENT]=k,P=0;P<b.length;P++)i[k+P]=b.charCodeAt(P);i[k+b.length]=0,a[h/Int32Array.BYTES_PER_ELEMENT]=x;case 42:case"end":return s.stop()}}),c,null,[[9,16],[20,26]])})))},v=function(t){return c(this,void 0,void 0,s.mark((function e(){var n,o,c;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=void 0!==navigator.userAgent?navigator.userAgent:"unknown",e.next=3,I(Uint8Array.BYTES_PER_ELEMENT,(n.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 3:if(0!==(o=e.sent)){e.next=8;break}return null==r||r.addError("pvMallocError","pvGetBrowserInfo: cannot allocate memory for browser info"),a[t/Int32Array.BYTES_PER_ELEMENT]=0,e.abrupt("return");case 8:for(a[t/Int32Array.BYTES_PER_ELEMENT]=o,c=0;c<n.length;c++)i[o+c]=n.charCodeAt(c);i[o+n.length]=0;case 11:case"end":return e.stop()}}),e)})))},_=function(t){var e;return c(this,void 0,void 0,s.mark((function n(){var o,c,u,f;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=null!==(e=self.origin)&&void 0!==e?e:self.location.origin,c=new URL(o).hostname,n.next=4,I(Uint8Array.BYTES_PER_ELEMENT,(c.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 4:if(0!==(u=n.sent)){n.next=9;break}return null==r||r.addError("pvMallocError","pvGetOriginInfo: cannot allocate memory for origin info"),a[t/Int32Array.BYTES_PER_ELEMENT]=0,n.abrupt("return");case 9:for(a[t/Int32Array.BYTES_PER_ELEMENT]=u,f=0;f<c.length;f++)i[u+f]=c.charCodeAt(f);i[u+c.length]=0;case 12:case"end":return n.stop()}}),n)})))},y=function(t,e,n,o){return c(this,void 0,void 0,s.mark((function c(){var u,f,l;return s.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return u=B(i,e),f=B(i,n),s.prev=2,s.next=5,Y(u,f);case 5:l=s.sent,k.setPtr(t,l),a[o/Int32Array.BYTES_PER_ELEMENT]=0,s.next=14;break;case 10:s.prev=10,s.t0=s.catch(2),"FileNotExists"!==s.t0.name&&(null==r||r.addError("pvFileOpenWasm",s.t0)),a[o/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return s.stop()}}),c,null,[[2,10]])})))},m=function(t,e){return c(this,void 0,void 0,s.mark((function n(){var o;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,k.getPtr(t);case 3:return o=n.sent,n.next=6,o.close();case 6:a[e/Int32Array.BYTES_PER_ELEMENT]=0,n.next=13;break;case 9:n.prev=9,n.t0=n.catch(0),null==r||r.addError("pvFileCloseWasm",n.t0),a[e/Int32Array.BYTES_PER_ELEMENT]=-1;case 13:case"end":return n.stop()}}),n,null,[[0,9]])})))},E=function(t,e,n,o,u){return c(this,void 0,void 0,s.mark((function c(){var f,l;return s.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.prev=0,s.next=3,k.getPtr(t);case 3:return f=s.sent,s.next=6,f.read(n,o);case 6:l=s.sent,i.set(l,e),a[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,s.next=15;break;case 11:s.prev=11,s.t0=s.catch(0),null==r||r.addError("pvFileReadWasm",s.t0),a[u/Int32Array.BYTES_PER_ELEMENT]=-1;case 15:case"end":return s.stop()}}),c,null,[[0,11]])})))},g=function(t,e,n,o,u){return c(this,void 0,void 0,s.mark((function c(){var f,l;return s.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.prev=0,s.next=3,k.getPtr(t);case 3:return f=s.sent,(l=new Uint8Array(n*o)).set(i.slice(e,e+n*o),0),s.next=8,f.write(l);case 8:a[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,s.next=15;break;case 11:s.prev=11,s.t0=s.catch(0),null==r||r.addError("pvFileWriteWasm",s.t0),a[u/Int32Array.BYTES_PER_ELEMENT]=1;case 15:case"end":return s.stop()}}),c,null,[[0,11]])})))},w=function(t,e,n,o){try{k.getPtr(t).seek(e,n),a[o/Int32Array.BYTES_PER_ELEMENT]=0}catch(t){null==r||r.addError("pvFileSeekWasm",t),a[o/Int32Array.BYTES_PER_ELEMENT]=-1}},b=function(t,e){try{var n=k.getPtr(t);a[e/Int32Array.BYTES_PER_ELEMENT]=n.tell()}catch(t){null==r||r.addError("pvFileTellWasm",t),a[e/Int32Array.BYTES_PER_ELEMENT]=-1}},x=function(t,e){return c(this,void 0,void 0,s.mark((function n(){var o,c;return s.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=B(i,t),n.prev=1,n.next=4,Y(o,"w");case 4:return c=n.sent,n.next=7,c.remove();case 7:a[e/Int32Array.BYTES_PER_ELEMENT]=0,n.next=14;break;case 10:n.prev=10,n.t0=n.catch(1),null==r||r.addError("pvFileRemoveWasm",n.t0),a[e/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return n.stop()}}),n,null,[[1,10]])})))},P={wasi_snapshot_preview1:C,env:Object.assign({memory:t,pv_console_log_wasm:u,pv_assert_wasm:f,pv_time_wasm:l,pv_https_request_wasm:p,pv_get_browser_info:v,pv_get_origin_info:_,pv_file_open_wasm:y,pv_file_close_wasm:m,pv_file_read_wasm:E,pv_file_write_wasm:g,pv_file_seek_wasm:w,pv_file_tell_wasm:b,pv_file_remove_wasm:x},n)},!(e instanceof Promise)){o.next=34;break}if(!d){o.next=23;break}return o.next=20,d(e,P);case 20:S=o.sent.instance,o.next=32;break;case 23:return o.next=25,e;case 25:return T=o.sent,o.next=28,T.arrayBuffer();case 28:return O=o.sent,o.next=31,h(new Uint8Array(O),P);case 31:S=o.sent.instance;case 32:o.next=38;break;case 34:return A=F(e),o.next=37,h(A,P);case 37:S=o.sent.instance;case 38:return I=S.exports.aligned_alloc,o.abrupt("return",S.exports);case 40:case"end":return o.stop()}}),o)})))},t.dbConfig=K,t.fetchWithTimeout=j,t.fromBase64=W,t.fromPublicDirectory=D,t.getDB=O,t.isAccessKeyValid=function(t){if("string"!=typeof t)return!1;var e=t.trim();if(""===e)return!1;try{return btoa(atob(e))===e}catch(t){return!1}},t.loadModel=function(t){return c(this,void 0,void 0,s.mark((function e(){var r,n,o,i,a,c,u,f,l;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new Error("The model is undefined / empty");case 2:if(r=t.base64,n=t.publicPath,o=t.customWritePath,i=t.forceWrite,a=void 0!==i&&i,c=t.version,u=void 0===c?1:c,f=t.numFetchRetries,l=void 0===f?0:f,null!=o){e.next=5;break}throw new Error("The customWritePath of the provided model is undefined / empty");case 5:if(null==r){e.next=10;break}return e.next=8,W(o,r,a,u);case 8:case 13:e.next=16;break;case 10:if(null==n){e.next=15;break}return e.next=13,D(o,n,a,u,l);case 15:throw new Error("The provided model doesn't contain a valid publicPath or base64 value");case 16:return e.abrupt("return",o);case 17:case"end":return e.stop()}}),e)})))},t.open=Y,t.stringHeaderToObject=R,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); |
{ | ||
"name": "@picovoice/web-utils", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Picovoice web utility functions", | ||
@@ -5,0 +5,0 @@ "author": "Picovoice", |
@@ -358,3 +358,3 @@ /* | ||
private static createPage(page: number) { | ||
return ("000" + page).slice(-4); | ||
return ("00000" + page).slice(-6); | ||
} | ||
@@ -361,0 +361,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
349842