@picovoice/rhino-react
Version:
React component for Rhino Web SDK
1 lines • 3.12 MB
JavaScript
import{useRef as A,useState as I,useCallback as g,useEffect as C}from"react";import{WebVoiceProcessor as B}from"@picovoice/web-voice-processor";function c(A){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},c(A)}function l(A){var I=function(A,I){if("object"!==c(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==c(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===c(I)?I:String(I)}function d(A,I,g,C,B,c,l){try{var d=A[c](l),Z=d.value}catch(A){return void g(A)}d.done?I(Z):Promise.resolve(Z).then(C,B)}function Z(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var c=A.apply(I,g);function l(A){d(c,C,B,l,Z,"next",A)}function Z(A){d(c,C,B,l,Z,"throw",A)}l(void 0)}))}}function i(A,I){(null==I||I>A.length)&&(I=A.length);for(var g=0,C=new Array(I);g<I;g++)C[g]=A[g];return C}function b(A,I){return function(A){if(Array.isArray(A))return A}(A)||function(A,I){var g=null==A?null:"undefined"!=typeof Symbol&&A[Symbol.iterator]||A["@@iterator"];if(null!=g){var C,B,c,l,d=[],Z=!0,i=!1;try{if(c=(g=g.call(A)).next,0===I){if(Object(g)!==g)return;Z=!1}else for(;!(Z=(C=c.call(g)).done)&&(d.push(C.value),d.length!==I);Z=!0);}catch(A){i=!0,B=A}finally{try{if(!Z&&null!=g.return&&(l=g.return(),Object(l)!==l))return}finally{if(i)throw B}}return d}}(A,I)||function(A,I){if(A){if("string"==typeof A)return i(A,I);var g=Object.prototype.toString.call(A).slice(8,-1);return"Object"===g&&A.constructor&&(g=A.constructor.name),"Map"===g||"Set"===g?Array.from(A):"Arguments"===g||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(g)?i(A,I):void 0}}(A,I)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function G(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var X={exports:{}},Q={exports:{}};!function(A){function I(g){return A.exports=I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},A.exports.__esModule=!0,A.exports.default=A.exports,I(g)}A.exports=I,A.exports.__esModule=!0,A.exports.default=A.exports}(Q);var m=Q.exports;!function(A){var I=m.default;function g(){A.exports=g=function(){return B},A.exports.__esModule=!0,A.exports.default=A.exports;var C,B={},c=Object.prototype,l=c.hasOwnProperty,d=Object.defineProperty||function(A,I,g){A[I]=g.value},Z="function"==typeof Symbol?Symbol:{},i=Z.iterator||"@@iterator",b=Z.asyncIterator||"@@asyncIterator",G=Z.toStringTag||"@@toStringTag";function X(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{X({},"")}catch(C){X=function(A,I,g){return A[I]=g}}function Q(A,I,g,C){var B=I&&I.prototype instanceof V?I:V,c=Object.create(B.prototype),l=new w(C||[]);return d(c,"_invoke",{value:e(A,g,l)}),c}function m(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=Q;var a="suspendedStart",y="suspendedYield",n="executing",s="completed",o={};function V(){}function R(){}function E(){}var t={};X(t,i,(function(){return this}));var W=Object.getPrototypeOf,h=W&&W(W(p([])));h&&h!==c&&l.call(h,i)&&(t=h);var Y=E.prototype=V.prototype=Object.create(t);function F(A){["next","throw","return"].forEach((function(I){X(A,I,(function(A){return this._invoke(I,A)}))}))}function u(A,g){function C(B,c,d,Z){var i=m(A[B],A,c);if("throw"!==i.type){var b=i.arg,G=b.value;return G&&"object"==I(G)&&l.call(G,"__await")?g.resolve(G.__await).then((function(A){C("next",A,d,Z)}),(function(A){C("throw",A,d,Z)})):g.resolve(G).then((function(A){b.value=A,d(b)}),(function(A){return C("throw",A,d,Z)}))}Z(i.arg)}var B;d(this,"_invoke",{value:function(A,I){function c(){return new g((function(g,B){C(A,I,g,B)}))}return B=B?B.then(c,c):c()}})}function e(A,I,g){var B=a;return function(c,l){if(B===n)throw new Error("Generator is already running");if(B===s){if("throw"===c)throw l;return{value:C,done:!0}}for(g.method=c,g.arg=l;;){var d=g.delegate;if(d){var Z=J(d,g);if(Z){if(Z===o)continue;return Z}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===a)throw B=s,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=n;var i=m(A,I,g);if("normal"===i.type){if(B=g.done?s:y,i.arg===o)continue;return{value:i.arg,done:g.done}}"throw"===i.type&&(B=s,g.method="throw",g.arg=i.arg)}}}function J(A,I){var g=I.method,B=A.iterator[g];if(B===C)return I.delegate=null,"throw"===g&&A.iterator.return&&(I.method="return",I.arg=C,J(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),o;var c=m(B,A.iterator,I.arg);if("throw"===c.type)return I.method="throw",I.arg=c.arg,I.delegate=null,o;var l=c.arg;return l?l.done?(I[A.resultName]=l.value,I.next=A.nextLoc,"return"!==I.method&&(I.method="next",I.arg=C),I.delegate=null,o):l:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,o)}function H(A){var I={tryLoc:A[0]};1 in A&&(I.catchLoc=A[1]),2 in A&&(I.finallyLoc=A[2],I.afterLoc=A[3]),this.tryEntries.push(I)}function N(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function w(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(H,this),this.reset(!0)}function p(A){if(A||""===A){var g=A[i];if(g)return g.call(A);if("function"==typeof A.next)return A;if(!isNaN(A.length)){var B=-1,c=function I(){for(;++B<A.length;)if(l.call(A,B))return I.value=A[B],I.done=!1,I;return I.value=C,I.done=!0,I};return c.next=c}}throw new TypeError(I(A)+" is not iterable")}return R.prototype=E,d(Y,"constructor",{value:E,configurable:!0}),d(E,"constructor",{value:R,configurable:!0}),R.displayName=X(E,G,"GeneratorFunction"),B.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===R||"GeneratorFunction"===(I.displayName||I.name))},B.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,E):(A.__proto__=E,X(A,G,"GeneratorFunction")),A.prototype=Object.create(Y),A},B.awrap=function(A){return{__await:A}},F(u.prototype),X(u.prototype,b,(function(){return this})),B.AsyncIterator=u,B.async=function(A,I,g,C,c){void 0===c&&(c=Promise);var l=new u(Q(A,I,g,C),c);return B.isGeneratorFunction(I)?l:l.next().then((function(A){return A.done?A.value:l.next()}))},F(Y),X(Y,G,"Generator"),X(Y,i,(function(){return this})),X(Y,"toString",(function(){return"[object Generator]"})),B.keys=function(A){var I=Object(A),g=[];for(var C in I)g.push(C);return g.reverse(),function A(){for(;g.length;){var C=g.pop();if(C in I)return A.value=C,A.done=!1,A}return A.done=!0,A}},B.values=p,w.prototype={constructor:w,reset:function(A){if(this.prev=0,this.next=0,this.sent=this._sent=C,this.done=!1,this.delegate=null,this.method="next",this.arg=C,this.tryEntries.forEach(N),!A)for(var I in this)"t"===I.charAt(0)&&l.call(this,I)&&!isNaN(+I.slice(1))&&(this[I]=C)},stop:function(){this.done=!0;var A=this.tryEntries[0].completion;if("throw"===A.type)throw A.arg;return this.rval},dispatchException:function(A){if(this.done)throw A;var I=this;function g(g,B){return d.type="throw",d.arg=A,I.next=g,B&&(I.method="next",I.arg=C),!!B}for(var B=this.tryEntries.length-1;B>=0;--B){var c=this.tryEntries[B],d=c.completion;if("root"===c.tryLoc)return g("end");if(c.tryLoc<=this.prev){var Z=l.call(c,"catchLoc"),i=l.call(c,"finallyLoc");if(Z&&i){if(this.prev<c.catchLoc)return g(c.catchLoc,!0);if(this.prev<c.finallyLoc)return g(c.finallyLoc)}else if(Z){if(this.prev<c.catchLoc)return g(c.catchLoc,!0)}else{if(!i)throw new Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return g(c.finallyLoc)}}}},abrupt:function(A,I){for(var g=this.tryEntries.length-1;g>=0;--g){var C=this.tryEntries[g];if(C.tryLoc<=this.prev&&l.call(C,"finallyLoc")&&this.prev<C.finallyLoc){var B=C;break}}B&&("break"===A||"continue"===A)&&B.tryLoc<=I&&I<=B.finallyLoc&&(B=null);var c=B?B.completion:{};return c.type=A,c.arg=I,B?(this.method="next",this.next=B.finallyLoc,o):this.complete(c)},complete:function(A,I){if("throw"===A.type)throw A.arg;return"break"===A.type||"continue"===A.type?this.next=A.arg:"return"===A.type?(this.rval=this.arg=A.arg,this.method="return",this.next="end"):"normal"===A.type&&I&&(this.next=I),o},finish:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.finallyLoc===A)return this.complete(g.completion,g.afterLoc),N(g),o}},catch:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.tryLoc===A){var C=g.completion;if("throw"===C.type){var B=C.arg;N(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:p(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=C),o}},B}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(X);var a=(0,X.exports)(),y=a;try{regeneratorRuntime=a}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=a:Function("r","regeneratorRuntime = r")(a)}var n=G(y);function s(A,I,g,C,B,c,l){try{var d=A[c](l),Z=d.value}catch(A){return void g(A)}d.done?I(Z):Promise.resolve(Z).then(C,B)}function o(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var c=A.apply(I,g);function l(A){s(c,C,B,l,d,"next",A)}function d(A){s(c,C,B,l,d,"throw",A)}l(void 0)}))}}function V(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")}function R(A){return R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},R(A)}function E(A){var I=function(A,I){if("object"!==R(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==R(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===R(I)?I:String(I)}function t(A,I){for(var g=0;g<I.length;g++){var C=I[g];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(A,E(C.key),C)}}function W(A,I,g){return I&&t(A.prototype,I),g&&t(A,g),Object.defineProperty(A,"prototype",{writable:!1}),A}function h(A,I,g){return(I=E(I))in A?Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}):A[I]=g,A}function Y(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var F={exports:{}},u={exports:{}};!function(A){function I(g){return A.exports=I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},A.exports.__esModule=!0,A.exports.default=A.exports,I(g)}A.exports=I,A.exports.__esModule=!0,A.exports.default=A.exports}(u);var e=u.exports;!function(A){var I=e.default;function g(){A.exports=g=function(){return B},A.exports.__esModule=!0,A.exports.default=A.exports;var C,B={},c=Object.prototype,l=c.hasOwnProperty,d=Object.defineProperty||function(A,I,g){A[I]=g.value},Z="function"==typeof Symbol?Symbol:{},i=Z.iterator||"@@iterator",b=Z.asyncIterator||"@@asyncIterator",G=Z.toStringTag||"@@toStringTag";function X(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{X({},"")}catch(C){X=function(A,I,g){return A[I]=g}}function Q(A,I,g,C){var B=I&&I.prototype instanceof V?I:V,c=Object.create(B.prototype),l=new w(C||[]);return d(c,"_invoke",{value:e(A,g,l)}),c}function m(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=Q;var a="suspendedStart",y="suspendedYield",n="executing",s="completed",o={};function V(){}function R(){}function E(){}var t={};X(t,i,(function(){return this}));var W=Object.getPrototypeOf,h=W&&W(W(p([])));h&&h!==c&&l.call(h,i)&&(t=h);var Y=E.prototype=V.prototype=Object.create(t);function F(A){["next","throw","return"].forEach((function(I){X(A,I,(function(A){return this._invoke(I,A)}))}))}function u(A,g){function C(B,c,d,Z){var i=m(A[B],A,c);if("throw"!==i.type){var b=i.arg,G=b.value;return G&&"object"==I(G)&&l.call(G,"__await")?g.resolve(G.__await).then((function(A){C("next",A,d,Z)}),(function(A){C("throw",A,d,Z)})):g.resolve(G).then((function(A){b.value=A,d(b)}),(function(A){return C("throw",A,d,Z)}))}Z(i.arg)}var B;d(this,"_invoke",{value:function(A,I){function c(){return new g((function(g,B){C(A,I,g,B)}))}return B=B?B.then(c,c):c()}})}function e(A,I,g){var B=a;return function(c,l){if(B===n)throw new Error("Generator is already running");if(B===s){if("throw"===c)throw l;return{value:C,done:!0}}for(g.method=c,g.arg=l;;){var d=g.delegate;if(d){var Z=J(d,g);if(Z){if(Z===o)continue;return Z}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===a)throw B=s,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=n;var i=m(A,I,g);if("normal"===i.type){if(B=g.done?s:y,i.arg===o)continue;return{value:i.arg,done:g.done}}"throw"===i.type&&(B=s,g.method="throw",g.arg=i.arg)}}}function J(A,I){var g=I.method,B=A.iterator[g];if(B===C)return I.delegate=null,"throw"===g&&A.iterator.return&&(I.method="return",I.arg=C,J(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),o;var c=m(B,A.iterator,I.arg);if("throw"===c.type)return I.method="throw",I.arg=c.arg,I.delegate=null,o;var l=c.arg;return l?l.done?(I[A.resultName]=l.value,I.next=A.nextLoc,"return"!==I.method&&(I.method="next",I.arg=C),I.delegate=null,o):l:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,o)}function H(A){var I={tryLoc:A[0]};1 in A&&(I.catchLoc=A[1]),2 in A&&(I.finallyLoc=A[2],I.afterLoc=A[3]),this.tryEntries.push(I)}function N(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function w(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(H,this),this.reset(!0)}function p(A){if(A||""===A){var g=A[i];if(g)return g.call(A);if("function"==typeof A.next)return A;if(!isNaN(A.length)){var B=-1,c=function I(){for(;++B<A.length;)if(l.call(A,B))return I.value=A[B],I.done=!1,I;return I.value=C,I.done=!0,I};return c.next=c}}throw new TypeError(I(A)+" is not iterable")}return R.prototype=E,d(Y,"constructor",{value:E,configurable:!0}),d(E,"constructor",{value:R,configurable:!0}),R.displayName=X(E,G,"GeneratorFunction"),B.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===R||"GeneratorFunction"===(I.displayName||I.name))},B.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,E):(A.__proto__=E,X(A,G,"GeneratorFunction")),A.prototype=Object.create(Y),A},B.awrap=function(A){return{__await:A}},F(u.prototype),X(u.prototype,b,(function(){return this})),B.AsyncIterator=u,B.async=function(A,I,g,C,c){void 0===c&&(c=Promise);var l=new u(Q(A,I,g,C),c);return B.isGeneratorFunction(I)?l:l.next().then((function(A){return A.done?A.value:l.next()}))},F(Y),X(Y,G,"Generator"),X(Y,i,(function(){return this})),X(Y,"toString",(function(){return"[object Generator]"})),B.keys=function(A){var I=Object(A),g=[];for(var C in I)g.push(C);return g.reverse(),function A(){for(;g.length;){var C=g.pop();if(C in I)return A.value=C,A.done=!1,A}return A.done=!0,A}},B.values=p,w.prototype={constructor:w,reset:function(A){if(this.prev=0,this.next=0,this.sent=this._sent=C,this.done=!1,this.delegate=null,this.method="next",this.arg=C,this.tryEntries.forEach(N),!A)for(var I in this)"t"===I.charAt(0)&&l.call(this,I)&&!isNaN(+I.slice(1))&&(this[I]=C)},stop:function(){this.done=!0;var A=this.tryEntries[0].completion;if("throw"===A.type)throw A.arg;return this.rval},dispatchException:function(A){if(this.done)throw A;var I=this;function g(g,B){return d.type="throw",d.arg=A,I.next=g,B&&(I.method="next",I.arg=C),!!B}for(var B=this.tryEntries.length-1;B>=0;--B){var c=this.tryEntries[B],d=c.completion;if("root"===c.tryLoc)return g("end");if(c.tryLoc<=this.prev){var Z=l.call(c,"catchLoc"),i=l.call(c,"finallyLoc");if(Z&&i){if(this.prev<c.catchLoc)return g(c.catchLoc,!0);if(this.prev<c.finallyLoc)return g(c.finallyLoc)}else if(Z){if(this.prev<c.catchLoc)return g(c.catchLoc,!0)}else{if(!i)throw new Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return g(c.finallyLoc)}}}},abrupt:function(A,I){for(var g=this.tryEntries.length-1;g>=0;--g){var C=this.tryEntries[g];if(C.tryLoc<=this.prev&&l.call(C,"finallyLoc")&&this.prev<C.finallyLoc){var B=C;break}}B&&("break"===A||"continue"===A)&&B.tryLoc<=I&&I<=B.finallyLoc&&(B=null);var c=B?B.completion:{};return c.type=A,c.arg=I,B?(this.method="next",this.next=B.finallyLoc,o):this.complete(c)},complete:function(A,I){if("throw"===A.type)throw A.arg;return"break"===A.type||"continue"===A.type?this.next=A.arg:"return"===A.type?(this.rval=this.arg=A.arg,this.method="return",this.next="end"):"normal"===A.type&&I&&(this.next=I),o},finish:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.finallyLoc===A)return this.complete(g.completion,g.afterLoc),N(g),o}},catch:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.tryLoc===A){var C=g.completion;if("throw"===C.type){var B=C.arg;N(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:p(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=C),o}},B}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(F);var J=(0,F.exports)(),H=J;try{regeneratorRuntime=J}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=J:Function("r","regeneratorRuntime = r")(J)}var N=Y(H);const w=new Error("request for lock canceled");var p=function(A,I,g,C){return new(g||(g=Promise))((function(B,c){function l(A){try{Z(C.next(A))}catch(A){c(A)}}function d(A){try{Z(C.throw(A))}catch(A){c(A)}}function Z(A){var I;A.done?B(A.value):(I=A.value,I instanceof g?I:new g((function(A){A(I)}))).then(l,d)}Z((C=C.apply(A,I||[])).next())}))};class S{constructor(A,I=w){this._value=A,this._cancelError=I,this._weightedQueues=[],this._weightedWaiters=[]}acquire(A=1){if(A<=0)throw new Error(`invalid weight ${A}: must be positive`);return new Promise(((I,g)=>{this._weightedQueues[A-1]||(this._weightedQueues[A-1]=[]),this._weightedQueues[A-1].push({resolve:I,reject:g}),this._dispatch()}))}runExclusive(A,I=1){return p(this,void 0,void 0,(function*(){const[g,C]=yield this.acquire(I);try{return yield A(g)}finally{C()}}))}waitForUnlock(A=1){if(A<=0)throw new Error(`invalid weight ${A}: must be positive`);return new Promise((I=>{this._weightedWaiters[A-1]||(this._weightedWaiters[A-1]=[]),this._weightedWaiters[A-1].push(I),this._dispatch()}))}isLocked(){return this._value<=0}getValue(){return this._value}setValue(A){this._value=A,this._dispatch()}release(A=1){if(A<=0)throw new Error(`invalid weight ${A}: must be positive`);this._value+=A,this._dispatch()}cancel(){this._weightedQueues.forEach((A=>A.forEach((A=>A.reject(this._cancelError))))),this._weightedQueues=[]}_dispatch(){var A;for(let I=this._value;I>0;I--){const g=null===(A=this._weightedQueues[I-1])||void 0===A?void 0:A.shift();if(!g)continue;const C=this._value,B=I;this._value-=I,I=this._value+1,g.resolve([C,this._newReleaser(B)])}this._drainUnlockWaiters()}_newReleaser(A){let I=!1;return()=>{I||(I=!0,this.release(A))}}_drainUnlockWaiters(){for(let A=this._value;A>0;A--)this._weightedWaiters[A-1]&&(this._weightedWaiters[A-1].forEach((A=>A())),this._weightedWaiters[A-1]=[])}}var k=function(A,I,g,C){return new(g||(g=Promise))((function(B,c){function l(A){try{Z(C.next(A))}catch(A){c(A)}}function d(A){try{Z(C.throw(A))}catch(A){c(A)}}function Z(A){var I;A.done?B(A.value):(I=A.value,I instanceof g?I:new g((function(A){A(I)}))).then(l,d)}Z((C=C.apply(A,I||[])).next())}))};class M{constructor(A){this._semaphore=new S(1,A)}acquire(){return k(this,void 0,void 0,(function*(){const[,A]=yield this._semaphore.acquire();return A}))}runExclusive(A){return this._semaphore.runExclusive((()=>A()))}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}function U(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var K={exports:{}},r={exports:{}};!function(A){function I(g){return A.exports=I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},A.exports.__esModule=!0,A.exports.default=A.exports,I(g)}A.exports=I,A.exports.__esModule=!0,A.exports.default=A.exports}(r);var x=r.exports;!function(A){var I=x.default;function g(){A.exports=g=function(){return B},A.exports.__esModule=!0,A.exports.default=A.exports;var C,B={},c=Object.prototype,l=c.hasOwnProperty,d=Object.defineProperty||function(A,I,g){A[I]=g.value},Z="function"==typeof Symbol?Symbol:{},i=Z.iterator||"@@iterator",b=Z.asyncIterator||"@@asyncIterator",G=Z.toStringTag||"@@toStringTag";function X(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{X({},"")}catch(C){X=function(A,I,g){return A[I]=g}}function Q(A,I,g,C){var B=I&&I.prototype instanceof V?I:V,c=Object.create(B.prototype),l=new w(C||[]);return d(c,"_invoke",{value:e(A,g,l)}),c}function m(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=Q;var a="suspendedStart",y="suspendedYield",n="executing",s="completed",o={};function V(){}function R(){}function E(){}var t={};X(t,i,(function(){return this}));var W=Object.getPrototypeOf,h=W&&W(W(p([])));h&&h!==c&&l.call(h,i)&&(t=h);var Y=E.prototype=V.prototype=Object.create(t);function F(A){["next","throw","return"].forEach((function(I){X(A,I,(function(A){return this._invoke(I,A)}))}))}function u(A,g){function C(B,c,d,Z){var i=m(A[B],A,c);if("throw"!==i.type){var b=i.arg,G=b.value;return G&&"object"==I(G)&&l.call(G,"__await")?g.resolve(G.__await).then((function(A){C("next",A,d,Z)}),(function(A){C("throw",A,d,Z)})):g.resolve(G).then((function(A){b.value=A,d(b)}),(function(A){return C("throw",A,d,Z)}))}Z(i.arg)}var B;d(this,"_invoke",{value:function(A,I){function c(){return new g((function(g,B){C(A,I,g,B)}))}return B=B?B.then(c,c):c()}})}function e(A,I,g){var B=a;return function(c,l){if(B===n)throw new Error("Generator is already running");if(B===s){if("throw"===c)throw l;return{value:C,done:!0}}for(g.method=c,g.arg=l;;){var d=g.delegate;if(d){var Z=J(d,g);if(Z){if(Z===o)continue;return Z}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===a)throw B=s,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=n;var i=m(A,I,g);if("normal"===i.type){if(B=g.done?s:y,i.arg===o)continue;return{value:i.arg,done:g.done}}"throw"===i.type&&(B=s,g.method="throw",g.arg=i.arg)}}}function J(A,I){var g=I.method,B=A.iterator[g];if(B===C)return I.delegate=null,"throw"===g&&A.iterator.return&&(I.method="return",I.arg=C,J(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),o;var c=m(B,A.iterator,I.arg);if("throw"===c.type)return I.method="throw",I.arg=c.arg,I.delegate=null,o;var l=c.arg;return l?l.done?(I[A.resultName]=l.value,I.next=A.nextLoc,"return"!==I.method&&(I.method="next",I.arg=C),I.delegate=null,o):l:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,o)}function H(A){var I={tryLoc:A[0]};1 in A&&(I.catchLoc=A[1]),2 in A&&(I.finallyLoc=A[2],I.afterLoc=A[3]),this.tryEntries.push(I)}function N(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function w(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(H,this),this.reset(!0)}function p(A){if(A||""===A){var g=A[i];if(g)return g.call(A);if("function"==typeof A.next)return A;if(!isNaN(A.length)){var B=-1,c=function I(){for(;++B<A.length;)if(l.call(A,B))return I.value=A[B],I.done=!1,I;return I.value=C,I.done=!0,I};return c.next=c}}throw new TypeError(I(A)+" is not iterable")}return R.prototype=E,d(Y,"constructor",{value:E,configurable:!0}),d(E,"constructor",{value:R,configurable:!0}),R.displayName=X(E,G,"GeneratorFunction"),B.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===R||"GeneratorFunction"===(I.displayName||I.name))},B.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,E):(A.__proto__=E,X(A,G,"GeneratorFunction")),A.prototype=Object.create(Y),A},B.awrap=function(A){return{__await:A}},F(u.prototype),X(u.prototype,b,(function(){return this})),B.AsyncIterator=u,B.async=function(A,I,g,C,c){void 0===c&&(c=Promise);var l=new u(Q(A,I,g,C),c);return B.isGeneratorFunction(I)?l:l.next().then((function(A){return A.done?A.value:l.next()}))},F(Y),X(Y,G,"Generator"),X(Y,i,(function(){return this})),X(Y,"toString",(function(){return"[object Generator]"})),B.keys=function(A){var I=Object(A),g=[];for(var C in I)g.push(C);return g.reverse(),function A(){for(;g.length;){var C=g.pop();if(C in I)return A.value=C,A.done=!1,A}return A.done=!0,A}},B.values=p,w.prototype={constructor:w,reset:function(A){if(this.prev=0,this.next=0,this.sent=this._sent=C,this.done=!1,this.delegate=null,this.method="next",this.arg=C,this.tryEntries.forEach(N),!A)for(var I in this)"t"===I.charAt(0)&&l.call(this,I)&&!isNaN(+I.slice(1))&&(this[I]=C)},stop:function(){this.done=!0;var A=this.tryEntries[0].completion;if("throw"===A.type)throw A.arg;return this.rval},dispatchException:function(A){if(this.done)throw A;var I=this;function g(g,B){return d.type="throw",d.arg=A,I.next=g,B&&(I.method="next",I.arg=C),!!B}for(var B=this.tryEntries.length-1;B>=0;--B){var c=this.tryEntries[B],d=c.completion;if("root"===c.tryLoc)return g("end");if(c.tryLoc<=this.prev){var Z=l.call(c,"catchLoc"),i=l.call(c,"finallyLoc");if(Z&&i){if(this.prev<c.catchLoc)return g(c.catchLoc,!0);if(this.prev<c.finallyLoc)return g(c.finallyLoc)}else if(Z){if(this.prev<c.catchLoc)return g(c.catchLoc,!0)}else{if(!i)throw new Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return g(c.finallyLoc)}}}},abrupt:function(A,I){for(var g=this.tryEntries.length-1;g>=0;--g){var C=this.tryEntries[g];if(C.tryLoc<=this.prev&&l.call(C,"finallyLoc")&&this.prev<C.finallyLoc){var B=C;break}}B&&("break"===A||"continue"===A)&&B.tryLoc<=I&&I<=B.finallyLoc&&(B=null);var c=B?B.completion:{};return c.type=A,c.arg=I,B?(this.method="next",this.next=B.finallyLoc,o):this.complete(c)},complete:function(A,I){if("throw"===A.type)throw A.arg;return"break"===A.type||"continue"===A.type?this.next=A.arg:"return"===A.type?(this.rval=this.arg=A.arg,this.method="return",this.next="end"):"normal"===A.type&&I&&(this.next=I),o},finish:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.finallyLoc===A)return this.complete(g.completion,g.afterLoc),N(g),o}},catch:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.tryLoc===A){var C=g.completion;if("throw"===C.type){var B=C.arg;N(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:p(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=C),o}},B}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(K);var z=(0,K.exports)(),D=z;try{regeneratorRuntime=z}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=z:Function("r","regeneratorRuntime = r")(z)}var f=U(D);function v(A,I,g,C){return new(g||(g=Promise))((function(B,c){function l(A){try{Z(C.next(A))}catch(A){c(A)}}function d(A){try{Z(C.throw(A))}catch(A){c(A)}}function Z(A){var I;A.done?B(A.value):(I=A.value,I instanceof g?I:new g((function(A){A(I)}))).then(l,d)}Z((C=C.apply(A,I||[])).next())}))}function j(A,I){return j=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(A,I){return A.__proto__=I,A},j(A,I)}function L(A,I){if("function"!=typeof I&&null!==I)throw new TypeError("Super expression must either be null or a function");A.prototype=Object.create(I&&I.prototype,{constructor:{value:A,writable:!0,configurable:!0}}),Object.defineProperty(A,"prototype",{writable:!1}),I&&j(A,I)}function T(A){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},T(A)}function O(A,I){if(I&&("object"===T(I)||"function"==typeof I))return I;if(void 0!==I)throw new TypeError("Derived constructors may only return object or undefined");return function(A){if(void 0===A)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return A}(A)}function P(A){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(A){return A.__proto__||Object.getPrototypeOf(A)},P(A)}function _(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")}function q(A){var I=function(A,I){if("object"!==T(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==T(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===T(I)?I:String(I)}function $(A,I){for(var g=0;g<I.length;g++){var C=I[g];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(A,q(C.key),C)}}function AA(A,I,g){return I&&$(A.prototype,I),g&&$(A,g),Object.defineProperty(A,"prototype",{writable:!1}),A}var IA=function(){function A(){_(this,A),this._path=""}return AA(A,[{key:"meta",get:function(){if(void 0!==this._meta)return Object.assign({version:0},this._meta)}},{key:"pageSize",get:function(){}}],[{key:"getPtr",value:function(I){if(A._filePtrs.has(I))return A._filePtrs.get(I);throw new Error("File instance not found.")}},{key:"setPtr",value:function(I,g){A._filePtrs.set(I,g)}},{key:"removePtr",value:function(I){A._filePtrs.delete(I)}}]),A}();function gA(A){var I=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(A){return!1}}();return function(){var g,C=P(A);if(I){var B=P(this).constructor;g=Reflect.construct(C,arguments,B)}else g=C.apply(this,arguments);return O(this,g)}}IA._filePtrs=new Map;var CA="pv_file";var BA=function(){function A(){_(this,A),this._pos=0,this._data=new Uint8Array}return AA(A,[{key:"get",value:function(A){if(!(this._pos>=this._data.length)){var I=this._data.slice(this._pos,this._pos+A);return this._pos+=A,I}}},{key:"set",value:function(A,I){this._pos=A,this._data=I}},{key:"clear",value:function(){this._pos=0,this._data=new Uint8Array}}]),A}(),cA=function(A){L(g,IA);var I=gA(g);function g(A,C,B,c){var l;return _(this,g),(l=I.call(this))._pageSize=524288,l._pagePtr=0,l._pageOffset=0,l._path=A,l._meta=C,l._db=B,l._mode=c,l._cache=new BA,l}return AA(g,[{key:"pageSize",get:function(){return this._pageSize}},{key:"close",value:function(){return v(this,void 0,void 0,f.mark((function A(){return f.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:this._db.close();case 1:case"end":return A.stop()}}),A,this)})))}},{key:"read",value:function(A,I){return v(this,void 0,void 0,f.mark((function C(){var B=this;return f.wrap((function(C){for(;;)switch(C.prev=C.next){case 0:return C.abrupt("return",new Promise((function(C,c){if(B.exists()){if(B._isEOF){var l=new Error("EOF");return l.name="EndOfFile",void c(l)}var d=0,Z=Math.min(A*I,B._meta.size),i=Z-Z%A,b=new Uint8Array(i),G=B._cache.get(i);if(G){if(d+=G.length,B._pageOffset+=G.length,B._pageOffset===B._pageSize&&(B._pagePtr+=1,B._pageOffset=0),i===d)return void C(G);b.set(G)}var X=IDBKeyRange.bound("".concat(B._path,"-").concat(g.createPage(B._pagePtr)),"".concat(B._path,"-").concat(g.createPage(B._pagePtr+Math.floor(i/B._pageSize)+1))),Q=B._store,m=Q.openCursor(X);m.onsuccess=function(){var A,I,g=m.result;if(g&&!B._isEOF){var C=Math.min(i-d,g.value.length-B._pageOffset);b.set(g.value.slice(B._pageOffset,B._pageOffset+C),d),d+=C,B._pageOffset+=C,B._pageOffset===B._pageSize&&(B._pagePtr+=1,B._pageOffset=0),d<i?g.continue():(0!==B._pageOffset?B._cache.set(B._pageOffset,g.value):B._cache.clear(),(null===(A=Q.transaction)||void 0===A?void 0:A.commit)&&(null===(I=Q.transaction)||void 0===I||I.commit()))}},Q.transaction.onerror=function(){c(Q.transaction.error)},Q.transaction.oncomplete=function(){C(b.slice(0,d))}}else c(new Error("'".concat(B._path,"' doesn't exist.")))})));case 1:case"end":return C.stop()}}),C)})))}},{key:"write",value:function(A){var I=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return v(this,void 0,void 0,f.mark((function C(){var B=this;return f.wrap((function(C){for(;;)switch(C.prev=C.next){case 0:return C.abrupt("return",new Promise((function(C,c){return v(B,void 0,void 0,f.mark((function B(){var l,d,Z,i,b,G,X,Q,m,a,y,n=this;return f.wrap((function(B){for(;;)switch(B.prev=B.next){case 0:if("readonly"!==this._mode){B.next=3;break}return c(new Error("Instance is readonly mode only.")),B.abrupt("return");case 3:if(!("number"!=typeof I&&I<=0)){B.next=6;break}return c(new Error("Version should be a positive number")),B.abrupt("return");case 6:return Z=this._store,i=function(){return new Promise((function(A){var I=Z.get("".concat(n._path,"-").concat(g.createPage(n._pagePtr)));I.onsuccess=function(){void 0!==I.result?A(I.result.slice(0,n._pageOffset)):A(new Uint8Array(0))}}))},B.next=10,i();case 10:for(b=B.sent,(G=new Uint8Array(b.length+A.length)).set(b),G.set(A,b.length),X=this._pagePtr*this._pageSize+G.length,Q={size:X,numPages:Math.ceil(X/this._pageSize),version:I,pageSize:this._pageSize},Z.put(Q,this._path),m=Math.ceil(G.length/this._pageSize),a=0;a<m;a++)Z.put(G.slice(a*this._pageSize,(a+1)*this._pageSize),"".concat(this._path,"-").concat(g.createPage(this._pagePtr+a)));this.exists()&&Q.numPages<this._meta.numPages&&(y=IDBKeyRange.bound("".concat(this._path,"-").concat(g.createPage(Q.numPages)),"".concat(this._path,"-").concat(g.createPage(this._meta.numPages)),!0),Z.delete(y)),(null===(l=Z.transaction)||void 0===l?void 0:l.commit)&&(null===(d=Z.transaction)||void 0===d||d.commit()),Z.transaction.onerror=function(){c(Z.transaction.error)},Z.transaction.oncomplete=function(){n._meta=Q,n.seek(0,2),C()};case 23:case"end":return B.stop()}}),B,this)})))})));case 1:case"end":return C.stop()}}),C)})))}},{key:"seek",value:function(A,I){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(A<0){var g=new Error("EOF");throw g.name="EndOfFile",g}var C;if(0===I)C=Math.min(A,this._meta.size);else if(1===I){var B=this._pageSize*this._pagePtr+this._pageOffset;C=Math.min(B+A,this._meta.size)}else{if(2!==I)throw new Error("Invalid operation: ".concat(I,"."));C=Math.min(this._meta.size+A,this._meta.size)}this._pageOffset=C%this._pageSize,this._pagePtr=Math.floor(C/this._pageSize),this._cache.clear()}},{key:"tell",value:function(){return this.exists()?this._pagePtr*this._pageSize+this._pageOffset:-1}},{key:"remove",value:function(){return v(this,void 0,void 0,f.mark((function A(){var I=this;return f.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.abrupt("return",new Promise((function(A,C){return v(I,void 0,void 0,f.mark((function I(){var B,c,l,d,Z=this;return f.wrap((function(I){for(;;)switch(I.prev=I.next){case 0:if(this.exists()){I.next=3;break}return C(new Error("ENOENT")),I.abrupt("return");case 3:B=this._meta.numPages,c=IDBKeyRange.bound(this._path,"".concat(this._path,"-").concat(g.createPage(B))),l=this._store,(d=l.delete(c)).onerror=function(){C(d.error)},d.onsuccess=function(){Z._meta=void 0,Z._pageOffset=0,Z._pagePtr=0,A()};case 9:case"end":return I.stop()}}),I,this)})))})));case 1:case"end":return A.stop()}}),A)})))}},{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(CA,this._mode).objectStore(CA)}}],[{key:"open",value:function(A,I){var C=this;if(!self.indexedDB){var B=new Error("IndexedDB is not supported");throw B.name="IndexedDBNotSupported",B}return new Promise((function(B,c){return v(C,void 0,void 0,f.mark((function C(){var l,d,Z;return f.wrap((function(C){for(;;)switch(C.prev=C.next){case 0:return C.prev=0,C.next=3,new Promise((function(A,I){var g=self.indexedDB.open("pv_db",3);g.onerror=function(){I(g.error)},g.onsuccess=function(){A(g.result)},g.onupgradeneeded=function(){g.result.objectStoreNames.contains(CA)||g.result.createObjectStore(CA)}}));case 3:l=C.sent,(d=l.transaction(CA,"readwrite").objectStore(CA).get(A)).onerror=function(){c(d.error)},d.onsuccess=function(){var C=d.result,Z=I.includes("r")?"readonly":"readwrite";if(void 0===C&&"readonly"===Z){var i=new Error("'".concat(A,"' doesn't exist."));return i.name="FileNotExists",void c(i)}var b=new g(A,C,l,Z);I.includes("a")&&b.seek(0,2),B(b)},C.next=12;break;case 9:C.prev=9,C.t0=C.catch(0),"InvalidStateError"===C.t0.name?((Z=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",c(Z)):c(C.t0);case 12:case"end":return C.stop()}}),C,null,[[0,9]])})))}))}},{key:"createPage",value:function(A){return("00000"+A).slice(-6)}}]),g}();function lA(A){var I=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(A){return!1}}();return function(){var g,C=P(A);if(I){var B=P(this).constructor;g=Reflect.construct(C,arguments,B)}else g=C.apply(this,arguments);return O(this,g)}}var dA=function(A){L(g,IA);var I=lA(g);function g(A,C,B,c){var l;return _(this,g),(l=I.call(this))._pos=0,l._path=A,l._meta=C,l._mode=c,l}return AA(g,[{key:"close",value:function(){}},{key:"read",value:function(A,I){if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(this._isEOF){var g=new Error("EOF");throw g.name="EndOfFile",g}var C=Math.min(A*I,this._file.length-this._pos),B=C-C%A,c=new Uint8Array(B);return c.set(this._file.slice(this._pos,this._pos+B),0),this._pos+=B,c}},{key:"write",value:function(A){var I=new Uint8Array(this._pos+A.length);void 0!==this._file?(I.set(this._file.slice(0,this._pos)),I.set(A,this._pos)):I.set(A),this._file=I,this._pos+=A.length}},{key:"seek",value:function(A,I){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(A<0){var g=new Error("EOF");throw g.name="EndOfFile",g}var C;if(0===I)C=Math.min(A,this._file.length);else if(1===I)C=Math.min(this._pos+A,this._file.length);else{if(2!==I)throw new Error("Invalid operation: ".concat(I,"."));C=Math.min(this._file.length+A,this._file.length)}this._pos=C}},{key:"tell",value:function(){return this.exists()?this._pos:-1}},{key:"remove",value:function(){return v(this,void 0,void 0,f.mark((function A(){return f.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:if(this.exists()){A.next=2;break}throw new Error("ENOENT");case 2:g._memFiles.delete(this._path),this._pos=0;case 4:case"end":return A.stop()}}),A,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 g._memFiles.get(this._path)},set:function(A){g._memFiles.set(this._path,A)}}],[{key:"open",value:function(A,I){var C=g._memFiles.get(A),B=I.includes("r")?"readonly":"readwrite";if(void 0===C&&"readonly"===B){var c=new Error("'".concat(A,"' doesn't exist."));throw c.name="FileNotExists",c}var l=new g(A,void 0,void 0,B);return I.includes("a")&&l.seek(0,2),l}}]),g}();function ZA(A,I){for(var g=I;0!==A[g];)g++;return new TextDecoder("utf-8").decode(A.slice(I,g))}function iA(A){for(var I=atob(A),g=new Uint8Array(I.length),C=0;C<I.length;C++)g[C]=I.charCodeAt(C);return g}function bA(A){if("string"!=typeof A)return!1;var I=A.trim();if(""===I)return!1;try{return btoa(atob(I))===I}catch(A){return!1}}function GA(A,I){return v(this,void 0,void 0,f.mark((function g(){var C;return f.wrap((function(g){for(;;)switch(g.prev=g.next){case 0:return g.prev=0,g.next=3,cA.open(A,I);case 3:return g.abrupt("return",g.sent);case 6:if(g.prev=6,g.t0=g.catch(0),"IndexedDBNotSupported"===g.t0.name?console.warn("IndexedDB is not supported. Fallback to in-memory storage."):"FileNotExists"!==g.t0.name&&console.warn("Unable to access IndexedDB (".concat(g.t0.toString(),"). Fallback to in-memory storage.")),!("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope)){g.next=16;break}if("FileNotExists"!==g.t0.name){g.next=12;break}throw g.t0;case 12:throw console.error("In-memory storage cannot be used inside a worker."),(C=new Error("Failed to start PvFile: ".concat(g.t0.toString()))).name="PvFileNotSupported",C;case 16:return g.abrupt("return",dA.open(A,I));case 17:case"end":return g.stop()}}),g,null,[[0,6]])})))}function XA(A,I,g,C){return v(this,void 0,void 0,f.mark((function B(){var c;return f.wrap((function(B){for(;;)switch(B.prev=B.next){case 0:return B.next=2,GA(A,"w");case 2:if(c=B.sent,!(g||void 0===c.meta||C>c.meta.version||c.meta.pageSize!==c.pageSize)){B.next=6;break}return B.next=6,c.write(iA(I),C);case 6:case"end":return B.stop()}}),B)})))}dA._memFiles=new Map;var QA=5e3,mA=2;function aA(A,I,g,C,B){return v(this,void 0,void 0,f.mark((function c(){var l,d,Z,i,b,G,X,Q;return f.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,GA(A,"w");case 2:if(l=c.sent,!(g||void 0===l.meta||C>l.meta.version||l.meta.pageSize!==l.pageSize)){c.next=43;break}if(!(B<0)){c.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:d=mA,Z=function(A){return new Promise((function(I){setTimeout(I,A)}))},i=B+1,b=null;case 10:if(!(i>0)){c.next=38;break}return b=null,c.prev=12,c.next=15,fetch(I,{cache:"no-cache"});case 15:if(!(G=c.sent).ok){c.next=23;break}return c.next=19,G.arrayBuffer();case 19:return X=c.sent,c.next=22,l.write(new Uint8Array(X),C);case 22:return c.abrupt("return");case 23:return c.next=25,G.text();case 25:Q=c.sent,b=new Error("Error response returned while fetching model from '".concat(I,"': ").concat(Q)),c.next=32;break;case 29:c.prev=29,c.t0=c.catch(12),b=new Error("Failed to fetch model from '".concat(I,"': ").concat(c.t0.message));case 32:return i--,c.next=35,Z(d);case 35:d=Math.min(QA,d*mA),c.next=10;break;case 38:if(null===b){c.next=42;break}throw b;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(I,"'"));case 43:case"end":return c.stop()}}),c,null,[[12,29]])})))}function yA(A){return v(this,void 0,void 0,f.mark((function I(){var g,C,B,c,l,d,Z,i,b;return f.wrap((function(I){for(;;)switch(I.prev=I.next){case 0:if(null!=A){I.next=2;break}throw new Error("The model is undefined / empty");case 2:if(g=A.base64,C=A.publicPath,B=A.customWritePath,c=A.forceWrite,l=void 0!==c&&c,d=A.version,Z=void 0===d?1:d,i=A.numFetchRetries,b=void 0===i?0:i,null!=B){I.next=5;break}throw new Error("The customWritePath of the provided model is undefined / empty");case 5:if(null==g){I.next=10;break}return I.next=8,XA(B,g,l,Z);case 8:case 13:I.next=16;break;case 10:if(null==C){I.next=15;break}return I.next=13,aA(B,C,l,Z,b);case 15:throw new Error("The provided model doesn't contain a valid publicPath or base64 value");case 16:return I.abrupt("return",B);case 17:case"end":return I.stop()}}),I)})))}function nA(A,I){(null==I||I>A.length)&&(I=A.length);for(var g=0,C=new Array(I);g<I;g++)C[g]=A[g];return C}function sA(A,I){if(A){if("string"==typeof A)return nA(A,I);var g=Object.prototype.toString.call(A).slice(8,-1);return"Object"===g&&A.constructor&&(g=A.constructor.name),"Map"===g||"Set"===g?Array.from(A):"Arguments"===g||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(g)?nA(A,I):void 0}}function oA(A,I){return function(A){if(Array.isArray(A))return A}(A)||function(A,I){var g=null==A?null:"undefined"!=typeof Symbol&&A[Symbol.iterator]||A["@@iterator"];if(null!=g){var C,B,c,l,d=[],Z=!0,i=!1;try{if(c=(g=g.call(A)).next,0===I){if(Object(g)!==g)return;Z=!1}else for(;!(Z=(C=c.call(g)).done)&&(d.push(C.value),d.length!==I);Z=!0);}catch(A){i=!0,B=A}finally{try{if(!Z&&null!=g.return&&(l=g.return(),Object(l)!==l))return}finally{if(i)throw B}}return d}}(A,I)||sA(A,I)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var VA,RA,EA,tA=(RA="undefined"!=typeof document?null===(VA=document.currentScript)||void 0===VA?void 0:VA.src:void 0,function(){var A,I,g=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},C=new Promise((function(g,C){A=g,I=C})),B="object"==("undefined"==typeof window?"undefined":R(window)),c="function"==typeof importScripts;function l(A){return l="function"==typeof Symbol&&"symbol"==R(Symbol.iterator)?function(A){return R(A)}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":R(A)},l(A)}function d(A){var I=function(A,I){if("object"!=l(A)||!A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!=l(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"==l(I)?I:I+""}function Z(A,I,g){return(I=d(I))in A?Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}):A[I]=g,A}function i(A,I,g,C,B,c,l){try{var d=A[c](l),Z=d.value}catch(A){return void g(A)}d.done?I(Z):Promise.resolve(Z).then(C,B)}function b(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var c=A.apply(I,g);function l(A){i(c,C,B,l,d,"next",A)}function d(A){i(c,C,B,l,d,"throw",A)}l(void 0)}))}}function G(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}"object"==("undefined"==typeof process?"undefined":R(process))&&"object"==R(process.versions)&&process.versions.node;var X={exports:{}},Q={exports:{}};!function(A){function I(g){return A.exports=I="function"==typeof Symbol&&"symbol"==R(Symbol.iterator)?function(A){return R(A)}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":R(A)},A.exports.__esModule=!0,A.exports.default=A.exports,I(g)}A.exports=I,A.exports.__esModule=!0,A.exports.default=A.exports}(Q);var m=Q.exports;G(m),function(A){var I=m.default;function g(){A.exports=g=function(){return B},A.exports.__esModule=!0,A.exports.default=A.exports;var C,B={},c=Object.prototype,l=c.hasOwnProperty,d=Object.defineProperty||function(A,I,g){A[I]=g.value},Z="function"==typeof Symbol?Symbol:{},i=Z.iterator||"@@iterator",b=Z.asyncIterator||"@@asyncIterator",G=Z.toStringTag||"@@toStringTag";function X(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{X({},"")}catch(C){X=function(A,I,g){return A[I]=g}}function Q(A,I,g,C){var B=I&&I.prototype instanceof V?I:V,c=Object.create(B.prototype),l=new w(C||[]);return d(c,"_invoke",{value:e(A,g,l)}),c}function m(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=Q;var a="suspendedStart",y="suspendedYield",n="executing",s="completed",o={};function V(){}function R(){}function E(){}var t={};X(t,i,(function(){return this}));var W=Object.getPrototypeOf,h=W&&W(W(p([])));h&&h!==c&&l.call(h,i)&&(t=h);var Y=E.prototype=V.prototype=Object.create(t);function F(A){["next","throw","return"].forEach((function(I){X(A,I,(function(A){return this._invoke(I,A)}))}))}function u(A,g){function C(B,c,d,Z){var i=m(A[B],A,c);if("throw"!==i.type){var b=i.arg,G=b.value;return G&&"object"==I(G)&&l.call(G,"__await")?g.resolve(G.__await).then((function(A){C("next",A,d,Z)}),(function(A){C("throw",A,d,Z)})):g.resolve(G).then((function(A){b.value=A,d(b)}),(function(A){return C("throw",A,d,Z)}))}Z(i.arg)}var B;d(this,"_invoke",{value:function(A,I){function c(){return new g((function(g,B){C(A,I,g,B)}))}return B=B?B.then(c,c):c()}})}function e(A,I,g){var B=a;return function(c,l){if(B===n)throw Error("Generator is already running");if(B===s){if("throw"===c)throw l;return{value:C,done:!0}}for(g.method=c,g.arg=l;;){var d=g.delegate;if(d){var Z=J(d,g);if(Z){if(Z===o)continue;return Z}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===a)throw B=s,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=n;var i=m(A,I,g);if("normal"===i.type){if(B=g.done?s:y,i.arg===o)continue;return{value:i.arg,done:g.done}}"throw"===i.type&&(B=s,g.method="throw",g.arg=i.arg)}}}function J(A,I){var g=I.method,B=A.iterator[g];if(B===C)return I.delegate=null,"throw"===g&&A.iterator.return&&(I.method="return",I.arg=C,J(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),o;var c=m(B,A.iterator,I.arg);if("throw"===c.type)return I.method="throw",I.arg=c.arg,I.delegate=null,o;var l=c.arg;return l?l.done?(I[A.resultName]=l.value,I.next